@picked/react 0.0.1-dev.1780464669265 → 0.0.1-dev.1780552550363

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.
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- interface ExperienceProps {
2
+ interface ExperienceSlotProps {
3
3
  /**
4
4
  * Slot name. Maps to the `.picked-slot-<name>` selector that targeted experiences declare.
5
5
  * Named `name` rather than `slot` for parity with the Svelte component, where `slot` is a
@@ -9,19 +9,20 @@ interface ExperienceProps {
9
9
  }
10
10
  /**
11
11
  * Renders the experiences that target the named slot and whose condition is active, ordered by
12
- * placement precedence (`before → prepend → append → after`).
12
+ * placement precedence (`replace → before → prepend → append → after`). An active `replace`
13
+ * experience wins: the first one renders alone, replacing any other matches in the slot.
13
14
  *
14
15
  * Active is read from `conditionResults` via `peek`: a seeded snapshot makes it synchronous for
15
16
  * SSR and the hydration first paint, while a cache miss (standalone, no snapshot) triggers an
16
17
  * asynchronous evaluation in a browser effect whose store write re-renders this component.
17
18
  * Subscribing to `client.conditionResults.store` is what makes those late writes reactive.
18
19
  *
19
- * @param {ExperienceProps} props - The component props.
20
+ * @param {ExperienceSlotProps} props - The component props.
20
21
  * @param {string} props.name - The slot name, mapped to the `.picked-slot-<name>` selector.
21
22
  * @returns {React.JSX.Element} The active experiences for the slot.
22
23
  * @example
23
- * <Experience name="page" />
24
+ * <ExperienceSlot name="page" />
24
25
  */
25
- declare function Experience({ name }: ExperienceProps): React.JSX.Element;
26
- export default Experience;
27
- //# sourceMappingURL=Experience.d.ts.map
26
+ declare function ExperienceSlot({ name }: ExperienceSlotProps): React.JSX.Element;
27
+ export default ExperienceSlot;
28
+ //# sourceMappingURL=ExperienceSlot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExperienceSlot.d.ts","sourceRoot":"","sources":["../../src/experience/ExperienceSlot.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAoB,MAAM,OAAO,CAAA;AAQxC,UAAU,mBAAmB;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAmFD;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,cAAc,CAAC,EAAE,IAAI,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA+CxE;AAED,eAAe,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ import{usePicked as e}from"../hooks/client.js";import{useStoreGlobal as t}from"../hooks/use-store-global.js";import"../hooks/index.js";import n from"./ExperienceHost.js";import{useEffect as r}from"react";import{supportsWindow as i}from"@picked/client";import{evaluateConditionMemo as a,hashRule as o,ruleReferencesAction as s}from"@picked/client/server";import{Fragment as c,jsx as l}from"react/jsx-runtime";var u=[`replace`,`before`,`prepend`,`append`,`after`];function d(e){let t=u.indexOf(e);return t===-1?u.length:t}function f(e,t){let n=e.configStore.getState(),r=n.targetSelectors.find(e=>e.selector===t);return!r||s(n.decisionLogic)?null:{experience:e,placement:r.placement,condition:n.decisionLogic,hash:o(n.decisionLogic)}}function p(){let{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}=globalThis.location;return{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}}function m({name:o}){let s=e(),u=`.picked-slot-${o}`,m=t(s.experiences.listStore);t(s.conditionResults.store);let h=m.map(e=>f(e,u)).filter(e=>e!==null).sort((e,t)=>d(e.placement)-d(t.placement)),g=h.filter(e=>s.conditionResults.peek(e.hash)===!0),_=g.find(e=>e.placement===`replace`),v=_?[_]:g;return r(()=>{if(i())for(let e of h)s.conditionResults.peek(e.hash)===void 0&&a(s,e.condition,{context:{location:p()}})}),l(c,{children:v.map(e=>l(n,{experience:e.experience,client:s},e.experience.id))})}export{m as default};
@@ -3,6 +3,7 @@ import { CreateClientOptions, Picked } from '@picked/client';
3
3
  import { PickedSnapshot } from '@picked/client/server';
4
4
  type PickedProviderProps = {
5
5
  readonly client: Picked;
6
+ readonly snapshot?: PickedSnapshot;
6
7
  readonly children?: React.ReactNode;
7
8
  } | {
8
9
  readonly options: CreateClientOptions;
@@ -13,21 +14,22 @@ type PickedProviderProps = {
13
14
  * Provides a Picked client to descendant components.
14
15
  *
15
16
  * Pass `options` to have the provider create the client and synchronously hydrate it from an
16
- * optional SSR snapshot, so `<Experience>` and the hooks read a fully-populated client during SSR
17
+ * optional SSR snapshot, so `<ExperienceSlot>` and the hooks read a fully-populated client during SSR
17
18
  * and the hydration first paint; a `versionId` mismatch is tolerated (the client reconciles via
18
- * `start()`). Alternatively pass an existing `client` (such as the app's already-running global
19
- * client) to render experiences against it. In the browser the provider calls `client.start()`
19
+ * `start()`). Alternatively pass an existing `client` (such as the app's single global client) to
20
+ * render experiences against it — supply `snapshot` alongside `client` to SSR-seed that shared
21
+ * client rather than creating a second one. In the browser the provider calls `client.start()`
20
22
  * from an effect; `start()` is idempotent, so a client that was already started is left untouched.
21
23
  *
22
- * @param {PickedProviderProps} props - Either `{ client }` or `{ options, snapshot? }`, plus `children`.
24
+ * @param {PickedProviderProps} props - `{ client, snapshot? }` or `{ options, snapshot? }`, plus `children`.
23
25
  * @returns {React.JSX.Element} The provider wrapping its children.
24
26
  * @example
25
27
  * <PickedProvider options={options} snapshot={snapshot}>
26
- * <Experience name="page" />
28
+ * <ExperienceSlot name="page" />
27
29
  * </PickedProvider>
28
30
  * @example
29
- * <PickedProvider client={globalClient}>
30
- * <Experience name="hero-widget" />
31
+ * <PickedProvider client={globalClient} snapshot={snapshot}>
32
+ * <ExperienceSlot name="page" />
31
33
  * </PickedProvider>
32
34
  */
33
35
  declare function PickedProvider(props: PickedProviderProps): React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"PickedProvider.d.ts","sourceRoot":"","sources":["../../src/experience/PickedProvider.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAA4B,MAAM,OAAO,CAAA;AAChD,OAAO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;;;;;;;GAqBG;AACH,iBAAS,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAwBrE;AAED,eAAe,cAAc,CAAA"}
@@ -1 +1 @@
1
- import{ClientProvider as e}from"../context.js";import{useEffect as t,useRef as n}from"react";import{createClient as r,supportsWindow as i}from"@picked/client";import{registerProjectConfig as a}from"@picked/client/server";import{jsx as o}from"react/jsx-runtime";function s(e,t){let n=r(e);if(t){let e=n.session.store.getState().id;a(n,t.projectConfig,{isPreview:!1,sessionId:e}),t.content.forEach(e=>n.registerContent(e)),n.conditionResults.seed(t.conditionResults)}return n}function c(r){let a=n(null);a.current??=`client`in r?r.client:s(r.options,r.snapshot);let c=a.current;return t(()=>{i()&&c.start()},[c]),o(e,{value:c,children:r.children})}export{c as default};
1
+ import{ClientProvider as e}from"../context.js";import{useEffect as t,useState as n}from"react";import{createClient as r,supportsWindow as i}from"@picked/client";import{registerProjectConfig as a}from"@picked/client/server";import{jsx as o}from"react/jsx-runtime";function s(e,t){let n=e.session.store.getState().id;a(e,t.projectConfig,{isPreview:!1,sessionId:n}),t.content.forEach(t=>e.registerContent(t)),e.conditionResults.seed(t.conditionResults)}function c(e,t){let n=r(e);return t&&s(n,t),n}function l(r){let[a]=n(()=>{let e;return`client`in r?(r.snapshot&&s(r.client,r.snapshot),e=r.client):e=c(r.options,r.snapshot),e});return t(()=>{i()&&a.start()},[a]),o(e,{value:a,children:r.children})}export{l as default};
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export { ClientContext, ClientProvider, ExperienceContext, ExperienceProvider } from '../context';
5
5
  export { usePicked, useExperience } from './client';
6
+ export { useStoreGlobal } from './use-store-global';
6
7
  export { useStep, useSetStepContext, useStepContent } from './step';
7
8
  export type { StepContext } from './step';
8
9
  export { useSessionStorage, useLocalStorage } from './storage';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAA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,eAAe,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA"}
@@ -1 +1 @@
1
- import{ClientContext as e,ClientProvider as t,ExperienceContext as n,ExperienceProvider as r}from"../context.js";import{useExperience as i,usePicked as a}from"./client.js";import{useSetStepContext as o,useStep as s,useStepContent as c}from"./step.js";import{useLocalStorage as l,useSessionStorage as u}from"./storage.js";import{getField as d}from"./field.js";import{useFeature as f,useFeatureResult as p}from"./feature.js";import{useAction as m,useActionResult as h}from"./action.js";import{useContent as g}from"./content.js";export{e as ClientContext,t as ClientProvider,n as ExperienceContext,r as ExperienceProvider,d as getField,m as useAction,h as useActionResult,g as useContent,i as useExperience,f as useFeature,p as useFeatureResult,l as useLocalStorage,a as usePicked,u as useSessionStorage,o as useSetStepContext,s as useStep,c as useStepContent};
1
+ import{ClientContext as e,ClientProvider as t,ExperienceContext as n,ExperienceProvider as r}from"../context.js";import{useExperience as i,usePicked as a}from"./client.js";import{useStoreGlobal as o}from"./use-store-global.js";import{useSetStepContext as s,useStep as c,useStepContent as l}from"./step.js";import{useLocalStorage as u,useSessionStorage as d}from"./storage.js";import{getField as f}from"./field.js";import{useFeature as p,useFeatureResult as m}from"./feature.js";import{useAction as h,useActionResult as g}from"./action.js";import{useContent as _}from"./content.js";export{e as ClientContext,t as ClientProvider,n as ExperienceContext,r as ExperienceProvider,f as getField,h as useAction,g as useActionResult,_ as useContent,i as useExperience,p as useFeature,m as useFeatureResult,u as useLocalStorage,a as usePicked,d as useSessionStorage,s as useSetStepContext,c as useStep,l as useStepContent,o as useStoreGlobal};
@@ -1 +1 @@
1
- import{useExperience as e,usePicked as t}from"./client.js";import{useForm as n}from"../form/index.js";import{useStepRouter as r}from"../router/context.js";import{useStoreGlobal as i}from"./use-store-global.js";import{createContext as a,useContext as o,useMemo as s}from"react";import{combine as c}from"effector";var l=a(null);function u(){let e=o(l);if(!e)throw Error(`useStep must be used within a StepContextProvider`);return e}function d(i){let a=e(),o=t(),{activeStep:l}=r(),u=s(()=>l?.key===i,[l?.key,i]),d=s(()=>a.treeStore.map(e=>e.steps.find(e=>e.key===i)??{id:i,key:i,name:``,fieldKeys:[]},{skipVoid:!1}),[a,i]),{form:f,fields:p}=n(i,s(()=>d.map(e=>e.name,{skipVoid:!1}),[d]),s(()=>d.map(e=>e.fieldKeys,{skipVoid:!1}),[d]));return{step:d,fields:p,layoutContentStore:s(()=>c(d,o.contents.indexStore,(e,t)=>e.layoutContentId?t[e.layoutContentId]??null:null,{skipVoid:!1}),[d,o]),isActive:u,isActiveStep:u,form:f}}function f(){let n=e(),r=t();return s(()=>c(n.treeStore,r.contents.indexStore,(e,t)=>{let n=e.steps.find(e=>e.layoutContentId);return n?.layoutContentId?t[n.layoutContentId]??null:null}),[n,r])}function p(){let e=o(l),t=f();return i(e?.layoutContentStore??t)?.data??null}export{l as StepContextProvider,d as useSetStepContext,u as useStep,p as useStepContent};
1
+ import{useExperience as e,usePicked as t}from"./client.js";import{useStoreGlobal as n}from"./use-store-global.js";import{useForm as r}from"../form/index.js";import{useStepRouter as i}from"../router/context.js";import{createContext as a,useContext as o,useMemo as s}from"react";import{combine as c}from"effector";var l=a(null);function u(){let e=o(l);if(!e)throw Error(`useStep must be used within a StepContextProvider`);return e}function d(n){let a=e(),o=t(),{activeStep:l}=i(),u=s(()=>l?.key===n,[l?.key,n]),d=s(()=>a.treeStore.map(e=>e.steps.find(e=>e.key===n)??{id:n,key:n,name:``,fieldKeys:[]},{skipVoid:!1}),[a,n]),{form:f,fields:p}=r(n,s(()=>d.map(e=>e.name,{skipVoid:!1}),[d]),s(()=>d.map(e=>e.fieldKeys,{skipVoid:!1}),[d]));return{step:d,fields:p,layoutContentStore:s(()=>c(d,o.contents.indexStore,(e,t)=>e.layoutContentId?t[e.layoutContentId]??null:null,{skipVoid:!1}),[d,o]),isActive:u,isActiveStep:u,form:f}}function f(){let n=e(),r=t();return s(()=>c(n.treeStore,r.contents.indexStore,(e,t)=>{let n=e.steps.find(e=>e.layoutContentId);return n?.layoutContentId?t[n.layoutContentId]??null:null}),[n,r])}function p(){let e=o(l),t=f();return n(e?.layoutContentStore??t)?.data??null}export{l as StepContextProvider,d as useSetStepContext,u as useStep,p as useStepContent};
@@ -6,13 +6,19 @@ import { Store } from 'effector';
6
6
  * The Picked client is a global singleton (SSR isolation comes from per-request client instances,
7
7
  * not effector `fork()` scopes), so its stores must be read scope-agnostically. Reading them through
8
8
  * scope-aware `useUnit` inside a host `fork()` scope pins the value to the empty fork-time snapshot
9
- * and misses post-`start()` updates, leaving slot components frozen and empty.
9
+ * and misses post-`start()` updates. This is the supported way for host apps to read any Picked
10
+ * client store from React, including `useStep().fields`, whose form-evaluator store is created and
11
+ * written in the global scope after a route-level fork is taken; a `useUnit(fields)` read in that
12
+ * fork sees an empty array, while `useStoreGlobal(fields)` resolves the fields.
10
13
  *
11
14
  * @template T - The store's value type.
12
15
  * @param {Store<T>} store - The Picked client store to read globally.
13
16
  * @returns {T} The store's current global value, re-rendering on global updates.
14
17
  * @example
15
18
  * const experiences = useStoreGlobal(client.experiences.listStore)
19
+ * @example
20
+ * const { fields } = useStep()
21
+ * const resolvedFields = useStoreGlobal(fields)
16
22
  */
17
23
  export declare function useStoreGlobal<T>(store: Store<T>): T;
18
24
  //# sourceMappingURL=use-store-global.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-store-global.d.ts","sourceRoot":"","sources":["../../src/hooks/use-store-global.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAgCrC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAMpD"}
1
+ {"version":3,"file":"use-store-global.d.ts","sourceRoot":"","sources":["../../src/hooks/use-store-global.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAgCrC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAMpD"}
package/dist/index.d.ts CHANGED
@@ -4,5 +4,5 @@
4
4
  export { adaptReactComponent, isValidAdaptedComponent } from './component';
5
5
  export type * from './component';
6
6
  export { default as PickedProvider } from './experience/PickedProvider';
7
- export { default as Experience } from './experience/Experience';
7
+ export { default as ExperienceSlot } from './experience/ExperienceSlot';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAC1E,mBAAmB,aAAa,CAAA;AAChC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAC1E,mBAAmB,aAAa,CAAA;AAChC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAA"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{adaptReactComponent as e,isValidAdaptedComponent as t}from"./component.js";import n from"./experience/PickedProvider.js";import r from"./experience/Experience.js";export{r as Experience,n as PickedProvider,e as adaptReactComponent,t as isValidAdaptedComponent};
1
+ import{adaptReactComponent as e,isValidAdaptedComponent as t}from"./component.js";import n from"./experience/PickedProvider.js";import r from"./experience/ExperienceSlot.js";export{r as ExperienceSlot,n as PickedProvider,e as adaptReactComponent,t as isValidAdaptedComponent};
@@ -1 +1 @@
1
- import{useExperience as e}from"../hooks/client.js";import{StepRouterProvider as t}from"./context.js";import{useStoreGlobal as n}from"../hooks/use-store-global.js";import"../hooks/index.js";import{useCallback as r,useMemo as i,useRef as a,useState as o}from"react";import{supportsWindow as s}from"@picked/client";import{jsx as c}from"react/jsx-runtime";function l({children:l}){let{currentStepStore:u}=e(),d=n(u),f=a(!1),[p,m]=o([]),[h,g]=o(null),_=r(e=>{if(s())m(t=>[...t,e]);else{if(f.current)return;e.key===d?.key&&(g(e),f.current=!0)}},[d?.key]),v=r(e=>{m(t=>t.filter(t=>t!==e))},[]),y=i(()=>h??p.find(e=>e.key===d?.key)??null,[h,p,d?.key]),b=i(()=>({activeStep:y,registerStep:_,unregisterStep:v}),[y,_,v]);return d?.key?c(t,{value:b,children:l}):null}export{l as default};
1
+ import{useExperience as e}from"../hooks/client.js";import{useStoreGlobal as t}from"../hooks/use-store-global.js";import{StepRouterProvider as n}from"./context.js";import"../hooks/index.js";import{useCallback as r,useMemo as i,useRef as a,useState as o}from"react";import{supportsWindow as s}from"@picked/client";import{jsx as c}from"react/jsx-runtime";function l({children:l}){let{currentStepStore:u}=e(),d=t(u),f=a(!1),[p,m]=o([]),[h,g]=o(null),_=r(e=>{if(s())m(t=>[...t,e]);else{if(f.current)return;e.key===d?.key&&(g(e),f.current=!0)}},[d?.key]),v=r(e=>{m(t=>t.filter(t=>t!==e))},[]),y=i(()=>h??p.find(e=>e.key===d?.key)??null,[h,p,d?.key]),b=i(()=>({activeStep:y,registerStep:_,unregisterStep:v}),[y,_,v]);return d?.key?c(n,{value:b,children:l}):null}export{l as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/react",
3
- "version": "0.0.1-dev.1780464669265",
3
+ "version": "0.0.1-dev.1780552550363",
4
4
  "devDependencies": {
5
5
  "@picked/client": "workspace:*",
6
6
  "@repo/eslint-config": "workspace:*",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "module": "./dist/index.js",
87
87
  "peerDependencies": {
88
- "@picked/client": "0.0.1-dev.1780464669265",
88
+ "@picked/client": "0.0.1-dev.1780552550363",
89
89
  "effector": "^23.3.0",
90
90
  "react": "19.2.2",
91
91
  "react-dom": "19.2.2"
@@ -1 +0,0 @@
1
- {"version":3,"file":"Experience.d.ts","sourceRoot":"","sources":["../../src/experience/Experience.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAoB,MAAM,OAAO,CAAA;AAQxC,UAAU,eAAe;IACvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAmFD;;;;;;;;;;;;;;GAcG;AACH,iBAAS,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA2ChE;AAED,eAAe,UAAU,CAAA"}
@@ -1 +0,0 @@
1
- import{usePicked as e}from"../hooks/client.js";import{useStoreGlobal as t}from"../hooks/use-store-global.js";import"../hooks/index.js";import n from"./ExperienceHost.js";import{useEffect as r}from"react";import{supportsWindow as i}from"@picked/client";import{evaluateConditionMemo as a,hashRule as o,ruleReferencesAction as s}from"@picked/client/server";import{Fragment as c,jsx as l}from"react/jsx-runtime";var u=[`before`,`prepend`,`append`,`after`];function d(e){let t=u.indexOf(e);return t===-1?u.length:t}function f(e,t){let n=e.configStore.getState(),r=n.targetSelectors.find(e=>e.selector===t);return!r||r.placement===`replace`||s(n.decisionLogic)?null:{experience:e,placement:r.placement,condition:n.decisionLogic,hash:o(n.decisionLogic)}}function p(){let{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}=globalThis.location;return{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}}function m({name:o}){let s=e(),u=`.picked-slot-${o}`,m=t(s.experiences.listStore);t(s.conditionResults.store);let h=m.map(e=>f(e,u)).filter(e=>e!==null).sort((e,t)=>d(e.placement)-d(t.placement)),g=h.filter(e=>s.conditionResults.peek(e.hash)===!0);return r(()=>{if(i())for(let e of h)s.conditionResults.peek(e.hash)===void 0&&a(s,e.condition,{context:{location:p()}})}),l(c,{children:g.map(e=>l(n,{experience:e.experience,client:s},e.experience.id))})}export{m as default};