@picked/client 0.0.26-next.1 → 0.0.26-next.2
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/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty;var V=(t,e,r)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var h=(t,e,r)=>V(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("effector"),v=require("@withease/factories"),I=require("../experience-instance-DjjpHk0t.cjs"),F=require("../logger-BsmHUUw1.cjs"),w=require("../storage-YlR83AWP.cjs"),N=require("../id-BKIWbSTy.cjs"),_=require("../object-BbFTsGh3.cjs"),S=require("../supports-YvpQZxbh.cjs"),z=f.createDomain("experience"),q=v.createFactory(({client:t,experience:e})=>{const r=z.store(e),n=f.createApi(r,{merge(d,y){return{...d,...y.experience}}}),i=r.map(d=>({name:d.name,decisionLogic:d.condition??d.decide,targetSelectors:d.targets,initializeOpenLogic:e.initializeOpen})),a=t.components.listStore.map(d=>d.find(y=>y.name===`experience:${e.id}`)||d.find(y=>y.name==="experience"),{skipVoid:!1}),s=r.map(d=>({steps:d.steps,nodes:d.nodes,edges:d.edges,conditionals:d.conditionals})),o=e.actions??[];return{id:e.id,configStore:i,treeStore:s,componentStore:a,actions:o,merge:n.merge}});function K(t){return v.invoke(q,t)}const W=v.createFactory(({client:t})=>{const e=z.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.id]:o}}});function n(s){const o=e.getState()[s.id];if(o){o.merge({experience:s,strategy:"override"});return}const d=K({client:t,experience:s});r.register(d)}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getById:a,listStore:i}});function H(t){return v.invoke(W,t)}const G=(t,e)=>{e.register(t)},U=(t,e)=>{const{targetSelectors:r}=e.configStore.getState(),n=I.getTargetElements(r,e.id);n.forEach(({elements:a})=>a.forEach(s=>I.tagTargetElement(s,e.id))),I.createAppHosts(n,e.id).forEach(a=>{t.experienceInstances.spawn(e,a)})},D=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await Y(t,e)&&U(t,e)}))},Y=async(t,e)=>{const{decisionLogic:r,targetSelectors:n}=e.configStore.getState();return I.getTargetElements(n,e.id).length<1||n.length===0?!1:r&&I.isRulesLogic(r)?await I.evaluateRuleLogic(t,r)===!0:!0},J=(t,e,r)=>{const n=e.name,i=e.setup(t);if(i){const a=r[n]??{};r[n]=Object.freeze({...a,...i})}},Q=f.createDomain("component"),X=v.createFactory(({client:t,component:e,name:r})=>{const n=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:n}});function Z(t){return v.invoke(X,t)}const ee=v.createFactory(({client:t})=>{const e=Q.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.name]:o}}});function n(s,o){e.getState()[s]&&F.logger("warn",`Component '${s}' already registered. Registering again will override the previous registration.`);const y=Z({client:t,name:s,component:o});r.register(y)}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getByName:a,listStore:i}});function te(t){return v.invoke(ee,t)}const B=(t,e,r)=>{r.register(t,e)},re=f.createDomain("framework"),ne=v.createFactory(({client:t})=>{const e=re.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.name]:o.framework}}});function n(s,o){e.getState()[s]&&F.logger("warn",`Framework '${s}' already registered. Registering again will override the previous registration.`),r.register({name:s,framework:o})}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getByName:a,listStore:i}});function se(t){return v.invoke(ne,t)}const ie=(t,e)=>{e.register(t.name,t)},oe=6e3,ae=w.createStorageKey("last_ping","global"),ce=t=>`${t}/api/v1/ping`,ue=async t=>{try{const e=Date.now(),r=w.localStore.get(ae);let n=0;if(r.isSet()&&(n=r.json()??0),n&&e-n<oe)return!0;const i=ce(t.apiUrl),a={projectId:t.projectId,path:window.location.pathname},s=JSON.stringify(a),o={"Content-Type":"application/json"},d=document.getElementById("picked_script"),y=d==null?void 0:d.dataset.verceltoken;y&&(o["x-vercel-protection-bypass"]=y);const l=(await fetch(i,{method:"POST",headers:o,body:s})).ok;return l&&r.set(e),l}catch(e){return F.logger("error",e),!1}};function de(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 le=f.createDomain("predicate"),pe=v.createFactory(({client:t})=>{const e=le.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.name]:{name:o.name,predicate:o.predicate}}}});function n(s,o){e.getState()[s]&&F.logger("warn",`Predicate '${s}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:s,predicate:o}))}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getByName:a,listStore:i}});function ge(t){return v.invoke(pe,t)}const fe=(t,e,r)=>{r.register(t,e)},C=f.createDomain("feature"),me=v.createFactory(({client:t})=>{const e=C.store({}),r=C.store([]),n=f.createApi(e,{register(l,u){return{...l,[u.id]:u.feature}}});function i(l,u){e.getState()[l]&&F.logger("warn",`Feature '${l}' already registered. Registering again will override the previous registration.`);const p={id:l,feature:{...u,id:l}};n.register(Object.freeze({id:l,feature:p}))}const a=f.createEffect(async({id:l,key:u,storage:c="local"})=>{const p=w.createStorageKey(`feature:${l}:${u}`,"global"),g=(c==="session"?w.sessionStore:w.localStore).get(p).boolean();return g===null?null:{id:l,key:u,bucket:g,storage:c}}),s=f.createEffect(l=>{if(!l)return null;const u=w.createStorageKey(`feature:${l.id}:${l.key}`,"global");(l.storage==="session"?w.sessionStore:w.localStore).set(u,l.bucket)}),o=new Map,d=f.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:l,resolvedFeaturesStore:u},{id:c,decide:p,key:m})=>{const g=u.find(P=>P.id===c&&P.key===m);if(g)return g;const k=l[c];if(!k)throw new Error(`Feature with id '${c}' not found`);const E=o.get(`${c}:${m}`);if(E!==void 0){const P=await E;return{id:k.id,bucket:P,key:m,storage:k.feature.storage}}const j=p();o.set(`${c}:${m}`,j);const x=await j;return{id:k.id,bucket:x,key:m,storage:k.feature.storage}}});f.sample({clock:n.register,fn:l=>{const{id:u,feature:c}=l;return{id:u,key:c.feature.key,storage:c.feature.storage}},target:a}),f.sample({source:e,clock:d.doneData,fn:(l,u)=>{var k;const{id:c,bucket:p,storage:m}=u,g=(k=l[c])==null?void 0:k.feature.key;return g?{key:g,id:c,bucket:p,storage:m}:null},target:s});const y=f.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:l,resolvedFeaturesStore:u})=>Object.values(l).map(c=>{const p=u.find(m=>m.id===c.id&&m.key===c.feature.key);return p?{id:c.id,name:c.feature.name,key:c.feature.key,getBucket:()=>({id:c.id,bucket:p.bucket}),isResolved:!0}:{id:c.id,name:c.feature.name,key:c.feature.key,getBucket:async()=>await d(c.feature),isResolved:!1}}));f.sample({clock:d.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:l},{id:u,key:c})=>!l.some(m=>m.id===u&&m.key===c),fn:(l,u)=>u,target:t.eventBus.prepend(l=>({type:"feature_decide",feature:l}))}),f.sample({clock:[a.doneData,d.doneData],source:r,fn:(l,u)=>!u||l.some(p=>p.id===u.id&&p.key===u.key)?l:[...l,u],target:r});function b(l){return e.map(u=>u[l],{skipVoid:!1})}return{register:i,getByName:b,listStore:y}});function he(t){return v.invoke(me,t)}const ye=(t,e,r)=>{r.register(t,e)},R=f.createDomain("history");function $(t,e){return{id:N.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ve=v.createFactory(()=>{const t=R.store({entries:[]}),e=R.event(),r=R.event(),n=R.event(),i=R.event();t.on(e,(s,o)=>({entries:[...s.entries,$(o.experienceId,o.node)]})),t.on(r,(s,o)=>({entries:[...s.entries.slice(0,-1),$(o.experienceId,o.node)]})),t.on(i,(s,o)=>o);function a(s,o){const d={lastStepIndex:-1,secondLastStepIndex:-1};for(let y=s.length-1;y>=0;y--){const b=s[y],l=b==null?void 0:b.node;if(!(!l||!I.isStepNode(l))&&!(o&&(b==null?void 0:b.experienceId)!==o))if(d.lastStepIndex===-1)d.lastStepIndex=y;else{d.secondLastStepIndex=y;break}}return d}return t.on(n,(s,o)=>{const{secondLastStepIndex:d}=a(s.entries,o.experienceId),y=d!==-1?s.entries.slice(0,d+1):s.entries;return{...s,entries:y}}),{push:e,replace:r,back:n,restore:i,entriesStore:t.map(s=>s.entries)}});function Se(){return v.invoke(ve)}const ke=()=>f.createEvent(),we=f.createDomain("field"),Ie=v.createFactory(()=>{const t=we.store({}),e=f.createApi(t,{register(s,o){return{...s,[o.field.id]:o.field}}});function r(s){e.register({field:s})}const n=t.map(s=>Object.values(s));function i(s){return t.map(o=>o[s]||null)}function a(s){return t.map(o=>Object.values(o).find(d=>d.name===s)||null)}return{register:r,getById:i,listStore:n,getByName:a}});function be(){return v.invoke(Ie)}const Fe=(t,e)=>{e.register(t)},Ee=f.createDomain("action"),xe=v.createFactory(()=>{const t=Ee.store({}),e=f.createApi(t,{register(a,s){return{...a,[s.name]:{name:s.name,action:s.action}}}});function r(a,s){e.register({name:a,action:s})}const n=t.map(a=>Object.values(a));function i(a){return t.map(s=>s[a],{skipVoid:!1})}return{register:r,getByName:i,listStore:n}});function Re(){return v.invoke(xe)}const je=(t,e,r)=>{r.register(t,e)};function O(t){return typeof t>"u"||t===null||t===""||Array.isArray(t)&&!t.length}const Pe=f.createDomain("response"),Ae=v.createFactory(({client:t})=>{const e=Pe.store({}),r=f.createEvent(),n=f.createEvent(),i=f.createApi(e,{register(u,c){return{...u,[c.fieldId]:c.response}},registerBatch(u,c){return{...u,...c}},clear(u,c){const{[c]:p,...m}=u;return m},clearAll(){return{}}});function a(u,c){i.register({fieldId:u,response:c})}async function s(u){const c=[];return await Promise.allSettled(Object.entries(u).map(async([p,m])=>{let g=m;const k=t.fields.getById(p).getState();if(!k){c.push({fieldId:p,userMessage:`Field '${p}' not found`,systemMessage:`No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:g});return}if(k.multiple&&(typeof g=="string"||typeof g=="number"||typeof g=="boolean")&&(g=[g]),k.validation&&!_.isEmpty(k.validation)&&!O(g)){const E=await I.evaluateRuleLogic(t,k.validation,{$input:g});if(typeof E=="string"){c.push({fieldId:p,userMessage:E,systemMessage:`Field validation resulted in an error: ${E}.`,value:g});return}if(E===!1){c.push({fieldId:p,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:g});return}}if(k.required&&O(g)){c.push({fieldId:p,userMessage:"This field is required",systemMessage:"Field is required.",value:g});return}if(!k.multiple&&Array.isArray(g)&&g.length>1){c.push({fieldId:p,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:g});return}if(k.options){const E=k.options.map(x=>x.value),j=Array.isArray(g)?g:[g];Array.isArray(g)&&(j.every(x=>E.includes(x))||c.push({fieldId:p,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${E.join(", ")}`,value:g}))}})),{responsesToCommit:u,validationErrors:c}}async function o(u){const{responsesToCommit:c,validationErrors:p}=await s(u);return p.length?{errors:p}:(i.registerBatch(c),{errors:[]})}const d=e.map(u=>u),y=e.map(u=>Object.keys(u).map(p=>({fieldId:p,value:u[p]})));function b(u){const c=t.fields.getById(u),p=e.map(m=>m[u]||null);return f.combine({f:c,r:p},({f:m,r:g})=>g||(m!=null&&m.defaultValue?m.defaultValue:null))}function l(u){const c=t.fields.getByName(u);return f.combine({f:c,s:e},({f:p,s:m})=>{const g=p&&m[p.id]||null;return g||(p!=null&&p.defaultValue?p.defaultValue:null)})}return f.sample({clock:r,target:i.clearAll}),f.sample({clock:n,target:i.clear}),{register:a,clearAll:r,clear:n,commit:o,getResponsesToCommit:s,listStore:y,getAllStore:d,getByFieldId:b,getByFieldName:l}});function De(t){return v.invoke(Ae,t)}const Be=()=>"0.0.26-next.1";function Ce(){if(S.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 $e(){if(!S.supportsWindow())return{};const t=new URLSearchParams(window.location.search),e={},r=new Set;for(const[i]of t.entries())i.startsWith("picked-")&&r.add(i);for(const i of r){const a=i.replace("picked-","");e[a]=t.getAll(i)}const n=w.createStorageKey("s");if(r.size>0)w.sessionStore.set(n,e);else{const i=w.sessionStore.get(n);if(i)return i.json()||{}}return e}function Oe(){if(S.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 ze=w.createStorageKey("session","global"),Ue=()=>{const t=w.localStore.get(ze);let e;t.isSet()&&(e=t.json());const r=i=>t.set({id:i.id,isUser:i.isUser,identifiers:i.identifiers}),n={id:(e==null?void 0:e.id)??Oe(),isUser:(e==null?void 0:e.isUser)??void 0,identifiers:(e==null?void 0:e.identifiers)??void 0,setIsUser(i){this.isUser=i,r(this)},setIdentifier(i,a){this.identifiers={...this.identifiers,[i]:a},r(this)},removeIdentifier(i){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([a])=>a!==i)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,r(this))}};return r(n),n},Le=()=>S.supportsLocalStorage()?Ue():null;function L(){if(S.supportsWindow())return globalThis.window.pickedConfig}function Te(){if(!S.supportsWindow())return;const t=L(),e=t==null?void 0:t.organizationId,r=t==null?void 0:t.projectId;return e&&r?{organizationId:e,projectId:r}:void 0}function Me(){if(!S.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 Ve(t){const{organizationId:e,projectId:r}=t;if(e&&r)return{organizationId:e,projectId:r};const n=Te();if(n)return n;const i=Me();if(i)return i;throw new Error(`organizationId and projectId are required. You can provide them via one of:
|
|
1
|
+
"use strict";var M=Object.defineProperty;var V=(t,e,r)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var y=(t,e,r)=>V(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("effector"),v=require("@withease/factories"),I=require("../experience-instance-DjjpHk0t.cjs"),F=require("../logger-BsmHUUw1.cjs"),w=require("../storage-YlR83AWP.cjs"),N=require("../id-BKIWbSTy.cjs"),_=require("../object-BbFTsGh3.cjs"),S=require("../supports-YvpQZxbh.cjs"),z=f.createDomain("experience"),q=v.createFactory(({client:t,experience:e})=>{const r=z.store(e),n=f.createApi(r,{merge(c,m){return{...c,...m.experience}}}),i=r.map(c=>({name:c.name,decisionLogic:c.condition??c.decide,targetSelectors:c.targets,initializeOpenLogic:e.initializeOpen})),a=t.components.listStore.map(c=>c.find(m=>m.name===`experience:${e.id}`)||c.find(m=>m.name==="experience"),{skipVoid:!1}),s=r.map(c=>({steps:c.steps,nodes:c.nodes,edges:c.edges,conditionals:c.conditionals})),o=e.actions??[];return{id:e.id,configStore:i,treeStore:s,componentStore:a,actions:o,merge:n.merge}});function K(t){return v.invoke(q,t)}const W=v.createFactory(({client:t})=>{const e=z.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.id]:o}}});function n(s){const o=e.getState()[s.id];if(o){o.merge({experience:s,strategy:"override"});return}const c=K({client:t,experience:s});r.register(c)}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getById:a,listStore:i}});function H(t){return v.invoke(W,t)}const G=(t,e)=>{e.register(t)},U=(t,e)=>{const{targetSelectors:r}=e.configStore.getState(),n=I.getTargetElements(r,e.id);n.forEach(({elements:a})=>a.forEach(s=>I.tagTargetElement(s,e.id))),I.createAppHosts(n,e.id).forEach(a=>{t.experienceInstances.spawn(e,a)})},D=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await Y(t,e)&&U(t,e)}))},Y=async(t,e)=>{const{decisionLogic:r,targetSelectors:n}=e.configStore.getState();return I.getTargetElements(n,e.id).length<1||n.length===0?!1:r&&I.isRulesLogic(r)?await I.evaluateRuleLogic(t,r)===!0:!0},J=(t,e,r)=>{const n=e.name,i=e.setup(t);if(i){const a=r[n]??{};r[n]=Object.freeze({...a,...i})}},Q=f.createDomain("component"),X=v.createFactory(({client:t,component:e,name:r})=>{const n=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:n}});function Z(t){return v.invoke(X,t)}const ee=v.createFactory(({client:t})=>{const e=Q.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.name]:o}}});function n(s,o){e.getState()[s]&&F.logger("warn",`Component '${s}' already registered. Registering again will override the previous registration.`);const m=Z({client:t,name:s,component:o});r.register(m)}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getByName:a,listStore:i}});function te(t){return v.invoke(ee,t)}const B=(t,e,r)=>{r.register(t,e)},re=f.createDomain("framework"),ne=v.createFactory(({client:t})=>{const e=re.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.name]:o.framework}}});function n(s,o){e.getState()[s]&&F.logger("warn",`Framework '${s}' already registered. Registering again will override the previous registration.`),r.register({name:s,framework:o})}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getByName:a,listStore:i}});function se(t){return v.invoke(ne,t)}const ie=(t,e)=>{e.register(t.name,t)},oe=6e3,ae=w.createStorageKey("last_ping","global"),ce=t=>`${t}/api/v1/ping`,ue=async t=>{try{const e=Date.now(),r=w.localStore.get(ae);let n=0;if(r.isSet()&&(n=r.json()??0),n&&e-n<oe)return!0;const i=ce(t.apiUrl),a={projectId:t.projectId,path:window.location.pathname},s=JSON.stringify(a),o={"Content-Type":"application/json"},c=document.getElementById("picked_script"),m=c==null?void 0:c.dataset.verceltoken;m&&(o["x-vercel-protection-bypass"]=m);const l=(await fetch(i,{method:"POST",headers:o,body:s})).ok;return l&&r.set(e),l}catch(e){return F.logger("error",e),!1}};function de(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 le=f.createDomain("predicate"),pe=v.createFactory(({client:t})=>{const e=le.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.name]:{name:o.name,predicate:o.predicate}}}});function n(s,o){e.getState()[s]&&F.logger("warn",`Predicate '${s}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:s,predicate:o}))}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getByName:a,listStore:i}});function ge(t){return v.invoke(pe,t)}const fe=(t,e,r)=>{r.register(t,e)},C=f.createDomain("feature"),me=v.createFactory(({client:t})=>{const e=C.store({}),r=C.store([]),n=f.createApi(e,{register(l,d){return{...l,[d.id]:d.feature}}});function i(l,d){e.getState()[l]&&F.logger("warn",`Feature '${l}' already registered. Registering again will override the previous registration.`);const p={id:l,feature:{...d,id:l}};n.register(Object.freeze({id:l,feature:p}))}const a=f.createEffect(async({id:l,key:d,storage:u="local"})=>{const p=w.createStorageKey(`feature:${l}:${d}`,"global"),g=(u==="session"?w.sessionStore:w.localStore).get(p).boolean();return g===null?null:{id:l,key:d,bucket:g,storage:u}}),s=f.createEffect(l=>{if(!l)return null;const d=w.createStorageKey(`feature:${l.id}:${l.key}`,"global");(l.storage==="session"?w.sessionStore:w.localStore).set(d,l.bucket)}),o=new Map,c=f.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:l,resolvedFeaturesStore:d},{id:u,decide:p,key:h})=>{const g=d.find(P=>P.id===u&&P.key===h);if(g)return g;const k=l[u];if(!k)throw new Error(`Feature with id '${u}' not found`);const E=o.get(`${u}:${h}`);if(E!==void 0){const P=await E;return{id:k.id,bucket:P,key:h,storage:k.feature.storage}}const R=p();o.set(`${u}:${h}`,R);const x=await R;return{id:k.id,bucket:x,key:h,storage:k.feature.storage}}});f.sample({clock:n.register,fn:l=>{const{id:d,feature:u}=l;return{id:d,key:u.feature.key,storage:u.feature.storage}},target:a}),f.sample({source:e,clock:c.doneData,fn:(l,d)=>{var k;const{id:u,bucket:p,storage:h}=d,g=(k=l[u])==null?void 0:k.feature.key;return g?{key:g,id:u,bucket:p,storage:h}:null},target:s});const m=f.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:l,resolvedFeaturesStore:d})=>Object.values(l).map(u=>{const p=d.find(h=>h.id===u.id&&h.key===u.feature.key);return p?{id:u.id,name:u.feature.name,key:u.feature.key,getBucket:()=>({id:u.id,bucket:p.bucket}),isResolved:!0}:{id:u.id,name:u.feature.name,key:u.feature.key,getBucket:async()=>await c(u.feature),isResolved:!1}}));f.sample({clock:c.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:l},{id:d,key:u})=>!l.some(h=>h.id===d&&h.key===u),fn:(l,d)=>d,target:t.eventBus.prepend(l=>({type:"feature_decide",feature:l}))}),f.sample({clock:[a.doneData,c.doneData],source:r,fn:(l,d)=>!d||l.some(p=>p.id===d.id&&p.key===d.key)?l:[...l,d],target:r});function b(l){return e.map(d=>d[l],{skipVoid:!1})}return{register:i,getByName:b,listStore:m}});function he(t){return v.invoke(me,t)}const ye=(t,e,r)=>{r.register(t,e)},j=f.createDomain("history");function O(t,e){return{id:N.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ve=v.createFactory(()=>{const t=j.store({entries:[]}),e=j.event(),r=j.event(),n=j.event(),i=j.event();t.on(e,(s,o)=>({entries:[...s.entries,O(o.experienceId,o.node)]})),t.on(r,(s,o)=>({entries:[...s.entries.slice(0,-1),O(o.experienceId,o.node)]})),t.on(i,(s,o)=>o);function a(s,o){const c={lastStepIndex:-1,secondLastStepIndex:-1};for(let m=s.length-1;m>=0;m--){const b=s[m],l=b==null?void 0:b.node;if(!(!l||!I.isStepNode(l))&&!(o&&(b==null?void 0:b.experienceId)!==o))if(c.lastStepIndex===-1)c.lastStepIndex=m;else{c.secondLastStepIndex=m;break}}return c}return t.on(n,(s,o)=>{const{secondLastStepIndex:c}=a(s.entries,o.experienceId),m=c!==-1?s.entries.slice(0,c+1):s.entries;return{...s,entries:m}}),{push:e,replace:r,back:n,restore:i,entriesStore:t.map(s=>s.entries)}});function Se(){return v.invoke(ve)}const ke=()=>f.createEvent(),we=f.createDomain("field"),Ie=v.createFactory(()=>{const t=we.store({}),e=f.createApi(t,{register(o,c){return{...o,[c.field.id]:c.field}}});function r(o){e.register({field:o})}function n(o,c){const m=a(o).getState();if(!m)return;const b=Object.assign({},m,{...c});e.register({field:{...b}})}const i=t.map(o=>Object.values(o));function a(o){return t.map(c=>c[o]||null)}function s(o){return t.map(c=>Object.values(c).find(m=>m.name===o)||null)}return{register:r,update:n,getById:a,listStore:i,getByName:s}});function be(){return v.invoke(Ie)}const Fe=(t,e)=>{e.register(t)},Ee=f.createDomain("action"),xe=v.createFactory(()=>{const t=Ee.store({}),e=f.createApi(t,{register(a,s){return{...a,[s.name]:{name:s.name,action:s.action}}}});function r(a,s){e.register({name:a,action:s})}const n=t.map(a=>Object.values(a));function i(a){return t.map(s=>s[a],{skipVoid:!1})}return{register:r,getByName:i,listStore:n}});function je(){return v.invoke(xe)}const Re=(t,e,r)=>{r.register(t,e)};function $(t){return typeof t>"u"||t===null||t===""||Array.isArray(t)&&!t.length}const Pe=f.createDomain("response"),Ae=v.createFactory(({client:t})=>{const e=Pe.store({}),r=f.createEvent(),n=f.createEvent(),i=f.createApi(e,{register(d,u){return{...d,[u.fieldId]:u.response}},registerBatch(d,u){return{...d,...u}},clear(d,u){const{[u]:p,...h}=d;return h},clearAll(){return{}}});function a(d,u){i.register({fieldId:d,response:u})}async function s(d){const u=[];return await Promise.allSettled(Object.entries(d).map(async([p,h])=>{let g=h;const k=t.fields.getById(p).getState();if(!k){u.push({fieldId:p,userMessage:`Field '${p}' not found`,systemMessage:`No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:g});return}if(k.multiple&&(typeof g=="string"||typeof g=="number"||typeof g=="boolean")&&(g=[g]),k.validation&&!_.isEmpty(k.validation)&&!$(g)){const E=await I.evaluateRuleLogic(t,k.validation,{$input:g});if(typeof E=="string"){u.push({fieldId:p,userMessage:E,systemMessage:`Field validation resulted in an error: ${E}.`,value:g});return}if(E===!1){u.push({fieldId:p,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:g});return}}if(k.required&&$(g)){u.push({fieldId:p,userMessage:"This field is required",systemMessage:"Field is required.",value:g});return}if(!k.multiple&&Array.isArray(g)&&g.length>1){u.push({fieldId:p,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:g});return}if(k.options){const E=k.options.map(x=>x.value),R=Array.isArray(g)?g:[g];Array.isArray(g)&&(R.every(x=>E.includes(x))||u.push({fieldId:p,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${E.join(", ")}`,value:g}))}})),{responsesToCommit:d,validationErrors:u}}async function o(d){const{responsesToCommit:u,validationErrors:p}=await s(d);return p.length?{errors:p}:(i.registerBatch(u),{errors:[]})}const c=e.map(d=>d),m=e.map(d=>Object.keys(d).map(p=>({fieldId:p,value:d[p]})));function b(d){const u=t.fields.getById(d),p=e.map(h=>h[d]||null);return f.combine({f:u,r:p},({f:h,r:g})=>g||(h!=null&&h.defaultValue?h.defaultValue:null))}function l(d){const u=t.fields.getByName(d);return f.combine({f:u,s:e},({f:p,s:h})=>{const g=p&&h[p.id]||null;return g||(p!=null&&p.defaultValue?p.defaultValue:null)})}return f.sample({clock:r,target:i.clearAll}),f.sample({clock:n,target:i.clear}),{register:a,clearAll:r,clear:n,commit:o,getResponsesToCommit:s,listStore:m,getAllStore:c,getByFieldId:b,getByFieldName:l}});function De(t){return v.invoke(Ae,t)}const Be=()=>"0.0.26-next.2";function Ce(){if(S.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 Oe(){if(!S.supportsWindow())return{};const t=new URLSearchParams(window.location.search),e={},r=new Set;for(const[i]of t.entries())i.startsWith("picked-")&&r.add(i);for(const i of r){const a=i.replace("picked-","");e[a]=t.getAll(i)}const n=w.createStorageKey("s");if(r.size>0)w.sessionStore.set(n,e);else{const i=w.sessionStore.get(n);if(i)return i.json()||{}}return e}function $e(){if(S.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 ze=w.createStorageKey("session","global"),Ue=()=>{const t=w.localStore.get(ze);let e;t.isSet()&&(e=t.json());const r=i=>t.set({id:i.id,isUser:i.isUser,identifiers:i.identifiers}),n={id:(e==null?void 0:e.id)??$e(),isUser:(e==null?void 0:e.isUser)??void 0,identifiers:(e==null?void 0:e.identifiers)??void 0,setIsUser(i){this.isUser=i,r(this)},setIdentifier(i,a){this.identifiers={...this.identifiers,[i]:a},r(this)},removeIdentifier(i){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([a])=>a!==i)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,r(this))}};return r(n),n},Le=()=>S.supportsLocalStorage()?Ue():null;function L(){if(S.supportsWindow())return globalThis.window.pickedConfig}function Te(){if(!S.supportsWindow())return;const t=L(),e=t==null?void 0:t.organizationId,r=t==null?void 0:t.projectId;return e&&r?{organizationId:e,projectId:r}:void 0}function Me(){if(!S.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 Ve(t){const{organizationId:e,projectId:r}=t;if(e&&r)return{organizationId:e,projectId:r};const n=Te();if(n)return n;const i=Me();if(i)return i;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.`)}class A{constructor(e){
|
|
4
|
+
(3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`)}class A{constructor(e){y(this,"options");y(this,"isReady",!1);y(this,"project");y(this,"plugins",{});y(this,"eventBus",ke());y(this,"organizationId");y(this,"projectId");y(this,"apiUrl");y(this,"session");y(this,"precondition");y(this,"condition");y(this,"searchParams",Oe());y(this,"history",Se());y(this,"components",te({client:this}));y(this,"experienceInstances",I.createExperienceInstanceIndex({client:this}));y(this,"experiences",H({client:this}));y(this,"frameworks",se({client:this}));y(this,"predicates",ge({client:this}));y(this,"features",he({client:this}));y(this,"responses",De({client:this}));y(this,"fields",be());y(this,"actions",je());F.logger("info","Picked client initializing.");const{organizationId:r,projectId:n}=Ve(e);this.organizationId=r,this.projectId=n,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||Ce(),this.session=Le(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.precondition=e.precondition,this.condition=e.condition,this.eventBus({type:"load",version:Be()}),F.logger("info","Picked client initialized.")}start(){ue(this),(async()=>{if(!S.supportsDocument())return;let r;typeof this.precondition>"u"?r=!0:typeof this.precondition=="boolean"?r=this.precondition:r=await I.evaluateRuleLogic(this,this.precondition)===!0;let n;r&&(this.condition===void 0?n=!0:typeof this.condition=="boolean"?n=this.condition:n=await I.evaluateRuleLogic(this,this.condition)===!0);const i=r&&n===!0;if(typeof n=="boolean"&&this.session){const a=n;this.session.setIsUser(a),this.eventBus({type:"user_decide",value:a})}this.eventBus({type:"initialize"}),document.body&&i&&D(this),await I.domInteractive(),i&&D(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session&&this.eventBus({type:"session",...this.session})})()}registerFramework(e){ie(e,this.frameworks)}registerComponent(e,r){B(e,r,this.components)}registerPlugin(e){J(this,e,this.plugins)}registerFeature(e,r){ye(e,r,this.features)}registerPredicate(e,r){fe(e,r,this.predicates)}registerField(e){Fe(e,this.fields)}registerAction(e,r){Re(e,r,this.actions)}registerExperience(e){e.component&&B(`experience:${e.id}`,e.component,this.components),G(e,this.experiences)}getStateSnapshot(){return de(this)}async launchExperienceById(e){const r=this.experiences.getById(e).getState();if(!r){F.logger("warn",`Experience with id '${e}' not found.`);return}U(this,r)}setupPlugins(){var e;(e=this.options.plugins)==null||e.forEach(r=>{if(Array.isArray(r)){r.forEach(i=>{this.registerPlugin(i)});return}const n=typeof r=="function"?r():r;if(Array.isArray(n)){n.forEach(i=>this.registerPlugin(i));return}this.registerPlugin(n)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([r,n])=>{const i=typeof n=="function"?n():n;this.registerFeature(r,i)}),this.searchParams.feature&&this.searchParams.feature.forEach(r=>{try{const[n,i]=r.split(":");if(!n||!i)return;let a=i;a==="true"&&(a=!0),a==="false"&&(a=!1),this.registerFeature(n,{key:`${a}`,name:n,decide:()=>a,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([r,n])=>{if(typeof n!="function"){F.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"){F.logger("warn",`Action "${r}" is not a function.`);return}this.registerAction(r,n)})}getPluginConfig(e){return this.plugins[e]??{}}}y(A,"logger",F.logger);function T(t){var e;return((e=t.options)==null?void 0:e.some(r=>"condition"in r))??!1}function Ne(t){return t.some(e=>e.condition||T(e))}async function _e(t,e){return e.length===0||!Ne(e)?e:(await Promise.all(e.map(async n=>{if(!(n.condition?await I.evaluateRuleLogic(t,n.condition):!0))return null;if(!n.options||!T(n))return n;const s=(await Promise.all(n.options.map(async c=>c.condition?await I.evaluateRuleLogic(t,c.condition)?c:null:c))).filter(c=>c!==null);return s.length===n.options.length?n:s.length===0?null:{...n,options:s}}))).filter(n=>n!==null)}const qe=t=>{const e=new A(t);return S.bindClient(e),e};exports.evaluateRuleLogic=I.evaluateRuleLogic;exports.isPickedRoot=I.isPickedRoot;exports.createStorageKey=w.createStorageKey;exports.localStore=w.localStore;exports.sessionStore=w.sessionStore;exports.subscribe=w.subscribe;exports.supportsCookies=S.supportsCookies;exports.supportsCryptoRandomUUID=S.supportsCryptoRandomUUID;exports.supportsDocument=S.supportsDocument;exports.supportsHistory=S.supportsHistory;exports.supportsIntersectionObserver=S.supportsIntersectionObserver;exports.supportsLocalStorage=S.supportsLocalStorage;exports.supportsLocation=S.supportsLocation;exports.supportsSessionStorage=S.supportsSessionStorage;exports.supportsShadowRoot=S.supportsShadowRoot;exports.supportsWebComponents=S.supportsWebComponents;exports.supportsWindow=S.supportsWindow;exports.Picked=A;exports.createClient=qe;exports.getPickedConfig=L;exports.getStepFields=_e;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var Y = Object.defineProperty;
|
|
2
2
|
var J = (t, e, r) => e in t ? Y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
-
var
|
|
3
|
+
var h = (t, e, r) => J(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
4
|
import { createDomain as b, createApi as F, createEffect as M, attach as Q, sample as x, combine as z, createEvent as C } from "effector";
|
|
5
5
|
import { createFactory as k, invoke as w } from "@withease/factories";
|
|
6
6
|
import { g as G, t as X, c as Z, i as ee, e as E, a as te, b as re, d as ne } from "../experience-instance-C4INDX6a.js";
|
|
@@ -15,25 +15,25 @@ import { h as Et, f as jt, j as Pt, e as Rt, g as Bt, i as At, k as $t } from ".
|
|
|
15
15
|
const H = b("experience"), ue = k(
|
|
16
16
|
({ client: t, experience: e }) => {
|
|
17
17
|
const r = H.store(e), n = F(r, {
|
|
18
|
-
merge(
|
|
18
|
+
merge(c, f) {
|
|
19
19
|
return {
|
|
20
|
-
...
|
|
21
|
-
...
|
|
20
|
+
...c,
|
|
21
|
+
...f.experience
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
}), i = r.map((
|
|
25
|
-
name:
|
|
26
|
-
decisionLogic:
|
|
27
|
-
targetSelectors:
|
|
24
|
+
}), i = r.map((c) => ({
|
|
25
|
+
name: c.name,
|
|
26
|
+
decisionLogic: c.condition ?? c.decide,
|
|
27
|
+
targetSelectors: c.targets,
|
|
28
28
|
initializeOpenLogic: e.initializeOpen
|
|
29
29
|
})), a = t.components.listStore.map(
|
|
30
|
-
(
|
|
30
|
+
(c) => c.find((f) => f.name === `experience:${e.id}`) || c.find((f) => f.name === "experience"),
|
|
31
31
|
{ skipVoid: !1 }
|
|
32
|
-
), s = r.map((
|
|
33
|
-
steps:
|
|
34
|
-
nodes:
|
|
35
|
-
edges:
|
|
36
|
-
conditionals:
|
|
32
|
+
), s = r.map((c) => ({
|
|
33
|
+
steps: c.steps,
|
|
34
|
+
nodes: c.nodes,
|
|
35
|
+
edges: c.edges,
|
|
36
|
+
conditionals: c.conditionals
|
|
37
37
|
})), o = e.actions ?? [];
|
|
38
38
|
return {
|
|
39
39
|
id: e.id,
|
|
@@ -63,8 +63,8 @@ const le = k(({ client: t }) => {
|
|
|
63
63
|
o.merge({ experience: s, strategy: "override" });
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
r.register(
|
|
66
|
+
const c = de({ client: t, experience: s });
|
|
67
|
+
r.register(c);
|
|
68
68
|
}
|
|
69
69
|
const i = e.map((s) => Object.values(s));
|
|
70
70
|
function a(s) {
|
|
@@ -130,8 +130,8 @@ const Se = k(({ client: t }) => {
|
|
|
130
130
|
"warn",
|
|
131
131
|
`Component '${s}' already registered. Registering again will override the previous registration.`
|
|
132
132
|
);
|
|
133
|
-
const
|
|
134
|
-
r.register(
|
|
133
|
+
const f = ve({ client: t, name: s, component: o });
|
|
134
|
+
r.register(f);
|
|
135
135
|
}
|
|
136
136
|
const i = e.map((s) => Object.values(s));
|
|
137
137
|
function a(s) {
|
|
@@ -189,8 +189,8 @@ const Fe = (t, e) => {
|
|
|
189
189
|
path: window.location.pathname
|
|
190
190
|
}, s = JSON.stringify(a), o = {
|
|
191
191
|
"Content-Type": "application/json"
|
|
192
|
-
},
|
|
193
|
-
|
|
192
|
+
}, c = document.getElementById("picked_script"), f = c == null ? void 0 : c.dataset.verceltoken;
|
|
193
|
+
f && (o["x-vercel-protection-bypass"] = f);
|
|
194
194
|
const l = (await fetch(i, {
|
|
195
195
|
method: "POST",
|
|
196
196
|
headers: o,
|
|
@@ -248,14 +248,14 @@ const Oe = (t, e, r) => {
|
|
|
248
248
|
r.register(t, e);
|
|
249
249
|
}, N = b("feature"), ze = k(({ client: t }) => {
|
|
250
250
|
const e = N.store({}), r = N.store([]), n = F(e, {
|
|
251
|
-
register(l,
|
|
251
|
+
register(l, d) {
|
|
252
252
|
return {
|
|
253
253
|
...l,
|
|
254
|
-
[
|
|
254
|
+
[d.id]: d.feature
|
|
255
255
|
};
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
|
-
function i(l,
|
|
258
|
+
function i(l, d) {
|
|
259
259
|
e.getState()[l] && S(
|
|
260
260
|
"warn",
|
|
261
261
|
`Feature '${l}' already registered. Registering again will override the previous registration.`
|
|
@@ -263,7 +263,7 @@ const Oe = (t, e, r) => {
|
|
|
263
263
|
const p = {
|
|
264
264
|
id: l,
|
|
265
265
|
feature: {
|
|
266
|
-
...
|
|
266
|
+
...d,
|
|
267
267
|
id: l
|
|
268
268
|
}
|
|
269
269
|
};
|
|
@@ -277,105 +277,105 @@ const Oe = (t, e, r) => {
|
|
|
277
277
|
const a = M(
|
|
278
278
|
async ({
|
|
279
279
|
id: l,
|
|
280
|
-
key:
|
|
281
|
-
storage:
|
|
280
|
+
key: d,
|
|
281
|
+
storage: u = "local"
|
|
282
282
|
}) => {
|
|
283
|
-
const p = R(`feature:${l}:${
|
|
284
|
-
return g === null ? null : { id: l, key:
|
|
283
|
+
const p = R(`feature:${l}:${d}`, "global"), g = (u === "session" ? O : $).get(p).boolean();
|
|
284
|
+
return g === null ? null : { id: l, key: d, bucket: g, storage: u };
|
|
285
285
|
}
|
|
286
286
|
), s = M((l) => {
|
|
287
287
|
if (!l)
|
|
288
288
|
return null;
|
|
289
|
-
const
|
|
290
|
-
(l.storage === "session" ? O : $).set(
|
|
291
|
-
}), o = /* @__PURE__ */ new Map(),
|
|
289
|
+
const d = R(`feature:${l.id}:${l.key}`, "global");
|
|
290
|
+
(l.storage === "session" ? O : $).set(d, l.bucket);
|
|
291
|
+
}), o = /* @__PURE__ */ new Map(), c = Q({
|
|
292
292
|
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
293
|
-
effect: async ({ allFeaturesStore: l, resolvedFeaturesStore:
|
|
294
|
-
const g =
|
|
295
|
-
(A) => A.id ===
|
|
293
|
+
effect: async ({ allFeaturesStore: l, resolvedFeaturesStore: d }, { id: u, decide: p, key: m }) => {
|
|
294
|
+
const g = d.find(
|
|
295
|
+
(A) => A.id === u && A.key === m
|
|
296
296
|
);
|
|
297
297
|
if (g)
|
|
298
298
|
return g;
|
|
299
|
-
const y = l[
|
|
299
|
+
const y = l[u];
|
|
300
300
|
if (!y)
|
|
301
|
-
throw new Error(`Feature with id '${
|
|
302
|
-
const I = o.get(`${
|
|
301
|
+
throw new Error(`Feature with id '${u}' not found`);
|
|
302
|
+
const I = o.get(`${u}:${m}`);
|
|
303
303
|
if (I !== void 0) {
|
|
304
304
|
const A = await I;
|
|
305
|
-
return { id: y.id, bucket: A, key:
|
|
305
|
+
return { id: y.id, bucket: A, key: m, storage: y.feature.storage };
|
|
306
306
|
}
|
|
307
307
|
const B = p();
|
|
308
|
-
o.set(`${
|
|
308
|
+
o.set(`${u}:${m}`, B);
|
|
309
309
|
const j = await B;
|
|
310
|
-
return { id: y.id, bucket: j, key:
|
|
310
|
+
return { id: y.id, bucket: j, key: m, storage: y.feature.storage };
|
|
311
311
|
}
|
|
312
312
|
});
|
|
313
313
|
x({
|
|
314
314
|
clock: n.register,
|
|
315
315
|
fn: (l) => {
|
|
316
|
-
const { id:
|
|
317
|
-
return { id:
|
|
316
|
+
const { id: d, feature: u } = l;
|
|
317
|
+
return { id: d, key: u.feature.key, storage: u.feature.storage };
|
|
318
318
|
},
|
|
319
319
|
target: a
|
|
320
320
|
}), x({
|
|
321
321
|
source: e,
|
|
322
|
-
clock:
|
|
323
|
-
fn: (l,
|
|
322
|
+
clock: c.doneData,
|
|
323
|
+
fn: (l, d) => {
|
|
324
324
|
var y;
|
|
325
|
-
const { id:
|
|
326
|
-
return g ? { key: g, id:
|
|
325
|
+
const { id: u, bucket: p, storage: m } = d, g = (y = l[u]) == null ? void 0 : y.feature.key;
|
|
326
|
+
return g ? { key: g, id: u, bucket: p, storage: m } : null;
|
|
327
327
|
},
|
|
328
328
|
target: s
|
|
329
329
|
});
|
|
330
|
-
const
|
|
330
|
+
const f = z({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
331
331
|
({
|
|
332
332
|
allFeaturesStore: l,
|
|
333
|
-
resolvedFeaturesStore:
|
|
334
|
-
}) => Object.values(l).map((
|
|
335
|
-
const p =
|
|
336
|
-
(
|
|
333
|
+
resolvedFeaturesStore: d
|
|
334
|
+
}) => Object.values(l).map((u) => {
|
|
335
|
+
const p = d.find(
|
|
336
|
+
(m) => m.id === u.id && m.key === u.feature.key
|
|
337
337
|
);
|
|
338
338
|
return p ? {
|
|
339
|
-
id:
|
|
340
|
-
name:
|
|
341
|
-
key:
|
|
342
|
-
getBucket: () => ({ id:
|
|
339
|
+
id: u.id,
|
|
340
|
+
name: u.feature.name,
|
|
341
|
+
key: u.feature.key,
|
|
342
|
+
getBucket: () => ({ id: u.id, bucket: p.bucket }),
|
|
343
343
|
isResolved: !0
|
|
344
344
|
} : {
|
|
345
|
-
id:
|
|
346
|
-
name:
|
|
347
|
-
key:
|
|
348
|
-
getBucket: async () => await
|
|
345
|
+
id: u.id,
|
|
346
|
+
name: u.feature.name,
|
|
347
|
+
key: u.feature.key,
|
|
348
|
+
getBucket: async () => await c(u.feature),
|
|
349
349
|
isResolved: !1
|
|
350
350
|
};
|
|
351
351
|
})
|
|
352
352
|
);
|
|
353
353
|
x({
|
|
354
|
-
clock:
|
|
354
|
+
clock: c.doneData,
|
|
355
355
|
source: { resolvedFeatures: r },
|
|
356
|
-
filter: ({ resolvedFeatures: l }, { id:
|
|
357
|
-
(
|
|
356
|
+
filter: ({ resolvedFeatures: l }, { id: d, key: u }) => !l.some(
|
|
357
|
+
(m) => m.id === d && m.key === u
|
|
358
358
|
),
|
|
359
|
-
fn: (l,
|
|
359
|
+
fn: (l, d) => d,
|
|
360
360
|
target: t.eventBus.prepend((l) => ({
|
|
361
361
|
type: "feature_decide",
|
|
362
362
|
feature: l
|
|
363
363
|
}))
|
|
364
364
|
}), x({
|
|
365
|
-
clock: [a.doneData,
|
|
365
|
+
clock: [a.doneData, c.doneData],
|
|
366
366
|
source: r,
|
|
367
|
-
fn: (l,
|
|
368
|
-
(p) => p.id ===
|
|
369
|
-
) ? l : [...l,
|
|
367
|
+
fn: (l, d) => !d || l.some(
|
|
368
|
+
(p) => p.id === d.id && p.key === d.key
|
|
369
|
+
) ? l : [...l, d],
|
|
370
370
|
target: r
|
|
371
371
|
});
|
|
372
372
|
function v(l) {
|
|
373
|
-
return e.map((
|
|
373
|
+
return e.map((d) => d[l], { skipVoid: !1 });
|
|
374
374
|
}
|
|
375
375
|
return {
|
|
376
376
|
register: i,
|
|
377
377
|
getByName: v,
|
|
378
|
-
listStore:
|
|
378
|
+
listStore: f
|
|
379
379
|
};
|
|
380
380
|
});
|
|
381
381
|
function Ce(t) {
|
|
@@ -404,24 +404,24 @@ const Ue = k(() => {
|
|
|
404
404
|
]
|
|
405
405
|
})), t.on(i, (s, o) => o);
|
|
406
406
|
function a(s, o) {
|
|
407
|
-
const
|
|
408
|
-
for (let
|
|
409
|
-
const v = s[
|
|
407
|
+
const c = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
408
|
+
for (let f = s.length - 1; f >= 0; f--) {
|
|
409
|
+
const v = s[f], l = v == null ? void 0 : v.node;
|
|
410
410
|
if (!(!l || !te(l)) && !(o && (v == null ? void 0 : v.experienceId) !== o))
|
|
411
|
-
if (
|
|
412
|
-
|
|
411
|
+
if (c.lastStepIndex === -1)
|
|
412
|
+
c.lastStepIndex = f;
|
|
413
413
|
else {
|
|
414
|
-
|
|
414
|
+
c.secondLastStepIndex = f;
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
|
-
return
|
|
418
|
+
return c;
|
|
419
419
|
}
|
|
420
420
|
return t.on(n, (s, o) => {
|
|
421
|
-
const { secondLastStepIndex:
|
|
421
|
+
const { secondLastStepIndex: c } = a(s.entries, o.experienceId), f = c !== -1 ? s.entries.slice(0, c + 1) : s.entries;
|
|
422
422
|
return {
|
|
423
423
|
...s,
|
|
424
|
-
entries:
|
|
424
|
+
entries: f
|
|
425
425
|
};
|
|
426
426
|
}), {
|
|
427
427
|
push: e,
|
|
@@ -436,28 +436,38 @@ function Me() {
|
|
|
436
436
|
}
|
|
437
437
|
const Te = () => C(), Ve = b("field"), Ne = k(() => {
|
|
438
438
|
const t = Ve.store({}), e = F(t, {
|
|
439
|
-
register(
|
|
439
|
+
register(o, c) {
|
|
440
440
|
return {
|
|
441
|
-
...
|
|
442
|
-
[
|
|
441
|
+
...o,
|
|
442
|
+
[c.field.id]: c.field
|
|
443
443
|
};
|
|
444
444
|
}
|
|
445
445
|
});
|
|
446
|
-
function r(
|
|
447
|
-
e.register({ field:
|
|
446
|
+
function r(o) {
|
|
447
|
+
e.register({ field: o });
|
|
448
448
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
449
|
+
function n(o, c) {
|
|
450
|
+
const f = a(o).getState();
|
|
451
|
+
if (!f)
|
|
452
|
+
return;
|
|
453
|
+
const v = Object.assign({}, f, {
|
|
454
|
+
...c
|
|
455
|
+
});
|
|
456
|
+
e.register({ field: { ...v } });
|
|
452
457
|
}
|
|
453
|
-
|
|
454
|
-
|
|
458
|
+
const i = t.map((o) => Object.values(o));
|
|
459
|
+
function a(o) {
|
|
460
|
+
return t.map((c) => c[o] || null);
|
|
461
|
+
}
|
|
462
|
+
function s(o) {
|
|
463
|
+
return t.map((c) => Object.values(c).find((f) => f.name === o) || null);
|
|
455
464
|
}
|
|
456
465
|
return {
|
|
457
466
|
register: r,
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
467
|
+
update: n,
|
|
468
|
+
getById: a,
|
|
469
|
+
listStore: i,
|
|
470
|
+
getByName: s
|
|
461
471
|
};
|
|
462
472
|
});
|
|
463
473
|
function _e() {
|
|
@@ -501,37 +511,37 @@ function L(t) {
|
|
|
501
511
|
}
|
|
502
512
|
const We = b("response"), Ye = k(({ client: t }) => {
|
|
503
513
|
const e = We.store({}), r = C(), n = C(), i = F(e, {
|
|
504
|
-
register(
|
|
514
|
+
register(d, u) {
|
|
505
515
|
return {
|
|
506
|
-
...
|
|
507
|
-
[
|
|
516
|
+
...d,
|
|
517
|
+
[u.fieldId]: u.response
|
|
508
518
|
};
|
|
509
519
|
},
|
|
510
|
-
registerBatch(
|
|
520
|
+
registerBatch(d, u) {
|
|
511
521
|
return {
|
|
512
|
-
...
|
|
513
|
-
...
|
|
522
|
+
...d,
|
|
523
|
+
...u
|
|
514
524
|
};
|
|
515
525
|
},
|
|
516
|
-
clear(
|
|
517
|
-
const { [
|
|
518
|
-
return
|
|
526
|
+
clear(d, u) {
|
|
527
|
+
const { [u]: p, ...m } = d;
|
|
528
|
+
return m;
|
|
519
529
|
},
|
|
520
530
|
clearAll() {
|
|
521
531
|
return {};
|
|
522
532
|
}
|
|
523
533
|
});
|
|
524
|
-
function a(
|
|
525
|
-
i.register({ fieldId:
|
|
534
|
+
function a(d, u) {
|
|
535
|
+
i.register({ fieldId: d, response: u });
|
|
526
536
|
}
|
|
527
|
-
async function s(
|
|
528
|
-
const
|
|
537
|
+
async function s(d) {
|
|
538
|
+
const u = [];
|
|
529
539
|
return await Promise.allSettled(
|
|
530
|
-
Object.entries(
|
|
531
|
-
let g =
|
|
540
|
+
Object.entries(d).map(async ([p, m]) => {
|
|
541
|
+
let g = m;
|
|
532
542
|
const y = t.fields.getById(p).getState();
|
|
533
543
|
if (!y) {
|
|
534
|
-
|
|
544
|
+
u.push({
|
|
535
545
|
fieldId: p,
|
|
536
546
|
userMessage: `Field '${p}' not found`,
|
|
537
547
|
systemMessage: `No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
@@ -544,7 +554,7 @@ const We = b("response"), Ye = k(({ client: t }) => {
|
|
|
544
554
|
$input: g
|
|
545
555
|
});
|
|
546
556
|
if (typeof I == "string") {
|
|
547
|
-
|
|
557
|
+
u.push({
|
|
548
558
|
fieldId: p,
|
|
549
559
|
userMessage: I,
|
|
550
560
|
systemMessage: `Field validation resulted in an error: ${I}.`,
|
|
@@ -553,7 +563,7 @@ const We = b("response"), Ye = k(({ client: t }) => {
|
|
|
553
563
|
return;
|
|
554
564
|
}
|
|
555
565
|
if (I === !1) {
|
|
556
|
-
|
|
566
|
+
u.push({
|
|
557
567
|
fieldId: p,
|
|
558
568
|
userMessage: "This field is invalid",
|
|
559
569
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
@@ -563,7 +573,7 @@ const We = b("response"), Ye = k(({ client: t }) => {
|
|
|
563
573
|
}
|
|
564
574
|
}
|
|
565
575
|
if (y.required && L(g)) {
|
|
566
|
-
|
|
576
|
+
u.push({
|
|
567
577
|
fieldId: p,
|
|
568
578
|
userMessage: "This field is required",
|
|
569
579
|
systemMessage: "Field is required.",
|
|
@@ -572,7 +582,7 @@ const We = b("response"), Ye = k(({ client: t }) => {
|
|
|
572
582
|
return;
|
|
573
583
|
}
|
|
574
584
|
if (!y.multiple && Array.isArray(g) && g.length > 1) {
|
|
575
|
-
|
|
585
|
+
u.push({
|
|
576
586
|
fieldId: p,
|
|
577
587
|
userMessage: "This field expects a single response",
|
|
578
588
|
systemMessage: "Field expects a single response.",
|
|
@@ -582,7 +592,7 @@ const We = b("response"), Ye = k(({ client: t }) => {
|
|
|
582
592
|
}
|
|
583
593
|
if (y.options) {
|
|
584
594
|
const I = y.options.map((j) => j.value), B = Array.isArray(g) ? g : [g];
|
|
585
|
-
Array.isArray(g) && (B.every((j) => I.includes(j)) ||
|
|
595
|
+
Array.isArray(g) && (B.every((j) => I.includes(j)) || u.push({
|
|
586
596
|
fieldId: p,
|
|
587
597
|
userMessage: "This field expects a valid option",
|
|
588
598
|
systemMessage: `Field expects a valid option. Valid options are: ${I.join(", ")}`,
|
|
@@ -590,24 +600,24 @@ const We = b("response"), Ye = k(({ client: t }) => {
|
|
|
590
600
|
}));
|
|
591
601
|
}
|
|
592
602
|
})
|
|
593
|
-
), { responsesToCommit:
|
|
603
|
+
), { responsesToCommit: d, validationErrors: u };
|
|
594
604
|
}
|
|
595
|
-
async function o(
|
|
596
|
-
const { responsesToCommit:
|
|
597
|
-
return p.length ? { errors: p } : (i.registerBatch(
|
|
605
|
+
async function o(d) {
|
|
606
|
+
const { responsesToCommit: u, validationErrors: p } = await s(d);
|
|
607
|
+
return p.length ? { errors: p } : (i.registerBatch(u), { errors: [] });
|
|
598
608
|
}
|
|
599
|
-
const
|
|
609
|
+
const c = e.map((d) => d), f = e.map((d) => Object.keys(d).map((p) => ({
|
|
600
610
|
fieldId: p,
|
|
601
|
-
value:
|
|
611
|
+
value: d[p]
|
|
602
612
|
})));
|
|
603
|
-
function v(
|
|
604
|
-
const
|
|
605
|
-
return z({ f:
|
|
606
|
-
}
|
|
607
|
-
function l(
|
|
608
|
-
const
|
|
609
|
-
return z({ f:
|
|
610
|
-
const g = p &&
|
|
613
|
+
function v(d) {
|
|
614
|
+
const u = t.fields.getById(d), p = e.map((m) => m[d] || null);
|
|
615
|
+
return z({ f: u, r: p }, ({ f: m, r: g }) => g || (m != null && m.defaultValue ? m.defaultValue : null));
|
|
616
|
+
}
|
|
617
|
+
function l(d) {
|
|
618
|
+
const u = t.fields.getByName(d);
|
|
619
|
+
return z({ f: u, s: e }, ({ f: p, s: m }) => {
|
|
620
|
+
const g = p && m[p.id] || null;
|
|
611
621
|
return g || (p != null && p.defaultValue ? p.defaultValue : null);
|
|
612
622
|
});
|
|
613
623
|
}
|
|
@@ -623,8 +633,8 @@ const We = b("response"), Ye = k(({ client: t }) => {
|
|
|
623
633
|
clear: n,
|
|
624
634
|
commit: o,
|
|
625
635
|
getResponsesToCommit: s,
|
|
626
|
-
listStore:
|
|
627
|
-
getAllStore:
|
|
636
|
+
listStore: f,
|
|
637
|
+
getAllStore: c,
|
|
628
638
|
getByFieldId: v,
|
|
629
639
|
getByFieldName: l
|
|
630
640
|
};
|
|
@@ -632,7 +642,7 @@ const We = b("response"), Ye = k(({ client: t }) => {
|
|
|
632
642
|
function Je(t) {
|
|
633
643
|
return w(Ye, t);
|
|
634
644
|
}
|
|
635
|
-
const Qe = () => "0.0.26-next.
|
|
645
|
+
const Qe = () => "0.0.26-next.2";
|
|
636
646
|
function Xe() {
|
|
637
647
|
if (D()) {
|
|
638
648
|
const t = [
|
|
@@ -739,28 +749,28 @@ function at(t) {
|
|
|
739
749
|
}
|
|
740
750
|
class K {
|
|
741
751
|
constructor(e) {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
752
|
+
h(this, "options");
|
|
753
|
+
h(this, "isReady", !1);
|
|
754
|
+
h(this, "project");
|
|
755
|
+
h(this, "plugins", {});
|
|
756
|
+
h(this, "eventBus", Te());
|
|
757
|
+
h(this, "organizationId");
|
|
758
|
+
h(this, "projectId");
|
|
759
|
+
h(this, "apiUrl");
|
|
760
|
+
h(this, "session");
|
|
761
|
+
h(this, "precondition");
|
|
762
|
+
h(this, "condition");
|
|
763
|
+
h(this, "searchParams", Ze());
|
|
764
|
+
h(this, "history", Me());
|
|
765
|
+
h(this, "components", ke({ client: this }));
|
|
766
|
+
h(this, "experienceInstances", re({ client: this }));
|
|
767
|
+
h(this, "experiences", pe({ client: this }));
|
|
768
|
+
h(this, "frameworks", be({ client: this }));
|
|
769
|
+
h(this, "predicates", $e({ client: this }));
|
|
770
|
+
h(this, "features", Ce({ client: this }));
|
|
771
|
+
h(this, "responses", Je({ client: this }));
|
|
772
|
+
h(this, "fields", _e());
|
|
773
|
+
h(this, "actions", qe());
|
|
764
774
|
S("info", "Picked client initializing.");
|
|
765
775
|
const { organizationId: r, projectId: n } = at(e);
|
|
766
776
|
this.organizationId = r, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Xe(), this.session = nt(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: Qe() }), S("info", "Picked client initialized.");
|
|
@@ -889,7 +899,7 @@ class K {
|
|
|
889
899
|
return this.plugins[e] ?? {};
|
|
890
900
|
}
|
|
891
901
|
}
|
|
892
|
-
|
|
902
|
+
h(K, "logger", S);
|
|
893
903
|
function W(t) {
|
|
894
904
|
var e;
|
|
895
905
|
return ((e = t.options) == null ? void 0 : e.some((r) => "condition" in r)) ?? !1;
|
|
@@ -905,8 +915,8 @@ async function vt(t, e) {
|
|
|
905
915
|
if (!n.options || !W(n))
|
|
906
916
|
return n;
|
|
907
917
|
const s = (await Promise.all(
|
|
908
|
-
n.options.map(async (
|
|
909
|
-
)).filter((
|
|
918
|
+
n.options.map(async (c) => c.condition ? await E(t, c.condition) ? c : null : c)
|
|
919
|
+
)).filter((c) => c !== null);
|
|
910
920
|
return s.length === n.options.length ? n : s.length === 0 ? null : { ...n, options: s };
|
|
911
921
|
})
|
|
912
922
|
)).filter((n) => n !== null);
|
|
@@ -102,6 +102,7 @@ export interface FieldBooleanMultiple extends FieldBase {
|
|
|
102
102
|
export type Field = FieldTextSingular | FieldTextMultiple | FieldNumberSingular | FieldNumberMultiple | FieldBooleanSingular | FieldBooleanMultiple;
|
|
103
103
|
declare const createFieldIndexFactory: () => {
|
|
104
104
|
register: (field: Field) => void;
|
|
105
|
+
update: (fieldId: FieldBase["id"], updates: Partial<Field>) => void;
|
|
105
106
|
getById: (id: FieldBase["id"]) => import('effector').Store<Field | null>;
|
|
106
107
|
listStore: import('effector').Store<Field[]>;
|
|
107
108
|
getByName: (name: FieldBase["name"]) => import('effector').Store<Field | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../../src/entities/field/field.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAI7D,MAAM,MAAM,mBAAmB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,EAAE,SAAS,CAAA;IACf,QAAQ,EAAE,IAAI,CAAA;IACd,YAAY,CAAC,EAAE,OAAO,EAAE,CAAA;IACxB,OAAO,CAAC,EACJ;QACE,EAAE,EAAE,MAAM,CAAA;QACV,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,KAAK,EAAE,OAAO,CAAA;QACd,SAAS,CAAC,EAAE,SAAS,CAAA;KACtB,EAAE,GACH,IAAI,CAAA;CACT;AAED,MAAM,MAAM,KAAK,GACb,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,mBAAmB,GAGnB,oBAAoB,GACpB,oBAAoB,CAAA;AAGxB,QAAA,MAAM,uBAAuB;sBAcF,KAAK,KAAG,IAAI;sBAcZ,SAAS,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,KAAK,CAAC,KAAG,IAAI;kBAmBnD,SAAS,CAAC,IAAI,CAAC;;sBAIX,SAAS,CAAC,MAAM,CAAC;CAW1C,CAAA;AAEF,wBAAgB,gBAAgB,IAAI,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAE7E;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,EAAE,QAAQ,WAAW,KAAG,IAE9D,CAAA"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -227,6 +227,7 @@ export declare class Picked {
|
|
|
227
227
|
};
|
|
228
228
|
readonly fields: {
|
|
229
229
|
register: (field: Field) => void;
|
|
230
|
+
update: (fieldId: import('.').FieldBase["id"], updates: Partial<Field>) => void;
|
|
230
231
|
getById: (id: import('.').FieldBase["id"]) => import('effector').Store<Field | null>;
|
|
231
232
|
listStore: import('effector').Store<Field[]>;
|
|
232
233
|
getByName: (name: import('.').FieldBase["name"]) => import('effector').Store<Field | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,UAAU,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