jspsych 8.2.2 → 8.2.3
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/README.md +1 -1
- package/dist/index.browser.js +69 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +6 -6
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +68 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +68 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/modules/plugins.ts +1 -0
- package/src/timeline/Trial.spec.ts +105 -1
- package/src/timeline/Trial.ts +78 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var jsPsychModule=function(
|
|
1
|
+
var jsPsychModule=function($){"use strict";var D=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Y(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}const Fe=r=>{const e=new Set;do for(const t of Reflect.ownKeys(r))e.add([r,t]);while((r=Reflect.getPrototypeOf(r))&&r!==Object.prototype);return e};var Je=(r,{include:e,exclude:t}={})=>{const n=s=>{const l=u=>typeof u=="string"?s===u:u.test(s);return e?e.some(l):t?!t.some(l):!0};for(const[s,l]of Fe(r.constructor.prototype)){if(l==="constructor"||!n(l))continue;const u=Reflect.getOwnPropertyDescriptor(s,l);u&&typeof u.value=="function"&&(r[l]=r[l].bind(r))}return r},X=Y(Je),We="8.2.3",me=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});class U{constructor(e,t){this.dependencies=e,this.extensionsConfiguration=t,this.extensions=Object.fromEntries(t.map(n=>[U.getExtensionNameByClass(n.type),this.dependencies.instantiateExtension(n.type)]))}static getExtensionNameByClass(e){return e.info.name}getExtensionInstanceByClass(e){return this.extensions[U.getExtensionNameByClass(e)]}initializeExtensions(){return me(this,null,function*(){yield Promise.all(this.extensionsConfiguration.map(({type:e,params:t={}})=>{this.getExtensionInstanceByClass(e).initialize(t);const n=e.info;!("version"in n)&&!("data"in n)?console.warn(n.name,"is missing the 'version' and 'data' fields. Please update extension as 'version' and 'data' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details."):"version"in n?"data"in n||console.warn(n.name,"is missing the 'data' field. Please update extension as 'data' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details."):console.warn(n.name,"is missing the 'version' field. Please update extension as 'version' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details.")}))})}onStart(e=[]){var t;for(const{type:n,params:s}of e)(t=this.getExtensionInstanceByClass(n))==null||t.on_start(s)}onLoad(e=[]){var t;for(const{type:n,params:s}of e)(t=this.getExtensionInstanceByClass(n))==null||t.on_load(s)}onFinish(){return me(this,arguments,function*(e=[]){const t=yield Promise.all(e.map(({type:s,params:l})=>{var u;return Promise.resolve((u=this.getExtensionInstanceByClass(s))==null?void 0:u.on_finish(l))})),n=e.length?{extension_type:e.map(({type:s})=>s.info.name),extension_version:e.map(({type:s})=>s.info.version)}:{};return t.unshift(n),Object.assign({},...t)})}}function K(r){return[...new Set(r)]}function j(r){if(!r)return r;let e;if(Array.isArray(r)){e=[];for(const t of r)e.push(j(t));return e}else if(typeof r=="object"&&r!==null){e={};for(const t in r)r.hasOwnProperty(t)&&(e[t]=j(r[t]));return e}else return r}function G(r,e){let t={};for(const n in r)r.hasOwnProperty(n)&&(typeof r[n]=="object"&&e.hasOwnProperty(n)?t[n]=G(r[n],e[n]):t[n]=r[n]);for(const n in e)e.hasOwnProperty(n)&&(t.hasOwnProperty(n)&&typeof e[n]=="object"?t[n]=G(t[n],e[n]):t[n]=e[n]);return t}var Ye=Object.freeze({__proto__:null,deepCopy:j,deepMerge:G,unique:K});class H{constructor(e=[]){this.values=e}sum(){let e=0;for(const t of this.values)e+=t;return e}mean(){let e=0,t=0;for(const n of this.values)typeof n!="undefined"&&n!==null&&(e+=n,t++);if(t!==0)return e/t}median(){if(this.values.length===0)return;const e=this.values.slice(0).sort(function(n,s){return n-s}),t=Math.floor(e.length/2);return e.length%2===0?(e[t]+e[t-1])/2:e[t]}min(){return Math.min.apply(null,this.values)}max(){return Math.max.apply(null,this.values)}count(){return this.values.length}variance(){const e=this.mean();let t=0;for(const n of this.values)t+=Math.pow(n-e,2);return t/(this.values.length-1)}sd(){const e=this.variance();return Math.sqrt(e)}frequencies(){const e={};for(const t of this.values)typeof e[t]=="undefined"?e[t]=1:e[t]++;return e}all(e){for(const t of this.values)if(!e(t))return!1;return!0}subset(e){const t=[];for(const n of this.values)e(n)&&t.push(n);return new H(t)}}function Xe(r,e){const t=new Blob([r],{type:"text/plain"});let n="";typeof window.webkitURL!="undefined"?n=window.webkitURL.createObjectURL(t):n=window.URL.createObjectURL(t);const s=document.createElement("a");s.id="jspsych-download-as-text-link",s.style.display="none",s.download=e,s.href=n,s.click()}function He(r){const e=typeof r!="object"?JSON.parse(r):r;let t="",n="";const s=[];for(const l of e)for(const u in l){let a=u+"";a='"'+a.replace(/"/g,'""')+'",',s.includes(u)||(s.push(u),t+=a)}t=t.slice(0,-1),n+=t+`\r
|
|
2
2
|
`;for(const l of e){t="";for(const u of s){let a=typeof l[u]=="undefined"?"":l[u];typeof a=="object"&&(a=JSON.stringify(a));const i=a+"";t+='"'+i.replace(/"/g,'""')+'",'}t=t.slice(0,-1),n+=t+`\r
|
|
3
|
-
`}return n}function Qe(){const r=window.location.search.substr(1).split("&"),e={};for(let t=0;t<r.length;++t){const n=r[t].split("=",2);n.length==1?e[n[0]]="":e[n[0]]=decodeURIComponent(n[1].replace(/\+/g," "))}return e}class
|
|
4
|
-
different value for n.`;return this.trials.length===0?new
|
|
5
|
-
different value for n.`;return this.trials.length===0?new b:(e>this.trials.length&&(e=this.trials.length),new b(this.trials.slice(this.trials.length-e,this.trials.length)))}values(){return this.trials}count(){return this.trials.length}readOnly(){return new b(j(this.trials))}addToAll(e){for(const t of this.trials)Object.assign(t,e);return this}addToLast(e){return this.trials.length>0&&Object.assign(this.trials[this.trials.length-1],e),this}filter(e){let t;Array.isArray(e)?t=j(e):t=j([e]);const n=[];for(const s of this.trials){let l=!1;for(const u of t){let a=!0;for(const i of Object.keys(u))typeof s[i]!="undefined"&&s[i]===u[i]||(a=!1);if(a){l=!0;break}}l&&n.push(s)}return new b(n)}filterCustom(e){return new b(this.trials.filter(e))}filterColumns(e){return new b(this.trials.map(t=>Object.fromEntries(e.filter(n=>n in t).map(n=>[n,t[n]]))))}select(e){const t=[];for(const n of this.trials)typeof n[e]!="undefined"&&t.push(n[e]);return new X(t)}ignore(e){Array.isArray(e)||(e=[e]);const t=j(this.trials);for(const n of t)for(const s of e)delete n[s];return new b(t)}uniqueNames(){const e=[];for(const t of this.trials)for(const n of Object.keys(t))e.includes(n)||e.push(n);return e}csv(){return He(this.trials)}json(e=!1){return e?JSON.stringify(this.trials,null," "):JSON.stringify(this.trials)}localSave(e,t){e=e.toLowerCase();let n;if(e==="json")n=this.json();else if(e==="csv")n=this.csv();else throw new Error('Invalid format specified for localSave. Must be "json" or "csv".');Xe(n,t)}}var Ze=Object.defineProperty,me=Object.getOwnPropertySymbols,et=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable,ge=(r,e,t)=>e in r?Ze(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rt=(r,e)=>{for(var t in e||(e={}))et.call(e,t)&&ge(r,t,e[t]);if(me)for(var t of me(e))tt.call(e,t)&&ge(r,t,e[t]);return r};class nt{constructor(e){this.dependencies=e,this.dataProperties={},this.interactionListeners={blur:()=>{this.addInteractionRecord("blur")},focus:()=>{this.addInteractionRecord("focus")},fullscreenchange:()=>{this.addInteractionRecord(document.isFullScreen||document.webkitIsFullScreen||document.mozIsFullScreen||document.fullscreenElement?"fullscreenenter":"fullscreenexit")}},this.reset()}reset(){this.results=new b,this.resultToTrialMap=new WeakMap,this.interactionRecords=new b}get(){return this.results}getInteractionData(){return this.interactionRecords}write(e){const t=e.getResult();Object.assign(t,this.dataProperties),this.results.push(t),this.resultToTrialMap.set(t,e)}addProperties(e){this.results.addToAll(e),this.dataProperties=Object.assign({},this.dataProperties,e)}addDataToLastTrial(e){this.results.addToLast(e)}getLastTrialData(){return this.results.top()}getLastTimelineData(){const e=this.getLastTrialData().values()[0];return new b(e?this.resultToTrialMap.get(e).parent.getResults():[])}displayData(e="json"){e=e.toLowerCase(),e!=="json"&&e!=="csv"&&(console.log("Invalid format declared for displayData function. Using json as default."),e="json");const t=document.createElement("pre");t.id="jspsych-data-display",t.textContent=e==="json"?this.results.json(!0):this.results.csv(),this.dependencies.getDisplayElement().replaceChildren(t)}urlVariables(){return typeof this.query_string=="undefined"&&(this.query_string=Qe()),this.query_string}getURLVariable(e){return this.urlVariables()[e]}addInteractionRecord(e){const t=rt({event:e},this.dependencies.getProgress());this.interactionRecords.push(t),this.dependencies.onInteractionRecordAdded(t)}createInteractionListeners(){window.addEventListener("blur",this.interactionListeners.blur),window.addEventListener("focus",this.interactionListeners.focus),document.addEventListener("fullscreenchange",this.interactionListeners.fullscreenchange),document.addEventListener("mozfullscreenchange",this.interactionListeners.fullscreenchange),document.addEventListener("webkitfullscreenchange",this.interactionListeners.fullscreenchange)}removeInteractionListeners(){window.removeEventListener("blur",this.interactionListeners.blur),window.removeEventListener("focus",this.interactionListeners.focus),document.removeEventListener("fullscreenchange",this.interactionListeners.fullscreenchange),document.removeEventListener("mozfullscreenchange",this.interactionListeners.fullscreenchange),document.removeEventListener("webkitfullscreenchange",this.interactionListeners.fullscreenchange)}}class it{constructor(e,t=!1,n=0){this.getRootElement=e,this.areResponsesCaseSensitive=t,this.minimumValidRt=n,this.listeners=new Set,this.heldKeys=new Set,this.areRootListenersRegistered=!1,Y(this),this.registerRootListeners()}registerRootListeners(){if(!this.areRootListenersRegistered){const e=this.getRootElement();e&&(e.addEventListener("keydown",this.rootKeydownListener),e.addEventListener("keyup",this.rootKeyupListener),this.areRootListenersRegistered=!0)}}rootKeydownListener(e){for(const t of[...this.listeners])t(e);this.heldKeys.add(this.toLowerCaseIfInsensitive(e.key))}toLowerCaseIfInsensitive(e){return this.areResponsesCaseSensitive?e:e.toLowerCase()}rootKeyupListener(e){this.heldKeys.delete(this.toLowerCaseIfInsensitive(e.key))}isResponseValid(e,t,n){return!t&&this.heldKeys.has(n)?!1:e==="ALL_KEYS"?!0:e==="NO_KEYS"?!1:e.includes(n)}getKeyboardResponse({callback_function:e,valid_responses:t="ALL_KEYS",rt_method:n="performance",persist:s,audio_context:l,audio_context_start_time:u,allow_held_key:a=!1,minimum_valid_rt:i=this.minimumValidRt}){n!=="performance"&&n!=="audio"&&(console.log('Invalid RT method specified in getKeyboardResponse. Defaulting to "performance" method.'),n="performance");const o=n==="performance"?performance.now():u*1e3;this.registerRootListeners(),!this.areResponsesCaseSensitive&&typeof t!="string"&&(t=t.map(c=>c.toLowerCase()));const d=c=>{const h=Math.round((n=="performance"?performance.now():l.currentTime*1e3)-o);if(h<i)return;const p=this.toLowerCaseIfInsensitive(c.key);this.isResponseValid(t,a,p)&&(c.preventDefault(),s||this.cancelKeyboardResponse(d),e({key:c.key,rt:h}))};return this.listeners.add(d),d}cancelKeyboardResponse(e){this.listeners.delete(e)}cancelAllKeyboardResponses(){this.listeners.clear()}compareKeys(e,t){if(typeof e!="string"&&e!==null||typeof t!="string"&&t!==null){console.error("Error in jsPsych.pluginAPI.compareKeys: arguments must be key strings or null.");return}return typeof e=="string"&&typeof t=="string"?this.areResponsesCaseSensitive?e===t:e.toLowerCase()===t.toLowerCase():e===null&&t===null}}var T=(r=>(r[r.BOOL=0]="BOOL",r[r.STRING=1]="STRING",r[r.INT=2]="INT",r[r.FLOAT=3]="FLOAT",r[r.FUNCTION=4]="FUNCTION",r[r.KEY=5]="KEY",r[r.KEYS=6]="KEYS",r[r.SELECT=7]="SELECT",r[r.HTML_STRING=8]="HTML_STRING",r[r.IMAGE=9]="IMAGE",r[r.AUDIO=10]="AUDIO",r[r.VIDEO=11]="VIDEO",r[r.OBJECT=12]="OBJECT",r[r.COMPLEX=13]="COMPLEX",r[r.TIMELINE=14]="TIMELINE",r))(T||{}),H=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});class G{constructor(e,t={useWebAudio:!1}){this.src=e,this.useWebAudio=t.useWebAudio,this.audioContext=t.audioContext||null}load(){return H(this,null,function*(){this.useWebAudio?this.webAudioBuffer=yield this.preloadWebAudio(this.src):this.audio=yield this.preloadHTMLAudio(this.src)})}play(){this.audio instanceof HTMLAudioElement?this.audio.play():(this.audio||(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.start())}stop(){this.audio instanceof HTMLAudioElement?(this.audio.pause(),this.audio.currentTime=0):(this.audio.stop(),this.audio=this.getAudioSourceNode(this.webAudioBuffer))}addEventListener(e,t){!this.audio&&this.webAudioBuffer&&(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.addEventListener(e,t)}removeEventListener(e,t){!this.audio&&this.webAudioBuffer&&(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.removeEventListener(e,t)}getAudioSourceNode(e){const t=this.audioContext.createBufferSource();return t.buffer=e,t.connect(this.audioContext.destination),t}preloadWebAudio(e){return H(this,null,function*(){const t=yield(yield fetch(e)).arrayBuffer(),n=yield this.audioContext.decodeAudioData(t),s=this.audioContext.createBufferSource();return s.buffer=n,s.connect(this.audioContext.destination),n})}preloadHTMLAudio(e){return H(this,null,function*(){return new Promise((t,n)=>{const s=new Audio(e);s.addEventListener("canplaythrough",()=>{t(s)}),s.addEventListener("error",l=>{n(l)}),s.addEventListener("abort",l=>{n(l)})})})}}var st=Object.defineProperty,at=Object.defineProperties,ot=Object.getOwnPropertyDescriptors,ye=Object.getOwnPropertySymbols,lt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,ve=(r,e,t)=>e in r?st(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ct=(r,e)=>{for(var t in e||(e={}))lt.call(e,t)&&ve(r,t,e[t]);if(ye)for(var t of ye(e))ut.call(e,t)&&ve(r,t,e[t]);return r},ht=(r,e)=>at(r,ot(e)),dt=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});const be=[T.AUDIO,T.IMAGE,T.VIDEO];class pt{constructor(e){this.useWebaudio=e,this.video_buffers={},this.context=null,this.audio_buffers=[],this.preload_requests=[],this.img_cache={},this.preloadMap=new Map,this.microphone_recorder=null,this.camera_stream=null,this.camera_recorder=null,this.useWebaudio&&typeof window!="undefined"&&typeof window.AudioContext!="undefined"&&(this.context=new AudioContext)}getVideoBuffer(e){return e.startsWith("blob:")&&(this.video_buffers[e]=e),this.video_buffers[e]}audioContext(){return this.context&&this.context.state!=="running"&&this.context.resume(),this.context}getAudioPlayer(e){return dt(this,null,function*(){return this.audio_buffers[e]instanceof G?this.audio_buffers[e]:(this.audio_buffers[e]=new G(e,{useWebAudio:this.useWebaudio,audioContext:this.context}),yield this.audio_buffers[e].load(),this.audio_buffers[e])})}preloadAudio(e,t=()=>{},n=l=>{},s=l=>{}){e=U(e.flat());let l=0;if(e.length==0){t();return}for(const u of e)this.audio_buffers[u]instanceof G?(l++,n(u),l==e.length&&t()):(this.audio_buffers[u]=new G(u,{useWebAudio:this.useWebaudio,audioContext:this.context}),this.audio_buffers[u].load().then(()=>{l++,n(u),l==e.length&&t()}).catch(a=>{s(a)}))}preloadImages(e,t=()=>{},n=l=>{},s=l=>{}){e=U(e.flat());var l=0;if(e.length===0){t();return}for(let u=0;u<e.length;u++){const a=new Image,i=e[u];a.onload=()=>{l++,n(i),l===e.length&&t()},a.onerror=o=>{s({source:i,error:o})},a.src=i,this.img_cache[i]=a,this.preload_requests.push(a)}}preloadVideo(e,t=()=>{},n=l=>{},s=l=>{}){e=U(e.flat());let l=0;if(e.length===0){t();return}for(const u of e){const a=this.video_buffers,i=new XMLHttpRequest;i.open("GET",u,!0),i.responseType="blob",i.onload=()=>{if(i.status===200||i.status===0){const o=i.response;a[u]=URL.createObjectURL(o),l++,n(u),l===e.length&&t()}},i.onerror=o=>{let d=o;i.status==404&&(d="404"),s({source:u,error:d})},i.onloadend=o=>{i.status==404&&s({source:u,error:"404"})},i.send(),this.preload_requests.push(i)}}getAutoPreloadList(e){const t=Object.fromEntries(be.map(s=>[s,new Set])),n=(s,l)=>{var u,a,i,o;if(typeof s.timeline!="undefined")for(const d of s.timeline)n(d,(u=s.type)!=null?u:l);else if((i=(a=s.type)!=null?a:l)!=null&&i.info){const{name:d,parameters:c}=((o=s.type)!=null?o:l).info;this.preloadMap.has(d)||this.preloadMap.set(d,Object.fromEntries(Object.entries(c).filter(([h,{type:p,preload:f}])=>be.includes(p)&&(f!=null?f:!0)).map(([h,{type:p}])=>[h,p])));for(const[h,p]of Object.entries(this.preloadMap.get(d))){const f=s[h],x=t[p];if(typeof f=="string")x.add(f);else if(Array.isArray(f))for(const k of f.flat())typeof k=="string"&&x.add(k)}}};return n({timeline:e}),{images:[...t[T.IMAGE]],audio:[...t[T.AUDIO]],video:[...t[T.VIDEO]]}}cancelPreloads(){for(const e of this.preload_requests)e.onload=()=>{},e.onerror=()=>{},e.oncanplaythrough=()=>{},e.onabort=()=>{};this.preload_requests=[]}initializeMicrophoneRecorder(e){const t=new MediaRecorder(e);this.microphone_recorder=t}getMicrophoneRecorder(){return this.microphone_recorder}initializeCameraRecorder(e,t){let n=this.getCompatibleMimeType()||"video/webm";const s=ht(ct({},t),{mimeType:n});this.camera_stream=e;const l=new MediaRecorder(e,s);this.camera_recorder=l}getCompatibleMimeType(){const e=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4;codecs=h264,aac","video/mp4;codecs=hevc,aac"];for(const t of e)if(MediaRecorder.isTypeSupported(t))return t;return null}getCameraStream(){return this.camera_stream}getCameraRecorder(){return this.camera_recorder}}var ft=Object.defineProperty,we=Object.getOwnPropertySymbols,mt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable,xe=(r,e,t)=>e in r?ft(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Pe=(r,e)=>{for(var t in e||(e={}))mt.call(e,t)&&xe(r,t,e[t]);if(we)for(var t of we(e))gt.call(e,t)&&xe(r,t,e[t]);return r};class yt{constructor(e,t){this.getDisplayContainerElement=e,this.setJsPsychTimeout=t}dispatchEvent(e){this.getDisplayContainerElement().dispatchEvent(e)}keyDown(e){this.dispatchEvent(new KeyboardEvent("keydown",{key:e}))}keyUp(e){this.dispatchEvent(new KeyboardEvent("keyup",{key:e}))}pressKey(e,t=0){t>0?this.setJsPsychTimeout(()=>{this.keyDown(e),this.keyUp(e)},t):(this.keyDown(e),this.keyUp(e))}clickTarget(e,t=0){t>0?this.setJsPsychTimeout(()=>{e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0})),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))},t):(e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0})),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0})))}fillTextInput(e,t,n=0){n>0?this.setJsPsychTimeout(()=>{e.value=t},n):e.value=t}getValidKey(e){const t=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"," "];let n;if(e=="NO_KEYS")n=null;else if(e=="ALL_KEYS")n=t[Math.floor(Math.random()*t.length)];else{const s=e.flat();n=s[Math.floor(Math.random()*s.length)]}return n}mergeSimulationData(e,t){return Pe(Pe({},e),t==null?void 0:t.data)}ensureSimulationDataConsistency(e,t){if(t.rt&&(t.rt=Math.round(t.rt)),e.trial_duration&&t.rt&&t.rt>e.trial_duration&&(t.rt=null,t.response&&(t.response=null),t.correct&&(t.correct=!1)),e.choices&&e.choices=="NO_KEYS"&&(t.rt&&(t.rt=null),t.response&&(t.response=null)),e.allow_response_before_complete&&e.sequence_reps&&e.frame_time){const n=e.sequence_reps*e.frame_time*e.stimuli.length;t.rt<n&&(t.rt=null,t.response=null)}}}class vt{constructor(){this.timeout_handlers=[]}setTimeout(e,t){const n=window.setTimeout(e,t);return this.timeout_handlers.push(n),n}clearAllTimeouts(){for(const e of this.timeout_handlers)clearTimeout(e);this.timeout_handlers=[]}}function bt(r){const e=r.getInitSettings(),t=new it(r.getDisplayContainerElement,e.case_sensitive_responses,e.minimum_valid_rt),n=new vt,s=new pt(e.use_webaudio),l=new yt(r.getDisplayContainerElement,n.setTimeout.bind(n));return Object.assign({},...[t,n,s,l].map(u=>Y(u)))}var Q={exports:{}};Q.exports,function(r){(function(e,t,n){function s(i){var o=this,d=a();o.next=function(){var c=2091639*o.s0+o.c*23283064365386963e-26;return o.s0=o.s1,o.s1=o.s2,o.s2=c-(o.c=c|0)},o.c=1,o.s0=d(" "),o.s1=d(" "),o.s2=d(" "),o.s0-=d(i),o.s0<0&&(o.s0+=1),o.s1-=d(i),o.s1<0&&(o.s1+=1),o.s2-=d(i),o.s2<0&&(o.s2+=1),d=null}function l(i,o){return o.c=i.c,o.s0=i.s0,o.s1=i.s1,o.s2=i.s2,o}function u(i,o){var d=new s(i),c=o&&o.state,h=d.next;return h.int32=function(){return d.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,c&&(typeof c=="object"&&l(c,d),h.state=function(){return l(d,{})}),h}function a(){var i=4022871197,o=function(d){d=String(d);for(var c=0;c<d.length;c++){i+=d.charCodeAt(c);var h=.02519603282416938*i;i=h>>>0,h-=i,h*=i,i=h>>>0,h-=i,i+=h*4294967296}return(i>>>0)*23283064365386963e-26};return o}t&&t.exports?t.exports=u:this.alea=u})(N,r)}(Q);var Ee=Q.exports,wt=W(Ee),Z={exports:{}};Z.exports,function(r){(function(e,t,n){function s(a){var i=this,o="";i.x=0,i.y=0,i.z=0,i.w=0,i.next=function(){var c=i.x^i.x<<11;return i.x=i.y,i.y=i.z,i.z=i.w,i.w^=i.w>>>19^c^c>>>8},a===(a|0)?i.x=a:o+=a;for(var d=0;d<o.length+64;d++)i.x^=o.charCodeAt(d)|0,i.next()}function l(a,i){return i.x=a.x,i.y=a.y,i.z=a.z,i.w=a.w,i}function u(a,i){var o=new s(a),d=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var h=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(h+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,d&&(typeof d=="object"&&l(d,o),c.state=function(){return l(o,{})}),c}t&&t.exports?t.exports=u:this.xor128=u})(N,r)}(Z);var xt=Z.exports,ee={exports:{}};ee.exports,function(r){(function(e,t,n){function s(a){var i=this,o="";i.next=function(){var c=i.x^i.x>>>2;return i.x=i.y,i.y=i.z,i.z=i.w,i.w=i.v,(i.d=i.d+362437|0)+(i.v=i.v^i.v<<4^(c^c<<1))|0},i.x=0,i.y=0,i.z=0,i.w=0,i.v=0,a===(a|0)?i.x=a:o+=a;for(var d=0;d<o.length+64;d++)i.x^=o.charCodeAt(d)|0,d==o.length&&(i.d=i.x<<10^i.x>>>4),i.next()}function l(a,i){return i.x=a.x,i.y=a.y,i.z=a.z,i.w=a.w,i.v=a.v,i.d=a.d,i}function u(a,i){var o=new s(a),d=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var h=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(h+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,d&&(typeof d=="object"&&l(d,o),c.state=function(){return l(o,{})}),c}t&&t.exports?t.exports=u:this.xorwow=u})(N,r)}(ee);var Pt=ee.exports,te={exports:{}};te.exports,function(r){(function(e,t,n){function s(a){var i=this;i.next=function(){var d=i.x,c=i.i,h,p;return h=d[c],h^=h>>>7,p=h^h<<24,h=d[c+1&7],p^=h^h>>>10,h=d[c+3&7],p^=h^h>>>3,h=d[c+4&7],p^=h^h<<7,h=d[c+7&7],h=h^h<<13,p^=h^h<<9,d[c]=p,i.i=c+1&7,p};function o(d,c){var h,p=[];if(c===(c|0))p[0]=c;else for(c=""+c,h=0;h<c.length;++h)p[h&7]=p[h&7]<<15^c.charCodeAt(h)+p[h+1&7]<<13;for(;p.length<8;)p.push(0);for(h=0;h<8&&p[h]===0;++h);for(h==8?p[7]=-1:p[h],d.x=p,d.i=0,h=256;h>0;--h)d.next()}o(i,a)}function l(a,i){return i.x=a.x.slice(),i.i=a.i,i}function u(a,i){a==null&&(a=+new Date);var o=new s(a),d=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var h=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(h+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,d&&(d.x&&l(d,o),c.state=function(){return l(o,{})}),c}t&&t.exports?t.exports=u:this.xorshift7=u})(N,r)}(te);var Et=te.exports,re={exports:{}};re.exports,function(r){(function(e,t,n){function s(a){var i=this;i.next=function(){var d=i.w,c=i.X,h=i.i,p,f;return i.w=d=d+1640531527|0,f=c[h+34&127],p=c[h=h+1&127],f^=f<<13,p^=p<<17,f^=f>>>15,p^=p>>>12,f=c[h]=f^p,i.i=h,f+(d^d>>>16)|0};function o(d,c){var h,p,f,x,k,A=[],$=128;for(c===(c|0)?(p=c,c=null):(c=c+"\0",p=0,$=Math.max($,c.length)),f=0,x=-32;x<$;++x)c&&(p^=c.charCodeAt((x+32)%c.length)),x===0&&(k=p),p^=p<<10,p^=p>>>15,p^=p<<4,p^=p>>>13,x>=0&&(k=k+1640531527|0,h=A[x&127]^=p+k,f=h==0?f+1:0);for(f>=128&&(A[(c&&c.length||0)&127]=-1),f=127,x=512;x>0;--x)p=A[f+34&127],h=A[f=f+1&127],p^=p<<13,h^=h<<17,p^=p>>>15,h^=h>>>12,A[f]=p^h;d.w=k,d.X=A,d.i=f}o(i,a)}function l(a,i){return i.i=a.i,i.w=a.w,i.X=a.X.slice(),i}function u(a,i){a==null&&(a=+new Date);var o=new s(a),d=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var h=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(h+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,d&&(d.X&&l(d,o),c.state=function(){return l(o,{})}),c}t&&t.exports?t.exports=u:this.xor4096=u})(N,r)}(re);var _t=re.exports,ne={exports:{}};ne.exports,function(r){(function(e,t,n){function s(a){var i=this,o="";i.next=function(){var c=i.b,h=i.c,p=i.d,f=i.a;return c=c<<25^c>>>7^h,h=h-p|0,p=p<<24^p>>>8^f,f=f-c|0,i.b=c=c<<20^c>>>12^h,i.c=h=h-p|0,i.d=p<<16^h>>>16^f,i.a=f-c|0},i.a=0,i.b=0,i.c=-1640531527,i.d=1367130551,a===Math.floor(a)?(i.a=a/4294967296|0,i.b=a|0):o+=a;for(var d=0;d<o.length+20;d++)i.b^=o.charCodeAt(d)|0,i.next()}function l(a,i){return i.a=a.a,i.b=a.b,i.c=a.c,i.d=a.d,i}function u(a,i){var o=new s(a),d=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var h=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(h+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,d&&(typeof d=="object"&&l(d,o),c.state=function(){return l(o,{})}),c}t&&t.exports?t.exports=u:this.tychei=u})(N,r)}(ne);var jt=ne.exports,_e={exports:{}};(function(r){(function(e,t,n){var s=256,l=6,u=52,a="random",i=n.pow(s,l),o=n.pow(2,u),d=o*2,c=s-1,h;function p(m,g,P){var v=[];g=g==!0?{entropy:!0}:g||{};var y=A(k(g.entropy?[m,z(t)]:m==null?$():m,3),v),E=new f(v),O=function(){for(var _=E.g(l),S=i,C=0;_<o;)_=(_+C)*s,S*=s,C=E.g(1);for(;_>=d;)_/=2,S/=2,C>>>=1;return(_+C)/S};return O.int32=function(){return E.g(4)|0},O.quick=function(){return E.g(4)/4294967296},O.double=O,A(z(E.S),t),(g.pass||P||function(_,S,C,R){return R&&(R.S&&x(R,E),_.state=function(){return x(E,{})}),C?(n[a]=_,S):_})(O,y,"global"in g?g.global:this==n,g.state)}function f(m){var g,P=m.length,v=this,y=0,E=v.i=v.j=0,O=v.S=[];for(P||(m=[P++]);y<s;)O[y]=y++;for(y=0;y<s;y++)O[y]=O[E=c&E+m[y%P]+(g=O[y])],O[E]=g;(v.g=function(_){for(var S,C=0,R=v.i,J=v.j,q=v.S;_--;)S=q[R=c&R+1],C=C*s+q[c&(q[R]=q[J=c&J+S])+(q[J]=S)];return v.i=R,v.j=J,C})(s)}function x(m,g){return g.i=m.i,g.j=m.j,g.S=m.S.slice(),g}function k(m,g){var P=[],v=typeof m,y;if(g&&v=="object")for(y in m)try{P.push(k(m[y],g-1))}catch(E){}return P.length?P:v=="string"?m:m+"\0"}function A(m,g){for(var P=m+"",v,y=0;y<P.length;)g[c&y]=c&(v^=g[c&y]*19)+P.charCodeAt(y++);return z(g)}function $(){try{var m;return h&&(m=h.randomBytes)?m=m(s):(m=new Uint8Array(s),(e.crypto||e.msCrypto).getRandomValues(m)),z(m)}catch(v){var g=e.navigator,P=g&&g.plugins;return[+new Date,e,P,e.screen,z(t)]}}function z(m){return String.fromCharCode.apply(0,m)}if(A(n.random(),t),r.exports){r.exports=p;try{h=require("crypto")}catch(m){}}else n["seed"+a]=p})(typeof self!="undefined"?self:N,[],Math)})(_e);var kt=_e.exports,Ot=Ee,Tt=xt,At=Pt,Ct=Et,St=_t,It=jt,D=kt;D.alea=Ot,D.xor128=Tt,D.xorwow=At,D.xorshift7=Ct,D.xor4096=St,D.tychei=It;var Lt=D,Mt=Lt,ie=["ability","able","aboard","about","above","accept","accident","according","account","accurate","acres","across","act","action","active","activity","actual","actually","add","addition","additional","adjective","adult","adventure","advice","affect","afraid","after","afternoon","again","against","age","ago","agree","ahead","aid","air","airplane","alike","alive","all","allow","almost","alone","along","aloud","alphabet","already","also","although","am","among","amount","ancient","angle","angry","animal","announced","another","answer","ants","any","anybody","anyone","anything","anyway","anywhere","apart","apartment","appearance","apple","applied","appropriate","are","area","arm","army","around","arrange","arrangement","arrive","arrow","art","article","as","aside","ask","asleep","at","ate","atmosphere","atom","atomic","attached","attack","attempt","attention","audience","author","automobile","available","average","avoid","aware","away","baby","back","bad","badly","bag","balance","ball","balloon","band","bank","bar","bare","bark","barn","base","baseball","basic","basis","basket","bat","battle","be","bean","bear","beat","beautiful","beauty","became","because","become","becoming","bee","been","before","began","beginning","begun","behavior","behind","being","believed","bell","belong","below","belt","bend","beneath","bent","beside","best","bet","better","between","beyond","bicycle","bigger","biggest","bill","birds","birth","birthday","bit","bite","black","blank","blanket","blew","blind","block","blood","blow","blue","board","boat","body","bone","book","border","born","both","bottle","bottom","bound","bow","bowl","box","boy","brain","branch","brass","brave","bread","break","breakfast","breath","breathe","breathing","breeze","brick","bridge","brief","bright","bring","broad","broke","broken","brother","brought","brown","brush","buffalo","build","building","built","buried","burn","burst","bus","bush","business","busy","but","butter","buy","by","cabin","cage","cake","call","calm","came","camera","camp","can","canal","cannot","cap","capital","captain","captured","car","carbon","card","care","careful","carefully","carried","carry","case","cast","castle","cat","catch","cattle","caught","cause","cave","cell","cent","center","central","century","certain","certainly","chain","chair","chamber","chance","change","changing","chapter","character","characteristic","charge","chart","check","cheese","chemical","chest","chicken","chief","child","children","choice","choose","chose","chosen","church","circle","circus","citizen","city","class","classroom","claws","clay","clean","clear","clearly","climate","climb","clock","close","closely","closer","cloth","clothes","clothing","cloud","club","coach","coal","coast","coat","coffee","cold","collect","college","colony","color","column","combination","combine","come","comfortable","coming","command","common","community","company","compare","compass","complete","completely","complex","composed","composition","compound","concerned","condition","congress","connected","consider","consist","consonant","constantly","construction","contain","continent","continued","contrast","control","conversation","cook","cookies","cool","copper","copy","corn","corner","correct","correctly","cost","cotton","could","count","country","couple","courage","course","court","cover","cow","cowboy","crack","cream","create","creature","crew","crop","cross","crowd","cry","cup","curious","current","curve","customs","cut","cutting","daily","damage","dance","danger","dangerous","dark","darkness","date","daughter","dawn","day","dead","deal","dear","death","decide","declared","deep","deeply","deer","definition","degree","depend","depth","describe","desert","design","desk","detail","determine","develop","development","diagram","diameter","did","die","differ","difference","different","difficult","difficulty","dig","dinner","direct","direction","directly","dirt","dirty","disappear","discover","discovery","discuss","discussion","disease","dish","distance","distant","divide","division","do","doctor","does","dog","doing","doll","dollar","done","donkey","door","dot","double","doubt","down","dozen","draw","drawn","dream","dress","drew","dried","drink","drive","driven","driver","driving","drop","dropped","drove","dry","duck","due","dug","dull","during","dust","duty","each","eager","ear","earlier","early","earn","earth","easier","easily","east","easy","eat","eaten","edge","education","effect","effort","egg","eight","either","electric","electricity","element","elephant","eleven","else","empty","end","enemy","energy","engine","engineer","enjoy","enough","enter","entire","entirely","environment","equal","equally","equator","equipment","escape","especially","essential","establish","even","evening","event","eventually","ever","every","everybody","everyone","everything","everywhere","evidence","exact","exactly","examine","example","excellent","except","exchange","excited","excitement","exciting","exclaimed","exercise","exist","expect","experience","experiment","explain","explanation","explore","express","expression","extra","eye","face","facing","fact","factor","factory","failed","fair","fairly","fall","fallen","familiar","family","famous","far","farm","farmer","farther","fast","fastened","faster","fat","father","favorite","fear","feathers","feature","fed","feed","feel","feet","fell","fellow","felt","fence","few","fewer","field","fierce","fifteen","fifth","fifty","fight","fighting","figure","fill","film","final","finally","find","fine","finest","finger","finish","fire","fireplace","firm","first","fish","five","fix","flag","flame","flat","flew","flies","flight","floating","floor","flow","flower","fly","fog","folks","follow","food","foot","football","for","force","foreign","forest","forget","forgot","forgotten","form","former","fort","forth","forty","forward","fought","found","four","fourth","fox","frame","free","freedom","frequently","fresh","friend","friendly","frighten","frog","from","front","frozen","fruit","fuel","full","fully","fun","function","funny","fur","furniture","further","future","gain","game","garage","garden","gas","gasoline","gate","gather","gave","general","generally","gentle","gently","get","getting","giant","gift","girl","give","given","giving","glad","glass","globe","go","goes","gold","golden","gone","good","goose","got","government","grabbed","grade","gradually","grain","grandfather","grandmother","graph","grass","gravity","gray","great","greater","greatest","greatly","green","grew","ground","group","grow","grown","growth","guard","guess","guide","gulf","gun","habit","had","hair","half","halfway","hall","hand","handle","handsome","hang","happen","happened","happily","happy","harbor","hard","harder","hardly","has","hat","have","having","hay","he","headed","heading","health","heard","hearing","heart","heat","heavy","height","held","hello","help","helpful","her","herd","here","herself","hidden","hide","high","higher","highest","highway","hill","him","himself","his","history","hit","hold","hole","hollow","home","honor","hope","horn","horse","hospital","hot","hour","house","how","however","huge","human","hundred","hung","hungry","hunt","hunter","hurried","hurry","hurt","husband","ice","idea","identity","if","ill","image","imagine","immediately","importance","important","impossible","improve","in","inch","include","including","income","increase","indeed","independent","indicate","individual","industrial","industry","influence","information","inside","instance","instant","instead","instrument","interest","interior","into","introduced","invented","involved","iron","is","island","it","its","itself","jack","jar","jet","job","join","joined","journey","joy","judge","jump","jungle","just","keep","kept","key","kids","kill","kind","kitchen","knew","knife","know","knowledge","known","label","labor","lack","lady","laid","lake","lamp","land","language","large","larger","largest","last","late","later","laugh","law","lay","layers","lead","leader","leaf","learn","least","leather","leave","leaving","led","left","leg","length","lesson","let","letter","level","library","lie","life","lift","light","like","likely","limited","line","lion","lips","liquid","list","listen","little","live","living","load","local","locate","location","log","lonely","long","longer","look","loose","lose","loss","lost","lot","loud","love","lovely","low","lower","luck","lucky","lunch","lungs","lying","machine","machinery","mad","made","magic","magnet","mail","main","mainly","major","make","making","man","managed","manner","manufacturing","many","map","mark","market","married","mass","massage","master","material","mathematics","matter","may","maybe","me","meal","mean","means","meant","measure","meat","medicine","meet","melted","member","memory","men","mental","merely","met","metal","method","mice","middle","might","mighty","mile","military","milk","mill","mind","mine","minerals","minute","mirror","missing","mission","mistake","mix","mixture","model","modern","molecular","moment","money","monkey","month","mood","moon","more","morning","most","mostly","mother","motion","motor","mountain","mouse","mouth","move","movement","movie","moving","mud","muscle","music","musical","must","my","myself","mysterious","nails","name","nation","national","native","natural","naturally","nature","near","nearby","nearer","nearest","nearly","necessary","neck","needed","needle","needs","negative","neighbor","neighborhood","nervous","nest","never","new","news","newspaper","next","nice","night","nine","no","nobody","nodded","noise","none","noon","nor","north","nose","not","note","noted","nothing","notice","noun","now","number","numeral","nuts","object","observe","obtain","occasionally","occur","ocean","of","off","offer","office","officer","official","oil","old","older","oldest","on","once","one","only","onto","open","operation","opinion","opportunity","opposite","or","orange","orbit","order","ordinary","organization","organized","origin","original","other","ought","our","ourselves","out","outer","outline","outside","over","own","owner","oxygen","pack","package","page","paid","pain","paint","pair","palace","pale","pan","paper","paragraph","parallel","parent","park","part","particles","particular","particularly","partly","parts","party","pass","passage","past","path","pattern","pay","peace","pen","pencil","people","per","percent","perfect","perfectly","perhaps","period","person","personal","pet","phrase","physical","piano","pick","picture","pictured","pie","piece","pig","pile","pilot","pine","pink","pipe","pitch","place","plain","plan","plane","planet","planned","planning","plant","plastic","plate","plates","play","pleasant","please","pleasure","plenty","plural","plus","pocket","poem","poet","poetry","point","pole","police","policeman","political","pond","pony","pool","poor","popular","population","porch","port","position","positive","possible","possibly","post","pot","potatoes","pound","pour","powder","power","powerful","practical","practice","prepare","present","president","press","pressure","pretty","prevent","previous","price","pride","primitive","principal","principle","printed","private","prize","probably","problem","process","produce","product","production","program","progress","promised","proper","properly","property","protection","proud","prove","provide","public","pull","pupil","pure","purple","purpose","push","put","putting","quarter","queen","question","quick","quickly","quiet","quietly","quite","rabbit","race","radio","railroad","rain","raise","ran","ranch","range","rapidly","rate","rather","raw","rays","reach","read","reader","ready","real","realize","rear","reason","recall","receive","recent","recently","recognize","record","red","refer","refused","region","regular","related","relationship","religious","remain","remarkable","remember","remove","repeat","replace","replied","report","represent","require","research","respect","rest","result","return","review","rhyme","rhythm","rice","rich","ride","riding","right","ring","rise","rising","river","road","roar","rock","rocket","rocky","rod","roll","roof","room","root","rope","rose","rough","round","route","row","rubbed","rubber","rule","ruler","run","running","rush","sad","saddle","safe","safety","said","sail","sale","salmon","salt","same","sand","sang","sat","satellites","satisfied","save","saved","saw","say","scale","scared","scene","school","science","scientific","scientist","score","screen","sea","search","season","seat","second","secret","section","see","seed","seeing","seems","seen","seldom","select","selection","sell","send","sense","sent","sentence","separate","series","serious","serve","service","sets","setting","settle","settlers","seven","several","shade","shadow","shake","shaking","shall","shallow","shape","share","sharp","she","sheep","sheet","shelf","shells","shelter","shine","shinning","ship","shirt","shoe","shoot","shop","shore","short","shorter","shot","should","shoulder","shout","show","shown","shut","sick","sides","sight","sign","signal","silence","silent","silk","silly","silver","similar","simple","simplest","simply","since","sing","single","sink","sister","sit","sitting","situation","six","size","skill","skin","sky","slabs","slave","sleep","slept","slide","slight","slightly","slip","slipped","slope","slow","slowly","small","smaller","smallest","smell","smile","smoke","smooth","snake","snow","so","soap","social","society","soft","softly","soil","solar","sold","soldier","solid","solution","solve","some","somebody","somehow","someone","something","sometime","somewhere","son","song","soon","sort","sound","source","south","southern","space","speak","special","species","specific","speech","speed","spell","spend","spent","spider","spin","spirit","spite","split","spoken","sport","spread","spring","square","stage","stairs","stand","standard","star","stared","start","state","statement","station","stay","steady","steam","steel","steep","stems","step","stepped","stick","stiff","still","stock","stomach","stone","stood","stop","stopped","store","storm","story","stove","straight","strange","stranger","straw","stream","street","strength","stretch","strike","string","strip","strong","stronger","struck","structure","struggle","stuck","student","studied","studying","subject","substance","success","successful","such","sudden","suddenly","sugar","suggest","suit","sum","summer","sun","sunlight","supper","supply","support","suppose","sure","surface","surprise","surrounded","swam","sweet","swept","swim","swimming","swing","swung","syllable","symbol","system","table","tail","take","taken","tales","talk","tall","tank","tape","task","taste","taught","tax","tea","teach","teacher","team","tears","teeth","telephone","television","tell","temperature","ten","tent","term","terrible","test","than","thank","that","thee","them","themselves","then","theory","there","therefore","these","they","thick","thin","thing","think","third","thirty","this","those","thou","though","thought","thousand","thread","three","threw","throat","through","throughout","throw","thrown","thumb","thus","thy","tide","tie","tight","tightly","till","time","tin","tiny","tip","tired","title","to","tobacco","today","together","told","tomorrow","tone","tongue","tonight","too","took","tool","top","topic","torn","total","touch","toward","tower","town","toy","trace","track","trade","traffic","trail","train","transportation","trap","travel","treated","tree","triangle","tribe","trick","tried","trip","troops","tropical","trouble","truck","trunk","truth","try","tube","tune","turn","twelve","twenty","twice","two","type","typical","uncle","under","underline","understanding","unhappy","union","unit","universe","unknown","unless","until","unusual","up","upon","upper","upward","us","use","useful","using","usual","usually","valley","valuable","value","vapor","variety","various","vast","vegetable","verb","vertical","very","vessels","victory","view","village","visit","visitor","voice","volume","vote","vowel","voyage","wagon","wait","walk","wall","want","war","warm","warn","was","wash","waste","watch","water","wave","way","we","weak","wealth","wear","weather","week","weigh","weight","welcome","well","went","were","west","western","wet","whale","what","whatever","wheat","wheel","when","whenever","where","wherever","whether","which","while","whispered","whistle","white","who","whole","whom","whose","why","wide","widely","wife","wild","will","willing","win","wind","window","wing","winter","wire","wise","wish","with","within","without","wolf","women","won","wonder","wonderful","wood","wooden","wool","word","wore","work","worker","world","worried","worry","worse","worth","would","wrapped","write","writer","writing","written","wrong","wrote","yard","year","yellow","yes","yesterday","yet","you","young","younger","your","yourself","youth","zero","zebra","zipper","zoo","zulu"];function je(r){const e=r!=null&&r.seed?new Mt(r.seed):null;function t(){return r&&r.maxLength>1?n():s()}function n(){for(var c=!1,h;!c;)h=s(),h.length<=r.maxLength&&(c=!0);return h}function s(){return ie[l(ie.length)]}function l(c){const h=e?e():Math.random();return Math.floor(h*c)}if(typeof r=="undefined")return t();typeof r=="number"&&(r={exactly:r}),r.exactly&&(r.min=r.exactly,r.max=r.exactly),typeof r.wordsPerString!="number"&&(r.wordsPerString=1),typeof r.formatter!="function"&&(r.formatter=c=>c),typeof r.separator!="string"&&(r.separator=" ");for(var u=r.min+l(r.max+1-r.min),a=[],i="",o=0,d=0;d<u*r.wordsPerString;d++)o===r.wordsPerString-1?i+=r.formatter(t(),o):i+=r.formatter(t(),o)+r.separator,o++,(d+1)%r.wordsPerString===0&&(a.push(i),i="",o=0);return typeof r.join=="string"&&(a=a.join(r.join)),a}var Rt=je;je.wordList=ie;var Nt=W(Rt),Dt=Object.defineProperty,Vt=Object.defineProperties,$t=Object.getOwnPropertyDescriptors,ke=Object.getOwnPropertySymbols,zt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable,Oe=(r,e,t)=>e in r?Dt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Bt=(r,e)=>{for(var t in e||(e={}))zt.call(e,t)&&Oe(r,t,e[t]);if(ke)for(var t of ke(e))qt.call(e,t)&&Oe(r,t,e[t]);return r},Ut=(r,e)=>Vt(r,$t(e));function Kt(r=Math.random().toString()){return Math.random=wt(r),r}function se(r,e,t=!1){const n=Array.isArray(r),s=Array.isArray(e);if(!n)s?(e=[e[0]],console.log("Unclear parameters given to randomization.repeat. Multiple set sizes specified, but only one item exists to sample. Proceeding using the first set size.")):(r=[r],e=[e]);else if(s){if(r.length!=e.length)if(console.warn("Unclear parameters given to randomization.repeat. Items and repetitions are unequal lengths. Behavior may not be as expected."),e.length<r.length){let a=[];for(let i=0;i<r.length;i++)a.push(e);e=a}else e=e.slice(0,r.length)}else{let a=[];for(let i=0;i<r.length;i++)a.push(e);e=a}let l=[];for(let a=0;a<r.length;a++)for(let i=0;i<e[a];i++)r[a]==null||typeof r[a]!="object"?l.push(r[a]):l.push(Object.assign({},r[a]));let u=I(l);return t&&(u=Zt(u)),u}function I(r){Array.isArray(r)||console.error("Argument to shuffle() must be an array.");const e=r.slice(0);let t=e.length,n,s;for(;t;)s=Math.floor(Math.random()*t--),n=e[t],e[t]=e[s],e[s]=n;return e}function Gt(r,e){Array.isArray(r)||console.error("First argument to shuffleNoRepeats() must be an array."),typeof e!="undefined"&&typeof e!="function"&&console.error("Second argument to shuffleNoRepeats() must be a function."),typeof e=="undefined"&&(e=function(n,s){return n===s});const t=I(r);for(let n=0;n<t.length-1;n++)if(e(t[n],t[n+1])){let s=Math.floor(Math.random()*(t.length-2))+1;for(;e(t[n+1],t[s])||e(t[n+1],t[s+1])||e(t[n+1],t[s-1])||e(t[n],t[s]);)s=Math.floor(Math.random()*(t.length-2))+1;const l=t[s];t[s]=t[n+1],t[n+1]=l}return t}function Te(r,e=!1){const t=r.length;if(t==1)return console.warn("shuffleAlternateGroups() was called with only one group. Defaulting to simple shuffle."),I(r[0]);let n=[];for(let a=0;a<t;a++)n.push(a);e&&(n=I(n));const s=[];let l=null;for(let a=0;a<t;a++)l=l===null?r[a].length:Math.min(l,r[a].length),s.push(I(r[a]));const u=[];for(let a=0;a<l;a++)for(let i=0;i<n.length;i++)u.push(s[n[i]][a]);return u}function Ae(r,e){return Array.isArray(r)||console.error("First argument to sampleWithoutReplacement() must be an array"),e>r.length&&console.error("Cannot take a sample larger than the size of the set of items to sample."),I(r).slice(0,e)}function Ce(r,e,t){Array.isArray(r)||console.error("First argument to sampleWithReplacement() must be an array");const n=[];if(typeof t!="undefined"){t.length!==r.length&&console.error("The length of the weights array must equal the length of the array to be sampled from.");let u=0;for(const a of t)u+=a;for(const a of t)n.push(a/u)}else for(let u=0;u<r.length;u++)n.push(1/r.length);const s=[n[0]];for(let u=1;u<n.length;u++)s.push(n[u]+s[u-1]);const l=[];for(let u=0;u<e;u++){const a=Math.random();let i=0;for(;a>s[i];)i++;l.push(r[i])}return l}function Ft(r,e=1,t=!1){let n=[{}];for(const[s,l]of Object.entries(r)){const u=[];for(const a of l)for(const i of n)u.push(Ut(Bt({},i),{[s]:a}));n=u}return se(n,e,t)}function Jt(r=32){let e="";const t="0123456789abcdefghjklmnopqrstuvwxyz";for(let n=0;n<r;n++)e+=t[Math.floor(Math.random()*t.length)];return e}function Wt(r,e){if(e<r)throw new Error("Upper boundary must be greater than or equal to lower boundary");return r+Math.floor(Math.random()*(e-r+1))}function Yt(r){return Math.random()<=r?1:0}function ae(r,e){return Qt()*e+r}function oe(r){return-Math.log(Math.random())/r}function Xt(r,e,t,n=!1){let s=ae(r,e)+oe(t);if(n)for(;s<=0;)s=ae(r,e)+oe(t);return s}function Ht(r){return Nt(r)}function Qt(){for(var r=0,e=0;r===0;)r=Math.random();for(;e===0;)e=Math.random();return Math.sqrt(-2*Math.log(r))*Math.cos(2*Math.PI*e)}function Zt(r){const e={};for(const t of r)for(const n of Object.keys(t))typeof e[n]=="undefined"&&(e[n]=[]),e[n].push(t[n]);return e}var er=Object.freeze({__proto__:null,factorial:Ft,randomID:Jt,randomInt:Wt,randomWords:Ht,repeat:se,sampleBernoulli:Yt,sampleExGaussian:Xt,sampleExponential:oe,sampleNormal:ae,sampleWithReplacement:Ce,sampleWithoutReplacement:Ae,setSeed:Kt,shuffle:I,shuffleAlternateGroups:Te,shuffleNoRepeats:Gt});function Se(){const r={previewMode:!1,outsideTurk:!1,hitId:"INVALID_URL_PARAMETER",assignmentId:"INVALID_URL_PARAMETER",workerId:"INVALID_URL_PARAMETER",turkSubmitTo:"INVALID_URL_PARAMETER"},e=function(n,s){s=s.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");const l="[\\?&]"+s+"=([^&#]*)",u=new RegExp(l).exec(n);return u==null?"":u[1]},t=e(window.location.href,"assignmentId")?window.location.href:document.referrer;return["assignmentId","hitId","workerId","turkSubmitTo"].map(function(n){r[n]=unescape(e(t,n))}),r.previewMode=r.assignmentId=="ASSIGNMENT_ID_NOT_AVAILABLE",r.outsideTurk=!r.previewMode&&r.hitId===""&&r.assignmentId==""&&r.workerId=="",r}function tr(r){const e=Se(),t=e.assignmentId,n=e.turkSubmitTo;if(!t||!n)return;const s=document.createElement("form");s.method="POST",s.action=n+"/mturk/externalSubmit?assignmentId="+t;for(const l in r)if(r.hasOwnProperty(l)){const u=document.createElement("input");u.type="hidden",u.name=l,u.id=l,u.value=r[l],s.appendChild(u)}document.body.appendChild(s),s.submit()}var rr=Object.freeze({__proto__:null,submitToTurk:tr,turkInfo:Se});class nr{constructor(e,t){this.containerElement=e,this.message=t,this._progress=0,this.setupElements()}setupElements(){this.messageSpan=document.createElement("span"),this.innerDiv=document.createElement("div"),this.innerDiv.id="jspsych-progressbar-inner",this.update();const e=document.createElement("div");e.id="jspsych-progressbar-outer",e.appendChild(this.innerDiv),this.containerElement.appendChild(this.messageSpan),this.containerElement.appendChild(e)}update(){this.innerDiv.style.width=this._progress*100+"%",typeof this.message=="function"?this.messageSpan.innerHTML=this.message(this._progress):this.messageSpan.innerHTML=this.message}set progress(e){if(typeof e!="number"||e<0||e>1)throw new Error("jsPsych.progressBar.progress must be a number between 0 and 1");this._progress=e,this.update()}get progress(){return this._progress}}class le{constructor(e){this.name=e}}const ir=["timeline","timeline_variables","name","repetitions","loop_function","conditional_function","randomize_order","sample","on_timeline_start","on_timeline_finish"];function sr(r){return!ue(r)}function ue(r){return!!r.timeline||Array.isArray(r)}var w=(r=>(r[r.PENDING=0]="PENDING",r[r.RUNNING=1]="RUNNING",r[r.PAUSED=2]="PAUSED",r[r.COMPLETED=3]="COMPLETED",r[r.ABORTED=4]="ABORTED",r))(w||{});class Ie{constructor(){this.reset()}reset(){this.promise=new Promise(e=>{this.resolvePromise=e})}get(){return this.promise}resolve(e){this.resolvePromise(e),this.reset()}}function ar(r){return r&&typeof r.then=="function"}function or(r){return new Promise(e=>setTimeout(e,r))}function Le([r,...e]){let t=r!=null?r:"";for(const n of e)t+=Number.isNaN(Number.parseInt(n))?`.${n}`:`[${n}]`;return t}function lr(r){return typeof r=="object"&&r!==null}class ce{constructor(){this.cache=new Map}static lookupChild(e,t){let n=!1,s;return Number.isNaN(Number.parseInt(t))?Object.hasOwn(e,t)&&(n=!0,s=e[t]):Number.parseInt(t)<e.length&&(n=!0,s=e[t]),{doesPathExist:n,value:s}}get(e){return this.cache.get(e.join("."))}has(e){return this.cache.has(e.join("."))}initialize(e){this.rootObject=e,this.cache.set("",e)}reset(){this.cache.clear(),this.cache.set("",this.rootObject)}set(e,t){this.cache.set(e.join("."),t)}lookup(e){if(this.has(e))return{doesPathExist:!0,value:this.get(e)};const t=n=>{const s=n.slice(0,-1),l=n[n.length-1];if(!this.has(s)&&s.length>0&&!t(s).doesPathExist)return{doesPathExist:!1};const u=this.get(s);if(!lr(u))return{doesPathExist:!1};const a=ce.lookupChild(u,l);return a.doesPathExist&&this.set(n,a.value),a};return t(e)}}var ur=Object.defineProperty,Me=Object.getOwnPropertySymbols,cr=Object.prototype.hasOwnProperty,hr=Object.prototype.propertyIsEnumerable,Re=(r,e,t)=>e in r?ur(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ne=(r,e)=>{for(var t in e||(e={}))cr.call(e,t)&&Re(r,t,e[t]);if(Me)for(var t of Me(e))hr.call(e,t)&&Re(r,t,e[t]);return r};class De{constructor(e){this.dependencies=e,this.status=w.PENDING,this.parameterValueCache=new ce}getStatus(){return this.status}initializeParameterValueCache(){this.parameterValueCache.initialize(this.description)}resetParameterValueCache(){var e;this.parameterValueCache.reset(),(e=this.parent)==null||e.resetParameterValueCache()}getParameterValue(e,t={}){const{evaluateFunctions:n=!0,recursive:s=!0,cacheResult:l=!0,replaceResult:u}=t;typeof e=="string"&&(e=[e]);let{doesPathExist:a,value:i}=this.parameterValueCache.lookup(e);return!a&&s&&this.parent&&(i=this.parent.getParameterValue(e,t)),typeof i=="function"&&n&&(i=i()),i instanceof le&&(i=this.evaluateTimelineVariable(i)),typeof u=="function"&&(i=u(i)),l&&this.parameterValueCache.set(e,i),i}getDataParameter(){var e;const t=this.getParameterValue("data",{recursive:!1});return Ne(Ne({},Object.fromEntries(typeof t=="object"?Object.keys(t).map(n=>[n,this.getParameterValue(["data",n])]):[])),(e=this.parent)==null?void 0:e.getDataParameter())}}var dr=Object.defineProperty,pr=Object.defineProperties,fr=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertySymbols,mr=Object.prototype.hasOwnProperty,gr=Object.prototype.propertyIsEnumerable,$e=(r,e,t)=>e in r?dr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,he=(r,e)=>{for(var t in e||(e={}))mr.call(e,t)&&$e(r,t,e[t]);if(Ve)for(var t of Ve(e))gr.call(e,t)&&$e(r,t,e[t]);return r},yr=(r,e)=>pr(r,fr(e)),de=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});class F extends De{constructor(e,t,n){var s;if(super(e),this.description=t,this.parent=n,this.onLoad=()=>{this.runParameterCallback("on_load"),this.dependencies.runOnLoadExtensionCallbacks(this.getParameterValue("extensions"))},this.initializeParameterValueCache(),this.trialObject=j(t),this.pluginClass=this.getParameterValue("type",{evaluateFunctions:!1}),this.pluginInfo=(s=this.pluginClass)==null?void 0:s.info,!this.pluginInfo)throw new Error("Plugin not recognized. Please provide a valid plugin using the 'type' parameter.");!("version"in this.pluginInfo)&&!("data"in this.pluginInfo)?console.warn(this.pluginInfo.name,"is missing the 'version' and 'data' fields. Please update plugin as 'version' and 'data' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."):"version"in this.pluginInfo?"data"in this.pluginInfo||console.warn(this.pluginInfo.name,"is missing the 'data' field. Please update plugin as 'data' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."):console.warn(this.pluginInfo.name,"is missing the 'version' field. Please update plugin as 'version' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details.")}run(){return de(this,null,function*(){var e;this.status=w.RUNNING,this.processParameters(),this.onStart(),this.addCssClasses(),this.pluginInstance=this.dependencies.instantiatePlugin(this.pluginClass),this.result=this.processResult(yield this.executeTrial()),this.dependencies.onTrialResultAvailable(this),this.status=w.COMPLETED,yield this.onFinish(),this.removeCssClasses();const t=(e=this.getParameterValue("post_trial_gap"))!=null?e:this.dependencies.getDefaultIti();t!==0&&this.dependencies.getSimulationMode()!=="data-only"&&(yield or(t)),this.resetParameterValueCache()})}executeTrial(){return de(this,null,function*(){const e=this.dependencies.finishTrialPromise.get();let t=!1;e.then(()=>{t=!0});const{trialReturnValue:n,hasTrialBeenSimulated:s}=this.invokeTrialMethod();let l;return ar(n)?(l=yield Promise.race([n,e]),t&&(l=yield e)):(s||this.onLoad(),l=yield e),this.cleanupTrial(),l})}invokeTrialMethod(){var e;const t=this.dependencies.getSimulationMode();if(t&&typeof this.pluginInstance.simulate=="function"){const n=this.getSimulationOptions();if(n.simulate!==!1)return{hasTrialBeenSimulated:!0,trialReturnValue:this.pluginInstance.simulate(this.trialObject,(e=n.mode)!=null?e:t,n,this.onLoad)}}return{hasTrialBeenSimulated:!1,trialReturnValue:this.pluginInstance.trial(this.dependencies.getDisplayElement(),this.trialObject,this.onLoad)}}cleanupTrial(){this.dependencies.clearAllTimeouts(),this.dependencies.getDisplayElement().innerHTML=""}addCssClasses(){const e=this.getParameterValue("css_classes"),t=this.dependencies.getDisplayElement().classList;typeof e=="string"?t.add(e):Array.isArray(e)&&t.add(...e)}removeCssClasses(){const e=this.getParameterValue("css_classes");e&&this.dependencies.getDisplayElement().classList.remove(...typeof e=="string"?[e]:e)}processResult(e){var t;e||(e={});for(const[s,l]of Object.entries((t=this.getParameterValue("save_trial_parameters"))!=null?t:{}))if(this.pluginInfo.parameters[s])if(l&&!Object.hasOwn(e,s)){let u=this.trialObject[s];typeof u=="function"&&(u=u.toString()),e[s]=u}else!l&&Object.hasOwn(e,s)&&delete e[s];else console.warn(`Non-existent parameter "${s}" specified in save_trial_parameters.`);e=yr(he(he({},this.getDataParameter()),e),{trial_type:this.pluginInfo.name,trial_index:this.index,plugin_version:this.pluginInfo.version?this.pluginInfo.version:null});const n=this.getParameterValue("save_timeline_variables");return n===!0?e.timeline_variables=he({},this.parent.getAllTimelineVariables()):Array.isArray(n)&&(e.timeline_variables=Object.fromEntries(Object.entries(this.parent.getAllTimelineVariables()).filter(([s,l])=>n.includes(s)))),e}runParameterCallback(e,...t){const n=this.getParameterValue(e,{evaluateFunctions:!1});if(n)return n(...t)}onStart(){this.dependencies.onTrialStart(this),this.runParameterCallback("on_start",this.trialObject),this.dependencies.runOnStartExtensionCallbacks(this.getParameterValue("extensions"))}onFinish(){return de(this,null,function*(){const e=yield this.dependencies.runOnFinishExtensionCallbacks(this.getParameterValue("extensions"));Object.assign(this.result,e),yield Promise.resolve(this.runParameterCallback("on_finish",this.getResult())),this.dependencies.onTrialFinished(this)})}evaluateTimelineVariable(e){var t;return(t=this.parent)==null?void 0:t.evaluateTimelineVariable(e)}getParameterValue(e,t={}){return ir.includes(typeof e=="string"?e:e[0])&&(t.recursive=!1),super.getParameterValue(e,t)}getSimulationOptions(){const e=this.getParameterValue("simulation_options",{replaceResult:(t={})=>{var n,s;if(typeof t=="string"){const l=this.dependencies.getGlobalSimulationOptions();t=(s=(n=l[t])!=null?n:l.default)!=null?s:{}}return K(j(this.dependencies.getGlobalSimulationOptions().default),j(t))}});return typeof e=="undefined"?{}:(e.mode=this.getParameterValue(["simulation_options","mode"]),e.simulate=this.getParameterValue(["simulation_options","simulate"]),e.data=this.getParameterValue(["simulation_options","data"]),typeof e.data=="object"&&(e.data=Object.fromEntries(Object.keys(e.data).map(t=>[t,this.getParameterValue(["simulation_options","data",t])]))),e)}getResult(){return this.getParameterValue("record_data")===!1?void 0:this.result}getResults(){const e=this.getResult();return e?[e]:[]}processParameters(){const e=(n,s,l=[])=>{for(const[u,a]of Object.entries(s)){const i=[...l,u];let o=this.getParameterValue(i,{evaluateFunctions:a.type!==T.FUNCTION,replaceResult:d=>{if(typeof d=="undefined"){if(typeof a.default=="undefined")throw new Error(`You must specify a value for the "${Le(i)}" parameter in the "${this.pluginInfo.name}" plugin.`);return a.default}else return d}});if(a.array&&!Array.isArray(o)){const d=Le(i);throw new Error(`A non-array value (\`${o}\`) was provided for the array parameter "${d}" in the "${this.pluginInfo.name}" plugin. Please make sure that "${d}" is an array.`)}a.type===T.COMPLEX&&a.nested&&(a.array?o=o.map((d,c)=>{const h=[...i,c.toString()],p=this.getParameterValue(h);return e(p,a.nested,h),p}):e(o,a.nested,i)),n[u]=o}},t=j(this.description);e(t,this.pluginInfo.parameters),this.trialObject=t}getLatestNode(){return this}getActiveTimelineByName(e){}}var vr=Object.defineProperty,ze=Object.getOwnPropertySymbols,br=Object.prototype.hasOwnProperty,wr=Object.prototype.propertyIsEnumerable,qe=(r,e,t)=>e in r?vr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Be=(r,e)=>{for(var t in e||(e={}))br.call(e,t)&&qe(r,t,e[t]);if(ze)for(var t of ze(e))wr.call(e,t)&&qe(r,t,e[t]);return r},xr=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});class L extends De{constructor(e,t,n){super(e),this.parent=n,this.children=[],this.shouldAbort=!1,this.resumePromise=new Ie,this.description=Array.isArray(t)?{timeline:t}:t,this.initializeParameterValueCache()}run(){return xr(this,null,function*(){typeof this.index=="undefined"&&(this.index=0),this.status=w.RUNNING;const{conditional_function:e,loop_function:t,repetitions:n=1}=this.description;let s=this.generateTimelineVariableOrder();this.setCurrentTimelineVariablesByIndex(s[0]);let l=!0,u;if(!e||e()){this.onStart();for(let a=0;a<n;a++)do{u=[],l?l=!1:s=this.generateTimelineVariableOrder();for(const i of s){this.setCurrentTimelineVariablesByIndex(i);for(const o of this.description.timeline){const d=this.instantiateChildNode(o),c=this.currentChild;if(this.currentChild=d,d.index=c?c.getLatestNode().index+1:this.index,yield d.run(),this.status===w.PAUSED&&(yield this.resumePromise.get()),this.shouldAbort){this.status=w.ABORTED;return}u.push(...this.currentChild.getResults())}}}while(t&&t(new b(u)));this.onFinish()}this.status=w.COMPLETED})}onStart(){this.description.on_timeline_start&&this.description.on_timeline_start()}onFinish(){this.description.on_timeline_finish&&this.description.on_timeline_finish()}pause(){this.currentChild instanceof L&&this.currentChild.pause(),this.status=w.PAUSED}resume(){this.status==w.PAUSED&&(this.currentChild instanceof L&&this.currentChild.resume(),this.status=w.RUNNING,this.resumePromise.resolve())}abort(){(this.status===w.RUNNING||this.status===w.PAUSED)&&(this.currentChild instanceof L&&this.currentChild.abort(),this.shouldAbort=!0,this.status===w.PAUSED&&this.resume())}instantiateChildNode(e){const t=ue(e)?new L(this.dependencies,e,this):new F(this.dependencies,e,this);return this.children.push(t),t}setCurrentTimelineVariablesByIndex(e){var t;this.currentTimelineVariables=Be(Be({},(t=this.parent)==null?void 0:t.getAllTimelineVariables()),e===null?void 0:this.description.timeline_variables[e])}generateTimelineVariableOrder(){var e;const t=(e=this.description.timeline_variables)==null?void 0:e.length;if(!t)return[null];let n=[...Array(t).keys()];const s=this.description.sample;if(s)switch(s.type){case"custom":n=s.fn(n);break;case"with-replacement":n=Ce(n,s.size,s.weights);break;case"without-replacement":n=Ae(n,s.size);break;case"fixed-repetitions":n=se(n,s.size);break;case"alternate-groups":n=Te(s.groups,s.randomize_group_order);break;default:throw new Error(`Invalid type "${s.type}" in timeline sample parameters. Valid options for type are "custom", "with-replacement", "without-replacement", "fixed-repetitions", and "alternate-groups"`)}return this.description.randomize_order&&(n=I(n)),n}getAllTimelineVariables(){return this.currentTimelineVariables}evaluateTimelineVariable(e){var t;if((t=this.currentTimelineVariables)!=null&&t.hasOwnProperty(e.name))return this.currentTimelineVariables[e.name];throw new Error(`Timeline variable ${e.name} not found.`)}getResults(){const e=[];for(const t of this.children)if(t instanceof F){const n=t.getResult();n&&e.push(n)}else t instanceof L&&e.push(...t.getResults());return e}getNaiveProgress(){if(this.status===w.PENDING)return 0;const e=this.getLatestNode();if(!e)return 1;let t=e.index;return e.getStatus()===w.COMPLETED&&t++,Math.min(t/this.getNaiveTrialCount(),1)}getNaiveTrialCount(){const e=t=>{var n,s,l;const u=a=>a.map(i=>e(i)).reduce((i,o)=>i+o);if(Array.isArray(t))return u(t);if(sr(t))return 1;if(ue(t)){let a=((n=t.timeline_variables)==null?void 0:n.length)||1;switch((s=t.sample)==null?void 0:s.type){case"with-replacement":case"without-replacement":a=t.sample.size;break;case"fixed-repetitions":a*=t.sample.size;break;case"alternate-groups":a=t.sample.groups.map(i=>i.length).reduce((i,o)=>i+o,0);break}return u(t.timeline)*((l=t.repetitions)!=null?l:1)*a}return 0};return e(this.description)}getLatestNode(){var e,t;return(t=(e=this.currentChild)==null?void 0:e.getLatestNode())!=null?t:this}getActiveTimelineByName(e){var t;return this.description.name===e?this:(t=this.currentChild)==null?void 0:t.getActiveTimelineByName(e)}}var Pr=Object.defineProperty,Ue=Object.getOwnPropertySymbols,Er=Object.prototype.hasOwnProperty,_r=Object.prototype.propertyIsEnumerable,Ke=(r,e,t)=>e in r?Pr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,jr=(r,e)=>{for(var t in e||(e={}))Er.call(e,t)&&Ke(r,t,e[t]);if(Ue)for(var t of Ue(e))_r.call(e,t)&&Ke(r,t,e[t]);return r},pe=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});class Ge{constructor(e){this.turk=rr,this.randomization=er,this.utils=Ye,this.citation={apa:"de Leeuw, J. R., Gilbert, R. A., & Luchterhandt, B. (2023). jsPsych: Enabling an Open-Source Collaborative Ecosystem of Behavioral Experiments. Journal of Open Source Software, 8(85), 5351. https://doi.org/10.21105/joss.05351 ",bibtex:'@article{Leeuw2023jsPsych, author = {de Leeuw, Joshua R. and Gilbert, Rebecca A. and Luchterhandt, Bj{\\" o}rn}, journal = {Journal of Open Source Software}, doi = {10.21105/joss.05351}, issn = {2475-9066}, number = {85}, year = {2023}, month = {may 11}, pages = {5351}, publisher = {Open Journals}, title = {jsPsych: Enabling an {Open}-{Source} {Collaborative} {Ecosystem} of {Behavioral} {Experiments}}, url = {https://joss.theoj.org/papers/10.21105/joss.05351}, volume = {8}, } '},this.options={},this.isFileProtocolUsed=!1,this.finishTrialPromise=new Ie,this.timelineDependencies={onTrialStart:t=>{this.options.on_trial_start(t.trialObject),this.getDisplayContainerElement().focus(),this.getDisplayElement().scrollTop=0},onTrialResultAvailable:t=>{const n=t.getResult();n&&(n.time_elapsed=this.getTotalTime(),this.data.write(t))},onTrialFinished:t=>{const n=t.getResult();this.options.on_trial_finish(n),n&&this.options.on_data_update(n),this.progressBar&&this.options.auto_update_progress_bar&&(this.progressBar.progress=this.timeline.getNaiveProgress())},runOnStartExtensionCallbacks:t=>this.extensionManager.onStart(t),runOnLoadExtensionCallbacks:t=>this.extensionManager.onLoad(t),runOnFinishExtensionCallbacks:t=>this.extensionManager.onFinish(t),getSimulationMode:()=>this.simulationMode,getGlobalSimulationOptions:()=>this.simulationOptions,instantiatePlugin:t=>new t(this),getDisplayElement:()=>this.getDisplayElement(),getDefaultIti:()=>this.getInitSettings().default_iti,finishTrialPromise:this.finishTrialPromise,clearAllTimeouts:()=>this.pluginAPI.clearAllTimeouts()},this.extensionManagerDependencies={instantiateExtension:t=>new t(this)},this.dataDependencies={getProgress:()=>{var t,n;return{time:this.getTotalTime(),trial:(n=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?n:0}},onInteractionRecordAdded:t=>{this.options.on_interaction_data_update(t)},getDisplayElement:()=>this.getDisplayElement()},e=jr({display_element:void 0,on_finish:()=>{},on_trial_start:()=>{},on_trial_finish:()=>{},on_data_update:()=>{},on_interaction_data_update:()=>{},on_close:()=>{},use_webaudio:!0,show_progress_bar:!1,message_progress_bar:"Completion Progress",auto_update_progress_bar:!0,default_iti:0,minimum_valid_rt:0,experiment_width:null,override_safe_mode:!1,case_sensitive_responses:!1,extensions:[]},e),this.options=e,Y(this),window.location.protocol=="file:"&&(e.override_safe_mode===!1||typeof e.override_safe_mode=="undefined")&&(e.use_webaudio=!1,this.isFileProtocolUsed=!0,console.warn("jsPsych detected that it is running via the file:// protocol and not on a web server. To prevent issues with cross-origin requests, Web Audio and video preloading have been disabled. If you would like to override this setting, you can set 'override_safe_mode' to 'true' in initJsPsych. For more information, see: https://www.jspsych.org/overview/running-experiments")),this.data=new nt(this.dataDependencies),this.pluginAPI=bt(this),this.extensionManager=new B(this.extensionManagerDependencies,e.extensions)}version(){return We}run(e){return pe(this,null,function*(){typeof e=="undefined"&&console.error("No timeline declared in jsPsych.run(). Cannot start experiment."),e.length===0&&console.error("No trials have been added to the timeline (the timeline is an empty array). Cannot start experiment."),this.timeline=new L(this.timelineDependencies,e),yield this.prepareDom(),yield this.extensionManager.initializeExtensions(),document.documentElement.setAttribute("jspsych","present"),this.experimentStartTime=new Date,yield this.timeline.run(),yield Promise.resolve(this.options.on_finish(this.data.get())),this.endMessage&&(this.getDisplayElement().innerHTML=this.endMessage),this.data.removeInteractionListeners()})}simulate(e){return pe(this,arguments,function*(t,n="data-only",s={}){this.simulationMode=n,this.simulationOptions=s,yield this.run(t)})}getProgress(){var e,t,n,s;return{total_trials:(e=this.timeline)==null?void 0:e.getNaiveTrialCount(),current_trial_global:(n=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?n:0,percent_complete:((s=this.timeline)==null?void 0:s.getNaiveProgress())*100}}getStartTime(){return this.experimentStartTime}getTotalTime(){return this.experimentStartTime?new Date().getTime()-this.experimentStartTime.getTime():0}getDisplayElement(){return this.displayElement}getDisplayContainerElement(){return this.displayContainerElement}abortExperiment(e,t={}){this.endMessage=e,this.timeline.abort(),this.pluginAPI.cancelAllKeyboardResponses(),this.pluginAPI.clearAllTimeouts(),this.finishTrial(t)}abortCurrentTimeline(){var e;let t=(e=this.timeline)==null?void 0:e.getLatestNode();t instanceof F&&(t=t.parent),t instanceof L&&t.abort()}abortTimelineByName(e){var t;const n=(t=this.timeline)==null?void 0:t.getActiveTimelineByName(e);n&&n.abort()}getCurrentTrial(){var e;const t=(e=this.timeline)==null?void 0:e.getLatestNode();if(t instanceof F)return t.description}getInitSettings(){return this.options}timelineVariable(e){return new le(e)}evaluateTimelineVariable(e){var t,n;return(n=(t=this.timeline)==null?void 0:t.getLatestNode())==null?void 0:n.evaluateTimelineVariable(new le(e))}pauseExperiment(){var e;(e=this.timeline)==null||e.pause()}resumeExperiment(){var e;(e=this.timeline)==null||e.resume()}getSafeModeStatus(){return this.isFileProtocolUsed}getTimeline(){var e;return(e=this.timeline)==null?void 0:e.description.timeline}getCitations(e=[],t="apa"){const n=["apa","bibtex"];if(t=t.toLowerCase(),Array.isArray(e))if(n.includes(t)){const s=this.citation[t],l=new Set([s]);for(const u of e)try{const a=u.info.citations[t];l.add(a)}catch(a){console.error(`${u} does not have citation in ${t} format.`)}return Array.from(l).join(`
|
|
6
|
-
`)}else throw new Error("Unsupported citation format");else throw new Error("Expected array of plugins/extensions")}get extensions(){var e,t;return(t=(e=this.extensionManager)==null?void 0:e.extensions)!=null?t:{}}prepareDom(){return
|
|
7
|
-
//# sourceMappingURL=https://unpkg.com/jspsych@8.2.
|
|
3
|
+
`}return n}function Qe(){const r=window.location.search.substr(1).split("&"),e={};for(let t=0;t<r.length;++t){const n=r[t].split("=",2);n.length==1?e[n[0]]="":e[n[0]]=decodeURIComponent(n[1].replace(/\+/g," "))}return e}class w{constructor(e=[]){this.trials=e}push(e){return this.trials.push(e),this}join(e){return this.trials=this.trials.concat(e.values()),this}top(){return this.trials.length<=1?this:new w([this.trials[this.trials.length-1]])}first(e=1){if(e<1)throw`You must query with a positive nonzero integer. Please use a
|
|
4
|
+
different value for n.`;return this.trials.length===0?new w:(e>this.trials.length&&(e=this.trials.length),new w(this.trials.slice(0,e)))}last(e=1){if(e<1)throw`You must query with a positive nonzero integer. Please use a
|
|
5
|
+
different value for n.`;return this.trials.length===0?new w:(e>this.trials.length&&(e=this.trials.length),new w(this.trials.slice(this.trials.length-e,this.trials.length)))}values(){return this.trials}count(){return this.trials.length}readOnly(){return new w(j(this.trials))}addToAll(e){for(const t of this.trials)Object.assign(t,e);return this}addToLast(e){return this.trials.length>0&&Object.assign(this.trials[this.trials.length-1],e),this}filter(e){let t;Array.isArray(e)?t=j(e):t=j([e]);const n=[];for(const s of this.trials){let l=!1;for(const u of t){let a=!0;for(const i of Object.keys(u))typeof s[i]!="undefined"&&s[i]===u[i]||(a=!1);if(a){l=!0;break}}l&&n.push(s)}return new w(n)}filterCustom(e){return new w(this.trials.filter(e))}filterColumns(e){return new w(this.trials.map(t=>Object.fromEntries(e.filter(n=>n in t).map(n=>[n,t[n]]))))}select(e){const t=[];for(const n of this.trials)typeof n[e]!="undefined"&&t.push(n[e]);return new H(t)}ignore(e){Array.isArray(e)||(e=[e]);const t=j(this.trials);for(const n of t)for(const s of e)delete n[s];return new w(t)}uniqueNames(){const e=[];for(const t of this.trials)for(const n of Object.keys(t))e.includes(n)||e.push(n);return e}csv(){return He(this.trials)}json(e=!1){return e?JSON.stringify(this.trials,null," "):JSON.stringify(this.trials)}localSave(e,t){e=e.toLowerCase();let n;if(e==="json")n=this.json();else if(e==="csv")n=this.csv();else throw new Error('Invalid format specified for localSave. Must be "json" or "csv".');Xe(n,t)}}var Ze=Object.defineProperty,ge=Object.getOwnPropertySymbols,et=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable,ye=(r,e,t)=>e in r?Ze(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rt=(r,e)=>{for(var t in e||(e={}))et.call(e,t)&&ye(r,t,e[t]);if(ge)for(var t of ge(e))tt.call(e,t)&&ye(r,t,e[t]);return r};class nt{constructor(e){this.dependencies=e,this.dataProperties={},this.interactionListeners={blur:()=>{this.addInteractionRecord("blur")},focus:()=>{this.addInteractionRecord("focus")},fullscreenchange:()=>{this.addInteractionRecord(document.isFullScreen||document.webkitIsFullScreen||document.mozIsFullScreen||document.fullscreenElement?"fullscreenenter":"fullscreenexit")}},this.reset()}reset(){this.results=new w,this.resultToTrialMap=new WeakMap,this.interactionRecords=new w}get(){return this.results}getInteractionData(){return this.interactionRecords}write(e){const t=e.getResult();Object.assign(t,this.dataProperties),this.results.push(t),this.resultToTrialMap.set(t,e)}addProperties(e){this.results.addToAll(e),this.dataProperties=Object.assign({},this.dataProperties,e)}addDataToLastTrial(e){this.results.addToLast(e)}getLastTrialData(){return this.results.top()}getLastTimelineData(){const e=this.getLastTrialData().values()[0];return new w(e?this.resultToTrialMap.get(e).parent.getResults():[])}displayData(e="json"){e=e.toLowerCase(),e!=="json"&&e!=="csv"&&(console.log("Invalid format declared for displayData function. Using json as default."),e="json");const t=document.createElement("pre");t.id="jspsych-data-display",t.textContent=e==="json"?this.results.json(!0):this.results.csv(),this.dependencies.getDisplayElement().replaceChildren(t)}urlVariables(){return typeof this.query_string=="undefined"&&(this.query_string=Qe()),this.query_string}getURLVariable(e){return this.urlVariables()[e]}addInteractionRecord(e){const t=rt({event:e},this.dependencies.getProgress());this.interactionRecords.push(t),this.dependencies.onInteractionRecordAdded(t)}createInteractionListeners(){window.addEventListener("blur",this.interactionListeners.blur),window.addEventListener("focus",this.interactionListeners.focus),document.addEventListener("fullscreenchange",this.interactionListeners.fullscreenchange),document.addEventListener("mozfullscreenchange",this.interactionListeners.fullscreenchange),document.addEventListener("webkitfullscreenchange",this.interactionListeners.fullscreenchange)}removeInteractionListeners(){window.removeEventListener("blur",this.interactionListeners.blur),window.removeEventListener("focus",this.interactionListeners.focus),document.removeEventListener("fullscreenchange",this.interactionListeners.fullscreenchange),document.removeEventListener("mozfullscreenchange",this.interactionListeners.fullscreenchange),document.removeEventListener("webkitfullscreenchange",this.interactionListeners.fullscreenchange)}}class it{constructor(e,t=!1,n=0){this.getRootElement=e,this.areResponsesCaseSensitive=t,this.minimumValidRt=n,this.listeners=new Set,this.heldKeys=new Set,this.areRootListenersRegistered=!1,X(this),this.registerRootListeners()}registerRootListeners(){if(!this.areRootListenersRegistered){const e=this.getRootElement();e&&(e.addEventListener("keydown",this.rootKeydownListener),e.addEventListener("keyup",this.rootKeyupListener),this.areRootListenersRegistered=!0)}}rootKeydownListener(e){for(const t of[...this.listeners])t(e);this.heldKeys.add(this.toLowerCaseIfInsensitive(e.key))}toLowerCaseIfInsensitive(e){return this.areResponsesCaseSensitive?e:e.toLowerCase()}rootKeyupListener(e){this.heldKeys.delete(this.toLowerCaseIfInsensitive(e.key))}isResponseValid(e,t,n){return!t&&this.heldKeys.has(n)?!1:e==="ALL_KEYS"?!0:e==="NO_KEYS"?!1:e.includes(n)}getKeyboardResponse({callback_function:e,valid_responses:t="ALL_KEYS",rt_method:n="performance",persist:s,audio_context:l,audio_context_start_time:u,allow_held_key:a=!1,minimum_valid_rt:i=this.minimumValidRt}){n!=="performance"&&n!=="audio"&&(console.log('Invalid RT method specified in getKeyboardResponse. Defaulting to "performance" method.'),n="performance");const o=n==="performance"?performance.now():u*1e3;this.registerRootListeners(),!this.areResponsesCaseSensitive&&typeof t!="string"&&(t=t.map(c=>c.toLowerCase()));const h=c=>{const d=Math.round((n=="performance"?performance.now():l.currentTime*1e3)-o);if(d<i)return;const p=this.toLowerCaseIfInsensitive(c.key);this.isResponseValid(t,a,p)&&(c.preventDefault(),s||this.cancelKeyboardResponse(h),e({key:c.key,rt:d}))};return this.listeners.add(h),h}cancelKeyboardResponse(e){this.listeners.delete(e)}cancelAllKeyboardResponses(){this.listeners.clear()}compareKeys(e,t){if(typeof e!="string"&&e!==null||typeof t!="string"&&t!==null){console.error("Error in jsPsych.pluginAPI.compareKeys: arguments must be key strings or null.");return}return typeof e=="string"&&typeof t=="string"?this.areResponsesCaseSensitive?e===t:e.toLowerCase()===t.toLowerCase():e===null&&t===null}}var y=(r=>(r[r.BOOL=0]="BOOL",r[r.STRING=1]="STRING",r[r.INT=2]="INT",r[r.FLOAT=3]="FLOAT",r[r.FUNCTION=4]="FUNCTION",r[r.KEY=5]="KEY",r[r.KEYS=6]="KEYS",r[r.SELECT=7]="SELECT",r[r.HTML_STRING=8]="HTML_STRING",r[r.IMAGE=9]="IMAGE",r[r.AUDIO=10]="AUDIO",r[r.VIDEO=11]="VIDEO",r[r.OBJECT=12]="OBJECT",r[r.COMPLEX=13]="COMPLEX",r[r.TIMELINE=14]="TIMELINE",r))(y||{}),Q=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});class F{constructor(e,t={useWebAudio:!1}){this.src=e,this.useWebAudio=t.useWebAudio,this.audioContext=t.audioContext||null}load(){return Q(this,null,function*(){this.useWebAudio?this.webAudioBuffer=yield this.preloadWebAudio(this.src):this.audio=yield this.preloadHTMLAudio(this.src)})}play(){this.audio instanceof HTMLAudioElement?this.audio.play():(this.audio||(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.start())}stop(){this.audio instanceof HTMLAudioElement?(this.audio.pause(),this.audio.currentTime=0):(this.audio.stop(),this.audio=this.getAudioSourceNode(this.webAudioBuffer))}addEventListener(e,t){!this.audio&&this.webAudioBuffer&&(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.addEventListener(e,t)}removeEventListener(e,t){!this.audio&&this.webAudioBuffer&&(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.removeEventListener(e,t)}getAudioSourceNode(e){const t=this.audioContext.createBufferSource();return t.buffer=e,t.connect(this.audioContext.destination),t}preloadWebAudio(e){return Q(this,null,function*(){const t=yield(yield fetch(e)).arrayBuffer(),n=yield this.audioContext.decodeAudioData(t),s=this.audioContext.createBufferSource();return s.buffer=n,s.connect(this.audioContext.destination),n})}preloadHTMLAudio(e){return Q(this,null,function*(){return new Promise((t,n)=>{const s=new Audio(e);s.addEventListener("canplaythrough",()=>{t(s)}),s.addEventListener("error",l=>{n(l)}),s.addEventListener("abort",l=>{n(l)})})})}}var st=Object.defineProperty,at=Object.defineProperties,ot=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,lt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,be=(r,e,t)=>e in r?st(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ct=(r,e)=>{for(var t in e||(e={}))lt.call(e,t)&&be(r,t,e[t]);if(ve)for(var t of ve(e))ut.call(e,t)&&be(r,t,e[t]);return r},ht=(r,e)=>at(r,ot(e)),dt=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});const we=[y.AUDIO,y.IMAGE,y.VIDEO];class pt{constructor(e){this.useWebaudio=e,this.video_buffers={},this.context=null,this.audio_buffers=[],this.preload_requests=[],this.img_cache={},this.preloadMap=new Map,this.microphone_recorder=null,this.camera_stream=null,this.camera_recorder=null,this.useWebaudio&&typeof window!="undefined"&&typeof window.AudioContext!="undefined"&&(this.context=new AudioContext)}getVideoBuffer(e){return e.startsWith("blob:")&&(this.video_buffers[e]=e),this.video_buffers[e]}audioContext(){return this.context&&this.context.state!=="running"&&this.context.resume(),this.context}getAudioPlayer(e){return dt(this,null,function*(){return this.audio_buffers[e]instanceof F?this.audio_buffers[e]:(this.audio_buffers[e]=new F(e,{useWebAudio:this.useWebaudio,audioContext:this.context}),yield this.audio_buffers[e].load(),this.audio_buffers[e])})}preloadAudio(e,t=()=>{},n=l=>{},s=l=>{}){e=K(e.flat());let l=0;if(e.length==0){t();return}for(const u of e)this.audio_buffers[u]instanceof F?(l++,n(u),l==e.length&&t()):(this.audio_buffers[u]=new F(u,{useWebAudio:this.useWebaudio,audioContext:this.context}),this.audio_buffers[u].load().then(()=>{l++,n(u),l==e.length&&t()}).catch(a=>{s(a)}))}preloadImages(e,t=()=>{},n=l=>{},s=l=>{}){e=K(e.flat());var l=0;if(e.length===0){t();return}for(let u=0;u<e.length;u++){const a=new Image,i=e[u];a.onload=()=>{l++,n(i),l===e.length&&t()},a.onerror=o=>{s({source:i,error:o})},a.src=i,this.img_cache[i]=a,this.preload_requests.push(a)}}preloadVideo(e,t=()=>{},n=l=>{},s=l=>{}){e=K(e.flat());let l=0;if(e.length===0){t();return}for(const u of e){const a=this.video_buffers,i=new XMLHttpRequest;i.open("GET",u,!0),i.responseType="blob",i.onload=()=>{if(i.status===200||i.status===0){const o=i.response;a[u]=URL.createObjectURL(o),l++,n(u),l===e.length&&t()}},i.onerror=o=>{let h=o;i.status==404&&(h="404"),s({source:u,error:h})},i.onloadend=o=>{i.status==404&&s({source:u,error:"404"})},i.send(),this.preload_requests.push(i)}}getAutoPreloadList(e){const t=Object.fromEntries(we.map(s=>[s,new Set])),n=(s,l)=>{var u,a,i,o;if(typeof s.timeline!="undefined")for(const h of s.timeline)n(h,(u=s.type)!=null?u:l);else if((i=(a=s.type)!=null?a:l)!=null&&i.info){const{name:h,parameters:c}=((o=s.type)!=null?o:l).info;this.preloadMap.has(h)||this.preloadMap.set(h,Object.fromEntries(Object.entries(c).filter(([d,{type:p,preload:f}])=>we.includes(p)&&(f!=null?f:!0)).map(([d,{type:p}])=>[d,p])));for(const[d,p]of Object.entries(this.preloadMap.get(h))){const f=s[d],E=t[p];if(typeof f=="string")E.add(f);else if(Array.isArray(f))for(const k of f.flat())typeof k=="string"&&E.add(k)}}};return n({timeline:e}),{images:[...t[y.IMAGE]],audio:[...t[y.AUDIO]],video:[...t[y.VIDEO]]}}cancelPreloads(){for(const e of this.preload_requests)e.onload=()=>{},e.onerror=()=>{},e.oncanplaythrough=()=>{},e.onabort=()=>{};this.preload_requests=[]}initializeMicrophoneRecorder(e){const t=new MediaRecorder(e);this.microphone_recorder=t}getMicrophoneRecorder(){return this.microphone_recorder}initializeCameraRecorder(e,t){let n=this.getCompatibleMimeType()||"video/webm";const s=ht(ct({},t),{mimeType:n});this.camera_stream=e;const l=new MediaRecorder(e,s);this.camera_recorder=l}getCompatibleMimeType(){const e=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4;codecs=h264,aac","video/mp4;codecs=hevc,aac"];for(const t of e)if(MediaRecorder.isTypeSupported(t))return t;return null}getCameraStream(){return this.camera_stream}getCameraRecorder(){return this.camera_recorder}}var ft=Object.defineProperty,xe=Object.getOwnPropertySymbols,mt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable,Ee=(r,e,t)=>e in r?ft(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Pe=(r,e)=>{for(var t in e||(e={}))mt.call(e,t)&&Ee(r,t,e[t]);if(xe)for(var t of xe(e))gt.call(e,t)&&Ee(r,t,e[t]);return r};class yt{constructor(e,t){this.getDisplayContainerElement=e,this.setJsPsychTimeout=t}dispatchEvent(e){this.getDisplayContainerElement().dispatchEvent(e)}keyDown(e){this.dispatchEvent(new KeyboardEvent("keydown",{key:e}))}keyUp(e){this.dispatchEvent(new KeyboardEvent("keyup",{key:e}))}pressKey(e,t=0){t>0?this.setJsPsychTimeout(()=>{this.keyDown(e),this.keyUp(e)},t):(this.keyDown(e),this.keyUp(e))}clickTarget(e,t=0){t>0?this.setJsPsychTimeout(()=>{e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0})),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))},t):(e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0})),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0})))}fillTextInput(e,t,n=0){n>0?this.setJsPsychTimeout(()=>{e.value=t},n):e.value=t}getValidKey(e){const t=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"," "];let n;if(e=="NO_KEYS")n=null;else if(e=="ALL_KEYS")n=t[Math.floor(Math.random()*t.length)];else{const s=e.flat();n=s[Math.floor(Math.random()*s.length)]}return n}mergeSimulationData(e,t){return Pe(Pe({},e),t==null?void 0:t.data)}ensureSimulationDataConsistency(e,t){if(t.rt&&(t.rt=Math.round(t.rt)),e.trial_duration&&t.rt&&t.rt>e.trial_duration&&(t.rt=null,t.response&&(t.response=null),t.correct&&(t.correct=!1)),e.choices&&e.choices=="NO_KEYS"&&(t.rt&&(t.rt=null),t.response&&(t.response=null)),e.allow_response_before_complete&&e.sequence_reps&&e.frame_time){const n=e.sequence_reps*e.frame_time*e.stimuli.length;t.rt<n&&(t.rt=null,t.response=null)}}}class vt{constructor(){this.timeout_handlers=[]}setTimeout(e,t){const n=window.setTimeout(e,t);return this.timeout_handlers.push(n),n}clearAllTimeouts(){for(const e of this.timeout_handlers)clearTimeout(e);this.timeout_handlers=[]}}function bt(r){const e=r.getInitSettings(),t=new it(r.getDisplayContainerElement,e.case_sensitive_responses,e.minimum_valid_rt),n=new vt,s=new pt(e.use_webaudio),l=new yt(r.getDisplayContainerElement,n.setTimeout.bind(n));return Object.assign({},...[t,n,s,l].map(u=>X(u)))}var Z={exports:{}};Z.exports,function(r){(function(e,t,n){function s(i){var o=this,h=a();o.next=function(){var c=2091639*o.s0+o.c*23283064365386963e-26;return o.s0=o.s1,o.s1=o.s2,o.s2=c-(o.c=c|0)},o.c=1,o.s0=h(" "),o.s1=h(" "),o.s2=h(" "),o.s0-=h(i),o.s0<0&&(o.s0+=1),o.s1-=h(i),o.s1<0&&(o.s1+=1),o.s2-=h(i),o.s2<0&&(o.s2+=1),h=null}function l(i,o){return o.c=i.c,o.s0=i.s0,o.s1=i.s1,o.s2=i.s2,o}function u(i,o){var h=new s(i),c=o&&o.state,d=h.next;return d.int32=function(){return h.next()*4294967296|0},d.double=function(){return d()+(d()*2097152|0)*11102230246251565e-32},d.quick=d,c&&(typeof c=="object"&&l(c,h),d.state=function(){return l(h,{})}),d}function a(){var i=4022871197,o=function(h){h=String(h);for(var c=0;c<h.length;c++){i+=h.charCodeAt(c);var d=.02519603282416938*i;i=d>>>0,d-=i,d*=i,i=d>>>0,d-=i,i+=d*4294967296}return(i>>>0)*23283064365386963e-26};return o}t&&t.exports?t.exports=u:this.alea=u})(D,r)}(Z);var _e=Z.exports,wt=Y(_e),ee={exports:{}};ee.exports,function(r){(function(e,t,n){function s(a){var i=this,o="";i.x=0,i.y=0,i.z=0,i.w=0,i.next=function(){var c=i.x^i.x<<11;return i.x=i.y,i.y=i.z,i.z=i.w,i.w^=i.w>>>19^c^c>>>8},a===(a|0)?i.x=a:o+=a;for(var h=0;h<o.length+64;h++)i.x^=o.charCodeAt(h)|0,i.next()}function l(a,i){return i.x=a.x,i.y=a.y,i.z=a.z,i.w=a.w,i}function u(a,i){var o=new s(a),h=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var d=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,h&&(typeof h=="object"&&l(h,o),c.state=function(){return l(o,{})}),c}t&&t.exports?t.exports=u:this.xor128=u})(D,r)}(ee);var xt=ee.exports,te={exports:{}};te.exports,function(r){(function(e,t,n){function s(a){var i=this,o="";i.next=function(){var c=i.x^i.x>>>2;return i.x=i.y,i.y=i.z,i.z=i.w,i.w=i.v,(i.d=i.d+362437|0)+(i.v=i.v^i.v<<4^(c^c<<1))|0},i.x=0,i.y=0,i.z=0,i.w=0,i.v=0,a===(a|0)?i.x=a:o+=a;for(var h=0;h<o.length+64;h++)i.x^=o.charCodeAt(h)|0,h==o.length&&(i.d=i.x<<10^i.x>>>4),i.next()}function l(a,i){return i.x=a.x,i.y=a.y,i.z=a.z,i.w=a.w,i.v=a.v,i.d=a.d,i}function u(a,i){var o=new s(a),h=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var d=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,h&&(typeof h=="object"&&l(h,o),c.state=function(){return l(o,{})}),c}t&&t.exports?t.exports=u:this.xorwow=u})(D,r)}(te);var Et=te.exports,re={exports:{}};re.exports,function(r){(function(e,t,n){function s(a){var i=this;i.next=function(){var h=i.x,c=i.i,d,p;return d=h[c],d^=d>>>7,p=d^d<<24,d=h[c+1&7],p^=d^d>>>10,d=h[c+3&7],p^=d^d>>>3,d=h[c+4&7],p^=d^d<<7,d=h[c+7&7],d=d^d<<13,p^=d^d<<9,h[c]=p,i.i=c+1&7,p};function o(h,c){var d,p=[];if(c===(c|0))p[0]=c;else for(c=""+c,d=0;d<c.length;++d)p[d&7]=p[d&7]<<15^c.charCodeAt(d)+p[d+1&7]<<13;for(;p.length<8;)p.push(0);for(d=0;d<8&&p[d]===0;++d);for(d==8?p[7]=-1:p[d],h.x=p,h.i=0,d=256;d>0;--d)h.next()}o(i,a)}function l(a,i){return i.x=a.x.slice(),i.i=a.i,i}function u(a,i){a==null&&(a=+new Date);var o=new s(a),h=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var d=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,h&&(h.x&&l(h,o),c.state=function(){return l(o,{})}),c}t&&t.exports?t.exports=u:this.xorshift7=u})(D,r)}(re);var Pt=re.exports,ne={exports:{}};ne.exports,function(r){(function(e,t,n){function s(a){var i=this;i.next=function(){var h=i.w,c=i.X,d=i.i,p,f;return i.w=h=h+1640531527|0,f=c[d+34&127],p=c[d=d+1&127],f^=f<<13,p^=p<<17,f^=f>>>15,p^=p>>>12,f=c[d]=f^p,i.i=d,f+(h^h>>>16)|0};function o(h,c){var d,p,f,E,k,A=[],z=128;for(c===(c|0)?(p=c,c=null):(c=c+"\0",p=0,z=Math.max(z,c.length)),f=0,E=-32;E<z;++E)c&&(p^=c.charCodeAt((E+32)%c.length)),E===0&&(k=p),p^=p<<10,p^=p>>>15,p^=p<<4,p^=p>>>13,E>=0&&(k=k+1640531527|0,d=A[E&127]^=p+k,f=d==0?f+1:0);for(f>=128&&(A[(c&&c.length||0)&127]=-1),f=127,E=512;E>0;--E)p=A[f+34&127],d=A[f=f+1&127],p^=p<<13,d^=d<<17,p^=p>>>15,d^=d>>>12,A[f]=p^d;h.w=k,h.X=A,h.i=f}o(i,a)}function l(a,i){return i.i=a.i,i.w=a.w,i.X=a.X.slice(),i}function u(a,i){a==null&&(a=+new Date);var o=new s(a),h=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var d=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,h&&(h.X&&l(h,o),c.state=function(){return l(o,{})}),c}t&&t.exports?t.exports=u:this.xor4096=u})(D,r)}(ne);var _t=ne.exports,ie={exports:{}};ie.exports,function(r){(function(e,t,n){function s(a){var i=this,o="";i.next=function(){var c=i.b,d=i.c,p=i.d,f=i.a;return c=c<<25^c>>>7^d,d=d-p|0,p=p<<24^p>>>8^f,f=f-c|0,i.b=c=c<<20^c>>>12^d,i.c=d=d-p|0,i.d=p<<16^d>>>16^f,i.a=f-c|0},i.a=0,i.b=0,i.c=-1640531527,i.d=1367130551,a===Math.floor(a)?(i.a=a/4294967296|0,i.b=a|0):o+=a;for(var h=0;h<o.length+20;h++)i.b^=o.charCodeAt(h)|0,i.next()}function l(a,i){return i.a=a.a,i.b=a.b,i.c=a.c,i.d=a.d,i}function u(a,i){var o=new s(a),h=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var d=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,h&&(typeof h=="object"&&l(h,o),c.state=function(){return l(o,{})}),c}t&&t.exports?t.exports=u:this.tychei=u})(D,r)}(ie);var Tt=ie.exports,Te={exports:{}};(function(r){(function(e,t,n){var s=256,l=6,u=52,a="random",i=n.pow(s,l),o=n.pow(2,u),h=o*2,c=s-1,d;function p(m,g,P){var b=[];g=g==!0?{entropy:!0}:g||{};var v=A(k(g.entropy?[m,q(t)]:m==null?z():m,3),b),_=new f(b),O=function(){for(var T=_.g(l),L=i,I=0;T<o;)T=(T+I)*s,L*=s,I=_.g(1);for(;T>=h;)T/=2,L/=2,I>>>=1;return(T+I)/L};return O.int32=function(){return _.g(4)|0},O.quick=function(){return _.g(4)/4294967296},O.double=O,A(q(_.S),t),(g.pass||P||function(T,L,I,N){return N&&(N.S&&E(N,_),T.state=function(){return E(_,{})}),I?(n[a]=T,L):T})(O,v,"global"in g?g.global:this==n,g.state)}function f(m){var g,P=m.length,b=this,v=0,_=b.i=b.j=0,O=b.S=[];for(P||(m=[P++]);v<s;)O[v]=v++;for(v=0;v<s;v++)O[v]=O[_=c&_+m[v%P]+(g=O[v])],O[_]=g;(b.g=function(T){for(var L,I=0,N=b.i,W=b.j,B=b.S;T--;)L=B[N=c&N+1],I=I*s+B[c&(B[N]=B[W=c&W+L])+(B[W]=L)];return b.i=N,b.j=W,I})(s)}function E(m,g){return g.i=m.i,g.j=m.j,g.S=m.S.slice(),g}function k(m,g){var P=[],b=typeof m,v;if(g&&b=="object")for(v in m)try{P.push(k(m[v],g-1))}catch(_){}return P.length?P:b=="string"?m:m+"\0"}function A(m,g){for(var P=m+"",b,v=0;v<P.length;)g[c&v]=c&(b^=g[c&v]*19)+P.charCodeAt(v++);return q(g)}function z(){try{var m;return d&&(m=d.randomBytes)?m=m(s):(m=new Uint8Array(s),(e.crypto||e.msCrypto).getRandomValues(m)),q(m)}catch(b){var g=e.navigator,P=g&&g.plugins;return[+new Date,e,P,e.screen,q(t)]}}function q(m){return String.fromCharCode.apply(0,m)}if(A(n.random(),t),r.exports){r.exports=p;try{d=require("crypto")}catch(m){}}else n["seed"+a]=p})(typeof self!="undefined"?self:D,[],Math)})(Te);var jt=Te.exports,kt=_e,Ot=xt,At=Et,It=Pt,St=_t,Lt=Tt,V=jt;V.alea=kt,V.xor128=Ot,V.xorwow=At,V.xorshift7=It,V.xor4096=St,V.tychei=Lt;var Ct=V,Mt=Ct,se=["ability","able","aboard","about","above","accept","accident","according","account","accurate","acres","across","act","action","active","activity","actual","actually","add","addition","additional","adjective","adult","adventure","advice","affect","afraid","after","afternoon","again","against","age","ago","agree","ahead","aid","air","airplane","alike","alive","all","allow","almost","alone","along","aloud","alphabet","already","also","although","am","among","amount","ancient","angle","angry","animal","announced","another","answer","ants","any","anybody","anyone","anything","anyway","anywhere","apart","apartment","appearance","apple","applied","appropriate","are","area","arm","army","around","arrange","arrangement","arrive","arrow","art","article","as","aside","ask","asleep","at","ate","atmosphere","atom","atomic","attached","attack","attempt","attention","audience","author","automobile","available","average","avoid","aware","away","baby","back","bad","badly","bag","balance","ball","balloon","band","bank","bar","bare","bark","barn","base","baseball","basic","basis","basket","bat","battle","be","bean","bear","beat","beautiful","beauty","became","because","become","becoming","bee","been","before","began","beginning","begun","behavior","behind","being","believed","bell","belong","below","belt","bend","beneath","bent","beside","best","bet","better","between","beyond","bicycle","bigger","biggest","bill","birds","birth","birthday","bit","bite","black","blank","blanket","blew","blind","block","blood","blow","blue","board","boat","body","bone","book","border","born","both","bottle","bottom","bound","bow","bowl","box","boy","brain","branch","brass","brave","bread","break","breakfast","breath","breathe","breathing","breeze","brick","bridge","brief","bright","bring","broad","broke","broken","brother","brought","brown","brush","buffalo","build","building","built","buried","burn","burst","bus","bush","business","busy","but","butter","buy","by","cabin","cage","cake","call","calm","came","camera","camp","can","canal","cannot","cap","capital","captain","captured","car","carbon","card","care","careful","carefully","carried","carry","case","cast","castle","cat","catch","cattle","caught","cause","cave","cell","cent","center","central","century","certain","certainly","chain","chair","chamber","chance","change","changing","chapter","character","characteristic","charge","chart","check","cheese","chemical","chest","chicken","chief","child","children","choice","choose","chose","chosen","church","circle","circus","citizen","city","class","classroom","claws","clay","clean","clear","clearly","climate","climb","clock","close","closely","closer","cloth","clothes","clothing","cloud","club","coach","coal","coast","coat","coffee","cold","collect","college","colony","color","column","combination","combine","come","comfortable","coming","command","common","community","company","compare","compass","complete","completely","complex","composed","composition","compound","concerned","condition","congress","connected","consider","consist","consonant","constantly","construction","contain","continent","continued","contrast","control","conversation","cook","cookies","cool","copper","copy","corn","corner","correct","correctly","cost","cotton","could","count","country","couple","courage","course","court","cover","cow","cowboy","crack","cream","create","creature","crew","crop","cross","crowd","cry","cup","curious","current","curve","customs","cut","cutting","daily","damage","dance","danger","dangerous","dark","darkness","date","daughter","dawn","day","dead","deal","dear","death","decide","declared","deep","deeply","deer","definition","degree","depend","depth","describe","desert","design","desk","detail","determine","develop","development","diagram","diameter","did","die","differ","difference","different","difficult","difficulty","dig","dinner","direct","direction","directly","dirt","dirty","disappear","discover","discovery","discuss","discussion","disease","dish","distance","distant","divide","division","do","doctor","does","dog","doing","doll","dollar","done","donkey","door","dot","double","doubt","down","dozen","draw","drawn","dream","dress","drew","dried","drink","drive","driven","driver","driving","drop","dropped","drove","dry","duck","due","dug","dull","during","dust","duty","each","eager","ear","earlier","early","earn","earth","easier","easily","east","easy","eat","eaten","edge","education","effect","effort","egg","eight","either","electric","electricity","element","elephant","eleven","else","empty","end","enemy","energy","engine","engineer","enjoy","enough","enter","entire","entirely","environment","equal","equally","equator","equipment","escape","especially","essential","establish","even","evening","event","eventually","ever","every","everybody","everyone","everything","everywhere","evidence","exact","exactly","examine","example","excellent","except","exchange","excited","excitement","exciting","exclaimed","exercise","exist","expect","experience","experiment","explain","explanation","explore","express","expression","extra","eye","face","facing","fact","factor","factory","failed","fair","fairly","fall","fallen","familiar","family","famous","far","farm","farmer","farther","fast","fastened","faster","fat","father","favorite","fear","feathers","feature","fed","feed","feel","feet","fell","fellow","felt","fence","few","fewer","field","fierce","fifteen","fifth","fifty","fight","fighting","figure","fill","film","final","finally","find","fine","finest","finger","finish","fire","fireplace","firm","first","fish","five","fix","flag","flame","flat","flew","flies","flight","floating","floor","flow","flower","fly","fog","folks","follow","food","foot","football","for","force","foreign","forest","forget","forgot","forgotten","form","former","fort","forth","forty","forward","fought","found","four","fourth","fox","frame","free","freedom","frequently","fresh","friend","friendly","frighten","frog","from","front","frozen","fruit","fuel","full","fully","fun","function","funny","fur","furniture","further","future","gain","game","garage","garden","gas","gasoline","gate","gather","gave","general","generally","gentle","gently","get","getting","giant","gift","girl","give","given","giving","glad","glass","globe","go","goes","gold","golden","gone","good","goose","got","government","grabbed","grade","gradually","grain","grandfather","grandmother","graph","grass","gravity","gray","great","greater","greatest","greatly","green","grew","ground","group","grow","grown","growth","guard","guess","guide","gulf","gun","habit","had","hair","half","halfway","hall","hand","handle","handsome","hang","happen","happened","happily","happy","harbor","hard","harder","hardly","has","hat","have","having","hay","he","headed","heading","health","heard","hearing","heart","heat","heavy","height","held","hello","help","helpful","her","herd","here","herself","hidden","hide","high","higher","highest","highway","hill","him","himself","his","history","hit","hold","hole","hollow","home","honor","hope","horn","horse","hospital","hot","hour","house","how","however","huge","human","hundred","hung","hungry","hunt","hunter","hurried","hurry","hurt","husband","ice","idea","identity","if","ill","image","imagine","immediately","importance","important","impossible","improve","in","inch","include","including","income","increase","indeed","independent","indicate","individual","industrial","industry","influence","information","inside","instance","instant","instead","instrument","interest","interior","into","introduced","invented","involved","iron","is","island","it","its","itself","jack","jar","jet","job","join","joined","journey","joy","judge","jump","jungle","just","keep","kept","key","kids","kill","kind","kitchen","knew","knife","know","knowledge","known","label","labor","lack","lady","laid","lake","lamp","land","language","large","larger","largest","last","late","later","laugh","law","lay","layers","lead","leader","leaf","learn","least","leather","leave","leaving","led","left","leg","length","lesson","let","letter","level","library","lie","life","lift","light","like","likely","limited","line","lion","lips","liquid","list","listen","little","live","living","load","local","locate","location","log","lonely","long","longer","look","loose","lose","loss","lost","lot","loud","love","lovely","low","lower","luck","lucky","lunch","lungs","lying","machine","machinery","mad","made","magic","magnet","mail","main","mainly","major","make","making","man","managed","manner","manufacturing","many","map","mark","market","married","mass","massage","master","material","mathematics","matter","may","maybe","me","meal","mean","means","meant","measure","meat","medicine","meet","melted","member","memory","men","mental","merely","met","metal","method","mice","middle","might","mighty","mile","military","milk","mill","mind","mine","minerals","minute","mirror","missing","mission","mistake","mix","mixture","model","modern","molecular","moment","money","monkey","month","mood","moon","more","morning","most","mostly","mother","motion","motor","mountain","mouse","mouth","move","movement","movie","moving","mud","muscle","music","musical","must","my","myself","mysterious","nails","name","nation","national","native","natural","naturally","nature","near","nearby","nearer","nearest","nearly","necessary","neck","needed","needle","needs","negative","neighbor","neighborhood","nervous","nest","never","new","news","newspaper","next","nice","night","nine","no","nobody","nodded","noise","none","noon","nor","north","nose","not","note","noted","nothing","notice","noun","now","number","numeral","nuts","object","observe","obtain","occasionally","occur","ocean","of","off","offer","office","officer","official","oil","old","older","oldest","on","once","one","only","onto","open","operation","opinion","opportunity","opposite","or","orange","orbit","order","ordinary","organization","organized","origin","original","other","ought","our","ourselves","out","outer","outline","outside","over","own","owner","oxygen","pack","package","page","paid","pain","paint","pair","palace","pale","pan","paper","paragraph","parallel","parent","park","part","particles","particular","particularly","partly","parts","party","pass","passage","past","path","pattern","pay","peace","pen","pencil","people","per","percent","perfect","perfectly","perhaps","period","person","personal","pet","phrase","physical","piano","pick","picture","pictured","pie","piece","pig","pile","pilot","pine","pink","pipe","pitch","place","plain","plan","plane","planet","planned","planning","plant","plastic","plate","plates","play","pleasant","please","pleasure","plenty","plural","plus","pocket","poem","poet","poetry","point","pole","police","policeman","political","pond","pony","pool","poor","popular","population","porch","port","position","positive","possible","possibly","post","pot","potatoes","pound","pour","powder","power","powerful","practical","practice","prepare","present","president","press","pressure","pretty","prevent","previous","price","pride","primitive","principal","principle","printed","private","prize","probably","problem","process","produce","product","production","program","progress","promised","proper","properly","property","protection","proud","prove","provide","public","pull","pupil","pure","purple","purpose","push","put","putting","quarter","queen","question","quick","quickly","quiet","quietly","quite","rabbit","race","radio","railroad","rain","raise","ran","ranch","range","rapidly","rate","rather","raw","rays","reach","read","reader","ready","real","realize","rear","reason","recall","receive","recent","recently","recognize","record","red","refer","refused","region","regular","related","relationship","religious","remain","remarkable","remember","remove","repeat","replace","replied","report","represent","require","research","respect","rest","result","return","review","rhyme","rhythm","rice","rich","ride","riding","right","ring","rise","rising","river","road","roar","rock","rocket","rocky","rod","roll","roof","room","root","rope","rose","rough","round","route","row","rubbed","rubber","rule","ruler","run","running","rush","sad","saddle","safe","safety","said","sail","sale","salmon","salt","same","sand","sang","sat","satellites","satisfied","save","saved","saw","say","scale","scared","scene","school","science","scientific","scientist","score","screen","sea","search","season","seat","second","secret","section","see","seed","seeing","seems","seen","seldom","select","selection","sell","send","sense","sent","sentence","separate","series","serious","serve","service","sets","setting","settle","settlers","seven","several","shade","shadow","shake","shaking","shall","shallow","shape","share","sharp","she","sheep","sheet","shelf","shells","shelter","shine","shinning","ship","shirt","shoe","shoot","shop","shore","short","shorter","shot","should","shoulder","shout","show","shown","shut","sick","sides","sight","sign","signal","silence","silent","silk","silly","silver","similar","simple","simplest","simply","since","sing","single","sink","sister","sit","sitting","situation","six","size","skill","skin","sky","slabs","slave","sleep","slept","slide","slight","slightly","slip","slipped","slope","slow","slowly","small","smaller","smallest","smell","smile","smoke","smooth","snake","snow","so","soap","social","society","soft","softly","soil","solar","sold","soldier","solid","solution","solve","some","somebody","somehow","someone","something","sometime","somewhere","son","song","soon","sort","sound","source","south","southern","space","speak","special","species","specific","speech","speed","spell","spend","spent","spider","spin","spirit","spite","split","spoken","sport","spread","spring","square","stage","stairs","stand","standard","star","stared","start","state","statement","station","stay","steady","steam","steel","steep","stems","step","stepped","stick","stiff","still","stock","stomach","stone","stood","stop","stopped","store","storm","story","stove","straight","strange","stranger","straw","stream","street","strength","stretch","strike","string","strip","strong","stronger","struck","structure","struggle","stuck","student","studied","studying","subject","substance","success","successful","such","sudden","suddenly","sugar","suggest","suit","sum","summer","sun","sunlight","supper","supply","support","suppose","sure","surface","surprise","surrounded","swam","sweet","swept","swim","swimming","swing","swung","syllable","symbol","system","table","tail","take","taken","tales","talk","tall","tank","tape","task","taste","taught","tax","tea","teach","teacher","team","tears","teeth","telephone","television","tell","temperature","ten","tent","term","terrible","test","than","thank","that","thee","them","themselves","then","theory","there","therefore","these","they","thick","thin","thing","think","third","thirty","this","those","thou","though","thought","thousand","thread","three","threw","throat","through","throughout","throw","thrown","thumb","thus","thy","tide","tie","tight","tightly","till","time","tin","tiny","tip","tired","title","to","tobacco","today","together","told","tomorrow","tone","tongue","tonight","too","took","tool","top","topic","torn","total","touch","toward","tower","town","toy","trace","track","trade","traffic","trail","train","transportation","trap","travel","treated","tree","triangle","tribe","trick","tried","trip","troops","tropical","trouble","truck","trunk","truth","try","tube","tune","turn","twelve","twenty","twice","two","type","typical","uncle","under","underline","understanding","unhappy","union","unit","universe","unknown","unless","until","unusual","up","upon","upper","upward","us","use","useful","using","usual","usually","valley","valuable","value","vapor","variety","various","vast","vegetable","verb","vertical","very","vessels","victory","view","village","visit","visitor","voice","volume","vote","vowel","voyage","wagon","wait","walk","wall","want","war","warm","warn","was","wash","waste","watch","water","wave","way","we","weak","wealth","wear","weather","week","weigh","weight","welcome","well","went","were","west","western","wet","whale","what","whatever","wheat","wheel","when","whenever","where","wherever","whether","which","while","whispered","whistle","white","who","whole","whom","whose","why","wide","widely","wife","wild","will","willing","win","wind","window","wing","winter","wire","wise","wish","with","within","without","wolf","women","won","wonder","wonderful","wood","wooden","wool","word","wore","work","worker","world","worried","worry","worse","worth","would","wrapped","write","writer","writing","written","wrong","wrote","yard","year","yellow","yes","yesterday","yet","you","young","younger","your","yourself","youth","zero","zebra","zipper","zoo","zulu"];function je(r){const e=r!=null&&r.seed?new Mt(r.seed):null;function t(){return r&&r.maxLength>1?n():s()}function n(){for(var c=!1,d;!c;)d=s(),d.length<=r.maxLength&&(c=!0);return d}function s(){return se[l(se.length)]}function l(c){const d=e?e():Math.random();return Math.floor(d*c)}if(typeof r=="undefined")return t();typeof r=="number"&&(r={exactly:r}),r.exactly&&(r.min=r.exactly,r.max=r.exactly),typeof r.wordsPerString!="number"&&(r.wordsPerString=1),typeof r.formatter!="function"&&(r.formatter=c=>c),typeof r.separator!="string"&&(r.separator=" ");for(var u=r.min+l(r.max+1-r.min),a=[],i="",o=0,h=0;h<u*r.wordsPerString;h++)o===r.wordsPerString-1?i+=r.formatter(t(),o):i+=r.formatter(t(),o)+r.separator,o++,(h+1)%r.wordsPerString===0&&(a.push(i),i="",o=0);return typeof r.join=="string"&&(a=a.join(r.join)),a}var Rt=je;je.wordList=se;var Nt=Y(Rt),Dt=Object.defineProperty,Vt=Object.defineProperties,$t=Object.getOwnPropertyDescriptors,ke=Object.getOwnPropertySymbols,zt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable,Oe=(r,e,t)=>e in r?Dt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Bt=(r,e)=>{for(var t in e||(e={}))zt.call(e,t)&&Oe(r,t,e[t]);if(ke)for(var t of ke(e))qt.call(e,t)&&Oe(r,t,e[t]);return r},Ut=(r,e)=>Vt(r,$t(e));function Kt(r=Math.random().toString()){return Math.random=wt(r),r}function ae(r,e,t=!1){const n=Array.isArray(r),s=Array.isArray(e);if(!n)s?(e=[e[0]],console.log("Unclear parameters given to randomization.repeat. Multiple set sizes specified, but only one item exists to sample. Proceeding using the first set size.")):(r=[r],e=[e]);else if(s){if(r.length!=e.length)if(console.warn("Unclear parameters given to randomization.repeat. Items and repetitions are unequal lengths. Behavior may not be as expected."),e.length<r.length){let a=[];for(let i=0;i<r.length;i++)a.push(e);e=a}else e=e.slice(0,r.length)}else{let a=[];for(let i=0;i<r.length;i++)a.push(e);e=a}let l=[];for(let a=0;a<r.length;a++)for(let i=0;i<e[a];i++)r[a]==null||typeof r[a]!="object"?l.push(r[a]):l.push(Object.assign({},r[a]));let u=C(l);return t&&(u=Zt(u)),u}function C(r){Array.isArray(r)||console.error("Argument to shuffle() must be an array.");const e=r.slice(0);let t=e.length,n,s;for(;t;)s=Math.floor(Math.random()*t--),n=e[t],e[t]=e[s],e[s]=n;return e}function Gt(r,e){Array.isArray(r)||console.error("First argument to shuffleNoRepeats() must be an array."),typeof e!="undefined"&&typeof e!="function"&&console.error("Second argument to shuffleNoRepeats() must be a function."),typeof e=="undefined"&&(e=function(n,s){return n===s});const t=C(r);for(let n=0;n<t.length-1;n++)if(e(t[n],t[n+1])){let s=Math.floor(Math.random()*(t.length-2))+1;for(;e(t[n+1],t[s])||e(t[n+1],t[s+1])||e(t[n+1],t[s-1])||e(t[n],t[s]);)s=Math.floor(Math.random()*(t.length-2))+1;const l=t[s];t[s]=t[n+1],t[n+1]=l}return t}function Ae(r,e=!1){const t=r.length;if(t==1)return console.warn("shuffleAlternateGroups() was called with only one group. Defaulting to simple shuffle."),C(r[0]);let n=[];for(let a=0;a<t;a++)n.push(a);e&&(n=C(n));const s=[];let l=null;for(let a=0;a<t;a++)l=l===null?r[a].length:Math.min(l,r[a].length),s.push(C(r[a]));const u=[];for(let a=0;a<l;a++)for(let i=0;i<n.length;i++)u.push(s[n[i]][a]);return u}function Ie(r,e){return Array.isArray(r)||console.error("First argument to sampleWithoutReplacement() must be an array"),e>r.length&&console.error("Cannot take a sample larger than the size of the set of items to sample."),C(r).slice(0,e)}function Se(r,e,t){Array.isArray(r)||console.error("First argument to sampleWithReplacement() must be an array");const n=[];if(typeof t!="undefined"){t.length!==r.length&&console.error("The length of the weights array must equal the length of the array to be sampled from.");let u=0;for(const a of t)u+=a;for(const a of t)n.push(a/u)}else for(let u=0;u<r.length;u++)n.push(1/r.length);const s=[n[0]];for(let u=1;u<n.length;u++)s.push(n[u]+s[u-1]);const l=[];for(let u=0;u<e;u++){const a=Math.random();let i=0;for(;a>s[i];)i++;l.push(r[i])}return l}function Ft(r,e=1,t=!1){let n=[{}];for(const[s,l]of Object.entries(r)){const u=[];for(const a of l)for(const i of n)u.push(Ut(Bt({},i),{[s]:a}));n=u}return ae(n,e,t)}function Jt(r=32){let e="";const t="0123456789abcdefghjklmnopqrstuvwxyz";for(let n=0;n<r;n++)e+=t[Math.floor(Math.random()*t.length)];return e}function Wt(r,e){if(e<r)throw new Error("Upper boundary must be greater than or equal to lower boundary");return r+Math.floor(Math.random()*(e-r+1))}function Yt(r){return Math.random()<=r?1:0}function oe(r,e){return Qt()*e+r}function le(r){return-Math.log(Math.random())/r}function Xt(r,e,t,n=!1){let s=oe(r,e)+le(t);if(n)for(;s<=0;)s=oe(r,e)+le(t);return s}function Ht(r){return Nt(r)}function Qt(){for(var r=0,e=0;r===0;)r=Math.random();for(;e===0;)e=Math.random();return Math.sqrt(-2*Math.log(r))*Math.cos(2*Math.PI*e)}function Zt(r){const e={};for(const t of r)for(const n of Object.keys(t))typeof e[n]=="undefined"&&(e[n]=[]),e[n].push(t[n]);return e}var er=Object.freeze({__proto__:null,factorial:Ft,randomID:Jt,randomInt:Wt,randomWords:Ht,repeat:ae,sampleBernoulli:Yt,sampleExGaussian:Xt,sampleExponential:le,sampleNormal:oe,sampleWithReplacement:Se,sampleWithoutReplacement:Ie,setSeed:Kt,shuffle:C,shuffleAlternateGroups:Ae,shuffleNoRepeats:Gt});function Le(){const r={previewMode:!1,outsideTurk:!1,hitId:"INVALID_URL_PARAMETER",assignmentId:"INVALID_URL_PARAMETER",workerId:"INVALID_URL_PARAMETER",turkSubmitTo:"INVALID_URL_PARAMETER"},e=function(n,s){s=s.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");const l="[\\?&]"+s+"=([^&#]*)",u=new RegExp(l).exec(n);return u==null?"":u[1]},t=e(window.location.href,"assignmentId")?window.location.href:document.referrer;return["assignmentId","hitId","workerId","turkSubmitTo"].map(function(n){r[n]=unescape(e(t,n))}),r.previewMode=r.assignmentId=="ASSIGNMENT_ID_NOT_AVAILABLE",r.outsideTurk=!r.previewMode&&r.hitId===""&&r.assignmentId==""&&r.workerId=="",r}function tr(r){const e=Le(),t=e.assignmentId,n=e.turkSubmitTo;if(!t||!n)return;const s=document.createElement("form");s.method="POST",s.action=n+"/mturk/externalSubmit?assignmentId="+t;for(const l in r)if(r.hasOwnProperty(l)){const u=document.createElement("input");u.type="hidden",u.name=l,u.id=l,u.value=r[l],s.appendChild(u)}document.body.appendChild(s),s.submit()}var rr=Object.freeze({__proto__:null,submitToTurk:tr,turkInfo:Le});class nr{constructor(e,t){this.containerElement=e,this.message=t,this._progress=0,this.setupElements()}setupElements(){this.messageSpan=document.createElement("span"),this.innerDiv=document.createElement("div"),this.innerDiv.id="jspsych-progressbar-inner",this.update();const e=document.createElement("div");e.id="jspsych-progressbar-outer",e.appendChild(this.innerDiv),this.containerElement.appendChild(this.messageSpan),this.containerElement.appendChild(e)}update(){this.innerDiv.style.width=this._progress*100+"%",typeof this.message=="function"?this.messageSpan.innerHTML=this.message(this._progress):this.messageSpan.innerHTML=this.message}set progress(e){if(typeof e!="number"||e<0||e>1)throw new Error("jsPsych.progressBar.progress must be a number between 0 and 1");this._progress=e,this.update()}get progress(){return this._progress}}class ue{constructor(e){this.name=e}}const ir=["timeline","timeline_variables","name","repetitions","loop_function","conditional_function","randomize_order","sample","on_timeline_start","on_timeline_finish"];function sr(r){return!ce(r)}function ce(r){return!!r.timeline||Array.isArray(r)}var x=(r=>(r[r.PENDING=0]="PENDING",r[r.RUNNING=1]="RUNNING",r[r.PAUSED=2]="PAUSED",r[r.COMPLETED=3]="COMPLETED",r[r.ABORTED=4]="ABORTED",r))(x||{});class Ce{constructor(){this.reset()}reset(){this.promise=new Promise(e=>{this.resolvePromise=e})}get(){return this.promise}resolve(e){this.resolvePromise(e),this.reset()}}function ar(r){return r&&typeof r.then=="function"}function or(r){return new Promise(e=>setTimeout(e,r))}function S([r,...e]){let t=r!=null?r:"";for(const n of e)t+=Number.isNaN(Number.parseInt(n))?`.${n}`:`[${n}]`;return t}function lr(r){return typeof r=="object"&&r!==null}class he{constructor(){this.cache=new Map}static lookupChild(e,t){let n=!1,s;return Number.isNaN(Number.parseInt(t))?Object.hasOwn(e,t)&&(n=!0,s=e[t]):Number.parseInt(t)<e.length&&(n=!0,s=e[t]),{doesPathExist:n,value:s}}get(e){return this.cache.get(e.join("."))}has(e){return this.cache.has(e.join("."))}initialize(e){this.rootObject=e,this.cache.set("",e)}reset(){this.cache.clear(),this.cache.set("",this.rootObject)}set(e,t){this.cache.set(e.join("."),t)}lookup(e){if(this.has(e))return{doesPathExist:!0,value:this.get(e)};const t=n=>{const s=n.slice(0,-1),l=n[n.length-1];if(!this.has(s)&&s.length>0&&!t(s).doesPathExist)return{doesPathExist:!1};const u=this.get(s);if(!lr(u))return{doesPathExist:!1};const a=he.lookupChild(u,l);return a.doesPathExist&&this.set(n,a.value),a};return t(e)}}var ur=Object.defineProperty,Me=Object.getOwnPropertySymbols,cr=Object.prototype.hasOwnProperty,hr=Object.prototype.propertyIsEnumerable,Re=(r,e,t)=>e in r?ur(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ne=(r,e)=>{for(var t in e||(e={}))cr.call(e,t)&&Re(r,t,e[t]);if(Me)for(var t of Me(e))hr.call(e,t)&&Re(r,t,e[t]);return r};class De{constructor(e){this.dependencies=e,this.status=x.PENDING,this.parameterValueCache=new he}getStatus(){return this.status}initializeParameterValueCache(){this.parameterValueCache.initialize(this.description)}resetParameterValueCache(){var e;this.parameterValueCache.reset(),(e=this.parent)==null||e.resetParameterValueCache()}getParameterValue(e,t={}){const{evaluateFunctions:n=!0,recursive:s=!0,cacheResult:l=!0,replaceResult:u}=t;typeof e=="string"&&(e=[e]);let{doesPathExist:a,value:i}=this.parameterValueCache.lookup(e);return!a&&s&&this.parent&&(i=this.parent.getParameterValue(e,t)),typeof i=="function"&&n&&(i=i()),i instanceof ue&&(i=this.evaluateTimelineVariable(i)),typeof u=="function"&&(i=u(i)),l&&this.parameterValueCache.set(e,i),i}getDataParameter(){var e;const t=this.getParameterValue("data",{recursive:!1});return Ne(Ne({},Object.fromEntries(typeof t=="object"?Object.keys(t).map(n=>[n,this.getParameterValue(["data",n])]):[])),(e=this.parent)==null?void 0:e.getDataParameter())}}var dr=Object.defineProperty,pr=Object.defineProperties,fr=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertySymbols,mr=Object.prototype.hasOwnProperty,gr=Object.prototype.propertyIsEnumerable,$e=(r,e,t)=>e in r?dr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,de=(r,e)=>{for(var t in e||(e={}))mr.call(e,t)&&$e(r,t,e[t]);if(Ve)for(var t of Ve(e))gr.call(e,t)&&$e(r,t,e[t]);return r},yr=(r,e)=>pr(r,fr(e)),pe=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});class J extends De{constructor(e,t,n){var s;if(super(e),this.description=t,this.parent=n,this.onLoad=()=>{this.runParameterCallback("on_load"),this.dependencies.runOnLoadExtensionCallbacks(this.getParameterValue("extensions"))},this.initializeParameterValueCache(),this.trialObject=j(t),this.pluginClass=this.getParameterValue("type",{evaluateFunctions:!1}),this.pluginInfo=(s=this.pluginClass)==null?void 0:s.info,!this.pluginInfo)throw new Error("Plugin not recognized. Please provide a valid plugin using the 'type' parameter.");!("version"in this.pluginInfo)&&!("data"in this.pluginInfo)?console.warn(this.pluginInfo.name,"is missing the 'version' and 'data' fields. Please update plugin as 'version' and 'data' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."):"version"in this.pluginInfo?"data"in this.pluginInfo||console.warn(this.pluginInfo.name,"is missing the 'data' field. Please update plugin as 'data' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."):console.warn(this.pluginInfo.name,"is missing the 'version' field. Please update plugin as 'version' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details.")}run(){return pe(this,null,function*(){var e;this.status=x.RUNNING,this.processParameters(),this.onStart(),this.addCssClasses(),this.pluginInstance=this.dependencies.instantiatePlugin(this.pluginClass),this.result=this.processResult(yield this.executeTrial()),this.dependencies.onTrialResultAvailable(this),this.status=x.COMPLETED,yield this.onFinish(),this.removeCssClasses();const t=(e=this.getParameterValue("post_trial_gap"))!=null?e:this.dependencies.getDefaultIti();t!==0&&this.dependencies.getSimulationMode()!=="data-only"&&(yield or(t)),this.resetParameterValueCache()})}executeTrial(){return pe(this,null,function*(){const e=this.dependencies.finishTrialPromise.get();let t=!1;e.then(()=>{t=!0});const{trialReturnValue:n,hasTrialBeenSimulated:s}=this.invokeTrialMethod();let l;return ar(n)?(l=yield Promise.race([n,e]),t&&(l=yield e)):(s||this.onLoad(),l=yield e),this.cleanupTrial(),l})}invokeTrialMethod(){var e;const t=this.dependencies.getSimulationMode();if(t&&typeof this.pluginInstance.simulate=="function"){const n=this.getSimulationOptions();if(n.simulate!==!1)return{hasTrialBeenSimulated:!0,trialReturnValue:this.pluginInstance.simulate(this.trialObject,(e=n.mode)!=null?e:t,n,this.onLoad)}}return{hasTrialBeenSimulated:!1,trialReturnValue:this.pluginInstance.trial(this.dependencies.getDisplayElement(),this.trialObject,this.onLoad)}}cleanupTrial(){this.dependencies.clearAllTimeouts(),this.dependencies.getDisplayElement().innerHTML=""}addCssClasses(){const e=this.getParameterValue("css_classes"),t=this.dependencies.getDisplayElement().classList;typeof e=="string"?t.add(e):Array.isArray(e)&&t.add(...e)}removeCssClasses(){const e=this.getParameterValue("css_classes");e&&this.dependencies.getDisplayElement().classList.remove(...typeof e=="string"?[e]:e)}processResult(e){var t;e||(e={});for(const[s,l]of Object.entries((t=this.getParameterValue("save_trial_parameters"))!=null?t:{}))if(this.pluginInfo.parameters[s])if(l&&!Object.hasOwn(e,s)){let u=this.trialObject[s];typeof u=="function"&&(u=u.toString()),e[s]=u}else!l&&Object.hasOwn(e,s)&&delete e[s];else console.warn(`Non-existent parameter "${s}" specified in save_trial_parameters.`);e=yr(de(de({},this.getDataParameter()),e),{trial_type:this.pluginInfo.name,trial_index:this.index,plugin_version:this.pluginInfo.version?this.pluginInfo.version:null});const n=this.getParameterValue("save_timeline_variables");return n===!0?e.timeline_variables=de({},this.parent.getAllTimelineVariables()):Array.isArray(n)&&(e.timeline_variables=Object.fromEntries(Object.entries(this.parent.getAllTimelineVariables()).filter(([s,l])=>n.includes(s)))),e}runParameterCallback(e,...t){const n=this.getParameterValue(e,{evaluateFunctions:!1});if(n)return n(...t)}onStart(){this.dependencies.onTrialStart(this),this.runParameterCallback("on_start",this.trialObject),this.dependencies.runOnStartExtensionCallbacks(this.getParameterValue("extensions"))}onFinish(){return pe(this,null,function*(){const e=yield this.dependencies.runOnFinishExtensionCallbacks(this.getParameterValue("extensions"));Object.assign(this.result,e),yield Promise.resolve(this.runParameterCallback("on_finish",this.getResult())),this.dependencies.onTrialFinished(this)})}evaluateTimelineVariable(e){var t;return(t=this.parent)==null?void 0:t.evaluateTimelineVariable(e)}getParameterValue(e,t={}){return ir.includes(typeof e=="string"?e:e[0])&&(t.recursive=!1),super.getParameterValue(e,t)}getSimulationOptions(){const e=this.getParameterValue("simulation_options",{replaceResult:(t={})=>{var n,s;if(typeof t=="string"){const l=this.dependencies.getGlobalSimulationOptions();t=(s=(n=l[t])!=null?n:l.default)!=null?s:{}}return G(j(this.dependencies.getGlobalSimulationOptions().default),j(t))}});return typeof e=="undefined"?{}:(e.mode=this.getParameterValue(["simulation_options","mode"]),e.simulate=this.getParameterValue(["simulation_options","simulate"]),e.data=this.getParameterValue(["simulation_options","data"]),typeof e.data=="object"&&(e.data=Object.fromEntries(Object.keys(e.data).map(t=>[t,this.getParameterValue(["simulation_options","data",t])]))),e)}getResult(){return this.getParameterValue("record_data")===!1?void 0:this.result}getResults(){const e=this.getResult();return e?[e]:[]}processParameters(){const e=(n,s,l=[])=>{for(const[u,a]of Object.entries(s)){const i=[...l,u];let o=this.getParameterValue(i,{evaluateFunctions:a.type!==y.FUNCTION,replaceResult:h=>{if(typeof h=="undefined"){if(typeof a.default=="undefined")throw new Error(`You must specify a value for the "${S(i)}" parameter in the "${this.pluginInfo.name}" plugin.`);return a.default}else return h}});if(!a.array&&o!==null){switch(a.type){case y.BOOL:if(typeof o!="boolean"){const h=S(i);console.warn(`A non-boolean value (\`${o}\`) was provided for the boolean parameter "${h}" in the "${this.pluginInfo.name}" plugin.`)}break;case y.KEYS:if(Array.isArray(o))break;case y.STRING:case y.HTML_STRING:case y.KEY:case y.AUDIO:case y.VIDEO:case y.IMAGE:if(typeof o!="string"){const h=S(i);console.warn(`A non-string value (\`${o}\`) was provided for the parameter "${h}" in the "${this.pluginInfo.name}" plugin.`)}break;case y.FLOAT:case y.INT:if(typeof o!="number"){const h=S(i);console.warn(`A non-numeric value (\`${o}\`) was provided for the numeric parameter "${h}" in the "${this.pluginInfo.name}" plugin.`)}break;case y.FUNCTION:if(typeof o!="function"){const h=S(i);console.warn(`A non-function value (\`${o}\`) was provided for the function parameter "${h}" in the "${this.pluginInfo.name}" plugin.`)}break;case y.SELECT:if(!a.options){const h=S(i);console.warn(`The "options" array is required for the "select" parameter "${h}" in the "${this.pluginInfo.name}" plugin.`)}}if(a.type===y.INT&&o%1!==0){const h=S(i);console.warn(`A float value (\`${o}\`) was provided for the integer parameter "${h}" in the "${this.pluginInfo.name}" plugin. The value will be truncated to an integer.`),o=Math.trunc(o)}}if(a.type===y.SELECT&&!a.options.includes(o)){const h=S(i);console.warn(`The value "${o}" is not a valid option for the parameter "${h}" in the "${this.pluginInfo.name}" plugin. Valid options are: ${a.options.join(", ")}.`)}if(a.array&&!Array.isArray(o)){const h=S(i);throw new Error(`A non-array value (\`${o}\`) was provided for the array parameter "${h}" in the "${this.pluginInfo.name}" plugin. Please make sure that "${h}" is an array.`)}a.type===y.COMPLEX&&a.nested&&(a.array?o=o.map((h,c)=>{const d=[...i,c.toString()],p=this.getParameterValue(d);return e(p,a.nested,d),p}):e(o,a.nested,i)),n[u]=o}},t=j(this.description);e(t,this.pluginInfo.parameters),this.trialObject=t}getLatestNode(){return this}getActiveTimelineByName(e){}}var vr=Object.defineProperty,ze=Object.getOwnPropertySymbols,br=Object.prototype.hasOwnProperty,wr=Object.prototype.propertyIsEnumerable,qe=(r,e,t)=>e in r?vr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Be=(r,e)=>{for(var t in e||(e={}))br.call(e,t)&&qe(r,t,e[t]);if(ze)for(var t of ze(e))wr.call(e,t)&&qe(r,t,e[t]);return r},xr=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});class M extends De{constructor(e,t,n){super(e),this.parent=n,this.children=[],this.shouldAbort=!1,this.resumePromise=new Ce,this.description=Array.isArray(t)?{timeline:t}:t,this.initializeParameterValueCache()}run(){return xr(this,null,function*(){typeof this.index=="undefined"&&(this.index=0),this.status=x.RUNNING;const{conditional_function:e,loop_function:t,repetitions:n=1}=this.description;let s=this.generateTimelineVariableOrder();this.setCurrentTimelineVariablesByIndex(s[0]);let l=!0,u;if(!e||e()){this.onStart();for(let a=0;a<n;a++)do{u=[],l?l=!1:s=this.generateTimelineVariableOrder();for(const i of s){this.setCurrentTimelineVariablesByIndex(i);for(const o of this.description.timeline){const h=this.instantiateChildNode(o),c=this.currentChild;if(this.currentChild=h,h.index=c?c.getLatestNode().index+1:this.index,yield h.run(),this.status===x.PAUSED&&(yield this.resumePromise.get()),this.shouldAbort){this.status=x.ABORTED;return}u.push(...this.currentChild.getResults())}}}while(t&&t(new w(u)));this.onFinish()}this.status=x.COMPLETED})}onStart(){this.description.on_timeline_start&&this.description.on_timeline_start()}onFinish(){this.description.on_timeline_finish&&this.description.on_timeline_finish()}pause(){this.currentChild instanceof M&&this.currentChild.pause(),this.status=x.PAUSED}resume(){this.status==x.PAUSED&&(this.currentChild instanceof M&&this.currentChild.resume(),this.status=x.RUNNING,this.resumePromise.resolve())}abort(){(this.status===x.RUNNING||this.status===x.PAUSED)&&(this.currentChild instanceof M&&this.currentChild.abort(),this.shouldAbort=!0,this.status===x.PAUSED&&this.resume())}instantiateChildNode(e){const t=ce(e)?new M(this.dependencies,e,this):new J(this.dependencies,e,this);return this.children.push(t),t}setCurrentTimelineVariablesByIndex(e){var t;this.currentTimelineVariables=Be(Be({},(t=this.parent)==null?void 0:t.getAllTimelineVariables()),e===null?void 0:this.description.timeline_variables[e])}generateTimelineVariableOrder(){var e;const t=(e=this.description.timeline_variables)==null?void 0:e.length;if(!t)return[null];let n=[...Array(t).keys()];const s=this.description.sample;if(s)switch(s.type){case"custom":n=s.fn(n);break;case"with-replacement":n=Se(n,s.size,s.weights);break;case"without-replacement":n=Ie(n,s.size);break;case"fixed-repetitions":n=ae(n,s.size);break;case"alternate-groups":n=Ae(s.groups,s.randomize_group_order);break;default:throw new Error(`Invalid type "${s.type}" in timeline sample parameters. Valid options for type are "custom", "with-replacement", "without-replacement", "fixed-repetitions", and "alternate-groups"`)}return this.description.randomize_order&&(n=C(n)),n}getAllTimelineVariables(){return this.currentTimelineVariables}evaluateTimelineVariable(e){var t;if((t=this.currentTimelineVariables)!=null&&t.hasOwnProperty(e.name))return this.currentTimelineVariables[e.name];throw new Error(`Timeline variable ${e.name} not found.`)}getResults(){const e=[];for(const t of this.children)if(t instanceof J){const n=t.getResult();n&&e.push(n)}else t instanceof M&&e.push(...t.getResults());return e}getNaiveProgress(){if(this.status===x.PENDING)return 0;const e=this.getLatestNode();if(!e)return 1;let t=e.index;return e.getStatus()===x.COMPLETED&&t++,Math.min(t/this.getNaiveTrialCount(),1)}getNaiveTrialCount(){const e=t=>{var n,s,l;const u=a=>a.map(i=>e(i)).reduce((i,o)=>i+o);if(Array.isArray(t))return u(t);if(sr(t))return 1;if(ce(t)){let a=((n=t.timeline_variables)==null?void 0:n.length)||1;switch((s=t.sample)==null?void 0:s.type){case"with-replacement":case"without-replacement":a=t.sample.size;break;case"fixed-repetitions":a*=t.sample.size;break;case"alternate-groups":a=t.sample.groups.map(i=>i.length).reduce((i,o)=>i+o,0);break}return u(t.timeline)*((l=t.repetitions)!=null?l:1)*a}return 0};return e(this.description)}getLatestNode(){var e,t;return(t=(e=this.currentChild)==null?void 0:e.getLatestNode())!=null?t:this}getActiveTimelineByName(e){var t;return this.description.name===e?this:(t=this.currentChild)==null?void 0:t.getActiveTimelineByName(e)}}var Er=Object.defineProperty,Ue=Object.getOwnPropertySymbols,Pr=Object.prototype.hasOwnProperty,_r=Object.prototype.propertyIsEnumerable,Ke=(r,e,t)=>e in r?Er(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Tr=(r,e)=>{for(var t in e||(e={}))Pr.call(e,t)&&Ke(r,t,e[t]);if(Ue)for(var t of Ue(e))_r.call(e,t)&&Ke(r,t,e[t]);return r},fe=(r,e,t)=>new Promise((n,s)=>{var l=i=>{try{a(t.next(i))}catch(o){s(o)}},u=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,u);a((t=t.apply(r,e)).next())});class Ge{constructor(e){this.turk=rr,this.randomization=er,this.utils=Ye,this.citation={apa:"de Leeuw, J. R., Gilbert, R. A., & Luchterhandt, B. (2023). jsPsych: Enabling an Open-Source Collaborative Ecosystem of Behavioral Experiments. Journal of Open Source Software, 8(85), 5351. https://doi.org/10.21105/joss.05351 ",bibtex:'@article{Leeuw2023jsPsych, author = {de Leeuw, Joshua R. and Gilbert, Rebecca A. and Luchterhandt, Bj{\\" o}rn}, journal = {Journal of Open Source Software}, doi = {10.21105/joss.05351}, issn = {2475-9066}, number = {85}, year = {2023}, month = {may 11}, pages = {5351}, publisher = {Open Journals}, title = {jsPsych: Enabling an {Open}-{Source} {Collaborative} {Ecosystem} of {Behavioral} {Experiments}}, url = {https://joss.theoj.org/papers/10.21105/joss.05351}, volume = {8}, } '},this.options={},this.isFileProtocolUsed=!1,this.finishTrialPromise=new Ce,this.timelineDependencies={onTrialStart:t=>{this.options.on_trial_start(t.trialObject),this.getDisplayContainerElement().focus(),this.getDisplayElement().scrollTop=0},onTrialResultAvailable:t=>{const n=t.getResult();n&&(n.time_elapsed=this.getTotalTime(),this.data.write(t))},onTrialFinished:t=>{const n=t.getResult();this.options.on_trial_finish(n),n&&this.options.on_data_update(n),this.progressBar&&this.options.auto_update_progress_bar&&(this.progressBar.progress=this.timeline.getNaiveProgress())},runOnStartExtensionCallbacks:t=>this.extensionManager.onStart(t),runOnLoadExtensionCallbacks:t=>this.extensionManager.onLoad(t),runOnFinishExtensionCallbacks:t=>this.extensionManager.onFinish(t),getSimulationMode:()=>this.simulationMode,getGlobalSimulationOptions:()=>this.simulationOptions,instantiatePlugin:t=>new t(this),getDisplayElement:()=>this.getDisplayElement(),getDefaultIti:()=>this.getInitSettings().default_iti,finishTrialPromise:this.finishTrialPromise,clearAllTimeouts:()=>this.pluginAPI.clearAllTimeouts()},this.extensionManagerDependencies={instantiateExtension:t=>new t(this)},this.dataDependencies={getProgress:()=>{var t,n;return{time:this.getTotalTime(),trial:(n=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?n:0}},onInteractionRecordAdded:t=>{this.options.on_interaction_data_update(t)},getDisplayElement:()=>this.getDisplayElement()},e=Tr({display_element:void 0,on_finish:()=>{},on_trial_start:()=>{},on_trial_finish:()=>{},on_data_update:()=>{},on_interaction_data_update:()=>{},on_close:()=>{},use_webaudio:!0,show_progress_bar:!1,message_progress_bar:"Completion Progress",auto_update_progress_bar:!0,default_iti:0,minimum_valid_rt:0,experiment_width:null,override_safe_mode:!1,case_sensitive_responses:!1,extensions:[]},e),this.options=e,X(this),window.location.protocol=="file:"&&(e.override_safe_mode===!1||typeof e.override_safe_mode=="undefined")&&(e.use_webaudio=!1,this.isFileProtocolUsed=!0,console.warn("jsPsych detected that it is running via the file:// protocol and not on a web server. To prevent issues with cross-origin requests, Web Audio and video preloading have been disabled. If you would like to override this setting, you can set 'override_safe_mode' to 'true' in initJsPsych. For more information, see: https://www.jspsych.org/overview/running-experiments")),this.data=new nt(this.dataDependencies),this.pluginAPI=bt(this),this.extensionManager=new U(this.extensionManagerDependencies,e.extensions)}version(){return We}run(e){return fe(this,null,function*(){typeof e=="undefined"&&console.error("No timeline declared in jsPsych.run(). Cannot start experiment."),e.length===0&&console.error("No trials have been added to the timeline (the timeline is an empty array). Cannot start experiment."),this.timeline=new M(this.timelineDependencies,e),yield this.prepareDom(),yield this.extensionManager.initializeExtensions(),document.documentElement.setAttribute("jspsych","present"),this.experimentStartTime=new Date,yield this.timeline.run(),yield Promise.resolve(this.options.on_finish(this.data.get())),this.endMessage&&(this.getDisplayElement().innerHTML=this.endMessage),this.data.removeInteractionListeners()})}simulate(e){return fe(this,arguments,function*(t,n="data-only",s={}){this.simulationMode=n,this.simulationOptions=s,yield this.run(t)})}getProgress(){var e,t,n,s;return{total_trials:(e=this.timeline)==null?void 0:e.getNaiveTrialCount(),current_trial_global:(n=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?n:0,percent_complete:((s=this.timeline)==null?void 0:s.getNaiveProgress())*100}}getStartTime(){return this.experimentStartTime}getTotalTime(){return this.experimentStartTime?new Date().getTime()-this.experimentStartTime.getTime():0}getDisplayElement(){return this.displayElement}getDisplayContainerElement(){return this.displayContainerElement}abortExperiment(e,t={}){this.endMessage=e,this.timeline.abort(),this.pluginAPI.cancelAllKeyboardResponses(),this.pluginAPI.clearAllTimeouts(),this.finishTrial(t)}abortCurrentTimeline(){var e;let t=(e=this.timeline)==null?void 0:e.getLatestNode();t instanceof J&&(t=t.parent),t instanceof M&&t.abort()}abortTimelineByName(e){var t;const n=(t=this.timeline)==null?void 0:t.getActiveTimelineByName(e);n&&n.abort()}getCurrentTrial(){var e;const t=(e=this.timeline)==null?void 0:e.getLatestNode();if(t instanceof J)return t.description}getInitSettings(){return this.options}timelineVariable(e){return new ue(e)}evaluateTimelineVariable(e){var t,n;return(n=(t=this.timeline)==null?void 0:t.getLatestNode())==null?void 0:n.evaluateTimelineVariable(new ue(e))}pauseExperiment(){var e;(e=this.timeline)==null||e.pause()}resumeExperiment(){var e;(e=this.timeline)==null||e.resume()}getSafeModeStatus(){return this.isFileProtocolUsed}getTimeline(){var e;return(e=this.timeline)==null?void 0:e.description.timeline}getCitations(e=[],t="apa"){const n=["apa","bibtex"];if(t=t.toLowerCase(),Array.isArray(e))if(n.includes(t)){const s=this.citation[t],l=new Set([s]);for(const u of e)try{const a=u.info.citations[t];l.add(a)}catch(a){console.error(`${u} does not have citation in ${t} format.`)}return Array.from(l).join(`
|
|
6
|
+
`)}else throw new Error("Unsupported citation format");else throw new Error("Expected array of plugins/extensions")}get extensions(){var e,t;return(t=(e=this.extensionManager)==null?void 0:e.extensions)!=null?t:{}}prepareDom(){return fe(this,null,function*(){document.readyState!=="complete"&&(yield new Promise(s=>{window.addEventListener("load",s)}));const e=this.options;if(typeof e.display_element=="undefined"){let s=document.body;s||(s=document.createElement("body"),document.documentElement.appendChild(s)),document.querySelector("html").style.height="100%",s.style.margin="0px",s.style.height="100%",s.style.width="100%",e.display_element=s}else{const s=e.display_element instanceof Element?e.display_element:document.querySelector("#"+e.display_element);s===null?console.error("The display_element specified in initJsPsych() does not exist in the DOM."):e.display_element=s}const t=document.createElement("div");t.id="jspsych-content";const n=document.createElement("div");if(n.className="jspsych-content-wrapper",n.appendChild(t),this.displayContainerElement=e.display_element,this.displayContainerElement.appendChild(n),this.displayElement=t,e.experiment_width!==null&&(this.displayElement.style.width=e.experiment_width+"px"),e.display_element.tabIndex=0,this.displayContainerElement.classList.add("jspsych-display-element"),this.displayElement.classList.add("jspsych-content"),this.data.createInteractionListeners(),window.addEventListener("beforeunload",e.on_close),this.options.show_progress_bar){const s=document.createElement("div");s.id="jspsych-progressbar-container",this.progressBar=new nr(s,this.options.message_progress_bar),this.getDisplayContainerElement().insertAdjacentElement("afterbegin",s)}})}finishTrial(e){this.finishTrialPromise.resolve(e)}}class R extends Error{constructor(e="The global `jsPsych` variable is no longer available in jsPsych v7."){super(`${e} Please follow the migration guide at https://www.jspsych.org/7.0/support/migration-v7/ to update your experiment.`),this.name="MigrationError"}}window.jsPsych={get init(){throw new R("`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.")},get data(){throw new R},get randomization(){throw new R},get turk(){throw new R},get pluginAPI(){throw new R},get ALL_KEYS(){throw new R('jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.')},get NO_KEYS(){throw new R('jsPsych.NO_KEYS was replaced by the "NO_KEYS" string in jsPsych v7.')}},typeof window!="undefined"&&window.hasOwnProperty("webkitAudioContext")&&!window.hasOwnProperty("AudioContext")&&(window.AudioContext=webkitAudioContext);function jr(r){const e=new Ge(r);return Object.defineProperties(e,Object.fromEntries(Object.entries({init:"`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.",ALL_KEYS:'jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.',NO_KEYS:'jsPsych.NO_KEYS was replaced by the "NO_KEYS" string in jsPsych v7.',currentTimelineNodeID:"`currentTimelineNodeID()` was renamed to `getCurrentTimelineNodeID()` in jsPsych v7.",progress:"`progress()` was renamed to `getProgress()` in jsPsych v7.",startTime:"`startTime()` was renamed to `getStartTime()` in jsPsych v7.",totalTime:"`totalTime()` was renamed to `getTotalTime()` in jsPsych v7.",currentTrial:"`currentTrial()` was renamed to `getCurrentTrial()` in jsPsych v7.",initSettings:"`initSettings()` was renamed to `getInitSettings()` in jsPsych v7.",allTimelineVariables:"`allTimelineVariables()` was renamed to `getAllTimelineVariables()` in jsPsych v7."}).map(([t,n])=>[t,{get(){throw new R(n)}}]))),e}return $.DataCollection=w,$.JsPsych=Ge,$.ParameterType=y,$.initJsPsych=jr,$}({}),initJsPsych=jsPsychModule.initJsPsych;
|
|
7
|
+
//# sourceMappingURL=https://unpkg.com/jspsych@8.2.3/dist/index.browser.min.js.map
|