@adriansteffan/reactive 0.1.4 → 0.1.6

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.
@@ -16724,7 +16724,7 @@ function Xye() {
16724
16724
  }
16725
16725
  const yc = [];
16726
16726
  function Oo(i, e, t = "string", s, r) {
16727
- let n = yc.find((c) => c.name === i);
16727
+ let n = yc.find((d) => d.name === i);
16728
16728
  n || (n = {
16729
16729
  name: i,
16730
16730
  defaultValue: r !== void 0 ? r : e,
@@ -16733,41 +16733,41 @@ function Oo(i, e, t = "string", s, r) {
16733
16733
  value: void 0
16734
16734
  }, yc.push(n));
16735
16735
  const a = {
16736
- string: (c) => c,
16737
- number: (c) => {
16738
- const d = Number(c);
16739
- return isNaN(d) ? e : d;
16736
+ string: (d) => d,
16737
+ number: (d) => {
16738
+ const f = Number(d);
16739
+ return isNaN(f) ? e : f;
16740
16740
  },
16741
- boolean: (c) => c.toLowerCase() === "true",
16742
- array: (c) => {
16741
+ boolean: (d) => d.toLowerCase() === "true",
16742
+ array: (d) => {
16743
16743
  try {
16744
- return JSON.parse(c);
16744
+ return JSON.parse(d);
16745
16745
  } catch {
16746
16746
  return e;
16747
16747
  }
16748
16748
  },
16749
- json: (c) => {
16749
+ json: (d) => {
16750
16750
  try {
16751
- return JSON.parse(c);
16751
+ return JSON.parse(d);
16752
16752
  } catch {
16753
16753
  return e;
16754
16754
  }
16755
16755
  }
16756
- }, o = (c) => t === "string" && typeof c == "string" || t === "number" && typeof c == "number" || t === "boolean" && typeof c == "boolean" || t === "array" && Array.isArray(c) || t === "json" && typeof c == "object" && c !== null ? c : typeof c == "string" ? c.toLowerCase() === "undefined" ? e : a[t](c) : e, l = new URLSearchParams(window.location.search).get("_b");
16757
- if (l)
16756
+ }, o = (d) => t === "string" && typeof d == "string" || t === "number" && typeof d == "number" || t === "boolean" && typeof d == "boolean" || t === "array" && Array.isArray(d) || t === "json" && typeof d == "object" && d !== null ? d : typeof d == "string" ? d.toLowerCase() === "undefined" ? e : a[t](d) : e, l = typeof window < "u" ? new URLSearchParams(window.location.search) : new URLSearchParams(), u = l.get("_b");
16757
+ if (u)
16758
16758
  try {
16759
- const c = atob(l), d = JSON.parse(c);
16760
- if (i in d) {
16761
- const f = o(d[i]);
16762
- return n.value = f, f;
16759
+ const d = atob(u), f = JSON.parse(d);
16760
+ if (i in f) {
16761
+ const y = o(f[i]);
16762
+ return n.value = y, y;
16763
16763
  }
16764
16764
  } catch {
16765
16765
  }
16766
- const u = new URLSearchParams(window.location.search).get(i);
16767
- if (u == null)
16766
+ const h = l.get(i);
16767
+ if (h == null)
16768
16768
  return e;
16769
- const h = o(u);
16770
- return n.value = h, h;
16769
+ const c = o(h);
16770
+ return n.value = c, c;
16771
16771
  }
16772
16772
  const Rm = [];
16773
16773
  class Am {
@@ -78625,7 +78625,7 @@ var Ym;
78625
78625
  i.UTF8 = "utf8", i.ASCII = "ascii", i.UTF16 = "utf16";
78626
78626
  })(Ym || (Ym = {}));
78627
78627
  const Ea = wu("Filesystem", {
78628
- web: () => import("./web-DGGPscOK.js").then((i) => new i.FilesystemWeb())
78628
+ web: () => import("./web-Dr8wSxgd.js").then((i) => new i.FilesystemWeb())
78629
78629
  });
78630
78630
  vi("Upload", async (i, e, t, s) => {
78631
78631
  const r = i.sessionID || `sim_${Date.now()}_${Math.floor(Lt(0, 2176782336)).toString(36)}`, n = xV({
@@ -78883,7 +78883,7 @@ var iw;
78883
78883
  i.None = "NONE", i.Slide = "SLIDE", i.Fade = "FADE";
78884
78884
  })(iw || (iw = {}));
78885
78885
  const X3 = wu("StatusBar"), e7 = wu("ImmersiveMode", {
78886
- web: () => import("./web-BGLPXsYu.js").then((i) => new i.ImmersiveModeWeb())
78886
+ web: () => import("./web-dAxPFW1N.js").then((i) => new i.ImmersiveModeWeb())
78887
78887
  });
78888
78888
  Ai("EnterFullscreen", "session");
78889
78889
  vi("EnterFullscreen", xu, {});
@@ -85718,7 +85718,7 @@ const Pye = {
85718
85718
  ...gye,
85719
85719
  ...Iye
85720
85720
  }, Aye = /* @__PURE__ */ W1e(Rye, G1e);
85721
- Ai("Tutorial", "session");
85721
+ Ai("Tutorial", null);
85722
85722
  vi("Tutorial", (i, e, t, s) => {
85723
85723
  var o;
85724
85724
  const r = ((o = i.slides) == null ? void 0 : o.length) ?? 0, n = {};
@@ -1,4 +1,4 @@
1
- import { H as e, C as t, a as i, c as r, d as n, e as o, f as l, Y as m, z as u, M as c, P as p, g as P, h as g, Q as d, R as C, i as D, j as T, F as x, T as h, k, l as E, U as F, X as S, m as f, n as v, o as B, p as R, q as b, r as y, s as I, t as M, u as U, v as w, w as K, x as q, y as A, A as Q, B as Z, D as j, G as z, I as G, J as H, K as J, L, N, O, S as V, V as X, Z as Y, _, $, a0 as W, a1 as aa, a2 as sa, a3 as ea, a4 as ta, a5 as ia, a6 as ra, a7 as na, a8 as oa, a9 as la, aa as ma, ab as ua } from "./mod-DHUjIRfF.js";
1
+ import { H as e, C as t, a as i, c as r, d as n, e as o, f as l, Y as m, z as u, M as c, P as p, g as P, h as g, Q as d, R as C, i as D, j as T, F as x, T as h, k, l as E, U as F, X as S, m as f, n as v, o as B, p as R, q as b, r as y, s as I, t as M, u as U, v as w, w as K, x as q, y as A, A as Q, B as Z, D as j, G as z, I as G, J as H, K as J, L, N, O, S as V, V as X, Z as Y, _, $, a0 as W, a1 as aa, a2 as sa, a3 as ea, a4 as ta, a5 as ia, a6 as ra, a7 as na, a8 as oa, a9 as la, aa as ma, ab as ua } from "./mod-Csi4RGrw.js";
2
2
  export {
3
3
  e as Bounce,
4
4
  t as CanvasBlock,
@@ -10145,7 +10145,7 @@
10145
10145
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10146
10146
  * See the License for the specific language governing permissions and
10147
10147
  * limitations under the License.
10148
- */var Ire=it,d2=Cre,Rre=Pre;Ire(d2,"factory",Rre);var Are=d2;const Lre=za(Are),Ts=new Uint32Array(1);function _re(i){return Ts[0]=i,Ts[0]=(Ts[0]<<16|Ts[0]>>16)>>>0,Ts[0]=(Ts[0]&1431655765)<<1|(Ts[0]&2863311530)>>>1>>>0,Ts[0]=(Ts[0]&858993459)<<2|(Ts[0]&3435973836)>>>2>>>0,Ts[0]=(Ts[0]&252645135)<<4|(Ts[0]&4042322160)>>>4>>>0,Ts[0]=(Ts[0]&16711935)<<8|(Ts[0]&4278255360)>>>8>>>0,Ts[0]*23283064365386963e-26}function Dre(i,e){let t=1,s=0;for(;i>0;)t/=e,s+=t*(i%e),i=~~(i/e);return s}const kre=(i,e=[2,3])=>Array.from({length:i},(t,s)=>e.map(r=>r===2?_re(s):Dre(s,r)));X.normal=qC,X.poisson=db,X.uniform=Vb;function Ore(i){const e=LB.factory({seed:i});X.normal=qC.factory({prng:e.normalized}),X.poisson=db.factory({prng:e.normalized}),X.uniform=Vb.factory({prng:e.normalized}),Math.random=()=>X.uniform(0,1)}function p2(i){return Math.max(1e-10,Math.min(1-1e-10,i))}function f2(i){switch(i.distribution){case"uniform":return e=>i.min+e*(i.max-i.min);case"normal":return e=>UK(p2(e),i.mean,i.sd);case"poisson":return e=>Lre(p2(e),i.mean)}}function m2(i,e){const t=e.map(f2);return e.length===1?i.map(s=>t[0](s[0])):i.map(s=>s.map((r,n)=>t[n](r)))}const Mre=[[1,0,[1]],[2,1,[1,1]],[3,1,[1,3,7]],[3,2,[1,1,5]],[4,1,[1,3,1,1]],[4,4,[1,1,3,7]],[5,2,[1,3,3,9,9]],[5,13,[1,3,7,13,3]],[5,7,[1,1,5,11,27]],[5,14,[1,3,5,1,15]],[5,11,[1,1,7,3,29]],[5,4,[1,3,7,7,21]],[6,1,[1,1,1,9,23,37]],[6,16,[1,3,3,5,19,33]],[6,13,[1,1,3,13,11,7]],[6,22,[1,1,7,13,25,5]],[6,19,[1,3,5,11,7,11]],[6,25,[1,1,1,3,13,39]],[7,1,[1,3,1,15,17,63,13]],[7,32,[1,1,5,5,1,59,33]]],oo=32,Nre=2**oo;function Fre(i){const e=new Uint32Array(oo);if(i===0){for(let n=0;n<oo;n++)e[n]=1<<oo-1-n;return e}const[t,s,r]=Mre[i-1];for(let n=0;n<t;n++)e[n]=r[n]<<oo-1-n;for(let n=t;n<oo;n++){e[n]=e[n-t]^e[n-t]>>>t;for(let a=1;a<t;a++)s>>>t-1-a&1&&(e[n]^=e[n-a])}return e}function qre(i,e){if(e<1||e>21)throw new RangeError("sobol() supports 1-21 dimensions");const t=Array.from({length:e},(n,a)=>Fre(a)),s=new Uint32Array(e),r=[new Array(e).fill(0)];for(let n=1;n<i;n++){let a=0,o=n-1;for(;(o&1)===1;)o>>>=1,a++;for(let l=0;l<e;l++)s[l]^=t[l][a];r.push(Array.from(s,l=>l/Nre))}return r}const Bre=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73],g2=6;function v2(i,e){const t=qre(i+1,e.length).slice(1);return m2(t,e)}function y2(i,e){e.length>g2&&console.warn(`Halton sequence quality degrades above ${g2} dimensions. Consider using sobol() instead.`);const t=Bre.slice(0,e.length),s=kre(i+1,t).slice(1);return m2(s,e)}function $re(i,e,t){const s=Object.keys(t),r=s.map(a=>t[a]);let n;switch(i){case"sobol":n=v2(e,r);break;case"halton":n=y2(e,r);break;case"random":n=Hre(e,r);break}return Array.from({length:e},(a,o)=>{const l=s.length===1?[n[o]]:n[o];return Object.fromEntries(s.map((u,h)=>[u,l[h]]))})}function Hre(i,e){const t=e.map(f2);return e.length===1?Array.from({length:i},()=>t[0](X.uniform(0,1))):Array.from({length:i},()=>t.map(s=>s(X.uniform(0,1))))}function C2(i,e=1){const t=[];if(i.length===0)return t;for(let s=0;s<e;s++){const r=Math.floor(X.uniform(0,1)*i.length);t.push(i[r])}return t}function fm(i){const e=[...i];for(let t=e.length-1;t>=0;t--){const s=Math.floor(X.uniform(0,1)*(t+1));[e[t],e[s]]=[e[s],e[t]]}return e}function b2(i,e){return e(i)}function w2(i,e){const t=Math.ceil(i.length/e);return Array.from({length:Math.ceil(i.length/t)},(s,r)=>i.slice(r*t,r*t+t))}function Qre(){typeof Array.prototype.sample!="function"&&(Array.prototype.sample=function(i){return C2(this,i)}),typeof Array.prototype.shuffle!="function"&&(Array.prototype.shuffle=function(){return fm(this)}),typeof Array.prototype.pipe!="function"&&(Array.prototype.pipe=function(i){return b2(this,i)}),typeof Array.prototype.chunk!="function"&&(Array.prototype.chunk=function(i){return w2(this,i)})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var lo;(function(i){i.Unimplemented="UNIMPLEMENTED",i.Unavailable="UNAVAILABLE"})(lo||(lo={}));class mm extends Error{constructor(e,t,s){super(e),this.message=e,this.code=t,this.data=s}}const Ure=i=>{var e,t;return i!=null&&i.androidBridge?"android":!((t=(e=i==null?void 0:i.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||t===void 0)&&t.bridge?"ios":"web"},zre=i=>{const e=i.CapacitorCustomPlatform||null,t=i.Capacitor||{},s=t.Plugins=t.Plugins||{},r=()=>e!==null?e.name:Ure(i),n=()=>r()!=="web",a=c=>{const d=u.get(c);return!!(d!=null&&d.platforms.has(r())||o(c))},o=c=>{var d;return(d=t.PluginHeaders)===null||d===void 0?void 0:d.find(f=>f.name===c)},l=c=>i.console.error(c),u=new Map,h=(c,d={})=>{const f=u.get(c);if(f)return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`),f.proxy;const y=r(),v=o(c);let m;const g=async()=>(!m&&y in d?m=typeof d[y]=="function"?m=await d[y]():m=d[y]:e!==null&&!m&&"web"in d&&(m=typeof d.web=="function"?m=await d.web():m=d.web),m),b=(T,k)=>{var q,B;if(v){const U=v==null?void 0:v.methods.find(D=>k===D.name);if(U)return U.rtype==="promise"?D=>t.nativePromise(c,k.toString(),D):(D,H)=>t.nativeCallback(c,k.toString(),D,H);if(T)return(q=T[k])===null||q===void 0?void 0:q.bind(T)}else{if(T)return(B=T[k])===null||B===void 0?void 0:B.bind(T);throw new mm(`"${c}" plugin is not implemented on ${y}`,lo.Unimplemented)}},x=T=>{let k;const q=(...B)=>{const U=g().then(D=>{const H=b(D,T);if(H){const Q=H(...B);return k=Q==null?void 0:Q.remove,Q}else throw new mm(`"${c}.${T}()" is not implemented on ${y}`,lo.Unimplemented)});return T==="addListener"&&(U.remove=async()=>k()),U};return q.toString=()=>`${T.toString()}() { [capacitor code] }`,Object.defineProperty(q,"name",{value:T,writable:!1,configurable:!1}),q},P=x("addListener"),R=x("removeListener"),A=(T,k)=>{const q=P({eventName:T},k),B=async()=>{const D=await q;R({eventName:T,callbackId:D},k)},U=new Promise(D=>q.then(()=>D({remove:B})));return U.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await B()},U},_=new Proxy({},{get(T,k){switch(k){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return v?A:P;case"removeListener":return R;default:return x(k)}}});return s[c]=_,u.set(c,{name:c,proxy:_,platforms:new Set([...Object.keys(d),...v?[y]:[]])}),_};return t.convertFileSrc||(t.convertFileSrc=c=>c),t.getPlatform=r,t.handleError=l,t.isNativePlatform=n,t.isPluginAvailable=a,t.registerPlugin=h,t.Exception=mm,t.DEBUG=!!t.DEBUG,t.isLoggingEnabled=!!t.isLoggingEnabled,t},fa=(i=>i.Capacitor=zre(i))(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),_l=fa.registerPlugin;class Zh{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,t){let s=!1;this.listeners[e]||(this.listeners[e]=[],s=!0),this.listeners[e].push(t);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n),s&&this.sendRetainedArgumentsForEvent(e);const a=async()=>this.removeListener(e,t);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t,s){const r=this.listeners[e];if(!r){if(s){let n=this.retainedEventArguments[e];n||(n=[]),n.push(t),this.retainedEventArguments[e]=n}return}r.forEach(n=>n(t))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:s=>{this.notifyListeners(t,s)}}}unimplemented(e="not implemented"){return new fa.Exception(e,lo.Unimplemented)}unavailable(e="not available"){return new fa.Exception(e,lo.Unavailable)}async removeListener(e,t){const s=this.listeners[e];if(!s)return;const r=s.indexOf(t);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const t=this.retainedEventArguments[e];t&&(delete this.retainedEventArguments[e],t.forEach(s=>{this.notifyListeners(e,s)}))}}const x2=i=>encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),E2=i=>i.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class jre extends Zh{async getCookies(){const e=document.cookie,t={};return e.split(";").forEach(s=>{if(s.length<=0)return;let[r,n]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");r=E2(r).trim(),n=E2(n).trim(),t[r]=n}),t}async setCookie(e){try{const t=x2(e.key),s=x2(e.value),r=`; expires=${(e.expires||"").replace("expires=","")}`,n=(e.path||"/").replace("path=",""),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${s||""}${r}; path=${n}; ${a};`}catch(t){return Promise.reject(t)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(t){return Promise.reject(t)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}_l("CapacitorCookies",{web:()=>new jre});const Wre=async i=>new Promise((e,t)=>{const s=new FileReader;s.onload=()=>{const r=s.result;e(r.indexOf(",")>=0?r.split(",")[1]:r)},s.onerror=r=>t(r),s.readAsDataURL(i)}),Gre=(i={})=>{const e=Object.keys(i);return Object.keys(i).map(r=>r.toLocaleLowerCase()).reduce((r,n,a)=>(r[n]=i[e[a]],r),{})},Kre=(i,e=!0)=>i?Object.entries(i).reduce((s,r)=>{const[n,a]=r;let o,l;return Array.isArray(a)?(l="",a.forEach(u=>{o=e?encodeURIComponent(u):u,l+=`${n}=${o}&`}),l.slice(0,-1)):(o=e?encodeURIComponent(a):a,l=`${n}=${o}`),`${s}&${l}`},"").substr(1):null,V2=(i,e={})=>{const t=Object.assign({method:i.method||"GET",headers:i.headers},e),r=Gre(i.headers)["content-type"]||"";if(typeof i.data=="string")t.body=i.data;else if(r.includes("application/x-www-form-urlencoded")){const n=new URLSearchParams;for(const[a,o]of Object.entries(i.data||{}))n.set(a,o);t.body=n.toString()}else if(r.includes("multipart/form-data")||i.data instanceof FormData){const n=new FormData;if(i.data instanceof FormData)i.data.forEach((o,l)=>{n.append(l,o)});else for(const o of Object.keys(i.data))n.append(o,i.data[o]);t.body=n;const a=new Headers(t.headers);a.delete("content-type"),t.headers=a}else(r.includes("application/json")||typeof i.data=="object")&&(t.body=JSON.stringify(i.data));return t};class Zre extends Zh{async request(e){const t=V2(e,e.webFetchExtra),s=Kre(e.params,e.shouldEncodeUrlParams),r=s?`${e.url}?${s}`:e.url,n=await fetch(r,t),a=n.headers.get("content-type")||"";let{responseType:o="text"}=n.ok?e:{};a.includes("application/json")&&(o="json");let l,u;switch(o){case"arraybuffer":case"blob":u=await n.blob(),l=await Wre(u);break;case"json":l=await n.json();break;case"document":case"text":default:l=await n.text()}const h={};return n.headers.forEach((c,d)=>{h[d]=c}),{data:l,headers:h,status:n.status,url:n.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}_l("CapacitorHttp",{web:()=>new Zre});function Ps(){return Math.round(performance.now())}function uo(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}function Jre(){return window.electronAPI!==void 0}const Jh=[];function ma(i,e,t="string",s,r){let n=Jh.find(c=>c.name===i);n||(n={name:i,defaultValue:r!==void 0?r:e,type:t,description:s,value:void 0},Jh.push(n));const a={string:c=>c,number:c=>{const d=Number(c);return isNaN(d)?e:d},boolean:c=>c.toLowerCase()==="true",array:c=>{try{return JSON.parse(c)}catch{return e}},json:c=>{try{return JSON.parse(c)}catch{return e}}},o=c=>t==="string"&&typeof c=="string"||t==="number"&&typeof c=="number"||t==="boolean"&&typeof c=="boolean"||t==="array"&&Array.isArray(c)||t==="json"&&typeof c=="object"&&c!==null?c:typeof c=="string"?c.toLowerCase()==="undefined"?e:a[t](c):e,l=new URLSearchParams(window.location.search).get("_b");if(l)try{const c=atob(l),d=JSON.parse(c);if(i in d){const f=o(d[i]);return n.value=f,f}}catch{}const u=new URLSearchParams(window.location.search).get(i);if(u==null)return e;const h=o(u);return n.value=h,h}const gm=[];class Yh{static getRegistry(){return[...Jh]}static getTimelineRepresentation(){return[...gm]}}const Dl=()=>window.electronAPI?"desktop":fa.isNativePlatform()?"mobile":"web",S2={};function T2(i){i.forEach(e=>{const t=S2[e.type];if(t)for(const s of t)(!e.hideSettings||e.hideSettings!==!0&&!e.hideSettings.includes(s.name))&&Jh.push(s)})}function vm(i,e){S2[i]=e}function Yre(i){T2(i),gm.length=0,i.forEach(r=>{gm.push({type:r.type??"NoTypeSpecified",name:r.name})});const e=ma("includeSubset",void 0),t=ma("excludeSubset",void 0);let s=[...i];if(e){const r=e.split(",");s=s.filter((n,a)=>{const o=r.some(u=>{const h=parseInt(u,10);return!isNaN(h)&&h-1===a}),l=n.name&&r.includes(n.name);return o||l})}if(t){const r=t.split(",");s=s.filter((n,a)=>{const o=r.some(u=>{const h=parseInt(u,10);return!isNaN(h)&&h-1===a}),l=n.name&&r.includes(n.name);return!(o||l)})}return s}function Xre(i){return i<=0?[]:Array.from({length:i},(e,t)=>{const s=i-t;return{draw:(r,n,a)=>{r.save(),r.fillStyle="black",r.font=`bold ${Math.min(n,a)*.02*2}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(s.toString(),n/2,a/2),r.restore()},displayDuration:1e3,ignoreData:!0}})}function P2(i){return`user_${i}`}function Xh(i){const e=[],t={};let s=0;function r(l){return`${l}_auto_${s++}`}function n(l){return(u,h)=>l(h,u)}function a(l){return(u,h)=>{const c=l(h,u);return typeof c=="object"&&c!==null?{...u,...c}:(console.warn("Store update function did not return an object. Store remains unchanged.",{data:h,store:u}),u)}}function o(l){for(const u of l){let h=!1;if(typeof u=="object"&&u!==null&&"type"in u)switch(u.type){case"MARKER":{const d=u;t[P2(d.id)]=e.length,h=!0;break}case"IF_GOTO":{const d=u,f=n(d.cond);e.push({type:"IfGoto",cond:f,marker:P2(d.marker)}),h=!0;break}case"UPDATE_STORE":{const f=a(u.fun);e.push({type:"UpdateStore",fun:f}),h=!0;break}case"IF_BLOCK":{const d=u,f=r("if_end"),y=n(d.cond);e.push({type:"IfGoto",cond:(v,m)=>!y(v,m),marker:f}),o(d.timeline),t[f]=e.length,h=!0;break}case"WHILE_BLOCK":{const d=u,f=r("while_start"),y=r("while_end"),v=n(d.cond);t[f]=e.length,e.push({type:"IfGoto",cond:(m,g)=>!v(m,g),marker:y}),o(d.timeline),e.push({type:"IfGoto",cond:()=>!0,marker:f}),t[y]=e.length,h=!0;break}}h||e.push({type:"ExecuteContent",content:u})}}return o(i),{instructions:e,markers:t}}function ec(i,e,t,s){const r=typeof e.metadata=="function"?e.metadata(t,s):e.metadata;return e.nestMetadata?{...i,metadata:r}:r?{...r,...i}:i}function In(i,e,t,s,r){let n=e;for(;n<i.instructions.length;){const a=i.instructions[n];switch(a.type){case"ExecuteContent":return n;case"IfGoto":if(a.cond(t(),s())){const o=i.markers[a.marker];if(o!==void 0){n=o;continue}}n++;break;case"UpdateStore":r(a.fun(t(),s())),n++;break;default:n++}}return n}const ym={};function Qs(i,e,t){ym[i]={simulate:e,defaultSimulators:t}}function ene(i){return ym[i]}const ho=(i,e,t,s)=>({responseData:{},participantState:s});function Cm(i,e,t){const s=typeof i.props=="function"?i.props(e,t):i.props||{},r=ym[i.type],n=typeof i.simulate=="function"?i.simulate:r==null?void 0:r.simulate;if(!n)throw new Error(`No simulation registered for trial type '${i.type}' (name: '${i.name??"unnamed"}'). Register one with registerSimulation() or add a simulate function to the timeline item.`);const a={...r==null?void 0:r.defaultSimulators,...i.simulators};return{trialProps:s,simulateFn:n,simulators:a}}let I2="http://localhost:8001/backend";function tne(i){I2=i}function R2(){return I2}let A2;function L2(){return A2}async function sne(i,e){A2={...e};let t={...e};const s=Xh(i);let r={};const n=[{index:-1,trialNumber:-1,start:0,end:0,duration:0,type:"",name:"",responseData:{userAgent:"simulated",params:{}}}],a=()=>r,o=()=>n,l=d=>{r=d};let u=0,h=0,c=In(s,0,a,o,l);for(;c<s.instructions.length;){const d=s.instructions[c].content;if(typeof d!="object"||d===null||typeof d.type!="string"){c=In(s,c+1,a,o,l);continue}const{trialProps:f,simulateFn:y,simulators:v}=Cm(d,n,r),m=await y(f,{data:n,store:r},v,t);t=m.participantState,m.storeUpdates&&(r={...r,...m.storeUpdates}),u++;const g=m.duration??0,b=h;h+=g;let x={index:c,trialNumber:u,start:b,end:h,duration:g,type:d.type,name:d.name??"",...d.csv!==void 0?{csv:d.csv}:{},responseData:m.responseData};n.push(ec(x,d,n,r)),c=In(s,c+1,a,o,l)}return n}async function ine(i,e){const{spawn:t}=await import("child_process"),s=i.backendPort??8001,r=`http://localhost:${s}/backend`,n=typeof i.participants=="function"?i.participants().length:Array.isArray(i.participants)?i.participants.length:i.participants.count,a=t("npx",["tsx","src/backend.ts"],{cwd:"./backend",stdio:["ignore","pipe","pipe"]});await new Promise((o,l)=>{var u,h;a.on("error",l),(u=a.stdout)==null||u.on("data",c=>{c.toString().includes("REACTIVE_BACKEND_READY")&&o()}),(h=a.stderr)==null||h.on("data",c=>{console.error(`[backend] ${c.toString().trim()}`)}),setTimeout(()=>l(new Error("Backend did not start within 10 seconds")),1e4)}),console.log(`Backend running on port ${s}`);try{const o=i.concurrency??(await import("os")).cpus().length;console.log(`Simulating ${n} participants (concurrency: ${o})...`);let l=0;const u=[],h=()=>{const f=Math.min(100,Math.round(l/n*100)),y=Math.floor(f/2),v="█".repeat(y)+"░".repeat(50-y);process.stdout.write(`\r ${v} ${l}/${n} (${f}%)`)},c=f=>new Promise(y=>{var g;let v="";const m=t("npx",["tsx",e],{env:{...process.env,_REACTIVE_WORKER_INDEX:String(f),_REACTIVE_BACKEND_URL:r,...i.seed!==void 0?{_REACTIVE_SIMULATION_SEED:String(i.seed)}:{}},stdio:["ignore","pipe","pipe"]});(g=m.stderr)==null||g.on("data",b=>{v+=b.toString()}),m.on("close",b=>{b!==0&&u.push({index:f,error:v.trim()||`exited with code ${b}`}),l++,h(),y()}),m.on("error",b=>{u.push({index:f,error:b.message}),l++,h(),y()})});h();let d=0;if(await new Promise(f=>{const y=()=>{if(d>=n){l>=n&&f();return}const v=d++;c(v).then(y)};for(let v=0;v<Math.min(o,n);v++)y()}),process.stdout.write(`
10148
+ */var Ire=it,d2=Cre,Rre=Pre;Ire(d2,"factory",Rre);var Are=d2;const Lre=za(Are),Ts=new Uint32Array(1);function _re(i){return Ts[0]=i,Ts[0]=(Ts[0]<<16|Ts[0]>>16)>>>0,Ts[0]=(Ts[0]&1431655765)<<1|(Ts[0]&2863311530)>>>1>>>0,Ts[0]=(Ts[0]&858993459)<<2|(Ts[0]&3435973836)>>>2>>>0,Ts[0]=(Ts[0]&252645135)<<4|(Ts[0]&4042322160)>>>4>>>0,Ts[0]=(Ts[0]&16711935)<<8|(Ts[0]&4278255360)>>>8>>>0,Ts[0]*23283064365386963e-26}function Dre(i,e){let t=1,s=0;for(;i>0;)t/=e,s+=t*(i%e),i=~~(i/e);return s}const kre=(i,e=[2,3])=>Array.from({length:i},(t,s)=>e.map(r=>r===2?_re(s):Dre(s,r)));X.normal=qC,X.poisson=db,X.uniform=Vb;function Ore(i){const e=LB.factory({seed:i});X.normal=qC.factory({prng:e.normalized}),X.poisson=db.factory({prng:e.normalized}),X.uniform=Vb.factory({prng:e.normalized}),Math.random=()=>X.uniform(0,1)}function p2(i){return Math.max(1e-10,Math.min(1-1e-10,i))}function f2(i){switch(i.distribution){case"uniform":return e=>i.min+e*(i.max-i.min);case"normal":return e=>UK(p2(e),i.mean,i.sd);case"poisson":return e=>Lre(p2(e),i.mean)}}function m2(i,e){const t=e.map(f2);return e.length===1?i.map(s=>t[0](s[0])):i.map(s=>s.map((r,n)=>t[n](r)))}const Mre=[[1,0,[1]],[2,1,[1,1]],[3,1,[1,3,7]],[3,2,[1,1,5]],[4,1,[1,3,1,1]],[4,4,[1,1,3,7]],[5,2,[1,3,3,9,9]],[5,13,[1,3,7,13,3]],[5,7,[1,1,5,11,27]],[5,14,[1,3,5,1,15]],[5,11,[1,1,7,3,29]],[5,4,[1,3,7,7,21]],[6,1,[1,1,1,9,23,37]],[6,16,[1,3,3,5,19,33]],[6,13,[1,1,3,13,11,7]],[6,22,[1,1,7,13,25,5]],[6,19,[1,3,5,11,7,11]],[6,25,[1,1,1,3,13,39]],[7,1,[1,3,1,15,17,63,13]],[7,32,[1,1,5,5,1,59,33]]],oo=32,Nre=2**oo;function Fre(i){const e=new Uint32Array(oo);if(i===0){for(let n=0;n<oo;n++)e[n]=1<<oo-1-n;return e}const[t,s,r]=Mre[i-1];for(let n=0;n<t;n++)e[n]=r[n]<<oo-1-n;for(let n=t;n<oo;n++){e[n]=e[n-t]^e[n-t]>>>t;for(let a=1;a<t;a++)s>>>t-1-a&1&&(e[n]^=e[n-a])}return e}function qre(i,e){if(e<1||e>21)throw new RangeError("sobol() supports 1-21 dimensions");const t=Array.from({length:e},(n,a)=>Fre(a)),s=new Uint32Array(e),r=[new Array(e).fill(0)];for(let n=1;n<i;n++){let a=0,o=n-1;for(;(o&1)===1;)o>>>=1,a++;for(let l=0;l<e;l++)s[l]^=t[l][a];r.push(Array.from(s,l=>l/Nre))}return r}const Bre=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73],g2=6;function v2(i,e){const t=qre(i+1,e.length).slice(1);return m2(t,e)}function y2(i,e){e.length>g2&&console.warn(`Halton sequence quality degrades above ${g2} dimensions. Consider using sobol() instead.`);const t=Bre.slice(0,e.length),s=kre(i+1,t).slice(1);return m2(s,e)}function $re(i,e,t){const s=Object.keys(t),r=s.map(a=>t[a]);let n;switch(i){case"sobol":n=v2(e,r);break;case"halton":n=y2(e,r);break;case"random":n=Hre(e,r);break}return Array.from({length:e},(a,o)=>{const l=s.length===1?[n[o]]:n[o];return Object.fromEntries(s.map((u,h)=>[u,l[h]]))})}function Hre(i,e){const t=e.map(f2);return e.length===1?Array.from({length:i},()=>t[0](X.uniform(0,1))):Array.from({length:i},()=>t.map(s=>s(X.uniform(0,1))))}function C2(i,e=1){const t=[];if(i.length===0)return t;for(let s=0;s<e;s++){const r=Math.floor(X.uniform(0,1)*i.length);t.push(i[r])}return t}function fm(i){const e=[...i];for(let t=e.length-1;t>=0;t--){const s=Math.floor(X.uniform(0,1)*(t+1));[e[t],e[s]]=[e[s],e[t]]}return e}function b2(i,e){return e(i)}function w2(i,e){const t=Math.ceil(i.length/e);return Array.from({length:Math.ceil(i.length/t)},(s,r)=>i.slice(r*t,r*t+t))}function Qre(){typeof Array.prototype.sample!="function"&&(Array.prototype.sample=function(i){return C2(this,i)}),typeof Array.prototype.shuffle!="function"&&(Array.prototype.shuffle=function(){return fm(this)}),typeof Array.prototype.pipe!="function"&&(Array.prototype.pipe=function(i){return b2(this,i)}),typeof Array.prototype.chunk!="function"&&(Array.prototype.chunk=function(i){return w2(this,i)})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var lo;(function(i){i.Unimplemented="UNIMPLEMENTED",i.Unavailable="UNAVAILABLE"})(lo||(lo={}));class mm extends Error{constructor(e,t,s){super(e),this.message=e,this.code=t,this.data=s}}const Ure=i=>{var e,t;return i!=null&&i.androidBridge?"android":!((t=(e=i==null?void 0:i.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||t===void 0)&&t.bridge?"ios":"web"},zre=i=>{const e=i.CapacitorCustomPlatform||null,t=i.Capacitor||{},s=t.Plugins=t.Plugins||{},r=()=>e!==null?e.name:Ure(i),n=()=>r()!=="web",a=c=>{const d=u.get(c);return!!(d!=null&&d.platforms.has(r())||o(c))},o=c=>{var d;return(d=t.PluginHeaders)===null||d===void 0?void 0:d.find(f=>f.name===c)},l=c=>i.console.error(c),u=new Map,h=(c,d={})=>{const f=u.get(c);if(f)return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`),f.proxy;const y=r(),v=o(c);let m;const g=async()=>(!m&&y in d?m=typeof d[y]=="function"?m=await d[y]():m=d[y]:e!==null&&!m&&"web"in d&&(m=typeof d.web=="function"?m=await d.web():m=d.web),m),b=(T,k)=>{var q,B;if(v){const U=v==null?void 0:v.methods.find(D=>k===D.name);if(U)return U.rtype==="promise"?D=>t.nativePromise(c,k.toString(),D):(D,H)=>t.nativeCallback(c,k.toString(),D,H);if(T)return(q=T[k])===null||q===void 0?void 0:q.bind(T)}else{if(T)return(B=T[k])===null||B===void 0?void 0:B.bind(T);throw new mm(`"${c}" plugin is not implemented on ${y}`,lo.Unimplemented)}},x=T=>{let k;const q=(...B)=>{const U=g().then(D=>{const H=b(D,T);if(H){const Q=H(...B);return k=Q==null?void 0:Q.remove,Q}else throw new mm(`"${c}.${T}()" is not implemented on ${y}`,lo.Unimplemented)});return T==="addListener"&&(U.remove=async()=>k()),U};return q.toString=()=>`${T.toString()}() { [capacitor code] }`,Object.defineProperty(q,"name",{value:T,writable:!1,configurable:!1}),q},P=x("addListener"),R=x("removeListener"),A=(T,k)=>{const q=P({eventName:T},k),B=async()=>{const D=await q;R({eventName:T,callbackId:D},k)},U=new Promise(D=>q.then(()=>D({remove:B})));return U.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await B()},U},_=new Proxy({},{get(T,k){switch(k){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return v?A:P;case"removeListener":return R;default:return x(k)}}});return s[c]=_,u.set(c,{name:c,proxy:_,platforms:new Set([...Object.keys(d),...v?[y]:[]])}),_};return t.convertFileSrc||(t.convertFileSrc=c=>c),t.getPlatform=r,t.handleError=l,t.isNativePlatform=n,t.isPluginAvailable=a,t.registerPlugin=h,t.Exception=mm,t.DEBUG=!!t.DEBUG,t.isLoggingEnabled=!!t.isLoggingEnabled,t},fa=(i=>i.Capacitor=zre(i))(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),_l=fa.registerPlugin;class Zh{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,t){let s=!1;this.listeners[e]||(this.listeners[e]=[],s=!0),this.listeners[e].push(t);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n),s&&this.sendRetainedArgumentsForEvent(e);const a=async()=>this.removeListener(e,t);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t,s){const r=this.listeners[e];if(!r){if(s){let n=this.retainedEventArguments[e];n||(n=[]),n.push(t),this.retainedEventArguments[e]=n}return}r.forEach(n=>n(t))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:s=>{this.notifyListeners(t,s)}}}unimplemented(e="not implemented"){return new fa.Exception(e,lo.Unimplemented)}unavailable(e="not available"){return new fa.Exception(e,lo.Unavailable)}async removeListener(e,t){const s=this.listeners[e];if(!s)return;const r=s.indexOf(t);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const t=this.retainedEventArguments[e];t&&(delete this.retainedEventArguments[e],t.forEach(s=>{this.notifyListeners(e,s)}))}}const x2=i=>encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),E2=i=>i.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class jre extends Zh{async getCookies(){const e=document.cookie,t={};return e.split(";").forEach(s=>{if(s.length<=0)return;let[r,n]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");r=E2(r).trim(),n=E2(n).trim(),t[r]=n}),t}async setCookie(e){try{const t=x2(e.key),s=x2(e.value),r=`; expires=${(e.expires||"").replace("expires=","")}`,n=(e.path||"/").replace("path=",""),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${s||""}${r}; path=${n}; ${a};`}catch(t){return Promise.reject(t)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(t){return Promise.reject(t)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}_l("CapacitorCookies",{web:()=>new jre});const Wre=async i=>new Promise((e,t)=>{const s=new FileReader;s.onload=()=>{const r=s.result;e(r.indexOf(",")>=0?r.split(",")[1]:r)},s.onerror=r=>t(r),s.readAsDataURL(i)}),Gre=(i={})=>{const e=Object.keys(i);return Object.keys(i).map(r=>r.toLocaleLowerCase()).reduce((r,n,a)=>(r[n]=i[e[a]],r),{})},Kre=(i,e=!0)=>i?Object.entries(i).reduce((s,r)=>{const[n,a]=r;let o,l;return Array.isArray(a)?(l="",a.forEach(u=>{o=e?encodeURIComponent(u):u,l+=`${n}=${o}&`}),l.slice(0,-1)):(o=e?encodeURIComponent(a):a,l=`${n}=${o}`),`${s}&${l}`},"").substr(1):null,V2=(i,e={})=>{const t=Object.assign({method:i.method||"GET",headers:i.headers},e),r=Gre(i.headers)["content-type"]||"";if(typeof i.data=="string")t.body=i.data;else if(r.includes("application/x-www-form-urlencoded")){const n=new URLSearchParams;for(const[a,o]of Object.entries(i.data||{}))n.set(a,o);t.body=n.toString()}else if(r.includes("multipart/form-data")||i.data instanceof FormData){const n=new FormData;if(i.data instanceof FormData)i.data.forEach((o,l)=>{n.append(l,o)});else for(const o of Object.keys(i.data))n.append(o,i.data[o]);t.body=n;const a=new Headers(t.headers);a.delete("content-type"),t.headers=a}else(r.includes("application/json")||typeof i.data=="object")&&(t.body=JSON.stringify(i.data));return t};class Zre extends Zh{async request(e){const t=V2(e,e.webFetchExtra),s=Kre(e.params,e.shouldEncodeUrlParams),r=s?`${e.url}?${s}`:e.url,n=await fetch(r,t),a=n.headers.get("content-type")||"";let{responseType:o="text"}=n.ok?e:{};a.includes("application/json")&&(o="json");let l,u;switch(o){case"arraybuffer":case"blob":u=await n.blob(),l=await Wre(u);break;case"json":l=await n.json();break;case"document":case"text":default:l=await n.text()}const h={};return n.headers.forEach((c,d)=>{h[d]=c}),{data:l,headers:h,status:n.status,url:n.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}_l("CapacitorHttp",{web:()=>new Zre});function Ps(){return Math.round(performance.now())}function uo(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}function Jre(){return window.electronAPI!==void 0}const Jh=[];function ma(i,e,t="string",s,r){let n=Jh.find(d=>d.name===i);n||(n={name:i,defaultValue:r!==void 0?r:e,type:t,description:s,value:void 0},Jh.push(n));const a={string:d=>d,number:d=>{const f=Number(d);return isNaN(f)?e:f},boolean:d=>d.toLowerCase()==="true",array:d=>{try{return JSON.parse(d)}catch{return e}},json:d=>{try{return JSON.parse(d)}catch{return e}}},o=d=>t==="string"&&typeof d=="string"||t==="number"&&typeof d=="number"||t==="boolean"&&typeof d=="boolean"||t==="array"&&Array.isArray(d)||t==="json"&&typeof d=="object"&&d!==null?d:typeof d=="string"?d.toLowerCase()==="undefined"?e:a[t](d):e,l=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,u=l.get("_b");if(u)try{const d=atob(u),f=JSON.parse(d);if(i in f){const y=o(f[i]);return n.value=y,y}}catch{}const h=l.get(i);if(h==null)return e;const c=o(h);return n.value=c,c}const gm=[];class Yh{static getRegistry(){return[...Jh]}static getTimelineRepresentation(){return[...gm]}}const Dl=()=>window.electronAPI?"desktop":fa.isNativePlatform()?"mobile":"web",S2={};function T2(i){i.forEach(e=>{const t=S2[e.type];if(t)for(const s of t)(!e.hideSettings||e.hideSettings!==!0&&!e.hideSettings.includes(s.name))&&Jh.push(s)})}function vm(i,e){S2[i]=e}function Yre(i){T2(i),gm.length=0,i.forEach(r=>{gm.push({type:r.type??"NoTypeSpecified",name:r.name})});const e=ma("includeSubset",void 0),t=ma("excludeSubset",void 0);let s=[...i];if(e){const r=e.split(",");s=s.filter((n,a)=>{const o=r.some(u=>{const h=parseInt(u,10);return!isNaN(h)&&h-1===a}),l=n.name&&r.includes(n.name);return o||l})}if(t){const r=t.split(",");s=s.filter((n,a)=>{const o=r.some(u=>{const h=parseInt(u,10);return!isNaN(h)&&h-1===a}),l=n.name&&r.includes(n.name);return!(o||l)})}return s}function Xre(i){return i<=0?[]:Array.from({length:i},(e,t)=>{const s=i-t;return{draw:(r,n,a)=>{r.save(),r.fillStyle="black",r.font=`bold ${Math.min(n,a)*.02*2}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(s.toString(),n/2,a/2),r.restore()},displayDuration:1e3,ignoreData:!0}})}function P2(i){return`user_${i}`}function Xh(i){const e=[],t={};let s=0;function r(l){return`${l}_auto_${s++}`}function n(l){return(u,h)=>l(h,u)}function a(l){return(u,h)=>{const c=l(h,u);return typeof c=="object"&&c!==null?{...u,...c}:(console.warn("Store update function did not return an object. Store remains unchanged.",{data:h,store:u}),u)}}function o(l){for(const u of l){let h=!1;if(typeof u=="object"&&u!==null&&"type"in u)switch(u.type){case"MARKER":{const d=u;t[P2(d.id)]=e.length,h=!0;break}case"IF_GOTO":{const d=u,f=n(d.cond);e.push({type:"IfGoto",cond:f,marker:P2(d.marker)}),h=!0;break}case"UPDATE_STORE":{const f=a(u.fun);e.push({type:"UpdateStore",fun:f}),h=!0;break}case"IF_BLOCK":{const d=u,f=r("if_end"),y=n(d.cond);e.push({type:"IfGoto",cond:(v,m)=>!y(v,m),marker:f}),o(d.timeline),t[f]=e.length,h=!0;break}case"WHILE_BLOCK":{const d=u,f=r("while_start"),y=r("while_end"),v=n(d.cond);t[f]=e.length,e.push({type:"IfGoto",cond:(m,g)=>!v(m,g),marker:y}),o(d.timeline),e.push({type:"IfGoto",cond:()=>!0,marker:f}),t[y]=e.length,h=!0;break}}h||e.push({type:"ExecuteContent",content:u})}}return o(i),{instructions:e,markers:t}}function ec(i,e,t,s){const r=typeof e.metadata=="function"?e.metadata(t,s):e.metadata;return e.nestMetadata?{...i,metadata:r}:r?{...r,...i}:i}function In(i,e,t,s,r){let n=e;for(;n<i.instructions.length;){const a=i.instructions[n];switch(a.type){case"ExecuteContent":return n;case"IfGoto":if(a.cond(t(),s())){const o=i.markers[a.marker];if(o!==void 0){n=o;continue}}n++;break;case"UpdateStore":r(a.fun(t(),s())),n++;break;default:n++}}return n}const ym={};function Qs(i,e,t){ym[i]={simulate:e,defaultSimulators:t}}function ene(i){return ym[i]}const ho=(i,e,t,s)=>({responseData:{},participantState:s});function Cm(i,e,t){const s=typeof i.props=="function"?i.props(e,t):i.props||{},r=ym[i.type],n=typeof i.simulate=="function"?i.simulate:r==null?void 0:r.simulate;if(!n)throw new Error(`No simulation registered for trial type '${i.type}' (name: '${i.name??"unnamed"}'). Register one with registerSimulation() or add a simulate function to the timeline item.`);const a={...r==null?void 0:r.defaultSimulators,...i.simulators};return{trialProps:s,simulateFn:n,simulators:a}}let I2="http://localhost:8001/backend";function tne(i){I2=i}function R2(){return I2}let A2;function L2(){return A2}async function sne(i,e){A2={...e};let t={...e};const s=Xh(i);let r={};const n=[{index:-1,trialNumber:-1,start:0,end:0,duration:0,type:"",name:"",responseData:{userAgent:"simulated",params:{}}}],a=()=>r,o=()=>n,l=d=>{r=d};let u=0,h=0,c=In(s,0,a,o,l);for(;c<s.instructions.length;){const d=s.instructions[c].content;if(typeof d!="object"||d===null||typeof d.type!="string"){c=In(s,c+1,a,o,l);continue}const{trialProps:f,simulateFn:y,simulators:v}=Cm(d,n,r),m=await y(f,{data:n,store:r},v,t);t=m.participantState,m.storeUpdates&&(r={...r,...m.storeUpdates}),u++;const g=m.duration??0,b=h;h+=g;let x={index:c,trialNumber:u,start:b,end:h,duration:g,type:d.type,name:d.name??"",...d.csv!==void 0?{csv:d.csv}:{},responseData:m.responseData};n.push(ec(x,d,n,r)),c=In(s,c+1,a,o,l)}return n}async function ine(i,e){const{spawn:t}=await import("child_process"),s=i.backendPort??8001,r=`http://localhost:${s}/backend`,n=typeof i.participants=="function"?i.participants().length:Array.isArray(i.participants)?i.participants.length:i.participants.count,a=t("npx",["tsx","src/backend.ts"],{cwd:"./backend",stdio:["ignore","pipe","pipe"]});await new Promise((o,l)=>{var u,h;a.on("error",l),(u=a.stdout)==null||u.on("data",c=>{c.toString().includes("REACTIVE_BACKEND_READY")&&o()}),(h=a.stderr)==null||h.on("data",c=>{console.error(`[backend] ${c.toString().trim()}`)}),setTimeout(()=>l(new Error("Backend did not start within 10 seconds")),1e4)}),console.log(`Backend running on port ${s}`);try{const o=i.concurrency??(await import("os")).cpus().length;console.log(`Simulating ${n} participants (concurrency: ${o})...`);let l=0;const u=[],h=()=>{const f=Math.min(100,Math.round(l/n*100)),y=Math.floor(f/2),v="█".repeat(y)+"░".repeat(50-y);process.stdout.write(`\r ${v} ${l}/${n} (${f}%)`)},c=f=>new Promise(y=>{var g;let v="";const m=t("npx",["tsx",e],{env:{...process.env,_REACTIVE_WORKER_INDEX:String(f),_REACTIVE_BACKEND_URL:r,...i.seed!==void 0?{_REACTIVE_SIMULATION_SEED:String(i.seed)}:{}},stdio:["ignore","pipe","pipe"]});(g=m.stderr)==null||g.on("data",b=>{v+=b.toString()}),m.on("close",b=>{b!==0&&u.push({index:f,error:v.trim()||`exited with code ${b}`}),l++,h(),y()}),m.on("error",b=>{u.push({index:f,error:b.message}),l++,h(),y()})});h();let d=0;if(await new Promise(f=>{const y=()=>{if(d>=n){l>=n&&f();return}const v=d++;c(v).then(y)};for(let v=0;v<Math.min(o,n);v++)y()}),process.stdout.write(`
10149
10149
  `),u.length>0){console.error(`
10150
10150
  ${u.length} participant(s) failed:`);for(const{index:f,error:y}of u)console.error(` Participant ${f}: ${y}`)}console.log(`Simulation complete. ${l-u.length}/${n} participants simulated successfully.`)}finally{a.kill(),console.log("Backend stopped.")}}const tc={};function ni(i,e,t){tc[i]||(tc[i]=[]),tc[i].push({csv:e,flatten:t})}function _2(i){const e=i.responseData;return Array.isArray(e)?e.map(t=>({block:i.name,...t})):[]}function D2(i){if(i==null)return"";const e=String(i);return e.includes(",")||e.includes('"')||e.includes(`
10151
10151
  `)?`"${e.replace(/"/g,'""')}"`:e}function sc(i){if(!i||i.length===0)return"";const e=new Set;i.forEach(n=>{Object.keys(n).forEach(a=>{e.add(a)})});const t=Array.from(e),s=t.map(n=>D2(n)).join(","),r=i.map(n=>t.map(a=>{const o=n[a];return D2(o)}).join(","));return[s,...r].join(`
@@ -10278,6 +10278,6 @@ Click the button below to add a new entry.`,noEntriesReadonlyText:"No entries",t
10278
10278
  ${x}px !important;
10279
10279
  ${P}px !important;
10280
10280
  }
10281
- `),()=>{var _;(_=o.current)==null||_.removeAttribute("data-motion-pop-id"),A.contains(R)&&A.removeChild(R)}},[e]),L.jsx(Ave,{isPresent:e,childRef:o,sizeRef:l,pop:n,children:n===!1?i:p.cloneElement(i,{ref:c})})}const _ve=({children:i,initial:e,isPresent:t,onExitComplete:s,custom:r,presenceAffectsLayout:n,mode:a,anchorX:o,anchorY:l,root:u})=>{const h=Jg(Dve),c=S.useId();let d=!0,f=S.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:t,custom:r,onExitComplete:y=>{h.set(y,!0);for(const v of h.values())if(!v)return;s&&s()},register:y=>(h.set(y,!1),()=>h.delete(y))}),[t,h,s]);return n&&d&&(f={...f}),S.useMemo(()=>{h.forEach((y,v)=>h.set(v,!1))},[t]),p.useEffect(()=>{!t&&!h.size&&s&&s()},[t]),i=L.jsx(Lve,{pop:a==="popLayout",isPresent:t,anchorX:o,anchorY:l,root:u,children:i}),L.jsx(Sd.Provider,{value:f,children:i})};function Dve(){return new Map}function X7(i=!0){const e=S.useContext(Sd);if(e===null)return[!0,null];const{isPresent:t,onExitComplete:s,register:r}=e,n=S.useId();S.useEffect(()=>{if(i)return r(n)},[i]);const a=S.useCallback(()=>i&&s&&s(n),[n,s,i]);return!t&&s?[!1,a]:[!0]}const Wd=i=>i.key||"";function e4(i){const e=[];return S.Children.forEach(i,t=>{S.isValidElement(t)&&e.push(t)}),e}const kve=({children:i,custom:e,initial:t=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:n="sync",propagate:a=!1,anchorX:o="left",anchorY:l="top",root:u})=>{const[h,c]=X7(a),d=S.useMemo(()=>e4(i),[i]),f=a&&!h?[]:d.map(Wd),y=S.useRef(!0),v=S.useRef(d),m=Jg(()=>new Map),g=S.useRef(new Set),[b,x]=S.useState(d),[P,R]=S.useState(d);Yg(()=>{y.current=!1,v.current=d;for(let T=0;T<P.length;T++){const k=Wd(P[T]);f.includes(k)?(m.delete(k),g.current.delete(k)):m.get(k)!==!0&&m.set(k,!1)}},[P,f.length,f.join("-")]);const A=[];if(d!==b){let T=[...d];for(let k=0;k<P.length;k++){const q=P[k],B=Wd(q);f.includes(B)||(T.splice(k,0,q),A.push(q))}return n==="wait"&&A.length&&(T=A),R(e4(T)),x(d),null}process.env.NODE_ENV!=="production"&&n==="wait"&&P.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:_}=S.useContext(vu);return L.jsx(L.Fragment,{children:P.map(T=>{const k=Wd(T),q=a&&!h?!1:d===P||f.includes(k),B=()=>{if(g.current.has(k))return;if(m.has(k))g.current.add(k),m.set(k,!0);else return;let U=!0;m.forEach(D=>{D||(U=!1)}),U&&(_==null||_(),R(v.current),a&&(c==null||c()),s&&s())};return L.jsx(_ve,{isPresent:q,initial:!y.current||t?void 0:!1,custom:e,presenceAffectsLayout:r,mode:n,root:u,onExitComplete:q?void 0:B,anchorX:o,anchorY:l,children:T},k)})})},Ove=S.createContext(null);function Mve(){const i=S.useRef(!1);return Yg(()=>(i.current=!0,()=>{i.current=!1}),[]),i}function Nve(){const i=Mve(),[e,t]=S.useState(0),s=S.useCallback(()=>{i.current&&t(e+1)},[e]);return[S.useCallback(()=>Tt.postRender(s),[s]),e]}const t4=i=>i===!0,Fve=i=>t4(i===!0)||i==="id",qve=({children:i,id:e,inherit:t=!0})=>{const s=S.useContext(vu),r=S.useContext(Ove),[n,a]=Nve(),o=S.useRef(null),l=s.id||r;o.current===null&&(Fve(t)&&l&&(e=e?l+"-"+e:l),o.current={id:e,group:t4(t)&&s.group||Z7()});const u=S.useMemo(()=>({...o.current,forceRender:n}),[a]);return L.jsx(vu.Provider,{value:u,children:i})},s4=S.createContext({strict:!1}),i4={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let r4=!1;function Bve(){if(r4)return;const i={};for(const e in i4)i[e]={isEnabled:t=>i4[e].some(s=>!!t[s])};Z3(i),r4=!0}function n4(){return Bve(),vge()}function $ve(i){const e=n4();for(const t in i)e[t]={...e[t],...i[t]};Z3(e)}const Hve=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Gd(i){return i.startsWith("while")||i.startsWith("drag")&&i!=="draggable"||i.startsWith("layout")||i.startsWith("onTap")||i.startsWith("onPan")||i.startsWith("onLayout")||Hve.has(i)}let a4=i=>!Gd(i);function Qve(i){typeof i=="function"&&(a4=e=>e.startsWith("on")?!Gd(e):i(e))}try{Qve(require("@emotion/is-prop-valid").default)}catch{}function Uve(i,e,t){const s={};for(const r in i)r==="values"&&typeof i.values=="object"||ks(i[r])||(a4(r)||t===!0&&Gd(r)||!e&&!Gd(r)||i.draggable&&r.startsWith("onDrag"))&&(s[r]=i[r]);return s}const Kd=S.createContext({});function zve(i,e){if(Bd(i)){const{initial:t,animate:s}=i;return{initial:t===!1||Su(t)?t:void 0,animate:Su(s)?s:void 0}}return i.inherit!==!1?e:{}}function jve(i){const{initial:e,animate:t}=zve(i,S.useContext(Kd));return S.useMemo(()=>({initial:e,animate:t}),[o4(e),o4(t)])}function o4(i){return Array.isArray(i)?i.join(" "):i}const r0=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function l4(i,e,t){for(const s in e)!ks(e[s])&&!h7(s,t)&&(i[s]=e[s])}function Wve({transformTemplate:i},e){return S.useMemo(()=>{const t=r0();return Zv(t,e,i),Object.assign({},t.vars,t.style)},[e])}function Gve(i,e){const t=i.style||{},s={};return l4(s,t,i),Object.assign(s,Wve(i,e)),s}function Kve(i,e){const t={},s=Gve(i,e);return i.drag&&i.dragListener!==!1&&(t.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=i.drag===!0?"none":`pan-${i.drag==="x"?"y":"x"}`),i.tabIndex===void 0&&(i.onTap||i.onTapStart||i.whileTap)&&(t.tabIndex=0),t.style=s,t}const u4=()=>({...r0(),attrs:{}});function Zve(i,e,t,s){const r=S.useMemo(()=>{const n=u4();return c7(n,e,p7(s),i.transformTemplate,i.style),{...n.attrs,style:{...n.style}}},[e]);if(i.style){const n={};l4(n,i.style,i),r.style={...n,...r.style}}return r}const Jve=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function n0(i){return typeof i!="string"||i.includes("-")?!1:!!(Jve.indexOf(i)>-1||/[A-Z]/u.test(i))}function Yve(i,e,t,{latestValues:s},r,n=!1,a){const l=(a??n0(i)?Zve:Kve)(e,s,r,i),u=Uve(e,typeof i=="string",n),h=i!==S.Fragment?{...u,...l,ref:t}:{},{children:c}=e,d=S.useMemo(()=>ks(c)?c.get():c,[c]);return S.createElement(i,{...h,children:d})}function Xve({scrapeMotionValuesFromProps:i,createRenderState:e},t,s,r){return{latestValues:e0e(t,s,r,i),renderState:e()}}function e0e(i,e,t,s){const r={},n=s(i,{});for(const d in n)r[d]=zd(n[d]);let{initial:a,animate:o}=i;const l=Bd(i),u=W3(i);e&&u&&!l&&i.inherit!==!1&&(a===void 0&&(a=e.initial),o===void 0&&(o=e.animate));let h=t?t.initial===!1:!1;h=h||a===!1;const c=h?o:a;if(c&&typeof c!="boolean"&&!qd(c)){const d=Array.isArray(c)?c:[c];for(let f=0;f<d.length;f++){const y=_v(i,d[f]);if(y){const{transitionEnd:v,transition:m,...g}=y;for(const b in g){let x=g[b];if(Array.isArray(x)){const P=h?x.length-1:0;x=x[P]}x!==null&&(r[b]=x)}for(const b in v)r[b]=v[b]}}}return r}const h4=i=>(e,t)=>{const s=S.useContext(Kd),r=S.useContext(Sd),n=()=>Xve(i,e,s,r);return t?n():Jg(n)},t0e=h4({scrapeMotionValuesFromProps:Yv,createRenderState:r0}),s0e=h4({scrapeMotionValuesFromProps:f7,createRenderState:u4}),i0e=Symbol.for("motionComponentSymbol");function r0e(i,e,t){const s=S.useRef(t);S.useInsertionEffect(()=>{s.current=t});const r=S.useRef(null);return S.useCallback(n=>{var o;n&&((o=i.onMount)==null||o.call(i,n));const a=s.current;if(typeof a=="function")if(n){const l=a(n);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):a(n);else a&&(a.current=n);e&&(n?e.mount(n):e.unmount())},[e])}const c4=S.createContext({});function jo(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"current")}function n0e(i,e,t,s,r,n){var x,P;const{visualElement:a}=S.useContext(Kd),o=S.useContext(s4),l=S.useContext(Sd),u=S.useContext(i0),h=u.reducedMotion,c=u.skipAnimations,d=S.useRef(null),f=S.useRef(!1);s=s||o.renderer,!d.current&&s&&(d.current=s(i,{visualState:e,parent:a,props:t,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:h,skipAnimations:c,isSVG:n}),f.current&&d.current&&(d.current.manuallyAnimateOnMount=!0));const y=d.current,v=S.useContext(c4);y&&!y.projection&&r&&(y.type==="html"||y.type==="svg")&&a0e(d.current,t,r,v);const m=S.useRef(!1);S.useInsertionEffect(()=>{y&&m.current&&y.update(t,l)});const g=t[T3],b=S.useRef(!!g&&typeof window<"u"&&!((x=window.MotionHandoffIsComplete)!=null&&x.call(window,g))&&((P=window.MotionHasOptimisedAnimation)==null?void 0:P.call(window,g)));return Yg(()=>{f.current=!0,y&&(m.current=!0,window.MotionIsMounted=!0,y.updateFeatures(),y.scheduleRenderMicrotask(),b.current&&y.animationState&&y.animationState.animateChanges())}),S.useEffect(()=>{y&&(!b.current&&y.animationState&&y.animationState.animateChanges(),b.current&&(queueMicrotask(()=>{var R;(R=window.MotionHandoffMarkAsComplete)==null||R.call(window,g)}),b.current=!1),y.enteringChildren=void 0)}),y}function a0e(i,e,t,s){const{layoutId:r,layout:n,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:u,layoutAnchor:h,layoutCrossfade:c}=e;i.projection=new t(i.latestValues,e["data-framer-portal-id"]?void 0:d4(i.parent)),i.projection.setOptions({layoutId:r,layout:n,alwaysMeasureLayout:!!a||o&&jo(o),visualElement:i,animationType:typeof n=="string"?n:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u,layoutAnchor:h})}function d4(i){if(i)return i.options.allowProjection!==!1?i.projection:d4(i.parent)}function a0(i,{forwardMotionProps:e=!1,type:t}={},s,r){s&&$ve(s);const n=t?t==="svg":n0(i),a=n?s0e:t0e;function o(u,h){let c;const d={...S.useContext(i0),...u,layoutId:o0e(u)},{isStatic:f}=d,y=jve(u),v=a(u,f);if(!f&&typeof window<"u"){l0e(d,s);const m=u0e(d);c=m.MeasureLayout,y.visualElement=n0e(i,v,d,r,m.ProjectionNode,n)}return L.jsxs(Kd.Provider,{value:y,children:[c&&y.visualElement?L.jsx(c,{visualElement:y.visualElement,...d}):null,Yve(i,u,r0e(v,y.visualElement,h),v,f,e,n)]})}o.displayName=`motion.${typeof i=="string"?i:`create(${i.displayName??i.name??""})`}`;const l=S.forwardRef(o);return l[i0e]=i,l}function o0e({layoutId:i}){const e=S.useContext(vu).id;return e&&i!==void 0?e+"-"+i:i}function l0e(i,e){const t=S.useContext(s4).strict;if(process.env.NODE_ENV!=="production"&&e&&t){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";i.ignoreStrict?Mo(!1,s,"lazy-strict-mode"):an(!1,s,"lazy-strict-mode")}}function u0e(i){const e=n4(),{drag:t,layout:s}=e;if(!t&&!s)return{};const r={...t,...s};return{MeasureLayout:t!=null&&t.isEnabled(i)||s!=null&&s.isEnabled(i)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function h0e(i,e){if(typeof Proxy>"u")return a0;const t=new Map,s=(n,a)=>a0(n,a,i,e),r=(n,a)=>(process.env.NODE_ENV!=="production"&&sv(!1,"motion() is deprecated. Use motion.create() instead."),s(n,a));return new Proxy(r,{get:(n,a)=>a==="create"?s:(t.has(a)||t.set(a,a0(a,void 0,i,e)),t.get(a))})}const c0e=(i,e)=>e.isSVG??n0(i)?new kge(e):new Ige(e,{allowProjection:i!==S.Fragment});class d0e extends Zn{constructor(e){super(e),e.animationState||(e.animationState=qge(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();qd(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let p0e=0;class f0e extends Zn{constructor(){super(...arguments),this.id=p0e++,this.isExitComplete=!1}update(){var n;if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;if(e&&s===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"){const l=Da(this.node,a,o);if(l){const{transition:u,transitionEnd:h,...c}=l;for(const d in c)(n=this.node.getValue(d))==null||n.jump(c[d])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const m0e={animation:{Feature:d0e},exit:{Feature:f0e}};function Ru(i){return{point:{x:i.pageX,y:i.pageY}}}const g0e=i=>e=>$v(e)&&i(e,Ru(e));function Au(i,e,t,s){return Iu(i,e,g0e(t),s)}const p4=({current:i})=>i?i.ownerDocument.defaultView:null,f4=(i,e)=>Math.abs(i-e);function v0e(i,e){const t=f4(i.x,e.x),s=f4(i.y,e.y);return Math.sqrt(t**2+s**2)}const m4=new Set(["auto","scroll"]);class g4{constructor(e,t,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:n=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=f=>{this.handleScroll(f.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Zd(this.lastRawMoveEventInfo,this.transformPagePoint));const f=o0(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,v=v0e(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!y&&!v)return;const{point:m}=f,{timestamp:g}=Ds;this.history.push({...m,timestamp:g});const{onStart:b,onMove:x}=this.handlers;y||(b&&b(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,f)},this.handlePointerMove=(f,y)=>{this.lastMoveEvent=f,this.lastRawMoveEventInfo=y,this.lastMoveEventInfo=Zd(y,this.transformPagePoint),Tt.update(this.updatePoint,!0)},this.handlePointerUp=(f,y)=>{this.end();const{onEnd:v,onSessionEnd:m,resumeAnimation:g}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=o0(f.type==="pointercancel"?this.lastMoveEventInfo:Zd(y,this.transformPagePoint),this.history);this.startEvent&&v&&v(f,b),m&&m(f,b)},!$v(e))return;this.dragSnapToOrigin=n,this.handlers=t,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=r||window;const l=Ru(e),u=Zd(l,this.transformPagePoint),{point:h}=u,{timestamp:c}=Ds;this.history=[{...h,timestamp:c}];const{onSessionStart:d}=t;d&&d(e,o0(u,this.history)),this.removeListeners=yu(Au(this.contextWindow,"pointermove",this.handlePointerMove),Au(this.contextWindow,"pointerup",this.handlePointerUp),Au(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){const s=getComputedStyle(t);(m4.has(s.overflowX)||m4.has(s.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const t=this.scrollPositions.get(e);if(!t)return;const s=e===window,r=s?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},n={x:r.x-t.x,y:r.y-t.y};n.x===0&&n.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=n.x,this.lastMoveEventInfo.point.y+=n.y):this.history.length>0&&(this.history[0].x-=n.x,this.history[0].y-=n.y),this.scrollPositions.set(e,r),Tt.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),jn(this.updatePoint)}}function Zd(i,e){return e?{point:e(i.point)}:i}function v4(i,e){return{x:i.x-e.x,y:i.y-e.y}}function o0({point:i},e){return{point:i,delta:v4(i,y4(e)),offset:v4(i,y0e(e)),velocity:C0e(e,.1)}}function y0e(i){return i[0]}function y4(i){return i[i.length-1]}function C0e(i,e){if(i.length<2)return{x:0,y:0};let t=i.length-1,s=null;const r=y4(i);for(;t>=0&&(s=i[t],!(r.timestamp-s.timestamp>di(e)));)t--;if(!s)return{x:0,y:0};s===i[0]&&i.length>2&&r.timestamp-s.timestamp>di(e)*2&&(s=i[1]);const n=Qi(r.timestamp-s.timestamp);if(n===0)return{x:0,y:0};const a={x:(r.x-s.x)/n,y:(r.y-s.y)/n};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function b0e(i,{min:e,max:t},s){return e!==void 0&&i<e?i=s?qt(e,i,s.min):Math.max(i,e):t!==void 0&&i>t&&(i=s?qt(t,i,s.max):Math.min(i,t)),i}function C4(i,e,t){return{min:e!==void 0?i.min+e:void 0,max:t!==void 0?i.max+t-(i.max-i.min):void 0}}function w0e(i,{top:e,left:t,bottom:s,right:r}){return{x:C4(i.x,t,r),y:C4(i.y,e,s)}}function b4(i,e){let t=e.min-i.min,s=e.max-i.max;return e.max-e.min<i.max-i.min&&([t,s]=[s,t]),{min:t,max:s}}function x0e(i,e){return{x:b4(i.x,e.x),y:b4(i.y,e.y)}}function E0e(i,e){let t=.5;const s=Gs(i),r=Gs(e);return r>s?t=Cu(e.min,e.max-s,i.min):s>r&&(t=Cu(i.min,i.max-r,e.min)),Lr(0,1,t)}function V0e(i,e){const t={};return e.min!==void 0&&(t.min=e.min-i.min),e.max!==void 0&&(t.max=e.max-i.min),t}const l0=.35;function S0e(i=l0){return i===!1?i=0:i===!0&&(i=l0),{x:w4(i,"left","right"),y:w4(i,"top","bottom")}}function w4(i,e,t){return{min:x4(i,e),max:x4(i,t)}}function x4(i,e){return typeof i=="number"?i:i[e]||0}const T0e=new WeakMap;class P0e{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ys(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const n=c=>{t&&this.snapToCursor(Ru(c).point),this.stopAnimation()},a=(c,d)=>{const{drag:f,dragPropagation:y,onDragStart:v}=this.getProps();if(f&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Wme(f),!this.openDragLock))return;this.latestPointerEvent=c,this.latestPanInfo=d,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kr(g=>{let b=this.getAxisMotionValue(g).get()||0;if(_r.test(b)){const{projection:x}=this.visualElement;if(x&&x.layout){const P=x.layout.layoutBox[g];P&&(b=Gs(P)*(parseFloat(b)/100))}}this.originPoint[g]=b}),v&&Tt.update(()=>v(c,d),!1,!0),kv(this.visualElement,"transform");const{animationState:m}=this.visualElement;m&&m.setActive("whileDrag",!0)},o=(c,d)=>{this.latestPointerEvent=c,this.latestPanInfo=d;const{dragPropagation:f,dragDirectionLock:y,onDirectionLock:v,onDrag:m}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:g}=d;if(y&&this.currentDirection===null){this.currentDirection=R0e(g),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",d.point,g),this.updateAxis("y",d.point,g),this.visualElement.render(),m&&Tt.update(()=>m(c,d),!1,!0)},l=(c,d)=>{this.latestPointerEvent=c,this.latestPanInfo=d,this.stop(c,d),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:c}=this.getProps();(c||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new g4(e,{onSessionStart:n,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:s,contextWindow:p4(this.visualElement),element:this.visualElement.current})}stop(e,t){const s=e||this.latestPointerEvent,r=t||this.latestPanInfo,n=this.isDragging;if(this.cancel(),!n||!r||!s)return;const{velocity:a}=r;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&Tt.postRender(()=>o(s,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,s){const{drag:r}=this.getProps();if(!s||!Jd(e,r,this.currentDirection))return;const n=this.getAxisMotionValue(e);let a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=b0e(a,this.constraints[e],this.elastic[e])),n.set(a)}resolveConstraints(){var n;const{dragConstraints:e,dragElastic:t}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(n=this.visualElement.projection)==null?void 0:n.layout,r=this.constraints;e&&jo(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=w0e(s.layoutBox,e):this.constraints=!1,this.elastic=S0e(t),r!==this.constraints&&!jo(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&kr(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=V0e(s.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!jo(e))return!1;const s=e.current;an(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const n=xge(s,r.root,this.visualElement.getTransformPagePoint());let a=x0e(r.layout.layoutBox,n);if(t){const o=t(Cge(a));this.hasMutatedConstraints=!!o,o&&(a=Y3(o))}return a}startAnimation(e){const{drag:t,dragMomentum:s,dragElastic:r,dragTransition:n,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},u=kr(h=>{if(!Jd(h,t,this.currentDirection))return;let c=l&&l[h]||{};(a===!0||a===h)&&(c={min:0,max:0});const d=r?200:1e6,f=r?40:1e7,y={type:"inertia",velocity:s?e[h]:0,bounceStiffness:d,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...n,...c};return this.startAxisValueAnimation(h,y)});return Promise.all(u).then(o)}startAxisValueAnimation(e,t){const s=this.getAxisMotionValue(e);return kv(this.visualElement,e),s.start(Lv(e,s,0,t,this.visualElement,!1))}stopAnimation(){kr(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),r=s[t];return r||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){kr(t=>{const{drag:s}=this.getProps();if(!Jd(t,s,this.currentDirection))return;const{projection:r}=this.visualElement,n=this.getAxisMotionValue(t);if(r&&r.layout){const{min:a,max:o}=r.layout.layoutBox[t],l=n.get()||0;n.set(e[t]-qt(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:s}=this.visualElement;if(!jo(t)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};kr(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();r[a]=E0e({min:l,max:l},this.constraints[a])}});const{transformTemplate:n}=this.visualElement.getProps();this.visualElement.current.style.transform=n?n({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),kr(a=>{if(!Jd(a,e,null))return;const o=this.getAxisMotionValue(a),{min:l,max:u}=this.constraints[a];o.set(qt(l,u,r[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;T0e.set(this.visualElement,this);const e=this.visualElement.current,t=Au(e,"pointerdown",u=>{const{drag:h,dragListener:c=!0}=this.getProps(),d=u.target,f=d!==e&&Xme(d);h&&c&&!f&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();jo(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=I0e(e,u.current,()=>this.scalePositionWithinConstraints())))},{projection:n}=this.visualElement,a=n.addEventListener("measure",r);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),Tt.read(r);const o=Iu(window,"resize",()=>this.scalePositionWithinConstraints()),l=n.addEventListener("didUpdate",({delta:u,hasLayoutChanged:h})=>{this.isDragging&&h&&(kr(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=u[c].translate,d.set(d.get()+u[c].translate))}),this.visualElement.render())});return()=>{o(),t(),a(),l&&l(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:n=!1,dragElastic:a=l0,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:s,dragPropagation:r,dragConstraints:n,dragElastic:a,dragMomentum:o}}}function E4(i){let e=!0;return()=>{if(e){e=!1;return}i()}}function I0e(i,e,t){const s=U3(i,E4(t)),r=U3(e,E4(t));return()=>{s(),r()}}function Jd(i,e,t){return(e===!0||e===i)&&(t===null||t===i)}function R0e(i,e=10){let t=null;return Math.abs(i.y)>e?t="y":Math.abs(i.x)>e&&(t="x"),t}class A0e extends Zn{constructor(e){super(e),this.removeGroupControls=Hi,this.removeListeners=Hi,this.controls=new P0e(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Hi}update(){const{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const u0=i=>(e,t)=>{i&&Tt.update(()=>i(e,t),!1,!0)};class L0e extends Zn{constructor(){super(...arguments),this.removePointerDownListener=Hi}onPointerDown(e){this.session=new g4(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:p4(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:u0(e),onStart:u0(t),onMove:u0(s),onEnd:(n,a)=>{delete this.session,r&&Tt.postRender(()=>r(n,a))}}}mount(){this.removePointerDownListener=Au(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let h0=!1;class _0e extends S.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s,layoutId:r}=this.props,{projection:n}=e;n&&(t.group&&t.group.add(n),s&&s.register&&r&&s.register(n),h0&&n.root.didUpdate(),n.addEventListener("animationComplete",()=>{this.safeToRemove()}),n.setOptions({...n.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),jd.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:s,drag:r,isPresent:n}=this.props,{projection:a}=s;return a&&(a.isPresent=n,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),h0=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==n?a.willUpdate():this.safeToRemove(),e.isPresent!==n&&(n?a.promote():a.relegate()||Tt.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:t}=this.props,{projection:s}=e;s&&(s.options.layoutAnchor=t,s.root.didUpdate(),Bv.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s}=this.props,{projection:r}=e;h0=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function V4(i){const[e,t]=X7(),s=S.useContext(vu);return L.jsx(_0e,{...i,layoutGroup:s,switchLayoutGroup:S.useContext(c4),isPresent:e,safeToRemove:t})}const D0e={pan:{Feature:L0e},drag:{Feature:A0e,ProjectionNode:J7,MeasureLayout:V4}};function S4(i,e,t){const{props:s}=i;i.animationState&&s.whileHover&&i.animationState.setActive("whileHover",t==="Start");const r="onHover"+t,n=s[r];n&&Tt.postRender(()=>n(e,Ru(e)))}class k0e extends Zn{mount(){const{current:e}=this.node;e&&(this.unmount=Kme(e,(t,s)=>(S4(this.node,s,"Start"),r=>S4(this.node,r,"End"))))}unmount(){}}class O0e extends Zn{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=yu(Iu(this.node.current,"focus",()=>this.onFocus()),Iu(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function T4(i,e,t){const{props:s}=i;if(i.current instanceof HTMLButtonElement&&i.current.disabled)return;i.animationState&&s.whileTap&&i.animationState.setActive("whileTap",t==="Start");const r="onTap"+(t==="End"?"":t),n=s[r];n&&Tt.postRender(()=>n(e,Ru(e)))}class M0e extends Zn{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:s}=this.node.props;this.unmount=tge(e,(r,n)=>(T4(this.node,n,"Start"),(a,{success:o})=>T4(this.node,a,o?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:(s==null?void 0:s.tap)===!1})}unmount(){}}const c0=new WeakMap,d0=new WeakMap,N0e=i=>{const e=c0.get(i.target);e&&e(i)},F0e=i=>{i.forEach(N0e)};function q0e({root:i,...e}){const t=i||document;d0.has(t)||d0.set(t,{});const s=d0.get(t),r=JSON.stringify(e);return s[r]||(s[r]=new IntersectionObserver(F0e,{root:i,...e})),s[r]}function B0e(i,e,t){const s=q0e(e);return c0.set(i,t),s.observe(i),()=>{c0.delete(i),s.unobserve(i)}}const $0e={some:0,all:1};class H0e extends Zn{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var l;(l=this.stopObserver)==null||l.call(this);const{viewport:e={}}=this.node.getProps(),{root:t,margin:s,amount:r="some",once:n}=e,a={root:t?t.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:$0e[r]},o=u=>{const{isIntersecting:h}=u;if(this.isInView===h||(this.isInView=h,n&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=h?c:d;f&&f(u)};this.stopObserver=B0e(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(Q0e(e,t))&&this.startObserver()}unmount(){var e;(e=this.stopObserver)==null||e.call(this),this.hasEnteredView=!1,this.isInView=!1}}function Q0e({viewport:i={}},{viewport:e={}}={}){return t=>i[t]!==e[t]}const U0e={...m0e,...{inView:{Feature:H0e},tap:{Feature:M0e},focus:{Feature:O0e},hover:{Feature:k0e}},...D0e,...{layout:{ProjectionNode:J7,MeasureLayout:V4}}},z0e=h0e(U0e,c0e);ni("Tutorial","session"),Qs("Tutorial",(i,e,t,s)=>{var o;const r=((o=i.slides)==null?void 0:o.length)??0,n={};let a=0;for(let l=0;l<r;l++){const u=t.respondToSlide(l,i,s);s=u.participantState,n[l]=u.value??{},a+=u.duration??500}return{responseData:{slides:n},participantState:s,duration:a}},{respondToSlide:(i,e,t)=>({value:{},participantState:t,duration:500})});const P4=S.createContext({setCanProgress:()=>{},autoAdvance:()=>{},setSlideData:()=>{}}),j0e=({locked:i=!1}={})=>{const e=S.useContext(P4),t=S.useRef(!1);return!t.current&&i&&(t.current=!0,e.setCanProgress(!1)),{setData:e.setSlideData,unlock:({autoAdvanceMs:s}={})=>{e.setCanProgress(!0),s!==void 0&&e.autoAdvance(s)}}},I4="px-4 py-3 border-2 border-black font-bold text-lg rounded-xl shadow-[2px_2px_0px_rgba(0,0,0,1)] transition-all duration-100 outline-none focus:outline-none focus:ring-0",R4=I4+" bg-white text-black cursor-pointer hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none",W0e=I4+" bg-gray-200 text-gray-400 border-gray-400 shadow-[2px_2px_0px_rgba(156,163,175,1)] cursor-default",A4=({next:i,slides:e,fadeDuration:t=.3,finishText:s="Start",containerClass:r,nextKey:n="ArrowRight",backKey:a="ArrowLeft",theme:o="light"})=>{const[l,u]=S.useState(0),[h,c]=S.useState({}),d=S.useRef(),f=S.useRef({}),y=h[l]!==!1,v=S.useCallback(R=>{c(A=>({...A,[l]:R}))},[l]),m=S.useCallback(R=>{f.current[l]={...f.current[l],...R}},[l]),g=S.useCallback(()=>{l===e.length-1?i({slides:f.current}):u(R=>R+1)},[l,e.length,i]),b=S.useCallback(()=>{y&&g()},[y,g]),x=S.useCallback((R=0)=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>g(),R)},[g]);S.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const P=S.useCallback(()=>{l>0&&u(R=>R-1)},[l]);return S.useEffect(()=>{if(n===!1&&a===!1)return;const R=A=>{n&&A.key===n&&b(),a&&A.key===a&&P()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[n,a,b,P]),L.jsx(qve,{children:L.jsxs("div",{className:r,style:{width:"100vw",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[L.jsx("div",{style:{flex:1,position:"relative"},children:L.jsx(kve,{mode:"sync",children:L.jsx(z0e.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:t},style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:L.jsx(P4.Provider,{value:{setCanProgress:v,autoAdvance:x,setSlideData:m},children:e[l]})},l)})}),L.jsxs("div",{style:{padding:"1.5rem",display:"grid",gridTemplateColumns:"1fr auto 1fr",alignItems:"center"},children:[L.jsx("div",{style:{justifySelf:"end",marginRight:"1rem"},children:L.jsx("button",{onClick:P,className:R4,tabIndex:-1,style:{visibility:l>0?"visible":"hidden"},children:"←"})}),L.jsx("div",{style:{display:"flex",gap:6},children:e.map((R,A)=>L.jsx("div",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:A===l?o==="dark"?"#fff":"#000":o==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",transition:"background-color 0.2s"}},A))}),L.jsx("div",{style:{justifySelf:"start",marginLeft:"1rem"},children:L.jsx("button",{onClick:b,tabIndex:-1,className:(y?R4:W0e)+(l===e.length-1?" px-8":""),children:l===e.length-1?s:"→"})})]})]})})};ni("RandomDotKinematogram","rdk");const Or={validKeys:[],duration:1e3,responseEndsTrial:!0,dotCount:300,dotSetCount:1,direction:0,coherence:.5,opposite:0,speed:60,dotLifetime:-1,dotRadius:2,dotColor:"white",backgroundColor:"gray",apertureShape:"ellipse",apertureWidth:600,apertureHeight:400,reinsertMode:"opposite",noiseMovement:"randomDirection",fixationTime:500,showFixation:!1,fixationWidth:15,fixationHeight:15,fixationColor:"white",fixationThickness:2,showBorder:!1,borderWidth:1,borderColor:"black"};Qs("RandomDotKinematogram",(i,e,t,s)=>{const r={...Or,...i},n=t.respond(r,s),{rt:a,response:o}=n.value,l=r.fixationTime??Or.fixationTime,u=r.duration??Or.duration,c=(r.responseEndsTrial??Or.responseEndsTrial)&&a!=null?a:u,d=Array.isArray(r.correctResponse)?r.correctResponse.map(f=>f.toLowerCase()):r.correctResponse?[r.correctResponse.toLowerCase()]:null;return{responseData:{...r,rt:a,response:o,correct:o&&d?d.includes(o.toLowerCase()):null,framesDisplayed:0,measuredRefreshRate:null},participantState:n.participantState,duration:l+c}},{respond:(i,e)=>{const t=N2({driftRate:74e-5*(i.coherence??Or.coherence),boundaries:.0555,startingPoint:0,noiseLevel:.00316,sensoryDelay:{type:"uniform",min:150,max:250},motorDelay:{type:"uniform",min:130,max:210},timeLimit:i.duration??Or.duration,stimOffset:i.stimulusDuration??i.duration??Or.duration,postStimStrategy:{type:"continue"}}),s=F2(t.choice,i.validKeys,i.correctResponse);return{value:{rt:s?t.rt:null,response:s},participantState:e}}});const G0e=10,L4=.1,K0e=(i,e,t,s)=>{const r=Math.floor(i*e),n=Math.floor(i*t),a=[...Array(r).fill("coherent"),...Array(n).fill("opposite"),...Array(i-r-n).fill(s)];return fm(a)},Ma=(i,e)=>i+Math.random()*(e-i),Z0e=(i,e,t,s,r)=>{const n=e/2,a=i==="circle"||i==="square"?n:t/2,o=(l,u)=>{const h=n*2,c=a*2,d=s-n,f=r-a;return[((l-d)%h+h)%h+d,((u-f)%c+c)%c+f]};return i==="circle"||i==="ellipse"?{centerX:s,centerY:r,getRandomPosition(){const l=Ma(-Math.PI,Math.PI),u=Math.sqrt(Math.random());return[Math.cos(l)*u*n+s,Math.sin(l)*u*a+r]},isOutside(l,u,h){const c=n+h,d=a+h,f=(l-s)/c,y=(u-r)/d;return f*f+y*y>1},getOppositePosition(l,u,h){if(u!==void 0&&h!==void 0){const c=u*u+h*h;if(c>1e-10){const d=Math.sqrt(c),f=u/d,y=h/d,v=l.x-s,m=l.y-r,g=n*n,b=a*a,x=f*f/g+y*y/b,P=v*f/g+m*y/b,R=v*v/g+m*m/b-1,A=P*P-x*R;if(A>=0){const _=(P+Math.sqrt(A))/x;if(_>0&&Number.isFinite(_))return[l.x-f*_,l.y-y*_]}}}return this.getOppositePositionSimple(l)},getOppositePositionSimple(l){const u=2*s-l.x,h=2*r-l.y,c=(u-s)/n,d=(h-r)/a,f=Math.sqrt(c*c+d*d);return f>1?[s+c/f*n,r+d/f*a]:[u,h]},wrap:o,clip(l){l.beginPath(),l.ellipse(s,r,n,a,0,0,Math.PI*2),l.clip()},drawBorder(l,u,h){l.strokeStyle=u,l.lineWidth=h,l.beginPath(),l.ellipse(s,r,n+h/2,a+h/2,0,0,Math.PI*2),l.stroke()}}:{centerX:s,centerY:r,getRandomPosition(){return[Ma(s-n,s+n),Ma(r-a,r+a)]},isOutside(l,u,h){const c=n+h,d=a+h;return l<s-c||l>s+c||u<r-d||u>r+d},getOppositePosition(l,u,h){if(u===void 0||h===void 0)return this.getOppositePositionSimple(l);const c=Math.sqrt(u*u+h*h);if(c<1e-10)return this.getOppositePositionSimple(l);const d=-u/c,f=-h/c,y=s-n,v=s+n,m=r-a,g=r+a,b=d!==0?(y-l.x)/d:-1/0,x=d!==0?(v-l.x)/d:-1/0,P=f!==0?(m-l.y)/f:-1/0,R=f!==0?(g-l.y)/f:-1/0,A=Math.max(Math.min(b,x),Math.min(P,R)),_=Math.min(Math.max(b,x),Math.max(P,R));return _>0&&A<=_&&Number.isFinite(_)?[l.x+d*_,l.y+f*_]:this.getOppositePositionSimple(l)},getOppositePositionSimple(l){const u=s-n,h=s+n,c=r-a,d=r+a;let f=l.x,y=l.y;return l.x<u?f=h:l.x>h&&(f=u),l.y<c?y=d:l.y>d&&(y=c),[f,y]},wrap:o,clip(l){l.beginPath(),l.rect(s-n,r-a,n*2,a*2),l.clip()},drawBorder(l,u,h){l.strokeStyle=u,l.lineWidth=h,l.strokeRect(s-n-h/2,r-a-h/2,n*2+h,a*2+h)}}},J0e=(i,e,t)=>{const[s,r]=t.getRandomPosition(),n=i==="randomDirection"?Ma(-Math.PI,Math.PI):0;return{x:s,y:r,randomDirX:n?Math.cos(n):0,randomDirY:n?-Math.sin(n):0,lifeCount:Ma(0,e>0?e:0),assignedMovement:i}},Y0e=(i,e,t,s,r,n,a,o,l)=>{const u={...i};if(u.lifeCount+=t,s>0&&u.lifeCount>=s)return[u.x,u.y]=r.getRandomPosition(),u.lifeCount=0,u;let h=i.assignedMovement;if(l!==void 0&&(h=l,u.assignedMovement=h,h==="randomDirection")){const y=Ma(-Math.PI,Math.PI);u.randomDirX=Math.cos(y),u.randomDirY=-Math.sin(y)}let c=0,d=0;switch(h){case"coherent":c=o[0],d=o[1];break;case"opposite":c=-o[0],d=-o[1];break;case"randomTeleport":return[u.x,u.y]=r.getRandomPosition(),u;case"randomWalk":{const y=Ma(-Math.PI,Math.PI);c=Math.cos(y),d=-Math.sin(y);break}case"randomDirection":c=u.randomDirX,d=u.randomDirY;break}if(u.x+=c*e,u.y+=d*e,r.isOutside(u.x,u.y,a))if(n==="random")[u.x,u.y]=r.getRandomPosition();else if(n==="oppositeSimple")[u.x,u.y]=r.getOppositePositionSimple(u);else if(n==="opposite")[u.x,u.y]=r.getOppositePosition(u,c,d);else if(n==="wrap")[u.x,u.y]=r.wrap(u.x,u.y);else throw new Error(`Unknown reinsertType: ${n}`);return u},_4=S.forwardRef((i,e)=>{const{width:t,height:s,dotCount:r,dotSetCount:n,direction:a,coherence:o,opposite:l,speed:u,dotLifetime:h,updateRate:c,dotRadius:d,dotCharacter:f,dotColor:y,coherentDotColor:v,backgroundColor:m,apertureShape:g,apertureWidth:b,apertureHeight:x,apertureCenterX:P,apertureCenterY:R,reinsertMode:A,noiseMovement:_,reassignEveryMs:T,showFixation:k,fixationWidth:q,fixationHeight:B,fixationColor:U,fixationThickness:D,showBorder:H,borderWidth:Q,borderColor:$,active:W=!0,initialRefreshRate:K,style:oe,className:ee}={...Or,...i},ue=S.useRef(null),ae=S.useRef(),ce=S.useRef(),Ae=S.useRef(),ve=S.useRef(0),ie=S.useRef(0),xe=S.useRef([]),et=S.useRef(null),Xt=S.useRef(!1),jt=P??t/2,Os=R??s/2,Et=S.useMemo(()=>Z0e(g,b,x,jt,Os),[g,b,x,jt,Os]),fs=S.useMemo(()=>{const Oe=(90-a)*Math.PI/180;return[Math.cos(Oe),-Math.sin(Oe)]},[a]),is=S.useRef([]),_e=S.useRef(0);S.useEffect(()=>{const Oe=Math.floor(r*o),Ke=Math.floor(r*l);is.current=Array.from({length:n},()=>Array.from({length:r},(Pe,rs)=>{let Cs;return rs<Oe?Cs="coherent":rs<Oe+Ke?Cs="opposite":Cs=_,J0e(Cs,h,Et)}))},[]),S.useEffect(()=>{typeof K=="number"&&K>=20&&K<=300&&(et.current=1e3/K,Xt.current=!0)},[K]),S.useImperativeHandle(e,()=>({getStats:()=>({framesDisplayed:ie.current,measuredRefreshRate:et.current?Math.round(1e3/et.current):null})}));const tt=S.useCallback((Oe,Ke)=>{Ke.forEach(Pe=>{const rs=v&&Pe.assignedMovement==="coherent"?v:y;if(Oe.fillStyle=rs,f){const Cs=d*2.5;Oe.font=`${Cs}px monospace`,Oe.textAlign="center",Oe.textBaseline="middle",Oe.fillText(f,Pe.x,Pe.y)}else Oe.beginPath(),Oe.arc(Pe.x,Pe.y,d,0,Math.PI*2),Oe.fill()})},[y,v,d,f]),Bt=S.useCallback((Oe,Ke,Pe)=>{k&&(Oe.fillStyle=U,Oe.fillRect(Ke-q,Pe-D/2,q*2,D),Oe.fillRect(Ke-D/2,Pe-B,D,B*2))},[k,U,D,q,B]),Ht=S.useCallback(Oe=>{H&&Et.drawBorder(Oe,$,Q)},[H,$,Q,Et]),gt=S.useCallback(Oe=>{const Ke=ue.current,Pe=Ke==null?void 0:Ke.getContext("2d");if(!Ke||!Pe)return;ce.current===void 0&&(ce.current=Oe),Ae.current===void 0&&(Ae.current=Oe);const rs=Oe-Ae.current;if(Ae.current=Oe,ie.current++,rs>0&&rs<500){if(Xt.current)et.current=L4*rs+(1-L4)*et.current;else if(xe.current.push(rs),xe.current.length>=G0e){const Js=[...xe.current].sort((Ys,ji)=>Ys-ji),zi=Math.floor(Js.length/2);et.current=Js.length%2?Js[zi]:(Js[zi-1]+Js[zi])/2,Xt.current=!0}}const Cs=Oe-(ce.current??Oe),bs=Math.min(Cs,100),un=c&&c>0?1e3/c:0,Zs=!c||c<=0||bs>=un;if(Pe.clearRect(0,0,Ke.width,Ke.height),Pe.save(),Et.clip(Pe),Pe.fillStyle=m,Pe.fillRect(0,0,Ke.width,Ke.height),Pe.restore(),!W)Bt(Pe,Et.centerX,Et.centerY);else{if(Zs){const zi=u*bs/1e3;let Ys=!1;if(T!==void 0)if(T===0)Ys=!0;else{ve.current+=bs;const J=Xt.current&&et.current?et.current*.5:0;Ys=ve.current+J>=T,Ys&&(ve.current%=T)}const ji=Ys?K0e(r,o,l,_):null,ra=is.current[_e.current].map((J,re)=>Y0e(J,zi,bs,h,Et,A,d,fs,ji==null?void 0:ji[re]));is.current[_e.current]=ra,_e.current=(_e.current+1)%n,ce.current=Oe}const Js=is.current[_e.current];Pe.save(),Et.clip(Pe),tt(Pe,Js),Pe.restore(),Pe.save(),Pe.beginPath(),Bt(Pe,Et.centerX,Et.centerY),Ht(Pe),Pe.restore()}ae.current=requestAnimationFrame(gt)},[W,m,_,o,l,r,u,h,Et,A,n,d,fs,c,tt,Bt,Ht,T]);return S.useEffect(()=>(ae.current=requestAnimationFrame(gt),()=>{ae.current&&cancelAnimationFrame(ae.current)}),[gt]),S.useEffect(()=>{const Oe=ue.current;if(!Oe)return;const Ke=window.devicePixelRatio||1;Oe.width=t*Ke,Oe.height=s*Ke,Oe.style.width=`${t}px`,Oe.style.height=`${s}px`;const Pe=Oe.getContext("2d");Pe&&Pe.scale(Ke,Ke)},[t,s]),L.jsx("canvas",{ref:ue,style:{display:"block",...oe},className:ee})}),D4=i=>{const{store:e,stimulusDuration:t,updateRate:s,dotCharacter:r,coherentDotColor:n,apertureCenterX:a=window.innerWidth/2,apertureCenterY:o=window.innerHeight/2,reassignEveryMs:l,responseHint:u,validKeys:h,duration:c,responseEndsTrial:d,dotCount:f,dotSetCount:y,direction:v,coherence:m,opposite:g,speed:b,dotLifetime:x,dotRadius:P,dotColor:R,backgroundColor:A,apertureShape:_,apertureWidth:T,apertureHeight:k,reinsertMode:q,noiseMovement:B,showFixation:U,fixationTime:D,fixationWidth:H,fixationHeight:Q,fixationColor:$,fixationThickness:W,showBorder:K,borderWidth:oe,borderColor:ee}={...Or,...i},ue=S.useRef(i);ue.current=i;const ae=S.useRef(null),ce=S.useRef(performance.now()),Ae=S.useRef(!1),ve=S.useRef(null),ie=S.useRef(null),[xe,et]=S.useState(null),[Xt,jt]=S.useState(D<=0),[Os,Et]=S.useState(!0),fs=e==null?void 0:e._reactiveScreenRefreshRate,is=S.useCallback((_e,tt)=>{var Cs;if(Ae.current)return;Ae.current=!0;const{next:Bt,data:Ht,store:gt,updateStore:Oe,...Ke}=ue.current,Pe=(Cs=ae.current)==null?void 0:Cs.getStats(),rs=Array.isArray(Ke.correctResponse)?Ke.correctResponse.map(bs=>bs.toLowerCase()):Ke.correctResponse?[Ke.correctResponse.toLowerCase()]:null;Bt({...Or,...Ke,rt:tt,response:_e,correct:_e&&rs?rs.includes(_e):null,framesDisplayed:(Pe==null?void 0:Pe.framesDisplayed)??0,measuredRefreshRate:(Pe==null?void 0:Pe.measuredRefreshRate)??null})},[]);return S.useEffect(()=>{if(D<=0)return;const _e=setTimeout(()=>jt(!0),D);return()=>clearTimeout(_e)},[D]),S.useEffect(()=>{const _e=t??c;if(_e<=0)return;const tt=setTimeout(()=>Et(!1),D+_e);return()=>clearTimeout(tt)},[D,t,c]),S.useEffect(()=>{if(c<=0)return;const _e=setTimeout(()=>{is(ve.current,ie.current)},D+c);return()=>clearTimeout(_e)},[D,c,is]),S.useEffect(()=>{const _e=tt=>{if(Ae.current||ve.current)return;const Bt=tt.key.toLowerCase(),Ht=h.length>0?h.map(gt=>gt.toLowerCase()):null;if(!Ht||Ht.includes(Bt)){const gt=performance.now()-ce.current;ve.current=Bt,ie.current=gt,et(Bt),d&&is(Bt,gt)}};return window.addEventListener("keydown",_e),()=>window.removeEventListener("keydown",_e)},[h,d,is]),L.jsxs("div",{style:{width:"100vw",height:"100vh",overflow:"hidden",margin:0,padding:0,backgroundColor:A},children:[L.jsx(_4,{ref:ae,width:window.innerWidth,height:window.innerHeight,active:Xt&&Os,initialRefreshRate:fs,dotCount:f,dotSetCount:y,direction:v,coherence:m,opposite:g,speed:b,dotLifetime:x,updateRate:s,dotRadius:P,dotCharacter:r,dotColor:R,coherentDotColor:n,backgroundColor:A,apertureShape:_,apertureWidth:T,apertureHeight:k,apertureCenterX:a,apertureCenterY:o,reinsertMode:q,noiseMovement:B,reassignEveryMs:l,showFixation:U,fixationWidth:H,fixationHeight:Q,fixationColor:$,fixationThickness:W,showBorder:K,borderWidth:oe,borderColor:ee}),u&&!Os&&!xe&&L.jsx("div",{style:{position:"absolute",top:"60%",width:"100%",textAlign:"center",color:"white",fontSize:"1.25rem"},children:u})]})},X0e={Text:rc,ProlificEnding:H2,EnterFullscreen:iS,ExitFullscreen:rS,Quest:U5,Upload:YV,MicrophoneCheck:G2,PlainInput:$2,RequestFilePermission:yS,CanvasBlock:CS,CheckDevice:bS,StoreUI:Upe,Tutorial:A4,RandomDotKinematogram:D4},e1e={voicerecorder:bne};function p0(i){return typeof i=="object"&&i!==null&&typeof i.type=="string"}function t1e({timeline:i,config:e={showProgressBar:!1},components:t={},questions:s={},hybridParticipant:r}){const n=Bpe(),a=S.useMemo(()=>Xh(i),[i]),o=S.useRef((()=>{const B={},U=new URLSearchParams(window.location.search);for(const[$,W]of U.entries())B[$]=W;const D=Yh.getRegistry()||[],H={};for(const[$,W]of Object.entries(B))H[$]={value:W,registered:!1,defaultValue:void 0,type:void 0,description:void 0};for(const $ of D)H[$.name]={value:$.value!==void 0?$.value:B[$.name],registered:!0,defaultValue:$.defaultValue,type:$.type,description:$.description};return[{index:-1,trialNumber:-1,start:Ps(),end:Ps(),duration:0,type:"",name:"",responseData:{userAgent:navigator.userAgent,params:H}}]})()),[l,u]=S.useState(0),h=S.useRef(Ps()),c=S.useRef({}),[d,f]=S.useState(()=>In(a,0,()=>c.current,()=>o.current,B=>{c.current={...c.current,...B}})),y=!n&&ma("hybridSimulation",!1,"boolean")?"hybrid":"none",v=S.useRef(r||{}),m=S.useRef(-1),g={...X0e,...t},b={...e1e,...s},x=S.useMemo(()=>{const B=a.instructions.length;return B>0?d/B:0},[d,a.instructions]);S.useEffect(()=>{window.scrollTo(0,0)},[d]);function P(B){c.current={...c.current,...B}}function R(B,U,D){const H=Ps(),Q=a.instructions[d],$=U!==void 0?U:h.current,W=D!==void 0?D:H;if((Q==null?void 0:Q.type)==="ExecuteContent"){const oe=Q.content;if(p0(oe)){let ee={index:d,trialNumber:l+1,start:$,end:W,duration:W-$,type:oe.type,name:oe.name??"",...oe.csv!==void 0?{csv:oe.csv}:{},responseData:B};ee=ec(ee,oe,o.current,c.current),o.current=[...o.current,ee],u(ue=>ue+1)}else console.log("ExecuteContent finished, but content wasn't standard component format:",oe)}const K=In(a,d+1,()=>c.current,()=>o.current,oe=>P(oe));K<a.instructions.length&&(h.current=Ps()),f(K)}const A=S.useCallback(B=>{let U=0;const D=Ps(),H=2e4;let Q,$=D;const W=1e3,K=()=>{const ae=Ps()-D;return ae>0?Math.round(U*1e3/ae):null},oe=()=>{Q&&cancelAnimationFrame(Q)},ee=ue=>{U++;const ae=ue-D;ue-$>=W&&(B(K()),$=ue),ae<H?Q=requestAnimationFrame(ee):(oe(),B(K()))};return Q=requestAnimationFrame(ee),oe},[]),_=({children:B,collectRefreshRate:U})=>{const D=S.useRef(null),H=S.useRef(null);S.useEffect(()=>{if(D.current=Ps(),U)return A(W=>{H.current=W,P({_reactiveScreenRefreshRate:W})})},[]);const Q=S.Children.map(B,$=>{if(S.isValidElement($)){const W=(K,oe,ee)=>{const ue=Ps(),ae=oe!==void 0?oe:D.current;R(K,ae??void 0,(ee!==void 0?ee:ue)??void 0)};return S.cloneElement($,{...$.props,next:W})}return $});return L.jsx(L.Fragment,{children:Q})},T=a.instructions[d],k=S.useMemo(()=>{if(y==="none"||(T==null?void 0:T.type)!=="ExecuteContent")return!1;const B=T.content;return!p0(B)||B.simulate===!1?!1:!!B.simulate||!!B.simulators},[d,y,T]);S.useEffect(()=>{k&&m.current!==d&&(m.current=d,(async()=>{const B=T.content,{trialProps:U,simulateFn:D,simulators:H}=Cm(B,o.current,c.current),Q=await D(U,{data:o.current,store:c.current},H,v.current);v.current=Q.participantState,Q.storeUpdates&&P(Q.storeUpdates),R(Q.responseData)})())},[k,d]);let q=null;if((T==null?void 0:T.type)==="ExecuteContent"&&!k){const B=T.content;if(p0(B)){const U=g[B.type];if(U){const D=typeof B.props=="function"?B.props(o.current,c.current):B.props||{};q=L.jsx(_,{collectRefreshRate:B.collectRefreshRate,children:L.jsx(U,{next:R,updateStore:P,store:c.current,data:o.current,...B.type==="Quest"?{customQuestions:b}:{},...D})},d)}else console.error(`No component found for type: ${B.type}`),q=L.jsxs("div",{children:['Error: Component type "',B.type,'" not found.']})}else console.warn("ExecuteContent instruction does not contain standard component data:",B),q=L.jsx("div",{children:"Non-component content encountered."})}else d>=a.instructions.length&&(q=L.jsx(L.Fragment,{}));return L.jsxs("div",{className:"w-full h-full",children:[L.jsx("div",{className:` ${e.showProgressBar?"":"hidden "} px-4 mt-4 sm:mt-12 max-w-2xl mx-auto`,children:L.jsx("div",{className:"flex-1 h-6 bg-gray-200 rounded-full overflow-hidden",children:L.jsx("div",{className:`h-full bg-gray-200 rounded-full duration-300 ${x>0?" border-black border-2":""}`,style:{width:`${x*100}%`,backgroundImage:`repeating-linear-gradient(
10281
+ `),()=>{var _;(_=o.current)==null||_.removeAttribute("data-motion-pop-id"),A.contains(R)&&A.removeChild(R)}},[e]),L.jsx(Ave,{isPresent:e,childRef:o,sizeRef:l,pop:n,children:n===!1?i:p.cloneElement(i,{ref:c})})}const _ve=({children:i,initial:e,isPresent:t,onExitComplete:s,custom:r,presenceAffectsLayout:n,mode:a,anchorX:o,anchorY:l,root:u})=>{const h=Jg(Dve),c=S.useId();let d=!0,f=S.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:t,custom:r,onExitComplete:y=>{h.set(y,!0);for(const v of h.values())if(!v)return;s&&s()},register:y=>(h.set(y,!1),()=>h.delete(y))}),[t,h,s]);return n&&d&&(f={...f}),S.useMemo(()=>{h.forEach((y,v)=>h.set(v,!1))},[t]),p.useEffect(()=>{!t&&!h.size&&s&&s()},[t]),i=L.jsx(Lve,{pop:a==="popLayout",isPresent:t,anchorX:o,anchorY:l,root:u,children:i}),L.jsx(Sd.Provider,{value:f,children:i})};function Dve(){return new Map}function X7(i=!0){const e=S.useContext(Sd);if(e===null)return[!0,null];const{isPresent:t,onExitComplete:s,register:r}=e,n=S.useId();S.useEffect(()=>{if(i)return r(n)},[i]);const a=S.useCallback(()=>i&&s&&s(n),[n,s,i]);return!t&&s?[!1,a]:[!0]}const Wd=i=>i.key||"";function e4(i){const e=[];return S.Children.forEach(i,t=>{S.isValidElement(t)&&e.push(t)}),e}const kve=({children:i,custom:e,initial:t=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:n="sync",propagate:a=!1,anchorX:o="left",anchorY:l="top",root:u})=>{const[h,c]=X7(a),d=S.useMemo(()=>e4(i),[i]),f=a&&!h?[]:d.map(Wd),y=S.useRef(!0),v=S.useRef(d),m=Jg(()=>new Map),g=S.useRef(new Set),[b,x]=S.useState(d),[P,R]=S.useState(d);Yg(()=>{y.current=!1,v.current=d;for(let T=0;T<P.length;T++){const k=Wd(P[T]);f.includes(k)?(m.delete(k),g.current.delete(k)):m.get(k)!==!0&&m.set(k,!1)}},[P,f.length,f.join("-")]);const A=[];if(d!==b){let T=[...d];for(let k=0;k<P.length;k++){const q=P[k],B=Wd(q);f.includes(B)||(T.splice(k,0,q),A.push(q))}return n==="wait"&&A.length&&(T=A),R(e4(T)),x(d),null}process.env.NODE_ENV!=="production"&&n==="wait"&&P.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:_}=S.useContext(vu);return L.jsx(L.Fragment,{children:P.map(T=>{const k=Wd(T),q=a&&!h?!1:d===P||f.includes(k),B=()=>{if(g.current.has(k))return;if(m.has(k))g.current.add(k),m.set(k,!0);else return;let U=!0;m.forEach(D=>{D||(U=!1)}),U&&(_==null||_(),R(v.current),a&&(c==null||c()),s&&s())};return L.jsx(_ve,{isPresent:q,initial:!y.current||t?void 0:!1,custom:e,presenceAffectsLayout:r,mode:n,root:u,onExitComplete:q?void 0:B,anchorX:o,anchorY:l,children:T},k)})})},Ove=S.createContext(null);function Mve(){const i=S.useRef(!1);return Yg(()=>(i.current=!0,()=>{i.current=!1}),[]),i}function Nve(){const i=Mve(),[e,t]=S.useState(0),s=S.useCallback(()=>{i.current&&t(e+1)},[e]);return[S.useCallback(()=>Tt.postRender(s),[s]),e]}const t4=i=>i===!0,Fve=i=>t4(i===!0)||i==="id",qve=({children:i,id:e,inherit:t=!0})=>{const s=S.useContext(vu),r=S.useContext(Ove),[n,a]=Nve(),o=S.useRef(null),l=s.id||r;o.current===null&&(Fve(t)&&l&&(e=e?l+"-"+e:l),o.current={id:e,group:t4(t)&&s.group||Z7()});const u=S.useMemo(()=>({...o.current,forceRender:n}),[a]);return L.jsx(vu.Provider,{value:u,children:i})},s4=S.createContext({strict:!1}),i4={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let r4=!1;function Bve(){if(r4)return;const i={};for(const e in i4)i[e]={isEnabled:t=>i4[e].some(s=>!!t[s])};Z3(i),r4=!0}function n4(){return Bve(),vge()}function $ve(i){const e=n4();for(const t in i)e[t]={...e[t],...i[t]};Z3(e)}const Hve=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Gd(i){return i.startsWith("while")||i.startsWith("drag")&&i!=="draggable"||i.startsWith("layout")||i.startsWith("onTap")||i.startsWith("onPan")||i.startsWith("onLayout")||Hve.has(i)}let a4=i=>!Gd(i);function Qve(i){typeof i=="function"&&(a4=e=>e.startsWith("on")?!Gd(e):i(e))}try{Qve(require("@emotion/is-prop-valid").default)}catch{}function Uve(i,e,t){const s={};for(const r in i)r==="values"&&typeof i.values=="object"||ks(i[r])||(a4(r)||t===!0&&Gd(r)||!e&&!Gd(r)||i.draggable&&r.startsWith("onDrag"))&&(s[r]=i[r]);return s}const Kd=S.createContext({});function zve(i,e){if(Bd(i)){const{initial:t,animate:s}=i;return{initial:t===!1||Su(t)?t:void 0,animate:Su(s)?s:void 0}}return i.inherit!==!1?e:{}}function jve(i){const{initial:e,animate:t}=zve(i,S.useContext(Kd));return S.useMemo(()=>({initial:e,animate:t}),[o4(e),o4(t)])}function o4(i){return Array.isArray(i)?i.join(" "):i}const r0=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function l4(i,e,t){for(const s in e)!ks(e[s])&&!h7(s,t)&&(i[s]=e[s])}function Wve({transformTemplate:i},e){return S.useMemo(()=>{const t=r0();return Zv(t,e,i),Object.assign({},t.vars,t.style)},[e])}function Gve(i,e){const t=i.style||{},s={};return l4(s,t,i),Object.assign(s,Wve(i,e)),s}function Kve(i,e){const t={},s=Gve(i,e);return i.drag&&i.dragListener!==!1&&(t.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=i.drag===!0?"none":`pan-${i.drag==="x"?"y":"x"}`),i.tabIndex===void 0&&(i.onTap||i.onTapStart||i.whileTap)&&(t.tabIndex=0),t.style=s,t}const u4=()=>({...r0(),attrs:{}});function Zve(i,e,t,s){const r=S.useMemo(()=>{const n=u4();return c7(n,e,p7(s),i.transformTemplate,i.style),{...n.attrs,style:{...n.style}}},[e]);if(i.style){const n={};l4(n,i.style,i),r.style={...n,...r.style}}return r}const Jve=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function n0(i){return typeof i!="string"||i.includes("-")?!1:!!(Jve.indexOf(i)>-1||/[A-Z]/u.test(i))}function Yve(i,e,t,{latestValues:s},r,n=!1,a){const l=(a??n0(i)?Zve:Kve)(e,s,r,i),u=Uve(e,typeof i=="string",n),h=i!==S.Fragment?{...u,...l,ref:t}:{},{children:c}=e,d=S.useMemo(()=>ks(c)?c.get():c,[c]);return S.createElement(i,{...h,children:d})}function Xve({scrapeMotionValuesFromProps:i,createRenderState:e},t,s,r){return{latestValues:e0e(t,s,r,i),renderState:e()}}function e0e(i,e,t,s){const r={},n=s(i,{});for(const d in n)r[d]=zd(n[d]);let{initial:a,animate:o}=i;const l=Bd(i),u=W3(i);e&&u&&!l&&i.inherit!==!1&&(a===void 0&&(a=e.initial),o===void 0&&(o=e.animate));let h=t?t.initial===!1:!1;h=h||a===!1;const c=h?o:a;if(c&&typeof c!="boolean"&&!qd(c)){const d=Array.isArray(c)?c:[c];for(let f=0;f<d.length;f++){const y=_v(i,d[f]);if(y){const{transitionEnd:v,transition:m,...g}=y;for(const b in g){let x=g[b];if(Array.isArray(x)){const P=h?x.length-1:0;x=x[P]}x!==null&&(r[b]=x)}for(const b in v)r[b]=v[b]}}}return r}const h4=i=>(e,t)=>{const s=S.useContext(Kd),r=S.useContext(Sd),n=()=>Xve(i,e,s,r);return t?n():Jg(n)},t0e=h4({scrapeMotionValuesFromProps:Yv,createRenderState:r0}),s0e=h4({scrapeMotionValuesFromProps:f7,createRenderState:u4}),i0e=Symbol.for("motionComponentSymbol");function r0e(i,e,t){const s=S.useRef(t);S.useInsertionEffect(()=>{s.current=t});const r=S.useRef(null);return S.useCallback(n=>{var o;n&&((o=i.onMount)==null||o.call(i,n));const a=s.current;if(typeof a=="function")if(n){const l=a(n);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):a(n);else a&&(a.current=n);e&&(n?e.mount(n):e.unmount())},[e])}const c4=S.createContext({});function jo(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"current")}function n0e(i,e,t,s,r,n){var x,P;const{visualElement:a}=S.useContext(Kd),o=S.useContext(s4),l=S.useContext(Sd),u=S.useContext(i0),h=u.reducedMotion,c=u.skipAnimations,d=S.useRef(null),f=S.useRef(!1);s=s||o.renderer,!d.current&&s&&(d.current=s(i,{visualState:e,parent:a,props:t,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:h,skipAnimations:c,isSVG:n}),f.current&&d.current&&(d.current.manuallyAnimateOnMount=!0));const y=d.current,v=S.useContext(c4);y&&!y.projection&&r&&(y.type==="html"||y.type==="svg")&&a0e(d.current,t,r,v);const m=S.useRef(!1);S.useInsertionEffect(()=>{y&&m.current&&y.update(t,l)});const g=t[T3],b=S.useRef(!!g&&typeof window<"u"&&!((x=window.MotionHandoffIsComplete)!=null&&x.call(window,g))&&((P=window.MotionHasOptimisedAnimation)==null?void 0:P.call(window,g)));return Yg(()=>{f.current=!0,y&&(m.current=!0,window.MotionIsMounted=!0,y.updateFeatures(),y.scheduleRenderMicrotask(),b.current&&y.animationState&&y.animationState.animateChanges())}),S.useEffect(()=>{y&&(!b.current&&y.animationState&&y.animationState.animateChanges(),b.current&&(queueMicrotask(()=>{var R;(R=window.MotionHandoffMarkAsComplete)==null||R.call(window,g)}),b.current=!1),y.enteringChildren=void 0)}),y}function a0e(i,e,t,s){const{layoutId:r,layout:n,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:u,layoutAnchor:h,layoutCrossfade:c}=e;i.projection=new t(i.latestValues,e["data-framer-portal-id"]?void 0:d4(i.parent)),i.projection.setOptions({layoutId:r,layout:n,alwaysMeasureLayout:!!a||o&&jo(o),visualElement:i,animationType:typeof n=="string"?n:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u,layoutAnchor:h})}function d4(i){if(i)return i.options.allowProjection!==!1?i.projection:d4(i.parent)}function a0(i,{forwardMotionProps:e=!1,type:t}={},s,r){s&&$ve(s);const n=t?t==="svg":n0(i),a=n?s0e:t0e;function o(u,h){let c;const d={...S.useContext(i0),...u,layoutId:o0e(u)},{isStatic:f}=d,y=jve(u),v=a(u,f);if(!f&&typeof window<"u"){l0e(d,s);const m=u0e(d);c=m.MeasureLayout,y.visualElement=n0e(i,v,d,r,m.ProjectionNode,n)}return L.jsxs(Kd.Provider,{value:y,children:[c&&y.visualElement?L.jsx(c,{visualElement:y.visualElement,...d}):null,Yve(i,u,r0e(v,y.visualElement,h),v,f,e,n)]})}o.displayName=`motion.${typeof i=="string"?i:`create(${i.displayName??i.name??""})`}`;const l=S.forwardRef(o);return l[i0e]=i,l}function o0e({layoutId:i}){const e=S.useContext(vu).id;return e&&i!==void 0?e+"-"+i:i}function l0e(i,e){const t=S.useContext(s4).strict;if(process.env.NODE_ENV!=="production"&&e&&t){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";i.ignoreStrict?Mo(!1,s,"lazy-strict-mode"):an(!1,s,"lazy-strict-mode")}}function u0e(i){const e=n4(),{drag:t,layout:s}=e;if(!t&&!s)return{};const r={...t,...s};return{MeasureLayout:t!=null&&t.isEnabled(i)||s!=null&&s.isEnabled(i)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function h0e(i,e){if(typeof Proxy>"u")return a0;const t=new Map,s=(n,a)=>a0(n,a,i,e),r=(n,a)=>(process.env.NODE_ENV!=="production"&&sv(!1,"motion() is deprecated. Use motion.create() instead."),s(n,a));return new Proxy(r,{get:(n,a)=>a==="create"?s:(t.has(a)||t.set(a,a0(a,void 0,i,e)),t.get(a))})}const c0e=(i,e)=>e.isSVG??n0(i)?new kge(e):new Ige(e,{allowProjection:i!==S.Fragment});class d0e extends Zn{constructor(e){super(e),e.animationState||(e.animationState=qge(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();qd(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let p0e=0;class f0e extends Zn{constructor(){super(...arguments),this.id=p0e++,this.isExitComplete=!1}update(){var n;if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;if(e&&s===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"){const l=Da(this.node,a,o);if(l){const{transition:u,transitionEnd:h,...c}=l;for(const d in c)(n=this.node.getValue(d))==null||n.jump(c[d])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const m0e={animation:{Feature:d0e},exit:{Feature:f0e}};function Ru(i){return{point:{x:i.pageX,y:i.pageY}}}const g0e=i=>e=>$v(e)&&i(e,Ru(e));function Au(i,e,t,s){return Iu(i,e,g0e(t),s)}const p4=({current:i})=>i?i.ownerDocument.defaultView:null,f4=(i,e)=>Math.abs(i-e);function v0e(i,e){const t=f4(i.x,e.x),s=f4(i.y,e.y);return Math.sqrt(t**2+s**2)}const m4=new Set(["auto","scroll"]);class g4{constructor(e,t,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:n=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=f=>{this.handleScroll(f.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Zd(this.lastRawMoveEventInfo,this.transformPagePoint));const f=o0(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,v=v0e(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!y&&!v)return;const{point:m}=f,{timestamp:g}=Ds;this.history.push({...m,timestamp:g});const{onStart:b,onMove:x}=this.handlers;y||(b&&b(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,f)},this.handlePointerMove=(f,y)=>{this.lastMoveEvent=f,this.lastRawMoveEventInfo=y,this.lastMoveEventInfo=Zd(y,this.transformPagePoint),Tt.update(this.updatePoint,!0)},this.handlePointerUp=(f,y)=>{this.end();const{onEnd:v,onSessionEnd:m,resumeAnimation:g}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=o0(f.type==="pointercancel"?this.lastMoveEventInfo:Zd(y,this.transformPagePoint),this.history);this.startEvent&&v&&v(f,b),m&&m(f,b)},!$v(e))return;this.dragSnapToOrigin=n,this.handlers=t,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=r||window;const l=Ru(e),u=Zd(l,this.transformPagePoint),{point:h}=u,{timestamp:c}=Ds;this.history=[{...h,timestamp:c}];const{onSessionStart:d}=t;d&&d(e,o0(u,this.history)),this.removeListeners=yu(Au(this.contextWindow,"pointermove",this.handlePointerMove),Au(this.contextWindow,"pointerup",this.handlePointerUp),Au(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){const s=getComputedStyle(t);(m4.has(s.overflowX)||m4.has(s.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const t=this.scrollPositions.get(e);if(!t)return;const s=e===window,r=s?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},n={x:r.x-t.x,y:r.y-t.y};n.x===0&&n.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=n.x,this.lastMoveEventInfo.point.y+=n.y):this.history.length>0&&(this.history[0].x-=n.x,this.history[0].y-=n.y),this.scrollPositions.set(e,r),Tt.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),jn(this.updatePoint)}}function Zd(i,e){return e?{point:e(i.point)}:i}function v4(i,e){return{x:i.x-e.x,y:i.y-e.y}}function o0({point:i},e){return{point:i,delta:v4(i,y4(e)),offset:v4(i,y0e(e)),velocity:C0e(e,.1)}}function y0e(i){return i[0]}function y4(i){return i[i.length-1]}function C0e(i,e){if(i.length<2)return{x:0,y:0};let t=i.length-1,s=null;const r=y4(i);for(;t>=0&&(s=i[t],!(r.timestamp-s.timestamp>di(e)));)t--;if(!s)return{x:0,y:0};s===i[0]&&i.length>2&&r.timestamp-s.timestamp>di(e)*2&&(s=i[1]);const n=Qi(r.timestamp-s.timestamp);if(n===0)return{x:0,y:0};const a={x:(r.x-s.x)/n,y:(r.y-s.y)/n};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function b0e(i,{min:e,max:t},s){return e!==void 0&&i<e?i=s?qt(e,i,s.min):Math.max(i,e):t!==void 0&&i>t&&(i=s?qt(t,i,s.max):Math.min(i,t)),i}function C4(i,e,t){return{min:e!==void 0?i.min+e:void 0,max:t!==void 0?i.max+t-(i.max-i.min):void 0}}function w0e(i,{top:e,left:t,bottom:s,right:r}){return{x:C4(i.x,t,r),y:C4(i.y,e,s)}}function b4(i,e){let t=e.min-i.min,s=e.max-i.max;return e.max-e.min<i.max-i.min&&([t,s]=[s,t]),{min:t,max:s}}function x0e(i,e){return{x:b4(i.x,e.x),y:b4(i.y,e.y)}}function E0e(i,e){let t=.5;const s=Gs(i),r=Gs(e);return r>s?t=Cu(e.min,e.max-s,i.min):s>r&&(t=Cu(i.min,i.max-r,e.min)),Lr(0,1,t)}function V0e(i,e){const t={};return e.min!==void 0&&(t.min=e.min-i.min),e.max!==void 0&&(t.max=e.max-i.min),t}const l0=.35;function S0e(i=l0){return i===!1?i=0:i===!0&&(i=l0),{x:w4(i,"left","right"),y:w4(i,"top","bottom")}}function w4(i,e,t){return{min:x4(i,e),max:x4(i,t)}}function x4(i,e){return typeof i=="number"?i:i[e]||0}const T0e=new WeakMap;class P0e{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ys(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const n=c=>{t&&this.snapToCursor(Ru(c).point),this.stopAnimation()},a=(c,d)=>{const{drag:f,dragPropagation:y,onDragStart:v}=this.getProps();if(f&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Wme(f),!this.openDragLock))return;this.latestPointerEvent=c,this.latestPanInfo=d,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kr(g=>{let b=this.getAxisMotionValue(g).get()||0;if(_r.test(b)){const{projection:x}=this.visualElement;if(x&&x.layout){const P=x.layout.layoutBox[g];P&&(b=Gs(P)*(parseFloat(b)/100))}}this.originPoint[g]=b}),v&&Tt.update(()=>v(c,d),!1,!0),kv(this.visualElement,"transform");const{animationState:m}=this.visualElement;m&&m.setActive("whileDrag",!0)},o=(c,d)=>{this.latestPointerEvent=c,this.latestPanInfo=d;const{dragPropagation:f,dragDirectionLock:y,onDirectionLock:v,onDrag:m}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:g}=d;if(y&&this.currentDirection===null){this.currentDirection=R0e(g),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",d.point,g),this.updateAxis("y",d.point,g),this.visualElement.render(),m&&Tt.update(()=>m(c,d),!1,!0)},l=(c,d)=>{this.latestPointerEvent=c,this.latestPanInfo=d,this.stop(c,d),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:c}=this.getProps();(c||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new g4(e,{onSessionStart:n,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:s,contextWindow:p4(this.visualElement),element:this.visualElement.current})}stop(e,t){const s=e||this.latestPointerEvent,r=t||this.latestPanInfo,n=this.isDragging;if(this.cancel(),!n||!r||!s)return;const{velocity:a}=r;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&Tt.postRender(()=>o(s,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,s){const{drag:r}=this.getProps();if(!s||!Jd(e,r,this.currentDirection))return;const n=this.getAxisMotionValue(e);let a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=b0e(a,this.constraints[e],this.elastic[e])),n.set(a)}resolveConstraints(){var n;const{dragConstraints:e,dragElastic:t}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(n=this.visualElement.projection)==null?void 0:n.layout,r=this.constraints;e&&jo(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=w0e(s.layoutBox,e):this.constraints=!1,this.elastic=S0e(t),r!==this.constraints&&!jo(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&kr(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=V0e(s.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!jo(e))return!1;const s=e.current;an(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const n=xge(s,r.root,this.visualElement.getTransformPagePoint());let a=x0e(r.layout.layoutBox,n);if(t){const o=t(Cge(a));this.hasMutatedConstraints=!!o,o&&(a=Y3(o))}return a}startAnimation(e){const{drag:t,dragMomentum:s,dragElastic:r,dragTransition:n,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},u=kr(h=>{if(!Jd(h,t,this.currentDirection))return;let c=l&&l[h]||{};(a===!0||a===h)&&(c={min:0,max:0});const d=r?200:1e6,f=r?40:1e7,y={type:"inertia",velocity:s?e[h]:0,bounceStiffness:d,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...n,...c};return this.startAxisValueAnimation(h,y)});return Promise.all(u).then(o)}startAxisValueAnimation(e,t){const s=this.getAxisMotionValue(e);return kv(this.visualElement,e),s.start(Lv(e,s,0,t,this.visualElement,!1))}stopAnimation(){kr(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),r=s[t];return r||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){kr(t=>{const{drag:s}=this.getProps();if(!Jd(t,s,this.currentDirection))return;const{projection:r}=this.visualElement,n=this.getAxisMotionValue(t);if(r&&r.layout){const{min:a,max:o}=r.layout.layoutBox[t],l=n.get()||0;n.set(e[t]-qt(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:s}=this.visualElement;if(!jo(t)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};kr(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();r[a]=E0e({min:l,max:l},this.constraints[a])}});const{transformTemplate:n}=this.visualElement.getProps();this.visualElement.current.style.transform=n?n({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),kr(a=>{if(!Jd(a,e,null))return;const o=this.getAxisMotionValue(a),{min:l,max:u}=this.constraints[a];o.set(qt(l,u,r[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;T0e.set(this.visualElement,this);const e=this.visualElement.current,t=Au(e,"pointerdown",u=>{const{drag:h,dragListener:c=!0}=this.getProps(),d=u.target,f=d!==e&&Xme(d);h&&c&&!f&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();jo(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=I0e(e,u.current,()=>this.scalePositionWithinConstraints())))},{projection:n}=this.visualElement,a=n.addEventListener("measure",r);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),Tt.read(r);const o=Iu(window,"resize",()=>this.scalePositionWithinConstraints()),l=n.addEventListener("didUpdate",({delta:u,hasLayoutChanged:h})=>{this.isDragging&&h&&(kr(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=u[c].translate,d.set(d.get()+u[c].translate))}),this.visualElement.render())});return()=>{o(),t(),a(),l&&l(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:n=!1,dragElastic:a=l0,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:s,dragPropagation:r,dragConstraints:n,dragElastic:a,dragMomentum:o}}}function E4(i){let e=!0;return()=>{if(e){e=!1;return}i()}}function I0e(i,e,t){const s=U3(i,E4(t)),r=U3(e,E4(t));return()=>{s(),r()}}function Jd(i,e,t){return(e===!0||e===i)&&(t===null||t===i)}function R0e(i,e=10){let t=null;return Math.abs(i.y)>e?t="y":Math.abs(i.x)>e&&(t="x"),t}class A0e extends Zn{constructor(e){super(e),this.removeGroupControls=Hi,this.removeListeners=Hi,this.controls=new P0e(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Hi}update(){const{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const u0=i=>(e,t)=>{i&&Tt.update(()=>i(e,t),!1,!0)};class L0e extends Zn{constructor(){super(...arguments),this.removePointerDownListener=Hi}onPointerDown(e){this.session=new g4(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:p4(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:u0(e),onStart:u0(t),onMove:u0(s),onEnd:(n,a)=>{delete this.session,r&&Tt.postRender(()=>r(n,a))}}}mount(){this.removePointerDownListener=Au(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let h0=!1;class _0e extends S.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s,layoutId:r}=this.props,{projection:n}=e;n&&(t.group&&t.group.add(n),s&&s.register&&r&&s.register(n),h0&&n.root.didUpdate(),n.addEventListener("animationComplete",()=>{this.safeToRemove()}),n.setOptions({...n.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),jd.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:s,drag:r,isPresent:n}=this.props,{projection:a}=s;return a&&(a.isPresent=n,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),h0=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==n?a.willUpdate():this.safeToRemove(),e.isPresent!==n&&(n?a.promote():a.relegate()||Tt.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:t}=this.props,{projection:s}=e;s&&(s.options.layoutAnchor=t,s.root.didUpdate(),Bv.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s}=this.props,{projection:r}=e;h0=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function V4(i){const[e,t]=X7(),s=S.useContext(vu);return L.jsx(_0e,{...i,layoutGroup:s,switchLayoutGroup:S.useContext(c4),isPresent:e,safeToRemove:t})}const D0e={pan:{Feature:L0e},drag:{Feature:A0e,ProjectionNode:J7,MeasureLayout:V4}};function S4(i,e,t){const{props:s}=i;i.animationState&&s.whileHover&&i.animationState.setActive("whileHover",t==="Start");const r="onHover"+t,n=s[r];n&&Tt.postRender(()=>n(e,Ru(e)))}class k0e extends Zn{mount(){const{current:e}=this.node;e&&(this.unmount=Kme(e,(t,s)=>(S4(this.node,s,"Start"),r=>S4(this.node,r,"End"))))}unmount(){}}class O0e extends Zn{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=yu(Iu(this.node.current,"focus",()=>this.onFocus()),Iu(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function T4(i,e,t){const{props:s}=i;if(i.current instanceof HTMLButtonElement&&i.current.disabled)return;i.animationState&&s.whileTap&&i.animationState.setActive("whileTap",t==="Start");const r="onTap"+(t==="End"?"":t),n=s[r];n&&Tt.postRender(()=>n(e,Ru(e)))}class M0e extends Zn{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:s}=this.node.props;this.unmount=tge(e,(r,n)=>(T4(this.node,n,"Start"),(a,{success:o})=>T4(this.node,a,o?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:(s==null?void 0:s.tap)===!1})}unmount(){}}const c0=new WeakMap,d0=new WeakMap,N0e=i=>{const e=c0.get(i.target);e&&e(i)},F0e=i=>{i.forEach(N0e)};function q0e({root:i,...e}){const t=i||document;d0.has(t)||d0.set(t,{});const s=d0.get(t),r=JSON.stringify(e);return s[r]||(s[r]=new IntersectionObserver(F0e,{root:i,...e})),s[r]}function B0e(i,e,t){const s=q0e(e);return c0.set(i,t),s.observe(i),()=>{c0.delete(i),s.unobserve(i)}}const $0e={some:0,all:1};class H0e extends Zn{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var l;(l=this.stopObserver)==null||l.call(this);const{viewport:e={}}=this.node.getProps(),{root:t,margin:s,amount:r="some",once:n}=e,a={root:t?t.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:$0e[r]},o=u=>{const{isIntersecting:h}=u;if(this.isInView===h||(this.isInView=h,n&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=h?c:d;f&&f(u)};this.stopObserver=B0e(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(Q0e(e,t))&&this.startObserver()}unmount(){var e;(e=this.stopObserver)==null||e.call(this),this.hasEnteredView=!1,this.isInView=!1}}function Q0e({viewport:i={}},{viewport:e={}}={}){return t=>i[t]!==e[t]}const U0e={...m0e,...{inView:{Feature:H0e},tap:{Feature:M0e},focus:{Feature:O0e},hover:{Feature:k0e}},...D0e,...{layout:{ProjectionNode:J7,MeasureLayout:V4}}},z0e=h0e(U0e,c0e);ni("Tutorial",null),Qs("Tutorial",(i,e,t,s)=>{var o;const r=((o=i.slides)==null?void 0:o.length)??0,n={};let a=0;for(let l=0;l<r;l++){const u=t.respondToSlide(l,i,s);s=u.participantState,n[l]=u.value??{},a+=u.duration??500}return{responseData:{slides:n},participantState:s,duration:a}},{respondToSlide:(i,e,t)=>({value:{},participantState:t,duration:500})});const P4=S.createContext({setCanProgress:()=>{},autoAdvance:()=>{},setSlideData:()=>{}}),j0e=({locked:i=!1}={})=>{const e=S.useContext(P4),t=S.useRef(!1);return!t.current&&i&&(t.current=!0,e.setCanProgress(!1)),{setData:e.setSlideData,unlock:({autoAdvanceMs:s}={})=>{e.setCanProgress(!0),s!==void 0&&e.autoAdvance(s)}}},I4="px-4 py-3 border-2 border-black font-bold text-lg rounded-xl shadow-[2px_2px_0px_rgba(0,0,0,1)] transition-all duration-100 outline-none focus:outline-none focus:ring-0",R4=I4+" bg-white text-black cursor-pointer hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none",W0e=I4+" bg-gray-200 text-gray-400 border-gray-400 shadow-[2px_2px_0px_rgba(156,163,175,1)] cursor-default",A4=({next:i,slides:e,fadeDuration:t=.3,finishText:s="Start",containerClass:r,nextKey:n="ArrowRight",backKey:a="ArrowLeft",theme:o="light"})=>{const[l,u]=S.useState(0),[h,c]=S.useState({}),d=S.useRef(),f=S.useRef({}),y=h[l]!==!1,v=S.useCallback(R=>{c(A=>({...A,[l]:R}))},[l]),m=S.useCallback(R=>{f.current[l]={...f.current[l],...R}},[l]),g=S.useCallback(()=>{l===e.length-1?i({slides:f.current}):u(R=>R+1)},[l,e.length,i]),b=S.useCallback(()=>{y&&g()},[y,g]),x=S.useCallback((R=0)=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>g(),R)},[g]);S.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const P=S.useCallback(()=>{l>0&&u(R=>R-1)},[l]);return S.useEffect(()=>{if(n===!1&&a===!1)return;const R=A=>{n&&A.key===n&&b(),a&&A.key===a&&P()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[n,a,b,P]),L.jsx(qve,{children:L.jsxs("div",{className:r,style:{width:"100vw",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[L.jsx("div",{style:{flex:1,position:"relative"},children:L.jsx(kve,{mode:"sync",children:L.jsx(z0e.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:t},style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:L.jsx(P4.Provider,{value:{setCanProgress:v,autoAdvance:x,setSlideData:m},children:e[l]})},l)})}),L.jsxs("div",{style:{padding:"1.5rem",display:"grid",gridTemplateColumns:"1fr auto 1fr",alignItems:"center"},children:[L.jsx("div",{style:{justifySelf:"end",marginRight:"1rem"},children:L.jsx("button",{onClick:P,className:R4,tabIndex:-1,style:{visibility:l>0?"visible":"hidden"},children:"←"})}),L.jsx("div",{style:{display:"flex",gap:6},children:e.map((R,A)=>L.jsx("div",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:A===l?o==="dark"?"#fff":"#000":o==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",transition:"background-color 0.2s"}},A))}),L.jsx("div",{style:{justifySelf:"start",marginLeft:"1rem"},children:L.jsx("button",{onClick:b,tabIndex:-1,className:(y?R4:W0e)+(l===e.length-1?" px-8":""),children:l===e.length-1?s:"→"})})]})]})})};ni("RandomDotKinematogram","rdk");const Or={validKeys:[],duration:1e3,responseEndsTrial:!0,dotCount:300,dotSetCount:1,direction:0,coherence:.5,opposite:0,speed:60,dotLifetime:-1,dotRadius:2,dotColor:"white",backgroundColor:"gray",apertureShape:"ellipse",apertureWidth:600,apertureHeight:400,reinsertMode:"opposite",noiseMovement:"randomDirection",fixationTime:500,showFixation:!1,fixationWidth:15,fixationHeight:15,fixationColor:"white",fixationThickness:2,showBorder:!1,borderWidth:1,borderColor:"black"};Qs("RandomDotKinematogram",(i,e,t,s)=>{const r={...Or,...i},n=t.respond(r,s),{rt:a,response:o}=n.value,l=r.fixationTime??Or.fixationTime,u=r.duration??Or.duration,c=(r.responseEndsTrial??Or.responseEndsTrial)&&a!=null?a:u,d=Array.isArray(r.correctResponse)?r.correctResponse.map(f=>f.toLowerCase()):r.correctResponse?[r.correctResponse.toLowerCase()]:null;return{responseData:{...r,rt:a,response:o,correct:o&&d?d.includes(o.toLowerCase()):null,framesDisplayed:0,measuredRefreshRate:null},participantState:n.participantState,duration:l+c}},{respond:(i,e)=>{const t=N2({driftRate:74e-5*(i.coherence??Or.coherence),boundaries:.0555,startingPoint:0,noiseLevel:.00316,sensoryDelay:{type:"uniform",min:150,max:250},motorDelay:{type:"uniform",min:130,max:210},timeLimit:i.duration??Or.duration,stimOffset:i.stimulusDuration??i.duration??Or.duration,postStimStrategy:{type:"continue"}}),s=F2(t.choice,i.validKeys,i.correctResponse);return{value:{rt:s?t.rt:null,response:s},participantState:e}}});const G0e=10,L4=.1,K0e=(i,e,t,s)=>{const r=Math.floor(i*e),n=Math.floor(i*t),a=[...Array(r).fill("coherent"),...Array(n).fill("opposite"),...Array(i-r-n).fill(s)];return fm(a)},Ma=(i,e)=>i+Math.random()*(e-i),Z0e=(i,e,t,s,r)=>{const n=e/2,a=i==="circle"||i==="square"?n:t/2,o=(l,u)=>{const h=n*2,c=a*2,d=s-n,f=r-a;return[((l-d)%h+h)%h+d,((u-f)%c+c)%c+f]};return i==="circle"||i==="ellipse"?{centerX:s,centerY:r,getRandomPosition(){const l=Ma(-Math.PI,Math.PI),u=Math.sqrt(Math.random());return[Math.cos(l)*u*n+s,Math.sin(l)*u*a+r]},isOutside(l,u,h){const c=n+h,d=a+h,f=(l-s)/c,y=(u-r)/d;return f*f+y*y>1},getOppositePosition(l,u,h){if(u!==void 0&&h!==void 0){const c=u*u+h*h;if(c>1e-10){const d=Math.sqrt(c),f=u/d,y=h/d,v=l.x-s,m=l.y-r,g=n*n,b=a*a,x=f*f/g+y*y/b,P=v*f/g+m*y/b,R=v*v/g+m*m/b-1,A=P*P-x*R;if(A>=0){const _=(P+Math.sqrt(A))/x;if(_>0&&Number.isFinite(_))return[l.x-f*_,l.y-y*_]}}}return this.getOppositePositionSimple(l)},getOppositePositionSimple(l){const u=2*s-l.x,h=2*r-l.y,c=(u-s)/n,d=(h-r)/a,f=Math.sqrt(c*c+d*d);return f>1?[s+c/f*n,r+d/f*a]:[u,h]},wrap:o,clip(l){l.beginPath(),l.ellipse(s,r,n,a,0,0,Math.PI*2),l.clip()},drawBorder(l,u,h){l.strokeStyle=u,l.lineWidth=h,l.beginPath(),l.ellipse(s,r,n+h/2,a+h/2,0,0,Math.PI*2),l.stroke()}}:{centerX:s,centerY:r,getRandomPosition(){return[Ma(s-n,s+n),Ma(r-a,r+a)]},isOutside(l,u,h){const c=n+h,d=a+h;return l<s-c||l>s+c||u<r-d||u>r+d},getOppositePosition(l,u,h){if(u===void 0||h===void 0)return this.getOppositePositionSimple(l);const c=Math.sqrt(u*u+h*h);if(c<1e-10)return this.getOppositePositionSimple(l);const d=-u/c,f=-h/c,y=s-n,v=s+n,m=r-a,g=r+a,b=d!==0?(y-l.x)/d:-1/0,x=d!==0?(v-l.x)/d:-1/0,P=f!==0?(m-l.y)/f:-1/0,R=f!==0?(g-l.y)/f:-1/0,A=Math.max(Math.min(b,x),Math.min(P,R)),_=Math.min(Math.max(b,x),Math.max(P,R));return _>0&&A<=_&&Number.isFinite(_)?[l.x+d*_,l.y+f*_]:this.getOppositePositionSimple(l)},getOppositePositionSimple(l){const u=s-n,h=s+n,c=r-a,d=r+a;let f=l.x,y=l.y;return l.x<u?f=h:l.x>h&&(f=u),l.y<c?y=d:l.y>d&&(y=c),[f,y]},wrap:o,clip(l){l.beginPath(),l.rect(s-n,r-a,n*2,a*2),l.clip()},drawBorder(l,u,h){l.strokeStyle=u,l.lineWidth=h,l.strokeRect(s-n-h/2,r-a-h/2,n*2+h,a*2+h)}}},J0e=(i,e,t)=>{const[s,r]=t.getRandomPosition(),n=i==="randomDirection"?Ma(-Math.PI,Math.PI):0;return{x:s,y:r,randomDirX:n?Math.cos(n):0,randomDirY:n?-Math.sin(n):0,lifeCount:Ma(0,e>0?e:0),assignedMovement:i}},Y0e=(i,e,t,s,r,n,a,o,l)=>{const u={...i};if(u.lifeCount+=t,s>0&&u.lifeCount>=s)return[u.x,u.y]=r.getRandomPosition(),u.lifeCount=0,u;let h=i.assignedMovement;if(l!==void 0&&(h=l,u.assignedMovement=h,h==="randomDirection")){const y=Ma(-Math.PI,Math.PI);u.randomDirX=Math.cos(y),u.randomDirY=-Math.sin(y)}let c=0,d=0;switch(h){case"coherent":c=o[0],d=o[1];break;case"opposite":c=-o[0],d=-o[1];break;case"randomTeleport":return[u.x,u.y]=r.getRandomPosition(),u;case"randomWalk":{const y=Ma(-Math.PI,Math.PI);c=Math.cos(y),d=-Math.sin(y);break}case"randomDirection":c=u.randomDirX,d=u.randomDirY;break}if(u.x+=c*e,u.y+=d*e,r.isOutside(u.x,u.y,a))if(n==="random")[u.x,u.y]=r.getRandomPosition();else if(n==="oppositeSimple")[u.x,u.y]=r.getOppositePositionSimple(u);else if(n==="opposite")[u.x,u.y]=r.getOppositePosition(u,c,d);else if(n==="wrap")[u.x,u.y]=r.wrap(u.x,u.y);else throw new Error(`Unknown reinsertType: ${n}`);return u},_4=S.forwardRef((i,e)=>{const{width:t,height:s,dotCount:r,dotSetCount:n,direction:a,coherence:o,opposite:l,speed:u,dotLifetime:h,updateRate:c,dotRadius:d,dotCharacter:f,dotColor:y,coherentDotColor:v,backgroundColor:m,apertureShape:g,apertureWidth:b,apertureHeight:x,apertureCenterX:P,apertureCenterY:R,reinsertMode:A,noiseMovement:_,reassignEveryMs:T,showFixation:k,fixationWidth:q,fixationHeight:B,fixationColor:U,fixationThickness:D,showBorder:H,borderWidth:Q,borderColor:$,active:W=!0,initialRefreshRate:K,style:oe,className:ee}={...Or,...i},ue=S.useRef(null),ae=S.useRef(),ce=S.useRef(),Ae=S.useRef(),ve=S.useRef(0),ie=S.useRef(0),xe=S.useRef([]),et=S.useRef(null),Xt=S.useRef(!1),jt=P??t/2,Os=R??s/2,Et=S.useMemo(()=>Z0e(g,b,x,jt,Os),[g,b,x,jt,Os]),fs=S.useMemo(()=>{const Oe=(90-a)*Math.PI/180;return[Math.cos(Oe),-Math.sin(Oe)]},[a]),is=S.useRef([]),_e=S.useRef(0);S.useEffect(()=>{const Oe=Math.floor(r*o),Ke=Math.floor(r*l);is.current=Array.from({length:n},()=>Array.from({length:r},(Pe,rs)=>{let Cs;return rs<Oe?Cs="coherent":rs<Oe+Ke?Cs="opposite":Cs=_,J0e(Cs,h,Et)}))},[]),S.useEffect(()=>{typeof K=="number"&&K>=20&&K<=300&&(et.current=1e3/K,Xt.current=!0)},[K]),S.useImperativeHandle(e,()=>({getStats:()=>({framesDisplayed:ie.current,measuredRefreshRate:et.current?Math.round(1e3/et.current):null})}));const tt=S.useCallback((Oe,Ke)=>{Ke.forEach(Pe=>{const rs=v&&Pe.assignedMovement==="coherent"?v:y;if(Oe.fillStyle=rs,f){const Cs=d*2.5;Oe.font=`${Cs}px monospace`,Oe.textAlign="center",Oe.textBaseline="middle",Oe.fillText(f,Pe.x,Pe.y)}else Oe.beginPath(),Oe.arc(Pe.x,Pe.y,d,0,Math.PI*2),Oe.fill()})},[y,v,d,f]),Bt=S.useCallback((Oe,Ke,Pe)=>{k&&(Oe.fillStyle=U,Oe.fillRect(Ke-q,Pe-D/2,q*2,D),Oe.fillRect(Ke-D/2,Pe-B,D,B*2))},[k,U,D,q,B]),Ht=S.useCallback(Oe=>{H&&Et.drawBorder(Oe,$,Q)},[H,$,Q,Et]),gt=S.useCallback(Oe=>{const Ke=ue.current,Pe=Ke==null?void 0:Ke.getContext("2d");if(!Ke||!Pe)return;ce.current===void 0&&(ce.current=Oe),Ae.current===void 0&&(Ae.current=Oe);const rs=Oe-Ae.current;if(Ae.current=Oe,ie.current++,rs>0&&rs<500){if(Xt.current)et.current=L4*rs+(1-L4)*et.current;else if(xe.current.push(rs),xe.current.length>=G0e){const Js=[...xe.current].sort((Ys,ji)=>Ys-ji),zi=Math.floor(Js.length/2);et.current=Js.length%2?Js[zi]:(Js[zi-1]+Js[zi])/2,Xt.current=!0}}const Cs=Oe-(ce.current??Oe),bs=Math.min(Cs,100),un=c&&c>0?1e3/c:0,Zs=!c||c<=0||bs>=un;if(Pe.clearRect(0,0,Ke.width,Ke.height),Pe.save(),Et.clip(Pe),Pe.fillStyle=m,Pe.fillRect(0,0,Ke.width,Ke.height),Pe.restore(),!W)Bt(Pe,Et.centerX,Et.centerY);else{if(Zs){const zi=u*bs/1e3;let Ys=!1;if(T!==void 0)if(T===0)Ys=!0;else{ve.current+=bs;const J=Xt.current&&et.current?et.current*.5:0;Ys=ve.current+J>=T,Ys&&(ve.current%=T)}const ji=Ys?K0e(r,o,l,_):null,ra=is.current[_e.current].map((J,re)=>Y0e(J,zi,bs,h,Et,A,d,fs,ji==null?void 0:ji[re]));is.current[_e.current]=ra,_e.current=(_e.current+1)%n,ce.current=Oe}const Js=is.current[_e.current];Pe.save(),Et.clip(Pe),tt(Pe,Js),Pe.restore(),Pe.save(),Pe.beginPath(),Bt(Pe,Et.centerX,Et.centerY),Ht(Pe),Pe.restore()}ae.current=requestAnimationFrame(gt)},[W,m,_,o,l,r,u,h,Et,A,n,d,fs,c,tt,Bt,Ht,T]);return S.useEffect(()=>(ae.current=requestAnimationFrame(gt),()=>{ae.current&&cancelAnimationFrame(ae.current)}),[gt]),S.useEffect(()=>{const Oe=ue.current;if(!Oe)return;const Ke=window.devicePixelRatio||1;Oe.width=t*Ke,Oe.height=s*Ke,Oe.style.width=`${t}px`,Oe.style.height=`${s}px`;const Pe=Oe.getContext("2d");Pe&&Pe.scale(Ke,Ke)},[t,s]),L.jsx("canvas",{ref:ue,style:{display:"block",...oe},className:ee})}),D4=i=>{const{store:e,stimulusDuration:t,updateRate:s,dotCharacter:r,coherentDotColor:n,apertureCenterX:a=window.innerWidth/2,apertureCenterY:o=window.innerHeight/2,reassignEveryMs:l,responseHint:u,validKeys:h,duration:c,responseEndsTrial:d,dotCount:f,dotSetCount:y,direction:v,coherence:m,opposite:g,speed:b,dotLifetime:x,dotRadius:P,dotColor:R,backgroundColor:A,apertureShape:_,apertureWidth:T,apertureHeight:k,reinsertMode:q,noiseMovement:B,showFixation:U,fixationTime:D,fixationWidth:H,fixationHeight:Q,fixationColor:$,fixationThickness:W,showBorder:K,borderWidth:oe,borderColor:ee}={...Or,...i},ue=S.useRef(i);ue.current=i;const ae=S.useRef(null),ce=S.useRef(performance.now()),Ae=S.useRef(!1),ve=S.useRef(null),ie=S.useRef(null),[xe,et]=S.useState(null),[Xt,jt]=S.useState(D<=0),[Os,Et]=S.useState(!0),fs=e==null?void 0:e._reactiveScreenRefreshRate,is=S.useCallback((_e,tt)=>{var Cs;if(Ae.current)return;Ae.current=!0;const{next:Bt,data:Ht,store:gt,updateStore:Oe,...Ke}=ue.current,Pe=(Cs=ae.current)==null?void 0:Cs.getStats(),rs=Array.isArray(Ke.correctResponse)?Ke.correctResponse.map(bs=>bs.toLowerCase()):Ke.correctResponse?[Ke.correctResponse.toLowerCase()]:null;Bt({...Or,...Ke,rt:tt,response:_e,correct:_e&&rs?rs.includes(_e):null,framesDisplayed:(Pe==null?void 0:Pe.framesDisplayed)??0,measuredRefreshRate:(Pe==null?void 0:Pe.measuredRefreshRate)??null})},[]);return S.useEffect(()=>{if(D<=0)return;const _e=setTimeout(()=>jt(!0),D);return()=>clearTimeout(_e)},[D]),S.useEffect(()=>{const _e=t??c;if(_e<=0)return;const tt=setTimeout(()=>Et(!1),D+_e);return()=>clearTimeout(tt)},[D,t,c]),S.useEffect(()=>{if(c<=0)return;const _e=setTimeout(()=>{is(ve.current,ie.current)},D+c);return()=>clearTimeout(_e)},[D,c,is]),S.useEffect(()=>{const _e=tt=>{if(Ae.current||ve.current)return;const Bt=tt.key.toLowerCase(),Ht=h.length>0?h.map(gt=>gt.toLowerCase()):null;if(!Ht||Ht.includes(Bt)){const gt=performance.now()-ce.current;ve.current=Bt,ie.current=gt,et(Bt),d&&is(Bt,gt)}};return window.addEventListener("keydown",_e),()=>window.removeEventListener("keydown",_e)},[h,d,is]),L.jsxs("div",{style:{width:"100vw",height:"100vh",overflow:"hidden",margin:0,padding:0,backgroundColor:A},children:[L.jsx(_4,{ref:ae,width:window.innerWidth,height:window.innerHeight,active:Xt&&Os,initialRefreshRate:fs,dotCount:f,dotSetCount:y,direction:v,coherence:m,opposite:g,speed:b,dotLifetime:x,updateRate:s,dotRadius:P,dotCharacter:r,dotColor:R,coherentDotColor:n,backgroundColor:A,apertureShape:_,apertureWidth:T,apertureHeight:k,apertureCenterX:a,apertureCenterY:o,reinsertMode:q,noiseMovement:B,reassignEveryMs:l,showFixation:U,fixationWidth:H,fixationHeight:Q,fixationColor:$,fixationThickness:W,showBorder:K,borderWidth:oe,borderColor:ee}),u&&!Os&&!xe&&L.jsx("div",{style:{position:"absolute",top:"60%",width:"100%",textAlign:"center",color:"white",fontSize:"1.25rem"},children:u})]})},X0e={Text:rc,ProlificEnding:H2,EnterFullscreen:iS,ExitFullscreen:rS,Quest:U5,Upload:YV,MicrophoneCheck:G2,PlainInput:$2,RequestFilePermission:yS,CanvasBlock:CS,CheckDevice:bS,StoreUI:Upe,Tutorial:A4,RandomDotKinematogram:D4},e1e={voicerecorder:bne};function p0(i){return typeof i=="object"&&i!==null&&typeof i.type=="string"}function t1e({timeline:i,config:e={showProgressBar:!1},components:t={},questions:s={},hybridParticipant:r}){const n=Bpe(),a=S.useMemo(()=>Xh(i),[i]),o=S.useRef((()=>{const B={},U=new URLSearchParams(window.location.search);for(const[$,W]of U.entries())B[$]=W;const D=Yh.getRegistry()||[],H={};for(const[$,W]of Object.entries(B))H[$]={value:W,registered:!1,defaultValue:void 0,type:void 0,description:void 0};for(const $ of D)H[$.name]={value:$.value!==void 0?$.value:B[$.name],registered:!0,defaultValue:$.defaultValue,type:$.type,description:$.description};return[{index:-1,trialNumber:-1,start:Ps(),end:Ps(),duration:0,type:"",name:"",responseData:{userAgent:navigator.userAgent,params:H}}]})()),[l,u]=S.useState(0),h=S.useRef(Ps()),c=S.useRef({}),[d,f]=S.useState(()=>In(a,0,()=>c.current,()=>o.current,B=>{c.current={...c.current,...B}})),y=!n&&ma("hybridSimulation",!1,"boolean")?"hybrid":"none",v=S.useRef(r||{}),m=S.useRef(-1),g={...X0e,...t},b={...e1e,...s},x=S.useMemo(()=>{const B=a.instructions.length;return B>0?d/B:0},[d,a.instructions]);S.useEffect(()=>{window.scrollTo(0,0)},[d]);function P(B){c.current={...c.current,...B}}function R(B,U,D){const H=Ps(),Q=a.instructions[d],$=U!==void 0?U:h.current,W=D!==void 0?D:H;if((Q==null?void 0:Q.type)==="ExecuteContent"){const oe=Q.content;if(p0(oe)){let ee={index:d,trialNumber:l+1,start:$,end:W,duration:W-$,type:oe.type,name:oe.name??"",...oe.csv!==void 0?{csv:oe.csv}:{},responseData:B};ee=ec(ee,oe,o.current,c.current),o.current=[...o.current,ee],u(ue=>ue+1)}else console.log("ExecuteContent finished, but content wasn't standard component format:",oe)}const K=In(a,d+1,()=>c.current,()=>o.current,oe=>P(oe));K<a.instructions.length&&(h.current=Ps()),f(K)}const A=S.useCallback(B=>{let U=0;const D=Ps(),H=2e4;let Q,$=D;const W=1e3,K=()=>{const ae=Ps()-D;return ae>0?Math.round(U*1e3/ae):null},oe=()=>{Q&&cancelAnimationFrame(Q)},ee=ue=>{U++;const ae=ue-D;ue-$>=W&&(B(K()),$=ue),ae<H?Q=requestAnimationFrame(ee):(oe(),B(K()))};return Q=requestAnimationFrame(ee),oe},[]),_=({children:B,collectRefreshRate:U})=>{const D=S.useRef(null),H=S.useRef(null);S.useEffect(()=>{if(D.current=Ps(),U)return A(W=>{H.current=W,P({_reactiveScreenRefreshRate:W})})},[]);const Q=S.Children.map(B,$=>{if(S.isValidElement($)){const W=(K,oe,ee)=>{const ue=Ps(),ae=oe!==void 0?oe:D.current;R(K,ae??void 0,(ee!==void 0?ee:ue)??void 0)};return S.cloneElement($,{...$.props,next:W})}return $});return L.jsx(L.Fragment,{children:Q})},T=a.instructions[d],k=S.useMemo(()=>{if(y==="none"||(T==null?void 0:T.type)!=="ExecuteContent")return!1;const B=T.content;return!p0(B)||B.simulate===!1?!1:!!B.simulate||!!B.simulators},[d,y,T]);S.useEffect(()=>{k&&m.current!==d&&(m.current=d,(async()=>{const B=T.content,{trialProps:U,simulateFn:D,simulators:H}=Cm(B,o.current,c.current),Q=await D(U,{data:o.current,store:c.current},H,v.current);v.current=Q.participantState,Q.storeUpdates&&P(Q.storeUpdates),R(Q.responseData)})())},[k,d]);let q=null;if((T==null?void 0:T.type)==="ExecuteContent"&&!k){const B=T.content;if(p0(B)){const U=g[B.type];if(U){const D=typeof B.props=="function"?B.props(o.current,c.current):B.props||{};q=L.jsx(_,{collectRefreshRate:B.collectRefreshRate,children:L.jsx(U,{next:R,updateStore:P,store:c.current,data:o.current,...B.type==="Quest"?{customQuestions:b}:{},...D})},d)}else console.error(`No component found for type: ${B.type}`),q=L.jsxs("div",{children:['Error: Component type "',B.type,'" not found.']})}else console.warn("ExecuteContent instruction does not contain standard component data:",B),q=L.jsx("div",{children:"Non-component content encountered."})}else d>=a.instructions.length&&(q=L.jsx(L.Fragment,{}));return L.jsxs("div",{className:"w-full h-full",children:[L.jsx("div",{className:` ${e.showProgressBar?"":"hidden "} px-4 mt-4 sm:mt-12 max-w-2xl mx-auto`,children:L.jsx("div",{className:"flex-1 h-6 bg-gray-200 rounded-full overflow-hidden",children:L.jsx("div",{className:`h-full bg-gray-200 rounded-full duration-300 ${x>0?" border-black border-2":""}`,style:{width:`${x*100}%`,backgroundImage:`repeating-linear-gradient(
10282
10282
  -45deg, #E5E7EB, #E5E7EB 10px, #D1D5DB 10px, #D1D5DB 20px
10283
10283
  )`,transition:"width 300ms ease-in-out"}})})}),q]})}function k4(i){const e=i.split("/").filter(s=>s!=="."),t=[];return e.forEach(s=>{s===".."&&t.length>0&&t[t.length-1]!==".."?t.pop():t.push(s)}),t.join("/")}function s1e(i,e){i=k4(i),e=k4(e);const t=i.split("/"),s=e.split("/");return i!==e&&t.every((r,n)=>r===s[n])}class Yd extends Zh{constructor(){super(...arguments),this.DB_VERSION=1,this.DB_NAME="Disc",this._writeCmds=["add","put","delete"],this.downloadFile=async e=>{var t,s;const r=V2(e,e.webFetchExtra),n=await fetch(e.url,r);let a;if(!e.progress)a=await n.blob();else if(!(n!=null&&n.body))a=new Blob;else{const l=n.body.getReader();let u=0;const h=[],c=n.headers.get("content-type"),d=parseInt(n.headers.get("content-length")||"0",10);for(;;){const{done:v,value:m}=await l.read();if(v)break;h.push(m),u+=(m==null?void 0:m.length)||0;const g={url:e.url,bytes:u,contentLength:d};this.notifyListeners("progress",g)}const f=new Uint8Array(u);let y=0;for(const v of h)typeof v>"u"||(f.set(v,y),y+=v.length);a=new Blob([f.buffer],{type:c||void 0})}return{path:(await this.writeFile({path:e.path,directory:(t=e.directory)!==null&&t!==void 0?t:void 0,recursive:(s=e.recursive)!==null&&s!==void 0?s:!1,data:a})).uri,blob:a}}}async initDb(){if(this._db!==void 0)return this._db;if(!("indexedDB"in window))throw this.unavailable("This browser doesn't support IndexedDB");return new Promise((e,t)=>{const s=indexedDB.open(this.DB_NAME,this.DB_VERSION);s.onupgradeneeded=Yd.doUpgrade,s.onsuccess=()=>{this._db=s.result,e(s.result)},s.onerror=()=>t(s.error),s.onblocked=()=>{console.warn("db blocked")}})}static doUpgrade(e){const s=e.target.result;switch(e.oldVersion){case 0:case 1:default:s.objectStoreNames.contains("FileStorage")&&s.deleteObjectStore("FileStorage"),s.createObjectStore("FileStorage",{keyPath:"path"}).createIndex("by_folder","folder")}}async dbRequest(e,t){const s=this._writeCmds.indexOf(e)!==-1?"readwrite":"readonly";return this.initDb().then(r=>new Promise((n,a)=>{const u=r.transaction(["FileStorage"],s).objectStore("FileStorage")[e](...t);u.onsuccess=()=>n(u.result),u.onerror=()=>a(u.error)}))}async dbIndexRequest(e,t,s){const r=this._writeCmds.indexOf(t)!==-1?"readwrite":"readonly";return this.initDb().then(n=>new Promise((a,o)=>{const c=n.transaction(["FileStorage"],r).objectStore("FileStorage").index(e)[t](...s);c.onsuccess=()=>a(c.result),c.onerror=()=>o(c.error)}))}getPath(e,t){const s=t!==void 0?t.replace(/^[/]+|[/]+$/g,""):"";let r="";return e!==void 0&&(r+="/"+e),t!==""&&(r+="/"+s),r}async clear(){(await this.initDb()).transaction(["FileStorage"],"readwrite").objectStore("FileStorage").clear()}async readFile(e){const t=this.getPath(e.directory,e.path),s=await this.dbRequest("get",[t]);if(s===void 0)throw Error("File does not exist.");return{data:s.content?s.content:""}}async writeFile(e){const t=this.getPath(e.directory,e.path);let s=e.data;const r=e.encoding,n=e.recursive,a=await this.dbRequest("get",[t]);if(a&&a.type==="directory")throw Error("The supplied path is a directory.");const o=t.substr(0,t.lastIndexOf("/"));if(await this.dbRequest("get",[o])===void 0){const c=o.indexOf("/",1);if(c!==-1){const d=o.substr(c);await this.mkdir({path:d,directory:e.directory,recursive:n})}}if(!r&&!(s instanceof Blob)&&(s=s.indexOf(",")>=0?s.split(",")[1]:s,!this.isBase64String(s)))throw Error("The supplied data is not valid base64 content.");const u=Date.now(),h={path:t,folder:o,type:"file",size:s instanceof Blob?s.size:s.length,ctime:u,mtime:u,content:s};return await this.dbRequest("put",[h]),{uri:h.path}}async appendFile(e){const t=this.getPath(e.directory,e.path);let s=e.data;const r=e.encoding,n=t.substr(0,t.lastIndexOf("/")),a=Date.now();let o=a;const l=await this.dbRequest("get",[t]);if(l&&l.type==="directory")throw Error("The supplied path is a directory.");if(await this.dbRequest("get",[n])===void 0){const c=n.indexOf("/",1);if(c!==-1){const d=n.substr(c);await this.mkdir({path:d,directory:e.directory,recursive:!0})}}if(!r&&!this.isBase64String(s))throw Error("The supplied data is not valid base64 content.");if(l!==void 0){if(l.content instanceof Blob)throw Error("The occupied entry contains a Blob object which cannot be appended to.");l.content!==void 0&&!r?s=btoa(atob(l.content)+atob(s)):s=l.content+s,o=l.ctime}const h={path:t,folder:n,type:"file",size:s.length,ctime:o,mtime:a,content:s};await this.dbRequest("put",[h])}async deleteFile(e){const t=this.getPath(e.directory,e.path);if(await this.dbRequest("get",[t])===void 0)throw Error("File does not exist.");if((await this.dbIndexRequest("by_folder","getAllKeys",[IDBKeyRange.only(t)])).length!==0)throw Error("Folder is not empty.");await this.dbRequest("delete",[t])}async mkdir(e){const t=this.getPath(e.directory,e.path),s=e.recursive,r=t.substr(0,t.lastIndexOf("/")),n=(t.match(/\//g)||[]).length,a=await this.dbRequest("get",[r]),o=await this.dbRequest("get",[t]);if(n===1)throw Error("Cannot create Root directory");if(o!==void 0)throw Error("Current directory does already exist.");if(!s&&n!==2&&a===void 0)throw Error("Parent directory must exist");if(s&&n!==2&&a===void 0){const h=r.substr(r.indexOf("/",1));await this.mkdir({path:h,directory:e.directory,recursive:s})}const l=Date.now(),u={path:t,folder:r,type:"directory",size:0,ctime:l,mtime:l};await this.dbRequest("put",[u])}async rmdir(e){const{path:t,directory:s,recursive:r}=e,n=this.getPath(s,t),a=await this.dbRequest("get",[n]);if(a===void 0)throw Error("Folder does not exist.");if(a.type!=="directory")throw Error("Requested path is not a directory");const o=await this.readdir({path:t,directory:s});if(o.files.length!==0&&!r)throw Error("Folder is not empty");for(const l of o.files){const u=`${t}/${l.name}`;(await this.stat({path:u,directory:s})).type==="file"?await this.deleteFile({path:u,directory:s}):await this.rmdir({path:u,directory:s,recursive:r})}await this.dbRequest("delete",[n])}async readdir(e){const t=this.getPath(e.directory,e.path),s=await this.dbRequest("get",[t]);if(e.path!==""&&s===void 0)throw Error("Folder does not exist.");const r=await this.dbIndexRequest("by_folder","getAllKeys",[IDBKeyRange.only(t)]);return{files:await Promise.all(r.map(async a=>{let o=await this.dbRequest("get",[a]);return o===void 0&&(o=await this.dbRequest("get",[a+"/"])),{name:a.substring(t.length+1),type:o.type,size:o.size,ctime:o.ctime,mtime:o.mtime,uri:o.path}}))}}async getUri(e){const t=this.getPath(e.directory,e.path);let s=await this.dbRequest("get",[t]);return s===void 0&&(s=await this.dbRequest("get",[t+"/"])),{uri:(s==null?void 0:s.path)||t}}async stat(e){const t=this.getPath(e.directory,e.path);let s=await this.dbRequest("get",[t]);if(s===void 0&&(s=await this.dbRequest("get",[t+"/"])),s===void 0)throw Error("Entry does not exist.");return{type:s.type,size:s.size,ctime:s.ctime,mtime:s.mtime,uri:s.path}}async rename(e){await this._copy(e,!0)}async copy(e){return this._copy(e,!1)}async requestPermissions(){return{publicStorage:"granted"}}async checkPermissions(){return{publicStorage:"granted"}}async _copy(e,t=!1){let{toDirectory:s}=e;const{to:r,from:n,directory:a}=e;if(!r||!n)throw Error("Both to and from must be provided");s||(s=a);const o=this.getPath(a,n),l=this.getPath(s,r);if(o===l)return{uri:l};if(s1e(o,l))throw Error("To path cannot contain the from path");let u;try{u=await this.stat({path:r,directory:s})}catch{const y=r.split("/");y.pop();const v=y.join("/");if(y.length>0&&(await this.stat({path:v,directory:s})).type!=="directory")throw new Error("Parent directory of the to path is a file")}if(u&&u.type==="directory")throw new Error("Cannot overwrite a directory with a file");const h=await this.stat({path:n,directory:a}),c=async(f,y,v)=>{const m=this.getPath(s,f),g=await this.dbRequest("get",[m]);g.ctime=y,g.mtime=v,await this.dbRequest("put",[g])},d=h.ctime?h.ctime:Date.now();switch(h.type){case"file":{const f=await this.readFile({path:n,directory:a});t&&await this.deleteFile({path:n,directory:a});let y;!(f.data instanceof Blob)&&!this.isBase64String(f.data)&&(y=yd.UTF8);const v=await this.writeFile({path:r,directory:s,data:f.data,encoding:y});return t&&await c(r,d,h.mtime),v}case"directory":{if(u)throw Error("Cannot move a directory over an existing object");try{await this.mkdir({path:r,directory:s,recursive:!1}),t&&await c(r,d,h.mtime)}catch{}const f=(await this.readdir({path:n,directory:a})).files;for(const y of f)await this._copy({from:`${n}/${y.name}`,to:`${r}/${y.name}`,directory:a,toDirectory:s},t);t&&await this.rmdir({path:n,directory:a})}}return{uri:l}}isBase64String(e){try{return btoa(atob(e))==e}catch{return!1}}}Yd._debug=!0;const i1e=Object.freeze(Object.defineProperty({__proto__:null,FilesystemWeb:Yd},Symbol.toStringTag,{value:"Module"}));class r1e extends Zh{async enable(){console.log("Immersive mode is only available on Android")}async disable(){console.log("Immersive mode is only available on Android")}}const n1e=Object.freeze(Object.defineProperty({__proto__:null,ImmersiveModeWeb:r1e},Symbol.toStringTag,{value:"Module"}));X.Bounce=mS,X.CanvasBlock=CS,X.CheckDevice=bS,X.EnterFullscreen=iS,X.ExitFullscreen=rS,X.ExperimentProvider=$pe,X.ExperimentRunner=t1e,X.Flip=Mpe,X.Icons=Ed,X.MicCheck=G2,X.Param=Yh,X.PlainInput=$2,X.ProlificEnding=H2,X.Quest=U5,X.RDKCanvas=_4,X.RandomDotKinematogram=D4,X.RequestFilePermission=yS,X.Slide=kpe,X.Text=rc,X.ToastContainer=gS,X.Tutorial=A4,X.Upload=YV,X.Zoom=Ope,X.arrayFlattener=_2,X.canvasCountdown=Xre,X.chunk=w2,X.collapseToast=aS,X.cssTransition=fu,X.getBackendUrl=R2,X.getInitialParticipant=L2,X.getParam=ma,X.getPlatform=Dl,X.getSimulation=ene,X.halton=y2,X.isDesktop=Jre,X.isFullscreen=uo,X.mapDDMChoice=F2,X.noopSimulate=ho,X.now=Ps,X.orchestrateSimulation=ine,X.pipe=b2,X.registerArrayExtensions=Qre,X.registerComponentParams=vm,X.registerExperimentParams=T2,X.registerFlattener=ni,X.registerSimulation=Qs,X.resolveSimulation=Cm,X.sample=C2,X.sampleParticipants=$re,X.seedDistributions=Ore,X.setBackendUrl=tne,X.shuffle=fm,X.simulateDDMTrial=N2,X.simulateParticipant=sne,X.sobol=v2,X.subsetExperimentByParam=Yre,X.toast=_t,X.useToast=pS,X.useToastContainer=dS,X.useTutorialSlide=j0e,Object.defineProperty(X,Symbol.toStringTag,{value:"Module"})});
@@ -1,4 +1,4 @@
1
- import { W as P, b as x, E } from "./mod-DHUjIRfF.js";
1
+ import { W as P, b as x, E } from "./mod-Csi4RGrw.js";
2
2
  function m(w) {
3
3
  const e = w.split("/").filter((t) => t !== "."), r = [];
4
4
  return e.forEach((t) => {
@@ -1,4 +1,4 @@
1
- import { W as e } from "./mod-DHUjIRfF.js";
1
+ import { W as e } from "./mod-Csi4RGrw.js";
2
2
  class s extends e {
3
3
  async enable() {
4
4
  console.log("Immersive mode is only available on Android");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adriansteffan/reactive",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -4,7 +4,7 @@ import { BaseComponentProps } from '../mod';
4
4
  import { registerSimulation } from '../utils/simulation';
5
5
  import { registerFlattener } from '../utils/upload';
6
6
 
7
- registerFlattener('Tutorial', 'session');
7
+ registerFlattener('Tutorial', null);
8
8
 
9
9
  registerSimulation('Tutorial', (trialProps, _experimentState, simulators, participant) => {
10
10
  const slideCount = trialProps.slides?.length ?? 0;
@@ -128,7 +128,8 @@ export function getParam<T extends ParamType>(
128
128
  };
129
129
 
130
130
  // First, check for the parameter in the base64-encoded JSON
131
- const encodedJson = new URLSearchParams(window.location.search).get('_b');
131
+ const searchParams = typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : new URLSearchParams();
132
+ const encodedJson = searchParams.get('_b');
132
133
  if (encodedJson) {
133
134
  try {
134
135
  const jsonString = atob(encodedJson);
@@ -144,7 +145,7 @@ export function getParam<T extends ParamType>(
144
145
  }
145
146
 
146
147
  // Next, check for the parameter directly in the URL
147
- const value = new URLSearchParams(window.location.search).get(name);
148
+ const value = searchParams.get(name);
148
149
  if (value === undefined || value === null) {
149
150
  // If no value found, register default value
150
151
  return defaultValue;