@spiffcommerce/core 34.2.0 → 34.3.0-beta.30ca33a3-7b27-57c0-87b4-33dd497ec9b8
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.d.ts +5 -1
- package/dist/index.js +186 -177
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +804 -757
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var pi=Object.create;var ln=Object.defineProperty;var fi=Object.getOwnPropertyDescriptor;var Ci=Object.getOwnPropertyNames;var wi=Object.getPrototypeOf,yi=Object.prototype.hasOwnProperty;var Si=(n,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ci(t))!yi.call(n,r)&&r!==e&&ln(n,r,{get:()=>t[r],enumerable:!(a=fi(t,r))||a.enumerable});return n};var vi=(n,t,e)=>(e=n!=null?pi(wi(n)):{},Si(t||!n||!n.__esModule?ln(e,"default",{value:n,enumerable:!0}):e,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("@apollo/client/core"),Ei=require("@apollo/client/link/context"),bi=require("@apollo/client/link/error"),Ii=require("preact-render-to-string"),Bi=require("@apollo/client/link/remove-typename"),Pi=require("exifr/dist/mini.umd.cjs"),Qn=require("css"),xi=require("fuse.js"),Ta=require("pith"),It=require("lodash.clonedeep"),te=require("lodash.isequal"),B=require("preact/jsx-runtime"),ga=require("opentype.js"),Fi=require("handlebars"),Di=require("data-uri-to-buffer"),Rn=require("qrcode"),ma=require("unicode-default-word-boundary"),ki=require("svg-path-bbox"),pa=require("lodash.chunk"),we=require("@aws-sdk/client-cognito-identity-provider"),Mi=require("dinero.js"),Ti=require("currency-codes"),On=require("lodash.debounce");require("fs");require("path");const Ni=require("lodash.omit");function Qi(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const cn=Qi(Ti);var ee=(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))(ee||{}),$n=(n=>(n.AND="AND",n.OR="OR",n))($n||{}),z=(n=>(n.FileUpload="FileUpload",n.Option="Option",n.ColorOption="ColorOption",n.Text="Text",n))(z||{}),b=(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))(b||{}),Un=(n=>(n.Color="Color",n.Colors="Colors",n.Selection="Selection",n.Selections="Selections",n.Text="Text",n.Upload="Upload",n))(Un||{}),Nt=(n=>(n.ThreeD="ThreeD",n.FreeDesign="FreeDesign",n.Print="Print",n))(Nt||{}),F=(n=>(n.Frame="frame",n.Group="group",n.Image="image",n.Pattern="pattern",n.Illustration="illustration",n.Textbox="textbox",n))(F||{}),Ln=(n=>(n.Default="Default",n.FirstTransaction="FirstTransaction",n.OneToOne="OneToOne",n))(Ln||{}),Na=(n=>(n.Pending="Pending",n.Failed="Failed",n.Validated="Validated",n.Overridden="Overridden",n))(Na||{}),Vn=(n=>(n.Hyperlink="Hyperlink",n.Edit="Edit",n.Approve="Approve",n))(Vn||{}),zn=(n=>(n.Hub="Hub",n.Shopify="Shopify",n))(zn||{}),$e=(n=>(n.BackgroundRemover="BackgroundRemover",n.ConversionAccelerator="Conversion Accelerator",n.ProcessBuilder="ProcessBuilder",n))($e||{}),qn=(n=>(n[n.Orbit=0]="Orbit",n[n.Pan=1]="Pan",n))(qn||{}),ae=(n=>(n.Owner="Owner",n.Approver="Approver",n.Editor="Editor",n.Viewer="Viewer",n))(ae||{}),Bt=(n=>(n.Autosize="Autosize",n.Traditional="Traditional",n))(Bt||{}),H=(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))(H||{}),Gn=(n=>(n.Pixel="px",n.Millimeter="mm",n.Centimeter="cm",n))(Gn||{});class jn extends Error{constructor(t){super(t),this.name=this.constructor.name}}class se extends jn{constructor(t){super(`ConfigurationError - ${t}`)}}class ne extends se{constructor(t){super(`Option not Configured: ${t.stepTitle}`),this.optionId=t?.optionId||"N/A"}}class J extends se{constructor(t){super(`Panel not Found: ${t.panelId}`),this.panelId=t?.panelId||"N/A"}}class ft extends se{constructor(t){super(`Asset not found for variant: ${t.name}`),this.variant=t}}class Qt extends se{constructor(t){super(`Resource not found for asset: ${t.name}`),this.asset=t}}class re extends se{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),this.step=t}}class Ue extends jn{constructor(t){super(`ImplementationError - ${t}`)}}class Q extends Ue{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class Et extends Ue{constructor(t){super(`Parsing Error: ${t}`)}}class mt extends Ue{constructor(t){super(`Client Error: ${t}`)}}class Le extends Ue{constructor(t){super(`Resource Generation Failed: ${t}`)}}class Ri{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 dn{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 Oi=()=>{try{return localStorage?new Ri:new dn}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new dn}},D=Oi();class $i{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 ut=new $i;let fa,Ca;function Ui(n){fa=n}function Li(n){Ca=n}function le(){return fa?new fa().window:(console.log("DOM constructor is not registered. Assuming browser environment. If not, please register DOM constructor before calling this function."),window)}function rt(n,t){if(!Ca){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 Ca(n,t)}const Wn=new Map,un=new Map,An=new Map,Hn=async n=>{const t=un.get(n);if(t)return t;const a=(async()=>{const r=await rt(n);return Wn.set(n,r.headers?.get("content-type")||""),await r.arrayBuffer()})();return un.set(n,a),a},Vi=async n=>{const t=An.get(n);if(t)return t;const a=(async()=>await(await rt(n)).text())();return An.set(n,a),a},Ut=n=>n.every(t=>t!=="undefined"),ye=n=>Ut([typeof document])?document.createElement(n):le().document.createElement(n),zi=(n,t)=>{if(Ut([typeof document]))return document.createElementNS(n,t);const a=le().document.createElement(t);return a.setAttribute("xmlns",n),a},lt=()=>{if(Ut([typeof DOMParser]))return new DOMParser;const n=le();return new n.DOMParser},qi=()=>Ut([typeof DOMParser])?DOMParser:le().DOMParser,Ve=(n,t)=>new Promise((e,a)=>{t?Hn(n).then(e).catch(a):rt(n).then(r=>{r.arrayBuffer().then(e).catch(a)}).catch(r=>{a(r)})}),et=(n,t)=>new Promise((e,a)=>{t?Vi(n).then(e).catch(a):rt(n).then(r=>{r.text().then(e).catch(a)}).catch(a)}),Yn=n=>Ii.renderToStaticMarkup(n),ta=new Map,Gi=async(n,t)=>{if(Ut([typeof FontFace])){if(ta.has(t))return ta.get(t);const e=n.names.fullName.en,a=new FontFace(e,`url(${t})`);document.fonts.add(a);const r=a.load();return ta.set(t,r),r}},St=()=>{if(Ut([typeof XMLSerializer]))return new XMLSerializer;const n=le();return new n.XMLSerializer},hn=n=>btoa(n),ze=n=>{function t(){const a=new Uint8Array(n),r=4;if(a.length>=r){const i=new Array(r);for(let l=0;l<r;l++)i[l]=new Uint8Array(n)[l].toString(16);const o=i.join("").toUpperCase();switch(o){case"89504E47":return"image/png";case"47494638":return"image/gif";case"25504446":return"application/pdf";case"504B0304":return"application/zip"}switch(o.slice(0,4)){case"FFD8":return"image/jpeg"}}return null}const e=t();return e||"image/svg+xml"},ji=async n=>{const t=await Hn(n),e=Wn.get(n)||ze(t);return await Yi(new Blob([t],{type:e}))},Wi=n=>{let t="";const e=n.byteLength;for(let a=0;a<e;a++)t+=String.fromCharCode(n[a]);return t},Hi=async n=>{const t=ze(n),e=new Uint8Array(n),a=Wi(e),r=btoa(a);return`data:${t};base64,${r}`},qe=n=>`data:image/svg+xml;base64,${btoa(n)}`,Jn=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 r=!1;for(let o=1;o<a.length;o++)a[o]==="base64"&&(r=!0);const i=decodeURI(t.substring(e+1));return r?new Uint8Array(atob(i).split("").map(s=>s.charCodeAt(0))).buffer:new Uint8Array(i.split("").map(s=>s.charCodeAt(0))).buffer},Yi=n=>new Promise((t,e)=>{const a=new FileReader;a.onload=function(r){const i=r.target;!i||!i.result?e():t(i.result.toString())},a.readAsDataURL(n)});let Ji,Qa;const Ki=n=>{Qa=n},_i=()=>Qa;let Kn;const _n=n=>{Kn=n},Xi=()=>new Promise(n=>{const t=ut.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))}),Zi=async()=>{const n={applicationKey:Qa,customerToken:Ji,bearer:Kn};return typeof window<"u"&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await Xi(),...n}:n};async function to(n,t){const e=ut.getServerUrl(),a=e.includes(".aumelbdev.spiffcommerce.com")?"https://moonlight.aumelbdev.spiffcommerce.com":e.includes(".us.spiffcommerce.com")?"https://moonlight.us.spiffcommerce.com":"https://moonlight.au.spiffcommerce.com";let r=await rt(n,{...t,redirect:"manual"});return r.type==="opaqueredirect"&&(typeof n!="string"&&"url"in n?r=await rt({...n,url:`${a}/graphql`},t):r=await rt(`${a}/graphql`,t)),r}class eo{constructor(){this.shadowGraphqlClient=this.constructShadowGraphqlClient(),ut.addServerUrlCallback(()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()})}setSpiffCommerceClient(t){this.spiffClient=t,this.shadowGraphqlClient=this.constructShadowGraphqlClient()}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const t=C.createHttpLink({uri:`${ut.getServerUrl()}/graphql`,fetch:to}),e=Ei.setContext(async(i,o)=>{const{headers:s}=o,l=s||{},c=await Zi();let d=o.bearer??c.bearer;if(this.spiffClient)try{d=await this.spiffClient.loggedInBearerToken()}catch{}const u=o.partnerId??c.partnerId,A=o.activeIntegration??c.activeIntegration,h=o.transactionOwnerId,g=o.customerToken??c.customerToken,m=o.applicationKey??c.applicationKey,p=o.bundleOwnerId;try{if(window&&window.__SENTRY__){const f=window.__SENTRY__.hub;if(f){const S=f.traceHeaders();Object.entries(S).forEach(([w,x])=>{l[w]=x})}}}catch{}return d&&(l.Authorization=`Bearer ${d}`),u&&(l.partnerId=u),A&&(l.activeIntegration=A),h&&(l.transactionOwnerId=h),g&&(l.customerToken=g),m&&(l["X-Application-Key"]=m),p&&(l.bundleOwnerId=p),l["Allow-Moonlight-Redirect"]="true",{headers:l}}),a=bi.onError(({operation:i,graphQLErrors:o,networkError:s})=>{const l=o||[],c=i.getContext();s&&!c?.fetchOptions?.signal?.aborted&&console.log("GraphQL Network error"),l.forEach(()=>console.log("GraphQL Error: "+i.operationName))}),r=Bi.removeTypenameFromVariables();return new C.ApolloClient({link:C.from([r,a,e,t]),cache:new C.InMemoryCache,name:"Core"})}}const y=new eo;let wa,ya;const Ct=(n,t,e)=>{if(wa!==void 0)return wa(n,t,e);try{const a=Xn(!0);return Ra(a),a.createCanvas(n,t,e)}catch{throw new Error("Canvas module not set")}},ce=(n,t)=>{if(ya!==void 0)return ya(n,t);try{const e=Xn(!0);return Ra(e),e.loadImage(n,t)}catch{throw new Error("Canvas module not set")}};function Ra(n){wa=n?.createCanvas,ya=n?.loadImage}function Xn(n){try{if(document.createElement("canvas").getContext("2d"))return{createCanvas:(e,a,r)=>{const i=document.createElement("canvas");return e!=null&&(i.width=e),a!=null&&(i.height=a),i},loadImage:(e,a)=>new Promise((r,i)=>{const o=document.createElement("img");a!==!1&&(o.crossOrigin="Anonymous"),o.onload=()=>{r(o)},o.onerror=i,o.src=e})}}catch(t){throw t}}let ea;function Oa(){return ea===void 0&&(ea=qi()),ea}let Se=null;const ao=n=>new Promise(t=>{if(ze(n)!=="image/jpeg")return t(1);Pi.orientation(n).then(a=>t(a||1)).catch(()=>t(1))}),no=async()=>{if(Se!==null)return!Se;const t=await ce("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return Se=t.width===2&&t.height===3,!Se},ro=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]},io=async n=>{const t=await Hi(n),e=await ce(t),[a,r]=ro(e);if(!await no()){const u=Ct(a,r);return u.getContext("2d")?.drawImage(e,0,0,a,r),u}const o=await ao(n),[s,l]=o>4?[r,a]:[a,r],c=Ct(s,l),d=c.getContext("2d");switch(o){case 2:d.translate(s,0),d.scale(-1,1);break;case 3:d.translate(s,l),d.rotate(Math.PI);break;case 4:d.translate(0,l),d.scale(1,-1);break;case 5:d.rotate(-.5*Math.PI),d.scale(-1,1);break;case 6:d.rotate(-.5*Math.PI),d.translate(-s,0);break;case 7:d.rotate(-.5*Math.PI),d.translate(-s,l),d.scale(1,-1);break;case 8:d.rotate(.5*Math.PI),d.translate(0,-l);break}return d.drawImage(e,0,0,s,l),c},de=async n=>{const t=await io(n);return ze(n)==="image/jpeg"?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}},ie=["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"],Rt=["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"],aa=Rt.map(n=>[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]);function oo(n){const t=ie.indexOf(n);return t>=0?Rt[t]:""}function Zn(n){const t=Rt.indexOf(n);return t>=0?ie[t]:""}function so(n,t=64){const e=[],a=[],r=Zn(n);r&&e.push({pms:r,hex:n,distance:0});const i=parseInt(n.substring(0,2),16),o=parseInt(n.substring(2,4),16),s=parseInt(n.substring(4,6),16);let l,c,d;for(let u=0;u<Rt.length;u++){l=aa[u][0],c=aa[u][1],d=aa[u][2];const A=Math.sqrt(Math.pow(i-l,2)+Math.pow(o-c,2)+Math.pow(s-d,2));a.push(A)}for(let u=0;u<a.length;u++)a[u]<=t&&!e.some(A=>A.pms===ie[u])&&e.push({pms:ie[u],hex:Rt[u],distance:a[u]});return e.sort((u,A)=>u.distance-A.distance)}const lo=ie.map((n,t)=>({pms:n,hex:Rt[t]})),co=new xi(lo,{keys:["pms"]});function uo(n,t){return co.search(n,t?{limit:t}:void 0)}let Lt=null;function tr(n){if(n.startsWith("#"))return gn(n);if(!document)throw new Error("browserColorToHex is only supported on browsers");if(Lt||(Lt=document.createElement("canvas").getContext("2d")),!Lt)throw new Error("Failed to create canvas context required to convert colors");Lt.fillStyle=n;const t=gn(Lt.fillStyle);return t||console.error(`Unknown browser color ${n}`),t}function gn(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 ve=n=>{const t=er(n.spotColor);return t?`${n.browserValue} ${t}`:n.browserValue},er=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})`},Sa=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]}}},Ao=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],ho=["fill","stroke"],Ot=(n,t)=>{t(n),n.children.length>0&&Array.from(n.children).forEach(e=>Ot(e,t))},ar=(n,t)=>{const e=t(n);if(e)return e;const a=n.parentElement;if(a)return ar(a,t)},go=(n,t)=>{try{return n.matches(t)}catch{return n.classList.contains(t.substring(1))}},Ge=(n,t=!1)=>{!t&&n.setAttribute("preserveAspectRatio","none");const e=[];Ot(n,a=>{if(a.tagName==="script"){a.remove();return}if(a.tagName==="style"){try{Qn.parse(a.innerHTML).stylesheet?.rules.forEach(o=>{e.push(o)}),a.remove()}catch(i){console.error(i)}return}const r=a.attributes.getNamedItem("style")?.value?.trim();if(r){const i=[];r.split(";").forEach(s=>{const l=s.trim();if(l){const[c,d]=l.split(":"),u=c.toLowerCase();ho.indexOf(u)>-1?a.setAttribute(u,d.trim()):i.push(l)}}),i.length>0?a.setAttribute("style",i.join(";")):a.removeAttribute("style")}}),Ot(n,a=>{e.forEach(r=>{r.selectors?.forEach(i=>{go(a,i)&&r.declarations?.forEach(o=>{o.property&&o.value&&a.setAttribute(o.property,o.value)})})})})},mo=n=>{const t=/pt|pc|mm|cm|in/gm,e=n.getAttribute("viewBox"),a=n.getAttribute("width"),r=n.getAttribute("height");if(!e)throw new Error("viewBox not specified on SVG!");a&&n.setAttribute("width",a.replace(t,"")),r&&n.setAttribute("height",r.replace(t,""))},nr=n=>lt().parseFromString(n,"image/svg+xml").firstElementChild,po=(n,t,e)=>{n.setAttribute("height",`${e}px`),n.setAttribute("width",`${t}px`)},rr=(n,t,e)=>{Ot(n,a=>{const r=a.attributes.getNamedItem("fill");r&&r.value!=="none"&&a.classList.forEach(o=>{if(o.startsWith("spiff-fill")){const s=t[o.replace("spiff-fill-","")];if(s)a.setAttribute("fill",e?ve(s):s.browserValue);else{const l=t[o];l&&a.setAttribute("fill",e?ve(l):l.browserValue)}}});const i=a.attributes.getNamedItem("stroke");i&&i.value!=="none"&&a.classList.forEach(o=>{if(o.startsWith("spiff-stroke")){const s=t[o.replace("spiff-stroke-","")];if(s)a.setAttribute("stroke",e?ve(s):s.browserValue);else{const l=t[o];l&&a.setAttribute("fill",e?ve(l):l.browserValue)}}})})},ir=n=>St().serializeToString(n),$a=(n,t,e,a,r)=>{const i=nr(n);if(!i)throw new Error("Failed to read SVG.");return po(i,t,e),rr(i,a,r),ir(i)},je=(n,t,e)=>{const a=nr(n);if(!a)throw new Error("Failed to read SVG.");return rr(a,t,e),ir(a)},fo=n=>{const t=/<svg.*<\/svg>/s,e=n.match(t)||[],a=e?.length>0?e[0]:"";return lt().parseFromString(a,"image/svg+xml")},it=async n=>{const e=fo(n).firstElementChild;if(!e)throw new Error("Failed to read SVG.");Ge(e);const a={};Ot(e,o=>{if(Ao.includes(o.tagName)&&!o.attributes.getNamedItem("fill")){let c="black";const d=o.parentElement;if(d){const u=ar(d,A=>{const g=A.style.fill;if(g)return g;const m=A.getAttribute("fill");if(m)return m});u&&(c=u)}o.setAttribute("fill",c)}const s=o.attributes.getNamedItem("fill");if(s&&s.value!=="none"&&!s.value.startsWith("url(")){const c=Sa(s.value),d=c.browserValue.replace(/\W/g,""),u=`spiff-fill-${d}`;o.setAttribute("fill",c.browserValue),o.classList.add(u),a[d]=c}const l=o.attributes.getNamedItem("stroke");if(l&&l.value!=="none"&&!l.value.startsWith("url(")){const c=Sa(l.value),d=c.browserValue.replace(/\W/g,""),u=`spiff-stroke-${d}`;o.classList.add(u),o.setAttribute("stroke",c.browserValue),a[d]=c}});const i=St().serializeToString(e);return{colors:a,svg:i}},Co=C.gql`
|
|
1
|
+
"use strict";var fi=Object.create;var la=Object.defineProperty;var Ci=Object.getOwnPropertyDescriptor;var wi=Object.getOwnPropertyNames;var yi=Object.getPrototypeOf,Si=Object.prototype.hasOwnProperty;var vi=(a,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of wi(t))!Si.call(a,r)&&r!==e&&la(a,r,{get:()=>t[r],enumerable:!(n=Ci(t,r))||n.enumerable});return a};var Ei=(a,t,e)=>(e=a!=null?fi(yi(a)):{},vi(t||!a||!a.__esModule?la(e,"default",{value:a,enumerable:!0}):e,a));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("@apollo/client/core"),bi=require("@apollo/client/link/context"),Ii=require("@apollo/client/link/error"),Bi=require("preact-render-to-string"),Pi=require("@apollo/client/link/remove-typename"),xi=require("exifr/dist/mini.umd.cjs"),Qa=require("css"),Fi=require("fuse.js"),Nn=require("pith"),It=require("lodash.clonedeep"),te=require("lodash.isequal"),B=require("preact/jsx-runtime"),mn=require("opentype.js"),Di=require("handlebars"),ki=require("data-uri-to-buffer"),Ra=require("qrcode"),pn=require("unicode-default-word-boundary"),Mi=require("svg-path-bbox"),fn=require("lodash.chunk"),we=require("@aws-sdk/client-cognito-identity-provider"),Ti=require("dinero.js"),Ni=require("currency-codes"),Oa=require("lodash.debounce");require("fs");require("path");const Qi=require("lodash.omit");function Ri(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>a[e]})}}return t.default=a,Object.freeze(t)}const ca=Ri(Ni);var ee=(a=>(a.Data="Data",a.Font="Font",a.Frame="Frame",a.Illustration="Illustration",a.Image="Image",a.Model="Model",a.Material="Material",a.Color="Color",a.QuestionnaireCollateral="QuestionnaireCollateral",a.RequestCollateral="RequestCollateral",a.SignupCollateral="SignupCollateral",a.Video="Video",a.ColorProfile="ColorProfile",a.Environment="Environment",a))(ee||{}),$a=(a=>(a.AND="AND",a.OR="OR",a))($a||{}),z=(a=>(a.FileUpload="FileUpload",a.Option="Option",a.ColorOption="ColorOption",a.Text="Text",a))(z||{}),b=(a=>(a.Information="Information",a.Bulk="Bulk",a.DigitalContent="DigitalContent",a.Finish="Finish",a.Frame="Frame",a.Illustration="Illustration",a.Introduction="Introduction",a.Material="Material",a.Model="Model",a.Module="Module",a.Picture="Picture",a.Photo="Photo",a.ProductOverlay="ProductOverlay",a.Question="Question",a.Shape="Shape",a.SilentIllustration="SilentIllustration",a.Text="Text",a))(b||{}),Ua=(a=>(a.Color="Color",a.Colors="Colors",a.Selection="Selection",a.Selections="Selections",a.Text="Text",a.Upload="Upload",a))(Ua||{}),Nt=(a=>(a.ThreeD="ThreeD",a.FreeDesign="FreeDesign",a.Print="Print",a))(Nt||{}),F=(a=>(a.Frame="frame",a.Group="group",a.Image="image",a.Pattern="pattern",a.Illustration="illustration",a.Textbox="textbox",a))(F||{}),La=(a=>(a.Default="Default",a.FirstTransaction="FirstTransaction",a.OneToOne="OneToOne",a))(La||{}),Qn=(a=>(a.Pending="Pending",a.Failed="Failed",a.Validated="Validated",a.Overridden="Overridden",a))(Qn||{}),Va=(a=>(a.Hyperlink="Hyperlink",a.Edit="Edit",a.Approve="Approve",a))(Va||{}),za=(a=>(a.Hub="Hub",a.Shopify="Shopify",a))(za||{}),$e=(a=>(a.BackgroundRemover="BackgroundRemover",a.ConversionAccelerator="Conversion Accelerator",a.ProcessBuilder="ProcessBuilder",a))($e||{}),qa=(a=>(a[a.Orbit=0]="Orbit",a[a.Pan=1]="Pan",a))(qa||{}),ne=(a=>(a.Owner="Owner",a.Approver="Approver",a.Editor="Editor",a.Viewer="Viewer",a))(ne||{}),Bt=(a=>(a.Autosize="Autosize",a.Traditional="Traditional",a))(Bt||{}),H=(a=>(a[a.North=0]="North",a[a.Northeast=1]="Northeast",a[a.East=2]="East",a[a.Southeast=3]="Southeast",a[a.South=4]="South",a[a.Southwest=5]="Southwest",a[a.West=6]="West",a[a.Northwest=7]="Northwest",a))(H||{}),Ga=(a=>(a.Pixel="px",a.Millimeter="mm",a.Centimeter="cm",a))(Ga||{});class ja extends Error{constructor(t){super(t),this.name=this.constructor.name}}class se extends ja{constructor(t){super(`ConfigurationError - ${t}`)}}class ae extends se{constructor(t){super(`Option not Configured: ${t.stepTitle}`),this.optionId=t?.optionId||"N/A"}}class J extends se{constructor(t){super(`Panel not Found: ${t.panelId}`),this.panelId=t?.panelId||"N/A"}}class ft extends se{constructor(t){super(`Asset not found for variant: ${t.name}`),this.variant=t}}class Qt extends se{constructor(t){super(`Resource not found for asset: ${t.name}`),this.asset=t}}class re extends se{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),this.step=t}}class Ue extends ja{constructor(t){super(`ImplementationError - ${t}`)}}class Q extends Ue{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class Et extends Ue{constructor(t){super(`Parsing Error: ${t}`)}}class mt extends Ue{constructor(t){super(`Client Error: ${t}`)}}class Le extends Ue{constructor(t){super(`Resource Generation Failed: ${t}`)}}class Oi{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 n=JSON.stringify([...e.entries()]);this.set(t,n)}}class da{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 n=JSON.stringify([...e.entries()]);this.set(t,n)}}const $i=()=>{try{return localStorage?new Oi:new da}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new da}},D=$i();class Ui{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 ut=new Ui;let Cn,wn;function Li(a){Cn=a}function Vi(a){wn=a}function le(){return Cn?new Cn().window:(console.log("DOM constructor is not registered. Assuming browser environment. If not, please register DOM constructor before calling this function."),window)}function rt(a,t){if(!wn){if(typeof window<"u"&&window.fetch)return window.fetch(a,t);if(typeof global<"u"&&global.fetch)return global.fetch(a,t);throw new Error("Fetch implementation is not registered. Please register it before calling this function.")}return wn(a,t)}const Wa=new Map,ua=new Map,Aa=new Map,Ha=async a=>{const t=ua.get(a);if(t)return t;const n=(async()=>{const r=await rt(a);return Wa.set(a,r.headers?.get("content-type")||""),await r.arrayBuffer()})();return ua.set(a,n),n},zi=async a=>{const t=Aa.get(a);if(t)return t;const n=(async()=>await(await rt(a)).text())();return Aa.set(a,n),n},Ut=a=>a.every(t=>t!=="undefined"),ye=a=>Ut([typeof document])?document.createElement(a):le().document.createElement(a),qi=(a,t)=>{if(Ut([typeof document]))return document.createElementNS(a,t);const n=le().document.createElement(t);return n.setAttribute("xmlns",a),n},lt=()=>{if(Ut([typeof DOMParser]))return new DOMParser;const a=le();return new a.DOMParser},Gi=()=>Ut([typeof DOMParser])?DOMParser:le().DOMParser,Ve=(a,t)=>new Promise((e,n)=>{t?Ha(a).then(e).catch(n):rt(a).then(r=>{r.arrayBuffer().then(e).catch(n)}).catch(r=>{n(r)})}),et=(a,t)=>new Promise((e,n)=>{t?zi(a).then(e).catch(n):rt(a).then(r=>{r.text().then(e).catch(n)}).catch(n)}),Ya=a=>Bi.renderToStaticMarkup(a),tn=new Map,ji=async(a,t)=>{if(Ut([typeof FontFace])){if(tn.has(t))return tn.get(t);const e=a.names.fullName.en,n=new FontFace(e,`url(${t})`);document.fonts.add(n);const r=n.load();return tn.set(t,r),r}},St=()=>{if(Ut([typeof XMLSerializer]))return new XMLSerializer;const a=le();return new a.XMLSerializer},ha=a=>btoa(a),ze=a=>{function t(){const n=new Uint8Array(a),r=4;if(n.length>=r){const i=new Array(r);for(let l=0;l<r;l++)i[l]=new Uint8Array(a)[l].toString(16);const o=i.join("").toUpperCase();switch(o){case"89504E47":return"image/png";case"47494638":return"image/gif";case"25504446":return"application/pdf";case"504B0304":return"application/zip"}switch(o.slice(0,4)){case"FFD8":return"image/jpeg"}}return null}const e=t();return e||"image/svg+xml"},Wi=async a=>{const t=await Ha(a),e=Wa.get(a)||ze(t);return await Ji(new Blob([t],{type:e}))},Hi=a=>{let t="";const e=a.byteLength;for(let n=0;n<e;n++)t+=String.fromCharCode(a[n]);return t},Yi=async a=>{const t=ze(a),e=new Uint8Array(a),n=Hi(e),r=btoa(n);return`data:${t};base64,${r}`},qe=a=>`data:image/svg+xml;base64,${btoa(a)}`,Ja=a=>{const t=a.replace(/\r?\n/g,""),e=t.indexOf(",");if(e===-1||e<=4)throw new TypeError("malformed data: URI");const n=t.substring(5,e).split(";");let r=!1;for(let o=1;o<n.length;o++)n[o]==="base64"&&(r=!0);const i=decodeURI(t.substring(e+1));return r?new Uint8Array(atob(i).split("").map(s=>s.charCodeAt(0))).buffer:new Uint8Array(i.split("").map(s=>s.charCodeAt(0))).buffer},Ji=a=>new Promise((t,e)=>{const n=new FileReader;n.onload=function(r){const i=r.target;!i||!i.result?e():t(i.result.toString())},n.readAsDataURL(a)});let Ki,Rn;const _i=a=>{Rn=a},Xi=()=>Rn;let Ka;const _a=a=>{Ka=a},Zi=()=>new Promise(a=>{const t=ut.getHubUrl(),e=n=>{n.origin===t&&(window.removeEventListener("message",e),a(n.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))}),to=async()=>{const a={applicationKey:Rn,customerToken:Ki,bearer:Ka};return typeof window<"u"&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await Zi(),...a}:a};async function eo(a,t){const e=ut.getServerUrl(),n=e.includes(".aumelbdev.spiffcommerce.com")?"https://moonlight.aumelbdev.spiffcommerce.com":e.includes(".us.spiffcommerce.com")?"https://moonlight.us.spiffcommerce.com":"https://moonlight.au.spiffcommerce.com";let r=await rt(a,{...t,redirect:"manual"});return r.type==="opaqueredirect"&&(typeof a!="string"&&"url"in a?r=await rt({...a,url:`${n}/graphql`},t):r=await rt(`${n}/graphql`,t)),r}class no{constructor(){this.shadowGraphqlClient=this.constructShadowGraphqlClient(),ut.addServerUrlCallback(()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()})}setSpiffCommerceClient(t){this.spiffClient=t,this.shadowGraphqlClient=this.constructShadowGraphqlClient()}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const t=C.createHttpLink({uri:`${ut.getServerUrl()}/graphql`,fetch:eo}),e=bi.setContext(async(i,o)=>{const{headers:s}=o,l=s||{},c=await to();let d=o.bearer??c.bearer;if(this.spiffClient)try{d=await this.spiffClient.loggedInBearerToken()}catch{}const u=o.partnerId??c.partnerId,A=o.activeIntegration??c.activeIntegration,h=o.transactionOwnerId,g=o.customerToken??c.customerToken,m=o.applicationKey??c.applicationKey,p=o.bundleOwnerId;try{if(window&&window.__SENTRY__){const f=window.__SENTRY__.hub;if(f){const S=f.traceHeaders();Object.entries(S).forEach(([w,x])=>{l[w]=x})}}}catch{}return d&&(l.Authorization=`Bearer ${d}`),u&&(l.partnerId=u),A&&(l.activeIntegration=A),h&&(l.transactionOwnerId=h),g&&(l.customerToken=g),m&&(l["X-Application-Key"]=m),p&&(l.bundleOwnerId=p),l["Allow-Moonlight-Redirect"]="true",{headers:l}}),n=Ii.onError(({operation:i,graphQLErrors:o,networkError:s})=>{const l=o||[],c=i.getContext();s&&!c?.fetchOptions?.signal?.aborted&&console.log("GraphQL Network error"),l.forEach(()=>console.log("GraphQL Error: "+i.operationName))}),r=Pi.removeTypenameFromVariables();return new C.ApolloClient({link:C.from([r,n,e,t]),cache:new C.InMemoryCache,name:"Core"})}}const y=new no;let yn,Sn;const Ct=(a,t,e)=>{if(yn!==void 0)return yn(a,t,e);try{const n=Xa(!0);return On(n),n.createCanvas(a,t,e)}catch{throw new Error("Canvas module not set")}},ce=(a,t)=>{if(Sn!==void 0)return Sn(a,t);try{const e=Xa(!0);return On(e),e.loadImage(a,t)}catch{throw new Error("Canvas module not set")}};function On(a){yn=a?.createCanvas,Sn=a?.loadImage}function Xa(a){try{if(document.createElement("canvas").getContext("2d"))return{createCanvas:(e,n,r)=>{const i=document.createElement("canvas");return e!=null&&(i.width=e),n!=null&&(i.height=n),i},loadImage:(e,n)=>new Promise((r,i)=>{const o=document.createElement("img");n!==!1&&(o.crossOrigin="Anonymous"),o.onload=()=>{r(o)},o.onerror=i,o.src=e})}}catch(t){throw t}}let en;function $n(){return en===void 0&&(en=Gi()),en}let Se=null;const ao=a=>new Promise(t=>{if(ze(a)!=="image/jpeg")return t(1);xi.orientation(a).then(n=>t(n||1)).catch(()=>t(1))}),ro=async()=>{if(Se!==null)return!Se;const t=await ce("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return Se=t.width===2&&t.height===3,!Se},io=a=>{const e=a.naturalWidth/a.naturalHeight;return a.naturalHeight<=8192&&a.naturalWidth<=8192?[a.naturalWidth,a.naturalHeight]:a.naturalHeight>a.naturalWidth?[e*8192,8192]:[8192,8192/e]},oo=async a=>{const t=await Yi(a),e=await ce(t),[n,r]=io(e);if(!await ro()){const u=Ct(n,r);return u.getContext("2d")?.drawImage(e,0,0,n,r),u}const o=await ao(a),[s,l]=o>4?[r,n]:[n,r],c=Ct(s,l),d=c.getContext("2d");switch(o){case 2:d.translate(s,0),d.scale(-1,1);break;case 3:d.translate(s,l),d.rotate(Math.PI);break;case 4:d.translate(0,l),d.scale(1,-1);break;case 5:d.rotate(-.5*Math.PI),d.scale(-1,1);break;case 6:d.rotate(-.5*Math.PI),d.translate(-s,0);break;case 7:d.rotate(-.5*Math.PI),d.translate(-s,l),d.scale(1,-1);break;case 8:d.rotate(.5*Math.PI),d.translate(0,-l);break}return d.drawImage(e,0,0,s,l),c},de=async a=>{const t=await oo(a);return ze(a)==="image/jpeg"?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}},ie=["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"],Rt=["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"],nn=Rt.map(a=>[parseInt(a.substring(0,2),16),parseInt(a.substring(2,4),16),parseInt(a.substring(4,6),16)]);function so(a){const t=ie.indexOf(a);return t>=0?Rt[t]:""}function Za(a){const t=Rt.indexOf(a);return t>=0?ie[t]:""}function lo(a,t=64){const e=[],n=[],r=Za(a);r&&e.push({pms:r,hex:a,distance:0});const i=parseInt(a.substring(0,2),16),o=parseInt(a.substring(2,4),16),s=parseInt(a.substring(4,6),16);let l,c,d;for(let u=0;u<Rt.length;u++){l=nn[u][0],c=nn[u][1],d=nn[u][2];const A=Math.sqrt(Math.pow(i-l,2)+Math.pow(o-c,2)+Math.pow(s-d,2));n.push(A)}for(let u=0;u<n.length;u++)n[u]<=t&&!e.some(A=>A.pms===ie[u])&&e.push({pms:ie[u],hex:Rt[u],distance:n[u]});return e.sort((u,A)=>u.distance-A.distance)}const co=ie.map((a,t)=>({pms:a,hex:Rt[t]})),uo=new Fi(co,{keys:["pms"]});function Ao(a,t){return uo.search(a,t?{limit:t}:void 0)}let Lt=null;function tr(a){if(a.startsWith("#"))return ga(a);if(!document)throw new Error("browserColorToHex is only supported on browsers");if(Lt||(Lt=document.createElement("canvas").getContext("2d")),!Lt)throw new Error("Failed to create canvas context required to convert colors");Lt.fillStyle=a;const t=ga(Lt.fillStyle);return t||console.error(`Unknown browser color ${a}`),t}function ga(a){const t=a.substring(1).toUpperCase();return t.length===6?t:t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:""}const ve=a=>{const t=er(a.spotColor);return t?`${a.browserValue} ${t}`:a.browserValue},er=a=>{if(!a)return"";if(a.profileName.includes("/")&&a.profileName.includes(".icc")){const t=a.profileName.replace(/\s/g,"-"),e=t.lastIndexOf("/");return`icc-named-color(${t.slice(e+1).slice(0,-4)}, ${a.namedColor})`}return`icc-named-color(${a.profileName}, ${a.namedColor})`},vn=a=>{const t=a.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 n=e[0].replace(/[() ]/g,"").split(",");return{browserValue:t[0],spotColor:{profileName:n[0],namedColor:n[1]}}},ho=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],go=["fill","stroke"],Ot=(a,t)=>{t(a),a.children.length>0&&Array.from(a.children).forEach(e=>Ot(e,t))},nr=(a,t)=>{const e=t(a);if(e)return e;const n=a.parentElement;if(n)return nr(n,t)},mo=(a,t)=>{try{return a.matches(t)}catch{return a.classList.contains(t.substring(1))}},Ge=(a,t=!1)=>{!t&&a.setAttribute("preserveAspectRatio","none");const e=[];Ot(a,n=>{if(n.tagName==="script"){n.remove();return}if(n.tagName==="style"){try{Qa.parse(n.innerHTML).stylesheet?.rules.forEach(o=>{e.push(o)}),n.remove()}catch(i){console.error(i)}return}const r=n.attributes.getNamedItem("style")?.value?.trim();if(r){const i=[];r.split(";").forEach(s=>{const l=s.trim();if(l){const[c,d]=l.split(":"),u=c.toLowerCase();go.indexOf(u)>-1?n.setAttribute(u,d.trim()):i.push(l)}}),i.length>0?n.setAttribute("style",i.join(";")):n.removeAttribute("style")}}),Ot(a,n=>{e.forEach(r=>{r.selectors?.forEach(i=>{mo(n,i)&&r.declarations?.forEach(o=>{o.property&&o.value&&n.setAttribute(o.property,o.value)})})})})},po=a=>{const t=/pt|pc|mm|cm|in/gm,e=a.getAttribute("viewBox"),n=a.getAttribute("width"),r=a.getAttribute("height");if(!e)throw new Error("viewBox not specified on SVG!");n&&a.setAttribute("width",n.replace(t,"")),r&&a.setAttribute("height",r.replace(t,""))},ar=a=>lt().parseFromString(a,"image/svg+xml").firstElementChild,fo=(a,t,e)=>{a.setAttribute("height",`${e}px`),a.setAttribute("width",`${t}px`)},rr=(a,t,e)=>{Ot(a,n=>{const r=n.attributes.getNamedItem("fill");r&&r.value!=="none"&&n.classList.forEach(o=>{if(o.startsWith("spiff-fill")){const s=t[o.replace("spiff-fill-","")];if(s)n.setAttribute("fill",e?ve(s):s.browserValue);else{const l=t[o];l&&n.setAttribute("fill",e?ve(l):l.browserValue)}}});const i=n.attributes.getNamedItem("stroke");i&&i.value!=="none"&&n.classList.forEach(o=>{if(o.startsWith("spiff-stroke")){const s=t[o.replace("spiff-stroke-","")];if(s)n.setAttribute("stroke",e?ve(s):s.browserValue);else{const l=t[o];l&&n.setAttribute("fill",e?ve(l):l.browserValue)}}})})},ir=a=>St().serializeToString(a),Un=(a,t,e,n,r)=>{const i=ar(a);if(!i)throw new Error("Failed to read SVG.");return fo(i,t,e),rr(i,n,r),ir(i)},je=(a,t,e)=>{const n=ar(a);if(!n)throw new Error("Failed to read SVG.");return rr(n,t,e),ir(n)},Co=a=>{const t=/<svg.*<\/svg>/s,e=a.match(t)||[],n=e?.length>0?e[0]:"";return lt().parseFromString(n,"image/svg+xml")},it=async a=>{const e=Co(a).firstElementChild;if(!e)throw new Error("Failed to read SVG.");Ge(e);const n={};Ot(e,o=>{if(ho.includes(o.tagName)&&!o.attributes.getNamedItem("fill")){let c="black";const d=o.parentElement;if(d){const u=nr(d,A=>{const g=A.style.fill;if(g)return g;const m=A.getAttribute("fill");if(m)return m});u&&(c=u)}o.setAttribute("fill",c)}const s=o.attributes.getNamedItem("fill");if(s&&s.value!=="none"&&!s.value.startsWith("url(")){const c=vn(s.value),d=c.browserValue.replace(/\W/g,""),u=`spiff-fill-${d}`;o.setAttribute("fill",c.browserValue),o.classList.add(u),n[d]=c}const l=o.attributes.getNamedItem("stroke");if(l&&l.value!=="none"&&!l.value.startsWith("url(")){const c=vn(l.value),d=c.browserValue.replace(/\W/g,""),u=`spiff-stroke-${d}`;o.classList.add(u),o.setAttribute("stroke",c.browserValue),n[d]=c}});const i=St().serializeToString(e);return{colors:n,svg:i}},wo=C.gql`
|
|
2
2
|
fragment AssetMetadataFields on Asset {
|
|
3
3
|
metadata {
|
|
4
4
|
key
|
|
5
5
|
value
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
`,ue=
|
|
9
|
-
${
|
|
8
|
+
`,ue=a=>C.gql`
|
|
9
|
+
${a&&wo||""}
|
|
10
10
|
fragment AssetFields on Asset {
|
|
11
11
|
name
|
|
12
12
|
key
|
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
name
|
|
47
47
|
link
|
|
48
48
|
}
|
|
49
|
-
${
|
|
49
|
+
${a&&"...AssetMetadataFields"||""}
|
|
50
50
|
}
|
|
51
|
-
`,
|
|
51
|
+
`,yo=C.gql`
|
|
52
52
|
${ue(!1)}
|
|
53
53
|
query GetAssets($keys: [String]!) {
|
|
54
54
|
assets(keys: $keys) {
|
|
55
55
|
...AssetFields
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
`,
|
|
58
|
+
`,Ln=C.gql`
|
|
59
59
|
fragment MaterialFields on Material {
|
|
60
60
|
id
|
|
61
61
|
name
|
|
@@ -102,14 +102,14 @@
|
|
|
102
102
|
fileLink
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
`,
|
|
106
|
-
${
|
|
105
|
+
`,So=C.gql`
|
|
106
|
+
${Ln}
|
|
107
107
|
query GetMaterials($ids: [String]) {
|
|
108
108
|
materials(id: $ids) {
|
|
109
109
|
...MaterialFields
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
`,
|
|
112
|
+
`,vo=C.gql`
|
|
113
113
|
mutation CreateAsset($name: String!, $type: String!, $mimeType: String!, $anonymous: Boolean, $temporary: Boolean) {
|
|
114
114
|
assetCreate(name: $name, type: $type, mimeType: $mimeType, anonymous: $anonymous, temporary: $temporary) {
|
|
115
115
|
uploadUrl
|
|
@@ -123,14 +123,14 @@
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
`,
|
|
126
|
+
`,Eo=C.gql`
|
|
127
127
|
${ue(!1)}
|
|
128
128
|
mutation RemoveBackgroundFromAsset($key: String!) {
|
|
129
129
|
assetRemoveBackground(key: $key) {
|
|
130
130
|
...AssetFields
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
`,De=async
|
|
133
|
+
`,De=async a=>(await y.getShadowGraphqlClient().query({query:yo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{keys:a}})).data.assets,bo=async a=>(await y.getShadowGraphqlClient().query({query:So,errorPolicy:"all",variables:{ids:a}})).data.materials,Io=async(a,t,e,n,r)=>(await y.getShadowGraphqlClient().mutate({mutation:vo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:a,type:t,mimeType:e,anonymous:n,temporary:r}})).data?.assetCreate;class Bo{constructor(){this.cache=new Map,this.bgrmProcessCache=new Map,this.materialCache=new Map,this.loadImageAsFileInfo=async t=>{const e=await t.arrayBuffer(),n=await de(e),r=(i,o)=>{const s=atob(i.split(",")[1]),l=[];for(let c=0;c<s.length;c++)l.push(s.charCodeAt(c));return new Blob([new Uint8Array(l)],{type:o})};return{name:t.name.substring(t.name.lastIndexOf("/")+1),blob:r(n.dataUrl,t.type)}}}async getLocalOrFromServer(t){if(this.cache.has(t)){const r=this.cache.get(t);if(!r)throw new Q("Failed to get asset from cache!");return r}const n=(async()=>(await De([t]))[0])();return this.cache.set(t,n),n}async getFromServer(t){const n=(async()=>(await De([t]))[0])();return this.cache.set(t,n),n}keyFromURL(t){let e;try{e=new URL(t).pathname}catch{e=void 0}return e!==void 0&&e.startsWith("/")&&(e=e.replace("/","")),e?.split("?")[0]}cacheAsset(t){if(!t.key)throw new Q("Asset has no key!");this.cache.has(t.key)||this.cache.set(t.key,Promise.resolve(t))}cacheMaterial(t){if(!t.id)throw new Q("Material has no id!");this.materialCache.has(t.id)||this.materialCache.set(t.id,Promise.resolve(t))}async getMaterialLocalOrFromServer(t){if(this.materialCache.has(t))return this.materialCache.get(t);const n=(async()=>(await bo([t]))[0])();return this.materialCache.set(t,n),n}async uploadAssetWithProgress(t,e,n,r,i){const o=await this.dispatchCreateAssetRequest(t,e,r,i);if(!o)throw new Error("Failed to create asset.");return await new Promise((s,l)=>{const c=new XMLHttpRequest;c.open("PUT",o.assetResponse.uploadUrl,!0),c.setRequestHeader("Content-Type",o.mimeType),c.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),c.upload.onprogress=d=>{d.lengthComputable&&n(d.loaded*100/d.total)},c.onload=()=>{const d=o.assetResponse.asset;ht.add(o.assetResponse.asset),s(d)},c.onerror=l,this.postProcessFileUpload(t,o.mimeType).then(d=>c.send(d.blob)).catch(l)}),this.cacheAsset(o.assetResponse.asset),o.assetResponse.asset}async uploadAsset(t,e,n,r){return this.uploadAssetWithProgress(t,e,()=>{},n,r)}async uploadFile(t,e){const r=this.isRaster(t)?ee.Image:ee.Illustration,i=await this.loadImageAsFileInfo(t);return await this.uploadAssetWithProgress(i,r,e,!0)}async removeBackgroundFromAsset(t){const e=t.key;if(this.bgrmProcessCache.has(e))return this.bgrmProcessCache.get(e);if(K.has(e)){const i=this.getLocalOrFromServer(K.get(e));return this.bgrmProcessCache.set(e,i),i}const r=(async()=>{const i=await y.getShadowGraphqlClient().mutate({mutation:Eo,fetchPolicy:"no-cache",errorPolicy:"all",variables:{key:e}});if(this.bgrmProcessCache.delete(e),!i.data?.assetRemoveBackground?.key)throw new Error("Failed to remove background from image");return ht.add(i.data.assetRemoveBackground),K.add(e,i.data.assetRemoveBackground.key),this.cache.set(i.data.assetRemoveBackground.key,Promise.resolve(i.data.assetRemoveBackground)),i.data.assetRemoveBackground})();return this.bgrmProcessCache.set(e,r),r}removePersistedAsset(t){ht.remove(t),K.delete(t),K.deleteForBgRemovedKey(t)}getPersistedAssets(){return ht.list()}registerPersistedAssetListener(t){ht.addCallback(t)}unRegisterPersistedAssetListener(t){ht.removeCallback(t)}isRaster(t){return!(t.type==="image/svg+xml"||t.type==="application/pdf"||t.type==="application/postscript")}async postProcessFileUpload(t,e){if(e==="image/svg+xml"){const n=await t.blob.text(),o=new window.DOMParser().parseFromString(n,"image/svg+xml").documentElement;if(!o)throw new Et("Failed to read SVG.");po(o);const l=St().serializeToString(o);return{name:t.name,blob:new Blob([l],{type:"image/svg+xml"})}}return t}async dispatchCreateAssetRequest(t,e,n,r){const i=t.blob.type?t.blob.type:this.guessMIME(t.name),o=await Io(t.name,e,i,n,r);if(o)return{assetResponse:o,mimeType:i}}guessMIME(t){const e=t.split(".").pop();switch(e){case"glb":return"model/gltf-binary";case"ttf":return"font/ttf";case"mkv":return"video/x-matroska";default:throw new Q("Unexpected mimetype: "+e)}}}const Vt="persistentAssets",ct=class ct{static add(t){if(!t.fileLink){console.error("Failed to find cdn link on asset, cannot persist!");return}const e=new Map;e.set(t.key||"",t.fileLink);const n=D.getMap(Vt);n&&n.forEach((r,i)=>{e.set(i,r)}),D.setMap(Vt,e),ct.executeCallbacks()}static remove(t){const e=D.getMap(Vt);if(!e)return;const n=Array.from(e.entries()).find(r=>r[0]===t);n&&(e.delete(n[0]),D.setMap(Vt,e),ct.executeCallbacks())}static list(){const t=D.getMap(Vt);return t?Array.from(t.entries()).map(e=>({assetKey:e[0],src:e[1]})):[]}static addCallback(t){ct.callbacks.push(t)}static removeCallback(t){ct.callbacks=ct.callbacks.filter(e=>e!==t)}static executeCallbacks(){ct.callbacks.forEach(t=>t())}};ct.callbacks=[];let ht=ct;const ma="bgrmPersistentAssets";class K{static has(t){return K.getMap().has(t)}static get(t){return K.getMap().get(t)}static keys(){return K.getMap().keys()}static values(){return K.getMap().values()}static add(t,e){const n=K.getMap();n.set(t,e),K.setMap(n)}static delete(t){const e=K.getMap();e.delete(t),K.setMap(e)}static deleteForBgRemovedKey(t){const e=K.getMap(),n=Array.from(e.keys()).find(r=>e.get(r)===t);n&&(e.delete(n),K.setMap(e))}static getMap(){return D.getMap(ma)||new Map}static setMap(t){D.setMap(ma,t)}}const U=new Bo;class Po{constructor(){this.cache={},this.disabled=!1}get(t){if(this.disabled)return;const e=JSON.stringify(t);return this.cache[e]}set(t,e){if(this.disabled)return e;const n=JSON.stringify(t);return this.cache[n]=e,e}disable(t){this.disabled=t}}const $t=new Po,or=C.gql`
|
|
134
134
|
fragment OptionFields on Option {
|
|
135
135
|
id
|
|
136
136
|
name
|
|
@@ -171,16 +171,16 @@
|
|
|
171
171
|
...AssetFields
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
`,
|
|
174
|
+
`,xo=C.gql`
|
|
175
175
|
${ue(!1)}
|
|
176
|
-
${
|
|
176
|
+
${Ln}
|
|
177
177
|
${or}
|
|
178
178
|
query GetOptions($ids: [String]!) {
|
|
179
179
|
options(ids: $ids) {
|
|
180
180
|
...OptionFields
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
`,
|
|
183
|
+
`,Fo=async a=>{const t=await y.getShadowGraphqlClient().query({query:xo,errorPolicy:"all",variables:{ids:a}});return t.data.options.forEach(e=>{e.defaultVariant?.asset&&U.cacheAsset(e.defaultVariant.asset),e.colorProfile&&U.cacheAsset(e.colorProfile),e.variants?.forEach(n=>{n.asset&&U.cacheAsset(n.asset),n.thumbnail&&U.cacheAsset(n.thumbnail),n.material&&U.cacheMaterial(n.material)})}),t.data.options},Do=async(a,t)=>(await t).find(n=>n.id===a),ko=async a=>{const t=a.map(o=>$t.get({id:o})),e=a.filter((o,s)=>t[s]===void 0);if(e.length===0)return Promise.all(t);const n=Fo(e),r=e.map(o=>$t.set({id:o},Do(o,n))),i=t.filter(o=>o!==void 0);return await Promise.all(i.concat(r))};class Mo{constructor(){this.getSelectedVariant=(t,e)=>{if(!(!t||e.length===0))return t.variants?.find(n=>n.id===e[0])}}async getOption(t){return(async()=>{const r=(await ko([t]))[0];if(r)return r})()}async getAssetTileImageForVariant(t){const e=t.thumbnail;if(e){const r=e.versions?.find(o=>o.name==="thumbnail"),i=e.fileLink;return r?.link||i}const n=t.asset;if(n){const r=n.versions?.find(o=>o.name==="thumbnail"),i=n.fileLink;return r?.link||i}return t.material?t.material.id:""}getDefaultVariant(t){const e=t.variants;if(e){if(e.length===1)return e[0];if(t.defaultVariant!==void 0)return e.find(n=>n.id===t.defaultVariant?.id)}}}const Y=new Mo,sr=C.gql`
|
|
184
184
|
fragment ActiveIntegrationFields on Integration {
|
|
185
185
|
id
|
|
186
186
|
logo
|
|
@@ -268,7 +268,7 @@
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
`,
|
|
271
|
+
`,To=C.gql`
|
|
272
272
|
${lr}
|
|
273
273
|
mutation CreateTransactions(
|
|
274
274
|
$inputs: [TransactionCreateInput]!
|
|
@@ -314,7 +314,7 @@
|
|
|
314
314
|
precedence
|
|
315
315
|
url
|
|
316
316
|
}
|
|
317
|
-
`,
|
|
317
|
+
`,No=C.gql`
|
|
318
318
|
${We}
|
|
319
319
|
${Ae}
|
|
320
320
|
${sr}
|
|
@@ -406,7 +406,7 @@
|
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
`,
|
|
409
|
+
`,Qo=C.gql`
|
|
410
410
|
${cr}
|
|
411
411
|
${dr}
|
|
412
412
|
${lr}
|
|
@@ -458,32 +458,32 @@
|
|
|
458
458
|
integrationProductId
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
`,
|
|
461
|
+
`,Ro=C.gql`
|
|
462
462
|
mutation UpdateTransactionWorkflowState($id: String!, $workflowState: String!) {
|
|
463
463
|
transactionUpdate(id: $id, workflowState: $workflowState) {
|
|
464
464
|
id
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
`,
|
|
467
|
+
`,Oo=C.gql`
|
|
468
468
|
mutation UpdateTransactionQuantity($id: String!, $quantity: Int) {
|
|
469
469
|
transactionUpdate(id: $id, quantity: $quantity) {
|
|
470
470
|
id
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
|
|
473
|
+
`,$o=C.gql`
|
|
474
474
|
mutation UpdateTransactionWorkflow($id: String!, $workflowId: String!) {
|
|
475
475
|
transactionUpdate(id: $id, workflowId: $workflowId) {
|
|
476
476
|
id
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
|
-
|
|
479
|
+
`,Uo=C.gql`
|
|
480
480
|
${Ae}
|
|
481
481
|
query ReadConversionConfigurationQuery($id: String!) {
|
|
482
482
|
conversionConfiguration(id: $id) {
|
|
483
483
|
...ConversionConfigurationFields
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
`,
|
|
486
|
+
`,Lo=C.gql`
|
|
487
487
|
${Ae}
|
|
488
488
|
query ReadTransactionForDesignCreation($id: String!) {
|
|
489
489
|
transactions(ids: [$id]) {
|
|
@@ -542,7 +542,7 @@
|
|
|
542
542
|
workflowViewerReadOnlyLink
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
|
-
`,
|
|
545
|
+
`,Vo=C.gql`
|
|
546
546
|
${dr}
|
|
547
547
|
query ReadTransactionForShareActions($id: String!) {
|
|
548
548
|
transactions(ids: [$id]) {
|
|
@@ -553,11 +553,11 @@
|
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
|
-
`,
|
|
556
|
+
`,zo=C.gql`
|
|
557
557
|
query ConfirmWorkflowStates($transactions: [TransactionConfirmInput!]!) {
|
|
558
558
|
transactionConfirmWorkflowStates(transactions: $transactions)
|
|
559
559
|
}
|
|
560
|
-
`,ur=
|
|
560
|
+
`,ur=a=>C.gql`
|
|
561
561
|
${We}
|
|
562
562
|
fragment IntegrationProductFields on IntegrationProduct {
|
|
563
563
|
id
|
|
@@ -619,7 +619,7 @@
|
|
|
619
619
|
minQty
|
|
620
620
|
percentage
|
|
621
621
|
}
|
|
622
|
-
${
|
|
622
|
+
${a?`
|
|
623
623
|
integrationProducts {
|
|
624
624
|
id
|
|
625
625
|
externalProductId
|
|
@@ -640,15 +640,15 @@
|
|
|
640
640
|
`:""}
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
|
-
`,
|
|
644
|
-
${ur(
|
|
643
|
+
`,qo=a=>C.gql`
|
|
644
|
+
${ur(a)}
|
|
645
645
|
query GetIntegrationProducts($ids: [String!]!) {
|
|
646
646
|
integrationProducts(ids: $ids) {
|
|
647
647
|
...IntegrationProductFields
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
|
-
`,
|
|
651
|
-
${ur(
|
|
650
|
+
`,Go=a=>C.gql`
|
|
651
|
+
${ur(a)}
|
|
652
652
|
query GetIntegrationProductFromExternalIds($externalIntegrationId: String!, $externalProductId: String!) {
|
|
653
653
|
integrationProductFromExternalIds(
|
|
654
654
|
externalIntegrationId: $externalIntegrationId
|
|
@@ -657,7 +657,7 @@
|
|
|
657
657
|
...IntegrationProductFields
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
|
-
`,
|
|
660
|
+
`,jo=C.gql`
|
|
661
661
|
${cr}
|
|
662
662
|
query ReadTransactionForStakeholders($id: String!) {
|
|
663
663
|
transactions(ids: [$id]) {
|
|
@@ -669,11 +669,11 @@
|
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
|
-
`,
|
|
672
|
+
`,Wo=C.gql`
|
|
673
673
|
mutation FinalizeUpdateTransaction($transactionId: String!) {
|
|
674
674
|
transactionFinalizeUpdate(transactionId: $transactionId)
|
|
675
675
|
}
|
|
676
|
-
`,
|
|
676
|
+
`,Ho=C.gql`
|
|
677
677
|
fragment RegionFields on Region {
|
|
678
678
|
width
|
|
679
679
|
top
|
|
@@ -691,7 +691,7 @@
|
|
|
691
691
|
height
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
|
-
`,
|
|
694
|
+
`,Yo=C.gql`
|
|
695
695
|
fragment LookAtAnimationFields on LookAtAnimation {
|
|
696
696
|
latDeg
|
|
697
697
|
lonDeg
|
|
@@ -702,7 +702,7 @@
|
|
|
702
702
|
z
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
|
-
`,
|
|
705
|
+
`,Jo=C.gql`
|
|
706
706
|
fragment RenderingPipelineConfigurationFields on RenderingPipelineConfiguration {
|
|
707
707
|
antiAliasing {
|
|
708
708
|
samples
|
|
@@ -786,21 +786,21 @@
|
|
|
786
786
|
weight
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
|
-
`,
|
|
789
|
+
`,Ko=C.gql`
|
|
790
790
|
fragment ModelAnimationFields on ModelAnimation {
|
|
791
791
|
from
|
|
792
792
|
to
|
|
793
793
|
loop
|
|
794
794
|
name
|
|
795
795
|
}
|
|
796
|
-
`,
|
|
797
|
-
${ue(
|
|
798
|
-
${
|
|
796
|
+
`,_o=a=>C.gql`
|
|
797
|
+
${ue(a)}
|
|
798
|
+
${Ln}
|
|
799
799
|
${or}
|
|
800
|
-
${Wo}
|
|
801
800
|
${Ho}
|
|
802
801
|
${Yo}
|
|
803
802
|
${Jo}
|
|
803
|
+
${Ko}
|
|
804
804
|
query GetWorkflows($ids: [String!]!) {
|
|
805
805
|
workflows(ids: $ids) {
|
|
806
806
|
partner {
|
|
@@ -1199,7 +1199,7 @@
|
|
|
1199
1199
|
}
|
|
1200
1200
|
}
|
|
1201
1201
|
}
|
|
1202
|
-
`,
|
|
1202
|
+
`,Xo=C.gql`
|
|
1203
1203
|
query GetTransactionForPartner($id: String!) {
|
|
1204
1204
|
transactions(ids: [$id]) {
|
|
1205
1205
|
id
|
|
@@ -1217,7 +1217,7 @@
|
|
|
1217
1217
|
}
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
1220
|
-
`,
|
|
1220
|
+
`,Zo=C.gql`
|
|
1221
1221
|
${ue(!1)}
|
|
1222
1222
|
query GetWorkflowForTheme($id: String!) {
|
|
1223
1223
|
workflow(id: $id) {
|
|
@@ -1307,14 +1307,14 @@
|
|
|
1307
1307
|
}
|
|
1308
1308
|
}
|
|
1309
1309
|
}
|
|
1310
|
-
`,
|
|
1310
|
+
`,ts=C.gql`
|
|
1311
1311
|
${He}
|
|
1312
1312
|
query GetMarketplaceThemeInstallConfiguration($themeConfigurationId: String!, $themeInstallId: String!) {
|
|
1313
1313
|
marketplaceThemeInstallConfiguration(id: $themeConfigurationId, themeInstallId: $themeInstallId, raw: false) {
|
|
1314
1314
|
...MarketplaceThemeInstallConfigurationFields
|
|
1315
1315
|
}
|
|
1316
1316
|
}
|
|
1317
|
-
`,
|
|
1317
|
+
`,es=C.gql`
|
|
1318
1318
|
${sr}
|
|
1319
1319
|
${He}
|
|
1320
1320
|
query GetCurrentIntegration($themeConfigurationId: String) {
|
|
@@ -1327,7 +1327,7 @@
|
|
|
1327
1327
|
...ActiveIntegrationFields
|
|
1328
1328
|
}
|
|
1329
1329
|
}
|
|
1330
|
-
`,
|
|
1330
|
+
`,ns=C.gql`
|
|
1331
1331
|
${He}
|
|
1332
1332
|
query ReadTransactionForMarketplaceTheme($id: String!) {
|
|
1333
1333
|
transactions(ids: [$id]) {
|
|
@@ -1345,14 +1345,14 @@
|
|
|
1345
1345
|
}
|
|
1346
1346
|
}
|
|
1347
1347
|
}
|
|
1348
|
-
`,
|
|
1348
|
+
`,rs=C.gql`
|
|
1349
1349
|
mutation CreateOrder($orderItems: [OrderItemInput]!) {
|
|
1350
1350
|
orderCreate(orderItems: $orderItems, paid: false, generateInternalId: true) {
|
|
1351
1351
|
id
|
|
1352
1352
|
internalId
|
|
1353
1353
|
}
|
|
1354
1354
|
}
|
|
1355
|
-
`,
|
|
1355
|
+
`,is=C.gql`
|
|
1356
1356
|
query CurrencyConversion($from: String!, $to: String!) {
|
|
1357
1357
|
currencyConversion(from: $from, to: $to) {
|
|
1358
1358
|
rateFrom
|
|
@@ -1360,49 +1360,49 @@
|
|
|
1360
1360
|
timestamp
|
|
1361
1361
|
}
|
|
1362
1362
|
}
|
|
1363
|
-
`,zt=[b.SilentIllustration,b.ProductOverlay],
|
|
1364
|
-
matrix(1, 0, 0, 1, ${
|
|
1365
|
-
matrix(1, 0, 0, 1, ${
|
|
1366
|
-
matrix(${
|
|
1367
|
-
matrix(1, 0, 0, 1, ${-
|
|
1368
|
-
`,children:B.jsx("image",{xlinkHref:
|
|
1369
|
-
matrix(1, 0, 0, 1, ${
|
|
1370
|
-
matrix(1, 0, 0, 1, ${
|
|
1363
|
+
`,zt=[b.SilentIllustration,b.ProductOverlay],os=async a=>{const t=[];a.introduction&&t.push({name:"Introduction",title:a.name,renderableSteps:[{type:b.Introduction,stepName:"Introduction",stepTitle:a.name,helpText:a.introduction,data:{},conditions:[]}],silentSteps:[]});for(const n of a.steps){const r=ss(n.stepName,a.stepGroups);if(!r)t.push({name:n.stepName,title:n.stepTitle,renderableSteps:zt.includes(n.type)?[]:[n],silentSteps:zt.includes(n.type)?[n]:[]});else{const i=t.find(o=>o.name===r.name);i?zt.includes(n.type)?i.silentSteps.push(n):i.renderableSteps.push(n):t.push({name:r.name,title:r.name,renderableSteps:zt.includes(n.type)?[]:[n],silentSteps:zt.includes(n.type)?[n]:[]})}}const e="workflow.steps.finish.confirmDesign";return t.push({name:"Finish",title:e,renderableSteps:[{type:b.Finish,stepName:"Finish",stepTitle:e,helpText:"",data:{modelAnimation:a.finalizeStepConfig?a.finalizeStepConfig.modelAnimation:void 0,lookAtAnimation:a.finalizeStepConfig?a.finalizeStepConfig.lookAtAnimation:void 0},conditions:[]}],silentSteps:[]}),t},ss=(a,t)=>t.find(e=>e.stepNames.includes(a)),bt=(a,t)=>(a.conditions||[]).every(e=>{const n=t[e.targetStepName];if(n&&n.selectedVariants){const r=n.selectedVariants;return e.requiredVariantSelections.some(i=>r.find(o=>o.id===i)!==void 0)}return!1}),ls=(a,t)=>{const e={name:a.name,title:a.title,renderableSteps:a.renderableSteps.filter(n=>bt(n,t)),silentSteps:a.silentSteps.filter(n=>bt(n,t))};return e.silentSteps.length===0&&e.renderableSteps.length===0?null:e},vt=(a,t)=>a.map(e=>ls(e,t)).filter(e=>e!==null),cs=async(a,t,e=!1)=>{const n=vt(a,t),r=[];for(const o of n)for(const s of o.renderableSteps){const l=(s.option?.variants||[]).length;s.silent||(s.type===b.Model||s.type===b.Material||s.type===b.Picture||s.type===b.Shape?(l>1||e)&&r.push(s.stepName):r.push(s.stepName))}const i=n.filter(o=>o.renderableSteps.filter(l=>r.includes(l.stepName)).length>0);for(const o of i)o.renderableSteps=o.renderableSteps.filter(s=>r.includes(s.stepName));return i};class Vn{constructor(){this.timestamp=Date.now()}}class zn{constructor(t,e=!0){this.queue=[],this.activePromise=void 0,this.queueMaxSize=void 0,this.queueMaxSize=t,this.isEnabled=e}enqueue(t){if(this.queue.push(t),this.queueMaxSize!==void 0&&this.queue.length>this.queueMaxSize){const e=this.queue.length-1;for(let n=0;n<e;++n)this.queue.shift()}this.isEnabled&&(this.activePromise||(this.activePromise=this.dequeue()))}get enabled(){return this.isEnabled}set enabled(t){!this.isEnabled&&t&&!this.activePromise&&this.getRemainingQueueSize()>0&&(this.activePromise=this.dequeue()),this.isEnabled=t}hasActivePromise(){return!!this.activePromise}getRemainingQueueSize(){return this.queue.length}async finalize(){return this.activePromise?this.activePromise:Promise.resolve()}async dequeue(){const t=this.queue.shift();if(!t){this.activePromise=void 0;return}try{await t.execute()}catch(e){console.log(e)}finally{await this.dequeue()}}}const M=()=>{const a=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},ds=({backgroundColor:a,outlineColor:t,borderRadius:e,configuration:n,elements:r,height:i,maxHeight:o,maxWidth:s,outlineArea:l,position:c,preserveAspectRatio:d,viewBox:u,width:A})=>{const h=e||0,g=2*(l?.scale||1),m=u||{x:0,y:0,width:A,height:i},p=`${m.x} ${m.y} ${m.width} ${m.height}`,f=M(),S=n.purpose===Nt.FreeDesign&&B.jsx("defs",{children:B.jsx("clipPath",{id:"viewboxClip",children:B.jsx("rect",{width:m.width,height:m.height,rx:h})})}),w=n.colorProfiles?.map((E,I)=>B.jsx("color-profile",{name:E.name,xlinkHref:E.key,children:" "},I)),x=r.map(E=>({...E,_renderingConfiguration:n,mask:l?`url(#viewmask-${f})`:void 0})),v=qn(x);return B.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:d,width:A,height:i,style:{gridColumn:1,gridRow:1,maxWidth:s,maxHeight:o,position:c},viewBox:p,children:[w,S,!!a&&B.jsx("rect",{id:"layout-background",width:m.width,height:m.height,fill:a,rx:h}),B.jsx("g",{id:"element-group",clipPath:n.purpose===Nt.FreeDesign?"url(#viewboxClip)":void 0,children:v.map(E=>yr(E)).filter(E=>!!E)}),l&&B.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:l.hidden?"none":t||"#aaaaaa",strokeWidth:g/2,strokeDasharray:`${g*2} ${g}`}),l&&B.jsxs("mask",{id:`viewmask-${f}`,children:[B.jsx("rect",{x:m.x,y:m.y,width:m.width,height:m.height,fill:"black"}),B.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"white"})]})]})},us=(a,t,e,n,r)=>{const i=wt(r),o=e/2,s=n/2,l=a+o,c=t+s,d=Math.sin(i),u=Math.cos(i),A=o,h=o,g=-s,m=s,p=A*u-g*d,f=h*u-m*d,S=A*d+g*u,w=h*d+m*u,x=Math.max(Math.abs(p),Math.abs(f)),v=Math.max(Math.abs(S),Math.abs(w));return{minX:l-x,maxX:l+x,minY:c-v,maxY:c+v}},As=(a,t,e)=>{const n=Math.sqrt(Math.pow(t.x-a.x,2)+Math.pow(t.y-a.y,2)),r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-a.x,2)+Math.pow(e.y-a.y,2));return Math.acos((r*r+n*n-i*i)/(2*r*n))*(180/Math.PI)},wt=a=>a*(Math.PI/180),hs=(a,t,e)=>Math.abs(a-t)<e,gs=(a,t,e)=>{const n=Math.sin(wt(e)),r=Math.cos(wt(e));return{x:(a.x-t.x)*r-(a.y-t.y)*n+t.x,y:(a.x-t.x)*n+(a.y-t.y)*r+t.y}},ms=(a,t)=>({x:(a.x+t.x)/2,y:(a.y+t.y)/2}),ps=(a,t,e,n)=>({x:a.x+t?.x*e,y:a.y+t?.y*n}),fs=(a,t,e,n)=>({x:a.x+(t?.x+t?.width)*e,y:a.y+t?.y*n}),Cs=(a,t,e,n)=>({x:a.x+(t?.x+t?.width)*e,y:a.y+(t?.y+t?.height)*n}),Ft=a=>{switch(a){case H.North:return H.East;case H.East:return H.South;case H.South:return H.West;case H.West:return H.North;case H.Northwest:return H.Northeast;case H.Northeast:return H.Southeast;case H.Southeast:return H.Southwest;case H.Southwest:return H.Northwest}},ws=(a,t)=>t>45&&t<=135?Ft(a):t>135&&t<=225?Ft(Ft(a)):t>225&&t<=315?Ft(Ft(Ft(a))):a,ys=(a,t={x:0,y:0},e={x:1,y:1})=>{const n=wt(a.rotation),r={x:t.x+a.x*e.x,y:t.x+a.y*e.y},i={x:a.x+a.width,y:a.y},o={x:t.x+(a.x+a.width)*e.x,y:t.y+(a.height+a.y)*e.y},s={x:t.x+a.x*e.x,y:t.y+(a.height+a.y)*e.y},l={x:(s.x+o.x)/2,y:s.y-a.height*e.y/2};return{a:Wt(r,l,n),b:Wt(i,l,n),c:Wt(o,l,n),d:Wt(s,l,n),center:l}},Wt=(a,t,e)=>{const n=Math.sin(e),r=Math.cos(e);return{x:(a.x-t.x)*r-(a.y-t.y)*n+t.x,y:(a.x-t.x)*n+(a.y-t.y)*r+t.y}},Ss=.352778,vs=.035277,Ar=a=>{const t=a.rotation||0,e=wt(t),n=Math.cos(e),r=-Math.sin(e);return B.jsx("g",{mask:a.stepName||a.productOverlay?void 0:a.mask,children:B.jsx("g",{transform:`
|
|
1364
|
+
matrix(1, 0, 0, 1, ${a.x}, ${a.y})
|
|
1365
|
+
matrix(1, 0, 0, 1, ${a.width/2}, ${a.height/2})
|
|
1366
|
+
matrix(${n}, ${-r}, ${r}, ${n}, 0, 0)
|
|
1367
|
+
matrix(1, 0, 0, 1, ${-a.width/2}, ${-a.height/2})
|
|
1368
|
+
`,children:B.jsx("image",{xlinkHref:a.src,preserveAspectRatio:a.preserveAspectRatio,width:a.width,height:a.height})})})},hr=a=>{const t=`spiff-group-clip-${a.id}`,e=a.rotation||0,n=wt(e),r=Math.cos(n),i=-Math.sin(n),o=qn(a.children),s=()=>B.jsx("clipPath",{id:t,preserveAspectRatio:"none",children:a.clipPath?B.jsx("path",{d:a.clipPath}):B.jsx("rect",{x:0,y:0,width:a.width,height:a.height})});return B.jsxs(B.Fragment,{children:[B.jsx("defs",{children:s()}),B.jsxs("g",{transform:`
|
|
1369
|
+
matrix(1, 0, 0, 1, ${a.x}, ${a.y})
|
|
1370
|
+
matrix(1, 0, 0, 1, ${a.width/2}, ${a.height/2})
|
|
1371
1371
|
matrix(${r}, ${-i}, ${i}, ${r}, 0, 0)
|
|
1372
|
-
matrix(1, 0, 0, 1, ${-
|
|
1373
|
-
`,children:[
|
|
1374
|
-
${
|
|
1375
|
-
${
|
|
1376
|
-
${
|
|
1372
|
+
matrix(1, 0, 0, 1, ${-a.width/2}, ${-a.height/2})
|
|
1373
|
+
`,children:[a._renderingConfiguration?.debug?B.jsx("rect",{stroke:"red",opacity:.3,fill:"none",x:0,y:0,width:a.width,height:a.height}):void 0,o.map(l=>yr(l)).filter(l=>!!l).map(l=>B.jsx("g",{clipPath:`url(#${t})`,children:l}))]})]})},Es=a=>{const t=`spiff-frame-${a.id}`,e=`spiff-frame-threshold-${a.id}`,n=()=>{if(!a.pattern)return"";if(a.pattern.svg){const u=je(a.pattern.svg,a.pattern.colors||{},!1);return qe(u)}return a.pattern.src};if(!n())return B.jsx(B.Fragment,{});const r=()=>a.threshold?a.invertThreshold?"1 ".repeat(a.threshold)+"0 ".repeat(256-a.threshold):"0 ".repeat(a.threshold)+"1 ".repeat(256-a.threshold):"",i=()=>B.jsx(B.Fragment,{children:a.useThreshold&&B.jsx("defs",{children:B.jsxs("filter",{id:e,"color-interpolation-filters":"sRGB",children:[B.jsx("feColorMatrix",{type:"matrix",values:`
|
|
1374
|
+
${a.thresholdSaturation} ${a.thresholdSaturation} ${a.thresholdSaturation} 0 0
|
|
1375
|
+
${a.thresholdSaturation} ${a.thresholdSaturation} ${a.thresholdSaturation} 0 0
|
|
1376
|
+
${a.thresholdSaturation} ${a.thresholdSaturation} ${a.thresholdSaturation} 0 0
|
|
1377
1377
|
0 0 0 1 0
|
|
1378
|
-
`,result:"greyscale"}),B.jsxs("feComponentTransfer",{in:"greyscale",children:[B.jsx("feFuncR",{type:"discrete",tableValues:r()}),B.jsx("feFuncG",{type:"discrete",tableValues:r()}),B.jsx("feFuncB",{type:"discrete",tableValues:r()})]})]})})}),o=
|
|
1379
|
-
matrix(1, 0, 0, 1, ${
|
|
1380
|
-
matrix(1, 0, 0, 1, ${
|
|
1378
|
+
`,result:"greyscale"}),B.jsxs("feComponentTransfer",{in:"greyscale",children:[B.jsx("feFuncR",{type:"discrete",tableValues:r()}),B.jsx("feFuncG",{type:"discrete",tableValues:r()}),B.jsx("feFuncB",{type:"discrete",tableValues:r()})]})]})})}),o=a.rotation||0,s=wt(o),l=Math.cos(s),c=-Math.sin(s),d=()=>{const u=a.pattern?.x||0,A=a.pattern?.y||0,h=a.pattern?.width||0,g=a.pattern?.height||0,m=a.pattern?.scaleX||1,p=a.pattern?.scaleY||1,f=a.pattern?.rotation||0;return[a.pattern?.svg?{id:`${t}-contents`,type:F.Illustration,x:u,y:A,rotation:f,width:h*m,height:g*p,src:n(),svg:a.pattern?.svg,colors:a.pattern?.colors}:{id:`${t}-contents`,type:F.Image,x:u,y:A,rotation:f,width:h*m,height:g*p,src:n()}]};return B.jsxs(B.Fragment,{children:[i(),B.jsx("g",{opacity:a.opacity,mask:a.stepName?void 0:a.mask,filter:a.useThreshold?`url(#${e})`:void 0,children:B.jsx("g",{transform:`
|
|
1379
|
+
matrix(1, 0, 0, 1, ${a.x}, ${a.y})
|
|
1380
|
+
matrix(1, 0, 0, 1, ${a.width/2}, ${a.height/2})
|
|
1381
1381
|
matrix(${l}, ${-c}, ${c}, ${l}, 0, 0)
|
|
1382
|
-
matrix(1, 0, 0, 1, ${-
|
|
1383
|
-
matrix(${
|
|
1384
|
-
`,children:B.jsx(hr,{id:t,x:0,y:0,rotation:0,width:
|
|
1385
|
-
`),e,
|
|
1386
|
-
`);try{const l=s.flatMap(d=>Pe(d,
|
|
1382
|
+
matrix(1, 0, 0, 1, ${-a.width/2}, ${-a.height/2})
|
|
1383
|
+
matrix(${a.scaleX}, 0, 0, ${a.scaleY}, 0, 0)
|
|
1384
|
+
`,children:B.jsx(hr,{id:t,x:0,y:0,rotation:0,width:a.width,height:a.height,clipPath:a.path,children:d()})})})]})},gr=new Map;class bs{constructor(t){this.font=t,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(t){const e=this.glyphsFromText.get(t);if(e)return e;const n=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,n),n}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let n=0,r=0;return e.forEach(i=>{const o=i.getMetrics();n=Math.max(n,o.yMax),r=Math.min(r,o.yMin)}),n-r}getKerningValue(t,e){if(!t.name||!e.name)return;let n=this.kerningValues.get(t.name);n||(n=new Map,this.kerningValues.set(t.name,n));let r=n.get(e.name);return r||(r=this.font.getKerningValue(t,e),n.set(e.name,r)),r}calculateApproximateHeight(){const e=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let n=0,r=0;return e.forEach(i=>{const o=i.getMetrics();n=Math.max(n,o.yMax),r=Math.min(r,o.yMin)}),n-r}}const Is=a=>a.substring(0,5).toLowerCase().trim()==="data:",an=new Map,Pt=async a=>{if(an.has(a))return an.get(a);const e=(async()=>{try{return yt(a).getFont()}catch{if(Is(a)){const n=Ja(a),r=mn.parse(n);return En(a,r),r}else{const n=await Ve(a,!0),r=mn.parse(n);return En(a,r),await ji(r,a),r}}})();return an.set(a,e),e},Bs=a=>{const t=Ja(a),e=mn.parse(t);return En(a,e),e},yt=a=>{const t=gr.get(a);if(t)return t;throw new Error("Font metrics unavailable for font")},En=(a,t)=>{const e=new bs(t);return gr.set(a,e),e},Ps=async a=>{const t=lt(),e=t.parseFromString(a,"image/svg+xml"),n=e.firstElementChild,r=new Map;n.querySelectorAll("style").forEach(d=>{Qa.parse(d.innerHTML).stylesheet?.rules.forEach(A=>{if(A.type==="font-face"&&A.declarations){const h=A.declarations.find(p=>p.property==="font-family")?.value,m=A.declarations.find(p=>p.property==="src")?.value?.match(/'(https.*?)'/)?.[1];h&&m&&r.set(h,m)}})});const o=e.querySelectorAll("tspan");for(let d=0;d<o.length;d++){const u=o.item(d),A=u.closest("text"),h=u.closest("g"),g=A.getAttribute("font-family"),m=await Pt(r.get(g)),p=A.getAttribute("fill"),f=A.getAttribute("stroke"),S=A.getAttribute("stroke-width"),w=m.getPath(u.innerHTML,0,0,parseInt(A.getAttribute("font-size")??"72")),x=w.getBoundingBox().x2-w.getBoundingBox().x1;let v=0;const E=u.getAttribute("text-anchor");E==="middle"?v=x/2:E==="end"&&(v=x);const I=m.getPath(u.innerHTML,parseFloat(u.getAttribute("x")??"0")-v,parseFloat(u.getAttribute("y")??"0"),parseInt(A.getAttribute("font-size")??"72"));I.fill=p,I.stroke=f,I.strokeWidth=parseFloat(S??"0");const N=I.toSVG(2),P=t.parseFromString(N,"image/svg+xml").firstElementChild;h.appendChild(P)}return e.querySelectorAll("text").forEach(d=>d.remove()),St().serializeToString(n)},ke=(a,t,e,n)=>Math.max(ks(a.join(`
|
|
1385
|
+
`),e,n),t),pa=(a,t,e,n,r,i)=>{const o=(i||fr)*r.getApproximateHeight(),s=t.split(`
|
|
1386
|
+
`);try{const l=s.flatMap(d=>Pe(d,a.width,n,r)),c=l.flatMap(d=>d.lines);return{lines:c,requiredHeight:l.flatMap(d=>d.lines).length*(n*o),fontSize:e,requiredWidth:ke(c,a.width,n,r)}}catch{const c=t.split("");return{lines:c,requiredHeight:c.length*(n*o),fontSize:e,requiredWidth:ke(c,a.width,n,r)}}},Pe=(a,t,e,n)=>{const r=pt(a,e,n);if(r<=t)return{lines:[a],width:r};if(!(a.indexOf(" ")>-1)){if(a.length<=1)throw new Error(`Character ${a} is wider than region`);const d=Math.floor(a.length/2),u=Pe(a.slice(0,d),t,e,n),A=Pe(a.slice(d),t,e,n);return{lines:[...u.lines,...A.lines],width:Math.max(u.width,A.width)}}const o=a.split(" "),s=[];let l=-1/0,c=0;for(;c<o.length;){const d=o[c];if(pt(d,e,n)>t){const u=Pe(d,t,e,n);s.push(...u.lines),l=Math.max(l,u.width),c++}else{const u=[d];l=Math.max(l,pt(d,e,n));let A=c+1,h=!0;for(;A<o.length&&h;){const g=o[A],m=pt(`${u.join(" ")} ${g}`,e,n);m<=t?(u.push(g),l=Math.max(l,m),A++):h=!1}s.push(u.join(" ")),c=A}}if(l<0)throw new Error(`No max width calculated for text: ${s}.`);return{lines:s,width:l}},xs=(a,t,e,n,r,i)=>{const o=(i??fr)*t.getApproximateHeight(),s=1/e.unitsPerEm,l=mr(a,s,t),c=a.length*o*s,d=n/l,u=r/c;return Math.min(u,d)},Fs=(a,t,e,n)=>{const r=yt(t.fontData.assetUrl),i=r.getFont(),o=t.fontSize/i.unitsPerEm;if(!e)return pa(t,a,t.fontSize,o,r,n);let s;if(t.text?s=t.text.split(`
|
|
1387
1387
|
`):s=t.input?.split(`
|
|
1388
|
-
`)??[""],e.input===
|
|
1389
|
-
`)),
|
|
1390
|
-
`),height:r.requiredHeight,width:r.requiredWidth,fontSize:r.fontSize,input:t}}else return{text:t}})()}:
|
|
1391
|
-
`),u=
|
|
1388
|
+
`)??[""],e.input===a&&t.width===e.width&&t.height===e.height&&t.lineHeight===e.lineHeight)return{lines:s,requiredHeight:t.height,requiredWidth:ke(s,t.width,o,r),fontSize:t.fontSize};const l=t.width!==e.width!=(t.height!==e.height);return t.lineHeight===e.lineHeight&&!l&&e.input===a?{lines:s,requiredHeight:t.height,requiredWidth:ke(s,t.width,o,r),fontSize:xs(s,r,i,t.width,t.height,n)}:pa(t,a,t.fontSize,o,r,n)},Ds=(a,t,e,n,r)=>{const o=yt(t.assetUrl).getFont();let s={...a};const l={...a},c=mr(n,e/o.unitsPerEm,yt(t.assetUrl));return c&&c<s.width&&(l.width=c,r==="left"?(l.left+=Math.sin(s.rotation*Math.PI/360)*(s.width-c),l.top+=Math.sin(s.rotation*Math.PI/180)*(c-s.width)/2):r==="right"?l.left+=s.width-c:l.left+=(s.width-c)/2,n&&Ms(n,n).every(([d,u])=>d===u)&&(s=l)),s},rn=1,pt=(a,t,e)=>{let n=0;const r=e.getGlyphs(a);return r.forEach((i,o)=>{if(i.advanceWidth&&(n+=i.advanceWidth),o<r.length-1){const s=e.getKerningValue(i,r[o+1]);n+=s||0}}),n*=t,n},ks=(a,t,e)=>{let n=0;const r=e.getGlyphs(a);return r.forEach((i,o)=>{if(i.advanceWidth&&(n=Math.max(n,i.advanceWidth)),o<r.length-1){const s=e.getKerningValue(i,r[o+1]);n=Math.max(n,s||0)}}),n*=t,n},mr=(a,t,e)=>{let n=0;return a.forEach(r=>{n=Math.max(n,pt(r,t,e))}),n},fa={stripControlCharacters:!0,vertical:!1,uppercase:!1},Me=(a,t=fa)=>{const e={...fa,...t};let n=a||"";return e.stripControlCharacters&&(n=n.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),e.uppercase&&(n=n.toUpperCase()),e.vertical&&(n=n.split("").join(`
|
|
1389
|
+
`)),n},Ms=(a,t)=>a.map((e,n)=>[e,t[n]]),Ts=(a="center",t=!1)=>t?"center":a,pr=a=>a==="left"?"start":a==="right"?"end":"middle",he=(a,t,e)=>a.fontData?{...a,...(()=>{if(a.algorithm===Bt.Traditional){const r=Fs(t,a,e,a.lineHeight);return{text:r.lines.join(`
|
|
1390
|
+
`),height:r.requiredHeight,width:r.requiredWidth,fontSize:r.fontSize,input:t}}else return{text:t}})()}:a,fr=1.1;function Mt(a,t){return Cr(a,t.getTemplatingContext())}function Cr(a,t){try{a=Di.compile(a)(t)}catch(e){console.error("failed to render templated text",e)}return a}const Ns=a=>{const e=(a.rotation||0)*Math.PI/180,n=Math.cos(e),r=-Math.sin(e),i=`text-path-${a.id}`,o=`text-fill-${a.id}`,s=a.x+(a.curved?0:a.width/2),l=a.y+(a.curved?0:a.height/2),c=Cr(a.text||"",a._renderingConfiguration?.templatingContext),d=c.split(`
|
|
1391
|
+
`),u=a.strokeColor?.browserValue&&a.strokeThickness?a.strokeColor?.browserValue:void 0,A=a.strokeColor?.browserValue&&a.strokeThickness?a.strokeThickness:void 0;if(a.curved&&!a.paths||!a.fontData)return null;const h=()=>a.textFillImage?`url("#${o}")`:a._renderingConfiguration?.spotColors&&a.fillSpotColorDefinition?`${a.fill} ${er(a.fillSpotColorDefinition)}`:a.fill;return B.jsxs(B.Fragment,{children:[B.jsxs("defs",{children:[a.textFillImage&&B.jsx("pattern",{id:o,patternUnits:"userSpaceOnUse",width:a.textFillImage.scale*a.textFillImage.width,height:a.textFillImage.scale*a.textFillImage.height,x:0,y:0,children:B.jsx("image",{href:a.textFillImage.src,xlinkHref:a.textFillImage.src,width:a.textFillImage.scale*a.textFillImage.width,height:a.textFillImage.scale*a.textFillImage.height})}),B.jsx("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`
|
|
1392
1392
|
@font-face {
|
|
1393
|
-
font-family: '${
|
|
1394
|
-
src: url('${
|
|
1393
|
+
font-family: '${a.fontData.name}';
|
|
1394
|
+
src: url('${a.fontData.assetUrl}') format('truetype');
|
|
1395
1395
|
}
|
|
1396
|
-
`}}),
|
|
1397
|
-
matrix(1, 0, 0, 1, ${
|
|
1398
|
-
matrix(1, 0, 0, 1, ${
|
|
1399
|
-
matrix(${
|
|
1400
|
-
matrix(1, 0, 0, 1, ${-
|
|
1401
|
-
`;if(!
|
|
1396
|
+
`}}),a.curved&&a.paths?B.jsx("path",{id:i,d:a.paths[0]}):void 0]}),a._renderingConfiguration?.debug?B.jsx("rect",{stroke:"blue",fill:"none",x:a.x,y:a.y,width:a.width,height:a.height}):void 0,B.jsx("g",{mask:a.stepName?void 0:a.mask,children:B.jsx("g",{transform:`matrix(${n}, ${-r}, ${r}, ${n}, ${s}, ${l})`,children:B.jsx("text",{xmlSpace:"preserve",fontFamily:`'${a.fontData.name}'`,fontSize:a.fontSize,fontStyle:"normal",fontWeight:"normal",fill:h(),style:{whiteSpace:"pre",userSelect:"none"},stroke:u,strokeWidth:A,children:a.curved?B.jsx(Rs,{text:c,curvedPathId:i,align:a.align}):d.map((g,m)=>B.jsx(Qs,{align:a.vertical?"center":a.align,fontSize:a.fontSize,thisLineIdx:m,amountLines:d.length,text:g,textboxHeight:a.height,textboxWidth:a.width,lineHeight:a.lineHeight,vertical:a.vertical,verticalAlign:a.verticalAlign,fontData:a.fontData},m))})})})]})},Qs=a=>{const t=()=>{if(a.lineHeight!==void 0)return a.lineHeight*a.fontSize;const r=yt(a.fontData.assetUrl),i=r.getFont(),o=a.fontSize/i.unitsPerEm;return r.getApproximateHeight()*o},e=()=>a.align==="left"?-a.textboxWidth/2:a.align==="right"?a.textboxWidth/2:0,n=()=>{const r=t(),i=a.textboxHeight/2;if(a.verticalAlign==="top")return-i+a.fontSize*3/4+a.thisLineIdx*r;if(a.verticalAlign==="bottom"){const s=a.amountLines-1-a.thisLineIdx;return i-a.fontSize/4-s*r}const o=(a.amountLines-1)/2;return(a.thisLineIdx-o)*r+a.fontSize/4};return B.jsx("tspan",{textAnchor:pr(a.align),x:e(),y:`${n()}px`,children:a.text})},Rs=a=>{const t=`#${a.curvedPathId}`,e=()=>a.align==="left"?"0%":a.align==="right"?"100%":"50%";return B.jsx("textPath",{startOffset:e(),textAnchor:pr(a.align),href:t,xlinkHref:t,children:a.text})},Os=a=>{if(a.cachedObjectURL&&!a._renderingConfiguration?.omitCachedFields)return B.jsx(Ar,{id:a.id,src:a.cachedObjectURL,x:a.x,y:a.y,width:a.width,height:a.height,rotation:a.rotation,preserveAspectRatio:"none",immutable:a.immutable,mask:a.stepName?void 0:a.mask});const t=a.rotation||0,e=wt(t),n=Math.cos(e),r=-Math.sin(e),i=`
|
|
1397
|
+
matrix(1, 0, 0, 1, ${a.x}, ${a.y})
|
|
1398
|
+
matrix(1, 0, 0, 1, ${a.width/2}, ${a.height/2})
|
|
1399
|
+
matrix(${n}, ${-r}, ${r}, ${n}, 0, 0)
|
|
1400
|
+
matrix(1, 0, 0, 1, ${-a.width/2}, ${-a.height/2})
|
|
1401
|
+
`;if(!a.svg)throw new Error(`Illustration element ${a.id} (stepName ${a.stepName}) lacked svg from src ${a.src} at render time.`);return B.jsx("g",{mask:a.stepName?void 0:a.mask,children:B.jsx("g",{transform:i,dangerouslySetInnerHTML:{__html:Un(a.svg,a.width,a.height,a.colors,a._renderingConfiguration?.spotColors)}})})};class wr{constructor(){this.id=M(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(t){this.stateCallbacks.push(t)}unregisterStateCallback(t){this.stateCallbacks.filter(e=>e!==t)}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach(t=>t())}apply(t,e){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.nextCommands=[],e||this.prevCommands.push(t)}undo(){if(!this.state)return;const t=this.prevCommands.pop();if(!t)return;const e=t.undo();this.state={...this.state,transaction:e},this.nextCommands.push(t),this.runStateCallbacks()}redo(){if(!this.state)return;const t=this.nextCommands.pop();t&&(this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.prevCommands.push(t))}flattenSequence(t,e){const r=this.prevCommands.filter(i=>i.sequenceId===t).pop();r&&(this.prevCommands=this.prevCommands.filter(i=>i.sequenceId!==t),r?.overrideOldState(e),this.prevCommands.push(r))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],n=e?.layout;if(!n)throw new Error(`No layout: ${t}`);const r=[...e?.elements||[]];return this.getLayoutDataWithState(n,r)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=[...Object.keys(this.state.transaction?.layouts)];return[...new Set(t)].map(n=>this.getLayoutById(n))}getLayoutDataWithState(t,e){return{layoutState:{layout:t,elements:e},getComponentWithProps:n=>Ye(t,e,n)}}initialize(t,e){if(e){this.state={transaction:e};return}let n={serializableWorkflow:{steps:[]},layouts:{}};t.forEach(r=>{n=new Hn(r).apply(n)}),this.runStateCallbacks(),this.state={transaction:n}}commandReducer(t,e){const n=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(n)}}}const yr=a=>a.type===F.Image?B.jsx(Ar,{...a},a.id):a.type===F.Frame?B.jsx(Es,{...a},a.id):a.type===F.Illustration?B.jsx(Os,{...a},a.id):a.type===F.Textbox?B.jsx(Ns,{...a},a.id):a.type===F.Group?B.jsx(hr,{...a},a.id):null,Ye=(a,t,e)=>{const n=e.renderingConfiguration,r=n?.removeExcludedElements?t.filter(i=>!i.excludeFromExport):t;return B.jsx(ds,{preserveAspectRatio:void 0,elements:r,backgroundColor:a.transparentBackground?void 0:e.backgroundColor?e.backgroundColor:"white",width:e.width||a.width,height:e.height||a.height,viewBox:n?.region?{x:n.region.left,y:n.region.top,width:n.region.width,height:n.region.height}:{x:0,y:0,width:a.width,height:a.height},configuration:n,outlineArea:e.outlineArea,maxHeight:e.maxHeight,maxWidth:e.maxWidth,position:e.position,borderRadius:e.borderRadius,outlineColor:e.outlineColor})};function qn(a){return a.sort((t,e)=>{const n=t.layer||0,r=e.layer||0;if(n<r)return-1;if(n>r)return 1;const i=t.layerIndex||0,o=e.layerIndex||0;return i<o?-1:i>o?1:0})}const ge=a=>{const t=a.variants;if(t){if(t.length===1)return t[0];if(a.defaultVariant!==void 0)return t.find(e=>e.id===a.defaultVariant)}},dt=new Map,Dt=new Map,on=new Map,Sr=async(a,t)=>{if(!t){if(!a)throw new Error("No region or src supplied. Cannot construct frame!");return bn(a)}return et(t)},bn=a=>{const t=a.width,e=a.height;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${t} ${e}'>
|
|
1402
1402
|
<path id="target-path" d='M0 0 h ${t} v ${e} h ${-t} Z' />
|
|
1403
1403
|
</svg>
|
|
1404
|
-
`}
|
|
1405
|
-
`)||[],A.align);return{...A,x:h.left,y:h.top+(u.height-h.height)/2,width:h.width,height:h.height}}static async getShape(t,e){const
|
|
1404
|
+
`},$s=(a,t)=>{if(!t)return;const e=t.variants?.find(n=>n.id===a.frameVariantId)||ge(t);if(!e)throw new Error(`No variant with ID: ${a.frameVariantId}`);if(!e.asset)throw new Error(`No asset for variant with ID: ${a.frameVariantId}`);return e},me=async a=>{if(on.has(a))return on.get(a);const e=(async()=>{if(Dt.has(a))return Dt.get(a);await new Promise(A=>setTimeout(A,0));const r=lt().parseFromString(a,"image/svg+xml"),i=r.querySelector("svg");if(!i)throw new Error("Malformed frame SVG: <svg> tag not found");const o=i.getAttribute("viewBox");if(!o)throw new Error("SVG missing viewBox.");const s=o.split(" "),l=parseFloat(s[3])||1,c=parseFloat(s[2])||1,d=r.getElementById("target-path"),u=r.getElementsByClassName("st0").item(0);if(d){const A=d.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const h={path:A,width:c,height:l};return Dt.set(A,h),h}if(u){const A=u.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const h={path:A,width:c,height:l};return Dt.set(A,h),h}throw new Error("Malformed frame SVG")})();return on.set(a,e),e},Gn=(a,t,e,n)=>{const r=t.width/t.height,i=a.width/a.height;let o;n?i>r?o=t.height/a.height:o=t.width/a.width:i>r?o=t.width/a.width:o=t.height/a.height,e?.scale!==void 0&&(o*=e?.scale);const s=t.width/2,l=t.height/2,c=s-a.width/2*o,d=e?.left||c,u=l-a.height/2*o,A=e?.top||u;return{x:d,y:A,zoom:o}},In=async a=>{if(dt.has(a))return dt.get(a);if(a.startsWith("data:image/svg+xml")){const e=ki.dataUriToBuffer(a),n=new TextDecoder().decode(e.buffer),r=Wn(n),i={src:a,width:r.width,height:r.height,aspect:r.width/r.height};return dt.set(a,i),i}if((a.split(".").pop()?.toLowerCase()??"")==="svg"){const e=await jn(a),n=e.width,r=e.height,i={src:a,width:n,height:r,aspect:n/r};return dt.set(a,i),i}else{const e=await Ve(a,!0),n=await de(e),r={src:a,width:n.width,height:n.height,aspect:n.width/n.height};return dt.set(a,r),r}},jn=async a=>{const t=await et(a);return Wn(t)},Ca=a=>a.endsWith("mm")?Number(a.replace("mm",""))*3.7795275591:a.endsWith("px")?Number(a.replace("px","")):Number(a),Wn=a=>{const n=lt().parseFromString(a,"image/svg+xml").querySelector("svg");if(!n)throw new Error("No svg tag found, this svg must be malformed!");const r=n.getAttribute("viewBox"),i=n.getAttribute("width"),o=n.getAttribute("height"),s=o&&i?[0,0,Ca(i),Ca(o)]:r?.split(" ").map(l=>Number(l));if(!s)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:s[2],height:s[3]}},qt=(a,t)=>{const e=a.layoutState.elements.filter(r=>r.layer===t),n=Math.max(...e.map(r=>r.layerIndex).filter(r=>r!==void 0));return Math.max(n,0)+1},vr=async a=>new Promise(t=>{et(a).then(e=>{t(e)}).catch(e=>console.error(e))}),sn=new Map,oe=async a=>{if(sn.has(a))return sn.get(a);const t=async r=>new Promise((i,o)=>{try{if(!(!!URL&&!!URL.createObjectURL))throw new Error("Environment incapable of generating ObjectURL");r.toBlob(l=>{if(!l)throw r.width===0||r.height===0?new Error(`Canvas dimensions are invalid (${r.width},${r.height})`):r.width*r.height>=268435456?new Error(`Canvas dimensions exceed device limit (${r.width},${r.height})`):new Error("Couldn't generate object URL for Illustration, the blob was undefined!");i(URL.createObjectURL(l))})}catch(s){o(s)}}),n=(async()=>{const o=lt().parseFromString(a,"image/svg+xml").firstElementChild;if(!o)throw new Error("Failed to read SVG");const l=St().serializeToString(o),c=Ct(),d=c.getContext("2d"),u=await Nn.Pith.from(d,l,{anonymousCrossOrigin:!0,ignoreDimensions:!1,createCanvas:Ct,createImage:ce,DOMParser:$n(),fetch:rt}),A=o.getAttribute("width"),h=o.getAttribute("height"),g=2048;if(h&&A){const m=parseFloat(h),f=parseFloat(A)/m;f>1?u.resize(g,g/f):u.resize(g*f,g)}else u.resize(g,g);return await u.render(),await t(c)})();return sn.set(a,n),n},Gt=async(a,t,e,n)=>{const r=a.layoutState.layout.useEditableArea&&a.layoutState.layout.editableArea||{width:a.layoutState.layout.width,height:a.layoutState.layout.height,x:0,y:0},i=r.width<r.height?r.width:r.height,o=a.layoutState.layout.useEditableArea?i/1.3:i/2,s={top:r.y+r.height/2-o/2,left:r.x+r.width/2-o/2,width:o,height:o,rotation:0,panelId:a.layoutState.layout.panelId};if(e&&t===F.Illustration){const l=await it(await vr(e)),A=lt().parseFromString(l.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!A)throw new Error("SVG missing viewBox.");const h=s.height,g=A.split(" "),m=parseFloat(g[2])||1,p=parseFloat(g[3])||1,f=m/p;s.height=s.width/f,s.top+=(h-s.height)/2}if(e&&t===F.Image){const l=s.height,c=await Ve(e),d=await de(c),u=d.width/d.height;s.height=s.width/u,s.top+=(l-s.height)/2}if(e&&t===F.Textbox&&n?.text&&n?.fontScale){await Pt(e);const l=yt(e),c=pt(n.text,n?.fontScale,l);s.width=Math.min(c,r.width*.85),s.left=r.x+r.width/2-s.width/2}return s};class Us{static async getFrame(t,e){const n=await Sr(e.region,e.src),r=await me(n),i=e.region||await Gt(t,F.Frame);return{id:M(),x:i.left,y:i.top,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||qt(t,i.layer||0),rotation:i.rotation,scaleX:i.width/r.width,scaleY:i.height/r.height,path:r.path,dataWidth:r.width,dataHeight:r.height,type:F.Frame,disablePlaceholder:e.configuration.disablePlaceholder,focalBlur:e.configuration.focalBlur,focalBlurStrength:e.configuration.focalBlurStrength,focalBlurRadius:e.configuration.focalBlurRadius,forceImageCover:e.configuration.forceImageCover,pattern:void 0,immutable:i.immutable}}static async getImage(t,e){const n=e.region||await Gt(t,F.Image,e.src);return{id:M(),src:e.src,type:F.Image,y:n.top,x:n.left,rotation:n.rotation,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||qt(t,n.layer||0),immutable:n.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:n,fontSrc:r,designInputStep:i}=e,o=await Pt(r),s={assetUrl:r,name:o.names.fullName.en},l=i?.text||n.defaultText||"",c=n.replaceableText?n.replaceableText.replace("{{}}",l):l,d=Me(c,{vertical:n.vertical,uppercase:n.uppercase}),u=e.region||await Gt(t,F.Textbox,r,{text:d,fontScale:n.size?n.size/o.unitsPerEm:void 0}),A=he({id:M(),type:F.Textbox,x:u.left,y:u.top,width:u.width,height:u.height,align:Ts(n.textAlign,n.vertical),curved:n.curved,fill:i?.color||n.colour||"#000000",fontData:s,layer:u.layer||0,layerIndex:u.layerIndex||qt(t,u.layer||0),paths:n.paths,rotation:u.rotation,vertical:n.vertical,verticalAlign:n.verticalAlign||"middle",algorithm:Bt.Traditional,fontSize:n.size||Math.max(Math.round(u.height*.025),1),text:d,input:l},d),h=Ds({...u,height:A.height},s,A.fontSize,A?.text?.split(`
|
|
1405
|
+
`)||[],A.align);return{...A,x:h.left,y:h.top+(u.height-h.height)/2,width:h.width,height:h.height}}static async getShape(t,e){const n=`
|
|
1406
1406
|
<svg
|
|
1407
1407
|
xmlns="http://www.w3.org/2000/svg"
|
|
1408
1408
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
@@ -1422,7 +1422,7 @@
|
|
|
1422
1422
|
fill="${e.color}"
|
|
1423
1423
|
/>
|
|
1424
1424
|
</svg>
|
|
1425
|
-
`,r={};r["spiff-fill-shape"]={browserValue:e.color};const i=e.region?.item||await Gt(t,F.Illustration),o=M();return{stepRegion:e.region?.item,stepRegionIndex:e.region?.index,colors:r,id:o,svg:a,type:F.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||qt(t,i.layer||0),immutable:i.immutable}}static async getIllustration(t,e){const a=e.region?.item||await Gt(t,F.Illustration,e.src),r=await it(await vr(e.src)),i=await oe(r.svg),o=M();return{cachedObjectURL:i,stepRegion:e.region?.item,stepRegionIndex:e.region?.index,colors:r.colors,id:o,src:e.src,svg:r.svg,type:F.Illustration,y:a.top,x:a.left,rotation:a.rotation,width:a.width,height:a.height,layer:a.layer||0,layerIndex:a.layerIndex||qt(t,a.layer||0),immutable:a.immutable}}}class q extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,q.prototype)}}const L=(n,t)=>X(n,t).elements.find(r=>r.id===n),X=(n,t)=>{const e=Object.values(t).find(a=>a.elements.some(r=>r.id===n));if(!e)throw new q;return e},tt=(n,t)=>{const e=[...t.elements.filter(r=>r.id!==n.id),n],a=za(e);return{layout:t.layout,elements:a,modificationID:M()}},Ia=async n=>{const t=[...Object.keys(n.layouts)],e=[...new Set(t)];for(let a=0;a<e.length;a++){const r=e[a],i=n.layouts[r];await Promise.all(i.elements.map(async o=>{if(o.type==="illustration"){const s=o;if(s.src&&!s.svg){const l=await et(s.src),c=await it(l);s.svg=$a(c.svg,s.width,s.height,s.colors)}}else if(o.type==="frame"){const s=o;if(s.pattern?.colors&&s.pattern?.src){const l=await et(s.pattern?.src),c=await it(l);s.pattern.svg=c.svg}}isNaN(o.x)&&(o.x=0),isNaN(o.y)&&(o.y=0),isNaN(o.width)&&(o.width=0),isNaN(o.height)&&(o.height=0),isNaN(o.rotation)&&(o.rotation=0)}))}for(const a in n.layouts){const r=n.layouts[a].elements.filter(o=>o.type===F.Illustration);for(let o=0;o<r.length;++o){const s=r[o];if(s.src&&s.svg)try{s.cachedObjectURL=await oe(s.svg)}catch(l){console.log(l)}}const i=n.layouts[a].elements.filter(o=>o.type===F.Textbox);for(let o=0;o<i.length;++o){const s=i[o];s.fontData?.assetUrl&&await Pt(s.fontData.assetUrl)}}};class O{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class wn extends O{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class Us extends O{constructor(t,e,a){super(),this.id=t,this.x=e,this.y=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,x:this.x,y:this.y},r=X(e.id,Object.values(t.layouts)),i=tt(a,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class Ls extends O{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,rotation:this.angle},r=X(e.id,Object.values(t.layouts)),i=tt(a,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class Vs extends O{constructor(t,e,a){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(a)}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;let a={...e,width:this.width,height:this.height};if(e.type==="frame"){const o=a;o.scaleX=o.scaleX*this.width/e.width,o.scaleY=o.scaleY*this.height/e.height}else if(e.type==="textbox"){const o=a,s=(!o.algorithm||o.algorithm===Bt.Autosize?o.text:o.input)??"";a=he(o,s,e)}const r=X(e.id,Object.values(t.layouts)),i=tt(a,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class $ extends O{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce((e,a)=>a.apply(e),t)}}class Wa extends O{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:M()}}}}}class G extends O{constructor(t,e){super(),this.element=t,this.layout=e}apply(t){this.oldState=t,t.layouts[this.layout.id]||(t.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const e=t.layouts[this.layout.id].elements;if(e.find(s=>s.id===this.element.id))throw new Error(`Failed to apply new ${this.element.type} element because ID ${this.element.id} already taken`);if(this.element.productOverlay||e.length===0){const s=[...e,this.element];return this.element.layerIndex===void 0&&(this.element.layerIndex=this.assignIndex(this.element,s)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:s,modificationID:M()}}}}const r=e[e.length-1],i=r.productOverlay?r:null;i&&e.pop();let o;if(this.element.layerIndex!==null&&this.element.layerIndex!==void 0)o=[...e,this.element].sort((s,l)=>s.layerIndex!==void 0&&l.layerIndex!==void 0?s.layerIndex-l.layerIndex:0);else{const s=this.assignIndex(this.element,e);this.element.layerIndex=s!==void 0?s:0,o=[...e,this.element]}return i&&o.push(i),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:o,modificationID:M()}}}}assignIndex(t,e){if(e.length===0)return 0;const a=e.filter(r=>(r.layer||0)===(t.layer||0)).sort((r,i)=>(r.layerIndex||0)-(i.layerIndex||0))[e.length-1]?.layerIndex;return a!==void 0?a+1:0}}class xt extends O{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const a=Object.values(t.layouts).map(i=>(i.elements.filter(s=>s.id!==this.id).length!==i.elements.length&&(e=!0),{...i,elements:i.elements.filter(s=>s.id!==this.id),modificationID:M()}));e||console.log(`Failed to delete element ${this.id}`);const r={};return a.forEach(i=>{r[i.layout.id]=i}),{...t,layouts:r}}}class Er extends O{constructor(t,e,a){super(),this.id=t,this.color=e,this.textFillSpotColor=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},r=X(e.id,Object.values(t.layouts)),i=tt(a,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class sa extends O{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,textFillImage:this.imageFill},r=X(e.id,Object.values(t.layouts)),i=tt(a,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class br extends O{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,fontSize:this.size},r=X(e.id,Object.values(t.layouts)),i=(!e.algorithm||e.algorithm===Bt.Autosize?e.text:e.input)??"",o=tt(he(a,i),r);return{...t,layouts:{...t.layouts,[r.layout.id]:o}}}}class Ba extends O{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,fontData:this.fontData},r=X(e.id,Object.values(t.layouts)),i=(!e.algorithm||e.algorithm===Bt.Autosize?e.text:e.input)??"",o=tt(he(a,i),r);return{...t,layouts:{...t.layouts,[r.layout.id]:o}}}}class Ir extends O{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,align:this.align},r=X(e.id,Object.values(t.layouts)),i=tt(a,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class zs extends O{constructor(t,e,a){super(),this.id=t,this.imageData=e,this.offsets=a}apply(t){this.oldState=t;const e=X(this.id,Object.values(t.layouts)),a=e.elements.findIndex(s=>s.id===this.id),r=e.elements[a].pattern,i=[...e.elements];i.splice(a,1,{...e.elements[a],pattern:{...r,src:this.imageData.src,x:this.offsets.x,y:this.offsets.y,width:this.imageData.width,height:this.imageData.height,scaleX:this.offsets.zoom,scaleY:this.offsets.zoom,svg:this.imageData.svg,colors:this.imageData.colors}});const o={...e,elements:i,modificationID:M()};return{...t,layouts:{...t.layouts,[e.layout.id]:o}}}}class qs extends O{constructor(t,e,a,r,i){super(),this.id=t,this.useThreshold=e,this.invertThreshold=a,this.threshold=r,this.thresholdSaturation=i}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,useThreshold:this.useThreshold,invertThreshold:this.invertThreshold,threshold:this.threshold,thresholdSaturation:this.thresholdSaturation},r=X(e.id,Object.values(t.layouts)),i=tt(a,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class Gs extends O{constructor(t,e){super(),this.id=t,this.src=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,src:this.src},r=X(e.id,Object.values(t.layouts)),i=tt(a,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class Br extends O{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a=X(e.id,Object.values(t.layouts)),r=tt(he(e,this.text,e),a);return{...t,layouts:{...t.layouts,[a.layout.id]:r}}}}class la extends O{constructor(t,e,a){super(),this.id=t,this.strokeColor=e,this.strokeThickness=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,strokeColor:this.strokeColor,strokeThickness:this.strokeThickness},r=X(e.id,Object.values(t.layouts)),i=tt(a,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class Pa extends O{constructor(t,e,a){super(),this.id=t,this.className=e,this.fill=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a=e.colors||{},r=a[this.className];typeof this.fill=="string"?a[this.className]={browserValue:this.fill,spotColor:r?.spotColor,pmsValue:r?.pmsValue}:a[this.className]={browserValue:this.fill.browserValue,spotColor:r?.spotColor,pmsValue:this.fill.pmsValue};const i={...e,colors:a},o=X(e.id,Object.values(t.layouts)),s=tt(i,o);return{...t,layouts:{...t.layouts,[o.layout.id]:s}}}}class js extends O{constructor(t,e,a){super(),this.id=t,this.svgBody=e,this.objectURL=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},r=X(e.id,Object.values(t.layouts)),i=tt(a,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class Ws extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new q;const a=Object.values(t.layouts).find(o=>o.elements.find(s=>s.id===this.id));if(!a)throw new Error("Layout missing from state!");const r=a.elements.findIndex(o=>o.id===this.id);a.elements.push(a.elements.splice(r,1)[0]);const i=[...a.elements];return i.forEach((o,s)=>o.layerIndex=s),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:i,modificationID:M()}}}}}class Hs extends O{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a=Object.values(t.layouts).find(s=>s.elements.find(l=>l.id===this.id));if(!a)throw new Error("Layout missing from state!");const r=a.elements.findIndex(s=>s.id===this.id);a.elements.splice(r,1),a.elements.unshift(e);const i=[...a.elements],o=i.splice(r,1)[0];return i.splice(r,0,o),i.forEach((s,l)=>s.layerIndex=l),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:i,modificationID:M()}}}}}class Ys extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new q;const a=Object.values(t.layouts).find(l=>l.elements.find(c=>c.id===this.id));if(!a)throw new Error("Layout missing from state!");const r=a.elements.findIndex(l=>l.id===this.id),i=r+1,o=[...a.elements],s=o.splice(r,1)[0];return o.splice(i,0,s),o.forEach((l,c)=>l.layerIndex=c),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:o,modificationID:M()}}}}}class Js extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new q;const a=Object.values(t.layouts).find(l=>l.elements.find(c=>c.id===this.id));if(!a)throw new Error("Layout missing from state!");const r=a.elements.findIndex(l=>l.id===this.id),i=r-1,o=[...a.elements],s=o.splice(r,1)[0];return o.splice(i,0,s),o.forEach((l,c)=>l.layerIndex=c),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:o,modificationID:M()}}}}}class yn{constructor(t,e,a){this.processRegion=async r=>{const i=this.layouts.find(l=>l.panelId===r.panelId);if(!i)throw new J(r);let o="";if(this.configuration.type===b.ProductOverlay){let l="";if(this.product?.overlayImageUrl&&(l=this.product.overlayImageUrl),o=l,!l)throw new re(this.configuration,"Couldn't find an asset for product overlay step")}const s=this.evaluateAssetType();if(s===F.Image){const l=this.configuration.type===b.SilentIllustration?this.configuration.data.asset?.fileLink:this.product?.overlayImageUrl;if(!l)throw new Error("Undefined raster silent step source");const c={stepName:this.configuration.stepName,id:M(),src:l,type:s,y:r.top,x:r.left,width:r.width,height:r.height,layer:r.layer,layerIndex:r.layerIndex,immutable:r.immutable,productOverlay:this.configuration.type===b.ProductOverlay?!0:void 0,rotation:r.rotation,excludeFromExport:this.configuration.data.excludeFromPrint,preserveAspectRatio:"none"};return{regionElement:{id:c.id,region:r},command:new G(c,i)}}else{const l=this.configuration.type===b.SilentIllustration?this.configuration.data.asset?.fileLink:o,d=await it(await(async()=>new Promise((A,h)=>{if(!l){h("Undefined vector silent step source");return}et(l,!0).then(g=>{A(g)}).catch(g=>console.error(g))}))()),u={stepName:this.configuration.stepName,id:M(),cachedObjectURL:await oe(d.svg),src:l,svg:d.svg,colors:d.colors,type:s,y:r.top,x:r.left,width:r.width,height:r.height,layer:r.layer,layerIndex:r.layerIndex,rotation:r.rotation,immutable:r.immutable,productOverlay:this.configuration.type===b.ProductOverlay?!0:void 0,excludeFromExport:this.configuration.data.excludeFromPrint};return{regionElement:{id:u.id,region:r},command:new G(u,i)}}},this.configuration=t,this.layouts=e,this.product=a||void 0}async trigger(){if(!this.configuration.data.regions)throw new re(this.configuration,"Missing regions.");if(this.configuration.type===b.SilentIllustration){const t=this.configuration.data.regions.map(this.processRegion);return Promise.all(t)}else return this.configuration.type===b.ProductOverlay?Promise.all(this.configuration.data.regions.map(t=>{if(!this.layouts.find(a=>t.panelId===a.panelId))throw new J(t);return this.processRegion(t)})):Promise.reject("Unknown silent step. This is a bug")}evaluateAssetType(){const t=this.configuration.type===b.ProductOverlay&&this.product?.overlayImageUrl?this.product.overlayImageUrl.toLowerCase():this.configuration.data.asset?.fileLink?.toLowerCase().split("?")[0];return t?.startsWith("data:image/png")||t?.endsWith(".jpeg")||t?.endsWith(".jpg")||t?.endsWith(".png")?F.Image:(t?.endsWith(".svg")||t?.startsWith("image/svg+xml"),F.Illustration)}}const Pr=async n=>{const t=`${ut.getServicesApiUrl()}/shortener`;try{return(await(await rt(t,{method:"POST",body:JSON.stringify({longUrl:n}),headers:{"Content-Type":"application/json"}})).json()).shortUrl}catch(e){throw console.error(e),new Le("Failed to shorten URL, see console.")}};class xr{async poll(){try{if(await this.predicate()){this.onSuccess(),this.pollingId>-1&&window.clearInterval(this.pollingId);return}}catch{}this.attempts+=1,this.attempts<this.maxAttempts?this.pollingId=window.setTimeout(this.poll.bind(this),this.interval):this.onFailure()}constructor(t,e,a,r=3e3,i=10){this.onSuccess=e,this.onFailure=a,this.predicate=t,this.attempts=0,this.pollingId=-1,this.interval=r,this.maxAttempts=i,this.poll()}}class Ks{async init(t,e,a){return a&&await this.reload(t,e,a),null}async reload(t,e,a){const r=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),l=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName).map(c=>({id:c.id,region:c.stepRegion,regionIndex:c.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[],l,async()=>{const c=r?.storage?.videoShortUrl,d=r?.storage?.videoUrl;e.updateStorage(t.stepName,{videoShortUrl:c,videoUrl:d})})}async regenerateQRCode(t,e,a,r){const i=async()=>{const h=(await De([e]))[0],g=h?.versions?.find(m=>m.name==="mpeg4")?.link;return{asset:h,link:g}},o=await new Promise((h,g)=>{new xr(async()=>!!(await i()).link,async()=>{const m=await i();if(!m.link||!m.link)throw new Qt(m.asset);h({rel:"mpeg4",href:m.link})},()=>{g("Poller timed out with 40 attempts @ 3 second interval")},3e3,40)});t.forEach(h=>a.getCommandDispatcher()(new xt(h.id)));const s=r.data.baseUrl.slice(0,4)==="http"?"":"https://",l=new URL(s+r.data.baseUrl);l.searchParams.append("video",btoa(JSON.stringify([o]))),l.pathname=l.pathname+(l.pathname.slice(-1)==="/"?"":"/");const c=l.toString();if(c.length>=2e3)throw new Le("Cannot create QR code, URL too long.");const d=await Pr(c);if(!r.data||!r.data.regions)throw new re(r,"Missing regions.");const u=await this.regionElements(r),A=await this.command(d,u,a,r.stepName);return A&&(A.command&&a.getCommandDispatcher()(A.command),A.followup&&await A.followup()),await a.setSelectionsAndElements(r.stepName,[],u,async()=>{a.updateStorage(r.stepName,{videoShortUrl:d,videoUrl:o.href})}),d}async regionElements(t){const e=(a,r)=>({id:M(),region:a,regionIndex:r});return t.data.regions.map(e)}async command(t,e,a,r){const i=a.getLayouts(),s=`data:image/svg+xml;base64,${btoa(await Rn.toString(t,{type:"svg"}))}`,l=e.map(c=>{const d=c.region,u=i.find(A=>A.panelId===d?.panelId);if(!u&&d)throw new J(d);if(u&&!d)throw new Error("Region not found");if(!u||!d)throw new Error("Neither a region or layout found!");return new G({stepRegion:d,stepRegionIndex:c.regionIndex,stepName:r,id:c.id,src:s,type:F.Image,y:d.top,x:d.left,width:d.width,height:d.height,rotation:0},u)});return{command:new $(l),followup:async()=>{}}}}const Ha=new Ks;class Te{constructor(){this.frameSourceSvg=async(t,e)=>{if(!t)return Ea(e);const a=t.asset;if(!a)throw new ft(t);const r=a.fileLink;if(r)return et(r,!0);throw new Qt(a)}}async init(t,e,a){const r=a?.serializableWorkflow.steps.find(s=>s.stepName===t.stepName);if(r?.storage&&Object.keys(r.storage).length!==0||r?.selectedVariants&&r.selectedVariants.length!==0)return await this.reload(t,e,a),null;t.mandatory&&e.setMandatoryFulfilled(t.stepName,!1),e.markStepsAsInitialised([t.stepName]);let i;const o=e.getWorkflowExperience().getBundle();if(o&&t.globalPropertyAspectConfigurations){const s=o.getGlobalPropertyStateManager(),l=t.globalPropertyAspectConfigurations[0],c=s.getAspectStorage(l.aspectName);c&&c.originalAssetKey&&(i=(await U.getLocalOrFromServer(c.originalAssetKey)).fileLink)}if(t.option&&t.option.variants&&t.option.variants.length>0){const s=t.option,l=Y.getDefaultVariant(s);return l?this.selectVariantCommand(t,l,[],e,void 0,i||t.data.placeholderImageUrl):null}return this.selectVariantCommand(t,void 0,[],e,void 0,i||t.data.placeholderImageUrl)}async reload(t,e,a){const r=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),l=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName).map(c=>({id:c.id,region:c.stepRegion,regionIndex:c.stepRegionIndex}));if(!t.option||(t.option.variants||[]).length===0){const c=t.data.regions.map(d=>Ea(d));e.updateStorage(t.stepName,{currentFrameSources:c})}if(r){const c=async()=>{const d=r.storage?.colors,u=r.storage?.framePatternSrc,A=r.storage?.frameOffsetsList;if(e.updateMetadata(t.stepName,{frameOffsetsList:A,framePatternSrc:u}),u){const h=e.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!h)throw new Error("Frame service unavailable, cannot load pattern!");await this.loadPatternFromString(u,h,!0,d),e.updateMetadata(t.stepName,{image:u}),e.updateStorage(t.stepName,{framePatternSrc:u}),this.validateColorCount(t,e)}if(A?.some(h=>h.zoom)){const h=e.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!h)throw new Error("Frame service unavailable, cannot load pattern!");h.updateOffsets(A)}e.setMandatoryFulfilled(t.stepName,!0)};if(r.selectedVariants&&r.selectedVariants.length>0){const d=r.selectedVariants[0].id;if(t.option&&d){const u=t.option.variants?.find(A=>A.id===d);u&&await e.setSelectionsAndElements(t.stepName,[u],l,async()=>{const A=await Promise.all(t.data.regions.map(h=>this.frameSourceSvg(u,h)));e.updateStorage(t.stepName,{currentFrameSources:A}),await c()})}}else await e.setSelectionsAndElements(t.stepName,[],l,c)}}async availableColors(t,e){return t.data.colorOption?.variants?.map(r=>({fill:r.color,stroke:r.color,variant:r,pmsValue:r.name}))??[]}selectImage(t,e,a,r=!0){const i=Te.patternSource(e),o=a.getStepStorage(t.stepName)?.framePatternSrc;if(o&&o===i)return Promise.resolve();a.setEditedStatus(t.stepName,!0);const s=e.fileLink||"";return s.endsWith(".pdf")||s.endsWith(".eps")||s.endsWith(".ai")?new Promise(l=>{a.addPoller(new xr(async()=>{const d=(await U.getFromServer(e.key||"")).versions?.find(A=>A.name==="svg");return d?(await rt(d.link)).status===200:!1},()=>{U.getLocalOrFromServer(e.key||"").then(c=>{this.loadPatternFromAsset(c,t,a,r).then(l)})},()=>{throw new Le("Failed to resolve transcoded PDF")}))}):this.loadPatternFromAsset(e,t,a,r)}async selectVariant(t,e,a,r,i){const o=await this.selectVariantCommand(t,e,a,r,i);o&&(o.command&&r.getCommandDispatcher()(o.command),o.followup&&await o.followup())}getCreateElementCommand(t,e,a,r,i){return new G({id:t,type:F.Frame,x:e.left,y:e.top,width:e.width,height:e.height,layer:e.layer,layerIndex:e.layerIndex,rotation:e.rotation,scaleX:e.width/i.frameData.width,scaleY:e.height/i.frameData.height,path:i.frameData.path,dataWidth:i.frameData.width,dataHeight:i.frameData.height,stepRegion:e,stepRegionIndex:a,stepName:i.stepName,disablePlaceholder:i.disablePlaceholder,pattern:i.pattern,immutable:e.immutable},r)}async loadPatternFromString(t,e,a=!0,r=void 0,i){if(t.endsWith("svg")){const o=await Ga(t),s=o.width,l=o.height,c=await et(t);if(i){const A=c.match(/<(image|linearGradient|radialGradient)(\s|>|\/>)/gim);if(A&&A.length>0)throw new Error("Vector files may not include images or gradients when a color limit is specified.")}const d=await it(c),u={src:t,width:s,height:l,aspect:s/l,svg:d.svg,colors:r??d.colors};dt.set(t,u),e.setPatternData(u,a)}else{const o=await Ve(t,!0),s=await de(o),l={src:t,width:s.width,height:s.height,aspect:s.width/s.height,svg:void 0,colors:void 0};dt.set(t,l),e.setPatternData(l,a)}}changeColors(t,e,a){const r=e.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!r||!r.getImageData()?.svg){console.warn("changeColors was called without an SVG being assigned to a frame step");return}const i=this.calculateColorMetadata(r,t,a);e.updateMetadata(t.stepName,{colors:i.metadataColors}),e.updateStorage(t.stepName,{colors:i.storageColors}),r.setPatternData({...r.getImageData(),colors:i.newColors},!1),this.validateColorCount(t,e)}getUniqueColorCount(t,e){const a=e.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!a)return 0;const r=a.getImageData()?.colors??{},i=[];for(const o in r){const s=r[o];if(s.pmsValue){const l=s.pmsValue.trim().toLocaleLowerCase();i.includes(l)||i.push(l)}else if(s.browserValue){const l=tr(s.browserValue);i.includes(l)||i.push(l)}}return i.length}calculateColorMetadata(t,e,a){if(!t.getImageData()?.svg)return{newColors:void 0,metadataColors:void 0,storageColors:void 0};const r={...t.getImageData().colors??{}},i={};Object.entries(r).forEach(([l,c])=>{const d={browserValue:c.browserValue};i[l]=d});for(const[l,c]of a.entries())r[l]={browserValue:c.browserValue,pmsValue:c.pmsValue},i[l]=c;let o=Array.from(Object.values(r)).map(l=>l.browserValue);const s=e.data.colorOption;return s&&s.variants?.forEach(l=>{o=o.map(c=>c.toLowerCase()===l.color?.toLowerCase()?l.name:c)}),{newColors:r,metadataColors:o,storageColors:i}}validateColorCount(t,e){const a=t.data.colorPickerEnabled?t.data.maxColors??0:0;e.setStepError(t.stepName,"colors",a>0&&this.getUniqueColorCount(t,e)>a?"workflow.steps.frame.tooManyColors":void 0)}async selectVariantCommand(t,e,a,r,i,o){const s=r.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!s)throw new Error("Frame service unavailable, cannot load pattern!");const l=await Promise.all(t.data.regions.map(h=>this.frameSourceSvg(e,h)));i&&i(!0);const c=t.data.initialZoomLevel,d=await Promise.all(t.data.regions.map(async(h,g)=>{const m=await me(l[g]),p=s.getImageData(),f=a.map(I=>new xt(I.id)),S=p?qa(p,m,c&&!t.data.forceImageCover?{scale:c}:void 0,t.data.forceImageCover):void 0,w=p?{id:M(),src:p.src,x:S?.x||0,y:S?.y||0,width:p.width,height:p.height,scaleX:S?.zoom||1,scaleY:S?.zoom||1,rotation:0}:void 0,x=M(),E=r.getLayouts().find(I=>I.panelId===h.panelId);if(!E)throw new J(h);return{command:this.getCreateElementCommand(x,h,g,E,{frameData:m,pattern:w,disablePlaceholder:t.data.disablePlaceholder,stepName:t.stepName}),regionEl:{id:x,region:h,regionIndex:g},removeExistingCommands:f}})),u=d.map(h=>h.command),A=d.map(h=>h.removeExistingCommands).flat();return{command:new $([...u,...A]),followup:async()=>{i&&i(!1),await r.setSelectionsAndElements(t.stepName,e?[e]:[],[...d.map(h=>h.regionEl)],async()=>{if(r.updateStorage(t.stepName,{currentFrameSources:l}),o){const h=r.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!h)throw new Error("Frame service unavailable, cannot load pattern!");await this.loadPatternFromString(o,h,!0)}})}}}static patternSource(t){const e=t.versions?.find(r=>r.name==="svg");if(e?.link)return e.link;const a=t.fileLink;if(a)return a;throw new Qt(t)}async loadPatternFromAsset(t,e,a,r){const i=Te.patternSource(t),o=a.markUpdatePending(),s=a.getWorkflowExperience().getStepById(e.stepName)?.frameService;if(!s)throw a.markUpdateCompleted(o),new Error("Frame service unavailable, cannot load pattern!");try{await this.loadPatternFromString(i,s,r,void 0,e.data.colorPickerEnabled&&!!e.data.maxColors&&e.data.maxColors>0)}catch(c){throw a.markUpdateCompleted(o),c}const l=this.calculateColorMetadata(s,e,new Map(Object.entries(s.getImageData()?.colors??{})));a.updateMetadata(e.stepName,{image:i,colors:l.metadataColors}),a.updateStorage(e.stepName,{framePatternSrc:i,colors:l.storageColors}),a.markUpdateCompleted(o),a.setMandatoryFulfilled(e.stepName,!0),a.setInformationResults(a.getInformationResults().filter(c=>c.stepID===e.stepName)),this.validateColorCount(e,a)}}const gt=new Te;class _s{async getIllustrationBody(t){return new Promise(e=>{et(t,!0).then(a=>{e(a)}).catch(a=>console.error(a))})}getCreateElementCommand(t,e,a,r,i){return new G({stepRegion:e,stepRegionIndex:a,stepName:i.stepName,colors:i.svg.colors,id:t,src:i.src,svg:i.svg.svg,cachedObjectURL:i.objectURL,type:F.Illustration,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer,layerIndex:e.layerIndex,immutable:e.immutable},r)}getColors(t,e){const a=e.getRegionElements(t.stepName)||[];if(a.length===0)return[];try{return L(a[0].id,e.getAllLayoutData()).colors}catch{return[]}}async init(t,e,a){const r=t.option;if(!r)return null;if(a)return this.reload(t,e,a);{const i=Y.getDefaultVariant(r);if(i)return await this.selectVariantCommand(t,i,[],()=>{},e)}return null}async reload(t,e,a){const r=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),s=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(l&&c){const d=l.variants?.find(u=>u.id===c);if(d){const u=s.map(A=>({id:A.id,region:A.stepRegion,regionIndex:A.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[d],u,async()=>{e.updateMetadata(t.stepName,{colors:r.storage?.colors}),e.setMandatoryFulfilled(t.stepName,!0)})}}else throw new Error("Required illustration variant no longer available")}return null}async availableColors(t,e){const a=t.data.colorOption;return a?a?a.variants?.map(r=>({fill:r.color,stroke:r.color,variant:r,pmsValue:r.name})):[]:[]}async changeColorsCommand(t,e,a,r,i){const o={};for(const[d,u]of i.entries())typeof u=="string"?o[d]={browserValue:u,spotColor:void 0,pmsValue:void 0}:o[d]={browserValue:u.browserValue,spotColor:u.spotColor,pmsValue:u.pmsValue};const s=$a(t,e,a,o),l=await oe(s),c=[];for(const d of r){for(const[u,A]of i.entries())c.push(new Pa(d,u,A));c.push(new js(d,s,l))}return new $(c)}async changeColors(t,e,a,r,i){if(e.length===0)return;const o=L(e[0].id,r().map(h=>h.layoutState)),s={...o.colors},l={};Object.entries(s).forEach(([h,g])=>{const m={browserValue:g.browserValue,pmsValue:g.pmsValue},p=g.spotColor;p&&(m.spotColor={profileName:p.profileName,namedColor:p.namedColor}),l[h]=m});for(const[h,g]of i.entries()){const m=typeof g=="string"?g:g.browserValue,p=typeof g=="string"?void 0:g.pmsValue;s[h]={browserValue:m,spotColor:s[h]?.spotColor,pmsValue:p},l[h]={browserValue:m}}let c=Array.from(Object.values(s)).map(h=>h.browserValue);const d=t.data.colorOption;d&&d.variants?.forEach(h=>{c=c.map(g=>g.toLowerCase()===h.color?.toLowerCase()?h.name:g)}),a.updateMetadata(t.stepName,{colors:c});const u=new Map;if(Object.entries(s).forEach(([h,g])=>{u.set(h,g)}),!o.svg)throw new Error("Colors changed before SVG loaded. This should never happen!");const A=await this.changeColorsCommand(o.svg,o.width,o.height,e.map(h=>h.id),u);a.updateStorage(t.stepName,{colors:l}),a.getCommandDispatcher()(A)}async selectVariant(t,e,a,r,i){const o=await this.selectVariantCommand(t,e,a,r,i);o&&(o.command&&i.getCommandDispatcher()(o.command),o.followup&&await o.followup())}async selectVariantCommand(t,e,a,r,i){if(!t.data||!t.data.regions)throw new re(t,"Missing regions.");r(!0);const o=a.map(f=>new xt(f.id));t.mandatory&&i.setMandatoryFulfilled(t.stepName,!1);const s=e.asset;if(!s)throw new ft(e);const l=s.fileLink;if(!l)throw new Qt(s);const c=await it(await this.getIllustrationBody(l)),d=await oe(c.svg),u=(f,S)=>{const w=i.getLayouts().find(v=>v.panelId===f.panelId);if(!w)throw new J(f);const x=M();return{regionElement:{id:x,region:f,regionIndex:S},command:this.getCreateElementCommand(x,f,S,w,{stepName:t.stepName,src:l,objectURL:d,svg:c})}},A=t.data.regions.map(u),g=[...A.map(f=>f.command),...o];let m=Array.from(Object.values(c.colors)).map(f=>f.browserValue);const p=t.data.colorOption;return p&&p.variants?.forEach(f=>{m=m.map(S=>S.toLowerCase()===f.color?.toLowerCase()?f.name:S)}),i.updateMetadata(t.stepName,{colors:m}),{command:new $(g),followup:async()=>{await i.setSelectionsAndElements(t.stepName,[e],A.map(S=>S.regionElement),async()=>{i.setMandatoryFulfilled(t.stepName,!0),r(!1)});const f=s.assetConfiguration?.defaultColorVariants||[];if(f.length!==0){const S={};(s.assetConfiguration?.channelNumbers||[]).forEach(x=>{const v=f.find(E=>E.channelNumber===x.number);v&&(S[`${x.id.replace(/\W/g,"")}`]={browserValue:v?.variant?.color||""})}),await this.changeColors(t,A.map(x=>x.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map(Object.entries(S)))}if(t.data.colorPickerEnabled){const S=await this.availableColors(t,i)||[],w=Object.keys(c.colors),x=S.length===1&&w.length===1;if(x){const v=S[0],E=w[0];await this.changeColors(t,A.map(I=>I.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map([[E,v.variant.color]]))}!x&&f.length===0&&await this.changeColors(t,A.map(v=>v.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map)}}}}}const Jt=new _s;class Xs{async init(t,e,a){const r=t.option;if(!r)throw new ne(t);if(a)await this.reload(t,e,a);else{const i=Y.getDefaultVariant(r);if(i)return await this.selectVariantLambda(t,i,e,()=>{})}return null}async reload(t,e,a){const r=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),s=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(!l)throw new ne(t);if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(c){const d=l.variants?.find(u=>u.id===c);if(d){const u=d.material,A=s.map(h=>({id:h.id,region:h.stepRegion,regionIndex:h.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[d],A,async()=>{const h=e.getModelContainer();if(h){const g=t.data.targetMaterials.map(m=>h.applyMaterialVariant(m,l.id||"",u||{}));Promise.all(g).then(()=>e.setMandatoryFulfilled(t.stepName,!0))}})}}}}async selectVariant(t,e,a,r){const i=await this.selectVariantLambda(t,e,a,r);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantLambda(t,e,a,r){const i=a.getModelContainer();r(!0);const o=e.material;if(!o)throw r(!1),new ft(e);return{command:void 0,followup:async()=>{await a.setSelectionsAndElements(t.stepName,[e],[],async()=>{try{i&&t.data.targetMaterials.forEach(s=>{t.option&&i.applyMaterialVariant(s,t.option.id||"",o)}),a.setMandatoryFulfilled(t.stepName,!0)}finally{r(!1)}})}}}}const Ya=new Xs;class Zs{async init(t,e,a){const r=t.option;if(!r)throw new ne(t);if(a)await this.reload(t,e,a);else{const i=Y.getDefaultVariant(r);if(i)return await this.selectVariantLambda(t,i,e,()=>{})}return null}async reload(t,e,a){const r=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),s=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(l&&c){const d=l.variants?.find(u=>u.id===c);if(d){const u=s.map(A=>({id:A.id,region:A.stepRegion,regionIndex:A.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[d],u,async()=>{const A=e.getModelContainer();if(A&&t.option){const h=d.asset?.fileLink;if(!h)throw new ft(d);await A.applyModelVariant(t.stepName||"",{model:h,contextService:e.getLayoutPreviewService()},t.data.replaceProductModel||!1),e.setMandatoryFulfilled(t.stepName,!0)}})}}}}async selectVariant(t,e,a,r){const i=await this.selectVariantLambda(t,e,a,r);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantLambda(t,e,a,r){r(!0);const i=e.asset?.fileLink;if(!i)throw new ft(e);return{command:void 0,followup:async()=>{await a.setSelectionsAndElements(t.stepName,[e],[],async()=>{try{const o=a.getModelContainer();o&&await o.applyModelVariant(t.stepName,{model:i,contextService:a.getLayoutPreviewService()},t.data.replaceProductModel||!1),a.setMandatoryFulfilled(t.stepName,!0)}finally{r(!1)}})}}}}const Ja=new Zs;class tl{async init(t,e,a){if(a)await this.reload(t,e,a);else return e.updateMetadata(t.stepName,{text:""}),this.changeTextCommand(t,"",e,()=>{});return null}async reload(t,e,a){const r=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),l=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName).map(c=>({id:c.id,region:c.stepRegion,regionIndex:c.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[],l,async()=>{e.updateStorage(t.stepName,{text:r?.storage?.text}),e.setMandatoryFulfilled(t.stepName,r?.storage?.text!=="")})}async changeText(t,e,a,r){const i=await this.changeTextCommand(t,e,a,r);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async changeTextCommand(t,e,a,r){const i=a.getRegionElements(t.stepName),o=a.getStepSpecificServices(t.stepName)?.module;if(!o)return console.error("Missing module."),null;const s=a.getWorkflowExperience().getProfanityList(),l=this.validateInput(t,e,s,r);if(l.errorData)return a.setMandatoryFulfilled(t.stepName,!1),l.errorData.blockedProfanity?console.error("Blocked profanity."):l.errorData.hitCharacterLimit?console.error("Too many characters."):l.errorData.unsupportedCharacters&&console.error("Unsupported characters."),null;if(a.setMandatoryFulfilled(t.stepName,e!==""),!t.data||!t.data.regions||t.data.regions.length<=0)return console.error("Missing configuration."),null;a.updateStorage(t.stepName,{text:e}),a.updateMetadata(t.stepName,{text:e});const c=(d,u,A,h)=>{const g=h||M(),p=a.getLayouts().find(S=>S.panelId===u.panelId);if(!p)return console.error(`Can not find layout for region: ${u.panelId}`),null;const f=[];return h&&f.push(new xt(g)),f.push(new G({stepRegion:u,stepRegionIndex:A,stepName:t.stepName,colors:{},id:g,svg:d,type:F.Illustration,y:u.top,x:u.left,rotation:u.rotation,width:u.width,height:u.height,layer:u.layer,layerIndex:u.layerIndex,immutable:u.immutable},p)),{id:g,region:u,command:new $(f)}};if(i.length>0){const u=i.map(A=>{if(!A.region)return null;const h=o.svgPrint(e,A.region);return c(h,A.region,A.regionIndex,A.id)}).filter(A=>!!A).filter(A=>!!A).map(A=>A&&A.command);return{command:new $(u),followup:async()=>{}}}else{const d=t.data.regions.map((A,h)=>c(o.svgPrint(e,A),A,h)),u=d.filter(A=>!!A).map(A=>A&&A.command);return{command:new $(u),followup:async()=>{const A=d.filter(h=>h).map(h=>h&&{id:h.id,region:h.region});await a.setSelectionsAndElements(t.stepName,[],A)}}}}validateInput(t,e,a,r){if(t.data&&t.data.maxLength){const o=t.data.maxLength;if(e.length>o)return r("Too many characters."),{input:e,helperData:{},errorData:{hitCharacterLimit:!0}}}if(!/^$|^[a-zA-Z0-9 ]+$/.test(e))return r("Unsupported characters."),{input:e,helperData:{},errorData:{unsupportedCharacters:!0}};const i=ma.split(e.toLowerCase());for(const o of i)for(const s in a){const l=a[s].toLowerCase().replace(/\s/g,"");if(o===l)return r("Blocked profanity."),{input:e,helperData:{},errorData:{blockedProfanity:!0}}}return r(""),{input:e,helperData:{}}}}const Ka=new tl;class el{async init(t,e,a){const r=t.option;if(!r)return null;if(a)await this.reload(t,e,a);else if(r.defaultVariant)return e.markStepsAsInitialised([t.stepName]),this.selectVariantCommand(t,r.defaultVariant,e,()=>{});return e.markStepsAsInitialised([t.stepName]),null}async reload(t,e,a){const r=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),s=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(l&&c){const d=l.variants?.find(u=>u.id===c);if(d){const u=s.map(A=>({id:A.id,region:A.stepRegion,regionIndex:A.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[d],u,async()=>{e.setMandatoryFulfilled(t.stepName,!0)})}}}}async selectVariant(t,e,a,r){const i=await this.selectVariantCommand(t,e,a,r);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantCommand(t,e,a,r){const i=e.asset;if(!i)throw new ft(e);const o=i?.fileLink;if(!o)return console.error("No URL for picture!"),null;r(!0),t.mandatory&&a.setMandatoryFulfilled(t.stepName,!1);const l=a.getRegionElements(t.stepName).map(u=>new xt(u.id)),c=(u,A)=>{const g=a.getLayouts().find(p=>p.panelId===u.panelId);if(!g)throw new J(u);const m=M();return{regionElement:{id:m,region:u,regionIndex:A},command:new G({stepName:t.stepName,stepRegion:u,stepRegionIndex:A,id:m,src:o,type:F.Image,y:u.top,x:u.left,rotation:u.rotation,width:u.width,height:u.height,layer:u.layer,layerIndex:u.layerIndex,immutable:u.immutable,preserveAspectRatio:"none"},g)}},d=t.data.regions.map(c);return{command:new $([...l,...d.map(u=>u.command)]),followup:async()=>{await a.setSelectionsAndElements(t.stepName,[e],d.map(u=>u.regionElement),async()=>{a.setMandatoryFulfilled(t.stepName,!0),r(!1)})}}}}const _a=new el;class al{async init(t,e,a){const r=t.option;if(!r)return null;if(a)await this.reload(t,e,a);else{const i=r.variants;if(Y.getDefaultVariant(r)){const s=i?.find(l=>l.id===r.defaultVariant?.id);return this.selectVariantLambda(t,s?.id||"",e)}}return null}async reload(t,e,a){const r=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),i=t.option;if(r?.selectedVariants){const o=r.selectedVariants[0].id;if(i&&o){const s=i.variants?.find(l=>l.id===o);s&&await e.setSelectionsAndElements(t.stepName,[s],[])}}}async selectVariant(t,e,a){await a.getInitializationPromise();const r=await this.selectVariantLambda(t,e,a);r&&(r.command&&a.getCommandDispatcher()(r.command),r.followup&&await r.followup())}async selectVariantLambda(t,e,a){const r=t.option;if(!r)return null;const i=r.variants;if(!i)return null;const o=i.length>1?i.find(s=>s.id===e):i[0];if(!o)throw new Error(`Failed to find selected variant ${e} in option ${r.id} of step ${t.stepName} (${t.stepTitle})`);return{command:void 0,followup:async()=>{await a.setSelectionsAndElements(t.stepName,[o],[],async()=>{a.setMandatoryFulfilled(t.stepName,!0)})}}}}const Xa=new al;class nl{constructor(){this.shapeFillId="spiff-fill-shape"}async availableColours(t){const e=t.option;return e?e.variants?.map(a=>({fill:a.color,stroke:a.color,variant:a}))||[]:[]}setCustomColor(t,e,a){const r=a.getLayouts(),o=(a.getRegionElements(e.stepName)||[]).map(s=>{const l=s.region;if(!r.find(d=>d.panelId===l?.panelId))throw new J(l);return new Pa(s.id,this.shapeFillId,t)}).filter(s=>!!s);a.getCommandDispatcher()(new $(o)),a.updateStorage(e.stepName,{colour:t})}async init(t,e,a){const r=t.option;if(!r)throw new ne(t);if(a)await this.reload(t,e,a);else{const i=Y.getDefaultVariant(r);return i?this.selectVariantCommand(t,{fill:i.color,stroke:i.color,variant:i},[],e):null}return null}async selectVariant(t,e,a,r){const i=await this.selectVariantCommand(t,e,a,r);i&&(i.command&&r.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async reload(t,e,a){const r=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),s=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(l&&c){const d=l.variants?.find(u=>u.id===c);if(d){const u=s.map(A=>({id:A.id,region:A.stepRegion,regionIndex:A.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[d],u,async()=>{e.updateStorage(t.stepName,{colour:r?.storage?.colour||""}),e.setMandatoryFulfilled(t.stepName,!0)})}}}}async selectVariantCommand(t,e,a,r){const i=r.getLayouts(),o=r.getStepStorage(t.stepName)?.colour,s=()=>{if(e.variant?.color==="#custom")return o||"#FFFFFF";if(e.variant?.color)return e.variant.color;throw new Error("Failed to resolve color for shape step.")};if(a.length>0){const l=d=>{const u=d.region;if(!i.find(g=>g.panelId===u?.panelId))throw new J(u);const h=s();return new Pa(d.id,this.shapeFillId,h)},c=a.map(l).filter(d=>!!d);return{command:new $(c),followup:async()=>{await r.setSelectionsAndElements(t.stepName,e.variant?[e.variant]:[],a),r.updateStorage(t.stepName,{colour:s()})}}}else{const l=(A,h)=>{const g=i.find(w=>w.panelId===A.panelId);if(!g)throw new J(A);const m=s(),p=`
|
|
1425
|
+
`,r={};r["spiff-fill-shape"]={browserValue:e.color};const i=e.region?.item||await Gt(t,F.Illustration),o=M();return{stepRegion:e.region?.item,stepRegionIndex:e.region?.index,colors:r,id:o,svg:n,type:F.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||qt(t,i.layer||0),immutable:i.immutable}}static async getIllustration(t,e){const n=e.region?.item||await Gt(t,F.Illustration,e.src),r=await it(await vr(e.src)),i=await oe(r.svg),o=M();return{cachedObjectURL:i,stepRegion:e.region?.item,stepRegionIndex:e.region?.index,colors:r.colors,id:o,src:e.src,svg:r.svg,type:F.Illustration,y:n.top,x:n.left,rotation:n.rotation,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||qt(t,n.layer||0),immutable:n.immutable}}}class q extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,q.prototype)}}const L=(a,t)=>X(a,t).elements.find(r=>r.id===a),X=(a,t)=>{const e=Object.values(t).find(n=>n.elements.some(r=>r.id===a));if(!e)throw new q;return e},tt=(a,t)=>{const e=[...t.elements.filter(r=>r.id!==a.id),a],n=qn(e);return{layout:t.layout,elements:n,modificationID:M()}},Bn=async a=>{const t=[...Object.keys(a.layouts)],e=[...new Set(t)];for(let n=0;n<e.length;n++){const r=e[n],i=a.layouts[r];await Promise.all(i.elements.map(async o=>{if(o.type==="illustration"){const s=o;if(s.src&&!s.svg){const l=await et(s.src),c=await it(l);s.svg=Un(c.svg,s.width,s.height,s.colors)}}else if(o.type==="frame"){const s=o;if(s.pattern?.colors&&s.pattern?.src){const l=await et(s.pattern?.src),c=await it(l);s.pattern.svg=c.svg}}isNaN(o.x)&&(o.x=0),isNaN(o.y)&&(o.y=0),isNaN(o.width)&&(o.width=0),isNaN(o.height)&&(o.height=0),isNaN(o.rotation)&&(o.rotation=0)}))}for(const n in a.layouts){const r=a.layouts[n].elements.filter(o=>o.type===F.Illustration);for(let o=0;o<r.length;++o){const s=r[o];if(s.src&&s.svg)try{s.cachedObjectURL=await oe(s.svg)}catch(l){console.log(l)}}const i=a.layouts[n].elements.filter(o=>o.type===F.Textbox);for(let o=0;o<i.length;++o){const s=i[o];s.fontData?.assetUrl&&await Pt(s.fontData.assetUrl)}}};class O{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class wa extends O{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class Ls extends O{constructor(t,e,n){super(),this.id=t,this.x=e,this.y=n}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,x:this.x,y:this.y},r=X(e.id,Object.values(t.layouts)),i=tt(n,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class Vs extends O{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,rotation:this.angle},r=X(e.id,Object.values(t.layouts)),i=tt(n,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class zs extends O{constructor(t,e,n){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(n)}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;let n={...e,width:this.width,height:this.height};if(e.type==="frame"){const o=n;o.scaleX=o.scaleX*this.width/e.width,o.scaleY=o.scaleY*this.height/e.height}else if(e.type==="textbox"){const o=n,s=(!o.algorithm||o.algorithm===Bt.Autosize?o.text:o.input)??"";n=he(o,s,e)}const r=X(e.id,Object.values(t.layouts)),i=tt(n,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class $ extends O{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce((e,n)=>n.apply(e),t)}}class Hn extends O{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:M()}}}}}class G extends O{constructor(t,e){super(),this.element=t,this.layout=e}apply(t){this.oldState=t,t.layouts[this.layout.id]||(t.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const e=t.layouts[this.layout.id].elements;if(e.find(s=>s.id===this.element.id))throw new Error(`Failed to apply new ${this.element.type} element because ID ${this.element.id} already taken`);if(this.element.productOverlay||e.length===0){const s=[...e,this.element];return this.element.layerIndex===void 0&&(this.element.layerIndex=this.assignIndex(this.element,s)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:s,modificationID:M()}}}}const r=e[e.length-1],i=r.productOverlay?r:null;i&&e.pop();let o;if(this.element.layerIndex!==null&&this.element.layerIndex!==void 0)o=[...e,this.element].sort((s,l)=>s.layerIndex!==void 0&&l.layerIndex!==void 0?s.layerIndex-l.layerIndex:0);else{const s=this.assignIndex(this.element,e);this.element.layerIndex=s!==void 0?s:0,o=[...e,this.element]}return i&&o.push(i),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:o,modificationID:M()}}}}assignIndex(t,e){if(e.length===0)return 0;const n=e.filter(r=>(r.layer||0)===(t.layer||0)).sort((r,i)=>(r.layerIndex||0)-(i.layerIndex||0))[e.length-1]?.layerIndex;return n!==void 0?n+1:0}}class xt extends O{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const n=Object.values(t.layouts).map(i=>(i.elements.filter(s=>s.id!==this.id).length!==i.elements.length&&(e=!0),{...i,elements:i.elements.filter(s=>s.id!==this.id),modificationID:M()}));e||console.log(`Failed to delete element ${this.id}`);const r={};return n.forEach(i=>{r[i.layout.id]=i}),{...t,layouts:r}}}class Er extends O{constructor(t,e,n){super(),this.id=t,this.color=e,this.textFillSpotColor=n}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},r=X(e.id,Object.values(t.layouts)),i=tt(n,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class ln extends O{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,textFillImage:this.imageFill},r=X(e.id,Object.values(t.layouts)),i=tt(n,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class br extends O{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,fontSize:this.size},r=X(e.id,Object.values(t.layouts)),i=(!e.algorithm||e.algorithm===Bt.Autosize?e.text:e.input)??"",o=tt(he(n,i),r);return{...t,layouts:{...t.layouts,[r.layout.id]:o}}}}class Pn extends O{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,fontData:this.fontData},r=X(e.id,Object.values(t.layouts)),i=(!e.algorithm||e.algorithm===Bt.Autosize?e.text:e.input)??"",o=tt(he(n,i),r);return{...t,layouts:{...t.layouts,[r.layout.id]:o}}}}class Ir extends O{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,align:this.align},r=X(e.id,Object.values(t.layouts)),i=tt(n,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class qs extends O{constructor(t,e,n){super(),this.id=t,this.imageData=e,this.offsets=n}apply(t){this.oldState=t;const e=X(this.id,Object.values(t.layouts)),n=e.elements.findIndex(s=>s.id===this.id),r=e.elements[n].pattern,i=[...e.elements];i.splice(n,1,{...e.elements[n],pattern:{...r,src:this.imageData.src,x:this.offsets.x,y:this.offsets.y,width:this.imageData.width,height:this.imageData.height,scaleX:this.offsets.zoom,scaleY:this.offsets.zoom,svg:this.imageData.svg,colors:this.imageData.colors}});const o={...e,elements:i,modificationID:M()};return{...t,layouts:{...t.layouts,[e.layout.id]:o}}}}class Gs extends O{constructor(t,e,n,r,i){super(),this.id=t,this.useThreshold=e,this.invertThreshold=n,this.threshold=r,this.thresholdSaturation=i}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,useThreshold:this.useThreshold,invertThreshold:this.invertThreshold,threshold:this.threshold,thresholdSaturation:this.thresholdSaturation},r=X(e.id,Object.values(t.layouts)),i=tt(n,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class js extends O{constructor(t,e){super(),this.id=t,this.src=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,src:this.src},r=X(e.id,Object.values(t.layouts)),i=tt(n,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class Br extends O{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n=X(e.id,Object.values(t.layouts)),r=tt(he(e,this.text,e),n);return{...t,layouts:{...t.layouts,[n.layout.id]:r}}}}class cn extends O{constructor(t,e,n){super(),this.id=t,this.strokeColor=e,this.strokeThickness=n}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,strokeColor:this.strokeColor,strokeThickness:this.strokeThickness},r=X(e.id,Object.values(t.layouts)),i=tt(n,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class xn extends O{constructor(t,e,n){super(),this.id=t,this.className=e,this.fill=n}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n=e.colors||{},r=n[this.className];typeof this.fill=="string"?n[this.className]={browserValue:this.fill,spotColor:r?.spotColor,pmsValue:r?.pmsValue}:n[this.className]={browserValue:this.fill.browserValue,spotColor:r?.spotColor,pmsValue:this.fill.pmsValue};const i={...e,colors:n},o=X(e.id,Object.values(t.layouts)),s=tt(i,o);return{...t,layouts:{...t.layouts,[o.layout.id]:s}}}}class Ws extends O{constructor(t,e,n){super(),this.id=t,this.svgBody=e,this.objectURL=n}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},r=X(e.id,Object.values(t.layouts)),i=tt(n,r);return{...t,layouts:{...t.layouts,[r.layout.id]:i}}}}class Hs extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new q;const n=Object.values(t.layouts).find(o=>o.elements.find(s=>s.id===this.id));if(!n)throw new Error("Layout missing from state!");const r=n.elements.findIndex(o=>o.id===this.id);n.elements.push(n.elements.splice(r,1)[0]);const i=[...n.elements];return i.forEach((o,s)=>o.layerIndex=s),{...t,layouts:{...t.layouts,[n.layout.id]:{...t.layouts[n.layout.id],elements:i,modificationID:M()}}}}}class Ys extends O{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const n=Object.values(t.layouts).find(s=>s.elements.find(l=>l.id===this.id));if(!n)throw new Error("Layout missing from state!");const r=n.elements.findIndex(s=>s.id===this.id);n.elements.splice(r,1),n.elements.unshift(e);const i=[...n.elements],o=i.splice(r,1)[0];return i.splice(r,0,o),i.forEach((s,l)=>s.layerIndex=l),{...t,layouts:{...t.layouts,[n.layout.id]:{...t.layouts[n.layout.id],elements:i,modificationID:M()}}}}}class Js extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new q;const n=Object.values(t.layouts).find(l=>l.elements.find(c=>c.id===this.id));if(!n)throw new Error("Layout missing from state!");const r=n.elements.findIndex(l=>l.id===this.id),i=r+1,o=[...n.elements],s=o.splice(r,1)[0];return o.splice(i,0,s),o.forEach((l,c)=>l.layerIndex=c),{...t,layouts:{...t.layouts,[n.layout.id]:{...t.layouts[n.layout.id],elements:o,modificationID:M()}}}}}class Ks extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new q;const n=Object.values(t.layouts).find(l=>l.elements.find(c=>c.id===this.id));if(!n)throw new Error("Layout missing from state!");const r=n.elements.findIndex(l=>l.id===this.id),i=r-1,o=[...n.elements],s=o.splice(r,1)[0];return o.splice(i,0,s),o.forEach((l,c)=>l.layerIndex=c),{...t,layouts:{...t.layouts,[n.layout.id]:{...t.layouts[n.layout.id],elements:o,modificationID:M()}}}}}class ya{constructor(t,e,n){this.processRegion=async r=>{const i=this.layouts.find(l=>l.panelId===r.panelId);if(!i)throw new J(r);let o="";if(this.configuration.type===b.ProductOverlay){let l="";if(this.product?.overlayImageUrl&&(l=this.product.overlayImageUrl),o=l,!l)throw new re(this.configuration,"Couldn't find an asset for product overlay step")}const s=this.evaluateAssetType();if(s===F.Image){const l=this.configuration.type===b.SilentIllustration?this.configuration.data.asset?.fileLink:this.product?.overlayImageUrl;if(!l)throw new Error("Undefined raster silent step source");const c={stepName:this.configuration.stepName,id:M(),src:l,type:s,y:r.top,x:r.left,width:r.width,height:r.height,layer:r.layer,layerIndex:r.layerIndex,immutable:r.immutable,productOverlay:this.configuration.type===b.ProductOverlay?!0:void 0,rotation:r.rotation,excludeFromExport:this.configuration.data.excludeFromPrint,preserveAspectRatio:"none"};return{regionElement:{id:c.id,region:r},command:new G(c,i)}}else{const l=this.configuration.type===b.SilentIllustration?this.configuration.data.asset?.fileLink:o,d=await it(await(async()=>new Promise((A,h)=>{if(!l){h("Undefined vector silent step source");return}et(l,!0).then(g=>{A(g)}).catch(g=>console.error(g))}))()),u={stepName:this.configuration.stepName,id:M(),cachedObjectURL:await oe(d.svg),src:l,svg:d.svg,colors:d.colors,type:s,y:r.top,x:r.left,width:r.width,height:r.height,layer:r.layer,layerIndex:r.layerIndex,rotation:r.rotation,immutable:r.immutable,productOverlay:this.configuration.type===b.ProductOverlay?!0:void 0,excludeFromExport:this.configuration.data.excludeFromPrint};return{regionElement:{id:u.id,region:r},command:new G(u,i)}}},this.configuration=t,this.layouts=e,this.product=n||void 0}async trigger(){if(!this.configuration.data.regions)throw new re(this.configuration,"Missing regions.");if(this.configuration.type===b.SilentIllustration){const t=this.configuration.data.regions.map(this.processRegion);return Promise.all(t)}else return this.configuration.type===b.ProductOverlay?Promise.all(this.configuration.data.regions.map(t=>{if(!this.layouts.find(n=>t.panelId===n.panelId))throw new J(t);return this.processRegion(t)})):Promise.reject("Unknown silent step. This is a bug")}evaluateAssetType(){const t=this.configuration.type===b.ProductOverlay&&this.product?.overlayImageUrl?this.product.overlayImageUrl.toLowerCase():this.configuration.data.asset?.fileLink?.toLowerCase().split("?")[0];return t?.startsWith("data:image/png")||t?.endsWith(".jpeg")||t?.endsWith(".jpg")||t?.endsWith(".png")?F.Image:(t?.endsWith(".svg")||t?.startsWith("image/svg+xml"),F.Illustration)}}const Pr=async a=>{const t=`${ut.getServicesApiUrl()}/shortener`;try{return(await(await rt(t,{method:"POST",body:JSON.stringify({longUrl:a}),headers:{"Content-Type":"application/json"}})).json()).shortUrl}catch(e){throw console.error(e),new Le("Failed to shorten URL, see console.")}};class xr{async poll(){try{if(await this.predicate()){this.onSuccess(),this.pollingId>-1&&window.clearInterval(this.pollingId);return}}catch{}this.attempts+=1,this.attempts<this.maxAttempts?this.pollingId=window.setTimeout(this.poll.bind(this),this.interval):this.onFailure()}constructor(t,e,n,r=3e3,i=10){this.onSuccess=e,this.onFailure=n,this.predicate=t,this.attempts=0,this.pollingId=-1,this.interval=r,this.maxAttempts=i,this.poll()}}class _s{async init(t,e,n){return n&&await this.reload(t,e,n),null}async reload(t,e,n){const r=e.getSerializedStep(t.stepName,n.serializableWorkflow.steps),l=Object.values(n.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName).map(c=>({id:c.id,region:c.stepRegion,regionIndex:c.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[],l,async()=>{const c=r?.storage?.videoShortUrl,d=r?.storage?.videoUrl;e.updateStorage(t.stepName,{videoShortUrl:c,videoUrl:d})})}async regenerateQRCode(t,e,n,r){const i=async()=>{const h=(await De([e]))[0],g=h?.versions?.find(m=>m.name==="mpeg4")?.link;return{asset:h,link:g}},o=await new Promise((h,g)=>{new xr(async()=>!!(await i()).link,async()=>{const m=await i();if(!m.link||!m.link)throw new Qt(m.asset);h({rel:"mpeg4",href:m.link})},()=>{g("Poller timed out with 40 attempts @ 3 second interval")},3e3,40)});t.forEach(h=>n.getCommandDispatcher()(new xt(h.id)));const s=r.data.baseUrl.slice(0,4)==="http"?"":"https://",l=new URL(s+r.data.baseUrl);l.searchParams.append("video",btoa(JSON.stringify([o]))),l.pathname=l.pathname+(l.pathname.slice(-1)==="/"?"":"/");const c=l.toString();if(c.length>=2e3)throw new Le("Cannot create QR code, URL too long.");const d=await Pr(c);if(!r.data||!r.data.regions)throw new re(r,"Missing regions.");const u=await this.regionElements(r),A=await this.command(d,u,n,r.stepName);return A&&(A.command&&n.getCommandDispatcher()(A.command),A.followup&&await A.followup()),await n.setSelectionsAndElements(r.stepName,[],u,async()=>{n.updateStorage(r.stepName,{videoShortUrl:d,videoUrl:o.href})}),d}async regionElements(t){const e=(n,r)=>({id:M(),region:n,regionIndex:r});return t.data.regions.map(e)}async command(t,e,n,r){const i=n.getLayouts(),s=`data:image/svg+xml;base64,${btoa(await Ra.toString(t,{type:"svg"}))}`,l=e.map(c=>{const d=c.region,u=i.find(A=>A.panelId===d?.panelId);if(!u&&d)throw new J(d);if(u&&!d)throw new Error("Region not found");if(!u||!d)throw new Error("Neither a region or layout found!");return new G({stepRegion:d,stepRegionIndex:c.regionIndex,stepName:r,id:c.id,src:s,type:F.Image,y:d.top,x:d.left,width:d.width,height:d.height,rotation:0},u)});return{command:new $(l),followup:async()=>{}}}}const Yn=new _s;class Te{constructor(){this.frameSourceSvg=async(t,e)=>{if(!t)return bn(e);const n=t.asset;if(!n)throw new ft(t);const r=n.fileLink;if(r)return et(r,!0);throw new Qt(n)}}async init(t,e,n){const r=n?.serializableWorkflow.steps.find(s=>s.stepName===t.stepName);if(r?.storage&&Object.keys(r.storage).length!==0||r?.selectedVariants&&r.selectedVariants.length!==0)return await this.reload(t,e,n),null;t.mandatory&&e.setMandatoryFulfilled(t.stepName,!1),e.markStepsAsInitialised([t.stepName]);let i;const o=e.getWorkflowExperience().getBundle();if(o&&t.globalPropertyAspectConfigurations){const s=o.getGlobalPropertyStateManager(),l=t.globalPropertyAspectConfigurations[0],c=s.getAspectStorage(l.aspectName);c&&c.originalAssetKey&&(i=(await U.getLocalOrFromServer(c.originalAssetKey)).fileLink)}if(t.option&&t.option.variants&&t.option.variants.length>0){const s=t.option,l=Y.getDefaultVariant(s);return l?this.selectVariantCommand(t,l,[],e,void 0,i||t.data.placeholderImageUrl):null}return this.selectVariantCommand(t,void 0,[],e,void 0,i||t.data.placeholderImageUrl)}async reload(t,e,n){const r=e.getSerializedStep(t.stepName,n.serializableWorkflow.steps),l=Object.values(n.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName).map(c=>({id:c.id,region:c.stepRegion,regionIndex:c.stepRegionIndex}));if(!t.option||(t.option.variants||[]).length===0){const c=t.data.regions.map(d=>bn(d));e.updateStorage(t.stepName,{currentFrameSources:c})}if(r){const c=async()=>{const d=r.storage?.colors,u=r.storage?.framePatternSrc,A=r.storage?.frameOffsetsList;if(e.updateMetadata(t.stepName,{frameOffsetsList:A,framePatternSrc:u}),u){const h=e.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!h)throw new Error("Frame service unavailable, cannot load pattern!");await this.loadPatternFromString(u,h,!0,d),e.updateMetadata(t.stepName,{image:u}),e.updateStorage(t.stepName,{framePatternSrc:u}),this.validateColorCount(t,e)}if(A?.some(h=>h.zoom)){const h=e.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!h)throw new Error("Frame service unavailable, cannot load pattern!");h.updateOffsets(A)}e.setMandatoryFulfilled(t.stepName,!0)};if(r.selectedVariants&&r.selectedVariants.length>0){const d=r.selectedVariants[0].id;if(t.option&&d){const u=t.option.variants?.find(A=>A.id===d);u&&await e.setSelectionsAndElements(t.stepName,[u],l,async()=>{const A=await Promise.all(t.data.regions.map(h=>this.frameSourceSvg(u,h)));e.updateStorage(t.stepName,{currentFrameSources:A}),await c()})}}else await e.setSelectionsAndElements(t.stepName,[],l,c)}}async availableColors(t,e){return t.data.colorOption?.variants?.map(r=>({fill:r.color,stroke:r.color,variant:r,pmsValue:r.name}))??[]}selectImage(t,e,n,r=!0){const i=Te.patternSource(e),o=n.getStepStorage(t.stepName)?.framePatternSrc;if(o&&o===i)return Promise.resolve();n.setEditedStatus(t.stepName,!0);const s=e.fileLink||"";return s.endsWith(".pdf")||s.endsWith(".eps")||s.endsWith(".ai")?new Promise(l=>{n.addPoller(new xr(async()=>{const d=(await U.getFromServer(e.key||"")).versions?.find(A=>A.name==="svg");return d?(await rt(d.link)).status===200:!1},()=>{U.getLocalOrFromServer(e.key||"").then(c=>{this.loadPatternFromAsset(c,t,n,r).then(l)})},()=>{throw new Le("Failed to resolve transcoded PDF")}))}):this.loadPatternFromAsset(e,t,n,r)}async selectVariant(t,e,n,r,i){const o=await this.selectVariantCommand(t,e,n,r,i);o&&(o.command&&r.getCommandDispatcher()(o.command),o.followup&&await o.followup())}getCreateElementCommand(t,e,n,r,i){return new G({id:t,type:F.Frame,x:e.left,y:e.top,width:e.width,height:e.height,layer:e.layer,layerIndex:e.layerIndex,rotation:e.rotation,scaleX:e.width/i.frameData.width,scaleY:e.height/i.frameData.height,path:i.frameData.path,dataWidth:i.frameData.width,dataHeight:i.frameData.height,stepRegion:e,stepRegionIndex:n,stepName:i.stepName,disablePlaceholder:i.disablePlaceholder,pattern:i.pattern,immutable:e.immutable},r)}async loadPatternFromString(t,e,n=!0,r=void 0,i){if(t.endsWith("svg")){const o=await jn(t),s=o.width,l=o.height,c=await et(t);if(i){const A=c.match(/<(image|linearGradient|radialGradient)(\s|>|\/>)/gim);if(A&&A.length>0)throw new Error("Vector files may not include images or gradients when a color limit is specified.")}const d=await it(c),u={src:t,width:s,height:l,aspect:s/l,svg:d.svg,colors:r??d.colors};dt.set(t,u),e.setPatternData(u,n)}else{const o=await Ve(t,!0),s=await de(o),l={src:t,width:s.width,height:s.height,aspect:s.width/s.height,svg:void 0,colors:void 0};dt.set(t,l),e.setPatternData(l,n)}}changeColors(t,e,n){const r=e.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!r||!r.getImageData()?.svg){console.warn("changeColors was called without an SVG being assigned to a frame step");return}const i=this.calculateColorMetadata(r,t,n);e.updateMetadata(t.stepName,{colors:i.metadataColors}),e.updateStorage(t.stepName,{colors:i.storageColors}),r.setPatternData({...r.getImageData(),colors:i.newColors},!1),this.validateColorCount(t,e)}getUniqueColorCount(t,e){const n=e.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!n)return 0;const r=n.getImageData()?.colors??{},i=[];for(const o in r){const s=r[o];if(s.pmsValue){const l=s.pmsValue.trim().toLocaleLowerCase();i.includes(l)||i.push(l)}else if(s.browserValue){const l=tr(s.browserValue);i.includes(l)||i.push(l)}}return i.length}calculateColorMetadata(t,e,n){if(!t.getImageData()?.svg)return{newColors:void 0,metadataColors:void 0,storageColors:void 0};const r={...t.getImageData().colors??{}},i={};Object.entries(r).forEach(([l,c])=>{const d={browserValue:c.browserValue};i[l]=d});for(const[l,c]of n.entries())r[l]={browserValue:c.browserValue,pmsValue:c.pmsValue},i[l]=c;let o=Array.from(Object.values(r)).map(l=>l.browserValue);const s=e.data.colorOption;return s&&s.variants?.forEach(l=>{o=o.map(c=>c.toLowerCase()===l.color?.toLowerCase()?l.name:c)}),{newColors:r,metadataColors:o,storageColors:i}}validateColorCount(t,e){const n=t.data.colorPickerEnabled?t.data.maxColors??0:0;e.setStepError(t.stepName,"colors",n>0&&this.getUniqueColorCount(t,e)>n?"workflow.steps.frame.tooManyColors":void 0)}async selectVariantCommand(t,e,n,r,i,o){const s=r.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!s)throw new Error("Frame service unavailable, cannot load pattern!");const l=await Promise.all(t.data.regions.map(h=>this.frameSourceSvg(e,h)));i&&i(!0);const c=t.data.initialZoomLevel,d=await Promise.all(t.data.regions.map(async(h,g)=>{const m=await me(l[g]),p=s.getImageData(),f=n.map(I=>new xt(I.id)),S=p?Gn(p,m,c&&!t.data.forceImageCover?{scale:c}:void 0,t.data.forceImageCover):void 0,w=p?{id:M(),src:p.src,x:S?.x||0,y:S?.y||0,width:p.width,height:p.height,scaleX:S?.zoom||1,scaleY:S?.zoom||1,rotation:0}:void 0,x=M(),E=r.getLayouts().find(I=>I.panelId===h.panelId);if(!E)throw new J(h);return{command:this.getCreateElementCommand(x,h,g,E,{frameData:m,pattern:w,disablePlaceholder:t.data.disablePlaceholder,stepName:t.stepName}),regionEl:{id:x,region:h,regionIndex:g},removeExistingCommands:f}})),u=d.map(h=>h.command),A=d.map(h=>h.removeExistingCommands).flat();return{command:new $([...u,...A]),followup:async()=>{i&&i(!1),await r.setSelectionsAndElements(t.stepName,e?[e]:[],[...d.map(h=>h.regionEl)],async()=>{if(r.updateStorage(t.stepName,{currentFrameSources:l}),o){const h=r.getWorkflowExperience().getStepById(t.stepName)?.frameService;if(!h)throw new Error("Frame service unavailable, cannot load pattern!");await this.loadPatternFromString(o,h,!0)}})}}}static patternSource(t){const e=t.versions?.find(r=>r.name==="svg");if(e?.link)return e.link;const n=t.fileLink;if(n)return n;throw new Qt(t)}async loadPatternFromAsset(t,e,n,r){const i=Te.patternSource(t),o=n.markUpdatePending(),s=n.getWorkflowExperience().getStepById(e.stepName)?.frameService;if(!s)throw n.markUpdateCompleted(o),new Error("Frame service unavailable, cannot load pattern!");try{await this.loadPatternFromString(i,s,r,void 0,e.data.colorPickerEnabled&&!!e.data.maxColors&&e.data.maxColors>0)}catch(c){throw n.markUpdateCompleted(o),c}const l=this.calculateColorMetadata(s,e,new Map(Object.entries(s.getImageData()?.colors??{})));n.updateMetadata(e.stepName,{image:i,colors:l.metadataColors}),n.updateStorage(e.stepName,{framePatternSrc:i,colors:l.storageColors}),n.markUpdateCompleted(o),n.setMandatoryFulfilled(e.stepName,!0),n.setInformationResults(n.getInformationResults().filter(c=>c.stepID===e.stepName)),this.validateColorCount(e,n)}}const gt=new Te;class Xs{async getIllustrationBody(t){return new Promise(e=>{et(t,!0).then(n=>{e(n)}).catch(n=>console.error(n))})}getCreateElementCommand(t,e,n,r,i){return new G({stepRegion:e,stepRegionIndex:n,stepName:i.stepName,colors:i.svg.colors,id:t,src:i.src,svg:i.svg.svg,cachedObjectURL:i.objectURL,type:F.Illustration,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer,layerIndex:e.layerIndex,immutable:e.immutable},r)}getColors(t,e){const n=e.getRegionElements(t.stepName)||[];if(n.length===0)return[];try{return L(n[0].id,e.getAllLayoutData()).colors}catch{return[]}}async init(t,e,n){const r=t.option;if(!r)return null;if(n)return this.reload(t,e,n);{const i=Y.getDefaultVariant(r);if(i)return await this.selectVariantCommand(t,i,[],()=>{},e)}return null}async reload(t,e,n){const r=e.getSerializedStep(t.stepName,n.serializableWorkflow.steps),s=Object.values(n.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(l&&c){const d=l.variants?.find(u=>u.id===c);if(d){const u=s.map(A=>({id:A.id,region:A.stepRegion,regionIndex:A.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[d],u,async()=>{e.updateMetadata(t.stepName,{colors:r.storage?.colors}),e.setMandatoryFulfilled(t.stepName,!0)})}}else throw new Error("Required illustration variant no longer available")}return null}async availableColors(t,e){const n=t.data.colorOption;return n?n?n.variants?.map(r=>({fill:r.color,stroke:r.color,variant:r,pmsValue:r.name})):[]:[]}async changeColorsCommand(t,e,n,r,i){const o={};for(const[d,u]of i.entries())typeof u=="string"?o[d]={browserValue:u,spotColor:void 0,pmsValue:void 0}:o[d]={browserValue:u.browserValue,spotColor:u.spotColor,pmsValue:u.pmsValue};const s=Un(t,e,n,o),l=await oe(s),c=[];for(const d of r){for(const[u,A]of i.entries())c.push(new xn(d,u,A));c.push(new Ws(d,s,l))}return new $(c)}async changeColors(t,e,n,r,i){if(e.length===0)return;const o=L(e[0].id,r().map(h=>h.layoutState)),s={...o.colors},l={};Object.entries(s).forEach(([h,g])=>{const m={browserValue:g.browserValue,pmsValue:g.pmsValue},p=g.spotColor;p&&(m.spotColor={profileName:p.profileName,namedColor:p.namedColor}),l[h]=m});for(const[h,g]of i.entries()){const m=typeof g=="string"?g:g.browserValue,p=typeof g=="string"?void 0:g.pmsValue;s[h]={browserValue:m,spotColor:s[h]?.spotColor,pmsValue:p},l[h]={browserValue:m}}let c=Array.from(Object.values(s)).map(h=>h.browserValue);const d=t.data.colorOption;d&&d.variants?.forEach(h=>{c=c.map(g=>g.toLowerCase()===h.color?.toLowerCase()?h.name:g)}),n.updateMetadata(t.stepName,{colors:c});const u=new Map;if(Object.entries(s).forEach(([h,g])=>{u.set(h,g)}),!o.svg)throw new Error("Colors changed before SVG loaded. This should never happen!");const A=await this.changeColorsCommand(o.svg,o.width,o.height,e.map(h=>h.id),u);n.updateStorage(t.stepName,{colors:l}),n.getCommandDispatcher()(A)}async selectVariant(t,e,n,r,i){const o=await this.selectVariantCommand(t,e,n,r,i);o&&(o.command&&i.getCommandDispatcher()(o.command),o.followup&&await o.followup())}async selectVariantCommand(t,e,n,r,i){if(!t.data||!t.data.regions)throw new re(t,"Missing regions.");r(!0);const o=n.map(f=>new xt(f.id));t.mandatory&&i.setMandatoryFulfilled(t.stepName,!1);const s=e.asset;if(!s)throw new ft(e);const l=s.fileLink;if(!l)throw new Qt(s);const c=await it(await this.getIllustrationBody(l)),d=await oe(c.svg),u=(f,S)=>{const w=i.getLayouts().find(v=>v.panelId===f.panelId);if(!w)throw new J(f);const x=M();return{regionElement:{id:x,region:f,regionIndex:S},command:this.getCreateElementCommand(x,f,S,w,{stepName:t.stepName,src:l,objectURL:d,svg:c})}},A=t.data.regions.map(u),g=[...A.map(f=>f.command),...o];let m=Array.from(Object.values(c.colors)).map(f=>f.browserValue);const p=t.data.colorOption;return p&&p.variants?.forEach(f=>{m=m.map(S=>S.toLowerCase()===f.color?.toLowerCase()?f.name:S)}),i.updateMetadata(t.stepName,{colors:m}),{command:new $(g),followup:async()=>{await i.setSelectionsAndElements(t.stepName,[e],A.map(S=>S.regionElement),async()=>{i.setMandatoryFulfilled(t.stepName,!0),r(!1)});const f=s.assetConfiguration?.defaultColorVariants||[];if(f.length!==0){const S={};(s.assetConfiguration?.channelNumbers||[]).forEach(x=>{const v=f.find(E=>E.channelNumber===x.number);v&&(S[`${x.id.replace(/\W/g,"")}`]={browserValue:v?.variant?.color||""})}),await this.changeColors(t,A.map(x=>x.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map(Object.entries(S)))}if(t.data.colorPickerEnabled){const S=await this.availableColors(t,i)||[],w=Object.keys(c.colors),x=S.length===1&&w.length===1;if(x){const v=S[0],E=w[0];await this.changeColors(t,A.map(I=>I.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map([[E,v.variant.color]]))}!x&&f.length===0&&await this.changeColors(t,A.map(v=>v.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map)}}}}}const Jt=new Xs;class Zs{async init(t,e,n){const r=t.option;if(!r)throw new ae(t);if(n)await this.reload(t,e,n);else{const i=Y.getDefaultVariant(r);if(i)return await this.selectVariantLambda(t,i,e,()=>{})}return null}async reload(t,e,n){const r=e.getSerializedStep(t.stepName,n.serializableWorkflow.steps),s=Object.values(n.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(!l)throw new ae(t);if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(c){const d=l.variants?.find(u=>u.id===c);if(d){const u=d.material,A=s.map(h=>({id:h.id,region:h.stepRegion,regionIndex:h.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[d],A,async()=>{const h=e.getModelContainer();if(h){const g=t.data.targetMaterials.map(m=>h.applyMaterialVariant(m,l.id||"",u||{}));Promise.all(g).then(()=>e.setMandatoryFulfilled(t.stepName,!0))}})}}}}async selectVariant(t,e,n,r){const i=await this.selectVariantLambda(t,e,n,r);i&&(i.command&&n.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantLambda(t,e,n,r){const i=n.getModelContainer();r(!0);const o=e.material;if(!o)throw r(!1),new ft(e);return{command:void 0,followup:async()=>{await n.setSelectionsAndElements(t.stepName,[e],[],async()=>{try{i&&t.data.targetMaterials.forEach(s=>{t.option&&i.applyMaterialVariant(s,t.option.id||"",o)}),n.setMandatoryFulfilled(t.stepName,!0)}finally{r(!1)}})}}}}const Jn=new Zs;class tl{async init(t,e,n){const r=t.option;if(!r)throw new ae(t);if(n)await this.reload(t,e,n);else{const i=Y.getDefaultVariant(r);if(i)return await this.selectVariantLambda(t,i,e,()=>{})}return null}async reload(t,e,n){const r=e.getSerializedStep(t.stepName,n.serializableWorkflow.steps),s=Object.values(n.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(l&&c){const d=l.variants?.find(u=>u.id===c);if(d){const u=s.map(A=>({id:A.id,region:A.stepRegion,regionIndex:A.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[d],u,async()=>{const A=e.getModelContainer();if(A&&t.option){const h=d.asset?.fileLink;if(!h)throw new ft(d);await A.applyModelVariant(t.stepName||"",{model:h,contextService:e.getLayoutPreviewService()},t.data.replaceProductModel||!1),e.setMandatoryFulfilled(t.stepName,!0)}})}}}}async selectVariant(t,e,n,r){const i=await this.selectVariantLambda(t,e,n,r);i&&(i.command&&n.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantLambda(t,e,n,r){r(!0);const i=e.asset?.fileLink;if(!i)throw new ft(e);return{command:void 0,followup:async()=>{await n.setSelectionsAndElements(t.stepName,[e],[],async()=>{try{const o=n.getModelContainer();o&&await o.applyModelVariant(t.stepName,{model:i,contextService:n.getLayoutPreviewService()},t.data.replaceProductModel||!1),n.setMandatoryFulfilled(t.stepName,!0)}finally{r(!1)}})}}}}const Kn=new tl;class el{async init(t,e,n){if(n)await this.reload(t,e,n);else return e.updateMetadata(t.stepName,{text:""}),this.changeTextCommand(t,"",e,()=>{});return null}async reload(t,e,n){const r=e.getSerializedStep(t.stepName,n.serializableWorkflow.steps),l=Object.values(n.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName).map(c=>({id:c.id,region:c.stepRegion,regionIndex:c.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[],l,async()=>{e.updateStorage(t.stepName,{text:r?.storage?.text}),e.setMandatoryFulfilled(t.stepName,r?.storage?.text!=="")})}async changeText(t,e,n,r){const i=await this.changeTextCommand(t,e,n,r);i&&(i.command&&n.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async changeTextCommand(t,e,n,r){const i=n.getRegionElements(t.stepName),o=n.getStepSpecificServices(t.stepName)?.module;if(!o)return console.error("Missing module."),null;const s=n.getWorkflowExperience().getProfanityList(),l=this.validateInput(t,e,s,r);if(l.errorData)return n.setMandatoryFulfilled(t.stepName,!1),l.errorData.blockedProfanity?console.error("Blocked profanity."):l.errorData.hitCharacterLimit?console.error("Too many characters."):l.errorData.unsupportedCharacters&&console.error("Unsupported characters."),null;if(n.setMandatoryFulfilled(t.stepName,e!==""),!t.data||!t.data.regions||t.data.regions.length<=0)return console.error("Missing configuration."),null;n.updateStorage(t.stepName,{text:e}),n.updateMetadata(t.stepName,{text:e});const c=(d,u,A,h)=>{const g=h||M(),p=n.getLayouts().find(S=>S.panelId===u.panelId);if(!p)return console.error(`Can not find layout for region: ${u.panelId}`),null;const f=[];return h&&f.push(new xt(g)),f.push(new G({stepRegion:u,stepRegionIndex:A,stepName:t.stepName,colors:{},id:g,svg:d,type:F.Illustration,y:u.top,x:u.left,rotation:u.rotation,width:u.width,height:u.height,layer:u.layer,layerIndex:u.layerIndex,immutable:u.immutable},p)),{id:g,region:u,command:new $(f)}};if(i.length>0){const u=i.map(A=>{if(!A.region)return null;const h=o.svgPrint(e,A.region);return c(h,A.region,A.regionIndex,A.id)}).filter(A=>!!A).filter(A=>!!A).map(A=>A&&A.command);return{command:new $(u),followup:async()=>{}}}else{const d=t.data.regions.map((A,h)=>c(o.svgPrint(e,A),A,h)),u=d.filter(A=>!!A).map(A=>A&&A.command);return{command:new $(u),followup:async()=>{const A=d.filter(h=>h).map(h=>h&&{id:h.id,region:h.region});await n.setSelectionsAndElements(t.stepName,[],A)}}}}validateInput(t,e,n,r){if(t.data&&t.data.maxLength){const o=t.data.maxLength;if(e.length>o)return r("Too many characters."),{input:e,helperData:{},errorData:{hitCharacterLimit:!0}}}if(!/^$|^[a-zA-Z0-9 ]+$/.test(e))return r("Unsupported characters."),{input:e,helperData:{},errorData:{unsupportedCharacters:!0}};const i=pn.split(e.toLowerCase());for(const o of i)for(const s in n){const l=n[s].toLowerCase().replace(/\s/g,"");if(o===l)return r("Blocked profanity."),{input:e,helperData:{},errorData:{blockedProfanity:!0}}}return r(""),{input:e,helperData:{}}}}const _n=new el;class nl{async init(t,e,n){const r=t.option;if(!r)return null;if(n)await this.reload(t,e,n);else if(r.defaultVariant)return e.markStepsAsInitialised([t.stepName]),this.selectVariantCommand(t,r.defaultVariant,e,()=>{});return e.markStepsAsInitialised([t.stepName]),null}async reload(t,e,n){const r=e.getSerializedStep(t.stepName,n.serializableWorkflow.steps),s=Object.values(n.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(l&&c){const d=l.variants?.find(u=>u.id===c);if(d){const u=s.map(A=>({id:A.id,region:A.stepRegion,regionIndex:A.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[d],u,async()=>{e.setMandatoryFulfilled(t.stepName,!0)})}}}}async selectVariant(t,e,n,r){const i=await this.selectVariantCommand(t,e,n,r);i&&(i.command&&n.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantCommand(t,e,n,r){const i=e.asset;if(!i)throw new ft(e);const o=i?.fileLink;if(!o)return console.error("No URL for picture!"),null;r(!0),t.mandatory&&n.setMandatoryFulfilled(t.stepName,!1);const l=n.getRegionElements(t.stepName).map(u=>new xt(u.id)),c=(u,A)=>{const g=n.getLayouts().find(p=>p.panelId===u.panelId);if(!g)throw new J(u);const m=M();return{regionElement:{id:m,region:u,regionIndex:A},command:new G({stepName:t.stepName,stepRegion:u,stepRegionIndex:A,id:m,src:o,type:F.Image,y:u.top,x:u.left,rotation:u.rotation,width:u.width,height:u.height,layer:u.layer,layerIndex:u.layerIndex,immutable:u.immutable,preserveAspectRatio:"none"},g)}},d=t.data.regions.map(c);return{command:new $([...l,...d.map(u=>u.command)]),followup:async()=>{await n.setSelectionsAndElements(t.stepName,[e],d.map(u=>u.regionElement),async()=>{n.setMandatoryFulfilled(t.stepName,!0),r(!1)})}}}}const Xn=new nl;class al{async init(t,e,n){const r=t.option;if(!r)return null;if(n)await this.reload(t,e,n);else{const i=r.variants;if(Y.getDefaultVariant(r)){const s=i?.find(l=>l.id===r.defaultVariant?.id);return this.selectVariantLambda(t,s?.id||"",e)}}return null}async reload(t,e,n){const r=e.getSerializedStep(t.stepName,n.serializableWorkflow.steps),i=t.option;if(r?.selectedVariants){const o=r.selectedVariants[0].id;if(i&&o){const s=i.variants?.find(l=>l.id===o);s&&await e.setSelectionsAndElements(t.stepName,[s],[])}}}async selectVariant(t,e,n){await n.getInitializationPromise();const r=await this.selectVariantLambda(t,e,n);r&&(r.command&&n.getCommandDispatcher()(r.command),r.followup&&await r.followup())}async selectVariantLambda(t,e,n){const r=t.option;if(!r)return null;const i=r.variants;if(!i)return null;const o=i.length>1?i.find(s=>s.id===e):i[0];if(!o)throw new Error(`Failed to find selected variant ${e} in option ${r.id} of step ${t.stepName} (${t.stepTitle})`);return{command:void 0,followup:async()=>{await n.setSelectionsAndElements(t.stepName,[o],[],async()=>{n.setMandatoryFulfilled(t.stepName,!0)})}}}}const Zn=new al;class rl{constructor(){this.shapeFillId="spiff-fill-shape"}async availableColours(t){const e=t.option;return e?e.variants?.map(n=>({fill:n.color,stroke:n.color,variant:n}))||[]:[]}setCustomColor(t,e,n){const r=n.getLayouts(),o=(n.getRegionElements(e.stepName)||[]).map(s=>{const l=s.region;if(!r.find(d=>d.panelId===l?.panelId))throw new J(l);return new xn(s.id,this.shapeFillId,t)}).filter(s=>!!s);n.getCommandDispatcher()(new $(o)),n.updateStorage(e.stepName,{colour:t})}async init(t,e,n){const r=t.option;if(!r)throw new ae(t);if(n)await this.reload(t,e,n);else{const i=Y.getDefaultVariant(r);return i?this.selectVariantCommand(t,{fill:i.color,stroke:i.color,variant:i},[],e):null}return null}async selectVariant(t,e,n,r){const i=await this.selectVariantCommand(t,e,n,r);i&&(i.command&&r.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async reload(t,e,n){const r=e.getSerializedStep(t.stepName,n.serializableWorkflow.steps),s=Object.values(n.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(l&&c){const d=l.variants?.find(u=>u.id===c);if(d){const u=s.map(A=>({id:A.id,region:A.stepRegion,regionIndex:A.stepRegionIndex}));await e.setSelectionsAndElements(t.stepName,[d],u,async()=>{e.updateStorage(t.stepName,{colour:r?.storage?.colour||""}),e.setMandatoryFulfilled(t.stepName,!0)})}}}}async selectVariantCommand(t,e,n,r){const i=r.getLayouts(),o=r.getStepStorage(t.stepName)?.colour,s=()=>{if(e.variant?.color==="#custom")return o||"#FFFFFF";if(e.variant?.color)return e.variant.color;throw new Error("Failed to resolve color for shape step.")};if(n.length>0){const l=d=>{const u=d.region;if(!i.find(g=>g.panelId===u?.panelId))throw new J(u);const h=s();return new xn(d.id,this.shapeFillId,h)},c=n.map(l).filter(d=>!!d);return{command:new $(c),followup:async()=>{await r.setSelectionsAndElements(t.stepName,e.variant?[e.variant]:[],n),r.updateStorage(t.stepName,{colour:s()})}}}else{const l=(A,h)=>{const g=i.find(w=>w.panelId===A.panelId);if(!g)throw new J(A);const m=s(),p=`
|
|
1426
1426
|
<svg
|
|
1427
1427
|
xmlns="http://www.w3.org/2000/svg"
|
|
1428
1428
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
@@ -1442,14 +1442,14 @@
|
|
|
1442
1442
|
fill="${m}"
|
|
1443
1443
|
/>
|
|
1444
1444
|
</svg>
|
|
1445
|
-
`,f={};f[this.shapeFillId]={browserValue:m};const S=M();return{id:S,region:A,command:new G({stepRegion:A,stepRegionIndex:h,stepName:t.stepName,colors:f,id:S,svg:p,type:F.Illustration,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer,layerIndex:A.layerIndex,immutable:A.immutable,excludeFromExport:t.data.excludeFromPrint},g)}},c=t.data.regions.map(l),d=c.filter(A=>!!A).map(A=>A?.command),u=c.filter(A=>!!A).map((A,h)=>({id:A.id,region:A.region,regionIndex:h}));return{command:new $(d),followup:async()=>{await r.setSelectionsAndElements(t.stepName,e.variant?[e.variant]:[],u,async()=>{r.updateStorage(t.stepName,{colour:s()})})}}}}}const kt=new
|
|
1446
|
-
`)).flat(),o=i.length,s=i.map(d=>pt(d,
|
|
1447
|
-
`];class Qe extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),this.name=Qe.name}}class
|
|
1448
|
-
`)||t.includes("\r"))&&(i||(i={}),i.illegalMultipleLines=!0),i}}async init(t,e,
|
|
1449
|
-
`);c.push(this.generateTextChangeCommandsForRegion(h,
|
|
1450
|
-
`);E.push(this.generateTextChangeCommandsForRegion(R,
|
|
1445
|
+
`,f={};f[this.shapeFillId]={browserValue:m};const S=M();return{id:S,region:A,command:new G({stepRegion:A,stepRegionIndex:h,stepName:t.stepName,colors:f,id:S,svg:p,type:F.Illustration,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer,layerIndex:A.layerIndex,immutable:A.immutable,excludeFromExport:t.data.excludeFromPrint},g)}},c=t.data.regions.map(l),d=c.filter(A=>!!A).map(A=>A?.command),u=c.filter(A=>!!A).map((A,h)=>({id:A.id,region:A.region,regionIndex:h}));return{command:new $(d),followup:async()=>{await r.setSelectionsAndElements(t.stepName,e.variant?[e.variant]:[],u,async()=>{r.updateStorage(t.stepName,{colour:s()})})}}}}}const kt=new rl;class il{constructor(){this.latestToast=null,this.toastType=null,this.toastCallbacks=[]}addToastCallback(t){t({toastMessage:this.latestToast,toastType:this.toastType}),this.toastCallbacks.push(t)}removeToastCallback(t){this.toastCallbacks=this.toastCallbacks.filter(e=>e!==t)}setLatestToast(t,e){this.latestToast=t,this.toastType=e,this.onToastChange()}onToastChange(){this.toastCallbacks.forEach(t=>t({toastMessage:this.latestToast,toastType:this.toastType}))}}const Fr=new il,dn=(a,t,e,n,r)=>{if(t.some(d=>d==null))throw new Error(`Failed to autosize lines: ${t.join(", ")}`);let i=t.map(d=>d.split(`
|
|
1446
|
+
`)).flat(),o=i.length,s=i.map(d=>pt(d,n,r));const l=r.getApproximateHeight()*n;let c=!0;for(;c;){if(l+(o-1)*e>a.height)return[null,null];const u=Math.max(...s);if(u<=a.width)return[i,u];const A=s.reduce((p,f,S,w)=>f>w[p]?S:p,0),h=i[A];let g=!1,m=h.length;for(;!g&&m>-1;){m=h.lastIndexOf(" ",m-1);const p=[h.slice(0,m),h.slice(m+1)],f=p.map(w=>pt(w,n,r));f[0]<=a.width&&(i=[...i.slice(0,A),...p,...i.slice(A+1)],s=[...s.slice(0,A),...f,...s.slice(A+1)],o+=1,g=!0)}g||(c=!1)}return[null,null]},Kt=(a,t,e,n,r)=>{let i,o;const s=yt(t.assetUrl),l=s.getFont();if(r.size){const A=a/l.unitsPerEm;return[i,o]=dn(e,n,a,A,s),[r.size,i,o]}const c=6;let d=c-rn;if(n.length>0){let A=n,h=0;for(;(!r.maxSize||d<=r.maxSize)&&A;)d+=rn,h=d/l.unitsPerEm,[A,o]=dn(e,n,d,h,s)}d>c&&(d-=rn),r.minSize&&d<r.minSize&&(d=r.minSize);const u=d/l.unitsPerEm;return[i,o]=dn(e,n,d,u,s),[d,i,o]},un=30;class Ne extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),this.name=Ne.name}}const ol=["‘","’","“","”",`
|
|
1447
|
+
`];class Qe extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),this.name=Qe.name}}class sl{constructor(){this.cachedColors=new Map,this.cachedStrokeColors=new Map,this.filterUnsupportedCharacters=(t,e)=>{let n=t.replace(/(\r\n|\r|(\u2665|\u00a9|\u00ae|[\u2000-\u2017]|[\u201E-\u3300]]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]))/gm,"");const r=[],i=e?yt(e.assetUrl):void 0;if(i){const o=n.split("").filter(l=>!ol.includes(l)).join(""),s=o.split("").map(l=>i.getFont().charToGlyph(l));for(let l=0;l<s.length;l++)s[l].name===".notdef"&&r.push(String.fromCharCode(o.charCodeAt(l)))}for(let o=0;o<r.length;o++)n=n.replaceAll(r[o],"");return n},this.textAlign=t=>t.vertical?"center":t.textAlign||"center",this.getErrorsForText=(t,e,n,r)=>{let i;n.data&&n.data.maxLength&&e.length>n.data.maxLength&&(i||(i={}),i.hitCharacterLimit=!0);const o=r.getWorkflowExperience().getProfanityList(),s=pn.split(t.toLowerCase());for(const c of s)for(const d in o){const u=o[d].toLowerCase().replace(/\s/g,"");if(c===u){i||(i={}),i.blockedProfanity=!0;break}}return!n.data.allowNewlines&&(t.includes(`
|
|
1448
|
+
`)||t.includes("\r"))&&(i||(i={}),i.illegalMultipleLines=!0),i}}async init(t,e,n){const r=t.option;if(!r)return null;if(n)await this.reload(t,e,n);else{const i=this.getDefaultImageFillVariant(t.data),o=i?.asset?.fileLink,s=o?await In(o):void 0,l=s?{src:s.src,height:s.height,width:s.width,scale:t.data.imageFillScale||1}:void 0,c=this.getDefaultStrokeColorVariant(t.data),d=t.data.strokeEnabled&&c?.color?{browserValue:c.color,pmsValue:c.name}:void 0;let u=t.data.defaultText||"";const A=e.getWorkflowExperience().getBundle();if(A&&t.globalPropertyAspectConfigurations){const m=A.getGlobalPropertyConfiguration()?.aspects?.find(p=>p.type===z.Text&&t.globalPropertyAspectConfigurations?.map(f=>f.aspectName).includes(p.name));if(m){const f=A.getGlobalPropertyStateManager().getAspect(m.name);f&&(u=f)}}e.updateStorage(t.stepName,{text:u,inputText:t.data.defaultText||"",color:this.getDefaultColorVariant(t.data)?.color||this.getDefaultColor(t.data),fillImage:l,strokeColor:d}),e.updateMetadata(t.stepName,{text:u,color:this.getDefaultColorVariant(t.data)?.name||this.getDefaultColor(t.data),fillImage:i?.name,strokeColor:t.data.strokeEnabled?c?.color:void 0});const h=Y.getDefaultVariant(r);if(h)return this.selectVariantCommand(t,h,{text:u},[],e,()=>{},()=>{},l,d)}return null}findLayoutElements(t,e){return t.getRegionElements(e.stepName).map(i=>L(i.id,t.getAllLayoutData()))}availableFillColors(t){const e=this.cachedColors.get(t.stepName);if(e)return e;const n=t.data.colorOption;if(n){const r=n.variants?.map(i=>({fill:i.color,stroke:i.color,variant:i}))||[];return this.cachedColors.set(t.stepName,r),r}return[]}changeAlignment(t,e,n,r){if(!t.data||!t.data.regions)return;const i=r.getCommandDispatcher();for(const o of n){const s=new Ir(o.id,e);i(s)}}async changeFillColor(t,e,n,r){if(!t.data||!t.data.regions)return;const i=r.getCommandDispatcher();e.variant?r.updateMetadata(t.stepName,{color:e.variant.name}):r.updateMetadata(t.stepName,{color:e.fill});const o=t.data.colorOption,s=o?this.createTextFillSpotColor(o,e.variant):void 0;o?r.updateStorage(t.stepName,{color:e.fill,colorProfileAssetKey:o.colorProfile?.key}):r.updateStorage(t.stepName,{color:e.fill});for(const l of n){if(!e.fill)throw new Error("Fill not set on new color selection!");const c=new Er(l.id,e.fill,s);i(c)}}async availableFillImages(t){const e=t.data.imageFillOption;if(e){const n=e.variants?.map(r=>r.asset?.fileLink)?.filter(r=>!!r)||[];return Promise.all(n.map(async r=>{const i=await In(r);return{src:r,width:i.width,height:i.height,scale:t.data.imageFillScale||1}}))}return Promise.resolve([])}async changeFillImage(t,e,n,r){if(!t.data||!t.data.regions)return;const i=r.getCommandDispatcher(),o=t.option?.variants?.find(s=>s.asset?.fileLink===e.src);r.updateMetadata(t.stepName,{fillImage:o?.name}),r.updateStorage(t.stepName,{fillImage:e});for(const s of n){const l=new ln(s.id,e);i(l)}}availableStrokeColors(t){const e=this.cachedStrokeColors.get(t.stepName);if(e)return e;const n=t.data.strokeOption;if(n){const r=n.variants?.map(i=>({fill:i.color,stroke:i.color,variant:i}))||[];return this.cachedStrokeColors.set(t.stepName,r),r}return[]}async changeStrokeColor(t,e,n,r){if(!t.data||!t.data.regions)return;const i=r.getCommandDispatcher();e?.variant?r.updateMetadata(t.stepName,{strokeColor:e.variant.name}):r.updateMetadata(t.stepName,{strokeColor:e?.fill});const o=e?{browserValue:e.fill,pmsValue:e.pmsValue}:void 0;r.updateStorage(t.stepName,{strokeColor:o});for(const s of n){const l=new cn(s.id,o,t.data?.strokeThickness);i(l)}}getProcessedInput(t,e,n){const r=n?t:this.injectReplaceableText(t,e);return Me(r,{vertical:e.vertical,uppercase:e.uppercase})}updateInputText(t,e,n,r){const i=r.getStepStorage(n.stepName),o=Mt(t,r),s=this.getProcessedInput(o,n.data,i?.customiseAllText??!1),l={command:void 0,helperData:{},errorData:this.getErrorsForText(t,s,n,r)};if(l.errorData)return l;l.helperData.charactersRemaining=n.data.maxLength-s.length;const c=[],d=new Map,u=new Map;for(const A of e){if(!A.fontData)throw new Q("Failed to resolve font data for text.");const[h,g]=Kt(A.fontSize,A.fontData,{left:A.x,top:A.y,width:A.width,height:A.height,rotation:A.rotation},[s],{size:n.data.size,minSize:n.data.minSize,maxSize:n.data.maxSize});d.set(A.id,h),u.set(A.id,g);const m=n.data.curved?s:(g||[]).join(`
|
|
1449
|
+
`);c.push(this.generateTextChangeCommandsForRegion(h,n.data,A.id,m))}return!n.data.curved&&e.length>0&&!Array.from(u.values()).every(h=>h)?(l.errorData||(l.errorData={}),l.errorData.doesNotFit=!0,l):(r.updateStorage(n.stepName,{text:t}),r.updateMetadata(n.stepName,{text:s}),(i?.defaultCleared||!n.data.deleteDefaultOnFocus)&&s.trim()!==""&&r.setMandatoryFulfilled(n.stepName,!0),l.command=new $(c),l)}async selectVariant(t,e,n,r,i){const o=await this.selectVariantCommand(t,e,n.getStepStorage(t.stepName)||{},n.getRegionElements(t.stepName),n,r,i);o&&(o.command&&n.getCommandDispatcher()(o.command),o.followup&&await o.followup())}createTextFillSpotColor(t,e){const n=t.colorProfile;if(n){const r=(n.name||"").replace(/\s/g,"-"),i=r.lastIndexOf("/"),s=r.slice(i+1).slice(0,-4);if(!e.namedColor)throw new Error("variant named color not set!");return{profileName:s,namedColor:e.namedColor}}}async reload(t,e,n){const r=e.getSerializedStep(t.stepName,n.serializableWorkflow.steps),s=Object.values(n.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName),l=t.option;if(r?.selectedVariants){const c=r.selectedVariants[0].id;if(l&&c){const d=l.variants?.find(u=>u.id===c);if(d){const u=await this.fontDataFromVariant(d),A=s.map(p=>({id:p.id,region:p.stepRegion,regionIndex:p.stepRegionIndex})),h=r.storage?.color;let g=r.storage?.text;const m=e.getWorkflowExperience().getBundle();if(m&&t.globalPropertyAspectConfigurations){const f=m.getGlobalPropertyConfiguration()?.aspects?.find(S=>S.type===z.Text&&t.globalPropertyAspectConfigurations?.map(w=>w.aspectName).includes(S.name));if(f){const w=m.getGlobalPropertyStateManager().getAspect(f.name);w&&(g=w)}}if(await e.setSelectionsAndElements(t.stepName,[d],A,async()=>{e.updateMetadata(t.stepName,{color:h,text:g}),e.updateStorage(t.stepName,{text:g,inputText:g});const p=s.map(S=>new Pn(S.id,u)),f=new $(p);e.getCommandDispatcher()(f)}),s.length===0&&l){const p=Y.getDefaultVariant(l);if(p){const f=await this.selectVariantCommand(t,p,{text:g},[],e,()=>{},()=>{});e.getCommandDispatcher()(f.command)}}else{const{command:p}=j.updateInputText(g||"",s,t,e);p&&e.getCommandDispatcher()(p)}}}}else{const c=e.getWorkflowExperience().getBundle();if(c&&t.globalPropertyAspectConfigurations){const u=c.getGlobalPropertyConfiguration()?.aspects?.find(A=>A.type===z.Text&&t.globalPropertyAspectConfigurations?.map(h=>h.aspectName).includes(A.name));if(u){const h=c.getGlobalPropertyStateManager().getAspect(u.name);if(h)if(s.length===0&&l){const g=Y.getDefaultVariant(l);if(g){const m=await this.selectVariantCommand(t,g,{text:h},[],e,()=>{},()=>{});e.getCommandDispatcher()(m.command)}}else{const{command:g}=j.updateInputText(h,s,t,e);g&&e.getCommandDispatcher()(g)}}}}}getDefaultColorVariant(t){const e=t.colorOption;if(e)return Y.getDefaultVariant(e)}getDefaultColor(t){const e=t.colorOption;return e?Y.getDefaultVariant(e)?.color:void 0}getDefaultImageFillVariant(t){const e=t.imageFillOption;if(e)return Y.getDefaultVariant(e)}getDefaultStrokeColorVariant(t){const e=t.strokeOption;if(e)return Y.getDefaultVariant(e)}async fontDataFromVariant(t){const e=t.asset;if(!e)throw new ft(t);const n=e.fileLink;if(!n)throw new Qt(e);const r=await Pt(n);return{assetUrl:n,name:r.names.fullName.en}}async selectVariantCommand(t,e,n,r,i,o,s,l,c){const d=i.markUpdatePending(),u=await this.fontDataFromVariant(e);if(r.length>0){const A=r.map(m=>new Pn(m.id,u));if(l){const m=r.map(p=>new ln(p.id,l));A.push(...m)}if(c){const m=r.map(p=>new cn(p.id,c,t.data.strokeThickness));A.push(...m)}const h=await this.changeInputTextWithRegion(t,t.data.size||un,u,n.text||"",n,i,n?.customiseAllText??!1,o,s);return h&&A.push(h),{command:new $(A),followup:async()=>{i.markUpdateCompleted(d),await i.setSelectionsAndElements(t.stepName,[e],r)}}}else{const A=await this.createTextboxRegions(t.stepName,e,t.data,u,n,i),h=await this.changeInputTextWithRegion(t,t.data.size||un,u,A[0]?.newElement.input||n.text||t.data.defaultText||"",n,i,n?.customiseAllText??!1,o,s),g=A.flatMap(p=>p.commands);if(l){const p=A.map(f=>new ln(f.regionElement.id,l));g.push(...p)}if(c){const p=r.map(f=>new cn(f.id,c,t.data.strokeThickness));g.push(...p)}return h&&g.push(h),{command:new $(g),followup:async()=>{i.markUpdateCompleted(d)}}}}injectReplaceableText(t,e){return e.replaceableText?e.replaceableText.replace("{{}}",t):t}async createTextboxRegions(t,e,n,r,i,o){if(!n||!n.regions)throw new Error("Step data not supplied");const s=i.text||n.defaultText||"",l=Mt(s,o),c=this.getProcessedInput(l,n,!1),d=async(A,h)=>{const m=o.getLayouts().find(f=>f.panelId===A.panelId),p=M();try{if(!m)throw new Qe("Failed to find layout for region: "+A.panelId);const f=n.colorOption;let S;if(f&&f.variants){const k=f.variants.find(W=>W.id===f.defaultVariant?.id)||f.variants[0];S=this.createTextFillSpotColor(f,k),o.updateStorage(t,{colorProfileAssetKey:f.colorProfile?.key})}const w=await this.getDefaultColor(n),x=w||"#000000",v={stepRegion:A,stepRegionIndex:h,stepName:t,align:this.textAlign(n),fill:i.color?i.color:x,fontSize:n.size||un,fontData:r,id:p,layer:A.layer,layerIndex:A.layerIndex,rotation:A.rotation,text:c,input:s,type:F.Textbox,vertical:n.vertical,x:A.left,y:A.top,height:A.height,width:A.width,immutable:A.immutable,verticalAlign:n.verticalAlign||"middle",curved:n.curved,paths:n.paths,fillSpotColorDefinition:S},E=[],I=new Map,N=new Map;if(!v.fontData)throw new Q("Failed to resolve font data for text.");const[R,P]=Kt(v.fontSize,v.fontData,{left:v.x,top:v.y,width:v.width,height:v.height,rotation:v.rotation,panelId:""},[c],{size:n.size,minSize:n.minSize,maxSize:n.maxSize});I.set(v.id,R),N.set(v.id,P);const T=n.curved||n.vertical?c:(P||[]).join(`
|
|
1450
|
+
`);E.push(this.generateTextChangeCommandsForRegion(R,n,v.id,T));const V=new G(v,m);return{regionElement:{id:p,region:A,regionIndex:h},commands:[V,...E],newElement:v,fontData:r}}catch(f){throw console.log(f),new Ne("Error adding font to region")}},u=await Promise.all(n.regions.map(d)).catch(A=>{throw A instanceof Ne?(Fr.setLatestToast("Failed to load font.",pe.Error),A):A instanceof Qe?A:new Error(A)});return await o.setSelectionsAndElements(t,[e],u.map(A=>A.regionElement),async()=>{o.updateMetadata(t,{text:s}),o.updateStorage(t,{text:s})}),u}generateTextChangeCommandsForRegion(t,e,n,r){const i=[],o=new Br(n,r);if(i.push(o),!e.size){const l=new br(n,t);i.push(l)}return new $(i)}async changeInputTextWithRegion(t,e,n,r,i,o,s,l,c,d){const u=(r||"").replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,""),A=Mt(u,o),h=this.getProcessedInput(A,t.data,s),g=o.getRegionElements(t.stepName),m=new Map,p=new Map;for(const v of g)if(v.region){const[E,I]=Kt(e,n,v.region,[h],{size:t.data.size,minSize:t.data.minSize,maxSize:t.data.maxSize});m.set(v.id,E),p.set(v.id,I)}const S=(()=>{if(t.data&&t.data.maxLength&&h.length>t.data.maxLength)return d&&d(!0),{info:"0"};const v=o.getWorkflowExperience().getProfanityList(),E=pn.split(h.toLowerCase());for(const I of E)for(const N in v){const R=v[N].toLowerCase().replace(/\s/g,"");if(I===R)return l(!0),{error:"Blocked profanity."}}return!t.data.vertical&&!t.data.allowNewlines&&(h.includes(`
|
|
1451
1451
|
`)||h.includes("\r"))?(l(!0),{error:"Cannot span multiple lines."}):!t.data.curved&&!Array.from(p.values()).every(N=>N)?(l(!0),{error:"Does not fit."}):(l(!1),{info:(t.data.maxLength-h.length).toString()})})();if(S.error){c(S.error);return}if(c(`${S.info} characters remaining`||""),d)return;o.updateStorage(t.stepName,{text:u}),o.updateMetadata(t.stepName,{text:this.injectReplaceableText(u,t.data)}),(i.defaultCleared||!t.data.deleteDefaultOnFocus)&&u.trim()!==""&&o.setMandatoryFulfilled(t.stepName,!0);const w=[];for(const v of g){const E=t.data.curved?h:(p.get(v.id)||[]).join(`
|
|
1452
|
-
`);w.push(this.generateTextChangeCommandsForRegion(m.get(v.id)||1,t.data,v.id,E))}return new $(w)}}const j=new ol;class sl{}const ll="data:application/octet-stream;base64,AAEAAAAPAIAAAwBwRkZUTYdHeHoAAElcAAAAHEdERUYAJwBUAAAe2AAAAB5HUE9TkNtcVAAAHygAACoyR1NVQrj/uP4AAB74AAAAME9TLzJoWmUcAAABeAAAAGBjbWFwtkIacAAAAxAAAAJWZ2FzcP//AAMAAB7QAAAACGdseWY27KOUAAAGCAAAFcRoZWFkFPal0gAAAPwAAAA2aGhlYQU0Ar0AAAE0AAAAJGhtdHiADw6qAAAB2AAAAThsb2Nh5CzfJAAABWgAAACebWF4cACVAEwAAAFYAAAAIG5hbWXeIPPyAAAbzAAAAiJwb3N0ABeZTwAAHfAAAADdAAEAAAABAAAZ9vREXw889QALA+gAAAAA2ZexNAAAAADZl7E0ADL/yQJ2ArwAAAAIAAIAAAAAAAAAAQAAArz/wwAAAqsAAAAAAnYAAQAAAAAAAAAAAAAAAAAAAE4AAQAAAE4ASQAFAAAAAAACAAAAAQABAAAAQAAAAAAAAAAEAbsBkAAFAAACigK7AAAAjAKKArsAAAHfADEBAg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ANP/dADb/6wA3//MAOP/lADn/8QA6//IAO//eADz/5wA9/+4APv/zAD//8ABA/+IAQf/2AEL/6gBD//YARP/kAEX/zABG/+8AR/+0AEj/uwBJ/64ASv+vAEv/5QAsAAb/+wAH/90ACP/nAAn/4gAK/9MAC//nAAz/3QAN//YADv/eAA//3QAQ/7AAEf/OABL/sAAT//sAFP/dABX/0wAW/9MAMf/iADL/iAAz//YANP/OADX/9gA2//EAN//xADj/0wA5//YAOv/zADv/gAA8//EAPf/7AD7/+wA///YAQP/OAEH/7gBC/84AQ//2AET/2ABF//sARv/2AEf/5wBI/+cASf/TAEr/4gBL/+wALAAG//sAB//2AAj/8QAJ/9gACv/nAAv/3QAM/+IADf/dAA7/4gAP/+IAEP/nABH/5wAS/9gAE//YABT/3QAV/84AFv/sADH/5wAy/78AM//nADT/2AA1/+cANv/nADf/7AA4/90AOf/sADr/7AA7/+cAPP/sAD3/8QA+/+wAP//xAED/4gBB//EAQv/dAEP/5wBE/+IARf/YAEb/5wBH/78ASP/HAEn/sABK/7UAS//dACsABv/xAAf/8QAI/+IACf/dAAr/0wAL/+IADP/iAA3/3QAO/+cAD//dABD/zgAR/9MAEv/EABP/0wAU/84AFv/dADH/4gAy/6EAM//jADT/3QA1/+wANv/sADf/5wA4/90AOf/nADr/8QA7/78APP/xAD3/9gA+/+wAP//nAED/3QBB/+cAQv/nAEP/5wBE/+IARf/OAEb/3QBH/8QASP/JAEn/lwBK/7oAS//YACkABv/sAAf/0wAI/90ACf/OAAr/3QAM/90ADf/EAA7/5wAP/9gAEP/YABH/3QAS/9MAE//YABT/4gAV/90AMf/sADL/wAAz/+8ANP/kADX/6wA2//AAN//2ADj/5AA5//EAOv/uADv/1gA8//QAPf/2AD7/8QA///AAQP/dAEH/7ABD/+gARP/YAEX/1QBG/+wAR/+3AEj/wwBJ/7UASv+wAEv/5gAeAAf/zgAi/+4AI//5ACT/7wAy/9AAM//pADT/sQA1/+sANv/nADf/5gA4/7oAOf/vADr/9wA7/9AA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wA///4AQP/uAEL/9wBD//4ARP/+AEX/+QBG//4AR//uAEj/9wBJ/+4ASv/zAEv//gAYAAb/+wAx//YAMv/rADP//wA0//MANf//ADYAAQA3//8AOP/zADv/6AA8//4APf/+AD4AAQBA/+4AQf//AEL/8wBD//4ARP/4AEX//QBH/+wASP/3AEn/7ABK//EASwABABwABv/2ABf/4QAy/8oAM//9ADT/+QA1//4ANv/7ADf//gA4//MAOf/+ADr//wA7/+EAPP/7AD3//gA+//4AP//+AED/7wBB//4AQv/zAEP//gBE//sARf/7AEb//gBH/+8ASP/5AEn/2gBK//oAS//+AB0ABv/nABf/5wAx/7AAMv/hADP/7gA0/7QANf/rADb/5wA3/+4AOP+sADn/6wA6//kAO/+3ADz/6gA9/+8APv/nAD//5wBA/6wAQf/uAEL/rgBD/+cARP+8AEX/3ABG/9oAR//cAEj/0QBJ/9oASv/RAEv/7wAeAAb/9gAX//cAI//9ADH/vwAy/+4AM//5ADT/2gA1//4ANv/3ADf/+wA4/9oAOf/3ADr/+wA7/+cAPP/7AD3/+QA+//cAP//5AED/1ABB//sAQv/cAEP/9wBE/+8ARf/JAEb/6wBH/8QASP++AEn/5wBK/8EAS//+ABwAF//7ADH/7AAy/+QAM//+ADT/7gA1//4ANgAAADf//QA4//cAOf/7ADr//gA7/+4APP/+AD3//gA+//0AP//7AED/7wBB//4AQv/uAEP//gBE//cARf/7AEb/+QBH/+gASP/vAEn/6wBK/+gAS//+AB4ABv/7ABf/8wAa//4AHf/3ACX/9wAq//4AMf/2ADL/5AAz//0ANP/zADX/+wA2//4AN//+ADj/+QA7/+4APf/+AD7/+wA///4AQP/2AEH/+gBC/+4AQ//7AET/+QBF//sARv/+AEf/8wBI/+8ASf/zAEr/6wBL//4AHQAG//EAJP/3ADH/7AAy/7sAM//sADT/4wA1/+8ANv/vADf/9wA4/+QAOf/qADr/9wA7/98APP/vAD3/9wA+/+sAP//uAED/4wBB/+4AQv/mAEP/7wBE/+IARf/VAEb/7gBH/8MASP/GAEn/uwBK/7oAS//fABwABv/sACT//gAy/54AM//rADT/6gA1//EANv/rADf/9wA4/+MAOf/oADr/9wA7/64APP/sAD3/8QA+/+wAP//sAED/4QBB//MAQv/oAEP/5ABE/9gARf/kAEb/7gBH/9EASP/QAEn/uwBK/8QAS//zADAAF//3ABj//wAZ/+kAGv//ABv//QAc//4AHf/pAB7/+wAf//8AIP/iACH//gAi//8AI//+ACT//wAl/+IAJ//uACj//gAp/+cAKv/hACv/+QAs/8MALf/QAC7/5AAv/8wAMP//ADL/4QAz//4ANP/jADX/9wA3//kAOP/fADn/9wA7/+IAPP/5AD3/+gA+//EAP//6AED/2gBB/+8AQv/aAET/7wBF/9cARv/qAEf/xgBI/7sASf/qAEr/tABL//sAHQAG/+cAF//oACT/+gAy/+IAM//xADT/zAA1/+8ANv/sADf/+gA4/8wAOf/3ADr/8wA7/8kAPP/uAD3/7wA+/+wAP//rAED/yQBB//cAQv/MAEP/+ABE/9QARf/KAEb/2gBH/8EASP/EAEn/4gBK/7cAS//vAB0ABv/xABv/+QAl/+4AMv+8ADP/7wA0/9wANf/zADb/6AA3//cAOP/hADn/5gA6//MAO//aADz/6QA9//MAPv/pAD//6wBA/+MAQf/3AEL/2gBD/+kARP/rAEX/1ABG/+kAR//JAEj/zABJ/7QASv+7AEv/5wAbAAb/9gAy/6YAM//9ADT/0wA1//oANv/+ADf//QA4/9UAOf/3ADr//wA7/7kAPP/6AD3//gA+//sAP//7AED/0ABB//oAQv/XAEP/+QBE/+IARf/zAEb/9wBH/+8ASP/vAEn/6gBK/+cAS//6ABwABv/7ACQAAgAy/9UAM//7ADT/7wA1//cANv/9ADf//wA4/+4AOf/7ADr//wA7/+sAPP/+AD3//gA+//0AP//6AED/7gBB//sAQv/sAEP/+wBE/+8ARf/7AEb//QBH/+8ASP/qAEn/3wBK//gAS//+ABwABv/nABf/lQAy/4IAM//3ADT/wQA1/+kANv/nADf/+gA4/8QAOf/oADr/6wA7/5UAPP/uAD3/+wA+//cAP//vAED/wQB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v/1AA//8QAQ/90AEf/kABL/4gAT/+wAFP/YABX/3QAx//YAMv+5ADP/+AA0/+MANf/3ADb/+AA3//kAOP/iADn/+gA6//0AO//OADz//QA9//4APv/5AD///ABA/+YAQv/jAEP/9wBE/+YARf/vAEb//gBH/+cASP/vAEn/0QBK/+YAS//9ACgAB//2AAj/4gAJ/90ACv/sAAv/4gAM/+gADf/iAA7/9QAP/+gAEP/dABH/4AAS/+YAE//OABT/4gAV/90AJP/7ADH/9gAy/8EAM//vADT/3wA2//QAN//4ADj/4wA5/+kAOv/6ADv/0QA8/+YAPf/zAD7/6QA///EAQP/qAEL/3ABD/+gARP/fAEb/+ABH/7sASP+7AEn/rwBK/68AS//jACcACP/xAAn/7AAK//gADP/2AA7/9wAP//YAEP/xABH/5wAS/+cAE//xABT/7AAV/+UAMf/2ADL/6AAz//kANP/qADX/+wA2//oAN//7ADj/6wA5//cAOv//ADv/4wA8//sAPf/+AD7/+wA///oAQP/sAEH/+gBC/+MAQ//5AET/7wBF/+oARv/7AEf/4wBI/+wASf/jAEr/6gBL//4AJgAH//sACP/7AAn/5wAK//oADP/2AA7/9gAP//YAEP/xABH/8QAS//IAE//xABT/5wAV//EAMv/nADP/+wA0//EANf/9ADb//gA3//4AOP/uADn/+wA6//4AO//oAD0AAAA+//sAP//+AED/7wBB//4AQv/qAEP//wBE//EARf/3AEb/+wBH/+YASP/3AEn/2gBK/+QAS//7ACkAB//2AAj/9gAJ/90ACv/yAAz/8QAO//EAD//wABD/6gAR/+wAEv/mABP/9AAU/+wAFf/rABf/zgAx//YAMv/OADP/7wA0/+oANf/5ADb//gA3//0AOP/oADn/+QA6//0AO//YADz//gA9//8APv/6AD//+QBA/+4AQf/5AEL/4wBD//gARP/qAEX/+QBG//oAR//pAEj/6QBJ/9UASv/rAEv/+gAqAAf/sgAI/8kACf+wAAr/ugAL/7UADP+1AA3/3QAO/+QAD/+6ABD/sgAR/7UAEv+xABP/4gAU/6sAFf+mADH/lwAy/9oAM//jADT/qw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iAAr/7AAL/+cADP/iAA3//wAO//UAD//nABD/7AAR/+IAEv/gABP/7AAU/90AFf/TADH/4gAy/+sAM//+ADT/6AA1//4ANgAEADf//wA4/9wAOf/6ADv/5gA8//8APf//AD///QBA/+MAQf//AEMAAABE/+8ARf/4AEb/+wBH//cASP/rAEn/6QBK/+kAS//9AAIAAQAGAEsAAAAAAAAAAQAAAADUGBYRAAAAANmXsTQAAAAA2ZexNA==",at=n=>zi("http://www.w3.org/2000/svg",n),cl=(n,t)=>{const e=at("rect");return e.setAttribute("height",`${n}`),e.setAttribute("width",`${t}`),e},dl=(n,t,e,a)=>{const r=ye("filter");r.setAttribute("id",a),r.setAttribute("height","200%"),r.setAttribute("width","200%"),r.setAttribute("x","-50%"),r.setAttribute("y","-50%");const i=ye("feOffset");r.appendChild(i),i.setAttribute("result","offOut"),i.setAttribute("in","SourceAlpha"),i.setAttribute("dx",`${n}`),i.setAttribute("dy",`${t}`);const o=ye("feGaussianBlur");r.appendChild(o),o.setAttribute("result","blurOut"),o.setAttribute("in","offOut"),o.setAttribute("stdDeviation",`${e}`);const s=ye("feBlend");return r.appendChild(s),s.setAttribute("in","SourceGraphic"),s.setAttribute("in2","blurOut"),s.setAttribute("mode","normal"),r},ul=n=>{let t=n;return t=t.replace(/feoffset/gi,"feOffset"),t=t.replace(/fegaussianblur/gi,"feGaussianBlur"),t=t.replace(/feblend/gi,"feBlend"),t=t.replace(/lineargradient/gi,"linearGradient"),t=t.replace(/stddeviation/gi,"stdDeviation"),t};function Al(n,t,e,a,r,i){const o=r,s=i,l={x:t[0],y:t[1],width:t[2]-t[0],height:t[3]-t[1]};if(l.width<=0)return;const c=hl(l.height,l.width,e*o,a*s),d=(a-c*l.width)/2-c*l.x,u=(e-c*l.height)/2-c*l.y;n.setAttribute("transform",`translate(${d} ${u}) scale(${c} ${c})`)}function hl(n,t,e,a){const r=e/n,i=a/t;return r>1&&i>1?Math.min(r,i):r>1&&i<1?i:r<1&&i>1?r:Math.min(r,i)}const Sn={m:["x","y"],z:[],l:["x","y"],h:["x"],v:["y"],c:["x1","y1","x2","y2","x","y"],s:["x2","y2","x","y"],q:["x1","y1","x","y"],t:["x","y"],a:["rx","ry","xRotation","largeArc","sweep","x","y"]};class gl{constructor(t){const e=Array.from(t.querySelectorAll("path"));this.paths=e.map(a=>{const r=a.getAttribute("d")||"",i=this.parsePath(r);return{pathElement:a,pathData:i}})}transform(t){for(const e of this.paths)e.pathData=this.runTransformer(e.pathData,t);this.update()}encodePath(t){let e="";const r=i=>{const o=[],s=i.relative?i.type:i.type.toUpperCase();let l=e!==s;const c=Sn[i.type];l&&(o.push(s),e=s);for(const d of c){const u=i[d];let A;switch(typeof u){case"boolean":A=u|0;break;case"number":A=(u*100|0)/100;break;default:throw new Et("Failed to encode path.")}l||o.push(" "),o.push(A),l=!1}return o.join("")};return t.map(r).join("")}parsePath(t){const e=/([mzlhvcsqta])([^mzlhvcsqta]*)/gi,a=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi,r=[];let i;for(e.lastIndex=0;i=e.exec(t);){const o=i[1].toLowerCase(),s=(i[2].match(a)||[]).map(parseFloat),l=o===i[1],c=Sn[o];if(s.length<c.length)throw new Et(`Path type "${o}" given ${s.length} arguments, expected ${c.length}.`);if(c.length>0){if(s.length%c.length!==0)throw new Et(`Path type "${o}" given ${s.length} arguments, not divisible by ${c.length}`);for(let d=0;d<s.length/c.length;d++){const u={type:o,relative:l};for(let A=0;A<c.length;A++)u[c[A]]=s[d*c.length+A];r.push(u)}}else r.push({type:o,relative:l})}return r}runTransformer(t,e){const a=[["x1","y1"],["x2","y2"],["x","y"]],r=i=>{for(let o=0;o<a.length;o++){const[s,l]=a[o];if(s in i&&l in i){const c=[i[s],i[l]],d=e(c);if(d.length<2)throw new Et("Transformer must return at least 2 points.");i[s]=d[0],i[l]=d[1]}}return i};return this.transformPath(t,r)}transformPath(t,e){const a=[];for(let r=0;r<t.length;r++){const i=JSON.parse(JSON.stringify(t[r])),o=e(i);Array.isArray(o)?a.push(...o):o&&a.push(o)}return a}update(){for(const{pathElement:t,pathData:e}of this.paths){const a=this.encodePath(e);t.setAttribute("d",a)}}}class ml extends sl{constructor(){super(...arguments),this.moduleName="Vegemite"}svgPreview(t,e){return this.svgElement(t,e)}svgPrint(t,e){return this.svgElement(t,e)}svgElement(t,e){const a=Is(ll),i=t!==""?(w=>w.charAt(0).toUpperCase()+w.substr(1).toLowerCase())(t):"",o=a.getPath(i,0,72,72),s=o.toSVG(2),l=o.getBoundingBox(),c=l.x2-l.x1,d=o.toPathData(3),u=()=>{const w=at("g");w.classList.add("module-text-group");const x=at("defs");w.appendChild(x),x.appendChild(dl(0,2,2,"shadow"));const v=at("path");v.setAttribute("d",d),v.setAttribute("stroke","black"),v.setAttribute("stroke-width","3"),x.appendChild(v);const E=at("g");E.classList.add("module-layer0"),w.appendChild(E),E.setAttribute("filter","url(#shadow)"),E.innerHTML=v.outerHTML;const I=at("g");I.classList.add("module-layer1"),w.appendChild(I),I.setAttribute("stroke-width","3"),I.setAttribute("stroke","rgb(45,41,38)"),I.setAttribute("fill","rgb(45,41,38)"),I.setAttribute("transform","translate(0.5,0)"),I.innerHTML=s;const N=at("g");N.classList.add("module-layer2"),w.appendChild(N),N.setAttribute("fill","rgb(255,209,0)"),N.setAttribute("transform","translate(1,-0.1)"),N.innerHTML=s;const R=at("g");return R.classList.add("module-layer3"),w.appendChild(R),R.setAttribute("fill","white"),R.innerHTML=s,new gl(w).transform(([T,V])=>[T,V+(c/2-T)**2/(c*6)]),w},A=at("g");A.classList.add("module-root");const h=at("defs");A.appendChild(h);const g=at("g");g.classList.add("module-bounds"),A.appendChild(g);const m=cl(e.height,e.width);m.setAttribute("opacity","0"),g.appendChild(m);const p=at("g");p.classList.add("module-text-enclosure"),A.appendChild(p);const f=u();p.appendChild(f);const S=ki(d);return Al(p,S,e.height,e.width,.35,.65),ul(A.outerHTML)}}async function Dr(n){if(n==="Vegemite")return new ml;throw new Q(`Failed to resolve Module, Module ${n} not found`)}const pl=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],fl=async(n,t,e)=>{const a=t.data,r=e.data.baseUrl,i=a.assetUrl.replace("localhost","localstack"),o=r.slice(0,4)==="http"?"":"https://",s=new URL(o+r);s.searchParams.append("video",hn(JSON.stringify([{href:i}]))),s.pathname=s.pathname+(s.pathname.slice(-1)==="/"?"":"/");const l=s.toString(),d=`data:image/svg+xml;base64,${hn(await Rn.toString(l,{type:"svg"}))}`,u=h=>{const g=n.find(p=>p.panelId===h.panelId);if(!g)throw new J(h);const m=M();return new G({id:m,src:d,type:F.Image,y:h.top,x:h.left,width:h.width,height:h.height,rotation:0},g)},A=e.data.regions;try{return A.map(u)}catch(h){return console.error(h),[]}},Cl=async(n,t,e,a)=>{const r=e.data,i=r.assetUrl,o=await ba(i);try{const s=Os(r,a.option);s&&(t[a.stepName]={selectedVariants:[s]});const l=async c=>{const d=await Sr(c,s?.asset?.fileLink),u=await me(d),A=M(),h=n.find(m=>m.panelId===c.panelId);if(!h)throw new J(c);const g=qa(o,u,{scale:r.scale,left:r.x,top:r.y},a.data.forceImageCover);return[new G({id:A,path:u.path,type:F.Frame,forceImageCover:a.data.forceImageCover,x:c.left,y:c.top,width:c.width,height:c.height,layer:c.layer,layerIndex:c.layerIndex,rotation:c.rotation,scaleX:c.width/u.width,scaleY:c.height/u.height,pattern:{id:`${A}-pattern`,src:o.src,x:g.x,y:g.y,width:o.width,height:o.height,rotation:0,scaleX:g.zoom,scaleY:g.zoom,svg:o.svg,colors:o.colors}},h)]};return(await Promise.all(a.data.regions.map(c=>l(c)))).flat()}catch(s){return console.error(s),[]}},wl=async(n,t,e,a)=>{const r=e.data,i=a.option;if(!i)return console.error(`No option for step ${a.stepName}.`),[];const o=i.variants?.find(v=>v.id===r.illustrationVariantId)||ge(i);if(!o)return console.error(`No variant with ID: ${r.illustrationVariantId}`),[];if(!o.asset)return console.error(`No asset for variant with ID: ${r.illustrationVariantId}`),[];t[a.stepName]={selectedVariants:[o]};const s=o.asset?.fileLink;if(!s)return console.error(`No asset link for variant with ID: ${r.illustrationVariantId}`),[];const l=await et(s,!0),c=/<svg.*?<\/svg>/s,d=l.match(c)||[],u=d?.length>0?d[0]:"",g=lt().parseFromString(u,"image/svg+xml").firstElementChild;if(!g)return console.error("Failed to read SVG."),[];Ge(g);const m={};Ot(g,v=>{pl.includes(v.tagName)&&!v.attributes.getNamedItem("fill")&&v.setAttribute("fill","#000000");const E=v.attributes.getNamedItem("fill");if(E&&E.value!=="none"){const N=E.value,P=`spiff-fill-${N.replace(/\W/g,"")}`;v.classList.add(P),m[P]={browserValue:N}}const I=v.attributes.getNamedItem("stroke");if(I&&I.value!=="none"){const N=I.value,P=`spiff-stroke-${N.replace(/\W/g,"")}`;v.classList.add(P),m[P]={browserValue:N}}});const f=St().serializeToString(g),S=r.colors;if(S){for(const[v,E]of Object.entries(m))for(const I of Object.keys(S))if(E.browserValue===I){m[v]={browserValue:S[I]};break}}const w=v=>{const E=n.find(N=>N.panelId===v.panelId);if(!E)throw new J(v);const I=M();return new G({colors:m,id:I,svg:f,type:F.Illustration,y:v.top,x:v.left,rotation:v.rotation,width:v.width,height:v.height,layer:v.layer,layerIndex:v.layerIndex,immutable:v.immutable},E)},x=a.data.regions;try{return x.map(w)}catch(v){return console.error(v),[]}},yl=async(n,t,e)=>{const a=await Dr(e.data.module),r=t.data,i=(s,l)=>{const c=n.find(u=>u.panelId===l.panelId);if(!c)throw new J(l);const d=M();return new G({colors:{},id:d,svg:s,type:F.Illustration,y:l.top,x:l.left,rotation:l.rotation,width:l.width,height:l.height,layer:l.layer,layerIndex:l.layerIndex},c)},o=e.data.regions;try{return o.map(s=>i(a.svgPrint(r.text,s),s))}catch(s){return console.error(s),[]}},Sl=async(n,t,e,a)=>{const r=e.data,i=a.option;if(!i)return console.error(`No option for step ${a.stepName}.`),[];const o=i.variants?.find(d=>d.id===r.pictureVariantId)||ge(i);if(!o)return console.error(`No variant with ID: ${r.pictureVariantId}`),[];if(!o.asset)return console.error(`No asset for variant with ID: ${r.pictureVariantId}`),[];t[a.stepName]={selectedVariants:[o]};const s=o.asset?.fileLink;if(!s)return console.error(`No asset link for variant with ID: ${r.pictureVariantId}`),[];const l=d=>{const u=n.find(h=>h.panelId===d.panelId);if(!u)throw new J(d);const A=M();return new G({id:A,src:s,type:F.Image,y:d.top,x:d.left,rotation:d.rotation,width:d.width,height:d.height,layer:d.layer,layerIndex:d.layerIndex,immutable:d.immutable,preserveAspectRatio:"none"},u)},c=a.data.regions;try{return c.map(l)}catch(d){return console.error(d),[]}},vl=async(n,t,e,a)=>{const r=e.data,i=a.option;if(!i)return console.error(`No option for step ${a.stepName}.`),[];const o=i.variants?.find(c=>c.id===r.colorVariantId)||ge(i);if(!o)return console.error(`No variant with ID: ${r.colorVariantId}`),[];t[a.stepName]={selectedVariants:[o]};const s=c=>{const d=n.find(m=>m.panelId===c.panelId);if(!d)throw new J(c);const u=`
|
|
1452
|
+
`);w.push(this.generateTextChangeCommandsForRegion(m.get(v.id)||1,t.data,v.id,E))}return new $(w)}}const j=new sl;class ll{}const cl="data:application/octet-stream;base64,AAEAAAAPAIAAAwBwRkZUTYdHeHoAAElcAAAAHEdERUYAJwBUAAAe2AAAAB5HUE9TkNtcVAAAHygAACoyR1NVQrj/uP4AAB74AAAAME9TLzJoWmUcAAABeAAAAGBjbWFwtkIacAAAAxAAAAJWZ2FzcP//AAMAAB7QAAAACGdseWY27KOUAAAGCAAAFcRoZWFkFPal0gAAAPwAAAA2aGhlYQU0Ar0AAAE0AAAAJGhtdHiADw6qAAAB2AAAAThsb2Nh5CzfJAAABWgAAACebWF4cACVAEwAAAFYAAAAIG5hbWXeIPPyAAAbzAAAAiJwb3N0ABeZTwAAHfAAAADdAAEAAAABAAAZ9vREXw889QALA+gAAAAA2ZexNAAAAADZl7E0ADL/yQJ2ArwAAAAIAAIAAAAAAAAAAQAAArz/wwAAAqsAAAAAAnYAAQAAAAAAAAAAAAAAAAAAA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L/8kADP/dAA3/xwAO/+cAD//dABD/7AAR/+cAEv/iABP/yQAU/9cAFf+/ABb/4gAa/+kAMf/YADL/uwAz/+EANP/dADb/6wA3//MAOP/lADn/8QA6//IAO//eADz/5wA9/+4APv/zAD//8ABA/+IAQf/2AEL/6gBD//YARP/kAEX/zABG/+8AR/+0AEj/uwBJ/64ASv+vAEv/5QAsAAb/+wAH/90ACP/nAAn/4gAK/9MAC//nAAz/3QAN//YADv/eAA//3QAQ/7AAEf/OABL/sAAT//sAFP/dABX/0wAW/9MAMf/iADL/iAAz//YANP/OADX/9gA2//EAN//xADj/0wA5//YAOv/zADv/gAA8//EAPf/7AD7/+wA///YAQP/OAEH/7gBC/84AQ//2AET/2ABF//sARv/2AEf/5wBI/+cASf/TAEr/4gBL/+wALAAG//sAB//2AAj/8QAJ/9gACv/nAAv/3QAM/+IADf/dAA7/4gAP/+IAEP/nABH/5wAS/9gAE//YABT/3QAV/84AFv/sADH/5wAy/78AM//nADT/2AA1/+cANv/nADf/7AA4/90AOf/sADr/7AA7/+cAPP/sAD3/8QA+/+wAP//xAED/4gBB//EAQv/dAEP/5wBE/+IARf/YAEb/5wBH/78ASP/HAEn/sABK/7UAS//dACsABv/xAAf/8QAI/+IACf/dAAr/0wAL/+IADP/iAA3/3QAO/+cAD//dABD/zgAR/9MAEv/EABP/0wAU/84AFv/dADH/4gAy/6EAM//jADT/3QA1/+wANv/sADf/5wA4/90AOf/nADr/8QA7/78APP/xAD3/9gA+/+wAP//nAED/3QBB/+cAQv/nAEP/5wBE/+IARf/OAEb/3QBH/8QASP/JAEn/lwBK/7oAS//YACkABv/sAAf/0wAI/90ACf/OAAr/3QAM/90ADf/EAA7/5wAP/9gAEP/YABH/3QAS/9MAE//YABT/4gAV/90AMf/sADL/wAAz/+8ANP/kADX/6wA2//AAN//2ADj/5AA5//EAOv/uADv/1gA8//QAPf/2AD7/8QA///AAQP/dAEH/7ABD/+gARP/YAEX/1QBG/+wAR/+3AEj/wwBJ/7UASv+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AcAAb/+wAX//MAJf/7ADL/6wAz//4ANP/uADX/+wA2//4AN//+ADj/8wA5//0AOv/+ADv/7gA8//4APf/+AD7/+wA///4AQP/uAEL/9wBD//4ARP/+AEX/+QBG//4AR//uAEj/9wBJ/+4ASv/zAEv//gAYAAb/+wAx//YAMv/rADP//wA0//MANf//ADYAAQA3//8AOP/zADv/6AA8//4APf/+AD4AAQBA/+4AQf//AEL/8wBD//4ARP/4AEX//QBH/+wASP/3AEn/7ABK//EASwABABwABv/2ABf/4QAy/8oAM//9ADT/+QA1//4ANv/7ADf//gA4//MAOf/+ADr//wA7/+EAPP/7AD3//gA+//4AP//+AED/7wBB//4AQv/zAEP//gBE//sARf/7AEb//gBH/+8ASP/5AEn/2gBK//oAS//+AB0ABv/nABf/5wAx/7AAMv/hADP/7gA0/7QANf/rADb/5wA3/+4AOP+sADn/6wA6//kAO/+3ADz/6gA9/+8APv/nAD//5wBA/6wAQf/uAEL/rgBD/+cARP+8AEX/3ABG/9oAR//cAEj/0QBJ/9oASv/RAEv/7wAeAAb/9gAX//cAI//9ADH/vwAy/+4AM//5ADT/2gA1//4ANv/3ADf/+wA4/9oAOf/3ADr/+wA7/+cAPP/7AD3/+QA+//cAP//5AED/1ABB//sAQv/cAEP/9wBE/+8ARf/JAEb/6wBH/8QASP++AEn/5wBK/8EAS//+ABwAF//7ADH/7AAy/+QAM//+ADT/7gA1//4ANgAAADf//QA4//cAOf/7ADr//gA7/+4APP/+AD3//gA+//0AP//7AED/7wBB//4AQv/uAEP//gBE//cARf/7AEb/+QBH/+gASP/vAEn/6wBK/+gAS//+AB4ABv/7ABf/8wAa//4AHf/3ACX/9wAq//4AMf/2ADL/5AAz//0ANP/zADX/+wA2//4AN//+ADj/+QA7/+4APf/+AD7/+wA///4AQP/2AEH/+gBC/+4AQ//7AET/+QBF//sARv/+AEf/8wBI/+8ASf/zAEr/6wBL//4AHQAG//EAJP/3ADH/7AAy/7sAM//sADT/4wA1/+8ANv/vADf/9wA4/+QAOf/qADr/9wA7/98APP/vAD3/9wA+/+sAP//uAED/4wBB/+4AQv/mAEP/7wBE/+IARf/VAEb/7gBH/8MASP/GAEn/uwBK/7oAS//fABwABv/sACT//gAy/54AM//rADT/6gA1//EANv/rADf/9wA4/+MAOf/oADr/9wA7/64APP/sAD3/8QA+/+wAP//sAED/4QBB//MAQv/oAEP/5ABE/9gARf/kAEb/7gBH/9EASP/QAEn/uwBK/8QAS//zADAAF//3ABj//wAZ/+kAGv//ABv//QAc//4AHf/pAB7/+wAf//8AIP/iACH//gAi//8AI//+ACT//wAl/+IAJ//uACj//gAp/+cAKv/hACv/+QAs/8MALf/QAC7/5AAv/8wAMP//ADL/4QAz//4ANP/jADX/9wA3//kAOP/fADn/9wA7/+IAPP/5AD3/+gA+//EAP//6AED/2gBB/+8AQv/aAET/7wBF/9cARv/qAEf/xgBI/7sASf/qAEr/tABL//sAHQAG/+cAF//oACT/+gAy/+IAM//xADT/zAA1/+8ANv/sADf/+gA4/8wAOf/3ADr/8wA7/8kAPP/uAD3/7wA+/+wAP//rAED/yQBB//cAQv/MAEP/+ABE/9QARf/KAEb/2gBH/8EASP/EAEn/4gBK/7cAS//vAB0ABv/xABv/+QAl/+4AMv+8ADP/7wA0/9wANf/zADb/6AA3//cAOP/hADn/5gA6//MAO//aADz/6QA9//MAPv/pAD//6wBA/+MAQf/3AEL/2gBD/+kARP/rAEX/1ABG/+kAR//JAEj/zABJ/7QASv+7AEv/5wAbAAb/9gAy/6YAM//9ADT/0wA1//oANv/+ADf//QA4/9UAOf/3ADr//wA7/7kAPP/6AD3//gA+//sAP//7AED/0ABB//oAQv/XAEP/+QBE/+IARf/zAEb/9wBH/+8ASP/vAEn/6gBK/+cAS//6ABwABv/7ACQAAgAy/9UAM//7ADT/7wA1//cANv/9ADf//wA4/+4AOf/7ADr//wA7/+sAPP/+AD3//gA+//0AP//6AED/7gBB//sAQv/sAEP/+wBE/+8ARf/7AEb//QBH/+8ASP/qAEn/3wBK//gAS//+ABwABv/n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/pAEP/+QBE/+wARgACAEf/6QBI/+8ASf/nAEr/6wBL//sAKQAH//sACP/xAAn/5wAK/+4AC//2AAz/4gAN//sADv/1AA//8QAQ/90AEf/kABL/4gAT/+wAFP/YABX/3QAx//YAMv+5ADP/+AA0/+MANf/3ADb/+AA3//kAOP/iADn/+gA6//0AO//OADz//QA9//4APv/5AD///ABA/+YAQv/jAEP/9wBE/+YARf/vAEb//gBH/+cASP/vAEn/0QBK/+YAS//9ACgAB//2AAj/4gAJ/90ACv/sAAv/4gAM/+gADf/iAA7/9QAP/+gAEP/dABH/4AAS/+YAE//OABT/4gAV/90AJP/7ADH/9gAy/8EAM//vADT/3wA2//QAN//4ADj/4wA5/+kAOv/6ADv/0QA8/+YAPf/zAD7/6QA///EAQP/qAEL/3ABD/+gARP/fAEb/+ABH/7sASP+7AEn/rwBK/68AS//jACcACP/xAAn/7AAK//gADP/2AA7/9wAP//YAEP/xABH/5wAS/+cAE//xABT/7AAV/+UAMf/2ADL/6AAz//kANP/qADX/+wA2//oAN//7ADj/6wA5//cAOv//ADv/4wA8//sAPf/+AD7/+wA///oAQP/sAEH/+gBC/+MAQ//5AET/7wBF/+oARv/7AEf/4wBI/+wASf/jAEr/6gBL//4AJgAH//sACP/7AAn/5wAK//oADP/2AA7/9gAP//YAEP/xABH/8QAS//IAE//xABT/5wAV//EAMv/nADP/+wA0//EANf/9ADb//gA3//4AOP/uADn/+wA6//4AO//oAD0AAAA+//sAP//+AED/7wBB//4AQv/qAEP//wBE//EARf/3AEb/+wBH/+YASP/3AEn/2gBK/+QAS//7ACkAB//2AAj/9gAJ/90ACv/yAAz/8QAO//EAD//wABD/6gAR/+wAEv/mABP/9AAU/+wAFf/rABf/zgAx//YAMv/OADP/7wA0/+oANf/5ADb//gA3//0AOP/oADn/+QA6//0AO//YADz//gA9//8APv/6AD//+QBA/+4AQf/5AEL/4wBD//gARP/qAEX/+QBG//oAR//pAEj/6QBJ/9UASv/rAEv/+gAqAAf/sgAI/8kACf+wAA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7/7AA//+oAQP+6AEH/7ABC/7kAQ//pAET/ygBF/+8ARv/vAEf/6ABI/+kASf/fAEr/5ABL//EAJgAH//YACf/iAAr/7AAL/+cADP/iAA3//wAO//UAD//nABD/7AAR/+IAEv/gABP/7AAU/90AFf/TADH/4gAy/+sAM//+ADT/6AA1//4ANgAEADf//wA4/9wAOf/6ADv/5gA8//8APf//AD///QBA/+MAQf//AEMAAABE/+8ARf/4AEb/+wBH//cASP/rAEn/6QBK/+kAS//9AAIAAQAGAEsAAAAAAAAAAQAAAADUGBYRAAAAANmXsTQAAAAA2ZexNA==",nt=a=>qi("http://www.w3.org/2000/svg",a),dl=(a,t)=>{const e=nt("rect");return e.setAttribute("height",`${a}`),e.setAttribute("width",`${t}`),e},ul=(a,t,e,n)=>{const r=ye("filter");r.setAttribute("id",n),r.setAttribute("height","200%"),r.setAttribute("width","200%"),r.setAttribute("x","-50%"),r.setAttribute("y","-50%");const i=ye("feOffset");r.appendChild(i),i.setAttribute("result","offOut"),i.setAttribute("in","SourceAlpha"),i.setAttribute("dx",`${a}`),i.setAttribute("dy",`${t}`);const o=ye("feGaussianBlur");r.appendChild(o),o.setAttribute("result","blurOut"),o.setAttribute("in","offOut"),o.setAttribute("stdDeviation",`${e}`);const s=ye("feBlend");return r.appendChild(s),s.setAttribute("in","SourceGraphic"),s.setAttribute("in2","blurOut"),s.setAttribute("mode","normal"),r},Al=a=>{let t=a;return t=t.replace(/feoffset/gi,"feOffset"),t=t.replace(/fegaussianblur/gi,"feGaussianBlur"),t=t.replace(/feblend/gi,"feBlend"),t=t.replace(/lineargradient/gi,"linearGradient"),t=t.replace(/stddeviation/gi,"stdDeviation"),t};function hl(a,t,e,n,r,i){const o=r,s=i,l={x:t[0],y:t[1],width:t[2]-t[0],height:t[3]-t[1]};if(l.width<=0)return;const c=gl(l.height,l.width,e*o,n*s),d=(n-c*l.width)/2-c*l.x,u=(e-c*l.height)/2-c*l.y;a.setAttribute("transform",`translate(${d} ${u}) scale(${c} ${c})`)}function gl(a,t,e,n){const r=e/a,i=n/t;return r>1&&i>1?Math.min(r,i):r>1&&i<1?i:r<1&&i>1?r:Math.min(r,i)}const Sa={m:["x","y"],z:[],l:["x","y"],h:["x"],v:["y"],c:["x1","y1","x2","y2","x","y"],s:["x2","y2","x","y"],q:["x1","y1","x","y"],t:["x","y"],a:["rx","ry","xRotation","largeArc","sweep","x","y"]};class ml{constructor(t){const e=Array.from(t.querySelectorAll("path"));this.paths=e.map(n=>{const r=n.getAttribute("d")||"",i=this.parsePath(r);return{pathElement:n,pathData:i}})}transform(t){for(const e of this.paths)e.pathData=this.runTransformer(e.pathData,t);this.update()}encodePath(t){let e="";const r=i=>{const o=[],s=i.relative?i.type:i.type.toUpperCase();let l=e!==s;const c=Sa[i.type];l&&(o.push(s),e=s);for(const d of c){const u=i[d];let A;switch(typeof u){case"boolean":A=u|0;break;case"number":A=(u*100|0)/100;break;default:throw new Et("Failed to encode path.")}l||o.push(" "),o.push(A),l=!1}return o.join("")};return t.map(r).join("")}parsePath(t){const e=/([mzlhvcsqta])([^mzlhvcsqta]*)/gi,n=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi,r=[];let i;for(e.lastIndex=0;i=e.exec(t);){const o=i[1].toLowerCase(),s=(i[2].match(n)||[]).map(parseFloat),l=o===i[1],c=Sa[o];if(s.length<c.length)throw new Et(`Path type "${o}" given ${s.length} arguments, expected ${c.length}.`);if(c.length>0){if(s.length%c.length!==0)throw new Et(`Path type "${o}" given ${s.length} arguments, not divisible by ${c.length}`);for(let d=0;d<s.length/c.length;d++){const u={type:o,relative:l};for(let A=0;A<c.length;A++)u[c[A]]=s[d*c.length+A];r.push(u)}}else r.push({type:o,relative:l})}return r}runTransformer(t,e){const n=[["x1","y1"],["x2","y2"],["x","y"]],r=i=>{for(let o=0;o<n.length;o++){const[s,l]=n[o];if(s in i&&l in i){const c=[i[s],i[l]],d=e(c);if(d.length<2)throw new Et("Transformer must return at least 2 points.");i[s]=d[0],i[l]=d[1]}}return i};return this.transformPath(t,r)}transformPath(t,e){const n=[];for(let r=0;r<t.length;r++){const i=JSON.parse(JSON.stringify(t[r])),o=e(i);Array.isArray(o)?n.push(...o):o&&n.push(o)}return n}update(){for(const{pathElement:t,pathData:e}of this.paths){const n=this.encodePath(e);t.setAttribute("d",n)}}}class pl extends ll{constructor(){super(...arguments),this.moduleName="Vegemite"}svgPreview(t,e){return this.svgElement(t,e)}svgPrint(t,e){return this.svgElement(t,e)}svgElement(t,e){const n=Bs(cl),i=t!==""?(w=>w.charAt(0).toUpperCase()+w.substr(1).toLowerCase())(t):"",o=n.getPath(i,0,72,72),s=o.toSVG(2),l=o.getBoundingBox(),c=l.x2-l.x1,d=o.toPathData(3),u=()=>{const w=nt("g");w.classList.add("module-text-group");const x=nt("defs");w.appendChild(x),x.appendChild(ul(0,2,2,"shadow"));const v=nt("path");v.setAttribute("d",d),v.setAttribute("stroke","black"),v.setAttribute("stroke-width","3"),x.appendChild(v);const E=nt("g");E.classList.add("module-layer0"),w.appendChild(E),E.setAttribute("filter","url(#shadow)"),E.innerHTML=v.outerHTML;const I=nt("g");I.classList.add("module-layer1"),w.appendChild(I),I.setAttribute("stroke-width","3"),I.setAttribute("stroke","rgb(45,41,38)"),I.setAttribute("fill","rgb(45,41,38)"),I.setAttribute("transform","translate(0.5,0)"),I.innerHTML=s;const N=nt("g");N.classList.add("module-layer2"),w.appendChild(N),N.setAttribute("fill","rgb(255,209,0)"),N.setAttribute("transform","translate(1,-0.1)"),N.innerHTML=s;const R=nt("g");return R.classList.add("module-layer3"),w.appendChild(R),R.setAttribute("fill","white"),R.innerHTML=s,new ml(w).transform(([T,V])=>[T,V+(c/2-T)**2/(c*6)]),w},A=nt("g");A.classList.add("module-root");const h=nt("defs");A.appendChild(h);const g=nt("g");g.classList.add("module-bounds"),A.appendChild(g);const m=dl(e.height,e.width);m.setAttribute("opacity","0"),g.appendChild(m);const p=nt("g");p.classList.add("module-text-enclosure"),A.appendChild(p);const f=u();p.appendChild(f);const S=Mi(d);return hl(p,S,e.height,e.width,.35,.65),Al(A.outerHTML)}}async function Dr(a){if(a==="Vegemite")return new pl;throw new Q(`Failed to resolve Module, Module ${a} not found`)}const fl=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],Cl=async(a,t,e)=>{const n=t.data,r=e.data.baseUrl,i=n.assetUrl.replace("localhost","localstack"),o=r.slice(0,4)==="http"?"":"https://",s=new URL(o+r);s.searchParams.append("video",ha(JSON.stringify([{href:i}]))),s.pathname=s.pathname+(s.pathname.slice(-1)==="/"?"":"/");const l=s.toString(),d=`data:image/svg+xml;base64,${ha(await Ra.toString(l,{type:"svg"}))}`,u=h=>{const g=a.find(p=>p.panelId===h.panelId);if(!g)throw new J(h);const m=M();return new G({id:m,src:d,type:F.Image,y:h.top,x:h.left,width:h.width,height:h.height,rotation:0},g)},A=e.data.regions;try{return A.map(u)}catch(h){return console.error(h),[]}},wl=async(a,t,e,n)=>{const r=e.data,i=r.assetUrl,o=await In(i);try{const s=$s(r,n.option);s&&(t[n.stepName]={selectedVariants:[s]});const l=async c=>{const d=await Sr(c,s?.asset?.fileLink),u=await me(d),A=M(),h=a.find(m=>m.panelId===c.panelId);if(!h)throw new J(c);const g=Gn(o,u,{scale:r.scale,left:r.x,top:r.y},n.data.forceImageCover);return[new G({id:A,path:u.path,type:F.Frame,forceImageCover:n.data.forceImageCover,x:c.left,y:c.top,width:c.width,height:c.height,layer:c.layer,layerIndex:c.layerIndex,rotation:c.rotation,scaleX:c.width/u.width,scaleY:c.height/u.height,pattern:{id:`${A}-pattern`,src:o.src,x:g.x,y:g.y,width:o.width,height:o.height,rotation:0,scaleX:g.zoom,scaleY:g.zoom,svg:o.svg,colors:o.colors}},h)]};return(await Promise.all(n.data.regions.map(c=>l(c)))).flat()}catch(s){return console.error(s),[]}},yl=async(a,t,e,n)=>{const r=e.data,i=n.option;if(!i)return console.error(`No option for step ${n.stepName}.`),[];const o=i.variants?.find(v=>v.id===r.illustrationVariantId)||ge(i);if(!o)return console.error(`No variant with ID: ${r.illustrationVariantId}`),[];if(!o.asset)return console.error(`No asset for variant with ID: ${r.illustrationVariantId}`),[];t[n.stepName]={selectedVariants:[o]};const s=o.asset?.fileLink;if(!s)return console.error(`No asset link for variant with ID: ${r.illustrationVariantId}`),[];const l=await et(s,!0),c=/<svg.*?<\/svg>/s,d=l.match(c)||[],u=d?.length>0?d[0]:"",g=lt().parseFromString(u,"image/svg+xml").firstElementChild;if(!g)return console.error("Failed to read SVG."),[];Ge(g);const m={};Ot(g,v=>{fl.includes(v.tagName)&&!v.attributes.getNamedItem("fill")&&v.setAttribute("fill","#000000");const E=v.attributes.getNamedItem("fill");if(E&&E.value!=="none"){const N=E.value,P=`spiff-fill-${N.replace(/\W/g,"")}`;v.classList.add(P),m[P]={browserValue:N}}const I=v.attributes.getNamedItem("stroke");if(I&&I.value!=="none"){const N=I.value,P=`spiff-stroke-${N.replace(/\W/g,"")}`;v.classList.add(P),m[P]={browserValue:N}}});const f=St().serializeToString(g),S=r.colors;if(S){for(const[v,E]of Object.entries(m))for(const I of Object.keys(S))if(E.browserValue===I){m[v]={browserValue:S[I]};break}}const w=v=>{const E=a.find(N=>N.panelId===v.panelId);if(!E)throw new J(v);const I=M();return new G({colors:m,id:I,svg:f,type:F.Illustration,y:v.top,x:v.left,rotation:v.rotation,width:v.width,height:v.height,layer:v.layer,layerIndex:v.layerIndex,immutable:v.immutable},E)},x=n.data.regions;try{return x.map(w)}catch(v){return console.error(v),[]}},Sl=async(a,t,e)=>{const n=await Dr(e.data.module),r=t.data,i=(s,l)=>{const c=a.find(u=>u.panelId===l.panelId);if(!c)throw new J(l);const d=M();return new G({colors:{},id:d,svg:s,type:F.Illustration,y:l.top,x:l.left,rotation:l.rotation,width:l.width,height:l.height,layer:l.layer,layerIndex:l.layerIndex},c)},o=e.data.regions;try{return o.map(s=>i(n.svgPrint(r.text,s),s))}catch(s){return console.error(s),[]}},vl=async(a,t,e,n)=>{const r=e.data,i=n.option;if(!i)return console.error(`No option for step ${n.stepName}.`),[];const o=i.variants?.find(d=>d.id===r.pictureVariantId)||ge(i);if(!o)return console.error(`No variant with ID: ${r.pictureVariantId}`),[];if(!o.asset)return console.error(`No asset for variant with ID: ${r.pictureVariantId}`),[];t[n.stepName]={selectedVariants:[o]};const s=o.asset?.fileLink;if(!s)return console.error(`No asset link for variant with ID: ${r.pictureVariantId}`),[];const l=d=>{const u=a.find(h=>h.panelId===d.panelId);if(!u)throw new J(d);const A=M();return new G({id:A,src:s,type:F.Image,y:d.top,x:d.left,rotation:d.rotation,width:d.width,height:d.height,layer:d.layer,layerIndex:d.layerIndex,immutable:d.immutable,preserveAspectRatio:"none"},u)},c=n.data.regions;try{return c.map(l)}catch(d){return console.error(d),[]}},El=async(a,t,e,n)=>{const r=e.data,i=n.option;if(!i)return console.error(`No option for step ${n.stepName}.`),[];const o=i.variants?.find(c=>c.id===r.colorVariantId)||ge(i);if(!o)return console.error(`No variant with ID: ${r.colorVariantId}`),[];t[n.stepName]={selectedVariants:[o]};const s=c=>{const d=a.find(m=>m.panelId===c.panelId);if(!d)throw new J(c);const u=`
|
|
1453
1453
|
<svg
|
|
1454
1454
|
xmlns="http://www.w3.org/2000/svg"
|
|
1455
1455
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
@@ -1469,8 +1469,8 @@
|
|
|
1469
1469
|
fill="${o?.color}"
|
|
1470
1470
|
/>
|
|
1471
1471
|
</svg>
|
|
1472
|
-
`,h={"spiff-fill-shape":{browserValue:o.color||"#000000"}},g=M();return new G({colors:h,id:g,svg:u,type:F.Illustration,y:c.top,x:c.left,rotation:c.rotation,width:c.width,height:c.height,layer:c.layer,layerIndex:c.layerIndex,immutable:c.immutable},d)},l=
|
|
1473
|
-
`)},f))}else r.push(new G(S,f))}return r},
|
|
1472
|
+
`,h={"spiff-fill-shape":{browserValue:o.color||"#000000"}},g=M();return new G({colors:h,id:g,svg:u,type:F.Illustration,y:c.top,x:c.left,rotation:c.rotation,width:c.width,height:c.height,layer:c.layer,layerIndex:c.layerIndex,immutable:c.immutable},d)},l=n.data.regions;try{return l.map(s)}catch(c){return console.error(c),[]}},bl=async(a,t,e)=>{const n=[],i=t.type===b.ProductOverlay?e||t.data.asset?.fileLink||"":t.data.asset?.fileLink||"",s=i.endsWith(".jpeg")||i.endsWith(".jpg")||i.endsWith(".png")?F.Image:(i.endsWith(".svg"),F.Illustration),l=t.data.regions;if(s==="image")try{l.forEach(c=>{const d=a.find(A=>A.panelId===c.panelId);if(!d)throw new J(c);const u={id:M(),src:i,type:s,y:c.top,x:c.left,width:c.width,height:c.height,layer:c.layer,layerIndex:c.layerIndex,productOverlay:t.type===b.ProductOverlay?!0:void 0,scaleX:1,scaleY:1,rotation:c.rotation,excludeFromExport:t.data.excludeFromPrint,preserveAspectRatio:"none"};n.push(new G(u,d))})}catch(c){console.error(c)}else{const c=await et(i,!0),d=u=>{const A=/<svg.*?<\/svg>/s,h=u.match(A)||[],g=h?.length>0?h[0]:"",f=lt().parseFromString(g,"image/svg+xml").firstElementChild;if(!f)throw new Et("Failed to read SVG.");return Ge(f),St().serializeToString(f)};l.forEach(u=>{const A=a.find(g=>g.panelId===u.panelId);if(!A)throw new J(u);const h={id:M(),src:i,asset_key:i,svg:d(c),colors:{},type:s,y:u.top,x:u.left,width:u.width,height:u.height,layer:u.layer,layerIndex:u.layerIndex,scaleX:1,scaleY:1,rotation:u.rotation,productOverlay:t.type===b.ProductOverlay?!0:void 0,excludeFromExport:t.data.excludeFromPrint};n.push(new G(h,A))})}return n},Il=async(a,t,e,n)=>{const r=[],i=e.data,o=30,s=p=>p.vertical?"center":p.textAlign||"center",l=()=>{const p=n.option;if(!p)return;const f=p.variants?.find(w=>w.id===i.fontVariantId)||ge(p);if(!f||!f.asset)return;t[n.stepName]={selectedVariants:[f]};const S=f.asset.fileLink;if(S)return S},d=await(async()=>{const p=l();if(!p)return;const f=await Pt(p);return{assetUrl:p,name:f.names.fullName.en}})(),u=(n.data.replaceableText?n.data.replaceableText.replace("{{}}",i.text):i.text)||"",A=Me(u,{vertical:n.data.vertical,uppercase:n.data.uppercase}),h=async p=>{const f=p.colorOption;return f?Y.getDefaultVariant(f)?.color:void 0},g=i.color||await h(n.data),m=n.data.regions;for(const p of m){const f=a.find(w=>w.panelId===p.panelId);if(!f)continue;const S={stepName:e.name,id:M(),align:s(n.data),curved:n.data.curved,fill:i.color||g||"#000000",fontData:d,fontSize:n.data.size||o,height:p.height,layer:p.layer,layerIndex:p.layerIndex,paths:n.data.paths,rotation:p.rotation,text:A,type:F.Textbox,vertical:n.data.vertical,verticalAlign:n.data.verticalAlign||"middle",width:p.width,x:p.left,y:p.top};if(d){const[w,x]=Kt(n.data.size||o,d,p,[Me(A,{vertical:n.data.vertical,uppercase:n.data.uppercase})],{size:n.data.size,minSize:n.data.minSize,maxSize:n.data.maxSize});r.push(new G({...S,fontSize:w,text:S.curved?S.text:(x||[]).join(`
|
|
1473
|
+
`)},f))}else r.push(new G(S,f))}return r},Bl=(a,t)=>a.conditions?a.conditions.every(e=>{const n=t[e.targetStepName];if(n&&n.selectedVariants){const r=n.selectedVariants;return e.requiredVariantSelections.some(i=>r.find(o=>o.id===i)!==void 0)}return!1}):!0,kr=async(a,t,e,n)=>{const r=[],i={};for(const o of a){const s=t.steps.find(l=>l.stepName===o.name);if(s)switch(s.type){case b.DigitalContent:r.push(...await Cl(e,o,s));break;case b.Frame:case b.Photo:r.push(...await wl(e,i,o,s));break;case b.Illustration:r.push(...await yl(e,i,o,s));break;case b.Module:r.push(...await Sl(e,o,s));break;case b.Picture:r.push(...await vl(e,i,o,s));break;case b.Shape:r.push(...await El(e,i,o,s));break;case b.Text:r.push(...await Il(e,i,o,s));break}}for(const o of t.steps)o.type!==b.SilentIllustration&&o.type!==b.ProductOverlay||Bl(o,i)&&r.push(...await bl(e,o,n));return r};class Pl{constructor(t){this.handleCompleteRender=null;const e=new Map;t.forEach(n=>e.set(n.id,new Dl(n.id,n.name,this,{width:n.width,height:n.height},this.getWorkflowManager.bind(this)))),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}setWorkflowManager(t){this.workflowManager=t}getWorkflowManager(){return this.workflowManager}}const xl=()=>new Promise((a,t)=>{try{const n=Ct().getContext("webgl2");a(!!n)}catch{a(!1)}}),Fl=xl();class Dl{constructor(t,e,n,r,i){this.hasSetStaticContext=!1,this.interactiveDirty=!1,this.staticCtxDirty=!1,this.lastRequestedRenderArguments=void 0,this.lastCompletedStaticRender=void 0,this.renderQueue=new zn(2),this.id=t,this.name=e,this.service=n,this.panelSize=r,this.getWorkflowManager=i}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=It(t);this.lastRequestedRenderArguments=e;const n=this.getStaticContext();if(!n){this.markLastCompletedStaticRender(),this.setStaticContextDirty(!1);return}this.renderQueue.enqueue(new kl(this.getID(),n,await Fl,()=>{this.markLastCompletedStaticRender(),this.setStaticContextDirty(!0)},e,this.getWorkflowManager))}}class kl extends Vn{constructor(t,e,n,r,i,o){super(),this.layoutId=t,this.ctx=e,this.nonPOTSupport=n,this.onRender=r,this.layouts=i,this.getWorkflowManager=o}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 n=e/t.width,r=e/t.height,i=Math.min(n,r);return i>1?t:{width:t.width*i,height:t.height*i}}async execute(){const t=this.layouts.find(g=>g.layoutState.layout.id===this.layoutId);if(!t)return;const e=t.layoutState.elements||[],n=t.layoutState.layout.width,r=t.layoutState.layout.height,i=n===1||r===1?{width:1,height:1}:this.getDynamicTextureResolution(),o=i.width,s=i.height;let l,c;if(this.nonPOTSupport){const g=o/s;n/r<g?(l=o,c=r*(o/n)):(l=n*(s/r),c=s);const p=this.resizeFit({width:l,height:c});l=p.width,c=p.height}else l=i.width,c=i.height;const d=this.getWorkflowManager?.()?.getTemplatingContext(),u=Ye(t.layoutState.layout,e,{renderingConfiguration:{purpose:Nt.ThreeD,templatingContext:d}}),A=Ya(u),h=await Nn.Pith.from(this.ctx,A,{anonymousCrossOrigin:!0,ignoreDimensions:!this.nonPOTSupport,ignoreAnimation:!0,ignoreClear:!0,ignoreMouse:!0,enableRedraw:!1,createCanvas:Ct,createImage:ce,DOMParser:$n(),fetch});h.resize(l,c),await h.render(),this.onRender()}}const Ml=(a,t)=>{const e=[];return a.forEach(n=>{const r=t.steps.find(i=>i.stepName===n.stepName);r?.type===b.Text&&n.stepAspectType==="Text"&&e.push({name:r.stepName,data:{text:n.value}})}),e},Tl=async(a,t,e,n)=>{let r={serializableWorkflow:{steps:[]},layouts:{}};r=new $(e.map(l=>new Hn(l))).apply(r);const o=await kr(a,t,e,n);return new $(o).apply(r)},Je=C.gql`
|
|
1474
1474
|
fragment GlobalPropertyStateAspectFields on GlobalPropertyStateAspect {
|
|
1475
1475
|
name
|
|
1476
1476
|
value
|
|
@@ -1492,7 +1492,7 @@
|
|
|
1492
1492
|
}
|
|
1493
1493
|
}
|
|
1494
1494
|
}
|
|
1495
|
-
`,
|
|
1495
|
+
`,Nl=C.gql`
|
|
1496
1496
|
${Je}
|
|
1497
1497
|
mutation CreateGlobalPropertyState($bundleId: String!) {
|
|
1498
1498
|
globalPropertyStateCreate(bundleId: $bundleId) {
|
|
@@ -1502,7 +1502,7 @@
|
|
|
1502
1502
|
}
|
|
1503
1503
|
}
|
|
1504
1504
|
}
|
|
1505
|
-
`,
|
|
1505
|
+
`,Ql=C.gql`
|
|
1506
1506
|
${Je}
|
|
1507
1507
|
mutation UpdateGlobalPropertyState($id: String!, $aspects: [GlobalPropertyStateAspectInput]!) {
|
|
1508
1508
|
globalPropertyStateUpdate(id: $id, aspects: $aspects) {
|
|
@@ -1512,7 +1512,7 @@
|
|
|
1512
1512
|
}
|
|
1513
1513
|
}
|
|
1514
1514
|
}
|
|
1515
|
-
`,
|
|
1515
|
+
`,Rl=C.gql`
|
|
1516
1516
|
${Je}
|
|
1517
1517
|
query GetGlobalPropertyState($bundleId: String!) {
|
|
1518
1518
|
globalPropertyState(bundleId: $bundleId) {
|
|
@@ -1522,7 +1522,7 @@
|
|
|
1522
1522
|
}
|
|
1523
1523
|
}
|
|
1524
1524
|
}
|
|
1525
|
-
`,
|
|
1525
|
+
`,Ol=async a=>(await y.getShadowGraphqlClient().query({query:Rl,fetchPolicy:"cache-first",errorPolicy:"all",variables:{bundleId:a}})).data.globalPropertyState,$l=a=>C.gql`
|
|
1526
1526
|
${We}
|
|
1527
1527
|
fragment ProductFields on Product {
|
|
1528
1528
|
id
|
|
@@ -1554,7 +1554,7 @@
|
|
|
1554
1554
|
preloadImageUrl
|
|
1555
1555
|
sku
|
|
1556
1556
|
skuCode
|
|
1557
|
-
workflows${
|
|
1557
|
+
workflows${a?"(filters: $productWorkflowFilters)":""} {
|
|
1558
1558
|
id
|
|
1559
1559
|
index
|
|
1560
1560
|
friendlyName
|
|
@@ -1567,8 +1567,8 @@
|
|
|
1567
1567
|
name
|
|
1568
1568
|
}
|
|
1569
1569
|
}
|
|
1570
|
-
`,
|
|
1571
|
-
${
|
|
1570
|
+
`,ta=a=>C.gql`
|
|
1571
|
+
${$l(a)}
|
|
1572
1572
|
fragment ProductCollectionProductFields on ProductCollectionProduct {
|
|
1573
1573
|
id
|
|
1574
1574
|
productId
|
|
@@ -1577,8 +1577,8 @@
|
|
|
1577
1577
|
...ProductFields
|
|
1578
1578
|
}
|
|
1579
1579
|
}
|
|
1580
|
-
`,Ke=(
|
|
1581
|
-
${
|
|
1580
|
+
`,Ke=(a,t=!1)=>C.gql`
|
|
1581
|
+
${a?ta(t):""}
|
|
1582
1582
|
fragment ProductCollectionFields on ProductCollection {
|
|
1583
1583
|
id
|
|
1584
1584
|
name
|
|
@@ -1623,7 +1623,7 @@
|
|
|
1623
1623
|
}
|
|
1624
1624
|
}
|
|
1625
1625
|
}
|
|
1626
|
-
${
|
|
1626
|
+
${a?"productCollectionProducts { ...ProductCollectionProductFields }":""}
|
|
1627
1627
|
transformCollection {
|
|
1628
1628
|
id
|
|
1629
1629
|
name
|
|
@@ -1669,9 +1669,9 @@
|
|
|
1669
1669
|
workflowViewerLink
|
|
1670
1670
|
workflowViewerAmendLink
|
|
1671
1671
|
}
|
|
1672
|
-
|
|
1672
|
+
`,Ul=a=>C.gql`
|
|
1673
1673
|
${Je}
|
|
1674
|
-
${Ke(
|
|
1674
|
+
${Ke(a)}
|
|
1675
1675
|
${Mr}
|
|
1676
1676
|
query GetBundle($id: String!) {
|
|
1677
1677
|
globalPropertyState(bundleId: $id) {
|
|
@@ -1704,7 +1704,7 @@
|
|
|
1704
1704
|
}
|
|
1705
1705
|
}
|
|
1706
1706
|
}
|
|
1707
|
-
`,
|
|
1707
|
+
`,va=C.gql`
|
|
1708
1708
|
query GetBundleStakeholders($id: String!) {
|
|
1709
1709
|
bundles(ids: [$id]) {
|
|
1710
1710
|
id
|
|
@@ -1749,7 +1749,7 @@
|
|
|
1749
1749
|
}
|
|
1750
1750
|
}
|
|
1751
1751
|
}
|
|
1752
|
-
`,
|
|
1752
|
+
`,Ll=C.gql`
|
|
1753
1753
|
query GetBundlesForCustomer($id: String!) {
|
|
1754
1754
|
customers(ids: [$id]) {
|
|
1755
1755
|
bundleStakeholders {
|
|
@@ -1778,8 +1778,8 @@
|
|
|
1778
1778
|
}
|
|
1779
1779
|
}
|
|
1780
1780
|
}
|
|
1781
|
-
`,
|
|
1782
|
-
${
|
|
1781
|
+
`,Vl=C.gql`
|
|
1782
|
+
${ta(!1)}
|
|
1783
1783
|
query GetProductCollectionProducts($id: String!, $productIds: [String!]) {
|
|
1784
1784
|
productCollections(ids: [$id], productIds: $productIds) {
|
|
1785
1785
|
id
|
|
@@ -1788,7 +1788,7 @@
|
|
|
1788
1788
|
}
|
|
1789
1789
|
}
|
|
1790
1790
|
}
|
|
1791
|
-
`,
|
|
1791
|
+
`,zl=C.gql`
|
|
1792
1792
|
query GetProductCollectionForFilteredProducts(
|
|
1793
1793
|
$id: String!
|
|
1794
1794
|
$filters: ProductCollectionProductFilterInput
|
|
@@ -1811,8 +1811,8 @@
|
|
|
1811
1811
|
}
|
|
1812
1812
|
}
|
|
1813
1813
|
}
|
|
1814
|
-
`,
|
|
1815
|
-
${
|
|
1814
|
+
`,ql=C.gql`
|
|
1815
|
+
${ta(!0)}
|
|
1816
1816
|
query GetProductCollectionForProductsFeed(
|
|
1817
1817
|
$id: String!
|
|
1818
1818
|
$limit: Int
|
|
@@ -1843,8 +1843,8 @@
|
|
|
1843
1843
|
}
|
|
1844
1844
|
}
|
|
1845
1845
|
}
|
|
1846
|
-
`,
|
|
1847
|
-
${Ke(
|
|
1846
|
+
`,Gl=a=>C.gql`
|
|
1847
|
+
${Ke(a)}
|
|
1848
1848
|
mutation CreateBundle(
|
|
1849
1849
|
$collectionId: String
|
|
1850
1850
|
$initialMetadata: [MetadataInput!]
|
|
@@ -1872,7 +1872,7 @@
|
|
|
1872
1872
|
}
|
|
1873
1873
|
}
|
|
1874
1874
|
}
|
|
1875
|
-
`,
|
|
1875
|
+
`,jl=()=>C.gql`
|
|
1876
1876
|
mutation DuplicateBundle(
|
|
1877
1877
|
$id: String!
|
|
1878
1878
|
$template: Boolean
|
|
@@ -1894,7 +1894,7 @@
|
|
|
1894
1894
|
}
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
|
-
`,
|
|
1897
|
+
`,An=C.gql`
|
|
1898
1898
|
mutation UpdateBundle(
|
|
1899
1899
|
$id: String!
|
|
1900
1900
|
$name: String
|
|
@@ -1914,19 +1914,19 @@
|
|
|
1914
1914
|
id
|
|
1915
1915
|
}
|
|
1916
1916
|
}
|
|
1917
|
-
`,
|
|
1917
|
+
`,Wl=C.gql`
|
|
1918
1918
|
mutation BundleAddTransaction($id: String!, $transactionId: String!) {
|
|
1919
1919
|
bundleAddTransaction(id: $id, transactionId: $transactionId) {
|
|
1920
1920
|
id
|
|
1921
1921
|
}
|
|
1922
1922
|
}
|
|
1923
|
-
`,
|
|
1923
|
+
`,Hl=C.gql`
|
|
1924
1924
|
mutation BundleAddTransactions($id: String!, $transactionIds: [String!]!, $transactionOwnerIds: [String!]) {
|
|
1925
1925
|
bundleAddTransactions(id: $id, transactionIds: $transactionIds, transactionOwnerIds: $transactionOwnerIds) {
|
|
1926
1926
|
id
|
|
1927
1927
|
}
|
|
1928
1928
|
}
|
|
1929
|
-
`,
|
|
1929
|
+
`,Yl=C.gql`
|
|
1930
1930
|
mutation BundleRemoveTransaction(
|
|
1931
1931
|
$id: String!
|
|
1932
1932
|
$transactionId: String!
|
|
@@ -1941,7 +1941,7 @@
|
|
|
1941
1941
|
id
|
|
1942
1942
|
}
|
|
1943
1943
|
}
|
|
1944
|
-
`,
|
|
1944
|
+
`,Jl=C.gql`
|
|
1945
1945
|
mutation BundleRemoveTransactions(
|
|
1946
1946
|
$id: String!
|
|
1947
1947
|
$transactionIds: [String!]!
|
|
@@ -1956,7 +1956,7 @@
|
|
|
1956
1956
|
id
|
|
1957
1957
|
}
|
|
1958
1958
|
}
|
|
1959
|
-
`,
|
|
1959
|
+
`,Kl=C.gql`
|
|
1960
1960
|
mutation BundleAddStakeholder($id: String!, $details: CustomerDetailsInput!, $type: String!) {
|
|
1961
1961
|
bundleAddStakeholder(id: $id, details: $details, type: $type) {
|
|
1962
1962
|
id
|
|
@@ -1976,13 +1976,13 @@
|
|
|
1976
1976
|
}
|
|
1977
1977
|
}
|
|
1978
1978
|
}
|
|
1979
|
-
`,
|
|
1979
|
+
`,_l=C.gql`
|
|
1980
1980
|
mutation BundleAddStakeholder($id: String!, $emailAddress: String!) {
|
|
1981
1981
|
bundleRemoveStakeholder(id: $id, emailAddress: $emailAddress) {
|
|
1982
1982
|
id
|
|
1983
1983
|
}
|
|
1984
1984
|
}
|
|
1985
|
-
`,
|
|
1985
|
+
`,Xl=C.gql`
|
|
1986
1986
|
mutation BundleUpdateStakeholders($id: String!, $input: [BundleStakeholderInput!]!) {
|
|
1987
1987
|
bundleUpdateStakeholders(id: $id, input: $input) {
|
|
1988
1988
|
id
|
|
@@ -2002,14 +2002,14 @@
|
|
|
2002
2002
|
}
|
|
2003
2003
|
}
|
|
2004
2004
|
}
|
|
2005
|
-
`,
|
|
2005
|
+
`,Zl=C.gql`
|
|
2006
2006
|
mutation BundleUpdateTransactionOrder($id: String!, $transactionIds: [String!]!) {
|
|
2007
2007
|
bundleUpdateTransactionOrder(id: $id, transactionIds: $transactionIds) {
|
|
2008
2008
|
id
|
|
2009
2009
|
}
|
|
2010
2010
|
}
|
|
2011
|
-
`,
|
|
2012
|
-
${Ke(
|
|
2011
|
+
`,tc=a=>C.gql`
|
|
2012
|
+
${Ke(a)}
|
|
2013
2013
|
mutation BundleAssignProductCollection($id: String!, $productCollectionId: String!) {
|
|
2014
2014
|
bundleAssignProductCollection(id: $id, collectionId: $productCollectionId) {
|
|
2015
2015
|
id
|
|
@@ -2018,13 +2018,13 @@
|
|
|
2018
2018
|
}
|
|
2019
2019
|
}
|
|
2020
2020
|
}
|
|
2021
|
-
`,
|
|
2021
|
+
`,ec=C.gql`
|
|
2022
2022
|
mutation AssignGlobalPropertyConfiguration($bundleId: String!, $globalPropertyConfigurationId: String!) {
|
|
2023
2023
|
bundleUpdate(id: $bundleId, globalPropertyConfigurationId: $globalPropertyConfigurationId) {
|
|
2024
2024
|
id
|
|
2025
2025
|
}
|
|
2026
2026
|
}
|
|
2027
|
-
`,
|
|
2027
|
+
`,nc=a=>C.gql`
|
|
2028
2028
|
${Mr}
|
|
2029
2029
|
query CustomerBundlesFeed($id: String!, $limit: Int!, $offset: Int!, $template: Boolean, $templateStatus: BundleTemplateStatus, $ordered: Boolean) {
|
|
2030
2030
|
customerBundlesFeed(id: $id, limit: $limit, offset: $offset, template: $template, templateStatus: $templateStatus, ordered: $ordered) {
|
|
@@ -2045,7 +2045,7 @@
|
|
|
2045
2045
|
id
|
|
2046
2046
|
}
|
|
2047
2047
|
}
|
|
2048
|
-
${
|
|
2048
|
+
${a?"metadata { key, value }":""}
|
|
2049
2049
|
}
|
|
2050
2050
|
total
|
|
2051
2051
|
}
|
|
@@ -2054,23 +2054,23 @@
|
|
|
2054
2054
|
mutation FinalizeUpdateBundle($bundleId: String!) {
|
|
2055
2055
|
bundleFinalizeUpdate(bundleId: $bundleId)
|
|
2056
2056
|
}
|
|
2057
|
-
`,
|
|
2057
|
+
`,rc=C.gql`
|
|
2058
2058
|
mutation ApproveBundle($id: String!, $note: String, $stakeholderId: String) {
|
|
2059
2059
|
bundleApprove(id: $id, note: $note, stakeholderId: $stakeholderId)
|
|
2060
2060
|
}
|
|
2061
|
-
`,
|
|
2061
|
+
`,ic=C.gql`
|
|
2062
2062
|
mutation RejectBundle($id: String!, $note: String, $stakeholderId: String) {
|
|
2063
2063
|
bundleReject(id: $id, note: $note, stakeholderId: $stakeholderId)
|
|
2064
2064
|
}
|
|
2065
|
-
`,
|
|
2065
|
+
`,oc=C.gql`
|
|
2066
2066
|
mutation ApproveTransaction($id: String!, $note: String) {
|
|
2067
2067
|
transactionApprove(id: $id, note: $note)
|
|
2068
2068
|
}
|
|
2069
|
-
`,
|
|
2069
|
+
`,sc=C.gql`
|
|
2070
2070
|
mutation RejectTransaction($id: String!, $note: String) {
|
|
2071
2071
|
transactionReject(id: $id, note: $note)
|
|
2072
2072
|
}
|
|
2073
|
-
`,
|
|
2073
|
+
`,lc=C.gql`
|
|
2074
2074
|
mutation CreateRecipient(
|
|
2075
2075
|
$firstName: String
|
|
2076
2076
|
$lastName: String
|
|
@@ -2112,7 +2112,7 @@
|
|
|
2112
2112
|
id
|
|
2113
2113
|
}
|
|
2114
2114
|
}
|
|
2115
|
-
`,
|
|
2115
|
+
`,cc=C.gql`
|
|
2116
2116
|
mutation UpdateRecipient(
|
|
2117
2117
|
$id: String!
|
|
2118
2118
|
$firstName: String
|
|
@@ -2158,17 +2158,26 @@
|
|
|
2158
2158
|
id
|
|
2159
2159
|
}
|
|
2160
2160
|
}
|
|
2161
|
-
`,
|
|
2161
|
+
`,dc=C.gql`
|
|
2162
2162
|
mutation AtttachRecipient($id: String!, $recipientId: String!) {
|
|
2163
2163
|
transactionAttachRecipient(id: $id, recipientId: $recipientId) {
|
|
2164
2164
|
id
|
|
2165
2165
|
}
|
|
2166
2166
|
}
|
|
2167
|
-
`,
|
|
2167
|
+
`,uc=C.gql`
|
|
2168
2168
|
mutation DeleteBundle($id: String!) {
|
|
2169
2169
|
bundleDelete(id: $id)
|
|
2170
2170
|
}
|
|
2171
|
-
`;var pe=(n=>(n.Error="Error",n.Warning="Warning",n.Info="Info",n))(pe||{});const uc=1e3;class En extends La{constructor(t){super(),this.createdAt=new Date,this.update=t}async execute(){await this.update(),await new Promise(t=>{window.setTimeout(()=>{t()},uc)})}}const Ac=n=>n.sort((t,e)=>t.index-e.index).map(t=>({id:M(),panelId:t.name,name:t.name,title:t.title,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})),hc=(n,t)=>{const e=n.workflowState,a=e?JSON.parse(e):void 0;return a?Object.values(a.layouts).map(r=>r.layout):Ac(t.panels)},Xt=class Xt{constructor(t,e,a,r,i,o=!1,s,l=!1,c=!1,d=!1){this.workflowStatePromiseQueue=new Va(1),this.initialized=!1,this.readOnly=!1,this.isReloadedTransaction=!1,this.singleVariantsRenderable=!1,this.stepTags={},this.setWorkflow=async A=>{this.confirmedDesign=!1,this.editedSteps={},this.informationResults=[],this.mandatorySteps={},this.pendingUpdates=[],this.selectionCost=0,this.stepSpecificServices={},this.pollers=[],this.allScenes=[],this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},this.validationErrors={steps:new Map},this.currentAdjustingStepId="",this.reloadedState?this.layouts=Object.values(this.reloadedState.layouts||{}).map(g=>g.layout):A?this.layouts=hc(this.experience.getTransaction(),A):this.layouts=[],this.commandContext.initialize(this.layouts,this.reloadedState),this.renderableContextService=new Bl(this.layouts),this.renderableContextService.setWorkflowManager(this),A.steps.forEach(g=>{this.stepTags[g.stepName]=g.tags??[]});const h=this.previewService;this.ejectFromPreviewService(),this.initializationPromise=this.initializeDefaultWorkflowState(A),this.initializationPromise.then(()=>{this.initialized=!0}),this.initializationPromise.catch(g=>{throw console.error(g),this.initialized=!1,new Error("Workflow initialization failed due to an error. See console.")}),this.initializationPromise.finally(()=>this.commandContext.registerStateCallback(()=>{this.updateStateWithServer(),this.renderLayouts()})),h&&await this.injectIntoPreviewService(h,!0)},this.renderLayouts=()=>{if(!this.previewService)return;const A=this.getCommandContext().getAllLayouts(),h=this.getLayoutPreviewService()?.getAll();if(h)for(const[,g]of h)g.render(A)},this.sortKeysReplacer=(A,h)=>h&&typeof h=="object"&&!Array.isArray(h)?Object.keys(h).sort().reduce((g,m)=>(g[m]=h[m],g),{}):h,this.experience=t,this.client=e,this.updateTransaction=a,this.graphQlClient=r,this.reloadedState=i,this.readOnly=o,this.singleVariantsRenderable=c,this.commandContext=new wr,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.recipientCallbacks=[],this.modelContainer=s,this.confirmedDesign=!1,this.editedSteps={},this.informationResults=[],this.mandatorySteps={},this.pendingUpdates=[],this.selectionCost=0,this.stepSpecificServices={},this.pollers=[],this.allScenes=[],this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},this.validationErrors={steps:new Map},this.currentAdjustingStepId="",this.isReloadedTransaction=l,d&&(this.workflowStatePromiseQueue.enabled=!1);const u=this.experience.getWorkflow();u&&this.setWorkflow(u)}getTemplatingContext(){const t=this.experience.getTransaction().recipient,e={recipient:t};return this.recipientConversionConfiguration?.requestedDataItems?.forEach(a=>{const r=a.uniqueIdentifier??a.title??"";a.type===_t.FirstName?e[r]=t?.firstName:a.type===_t.LastName?e[r]=t?.lastName:a.type===_t.Custom&&(a.customFieldIndex===1?e[r]=t?.customField1:a.customFieldIndex===2?e[r]=t?.customField2:a.customFieldIndex===3?e[r]=t?.customField3:a.customFieldIndex===4?e[r]=t?.customField4:a.customFieldIndex===5&&(e[r]=t?.customField5),a.option&&(e[r]=a.option.variants?.find(i=>i.id===e[r])?.name))}),e}async updateRecipient(t,e,a,r,i,o,s,l,c,d,u,A,h,g,m,p,f,S){const w=this.experience.getTransaction();if(w.recipient?.id)this.experience.getTransaction().recipient={id:w.recipient.id,firstName:t??w.recipient.firstName,lastName:e??w.recipient.lastName,address:a??w.recipient.address,suburb:r??w.recipient.suburb,state:i??w.recipient.state,email:o??w.recipient.email,postalCode:s??w.recipient.postalCode,country:l??w.recipient.country,mobile:c??w.recipient.mobile,company:d??w.recipient.company,apartment:u??w.recipient.apartment,customField1:A??w.recipient.customField1,customField2:h??w.recipient.customField2,customField3:g??w.recipient.customField3,customField4:m??w.recipient.customField4,customField5:p??w.recipient.customField5,conversionConfigurationId:f||w.recipient.conversionConfigurationId},this.experience.callEvent(Oe.RecipientChanged),await this.graphQlClient().mutate({mutation:lc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:w.recipient.id,firstName:t||w.recipient.firstName,lastName:e||w.recipient.lastName,address:a||w.recipient.address,suburb:r||w.recipient.suburb,state:i||w.recipient.state,email:o||w.recipient.email,postalCode:s||w.recipient.postalCode,country:l||w.recipient.country,mobile:c||w.recipient.mobile,company:d||w.recipient.company,apartment:u||w.recipient.apartment,customField1:A||w.recipient.customField1,customField2:h||w.recipient.customField2,customField3:g||w.recipient.customField3,customField4:m||w.recipient.customField4,customField5:p||w.recipient.customField5,conversionConfigurationId:f||w.recipient.conversionConfigurationId,prevalidated:S}});else{const x=await this.graphQlClient().mutate({mutation:sc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{firstName:t,lastName:e,address:a,suburb:r,state:i,email:o,postalCode:s,country:l,mobile:c,company:d,apartment:u,customField1:A,customField2:h,customField3:g,customField4:m,customField5:p,conversionConfigurationId:f}});w.recipient={id:x?.data?.recipientCreate?.id,firstName:t,lastName:e,address:a,suburb:r,state:i,email:o,postalCode:s,country:l,mobile:c,company:d,apartment:u,customField1:A,customField2:h,customField3:g,customField4:m,customField5:p,conversionConfigurationId:f},this.experience.callEvent(Oe.RecipientChanged),await this.graphQlClient().mutate({mutation:cc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.experience.getTransaction().id,recipientId:x.data?.recipientCreate?.id},context:{transactionOwnerId:this.experience.getTransaction().transactionOwnerId}})}await this.fetchConversionConfiguration(),this.recipientCallbacks.forEach(x=>x(this.experience.getTransaction().recipient))}async fetchConversionConfiguration(){const t=this.experience.getTransaction().recipient;if(t?.conversionConfigurationId&&!this.recipientConversionConfiguration){const e=Xt.configurationPromiseMap.get(t.conversionConfigurationId);if(e)this.recipientConversionConfiguration=await e;else{const r=(async()=>(await this.graphQlClient().query({query:$o,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t.conversionConfigurationId}})).data.conversionConfiguration)();Xt.configurationPromiseMap.set(t.conversionConfigurationId,r),this.recipientConversionConfiguration=await r}}}async initializeDefaultWorkflowState(t){const e=()=>{const s=t.finalizeStepConfig;if(!s)return;const l=s.lookAtAnimation,c=s.modelAnimation;l&&this.previewService?.executeCameraAnimation(l),c&&this.modelContainer?.executeAnimation(c)};this.reloadedState&&this.reloadedState.serializableWorkflow.steps.forEach(s=>{this.storage[s.stepName]=s.storage||{}}),await this.fetchConversionConfiguration(),this.allScenes=await is(t);const r=vt(this.allScenes,this.stepSelections).map(s=>s.silentSteps).flat(),{stepElements:i,commands:o}=await this.stepElementsForIntroducedSilentSteps(r,!!this.reloadedState);this.commandContext.apply(new $(o),!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}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)}addRecipientCallback(t){this.recipientCallbacks.push(t),t(this.experience.getTransaction().recipient)}removeRecipientCallback(t){this.recipientCallbacks=this.recipientCallbacks.filter(e=>e!==t)}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}getCommandContext(){return this.commandContext}getRegionElements(t){return this.stepElements[t]||[]}getStepSpecificServices(t){return this.stepSpecificServices[t]}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))}getCommandDispatcher(){return t=>this.commandContext.apply(t,!this.initialized)}getWorkflowSelections(){const t={};return this.experience.getWorkflow()?.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=M();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.onMandatoryChange())}getMandatoryUnfulfilledSteps(){return vt(this.allScenes,this.stepSelections).flatMap(i=>i.renderableSteps).filter(i=>i.mandatory).filter(i=>!this.mandatorySteps[i.stepName]).map(i=>i.stepName)}setStepError(t,e,a){let r=!1;if(!this.validationErrors.steps.has(t)&&a)r=!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)?(r=!0,i.set(e,a)):a||(r=!0,i.delete(e),i.size===0&&this.validationErrors.steps.delete(t))}r&&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.");this.previewService=t;const a=this.experience.getProduct();if(!a?.modelUrl||!this.previewService)return;const r=t.loadModel({model:a.modelUrl,contextService:this.getLayoutPreviewService()},{refocusCamera:e});this.setModelContainer(r),vt(this.allScenes,this.stepSelections).filter(s=>s).map(s=>s.renderableSteps).flat().filter(s=>s.type===b.Model||s.type===b.Material).forEach(s=>{if(!s.option?.id){console.error(`Failed to read option id from step: ${s.stepName}`);return}const l=this.stepSelections[s.stepName]?.selectedVariants||[];if(l.length===0)return;const c=l[0];if(s.type===b.Model){if(!this.modelContainer)throw new Q("We should always have a model container when injecting a preview!");const d=c.asset?.fileLink;if(!d){console.error(`Failed to read model url from variant: ${c.id} for step: ${s.stepName}`);return}const u=s.data;this.modelContainer.applyModelVariant(s.stepName,{model:d,contextService:this.getLayoutPreviewService()},u.replaceProductModel||!1)}else{const d=c.material;if(!d){console.error(`Failed to read material from variant: ${c.id} for step: ${s.stepName}`);return}s.data.targetMaterials.forEach(A=>{if(!this.modelContainer)throw new Q("We should always have a model container when injecting a preview!");this.modelContainer.applyMaterialVariant(A,s.option.id,d)})}}),await r.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(!te(a,this.storage)){this.storage=a;const r=new wn(this.constructSerializableWorkflow());this.commandContext.apply(r,!0),this.onStepSpecificStorageChange(t),this.onStorageChange()}}constructSerializableWorkflow(){const t=[];return this.allScenes.forEach(e=>{e.renderableSteps.forEach(a=>{const r={stepName:a.stepName};r.storage=this.storage[a.stepName],r.selectedVariants=this.stepSelections[a.stepName]?.selectedVariants?.map(i=>({id:i.id,priceModifier:i.priceModifier})),t.push(r)})}),{steps:t}}updateStateWithServer(){if(this.readOnly)return;const t=this.serialize();this.workflowStatePromiseQueue.enqueue(new En(async()=>{await new Promise(e=>{setTimeout(()=>{e()},1)}),await this.updateTransaction({variables:{id:this.experience.getTransaction().id,workflowState:t}})}))}async updateStateWithServerImmediate(){if(this.readOnly)return;const t=this.serialize();return new En(async()=>{await this.updateTransaction({variables:{id:this.experience.getTransaction().id,workflowState:t}})}).execute()}serialize(){const t=this.getCommandContext().getState();if(!t)throw new Q("Attempted to serialize state before it was initialized.");const e=It(t.transaction),a=this.dehydrateState(e);return JSON.stringify(a,this.sortKeysReplacer,void 0)}async getStateHash(){const t=this.getCommandContext().getState(),a=Object.values(t?.transaction.layouts||{}).map(o=>o.modificationID??"").sort().join(""),i=new TextEncoder().encode(a);if(typeof window<"u"&&window.crypto&&window.crypto.subtle&&window.crypto.subtle.digest){const o=await window.crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(o)).map(c=>c.toString(16).padStart(2,"0")).join("")}try{return(await import("crypto")).createHash("sha256").update(a,"utf8").digest("hex")}catch{throw new Error("Unable to compute SHA-256 hash: no suitable crypto implementation available.")}}dehydrateState(t){for(const e of Object.values(t.layouts).map(a=>a.elements).flat())e.type==="illustration"&&(delete e.cachedObjectURL,e.src&&delete e.svg),e.type==="frame"&&delete e.pattern?.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,r)=>Object.keys(a).reduce((i,o)=>{const s=[...a[o]||[]];return r.forEach(l=>{const c=s.findIndex(d=>d.id===l.id);c>-1&&s.splice(c,1)}),i[o]=s,i},{});this.stepElements=e(this.stepElements,t)}getInvalidCanvasRegions(){return this.experience.getWorkflow()?.steps.reduce((t,e)=>(bt(e,this.stepSelections)||this.stepElements[e.stepName]&&this.stepElements[e.stepName].forEach(a=>t.push(a)),t),[])||[]}getInvalidModelVariants(){return this.experience.getWorkflow()?.steps.reduce((t,e)=>(e.type===b.Model&&!bt(e,this.stepSelections)&&t.push(e.stepName),t),[])||[]}async stepElementsForIntroducedSilentSteps(t,e){const a=this.experience.getProduct();if(!a)return Promise.resolve({stepElements:{},commands:[]});const r=async(c,d,u)=>{if(c.type===b.SilentIllustration){const A=await new yn(c,d).trigger();return{step:c,results:A}}else if(c.type===b.ProductOverlay){const A=await new yn(c,d,u).trigger();return{step:c,results:A}}return Promise.reject("Unknown silent step. This is a bug")},i=t.filter(c=>!this.stepInitialised[c.stepName]),o={stepElements:{},commands:[]},s=[];for(const c of i)this.markStepsAsInitialised([c.stepName]),e||s.push(r(c,this.layouts,a));const l=await Promise.all(s);for(const c of l)o.stepElements[c.step.stepName]=c.results.map(d=>d.regionElement),o.commands=[...o.commands,...c.results.map(d=>d.command)];return o}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.experience.getTransaction().id);this.experience.getTransaction().transactionShareActions=t}async updateTransactionStakeholders(){const t=await y.getShadowGraphqlClient().query({query:Go,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.experience.getTransaction().id}});!t?.data?.transactions||t.data.transactions.length!==1?(this.experience.getTransaction().currentStakeholder=void 0,this.experience.getTransaction().stakeholders=void 0):(this.experience.getTransaction().stakeholders=t.data.transactions[0].stakeholders,this.experience.getTransaction().currentStakeholder=t.data.transactions[0].currentStakeholder)}async approveTransaction(t){await y.getShadowGraphqlClient().mutate({mutation:ic,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.experience.getTransaction().id,note:t}})}async rejectTransaction(t){await y.getShadowGraphqlClient().mutate({mutation:oc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.experience.getTransaction().id,note:t}})}async reset(){this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},await this.ensureStepsAreLoaded()}async setSelectionsAndElements(t,e,a,r){const i=this.experience.getWorkflow();if(!i)throw new Error("Attempted to set selections when no workflow is set!");const o=this.stepSelections;this.stepSelections={...this.stepSelections,[t]:{selectedVariants:e}},this.selectionCost=Object.values(this.stepSelections).reduce((E,I)=>E+I.selectedVariants.map(N=>N.priceModifier||0).reduce((N,R)=>N+R,0),0),i.steps.forEach(E=>{bt(E,this.stepSelections)||(this.stepInitialised[E.stepName]=!1,delete this.stepMetadata[E.stepName],delete this.stepSelections[E.stepName],delete this.storage[E.stepName])});const s=this.allScenes,l=vt(s,o),c=vt(s,this.stepSelections),d=l.map(E=>E.silentSteps).flat(),A=c.map(E=>E.silentSteps).flat().filter(E=>!d.some(I=>I.stepName===E.stepName));d.forEach(E=>{bt(E,this.stepSelections)||(this.stepInitialised[E.stepName]=!1)});const h=this.getInvalidCanvasRegions(),{stepElements:g,commands:m}=await this.stepElementsForIntroducedSilentSteps(A,!1);this.stepElements={...this.stepElements,...g,[t]:a},this.removeElements(h);const p=i.steps.find(E=>E.stepName===t);p?.type===b.Frame&&this.getWorkflowExperience().getStepById(p.stepName)?.frameService?.setTargetElements(a.map(I=>I.id));const f=h.map(E=>new xt(E.id)),S=new wn(this.constructSerializableWorkflow()),w=[...m,...f,S];w.length>0&&this.commandContext.apply(new $(w),!0),await this.ensureStepsAreLoaded(),this.onElementsChange();const x=this.getInvalidModelVariants(),v=this.modelContainer;if(v){const E=x.map(I=>v.applyModelVariant(I,{contextService:this.getLayoutPreviewService()},!1));await Promise.all(E)}await this.onSelectionChange(),r&&await r()}async ensureStepsAreLoaded(){const e=vt(this.allScenes,this.stepSelections).map(l=>l.renderableSteps),a=[],r=e.flat();for(const l of r)if(!this.stepInitialised[l.stepName])switch(this.stepInitialised[l.stepName]=!0,l.type){case b.DigitalContent:a.push(Ha.init(l,this,this.reloadedState));break;case b.Frame:a.push(gt.init(l,this,this.reloadedState));break;case b.Illustration:a.push(Jt.init(l,this,this.reloadedState));break;case b.Material:a.push(Ya.init(l,this,this.reloadedState));break;case b.Model:a.push(Ja.init(l,this,this.reloadedState));break;case b.Module:this.stepSpecificServices[l.stepName]={module:await Dr(l.data.module)},a.push(Ka.init(l,this,this.reloadedState));break;case b.Picture:a.push(_a.init(l,this,this.reloadedState));break;case b.Question:a.push(Xa.init(l,this,this.reloadedState));break;case b.Shape:a.push(kt.init(l,this,this.reloadedState));break;case b.Text:a.push(j.init(l,this,this.reloadedState));break}const i=(await Promise.allSettled(a)).map(l=>{if(l.status==="rejected")throw new Error(`Step initialization failed: ${l.reason}`);return l.value}),o=i.filter(l=>!!l&&!!l.command).map(l=>l.command),s=i.filter(l=>!!l&&!!l.followup).map(l=>l.followup);o&&o.length>0&&this.commandContext.apply(new $(o),!0);for(const l of s)await l();s.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 ls(this.allScenes,this.stepSelections,this.singleVariantsRenderable)}};Xt.configurationPromiseMap=new Map;let xa=Xt;class nt{constructor(t){this.variantData=t}getType(){return this.variantData.asset?.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(){return this.variantData.asset?.versions?.find(t=>t.name==="cdn")?.link}getAssetResource(){return this.variantData.asset}getThumbnail(){const t=this.variantData.thumbnail?.versions?.find(a=>a.name==="thumbnail")?.link,e=this.variantData.thumbnail?.fileLink;return t||e}getColor(){return this.variantData.color}isDefault(){return!!this.variantData.default}getResource(){return this.variantData}isEnabled(){return this.variantData.enabled}}const Zt=class Zt{constructor(t,e,a){this.manager=t,this.step=e,this.tags=a}setUpdateState(t){Zt.updateState.set(`${this.step.stepName}-${this.manager.getWorkflowExperience().getTransaction().id}`,t)}getUpdateState(){return!!Zt.updateState.get(`${this.step.stepName}-${this.manager.getWorkflowExperience().getTransaction().id}`)}getCurrentVariant(){const a=this.manager.getWorkflowSelections()[this.step.stepName]?.selections[0];if(a)return new nt(a)}getAvailableVariants(){return(this.step.option?.variants?.filter(e=>e.enabled)||[]).map(e=>new nt(e))}getAllVariants(){return(this.step.option?.variants||[]).map(e=>new nt(e))}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){return(this.manager.getStepStorage(this.step.stepName)?.overrideGlobalConfigurations??{})[t.toString()]??!1}setOverrideGlobalPropertyConfiguration(t,e){const a=this.manager.getStepStorage(this.step.stepName)?.overrideGlobalConfigurations??{};this.manager.updateStorage(this.step.stepName,{overrideGlobalConfigurations:{...a,[t.toString()]:e}})}getGlobalPropertyAspects(t){return this.step.globalPropertyAspectConfigurations?.filter(e=>e.globalPropertyConfigurationId===t&&e.aspectName).map(e=>e.aspectName)??[]}executeAnimations(t){const e=this.manager.getPreviewService(),a=this.manager.getModelContainer(),r=this.step.data.modelAnimation,i=this.step.data.lookAtAnimation;e?i&&e.executeCameraAnimation(i):console.warn("No preview service available, cannot execute camera animations."),a?r&&a.executeAnimation(r,t):console.warn("No model container available, cannot execute model animations.")}};Zt.updateState=new Map;let Z=Zt;class Tr extends Z{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)return;const a=L(t[0].id,this.manager.getAllLayoutData()).colors,i=this.getCurrentVariant()?.getAssetResource()?.assetConfiguration,o=i?.defaultColorVariants||[];if(o.length!==0){const s={};return o.forEach(l=>{const c=i.channelNumbers.find(d=>d.number===l.channelNumber);if(c){const d=c.id.replace(/\W/g,"");s[l.channelNumber]={browserValue:a[d]?.browserValue||""}}}),s}try{return a}catch(s){console.error(s)}}setColor(t,e,a){const r=new Map,o=this.getCurrentVariant()?.getAssetResource()?.assetConfiguration;return(o?.defaultColorVariants||[]).length!==0?o.channelNumbers.forEach(l=>{if(l.number.toString()===t){const c=l.id.replace(/\W/g,"");a?r.set(c,{browserValue:e,pmsValue:a}):r.set(c,e)}}):a?r.set(t,{browserValue:e,pmsValue:a}):r.set(t,e),Jt.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,()=>this.manager.getCommandContext().getAllLayouts(),r)}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 Nr extends Z{constructor(t,e,a){super(t,e,a)}selectVariant(t){return Ya.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class Qr extends Z{constructor(t,e,a){super(t,e,a)}selectVariant(t){return Ja.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class Rr extends Z{constructor(t,e,a){super(t,e,a)}selectVariant(t){return _a.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class Or extends Z{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 Xa.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){return this.step.data.displayType||this.step.option?.displayType}}class $r extends Z{constructor(t,e,a){super(t,e,a)}selectVariant(t){const e=t.getResource();return kt.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return kt.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return kt.availableColours(this.step)}setCustomColor(t){return this.getCurrentVariant()?.getColor()!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${this.getCurrentVariant()?.getColor()}`),kt.setCustomColor(t,this.step,this.manager)}getCustomColor(){this.getCurrentVariant()?.getColor()!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${this.getCurrentVariant()?.getColor()}`);const t=this.manager.getStepStorage(this.step.stepName)?.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 Ur extends Z{constructor(t,e,a){super(t,e,a)}async selectVariant(t){j.selectVariant(this.step,t.getResource(),this.manager,e=>{if(e)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occurred with text",messageType:pe.Error,stepID:this.step.stepName}]);else{const a=this.manager.getInformationResults().filter(r=>r.stepID!==this.step.stepName);this.manager.setInformationResults(a)}},()=>{})}getAvailableFillColors(){return this.step.data.colorPickerEnabled?j.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await j.changeFillColor(this.step,t,e,this.manager)}getFillColor(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}getAvailableFillImages(){return j.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await j.changeFillImage(this.step,t,e,this.manager)}getFillImage(){return this.manager.getStepStorage(this.step.stepName)?.fillImage}getAlignment(){return j.findLayoutElements(this.manager,this.step)?.[0].align}setAlignment(t){const e=this.manager.getRegionElements(this.step.stepName);j.changeAlignment(this.step,t,e,this.manager)}setFullTextCustomization(t){const e=this.manager.getStepStorage(this.step.stepName)?.inputText||"",a=this.step.data.replaceableText!==void 0?this.step.data.replaceableText.replace("{{}}",e):e,r=t?a:this.step.data.defaultText;return this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:r,defaultCleared:!1}),this.setText(r)}setText(t){const e={input:t,helperData:{}},a=j.findLayoutElements(this.manager,this.step),r=j.filterUnsupportedCharacters(t,a[0]?.fontData),i=Mt(r,this.manager).length,o=!!this.step.data&&!!this.step.data.maxLength&&i>this.step.data.maxLength;o||(e.input=r);const s=a.length<=0,l=s?{inputText:r,text:r}:{inputText:r};this.manager.updateStorage(this.step.stepName,l);const c=this.manager.getStepStorage(this.step.stepName),d=j.getProcessedInput(r,this.step.data,c?.customiseAllText??!1);if(s)o||this.manager.updateMetadata(this.step.stepName,{text:d});else{const{command:u,errorData:A,helperData:h}=j.updateInputText(r,a,this.step,this.manager);u&&this.manager.getCommandDispatcher()(u),e.helperData=h,e.errorData=A,!o&&!A&&this.manager.updateMetadata(this.step.stepName,{text:d})}return e}getText(){const t=this.step.data.defaultText,e=this.manager.getStepStorage(this.step.stepName);return t&&e?.defaultCleared!==void 0&&!e?.defaultCleared?t:this.manager.getStepStorage(this.step.stepName)?.text||""}isReplaceable(){return this.step.data.userCanReplaceText}newLinesSupported(){return this.step.data.allowNewlines||!1}clearDefaultTextIfNecessary(){if(!this.manager.getStepStorage(this.step.stepName)?.defaultCleared&&this.step.data.deleteDefaultOnFocus){const e=this.setText("");this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""});const a=j.findLayoutElements(this.manager,this.step);return j.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=Mt(this.getText(),this.manager);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?j.availableStrokeColors(this.step):[]}getStrokeColor(){return this.manager.getStepStorage(this.step.stepName)?.strokeColor?.browserValue||"#000000"}async setStrokeColor(t){const e=this.manager.getRegionElements(this.step.stepName);await j.changeStrokeColor(this.step,t,e,this.manager)}}class Lr extends Z{constructor(t,e,a){super(t,e,a)}async selectVariant(){}getContent(){return this.step.data.content}}class Vr extends Z{constructor(t,e,a){super(t,e,a)}async selectVariant(){}getPreviewURL(){return this.manager.getStepStorage(this.step.stepName)?.videoUrl||""}async selectVideo(t){return Ha.regenerateQRCode(this.manager.getRegionElements(this.step.stepName),t.key,this.manager,this.step)}}class zr extends Z{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=Mt(this.getText(),this.manager);return t-e.length}getCharacterLimit(){return this.step.data.maxLength}getText(){return this.manager.getStepStorage(this.step.stepName)?.text||""}setText(t){Ka.changeText(this.step,t,this.manager,e=>{if(e){const a=[...this.manager.getInformationResults(),{message:e,messageType:pe.Error,stepID:this.step.stepName}];this.manager.setInformationResults(a)}else{const a=this.manager.getInformationResults().filter(r=>r.stepID!==this.step.stepName);this.manager.setInformationResults(a)}})}}class Ee{static get(t,e){switch(e.type){case b.DigitalContent:return new Vr(t,e,t.getStepTags(e.stepName));case b.Information:return new Lr(t,e,t.getStepTags(e.stepName));case b.Question:return new Or(t,e,t.getStepTags(e.stepName));case b.Text:return new Ur(t,e,t.getStepTags(e.stepName));case b.Illustration:return new Tr(t,e,t.getStepTags(e.stepName));case b.Picture:return new Rr(t,e,t.getStepTags(e.stepName));case b.Shape:return new $r(t,e,t.getStepTags(e.stepName));case b.Material:return new Nr(t,e,t.getStepTags(e.stepName));case b.Model:return new Qr(t,e,t.getStepTags(e.stepName));case b.Frame:return new ci(t,e,t.getStepTags(e.stepName));case b.Module:return new zr(t,e,t.getStepTags(e.stepName));default:throw new Q(`Step type ${e.type} not yet supported in Core SDK`)}}}const gc=C.gql`
|
|
2171
|
+
`,Ac=C.gql`
|
|
2172
|
+
query FindBundleForTransactions($ids: [String!]!) {
|
|
2173
|
+
transactions(ids: $ids) {
|
|
2174
|
+
id
|
|
2175
|
+
bundle {
|
|
2176
|
+
id
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
`;var pe=(a=>(a.Error="Error",a.Warning="Warning",a.Info="Info",a))(pe||{});const hc=1e3;class Ea extends Vn{constructor(t){super(),this.createdAt=new Date,this.update=t}async execute(){await this.update(),await new Promise(t=>{window.setTimeout(()=>{t()},hc)})}}const gc=a=>a.sort((t,e)=>t.index-e.index).map(t=>({id:M(),panelId:t.name,name:t.name,title:t.title,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})),mc=(a,t)=>{const e=a.workflowState,n=e?JSON.parse(e):void 0;return n?Object.values(n.layouts).map(r=>r.layout):gc(t.panels)},Xt=class Xt{constructor(t,e,n,r,i,o=!1,s,l=!1,c=!1,d=!1){this.workflowStatePromiseQueue=new zn(1),this.initialized=!1,this.readOnly=!1,this.isReloadedTransaction=!1,this.singleVariantsRenderable=!1,this.stepTags={},this.setWorkflow=async A=>{this.confirmedDesign=!1,this.editedSteps={},this.informationResults=[],this.mandatorySteps={},this.pendingUpdates=[],this.selectionCost=0,this.stepSpecificServices={},this.pollers=[],this.allScenes=[],this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},this.validationErrors={steps:new Map},this.currentAdjustingStepId="",this.reloadedState?this.layouts=Object.values(this.reloadedState.layouts||{}).map(g=>g.layout):A?this.layouts=mc(this.experience.getTransaction(),A):this.layouts=[],this.commandContext.initialize(this.layouts,this.reloadedState),this.renderableContextService=new Pl(this.layouts),this.renderableContextService.setWorkflowManager(this),A.steps.forEach(g=>{this.stepTags[g.stepName]=g.tags??[]});const h=this.previewService;this.ejectFromPreviewService(),this.initializationPromise=this.initializeDefaultWorkflowState(A),this.initializationPromise.then(()=>{this.initialized=!0}),this.initializationPromise.catch(g=>{throw console.error(g),this.initialized=!1,new Error("Workflow initialization failed due to an error. See console.")}),this.initializationPromise.finally(()=>this.commandContext.registerStateCallback(()=>{this.updateStateWithServer(),this.renderLayouts()})),h&&await this.injectIntoPreviewService(h,!0)},this.renderLayouts=()=>{if(!this.previewService)return;const A=this.getCommandContext().getAllLayouts(),h=this.getLayoutPreviewService()?.getAll();if(h)for(const[,g]of h)g.render(A)},this.sortKeysReplacer=(A,h)=>h&&typeof h=="object"&&!Array.isArray(h)?Object.keys(h).sort().reduce((g,m)=>(g[m]=h[m],g),{}):h,this.experience=t,this.client=e,this.updateTransaction=n,this.graphQlClient=r,this.reloadedState=i,this.readOnly=o,this.singleVariantsRenderable=c,this.commandContext=new wr,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.recipientCallbacks=[],this.modelContainer=s,this.confirmedDesign=!1,this.editedSteps={},this.informationResults=[],this.mandatorySteps={},this.pendingUpdates=[],this.selectionCost=0,this.stepSpecificServices={},this.pollers=[],this.allScenes=[],this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},this.validationErrors={steps:new Map},this.currentAdjustingStepId="",this.isReloadedTransaction=l,d&&(this.workflowStatePromiseQueue.enabled=!1);const u=this.experience.getWorkflow();u&&this.setWorkflow(u)}getTemplatingContext(){const t=this.experience.getTransaction().recipient,e={recipient:t};return this.recipientConversionConfiguration?.requestedDataItems?.forEach(n=>{const r=n.uniqueIdentifier??n.title??"";n.type===_t.FirstName?e[r]=t?.firstName:n.type===_t.LastName?e[r]=t?.lastName:n.type===_t.Custom&&(n.customFieldIndex===1?e[r]=t?.customField1:n.customFieldIndex===2?e[r]=t?.customField2:n.customFieldIndex===3?e[r]=t?.customField3:n.customFieldIndex===4?e[r]=t?.customField4:n.customFieldIndex===5&&(e[r]=t?.customField5),n.option&&(e[r]=n.option.variants?.find(i=>i.id===e[r])?.name))}),e}async updateRecipient(t,e,n,r,i,o,s,l,c,d,u,A,h,g,m,p,f,S){const w=this.experience.getTransaction();if(w.recipient?.id)this.experience.getTransaction().recipient={id:w.recipient.id,firstName:t??w.recipient.firstName,lastName:e??w.recipient.lastName,address:n??w.recipient.address,suburb:r??w.recipient.suburb,state:i??w.recipient.state,email:o??w.recipient.email,postalCode:s??w.recipient.postalCode,country:l??w.recipient.country,mobile:c??w.recipient.mobile,company:d??w.recipient.company,apartment:u??w.recipient.apartment,customField1:A??w.recipient.customField1,customField2:h??w.recipient.customField2,customField3:g??w.recipient.customField3,customField4:m??w.recipient.customField4,customField5:p??w.recipient.customField5,conversionConfigurationId:f||w.recipient.conversionConfigurationId},this.experience.callEvent(Oe.RecipientChanged),await this.graphQlClient().mutate({mutation:cc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:w.recipient.id,firstName:t||w.recipient.firstName,lastName:e||w.recipient.lastName,address:n||w.recipient.address,suburb:r||w.recipient.suburb,state:i||w.recipient.state,email:o||w.recipient.email,postalCode:s||w.recipient.postalCode,country:l||w.recipient.country,mobile:c||w.recipient.mobile,company:d||w.recipient.company,apartment:u||w.recipient.apartment,customField1:A||w.recipient.customField1,customField2:h||w.recipient.customField2,customField3:g||w.recipient.customField3,customField4:m||w.recipient.customField4,customField5:p||w.recipient.customField5,conversionConfigurationId:f||w.recipient.conversionConfigurationId,prevalidated:S}});else{const x=await this.graphQlClient().mutate({mutation:lc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{firstName:t,lastName:e,address:n,suburb:r,state:i,email:o,postalCode:s,country:l,mobile:c,company:d,apartment:u,customField1:A,customField2:h,customField3:g,customField4:m,customField5:p,conversionConfigurationId:f}});w.recipient={id:x?.data?.recipientCreate?.id,firstName:t,lastName:e,address:n,suburb:r,state:i,email:o,postalCode:s,country:l,mobile:c,company:d,apartment:u,customField1:A,customField2:h,customField3:g,customField4:m,customField5:p,conversionConfigurationId:f},this.experience.callEvent(Oe.RecipientChanged),await this.graphQlClient().mutate({mutation:dc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.experience.getTransaction().id,recipientId:x.data?.recipientCreate?.id},context:{transactionOwnerId:this.experience.getTransaction().transactionOwnerId}})}await this.fetchConversionConfiguration(),this.recipientCallbacks.forEach(x=>x(this.experience.getTransaction().recipient))}async fetchConversionConfiguration(){const t=this.experience.getTransaction().recipient;if(t?.conversionConfigurationId&&!this.recipientConversionConfiguration){const e=Xt.configurationPromiseMap.get(t.conversionConfigurationId);if(e)this.recipientConversionConfiguration=await e;else{const r=(async()=>(await this.graphQlClient().query({query:Uo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t.conversionConfigurationId}})).data.conversionConfiguration)();Xt.configurationPromiseMap.set(t.conversionConfigurationId,r),this.recipientConversionConfiguration=await r}}}async initializeDefaultWorkflowState(t){const e=()=>{const s=t.finalizeStepConfig;if(!s)return;const l=s.lookAtAnimation,c=s.modelAnimation;l&&this.previewService?.executeCameraAnimation(l),c&&this.modelContainer?.executeAnimation(c)};this.reloadedState&&this.reloadedState.serializableWorkflow.steps.forEach(s=>{this.storage[s.stepName]=s.storage||{}}),await this.fetchConversionConfiguration(),this.allScenes=await os(t);const r=vt(this.allScenes,this.stepSelections).map(s=>s.silentSteps).flat(),{stepElements:i,commands:o}=await this.stepElementsForIntroducedSilentSteps(r,!!this.reloadedState);this.commandContext.apply(new $(o),!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}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)}addRecipientCallback(t){this.recipientCallbacks.push(t),t(this.experience.getTransaction().recipient)}removeRecipientCallback(t){this.recipientCallbacks=this.recipientCallbacks.filter(e=>e!==t)}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}getCommandContext(){return this.commandContext}getRegionElements(t){return this.stepElements[t]||[]}getStepSpecificServices(t){return this.stepSpecificServices[t]}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))}getCommandDispatcher(){return t=>this.commandContext.apply(t,!this.initialized)}getWorkflowSelections(){const t={};return this.experience.getWorkflow()?.steps.forEach(e=>{const n=this.stepSelections[e.stepName];n&&n.selectedVariants&&n.selectedVariants.length>0&&(t[e.stepName]={selections:n.selectedVariants})}),t}getStepSelections(){return this.stepSelections}markStepsAsInitialised(t){const e={...this.stepInitialised};t.forEach(n=>{e[n]=!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=M();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.onMandatoryChange())}getMandatoryUnfulfilledSteps(){return vt(this.allScenes,this.stepSelections).flatMap(i=>i.renderableSteps).filter(i=>i.mandatory).filter(i=>!this.mandatorySteps[i.stepName]).map(i=>i.stepName)}setStepError(t,e,n){let r=!1;if(!this.validationErrors.steps.has(t)&&n)r=!0,this.validationErrors.steps.set(t,new Map([[e,n]]));else if(this.validationErrors.steps.has(t)){const i=this.validationErrors.steps.get(t);n&&n!==i.get(e)?(r=!0,i.set(e,n)):n||(r=!0,i.delete(e),i.size===0&&this.validationErrors.steps.delete(t))}r&&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.");this.previewService=t;const n=this.experience.getProduct();if(!n?.modelUrl||!this.previewService)return;const r=t.loadModel({model:n.modelUrl,contextService:this.getLayoutPreviewService()},{refocusCamera:e});this.setModelContainer(r),vt(this.allScenes,this.stepSelections).filter(s=>s).map(s=>s.renderableSteps).flat().filter(s=>s.type===b.Model||s.type===b.Material).forEach(s=>{if(!s.option?.id){console.error(`Failed to read option id from step: ${s.stepName}`);return}const l=this.stepSelections[s.stepName]?.selectedVariants||[];if(l.length===0)return;const c=l[0];if(s.type===b.Model){if(!this.modelContainer)throw new Q("We should always have a model container when injecting a preview!");const d=c.asset?.fileLink;if(!d){console.error(`Failed to read model url from variant: ${c.id} for step: ${s.stepName}`);return}const u=s.data;this.modelContainer.applyModelVariant(s.stepName,{model:d,contextService:this.getLayoutPreviewService()},u.replaceProductModel||!1)}else{const d=c.material;if(!d){console.error(`Failed to read material from variant: ${c.id} for step: ${s.stepName}`);return}s.data.targetMaterials.forEach(A=>{if(!this.modelContainer)throw new Q("We should always have a model container when injecting a preview!");this.modelContainer.applyMaterialVariant(A,s.option.id,d)})}}),await r.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 n={...this.storage,[t]:{...this.storage[t],...e}};if(!te(n,this.storage)){this.storage=n;const r=new wa(this.constructSerializableWorkflow());this.commandContext.apply(r,!0),this.onStepSpecificStorageChange(t),this.onStorageChange()}}constructSerializableWorkflow(){const t=[];return this.allScenes.forEach(e=>{e.renderableSteps.forEach(n=>{const r={stepName:n.stepName};r.storage=this.storage[n.stepName],r.selectedVariants=this.stepSelections[n.stepName]?.selectedVariants?.map(i=>({id:i.id,priceModifier:i.priceModifier})),t.push(r)})}),{steps:t}}updateStateWithServer(){if(this.readOnly)return;const t=this.serialize();this.workflowStatePromiseQueue.enqueue(new Ea(async()=>{await new Promise(e=>{setTimeout(()=>{e()},1)}),await this.updateTransaction({variables:{id:this.experience.getTransaction().id,workflowState:t}})}))}async updateStateWithServerImmediate(){if(this.readOnly)return;const t=this.serialize();return new Ea(async()=>{await this.updateTransaction({variables:{id:this.experience.getTransaction().id,workflowState:t}})}).execute()}serialize(){const t=this.getCommandContext().getState();if(!t)throw new Q("Attempted to serialize state before it was initialized.");const e=It(t.transaction),n=this.dehydrateState(e);return JSON.stringify(n,this.sortKeysReplacer,void 0)}async getStateHash(){const t=this.getCommandContext().getState(),n=Object.values(t?.transaction.layouts||{}).map(o=>o.modificationID??"").sort().join(""),i=new TextEncoder().encode(n);if(typeof window<"u"&&window.crypto&&window.crypto.subtle&&window.crypto.subtle.digest){const o=await window.crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(o)).map(c=>c.toString(16).padStart(2,"0")).join("")}try{return(await import("crypto")).createHash("sha256").update(n,"utf8").digest("hex")}catch{throw new Error("Unable to compute SHA-256 hash: no suitable crypto implementation available.")}}dehydrateState(t){for(const e of Object.values(t.layouts).map(n=>n.elements).flat())e.type==="illustration"&&(delete e.cachedObjectURL,e.src&&delete e.svg),e.type==="frame"&&delete e.pattern?.svg;return this.deleteFieldNameFromObjectRecursive(t,"__typename"),t}deleteFieldNameFromObjectRecursive(t,e){if(!(typeof t!="object"||t===null))for(const n in t)n===e?delete t[n]:this.deleteFieldNameFromObjectRecursive(t[n],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=(n,r)=>Object.keys(n).reduce((i,o)=>{const s=[...n[o]||[]];return r.forEach(l=>{const c=s.findIndex(d=>d.id===l.id);c>-1&&s.splice(c,1)}),i[o]=s,i},{});this.stepElements=e(this.stepElements,t)}getInvalidCanvasRegions(){return this.experience.getWorkflow()?.steps.reduce((t,e)=>(bt(e,this.stepSelections)||this.stepElements[e.stepName]&&this.stepElements[e.stepName].forEach(n=>t.push(n)),t),[])||[]}getInvalidModelVariants(){return this.experience.getWorkflow()?.steps.reduce((t,e)=>(e.type===b.Model&&!bt(e,this.stepSelections)&&t.push(e.stepName),t),[])||[]}async stepElementsForIntroducedSilentSteps(t,e){const n=this.experience.getProduct();if(!n)return Promise.resolve({stepElements:{},commands:[]});const r=async(c,d,u)=>{if(c.type===b.SilentIllustration){const A=await new ya(c,d).trigger();return{step:c,results:A}}else if(c.type===b.ProductOverlay){const A=await new ya(c,d,u).trigger();return{step:c,results:A}}return Promise.reject("Unknown silent step. This is a bug")},i=t.filter(c=>!this.stepInitialised[c.stepName]),o={stepElements:{},commands:[]},s=[];for(const c of i)this.markStepsAsInitialised([c.stepName]),e||s.push(r(c,this.layouts,n));const l=await Promise.all(s);for(const c of l)o.stepElements[c.step.stepName]=c.results.map(d=>d.regionElement),o.commands=[...o.commands,...c.results.map(d=>d.command)];return o}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(n=>n.stepName===t)}async updateTransactionShareActions(){const t=await this.client.getShareActionsForTransaction(this.experience.getTransaction().id);this.experience.getTransaction().transactionShareActions=t}async updateTransactionStakeholders(){const t=await y.getShadowGraphqlClient().query({query:jo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.experience.getTransaction().id}});!t?.data?.transactions||t.data.transactions.length!==1?(this.experience.getTransaction().currentStakeholder=void 0,this.experience.getTransaction().stakeholders=void 0):(this.experience.getTransaction().stakeholders=t.data.transactions[0].stakeholders,this.experience.getTransaction().currentStakeholder=t.data.transactions[0].currentStakeholder)}async approveTransaction(t){await y.getShadowGraphqlClient().mutate({mutation:oc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.experience.getTransaction().id,note:t}})}async rejectTransaction(t){await y.getShadowGraphqlClient().mutate({mutation:sc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.experience.getTransaction().id,note:t}})}async reset(){this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},await this.ensureStepsAreLoaded()}async setSelectionsAndElements(t,e,n,r){const i=this.experience.getWorkflow();if(!i)throw new Error("Attempted to set selections when no workflow is set!");const o=this.stepSelections;this.stepSelections={...this.stepSelections,[t]:{selectedVariants:e}},this.selectionCost=Object.values(this.stepSelections).reduce((E,I)=>E+I.selectedVariants.map(N=>N.priceModifier||0).reduce((N,R)=>N+R,0),0),i.steps.forEach(E=>{bt(E,this.stepSelections)||(this.stepInitialised[E.stepName]=!1,delete this.stepMetadata[E.stepName],delete this.stepSelections[E.stepName],delete this.storage[E.stepName])});const s=this.allScenes,l=vt(s,o),c=vt(s,this.stepSelections),d=l.map(E=>E.silentSteps).flat(),A=c.map(E=>E.silentSteps).flat().filter(E=>!d.some(I=>I.stepName===E.stepName));d.forEach(E=>{bt(E,this.stepSelections)||(this.stepInitialised[E.stepName]=!1)});const h=this.getInvalidCanvasRegions(),{stepElements:g,commands:m}=await this.stepElementsForIntroducedSilentSteps(A,!1);this.stepElements={...this.stepElements,...g,[t]:n},this.removeElements(h);const p=i.steps.find(E=>E.stepName===t);p?.type===b.Frame&&this.getWorkflowExperience().getStepById(p.stepName)?.frameService?.setTargetElements(n.map(I=>I.id));const f=h.map(E=>new xt(E.id)),S=new wa(this.constructSerializableWorkflow()),w=[...m,...f,S];w.length>0&&this.commandContext.apply(new $(w),!0),await this.ensureStepsAreLoaded(),this.onElementsChange();const x=this.getInvalidModelVariants(),v=this.modelContainer;if(v){const E=x.map(I=>v.applyModelVariant(I,{contextService:this.getLayoutPreviewService()},!1));await Promise.all(E)}await this.onSelectionChange(),r&&await r()}async ensureStepsAreLoaded(){const e=vt(this.allScenes,this.stepSelections).map(l=>l.renderableSteps),n=[],r=e.flat();for(const l of r)if(!this.stepInitialised[l.stepName])switch(this.stepInitialised[l.stepName]=!0,l.type){case b.DigitalContent:n.push(Yn.init(l,this,this.reloadedState));break;case b.Frame:n.push(gt.init(l,this,this.reloadedState));break;case b.Illustration:n.push(Jt.init(l,this,this.reloadedState));break;case b.Material:n.push(Jn.init(l,this,this.reloadedState));break;case b.Model:n.push(Kn.init(l,this,this.reloadedState));break;case b.Module:this.stepSpecificServices[l.stepName]={module:await Dr(l.data.module)},n.push(_n.init(l,this,this.reloadedState));break;case b.Picture:n.push(Xn.init(l,this,this.reloadedState));break;case b.Question:n.push(Zn.init(l,this,this.reloadedState));break;case b.Shape:n.push(kt.init(l,this,this.reloadedState));break;case b.Text:n.push(j.init(l,this,this.reloadedState));break}const i=(await Promise.allSettled(n)).map(l=>{if(l.status==="rejected")throw new Error(`Step initialization failed: ${l.reason}`);return l.value}),o=i.filter(l=>!!l&&!!l.command).map(l=>l.command),s=i.filter(l=>!!l&&!!l.followup).map(l=>l.followup);o&&o.length>0&&this.commandContext.apply(new $(o),!0);for(const l of s)await l();s.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)}};Xt.configurationPromiseMap=new Map;let Fn=Xt;class at{constructor(t){this.variantData=t}getType(){return this.variantData.asset?.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(){return this.variantData.asset?.versions?.find(t=>t.name==="cdn")?.link}getAssetResource(){return this.variantData.asset}getThumbnail(){const t=this.variantData.thumbnail?.versions?.find(n=>n.name==="thumbnail")?.link,e=this.variantData.thumbnail?.fileLink;return t||e}getColor(){return this.variantData.color}isDefault(){return!!this.variantData.default}getResource(){return this.variantData}isEnabled(){return this.variantData.enabled}}const Zt=class Zt{constructor(t,e,n){this.manager=t,this.step=e,this.tags=n}setUpdateState(t){Zt.updateState.set(`${this.step.stepName}-${this.manager.getWorkflowExperience().getTransaction().id}`,t)}getUpdateState(){return!!Zt.updateState.get(`${this.step.stepName}-${this.manager.getWorkflowExperience().getTransaction().id}`)}getCurrentVariant(){const n=this.manager.getWorkflowSelections()[this.step.stepName]?.selections[0];if(n)return new at(n)}getAvailableVariants(){return(this.step.option?.variants?.filter(e=>e.enabled)||[]).map(e=>new at(e))}getAllVariants(){return(this.step.option?.variants||[]).map(e=>new at(e))}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){return(this.manager.getStepStorage(this.step.stepName)?.overrideGlobalConfigurations??{})[t.toString()]??!1}setOverrideGlobalPropertyConfiguration(t,e){const n=this.manager.getStepStorage(this.step.stepName)?.overrideGlobalConfigurations??{};this.manager.updateStorage(this.step.stepName,{overrideGlobalConfigurations:{...n,[t.toString()]:e}})}getGlobalPropertyAspects(t){return this.step.globalPropertyAspectConfigurations?.filter(e=>e.globalPropertyConfigurationId===t&&e.aspectName).map(e=>e.aspectName)??[]}executeAnimations(t){const e=this.manager.getPreviewService(),n=this.manager.getModelContainer(),r=this.step.data.modelAnimation,i=this.step.data.lookAtAnimation;e?i&&e.executeCameraAnimation(i):console.warn("No preview service available, cannot execute camera animations."),n?r&&n.executeAnimation(r,t):console.warn("No model container available, cannot execute model animations.")}};Zt.updateState=new Map;let Z=Zt;class Tr extends Z{constructor(t,e,n){super(t,e,n)}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)return;const n=L(t[0].id,this.manager.getAllLayoutData()).colors,i=this.getCurrentVariant()?.getAssetResource()?.assetConfiguration,o=i?.defaultColorVariants||[];if(o.length!==0){const s={};return o.forEach(l=>{const c=i.channelNumbers.find(d=>d.number===l.channelNumber);if(c){const d=c.id.replace(/\W/g,"");s[l.channelNumber]={browserValue:n[d]?.browserValue||""}}}),s}try{return n}catch(s){console.error(s)}}setColor(t,e,n){const r=new Map,o=this.getCurrentVariant()?.getAssetResource()?.assetConfiguration;return(o?.defaultColorVariants||[]).length!==0?o.channelNumbers.forEach(l=>{if(l.number.toString()===t){const c=l.id.replace(/\W/g,"");n?r.set(c,{browserValue:e,pmsValue:n}):r.set(c,e)}}):n?r.set(t,{browserValue:e,pmsValue:n}):r.set(t,e),Jt.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,()=>this.manager.getCommandContext().getAllLayouts(),r)}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 Nr extends Z{constructor(t,e,n){super(t,e,n)}selectVariant(t){return Jn.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class Qr extends Z{constructor(t,e,n){super(t,e,n)}selectVariant(t){return Kn.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class Rr extends Z{constructor(t,e,n){super(t,e,n)}selectVariant(t){return Xn.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class Or extends Z{constructor(t,e,n){super(t,e,n)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await Zn.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){return this.step.data.displayType||this.step.option?.displayType}}class $r extends Z{constructor(t,e,n){super(t,e,n)}selectVariant(t){const e=t.getResource();return kt.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return kt.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return kt.availableColours(this.step)}setCustomColor(t){return this.getCurrentVariant()?.getColor()!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${this.getCurrentVariant()?.getColor()}`),kt.setCustomColor(t,this.step,this.manager)}getCustomColor(){this.getCurrentVariant()?.getColor()!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${this.getCurrentVariant()?.getColor()}`);const t=this.manager.getStepStorage(this.step.stepName)?.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 Ur extends Z{constructor(t,e,n){super(t,e,n)}async selectVariant(t){j.selectVariant(this.step,t.getResource(),this.manager,e=>{if(e)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occurred with text",messageType:pe.Error,stepID:this.step.stepName}]);else{const n=this.manager.getInformationResults().filter(r=>r.stepID!==this.step.stepName);this.manager.setInformationResults(n)}},()=>{})}getAvailableFillColors(){return this.step.data.colorPickerEnabled?j.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await j.changeFillColor(this.step,t,e,this.manager)}getFillColor(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}getAvailableFillImages(){return j.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await j.changeFillImage(this.step,t,e,this.manager)}getFillImage(){return this.manager.getStepStorage(this.step.stepName)?.fillImage}getAlignment(){return j.findLayoutElements(this.manager,this.step)?.[0].align}setAlignment(t){const e=this.manager.getRegionElements(this.step.stepName);j.changeAlignment(this.step,t,e,this.manager)}setFullTextCustomization(t){const e=this.manager.getStepStorage(this.step.stepName)?.inputText||"",n=this.step.data.replaceableText!==void 0?this.step.data.replaceableText.replace("{{}}",e):e,r=t?n:this.step.data.defaultText;return this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:r,defaultCleared:!1}),this.setText(r)}setText(t){const e={input:t,helperData:{}},n=j.findLayoutElements(this.manager,this.step),r=j.filterUnsupportedCharacters(t,n[0]?.fontData),i=Mt(r,this.manager).length,o=!!this.step.data&&!!this.step.data.maxLength&&i>this.step.data.maxLength;o||(e.input=r);const s=n.length<=0,l=s?{inputText:r,text:r}:{inputText:r};this.manager.updateStorage(this.step.stepName,l);const c=this.manager.getStepStorage(this.step.stepName),d=j.getProcessedInput(r,this.step.data,c?.customiseAllText??!1);if(s)o||this.manager.updateMetadata(this.step.stepName,{text:d});else{const{command:u,errorData:A,helperData:h}=j.updateInputText(r,n,this.step,this.manager);u&&this.manager.getCommandDispatcher()(u),e.helperData=h,e.errorData=A,!o&&!A&&this.manager.updateMetadata(this.step.stepName,{text:d})}return e}getText(){const t=this.step.data.defaultText,e=this.manager.getStepStorage(this.step.stepName);return t&&e?.defaultCleared!==void 0&&!e?.defaultCleared?t:this.manager.getStepStorage(this.step.stepName)?.text||""}isReplaceable(){return this.step.data.userCanReplaceText}newLinesSupported(){return this.step.data.allowNewlines||!1}clearDefaultTextIfNecessary(){if(!this.manager.getStepStorage(this.step.stepName)?.defaultCleared&&this.step.data.deleteDefaultOnFocus){const e=this.setText("");this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""});const n=j.findLayoutElements(this.manager,this.step);return j.updateInputText("",n,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=Mt(this.getText(),this.manager);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?j.availableStrokeColors(this.step):[]}getStrokeColor(){return this.manager.getStepStorage(this.step.stepName)?.strokeColor?.browserValue||"#000000"}async setStrokeColor(t){const e=this.manager.getRegionElements(this.step.stepName);await j.changeStrokeColor(this.step,t,e,this.manager)}}class Lr extends Z{constructor(t,e,n){super(t,e,n)}async selectVariant(){}getContent(){return this.step.data.content}}class Vr extends Z{constructor(t,e,n){super(t,e,n)}async selectVariant(){}getPreviewURL(){return this.manager.getStepStorage(this.step.stepName)?.videoUrl||""}async selectVideo(t){return Yn.regenerateQRCode(this.manager.getRegionElements(this.step.stepName),t.key,this.manager,this.step)}}class zr extends Z{constructor(t,e,n){super(t,e,n)}async selectVariant(){console.info("Text Modules don't support variants.")}getCharactersRemaining(){const t=this.step.data.maxLength;if(t===void 0)return;const e=Mt(this.getText(),this.manager);return t-e.length}getCharacterLimit(){return this.step.data.maxLength}getText(){return this.manager.getStepStorage(this.step.stepName)?.text||""}setText(t){_n.changeText(this.step,t,this.manager,e=>{if(e){const n=[...this.manager.getInformationResults(),{message:e,messageType:pe.Error,stepID:this.step.stepName}];this.manager.setInformationResults(n)}else{const n=this.manager.getInformationResults().filter(r=>r.stepID!==this.step.stepName);this.manager.setInformationResults(n)}})}}class Ee{static get(t,e){switch(e.type){case b.DigitalContent:return new Vr(t,e,t.getStepTags(e.stepName));case b.Information:return new Lr(t,e,t.getStepTags(e.stepName));case b.Question:return new Or(t,e,t.getStepTags(e.stepName));case b.Text:return new Ur(t,e,t.getStepTags(e.stepName));case b.Illustration:return new Tr(t,e,t.getStepTags(e.stepName));case b.Picture:return new Rr(t,e,t.getStepTags(e.stepName));case b.Shape:return new $r(t,e,t.getStepTags(e.stepName));case b.Material:return new Nr(t,e,t.getStepTags(e.stepName));case b.Model:return new Qr(t,e,t.getStepTags(e.stepName));case b.Frame:return new di(t,e,t.getStepTags(e.stepName));case b.Module:return new zr(t,e,t.getStepTags(e.stepName));default:throw new Q(`Step type ${e.type} not yet supported in Core SDK`)}}}const pc=C.gql`
|
|
2172
2181
|
fragment CreateDesignTransaction on Transaction {
|
|
2173
2182
|
id
|
|
2174
2183
|
designName
|
|
@@ -2193,8 +2202,8 @@
|
|
|
2193
2202
|
externalProductVariantId
|
|
2194
2203
|
}
|
|
2195
2204
|
}
|
|
2196
|
-
`,
|
|
2197
|
-
${
|
|
2205
|
+
`,fc=C.gql`
|
|
2206
|
+
${pc}
|
|
2198
2207
|
mutation CreateDesigns($inputs: [DesignCreateInput]!) {
|
|
2199
2208
|
designCreateMany(inputs: $inputs) {
|
|
2200
2209
|
id
|
|
@@ -2207,7 +2216,7 @@
|
|
|
2207
2216
|
}
|
|
2208
2217
|
}
|
|
2209
2218
|
}
|
|
2210
|
-
`;function Re(
|
|
2219
|
+
`;function Re(a){const t=JSON.parse(atob(a.split(".")[1])).exp;return Math.floor(new Date().getTime()/1e3)>=t}const Cc=async(a,t)=>{const e={};try{if(t){const i=await t.loggedInBearerToken();e.Authorization=`Bearer ${i}`}else throw new Error}catch{const s=Object.entries(localStorage).find(([c,d])=>c.startsWith("CognitoIdentityServiceProvider")&&c.endsWith("idToken"))?.[0]||"",l=localStorage.getItem(s);l&&!Re(l)&&(e.Authorization=`Bearer ${l}`)}return(await t.getIntegration()).partner.beta&&(e["X-Spiff-Beta"]="true"),(await y.getShadowGraphqlClient().mutate({mutation:fc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{inputs:a.map(i=>({name:i.name,layouts:i.layouts,workflowId:i.workflowId,transactionId:i.transactionId,previewImage:i.previewImage,useThreeDimPreview:i.useThreeDimPreview,metadata:i.metadata,selectedVariants:i.selectedVariants}))},context:{headers:e}})).data?.designCreateMany},ba=(a,t,e)=>{const n=i=>{const o={};if(i.type==="Frame"){const s=a[i.stepName],l=i.data;if(!s||!s.image||l.hideImageInCart&&e)return o;o[`${i.stepTitle} image`]=s.image}if(i.type==="Illustration"){const s=a[i.stepName],l=i.data;if(!s||l.hideColorsInCart&&e||!s.colors)return o;if(s.colors.length>0){const c=s.colors.join(", ").toUpperCase();o[`${i.stepTitle} colors`]=c}}if(i.type==="Module"){const s=a[i.stepName],l=i.data;if(!s||s.text===void 0||s.text===null||l.hideTextInCart&&e)return o;o[`${i.stepTitle} text`]=s.text}if(i.type==="Text"){const s=a[i.stepName];if(!s)return o;const l=i.data;(!l.hideTextInCart||!e&&s.text!==void 0&&s.text!==null)&&(o[`${i.stepTitle} text`]=s.text),s.color&&(!l.hideColorInCart||!e)&&(o[`${i.stepTitle} color`]=s.color),s.strokeColor&&(!l.hideStrokeInCart||!e)&&(o[`${i.stepTitle} stroke`]=s.strokeColor)}return o},r={};return t.steps.forEach(i=>{Object.assign(r,n(i))}),r},wc=(a,t,e,n)=>{const r={};let i={};n&&(i=n);const s=t.steps.map(l=>l.stepTitle).filter((l,c,d)=>d.indexOf(l)==c);for(const l of s){if(Object.keys(a).includes(l)){const c=a[l],d=t.steps.find(u=>u.stepTitle===l);r[`${d?.stepTitle} selection`]={value:c[0].name,priceModifier:c[0].priceModifier}}for(const c of Object.keys(i))[`${l} color`,`${l} colors`,`${l} text`,`${l} image`].includes(c)&&(r[c]={value:i[c],priceModifier:0})}return r},yc=(a,t,e,n,r,i,o,s)=>{const l=t.basePrice||0,c=a.priceModifierTotal||0,d=wc(n,e,void 0,i),A=(D.getMap("transactionOwnerIds")||new Map).get(a.id),h={additionalExternalProductId:a.integrationProduct?.additionalExternalProductId,additionalExternalVariantId:a.integrationProduct?.additionalExternalVariantId,baseCost:l,designExternalVariants:a.designExternalVariants,designProductId:a.externalDesignProductId,designProductVariantId:a.externalDesignProductVariantId,event:"onComplete",exportedData:d,externalCartProductId:a.externalCartProductId,externalCartProductVariantId:a.externalCartProductVariantId,lineItemImageUrl:o||"",optionsCost:c,processExecutionId:s,quantity:a.quantity,transactionId:a.id,transactionOwnerId:A,weight:t.weight,workflowViewerLink:a.workflowViewerLink||"",workflowViewerReadOnlyLink:a.workflowViewerReadOnlyLink||""};return i&&(h.metadata=i),n&&(h.selectedVariants=n),r&&(h.sku=r),h},Sc=async(a,t,e,n,r,i,o,s,l,c)=>{c&&(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(n())),await a.updateStateWithServerImmediate(n),console.log("Server state is undefined @ Workflow completion"));const d=a.getPreviewService(),u=t?.finalizeStepConfig?.lookAtAnimation,A=d&&t.showModelOnFinishStep&&!!u,h=l&&ba(l,t,!0),g=l&&ba(l,t,!1),m=async E=>{const I={};let N=0;if(Object.keys(i).length>0)for(const R of Object.keys(i)){const P=i[R],T=t.steps.find(V=>V.stepName===R);for(let V=0;V<P.selections.length;++V){const k=P.selections[V];if(T&&(!E||T.option&&(T.option.variants||[]).length>1&&!T.data.hideSelectionInCart&&!T.data.hideSelectionsInCart)){const W=T.stepTitle;I[W]?I[W].push({id:k.id||"",name:k.name,priceModifier:k.priceModifier}):I[W]=[{id:k.id||"",name:k.name,priceModifier:k.priceModifier}]}N+=k.priceModifier}}return[I,N]},[p]=await m(!0),f=Object.fromEntries(Object.keys(p).map(E=>[E,p[E].map(I=>I.id)])),[S]=await m(!1),w=Object.fromEntries(Object.keys(S).map(E=>[E,S[E].map(I=>I.id)]));let x=await s(A,r.id);if(x){const E=await(await rt(x)).blob();x=(await U.uploadAsset({name:`${r.id}-preview-image.png`,blob:E},ee.Image,!0,!1)).fileLink}return{designDetails:(()=>{const E={name:o,layouts:e.map(I=>({index:I.index,panelId:I.panelId})),workflowId:t.id,transactionId:r.id,useThreeDimPreview:!!A,previewImage:x};if(g){const I=[];for(const[N,R]of Object.entries(g))I.push({key:N,value:R});E.metadata=I}if(f){const I=[];for(const[N,R]of Object.entries(w))I.push({key:N,ids:R});E.selectedVariants=I}return E})(),cartSelectionsWithPrices:p,cartMetadata:h}},qr=async(a,t)=>{await Promise.all(a.map(async s=>{await s.workflowManager.outstandingRequestsPromise()}));const n=await(async()=>{const s=y.getShadowGraphqlClient(),l=await Promise.all(a.map(async A=>({id:A.transaction.id,hash:await A.workflowManager.getStateHash()}))),d=fn(l,100),u=[];for(const A of d){const h=await s.query({query:zo,variables:{transactions:A},fetchPolicy:"no-cache",errorPolicy:"all"});if(h.errors&&h.errors.length>0)return l.map(g=>g.id);u.push(...h.data?.transactionConfirmWorkflowStates??[])}return u})(),r=await Promise.all(a.map(async s=>await Sc(s.workflowManager,s.workflow,s.layouts,s.getReducerState,s.transaction,s.workflowSelections,s.designName,t??(()=>Promise.resolve(void 0)),s.workflowMetadata,n.includes(s.transaction.id)))),i=a[0].workflowManager.getClient(),o=await Cc(r.map(s=>s.designDetails),i);if(!o)throw new Error("Failed to create designs");return o.map((s,l)=>{const c=a[l],d=r[l],u=s.transaction;return yc(u,c.product,c.workflow,d.cartSelectionsWithPrices,s.sku,d.cartMetadata,u.previewImageLink,s.processExecution?.id)})};class vc{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=D.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new Q("Unexpected storage method requested")}async getSavedDesignByTransaction(t){return(await this.getSavedDesigns()).find(n=>n.transactionId===t)}async addDesign(t){const n=(await this.getSavedDesigns()).filter(r=>r.transactionId!==t.transactionId);n.unshift(t),await this.setDesigns(n),this.designSavedListeners.forEach(r=>r(t))}async renameDesign(t,e){const n=await this.getSavedDesigns(),r=n.find(i=>i.transactionId===t);if(!r)throw new Error(`No saved design for transaction ${t}.`);r.title=e,await this.setDesigns(n)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter(n=>n.transactionId!==t))}async setDesigns(t){if(this.storageMethod==="Local"){D.set(this.localPersistenceKey,JSON.stringify(t));return}throw new Q("Unexpected storage method requested")}}const xe=new vc,Ec=C.gql`
|
|
2211
2220
|
mutation AddTransactionStakeholder($id: String!, $type: String!, $details: CustomerDetailsInput!) {
|
|
2212
2221
|
transactionAddStakeholder(id: $id, details: $details, type: $type) {
|
|
2213
2222
|
id
|
|
@@ -2221,7 +2230,7 @@
|
|
|
2221
2230
|
}
|
|
2222
2231
|
}
|
|
2223
2232
|
}
|
|
2224
|
-
`,
|
|
2233
|
+
`,bc=C.gql`
|
|
2225
2234
|
mutation AddAddressToTransaction(
|
|
2226
2235
|
$transactionId: String!
|
|
2227
2236
|
$streetAddress: String
|
|
@@ -2243,13 +2252,13 @@
|
|
|
2243
2252
|
id
|
|
2244
2253
|
}
|
|
2245
2254
|
}
|
|
2246
|
-
`,
|
|
2255
|
+
`,Ic=C.gql`
|
|
2247
2256
|
mutation AddOrganizationToTransaction($transactionId: String!, $organizationName: String!) {
|
|
2248
2257
|
organizationAttachToTransaction(transactionId: $transactionId, organizationName: $organizationName) {
|
|
2249
2258
|
id
|
|
2250
2259
|
}
|
|
2251
2260
|
}
|
|
2252
|
-
`,
|
|
2261
|
+
`,Ia=C.gql`
|
|
2253
2262
|
${We}
|
|
2254
2263
|
${Ae}
|
|
2255
2264
|
mutation TransactionUpdateIntegrationProduct($id: String!, $integrationProductId: String) {
|
|
@@ -2337,7 +2346,7 @@
|
|
|
2337
2346
|
}
|
|
2338
2347
|
}
|
|
2339
2348
|
}
|
|
2340
|
-
`;var Oe=(n=>(n.PriceBreakChanged="PriceBreakChanged",n.ProductChanged="ProductChanged",n.QuantityChanged="QuantityChanged",n.RecipientChanged="RecipientChanged",n.SelectionChanged="SelectionChanged",n))(Oe||{});class Gr{constructor(t,e){this.cachedStepHandles=new Map,this.profanityList=[],this.currentPriceBreak=1,this.renderableScenes=[],this.renderableSceneCallbacks=[],this.eventCallbacks=new Map,this.debouncedSavedDesignUpdate=On(async()=>{await xe.getSavedDesignByTransaction(this.getTransaction().id)&&this.save()},2500),this.getCanvasObjectURLAsync=async a=>new Promise((r,i)=>{try{a.toBlob(o=>{if(o){const s=URL.createObjectURL(o);r(s)}})}catch(o){i(o)}}),this.client=t,this.transaction=e.transaction,this.workflow=e.workflow,this.profanityList=this.transaction.product?.profanities?.map(a=>a.word)||[],this.isReadOnly=e.transaction.isOrdered||!!e.readOnly,this.graphQlClient=e.graphQlClient,this.workflowManager=new xa(this,t,a=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(a)},e.graphQlClient,e.reloadedState,e.readOnly,e.modelContainer,e.isReloadedTransaction,e.singleVariantsRenderable,e.delayWorkflowStateSync),this.workflowManager.addSelectionCallback(a=>{const r=a.traversableScenes.map(i=>{const o=i.renderableSteps.map(s=>s.stepName);return{id:i.name,title:i.title,renderableSteps:o,workflowScene:i}});this.renderableScenes=r,this.renderableSceneCallbacks.forEach(i=>i(r)),this.callEvent("SelectionChanged")}),this.currentPriceBreak=this.priceBreakToBeApplied()}getTransaction(){return this.transaction}getProduct(){return this.transaction.product}getProfanityList(){return this.profanityList}async setProduct(t){this.workflow=void 0;const e=await this.graphQlClient().mutate({mutation:In,variables:{id:this.getTransaction().id,integrationProductId:t}}),a=e.data?.transactionUpdateIntegrationProduct.product;if(!a)throw new Q("Failed to set product. No product returned from server.");if(!this.bundle)throw new Q("Cannot set product on experience that is not part of a bundle.");this.transaction.product={...this.transaction.product,...e.data?.transactionUpdateIntegrationProduct.product},this.transaction.integrationProduct={...this.transaction.integrationProduct,...e.data?.transactionUpdateIntegrationProduct.integrationProduct},this.transaction.workflowState=void 0,this.currentPriceBreak=this.priceBreakToBeApplied(),this.callEvent("ProductChanged");const r=(await this.bundle.getProductCollection().fetchProducts()).find(i=>i.getId()===a.id);try{const i=r?.getDefaultWorkflow();if(i){const o=await ni(i.getId());await this.setWorkflow(o),console.log("Setting Product - Workflow set to default for product.")}}catch{console.log("Setting Product - No default workflow available, must be set manually.")}}async clearProduct(){if(!this.bundle)throw new Q("Cannot clear product on experience that is not part of a bundle.");this.workflow=void 0,this.transaction.workflowState=void 0,this.transaction.product=void 0,this.transaction.integrationProduct=void 0,this.currentPriceBreak=this.priceBreakToBeApplied(),this.callEvent("ProductChanged"),await this.graphQlClient().mutate({mutation:In,variables:{id:this.getTransaction().id}})}getWorkflow(){return this.workflow}async setWorkflow(t){return this.workflow=t,await this.graphQlClient().mutate({mutation:Oo,variables:{id:this.getTransaction().id,workflowId:t.id}}),this.workflowManager.setWorkflow(t)}async attachAddress(t,e,a,r,i,o){await this.graphQlClient().mutate({mutation:vc,variables:{transactionId:this.getTransaction().id,streetAddress:t||void 0,apartment:e||void 0,city:a||void 0,country:r||void 0,state:i||void 0,postCode:o||void 0}})}async attachOrganization(t){await this.graphQlClient().mutate({mutation:Ec,variables:{transactionId:this.getTransaction().id,organizationName:t}})}getBundle(){return this.bundle}setBundle(t){this.bundle=t}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.workflowManager.getCommandContext()}getWorkflowManager(){return this.workflowManager}async createPreviewImage(t,e){const a=this.getWorkflow(),r=a?.finalizeStepConfig?.lookAtAnimation;if(!a)throw new Error("Failed to generate cart preview image! No workflow is set.");if(t){if(!r)throw new Error("Failed to generate cart preview image! No camera orientation configured.");return await this.workflowManager.getPreviewService()?.renderSceneScreenshot(e??512,r)||""}let i=2048;e&&e<=2048&&(i=e);const o=Ct(i,i),s=this.workflowManager.getCommandContext().getAllLayouts(),l=a.defaultPreviewPanelIndex||0,c=a.panels[l],d=s.find(w=>w.layoutState?.layout.panelId===c?.name)||s[0],u=d.layoutState.layout.previewRegion?{x:d.layoutState.layout.previewRegion.left,y:d.layoutState.layout.previewRegion.top,width:d.layoutState.layout.previewRegion.width,height:d.layoutState.layout.previewRegion.height}:{x:0,y:0,width:d.layoutState.layout.width,height:d.layoutState.layout.height},A=this.workflowManager.getCommandContext().getLayoutById(d.layoutState.layout.id),h=o.getContext("2d");if(!h)throw new Le("Failed to obtain 2D context for preview image creation");const g=this.workflowManager.getTemplatingContext(),m=Ye(A.layoutState.layout,A.layoutState.elements,{renderingConfiguration:{purpose:Nt.Print,region:{left:u.x,top:u.y,width:u.width,height:u.height},templatingContext:g}}),p=Yn(m);await(await Ta.Pith.from(h,p,{anonymousCrossOrigin:!0,ignoreDimensions:!1,createCanvas:Ct,createImage:ce,DOMParser:Oa(),fetch})).render();const S=await this.getCanvasObjectURLAsync(o);return o.toDataURL(S)}getStepById(t){const e=this.getWorkflow()?.steps.find(i=>i.stepName===t);if(!e||!this.stepHasHandle(e))return;const a=this.cachedStepHandles.get(e.stepName);if(a)return a;const r=Ee.get(this.getWorkflowManager(),e);return this.cachedStepHandles.set(e.stepName,r),r}getSteps(){return this.getScenes().flatMap(t=>this.getStepsByScene(t))}getStepsConditionallyActive(){return this.getScenes().flatMap(t=>this.getStepsByScene(t).filter(e=>bt(e.getRaw(),this.getWorkflowManager().getStepSelections())))}getScenes(){return(this.getWorkflow()?.stepGroups||[]).map(e=>({id:e.id,name:e.name,stepIds:e.stepNames}))}getSelectionPriceSubunits(t){const e=this.getWorkflowManager().getWorkflowSelections();let a=0;return Object.values(e).forEach(r=>{a+=r.selections.reduce((i,o)=>i+(o.priceModifier||0),0)}),this.getPriceSubUnitsAfterPriceBreaks(a,t)}getBasePriceSubunits(t,e){const a=this.getPriceSubUnitsAfterPriceBreaks(this.getProduct()?.basePrice||0,e);if(t){const r=this.getAdditionalProductPriceSubunits(e)||0;return a+r}return a}getAdditionalProductPriceSubunits(t){const e=this.getTransaction().integrationProduct;if(e?.additionalIntegrationProduct?.product){const a=e.additionalIntegrationProduct.product.basePrice||0;return this.getPriceSubUnitsAfterPriceBreaks(a,t)}}getTotalPriceSubunits(t){return this.getBasePriceSubunits(!1,t)+this.getSelectionPriceSubunits(t)}getPriceSubUnitsAfterPriceBreaks(t,e){const a=e?1:this.priceBreakToBeApplied(),r=t*a;return Math.ceil(r)}priceBreakToBeApplied(){const t=(this.getProduct()?.priceBreaks||[]).sort((r,i)=>-(r.minQty-i.minQty)),a=[...this.getMatchingExperiencesFromBundle(),this].reduce((r,i)=>r+i.getQuantity(),0);for(const r of t)if(r.minQty<=a)return r.percentage;return 1}checkForPriceBreakChanges(){const t=this.priceBreakToBeApplied();this.currentPriceBreak!==t&&(this.updatePriceBreak(t),this.getMatchingExperiencesFromBundle().forEach(e=>e.updatePriceBreak(t)))}getMatchingExperiencesFromBundle(){return(this.bundle?.getWorkflowExperiences()||[]).filter(t=>{const e=t.getTransaction().id,a=this.getTransaction().id,r=t.getProduct()?.id,i=this.getProduct()?.id;return e!==a&&r===i})}updatePriceBreak(t){this.currentPriceBreak=t,this.callEvent("PriceBreakChanged")}async copySelectionsViaGlobalConfiguration(t,e,a){const r=await t.getGlobalProperties(),i=a?.map(c=>c.getId()),o=this.getSteps().filter(c=>i===void 0||i.includes(c.getId())),s=e.getSteps(),l=c=>r.find(d=>d.getRawProperty().name===c.aspectName);o.forEach(c=>{const d=new Set,u=c.getRaw().globalPropertyAspectConfigurations;u!==void 0&&(u.forEach(A=>d.add(JSON.stringify(A))),s.forEach(A=>{const h=A.getRaw().globalPropertyAspectConfigurations;h!==void 0&&h.forEach(g=>{const m=l(g),p=d.has(JSON.stringify(g));if(p&&m?.getType()==="Option"){const f=A.getCurrentVariant();if(!f)return;c.selectVariant(f),d.delete(JSON.stringify(g))}else if(p&&m?.getType()==="Text"){const f=A.getText();c.setText(f),d.delete(JSON.stringify(g))}})}))})}getStepByName(t){const e=this.getWorkflow()?.steps.find(a=>a.stepTitle===t);if(!(!e||!this.stepHasHandle(e)))return Ee.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflow()?.steps.filter(e=>e.type===t).map(e=>Ee.get(this.getWorkflowManager(),e))||[]}getStepsByScene(t){if(!this.getWorkflow()?.stepGroups.find(a=>a.name===t.name))throw new Error("Given scene is not present on workflow! Be careful when persisting scenes that you only use them with the relevant workflow.");return t.stepIds.map(a=>this.getWorkflow()?.steps.find(r=>r.stepName===a)).filter(a=>this.stepHasHandle(a)).map(a=>Ee.get(this.getWorkflowManager(),a))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){const a=(await this.graphQlClient().mutate({mutation:Sc,variables:{id:this.getTransaction().id,details:t,type:"Owner"}})).data?.transactionAddStakeholder?.stakeholders?.find(r=>r.customer?.emailAddress===t.emailAddress);if(a?.customer){this.getWorkflowManager().setTransactionCustomer(a.customer);const r=D.getMap("transactionCustomerIds")||new Map;r.set(this.getTransaction().id,a.customer.id),D.setMap("transactionCustomerIds",r)}}attachRenderableSceneListener(t){this.renderableSceneCallbacks.push(t),t(this.renderableScenes)}detachRenderableSceneListener(t){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter(e=>e!==t)}async save(t){const e=this.getProduct(),a=this.getWorkflow(),r=this.getCommandContext().getState();if(!e)throw new Q("Product undefined!");if(!a)throw new Q("Workflow undefined!");if(!r)throw new Q("State undefined!");const o={title:await(async()=>{if(t)return t;const s=this.getTransaction().id,c=(await xe.getSavedDesigns()).find(d=>d.transactionId===s)?.title;return c||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getTransaction().id,productId:e.id,integrationProductId:this.getTransaction().integrationProduct.id,workflowName:a.name,workflowId:a.id,lastEdited:new Date};return await xe.addDesign(o),o}async copy(){const t=It(this.getCommandContext().getState());if(!t)throw new Q("Internal state is undefined! Cannot copy experience!");const e=JSON.stringify(t.transaction),a=this.getWorkflow();if(!a)throw new Q("Workflow is undefined! Cannot copy experience!");const r=this.getTransaction().integrationProduct?.id;if(!r)throw new Q("Integration product id is undefined!");return await this.getClient().getWorkflowExperience({type:"integration",integrationProductId:r,workflowId:a.id,workflowState:e})}async onDesignFinished(t=!0){const e=this.getTransaction(),a=this.getProduct(),r=this.getWorkflow();if(!a)throw new Q("Product undefined! Cannot finish an experience without a product.");if(!r)throw new Q("Workflow undefined! Cannot finish an experience without a workflow.");return e.completed?(await this.graphQlClient().mutate({mutation:jo,variables:{transactionId:e.id}}),{event:"",exportedData:{},lineItemImageUrl:"",optionsCost:0,transactionId:e.id,workflowViewerLink:"",workflowViewerReadOnlyLink:""}):(await qr([{workflowManager:this.workflowManager,workflow:r,layouts:this.workflowManager.getLayouts(),getReducerState:()=>this.workflowManager.getCommandContext().getState(),product:a,transaction:e,workflowSelections:this.workflowManager.getWorkflowSelections(),workflowMetadata:this.workflowManager.getWorkflowMetadata(),designName:r.name}],o=>t?this.createPreviewImage(o,1024):Promise.resolve(void 0)))[0]}stepHasHandle(t){return t.type!==b.SilentIllustration&&t.type!==b.ProductOverlay}getExportedStepData(){const t=this.getWorkflow(),e=this.getWorkflowManager().getWorkflowMetadata(),a=this.getWorkflowManager().getWorkflowSelections(),r=[];return t?.steps.forEach(i=>{const o=i.stepName,s=e[o],l=a[o]?.selections[0],c={stepId:o,title:i.stepTitle,properties:[]};if(l&&Ic(i,a)&&c.properties.push({type:"selection",value:l.name,priceModifier:l.priceModifier}),!s){r.push(c);return}switch(i.type){case b.Frame:{const d=i.data,u=s;u.image&&d.displayImageOnFinishStep&&c.properties.push({type:"image",value:u.image,priceModifier:0})}break;case b.Illustration:{const d=i.data,u=s;if(u&&u.colors&&u.colors.length>0&&d.displayColorsOnFinishStep){const A=u.colors.join(", ").toUpperCase();c.properties.push({type:"color",value:A,priceModifier:0})}}break;case b.Module:{const d=i.data,u=s;u&&u.text&&d.displayTextOnFinishStep&&c.properties.push({type:"text",value:u.text,priceModifier:0})}break;case b.Text:{const d=i.data,u=s;u&&u.text&&d.displayTextOnFinishStep&&c.properties.push({type:"text",value:u.text,priceModifier:0}),u&&u.color&&d.displayColorOnFinishStep&&c.properties.push({type:"color",value:u.color,priceModifier:0})}}r.push(c)}),r.filter(i=>i.properties&&i.properties.length>0)}getQuantity(){return this.getTransaction().quantity||1}async setQuantity(t){if(t<1)throw new RangeError("WorkflowExperience quantity must be greater than zero.");if(this.isReadOnly)throw new Error("Cannot update quantity on a read-only WorkflowExperience");this.getTransaction().quantity=t,this.callEvent("QuantityChanged"),this.checkForPriceBreakChanges();const e=this.getTransaction();await this.graphQlClient().mutate({mutation:Ro,variables:{id:e.id,quantity:t}})}addEventListener(t,e){const a=this.eventCallbacks.get(t)||[];a.push(e),this.eventCallbacks.set(t,a)}removeEventListener(t,e){const a=this.eventCallbacks.get(t)||[];this.eventCallbacks.set(t,a.filter(r=>r!==e))}callEvent(t){(this.eventCallbacks.get(t)||[]).forEach(e=>e(this))}}const bc=n=>{if([b.Question,b.Frame,b.Illustration,b.Material,b.Model,b.Picture,b.Shape,b.Text].includes(n.type)){const e=n.data;return!!e.displaySelectionOnFinishStep||!!e.displaySelectionsOnFinishStep}return!1},Ic=(n,t)=>{if(!bc(n))return!1;if(n.option&&(n.option.variants||[]).length>1){const e=t[n.stepName];return!!(e&&e.selections.length>0)}return!1};class Bc{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(){if(!this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration)return[];await this.bundle.getGlobalPropertyStateManager().getInitializationPromise();const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map(e=>this.getHandle(e)))}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.conditionMode===$n.AND?Array.prototype.every.bind(t.conditions):Array.prototype.some.bind(t.conditions))(r=>{const i=e.aspects.find(o=>o.name===r.targetAspectName);return i?r.requiredVariantSelections.some(o=>o===i.value):!1})}async createHandle(t){switch(t.type){case z.FileUpload:return new jr(this.bundle,t).initialize();case z.ColorOption:return new Fa(this.bundle,t,t.entityId?await Y.getOption(t.entityId):void 0);case z.Option:{const e=t.entityId?await Y.getOption(t.entityId):void 0;return e?.type==="Color"?new Fa(this.bundle,t,e):new tn(this.bundle,t,e)}case z.Text:return new Wr(this.bundle,t);default:throw new Error("Unhandled Global Property Aspect Type")}}}class _e{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}isMandatory(){return!!this.property.mandatory}isMandatoryFulfilled(){return!this.property.mandatory||!!this.bundle.getGlobalPropertyStateManager().getAspectMandatoryFulfilled(this.property.name)}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap(r=>r.getStepsConditionallyActive().filter(i=>i.getOverrideGlobalPropertyConfiguration(this.property.type)?!1:i.getRaw().globalPropertyAspectConfigurations?.some(o=>o.globalPropertyConfigurationId===this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration?.id&&o.aspectName===this.property.name)))}getStateValue(){return this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name)}}class jr extends _e{constructor(t,e){super(t,e)}async initialize(){return this.property.data?.fileUpload?.colorOptionId&&(this.colorOption=await Y.getOption(this.property.data?.fileUpload?.colorOptionId)),await this.loadImageData(),this}async loadImageData(){const t=await this.getImage();if(t?.fileLink)if(t?.fileLink.endsWith(".svg")){const e=await et(t?.fileLink),a=await Ga(t?.fileLink),r=a.width,i=a.height,o=await it(e);this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name)?.colors?.forEach(c=>{o.colors[c.key]={browserValue:c.browserValue,pmsValue:c.pmsValue}});const l={src:t?.fileLink,width:r,height:i,aspect:r/i,svg:o.svg,colors:o.colors};dt.set(t?.fileLink,l),this.imageData=l}else this.imageData=void 0}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},void 0),this.applyImageSelection(t),this.loadImageData()])}async canUseBackgroundRemover(){return this.bundle.getClient().canUseAddon($e.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(),r=await U.removeBackgroundFromAsset(e),o={...a.getAspectStorage(this.property.name),backgroundRemovedAssetKey:r.key,useOriginalAsset:!t},l=[t?a.setAspect(this.property.name,r.key,o):a.setAspectStorage(this.property.name,o)];return t&&(l.push(this.applyImageSelection(r,void 0,!1,!1)),l.push(this.loadImageData())),await Promise.all(l),this.updateSharedStepStorage(o),r}hasImage(){return!!this.getStateValue()}async getImage(){const t=this.getStateValue();if(t)return U.getLocalOrFromServer(t)}async getImageWithColors(){return await this.loadImageData(),this.imageData?.svg?qe(je(this.imageData.svg,this.imageData.colors??{},!1)):this.imageData?.src}async getOriginalImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t?.originalAssetKey)return U.getLocalOrFromServer(t.originalAssetKey)}async getBackgroundRemovedImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t?.backgroundRemovedAssetKey)return U.getLocalOrFromServer(t.backgroundRemovedAssetKey)}getUseOriginalImage(){return this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name)?.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(),r=a.getAspectStorage(this.property.name);if(r?.useOriginalAsset===t)return;const i={...r,useOriginalAsset:t},o=t?r?.originalAssetKey:r?.backgroundRemovedAssetKey,s=[a.setAspect(this.property.name,o||"",i)];if(t)s.push(this.applyImageSelection(e,void 0,!1,!1));else{const l=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)};s.push(l())}s.push(this.loadImageData()),await Promise.all(s),this.updateSharedStepStorage(i)}async applyGlobalState(t){const e=this.getStateValue();if(!e)return;const a=await U.getLocalOrFromServer(e);if(!a)return;await this.applyImageSelection(a,t,!1,!0);const r=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(r){if(this.updateSharedStepStorage({...r}),r.colors){const i=new Map(r.colors.map(o=>[o.key,{browserValue:o.browserValue,pmsValue:o.pmsValue}])??[]);this.getSharedSteps(t).forEach(o=>{o.changeColors(i)})}}else this.updateSharedStepStorage({originalAssetKey:e}),await this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{originalAssetKey:e})}getAvailableColors(){return this.property.data?.fileUpload?.colorPickerEnabled?this.colorOption?.variants?.map(t=>({fill:t.color,stroke:t.color,variant:t,pmsValue:t.name}))??[]:[]}getCurrentColors(){return this.imageData?.colors}isColorPickerEnabled(){return this.property.data?.fileUpload?.colorPickerEnabled??!1}isPmsPickerEnabled(){return this.property.data?.fileUpload?.pmsPickerEnabled??!1}async getOriginalColors(){return this.imageData?.svg?(await it(this.imageData.svg)).colors:void 0}async changeColors(t){if(!this.imageData?.svg)return;const e=this.getSharedSteps(),a=new Map(Object.entries(t));e.forEach(i=>{i.changeColors(a)});const r=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{...r,colors:Object.entries(t).map(([i,o])=>({key:i,browserValue:o.browserValue,pmsValue:o.pmsValue}))}),await this.loadImageData()])}async applyImageSelection(t,e,a=!0,r=!0){const o=this.getSharedSteps(e).map(s=>{const l=s;if(l.getFrameService())return l.selectImage(t,a,r)});await Promise.all(o)}updateSharedStepStorage(t){this.bundle.getWorkflowExperiences().forEach(a=>a.getSteps().forEach(r=>{if(r.getOverrideGlobalPropertyConfiguration(this.property.type))return;r.getRaw().globalPropertyAspectConfigurations?.some(o=>o.globalPropertyConfigurationId===this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration?.id&&o.aspectName===this.property.name)&&a.getWorkflowManager().updateStorage(r.getId(),{framePatternData:{originalAssetKey:t.originalAssetKey,backgroundRemovedAssetKey:t.backgroundRemovedAssetKey,useOriginalAsset:t.useOriginalAsset}})}))}}class Wr extends _e{constructor(t,e){super(t,e)}isTemplatingEnabled(){return this.property.data?.text?.templatingEnabled||!1}getText(){const t=this.getStateValue();return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t,void 0,void 0),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 r=this.getSharedSteps(e).map(i=>{i.setText(t)});await Promise.all(r)}}class tn extends _e{constructor(t,e,a){super(t,e),this.optionResource=a}async initDefaultVariant(){const t=this.optionResource?.variants?.find(e=>e.id===this.optionResource?.defaultVariant?.id);t&&await this.selectVariant(new nt(t))}getCurrentVariant(){if(!this.optionResource)return;const t=this.getStateValue();if(t){const e=this.optionResource.variants?.find(a=>a.id===t);return e?new nt(e):void 0}else{const e=this.optionResource.variants?.find(a=>a.id===this.optionResource?.defaultVariant?.id);return e?new nt(e):void 0}}getAvailableVariants(){return(this.optionResource?.variants?.filter(e=>e.enabled)||[]).map(e=>new nt(e))}getAllVariants(){return(this.optionResource?.variants||[]).map(e=>new nt(e))}async selectVariant(t,e){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId(),void 0,e),this.applyVariantSelection(t)])}async applyGlobalState(t){const e=this.getStateValue();if(!e)return Promise.resolve();const a=this.optionResource?.variants?.find(r=>r.id===e);return a?this.applyVariantSelection(new nt(a),t):Promise.resolve()}async applyVariantSelection(t,e){const r=this.getSharedSteps(e).map(i=>i.selectVariant(t));await Promise.all(r)}}class Fa extends tn{constructor(t,e,a){super(t,e,a)}async selectVariant(t,e){await this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId(),void 0,e),await this.applyColorVariant(t,void 0,e)}async applyGlobalState(t){const e=this.getStateValue();if(!e)return Promise.resolve();const a=this.optionResource?.variants?.find(i=>i.id===e);if(!a)return Promise.resolve();await this.applyColorVariant(new nt(a),t);const r=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name)?.customColor;r&&this.setCustomColor(r)}async applyColorVariant(t,e,a){const i=this.getSharedSteps(e).map(o=>{switch(o.getType()){case b.Shape:return o.selectVariant(t);case b.Text:return o.setFillColor({fill:t.getColor(),stroke:t.getColor(),variant:t.getResource()});case b.Illustration:return o.setColor(a?.toString()||"",t.getColor()||"")}});await Promise.all(i)}setCustomColor(t){this.getCurrentVariant()?.getColor()&&this.getCurrentVariant().getColor().toLowerCase()==="#custom"&&this.getSharedSteps().forEach(a=>a.setCustomColor(t)),this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{customColor:t})}getCustomColor(){return this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name)?.customColor||this.getCurrentVariant()?.getColor()||"#ffffff"}}const Pc=(n,t,e,a)=>n.flatMap(r=>r.getSteps()).filter(r=>r.getGlobalPropertyAspects(t).includes(e)&&r.getType()===a),xc=(n,t,e)=>{const r=Pc(n,t,e,b.Illustration).map(i=>{const o=i.getCurrentVariant()?.getAssetResource(),s=i.getColors();return!o?.assetConfiguration||!s?0:Object.getOwnPropertyNames(s).length});return Math.max(...r)};function Da(n,t){function e(a){if(typeof a>"u"||!Array.isArray(a)&&!Dc(a))return a;if(Array.isArray(a))return Da(a,t);let r={};for(const[i,o]of Object.entries(a))r[i]=Fc(o)?o:Da(o,t);return Ni(r,t)}return Array.isArray(n)?n.map(e):e(n)}function Fc(n){return n==null}function Dc(n){return typeof n=="object"&&!Array.isArray(n)&&n!==null}function Hr(n){const t=new Map;return n?.aspects?.forEach(e=>{e.value!==""&&t.set(e.name,!0)}),t}function be(n){return Da(n,["__typename"])}class kc{constructor(t,e,a,r,i){this.mandatoryFulfilledAspects=new Map,this.bundleId=t,this.bundleOwnerId=e,this.configuration=a,this.bundleOptions=i;const o=i?.existingGlobalPropertyState;this.initPromise=o?Promise.resolve(o).then(()=>{console.log("Setting global property state to existing state."),this.globalPropertyState=be(o),this.recalculateMandatoryStates()}):this.createGlobalPropertyState().then(s=>{console.log("Setting global property state to new state."),this.globalPropertyState=be(s),this.recalculateMandatoryStates()}),this.onGlobalPropertyStateChange=r}async clearAspects(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects;this.globalPropertyState.aspects=e.filter(a=>!t.includes(a.name))}recalculateMandatoryStates(){this.mandatoryFulfilledAspects=Hr(this.globalPropertyState)}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=It(this.globalPropertyState);this.globalPropertyState={...be(t),id:e.id},this.recalculateMandatoryStates(),await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(e,this.globalPropertyState)}getAspectMandatoryFulfilled(t){return this.mandatoryFulfilledAspects.get(t)}getAspect(t,e){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const a=this.globalPropertyState.aspects.find(r=>r.name===t&&r.channel===e);if(a)return a.value}getAspectStorage(t,e){if(!this.globalPropertyState)throw new Error("Global property state not initialized");return this.globalPropertyState.aspects.find(a=>a.name===t&&a.channel===e)?.storage}async setAspect(t,e,a,r){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 i=this.configuration.aspects.find(l=>l.name===t);if(!i)throw new Error(`Failed to find configuration aspect with name: ${t}`);this.mandatoryFulfilledAspects.set(t,e!=="");const o=It(this.globalPropertyState),s=this.globalPropertyState.aspects.filter(l=>l.name===t);if(s.length>0)if(r){const l=s.find(c=>c.channel===r);if(l)l.value=e,l.type=i.type,l.channel=r,a!==void 0&&(l.storage=a!==null?a:void 0);else{if(r===1){const c=this.globalPropertyState.aspects.findIndex(d=>!d.channel&&d.name===t);c&&c>0&&this.globalPropertyState.aspects.splice(c,1)}this.globalPropertyState.aspects.push({name:t,value:e,type:i.type,storage:a!==null?a:void 0,channel:r})}}else{const l=s[0];l.value=e,l.type=i.type,a!==void 0&&(l.storage=a!==null?a:void 0)}else this.globalPropertyState.aspects.push({name:t,value:e,type:i.type,storage:a!==null?a:void 0,channel:r});te(o,this.globalPropertyState)||(await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(o,this.globalPropertyState))}async setAspectStorage(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 r=this.configuration.aspects.find(s=>s.name===t);if(!r)throw new Error(`Failed to find configuration aspect with name: ${t}`);const i=It(this.globalPropertyState),o=this.globalPropertyState.aspects.filter(s=>s.name===t);if(o.length>0)if(a){const s=o.find(l=>l.channel===a);s&&(s.storage=e!==null?e:void 0,s.type=r.type)}else{const s=o[0];s.storage=e!==null?e:void 0,s.type=r.type}else this.globalPropertyState.aspects.push({name:t,value:"",type:r.type,storage:e!==null?e:void 0,channel:a});te(i,this.globalPropertyState)||(await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(i,this.globalPropertyState))}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await y.getShadowGraphqlClient().mutate({mutation:Nl,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects.map(e=>{let a=e.type&&e.storage?{}:void 0;if(a)switch(e.type){case z.FileUpload:{a.fileUpload=e.storage;break}case z.Option:{a.option=e.storage;break}case z.ColorOption:{a=e.storage;break}}return{name:e.name,value:e.value,type:e.type,storage:a,channel:e.channel}})},context:{headers:{bundleOwnerId:this.bundleOwnerId,...this.bundleOptions?.additionalHeaders}}});if(t.data?.globalPropertyStateUpdate)this.globalPropertyState=be(t.data.globalPropertyStateUpdate);else throw new Error("Unable to update global property state")}async createGlobalPropertyState(){const t=await y.getShadowGraphqlClient().mutate({mutation:Tl,variables:{bundleId:this.bundleId},context:{headers:{bundleOwnerId:this.bundleOwnerId,...this.bundleOptions?.additionalHeaders}}});if(t.data?.globalPropertyStateCreate&&t.data.globalPropertyStateCreate.id)return t.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}class Mc{constructor(t){this.setState(t||'{"transactions": []}')}setState(t){t&&(this.state=JSON.parse(t))}getState(){return this.state}applyStateToWorkflowExperience(t){if(!this.state||!t?.getWorkflowManager()?.getModelContainer())return;const e=this.state.transactions.find(o=>o.transactionId===t.getTransaction().id);if(!e)return;const a=this.getTransformToApply(e);if(!a)return;const r=this.flipTransform(a,t.getWorkflowManager().getPreviewService()),i=t.getWorkflowManager().getModelContainer();i.position=r.position,i.rotation=r.rotation,i.scale=r.scale}getTransformToApply(t){return t.activeTransform&&t.transforms?t.transforms[t.activeTransform]:t.transform}updateWorkflowExperienceTransform(t,e,a){const r=t.getTransaction().id;this.state?this.state.transactions||(this.state.transactions=[]):this.state={transactions:[]};const i=this.state.transactions.find(o=>o.transactionId===r);i?(i.transforms||(i.transforms={}),i.transforms[e]=a):this.state.transactions.push({transactionId:r,activeTransform:e,transforms:{[e]:a}})}activateWorkflowExperienceTransform(t,e){if(!t?.getWorkflowManager()?.getModelContainer()||!this.state)return;const a=t.getTransaction().id,r=this.state.transactions.find(l=>l.transactionId===a),i=r?.transforms?.[e];if(!i)return;const o=this.flipTransform(i,t.getWorkflowManager().getPreviewService()),s=t.getWorkflowManager().getModelContainer();s.position=o.position,s.rotation=o.rotation,s.scale=o.scale,r.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 this.deleteFieldNameFromObjectRecursive(this.state,"__typename"),JSON.stringify(this.state)}deleteFieldNameFromObjectRecursive(t,e){if(!(typeof t!="object"||t===null))for(const a in t)a===e?delete t[a]:this.deleteFieldNameFromObjectRecursive(t[a],e)}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}}}const Tc=C.gql`
|
|
2349
|
+
`;var Oe=(a=>(a.PriceBreakChanged="PriceBreakChanged",a.ProductChanged="ProductChanged",a.QuantityChanged="QuantityChanged",a.RecipientChanged="RecipientChanged",a.SelectionChanged="SelectionChanged",a))(Oe||{});class Gr{constructor(t,e){this.cachedStepHandles=new Map,this.profanityList=[],this.currentPriceBreak=1,this.renderableScenes=[],this.renderableSceneCallbacks=[],this.eventCallbacks=new Map,this.debouncedSavedDesignUpdate=Oa(async()=>{await xe.getSavedDesignByTransaction(this.getTransaction().id)&&this.save()},2500),this.getCanvasObjectURLAsync=async n=>new Promise((r,i)=>{try{n.toBlob(o=>{if(o){const s=URL.createObjectURL(o);r(s)}})}catch(o){i(o)}}),this.client=t,this.transaction=e.transaction,this.workflow=e.workflow,this.profanityList=this.transaction.product?.profanities?.map(n=>n.word)||[],this.isReadOnly=e.transaction.isOrdered||!!e.readOnly,this.graphQlClient=e.graphQlClient,this.workflowManager=new Fn(this,t,n=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(n)},e.graphQlClient,e.reloadedState,e.readOnly,e.modelContainer,e.isReloadedTransaction,e.singleVariantsRenderable,e.delayWorkflowStateSync),this.workflowManager.addSelectionCallback(n=>{const r=n.traversableScenes.map(i=>{const o=i.renderableSteps.map(s=>s.stepName);return{id:i.name,title:i.title,renderableSteps:o,workflowScene:i}});this.renderableScenes=r,this.renderableSceneCallbacks.forEach(i=>i(r)),this.callEvent("SelectionChanged")}),this.currentPriceBreak=this.priceBreakToBeApplied()}getTransaction(){return this.transaction}getProduct(){return this.transaction.product}getProfanityList(){return this.profanityList}async setProduct(t){this.workflow=void 0;const e=await this.graphQlClient().mutate({mutation:Ia,variables:{id:this.getTransaction().id,integrationProductId:t}}),n=e.data?.transactionUpdateIntegrationProduct.product;if(!n)throw new Q("Failed to set product. No product returned from server.");if(!this.bundle)throw new Q("Cannot set product on experience that is not part of a bundle.");this.transaction.product={...this.transaction.product,...e.data?.transactionUpdateIntegrationProduct.product},this.transaction.integrationProduct={...this.transaction.integrationProduct,...e.data?.transactionUpdateIntegrationProduct.integrationProduct},this.transaction.workflowState=void 0,this.currentPriceBreak=this.priceBreakToBeApplied(),this.callEvent("ProductChanged");const r=(await this.bundle.getProductCollection().fetchProducts()).find(i=>i.getId()===n.id);try{const i=r?.getDefaultWorkflow();if(i){const o=await ai(i.getId());await this.setWorkflow(o),console.log("Setting Product - Workflow set to default for product.")}}catch{console.log("Setting Product - No default workflow available, must be set manually.")}}async clearProduct(){if(!this.bundle)throw new Q("Cannot clear product on experience that is not part of a bundle.");this.workflow=void 0,this.transaction.workflowState=void 0,this.transaction.product=void 0,this.transaction.integrationProduct=void 0,this.currentPriceBreak=this.priceBreakToBeApplied(),this.callEvent("ProductChanged"),await this.graphQlClient().mutate({mutation:Ia,variables:{id:this.getTransaction().id}})}getWorkflow(){return this.workflow}async setWorkflow(t){return this.workflow=t,await this.graphQlClient().mutate({mutation:$o,variables:{id:this.getTransaction().id,workflowId:t.id}}),this.workflowManager.setWorkflow(t)}async attachAddress(t,e,n,r,i,o){await this.graphQlClient().mutate({mutation:bc,variables:{transactionId:this.getTransaction().id,streetAddress:t||void 0,apartment:e||void 0,city:n||void 0,country:r||void 0,state:i||void 0,postCode:o||void 0}})}async attachOrganization(t){await this.graphQlClient().mutate({mutation:Ic,variables:{transactionId:this.getTransaction().id,organizationName:t}})}getBundle(){return this.bundle}setBundle(t){this.bundle=t}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.workflowManager.getCommandContext()}getWorkflowManager(){return this.workflowManager}async createPreviewImage(t,e){const n=this.getWorkflow(),r=n?.finalizeStepConfig?.lookAtAnimation;if(!n)throw new Error("Failed to generate cart preview image! No workflow is set.");if(t){if(!r)throw new Error("Failed to generate cart preview image! No camera orientation configured.");return await this.workflowManager.getPreviewService()?.renderSceneScreenshot(e??512,r)||""}let i=2048;e&&e<=2048&&(i=e);const o=Ct(i,i),s=this.workflowManager.getCommandContext().getAllLayouts(),l=n.defaultPreviewPanelIndex||0,c=n.panels[l],d=s.find(w=>w.layoutState?.layout.panelId===c?.name)||s[0],u=d.layoutState.layout.previewRegion?{x:d.layoutState.layout.previewRegion.left,y:d.layoutState.layout.previewRegion.top,width:d.layoutState.layout.previewRegion.width,height:d.layoutState.layout.previewRegion.height}:{x:0,y:0,width:d.layoutState.layout.width,height:d.layoutState.layout.height},A=this.workflowManager.getCommandContext().getLayoutById(d.layoutState.layout.id),h=o.getContext("2d");if(!h)throw new Le("Failed to obtain 2D context for preview image creation");const g=this.workflowManager.getTemplatingContext(),m=Ye(A.layoutState.layout,A.layoutState.elements,{renderingConfiguration:{purpose:Nt.Print,region:{left:u.x,top:u.y,width:u.width,height:u.height},templatingContext:g}}),p=Ya(m);await(await Nn.Pith.from(h,p,{anonymousCrossOrigin:!0,ignoreDimensions:!1,createCanvas:Ct,createImage:ce,DOMParser:$n(),fetch})).render();const S=await this.getCanvasObjectURLAsync(o);return o.toDataURL(S)}getStepById(t){const e=this.getWorkflow()?.steps.find(i=>i.stepName===t);if(!e||!this.stepHasHandle(e))return;const n=this.cachedStepHandles.get(e.stepName);if(n)return n;const r=Ee.get(this.getWorkflowManager(),e);return this.cachedStepHandles.set(e.stepName,r),r}getSteps(){return this.getScenes().flatMap(t=>this.getStepsByScene(t))}getStepsConditionallyActive(){return this.getScenes().flatMap(t=>this.getStepsByScene(t).filter(e=>bt(e.getRaw(),this.getWorkflowManager().getStepSelections())))}getScenes(){return(this.getWorkflow()?.stepGroups||[]).map(e=>({id:e.id,name:e.name,stepIds:e.stepNames}))}getSelectionPriceSubunits(t){const e=this.getWorkflowManager().getWorkflowSelections();let n=0;return Object.values(e).forEach(r=>{n+=r.selections.reduce((i,o)=>i+(o.priceModifier||0),0)}),this.getPriceSubUnitsAfterPriceBreaks(n,t)}getBasePriceSubunits(t,e){const n=this.getPriceSubUnitsAfterPriceBreaks(this.getProduct()?.basePrice||0,e);if(t){const r=this.getAdditionalProductPriceSubunits(e)||0;return n+r}return n}getAdditionalProductPriceSubunits(t){const e=this.getTransaction().integrationProduct;if(e?.additionalIntegrationProduct?.product){const n=e.additionalIntegrationProduct.product.basePrice||0;return this.getPriceSubUnitsAfterPriceBreaks(n,t)}}getTotalPriceSubunits(t){return this.getBasePriceSubunits(!1,t)+this.getSelectionPriceSubunits(t)}getPriceSubUnitsAfterPriceBreaks(t,e){const n=e?1:this.priceBreakToBeApplied(),r=t*n;return Math.ceil(r)}priceBreakToBeApplied(){const t=(this.getProduct()?.priceBreaks||[]).sort((r,i)=>-(r.minQty-i.minQty)),n=[...this.getMatchingExperiencesFromBundle(),this].reduce((r,i)=>r+i.getQuantity(),0);for(const r of t)if(r.minQty<=n)return r.percentage;return 1}checkForPriceBreakChanges(){const t=this.priceBreakToBeApplied();this.currentPriceBreak!==t&&(this.updatePriceBreak(t),this.getMatchingExperiencesFromBundle().forEach(e=>e.updatePriceBreak(t)))}getMatchingExperiencesFromBundle(){return(this.bundle?.getWorkflowExperiences()||[]).filter(t=>{const e=t.getTransaction().id,n=this.getTransaction().id,r=t.getProduct()?.id,i=this.getProduct()?.id;return e!==n&&r===i})}updatePriceBreak(t){this.currentPriceBreak=t,this.callEvent("PriceBreakChanged")}async copySelectionsViaGlobalConfiguration(t,e,n){const r=await t.getGlobalProperties(),i=n?.map(c=>c.getId()),o=this.getSteps().filter(c=>i===void 0||i.includes(c.getId())),s=e.getSteps(),l=c=>r.find(d=>d.getRawProperty().name===c.aspectName);o.forEach(c=>{const d=new Set,u=c.getRaw().globalPropertyAspectConfigurations;u!==void 0&&(u.forEach(A=>d.add(JSON.stringify(A))),s.forEach(A=>{const h=A.getRaw().globalPropertyAspectConfigurations;h!==void 0&&h.forEach(g=>{const m=l(g),p=d.has(JSON.stringify(g));if(p&&m?.getType()==="Option"){const f=A.getCurrentVariant();if(!f)return;c.selectVariant(f),d.delete(JSON.stringify(g))}else if(p&&m?.getType()==="Text"){const f=A.getText();c.setText(f),d.delete(JSON.stringify(g))}})}))})}getStepByName(t){const e=this.getWorkflow()?.steps.find(n=>n.stepTitle===t);if(!(!e||!this.stepHasHandle(e)))return Ee.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflow()?.steps.filter(e=>e.type===t).map(e=>Ee.get(this.getWorkflowManager(),e))||[]}getStepsByScene(t){if(!this.getWorkflow()?.stepGroups.find(n=>n.name===t.name))throw new Error("Given scene is not present on workflow! Be careful when persisting scenes that you only use them with the relevant workflow.");return t.stepIds.map(n=>this.getWorkflow()?.steps.find(r=>r.stepName===n)).filter(n=>this.stepHasHandle(n)).map(n=>Ee.get(this.getWorkflowManager(),n))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){const n=(await this.graphQlClient().mutate({mutation:Ec,variables:{id:this.getTransaction().id,details:t,type:"Owner"}})).data?.transactionAddStakeholder?.stakeholders?.find(r=>r.customer?.emailAddress===t.emailAddress);if(n?.customer){this.getWorkflowManager().setTransactionCustomer(n.customer);const r=D.getMap("transactionCustomerIds")||new Map;r.set(this.getTransaction().id,n.customer.id),D.setMap("transactionCustomerIds",r)}}attachRenderableSceneListener(t){this.renderableSceneCallbacks.push(t),t(this.renderableScenes)}detachRenderableSceneListener(t){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter(e=>e!==t)}async save(t){const e=this.getProduct(),n=this.getWorkflow(),r=this.getCommandContext().getState();if(!e)throw new Q("Product undefined!");if(!n)throw new Q("Workflow undefined!");if(!r)throw new Q("State undefined!");const o={title:await(async()=>{if(t)return t;const s=this.getTransaction().id,c=(await xe.getSavedDesigns()).find(d=>d.transactionId===s)?.title;return c||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getTransaction().id,productId:e.id,integrationProductId:this.getTransaction().integrationProduct.id,workflowName:n.name,workflowId:n.id,lastEdited:new Date};return await xe.addDesign(o),o}async copy(){const t=It(this.getCommandContext().getState());if(!t)throw new Q("Internal state is undefined! Cannot copy experience!");const e=JSON.stringify(t.transaction),n=this.getWorkflow();if(!n)throw new Q("Workflow is undefined! Cannot copy experience!");const r=this.getTransaction().integrationProduct?.id;if(!r)throw new Q("Integration product id is undefined!");return await this.getClient().getWorkflowExperience({type:"integration",integrationProductId:r,workflowId:n.id,workflowState:e})}async onDesignFinished(t=!0){const e=this.getTransaction(),n=this.getProduct(),r=this.getWorkflow();if(!n)throw new Q("Product undefined! Cannot finish an experience without a product.");if(!r)throw new Q("Workflow undefined! Cannot finish an experience without a workflow.");return e.completed?(await this.graphQlClient().mutate({mutation:Wo,variables:{transactionId:e.id}}),{event:"",exportedData:{},lineItemImageUrl:"",optionsCost:0,transactionId:e.id,workflowViewerLink:"",workflowViewerReadOnlyLink:""}):(await qr([{workflowManager:this.workflowManager,workflow:r,layouts:this.workflowManager.getLayouts(),getReducerState:()=>this.workflowManager.getCommandContext().getState(),product:n,transaction:e,workflowSelections:this.workflowManager.getWorkflowSelections(),workflowMetadata:this.workflowManager.getWorkflowMetadata(),designName:r.name}],o=>t?this.createPreviewImage(o,1024):Promise.resolve(void 0)))[0]}stepHasHandle(t){return t.type!==b.SilentIllustration&&t.type!==b.ProductOverlay}getExportedStepData(){const t=this.getWorkflow(),e=this.getWorkflowManager().getWorkflowMetadata(),n=this.getWorkflowManager().getWorkflowSelections(),r=[];return t?.steps.forEach(i=>{const o=i.stepName,s=e[o],l=n[o]?.selections[0],c={stepId:o,title:i.stepTitle,properties:[]};if(l&&Pc(i,n)&&c.properties.push({type:"selection",value:l.name,priceModifier:l.priceModifier}),!s){r.push(c);return}switch(i.type){case b.Frame:{const d=i.data,u=s;u.image&&d.displayImageOnFinishStep&&c.properties.push({type:"image",value:u.image,priceModifier:0})}break;case b.Illustration:{const d=i.data,u=s;if(u&&u.colors&&u.colors.length>0&&d.displayColorsOnFinishStep){const A=u.colors.join(", ").toUpperCase();c.properties.push({type:"color",value:A,priceModifier:0})}}break;case b.Module:{const d=i.data,u=s;u&&u.text&&d.displayTextOnFinishStep&&c.properties.push({type:"text",value:u.text,priceModifier:0})}break;case b.Text:{const d=i.data,u=s;u&&u.text&&d.displayTextOnFinishStep&&c.properties.push({type:"text",value:u.text,priceModifier:0}),u&&u.color&&d.displayColorOnFinishStep&&c.properties.push({type:"color",value:u.color,priceModifier:0})}}r.push(c)}),r.filter(i=>i.properties&&i.properties.length>0)}getQuantity(){return this.getTransaction().quantity||1}async setQuantity(t){if(t<1)throw new RangeError("WorkflowExperience quantity must be greater than zero.");if(this.isReadOnly)throw new Error("Cannot update quantity on a read-only WorkflowExperience");this.getTransaction().quantity=t,this.callEvent("QuantityChanged"),this.checkForPriceBreakChanges();const e=this.getTransaction();await this.graphQlClient().mutate({mutation:Oo,variables:{id:e.id,quantity:t}})}addEventListener(t,e){const n=this.eventCallbacks.get(t)||[];n.push(e),this.eventCallbacks.set(t,n)}removeEventListener(t,e){const n=this.eventCallbacks.get(t)||[];this.eventCallbacks.set(t,n.filter(r=>r!==e))}callEvent(t){(this.eventCallbacks.get(t)||[]).forEach(e=>e(this))}}const Bc=a=>{if([b.Question,b.Frame,b.Illustration,b.Material,b.Model,b.Picture,b.Shape,b.Text].includes(a.type)){const e=a.data;return!!e.displaySelectionOnFinishStep||!!e.displaySelectionsOnFinishStep}return!1},Pc=(a,t)=>{if(!Bc(a))return!1;if(a.option&&(a.option.variants||[]).length>1){const e=t[a.stepName];return!!(e&&e.selections.length>0)}return!1};class xc{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(){if(!this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration)return[];await this.bundle.getGlobalPropertyStateManager().getInitializationPromise();const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map(e=>this.getHandle(e)))}applyConditionsFromState(t,e){return e?t.filter(n=>this.aspectConditionsSatisfied(n.getRawProperty(),e)):t}aspectConditionsSatisfied(t,e){return!t.conditions||t.conditions.length===0?!0:(t.conditionMode===$a.AND?Array.prototype.every.bind(t.conditions):Array.prototype.some.bind(t.conditions))(r=>{const i=e.aspects.find(o=>o.name===r.targetAspectName);return i?r.requiredVariantSelections.some(o=>o===i.value):!1})}async createHandle(t){switch(t.type){case z.FileUpload:return new jr(this.bundle,t).initialize();case z.ColorOption:return new Dn(this.bundle,t,t.entityId?await Y.getOption(t.entityId):void 0);case z.Option:{const e=t.entityId?await Y.getOption(t.entityId):void 0;return e?.type==="Color"?new Dn(this.bundle,t,e):new ea(this.bundle,t,e)}case z.Text:return new Wr(this.bundle,t);default:throw new Error("Unhandled Global Property Aspect Type")}}}class _e{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}isMandatory(){return!!this.property.mandatory}isMandatoryFulfilled(){return!this.property.mandatory||!!this.bundle.getGlobalPropertyStateManager().getAspectMandatoryFulfilled(this.property.name)}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap(r=>r.getStepsConditionallyActive().filter(i=>i.getOverrideGlobalPropertyConfiguration(this.property.type)?!1:i.getRaw().globalPropertyAspectConfigurations?.some(o=>o.globalPropertyConfigurationId===this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration?.id&&o.aspectName===this.property.name)))}getStateValue(){return this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name)}}class jr extends _e{constructor(t,e){super(t,e)}async initialize(){return this.property.data?.fileUpload?.colorOptionId&&(this.colorOption=await Y.getOption(this.property.data?.fileUpload?.colorOptionId)),await this.loadImageData(),this}async loadImageData(){const t=await this.getImage();if(t?.fileLink)if(t?.fileLink.endsWith(".svg")){const e=await et(t?.fileLink),n=await jn(t?.fileLink),r=n.width,i=n.height,o=await it(e);this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name)?.colors?.forEach(c=>{o.colors[c.key]={browserValue:c.browserValue,pmsValue:c.pmsValue}});const l={src:t?.fileLink,width:r,height:i,aspect:r/i,svg:o.svg,colors:o.colors};dt.set(t?.fileLink,l),this.imageData=l}else this.imageData=void 0}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},void 0),this.applyImageSelection(t),this.loadImageData()])}async canUseBackgroundRemover(){return this.bundle.getClient().canUseAddon($e.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 n=this.bundle.getGlobalPropertyStateManager(),r=await U.removeBackgroundFromAsset(e),o={...n.getAspectStorage(this.property.name),backgroundRemovedAssetKey:r.key,useOriginalAsset:!t},l=[t?n.setAspect(this.property.name,r.key,o):n.setAspectStorage(this.property.name,o)];return t&&(l.push(this.applyImageSelection(r,void 0,!1,!1)),l.push(this.loadImageData())),await Promise.all(l),this.updateSharedStepStorage(o),r}hasImage(){return!!this.getStateValue()}async getImage(){const t=this.getStateValue();if(t)return U.getLocalOrFromServer(t)}async getImageWithColors(){return await this.loadImageData(),this.imageData?.svg?qe(je(this.imageData.svg,this.imageData.colors??{},!1)):this.imageData?.src}async getOriginalImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t?.originalAssetKey)return U.getLocalOrFromServer(t.originalAssetKey)}async getBackgroundRemovedImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t?.backgroundRemovedAssetKey)return U.getLocalOrFromServer(t.backgroundRemovedAssetKey)}getUseOriginalImage(){return this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name)?.useOriginalAsset??!1}async setUseOriginalImage(t){const e=await this.getOriginalImage();if(!e)throw new Error("You must select an image before calling setUseOriginalImage");const n=this.bundle.getGlobalPropertyStateManager(),r=n.getAspectStorage(this.property.name);if(r?.useOriginalAsset===t)return;const i={...r,useOriginalAsset:t},o=t?r?.originalAssetKey:r?.backgroundRemovedAssetKey,s=[n.setAspect(this.property.name,o||"",i)];if(t)s.push(this.applyImageSelection(e,void 0,!1,!1));else{const l=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)};s.push(l())}s.push(this.loadImageData()),await Promise.all(s),this.updateSharedStepStorage(i)}async applyGlobalState(t){const e=this.getStateValue();if(!e)return;const n=await U.getLocalOrFromServer(e);if(!n)return;await this.applyImageSelection(n,t,!1,!0);const r=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(r){if(this.updateSharedStepStorage({...r}),r.colors){const i=new Map(r.colors.map(o=>[o.key,{browserValue:o.browserValue,pmsValue:o.pmsValue}])??[]);this.getSharedSteps(t).forEach(o=>{o.changeColors(i)})}}else this.updateSharedStepStorage({originalAssetKey:e}),await this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{originalAssetKey:e})}getAvailableColors(){return this.property.data?.fileUpload?.colorPickerEnabled?this.colorOption?.variants?.map(t=>({fill:t.color,stroke:t.color,variant:t,pmsValue:t.name}))??[]:[]}getCurrentColors(){return this.imageData?.colors}isColorPickerEnabled(){return this.property.data?.fileUpload?.colorPickerEnabled??!1}isPmsPickerEnabled(){return this.property.data?.fileUpload?.pmsPickerEnabled??!1}async getOriginalColors(){return this.imageData?.svg?(await it(this.imageData.svg)).colors:void 0}async changeColors(t){if(!this.imageData?.svg)return;const e=this.getSharedSteps(),n=new Map(Object.entries(t));e.forEach(i=>{i.changeColors(n)});const r=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{...r,colors:Object.entries(t).map(([i,o])=>({key:i,browserValue:o.browserValue,pmsValue:o.pmsValue}))}),await this.loadImageData()])}async applyImageSelection(t,e,n=!0,r=!0){const o=this.getSharedSteps(e).map(s=>{const l=s;if(l.getFrameService())return l.selectImage(t,n,r)});await Promise.all(o)}updateSharedStepStorage(t){this.bundle.getWorkflowExperiences().forEach(n=>n.getSteps().forEach(r=>{if(r.getOverrideGlobalPropertyConfiguration(this.property.type))return;r.getRaw().globalPropertyAspectConfigurations?.some(o=>o.globalPropertyConfigurationId===this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration?.id&&o.aspectName===this.property.name)&&n.getWorkflowManager().updateStorage(r.getId(),{framePatternData:{originalAssetKey:t.originalAssetKey,backgroundRemovedAssetKey:t.backgroundRemovedAssetKey,useOriginalAsset:t.useOriginalAsset}})}))}}class Wr extends _e{constructor(t,e){super(t,e)}isTemplatingEnabled(){return this.property.data?.text?.templatingEnabled||!1}getText(){const t=this.getStateValue();return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t,void 0,void 0),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 r=this.getSharedSteps(e).map(i=>{i.setText(t)});await Promise.all(r)}}class ea extends _e{constructor(t,e,n){super(t,e),this.optionResource=n}async initDefaultVariant(){const t=this.optionResource?.variants?.find(e=>e.id===this.optionResource?.defaultVariant?.id);t&&await this.selectVariant(new at(t))}getCurrentVariant(){if(!this.optionResource)return;const t=this.getStateValue();if(t){const e=this.optionResource.variants?.find(n=>n.id===t);return e?new at(e):void 0}else{const e=this.optionResource.variants?.find(n=>n.id===this.optionResource?.defaultVariant?.id);return e?new at(e):void 0}}getAvailableVariants(){return(this.optionResource?.variants?.filter(e=>e.enabled)||[]).map(e=>new at(e))}getAllVariants(){return(this.optionResource?.variants||[]).map(e=>new at(e))}async selectVariant(t,e){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId(),void 0,e),this.applyVariantSelection(t)])}async applyGlobalState(t){const e=this.getStateValue();if(!e)return Promise.resolve();const n=this.optionResource?.variants?.find(r=>r.id===e);return n?this.applyVariantSelection(new at(n),t):Promise.resolve()}async applyVariantSelection(t,e){const r=this.getSharedSteps(e).map(i=>i.selectVariant(t));await Promise.all(r)}}class Dn extends ea{constructor(t,e,n){super(t,e,n)}async selectVariant(t,e){await this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId(),void 0,e),await this.applyColorVariant(t,void 0,e)}async applyGlobalState(t){const e=this.getStateValue();if(!e)return Promise.resolve();const n=this.optionResource?.variants?.find(i=>i.id===e);if(!n)return Promise.resolve();await this.applyColorVariant(new at(n),t);const r=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name)?.customColor;r&&this.setCustomColor(r)}async applyColorVariant(t,e,n){const i=this.getSharedSteps(e).map(o=>{switch(o.getType()){case b.Shape:return o.selectVariant(t);case b.Text:return o.setFillColor({fill:t.getColor(),stroke:t.getColor(),variant:t.getResource()});case b.Illustration:return o.setColor(n?.toString()||"",t.getColor()||"")}});await Promise.all(i)}setCustomColor(t){this.getCurrentVariant()?.getColor()&&this.getCurrentVariant().getColor().toLowerCase()==="#custom"&&this.getSharedSteps().forEach(n=>n.setCustomColor(t)),this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{customColor:t})}getCustomColor(){return this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name)?.customColor||this.getCurrentVariant()?.getColor()||"#ffffff"}}const Fc=(a,t,e,n)=>a.flatMap(r=>r.getSteps()).filter(r=>r.getGlobalPropertyAspects(t).includes(e)&&r.getType()===n),Dc=(a,t,e)=>{const r=Fc(a,t,e,b.Illustration).map(i=>{const o=i.getCurrentVariant()?.getAssetResource(),s=i.getColors();return!o?.assetConfiguration||!s?0:Object.getOwnPropertyNames(s).length});return Math.max(...r)};function kn(a,t){function e(n){if(typeof n>"u"||!Array.isArray(n)&&!Mc(n))return n;if(Array.isArray(n))return kn(n,t);let r={};for(const[i,o]of Object.entries(n))r[i]=kc(o)?o:kn(o,t);return Qi(r,t)}return Array.isArray(a)?a.map(e):e(a)}function kc(a){return a==null}function Mc(a){return typeof a=="object"&&!Array.isArray(a)&&a!==null}function Hr(a){const t=new Map;return a?.aspects?.forEach(e=>{e.value!==""&&t.set(e.name,!0)}),t}function be(a){return kn(a,["__typename"])}class Tc{constructor(t,e,n,r,i){this.mandatoryFulfilledAspects=new Map,this.bundleId=t,this.bundleOwnerId=e,this.configuration=n,this.bundleOptions=i;const o=i?.existingGlobalPropertyState;this.initPromise=o?Promise.resolve(o).then(()=>{console.log("Setting global property state to existing state."),this.globalPropertyState=be(o),this.recalculateMandatoryStates()}):this.createGlobalPropertyState().then(s=>{console.log("Setting global property state to new state."),this.globalPropertyState=be(s),this.recalculateMandatoryStates()}),this.onGlobalPropertyStateChange=r}async clearAspects(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects;this.globalPropertyState.aspects=e.filter(n=>!t.includes(n.name))}recalculateMandatoryStates(){this.mandatoryFulfilledAspects=Hr(this.globalPropertyState)}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=It(this.globalPropertyState);this.globalPropertyState={...be(t),id:e.id},this.recalculateMandatoryStates(),await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(e,this.globalPropertyState)}getAspectMandatoryFulfilled(t){return this.mandatoryFulfilledAspects.get(t)}getAspect(t,e){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const n=this.globalPropertyState.aspects.find(r=>r.name===t&&r.channel===e);if(n)return n.value}getAspectStorage(t,e){if(!this.globalPropertyState)throw new Error("Global property state not initialized");return this.globalPropertyState.aspects.find(n=>n.name===t&&n.channel===e)?.storage}async setAspect(t,e,n,r){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 i=this.configuration.aspects.find(l=>l.name===t);if(!i)throw new Error(`Failed to find configuration aspect with name: ${t}`);this.mandatoryFulfilledAspects.set(t,e!=="");const o=It(this.globalPropertyState),s=this.globalPropertyState.aspects.filter(l=>l.name===t);if(s.length>0)if(r){const l=s.find(c=>c.channel===r);if(l)l.value=e,l.type=i.type,l.channel=r,n!==void 0&&(l.storage=n!==null?n:void 0);else{if(r===1){const c=this.globalPropertyState.aspects.findIndex(d=>!d.channel&&d.name===t);c&&c>0&&this.globalPropertyState.aspects.splice(c,1)}this.globalPropertyState.aspects.push({name:t,value:e,type:i.type,storage:n!==null?n:void 0,channel:r})}}else{const l=s[0];l.value=e,l.type=i.type,n!==void 0&&(l.storage=n!==null?n:void 0)}else this.globalPropertyState.aspects.push({name:t,value:e,type:i.type,storage:n!==null?n:void 0,channel:r});te(o,this.globalPropertyState)||(await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(o,this.globalPropertyState))}async setAspectStorage(t,e,n){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 r=this.configuration.aspects.find(s=>s.name===t);if(!r)throw new Error(`Failed to find configuration aspect with name: ${t}`);const i=It(this.globalPropertyState),o=this.globalPropertyState.aspects.filter(s=>s.name===t);if(o.length>0)if(n){const s=o.find(l=>l.channel===n);s&&(s.storage=e!==null?e:void 0,s.type=r.type)}else{const s=o[0];s.storage=e!==null?e:void 0,s.type=r.type}else this.globalPropertyState.aspects.push({name:t,value:"",type:r.type,storage:e!==null?e:void 0,channel:n});te(i,this.globalPropertyState)||(await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(i,this.globalPropertyState))}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await y.getShadowGraphqlClient().mutate({mutation:Ql,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects.map(e=>{let n=e.type&&e.storage?{}:void 0;if(n)switch(e.type){case z.FileUpload:{n.fileUpload=e.storage;break}case z.Option:{n.option=e.storage;break}case z.ColorOption:{n=e.storage;break}}return{name:e.name,value:e.value,type:e.type,storage:n,channel:e.channel}})},context:{headers:{bundleOwnerId:this.bundleOwnerId,...this.bundleOptions?.additionalHeaders}}});if(t.data?.globalPropertyStateUpdate)this.globalPropertyState=be(t.data.globalPropertyStateUpdate);else throw new Error("Unable to update global property state")}async createGlobalPropertyState(){const t=await y.getShadowGraphqlClient().mutate({mutation:Nl,variables:{bundleId:this.bundleId},context:{headers:{bundleOwnerId:this.bundleOwnerId,...this.bundleOptions?.additionalHeaders}}});if(t.data?.globalPropertyStateCreate&&t.data.globalPropertyStateCreate.id)return t.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}class Nc{constructor(t){this.setState(t||'{"transactions": []}')}setState(t){t&&(this.state=JSON.parse(t))}getState(){return this.state}applyStateToWorkflowExperience(t){if(!this.state||!t?.getWorkflowManager()?.getModelContainer())return;const e=this.state.transactions.find(o=>o.transactionId===t.getTransaction().id);if(!e)return;const n=this.getTransformToApply(e);if(!n)return;const r=this.flipTransform(n,t.getWorkflowManager().getPreviewService()),i=t.getWorkflowManager().getModelContainer();i.position=r.position,i.rotation=r.rotation,i.scale=r.scale}getTransformToApply(t){return t.activeTransform&&t.transforms?t.transforms[t.activeTransform]:t.transform}updateWorkflowExperienceTransform(t,e,n){const r=t.getTransaction().id;this.state?this.state.transactions||(this.state.transactions=[]):this.state={transactions:[]};const i=this.state.transactions.find(o=>o.transactionId===r);i?(i.transforms||(i.transforms={}),i.transforms[e]=n):this.state.transactions.push({transactionId:r,activeTransform:e,transforms:{[e]:n}})}activateWorkflowExperienceTransform(t,e){if(!t?.getWorkflowManager()?.getModelContainer()||!this.state)return;const n=t.getTransaction().id,r=this.state.transactions.find(l=>l.transactionId===n),i=r?.transforms?.[e];if(!i)return;const o=this.flipTransform(i,t.getWorkflowManager().getPreviewService()),s=t.getWorkflowManager().getModelContainer();s.position=o.position,s.rotation=o.rotation,s.scale=o.scale,r.activeTransform=e}removeStateForTransaction(t){if(!this.state||!this.state.transactions)return;const e=this.state.transactions.findIndex(n=>n.transactionId===t);e!==-1&&this.state.transactions.splice(e,1)}getSerializedState(){if(this.state)return this.deleteFieldNameFromObjectRecursive(this.state,"__typename"),JSON.stringify(this.state)}deleteFieldNameFromObjectRecursive(t,e){if(!(typeof t!="object"||t===null))for(const n in t)n===e?delete t[n]:this.deleteFieldNameFromObjectRecursive(t[n],e)}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}}}const Qc=C.gql`
|
|
2341
2350
|
query GetManyMetafields($entityIds: [String!]!) {
|
|
2342
2351
|
metafieldsMany(entityIds: $entityIds) {
|
|
2343
2352
|
id
|
|
@@ -2348,14 +2357,14 @@
|
|
|
2348
2357
|
}
|
|
2349
2358
|
}
|
|
2350
2359
|
}
|
|
2351
|
-
`;class
|
|
2360
|
+
`;class Rc{constructor(){this.internalMap=new Map}async requestKeysForEntity(t,e){const n=new Map;return await this.ensureIdsArePresent([t]),e.forEach(r=>{const i=this.requestKeyForEntityIfAvailable(t,r);i&&n.set(r,i)}),n}async ensureIdsArePresent(t){if(t.every(n=>this.internalMap.has(n)))return;const e=await y.getShadowGraphqlClient().query({query:Qc,errorPolicy:"all",variables:{entityIds:t.filter(n=>!this.internalMap.has(n))}});t.forEach((n,r)=>{const i=e.data.metafieldsMany[r];this.internalMap.set(n,i.map(o=>({key:o.metafieldConfiguration.name,value:o.value})))})}async requestKeyForEntity(t,e){if(!this.internalMap.has(t))return;let n=this.internalMap.get(t);const r=n.find(i=>i.key===e);return r||(await this.ensureIdsArePresent([t]),n=this.internalMap.get(t)),r?JSON.parse(r.value):void 0}requestKeyForEntityIfAvailable(t,e){if(!this.internalMap.has(t))return;const r=this.internalMap.get(t).find(i=>i.key===e);if(r)return JSON.parse(r.value)}}const Yr=new Rc;var Jr=(a=>(a.Default="Default",a.Name="Name",a.Price="Price",a))(Jr||{});class na{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||""}getDispatchStartDate(){if(this.collection.dispatchStartDate)return new Date(this.collection.dispatchStartDate)}getDispatchEndDate(){if(this.collection.dispatchEndDate)return new Date(this.collection.dispatchEndDate)}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.filter(t=>!!t.product).map(t=>new Ht(t))}async fetchProducts(t){if(this.fullFetched)return this.collection.productCollectionProducts.filter(n=>!!n.product).map(n=>new Ht(n));const e=await y.getShadowGraphqlClient().query({query:Vl,variables:{id:this.getId(),productIds:t},errorPolicy:"all"});return t||(this.fullFetched=!0),this.collection.productCollectionProducts=e.data.productCollections[0].productCollectionProducts||[],this.collection.productCollectionProducts.filter(n=>!!n.product).map(n=>new Ht(n))}async filterProducts(t,e,n,r){const i=await y.getShadowGraphqlClient().query({query:zl,errorPolicy:"all",variables:{id:this.getId(),filters:t?{link:"And",metafields:t}:void 0,tags:e?{include:e.include??[],exclude:e.exclude??[]}:void 0,sortKey:n,sortDescending:r}});if(!i.data?.productCollections||i.data?.productCollections.length===0)throw new Error("Failed to filter product collection products.");const o=this.getProducts(),s=i.data.productCollections[0].productCollectionProducts.map(l=>l.product.id);return o.filter(l=>s.includes(l.getId()))}async fetchProductsFeed(t,e,n,r,i,o,s,l){if(this.fullFetched){const A=await(n?this.filterProducts(n):this.fetchProducts());return{total:A.length,items:A.slice(t,t+e)}}const c=new AbortController,{signal:d}=c,u=y.getShadowGraphqlClient().watchQuery({query:ql,variables:{id:this.getId(),limit:e,offset:t,productFilters:n?{link:"And",metafields:n}:void 0,productWorkflowFilters:l?{link:"And",metafields:l}:void 0,tags:r?{include:r.include??[],exclude:r.exclude??[]}:void 0,sortKey:i,sortDescending:o,quickSearch:s},errorPolicy:"all",fetchPolicy:"cache-first",returnPartialData:!0,context:{fetchOptions:{signal:d}}});return new Promise(A=>{let h=!1;const g=u.subscribe({next(m){if(h||m.partial&&(!m.data.productCollections||m.data.productCollections.length===0||!m.data.productCollections[0].productCollectionProductsFeed?.items||m.data.productCollections[0].productCollectionProductsFeed?.items.length===0))return;c.abort(),h=!0,g.unsubscribe();const p=m.data.productCollections?.[0].productCollectionProductsFeed?.items.filter(f=>!!f.product).map(f=>new Ht(It(f)))||[];A({items:p,total:m.data.productCollections?.[0].productCollectionProductsFeed?.total??0})},error(){h||(h=!0,g.unsubscribe(),A({items:[],total:0}))}})})}getTransformCollection(){if(this.collection.transformCollection)return new Kr(this.collection.transformCollection)}getResource(){return this.collection}}class Ht{constructor(t){this.product=t.product,this.productResource=t}getId(){return this.product.id}getName(){return this.product.name}getIntegrationByType(t,e){const r=(this.product.integrationProducts||[]).find(i=>{const o=i.integration?.type,s=i.integration?.type===t,l=e?i.integration?.externalIntegrationId===e:!0;return o&&s&&l});if(!r)throw new Error("Failed to find requested integration type on product. This is generally due to a configuration error");return r}getCurrentIntegration(){const e=(this.product.integrationProducts||[]).find(n=>n.integration?.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 mt("Called getDefaultWorkflow() before fetching collection products. Use collection.fetchProducts() first to ensure the data is available.");if(t.length===0)throw new mt("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 n=t.find(r=>r.workflowName===e);if(n)return new Tt(n)}if(t.length===1)return new Tt(t[0]);throw new mt("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 mt("No workflows on configured product. Ensure at least 1 workflow is assigned to this product.");return this.product.workflows.sort((e,n)=>(e.index??0)-(n.index??0)).map(e=>new Tt(e))}getIntegrations(){return this.product.integrationProducts||[]}getResource(){return this.product}getBasePrice(t){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 n;return t.integrationId?n=this.product.integrationProducts?.find(r=>r.integration?.id===t.integrationId):t.externalId?n=this.product.integrationProducts?.find(r=>r.integration?.externalIntegrationId===t.externalId):n=this.product.integrationProducts?.find(r=>r.integration?.type===t.integrationType),n?.additionalIntegrationProduct?.product?e+(n.additionalIntegrationProduct.product.basePrice||0):e}async requestMetafields(t){return Yr.requestKeysForEntity(this.product.id,t)}}class Tt{constructor(t){this.workflow=t}getId(){return this.workflow.workflowName}getName(){return this.workflow.friendlyName}getThumbnail(){return this.workflow.imageUrl}}class Kr{constructor(t){this.collection=t}getId(){return this.collection.id}getName(){return this.collection.name}getTransforms(){return this.collection.transforms.map(t=>new _r(t))}}class _r{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}}}const Oc=C.gql`
|
|
2352
2361
|
${Ke(!1)}
|
|
2353
2362
|
query GetProductCollections($ids: [String!]!) {
|
|
2354
2363
|
productCollections(ids: $ids) {
|
|
2355
2364
|
...ProductCollectionFields
|
|
2356
2365
|
}
|
|
2357
2366
|
}
|
|
2358
|
-
|
|
2367
|
+
`,$c=async a=>(await y.getShadowGraphqlClient().query({query:Oc,errorPolicy:"all",variables:{ids:a}})).data?.productCollections?.map(e=>new na(e));class Uc{constructor(){this.listeners={}}on(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}off(t,e){this.listeners[t]&&(this.listeners[t]=this.listeners[t].filter(n=>n!==e))}emit(t,e){if(this.listeners[t])for(const n of this.listeners[t])n(e)}clear(t){if(t)delete this.listeners[t];else for(const e in this.listeners)delete this.listeners[e]}}const Lc=C.gql`
|
|
2359
2368
|
mutation AddAddressToBundle(
|
|
2360
2369
|
$bundleId: String!
|
|
2361
2370
|
$streetAddress: String
|
|
@@ -2377,26 +2386,26 @@
|
|
|
2377
2386
|
id
|
|
2378
2387
|
}
|
|
2379
2388
|
}
|
|
2380
|
-
`,
|
|
2389
|
+
`,Vc=C.gql`
|
|
2381
2390
|
mutation AddOrganizationToBundle($bundleId: String!, $organizationName: String!) {
|
|
2382
2391
|
organizationAttachToBundle(bundleId: $bundleId, organizationName: $organizationName) {
|
|
2383
2392
|
id
|
|
2384
2393
|
}
|
|
2385
2394
|
}
|
|
2386
|
-
`,
|
|
2395
|
+
`,zc=C.gql`
|
|
2387
2396
|
mutation GenerateQuoteId($id: String!) {
|
|
2388
2397
|
bundleGenerateQuoteId(id: $id) {
|
|
2389
2398
|
id
|
|
2390
2399
|
quoteId
|
|
2391
2400
|
}
|
|
2392
2401
|
}
|
|
2393
|
-
`;class Bn{constructor(t,e,a,r,i,o,s){this.workflowExperiences=[],this.eventEmitter=new Oc,this.updatesLocked=!1,this.client=t,this.id=e.id,this.name=e.name||"",this.dispatchDate=e.dispatchDate,this.template=e.template||!1,this.quoteId=e.quoteId,this.shareActions=e.bundleShareActions,this.workflowViewerLink=e.workflowViewerLink,this.workflowViewerAmendLink=e.workflowViewerAmendLink,this.ownerId=i,this.metadata=new Map(e.metadata?.map(d=>[d.key,d.value])||[]),this.completed=e.completed??!1,this.productCollection=e.productCollection,this.bundleStateManager=new Mc(e.bundleStateData);const l=this.productCollection?.globalPropertyConfiguration;this.globalConfigurationPropertyId=l?.id,this.globalPropertyStateManager=new kc(this.id,this.ownerId,l,this.onGlobalPropertiesChanged.bind(this),o),this.globalPropertyHandleService=new Bc(this),this.setPreviewService(a);const c=new Promise((d,u)=>{if(o?.readonly){d([]);return}console.log("Setting default global variants.");const A=this.globalPropertyStateManager.getGlobalPropertyState();A?this.globalPropertyHandleService.getHandles().then(h=>{const g=h.map(m=>{if(m.getType()===z.ColorOption||m.getType()===z.Option){const p=m;if(!A.aspects.find(S=>S.name===p.getName()))return p.initDefaultVariant()}});Promise.all(g).then(d).catch(u)}):(console.log("Attempted to set global default variant before state was initialized."),d([]))});this.initializationPromise=Promise.all([this.loadExistingWorkflowExperiences(e.transactionIds||[],{...r,bundleOwnerId:i},s),this.globalPropertyStateManager.getInitializationPromise()]).then(()=>c),this.initializationPromise.catch(d=>{console.error(`Bundle initialization failed: ${d}`)}),this.initializationPromise.then(()=>{this.getGlobalProperties().then(d=>this.checkMandatoryHandlesChanged(void 0,d))})}getIntegrationProductIds(){return this.bundleStateManager.getState()?.integrationProductIds}async addIntegrationProductId(t){const e=this.bundleStateManager.getState();if(e){if(!e.integrationProductIds)e.integrationProductIds=[];else if(e.integrationProductIds.some(r=>r===t)){this.fireEvent("bundle-integration-products-added",{integrationProductIds:e.integrationProductIds});return}e.integrationProductIds=[...e.integrationProductIds,t];const a=JSON.stringify(e);this.bundleStateManager.setState(a),this.fireEvent("bundle-integration-products-added",{integrationProductIds:e.integrationProductIds}),await y.getShadowGraphqlClient().mutate({mutation:ua,variables:{id:this.id,bundleStateData:a},context:{bundleOwnerId:this.ownerId}})}}async removeIntegrationProductIds(t){const e=this.bundleStateManager.getState();if(e){const a=t.filter(i=>(e.integrationProductIds??[]).includes(i));if(a.length===0)return;e.integrationProductIds=(e.integrationProductIds??[]).filter(i=>!a.includes(i));const r=JSON.stringify(e);this.bundleStateManager.setState(r),this.fireEvent("bundle-integration-products-removed",{integrationProductIds:a}),await y.getShadowGraphqlClient().mutate({mutation:ua,variables:{id:this.id,bundleStateData:r},context:{bundleOwnerId:this.ownerId}})}}getTemplate(){return this.template}async generateQuoteId(){const e=(await y.getShadowGraphqlClient().mutate({mutation:Lc,variables:{id:this.id},context:{bundleOwnerId:this.ownerId}})).data?.bundleGenerateQuoteId?.quoteId;return this.quoteId=e,e||""}async attachAddress(t,e,a,r,i,o){await y.getShadowGraphqlClient().mutate({mutation:$c,variables:{bundleId:this.id,streetAddress:t||void 0,apartment:e||void 0,city:a||void 0,country:r||void 0,state:i||void 0,postCode:o||void 0},context:{bundleOwnerId:this.ownerId}})}async attachOrganization(t){await y.getShadowGraphqlClient().mutate({mutation:Uc,variables:{bundleId:this.id,organizationName:t},context:{bundleOwnerId:this.ownerId}})}setBundleOptions(t){this.globalPropertyStateManager.setBundleOptions(t)}getInitializationPromise(){return this.initializationPromise}addEventListener(t,e){this.eventEmitter.on(t,e)}removeEventListener(t,e){this.eventEmitter.off(t,e)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}getQuoteId(){return this.quoteId}setName(t){return this.name=t,this.updateBundle()}getDispatchDate(){return this.dispatchDate}setDispatchDate(t){return this.dispatchDate=t,this.updateBundle()}getPurchaseOrder(){return this.purchaseOrder}setPurchaseOrder(t){return this.purchaseOrder=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(){return!!this.productCollection?.globalPropertyConfiguration}getGlobalPropertyConfiguration(){return this.productCollection?.globalPropertyConfiguration}async getGlobalProperties(){return this.globalPropertyHandleService.applyConditionsFromState(await this.globalPropertyHandleService.getHandles(),this.getGlobalPropertyStateManager().getGlobalPropertyState())}async applyGlobalPropertyState(t){this.updatesLocked=!0;const e=await this.globalPropertyHandleService.getHandles();try{for(const a of t.aspects){const r=a?.name;await this.getGlobalPropertyStateManager().setAspect(r,a.value)}for(const a of t.aspects){const r=a?.name,i=e.find(o=>o.getName()===r);if(i)switch(a.type){case z.FileUpload:{const o=i,s=await De([a.value]);s.length>0&&await o.selectImage(s[0]);const l=a.storage?.colors;if(l){const c=Object.fromEntries(l.map(d=>[d.key,{browserValue:d.browserValue,pmsValue:d.pmsValue}])??[]);await o.changeColors(c)}break}case z.ColorOption:{const o=i,l=o.getAllVariants().find(d=>d.getId()===a.value),c=a.storage?a.storage:void 0;l&&await o.selectVariant(l),c?.customColor&&o.setCustomColor(c.customColor);break}case z.Option:{const o=i,l=o.getAllVariants().find(c=>c.getId()===a.value);l&&await o.selectVariant(l);break}case z.Text:{await i.setText(a.value);break}}}}finally{this.updatesLocked=!1,this.onGlobalPropertiesChanged(void 0,this.globalPropertyStateManager.getGlobalPropertyState())}}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}async getGlobalPropertyTotalSubunits(){return(await this.globalPropertyHandleService.getHandles()).filter(a=>a.getType()===z.Option).map(a=>a.getCurrentVariant()?.getPrice()||0).reduce((a,r)=>a+r,0)}getTotalSubunits(){return this.workflowExperiences.map(t=>t.getTotalPriceSubunits()).reduce((t,e)=>t+e,0)}getProductCollection(){return this.productCollection?new en(this.productCollection):void 0}async initializeAdditionalRequiredColorChannels(t){for(const e of t.getStepsByType(b.Illustration)){const a=e.getGlobalPropertyAspects(this.globalConfigurationPropertyId||"");for(const r of a){const i=this.getGlobalPropertyConfiguration()?.aspects.find(o=>o.name===r);if(i&&i.type===z.ColorOption){const o=e.getCurrentVariant()?.getAssetResource(),s=o?.assetConfiguration?.channelNumbers||[],l=o?.assetConfiguration?.defaultColorVariants||[],c=xc(this.getWorkflowExperiences(),this.globalConfigurationPropertyId||"",r),d=[...new Set(s.map(A=>A.number))];if(d.length>c)for(const A of d){const h=this.getGlobalPropertyStateManager(),g=l.find(m=>m.channelNumber===A);g&&await h.setAspect(r,g.variant.id||"",void 0,g.channelNumber)}}}}}async addWorkflowExperience(t){await this.initializeAdditionalRequiredColorChannels(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]);this.fireEvent("workflow-experience-added",{workflowExperiences:[t]})}async addWorkflowExperiences(t){for(const s of t)await this.initializeAdditionalRequiredColorChannels(s);const e=t.map(s=>s.getTransaction().id),a=e.map(s=>this.workflowExperiences.find(l=>l.getTransaction().id===s));if(a.some(s=>!!s))throw new Error("Unable to add transaction to bundle - Already Exists: "+a.filter(s=>!!s).map(s=>s?.getTransaction().id).join(", "));const r=D.getMap("transactionOwnerIds")||new Map,i=e.map(s=>r.get(s));await y.getShadowGraphqlClient().mutate({mutation:Wl,variables:{id:this.id,transactionIds:e,transactionOwnerIds:i},context:{bundleOwnerId:this.ownerId}}).catch(s=>{console.error(s)}),this.workflowExperiences.push(...t);const o=async()=>{for(const l of t)l.setBundle(this),await this.injectExperienceIntoPreviewService(l);await Promise.all(t.map(l=>l.getWorkflowManager().getInitializationPromise()));const s=await this.getGlobalProperties();for(const l of s)await l.applyGlobalState(t)};await Promise.all([this.updateTransactionOrder(),o()]),this.workflowExperiences.forEach(s=>s.checkForPriceBreakChanges()),this.fireEvent("workflow-experience-added",{workflowExperiences:this.workflowExperiences})}async appendWorkflowExperience(t,e=!0){const a=t.getTransaction().id;if(this.workflowExperiences.find(s=>s.getTransaction().id===a))throw new Error("Unable to add transaction to bundle - Already Exists!");const o=(D.getMap("transactionOwnerIds")||new Map).get(a);await y.getShadowGraphqlClient().mutate({mutation:jl,variables:{id:this.id,transactionId:a},context:{bundleOwnerId:this.ownerId,transactionOwnerId:o}}),e&&(this.workflowExperiences.push(t),this.workflowExperiences.forEach(s=>s.checkForPriceBreakChanges()))}async removeWorkflowExperience(t){const e=this.workflowExperiences.indexOf(t);await this.removeTransaction(e,this.workflowExperiences[e].getTransaction()),this.fireEvent("workflow-experience-added",{workflowExperiences:[t]})}async removeWorkflowExperiences(t){await this.removeTransactions(t.map(e=>e.getTransaction()))}async removeWorkflowExperienceByTransaction(t){const e=this.workflowExperiences.findIndex(a=>a.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 r=this.workflowExperiences.find(i=>i.getTransaction().id===e.id);if(r.setBundle(void 0),this.previewService&&r.getWorkflowManager().ejectFromPreviewService(),this.bundleStateManager.removeStateForTransaction(e.id),await y.getShadowGraphqlClient().mutate({mutation:Hl,variables:{id:this.id,transactionId:e.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([i,o])=>({key:i,value:o})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),a){const i=this.workflowExperiences.splice(t,1);this.workflowExperiences.forEach(o=>o.checkForPriceBreakChanges()),r.checkForPriceBreakChanges(),await this.updateTransactionOrder(),this.fireEvent("workflow-experience-removed",{workflowExperiences:i})}}else throw new Error("Unable to remove workflow experience from bundle - Not Found! - "+e.id)}async removeTransactions(t){const e=t.map(r=>this.workflowExperiences.findIndex(i=>i.getTransaction().id===r.id));if(e.some(r=>r===-1))throw new Error("Unable to remove workflow experience from bundle - The following aren't included in the bundle: "+t.filter((r,i)=>e[i]===-1).map(r=>r.id).join(", "));const a=t.map(r=>this.workflowExperiences.splice(this.workflowExperiences.findIndex(i=>i.getTransaction().id===r.id),1)[0]);a.forEach(r=>r.setBundle(void 0)),[...this.workflowExperiences,...a].forEach(r=>r.checkForPriceBreakChanges()),this.previewService&&a.forEach(r=>r.getWorkflowManager().ejectFromPreviewService()),t.forEach(r=>this.bundleStateManager.removeStateForTransaction(r.id)),await y.getShadowGraphqlClient().mutate({mutation:Yl,variables:{id:this.id,transactionIds:t.map(r=>r.id),name:this.name,metadata:Array.from(this.metadata.entries()).map(([r,i])=>({key:r,value:i})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),this.fireEvent("workflow-experience-removed",{workflowExperiences:a}),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(r=>r.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.getTransaction().id===e.getTransaction().id)throw new Error("Unable to replace workflow experience in bundle - Same transaction!");await Promise.all([this.removeTransaction(t,a.getTransaction(),!1),this.appendWorkflowExperience(e,!1)]),this.workflowExperiences[t]=e,await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(e);const r=await this.getGlobalProperties();await Promise.all(r.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){const a=await y.getShadowGraphqlClient().mutate({mutation:Jl,variables:{id:this.id,details:t,type:e||ae.Owner},context:{bundleOwnerId:this.ownerId}});if(!a.data?.bundleAddStakeholder)throw new Error("Bundle not found!");const r=a.data.bundleAddStakeholder.bundleStakeholders||[];this.storeStakeholderCustomers(r)}async removeStakeholder(t){if(!(await y.getShadowGraphqlClient().mutate({mutation:Kl,variables:{id:this.id,emailAddress:t},context:{bundleOwnerId:this.ownerId}})).data?.bundleRemoveStakeholder)throw new Error("Bundle not found!")}async updateStakeholders(t){const e=await y.getShadowGraphqlClient().mutate({mutation:_l,variables:{id:this.id,input:t},context:{bundleOwnerId:this.ownerId}});if(!e.data?.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:vn,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:vn,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){this.completed&&await y.getShadowGraphqlClient().mutate({mutation:ac,variables:{bundleId:this.id}});const a=await qr(this.workflowExperiences.map(r=>{const i=r.getWorkflow();if(!i)throw new Error("Unable to create designs - Workflow not found!");const o=r.getProduct();if(!o)throw new Error("Unable to create designs - Product not found!");return{workflowManager:r.getWorkflowManager(),workflow:i,layouts:r.getWorkflowManager().getLayouts(),getReducerState:()=>r.getCommandContext().getState(),product:o,transaction:r.getTransaction(),workflowSelections:r.getWorkflowManager().getWorkflowSelections(),designName:i.name,workflowMetadata:r.getWorkflowManager().getWorkflowMetadata()}}),e?(r,i)=>{const o=this.workflowExperiences.find(s=>s.getTransaction().id===i);return o?e(o,r):(console.warn("SpiffCommerce - Bundle create design - Unable to find experience for transaction: "+i),Promise.resolve(void 0))}:void 0);return{bundleId:this.id,name:this.getName(),dispatchDate:this.getDispatchDate()||"",purchaseOrder:this.getPurchaseOrder()||"",collectionId:this.getProductCollection()?.getId()||"",collectionName:this.getProductCollection()?.getName()||"",items:a,bundleOwnerId:this.ownerId}}async placeOrder(){const t=this.workflowExperiences.map(e=>({transactionId:e.getTransaction().id,amountToOrder:e.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:tc,variables:{bundleId:this.id,globalPropertyConfigurationId:t},context:{bundleOwnerId:this.ownerId}}),this.globalConfigurationPropertyId=t}async assignProductCollection(t){const e=await y.getShadowGraphqlClient().mutate({mutation:Zl(this.globalPropertyStateManager.getBundleOptions()?.eagerFetchProducts??!1),variables:{id:this.id,productCollectionId:t??""},context:{bundleOwnerId:this.ownerId}});if(e.data?.bundleAssignProductCollection.productCollection){this.productCollection=e.data.bundleAssignProductCollection.productCollection;const a=e.data.bundleAssignProductCollection.productCollection.globalPropertyConfiguration;this.globalPropertyStateManager.setConfiguration(a),this.globalConfigurationPropertyId=a?.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 r=t.metadata.get("workflowManager").getWorkflowExperience().getTransaction(),i=this.workflowExperiences.find(o=>o.getTransaction().id===r.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,a){if(t.length===0)return;const r=await this.client.getWorkflowExperiences(t.map(i=>({type:"transaction",transactionId:i})),e,void 0,a);if(r.forEach(i=>i.setBundle(this)),r.forEach(i=>i.checkForPriceBreakChanges()),this.workflowExperiences=r,this.previewService)for(const i of r)await this.injectExperienceIntoPreviewService(i)}async updateBundle(){if(!(await y.getShadowGraphqlClient().mutate({mutation:ua,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([e,a])=>({key:e,value:a})),bundleStateData:this.bundleStateManager.getSerializedState(),dispatchDate:this.dispatchDate,purchaseOrder:this.purchaseOrder},context:{bundleOwnerId:this.ownerId}})).data?.bundleUpdate)throw new Error("Bundle not found!")}async updateTransactionOrder(){await y.getShadowGraphqlClient().mutate({mutation:Xl,variables:{id:this.id,transactionIds:this.workflowExperiences.map(t=>t.getTransaction().id)},context:{bundleOwnerId:this.ownerId}})}async onGlobalPropertiesChanged(t,e){if(this.updatesLocked)return;const a=await this.globalPropertyHandleService.getHandles(),r=this.globalPropertyHandleService.applyConditionsFromState(a,t),i=this.globalPropertyHandleService.applyConditionsFromState(a,e);this.checkConditionalHandlesChanged(r,i),this.checkMandatoryHandlesChanged(t,i);const o=this.getGlobalPropertyStateManager();let s=[];for(const u of a)i.find(A=>A.getName()==u.getName())||(s=[...s,u.getName()]);await o.clearAspects(s);const l=i.map(u=>{if(u.getType()===z.ColorOption||u.getType()===z.Option){const A=u;if(!e.aspects.find(g=>g.name===A.getName()))return A.initDefaultVariant()}});await Promise.all(l),await Promise.all(i.map(u=>u.applyGlobalState()));const c=this.globalPropertyStateManager.getGlobalPropertyState(),d=this.globalPropertyHandleService.applyConditionsFromState(a,c);te(i.sort(),d.sort())||(this.checkConditionalHandlesChanged(i,d),this.checkMandatoryHandlesChanged(c,d),await this.onGlobalPropertiesChanged(e,c))}checkConditionalHandlesChanged(t,e){(()=>{if(t.length!==e.length)return!0;for(let i=0;i<t.length;i++)if(t[i].getName()!==e[i].getName())return!0;return!1})()&&this.fireEvent("conditional-global-properties-changed",{globalProperties:e})}checkMandatoryHandlesChanged(t,e){const a=[],r=[],i=[],o=Hr(t);e.forEach(s=>{if(s.isMandatory()){const l=s.isMandatoryFulfilled();l?r.push(s):i.push(s);const c=o.get(s.getName());(c===void 0||c!==l)&&a.push(s)}}),this.fireEvent("global-properties-mandatory-changed",{changed:a,completed:r,remaining:i})}fireEvent(t,e){this.eventEmitter.emit(t,e)}getShareActions(){return this.shareActions}getWorkflowViewerLink(){return this.workflowViewerLink}getWorkflowViewerAmendLink(){return this.workflowViewerAmendLink}async approve(t,e){await y.getShadowGraphqlClient().mutate({mutation:nc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t,stakeholderId:e}})}async reject(t,e){await y.getShadowGraphqlClient().mutate({mutation:rc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t,stakeholderId:e}})}getQuoteCompleteMessage(){return{bundleId:this.id,bundleOwnerId:this.ownerId,quoteId:this.quoteId||""}}}const Vc=C.gql`
|
|
2402
|
+
`;class Ba{constructor(t,e,n,r,i,o,s){this.workflowExperiences=[],this.eventEmitter=new Uc,this.updatesLocked=!1,this.client=t,this.id=e.id,this.name=e.name||"",this.dispatchDate=e.dispatchDate,this.template=e.template||!1,this.quoteId=e.quoteId,this.shareActions=e.bundleShareActions,this.workflowViewerLink=e.workflowViewerLink,this.workflowViewerAmendLink=e.workflowViewerAmendLink,this.ownerId=i,this.metadata=new Map(e.metadata?.map(d=>[d.key,d.value])||[]),this.completed=e.completed??!1,this.productCollection=e.productCollection,this.bundleStateManager=new Nc(e.bundleStateData);const l=this.productCollection?.globalPropertyConfiguration;this.globalConfigurationPropertyId=l?.id,this.globalPropertyStateManager=new Tc(this.id,this.ownerId,l,this.onGlobalPropertiesChanged.bind(this),o),this.globalPropertyHandleService=new xc(this),this.setPreviewService(n);const c=new Promise((d,u)=>{if(o?.readonly){d([]);return}console.log("Setting default global variants.");const A=this.globalPropertyStateManager.getGlobalPropertyState();A?this.globalPropertyHandleService.getHandles().then(h=>{const g=h.map(m=>{if(m.getType()===z.ColorOption||m.getType()===z.Option){const p=m;if(!A.aspects.find(S=>S.name===p.getName()))return p.initDefaultVariant()}});Promise.all(g).then(d).catch(u)}):(console.log("Attempted to set global default variant before state was initialized."),d([]))});this.initializationPromise=Promise.all([this.loadExistingWorkflowExperiences(e.transactionIds||[],{...r,bundleOwnerId:i},s),this.globalPropertyStateManager.getInitializationPromise()]).then(()=>c),this.initializationPromise.catch(d=>{console.error(`Bundle initialization failed: ${d}`)}),this.initializationPromise.then(()=>{this.getGlobalProperties().then(d=>this.checkMandatoryHandlesChanged(void 0,d))})}getIntegrationProductIds(){return this.bundleStateManager.getState()?.integrationProductIds}async addIntegrationProductId(t){const e=this.bundleStateManager.getState();if(e){if(!e.integrationProductIds)e.integrationProductIds=[];else if(e.integrationProductIds.some(r=>r===t)){this.fireEvent("bundle-integration-products-added",{integrationProductIds:e.integrationProductIds});return}e.integrationProductIds=[...e.integrationProductIds,t];const n=JSON.stringify(e);this.bundleStateManager.setState(n),this.fireEvent("bundle-integration-products-added",{integrationProductIds:e.integrationProductIds}),await y.getShadowGraphqlClient().mutate({mutation:An,variables:{id:this.id,bundleStateData:n},context:{bundleOwnerId:this.ownerId}})}}async removeIntegrationProductIds(t){const e=this.bundleStateManager.getState();if(e){const n=t.filter(i=>(e.integrationProductIds??[]).includes(i));if(n.length===0)return;e.integrationProductIds=(e.integrationProductIds??[]).filter(i=>!n.includes(i));const r=JSON.stringify(e);this.bundleStateManager.setState(r),this.fireEvent("bundle-integration-products-removed",{integrationProductIds:n}),await y.getShadowGraphqlClient().mutate({mutation:An,variables:{id:this.id,bundleStateData:r},context:{bundleOwnerId:this.ownerId}})}}getTemplate(){return this.template}async generateQuoteId(){const e=(await y.getShadowGraphqlClient().mutate({mutation:zc,variables:{id:this.id},context:{bundleOwnerId:this.ownerId}})).data?.bundleGenerateQuoteId?.quoteId;return this.quoteId=e,e||""}async attachAddress(t,e,n,r,i,o){await y.getShadowGraphqlClient().mutate({mutation:Lc,variables:{bundleId:this.id,streetAddress:t||void 0,apartment:e||void 0,city:n||void 0,country:r||void 0,state:i||void 0,postCode:o||void 0},context:{bundleOwnerId:this.ownerId}})}async attachOrganization(t){await y.getShadowGraphqlClient().mutate({mutation:Vc,variables:{bundleId:this.id,organizationName:t},context:{bundleOwnerId:this.ownerId}})}setBundleOptions(t){this.globalPropertyStateManager.setBundleOptions(t)}getInitializationPromise(){return this.initializationPromise}addEventListener(t,e){this.eventEmitter.on(t,e)}removeEventListener(t,e){this.eventEmitter.off(t,e)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}getQuoteId(){return this.quoteId}setName(t){return this.name=t,this.updateBundle()}getDispatchDate(){return this.dispatchDate}setDispatchDate(t){return this.dispatchDate=t,this.updateBundle()}getPurchaseOrder(){return this.purchaseOrder}setPurchaseOrder(t){return this.purchaseOrder=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(){return!!this.productCollection?.globalPropertyConfiguration}getGlobalPropertyConfiguration(){return this.productCollection?.globalPropertyConfiguration}async getGlobalProperties(){return this.globalPropertyHandleService.applyConditionsFromState(await this.globalPropertyHandleService.getHandles(),this.getGlobalPropertyStateManager().getGlobalPropertyState())}async applyGlobalPropertyState(t){this.updatesLocked=!0;const e=await this.globalPropertyHandleService.getHandles();try{for(const n of t.aspects){const r=n?.name;await this.getGlobalPropertyStateManager().setAspect(r,n.value)}for(const n of t.aspects){const r=n?.name,i=e.find(o=>o.getName()===r);if(i)switch(n.type){case z.FileUpload:{const o=i,s=await De([n.value]);s.length>0&&await o.selectImage(s[0]);const l=n.storage?.colors;if(l){const c=Object.fromEntries(l.map(d=>[d.key,{browserValue:d.browserValue,pmsValue:d.pmsValue}])??[]);await o.changeColors(c)}break}case z.ColorOption:{const o=i,l=o.getAllVariants().find(d=>d.getId()===n.value),c=n.storage?n.storage:void 0;l&&await o.selectVariant(l),c?.customColor&&o.setCustomColor(c.customColor);break}case z.Option:{const o=i,l=o.getAllVariants().find(c=>c.getId()===n.value);l&&await o.selectVariant(l);break}case z.Text:{await i.setText(n.value);break}}}}finally{this.updatesLocked=!1,this.onGlobalPropertiesChanged(void 0,this.globalPropertyStateManager.getGlobalPropertyState())}}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}async getGlobalPropertyTotalSubunits(){return(await this.globalPropertyHandleService.getHandles()).filter(n=>n.getType()===z.Option).map(n=>n.getCurrentVariant()?.getPrice()||0).reduce((n,r)=>n+r,0)}getTotalSubunits(){return this.workflowExperiences.map(t=>t.getTotalPriceSubunits()).reduce((t,e)=>t+e,0)}getProductCollection(){return this.productCollection?new na(this.productCollection):void 0}async initializeAdditionalRequiredColorChannels(t){for(const e of t.getStepsByType(b.Illustration)){const n=e.getGlobalPropertyAspects(this.globalConfigurationPropertyId||"");for(const r of n){const i=this.getGlobalPropertyConfiguration()?.aspects.find(o=>o.name===r);if(i&&i.type===z.ColorOption){const o=e.getCurrentVariant()?.getAssetResource(),s=o?.assetConfiguration?.channelNumbers||[],l=o?.assetConfiguration?.defaultColorVariants||[],c=Dc(this.getWorkflowExperiences(),this.globalConfigurationPropertyId||"",r),d=[...new Set(s.map(A=>A.number))];if(d.length>c)for(const A of d){const h=this.getGlobalPropertyStateManager(),g=l.find(m=>m.channelNumber===A);g&&await h.setAspect(r,g.variant.id||"",void 0,g.channelNumber)}}}}}async addWorkflowExperience(t){await this.initializeAdditionalRequiredColorChannels(t),t.setBundle(this),await this.appendWorkflowExperience(t),await this.injectExperienceIntoPreviewService(t),await t.getWorkflowManager().getInitializationPromise();const e=await this.getGlobalProperties();for(const n of e)await n.applyGlobalState([t]);this.fireEvent("workflow-experience-added",{workflowExperiences:[t]})}async addWorkflowExperiences(t){for(const s of t)await this.initializeAdditionalRequiredColorChannels(s);const e=t.map(s=>s.getTransaction().id),n=e.map(s=>this.workflowExperiences.find(l=>l.getTransaction().id===s));if(n.some(s=>!!s))throw new Error("Unable to add transaction to bundle - Already Exists: "+n.filter(s=>!!s).map(s=>s?.getTransaction().id).join(", "));const r=D.getMap("transactionOwnerIds")||new Map,i=e.map(s=>r.get(s));await y.getShadowGraphqlClient().mutate({mutation:Hl,variables:{id:this.id,transactionIds:e,transactionOwnerIds:i},context:{bundleOwnerId:this.ownerId}}).catch(s=>{console.error(s)}),this.workflowExperiences.push(...t);const o=async()=>{for(const l of t)l.setBundle(this),await this.injectExperienceIntoPreviewService(l);await Promise.all(t.map(l=>l.getWorkflowManager().getInitializationPromise()));const s=await this.getGlobalProperties();for(const l of s)await l.applyGlobalState(t)};await Promise.all([this.updateTransactionOrder(),o()]),this.workflowExperiences.forEach(s=>s.checkForPriceBreakChanges()),this.fireEvent("workflow-experience-added",{workflowExperiences:this.workflowExperiences})}async appendWorkflowExperience(t,e=!0){const n=t.getTransaction().id;if(this.workflowExperiences.find(s=>s.getTransaction().id===n))throw new Error("Unable to add transaction to bundle - Already Exists!");const o=(D.getMap("transactionOwnerIds")||new Map).get(n);await y.getShadowGraphqlClient().mutate({mutation:Wl,variables:{id:this.id,transactionId:n},context:{bundleOwnerId:this.ownerId,transactionOwnerId:o}}),e&&(this.workflowExperiences.push(t),this.workflowExperiences.forEach(s=>s.checkForPriceBreakChanges()))}async removeWorkflowExperience(t){const e=this.workflowExperiences.indexOf(t);await this.removeTransaction(e,this.workflowExperiences[e].getTransaction()),this.fireEvent("workflow-experience-added",{workflowExperiences:[t]})}async removeWorkflowExperiences(t){await this.removeTransactions(t.map(e=>e.getTransaction()))}async removeWorkflowExperienceByTransaction(t){const e=this.workflowExperiences.findIndex(n=>n.getTransaction().id===t.id);await this.removeTransaction(e,t)}async removeWorkflowExperiencesByTransactions(t){await this.removeTransactions(t)}async removeTransaction(t,e,n=!0){if(t>-1){const r=this.workflowExperiences.find(i=>i.getTransaction().id===e.id);if(r.setBundle(void 0),this.previewService&&r.getWorkflowManager().ejectFromPreviewService(),this.bundleStateManager.removeStateForTransaction(e.id),await y.getShadowGraphqlClient().mutate({mutation:Yl,variables:{id:this.id,transactionId:e.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([i,o])=>({key:i,value:o})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),n){const i=this.workflowExperiences.splice(t,1);this.workflowExperiences.forEach(o=>o.checkForPriceBreakChanges()),r.checkForPriceBreakChanges(),await this.updateTransactionOrder(),this.fireEvent("workflow-experience-removed",{workflowExperiences:i})}}else throw new Error("Unable to remove workflow experience from bundle - Not Found! - "+e.id)}async removeTransactions(t){const e=t.map(r=>this.workflowExperiences.findIndex(i=>i.getTransaction().id===r.id));if(e.some(r=>r===-1))throw new Error("Unable to remove workflow experience from bundle - The following aren't included in the bundle: "+t.filter((r,i)=>e[i]===-1).map(r=>r.id).join(", "));const n=t.map(r=>this.workflowExperiences.splice(this.workflowExperiences.findIndex(i=>i.getTransaction().id===r.id),1)[0]);n.forEach(r=>r.setBundle(void 0)),[...this.workflowExperiences,...n].forEach(r=>r.checkForPriceBreakChanges()),this.previewService&&n.forEach(r=>r.getWorkflowManager().ejectFromPreviewService()),t.forEach(r=>this.bundleStateManager.removeStateForTransaction(r.id)),await y.getShadowGraphqlClient().mutate({mutation:Jl,variables:{id:this.id,transactionIds:t.map(r=>r.id),name:this.name,metadata:Array.from(this.metadata.entries()).map(([r,i])=>({key:r,value:i})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),this.fireEvent("workflow-experience-removed",{workflowExperiences:n}),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 n=await this.getGlobalProperties();await Promise.all(n.map(r=>r.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 n=this.workflowExperiences[t];if(n.getTransaction().id===e.getTransaction().id)throw new Error("Unable to replace workflow experience in bundle - Same transaction!");await Promise.all([this.removeTransaction(t,n.getTransaction(),!1),this.appendWorkflowExperience(e,!1)]),this.workflowExperiences[t]=e,await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(e);const r=await this.getGlobalProperties();await Promise.all(r.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 n=this.workflowExperiences[t];this.workflowExperiences[t]=this.workflowExperiences[e],this.workflowExperiences[e]=n,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){const n=await y.getShadowGraphqlClient().mutate({mutation:Kl,variables:{id:this.id,details:t,type:e||ne.Owner},context:{bundleOwnerId:this.ownerId}});if(!n.data?.bundleAddStakeholder)throw new Error("Bundle not found!");const r=n.data.bundleAddStakeholder.bundleStakeholders||[];this.storeStakeholderCustomers(r)}async removeStakeholder(t){if(!(await y.getShadowGraphqlClient().mutate({mutation:_l,variables:{id:this.id,emailAddress:t},context:{bundleOwnerId:this.ownerId}})).data?.bundleRemoveStakeholder)throw new Error("Bundle not found!")}async updateStakeholders(t){const e=await y.getShadowGraphqlClient().mutate({mutation:Xl,variables:{id:this.id,input:t},context:{bundleOwnerId:this.ownerId}});if(!e.data?.bundleUpdateStakeholders)throw new Error("Bundle not found!");const n=e.data.bundleUpdateStakeholders.bundleStakeholders||[];this.storeStakeholderCustomers(n)}async getAllStakeholders(){const t=await y.getShadowGraphqlClient().query({query:va,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:va,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){this.completed&&await y.getShadowGraphqlClient().mutate({mutation:ac,variables:{bundleId:this.id}});const n=await qr(this.workflowExperiences.map(r=>{const i=r.getWorkflow();if(!i)throw new Error("Unable to create designs - Workflow not found!");const o=r.getProduct();if(!o)throw new Error("Unable to create designs - Product not found!");return{workflowManager:r.getWorkflowManager(),workflow:i,layouts:r.getWorkflowManager().getLayouts(),getReducerState:()=>r.getCommandContext().getState(),product:o,transaction:r.getTransaction(),workflowSelections:r.getWorkflowManager().getWorkflowSelections(),designName:i.name,workflowMetadata:r.getWorkflowManager().getWorkflowMetadata()}}),e?(r,i)=>{const o=this.workflowExperiences.find(s=>s.getTransaction().id===i);return o?e(o,r):(console.warn("SpiffCommerce - Bundle create design - Unable to find experience for transaction: "+i),Promise.resolve(void 0))}:void 0);return{bundleId:this.id,name:this.getName(),dispatchDate:this.getDispatchDate()||"",purchaseOrder:this.getPurchaseOrder()||"",collectionId:this.getProductCollection()?.getId()||"",collectionName:this.getProductCollection()?.getName()||"",items:n,bundleOwnerId:this.ownerId}}async placeOrder(){const t=this.workflowExperiences.map(e=>({transactionId:e.getTransaction().id,amountToOrder:e.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,n){return this.bundleStateManager.updateWorkflowExperienceTransform(t,e,n),this.updateBundle()}activateWorkflowExperienceTransform(t,e){return this.bundleStateManager.activateWorkflowExperienceTransform(t,e),this.updateBundle()}async assignGlobalPropertyConfiguration(t){await y.getShadowGraphqlClient().mutate({mutation:ec,variables:{bundleId:this.id,globalPropertyConfigurationId:t},context:{bundleOwnerId:this.ownerId}}),this.globalConfigurationPropertyId=t}async assignProductCollection(t){const e=await y.getShadowGraphqlClient().mutate({mutation:tc(this.globalPropertyStateManager.getBundleOptions()?.eagerFetchProducts??!1),variables:{id:this.id,productCollectionId:t??""},context:{bundleOwnerId:this.ownerId}});if(e.data?.bundleAssignProductCollection.productCollection){this.productCollection=e.data.bundleAssignProductCollection.productCollection;const n=e.data.bundleAssignProductCollection.productCollection.globalPropertyConfiguration;this.globalPropertyStateManager.setConfiguration(n),this.globalConfigurationPropertyId=n?.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 r=t.metadata.get("workflowManager").getWorkflowExperience().getTransaction(),i=this.workflowExperiences.find(o=>o.getTransaction().id===r.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(n){console.error(`Unable to apply state to workflow experience: ${n}`)}await e}}async loadExistingWorkflowExperiences(t,e,n){if(t.length===0)return;const r=await this.client.getWorkflowExperiences(t.map(s=>({type:"transaction",transactionId:s})),e,void 0,n);if(r.forEach(s=>s.setBundle(this)),r.forEach(s=>s.checkForPriceBreakChanges()),this.workflowExperiences=r,this.previewService)for(const s of r)await this.injectExperienceIntoPreviewService(s);const i=this.getIntegrationProductIds()||[],o=this.getProductCollection();if(o&&i.length>0){await o.fetchProducts();const s=o.getProducts();for(const l of i)if(!s.find(d=>d.getCurrentIntegration().id===l)){for(const d of r)d.getProduct()?.integrationProducts?.map(u=>u.id)?.includes(l)&&await d.clearProduct();await this.removeIntegrationProductIds([l])}}}async updateBundle(){if(!(await y.getShadowGraphqlClient().mutate({mutation:An,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([e,n])=>({key:e,value:n})),bundleStateData:this.bundleStateManager.getSerializedState(),dispatchDate:this.dispatchDate,purchaseOrder:this.purchaseOrder},context:{bundleOwnerId:this.ownerId}})).data?.bundleUpdate)throw new Error("Bundle not found!")}async updateTransactionOrder(){await y.getShadowGraphqlClient().mutate({mutation:Zl,variables:{id:this.id,transactionIds:this.workflowExperiences.map(t=>t.getTransaction().id)},context:{bundleOwnerId:this.ownerId}})}async onGlobalPropertiesChanged(t,e){if(this.updatesLocked)return;const n=await this.globalPropertyHandleService.getHandles(),r=this.globalPropertyHandleService.applyConditionsFromState(n,t),i=this.globalPropertyHandleService.applyConditionsFromState(n,e);this.checkConditionalHandlesChanged(r,i),this.checkMandatoryHandlesChanged(t,i);const o=this.getGlobalPropertyStateManager();let s=[];for(const u of n)i.find(A=>A.getName()==u.getName())||(s=[...s,u.getName()]);await o.clearAspects(s);const l=i.map(u=>{if(u.getType()===z.ColorOption||u.getType()===z.Option){const A=u;if(!e.aspects.find(g=>g.name===A.getName()))return A.initDefaultVariant()}});await Promise.all(l),await Promise.all(i.map(u=>u.applyGlobalState()));const c=this.globalPropertyStateManager.getGlobalPropertyState(),d=this.globalPropertyHandleService.applyConditionsFromState(n,c);te(i.sort(),d.sort())||(this.checkConditionalHandlesChanged(i,d),this.checkMandatoryHandlesChanged(c,d),await this.onGlobalPropertiesChanged(e,c))}checkConditionalHandlesChanged(t,e){(()=>{if(t.length!==e.length)return!0;for(let i=0;i<t.length;i++)if(t[i].getName()!==e[i].getName())return!0;return!1})()&&this.fireEvent("conditional-global-properties-changed",{globalProperties:e})}checkMandatoryHandlesChanged(t,e){const n=[],r=[],i=[],o=Hr(t);e.forEach(s=>{if(s.isMandatory()){const l=s.isMandatoryFulfilled();l?r.push(s):i.push(s);const c=o.get(s.getName());(c===void 0||c!==l)&&n.push(s)}}),this.fireEvent("global-properties-mandatory-changed",{changed:n,completed:r,remaining:i})}fireEvent(t,e){this.eventEmitter.emit(t,e)}getShareActions(){return this.shareActions}getWorkflowViewerLink(){return this.workflowViewerLink}getWorkflowViewerAmendLink(){return this.workflowViewerAmendLink}async approve(t,e){await y.getShadowGraphqlClient().mutate({mutation:rc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t,stakeholderId:e}})}async reject(t,e){await y.getShadowGraphqlClient().mutate({mutation:ic,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t,stakeholderId:e}})}getQuoteCompleteMessage(){return{bundleId:this.id,bundleOwnerId:this.ownerId,quoteId:this.quoteId||""}}}const qc=C.gql`
|
|
2394
2403
|
mutation processFlowCreate($processFlowId: String!, $inputs: [String]!) {
|
|
2395
2404
|
processExecutionCreate(processFlowId: $processFlowId, inputs: $inputs) {
|
|
2396
2405
|
id
|
|
2397
2406
|
}
|
|
2398
2407
|
}
|
|
2399
|
-
`;class Xr{async execute(t,e,
|
|
2408
|
+
`;class Xr{async execute(t,e,n){const i=(await y.getShadowGraphqlClient().mutate({mutation:qc,variables:{processFlowId:t,inputs:[...e.map(u=>u.getValueForTransmission())]}})).data?.processExecutionCreate?.id;if(!i)throw new Error("Failed to create process execution.");function o(u){return new Promise(A=>{setTimeout(A,u)})}let s=!1,l=0,c,d;for(;!s;){c=await y.getShadowGraphqlClient().query({query:C.gql`
|
|
2400
2409
|
query getProcessFlowExecution($ids: [String]!) {
|
|
2401
2410
|
processExecutions(ids: $ids) {
|
|
2402
2411
|
id
|
|
@@ -2409,7 +2418,7 @@
|
|
|
2409
2418
|
}
|
|
2410
2419
|
}
|
|
2411
2420
|
}
|
|
2412
|
-
`,variables:{ids:[i]}});const u=c.data?.processExecutions[0];if(!c||!u)throw new Error("Failed to retrieve server response for execution.");if(u.failedAt)throw new Error("Execution has failed to complete. See Automation > FLows in Flight on partner account on SpiffCommerce Hub.");if(u.completedAt){s=!0,d=new Zr(u);break}l+=1;const A=
|
|
2421
|
+
`,variables:{ids:[i]}});const u=c.data?.processExecutions[0];if(!c||!u)throw new Error("Failed to retrieve server response for execution.");if(u.failedAt)throw new Error("Execution has failed to complete. See Automation > FLows in Flight on partner account on SpiffCommerce Hub.");if(u.completedAt){s=!0,d=new Zr(u);break}l+=1;const A=n?.repeats?n?.repeats:5;if(l>=A)throw new Error("Maximum wait time exceeded for execution result.");await o(n?.sleepTime?Math.max(n.sleepTime,500):2e3)}if(!d)throw new Error("Failed to retrieve server response for execution.");return Promise.resolve(d)}}class Zr{constructor(t){this.execution=t}getRaw(){return this.execution}getNodes(){return this.execution.nodes.map(t=>new Yt(t))}getNodesByType(t){return this.execution.nodes.filter(e=>e.type===t).map(e=>new Yt(e))}getInputs(){return this.execution.nodes.filter(t=>t.type==="StartTerminal").map(t=>new Yt(t))}getOutputs(){return this.execution.nodes.filter(t=>t.type==="EndTerminal").map(t=>new Yt(t))}getCompletedAt(){if(this.execution.completedAt)return new Date(this.execution.completedAt)}getFailedAt(){if(this.execution.failedAt)return new Date(this.execution.failedAt)}}class Yt{constructor(t){this.node=t}getId(){return this.node.id}getType(){return this.node.type}getArtifacts(){return new Map(Object.entries(JSON.parse(this.node.artifacts).value))}getArtifactByName(t){return this.getArtifacts().get(t)}}class aa{constructor(t){this.value=t}getRaw(){return this.value}getValueForTransmission(){const t=this.value;return t.startsWith("[")?JSON.stringify(JSON.parse(t)):t}}var ti=(a=>(a.Transaction="Transaction",a.Bundle="Bundle",a.Product="Product",a.Variant="Variant",a.Option="Option",a.LineItem="LineItem",a.Asset="Asset",a))(ti||{});class Gc extends aa{constructor(t){super(`"${t}"`)}}class ra extends aa{constructor(t,e){if(e!=="Asset"&&!ra.validUUID(t))throw new Error("Invalid ID, must be a valid v4 UUID. https://www.uuidgenerator.net/");super(`{"isSpiffObject": true, "id": "${t}", "type": "${e}"}`)}static validUUID(t){return t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)}}class jc extends aa{constructor(t){super(`[${t.map(e=>e.getRaw()).join(",")}]`)}}class Mn{constructor(t){this.integrationProduct=t}getId(){return this.integrationProduct.id}getResource(){return this.integrationProduct}getBasePrice(){if(!this.integrationProduct.product)throw new Error("IntegrationProductResource does not have a product");const t=this.integrationProduct.product.basePrice||0,e=this.integrationProduct?.additionalIntegrationProduct;if(!e)return t;if(e&&!e.product)throw new Error("An additional integration product was found, but it does not have a product");return t+(e.product.basePrice||0)}getDefaultWorkflow(){if(!this.integrationProduct.product)throw new Error("IntegrationProductResource does not have a product");const t=this.integrationProduct.product.workflows||[];if(t.length===0)throw new Error("No workflows found on product. This is generally due to a configuration error. Please confirm at least one workflow is configured for this product.");return new Tt(t[0])}getAllWorkflows(){if(!this.integrationProduct.product)throw new Error("IntegrationProductResource does not have a product");const t=this.integrationProduct.product.workflows||[];if(t.length===0)throw new Error("No workflows found on product. This is generally due to a configuration error. Please confirm at least one workflow is configured for this product.");return t.sort((e,n)=>(e.index??0)-(n.index??0)).map(e=>new Tt(e))}}const Ie=C.gql`
|
|
2413
2422
|
query GetCustomer($emailAddress: String!) {
|
|
2414
2423
|
customer(emailAddress: $emailAddress) {
|
|
2415
2424
|
id
|
|
@@ -2426,7 +2435,7 @@
|
|
|
2426
2435
|
}
|
|
2427
2436
|
}
|
|
2428
2437
|
}
|
|
2429
|
-
`,
|
|
2438
|
+
`,Wc=C.gql`
|
|
2430
2439
|
mutation CustomerCreate($details: CustomerDetailsInput!) {
|
|
2431
2440
|
customerCreate(details: $details) {
|
|
2432
2441
|
id
|
|
@@ -2466,7 +2475,7 @@
|
|
|
2466
2475
|
}
|
|
2467
2476
|
}
|
|
2468
2477
|
}
|
|
2469
|
-
`;const
|
|
2478
|
+
`;const Hc=C.gql`
|
|
2470
2479
|
mutation CustomerGenerateVerificationCode($emailAddress: String!) {
|
|
2471
2480
|
customerGenerateVerificationCode(emailAddress: $emailAddress)
|
|
2472
2481
|
}
|
|
@@ -2501,7 +2510,7 @@
|
|
|
2501
2510
|
}
|
|
2502
2511
|
}
|
|
2503
2512
|
}
|
|
2504
|
-
`;const
|
|
2513
|
+
`;const Yc=C.gql`
|
|
2505
2514
|
query CustomerMetafields($id: String!) {
|
|
2506
2515
|
metafields(entityId: $id) {
|
|
2507
2516
|
id
|
|
@@ -2519,13 +2528,13 @@
|
|
|
2519
2528
|
}
|
|
2520
2529
|
}
|
|
2521
2530
|
}
|
|
2522
|
-
`;class Hc{constructor(t,e=y.getShadowGraphqlClient.bind(y)){this.options=t,this.client=e}query(t){const e=this.options?.onQuery?this.options?.onQuery(t):{};return this.client().query({...e,...t,context:{...e.context??{},...t.context??{}}})}mutate(t){const e=this.options?.onMutate?this.options?.onMutate(t):{};return this.client().mutate({...e,...t,context:{...e.context??{},...t.context??{}}})}}class Yc{init(t,e,a){this.cognitoClient=new we.CognitoIdentityProviderClient({region:e}),this.spiffRegion=t,this.userPoolClientId=a}async generateCode(t){const e=await this.cognitoClient?.send(new we.InitiateAuthCommand({AuthFlow:"CUSTOM_AUTH",ClientId:this.userPoolClientId,AuthParameters:{USERNAME:t}}));e?.ChallengeName==="CUSTOM_CHALLENGE"&&(this.challengeSession=e.Session)}async verifyCode(t,e,a){const r=await this.cognitoClient?.send(new we.RespondToAuthChallengeCommand({ClientId:this.userPoolClientId,ChallengeName:"CUSTOM_CHALLENGE",Session:this.challengeSession,ChallengeResponses:{USERNAME:t,ANSWER:e},ClientMetadata:{partnerId:a,environment:(this.spiffRegion||"").toLowerCase()}}));return r?.ChallengeName==="CUSTOM_CHALLENGE"&&(this.challengeSession=r.Session),r}async refreshTokens(){const t=localStorage.getItem("cognito-tokens");if(!t)throw new Error("Failed to find existing tokens.");const e=JSON.parse(t);return await this.cognitoClient?.send(new we.InitiateAuthCommand({AuthFlow:"REFRESH_TOKEN_AUTH",ClientId:this.userPoolClientId,AuthParameters:{REFRESH_TOKEN:e.RefreshToken||""}}))}}const jt=new Yc;class ei{formatCurrencyForDisplay(t,e){const a={amount:e||0,currency:t,precision:this.getPrecisionForCurrency(t)};return Mi(a).toFormat(this.getSpecialFormat(t))}getPrecisionForCurrency(t){const e=t,a=cn.code(e);return a?a.digits:2}getSpecialFormat(t){const e=t;if(cn.code(e)?.code==="CLP")return"USD0,0"}}const Pn=new ei;class ai{constructor(t,e,a,r){this.presentmentCurrency=void 0,this.presentmentCurrency=r,this.partnerCurrency=a,this.rateFrom=t,this.rateTo=e}code(){return this.presentmentCurrency?this.presentmentCurrency:this.partnerCurrency}conversionRequired(){return this.presentmentCurrency!==void 0&&this.code()!==this.partnerCurrency}getConvertedSubunits(t){return this.conversionRequired()?Math.ceil(this.subunits(this.units(t,this.partnerCurrency)/this.rateFrom*this.rateTo,this.code())):t}units(t,e){return t/Math.pow(10,Pn.getPrecisionForCurrency(e))}subunits(t,e){return t*Math.pow(10,Pn.getPrecisionForCurrency(e))}}const Jc=async(n,t)=>{const e=await y.getShadowGraphqlClient().query({query:Ko(t?.assets?.metadata||!1),errorPolicy:"all",variables:{ids:n}});if(e.error)throw e.error;if(e.errors)throw e.errors.forEach(r=>console.error(r)),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(r=>{r.steps.forEach(i=>{delete i.data.__typename,i.option?.id&&(i.option.defaultVariant?.asset&&U.cacheAsset(i.option.defaultVariant.asset),i.option.colorProfile&&U.cacheAsset(i.option.colorProfile),i.option.variants?.forEach(o=>{o.asset&&U.cacheAsset(o.asset),o.thumbnail&&U.cacheAsset(o.thumbnail),o.material&&U.cacheMaterial(o.material)}),$t.set({id:i.option.id},Promise.resolve(i.option)))}),r.finalizeStepConfig||(r.finalizeStepConfig={}),r.finalizeStepConfig.termsMarkdown=r.finalizeStepConfig.termsMarkdown||r.partner.termsMarkdown}),a},Kc=async(n,t)=>{const a=(await t).find(r=>r.id===n);if(!a)throw new Error(`Workflow not found: ${n}`);return a},rn=async(n,t)=>{const e=n.map(s=>$t.get({id:s,options:t})),a=n.filter((s,l)=>e[l]===void 0);if(a.length===0)return Promise.all(e);const r=Jc(a,t),i=a.map(s=>$t.set({id:s,options:t},Kc(s,r))),o=e.filter(s=>s!==void 0);return await Promise.all(o.concat(i))},ni=async(n,t)=>(await rn([n],t))[0],_c=async n=>{const t=await y.getShadowGraphqlClient().query({query:To,variables:{ids:n},errorPolicy:"all",fetchPolicy:"no-cache"});return t.errors&&console.error(t.errors),t.data.integrationProducts||[]};class Xc{constructor(t){this.activeIntegration=void 0,this.updateTransactionState=async e=>{try{return y.getShadowGraphqlClient().mutate({...e,mutation:Qo})}catch(a){throw console.error(a),new mt("Critical - Unable to synchronize workflow state with server.")}},this.options=t,this.options.applicationKey&&Ki(this.options.applicationKey),console.debug("------------------------"),console.debug("Spiff Commerce Core SDK"),console.debug("Version: 34.2.0"),console.debug(`Application Key Provided: ${!!this.options.applicationKey}`),console.debug("------------------------")}configure(t){ut.setHubUrl(t.hubUrl),ut.setServerUrl(t.serverUrl),ut.setServicesApiUrl(t.servicesApiUrl),this.marketplaceThemeInstallId=t.marketplaceThemeInstallId,this.marketplaceThemeInstallConfigurationId=t.marketplaceThemeInstallConfigurationId,this.userPoolClientId=t.userPoolClientId,this.userPoolRegion=t.userPoolRegion,this.spiffRegion=t.spiffRegion,t.bearerAuthenticationToken&&_n(t.bearerAuthenticationToken),this.options.applicationKey&&this.getIntegration(),this.spiffRegion&&this.userPoolRegion&&this.userPoolClientId&&jt.init(this.spiffRegion,this.userPoolRegion,this.userPoolClientId)}getAssetManager(){return U}getFlowService(){if(!_i())throw new Error("Application key required to use Flow Service.");return new Xr}async getCurrencyContext(t){const a=(await this.getIntegration()).partner.currencyCode,i=await y.getShadowGraphqlClient().query({query:rs,errorPolicy:"all",fetchPolicy:"cache-first",variables:{from:a,to:t}}),{rateFrom:o,rateTo:s}=i.data.currencyConversion;return new ai(o,s,a,t)}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=ri(this.options.applicationKey),this.activeIntegration}async canUseAddon(t){try{return(await this.getIntegration()).partner.activeAddons?.includes(t)??!1}catch(e){return console.error(e),!1}}async authenticateBundleFromLocalStorage(t){if(D.getMap("bundleOwnerIds")?.has(t))return Promise.resolve({success:!0,stakeholderType:ae.Owner});const a=D.getMap("bundlePartnerIds")||new Map;if(a.has(t)){const r=a.get(t);if((D.getMap("partnerCustomerIds")||new Map).get(r)&&await this.reloadLoggedInCustomer()){const l=this.customer?.bundleStakeholders?.find(c=>c.bundle?.id===t);if(l)return Promise.resolve({success:!0,stakeholderType:l.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=y.getShadowGraphqlClient(),a=await e.query({query:_o,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 r=a.data.transactions[0];if(!r.product?.partner?.id)throw new Error(`Unable to read transaction: ${t}`);if(r.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});if(D.getMap("transactionOwnerIds")?.has(t))return Promise.resolve({success:!0,stakeholderType:ae.Owner});const s=D.getMap("transactionCustomerIds");if(s?.has(t)&&s.get(t)&&await this.reloadLoggedInCustomer()){const A=this.customer?.bundleStakeholders?.find(h=>h.bundle?.transactions?.some(g=>g.id===t))||this.customer?.stakeholders?.find(h=>h.transaction?.id===t);if(A)return Promise.resolve({success:!0,stakeholderType:A.type})}const c=(await e.query({query:Xo,errorPolicy:"all",variables:{id:r.workflowId}})).data.workflow;if(!c)throw new Error(`Unable to read workflow: ${r.workflowId}`);return Promise.resolve({success:!1,theme:c.overrideTheme,customLogoLink:r.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=D.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),D.setMap("transactionCustomerIds",e))}async customerHasBundleTemplates(t){const r=(await y.getShadowGraphqlClient().query({query:Ie,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;return r.id?r.hasBundleTemplates??!1:!1}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find(a=>a.transaction?.id===t);if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=y.getShadowGraphqlClient(),r=(await e.query({query:Ie,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!r.id){const s=(await e.mutate({mutation:Gc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!s)throw new Error("Unable to create customer.");return this.storeCustomer(s),this.customer=s,{customer:s,isAuthenticated:!1}}this.storeCustomer(r);const i=await this.reloadLoggedInCustomer();return{customer:this.customer||r,isAuthenticated:i}}getCustomer(){return this.customer}async reloadLoggedInCustomer(){const t=localStorage.getItem("last-refreshed-cognito-tokens"),e=localStorage.getItem("cognito-tokens"),a=localStorage.getItem("cognito-email");if(!t||!e||!a)return!1;const r=JSON.parse(e),i=new Date().getTime()/1e3;if(!r.ExpiresIn||r.ExpiresIn<i-parseInt(t)){const l=await jt.refreshTokens();if(l?.AuthenticationResult)localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),r.AccessToken=l.AuthenticationResult.AccessToken,localStorage.setItem("cognito-tokens",JSON.stringify(r));else return this.logOut(),console.error("Failed to refresh tokens."),!1}const s=(await y.getShadowGraphqlClient().query({query:Ie,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:a}})).data.customer;return s.id?(this.customer=s,!0):(console.error("Failed to get customer."),!1)}async generateVerificationCode(t){await y.getShadowGraphqlClient().mutate({mutation:jc,variables:{emailAddress:t}}),await jt.generateCode(t)}async verifyCode(t,e){const a=(await this.getIntegration()).partner.id||"",r=await jt.verifyCode(t,e,a);if(r?.AuthenticationResult){localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),localStorage.setItem("cognito-tokens",JSON.stringify(r.AuthenticationResult)),localStorage.setItem("cognito-email",t);const o=(await y.getShadowGraphqlClient().query({query:Ie,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!o.id)throw new Error("Failed to get customer.");return this.customer=o,!0}else throw new Error}async logOut(){localStorage.removeItem("last-refreshed-cognito-tokens"),localStorage.removeItem("cognito-tokens"),localStorage.removeItem("cognito-email"),this.clearCustomer()}async loggedInBearerToken(){const t=localStorage.getItem("last-refreshed-cognito-tokens"),e=localStorage.getItem("cognito-tokens");if(!t||!e)throw new Error("No token data in storage.");const a=JSON.parse(e),r=new Date().getTime()/1e3,i=!a?.AccessToken||Re(a.AccessToken);if(!a.ExpiresIn||a.ExpiresIn<r-parseInt(t)||i){const o=await jt.refreshTokens();if(o?.AuthenticationResult)localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),a.AccessToken=o.AuthenticationResult.AccessToken,localStorage.setItem("cognito-tokens",JSON.stringify(a));else throw this.logOut(),new Error("Failed to refresh tokens.")}if(!a.AccessToken)throw new Error("No bearer token in storage.");return a.AccessToken}async getCustomerMetafields(){if(!this.customer?.id)throw new Error("Customer must be logged in before calling this function.");return(await y.getShadowGraphqlClient().query({query:Wc,variables:{id:this.customer.id}})).data.metafields}async getNewBundle(t,e,a){const i=(await y.getShadowGraphqlClient().mutate({mutation:ql(a?.graphql?.productCollection?.eagerFetchProducts||!1),variables:{collectionId:t,initialMetadata:e?Object.entries(e).map((c,d)=>({key:c[0],value:c[1]})):void 0,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},fetchPolicy:"no-cache"})).data?.bundleCreate;if(!i?.id)throw new Error("Unable to create bundle");const o=D.getMap("bundlePartnerIds")||new Map;o.set(i.id,i.partner.id),D.setMap("bundlePartnerIds",o);const s=D.getMap("bundleOwnerIds")||new Map;s.set(i.id,i.bundleOwnerId),D.setMap("bundleOwnerIds",s);const l=new Bn(this,i,void 0,void 0,i.bundleOwnerId,{eagerFetchProducts:a?.graphql?.productCollection?.eagerFetchProducts});return await l.getInitializationPromise(),l}async getExistingBundle(t,e,a,r,i){const s=D.getMap("bundleOwnerIds")?.get(t),l={};try{const g=await this.loggedInBearerToken();l.Authorization=`Bearer ${g}`}catch{const p=Object.entries(localStorage).find(([S,w])=>S.startsWith("CognitoIdentityServiceProvider")&&S.endsWith("idToken"))?.[0]||"",f=localStorage.getItem(p);f&&!Re(f)&&(l.Authorization=`Bearer ${f}`)}const c={bundleOwnerId:s,...l,...r?.graphql?.additionalHeaders},d=await y.getShadowGraphqlClient().query({query:$l(r?.graphql?.productCollection?.eagerFetchProducts||!1),variables:{id:t},fetchPolicy:"no-cache",context:{headers:c}});if(!d.data?.bundles||d.data?.bundles.length===0||!d.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const u=d.data?.bundles[0],A=D.getMap("bundlePartnerIds")||new Map;A.set(u.id,u.partner.id),D.setMap("bundlePartnerIds",A);const h=new Bn(this,u,e,a,s,{additionalHeaders:r?.graphql?.additionalHeaders,eagerFetchProducts:r?.graphql?.productCollection?.eagerFetchProducts,existingGlobalPropertyState:d.data.globalPropertyState,readonly:r?.readonly},i);return await h.getInitializationPromise(),h}async duplicateBundle(t,e,a,r){const o={...await ii(t),...r?.graphql?.additionalHeaders},l=(await y.getShadowGraphqlClient().mutate({mutation:Gl(),variables:{id:t,template:e,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId,duplicateTransactions:a},context:{headers:o},fetchPolicy:"no-cache"})).data?.bundleDuplicate;if(!l?.id)throw new Error("Unable to duplicate bundle");const c=D.getMap("bundlePartnerIds")||new Map;c.set(l.id,l.partner.id),D.setMap("bundlePartnerIds",c);const d=D.getMap("bundleOwnerIds")||new Map;return d.set(l.id,l.bundleOwnerId),D.setMap("bundleOwnerIds",d),async()=>await this.getExistingBundle(l.id,void 0,void 0,{graphql:{productCollection:{eagerFetchProducts:r?.graphql?.productCollection?.eagerFetchProducts||!1}}})}async getBundlesForCustomer(t){if(!this.customer?.id)throw new Error("Customer not authenticated.");const{includeMetadata:e,...a}=t;return(await y.getShadowGraphqlClient().query({query:ec(e??!1),variables:{...a,id:this.customer.id},fetchPolicy:"no-cache"})).data.customerBundlesFeed}async getBundleStakeholders(){if(!this.customer)throw new Error("Customer not authenticated.");const t=await y.getShadowGraphqlClient().query({query:Ul,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!t.data?.customers||t.data.customers.length===0)throw new Error("Unable to find customer.");const a=t.data.customers[0].bundleStakeholders||[],r=D.getMap("bundlePartnerIds")||new Map;return a.forEach(i=>{i.bundle?.id&&i.bundle.partner?.id&&r.set(i.bundle.id,i.bundle.partner.id)}),D.setMap("bundlePartnerIds",r),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),r=a[0],i=r.getWorkflow();return e&&!i&&console.error("No workflow instantiated when trying to create preview service."),e&&i&&await r.getWorkflowManager().injectIntoPreviewService(e(i)),a[0]}async getWorkflowExperiences(t,e,a,r){if(t.length===0)throw new mt("No options provided!");const i=t.map((P,T)=>({option:P,index:T})),o=i.filter(P=>P.option.type==="transaction"),s=i.filter(P=>P.option.type==="integration"||P.option.type==="external"||P.option.type==="blank"),l=50,c=pa(o,l),d=pa(s,l);let u=0;const A=y.getShadowGraphqlClient(),h=async P=>{if(P.length===0)return[];const T=P.map(W=>W.option.transactionId),V=await A.query({query:No,variables:{ids:T},errorPolicy:"all",fetchPolicy:"no-cache"}),k=V.data.transactions;if(u=u+k.length,r&&r(u,o.length),k.length!==P.length){const W=V.errors?.[0]?.message||"Unknown error";throw new mt(`Not all transactions were found: ${W}`)}return!this.activeIntegration&&k[0].integrationProduct?.integration&&(this.activeIntegration=Promise.resolve(k[0].integrationProduct.integration)),k.map((W,Xe)=>({transaction:W,workflowId:W.workflowId,readOnly:P.find(At=>At.option.transactionId===W.id)?.option.readOnly??!1,index:P[Xe].index}))},g=async P=>{if(P.length===0)return[];const T=await A.mutate({mutation:Mo,variables:{inputs:P.map(k=>({integrationProductId:k.option.type==="integration"?k.option.integrationProductId:void 0,externalIntegrationId:k.option.type==="external"?k.option.externalIntegrationId:void 0,externalProductId:k.option.type==="external"?k.option.externalProductId:void 0,workflowId:k.option.workflowId,designName:k.option.designName,claim:!0,quantity:k.option.quantity,recipient:k.option.recipient})),marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},errorPolicy:"all",fetchPolicy:"no-cache"}),V=T.data?.transactionCreateMany;if(!V||V.length===0){const k=T.errors?.[0]?.message||"Unknown error";throw new mt(`Failed to create transactions: ${k}`)}return u=u+V.length,r&&r(u,o.length),V.map((k,W)=>({transaction:k,workflowId:k.workflowId,readOnly:!1,index:P[W].index}))},m=(await Promise.all([...c.map(h),...d.map(g)])).flat(),p=[...new Set(m.map(P=>P.transaction.integrationProductId))].filter(P=>P!==void 0),f=[...new Set(m.map(P=>P.workflowId))].filter(P=>P!==void 0),[S,w]=await Promise.all([(async()=>p.length>0?await _c(p):[])(),(async()=>f.length>0?await rn(f,e):[])()]),x=new Map(S.map(P=>[P.id,P])),v=new Map(w.map(P=>[P.id,P])),E=m.map(async P=>{const{transaction:T,workflowId:V,readOnly:k,index:W}=P,Xe=V?v.get(V):void 0,At=t[W];if(T.integrationProductId){const ot=x.get(T.integrationProductId);T.integrationProduct=ot,T.product=ot?.product,T.integrationProduct||console.error("failed to find transaction's product")}const fe=D.getMap("transactionOwnerIds")||new Map;!fe.get(T.id)&&T.transactionOwnerId&&(fe.set(T.id,T.transactionOwnerId),D.setMap("transactionOwnerIds",fe));const Ze=fe.get(T.id)||void 0,mi=new Hc({onMutate:()=>({context:{transactionOwnerId:Ze,bundleOwnerId:e?.bundleOwnerId}}),onQuery:()=>({context:{transactionOwnerId:Ze,bundleOwnerId:e?.bundleOwnerId}})}),Ce={workflow:Xe,transaction:T,singleVariantsRenderable:At?.workflowConfiguration?.singleVariantsRenderable,stateMutationFunc:k?async()=>{throw new Q("State mutation is forbidden in read only mode!")}:async ot=>this.updateTransactionState({...ot,context:{transactionOwnerId:Ze,bundleOwnerId:e?.bundleOwnerId}}),graphQlClient:()=>mi,readOnly:k,isReloadedTransaction:At.type==="transaction"};if(At.type==="transaction"&&T.workflowState){const ot=JSON.parse(T.workflowState);await Ia(ot),Ce.reloadedState=ot}else if(!k&&At.workflowState){const ot=JSON.parse(At.workflowState);await Ia(ot),Ce.reloadedState=ot}return Ce.delayWorkflowStateSync=!0,{experienceOptions:Ce,index:W,options:At}}),N=(await Promise.all(E)).sort((P,T)=>P.index-T.index);let R=[];for(const P of N){const{experienceOptions:T,options:V}=P,k=new Gr(this,T);await k.getWorkflowManager().getInitializationPromise(),a&&a(),V.type!=="transaction"&&this.customer&&await k.attachCustomerDetails({email:this.customer.emailAddress}),R=[...R,k],k.getWorkflowManager().setWorkflowStateSyncEnabled(!0)}return R}storeCustomer(t){const e=D.getMap("partnerCustomerIds")||new Map;e.set(t.partner.id,t.id),D.setMap("partnerCustomerIds",e)}async getIntegrationProductById(t,e){const i=(await y.getShadowGraphqlClient().query({query:zo(e),variables:{ids:[t]},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.integrationProducts;if(!i||i.length===0||!i[0]?.id)throw new Error("Integration product not found.");return new ka(i[0])}async getIntegrationProductFromExternalIds(t,e,a){const o=(await y.getShadowGraphqlClient().query({query:qo(a),variables:{externalProductId:e,externalIntegrationId:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.integrationProductFromExternalIds;if(!o?.id)throw new Error("Integration product not found.");return new ka(o)}async getIntegrationProduct(t){return t.type==="integration"?this.getIntegrationProductById(t.integrationProductId):this.getIntegrationProductFromExternalIds(t.externalIntegrationId,t.externalProductId)}async getShareActionsForTransaction(t){const a=(D.getMap("transactionOwnerIds")||new Map).get(t)||void 0,r=await y.getShadowGraphqlClient().query({query:Lo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t},context:{transactionOwnerId:a}});if(!r.data.transactions||r.data.transactions.length!==1)throw new Error(`Failed to fetch share actions for transaction: ${t}`);return r.data.transactions[0].transactionShareActions}async placeOrder(t){const e=await y.getShadowGraphqlClient().mutate({mutation:ns,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 ri=async(n,t)=>(await y.getShadowGraphqlClient().query({query:ts,errorPolicy:"all",fetchPolicy:"no-cache",context:{headers:{"x-application-key":n}},variables:{themeConfigurationId:t}})).data.currentIntegration,Zc=async n=>{const e=await y.getShadowGraphqlClient().query({query:Uo,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:n}});if(e.data.transactions.length!==0)return e.data.transactions[0]},td=async(n,t)=>(await y.getShadowGraphqlClient().query({query:Zo,errorPolicy:"all",variables:{themeConfigurationId:n,themeInstallId:t}})).data?.marketplaceThemeInstallConfiguration,ed=async n=>(await y.getShadowGraphqlClient().query({query:as,errorPolicy:"all",variables:{id:n}})).data?.bundles?.[0]?.marketplaceThemeInstallConfiguration,ad=async n=>(await y.getShadowGraphqlClient().query({query:es,errorPolicy:"all",variables:{id:n}})).data?.transactions?.[0]?.marketplaceThemeInstallConfiguration;async function ii(n){const e=D.getMap("bundleOwnerIds")?.get(n),a={};try{const r=await this.loggedInBearerToken();a.Authorization=`Bearer ${r}`}catch{const o=Object.entries(localStorage).find(([l,c])=>l.startsWith("CognitoIdentityServiceProvider")&&l.endsWith("idToken"))?.[0]||"",s=localStorage.getItem(o);s&&!Re(s)&&(a.Authorization=`Bearer ${s}`)}return{bundleOwnerId:e,...a}}const nd=async n=>{const t=await ii(n),e=await y.getShadowGraphqlClient().mutate({mutation:dc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n},context:{headers:t}});if(e.data?.bundleDelete!==n)throw new Error(`Failed to delete bundle: ${e.errors}`)};function oi(n,t,e,a){const r=e.width*n.zoom,i=e.height*n.zoom;if(a){const s=n,l=Math.max(t.width/e.width,t.height/e.height);s.zoom=Math.max(l,n.zoom);const c=e.width*s.zoom,d=e.height*s.zoom;return s.x=Be(n.x,t.width-c,0),s.y=Be(n.y,t.height-d,0),s}const o=n;return o.x=Be(o.x,-r,t.width),o.y=Be(o.y,-i,t.height),o}function Be(n,t,e){return Math.min(Math.max(n,t),e)}class si{constructor(t,e){this.minZoomScale=[.03],this.maxZoomScale=[20],this._debouncedUpdateFrameOffsets=On(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 r=a;if(r.currentFrameSources){let i=!1;for(let o=0;o<r.currentFrameSources.length;o++){const s=r.currentFrameSources[o],l=await me(s),c=this.frameData?this.frameData[o]:void 0;te(l,c)||(this.frameData||(this.frameData=new Array(r.currentFrameSources.length)),this.frameData[o]=l,i=!0)}i&&(this.onFrameDataChangeListeners.forEach(o=>o(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 r=Dt.get(e);r&&(this.frameData||(this.frameData=new Array(t.length)),this.frameData[a]=r)})}getImageData(){return this.imageData}getImageSrc(){if(this.imageData){if(this.imageData.svg){const t=je(this.imageData.svg,this.imageData.colors||{},!1);return qe(t)}return this.imageData.src}}getOffsets(){return this.offsets}setOffsets(t){this.offsets=t}setZoom(t,e,a,r){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((o,s)=>{const l=(e[s]-this.offsets[s].x)/this.offsets[s].zoom,c=(a[s]-this.offsets[s].y)/this.offsets[s].zoom,d=e[s]-l*t[s],u=a[s]-c*t[s];return{x:d,y:u,zoom:this.imageData.width*t[s]/this.imageData.width}});this.updateOffsets(i,r),this.onZoomChangeListeners.forEach(o=>o(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 r=this.imageData;if(!r||!this.frameData)return;if(this.frameData.length!==t.length)throw new Q("Frame data and offsets are not the same length. This is a bug. Please report it.");if(!this.offsets.some((o,s)=>!(t[s].x===o.x&&t[s].y===o.y&&t[s].zoom===o.zoom))&&!a){e&&e();return}(!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length)),this.frameData.forEach((o,s)=>{this.offsets[s]=oi(t[s],o,this.imageData,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,r,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,r,i){if(!a||a.length===0||a.some(l=>!l))throw new Q("Frame data not set. This is a bug");if(!this.workflowManager)throw new Q("No workflow manager set, cannot update offsets.");const o=this.workflowManager.getRegionElements(this.stepName||""),s=this.workflowManager.getCommandDispatcher();this.targetElements.forEach((l,c)=>{let d=o.find(u=>u.id===l)?.regionIndex??c;d>=t.length&&(d=c),s(new $([new zs(l,e,t[d]),new qs(l,r.useThreshold,r.invertThreshold,r.threshold,r.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,r)=>{const i=Math.max(a.width/t.width,a.height/t.height);this.forceImageCover?(this.minZoomScale[r]=i,this.maxZoomScale[r]=i*2.5):(this.minZoomScale[r]=i/10,this.maxZoomScale[r]=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]=qa(t,e,this.initialZoom&&!this.forceImageCover?{scale:this.initialZoom}:void 0,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,t,this.frameData,this.thresholdSettings))}}class rd{traversableScenes(){throw new Error("Method not implemented.")}updateRecipient(t,e,a,r,i,o,s,l,c,d,u,A,h,g,m,p,f){throw new Error("Method not implemented.")}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(){}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 li=(n=>(n.SelectFrame="SelectFrame",n.SelectImage="SelectImage",n.Position="Position",n))(li||{});class ci extends Z{constructor(t,e,a){super(t,e,a);const r=e.data;this.frameService=new si(r.forceImageCover,r.initialZoomLevel),this.frameService.connectWorkflowManager(t,e.stepName)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return gt.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){if(await gt.selectImage(this.step,t,this.manager,a),e){const r=this.manager.getStepStorage(this.step.stepName)?.framePatternData||{};this.manager.updateStorage(this.step.stepName,{framePatternData:{...r,originalAssetKey:t.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}})}}async canUseBackgroundRemover(){return this.manager.getClient().canUseAddon($e.BackgroundRemover)}async canRemoveBackground(){return await this.canUseBackgroundRemover()&&this.hasOriginalImageSelection()&&!!this.frameService?.getImageData()?.src&&!this.frameService?.getImageData()?.svg}async removeBackgroundFromImageSelection(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.getOriginalImageSelection();if(!e)throw new Error("You must supply an image selection before attempting to remove the background.");const a=await U.removeBackgroundFromAsset(e);t&&await gt.selectImage(this.step,a,this.manager,!1);const r=this.manager.getStepStorage(this.step.stepName)?.framePatternData||{};return this.manager.updateStorage(this.step.stepName,{framePatternData:{...r,backgroundRemovedAssetKey:a.key,useOriginalAsset:!t}}),a}changeColors(t){gt.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?gt.availableColors(this.step,this.manager):Promise.resolve([])}isColorPickerEnabled(){return this.step.data.colorPickerEnabled??!1}async getOriginalImageColors(){const t=this.getImageData();return t?.svg?(await it(t.svg)).colors:void 0}getMaxAllowedColors(){return this.step.data.maxColors}getUniqueColorCount(){return gt.getUniqueColorCount(this.step,this.manager)}getCurrentFrameStep(t,e,a,r){return r&&r.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(){const t=this.manager.getStepStorage(this.step.stepName)?.framePatternData?.originalAssetKey;if(t)return U.getLocalOrFromServer(t)}async getBackgroundRemovedImageSelection(){const t=this.manager.getStepStorage(this.step.stepName)?.framePatternData?.backgroundRemovedAssetKey;if(t)return U.getLocalOrFromServer(t)}hasOriginalImageSelection(){return!!this.manager.getStepStorage(this.step.stepName)?.framePatternData?.originalAssetKey}hasBackgroundRemovedImageSelection(){return!!this.getFrameStepStorage()?.framePatternData?.backgroundRemovedAssetKey}getUseOriginalImageSelection(){return this.getFrameStepStorage()?.framePatternData?.useOriginalAsset??!1}async setUseOriginalImageSelection(t){const e=this.getFrameStepStorage()?.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 r=await this.getBackgroundRemovedImageSelection();if(!r)throw new Error("You must call removeBackgroundFromImageSelection before attempting to apply the image.");await this.selectImage(r,!1,!1)}this.manager.updateStorage(this.step.stepName,{framePatternData:{...e,useOriginalAsset:t}})}getFrameStepStorage(){return this.manager.getStepStorage(this.step.stepName)}}const id=C.gql`
|
|
2531
|
+
`;class Jc{constructor(t,e=y.getShadowGraphqlClient.bind(y)){this.options=t,this.client=e}query(t){const e=this.options?.onQuery?this.options?.onQuery(t):{};return this.client().query({...e,...t,context:{...e.context??{},...t.context??{}}})}mutate(t){const e=this.options?.onMutate?this.options?.onMutate(t):{};return this.client().mutate({...e,...t,context:{...e.context??{},...t.context??{}}})}}class Kc{init(t,e,n){this.cognitoClient=new we.CognitoIdentityProviderClient({region:e}),this.spiffRegion=t,this.userPoolClientId=n}async generateCode(t){const e=await this.cognitoClient?.send(new we.InitiateAuthCommand({AuthFlow:"CUSTOM_AUTH",ClientId:this.userPoolClientId,AuthParameters:{USERNAME:t}}));e?.ChallengeName==="CUSTOM_CHALLENGE"&&(this.challengeSession=e.Session)}async verifyCode(t,e,n){const r=await this.cognitoClient?.send(new we.RespondToAuthChallengeCommand({ClientId:this.userPoolClientId,ChallengeName:"CUSTOM_CHALLENGE",Session:this.challengeSession,ChallengeResponses:{USERNAME:t,ANSWER:e},ClientMetadata:{partnerId:n,environment:(this.spiffRegion||"").toLowerCase()}}));return r?.ChallengeName==="CUSTOM_CHALLENGE"&&(this.challengeSession=r.Session),r}async refreshTokens(){const t=localStorage.getItem("cognito-tokens");if(!t)throw new Error("Failed to find existing tokens.");const e=JSON.parse(t);return await this.cognitoClient?.send(new we.InitiateAuthCommand({AuthFlow:"REFRESH_TOKEN_AUTH",ClientId:this.userPoolClientId,AuthParameters:{REFRESH_TOKEN:e.RefreshToken||""}}))}}const jt=new Kc;class ei{formatCurrencyForDisplay(t,e){const n={amount:e||0,currency:t,precision:this.getPrecisionForCurrency(t)};return Ti(n).toFormat(this.getSpecialFormat(t))}getPrecisionForCurrency(t){const e=t,n=ca.code(e);return n?n.digits:2}getSpecialFormat(t){const e=t;if(ca.code(e)?.code==="CLP")return"USD0,0"}}const Pa=new ei;class ni{constructor(t,e,n,r){this.presentmentCurrency=void 0,this.presentmentCurrency=r,this.partnerCurrency=n,this.rateFrom=t,this.rateTo=e}code(){return this.presentmentCurrency?this.presentmentCurrency:this.partnerCurrency}conversionRequired(){return this.presentmentCurrency!==void 0&&this.code()!==this.partnerCurrency}getConvertedSubunits(t){return this.conversionRequired()?Math.ceil(this.subunits(this.units(t,this.partnerCurrency)/this.rateFrom*this.rateTo,this.code())):t}units(t,e){return t/Math.pow(10,Pa.getPrecisionForCurrency(e))}subunits(t,e){return t*Math.pow(10,Pa.getPrecisionForCurrency(e))}}const _c=async(a,t)=>{const e=await y.getShadowGraphqlClient().query({query:_o(t?.assets?.metadata||!1),errorPolicy:"all",variables:{ids:a}});if(e.error)throw e.error;if(e.errors)throw e.errors.forEach(r=>console.error(r)),new Error("Unable to read workflows. Consult GraphQL errors.");const n=e.data.workflows;if(n===void 0||n.length!==a.length)throw new Error(`Unable to read workflows: ${e.errors??"Length mismatch in response"}`);return n.forEach(r=>{r.steps.forEach(i=>{delete i.data.__typename,i.option?.id&&(i.option.defaultVariant?.asset&&U.cacheAsset(i.option.defaultVariant.asset),i.option.colorProfile&&U.cacheAsset(i.option.colorProfile),i.option.variants?.forEach(o=>{o.asset&&U.cacheAsset(o.asset),o.thumbnail&&U.cacheAsset(o.thumbnail),o.material&&U.cacheMaterial(o.material)}),$t.set({id:i.option.id},Promise.resolve(i.option)))}),r.finalizeStepConfig||(r.finalizeStepConfig={}),r.finalizeStepConfig.termsMarkdown=r.finalizeStepConfig.termsMarkdown||r.partner.termsMarkdown}),n},Xc=async(a,t)=>{const n=(await t).find(r=>r.id===a);if(!n)throw new Error(`Workflow not found: ${a}`);return n},ia=async(a,t)=>{const e=a.map(s=>$t.get({id:s,options:t})),n=a.filter((s,l)=>e[l]===void 0);if(n.length===0)return Promise.all(e);const r=_c(n,t),i=n.map(s=>$t.set({id:s,options:t},Xc(s,r))),o=e.filter(s=>s!==void 0);return await Promise.all(o.concat(i))},ai=async(a,t)=>(await ia([a],t))[0],Zc=async a=>{const t=await y.getShadowGraphqlClient().query({query:No,variables:{ids:a},errorPolicy:"all",fetchPolicy:"no-cache"});return t.errors&&console.error(t.errors),t.data.integrationProducts||[]};class td{constructor(t){this.activeIntegration=void 0,this.updateTransactionState=async e=>{try{return y.getShadowGraphqlClient().mutate({...e,mutation:Ro})}catch(n){throw console.error(n),new mt("Critical - Unable to synchronize workflow state with server.")}},this.options=t,this.options.applicationKey&&_i(this.options.applicationKey),console.debug("------------------------"),console.debug("Spiff Commerce Core SDK"),console.debug("Version: 34.3.0"),console.debug(`Application Key Provided: ${!!this.options.applicationKey}`),console.debug("------------------------")}configure(t){ut.setHubUrl(t.hubUrl),ut.setServerUrl(t.serverUrl),ut.setServicesApiUrl(t.servicesApiUrl),this.marketplaceThemeInstallId=t.marketplaceThemeInstallId,this.marketplaceThemeInstallConfigurationId=t.marketplaceThemeInstallConfigurationId,this.userPoolClientId=t.userPoolClientId,this.userPoolRegion=t.userPoolRegion,this.spiffRegion=t.spiffRegion,t.bearerAuthenticationToken&&_a(t.bearerAuthenticationToken),this.options.applicationKey&&this.getIntegration(),this.spiffRegion&&this.userPoolRegion&&this.userPoolClientId&&jt.init(this.spiffRegion,this.userPoolRegion,this.userPoolClientId)}getAssetManager(){return U}getFlowService(){if(!Xi())throw new Error("Application key required to use Flow Service.");return new Xr}async getCurrencyContext(t){const n=(await this.getIntegration()).partner.currencyCode,i=await y.getShadowGraphqlClient().query({query:is,errorPolicy:"all",fetchPolicy:"cache-first",variables:{from:n,to:t}}),{rateFrom:o,rateTo:s}=i.data.currencyConversion;return new ni(o,s,n,t)}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=ri(this.options.applicationKey),this.activeIntegration}async canUseAddon(t){try{return(await this.getIntegration()).partner.activeAddons?.includes(t)??!1}catch(e){return console.error(e),!1}}async authenticateBundleFromLocalStorage(t){if(D.getMap("bundleOwnerIds")?.has(t))return Promise.resolve({success:!0,stakeholderType:ne.Owner});const n=D.getMap("bundlePartnerIds")||new Map;if(n.has(t)){const r=n.get(t);if((D.getMap("partnerCustomerIds")||new Map).get(r)&&await this.reloadLoggedInCustomer()){const l=this.customer?.bundleStakeholders?.find(c=>c.bundle?.id===t);if(l)return Promise.resolve({success:!0,stakeholderType:l.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=y.getShadowGraphqlClient(),n=await e.query({query:Xo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!n.data.transactions||n.data.transactions.length===0)throw new Error(`Transaction not found: ${t}`);const r=n.data.transactions[0];if(!r.product?.partner?.id)throw new Error(`Unable to read transaction: ${t}`);if(r.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});if(D.getMap("transactionOwnerIds")?.has(t))return Promise.resolve({success:!0,stakeholderType:ne.Owner});const s=D.getMap("transactionCustomerIds");if(s?.has(t)&&s.get(t)&&await this.reloadLoggedInCustomer()){const A=this.customer?.bundleStakeholders?.find(h=>h.bundle?.transactions?.some(g=>g.id===t))||this.customer?.stakeholders?.find(h=>h.transaction?.id===t);if(A)return Promise.resolve({success:!0,stakeholderType:A.type})}const c=(await e.query({query:Zo,errorPolicy:"all",variables:{id:r.workflowId}})).data.workflow;if(!c)throw new Error(`Unable to read workflow: ${r.workflowId}`);return Promise.resolve({success:!1,theme:c.overrideTheme,customLogoLink:r.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=D.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),D.setMap("transactionCustomerIds",e))}async customerHasBundleTemplates(t){const r=(await y.getShadowGraphqlClient().query({query:Ie,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;return r.id?r.hasBundleTemplates??!1:!1}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find(n=>n.transaction?.id===t);if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=y.getShadowGraphqlClient(),r=(await e.query({query:Ie,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!r.id){const s=(await e.mutate({mutation:Wc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!s)throw new Error("Unable to create customer.");return this.storeCustomer(s),this.customer=s,{customer:s,isAuthenticated:!1}}this.storeCustomer(r);const i=await this.reloadLoggedInCustomer();return{customer:this.customer||r,isAuthenticated:i}}getCustomer(){return this.customer}async reloadLoggedInCustomer(){const t=localStorage.getItem("last-refreshed-cognito-tokens"),e=localStorage.getItem("cognito-tokens"),n=localStorage.getItem("cognito-email");if(!t||!e||!n)return!1;const r=JSON.parse(e),i=new Date().getTime()/1e3;if(!r.ExpiresIn||r.ExpiresIn<i-parseInt(t)){const l=await jt.refreshTokens();if(l?.AuthenticationResult)localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),r.AccessToken=l.AuthenticationResult.AccessToken,localStorage.setItem("cognito-tokens",JSON.stringify(r));else return this.logOut(),console.error("Failed to refresh tokens."),!1}const s=(await y.getShadowGraphqlClient().query({query:Ie,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:n}})).data.customer;return s.id?(this.customer=s,!0):(console.error("Failed to get customer."),!1)}async generateVerificationCode(t){await y.getShadowGraphqlClient().mutate({mutation:Hc,variables:{emailAddress:t}}),await jt.generateCode(t)}async verifyCode(t,e){const n=(await this.getIntegration()).partner.id||"",r=await jt.verifyCode(t,e,n);if(r?.AuthenticationResult){localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),localStorage.setItem("cognito-tokens",JSON.stringify(r.AuthenticationResult)),localStorage.setItem("cognito-email",t);const o=(await y.getShadowGraphqlClient().query({query:Ie,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!o.id)throw new Error("Failed to get customer.");return this.customer=o,!0}else throw new Error}async logOut(){localStorage.removeItem("last-refreshed-cognito-tokens"),localStorage.removeItem("cognito-tokens"),localStorage.removeItem("cognito-email"),this.clearCustomer()}async loggedInBearerToken(){const t=localStorage.getItem("last-refreshed-cognito-tokens"),e=localStorage.getItem("cognito-tokens");if(!t||!e)throw new Error("No token data in storage.");const n=JSON.parse(e),r=new Date().getTime()/1e3,i=!n?.AccessToken||Re(n.AccessToken);if(!n.ExpiresIn||n.ExpiresIn<r-parseInt(t)||i){const o=await jt.refreshTokens();if(o?.AuthenticationResult)localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),n.AccessToken=o.AuthenticationResult.AccessToken,localStorage.setItem("cognito-tokens",JSON.stringify(n));else throw this.logOut(),new Error("Failed to refresh tokens.")}if(!n.AccessToken)throw new Error("No bearer token in storage.");return n.AccessToken}async getCustomerMetafields(){if(!this.customer?.id)throw new Error("Customer must be logged in before calling this function.");return(await y.getShadowGraphqlClient().query({query:Yc,variables:{id:this.customer.id}})).data.metafields}async getNewBundle(t,e,n){const i=(await y.getShadowGraphqlClient().mutate({mutation:Gl(n?.graphql?.productCollection?.eagerFetchProducts||!1),variables:{collectionId:t,initialMetadata:e?Object.entries(e).map((c,d)=>({key:c[0],value:c[1]})):void 0,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},fetchPolicy:"no-cache"})).data?.bundleCreate;if(!i?.id)throw new Error("Unable to create bundle");const o=D.getMap("bundlePartnerIds")||new Map;o.set(i.id,i.partner.id),D.setMap("bundlePartnerIds",o);const s=D.getMap("bundleOwnerIds")||new Map;s.set(i.id,i.bundleOwnerId),D.setMap("bundleOwnerIds",s);const l=new Ba(this,i,void 0,void 0,i.bundleOwnerId,{eagerFetchProducts:n?.graphql?.productCollection?.eagerFetchProducts});return await l.getInitializationPromise(),l}async getExistingBundle(t,e,n,r,i){const s=D.getMap("bundleOwnerIds")?.get(t),l={};try{const g=await this.loggedInBearerToken();l.Authorization=`Bearer ${g}`}catch{const p=Object.entries(localStorage).find(([S,w])=>S.startsWith("CognitoIdentityServiceProvider")&&S.endsWith("idToken"))?.[0]||"",f=localStorage.getItem(p);f&&!Re(f)&&(l.Authorization=`Bearer ${f}`)}const c={bundleOwnerId:s,...l,...r?.graphql?.additionalHeaders},d=await y.getShadowGraphqlClient().query({query:Ul(r?.graphql?.productCollection?.eagerFetchProducts||!1),variables:{id:t},fetchPolicy:"no-cache",context:{headers:c}});if(!d.data?.bundles||d.data?.bundles.length===0||!d.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const u=d.data?.bundles[0],A=D.getMap("bundlePartnerIds")||new Map;A.set(u.id,u.partner.id),D.setMap("bundlePartnerIds",A);const h=new Ba(this,u,e,n,s,{additionalHeaders:r?.graphql?.additionalHeaders,eagerFetchProducts:r?.graphql?.productCollection?.eagerFetchProducts,existingGlobalPropertyState:d.data.globalPropertyState,readonly:r?.readonly},i);return await h.getInitializationPromise(),h}async duplicateBundle(t,e,n,r){const o={...await oi(t),...r?.graphql?.additionalHeaders},l=(await y.getShadowGraphqlClient().mutate({mutation:jl(),variables:{id:t,template:e,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId,duplicateTransactions:n},context:{headers:o},fetchPolicy:"no-cache"})).data?.bundleDuplicate;if(!l?.id)throw new Error("Unable to duplicate bundle");const c=D.getMap("bundlePartnerIds")||new Map;c.set(l.id,l.partner.id),D.setMap("bundlePartnerIds",c);const d=D.getMap("bundleOwnerIds")||new Map;return d.set(l.id,l.bundleOwnerId),D.setMap("bundleOwnerIds",d),async()=>await this.getExistingBundle(l.id,void 0,void 0,{graphql:{productCollection:{eagerFetchProducts:r?.graphql?.productCollection?.eagerFetchProducts||!1}}})}async getBundlesForCustomer(t){if(!this.customer?.id)throw new Error("Customer not authenticated.");const{includeMetadata:e,...n}=t;return(await y.getShadowGraphqlClient().query({query:nc(e??!1),variables:{...n,id:this.customer.id},fetchPolicy:"no-cache"})).data.customerBundlesFeed}async getBundleStakeholders(){if(!this.customer)throw new Error("Customer not authenticated.");const t=await y.getShadowGraphqlClient().query({query:Ll,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!t.data?.customers||t.data.customers.length===0)throw new Error("Unable to find customer.");const n=t.data.customers[0].bundleStakeholders||[],r=D.getMap("bundlePartnerIds")||new Map;return n.forEach(i=>{i.bundle?.id&&i.bundle.partner?.id&&r.set(i.bundle.id,i.bundle.partner.id)}),D.setMap("bundlePartnerIds",r),n}async getWorkflowExperience(t,e){if(!t)throw new Error("getWorkflowExperience has been called without an options object! This is not supported.");const n=await this.getWorkflowExperiences([t],t.graphql),r=n[0],i=r.getWorkflow();return e&&!i&&console.error("No workflow instantiated when trying to create preview service."),e&&i&&await r.getWorkflowManager().injectIntoPreviewService(e(i)),n[0]}async getWorkflowExperiences(t,e,n,r){if(t.length===0)throw new mt("No options provided!");const i=t.map((P,T)=>({option:P,index:T})),o=i.filter(P=>P.option.type==="transaction"),s=i.filter(P=>P.option.type==="integration"||P.option.type==="external"||P.option.type==="blank"),l=50,c=fn(o,l),d=fn(s,l);let u=0;const A=y.getShadowGraphqlClient(),h=async P=>{if(P.length===0)return[];const T=P.map(W=>W.option.transactionId),V=await A.query({query:Qo,variables:{ids:T},errorPolicy:"all",fetchPolicy:"no-cache"}),k=V.data.transactions;if(u=u+k.length,r&&r(u,o.length),k.length!==P.length){const W=V.errors?.[0]?.message||"Unknown error";throw new mt(`Not all transactions were found: ${W}`)}return!this.activeIntegration&&k[0].integrationProduct?.integration&&(this.activeIntegration=Promise.resolve(k[0].integrationProduct.integration)),k.map((W,Xe)=>({transaction:W,workflowId:W.workflowId,readOnly:P.find(At=>At.option.transactionId===W.id)?.option.readOnly??!1,index:P[Xe].index}))},g=async P=>{if(P.length===0)return[];const T=await A.mutate({mutation:To,variables:{inputs:P.map(k=>({integrationProductId:k.option.type==="integration"?k.option.integrationProductId:void 0,externalIntegrationId:k.option.type==="external"?k.option.externalIntegrationId:void 0,externalProductId:k.option.type==="external"?k.option.externalProductId:void 0,workflowId:k.option.workflowId,designName:k.option.designName,claim:!0,quantity:k.option.quantity,recipient:k.option.recipient})),marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},errorPolicy:"all",fetchPolicy:"no-cache"}),V=T.data?.transactionCreateMany;if(!V||V.length===0){const k=T.errors?.[0]?.message||"Unknown error";throw new mt(`Failed to create transactions: ${k}`)}return u=u+V.length,r&&r(u,o.length),V.map((k,W)=>({transaction:k,workflowId:k.workflowId,readOnly:!1,index:P[W].index}))},m=(await Promise.all([...c.map(h),...d.map(g)])).flat(),p=[...new Set(m.map(P=>P.transaction.integrationProductId))].filter(P=>P!==void 0),f=[...new Set(m.map(P=>P.workflowId))].filter(P=>P!==void 0),[S,w]=await Promise.all([(async()=>p.length>0?await Zc(p):[])(),(async()=>f.length>0?await ia(f,e):[])()]),x=new Map(S.map(P=>[P.id,P])),v=new Map(w.map(P=>[P.id,P])),E=m.map(async P=>{const{transaction:T,workflowId:V,readOnly:k,index:W}=P,Xe=V?v.get(V):void 0,At=t[W];if(T.integrationProductId){const ot=x.get(T.integrationProductId);T.integrationProduct=ot,T.product=ot?.product,T.integrationProduct||console.error("failed to find transaction's product")}const fe=D.getMap("transactionOwnerIds")||new Map;!fe.get(T.id)&&T.transactionOwnerId&&(fe.set(T.id,T.transactionOwnerId),D.setMap("transactionOwnerIds",fe));const Ze=fe.get(T.id)||void 0,pi=new Jc({onMutate:()=>({context:{transactionOwnerId:Ze,bundleOwnerId:e?.bundleOwnerId}}),onQuery:()=>({context:{transactionOwnerId:Ze,bundleOwnerId:e?.bundleOwnerId}})}),Ce={workflow:Xe,transaction:T,singleVariantsRenderable:At?.workflowConfiguration?.singleVariantsRenderable,stateMutationFunc:k?async()=>{throw new Q("State mutation is forbidden in read only mode!")}:async ot=>this.updateTransactionState({...ot,context:{transactionOwnerId:Ze,bundleOwnerId:e?.bundleOwnerId}}),graphQlClient:()=>pi,readOnly:k,isReloadedTransaction:At.type==="transaction"};if(At.type==="transaction"&&T.workflowState){const ot=JSON.parse(T.workflowState);await Bn(ot),Ce.reloadedState=ot}else if(!k&&At.workflowState){const ot=JSON.parse(At.workflowState);await Bn(ot),Ce.reloadedState=ot}return Ce.delayWorkflowStateSync=!0,{experienceOptions:Ce,index:W,options:At}}),N=(await Promise.all(E)).sort((P,T)=>P.index-T.index);let R=[];for(const P of N){const{experienceOptions:T,options:V}=P,k=new Gr(this,T);await k.getWorkflowManager().getInitializationPromise(),n&&n(),V.type!=="transaction"&&this.customer&&await k.attachCustomerDetails({email:this.customer.emailAddress}),R=[...R,k],k.getWorkflowManager().setWorkflowStateSyncEnabled(!0)}return R}storeCustomer(t){const e=D.getMap("partnerCustomerIds")||new Map;e.set(t.partner.id,t.id),D.setMap("partnerCustomerIds",e)}async getIntegrationProductById(t,e){const i=(await y.getShadowGraphqlClient().query({query:qo(e),variables:{ids:[t]},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.integrationProducts;if(!i||i.length===0||!i[0]?.id)throw new Error("Integration product not found.");return new Mn(i[0])}async getIntegrationProductFromExternalIds(t,e,n){const o=(await y.getShadowGraphqlClient().query({query:Go(n),variables:{externalProductId:e,externalIntegrationId:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.integrationProductFromExternalIds;if(!o?.id)throw new Error("Integration product not found.");return new Mn(o)}async getIntegrationProduct(t){return t.type==="integration"?this.getIntegrationProductById(t.integrationProductId):this.getIntegrationProductFromExternalIds(t.externalIntegrationId,t.externalProductId)}async getShareActionsForTransaction(t){const n=(D.getMap("transactionOwnerIds")||new Map).get(t)||void 0,r=await y.getShadowGraphqlClient().query({query:Vo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t},context:{transactionOwnerId:n}});if(!r.data.transactions||r.data.transactions.length!==1)throw new Error(`Failed to fetch share actions for transaction: ${t}`);return r.data.transactions[0].transactionShareActions}async placeOrder(t){const e=await y.getShadowGraphqlClient().mutate({mutation:rs,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 ri=async(a,t)=>(await y.getShadowGraphqlClient().query({query:es,errorPolicy:"all",fetchPolicy:"no-cache",context:{headers:{"x-application-key":a}},variables:{themeConfigurationId:t}})).data.currentIntegration,ed=async a=>{const e=await y.getShadowGraphqlClient().query({query:Lo,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:a}});if(e.data.transactions.length!==0)return e.data.transactions[0]},nd=async(a,t)=>(await y.getShadowGraphqlClient().query({query:ts,errorPolicy:"all",variables:{themeConfigurationId:a,themeInstallId:t}})).data?.marketplaceThemeInstallConfiguration,ad=async a=>(await y.getShadowGraphqlClient().query({query:as,errorPolicy:"all",variables:{id:a}})).data?.bundles?.[0]?.marketplaceThemeInstallConfiguration,rd=async a=>(await y.getShadowGraphqlClient().query({query:ns,errorPolicy:"all",variables:{id:a}})).data?.transactions?.[0]?.marketplaceThemeInstallConfiguration;async function ii(){const a={};try{const t=await this.loggedInBearerToken();a.Authorization=`Bearer ${t}`}catch{const n=Object.entries(localStorage).find(([i,o])=>i.startsWith("CognitoIdentityServiceProvider")&&i.endsWith("idToken"))?.[0]||"",r=localStorage.getItem(n);r&&!Re(r)&&(a.Authorization=`Bearer ${r}`)}return a}async function oi(a){const e=D.getMap("bundleOwnerIds")?.get(a),n=await ii();return{bundleOwnerId:e,...n}}async function id(a){const e=D.getMap("transactionOwnerIds")?.get(a),n=await ii();return{transactionOwnerId:e,...n}}const od=async a=>{const t=await oi(a),e=await y.getShadowGraphqlClient().mutate({mutation:uc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:a},context:{headers:t}});if(e.data?.bundleDelete!==a)throw new Error(`Failed to delete bundle: ${e.errors}`)},sd=async a=>{const t=await id(a),e=await y.getShadowGraphqlClient().mutate({mutation:Ac,errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:[a]},context:{headers:t}});if(!e.data?.transactions||e.data.transactions.length!==1||e.data.transactions[0].id!==a)throw new Error(`Failed to find transaction to read bundle id: ${JSON.stringify(e.errors)}`);return e.data.transactions[0].bundle?.id};function si(a,t,e,n){const r=e.width*a.zoom,i=e.height*a.zoom;if(n){const s=a,l=Math.max(t.width/e.width,t.height/e.height);s.zoom=Math.max(l,a.zoom);const c=e.width*s.zoom,d=e.height*s.zoom;return s.x=Be(a.x,t.width-c,0),s.y=Be(a.y,t.height-d,0),s}const o=a;return o.x=Be(o.x,-r,t.width),o.y=Be(o.y,-i,t.height),o}function Be(a,t,e){return Math.min(Math.max(a,t),e)}class li{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 n=>{if(n){const r=n;if(r.currentFrameSources){let i=!1;for(let o=0;o<r.currentFrameSources.length;o++){const s=r.currentFrameSources[o],l=await me(s),c=this.frameData?this.frameData[o]:void 0;te(l,c)||(this.frameData||(this.frameData=new Array(r.currentFrameSources.length)),this.frameData[o]=l,i=!0)}i&&(this.onFrameDataChangeListeners.forEach(o=>o(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,n)=>{const r=Dt.get(e);r&&(this.frameData||(this.frameData=new Array(t.length)),this.frameData[n]=r)})}getImageData(){return this.imageData}getImageSrc(){if(this.imageData){if(this.imageData.svg){const t=je(this.imageData.svg,this.imageData.colors||{},!1);return qe(t)}return this.imageData.src}}getOffsets(){return this.offsets}setOffsets(t){this.offsets=t}setZoom(t,e,n,r){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((o,s)=>{const l=(e[s]-this.offsets[s].x)/this.offsets[s].zoom,c=(n[s]-this.offsets[s].y)/this.offsets[s].zoom,d=e[s]-l*t[s],u=n[s]-c*t[s];return{x:d,y:u,zoom:this.imageData.width*t[s]/this.imageData.width}});this.updateOffsets(i,r),this.onZoomChangeListeners.forEach(o=>o(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,n){const r=this.imageData;if(!r||!this.frameData)return;if(this.frameData.length!==t.length)throw new Q("Frame data and offsets are not the same length. This is a bug. Please report it.");if(!this.offsets.some((o,s)=>!(t[s].x===o.x&&t[s].y===o.y&&t[s].zoom===o.zoom))&&!n){e&&e();return}(!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length)),this.frameData.forEach((o,s)=>{this.offsets[s]=si(t[s],o,this.imageData,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,r,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,n,r,i){if(!n||n.length===0||n.some(l=>!l))throw new Q("Frame data not set. This is a bug");if(!this.workflowManager)throw new Q("No workflow manager set, cannot update offsets.");const o=this.workflowManager.getRegionElements(this.stepName||""),s=this.workflowManager.getCommandDispatcher();this.targetElements.forEach((l,c)=>{let d=o.find(u=>u.id===l)?.regionIndex??c;d>=t.length&&(d=c),s(new $([new qs(l,e,t[d]),new Gs(l,r.useThreshold,r.invertThreshold,r.threshold,r.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((n,r)=>{const i=Math.max(n.width/t.width,n.height/t.height);this.forceImageCover?(this.minZoomScale[r]=i,this.maxZoomScale[r]=i*2.5):(this.minZoomScale[r]=i/10,this.maxZoomScale[r]=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,n)=>{this.offsets[n]=Gn(t,e,this.initialZoom&&!this.forceImageCover?{scale:this.initialZoom}:void 0,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,t,this.frameData,this.thresholdSettings))}}class ld{traversableScenes(){throw new Error("Method not implemented.")}updateRecipient(t,e,n,r,i,o,s,l,c,d,u,A,h,g,m,p,f){throw new Error("Method not implemented.")}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(){}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,n){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(t){}async updateTransactionShareActions(){}addValidationCallback(t){}setStepError(t,e,n){}getStepErrors(t){}getValidationErrors(){return{steps:new Map}}async updateTransactionStakeholders(){}getStepTags(t){return[]}}var ci=(a=>(a.SelectFrame="SelectFrame",a.SelectImage="SelectImage",a.Position="Position",a))(ci||{});class di extends Z{constructor(t,e,n){super(t,e,n);const r=e.data;this.frameService=new li(r.forceImageCover,r.initialZoomLevel),this.frameService.connectWorkflowManager(t,e.stepName)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return gt.selectVariant(this.step,t.getResource(),e,this.manager,n=>this.setUpdateState(n))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged(e=>{e&&t(e)})}async selectImage(t,e=!0,n=!0){if(await gt.selectImage(this.step,t,this.manager,n),e){const r=this.manager.getStepStorage(this.step.stepName)?.framePatternData||{};this.manager.updateStorage(this.step.stepName,{framePatternData:{...r,originalAssetKey:t.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}})}}async canUseBackgroundRemover(){return this.manager.getClient().canUseAddon($e.BackgroundRemover)}async canRemoveBackground(){return await this.canUseBackgroundRemover()&&this.hasOriginalImageSelection()&&!!this.frameService?.getImageData()?.src&&!this.frameService?.getImageData()?.svg}async removeBackgroundFromImageSelection(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.getOriginalImageSelection();if(!e)throw new Error("You must supply an image selection before attempting to remove the background.");const n=await U.removeBackgroundFromAsset(e);t&&await gt.selectImage(this.step,n,this.manager,!1);const r=this.manager.getStepStorage(this.step.stepName)?.framePatternData||{};return this.manager.updateStorage(this.step.stepName,{framePatternData:{...r,backgroundRemovedAssetKey:n.key,useOriginalAsset:!t}}),n}changeColors(t){gt.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?gt.availableColors(this.step,this.manager):Promise.resolve([])}isColorPickerEnabled(){return this.step.data.colorPickerEnabled??!1}async getOriginalImageColors(){const t=this.getImageData();return t?.svg?(await it(t.svg)).colors:void 0}getMaxAllowedColors(){return this.step.data.maxColors}getUniqueColorCount(){return gt.getUniqueColorCount(this.step,this.manager)}getCurrentFrameStep(t,e,n,r){return r&&r.length>1&&t===void 0?"SelectFrame":e||n||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(){const t=this.manager.getStepStorage(this.step.stepName)?.framePatternData?.originalAssetKey;if(t)return U.getLocalOrFromServer(t)}async getBackgroundRemovedImageSelection(){const t=this.manager.getStepStorage(this.step.stepName)?.framePatternData?.backgroundRemovedAssetKey;if(t)return U.getLocalOrFromServer(t)}hasOriginalImageSelection(){return!!this.manager.getStepStorage(this.step.stepName)?.framePatternData?.originalAssetKey}hasBackgroundRemovedImageSelection(){return!!this.getFrameStepStorage()?.framePatternData?.backgroundRemovedAssetKey}getUseOriginalImageSelection(){return this.getFrameStepStorage()?.framePatternData?.useOriginalAsset??!1}async setUseOriginalImageSelection(t){const e=this.getFrameStepStorage()?.framePatternData||{};if(e.useOriginalAsset===t)return;const n=await this.getOriginalImageSelection();if(!n)throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");if(t)await this.selectImage(n,!1,!1);else{const r=await this.getBackgroundRemovedImageSelection();if(!r)throw new Error("You must call removeBackgroundFromImageSelection before attempting to apply the image.");await this.selectImage(r,!1,!1)}this.manager.updateStorage(this.step.stepName,{framePatternData:{...e,useOriginalAsset:t}})}getFrameStepStorage(){return this.manager.getStepStorage(this.step.stepName)}}const cd=C.gql`
|
|
2523
2532
|
query GetLoggedInCustomer($email: String!) {
|
|
2524
2533
|
customer(emailAddress: $email) {
|
|
2525
2534
|
id
|
|
2526
2535
|
}
|
|
2527
2536
|
}
|
|
2528
|
-
`,
|
|
2537
|
+
`,oa=C.gql`
|
|
2529
2538
|
query GetCustomerTransactions(
|
|
2530
2539
|
$id: String!
|
|
2531
2540
|
$limit: Int!
|
|
@@ -2562,21 +2571,21 @@
|
|
|
2562
2571
|
total
|
|
2563
2572
|
}
|
|
2564
2573
|
}
|
|
2565
|
-
`,
|
|
2574
|
+
`,dd=C.gql`
|
|
2566
2575
|
mutation SetTransactionDesignName($id: String!, $name: String!) {
|
|
2567
2576
|
transactionUpdate(id: $id, designName: $name) {
|
|
2568
2577
|
id
|
|
2569
2578
|
designName
|
|
2570
2579
|
}
|
|
2571
2580
|
}
|
|
2572
|
-
`,
|
|
2581
|
+
`,ud=C.gql`
|
|
2573
2582
|
mutation DuplicateTransaction($id: String!, $template: Boolean!) {
|
|
2574
2583
|
transactionDuplicate(id: $id, template: $template) {
|
|
2575
2584
|
id
|
|
2576
2585
|
workflowViewerLink
|
|
2577
2586
|
}
|
|
2578
2587
|
}
|
|
2579
|
-
`,
|
|
2588
|
+
`,Ad=C.gql`
|
|
2580
2589
|
query GetCustomerBundles($id: String!, $limit: Int!, $offset: Int!) {
|
|
2581
2590
|
customerBundlesFeed(id: $id, limit: $limit, offset: $offset) {
|
|
2582
2591
|
items {
|
|
@@ -2591,7 +2600,7 @@
|
|
|
2591
2600
|
total
|
|
2592
2601
|
}
|
|
2593
2602
|
}
|
|
2594
|
-
`,
|
|
2603
|
+
`,hd=C.gql`
|
|
2595
2604
|
query GetTransactionsForBundle($id: String!) {
|
|
2596
2605
|
bundles(ids: [$id]) {
|
|
2597
2606
|
id
|
|
@@ -2612,21 +2621,21 @@
|
|
|
2612
2621
|
}
|
|
2613
2622
|
}
|
|
2614
2623
|
}
|
|
2615
|
-
`,
|
|
2624
|
+
`,gd=C.gql`
|
|
2616
2625
|
mutation SetBundleName($id: String!, $name: String!) {
|
|
2617
2626
|
bundleUpdate(id: $id, name: $name) {
|
|
2618
2627
|
id
|
|
2619
2628
|
name
|
|
2620
2629
|
}
|
|
2621
2630
|
}
|
|
2622
|
-
`,
|
|
2631
|
+
`,md=C.gql`
|
|
2623
2632
|
mutation DuplicateBundle($id: String!, $template: Boolean!) {
|
|
2624
2633
|
bundleDuplicate(id: $id, template: $template) {
|
|
2625
2634
|
id
|
|
2626
2635
|
workflowViewerLink
|
|
2627
2636
|
}
|
|
2628
2637
|
}
|
|
2629
|
-
`,
|
|
2638
|
+
`,pd=C.gql`
|
|
2630
2639
|
query GetBundleTemplates($id: String!, $limit: Int!, $offset: Int!) {
|
|
2631
2640
|
customerBundlesFeed(id: $id, limit: $limit, offset: $offset, template: true) {
|
|
2632
2641
|
items {
|
|
@@ -2639,7 +2648,7 @@
|
|
|
2639
2648
|
total
|
|
2640
2649
|
}
|
|
2641
2650
|
}
|
|
2642
|
-
`,
|
|
2651
|
+
`,fd=async(a,t,e)=>await y.getShadowGraphqlClient().mutate({mutation:gd,errorPolicy:"all",variables:{id:a,name:t},context:e}),Cd=async(a,t)=>await y.getShadowGraphqlClient().mutate({mutation:dd,errorPolicy:"all",variables:{id:a,name:t}}),wd=async(a,t)=>await y.getShadowGraphqlClient().mutate({mutation:md,errorPolicy:"all",variables:{id:a,template:t}}),yd=async(a,t)=>await y.getShadowGraphqlClient().mutate({mutation:ud,errorPolicy:"all",variables:{id:a,template:t}}),Sd=async a=>(await y.getShadowGraphqlClient().query({query:cd,errorPolicy:"all",variables:{email:a}})).data.customer,vd=async(a,t,e)=>await y.getShadowGraphqlClient().query({query:Ad,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:a,offset:e,limit:t}}),Ed=async(a,t)=>await y.getShadowGraphqlClient().query({query:hd,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:a},context:t}),bd=async(a,t,e)=>(await y.getShadowGraphqlClient().query({query:oa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:a,quicksearch:"",filters:{link:"and",status:{operator:"isAnyOf",values:["Created","DesignCompleted","ExternallyOrdered"]},template:{value:"false"}},offset:e,limit:t}}))?.data.customerTransactionsFeed?.items||[],Id=async(a,t,e)=>(await y.getShadowGraphqlClient().query({query:oa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:a,quicksearch:"",filters:{link:"and",status:{operator:"equals",value:"Ordered"},template:{value:"false"}},offset:e,limit:t}}))?.data.customerTransactionsFeed?.items||[],Bd=async(a,t,e)=>(await y.getShadowGraphqlClient().query({query:oa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:a,quicksearch:"",filters:{link:"and",template:{value:"true"}},offset:e,limit:t}}))?.data.customerTransactionsFeed?.items||[],Pd=async(a,t,e)=>(await y.getShadowGraphqlClient().query({query:pd,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:a,offset:e,limit:t}}))?.data.customerBundlesFeed?.items||[];(function(){try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode("#spiffThemeWrapper{width:100%;height:100%}")),document.head.appendChild(a)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var ui=(a=>(a.Manual="Manual",a.OnStart="OnStart",a.OnQuit="OnQuit",a.OnEnd="OnEnd",a))(ui||{}),_t=(a=>(a.Email="Email",a.FirstName="FirstName",a.LastName="LastName",a.Phone="Phone",a.Apartment="Apartment",a.City="City",a.Country="Country",a.OrganizationName="OrganizationName",a.PostCode="PostCode",a.State="State",a.StreetAddress="StreetAddress",a.Custom="Custom",a))(_t||{}),_;_={__e:function(a,t,e,n){for(var r,i,o;t=t.__;)if((r=t.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(a)),o=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(a,n||{}),o=r.__d),o)return r.__E=r}catch(s){a=s}throw a}},typeof Promise=="function"&&Promise.prototype.then.bind(Promise.resolve());var st,hn,xa,Ai=[],gn=[],Fa=_.__b,Da=_.__r,ka=_.diffed,Ma=_.__c,Ta=_.unmount;function xd(){for(var a;a=Ai.shift();)if(a.__P&&a.__H)try{a.__H.__h.forEach(Fe),a.__H.__h.forEach(Tn),a.__H.__h=[]}catch(t){a.__H.__h=[],_.__e(t,a.__v)}}_.__b=function(a){st=null,Fa&&Fa(a)},_.__r=function(a){Da&&Da(a);var t=(st=a.__c).__H;t&&(hn===st?(t.__h=[],st.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.__V=gn,e.__N=e.i=void 0})):(t.__h.forEach(Fe),t.__h.forEach(Tn),t.__h=[])),hn=st},_.diffed=function(a){ka&&ka(a);var t=a.__c;t&&t.__H&&(t.__H.__h.length&&(Ai.push(t)!==1&&xa===_.requestAnimationFrame||((xa=_.requestAnimationFrame)||Fd)(xd)),t.__H.__.forEach(function(e){e.i&&(e.__H=e.i),e.__V!==gn&&(e.__=e.__V),e.i=void 0,e.__V=gn})),hn=st=null},_.__c=function(a,t){t.some(function(e){try{e.__h.forEach(Fe),e.__h=e.__h.filter(function(n){return!n.__||Tn(n)})}catch(n){t.some(function(r){r.__h&&(r.__h=[])}),t=[],_.__e(n,e.__v)}}),Ma&&Ma(a,t)},_.unmount=function(a){Ta&&Ta(a);var t,e=a.__c;e&&e.__H&&(e.__H.__.forEach(function(n){try{Fe(n)}catch(r){t=r}}),e.__H=void 0,t&&_.__e(t,e.__v))};var Na=typeof requestAnimationFrame=="function";function Fd(a){var t,e=function(){clearTimeout(n),Na&&cancelAnimationFrame(t),setTimeout(a)},n=setTimeout(e,100);Na&&(t=requestAnimationFrame(e))}function Fe(a){var t=st,e=a.__c;typeof e=="function"&&(a.__c=void 0,e()),st=t}function Tn(a){var t=st;a.__c=a.__(),st=t}const hi=C.gql`
|
|
2643
2652
|
fragment AddressValidationResultFields on AddressValidationResult {
|
|
2644
2653
|
addressComplete
|
|
2645
2654
|
address {
|
|
@@ -2661,8 +2670,8 @@
|
|
|
2661
2670
|
}
|
|
2662
2671
|
missingComponentTypes
|
|
2663
2672
|
}
|
|
2664
|
-
`,
|
|
2665
|
-
${
|
|
2673
|
+
`,sa=C.gql`
|
|
2674
|
+
${hi}
|
|
2666
2675
|
fragment AddressValidationJobFields on AddressValidationJob {
|
|
2667
2676
|
id
|
|
2668
2677
|
entityId
|
|
@@ -2673,15 +2682,15 @@
|
|
|
2673
2682
|
...AddressValidationResultFields
|
|
2674
2683
|
}
|
|
2675
2684
|
}
|
|
2676
|
-
`,
|
|
2677
|
-
${
|
|
2685
|
+
`,Dd=C.gql`
|
|
2686
|
+
${sa}
|
|
2678
2687
|
query GetAddressValidationJobs($ids: [String!]!) {
|
|
2679
2688
|
addressValidationJobs(ids: $ids) {
|
|
2680
2689
|
...AddressValidationJobFields
|
|
2681
2690
|
}
|
|
2682
2691
|
}
|
|
2683
|
-
`,
|
|
2684
|
-
${
|
|
2692
|
+
`,kd=C.gql`
|
|
2693
|
+
${sa}
|
|
2685
2694
|
query GetRecipientsWithAddressValidationJobs($ids: [String!]!) {
|
|
2686
2695
|
recipients(ids: $ids) {
|
|
2687
2696
|
id
|
|
@@ -2690,27 +2699,27 @@
|
|
|
2690
2699
|
}
|
|
2691
2700
|
}
|
|
2692
2701
|
}
|
|
2693
|
-
`,
|
|
2694
|
-
${
|
|
2702
|
+
`,Md=C.gql`
|
|
2703
|
+
${hi}
|
|
2695
2704
|
mutation ValidateRecipientAddress($id: String!) {
|
|
2696
2705
|
recipientValidate(id: $id) {
|
|
2697
2706
|
...AddressValidationResultFields
|
|
2698
2707
|
}
|
|
2699
2708
|
}
|
|
2700
|
-
`,
|
|
2701
|
-
${
|
|
2709
|
+
`,Td=C.gql`
|
|
2710
|
+
${sa}
|
|
2702
2711
|
mutation BatchValidateRecipientAddress($ids: [String!]!) {
|
|
2703
2712
|
recipientValidateBatch(ids: $ids) {
|
|
2704
2713
|
...AddressValidationJobFields
|
|
2705
2714
|
}
|
|
2706
2715
|
}
|
|
2707
|
-
`,
|
|
2716
|
+
`,Nd=C.gql`
|
|
2708
2717
|
mutation OverrideRecipientAddress($id: String!) {
|
|
2709
2718
|
recipientOverrideAddress(id: $id) {
|
|
2710
2719
|
id
|
|
2711
2720
|
}
|
|
2712
2721
|
}
|
|
2713
|
-
`;var
|
|
2722
|
+
`;var gi=(a=>(a.Confirmed="Confirmed",a.Plausible="Plausible",a.Unlikely="Unlikely",a))(gi||{}),mi=(a=>(a.Created="Created",a.Processing="Processing",a.Completed="Completed",a.Failed="Failed",a.Cancelled="Cancelled",a))(mi||{});const Qd=async a=>{const t=a.map(n=>n.getTransaction().recipient?.id).filter(n=>!!n),e=await y.getShadowGraphqlClient().query({query:kd,errorPolicy:"all",fetchPolicy:"network-only",variables:{ids:t}});return a.map(n=>{const r=n.getTransaction().recipient?.id;if(r)return e.data?.recipients?.find(i=>i.id===r)?.addressValidationJob})},Rd=async a=>(await y.getShadowGraphqlClient().query({query:Dd,errorPolicy:"all",fetchPolicy:"network-only",variables:{ids:a}})).data?.addressValidationJobs,Od=async a=>a.getTransaction().recipient?.id?(await y.getShadowGraphqlClient().mutate({mutation:Md,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:a.getTransaction().recipient.id}})).data?.recipientValidate:void 0,$d=async a=>{const t=a.map(n=>n.getTransaction().recipient?.id).filter(n=>!!n),e=await y.getShadowGraphqlClient().mutate({mutation:Td,errorPolicy:"all",fetchPolicy:"network-only",variables:{ids:t}});return a.map(n=>{const r=n.getTransaction().recipient?.id;if(r)return e.data?.recipientValidateBatch?.find(i=>i.entityId===r)})},Ud=async a=>{const t=a.getTransaction().recipient?.id;if(!t)return;(await y.getShadowGraphqlClient().mutate({mutation:Nd,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:t}})).data?.recipientOverrideAddress?.id&&(a.getTransaction().addressValidationStatus=Qn.Overridden)},Ld=C.gql`
|
|
2714
2723
|
query GetIntegrationProductsForIds($ids: [String!]!) {
|
|
2715
2724
|
integrationProducts(ids: $ids) {
|
|
2716
2725
|
id
|
|
@@ -2720,5 +2729,5 @@
|
|
|
2720
2729
|
}
|
|
2721
2730
|
}
|
|
2722
2731
|
}
|
|
2723
|
-
`,
|
|
2732
|
+
`,Vd=async a=>(await y.getShadowGraphqlClient().query({query:Ld,variables:{ids:a}})).data.integrationProducts;exports.AddonHandle=$e;exports.AddressValidationJobStatus=mi;exports.AddressValidationResultConfirmationLevel=gi;exports.AddressValidationStatus=Qn;exports.ArrayInput=jc;exports.AspectType=z;exports.AssetNotFoundError=ft;exports.AssetType=ee;exports.BringForwardCommand=Js;exports.BringToBackCommand=Ys;exports.BringToFrontCommand=Hs;exports.BundleDesignCreationCartAddMode=La;exports.CanvasCommand=O;exports.CollectionProduct=Ht;exports.ColorOptionGlobalPropertyHandle=Dn;exports.CommandContext=wr;exports.ConversionDataType=_t;exports.ConversionLocation=ui;exports.CreateElementCommand=G;exports.CreateLayoutCommand=Hn;exports.CurrencyContext=ni;exports.CurrencyService=ei;exports.DeleteElementCommand=xt;exports.DigitalContentStepHandle=Vr;exports.FileUploadGlobalPropertyHandle=jr;exports.FlowExecutionNodeResult=Yt;exports.FlowExecutionResult=Zr;exports.FlowService=Xr;exports.FontAlignmentCommand=Ir;exports.FontColorCommand=Er;exports.FontSizeCommand=br;exports.FontSourceCommand=Pn;exports.FrameService=li;exports.FrameStep=ci;exports.FrameStepHandle=di;exports.GlobalPropertyHandle=_e;exports.GroupCommand=$;exports.IllustrationStepHandle=Tr;exports.InformationMessageType=pe;exports.InformationStepHandle=Lr;exports.IntegrationProduct=Mn;exports.IntegrationType=za;exports.LayoutElementFactory=Us;exports.LayoutElementType=F;exports.LayoutNotFoundError=J;exports.LayoutRenderingPurpose=Nt;exports.MaterialStepHandle=Nr;exports.MisconfigurationError=re;exports.MockWorkflowManager=ld;exports.ModelStepHandle=Qr;exports.ModuleStepHandle=zr;exports.MoveCommand=Ls;exports.ObjectInput=ra;exports.ObjectInputType=ti;exports.OptionGlobalPropertyHandle=ea;exports.OptionNotFoundError=ae;exports.ParseError=Et;exports.PictureStepHandle=Rr;exports.ProductCameraRig=qa;exports.ProductCollection=na;exports.ProductCollectionProductSortKey=Jr;exports.ProductWorkflow=Tt;exports.PromiseCache=$t;exports.PromiseQueue=zn;exports.QuestionStepHandle=Or;exports.QueueablePromise=Vn;exports.ResizeCommand=zs;exports.ResourceNotFoundError=Qt;exports.RotateCommand=Vs;exports.ScaleAxis=H;exports.SendBackwardsCommand=Ks;exports.ShapeStepHandle=$r;exports.ShareActionType=Va;exports.SpiffCommerceClient=td;exports.StakeholderType=ne;exports.StepAspectType=Ua;exports.StepHandle=Z;exports.StepType=b;exports.TextAlgorithm=Bt;exports.TextChangeCommand=Br;exports.TextGlobalPropertyHandle=Wr;exports.TextInput=Gc;exports.TextStepHandle=Ur;exports.Transform=_r;exports.TransformCollection=Kr;exports.UnhandledBehaviorError=Q;exports.UnitOfMeasurement=Ga;exports.UpdateImageSourceCommand=js;exports.Variant=at;exports.WorkflowExperienceEventType=Oe;exports.WorkflowExperienceImpl=Gr;exports.assetService=U;exports.browserColorToHex=tr;exports.cmPerPixel=vs;exports.currentDirection=ws;exports.dataUrlFromExternalUrl=Wi;exports.deleteBundle=od;exports.designService=xe;exports.determineCorrectFontSizeAndLines=Kt;exports.digitalContentStepService=Yn;exports.domParser=lt;exports.duplicateBundle=wd;exports.duplicateTransaction=yd;exports.fetchAsString=et;exports.findAngle=As;exports.findElement=L;exports.findPmsColors=Ao;exports.frameDataCache=Dt;exports.frameStepService=gt;exports.generate=M;exports.generateCommands=kr;exports.generateSVGWithUnknownColors=it;exports.generateStateFromDesignInputSteps=Tl;exports.getAddressValidationJobs=Rd;exports.getAttributesFromArrayBuffer=de;exports.getAxisAlignedBoundingBox=us;exports.getBoundedOffsets=si;exports.getBundleIdForTransaction=sd;exports.getBundleThemeConfiguration=ad;exports.getCustomer=Sd;exports.getCustomerBundles=vd;exports.getElementVertices=ys;exports.getFrameData=me;exports.getGlobalPropertyStateForBundle=Ol;exports.getIntegration=ri;exports.getIntegrationProducts=Vd;exports.getNEPoint=fs;exports.getNWPoint=ps;exports.getOrderedTransactions=Id;exports.getOverrideThemeConfiguration=nd;exports.getPointOfRotation=ms;exports.getProductCollections=$c;exports.getSEPoint=Cs;exports.getSvgElement=Ye;exports.getTemplateBundles=Pd;exports.getTemplateTransactions=Bd;exports.getTransaction=ed;exports.getTransactionThemeConfiguration=rd;exports.getTransactionsForBundle=Ed;exports.getTrueCoordinates=gs;exports.getUnorderedTransactions=bd;exports.getValidationJobsForWorkflowExperiences=Qd;exports.getWorkflow=ai;exports.getWorkflows=ia;exports.graphQlManager=y;exports.illustrationStepService=Jt;exports.isCloseToValue=hs;exports.loadFont=Pt;exports.matchHexToPms=lo;exports.materialStepService=Jn;exports.metafieldManager=Yr;exports.mmPerPixel=Ss;exports.modelStepService=Kn;exports.modifySVGColors=je;exports.moduleStepService=_n;exports.nameBundle=fd;exports.nameTransaction=Cd;exports.optionService=Y;exports.outlineFontsInSvg=Ps;exports.overrideWorkflowExperienceRecipientAddress=Ud;exports.patternImageDataCache=dt;exports.persistenceService=D;exports.pictureStepService=Xn;exports.pmsToRgb=so;exports.questionStepService=Zn;exports.registerFetchImplementation=Vi;exports.registerWindowImplementation=Li;exports.rehydrateSerializedLayout=Bn;exports.rgbToPms=Za;exports.rotateAroundPoint=Wt;exports.sanitizeSvgTree=Ge;exports.setBearerAuthenticationToken=_a;exports.setCanvasModule=On;exports.shapeStepService=kt;exports.shortenUrl=Pr;exports.spiffCoreConfiguration=ut;exports.stepAspectValuesToDesignInputSteps=Ml;exports.svgColorValueToDefinition=vn;exports.svgStringDimensions=Wn;exports.svgToDataUrl=qe;exports.textStepService=j;exports.toast=Fr;exports.validateWorkflowExperienceRecipient=Od;exports.validateWorkflowExperienceRecipients=$d;exports.xmlSerializer=St;
|
|
2724
2733
|
//# sourceMappingURL=index.js.map
|