/*! * PennController for IBEX * This software is licensed under a BSD license; see the LICENSE file for details. * * - Version 2.0.beta * - Last Update: 2021, June 22 * - Major changes in version 2.0.beta: * * Fixed Controller element duplicating lines and not rerunning properly * * Fixed selector.shuffle and its order logging * * Improved handling of trial end for the MediaRecorder element * * Improved audio/video recording upload * * Fixed print/canvas.add coordinates format bug (introduced in 1.9) * * Can now pass opacity of 0 to audio.disable and video.disable * * Fixed all-digit strings passed to Key element * * Fixed MediaRecorder stop / end of trials * * Fixed problems with some special commands (eg. fullscreen) not being properly executed as callback * * Fixed: Controller elements no longer appear multiple times when printed onto a Canvas element * * Fixed: calling print() after print(x,y[, canvas]) no longer preserves old positioning * * Fixed: referencing PennController element in scale.label before printing it * * Fixed elusive flickering with scaling * * Fixed selector.shuffle with elements printed before/after other elements * * Replaced the EyeTracker test with a smoother one * * Resources are now preloading 4 at a time, following the running order (= less aggressive requests) * * Fixed audio and video preloading problems * * Fixed video.disable semi-opaque layer * + Added newTrial().noTrialLog("start","end") to skip the tria's Start and/or End lines in the results file * + Added controller.callback * + Added textinput.callback * + Added specialcommand jump to navigate the sequence * + Added element DragDrop * */!function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=45)}([function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var i=n(1);let r=[],s={keypress:[]};class o{constructor(e,t,n){this.name=e,this.value=e,this.creator=t,this.controllers=[],this.object=null,this.status="void",this.useURLs=void 0===n||n,this.created_at=0}create(){this.status="pending",this.created_at=Date.now(),this.creator.call(this,()=>this.resolve())}resolve(){this.status="ready",a.debug.log("
Successfully preloaded resource "+this.name+"
")}}var a={resources:{list:[],fetch:function(e,t,n){var i=a.resources.list.filter(t=>t.name==e&&t.controllers.indexOf(a.controllers.underConstruction.id)<0);return(i=i.length?i[0]:new o(e,t,n)).controllers.push(a.controllers.underConstruction.id),a.controllers.underConstruction.resources.push(i),"void"!=i.status||(i.creator=t,a.resources.list.push(i)),i}},controllers:{list:[],running:null,underConstruction:null},elements:{list:[]},events:{keypress:e=>{let t=[e,a.controllers.running||a.controllers.underConstruction];if(s.keypress.push(t),a.controllers.running){let e=a.controllers._endTrial;a.controllers.running._endTrial=async function(){await e.apply(a.controllers.running),t[0]=()=>{}}}else{let e=a.controllers.underConstruction.sequence;a.controllers.underConstruction.sequence=Object(i.d)([e,e=>{t[0]=()=>{},e()}])}}},URLs:[],utils:{guidGenerator:i.b,parseCoordinates:i.h,printAndRefreshUntil:i.j,levensthein:i.e,upload:i.k,overToScale:i.g},tmpItems:[],tables:{},Prerun:function(e){r.push(e)}};let l=window.ibex_controller_set_properties;window.ibex_controller_set_properties=function(e,t){if(l(e,t),"__SendResults__"==e){document.addEventListener("keydown",e=>{if(!e.repeat&&a.controllers.running)for(let t=0;t{const e=t=>{a.runningOrder&&a.runningOrder.active?t():window.requestAnimationFrame(()=>e(t))};await new Promise(e);let t=[];a.runningOrder.active.forEach(e=>e.forEach(e=>{"PennController"==e.controller&&(t=[...t,...e.options.resources])}));let n=[];const i=()=>{if(n=n.filter(e=>"ready"!=e.status||e.created_at&&Date.now()-e.created_at>1e4),t.length>0&&n.length<4){let e=t.shift();for(;(void 0===e||"ready"==e.status)&&t.length;)e=t.shift();e&&"ready"!=e.status&&n.push(e)}0!=n.length&&(n.forEach(e=>{if(e instanceof o&&"void"==e.status&&(e.create(),e.useURLs))for(let t in a.URLs)e.create.apply($.extend({},e,{value:a.URLs[t]+e.name,resolve:function(){"ready"!=e.status&&(e.object=this.object,e.resolve())}}))}),window.requestAnimationFrame(i))};i()})},function(e,t,n){"use strict";function i(e){return()=>new Promise((async function(t){for(let t in e)if(e[t]instanceof Function)var n=await e[t]();t(n)}))}function r(e){const t=new Uint8Array(e);let n=[];return t.forEach(e=>{n.push(e.toString(16))}),n.join("").toUpperCase()}n.d(t,"d",(function(){return i})),n.d(t,"c",(function(){return r})),n.d(t,"g",(function(){return o})),n.d(t,"k",(function(){return a})),n.d(t,"a",(function(){return l})),n.d(t,"f",(function(){return u})),n.d(t,"b",(function(){return h})),n.d(t,"i",(function(){return c})),n.d(t,"h",(function(){return d})),n.d(t,"j",(function(){return p})),n.d(t,"e",(function(){return m}));const s=function(e){const t=this.css("transform").match(/matrix\(\s*(-?\d+(.\d+)?),[^,]+,[^,]+,\s*(-?\d+(.\d+)?),/);return t&&(e.x=e.x*Number(t[1]),e.y=e.y*Number(t[3])),e};function o(e,t){let n=this,i={x:1,y:1};for(;n;)s.call(n,i),n=n.parent(),n[0]===document&&(n=void 0);let r=this.offset(),o=this.width(),a=this.height(),l=o*i.x,u=a*i.y;return r.left<=e&&r.top<=t&&r.left+l>=e&&r.top+u>=t}async function a(e,t,n,i){let r;try{r=await new Promise((n,r)=>{const s=new XMLHttpRequest,o=e.match(/\?/)?"&":"?";s.open("GET",e+o+"filename="+encodeURIComponent(t)+"&mimetype="+encodeURIComponent(i),!0),s.setRequestHeader("Content-Type","application/json"),s.onerror=t=>r("Could not GET "+e+";"),s.onload=function(){let e=null;try{e=JSON.parse(this.responseText)}catch{e=this.responseText}console.log("response",e),n(e)},console.log("before sending xhr"),s.send(),console.log("after sending xhr")})}catch(e){return new Promise((t,n)=>n(e))}console.log("presignedPostData",r);const s=new FormData;return void 0===r||"string"==typeof r?(s.append("fileName",t),s.append("mimeType",i),s.append("file",n)):(Object.keys(r).forEach(t=>{"url"==t?e=r.url:s.append(t,r[t])}),s.append("file",n),r.key&&(t=r.key)),new Promise((n,i)=>{const r=new XMLHttpRequest;r.open("POST",e,!0),r.onload=()=>n(t),r.onerror=()=>i(r.responseText);try{r.send(s)}catch(t){return i("Could not POST to "+e+"; "+t)}})}function l(e,t){if(e.match(/^00000[12]00/i))return"image/x-icon";if(e.match(/424D/i))return"image/bmp";if(e.match(/^89504E470?D0?A1A0?A/i))return"image/png";if(e.match(/^474946383[79]61/i))return"image/gif";if(e.match(/^52494646........574542505650/i))return"image/webp";if(e.match(/^FFD8FF/i))return"image/jpeg";if(e.match(/^2E736E64/i))return"audio/basic";if(e.match(/^464F524D........41494646/i))return"audio/aiff";if(e.match(/^(fff[b3a2]|494433)/i))return"audio/mpeg";if(e.match(/^4F67675300/i))return"application/ogg";if(e.match(/^4D546864......06/i))return"audio/midi";if(e.match(/^52494646........41564920/i))return"video/avi";if(e.match(/^52494646.{4,8}57415645/i))return"audio/wave";if(e.match(/^1A45DFA3/i))return"video/webm";if(e.match(/^25504446/i))return"application/pdf";if(e.match(/^504B0304/i))return"application/zip";{let e=t.match(/\.([^.]+)$/);if(!e)return"";switch(e[1].toLowerCase()){case"bmp":return"image/bmp";case"png":return"image/png";case"gif":return"image/gif";case"webp":return"image/webp";case"jpg":case"jpeg":return"image/jpeg";case"mp3":return"audio/mpeg";case"ogg":case"oga":return"audio/ogg";case"midi":case"mid":return"audio/midi";case"wav":return"audio/wave";case"webm":return"video/webm";case"avi":return"video/avi";case"mp4":return"video/mp4";case"ogv":return"video/ogg";case"mov":return"video/quicktime";default:return""}}}function u(e){let t=e/1e3%60,n=Math.trunc(e/6e4);return(n>0?n+"min":"")+(t>0?t+"s":"")}function h(){var e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}function c(e){return e.map(e=>e instanceof Object&&e.hasOwnProperty("_promises")&&e.type&&e._element?e.type+":"+e._element.id:e)}function d(e,t){const n=this.css("transform").match(/matrix\(\s*(-?\d+(.\d+)?),[^,]+,[^,]+,\s*(-?\d+(.\d+)?),/),i=window.getComputedStyle(this[0]),r=Number(i.width.replace(/px$/,"")),s=Number(i.height.replace(/px$/,""));let o=r,a=s;n&&(o=Math.abs(o*n[1]),a=Math.abs(a*n[3]));let l=String(e).match(/^(.+)\s+at\s+(.+)$/i),u=String(t).match(/^(.+)\s+at\s+(.+)$/i);if(l&&(e=String(l[2])),u&&(t=String(u[2])),isNaN(e)||(e+="px"),isNaN(t)||(t+="px"),l){if(l[1].match(/top|bottom/i))throw"Passed Y coordinate in place of X";e=l[1].match(/center|middle/i)?`calc(${e} - ${r/2}px)`:l[1].match(/right/i)?`calc(${e} - ${o-(o-r)/2}px)`:`calc(${e} + ${(o-r)/2}px)`}else e=`calc(${e} + ${(o-r)/2}px)`;if(u){if(u[1].match(/left|right/i))throw"Passed X coordinate in place of Y";t=u[1].match(/center|middle/i)?`calc(${t} - ${s/2}px)`:u[1].match(/bottom/i)?`calc(${t} - ${a-(a-s)/2}px)`:`calc(${t} + ${(a-s)/2}px)`}else t=`calc(${t} + ${(a-s)/2}px)`;return{x:e,y:t}}function f(e,t,n,i,r){if(i instanceof Function&&i())return this.css(r);const s=d.call(this,e,t);this.css({position:"absolute",left:s.x,top:s.y}),window.requestAnimationFrame(()=>f.call(this,e,t,n,i,r))}function p(e,t,n,i){n=n||$("body");const r=this.parent()[0],s={display:this.css("display"),position:this.css("position"),left:this.css("left"),top:this.css("top")};void 0!==r&&r==n[0]||this.appendTo(n).css("display","inline-block"),f.call(this,e,t,n,i,s)}function m(e,t){let n=[];n[0]=("a"+t).split("").map((e,t)=>t);for(let i=1;i0)];for(let i=1;ie.toUpperCase());String.prototype.isSpecialKey=function(e){return e?g.indexOf(this)>-1:y.indexOf(this.toUpperCase())>-1},jQuery.fn.printed=function(){let e=this.parent();for(;e.length;){if(e[0]==document.body)return!0;e=e.parent()}return!1}},function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return h}));var i=n(0),r=n(1);let s=null,o=null,a=[];class l{constructor(){if(this.id=i.a.controllers.list.length,this.useLabel=!1,this.addToItems=!0,this.appendResultLine=[],this.linesToSave=[],this.resources=[],this.elements={},this.ambiguousElementNames=[],this.preloadDelay=6e4,i.a.controllers.list.push(this),this.defaultCommands={},this.headerDefaultCommands={},s&&s.defaultCommands)for(let e in s.defaultCommands)this.defaultCommands[e]=[].concat(s.defaultCommands[e])}_addElement(e){if(!e.hasOwnProperty("type")||!e.hasOwnProperty("id"))return i.a.debug.error("Attempted to create an invalid element");this.elements.hasOwnProperty(e.type)||(this.elements[e.type]={}),this.elements[e.type].hasOwnProperty(e.id)&&i.a.debug.warning("Overwrting another "+e.type+" element with the same name ("+e.id+")"),this.elements[e.type][e.id]=e}_getElement(e,t){if("string"!=typeof e||e.length<1||"string"!=typeof t||t.length<1)return i.a.debug.error("Attempted to get an invalid element",e,t);if(!this.elements.hasOwnProperty(t))return i.a.debug.error("Attempted to get an element of an invalid type ("+t+")",e);if(!this.elements[t].hasOwnProperty(e)){let n=[];for(let t in this.elements)this.elements[t].hasOwnProperty(e)&&n.push(t);return i.a.debug.error("No "+t+" element named ""+e+"" found",n.length?"Found ""+e+"" of type "+n.join(","):null)}return this.elements[t][e]}label(e){return this.useLabel=e,this}logAppend(e,t,n){return this.linesToSave.push(["PennController",this.id,e,t,Date.now(),n]),this}log(e,t){return null==t&&(t=e),void 0===e?(i.a.debug.warning("Used newTrial().log with no arguments"),this):(this.appendResultLine.push([csv_url_encode(e),t]),this)}noHeader(){return this.runHeader=!1,this}noFooter(){return this.runFooter=!1,this}setOption(e,t){return this[e]=t,this}noTrialLog(...e){return this.skipLog=e,this}}i.a.controllers.underConstruction=new l,i.a.controllers.new=()=>new l;const u=[];var h=function(...e){let t=i.a.controllers.underConstruction;if(window.items)for(let e in window.items)i.a.tmpItems.indexOf(window.items[e])<0&&i.a.tmpItems.push(window.items[e]);i.a.tmpItems.push(t),e.length&&"string"==typeof e[0]&&(t.useLabel=e[0]);let n=[];return function e(...t){for(let n in t)u.filter(e=>e instanceof Function&&e.call(null,t[n])),t[n]&&t[n]._promises?this.push(Object(r.d)(t[n]._promises)):t[n]&&t[n]instanceof Array&&e.apply(this,t[n])}.apply(n,e),t.sequence=Object(r.d)(n),i.a.controllers.underConstruction=new l,t};i.a.NewTrialArgumentCallback=e=>u.push(e),h.newTrial=h,h.Debug=function(e){i.a.debug.on=null==e||e},h.DebugOff=()=>h.Debug(!1),h.Sequence=function(...e){for(let t=0;t1&&"__SendResults__"==e[t]._item[1]){let n="sendResults-"+Object(r.b)();e[t].label(n),e[t]=n}window.shuffleSequence=window.seq(...e)};let c={};h.GetURLParameter=function(e){if(!Object.keys(c).length){let e=window.location.search.replace("?","").split("&");for(let t in e)c[e[t].split("=")[0]]=e[t].split("=")[1]}if(c.hasOwnProperty(e))return c[e]},h.AddHost=function(...e){for(let t in e)"string"==typeof e[t]&&e[t].match(/^https?:\/\//i)?i.a.URLs.push(e[t]):i.a.debug.warning("URL #"+t+" is not a valid URL (PennController.AddHost).",e[t])},h.CheckPreloaded=function(...e){let t=new l;t.id="Preloader-"+a.length,t.runHeader=!1,t.runFooter=!1,a.push(t),i.a.controllers.list.pop(),t.sequence=()=>new Promise(e=>e()),t.ignoreWhenCheckingPreload=!0,i.a.tmpItems.push(t),e.length&&Number(e[e.length-1])>0&&(t.preloadDelay=Number(e[e.length-1]),e.pop());let n=[];if(e.length)for(let t in e){let i=e[t];"string"==typeof i&&(i=n=>n==e[t]),i instanceof Function&&n.push(i)}else n=[e=>!0];return i.a.Prerun(()=>{let e=window.conf_modifyRunningOrder;window.conf_modifyRunningOrder=function(i){e instanceof Function&&(i=e.call(this,i));for(let e=0;e{let t=!1;for(let i=0;it.resources.indexOf(e)<0))}return i}}),t};const d=window.JSON.stringify;window.JSON.stringify=function(...e){const t=d.apply(this,e);if(1==e.length&&e[0]instanceof Array&&6==e[0].length&&!1===e[0][0]&&e[0][1]==window.__counter_value_from_server__&&e[0][4]==(()=>{for(var e=(new Date).getTimezoneOffset()+":",t=["Java","QuickTime","DevalVR","Shockwave","Flash","Windows Media Player","Silverlight","VLC Player"],n=0;nnew Promise(e=>{const n=window.__server_py_script_name__;let r={_finishedCallback:()=>{window.__server_py_script_name__=n,e()},_cssPrefix:"",_utils:i.a.controllers.running.utils},s=window.$("

").addClass("PennController-SendResults");i.a.controllers.running.element.append(s),addSafeBindMethodPair("__SendResults__"),"string"==typeof t&&(window.__server_py_script_name__=t),s.__SendResults__(r)}),o={label:e=>(r[0]=e,o),setOption:(e,t)=>(n[e]=t,o)};o._item=r,o.type="__SendResults__",o._element={id:"SendResults"};const a=e=>{if(e==o){let e=window.items&&window.items.indexOf(r);e>=0&&window.items.splice(e,1),i.a.tmpItems=i.a.tmpItems.filter(e=>e!=r)}};return i.a.ArgumentCallback(a),i.a.NewTrialArgumentCallback(a),o._promises=[s],o._runPromises=s,window.items.push(r),o},h.SetCounter=function(...e){null==window.items&&(window.items=[]);let t="setCounter",n={};e.length&&(isNaN(Number(e[0]))?1==e.length?isNaN(Number(e[0]))?t=e[0]:n.set=Number(e[0]):2!=e.length||isNaN(Number(e[1]))?e.length>2&&!isNaN(Number(e[2]))?(t=e[0],e[1].match(/\s*inc\s*$/i)?n.inc=e[2]:n.set=e[2]):t=e[0]:e[0].match(/\s*inc\s*$/i)?n.inc=e[1]:(n.set=e[1],e[0].match(/\s*set\s*$/i)||(t=e[0])):n.set=Number(e[0]));let i=[t,"__SetCounter__",n];return n.label=e=>(i[0]=e,n),n.setOption=(e,t)=>(n[e]=t,n),window.items.push(i),n},h.Header=function(...e){let t=i.a.controllers.underConstruction;t.id="Header",t.addToItems=!1,i.a.controllers.list.pop(),t.sequence=Object(r.d)(e.map(e=>Object(r.d)(e._promises)));for(let e in t.defaultCommands)for(let n in t.defaultCommands[e])t.defaultCommands[e][n].push("header");return s?(s.resources=s.resources.concat(t.resources),$.extend(!0,s.elements,t.elements),s.headerDefaultCommands=t.headerDefaultCommands,s.sequence=Object(r.d)([s.sequence,t.sequence])):s=t,i.a.controllers.underConstruction=new l,s},h.Footer=function(...e){let t=i.a.controllers.underConstruction;return t.id="Footer",t.addToItems=!1,i.a.controllers.list.pop(),t.sequence=Object(r.d)(e.map(e=>Object(r.d)(e._promises))),o?(o.resources=o.resources.concat(t.resources),$.extend(!0,o.elements,t.elements),o.headerDefaultCommands=t.headerDefaultCommands,o.sequence=Object(r.d)([o.sequence,t.sequence])):o=t,i.a.controllers.underConstruction=new l,o},define_ibex_controller({name:"PennController",jqueryWidget:{_init:function(){var e=this;i.a.controllers.running=e,e.cssPrefix=e.options._cssPrefix,e.utils=e.options._utils,e.finishedCallback=e.options._finishedCallback,e.id=e.options.id,"string"==typeof e.id&&e.id.match(/^Preloader-/)?e.controller=a[Number(e.id.replace(/Preloader-/,""))]:"Header"==e.id?e.controller=s:"Footer"==e.id?e.controller=o:Number(e.id)>=0&&Number(e.id)e.controller.resources.indexOf(t)<0)),$.extend(!0,e.controller.elements,s.elements);for(let t=0;te.controller.resources.indexOf(t)<0)),$.extend(!0,e.controller.elements,o.elements);for(let t=0;t0&&0==o.skipLog.filter(e=>e.match(/start/i)).length)||e.save("PennController",e.id,"_Footer_","Start",Date.now(),"NULL"),o._getElement=(t,n)=>e.controller._getElement(t,n),await o.sequence(),o.skipLog instanceof Array&&!(o.skipLog.length>0&&0==o.skipLog.filter(e=>e.match(/end/i)).length)||e.save("PennController",e.id,"_Footer_","End",Date.now(),"NULL"));for(let t in e.controller.elements)for(let n in e.controller.elements[t])await e.controller.elements[t][n].end();e.controller.skipLog instanceof Array&&!(e.controller.skipLog.length>0&&0==e.controller.skipLog.filter(e=>e.match(/end/i)).length)||e.save("PennController",e.id,"_Trial_","End",Date.now(),"NULL"),n.sort((e,t)=>e[4][1]>t[4][1]),n.map(e=>{for(let t in e){e[t][1]instanceof Function&&(e[t][1]=e[t][1]());let n=[];for(;e[t][1].value&&e[t][1].value._element;)n.indexOf(e[t][1]._element)<0?(n.push(e[t][1]._element),e[t][1]=e[t][1].value):e[t][1]=e[t][1]._element.id;e[t][1]._element&&e[t][1]._element.id&&(e[t][1]=e[t][1]._element.value),e[t][1]=csv_url_encode(""+e[t][1])}}),e.finishedCallback(n)}};e.endTrial=h;let c=!1,d=async function(t){if(!c){if(e.element.css({display:"flex","flex-direction":"column",position:"absolute",left:0,width:"100vw"}),c=!0,t)for(let t in e.controller.resources.filter(e=>"ready"!=e.status))e.save("PennController",e.id,"_PreloadFailed_",csv_url_encode(e.controller.resources[t].name),Date.now(),"NULL");f.remove(),e.controller.skipLog instanceof Array&&!(e.controller.skipLog.length>0&&0==e.controller.skipLog.filter(e=>e.match(/start/i)).length)||e.save("PennController",e.id,"_Trial_","Start",Date.now(),"NULL"),e.runHeader&&s instanceof l&&(s.skipLog instanceof Array&&!(s.skipLog.length>0&&0==s.skipLog.filter(e=>e.match(/start/i)).length)||e.save("PennController",e.id,"_Header_","Start",Date.now(),"NULL"),await s.sequence(),s.skipLog instanceof Array&&!(s.skipLog.length>0&&0==s.skipLog.filter(e=>e.match(/end/i)).length)||e.save("PennController",e.id,"_Header_","End",Date.now(),"NULL")),e.controller.sequence().then(h)}},f=$("

Please wait while the resources are preloading

This may take up to "+Object(r.f)(t)+".

");e.element.append(f);for(let t in e.controller.resources){let n=e.controller.resources[t],i=n.resolve;"ready"!=n.status&&(n.resolve=function(){i.apply(n),0==e.controller.resources.filter(e=>"ready"!=e.status).length&&d()})}0==e.controller.resources.filter(e=>"ready"!=e.status).length?d():setTimeout((function(){d(!0)}),t)}},properties:{obligatory:[],countsForProgressBar:!0,htmlDescription:null}}),window.PennController=new Proxy(h,{get:(e,t)=>{if(t in e)return e[t];i.a.debug.error("Unknown global PennController command: ‘"+t+"’")}})},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var i={};function r(){try{return new window.XMLHttpRequest}catch(e){}}i._getBinaryFromXHR=function(e){return e.response||e.responseText};var s=window.ActiveXObject?function(){return r()||function(){try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}()}:r;i.getBinaryContent=function(e,t){try{var n=s();n.open("GET",e,!0),"responseType"in n&&(n.responseType="arraybuffer"),n.overrideMimeType&&n.overrideMimeType("text/plain; charset=x-user-defined"),n.onreadystatechange=function(r){var s,o;if(4===n.readyState)if(200===n.status||0===n.status){s=null,o=null;try{s=i._getBinaryFromXHR(n)}catch(e){o=new Error(e)}t(o,s)}else t(new Error("Ajax error for "+e+" : "+this.status+" "+this.statusText),null)},n.send()}catch(e){t(new Error(e),null)}},e.exports=i},function(e,t,n){(function(n){var i,r,s;r=[],void 0===(s="function"==typeof(i=function(){"use strict";function t(e,t,n){var i=new XMLHttpRequest;i.open("GET",e),i.responseType="blob",i.onload=function(){o(i.response,t,n)},i.onerror=function(){console.error("could not download file")},i.send()}function i(e){var t=new XMLHttpRequest;return t.open("HEAD",e,!1),t.send(),200<=t.status&&299>=t.status}function r(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var s="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n&&n.global===n?n:void 0,o=s.saveAs||"object"!=typeof window||window!==s?function(){}:"download"in HTMLAnchorElement.prototype?function(e,n,o){var a=s.URL||s.webkitURL,l=document.createElement("a");n=n||e.name||"download",l.download=n,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?r(l):i(l.href)?t(e,n,o):r(l,l.target="_blank")):(l.href=a.createObjectURL(e),setTimeout((function(){a.revokeObjectURL(l.href)}),4e4),setTimeout((function(){r(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,n,s){if(n=n||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Depricated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,s),n);else if(i(e))t(e,n,s);else{var o=document.createElement("a");o.href=e,o.target="_blank",setTimeout((function(){r(o)}))}}:function(e,n,i,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,i);var o="application/octet-stream"===e.type,a=/constructor/i.test(s.HTMLElement)||s.safari,l=/CriOS\/[\d]+/.test(navigator.userAgent);if((l||o&&a)&&"object"==typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=l?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=e:location=e,r=null},u.readAsDataURL(e)}else{var h=s.URL||s.webkitURL,c=h.createObjectURL(e);r?r.location=c:location.href=c,r=null,setTimeout((function(){h.revokeObjectURL(c)}),4e4)}};s.saveAs=o.saveAs=o,e.exports=o})?i.apply(t,r):i)||(e.exports=s)}).call(this,n(3))},function(e,t,n){"use strict";var i=n(0),r=n(1);$.prototype.left=function(){return Number(this.css("left").replace(/px/,""))},$.prototype.top=function(){return Number(this.css("top").replace(/px/,""))};i.a.Prerun(()=>{const e=window.location.pathname;if(!i.a.debug.on||null==="2.0.beta".match(/beta/i)||window.localStorage.getItem(e))return;const t=new s("Beta Version",400,200,"calc(50vw - 200px)","calc(50vh - 100px)");t.container.find("div:nth-child(3)").remove(),t.content.html("

Please note that this project is using a beta version of PennController (2.0.beta).

\n

Report new bugs at https://www.pcibex.net/bug-report/\n or at support@pcibex.net

"),t.popIn(),t.titleExpand.click().remove();const n=t.popOut;t.popOut=()=>{window.localStorage.setItem(e,!0),n.call(t)}});class s{constructor(e,t,n,i,r){let s=this;this.title=e,this.width=t,this.height=n,this.x=i,this.y=r,this.tabs=[],this.container=$("
").css({width:t,height:"3em",overflow:"hidden",position:"fixed","border-radius":"5px","background-color":"floralwhite","min-height":"3em","min-width":"3em","z-index":9999}),this.titleBar=$("
").css({width:"100%",height:"1.5em",margin:0,padding:0,"background-color":"gray",cursor:"move",color:"white","border-radius":"5px 5px 0px 0px"}),this.titleExpand=$("").css({display:"inline-block","line-height":"1.3em",padding:"2px","margin-right":"0.25em",cursor:"pointer"}).click(()=>{9656==this.titleExpand.html().charCodeAt(0)?(this.titleExpand.html("▾"),this.container.css({height:this.height,overflow:"unset"})):(this.titleExpand.html("▸"),this.container.css({height:"3em",overflow:"hidden"}))}),this.titleSpan=$(""+e+"").css({display:"inline-block",padding:"2px","line-height":"1.3em",overflow:"hidden"}),this.titleBar.append(this.titleSpan.prepend(this.titleExpand)).append($("X").css({width:"1.3em",height:"1.3em",margin:"0.1em","line-height":"1.3em","border-radius":"2px","text-align":"center",position:"absolute",right:0,cursor:"pointer",overflow:"hidden"}).click((function(){s.popOut()})).mouseenter((function(){$(this).css({border:"solid 1px lightgray","border-radius":"2px"})})).mouseleave((function(){$(this).css({border:"none"})}))).mousedown((function(e){s.updatePosition={x:e.clientX,y:e.clientY,left:s.container.left(),top:s.container.top()},e.preventDefault()})),this.tabBar=$("
").css({width:"calc(100% - 10px)",height:"1.5em","margin-bottom":"0px",overflow:"hidden",display:"flex","margin-left":"5px","margin-right":"5px"}),this.tabBar.append($("
").css({width:"100%","border-bottom":"solid 1px lightgray"})),this.newTab=(e,t)=>{e instanceof jQuery||(e=$("").append(e)),t instanceof jQuery||(t=$("
").append(t));let n={title:e,content:t,jQuery:$("
").append(e).css({border:"solid 1px lightgray","border-top-right-radius":"5px","border-top-left-radius":"5px","padding-left":"5px","padding-right":"5px",cursor:"pointer"}).click(()=>{this.content.children().detach(),this.content.append(n.content),this.tabBar.children().css({background:"linen",color:"darkgray","border-bottom":"solid 1px lightgray"}),n.jQuery.css({color:"black",background:"inherit","border-bottom":"none"}),a.activeTab=n}),remove:()=>this.jQuery.remove()};return this.tabs.push(n),this.tabBar.prepend(n.jQuery),n},this.container.append($("
").css({display:"inline-block",width:"1.3em",height:"1.3em",position:"absolute",bottom:0,right:0,cursor:"se-resize",background:"repeating-linear-gradient(135deg,rgba(255,255,255,.5),rgba(255,255,255,.5) 2px,#777 2px,#777 4px)","clip-path":"polygon(90% 0,90% 90%,0 90%)",opacity:"0.5"}).mousedown((function(e){s.updateSize=!0,s.offsetRight=e.clientX-(s.container.left()+s.container.width()),s.offsetBottom=e.clientY-(s.container.top()+s.container.height()),e.preventDefault()}))),this.content=$("
").css({border:"solid 1px lightgray","font-family":"monospace","font-size":"0.9em",margin:"0px 5px 5px 5px",padding:"2px",height:"calc(100% - 4.5em - 30px)",overflow:"auto","border-top":"none"}),this.container.append(this.titleBar),this.container.append($("
Use DebugOff() before publishing.
").css({height:"1.5em","overflow-x":"hidden"})),this.container.append(this.tabBar),this.container.append(this.content),this.container.css({left:i,top:r}),$(document).mousemove((function(e){s.updatePosition&&(s.x=s.updatePosition.left+(e.clientX-s.updatePosition.x),s.y=s.updatePosition.top+(e.clientY-s.updatePosition.y),s.container.css({left:s.x,top:s.y})),s.updateSize&&(s.width=e.clientX-s.container.left()-s.offsetRight,s.height=e.clientY-s.container.top()-s.offsetBottom,s.container.css({width:s.width,height:s.height}))})).mouseup((function(){s.updatePosition=void 0,s.updateSize=!1}))}popIn(){$(document.body).append(this.container)}popOut(){this.container.detach()}}let o=!1,a={popin:{},tablePopin:{},infoTab:null,runningOrder:null,runningIndex:-1,runningElement:-1,currentController:null,currentTable:null,activeTab:null};i.a.debug={on:!0,currentPromise:null,forceResolve:()=>{i.a.debug.currentPromise instanceof Function&&i.a.debug.currentPromise()},addToTab:(e,...t)=>{if(!i.a.debug.on)return;let n;n=i.a.controllers.running?i.a.controllers.list[i.a.controllers.running.id]:i.a.controllers.underConstruction,null==n&&(n={id:"NA"});let r=new Date;e.prepend($("
["+[r.getHours(),r.getMinutes(),r.getSeconds()].join(":")+"] "+t.join(";")+" (newTrial: "+n.id+(n.useLabel?"-"+n.useLabel:"")+")
").css({"border-bottom":"dotted 1px gray","margin-bottom":"1px","padding-bottom":"1px"}))},log:(...e)=>i.a.debug.addToTab(a.logTab.log,...e),warning:(...e)=>{i.a.debug.on&&(i.a.debug.addToTab(a.warningsTab.content,...e),a.warningsTab.title.css("color","orange"),a.warningsTab.content.find(".PennController-debug-nowarnings").css("display","none"),9656==a.popin.titleExpand.html().charCodeAt(0)&&a.popin.titleExpand.click(),a.warningsTab.jQuery.click())},error:(...e)=>{i.a.debug.on&&(i.a.debug.addToTab(a.errorsTab.content,...e),a.errorsTab.title.css("color","red"),a.errorsTab.content.find(".PennController-debug-noerrors").css("display","none"),9656==a.popin.titleExpand.html().charCodeAt(0)&&a.popin.titleExpand.click(),a.errorsTab.jQuery.click())}},a.popin=new s("Debug (PennController 2.0.beta)",440,240,window.innerWidth-450,10),a.logTab=a.popin.newTab("Log"),a.logTab.controls=$("
").append($("").click(()=>{"PennController-"==a.currentController._cssPrefix?i.a.controllers.running.endTrial():a.currentController._finishedCallback()})).append($("").click(()=>i.a.debug.forceResolve())).css({background:"lightgray","border-bottom":"dotted 1px black"}).appendTo(a.logTab.content),a.logTab.log=$("
").appendTo(a.logTab.content),a.warningsTab=a.popin.newTab("Warnings"),a.warningsTab.content.prepend($("
No warnings
").css({"font-style":"italic","text-align":"center",margin:"5px"}).addClass("PennController-debug-nowarnings")),a.errorsTab=a.popin.newTab("Errors"),a.errorsTab.content.prepend($("
No errors found
").css({"font-style":"italic","text-align":"center",margin:"5px"}).addClass("PennController-debug-noerrors"));let l=()=>{a.currentTable&&a.currentTable.debug&&(a.currentTable.debug.content.find("tr").css("background-color","transparent"),$(a.currentTable.debug.content.find("tr")[a.currentRow+1]).css("background-color","pink"),a.tablePopin.titleSpan.after(u),a.currentTable.hasOwnProperty("group")&&a.currentTable.table[0].hasOwnProperty(a.currentTable.group)&&u.after(c))},u=$("").click((function(){a.currentTable.debug.jQuery.click();let e=$(a.currentTable.debug.content.find("tr")[a.currentRow+1]).position().top;a.currentTable.debug.content.children()[2].scrollTop+=e})).css({display:"inline-block",padding:"2px 5px","line-height":"1.3em",overflow:"hidden"}),h=!1,c=$("👁").click((function(){if(h)a.currentTable.debug.content.find("tr").css("display","table-row");else{let e=a.currentTable.table[a.currentRow][a.currentTable.group],t=a.currentTable.debug.content.find("tr");for(let n=0;n{let t=Object.keys(e.table[0]),n=$("").css({display:"table","table-layout":"fixed",height:"100%",width:70*(t.length+1)}),i=$("
").css({display:"table","table-layout":"fixed",height:"100%",width:70*(t.length+1)}),r=$("");r.append($("
").html("#").css({width:70,overflow:"hidden"}));for(let e=0;e").html(t[e]).css({width:70,overflow:"hidden"}));i.append(r);for(let i=0;i");r.append($("").html(""+Number(i+1)+".").css({width:70,overflow:"hidden"}));for(let n=0;n").html(e.table[i][t[n]]).css({width:70,overflow:"hidden"}));n.append(r)}let s=$("
").css({height:"calc(100% - 1.5em)",overflow:"auto"}).append(n),o=$("
").css({height:"1.5em",width:"100%"}),a=$("
").css({width:"100%",position:"absolute",left:0,top:0}).append(i);return s.scroll(()=>a.css("margin-left",-1*s[0].scrollLeft)),$("
").css({width:"100%",height:"100%","white-space":"nowrap",position:"relative",overflow:"hidden"}).append(a).append(o).append(s)},f=e=>{if(a.tablePopin.hasOwnProperty("container"))a.tablePopin.container.parent().length>0?a.tablePopin.tabs[e].jQuery.click():$(document.body).append(a.tablePopin.container);else{a.tablePopin=new s("Tables",window.innerWidth-320,190,10,window.innerHeight-200);let t=Object.keys(i.a.tables);for(let e=0;e{if(a.runningIndex<0&&(a.runningIndex=0),a.runningElement<0?a.runningElement=0:(a.runningElement++,a.runningElement>=a.runningOrder[a.runningIndex].length&&(a.runningElement=0,a.runningIndex++)),"__SendResults__"==a.runningOrder[a.runningIndex][a.runningElement].controller&&(o=!0),!i.a.debug.on)return void(window.items=void 0);if(b(),g(),u.detach(),c.detach(),a.currentTable=null,a.currentTableName="NA",a.currentRow=-1,a.currentController=a.runningOrder[a.runningIndex][a.runningElement].options,a.currentController.hasOwnProperty("_PennController")){a.currentTable=a.currentController._PennController.table;for(let e in i.a.tables)i.a.tables[e]==a.currentTable&&(a.currentTableName=e);a.currentRow=Number(a.currentController._PennController.row),l()}let e=a.runningOrder[a.runningIndex][a.runningElement];a.infoTab.content.empty(),a.infoTab.content.append($("
Trial in sequence "+Number(a.runningIndex+1)+" / "+a.runningOrder.length+"
")).append($("
Element in trial "+Number(a.runningElement+1)+" / "+a.runningOrder[a.runningIndex].length+"
")).append($("
Trial's label: "+e.type+"
")).append($("
Trial's type (controller): "+e.controller+"
")).append($("
Trial's index: "+e.itemNumber+" / "+window.items.length+"
")).append($("
From table: "+a.currentTableName+"
")),"PennController"==e.controller?$(a.logTab.controls.children()[1]).css("display","inline-block"):$(a.logTab.controls.children()[1]).css("display","none")};let m=window.dget;window.dget=(...e)=>{let t=m(...e);return e[1]&&"displayMode"==e[1]&&e[2]&&"overwrite"==e[2]&&p(),t};const g=()=>{if(window.conf_showProgressBar){let e=0,t=0;a.runningOrder.forEach((n,i)=>n.forEach((n,r)=>{const s=ibex_controller_get_property(n.controller,"countsForProgressBar");(void 0===s||s)&&(e++,(i table div.bar-container"),i=n.find(".bar"),r=5*e<300?5*e:300,s=t*r/e;n.css("width",r),i.css("width",Math.round(s)+"px")}},y=e=>{a.runningIndexy(e),1))},b=()=>{const e=$("
    ");for(let t=0;t").append(s);t<=a.runningIndex?o.css({color:"gray","background-color":t==a.runningIndex?"pink":"transparent"}):o.append($("").click(()=>y(t))),e.append(o)}a.sequenceTab.content.empty().append(e)};let w=window.$.ajax;window.$.ajax=(...e)=>(i.a.debug.on&&e[0]&&e[0].url&&e[0].url.match(/\?allchunks=1$/)&&a.popin.popIn(),w(...e)),i.a.Prerun(()=>{window.onbeforeunload=function(){if(!o)return"Your results have not been sent yet. Do you really want to leave the page?"};let e=!1;PennController.version="2.0.beta";let t=window.assert;window.assert=function(...n){if(e||"There must be some items in the running order!"!=n[1])return t.apply(this,n);e=!0;let r=window.conf_modifyRunningOrder;return window.conf_modifyRunningOrder=function(e){a.runningOrder=r instanceof Function?r.call(this,e):e,i.a.runningOrder={active:a.runningOrder,original:[...a.runningOrder]};const t=i.a.runningOrder.active.push;let n=!1;return i.a.runningOrder.active.push=function(...e){const r=t.apply(this,e);return!n&&e[0]instanceof Array&&e[0][0]&&"__SendResults__"==e[0][0].controller&&(i.a.runningOrder.original=[...this],n=!0),r},Object.defineProperty(i.a.runningOrder,"runningIndex",{get:()=>a.runningIndex}),i.a.debug.on&&(()=>{let e=Object.keys(i.a.tables);if(e.length>0){let t=$("
      ");for(let n=0;n").html(e[n]).click(()=>f(n)).css("cursor","pointer"));a.popin.newTab("Tables",t)}a.sequenceTab=a.popin.newTab("Sequence"),a.infoTab=a.popin.newTab("Info"),b(),a.activeTab?a.activeTab.jQuery.click():a.errorsTab.jQuery.click(),$(window.document).bind("keyup keydown",(function(e){if(e.ctrlKey&&68==e.keyCode){let t=window.innerWidth-450,n=window.innerHeight-250;return $(window.document.body).append(a.popin.container),a.popin.x=t,a.popin.y=n,a.popin.container.css({top:n,left:t}),e.preventDefault(),e.stopPropagation(),!1}}))})(),p(),a.runningOrder},t.apply(this,n)}}),window.onerror=function(e,t,n){if(!t.match(/include=data$/))return;let s=e.match(/ReferenceError: (.+) is not defined/);if(s)if(s[1].match(/^(new|get|default)/)&&PennController.Elements[s[1]])i.a.debug.error("Tried to use ‘"+s[1]+"’ without a prefix on line "+n+"; did you forget to use PennController.ResetPrefix?");else{let e={score:1,command:""},t=Object.getOwnPropertyNames(PennController.Elements);for(let n=0;n"+e.command+"’?"):i.a.debug.error("Unrecognized expression ‘"+s[1]+"’ (line "+n+")")}else i.a.debug.error(e)};let v=window.ibex_controller_get_property;window.ibex_controller_get_property=(e,t)=>{let n=Object.getOwnPropertyNames($.ui);if(n.indexOf(e)>-1)return v(e,t);let s={score:1,controllerName:""};for(let t=0;t"+s.controllerName+"?"):i.a.debug.error("Invalid controller reference: ‘"+e+"’")}},function(e,t,n){"use strict";var i=n(1),r=n(2),s=n(0);r.b.Elements={};class o{constructor(){this._commands=[],this._currentType="action."}}Object.defineProperty(r.b.Elements,"self",{get:()=>{const e=new o,t=new Proxy(e,{get:(n,i)=>{if("_commands"==i||"_currentType"==i||"hasOwnProperty"==i)return e[i];if(console.log("Getting self's proxy, with",i),"settings"==i)e._currentType="settings.";else if("test"==i)e._currentType="test.";else{if("testNot"!=i){console.log("Action on self");let n={name:e._currentType.replace("action.","")+i};e._commands.push(n);const r=(...e)=>(n.args=e,console.log("Added args",e,"to",n),t);return e._currentType="action.",r}e._currentType="testNot."}return t}});return t}});const a=[];s.a.ArgumentCallback=e=>a.push(e);const l=async function(e){for(let t=0;tn instanceof Function&&n.call(null,e[t])),e[t]instanceof f&&"Var"==e[t].type&&0==e[t]._promises.length)e[t]._runPromises instanceof Function&&await e[t]._runPromises(),e[t]=e[t].value;else if(e[t]instanceof o){let n=new f(this,m[this.type]),i=n._proxy;const r=e[t]._commands;for(let e=0;e{let r=s.a.controllers.running;s.a.debug.currentPromise=i;await l.call(n,t),e.apply(n,[(...e)=>s.a.controllers.running!=r||i(...e)].concat(t))})}},h=function(e){let t=[],n=()=>new Promise(e=>e()),r=()=>new Promise(e=>e()),o=function(...i){let o=this;return new Promise((async function(a){let u=s.a.controllers.running;s.a.debug.currentPromise=a;let h=(...e)=>s.a.controllers.running!=u||a(...e);await l.call(o,i);let c=e.apply(o,i),d="and";for(let e=0;e{t.push("and"),t.push(e)},o.or=e=>{t.push("or"),t.push(e)},o.success=function(...e){n=Object(i.d)(e.map(e=>async()=>{const t=await l.call(this,[e]);t[0]&&t[0]._runPromises instanceof Function&&await t[0]._runPromises()}))},o.failure=function(...e){r=Object(i.d)(e.map(e=>async()=>{const t=await l.call(this,[e]);t[0]&&t[0]._runPromises instanceof Function&&await t[0]._runPromises()}))},o};class c{constructor(e,t,n){let i=$(""),r=i.css,o=[];i.css=(...e)=>{o.push(e),r.apply(i,e)};let a=!1;Object.defineProperty(this,"jQueryElement",{set:function(t){if(!(t instanceof jQuery))return s.a.debug.error("Tried to assign a non jQuery element to PennElement named "+e);if(a)return i=t;let n=i.data("events");n&&$.each(n,(function(){$.each(this,(function(){t.bind(this.type,this.handler)}))}));for(let e in o)t.css(...o[e]);i=t,a=!0},get:function(){return i}}),this.jQueryContainer=$("
      "),this.id=e,this.type=t,this.validate=()=>this.hasValidated=!0,this._printCallback=[],n.hasOwnProperty("end")&&(this.end=async function(){await n.end.apply(this)})}}s.a.PennElement=c;let d=(e,t,n,r)=>{let o="",a=e.replace(/^\.(settings|testNot|test)\./,"");Object(i.e)(a,"settings")/"settings".length<.5&&(o=" Did you mean to type ‘settings’?"),Object(i.e)(a,"test")/"test".length<.5&&(o=" Did you mean to type ‘test’?"),Object(i.e)(a,"testNot")/"testNot".length<.5&&(o=" Did you mean to type ‘testNot’?");let l={score:1,command:""};for(let e=0;e"+e.replace(a,l.command)+"?"),s.a.debug.error("Command ‘"+e+"’ unknown on "+t+" element ‘"+n+"’."+o)};class f{constructor(e,t){let n=new Proxy(this,{get:(e,i)=>{if(i in this)return e[i];{if("_runPromises"==i)return()=>this._runPromises.call(this);let e;try{e=this[i]}catch(e){return d(i,this.type,this._element.id,Object.getOwnPropertyNames(t.actions)),n}return void 0===e&&"string"==typeof i&&"nodeType"!=i&&d(i,this.type,this._element.id,Object.getOwnPropertyNames(t.actions)),e}}});if(this._proxy=n,e instanceof c)n._element=e;else if("string"==typeof e){let i;i=s.a.controllers.running?s.a.controllers.list[s.a.controllers.running.id]:s.a.controllers.underConstruction,Object.defineProperty(n,"_element",{get:()=>i._getElement(e,t.name)})}n.type=t.name,n._promises=[];for(let e in t.actions)n[e]=function(...r){let o=u((function(...r){s.a.debug.on&&s.a.debug.log("
      "+n._element.id+" ("+t.name+") Action command '"+e+"' running, params: "+JSON.stringify(Object(i.i)(r))+"
      "),t.actions[e].apply(this,r)}));return n._promises.push(()=>o.apply(n._element,r)),n};n.settings=new Proxy({},{get:(e,n)=>{if(n in e)return e[n];d(".settings."+n,this.type,this._element.id,Object.getOwnPropertyNames(t.settings))}});for(let e in t.settings)n.settings[e]=function(...r){let o=u((function(...r){s.a.debug.on&&s.a.debug.log("
      "+n._element.id+" ("+t.name+") Settings command '"+e+"' running, params: "+JSON.stringify(Object(i.i)(r))+"
      "),t.settings[e].apply(this,r)}));return n._promises.push(()=>o.apply(n._element,r)),n};n.test=new Proxy({},{get:(e,n)=>{if(n in e)return e[n];d(".test."+n,this.type,this._element.id,Object.getOwnPropertyNames(t.test))}}),n.testNot=new Proxy({},{get:(e,n)=>{if(n in e)return e[n];d(".testNot."+n,this.type,this._element.id,Object.getOwnPropertyNames(t.test))}});for(let e in t.test)n.test[e]=function(...r){let o=h((function(...r){return s.a.debug.on&&s.a.debug.log("
      "+n._element.id+" ("+t.name+") Test command '"+e+"' running, params: "+JSON.stringify(Object(i.i)(r))+"
      "),t.test[e].apply(this,r)}));return n._promises.push(()=>o.apply(n._element,r)),n.success=(...e)=>(o.success.apply(n._element,e),n),n.failure=(...e)=>(o.failure.apply(n._element,e),n),n.and=e=>(o.and.call(n._element,e),n),n.or=e=>(o.or.call(n._element,e),n),n},n.testNot[e]=function(...r){let o=h((function(...n){return s.a.debug.on&&s.a.debug.log(t.name+" testNot command "+e+" running, params: "+JSON.stringify(Object(i.i)(n))),!t.test[e].apply(this,n)}));return n._promises.push(()=>o.apply(n._element,r)),n.success=(...e)=>(o.success.apply(n._element,e),n),n.failure=(...e)=>(o.failure.apply(n._element,e),n),n.and=e=>(o.and.call(n._element,e),n),n.or=e=>(o.or.call(n._element,e),n),n};t.value&&Object.defineProperty(n,"value",{get:()=>t.value.apply(n._element)})}_runPromises(){return Object(i.d)(this._promises)()}}s.a.PennElementCommands=f;let p={actions:{scaling:function(e,t,n){let i=this.jQueryElement,r=0,o=0,a=0,l=0;const u=s.a.controllers.running,h=(e,t)=>{let n=0;if(!isNaN(Number(e)))return Number(e);if(e.match(/(\d+(.\d+)?)px/))n=Number(e.replace(/^[^\d]*(\d+(.\d+)?)px.*$/,"$1"));else{const t=$("
      ").css("width",e);n=t.appendTo(i.parent()).width(),t.remove()}return n/t},c=()=>{if(u!=s.a.controllers.running)return;this.jQueryContainer&&this.jQueryContainer instanceof jQuery&&this.jQueryContainer.parent().length&&(i=this.jQueryContainer);const e=i.width(),d=i.height(),f=$(window).width(),p=$(window).height();window.requestAnimationFrame(c),r=e,o=d,a=f,l=p;let m="";if(t.match(/page|screen/i)){m=a/lthis.jQueryElement.css(...e)),this.jQueryElement.addClass("PennController-"+this.type.replace(/[\s_]/g,"")),this.jQueryElement.addClass("PennController-"+this.id.replace(/[\s_]/g,""));let e=this.jQueryContainer;if(e.css("display","inherit"),"string"==typeof this.jQueryAlignment&&(this.jQueryAlignment.match(/left/i)?e.css("align-self","start"):this.jQueryAlignment.match(/center/i)?e.css("align-self","center"):this.jQueryAlignment.match(/right/i)&&e.css("align-self","end")),e.addClass("PennController-elementContainer").addClass("PennController-"+this.type.replace(/[\s_]+/g,"")+"-container").addClass("PennController-"+this.id.replace(/[\s_]+/g,"")+"-container").append(this.jQueryElement),t instanceof jQuery)t.append(e);else if(t instanceof f&&t._element.jQueryElement instanceof jQuery)t._element.jQueryElement.append(e);else if(void 0!==n){const r=s.a.controllers.running;i.j.call(e,t,n,$("body"),()=>r!=s.a.controllers.running||this._lastPrint!=a)}else s.a.controllers.running.element.append(e);this.cssContainer instanceof Array&&this.cssContainer.forEach(t=>e.css(...t));let r=$("
      ").css("display","inline-block").addClass("PennController-before"),o=$("
      ").css("display","inline-block").addClass("PennController-after");this.jQueryElement.before(r),this.jQueryElement.after(o);for(let e in this.jQueryBefore)this.jQueryBefore[e]&&this.jQueryBefore[e]._element&&await new Promise(t=>p.actions.print.call(this.jQueryBefore[e]._element,t,r));for(let e in this.jQueryAfter)this.jQueryAfter[e]&&this.jQueryAfter[e]._element&&await new Promise(t=>p.actions.print.call(this.jQueryAfter[e]._element,t,o))}else s.a.debug.warning("No jQuery instance to print for element "+this.id);this.printTime=Date.now();for(let e=0;e");t.before(n),r.b.Elements["get"+this.type](this.id).print(n)._runPromises().then(()=>{n.before(this.jQueryElement.parent()),n.remove(),e()})},remove:function(e){if(this.jQueryContainer instanceof jQuery&&this.jQueryContainer.detach(),this.jQueryElement instanceof jQuery?this.jQueryElement.detach():s.a.debug.error("No jQuery instance to remove for element "+this.id),this.jQueryBefore&&this.jQueryBefore.length)for(let e in this.jQueryBefore)this.jQueryBefore[e]._element&&this.jQueryBefore[e]._element.jQueryElement instanceof jQuery&&this.jQueryBefore[e]._element.jQueryElement.detach();if(this.jQueryAfter&&this.jQueryAfter.length)for(let e in this.jQueryAfter)this.jQueryAfter[e]._element&&this.jQueryAfter[e]._element.jQueryElement instanceof jQuery&&this.jQueryAfter[e]._element.jQueryElement.detach();e()},wait:function(e,t){if("first"==t&&this.hasValidated)e();else{let n=!1,i=this.validate;if(this.validate=()=>{if(i.apply(this),!n)if(t instanceof Object&&t._runPromises&&t.success){let i=this.disabled;this.jQueryElement.attr("disabled",!0),this.disabled="tmp",t._runPromises().then(t=>{"success"==t&&(n=!0,e()),"tmp"==this.disabled&&(this.disabled=i,this.jQueryElement.attr("disabled",i))})}else n=!0,e()},"number"==typeof t&&t>0){let e=Date.now(),t=()=>{Date.now()-e<=0?this.validate():window.requestAnimationFrame(t)};window.requestAnimationFrame(t)}}}},settings:{after:function(e,t){t._element&&t._element.jQueryElement instanceof jQuery?(t._element.jQueryAfter instanceof Array&&(t._element.jQueryAfter=t._element.jQueryAfter.filter(e=>e._element!=this)),this.jQueryElement instanceof jQuery&&this.jQueryElement.printed()&&(t=t.print(this.jQueryContainer.find(".PennController-after"))),t._runPromises().then(()=>{this.jQueryAfter.push(t),e()})):(s.a.debug.error("Tried to add an invalid element after element named "+this.id),e())},before:function(e,t){t._element&&t._element.jQueryElement instanceof jQuery?(t._element.jQueryBefore instanceof Array&&(t._element.jQueryBefore=t._element.jQueryBefore.filter(e=>e._element!=this)),this.jQueryElement instanceof jQuery&&this.jQueryElement.printed()&&t.print(this.jQueryContainer.find(".PennController-"+this.type+"-before")),t._runPromises().then(()=>{this.jQueryBefore.push(t),e()})):(s.a.debug.error("Tried to add an invalid element before element named "+this.id),e())},bold:function(e){this.jQueryElement instanceof jQuery?this.jQueryElement.css("font-weight","bold"):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as bold"),e()},center:function(e){this.jQueryElement instanceof jQuery?(this.jQueryAlignment="center",this.jQueryElement.parent().length&&this.jQueryContainer.css("align-self","center")):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as centered"),e()},color:function(e,t){this.jQueryElement&&"string"==typeof t?this.jQueryElement.css("color",t):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as "+t),e()},cssContainer:function(e,...t){this.cssContainer||(this.cssContainer=[]),this.cssContainer.push(t),this.jQueryContainer.printed()&&this.jQueryContainer.css(...t),e()},css:function(e,...t){this.cssToApply||(this.cssToApply=[]),this.cssToApply.push(t),this.jQueryElement instanceof jQuery?this.jQueryElement.css(...t):s.a.debug.error("Element named "+this.id+" has not jQuery element on which to apply the CSS"),e()},disable:function(e){this.hasOwnProperty("jQueryElement")&&this.jQueryElement instanceof jQuery?this.jQueryElement.attr("disabled",!0).addClass("PennController-disabled"):s.a.debug.error("No jQuery instance to disable for element "+this.id),e()},enable:function(e){this.hasOwnProperty("jQueryElement")&&this.jQueryElement instanceof jQuery?this.jQueryElement.removeAttr("disabled").removeClass("PennController-disabled"):s.a.debug.error("No jQuery instance to enable for element "+this.id),e()},hidden:function(e){this.hasOwnProperty("jQueryElement")&&this.jQueryElement instanceof jQuery?this.jQueryElement.css({visibility:"hidden"}):s.a.debug.error("No jQuery instance to hide for element "+this.id),e()},italic:function(e){this.jQueryElement instanceof jQuery?this.jQueryElement.css("font-style","italic"):s.a.debug.error("Element named "+this.id+" has not jQuery element to render in italic"),e()},left:function(e){this.jQueryElement instanceof jQuery?(this.jQueryAlignment="left",this.jQueryElement.parent().length&&this.jQueryContainer.css("align-self","left")):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as aligned to the left"),e()},log:function(e,t){this.log=void 0===t||t,e()},once:function(e){if(this.hasValidated)this.disabled=!0,this.jQueryElement.attr("disabled",!0);else{let e=this.validate;this.validate=()=>{e.apply(this),this.disabled=!0,this.jQueryElement.attr("disabled",!0)}}e()},right:function(e){this.jQueryElement instanceof jQuery?(this.jQueryAlignment="right",this.jQueryElement.parent().length&&this.jQueryContainer.css("align-self","right")):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as aligned to the right"),e()},size:function(e,t,n){this.jQueryElement instanceof jQuery?(this.jQueryElement.width(t),this.jQueryElement.height(n),this.jQueryContainer instanceof jQuery&&("string"==typeof t&&t.match(/%$/)&&this.jQueryContainer.width("100%"),"string"==typeof n&&n.match(/%$/)&&this.jQueryContainer.height("100%"))):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as aligned to the right"),e()},visible:function(e){this.hasOwnProperty("jQueryElement")&&this.jQueryElement instanceof jQuery?this.jQueryElement.css({visibility:"visible"}):s.a.debug.error("No jQuery instance to make visible for element "+this.id),e()}},test:{printed:function(){return!!(this.hasOwnProperty("jQueryElement")&&this.jQueryElement instanceof jQuery)&&this.jQueryElement.printed()}}};s.a.elements.standardCommands=p,r.b.Elements.jump=function(e){var t;"string"==typeof e&&(t=e,e=e=>e==t);let n=-1;const r=e=>s.a.runningOrder&&e()||setTimeout(()=>r(e),50);new Promise(e=>r(e)).then(()=>{console.log("ro",s.a.runningOrder);for(let t=0;tnew Promise(e=>{if(n<0)return e();s.a.runningOrder.active.splice(s.a.runningOrder.runningIndex+1,s.a.runningOrder.active.length,...s.a.runningOrder.original.slice(n,s.a.runningOrder.original.length)),e()});return{_promises:[o],_runPromises:()=>Object(i.d)([o])()}},r.b.Elements.fullscreen=function(){const e=()=>new Promise(e=>{if(document.documentElement.requestFullscreen)return document.documentElement.requestFullscreen().then(e).catch(e);document.documentElement.mozRequestFullScreen?document.documentElement.mozRequestFullScreen():document.documentElement.webkitRequestFullscreen?document.documentElement.webkitRequestFullscreen():document.documentElement.msRequestFullscreen&&document.documentElement.msRequestFullscreen(),e()});return{_promises:[e],_runPromises:()=>Object(i.d)([e])()}},r.b.Elements.exitFullscreen=function(){const e=()=>new Promise(e=>{if(document.exitFullscreen)return document.exitFullscreen().then(e).catch(e);document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen(),e()});return{_promises:[e],_runPromises:()=>Object(i.d)([e])()}},r.b.Elements.clear=function(){const e=()=>new Promise(async e=>{let t=s.a.controllers.list[s.a.controllers.running.id];for(let e in t.elements)for(let n in t.elements[e]){let i=t.elements[e][n],s=r.b.Elements["get"+i.type](i.id);await s.remove()._runPromises()}e()});return{_promises:[e],_runPromises:()=>Object(i.d)([e])()}},r.b.Elements.end=function(){const e=()=>new Promise(async e=>{await s.a.controllers.running.endTrial(),e()});return{_promises:[e],_runPromises:()=>Object(i.d)([e])()}};let m={};r.b._AddElementType=function(e,t){m.hasOwnProperty(e)&&s.a.debug.error("Element type "+e+" defined more than once"),m[e]=function(t){let n=new t(s.a);n.hasOwnProperty("actions")||(n.actions={}),n.hasOwnProperty("settings")||(n.settings={}),n.hasOwnProperty("test")||(n.test={});for(let e in p.actions)n.actions.hasOwnProperty(e)||(n.actions[e]=p.actions[e]);for(let e in p.settings)n.settings.hasOwnProperty(e)||(n.settings[e]=p.settings[e]);for(let e in p.test)n.test.hasOwnProperty(e)||(n.test[e]=p.test[e]);for(let e in n.settings)n.actions.hasOwnProperty(e)||(n.actions[e]=n.settings[e]);let i=n.uponCreation;n.uponCreation=function(e){this.jQueryAfter=[],this.jQueryBefore=[],this.jQueryElement&&this.jQueryElement instanceof jQuery&&this.jQueryElement.removeAttr("style"),this.jQuerycontainer&&this.jQueryContainer instanceof jQuery&&(this.jQuerycontainer=$("
      ")),i instanceof Function?i.apply(this,[e]):e()};let r=n.end;return n.end=async function(){this.jQueryElement instanceof jQuery&&this.jQueryElement.remove();for(let e in this.jQueryBefore)this.jQueryBefore[e]._element&&this.jQueryBefore[e]._element.jQueryElement instanceof jQuery&&this.jQueryBefore[e]._element.jQueryElement.remove();for(let e in this.jQueryAfter)this.jQueryAfter[e]._element&&this.jQueryAfter[e]._element.jQueryElement instanceof jQuery&&this.jQueryAfter[e]._element.jQueryElement.remove();this.jQueryContainer instanceof jQuery&&this.jQueryContainer.remove(),r instanceof Function&&await r.apply(this)},n.name=e,n}(t),r.b.Elements["new"+e]=function(...t){let n=m[e],i=s.a.controllers.underConstruction;s.a.controllers.running&&(i=s.a.controllers.list[s.a.controllers.running.id]);let r="unnamed-"+e;t.length<1?t=[r]:"string"==typeof t[0]&&t[0].length>0&&(r=t[0]);let o=new c(r,e,n);l.call(o,t),n.hasOwnProperty("immediate")&&n.immediate instanceof Function&&n.immediate.apply(o,t);let a=o.id;for(let t=2;i.elements.hasOwnProperty(e)&&i.elements[e].hasOwnProperty(o.id);t++)o.id=a+String(t);a!=o.id&&(s.a.debug.warning("Found an existing "+o.type+" element named “"+a+"”--using name “"+o.id+"” instead for new element"),i.ambiguousElementNames.push(a)),i._addElement(o);let u=new f(o,n);if(u=u._proxy,u._promises.push(()=>new Promise(e=>{o.printTime=0,o.log=!1,e()})),u._promises.push(()=>new Promise(e=>n.uponCreation.apply(o,[e]))),i.defaultCommands.hasOwnProperty(e))for(let t in i.defaultCommands[e]){let n=i.defaultCommands[e][t];u._promises.push(()=>new Promise(e=>{"header"==n[2]&&0==s.a.controllers.running.options.runHeader?e():n[0].apply(o,[e,...n[1]])}))}return u},r.b.Elements["get"+e]=function(t){let n=s.a.controllers.underConstruction;s.a.controllers.running&&(n=s.a.controllers.list[s.a.controllers.running.id]);let i=m[e];return n.ambiguousElementNames.indexOf(t)>=0&&s.a.debug.error("Ambiguous use of get"+e+"(“"+t+"”): more than one elements were created with that name-- get"+e+"(“"+t+"”) will refer to the first one"),new f(t,i)._proxy},Object.defineProperty(r.b.Elements,"default"+e,{get:function(){let t=m[e],n={},i=function(){s.a.controllers.underConstruction.hasOwnProperty("defaultCommands")||(s.a.controllers.underConstruction.defaultCommands={}),s.a.controllers.underConstruction.defaultCommands.hasOwnProperty(e)||(s.a.controllers.underConstruction.defaultCommands[e]=[])};for(let r in t.actions)n[r]=function(...o){return i(),s.a.controllers.underConstruction.defaultCommands[e].push([t.actions[r],o]),n};n.settings={};for(let r in t.settings)n.settings[r]=function(...o){return i(),s.a.controllers.underConstruction.defaultCommands[e].push([t.settings[r],o]),n};return n}})},r.b._AddStandardCommands=function(e){let t=new e(s.a);for(let e in t)if(e.match(/^(actions|settings|test)$/))for(let n in t[e]){let i=t[e][n];if(p[e].hasOwnProperty(n))s.a.debug.error("There already is a standard "+e+" command named "+n);else if(i instanceof Function){p[e][n]=i;for(let t in m)m[t][e].hasOwnProperty(n)||(m[t][e][n]=i),"settings"!=e||m[t].actions.hasOwnProperty(n)||(m[t].actions[n]=i)}else s.a.debug.error("Standard "+e+" command "+n+" should be a function")}else s.a.debug.error("Standard command type unknown",e)}},function(e,t,n){"use strict";var i=n(4),r=n(1),s=n(2),o=n(0),a=n(5),l=n(9);let u=[];o.a.utils.JSZip=l,o.a.utils.JSZip.getBinaryContent=i.getBinaryContent,o.a.utils.saveAs=a.saveAs,s.b.PreloadZip=function(){for(let e in arguments)u.push(arguments[e])},o.a.Prerun((function(){if(u.length){var e=function(e){function t(){let t=u.indexOf(e);t>=0&&u.splice(t,1)}var n=new l;Object(i.getBinaryContent)(e,(function(i,s){if(i)throw t(),o.a.debug.error("Error downloading "+e+":",i),i;n.loadAsync(s).then((function(){o.a.debug.log("Download of "+e+" complete");var i=0;n.forEach((function(e,s){s.async("arraybuffer").then((function(s){if(!e.match(/__MACOS.+\/\.[^\/]+$/)){let t=e.replace(/^.*?([^\/]+)$/,"$1"),n=Object(r.a)(Object(r.c)(s.slice(0,28)),t);if(n){let e=URL.createObjectURL(new Blob([s],{type:n}));console.log("Found a resource named",t,"of type",n,"with url",e);var a=!1;for(let n in o.a.resources.list){let i=o.a.resources.list[n];i.name==t&&"ready"!=i.status&&(console.log("Applying create to a copye of",t),i.create.apply($.extend({},i,{value:e,object:null,resolve:function(){console.log("Resolving",t,"current status",i.status),"ready"!=i.status&&(i.object=this.object,console.log("Set",t," object to",i.object,"calling resolve now"),i.resolve())}})),a=!0)}a||o.a.resources.list.push({name:t,value:e,controllers:[],object:null,status:"void",create:function(){this.status="pending"},resolve:function(){this.status="ready"}})}}++i>=Object.keys(n.files).length&&t()}))}))}))}))};for(let t in u){let n=u[t],i=n.match(/^https?:\/\/.+\.(zip)$/i);"string"==typeof n&&i?"zip"==i[1].toLowerCase()&&e(n):o.a.debug.warning("Preload: entry #"+t+" is not a valid URL, ignoring it")}}}))},function(e,t,n){(function(t,n,i){e.exports=function e(t,n,i){function r(o,a){if(!n[o]){if(!t[o]){if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[o]={exports:{}};t[o][0].call(u.exports,(function(e){return r(t[o][1][e]||e)}),u,u.exports,e,t,n,i)}return n[o].exports}for(var s=!1,o=0;o>2,a=(3&t)<<4|n>>4,l=1>6:64,u=2>4,n=(15&o)<<4|(a=s.indexOf(e.charAt(u++)))>>2,i=(3&a)<<6|(l=s.indexOf(e.charAt(u++))),c[h++]=t,64!==a&&(c[h++]=n),64!==l&&(c[h++]=i);return c}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var i=e("./external"),r=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),o=e("./stream/DataLengthProbe");function a(e,t,n,i,r){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=i,this.compressedContent=r}a.prototype={getContentWorker:function(){var e=new r(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new r(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(e,t,n){return e.pipe(new s).pipe(new o("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var i=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(e){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var i=e("./utils"),r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==i.getTypeOf(e)?function(e,t,n){var i=r,s=0+n;e^=-1;for(var o=0;o>>8^i[255&(e^t[o])];return-1^e}(0|t,e,e.length):function(e,t,n){var i=r,s=0+n;e^=-1;for(var o=0;o>>8^i[255&(e^t.charCodeAt(o))];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var i;i="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:i}},{lie:37}],7:[function(e,t,n){"use strict";var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,r=e("pako"),s=e("./utils"),o=e("./stream/GenericWorker"),a=i?"uint8array":"array";function l(e,t){o.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",s.inherits(l,o),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(a,e.data),!1)},l.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function i(e,t){var n,i="";for(n=0;n>>=8;return i}function r(e,t,n,r,o,h){var c,d,f=e.file,p=e.compression,m=h!==a.utf8encode,g=s.transformTo("string",h(f.name)),y=s.transformTo("string",a.utf8encode(f.name)),b=f.comment,w=s.transformTo("string",h(b)),v=s.transformTo("string",a.utf8encode(b)),_=y.length!==f.name.length,E=v.length!==b.length,k="",C="",A="",P=f.dir,x=f.date,j={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(j.crc32=e.crc32,j.compressedSize=e.compressedSize,j.uncompressedSize=e.uncompressedSize);var T=0;t&&(T|=8),m||!_&&!E||(T|=2048);var S,O=0,Q=0;P&&(O|=16),"UNIX"===o?(Q=798,O|=((S=f.unixPermissions)||(S=P?16893:33204),(65535&S)<<16)):(Q=20,O|=63&(f.dosPermissions||0)),c=x.getUTCHours(),c<<=6,c|=x.getUTCMinutes(),c<<=5,c|=x.getUTCSeconds()/2,d=x.getUTCFullYear()-1980,d<<=4,d|=x.getUTCMonth()+1,d<<=5,d|=x.getUTCDate(),_&&(k+="up"+i((C=i(1,1)+i(l(g),4)+y).length,2)+C),E&&(k+="uc"+i((A=i(1,1)+i(l(w),4)+v).length,2)+A);var N="";return N+="\n\0",N+=i(T,2),N+=p.magic,N+=i(c,2),N+=i(d,2),N+=i(j.crc32,4),N+=i(j.compressedSize,4),N+=i(j.uncompressedSize,4),N+=i(g.length,2),N+=i(k.length,2),{fileRecord:u.LOCAL_FILE_HEADER+N+g+k,dirRecord:u.CENTRAL_FILE_HEADER+i(Q,2)+N+i(w.length,2)+"\0\0\0\0"+i(O,4)+i(r,4)+g+k+w}}var s=e("../utils"),o=e("../stream/GenericWorker"),a=e("../utf8"),l=e("../crc32"),u=e("../signature");function h(e,t,n,i){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=i,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(h,o),h.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-i-1))/n:100}}))},h.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=r(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(e){this.accumulate=!1;var t,n=this.streamFiles&&!e.file.dir,s=r(e,n,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(s.dirRecord),n)this.push({data:(t=e,u.DATA_DESCRIPTOR+i(t.crc32,4)+i(t.compressedSize,4)+i(t.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:s.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return i.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readAndCheckSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=r},{"../utils":32}],19:[function(e,t,n){"use strict";var i=e("./Uint8ArrayReader");function r(e){i.call(this,e)}e("../utils").inherits(r,i),r.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){"use strict";var i=e("./DataReader");function r(e){i.call(this,e)}e("../utils").inherits(r,i),r.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},r.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},r.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},r.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){"use strict";var i=e("./ArrayReader");function r(e){i.call(this,e)}e("../utils").inherits(r,i),r.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){"use strict";var i=e("../utils"),r=e("../support"),s=e("./ArrayReader"),o=e("./StringReader"),a=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=i.getTypeOf(e);return i.checkSupport(t),"string"!==t||r.uint8array?"nodebuffer"===t?new a(e):r.uint8array?new l(i.transformTo("uint8array",e)):new s(i.transformTo("array",e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){"use strict";n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){"use strict";var i=e("./GenericWorker"),r=e("../utils");function s(e){i.call(this,"ConvertWorker to "+e),this.destType=e}r.inherits(s,i),s.prototype.processChunk=function(e){this.push({data:r.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){"use strict";var i=e("./GenericWorker"),r=e("../crc32");function s(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,i),s.prototype.processChunk=function(e){this.streamInfo.crc32=r(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){"use strict";var i=e("../utils"),r=e("./GenericWorker");function s(e){r.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}i.inherits(s,r),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}r.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){"use strict";var i=e("../utils"),r=e("./GenericWorker");function s(e){r.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=i.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}i.inherits(s,r),s.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){"use strict";function i(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n "+e:e}},t.exports=i},{}],29:[function(e,t,i){"use strict";var r=e("../utils"),s=e("./ConvertWorker"),o=e("./GenericWorker"),a=e("../base64"),l=e("../support"),u=e("../external"),h=null;if(l.nodestream)try{h=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function c(e,t,n){var i=t;switch(t){case"blob":case"arraybuffer":i="uint8array";break;case"base64":i="string"}try{this._internalType=i,this._outputType=t,this._mimeType=n,r.checkSupport(i),this._worker=e.pipe(new s(i)),e.lock()}catch(e){this._worker=new o("error"),this._worker.error(e)}}c.prototype={accumulate:function(e){return t=this,i=e,new u.Promise((function(e,s){var o=[],l=t._internalType,u=t._outputType,h=t._mimeType;t.on("data",(function(e,t){o.push(e),i&&i(t)})).on("error",(function(e){o=[],s(e)})).on("end",(function(){try{var t=function(e,t,n){switch(e){case"blob":return r.newBlob(r.transformTo("arraybuffer",t),n);case"base64":return a.encode(t);default:return r.transformTo(e,t)}}(u,function(e,t){var i,r=0,s=null,o=0;for(i=0;i>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t}(e)},n.utf8decode=function(e){return r.nodebuffer?i.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,r,s,o=e.length,l=new Array(2*o);for(t=n=0;t>10&1023,l[n++]=56320|1023&r)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),i.applyFromCharCode(l)}(e=i.transformTo(r.uint8array?"uint8array":"array",e))},i.inherits(u,o),u.prototype.processChunk=function(e){var t=i.transformTo(r.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var s=t;(t=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),t.set(s,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}(t),l=t;o!==t.length&&(r.uint8array?(l=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(l=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=u,i.inherits(h,o),h.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){"use strict";var i=e("./support"),r=e("./base64"),s=e("./nodejsUtils"),o=e("set-immediate-shim"),a=e("./external");function l(e){return e}function u(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(e){if(this.extraFields[1]){var t=i(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(e){var t,n,i,r=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new i.Buf8(e.length),n=0,r=t.length;n>10&1023,u[i++]=56320|1023&r)}return l(u,i)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+o[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){"use strict";t.exports=function(e,t,n,i){for(var r=65535&e|0,s=e>>>16&65535|0,o=0;0!==n;){for(n-=o=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,r){var s=i,o=r+n;e^=-1;for(var a=r;a>>8^s[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,n){"use strict";var i,r=e("../utils/common"),s=e("./trees"),o=e("./adler32"),a=e("./crc32"),l=e("./messages"),u=-2,h=258,c=262,d=113;function f(e,t){return e.msg=l[t],t}function p(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),0!==n&&(r.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function y(e,t){s._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,g(e.strm)}function b(e,t){e.pending_buf[e.pending++]=t}function w(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function v(e,t){var n,i,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-c?e.strstart-(e.w_size-c):0,u=e.window,d=e.w_mask,f=e.prev,p=e.strstart+h,m=u[s+o-1],g=u[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(n=t)+o]===g&&u[n+o-1]===m&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do{}while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&sl&&0!=--r);return o<=e.lookahead?o:e.lookahead}function _(e){var t,n,i,s,l,u,h,d,f,p,m=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-c)){for(r.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=n=e.hash_size;i=e.head[--t],e.head[t]=m<=i?i-m:0,--n;);for(t=n=m;i=e.prev[--t],e.prev[t]=m<=i?i-m:0,--n;);s+=m}if(0===e.strm.avail_in)break;if(u=e.strm,h=e.window,d=e.strstart+e.lookahead,p=void 0,(f=s)<(p=u.avail_in)&&(p=f),n=0===p?0:(u.avail_in-=p,r.arraySet(h,u.input,u.next_in,p,d),1===u.state.wrap?u.adler=o(u.adler,h,p,d):2===u.state.wrap&&(u.adler=a(u.adler,h,p,d)),u.next_in+=p,u.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=3)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(i=s._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3&&e.match_length<=e.prev_length){for(r=e.strstart+e.lookahead-3,i=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=r&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(_(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+n;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,y(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-c&&(y(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(y(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(y(e,!1),e.strm.avail_out),1)})),new C(4,4,8,4,E),new C(4,5,16,8,E),new C(4,6,32,32,E),new C(4,4,16,16,k),new C(8,16,32,32,k),new C(8,16,128,128,k),new C(8,32,128,256,k),new C(32,128,258,1024,k),new C(32,258,258,4096,k)],n.deflateInit=function(e,t){return j(e,t,8,15,8,0)},n.deflateInit2=j,n.deflateReset=x,n.deflateResetKeep=P,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?u:(e.state.gzhead=t,0):u},n.deflate=function(e,t){var n,r,o,l;if(!e||!e.state||5>8&255),b(r,r.gzhead.time>>16&255),b(r,r.gzhead.time>>24&255),b(r,9===r.level?2:2<=r.strategy||r.level<2?4:0),b(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(b(r,255&r.gzhead.extra.length),b(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=a(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(b(r,0),b(r,0),b(r,0),b(r,0),b(r,0),b(r,9===r.level?2:2<=r.strategy||r.level<2?4:0),b(r,3),r.status=d);else{var c=8+(r.w_bits-8<<4)<<8;c|=(2<=r.strategy||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(c|=32),c+=31-c%31,r.status=d,w(r,c),0!==r.strstart&&(w(r,e.adler>>>16),w(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),g(e),o=r.pending,r.pending!==r.pending_buf_size));)b(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),g(e),o=r.pending,r.pending===r.pending_buf_size)){l=1;break}l=r.gzindexo&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===l&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),g(e),o=r.pending,r.pending===r.pending_buf_size)){l=1;break}l=r.gzindexo&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===l&&(r.status=103)}else r.status=103;if(103===r.status&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&g(e),r.pending+2<=r.pending_buf_size&&(b(r,255&e.adler),b(r,e.adler>>8&255),e.adler=0,r.status=d)):r.status=d),0!==r.pending){if(g(e),0===e.avail_out)return r.last_flush=-1,0}else if(0===e.avail_in&&p(t)<=p(n)&&4!==t)return f(e,-5);if(666===r.status&&0!==e.avail_in)return f(e,-5);if(0!==e.avail_in||0!==r.lookahead||0!==t&&666!==r.status){var v=2===r.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(_(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(y(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(y(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(y(e,!1),0===e.strm.avail_out)?1:2}(r,t):3===r.strategy?function(e,t){for(var n,i,r,o,a=e.window;;){if(e.lookahead<=h){if(_(e),e.lookahead<=h&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=s._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(y(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(y(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(y(e,!1),0===e.strm.avail_out)?1:2}(r,t):i[r.level].func(r,t);if(3!==v&&4!==v||(r.status=666),1===v||3===v)return 0===e.avail_out&&(r.last_flush=-1),0;if(2===v&&(1===t?s._tr_align(r):5!==t&&(s._tr_stored_block(r,0,0,!1),3===t&&(m(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),g(e),0===e.avail_out))return r.last_flush=-1,0}return 4!==t?0:r.wrap<=0?1:(2===r.wrap?(b(r,255&e.adler),b(r,e.adler>>8&255),b(r,e.adler>>16&255),b(r,e.adler>>24&255),b(r,255&e.total_in),b(r,e.total_in>>8&255),b(r,e.total_in>>16&255),b(r,e.total_in>>24&255)):(w(r,e.adler>>>16),w(r,65535&e.adler)),g(e),0=n.w_size&&(0===a&&(m(n.head),n.strstart=0,n.block_start=0,n.insert=0),d=new r.Buf8(n.w_size),r.arraySet(d,t,f-n.w_size,n.w_size,0),t=d,f=n.w_size),l=e.avail_in,h=e.next_in,c=e.input,e.avail_in=f,e.next_in=0,e.input=t,_(n);n.lookahead>=3;){for(i=n.strstart,s=n.lookahead-2;n.ins_h=(n.ins_h<>>=v=w>>>24,p-=v,0==(v=w>>>16&255))P[s++]=65535&w;else{if(!(16&v)){if(0==(64&v)){w=m[(65535&w)+(f&(1<>>=v,p-=v),p<15&&(f+=A[i++]<>>=v=w>>>24,p-=v,!(16&(v=w>>>16&255))){if(0==(64&v)){w=g[(65535&w)+(f&(1<>>=v,p-=v,(v=s-o)>3,f&=(1<<(p-=_<<3))-1,e.next_in=i,e.next_out=s,e.avail_in=i>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function c(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new i.Buf32(852),t.distcode=t.distdyn=new i.Buf32(592),t.sane=1,t.back=-1,0):l}function d(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,c(e)):l}function f(e,t){var n,i;return e&&e.state?(i=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=o.wsize?(i.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(r<(s=o.wsize-o.wnext)&&(s=r),i.arraySet(o.window,t,n-r,s,o.wnext),(r-=s)?(i.arraySet(o.window,t,n-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=s(n.check,I,2,0),y=g=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&g)<<8)+(g>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&g)){e.msg="unknown compression method",n.mode=30;break}if(y-=4,O=8+(15&(g>>>=4)),0===n.wbits)n.wbits=O;else if(O>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(I[0]=255&g,I[1]=g>>>8&255,n.check=s(n.check,I,2,0)),y=g=0,n.mode=3;case 3:for(;y<32;){if(0===p)break e;p--,g+=h[d++]<>>8&255,I[2]=g>>>16&255,I[3]=g>>>24&255,n.check=s(n.check,I,4,0)),y=g=0,n.mode=4;case 4:for(;y<16;){if(0===p)break e;p--,g+=h[d++]<>8),512&n.flags&&(I[0]=255&g,I[1]=g>>>8&255,n.check=s(n.check,I,2,0)),y=g=0,n.mode=5;case 5:if(1024&n.flags){for(;y<16;){if(0===p)break e;p--,g+=h[d++]<>>8&255,n.check=s(n.check,I,2,0)),y=g=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p<(E=n.length)&&(E=p),E&&(n.head&&(O=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),i.arraySet(n.head.extra,h,d,E,O)),512&n.flags&&(n.check=s(n.check,h,E,d)),p-=E,d+=E,n.length-=E),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;for(E=0;O=h[d+E++],n.head&&O&&n.length<65536&&(n.head.name+=String.fromCharCode(O)),O&&E>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;y<32;){if(0===p)break e;p--,g+=h[d++]<>>=7&y,y-=7&y,n.mode=27;break}for(;y<3;){if(0===p)break e;p--,g+=h[d++]<>>=1)){case 0:n.mode=14;break;case 1:if(b(n),n.mode=20,6!==t)break;g>>>=2,y-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}g>>>=2,y-=2;break;case 14:for(g>>>=7&y,y-=7&y;y<32;){if(0===p)break e;p--,g+=h[d++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&g,y=g=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(E=n.length){if(p>>=5,y-=5,n.ndist=1+(31&g),g>>>=5,y-=5,n.ncode=4+(15&g),g>>>=4,y-=4,286>>=3,y-=3}for(;n.have<19;)n.lens[L[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,N={bits:n.lenbits},Q=a(0,n.lens,0,19,n.lencode,0,n.work,N),n.lenbits=N.bits,Q){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,x=65535&R,!((A=R>>>24)<=y);){if(0===p)break e;p--,g+=h[d++]<>>=A,y-=A,n.lens[n.have++]=x;else{if(16===x){for(D=A+2;y>>=A,y-=A,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}O=n.lens[n.have-1],E=3+(3&g),g>>>=2,y-=2}else if(17===x){for(D=A+3;y>>=A)),g>>>=3,y-=3}else{for(D=A+7;y>>=A)),g>>>=7,y-=7}if(n.have+E>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;E--;)n.lens[n.have++]=O}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,N={bits:n.lenbits},Q=a(1,n.lens,0,n.nlen,n.lencode,0,n.work,N),n.lenbits=N.bits,Q){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,N={bits:n.distbits},Q=a(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,N),n.distbits=N.bits,Q){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=p&&258<=m){e.next_out=f,e.avail_out=m,e.next_in=d,e.avail_in=p,n.hold=g,n.bits=y,o(e,_),f=e.next_out,c=e.output,m=e.avail_out,d=e.next_in,h=e.input,p=e.avail_in,g=n.hold,y=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;P=(R=n.lencode[g&(1<>>16&255,x=65535&R,!((A=R>>>24)<=y);){if(0===p)break e;p--,g+=h[d++]<>j)])>>>16&255,x=65535&R,!(j+(A=R>>>24)<=y);){if(0===p)break e;p--,g+=h[d++]<>>=j,y-=j,n.back+=j}if(g>>>=A,y-=A,n.back+=A,n.length=x,0===P){n.mode=26;break}if(32&P){n.back=-1,n.mode=12;break}if(64&P){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&P,n.mode=22;case 22:if(n.extra){for(D=n.extra;y>>=n.extra,y-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;P=(R=n.distcode[g&(1<>>16&255,x=65535&R,!((A=R>>>24)<=y);){if(0===p)break e;p--,g+=h[d++]<>j)])>>>16&255,x=65535&R,!(j+(A=R>>>24)<=y);){if(0===p)break e;p--,g+=h[d++]<>>=j,y-=j,n.back+=j}if(g>>>=A,y-=A,n.back+=A,64&P){e.msg="invalid distance code",n.mode=30;break}n.offset=x,n.extra=15&P,n.mode=24;case 24:if(n.extra){for(D=n.extra;y>>=n.extra,y-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===m)break e;if(E=_-m,n.offset>E){if((E=n.offset-E)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}k=E>n.wnext?(E-=n.wnext,n.wsize-E):n.wnext-E,E>n.length&&(E=n.length),C=n.window}else C=c,k=f-n.offset,E=n.length;for(mb?(v=L[F+c[C]],N[D+c[C]]):(v=96,0),f=1<>T)+(p-=f)]=w<<24|v<<16|_|0,0!==p;);for(f=1<>=1;if(0!==f?(Q&=f-1,Q+=f):Q=0,C++,0==--R[k]){if(k===P)break;k=t[n+c[C]]}if(x>>7)]}function E(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function k(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function P(e,t,n){var i,r,o=new Array(16),a=0;for(i=1;i<=s;i++)o[i]=a=a+n[i-1]<<1;for(r=0;r<=t;r++){var l=e[2*r+1];0!==l&&(e[2*r]=A(o[l]++,l))}}function x(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function j(e){8>1;1<=n;n--)S(e,o,n);for(r=u;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],S(e,o,1),i=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=i,o[2*r]=o[2*n]+o[2*i],e.depth[r]=(e.depth[n]>=e.depth[i]?e.depth[n]:e.depth[i])+1,o[2*n+1]=o[2*i+1]=r,e.heap[1]=r++,S(e,o,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,i,r,o,a,l,u=t.dyn_tree,h=t.max_code,c=t.stat_desc.static_tree,d=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,m=t.stat_desc.max_length,g=0;for(o=0;o<=s;o++)e.bl_count[o]=0;for(u[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)m<(o=u[2*u[2*(i=e.heap[n])+1]+1]+1)&&(o=m,g++),u[2*i+1]=o,h>=7;i<30;i++)for(b[i]=r<<7,e=0;e<1<>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),Q(e,e.l_desc),Q(e,e.d_desc),o=function(e){var t;for(N(e,e.dyn_ltree,e.l_desc.max_code),N(e,e.dyn_dtree,e.d_desc.max_code),Q(e,e.bl_desc),t=18;3<=t&&0===e.bl_tree[2*u[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==t?I(e,t,n,i):4===e.strategy||s===r?(k(e,2+(i?1:0),3),O(e,h,c)):(k(e,4+(i?1:0),3),function(e,t,n,i){var r;for(k(e,t-257,5),k(e,n-1,5),k(e,i-4,4),r=0;r>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(f[n]+256+1)]++,e.dyn_dtree[2*_(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){var t;k(e,2,3),C(e,256,h),16===(t=e).bi_valid?(E(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}},{"../utils/common":41}],53:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){"use strict";t.exports="function"==typeof i?i:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}]},{},[10])(10)}))}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}))}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}))}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}))}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}))}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}).call(this,n(3),n(10).Buffer,n(14).setImmediate)},function(e,t,n){"use strict";(function(e){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ var i=n(11),r=n(12),s=n(13);function o(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(l.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(e).length;default:if(i)return U(e).length;t=(""+t).toLowerCase(),i=!0}}function m(e,t,n){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return T(this,t,n);case"utf8":case"utf-8":return P(this,t,n);case"ascii":return x(this,t,n);case"latin1":case"binary":return j(this,t,n);case"base64":return A(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function g(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function y(e,t,n,i,r){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=l.from(t,i)),l.isBuffer(t))return 0===t.length?-1:b(e,t,n,i,r);if("number"==typeof t)return t&=255,l.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):b(e,[t],n,i,r);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,i,r){var s,o=1,a=e.length,l=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,a/=2,l/=2,n/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){var h=-1;for(s=n;sa&&(n=a-l),s=n;s>=0;s--){for(var c=!0,d=0;dr&&(i=r):i=r;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var o=0;o>8,r=n%256,s.push(r),s.push(i);return s}(t,e.length-n),e,n,i)}function A(e,t,n){return 0===t&&n===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,n))}function P(e,t,n){n=Math.min(e.length,n);for(var i=[],r=t;r239?4:u>223?3:u>191?2:1;if(r+c<=n)switch(c){case 1:u<128&&(h=u);break;case 2:128==(192&(s=e[r+1]))&&(l=(31&u)<<6|63&s)>127&&(h=l);break;case 3:s=e[r+1],o=e[r+2],128==(192&s)&&128==(192&o)&&(l=(15&u)<<12|(63&s)<<6|63&o)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:s=e[r+1],o=e[r+2],a=e[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&l<1114112&&(h=l)}null===h?(h=65533,c=1):h>65535&&(h-=65536,i.push(h>>>10&1023|55296),h=56320|1023&h),i.push(h),r+=c}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",i=0;for(;i0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},l.prototype.compare=function(e,t,n,i,r){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),t<0||n>e.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&t>=n)return 0;if(i>=r)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(r>>>=0)-(i>>>=0),o=(n>>>=0)-(t>>>=0),a=Math.min(s,o),u=this.slice(i,r),h=e.slice(t,n),c=0;cr)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return v(this,e,t,n);case"ascii":return _(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return k(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(e,t,n){var i="";n=Math.min(e.length,n);for(var r=t;ri)&&(n=i);for(var r="",s=t;sn)throw new RangeError("Trying to access beyond buffer length")}function Q(e,t,n,i,r,s){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError("Index out of range")}function N(e,t,n,i){t<0&&(t=65535+t+1);for(var r=0,s=Math.min(e.length-n,2);r>>8*(i?r:1-r)}function D(e,t,n,i){t<0&&(t=4294967295+t+1);for(var r=0,s=Math.min(e.length-n,4);r>>8*(i?r:3-r)&255}function R(e,t,n,i,r,s){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function I(e,t,n,i,s){return s||R(e,0,n,4),r.write(e,t,n,i,23,4),n+4}function L(e,t,n,i,s){return s||R(e,0,n,8),r.write(e,t,n,i,52,8),n+8}l.prototype.slice=function(e,t){var n,i=this.length;if((e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t0&&(r*=256);)i+=this[e+--t]*r;return i},l.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},l.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||O(e,t,this.length);for(var i=this[e],r=1,s=0;++s=(r*=128)&&(i-=Math.pow(2,8*t)),i},l.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||O(e,t,this.length);for(var i=t,r=1,s=this[e+--i];i>0&&(r*=256);)s+=this[e+--i]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*t)),s},l.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),r.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),r.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),r.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),r.read(this,e,!1,52,8)},l.prototype.writeUIntLE=function(e,t,n,i){(e=+e,t|=0,n|=0,i)||Q(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,s=0;for(this[t]=255&e;++s=0&&(s*=256);)this[t+r]=e/s&255;return t+n},l.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Q(this,e,t,1,255,0),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Q(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Q(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Q(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Q(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},l.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t|=0,!i){var r=Math.pow(2,8*n-1);Q(this,e,t,n,r-1,-r)}var s=0,o=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+n},l.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t|=0,!i){var r=Math.pow(2,8*n-1);Q(this,e,t,n,r-1,-r)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},l.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Q(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Q(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},l.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Q(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},l.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Q(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},l.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Q(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},l.prototype.writeFloatLE=function(e,t,n){return I(this,e,t,!0,n)},l.prototype.writeFloatBE=function(e,t,n){return I(this,e,t,!1,n)},l.prototype.writeDoubleLE=function(e,t,n){return L(this,e,t,!0,n)},l.prototype.writeDoubleBE=function(e,t,n){return L(this,e,t,!1,n)},l.prototype.copy=function(e,t,n,i){if(n||(n=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t=0;--r)e[r+t]=this[r+n];else if(s<1e3||!l.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&s.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function z(e){return i.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function M(e,t,n,i){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}}).call(this,n(3))},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],i=t[1];return 3*(n+i)/4-i},t.toByteArray=function(e){var t,n,i=u(e),o=i[0],a=i[1],l=new s(function(e,t,n){return 3*(t+n)/4-n}(0,o,a)),h=0,c=a>0?o-4:o;for(n=0;n>16&255,l[h++]=t>>8&255,l[h++]=255&t;2===a&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,l[h++]=255&t);1===a&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,l[h++]=t>>8&255,l[h++]=255&t);return l},t.fromByteArray=function(e){for(var t,n=e.length,r=n%3,s=[],o=0,a=n-r;oa?a:o+16383));1===r?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return s.join("")};for(var i=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,l=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function h(e,t,n){for(var r,s,o=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,i,r){var s,o,a=8*r-i-1,l=(1<>1,h=-7,c=n?r-1:0,d=n?-1:1,f=e[t+c];for(c+=d,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+c],c+=d,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=i;h>0;o=256*o+e[t+c],c+=d,h-=8);if(0===s)s=1-u;else{if(s===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,i),s-=u}return(f?-1:1)*o*Math.pow(2,s-i)},t.write=function(e,t,n,i,r,s){var o,a,l,u=8*s-r-1,h=(1<>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:s-1,p=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+c>=1?d/l:d*Math.pow(2,1-c))*l>=2&&(o++,l/=2),o+c>=h?(a=0,o=h):o+c>=1?(a=(t*l-1)*Math.pow(2,r),o+=c):(a=t*Math.pow(2,c-1)*Math.pow(2,r),o=0));r>=8;e[n+f]=255&a,f+=p,a/=256,r-=8);for(o=o<0;e[n+f]=255&o,f+=p,o/=256,u-=8);e[n+f-p]|=128*m}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){(function(e){var i=void 0!==e&&e||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function s(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new s(r.call(setTimeout,i,arguments),clearTimeout)},t.setInterval=function(){return new s(r.call(setInterval,i,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(i,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(15),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(3))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var i,r,s,o,a,l=1,u={},h=!1,c=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?i=function(e){t.nextTick((function(){p(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((s=new MessageChannel).port1.onmessage=function(e){p(e.data)},i=function(e){s.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(r=c.documentElement,i=function(e){var t=c.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):i=function(e){setTimeout(p,0,e)}:(o="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(o)&&p(+t.data.slice(o.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),i=function(t){e.postMessage(o+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n1)for(var n=1;nr[t]=n[e][i]),t.push(r)}}catch(e){t.push({})}try{let t=$.csv.toArrays(e,{separator:"\t"}),i=t[0];for(let e=1;er[n]=t[e][i]),n.push(r)}}catch(e){n.push({})}return Object.keys(t[0]).length>Object.keys(n[0]).length?t:Object.keys(n[0]).length?n:r.a.debug.error("Format of table is invalid")}let c=[],d=window.$.ajax;window.$.ajax=function(...e){if(e[0]&&e[0].url&&e[0].url.match(/allchunks=1$/)){let t=e[0].success;e[0].success=e=>{if(0==c.length)return t(e);let n,r=[];for(let s=c.length-1;s>=0;s--)n=s==c.length-1?n=>{i.b.AddTable(c[s].name,n),t(e)}:e=>{i.b.AddTable(c[s].name,e),r[0]()},r.push(()=>$.ajax({url:c[s].table,cache:!1,dataType:"text",success:n}));r[0]()}}return d(...e)},i.b.AddTable=function(e,t){if("string"!=typeof e||"string"!=typeof t)return r.a.debug.error("Table "+e+" not added: tables and table names should be strings");if(r.a.tables.hasOwnProperty(e)&&r.a.debug.warning("A table named "+e+" already exists; overriding it"),t.match(/^http/))c.push({name:e,table:t});else{if(!(t=h(t)))return r.a.debug.error("Table "+e+" does not have the right format.");t=new l(t,e),r.a.tables[e]=t}},i.b.GetTable=function(e){return new u(e)};let f,p=[];i.b.Template=function(e,t){if(window.items)for(let e in window.items)r.a.tmpItems.indexOf(window.items[e])<0&&r.a.tmpItems.push(window.items[e]);let n={PennTemplate:[]};return r.a.tmpItems.push(n),p.push((function(){let i,h=r.a.tmpItems.length;if(e instanceof Function){t=e;let n=Object.keys(r.a.tables);if(!(n.length&&r.a.tables[n[0]]instanceof l))return r.a.debug.error("No valid table detected");i=r.a.tables[n[0]]}else if("string"==typeof e){if(!r.a.tables.hasOwnProperty(e)){let t=Object.keys(r.a.tables),n="";for(let i=0;i’?");return r.a.debug.error("No table found with name "+e+"."+n)}if(!(r.a.tables[e]instanceof l))return r.a.debug.error("Table "+e+" does not have the right format.");i=r.a.tables[e]}else{if(!(e instanceof u))return r.a.debug.error("Bad format for Template's first argument (should be a PennController table, table name or function from rows to Ibex elements)");if(Object.keys(r.a.tables).length<1)return r.a.debug.error("No table was defined");if(e.name==o)i=r.a.tables[Object.keys(r.a.tables)[0]];else{if(!e.name||!r.a.tables.hasOwnProperty(e.name)){let t=Object.keys(r.a.tables),n="";for(let i=0;i’?");return r.a.debug.error("No table named "+e.name+" was found."+n)}i=r.a.tables[e.name]}for(let t=0;t{let t=d.filter((t,n)=>t==e.groups[n]);d.indexOf(e.runningGroup)>-1&&t.length==e.groups.length&&t.length==d.length&&(c=e.runningGroup)}),void 0===c){let e=window.__counter_value_from_server__;"number"==typeof window.counterOverride&&(e=counterOverride),c=d[e%d.length]}a.push({runningGroup:c,groups:d})}let f=[];for(let e=0;e{if(n in i.table[e])return t[n];{let t=Object.keys(i.table[e]),o="";for(let e=0;e’?");r.a.debug.error("No column named ‘"+n+"’ found in table "+i.id+"."+o)}return""}});try{n=t.call(null,a)}catch(e){window.onerror(e.name+": "+e.message,"include=data","inside PennController.Template")}n instanceof Array?n.length%2&&"string"==typeof n[0]&&(o=n[0],n.splice(0,1)):(o=n.useLabel,n.addToItems=!1,n=["PennController",n]),o||(o=i.label&&i.table[e].hasOwnProperty(i.label)?i.table[e][i.label]:i.item&&i.table[e].hasOwnProperty(i.item)?"Item-"+i.table[e][i.item]:"Item-"+e);let l=[o];for(let t in n)n[t]instanceof Object&&(n[t]._PennController={table:i,row:e}),l.push(n[t]);f.push(l)}for(n.PennTemplate=f;r.a.tmpItems.length>h;)r.a.tmpItems.pop()})),window.items||(window.items=[]),{log:()=>r.a.debug.error("Tried to call .log command on Template(); .log commands should be called on newTrial()"),label:()=>r.a.debug.error("Tried to call .label command on Template(); .label commands should be called on newTrial()"),setOption:()=>r.a.debug.error("Tried to call .setOption command on Template(); .setOption commands should be called on newTrial()"),noHeader:()=>r.a.debug.error("Tried to call .noHeader command on Template(); .noHeader commands should be called on newTrial()"),noFooter:()=>r.a.debug.error("Tried to call .noFooter command on Template(); .noFooter commands should be called on newTrial()"),noTrialLog:()=>r.a.debug.error("Tried to call .noTrialLog command on Template(); .noTrialLog commands should be called on newTrial()")}},i.b.FeedItems=(e,t)=>i.b.Template(e,t),$(document).ready((function(){f=document.createElement("P"),f.style["text-align"]="center",f.innerHTML="Loading, please wait...",f.id="FirstLoadingMessage",document.body.appendChild(f)})),r.a.Prerun(()=>{for(let e in window.CHUNKS_DICT){if(e.match(/\.(html?|mp3)$/i))continue;let t=h(window.CHUNKS_DICT[e]);t?(t=new l(t,e),r.a.tables[e]=t):(t=$.csv.toObjects(window.CHUNKS_DICT[e],{separator:"\t"}),Object.keys(t[0]).length>1&&(t=new l(t,e),r.a.tables[e]=t))}for(let e=0;e=t.end&&(l=!0),t.state.rowNum++,t.state.colNum=1}function h(){if(void 0===t.onParseValue)s.push(a);else{var e=t.onParseValue(a,t.state);!1!==e&&s.push(e)}a="",o=0,t.state.colNum++}var c=RegExp.escape(n),d=RegExp.escape(i),f=/(D|S|\r\n|\n|\r|[^DS\r\n]+)/,p=f.source;return p=(p=p.replace(/S/g,c)).replace(/D/g,d),f=new RegExp(p,"gm"),e.replace(f,(function(e){if(!l)switch(o){case 0:if(e===n){a+="",h();break}if(e===i){o=1;break}if(/^(\r\n|\n|\r)$/.test(e)){h(),u();break}a+=e,o=3;break;case 1:if(e===i){o=2;break}a+=e,o=1;break;case 2:if(e===i){a+=e,o=1;break}if(e===n){h();break}if(/^(\r\n|\n|\r)$/.test(e)){h(),u();break}throw new Error("CSVDataError: Illegal State [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");case 3:if(e===n){h();break}if(/^(\r\n|\n|\r)$/.test(e)){h(),u();break}if(e===i)throw new Error("CSVDataError: Illegal Quote [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");throw new Error("CSVDataError: Illegal Data [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");default:throw new Error("CSVDataError: Unknown State [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]")}})),0!==s.length&&(h(),u()),r},splitLines:function(e,n){if(e){var i=(n=n||{}).separator||t.csv.defaults.separator,r=n.delimiter||t.csv.defaults.delimiter;n.state=n.state||{},n.state.rowNum||(n.state.rowNum=1);var s=[],o=0,a="",l=!1,u=RegExp.escape(i),h=RegExp.escape(r),c=/(D|S|\n|\r|[^DS\r\n]+)/,d=c.source;return d=(d=d.replace(/S/g,u)).replace(/D/g,h),c=new RegExp(d,"gm"),e.replace(c,(function(e){if(!l)switch(o){case 0:if(e===i){a+=e,o=0;break}if(e===r){a+=e,o=1;break}if("\n"===e){f();break}if(/^\r$/.test(e))break;a+=e,o=3;break;case 1:if(e===r){a+=e,o=2;break}a+=e,o=1;break;case 2:var t=a.substr(a.length-1);if(e===r&&t===r){a+=e,o=1;break}if(e===i){a+=e,o=0;break}if("\n"===e){f();break}if("\r"===e)break;throw new Error("CSVDataError: Illegal state [Row:"+n.state.rowNum+"]");case 3:if(e===i){a+=e,o=0;break}if("\n"===e){f();break}if("\r"===e)break;if(e===r)throw new Error("CSVDataError: Illegal quote [Row:"+n.state.rowNum+"]");throw new Error("CSVDataError: Illegal state [Row:"+n.state.rowNum+"]");default:throw new Error("CSVDataError: Unknown state [Row:"+n.state.rowNum+"]")}})),""!==a&&f(),s}function f(){if(o=0,n.start&&n.state.rowNum=n.end&&(l=!0),n.state.rowNum++}},parseEntry:function(e,t){var n=t.separator,i=t.delimiter;t.state.rowNum||(t.state.rowNum=1),t.state.colNum||(t.state.colNum=1);var r=[],s=0,o="";function a(){if(void 0===t.onParseValue)r.push(o);else{var e=t.onParseValue(o,t.state);!1!==e&&r.push(e)}o="",s=0,t.state.colNum++}if(!t.match){var l=RegExp.escape(n),u=RegExp.escape(i),h=/(D|S|\n|\r|[^DS\r\n]+)/.source;h=(h=h.replace(/S/g,l)).replace(/D/g,u),t.match=new RegExp(h,"gm")}return e.replace(t.match,(function(e){switch(s){case 0:if(e===n){o+="",a();break}if(e===i){s=1;break}if("\n"===e||"\r"===e)break;o+=e,s=3;break;case 1:if(e===i){s=2;break}o+=e,s=1;break;case 2:if(e===i){o+=e,s=1;break}if(e===n){a();break}if("\n"===e||"\r"===e)break;throw new Error("CSVDataError: Illegal State [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");case 3:if(e===n){a();break}if("\n"===e||"\r"===e)break;if(e===i)throw new Error("CSVDataError: Illegal Quote [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");throw new Error("CSVDataError: Illegal Data [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");default:throw new Error("CSVDataError: Unknown State [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]")}})),a(),r}},helpers:{collectPropertyNames:function(e){var t=[],n=[],i=[];for(t in e)for(n in e[t])e[t].hasOwnProperty(n)&&i.indexOf(n)<0&&"function"!=typeof e[t][n]&&i.push(n);return i}},toArray:function(e,n,i){n=void 0!==n?n:{};var r={};r.callback=void 0!==i&&"function"==typeof i&&i,r.separator="separator"in n?n.separator:t.csv.defaults.separator,r.delimiter="delimiter"in n?n.delimiter:t.csv.defaults.delimiter;var s=void 0!==n.state?n.state:{};n={delimiter:r.delimiter,separator:r.separator,onParseEntry:n.onParseEntry,onParseValue:n.onParseValue,state:s};var o=t.csv.parsers.parseEntry(e,n);if(!r.callback)return o;r.callback("",o)},toArrays:function(e,n,i){n=void 0!==n?n:{};var r={};r.callback=void 0!==i&&"function"==typeof i&&i,r.separator="separator"in n?n.separator:t.csv.defaults.separator,r.delimiter="delimiter"in n?n.delimiter:t.csv.defaults.delimiter;var s;if(void 0!==(n={delimiter:r.delimiter,separator:r.separator,onPreParse:n.onPreParse,onParseEntry:n.onParseEntry,onParseValue:n.onParseValue,onPostParse:n.onPostParse,start:n.start,end:n.end,state:{rowNum:1,colNum:1}}).onPreParse&&n.onPreParse(e,n.state),s=t.csv.parsers.parse(e,n),void 0!==n.onPostParse&&n.onPostParse(s,n.state),!r.callback)return s;r.callback("",s)},toObjects:function(e,n,i){n=void 0!==n?n:{};var r={};r.callback=void 0!==i&&"function"==typeof i&&i,r.separator="separator"in n?n.separator:t.csv.defaults.separator,r.delimiter="delimiter"in n?n.delimiter:t.csv.defaults.delimiter,r.headers="headers"in n?n.headers:t.csv.defaults.headers,n.start="start"in n?n.start:1,r.headers&&n.start++,n.end&&r.headers&&n.end++;var s,o=[];n={delimiter:r.delimiter,separator:r.separator,onPreParse:n.onPreParse,onParseEntry:n.onParseEntry,onParseValue:n.onParseValue,onPostParse:n.onPostParse,start:n.start,end:n.end,state:{rowNum:1,colNum:1},match:!1,transform:n.transform};var a={delimiter:r.delimiter,separator:r.separator,start:1,end:1,state:{rowNum:1,colNum:1}};void 0!==n.onPreParse&&n.onPreParse(e,n.state);var l=t.csv.parsers.splitLines(e,a),u=t.csv.toArray(l[0],n);s=t.csv.parsers.splitLines(e,n),n.state.colNum=1,n.state.rowNum=u?2:1;for(var h=0,c=s.length;h-1&&(h=h.replace(new RegExp(r.delimiter,"g"),r.delimiter+r.delimiter));var c="\n|\r|S|D";c=(c=c.replace("S",r.separator)).replace("D",r.delimiter),h.search(c)>-1&&(h=r.delimiter+h+r.delimiter),o.push(h)}u+=o.join(r.separator)+"\n"}if(!r.callback)return u;r.callback("",u)},fromObjects:function(e,n,i){n=void 0!==n?n:{};var r={};if(r.callback=void 0!==i&&"function"==typeof i&&i,r.separator="separator"in n?n.separator:t.csv.defaults.separator,r.delimiter="delimiter"in n?n.delimiter:t.csv.defaults.delimiter,r.headers="headers"in n?n.headers:t.csv.defaults.headers,r.sortOrder="sortOrder"in n?n.sortOrder:"declare",r.manualOrder="manualOrder"in n?n.manualOrder:[],r.transform=n.transform,"string"==typeof r.manualOrder&&(r.manualOrder=t.csv.toArray(r.manualOrder,r)),void 0!==r.transform){var s,o=e;for(e=[],s=0;s0){var d=[].concat(r.manualOrder);let e;for(e=0;e{let n=Object.getOwnPropertyDescriptors(t);for(let t in n){let i=n[t];i.value instanceof Function?e[t]=i.value:i.get instanceof Function&&Object.defineProperty(e,t,i)}};window.PennController.ResetPrefix=function(e){if("string"==typeof e){if(window[e])throw"ERROR: prefix string already used for another JS object";window[e]={};var t=window[e]}else t=window;n(t,window.PennController.Elements),n(t,window.PennController)}},function(e,t,n){"use strict";var i=n(0),r=n(2);i.a.Prerun(()=>{let e=[];function t(t){return t instanceof r.a?e.indexOf(t)<0&&t.addToItems?[t.useLabel||"unlabeled","PennController",t]:null:t}if(window.items instanceof Array)for(let t=0;t2)for(let n=2;n2)for(let n=2;ne instanceof Array&&e.length>2),window.shuffleSequence||(window.conf_shuffleSequence=window.seq(window.anyType))})},function(e,t){window.PennController._AddElementType("Audio",(function(e){this.immediate=function(t,n){"string"==typeof t&&void 0===n&&(n=t);let i=!n.match(/^http/i);this.resource=e.resources.fetch(n,(function(e){this.object=new Audio,this.object.muted=!0;let t=!1;const n=()=>{if(t=!0,this.object.buffered.length&&this.object.seekable.length){if(this.object.buffered.end(0)==this.object.seekable.end(0))return this.object.pause(),this.object.currentTime=0,this.object.muted=!1,resolved=!0,e();this.object.muted=!0,this.object.play()}return window.requestAnimationFrame(n),!0};this.object.addEventListener("progress",()=>t||n()),this.object.src=this.value,this.object.load()}),i),void 0!==t&&"string"==typeof t&&0!=t.length||(t="Audio"),this.id=t},this.uponCreation=function(e){this.resource.object.controls=!0,this.audio=this.resource.object,this.hasPlayed=!1,this.disabled=!1,this.resource.object.style=null,this.jQueryElement=$(this.audio),this.jQueryElement.removeClass(),this.jQueryDisable=null,this.playEvents=[],this.endEvents=[],this.pauseEvents=[],this.seekEvents=[],this.bufferEvents=[],this.whatToSave=[],this.resource.object.onplay=()=>{this.playEvents.push(["play",this.audio.currentTime,Date.now()])},this.resource.object.onended=()=>{this.hasPlayed=!0,this.endEvents.push(["end",this.audio.currentTime,Date.now()])},this.resource.object.onpause=()=>{this.pauseEvents.push(["pause",this.audio.currentTime,Date.now()])},this.resource.object.onseeked=()=>{this.seekEvents.push(["seek",this.audio.currentTime,Date.now()])},this.resource.object.onwaiting=()=>{this.bufferEvents.push(["buffer",this.audio.currentTime,Date.now()])},this.printDisable=e=>{void 0===e&&(e=this.disabled),(!0===e||isNaN(Number(e)))&&(e=.5),this.jQueryDisable instanceof jQuery&&this.jQueryDisable.remove(),this.jQueryDisable=$("
      ").css({position:"absolute",display:"inline-block","background-color":"gray",opacity:e,width:this.jQueryElement.width(),height:this.jQueryElement.height()}),this.jQueryElement.before(this.jQueryDisable)},e()},this.end=function(){if(this.whatToSave&&this.whatToSave.indexOf("play")>-1){this.playEvents.length||e.controllers.running.save(this.type,this.id,"play","NA","Never");for(let t in this.playEvents)e.controllers.running.save(this.type,this.id,...this.playEvents[t])}if(this.whatToSave&&this.whatToSave.indexOf("end")>-1){this.endEvents.length||e.controllers.running.save(this.type,this.id,"end","NA","Never");for(let t in this.endEvents)e.controllers.running.save(this.type,this.id,...this.endEvents[t])}if(this.whatToSave&&this.whatToSave.indexOf("pause")>-1){this.pauseEvents.length||e.controllers.running.save(this.type,this.id,"pause","NA","Never");for(let t in this.pauseEvents)e.controllers.running.save(this.type,this.id,...this.pauseEvents[t])}if(this.whatToSave&&this.whatToSave.indexOf("seek")>-1){this.seekEvents.length||e.controllers.running.save(this.type,this.id,"seek","NA","Never");for(let t in this.seekEvents)e.controllers.running.save(this.type,this.id,...this.seekEvents[t])}if(this.bufferEvents)for(let t in this.bufferEvents)e.controllers.running.save(this.type,this.id,...this.bufferEvents[t]);this.resource.object.pause(),this.resource.object.currentTime=0,this.jQueryDisable&&this.jQueryDisable.remove()},this.value=function(){return this.endEvents.length?this.endEvents[this.endEvents.length-1][2]:0},this.actions={play:function(t,n){this.hasOwnProperty("audio")&&this.audio instanceof Audio?(n&&"once"==n?this.audio.removeAttribute("loop"):n&&(this.audio.loop=!0),this.audio.play()):e.debug.error("No audio to play for element ",this.id),t()},pause:function(e){this.audio.pause(),e()},print:function(t,...n){e.elements.standardCommands.actions.print.apply(this,[()=>{(this.disabled||null!==this.disabled&&!1!==this.disabled&&!isNaN(this.disabled))&&this.printDisable(this.disabled),t()},...n])},stop:function(e){this.audio.currentTime=this.audio.duration,e()},wait:function(e,t){if("first"==t&&this.hasPlayed)e();else{let n=!1,i=this.audio.onended;this.audio.onended=function(...r){if(i.apply(this,r),!n)if(t instanceof Object&&t._runPromises&&t.success){let i=this.disabled;this.disabled="tmp",t._runPromises().then(t=>{"success"==t&&(n=!0,e()),"tmp"==this.disabled&&(this.disabled=i)})}else n=!0,e()}}}},this.settings={disable:function(e,t){this.jQueryElement.addClass("PennController-disabled"),this.jQueryContainer.addClass("PennController-disabled"),t=!(!isNaN(t)&&null!==t)||Number(t),this.disabled=t,this.printDisable(t),e()},enable:function(e){this.jQueryDisable instanceof jQuery&&(this.disabled=!1,this.jQueryDisable.remove(),this.jQueryDisable=null,this.jQueryElement.removeClass("PennController-disabled"),this.jQueryContainer.removeClass("PennController-disabled"),this.jQueryElement.attr("controls",!0)),e()},once:function(e){if(this.hasPlayed)this.disabled=!0,this.printDisable();else{let e=this.audio.onended,t=this;this.audio.onended=function(...n){e.apply(this,n),t.disabled=!0,t.printDisable()}}e()},log:function(e,...t){1==t.length&&"string"==typeof t[0]?this.whatToSave.push(t[0]):t.length>1?this.whatToSave=this.whatToSave.concat(t):this.whatToSave=["play","end","pause","seek"],e()}},this.test={hasPlayed:function(){return this.hasPlayed},playing:function(){return this.audio.currentTime&&!this.audio.paused}}}))},function(e,t){window.PennController._AddElementType("Button",(function(e){this.immediate=function(e,t){void 0===t&&(t=e,void 0!==e&&"string"==typeof e&&0!=e.length||(e="Button"),this.id=e),this.initialText=t},this.uponCreation=function(e){this.text=this.initialText,this.jQueryElement=$("").click((function(){u.remove(),window.webgazer.reg.RidgeWeightedReg.call(window.webgazer.getRegression()[0]),t(n,i,r,s-1)})).css("margin","auto"))):(l=!0,u.remove(),m().removeMouseEventListeners(),n())},3e3)};if(l)c();else{g(!0);const e=48,t=48,n=120;let i=[];const r=async s=>{const o=i.shift(),a=$("
      ").css({position:"fixed",display:"block",width:e+"px",height:t+"px",background:"green","border-radius":"100%",left:o[0],top:o[1],"z-index":999999});await new Promise(e=>setTimeout(e,750)),$("body").append(a),f.play(),await new Promise(e=>setTimeout(e,250));let l=n;const u=()=>{l%2&&h({clientX:o[0]+e/2,clientY:o[1]+t/2}),0==l?(a.detach(),i.length?r():c()):(l--,window.requestAnimationFrame(u))};u()},s=()=>$("body").append($("").bind("click",n=>{m().removeMouseEventListeners(),g(!1),$(n.target).detach();const s=window.innerWidth,o=window.innerHeight;i=[[(s-e)/2,(o-t)/2],...[[0,0],[(s-e)/2,0],[s-e,o-t],[(s-e)/2,o-t],[s-e,(o-t)/2],[s-e,0],[0,(o-t)/2],[0,o-t]].sort(e=>.5-Math.random()),[(s-e)/2,(o-t)/2]],r()}).css({position:"fixed",display:"block",left:"50vw",top:"50vh",transform:"translate(-50%,-50%)"}));if(d)s();else{const e=$("

      Wait until your face is detected (you should see green contours around it) and then click anywhere on the page until you see a red dot

      ");e.css({position:"fixed",left:"50vw",top:"50vh",transform:"translate(-50%,-50%)"}),$("body").append(e);const t=()=>{d?(e.remove(),s()):window.requestAnimationFrame(t)};t()}}$("#webgazerVideoFeed").before(u)}(t,this,n,i)},hideFeedback:function(e){g(!1),e()},start:function(e){this.enabled=!0,i=this,e()},stop:function(e){this.enabled=!1,i=void 0,e()},stopTraining:function(e){m().removeMouseEventListeners(),m().showPredictionPoints(!1),e()},showFeedback:function(e){g(),e()},train:function(e,t){m().addMouseEventListeners(),this.trainOnMouseMove||document.removeEventListener("mousemove",u,!0),m().showPredictionPoints(t),e()}},this.settings={add:function(e,...t){for(let e=0;e=Number(e)}}}))},function(e,t){window.PennController._AddElementType("Function",(function(e){this.immediate=function(e,t){"function"==typeof e&&(t=e,void 0!==e&&"string"==typeof e&&0!=e.length||(e="Function"),this.id=e),this.function=t},this.uponCreation=function(t){e.controllers.running.hasOwnProperty("internalVariables")||(e.controllers.running.internalVariables={}),t()},this.end=function(){e.controllers.running.internalVariables=void 0},this.value=function(){return this.function.apply(e.controllers.running.internalVariables)},this.actions={call:async function(t,...n){await this.function.apply(e.controllers.running.internalVariables,n),t()}},this.test={is:function(t){let n=this.function.apply(e.controllers.running.internalVariables);return void 0===t?!n:n==t}}}))},function(e,t){window.PennController._AddElementType("Html",(function(e){function t(e,t){var n=$("label.error[for=__ALL_FIELDS__]");if(n.length>0)n.addClass("Form-error-text").text(t);else{var i=$("label.error[for="+escape(e)+"]");i.length>0?i.addClass("Form-error-text").text(t):alert(t)}}function n(){for(var e=this.jQueryElement[0],t=$(e).find("input[type=text]"),n=$(e).find("textarea"),i=0;i").html(htmlCodeToDOM({include:this.html})):this.jQueryElement=$("
      ").append(this.html),this.log=!1,this.checkboxWarningMessage="You must check the %name% checkbox to continue.",this.inputWarningMessage="The ‘%name%’ field is obligatory.",this.radioWarningMessage="You must select an option for ‘%name%’.",e()},this.end=function(){if(this.log){for(var t=this.jQueryElement[0],n=$(t).find("input[type=text]"),i=$(t).find("textarea"),r=0;r0?this.keys.push(String.fromCharCode(n[i])):"string"!=typeof n[i]?e.debug.error("Invalid key(s) passed to new Key ""+t+"" (should be a string or a key code number)",n[i]):n[i].isSpecialKey()||n[i].replace(/^(Left|Right)/i,"").isSpecialKey()?this.specialKeys.push(n[i].toUpperCase()):n[i].length&&this.keys.push(n[i].toUpperCase())},this.uponCreation=function(t){this.pressed=[],this.pressedWait=[],this.log=!1,this.enabled=!0,e.events.keypress(e=>{if(!this.enabled)return;let t=e.key.isSpecialKey(),n=e.key.toUpperCase(),i={0:"",1:"LEFT",2:"RIGHT"};(0==this.keys.length&&0==this.specialKeys.length||t&&this.specialKeys.filter(t=>t==n||t===i[e.location]+n).length||!t&&this.keys.filter(e=>e.indexOf(n)>-1).length)&&this.press(e.key)}),this.press=e=>{this.pressed.push(["PressedKey",e.toUpperCase(),Date.now(),"NULL"])},t()},this.end=function(){if(this.log&&this.log instanceof Array)if(0==this.pressed.length)e.controllers.running.save(this.type,this.id,"Key","NA","Never","NULL");else if(this.log.indexOf("all")>-1)for(let t in this.pressed)e.controllers.running.save(this.type,this.id,...this.pressed[t]);else if(this.log.indexOf("wait")>-1){let t=!1;for(let n in this.pressed)"Wait success"==this.pressed[n][3]&&(e.controllers.running.save(this.type,this.id,...this.pressed[n]),t=!0);t||e.controllers.running.save(this.type,this.id,"Key","NA","Never","(failed keypresses happened)")}else 1==this.pressed.length?e.controllers.running.save(this.type,this.id,...this.pressed[0]):(this.log.indexOf("first")>-1&&e.controllers.running.save(this.type,this.id,...this.pressed[0]),this.log.indexOf("last")>-1&&e.controllers.running.save(this.type,this.id,...this.pressed[this.pressed.length-1]))},this.value=function(){return this.pressed.length?this.pressed[this.pressed.length-1][1]:""},this.actions={wait:function(e,t){if("first"==t&&this.pressed.length)e();else{let n=!1,i=this.press,r=document.activeElement;for(;r;)r.disabled?(r.blur(),r=null):r=r.parentElement;this.press=r=>{if(i.apply(this,[r]),!n)if(t instanceof Object&&t._runPromises&&t.success){let i=this.enabled;this.enabled=0,t._runPromises().then(t=>{"success"==t?(this.pressed[this.pressed.length-1][3]="Wait success",n=!0,e()):this.pressed[this.pressed.length-1][3]="Wait failure",0===this.enabled&&(this.enabled=i)})}else this.pressed[this.pressed.length-1][3]="Wait success",n=!0,e()}}}},this.settings={callback:function(e,...t){let n=this.press;this.press=async function(e){if(n.apply(this,[e]),this.enabled)for(let e in t)await t[e]._runPromises()},e()},disable:function(e){this.enabled=!1,e()},enable:function(e){this.enabled=!0,e()},log:function(e,...t){t.length?this.log=t:this.log=["wait"],e()}},this.test={pressed:function(e,t){for(let n in this.pressed){let i=this.pressed[n][1];if(Number(e)>0&&i.toUpperCase()==String.fromCharCode(e).toUpperCase())return!0;if("string"==typeof e&&e.toUpperCase()==i.toUpperCase())return!0;if(void 0===e)return!0;if(t)return!1}return!1}}}))},function(e,t){window.PennController._AddElementType("MouseTracker",(function(e){let t,n;this.immediate=function(e){void 0!==e&&"string"==typeof e&&0!=e.length||(e="MouseTracker"),this.id=e,$(document).mousemove(e=>{t=e.clientX,n=e.clientY,this.move&&this.move instanceof Function&&this.enabled&&this.move(e)}),$(document).click(e=>{this.click&&this.click instanceof Function&&this.enabled&&this.click(e)})},this.uponCreation=function(e){this.coordinates=[],this.enabled=!1,this.callbacks=[],this.clickCallbacks=[],this.currentStream=[],this.log=[],this.clicks=[];let i=this;this.click=async e=>{if(this.enabled){this.clicks.push([Date.now(),e.clientX,e.clientY]);for(let t=0;t{if(this.currentStream.length>1){let e=this.currentStream[0][1],t=this.currentStream[0][2],n=this.currentStream[0][0];void 0===e&&(e=this.currentStream[1][1]),void 0===t&&(t=this.currentStream[1][2]);let i="x"+e+"y"+t+"w"+this.currentStream[0][3]+"h"+this.currentStream[0][4];for(let r=1;r=0?"+":"")+s,i+=(o>=0?"+":"")+o,e=this.currentStream[r][1],t=this.currentStream[r][2],n=this.currentStream[r][0]}let r="NULL";window.innerWidth==this.currentStream[0][3]&&window.innerHeight==this.currentStream[0][4]||(r="Size of window changed to "+window.innerWidth+" * "+window.innerHeight),this.coordinates.push([i,this.currentStream[0][0],r])}this.currentStream=[]},e()},this.end=function(){this.enabled=!1,this.finishStream&&this.finishStream instanceof Function&&this.finishStream(),this.log.map(t=>{"string"==typeof t&&(t.match(/move/i)?this.coordinates.map(t=>e.controllers.running.save(this.type,this.id,"Move",...t)):t.match(/click/i)&&this.clicks.map(t=>e.controllers.running.save(this.type,this.id,"Click",t[1]+":"+t[2],t[0],"NULL")))})},this.value=function(){return t&&n?t+"-"+n:"NA-NA"},this.actions={start:function(e){this.currentStream=[[Date.now(),t,n,window.innerWidth,window.innerHeight]],this.enabled=!0,e()},stop:function(e){this.enabled=!1,this.finishStream(),e()}},this.settings={callback:function(e,...t){0!=t.length&&("string"==typeof t[0]&&t[0].match(/click/i)?(t.shift(),this.clickCallbacks=this.clickCallbacks.concat(t)):this.callbacks=this.callbacks.concat(t),e())},log:function(e,...t){console.log("log what?",t),t.length?this.log=t:this.log=["clicks","movements"],e()}},this.test={over:function(i){return i instanceof jQuery?e.utils.overToScale.call(i,t,n):!!(i._element&&i._element.hasOwnProperty("jQueryElement")&&i._element.jQueryElement instanceof jQuery)&&e.utils.overToScale.call(i._element.jQueryElement,t,n)}}}))},function(e,t){window.PennController._AddElementType("Palette",(function(e){this.immediate=function(e,t){void 0===t&&(t=e),this.mode=t||"background",void 0!==e&&"string"==typeof e&&0!=e.length||(e="Palette"),this.id=e},this.uponCreation=function(e){this.currentColor=null,this.enabled=!0,this.elements=[],this.colors=[],this.brushes=[],this.log=!1,this.select=e=>{if(!this.enabled||!this.currentColor)return;let t=this.elements.map(e=>e[0]).indexOf(e);if(t<0)return;this.elements[t][1]=this.currentColor;let n=e.jQueryElement;this.brushes.push([e.id,this.currentColor,Date.now()]),"background"==this.mode?n.css("background-color",this.currentColor):(n._tinter&&n._tinter instanceof jQuery&&n._tinter.remove(),n._tinter=$("
      ").css({display:"block",position:"absolute",width:n.width(),height:n.height(),"margin-top":-1*n.width(),background:this.elements[t][1],opacity:.5}),n.before(n._tinter))},e()},this.end=function(){if(this.enabled=!1,$("#bod").css("cursor","default"),this.log){if("all"==this.log)for(let t=0;t{let s=i.apply(this,[r]);n||!this.enabled&&!s||(t instanceof Object&&t._runPromises&&t.success?t._runPromises().then(t=>{"success"==t&&(n=!0,e())}):(n=!0,e()))}}}},this.settings={addColor:function(t,n,...i){this.colors.indexOf(n)<0&&this.colors.push(n);let r=[],s=()=>{this.colors.indexOf(n)<0||(this.currentColor=n,$(".PennController-"+this.type+"-palette-selected").removeClass("PennController-"+this.type+"-palette-selected"),r.map(e=>e.jQueryElement.addClass("PennController-"+this.type+"-palette-selected")),$("#bod").css("cursor","crosshair"))};for(let t in i){let n=i[t];"string"==typeof n?e.events.keypress(e=>{n.toUpperCase().indexOf(String.fromCharCode(e.which).toUpperCase())>-1?s():27==e.which&&($(".PennController-"+this.type+"-palette-selected").removeClass("PennController-"+this.type+"-palette-selected"),$("#bod").css("cursor","default"),this.currentColor=null)}):n._element&&n._element.jQueryElement&&(n._element.jQueryElement.bind("click",s),n._element.jQueryElement.addClass("PennController-"+this.type+"-palette"),n._element.jQueryElement.addClass("PennController-"+this.id+"-palette"),r.push(n._element))}t()},addElement:function(e,...t){for(let e in t){let n=t[e];n._element&&n._element.jQueryElement&&(n._element.jQueryElement.bind("click",()=>{this.select(n._element)}),this.elements.map(e=>e[0]).indexOf(n._element)<0&&this.elements.push([n._element,null]))}e()},callback:function(e,...t){let n=this.select;this.select=async function(e){if(n.apply(this,[e]),this.enabled)for(let e in t)await t[e]._runPromises()},e()},enable:function(e){this.jQueryContainer.removeClass("PennController-disabled"),this.jQueryElement.removeClass("PennController-disabled"),this.enabled=!0,e()},disable:function(e){this.jQueryContainer.addClass("PennController-disabled"),this.jQueryElement.addClass("PennController-disabled"),this.enabled=!1,e()},log:function(e,t){this.log=t||"all",e()},once:function(e){if(this.brushes.length)this.enabled=!1,$(".PennController-"+this.type+"-palette-selected").removeClass("PennController-"+this.type+"-palette-selected"),$("#bod").css("cursor","default"),this.currentColor=null;else{let e=this.select;this.select=t=>{if(e.apply(this,[t]),this.enabled)return this.enabled=!1,$(".PennController-"+this.type+"-palette-selected").removeClass("PennController-"+this.type+"-palette-selected"),$("#bod").css("cursor","default"),this.currentColor=null,"once"}}e()},removeColor:function(e,t){let n=this.colors.indexOf(t);n>-1&&this.colors.splice(n,1),e()}},this.test={color:function(e,t){if(e._element&&e._element){let n=this.elements.map(e=>e[0]).indexOf(e._element);return!(n<0)&&this.elements[n][1]==t}return!1}}}))},function(e,t){window.PennController._AddElementType("Scale",(function(e){function t(){this.jQueryElement.find("input").attr("disabled",!0),this.jQueryElement.find("div,label").css("cursor",""),this.disabled=!0}function n(){this.jQueryElement.find("input").removeAttr("disabled"),this.jQueryElement.find("div").css("cursor","pointer"),this.disabled=!1}function i(e,t){if("slider"==this.scaleType?this.jQueryElement.find("input[type=range]")[0].value=e:this.jQueryElement.find(`input#${this.id}-${e}`).attr("checked",!0).change(),t){let t=this.buttons[e];null!=t&&""!=t||(t=e+1),this.choice(t)}}async function r(){let t=this.defaultValue,n=this.orientation,i=this.scaleType;if(this.jQueryElement.empty(),"slider"==i){var r=$("").attr({type:"range",min:"0",max:String(this.buttons.length-1),value:String((this.buttons.length-1)/2),step:"1"});Number(t)>=0&&Number(t)<=this.buttons.length-1&&r.attr("value",String(t)),this.disabled&&r.attr("disabled",!0),r[0].oninput=()=>{this.firstClick||(this.firstClick=Date.now())},r[0].onchange=()=>this.choice(r[0].value),"vertical"==n&&(r.attr("orient","vertical"),r.css({"writing-mode":"vertical-lr","-webkit-appearance":"slider-vertical"})),r.css({width:"100%",height:"100%"}),this.jQueryElement.append(r)}else{this.jQueryElement.css({display:"inline-flex","justify-content":"space-between"});for(let n=0;n").attr({for:this.id+"-"+n}).html(r).css("cursor","pointer"),o=$("").attr({name:this.id,value:r,type:"checkbox"==i?"checkbox":"radio",id:this.id+"-"+n}),a=$("
      ").addClass("option").css({cursor:"pointer",display:"flex","align-items":"center"}).append(o).append(s);r._runPromises&&r.print(s.empty())._runPromises(),t!=r&&t!=n||o.attr("checked",!0),this.disabled&&o.attr("disabled",!0),o[0].onchange=()=>{this.choice(this.buttons[n]||r,"checkbox"==i&&!o[0].checked),this.jQueryElement.find("label").css("outline","none"),"buttons"==i&&s.css("outline","dotted 1px black")},"buttons"==i&&o.css("display","none"),"top"==this.labels?a.css("flex-direction","column-reverse"):"bottom"==this.labels?a.css("flex-direction","column"):"left"==this.labels&&a.css("flex-direction","row-reverse"),this.jQueryElement.append(a),"radio"==i&&!1===this.labels?s.css("display","none"):this.buttons[n]instanceof e.PennElementCommands&&await this.buttons[n].print(s.empty())._runPromises()}"vertical"==n&&this.jQueryElement.css("flex-direction","column")}this.width||this.jQueryElement.css("max-width","max-content")}this.immediate=function(e,...t){t.length||(t=[e],void 0!==e&&"string"==typeof e&&0!=e.length||(e="Scale")),this.id=e,"string"!=typeof t[0]&&Number(t[0])>0?this.initialButtons=new Array(Number(t[0])):this.initialButtons=t},this.uponCreation=function(t){this.jQueryElement=$("
      ").css("display","inline-block"),this.choices=[],this.log=!1,this.labels=!1,this.disabled=!1,this.vertical=!1,this.scaleType="radio",this.defaultValue=null,this.orientation="horizontal",this.width=null,this.keys=[],this.buttons=this.initialButtons,this.choice=(e,t)=>{if(this.disabled)return;this.unselected=t||void 0,e&&e._runPromises&&(e=e._element.id);let n=null;"slider"==this.scaleType&&this.firstClick&&(n=Date.now()-this.firstClick,this.firstClick=void 0),this.choices.push([t?"Unselect":"Choice",e,Date.now(),n||"NULL"])},e.controllers.running.safeBind($(document),"keydown",e=>{if(!this.disabled)for(let t=0;t-1)for(let t in this.choices)e.controllers.running.save(this.type,this.id,...this.choices[t]);else this.log.indexOf("first")>-1&&e.controllers.running.save(this.type,this.id,...this.choices[0]),this.log.indexOf("last")>-1&&e.controllers.running.save(this.type,this.id,...this.choices[this.choices.length-1]);else e.controllers.running.save(this.type,this.id,"Choice","NA","Never","No selection happened")},this.value=function(){return this.choices.length&&void 0===this.unselected?this.choices[this.choices.length-1][1]:NaN},this.actions={print:async function(t,...n){await r.apply(this),e.elements.standardCommands.actions.print.apply(this,[t,...n])},select:function(t,n,r){for(var s=0;s=this.buttons.length)return t(e.debug.error("Option "+n+" not found for selection on Scale "+this.id));i.apply(this,[s,r]),t()},unselect:function(e){if("slider"==this.scaleType){let e=this.jQueryElement.find("input[type=range]")[0];e.value=(e.max-e.min)/2}else this.jQueryElement.find("input").removeAttr("checked").change();this.unselected=!0,e()},wait:function(e,t){if("first"==t&&this.choices.length)e();else{let n=!1,i=this.choice;this.choice=r=>{if(i.apply(this,[r]),!n)if(t instanceof Object&&t._runPromises&&t.success){let i=this.disabled;this.disabled="tmp",t._runPromises().then(t=>{"success"==t&&(n=!0,e()),"tmp"==this.disabled&&(this.disabled=i)})}else n=!0,e()}}}},this.settings={button:async function(e){this.scaleType="buttons",await r.apply(this),e()},callback:function(e,...t){let n=this.choice;this.choice=async function(e){let i=this.disabled;if(n.apply(this,[e]),!i)for(let e in t)await t[e]._runPromises()},e()},checkbox:async function(e){this.scaleType="checkbox",await r.apply(this),e()},default:function(t,n){this.buttons.indexOf(n)>-1||Number(n)>=0&&Number(n)"string"==typeof e&&1==e.length).length!=n.length)return t(e.debug.error("Every key should be a string of length 1 in Scale "+this.id,n));this.keys=n.map(e=>e.toUpperCase())}else this.buttons.filter(e=>"string"==typeof e&&1==e.length).length==this.buttons.length?this.keys=this.buttons.map(e=>e.toUpperCase()):this.keys=Array.from({length:this.buttons.length},(e,t)=>t+1);t()},label:async function(e,t,n){if(isNaN(Number(t))||t<0||t>=this.buttons.length)return e();this.buttons[t]=n,await r.apply(this),e()},labels:function(e,t){this.labels=t,e()},labelsPosition:async function(e,t){this.labels=t,await r.apply(this),e()},log:function(e,...t){t.length?this.log=t:this.log=["last"],e()},once:function(e){if(this.hasClicked)t.apply(this);else{let e=this.choice;this.choice=n=>{e.apply(this,[n]),t.apply(this)}}e()},radio:async function(e){this.scaleType="radio",await r.apply(this),e()},size:async function(t,n,i){this.width=n,await r.apply(this),e.elements.standardCommands.settings.size.apply(this,[t,n,i])},slider:async function(e){this.scaleType="slider",await r.apply(this),e()},vertical:async function(e){this.orientation="vertical",this.jQueryElement.parent().length&&await r.apply(this),e()}},this.test={selected:function(e){return!(!this.choices.length||this.unselected)&&(null==e||e==this.choices[this.choices.length-1][1])}}}))},function(e,t){window.PennController._AddElementType("Selector",(function(e){async function t(t,...n){let i=[];if(n.length)for(let t in n){if(!(n[t]._element&&n[t]._element.jQueryElement instanceof jQuery)){e.debug.error("Invalid element #"+t+" in shuffling selector "+this.id);continue}let r=this.elements.map(e=>e[0]).indexOf(n[t]._element);r<0?e.debug.error("Cannot shuffle element "+n[t]._element.id+" for it has not been added to selector "+this.id):i.push(r)}else i=[...new Array(this.elements.length)].map((e,t)=>t);let r=[...i];fisherYates(r);const s=[],o=i.map(e=>{const t=this.elements[e][0],n=t._lastPrint;if(void 0===n[0]){const n=t.jQueryContainer;if(n instanceof jQuery&&n.parent().length){const t=$("");n.before(t),s[e]=t}}else if(n[0]instanceof jQuery&&(n[0].hasClass("PennController-after")||n[0].hasClass("PennController-before"))){const e={};let s=n[0][0].className.replace(/^.*PennController-(after|before).*$/,"$1");s=s.replace(/^[ab]/,e=>e.toUpperCase());for(let n=0;ne._element!=t),o["jQuery"+s].length{const t=this.elements[e][0];await window.PennController.Elements["get"+t.type](t.id).remove()._runPromises()}),r.forEach(async(e,t)=>{let n=this.elements[e][0],r=o[t];if(void 0===r)return;const a=window.PennController.Elements["get"+n.type](n.id);r.hasOwnProperty("After")?await window.PennController.Elements["get"+r.After.type](r.After.id).after(a)._runPromises():r.hasOwnProperty("Before")?await window.PennController.Elements["get"+r.Before.type](r.Before.id).after(a)._runPromises():await a.print(...r)._runPromises();const l=s[i[t]];l instanceof jQuery&&(n.jQueryContainer.css("position","unset"),l.before(n.jQueryContainer),l.remove())});const a=[...this.elements];i.forEach((e,t)=>this.elements[e]=a[r[t]]),t()}this.immediate=function(e){void 0!==e&&"string"==typeof e&&0!=e.length||(e="Selector"),this.id=e},this.uponCreation=function(t){this.elements=[],this.selections=[],this.disabled=!1,this.frame=$("
      ").css({position:"absolute",display:"inline-block",margin:"auto",outline:"dotted 1px grey","z-index":100}).addClass("PennController-"+this.type.replace(/[\s_]/g,"")+"-selectionFrame"),this.noClick=!1,this.select=t=>{if(!this.disabled){if(this.elements.map(e=>e[0]).indexOf(t)<0)return e.debug.error("Tried to select an element not part of Selector "+this.id);this.selections.push(["Selection",t.id,Date.now(),this.elements.map(e=>e[0].id).join(";")]),this.frame.css({width:t.jQueryElement.outerWidth(),height:t.jQueryElement.outerHeight(),"pointer-events":"none"}),"absolute"==t.jQueryElement.css("position")&&this.frame.css({left:t.jQueryElement.css("left"),top:t.jQueryElement.css("top")}),t.jQueryElement.before(this.frame),this.elements.map(e=>e[0].jQueryElement.removeClass("PennController-"+this.type.replace(/[\s_]/g,"")+"-selected")),t.jQueryElement.addClass("PennController-"+this.type.replace(/[\s_]/g,"")+"-selected")}},e.events.keypress(e=>{if(!this.disabled)for(let t=0;t1&&(n=this.elements[t][1]);let i=e.key.isSpecialKey(),r=e.key.toUpperCase(),s={0:"",1:"LEFT",2:"RIGHT"};if(i===n.replace(/^(Left|Right)/i,"").isSpecialKey()&&(n.toUpperCase()==r||n.toUpperCase()==s[e.location]+r))return this.select(this.elements[t][0])}}),t()},this.end=function(){if(this.select=()=>{},this.frame&&this.frame instanceof jQuery&&this.frame.remove(),this.log&&this.log instanceof Array)if(this.selections.length)if(1==this.selections.length)e.controllers.running.save(this.type,this.id,...this.selections[0]);else if(this.log.indexOf("all")>-1)for(let t in this.selections)e.controllers.running.save(this.type,this.id,...this.selections[t]);else this.log.indexOf("first")>-1&&e.controllers.running.save(this.type,this.id,...this.selections[0]),this.log.indexOf("last")>-1&&e.controllers.running.save(this.type,this.id,...this.selections[this.selections.length-1]);else e.controllers.running.save(this.type,this.id,"Selection","NA","Never",this.elements.map(e=>e[0].id).join(";")+";No selection happened");this.elements=[]},this.value=function(){if(this.selections.length){let e=this.selections[this.selections.length-1][1],t=this.elements.filter(t=>t[0].id==e);return t.length?(t=t[0][0],window.PennController.Elements["get"+t.type](t.id)):null}return null},this.actions={select:function(t,n){if(!isNaN(Number(n))&&Number(n)>=0&&Number(n)e[0].id).join(";")+";From script"]),this.frame.detach(),this.elements.map(e=>e[0].jQueryElement.removeClass("PennController-"+this.type+"-selected")),e()},wait:function(e,t){if("first"==t&&this.selections.length)e();else{let n=!1,i=this.select;this.select=r=>{let s=i.apply(this,[r]);if(!(n||this.disabled&&!s))if(t instanceof Object&&t._runPromises&&t.success){let i=this.disabled;this.disabled="tmp",t._runPromises().then(t=>{"success"==t&&(n=!0,e()),"tmp"==this.disabled&&(this.disabled=i)})}else n=!0,e()}}}},this.settings={add:function(t,...n){for(w in n){let t=n[w]._element;if(null==t||null==t.id)e.debug.error("Invalid element added to selector "+this.id);else if(this.elements.map(e=>e[0]).indexOf(t)>-1)e.debug.error("Element "+t.id+" already part of selector "+this.id);else if(null!=t.jQueryElement&&t.jQueryElement instanceof jQuery){this.elements.push([t]);let e=()=>{this.noClick||t.jQueryElement.css("cursor","pointer");let e=t.jQueryElement[0].onclick;t.jQueryElement[0].onclick=(...n)=>{e instanceof Function&&e.apply(t.jQueryElement[0],n),this.noClick||this.select(t)}};t.jQueryElement.parent().length?e():t._printCallback.push(e)}else e.debug.error("Element "+t.id+" has no visble element to be chosen in selector "+this.id)}t()},callback:function(e,...t){let n=this.select;this.select=async function(e){let i=this.disabled;if(n.apply(this,[e]),!i)for(let e in t)await t[e]._runPromises()},e()},disable:function(e){this.disabled=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor","")),this.jQueryContainer.addClass("PennController-disabled"),this.jQueryElement.addClass("PennController-disabled"),e()},disableClicks:function(e){this.noClick=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor","")),e()},enable:function(e){this.disabled=!1,this.noClick||this.elements.map(e=>e[0].jQueryElement.css("cursor","pointer")),this.jQueryContainer.removeClass("PennController-disabled"),this.jQueryElement.removeClass("PennController-disabled"),e()},enableClicks:function(e){this.noClick=!1,this.elements.map(e=>e[0].jQueryElement.css("cursor","pointer")),e()},frame:function(e,t){this.frame.css.apply(this.frame,["outline",t]),e()},keys:function(e,...t){for(let e=0;e=this.elements.length)break;"string"!=typeof n&&Number(n)>0&&(n=String.fromCharCode(n)),this.elements[e]=[this.elements[e][0],n]}e()},log:function(e,...t){t.length?this.log=t:this.log=["last"],e()},once:function(e){if(this.selections.length)this.disabled=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor",""));else{let e=this.select;this.select=t=>{if(e.apply(this,[t]),!this.disabled)return this.disabled=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor","")),"once"}}e()},shuffle:function(e,...n){t.apply(this,[e].concat(n))}},this.test={selected:function(t){if(0===this.selections.length)return!1;let n=this.selections[this.selections.length-1][1];return null==t?this.selections.length>0:"string"==typeof t?t==n:t._element?t._element.id==n:(e.debug.error("Invalid element tested for Selector "+this.id,t._element.id),!1)},index:function(t,n){return null==t||null==t._element?e.debug.error("Invalid element tested for selector "+this.id,t._element.id):Number(n)>=0?this.elements.map(e=>e[0]).indexOf(t._element)==Number(n):this.elements.map(e=>e[0]).indexOf(t._element)>=0}}})),window.PennController._AddStandardCommands((function(e){this.settings={selector:async function(t,n){var i;if("string"==typeof n){let t=e.controllers.running.options.elements;if(!t.hasOwnProperty("Selector")||!t.Selector.hasOwnProperty(n))return e.debug.error("No selector found named "+n);i=t.Selector[n]}else n._element&&n._runPromises&&("Selector"==n._element.type?(await n._runPromises(),i=n._element):e.debug.error("Tried to add "+this.name+" to an invalid Selector"));if(i.elements.map(e=>e[0]).indexOf(this)>-1)e.debug.error("Element "+this.id+" already part of Selector "+i.id);else if(null!=this.jQueryElement&&this.jQueryElement instanceof jQuery){i.elements.push([this]),this.noClick||this.jQueryElement.css("cursor","pointer");let e=this.jQueryElement[0].onclick;this.jQueryElement[0].onclick=(...t)=>{e instanceof Function&&e.apply(this.jQueryElement[0],t),i.noClick||i.select(this)}}else e.debug.error("Element "+this.id+" has no visble element to be chosen in Selector "+i.id);t()}}}))},function(e,t){window.PennController._AddElementType("Text",(function(e){this.immediate=function(e,t){void 0===t&&(t=e),this.id=e,t=t.replace(/(^\s|\s$)/," "),this.initialText=t,this.text=t},this.uponCreation=function(e){this.jQueryElement=$(""+this.initialText+"").css("display","inline-block"),e()},this.value=function(){return this.text},this.end=function(){this.log&&(this.printTime?e.controllers.running.save(this.type,this.id,"Print","NA",this.printTime,"NULL"):e.controllers.running.save(this.type,this.id,"Print","NA","Never","NULL"))},this.actions={unfold:function(t,n){let i=()=>{let e=Number(n);if(e>0){let t=Date.now();this.jQueryElement.css("visibility","visible");let n=this.jQueryElement.width(),i=$("
      ").css({display:"inline-block","overflow-x":"hidden",width:0,margin:0,padding:0,"white-space":"nowrap"});i=this.jQueryElement.wrap(i).parent();let r=0,s=()=>{let o=(Date.now()-t)/e;o>=1&&(o=1);let a=Math.round(n*o);a>r&&i.width(a),r=a,o<1&&window.requestAnimationFrame(s)};window.requestAnimationFrame(s)}};this.jQueryContainer instanceof jQuery&&this.jQueryContainer.parent().length?i():e.elements.standardCommands.actions.print.call(this,i),t()}},this.settings={text:function(t,n){n instanceof e.PennElementCommands&&(n=n.value),this.text=n,this.jQueryElement.html(n),t()}},this.test={text:function(e){return e instanceof RegExp?this.text.match(e):e==this.text}}}))},function(e,t){window.PennController._AddElementType("TextInput",(function(e){this.immediate=function(e,t){void 0!==e&&"string"==typeof e&&0!=e.length||(e="TextInput"),this.initialText=t,this.id=e},this.uponCreation=function(e){this.text=this.initialText,this.jQueryElement=$("