var jsPsychModule=function(e){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function v(e,t,r,n){return new(r||(r=Promise))((function(i,a){function o(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}l((n=n.apply(e,t||[])).next())}))}!function(e){var r=function(e){var r,n=Object.prototype,i=n.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var i=t&&t.prototype instanceof v?t:v,a=Object.create(i.prototype),o=new L(n||[]);return a._invoke=function(e,t,r){var n=d;return function(i,a){if(n===p)throw new Error("Generator is already running");if(n===m){if("throw"===i)throw a;return I()}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var s=P(o,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===d)throw n=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var l=h(e,t,r);if("normal"===l.type){if(n=r.done?m:f,l.arg===y)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n=m,r.method="throw",r.arg=l.arg)}}}(e,r,o),a}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var d="suspendedStart",f="suspendedYield",p="executing",m="completed",y={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(A([])));k&&k!==n&&i.call(k,o)&&(w=k);var x=b.prototype=v.prototype=Object.create(w);function T(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function j(e,r){function n(a,o,s,l){var u=h(e[a],e,o);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"===t(d)&&i.call(d,"__await")?r.resolve(d.__await).then((function(e){n("next",e,s,l)}),(function(e){n("throw",e,s,l)})):r.resolve(d).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,l)}))}l(u.arg)}var a;this._invoke=function(e,t){function i(){return new r((function(r,i){n(e,t,r,i)}))}return a=a?a.then(i,i):i()}}function P(e,t){var n=e.iterator[t.method];if(n===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=r,P(e,t),"throw"===t.method))return y;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var i=h(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,y;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=r),t.delegate=null,y):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function A(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var l=i.call(o,"catchLoc"),u=i.call(o,"finallyLoc");if(l&&u){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=r),y}},e}(e.exports);try{regeneratorRuntime=r}catch(e){"object"===("undefined"==typeof globalThis?"undefined":t(globalThis))?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}({exports:{}});var g=function(e){var t=new Set;do{var r,n=y(Reflect.ownKeys(e));try{for(n.s();!(r=n.n()).done;){var i=r.value;t.add([e,i])}}catch(e){n.e(e)}finally{n.f()}}while((e=Reflect.getPrototypeOf(e))&&e!==Object.prototype);return t},b=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.include,i=r.exclude,a=function(e){var t=function(t){return"string"==typeof t?e===t:t.test(e)};return n?n.some(t):!i||!i.some(t)},o=y(g(e.constructor.prototype));try{for(o.s();!(t=o.n()).done;){var s=d(t.value,2),l=s[0],u=s[1];if("constructor"!==u&&a(u)){var c=Reflect.getOwnPropertyDescriptor(l,u);c&&"function"==typeof c.value&&(e[u]=e[u].bind(e))}}}catch(e){o.e(e)}finally{o.f()}return e},w=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}(u,e);var t,n,a=(t=u,n=l(),function(){var e,r=o(t);if(n){var i=o(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function u(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"The global `jsPsych` variable is no longer available in jsPsych v7.";return r(this,u),(e=a.call(this,"".concat(t," Please follow the migration guide at https://www.jspsych.org/7.0/support/migration-v7/ to update your experiment."))).name="MigrationError",e}return i(u)}(c(Error));function _(e){return f(new Set(e))}function k(e){if(!e)return e;var r;if(Array.isArray(e)){r=[];var n,i=y(e);try{for(i.s();!(n=i.n()).done;){var a=n.value;r.push(k(a))}}catch(e){i.e(e)}finally{i.f()}return r}if("object"===t(e)&&null!==e){for(var o in r={},e)e.hasOwnProperty(o)&&(r[o]=k(e[o]));return r}return e}window.jsPsych={get init(){throw new w("`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.")},get data(){throw new w},get randomization(){throw new w},get turk(){throw new w},get pluginAPI(){throw new w},get ALL_KEYS(){throw new w('jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.')},get NO_KEYS(){throw new w('jsPsych.NO_KEYS was replaced by the "NO_KEYS" string in jsPsych v7.')}};var x=Object.freeze({__proto__:null,unique:_,deepCopy:k,deepMerge:function e(r,n){var i={};for(var a in r)r.hasOwnProperty(a)&&("object"===t(r[a])&&n.hasOwnProperty(a)?i[a]=e(r[a],n[a]):i[a]=r[a]);for(var o in n)n.hasOwnProperty(o)&&(i.hasOwnProperty(o)&&"object"===t(n[o])?i[o]=e(i[o],n[o]):i[o]=n[o]);return i}}),T=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];r(this,e),this.values=t}return i(e,[{key:"sum",value:function(){var e,t=0,r=y(this.values);try{for(r.s();!(e=r.n()).done;){t+=e.value}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"mean",value:function(){return this.sum()/this.count()}},{key:"median",value:function(){if(0!==this.values.length){var e=this.values.slice(0).sort((function(e,t){return e-t})),t=Math.floor(e.length/2);return e.length%2==0?(e[t]+e[t-1])/2:e[t]}}},{key:"min",value:function(){return Math.min.apply(null,this.values)}},{key:"max",value:function(){return Math.max.apply(null,this.values)}},{key:"count",value:function(){return this.values.length}},{key:"variance",value:function(){var e,t=this.mean(),r=0,n=y(this.values);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=Math.pow(i-t,2)}}catch(e){n.e(e)}finally{n.f()}return r/(this.values.length-1)}},{key:"sd",value:function(){var e=this.variance();return Math.sqrt(e)}},{key:"frequencies",value:function(){var e,t={},r=y(this.values);try{for(r.s();!(e=r.n()).done;){var n=e.value;void 0===t[n]?t[n]=1:t[n]++}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"all",value:function(e){var t,r=y(this.values);try{for(r.s();!(t=r.n()).done;){if(!e(t.value))return!1}}catch(e){r.e(e)}finally{r.f()}return!0}},{key:"subset",value:function(t){var r,n=[],i=y(this.values);try{for(i.s();!(r=i.n()).done;){var a=r.value;t(a)&&n.push(a)}}catch(e){i.e(e)}finally{i.f()}return new e(n)}}]),e}();var j,P=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];r(this,e),this.trials=t}return i(e,[{key:"push",value:function(e){return this.trials.push(e),this}},{key:"join",value:function(e){return this.trials=this.trials.concat(e.values()),this}},{key:"top",value:function(){return this.trials.length<=1?this:new e([this.trials[this.trials.length-1]])}},{key:"first",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(t<1)throw"You must query with a positive nonzero integer. Please use a\n different value for n.";return 0===this.trials.length?new e:(t>this.trials.length&&(t=this.trials.length),new e(this.trials.slice(0,t)))}},{key:"last",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(t<1)throw"You must query with a positive nonzero integer. Please use a\n different value for n.";return 0===this.trials.length?new e:(t>this.trials.length&&(t=this.trials.length),new e(this.trials.slice(this.trials.length-t,this.trials.length)))}},{key:"values",value:function(){return this.trials}},{key:"count",value:function(){return this.trials.length}},{key:"readOnly",value:function(){return new e(k(this.trials))}},{key:"addToAll",value:function(e){var t,r=y(this.trials);try{for(r.s();!(t=r.n()).done;){var n=t.value;Object.assign(n,e)}}catch(e){r.e(e)}finally{r.f()}return this}},{key:"addToLast",value:function(e){return 0!=this.trials.length&&Object.assign(this.trials[this.trials.length-1],e),this}},{key:"filter",value:function(t){var r;r=Array.isArray(t)?k(t):k([t]);var n,i=[],a=y(this.trials);try{for(a.s();!(n=a.n()).done;){var o,s=n.value,l=!1,u=y(r);try{for(u.s();!(o=u.n()).done;){for(var c=o.value,h=!0,d=0,f=Object.keys(c);d0&&void 0!==arguments[0]&&arguments[0];return e?JSON.stringify(this.trials,null,"\t"):JSON.stringify(this.trials)}},{key:"localSave",value:function(e,t){var r;if("json"===(e=e.toLowerCase()))r=this.json();else{if("csv"!==e)throw new Error('Invalid format specified for localSave. Must be "json" or "csv".');r=this.csv()}!function(e,t){var r=new Blob([e],{type:"text/plain"}),n="";n=void 0!==window.webkitURL?window.webkitURL.createObjectURL(r):window.URL.createObjectURL(r);var i=document.createElement("a");i.id="jspsych-download-as-text-link",i.style.display="none",i.download=t,i.href=n,i.click()}(r,t)}}]),e}(),E=function(){function e(t){r(this,e),this.jsPsych=t,this.dataProperties={},this.reset()}return i(e,[{key:"reset",value:function(){this.allData=new P,this.interactionData=new P}},{key:"get",value:function(){return this.allData}},{key:"getInteractionData",value:function(){return this.interactionData}},{key:"write",value:function(e){var t=this.jsPsych.getProgress(),r=this.jsPsych.getCurrentTrial(),n={trial_type:r.type.info.name,trial_index:t.current_trial_global,time_elapsed:this.jsPsych.getTotalTime(),internal_node_id:this.jsPsych.getCurrentTimelineNodeID()};this.allData.push(Object.assign(Object.assign(Object.assign(Object.assign({},e),r.data),n),this.dataProperties))}},{key:"addProperties",value:function(e){this.allData.addToAll(e),this.dataProperties=Object.assign({},this.dataProperties,e)}},{key:"addDataToLastTrial",value:function(e){this.allData.addToLast(e)}},{key:"getDataByTimelineNode",value:function(e){return this.allData.filterCustom((function(t){return t.internal_node_id.slice(0,e.length)===e}))}},{key:"getLastTrialData",value:function(){return this.allData.top()}},{key:"getLastTimelineData",value:function(){var e=this.getLastTrialData().select("internal_node_id").values[0];if(void 0===e)return new P;var t=e.substr(0,e.lastIndexOf("-"));return this.getDataByTimelineNode(t)}},{key:"displayData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"json";"json"!=(e=e.toLowerCase())&&"csv"!=e&&(console.log("Invalid format declared for displayData function. Using json as default."),e="json");var t="json"===e?this.allData.json(!0):this.allData.csv(),r=this.jsPsych.getDisplayElement();r.innerHTML='',document.getElementById("jspsych-data-display").textContent=t}},{key:"urlVariables",value:function(){return void 0===this.query_string&&(this.query_string=function(){for(var e=window.location.search.substr(1).split("&"),t={},r=0;r1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;r(this,e),this.getRootElement=t,this.areResponsesCaseSensitive=n,this.minimumValidRt=i,this.listeners=new Set,this.heldKeys=new Set,this.areRootListenersRegistered=!1,b(this),this.registerRootListeners()}return i(e,[{key:"registerRootListeners",value:function(){if(!this.areRootListenersRegistered){var e=this.getRootElement();e&&(e.addEventListener("keydown",this.rootKeydownListener),e.addEventListener("keyup",this.rootKeyupListener),this.areRootListenersRegistered=!0)}}},{key:"rootKeydownListener",value:function(e){for(var t=0,r=Array.from(this.listeners);t1&&void 0!==arguments[1]?arguments[1]:function(){},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(e){};e=_(e.flat());var a=0;if(0!=e.length){var o,s=function(o){var s=new XMLHttpRequest;s.open("GET",o,!0),s.responseType="arraybuffer",s.onload=function(){t.context.decodeAudioData(s.response,(function(i){t.audio_buffers[o]=i,a++,n(o),a==e.length&&r()}),(function(e){i({source:o,error:e})}))},s.onerror=function(e){var t=e;404==s.status&&(t="404"),i({source:o,error:t})},s.onloadend=function(e){404==s.status&&i({source:o,error:"404"})},s.send(),t.preload_requests.push(s)},l=function(o){var s=new Audio;s.addEventListener("canplaythrough",(function i(){t.audio_buffers[o]=s,a++,n(o),a==e.length&&r(),s.removeEventListener("canplaythrough",i)})),s.addEventListener("error",(function e(t){i({source:s.src,error:t}),s.removeEventListener("error",e)})),s.addEventListener("abort",(function e(t){i({source:s.src,error:t}),s.removeEventListener("abort",e)})),s.src=o,t.preload_requests.push(s)},u=y(e);try{for(u.s();!(o=u.n()).done;){var c=o.value;void 0!==this.audio_buffers[c]?(a++,n(c),a==e.length&&r()):(this.audio_buffers[c]="tmp",null!==this.audioContext()?s(c):l(c))}}catch(e){u.e(e)}finally{u.f()}}else r()}},{key:"preloadImages",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(e){};e=_(e.flat());var a=0;if(0!==e.length)for(var o=function(o){var s=new Image,l=e[o];s.onload=function(){a++,n(l),a===e.length&&r()},s.onerror=function(e){i({source:l,error:e})},s.src=l,t.img_cache[l]=s,t.preload_requests.push(s)},s=0;s1&&void 0!==arguments[1]?arguments[1]:function(){},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(e){};e=_(e.flat());var a=0;if(0!==e.length){var o,s=y(e);try{var l=function(){var s=o.value,l=t.video_buffers,u=new XMLHttpRequest;u.open("GET",s,!0),u.responseType="blob",u.onload=function(){if(200===u.status||0===u.status){var t=u.response;l[s]=URL.createObjectURL(t),a++,n(s),a===e.length&&r()}},u.onerror=function(e){var t=e;404==u.status&&(t="404"),i({source:s,error:t})},u.onloadend=function(e){404==u.status&&i({source:s,error:"404"})},u.send(),t.preload_requests.push(u)};for(s.s();!(o=s.n()).done;)l()}catch(e){s.e(e)}finally{s.f()}}else r()}},{key:"getAutoPreloadList",value:function(t){var r=this,n=Object.fromEntries(I.map((function(e){return[e,new Set]})));return function e(t,i){var a,o,s,l;if(void 0!==t.timeline){var u,c=y(t.timeline);try{for(c.s();!(u=c.n()).done;){e(u.value,null!==(a=t.type)&&void 0!==a?a:i)}}catch(e){c.e(e)}finally{c.f()}}else if(null===(s=null!==(o=t.type)&&void 0!==o?o:i)||void 0===s?void 0:s.info){var h=(null!==(l=t.type)&&void 0!==l?l:i).info,f=h.name,p=h.parameters;r.preloadMap.has(f)||r.preloadMap.set(f,Object.fromEntries(Object.entries(p).filter((function(e){var t=d(e,2);t[0];var r=t[1],n=r.type,i=r.preload;return I.includes(n)&&(null==i||i)})).map((function(e){var t=d(e,2);return[t[0],t[1].type]}))));for(var m=0,v=Object.entries(r.preloadMap.get(f));m1&&void 0!==arguments[1]?arguments[1]:0;r>0?this.setJsPsychTimeout((function(){t.keyDown(e),t.keyUp(e)}),r):(this.keyDown(e),this.keyUp(e))}},{key:"clickTarget",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t>0?this.setJsPsychTimeout((function(){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})))}},{key:"fillTextInput",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;r>0?this.setJsPsychTimeout((function(){e.value=t}),r):e.value=t}},{key:"getValidKey",value:function(e){var t,r=["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"," "];if("NO_KEYS"==e)t=null;else if("ALL_KEYS"==e)t=r[Math.floor(Math.random()*r.length)];else{var n=e.flat();t=n[Math.floor(Math.random()*n.length)]}return t}},{key:"mergeSimulationData",value:function(e,t){return Object.assign(Object.assign({},e),null==t?void 0:t.data)}},{key:"ensureSimulationDataConsistency",value:function(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&&"NO_KEYS"==e.choices&&(t.rt&&(t.rt=null),t.response&&(t.response=null)),e.allow_response_before_complete&&e.sequence_reps&&e.frame_time){var r=e.sequence_reps*e.frame_time*e.stimuli.length;t.rt1?function(){var t,n=!1;for(;!n;)(t=r()).length<=e.maxLength&&(n=!0);return t}():r()}function r(){return C[n(C.length)]}function n(e){return Math.floor(Math.random()*e)}if(void 0===e)return t();"number"==typeof e&&(e={exactly:e}),e.exactly&&(e.min=e.exactly,e.max=e.exactly),"number"!=typeof e.wordsPerString&&(e.wordsPerString=1),"function"!=typeof e.formatter&&(e.formatter=function(e){return e}),"string"!=typeof e.separator&&(e.separator=" ");for(var i=e.min+n(e.max+1-e.min),a=[],o="",s=0,l=0;l>>0,t=(n*=t)>>>0,t+=4294967296*(n-=t)}return 2.3283064365386963e-10*(t>>>0)});r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1),n=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function o(e,r){var n=new i(e),o=r&&r.state,s=n.next;return s.int32=function(){return 4294967296*n.next()|0},s.double=function(){return s()+11102230246251565e-32*(2097152*s()|0)},s.quick=s,o&&("object"==t(o)&&a(o,n),s.state=function(){return a(n,{})}),s}r&&r.exports?r.exports=o:n&&n.amd?n((function(){return o})):this.alea=o})(0,V,!1);var q=V.exports;function z(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=Array.isArray(e),a=Array.isArray(r);if(i)if(a){if(e.length!=r.length)if(console.warn("Unclear parameters given to randomization.repeat. Items and repetitions are unequal lengths. Behavior may not be as expected."),r.length1&&void 0!==arguments[1]&&arguments[1],r=e.length;if(1==r)return console.warn("shuffleAlternateGroups() was called with only one group. Defaulting to simple shuffle."),K(e[0]);for(var n=[],i=0;ie.length&&console.error("Cannot take a sample larger than the size of the set of items to sample."),K(e).slice(0,t)}function Y(e,t,r){Array.isArray(e)||console.error("First argument to sampleWithReplacement() must be an array");var n=[];if(void 0!==r){r.length!==e.length&&console.error("The length of the weights array must equal the length of the array to be sampled from.");var i,a=0,o=y(r);try{for(o.s();!(i=o.n()).done;){a+=i.value}}catch(e){o.e(e)}finally{o.f()}var s,l=y(r);try{for(l.s();!(s=l.n()).done;){var u=s.value;n.push(u/a)}}catch(e){l.e(e)}finally{l.f()}}else for(var c=0;ch[v];)v++;f.push(e[v])}return f}function B(e,t){return function(){var e=0,t=0;for(;0===e;)e=Math.random();for(;0===t;)t=Math.random();return Math.sqrt(-2*Math.log(e))*Math.cos(2*Math.PI*t)}()*t+e}function G(e){return-Math.log(Math.random())/e}function W(e){var t,r={},n=y(e);try{for(n.s();!(t=n.n()).done;)for(var i=t.value,a=0,o=Object.keys(i);a0&&void 0!==arguments[0]?arguments[0]:Math.random().toString();return Math.random=q(e),e},repeat:z,shuffle:K,shuffleNoRepeats:function(e,t){Array.isArray(e)||console.error("First argument to shuffleNoRepeats() must be an array."),void 0!==t&&"function"!=typeof t&&console.error("Second argument to shuffleNoRepeats() must be a function."),void 0===t&&(t=function(e,t){return e===t});for(var r=K(e),n=0;n1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=[{}],i=0,o=Object.entries(e);i0&&void 0!==arguments[0]?arguments[0]:32,t="",r="0123456789abcdefghjklmnopqrstuvwxyz",n=0;n3&&void 0!==arguments[3]&&arguments[3],i=B(e,t)+G(r);if(n)for(;i<=0;)i=B(e,t)+G(r);return i},randomWords:function(e){return N(e)}});function H(){var e={previewMode:!1,outsideTurk:!1,hitId:"INVALID_URL_PARAMETER",assignmentId:"INVALID_URL_PARAMETER",workerId:"INVALID_URL_PARAMETER",turkSubmitTo:"INVALID_URL_PARAMETER"},t=function(e,t){t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var r=new RegExp("[\\?&]"+t+"=([^]*)").exec(e);return null==r?"":r[1]},r=t(window.location.href,"assignmentId")?window.location.href:document.referrer;return["assignmentId","hitId","workerId","turkSubmitTo"].map((function(n){e[n]=unescape(t(r,n))})),e.previewMode="ASSIGNMENT_ID_NOT_AVAILABLE"==e.assignmentId,e.outsideTurk=!e.previewMode&&""===e.hitId&&""==e.assignmentId&&""==e.workerId,e}var X=Object.freeze({__proto__:null,turkInfo:H,submitToTurk:function(e){var t=H(),r=t.assignmentId,n=t.turkSubmitTo;if(r&&n){var i=document.createElement("form");for(var a in i.method="POST",i.action=n+"/mturk/externalSubmit?assignmentId="+r,e)if(e.hasOwnProperty(a)){var o=document.createElement("input");o.type="hidden",o.name=a,o.id=a,o.value=e[a],i.appendChild(o)}document.body.appendChild(i),i.submit()}}}),$=function(){function e(n,i,a,o){if(r(this,e),this.jsPsych=n,this.progress={current_location:-1,current_variable_set:0,current_repetition:0,current_iteration:0,done:!1},this.parent_node=a,this.relative_id=void 0===a?0:o,void 0!==i.timeline){this.timeline_parameters={timeline:[],loop_function:i.loop_function,conditional_function:i.conditional_function,sample:i.sample,randomize_order:void 0!==i.randomize_order&&i.randomize_order,repetitions:void 0===i.repetitions?1:i.repetitions,timeline_variables:void 0===i.timeline_variables?[{}]:i.timeline_variables,on_timeline_finish:i.on_timeline_finish,on_timeline_start:i.on_timeline_start},this.setTimelineVariablesOrder();var s=Object.assign({},i);delete s.timeline,delete s.conditional_function,delete s.loop_function,delete s.randomize_order,delete s.repetitions,delete s.timeline_variables,delete s.sample,delete s.on_timeline_start,delete s.on_timeline_finish,this.node_trial_data=s;for(var l=0;l=this.timeline_parameters.timeline.length?null:this.timeline_parameters.timeline[this.progress.current_location].trial()}},{key:"markCurrentTrialComplete",value:function(){void 0===this.timeline_parameters?this.progress.done=!0:this.timeline_parameters.timeline[this.progress.current_location].markCurrentTrialComplete()}},{key:"nextRepetiton",value:function(){this.setTimelineVariablesOrder(),this.progress.current_location=-1,this.progress.current_variable_set=0,this.progress.current_repetition++;for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:[];if(void 0!==this.timeline_parameters){e=e.concat(Object.keys(this.timeline_parameters.timeline_variables[this.progress.order[this.progress.current_variable_set]]));var t=Math.max(0,this.progress.current_location);return t==this.timeline_parameters.timeline.length&&(t-=1),this.timeline_parameters.timeline[t].allTimelineVariablesNames(e)}if(void 0===this.timeline_parameters)return e}},{key:"length",value:function(){var e=0;if(void 0===this.timeline_parameters)return 1;for(var t=0;t1&&void 0!==arguments[1]?arguments[1]:"data-only",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return v(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this.simulation_mode=t,this.simulation_options=r,n.next=4,this.run(e);case 4:case"end":return n.stop()}}),n,this)})))}},{key:"getProgress",value:function(){return{total_trials:void 0===this.timeline?void 0:this.timeline.length(),current_trial_global:this.global_trial_index,percent_complete:void 0===this.timeline?0:this.timeline.percentComplete()}}},{key:"getStartTime",value:function(){return this.exp_start_time}},{key:"getTotalTime",value:function(){return void 0===this.exp_start_time?0:(new Date).getTime()-this.exp_start_time.getTime()}},{key:"getDisplayElement",value:function(){return this.DOM_target}},{key:"getDisplayContainerElement",value:function(){return this.DOM_container}},{key:"finishTrial",value:function(){var e,r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.current_trial_finished){var i;if(this.current_trial_finished=!0,void 0!==this.current_trial.css_classes&&Array.isArray(this.current_trial.css_classes))(i=this.DOM_target.classList).remove.apply(i,f(this.current_trial.css_classes));this.data.write(n);var a=this.data.getLastTrialData(),o=a.values()[0],s=this.current_trial;if("object"===t(s.save_trial_parameters))for(var l=0,u=Object.keys(s.save_trial_parameters);l0?setTimeout(r.nextTrial,r.opts.default_iti):r.nextTrial():s.post_trial_gap>0?setTimeout(r.nextTrial,s.post_trial_gap):r.nextTrial()};if(d.some((function(e){return"function"==typeof e.then})))Promise.all(d.map((function(e){return Promise.resolve(e).then((function(e){Object.assign(o,e)}))}))).then(p);else{var m,v=y(d);try{for(v.s();!(m=v.n()).done;){var g=m.value;Object.assign(o,g)}}catch(e){v.e(e)}finally{v.f()}p()}}}},{key:"endExperiment",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.timeline.end_message=e,this.timeline.end(),this.pluginAPI.cancelAllKeyboardResponses(),this.pluginAPI.clearAllTimeouts(),this.finishTrial(t)}},{key:"endCurrentTimeline",value:function(){this.timeline.endActiveNode()}},{key:"getCurrentTrial",value:function(){return this.current_trial}},{key:"getInitSettings",value:function(){return this.opts}},{key:"getCurrentTimelineNodeID",value:function(){return this.timeline.activeID()}},{key:"timelineVariable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.internal.call_immediate||!0===r?this.timeline.timelineVariable(e):{timelineVariablePlaceholder:!0,timelineVariableFunction:function(){return t.timeline.timelineVariable(e)}}}},{key:"getAllTimelineVariables",value:function(){return this.timeline.allTimelineVariables()}},{key:"addNodeToEndOfTimeline",value:function(e,t){this.timeline.insert(e)}},{key:"pauseExperiment",value:function(){this.paused=!0}},{key:"resumeExperiment",value:function(){this.paused=!1,this.waiting&&(this.waiting=!1,this.nextTrial())}},{key:"loadFail",value:function(e){e=e||"The experiment failed to load.
",this.DOM_target.innerHTML=e}},{key:"getSafeModeStatus",value:function(){return this.file_protocol}},{key:"getTimeline",value:function(){return this.timelineDescription}},{key:"prepareDom",value:function(){return v(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("complete"===document.readyState){e.next=3;break}return e.next=3,new Promise((function(e){window.addEventListener("load",e)}));case 3:void 0===(t=this.opts).display_element?(null===document.querySelector("body")&&document.documentElement.appendChild(document.createElement("body")),document.querySelector("html").style.height="100%",document.querySelector("body").style.margin="0px",document.querySelector("body").style.height="100%",document.querySelector("body").style.width="100%",t.display_element=document.querySelector("body")):null===(r=t.display_element instanceof Element?t.display_element:document.querySelector("#"+t.display_element))?console.error("The display_element specified in initJsPsych() does not exist in the DOM."):t.display_element=r,t.display_element.innerHTML='',this.DOM_container=t.display_element,this.DOM_target=document.querySelector("#jspsych-content"),null!==t.experiment_width&&(this.DOM_target.style.width=t.experiment_width+"px"),t.display_element.tabIndex=0,-1===t.display_element.className.indexOf("jspsych-display-element")&&(t.display_element.className+=" jspsych-display-element"),this.DOM_target.className+="jspsych-content",this.data.createInteractionListeners(),window.addEventListener("beforeunload",t.on_close);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"loadExtensions",value:function(e){return v(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Promise.all(e.map((function(e){return r.extensions[e.type.info.name].initialize(e.params||{})})));case 3:t.next=9;break;case 5:throw t.prev=5,t.t0=t.catch(0),console.error(t.t0),new Error(t.t0);case 9:case"end":return t.stop()}}),t,null,[[0,5]])})))}},{key:"startExperiment",value:function(){var e=this;this.finished=new Promise((function(t){e.resolveFinishedPromise=t})),!0===this.opts.show_progress_bar&&this.drawProgressBar(this.opts.message_progress_bar),this.exp_start_time=new Date,this.timeline.advance(),this.doTrial(this.timeline.trial())}},{key:"finishExperiment",value:function(){var e=this,t=this.opts.on_finish(this.data.get()),r=function(){void 0!==e.timeline.end_message&&(e.DOM_target.innerHTML=e.timeline.end_message),e.resolveFinishedPromise()};t?Promise.resolve(t).then(r):r()}},{key:"nextTrial",value:function(){if(this.paused)this.waiting=!0;else{this.global_trial_index++,this.timeline.markCurrentTrialComplete();var e=this.timeline.advance();!0===this.opts.show_progress_bar&&!0===this.opts.auto_update_progress_bar&&this.updateProgressBar(),e?this.finishExperiment():this.doTrial(this.timeline.trial())}}},{key:"doTrial",value:function(e){var t,r=this;if(this.current_trial=e,this.current_trial_finished=!1,this.evaluateTimelineVariables(e),"string"==typeof e.type)throw new w("A string was provided as the trial's `type` parameter. Since jsPsych v7, the `type` parameter needs to be a plugin object.");if(e.type=Object.assign(Object.assign({},b(new e.type(this))),{info:e.type.info}),this.evaluateFunctionParameters(e),this.setDefaultValues(e),this.internal.call_immediate=!0,this.opts.on_trial_start(e),"function"==typeof e.on_start&&e.on_start(e),Array.isArray(e.extensions)){var n,i=y(e.extensions);try{for(i.s();!(n=i.n()).done;){var a=n.value;this.extensions[a.type.info.name].on_start(a.params)}}catch(e){i.e(e)}finally{i.f()}}(this.DOM_container.focus(),this.DOM_target.scrollTop=0,void 0!==e.css_classes)&&(Array.isArray(e.css_classes)||"string"!=typeof e.css_classes||(e.css_classes=[e.css_classes]),Array.isArray(e.css_classes)&&(t=this.DOM_target.classList).add.apply(t,f(e.css_classes)));var o,s,l,u=function(){if("function"==typeof e.on_load&&e.on_load(),Array.isArray(e.extensions)){var t,n=y(e.extensions);try{for(n.s();!(t=n.n()).done;){var i=t.value;r.extensions[i.type.info.name].on_load(i.params)}}catch(e){n.e(e)}finally{n.f()}}};this.simulation_mode||(o=e.type.trial(this.DOM_target,e,u)),this.simulation_mode&&(e.type.simulate?(e.simulation_options||(s=this.simulation_options.default),e.simulation_options&&("string"==typeof e.simulation_options?this.simulation_options[e.simulation_options]?s=this.simulation_options[e.simulation_options]:this.simulation_options.default?(console.log('No matching simulation options found for "'.concat(e.simulation_options,'". Using "default" options.')),s=this.simulation_options.default):(console.log('No matching simulation options found for "'.concat(e.simulation_options,'" and no "default" options provided. Using the default values provided by the plugin.')),s={}):s=e.simulation_options),l=this.utils.deepMerge(this.simulation_options.default,s),l=this.utils.deepCopy(l),o=!1===(null==(l=this.replaceFunctionsWithValues(l,null))?void 0:l.simulate)?e.type.trial(this.DOM_target,e,u):e.type.simulate(e,(null==l?void 0:l.mode)||this.simulation_mode,l,u)):o=e.type.trial(this.DOM_target,e,u)),o&&"function"==typeof o.then||this.simulation_mode&&(!this.simulation_mode||!1!==(null==l?void 0:l.simulate))||u(),this.internal.call_immediate=!1}},{key:"evaluateTimelineVariables",value:function(e){for(var r=0,n=Object.keys(e);rYour browser window is too small to complete this experiment. Please maximize the size of your browser window. If your browser window is already maximized, you will not be able to complete this experiment.
The minimum width is "+r+"px. Your current width is "+window.innerWidth+"px.
The minimum height is "+n+"px. Your current height is "+window.innerHeight+"px.
";case 6:if(!(window.innerWidthYour browser does not support the WebAudio API, which means that you will not be able to complete the experiment.Browsers that support the WebAudio API include Chrome, Firefox, Safari, and Edge.
",new Error;case 16:case"end":return t.stop()}}),t,this)})))}},{key:"drawProgressBar",value:function(e){document.querySelector(".jspsych-display-element").insertAdjacentHTML("afterbegin",'')}},{key:"updateProgressBar",value:function(){this.setProgressBar(this.getProgress().percent_complete/100)}},{key:"setProgressBar",value:function(e){e=Math.max(Math.min(1,e),0),document.querySelector("#jspsych-progressbar-inner").style.width=100*e+"%",this.progress_bar_amount=e}},{key:"getProgressBarCompleted",value:function(){return this.progress_bar_amount}}]),n}();return"undefined"!=typeof window&&window.hasOwnProperty("webkitAudioContext")&&!window.hasOwnProperty("AudioContext")&&(window.AudioContext=webkitAudioContext),e.JsPsych=Z,e.initJsPsych=function(e){var t=new Z(e);return Object.defineProperties(t,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((function(e){var t=d(e,2),r=t[0],n=t[1];return[r,{get:function(){throw new w(n)}}]})))),t},e.universalPluginParameters=A,Object.defineProperty(e,"__esModule",{value:!0}),e}({}),initJsPsych=jsPsychModule.initJsPsych;
//# sourceMappingURL=index.browser.min.js.map