@spiffcommerce/core 21.18.0 → 21.19.0
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 +7 -7
- package/dist/index.js +4 -0
- package/dist/index.umd.cjs +3 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1744,23 +1744,23 @@ interface GetWorkflowFromTransactionOptions extends GetWorkflowOptionsBase {
|
|
|
1744
1744
|
workflowState?: string;
|
|
1745
1745
|
type: "transaction";
|
|
1746
1746
|
}
|
|
1747
|
-
interface
|
|
1747
|
+
interface GetNewWorkflowOptionsBase extends GetWorkflowOptionsBase {
|
|
1748
|
+
/** A name for the new transaction. */
|
|
1749
|
+
designName?: string;
|
|
1748
1750
|
/** The workflow to load. */
|
|
1749
1751
|
workflowId: string;
|
|
1750
|
-
integrationProductId: string;
|
|
1751
1752
|
/** An existing workflow state, if available. */
|
|
1752
1753
|
workflowState?: string;
|
|
1754
|
+
}
|
|
1755
|
+
interface GetWorkflowFromIntegrationProductOptions extends GetNewWorkflowOptionsBase {
|
|
1756
|
+
integrationProductId: string;
|
|
1753
1757
|
type: "integration";
|
|
1754
1758
|
}
|
|
1755
|
-
interface GetWorkflowFromExternalProductOptions extends
|
|
1756
|
-
/** The workflow to load. */
|
|
1757
|
-
workflowId: string;
|
|
1759
|
+
interface GetWorkflowFromExternalProductOptions extends GetNewWorkflowOptionsBase {
|
|
1758
1760
|
/** The external ID associated with an integration. */
|
|
1759
1761
|
externalIntegrationId: string;
|
|
1760
1762
|
/** The ID of the product from the external system. */
|
|
1761
1763
|
externalProductId: string;
|
|
1762
|
-
/** An existing workflow state, if available. */
|
|
1763
|
-
workflowState?: string;
|
|
1764
1764
|
type: "external";
|
|
1765
1765
|
}
|
|
1766
1766
|
type GetNewWorkflowOptions = GetWorkflowFromIntegrationProductOptions | GetWorkflowFromExternalProductOptions;
|
package/dist/index.js
CHANGED
|
@@ -833,6 +833,7 @@ const oe = D`
|
|
|
833
833
|
$externalProductId: String
|
|
834
834
|
$claim: Boolean
|
|
835
835
|
$workflowId: String
|
|
836
|
+
$designName: String
|
|
836
837
|
) {
|
|
837
838
|
transactionCreate(
|
|
838
839
|
integrationProductId: $integrationProductId
|
|
@@ -840,6 +841,7 @@ const oe = D`
|
|
|
840
841
|
externalProductId: $externalProductId
|
|
841
842
|
claim: $claim
|
|
842
843
|
workflowId: $workflowId
|
|
844
|
+
designName: $designName
|
|
843
845
|
) {
|
|
844
846
|
id
|
|
845
847
|
designName
|
|
@@ -10836,6 +10838,7 @@ class Hi {
|
|
|
10836
10838
|
variables: {
|
|
10837
10839
|
...I,
|
|
10838
10840
|
workflowId: a.workflowId,
|
|
10841
|
+
designName: a.designName,
|
|
10839
10842
|
claim: !0
|
|
10840
10843
|
},
|
|
10841
10844
|
errorPolicy: "all",
|
|
@@ -10944,6 +10947,7 @@ class Hi {
|
|
|
10944
10947
|
externalIntegrationId: S.option.type === "external" ? S.option.externalIntegrationId : void 0,
|
|
10945
10948
|
externalProductId: S.option.type === "external" ? S.option.externalProductId : void 0,
|
|
10946
10949
|
workflowId: S.option.workflowId,
|
|
10950
|
+
designName: S.option.designName,
|
|
10947
10951
|
claim: !0
|
|
10948
10952
|
}))
|
|
10949
10953
|
},
|
package/dist/index.umd.cjs
CHANGED
|
@@ -177,6 +177,7 @@
|
|
|
177
177
|
$externalProductId: String
|
|
178
178
|
$claim: Boolean
|
|
179
179
|
$workflowId: String
|
|
180
|
+
$designName: String
|
|
180
181
|
) {
|
|
181
182
|
transactionCreate(
|
|
182
183
|
integrationProductId: $integrationProductId
|
|
@@ -184,6 +185,7 @@
|
|
|
184
185
|
externalProductId: $externalProductId
|
|
185
186
|
claim: $claim
|
|
186
187
|
workflowId: $workflowId
|
|
188
|
+
designName: $designName
|
|
187
189
|
) {
|
|
188
190
|
id
|
|
189
191
|
designName
|
|
@@ -3097,4 +3099,4 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
|
|
|
3097
3099
|
}
|
|
3098
3100
|
}
|
|
3099
3101
|
}
|
|
3100
|
-
`,oe=async c=>{var e;for(const t in c.layouts){const A=c.layouts[t].elements.filter(a=>a.type===l.LayoutElementType.Illustration);for(let a=0;a<A.length;++a){const i=A[a];i.src&&i.svg&&(i.cachedObjectURL=await l.svgObjectURL(i.svg))}const n=c.layouts[t].elements.filter(a=>a.type===l.LayoutElementType.Textbox);for(let a=0;a<n.length;++a){const i=n[a];(e=i.fontData)!=null&&e.assetUrl&&await l.loadFont(i.fontData.assetUrl)}}},xa=async(c,e)=>{var n;const t=await N.getShadowGraphqlClient().query({query:Ia(((n=e==null?void 0:e.assets)==null?void 0:n.metadata)||!1),errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:c}}),A=t.data.workflows;if(A===void 0||A.length!==c.length)throw new Error(`Unable to read workflows: ${t.errors??"Length mismatch in response"}`);return A.forEach(a=>{a.steps.forEach(i=>{var o,s,r;delete i.data.__typename,(o=i.option)!=null&&o.id&&((s=i.option.defaultVariant)!=null&&s.asset&&G.cacheAsset(i.option.defaultVariant.asset),i.option.colorProfile&&G.cacheAsset(i.option.colorProfile),(r=i.option.variants)==null||r.forEach(g=>{g.asset&&G.cacheAsset(g.asset),g.displayImage&&G.cacheAsset(g.displayImage),g.thumbnail&&G.cacheAsset(g.thumbnail),g.material&&G.cacheMaterial(g.material)}),ee.set({id:i.option.id},Promise.resolve(i.option)))})}),A},Na=async(c,e)=>{const A=(await e).find(n=>n.id===c);if(!A)throw new Error(`Workflow not found: ${c}`);return A},At=async(c,e)=>{const t=c.map(o=>ee.get({id:o,options:e})),A=c.filter((o,s)=>t[s]===void 0);if(A.length===0)return Promise.all(t);const n=xa(A,e),a=A.map(o=>ee.set({id:o,options:e},Na(o,n))),i=t.filter(o=>o!==void 0);return await Promise.all(i.concat(a))},me=async(c,e)=>(await At([c],e))[0],Ha=c=>c.sort((e,t)=>e.index-t.index).map(e=>({id:l.generate(),panelId:e.name,name:e.name,index:e.index,createdAt:new Date,updatedAt:new Date,transparentBackground:e.transparentBackground,height:e.height,width:e.width,previewRegion:e.previewRegion,useEditableArea:e.useEditableArea,editableArea:e.editableArea})),nt=(c,e)=>{const t=c.workflowState,A=t?JSON.parse(t):void 0;return A?Object.values(A.layouts).map(n=>n.layout):Ha(e.panels)};class wA{constructor(e){this.activeIntegration=void 0,this.updateTransactionState=async t=>{try{return N.getShadowGraphqlClient().mutate({...t,mutation:LA})}catch(A){throw console.error(A),new v("Critical - Unable to synchronize workflow state with server.")}},this.initialized=!1,this.options=e,this.options.applicationKey&&fA(this.options.applicationKey)}getAssetManager(){return G}getCurrencyCode(){if(this.currencyCode===void 0)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!IA())throw new Error("Application key required to use Flow Service.");return new lA}async getIntegration(){if(!this.options.applicationKey)throw new Error("Cannot get current Integration without specifying an Application Key.");if(this.activeIntegration)return this.activeIntegration;const e=async()=>(await N.getShadowGraphqlClient().query({query:Da,errorPolicy:"all",fetchPolicy:"no-cache"})).data.currentIntegration;return this.activeIntegration=e(),this.activeIntegration}async canUseAddon(e){var t;try{return((t=(await this.getIntegration()).partner.activeAddons)==null?void 0:t.includes(e))??!1}catch(A){return console.error(A),!1}}async authenticateBundleFromLocalStorage(e){var n,a;const t=Y.getMap("bundleOwnerIds");if(t!=null&&t.has(e))return Promise.resolve({success:!0,stakeholderType:Be.Owner});const A=Y.getMap("bundlePartnerIds")||new Map;if(A.has(e)){const i=A.get(e),s=(Y.getMap("partnerCustomerIds")||new Map).get(i);if(s&&await this.authenticateCustomerId(s)){const g=(a=(n=this.customer)==null?void 0:n.bundleStakeholders)==null?void 0:a.find(B=>{var d;return((d=B.bundle)==null?void 0:d.id)===e});if(g)return Promise.resolve({success:!0,stakeholderType:g.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(e){var g,B,d,w,h,C;const t=N.getShadowGraphqlClient(),A=await t.query({query:pa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:e}});if(!A.data.transactions||A.data.transactions.length===0)throw new Error(`Transaction not found: ${e}`);const n=A.data.transactions[0];if(!((B=(g=n.product)==null?void 0:g.partner)==null?void 0:B.id))throw new Error(`Unable to read transaction: ${e}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=Y.getMap("transactionOwnerIds");if(i!=null&&i.has(e))return Promise.resolve({success:!0,stakeholderType:Be.Owner});const o=Y.getMap("transactionCustomerIds");if(o!=null&&o.has(e)){const E=o.get(e);if(E&&await this.authenticateCustomerId(E)){const Q=((w=(d=this.customer)==null?void 0:d.bundleStakeholders)==null?void 0:w.find(F=>{var f,p;return(p=(f=F.bundle)==null?void 0:f.transactions)==null?void 0:p.some(I=>I.id===e)}))||((C=(h=this.customer)==null?void 0:h.stakeholders)==null?void 0:C.find(F=>{var f;return((f=F.transaction)==null?void 0:f.id)===e}));if(Q)return Promise.resolve({success:!0,stakeholderType:Q.type})}}const r=(await t.query({query:Fa,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(e){const t=Y.getMap("transactionCustomerIds");t!=null&&t.has(e)&&(t.delete(e),Y.setMap("transactionCustomerIds",t))}getStakeholderTypeForTransaction(e){var A,n;const t=(n=(A=this.customer)==null?void 0:A.stakeholders)==null?void 0:n.find(a=>{var i;return((i=a.transaction)==null?void 0:i.id)===e});if(t)return t.type}async getOrCreateCustomer(e){var i;this.customer=void 0;const t=N.getShadowGraphqlClient(),n=(await t.query({query:Ma,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e}})).data.customer;if(!n.id){const s=(i=(await t.mutate({mutation:ya,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:e}}})).data)==null?void 0:i.customerCreate;if(!s)throw new Error("Unable to create customer.");return this.storeCustomer(s),this.customer=s,{customer:s,isAuthenticated:!1}}this.storeCustomer(n);const a=await this.authenticateCustomerId(n.id);return{customer:this.customer||n,isAuthenticated:a}}async authenticateCustomerId(e){var o;const t=N.getShadowGraphqlClient(),A=Y.getMap("customerTokens");if(!(A!=null&&A.has(e)))return!1;const n=A.get(e);if(!n)return!1;const i=(o=(await t.mutate({mutation:Sa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data)==null?void 0:o.customerAuthenticate;return i?(this.storeCustomer(i),wt(n),this.customer=i,!0):!1}async generateVerificationCode(e){await N.getShadowGraphqlClient().mutate({mutation:Ya,variables:{emailAddress:e}})}async verifyCode(e,t){var a,i;const n=(a=(await N.getShadowGraphqlClient().mutate({mutation:Pa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e,verificationCode:t}})).data)==null?void 0:a.customerVerifyCode;if(n!=null&&n.loginToken){if(!((i=n.partner)!=null&&i.id))throw new Error(`Unable to find customer: ${e}`);const o=Y.getMap("customerTokens")||new Map;return o.set(n.id,n.loginToken),Y.setMap("customerTokens",o),this.storeCustomer(n),wt(n.loginToken),this.customer={...n,loginToken:void 0},!0}return!1}async getNewBundle(e,t,A){var s,r,g;const a=(g=(await N.getShadowGraphqlClient().mutate({mutation:_n(((r=(s=A==null?void 0:A.graphql)==null?void 0:s.productCollection)==null?void 0:r.eagerFetchProducts)||!1),variables:{collectionId:e,initialMetadata:t?Object.entries(t).map((B,d)=>({key:B[0],value:B[1]})):void 0},fetchPolicy:"no-cache"})).data)==null?void 0:g.bundleCreate;if(!(a!=null&&a.id))throw new Error("Unable to create bundle");const i=Y.getMap("bundlePartnerIds")||new Map;i.set(a.id,a.partner.id),Y.setMap("bundlePartnerIds",i);const o=Y.getMap("bundleOwnerIds")||new Map;return o.set(a.id,a.bundleOwnerId),Y.setMap("bundleOwnerIds",o),new gA(this,a,void 0,void 0,a.bundleOwnerId)}async getExistingBundle(e,t,A,n){var E,m,Q,F,f,p,I,D,y;const a=Y.getMap("bundleOwnerIds"),i=a==null?void 0:a.get(e),s=((E=Object.entries(localStorage).find(([S,x])=>S.startsWith("CognitoIdentityServiceProvider")&&S.endsWith("idToken")))==null?void 0:E[0])||"",r=localStorage.getItem(s),g={};r&&!Xe(r)&&(g.Authorization=`Bearer ${r}`);const B={bundleOwnerId:i,...g,...(m=n==null?void 0:n.graphql)==null?void 0:m.additionalHeaders},d=await N.getShadowGraphqlClient().query({query:Xn(((F=(Q=n==null?void 0:n.graphql)==null?void 0:Q.productCollection)==null?void 0:F.eagerFetchProducts)||!1),variables:{id:e},fetchPolicy:"no-cache",context:{headers:B}});if(!((f=d.data)!=null&&f.bundles)||((p=d.data)==null?void 0:p.bundles.length)===0||!((I=d.data)!=null&&I.bundles[0]))throw new Error(`Unable to find bundle: ${e}`);const w=(D=d.data)==null?void 0:D.bundles[0],h=Y.getMap("bundlePartnerIds")||new Map;h.set(w.id,w.partner.id),Y.setMap("bundlePartnerIds",h);const C=new gA(this,w,t,A,i,{additionalHeaders:(y=n==null?void 0:n.graphql)==null?void 0:y.additionalHeaders});return await C.getInitializationPromise(),C}async getBundleStakeholders(){var a;if(!this.customer)throw new Error("Customer not authenticated.");const e=await N.getShadowGraphqlClient().query({query:Zn,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((a=e.data)!=null&&a.customers)||e.data.customers.length===0)throw new Error("Unable to find customer.");const A=e.data.customers[0].bundleStakeholders||[],n=Y.getMap("bundlePartnerIds")||new Map;return A.forEach(i=>{var o,s;(o=i.bundle)!=null&&o.id&&((s=i.bundle.partner)!=null&&s.id)&&n.set(i.bundle.id,i.bundle.partner.id)}),Y.setMap("bundlePartnerIds",n),A}async getWorkflowExperience(e,t,A,n){var B,d,w,h,C;if(!n)return await this.getWorkflowExperienceDeprecated(e,t,A);const a=async()=>{var m,Q;const E=N.getShadowGraphqlClient();if(n.type==="transaction"){const{transactionId:F,readOnly:f}=n,p=await E.query({query:De,variables:{ids:[F]},errorPolicy:"all",fetchPolicy:"no-cache"});if(!((m=p.data)!=null&&m.transactions)||p.data.transactions.length===0)throw new v("Existing transaction not found.");const I=(Q=p.data)==null?void 0:Q.transactions[0];if(!I.workflowId)throw new v("Existing transaction has no workflow ID.");const D=await me(I.workflowId);if(!I.product)throw new v("Failed to load transaction, product not available.");return{transaction:I,workflow:D,readOnly:f}}if(n.type==="integration"||n.type==="external"){const F=async()=>{const D=n.type==="integration"?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},y=await E.mutate({mutation:pt,variables:{...D,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!y.data||!y.data.transactionCreate)throw new v("Failed to create transaction!");const S=y.data.transactionCreate;if(!S.product)throw new v("Failed to create transaction, product not available.");return S},f=me(n.workflowId,n==null?void 0:n.graphql),[p,I]=await Promise.all([F(),f]);return{transaction:p,workflow:I}}throw new v("No workflow ID provided.")},{transaction:i,workflow:o,readOnly:s}=await a();this.currencyCode=(B=i.product.partner)==null?void 0:B.currencyCode;const r={product:i.product,transaction:i,layouts:[],singleVariantsRenderable:(d=n==null?void 0:n.workflowConfiguration)==null?void 0:d.singleVariantsRenderable,stateMutationFunc:s?async()=>{throw new k("State mutation is forbidden in read only mode!")}:async E=>{const Q=(Y.getMap("transactionOwnerIds")||new Map).get(i.id)||void 0;return this.updateTransactionState({...E,context:{transactionOwnerId:Q}})},readOnly:s,workflow:o};if(n.type==="transaction"&&i.workflowState){const E=JSON.parse(i.workflowState);r.layouts=Object.values(E.layouts).map(m=>m.layout),await l.rehydrateSerializedLayout(E),await oe(E),r.reloadedState=E}else if(!s&&n.workflowState){const E=JSON.parse(n.workflowState);r.layouts=Object.values(E.layouts).map(m=>m.layout),await l.rehydrateSerializedLayout(E),await oe(E),r.reloadedState=E}else r.layouts=nt(r.transaction,r.workflow);if(r.renderableContextService=new Pe(r.layouts),n.previewService?(r.previewService=n.previewService,(w=r.product)!=null&&w.modelUrl&&(r.modelContainer=r.previewService.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))):(r.previewService=A&&A(o),(h=r.product)!=null&&h.modelUrl&&(r.modelContainer=(C=r.previewService)==null?void 0:C.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))),n.type!=="transaction"){const E=Y.getMap("transactionOwnerIds")||new Map;E.set(i.id,i.transactionOwnerId),Y.setMap("transactionOwnerIds",E)}else r.isReloadedTransaction=!0;this.initialized=!0,this.experienceOptions=r;const g=new ue(this,r);return await g.getWorkflowManager().getInitializationPromise(),n.type!=="transaction"&&this.customer&&await g.attachCustomerDetails({email:this.customer.emailAddress}),g}async getWorkflowExperiences(e,t){if(e.length===0)throw new v("No options provided!");const A=N.getShadowGraphqlClient(),n=async p=>{var S,x;if(p.length===0)return[];const I=p.map(P=>P.option.transactionId),D=await A.query({query:De,variables:{ids:I},errorPolicy:"all",fetchPolicy:"no-cache"}),y=D.data.transactions;if(y.length!==p.length){const P=((x=(S=D.errors)==null?void 0:S[0])==null?void 0:x.message)||"Unknown error";throw new v(`Not all transactions were found: ${P}`)}return y.map((P,H)=>{var R;return{transaction:P,workflowId:P.workflowId,readOnly:((R=p.find(T=>T.option.transactionId===P.id))==null?void 0:R.option.readOnly)??!1,index:p[H].index}})},a=async p=>{var y,S,x;if(p.length===0)return[];const I=await A.mutate({mutation:TA,variables:{inputs:p.map(P=>({integrationProductId:P.option.type==="integration"?P.option.integrationProductId:void 0,externalIntegrationId:P.option.type==="external"?P.option.externalIntegrationId:void 0,externalProductId:P.option.type==="external"?P.option.externalProductId:void 0,workflowId:P.option.workflowId,claim:!0}))},errorPolicy:"all",fetchPolicy:"no-cache"}),D=(y=I.data)==null?void 0:y.transactionCreateMany;if(!D||D.length===0){const P=((x=(S=I.errors)==null?void 0:S[0])==null?void 0:x.message)||"Unknown error";throw new v(`Failed to create transactions: ${P}`)}return D.map((P,H)=>({transaction:P,workflowId:P.workflowId,readOnly:!1,index:p[H].index}))},i=e.map((p,I)=>({option:p,index:I})),o=i.filter(p=>p.option.type==="transaction"),s=i.filter(p=>p.option.type==="integration"||p.option.type==="external"),r=gt(o,10),g=gt(s,10),B=(await Promise.all([...r.map(n),...g.map(a)])).flat(),d=[...new Set(B.map(p=>p.workflowId))],w=await At(d,t),h=new Map(w.map(p=>[p.id,p])),C=Y.getMap("transactionOwnerIds")||new Map,E=B.map(async p=>{var T;const{transaction:I,workflowId:D,readOnly:y,index:S}=p,x=h.get(D),P=e[S];!C.get(I.id)&&I.transactionOwnerId&&C.set(I.id,I.transactionOwnerId);const H=C.get(I.id)||void 0,R={product:I.product,transaction:I,layouts:[],singleVariantsRenderable:(T=P==null?void 0:P.workflowConfiguration)==null?void 0:T.singleVariantsRenderable,stateMutationFunc:y?async()=>{throw new k("State mutation is forbidden in read only mode!")}:async b=>this.updateTransactionState({...b,context:{transactionOwnerId:H}}),readOnly:y,workflow:x,isReloadedTransaction:P.type==="transaction"};if(P.type==="transaction"&&I.workflowState){const b=JSON.parse(I.workflowState);R.layouts=Object.values(b.layouts||{}).map(j=>j.layout),await l.rehydrateSerializedLayout(b),await oe(b),R.reloadedState=b}else if(!y&&P.workflowState){const b=JSON.parse(P.workflowState);R.layouts=Object.values(b.layouts||{}).map(j=>j.layout),await l.rehydrateSerializedLayout(b),await oe(b),R.reloadedState=b}else R.layouts=nt(R.transaction,R.workflow);return R.renderableContextService=new Pe(R.layouts),R.delayWorkflowStateSync=!0,this.initialized=!0,this.experienceOptions=R,{experienceOptions:R,index:S,options:P}});Y.setMap("transactionOwnerIds",C);const F=(await Promise.all(E)).sort((p,I)=>p.index-I.index).map(async p=>{const{experienceOptions:I,options:D}=p,y=new ue(this,I);return await y.getWorkflowManager().getInitializationPromise(),D.type!=="transaction"&&this.customer&&await y.attachCustomerDetails({email:this.customer.emailAddress}),y}),f=await Promise.all(F);return f.forEach(p=>p.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),f}async initFromIntegrationProduct(e){var i;if(e==="")throw new v("No integration product ID provided.");const A=await N.getShadowGraphqlClient().mutate({mutation:pt,variables:{integrationProductId:e,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new v("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new v("Failed to create transaction, product not available.");this.currencyCode=(i=n.product.partner)==null?void 0:i.currencyCode;const a=Y.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),Y.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async o=>this.updateTransactionState({...o,context:{transactionOwnerId:n.transactionOwnerId}})},this.initialized=!0}async initFromTransaction(e,t=!1){var o,s,r,g;if(e==="")throw new v("No transaction ID provided.");const A=N.getShadowGraphqlClient(),n=async()=>{var w,h;const d=(w=(await A.query({query:De,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:w.transactions[0];if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(h=d.product.partner)==null?void 0:h.currencyCode,this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async()=>{throw new k("State mutation is forbidden in read only mode!")},readOnly:t},this.initialized=!0};if(t)return await n();const a=Y.getMap("transactionOwnerIds")||new Map,i=a.get(e);if(i){const d=(o=(await A.query({query:De,variables:{ids:[e]},errorPolicy:"all"})).data)==null?void 0:o.transactions[0];if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(s=d.product.partner)==null?void 0:s.currencyCode,this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:i}}),readOnly:t},this.initialized=!0;return}try{const d=(r=(await A.mutate({mutation:OA,variables:{id:e},errorPolicy:"all"})).data)==null?void 0:r.transactionClaim;if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(g=d.product.partner)==null?void 0:g.currencyCode,d.transactionOwnerId&&(a.set(d.id,d.transactionOwnerId),Y.setMap("transactionOwnerIds",a)),this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:d.transactionOwnerId}}),readOnly:t},this.initialized=!0}catch{throw new v("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(e,t,A){var n,a,i,o;if(!this.initialized||!this.experienceOptions)throw new v("Cannot launch experience: Not initialized.");if(this.experienceOptions.transaction.workflowId){const s=await me(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=s,this.experienceOptions.transaction.workflowState){const g=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(g.layouts).map(B=>B.layout),await l.rehydrateSerializedLayout(g),await oe(g),this.experienceOptions.reloadedState=g}this.experienceOptions.previewService=A&&A(s),this.experienceOptions.renderableContextService=new Pe(this.experienceOptions.layouts),(n=this.experienceOptions.product)!=null&&n.modelUrl&&(this.experienceOptions.modelContainer=(a=this.experienceOptions.previewService)==null?void 0:a.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const r=new ue(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}if(e){const r=(Y.getMap("transactionOwnerIds")||new Map).get(this.experienceOptions.transaction.id),g=N.getShadowGraphqlClient().mutate({mutation:zA,variables:{workflowId:e,id:this.experienceOptions.transaction.id},context:{transactionOwnerId:r}}),B=me(e);if(await Promise.all([g,B]),this.experienceOptions.workflow=await B,t){const w=JSON.parse(t);this.experienceOptions.layouts=Object.values(w.layouts).map(h=>h.layout),await l.rehydrateSerializedLayout(w),await oe(w),this.experienceOptions.reloadedState=w}else this.experienceOptions.layouts=nt(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await B),this.experienceOptions.renderableContextService=new Pe(this.experienceOptions.layouts),(i=this.experienceOptions.product)!=null&&i.modelUrl&&(this.experienceOptions.modelContainer=(o=this.experienceOptions.previewService)==null?void 0:o.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const d=new ue(this,this.experienceOptions);return await d.getWorkflowManager().getInitializationPromise(),d}throw new v("No workflow ID provided.")}getPreviewService(){var e;return(e=this.experienceOptions)==null?void 0:e.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new v("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new v("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}configureUrls(e,t,A){X.setHubUrl(e),X.setServerUrl(t),X.setServicesApiUrl(A),this.getIntegration()}storeCustomer(e){const t=Y.getMap("partnerCustomerIds")||new Map;t.set(e.partner.id,e.id),Y.setMap("partnerCustomerIds",t)}async getIntegrationProductById(e){var a,i;const n=(a=(await N.getShadowGraphqlClient().query({query:VA,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:a.integrationProducts;if(!n||n.length===0||!((i=n[0])!=null&&i.id))throw new Error("Integration product not found.");return new tt(n[0])}async getIntegrationProductFromExternalIds(e,t){var i;const a=(i=(await N.getShadowGraphqlClient().query({query:WA,variables:{externalProductId:t,externalIntegrationId:e},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:i.integrationProductFromExternalIds;if(!(a!=null&&a.id))throw new Error("Integration product not found.");return new tt(a)}async getIntegrationProduct(e){return e.type==="integration"?this.getIntegrationProductById(e.integrationProductId):this.getIntegrationProductFromExternalIds(e.externalIntegrationId,e.externalProductId)}async getShareActionsForTransaction(e){const A=(Y.getMap("transactionOwnerIds")||new Map).get(e)||void 0,n=await N.getShadowGraphqlClient().query({query:KA,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:e},context:{transactionOwnerId:A}});if(!n.data.transactions||n.data.transactions.length!==1)throw new Error(`Failed to fetch share actions for transaction: ${e}`);return n.data.transactions[0].transactionShareActions}}class Ra{getClient(){return this.client??{}}setClient(e){this.client=e}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(e){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(e){}addPoller(e){}addConfirmCallback(e){}addEditedCallback(e){}addElementsCallback(e){}addInformationResultCallback(e){}addInitCallback(e){}addMakingAdjustmentsCallback(e){}addMandatoryCallback(e){}addMetadataCallback(e){}addSelectionCallback(e){}addStepSpecificStorageCallback(e,t){}addStorageCallback(e){}getCommandDispatcher(){return e=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(e){return[]}getSerializedStep(e,t){}getStepSpecificServices(e){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(e){}markUpdateCompleted(e){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(e){}setEditedStatus(e,t){}setInformationResults(e){}setMandatoryFulfilled(e,t){}async setSelectionsAndElements(e,t,A){}toggleDesignConfirmed(){}updateMetadata(e,t){}async updateStorage(e,t){}injectIntoPreviewService(e){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(e){}async updateTransactionShareActions(){}}var hA=(c=>(c.SelectFrame="SelectFrame",c.SelectImage="SelectImage",c.Position="Position",c))(hA||{});class EA extends K{constructor(e,t){var A;super(e,t),this.frameService=(A=this.manager.getStepSpecificServices(this.getId()))==null?void 0:A.frameService}selectVariant(e){const t=this.manager.getRegionElements(this.step.stepName);return he.selectVariant(this.step,e.getResource(),t,this.manager,A=>this.setUpdateState(A))}onFrameDataChanged(e){this.frameService&&this.frameService.onFrameDataChanged(t=>{t&&e(t)})}async selectImage(e,t=!0,A=!0){var n;if(await he.selectImage(this.step,e,this.manager,A),t){const a=((n=this.manager.getStepStorage(this.step.stepName))==null?void 0:n.framePatternData)||{};this.manager.updateStorage(this.step.stepName,{framePatternData:{...a,originalAssetKey:e.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}})}}async canUseBackgroundRemover(){return this.manager.getClient().canUseAddon(pe.BackgroundRemover)}async removeBackgroundFromImageSelection(e=!0){var a;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 t=await this.getOriginalImageSelection();if(!t)throw new Error("You must supply an image selection before attempting to remove the background.");const A=await G.removeBackgroundFromAsset(t);e&&await he.selectImage(this.step,A,this.manager,!1);const n=((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.framePatternData)||{};return this.manager.updateStorage(this.step.stepName,{framePatternData:{...n,backgroundRemovedAssetKey:A.key,useOriginalAsset:!e}}),A}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(e,t,A,n){return n&&n.length>1&&e===void 0?"SelectFrame":t||A||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}async getOriginalImageSelection(){var t,A;const e=(A=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)==null?void 0:A.originalAssetKey;if(e)return G.getLocalOrFromServer(e)}async getBackgroundRemovedImageSelection(){var t,A;const e=(A=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)==null?void 0:A.backgroundRemovedAssetKey;if(e)return G.getLocalOrFromServer(e)}hasBackgroundRemovedImageSelection(){var e,t;return!!((t=(e=this.getFrameStepStorage())==null?void 0:e.framePatternData)!=null&&t.backgroundRemovedAssetKey)}getUseOriginalImageSelection(){var e,t;return((t=(e=this.getFrameStepStorage())==null?void 0:e.framePatternData)==null?void 0:t.useOriginalAsset)??!1}async setUseOriginalImageSelection(e){var n;const t=((n=this.getFrameStepStorage())==null?void 0:n.framePatternData)||{};if(t.useOriginalAsset===e)return;const A=await this.getOriginalImageSelection();if(!A)throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");if(e)await this.selectImage(A,!1,!1);else{const a=await this.getBackgroundRemovedImageSelection();if(!a)throw new Error("You must call removeBackgroundFromImageSelection before attempting to apply the image.");await this.selectImage(a,!1,!1)}this.manager.updateStorage(this.step.stepName,{framePatternData:{...t,useOriginalAsset:e}})}getFrameStepStorage(){return this.manager.getStepStorage(this.step.stepName)}}Object.defineProperty(u,"AspectType",{enumerable:!0,get:()=>l.AspectType}),Object.defineProperty(u,"AssetType",{enumerable:!0,get:()=>l.AssetType}),Object.defineProperty(u,"BringForwardCommand",{enumerable:!0,get:()=>l.BringForwardCommand}),Object.defineProperty(u,"BringToBackCommand",{enumerable:!0,get:()=>l.BringToBackCommand}),Object.defineProperty(u,"BringToFrontCommand",{enumerable:!0,get:()=>l.BringToFrontCommand}),Object.defineProperty(u,"CanvasCommand",{enumerable:!0,get:()=>l.CanvasCommand}),Object.defineProperty(u,"CommandContext",{enumerable:!0,get:()=>l.CommandContext}),Object.defineProperty(u,"CreateElementCommand",{enumerable:!0,get:()=>l.CreateElementCommand}),Object.defineProperty(u,"CreateLayoutCommand",{enumerable:!0,get:()=>l.CreateLayoutCommand}),Object.defineProperty(u,"DeleteElementCommand",{enumerable:!0,get:()=>l.DeleteElementCommand}),Object.defineProperty(u,"FontAlignmentCommand",{enumerable:!0,get:()=>l.FontAlignmentCommand}),Object.defineProperty(u,"FontColorCommand",{enumerable:!0,get:()=>l.FontColorCommand}),Object.defineProperty(u,"FontSizeCommand",{enumerable:!0,get:()=>l.FontSizeCommand}),Object.defineProperty(u,"FontSourceCommand",{enumerable:!0,get:()=>l.FontSourceCommand}),Object.defineProperty(u,"GroupCommand",{enumerable:!0,get:()=>l.GroupCommand}),Object.defineProperty(u,"LayoutElementFactory",{enumerable:!0,get:()=>l.LayoutElementFactory}),Object.defineProperty(u,"LayoutElementType",{enumerable:!0,get:()=>l.LayoutElementType}),Object.defineProperty(u,"MoveCommand",{enumerable:!0,get:()=>l.MoveCommand}),Object.defineProperty(u,"ResizeCommand",{enumerable:!0,get:()=>l.ResizeCommand}),Object.defineProperty(u,"RotateCommand",{enumerable:!0,get:()=>l.RotateCommand}),Object.defineProperty(u,"SendBackwardsCommand",{enumerable:!0,get:()=>l.SendBackwardsCommand}),Object.defineProperty(u,"StepAspectType",{enumerable:!0,get:()=>l.StepAspectType}),Object.defineProperty(u,"StepType",{enumerable:!0,get:()=>l.StepType}),Object.defineProperty(u,"TextChangeCommand",{enumerable:!0,get:()=>l.TextChangeCommand}),Object.defineProperty(u,"UnitOfMeasurement",{enumerable:!0,get:()=>l.UnitOfMeasurement}),Object.defineProperty(u,"UpdateImageSourceCommand",{enumerable:!0,get:()=>l.UpdateImageSourceCommand}),Object.defineProperty(u,"dataUrlFromExternalUrl",{enumerable:!0,get:()=>l.dataUrlFromExternalUrl}),Object.defineProperty(u,"determineCorrectFontSizeAndLines",{enumerable:!0,get:()=>l.determineCorrectFontSizeAndLines}),Object.defineProperty(u,"findElement",{enumerable:!0,get:()=>l.findElement}),Object.defineProperty(u,"frameDataCache",{enumerable:!0,get:()=>l.frameDataCache}),Object.defineProperty(u,"generate",{enumerable:!0,get:()=>l.generate}),Object.defineProperty(u,"generateSVGWithUnknownColors",{enumerable:!0,get:()=>l.generateSVGWithUnknownColors}),Object.defineProperty(u,"getAttributesFromArrayBuffer",{enumerable:!0,get:()=>l.getAttributesFromArrayBuffer}),Object.defineProperty(u,"getAxisAlignedBoundingBox",{enumerable:!0,get:()=>l.getAxisAlignedBoundingBox}),Object.defineProperty(u,"getFrameData",{enumerable:!0,get:()=>l.getFrameData}),Object.defineProperty(u,"getSvgElement",{enumerable:!0,get:()=>l.getSvgElement}),Object.defineProperty(u,"loadFont",{enumerable:!0,get:()=>l.loadFont}),Object.defineProperty(u,"patternImageDataCache",{enumerable:!0,get:()=>l.patternImageDataCache}),Object.defineProperty(u,"registerFetchImplementation",{enumerable:!0,get:()=>l.registerFetchImplementation}),Object.defineProperty(u,"registerWindowImplementation",{enumerable:!0,get:()=>l.registerWindowImplementation}),Object.defineProperty(u,"rehydrateSerializedLayout",{enumerable:!0,get:()=>l.rehydrateSerializedLayout}),Object.defineProperty(u,"setCanvasModule",{enumerable:!0,get:()=>l.setCanvasModule}),u.AddonHandle=pe,u.ArrayInput=Ca,u.AssetNotFoundError=W,u.CollectionProduct=Ne,u.ColorOptionGlobalPropertyHandle=oA,u.ConversionDataType=It,u.ConversionLocation=ft,u.FileUploadGlobalPropertyHandle=aA,u.FlowExecutionNodeResult=Qe,u.FlowExecutionResult=dA,u.FlowService=lA,u.FrameService=yt,u.FrameStep=hA,u.FrameStepHandle=EA,u.GlobalPropertyHandle=xe,u.IllustrationStepHandle=Ot,u.InformationMessageType=Ce,u.InformationStepHandle=Xt,u.IntegrationProduct=tt,u.IntegrationType=Qt,u.LayoutNotFoundError=J,u.MaterialStepHandle=Lt,u.MisconfigurationError=ge,u.MockWorkflowManager=Ra,u.ModelStepHandle=zt,u.ObjectInput=et,u.ObjectInputType=BA,u.OptionGlobalPropertyHandle=Ze,u.OptionNotFoundError=ce,u.ParseError=$,u.PictureStepHandle=jt,u.ProductCameraRig=mt,u.ProductCollection=sA,u.ProductWorkflow=ie,u.PromiseCache=ee,u.PromiseQueue=be,u.QuestionStepHandle=Kt,u.QueueablePromise=ke,u.ResourceNotFoundError=Z,u.ShapeStepHandle=Vt,u.SpiffCommerceClient=wA,u.StakeholderType=Be,u.StepHandle=K,u.TextGlobalPropertyHandle=iA,u.TextInput=Ea,u.TextStepHandle=Wt,u.Transform=cA,u.TransformCollection=rA,u.UnhandledBehaviorError=k,u.Variant=V,u.WorkflowExperienceEventType=eA,u.WorkflowExperienceImpl=ue,u.assetService=G,u.createDesign=_t,u.designService=Ye,u.digitalContentStepService=xt,u.frameStepService=he,u.generateCommands=tA,u.generateStateFromDesignInputSteps=Vn,u.getBoundedOffsets=Mt,u.getWorkflow=me,u.getWorkflows=At,u.graphQlManager=N,u.illustrationStepService=Ee,u.materialStepService=Je,u.modelStepService=Te,u.moduleStepService=Nt,u.optionService=L,u.persistenceService=Y,u.pictureStepService=Oe,u.questionStepService=Le,u.setBearerAuthenticationToken=pA,u.shapeStepService=ae,u.shortenUrl=Yt,u.spiffCoreConfiguration=X,u.stepAspectValuesToDesignInputSteps=Kn,u.textStepService=z,u.toast=Ht,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
3102
|
+
`,oe=async c=>{var e;for(const t in c.layouts){const A=c.layouts[t].elements.filter(a=>a.type===l.LayoutElementType.Illustration);for(let a=0;a<A.length;++a){const i=A[a];i.src&&i.svg&&(i.cachedObjectURL=await l.svgObjectURL(i.svg))}const n=c.layouts[t].elements.filter(a=>a.type===l.LayoutElementType.Textbox);for(let a=0;a<n.length;++a){const i=n[a];(e=i.fontData)!=null&&e.assetUrl&&await l.loadFont(i.fontData.assetUrl)}}},xa=async(c,e)=>{var n;const t=await N.getShadowGraphqlClient().query({query:Ia(((n=e==null?void 0:e.assets)==null?void 0:n.metadata)||!1),errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:c}}),A=t.data.workflows;if(A===void 0||A.length!==c.length)throw new Error(`Unable to read workflows: ${t.errors??"Length mismatch in response"}`);return A.forEach(a=>{a.steps.forEach(i=>{var o,s,r;delete i.data.__typename,(o=i.option)!=null&&o.id&&((s=i.option.defaultVariant)!=null&&s.asset&&G.cacheAsset(i.option.defaultVariant.asset),i.option.colorProfile&&G.cacheAsset(i.option.colorProfile),(r=i.option.variants)==null||r.forEach(g=>{g.asset&&G.cacheAsset(g.asset),g.displayImage&&G.cacheAsset(g.displayImage),g.thumbnail&&G.cacheAsset(g.thumbnail),g.material&&G.cacheMaterial(g.material)}),ee.set({id:i.option.id},Promise.resolve(i.option)))})}),A},Na=async(c,e)=>{const A=(await e).find(n=>n.id===c);if(!A)throw new Error(`Workflow not found: ${c}`);return A},At=async(c,e)=>{const t=c.map(o=>ee.get({id:o,options:e})),A=c.filter((o,s)=>t[s]===void 0);if(A.length===0)return Promise.all(t);const n=xa(A,e),a=A.map(o=>ee.set({id:o,options:e},Na(o,n))),i=t.filter(o=>o!==void 0);return await Promise.all(i.concat(a))},me=async(c,e)=>(await At([c],e))[0],Ha=c=>c.sort((e,t)=>e.index-t.index).map(e=>({id:l.generate(),panelId:e.name,name:e.name,index:e.index,createdAt:new Date,updatedAt:new Date,transparentBackground:e.transparentBackground,height:e.height,width:e.width,previewRegion:e.previewRegion,useEditableArea:e.useEditableArea,editableArea:e.editableArea})),nt=(c,e)=>{const t=c.workflowState,A=t?JSON.parse(t):void 0;return A?Object.values(A.layouts).map(n=>n.layout):Ha(e.panels)};class wA{constructor(e){this.activeIntegration=void 0,this.updateTransactionState=async t=>{try{return N.getShadowGraphqlClient().mutate({...t,mutation:LA})}catch(A){throw console.error(A),new v("Critical - Unable to synchronize workflow state with server.")}},this.initialized=!1,this.options=e,this.options.applicationKey&&fA(this.options.applicationKey)}getAssetManager(){return G}getCurrencyCode(){if(this.currencyCode===void 0)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!IA())throw new Error("Application key required to use Flow Service.");return new lA}async getIntegration(){if(!this.options.applicationKey)throw new Error("Cannot get current Integration without specifying an Application Key.");if(this.activeIntegration)return this.activeIntegration;const e=async()=>(await N.getShadowGraphqlClient().query({query:Da,errorPolicy:"all",fetchPolicy:"no-cache"})).data.currentIntegration;return this.activeIntegration=e(),this.activeIntegration}async canUseAddon(e){var t;try{return((t=(await this.getIntegration()).partner.activeAddons)==null?void 0:t.includes(e))??!1}catch(A){return console.error(A),!1}}async authenticateBundleFromLocalStorage(e){var n,a;const t=Y.getMap("bundleOwnerIds");if(t!=null&&t.has(e))return Promise.resolve({success:!0,stakeholderType:Be.Owner});const A=Y.getMap("bundlePartnerIds")||new Map;if(A.has(e)){const i=A.get(e),s=(Y.getMap("partnerCustomerIds")||new Map).get(i);if(s&&await this.authenticateCustomerId(s)){const g=(a=(n=this.customer)==null?void 0:n.bundleStakeholders)==null?void 0:a.find(B=>{var d;return((d=B.bundle)==null?void 0:d.id)===e});if(g)return Promise.resolve({success:!0,stakeholderType:g.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(e){var g,B,d,w,h,C;const t=N.getShadowGraphqlClient(),A=await t.query({query:pa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:e}});if(!A.data.transactions||A.data.transactions.length===0)throw new Error(`Transaction not found: ${e}`);const n=A.data.transactions[0];if(!((B=(g=n.product)==null?void 0:g.partner)==null?void 0:B.id))throw new Error(`Unable to read transaction: ${e}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=Y.getMap("transactionOwnerIds");if(i!=null&&i.has(e))return Promise.resolve({success:!0,stakeholderType:Be.Owner});const o=Y.getMap("transactionCustomerIds");if(o!=null&&o.has(e)){const E=o.get(e);if(E&&await this.authenticateCustomerId(E)){const Q=((w=(d=this.customer)==null?void 0:d.bundleStakeholders)==null?void 0:w.find(F=>{var f,p;return(p=(f=F.bundle)==null?void 0:f.transactions)==null?void 0:p.some(I=>I.id===e)}))||((C=(h=this.customer)==null?void 0:h.stakeholders)==null?void 0:C.find(F=>{var f;return((f=F.transaction)==null?void 0:f.id)===e}));if(Q)return Promise.resolve({success:!0,stakeholderType:Q.type})}}const r=(await t.query({query:Fa,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(e){const t=Y.getMap("transactionCustomerIds");t!=null&&t.has(e)&&(t.delete(e),Y.setMap("transactionCustomerIds",t))}getStakeholderTypeForTransaction(e){var A,n;const t=(n=(A=this.customer)==null?void 0:A.stakeholders)==null?void 0:n.find(a=>{var i;return((i=a.transaction)==null?void 0:i.id)===e});if(t)return t.type}async getOrCreateCustomer(e){var i;this.customer=void 0;const t=N.getShadowGraphqlClient(),n=(await t.query({query:Ma,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e}})).data.customer;if(!n.id){const s=(i=(await t.mutate({mutation:ya,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:e}}})).data)==null?void 0:i.customerCreate;if(!s)throw new Error("Unable to create customer.");return this.storeCustomer(s),this.customer=s,{customer:s,isAuthenticated:!1}}this.storeCustomer(n);const a=await this.authenticateCustomerId(n.id);return{customer:this.customer||n,isAuthenticated:a}}async authenticateCustomerId(e){var o;const t=N.getShadowGraphqlClient(),A=Y.getMap("customerTokens");if(!(A!=null&&A.has(e)))return!1;const n=A.get(e);if(!n)return!1;const i=(o=(await t.mutate({mutation:Sa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data)==null?void 0:o.customerAuthenticate;return i?(this.storeCustomer(i),wt(n),this.customer=i,!0):!1}async generateVerificationCode(e){await N.getShadowGraphqlClient().mutate({mutation:Ya,variables:{emailAddress:e}})}async verifyCode(e,t){var a,i;const n=(a=(await N.getShadowGraphqlClient().mutate({mutation:Pa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e,verificationCode:t}})).data)==null?void 0:a.customerVerifyCode;if(n!=null&&n.loginToken){if(!((i=n.partner)!=null&&i.id))throw new Error(`Unable to find customer: ${e}`);const o=Y.getMap("customerTokens")||new Map;return o.set(n.id,n.loginToken),Y.setMap("customerTokens",o),this.storeCustomer(n),wt(n.loginToken),this.customer={...n,loginToken:void 0},!0}return!1}async getNewBundle(e,t,A){var s,r,g;const a=(g=(await N.getShadowGraphqlClient().mutate({mutation:_n(((r=(s=A==null?void 0:A.graphql)==null?void 0:s.productCollection)==null?void 0:r.eagerFetchProducts)||!1),variables:{collectionId:e,initialMetadata:t?Object.entries(t).map((B,d)=>({key:B[0],value:B[1]})):void 0},fetchPolicy:"no-cache"})).data)==null?void 0:g.bundleCreate;if(!(a!=null&&a.id))throw new Error("Unable to create bundle");const i=Y.getMap("bundlePartnerIds")||new Map;i.set(a.id,a.partner.id),Y.setMap("bundlePartnerIds",i);const o=Y.getMap("bundleOwnerIds")||new Map;return o.set(a.id,a.bundleOwnerId),Y.setMap("bundleOwnerIds",o),new gA(this,a,void 0,void 0,a.bundleOwnerId)}async getExistingBundle(e,t,A,n){var E,m,Q,F,f,p,I,D,y;const a=Y.getMap("bundleOwnerIds"),i=a==null?void 0:a.get(e),s=((E=Object.entries(localStorage).find(([S,x])=>S.startsWith("CognitoIdentityServiceProvider")&&S.endsWith("idToken")))==null?void 0:E[0])||"",r=localStorage.getItem(s),g={};r&&!Xe(r)&&(g.Authorization=`Bearer ${r}`);const B={bundleOwnerId:i,...g,...(m=n==null?void 0:n.graphql)==null?void 0:m.additionalHeaders},d=await N.getShadowGraphqlClient().query({query:Xn(((F=(Q=n==null?void 0:n.graphql)==null?void 0:Q.productCollection)==null?void 0:F.eagerFetchProducts)||!1),variables:{id:e},fetchPolicy:"no-cache",context:{headers:B}});if(!((f=d.data)!=null&&f.bundles)||((p=d.data)==null?void 0:p.bundles.length)===0||!((I=d.data)!=null&&I.bundles[0]))throw new Error(`Unable to find bundle: ${e}`);const w=(D=d.data)==null?void 0:D.bundles[0],h=Y.getMap("bundlePartnerIds")||new Map;h.set(w.id,w.partner.id),Y.setMap("bundlePartnerIds",h);const C=new gA(this,w,t,A,i,{additionalHeaders:(y=n==null?void 0:n.graphql)==null?void 0:y.additionalHeaders});return await C.getInitializationPromise(),C}async getBundleStakeholders(){var a;if(!this.customer)throw new Error("Customer not authenticated.");const e=await N.getShadowGraphqlClient().query({query:Zn,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((a=e.data)!=null&&a.customers)||e.data.customers.length===0)throw new Error("Unable to find customer.");const A=e.data.customers[0].bundleStakeholders||[],n=Y.getMap("bundlePartnerIds")||new Map;return A.forEach(i=>{var o,s;(o=i.bundle)!=null&&o.id&&((s=i.bundle.partner)!=null&&s.id)&&n.set(i.bundle.id,i.bundle.partner.id)}),Y.setMap("bundlePartnerIds",n),A}async getWorkflowExperience(e,t,A,n){var B,d,w,h,C;if(!n)return await this.getWorkflowExperienceDeprecated(e,t,A);const a=async()=>{var m,Q;const E=N.getShadowGraphqlClient();if(n.type==="transaction"){const{transactionId:F,readOnly:f}=n,p=await E.query({query:De,variables:{ids:[F]},errorPolicy:"all",fetchPolicy:"no-cache"});if(!((m=p.data)!=null&&m.transactions)||p.data.transactions.length===0)throw new v("Existing transaction not found.");const I=(Q=p.data)==null?void 0:Q.transactions[0];if(!I.workflowId)throw new v("Existing transaction has no workflow ID.");const D=await me(I.workflowId);if(!I.product)throw new v("Failed to load transaction, product not available.");return{transaction:I,workflow:D,readOnly:f}}if(n.type==="integration"||n.type==="external"){const F=async()=>{const D=n.type==="integration"?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},y=await E.mutate({mutation:pt,variables:{...D,workflowId:n.workflowId,designName:n.designName,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!y.data||!y.data.transactionCreate)throw new v("Failed to create transaction!");const S=y.data.transactionCreate;if(!S.product)throw new v("Failed to create transaction, product not available.");return S},f=me(n.workflowId,n==null?void 0:n.graphql),[p,I]=await Promise.all([F(),f]);return{transaction:p,workflow:I}}throw new v("No workflow ID provided.")},{transaction:i,workflow:o,readOnly:s}=await a();this.currencyCode=(B=i.product.partner)==null?void 0:B.currencyCode;const r={product:i.product,transaction:i,layouts:[],singleVariantsRenderable:(d=n==null?void 0:n.workflowConfiguration)==null?void 0:d.singleVariantsRenderable,stateMutationFunc:s?async()=>{throw new k("State mutation is forbidden in read only mode!")}:async E=>{const Q=(Y.getMap("transactionOwnerIds")||new Map).get(i.id)||void 0;return this.updateTransactionState({...E,context:{transactionOwnerId:Q}})},readOnly:s,workflow:o};if(n.type==="transaction"&&i.workflowState){const E=JSON.parse(i.workflowState);r.layouts=Object.values(E.layouts).map(m=>m.layout),await l.rehydrateSerializedLayout(E),await oe(E),r.reloadedState=E}else if(!s&&n.workflowState){const E=JSON.parse(n.workflowState);r.layouts=Object.values(E.layouts).map(m=>m.layout),await l.rehydrateSerializedLayout(E),await oe(E),r.reloadedState=E}else r.layouts=nt(r.transaction,r.workflow);if(r.renderableContextService=new Pe(r.layouts),n.previewService?(r.previewService=n.previewService,(w=r.product)!=null&&w.modelUrl&&(r.modelContainer=r.previewService.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))):(r.previewService=A&&A(o),(h=r.product)!=null&&h.modelUrl&&(r.modelContainer=(C=r.previewService)==null?void 0:C.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))),n.type!=="transaction"){const E=Y.getMap("transactionOwnerIds")||new Map;E.set(i.id,i.transactionOwnerId),Y.setMap("transactionOwnerIds",E)}else r.isReloadedTransaction=!0;this.initialized=!0,this.experienceOptions=r;const g=new ue(this,r);return await g.getWorkflowManager().getInitializationPromise(),n.type!=="transaction"&&this.customer&&await g.attachCustomerDetails({email:this.customer.emailAddress}),g}async getWorkflowExperiences(e,t){if(e.length===0)throw new v("No options provided!");const A=N.getShadowGraphqlClient(),n=async p=>{var S,x;if(p.length===0)return[];const I=p.map(P=>P.option.transactionId),D=await A.query({query:De,variables:{ids:I},errorPolicy:"all",fetchPolicy:"no-cache"}),y=D.data.transactions;if(y.length!==p.length){const P=((x=(S=D.errors)==null?void 0:S[0])==null?void 0:x.message)||"Unknown error";throw new v(`Not all transactions were found: ${P}`)}return y.map((P,H)=>{var R;return{transaction:P,workflowId:P.workflowId,readOnly:((R=p.find(T=>T.option.transactionId===P.id))==null?void 0:R.option.readOnly)??!1,index:p[H].index}})},a=async p=>{var y,S,x;if(p.length===0)return[];const I=await A.mutate({mutation:TA,variables:{inputs:p.map(P=>({integrationProductId:P.option.type==="integration"?P.option.integrationProductId:void 0,externalIntegrationId:P.option.type==="external"?P.option.externalIntegrationId:void 0,externalProductId:P.option.type==="external"?P.option.externalProductId:void 0,workflowId:P.option.workflowId,designName:P.option.designName,claim:!0}))},errorPolicy:"all",fetchPolicy:"no-cache"}),D=(y=I.data)==null?void 0:y.transactionCreateMany;if(!D||D.length===0){const P=((x=(S=I.errors)==null?void 0:S[0])==null?void 0:x.message)||"Unknown error";throw new v(`Failed to create transactions: ${P}`)}return D.map((P,H)=>({transaction:P,workflowId:P.workflowId,readOnly:!1,index:p[H].index}))},i=e.map((p,I)=>({option:p,index:I})),o=i.filter(p=>p.option.type==="transaction"),s=i.filter(p=>p.option.type==="integration"||p.option.type==="external"),r=gt(o,10),g=gt(s,10),B=(await Promise.all([...r.map(n),...g.map(a)])).flat(),d=[...new Set(B.map(p=>p.workflowId))],w=await At(d,t),h=new Map(w.map(p=>[p.id,p])),C=Y.getMap("transactionOwnerIds")||new Map,E=B.map(async p=>{var T;const{transaction:I,workflowId:D,readOnly:y,index:S}=p,x=h.get(D),P=e[S];!C.get(I.id)&&I.transactionOwnerId&&C.set(I.id,I.transactionOwnerId);const H=C.get(I.id)||void 0,R={product:I.product,transaction:I,layouts:[],singleVariantsRenderable:(T=P==null?void 0:P.workflowConfiguration)==null?void 0:T.singleVariantsRenderable,stateMutationFunc:y?async()=>{throw new k("State mutation is forbidden in read only mode!")}:async b=>this.updateTransactionState({...b,context:{transactionOwnerId:H}}),readOnly:y,workflow:x,isReloadedTransaction:P.type==="transaction"};if(P.type==="transaction"&&I.workflowState){const b=JSON.parse(I.workflowState);R.layouts=Object.values(b.layouts||{}).map(j=>j.layout),await l.rehydrateSerializedLayout(b),await oe(b),R.reloadedState=b}else if(!y&&P.workflowState){const b=JSON.parse(P.workflowState);R.layouts=Object.values(b.layouts||{}).map(j=>j.layout),await l.rehydrateSerializedLayout(b),await oe(b),R.reloadedState=b}else R.layouts=nt(R.transaction,R.workflow);return R.renderableContextService=new Pe(R.layouts),R.delayWorkflowStateSync=!0,this.initialized=!0,this.experienceOptions=R,{experienceOptions:R,index:S,options:P}});Y.setMap("transactionOwnerIds",C);const F=(await Promise.all(E)).sort((p,I)=>p.index-I.index).map(async p=>{const{experienceOptions:I,options:D}=p,y=new ue(this,I);return await y.getWorkflowManager().getInitializationPromise(),D.type!=="transaction"&&this.customer&&await y.attachCustomerDetails({email:this.customer.emailAddress}),y}),f=await Promise.all(F);return f.forEach(p=>p.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),f}async initFromIntegrationProduct(e){var i;if(e==="")throw new v("No integration product ID provided.");const A=await N.getShadowGraphqlClient().mutate({mutation:pt,variables:{integrationProductId:e,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new v("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new v("Failed to create transaction, product not available.");this.currencyCode=(i=n.product.partner)==null?void 0:i.currencyCode;const a=Y.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),Y.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async o=>this.updateTransactionState({...o,context:{transactionOwnerId:n.transactionOwnerId}})},this.initialized=!0}async initFromTransaction(e,t=!1){var o,s,r,g;if(e==="")throw new v("No transaction ID provided.");const A=N.getShadowGraphqlClient(),n=async()=>{var w,h;const d=(w=(await A.query({query:De,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:w.transactions[0];if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(h=d.product.partner)==null?void 0:h.currencyCode,this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async()=>{throw new k("State mutation is forbidden in read only mode!")},readOnly:t},this.initialized=!0};if(t)return await n();const a=Y.getMap("transactionOwnerIds")||new Map,i=a.get(e);if(i){const d=(o=(await A.query({query:De,variables:{ids:[e]},errorPolicy:"all"})).data)==null?void 0:o.transactions[0];if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(s=d.product.partner)==null?void 0:s.currencyCode,this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:i}}),readOnly:t},this.initialized=!0;return}try{const d=(r=(await A.mutate({mutation:OA,variables:{id:e},errorPolicy:"all"})).data)==null?void 0:r.transactionClaim;if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(g=d.product.partner)==null?void 0:g.currencyCode,d.transactionOwnerId&&(a.set(d.id,d.transactionOwnerId),Y.setMap("transactionOwnerIds",a)),this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:d.transactionOwnerId}}),readOnly:t},this.initialized=!0}catch{throw new v("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(e,t,A){var n,a,i,o;if(!this.initialized||!this.experienceOptions)throw new v("Cannot launch experience: Not initialized.");if(this.experienceOptions.transaction.workflowId){const s=await me(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=s,this.experienceOptions.transaction.workflowState){const g=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(g.layouts).map(B=>B.layout),await l.rehydrateSerializedLayout(g),await oe(g),this.experienceOptions.reloadedState=g}this.experienceOptions.previewService=A&&A(s),this.experienceOptions.renderableContextService=new Pe(this.experienceOptions.layouts),(n=this.experienceOptions.product)!=null&&n.modelUrl&&(this.experienceOptions.modelContainer=(a=this.experienceOptions.previewService)==null?void 0:a.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const r=new ue(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}if(e){const r=(Y.getMap("transactionOwnerIds")||new Map).get(this.experienceOptions.transaction.id),g=N.getShadowGraphqlClient().mutate({mutation:zA,variables:{workflowId:e,id:this.experienceOptions.transaction.id},context:{transactionOwnerId:r}}),B=me(e);if(await Promise.all([g,B]),this.experienceOptions.workflow=await B,t){const w=JSON.parse(t);this.experienceOptions.layouts=Object.values(w.layouts).map(h=>h.layout),await l.rehydrateSerializedLayout(w),await oe(w),this.experienceOptions.reloadedState=w}else this.experienceOptions.layouts=nt(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await B),this.experienceOptions.renderableContextService=new Pe(this.experienceOptions.layouts),(i=this.experienceOptions.product)!=null&&i.modelUrl&&(this.experienceOptions.modelContainer=(o=this.experienceOptions.previewService)==null?void 0:o.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const d=new ue(this,this.experienceOptions);return await d.getWorkflowManager().getInitializationPromise(),d}throw new v("No workflow ID provided.")}getPreviewService(){var e;return(e=this.experienceOptions)==null?void 0:e.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new v("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new v("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}configureUrls(e,t,A){X.setHubUrl(e),X.setServerUrl(t),X.setServicesApiUrl(A),this.getIntegration()}storeCustomer(e){const t=Y.getMap("partnerCustomerIds")||new Map;t.set(e.partner.id,e.id),Y.setMap("partnerCustomerIds",t)}async getIntegrationProductById(e){var a,i;const n=(a=(await N.getShadowGraphqlClient().query({query:VA,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:a.integrationProducts;if(!n||n.length===0||!((i=n[0])!=null&&i.id))throw new Error("Integration product not found.");return new tt(n[0])}async getIntegrationProductFromExternalIds(e,t){var i;const a=(i=(await N.getShadowGraphqlClient().query({query:WA,variables:{externalProductId:t,externalIntegrationId:e},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:i.integrationProductFromExternalIds;if(!(a!=null&&a.id))throw new Error("Integration product not found.");return new tt(a)}async getIntegrationProduct(e){return e.type==="integration"?this.getIntegrationProductById(e.integrationProductId):this.getIntegrationProductFromExternalIds(e.externalIntegrationId,e.externalProductId)}async getShareActionsForTransaction(e){const A=(Y.getMap("transactionOwnerIds")||new Map).get(e)||void 0,n=await N.getShadowGraphqlClient().query({query:KA,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:e},context:{transactionOwnerId:A}});if(!n.data.transactions||n.data.transactions.length!==1)throw new Error(`Failed to fetch share actions for transaction: ${e}`);return n.data.transactions[0].transactionShareActions}}class Ra{getClient(){return this.client??{}}setClient(e){this.client=e}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(e){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(e){}addPoller(e){}addConfirmCallback(e){}addEditedCallback(e){}addElementsCallback(e){}addInformationResultCallback(e){}addInitCallback(e){}addMakingAdjustmentsCallback(e){}addMandatoryCallback(e){}addMetadataCallback(e){}addSelectionCallback(e){}addStepSpecificStorageCallback(e,t){}addStorageCallback(e){}getCommandDispatcher(){return e=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(e){return[]}getSerializedStep(e,t){}getStepSpecificServices(e){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(e){}markUpdateCompleted(e){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(e){}setEditedStatus(e,t){}setInformationResults(e){}setMandatoryFulfilled(e,t){}async setSelectionsAndElements(e,t,A){}toggleDesignConfirmed(){}updateMetadata(e,t){}async updateStorage(e,t){}injectIntoPreviewService(e){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(e){}async updateTransactionShareActions(){}}var hA=(c=>(c.SelectFrame="SelectFrame",c.SelectImage="SelectImage",c.Position="Position",c))(hA||{});class EA extends K{constructor(e,t){var A;super(e,t),this.frameService=(A=this.manager.getStepSpecificServices(this.getId()))==null?void 0:A.frameService}selectVariant(e){const t=this.manager.getRegionElements(this.step.stepName);return he.selectVariant(this.step,e.getResource(),t,this.manager,A=>this.setUpdateState(A))}onFrameDataChanged(e){this.frameService&&this.frameService.onFrameDataChanged(t=>{t&&e(t)})}async selectImage(e,t=!0,A=!0){var n;if(await he.selectImage(this.step,e,this.manager,A),t){const a=((n=this.manager.getStepStorage(this.step.stepName))==null?void 0:n.framePatternData)||{};this.manager.updateStorage(this.step.stepName,{framePatternData:{...a,originalAssetKey:e.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}})}}async canUseBackgroundRemover(){return this.manager.getClient().canUseAddon(pe.BackgroundRemover)}async removeBackgroundFromImageSelection(e=!0){var a;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 t=await this.getOriginalImageSelection();if(!t)throw new Error("You must supply an image selection before attempting to remove the background.");const A=await G.removeBackgroundFromAsset(t);e&&await he.selectImage(this.step,A,this.manager,!1);const n=((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.framePatternData)||{};return this.manager.updateStorage(this.step.stepName,{framePatternData:{...n,backgroundRemovedAssetKey:A.key,useOriginalAsset:!e}}),A}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(e,t,A,n){return n&&n.length>1&&e===void 0?"SelectFrame":t||A||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}async getOriginalImageSelection(){var t,A;const e=(A=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)==null?void 0:A.originalAssetKey;if(e)return G.getLocalOrFromServer(e)}async getBackgroundRemovedImageSelection(){var t,A;const e=(A=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)==null?void 0:A.backgroundRemovedAssetKey;if(e)return G.getLocalOrFromServer(e)}hasBackgroundRemovedImageSelection(){var e,t;return!!((t=(e=this.getFrameStepStorage())==null?void 0:e.framePatternData)!=null&&t.backgroundRemovedAssetKey)}getUseOriginalImageSelection(){var e,t;return((t=(e=this.getFrameStepStorage())==null?void 0:e.framePatternData)==null?void 0:t.useOriginalAsset)??!1}async setUseOriginalImageSelection(e){var n;const t=((n=this.getFrameStepStorage())==null?void 0:n.framePatternData)||{};if(t.useOriginalAsset===e)return;const A=await this.getOriginalImageSelection();if(!A)throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");if(e)await this.selectImage(A,!1,!1);else{const a=await this.getBackgroundRemovedImageSelection();if(!a)throw new Error("You must call removeBackgroundFromImageSelection before attempting to apply the image.");await this.selectImage(a,!1,!1)}this.manager.updateStorage(this.step.stepName,{framePatternData:{...t,useOriginalAsset:e}})}getFrameStepStorage(){return this.manager.getStepStorage(this.step.stepName)}}Object.defineProperty(u,"AspectType",{enumerable:!0,get:()=>l.AspectType}),Object.defineProperty(u,"AssetType",{enumerable:!0,get:()=>l.AssetType}),Object.defineProperty(u,"BringForwardCommand",{enumerable:!0,get:()=>l.BringForwardCommand}),Object.defineProperty(u,"BringToBackCommand",{enumerable:!0,get:()=>l.BringToBackCommand}),Object.defineProperty(u,"BringToFrontCommand",{enumerable:!0,get:()=>l.BringToFrontCommand}),Object.defineProperty(u,"CanvasCommand",{enumerable:!0,get:()=>l.CanvasCommand}),Object.defineProperty(u,"CommandContext",{enumerable:!0,get:()=>l.CommandContext}),Object.defineProperty(u,"CreateElementCommand",{enumerable:!0,get:()=>l.CreateElementCommand}),Object.defineProperty(u,"CreateLayoutCommand",{enumerable:!0,get:()=>l.CreateLayoutCommand}),Object.defineProperty(u,"DeleteElementCommand",{enumerable:!0,get:()=>l.DeleteElementCommand}),Object.defineProperty(u,"FontAlignmentCommand",{enumerable:!0,get:()=>l.FontAlignmentCommand}),Object.defineProperty(u,"FontColorCommand",{enumerable:!0,get:()=>l.FontColorCommand}),Object.defineProperty(u,"FontSizeCommand",{enumerable:!0,get:()=>l.FontSizeCommand}),Object.defineProperty(u,"FontSourceCommand",{enumerable:!0,get:()=>l.FontSourceCommand}),Object.defineProperty(u,"GroupCommand",{enumerable:!0,get:()=>l.GroupCommand}),Object.defineProperty(u,"LayoutElementFactory",{enumerable:!0,get:()=>l.LayoutElementFactory}),Object.defineProperty(u,"LayoutElementType",{enumerable:!0,get:()=>l.LayoutElementType}),Object.defineProperty(u,"MoveCommand",{enumerable:!0,get:()=>l.MoveCommand}),Object.defineProperty(u,"ResizeCommand",{enumerable:!0,get:()=>l.ResizeCommand}),Object.defineProperty(u,"RotateCommand",{enumerable:!0,get:()=>l.RotateCommand}),Object.defineProperty(u,"SendBackwardsCommand",{enumerable:!0,get:()=>l.SendBackwardsCommand}),Object.defineProperty(u,"StepAspectType",{enumerable:!0,get:()=>l.StepAspectType}),Object.defineProperty(u,"StepType",{enumerable:!0,get:()=>l.StepType}),Object.defineProperty(u,"TextChangeCommand",{enumerable:!0,get:()=>l.TextChangeCommand}),Object.defineProperty(u,"UnitOfMeasurement",{enumerable:!0,get:()=>l.UnitOfMeasurement}),Object.defineProperty(u,"UpdateImageSourceCommand",{enumerable:!0,get:()=>l.UpdateImageSourceCommand}),Object.defineProperty(u,"dataUrlFromExternalUrl",{enumerable:!0,get:()=>l.dataUrlFromExternalUrl}),Object.defineProperty(u,"determineCorrectFontSizeAndLines",{enumerable:!0,get:()=>l.determineCorrectFontSizeAndLines}),Object.defineProperty(u,"findElement",{enumerable:!0,get:()=>l.findElement}),Object.defineProperty(u,"frameDataCache",{enumerable:!0,get:()=>l.frameDataCache}),Object.defineProperty(u,"generate",{enumerable:!0,get:()=>l.generate}),Object.defineProperty(u,"generateSVGWithUnknownColors",{enumerable:!0,get:()=>l.generateSVGWithUnknownColors}),Object.defineProperty(u,"getAttributesFromArrayBuffer",{enumerable:!0,get:()=>l.getAttributesFromArrayBuffer}),Object.defineProperty(u,"getAxisAlignedBoundingBox",{enumerable:!0,get:()=>l.getAxisAlignedBoundingBox}),Object.defineProperty(u,"getFrameData",{enumerable:!0,get:()=>l.getFrameData}),Object.defineProperty(u,"getSvgElement",{enumerable:!0,get:()=>l.getSvgElement}),Object.defineProperty(u,"loadFont",{enumerable:!0,get:()=>l.loadFont}),Object.defineProperty(u,"patternImageDataCache",{enumerable:!0,get:()=>l.patternImageDataCache}),Object.defineProperty(u,"registerFetchImplementation",{enumerable:!0,get:()=>l.registerFetchImplementation}),Object.defineProperty(u,"registerWindowImplementation",{enumerable:!0,get:()=>l.registerWindowImplementation}),Object.defineProperty(u,"rehydrateSerializedLayout",{enumerable:!0,get:()=>l.rehydrateSerializedLayout}),Object.defineProperty(u,"setCanvasModule",{enumerable:!0,get:()=>l.setCanvasModule}),u.AddonHandle=pe,u.ArrayInput=Ca,u.AssetNotFoundError=W,u.CollectionProduct=Ne,u.ColorOptionGlobalPropertyHandle=oA,u.ConversionDataType=It,u.ConversionLocation=ft,u.FileUploadGlobalPropertyHandle=aA,u.FlowExecutionNodeResult=Qe,u.FlowExecutionResult=dA,u.FlowService=lA,u.FrameService=yt,u.FrameStep=hA,u.FrameStepHandle=EA,u.GlobalPropertyHandle=xe,u.IllustrationStepHandle=Ot,u.InformationMessageType=Ce,u.InformationStepHandle=Xt,u.IntegrationProduct=tt,u.IntegrationType=Qt,u.LayoutNotFoundError=J,u.MaterialStepHandle=Lt,u.MisconfigurationError=ge,u.MockWorkflowManager=Ra,u.ModelStepHandle=zt,u.ObjectInput=et,u.ObjectInputType=BA,u.OptionGlobalPropertyHandle=Ze,u.OptionNotFoundError=ce,u.ParseError=$,u.PictureStepHandle=jt,u.ProductCameraRig=mt,u.ProductCollection=sA,u.ProductWorkflow=ie,u.PromiseCache=ee,u.PromiseQueue=be,u.QuestionStepHandle=Kt,u.QueueablePromise=ke,u.ResourceNotFoundError=Z,u.ShapeStepHandle=Vt,u.SpiffCommerceClient=wA,u.StakeholderType=Be,u.StepHandle=K,u.TextGlobalPropertyHandle=iA,u.TextInput=Ea,u.TextStepHandle=Wt,u.Transform=cA,u.TransformCollection=rA,u.UnhandledBehaviorError=k,u.Variant=V,u.WorkflowExperienceEventType=eA,u.WorkflowExperienceImpl=ue,u.assetService=G,u.createDesign=_t,u.designService=Ye,u.digitalContentStepService=xt,u.frameStepService=he,u.generateCommands=tA,u.generateStateFromDesignInputSteps=Vn,u.getBoundedOffsets=Mt,u.getWorkflow=me,u.getWorkflows=At,u.graphQlManager=N,u.illustrationStepService=Ee,u.materialStepService=Je,u.modelStepService=Te,u.moduleStepService=Nt,u.optionService=L,u.persistenceService=Y,u.pictureStepService=Oe,u.questionStepService=Le,u.setBearerAuthenticationToken=pA,u.shapeStepService=ae,u.shortenUrl=Yt,u.spiffCoreConfiguration=X,u.stepAspectValuesToDesignInputSteps=Kn,u.textStepService=z,u.toast=Ht,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|