@spiffcommerce/core 21.1.0 → 21.1.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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -41
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [21.1.1] - 15-03-2024
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Exported missing `AspectType` for global property handles.
|
|
13
|
+
|
|
14
|
+
## [21.1.0] - 14-03-2024
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- `Bundle.hasGlobalProperties(): boolean`: Returns true when the bundle is linked to a Global Property Configuration.
|
|
19
|
+
|
|
8
20
|
## [21.0.1] - 13-03-2024
|
|
9
21
|
|
|
10
22
|
### Fixed
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _spiffcommerce_papyrus from '@spiffcommerce/papyrus';
|
|
2
2
|
import { OptionResource, VariantResource, Step, AnyStepData, FrameOffsets, PatternImageData, Region, Workflow, ILayout, LayoutsState, LayoutData, SilentStepData, Placeable, StepStorage, CanvasCommand, CommandContext, LayoutState, SerializableStep, CommandState, GlobalPropertyConfiguration, Asset, MaterialResource, AssetType, StepType, GlobalPropertyConfigurationAspect, AspectType, Theme, FrameStepData, CreateElementCommand, FrameElement, IllustrationStepData, IllustrationElement, ColorDefinition, MaterialStepData, ModelStepData, TextStepData, TextboxElement, TextFillImage, FontData, GroupCommand, PictureStepData, QuestionStepData, ShapeStepData, ModuleStepData, DigitalContentStepData, FrameData as FrameData$1, InformationStepData } from '@spiffcommerce/papyrus';
|
|
3
|
-
export { Animatable, AnyStepData, Asset, AssetType, BringForwardCommand, BringToBackCommand, BringToFrontCommand, CanvasCommand, ColorDefinition, ColorProfileProps, CommandContext, CommandState, CreateElementCommand, CreateLayoutCommand, DeleteElementCommand, DigitalContentStepData, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameStepData, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, ImageElement, InformationStepData, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, MoveCommand, OptionResource, PictureStepData, QuestionStepData, ResizeCommand, RotateCommand, SendBackwardsCommand, ShapeStepData, Step, StepAspect, StepAspectType, StepStorage, StepType, TextChangeCommand, TextStepData, TextboxElement, Theme, UnitOfMeasurement, VariantResource, Workflow, WorkflowPanel, dataUrlFromExternalUrl, determineCorrectFontSizeAndLines, findElement, frameDataCache, generate, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, getAxisAlignedBoundingBox, getFrameData, getSvgElement, loadFont, patternImageDataCache, registerFetchImplementation, registerWindowImplementation, rehydrateSerializedLayout, setCanvasModule } from '@spiffcommerce/papyrus';
|
|
3
|
+
export { Animatable, AnyStepData, AspectType, Asset, AssetType, BringForwardCommand, BringToBackCommand, BringToFrontCommand, CanvasCommand, ColorDefinition, ColorProfileProps, CommandContext, CommandState, CreateElementCommand, CreateLayoutCommand, DeleteElementCommand, DigitalContentStepData, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameStepData, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, ImageElement, InformationStepData, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, MoveCommand, OptionResource, PictureStepData, QuestionStepData, ResizeCommand, RotateCommand, SendBackwardsCommand, ShapeStepData, Step, StepAspect, StepAspectType, StepStorage, StepType, TextChangeCommand, TextStepData, TextboxElement, Theme, UnitOfMeasurement, VariantResource, Workflow, WorkflowPanel, dataUrlFromExternalUrl, determineCorrectFontSizeAndLines, findElement, frameDataCache, generate, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, getAxisAlignedBoundingBox, getFrameData, getSvgElement, loadFont, patternImageDataCache, registerFetchImplementation, registerWindowImplementation, rehydrateSerializedLayout, setCanvasModule } from '@spiffcommerce/papyrus';
|
|
4
4
|
import { ApolloClient, MutationOptions, FetchResult } from '@apollo/client/core';
|
|
5
5
|
import { RenderableContextService, RenderableContext, ThreeDPreviewService, ModelContainer } from '@spiffcommerce/preview';
|
|
6
6
|
import * as lodash from 'lodash';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHttpLink as Et, InMemoryCache as ht, ApolloClient as Ct, from as Qt, gql as F } from "@apollo/client/core";
|
|
2
2
|
import { fetch as $e, getAttributesFromArrayBuffer as yA, AssetType as BA, StepType as D, getFrameData as _e, frameDataCache as ut, GroupCommand as G, UpdateFramePattern as YA, UpdateFrameThresholdSettingsCommand as mt, calculateOffsets as eA, LayoutElementType as v, generate as J, CreateElementCommand as L, generateSVGWithUnknownColors as SA, svgObjectURL as fe, fetchAsString as Z, DeleteElementCommand as $, generateDefaultRectangleFrameSvg as dA, GetSVGDimensions as It, patternImageDataCache as wA, fetchAsArrayBuffer as pt, findElement as De, modifySVGWithElementProperties as ft, IllustrationColorCommand as Ke, IllustrationCacheCommand as Dt, getFontMetrics as Ft, getPatternImageData as je, FontAlignmentCommand as Mt, FontColorCommand as yt, FontImageFillCommand as Je, applyTextTransformations as Ve, determineCorrectFontSizeAndLines as me, FontSourceCommand as EA, loadFont as AA, TextChangeCommand as Yt, FontSizeCommand as St, createElementNS as xt, createElement as Be, _loadFontExternalDataURL as tA, UpdateWorkflowStateCommand as hA, CommandContext as Pt, createCanvas as Fe, getSvgElement as xA, LayoutRenderingPurpose as PA, renderPapyrusComponentAsString as NA, loadImage as HA, getDomParser as RA, toBase64 as CA, getVariant as Nt, generateFrameSVG as Ht, getDefaultVariant as He, domParser as UA, sanitizeSvgTree as GA, traverse as Rt, xmlSerializer as vA, CreateLayoutCommand as Ut, AspectType as Ie, rehydrateSerializedLayout as ee } from "@spiffcommerce/papyrus";
|
|
3
|
-
import {
|
|
3
|
+
import { AspectType as Ki, AssetType as ji, BringForwardCommand as Vi, BringToBackCommand as Wi, BringToFrontCommand as Xi, CanvasCommand as qi, CommandContext as Zi, CreateElementCommand as $i, CreateLayoutCommand as _i, DeleteElementCommand as es, FontAlignmentCommand as As, FontColorCommand as ts, FontSizeCommand as ns, FontSourceCommand as as, GroupCommand as is, LayoutElementFactory as ss, LayoutElementType as os, MoveCommand as rs, ResizeCommand as cs, RotateCommand as gs, SendBackwardsCommand as ls, StepAspectType as Bs, StepType as ds, TextChangeCommand as ws, UnitOfMeasurement as Es, dataUrlFromExternalUrl as hs, determineCorrectFontSizeAndLines as Cs, findElement as Qs, frameDataCache as us, generate as ms, generateSVGWithUnknownColors as Is, getAttributesFromArrayBuffer as ps, getAxisAlignedBoundingBox as fs, getFrameData as Ds, getSvgElement as Fs, loadFont as Ms, patternImageDataCache as ys, registerFetchImplementation as Ys, registerWindowImplementation as Ss, rehydrateSerializedLayout as xs, setCanvasModule as Ps } from "@spiffcommerce/papyrus";
|
|
4
4
|
import { setContext as Gt } from "@apollo/client/link/context";
|
|
5
5
|
import { onError as vt } from "@apollo/client/link/error";
|
|
6
6
|
import { Pith as kA } from "pith";
|
|
@@ -10781,44 +10781,45 @@ class Fi extends W {
|
|
|
10781
10781
|
}
|
|
10782
10782
|
export {
|
|
10783
10783
|
Li as ArrayInput,
|
|
10784
|
+
Ki as AspectType,
|
|
10784
10785
|
_ as AssetNotFoundError,
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10786
|
+
ji as AssetType,
|
|
10787
|
+
Vi as BringForwardCommand,
|
|
10788
|
+
Wi as BringToBackCommand,
|
|
10789
|
+
Xi as BringToFrontCommand,
|
|
10790
|
+
qi as CanvasCommand,
|
|
10790
10791
|
Oe as CollectionProduct,
|
|
10791
|
-
|
|
10792
|
+
Zi as CommandContext,
|
|
10792
10793
|
cn as ConversionDataType,
|
|
10793
10794
|
rn as ConversionLocation,
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10795
|
+
$i as CreateElementCommand,
|
|
10796
|
+
_i as CreateLayoutCommand,
|
|
10797
|
+
es as DeleteElementCommand,
|
|
10797
10798
|
Qe as FlowExecutionNodeResult,
|
|
10798
10799
|
ii as FlowExecutionResult,
|
|
10799
10800
|
ai as FlowService,
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10801
|
+
As as FontAlignmentCommand,
|
|
10802
|
+
ts as FontColorCommand,
|
|
10803
|
+
ns as FontSizeCommand,
|
|
10804
|
+
as as FontSourceCommand,
|
|
10804
10805
|
pn as FrameService,
|
|
10805
10806
|
Di as FrameStep,
|
|
10806
10807
|
Fi as FrameStepHandle,
|
|
10807
10808
|
gA as GlobalPropertyHandle,
|
|
10808
|
-
|
|
10809
|
+
is as GroupCommand,
|
|
10809
10810
|
$n as IllustrationStepHandle,
|
|
10810
10811
|
Pe as InformationMessageType,
|
|
10811
10812
|
ia as InformationStepHandle,
|
|
10812
10813
|
MA as IntegrationProduct,
|
|
10813
10814
|
sn as IntegrationType,
|
|
10814
|
-
|
|
10815
|
-
|
|
10815
|
+
ss as LayoutElementFactory,
|
|
10816
|
+
os as LayoutElementType,
|
|
10816
10817
|
z as LayoutNotFoundError,
|
|
10817
10818
|
_n as MaterialStepHandle,
|
|
10818
10819
|
ye as MisconfigurationError,
|
|
10819
10820
|
Ti as MockWorkflowManager,
|
|
10820
10821
|
ea as ModelStepHandle,
|
|
10821
|
-
|
|
10822
|
+
rs as MoveCommand,
|
|
10822
10823
|
dt as ObjectInput,
|
|
10823
10824
|
si as ObjectInputType,
|
|
10824
10825
|
Me as OptionNotFoundError,
|
|
@@ -10831,61 +10832,61 @@ export {
|
|
|
10831
10832
|
XA as PromiseQueue,
|
|
10832
10833
|
ta as QuestionStepHandle,
|
|
10833
10834
|
WA as QueueablePromise,
|
|
10834
|
-
|
|
10835
|
+
cs as ResizeCommand,
|
|
10835
10836
|
ce as ResourceNotFoundError,
|
|
10836
|
-
|
|
10837
|
-
|
|
10837
|
+
gs as RotateCommand,
|
|
10838
|
+
ls as SendBackwardsCommand,
|
|
10838
10839
|
na as ShapeStepHandle,
|
|
10839
10840
|
fi as SpiffCommerceClient,
|
|
10840
10841
|
Ye as StakeholderType,
|
|
10841
|
-
|
|
10842
|
+
Bs as StepAspectType,
|
|
10842
10843
|
W as StepHandle,
|
|
10843
|
-
|
|
10844
|
-
|
|
10844
|
+
ds as StepType,
|
|
10845
|
+
ws as TextChangeCommand,
|
|
10845
10846
|
bi as TextInput,
|
|
10846
10847
|
aa as TextStepHandle,
|
|
10847
10848
|
ti as Transform,
|
|
10848
10849
|
Ai as TransformCollection,
|
|
10849
10850
|
k as UnhandledBehaviorError,
|
|
10850
|
-
|
|
10851
|
+
Es as UnitOfMeasurement,
|
|
10851
10852
|
X as Variant,
|
|
10852
10853
|
Ea as WorkflowExperienceEventType,
|
|
10853
10854
|
he as WorkflowExperienceImpl,
|
|
10854
10855
|
O as assetService,
|
|
10855
10856
|
la as createDesign,
|
|
10856
|
-
|
|
10857
|
+
hs as dataUrlFromExternalUrl,
|
|
10857
10858
|
Te as designService,
|
|
10858
|
-
|
|
10859
|
+
Cs as determineCorrectFontSizeAndLines,
|
|
10859
10860
|
Fn as digitalContentStepService,
|
|
10860
|
-
|
|
10861
|
-
|
|
10861
|
+
Qs as findElement,
|
|
10862
|
+
us as frameDataCache,
|
|
10862
10863
|
Xe as frameStepService,
|
|
10863
|
-
|
|
10864
|
+
ms as generate,
|
|
10864
10865
|
Ma as generateCommands,
|
|
10865
|
-
|
|
10866
|
+
Is as generateSVGWithUnknownColors,
|
|
10866
10867
|
Ji as generateStateFromDesignInputSteps,
|
|
10867
|
-
|
|
10868
|
-
|
|
10868
|
+
ps as getAttributesFromArrayBuffer,
|
|
10869
|
+
fs as getAxisAlignedBoundingBox,
|
|
10869
10870
|
In as getBoundedOffsets,
|
|
10870
|
-
|
|
10871
|
-
|
|
10871
|
+
Ds as getFrameData,
|
|
10872
|
+
Fs as getSvgElement,
|
|
10872
10873
|
ue as getWorkflow,
|
|
10873
10874
|
wt as getWorkflows,
|
|
10874
10875
|
P as graphQlManager,
|
|
10875
10876
|
pe as illustrationStepService,
|
|
10876
|
-
|
|
10877
|
+
Ms as loadFont,
|
|
10877
10878
|
ZA as materialStepService,
|
|
10878
10879
|
$A as modelStepService,
|
|
10879
10880
|
Pn as moduleStepService,
|
|
10880
10881
|
j as optionService,
|
|
10881
|
-
|
|
10882
|
+
ys as patternImageDataCache,
|
|
10882
10883
|
x as persistenceService,
|
|
10883
10884
|
_A as pictureStepService,
|
|
10884
10885
|
et as questionStepService,
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10886
|
+
Ys as registerFetchImplementation,
|
|
10887
|
+
Ss as registerWindowImplementation,
|
|
10888
|
+
xs as rehydrateSerializedLayout,
|
|
10889
|
+
Ps as setCanvasModule,
|
|
10889
10890
|
re as shapeStepService,
|
|
10890
10891
|
fn as shortenUrl,
|
|
10891
10892
|
q as spiffCoreConfiguration,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -2969,4 +2969,4 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
|
|
|
2969
2969
|
}
|
|
2970
2970
|
}
|
|
2971
2971
|
}
|
|
2972
|
-
`,Ae=async c=>{var e;for(const t in c.layouts){const A=c.layouts[t].elements.filter(a=>a.type===g.LayoutElementType.Illustration);for(let a=0;a<A.length;++a){const i=A[a];i.src&&i.svg&&(i.cachedObjectURL=await g.svgObjectURL(i.svg))}const n=c.layouts[t].elements.filter(a=>a.type===g.LayoutElementType.Textbox);for(let a=0;a<n.length;++a){const i=n[a];(e=i.fontData)!=null&&e.assetUrl&&await g.loadFont(i.fontData.assetUrl)}}},ua=async(c,e)=>{var n;const t=await N.getShadowGraphqlClient().query({query:ga(((n=e==null?void 0:e.assets)==null?void 0:n.metadata)||!1),errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:c}}),A=t.data.workflows;if(A===void 0||A.length!==c.length)throw new Error(`Unable to read workflows: ${t.errors??"Length mismatch in response"}`);return A.forEach(a=>{a.steps.forEach(i=>{var o,s,r;delete i.data.__typename,(o=i.option)!=null&&o.id&&((s=i.option.defaultVariant)!=null&&s.asset&&J.cacheAsset(i.option.defaultVariant.asset),i.option.colorProfile&&J.cacheAsset(i.option.colorProfile),(r=i.option.variants)==null||r.forEach(l=>{l.asset&&J.cacheAsset(l.asset),l.displayImage&&J.cacheAsset(l.displayImage),l.thumbnail&&J.cacheAsset(l.thumbnail),l.material&&J.cacheMaterial(l.material)}),Z.set({id:i.option.id},Promise.resolve(i.option)))})}),A},ma=async(c,e)=>{const A=(await e).find(n=>n.id===c);if(!A)throw new Error(`Workflow not found: ${c}`);return A},Xe=async(c,e)=>{const t=c.map(o=>Z.get({id:o,options:e})),A=c.filter((o,s)=>t[s]===void 0);if(A.length===0)return Promise.all(t);const n=ua(A,e),a=A.map(o=>Z.set({id:o,options:e},ma(o,n))),i=t.filter(o=>o!==void 0);return await Promise.all(i.concat(a))},we=async(c,e)=>(await Xe([c],e))[0],Ia=c=>c.sort((e,t)=>e.index-t.index).map(e=>({id:g.generate(),panelId:e.name,name:e.name,index:e.index,createdAt:new Date,updatedAt:new Date,transparentBackground:e.transparentBackground,height:e.height,width:e.width,previewRegion:e.previewRegion,useEditableArea:e.useEditableArea,editableArea:e.editableArea})),qe=(c,e)=>{const t=c.workflowState,A=t?JSON.parse(t):void 0;return A?Object.values(A.layouts).map(n=>n.layout):Ia(e.panels)};class nA{constructor(e){this.updateTransactionState=async t=>{try{return N.getShadowGraphqlClient().mutate({...t,mutation:PA})}catch(A){throw console.error(A),new G("Critical - Unable to synchronize workflow state with server.")}},this.initialized=!1,this.options=e,this.options.applicationKey&&gA(this.options.applicationKey)}getAssetManager(){return J}getCurrencyCode(){if(this.currencyCode===void 0)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!lA())throw new Error("Application key required to use Flow Service.");return new eA}async getIntegration(){return(await N.getShadowGraphqlClient().query({query:Ba,errorPolicy:"all"})).data.currentIntegration}async authenticateBundleFromLocalStorage(e){var n,a;const t=P.getMap("bundleOwnerIds");if(t!=null&&t.has(e))return Promise.resolve({success:!0,stakeholderType:se.Owner});const A=P.getMap("bundlePartnerIds")||new Map;if(A.has(e)){const i=A.get(e),s=(P.getMap("partnerCustomerIds")||new Map).get(i);if(s&&await this.authenticateCustomerId(s)){const l=(a=(n=this.customer)==null?void 0:n.bundleStakeholders)==null?void 0:a.find(d=>{var B;return((B=d.bundle)==null?void 0:B.id)===e});if(l)return Promise.resolve({success:!0,stakeholderType:l.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(e){var l,d,B,w,E,C;const t=N.getShadowGraphqlClient(),A=await t.query({query:la,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:e}});if(!A.data.transactions||A.data.transactions.length===0)throw new Error(`Transaction not found: ${e}`);const n=A.data.transactions[0];if(!((d=(l=n.product)==null?void 0:l.partner)==null?void 0:d.id))throw new Error(`Unable to read transaction: ${e}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=P.getMap("transactionOwnerIds");if(i!=null&&i.has(e))return Promise.resolve({success:!0,stakeholderType:se.Owner});const o=P.getMap("transactionCustomerIds");if(o!=null&&o.has(e)){const h=o.get(e);if(h&&await this.authenticateCustomerId(h)){const u=((w=(B=this.customer)==null?void 0:B.bundleStakeholders)==null?void 0:w.find(F=>{var I,f;return(f=(I=F.bundle)==null?void 0:I.transactions)==null?void 0:f.some(D=>D.id===e)}))||((C=(E=this.customer)==null?void 0:E.stakeholders)==null?void 0:C.find(F=>{var I;return((I=F.transaction)==null?void 0:I.id)===e}));if(u)return Promise.resolve({success:!0,stakeholderType:u.type})}}const r=(await t.query({query:da,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(e){const t=P.getMap("transactionCustomerIds");t!=null&&t.has(e)&&(t.delete(e),P.setMap("transactionCustomerIds",t))}getStakeholderTypeForTransaction(e){var A,n;const t=(n=(A=this.customer)==null?void 0:A.stakeholders)==null?void 0:n.find(a=>{var i;return((i=a.transaction)==null?void 0:i.id)===e});if(t)return t.type}async getOrCreateCustomer(e){var i;this.customer=void 0;const t=N.getShadowGraphqlClient(),n=(await t.query({query:wa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e}})).data.customer;if(!n.id){const s=(i=(await t.mutate({mutation:Ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:e}}})).data)==null?void 0:i.customerCreate;if(!s)throw new Error("Unable to create customer.");return this.storeCustomer(s),this.customer=s,{customer:s,isAuthenticated:!1}}this.storeCustomer(n);const a=await this.authenticateCustomerId(n.id);return{customer:this.customer||n,isAuthenticated:a}}async authenticateCustomerId(e){var o;const t=N.getShadowGraphqlClient(),A=P.getMap("customerTokens");if(!(A!=null&&A.has(e)))return!1;const n=A.get(e);if(!n)return!1;const i=(o=(await t.mutate({mutation:ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data)==null?void 0:o.customerAuthenticate;return i?(this.storeCustomer(i),st(n),this.customer=i,!0):!1}async generateVerificationCode(e){await N.getShadowGraphqlClient().mutate({mutation:Ca,variables:{emailAddress:e}})}async verifyCode(e,t){var a,i;const n=(a=(await N.getShadowGraphqlClient().mutate({mutation:Qa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e,verificationCode:t}})).data)==null?void 0:a.customerVerifyCode;if(n!=null&&n.loginToken){if(!((i=n.partner)!=null&&i.id))throw new Error(`Unable to find customer: ${e}`);const o=P.getMap("customerTokens")||new Map;return o.set(n.id,n.loginToken),P.setMap("customerTokens",o),this.storeCustomer(n),st(n.loginToken),this.customer={...n,loginToken:void 0},!0}return!1}async getNewBundle(e,t,A){var s,r,l;const a=(l=(await N.getShadowGraphqlClient().mutate({mutation:bn(((r=(s=A==null?void 0:A.graphql)==null?void 0:s.productCollection)==null?void 0:r.eagerFetchProducts)||!1),variables:{collectionId:e,initialMetadata:t?Object.entries(t).map((d,B)=>({key:d[0],value:d[1]})):void 0},fetchPolicy:"no-cache"})).data)==null?void 0:l.bundleCreate;if(!(a!=null&&a.id))throw new Error("Unable to create bundle");const i=P.getMap("bundlePartnerIds")||new Map;i.set(a.id,a.partner.id),P.setMap("bundlePartnerIds",i);const o=P.getMap("bundleOwnerIds")||new Map;return o.set(a.id,a.bundleOwnerId),P.setMap("bundleOwnerIds",o),new _t(this,a,void 0,void 0,a.bundleOwnerId)}async getExistingBundle(e,t,A,n){var d,B,w,E,C,h;const a=P.getMap("bundleOwnerIds"),i=a==null?void 0:a.get(e),o=await N.getShadowGraphqlClient().query({query:Un(((B=(d=n==null?void 0:n.graphql)==null?void 0:d.productCollection)==null?void 0:B.eagerFetchProducts)||!1),variables:{id:e},fetchPolicy:"no-cache",context:{bundleOwnerId:i}});if(!((w=o.data)!=null&&w.bundles)||((E=o.data)==null?void 0:E.bundles.length)===0||!((C=o.data)!=null&&C.bundles[0]))throw new Error(`Unable to find bundle: ${e}`);const s=(h=o.data)==null?void 0:h.bundles[0],r=P.getMap("bundlePartnerIds")||new Map;r.set(s.id,s.partner.id),P.setMap("bundlePartnerIds",r);const l=new _t(this,s,t,A,i);return await l.getInitializationPromise(),l}async getBundleStakeholders(){var a;if(!this.customer)throw new Error("Customer not authenticated.");const e=await N.getShadowGraphqlClient().query({query:vn,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((a=e.data)!=null&&a.customers)||e.data.customers.length===0)throw new Error("Unable to find customer.");const A=e.data.customers[0].bundleStakeholders||[],n=P.getMap("bundlePartnerIds")||new Map;return A.forEach(i=>{var o,s;(o=i.bundle)!=null&&o.id&&((s=i.bundle.partner)!=null&&s.id)&&n.set(i.bundle.id,i.bundle.partner.id)}),P.setMap("bundlePartnerIds",n),A}async getWorkflowExperience(e,t,A,n){var d,B,w,E,C;if(!n)return await this.getWorkflowExperienceDeprecated(e,t,A);const a=async()=>{var m,u;const h=N.getShadowGraphqlClient();if(n.type==="transaction"){const{transactionId:F,readOnly:I}=n,f=await h.query({query:ue,variables:{ids:[F]},errorPolicy:"all",fetchPolicy:"no-cache"});if(!((m=f.data)!=null&&m.transactions)||f.data.transactions.length===0)throw new G("Existing transaction not found.");const D=(u=f.data)==null?void 0:u.transactions[0];if(!D.workflowId)throw new G("Existing transaction has no workflow ID.");const p=await we(D.workflowId);if(!D.product)throw new G("Failed to load transaction, product not available.");return{transaction:D,workflow:p,readOnly:I}}if(n.type==="integration"||n.type==="external"){const F=async()=>{const p=n.type==="integration"?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},S=await h.mutate({mutation:wt,variables:{...p,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!S.data||!S.data.transactionCreate)throw new G("Failed to create transaction!");const y=S.data.transactionCreate;if(!y.product)throw new G("Failed to create transaction, product not available.");return y},I=we(n.workflowId,n==null?void 0:n.graphql),[f,D]=await Promise.all([F(),I]);return{transaction:f,workflow:D}}throw new G("No workflow ID provided.")},{transaction:i,workflow:o,readOnly:s}=await a();this.currencyCode=(d=i.product.partner)==null?void 0:d.currencyCode;const r={product:i.product,transaction:i,layouts:[],singleVariantsRenderable:(B=n==null?void 0:n.workflowConfiguration)==null?void 0:B.singleVariantsRenderable,stateMutationFunc:s?async()=>{throw new v("State mutation is forbidden in read only mode!")}:async h=>{const u=(P.getMap("transactionOwnerIds")||new Map).get(i.id)||void 0;return this.updateTransactionState({...h,context:{transactionOwnerId:u}})},readOnly:s,workflow:o};if(n.type==="transaction"&&i.workflowState){const h=JSON.parse(i.workflowState);r.layouts=Object.values(h.layouts).map(m=>m.layout),await g.rehydrateSerializedLayout(h),await Ae(h),r.reloadedState=h}else if(!s&&n.workflowState){const h=JSON.parse(n.workflowState);r.layouts=Object.values(h.layouts).map(m=>m.layout),await g.rehydrateSerializedLayout(h),await Ae(h),r.reloadedState=h}else r.layouts=qe(r.transaction,r.workflow);if(r.renderableContextService=new Me(r.layouts),n.previewService?(r.previewService=n.previewService,(w=r.product)!=null&&w.modelUrl&&(r.modelContainer=r.previewService.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))):(r.previewService=A&&A(o),(E=r.product)!=null&&E.modelUrl&&(r.modelContainer=(C=r.previewService)==null?void 0:C.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))),n.type!=="transaction"){const h=P.getMap("transactionOwnerIds")||new Map;h.set(i.id,i.transactionOwnerId),P.setMap("transactionOwnerIds",h)}else r.isReloadedTransaction=!0;this.initialized=!0,this.experienceOptions=r;const l=new le(this,r);return await l.getWorkflowManager().getInitializationPromise(),n.type!=="transaction"&&this.customer&&await l.attachCustomerDetails({email:this.customer.emailAddress}),l}async getWorkflowExperiences(e,t){if(e.length===0)throw new G("No options provided!");const A=N.getShadowGraphqlClient(),n=async f=>{var y,x;if(f.length===0)return[];const D=f.map(Y=>Y.option.transactionId),p=await A.query({query:ue,variables:{ids:D},errorPolicy:"all",fetchPolicy:"no-cache"}),S=p.data.transactions;if(S.length!==f.length){const Y=((x=(y=p.errors)==null?void 0:y[0])==null?void 0:x.message)||"Unknown error";throw new G(`Not all transactions were found: ${Y}`)}return S.map((Y,H)=>{var R;return{transaction:Y,workflowId:Y.workflowId,readOnly:((R=f.find(T=>T.option.transactionId===Y.id))==null?void 0:R.option.readOnly)??!1,index:f[H].index}})},a=async f=>{var S,y,x;if(f.length===0)return[];const D=await A.mutate({mutation:yA,variables:{inputs:f.map(Y=>({integrationProductId:Y.option.type==="integration"?Y.option.integrationProductId:void 0,externalIntegrationId:Y.option.type==="external"?Y.option.externalIntegrationId:void 0,externalProductId:Y.option.type==="external"?Y.option.externalProductId:void 0,workflowId:Y.option.workflowId,claim:!0}))},errorPolicy:"all",fetchPolicy:"no-cache"}),p=(S=D.data)==null?void 0:S.transactionCreateMany;if(!p||p.length===0){const Y=((x=(y=D.errors)==null?void 0:y[0])==null?void 0:x.message)||"Unknown error";throw new G(`Failed to create transactions: ${Y}`)}return p.map((Y,H)=>({transaction:Y,workflowId:Y.workflowId,readOnly:!1,index:f[H].index}))},i=e.map((f,D)=>({option:f,index:D})),o=i.filter(f=>f.option.type==="transaction"),s=i.filter(f=>f.option.type==="integration"||f.option.type==="external"),r=nt(o,10),l=nt(s,10),d=(await Promise.all([...r.map(n),...l.map(a)])).flat(),B=[...new Set(d.map(f=>f.workflowId))],w=await Xe(B,t),E=new Map(w.map(f=>[f.id,f])),C=P.getMap("transactionOwnerIds")||new Map,h=d.map(async f=>{var T;const{transaction:D,workflowId:p,readOnly:S,index:y}=f,x=E.get(p),Y=e[y];!C.get(D.id)&&D.transactionOwnerId&&C.set(D.id,D.transactionOwnerId);const H=C.get(D.id)||void 0,R={product:D.product,transaction:D,layouts:[],singleVariantsRenderable:(T=Y==null?void 0:Y.workflowConfiguration)==null?void 0:T.singleVariantsRenderable,stateMutationFunc:S?async()=>{throw new v("State mutation is forbidden in read only mode!")}:async k=>this.updateTransactionState({...k,context:{transactionOwnerId:H}}),readOnly:S,workflow:x,isReloadedTransaction:Y.type==="transaction"};if(Y.type==="transaction"&&D.workflowState){const k=JSON.parse(D.workflowState);R.layouts=Object.values(k.layouts).map(z=>z.layout),await g.rehydrateSerializedLayout(k),await Ae(k),R.reloadedState=k}else if(!S&&Y.workflowState){const k=JSON.parse(Y.workflowState);R.layouts=Object.values(k.layouts).map(z=>z.layout),await g.rehydrateSerializedLayout(k),await Ae(k),R.reloadedState=k}else R.layouts=qe(R.transaction,R.workflow);return R.renderableContextService=new Me(R.layouts),R.delayWorkflowStateSync=!0,this.initialized=!0,this.experienceOptions=R,{experienceOptions:R,index:y,options:Y}});P.setMap("transactionOwnerIds",C);const F=(await Promise.all(h)).sort((f,D)=>f.index-D.index).map(async f=>{const{experienceOptions:D,options:p}=f,S=new le(this,D);return await S.getWorkflowManager().getInitializationPromise(),p.type!=="transaction"&&this.customer&&await S.attachCustomerDetails({email:this.customer.emailAddress}),S}),I=await Promise.all(F);return I.forEach(f=>f.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),I}async initFromIntegrationProduct(e){var i;if(e==="")throw new G("No integration product ID provided.");const A=await N.getShadowGraphqlClient().mutate({mutation:wt,variables:{integrationProductId:e,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new G("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new G("Failed to create transaction, product not available.");this.currencyCode=(i=n.product.partner)==null?void 0:i.currencyCode;const a=P.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),P.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async o=>this.updateTransactionState({...o,context:{transactionOwnerId:n.transactionOwnerId}})},this.initialized=!0}async initFromTransaction(e,t=!1){var o,s,r,l;if(e==="")throw new G("No transaction ID provided.");const A=N.getShadowGraphqlClient(),n=async()=>{var w,E;const B=(w=(await A.query({query:ue,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:w.transactions[0];if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(E=B.product.partner)==null?void 0:E.currencyCode,this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async()=>{throw new v("State mutation is forbidden in read only mode!")},readOnly:t},this.initialized=!0};if(t)return await n();const a=P.getMap("transactionOwnerIds")||new Map,i=a.get(e);if(i){const B=(o=(await A.query({query:ue,variables:{ids:[e]},errorPolicy:"all"})).data)==null?void 0:o.transactions[0];if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(s=B.product.partner)==null?void 0:s.currencyCode,this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:i}}),readOnly:t},this.initialized=!0;return}try{const B=(r=(await A.mutate({mutation:YA,variables:{id:e},errorPolicy:"all"})).data)==null?void 0:r.transactionClaim;if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(l=B.product.partner)==null?void 0:l.currencyCode,B.transactionOwnerId&&(a.set(B.id,B.transactionOwnerId),P.setMap("transactionOwnerIds",a)),this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:B.transactionOwnerId}}),readOnly:t},this.initialized=!0}catch{throw new G("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(e,t,A){var n,a,i,o;if(!this.initialized||!this.experienceOptions)throw new G("Cannot launch experience: Not initialized.");if(this.experienceOptions.transaction.workflowId){const s=await we(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=s,this.experienceOptions.transaction.workflowState){const l=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(l.layouts).map(d=>d.layout),await g.rehydrateSerializedLayout(l),await Ae(l),this.experienceOptions.reloadedState=l}this.experienceOptions.previewService=A&&A(s),this.experienceOptions.renderableContextService=new Me(this.experienceOptions.layouts),(n=this.experienceOptions.product)!=null&&n.modelUrl&&(this.experienceOptions.modelContainer=(a=this.experienceOptions.previewService)==null?void 0:a.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const r=new le(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}if(e){const r=(P.getMap("transactionOwnerIds")||new Map).get(this.experienceOptions.transaction.id),l=N.getShadowGraphqlClient().mutate({mutation:xA,variables:{workflowId:e,id:this.experienceOptions.transaction.id},context:{transactionOwnerId:r}}),d=we(e);if(await Promise.all([l,d]),this.experienceOptions.workflow=await d,t){const w=JSON.parse(t);this.experienceOptions.layouts=Object.values(w.layouts).map(E=>E.layout),await g.rehydrateSerializedLayout(w),await Ae(w),this.experienceOptions.reloadedState=w}else this.experienceOptions.layouts=qe(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await d),this.experienceOptions.renderableContextService=new Me(this.experienceOptions.layouts),(i=this.experienceOptions.product)!=null&&i.modelUrl&&(this.experienceOptions.modelContainer=(o=this.experienceOptions.previewService)==null?void 0:o.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const B=new le(this,this.experienceOptions);return await B.getWorkflowManager().getInitializationPromise(),B}throw new G("No workflow ID provided.")}getPreviewService(){var e;return(e=this.experienceOptions)==null?void 0:e.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new G("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new G("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}configureUrls(e,t,A){W.setHubUrl(e),W.setServerUrl(t),W.setServicesApiUrl(A)}storeCustomer(e){const t=P.getMap("partnerCustomerIds")||new Map;t.set(e.partner.id,e.id),P.setMap("partnerCustomerIds",t)}async getIntegrationProductById(e){var a,i;const n=(a=(await N.getShadowGraphqlClient().query({query:HA,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:a.integrationProducts;if(!n||n.length===0||!((i=n[0])!=null&&i.id))throw new Error("Integration product not found.");return new We(n[0])}async getIntegrationProductFromExternalIds(e,t){var i;const a=(i=(await N.getShadowGraphqlClient().query({query:RA,variables:{externalProductId:t,externalIntegrationId:e},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:i.integrationProductFromExternalIds;if(!(a!=null&&a.id))throw new Error("Integration product not found.");return new We(a)}async getIntegrationProduct(e){return e.type==="integration"?this.getIntegrationProductById(e.integrationProductId):this.getIntegrationProductFromExternalIds(e.externalIntegrationId,e.externalProductId)}}class fa{getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(e){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(e){}addPoller(e){}addConfirmCallback(e){}addEditedCallback(e){}addElementsCallback(e){}addInformationResultCallback(e){}addInitCallback(e){}addMakingAdjustmentsCallback(e){}addMandatoryCallback(e){}addMetadataCallback(e){}addSelectionCallback(e){}addStepSpecificStorageCallback(e,t){}addStorageCallback(e){}getCommandDispatcher(){return e=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(e){return[]}getSerializedStep(e,t){}getStepSpecificServices(e){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(e){}markUpdateCompleted(e){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(e){}setEditedStatus(e,t){}setInformationResults(e){}setMandatoryFulfilled(e,t){}async setSelectionsAndElements(e,t,A){}toggleDesignConfirmed(){}updateMetadata(e,t){}async updateStorage(e,t){}injectIntoPreviewService(e){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(e){}}var aA=(c=>(c.SelectFrame="SelectFrame",c.SelectImage="SelectImage",c.Position="Position",c))(aA||{});class iA extends j{constructor(e,t){var A;super(e,t),this.frameService=(A=this.manager.getStepSpecificServices(this.getId()))==null?void 0:A.frameService}selectVariant(e){const t=this.manager.getRegionElements(this.step.stepName);return Ie.selectVariant(this.step,e.getResource(),t,this.manager,A=>this.setUpdateState(A))}onFrameDataChanged(e){this.frameService&&this.frameService.onFrameDataChanged(t=>{t&&e(t)})}selectImage(e){return Ie.selectImage(this.step,e,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(e,t,A,n){return n&&n.length>1&&e===void 0?"SelectFrame":t||A||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}}Object.defineProperty(Q,"AssetType",{enumerable:!0,get:()=>g.AssetType}),Object.defineProperty(Q,"BringForwardCommand",{enumerable:!0,get:()=>g.BringForwardCommand}),Object.defineProperty(Q,"BringToBackCommand",{enumerable:!0,get:()=>g.BringToBackCommand}),Object.defineProperty(Q,"BringToFrontCommand",{enumerable:!0,get:()=>g.BringToFrontCommand}),Object.defineProperty(Q,"CanvasCommand",{enumerable:!0,get:()=>g.CanvasCommand}),Object.defineProperty(Q,"CommandContext",{enumerable:!0,get:()=>g.CommandContext}),Object.defineProperty(Q,"CreateElementCommand",{enumerable:!0,get:()=>g.CreateElementCommand}),Object.defineProperty(Q,"CreateLayoutCommand",{enumerable:!0,get:()=>g.CreateLayoutCommand}),Object.defineProperty(Q,"DeleteElementCommand",{enumerable:!0,get:()=>g.DeleteElementCommand}),Object.defineProperty(Q,"FontAlignmentCommand",{enumerable:!0,get:()=>g.FontAlignmentCommand}),Object.defineProperty(Q,"FontColorCommand",{enumerable:!0,get:()=>g.FontColorCommand}),Object.defineProperty(Q,"FontSizeCommand",{enumerable:!0,get:()=>g.FontSizeCommand}),Object.defineProperty(Q,"FontSourceCommand",{enumerable:!0,get:()=>g.FontSourceCommand}),Object.defineProperty(Q,"GroupCommand",{enumerable:!0,get:()=>g.GroupCommand}),Object.defineProperty(Q,"LayoutElementFactory",{enumerable:!0,get:()=>g.LayoutElementFactory}),Object.defineProperty(Q,"LayoutElementType",{enumerable:!0,get:()=>g.LayoutElementType}),Object.defineProperty(Q,"MoveCommand",{enumerable:!0,get:()=>g.MoveCommand}),Object.defineProperty(Q,"ResizeCommand",{enumerable:!0,get:()=>g.ResizeCommand}),Object.defineProperty(Q,"RotateCommand",{enumerable:!0,get:()=>g.RotateCommand}),Object.defineProperty(Q,"SendBackwardsCommand",{enumerable:!0,get:()=>g.SendBackwardsCommand}),Object.defineProperty(Q,"StepAspectType",{enumerable:!0,get:()=>g.StepAspectType}),Object.defineProperty(Q,"StepType",{enumerable:!0,get:()=>g.StepType}),Object.defineProperty(Q,"TextChangeCommand",{enumerable:!0,get:()=>g.TextChangeCommand}),Object.defineProperty(Q,"UnitOfMeasurement",{enumerable:!0,get:()=>g.UnitOfMeasurement}),Object.defineProperty(Q,"dataUrlFromExternalUrl",{enumerable:!0,get:()=>g.dataUrlFromExternalUrl}),Object.defineProperty(Q,"determineCorrectFontSizeAndLines",{enumerable:!0,get:()=>g.determineCorrectFontSizeAndLines}),Object.defineProperty(Q,"findElement",{enumerable:!0,get:()=>g.findElement}),Object.defineProperty(Q,"frameDataCache",{enumerable:!0,get:()=>g.frameDataCache}),Object.defineProperty(Q,"generate",{enumerable:!0,get:()=>g.generate}),Object.defineProperty(Q,"generateSVGWithUnknownColors",{enumerable:!0,get:()=>g.generateSVGWithUnknownColors}),Object.defineProperty(Q,"getAttributesFromArrayBuffer",{enumerable:!0,get:()=>g.getAttributesFromArrayBuffer}),Object.defineProperty(Q,"getAxisAlignedBoundingBox",{enumerable:!0,get:()=>g.getAxisAlignedBoundingBox}),Object.defineProperty(Q,"getFrameData",{enumerable:!0,get:()=>g.getFrameData}),Object.defineProperty(Q,"getSvgElement",{enumerable:!0,get:()=>g.getSvgElement}),Object.defineProperty(Q,"loadFont",{enumerable:!0,get:()=>g.loadFont}),Object.defineProperty(Q,"patternImageDataCache",{enumerable:!0,get:()=>g.patternImageDataCache}),Object.defineProperty(Q,"registerFetchImplementation",{enumerable:!0,get:()=>g.registerFetchImplementation}),Object.defineProperty(Q,"registerWindowImplementation",{enumerable:!0,get:()=>g.registerWindowImplementation}),Object.defineProperty(Q,"rehydrateSerializedLayout",{enumerable:!0,get:()=>g.rehydrateSerializedLayout}),Object.defineProperty(Q,"setCanvasModule",{enumerable:!0,get:()=>g.setCanvasModule}),Q.ArrayInput=ia,Q.AssetNotFoundError=V,Q.CollectionProduct=ye,Q.ConversionDataType=dt,Q.ConversionLocation=Bt,Q.FlowExecutionNodeResult=de,Q.FlowExecutionResult=tA,Q.FlowService=eA,Q.FrameService=Qt,Q.FrameStep=aA,Q.FrameStepHandle=iA,Q.GlobalPropertyHandle=Se,Q.IllustrationStepHandle=Ht,Q.InformationMessageType=ge,Q.InformationStepHandle=Jt,Q.IntegrationProduct=We,Q.IntegrationType=gt,Q.LayoutNotFoundError=b,Q.MaterialStepHandle=Rt,Q.MisconfigurationError=ie,Q.MockWorkflowManager=fa,Q.ModelStepHandle=Ut,Q.ObjectInput=Ve,Q.ObjectInputType=AA,Q.OptionNotFoundError=ae,Q.ParseError=q,Q.PictureStepHandle=Gt,Q.ProductCameraRig=lt,Q.ProductCollection=qt,Q.ProductWorkflow=Be,Q.PromiseCache=Z,Q.PromiseQueue=Ue,Q.QuestionStepHandle=vt,Q.QueueablePromise=Re,Q.ResourceNotFoundError=X,Q.ShapeStepHandle=kt,Q.SpiffCommerceClient=nA,Q.StakeholderType=se,Q.StepHandle=j,Q.TextInput=aa,Q.TextStepHandle=bt,Q.Transform=$t,Q.TransformCollection=Zt,Q.UnhandledBehaviorError=v,Q.Variant=K,Q.WorkflowExperienceEventType=jt,Q.WorkflowExperienceImpl=le,Q.assetService=J,Q.createDesign=zt,Q.designService=Fe,Q.digitalContentStepService=ft,Q.frameStepService=Ie,Q.generateCommands=Kt,Q.generateStateFromDesignInputSteps=Hn,Q.getBoundedOffsets=Ct,Q.getWorkflow=we,Q.getWorkflows=Xe,Q.graphQlManager=N,Q.illustrationStepService=ce,Q.materialStepService=Ge,Q.modelStepService=ve,Q.moduleStepService=Dt,Q.optionService=L,Q.persistenceService=P,Q.pictureStepService=ke,Q.questionStepService=be,Q.shapeStepService=te,Q.shortenUrl=mt,Q.spiffCoreConfiguration=W,Q.stepAspectValuesToDesignInputSteps=Nn,Q.textStepService=O,Q.toast=pt,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})});
|
|
2972
|
+
`,Ae=async c=>{var e;for(const t in c.layouts){const A=c.layouts[t].elements.filter(a=>a.type===g.LayoutElementType.Illustration);for(let a=0;a<A.length;++a){const i=A[a];i.src&&i.svg&&(i.cachedObjectURL=await g.svgObjectURL(i.svg))}const n=c.layouts[t].elements.filter(a=>a.type===g.LayoutElementType.Textbox);for(let a=0;a<n.length;++a){const i=n[a];(e=i.fontData)!=null&&e.assetUrl&&await g.loadFont(i.fontData.assetUrl)}}},ua=async(c,e)=>{var n;const t=await N.getShadowGraphqlClient().query({query:ga(((n=e==null?void 0:e.assets)==null?void 0:n.metadata)||!1),errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:c}}),A=t.data.workflows;if(A===void 0||A.length!==c.length)throw new Error(`Unable to read workflows: ${t.errors??"Length mismatch in response"}`);return A.forEach(a=>{a.steps.forEach(i=>{var o,s,r;delete i.data.__typename,(o=i.option)!=null&&o.id&&((s=i.option.defaultVariant)!=null&&s.asset&&J.cacheAsset(i.option.defaultVariant.asset),i.option.colorProfile&&J.cacheAsset(i.option.colorProfile),(r=i.option.variants)==null||r.forEach(l=>{l.asset&&J.cacheAsset(l.asset),l.displayImage&&J.cacheAsset(l.displayImage),l.thumbnail&&J.cacheAsset(l.thumbnail),l.material&&J.cacheMaterial(l.material)}),Z.set({id:i.option.id},Promise.resolve(i.option)))})}),A},ma=async(c,e)=>{const A=(await e).find(n=>n.id===c);if(!A)throw new Error(`Workflow not found: ${c}`);return A},Xe=async(c,e)=>{const t=c.map(o=>Z.get({id:o,options:e})),A=c.filter((o,s)=>t[s]===void 0);if(A.length===0)return Promise.all(t);const n=ua(A,e),a=A.map(o=>Z.set({id:o,options:e},ma(o,n))),i=t.filter(o=>o!==void 0);return await Promise.all(i.concat(a))},we=async(c,e)=>(await Xe([c],e))[0],Ia=c=>c.sort((e,t)=>e.index-t.index).map(e=>({id:g.generate(),panelId:e.name,name:e.name,index:e.index,createdAt:new Date,updatedAt:new Date,transparentBackground:e.transparentBackground,height:e.height,width:e.width,previewRegion:e.previewRegion,useEditableArea:e.useEditableArea,editableArea:e.editableArea})),qe=(c,e)=>{const t=c.workflowState,A=t?JSON.parse(t):void 0;return A?Object.values(A.layouts).map(n=>n.layout):Ia(e.panels)};class nA{constructor(e){this.updateTransactionState=async t=>{try{return N.getShadowGraphqlClient().mutate({...t,mutation:PA})}catch(A){throw console.error(A),new G("Critical - Unable to synchronize workflow state with server.")}},this.initialized=!1,this.options=e,this.options.applicationKey&&gA(this.options.applicationKey)}getAssetManager(){return J}getCurrencyCode(){if(this.currencyCode===void 0)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!lA())throw new Error("Application key required to use Flow Service.");return new eA}async getIntegration(){return(await N.getShadowGraphqlClient().query({query:Ba,errorPolicy:"all"})).data.currentIntegration}async authenticateBundleFromLocalStorage(e){var n,a;const t=P.getMap("bundleOwnerIds");if(t!=null&&t.has(e))return Promise.resolve({success:!0,stakeholderType:se.Owner});const A=P.getMap("bundlePartnerIds")||new Map;if(A.has(e)){const i=A.get(e),s=(P.getMap("partnerCustomerIds")||new Map).get(i);if(s&&await this.authenticateCustomerId(s)){const l=(a=(n=this.customer)==null?void 0:n.bundleStakeholders)==null?void 0:a.find(d=>{var B;return((B=d.bundle)==null?void 0:B.id)===e});if(l)return Promise.resolve({success:!0,stakeholderType:l.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(e){var l,d,B,w,E,C;const t=N.getShadowGraphqlClient(),A=await t.query({query:la,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:e}});if(!A.data.transactions||A.data.transactions.length===0)throw new Error(`Transaction not found: ${e}`);const n=A.data.transactions[0];if(!((d=(l=n.product)==null?void 0:l.partner)==null?void 0:d.id))throw new Error(`Unable to read transaction: ${e}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=P.getMap("transactionOwnerIds");if(i!=null&&i.has(e))return Promise.resolve({success:!0,stakeholderType:se.Owner});const o=P.getMap("transactionCustomerIds");if(o!=null&&o.has(e)){const h=o.get(e);if(h&&await this.authenticateCustomerId(h)){const u=((w=(B=this.customer)==null?void 0:B.bundleStakeholders)==null?void 0:w.find(F=>{var I,f;return(f=(I=F.bundle)==null?void 0:I.transactions)==null?void 0:f.some(D=>D.id===e)}))||((C=(E=this.customer)==null?void 0:E.stakeholders)==null?void 0:C.find(F=>{var I;return((I=F.transaction)==null?void 0:I.id)===e}));if(u)return Promise.resolve({success:!0,stakeholderType:u.type})}}const r=(await t.query({query:da,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(e){const t=P.getMap("transactionCustomerIds");t!=null&&t.has(e)&&(t.delete(e),P.setMap("transactionCustomerIds",t))}getStakeholderTypeForTransaction(e){var A,n;const t=(n=(A=this.customer)==null?void 0:A.stakeholders)==null?void 0:n.find(a=>{var i;return((i=a.transaction)==null?void 0:i.id)===e});if(t)return t.type}async getOrCreateCustomer(e){var i;this.customer=void 0;const t=N.getShadowGraphqlClient(),n=(await t.query({query:wa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e}})).data.customer;if(!n.id){const s=(i=(await t.mutate({mutation:Ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:e}}})).data)==null?void 0:i.customerCreate;if(!s)throw new Error("Unable to create customer.");return this.storeCustomer(s),this.customer=s,{customer:s,isAuthenticated:!1}}this.storeCustomer(n);const a=await this.authenticateCustomerId(n.id);return{customer:this.customer||n,isAuthenticated:a}}async authenticateCustomerId(e){var o;const t=N.getShadowGraphqlClient(),A=P.getMap("customerTokens");if(!(A!=null&&A.has(e)))return!1;const n=A.get(e);if(!n)return!1;const i=(o=(await t.mutate({mutation:ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data)==null?void 0:o.customerAuthenticate;return i?(this.storeCustomer(i),st(n),this.customer=i,!0):!1}async generateVerificationCode(e){await N.getShadowGraphqlClient().mutate({mutation:Ca,variables:{emailAddress:e}})}async verifyCode(e,t){var a,i;const n=(a=(await N.getShadowGraphqlClient().mutate({mutation:Qa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e,verificationCode:t}})).data)==null?void 0:a.customerVerifyCode;if(n!=null&&n.loginToken){if(!((i=n.partner)!=null&&i.id))throw new Error(`Unable to find customer: ${e}`);const o=P.getMap("customerTokens")||new Map;return o.set(n.id,n.loginToken),P.setMap("customerTokens",o),this.storeCustomer(n),st(n.loginToken),this.customer={...n,loginToken:void 0},!0}return!1}async getNewBundle(e,t,A){var s,r,l;const a=(l=(await N.getShadowGraphqlClient().mutate({mutation:bn(((r=(s=A==null?void 0:A.graphql)==null?void 0:s.productCollection)==null?void 0:r.eagerFetchProducts)||!1),variables:{collectionId:e,initialMetadata:t?Object.entries(t).map((d,B)=>({key:d[0],value:d[1]})):void 0},fetchPolicy:"no-cache"})).data)==null?void 0:l.bundleCreate;if(!(a!=null&&a.id))throw new Error("Unable to create bundle");const i=P.getMap("bundlePartnerIds")||new Map;i.set(a.id,a.partner.id),P.setMap("bundlePartnerIds",i);const o=P.getMap("bundleOwnerIds")||new Map;return o.set(a.id,a.bundleOwnerId),P.setMap("bundleOwnerIds",o),new _t(this,a,void 0,void 0,a.bundleOwnerId)}async getExistingBundle(e,t,A,n){var d,B,w,E,C,h;const a=P.getMap("bundleOwnerIds"),i=a==null?void 0:a.get(e),o=await N.getShadowGraphqlClient().query({query:Un(((B=(d=n==null?void 0:n.graphql)==null?void 0:d.productCollection)==null?void 0:B.eagerFetchProducts)||!1),variables:{id:e},fetchPolicy:"no-cache",context:{bundleOwnerId:i}});if(!((w=o.data)!=null&&w.bundles)||((E=o.data)==null?void 0:E.bundles.length)===0||!((C=o.data)!=null&&C.bundles[0]))throw new Error(`Unable to find bundle: ${e}`);const s=(h=o.data)==null?void 0:h.bundles[0],r=P.getMap("bundlePartnerIds")||new Map;r.set(s.id,s.partner.id),P.setMap("bundlePartnerIds",r);const l=new _t(this,s,t,A,i);return await l.getInitializationPromise(),l}async getBundleStakeholders(){var a;if(!this.customer)throw new Error("Customer not authenticated.");const e=await N.getShadowGraphqlClient().query({query:vn,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((a=e.data)!=null&&a.customers)||e.data.customers.length===0)throw new Error("Unable to find customer.");const A=e.data.customers[0].bundleStakeholders||[],n=P.getMap("bundlePartnerIds")||new Map;return A.forEach(i=>{var o,s;(o=i.bundle)!=null&&o.id&&((s=i.bundle.partner)!=null&&s.id)&&n.set(i.bundle.id,i.bundle.partner.id)}),P.setMap("bundlePartnerIds",n),A}async getWorkflowExperience(e,t,A,n){var d,B,w,E,C;if(!n)return await this.getWorkflowExperienceDeprecated(e,t,A);const a=async()=>{var m,u;const h=N.getShadowGraphqlClient();if(n.type==="transaction"){const{transactionId:F,readOnly:I}=n,f=await h.query({query:ue,variables:{ids:[F]},errorPolicy:"all",fetchPolicy:"no-cache"});if(!((m=f.data)!=null&&m.transactions)||f.data.transactions.length===0)throw new G("Existing transaction not found.");const D=(u=f.data)==null?void 0:u.transactions[0];if(!D.workflowId)throw new G("Existing transaction has no workflow ID.");const p=await we(D.workflowId);if(!D.product)throw new G("Failed to load transaction, product not available.");return{transaction:D,workflow:p,readOnly:I}}if(n.type==="integration"||n.type==="external"){const F=async()=>{const p=n.type==="integration"?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},S=await h.mutate({mutation:wt,variables:{...p,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!S.data||!S.data.transactionCreate)throw new G("Failed to create transaction!");const y=S.data.transactionCreate;if(!y.product)throw new G("Failed to create transaction, product not available.");return y},I=we(n.workflowId,n==null?void 0:n.graphql),[f,D]=await Promise.all([F(),I]);return{transaction:f,workflow:D}}throw new G("No workflow ID provided.")},{transaction:i,workflow:o,readOnly:s}=await a();this.currencyCode=(d=i.product.partner)==null?void 0:d.currencyCode;const r={product:i.product,transaction:i,layouts:[],singleVariantsRenderable:(B=n==null?void 0:n.workflowConfiguration)==null?void 0:B.singleVariantsRenderable,stateMutationFunc:s?async()=>{throw new v("State mutation is forbidden in read only mode!")}:async h=>{const u=(P.getMap("transactionOwnerIds")||new Map).get(i.id)||void 0;return this.updateTransactionState({...h,context:{transactionOwnerId:u}})},readOnly:s,workflow:o};if(n.type==="transaction"&&i.workflowState){const h=JSON.parse(i.workflowState);r.layouts=Object.values(h.layouts).map(m=>m.layout),await g.rehydrateSerializedLayout(h),await Ae(h),r.reloadedState=h}else if(!s&&n.workflowState){const h=JSON.parse(n.workflowState);r.layouts=Object.values(h.layouts).map(m=>m.layout),await g.rehydrateSerializedLayout(h),await Ae(h),r.reloadedState=h}else r.layouts=qe(r.transaction,r.workflow);if(r.renderableContextService=new Me(r.layouts),n.previewService?(r.previewService=n.previewService,(w=r.product)!=null&&w.modelUrl&&(r.modelContainer=r.previewService.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))):(r.previewService=A&&A(o),(E=r.product)!=null&&E.modelUrl&&(r.modelContainer=(C=r.previewService)==null?void 0:C.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))),n.type!=="transaction"){const h=P.getMap("transactionOwnerIds")||new Map;h.set(i.id,i.transactionOwnerId),P.setMap("transactionOwnerIds",h)}else r.isReloadedTransaction=!0;this.initialized=!0,this.experienceOptions=r;const l=new le(this,r);return await l.getWorkflowManager().getInitializationPromise(),n.type!=="transaction"&&this.customer&&await l.attachCustomerDetails({email:this.customer.emailAddress}),l}async getWorkflowExperiences(e,t){if(e.length===0)throw new G("No options provided!");const A=N.getShadowGraphqlClient(),n=async f=>{var y,x;if(f.length===0)return[];const D=f.map(Y=>Y.option.transactionId),p=await A.query({query:ue,variables:{ids:D},errorPolicy:"all",fetchPolicy:"no-cache"}),S=p.data.transactions;if(S.length!==f.length){const Y=((x=(y=p.errors)==null?void 0:y[0])==null?void 0:x.message)||"Unknown error";throw new G(`Not all transactions were found: ${Y}`)}return S.map((Y,H)=>{var R;return{transaction:Y,workflowId:Y.workflowId,readOnly:((R=f.find(T=>T.option.transactionId===Y.id))==null?void 0:R.option.readOnly)??!1,index:f[H].index}})},a=async f=>{var S,y,x;if(f.length===0)return[];const D=await A.mutate({mutation:yA,variables:{inputs:f.map(Y=>({integrationProductId:Y.option.type==="integration"?Y.option.integrationProductId:void 0,externalIntegrationId:Y.option.type==="external"?Y.option.externalIntegrationId:void 0,externalProductId:Y.option.type==="external"?Y.option.externalProductId:void 0,workflowId:Y.option.workflowId,claim:!0}))},errorPolicy:"all",fetchPolicy:"no-cache"}),p=(S=D.data)==null?void 0:S.transactionCreateMany;if(!p||p.length===0){const Y=((x=(y=D.errors)==null?void 0:y[0])==null?void 0:x.message)||"Unknown error";throw new G(`Failed to create transactions: ${Y}`)}return p.map((Y,H)=>({transaction:Y,workflowId:Y.workflowId,readOnly:!1,index:f[H].index}))},i=e.map((f,D)=>({option:f,index:D})),o=i.filter(f=>f.option.type==="transaction"),s=i.filter(f=>f.option.type==="integration"||f.option.type==="external"),r=nt(o,10),l=nt(s,10),d=(await Promise.all([...r.map(n),...l.map(a)])).flat(),B=[...new Set(d.map(f=>f.workflowId))],w=await Xe(B,t),E=new Map(w.map(f=>[f.id,f])),C=P.getMap("transactionOwnerIds")||new Map,h=d.map(async f=>{var T;const{transaction:D,workflowId:p,readOnly:S,index:y}=f,x=E.get(p),Y=e[y];!C.get(D.id)&&D.transactionOwnerId&&C.set(D.id,D.transactionOwnerId);const H=C.get(D.id)||void 0,R={product:D.product,transaction:D,layouts:[],singleVariantsRenderable:(T=Y==null?void 0:Y.workflowConfiguration)==null?void 0:T.singleVariantsRenderable,stateMutationFunc:S?async()=>{throw new v("State mutation is forbidden in read only mode!")}:async k=>this.updateTransactionState({...k,context:{transactionOwnerId:H}}),readOnly:S,workflow:x,isReloadedTransaction:Y.type==="transaction"};if(Y.type==="transaction"&&D.workflowState){const k=JSON.parse(D.workflowState);R.layouts=Object.values(k.layouts).map(z=>z.layout),await g.rehydrateSerializedLayout(k),await Ae(k),R.reloadedState=k}else if(!S&&Y.workflowState){const k=JSON.parse(Y.workflowState);R.layouts=Object.values(k.layouts).map(z=>z.layout),await g.rehydrateSerializedLayout(k),await Ae(k),R.reloadedState=k}else R.layouts=qe(R.transaction,R.workflow);return R.renderableContextService=new Me(R.layouts),R.delayWorkflowStateSync=!0,this.initialized=!0,this.experienceOptions=R,{experienceOptions:R,index:y,options:Y}});P.setMap("transactionOwnerIds",C);const F=(await Promise.all(h)).sort((f,D)=>f.index-D.index).map(async f=>{const{experienceOptions:D,options:p}=f,S=new le(this,D);return await S.getWorkflowManager().getInitializationPromise(),p.type!=="transaction"&&this.customer&&await S.attachCustomerDetails({email:this.customer.emailAddress}),S}),I=await Promise.all(F);return I.forEach(f=>f.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),I}async initFromIntegrationProduct(e){var i;if(e==="")throw new G("No integration product ID provided.");const A=await N.getShadowGraphqlClient().mutate({mutation:wt,variables:{integrationProductId:e,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new G("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new G("Failed to create transaction, product not available.");this.currencyCode=(i=n.product.partner)==null?void 0:i.currencyCode;const a=P.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),P.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async o=>this.updateTransactionState({...o,context:{transactionOwnerId:n.transactionOwnerId}})},this.initialized=!0}async initFromTransaction(e,t=!1){var o,s,r,l;if(e==="")throw new G("No transaction ID provided.");const A=N.getShadowGraphqlClient(),n=async()=>{var w,E;const B=(w=(await A.query({query:ue,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:w.transactions[0];if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(E=B.product.partner)==null?void 0:E.currencyCode,this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async()=>{throw new v("State mutation is forbidden in read only mode!")},readOnly:t},this.initialized=!0};if(t)return await n();const a=P.getMap("transactionOwnerIds")||new Map,i=a.get(e);if(i){const B=(o=(await A.query({query:ue,variables:{ids:[e]},errorPolicy:"all"})).data)==null?void 0:o.transactions[0];if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(s=B.product.partner)==null?void 0:s.currencyCode,this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:i}}),readOnly:t},this.initialized=!0;return}try{const B=(r=(await A.mutate({mutation:YA,variables:{id:e},errorPolicy:"all"})).data)==null?void 0:r.transactionClaim;if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(l=B.product.partner)==null?void 0:l.currencyCode,B.transactionOwnerId&&(a.set(B.id,B.transactionOwnerId),P.setMap("transactionOwnerIds",a)),this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:B.transactionOwnerId}}),readOnly:t},this.initialized=!0}catch{throw new G("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(e,t,A){var n,a,i,o;if(!this.initialized||!this.experienceOptions)throw new G("Cannot launch experience: Not initialized.");if(this.experienceOptions.transaction.workflowId){const s=await we(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=s,this.experienceOptions.transaction.workflowState){const l=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(l.layouts).map(d=>d.layout),await g.rehydrateSerializedLayout(l),await Ae(l),this.experienceOptions.reloadedState=l}this.experienceOptions.previewService=A&&A(s),this.experienceOptions.renderableContextService=new Me(this.experienceOptions.layouts),(n=this.experienceOptions.product)!=null&&n.modelUrl&&(this.experienceOptions.modelContainer=(a=this.experienceOptions.previewService)==null?void 0:a.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const r=new le(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}if(e){const r=(P.getMap("transactionOwnerIds")||new Map).get(this.experienceOptions.transaction.id),l=N.getShadowGraphqlClient().mutate({mutation:xA,variables:{workflowId:e,id:this.experienceOptions.transaction.id},context:{transactionOwnerId:r}}),d=we(e);if(await Promise.all([l,d]),this.experienceOptions.workflow=await d,t){const w=JSON.parse(t);this.experienceOptions.layouts=Object.values(w.layouts).map(E=>E.layout),await g.rehydrateSerializedLayout(w),await Ae(w),this.experienceOptions.reloadedState=w}else this.experienceOptions.layouts=qe(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await d),this.experienceOptions.renderableContextService=new Me(this.experienceOptions.layouts),(i=this.experienceOptions.product)!=null&&i.modelUrl&&(this.experienceOptions.modelContainer=(o=this.experienceOptions.previewService)==null?void 0:o.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const B=new le(this,this.experienceOptions);return await B.getWorkflowManager().getInitializationPromise(),B}throw new G("No workflow ID provided.")}getPreviewService(){var e;return(e=this.experienceOptions)==null?void 0:e.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new G("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new G("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}configureUrls(e,t,A){W.setHubUrl(e),W.setServerUrl(t),W.setServicesApiUrl(A)}storeCustomer(e){const t=P.getMap("partnerCustomerIds")||new Map;t.set(e.partner.id,e.id),P.setMap("partnerCustomerIds",t)}async getIntegrationProductById(e){var a,i;const n=(a=(await N.getShadowGraphqlClient().query({query:HA,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:a.integrationProducts;if(!n||n.length===0||!((i=n[0])!=null&&i.id))throw new Error("Integration product not found.");return new We(n[0])}async getIntegrationProductFromExternalIds(e,t){var i;const a=(i=(await N.getShadowGraphqlClient().query({query:RA,variables:{externalProductId:t,externalIntegrationId:e},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:i.integrationProductFromExternalIds;if(!(a!=null&&a.id))throw new Error("Integration product not found.");return new We(a)}async getIntegrationProduct(e){return e.type==="integration"?this.getIntegrationProductById(e.integrationProductId):this.getIntegrationProductFromExternalIds(e.externalIntegrationId,e.externalProductId)}}class fa{getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(e){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(e){}addPoller(e){}addConfirmCallback(e){}addEditedCallback(e){}addElementsCallback(e){}addInformationResultCallback(e){}addInitCallback(e){}addMakingAdjustmentsCallback(e){}addMandatoryCallback(e){}addMetadataCallback(e){}addSelectionCallback(e){}addStepSpecificStorageCallback(e,t){}addStorageCallback(e){}getCommandDispatcher(){return e=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(e){return[]}getSerializedStep(e,t){}getStepSpecificServices(e){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(e){}markUpdateCompleted(e){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(e){}setEditedStatus(e,t){}setInformationResults(e){}setMandatoryFulfilled(e,t){}async setSelectionsAndElements(e,t,A){}toggleDesignConfirmed(){}updateMetadata(e,t){}async updateStorage(e,t){}injectIntoPreviewService(e){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(e){}}var aA=(c=>(c.SelectFrame="SelectFrame",c.SelectImage="SelectImage",c.Position="Position",c))(aA||{});class iA extends j{constructor(e,t){var A;super(e,t),this.frameService=(A=this.manager.getStepSpecificServices(this.getId()))==null?void 0:A.frameService}selectVariant(e){const t=this.manager.getRegionElements(this.step.stepName);return Ie.selectVariant(this.step,e.getResource(),t,this.manager,A=>this.setUpdateState(A))}onFrameDataChanged(e){this.frameService&&this.frameService.onFrameDataChanged(t=>{t&&e(t)})}selectImage(e){return Ie.selectImage(this.step,e,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(e,t,A,n){return n&&n.length>1&&e===void 0?"SelectFrame":t||A||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}}Object.defineProperty(Q,"AspectType",{enumerable:!0,get:()=>g.AspectType}),Object.defineProperty(Q,"AssetType",{enumerable:!0,get:()=>g.AssetType}),Object.defineProperty(Q,"BringForwardCommand",{enumerable:!0,get:()=>g.BringForwardCommand}),Object.defineProperty(Q,"BringToBackCommand",{enumerable:!0,get:()=>g.BringToBackCommand}),Object.defineProperty(Q,"BringToFrontCommand",{enumerable:!0,get:()=>g.BringToFrontCommand}),Object.defineProperty(Q,"CanvasCommand",{enumerable:!0,get:()=>g.CanvasCommand}),Object.defineProperty(Q,"CommandContext",{enumerable:!0,get:()=>g.CommandContext}),Object.defineProperty(Q,"CreateElementCommand",{enumerable:!0,get:()=>g.CreateElementCommand}),Object.defineProperty(Q,"CreateLayoutCommand",{enumerable:!0,get:()=>g.CreateLayoutCommand}),Object.defineProperty(Q,"DeleteElementCommand",{enumerable:!0,get:()=>g.DeleteElementCommand}),Object.defineProperty(Q,"FontAlignmentCommand",{enumerable:!0,get:()=>g.FontAlignmentCommand}),Object.defineProperty(Q,"FontColorCommand",{enumerable:!0,get:()=>g.FontColorCommand}),Object.defineProperty(Q,"FontSizeCommand",{enumerable:!0,get:()=>g.FontSizeCommand}),Object.defineProperty(Q,"FontSourceCommand",{enumerable:!0,get:()=>g.FontSourceCommand}),Object.defineProperty(Q,"GroupCommand",{enumerable:!0,get:()=>g.GroupCommand}),Object.defineProperty(Q,"LayoutElementFactory",{enumerable:!0,get:()=>g.LayoutElementFactory}),Object.defineProperty(Q,"LayoutElementType",{enumerable:!0,get:()=>g.LayoutElementType}),Object.defineProperty(Q,"MoveCommand",{enumerable:!0,get:()=>g.MoveCommand}),Object.defineProperty(Q,"ResizeCommand",{enumerable:!0,get:()=>g.ResizeCommand}),Object.defineProperty(Q,"RotateCommand",{enumerable:!0,get:()=>g.RotateCommand}),Object.defineProperty(Q,"SendBackwardsCommand",{enumerable:!0,get:()=>g.SendBackwardsCommand}),Object.defineProperty(Q,"StepAspectType",{enumerable:!0,get:()=>g.StepAspectType}),Object.defineProperty(Q,"StepType",{enumerable:!0,get:()=>g.StepType}),Object.defineProperty(Q,"TextChangeCommand",{enumerable:!0,get:()=>g.TextChangeCommand}),Object.defineProperty(Q,"UnitOfMeasurement",{enumerable:!0,get:()=>g.UnitOfMeasurement}),Object.defineProperty(Q,"dataUrlFromExternalUrl",{enumerable:!0,get:()=>g.dataUrlFromExternalUrl}),Object.defineProperty(Q,"determineCorrectFontSizeAndLines",{enumerable:!0,get:()=>g.determineCorrectFontSizeAndLines}),Object.defineProperty(Q,"findElement",{enumerable:!0,get:()=>g.findElement}),Object.defineProperty(Q,"frameDataCache",{enumerable:!0,get:()=>g.frameDataCache}),Object.defineProperty(Q,"generate",{enumerable:!0,get:()=>g.generate}),Object.defineProperty(Q,"generateSVGWithUnknownColors",{enumerable:!0,get:()=>g.generateSVGWithUnknownColors}),Object.defineProperty(Q,"getAttributesFromArrayBuffer",{enumerable:!0,get:()=>g.getAttributesFromArrayBuffer}),Object.defineProperty(Q,"getAxisAlignedBoundingBox",{enumerable:!0,get:()=>g.getAxisAlignedBoundingBox}),Object.defineProperty(Q,"getFrameData",{enumerable:!0,get:()=>g.getFrameData}),Object.defineProperty(Q,"getSvgElement",{enumerable:!0,get:()=>g.getSvgElement}),Object.defineProperty(Q,"loadFont",{enumerable:!0,get:()=>g.loadFont}),Object.defineProperty(Q,"patternImageDataCache",{enumerable:!0,get:()=>g.patternImageDataCache}),Object.defineProperty(Q,"registerFetchImplementation",{enumerable:!0,get:()=>g.registerFetchImplementation}),Object.defineProperty(Q,"registerWindowImplementation",{enumerable:!0,get:()=>g.registerWindowImplementation}),Object.defineProperty(Q,"rehydrateSerializedLayout",{enumerable:!0,get:()=>g.rehydrateSerializedLayout}),Object.defineProperty(Q,"setCanvasModule",{enumerable:!0,get:()=>g.setCanvasModule}),Q.ArrayInput=ia,Q.AssetNotFoundError=V,Q.CollectionProduct=ye,Q.ConversionDataType=dt,Q.ConversionLocation=Bt,Q.FlowExecutionNodeResult=de,Q.FlowExecutionResult=tA,Q.FlowService=eA,Q.FrameService=Qt,Q.FrameStep=aA,Q.FrameStepHandle=iA,Q.GlobalPropertyHandle=Se,Q.IllustrationStepHandle=Ht,Q.InformationMessageType=ge,Q.InformationStepHandle=Jt,Q.IntegrationProduct=We,Q.IntegrationType=gt,Q.LayoutNotFoundError=b,Q.MaterialStepHandle=Rt,Q.MisconfigurationError=ie,Q.MockWorkflowManager=fa,Q.ModelStepHandle=Ut,Q.ObjectInput=Ve,Q.ObjectInputType=AA,Q.OptionNotFoundError=ae,Q.ParseError=q,Q.PictureStepHandle=Gt,Q.ProductCameraRig=lt,Q.ProductCollection=qt,Q.ProductWorkflow=Be,Q.PromiseCache=Z,Q.PromiseQueue=Ue,Q.QuestionStepHandle=vt,Q.QueueablePromise=Re,Q.ResourceNotFoundError=X,Q.ShapeStepHandle=kt,Q.SpiffCommerceClient=nA,Q.StakeholderType=se,Q.StepHandle=j,Q.TextInput=aa,Q.TextStepHandle=bt,Q.Transform=$t,Q.TransformCollection=Zt,Q.UnhandledBehaviorError=v,Q.Variant=K,Q.WorkflowExperienceEventType=jt,Q.WorkflowExperienceImpl=le,Q.assetService=J,Q.createDesign=zt,Q.designService=Fe,Q.digitalContentStepService=ft,Q.frameStepService=Ie,Q.generateCommands=Kt,Q.generateStateFromDesignInputSteps=Hn,Q.getBoundedOffsets=Ct,Q.getWorkflow=we,Q.getWorkflows=Xe,Q.graphQlManager=N,Q.illustrationStepService=ce,Q.materialStepService=Ge,Q.modelStepService=ve,Q.moduleStepService=Dt,Q.optionService=L,Q.persistenceService=P,Q.pictureStepService=ke,Q.questionStepService=be,Q.shapeStepService=te,Q.shortenUrl=mt,Q.spiffCoreConfiguration=W,Q.stepAspectValuesToDesignInputSteps=Nn,Q.textStepService=O,Q.toast=pt,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})});
|