@spiffcommerce/core 12.11.0 → 12.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +2 -2
- package/dist/module.js +2 -2
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -677,7 +677,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
|
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
|
-
`;function dc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class uc{constructor(t){dc(this,"bundleId",void 0),dc(this,"globalPropertyState",void 0),this.bundleId=t,this.getOrCreateGlobalPropertyState().then((t=>this.globalPropertyState=t))}getGlobalPropertyState(){return this.globalPropertyState}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find((e=>e.name===t));if(e)return e.value}setAspect(t,e){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const A=this.globalPropertyState.aspects.find((e=>e.name===t));return A?A.value=e:this.globalPropertyState.aspects.push({name:t,value:e}),this.updateGlobalPropertyState()}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await Qa.getShadowGraphqlClient().mutate({mutation:gc,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects}});if(!t.data?.globalPropertyStateUpdate)throw new Error("Unable to update global property state");this.globalPropertyState=t.data.globalPropertyStateUpdate}async getOrCreateGlobalPropertyState(){const t=await Qa.getShadowGraphqlClient().query({query:hc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{bundleId:this.bundleId}});if(t.data.globalPropertyState&&t.data.globalPropertyState.id)return t.data.globalPropertyState;const e=await Qa.getShadowGraphqlClient().mutate({mutation:lc,variables:{bundleId:this.bundleId}});if(e.data?.globalPropertyStateCreate&&e.data.globalPropertyStateCreate.id)return e.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}function wc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Bc{constructor(t,e){wc(this,"client",void 0),wc(this,"id",void 0),wc(this,"name",void 0),wc(this,"metadata",void 0),wc(this,"productCollection",void 0),wc(this,"globalConfigurations",void 0),wc(this,"globalPropertyStateManager",void 0),wc(this,"workflowExperiences",[]),this.client=t,this.id=e.id,this.name=e.name||"",this.metadata=new Map(e.metadata?.map((t=>[t.key,t.value]))||[]),this.productCollection=e.productCollection,this.globalConfigurations=this.resolveGlobalProperties(),this.globalPropertyStateManager=new uc(this.id)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,e){return this.name=t,this.metadata=new Map(e),this.updateBundle()}async hasGlobalProperties(){const t=await this.globalConfigurations;return t.length>0&&t.some((t=>t.aspects.length>0))}async getGlobalProperties(){const t=await this.globalConfigurations;if(0===t.length)return[];return(await Promise.all(t.map((async t=>await Promise.all(t.aspects.map((async t=>{switch(t.type){case tA.FileUpload:return new sc(this,t);case tA.Option:const e=t.entityId?await ka.getOption(t.entityId):void 0;return new cc(this,t,e);case tA.Text:return new oc(this,t)}}))))))).flat()}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}getTotalSubunits(){return this.workflowExperiences.map((t=>t.getTotalPriceSubunits())).reduce(((t,e)=>t+e),0)}getProductCollection(){return this.productCollection}async addWorkflowExperience(t){const e=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===e)))throw new Error("Unable to add transaction to bundle - Already Exists!");await Qa.getShadowGraphqlClient().mutate({mutation:_o,variables:{id:this.id,transactionId:e}}),this.workflowExperiences.push(t);const A=await this.getGlobalProperties();await Promise.all(A.map((e=>e.applyGlobalState([t]))))}async removeWorkflowExperience(t){const e=this.workflowExperiences.indexOf(t);if(!(e>-1))throw new Error("Unable to remove workflow experience from bundle - Not Found!");await Qa.getShadowGraphqlClient().mutate({mutation:tc,variables:{id:this.id,transactionId:t.getWorkflowManager().getTransaction().id}}),this.workflowExperiences.splice(e,1)}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await Qa.getShadowGraphqlClient().mutate({mutation:nc,variables:{id:this.id,transactionIds:this.workflowExperiences.map((t=>t.getWorkflowManager().getTransaction().id))}})}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,e){await Qa.getShadowGraphqlClient().mutate({mutation:ec,variables:{id:this.id,details:t,type:e||ir.Owner}})}async updateStakeholders(t){await Qa.getShadowGraphqlClient().mutate({mutation:Ac,variables:{id:this.id,input:t}})}async getAllStakeholders(){const t=await Qa.getShadowGraphqlClient().query({query:qo,errorPolicy:"all",variables:{id:this.id}});if(!t.data.bundles||0===t.data.bundles.length)throw new Error("Bundle not found!");return t.data.bundles[0].bundleStakeholders||[]}
|
|
680
|
+
`;function dc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class uc{constructor(t){dc(this,"bundleId",void 0),dc(this,"globalPropertyState",void 0),this.bundleId=t,this.getOrCreateGlobalPropertyState().then((t=>this.globalPropertyState=t))}getGlobalPropertyState(){return this.globalPropertyState}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find((e=>e.name===t));if(e)return e.value}setAspect(t,e){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const A=this.globalPropertyState.aspects.find((e=>e.name===t));return A?A.value=e:this.globalPropertyState.aspects.push({name:t,value:e}),this.updateGlobalPropertyState()}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await Qa.getShadowGraphqlClient().mutate({mutation:gc,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects}});if(!t.data?.globalPropertyStateUpdate)throw new Error("Unable to update global property state");this.globalPropertyState=t.data.globalPropertyStateUpdate}async getOrCreateGlobalPropertyState(){const t=await Qa.getShadowGraphqlClient().query({query:hc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{bundleId:this.bundleId}});if(t.data.globalPropertyState&&t.data.globalPropertyState.id)return t.data.globalPropertyState;const e=await Qa.getShadowGraphqlClient().mutate({mutation:lc,variables:{bundleId:this.bundleId}});if(e.data?.globalPropertyStateCreate&&e.data.globalPropertyStateCreate.id)return e.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}function wc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Bc{constructor(t,e){wc(this,"client",void 0),wc(this,"id",void 0),wc(this,"name",void 0),wc(this,"metadata",void 0),wc(this,"productCollection",void 0),wc(this,"globalConfigurations",void 0),wc(this,"globalPropertyStateManager",void 0),wc(this,"workflowExperiences",[]),this.client=t,this.id=e.id,this.name=e.name||"",this.metadata=new Map(e.metadata?.map((t=>[t.key,t.value]))||[]),this.productCollection=e.productCollection,this.globalConfigurations=this.resolveGlobalProperties(),this.globalPropertyStateManager=new uc(this.id)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,e){return this.name=t,this.metadata=new Map(e),this.updateBundle()}async hasGlobalProperties(){const t=await this.globalConfigurations;return t.length>0&&t.some((t=>t.aspects.length>0))}async getGlobalProperties(){const t=await this.globalConfigurations;if(0===t.length)return[];return(await Promise.all(t.map((async t=>await Promise.all(t.aspects.map((async t=>{switch(t.type){case tA.FileUpload:return new sc(this,t);case tA.Option:const e=t.entityId?await ka.getOption(t.entityId):void 0;return new cc(this,t,e);case tA.Text:return new oc(this,t)}}))))))).flat()}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}getTotalSubunits(){return this.workflowExperiences.map((t=>t.getTotalPriceSubunits())).reduce(((t,e)=>t+e),0)}getProductCollection(){return this.productCollection}async addWorkflowExperience(t){const e=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===e)))throw new Error("Unable to add transaction to bundle - Already Exists!");await Qa.getShadowGraphqlClient().mutate({mutation:_o,variables:{id:this.id,transactionId:e}}),this.workflowExperiences.push(t);const A=await this.getGlobalProperties();await Promise.all(A.map((e=>e.applyGlobalState([t]))))}async removeWorkflowExperience(t){const e=this.workflowExperiences.indexOf(t);if(!(e>-1))throw new Error("Unable to remove workflow experience from bundle - Not Found!");await Qa.getShadowGraphqlClient().mutate({mutation:tc,variables:{id:this.id,transactionId:t.getWorkflowManager().getTransaction().id}}),this.workflowExperiences.splice(e,1)}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await Qa.getShadowGraphqlClient().mutate({mutation:nc,variables:{id:this.id,transactionIds:this.workflowExperiences.map((t=>t.getWorkflowManager().getTransaction().id))}})}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,e){await Qa.getShadowGraphqlClient().mutate({mutation:ec,variables:{id:this.id,details:t,type:e||ir.Owner}})}async updateStakeholders(t){await Qa.getShadowGraphqlClient().mutate({mutation:Ac,variables:{id:this.id,input:t}})}async getAllStakeholders(){const t=await Qa.getShadowGraphqlClient().query({query:qo,errorPolicy:"all",variables:{id:this.id}});if(!t.data.bundles||0===t.data.bundles.length)throw new Error("Bundle not found!");return t.data.bundles[0].bundleStakeholders||[]}async finish(){return Promise.all(this.workflowExperiences.map((t=>t.onDesignFinished())))}_setWorkflowExperiencesInternal(t){this.workflowExperiences=t}async updateBundle(){if(!(await Qa.getShadowGraphqlClient().mutate({mutation:$o,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,e])=>({key:t,value:e})))}})).data?.bundleUpdate)throw new Error("Bundle not found!")}async resolveGlobalProperties(){const t=this.productCollection;if(!t)return Promise.resolve([]);const e=new Set;t.products.forEach((t=>t.workflows?.forEach((t=>e.add(t.workflowName)))));const A=await Qa.getShadowGraphqlClient().query({query:ic,errorPolicy:"all",variables:{ids:Array.from(e)}}),i=new Map;return A.data.workflows?.forEach((t=>{t.globalPropertyConfiguration&&i.set(t.globalPropertyConfiguration.id,t.globalPropertyConfiguration)})),Array.from(i.values())}}function pc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Ec=t.gql`
|
|
681
681
|
fragment RegionFields on Region {
|
|
682
682
|
width
|
|
683
683
|
top
|
|
@@ -1303,5 +1303,5 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
|
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
1305
|
}
|
|
1306
|
-
`,Sc=async t=>{const e=(await Qa.getShadowGraphqlClient().query({query:fc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},Fc=(t,e)=>{const A=t.workflowState,i=A?JSON.parse(A):void 0;return i?Object.values(i.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:Te(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class bc{constructor(t){var e;pc(this,"options",void 0),pc(this,"initialized",void 0),pc(this,"currencyCode",void 0),pc(this,"customer",void 0),pc(this,"experienceOptions",void 0),pc(this,"updateTransactionState",(async t=>{try{return Qa.getShadowGraphqlClient().mutate({...t,mutation:Ys})}catch(t){throw console.error(t),new ra("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,fa=e)}getAssetManager(){return Ya}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateBundleFromLocalStorage(t){const e=ga.getMap("bundleOwnerIds");if(e?.has(t)){const A=e.get(t);return Ea(A),Promise.resolve({success:!0,stakeholderType:ir.Owner})}const A=ga.getMap("bundleCustomerIds");if(A?.has(t)){const e=A.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=Qa.getShadowGraphqlClient(),A=await e.query({query:Qc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!A.data.transactions||0===A.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const i=A.data.transactions[0],n=i.product?.partner?.id;if(!n)throw new Error(`Unable to read transaction: ${t}`);if(i.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=ga.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return Ba(e),Promise.resolve({success:!0,stakeholderType:ir.Owner})}const r=ga.getMap("transactionCustomerIds");if(r?.has(t)){const e=r.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const s=(await e.query({query:yc,errorPolicy:"all",variables:{id:i.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${i.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:i.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=ga.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),ga.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=Qa.getShadowGraphqlClient(),A=(await e.query({query:Dc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!A.id){const A=(await e.mutate({mutation:Ic,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!A)throw new Error("Unable to create customer.");return this.customer=A,{customer:A,isAuthenticated:!1}}const i=await this.authenticateCustomerId(A.id);return{customer:this.customer||A,isAuthenticated:i}}async authenticateCustomerId(t){const e=Qa.getShadowGraphqlClient(),A=ga.getMap("customerTokens");if(!A?.has(t))return!1;const i=A.get(t);if(!i)return!1;const n=(await e.mutate({mutation:xc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:i}})).data?.customerAuthenticate;return!!n&&(Ca(i),this.customer=n,!0)}async generateVerificationCode(t){await Qa.getShadowGraphqlClient().mutate({mutation:Mc,variables:{emailAddress:t}})}async verifyCode(t,e){const A=(await Qa.getShadowGraphqlClient().mutate({mutation:vc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(A?.loginToken){if(!A.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=ga.getMap("customerTokens")||new Map;return e.set(A.id,A.loginToken),ga.setMap("customerTokens",e),Ca(A.loginToken),this.customer={...A,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await Qa.getShadowGraphqlClient().mutate({mutation:Zo,variables:{collectionId:t}})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");Ea(e.bundleOwnerId);const A=ga.getMap("bundleOwnerIds")||new Map;return A.set(e.id,e.bundleOwnerId),ga.setMap("bundleOwnerIds",A),new Bc(this,e)}async getExistingBundle(t,e){const A=await Qa.getShadowGraphqlClient().query({query:Xo,variables:{id:t}});if(!A.data?.bundles||0===A.data?.bundles.length||!A.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const i=A.data?.bundles[0],n=ga.getMap("bundleOwnerIds");n?.has(i.id)&&Ea(n.get(i.id));const a=new Bc(this,i);if(i.transactions&&i.transactions.length>0){const t=t=>{const A=e?A=>e(A,t):void 0;return this.getWorkflowExperience(void 0,void 0,A,{type:"transaction",transactionId:t})},A=await Promise.all(i.transactions.map((e=>t(e.id))));a.setWorkflowExperiencesInternal(A)}return a}async getWorkflowExperience(t,e,A,i){if(!i)return await this.getWorkflowExperienceDeprecated(t,e,A);const n=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await Vn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ai(e.fontData.assetUrl)}}},{transaction:a,workflow:r,readOnly:s}=await(async()=>{const t=Qa.getShadowGraphqlClient();if("transaction"===i.type){const{transactionId:e,readOnly:A}=i,n=await t.query({query:bs,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!n.data?.transactions||0===n.data.transactions.length)throw new ra("Existing transaction not found.");const a=n.data?.transactions[0];if(!a.workflowId)throw new ra("Existing transaction has no workflow ID.");const r=await Sc(a.workflowId);if(!a.product)throw new ra("Failed to load transaction, product not available.");return{transaction:a,workflow:r,readOnly:A}}if("integration"===i.type||"external"===i.type){const e=async()=>{const e="integration"===i.type?{integrationProductId:i.integrationProductId}:{externalIntegrationId:i.externalIntegrationId,externalProductId:i.externalProductId},A=await t.mutate({mutation:Ss,variables:{...e,bulk:i.bulk,workflowId:i.workflowId,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 ra("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new ra("Failed to create transaction, product not available.");return n},A=Sc(i.workflowId),[n,a]=await Promise.all([e(),A]);return{transaction:n,workflow:a}}throw new ra("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const o={product:a.product,transaction:a,layouts:[],stateMutationFunc:s?async()=>{throw new na("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:s,workflow:r};if("transaction"===i.type&&a.workflowState){const t=JSON.parse(a.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await n(t),o.reloadedState=t}else if(!s&&i.workflowState){const t=JSON.parse(i.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await n(t),o.reloadedState=t}else o.layouts=Fc(o.transaction,o.workflow);if(o.renderableContextService=new Cs(o.layouts),i.previewService?(o.previewService=i.previewService,o.product?.modelUrl&&(o.modelContainer=o.previewService.loadModel({model:o.product.modelUrl,contextService:o.renderableContextService}))):(o.previewService=A&&A(r),o.product?.modelUrl&&(o.previewService?.initialize({model:o.product.modelUrl,contextService:o.renderableContextService}),o.modelContainer=o.previewService?.getAllModels()[0])),"transaction"!==i.type){const t=ga.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),Ba(a.transactionOwnerId||""),ga.setMap("transactionOwnerIds",t)}else{const t=(ga.getMap("transactionOwnerIds")||new Map).get(a.id);t&&Ba(t),o.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=o;const c=new Vo(this,o);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==i.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new ra("No integration product ID provided.");const e=Qa.getShadowGraphqlClient(),A=await e.mutate({mutation:Ss,variables:{integrationProductId:t,bulk:this.options.bulk||!1,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 ra("Failed to create transaction!");const i=A.data.transactionCreate;if(!i.product)throw new ra("Failed to create transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode;const n=ga.getMap("transactionOwnerIds")||new Map;n.set(i.id,i.transactionOwnerId),Ba(i.transactionOwnerId||""),ga.setMap("transactionOwnerIds",n),this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new ra("No transaction ID provided.");const A=Qa.getShadowGraphqlClient();if(e)return await(async()=>{const i=(await A.query({query:bs,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!i)throw new ra("Failed to read transaction.");if(!i.product)throw new ra("Failed to load transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:async()=>{throw new na("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const i=ga.getMap("transactionOwnerIds")||new Map,n=i.get(t);if(n){Ba(n);const i=(await A.query({query:bs,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!i)throw new ra("Failed to read transaction.");if(!i.product)throw new ra("Failed to load transaction, product not available.");return this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const n=(await A.mutate({mutation:Fs,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!n)throw new ra("Failed to read transaction.");if(!n.product)throw new ra("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,n.transactionOwnerId&&(i.set(n.id,n.transactionOwnerId),Ba(n.transactionOwnerId),ga.setMap("transactionOwnerIds",i)),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new ra("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,A){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot launch experience: Not initialized.");const i=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await Vn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ai(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Sc(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await i(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=A&&A(t),this.experienceOptions.renderableContextService=new Cs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Vo(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const n=Qa.getShadowGraphqlClient().mutate({mutation:Ps,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=Sc(t);if(await Promise.all([n,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await i(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=Fc(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await a),this.experienceOptions.renderableContextService=new Cs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const r=new Vo(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}throw new ra("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Yc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Pc{constructor(){Yc(this,"getProduct",void 0),Yc(this,"getCommandContext",void 0),Yc(this,"getAllLayoutData",void 0),Yc(this,"getMetadata",void 0),Yc(this,"getWorkflowMetadata",void 0),Yc(this,"getStepStorage",void 0),Yc(this,"setModelContainer",void 0),Yc(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,A){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Nc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Rc;var kc;(kc=Rc||(Rc={})).SelectFrame="SelectFrame",kc.SelectImage="SelectImage",kc.Position="Position";class Hc extends yo{constructor(t,e){super(t,e),Nc(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return eo.selectVariant(this.step,t.getResource(),e,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((e=>{e&&t(e)}))}selectImage(t){return eo.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,A,i){return i&&i.length>1&&void 0===t?Rc.SelectFrame:e||A||this.getImageData()?Rc.Position:Rc.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const Uc=t=>{const e=(0,i.useRef)(null),n=(0,i.useRef)(void 0),[a,r]=(0,i.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=Ua(),[g,h]=(0,i.useState)(!1),[d,u]=(0,i.useState)(!1),{state:w,uiDispatcher:B}=Wa(),p=(0,i.useCallback)((t=>{const e=t;B(new Ka({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[B,w.maxZoom]),E=(0,i.useCallback)((t=>{o(t),1===l.length&&(n.current=void 0),2===l.length&&r(void 0);"touch"===t.pointerType&&l.length>1&&l.length-1==1&&(u(!1),h(!1))}),[o,l.length]),m=(0,i.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(B(new Ka({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,B]),C=(0,i.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,A=2===l.length&&"touch"===l[0].pointerType;if(g&&A){const[t,e]=l,A=Math.abs(t.clientX-e.clientX),i=a;i&&p(w.zoom-.0055*(i-A)),r(A)}if(d&&(e||A)&&t.isPrimary){const e=(n?.current?.x||t.screenX)-t.screenX,A=(n?.current?.y||t.screenY)-t.screenY;B(new Ka({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-A/w.zoom}))}t.isPrimary&&(n.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,a,p,w.zoom,w.xTranslation,w.yTranslation,B]),f=(0,i.useCallback)((t=>{g&&p(w.zoom-.035*Math.sign(t.deltaY))}),[p,w.zoom,g]);(0,i.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,A=e.current.hasPointerCapture(t);d&&!A&&e.current.setPointerCapture(t),!d&&A&&e.current.releasePointerCapture(t)}),[e,d,l]),Hr([" "],(()=>{u(!0),B(new Ka({selectedElement:void 0}))}),(()=>u(!1))),Hr(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,i.useMemo)((()=>({cursor:d&&0===l.length?"grab":d&&1===l.length?"grabbing":g?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[d,g,l]);return(0,A.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:f,onPointerDown:m,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:C,style:Q,children:t.children})};
|
|
1306
|
+
`,Sc=async t=>{const e=(await Qa.getShadowGraphqlClient().query({query:fc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},Fc=(t,e)=>{const A=t.workflowState,i=A?JSON.parse(A):void 0;return i?Object.values(i.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:Te(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class bc{constructor(t){var e;pc(this,"options",void 0),pc(this,"initialized",void 0),pc(this,"currencyCode",void 0),pc(this,"customer",void 0),pc(this,"experienceOptions",void 0),pc(this,"updateTransactionState",(async t=>{try{return Qa.getShadowGraphqlClient().mutate({...t,mutation:Ys})}catch(t){throw console.error(t),new ra("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,fa=e)}getAssetManager(){return Ya}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateBundleFromLocalStorage(t){const e=ga.getMap("bundleOwnerIds");if(e?.has(t)){const A=e.get(t);return Ea(A),Promise.resolve({success:!0,stakeholderType:ir.Owner})}const A=ga.getMap("bundleCustomerIds");if(A?.has(t)){const e=A.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=Qa.getShadowGraphqlClient(),A=await e.query({query:Qc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!A.data.transactions||0===A.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const i=A.data.transactions[0],n=i.product?.partner?.id;if(!n)throw new Error(`Unable to read transaction: ${t}`);if(i.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=ga.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return Ba(e),Promise.resolve({success:!0,stakeholderType:ir.Owner})}const r=ga.getMap("transactionCustomerIds");if(r?.has(t)){const e=r.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const s=(await e.query({query:yc,errorPolicy:"all",variables:{id:i.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${i.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:i.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=ga.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),ga.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=Qa.getShadowGraphqlClient(),A=(await e.query({query:Dc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!A.id){const A=(await e.mutate({mutation:Ic,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!A)throw new Error("Unable to create customer.");return this.customer=A,{customer:A,isAuthenticated:!1}}const i=await this.authenticateCustomerId(A.id);return{customer:this.customer||A,isAuthenticated:i}}async authenticateCustomerId(t){const e=Qa.getShadowGraphqlClient(),A=ga.getMap("customerTokens");if(!A?.has(t))return!1;const i=A.get(t);if(!i)return!1;const n=(await e.mutate({mutation:xc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:i}})).data?.customerAuthenticate;return!!n&&(Ca(i),this.customer=n,!0)}async generateVerificationCode(t){await Qa.getShadowGraphqlClient().mutate({mutation:Mc,variables:{emailAddress:t}})}async verifyCode(t,e){const A=(await Qa.getShadowGraphqlClient().mutate({mutation:vc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(A?.loginToken){if(!A.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=ga.getMap("customerTokens")||new Map;return e.set(A.id,A.loginToken),ga.setMap("customerTokens",e),Ca(A.loginToken),this.customer={...A,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await Qa.getShadowGraphqlClient().mutate({mutation:Zo,variables:{collectionId:t}})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");Ea(e.bundleOwnerId);const A=ga.getMap("bundleOwnerIds")||new Map;return A.set(e.id,e.bundleOwnerId),ga.setMap("bundleOwnerIds",A),new Bc(this,e)}async getExistingBundle(t,e){const A=await Qa.getShadowGraphqlClient().query({query:Xo,variables:{id:t}});if(!A.data?.bundles||0===A.data?.bundles.length||!A.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const i=A.data?.bundles[0],n=ga.getMap("bundleOwnerIds");n?.has(i.id)&&Ea(n.get(i.id));const a=new Bc(this,i);if(i.transactions&&i.transactions.length>0){const t=t=>{const A=e?A=>e(A,t):void 0;return this.getWorkflowExperience(void 0,void 0,A,{type:"transaction",transactionId:t})},A=await Promise.all(i.transactions.map((e=>t(e.id))));a._setWorkflowExperiencesInternal(A)}return a}async getWorkflowExperience(t,e,A,i){if(!i)return await this.getWorkflowExperienceDeprecated(t,e,A);const n=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await Vn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ai(e.fontData.assetUrl)}}},{transaction:a,workflow:r,readOnly:s}=await(async()=>{const t=Qa.getShadowGraphqlClient();if("transaction"===i.type){const{transactionId:e,readOnly:A}=i,n=await t.query({query:bs,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!n.data?.transactions||0===n.data.transactions.length)throw new ra("Existing transaction not found.");const a=n.data?.transactions[0];if(!a.workflowId)throw new ra("Existing transaction has no workflow ID.");const r=await Sc(a.workflowId);if(!a.product)throw new ra("Failed to load transaction, product not available.");return{transaction:a,workflow:r,readOnly:A}}if("integration"===i.type||"external"===i.type){const e=async()=>{const e="integration"===i.type?{integrationProductId:i.integrationProductId}:{externalIntegrationId:i.externalIntegrationId,externalProductId:i.externalProductId},A=await t.mutate({mutation:Ss,variables:{...e,bulk:i.bulk,workflowId:i.workflowId,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 ra("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new ra("Failed to create transaction, product not available.");return n},A=Sc(i.workflowId),[n,a]=await Promise.all([e(),A]);return{transaction:n,workflow:a}}throw new ra("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const o={product:a.product,transaction:a,layouts:[],stateMutationFunc:s?async()=>{throw new na("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:s,workflow:r};if("transaction"===i.type&&a.workflowState){const t=JSON.parse(a.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await n(t),o.reloadedState=t}else if(!s&&i.workflowState){const t=JSON.parse(i.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await n(t),o.reloadedState=t}else o.layouts=Fc(o.transaction,o.workflow);if(o.renderableContextService=new Cs(o.layouts),i.previewService?(o.previewService=i.previewService,o.product?.modelUrl&&(o.modelContainer=o.previewService.loadModel({model:o.product.modelUrl,contextService:o.renderableContextService}))):(o.previewService=A&&A(r),o.product?.modelUrl&&(o.previewService?.initialize({model:o.product.modelUrl,contextService:o.renderableContextService}),o.modelContainer=o.previewService?.getAllModels()[0])),"transaction"!==i.type){const t=ga.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),Ba(a.transactionOwnerId||""),ga.setMap("transactionOwnerIds",t)}else{const t=(ga.getMap("transactionOwnerIds")||new Map).get(a.id);t&&Ba(t),o.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=o;const c=new Vo(this,o);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==i.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new ra("No integration product ID provided.");const e=Qa.getShadowGraphqlClient(),A=await e.mutate({mutation:Ss,variables:{integrationProductId:t,bulk:this.options.bulk||!1,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 ra("Failed to create transaction!");const i=A.data.transactionCreate;if(!i.product)throw new ra("Failed to create transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode;const n=ga.getMap("transactionOwnerIds")||new Map;n.set(i.id,i.transactionOwnerId),Ba(i.transactionOwnerId||""),ga.setMap("transactionOwnerIds",n),this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new ra("No transaction ID provided.");const A=Qa.getShadowGraphqlClient();if(e)return await(async()=>{const i=(await A.query({query:bs,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!i)throw new ra("Failed to read transaction.");if(!i.product)throw new ra("Failed to load transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:async()=>{throw new na("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const i=ga.getMap("transactionOwnerIds")||new Map,n=i.get(t);if(n){Ba(n);const i=(await A.query({query:bs,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!i)throw new ra("Failed to read transaction.");if(!i.product)throw new ra("Failed to load transaction, product not available.");return this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const n=(await A.mutate({mutation:Fs,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!n)throw new ra("Failed to read transaction.");if(!n.product)throw new ra("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,n.transactionOwnerId&&(i.set(n.id,n.transactionOwnerId),Ba(n.transactionOwnerId),ga.setMap("transactionOwnerIds",i)),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new ra("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,A){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot launch experience: Not initialized.");const i=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await Vn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ai(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Sc(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await i(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=A&&A(t),this.experienceOptions.renderableContextService=new Cs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Vo(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const n=Qa.getShadowGraphqlClient().mutate({mutation:Ps,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=Sc(t);if(await Promise.all([n,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await i(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=Fc(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await a),this.experienceOptions.renderableContextService=new Cs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const r=new Vo(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}throw new ra("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Yc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Pc{constructor(){Yc(this,"getProduct",void 0),Yc(this,"getCommandContext",void 0),Yc(this,"getAllLayoutData",void 0),Yc(this,"getMetadata",void 0),Yc(this,"getWorkflowMetadata",void 0),Yc(this,"getStepStorage",void 0),Yc(this,"setModelContainer",void 0),Yc(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,A){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Nc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Rc;var kc;(kc=Rc||(Rc={})).SelectFrame="SelectFrame",kc.SelectImage="SelectImage",kc.Position="Position";class Hc extends yo{constructor(t,e){super(t,e),Nc(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return eo.selectVariant(this.step,t.getResource(),e,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((e=>{e&&t(e)}))}selectImage(t){return eo.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,A,i){return i&&i.length>1&&void 0===t?Rc.SelectFrame:e||A||this.getImageData()?Rc.Position:Rc.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const Uc=t=>{const e=(0,i.useRef)(null),n=(0,i.useRef)(void 0),[a,r]=(0,i.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=Ua(),[g,h]=(0,i.useState)(!1),[d,u]=(0,i.useState)(!1),{state:w,uiDispatcher:B}=Wa(),p=(0,i.useCallback)((t=>{const e=t;B(new Ka({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[B,w.maxZoom]),E=(0,i.useCallback)((t=>{o(t),1===l.length&&(n.current=void 0),2===l.length&&r(void 0);"touch"===t.pointerType&&l.length>1&&l.length-1==1&&(u(!1),h(!1))}),[o,l.length]),m=(0,i.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(B(new Ka({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,B]),C=(0,i.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,A=2===l.length&&"touch"===l[0].pointerType;if(g&&A){const[t,e]=l,A=Math.abs(t.clientX-e.clientX),i=a;i&&p(w.zoom-.0055*(i-A)),r(A)}if(d&&(e||A)&&t.isPrimary){const e=(n?.current?.x||t.screenX)-t.screenX,A=(n?.current?.y||t.screenY)-t.screenY;B(new Ka({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-A/w.zoom}))}t.isPrimary&&(n.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,a,p,w.zoom,w.xTranslation,w.yTranslation,B]),f=(0,i.useCallback)((t=>{g&&p(w.zoom-.035*Math.sign(t.deltaY))}),[p,w.zoom,g]);(0,i.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,A=e.current.hasPointerCapture(t);d&&!A&&e.current.setPointerCapture(t),!d&&A&&e.current.releasePointerCapture(t)}),[e,d,l]),Hr([" "],(()=>{u(!0),B(new Ka({selectedElement:void 0}))}),(()=>u(!1))),Hr(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,i.useMemo)((()=>({cursor:d&&0===l.length?"grab":d&&1===l.length?"grabbing":g?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[d,g,l]);return(0,A.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:f,onPointerDown:m,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:C,style:Q,children:t.children})};
|
|
1307
1307
|
//# sourceMappingURL=main.js.map
|
package/dist/module.js
CHANGED
|
@@ -677,7 +677,7 @@ import{CommandContext as t,AssetType as A,BringForwardCommand as e,BringToFrontC
|
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
|
-
`;function hi(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Ei{constructor(t){hi(this,"bundleId",void 0),hi(this,"globalPropertyState",void 0),this.bundleId=t,this.getOrCreateGlobalPropertyState().then((t=>this.globalPropertyState=t))}getGlobalPropertyState(){return this.globalPropertyState}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const A=this.globalPropertyState.aspects.find((A=>A.name===t));if(A)return A.value}setAspect(t,A){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find((A=>A.name===t));return e?e.value=A:this.globalPropertyState.aspects.push({name:t,value:A}),this.updateGlobalPropertyState()}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await yA.getShadowGraphqlClient().mutate({mutation:wi,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects}});if(!t.data?.globalPropertyStateUpdate)throw new Error("Unable to update global property state");this.globalPropertyState=t.data.globalPropertyStateUpdate}async getOrCreateGlobalPropertyState(){const t=await yA.getShadowGraphqlClient().query({query:di,errorPolicy:"all",fetchPolicy:"no-cache",variables:{bundleId:this.bundleId}});if(t.data.globalPropertyState&&t.data.globalPropertyState.id)return t.data.globalPropertyState;const A=await yA.getShadowGraphqlClient().mutate({mutation:Bi,variables:{bundleId:this.bundleId}});if(A.data?.globalPropertyStateCreate&&A.data.globalPropertyStateCreate.id)return A.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}function Ci(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Qi{constructor(t,A){Ci(this,"client",void 0),Ci(this,"id",void 0),Ci(this,"name",void 0),Ci(this,"metadata",void 0),Ci(this,"productCollection",void 0),Ci(this,"globalConfigurations",void 0),Ci(this,"globalPropertyStateManager",void 0),Ci(this,"workflowExperiences",[]),this.client=t,this.id=A.id,this.name=A.name||"",this.metadata=new Map(A.metadata?.map((t=>[t.key,t.value]))||[]),this.productCollection=A.productCollection,this.globalConfigurations=this.resolveGlobalProperties(),this.globalPropertyStateManager=new Ei(this.id)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,A){return this.name=t,this.metadata=new Map(A),this.updateBundle()}async hasGlobalProperties(){const t=await this.globalConfigurations;return t.length>0&&t.some((t=>t.aspects.length>0))}async getGlobalProperties(){const t=await this.globalConfigurations;if(0===t.length)return[];return(await Promise.all(t.map((async t=>await Promise.all(t.aspects.map((async t=>{switch(t.type){case It.FileUpload:return new ci(this,t);case It.Option:const A=t.entityId?await bA.getOption(t.entityId):void 0;return new li(this,t,A);case It.Text:return new gi(this,t)}}))))))).flat()}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}getTotalSubunits(){return this.workflowExperiences.map((t=>t.getTotalPriceSubunits())).reduce(((t,A)=>t+A),0)}getProductCollection(){return this.productCollection}async addWorkflowExperience(t){const A=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===A)))throw new Error("Unable to add transaction to bundle - Already Exists!");await yA.getShadowGraphqlClient().mutate({mutation:Ai,variables:{id:this.id,transactionId:A}}),this.workflowExperiences.push(t);const e=await this.getGlobalProperties();await Promise.all(e.map((A=>A.applyGlobalState([t]))))}async removeWorkflowExperience(t){const A=this.workflowExperiences.indexOf(t);if(!(A>-1))throw new Error("Unable to remove workflow experience from bundle - Not Found!");await yA.getShadowGraphqlClient().mutate({mutation:ei,variables:{id:this.id,transactionId:t.getWorkflowManager().getTransaction().id}}),this.workflowExperiences.splice(A,1)}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await yA.getShadowGraphqlClient().mutate({mutation:oi,variables:{id:this.id,transactionIds:this.workflowExperiences.map((t=>t.getWorkflowManager().getTransaction().id))}})}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,A){await yA.getShadowGraphqlClient().mutate({mutation:ni,variables:{id:this.id,details:t,type:A||oe.Owner}})}async updateStakeholders(t){await yA.getShadowGraphqlClient().mutate({mutation:ai,variables:{id:this.id,input:t}})}async getAllStakeholders(){const t=await yA.getShadowGraphqlClient().query({query:$a,errorPolicy:"all",variables:{id:this.id}});if(!t.data.bundles||0===t.data.bundles.length)throw new Error("Bundle not found!");return t.data.bundles[0].bundleStakeholders||[]}
|
|
680
|
+
`;function hi(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Ei{constructor(t){hi(this,"bundleId",void 0),hi(this,"globalPropertyState",void 0),this.bundleId=t,this.getOrCreateGlobalPropertyState().then((t=>this.globalPropertyState=t))}getGlobalPropertyState(){return this.globalPropertyState}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const A=this.globalPropertyState.aspects.find((A=>A.name===t));if(A)return A.value}setAspect(t,A){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find((A=>A.name===t));return e?e.value=A:this.globalPropertyState.aspects.push({name:t,value:A}),this.updateGlobalPropertyState()}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await yA.getShadowGraphqlClient().mutate({mutation:wi,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects}});if(!t.data?.globalPropertyStateUpdate)throw new Error("Unable to update global property state");this.globalPropertyState=t.data.globalPropertyStateUpdate}async getOrCreateGlobalPropertyState(){const t=await yA.getShadowGraphqlClient().query({query:di,errorPolicy:"all",fetchPolicy:"no-cache",variables:{bundleId:this.bundleId}});if(t.data.globalPropertyState&&t.data.globalPropertyState.id)return t.data.globalPropertyState;const A=await yA.getShadowGraphqlClient().mutate({mutation:Bi,variables:{bundleId:this.bundleId}});if(A.data?.globalPropertyStateCreate&&A.data.globalPropertyStateCreate.id)return A.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}function Ci(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Qi{constructor(t,A){Ci(this,"client",void 0),Ci(this,"id",void 0),Ci(this,"name",void 0),Ci(this,"metadata",void 0),Ci(this,"productCollection",void 0),Ci(this,"globalConfigurations",void 0),Ci(this,"globalPropertyStateManager",void 0),Ci(this,"workflowExperiences",[]),this.client=t,this.id=A.id,this.name=A.name||"",this.metadata=new Map(A.metadata?.map((t=>[t.key,t.value]))||[]),this.productCollection=A.productCollection,this.globalConfigurations=this.resolveGlobalProperties(),this.globalPropertyStateManager=new Ei(this.id)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,A){return this.name=t,this.metadata=new Map(A),this.updateBundle()}async hasGlobalProperties(){const t=await this.globalConfigurations;return t.length>0&&t.some((t=>t.aspects.length>0))}async getGlobalProperties(){const t=await this.globalConfigurations;if(0===t.length)return[];return(await Promise.all(t.map((async t=>await Promise.all(t.aspects.map((async t=>{switch(t.type){case It.FileUpload:return new ci(this,t);case It.Option:const A=t.entityId?await bA.getOption(t.entityId):void 0;return new li(this,t,A);case It.Text:return new gi(this,t)}}))))))).flat()}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}getTotalSubunits(){return this.workflowExperiences.map((t=>t.getTotalPriceSubunits())).reduce(((t,A)=>t+A),0)}getProductCollection(){return this.productCollection}async addWorkflowExperience(t){const A=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===A)))throw new Error("Unable to add transaction to bundle - Already Exists!");await yA.getShadowGraphqlClient().mutate({mutation:Ai,variables:{id:this.id,transactionId:A}}),this.workflowExperiences.push(t);const e=await this.getGlobalProperties();await Promise.all(e.map((A=>A.applyGlobalState([t]))))}async removeWorkflowExperience(t){const A=this.workflowExperiences.indexOf(t);if(!(A>-1))throw new Error("Unable to remove workflow experience from bundle - Not Found!");await yA.getShadowGraphqlClient().mutate({mutation:ei,variables:{id:this.id,transactionId:t.getWorkflowManager().getTransaction().id}}),this.workflowExperiences.splice(A,1)}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await yA.getShadowGraphqlClient().mutate({mutation:oi,variables:{id:this.id,transactionIds:this.workflowExperiences.map((t=>t.getWorkflowManager().getTransaction().id))}})}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,A){await yA.getShadowGraphqlClient().mutate({mutation:ni,variables:{id:this.id,details:t,type:A||oe.Owner}})}async updateStakeholders(t){await yA.getShadowGraphqlClient().mutate({mutation:ai,variables:{id:this.id,input:t}})}async getAllStakeholders(){const t=await yA.getShadowGraphqlClient().query({query:$a,errorPolicy:"all",variables:{id:this.id}});if(!t.data.bundles||0===t.data.bundles.length)throw new Error("Bundle not found!");return t.data.bundles[0].bundleStakeholders||[]}async finish(){return Promise.all(this.workflowExperiences.map((t=>t.onDesignFinished())))}_setWorkflowExperiencesInternal(t){this.workflowExperiences=t}async updateBundle(){if(!(await yA.getShadowGraphqlClient().mutate({mutation:ti,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,A])=>({key:t,value:A})))}})).data?.bundleUpdate)throw new Error("Bundle not found!")}async resolveGlobalProperties(){const t=this.productCollection;if(!t)return Promise.resolve([]);const A=new Set;t.products.forEach((t=>t.workflows?.forEach((t=>A.add(t.workflowName)))));const e=await yA.getShadowGraphqlClient().query({query:ii,errorPolicy:"all",variables:{ids:Array.from(A)}}),n=new Map;return e.data.workflows?.forEach((t=>{t.globalPropertyConfiguration&&n.set(t.globalPropertyConfiguration.id,t.globalPropertyConfiguration)})),Array.from(n.values())}}function ui(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}const pi=ft`
|
|
681
681
|
${FA}
|
|
682
682
|
${SA}
|
|
683
683
|
${GA}
|
|
@@ -1303,5 +1303,5 @@ import{CommandContext as t,AssetType as A,BringForwardCommand as e,BringToFrontC
|
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
1305
|
}
|
|
1306
|
-
`,Yi=async t=>{const A=(await yA.getShadowGraphqlClient().query({query:pi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return A.steps.forEach((t=>{delete t.data.__typename})),A},Si=(t,A)=>{const e=t.workflowState,n=e?JSON.parse(e):void 0;return n?Object.values(n.layouts).map((t=>t.layout)):A.panels.sort(((t,A)=>t.index-A.index)).map((t=>({id:F(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class vi{constructor(t){var A;ui(this,"options",void 0),ui(this,"initialized",void 0),ui(this,"currencyCode",void 0),ui(this,"customer",void 0),ui(this,"experienceOptions",void 0),ui(this,"updateTransactionState",(async t=>{try{return yA.getShadowGraphqlClient().mutate({...t,mutation:Un})}catch(t){throw console.error(t),new cA("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(A=this.options.applicationKey,fA=A)}getAssetManager(){return HA}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateBundleFromLocalStorage(t){const A=dA.getMap("bundleOwnerIds");if(A?.has(t)){const e=A.get(t);return mA(e),Promise.resolve({success:!0,stakeholderType:oe.Owner})}const e=dA.getMap("bundleCustomerIds");if(e?.has(t)){const A=e.get(t);if(A){if(await this.authenticateCustomerId(A)){const A=this.customer?.bundleStakeholders?.find((A=>A.bundle?.id===t));if(A)return Promise.resolve({success:!0,stakeholderType:A.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const A=yA.getShadowGraphqlClient(),e=await A.query({query:mi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!e.data.transactions||0===e.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const n=e.data.transactions[0],a=n.product?.partner?.id;if(!a)throw new Error(`Unable to read transaction: ${t}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=dA.getMap("transactionOwnerIds");if(i?.has(t)){const A=i.get(t);return uA(A),Promise.resolve({success:!0,stakeholderType:oe.Owner})}const o=dA.getMap("transactionCustomerIds");if(o?.has(t)){const A=o.get(t);if(A){if(await this.authenticateCustomerId(A)){const A=this.customer?.bundleStakeholders?.find((A=>A.bundle?.transactions?.some((A=>A.id===t))))||this.customer?.stakeholders?.find((A=>A.transaction?.id===t));if(A)return Promise.resolve({success:!0,stakeholderType:A.type})}}}const r=(await A.query({query:Di,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(t){const A=dA.getMap("transactionCustomerIds");A?.has(t)&&(A.delete(t),dA.setMap("transactionCustomerIds",A))}getStakeholderTypeForTransaction(t){const A=this.customer?.stakeholders?.find((A=>A.transaction?.id===t));if(A)return A.type}async getOrCreateCustomer(t){this.customer=void 0;const A=yA.getShadowGraphqlClient(),e=(await A.query({query:Ii,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!e.id){const e=(await A.mutate({mutation:fi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!e)throw new Error("Unable to create customer.");return this.customer=e,{customer:e,isAuthenticated:!1}}const n=await this.authenticateCustomerId(e.id);return{customer:this.customer||e,isAuthenticated:n}}async authenticateCustomerId(t){const A=yA.getShadowGraphqlClient(),e=dA.getMap("customerTokens");if(!e?.has(t))return!1;const n=e.get(t);if(!n)return!1;const a=(await A.mutate({mutation:yi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!a&&(IA(n),this.customer=a,!0)}async generateVerificationCode(t){await yA.getShadowGraphqlClient().mutate({mutation:Mi,variables:{emailAddress:t}})}async verifyCode(t,A){const e=(await yA.getShadowGraphqlClient().mutate({mutation:Fi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:A}})).data?.customerVerifyCode;if(e?.loginToken){if(!e.partner?.id)throw new Error(`Unable to find customer: ${t}`);const A=dA.getMap("customerTokens")||new Map;return A.set(e.id,e.loginToken),dA.setMap("customerTokens",A),IA(e.loginToken),this.customer={...e,loginToken:void 0},!0}return!1}async getNewBundle(t){const A=(await yA.getShadowGraphqlClient().mutate({mutation:_a,variables:{collectionId:t}})).data?.bundleCreate;if(!A)throw new Error("Unable to create bundle");mA(A.bundleOwnerId);const e=dA.getMap("bundleOwnerIds")||new Map;return e.set(A.id,A.bundleOwnerId),dA.setMap("bundleOwnerIds",e),new Qi(this,A)}async getExistingBundle(t,A){const e=await yA.getShadowGraphqlClient().query({query:Za,variables:{id:t}});if(!e.data?.bundles||0===e.data?.bundles.length||!e.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const n=e.data?.bundles[0],a=dA.getMap("bundleOwnerIds");a?.has(n.id)&&mA(a.get(n.id));const i=new Qi(this,n);if(n.transactions&&n.transactions.length>0){const t=t=>{const e=A?e=>A(e,t):void 0;return this.getWorkflowExperience(void 0,void 0,e,{type:"transaction",transactionId:t})},e=await Promise.all(n.transactions.map((A=>t(A.id))));i.setWorkflowExperiencesInternal(e)}return i}async getWorkflowExperience(t,A,e,n){if(!n)return await this.getWorkflowExperienceDeprecated(t,A,e);const a=async t=>{for(const A in t.layouts){const e=t.layouts[A].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<e.length;++t){const A=e[t];A.src&&A.svg&&(A.cachedObjectURL=await dt(A.svg))}const n=t.layouts[A].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const A=n[t];A.fontData?.assetUrl&&H(A.fontData.assetUrl)}}},{transaction:i,workflow:o,readOnly:r}=await(async()=>{const t=yA.getShadowGraphqlClient();if("transaction"===n.type){const{transactionId:A,readOnly:e}=n,a=await t.query({query:Hn,variables:{id:A},errorPolicy:"all",fetchPolicy:"no-cache"});if(!a.data?.transactions||0===a.data.transactions.length)throw new cA("Existing transaction not found.");const i=a.data?.transactions[0];if(!i.workflowId)throw new cA("Existing transaction has no workflow ID.");const o=await Yi(i.workflowId);if(!i.product)throw new cA("Failed to load transaction, product not available.");return{transaction:i,workflow:o,readOnly:e}}if("integration"===n.type||"external"===n.type){const A=async()=>{const A="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},e=await t.mutate({mutation:Rn,variables:{...A,bulk:n.bulk,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!e.data||!e.data.transactionCreate)throw new cA("Failed to create transaction!");const a=e.data.transactionCreate;if(!a.product)throw new cA("Failed to create transaction, product not available.");return a},e=Yi(n.workflowId),[a,i]=await Promise.all([A(),e]);return{transaction:a,workflow:i}}throw new cA("No workflow ID provided.")})();this.currencyCode=i.product.partner?.currencyCode;const s={product:i.product,transaction:i,layouts:[],stateMutationFunc:r?async()=>{throw new rA("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:r,workflow:o};if("transaction"===n.type&&i.workflowState){const t=JSON.parse(i.workflowState);s.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await a(t),s.reloadedState=t}else if(!r&&n.workflowState){const t=JSON.parse(n.workflowState);s.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await a(t),s.reloadedState=t}else s.layouts=Si(s.transaction,s.workflow);if(s.renderableContextService=new fn(s.layouts),n.previewService?(s.previewService=n.previewService,s.product?.modelUrl&&(s.modelContainer=s.previewService.loadModel({model:s.product.modelUrl,contextService:s.renderableContextService}))):(s.previewService=e&&e(o),s.product?.modelUrl&&(s.previewService?.initialize({model:s.product.modelUrl,contextService:s.renderableContextService}),s.modelContainer=s.previewService?.getAllModels()[0])),"transaction"!==n.type){const t=dA.getMap("transactionOwnerIds")||new Map;t.set(i.id,i.transactionOwnerId),uA(i.transactionOwnerId||""),dA.setMap("transactionOwnerIds",t)}else{const t=(dA.getMap("transactionOwnerIds")||new Map).get(i.id);t&&uA(t),s.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=s;const c=new Xa(this,s);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==n.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new cA("No integration product ID provided.");const A=yA.getShadowGraphqlClient(),e=await A.mutate({mutation:Rn,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!e.data||!e.data.transactionCreate)throw new cA("Failed to create transaction!");const n=e.data.transactionCreate;if(!n.product)throw new cA("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const a=dA.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),uA(n.transactionOwnerId||""),dA.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,A=!1){if(""===t)throw new cA("No transaction ID provided.");const e=yA.getShadowGraphqlClient();if(A)return await(async()=>{const n=(await e.query({query:Hn,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!n)throw new cA("Failed to read transaction.");if(!n.product)throw new cA("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async()=>{throw new rA("State mutation is forbidden in read only mode!")},readOnly:A},this.initialized=!0})();const n=dA.getMap("transactionOwnerIds")||new Map,a=n.get(t);if(a){uA(a);const n=(await e.query({query:Hn,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new cA("Failed to read transaction.");if(!n.product)throw new cA("Failed to load transaction, product not available.");return this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:A},void(this.initialized=!0)}try{const a=(await e.mutate({mutation:Pn,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!a)throw new cA("Failed to read transaction.");if(!a.product)throw new cA("Failed to load transaction, product not available.");this.currencyCode=a.product.partner?.currencyCode,a.transactionOwnerId&&(n.set(a.id,a.transactionOwnerId),uA(a.transactionOwnerId),dA.setMap("transactionOwnerIds",n)),this.experienceOptions={product:a.product,transaction:a,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:A},this.initialized=!0}catch{throw new cA("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,A,e){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot launch experience: Not initialized.");const n=async t=>{for(const A in t.layouts){const e=t.layouts[A].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<e.length;++t){const A=e[t];A.src&&A.svg&&(A.cachedObjectURL=await dt(A.svg))}const n=t.layouts[A].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const A=n[t];A.fontData?.assetUrl&&H(A.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Yi(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=e&&e(t),this.experienceOptions.renderableContextService=new fn(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const A=new Xa(this,this.experienceOptions);return await A.getWorkflowManager().getInitializationPromise(),A}if(t){const a=yA.getShadowGraphqlClient().mutate({mutation:Gn,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),i=Yi(t);if(await Promise.all([a,i]),this.experienceOptions.workflow=await i,A){const t=JSON.parse(A);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=Si(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=e&&e(await i),this.experienceOptions.renderableContextService=new fn(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const o=new Xa(this,this.experienceOptions);return await o.getWorkflowManager().getInitializationPromise(),o}throw new cA("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function xi(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Ni{constructor(){xi(this,"getProduct",void 0),xi(this,"getCommandContext",void 0),xi(this,"getAllLayoutData",void 0),xi(this,"getMetadata",void 0),xi(this,"getWorkflowMetadata",void 0),xi(this,"getStepStorage",void 0),xi(this,"setModelContainer",void 0),xi(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,A){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,A){}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{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,A){}setInformationResults(t){}setMandatoryFulfilled(t,A){}async setSelectionsAndElements(t,A,e){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,A){}async updateStorage(t,A){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Ri(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}let Pi;var Hi;(Hi=Pi||(Pi={})).SelectFrame="SelectFrame",Hi.SelectImage="SelectImage",Hi.Position="Position";class Ui extends Ma{constructor(t,A){super(t,A),Ri(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const A=this.manager.getRegionElements(this.step.stepName);return ia.selectVariant(this.step,t.getResource(),A,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((A=>{A&&t(A)}))}selectImage(t){return ia.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,A,e,n){return n&&n.length>1&&void 0===t?Pi.SelectFrame:A||e||this.getImageData()?Pi.Position:Pi.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const Gi=t=>{const A=bt(null),e=bt(void 0),[n,a]=Rt(void 0),{addEvent:i,removeEvent:o,updateEvent:r,eventCache:s}=LA(),[c,g]=Rt(!1),[l,B]=Rt(!1),{state:w,uiDispatcher:d}=ZA(),h=Pt((t=>{const A=t;d(new qA({zoom:Math.max(.1,Math.min(A,w.maxZoom))}))}),[d,w.maxZoom]),E=Pt((t=>{o(t),1===s.length&&(e.current=void 0),2===s.length&&a(void 0);"touch"===t.pointerType&&s.length>1&&s.length-1==1&&(B(!1),g(!1))}),[o,s.length]),C=Pt((t=>{i(t);"touch"===t.pointerType&&1===s.length&&(d(new qA({selectedElement:void 0})),B(!0),g(!0))}),[i,s.length,d]),Q=Pt((t=>{r(t);const A=1===s.length&&"touch"!==s[0].pointerType,i=2===s.length&&"touch"===s[0].pointerType;if(c&&i){const[t,A]=s,e=Math.abs(t.clientX-A.clientX),i=n;i&&h(w.zoom-.0055*(i-e)),a(e)}if(l&&(A||i)&&t.isPrimary){const A=(e?.current?.x||t.screenX)-t.screenX,n=(e?.current?.y||t.screenY)-t.screenY;d(new qA({selectedElement:void 0,xTranslation:w.xTranslation-A/w.zoom,yTranslation:w.yTranslation-n/w.zoom}))}t.isPrimary&&(e.current={x:t.screenX,y:t.screenY})}),[r,s,c,l,n,h,w.zoom,w.xTranslation,w.yTranslation,d]),u=Pt((t=>{c&&h(w.zoom-.035*Math.sign(t.deltaY))}),[h,w.zoom,c]);Ut((()=>{if(!A.current||0===s.length)return;const t=s[0].pointerId,e=A.current.hasPointerCapture(t);l&&!e&&A.current.setPointerCapture(t),!l&&e&&A.current.releasePointerCapture(t)}),[A,l,s]),Je([" "],(()=>{B(!0),d(new qA({selectedElement:void 0}))}),(()=>B(!1))),Je(["Control"],(()=>g(!0)),(()=>g(!1)));const p=kt((()=>({cursor:l&&0===s.length?"grab":l&&1===s.length?"grabbing":c?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[l,c,s]);return Jt("div",{ref:A,className:"transform-wrapper",onWheel:u,onPointerDown:C,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:Q,style:p,children:t.children})};export{vi as SpiffCommerceClient,t as CommandContext,EA as spiffCoreConfiguration,ze as PromiseQueue,Oe as QueueablePromise,Ni as MockWorkflowManager,ua as InformationMessageType,Ma as StepHandle,Ga as TextStepHandle,Ui as FrameStepHandle,va as BulkStepHandle,Ua as ShapeStepHandle,xa as IllustrationStepHandle,Na as MaterialStepHandle,Ra as ModelStepHandle,Pa as PictureStepHandle,Ha as QuestionStepHandle,te as BulkPriceCalculationStrategy,fa as Variant,AA as OptionNotFoundError,eA as LayoutNotFoundError,nA as AssetNotFoundError,aA as ResourceNotFoundError,iA as MisconfigurationError,sA as ParseError,rA as UnhandledBehaviorError,HA as assetService,Va as designService,za as createDesign,bA as optionService,dA as persistenceService,yA as graphQlManager,ge as toast,Zn as FrameService,Xn as getBoundedOffsets,ia as frameStepService,sa as modelStepService,ra as materialStepService,Ba as shapeStepService,la as questionStepService,na as digitalContentStepService,ca as moduleStepService,ga as pictureStepService,Ca as textStepService,oa as illustrationStepService,$A as ProductCameraRig,Pi as FrameStep,ee as ConversionLocation,ae as ConversionDataType,Yi as getWorkflow,ta as shortenUrl,A as AssetType,e as BringForwardCommand,n as BringToFrontCommand,a as BringToBackCommand,i as CanvasCommand,o as CreateElementCommand,r as CreateLayoutCommand,s as DeleteElementCommand,c as FontAlignmentCommand,g as FontColorCommand,l as FontSizeCommand,B as FontSourceCommand,w as GroupCommand,d as LayoutElementFactory,h as LayoutElementType,E as MoveCommand,C as ResizeCommand,Q as RotateCommand,u as SendBackwardsCommand,oe as StakeholderType,p as StepAspectType,m as StepType,D as TextChangeCommand,I as UnitOfMeasurement,f as dataUrlFromExternalUrl,y as findElement,M as frameDataCache,F as generate,Y as getAxisAlignedBoundingBox,S as generateSVGWithUnknownColors,v as getAttributesFromArrayBuffer,x as rehydrateSerializedLayout,N as getFrameData,R as getSvgElement,P as loadFontFromDataUrl,H as loadFontFromExternalUrl,U as determineCorrectFontSizeAndLines,G as patternImageDataCache,Dn as generateCommands,k as registerJSDOM,Ge as minZoom,Nn as AdvancedEditor,Gi as TransformWrapper,xn as EditorCore,TA as useLayouts,ZA as useEditorState,be as useEditorInteraction,Je as useShortcutCombination,VA as commandReducer,KA as getDefaultState,JA as CommandContextContext,XA as AdvancedEditorStateProvider,WA as AdvancedEditorContext,qA as UICommand,zA as EditorSubMenu,le as ElementEventType,we as KeyEvent,Ln as gatherVaryingStepAspects};
|
|
1306
|
+
`,Yi=async t=>{const A=(await yA.getShadowGraphqlClient().query({query:pi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return A.steps.forEach((t=>{delete t.data.__typename})),A},Si=(t,A)=>{const e=t.workflowState,n=e?JSON.parse(e):void 0;return n?Object.values(n.layouts).map((t=>t.layout)):A.panels.sort(((t,A)=>t.index-A.index)).map((t=>({id:F(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class vi{constructor(t){var A;ui(this,"options",void 0),ui(this,"initialized",void 0),ui(this,"currencyCode",void 0),ui(this,"customer",void 0),ui(this,"experienceOptions",void 0),ui(this,"updateTransactionState",(async t=>{try{return yA.getShadowGraphqlClient().mutate({...t,mutation:Un})}catch(t){throw console.error(t),new cA("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(A=this.options.applicationKey,fA=A)}getAssetManager(){return HA}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateBundleFromLocalStorage(t){const A=dA.getMap("bundleOwnerIds");if(A?.has(t)){const e=A.get(t);return mA(e),Promise.resolve({success:!0,stakeholderType:oe.Owner})}const e=dA.getMap("bundleCustomerIds");if(e?.has(t)){const A=e.get(t);if(A){if(await this.authenticateCustomerId(A)){const A=this.customer?.bundleStakeholders?.find((A=>A.bundle?.id===t));if(A)return Promise.resolve({success:!0,stakeholderType:A.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const A=yA.getShadowGraphqlClient(),e=await A.query({query:mi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!e.data.transactions||0===e.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const n=e.data.transactions[0],a=n.product?.partner?.id;if(!a)throw new Error(`Unable to read transaction: ${t}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=dA.getMap("transactionOwnerIds");if(i?.has(t)){const A=i.get(t);return uA(A),Promise.resolve({success:!0,stakeholderType:oe.Owner})}const o=dA.getMap("transactionCustomerIds");if(o?.has(t)){const A=o.get(t);if(A){if(await this.authenticateCustomerId(A)){const A=this.customer?.bundleStakeholders?.find((A=>A.bundle?.transactions?.some((A=>A.id===t))))||this.customer?.stakeholders?.find((A=>A.transaction?.id===t));if(A)return Promise.resolve({success:!0,stakeholderType:A.type})}}}const r=(await A.query({query:Di,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(t){const A=dA.getMap("transactionCustomerIds");A?.has(t)&&(A.delete(t),dA.setMap("transactionCustomerIds",A))}getStakeholderTypeForTransaction(t){const A=this.customer?.stakeholders?.find((A=>A.transaction?.id===t));if(A)return A.type}async getOrCreateCustomer(t){this.customer=void 0;const A=yA.getShadowGraphqlClient(),e=(await A.query({query:Ii,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!e.id){const e=(await A.mutate({mutation:fi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!e)throw new Error("Unable to create customer.");return this.customer=e,{customer:e,isAuthenticated:!1}}const n=await this.authenticateCustomerId(e.id);return{customer:this.customer||e,isAuthenticated:n}}async authenticateCustomerId(t){const A=yA.getShadowGraphqlClient(),e=dA.getMap("customerTokens");if(!e?.has(t))return!1;const n=e.get(t);if(!n)return!1;const a=(await A.mutate({mutation:yi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!a&&(IA(n),this.customer=a,!0)}async generateVerificationCode(t){await yA.getShadowGraphqlClient().mutate({mutation:Mi,variables:{emailAddress:t}})}async verifyCode(t,A){const e=(await yA.getShadowGraphqlClient().mutate({mutation:Fi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:A}})).data?.customerVerifyCode;if(e?.loginToken){if(!e.partner?.id)throw new Error(`Unable to find customer: ${t}`);const A=dA.getMap("customerTokens")||new Map;return A.set(e.id,e.loginToken),dA.setMap("customerTokens",A),IA(e.loginToken),this.customer={...e,loginToken:void 0},!0}return!1}async getNewBundle(t){const A=(await yA.getShadowGraphqlClient().mutate({mutation:_a,variables:{collectionId:t}})).data?.bundleCreate;if(!A)throw new Error("Unable to create bundle");mA(A.bundleOwnerId);const e=dA.getMap("bundleOwnerIds")||new Map;return e.set(A.id,A.bundleOwnerId),dA.setMap("bundleOwnerIds",e),new Qi(this,A)}async getExistingBundle(t,A){const e=await yA.getShadowGraphqlClient().query({query:Za,variables:{id:t}});if(!e.data?.bundles||0===e.data?.bundles.length||!e.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const n=e.data?.bundles[0],a=dA.getMap("bundleOwnerIds");a?.has(n.id)&&mA(a.get(n.id));const i=new Qi(this,n);if(n.transactions&&n.transactions.length>0){const t=t=>{const e=A?e=>A(e,t):void 0;return this.getWorkflowExperience(void 0,void 0,e,{type:"transaction",transactionId:t})},e=await Promise.all(n.transactions.map((A=>t(A.id))));i._setWorkflowExperiencesInternal(e)}return i}async getWorkflowExperience(t,A,e,n){if(!n)return await this.getWorkflowExperienceDeprecated(t,A,e);const a=async t=>{for(const A in t.layouts){const e=t.layouts[A].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<e.length;++t){const A=e[t];A.src&&A.svg&&(A.cachedObjectURL=await dt(A.svg))}const n=t.layouts[A].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const A=n[t];A.fontData?.assetUrl&&H(A.fontData.assetUrl)}}},{transaction:i,workflow:o,readOnly:r}=await(async()=>{const t=yA.getShadowGraphqlClient();if("transaction"===n.type){const{transactionId:A,readOnly:e}=n,a=await t.query({query:Hn,variables:{id:A},errorPolicy:"all",fetchPolicy:"no-cache"});if(!a.data?.transactions||0===a.data.transactions.length)throw new cA("Existing transaction not found.");const i=a.data?.transactions[0];if(!i.workflowId)throw new cA("Existing transaction has no workflow ID.");const o=await Yi(i.workflowId);if(!i.product)throw new cA("Failed to load transaction, product not available.");return{transaction:i,workflow:o,readOnly:e}}if("integration"===n.type||"external"===n.type){const A=async()=>{const A="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},e=await t.mutate({mutation:Rn,variables:{...A,bulk:n.bulk,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!e.data||!e.data.transactionCreate)throw new cA("Failed to create transaction!");const a=e.data.transactionCreate;if(!a.product)throw new cA("Failed to create transaction, product not available.");return a},e=Yi(n.workflowId),[a,i]=await Promise.all([A(),e]);return{transaction:a,workflow:i}}throw new cA("No workflow ID provided.")})();this.currencyCode=i.product.partner?.currencyCode;const s={product:i.product,transaction:i,layouts:[],stateMutationFunc:r?async()=>{throw new rA("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:r,workflow:o};if("transaction"===n.type&&i.workflowState){const t=JSON.parse(i.workflowState);s.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await a(t),s.reloadedState=t}else if(!r&&n.workflowState){const t=JSON.parse(n.workflowState);s.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await a(t),s.reloadedState=t}else s.layouts=Si(s.transaction,s.workflow);if(s.renderableContextService=new fn(s.layouts),n.previewService?(s.previewService=n.previewService,s.product?.modelUrl&&(s.modelContainer=s.previewService.loadModel({model:s.product.modelUrl,contextService:s.renderableContextService}))):(s.previewService=e&&e(o),s.product?.modelUrl&&(s.previewService?.initialize({model:s.product.modelUrl,contextService:s.renderableContextService}),s.modelContainer=s.previewService?.getAllModels()[0])),"transaction"!==n.type){const t=dA.getMap("transactionOwnerIds")||new Map;t.set(i.id,i.transactionOwnerId),uA(i.transactionOwnerId||""),dA.setMap("transactionOwnerIds",t)}else{const t=(dA.getMap("transactionOwnerIds")||new Map).get(i.id);t&&uA(t),s.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=s;const c=new Xa(this,s);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==n.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new cA("No integration product ID provided.");const A=yA.getShadowGraphqlClient(),e=await A.mutate({mutation:Rn,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!e.data||!e.data.transactionCreate)throw new cA("Failed to create transaction!");const n=e.data.transactionCreate;if(!n.product)throw new cA("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const a=dA.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),uA(n.transactionOwnerId||""),dA.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,A=!1){if(""===t)throw new cA("No transaction ID provided.");const e=yA.getShadowGraphqlClient();if(A)return await(async()=>{const n=(await e.query({query:Hn,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!n)throw new cA("Failed to read transaction.");if(!n.product)throw new cA("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async()=>{throw new rA("State mutation is forbidden in read only mode!")},readOnly:A},this.initialized=!0})();const n=dA.getMap("transactionOwnerIds")||new Map,a=n.get(t);if(a){uA(a);const n=(await e.query({query:Hn,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new cA("Failed to read transaction.");if(!n.product)throw new cA("Failed to load transaction, product not available.");return this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:A},void(this.initialized=!0)}try{const a=(await e.mutate({mutation:Pn,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!a)throw new cA("Failed to read transaction.");if(!a.product)throw new cA("Failed to load transaction, product not available.");this.currencyCode=a.product.partner?.currencyCode,a.transactionOwnerId&&(n.set(a.id,a.transactionOwnerId),uA(a.transactionOwnerId),dA.setMap("transactionOwnerIds",n)),this.experienceOptions={product:a.product,transaction:a,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:A},this.initialized=!0}catch{throw new cA("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,A,e){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot launch experience: Not initialized.");const n=async t=>{for(const A in t.layouts){const e=t.layouts[A].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<e.length;++t){const A=e[t];A.src&&A.svg&&(A.cachedObjectURL=await dt(A.svg))}const n=t.layouts[A].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const A=n[t];A.fontData?.assetUrl&&H(A.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Yi(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=e&&e(t),this.experienceOptions.renderableContextService=new fn(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const A=new Xa(this,this.experienceOptions);return await A.getWorkflowManager().getInitializationPromise(),A}if(t){const a=yA.getShadowGraphqlClient().mutate({mutation:Gn,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),i=Yi(t);if(await Promise.all([a,i]),this.experienceOptions.workflow=await i,A){const t=JSON.parse(A);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=Si(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=e&&e(await i),this.experienceOptions.renderableContextService=new fn(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const o=new Xa(this,this.experienceOptions);return await o.getWorkflowManager().getInitializationPromise(),o}throw new cA("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function xi(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Ni{constructor(){xi(this,"getProduct",void 0),xi(this,"getCommandContext",void 0),xi(this,"getAllLayoutData",void 0),xi(this,"getMetadata",void 0),xi(this,"getWorkflowMetadata",void 0),xi(this,"getStepStorage",void 0),xi(this,"setModelContainer",void 0),xi(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,A){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,A){}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{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,A){}setInformationResults(t){}setMandatoryFulfilled(t,A){}async setSelectionsAndElements(t,A,e){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,A){}async updateStorage(t,A){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Ri(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}let Pi;var Hi;(Hi=Pi||(Pi={})).SelectFrame="SelectFrame",Hi.SelectImage="SelectImage",Hi.Position="Position";class Ui extends Ma{constructor(t,A){super(t,A),Ri(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const A=this.manager.getRegionElements(this.step.stepName);return ia.selectVariant(this.step,t.getResource(),A,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((A=>{A&&t(A)}))}selectImage(t){return ia.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,A,e,n){return n&&n.length>1&&void 0===t?Pi.SelectFrame:A||e||this.getImageData()?Pi.Position:Pi.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const Gi=t=>{const A=bt(null),e=bt(void 0),[n,a]=Rt(void 0),{addEvent:i,removeEvent:o,updateEvent:r,eventCache:s}=LA(),[c,g]=Rt(!1),[l,B]=Rt(!1),{state:w,uiDispatcher:d}=ZA(),h=Pt((t=>{const A=t;d(new qA({zoom:Math.max(.1,Math.min(A,w.maxZoom))}))}),[d,w.maxZoom]),E=Pt((t=>{o(t),1===s.length&&(e.current=void 0),2===s.length&&a(void 0);"touch"===t.pointerType&&s.length>1&&s.length-1==1&&(B(!1),g(!1))}),[o,s.length]),C=Pt((t=>{i(t);"touch"===t.pointerType&&1===s.length&&(d(new qA({selectedElement:void 0})),B(!0),g(!0))}),[i,s.length,d]),Q=Pt((t=>{r(t);const A=1===s.length&&"touch"!==s[0].pointerType,i=2===s.length&&"touch"===s[0].pointerType;if(c&&i){const[t,A]=s,e=Math.abs(t.clientX-A.clientX),i=n;i&&h(w.zoom-.0055*(i-e)),a(e)}if(l&&(A||i)&&t.isPrimary){const A=(e?.current?.x||t.screenX)-t.screenX,n=(e?.current?.y||t.screenY)-t.screenY;d(new qA({selectedElement:void 0,xTranslation:w.xTranslation-A/w.zoom,yTranslation:w.yTranslation-n/w.zoom}))}t.isPrimary&&(e.current={x:t.screenX,y:t.screenY})}),[r,s,c,l,n,h,w.zoom,w.xTranslation,w.yTranslation,d]),u=Pt((t=>{c&&h(w.zoom-.035*Math.sign(t.deltaY))}),[h,w.zoom,c]);Ut((()=>{if(!A.current||0===s.length)return;const t=s[0].pointerId,e=A.current.hasPointerCapture(t);l&&!e&&A.current.setPointerCapture(t),!l&&e&&A.current.releasePointerCapture(t)}),[A,l,s]),Je([" "],(()=>{B(!0),d(new qA({selectedElement:void 0}))}),(()=>B(!1))),Je(["Control"],(()=>g(!0)),(()=>g(!1)));const p=kt((()=>({cursor:l&&0===s.length?"grab":l&&1===s.length?"grabbing":c?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[l,c,s]);return Jt("div",{ref:A,className:"transform-wrapper",onWheel:u,onPointerDown:C,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:Q,style:p,children:t.children})};export{vi as SpiffCommerceClient,t as CommandContext,EA as spiffCoreConfiguration,ze as PromiseQueue,Oe as QueueablePromise,Ni as MockWorkflowManager,ua as InformationMessageType,Ma as StepHandle,Ga as TextStepHandle,Ui as FrameStepHandle,va as BulkStepHandle,Ua as ShapeStepHandle,xa as IllustrationStepHandle,Na as MaterialStepHandle,Ra as ModelStepHandle,Pa as PictureStepHandle,Ha as QuestionStepHandle,te as BulkPriceCalculationStrategy,fa as Variant,AA as OptionNotFoundError,eA as LayoutNotFoundError,nA as AssetNotFoundError,aA as ResourceNotFoundError,iA as MisconfigurationError,sA as ParseError,rA as UnhandledBehaviorError,HA as assetService,Va as designService,za as createDesign,bA as optionService,dA as persistenceService,yA as graphQlManager,ge as toast,Zn as FrameService,Xn as getBoundedOffsets,ia as frameStepService,sa as modelStepService,ra as materialStepService,Ba as shapeStepService,la as questionStepService,na as digitalContentStepService,ca as moduleStepService,ga as pictureStepService,Ca as textStepService,oa as illustrationStepService,$A as ProductCameraRig,Pi as FrameStep,ee as ConversionLocation,ae as ConversionDataType,Yi as getWorkflow,ta as shortenUrl,A as AssetType,e as BringForwardCommand,n as BringToFrontCommand,a as BringToBackCommand,i as CanvasCommand,o as CreateElementCommand,r as CreateLayoutCommand,s as DeleteElementCommand,c as FontAlignmentCommand,g as FontColorCommand,l as FontSizeCommand,B as FontSourceCommand,w as GroupCommand,d as LayoutElementFactory,h as LayoutElementType,E as MoveCommand,C as ResizeCommand,Q as RotateCommand,u as SendBackwardsCommand,oe as StakeholderType,p as StepAspectType,m as StepType,D as TextChangeCommand,I as UnitOfMeasurement,f as dataUrlFromExternalUrl,y as findElement,M as frameDataCache,F as generate,Y as getAxisAlignedBoundingBox,S as generateSVGWithUnknownColors,v as getAttributesFromArrayBuffer,x as rehydrateSerializedLayout,N as getFrameData,R as getSvgElement,P as loadFontFromDataUrl,H as loadFontFromExternalUrl,U as determineCorrectFontSizeAndLines,G as patternImageDataCache,Dn as generateCommands,k as registerJSDOM,Ge as minZoom,Nn as AdvancedEditor,Gi as TransformWrapper,xn as EditorCore,TA as useLayouts,ZA as useEditorState,be as useEditorInteraction,Je as useShortcutCombination,VA as commandReducer,KA as getDefaultState,JA as CommandContextContext,XA as AdvancedEditorStateProvider,WA as AdvancedEditorContext,qA as UICommand,zA as EditorSubMenu,le as ElementEventType,we as KeyEvent,Ln as gatherVaryingStepAspects};
|
|
1307
1307
|
//# sourceMappingURL=module.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -2043,6 +2043,12 @@ interface _Bundle1 {
|
|
|
2043
2043
|
* Retrieves all stakeholders associated with this bundle.
|
|
2044
2044
|
*/
|
|
2045
2045
|
getAllStakeholders(): Promise<BundleStakeholder[]>;
|
|
2046
|
+
/**
|
|
2047
|
+
* Finalizes all experiences within the bundle. This will return a promise that resolves when all experiences have been finalized.
|
|
2048
|
+
* The promise resolves with a list of messages that indicate the status of each experience including
|
|
2049
|
+
* helpful details like what product to add to cart on supported e-commerce platforms.
|
|
2050
|
+
*/
|
|
2051
|
+
finish(): Promise<DesignCreationMessage[]>;
|
|
2046
2052
|
}
|
|
2047
2053
|
export const getWorkflow: (id: string) => Promise<_Workflow1>;
|
|
2048
2054
|
/**
|