jspsych 8.0.2 → 8.1.0

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.
@@ -1,6 +1,6 @@
1
- var jsPsychModule=function(E){"use strict";var we=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function O(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}const ve=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 Pe=(r,{include:e,exclude:t}={})=>{const i=s=>{const l=o=>typeof o=="string"?s===o:o.test(s);return e?e.some(l):t?!t.some(l):!0};for(const[s,l]of ve(r.constructor.prototype)){if(l==="constructor"||!i(l))continue;const o=Reflect.getOwnPropertyDescriptor(s,l);o&&typeof o.value=="function"&&(r[l]=r[l].bind(r))}return r},A=O(Pe),Ee={name:"jspsych",version:"8.0.2",description:"Behavioral experiments in a browser",type:"module",main:"dist/index.cjs",exports:{".":{import:"./dist/index.js",require:"./dist/index.cjs"},"./css/*":"./css/*"},typings:"dist/index.d.ts",unpkg:"dist/index.browser.min.js",files:["src","dist","css"],source:"src/index.ts",scripts:{test:"jest","test:watch":"npm test -- --watch",tsc:"tsc","build:js":"rollup --config","build:styles":"webpack-cli",build:"run-p build:js build:styles","build:watch":'run-p "build:js -- --watch" "build:styles watch"',prepack:"cp ../../README.md ."},repository:{type:"git",url:"git+https://github.com/jspsych/jsPsych.git",directory:"packages/jspsych"},author:"Josh de Leeuw",license:"MIT",bugs:{url:"https://github.com/jspsych/jsPsych/issues"},homepage:"https://www.jspsych.org",dependencies:{"auto-bind":"^4.0.0","random-words":"^1.1.1",seedrandom:"^3.0.5","type-fest":"^2.9.0"},devDependencies:{"@fontsource/open-sans":"4.5.3","@jspsych/config":"^3.0.0","@types/dom-mediacapture-record":"^1.0.11","base64-inline-loader":"^2.0.1","css-loader":"^6.6.0","mini-css-extract-plugin":"^2.5.3","npm-run-all":"^4.1.5","replace-in-file-webpack-plugin":"^1.0.6",sass:"^1.43.5","sass-loader":"^12.4.0",webpack:"^5.76.0","webpack-cli":"^4.9.2","webpack-remove-empty-scripts":"^0.7.2"}},K=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class _{constructor(e,t){this.dependencies=e,this.extensionsConfiguration=t,this.extensions=Object.fromEntries(t.map(i=>[_.getExtensionNameByClass(i.type),this.dependencies.instantiateExtension(i.type)]))}static getExtensionNameByClass(e){return e.info.name}getExtensionInstanceByClass(e){return this.extensions[_.getExtensionNameByClass(e)]}initializeExtensions(){return K(this,null,function*(){yield Promise.all(this.extensionsConfiguration.map(({type:e,params:t={}})=>{this.getExtensionInstanceByClass(e).initialize(t);const i=e.info;!("version"in i)&&!("data"in i)?console.warn(i.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 i?"data"in i||console.warn(i.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(i.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:i,params:s}of e)(t=this.getExtensionInstanceByClass(i))==null||t.on_start(s)}onLoad(e=[]){var t;for(const{type:i,params:s}of e)(t=this.getExtensionInstanceByClass(i))==null||t.on_load(s)}onFinish(){return K(this,arguments,function*(e=[]){const t=yield Promise.all(e.map(({type:s,params:l})=>{var o;return Promise.resolve((o=this.getExtensionInstanceByClass(s))==null?void 0:o.on_finish(l))})),i=e.length?{extension_type:e.map(({type:s})=>s.info.name),extension_version:e.map(({type:s})=>s.info.version)}:{};return t.unshift(i),Object.assign({},...t)})}}function x(r){return[...new Set(r)]}function f(r){if(!r)return r;let e;if(Array.isArray(r)){e=[];for(const t of r)e.push(f(t));return e}else if(typeof r=="object"&&r!==null){e={};for(const t in r)r.hasOwnProperty(t)&&(e[t]=f(r[t]));return e}else return r}function k(r,e){let t={};for(const i in r)r.hasOwnProperty(i)&&(typeof r[i]=="object"&&e.hasOwnProperty(i)?t[i]=k(r[i],e[i]):t[i]=r[i]);for(const i in e)e.hasOwnProperty(i)&&(t.hasOwnProperty(i)&&typeof e[i]=="object"?t[i]=k(t[i],e[i]):t[i]=e[i]);return t}var _e=Object.freeze({__proto__:null,unique:x,deepCopy:f,deepMerge:k});class I{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 i of this.values)typeof i!="undefined"&&i!==null&&(e+=i,t++);if(t!==0)return e/t}median(){if(this.values.length===0)return;const e=this.values.slice(0).sort(function(i,s){return i-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 i of this.values)t+=Math.pow(i-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 i of this.values)e(i)&&t.push(i);return new I(t)}}function xe(r,e){const t=new Blob([r],{type:"text/plain"});let i="";typeof window.webkitURL!="undefined"?i=window.webkitURL.createObjectURL(t):i=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=i,s.click()}function ke(r){const e=typeof r!="object"?JSON.parse(r):r;let t="",i="";const s=[];for(const l of e)for(const o in l){let a=o+"";a='"'+a.replace(/"/g,'""')+'",',s.includes(o)||(s.push(o),t+=a)}t=t.slice(0,-1),i+=t+`\r
1
+ var jsPsychModule=function(E){"use strict";var we=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function O(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}const ve=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 Pe=(r,{include:e,exclude:t}={})=>{const i=s=>{const l=o=>typeof o=="string"?s===o:o.test(s);return e?e.some(l):t?!t.some(l):!0};for(const[s,l]of ve(r.constructor.prototype)){if(l==="constructor"||!i(l))continue;const o=Reflect.getOwnPropertyDescriptor(s,l);o&&typeof o.value=="function"&&(r[l]=r[l].bind(r))}return r},A=O(Pe),Ee={name:"jspsych",version:"8.1.0",description:"Behavioral experiments in a browser",type:"module",main:"dist/index.cjs",exports:{".":{import:"./dist/index.js",require:"./dist/index.cjs"},"./css/*":"./css/*"},typings:"dist/index.d.ts",unpkg:"dist/index.browser.min.js",files:["src","dist","css"],source:"src/index.ts",scripts:{test:"jest","test:watch":"npm test -- --watch",tsc:"tsc","build:js":"rollup --config","build:styles":"webpack-cli",build:"run-p build:js build:styles","build:watch":'run-p "build:js -- --watch" "build:styles watch"',prepack:"cp ../../README.md ."},repository:{type:"git",url:"git+https://github.com/jspsych/jsPsych.git",directory:"packages/jspsych"},author:"Josh de Leeuw",license:"MIT",bugs:{url:"https://github.com/jspsych/jsPsych/issues"},homepage:"https://www.jspsych.org",dependencies:{"auto-bind":"^4.0.0","random-words":"^1.1.1",seedrandom:"^3.0.5","type-fest":"^2.9.0"},devDependencies:{"@fontsource/open-sans":"4.5.3","@jspsych/config":"^3.0.1","@types/dom-mediacapture-record":"^1.0.11","base64-inline-loader":"^2.0.1","css-loader":"^6.6.0","mini-css-extract-plugin":"^2.5.3","npm-run-all":"^4.1.5","replace-in-file-webpack-plugin":"^1.0.6",sass:"^1.43.5","sass-loader":"^12.4.0",webpack:"^5.76.0","webpack-cli":"^4.9.2","webpack-remove-empty-scripts":"^0.7.2"}},K=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class _{constructor(e,t){this.dependencies=e,this.extensionsConfiguration=t,this.extensions=Object.fromEntries(t.map(i=>[_.getExtensionNameByClass(i.type),this.dependencies.instantiateExtension(i.type)]))}static getExtensionNameByClass(e){return e.info.name}getExtensionInstanceByClass(e){return this.extensions[_.getExtensionNameByClass(e)]}initializeExtensions(){return K(this,null,function*(){yield Promise.all(this.extensionsConfiguration.map(({type:e,params:t={}})=>{this.getExtensionInstanceByClass(e).initialize(t);const i=e.info;!("version"in i)&&!("data"in i)?console.warn(i.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 i?"data"in i||console.warn(i.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(i.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:i,params:s}of e)(t=this.getExtensionInstanceByClass(i))==null||t.on_start(s)}onLoad(e=[]){var t;for(const{type:i,params:s}of e)(t=this.getExtensionInstanceByClass(i))==null||t.on_load(s)}onFinish(){return K(this,arguments,function*(e=[]){const t=yield Promise.all(e.map(({type:s,params:l})=>{var o;return Promise.resolve((o=this.getExtensionInstanceByClass(s))==null?void 0:o.on_finish(l))})),i=e.length?{extension_type:e.map(({type:s})=>s.info.name),extension_version:e.map(({type:s})=>s.info.version)}:{};return t.unshift(i),Object.assign({},...t)})}}function x(r){return[...new Set(r)]}function f(r){if(!r)return r;let e;if(Array.isArray(r)){e=[];for(const t of r)e.push(f(t));return e}else if(typeof r=="object"&&r!==null){e={};for(const t in r)r.hasOwnProperty(t)&&(e[t]=f(r[t]));return e}else return r}function k(r,e){let t={};for(const i in r)r.hasOwnProperty(i)&&(typeof r[i]=="object"&&e.hasOwnProperty(i)?t[i]=k(r[i],e[i]):t[i]=r[i]);for(const i in e)e.hasOwnProperty(i)&&(t.hasOwnProperty(i)&&typeof e[i]=="object"?t[i]=k(t[i],e[i]):t[i]=e[i]);return t}var _e=Object.freeze({__proto__:null,unique:x,deepCopy:f,deepMerge:k});class I{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 i of this.values)typeof i!="undefined"&&i!==null&&(e+=i,t++);if(t!==0)return e/t}median(){if(this.values.length===0)return;const e=this.values.slice(0).sort(function(i,s){return i-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 i of this.values)t+=Math.pow(i-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 i of this.values)e(i)&&t.push(i);return new I(t)}}function xe(r,e){const t=new Blob([r],{type:"text/plain"});let i="";typeof window.webkitURL!="undefined"?i=window.webkitURL.createObjectURL(t):i=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=i,s.click()}function ke(r){const e=typeof r!="object"?JSON.parse(r):r;let t="",i="";const s=[];for(const l of e)for(const o in l){let a=o+"";a='"'+a.replace(/"/g,'""')+'",',s.includes(o)||(s.push(o),t+=a)}t=t.slice(0,-1),i+=t+`\r
2
2
  `;for(const l of e){t="";for(const o of s){let a=typeof l[o]=="undefined"?"":l[o];typeof a=="object"&&(a=JSON.stringify(a));const n=a+"";t+='"'+n.replace(/"/g,'""')+'",'}t=t.slice(0,-1),i+=t+`\r
3
3
  `}return i}function je(){const r=window.location.search.substr(1).split("&"),e={};for(let t=0;t<r.length;++t){const i=r[t].split("=",2);i.length==1?e[i[0]]="":e[i[0]]=decodeURIComponent(i[1].replace(/\+/g," "))}return e}class p{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 p([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
4
  different value for n.`;return this.trials.length===0?new p:(e>this.trials.length&&(e=this.trials.length),new p(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 p:(e>this.trials.length&&(e=this.trials.length),new p(this.trials.slice(this.trials.length-e,this.trials.length)))}values(){return this.trials}count(){return this.trials.length}readOnly(){return new p(f(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=f(e):t=f([e]);const i=[];for(const s of this.trials){let l=!1;for(const o of t){let a=!0;for(const n of Object.keys(o))typeof s[n]!="undefined"&&s[n]===o[n]||(a=!1);if(a){l=!0;break}}l&&i.push(s)}return new p(i)}filterCustom(e){return new p(this.trials.filter(e))}filterColumns(e){return new p(this.trials.map(t=>Object.fromEntries(e.filter(i=>i in t).map(i=>[i,t[i]]))))}select(e){const t=[];for(const i of this.trials)typeof i[e]!="undefined"&&t.push(i[e]);return new I(t)}ignore(e){Array.isArray(e)||(e=[e]);const t=f(this.trials);for(const i of t)for(const s of e)delete i[s];return new p(t)}uniqueNames(){const e=[];for(const t of this.trials)for(const i of Object.keys(t))e.includes(i)||e.push(i);return e}csv(){return ke(this.trials)}json(e=!1){return e?JSON.stringify(this.trials,null," "):JSON.stringify(this.trials)}localSave(e,t){e=e.toLowerCase();let i;if(e==="json")i=this.json();else if(e==="csv")i=this.csv();else throw new Error('Invalid format specified for localSave. Must be "json" or "csv".');xe(i,t)}}var Te=Object.defineProperty,U=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,F=(r,e,t)=>e in r?Te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ie=(r,e)=>{for(var t in e||(e={}))Oe.call(e,t)&&F(r,t,e[t]);if(U)for(var t of U(e))Ae.call(e,t)&&F(r,t,e[t]);return r};class Le{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 p,this.resultToTrialMap=new WeakMap,this.interactionRecords=new p}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 p(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=je()),this.query_string}getURLVariable(e){return this.urlVariables()[e]}addInteractionRecord(e){const t=Ie({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 Se{constructor(e,t=!1,i=0){this.getRootElement=e,this.areResponsesCaseSensitive=t,this.minimumValidRt=i,this.listeners=new Set,this.heldKeys=new Set,this.areRootListenersRegistered=!1,A(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,i){return!t&&this.heldKeys.has(i)?!1:e==="ALL_KEYS"?!0:e==="NO_KEYS"?!1:e.includes(i)}getKeyboardResponse({callback_function:e,valid_responses:t="ALL_KEYS",rt_method:i="performance",persist:s,audio_context:l,audio_context_start_time:o,allow_held_key:a=!1,minimum_valid_rt:n=this.minimumValidRt}){i!=="performance"&&i!=="audio"&&(console.log('Invalid RT method specified in getKeyboardResponse. Defaulting to "performance" method.'),i="performance");const u=i==="performance"?performance.now():o*1e3;this.registerRootListeners(),!this.areResponsesCaseSensitive&&typeof t!="string"&&(t=t.map(d=>d.toLowerCase()));const c=d=>{const h=Math.round((i=="performance"?performance.now():l.currentTime*1e3)-u);if(h<n)return;const y=this.toLowerCaseIfInsensitive(d.key);this.isResponseValid(t,a,y)&&(d.preventDefault(),s||this.cancelKeyboardResponse(c),e({key:d.key,rt:h}))};return this.listeners.add(c),c}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 g=(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))(g||{}),L=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class j{constructor(e,t={useWebAudio:!1}){this.src=e,this.useWebAudio=t.useWebAudio,this.audioContext=t.audioContext||null}load(){return L(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 L(this,null,function*(){const t=yield(yield fetch(e)).arrayBuffer(),i=yield this.audioContext.decodeAudioData(t),s=this.audioContext.createBufferSource();return s.buffer=i,s.connect(this.audioContext.destination),i})}preloadHTMLAudio(e){return L(this,null,function*(){return new Promise((t,i)=>{const s=new Audio(e);s.addEventListener("canplaythrough",()=>{t(s)}),s.addEventListener("error",l=>{i(l)}),s.addEventListener("abort",l=>{i(l)})})})}}var Ce=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});const G=[g.AUDIO,g.IMAGE,g.VIDEO];class Me{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 Ce(this,null,function*(){return this.audio_buffers[e]instanceof j?this.audio_buffers[e]:(this.audio_buffers[e]=new j(e,{useWebAudio:this.useWebaudio,audioContext:this.context}),yield this.audio_buffers[e].load(),this.audio_buffers[e])})}preloadAudio(e,t=()=>{},i=l=>{},s=l=>{}){e=x(e.flat());let l=0;if(e.length==0){t();return}for(const o of e)this.audio_buffers[o]instanceof j?(l++,i(o),l==e.length&&t()):(this.audio_buffers[o]=new j(o,{useWebAudio:this.useWebaudio,audioContext:this.context}),this.audio_buffers[o].load().then(()=>{l++,i(o),l==e.length&&t()}).catch(a=>{s(a)}))}preloadImages(e,t=()=>{},i=l=>{},s=l=>{}){e=x(e.flat());var l=0;if(e.length===0){t();return}for(let o=0;o<e.length;o++){const a=new Image,n=e[o];a.onload=()=>{l++,i(n),l===e.length&&t()},a.onerror=u=>{s({source:n,error:u})},a.src=n,this.img_cache[n]=a,this.preload_requests.push(a)}}preloadVideo(e,t=()=>{},i=l=>{},s=l=>{}){e=x(e.flat());let l=0;if(e.length===0){t();return}for(const o of e){const a=this.video_buffers,n=new XMLHttpRequest;n.open("GET",o,!0),n.responseType="blob",n.onload=()=>{if(n.status===200||n.status===0){const u=n.response;a[o]=URL.createObjectURL(u),l++,i(o),l===e.length&&t()}},n.onerror=u=>{let c=u;n.status==404&&(c="404"),s({source:o,error:c})},n.onloadend=u=>{n.status==404&&s({source:o,error:"404"})},n.send(),this.preload_requests.push(n)}}getAutoPreloadList(e){const t=Object.fromEntries(G.map(s=>[s,new Set])),i=(s,l)=>{var o,a,n,u;if(typeof s.timeline!="undefined")for(const c of s.timeline)i(c,(o=s.type)!=null?o:l);else if((n=(a=s.type)!=null?a:l)!=null&&n.info){const{name:c,parameters:d}=((u=s.type)!=null?u:l).info;this.preloadMap.has(c)||this.preloadMap.set(c,Object.fromEntries(Object.entries(d).filter(([h,{type:y,preload:P}])=>G.includes(y)&&(P!=null?P:!0)).map(([h,{type:y}])=>[h,y])));for(const[h,y]of Object.entries(this.preloadMap.get(c))){const P=s[h],ye=t[y];if(typeof P=="string")ye.add(P);else if(Array.isArray(P))for(const be of P.flat())typeof be=="string"&&ye.add(be)}}};return i({timeline:e}),{images:[...t[g.IMAGE]],audio:[...t[g.AUDIO]],video:[...t[g.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){this.camera_stream=e;const i=new MediaRecorder(e,t);this.camera_recorder=i}getCameraStream(){return this.camera_stream}getCameraRecorder(){return this.camera_recorder}}var Ne=Object.defineProperty,W=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,Y=(r,e,t)=>e in r?Ne(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,J=(r,e)=>{for(var t in e||(e={}))Re.call(e,t)&&Y(r,t,e[t]);if(W)for(var t of W(e))De.call(e,t)&&Y(r,t,e[t]);return r};class Ve{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,i=0){i>0?this.setJsPsychTimeout(()=>{e.value=t},i):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 i;if(e=="NO_KEYS")i=null;else if(e=="ALL_KEYS")i=t[Math.floor(Math.random()*t.length)];else{const s=e.flat();i=s[Math.floor(Math.random()*s.length)]}return i}mergeSimulationData(e,t){return J(J({},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 i=e.sequence_reps*e.frame_time*e.stimuli.length;t.rt<i&&(t.rt=null,t.response=null)}}}class qe{constructor(){this.timeout_handlers=[]}setTimeout(e,t){const i=window.setTimeout(e,t);return this.timeout_handlers.push(i),i}clearAllTimeouts(){for(const e of this.timeout_handlers)clearTimeout(e);this.timeout_handlers=[]}}function ze(r){const e=r.getInitSettings(),t=new Se(r.getDisplayContainerElement,e.case_sensitive_responses,e.minimum_valid_rt),i=new qe,s=new Me(e.use_webaudio),l=new Ve(r.getDisplayContainerElement,i.setTimeout.bind(i));return Object.assign({},...[t,i,s,l].map(o=>A(o)))}var S=["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 H(r){function e(){return r&&r.maxLength>1?t():i()}function t(){for(var c=!1,d;!c;)d=i(),d.length<=r.maxLength&&(c=!0);return d}function i(){return S[s(S.length)]}function s(c){return Math.floor(Math.random()*c)}if(typeof r=="undefined")return e();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 l=r.min+s(r.max+1-r.min),o=[],a="",n=0,u=0;u<l*r.wordsPerString;u++)n===r.wordsPerString-1?a+=r.formatter(e(),n):a+=r.formatter(e(),n)+r.separator,n++,(u+1)%r.wordsPerString===0&&(o.push(a),a="",n=0);return typeof r.join=="string"&&(o=o.join(r.join)),o}var Be=H;H.wordList=S;var $e=O(Be),C={exports:{}};C.exports,function(r){(function(e,t,i){function s(n){var u=this,c=a();u.next=function(){var d=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=d-(u.c=d|0)},u.c=1,u.s0=c(" "),u.s1=c(" "),u.s2=c(" "),u.s0-=c(n),u.s0<0&&(u.s0+=1),u.s1-=c(n),u.s1<0&&(u.s1+=1),u.s2-=c(n),u.s2<0&&(u.s2+=1),c=null}function l(n,u){return u.c=n.c,u.s0=n.s0,u.s1=n.s1,u.s2=n.s2,u}function o(n,u){var c=new s(n),d=u&&u.state,h=c.next;return h.int32=function(){return c.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,d&&(typeof d=="object"&&l(d,c),h.state=function(){return l(c,{})}),h}function a(){var n=4022871197,u=function(c){c=String(c);for(var d=0;d<c.length;d++){n+=c.charCodeAt(d);var h=.02519603282416938*n;n=h>>>0,h-=n,h*=n,n=h>>>0,h-=n,n+=h*4294967296}return(n>>>0)*23283064365386963e-26};return u}t&&t.exports?t.exports=o:i&&i.amd?i(function(){return o}):this.alea=o})(we,r,!1)}(C);var Ke=C.exports,Ue=O(Ke),Fe=Object.defineProperty,Ge=Object.defineProperties,We=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,Ye=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Q=(r,e,t)=>e in r?Fe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,He=(r,e)=>{for(var t in e||(e={}))Ye.call(e,t)&&Q(r,t,e[t]);if(X)for(var t of X(e))Je.call(e,t)&&Q(r,t,e[t]);return r},Xe=(r,e)=>Ge(r,We(e));function Qe(r=Math.random().toString()){return Math.random=Ue(r),r}function M(r,e,t=!1){const i=Array.isArray(r),s=Array.isArray(e);if(!i)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 n=0;n<r.length;n++)a.push(e);e=a}else e=e.slice(0,r.length)}else{let a=[];for(let n=0;n<r.length;n++)a.push(e);e=a}let l=[];for(let a=0;a<r.length;a++)for(let n=0;n<e[a];n++)r[a]==null||typeof r[a]!="object"?l.push(r[a]):l.push(Object.assign({},r[a]));let o=b(l);return t&&(o=ot(o)),o}function b(r){Array.isArray(r)||console.error("Argument to shuffle() must be an array.");const e=r.slice(0);let t=e.length,i,s;for(;t;)s=Math.floor(Math.random()*t--),i=e[t],e[t]=e[s],e[s]=i;return e}function Ze(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(i,s){return i===s});const t=b(r);for(let i=0;i<t.length-1;i++)if(e(t[i],t[i+1])){let s=Math.floor(Math.random()*(t.length-2))+1;for(;e(t[i+1],t[s])||e(t[i+1],t[s+1])||e(t[i+1],t[s-1])||e(t[i],t[s]);)s=Math.floor(Math.random()*(t.length-2))+1;const l=t[s];t[s]=t[i+1],t[i+1]=l}return t}function Z(r,e=!1){const t=r.length;if(t==1)return console.warn("shuffleAlternateGroups() was called with only one group. Defaulting to simple shuffle."),b(r[0]);let i=[];for(let a=0;a<t;a++)i.push(a);e&&(i=b(i));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(b(r[a]));const o=[];for(let a=0;a<l;a++)for(let n=0;n<i.length;n++)o.push(s[i[n]][a]);return o}function ee(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."),b(r).slice(0,e)}function te(r,e,t){Array.isArray(r)||console.error("First argument to sampleWithReplacement() must be an array");const i=[];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 o=0;for(const a of t)o+=a;for(const a of t)i.push(a/o)}else for(let o=0;o<r.length;o++)i.push(1/r.length);const s=[i[0]];for(let o=1;o<i.length;o++)s.push(i[o]+s[o-1]);const l=[];for(let o=0;o<e;o++){const a=Math.random();let n=0;for(;a>s[n];)n++;l.push(r[n])}return l}function et(r,e=1,t=!1){let i=[{}];for(const[s,l]of Object.entries(r)){const o=[];for(const a of l)for(const n of i)o.push(Xe(He({},n),{[s]:a}));i=o}return M(i,e,t)}function tt(r=32){let e="";const t="0123456789abcdefghjklmnopqrstuvwxyz";for(let i=0;i<r;i++)e+=t[Math.floor(Math.random()*t.length)];return e}function rt(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 it(r){return Math.random()<=r?1:0}function N(r,e){return at()*e+r}function R(r){return-Math.log(Math.random())/r}function st(r,e,t,i=!1){let s=N(r,e)+R(t);if(i)for(;s<=0;)s=N(r,e)+R(t);return s}function nt(r){return $e(r)}function at(){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 ot(r){const e={};for(const t of r)for(const i of Object.keys(t))typeof e[i]=="undefined"&&(e[i]=[]),e[i].push(t[i]);return e}var lt=Object.freeze({__proto__:null,setSeed:Qe,repeat:M,shuffle:b,shuffleNoRepeats:Ze,shuffleAlternateGroups:Z,sampleWithoutReplacement:ee,sampleWithReplacement:te,factorial:et,randomID:tt,randomInt:rt,sampleBernoulli:it,sampleNormal:N,sampleExponential:R,sampleExGaussian:st,randomWords:nt});function re(){const r={previewMode:!1,outsideTurk:!1,hitId:"INVALID_URL_PARAMETER",assignmentId:"INVALID_URL_PARAMETER",workerId:"INVALID_URL_PARAMETER",turkSubmitTo:"INVALID_URL_PARAMETER"},e=function(i,s){s=s.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");const l="[\\?&]"+s+"=([^&#]*)",o=new RegExp(l).exec(i);return o==null?"":o[1]},t=e(window.location.href,"assignmentId")?window.location.href:document.referrer;return["assignmentId","hitId","workerId","turkSubmitTo"].map(function(i){r[i]=unescape(e(t,i))}),r.previewMode=r.assignmentId=="ASSIGNMENT_ID_NOT_AVAILABLE",r.outsideTurk=!r.previewMode&&r.hitId===""&&r.assignmentId==""&&r.workerId=="",r}function ut(r){const e=re(),t=e.assignmentId,i=e.turkSubmitTo;if(!t||!i)return;const s=document.createElement("form");s.method="POST",s.action=i+"/mturk/externalSubmit?assignmentId="+t;for(const l in r)if(r.hasOwnProperty(l)){const o=document.createElement("input");o.type="hidden",o.name=l,o.id=l,o.value=r[l],s.appendChild(o)}document.body.appendChild(s),s.submit()}var ct=Object.freeze({__proto__:null,turkInfo:re,submitToTurk:ut});class ht{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 D{constructor(e){this.name=e}}const dt=["timeline","timeline_variables","name","repetitions","loop_function","conditional_function","randomize_order","sample","on_timeline_start","on_timeline_finish"];function pt(r){return!V(r)}function V(r){return Boolean(r.timeline)||Array.isArray(r)}var m=(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))(m||{});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 mt(r){return r&&typeof r.then=="function"}function ft(r){return new Promise(e=>setTimeout(e,r))}function se([r,...e]){let t=r!=null?r:"";for(const i of e)t+=Number.isNaN(Number.parseInt(i))?`.${i}`:`[${i}]`;return t}function gt(r){return typeof r=="object"&&r!==null}class q{constructor(){this.cache=new Map}static lookupChild(e,t){let i=!1,s;return Number.isNaN(Number.parseInt(t))?Object.hasOwn(e,t)&&(i=!0,s=e[t]):Number.parseInt(t)<e.length&&(i=!0,s=e[t]),{doesPathExist:i,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=i=>{const s=i.slice(0,-1),l=i[i.length-1];if(!this.has(s)&&s.length>0&&!t(s).doesPathExist)return{doesPathExist:!1};const o=this.get(s);if(!gt(o))return{doesPathExist:!1};const a=q.lookupChild(o,l);return a.doesPathExist&&this.set(i,a.value),a};return t(e)}}var yt=Object.defineProperty,ne=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,ae=(r,e,t)=>e in r?yt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,oe=(r,e)=>{for(var t in e||(e={}))bt.call(e,t)&&ae(r,t,e[t]);if(ne)for(var t of ne(e))wt.call(e,t)&&ae(r,t,e[t]);return r};class le{constructor(e){this.dependencies=e,this.status=m.PENDING,this.parameterValueCache=new q}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:i=!0,recursive:s=!0,cacheResult:l=!0,replaceResult:o}=t;typeof e=="string"&&(e=[e]);let{doesPathExist:a,value:n}=this.parameterValueCache.lookup(e);return!a&&s&&this.parent&&(n=this.parent.getParameterValue(e,t)),typeof n=="function"&&i&&(n=n()),n instanceof D&&(n=this.evaluateTimelineVariable(n)),typeof o=="function"&&(n=o(n)),l&&this.parameterValueCache.set(e,n),n}getDataParameter(){var e;const t=this.getParameterValue("data",{recursive:!1});return oe(oe({},Object.fromEntries(typeof t=="object"?Object.keys(t).map(i=>[i,this.getParameterValue(["data",i])]):[])),(e=this.parent)==null?void 0:e.getDataParameter())}}var vt=Object.defineProperty,Pt=Object.defineProperties,Et=Object.getOwnPropertyDescriptors,ue=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable,ce=(r,e,t)=>e in r?vt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,z=(r,e)=>{for(var t in e||(e={}))_t.call(e,t)&&ce(r,t,e[t]);if(ue)for(var t of ue(e))xt.call(e,t)&&ce(r,t,e[t]);return r},kt=(r,e)=>Pt(r,Et(e)),B=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class T extends le{constructor(e,t,i){super(e),this.description=t,this.parent=i,this.onLoad=()=>{this.runParameterCallback("on_load"),this.dependencies.runOnLoadExtensionCallbacks(this.getParameterValue("extensions"))},this.initializeParameterValueCache(),this.trialObject=f(t),this.pluginClass=this.getParameterValue("type",{evaluateFunctions:!1}),this.pluginInfo=this.pluginClass.info,!("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 B(this,null,function*(){var e;this.status=m.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=m.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 ft(t)),this.resetParameterValueCache()})}executeTrial(){return B(this,null,function*(){const e=this.dependencies.finishTrialPromise.get();let t=!1;e.then(()=>{t=!0});const{trialReturnValue:i,hasTrialBeenSimulated:s}=this.invokeTrialMethod();let l;return mt(i)?(l=yield Promise.race([i,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 i=this.getSimulationOptions();if(i.simulate!==!1)return{hasTrialBeenSimulated:!0,trialReturnValue:this.pluginInstance.simulate(this.trialObject,(e=i.mode)!=null?e:t,i,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 o=this.trialObject[s];typeof o=="function"&&(o=o.toString()),e[s]=o}else!l&&Object.hasOwn(e,s)&&delete e[s];else console.warn(`Non-existent parameter "${s}" specified in save_trial_parameters.`);e=kt(z(z({},this.getDataParameter()),e),{trial_type:this.pluginInfo.name,trial_index:this.index,plugin_version:this.pluginInfo.version?this.pluginInfo.version:null});const i=this.getParameterValue("save_timeline_variables");return i===!0?e.timeline_variables=z({},this.parent.getAllTimelineVariables()):Array.isArray(i)&&(e.timeline_variables=Object.fromEntries(Object.entries(this.parent.getAllTimelineVariables()).filter(([s,l])=>i.includes(s)))),e}runParameterCallback(e,...t){const i=this.getParameterValue(e,{evaluateFunctions:!1});if(i)return i(...t)}onStart(){this.dependencies.onTrialStart(this),this.runParameterCallback("on_start",this.trialObject),this.dependencies.runOnStartExtensionCallbacks(this.getParameterValue("extensions"))}onFinish(){return B(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 dt.includes(typeof e=="string"?e:e[0])&&(t.recursive=!1),super.getParameterValue(e,t)}getSimulationOptions(){const e=this.getParameterValue("simulation_options",{replaceResult:(t={})=>{var i,s;if(typeof t=="string"){const l=this.dependencies.getGlobalSimulationOptions();t=(s=(i=l[t])!=null?i:l.default)!=null?s:{}}return k(f(this.dependencies.getGlobalSimulationOptions().default),f(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=(i,s,l=[])=>{for(const[o,a]of Object.entries(s)){const n=[...l,o];let u=this.getParameterValue(n,{evaluateFunctions:a.type!==g.FUNCTION,replaceResult:c=>{if(typeof c=="undefined"){if(typeof a.default=="undefined")throw new Error(`You must specify a value for the "${se(n)}" parameter in the "${this.pluginInfo.name}" plugin.`);return a.default}else return c}});if(a.array&&!Array.isArray(u)){const c=se(n);throw new Error(`A non-array value (\`${u}\`) was provided for the array parameter "${c}" in the "${this.pluginInfo.name}" plugin. Please make sure that "${c}" is an array.`)}a.type===g.COMPLEX&&a.nested&&(a.array?u=u.map((c,d)=>{const h=[...n,d.toString()],y=this.getParameterValue(h);return e(y,a.nested,h),y}):e(u,a.nested,n)),i[o]=u}},t=f(this.description);e(t,this.pluginInfo.parameters),this.trialObject=t}getLatestNode(){return this}getActiveTimelineByName(e){}}var jt=Object.defineProperty,he=Object.getOwnPropertySymbols,Tt=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable,de=(r,e,t)=>e in r?jt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,pe=(r,e)=>{for(var t in e||(e={}))Tt.call(e,t)&&de(r,t,e[t]);if(he)for(var t of he(e))Ot.call(e,t)&&de(r,t,e[t]);return r},At=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class w extends le{constructor(e,t,i){super(e),this.parent=i,this.children=[],this.shouldAbort=!1,this.resumePromise=new ie,this.description=Array.isArray(t)?{timeline:t}:t,this.initializeParameterValueCache()}run(){return At(this,null,function*(){typeof this.index=="undefined"&&(this.index=0),this.status=m.RUNNING;const{conditional_function:e,loop_function:t,repetitions:i=1}=this.description;let s=this.generateTimelineVariableOrder();this.setCurrentTimelineVariablesByIndex(s[0]);let l=!0,o;if(!e||e()){this.onStart();for(let a=0;a<i;a++)do{o=[],l?l=!1:s=this.generateTimelineVariableOrder();for(const n of s){this.setCurrentTimelineVariablesByIndex(n);for(const u of this.instantiateChildNodes()){const c=this.currentChild;if(this.currentChild=u,u.index=c?c.getLatestNode().index+1:this.index,yield u.run(),this.status===m.PAUSED&&(yield this.resumePromise.get()),this.shouldAbort){this.status=m.ABORTED;return}o.push(...this.currentChild.getResults())}}}while(t&&t(new p(o)));this.onFinish()}this.status=m.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 w&&this.currentChild.pause(),this.status=m.PAUSED}resume(){this.status==m.PAUSED&&(this.currentChild instanceof w&&this.currentChild.resume(),this.status=m.RUNNING,this.resumePromise.resolve())}abort(){(this.status===m.RUNNING||this.status===m.PAUSED)&&(this.currentChild instanceof w&&this.currentChild.abort(),this.shouldAbort=!0,this.status===m.PAUSED&&this.resume())}instantiateChildNodes(){const e=this.description.timeline.map(t=>V(t)?new w(this.dependencies,t,this):new T(this.dependencies,t,this));return this.children.push(...e),e}setCurrentTimelineVariablesByIndex(e){var t;this.currentTimelineVariables=pe(pe({},(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 i=[...Array(t).keys()];const s=this.description.sample;if(s)switch(s.type){case"custom":i=s.fn(i);break;case"with-replacement":i=te(i,s.size,s.weights);break;case"without-replacement":i=ee(i,s.size);break;case"fixed-repetitions":i=M(i,s.size);break;case"alternate-groups":i=Z(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&&(i=b(i)),i}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 T){const i=t.getResult();i&&e.push(i)}else t instanceof w&&e.push(...t.getResults());return e}getNaiveProgress(){if(this.status===m.PENDING)return 0;const e=this.getLatestNode();if(!e)return 1;let t=e.index;return e.getStatus()===m.COMPLETED&&t++,Math.min(t/this.getNaiveTrialCount(),1)}getNaiveTrialCount(){const e=t=>{var i,s,l;const o=a=>a.map(n=>e(n)).reduce((n,u)=>n+u);if(Array.isArray(t))return o(t);if(pt(t))return 1;if(V(t)){let a=((i=t.timeline_variables)==null?void 0:i.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(n=>n.length).reduce((n,u)=>n+u,0);break}return o(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 It=Object.defineProperty,me=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,fe=(r,e,t)=>e in r?It(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)&&fe(r,t,e[t]);if(me)for(var t of me(e))St.call(e,t)&&fe(r,t,e[t]);return r},$=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class ge{constructor(e){this.turk=ct,this.randomization=lt,this.utils=_e,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 i=t.getResult();i&&(i.time_elapsed=this.getTotalTime(),this.data.write(t))},onTrialFinished:t=>{const i=t.getResult();this.options.on_trial_finish(i),i&&this.options.on_data_update(i),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,i;return{time:this.getTotalTime(),trial:(i=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?i:0}},onInteractionRecordAdded:t=>{this.options.on_interaction_data_update(t)},getDisplayElement:()=>this.getDisplayElement()},e=Ct({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,A(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 Le(this.dataDependencies),this.pluginAPI=ze(this),this.extensionManager=new _(this.extensionManagerDependencies,e.extensions)}version(){return Ee.version}run(e){return $(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 w(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 $(this,arguments,function*(t,i="data-only",s={}){this.simulationMode=i,this.simulationOptions=s,yield this.run(t)})}getProgress(){var e,t,i,s;return{total_trials:(e=this.timeline)==null?void 0:e.getNaiveTrialCount(),current_trial_global:(i=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?i: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 T&&(t=t.parent),t instanceof w&&t.abort()}abortTimelineByName(e){var t;const i=(t=this.timeline)==null?void 0:t.getActiveTimelineByName(e);i&&i.abort()}getCurrentTrial(){var e;const t=(e=this.timeline)==null?void 0:e.getLatestNode();if(t instanceof T)return t.description}getInitSettings(){return this.options}timelineVariable(e){return new D(e)}evaluateTimelineVariable(e){var t,i;return(i=(t=this.timeline)==null?void 0:t.getLatestNode())==null?void 0:i.evaluateTimelineVariable(new D(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}get extensions(){var e,t;return(t=(e=this.extensionManager)==null?void 0:e.extensions)!=null?t:{}}prepareDom(){return $(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 i=document.createElement("div");if(i.className="jspsych-content-wrapper",i.appendChild(t),this.displayContainerElement=e.display_element,this.displayContainerElement.appendChild(i),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 ht(s,this.options.message_progress_bar),this.getDisplayContainerElement().insertAdjacentElement("afterbegin",s)}})}finishTrial(e){this.finishTrialPromise.resolve(e)}}class v 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 v("`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.")},get data(){throw new v},get randomization(){throw new v},get turk(){throw new v},get pluginAPI(){throw new v},get ALL_KEYS(){throw new v('jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.')},get NO_KEYS(){throw new v('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 Mt(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,i])=>[t,{get(){throw new v(i)}}]))),e}return E.DataCollection=p,E.JsPsych=ge,E.ParameterType=g,E.initJsPsych=Mt,E}({}),initJsPsych=jsPsychModule.initJsPsych;
6
- //# sourceMappingURL=https://unpkg.com/jspsych@8.0.2/dist/index.browser.min.js.map
5
+ different value for n.`;return this.trials.length===0?new p:(e>this.trials.length&&(e=this.trials.length),new p(this.trials.slice(this.trials.length-e,this.trials.length)))}values(){return this.trials}count(){return this.trials.length}readOnly(){return new p(f(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=f(e):t=f([e]);const i=[];for(const s of this.trials){let l=!1;for(const o of t){let a=!0;for(const n of Object.keys(o))typeof s[n]!="undefined"&&s[n]===o[n]||(a=!1);if(a){l=!0;break}}l&&i.push(s)}return new p(i)}filterCustom(e){return new p(this.trials.filter(e))}filterColumns(e){return new p(this.trials.map(t=>Object.fromEntries(e.filter(i=>i in t).map(i=>[i,t[i]]))))}select(e){const t=[];for(const i of this.trials)typeof i[e]!="undefined"&&t.push(i[e]);return new I(t)}ignore(e){Array.isArray(e)||(e=[e]);const t=f(this.trials);for(const i of t)for(const s of e)delete i[s];return new p(t)}uniqueNames(){const e=[];for(const t of this.trials)for(const i of Object.keys(t))e.includes(i)||e.push(i);return e}csv(){return ke(this.trials)}json(e=!1){return e?JSON.stringify(this.trials,null," "):JSON.stringify(this.trials)}localSave(e,t){e=e.toLowerCase();let i;if(e==="json")i=this.json();else if(e==="csv")i=this.csv();else throw new Error('Invalid format specified for localSave. Must be "json" or "csv".');xe(i,t)}}var Te=Object.defineProperty,U=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,F=(r,e,t)=>e in r?Te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ie=(r,e)=>{for(var t in e||(e={}))Oe.call(e,t)&&F(r,t,e[t]);if(U)for(var t of U(e))Ae.call(e,t)&&F(r,t,e[t]);return r};class Le{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 p,this.resultToTrialMap=new WeakMap,this.interactionRecords=new p}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 p(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=je()),this.query_string}getURLVariable(e){return this.urlVariables()[e]}addInteractionRecord(e){const t=Ie({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 Se{constructor(e,t=!1,i=0){this.getRootElement=e,this.areResponsesCaseSensitive=t,this.minimumValidRt=i,this.listeners=new Set,this.heldKeys=new Set,this.areRootListenersRegistered=!1,A(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,i){return!t&&this.heldKeys.has(i)?!1:e==="ALL_KEYS"?!0:e==="NO_KEYS"?!1:e.includes(i)}getKeyboardResponse({callback_function:e,valid_responses:t="ALL_KEYS",rt_method:i="performance",persist:s,audio_context:l,audio_context_start_time:o,allow_held_key:a=!1,minimum_valid_rt:n=this.minimumValidRt}){i!=="performance"&&i!=="audio"&&(console.log('Invalid RT method specified in getKeyboardResponse. Defaulting to "performance" method.'),i="performance");const u=i==="performance"?performance.now():o*1e3;this.registerRootListeners(),!this.areResponsesCaseSensitive&&typeof t!="string"&&(t=t.map(h=>h.toLowerCase()));const c=h=>{const d=Math.round((i=="performance"?performance.now():l.currentTime*1e3)-u);if(d<n)return;const y=this.toLowerCaseIfInsensitive(h.key);this.isResponseValid(t,a,y)&&(h.preventDefault(),s||this.cancelKeyboardResponse(c),e({key:h.key,rt:d}))};return this.listeners.add(c),c}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 g=(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))(g||{}),L=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class j{constructor(e,t={useWebAudio:!1}){this.src=e,this.useWebAudio=t.useWebAudio,this.audioContext=t.audioContext||null}load(){return L(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 L(this,null,function*(){const t=yield(yield fetch(e)).arrayBuffer(),i=yield this.audioContext.decodeAudioData(t),s=this.audioContext.createBufferSource();return s.buffer=i,s.connect(this.audioContext.destination),i})}preloadHTMLAudio(e){return L(this,null,function*(){return new Promise((t,i)=>{const s=new Audio(e);s.addEventListener("canplaythrough",()=>{t(s)}),s.addEventListener("error",l=>{i(l)}),s.addEventListener("abort",l=>{i(l)})})})}}var Ce=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});const G=[g.AUDIO,g.IMAGE,g.VIDEO];class Me{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 Ce(this,null,function*(){return this.audio_buffers[e]instanceof j?this.audio_buffers[e]:(this.audio_buffers[e]=new j(e,{useWebAudio:this.useWebaudio,audioContext:this.context}),yield this.audio_buffers[e].load(),this.audio_buffers[e])})}preloadAudio(e,t=()=>{},i=l=>{},s=l=>{}){e=x(e.flat());let l=0;if(e.length==0){t();return}for(const o of e)this.audio_buffers[o]instanceof j?(l++,i(o),l==e.length&&t()):(this.audio_buffers[o]=new j(o,{useWebAudio:this.useWebaudio,audioContext:this.context}),this.audio_buffers[o].load().then(()=>{l++,i(o),l==e.length&&t()}).catch(a=>{s(a)}))}preloadImages(e,t=()=>{},i=l=>{},s=l=>{}){e=x(e.flat());var l=0;if(e.length===0){t();return}for(let o=0;o<e.length;o++){const a=new Image,n=e[o];a.onload=()=>{l++,i(n),l===e.length&&t()},a.onerror=u=>{s({source:n,error:u})},a.src=n,this.img_cache[n]=a,this.preload_requests.push(a)}}preloadVideo(e,t=()=>{},i=l=>{},s=l=>{}){e=x(e.flat());let l=0;if(e.length===0){t();return}for(const o of e){const a=this.video_buffers,n=new XMLHttpRequest;n.open("GET",o,!0),n.responseType="blob",n.onload=()=>{if(n.status===200||n.status===0){const u=n.response;a[o]=URL.createObjectURL(u),l++,i(o),l===e.length&&t()}},n.onerror=u=>{let c=u;n.status==404&&(c="404"),s({source:o,error:c})},n.onloadend=u=>{n.status==404&&s({source:o,error:"404"})},n.send(),this.preload_requests.push(n)}}getAutoPreloadList(e){const t=Object.fromEntries(G.map(s=>[s,new Set])),i=(s,l)=>{var o,a,n,u;if(typeof s.timeline!="undefined")for(const c of s.timeline)i(c,(o=s.type)!=null?o:l);else if((n=(a=s.type)!=null?a:l)!=null&&n.info){const{name:c,parameters:h}=((u=s.type)!=null?u:l).info;this.preloadMap.has(c)||this.preloadMap.set(c,Object.fromEntries(Object.entries(h).filter(([d,{type:y,preload:P}])=>G.includes(y)&&(P!=null?P:!0)).map(([d,{type:y}])=>[d,y])));for(const[d,y]of Object.entries(this.preloadMap.get(c))){const P=s[d],ye=t[y];if(typeof P=="string")ye.add(P);else if(Array.isArray(P))for(const be of P.flat())typeof be=="string"&&ye.add(be)}}};return i({timeline:e}),{images:[...t[g.IMAGE]],audio:[...t[g.AUDIO]],video:[...t[g.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){this.camera_stream=e;const i=new MediaRecorder(e,t);this.camera_recorder=i}getCameraStream(){return this.camera_stream}getCameraRecorder(){return this.camera_recorder}}var Ne=Object.defineProperty,W=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,Y=(r,e,t)=>e in r?Ne(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,J=(r,e)=>{for(var t in e||(e={}))Re.call(e,t)&&Y(r,t,e[t]);if(W)for(var t of W(e))De.call(e,t)&&Y(r,t,e[t]);return r};class Ve{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,i=0){i>0?this.setJsPsychTimeout(()=>{e.value=t},i):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 i;if(e=="NO_KEYS")i=null;else if(e=="ALL_KEYS")i=t[Math.floor(Math.random()*t.length)];else{const s=e.flat();i=s[Math.floor(Math.random()*s.length)]}return i}mergeSimulationData(e,t){return J(J({},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 i=e.sequence_reps*e.frame_time*e.stimuli.length;t.rt<i&&(t.rt=null,t.response=null)}}}class qe{constructor(){this.timeout_handlers=[]}setTimeout(e,t){const i=window.setTimeout(e,t);return this.timeout_handlers.push(i),i}clearAllTimeouts(){for(const e of this.timeout_handlers)clearTimeout(e);this.timeout_handlers=[]}}function ze(r){const e=r.getInitSettings(),t=new Se(r.getDisplayContainerElement,e.case_sensitive_responses,e.minimum_valid_rt),i=new qe,s=new Me(e.use_webaudio),l=new Ve(r.getDisplayContainerElement,i.setTimeout.bind(i));return Object.assign({},...[t,i,s,l].map(o=>A(o)))}var S=["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 H(r){function e(){return r&&r.maxLength>1?t():i()}function t(){for(var c=!1,h;!c;)h=i(),h.length<=r.maxLength&&(c=!0);return h}function i(){return S[s(S.length)]}function s(c){return Math.floor(Math.random()*c)}if(typeof r=="undefined")return e();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 l=r.min+s(r.max+1-r.min),o=[],a="",n=0,u=0;u<l*r.wordsPerString;u++)n===r.wordsPerString-1?a+=r.formatter(e(),n):a+=r.formatter(e(),n)+r.separator,n++,(u+1)%r.wordsPerString===0&&(o.push(a),a="",n=0);return typeof r.join=="string"&&(o=o.join(r.join)),o}var Be=H;H.wordList=S;var $e=O(Be),C={exports:{}};C.exports,function(r){(function(e,t,i){function s(n){var u=this,c=a();u.next=function(){var h=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=h-(u.c=h|0)},u.c=1,u.s0=c(" "),u.s1=c(" "),u.s2=c(" "),u.s0-=c(n),u.s0<0&&(u.s0+=1),u.s1-=c(n),u.s1<0&&(u.s1+=1),u.s2-=c(n),u.s2<0&&(u.s2+=1),c=null}function l(n,u){return u.c=n.c,u.s0=n.s0,u.s1=n.s1,u.s2=n.s2,u}function o(n,u){var c=new s(n),h=u&&u.state,d=c.next;return d.int32=function(){return c.next()*4294967296|0},d.double=function(){return d()+(d()*2097152|0)*11102230246251565e-32},d.quick=d,h&&(typeof h=="object"&&l(h,c),d.state=function(){return l(c,{})}),d}function a(){var n=4022871197,u=function(c){c=String(c);for(var h=0;h<c.length;h++){n+=c.charCodeAt(h);var d=.02519603282416938*n;n=d>>>0,d-=n,d*=n,n=d>>>0,d-=n,n+=d*4294967296}return(n>>>0)*23283064365386963e-26};return u}t&&t.exports?t.exports=o:i&&i.amd?i(function(){return o}):this.alea=o})(we,r,!1)}(C);var Ke=C.exports,Ue=O(Ke),Fe=Object.defineProperty,Ge=Object.defineProperties,We=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,Ye=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Q=(r,e,t)=>e in r?Fe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,He=(r,e)=>{for(var t in e||(e={}))Ye.call(e,t)&&Q(r,t,e[t]);if(X)for(var t of X(e))Je.call(e,t)&&Q(r,t,e[t]);return r},Xe=(r,e)=>Ge(r,We(e));function Qe(r=Math.random().toString()){return Math.random=Ue(r),r}function M(r,e,t=!1){const i=Array.isArray(r),s=Array.isArray(e);if(!i)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 n=0;n<r.length;n++)a.push(e);e=a}else e=e.slice(0,r.length)}else{let a=[];for(let n=0;n<r.length;n++)a.push(e);e=a}let l=[];for(let a=0;a<r.length;a++)for(let n=0;n<e[a];n++)r[a]==null||typeof r[a]!="object"?l.push(r[a]):l.push(Object.assign({},r[a]));let o=b(l);return t&&(o=ot(o)),o}function b(r){Array.isArray(r)||console.error("Argument to shuffle() must be an array.");const e=r.slice(0);let t=e.length,i,s;for(;t;)s=Math.floor(Math.random()*t--),i=e[t],e[t]=e[s],e[s]=i;return e}function Ze(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(i,s){return i===s});const t=b(r);for(let i=0;i<t.length-1;i++)if(e(t[i],t[i+1])){let s=Math.floor(Math.random()*(t.length-2))+1;for(;e(t[i+1],t[s])||e(t[i+1],t[s+1])||e(t[i+1],t[s-1])||e(t[i],t[s]);)s=Math.floor(Math.random()*(t.length-2))+1;const l=t[s];t[s]=t[i+1],t[i+1]=l}return t}function Z(r,e=!1){const t=r.length;if(t==1)return console.warn("shuffleAlternateGroups() was called with only one group. Defaulting to simple shuffle."),b(r[0]);let i=[];for(let a=0;a<t;a++)i.push(a);e&&(i=b(i));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(b(r[a]));const o=[];for(let a=0;a<l;a++)for(let n=0;n<i.length;n++)o.push(s[i[n]][a]);return o}function ee(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."),b(r).slice(0,e)}function te(r,e,t){Array.isArray(r)||console.error("First argument to sampleWithReplacement() must be an array");const i=[];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 o=0;for(const a of t)o+=a;for(const a of t)i.push(a/o)}else for(let o=0;o<r.length;o++)i.push(1/r.length);const s=[i[0]];for(let o=1;o<i.length;o++)s.push(i[o]+s[o-1]);const l=[];for(let o=0;o<e;o++){const a=Math.random();let n=0;for(;a>s[n];)n++;l.push(r[n])}return l}function et(r,e=1,t=!1){let i=[{}];for(const[s,l]of Object.entries(r)){const o=[];for(const a of l)for(const n of i)o.push(Xe(He({},n),{[s]:a}));i=o}return M(i,e,t)}function tt(r=32){let e="";const t="0123456789abcdefghjklmnopqrstuvwxyz";for(let i=0;i<r;i++)e+=t[Math.floor(Math.random()*t.length)];return e}function rt(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 it(r){return Math.random()<=r?1:0}function N(r,e){return at()*e+r}function R(r){return-Math.log(Math.random())/r}function st(r,e,t,i=!1){let s=N(r,e)+R(t);if(i)for(;s<=0;)s=N(r,e)+R(t);return s}function nt(r){return $e(r)}function at(){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 ot(r){const e={};for(const t of r)for(const i of Object.keys(t))typeof e[i]=="undefined"&&(e[i]=[]),e[i].push(t[i]);return e}var lt=Object.freeze({__proto__:null,setSeed:Qe,repeat:M,shuffle:b,shuffleNoRepeats:Ze,shuffleAlternateGroups:Z,sampleWithoutReplacement:ee,sampleWithReplacement:te,factorial:et,randomID:tt,randomInt:rt,sampleBernoulli:it,sampleNormal:N,sampleExponential:R,sampleExGaussian:st,randomWords:nt});function re(){const r={previewMode:!1,outsideTurk:!1,hitId:"INVALID_URL_PARAMETER",assignmentId:"INVALID_URL_PARAMETER",workerId:"INVALID_URL_PARAMETER",turkSubmitTo:"INVALID_URL_PARAMETER"},e=function(i,s){s=s.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");const l="[\\?&]"+s+"=([^&#]*)",o=new RegExp(l).exec(i);return o==null?"":o[1]},t=e(window.location.href,"assignmentId")?window.location.href:document.referrer;return["assignmentId","hitId","workerId","turkSubmitTo"].map(function(i){r[i]=unescape(e(t,i))}),r.previewMode=r.assignmentId=="ASSIGNMENT_ID_NOT_AVAILABLE",r.outsideTurk=!r.previewMode&&r.hitId===""&&r.assignmentId==""&&r.workerId=="",r}function ut(r){const e=re(),t=e.assignmentId,i=e.turkSubmitTo;if(!t||!i)return;const s=document.createElement("form");s.method="POST",s.action=i+"/mturk/externalSubmit?assignmentId="+t;for(const l in r)if(r.hasOwnProperty(l)){const o=document.createElement("input");o.type="hidden",o.name=l,o.id=l,o.value=r[l],s.appendChild(o)}document.body.appendChild(s),s.submit()}var ct=Object.freeze({__proto__:null,turkInfo:re,submitToTurk:ut});class ht{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 D{constructor(e){this.name=e}}const dt=["timeline","timeline_variables","name","repetitions","loop_function","conditional_function","randomize_order","sample","on_timeline_start","on_timeline_finish"];function pt(r){return!V(r)}function V(r){return Boolean(r.timeline)||Array.isArray(r)}var m=(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))(m||{});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 mt(r){return r&&typeof r.then=="function"}function ft(r){return new Promise(e=>setTimeout(e,r))}function se([r,...e]){let t=r!=null?r:"";for(const i of e)t+=Number.isNaN(Number.parseInt(i))?`.${i}`:`[${i}]`;return t}function gt(r){return typeof r=="object"&&r!==null}class q{constructor(){this.cache=new Map}static lookupChild(e,t){let i=!1,s;return Number.isNaN(Number.parseInt(t))?Object.hasOwn(e,t)&&(i=!0,s=e[t]):Number.parseInt(t)<e.length&&(i=!0,s=e[t]),{doesPathExist:i,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=i=>{const s=i.slice(0,-1),l=i[i.length-1];if(!this.has(s)&&s.length>0&&!t(s).doesPathExist)return{doesPathExist:!1};const o=this.get(s);if(!gt(o))return{doesPathExist:!1};const a=q.lookupChild(o,l);return a.doesPathExist&&this.set(i,a.value),a};return t(e)}}var yt=Object.defineProperty,ne=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,ae=(r,e,t)=>e in r?yt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,oe=(r,e)=>{for(var t in e||(e={}))bt.call(e,t)&&ae(r,t,e[t]);if(ne)for(var t of ne(e))wt.call(e,t)&&ae(r,t,e[t]);return r};class le{constructor(e){this.dependencies=e,this.status=m.PENDING,this.parameterValueCache=new q}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:i=!0,recursive:s=!0,cacheResult:l=!0,replaceResult:o}=t;typeof e=="string"&&(e=[e]);let{doesPathExist:a,value:n}=this.parameterValueCache.lookup(e);return!a&&s&&this.parent&&(n=this.parent.getParameterValue(e,t)),typeof n=="function"&&i&&(n=n()),n instanceof D&&(n=this.evaluateTimelineVariable(n)),typeof o=="function"&&(n=o(n)),l&&this.parameterValueCache.set(e,n),n}getDataParameter(){var e;const t=this.getParameterValue("data",{recursive:!1});return oe(oe({},Object.fromEntries(typeof t=="object"?Object.keys(t).map(i=>[i,this.getParameterValue(["data",i])]):[])),(e=this.parent)==null?void 0:e.getDataParameter())}}var vt=Object.defineProperty,Pt=Object.defineProperties,Et=Object.getOwnPropertyDescriptors,ue=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable,ce=(r,e,t)=>e in r?vt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,z=(r,e)=>{for(var t in e||(e={}))_t.call(e,t)&&ce(r,t,e[t]);if(ue)for(var t of ue(e))xt.call(e,t)&&ce(r,t,e[t]);return r},kt=(r,e)=>Pt(r,Et(e)),B=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class T extends le{constructor(e,t,i){super(e),this.description=t,this.parent=i,this.onLoad=()=>{this.runParameterCallback("on_load"),this.dependencies.runOnLoadExtensionCallbacks(this.getParameterValue("extensions"))},this.initializeParameterValueCache(),this.trialObject=f(t),this.pluginClass=this.getParameterValue("type",{evaluateFunctions:!1}),this.pluginInfo=this.pluginClass.info,!("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 B(this,null,function*(){var e;this.status=m.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=m.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 ft(t)),this.resetParameterValueCache()})}executeTrial(){return B(this,null,function*(){const e=this.dependencies.finishTrialPromise.get();let t=!1;e.then(()=>{t=!0});const{trialReturnValue:i,hasTrialBeenSimulated:s}=this.invokeTrialMethod();let l;return mt(i)?(l=yield Promise.race([i,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 i=this.getSimulationOptions();if(i.simulate!==!1)return{hasTrialBeenSimulated:!0,trialReturnValue:this.pluginInstance.simulate(this.trialObject,(e=i.mode)!=null?e:t,i,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 o=this.trialObject[s];typeof o=="function"&&(o=o.toString()),e[s]=o}else!l&&Object.hasOwn(e,s)&&delete e[s];else console.warn(`Non-existent parameter "${s}" specified in save_trial_parameters.`);e=kt(z(z({},this.getDataParameter()),e),{trial_type:this.pluginInfo.name,trial_index:this.index,plugin_version:this.pluginInfo.version?this.pluginInfo.version:null});const i=this.getParameterValue("save_timeline_variables");return i===!0?e.timeline_variables=z({},this.parent.getAllTimelineVariables()):Array.isArray(i)&&(e.timeline_variables=Object.fromEntries(Object.entries(this.parent.getAllTimelineVariables()).filter(([s,l])=>i.includes(s)))),e}runParameterCallback(e,...t){const i=this.getParameterValue(e,{evaluateFunctions:!1});if(i)return i(...t)}onStart(){this.dependencies.onTrialStart(this),this.runParameterCallback("on_start",this.trialObject),this.dependencies.runOnStartExtensionCallbacks(this.getParameterValue("extensions"))}onFinish(){return B(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 dt.includes(typeof e=="string"?e:e[0])&&(t.recursive=!1),super.getParameterValue(e,t)}getSimulationOptions(){const e=this.getParameterValue("simulation_options",{replaceResult:(t={})=>{var i,s;if(typeof t=="string"){const l=this.dependencies.getGlobalSimulationOptions();t=(s=(i=l[t])!=null?i:l.default)!=null?s:{}}return k(f(this.dependencies.getGlobalSimulationOptions().default),f(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=(i,s,l=[])=>{for(const[o,a]of Object.entries(s)){const n=[...l,o];let u=this.getParameterValue(n,{evaluateFunctions:a.type!==g.FUNCTION,replaceResult:c=>{if(typeof c=="undefined"){if(typeof a.default=="undefined")throw new Error(`You must specify a value for the "${se(n)}" parameter in the "${this.pluginInfo.name}" plugin.`);return a.default}else return c}});if(a.array&&!Array.isArray(u)){const c=se(n);throw new Error(`A non-array value (\`${u}\`) was provided for the array parameter "${c}" in the "${this.pluginInfo.name}" plugin. Please make sure that "${c}" is an array.`)}a.type===g.COMPLEX&&a.nested&&(a.array?u=u.map((c,h)=>{const d=[...n,h.toString()],y=this.getParameterValue(d);return e(y,a.nested,d),y}):e(u,a.nested,n)),i[o]=u}},t=f(this.description);e(t,this.pluginInfo.parameters),this.trialObject=t}getLatestNode(){return this}getActiveTimelineByName(e){}}var jt=Object.defineProperty,he=Object.getOwnPropertySymbols,Tt=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable,de=(r,e,t)=>e in r?jt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,pe=(r,e)=>{for(var t in e||(e={}))Tt.call(e,t)&&de(r,t,e[t]);if(he)for(var t of he(e))Ot.call(e,t)&&de(r,t,e[t]);return r},At=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class w extends le{constructor(e,t,i){super(e),this.parent=i,this.children=[],this.shouldAbort=!1,this.resumePromise=new ie,this.description=Array.isArray(t)?{timeline:t}:t,this.initializeParameterValueCache()}run(){return At(this,null,function*(){typeof this.index=="undefined"&&(this.index=0),this.status=m.RUNNING;const{conditional_function:e,loop_function:t,repetitions:i=1}=this.description;let s=this.generateTimelineVariableOrder();this.setCurrentTimelineVariablesByIndex(s[0]);let l=!0,o;if(!e||e()){this.onStart();for(let a=0;a<i;a++)do{o=[],l?l=!1:s=this.generateTimelineVariableOrder();for(const n of s){this.setCurrentTimelineVariablesByIndex(n);for(const u of this.description.timeline){const c=this.instantiateChildNode(u),h=this.currentChild;if(this.currentChild=c,c.index=h?h.getLatestNode().index+1:this.index,yield c.run(),this.status===m.PAUSED&&(yield this.resumePromise.get()),this.shouldAbort){this.status=m.ABORTED;return}o.push(...this.currentChild.getResults())}}}while(t&&t(new p(o)));this.onFinish()}this.status=m.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 w&&this.currentChild.pause(),this.status=m.PAUSED}resume(){this.status==m.PAUSED&&(this.currentChild instanceof w&&this.currentChild.resume(),this.status=m.RUNNING,this.resumePromise.resolve())}abort(){(this.status===m.RUNNING||this.status===m.PAUSED)&&(this.currentChild instanceof w&&this.currentChild.abort(),this.shouldAbort=!0,this.status===m.PAUSED&&this.resume())}instantiateChildNode(e){const t=V(e)?new w(this.dependencies,e,this):new T(this.dependencies,e,this);return this.children.push(t),t}setCurrentTimelineVariablesByIndex(e){var t;this.currentTimelineVariables=pe(pe({},(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 i=[...Array(t).keys()];const s=this.description.sample;if(s)switch(s.type){case"custom":i=s.fn(i);break;case"with-replacement":i=te(i,s.size,s.weights);break;case"without-replacement":i=ee(i,s.size);break;case"fixed-repetitions":i=M(i,s.size);break;case"alternate-groups":i=Z(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&&(i=b(i)),i}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 T){const i=t.getResult();i&&e.push(i)}else t instanceof w&&e.push(...t.getResults());return e}getNaiveProgress(){if(this.status===m.PENDING)return 0;const e=this.getLatestNode();if(!e)return 1;let t=e.index;return e.getStatus()===m.COMPLETED&&t++,Math.min(t/this.getNaiveTrialCount(),1)}getNaiveTrialCount(){const e=t=>{var i,s,l;const o=a=>a.map(n=>e(n)).reduce((n,u)=>n+u);if(Array.isArray(t))return o(t);if(pt(t))return 1;if(V(t)){let a=((i=t.timeline_variables)==null?void 0:i.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(n=>n.length).reduce((n,u)=>n+u,0);break}return o(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 It=Object.defineProperty,me=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,fe=(r,e,t)=>e in r?It(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)&&fe(r,t,e[t]);if(me)for(var t of me(e))St.call(e,t)&&fe(r,t,e[t]);return r},$=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class ge{constructor(e){this.turk=ct,this.randomization=lt,this.utils=_e,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 i=t.getResult();i&&(i.time_elapsed=this.getTotalTime(),this.data.write(t))},onTrialFinished:t=>{const i=t.getResult();this.options.on_trial_finish(i),i&&this.options.on_data_update(i),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,i;return{time:this.getTotalTime(),trial:(i=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?i:0}},onInteractionRecordAdded:t=>{this.options.on_interaction_data_update(t)},getDisplayElement:()=>this.getDisplayElement()},e=Ct({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,A(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 Le(this.dataDependencies),this.pluginAPI=ze(this),this.extensionManager=new _(this.extensionManagerDependencies,e.extensions)}version(){return Ee.version}run(e){return $(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 w(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 $(this,arguments,function*(t,i="data-only",s={}){this.simulationMode=i,this.simulationOptions=s,yield this.run(t)})}getProgress(){var e,t,i,s;return{total_trials:(e=this.timeline)==null?void 0:e.getNaiveTrialCount(),current_trial_global:(i=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?i: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 T&&(t=t.parent),t instanceof w&&t.abort()}abortTimelineByName(e){var t;const i=(t=this.timeline)==null?void 0:t.getActiveTimelineByName(e);i&&i.abort()}getCurrentTrial(){var e;const t=(e=this.timeline)==null?void 0:e.getLatestNode();if(t instanceof T)return t.description}getInitSettings(){return this.options}timelineVariable(e){return new D(e)}evaluateTimelineVariable(e){var t,i;return(i=(t=this.timeline)==null?void 0:t.getLatestNode())==null?void 0:i.evaluateTimelineVariable(new D(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}get extensions(){var e,t;return(t=(e=this.extensionManager)==null?void 0:e.extensions)!=null?t:{}}prepareDom(){return $(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 i=document.createElement("div");if(i.className="jspsych-content-wrapper",i.appendChild(t),this.displayContainerElement=e.display_element,this.displayContainerElement.appendChild(i),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 ht(s,this.options.message_progress_bar),this.getDisplayContainerElement().insertAdjacentElement("afterbegin",s)}})}finishTrial(e){this.finishTrialPromise.resolve(e)}}class v 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 v("`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.")},get data(){throw new v},get randomization(){throw new v},get turk(){throw new v},get pluginAPI(){throw new v},get ALL_KEYS(){throw new v('jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.')},get NO_KEYS(){throw new v('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 Mt(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,i])=>[t,{get(){throw new v(i)}}]))),e}return E.DataCollection=p,E.JsPsych=ge,E.ParameterType=g,E.initJsPsych=Mt,E}({}),initJsPsych=jsPsychModule.initJsPsych;
6
+ //# sourceMappingURL=https://unpkg.com/jspsych@8.1.0/dist/index.browser.min.js.map