@picked/client 0.0.1-dev.1769474304876 → 0.0.1-dev.1769554766412

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.
Files changed (32) hide show
  1. package/dist/cjs/index.js +2 -2
  2. package/dist/cjs/plugins/create-experience/index.js +1 -1
  3. package/dist/cjs/plugins/data-layer/index.js +1 -0
  4. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  5. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  6. package/dist/cjs/server/index.js +1 -1
  7. package/dist/esm/index.js +270 -997
  8. package/dist/esm/plugins/create-experience/index.js +251 -255
  9. package/dist/esm/plugins/data-layer/index.js +202 -0
  10. package/dist/esm/plugins/responses-browser-storage/index.js +23 -25
  11. package/dist/esm/plugins/responses-indexeddb/index.js +49 -67
  12. package/dist/esm/plugins/single-page-app/index.js +3 -3
  13. package/dist/esm/plugins/web-components/index.js +1 -1
  14. package/dist/esm/plugins/window-object/index.js +1 -1
  15. package/dist/esm/server/index.js +19 -19
  16. package/dist/experience-instance-CsMhH0DN.cjs +1 -0
  17. package/dist/{experience-instance-BstMURAM.js → experience-instance-DJCJUe0h.js} +113 -117
  18. package/dist/{supports-BjhuLJ8z.js → supports-DCSoenK6.js} +11 -11
  19. package/dist/types/plugins/data-layer/custom-event.d.ts +5 -0
  20. package/dist/types/plugins/data-layer/custom-event.d.ts.map +1 -0
  21. package/dist/types/plugins/data-layer/index.d.ts +2 -0
  22. package/dist/types/plugins/data-layer/index.d.ts.map +1 -0
  23. package/dist/types/plugins/data-layer/plugin.d.ts +55 -0
  24. package/dist/types/plugins/data-layer/plugin.d.ts.map +1 -0
  25. package/dist/types/plugins/data-layer/utils.d.ts +39 -0
  26. package/dist/types/plugins/data-layer/utils.d.ts.map +1 -0
  27. package/dist/types/utils/events.d.ts +6 -1
  28. package/dist/types/utils/events.d.ts.map +1 -1
  29. package/dist/user-session-DQh0BBTx.cjs +1 -0
  30. package/dist/user-session-XidjAPGf.js +747 -0
  31. package/package.json +11 -5
  32. package/dist/experience-instance-CqwH_Ayg.cjs +0 -1
package/dist/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var q=Object.defineProperty;var K=(t,e,r)=>e in t?q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var h=(t,e,r)=>K(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("effector"),v=require("@withease/factories"),b=require("../experience-instance-CqwH_Ayg.cjs"),E=require("../logger-BsmHUUw1.cjs"),w=require("../storage-YlR83AWP.cjs"),W=require("../id-BKIWbSTy.cjs"),H=require("../object-BbFTsGh3.cjs"),k=require("../supports-YvpQZxbh.cjs"),L=g.createDomain("experience"),G=v.createFactory(({client:t,experience:e})=>{const r=L.store(e),n=g.createApi(r,{merge(a,f){return{...a,...f.experience}}}),s=r.map(a=>({name:a.name,decisionLogic:a.condition??a.decide,targetSelectors:a.targets,initializeOpenLogic:e.initializeOpen})),d=t.components.listStore.map(a=>a.find(f=>f.name===`experience:${e.id}`)||a.find(f=>f.name==="experience"),{skipVoid:!1}),o=r.map(a=>({steps:a.steps,nodes:a.nodes,edges:a.edges,conditionals:a.conditionals})),i=e.actions??[];return{id:e.id,configStore:s,treeStore:o,componentStore:d,actions:i,merge:n.merge}});function Y(t){return v.invoke(G,t)}const J=v.createFactory(({client:t})=>{const e=L.store({}),r=g.createApi(e,{register(o,i){return{...o,[i.id]:i}}});function n(o){const i=e.getState()[o.id];if(i){i.merge({experience:o,strategy:"override"});return}const a=Y({client:t,experience:o});r.register(a)}const s=e.map(o=>Object.values(o));function d(o){return e.map(i=>i[o],{skipVoid:!1})}return{register:n,getById:d,listStore:s}});function Q(t){return v.invoke(J,t)}const X=(t,e)=>{e.register(t)},V=(t,e)=>{const{targetSelectors:r}=e.configStore.getState(),n=b.getTargetElements(r,e.id);n.forEach(({elements:d})=>d.forEach(o=>b.tagTargetElement(o,e.id))),b.createAppHosts(n,e.id).forEach(d=>{t.experienceInstances.spawn(e,d)})},$=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await Z(t,e)&&V(t,e)}))},Z=async(t,e)=>{const{decisionLogic:r,targetSelectors:n}=e.configStore.getState();return b.getTargetElements(n,e.id).length<1||n.length===0?!1:r&&b.isRulesLogic(r)?await b.evaluateRuleLogic(t,r)===!0:!0},ee=(t,e,r)=>{const n=e.name,s=e.setup(t);if(s){const d=r[n]??{};r[n]=Object.freeze({...d,...s})}},te=g.createDomain("component"),re=v.createFactory(({client:t,component:e,name:r})=>{const n=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:n}});function ne(t){return v.invoke(re,t)}const se=v.createFactory(({client:t})=>{const e=te.store({}),r=g.createApi(e,{register(o,i){return{...o,[i.name]:i}}});function n(o,i){e.getState()[o]&&E.logger("warn",`Component '${o}' already registered. Registering again will override the previous registration.`);const f=ne({client:t,name:o,component:i});r.register(f)}const s=e.map(o=>Object.values(o));function d(o){return e.map(i=>i[o],{skipVoid:!1})}return{register:n,getByName:d,listStore:s}});function ie(t){return v.invoke(se,t)}const C=(t,e,r)=>{r.register(t,e)},oe=g.createDomain("framework"),ae=v.createFactory(({client:t})=>{const e=oe.store({}),r=g.createApi(e,{register(o,i){return{...o,[i.name]:i.framework}}});function n(o,i){e.getState()[o]&&E.logger("warn",`Framework '${o}' already registered. Registering again will override the previous registration.`),r.register({name:o,framework:i})}const s=e.map(o=>Object.values(o));function d(o){return e.map(i=>i[o],{skipVoid:!1})}return{register:n,getByName:d,listStore:s}});function ce(t){return v.invoke(ae,t)}const ue=(t,e)=>{e.register(t.name,t)},de=6e3,le=w.createStorageKey("last_ping","global"),pe=t=>`${t}/api/v1/ping`,ge=async t=>{try{const e=Date.now(),r=w.localStore.get(le);let n=0;if(r.isSet()&&(n=r.json()??0),n&&e-n<de)return!0;const s=pe(t.apiUrl),d={projectId:t.projectId,path:window.location.pathname},o=JSON.stringify(d),i={"Content-Type":"application/json"},a=document.getElementById("picked_script"),f=a==null?void 0:a.dataset.verceltoken;f&&(i["x-vercel-protection-bypass"]=f);const F=(await fetch(s,{method:"POST",headers:i,body:o})).ok;return F&&r.set(e),F}catch(e){return E.logger("error",e),!1}};function M(t){const e=typeof window<"u",r={client:t,responses:t.responses.listStore.getState(),fields:t.fields.listStore.getState(),location:e?window.location:void 0,document:e?window.document:void 0,sessionStorage:e?window.sessionStorage:void 0,localStorage:e?window.localStorage:void 0};return Object.freeze(r)}const fe=g.createDomain("predicate"),me=v.createFactory(({client:t})=>{const e=fe.store({}),r=g.createApi(e,{register(i,a){return{...i,[a.name]:{name:a.name,predicate:a.predicate}}}});function n(i,a){e.getState()[i]&&E.logger("warn",`Predicate '${i}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:i,predicate:a}))}const s=e.map(i=>Object.values(i));function d(i){return e.map(a=>{var f;return(f=a[i])==null?void 0:f.predicate},{skipVoid:!1})}function o(i){const a=g.createStore(()=>{},{skipVoid:!1}),f=g.createEffect(async()=>{const S=d(i).getState();if(!S)return;const F=M(t);return(...m)=>S({...F,args:m})});return g.sample({source:{responses:t.responses.listStore,fields:t.fields.listStore},target:f}),g.sample({clock:f.doneData,filter:S=>S!==void 0,target:a}),f(),a}return{register:n,getByName:d,listStore:s,getEvokablePredicate:o}});function ye(t){return v.invoke(me,t)}const he=(t,e,r)=>{r.register(t,e)},O=g.createDomain("feature"),Se=v.createFactory(({client:t})=>{const e=O.store({}),r=O.store([]),n=g.createApi(e,{register(c,u){return{...c,[u.id]:u.feature}}});function s(c,u){e.getState()[c]&&E.logger("warn",`Feature '${c}' already registered. Registering again will override the previous registration.`);const p={id:c,feature:{...u,id:c}};n.register(Object.freeze({id:c,feature:p}))}const d=g.createEffect(async({id:c,key:u,storage:l="local"})=>{const p=w.createStorageKey(`feature:${c}:${u}`,"global"),I=(l==="session"?w.sessionStore:w.localStore).get(p).boolean();return I===null?null:{id:c,key:u,bucket:I,storage:l}}),o=g.createEffect(c=>{if(!c)return null;const u=w.createStorageKey(`feature:${c.id}:${c.key}`,"global");(c.storage==="session"?w.sessionStore:w.localStore).set(u,c.bucket)}),i=new Map,a=g.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:c,resolvedFeaturesStore:u},{id:l,decide:p,key:y})=>{const I=u.find(A=>A.id===l&&A.key===y);if(I)return I;const j=c[l];if(!j)throw new Error(`Feature with id '${l}' not found`);const x=i.get(`${l}:${y}`);if(x!==void 0){const A=await x;return{id:j.id,bucket:A,key:y,storage:j.feature.storage}}const D=p();i.set(`${l}:${y}`,D);const _=await D;return{id:j.id,bucket:_,key:y,storage:j.feature.storage}}});g.sample({clock:n.register,fn:c=>{const{id:u,feature:l}=c;return{id:u,key:l.feature.key,storage:l.feature.storage}},target:d}),g.sample({source:e,clock:a.doneData,fn:(c,u)=>{var j;const{id:l,bucket:p,storage:y}=u,I=(j=c[l])==null?void 0:j.feature.key;return I?{key:I,id:l,bucket:p,storage:y}:null},target:o});const f=g.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:c,resolvedFeaturesStore:u})=>Object.values(c).map(l=>{const p=u.find(y=>y.id===l.id&&y.key===l.feature.key);return p?{id:l.id,name:l.feature.name,key:l.feature.key,getBucket:()=>({id:l.id,bucket:p.bucket}),isResolved:!0}:{id:l.id,name:l.feature.name,key:l.feature.key,getBucket:async()=>await a(l.feature),isResolved:!1}}));g.sample({clock:a.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:c},{id:u,key:l})=>!c.some(y=>y.id===u&&y.key===l),fn:(c,u)=>u,target:t.eventBus.prepend(c=>({type:"feature_decide",feature:c}))}),g.sample({clock:[d.doneData,a.doneData],source:r,fn:(c,u)=>!u||c.some(p=>p.id===u.id&&p.key===u.key)?c:[...c,u],target:r});function S(c){return f.map(u=>u.find(l=>l.id===c))}function F(c){return e.map(u=>u[c],{skipVoid:!1})}function m(c){const u=g.createStore(async()=>{},{skipVoid:!1}),l=g.createEffect(async()=>{const p=S(c).getState();if(p)return async()=>(await p.getBucket()).bucket});return g.sample({source:r,filter:p=>p.some(y=>y.id===c),target:l}),g.sample({clock:l.doneData,filter:p=>p!==void 0,target:u}),l(),u}return{register:s,getById:S,getByName:F,listStore:f,getEvokableFeature:m}});function ve(t){return v.invoke(Se,t)}const ke=(t,e,r)=>{r.register(t,e)},R=g.createDomain("history");function z(t,e){return{id:W.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const we=v.createFactory(()=>{const t=R.store({entries:[]}),e=R.event(),r=R.event(),n=R.event(),s=R.event();t.on(e,(o,i)=>({entries:[...o.entries,z(i.experienceId,i.node)]})),t.on(r,(o,i)=>({entries:[...o.entries.slice(0,-1),z(i.experienceId,i.node)]})),t.on(s,(o,i)=>i);function d(o,i){const a={lastStepIndex:-1,secondLastStepIndex:-1};for(let f=o.length-1;f>=0;f--){const S=o[f],F=S==null?void 0:S.node;if(!(!F||!b.isStepNode(F))&&!(i&&(S==null?void 0:S.experienceId)!==i))if(a.lastStepIndex===-1)a.lastStepIndex=f;else{a.secondLastStepIndex=f;break}}return a}return t.on(n,(o,i)=>{const{secondLastStepIndex:a}=d(o.entries,i.experienceId),f=a!==-1?o.entries.slice(0,a+1):o.entries;return{...o,entries:f}}),{push:e,replace:r,back:n,restore:s,entriesStore:t.map(o=>o.entries)}});function Ie(){return v.invoke(we)}const be=()=>g.createEvent(),Fe=g.createDomain("field"),Ee=v.createFactory(()=>{const t=Fe.store({}),e=g.createApi(t,{register(i,a){return{...i,[a.field.id]:a.field}}});function r(i){e.register({field:i})}function n(i,a){const f=d(i).getState();if(!f)return;const S=Object.assign({},f,{...a});e.register({field:{...S}})}const s=t.map(i=>Object.values(i));function d(i){return t.map(a=>a[i]||null)}function o(i){return t.map(a=>Object.values(a).find(f=>f.name===i)||null)}return{register:r,update:n,getById:d,listStore:s,getByName:o}});function je(){return v.invoke(Ee)}const xe=(t,e)=>{e.register(t)},Re=g.createDomain("action"),Ae=v.createFactory(()=>{const t=Re.store({}),e=g.createApi(t,{register(o,i){return{...o,[i.name]:{name:i.name,action:i.action}}}});function r(o,i){e.register({name:o,action:i})}const n=t.map(o=>Object.values(o));function s(o){return t.map(i=>i[o],{skipVoid:!1})}function d(o){return t.map(i=>{const a=i[o];return a?a.action:void 0},{skipVoid:!1})}return{register:r,getByName:s,listStore:n,getEvokableAction:d}});function Pe(){return v.invoke(Ae)}const Be=(t,e,r)=>{r.register(t,e)};function U(t){return typeof t>"u"||t===null||t===""||Array.isArray(t)&&!t.length}const De=g.createDomain("response"),$e=v.createFactory(({client:t})=>{const e=De.store({}),r=g.createEvent(),n=g.createEvent(),s=g.createApi(e,{register(m,c){return{...m,[c.fieldId]:c.response}},registerBatch(m,c){return{...m,...c}},clear(m,c){const{[c]:u,...l}=m;return l},clearAll(){return{}}});function d(m,c){if(typeof m=="string"){if(c===void 0)throw new Error("Response is required when registering a single field");s.register({fieldId:m,response:c})}else s.registerBatch(m)}async function o(m){const c=[];return await Promise.allSettled(Object.entries(m).map(async([u,l])=>{let p=l;const y=t.fields.getById(u).getState();if(!y){c.push({fieldId:u,userMessage:`Field '${u}' not found`,systemMessage:`No field with ID '${u}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:p});return}if(y.multiple&&(typeof p=="string"||typeof p=="number"||typeof p=="boolean")&&(p=[p]),y.validation&&!H.isEmpty(y.validation)&&!U(p)){const I=await b.evaluateRuleLogic(t,y.validation,{$input:p});if(typeof I=="string"){c.push({fieldId:u,userMessage:I,systemMessage:`Field validation resulted in an error: ${I}.`,value:p});return}if(I===!1){c.push({fieldId:u,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:p});return}}if(y.required&&U(p)){c.push({fieldId:u,userMessage:"This field is required",systemMessage:"Field is required.",value:p});return}if(!y.multiple&&Array.isArray(p)&&p.length>1){c.push({fieldId:u,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:p});return}if(y.options){const I=y.options.map(x=>x.value),j=Array.isArray(p)?p:[p];Array.isArray(p)&&(j.every(x=>I.includes(x))||c.push({fieldId:u,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${I.join(", ")}`,value:p}))}})),{responsesToCommit:m,validationErrors:c}}async function i(m){const{responsesToCommit:c,validationErrors:u}=await o(m);return u.length?{errors:u}:(s.registerBatch(c),{errors:[]})}const a=e.map(m=>m),f=e.map(m=>Object.keys(m).map(u=>({fieldId:u,value:m[u]})));function S(m){const c=t.fields.getById(m),u=e.map(l=>l[m]||null);return g.combine({f:c,r:u},({f:l,r:p})=>p||(l!=null&&l.defaultValue?l.defaultValue:null))}function F(m){const c=t.fields.getByName(m);return g.combine({f:c,s:e},({f:u,s:l})=>{const p=u&&l[u.id]||null;return p||(u!=null&&u.defaultValue?u.defaultValue:null)})}return g.sample({clock:r,target:s.clearAll}),g.sample({clock:n,target:s.clear}),{register:d,clearAll:r,clear:n,commit:i,getResponsesToCommit:o,listStore:f,getAllStore:a,getByFieldId:S,getByFieldName:F}});function Ce(t){return v.invoke($e,t)}const Oe=()=>"0.0.1-dev.1769474304876";function ze(){if(k.supportsDocument()){const t=[document.currentScript,document.getElementById("picked_script"),document.getElementById("picked"),document.getElementById("cvly"),document.getElementById("cvly-x")];for(const e of t)if(e!=null&&e.dataset.api)return e.dataset.api}return"https://api.picked.app"}function Ue(){if(!k.supportsWindow())return{};const t=new URLSearchParams(window.location.search),e={},r=new Set;for(const[s]of t.entries())s.startsWith("picked-")&&r.add(s);for(const s of r){const d=s.replace("picked-","");e[d]=t.getAll(s)}const n=w.createStorageKey("s");if(r.size>0)w.sessionStore.set(n,e);else{const s=w.sessionStore.get(n);if(s)return s.json()||{}}return e}function Le(){if(k.supportsCryptoRandomUUID())return crypto.randomUUID();const t=Date.now().toString(36),e=Math.random().toString(36).substring(2,15),r=Math.random().toString(36).substring(2,15),n=Math.random().toString(36).substring(2,15);return`${t}-${e}-${r}-${n}`}const Ve=w.createStorageKey("session","global"),Me=()=>{const t=w.localStore.get(Ve);let e;t.isSet()&&(e=t.json());const r=s=>t.set({id:s.id,isUser:s.isUser,identifiers:s.identifiers}),n={id:(e==null?void 0:e.id)??Le(),isUser:(e==null?void 0:e.isUser)??void 0,identifiers:(e==null?void 0:e.identifiers)??void 0,setIsUser(s){this.isUser=s,r(this)},setIdentifier(s,d){this.identifiers={...this.identifiers,[s]:d},r(this)},removeIdentifier(s){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([d])=>d!==s)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,r(this))}};return r(n),n},Te=()=>k.supportsLocalStorage()?Me():null;function T(){if(k.supportsWindow())return globalThis.window.pickedConfig}function Ne(){if(!k.supportsWindow())return;const t=T(),e=t==null?void 0:t.organizationId,r=t==null?void 0:t.projectId;return e&&r?{organizationId:e,projectId:r}:void 0}function _e(){if(!k.supportsDocument())return;const t=document.getElementById("picked_script")||document.querySelector("script#picked")||document.getElementById("cvly");if(!t)return;const e=t.dataset.organizationid||t.getAttribute("organization-id"),r=t.dataset.projectid||t.getAttribute("project-id");return e&&r?{organizationId:e,projectId:r}:void 0}function qe(t){const{organizationId:e,projectId:r}=t;if(e&&r)return{organizationId:e,projectId:r};const n=Ne();if(n)return n;const s=_e();if(s)return s;throw new Error(`organizationId and projectId are required. You can provide them via one of:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../user-session-DQh0BBTx.cjs"),d=require("../logger-BsmHUUw1.cjs"),p=require("../experience-instance-CsMhH0DN.cjs"),S=require("effector"),c=require("../supports-YvpQZxbh.cjs"),u=require("../storage-YlR83AWP.cjs"),P=(e,t,i)=>{const n=t.name,o=t.setup(e);if(o){const r=i[n]??{};i[n]=Object.freeze({...r,...o})}},k=()=>S.createEvent(),C=()=>"0.0.1-dev.1769554766412";function b(){if(c.supportsDocument()){const e=[document.currentScript,document.getElementById("picked_script"),document.getElementById("picked"),document.getElementById("cvly"),document.getElementById("cvly-x")];for(const t of e)if(t?.dataset.api)return t.dataset.api}return"https://api.picked.app"}function j(){if(!c.supportsWindow())return{};const e=new URLSearchParams(window.location.search),t={},i=new Set;for(const[o]of e.entries())o.startsWith("picked-")&&i.add(o);for(const o of i){const r=o.replace("picked-","");t[r]=e.getAll(o)}const n=u.createStorageKey("s");if(i.size>0)u.sessionStore.set(n,t);else{const o=u.sessionStore.get(n);if(o)return o.json()||{}}return t}function y(){if(c.supportsWindow())return globalThis.window.pickedConfig}function E(){if(!c.supportsWindow())return;const e=y(),t=e?.organizationId,i=e?.projectId;return t&&i?{organizationId:t,projectId:i}:void 0}function x(){if(!c.supportsDocument())return;const e=document.getElementById("picked_script")||document.querySelector("script#picked")||document.getElementById("cvly");if(!e)return;const t=e.dataset.organizationid||e.getAttribute("organization-id"),i=e.dataset.projectid||e.getAttribute("project-id");return t&&i?{organizationId:t,projectId:i}:void 0}function z(e){const{organizationId:t,projectId:i}=e;if(t&&i)return{organizationId:t,projectId:i};const n=E();if(n)return n;const o=x();if(o)return o;throw new Error(`organizationId and projectId are required. You can provide them via one of:
2
2
  (1) createClient({ organizationId, projectId }) options;
3
3
  (2) window.pickedConfig = { organizationId, projectId };
4
- (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`)}function P(t){return t==null||t===""||Number.isNaN(t)}const Ke={default:(t,e)=>P(t)?String(e??""):String(t),append:(t,e)=>e&&!P(t)?`${t} ${e}`:t,prepend:(t,e)=>e&&!P(t)?`${e} ${t}`:t,upper:t=>typeof t=="string"?t.toUpperCase():t,lower:t=>typeof t=="string"?t.toLowerCase():t,capitalize:t=>typeof t=="string"?t.charAt(0).toUpperCase()+t.slice(1):t,list:t=>{if(!t||typeof t!="object")return t;const e=new Intl.ListFormat("en",{style:"long",type:"conjunction"});if(Array.isArray(t))return e.format(t.map(String));if(t instanceof Map){const r=Array.from(t.entries()).map(([n,s])=>`${n}: ${s}`);return e.format(r)}return t instanceof Set?e.format(Array.from(t).map(String)):t}};function We(t){return typeof t=="object"&&t!==null}function He(t,e){let r=e;for(const n of t.split("."))if(We(r)&&n in r)r=r[n];else return;return typeof r=="function"?r():r}function Ge(t,e){const r=t.split("|").map(d=>d.trim()),n=r.shift()??"";let s=He(n,e);for(const d of r){const[o,...i]=d.split(":"),a=(o==null?void 0:o.trim())??"",f=i.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g,""),S=Ke[a];S&&(s=S(s,f))}return P(s)?"":typeof s=="object"?JSON.stringify(s):String(s)}function Ye(t,e){let r="",n=0;for(;n<t.length;)if(t[n]==="{"&&t[n+1]==="{"){n+=2;let s="";for(;n<t.length;){if(t[n]==="}"&&t[n+1]==="}"){n+=2;break}s+=t[n++]}r+=Ge(s.trim(),e)}else r+=t[n++];return r}class B{constructor(e){h(this,"options");h(this,"isReady",!1);h(this,"project");h(this,"plugins",{});h(this,"eventBus",be());h(this,"organizationId");h(this,"projectId");h(this,"apiUrl");h(this,"session");h(this,"precondition");h(this,"condition");h(this,"searchParams",Ue());h(this,"history",Ie());h(this,"components",ie({client:this}));h(this,"experienceInstances",b.createExperienceInstanceIndex({client:this}));h(this,"experiences",Q({client:this}));h(this,"frameworks",ce({client:this}));h(this,"predicates",ye({client:this}));h(this,"features",ve({client:this}));h(this,"responses",Ce({client:this}));h(this,"fields",je());h(this,"actions",Pe());h(this,"renderString",(e,r)=>{const n=this.responses.listStore.getState().reduce((s,d)=>(s[d.fieldId]=d.value,s),{});return Ye(e,{...r,responses:n})});E.logger("info","Picked client initializing.");const{organizationId:r,projectId:n}=qe(e);this.organizationId=r,this.projectId=n,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||ze(),this.session=Te(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.precondition=e.precondition,this.condition=e.condition,this.eventBus({type:"load",version:Oe()}),E.logger("info","Picked client initialized.")}start(){ge(this),(async()=>{if(!k.supportsDocument())return;let r;typeof this.precondition>"u"?r=!0:typeof this.precondition=="boolean"?r=this.precondition:r=await b.evaluateRuleLogic(this,this.precondition)===!0;let n;r&&(this.condition===void 0?n=!0:typeof this.condition=="boolean"?n=this.condition:n=await b.evaluateRuleLogic(this,this.condition)===!0);const s=r&&n===!0;if(typeof n=="boolean"&&this.session){const d=n;this.session.setIsUser(d),this.eventBus({type:"user_decide",value:d})}this.eventBus({type:"initialize"}),document.body&&s&&$(this),await b.domInteractive(),s&&$(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session&&this.eventBus({type:"session",...this.session})})()}registerFramework(e){ue(e,this.frameworks)}registerComponent(e,r){C(e,r,this.components)}registerPlugin(e){ee(this,e,this.plugins)}registerFeature(e,r){ke(e,r,this.features)}registerPredicate(e,r){he(e,r,this.predicates)}registerField(e){xe(e,this.fields)}registerAction(e,r){Be(e,r,this.actions)}registerExperience(e){e.component&&C(`experience:${e.id}`,e.component,this.components),X(e,this.experiences)}getStateSnapshot(){return M(this)}async launchExperienceById(e){const r=this.experiences.getById(e).getState();if(!r){E.logger("warn",`Experience with id '${e}' not found.`);return}V(this,r)}setupPlugins(){var e;(e=this.options.plugins)==null||e.forEach(r=>{if(Array.isArray(r)){r.forEach(s=>{this.registerPlugin(s)});return}const n=typeof r=="function"?r():r;if(Array.isArray(n)){n.forEach(s=>this.registerPlugin(s));return}this.registerPlugin(n)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([r,n])=>{const s=typeof n=="function"?n():n;this.registerFeature(r,s)}),this.searchParams.feature&&this.searchParams.feature.forEach(r=>{try{const[n,s]=r.split(":");if(!n||!s)return;let d=s;d==="true"&&(d=!0),d==="false"&&(d=!1),this.registerFeature(n,{key:`${d}`,name:n,decide:()=>d,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([r,n])=>{if(typeof n!="function"){E.logger("warn",`Predicate "${r}" is not a function.`);return}this.registerPredicate(r,n)})}setupActions(){const e=this.options.actions;e&&Object.entries(e).forEach(([r,n])=>{if(typeof n!="function"){E.logger("warn",`Action "${r}" is not a function.`);return}this.registerAction(r,n)})}getPluginConfig(e){return this.plugins[e]??{}}}h(B,"logger",E.logger);function N(t){var e;return((e=t.options)==null?void 0:e.some(r=>"condition"in r))??!1}function Je(t){return t.some(e=>e.condition||N(e))}async function Qe(t,e){return e.length===0||!Je(e)?e:(await Promise.all(e.map(async n=>{if(!(n.condition?await b.evaluateRuleLogic(t,n.condition):!0))return null;if(!n.options||!N(n))return n;const o=(await Promise.all(n.options.map(async a=>a.condition?await b.evaluateRuleLogic(t,a.condition)?a:null:a))).filter(a=>a!==null);return o.length===n.options.length?n:o.length===0?null:{...n,options:o}}))).filter(n=>n!==null)}const Xe=t=>{const e=new B(t);return k.bindClient(e),e};exports.evaluateRuleLogic=b.evaluateRuleLogic;exports.isPickedRoot=b.isPickedRoot;exports.createStorageKey=w.createStorageKey;exports.localStore=w.localStore;exports.sessionStore=w.sessionStore;exports.subscribe=w.subscribe;exports.supportsCookies=k.supportsCookies;exports.supportsCryptoRandomUUID=k.supportsCryptoRandomUUID;exports.supportsDocument=k.supportsDocument;exports.supportsHistory=k.supportsHistory;exports.supportsIntersectionObserver=k.supportsIntersectionObserver;exports.supportsLocalStorage=k.supportsLocalStorage;exports.supportsLocation=k.supportsLocation;exports.supportsSessionStorage=k.supportsSessionStorage;exports.supportsShadowRoot=k.supportsShadowRoot;exports.supportsWebComponents=k.supportsWebComponents;exports.supportsWindow=k.supportsWindow;exports.Picked=B;exports.createClient=Xe;exports.getPickedConfig=T;exports.getStepFields=Qe;
4
+ (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`)}function f(e){return e==null||e===""||Number.isNaN(e)}const A={default:(e,t)=>f(e)?String(t??""):String(e),append:(e,t)=>t&&!f(e)?`${e} ${t}`:e,prepend:(e,t)=>t&&!f(e)?`${t} ${e}`:e,upper:e=>typeof e=="string"?e.toUpperCase():e,lower:e=>typeof e=="string"?e.toLowerCase():e,capitalize:e=>typeof e=="string"?e.charAt(0).toUpperCase()+e.slice(1):e,list:e=>{if(!e||typeof e!="object")return e;const t=new Intl.ListFormat("en",{style:"long",type:"conjunction"});if(Array.isArray(e))return t.format(e.map(String));if(e instanceof Map){const i=Array.from(e.entries()).map(([n,o])=>`${n}: ${o}`);return t.format(i)}return e instanceof Set?t.format(Array.from(e).map(String)):e}};function R(e){return typeof e=="object"&&e!==null}function v(e,t){let i=t;for(const n of e.split("."))if(R(i)&&n in i)i=i[n];else return;return typeof i=="function"?i():i}function F(e,t){const i=e.split("|").map(r=>r.trim()),n=i.shift()??"";let o=v(n,t);for(const r of i){const[l,...g]=r.split(":"),a=l?.trim()??"",h=g.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g,""),m=A[a];m&&(o=m(o,h))}return f(o)?"":typeof o=="object"?JSON.stringify(o):String(o)}function B(e,t){let i="",n=0;for(;n<e.length;)if(e[n]==="{"&&e[n+1]==="{"){n+=2;let o="";for(;n<e.length;){if(e[n]==="}"&&e[n+1]==="}"){n+=2;break}o+=e[n++]}i+=F(o.trim(),t)}else i+=e[n++];return i}class I{static logger=d.logger;options;isReady=!1;project;plugins={};eventBus=k();organizationId;projectId;apiUrl;session;precondition;condition;searchParams=j();history=s.createHistory();components=s.createComponentIndex({client:this});experienceInstances=p.createExperienceInstanceIndex({client:this});experiences=s.createExperienceIndex({client:this});frameworks=s.createFrameworkIndex({client:this});predicates=s.createPredicateIndex({client:this});features=s.createFeatureIndex({client:this});responses=s.createResponseIndex({client:this});fields=s.createFieldIndex();actions=s.createActionIndex();constructor(t){d.logger("info","Picked client initializing.");const{organizationId:i,projectId:n}=z(t);this.organizationId=i,this.projectId=n,this.options=Object.freeze(t),this.apiUrl=t.apiUrl||b(),this.session=s.initialiseSession(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.precondition=t.precondition,this.condition=t.condition,this.eventBus({type:"load",version:C()}),d.logger("info","Picked client initialized.")}start(){s.ping(this),(async()=>{if(!c.supportsDocument())return;let i;typeof this.precondition>"u"?i=!0:typeof this.precondition=="boolean"?i=this.precondition:i=await p.evaluateRuleLogic(this,this.precondition)===!0;let n;i&&(this.condition===void 0?n=!0:typeof this.condition=="boolean"?n=this.condition:n=await p.evaluateRuleLogic(this,this.condition)===!0);const o=i&&n===!0;if(typeof n=="boolean"&&this.session){const r=n;this.session.setIsUser(r),this.eventBus({type:"user_decide",is_user:r})}this.eventBus({type:"initialize"}),document.body&&o&&s.initialiseExperiences(this),await p.domInteractive(),o&&s.initialiseExperiences(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session&&this.eventBus({type:"session",...this.session})})()}registerFramework(t){s.setupFramework(t,this.frameworks)}registerComponent(t,i){s.setupComponent(t,i,this.components)}registerPlugin(t){P(this,t,this.plugins)}registerFeature(t,i){s.setupFeature(t,i,this.features)}registerPredicate(t,i){s.setupPredicate(t,i,this.predicates)}registerField(t){s.setupField(t,this.fields)}registerAction(t,i){s.setupAction(t,i,this.actions)}registerExperience(t){t.component&&s.setupComponent(`experience:${t.id}`,t.component,this.components),s.setupExperience(t,this.experiences)}getStateSnapshot(){return s.createStateSnapshot(this)}async launchExperienceById(t){const i=this.experiences.getById(t).getState();if(!i){d.logger("warn",`Experience with id '${t}' not found.`);return}s.initialiseExperience(this,i)}setupPlugins(){this.options.plugins?.forEach(t=>{if(Array.isArray(t)){t.forEach(n=>{this.registerPlugin(n)});return}const i=typeof t=="function"?t():t;if(Array.isArray(i)){i.forEach(n=>this.registerPlugin(n));return}this.registerPlugin(i)})}setupFeatures(){const t=this.options.features;t&&(Object.entries(t).forEach(([i,n])=>{const o=typeof n=="function"?n():n;this.registerFeature(i,o)}),this.searchParams.feature&&this.searchParams.feature.forEach(i=>{try{const[n,o]=i.split(":");if(!n||!o)return;let r=o;r==="true"&&(r=!0),r==="false"&&(r=!1),this.registerFeature(n,{key:`${r}`,name:n,decide:()=>r,storage:"session"})}catch{}}))}setupPredicates(){const t=this.options.predicates;t&&Object.entries(t).forEach(([i,n])=>{if(typeof n!="function"){d.logger("warn",`Predicate "${i}" is not a function.`);return}this.registerPredicate(i,n)})}setupActions(){const t=this.options.actions;t&&Object.entries(t).forEach(([i,n])=>{if(typeof n!="function"){d.logger("warn",`Action "${i}" is not a function.`);return}this.registerAction(i,n)})}getPluginConfig(t){return this.plugins[t]??{}}renderString=(t,i)=>{const n=this.responses.listStore.getState().reduce((o,r)=>(o[r.fieldId]=r.value,o),{});return B(t,{...i,responses:n})}}function w(e){return e.options?.some(t=>"condition"in t)??!1}function L(e){return e.some(t=>t.condition||w(t))}async function U(e,t){return t.length===0||!L(t)?t:(await Promise.all(t.map(async n=>{if(!(n.condition?await p.evaluateRuleLogic(e,n.condition):!0))return null;if(!n.options||!w(n))return n;const l=(await Promise.all(n.options.map(async a=>a.condition?await p.evaluateRuleLogic(e,a.condition)?a:null:a))).filter(a=>a!==null);return l.length===n.options.length?n:l.length===0?null:{...n,options:l}}))).filter(n=>n!==null)}const $=e=>{const t=new I(e);return c.bindClient(t),t};exports.evaluateRuleLogic=p.evaluateRuleLogic;exports.isPickedRoot=p.isPickedRoot;exports.supportsCookies=c.supportsCookies;exports.supportsCryptoRandomUUID=c.supportsCryptoRandomUUID;exports.supportsDocument=c.supportsDocument;exports.supportsHistory=c.supportsHistory;exports.supportsIntersectionObserver=c.supportsIntersectionObserver;exports.supportsLocalStorage=c.supportsLocalStorage;exports.supportsLocation=c.supportsLocation;exports.supportsSessionStorage=c.supportsSessionStorage;exports.supportsShadowRoot=c.supportsShadowRoot;exports.supportsWebComponents=c.supportsWebComponents;exports.supportsWindow=c.supportsWindow;exports.createStorageKey=u.createStorageKey;exports.localStore=u.localStore;exports.sessionStore=u.sessionStore;exports.subscribe=u.subscribe;exports.Picked=I;exports.createClient=$;exports.getPickedConfig=y;exports.getStepFields=U;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../../id-BKIWbSTy.cjs"),a={serialize(i){return JSON.stringify(i)},deserialize(i){return JSON.parse(i)}},m=i=>({name:"create-experience",setup:o=>{i.experiences.forEach(d=>{const n=d.serialize(),s=a.deserialize(n);s.component=d.component,o.registerExperience(s),s.fields.forEach(f=>{o.registerField(f)})})}}),z=(i,o)=>({id:p.generateId("node"),position:[0,0],experience:o,type:"action",action:i.action,addNext(n){if(!n.node)throw new Error("Cannot connect to node");const s=u({sourceNode:this,destinationNode:n.node,sourceNodeHandle:null},o);o.edges.push(s)},onSuccess(n){if(!n.node)throw new Error("Cannot connect to node");const s=u({sourceNode:this,destinationNode:n.node,sourceNodeHandle:"true"},o);o.edges.push(s)},onFail(n){if(!n.node)throw new Error("Cannot connect to node");const s=u({sourceNode:this,destinationNode:n.node,sourceNodeHandle:"false"},o);o.edges.push(s)},serialize(){return a.serialize({id:this.id,type:this.type,action:this.action,position:this.position})}}),b=i=>({id:i.id??p.generateId("step"),label:i.label,fields:i.fields??[],addField(o){var n,s;const d="serialize"in o?o:g(o);return(n=this.fields)!=null&&n.includes(d)||(s=this.fields)==null||s.push(d),d}}),x=(i,o)=>{const d={id:i.id??p.generateId("step"),label:i.label,experience:o,fields:i.fields??[],node:null,nextStep(n){return this.experience.addStep(n,this)},nextConditional(n){return this.experience.addConditional(n,this)},addNextExperience(n){return this.experience.addExperience(n,this)},addField(n){return this.experience.addField(n,this)},serialize(){return a.serialize({id:this.id,label:this.label,fieldIds:this.fields.map(n=>n.id)})}};return h({step:d,type:"step"},o),d},E=()=>[0,0],h=(i,o)=>{const d={id:p.generateId("node"),position:E(),experience:o};if(i.type==="step"){const s={...d,type:"step",connectedStep:i.step,serialize(){return a.serialize({id:this.id,type:this.type,stepId:this.connectedStep.id,position:this.position,label:this.connectedStep.label})}};return s.connectedStep.node=s,s}if(i.type==="conditional"){const s={...d,type:"conditional",connectedConditional:i.conditional,serialize(){return a.serialize({id:this.id,type:this.type,conditionalId:this.connectedConditional.id,position:this.position})}};return s.connectedConditional.node=s,s}return i.type==="experience"?{...d,type:"experience",connectedExperience:i.experience,serialize(){return a.serialize({id:this.id,type:this.type,experienceId:this.connectedExperience.id,position:this.position})}}:{...d,type:"origin",serialize(){return a.serialize({id:this.id,type:this.type,position:this.position})}}},u=(i,o)=>({id:p.generateId("edge"),sourceNode:i.sourceNode,sourceNodeHandle:i.sourceNodeHandle,destinationNode:i.destinationNode,experience:o,serialize(){return a.serialize({id:this.id,sourceNodeHandle:this.sourceNodeHandle??void 0,sourceNodeId:this.sourceNode.id,destinationNodeId:this.destinationNode.id})}}),y=(i,o)=>{const d={id:p.generateId("conditional"),condition:i.condition,node:null,experience:o,addTrue(n){if(!this.node||!n.node)throw new Error("todo no node");const s=u({sourceNode:this.node,destinationNode:n.node,sourceNodeHandle:"true"},this.experience);this.experience.edges.push(s)},addFalse(n){if(!this.node||!n.node)throw new Error("todo no node");const s=u({sourceNode:this.node,destinationNode:n.node,sourceNodeHandle:"false"},this.experience);this.experience.edges.push(s)},serialize(){return a.serialize({id:this.id,condition:this.condition})}};return h({conditional:d,type:"conditional"},o),d},g=i=>{var d;return{id:i.id,name:i.name,type:i.type,label:i.label,placeholder:i.placeholder,description:i.description,helpText:i.helpText,defaultValue:i.defaultValue??null,multiple:i.multiple,validation:i.validation??{},condition:i.condition,required:i.required,options:((d=i.options)==null?void 0:d.map(n=>({...n})))??null,policies:i.policies,serialize(){const n={id:this.id,name:this.name,label:this.label,placeholder:this.placeholder,required:this.required,description:this.description,helpText:this.helpText,validation:this.validation,condition:this.condition,policies:this.policies},s=typeof this.defaultValue=="string"?this.defaultValue:void 0,f=typeof this.defaultValue=="number"?this.defaultValue:void 0,N=typeof this.defaultValue=="boolean"?this.defaultValue:void 0;switch(this.type){case"text":if(this.multiple){let e;if(Array.isArray(this.defaultValue)){e=[];for(const t of this.defaultValue)typeof t=="string"&&e.push(t);e.length===0&&(e=void 0)}return a.serialize({...n,type:"text",multiple:!0,defaultValue:e,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:`${t.value}`,condition:t.condition})):null})}return a.serialize({...n,type:"text",multiple:!1,defaultValue:s,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:`${e.value}`,condition:e.condition})):null});case"number":if(this.multiple){let e;if(Array.isArray(this.defaultValue)){e=[];for(const t of this.defaultValue)typeof t=="number"&&e.push(t);e.length===0&&(e=void 0)}return a.serialize({...n,type:"number",multiple:!0,defaultValue:e,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:Number(t.value),condition:t.condition})):null})}return a.serialize({...n,type:"number",multiple:!1,defaultValue:f,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:Number(e.value),condition:e.condition})):null});case"boolean":if(this.multiple){let e;if(Array.isArray(this.defaultValue)){e=[];for(const t of this.defaultValue)typeof t=="boolean"&&e.push(t);e.length===0&&(e=void 0)}return a.serialize({...n,type:"boolean",multiple:!0,defaultValue:e,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:!!t.value,condition:t.condition})):null})}return a.serialize({...n,type:"boolean",multiple:!1,defaultValue:N,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:!!e.value,condition:e.condition})):null});default:throw new Error("Unsupported field type")}}}},v=i=>{const o=[],d=[],n=[],s=[],f=[],N=i.condition??i.decide;return{id:i.id,component:i.component,name:i.name,initializeOpen:i.initializeOpen,condition:N,decide:i.decide,targets:i.targets,steps:o,nodes:d,edges:n,fields:f,conditionals:s,addStep(e,t){let l=t==null?void 0:t.node;this.nodes.length===0&&(l=h({type:"origin"},this),this.nodes.push(l));const r="serialize"in e?e:x(e,this);if(l){if(!r.node)throw new Error("todo no node");const c=u({sourceNode:l,destinationNode:r.node,sourceNodeHandle:null},this);this.edges.push(c)}return r.fields.length>0&&r.fields.forEach(c=>{this.fields.includes(c)||this.fields.push(c)}),this.steps.includes(r)||(this.steps.push(r),r.node&&this.nodes.push(r.node)),r},addAction(e,t){let l=t==null?void 0:t.node;this.nodes.length===0&&(l=h({type:"origin"},this),this.nodes.push(l));const r="serialize"in e?e:z(e,this);if(l){const c=u({sourceNode:l,destinationNode:r,sourceNodeHandle:null},this);this.edges.push(c)}return this.nodes.push(r),r},addConditional(e,t){let l=t==null?void 0:t.node;this.nodes.length===0&&(l=h({type:"origin"},this),this.nodes.push(l));const r="serialize"in e?e:y(e,this);if(l){if(!r.node)throw new Error("todo no node");const c=u({sourceNode:l,destinationNode:r.node,sourceNodeHandle:null},this);this.edges.push(c)}return this.conditionals.includes(r)||(this.conditionals.push(r),r.node&&this.nodes.push(r.node)),r},addExperience(e,t){let l=t==null?void 0:t.node;this.nodes.length===0&&(l=h({type:"origin"},this),this.nodes.push(l));const r=h({type:"experience",experience:e},this);if(this.nodes.push(r),l){const c=u({sourceNode:l,destinationNode:r,sourceNodeHandle:null},this);this.edges.push(c)}return e},addField(e,t){const l="serialize"in e?e:g(e);return t&&t.fields.push(l),this.fields.includes(l)||this.fields.push(l),l},serialize(){return a.serialize({id:this.id,component:this.component,name:this.name,initializeOpen:this.initializeOpen,condition:this.condition??this.decide,decide:this.decide,targets:this.targets,steps:this.steps.map(e=>a.deserialize(e.serialize())),nodes:this.nodes.map(e=>a.deserialize(e.serialize())),edges:this.edges.map(e=>a.deserialize(e.serialize())),conditionals:this.conditionals.map(e=>a.deserialize(e.serialize())),fields:this.fields.map(e=>a.deserialize(e.serialize()))})}}};exports.createConditional=y;exports.createEdge=u;exports.createExperience=v;exports.createExperiencePlugin=m;exports.createField=g;exports.createNode=h;exports.createStep=b;exports.serialization=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../../id-BKIWbSTy.cjs"),a={serialize(e){return JSON.stringify(e)},deserialize(e){return JSON.parse(e)}},m=e=>({name:"create-experience",setup:o=>{e.experiences.forEach(s=>{const n=s.serialize(),d=a.deserialize(n);d.component=s.component,o.registerExperience(d),d.fields.forEach(N=>{o.registerField(N)})})}}),z=(e,o)=>({id:f.generateId("node"),position:[0,0],experience:o,type:"action",action:e.action,addNext(n){if(!n.node)throw new Error("Cannot connect to node");const d=h({sourceNode:this,destinationNode:n.node,sourceNodeHandle:null},o);o.edges.push(d)},onSuccess(n){if(!n.node)throw new Error("Cannot connect to node");const d=h({sourceNode:this,destinationNode:n.node,sourceNodeHandle:"true"},o);o.edges.push(d)},onFail(n){if(!n.node)throw new Error("Cannot connect to node");const d=h({sourceNode:this,destinationNode:n.node,sourceNodeHandle:"false"},o);o.edges.push(d)},serialize(){return a.serialize({id:this.id,type:this.type,action:this.action,position:this.position})}}),b=e=>({id:e.id??f.generateId("step"),label:e.label,fields:e.fields??[],addField(o){const s="serialize"in o?o:g(o);return this.fields?.includes(s)||this.fields?.push(s),s}}),x=(e,o)=>{const s={id:e.id??f.generateId("step"),label:e.label,experience:o,fields:e.fields??[],node:null,nextStep(n){return this.experience.addStep(n,this)},nextConditional(n){return this.experience.addConditional(n,this)},addNextExperience(n){return this.experience.addExperience(n,this)},addField(n){return this.experience.addField(n,this)},serialize(){return a.serialize({id:this.id,label:this.label,fieldIds:this.fields.map(n=>n.id)})}};return p({step:s,type:"step"},o),s},E=()=>[0,0],p=(e,o)=>{const s={id:f.generateId("node"),position:E(),experience:o};if(e.type==="step"){const d={...s,type:"step",connectedStep:e.step,serialize(){return a.serialize({id:this.id,type:this.type,stepId:this.connectedStep.id,position:this.position,label:this.connectedStep.label})}};return d.connectedStep.node=d,d}if(e.type==="conditional"){const d={...s,type:"conditional",connectedConditional:e.conditional,serialize(){return a.serialize({id:this.id,type:this.type,conditionalId:this.connectedConditional.id,position:this.position})}};return d.connectedConditional.node=d,d}return e.type==="experience"?{...s,type:"experience",connectedExperience:e.experience,serialize(){return a.serialize({id:this.id,type:this.type,experienceId:this.connectedExperience.id,position:this.position})}}:{...s,type:"origin",serialize(){return a.serialize({id:this.id,type:this.type,position:this.position})}}},h=(e,o)=>({id:f.generateId("edge"),sourceNode:e.sourceNode,sourceNodeHandle:e.sourceNodeHandle,destinationNode:e.destinationNode,experience:o,serialize(){return a.serialize({id:this.id,sourceNodeHandle:this.sourceNodeHandle??void 0,sourceNodeId:this.sourceNode.id,destinationNodeId:this.destinationNode.id})}}),y=(e,o)=>{const s={id:f.generateId("conditional"),condition:e.condition,node:null,experience:o,addTrue(n){if(!this.node||!n.node)throw new Error("todo no node");const d=h({sourceNode:this.node,destinationNode:n.node,sourceNodeHandle:"true"},this.experience);this.experience.edges.push(d)},addFalse(n){if(!this.node||!n.node)throw new Error("todo no node");const d=h({sourceNode:this.node,destinationNode:n.node,sourceNodeHandle:"false"},this.experience);this.experience.edges.push(d)},serialize(){return a.serialize({id:this.id,condition:this.condition})}};return p({conditional:s,type:"conditional"},o),s},g=e=>({id:e.id,name:e.name,type:e.type,label:e.label,placeholder:e.placeholder,description:e.description,helpText:e.helpText,defaultValue:e.defaultValue??null,multiple:e.multiple,validation:e.validation??{},condition:e.condition,required:e.required,options:e.options?.map(s=>({...s}))??null,policies:e.policies,serialize(){const s={id:this.id,name:this.name,label:this.label,placeholder:this.placeholder,required:this.required,description:this.description,helpText:this.helpText,validation:this.validation,condition:this.condition,policies:this.policies},n=typeof this.defaultValue=="string"?this.defaultValue:void 0,d=typeof this.defaultValue=="number"?this.defaultValue:void 0,N=typeof this.defaultValue=="boolean"?this.defaultValue:void 0;switch(this.type){case"text":if(this.multiple){let t;if(Array.isArray(this.defaultValue)){t=[];for(const i of this.defaultValue)typeof i=="string"&&t.push(i);t.length===0&&(t=void 0)}return a.serialize({...s,type:"text",multiple:!0,defaultValue:t,options:this.options?this.options.map(i=>({id:i.id,label:i.label,value:`${i.value}`,condition:i.condition})):null})}return a.serialize({...s,type:"text",multiple:!1,defaultValue:n,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:`${t.value}`,condition:t.condition})):null});case"number":if(this.multiple){let t;if(Array.isArray(this.defaultValue)){t=[];for(const i of this.defaultValue)typeof i=="number"&&t.push(i);t.length===0&&(t=void 0)}return a.serialize({...s,type:"number",multiple:!0,defaultValue:t,options:this.options?this.options.map(i=>({id:i.id,label:i.label,value:Number(i.value),condition:i.condition})):null})}return a.serialize({...s,type:"number",multiple:!1,defaultValue:d,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:Number(t.value),condition:t.condition})):null});case"boolean":if(this.multiple){let t;if(Array.isArray(this.defaultValue)){t=[];for(const i of this.defaultValue)typeof i=="boolean"&&t.push(i);t.length===0&&(t=void 0)}return a.serialize({...s,type:"boolean",multiple:!0,defaultValue:t,options:this.options?this.options.map(i=>({id:i.id,label:i.label,value:!!i.value,condition:i.condition})):null})}return a.serialize({...s,type:"boolean",multiple:!1,defaultValue:N,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:!!t.value,condition:t.condition})):null});default:throw new Error("Unsupported field type")}}}),v=e=>{const o=[],s=[],n=[],d=[],N=[],t=e.condition??e.decide;return{id:e.id,component:e.component,name:e.name,initializeOpen:e.initializeOpen,condition:t,decide:e.decide,targets:e.targets,steps:o,nodes:s,edges:n,fields:N,conditionals:d,addStep(i,c){let l=c?.node;this.nodes.length===0&&(l=p({type:"origin"},this),this.nodes.push(l));const r="serialize"in i?i:x(i,this);if(l){if(!r.node)throw new Error("todo no node");const u=h({sourceNode:l,destinationNode:r.node,sourceNodeHandle:null},this);this.edges.push(u)}return r.fields.length>0&&r.fields.forEach(u=>{this.fields.includes(u)||this.fields.push(u)}),this.steps.includes(r)||(this.steps.push(r),r.node&&this.nodes.push(r.node)),r},addAction(i,c){let l=c?.node;this.nodes.length===0&&(l=p({type:"origin"},this),this.nodes.push(l));const r="serialize"in i?i:z(i,this);if(l){const u=h({sourceNode:l,destinationNode:r,sourceNodeHandle:null},this);this.edges.push(u)}return this.nodes.push(r),r},addConditional(i,c){let l=c?.node;this.nodes.length===0&&(l=p({type:"origin"},this),this.nodes.push(l));const r="serialize"in i?i:y(i,this);if(l){if(!r.node)throw new Error("todo no node");const u=h({sourceNode:l,destinationNode:r.node,sourceNodeHandle:null},this);this.edges.push(u)}return this.conditionals.includes(r)||(this.conditionals.push(r),r.node&&this.nodes.push(r.node)),r},addExperience(i,c){let l=c?.node;this.nodes.length===0&&(l=p({type:"origin"},this),this.nodes.push(l));const r=p({type:"experience",experience:i},this);if(this.nodes.push(r),l){const u=h({sourceNode:l,destinationNode:r,sourceNodeHandle:null},this);this.edges.push(u)}return i},addField(i,c){const l="serialize"in i?i:g(i);return c&&c.fields.push(l),this.fields.includes(l)||this.fields.push(l),l},serialize(){return a.serialize({id:this.id,component:this.component,name:this.name,initializeOpen:this.initializeOpen,condition:this.condition??this.decide,decide:this.decide,targets:this.targets,steps:this.steps.map(i=>a.deserialize(i.serialize())),nodes:this.nodes.map(i=>a.deserialize(i.serialize())),edges:this.edges.map(i=>a.deserialize(i.serialize())),conditionals:this.conditionals.map(i=>a.deserialize(i.serialize())),fields:this.fields.map(i=>a.deserialize(i.serialize()))})}}};exports.createConditional=y;exports.createEdge=h;exports.createExperience=v;exports.createExperiencePlugin=m;exports.createField=g;exports.createNode=p;exports.createStep=b;exports.serialization=a;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("effector");require("../../../user-session-DQh0BBTx.cjs");const h=require("../../../supports-YvpQZxbh.cjs");require("../../../experience-instance-CsMhH0DN.cjs");const E=()=>sessionStorage.getItem("cvly_env");function L(e){const t=e?"true":"false";document.cookie=`picked-user=${t}; path=/; max-age=31536000; samesite=none; secure`}function I(e){document.cookie=`picked-id=${e}; path=/; max-age=31536000; samesite=none; secure`}const T=(e,t)=>e.filter(r=>!!t?.fieldIds.includes(r.fieldId)),w=e=>({id:e.experienceId,title:e.configStore.getState().name});function P(e){return e.isResolved}const b=e=>e.flatMap(t=>{if(!P(t))return[];const{bucket:r}=t.getBucket();return[{...t,bucket:r}]}),y=e=>{if("experience"in e&&e.experience){const{experience:t}=e;return{id:t.id,title:t.configStore.getState().name}}if("experienceInstance"in e&&e.experienceInstance){const{experienceInstance:t}=e;return{id:t.experienceId,title:t.configStore.getState().name}}},C=["click","double_click","mouse_over","mouse_out","mouse_down","mouse_up","focus","blur"],D={click:"click",double_click:"dblclick",mouse_over:"mouseover",mouse_out:"mouseout",mouse_down:"mousedown",mouse_up:"mouseup",focus:"focus",blur:"blur"},S=new WeakSet;function F(e,t){if(t&&!S.has(t)){for(const r of C){const c=D[r],o=`data-picked-${r.replace(/_/g,"-")}`;t.addEventListener(c,u=>{const a=u.composedPath().find(d=>d instanceof HTMLElement&&d.hasAttribute(o));if(!a)return;const p=a.getAttribute(o);p&&e(p)},{capture:!0})}S.add(t)}}const R="development",$=["experience_open","experience_close","experience_initialize","initialize","step_enter","step_submit"],g=e=>{const{action:t,organizationId:r,projectId:c,features:s,value:o,step:u,form:l,experience:a,responses:p,exception:d,item:n}=e;return{event:"picked_event",picked_action:t,picked_app:{organizationId:r,projectId:c},picked_feature_list:s?b(s):void 0,picked_environment:R,picked_value:o,picked_step:u,picked_form:l,picked_experience:a,picked_responses:p,picked_exception:d,picked_cvly_env:E()??void 0,picked_item:n}};function x(e){if(!h.supportsWindow())return;const t=[];globalThis.dataLayer=globalThis.dataLayer??t,globalThis.dataLayer.push(e)}const q=({featureWatchList:e=["convincely-enabled"],eventListOverride:t=$,eventMappingOverride:r,mappedProductToPicked:c}={})=>({name:"data-layer-plugin",setup:s=>{if(!h.supportsWindow())return;const{organizationId:o,projectId:u}=s;s.eventBus.watch(n=>{n.type==="user_decide"&&L(n.is_user),n.type==="session"&&I(n.id)});const l=v.attach({source:{responses:s.responses.listStore,features:s.features.listStore},effect:async({responses:n,features:f},i)=>{const{type:m}=i,_=r?.[m]||m,k=g({action:_,organizationId:o,projectId:u,features:b(f),step:"step"in i?i.step:void 0,form:"form"in i?i.form:void 0,exception:"exception"in i?i.exception.reason?.[0]:void 0,experience:y(i),responses:"step"in i?T(n,i.step):void 0,value:"value"in i?i.value:void 0,item:c?c():void 0});return x(k)}}),a=v.createEffect(n=>{if(!("feature"in n))return null;const f=g({action:"picked_decision",organizationId:o,projectId:u,value:`${n.feature.id}:${n.feature.bucket}`});return x(f)}),p=new Set(t);v.sample({clock:s.eventBus,filter:n=>p.has(n.type),target:l});const d=new Set(e);v.sample({source:s.eventBus,filter:n=>n.type==="feature_decide"&&d.has(n.feature.id),target:a}),s.experienceInstances.listStore.watch(n=>{n.forEach(f=>{const i=f.target;i&&F(_=>{const k=g({action:"experience_interaction",organizationId:o,projectId:u,experience:w(f),value:_});x(k)},i.shadowRoot)})})}});exports.dataLayerPlugin=q;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("effector"),c=require("../../../storage-YlR83AWP.cjs"),i=c.createStorageKey("responses","global"),g=(l,s)=>{const o={};return Object.entries(l).forEach(([r,a])=>{var t;const e=s.find(u=>u.id===r);!((t=e==null?void 0:e.policies)!=null&&t.doNotStoreValue)&&(o[r]=a)}),o},f=({storage:l="local"}={})=>({name:"responses-browser-storage-plugin",setup:s=>{const o=l==="local"?c.localStore:c.sessionStore,r=n.createEffect(async()=>{const e=o.get(i).json();if(!e)return null;s.responses.register(e)}),a=n.attach({source:{responses:s.responses.getAllStore,fields:s.fields.listStore},effect:({responses:e,fields:p})=>{const t=g(e,p);o.set(i,t)}});n.sample({source:s.eventBus,filter:e=>e.type==="load",target:r}),n.sample({source:s.responses.getAllStore,target:a})}});exports.responsesBrowserStoragePlugin=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("effector"),c=require("../../../storage-YlR83AWP.cjs"),p=c.createStorageKey("responses","global"),u=(n,e)=>{const o={};return Object.entries(n).forEach(([r,l])=>{!e.find(a=>a.id===r)?.policies?.doNotStoreValue&&(o[r]=l)}),o},g=({storage:n="local"}={})=>({name:"responses-browser-storage-plugin",setup:e=>{const o=n==="local"?c.localStore:c.sessionStore,r=t.createEffect(async()=>{const s=o.get(p).json();if(!s)return null;e.responses.register(s)}),l=t.attach({source:{responses:e.responses.getAllStore,fields:e.fields.listStore},effect:({responses:s,fields:i})=>{const a=u(s,i);o.set(p,a)}});t.sample({source:e.eventBus,filter:s=>s.type==="load",target:r}),t.sample({source:e.responses.getAllStore,target:l})}});exports.responsesBrowserStoragePlugin=g;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("effector"),w="picked";async function p(r){const{storeName:o,version:a=1,keyPath:n="id"}=r;return new Promise((i,t)=>{const s=indexedDB.open(w,a);s.onupgradeneeded=()=>{const e=s.result;e.objectStoreNames.contains(o)||e.createObjectStore(o,n?{keyPath:n}:void 0)},s.onsuccess=()=>i(s.result),s.onerror=()=>{var e;return t(new Error((e=s.error)==null?void 0:e.message))}})}async function g(r,o){return new Promise((a,n)=>{const s=r.transaction(o,"readonly").objectStore(o).getAll();s.onsuccess=()=>a(s.result),s.onerror=()=>{var e;return n(new Error((e=s.error)==null?void 0:e.message))}})}async function x(r,o,a){return new Promise((n,i)=>{const e=r.transaction(o,"readwrite").objectStore(o).put(a);e.onsuccess=()=>n(),e.onerror=()=>{var c;return i(new Error((c=e.error)==null?void 0:c.message))}})}async function y(r,o,a){return new Promise((n,i)=>{const e=r.transaction(o,"readwrite").objectStore(o).delete(a);e.onsuccess=()=>n(),e.onerror=()=>{var c;return i(new Error((c=e.error)==null?void 0:c.message))}})}async function b(r,o){return new Promise((a,n)=>{const s=r.transaction(o,"readwrite").objectStore(o).clear();s.onsuccess=()=>a(),s.onerror=()=>{var e;return n(new Error((e=s.error)==null?void 0:e.message))}})}const d="responses",f={storeName:d,keyPath:"fieldId"},E=()=>({name:"responses-indexdb-plugin",setup:r=>{const o=l.createEffect(async()=>{const t=await p(f),e=(await g(t,d)).reduce((c,{fieldId:u,value:m})=>(c[u]=m,c),{});await r.responses.commit(e)}),a=l.createEffect(async t=>{t.forEach(s=>{p(f).then(e=>{x(e,d,s)}).catch(e=>{console.error("Failed to store response in IndexedDB:",e)})})}),n=l.createEffect(async()=>{const t=await p(f);await b(t,d)}),i=l.createEffect(async t=>{const s=await p(f);await y(s,d,t)});l.sample({source:r.eventBus,filter:t=>t.type==="load",target:o}),l.sample({clock:r.responses.listStore,source:{responses:r.responses.listStore,fields:r.fields.listStore},fn:({responses:t,fields:s})=>{const e=s.filter(c=>{var u;return!((u=c.policies)!=null&&u.doNotStoreValue)});return t.filter(c=>e.some(u=>u.id===c.fieldId))},target:a}),l.sample({clock:r.responses.clearAll,target:n}),l.sample({clock:r.responses.clear,target:i})}});exports.responsesIndexedDBPlugin=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("effector"),w="picked";async function d(r){const{storeName:o,version:c=1,keyPath:n="id"}=r;return new Promise((a,t)=>{const e=indexedDB.open(w,c);e.onupgradeneeded=()=>{const s=e.result;s.objectStoreNames.contains(o)||s.createObjectStore(o,n?{keyPath:n}:void 0)},e.onsuccess=()=>a(e.result),e.onerror=()=>t(new Error(e.error?.message))})}async function g(r,o){return new Promise((c,n)=>{const e=r.transaction(o,"readonly").objectStore(o).getAll();e.onsuccess=()=>c(e.result),e.onerror=()=>n(new Error(e.error?.message))})}async function x(r,o,c){return new Promise((n,a)=>{const s=r.transaction(o,"readwrite").objectStore(o).put(c);s.onsuccess=()=>n(),s.onerror=()=>a(new Error(s.error?.message))})}async function y(r,o,c){return new Promise((n,a)=>{const s=r.transaction(o,"readwrite").objectStore(o).delete(c);s.onsuccess=()=>n(),s.onerror=()=>a(new Error(s.error?.message))})}async function b(r,o){return new Promise((c,n)=>{const e=r.transaction(o,"readwrite").objectStore(o).clear();e.onsuccess=()=>c(),e.onerror=()=>n(new Error(e.error?.message))})}const u="responses",p={storeName:u,keyPath:"fieldId"},E=()=>({name:"responses-indexdb-plugin",setup:r=>{const o=i.createEffect(async()=>{const t=await d(p),s=(await g(t,u)).reduce((l,{fieldId:f,value:m})=>(l[f]=m,l),{});await r.responses.commit(s)}),c=i.createEffect(async t=>{t.forEach(e=>{d(p).then(s=>{x(s,u,e)}).catch(s=>{console.error("Failed to store response in IndexedDB:",s)})})}),n=i.createEffect(async()=>{const t=await d(p);await b(t,u)}),a=i.createEffect(async t=>{const e=await d(p);await y(e,u,t)});i.sample({source:r.eventBus,filter:t=>t.type==="load",target:o}),i.sample({clock:r.responses.listStore,source:{responses:r.responses.listStore,fields:r.fields.listStore},fn:({responses:t,fields:e})=>{const s=e.filter(l=>!l.policies?.doNotStoreValue);return t.filter(l=>s.some(f=>f.id===l.fieldId))},target:c}),i.sample({clock:r.responses.clearAll,target:n}),i.sample({clock:r.responses.clear,target:a})}});exports.responsesIndexedDBPlugin=E;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("effector"),k=require("../../experience-instance-CqwH_Ayg.cjs");function S(){let c,i;return{promise:new Promise((t,o)=>{c=t,i=o}),resolve:t=>c(t),reject:t=>i(t)}}function C(c,i){const{promise:f,resolve:t}=S(),o=r.createEvent(),s=r.createEvent(),l=r.createEvent(),u=r.createEvent(),p=r.createEvent(),g=c.experiences.listStore.map(e=>e.map(n=>k.createExperienceInstance({client:c,experience:n}))),a=r.createStore({currentExperienceIndex:0,renderedExperiences:[],isComplete:!1}),m=r.createEffect(async({experience:e,availableRenderers:n,startRendererIndex:v=0})=>{if(!e)return null;for(let d=v;d<n.length;d++){const x=n[d],E=e.componentStore.getState();if(E&&(x!=null&&x.isValidComponent(E.component)))return{rendered:await x.render(E.component,c,e),rendererIndex:d}}return null});a.on(l,(e,n)=>({...e,renderedExperiences:[...e.renderedExperiences,n],currentExperienceIndex:e.currentExperienceIndex+1})).on(p,e=>({...e,currentExperienceIndex:e.currentExperienceIndex+1})).on(u,e=>({...e,isComplete:!0})).reset(o),r.sample({clock:o,target:s}),r.sample({clock:s,source:{experiences:g,state:a},filter:({experiences:e,state:n})=>n.currentExperienceIndex<e.length&&!n.isComplete,fn:({experiences:e,state:n})=>({experience:e[n.currentExperienceIndex],availableRenderers:i,startRendererIndex:0}),target:m}),r.sample({clock:m.doneData,filter:e=>e!==null,fn:e=>e.rendered.body,target:l}),r.sample({clock:l,target:s}),r.sample({clock:m.doneData,filter:e=>e===null,target:p}),r.sample({clock:p,target:s}),r.sample({clock:[s,p,l],source:{experiences:g,state:a},filter:({experiences:e,state:n})=>n.currentExperienceIndex>=e.length,target:u});const I=r.attach({source:a,effect:e=>{e.isComplete&&t(e.renderedExperiences)}});return r.sample({clock:u,target:I}),o(),f}exports.render=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("effector"),k=require("../../experience-instance-CsMhH0DN.cjs");function S(){let c,i;return{promise:new Promise((t,o)=>{c=t,i=o}),resolve:t=>c(t),reject:t=>i(t)}}function C(c,i){const{promise:E,resolve:t}=S(),o=r.createEvent(),s=r.createEvent(),l=r.createEvent(),x=r.createEvent(),p=r.createEvent(),f=c.experiences.listStore.map(e=>e.map(n=>k.createExperienceInstance({client:c,experience:n}))),a=r.createStore({currentExperienceIndex:0,renderedExperiences:[],isComplete:!1}),u=r.createEffect(async({experience:e,availableRenderers:n,startRendererIndex:v=0})=>{if(!e)return null;for(let d=v;d<n.length;d++){const g=n[d],m=e.componentStore.getState();if(m&&g?.isValidComponent(m.component))return{rendered:await g.render(m.component,c,e),rendererIndex:d}}return null});a.on(l,(e,n)=>({...e,renderedExperiences:[...e.renderedExperiences,n],currentExperienceIndex:e.currentExperienceIndex+1})).on(p,e=>({...e,currentExperienceIndex:e.currentExperienceIndex+1})).on(x,e=>({...e,isComplete:!0})).reset(o),r.sample({clock:o,target:s}),r.sample({clock:s,source:{experiences:f,state:a},filter:({experiences:e,state:n})=>n.currentExperienceIndex<e.length&&!n.isComplete,fn:({experiences:e,state:n})=>({experience:e[n.currentExperienceIndex],availableRenderers:i,startRendererIndex:0}),target:u}),r.sample({clock:u.doneData,filter:e=>e!==null,fn:e=>e.rendered.body,target:l}),r.sample({clock:l,target:s}),r.sample({clock:u.doneData,filter:e=>e===null,target:p}),r.sample({clock:p,target:s}),r.sample({clock:[s,p,l],source:{experiences:f,state:a},filter:({experiences:e,state:n})=>n.currentExperienceIndex>=e.length,target:x});const I=r.attach({source:a,effect:e=>{e.isComplete&&t(e.renderedExperiences)}});return r.sample({clock:x,target:I}),o(),E}exports.render=C;