@picked/client 0.0.1-dev.1778561735098 → 0.0.1-dev.1780446300503
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/{api-XV6bcv_D.cjs → api-Cqg2gPbP.cjs} +1 -1
- package/dist/{api-Bzb9pR2r.js → api-qqBYwjhT.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dom-observer/index.js +1 -0
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/plugins/web-components/index.js +1 -1
- package/dist/cjs/plugins/window-object/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/image-optimisation-service.md +6 -6
- package/dist/docs/sdk/content-security-policy.md +8 -7
- package/dist/docs/sdk/fields.md +2 -2
- package/dist/docs/workspaces.mdx +1 -1
- package/dist/dom-DjfSrkpp.js +84 -0
- package/dist/dom-sqnnO-CT.cjs +1 -0
- package/dist/esm/index.js +360 -349
- package/dist/esm/plugins/create-experience/index.js +1 -1
- package/dist/esm/plugins/dom-observer/index.js +87 -0
- package/dist/esm/plugins/dynamic-experiences/index.js +3 -163
- package/dist/esm/plugins/experience-browser-storage/index.js +2 -2
- package/dist/esm/plugins/history-browser-storage/index.js +15 -54
- package/dist/esm/plugins/responses-browser-storage/index.js +2 -2
- package/dist/esm/plugins/responses-indexeddb/index.js +1 -1
- package/dist/esm/plugins/single-page-app/index.js +14 -14
- package/dist/esm/plugins/web-components/index.js +2 -2
- package/dist/esm/plugins/window-object/index.js +1 -1
- package/dist/esm/server/index.js +84 -51
- package/dist/experience-instance-B2Xb6TAm.cjs +1 -0
- package/dist/experience-instance-Brph8SaR.js +512 -0
- package/dist/plugin-7rlBjq6t.js +240 -0
- package/dist/plugin-D1FIRtEo.cjs +1 -0
- package/dist/preview-bridge-Cv-Fu5Y1.cjs +1 -0
- package/dist/preview-bridge-eBbZClad.js +33 -0
- package/dist/supports-34OzZK5j.cjs +1 -0
- package/dist/{supports-0XIfd4-R.js → supports-BgjwyijI.js} +11 -4
- package/dist/types/entities/content/content.d.ts +37 -0
- package/dist/types/entities/content/content.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +22 -2
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts +16 -28
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +17 -2
- package/dist/types/entities/step/step.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifecycle/condition-selection.d.ts +98 -0
- package/dist/types/lifecycle/condition-selection.d.ts.map +1 -0
- package/dist/types/lifecycle/lifecycle.d.ts.map +1 -1
- package/dist/types/lifecycle/state-snapshot.d.ts.map +1 -1
- package/dist/types/picked.d.ts +72 -8
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dom-observer/index.d.ts +3 -0
- package/dist/types/plugins/dom-observer/index.d.ts.map +1 -0
- package/dist/types/plugins/dom-observer/plugin.d.ts +50 -0
- package/dist/types/plugins/dom-observer/plugin.d.ts.map +1 -0
- package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +41 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +67 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +0 -16
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/preview-bridge/index.d.ts +14 -0
- package/dist/types/preview-bridge/index.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +8 -0
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +67 -0
- package/dist/types/server/serialize.d.ts.map +1 -0
- package/dist/types/utils/dom.d.ts +0 -27
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/dist/types/utils/supports.d.ts +8 -0
- package/dist/types/utils/supports.d.ts.map +1 -1
- package/package.json +12 -2
- package/dist/experience-instance-B16NqD7y.cjs +0 -1
- package/dist/experience-instance-CZC0uPuv.js +0 -513
- package/dist/supports-Dsjg-82e.cjs +0 -1
- /package/dist/{id-Bv44ilEo.cjs → id-Cg7fVl1O.cjs} +0 -0
- /package/dist/{id-CRqy981z.js → id-n2yrHvNo.js} +0 -0
- /package/dist/{storage-B6lQtc4-.cjs → storage-BXSlLTRa.cjs} +0 -0
- /package/dist/{storage-6Xk0uAxB.js → storage-hOHCCXvP.js} +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Picked } from '../picked';
|
|
2
|
+
import { ContentBlob, ExperienceContentResponse, ProjectConfig } from '../plugins/dynamic-experiences/types';
|
|
3
|
+
/** Subset of `Location` fields that can be injected into the selection context. */
|
|
4
|
+
export interface SerializeLocation {
|
|
5
|
+
href: string;
|
|
6
|
+
pathname: string;
|
|
7
|
+
search: string;
|
|
8
|
+
hostname: string;
|
|
9
|
+
origin: string;
|
|
10
|
+
protocol: string;
|
|
11
|
+
port: string;
|
|
12
|
+
host: string;
|
|
13
|
+
hash: string;
|
|
14
|
+
}
|
|
15
|
+
/** Optional attributes injected into the selection context (currently the URL). */
|
|
16
|
+
export interface SerializeAttributes {
|
|
17
|
+
location?: Partial<SerializeLocation>;
|
|
18
|
+
}
|
|
19
|
+
/** Customer-supplied content fetcher used in place of the runtime API during serialization. */
|
|
20
|
+
export type SerializeGetContent = (experience: {
|
|
21
|
+
id: string;
|
|
22
|
+
key: string;
|
|
23
|
+
}) => Promise<ExperienceContentResponse | null>;
|
|
24
|
+
/** Parameters for {@link serialize}. */
|
|
25
|
+
export interface SerializeParams {
|
|
26
|
+
/** The project config to register and select against. */
|
|
27
|
+
projectConfig: ProjectConfig;
|
|
28
|
+
/** URL attributes injected into the selection context. */
|
|
29
|
+
attributes?: SerializeAttributes;
|
|
30
|
+
/** Optional content fetcher; falls back to the runtime API when omitted. */
|
|
31
|
+
getContent?: SerializeGetContent;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Plain-JSON SSR snapshot produced by {@link serialize} and consumed by the client provider.
|
|
35
|
+
*/
|
|
36
|
+
export interface PickedSnapshot {
|
|
37
|
+
/** The project version the snapshot was selected against, or `null` when unknown. */
|
|
38
|
+
versionId: string | null;
|
|
39
|
+
/** The project config the server selected with (travels for preview parity). */
|
|
40
|
+
projectConfig: ProjectConfig;
|
|
41
|
+
/** Deduped content blobs for the selected experiences. */
|
|
42
|
+
content: ContentBlob[];
|
|
43
|
+
/** Memoized condition-evaluation results keyed by rule hash. */
|
|
44
|
+
conditionResults: Record<string, boolean>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Registers a project config, selects experiences whose conditions pass for the given URL,
|
|
48
|
+
* fetches content for the selected experiences that reference CMS layout content, and returns
|
|
49
|
+
* a plain-JSON snapshot for SSR hydration.
|
|
50
|
+
*
|
|
51
|
+
* Registration is synchronous (no `client.start()`), so the client's stores are populated
|
|
52
|
+
* before selection. Each experience's own condition is evaluated through the memoized
|
|
53
|
+
* evaluator against the injected URL; client-level precondition/condition are not evaluated
|
|
54
|
+
* here in v1. Content is fetched via the `getContent` override when provided, otherwise via
|
|
55
|
+
* the runtime API, and deduped by blob id.
|
|
56
|
+
*
|
|
57
|
+
* @param {Picked} client - The Picked client to register and select with.
|
|
58
|
+
* @param {SerializeParams} params - Project config, URL attributes, and optional content fetcher.
|
|
59
|
+
* @returns {Promise<PickedSnapshot>} The plain-JSON snapshot of config, content, and condition results.
|
|
60
|
+
* @example
|
|
61
|
+
* const snapshot = await serialize(client, {
|
|
62
|
+
* projectConfig,
|
|
63
|
+
* attributes: { location: { pathname: '/promo' } },
|
|
64
|
+
* })
|
|
65
|
+
*/
|
|
66
|
+
export declare function serialize(client: Picked, params: SerializeParams): Promise<PickedSnapshot>;
|
|
67
|
+
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/server/serialize.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAOvC,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,aAAa,EAEd,MAAM,sCAAsC,CAAA;AAE7C,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,mFAAmF;AACnF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAA;CACtC;AAED,+FAA+F;AAC/F,MAAM,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAAE;IAC7C,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;CACZ,KAAK,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;AAE/C,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,aAAa,EAAE,aAAa,CAAA;IAC5B,0DAA0D;IAC1D,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC,4EAA4E;IAC5E,UAAU,CAAC,EAAE,mBAAmB,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,qFAAqF;IACrF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,gFAAgF;IAChF,aAAa,EAAE,aAAa,CAAA;IAC5B,0DAA0D;IAC1D,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C;AAoCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAoDhG"}
|
|
@@ -13,33 +13,6 @@ export declare function getTargetElements(targets: {
|
|
|
13
13
|
export declare function createAppHosts(targets: (ExperienceTarget & {
|
|
14
14
|
elements: HTMLElement[];
|
|
15
15
|
})[], experienceId: string, experienceKey: string): HTMLElement[];
|
|
16
|
-
/**
|
|
17
|
-
* Finds an existing picked-root host that has already claimed the given selector. Returns
|
|
18
|
-
* the claiming experience id, or `undefined` if no host is found.
|
|
19
|
-
*
|
|
20
|
-
* Used by the per-experience initialise effect to detect target conflicts. The lookup
|
|
21
|
-
* intentionally does not filter by placement: only `placement: 'replace'` removes the
|
|
22
|
-
* original target elements, so any prior claim that caused a later experience to find
|
|
23
|
-
* zero matches must itself have been `replace`. Selector alone is sufficient.
|
|
24
|
-
*
|
|
25
|
-
* @param {string} selector - The original target selector to look up.
|
|
26
|
-
* @returns {string | undefined} The claiming experience id, or `undefined`.
|
|
27
|
-
* @example
|
|
28
|
-
* const claimer = findClaimingExperienceId('.host-slot')
|
|
29
|
-
*/
|
|
30
|
-
export declare function findClaimingExperienceId(selector: string): string | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* Finds an existing picked-root host nested inside `element` that was claimed by a different
|
|
33
|
-
* experience. Used to detect destructive `placement: 'replace'` collisions where the
|
|
34
|
-
* replacing experience would otherwise silently remove another experience's host.
|
|
35
|
-
*
|
|
36
|
-
* @param {HTMLElement} element - The element that is about to be replaced.
|
|
37
|
-
* @param {string} ownExperienceId - The current experience id; matching hosts are ignored.
|
|
38
|
-
* @returns {string | undefined} The id of a nested experience's host, if any.
|
|
39
|
-
* @example
|
|
40
|
-
* findDescendantClaim(parentEl, 'B')
|
|
41
|
-
*/
|
|
42
|
-
export declare function findDescendantClaim(element: HTMLElement, ownExperienceId: string): string | undefined;
|
|
43
16
|
export declare function tagTargetElement(element: HTMLElement, experienceId: string): void;
|
|
44
17
|
export declare function isPickedRoot(element: HTMLElement, experienceId?: string): boolean;
|
|
45
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/utils/dom.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAGzE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,CAQ7D;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAMhE;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAa9C;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,QAS1E;AAED,KAAK,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAA;AAOtE,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,EAAE,EACrD,YAAY,EAAE,MAAM,GACnB,CAAC,gBAAgB,GAAG;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,EAAE,CAqBpD;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,CAAC,gBAAgB,GAAG;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,EAAE,EAC3D,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,iBAOtB;
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/utils/dom.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAGzE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,CAQ7D;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAMhE;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAa9C;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,QAS1E;AAED,KAAK,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAA;AAOtE,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,EAAE,EACrD,YAAY,EAAE,MAAM,GACnB,CAAC,gBAAgB,GAAG;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,EAAE,CAqBpD;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,CAAC,gBAAgB,GAAG;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,EAAE,EAC3D,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,iBAOtB;AAGD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAG1E;AAUD,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,WAMvE"}
|
|
@@ -5,6 +5,14 @@ export declare function supportsSessionStorage(): boolean;
|
|
|
5
5
|
export declare function supportsCookies(): boolean;
|
|
6
6
|
export declare function supportsShadowRoot(): boolean;
|
|
7
7
|
export declare function supportsWindow(): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Determines whether the current context runs inside an iframe (its top window differs from itself).
|
|
10
|
+
*
|
|
11
|
+
* @returns {boolean} True when embedded in an iframe.
|
|
12
|
+
* @example
|
|
13
|
+
* isInsideIframe()
|
|
14
|
+
*/
|
|
15
|
+
export declare function isInsideIframe(): boolean;
|
|
8
16
|
export declare function supportsDocument(): boolean;
|
|
9
17
|
export declare function supportsIntersectionObserver(): boolean;
|
|
10
18
|
export declare function supportsWebComponents(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supports.d.ts","sourceRoot":"","sources":["../../../src/utils/supports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"supports.d.ts","sourceRoot":"","sources":["../../../src/utils/supports.ts"],"names":[],"mappings":"AAGA,wBAAgB,gBAAgB,IAAI,OAAO,CAM1C;AAED,wBAAgB,eAAe,IAAI,OAAO,CAMzC;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAM9C;AAED,wBAAgB,sBAAsB,IAAI,OAAO,CAMhD;AAED,wBAAgB,eAAe,IAAI,OAAO,CAMzC;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAU5C;AAED,wBAAgB,cAAc,IAAI,OAAO,CAMxC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAMxC;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAM1C;AAED,wBAAgB,4BAA4B,IAAI,OAAO,CAMtD;AAED,wBAAgB,qBAAqB,IAAI,OAAO,CAM/C;AAED,wBAAgB,wBAAwB,IAAI,OAAO,CAMlD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/client",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.1780446300503",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@withease/factories": "^1.0.5"
|
|
6
6
|
},
|
|
@@ -89,6 +89,12 @@
|
|
|
89
89
|
"require": "./dist/cjs/plugins/dynamic-experiences/index.js",
|
|
90
90
|
"default": "./dist/esm/plugins/dynamic-experiences/index.js"
|
|
91
91
|
},
|
|
92
|
+
"./plugins/dom-observer": {
|
|
93
|
+
"types": "./dist/types/plugins/dom-observer/index.d.ts",
|
|
94
|
+
"import": "./dist/esm/plugins/dom-observer/index.js",
|
|
95
|
+
"require": "./dist/cjs/plugins/dom-observer/index.js",
|
|
96
|
+
"default": "./dist/esm/plugins/dom-observer/index.js"
|
|
97
|
+
},
|
|
92
98
|
"./form": {
|
|
93
99
|
"types": "./dist/types/form/index.d.ts",
|
|
94
100
|
"import": "./dist/esm/form/index.js",
|
|
@@ -160,7 +166,7 @@
|
|
|
160
166
|
"size-limit": [
|
|
161
167
|
{
|
|
162
168
|
"path": "dist/esm/index.js",
|
|
163
|
-
"limit": "
|
|
169
|
+
"limit": "14 kB"
|
|
164
170
|
},
|
|
165
171
|
{
|
|
166
172
|
"path": "dist/esm/server/index.js",
|
|
@@ -198,6 +204,10 @@
|
|
|
198
204
|
"path": "dist/esm/plugins/web-components/index.js",
|
|
199
205
|
"limit": "10 kB"
|
|
200
206
|
},
|
|
207
|
+
{
|
|
208
|
+
"path": "dist/esm/plugins/dom-observer/index.js",
|
|
209
|
+
"limit": "5 kB"
|
|
210
|
+
},
|
|
201
211
|
{
|
|
202
212
|
"path": "dist/esm/form/index.js",
|
|
203
213
|
"limit": "5 kB"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./rules-logic-H6P8xwHF.cjs`);require(`./logger-fbvQC40v.cjs`);const t=require(`./supports-Dsjg-82e.cjs`),n=require(`./id-Bv44ilEo.cjs`);let r=require(`effector`),i=require(`@withease/factories`);function a(e){return!t.d()||!t.r()?[]:Array.from(window.document.querySelectorAll(e)).filter(e=>e instanceof HTMLElement)}var o=`open`;function s(e){if(!t.l())throw Error(`Shadow DOM is not supported in this environment`);return e.attachShadow({mode:o})}function c(){return new Promise((e,n)=>{if(!t.r()){n();return}document.readyState===`loading`?document.addEventListener(`readystatechange`,()=>e(),{once:!0}):e()})}function l(e,t){let n=new MutationObserver(r=>{document.contains(e)||(n.disconnect(),t())});n.observe(document.body,{childList:!0,subtree:!0})}var u=`picked-root`,d=`picked-target`,f=`picked-root`;function p(e,t){return[...e,{selector:`${f}[experience-id="${t}"]`,placement:`replace`}].flatMap(e=>{let n=a(e.selector).filter(e=>!v(e,t)&&!y(e,t));return{...e,elements:n}})}function m(e,t,n){return e.flatMap(e=>e.elements.map(r=>x(r,e,t,n)))}function h(e){if(!t.r()||typeof CSS>`u`||typeof CSS.escape!=`function`)return;let n=CSS.escape(e),r=document.querySelector(`[data-picked-claimed-selector="${n}"]`);if(r instanceof HTMLElement)return r.dataset.pickedExperienceId}function g(e,n){if(!t.r())return;let r=e.querySelector(`[data-picked-experience-id]`);if(r instanceof HTMLElement){let e=r.dataset.pickedExperienceId;if(e&&e!==n)return e}}function _(e,t){e.classList.add(d),e.classList.add(`${d}-${t}`)}function v(e,t){return t?e.classList.contains(`${d}-${t}`):e.classList.contains(`${d}`)}function y(e,t){return t?e.classList.contains(`${u}-${t}`):e.classList.contains(u)}function b(e,t){let n=document.createElement(`div`);return n.style.display=`block`,n.classList.add(u),n.classList.add(`${u}-${e}`),n.classList.add(`${u}-${t}`),n}function x(e,t,n,r){let i,a=b(n,r);if(a.dataset.pickedExperienceId=n,a.dataset.pickedClaimedSelector=t.selector,e instanceof Document)i=e.body.appendChild(a);else{switch(t.placement){case`replace`:e.replaceWith(a);break;case`before`:e.before(a);break;case`after`:e.after(a);break;case`prepend`:e.prepend(a);break;case`append`:e.append(a);break}i=a}return i}function S(e){return e.type===`condition`}function C(e){return e.type===`step`}function w(e){return e.type===`experience`}function T(e){return e.type===`origin`}function E(e){return e.type===`action`}var D=(e,t,n,r,i=new Set)=>i.has(n.id)?[]:(i.add(n.id),C(n)&&!r?[n]:t.filter(e=>e.sourceNodeId===n.id).flatMap(n=>{let r=e.find(e=>e.id===n.destinationNodeId);return r?D(e,t,r,!1,i):[]})),ee=(e,t,n)=>D(e,t,n,!0,new Set),O=(e,t,n,r,i=new Set)=>{if(i.has(n.id))return[-1,-1];i.add(n.id);let a=t.filter(e=>e.sourceNodeId===n.id);if(a.length===0)return[0,0];let o=1/0,s=-1/0;for(let n of a){let r=e.find(e=>e.id===n.destinationNodeId);if(!r)continue;let[a,c]=O(e,t,r,!1,new Set(i));a!==-1&&(o=Math.min(o,a+1),s=Math.max(s,c+1))}return o===1/0?[-1,-1]:[o,s]},k=(e,t,n)=>O(e,t,n,!0,new Set),A=(e,t,n,r=new Set)=>{if(r.has(n.id))return[-1,-1];if(r.add(n.id),n.type===`origin`)return[0,0];let i=t.filter(e=>e.destinationNodeId===n.id);if(i.length===0)return[-1,-1];let a=1/0,o=-1/0;for(let n of i){let i=e.find(e=>e.id===n.sourceNodeId);if(!i)continue;let[s,c]=A(e,t,i,new Set(r));s!==-1&&(a=Math.min(a,s+1),o=Math.max(o,c+1))}return a===1/0?[-1,-1]:[a,o]},te=(e,t,n)=>A(e,t,n,new Set),j=e=>e.find(e=>e.type===`origin`)||null,M=(e,t,n)=>{if(!e)return j(t);let r=n.find(t=>t.sourceNodeId===e.id);return r&&t.find(e=>e.id===r.destinationNodeId)||null};async function N(e,t,n,r){let i=e?`true`:`false`,a=r.find(e=>e.sourceHandle===i&&e.sourceNodeId===t);return n.find(e=>e.id===a?.destinationNodeId)}function P(e,t,n,r){let i=t.find(t=>t.sourceNodeId===e.id&&t.sourceHandle===r);return i?n.find(e=>e.id===i.destinationNodeId)??null:null}var F=(0,r.createDomain)(`experience-instance`),I=(0,i.createFactory)(({client:t,experience:i,target:a,options:o})=>{let c=n.t(`exp-instance`);t.history.seedInstanceFromSnapshot({instanceId:c,experienceId:i.id});let l=(0,r.createEvent)(),u=(0,r.createEvent)(),d=(0,r.createEvent)(),f=(0,r.createEvent)(),p=(0,r.createEvent)(),m=(0,r.createEvent)(),h=i.componentStore,g=F.store(`transitioning`),_=t.history.entriesStore.map(e=>e.filter(e=>e.instanceId===c)),v=_.map(e=>e.filter(e=>C(e.node))),y=_.map(e=>e.at(-1)?.node||null),b=(0,r.combine)(t.steps.listStore,y,(e,t)=>e.find(e=>t&&C(t)&&e.id===t.stepId)||null),x=(0,r.combine)(t.steps.listStore,v,(e,t)=>{let n=t.at(-2);if(!n||!C(n.node))return null;let r=n.node;return e.find(e=>e.id===r.stepId)||null}),D=(0,r.combine)(i.treeStore,y,({nodes:e,edges:t},n)=>n?ee(e,t,n):[]),O=(0,r.combine)(i.treeStore,y,({nodes:e,edges:t},n)=>n?te(e,t,n):[-1,-1]),A=(0,r.combine)(i.treeStore,y,({nodes:e,edges:t},n)=>n?k(e,t,n):[-1,-1]),I=F.store(!1),L=(0,r.createApi)(I,{open:()=>!0,close:()=>!1,toggle:e=>!e,set:(e,t)=>t}),R=(0,r.createEffect)(()=>{t.history.back({instanceId:c})}),z=(0,r.attach)({source:i.treeStore,effect:(e,n)=>{let r=e.nodes.find(e=>C(e)&&e.stepId===n);r&&t.history.push({instanceId:c,experienceId:i.id,node:r})}}),B=(0,r.attach)({source:y,effect:e=>{}}),V=(0,r.attach)({source:i.treeStore,effect:async({nodes:e})=>j(e)}),H=(0,r.attach)({source:i.treeStore,effect:async({nodes:e,edges:t},n)=>{if(T(n))return M(n,e,t)}}),U=(0,r.attach)({source:i.treeStore,effect:async({nodes:n,edges:r,conditions:i},a)=>{if(!S(a))return;let o=i.find(e=>e.id===a.conditionId)?.logic;return o?N(!!await e.t(t,o),a.id,n,r):void 0}}),W=(0,r.attach)({source:{tree:i.treeStore,actions:t.actions.listStore,snapshot:t.stateSnapshotStore},effect:async({tree:e,actions:t,snapshot:n},r)=>{let{nodes:i,edges:a}=e;if(!E(r))return;let o=r.actionKey;if(!o){`${r.id}`;return}let s=t.find(e=>e.key===o)?.action;if(!s||typeof s!=`function`)return`${o}`,P(r,a,i,`false`);try{`${o}`,await s({...n,args:[]},{experience:Z});let e=P(r,a,i,`true`);return e?(`${o}${e.id}`,e):(`${r.id}`,null)}catch{`${o}`;let e=P(r,a,i,`false`);return e?(`${o}${e.id}`,e):(`${r.id}`,null)}}}),G=(0,r.createEffect)(e=>{w(e)&&t.experiences.launch({key:e.experienceKey})}),K=(0,r.attach)({source:[y,i.treeStore],effect:async([e,{nodes:t,edges:n}])=>M(e,t,n)}),q=(0,r.attach)({source:[y,i.treeStore],effect:async([e,{nodes:t,edges:n}])=>M(e,t,n)}),J=(0,r.createEffect)(e=>{t.history.push({instanceId:c,experienceId:i.id,node:e})}),Y=(0,r.attach)({source:i.configStore,effect:async({initializeOpenLogic:n})=>o?.initialiseOpen===void 0?e.n(n)?!!await e.t(t,n):n??!1:o.initialiseOpen}),X=(0,r.combine)(h,t.frameworks.listStore,(e,t)=>{if(!e)return null;let n=t.find(t=>t.name===e.component.frameworkName);return n?{component:e,framework:n}:null},{skipVoid:!1}),Z,ne=(0,r.attach)({source:X,effect:e=>{if(!e)return;if(!a){`${i.id}`;return}let n=s(a);try{e.framework.render(n,e.component.component,t,Z)}catch{}}});Z=Object.freeze({id:c,experienceKey:i.key,experienceId:i.id,experienceName:i.name,configStore:i.configStore,target:a,componentStore:h,componentAndFrameworkStore:X,stateStore:g,isOpenStore:I,open:L.open,close:L.close,toggleOpen:L.toggle,setOpen:L.set,treeStore:i.treeStore,currentNodeStore:y,currentStepStore:b,previousStepStore:x,nextReachableStepNodesStore:D,stepsToOriginStore:O,stepsToLeafStore:A,goToNextStep:u,goToPreviousStep:d,goToStepById:f,stepsHistoryStore:v,mountFx:ne});let Q=(0,r.createEvent)(),$=(0,r.createEvent)();return(0,r.sample)({clock:y,target:Q}),(0,r.sample)({clock:Q,filter:e=>e===null,target:V}),(0,r.sample)({clock:Q,filter:e=>e!==null,target:$}),(0,r.split)({source:$,match:e=>S(e)?`condition`:C(e)?`step`:w(e)?`launchExperience`:T(e)?`origin`:E(e)?`action`:`other`,cases:{origin:H,condition:U,step:B,launchExperience:G,action:W,__:(0,r.createEvent)()}}),(0,r.sample)({clock:[U.doneData,H.doneData,V.doneData,q.doneData,K.doneData,W.doneData],filter:Boolean,target:J}),(0,r.sample)({clock:u,target:q}),(0,r.sample)({clock:u,source:b,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_submit`,step:e,experience:Z}))}),(0,r.sample)({clock:q.done,source:b,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_submit_success`,step:e,experience:Z}))}),(0,r.sample)({clock:q.fail,source:b,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_submit_error`,step:e,experience:Z}))}),(0,r.sample)({clock:d,target:R}),(0,r.sample)({clock:f,target:z}),(0,r.sample)({source:(0,r.combine)([U.pending,H.pending,V.pending,q.pending]),fn:e=>e.some(Boolean)?`transitioning`:`ready`,target:g}),(0,r.sample)({clock:B.doneData,source:b,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_enter`,step:e,experience:Z}))}),(0,r.sample)({clock:m,target:Y}),(0,r.sample)({source:Y.doneData,fn:Boolean,target:I}),(0,r.sample)({source:y,clock:l,filter:e=>e?T(e):!0,target:K}),(0,r.sample)({source:I,filter:Boolean,target:l}),(0,r.sample)({source:I,filter:Boolean,target:t.eventBus.prepend(()=>({type:`experience_open`,experience:Z}))}),(0,r.sample)({source:I,filter:e=>!e,target:t.eventBus.prepend(()=>({type:`experience_close`,experience:Z}))}),(0,r.sample)({clock:p,target:[m]}),p(),Z});function L(e){return(0,i.invoke)(I,e)}var R=(0,i.createFactory)(({client:e})=>{let t=F.store({}),n=(0,r.createEvent)(),i=(0,r.createEvent)(),a=(0,r.createEvent)(),o=(0,r.createApi)(t,{register(e,t){let n=[...e[t.experienceId]??[]];return n.push(t),{...e,[t.experienceId]:n}},unregister(e,t){let n=t.experienceId,r=e[n]?.filter(e=>e!==t);return{...e,[n]:r??[]}}}),s=(0,r.createEffect)(({experience:t,target:n,options:r})=>L({client:e,experience:t,target:n,options:r})),c=(0,r.createEffect)(e=>{o.register(e)}),u=(0,r.createEffect)(e=>{e.target&&l(e.target,()=>{a(e)})}),d=(0,r.createEffect)(e=>{o.unregister(e)}),f=(0,r.createEffect)(async e=>{await e.mountFx()});(0,r.sample)({clock:n,target:s}),(0,r.sample)({clock:a,target:d}),(0,r.sample)({clock:s.doneData,target:[c,u,i]}),(0,r.sample)({clock:s.doneData,target:e.eventBus.prepend(e=>({type:`experience_initialize`,experience:e}))}),(0,r.sample)({clock:i,target:f});function p(e,t,r){n({experience:e,target:t,options:r})}let m=t.map(e=>Object.values(e).flat());function h(e){return m.map(t=>t.filter(t=>t.experienceKey===e),{skipVoid:!1})}function g(e){return t.map(t=>t[e]||[],{skipVoid:!1})}return{spawn:p,getByExperienceKey:h,getByExperienceId:g,listStore:m}});function z(e){return(0,i.invoke)(R,e)}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return y}});
|