@picked/client 0.0.1-dev.1773724362573 → 0.0.1-dev.1773729274420
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-Z3Hn2Kw-.cjs → api-47L967ES.cjs} +1 -1
- package/dist/{api-B3x8PEp4.js → api-DuHeVrL4.js} +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/plugins/create-experience/index.js +1 -1
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/types/plugins/create-experience/create-experience.d.ts +4 -0
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const a="Picked-Client",d="Picked-Version";function s(e,t){return{[a]:e,[d]:t}}const o=()=>"0.0.1-dev.
|
|
1
|
+
"use strict";const a="Picked-Client",d="Picked-Version";function s(e,t){return{[a]:e,[d]:t}}const o=()=>"0.0.1-dev.1773729274420",E="v1";function c(e,t){return new URL(`/api/${E}/${t}`,e).toString()}function i(e){return{...s("sdk",o()),...e}}async function f(e,t,n){const r=c(e,t);return fetch(r,{headers:i(n)})}async function l(e,t,n,r){const u=c(e,t);return fetch(u,{method:"POST",headers:{"Content-Type":"application/json",...i(r)},body:JSON.stringify(n)})}exports.createClientHeaders=s;exports.get=f;exports.getVersion=o;exports.post=l;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("effector"),S=require("@withease/factories"),F=require("../experience-instance-BX0aqKsC.cjs"),E=require("../logger-BsmHUUw1.cjs"),w=require("../storage-58NoTSsc.cjs"),L=require("../api-Z3Hn2Kw-.cjs"),G=require("../id-BKIWbSTy.cjs"),W=require("../object-mwaxtjLG.cjs"),k=require("../supports-YvpQZxbh.cjs"),N=g.createDomain("experience"),J=S.createFactory(({client:t,experience:e})=>{const r=N.store(e),n=g.createApi(r,{merge(l,h){return{...l,...h.experience}}}),a=r.map(l=>({name:l.name,decisionLogic:l.condition,targetSelectors:l.targets,initializeOpenLogic:e.initializeOpen})),d=t.components.listStore.map(l=>(e.componentName?l.find(h=>h.name===e.componentName):void 0)||l.find(h=>h.name===`experience:${e.id}`)||l.find(h=>h.name==="experience"),{skipVoid:!1}),p=r.map(l=>({steps:l.steps,nodes:l.nodes,edges:l.edges,conditionals:l.conditionals})),u=r.map(l=>l.fields),f=e.actions??[];return{id:e.id,configStore:a,treeStore:p,fieldsStore:u,componentStore:d,actions:f,merge:n.merge}});function Y(t){return S.invoke(J,t)}const Q=S.createFactory(({client:t})=>{const e=N.store({}),r=g.createApi(e,{register(f,l){return{...f,[l.id]:l}}});function n(f){const l=e.getState()[f.id];if(l){l.merge({experience:f,strategy:"override"});return}const h=Y({client:t,experience:f});r.register(h)}const a=e.map(f=>Object.values(f));function d(f){return e.map(l=>l[f],{skipVoid:!1})}const p=g.attach({source:e,effect:async(f,{id:l,options:h})=>{const v=f[l];if(!v){E.logger("warn",`Experience with id '${l}' not found.`);return}if(h?.bypassCondition){z(t,v,h);return}await T(t,v)&&z(t,v,h)}}),u=g.attach({source:t.experienceInstances.listStore,effect:(f,{id:l,options:h})=>{const v=f.filter(y=>y.experienceId===l);if(v.length>0)for(const y of v)y.open();else p({id:l,options:{...h,initialiseOpen:!0}})}});return{register:n,get:d,getById:d,launch:p,open:u,listStore:a}});function X(t){return S.invoke(Q,t)}const Z=(t,e)=>{e.register(t)},z=(t,e,r)=>{const{targetSelectors:n}=e.configStore.getState(),a=F.getTargetElements(n,e.id);a.forEach(({elements:p})=>p.forEach(u=>F.tagTargetElement(u,e.id))),F.createAppHosts(a,e.id).forEach(p=>{r?t.experienceInstances.spawn(e,p,r):t.experienceInstances.spawn(e,p)})},C=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await T(t,e)&&z(t,e)}))},T=async(t,e)=>{if(!t.preconditionPassed||!t.session?.isUser)return!1;const{decisionLogic:r,targetSelectors:n}=e.configStore.getState();return F.getTargetElements(n,e.id).length<1||n.length===0?!1:r===void 0?!0:F.isRulesLogic(r)?await F.evaluateRuleLogic(t,r)===!0:!0},ee=(t,e,r)=>{const n=e.name,a=e.setup(t);if(a){const d=r[n]??{};r[n]=Object.freeze({...d,...a})}},te=g.createDomain("component"),re=S.createFactory(({client:t,component:e,name:r})=>{const n=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:n}});function se(t){return S.invoke(re,t)}const ne=S.createFactory(({client:t})=>{const e=te.store({}),r=g.createApi(e,{register(p,u){return{...p,[u.name]:u}}});function n(p,u){e.getState()[p]&&E.logger("warn",`Component '${p}' already registered. Registering again will override the previous registration.`);const l=se({client:t,name:p,component:u});r.register(l)}const a=e.map(p=>Object.values(p));function d(p){return e.map(u=>u[p],{skipVoid:!1})}return{register:n,getByName:d,listStore:a}});function oe(t){return S.invoke(ne,t)}const M=(t,e,r)=>{r.register(t,e)},ie=g.createDomain("framework"),ae=S.createFactory(({client:t})=>{const e=ie.store({}),r=g.createApi(e,{register(p,u){return{...p,[u.name]:u.framework}}});function n(p,u){e.getState()[p]&&E.logger("warn",`Framework '${p}' already registered. Registering again will override the previous registration.`),r.register({name:p,framework:u})}const a=e.map(p=>Object.values(p));function d(p){return e.map(u=>u[p],{skipVoid:!1})}return{register:n,getByName:d,listStore:a}});function ce(t){return S.invoke(ae,t)}const ue=(t,e)=>{e.register(t.name,t)},le=6e3,de=w.createStorageKey("last_ping","global"),pe=async t=>{try{const e=Date.now(),r=w.localStore.get(de);let n=0;if(r.isSet()&&(n=r.json()??0),n&&e-n<le)return!0;const a={projectId:t.projectId,path:window.location.pathname},d={},u=document.getElementById("picked_script")?.dataset.verceltoken;u&&(d["x-vercel-protection-bypass"]=u);const l=(await L.post(t.apiUrl,"ping",a,d)).ok;return l&&r.set(e),l}catch(e){return E.logger("error",e),!1}};function _(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"),ge=S.createFactory(({client:t})=>{const e=fe.store({}),r=g.createApi(e,{register(u,f){return{...u,[f.name]:{name:f.name,predicate:f.predicate}}}});function n(u,f){e.getState()[u]&&E.logger("warn",`Predicate '${u}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:u,predicate:f}))}const a=e.map(u=>Object.values(u));function d(u){return e.map(f=>f[u]?.predicate,{skipVoid:!1})}function p(u){const f=g.createStore(()=>{},{skipVoid:!1}),l=g.createEffect(async()=>{const h=d(u).getState();if(!h)return;const v=_(t);return(...y)=>h({...v,args:y})});return g.sample({source:{responses:t.responses.listStore,fields:t.fields.listStore},target:l}),g.sample({clock:l.doneData,filter:h=>h!==void 0,target:f}),l(),f}return{register:n,getByName:d,listStore:a,getEvokablePredicate:p}});function me(t){return S.invoke(ge,t)}const ye=(t,e,r)=>{r.register(t,e)},O=g.createDomain("feature"),he=S.createFactory(({client:t})=>{const e=O.store({}),r=O.store([]),n=g.createApi(e,{register(c,s){return{...c,[s.id]:s.feature}}});function a(c,s){e.getState()[c]&&E.logger("warn",`Feature '${c}' already registered. Registering again will override the previous registration.`);const i={id:c,feature:{...s,id:c}};n.register(Object.freeze({id:c,feature:i}))}const d=g.createEffect(async({id:c,key:s,storage:o="local"})=>{const i=w.createStorageKey(`feature:${c}:${s}`,"global"),b=(o==="session"?w.sessionStore:w.localStore).get(i).boolean();return b===null?null:{id:c,key:s,bucket:b,storage:o}}),p=g.createEffect(c=>{if(!c)return null;const s=w.createStorageKey(`feature:${c.id}:${c.key}`,"global");(c.storage==="session"?w.sessionStore:w.localStore).set(s,c.bucket)}),u=new Map,f=g.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:c,resolvedFeaturesStore:s},{id:o,decide:i,key:m})=>{const b=s.find(P=>P.id===o&&P.key===m);if(b)return b;const I=c[o];if(!I)throw new Error(`Feature with id '${o}' not found`);const A=u.get(`${o}:${m}`);if(A!==void 0){const P=await A;return{id:I.id,bucket:P,key:m,storage:I.feature.storage}}const x=i();u.set(`${o}:${m}`,x);const K=await x;return{id:I.id,bucket:K,key:m,storage:I.feature.storage}}});g.sample({clock:n.register,fn:c=>{const{id:s,feature:o}=c;return{id:s,key:o.feature.key,storage:o.feature.storage}},target:d}),g.sample({source:e,clock:f.doneData,fn:(c,s)=>{const{id:o,bucket:i,storage:m}=s,b=c[o]?.feature.key;return b?{key:b,id:o,bucket:i,storage:m}:null},target:p});const l=g.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:c,resolvedFeaturesStore:s})=>Object.values(c).map(o=>{const i=s.find(m=>m.id===o.id&&m.key===o.feature.key);return i?{id:o.id,name:o.feature.name,key:o.feature.key,getBucket:()=>({id:o.id,bucket:i.bucket}),isResolved:!0}:{id:o.id,name:o.feature.name,key:o.feature.key,getBucket:async()=>await f(o.feature),isResolved:!1}}));g.sample({clock:f.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:c},{id:s,key:o})=>!c.some(m=>m.id===s&&m.key===o),fn:(c,s)=>s,target:t.eventBus.prepend(c=>({type:"feature_decide",feature:c}))}),g.sample({clock:[d.doneData,f.doneData],source:r,fn:(c,s)=>!s||c.some(i=>i.id===s.id&&i.key===s.key)?c:[...c,s],target:r});function h(c){return l.map(s=>s.find(o=>o.id===c))}function v(c){return e.map(s=>s[c],{skipVoid:!1})}function y(c){const s=g.createStore(async()=>{},{skipVoid:!1}),o=g.createEffect(async()=>{const i=h(c).getState();if(i)return async()=>(await i.getBucket()).bucket});return g.sample({source:r,filter:i=>i.some(m=>m.id===c),target:o}),g.sample({clock:o.doneData,filter:i=>i!==void 0,target:s}),o(),s}return{register:a,getById:h,getByName:v,listStore:l,getEvokableFeature:y}});function Se(t){return S.invoke(he,t)}const ve=(t,e,r)=>{r.register(t,e)},j=g.createDomain("history");function U(t,e){return{id:G.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ke=S.createFactory(()=>{const t=j.store({entries:[]}),e=j.event(),r=j.event(),n=j.event(),a=j.event();t.on(e,(p,u)=>({entries:[...p.entries,U(u.experienceId,u.node)]})),t.on(r,(p,u)=>({entries:[...p.entries.slice(0,-1),U(u.experienceId,u.node)]})),t.on(a,(p,u)=>u);function d(p,u){const f={lastStepIndex:-1,secondLastStepIndex:-1};for(let l=p.length-1;l>=0;l--){const h=p[l],v=h?.node;if(!(!v||!F.isStepNode(v))&&!(u&&h.experienceId!==u))if(f.lastStepIndex===-1)f.lastStepIndex=l;else{f.secondLastStepIndex=l;break}}return f}return t.on(n,(p,u)=>{const{secondLastStepIndex:f}=d(p.entries,u.experienceId),l=f!==-1?p.entries.slice(0,f+1):p.entries;return{...p,entries:l}}),{push:e,replace:r,back:n,restore:a,entriesStore:t.map(p=>p.entries)}});function be(){return S.invoke(ke)}let we=0;const Ie=t=>{const e=g.createStore([]);return g.sample({clock:t,source:e,fn:(r,n)=>[...r,{id:we++,at:new Date,payload:n}],target:e}),e},$=g.createDomain("field");function Fe(t){return Array.isArray(t)&&t.every(e=>typeof e=="object"&&e!==null&&"id"in e&&"label"in e&&"value"in e)}function B(t,e){const r=Array.isArray(t.options)?t.options:null,n=e??{status:"idle",options:r};return{...t,...n,options:n.options??r}}const xe=S.createFactory(({client:t})=>{const e=$.store({}),r=g.createApi(e,{register(s,o){return{...s,[o.field.id]:o.field}},updateById(s,o){const i=s[o.fieldId];return i?{...s,[o.fieldId]:Object.assign({},i,o.updates)}:s}});function n(s){r.register({field:s})}function a(s,o){r.updateById({fieldId:s,updates:o})}const d=$.store({}),p=g.combine(e,d,(s,o)=>Object.values(s).map(i=>B(i,o[i.id])));function u(s){return g.combine(e,d,(o,i)=>{const m=o[s];return m?B(m,i[s]):null})}function f(s){return g.combine(e,d,(o,i)=>{const m=Object.values(o).find(b=>b.name===s);return m?B(m,i[m.id]):null})}const l=$.effect(async({fieldId:s,fieldOptions:o,context:i})=>{if(t&&!Array.isArray(o)&&o!==null){const m=await F.evaluateRuleLogic(t,o,i);return Fe(m)?{fieldId:s,options:m}:{fieldId:s,options:null}}return{fieldId:s,options:Array.isArray(o)?o:null}});d.on(l,(s,{fieldId:o})=>{const i=s[o];return{...s,[o]:{status:"loading",options:i?.status==="resolved"?i.options:null}}}),d.on(l.doneData,(s,{fieldId:o,options:i})=>({...s,[o]:{status:"resolved",options:i}})),d.on(l.fail,(s,{params:{fieldId:o}})=>({...s,[o]:{status:"error",options:null,error:"Failed to resolve field options"}}));const h=g.createEvent();d.on(h,(s,o)=>({...s,[o]:{status:"waiting",options:null}}));const v=g.createEvent();t&&g.sample({clock:v,source:{states:d,fields:e},filter:({states:s},{fieldId:o,force:i})=>{if(i)return!0;const m=s[o];return!m||m.status==="idle"},fn:({fields:s},{fieldId:o,context:i})=>{const m=s[o]??null;return{fieldId:o,fieldOptions:m?.options??null,context:i}},target:l});function y(s,o){v({fieldId:s,force:o?.force,context:o?.context})}function c(s,o){for(const i of s)v({fieldId:i,force:o?.force,context:o?.context})}return{register:n,update:a,getById:u,listStore:p,getByName:f,resolve:y,resolveAll:c,setWaiting:h}});function Ee(t){return S.invoke(xe,t??{})}const je=(t,e)=>{e.register(t)},Ae=g.createDomain("action"),Pe=S.createFactory(({client:t})=>{const e=Ae.store({}),r=g.createApi(e,{register(u,f){return{...u,[f.name]:{name:f.name,action:f.action}}}});function n(u,f){r.register({name:u,action:f})}const a=e.map(u=>Object.values(u));function d(u){return e.map(f=>f[u],{skipVoid:!1})}function p(u){return e.map(f=>{const l=f[u];return l?l.action:void 0},{skipVoid:!1})}return{register:n,getByName:d,listStore:a,getEvokableAction:p}});function Re(t){return S.invoke(Pe,t)}const $e=(t,e,r)=>{r.register(t,e)};function D(t){return typeof t>"u"||t===null||t===""||Array.isArray(t)&&!t.length}function Be(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null}function V(t){try{return JSON.stringify(t),!0}catch{return!1}}const De=g.createDomain("response"),ze=S.createFactory(({client:t})=>{const e=De.store({}),r=g.createEvent(),n=g.createEvent(),a=g.createApi(e,{register(y,c){return{...y,[c.fieldId]:c.response}},registerBatch(y,c){return{...y,...c}},clear(y,c){const{[c]:s,...o}=y;return o},clearAll(){return{}}});function d(y,c){if(typeof y=="string"){if(c===void 0)throw new Error("Response is required when registering a single field");a.register({fieldId:y,response:c})}else a.registerBatch(y)}async function p(y){const c=[];return await Promise.allSettled(Object.entries(y).map(async([s,o])=>{let i=o;const m=t.fields.getById(s).getState();if(!m){c.push({fieldId:s,userMessage:`Field '${s}' not found`,systemMessage:`No field with ID '${s}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:i});return}if(m.multiple&&(typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&(i=[i]),m.validation&&!W.isEmpty(m.validation)&&!D(i)){const b={...e.getState(),...y},I=await F.evaluateRuleLogic(t,m.validation,{$input:i,responses:b});if(typeof I=="string"){c.push({fieldId:s,userMessage:I,systemMessage:`Field validation resulted in an error: ${I}.`,value:i});return}if(I===!1){c.push({fieldId:s,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:i});return}}if(m.required&&D(i)){c.push({fieldId:s,userMessage:"This field is required",systemMessage:"Field is required.",value:i});return}if(!m.multiple&&Array.isArray(i)&&i.length>1){c.push({fieldId:s,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:i});return}if(m.type==="object"&&!D(i))if(m.multiple){if(!Array.isArray(i)){c.push({fieldId:s,userMessage:"This field expects multiple values",systemMessage:"Field expects an array of objects.",value:i});return}for(const b of i){if(typeof b!="object"||b===null){c.push({fieldId:s,userMessage:"This field expects object values",systemMessage:"Field expects an array of objects, but received non-object value.",value:i});return}if(!V(b)){c.push({fieldId:s,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:i});return}}}else{if(Array.isArray(i)){c.push({fieldId:s,userMessage:"This field expects a single value",systemMessage:"Field expects a single object, not an array.",value:i});return}if(typeof i!="object"||i===null){c.push({fieldId:s,userMessage:"This field expects an object value",systemMessage:"Field expects an object value.",value:i});return}if(!V(i)){c.push({fieldId:s,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:i});return}}if(Array.isArray(m.options)&&m.options.length>0){const b=Array.isArray(i)?i:[i];if(m.type==="object"){const I=m.options.map(x=>JSON.stringify(x.value));b.every(x=>I.includes(JSON.stringify(x)))||c.push({fieldId:s,userMessage:"This field expects a valid option",systemMessage:"Field expects a valid option from the defined choices.",value:i})}else{const I=m.options.map(x=>x.value);b.every(x=>!Be(x)||x===null?!1:I.includes(x))||c.push({fieldId:s,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${I.join(", ")}`,value:i})}}})),{responsesToCommit:y,validationErrors:c}}async function u(y){const{responsesToCommit:c,validationErrors:s}=await p(y);return s.length?{errors:s}:(a.registerBatch(c),{errors:[]})}const f=e.map(y=>y),l=e.map(y=>Object.keys(y).map(s=>({fieldId:s,value:y[s]})));function h(y){const c=t.fields.getById(y),s=e.map(o=>o[y]||null);return g.combine({f:c,r:s},({f:o,r:i})=>i||(o?.defaultValue?o.defaultValue:null))}function v(y){const c=t.fields.getByName(y);return g.combine({f:c,s:e},({f:s,s:o})=>{const i=s&&o[s.id]||null;return i||(s?.defaultValue?s.defaultValue:null)})}return g.sample({clock:r,target:a.clearAll}),g.sample({clock:n,target:a.clear}),{register:d,clearAll:r,clear:n,commit:u,getResponsesToCommit:p,listStore:l,getAllStore:f,getByFieldId:h,getByFieldName:v}});function Ce(t){return S.invoke(ze,t)}function Me(){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?.dataset.api)return e.dataset.api}return"https://api.picked.app"}function Oe(){if(!k.supportsWindow())return{};const t=new URLSearchParams(window.location.search),e={},r=new Set;for(const[a]of t.entries())a.startsWith("picked-")&&r.add(a);for(const a of r){const d=a.replace("picked-","");e[d]=t.getAll(a)}const n=w.createStorageKey("s");if(r.size>0)w.sessionStore.set(n,e);else{const a=w.sessionStore.get(n);if(a)return a.json()||{}}return e}function Ue(){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"),Le=()=>{const t=w.localStore.get(Ve);let e;t.isSet()&&(e=t.json());const r=a=>t.set({id:a.id,isUser:a.isUser,identifiers:a.identifiers}),n={id:e?.id??Ue(),isUser:e?.isUser??void 0,identifiers:e?.identifiers??void 0,setIsUser(a){this.isUser=a,r(this)},setIdentifier(a,d){this.identifiers={...this.identifiers,[a]:d},r(this)},removeIdentifier(a){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([d])=>d!==a)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,r(this))}};return r(n),n},Ne=()=>k.supportsLocalStorage()?Le():null;function q(){if(k.supportsWindow())return globalThis.window.pickedConfig}function Te(){if(!k.supportsWindow())return;const t=q(),e=t?.organizationId,r=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=Te();if(n)return n;const a=_e();if(a)return a;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 g=require("effector"),S=require("@withease/factories"),F=require("../experience-instance-BX0aqKsC.cjs"),E=require("../logger-BsmHUUw1.cjs"),w=require("../storage-58NoTSsc.cjs"),L=require("../api-47L967ES.cjs"),G=require("../id-BKIWbSTy.cjs"),W=require("../object-mwaxtjLG.cjs"),k=require("../supports-YvpQZxbh.cjs"),N=g.createDomain("experience"),J=S.createFactory(({client:t,experience:e})=>{const r=N.store(e),n=g.createApi(r,{merge(l,h){return{...l,...h.experience}}}),a=r.map(l=>({name:l.name,decisionLogic:l.condition,targetSelectors:l.targets,initializeOpenLogic:e.initializeOpen})),d=t.components.listStore.map(l=>(e.componentName?l.find(h=>h.name===e.componentName):void 0)||l.find(h=>h.name===`experience:${e.id}`)||l.find(h=>h.name==="experience"),{skipVoid:!1}),p=r.map(l=>({steps:l.steps,nodes:l.nodes,edges:l.edges,conditionals:l.conditionals})),u=r.map(l=>l.fields),f=e.actions??[];return{id:e.id,configStore:a,treeStore:p,fieldsStore:u,componentStore:d,actions:f,merge:n.merge}});function Y(t){return S.invoke(J,t)}const Q=S.createFactory(({client:t})=>{const e=N.store({}),r=g.createApi(e,{register(f,l){return{...f,[l.id]:l}}});function n(f){const l=e.getState()[f.id];if(l){l.merge({experience:f,strategy:"override"});return}const h=Y({client:t,experience:f});r.register(h)}const a=e.map(f=>Object.values(f));function d(f){return e.map(l=>l[f],{skipVoid:!1})}const p=g.attach({source:e,effect:async(f,{id:l,options:h})=>{const v=f[l];if(!v){E.logger("warn",`Experience with id '${l}' not found.`);return}if(h?.bypassCondition){z(t,v,h);return}await T(t,v)&&z(t,v,h)}}),u=g.attach({source:t.experienceInstances.listStore,effect:(f,{id:l,options:h})=>{const v=f.filter(y=>y.experienceId===l);if(v.length>0)for(const y of v)y.open();else p({id:l,options:{...h,initialiseOpen:!0}})}});return{register:n,get:d,getById:d,launch:p,open:u,listStore:a}});function X(t){return S.invoke(Q,t)}const Z=(t,e)=>{e.register(t)},z=(t,e,r)=>{const{targetSelectors:n}=e.configStore.getState(),a=F.getTargetElements(n,e.id);a.forEach(({elements:p})=>p.forEach(u=>F.tagTargetElement(u,e.id))),F.createAppHosts(a,e.id).forEach(p=>{r?t.experienceInstances.spawn(e,p,r):t.experienceInstances.spawn(e,p)})},C=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await T(t,e)&&z(t,e)}))},T=async(t,e)=>{if(!t.preconditionPassed||!t.session?.isUser)return!1;const{decisionLogic:r,targetSelectors:n}=e.configStore.getState();return F.getTargetElements(n,e.id).length<1||n.length===0?!1:r===void 0?!0:F.isRulesLogic(r)?await F.evaluateRuleLogic(t,r)===!0:!0},ee=(t,e,r)=>{const n=e.name,a=e.setup(t);if(a){const d=r[n]??{};r[n]=Object.freeze({...d,...a})}},te=g.createDomain("component"),re=S.createFactory(({client:t,component:e,name:r})=>{const n=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:n}});function se(t){return S.invoke(re,t)}const ne=S.createFactory(({client:t})=>{const e=te.store({}),r=g.createApi(e,{register(p,u){return{...p,[u.name]:u}}});function n(p,u){e.getState()[p]&&E.logger("warn",`Component '${p}' already registered. Registering again will override the previous registration.`);const l=se({client:t,name:p,component:u});r.register(l)}const a=e.map(p=>Object.values(p));function d(p){return e.map(u=>u[p],{skipVoid:!1})}return{register:n,getByName:d,listStore:a}});function oe(t){return S.invoke(ne,t)}const M=(t,e,r)=>{r.register(t,e)},ie=g.createDomain("framework"),ae=S.createFactory(({client:t})=>{const e=ie.store({}),r=g.createApi(e,{register(p,u){return{...p,[u.name]:u.framework}}});function n(p,u){e.getState()[p]&&E.logger("warn",`Framework '${p}' already registered. Registering again will override the previous registration.`),r.register({name:p,framework:u})}const a=e.map(p=>Object.values(p));function d(p){return e.map(u=>u[p],{skipVoid:!1})}return{register:n,getByName:d,listStore:a}});function ce(t){return S.invoke(ae,t)}const ue=(t,e)=>{e.register(t.name,t)},le=6e3,de=w.createStorageKey("last_ping","global"),pe=async t=>{try{const e=Date.now(),r=w.localStore.get(de);let n=0;if(r.isSet()&&(n=r.json()??0),n&&e-n<le)return!0;const a={projectId:t.projectId,path:window.location.pathname},d={},u=document.getElementById("picked_script")?.dataset.verceltoken;u&&(d["x-vercel-protection-bypass"]=u);const l=(await L.post(t.apiUrl,"ping",a,d)).ok;return l&&r.set(e),l}catch(e){return E.logger("error",e),!1}};function _(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"),ge=S.createFactory(({client:t})=>{const e=fe.store({}),r=g.createApi(e,{register(u,f){return{...u,[f.name]:{name:f.name,predicate:f.predicate}}}});function n(u,f){e.getState()[u]&&E.logger("warn",`Predicate '${u}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:u,predicate:f}))}const a=e.map(u=>Object.values(u));function d(u){return e.map(f=>f[u]?.predicate,{skipVoid:!1})}function p(u){const f=g.createStore(()=>{},{skipVoid:!1}),l=g.createEffect(async()=>{const h=d(u).getState();if(!h)return;const v=_(t);return(...y)=>h({...v,args:y})});return g.sample({source:{responses:t.responses.listStore,fields:t.fields.listStore},target:l}),g.sample({clock:l.doneData,filter:h=>h!==void 0,target:f}),l(),f}return{register:n,getByName:d,listStore:a,getEvokablePredicate:p}});function me(t){return S.invoke(ge,t)}const ye=(t,e,r)=>{r.register(t,e)},O=g.createDomain("feature"),he=S.createFactory(({client:t})=>{const e=O.store({}),r=O.store([]),n=g.createApi(e,{register(c,s){return{...c,[s.id]:s.feature}}});function a(c,s){e.getState()[c]&&E.logger("warn",`Feature '${c}' already registered. Registering again will override the previous registration.`);const i={id:c,feature:{...s,id:c}};n.register(Object.freeze({id:c,feature:i}))}const d=g.createEffect(async({id:c,key:s,storage:o="local"})=>{const i=w.createStorageKey(`feature:${c}:${s}`,"global"),b=(o==="session"?w.sessionStore:w.localStore).get(i).boolean();return b===null?null:{id:c,key:s,bucket:b,storage:o}}),p=g.createEffect(c=>{if(!c)return null;const s=w.createStorageKey(`feature:${c.id}:${c.key}`,"global");(c.storage==="session"?w.sessionStore:w.localStore).set(s,c.bucket)}),u=new Map,f=g.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:c,resolvedFeaturesStore:s},{id:o,decide:i,key:m})=>{const b=s.find(P=>P.id===o&&P.key===m);if(b)return b;const I=c[o];if(!I)throw new Error(`Feature with id '${o}' not found`);const A=u.get(`${o}:${m}`);if(A!==void 0){const P=await A;return{id:I.id,bucket:P,key:m,storage:I.feature.storage}}const x=i();u.set(`${o}:${m}`,x);const K=await x;return{id:I.id,bucket:K,key:m,storage:I.feature.storage}}});g.sample({clock:n.register,fn:c=>{const{id:s,feature:o}=c;return{id:s,key:o.feature.key,storage:o.feature.storage}},target:d}),g.sample({source:e,clock:f.doneData,fn:(c,s)=>{const{id:o,bucket:i,storage:m}=s,b=c[o]?.feature.key;return b?{key:b,id:o,bucket:i,storage:m}:null},target:p});const l=g.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:c,resolvedFeaturesStore:s})=>Object.values(c).map(o=>{const i=s.find(m=>m.id===o.id&&m.key===o.feature.key);return i?{id:o.id,name:o.feature.name,key:o.feature.key,getBucket:()=>({id:o.id,bucket:i.bucket}),isResolved:!0}:{id:o.id,name:o.feature.name,key:o.feature.key,getBucket:async()=>await f(o.feature),isResolved:!1}}));g.sample({clock:f.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:c},{id:s,key:o})=>!c.some(m=>m.id===s&&m.key===o),fn:(c,s)=>s,target:t.eventBus.prepend(c=>({type:"feature_decide",feature:c}))}),g.sample({clock:[d.doneData,f.doneData],source:r,fn:(c,s)=>!s||c.some(i=>i.id===s.id&&i.key===s.key)?c:[...c,s],target:r});function h(c){return l.map(s=>s.find(o=>o.id===c))}function v(c){return e.map(s=>s[c],{skipVoid:!1})}function y(c){const s=g.createStore(async()=>{},{skipVoid:!1}),o=g.createEffect(async()=>{const i=h(c).getState();if(i)return async()=>(await i.getBucket()).bucket});return g.sample({source:r,filter:i=>i.some(m=>m.id===c),target:o}),g.sample({clock:o.doneData,filter:i=>i!==void 0,target:s}),o(),s}return{register:a,getById:h,getByName:v,listStore:l,getEvokableFeature:y}});function Se(t){return S.invoke(he,t)}const ve=(t,e,r)=>{r.register(t,e)},j=g.createDomain("history");function U(t,e){return{id:G.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ke=S.createFactory(()=>{const t=j.store({entries:[]}),e=j.event(),r=j.event(),n=j.event(),a=j.event();t.on(e,(p,u)=>({entries:[...p.entries,U(u.experienceId,u.node)]})),t.on(r,(p,u)=>({entries:[...p.entries.slice(0,-1),U(u.experienceId,u.node)]})),t.on(a,(p,u)=>u);function d(p,u){const f={lastStepIndex:-1,secondLastStepIndex:-1};for(let l=p.length-1;l>=0;l--){const h=p[l],v=h?.node;if(!(!v||!F.isStepNode(v))&&!(u&&h.experienceId!==u))if(f.lastStepIndex===-1)f.lastStepIndex=l;else{f.secondLastStepIndex=l;break}}return f}return t.on(n,(p,u)=>{const{secondLastStepIndex:f}=d(p.entries,u.experienceId),l=f!==-1?p.entries.slice(0,f+1):p.entries;return{...p,entries:l}}),{push:e,replace:r,back:n,restore:a,entriesStore:t.map(p=>p.entries)}});function be(){return S.invoke(ke)}let we=0;const Ie=t=>{const e=g.createStore([]);return g.sample({clock:t,source:e,fn:(r,n)=>[...r,{id:we++,at:new Date,payload:n}],target:e}),e},$=g.createDomain("field");function Fe(t){return Array.isArray(t)&&t.every(e=>typeof e=="object"&&e!==null&&"id"in e&&"label"in e&&"value"in e)}function B(t,e){const r=Array.isArray(t.options)?t.options:null,n=e??{status:"idle",options:r};return{...t,...n,options:n.options??r}}const xe=S.createFactory(({client:t})=>{const e=$.store({}),r=g.createApi(e,{register(s,o){return{...s,[o.field.id]:o.field}},updateById(s,o){const i=s[o.fieldId];return i?{...s,[o.fieldId]:Object.assign({},i,o.updates)}:s}});function n(s){r.register({field:s})}function a(s,o){r.updateById({fieldId:s,updates:o})}const d=$.store({}),p=g.combine(e,d,(s,o)=>Object.values(s).map(i=>B(i,o[i.id])));function u(s){return g.combine(e,d,(o,i)=>{const m=o[s];return m?B(m,i[s]):null})}function f(s){return g.combine(e,d,(o,i)=>{const m=Object.values(o).find(b=>b.name===s);return m?B(m,i[m.id]):null})}const l=$.effect(async({fieldId:s,fieldOptions:o,context:i})=>{if(t&&!Array.isArray(o)&&o!==null){const m=await F.evaluateRuleLogic(t,o,i);return Fe(m)?{fieldId:s,options:m}:{fieldId:s,options:null}}return{fieldId:s,options:Array.isArray(o)?o:null}});d.on(l,(s,{fieldId:o})=>{const i=s[o];return{...s,[o]:{status:"loading",options:i?.status==="resolved"?i.options:null}}}),d.on(l.doneData,(s,{fieldId:o,options:i})=>({...s,[o]:{status:"resolved",options:i}})),d.on(l.fail,(s,{params:{fieldId:o}})=>({...s,[o]:{status:"error",options:null,error:"Failed to resolve field options"}}));const h=g.createEvent();d.on(h,(s,o)=>({...s,[o]:{status:"waiting",options:null}}));const v=g.createEvent();t&&g.sample({clock:v,source:{states:d,fields:e},filter:({states:s},{fieldId:o,force:i})=>{if(i)return!0;const m=s[o];return!m||m.status==="idle"},fn:({fields:s},{fieldId:o,context:i})=>{const m=s[o]??null;return{fieldId:o,fieldOptions:m?.options??null,context:i}},target:l});function y(s,o){v({fieldId:s,force:o?.force,context:o?.context})}function c(s,o){for(const i of s)v({fieldId:i,force:o?.force,context:o?.context})}return{register:n,update:a,getById:u,listStore:p,getByName:f,resolve:y,resolveAll:c,setWaiting:h}});function Ee(t){return S.invoke(xe,t??{})}const je=(t,e)=>{e.register(t)},Ae=g.createDomain("action"),Pe=S.createFactory(({client:t})=>{const e=Ae.store({}),r=g.createApi(e,{register(u,f){return{...u,[f.name]:{name:f.name,action:f.action}}}});function n(u,f){r.register({name:u,action:f})}const a=e.map(u=>Object.values(u));function d(u){return e.map(f=>f[u],{skipVoid:!1})}function p(u){return e.map(f=>{const l=f[u];return l?l.action:void 0},{skipVoid:!1})}return{register:n,getByName:d,listStore:a,getEvokableAction:p}});function Re(t){return S.invoke(Pe,t)}const $e=(t,e,r)=>{r.register(t,e)};function D(t){return typeof t>"u"||t===null||t===""||Array.isArray(t)&&!t.length}function Be(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null}function V(t){try{return JSON.stringify(t),!0}catch{return!1}}const De=g.createDomain("response"),ze=S.createFactory(({client:t})=>{const e=De.store({}),r=g.createEvent(),n=g.createEvent(),a=g.createApi(e,{register(y,c){return{...y,[c.fieldId]:c.response}},registerBatch(y,c){return{...y,...c}},clear(y,c){const{[c]:s,...o}=y;return o},clearAll(){return{}}});function d(y,c){if(typeof y=="string"){if(c===void 0)throw new Error("Response is required when registering a single field");a.register({fieldId:y,response:c})}else a.registerBatch(y)}async function p(y){const c=[];return await Promise.allSettled(Object.entries(y).map(async([s,o])=>{let i=o;const m=t.fields.getById(s).getState();if(!m){c.push({fieldId:s,userMessage:`Field '${s}' not found`,systemMessage:`No field with ID '${s}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:i});return}if(m.multiple&&(typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&(i=[i]),m.validation&&!W.isEmpty(m.validation)&&!D(i)){const b={...e.getState(),...y},I=await F.evaluateRuleLogic(t,m.validation,{$input:i,responses:b});if(typeof I=="string"){c.push({fieldId:s,userMessage:I,systemMessage:`Field validation resulted in an error: ${I}.`,value:i});return}if(I===!1){c.push({fieldId:s,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:i});return}}if(m.required&&D(i)){c.push({fieldId:s,userMessage:"This field is required",systemMessage:"Field is required.",value:i});return}if(!m.multiple&&Array.isArray(i)&&i.length>1){c.push({fieldId:s,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:i});return}if(m.type==="object"&&!D(i))if(m.multiple){if(!Array.isArray(i)){c.push({fieldId:s,userMessage:"This field expects multiple values",systemMessage:"Field expects an array of objects.",value:i});return}for(const b of i){if(typeof b!="object"||b===null){c.push({fieldId:s,userMessage:"This field expects object values",systemMessage:"Field expects an array of objects, but received non-object value.",value:i});return}if(!V(b)){c.push({fieldId:s,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:i});return}}}else{if(Array.isArray(i)){c.push({fieldId:s,userMessage:"This field expects a single value",systemMessage:"Field expects a single object, not an array.",value:i});return}if(typeof i!="object"||i===null){c.push({fieldId:s,userMessage:"This field expects an object value",systemMessage:"Field expects an object value.",value:i});return}if(!V(i)){c.push({fieldId:s,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:i});return}}if(Array.isArray(m.options)&&m.options.length>0){const b=Array.isArray(i)?i:[i];if(m.type==="object"){const I=m.options.map(x=>JSON.stringify(x.value));b.every(x=>I.includes(JSON.stringify(x)))||c.push({fieldId:s,userMessage:"This field expects a valid option",systemMessage:"Field expects a valid option from the defined choices.",value:i})}else{const I=m.options.map(x=>x.value);b.every(x=>!Be(x)||x===null?!1:I.includes(x))||c.push({fieldId:s,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${I.join(", ")}`,value:i})}}})),{responsesToCommit:y,validationErrors:c}}async function u(y){const{responsesToCommit:c,validationErrors:s}=await p(y);return s.length?{errors:s}:(a.registerBatch(c),{errors:[]})}const f=e.map(y=>y),l=e.map(y=>Object.keys(y).map(s=>({fieldId:s,value:y[s]})));function h(y){const c=t.fields.getById(y),s=e.map(o=>o[y]||null);return g.combine({f:c,r:s},({f:o,r:i})=>i||(o?.defaultValue?o.defaultValue:null))}function v(y){const c=t.fields.getByName(y);return g.combine({f:c,s:e},({f:s,s:o})=>{const i=s&&o[s.id]||null;return i||(s?.defaultValue?s.defaultValue:null)})}return g.sample({clock:r,target:a.clearAll}),g.sample({clock:n,target:a.clear}),{register:d,clearAll:r,clear:n,commit:u,getResponsesToCommit:p,listStore:l,getAllStore:f,getByFieldId:h,getByFieldName:v}});function Ce(t){return S.invoke(ze,t)}function Me(){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?.dataset.api)return e.dataset.api}return"https://api.picked.app"}function Oe(){if(!k.supportsWindow())return{};const t=new URLSearchParams(window.location.search),e={},r=new Set;for(const[a]of t.entries())a.startsWith("picked-")&&r.add(a);for(const a of r){const d=a.replace("picked-","");e[d]=t.getAll(a)}const n=w.createStorageKey("s");if(r.size>0)w.sessionStore.set(n,e);else{const a=w.sessionStore.get(n);if(a)return a.json()||{}}return e}function Ue(){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"),Le=()=>{const t=w.localStore.get(Ve);let e;t.isSet()&&(e=t.json());const r=a=>t.set({id:a.id,isUser:a.isUser,identifiers:a.identifiers}),n={id:e?.id??Ue(),isUser:e?.isUser??void 0,identifiers:e?.identifiers??void 0,setIsUser(a){this.isUser=a,r(this)},setIdentifier(a,d){this.identifiers={...this.identifiers,[a]:d},r(this)},removeIdentifier(a){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([d])=>d!==a)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,r(this))}};return r(n),n},Ne=()=>k.supportsLocalStorage()?Le():null;function q(){if(k.supportsWindow())return globalThis.window.pickedConfig}function Te(){if(!k.supportsWindow())return;const t=q(),e=t?.organizationId,r=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=Te();if(n)return n;const a=_e();if(a)return a;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
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 R(t){return t==null||t===""||Number.isNaN(t)}const He={default:(t,e)=>R(t)?String(e??""):String(t),append:(t,e)=>e&&!R(t)?`${t} ${e}`:t,prepend:(t,e)=>e&&!R(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,a])=>`${n}: ${a}`);return e.format(r)}return t instanceof Set?e.format(Array.from(t).map(String)):t}};function Ke(t){return typeof t=="object"&&t!==null}function Ge(t,e){let r=e;for(const n of t.split("."))if(Ke(r)&&n in r)r=r[n];else return;return typeof r=="function"?r():r}function We(t,e){const r=t.split("|").map(d=>d.trim()),n=r.shift()??"";let a=Ge(n,e);for(const d of r){const[p,...u]=d.split(":"),f=p?.trim()??"",l=u.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g,""),h=He[f];h&&(a=h(a,l))}return R(a)?"":typeof a=="object"?JSON.stringify(a):String(a)}function Je(t,e){let r="",n=0;for(;n<t.length;)if(t[n]==="{"&&t[n+1]==="{"){n+=2;let a="";for(;n<t.length;){if(t[n]==="}"&&t[n+1]==="}"){n+=2;break}a+=t[n++]}r+=We(a.trim(),e)}else r+=t[n++];return r}class H{static logger=E.logger;options;isReady=!1;project;plugins={};pluginStartHooks=[];eventBus=g.createEvent();events;organizationId;projectId;apiUrl;dashboardUrl;documentationSiteUrl;session;precondition;condition;preconditionPassed;searchParams=Oe();history=be();components=oe({client:this});experienceInstances=F.createExperienceInstanceIndex({client:this});experiences=X({client:this});frameworks=ce({client:this});predicates=me({client:this});features=Se({client:this});responses=Ce({client:this});fields=Ee({client:this});actions=Re({client:this});constructor(e){E.logger("info","Picked client initializing."),this.events=Ie(this.eventBus);const{organizationId:r,projectId:n}=qe(e);this.organizationId=r,this.projectId=n,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||Me(),this.dashboardUrl=e.dashboardUrl??"https://dashboard.picked.app",this.documentationSiteUrl=e.documentationSiteUrl??"https://docs.picked.app",this.session=Ne(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.setupComponents(),this.precondition=e.precondition,this.condition=e.condition,this.eventBus({type:"load",version:L.getVersion()}),E.logger("info","Picked client initialized.")}start=()=>{pe(this),(async()=>{if(!k.supportsDocument())return;await this.runPluginStartHooks();const r=await this.evaluateGate(this.precondition);this.preconditionPassed=r;let n;r&&(n=await this.evaluateGate(this.condition));const a=r&&n===!0;if(typeof n=="boolean"&&this.session){const d=n;this.session.setIsUser(d),this.eventBus({type:"user_decide",value:d})}if(this.eventBus({type:"initialize"}),a&&C(this),await F.domInteractive(),a&&C(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session){const{id:d,isUser:p,identifiers:u}=this.session;this.eventBus({type:"session",id:d,isUser:p,identifiers:u})}})()};registerFramework=e=>{ue(e,this.frameworks)};registerComponent=(e,r)=>{M(e,r,this.components)};registerPlugin=e=>{ee(this,e,this.plugins);const r=this.plugins[e.name];r?.onStart&&this.pluginStartHooks.push(r.onStart)};registerFeature=(e,r)=>{ve(e,r,this.features)};registerPredicate=(e,r)=>{ye(e,r,this.predicates)};registerField=e=>{je(e,this.fields)};registerAction=(e,r)=>{$e(e,r,this.actions)};registerExperience=e=>{e.component&&M(`experience:${e.id}`,e.component,this.components),Z(e,this.experiences)};getStateSnapshot=()=>_(this);launchExperienceById=async(e,r)=>{this.experiences.launch({id:e,options:r})};openExperienceById=async e=>{this.experiences.open({id:e})};async runPluginStartHooks(){for(const e of this.pluginStartHooks)await e()}async evaluateGate(e){return e===void 0?!0:typeof e=="boolean"?e:await F.evaluateRuleLogic(this,e)===!0}setupPlugins(){this.options.plugins?.forEach(e=>{if(Array.isArray(e)){e.forEach(n=>{this.registerPlugin(n)});return}const r=typeof e=="function"?e():e;if(Array.isArray(r)){r.forEach(n=>this.registerPlugin(n));return}this.registerPlugin(r)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([r,n])=>{const a=typeof n=="function"?n():n;this.registerFeature(r,a)}),this.searchParams.feature&&this.searchParams.feature.forEach(r=>{try{const[n,a]=r.split(":");if(!n||!a)return;let d=a;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)})}setupComponents(){const e=this.options.components;e&&Object.entries(e).forEach(([r,n])=>{this.registerComponent(r,n)})}getPluginConfig=e=>this.plugins[e]??{};renderString=(e,r)=>{const n=this.responses.listStore.getState().reduce((a,d)=>(a[d.fieldId]=d.value,a),{});return Je(e,{...r,responses:n})}}function Ye(t){return{$$type:"lazy-component",load:t}}function Qe(t){return typeof t=="object"&&t!==null&&"$$type"in t&&t.$$type==="lazy-component"}const Xe=t=>{const e=new H(t);return k.bindClient(e),e};exports.evaluateRuleLogic=F.evaluateRuleLogic;exports.isPickedRoot=F.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=H;exports.createClient=Xe;exports.getPickedConfig=q;exports.isLazyLoader=Qe;exports.lazyComponent=Ye;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../../id-BKIWbSTy.cjs"),l={serialize(e){return JSON.stringify(e)},deserialize(e){return JSON.parse(e)}},y=e=>({name:"create-experience",setup:d=>{e.experiences.forEach(o=>{const s=o.serialize(),r=l.deserialize(s);r.component=o.component,d.registerExperience(r),r.fields.forEach(f=>{d.registerField(f)})})}}),z=(e,d)=>({id:p.generateId("node"),experience:d,type:"action",action:e.action,addNext(s){if(!s.node)throw new Error("Cannot connect to node");const r=c({sourceNode:this,destinationNode:s.node,sourceNodeHandle:null},d);d.edges.push(r)},onSuccess(s){if(!s.node)throw new Error("Cannot connect to node");const r=c({sourceNode:this,destinationNode:s.node,sourceNodeHandle:"true"},d);d.edges.push(r)},onFail(s){if(!s.node)throw new Error("Cannot connect to node");const r=c({sourceNode:this,destinationNode:s.node,sourceNodeHandle:"false"},d);d.edges.push(r)},serialize(){return l.serialize({id:this.id,type:this.type,action:this.action})}}),m=e=>({id:e.id??p.generateId("step"),label:e.label,fields:e.fields??[],addField(d){const o="serialize"in d?d:g(d);return this.fields.includes(o)||this.fields.push(o),o}}),b=(e,d)=>{const o={id:e.id??p.generateId("step"),label:e.label,experience:d,fields:e.fields??[],node:null,nextStep(s){return this.experience.addStep(s,this)},nextConditional(s){return this.experience.addConditional(s,this)},addNextExperience(s){return this.experience.addExperience(s,this)},addField(s){return this.experience.addField(s,this)},serialize(){return l.serialize({id:this.id,label:this.label,fieldIds:this.fields.map(s=>s.id)})}};return h({step:o,type:"step"},d),o},h=(e,d)=>{const o={id:p.generateId("node"),experience:d};if(e.type==="step"){const r={...o,type:"step",connectedStep:e.step,serialize(){return l.serialize({id:this.id,type:this.type,stepId:this.connectedStep.id,label:this.connectedStep.label})}};return r.connectedStep.node=r,r}if(e.type==="conditional"){const r={...o,type:"conditional",connectedConditional:e.conditional,serialize(){return l.serialize({id:this.id,type:this.type,conditionalId:this.connectedConditional.id})}};return r.connectedConditional.node=r,r}return e.type==="experience"?{...o,type:"experience",connectedExperience:e.experience,serialize(){return l.serialize({id:this.id,type:this.type,experienceId:this.connectedExperience.id})}}:{...o,type:"origin",serialize(){return l.serialize({id:this.id,type:this.type})}}},c=(e,d)=>({id:p.generateId("edge"),sourceNode:e.sourceNode,sourceNodeHandle:e.sourceNodeHandle,destinationNode:e.destinationNode,experience:d,serialize(){return l.serialize({id:this.id,sourceNodeHandle:this.sourceNodeHandle??void 0,sourceNodeId:this.sourceNode.id,destinationNodeId:this.destinationNode.id})}}),N=(e,d)=>{const o={id:p.generateId("conditional"),label:e.label,condition:e.condition,node:null,experience:d,addTrue(s){if(!this.node||!s.node)throw new Error("todo no node");const r=c({sourceNode:this.node,destinationNode:s.node,sourceNodeHandle:"true"},this.experience);this.experience.edges.push(r)},addFalse(s){if(!this.node||!s.node)throw new Error("todo no node");const r=c({sourceNode:this.node,destinationNode:s.node,sourceNodeHandle:"false"},this.experience);this.experience.edges.push(r)},serialize(){return l.serialize({id:this.id,label:this.label,condition:this.condition})}};return h({conditional:o,type:"conditional"},d),o},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:Array.isArray(e.options)?e.options.map(({id:o,...s})=>({id:o??p.generateId("option"),...s})):e.options??null,dependsOn:e.dependsOn,policies:e.policies,serialize(){const o={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,dependsOn:this.dependsOn,policies:this.policies},s=typeof this.defaultValue=="string"?this.defaultValue:void 0,r=typeof this.defaultValue=="number"?this.defaultValue:void 0,f=typeof this.defaultValue=="boolean"?this.defaultValue:void 0,n=t=>this.options?Array.isArray(this.options)?this.options.map(i=>({id:i.id,label:i.label,description:i.description,value:t(i.value),condition:i.condition})):this.options:null;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 l.serialize({...o,type:"text",multiple:!0,defaultValue:t,options:n(i=>`${i}`)})}return l.serialize({...o,type:"text",multiple:!1,defaultValue:s,options:n(t=>`${t}`)});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 l.serialize({...o,type:"number",multiple:!0,defaultValue:t,options:n(i=>Number(i))})}return l.serialize({...o,type:"number",multiple:!1,defaultValue:r,options:n(t=>Number(t))});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 l.serialize({...o,type:"boolean",multiple:!0,defaultValue:t,options:n(i=>!!i)})}return l.serialize({...o,type:"boolean",multiple:!1,defaultValue:f,options:n(t=>!!t)});case"object":return this.multiple?l.serialize({...o,type:"object",multiple:!0,defaultValue:this.defaultValue,options:n(t=>t)}):l.serialize({...o,type:"object",multiple:!1,defaultValue:this.defaultValue,options:n(t=>t)});default:throw new Error("Unsupported field type")}}}),x=e=>{const d=[],o=[],s=[],r=[],f=[];return{id:e.id,component:e.component,name:e.name,initializeOpen:e.initializeOpen,condition:e.condition,targets:e.targets,steps:d,nodes:o,edges:s,fields:f,conditionals:r,addStep(n,t){let i=t?.node;this.nodes.length===0&&(i=h({type:"origin"},this),this.nodes.push(i));const a="serialize"in n?n:b(n,this);if(i){if(!a.node)throw new Error("todo no node");const u=c({sourceNode:i,destinationNode:a.node,sourceNodeHandle:null},this);this.edges.push(u)}return a.fields.length>0&&a.fields.forEach(u=>{this.fields.includes(u)||this.fields.push(u)}),this.steps.includes(a)||(this.steps.push(a),a.node&&this.nodes.push(a.node)),a},addAction(n,t){let i=t?.node;this.nodes.length===0&&(i=h({type:"origin"},this),this.nodes.push(i));const a="serialize"in n?n:z(n,this);if(i){const u=c({sourceNode:i,destinationNode:a,sourceNodeHandle:null},this);this.edges.push(u)}return this.nodes.push(a),a},addConditional(n,t){let i=t?.node;this.nodes.length===0&&(i=h({type:"origin"},this),this.nodes.push(i));const a="serialize"in n?n:N(n,this);if(i){if(!a.node)throw new Error("todo no node");const u=c({sourceNode:i,destinationNode:a.node,sourceNodeHandle:null},this);this.edges.push(u)}return this.conditionals.includes(a)||(this.conditionals.push(a),a.node&&this.nodes.push(a.node)),a},addExperience(n,t){let i=t?.node;this.nodes.length===0&&(i=h({type:"origin"},this),this.nodes.push(i));const a=h({type:"experience",experience:n},this);if(this.nodes.push(a),i){const u=c({sourceNode:i,destinationNode:a,sourceNodeHandle:null},this);this.edges.push(u)}return n},addField(n,t){const i="serialize"in n?n:g(n);return t&&t.fields.push(i),this.fields.includes(i)||this.fields.push(i),i},serialize(){return l.serialize({id:this.id,component:this.component,name:this.name,initializeOpen:this.initializeOpen,condition:this.condition,targets:this.targets,steps:this.steps.map(n=>l.deserialize(n.serialize())),nodes:this.nodes.map(n=>l.deserialize(n.serialize())),edges:this.edges.map(n=>l.deserialize(n.serialize())),conditionals:this.conditionals.map(n=>l.deserialize(n.serialize())),fields:this.fields.map(n=>l.deserialize(n.serialize()))})}}};exports.createConditional=N;exports.createEdge=c;exports.createExperience=x;exports.createExperiencePlugin=y;exports.createField=g;exports.createNode=h;exports.createStep=m;exports.serialization=l;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../../id-BKIWbSTy.cjs"),l={serialize(e){return JSON.stringify(e)},deserialize(e){return JSON.parse(e)}},y=e=>({name:"create-experience",setup:d=>{e.experiences.forEach(o=>{const s=o.serialize(),r=l.deserialize(s);r.component=o.component,d.registerExperience(r),r.fields.forEach(f=>{d.registerField(f)})})}}),z=(e,d)=>({id:p.generateId("node"),experience:d,type:"action",action:e.action,addNext(s){if(!s.node)throw new Error("Cannot connect to node");const r=c({sourceNode:this,destinationNode:s.node,sourceNodeHandle:null},d);d.edges.push(r)},onSuccess(s){if(!s.node)throw new Error("Cannot connect to node");const r=c({sourceNode:this,destinationNode:s.node,sourceNodeHandle:"true"},d);d.edges.push(r)},onFail(s){if(!s.node)throw new Error("Cannot connect to node");const r=c({sourceNode:this,destinationNode:s.node,sourceNodeHandle:"false"},d);d.edges.push(r)},serialize(){return l.serialize({id:this.id,type:this.type,action:this.action})}}),m=e=>({id:e.id??p.generateId("step"),label:e.label,fields:e.fields??[],addField(d){const o="serialize"in d?d:g(d);return this.fields.includes(o)||this.fields.push(o),o}}),b=(e,d)=>{const o={id:e.id??p.generateId("step"),label:e.label,experience:d,fields:e.fields??[],node:null,nextStep(s){return this.experience.addStep(s,this)},nextConditional(s){return this.experience.addConditional(s,this)},addNextExperience(s){return this.experience.addExperience(s,this)},addField(s){return this.experience.addField(s,this)},serialize(){return l.serialize({id:this.id,label:this.label,fieldIds:this.fields.map(s=>s.id)})}};return h({step:o,type:"step"},d),o},h=(e,d)=>{const o={id:p.generateId("node"),experience:d};if(e.type==="step"){const r={...o,type:"step",connectedStep:e.step,serialize(){return l.serialize({id:this.id,type:this.type,stepId:this.connectedStep.id,label:this.connectedStep.label})}};return r.connectedStep.node=r,r}if(e.type==="conditional"){const r={...o,type:"conditional",connectedConditional:e.conditional,serialize(){return l.serialize({id:this.id,type:this.type,conditionalId:this.connectedConditional.id})}};return r.connectedConditional.node=r,r}return e.type==="experience"?{...o,type:"experience",connectedExperience:e.experience,serialize(){return l.serialize({id:this.id,type:this.type,experienceId:this.connectedExperience.id})}}:{...o,type:"origin",serialize(){return l.serialize({id:this.id,type:this.type})}}},c=(e,d)=>({id:p.generateId("edge"),sourceNode:e.sourceNode,sourceNodeHandle:e.sourceNodeHandle,destinationNode:e.destinationNode,experience:d,serialize(){return l.serialize({id:this.id,sourceNodeHandle:this.sourceNodeHandle??void 0,sourceNodeId:this.sourceNode.id,destinationNodeId:this.destinationNode.id})}}),N=(e,d)=>{const o={id:p.generateId("conditional"),label:e.label,condition:e.condition,node:null,experience:d,addTrue(s){if(!this.node||!s.node)throw new Error("todo no node");const r=c({sourceNode:this.node,destinationNode:s.node,sourceNodeHandle:"true"},this.experience);this.experience.edges.push(r)},addFalse(s){if(!this.node||!s.node)throw new Error("todo no node");const r=c({sourceNode:this.node,destinationNode:s.node,sourceNodeHandle:"false"},this.experience);this.experience.edges.push(r)},serialize(){return l.serialize({id:this.id,label:this.label,condition:this.condition})}};return h({conditional:o,type:"conditional"},d),o},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:Array.isArray(e.options)?e.options.map(({id:o,...s})=>({id:o??p.generateId("option"),...s})):e.options??null,dependsOn:e.dependsOn,policies:e.policies,serialize(){const o={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,dependsOn:this.dependsOn,policies:this.policies},s=typeof this.defaultValue=="string"?this.defaultValue:void 0,r=typeof this.defaultValue=="number"?this.defaultValue:void 0,f=typeof this.defaultValue=="boolean"?this.defaultValue:void 0,n=t=>this.options?Array.isArray(this.options)?this.options.map(i=>({id:i.id,label:i.label,description:i.description,value:t(i.value),condition:i.condition})):this.options:null;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 l.serialize({...o,type:"text",multiple:!0,defaultValue:t,options:n(i=>`${i}`)})}return l.serialize({...o,type:"text",multiple:!1,defaultValue:s,options:n(t=>`${t}`)});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 l.serialize({...o,type:"number",multiple:!0,defaultValue:t,options:n(i=>Number(i))})}return l.serialize({...o,type:"number",multiple:!1,defaultValue:r,options:n(t=>Number(t))});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 l.serialize({...o,type:"boolean",multiple:!0,defaultValue:t,options:n(i=>!!i)})}return l.serialize({...o,type:"boolean",multiple:!1,defaultValue:f,options:n(t=>!!t)});case"object":return this.multiple?l.serialize({...o,type:"object",multiple:!0,defaultValue:this.defaultValue,options:n(t=>t)}):l.serialize({...o,type:"object",multiple:!1,defaultValue:this.defaultValue,options:n(t=>t)});default:throw new Error("Unsupported field type")}}}),x=e=>{const d=[],o=[],s=[],r=[],f=[];return{id:e.id,component:e.component,name:e.name,initializeOpen:e.initializeOpen,condition:e.decide??e.condition,targets:e.targets,steps:d,nodes:o,edges:s,fields:f,conditionals:r,addStep(n,t){let i=t?.node;this.nodes.length===0&&(i=h({type:"origin"},this),this.nodes.push(i));const a="serialize"in n?n:b(n,this);if(i){if(!a.node)throw new Error("todo no node");const u=c({sourceNode:i,destinationNode:a.node,sourceNodeHandle:null},this);this.edges.push(u)}return a.fields.length>0&&a.fields.forEach(u=>{this.fields.includes(u)||this.fields.push(u)}),this.steps.includes(a)||(this.steps.push(a),a.node&&this.nodes.push(a.node)),a},addAction(n,t){let i=t?.node;this.nodes.length===0&&(i=h({type:"origin"},this),this.nodes.push(i));const a="serialize"in n?n:z(n,this);if(i){const u=c({sourceNode:i,destinationNode:a,sourceNodeHandle:null},this);this.edges.push(u)}return this.nodes.push(a),a},addConditional(n,t){let i=t?.node;this.nodes.length===0&&(i=h({type:"origin"},this),this.nodes.push(i));const a="serialize"in n?n:N(n,this);if(i){if(!a.node)throw new Error("todo no node");const u=c({sourceNode:i,destinationNode:a.node,sourceNodeHandle:null},this);this.edges.push(u)}return this.conditionals.includes(a)||(this.conditionals.push(a),a.node&&this.nodes.push(a.node)),a},addExperience(n,t){let i=t?.node;this.nodes.length===0&&(i=h({type:"origin"},this),this.nodes.push(i));const a=h({type:"experience",experience:n},this);if(this.nodes.push(a),i){const u=c({sourceNode:i,destinationNode:a,sourceNodeHandle:null},this);this.edges.push(u)}return n},addField(n,t){const i="serialize"in n?n:g(n);return t&&t.fields.push(i),this.fields.includes(i)||this.fields.push(i),i},serialize(){return l.serialize({id:this.id,component:this.component,name:this.name,initializeOpen:this.initializeOpen,condition:this.condition,targets:this.targets,steps:this.steps.map(n=>l.deserialize(n.serialize())),nodes:this.nodes.map(n=>l.deserialize(n.serialize())),edges:this.edges.map(n=>l.deserialize(n.serialize())),conditionals:this.conditionals.map(n=>l.deserialize(n.serialize())),fields:this.fields.map(n=>l.deserialize(n.serialize()))})}}};exports.createConditional=N;exports.createEdge=c;exports.createExperience=x;exports.createExperiencePlugin=y;exports.createField=g;exports.createNode=h;exports.createStep=m;exports.serialization=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../../api-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../../api-47L967ES.cjs"),a=require("../../../logger-BsmHUUw1.cjs");function d(e){let r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r,16777619);return r>>>0}function g(e){return d(e)%100}function p(e,r){return r<=0?!1:r>=100?!0:e<r}function h(e){return typeof e!="object"||e===null||!("id"in e&&"name"in e&&"enabled"in e&&"weight"in e&&"version"in e)?!1:typeof e.id=="string"&&typeof e.name=="string"&&typeof e.enabled=="boolean"&&typeof e.weight=="number"&&typeof e.version=="number"}function l(e){return typeof e!="object"||e===null||!("features"in e)||!Array.isArray(e.features)?!1:e.features.every(h)}function y(e){const r=e.searchParams["preview-token"];if(r&&r.length>0)return r[0]}function m(e){const r=new Set,n=e.searchParams.feature;if(!n)return r;for(const i of n){const t=i.indexOf(":");t>0&&r.add(i.substring(0,t))}return r}function c(e,r,n){const i=m(e),t=e.session?.id;if(!t)throw new Error("Session ID is required for feature registration");const o=g(t);for(const s of r.features)i.has(s.id)||v(e,s,n,o)}function v(e,r,n,i){e.registerFeature(r.id,{key:`v${r.version}`,name:r.name,storage:n?"session":"local",decide:()=>r.enabled?p(i,r.weight):!1})}function w(){let e;try{e=__PICKED_PROJECT_CONFIG__}catch{return}if(e===void 0)return;let r;if(typeof e=="string")try{r=JSON.parse(e)}catch{a.logger("warn","Build-time project config is not valid JSON");return}else r=e;if(l(r))return r;a.logger("warn","Build-time project config has invalid shape, falling back to runtime fetch")}function j(e){try{const r=new URL(e).hostname;return r==="localhost"||r==="127.0.0.1"||r==="::1"}catch{return!1}}function b(e){if(typeof e!="object"||e===null||!("cause"in e))return!1;const{cause:r}=e;return typeof r!="object"||r===null||!("code"in r)?!1:r.code==="ECONNREFUSED"}async function u(e,r,n){const i=n?.previewToken?`projects/${r}?preview_token=${encodeURIComponent(n.previewToken)}`:`projects/${r}`;let t;try{t=await f.get(e,i,n?.headers)}catch(s){return j(e)&&b(s)||a.logger("warn","Failed to fetch project config",s),null}if(!t.ok)return a.logger("warn",`Project config request failed with status ${t.status.toString()}`),null;let o;try{o=await t.json()}catch{return a.logger("warn","Failed to parse project config response"),null}return l(o)?o:(a.logger("warn","Invalid project config response shape"),null)}function P(e){return{name:"dynamic-experiences",setup:r=>{const n=e?.apiUrl??r.apiUrl;return{onStart:async()=>{const i=y(r);if(i){const s=await u(n,r.projectId,{previewToken:i});s&&c(r,s,!0);return}const t=e?.projectConfig??w();if(t){c(r,t,!1);return}const o=await u(n,r.projectId);o&&c(r,o,!1)}}}}}exports.createClientHeaders=f.createClientHeaders;exports.dynamicExperiencesPlugin=P;exports.fetchProject=u;
|
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { f as zt } from "../experience-instance-DTyL1fNb.js";
|
|
|
5
5
|
import { l as b } from "../logger-C9a75KZn.js";
|
|
6
6
|
import { c as $, l as M, s as O } from "../storage-B2d81EOI.js";
|
|
7
7
|
import { a as Ct } from "../storage-B2d81EOI.js";
|
|
8
|
-
import { p as ce, g as ue } from "../api-
|
|
8
|
+
import { p as ce, g as ue } from "../api-DuHeVrL4.js";
|
|
9
9
|
import { g as de } from "../id-BW-g3y32.js";
|
|
10
10
|
import { i as le } from "../object-CJssU1Pm.js";
|
|
11
11
|
import { s as H, a as G, b as pe, c as fe, d as ge } from "../supports-8YT4QKI7.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as l } from "../../../api-
|
|
2
|
-
import { c as S } from "../../../api-
|
|
1
|
+
import { a as l } from "../../../api-DuHeVrL4.js";
|
|
2
|
+
import { c as S } from "../../../api-DuHeVrL4.js";
|
|
3
3
|
import { l as a } from "../../../logger-C9a75KZn.js";
|
|
4
4
|
function d(e) {
|
|
5
5
|
let r = 2166136261;
|
|
@@ -175,6 +175,10 @@ export interface CreateExperienceOptions {
|
|
|
175
175
|
id: string;
|
|
176
176
|
name: string;
|
|
177
177
|
condition?: LogicRule | LogicValue;
|
|
178
|
+
/**
|
|
179
|
+
* Alias for `condition`. When both are provided, `decide` takes precedence.
|
|
180
|
+
*/
|
|
181
|
+
decide?: LogicRule | LogicValue;
|
|
178
182
|
initializeOpen?: LogicRule | LogicValue;
|
|
179
183
|
targets: ExperienceTarget[];
|
|
180
184
|
component?: AdaptedComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-experience.d.ts","sourceRoot":"","sources":["../../../../src/plugins/create-experience/create-experience.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAEV,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAGjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EACV,KAAK,EAOL,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACb,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEhE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAA;AAE7E,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAC9B;AAED,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,UAAU,EAAE,sBAAsB,CAAA;IAClC,QAAQ,EAAE,CAAC,WAAW,EAAE,iBAAiB,GAAG,gBAAgB,KAAK,gBAAgB,CAAA;IACjF,eAAe,EAAE,CACf,kBAAkB,EAAE,wBAAwB,GAAG,uBAAuB,KACnE,uBAAuB,CAAA;IAC5B,iBAAiB,EAAE,CAAC,U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AED,eAAO,MAAM,kBAAkB,GAC7B,aAAa,iBAAiB,GAAG,UAAU,EAC3C,YAAY,sBAAsB,KACjC,gBA+BF,CAAA;AAED,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBA0EF,CAAA;AAED,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBAkBF,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,oBAAoB,wBAAwB,EAC5C,YAAY,sBAAsB,KACjC,uBA4CF,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EACzD,cAAc,kBAAkB,CAAC,CAAC,CAAC,KAClC,iBAAiB,CAAC,CAAC,CA4LrB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,YAAY,uBAAuB,KAAG,sBAsLtE,CAAA"}
|
|
1
|
+
{"version":3,"file":"create-experience.d.ts","sourceRoot":"","sources":["../../../../src/plugins/create-experience/create-experience.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAEV,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAGjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EACV,KAAK,EAOL,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACb,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEhE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAA;AAE7E,MAAM,WAAW,QAAQ;IAC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