@adriansteffan/reactive 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{mod-CWKvMS7s.js → mod-CZYkml9p.js} +43 -44
- package/dist/mod.d.ts +4 -2
- package/dist/reactive.es.js +39 -39
- package/dist/reactive.umd.js +3 -3
- package/dist/{web-DR-HR3ib.js → web-BVQpCNK1.js} +1 -1
- package/dist/{web-DDyOXSFH.js → web-Ce2dHghr.js} +1 -1
- package/package.json +1 -1
- package/src/components/experimentrunner.tsx +1 -2
- package/src/utils/common.ts +6 -2
- package/template/src/Experiment.tsx +3 -3
|
@@ -16828,36 +16828,36 @@ function Oae(i) {
|
|
|
16828
16828
|
function AV(i, e) {
|
|
16829
16829
|
RV[i] = e;
|
|
16830
16830
|
}
|
|
16831
|
-
function RCe(i) {
|
|
16832
|
-
Mm.length = 0, i.forEach((
|
|
16831
|
+
function RCe(i, e = {}) {
|
|
16832
|
+
if (Oae(i), Mm.length = 0, i.forEach((n) => {
|
|
16833
16833
|
Mm.push({
|
|
16834
|
-
type:
|
|
16835
|
-
name:
|
|
16834
|
+
type: n.type ?? "NoTypeSpecified",
|
|
16835
|
+
name: n.name
|
|
16836
16836
|
});
|
|
16837
|
-
});
|
|
16838
|
-
const
|
|
16839
|
-
let
|
|
16840
|
-
if (
|
|
16841
|
-
const
|
|
16842
|
-
|
|
16843
|
-
const
|
|
16844
|
-
const
|
|
16845
|
-
return !isNaN(
|
|
16846
|
-
}),
|
|
16847
|
-
return
|
|
16837
|
+
}), !e.subset) return i;
|
|
16838
|
+
const t = ia("includeSubset", void 0), s = ia("excludeSubset", void 0);
|
|
16839
|
+
let r = [...i];
|
|
16840
|
+
if (t) {
|
|
16841
|
+
const n = t.split(",");
|
|
16842
|
+
r = r.filter((a, o) => {
|
|
16843
|
+
const l = n.some((h) => {
|
|
16844
|
+
const c = parseInt(h, 10);
|
|
16845
|
+
return !isNaN(c) && c - 1 === o;
|
|
16846
|
+
}), u = a.name && n.includes(a.name);
|
|
16847
|
+
return l || u;
|
|
16848
16848
|
});
|
|
16849
16849
|
}
|
|
16850
|
-
if (
|
|
16851
|
-
const
|
|
16852
|
-
|
|
16853
|
-
const
|
|
16854
|
-
const
|
|
16855
|
-
return !isNaN(
|
|
16856
|
-
}),
|
|
16857
|
-
return !(
|
|
16850
|
+
if (s) {
|
|
16851
|
+
const n = s.split(",");
|
|
16852
|
+
r = r.filter((a, o) => {
|
|
16853
|
+
const l = n.some((h) => {
|
|
16854
|
+
const c = parseInt(h, 10);
|
|
16855
|
+
return !isNaN(c) && c - 1 === o;
|
|
16856
|
+
}), u = a.name && n.includes(a.name);
|
|
16857
|
+
return !(l || u);
|
|
16858
16858
|
});
|
|
16859
16859
|
}
|
|
16860
|
-
return
|
|
16860
|
+
return r;
|
|
16861
16861
|
}
|
|
16862
16862
|
function ACe(i) {
|
|
16863
16863
|
return i <= 0 ? [] : Array.from({ length: i }, (e, t) => {
|
|
@@ -79109,7 +79109,7 @@ var rg;
|
|
|
79109
79109
|
i.UTF8 = "utf8", i.ASCII = "ascii", i.UTF16 = "utf16";
|
|
79110
79110
|
})(rg || (rg = {}));
|
|
79111
79111
|
const Ia = Su("Filesystem", {
|
|
79112
|
-
web: () => import("./web-
|
|
79112
|
+
web: () => import("./web-Ce2dHghr.js").then((i) => new i.FilesystemWeb())
|
|
79113
79113
|
});
|
|
79114
79114
|
ai("Upload", async (i, e, t, s) => {
|
|
79115
79115
|
const r = i.sessionID || `sim_${Date.now()}_${Math.floor(At(0, 2176782336)).toString(36)}`, n = OV({
|
|
@@ -79363,7 +79363,7 @@ var mw;
|
|
|
79363
79363
|
i.None = "NONE", i.Slide = "SLIDE", i.Fade = "FADE";
|
|
79364
79364
|
})(mw || (mw = {}));
|
|
79365
79365
|
const v7 = Su("StatusBar"), y7 = Su("ImmersiveMode", {
|
|
79366
|
-
web: () => import("./web-
|
|
79366
|
+
web: () => import("./web-BVQpCNK1.js").then((i) => new i.ImmersiveModeWeb())
|
|
79367
79367
|
});
|
|
79368
79368
|
xi("EnterFullscreen", "session");
|
|
79369
79369
|
ai("EnterFullscreen", Tu, {});
|
|
@@ -87002,7 +87002,6 @@ function jCe({
|
|
|
87002
87002
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87003
87003
|
simulationConfig: a
|
|
87004
87004
|
}) {
|
|
87005
|
-
Oae(i);
|
|
87006
87005
|
const o = Wme(), l = vi(() => Pd(i), [i]), u = me((() => {
|
|
87007
87006
|
const U = {}, re = new URLSearchParams(window.location.search);
|
|
87008
87007
|
for (const [ee, de] of re.entries())
|
|
@@ -87273,23 +87272,23 @@ export {
|
|
|
87273
87272
|
kCe as a0,
|
|
87274
87273
|
xae as a1,
|
|
87275
87274
|
dae as a2,
|
|
87276
|
-
|
|
87277
|
-
|
|
87278
|
-
|
|
87279
|
-
|
|
87280
|
-
|
|
87281
|
-
|
|
87282
|
-
|
|
87283
|
-
|
|
87284
|
-
|
|
87285
|
-
|
|
87286
|
-
|
|
87287
|
-
|
|
87288
|
-
|
|
87289
|
-
|
|
87290
|
-
|
|
87291
|
-
|
|
87292
|
-
|
|
87275
|
+
RCe as a3,
|
|
87276
|
+
Wae as a4,
|
|
87277
|
+
TCe as a5,
|
|
87278
|
+
AV as a6,
|
|
87279
|
+
Oae as a7,
|
|
87280
|
+
xi as a8,
|
|
87281
|
+
ai as a9,
|
|
87282
|
+
LV as aa,
|
|
87283
|
+
wae as ab,
|
|
87284
|
+
VCe as ac,
|
|
87285
|
+
ECe as ad,
|
|
87286
|
+
PCe as ae,
|
|
87287
|
+
_Ce as af,
|
|
87288
|
+
Pv as ag,
|
|
87289
|
+
foe as ah,
|
|
87290
|
+
DCe as ai,
|
|
87291
|
+
yae as aj,
|
|
87293
87292
|
Sae as ak,
|
|
87294
87293
|
tr as al,
|
|
87295
87294
|
zae as am,
|
package/dist/mod.d.ts
CHANGED
|
@@ -334,6 +334,10 @@ export declare type PoissonSpec = {
|
|
|
334
334
|
|
|
335
335
|
export declare type PostStimStrategyDef = ContinueStrategy | CollapseStrategy | SnapshotStrategy;
|
|
336
336
|
|
|
337
|
+
export declare function prepareTimeline(experiment: any[], options?: {
|
|
338
|
+
subset?: boolean;
|
|
339
|
+
}): any[];
|
|
340
|
+
|
|
337
341
|
/**
|
|
338
342
|
* Returns the duration of a base64-encoded audio file in milliseconds using ffprobe.
|
|
339
343
|
* Returns null if ffprobe is unavailable or the audio can't be probed.
|
|
@@ -571,8 +575,6 @@ declare type Store_2 = Record<string, any>;
|
|
|
571
575
|
|
|
572
576
|
declare type StoreUpdateFunction = (data?: TrialResult[], store?: Store_2) => Record<string, any>;
|
|
573
577
|
|
|
574
|
-
export declare function subsetExperimentByParam(experiment: any[]): any[];
|
|
575
|
-
|
|
576
578
|
/**
|
|
577
579
|
* Returns the sum of a number array
|
|
578
580
|
*/
|
package/dist/reactive.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as e, H as t, C as i, a as o, D as r, c as n, d as l, e as m, f as u, g as c, h as p, Y as D, z as d, L as T, M as
|
|
1
|
+
import { A as e, H as t, C as i, a as o, D as r, c as n, d as l, e as m, f as u, g as c, h as p, Y as D, z as d, L as T, M as g, P as C, i as P, j as S, Q as A, R as h, k as v, l as x, F as _, T as k, m as B, n as E, o as M, p as f, U as F, V as I, X as L, q as R, r as U, s as b, t as G, u as K, v as w, w as q, x as y, y as H, B as O, G as j, I as N, J as Q, K as V, N as Y, O as Z, S as z, Z as J, _ as W, $ as X, a0 as $, a1 as aa, a2 as sa, a3 as ea, a4 as ta, a5 as ia, a6 as oa, a7 as ra, a8 as na, a9 as la, aa as ma, ab as ua, ac as ca, ad as pa, ae as Da, af as da, ag as Ta, ah as ga, ai as Ca, aj as Pa, ak as Sa, al as Aa, am as ha, an as va, ao as xa, ap as _a, aq as ka, ar as Ba, as as Ea, at as Ma } from "./mod-CZYkml9p.js";
|
|
2
2
|
export {
|
|
3
3
|
e as AudioDeviceContext,
|
|
4
4
|
t as Bounce,
|
|
@@ -14,31 +14,31 @@ export {
|
|
|
14
14
|
D as Flip,
|
|
15
15
|
d as Icons,
|
|
16
16
|
T as LIGHT_DOT_BG_CLASS,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
g as MicCheck,
|
|
18
|
+
C as Param,
|
|
19
|
+
P as PlainInput,
|
|
20
20
|
S as ProlificEnding,
|
|
21
21
|
A as Quest,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
h as RDKCanvas,
|
|
23
|
+
v as RandomDotKinematogram,
|
|
24
|
+
x as RequestFilePermission,
|
|
25
|
+
_ as Slide,
|
|
26
|
+
k as THEME,
|
|
27
|
+
B as Text,
|
|
28
|
+
E as ThemeContext,
|
|
29
29
|
M as ToastContainer,
|
|
30
30
|
f as Tutorial,
|
|
31
31
|
F as Upload,
|
|
32
32
|
I as VoiceRecording,
|
|
33
33
|
L as Zoom,
|
|
34
34
|
R as arrayFlattener,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
U as canvasCountdown,
|
|
36
|
+
b as chunk,
|
|
37
37
|
G as collapseToast,
|
|
38
38
|
K as cssTransition,
|
|
39
39
|
w as draw,
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
q as getBackendUrl,
|
|
41
|
+
y as getInitialParticipant,
|
|
42
42
|
H as getParam,
|
|
43
43
|
O as getPlatform,
|
|
44
44
|
j as getSimulation,
|
|
@@ -54,31 +54,31 @@ export {
|
|
|
54
54
|
$ as orchestrateSimulation,
|
|
55
55
|
aa as pipe,
|
|
56
56
|
sa as poisson,
|
|
57
|
-
ea as
|
|
58
|
-
ta as
|
|
59
|
-
ia as
|
|
60
|
-
oa as
|
|
61
|
-
ra as
|
|
62
|
-
na as
|
|
63
|
-
la as
|
|
64
|
-
ma as
|
|
65
|
-
ua as
|
|
66
|
-
ca as
|
|
67
|
-
pa as
|
|
68
|
-
Da as
|
|
69
|
-
da as
|
|
70
|
-
Ta as
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
ea as prepareTimeline,
|
|
58
|
+
ta as probeAudioDurationMs,
|
|
59
|
+
ia as registerArrayExtensions,
|
|
60
|
+
oa as registerComponentParams,
|
|
61
|
+
ra as registerExperimentParams,
|
|
62
|
+
na as registerFlattener,
|
|
63
|
+
la as registerSimulation,
|
|
64
|
+
ma as resolveSimulation,
|
|
65
|
+
ua as sample,
|
|
66
|
+
ca as sampleParticipants,
|
|
67
|
+
pa as seedDistributions,
|
|
68
|
+
Da as selectPrevTrialData,
|
|
69
|
+
da as setBackendUrl,
|
|
70
|
+
Ta as shuffle,
|
|
71
|
+
ga as simulateDDMTrial,
|
|
72
|
+
Ca as simulateParticipant,
|
|
73
|
+
Pa as sobol,
|
|
74
74
|
Sa as sum,
|
|
75
75
|
Aa as t,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
ha as textToWebmBase64,
|
|
77
|
+
va as toast,
|
|
78
|
+
xa as uniform,
|
|
79
|
+
_a as useAudioDeviceId,
|
|
80
|
+
ka as useTheme,
|
|
81
|
+
Ba as useToast,
|
|
82
|
+
Ea as useToastContainer,
|
|
83
83
|
Ma as useTutorialSlide
|
|
84
84
|
};
|
package/dist/reactive.umd.js
CHANGED
|
@@ -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 Yre=st,w2=Qre,Xre=Jre;Yre(w2,"factory",Xre);var ene=w2;const tne=Ga(ene),Rs=new Uint32Array(1);function sne(i){return Rs[0]=i,Rs[0]=(Rs[0]<<16|Rs[0]>>16)>>>0,Rs[0]=(Rs[0]&1431655765)<<1|(Rs[0]&2863311530)>>>1>>>0,Rs[0]=(Rs[0]&858993459)<<2|(Rs[0]&3435973836)>>>2>>>0,Rs[0]=(Rs[0]&252645135)<<4|(Rs[0]&4042322160)>>>4>>>0,Rs[0]=(Rs[0]&16711935)<<8|(Rs[0]&4278255360)>>>8>>>0,Rs[0]*23283064365386963e-26}function ine(i,e){let t=1,s=0;for(;i>0;)t/=e,s+=t*(i%e),i=~~(i/e);return s}const rne=(i,e=[2,3])=>Array.from({length:i},(t,s)=>e.map(r=>r===2?sne(s):ine(s,r)));K.normal=GC,K.poisson=wb,K.uniform=Db;function nne(i){const e=t$.factory({seed:i});K.normal=GC.factory({prng:e.normalized}),K.poisson=wb.factory({prng:e.normalized}),K.uniform=Db.factory({prng:e.normalized}),Math.random=()=>K.uniform(0,1)}function x2(i){return Math.max(1e-10,Math.min(1-1e-10,i))}function bm(i){switch(i.distribution){case"uniform":return e=>i.min+e*(i.max-i.min);case"normal":return e=>fZ(x2(e),i.mean,i.sd);case"poisson":return e=>tne(x2(e),i.mean);case"integer":return e=>Math.floor(i.min+e*(i.max-i.min+1));case"discrete":{const e=i.outcomes.reduce((s,r)=>s+r.weight,0),t=i.outcomes.map((()=>{let s=0;return r=>(s+=r.weight/e,s)})());return s=>{for(let r=0;r<t.length;r++)if(s<t[r])return i.outcomes[r].value;return i.outcomes[i.outcomes.length-1].value}}}}function E2(i,e){const t=e.map(bm);return e.length===1?i.map(s=>t[0](s[0])):i.map(s=>s.map((r,n)=>t[n](r)))}const ane=[[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]]],ho=32,one=2**ho;function lne(i){const e=new Uint32Array(ho);if(i===0){for(let n=0;n<ho;n++)e[n]=1<<ho-1-n;return e}const[t,s,r]=ane[i-1];for(let n=0;n<t;n++)e[n]=r[n]<<ho-1-n;for(let n=t;n<ho;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 une(i,e){if(e<1||e>21)throw new RangeError("sobol() supports 1-21 dimensions");const t=Array.from({length:e},(n,a)=>lne(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/one))}return r}const hne=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73],V2=6;function S2(i,e){const t=une(i+1,e.length).slice(1);return E2(t,e)}function T2(i,e){e.length>V2&&console.warn(`Halton sequence quality degrades above ${V2} dimensions. Consider using sobol() instead.`);const t=hne.slice(0,e.length),s=rne(i+1,t).slice(1);return E2(s,e)}function cne(i,e,t){const s=Object.keys(t),r=s.map(a=>t[a]);let n;switch(i){case"sobol":n=S2(e,r);break;case"halton":n=T2(e,r);break;case"random":n=dne(e,r);break}return Array.from({length:e},(a,o)=>{const l=s.length===1?[n[o]]:n[o];return{index:o,...Object.fromEntries(s.map((u,h)=>[u,l[h]]))}})}function dne(i,e){const t=e.map(bm);return e.length===1?Array.from({length:i},()=>t[0](K.uniform(0,1))):Array.from({length:i},()=>t.map(s=>s(K.uniform(0,1))))}function pne(i){return bm(i)(K.uniform(0,1))}function P2(i,e=1,t={}){const{replace:s=!0}=t;if(i.length===0)return[];if(s){const a=[];for(let o=0;o<e;o++){const l=Math.floor(K.uniform(0,1)*i.length);a.push(i[l])}return a}const r=[];let n=[];for(let a=0;a<e;a++)n.length===0&&(n=sc(i)),r.push(n.pop());return r}function sc(i){const e=[...i];for(let t=e.length-1;t>=0;t--){const s=Math.floor(K.uniform(0,1)*(t+1));[e[t],e[s]]=[e[s],e[t]]}return e}function I2(i,e){return e(i)}function R2(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 A2(i){return i.length===0?0:i.reduce((e,t)=>e+t,0)/i.length}function L2(i){return i.reduce((e,t)=>e+t,0)}function fne(){typeof Array.prototype.sample!="function"&&(Array.prototype.sample=function(i,e){return P2(this,i,e)}),typeof Array.prototype.shuffle!="function"&&(Array.prototype.shuffle=function(){return sc(this)}),typeof Array.prototype.pipe!="function"&&(Array.prototype.pipe=function(i){return I2(this,i)}),typeof Array.prototype.mean!="function"&&(Array.prototype.mean=function(){return A2(this)}),typeof Array.prototype.sum!="function"&&(Array.prototype.sum=function(){return L2(this)}),typeof Array.prototype.chunk!="function"&&(Array.prototype.chunk=function(i){return R2(this,i)})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var co;(function(i){i.Unimplemented="UNIMPLEMENTED",i.Unavailable="UNAVAILABLE"})(co||(co={}));class wm extends Error{constructor(e,t,s){super(e),this.message=e,this.code=t,this.data=s}}const mne=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"},gne=i=>{const e=i.CapacitorCustomPlatform||null,t=i.Capacitor||{},s=t.Plugins=t.Plugins||{},r=()=>e!==null?e.name:mne(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=(P,O)=>{var D,$;if(v){const Q=v==null?void 0:v.methods.find(_=>O===_.name);if(Q)return Q.rtype==="promise"?_=>t.nativePromise(c,O.toString(),_):(_,B)=>t.nativeCallback(c,O.toString(),_,B);if(P)return(D=P[O])===null||D===void 0?void 0:D.bind(P)}else{if(P)return($=P[O])===null||$===void 0?void 0:$.bind(P);throw new wm(`"${c}" plugin is not implemented on ${y}`,co.Unimplemented)}},x=P=>{let O;const D=(...$)=>{const Q=g().then(_=>{const B=b(_,P);if(B){const H=B(...$);return O=H==null?void 0:H.remove,H}else throw new wm(`"${c}.${P}()" is not implemented on ${y}`,co.Unimplemented)});return P==="addListener"&&(Q.remove=async()=>O()),Q};return D.toString=()=>`${P.toString()}() { [capacitor code] }`,Object.defineProperty(D,"name",{value:P,writable:!1,configurable:!1}),D},I=x("addListener"),L=x("removeListener"),A=(P,O)=>{const D=I({eventName:P},O),$=async()=>{const _=await D;L({eventName:P,callbackId:_},O)},Q=new Promise(_=>D.then(()=>_({remove:$})));return Q.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await $()},Q},k=new Proxy({},{get(P,O){switch(O){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return v?A:I;case"removeListener":return L;default:return x(O)}}});return s[c]=k,u.set(c,{name:c,proxy:k,platforms:new Set([...Object.keys(d),...v?[y]:[]])}),k};return t.convertFileSrc||(t.convertFileSrc=c=>c),t.getPlatform=r,t.handleError=l,t.isNativePlatform=n,t.isPluginAvailable=a,t.registerPlugin=h,t.Exception=wm,t.DEBUG=!!t.DEBUG,t.isLoggingEnabled=!!t.isLoggingEnabled,t},Ca=(i=>i.Capacitor=gne(i))(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Ol=Ca.registerPlugin;class ic{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 Ca.Exception(e,co.Unimplemented)}unavailable(e="not available"){return new Ca.Exception(e,co.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 _2=i=>encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),D2=i=>i.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class vne extends ic{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=D2(r).trim(),n=D2(n).trim(),t[r]=n}),t}async setCookie(e){try{const t=_2(e.key),s=_2(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)}}}Ol("CapacitorCookies",{web:()=>new vne});const yne=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)}),Cne=(i={})=>{const e=Object.keys(i);return Object.keys(i).map(r=>r.toLocaleLowerCase()).reduce((r,n,a)=>(r[n]=i[e[a]],r),{})},bne=(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,k2=(i,e={})=>{const t=Object.assign({method:i.method||"GET",headers:i.headers},e),r=Cne(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 wne extends ic{async request(e){const t=k2(e,e.webFetchExtra),s=bne(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 yne(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"}))}}Ol("CapacitorHttp",{web:()=>new wne});function As(){return Math.round(performance.now())}function po(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}function xne(){return window.electronAPI!==void 0}function Ene(i,e){if(!e)return i.at(-1);for(let t=i.length-1;t>=0;t--)if(i[t].type===e)return i[t]}const Ml=[];function en(i,e,t="string",s,r){let n=Ml.find(d=>d.name===i);n||(n={name:i,defaultValue:r!==void 0?r:e,type:t,description:s,value:void 0},Ml.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 xm=[];class Nl{static getRegistry(){return[...Ml]}static getTimelineRepresentation(){return[...xm]}}const Fl=()=>window.electronAPI?"desktop":Ca.isNativePlatform()?"mobile":"web",O2={};function M2(i){i.forEach(e=>{const t=O2[e.type];if(t)for(const s of t)(!e.hideSettings||e.hideSettings!==!0&&!e.hideSettings.includes(s.name))&&(Ml.some(r=>r.name===s.name)||Ml.push(s))})}function Em(i,e){O2[i]=e}function Vne(i){xm.length=0,i.forEach(r=>{xm.push({type:r.type??"NoTypeSpecified",name:r.name})});const e=en("includeSubset",void 0),t=en("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 Sne(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 N2(i){return`user_${i}`}function rc(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[N2(d.id)]=e.length,h=!0;break}case"IF_GOTO":{const d=u,f=n(d.cond);e.push({type:"IfGoto",cond:f,marker:N2(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 nc(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 Dn(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 Vm={};function $s(i,e,t){Vm[i]={simulate:e,defaultSimulators:t}}function Tne(i){return Vm[i]}const fo=(i,e,t,s)=>({responseData:{},participantState:s});function Sm(i,e,t){const s=typeof i.props=="function"?i.props(e,t):i.props||{},r=Vm[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 F2="http://localhost:8001/backend";function Pne(i){F2=i}function q2(){return F2}let B2;function $2(){return B2}async function Ine(i,e){B2={...e};let t={...e};const s=rc(i);let r={};const n=[{index:-1,trialNumber:-1,start:0,end:0,duration:0,type:"",name:"",responseData:{userAgent:"simulated",params:Object.fromEntries((Nl.getRegistry()||[]).map(d=>[d.name,{value:d.value!==void 0?d.value:d.defaultValue,registered:!0,defaultValue:d.defaultValue,type:d.type,description:d.description}]))}}],a=()=>r,o=()=>n,l=d=>{r=d};let u=0,h=0,c=Dn(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=Dn(s,c+1,a,o,l);continue}const{trialProps:f,simulateFn:y,simulators:v}=Sm(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(nc(x,d,n,r)),c=Dn(s,c+1,a,o,l)}return n}async function Rne(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("node",["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("node",[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 Yre=st,w2=Qre,Xre=Jre;Yre(w2,"factory",Xre);var ene=w2;const tne=Ga(ene),Rs=new Uint32Array(1);function sne(i){return Rs[0]=i,Rs[0]=(Rs[0]<<16|Rs[0]>>16)>>>0,Rs[0]=(Rs[0]&1431655765)<<1|(Rs[0]&2863311530)>>>1>>>0,Rs[0]=(Rs[0]&858993459)<<2|(Rs[0]&3435973836)>>>2>>>0,Rs[0]=(Rs[0]&252645135)<<4|(Rs[0]&4042322160)>>>4>>>0,Rs[0]=(Rs[0]&16711935)<<8|(Rs[0]&4278255360)>>>8>>>0,Rs[0]*23283064365386963e-26}function ine(i,e){let t=1,s=0;for(;i>0;)t/=e,s+=t*(i%e),i=~~(i/e);return s}const rne=(i,e=[2,3])=>Array.from({length:i},(t,s)=>e.map(r=>r===2?sne(s):ine(s,r)));K.normal=GC,K.poisson=wb,K.uniform=Db;function nne(i){const e=t$.factory({seed:i});K.normal=GC.factory({prng:e.normalized}),K.poisson=wb.factory({prng:e.normalized}),K.uniform=Db.factory({prng:e.normalized}),Math.random=()=>K.uniform(0,1)}function x2(i){return Math.max(1e-10,Math.min(1-1e-10,i))}function bm(i){switch(i.distribution){case"uniform":return e=>i.min+e*(i.max-i.min);case"normal":return e=>fZ(x2(e),i.mean,i.sd);case"poisson":return e=>tne(x2(e),i.mean);case"integer":return e=>Math.floor(i.min+e*(i.max-i.min+1));case"discrete":{const e=i.outcomes.reduce((s,r)=>s+r.weight,0),t=i.outcomes.map((()=>{let s=0;return r=>(s+=r.weight/e,s)})());return s=>{for(let r=0;r<t.length;r++)if(s<t[r])return i.outcomes[r].value;return i.outcomes[i.outcomes.length-1].value}}}}function E2(i,e){const t=e.map(bm);return e.length===1?i.map(s=>t[0](s[0])):i.map(s=>s.map((r,n)=>t[n](r)))}const ane=[[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]]],ho=32,one=2**ho;function lne(i){const e=new Uint32Array(ho);if(i===0){for(let n=0;n<ho;n++)e[n]=1<<ho-1-n;return e}const[t,s,r]=ane[i-1];for(let n=0;n<t;n++)e[n]=r[n]<<ho-1-n;for(let n=t;n<ho;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 une(i,e){if(e<1||e>21)throw new RangeError("sobol() supports 1-21 dimensions");const t=Array.from({length:e},(n,a)=>lne(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/one))}return r}const hne=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73],V2=6;function S2(i,e){const t=une(i+1,e.length).slice(1);return E2(t,e)}function T2(i,e){e.length>V2&&console.warn(`Halton sequence quality degrades above ${V2} dimensions. Consider using sobol() instead.`);const t=hne.slice(0,e.length),s=rne(i+1,t).slice(1);return E2(s,e)}function cne(i,e,t){const s=Object.keys(t),r=s.map(a=>t[a]);let n;switch(i){case"sobol":n=S2(e,r);break;case"halton":n=T2(e,r);break;case"random":n=dne(e,r);break}return Array.from({length:e},(a,o)=>{const l=s.length===1?[n[o]]:n[o];return{index:o,...Object.fromEntries(s.map((u,h)=>[u,l[h]]))}})}function dne(i,e){const t=e.map(bm);return e.length===1?Array.from({length:i},()=>t[0](K.uniform(0,1))):Array.from({length:i},()=>t.map(s=>s(K.uniform(0,1))))}function pne(i){return bm(i)(K.uniform(0,1))}function P2(i,e=1,t={}){const{replace:s=!0}=t;if(i.length===0)return[];if(s){const a=[];for(let o=0;o<e;o++){const l=Math.floor(K.uniform(0,1)*i.length);a.push(i[l])}return a}const r=[];let n=[];for(let a=0;a<e;a++)n.length===0&&(n=sc(i)),r.push(n.pop());return r}function sc(i){const e=[...i];for(let t=e.length-1;t>=0;t--){const s=Math.floor(K.uniform(0,1)*(t+1));[e[t],e[s]]=[e[s],e[t]]}return e}function I2(i,e){return e(i)}function R2(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 A2(i){return i.length===0?0:i.reduce((e,t)=>e+t,0)/i.length}function L2(i){return i.reduce((e,t)=>e+t,0)}function fne(){typeof Array.prototype.sample!="function"&&(Array.prototype.sample=function(i,e){return P2(this,i,e)}),typeof Array.prototype.shuffle!="function"&&(Array.prototype.shuffle=function(){return sc(this)}),typeof Array.prototype.pipe!="function"&&(Array.prototype.pipe=function(i){return I2(this,i)}),typeof Array.prototype.mean!="function"&&(Array.prototype.mean=function(){return A2(this)}),typeof Array.prototype.sum!="function"&&(Array.prototype.sum=function(){return L2(this)}),typeof Array.prototype.chunk!="function"&&(Array.prototype.chunk=function(i){return R2(this,i)})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var co;(function(i){i.Unimplemented="UNIMPLEMENTED",i.Unavailable="UNAVAILABLE"})(co||(co={}));class wm extends Error{constructor(e,t,s){super(e),this.message=e,this.code=t,this.data=s}}const mne=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"},gne=i=>{const e=i.CapacitorCustomPlatform||null,t=i.Capacitor||{},s=t.Plugins=t.Plugins||{},r=()=>e!==null?e.name:mne(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=(P,O)=>{var D,$;if(v){const Q=v==null?void 0:v.methods.find(_=>O===_.name);if(Q)return Q.rtype==="promise"?_=>t.nativePromise(c,O.toString(),_):(_,B)=>t.nativeCallback(c,O.toString(),_,B);if(P)return(D=P[O])===null||D===void 0?void 0:D.bind(P)}else{if(P)return($=P[O])===null||$===void 0?void 0:$.bind(P);throw new wm(`"${c}" plugin is not implemented on ${y}`,co.Unimplemented)}},x=P=>{let O;const D=(...$)=>{const Q=g().then(_=>{const B=b(_,P);if(B){const H=B(...$);return O=H==null?void 0:H.remove,H}else throw new wm(`"${c}.${P}()" is not implemented on ${y}`,co.Unimplemented)});return P==="addListener"&&(Q.remove=async()=>O()),Q};return D.toString=()=>`${P.toString()}() { [capacitor code] }`,Object.defineProperty(D,"name",{value:P,writable:!1,configurable:!1}),D},I=x("addListener"),L=x("removeListener"),A=(P,O)=>{const D=I({eventName:P},O),$=async()=>{const _=await D;L({eventName:P,callbackId:_},O)},Q=new Promise(_=>D.then(()=>_({remove:$})));return Q.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await $()},Q},k=new Proxy({},{get(P,O){switch(O){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return v?A:I;case"removeListener":return L;default:return x(O)}}});return s[c]=k,u.set(c,{name:c,proxy:k,platforms:new Set([...Object.keys(d),...v?[y]:[]])}),k};return t.convertFileSrc||(t.convertFileSrc=c=>c),t.getPlatform=r,t.handleError=l,t.isNativePlatform=n,t.isPluginAvailable=a,t.registerPlugin=h,t.Exception=wm,t.DEBUG=!!t.DEBUG,t.isLoggingEnabled=!!t.isLoggingEnabled,t},Ca=(i=>i.Capacitor=gne(i))(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Ol=Ca.registerPlugin;class ic{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 Ca.Exception(e,co.Unimplemented)}unavailable(e="not available"){return new Ca.Exception(e,co.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 _2=i=>encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),D2=i=>i.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class vne extends ic{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=D2(r).trim(),n=D2(n).trim(),t[r]=n}),t}async setCookie(e){try{const t=_2(e.key),s=_2(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)}}}Ol("CapacitorCookies",{web:()=>new vne});const yne=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)}),Cne=(i={})=>{const e=Object.keys(i);return Object.keys(i).map(r=>r.toLocaleLowerCase()).reduce((r,n,a)=>(r[n]=i[e[a]],r),{})},bne=(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,k2=(i,e={})=>{const t=Object.assign({method:i.method||"GET",headers:i.headers},e),r=Cne(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 wne extends ic{async request(e){const t=k2(e,e.webFetchExtra),s=bne(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 yne(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"}))}}Ol("CapacitorHttp",{web:()=>new wne});function As(){return Math.round(performance.now())}function po(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}function xne(){return window.electronAPI!==void 0}function Ene(i,e){if(!e)return i.at(-1);for(let t=i.length-1;t>=0;t--)if(i[t].type===e)return i[t]}const Ml=[];function en(i,e,t="string",s,r){let n=Ml.find(d=>d.name===i);n||(n={name:i,defaultValue:r!==void 0?r:e,type:t,description:s,value:void 0},Ml.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 xm=[];class Nl{static getRegistry(){return[...Ml]}static getTimelineRepresentation(){return[...xm]}}const Fl=()=>window.electronAPI?"desktop":Ca.isNativePlatform()?"mobile":"web",O2={};function M2(i){i.forEach(e=>{const t=O2[e.type];if(t)for(const s of t)(!e.hideSettings||e.hideSettings!==!0&&!e.hideSettings.includes(s.name))&&(Ml.some(r=>r.name===s.name)||Ml.push(s))})}function Em(i,e){O2[i]=e}function Vne(i,e={}){if(M2(i),xm.length=0,i.forEach(n=>{xm.push({type:n.type??"NoTypeSpecified",name:n.name})}),!e.subset)return i;const t=en("includeSubset",void 0),s=en("excludeSubset",void 0);let r=[...i];if(t){const n=t.split(",");r=r.filter((a,o)=>{const l=n.some(h=>{const c=parseInt(h,10);return!isNaN(c)&&c-1===o}),u=a.name&&n.includes(a.name);return l||u})}if(s){const n=s.split(",");r=r.filter((a,o)=>{const l=n.some(h=>{const c=parseInt(h,10);return!isNaN(c)&&c-1===o}),u=a.name&&n.includes(a.name);return!(l||u)})}return r}function Sne(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 N2(i){return`user_${i}`}function rc(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[N2(d.id)]=e.length,h=!0;break}case"IF_GOTO":{const d=u,f=n(d.cond);e.push({type:"IfGoto",cond:f,marker:N2(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 nc(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 Dn(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 Vm={};function $s(i,e,t){Vm[i]={simulate:e,defaultSimulators:t}}function Tne(i){return Vm[i]}const fo=(i,e,t,s)=>({responseData:{},participantState:s});function Sm(i,e,t){const s=typeof i.props=="function"?i.props(e,t):i.props||{},r=Vm[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 F2="http://localhost:8001/backend";function Pne(i){F2=i}function q2(){return F2}let B2;function $2(){return B2}async function Ine(i,e){B2={...e};let t={...e};const s=rc(i);let r={};const n=[{index:-1,trialNumber:-1,start:0,end:0,duration:0,type:"",name:"",responseData:{userAgent:"simulated",params:Object.fromEntries((Nl.getRegistry()||[]).map(d=>[d.name,{value:d.value!==void 0?d.value:d.defaultValue,registered:!0,defaultValue:d.defaultValue,type:d.type,description:d.description}]))}}],a=()=>r,o=()=>n,l=d=>{r=d};let u=0,h=0,c=Dn(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=Dn(s,c+1,a,o,l);continue}const{trialProps:f,simulateFn:y,simulators:v}=Sm(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(nc(x,d,n,r)),c=Dn(s,c+1,a,o,l)}return n}async function Rne(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("node",["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("node",[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 ac={};function Zs(i,e,t){ac[i]||(ac[i]=[]),ac[i].push({csv:e,flatten:t})}function H2(i){const e=i.responseData;return Array.isArray(e)?e.map(t=>({block:i.name,...t})):[]}function Q2(i){if(i==null)return"";const e=typeof i=="object"?JSON.stringify(i):String(i);return e.includes(",")||e.includes('"')||e.includes(`
|
|
10151
10151
|
`)?`"${e.replace(/"/g,'""')}"`:e}function oc(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=>Q2(n)).join(","),r=i.map(n=>t.map(a=>{const o=n[a];return Q2(o)}).join(","));return[s,...r].join(`
|
|
@@ -10250,6 +10250,6 @@ Click the button below to add a new entry.`,noEntriesReadonlyText:"No entries",t
|
|
|
10250
10250
|
${x}px !important;
|
|
10251
10251
|
${I}px !important;
|
|
10252
10252
|
}
|
|
10253
|
-
`),()=>{var k;(k=o.current)==null||k.removeAttribute("data-motion-pop-id"),A.contains(L)&&A.removeChild(L)}},[e]),S.jsx(c0e,{isPresent:e,childRef:o,sizeRef:l,pop:n,children:n===!1?i:p.cloneElement(i,{ref:c})})}const p0e=({children:i,initial:e,isPresent:t,onExitComplete:s,custom:r,presenceAffectsLayout:n,mode:a,anchorX:o,anchorY:l,root:u})=>{const h=av(f0e),c=V.useId();let d=!0,f=V.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}),V.useMemo(()=>{h.forEach((y,v)=>h.set(v,!1))},[t]),p.useEffect(()=>{!t&&!h.size&&s&&s()},[t]),i=S.jsx(d0e,{pop:a==="popLayout",isPresent:t,anchorX:o,anchorY:l,root:u,children:i}),S.jsx(Ld.Provider,{value:f,children:i})};function f0e(){return new Map}function E4(i=!0){const e=V.useContext(Ld);if(e===null)return[!0,null];const{isPresent:t,onExitComplete:s,register:r}=e,n=V.useId();V.useEffect(()=>{if(i)return r(n)},[i]);const a=V.useCallback(()=>i&&s&&s(n),[n,s,i]);return!t&&s?[!1,a]:[!0]}const Xd=i=>i.key||"";function V4(i){const e=[];return V.Children.forEach(i,t=>{V.isValidElement(t)&&e.push(t)}),e}const m0e=({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]=E4(a),d=V.useMemo(()=>V4(i),[i]),f=a&&!h?[]:d.map(Xd),y=V.useRef(!0),v=V.useRef(d),m=av(()=>new Map),g=V.useRef(new Set),[b,x]=V.useState(d),[I,L]=V.useState(d);ov(()=>{y.current=!1,v.current=d;for(let P=0;P<I.length;P++){const O=Xd(I[P]);f.includes(O)?(m.delete(O),g.current.delete(O)):m.get(O)!==!0&&m.set(O,!1)}},[I,f.length,f.join("-")]);const A=[];if(d!==b){let P=[...d];for(let O=0;O<I.length;O++){const D=I[O],$=Xd(D);f.includes($)||(P.splice(O,0,D),A.push(D))}return n==="wait"&&A.length&&(P=A),L(V4(P)),x(d),null}process.env.NODE_ENV!=="production"&&n==="wait"&&I.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:k}=V.useContext(Eu);return S.jsx(S.Fragment,{children:I.map(P=>{const O=Xd(P),D=a&&!h?!1:d===I||f.includes(O),$=()=>{if(g.current.has(O))return;if(m.has(O))g.current.add(O),m.set(O,!0);else return;let Q=!0;m.forEach(_=>{_||(Q=!1)}),Q&&(k==null||k(),L(v.current),a&&(c==null||c()),s&&s())};return S.jsx(p0e,{isPresent:D,initial:!y.current||t?void 0:!1,custom:e,presenceAffectsLayout:r,mode:n,root:u,onExitComplete:D?void 0:$,anchorX:o,anchorY:l,children:P},O)})})},g0e=V.createContext(null);function v0e(){const i=V.useRef(!1);return ov(()=>(i.current=!0,()=>{i.current=!1}),[]),i}function y0e(){const i=v0e(),[e,t]=V.useState(0),s=V.useCallback(()=>{i.current&&t(e+1)},[e]);return[V.useCallback(()=>Pt.postRender(s),[s]),e]}const S4=i=>i===!0,C0e=i=>S4(i===!0)||i==="id",b0e=({children:i,id:e,inherit:t=!0})=>{const s=V.useContext(Eu),r=V.useContext(g0e),[n,a]=y0e(),o=V.useRef(null),l=s.id||r;o.current===null&&(C0e(t)&&l&&(e=e?l+"-"+e:l),o.current={id:e,group:S4(t)&&s.group||b4()});const u=V.useMemo(()=>({...o.current,forceRender:n}),[a]);return S.jsx(Eu.Provider,{value:u,children:i})},T4=V.createContext({strict:!1}),P4={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 I4=!1;function w0e(){if(I4)return;const i={};for(const e in P4)i[e]={isEnabled:t=>P4[e].some(s=>!!t[s])};b7(i),I4=!0}function R4(){return w0e(),Yge()}function x0e(i){const e=R4();for(const t in i)e[t]={...e[t],...i[t]};b7(e)}const E0e=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 ep(i){return i.startsWith("while")||i.startsWith("drag")&&i!=="draggable"||i.startsWith("layout")||i.startsWith("onTap")||i.startsWith("onPan")||i.startsWith("onLayout")||E0e.has(i)}let A4=i=>!ep(i);function V0e(i){typeof i=="function"&&(A4=e=>e.startsWith("on")?!ep(e):i(e))}try{V0e(require("@emotion/is-prop-valid").default)}catch{}function S0e(i,e,t){const s={};for(const r in i)r==="values"&&typeof i.values=="object"||Ns(i[r])||(A4(r)||t===!0&&ep(r)||!e&&!ep(r)||i.draggable&&r.startsWith("onDrag"))&&(s[r]=i[r]);return s}const tp=V.createContext({});function T0e(i,e){if(zd(i)){const{initial:t,animate:s}=i;return{initial:t===!1||Lu(t)?t:void 0,animate:Lu(s)?s:void 0}}return i.inherit!==!1?e:{}}function P0e(i){const{initial:e,animate:t}=T0e(i,V.useContext(tp));return V.useMemo(()=>({initial:e,animate:t}),[L4(e),L4(t)])}function L4(i){return Array.isArray(i)?i.join(" "):i}const p0=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function _4(i,e,t){for(const s in e)!Ns(e[s])&&!k7(s,t)&&(i[s]=e[s])}function I0e({transformTemplate:i},e){return V.useMemo(()=>{const t=p0();return n0(t,e,i),Object.assign({},t.vars,t.style)},[e])}function R0e(i,e){const t=i.style||{},s={};return _4(s,t,i),Object.assign(s,I0e(i,e)),s}function A0e(i,e){const t={},s=R0e(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 D4=()=>({...p0(),attrs:{}});function L0e(i,e,t,s){const r=V.useMemo(()=>{const n=D4();return O7(n,e,N7(s),i.transformTemplate,i.style),{...n.attrs,style:{...n.style}}},[e]);if(i.style){const n={};_4(n,i.style,i),r.style={...n,...r.style}}return r}const _0e=["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 f0(i){return typeof i!="string"||i.includes("-")?!1:!!(_0e.indexOf(i)>-1||/[A-Z]/u.test(i))}function D0e(i,e,t,{latestValues:s},r,n=!1,a){const l=(a??f0(i)?L0e:A0e)(e,s,r,i),u=S0e(e,typeof i=="string",n),h=i!==V.Fragment?{...u,...l,ref:t}:{},{children:c}=e,d=V.useMemo(()=>Ns(c)?c.get():c,[c]);return V.createElement(i,{...h,children:d})}function k0e({scrapeMotionValuesFromProps:i,createRenderState:e},t,s,r){return{latestValues:O0e(t,s,r,i),renderState:e()}}function O0e(i,e,t,s){const r={},n=s(i,{});for(const d in n)r[d]=Jd(n[d]);let{initial:a,animate:o}=i;const l=zd(i),u=v7(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"&&!jd(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 I=h?x.length-1:0;x=x[I]}x!==null&&(r[b]=x)}for(const b in v)r[b]=v[b]}}}return r}const k4=i=>(e,t)=>{const s=V.useContext(tp),r=V.useContext(Ld),n=()=>k0e(i,e,s,r);return t?n():av(n)},M0e=k4({scrapeMotionValuesFromProps:o0,createRenderState:p0}),N0e=k4({scrapeMotionValuesFromProps:F7,createRenderState:D4}),F0e=Symbol.for("motionComponentSymbol");function q0e(i,e,t){const s=V.useRef(t);V.useInsertionEffect(()=>{s.current=t});const r=V.useRef(null);return V.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 O4=V.createContext({});function Ko(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"current")}function B0e(i,e,t,s,r,n){var x,I;const{visualElement:a}=V.useContext(tp),o=V.useContext(T4),l=V.useContext(Ld),u=V.useContext(d0),h=u.reducedMotion,c=u.skipAnimations,d=V.useRef(null),f=V.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=V.useContext(O4);y&&!y.projection&&r&&(y.type==="html"||y.type==="svg")&&$0e(d.current,t,r,v);const m=V.useRef(!1);V.useInsertionEffect(()=>{y&&m.current&&y.update(t,l)});const g=t[Z3],b=V.useRef(!!g&&typeof window<"u"&&!((x=window.MotionHandoffIsComplete)!=null&&x.call(window,g))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,g)));return ov(()=>{f.current=!0,y&&(m.current=!0,window.MotionIsMounted=!0,y.updateFeatures(),y.scheduleRenderMicrotask(),b.current&&y.animationState&&y.animationState.animateChanges())}),V.useEffect(()=>{y&&(!b.current&&y.animationState&&y.animationState.animateChanges(),b.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,g)}),b.current=!1),y.enteringChildren=void 0)}),y}function $0e(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:M4(i.parent)),i.projection.setOptions({layoutId:r,layout:n,alwaysMeasureLayout:!!a||o&&Ko(o),visualElement:i,animationType:typeof n=="string"?n:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u,layoutAnchor:h})}function M4(i){if(i)return i.options.allowProjection!==!1?i.projection:M4(i.parent)}function m0(i,{forwardMotionProps:e=!1,type:t}={},s,r){s&&x0e(s);const n=t?t==="svg":f0(i),a=n?N0e:M0e;function o(u,h){let c;const d={...V.useContext(d0),...u,layoutId:H0e(u)},{isStatic:f}=d,y=P0e(u),v=a(u,f);if(!f&&typeof window<"u"){Q0e(d,s);const m=U0e(d);c=m.MeasureLayout,y.visualElement=B0e(i,v,d,r,m.ProjectionNode,n)}return S.jsxs(tp.Provider,{value:y,children:[c&&y.visualElement?S.jsx(c,{visualElement:y.visualElement,...d}):null,D0e(i,u,q0e(v,y.visualElement,h),v,f,e,n)]})}o.displayName=`motion.${typeof i=="string"?i:`create(${i.displayName??i.name??""})`}`;const l=V.forwardRef(o);return l[F0e]=i,l}function H0e({layoutId:i}){const e=V.useContext(Eu).id;return e&&i!==void 0?e+"-"+i:i}function Q0e(i,e){const t=V.useContext(T4).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?qo(!1,s,"lazy-strict-mode"):pn(!1,s,"lazy-strict-mode")}}function U0e(i){const e=R4(),{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 j0e(i,e){if(typeof Proxy>"u")return m0;const t=new Map,s=(n,a)=>m0(n,a,i,e),r=(n,a)=>(process.env.NODE_ENV!=="production"&&cv(!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,m0(a,void 0,i,e)),t.get(a))})}const z0e=(i,e)=>e.isSVG??f0(i)?new mve(e):new uve(e,{allowProjection:i!==V.Fragment});class W0e extends sa{constructor(e){super(e),e.animationState||(e.animationState=bve(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();jd(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 G0e=0;class K0e extends sa{constructor(){super(...arguments),this.id=G0e++,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=Na(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 Z0e={animation:{Feature:W0e},exit:{Feature:K0e}};function Ou(i){return{point:{x:i.pageX,y:i.pageY}}}const J0e=i=>e=>Zv(e)&&i(e,Ou(e));function Mu(i,e,t,s){return ku(i,e,J0e(t),s)}const N4=({current:i})=>i?i.ownerDocument.defaultView:null,F4=(i,e)=>Math.abs(i-e);function Y0e(i,e){const t=F4(i.x,e.x),s=F4(i.y,e.y);return Math.sqrt(t**2+s**2)}const q4=new Set(["auto","scroll"]);class B4{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=sp(this.lastRawMoveEventInfo,this.transformPagePoint));const f=g0(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,v=Y0e(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!y&&!v)return;const{point:m}=f,{timestamp:g}=Ms;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=sp(y,this.transformPagePoint),Pt.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=g0(f.type==="pointercancel"?this.lastMoveEventInfo:sp(y,this.transformPagePoint),this.history);this.startEvent&&v&&v(f,b),m&&m(f,b)},!Zv(e))return;this.dragSnapToOrigin=n,this.handlers=t,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=r||window;const l=Ou(e),u=sp(l,this.transformPagePoint),{point:h}=u,{timestamp:c}=Ms;this.history=[{...h,timestamp:c}];const{onSessionStart:d}=t;d&&d(e,g0(u,this.history)),this.removeListeners=Vu(Mu(this.contextWindow,"pointermove",this.handlePointerMove),Mu(this.contextWindow,"pointerup",this.handlePointerUp),Mu(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){const s=getComputedStyle(t);(q4.has(s.overflowX)||q4.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),Pt.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Yn(this.updatePoint)}}function sp(i,e){return e?{point:e(i.point)}:i}function $4(i,e){return{x:i.x-e.x,y:i.y-e.y}}function g0({point:i},e){return{point:i,delta:$4(i,H4(e)),offset:$4(i,X0e(e)),velocity:e1e(e,.1)}}function X0e(i){return i[0]}function H4(i){return i[i.length-1]}function e1e(i,e){if(i.length<2)return{x:0,y:0};let t=i.length-1,s=null;const r=H4(i);for(;t>=0&&(s=i[t],!(r.timestamp-s.timestamp>gi(e)));)t--;if(!s)return{x:0,y:0};s===i[0]&&i.length>2&&r.timestamp-s.timestamp>gi(e)*2&&(s=i[1]);const n=Ki(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 t1e(i,{min:e,max:t},s){return e!==void 0&&i<e?i=s?Bt(e,i,s.min):Math.max(i,e):t!==void 0&&i>t&&(i=s?Bt(t,i,s.max):Math.min(i,t)),i}function Q4(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 s1e(i,{top:e,left:t,bottom:s,right:r}){return{x:Q4(i.x,t,r),y:Q4(i.y,e,s)}}function U4(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 i1e(i,e){return{x:U4(i.x,e.x),y:U4(i.y,e.y)}}function r1e(i,e){let t=.5;const s=ti(i),r=ti(e);return r>s?t=Su(e.min,e.max-s,i.min):s>r&&(t=Su(i.min,i.max-r,e.min)),Nr(0,1,t)}function n1e(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 v0=.35;function a1e(i=v0){return i===!1?i=0:i===!0&&(i=v0),{x:j4(i,"left","right"),y:j4(i,"top","bottom")}}function j4(i,e,t){return{min:z4(i,e),max:z4(i,t)}}function z4(i,e){return typeof i=="number"?i:i[e]||0}const o1e=new WeakMap;class l1e{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=bs(),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(Ou(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=Ige(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),Br(g=>{let b=this.getAxisMotionValue(g).get()||0;if(Fr.test(b)){const{projection:x}=this.visualElement;if(x&&x.layout){const I=x.layout.layoutBox[g];I&&(b=ti(I)*(parseFloat(b)/100))}}this.originPoint[g]=b}),v&&Pt.update(()=>v(c,d),!1,!0),Qv(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=h1e(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&&Pt.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 B4(e,{onSessionStart:n,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:s,contextWindow:N4(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&&Pt.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||!ip(e,r,this.currentDirection))return;const n=this.getAxisMotionValue(e);let a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=t1e(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&&Ko(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=s1e(s.layoutBox,e):this.constraints=!1,this.elastic=a1e(t),r!==this.constraints&&!Ko(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&Br(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=n1e(s.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Ko(e))return!1;const s=e.current;pn(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=ive(s,r.root,this.visualElement.getTransformPagePoint());let a=i1e(r.layout.layoutBox,n);if(t){const o=t(eve(a));this.hasMutatedConstraints=!!o,o&&(a=x7(o))}return a}startAnimation(e){const{drag:t,dragMomentum:s,dragElastic:r,dragTransition:n,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},u=Br(h=>{if(!ip(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 Qv(this.visualElement,e),s.start(Bv(e,s,0,t,this.visualElement,!1))}stopAnimation(){Br(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){Br(t=>{const{drag:s}=this.getProps();if(!ip(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]-Bt(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:s}=this.visualElement;if(!Ko(t)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Br(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();r[a]=r1e({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(),Br(a=>{if(!ip(a,e,null))return;const o=this.getAxisMotionValue(a),{min:l,max:u}=this.constraints[a];o.set(Bt(l,u,r[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;o1e.set(this.visualElement,this);const e=this.visualElement.current,t=Mu(e,"pointerdown",u=>{const{drag:h,dragListener:c=!0}=this.getProps(),d=u.target,f=d!==e&&kge(d);h&&c&&!f&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();Ko(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=u1e(e,u.current,()=>this.scalePositionWithinConstraints())))},{projection:n}=this.visualElement,a=n.addEventListener("measure",r);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),Pt.read(r);const o=ku(window,"resize",()=>this.scalePositionWithinConstraints()),l=n.addEventListener("didUpdate",({delta:u,hasLayoutChanged:h})=>{this.isDragging&&h&&(Br(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=v0,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:s,dragPropagation:r,dragConstraints:n,dragElastic:a,dragMomentum:o}}}function W4(i){let e=!0;return()=>{if(e){e=!1;return}i()}}function u1e(i,e,t){const s=f7(i,W4(t)),r=f7(e,W4(t));return()=>{s(),r()}}function ip(i,e,t){return(e===!0||e===i)&&(t===null||t===i)}function h1e(i,e=10){let t=null;return Math.abs(i.y)>e?t="y":Math.abs(i.x)>e&&(t="x"),t}class c1e extends sa{constructor(e){super(e),this.removeGroupControls=Gi,this.removeListeners=Gi,this.controls=new l1e(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Gi}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 y0=i=>(e,t)=>{i&&Pt.update(()=>i(e,t),!1,!0)};class d1e extends sa{constructor(){super(...arguments),this.removePointerDownListener=Gi}onPointerDown(e){this.session=new B4(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:N4(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:y0(e),onStart:y0(t),onMove:y0(s),onEnd:(n,a)=>{delete this.session,r&&Pt.postRender(()=>r(n,a))}}}mount(){this.removePointerDownListener=Mu(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 C0=!1;class p1e extends V.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),C0&&n.root.didUpdate(),n.addEventListener("animationComplete",()=>{this.safeToRemove()}),n.setOptions({...n.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Yd.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}),C0=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==n?a.willUpdate():this.safeToRemove(),e.isPresent!==n&&(n?a.promote():a.relegate()||Pt.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(),Kv.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s}=this.props,{projection:r}=e;C0=!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 G4(i){const[e,t]=E4(),s=V.useContext(Eu);return S.jsx(p1e,{...i,layoutGroup:s,switchLayoutGroup:V.useContext(O4),isPresent:e,safeToRemove:t})}const f1e={pan:{Feature:d1e},drag:{Feature:c1e,ProjectionNode:w4,MeasureLayout:G4}};function K4(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&&Pt.postRender(()=>n(e,Ou(e)))}class m1e extends sa{mount(){const{current:e}=this.node;e&&(this.unmount=Age(e,(t,s)=>(K4(this.node,s,"Start"),r=>K4(this.node,r,"End"))))}unmount(){}}class g1e extends sa{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=Vu(ku(this.node.current,"focus",()=>this.onFocus()),ku(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Z4(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&&Pt.postRender(()=>n(e,Ou(e)))}class v1e extends sa{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:s}=this.node.props;this.unmount=Mge(e,(r,n)=>(Z4(this.node,n,"Start"),(a,{success:o})=>Z4(this.node,a,o?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:(s==null?void 0:s.tap)===!1})}unmount(){}}const b0=new WeakMap,w0=new WeakMap,y1e=i=>{const e=b0.get(i.target);e&&e(i)},C1e=i=>{i.forEach(y1e)};function b1e({root:i,...e}){const t=i||document;w0.has(t)||w0.set(t,{});const s=w0.get(t),r=JSON.stringify(e);return s[r]||(s[r]=new IntersectionObserver(C1e,{root:i,...e})),s[r]}function w1e(i,e,t){const s=b1e(e);return b0.set(i,t),s.observe(i),()=>{b0.delete(i),s.unobserve(i)}}const x1e={some:0,all:1};class E1e extends sa{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:x1e[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=w1e(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(V1e(e,t))&&this.startObserver()}unmount(){var e;(e=this.stopObserver)==null||e.call(this),this.hasEnteredView=!1,this.isInView=!1}}function V1e({viewport:i={}},{viewport:e={}}={}){return t=>i[t]!==e[t]}const S1e={...Z0e,...{inView:{Feature:E1e},tap:{Feature:v1e},focus:{Feature:g1e},hover:{Feature:m1e}},...f1e,...{layout:{ProjectionNode:w4,MeasureLayout:G4}}},J4=j0e(S1e,z0e);Zs("Tutorial",null),$s("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 Y4=V.createContext({setCanProgress:()=>{},autoAdvance:()=>{},setSlideData:()=>{}}),T1e=({locked:i=!1}={})=>{const e=V.useContext(Y4),t=V.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)}}},X4="px-4 py-3 border-2 font-bold text-lg rounded-xl transition-all duration-100 outline-none focus:outline-none focus:ring-0",eT=({next:i,slides:e,fadeDuration:t=.3,finishText:s="Start",containerClass:r,animate:n=!1,nextKey:a="ArrowRight",backKey:o="ArrowLeft",theme:l})=>{const u=qi(),c=xi(l??u),d=`${X4} ${c.buttonBg} ${c.buttonText} ${c.buttonBorder} ${c.buttonShadow} cursor-pointer hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none`,f=`${X4} ${c.buttonDisabledBg} ${c.buttonDisabledText} ${c.buttonDisabledBorder} ${c.buttonDisabledShadow} cursor-default`,[y,v]=V.useState(0),[m,g]=V.useState({}),b=V.useRef(),x=V.useRef({}),I=m[y]!==!1,L=V.useRef(I),[A,k]=V.useState(!1);V.useEffect(()=>{if(I&&!L.current){k(!0);const B=setTimeout(()=>k(!1),300);return()=>clearTimeout(B)}L.current=I},[I]);const P=V.useCallback(B=>{g(H=>({...H,[y]:B}))},[y]),O=V.useCallback(B=>{x.current[y]={...x.current[y],...B}},[y]),D=V.useCallback(()=>{y===e.length-1?i({slides:x.current}):v(B=>B+1)},[y,e.length,i]),$=V.useCallback(()=>{I&&D()},[I,D]),Q=V.useCallback((B=0)=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>D(),B)},[D]);V.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const _=V.useCallback(()=>{y>0&&v(B=>B-1)},[y]);return V.useEffect(()=>{if(a===!1&&o===!1)return;const B=H=>{a&&H.key===a&&(H.preventDefault(),$()),o&&H.key===o&&(H.preventDefault(),_())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[a,o,$,_]),S.jsx(b0e,{children:S.jsxs("div",{className:`${r??c.containerBg} ${c.text} ${n?"animate-slide-down opacity-0":""}`,style:{width:"100vw",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[S.jsx("div",{style:{flex:1,position:"relative"},children:S.jsx(m0e,{mode:"popLayout",children:S.jsx(J4.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:S.jsx(Y4.Provider,{value:{setCanProgress:P,autoAdvance:Q,setSlideData:O},children:e[y]})},y)})}),S.jsxs("div",{style:{padding:"1.5rem 1.5rem 3rem",display:"grid",gridTemplateColumns:"1fr auto 1fr",alignItems:"center"},children:[S.jsx("div",{style:{justifySelf:"end",marginRight:"1rem"},children:S.jsx("button",{onClick:_,className:d,tabIndex:-1,onKeyDown:B=>{(B.key===" "||B.key==="Enter")&&B.preventDefault()},style:{visibility:y>0?"visible":"hidden"},children:"←"})}),S.jsx("div",{style:{display:"flex",gap:6},children:e.map((B,H)=>S.jsx("div",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:H===y?c.dotActive:c.dotInactive,transition:"background-color 0.2s"}},H))}),S.jsx("div",{style:{justifySelf:"start",marginLeft:"1rem"},children:S.jsx(J4.button,{onClick:$,tabIndex:-1,onKeyDown:B=>{(B.key===" "||B.key==="Enter")&&B.preventDefault()},animate:{scale:A?1.2:1},transition:{type:"spring",stiffness:500,damping:15},className:(I?d:f)+(y===e.length-1?" px-8":""),children:y===e.length-1?s:"→"})})]})]})})};Zs("RandomDotKinematogram","rdk");const $r={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"};$s("RandomDotKinematogram",(i,e,t,s)=>{var b;const r={...$r,...i},n=t.respond(r,s),{rt:a,response:o}=n.value,l=((b=r.preTrialMessage)==null?void 0:b.duration)??0,u=r.fixationTime??$r.fixationTime,h=r.duration??$r.duration,d=(r.responseEndsTrial??$r.responseEndsTrial)&&a!=null?a:h,f=Array.isArray(r.correctResponse)?r.correctResponse.map(x=>x.toLowerCase()):r.correctResponse?[r.correctResponse.toLowerCase()]:null,y=o&&f?f.includes(o.toLowerCase()):null;let v=l+u+d;const m={...r,rt:a,response:o,correct:y,framesDisplayed:0,measuredRefreshRate:null,feedbackShown:null,feedbackDuration:null},g=r.feedback;if(g){let x=null;a===null&&g.onTimeout?x=g.onTimeout:y===!1&&g.onIncorrect?x=g.onIncorrect:y===!0&&g.onCorrect&&(x=g.onCorrect),x&&(m.feedbackShown=x.content,m.feedbackDuration=x.duration,v+=x.duration)}return{responseData:m,participantState:n.participantState,duration:v}},{respond:(i,e)=>{const t=px({driftRate:{type:"normal",mean:.005*(i.coherence??$r.coherence),sd:.0012},boundaries:.75,startingPoint:0,noiseLevel:.02,sensoryDelay:{type:"uniform",min:150,max:250},motorDelay:{type:"uniform",min:130,max:210},timeLimit:i.duration??$r.duration,stimOffset:i.stimulusDuration??i.duration??$r.duration,postStimStrategy:{type:"continue"}}),s=fx(t.choice,i.validKeys,i.correctResponse);return{value:{rt:s?t.rt:null,response:s},participantState:e}}});const P1e=10,tT=.1,I1e=(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 sc(a)},Ba=(i,e)=>i+Math.random()*(e-i),R1e=(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=Ba(-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,I=v*f/g+m*y/b,L=v*v/g+m*m/b-1,A=I*I-x*L;if(A>=0){const k=(I+Math.sqrt(A))/x;if(k>0&&Number.isFinite(k))return[l.x-f*k,l.y-y*k]}}}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[Ba(s-n,s+n),Ba(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,I=f!==0?(m-l.y)/f:-1/0,L=f!==0?(g-l.y)/f:-1/0,A=Math.max(Math.min(b,x),Math.min(I,L)),k=Math.min(Math.max(b,x),Math.max(I,L));return k>0&&A<=k&&Number.isFinite(k)?[l.x+d*k,l.y+f*k]: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)}}},A1e=(i,e,t)=>{const[s,r]=t.getRandomPosition(),n=i==="randomDirection"?Ba(-Math.PI,Math.PI):0;return{x:s,y:r,randomDirX:n?Math.cos(n):0,randomDirY:n?-Math.sin(n):0,lifeCount:Ba(0,e>0?e:0),assignedMovement:i}},L1e=(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=Ba(-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=Ba(-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},sT=V.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:I,apertureCenterY:L,reinsertMode:A,noiseMovement:k,reassignEveryMs:P,showFixation:O,fixationWidth:D,fixationHeight:$,fixationColor:Q,fixationThickness:_,showBorder:B,borderWidth:H,borderColor:U,active:G=!0,initialRefreshRate:j,style:ae,className:X}={...$r,...i},ue=V.useRef(null),ie=V.useRef(),se=V.useRef(),fe=V.useRef(),de=V.useRef(0),te=V.useRef(0),pe=V.useRef([]),Ne=V.useRef(null),gt=V.useRef(!1),$t=I??t/2,Us=L??s/2,Vt=V.useMemo(()=>R1e(g,b,x,$t,Us),[g,b,x,$t,Us]),ms=V.useMemo(()=>{const Le=(90-a)*Math.PI/180;return[Math.cos(Le),-Math.sin(Le)]},[a]),ws=V.useRef([]),Ze=V.useRef(0);V.useEffect(()=>{const Le=Math.floor(r*o),Ye=Math.floor(r*l);ws.current=Array.from({length:n},()=>Array.from({length:r},(we,Ht)=>{let Ut;return Ht<Le?Ut="coherent":Ht<Le+Ye?Ut="opposite":Ut=k,A1e(Ut,h,Vt)}))},[]),V.useEffect(()=>{typeof j=="number"&&j>=20&&j<=300&&(Ne.current=1e3/j,gt.current=!0)},[j]),V.useImperativeHandle(e,()=>({getStats:()=>({framesDisplayed:te.current,measuredRefreshRate:Ne.current?Math.round(1e3/Ne.current):null})}));const mt=V.useCallback((Le,Ye)=>{Ye.forEach(we=>{const Ht=v&&we.assignedMovement==="coherent"?v:y;if(Le.fillStyle=Ht,f){const Ut=d*2.5;Le.font=`${Ut}px monospace`,Le.textAlign="center",Le.textBaseline="middle",Le.fillText(f,we.x,we.y)}else Le.beginPath(),Le.arc(we.x,we.y,d,0,Math.PI*2),Le.fill()})},[y,v,d,f]),gs=V.useCallback((Le,Ye,we)=>{O&&(Le.fillStyle=Q,Le.fillRect(Ye-D,we-_/2,D*2,_),Le.fillRect(Ye-_/2,we-$,_,$*2))},[O,Q,_,D,$]),es=V.useCallback(Le=>{B&&Vt.drawBorder(Le,U,H)},[B,U,H,Vt]),Ct=V.useCallback(Le=>{const Ye=ue.current,we=Ye==null?void 0:Ye.getContext("2d");if(!Ye||!we)return;se.current===void 0&&(se.current=Le),fe.current===void 0&&(fe.current=Le);const Ht=Le-fe.current;if(fe.current=Le,te.current++,Ht>0&&Ht<500){if(gt.current)Ne.current=tT*Ht+(1-tT)*Ne.current;else if(pe.current.push(Ht),pe.current.length>=P1e){const ts=[...pe.current].sort((Ss,zs)=>Ss-zs),xs=Math.floor(ts.length/2);Ne.current=ts.length%2?ts[xs]:(ts[xs-1]+ts[xs])/2,gt.current=!0}}const Ut=Le-(se.current??Le),ns=Math.min(Ut,100),ii=c&&c>0?1e3/c:0,js=!c||c<=0||ns>=ii;if(we.clearRect(0,0,Ye.width,Ye.height),we.save(),Vt.clip(we),we.fillStyle=m,we.fillRect(0,0,Ye.width,Ye.height),we.restore(),!G)gs(we,Vt.centerX,Vt.centerY);else{if(js){const xs=u*ns/1e3;let Ss=!1;if(P!==void 0)if(P===0)Ss=!0;else{de.current+=ns;const J=gt.current&&Ne.current?Ne.current*.5:0;Ss=de.current+J>=P,Ss&&(de.current%=P)}const zs=Ss?I1e(r,o,l,k):null,Ws=ws.current[Ze.current].map((J,oe)=>L1e(J,xs,ns,h,Vt,A,d,ms,zs==null?void 0:zs[oe]));ws.current[Ze.current]=Ws,Ze.current=(Ze.current+1)%n,se.current=Le}const ts=ws.current[Ze.current];we.save(),Vt.clip(we),mt(we,ts),we.restore(),we.save(),we.beginPath(),gs(we,Vt.centerX,Vt.centerY),es(we),we.restore()}ie.current=requestAnimationFrame(Ct)},[G,m,k,o,l,r,u,h,Vt,A,n,d,ms,c,mt,gs,es,P]);return V.useEffect(()=>(ie.current=requestAnimationFrame(Ct),()=>{ie.current&&cancelAnimationFrame(ie.current)}),[Ct]),V.useEffect(()=>{const Le=ue.current;if(!Le)return;const Ye=window.devicePixelRatio||1;Le.width=t*Ye,Le.height=s*Ye,Le.style.width=`${t}px`,Le.style.height=`${s}px`;const we=Le.getContext("2d");we&&we.scale(Ye,Ye)},[t,s]),S.jsx("canvas",{ref:ue,style:{display:"block",...ae},className:X})}),iT=i=>{var Ye;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:I,dotColor:L,backgroundColor:A,apertureShape:k,apertureWidth:P,apertureHeight:O,reinsertMode:D,noiseMovement:$,showFixation:Q,fixationTime:_,fixationWidth:B,fixationHeight:H,fixationColor:U,fixationThickness:G,showBorder:j,borderWidth:ae,borderColor:X}={...$r,...i},ue=V.useRef(i);ue.current=i;const ie=((Ye=i.preTrialMessage)==null?void 0:Ye.duration)??0,se=V.useRef(null),fe=V.useRef(performance.now()),de=V.useRef(!1),te=V.useRef(null),pe=V.useRef(null),[Ne,gt]=V.useState(!i.preTrialMessage),[$t,Us]=V.useState(null),[Vt,ms]=V.useState(_<=0),[ws,Ze]=V.useState(!0),[mt,gs]=V.useState(null),es=e==null?void 0:e._reactiveScreenRefreshRate;V.useEffect(()=>{if(!i.preTrialMessage)return;const we=setTimeout(()=>gt(!0),i.preTrialMessage.duration);return()=>clearTimeout(we)},[]);const Ct=V.useCallback((we,Ht)=>{var oe;if(de.current)return;de.current=!0;const{next:Ut,data:ns,store:ii,updateStore:js,...ts}=ue.current,xs=(oe=se.current)==null?void 0:oe.getStats(),Ss=Array.isArray(ts.correctResponse)?ts.correctResponse.map(re=>re.toLowerCase()):ts.correctResponse?[ts.correctResponse.toLowerCase()]:null,zs=we&&Ss?Ss.includes(we):null,Ji={...$r,...ts,rt:Ht,response:we,correct:zs,framesDisplayed:(xs==null?void 0:xs.framesDisplayed)??0,measuredRefreshRate:(xs==null?void 0:xs.measuredRefreshRate)??null,feedbackShown:null,feedbackDuration:null},Ws=ts.feedback;let J=null;Ws&&(Ht===null&&Ws.onTimeout?J=Ws.onTimeout:zs===!1&&Ws.onIncorrect?J=Ws.onIncorrect:zs===!0&&Ws.onCorrect&&(J=Ws.onCorrect)),J?(Ji.feedbackShown=J.content,Ji.feedbackDuration=J.duration,gs(J),setTimeout(()=>Ut(Ji),J.duration)):Ut(Ji)},[]);V.useEffect(()=>{if(_<=0)return;const we=setTimeout(()=>ms(!0),ie+_);return()=>clearTimeout(we)},[_,ie]),V.useEffect(()=>{const we=t??c;if(we<=0)return;const Ht=setTimeout(()=>Ze(!1),ie+_+we);return()=>clearTimeout(Ht)},[ie,_,t,c]),V.useEffect(()=>{if(c<=0)return;const we=setTimeout(()=>{Ct(te.current,pe.current)},ie+_+c);return()=>clearTimeout(we)},[ie,_,c,Ct]),V.useEffect(()=>{const we=Ht=>{if(de.current||te.current||!Ne)return;const Ut=Ht.key.toLowerCase(),ns=h.length>0?h.map(ii=>ii.toLowerCase()):null;if(!ns||ns.includes(Ut)){const ii=performance.now()-fe.current;te.current=Ut,pe.current=ii,Us(Ut),d&&Ct(Ut,ii)}};return window.addEventListener("keydown",we),()=>window.removeEventListener("keydown",we)},[h,d,Ct,Ne]);const Le=we=>S.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:S.jsx("span",{style:{color:"white",fontSize:"2rem",fontWeight:"bold",textAlign:"center",padding:"0 2rem"},children:we})});return S.jsx("div",{style:{width:"100vw",height:"100vh",overflow:"hidden",margin:0,padding:0,backgroundColor:A},children:Ne?mt?Le(mt.content):S.jsxs(S.Fragment,{children:[S.jsx(sT,{ref:se,width:window.innerWidth,height:window.innerHeight,active:Vt&&ws,initialRefreshRate:es,dotCount:f,dotSetCount:y,direction:v,coherence:m,opposite:g,speed:b,dotLifetime:x,updateRate:s,dotRadius:I,dotCharacter:r,dotColor:L,coherentDotColor:n,backgroundColor:A,apertureShape:k,apertureWidth:P,apertureHeight:O,apertureCenterX:a,apertureCenterY:o,reinsertMode:D,noiseMovement:$,reassignEveryMs:l,showFixation:Q,fixationWidth:B,fixationHeight:H,fixationColor:U,fixationThickness:G,showBorder:j,borderWidth:ae,borderColor:X}),u&&!ws&&!$t&&S.jsx("div",{style:{position:"absolute",top:"60%",width:"100%",textAlign:"center",color:"white",fontSize:"1.25rem"},children:u})]}):Le(i.preTrialMessage.content)})},_1e={Text:dc,ProlificEnding:gx,EnterFullscreen:TS,ExitFullscreen:PS,Quest:pE,Upload:wS,MicrophoneCheck:vx,PlainInput:mx,RequestFilePermission:HS,CanvasBlock:QS,CheckDevice:US,StoreUI:Sfe,Tutorial:eT,RandomDotKinematogram:iT,VoiceRecording:ux},D1e={voicerecorder:Jne};en("dev",!1,"boolean","Enable the developer inspector panel");function x0(i){return typeof i=="object"&&i!==null&&typeof i.type=="string"}function k1e({timeline:i,config:e={showProgressBar:!1},components:t={},questions:s={},hybridParticipant:r,disableDev:n=!1,simulationConfig:a}){M2(i);const o=wfe(),l=V.useMemo(()=>rc(i),[i]),u=V.useRef((()=>{const j={},ae=new URLSearchParams(window.location.search);for(const[se,fe]of ae.entries())j[se]=fe;const X=Nl.getRegistry()||[],ue={};for(const[se,fe]of Object.entries(j))ue[se]={value:fe,registered:!1,defaultValue:void 0,type:void 0,description:void 0};for(const se of X)ue[se.name]={value:se.value!==void 0?se.value:j[se.name],registered:!0,defaultValue:se.defaultValue,type:se.type,description:se.description};return[{index:-1,trialNumber:-1,start:As(),end:As(),duration:0,type:"",name:"",responseData:{userAgent:navigator.userAgent,params:ue}}]})()),[h,c]=V.useState(0),d=V.useRef(As()),f=V.useRef({_uploadId:AE()}),[y,v]=V.useState(()=>Dn(l,0,()=>f.current,()=>u.current,j=>{f.current={...f.current,...j}})),m=!o&&en("hybridSimulation",!1,"boolean")?"hybrid":"none",g=V.useRef(r||{}),b=V.useRef(-1),x={..._1e,...t},I={...D1e,...s},L=V.useMemo(()=>{const j=l.instructions.length;return j>0?y/j:0},[y,l.instructions]);V.useEffect(()=>{window.scrollTo(0,0)},[y]);function A(j){f.current={...f.current,...j}}function k(j,ae,X){const ue=As(),ie=l.instructions[y],se=ae!==void 0?ae:d.current,fe=X!==void 0?X:ue;if((ie==null?void 0:ie.type)==="ExecuteContent"){const te=ie.content;if(x0(te)){let pe={index:y,trialNumber:h+1,start:se,end:fe,duration:fe-se,type:te.type,name:te.name??"",...te.csv!==void 0?{csv:te.csv}:{},responseData:j};pe=nc(pe,te,u.current,f.current),u.current=[...u.current,pe],c(Ne=>Ne+1)}else console.log("ExecuteContent finished, but content wasn't standard component format:",te)}const de=Dn(l,y+1,()=>f.current,()=>u.current,te=>A(te));de<l.instructions.length&&(d.current=As()),v(de)}const P=V.useCallback(j=>{let ae=0;const X=As(),ue=2e4;let ie,se=X;const fe=1e3,de=()=>{const gt=As()-X;return gt>0?Math.round(ae*1e3/gt):null},te=()=>{ie&&cancelAnimationFrame(ie)},pe=Ne=>{ae++;const gt=Ne-X;Ne-se>=fe&&(j(de()),se=Ne),gt<ue?ie=requestAnimationFrame(pe):(te(),j(de()))};return ie=requestAnimationFrame(pe),te},[]),O=({children:j,collectRefreshRate:ae})=>{const X=V.useRef(null),ue=V.useRef(null);V.useEffect(()=>{if(X.current=As(),ae)return P(fe=>{ue.current=fe,A({_reactiveScreenRefreshRate:fe})})},[]);const ie=V.Children.map(j,se=>{if(V.isValidElement(se)){const fe=(de,te,pe)=>{const Ne=As(),gt=te!==void 0?te:X.current;k(de,gt??void 0,(pe!==void 0?pe:Ne)??void 0)};return V.cloneElement(se,{...se.props,next:fe})}return se});return S.jsx(S.Fragment,{children:ie})},D=l.instructions[y],$=V.useMemo(()=>{if(m==="none"||(D==null?void 0:D.type)!=="ExecuteContent")return!1;const j=D.content;return!x0(j)||j.simulate===!1?!1:!!j.simulate||!!j.simulators},[y,m,D]);V.useEffect(()=>{$&&b.current!==y&&(b.current=y,(async()=>{const j=D.content,{trialProps:ae,simulateFn:X,simulators:ue}=Sm(j,u.current,f.current),ie=await X(ae,{data:u.current,store:f.current},ue,g.current);g.current=ie.participantState,ie.storeUpdates&&A(ie.storeUpdates),k(ie.responseData)})())},[$,y]);let Q=null;if((D==null?void 0:D.type)==="ExecuteContent"&&!$){const j=D.content;if(x0(j)){const ae=x[j.type];if(ae){const X=typeof j.props=="function"?j.props(u.current,f.current):j.props||{};Q=S.jsx(O,{collectRefreshRate:j.collectRefreshRate,children:S.jsx(ae,{next:k,updateStore:A,store:f.current,data:u.current,name:j.name,...j.type==="Quest"?{customQuestions:I}:{},...X})},y)}else console.error(`No component found for type: ${j.type}`),Q=S.jsxs("div",{children:['Error: Component type "',j.type,'" not found.']})}else console.warn("ExecuteContent instruction does not contain standard component data:",j),Q=S.jsx("div",{children:"Non-component content encountered."})}else y>=l.instructions.length&&(Q=S.jsx(S.Fragment,{}));const _=e.theme??"light",B=xi(_),H=!n&&en("dev",!1,"boolean"),U=V.useRef(null),G=(D==null?void 0:D.type)==="ExecuteContent"?D.content:null;return S.jsx(Tm.Provider,{value:_,children:S.jsx(Pm.Provider,{value:f.current.audioInputId,children:S.jsxs("div",{className:"w-full h-full",children:[S.jsx("div",{className:` ${e.showProgressBar?"":"hidden "} px-4 mt-4 sm:mt-12 max-w-2xl mx-auto`,children:S.jsx("div",{className:`flex-1 h-6 ${B.progressBg} rounded-full overflow-hidden`,children:S.jsx("div",{className:`h-full ${B.progressBg} rounded-full duration-300 ${L>0?" border-black border-2":""}`,style:{width:`${L*100}%`,backgroundImage:`repeating-linear-gradient(
|
|
10253
|
+
`),()=>{var k;(k=o.current)==null||k.removeAttribute("data-motion-pop-id"),A.contains(L)&&A.removeChild(L)}},[e]),S.jsx(c0e,{isPresent:e,childRef:o,sizeRef:l,pop:n,children:n===!1?i:p.cloneElement(i,{ref:c})})}const p0e=({children:i,initial:e,isPresent:t,onExitComplete:s,custom:r,presenceAffectsLayout:n,mode:a,anchorX:o,anchorY:l,root:u})=>{const h=av(f0e),c=V.useId();let d=!0,f=V.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}),V.useMemo(()=>{h.forEach((y,v)=>h.set(v,!1))},[t]),p.useEffect(()=>{!t&&!h.size&&s&&s()},[t]),i=S.jsx(d0e,{pop:a==="popLayout",isPresent:t,anchorX:o,anchorY:l,root:u,children:i}),S.jsx(Ld.Provider,{value:f,children:i})};function f0e(){return new Map}function E4(i=!0){const e=V.useContext(Ld);if(e===null)return[!0,null];const{isPresent:t,onExitComplete:s,register:r}=e,n=V.useId();V.useEffect(()=>{if(i)return r(n)},[i]);const a=V.useCallback(()=>i&&s&&s(n),[n,s,i]);return!t&&s?[!1,a]:[!0]}const Xd=i=>i.key||"";function V4(i){const e=[];return V.Children.forEach(i,t=>{V.isValidElement(t)&&e.push(t)}),e}const m0e=({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]=E4(a),d=V.useMemo(()=>V4(i),[i]),f=a&&!h?[]:d.map(Xd),y=V.useRef(!0),v=V.useRef(d),m=av(()=>new Map),g=V.useRef(new Set),[b,x]=V.useState(d),[I,L]=V.useState(d);ov(()=>{y.current=!1,v.current=d;for(let P=0;P<I.length;P++){const O=Xd(I[P]);f.includes(O)?(m.delete(O),g.current.delete(O)):m.get(O)!==!0&&m.set(O,!1)}},[I,f.length,f.join("-")]);const A=[];if(d!==b){let P=[...d];for(let O=0;O<I.length;O++){const D=I[O],$=Xd(D);f.includes($)||(P.splice(O,0,D),A.push(D))}return n==="wait"&&A.length&&(P=A),L(V4(P)),x(d),null}process.env.NODE_ENV!=="production"&&n==="wait"&&I.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:k}=V.useContext(Eu);return S.jsx(S.Fragment,{children:I.map(P=>{const O=Xd(P),D=a&&!h?!1:d===I||f.includes(O),$=()=>{if(g.current.has(O))return;if(m.has(O))g.current.add(O),m.set(O,!0);else return;let Q=!0;m.forEach(_=>{_||(Q=!1)}),Q&&(k==null||k(),L(v.current),a&&(c==null||c()),s&&s())};return S.jsx(p0e,{isPresent:D,initial:!y.current||t?void 0:!1,custom:e,presenceAffectsLayout:r,mode:n,root:u,onExitComplete:D?void 0:$,anchorX:o,anchorY:l,children:P},O)})})},g0e=V.createContext(null);function v0e(){const i=V.useRef(!1);return ov(()=>(i.current=!0,()=>{i.current=!1}),[]),i}function y0e(){const i=v0e(),[e,t]=V.useState(0),s=V.useCallback(()=>{i.current&&t(e+1)},[e]);return[V.useCallback(()=>Pt.postRender(s),[s]),e]}const S4=i=>i===!0,C0e=i=>S4(i===!0)||i==="id",b0e=({children:i,id:e,inherit:t=!0})=>{const s=V.useContext(Eu),r=V.useContext(g0e),[n,a]=y0e(),o=V.useRef(null),l=s.id||r;o.current===null&&(C0e(t)&&l&&(e=e?l+"-"+e:l),o.current={id:e,group:S4(t)&&s.group||b4()});const u=V.useMemo(()=>({...o.current,forceRender:n}),[a]);return S.jsx(Eu.Provider,{value:u,children:i})},T4=V.createContext({strict:!1}),P4={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 I4=!1;function w0e(){if(I4)return;const i={};for(const e in P4)i[e]={isEnabled:t=>P4[e].some(s=>!!t[s])};b7(i),I4=!0}function R4(){return w0e(),Yge()}function x0e(i){const e=R4();for(const t in i)e[t]={...e[t],...i[t]};b7(e)}const E0e=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 ep(i){return i.startsWith("while")||i.startsWith("drag")&&i!=="draggable"||i.startsWith("layout")||i.startsWith("onTap")||i.startsWith("onPan")||i.startsWith("onLayout")||E0e.has(i)}let A4=i=>!ep(i);function V0e(i){typeof i=="function"&&(A4=e=>e.startsWith("on")?!ep(e):i(e))}try{V0e(require("@emotion/is-prop-valid").default)}catch{}function S0e(i,e,t){const s={};for(const r in i)r==="values"&&typeof i.values=="object"||Ns(i[r])||(A4(r)||t===!0&&ep(r)||!e&&!ep(r)||i.draggable&&r.startsWith("onDrag"))&&(s[r]=i[r]);return s}const tp=V.createContext({});function T0e(i,e){if(zd(i)){const{initial:t,animate:s}=i;return{initial:t===!1||Lu(t)?t:void 0,animate:Lu(s)?s:void 0}}return i.inherit!==!1?e:{}}function P0e(i){const{initial:e,animate:t}=T0e(i,V.useContext(tp));return V.useMemo(()=>({initial:e,animate:t}),[L4(e),L4(t)])}function L4(i){return Array.isArray(i)?i.join(" "):i}const p0=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function _4(i,e,t){for(const s in e)!Ns(e[s])&&!k7(s,t)&&(i[s]=e[s])}function I0e({transformTemplate:i},e){return V.useMemo(()=>{const t=p0();return n0(t,e,i),Object.assign({},t.vars,t.style)},[e])}function R0e(i,e){const t=i.style||{},s={};return _4(s,t,i),Object.assign(s,I0e(i,e)),s}function A0e(i,e){const t={},s=R0e(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 D4=()=>({...p0(),attrs:{}});function L0e(i,e,t,s){const r=V.useMemo(()=>{const n=D4();return O7(n,e,N7(s),i.transformTemplate,i.style),{...n.attrs,style:{...n.style}}},[e]);if(i.style){const n={};_4(n,i.style,i),r.style={...n,...r.style}}return r}const _0e=["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 f0(i){return typeof i!="string"||i.includes("-")?!1:!!(_0e.indexOf(i)>-1||/[A-Z]/u.test(i))}function D0e(i,e,t,{latestValues:s},r,n=!1,a){const l=(a??f0(i)?L0e:A0e)(e,s,r,i),u=S0e(e,typeof i=="string",n),h=i!==V.Fragment?{...u,...l,ref:t}:{},{children:c}=e,d=V.useMemo(()=>Ns(c)?c.get():c,[c]);return V.createElement(i,{...h,children:d})}function k0e({scrapeMotionValuesFromProps:i,createRenderState:e},t,s,r){return{latestValues:O0e(t,s,r,i),renderState:e()}}function O0e(i,e,t,s){const r={},n=s(i,{});for(const d in n)r[d]=Jd(n[d]);let{initial:a,animate:o}=i;const l=zd(i),u=v7(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"&&!jd(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 I=h?x.length-1:0;x=x[I]}x!==null&&(r[b]=x)}for(const b in v)r[b]=v[b]}}}return r}const k4=i=>(e,t)=>{const s=V.useContext(tp),r=V.useContext(Ld),n=()=>k0e(i,e,s,r);return t?n():av(n)},M0e=k4({scrapeMotionValuesFromProps:o0,createRenderState:p0}),N0e=k4({scrapeMotionValuesFromProps:F7,createRenderState:D4}),F0e=Symbol.for("motionComponentSymbol");function q0e(i,e,t){const s=V.useRef(t);V.useInsertionEffect(()=>{s.current=t});const r=V.useRef(null);return V.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 O4=V.createContext({});function Ko(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"current")}function B0e(i,e,t,s,r,n){var x,I;const{visualElement:a}=V.useContext(tp),o=V.useContext(T4),l=V.useContext(Ld),u=V.useContext(d0),h=u.reducedMotion,c=u.skipAnimations,d=V.useRef(null),f=V.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=V.useContext(O4);y&&!y.projection&&r&&(y.type==="html"||y.type==="svg")&&$0e(d.current,t,r,v);const m=V.useRef(!1);V.useInsertionEffect(()=>{y&&m.current&&y.update(t,l)});const g=t[Z3],b=V.useRef(!!g&&typeof window<"u"&&!((x=window.MotionHandoffIsComplete)!=null&&x.call(window,g))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,g)));return ov(()=>{f.current=!0,y&&(m.current=!0,window.MotionIsMounted=!0,y.updateFeatures(),y.scheduleRenderMicrotask(),b.current&&y.animationState&&y.animationState.animateChanges())}),V.useEffect(()=>{y&&(!b.current&&y.animationState&&y.animationState.animateChanges(),b.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,g)}),b.current=!1),y.enteringChildren=void 0)}),y}function $0e(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:M4(i.parent)),i.projection.setOptions({layoutId:r,layout:n,alwaysMeasureLayout:!!a||o&&Ko(o),visualElement:i,animationType:typeof n=="string"?n:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u,layoutAnchor:h})}function M4(i){if(i)return i.options.allowProjection!==!1?i.projection:M4(i.parent)}function m0(i,{forwardMotionProps:e=!1,type:t}={},s,r){s&&x0e(s);const n=t?t==="svg":f0(i),a=n?N0e:M0e;function o(u,h){let c;const d={...V.useContext(d0),...u,layoutId:H0e(u)},{isStatic:f}=d,y=P0e(u),v=a(u,f);if(!f&&typeof window<"u"){Q0e(d,s);const m=U0e(d);c=m.MeasureLayout,y.visualElement=B0e(i,v,d,r,m.ProjectionNode,n)}return S.jsxs(tp.Provider,{value:y,children:[c&&y.visualElement?S.jsx(c,{visualElement:y.visualElement,...d}):null,D0e(i,u,q0e(v,y.visualElement,h),v,f,e,n)]})}o.displayName=`motion.${typeof i=="string"?i:`create(${i.displayName??i.name??""})`}`;const l=V.forwardRef(o);return l[F0e]=i,l}function H0e({layoutId:i}){const e=V.useContext(Eu).id;return e&&i!==void 0?e+"-"+i:i}function Q0e(i,e){const t=V.useContext(T4).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?qo(!1,s,"lazy-strict-mode"):pn(!1,s,"lazy-strict-mode")}}function U0e(i){const e=R4(),{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 j0e(i,e){if(typeof Proxy>"u")return m0;const t=new Map,s=(n,a)=>m0(n,a,i,e),r=(n,a)=>(process.env.NODE_ENV!=="production"&&cv(!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,m0(a,void 0,i,e)),t.get(a))})}const z0e=(i,e)=>e.isSVG??f0(i)?new mve(e):new uve(e,{allowProjection:i!==V.Fragment});class W0e extends sa{constructor(e){super(e),e.animationState||(e.animationState=bve(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();jd(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 G0e=0;class K0e extends sa{constructor(){super(...arguments),this.id=G0e++,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=Na(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 Z0e={animation:{Feature:W0e},exit:{Feature:K0e}};function Ou(i){return{point:{x:i.pageX,y:i.pageY}}}const J0e=i=>e=>Zv(e)&&i(e,Ou(e));function Mu(i,e,t,s){return ku(i,e,J0e(t),s)}const N4=({current:i})=>i?i.ownerDocument.defaultView:null,F4=(i,e)=>Math.abs(i-e);function Y0e(i,e){const t=F4(i.x,e.x),s=F4(i.y,e.y);return Math.sqrt(t**2+s**2)}const q4=new Set(["auto","scroll"]);class B4{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=sp(this.lastRawMoveEventInfo,this.transformPagePoint));const f=g0(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,v=Y0e(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!y&&!v)return;const{point:m}=f,{timestamp:g}=Ms;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=sp(y,this.transformPagePoint),Pt.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=g0(f.type==="pointercancel"?this.lastMoveEventInfo:sp(y,this.transformPagePoint),this.history);this.startEvent&&v&&v(f,b),m&&m(f,b)},!Zv(e))return;this.dragSnapToOrigin=n,this.handlers=t,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=r||window;const l=Ou(e),u=sp(l,this.transformPagePoint),{point:h}=u,{timestamp:c}=Ms;this.history=[{...h,timestamp:c}];const{onSessionStart:d}=t;d&&d(e,g0(u,this.history)),this.removeListeners=Vu(Mu(this.contextWindow,"pointermove",this.handlePointerMove),Mu(this.contextWindow,"pointerup",this.handlePointerUp),Mu(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){const s=getComputedStyle(t);(q4.has(s.overflowX)||q4.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),Pt.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Yn(this.updatePoint)}}function sp(i,e){return e?{point:e(i.point)}:i}function $4(i,e){return{x:i.x-e.x,y:i.y-e.y}}function g0({point:i},e){return{point:i,delta:$4(i,H4(e)),offset:$4(i,X0e(e)),velocity:e1e(e,.1)}}function X0e(i){return i[0]}function H4(i){return i[i.length-1]}function e1e(i,e){if(i.length<2)return{x:0,y:0};let t=i.length-1,s=null;const r=H4(i);for(;t>=0&&(s=i[t],!(r.timestamp-s.timestamp>gi(e)));)t--;if(!s)return{x:0,y:0};s===i[0]&&i.length>2&&r.timestamp-s.timestamp>gi(e)*2&&(s=i[1]);const n=Ki(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 t1e(i,{min:e,max:t},s){return e!==void 0&&i<e?i=s?Bt(e,i,s.min):Math.max(i,e):t!==void 0&&i>t&&(i=s?Bt(t,i,s.max):Math.min(i,t)),i}function Q4(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 s1e(i,{top:e,left:t,bottom:s,right:r}){return{x:Q4(i.x,t,r),y:Q4(i.y,e,s)}}function U4(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 i1e(i,e){return{x:U4(i.x,e.x),y:U4(i.y,e.y)}}function r1e(i,e){let t=.5;const s=ti(i),r=ti(e);return r>s?t=Su(e.min,e.max-s,i.min):s>r&&(t=Su(i.min,i.max-r,e.min)),Nr(0,1,t)}function n1e(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 v0=.35;function a1e(i=v0){return i===!1?i=0:i===!0&&(i=v0),{x:j4(i,"left","right"),y:j4(i,"top","bottom")}}function j4(i,e,t){return{min:z4(i,e),max:z4(i,t)}}function z4(i,e){return typeof i=="number"?i:i[e]||0}const o1e=new WeakMap;class l1e{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=bs(),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(Ou(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=Ige(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),Br(g=>{let b=this.getAxisMotionValue(g).get()||0;if(Fr.test(b)){const{projection:x}=this.visualElement;if(x&&x.layout){const I=x.layout.layoutBox[g];I&&(b=ti(I)*(parseFloat(b)/100))}}this.originPoint[g]=b}),v&&Pt.update(()=>v(c,d),!1,!0),Qv(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=h1e(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&&Pt.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 B4(e,{onSessionStart:n,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:s,contextWindow:N4(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&&Pt.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||!ip(e,r,this.currentDirection))return;const n=this.getAxisMotionValue(e);let a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=t1e(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&&Ko(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=s1e(s.layoutBox,e):this.constraints=!1,this.elastic=a1e(t),r!==this.constraints&&!Ko(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&Br(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=n1e(s.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Ko(e))return!1;const s=e.current;pn(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=ive(s,r.root,this.visualElement.getTransformPagePoint());let a=i1e(r.layout.layoutBox,n);if(t){const o=t(eve(a));this.hasMutatedConstraints=!!o,o&&(a=x7(o))}return a}startAnimation(e){const{drag:t,dragMomentum:s,dragElastic:r,dragTransition:n,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},u=Br(h=>{if(!ip(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 Qv(this.visualElement,e),s.start(Bv(e,s,0,t,this.visualElement,!1))}stopAnimation(){Br(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){Br(t=>{const{drag:s}=this.getProps();if(!ip(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]-Bt(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:s}=this.visualElement;if(!Ko(t)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Br(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();r[a]=r1e({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(),Br(a=>{if(!ip(a,e,null))return;const o=this.getAxisMotionValue(a),{min:l,max:u}=this.constraints[a];o.set(Bt(l,u,r[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;o1e.set(this.visualElement,this);const e=this.visualElement.current,t=Mu(e,"pointerdown",u=>{const{drag:h,dragListener:c=!0}=this.getProps(),d=u.target,f=d!==e&&kge(d);h&&c&&!f&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();Ko(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=u1e(e,u.current,()=>this.scalePositionWithinConstraints())))},{projection:n}=this.visualElement,a=n.addEventListener("measure",r);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),Pt.read(r);const o=ku(window,"resize",()=>this.scalePositionWithinConstraints()),l=n.addEventListener("didUpdate",({delta:u,hasLayoutChanged:h})=>{this.isDragging&&h&&(Br(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=v0,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:s,dragPropagation:r,dragConstraints:n,dragElastic:a,dragMomentum:o}}}function W4(i){let e=!0;return()=>{if(e){e=!1;return}i()}}function u1e(i,e,t){const s=f7(i,W4(t)),r=f7(e,W4(t));return()=>{s(),r()}}function ip(i,e,t){return(e===!0||e===i)&&(t===null||t===i)}function h1e(i,e=10){let t=null;return Math.abs(i.y)>e?t="y":Math.abs(i.x)>e&&(t="x"),t}class c1e extends sa{constructor(e){super(e),this.removeGroupControls=Gi,this.removeListeners=Gi,this.controls=new l1e(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Gi}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 y0=i=>(e,t)=>{i&&Pt.update(()=>i(e,t),!1,!0)};class d1e extends sa{constructor(){super(...arguments),this.removePointerDownListener=Gi}onPointerDown(e){this.session=new B4(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:N4(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:y0(e),onStart:y0(t),onMove:y0(s),onEnd:(n,a)=>{delete this.session,r&&Pt.postRender(()=>r(n,a))}}}mount(){this.removePointerDownListener=Mu(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 C0=!1;class p1e extends V.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),C0&&n.root.didUpdate(),n.addEventListener("animationComplete",()=>{this.safeToRemove()}),n.setOptions({...n.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Yd.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}),C0=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==n?a.willUpdate():this.safeToRemove(),e.isPresent!==n&&(n?a.promote():a.relegate()||Pt.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(),Kv.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s}=this.props,{projection:r}=e;C0=!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 G4(i){const[e,t]=E4(),s=V.useContext(Eu);return S.jsx(p1e,{...i,layoutGroup:s,switchLayoutGroup:V.useContext(O4),isPresent:e,safeToRemove:t})}const f1e={pan:{Feature:d1e},drag:{Feature:c1e,ProjectionNode:w4,MeasureLayout:G4}};function K4(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&&Pt.postRender(()=>n(e,Ou(e)))}class m1e extends sa{mount(){const{current:e}=this.node;e&&(this.unmount=Age(e,(t,s)=>(K4(this.node,s,"Start"),r=>K4(this.node,r,"End"))))}unmount(){}}class g1e extends sa{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=Vu(ku(this.node.current,"focus",()=>this.onFocus()),ku(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Z4(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&&Pt.postRender(()=>n(e,Ou(e)))}class v1e extends sa{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:s}=this.node.props;this.unmount=Mge(e,(r,n)=>(Z4(this.node,n,"Start"),(a,{success:o})=>Z4(this.node,a,o?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:(s==null?void 0:s.tap)===!1})}unmount(){}}const b0=new WeakMap,w0=new WeakMap,y1e=i=>{const e=b0.get(i.target);e&&e(i)},C1e=i=>{i.forEach(y1e)};function b1e({root:i,...e}){const t=i||document;w0.has(t)||w0.set(t,{});const s=w0.get(t),r=JSON.stringify(e);return s[r]||(s[r]=new IntersectionObserver(C1e,{root:i,...e})),s[r]}function w1e(i,e,t){const s=b1e(e);return b0.set(i,t),s.observe(i),()=>{b0.delete(i),s.unobserve(i)}}const x1e={some:0,all:1};class E1e extends sa{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:x1e[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=w1e(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(V1e(e,t))&&this.startObserver()}unmount(){var e;(e=this.stopObserver)==null||e.call(this),this.hasEnteredView=!1,this.isInView=!1}}function V1e({viewport:i={}},{viewport:e={}}={}){return t=>i[t]!==e[t]}const S1e={...Z0e,...{inView:{Feature:E1e},tap:{Feature:v1e},focus:{Feature:g1e},hover:{Feature:m1e}},...f1e,...{layout:{ProjectionNode:w4,MeasureLayout:G4}}},J4=j0e(S1e,z0e);Zs("Tutorial",null),$s("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 Y4=V.createContext({setCanProgress:()=>{},autoAdvance:()=>{},setSlideData:()=>{}}),T1e=({locked:i=!1}={})=>{const e=V.useContext(Y4),t=V.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)}}},X4="px-4 py-3 border-2 font-bold text-lg rounded-xl transition-all duration-100 outline-none focus:outline-none focus:ring-0",eT=({next:i,slides:e,fadeDuration:t=.3,finishText:s="Start",containerClass:r,animate:n=!1,nextKey:a="ArrowRight",backKey:o="ArrowLeft",theme:l})=>{const u=qi(),c=xi(l??u),d=`${X4} ${c.buttonBg} ${c.buttonText} ${c.buttonBorder} ${c.buttonShadow} cursor-pointer hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none`,f=`${X4} ${c.buttonDisabledBg} ${c.buttonDisabledText} ${c.buttonDisabledBorder} ${c.buttonDisabledShadow} cursor-default`,[y,v]=V.useState(0),[m,g]=V.useState({}),b=V.useRef(),x=V.useRef({}),I=m[y]!==!1,L=V.useRef(I),[A,k]=V.useState(!1);V.useEffect(()=>{if(I&&!L.current){k(!0);const B=setTimeout(()=>k(!1),300);return()=>clearTimeout(B)}L.current=I},[I]);const P=V.useCallback(B=>{g(H=>({...H,[y]:B}))},[y]),O=V.useCallback(B=>{x.current[y]={...x.current[y],...B}},[y]),D=V.useCallback(()=>{y===e.length-1?i({slides:x.current}):v(B=>B+1)},[y,e.length,i]),$=V.useCallback(()=>{I&&D()},[I,D]),Q=V.useCallback((B=0)=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>D(),B)},[D]);V.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const _=V.useCallback(()=>{y>0&&v(B=>B-1)},[y]);return V.useEffect(()=>{if(a===!1&&o===!1)return;const B=H=>{a&&H.key===a&&(H.preventDefault(),$()),o&&H.key===o&&(H.preventDefault(),_())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[a,o,$,_]),S.jsx(b0e,{children:S.jsxs("div",{className:`${r??c.containerBg} ${c.text} ${n?"animate-slide-down opacity-0":""}`,style:{width:"100vw",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[S.jsx("div",{style:{flex:1,position:"relative"},children:S.jsx(m0e,{mode:"popLayout",children:S.jsx(J4.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:S.jsx(Y4.Provider,{value:{setCanProgress:P,autoAdvance:Q,setSlideData:O},children:e[y]})},y)})}),S.jsxs("div",{style:{padding:"1.5rem 1.5rem 3rem",display:"grid",gridTemplateColumns:"1fr auto 1fr",alignItems:"center"},children:[S.jsx("div",{style:{justifySelf:"end",marginRight:"1rem"},children:S.jsx("button",{onClick:_,className:d,tabIndex:-1,onKeyDown:B=>{(B.key===" "||B.key==="Enter")&&B.preventDefault()},style:{visibility:y>0?"visible":"hidden"},children:"←"})}),S.jsx("div",{style:{display:"flex",gap:6},children:e.map((B,H)=>S.jsx("div",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:H===y?c.dotActive:c.dotInactive,transition:"background-color 0.2s"}},H))}),S.jsx("div",{style:{justifySelf:"start",marginLeft:"1rem"},children:S.jsx(J4.button,{onClick:$,tabIndex:-1,onKeyDown:B=>{(B.key===" "||B.key==="Enter")&&B.preventDefault()},animate:{scale:A?1.2:1},transition:{type:"spring",stiffness:500,damping:15},className:(I?d:f)+(y===e.length-1?" px-8":""),children:y===e.length-1?s:"→"})})]})]})})};Zs("RandomDotKinematogram","rdk");const $r={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"};$s("RandomDotKinematogram",(i,e,t,s)=>{var b;const r={...$r,...i},n=t.respond(r,s),{rt:a,response:o}=n.value,l=((b=r.preTrialMessage)==null?void 0:b.duration)??0,u=r.fixationTime??$r.fixationTime,h=r.duration??$r.duration,d=(r.responseEndsTrial??$r.responseEndsTrial)&&a!=null?a:h,f=Array.isArray(r.correctResponse)?r.correctResponse.map(x=>x.toLowerCase()):r.correctResponse?[r.correctResponse.toLowerCase()]:null,y=o&&f?f.includes(o.toLowerCase()):null;let v=l+u+d;const m={...r,rt:a,response:o,correct:y,framesDisplayed:0,measuredRefreshRate:null,feedbackShown:null,feedbackDuration:null},g=r.feedback;if(g){let x=null;a===null&&g.onTimeout?x=g.onTimeout:y===!1&&g.onIncorrect?x=g.onIncorrect:y===!0&&g.onCorrect&&(x=g.onCorrect),x&&(m.feedbackShown=x.content,m.feedbackDuration=x.duration,v+=x.duration)}return{responseData:m,participantState:n.participantState,duration:v}},{respond:(i,e)=>{const t=px({driftRate:{type:"normal",mean:.005*(i.coherence??$r.coherence),sd:.0012},boundaries:.75,startingPoint:0,noiseLevel:.02,sensoryDelay:{type:"uniform",min:150,max:250},motorDelay:{type:"uniform",min:130,max:210},timeLimit:i.duration??$r.duration,stimOffset:i.stimulusDuration??i.duration??$r.duration,postStimStrategy:{type:"continue"}}),s=fx(t.choice,i.validKeys,i.correctResponse);return{value:{rt:s?t.rt:null,response:s},participantState:e}}});const P1e=10,tT=.1,I1e=(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 sc(a)},Ba=(i,e)=>i+Math.random()*(e-i),R1e=(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=Ba(-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,I=v*f/g+m*y/b,L=v*v/g+m*m/b-1,A=I*I-x*L;if(A>=0){const k=(I+Math.sqrt(A))/x;if(k>0&&Number.isFinite(k))return[l.x-f*k,l.y-y*k]}}}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[Ba(s-n,s+n),Ba(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,I=f!==0?(m-l.y)/f:-1/0,L=f!==0?(g-l.y)/f:-1/0,A=Math.max(Math.min(b,x),Math.min(I,L)),k=Math.min(Math.max(b,x),Math.max(I,L));return k>0&&A<=k&&Number.isFinite(k)?[l.x+d*k,l.y+f*k]: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)}}},A1e=(i,e,t)=>{const[s,r]=t.getRandomPosition(),n=i==="randomDirection"?Ba(-Math.PI,Math.PI):0;return{x:s,y:r,randomDirX:n?Math.cos(n):0,randomDirY:n?-Math.sin(n):0,lifeCount:Ba(0,e>0?e:0),assignedMovement:i}},L1e=(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=Ba(-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=Ba(-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},sT=V.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:I,apertureCenterY:L,reinsertMode:A,noiseMovement:k,reassignEveryMs:P,showFixation:O,fixationWidth:D,fixationHeight:$,fixationColor:Q,fixationThickness:_,showBorder:B,borderWidth:H,borderColor:U,active:G=!0,initialRefreshRate:j,style:ae,className:X}={...$r,...i},ue=V.useRef(null),ie=V.useRef(),se=V.useRef(),fe=V.useRef(),de=V.useRef(0),te=V.useRef(0),pe=V.useRef([]),Ne=V.useRef(null),gt=V.useRef(!1),$t=I??t/2,Us=L??s/2,Vt=V.useMemo(()=>R1e(g,b,x,$t,Us),[g,b,x,$t,Us]),ms=V.useMemo(()=>{const Le=(90-a)*Math.PI/180;return[Math.cos(Le),-Math.sin(Le)]},[a]),ws=V.useRef([]),Ze=V.useRef(0);V.useEffect(()=>{const Le=Math.floor(r*o),Ye=Math.floor(r*l);ws.current=Array.from({length:n},()=>Array.from({length:r},(we,Ht)=>{let Ut;return Ht<Le?Ut="coherent":Ht<Le+Ye?Ut="opposite":Ut=k,A1e(Ut,h,Vt)}))},[]),V.useEffect(()=>{typeof j=="number"&&j>=20&&j<=300&&(Ne.current=1e3/j,gt.current=!0)},[j]),V.useImperativeHandle(e,()=>({getStats:()=>({framesDisplayed:te.current,measuredRefreshRate:Ne.current?Math.round(1e3/Ne.current):null})}));const mt=V.useCallback((Le,Ye)=>{Ye.forEach(we=>{const Ht=v&&we.assignedMovement==="coherent"?v:y;if(Le.fillStyle=Ht,f){const Ut=d*2.5;Le.font=`${Ut}px monospace`,Le.textAlign="center",Le.textBaseline="middle",Le.fillText(f,we.x,we.y)}else Le.beginPath(),Le.arc(we.x,we.y,d,0,Math.PI*2),Le.fill()})},[y,v,d,f]),gs=V.useCallback((Le,Ye,we)=>{O&&(Le.fillStyle=Q,Le.fillRect(Ye-D,we-_/2,D*2,_),Le.fillRect(Ye-_/2,we-$,_,$*2))},[O,Q,_,D,$]),es=V.useCallback(Le=>{B&&Vt.drawBorder(Le,U,H)},[B,U,H,Vt]),Ct=V.useCallback(Le=>{const Ye=ue.current,we=Ye==null?void 0:Ye.getContext("2d");if(!Ye||!we)return;se.current===void 0&&(se.current=Le),fe.current===void 0&&(fe.current=Le);const Ht=Le-fe.current;if(fe.current=Le,te.current++,Ht>0&&Ht<500){if(gt.current)Ne.current=tT*Ht+(1-tT)*Ne.current;else if(pe.current.push(Ht),pe.current.length>=P1e){const ts=[...pe.current].sort((Ss,zs)=>Ss-zs),xs=Math.floor(ts.length/2);Ne.current=ts.length%2?ts[xs]:(ts[xs-1]+ts[xs])/2,gt.current=!0}}const Ut=Le-(se.current??Le),ns=Math.min(Ut,100),ii=c&&c>0?1e3/c:0,js=!c||c<=0||ns>=ii;if(we.clearRect(0,0,Ye.width,Ye.height),we.save(),Vt.clip(we),we.fillStyle=m,we.fillRect(0,0,Ye.width,Ye.height),we.restore(),!G)gs(we,Vt.centerX,Vt.centerY);else{if(js){const xs=u*ns/1e3;let Ss=!1;if(P!==void 0)if(P===0)Ss=!0;else{de.current+=ns;const J=gt.current&&Ne.current?Ne.current*.5:0;Ss=de.current+J>=P,Ss&&(de.current%=P)}const zs=Ss?I1e(r,o,l,k):null,Ws=ws.current[Ze.current].map((J,oe)=>L1e(J,xs,ns,h,Vt,A,d,ms,zs==null?void 0:zs[oe]));ws.current[Ze.current]=Ws,Ze.current=(Ze.current+1)%n,se.current=Le}const ts=ws.current[Ze.current];we.save(),Vt.clip(we),mt(we,ts),we.restore(),we.save(),we.beginPath(),gs(we,Vt.centerX,Vt.centerY),es(we),we.restore()}ie.current=requestAnimationFrame(Ct)},[G,m,k,o,l,r,u,h,Vt,A,n,d,ms,c,mt,gs,es,P]);return V.useEffect(()=>(ie.current=requestAnimationFrame(Ct),()=>{ie.current&&cancelAnimationFrame(ie.current)}),[Ct]),V.useEffect(()=>{const Le=ue.current;if(!Le)return;const Ye=window.devicePixelRatio||1;Le.width=t*Ye,Le.height=s*Ye,Le.style.width=`${t}px`,Le.style.height=`${s}px`;const we=Le.getContext("2d");we&&we.scale(Ye,Ye)},[t,s]),S.jsx("canvas",{ref:ue,style:{display:"block",...ae},className:X})}),iT=i=>{var Ye;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:I,dotColor:L,backgroundColor:A,apertureShape:k,apertureWidth:P,apertureHeight:O,reinsertMode:D,noiseMovement:$,showFixation:Q,fixationTime:_,fixationWidth:B,fixationHeight:H,fixationColor:U,fixationThickness:G,showBorder:j,borderWidth:ae,borderColor:X}={...$r,...i},ue=V.useRef(i);ue.current=i;const ie=((Ye=i.preTrialMessage)==null?void 0:Ye.duration)??0,se=V.useRef(null),fe=V.useRef(performance.now()),de=V.useRef(!1),te=V.useRef(null),pe=V.useRef(null),[Ne,gt]=V.useState(!i.preTrialMessage),[$t,Us]=V.useState(null),[Vt,ms]=V.useState(_<=0),[ws,Ze]=V.useState(!0),[mt,gs]=V.useState(null),es=e==null?void 0:e._reactiveScreenRefreshRate;V.useEffect(()=>{if(!i.preTrialMessage)return;const we=setTimeout(()=>gt(!0),i.preTrialMessage.duration);return()=>clearTimeout(we)},[]);const Ct=V.useCallback((we,Ht)=>{var oe;if(de.current)return;de.current=!0;const{next:Ut,data:ns,store:ii,updateStore:js,...ts}=ue.current,xs=(oe=se.current)==null?void 0:oe.getStats(),Ss=Array.isArray(ts.correctResponse)?ts.correctResponse.map(re=>re.toLowerCase()):ts.correctResponse?[ts.correctResponse.toLowerCase()]:null,zs=we&&Ss?Ss.includes(we):null,Ji={...$r,...ts,rt:Ht,response:we,correct:zs,framesDisplayed:(xs==null?void 0:xs.framesDisplayed)??0,measuredRefreshRate:(xs==null?void 0:xs.measuredRefreshRate)??null,feedbackShown:null,feedbackDuration:null},Ws=ts.feedback;let J=null;Ws&&(Ht===null&&Ws.onTimeout?J=Ws.onTimeout:zs===!1&&Ws.onIncorrect?J=Ws.onIncorrect:zs===!0&&Ws.onCorrect&&(J=Ws.onCorrect)),J?(Ji.feedbackShown=J.content,Ji.feedbackDuration=J.duration,gs(J),setTimeout(()=>Ut(Ji),J.duration)):Ut(Ji)},[]);V.useEffect(()=>{if(_<=0)return;const we=setTimeout(()=>ms(!0),ie+_);return()=>clearTimeout(we)},[_,ie]),V.useEffect(()=>{const we=t??c;if(we<=0)return;const Ht=setTimeout(()=>Ze(!1),ie+_+we);return()=>clearTimeout(Ht)},[ie,_,t,c]),V.useEffect(()=>{if(c<=0)return;const we=setTimeout(()=>{Ct(te.current,pe.current)},ie+_+c);return()=>clearTimeout(we)},[ie,_,c,Ct]),V.useEffect(()=>{const we=Ht=>{if(de.current||te.current||!Ne)return;const Ut=Ht.key.toLowerCase(),ns=h.length>0?h.map(ii=>ii.toLowerCase()):null;if(!ns||ns.includes(Ut)){const ii=performance.now()-fe.current;te.current=Ut,pe.current=ii,Us(Ut),d&&Ct(Ut,ii)}};return window.addEventListener("keydown",we),()=>window.removeEventListener("keydown",we)},[h,d,Ct,Ne]);const Le=we=>S.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:S.jsx("span",{style:{color:"white",fontSize:"2rem",fontWeight:"bold",textAlign:"center",padding:"0 2rem"},children:we})});return S.jsx("div",{style:{width:"100vw",height:"100vh",overflow:"hidden",margin:0,padding:0,backgroundColor:A},children:Ne?mt?Le(mt.content):S.jsxs(S.Fragment,{children:[S.jsx(sT,{ref:se,width:window.innerWidth,height:window.innerHeight,active:Vt&&ws,initialRefreshRate:es,dotCount:f,dotSetCount:y,direction:v,coherence:m,opposite:g,speed:b,dotLifetime:x,updateRate:s,dotRadius:I,dotCharacter:r,dotColor:L,coherentDotColor:n,backgroundColor:A,apertureShape:k,apertureWidth:P,apertureHeight:O,apertureCenterX:a,apertureCenterY:o,reinsertMode:D,noiseMovement:$,reassignEveryMs:l,showFixation:Q,fixationWidth:B,fixationHeight:H,fixationColor:U,fixationThickness:G,showBorder:j,borderWidth:ae,borderColor:X}),u&&!ws&&!$t&&S.jsx("div",{style:{position:"absolute",top:"60%",width:"100%",textAlign:"center",color:"white",fontSize:"1.25rem"},children:u})]}):Le(i.preTrialMessage.content)})},_1e={Text:dc,ProlificEnding:gx,EnterFullscreen:TS,ExitFullscreen:PS,Quest:pE,Upload:wS,MicrophoneCheck:vx,PlainInput:mx,RequestFilePermission:HS,CanvasBlock:QS,CheckDevice:US,StoreUI:Sfe,Tutorial:eT,RandomDotKinematogram:iT,VoiceRecording:ux},D1e={voicerecorder:Jne};en("dev",!1,"boolean","Enable the developer inspector panel");function x0(i){return typeof i=="object"&&i!==null&&typeof i.type=="string"}function k1e({timeline:i,config:e={showProgressBar:!1},components:t={},questions:s={},hybridParticipant:r,disableDev:n=!1,simulationConfig:a}){const o=wfe(),l=V.useMemo(()=>rc(i),[i]),u=V.useRef((()=>{const j={},ae=new URLSearchParams(window.location.search);for(const[se,fe]of ae.entries())j[se]=fe;const X=Nl.getRegistry()||[],ue={};for(const[se,fe]of Object.entries(j))ue[se]={value:fe,registered:!1,defaultValue:void 0,type:void 0,description:void 0};for(const se of X)ue[se.name]={value:se.value!==void 0?se.value:j[se.name],registered:!0,defaultValue:se.defaultValue,type:se.type,description:se.description};return[{index:-1,trialNumber:-1,start:As(),end:As(),duration:0,type:"",name:"",responseData:{userAgent:navigator.userAgent,params:ue}}]})()),[h,c]=V.useState(0),d=V.useRef(As()),f=V.useRef({_uploadId:AE()}),[y,v]=V.useState(()=>Dn(l,0,()=>f.current,()=>u.current,j=>{f.current={...f.current,...j}})),m=!o&&en("hybridSimulation",!1,"boolean")?"hybrid":"none",g=V.useRef(r||{}),b=V.useRef(-1),x={..._1e,...t},I={...D1e,...s},L=V.useMemo(()=>{const j=l.instructions.length;return j>0?y/j:0},[y,l.instructions]);V.useEffect(()=>{window.scrollTo(0,0)},[y]);function A(j){f.current={...f.current,...j}}function k(j,ae,X){const ue=As(),ie=l.instructions[y],se=ae!==void 0?ae:d.current,fe=X!==void 0?X:ue;if((ie==null?void 0:ie.type)==="ExecuteContent"){const te=ie.content;if(x0(te)){let pe={index:y,trialNumber:h+1,start:se,end:fe,duration:fe-se,type:te.type,name:te.name??"",...te.csv!==void 0?{csv:te.csv}:{},responseData:j};pe=nc(pe,te,u.current,f.current),u.current=[...u.current,pe],c(Ne=>Ne+1)}else console.log("ExecuteContent finished, but content wasn't standard component format:",te)}const de=Dn(l,y+1,()=>f.current,()=>u.current,te=>A(te));de<l.instructions.length&&(d.current=As()),v(de)}const P=V.useCallback(j=>{let ae=0;const X=As(),ue=2e4;let ie,se=X;const fe=1e3,de=()=>{const gt=As()-X;return gt>0?Math.round(ae*1e3/gt):null},te=()=>{ie&&cancelAnimationFrame(ie)},pe=Ne=>{ae++;const gt=Ne-X;Ne-se>=fe&&(j(de()),se=Ne),gt<ue?ie=requestAnimationFrame(pe):(te(),j(de()))};return ie=requestAnimationFrame(pe),te},[]),O=({children:j,collectRefreshRate:ae})=>{const X=V.useRef(null),ue=V.useRef(null);V.useEffect(()=>{if(X.current=As(),ae)return P(fe=>{ue.current=fe,A({_reactiveScreenRefreshRate:fe})})},[]);const ie=V.Children.map(j,se=>{if(V.isValidElement(se)){const fe=(de,te,pe)=>{const Ne=As(),gt=te!==void 0?te:X.current;k(de,gt??void 0,(pe!==void 0?pe:Ne)??void 0)};return V.cloneElement(se,{...se.props,next:fe})}return se});return S.jsx(S.Fragment,{children:ie})},D=l.instructions[y],$=V.useMemo(()=>{if(m==="none"||(D==null?void 0:D.type)!=="ExecuteContent")return!1;const j=D.content;return!x0(j)||j.simulate===!1?!1:!!j.simulate||!!j.simulators},[y,m,D]);V.useEffect(()=>{$&&b.current!==y&&(b.current=y,(async()=>{const j=D.content,{trialProps:ae,simulateFn:X,simulators:ue}=Sm(j,u.current,f.current),ie=await X(ae,{data:u.current,store:f.current},ue,g.current);g.current=ie.participantState,ie.storeUpdates&&A(ie.storeUpdates),k(ie.responseData)})())},[$,y]);let Q=null;if((D==null?void 0:D.type)==="ExecuteContent"&&!$){const j=D.content;if(x0(j)){const ae=x[j.type];if(ae){const X=typeof j.props=="function"?j.props(u.current,f.current):j.props||{};Q=S.jsx(O,{collectRefreshRate:j.collectRefreshRate,children:S.jsx(ae,{next:k,updateStore:A,store:f.current,data:u.current,name:j.name,...j.type==="Quest"?{customQuestions:I}:{},...X})},y)}else console.error(`No component found for type: ${j.type}`),Q=S.jsxs("div",{children:['Error: Component type "',j.type,'" not found.']})}else console.warn("ExecuteContent instruction does not contain standard component data:",j),Q=S.jsx("div",{children:"Non-component content encountered."})}else y>=l.instructions.length&&(Q=S.jsx(S.Fragment,{}));const _=e.theme??"light",B=xi(_),H=!n&&en("dev",!1,"boolean"),U=V.useRef(null),G=(D==null?void 0:D.type)==="ExecuteContent"?D.content:null;return S.jsx(Tm.Provider,{value:_,children:S.jsx(Pm.Provider,{value:f.current.audioInputId,children:S.jsxs("div",{className:"w-full h-full",children:[S.jsx("div",{className:` ${e.showProgressBar?"":"hidden "} px-4 mt-4 sm:mt-12 max-w-2xl mx-auto`,children:S.jsx("div",{className:`flex-1 h-6 ${B.progressBg} rounded-full overflow-hidden`,children:S.jsx("div",{className:`h-full ${B.progressBg} rounded-full duration-300 ${L>0?" border-black border-2":""}`,style:{width:`${L*100}%`,backgroundImage:`repeating-linear-gradient(
|
|
10254
10254
|
-45deg, ${B.progressStripe1}, ${B.progressStripe1} 10px, ${B.progressStripe2} 10px, ${B.progressStripe2} 20px
|
|
10255
|
-
)`,transition:"width 300ms ease-in-out"}})})}),Q,H&&S.jsxs(S.Fragment,{children:[S.jsx("button",{onClick:j=>{const ae=U.current;if(ae){const X=ae.style.display==="none";ae.style.display=X?"block":"none",j.currentTarget.textContent=X?"✕":"DEV"}},className:"fixed top-2 right-2 z-50 px-3 py-1 bg-white text-black text-xs font-bold border-2 border-black shadow-[2px_2px_0px_rgba(0,0,0,1)] hover:translate-x-[1px] hover:translate-y-[1px] hover:shadow-none cursor-pointer",children:"DEV"}),S.jsx("div",{ref:U,style:{display:"none"},className:"fixed top-10 right-2 z-50 w-96 max-h-[80vh] overflow-auto bg-white text-black text-xs font-mono border-2 border-black shadow-[4px_4px_0px_rgba(0,0,0,1)] p-3",children:G&&S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"font-bold mb-2 text-sm",children:[G.type," ",G.name?`(${G.name})`:""]}),S.jsxs("div",{className:"mb-2",children:[S.jsx("span",{className:"font-bold",children:"Props:"}),S.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all",children:JSON.stringify(typeof G.props=="function"?"(dynamic)":G.props,null,2)})]}),G.metadata&&S.jsxs("div",{className:"mb-2",children:[S.jsx("span",{className:"font-bold",children:"Metadata:"}),S.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all",children:JSON.stringify(G.metadata,null,2)})]}),S.jsxs("div",{className:"mb-2",children:[S.jsx("span",{className:"font-bold",children:"Store:"}),S.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all",children:JSON.stringify(f.current,null,2)})]}),S.jsxs("div",{children:[S.jsxs("span",{className:"font-bold cursor-pointer",onClick:j=>{const ae=j.currentTarget.nextElementSibling;ae&&(ae.style.display=ae.style.display==="none"?"block":"none")},children:["Data (",u.current.length,") ▸"]}),S.jsx("pre",{style:{display:"none"},className:"mt-1 whitespace-pre-wrap break-all",children:JSON.stringify(u.current,null,2)})]})]})})]})]})})})}function rT(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 O1e(i,e){i=rT(i),e=rT(e);const t=i.split("/"),s=e.split("/");return i!==e&&t.every((r,n)=>r===s[n])}class rp extends ic{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=k2(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=rp.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(O1e(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=Vd.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}}}rp._debug=!0;const M1e=Object.freeze(Object.defineProperty({__proto__:null,FilesystemWeb:rp},Symbol.toStringTag,{value:"Module"}));class N1e extends ic{async enable(){console.log("Immersive mode is only available on Android")}async disable(){console.log("Immersive mode is only available on Android")}}const F1e=Object.freeze(Object.defineProperty({__proto__:null,ImmersiveModeWeb:N1e},Symbol.toStringTag,{value:"Module"}));K.AudioDeviceContext=Pm,K.Bounce=FS,K.CanvasBlock=QS,K.CheckDevice=US,K.DARK_BG_CLASS=Mne,K.DARK_BG_PLAIN_CLASS=Nne,K.DUMMY_AUDIO_BASE64=lx,K.EnterFullscreen=TS,K.ExitFullscreen=PS,K.ExperimentProvider=xfe,K.ExperimentRunner=k1e,K.Flip=vfe,K.Icons=Rd,K.LIGHT_DOT_BG_CLASS=One,K.MicCheck=vx,K.Param=Nl,K.PlainInput=mx,K.ProlificEnding=gx,K.Quest=pE,K.RDKCanvas=sT,K.RandomDotKinematogram=iT,K.RequestFilePermission=HS,K.Slide=mfe,K.THEME=G2,K.Text=dc,K.ThemeContext=Tm,K.ToastContainer=qS,K.Tutorial=eT,K.Upload=wS,K.VoiceRecording=ux,K.Zoom=gfe,K.arrayFlattener=H2,K.canvasCountdown=Sne,K.chunk=R2,K.collapseToast=RS,K.cssTransition=bu,K.draw=pne,K.getBackendUrl=q2,K.getInitialParticipant=$2,K.getParam=en,K.getPlatform=Fl,K.getSimulation=Tne,K.halton=T2,K.invokeLLM=sae,K.isDesktop=xne,K.isFullscreen=po,K.mapDDMChoice=fx,K.mean=A2,K.noopSimulate=fo,K.now=As,K.orchestrateSimulation=Rne,K.pipe=I2,K.probeAudioDurationMs=J2,K.registerArrayExtensions=fne,K.registerComponentParams=Em,K.registerExperimentParams=M2,K.registerFlattener=Zs,K.registerSimulation=$s,K.resolveSimulation=Sm,K.sample=P2,K.sampleParticipants=cne,K.seedDistributions=nne,K.selectPrevTrialData=Ene,K.setBackendUrl=Pne,K.shuffle=sc,K.simulateDDMTrial=px,K.simulateParticipant=Ine,K.sobol=S2,K.subsetExperimentByParam=Vne,K.sum=L2,K.t=xi,K.textToWebmBase64=Z2,K.toast=Dt,K.useAudioDeviceId=K2,K.useTheme=qi,K.useToast=MS,K.useToastContainer=OS,K.useTutorialSlide=T1e,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})});
|
|
10255
|
+
)`,transition:"width 300ms ease-in-out"}})})}),Q,H&&S.jsxs(S.Fragment,{children:[S.jsx("button",{onClick:j=>{const ae=U.current;if(ae){const X=ae.style.display==="none";ae.style.display=X?"block":"none",j.currentTarget.textContent=X?"✕":"DEV"}},className:"fixed top-2 right-2 z-50 px-3 py-1 bg-white text-black text-xs font-bold border-2 border-black shadow-[2px_2px_0px_rgba(0,0,0,1)] hover:translate-x-[1px] hover:translate-y-[1px] hover:shadow-none cursor-pointer",children:"DEV"}),S.jsx("div",{ref:U,style:{display:"none"},className:"fixed top-10 right-2 z-50 w-96 max-h-[80vh] overflow-auto bg-white text-black text-xs font-mono border-2 border-black shadow-[4px_4px_0px_rgba(0,0,0,1)] p-3",children:G&&S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"font-bold mb-2 text-sm",children:[G.type," ",G.name?`(${G.name})`:""]}),S.jsxs("div",{className:"mb-2",children:[S.jsx("span",{className:"font-bold",children:"Props:"}),S.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all",children:JSON.stringify(typeof G.props=="function"?"(dynamic)":G.props,null,2)})]}),G.metadata&&S.jsxs("div",{className:"mb-2",children:[S.jsx("span",{className:"font-bold",children:"Metadata:"}),S.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all",children:JSON.stringify(G.metadata,null,2)})]}),S.jsxs("div",{className:"mb-2",children:[S.jsx("span",{className:"font-bold",children:"Store:"}),S.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all",children:JSON.stringify(f.current,null,2)})]}),S.jsxs("div",{children:[S.jsxs("span",{className:"font-bold cursor-pointer",onClick:j=>{const ae=j.currentTarget.nextElementSibling;ae&&(ae.style.display=ae.style.display==="none"?"block":"none")},children:["Data (",u.current.length,") ▸"]}),S.jsx("pre",{style:{display:"none"},className:"mt-1 whitespace-pre-wrap break-all",children:JSON.stringify(u.current,null,2)})]})]})})]})]})})})}function rT(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 O1e(i,e){i=rT(i),e=rT(e);const t=i.split("/"),s=e.split("/");return i!==e&&t.every((r,n)=>r===s[n])}class rp extends ic{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=k2(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=rp.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(O1e(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=Vd.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}}}rp._debug=!0;const M1e=Object.freeze(Object.defineProperty({__proto__:null,FilesystemWeb:rp},Symbol.toStringTag,{value:"Module"}));class N1e extends ic{async enable(){console.log("Immersive mode is only available on Android")}async disable(){console.log("Immersive mode is only available on Android")}}const F1e=Object.freeze(Object.defineProperty({__proto__:null,ImmersiveModeWeb:N1e},Symbol.toStringTag,{value:"Module"}));K.AudioDeviceContext=Pm,K.Bounce=FS,K.CanvasBlock=QS,K.CheckDevice=US,K.DARK_BG_CLASS=Mne,K.DARK_BG_PLAIN_CLASS=Nne,K.DUMMY_AUDIO_BASE64=lx,K.EnterFullscreen=TS,K.ExitFullscreen=PS,K.ExperimentProvider=xfe,K.ExperimentRunner=k1e,K.Flip=vfe,K.Icons=Rd,K.LIGHT_DOT_BG_CLASS=One,K.MicCheck=vx,K.Param=Nl,K.PlainInput=mx,K.ProlificEnding=gx,K.Quest=pE,K.RDKCanvas=sT,K.RandomDotKinematogram=iT,K.RequestFilePermission=HS,K.Slide=mfe,K.THEME=G2,K.Text=dc,K.ThemeContext=Tm,K.ToastContainer=qS,K.Tutorial=eT,K.Upload=wS,K.VoiceRecording=ux,K.Zoom=gfe,K.arrayFlattener=H2,K.canvasCountdown=Sne,K.chunk=R2,K.collapseToast=RS,K.cssTransition=bu,K.draw=pne,K.getBackendUrl=q2,K.getInitialParticipant=$2,K.getParam=en,K.getPlatform=Fl,K.getSimulation=Tne,K.halton=T2,K.invokeLLM=sae,K.isDesktop=xne,K.isFullscreen=po,K.mapDDMChoice=fx,K.mean=A2,K.noopSimulate=fo,K.now=As,K.orchestrateSimulation=Rne,K.pipe=I2,K.prepareTimeline=Vne,K.probeAudioDurationMs=J2,K.registerArrayExtensions=fne,K.registerComponentParams=Em,K.registerExperimentParams=M2,K.registerFlattener=Zs,K.registerSimulation=$s,K.resolveSimulation=Sm,K.sample=P2,K.sampleParticipants=cne,K.seedDistributions=nne,K.selectPrevTrialData=Ene,K.setBackendUrl=Pne,K.shuffle=sc,K.simulateDDMTrial=px,K.simulateParticipant=Ine,K.sobol=S2,K.sum=L2,K.t=xi,K.textToWebmBase64=Z2,K.toast=Dt,K.useAudioDeviceId=K2,K.useTheme=qi,K.useToast=MS,K.useToastContainer=OS,K.useTutorialSlide=T1e,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
|
|
3
3
|
import '../index.css';
|
|
4
|
-
import { ExperimentConfig, Store, Param, now, getParam
|
|
4
|
+
import { ExperimentConfig, Store, Param, now, getParam } from '../utils/common';
|
|
5
5
|
import { useCallback, useEffect, useMemo, useRef, useState, ComponentType } from 'react';
|
|
6
6
|
import {
|
|
7
7
|
compileTimeline,
|
|
@@ -110,7 +110,6 @@ export default function ExperimentRunner({
|
|
|
110
110
|
/** Simulation config — not used at runtime, extracted by simulate.ts via createElement. */
|
|
111
111
|
simulationConfig?: any;
|
|
112
112
|
}) {
|
|
113
|
-
registerExperimentParams(timeline);
|
|
114
113
|
const disableHybridSimulation = useHybridSimulationDisabled();
|
|
115
114
|
const trialByteCode = useMemo(() => {
|
|
116
115
|
return compileTimeline(timeline);
|
package/src/utils/common.ts
CHANGED
|
@@ -213,9 +213,10 @@ export function registerComponentParams(
|
|
|
213
213
|
providedComponentParams[type] = params;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
export function
|
|
217
|
-
|
|
216
|
+
export function prepareTimeline(experiment: any[], options: { subset?: boolean } = {}): any[] {
|
|
217
|
+
registerExperimentParams(experiment);
|
|
218
218
|
|
|
219
|
+
timelineRepresentation.length = 0;
|
|
219
220
|
experiment.forEach((item) => {
|
|
220
221
|
timelineRepresentation.push({
|
|
221
222
|
type: item.type ?? 'NoTypeSpecified',
|
|
@@ -223,6 +224,8 @@ export function subsetExperimentByParam(experiment: any[]) {
|
|
|
223
224
|
});
|
|
224
225
|
});
|
|
225
226
|
|
|
227
|
+
if (!options.subset) return experiment;
|
|
228
|
+
|
|
226
229
|
const include = getParam('includeSubset', undefined);
|
|
227
230
|
const exclude = getParam('excludeSubset', undefined);
|
|
228
231
|
|
|
@@ -255,6 +258,7 @@ export function subsetExperimentByParam(experiment: any[]) {
|
|
|
255
258
|
return experimentFiltered;
|
|
256
259
|
}
|
|
257
260
|
|
|
261
|
+
|
|
258
262
|
export function canvasCountdown(seconds: number) {
|
|
259
263
|
if (seconds <= 0) {
|
|
260
264
|
return [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { useState, useRef } from 'react';
|
|
3
|
-
import { ExperimentRunner, BaseComponentProps, ExperimentConfig, registerSimulation, registerFlattener, sampleParticipants } from '@adriansteffan/reactive';
|
|
3
|
+
import { ExperimentRunner, BaseComponentProps, ExperimentConfig, registerSimulation, registerFlattener, sampleParticipants, prepareTimeline } from '@adriansteffan/reactive';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const config: ExperimentConfig = { showProgressBar: true };
|
|
@@ -66,7 +66,7 @@ const CustomQuestion = () => {
|
|
|
66
66
|
|
|
67
67
|
// --- Timeline ---
|
|
68
68
|
|
|
69
|
-
const experiment = [
|
|
69
|
+
const experiment = prepareTimeline([
|
|
70
70
|
{
|
|
71
71
|
name: 'introtext',
|
|
72
72
|
type: 'Text',
|
|
@@ -149,7 +149,7 @@ const experiment = [
|
|
|
149
149
|
content: <>Thank you for participating in our study, you can now close the browser window.</>,
|
|
150
150
|
},
|
|
151
151
|
},
|
|
152
|
-
];
|
|
152
|
+
]);
|
|
153
153
|
|
|
154
154
|
// --- Simulation config ---
|
|
155
155
|
const simulationConfig = {
|