diff --git a/devNotes/sugarcube stuff/important for updating sugarcube.txt b/devNotes/sugarcube stuff/important for updating sugarcube.txt index 3a232879724f823be8532a865fb7511616ebab25..f60ec8151d80de5171aa970317922943aa63559f 100644 --- a/devNotes/sugarcube stuff/important for updating sugarcube.txt +++ b/devNotes/sugarcube stuff/important for updating sugarcube.txt @@ -29,16 +29,14 @@ into this: var t=jQuery(this); const dataPassage = t.attr('data-passage'); - const savedYOffset = window.pageYOffset; - t.is("[aria-pressed]")&&t.attr("aria-pressed","true"===t.attr("aria-pressed")?"false":"true"),e.apply(this,arguments); - const doJump = function(){ window.scrollTo(0, savedYOffset); } - if ( dataPassage && (window.lastDataPassageLink === dataPassage)) - doJump(); - else if (dataPassage && dataPassage.includes('Workaround')) { - doJump(); /* Horrible hack to workaround the workaround... */ - setTimeout(doJump, 10); setTimeout(doJump, 100); setTimeout(doJump, 300); - } - window.lastDataPassageLink = dataPassage; - - + const initialDataPassage = window && window.SugarCube && window.SugarCube.State && window.SugarCube.State.passage; + const savedYOffset = window.pageYOffset; + t.is("[aria-pressed]")&&t.attr("aria-pressed","true"===t.attr("aria-pressed")?"false":"true"),e.apply(this,arguments); + const doJump = function(){ window.scrollTo(0, savedYOffset); } + if ( dataPassage && (window.lastDataPassageLink === dataPassage || initialDataPassage === dataPassage)) + doJump(); + window.lastDataPassageLink = dataPassage; + +This uses two separate methods to detect if we are returning to the same page. Just checking sugarcube should actually be sufficient, but +no harm in this approach either. diff --git a/devNotes/sugarcube stuff/stuffedanon's sugarcube header b/devNotes/sugarcube stuff/stuffedanon's sugarcube header index 7b2220405618010a392de163d87b2c93df79341a..25017cf00a53428e9cc5a372ac8a4861717bd46b 100644 --- a/devNotes/sugarcube stuff/stuffedanon's sugarcube header +++ b/devNotes/sugarcube stuff/stuffedanon's sugarcube header @@ -115,17 +115,14 @@ var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||f <script id="script-sugarcube" type="text/javascript"> /*! SugarCube JS */ if(document.documentElement.getAttribute("data-init")==="loading"){!function(window,document,jQuery,undefined){"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),_slicedToArray=function(){function e(e,t){var r=[],a=!0,n=!1,i=undefined;try{for(var o,s=e[Symbol.iterator]();!(a=(o=s.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){n=!0,i=e}finally{try{!a&&s.return&&s.return()}finally{if(n)throw i}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},errorPrologRegExp=/^(?:(?:uncaught\s+(?:exception:\s+)?)?error:\s+)+/i,Alert=function(){function e(e,t,r,a){var n="fatal"===e,i="Apologies! "+(n?"A fatal":"An")+" error has occurred.";i+=n?" Aborting.":" You may be able to continue, but some parts may not work properly.",null==t&&null==r||(i+="\n\nError",null!=t&&(i+=" ["+t+"]"),i+=null!=r?": "+r.replace(errorPrologRegExp,"")+".":": unknown error."),"object"===(void 0===a?"undefined":_typeof(a))&&a.stack&&(i+="\n\nStack Trace:\n"+a.stack),window.alert(i)}function t(t,r,a){e(null,t,r,a)}function r(t,r,a){e("fatal",t,r,a)}return function(e){window.onerror=function(a,n,i,o,s){"complete"===document.readyState?t(null,a,s):(r(null,a,s),window.onerror=e,"function"==typeof window.onerror&&window.onerror.apply(this,arguments))}}(window.onerror),Object.freeze(Object.defineProperties({},{error:{value:t},fatal:{value:r}}))}(),Patterns=function(){var e=function(){var e=new Map([[" ","\\u0020"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],[" ","\\u00a0"],[" ","\\u1680"],["á Ž","\\u180e"],[" ","\\u2000"],["â€","\\u2001"],[" ","\\u2002"],[" ","\\u2003"],[" ","\\u2004"],[" ","\\u2005"],[" ","\\u2006"],[" ","\\u2007"],[" ","\\u2008"],[" ","\\u2009"],[" ","\\u200a"],["\u2028","\\u2028"],["\u2029","\\u2029"],[" ","\\u202f"],["âŸ","\\u205f"],[" ","\\u3000"],["\ufeff","\\ufeff"]]),t=/\s/,r="";return e.forEach(function(e,a){t.test(a)||(r+=e)}),r?"[\\s"+r+"]":"\\s"}(),t="[0-9A-Z_a-z\\-\\u00c0-\\u00d6\\u00d8-\\u00f6\\u00f8-\\u00ff\\u0150\\u0170\\u0151\\u0171]",r=t.replace("\\-",""),a="("+t+"+)\\(([^\\)\\|\\n]+)\\):",n="("+t+"+):([^;\\|\\n]+);",i="((?:\\."+t+"+)+);",o="((?:#"+t+"+)+);",s=a+"|"+n+"|"+i+"|"+o;return Object.freeze({space:e,spaceNoTerminator:"[\\u0020\\f\\t\\v\\u00a0\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]",lineTerminator:"[\\n\\r\\u2028\\u2029]",anyLetter:t,anyLetterStrict:r,identifierFirstChar:"[$A-Z_a-z]",identifier:"[$A-Z_a-z][$0-9A-Z_a-z]*",variableSigil:"[$_]",variable:"[$_][$A-Z_a-z][$0-9A-Z_a-z]*",macroName:"[A-Za-z][\\w-]*|[=-]",cssImage:"\\[[<>]?[Ii][Mm][Gg]\\[(?:\\s|\\S)*?\\]\\]+",inlineCss:s,url:"(?:file|https?|mailto|ftp|javascript|irc|news|data):[^\\s'\"]+"})}();!function(){function e(e,t){var n=String(e);switch(t){case"start":return n&&r.test(n)?n.replace(r,""):n;case"end":return n&&a.test(n)?n.replace(a,""):n;default:throw new Error('_trimFrom called with incorrect where parameter value: "'+t+'"')}}function t(e,t){var r=Number.parseInt(e,10)||0;if(r<1)return"";var a=void 0===t?"":String(t);for(""===a&&(a=" ");a.length<r;){var n=a.length,i=r-n;a+=n>i?a.slice(0,i):a}return a.length>r&&(a=a.slice(0,r)),a}var r=/^[\s\u00A0\uFEFF][\s\u00A0\uFEFF]*/,a=/[\s\u00A0\uFEFF][\s\u00A0\uFEFF]*$/;Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");if(0===arguments.length)return!1;var e=this.length>>>0;if(0===e)return!1;var t=arguments[0],r=Number(arguments[1])||0;for(r<0&&(r=Math.max(0,e+r));r<e;++r){var a=this[r];if(t===a||t!==t&&a!==a)return!0}return!1}}),String.prototype.padStart||Object.defineProperty(String.prototype,"padStart",{configurable:!0,writable:!0,value:function(e,r){if(null==this)throw new TypeError("String.prototype.padStart called on null or undefined");var a=String(this),n=a.length,i=Number.parseInt(e,10);return i<=n?a:t(i-n,r)+a}}),String.prototype.padEnd||Object.defineProperty(String.prototype,"padEnd",{configurable:!0,writable:!0,value:function(e,r){if(null==this)throw new TypeError("String.prototype.padEnd called on null or undefined");var a=String(this),n=a.length,i=Number.parseInt(e,10);return i<=n?a:a+t(i-n,r)}}),String.prototype.trimStart||Object.defineProperty(String.prototype,"trimStart",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.trimStart called on null or undefined");return e(this,"start")}}),String.prototype.trimLeft||Object.defineProperty(String.prototype,"trimLeft",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.trimLeft called on null or undefined");return e(this,"start")}}),String.prototype.trimEnd||Object.defineProperty(String.prototype,"trimEnd",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.trimEnd called on null or undefined");return e(this,"end")}}),String.prototype.trimRight||Object.defineProperty(String.prototype,"trimRight",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.trimRight called on null or undefined");return e(this,"end")}})}(),function(){function _random(){var e=void 0,t=void 0;switch(arguments.length){case 0:throw new Error("_random called with insufficient parameters");case 1:e=0,t=arguments[0];break;default:e=arguments[0],t=arguments[1]}if(e>t){var r=[t,e];e=r[0],t=r[1]}return Math.floor(_nativeMathRandom()*(t-e+1))+e}function _randomIndex(e,t){var r=void 0,a=void 0;switch(t.length){case 1:r=0,a=e-1;break;case 2:r=0,a=Math.trunc(t[1]);break;default:r=Math.trunc(t[1]),a=Math.trunc(t[2])}return Number.isNaN(r)?r=0:!Number.isFinite(r)||r>=e?r=e-1:r<0&&(r=e+r)<0&&(r=0),Number.isNaN(a)?a=0:!Number.isFinite(a)||a>=e?a=e-1:a<0&&(a=e+a)<0&&(a=e-1),_random(r,a)}function _getCodePointStartAndEnd(e,t){var r=e.charCodeAt(t);if(Number.isNaN(r))return{char:"",start:-1,end:-1};if(r<55296||r>57343)return{char:e.charAt(t),start:t,end:t};if(r>=55296&&r<=56319){var a=t+1;if(a>=e.length)throw new Error("high surrogate without trailing low surrogate");var n=e.charCodeAt(a);if(n<56320||n>57343)throw new Error("high surrogate without trailing low surrogate");return{char:e.charAt(t)+e.charAt(a),start:t,end:a}}if(0===t)throw new Error("low surrogate without leading high surrogate");var i=t-1,o=e.charCodeAt(i);if(o<55296||o>56319)throw new Error("low surrogate without leading high surrogate");return{char:e.charAt(i)+e.charAt(t),start:i,end:t}}var _nativeMathRandom=Math.random;Object.defineProperty(Array,"random",{configurable:!0,writable:!0,value:function(e){if(null==e||"object"!==(void 0===e?"undefined":_typeof(e))||!Object.prototype.hasOwnProperty.call(e,"length"))throw new TypeError("Array.random array parameter must be an array or array-lke object");var t=e.length>>>0;if(0!==t){return e[0===arguments.length?_random(0,t-1):_randomIndex(t,Array.prototype.slice.call(arguments,1))]}}}),Object.defineProperty(Array.prototype,"concatUnique",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.concatUnique called on null or undefined");var e=Array.from(this);if(0===arguments.length)return e;var t=Array.prototype.reduce.call(arguments,function(e,t){return e.concat(t)},[]),r=t.length;if(0===r)return e;for(var a=Array.prototype.indexOf,n=Array.prototype.push,i=0;i<r;++i){var o=t[i];-1===a.call(e,o)&&n.call(e,o)}return e}}),Object.defineProperty(Array.prototype,"count",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.count called on null or undefined");for(var e=Array.prototype.indexOf,t=arguments[0],r=Number(arguments[1])||0,a=0;-1!==(r=e.call(this,t,r));)++a,++r;return a}}),Object.defineProperty(Array.prototype,"delete",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.delete called on null or undefined");if(0===arguments.length)return[];if(0==this.length>>>0)return[];for(var e=Array.prototype.indexOf,t=Array.prototype.push,r=Array.prototype.splice,a=Array.prototype.concat.apply([],arguments),n=[],i=0,o=a.length;i<o;++i)for(var s=a[i],u=0;-1!==(u=e.call(this,s,u));)t.apply(n,r.call(this,u,1));return n}}),Object.defineProperty(Array.prototype,"deleteAt",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.deleteAt called on null or undefined");if(0===arguments.length)return[];var e=this.length>>>0;if(0===e)return[];for(var t=Array.prototype.splice,r=[].concat(_toConsumableArray(new Set(Array.prototype.concat.apply([],arguments).map(function(t){return t<0?Math.max(0,e+t):t})).values())),a=[].concat(_toConsumableArray(r)).sort(function(e,t){return t-e}),n=[],i=0,o=r.length;i<o;++i)n[i]=this[r[i]];for(var s=0,u=a.length;s<u;++s)t.call(this,a[s],1);return n}}),Object.defineProperty(Array.prototype,"flatten",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.flatten called on null or undefined");return Array.prototype.reduce.call(this,function(e,t){return e.concat(Array.isArray(t)?t.flatten():t)},[])}}),Object.defineProperty(Array.prototype,"includesAll",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.includesAll called on null or undefined");if(1===arguments.length)return Array.isArray(arguments[0])?Array.prototype.includesAll.apply(this,arguments[0]):Array.prototype.includes.apply(this,arguments);for(var e=0,t=arguments.length;e<t;++e)if(!Array.prototype.some.call(this,function(e){return e===this.val||e!==e&&this.val!==this.val},{val:arguments[e]}))return!1;return!0}}),Object.defineProperty(Array.prototype,"includesAny",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.includesAny called on null or undefined");if(1===arguments.length)return Array.isArray(arguments[0])?Array.prototype.includesAny.apply(this,arguments[0]):Array.prototype.includes.apply(this,arguments);for(var e=0,t=arguments.length;e<t;++e)if(Array.prototype.some.call(this,function(e){return e===this.val||e!==e&&this.val!==this.val},{val:arguments[e]}))return!0;return!1}}),Object.defineProperty(Array.prototype,"pluck",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.pluck called on null or undefined");var e=this.length>>>0;if(0!==e){var t=0===arguments.length?_random(0,e-1):_randomIndex(e,[].concat(Array.prototype.slice.call(arguments)));return Array.prototype.splice.call(this,t,1)[0]}}}),Object.defineProperty(Array.prototype,"pluckMany",{configurable:!0,writable:!0,value:function(e){if(null==this)throw new TypeError("Array.prototype.pluckMany called on null or undefined");var t=this.length>>>0;if(0===t)return[];var r=Math.trunc(e);if(!Number.isInteger(r))throw new Error("Array.prototype.pluckMany want parameter must be an integer");if(r<1)return[];r>t&&(r=t);var a=Array.prototype.splice,n=[],i=t-1;do{n.push(a.call(this,_random(0,i--),1)[0])}while(n.length<r);return n}}),Object.defineProperty(Array.prototype,"pushUnique",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.pushUnique called on null or undefined");var e=arguments.length;if(0===e)return this.length>>>0;for(var t=Array.prototype.indexOf,r=Array.prototype.push,a=0;a<e;++a){var n=arguments[a];-1===t.call(this,n)&&r.call(this,n)}return this.length>>>0}}),Object.defineProperty(Array.prototype,"random",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.random called on null or undefined");var e=this.length>>>0;if(0!==e){return this[0===arguments.length?_random(0,e-1):_randomIndex(e,[].concat(Array.prototype.slice.call(arguments)))]}}}),Object.defineProperty(Array.prototype,"randomMany",{configurable:!0,writable:!0,value:function(e){if(null==this)throw new TypeError("Array.prototype.randomMany called on null or undefined");var t=this.length>>>0;if(0===t)return[];var r=Math.trunc(e);if(!Number.isInteger(r))throw new Error("Array.prototype.randomMany want parameter must be an integer");if(r<1)return[];r>t&&(r=t);var a=new Map,n=[],i=t-1;do{var o=void 0;do{o=_random(0,i)}while(a.has(o));a.set(o,!0),n.push(this[o])}while(n.length<r);return n}}),Object.defineProperty(Array.prototype,"shuffle",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.shuffle called on null or undefined");var e=this.length>>>0;if(0===e)return this;for(var t=e-1;t>0;--t){var r=Math.floor(_nativeMathRandom()*(t+1));if(t!==r){var a=this[t];this[t]=this[r],this[r]=a}}return this}}),Object.defineProperty(Array.prototype,"unshiftUnique",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.unshiftUnique called on null or undefined");var e=arguments.length;if(0===e)return this.length>>>0;for(var t=Array.prototype.indexOf,r=Array.prototype.unshift,a=0;a<e;++a){var n=arguments[a];-1===t.call(this,n)&&r.call(this,n)}return this.length>>>0}}),Object.defineProperty(Function.prototype,"partial",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Function.prototype.partial called on null or undefined");var e=Array.prototype.slice,t=this,r=e.call(arguments,0);return function(){for(var a=[],n=0,i=0;i<r.length;++i)a.push(r[i]===undefined?arguments[n++]:r[i]);return t.apply(this,a.concat(e.call(arguments,n)))}}}),Object.defineProperty(Math,"clamp",{configurable:!0,writable:!0,value:function(e,t,r){var a=Number(e);return Number.isNaN(a)?NaN:a.clamp(t,r)}}),Object.defineProperty(Math,"easeInOut",{configurable:!0,writable:!0,value:function(e){return 1-(Math.cos(Number(e)*Math.PI)+1)/2}}),Object.defineProperty(Number.prototype,"clamp",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Number.prototype.clamp called on null or undefined");if(2!==arguments.length)throw new Error("Number.prototype.clamp called with an incorrect number of parameters");var e=Number(arguments[0]),t=Number(arguments[1]);if(e>t){var r=[t,e];e=r[0],t=r[1]}return Math.min(Math.max(this,e),t)}}),RegExp.escape||function(){var e=/[\\^$*+?.()|[\]{}]/g,t=new RegExp(e.source);Object.defineProperty(RegExp,"escape",{configurable:!0,writable:!0,value:function(r){var a=String(r);return a&&t.test(a)?a.replace(e,"\\$&"):a}})}(),function(){var e=/{(\d+)(?:,([+-]?\d+))?}/g,t=new RegExp(e.source);Object.defineProperty(String,"format",{configurable:!0,writable:!0,value:function(r){function a(e,t,r){if(!t)return e;var a=Math.abs(t)-e.length;if(a<1)return e;var n=String(r).repeat(a);return t<0?e+n:n+e}if(arguments.length<2)return 0===arguments.length?"":r;var n=2===arguments.length&&Array.isArray(arguments[1])?[].concat(_toConsumableArray(arguments[1])):Array.prototype.slice.call(arguments,1);return 0===n.length?r:t.test(r)?(e.lastIndex=0,r.replace(e,function(e,t,r){var i=n[t];if(null==i)return"";for(;"function"==typeof i;)i=i();switch(void 0===i?"undefined":_typeof(i)){case"string":break;case"object":i=JSON.stringify(i);break;default:i=String(i)}return a(i,r?Number.parseInt(r,10):0," ")})):r}})}(),Object.defineProperty(String.prototype,"contains",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.contains called on null or undefined");return-1!==String.prototype.indexOf.apply(this,arguments)}}),Object.defineProperty(String.prototype,"count",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.count called on null or undefined");var e=String(arguments[0]||"");if(""===e)return 0;for(var t=String.prototype.indexOf,r=e.length,a=Number(arguments[1])||0,n=0;-1!==(a=t.call(this,e,a));)++n,a+=r;return n}}),Object.defineProperty(String.prototype,"splice",{configurable:!0,writable:!0,value:function(e,t,r){if(null==this)throw new TypeError("String.prototype.splice called on null or undefined");var a=this.length>>>0;if(0===a)return"";var n=Number(e);Number.isSafeInteger(n)?n<0&&(n+=a)<0&&(n=0):n=0,n>a&&(n=a);var i=Number(t);(!Number.isSafeInteger(i)||i<0)&&(i=0);var o=this.slice(0,n);return void 0!==r&&(o+=r),n+i<a&&(o+=this.slice(n+i)),o}}),Object.defineProperty(String.prototype,"splitOrEmpty",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.splitOrEmpty called on null or undefined");return""===String(this)?[]:String.prototype.split.apply(this,arguments)}}),Object.defineProperty(String.prototype,"toLocaleUpperFirst",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.toLocaleUpperFirst called on null or undefined");var e=String(this),t=_getCodePointStartAndEnd(e,0),r=t.char,a=t.end;return-1===a?"":r.toLocaleUpperCase()+e.slice(a+1)}}),Object.defineProperty(String.prototype,"toUpperFirst",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.toUpperFirst called on null or undefined");var e=String(this),t=_getCodePointStartAndEnd(e,0),r=t.char,a=t.end;return-1===a?"":r.toUpperCase()+e.slice(a+1)}}),Object.defineProperty(Date.prototype,"toJSON",{configurable:!0,writable:!0,value:function(){return["(revive:date)",this.toISOString()]}}),Object.defineProperty(Function.prototype,"toJSON",{configurable:!0,writable:!0,value:function(){return["(revive:eval)","("+this.toString()+")"]}}),Object.defineProperty(Map.prototype,"toJSON",{configurable:!0,writable:!0,value:function(){return["(revive:map)",[].concat(_toConsumableArray(this))]}}),Object.defineProperty(RegExp.prototype,"toJSON",{configurable:!0,writable:!0,value:function(){return["(revive:eval)",this.toString()]}}),Object.defineProperty(Set.prototype,"toJSON",{configurable:!0,writable:!0,value:function(){return["(revive:set)",[].concat(_toConsumableArray(this))]}}),Object.defineProperty(JSON,"reviveWrapper",{configurable:!0,writable:!0,value:function(e,t){if("string"!=typeof e)throw new TypeError("JSON.reviveWrapper code parameter must be a string");return["(revive:eval)",[e,t]]}}),Object.defineProperty(JSON,"_real_parse",{value:JSON.parse}),Object.defineProperty(JSON,"parse",{configurable:!0,writable:!0,value:function value(text,reviver){return JSON._real_parse(text,function(key,val){var value=val;if(Array.isArray(value)&&2===value.length)switch(value[0]){case"(revive:set)":value=new Set(value[1]);break;case"(revive:map)":value=new Map(value[1]);break;case"(revive:date)":value=new Date(value[1]);break;case"(revive:eval)":try{if(Array.isArray(value[1])){var $ReviveData$=value[1][1];value=eval(value[1][0])}else value=eval(value[1])}catch(e){}}else if("string"==typeof value&&"@@revive@@"===value.slice(0,10))try{value=eval(value.slice(10))}catch(e){}if("function"==typeof reviver)try{value=reviver(key,value)}catch(e){}return value})}}),Object.defineProperty(Array.prototype,"contains",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.contains called on null or undefined");return Array.prototype.includes.apply(this,arguments)}}),Object.defineProperty(Array.prototype,"containsAll",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.containsAll called on null or undefined");return Array.prototype.includesAll.apply(this,arguments)}}),Object.defineProperty(Array.prototype,"containsAny",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.containsAny called on null or undefined");return Array.prototype.includesAny.apply(this,arguments)}}),Object.defineProperty(String.prototype,"readBracketedList",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.readBracketedList called on null or undefined");for(var e=new RegExp("(?:\\[\\[((?:\\s|\\S)*?)\\]\\])|([^\"'\\s]\\S*)","gm"),t=[],r=void 0;null!==(r=e.exec(this));)r[1]?t.push(r[1]):r[2]&&t.push(r[2]);return t}})}();var Browser=function(){var e=navigator.userAgent.toLowerCase(),t=e.includes("windows phone"),r=Object.freeze({Android:!t&&e.includes("android"),BlackBerry:/blackberry|bb10/.test(e),iOS:!t&&/ip(?:hone|ad|od)/.test(e),Windows:t||e.includes("iemobile"),any:function(){return r.Android||r.BlackBerry||r.iOS||r.Windows}}),a=!r.Windows&&!/khtml|trident|edge/.test(e)&&e.includes("gecko"),n=!e.includes("opera")&&/msie|trident/.test(e),i=n?function(){var t=/(?:msie\s+|rv:)(\d+\.\d)/.exec(e);return t?Number(t[1]):0}():null,o=e.includes("opera")||e.includes(" opr/"),s=o?function(){var t=new RegExp((/khtml|chrome/.test(e)?"opr":"version")+"\\/(\\d+\\.\\d+)"),r=t.exec(e);return r?Number(r[1]):0}():null;return Object.freeze({userAgent:e,isMobile:r,isGecko:a,isIE:n,ieVersion:i,isOpera:o,operaVersion:s})}(),Has=function(){var e=function(){try{return"function"==typeof document.createElement("audio").canPlayType}catch(e){}return!1}(),t=function(){try{return"Blob"in window&&"File"in window&&"FileList"in window&&"FileReader"in window&&!Browser.isMobile.any()&&(!Browser.isOpera||Browser.operaVersion>=15)}catch(e){}return!1}(),r=function(){try{return"geolocation"in navigator&&"function"==typeof navigator.geolocation.getCurrentPosition&&"function"==typeof navigator.geolocation.watchPosition}catch(e){}return!1}(),a=function(){try{return"MutationObserver"in window&&"function"==typeof window.MutationObserver}catch(e){}return!1}(),n=function(){try{return"performance"in window&&"function"==typeof window.performance.now}catch(e){}return!1}();return Object.freeze({audio:e,fileAPI:t,geolocation:r,mutationObserver:a,performance:n})}(),_ref3=function(){function e(t){if("object"!==(void 0===t?"undefined":_typeof(t))||null===t)return t;if(t instanceof String)return String(t);if(t instanceof Number)return Number(t);if(t instanceof Boolean)return Boolean(t);if("function"==typeof t.clone)return t.clone(!0);if(t.nodeType&&"function"==typeof t.cloneNode)return t.cloneNode(!0);var r=void 0;return t instanceof Array?r=new Array(t.length):t instanceof Date?r=new Date(t.getTime()):t instanceof Map?(r=new Map,t.forEach(function(t,a){return r.set(a,e(t))})):t instanceof RegExp?r=new RegExp(t):t instanceof Set?(r=new Set,t.forEach(function(t){return r.add(e(t))})):r=Object.create(Object.getPrototypeOf(t)),Object.keys(t).forEach(function(a){return r[a]=e(t[a])}),r}function t(e){for(var t=document.createDocumentFragment(),r=document.createElement("p"),a=void 0;null!==(a=e.firstChild);){if(a.nodeType===Node.ELEMENT_NODE){switch(a.nodeName.toUpperCase()){case"BR":if(null!==a.nextSibling&&a.nextSibling.nodeType===Node.ELEMENT_NODE&&"BR"===a.nextSibling.nodeName.toUpperCase()){e.removeChild(a.nextSibling),e.removeChild(a),t.appendChild(r),r=document.createElement("p");continue}if(!r.hasChildNodes()){e.removeChild(a);continue}break;case"ADDRESS":case"ARTICLE":case"ASIDE":case"BLOCKQUOTE":case"CENTER":case"DIV":case"DL":case"FIGURE":case"FOOTER":case"FORM":case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":case"HEADER":case"HR":case"MAIN":case"NAV":case"OL":case"P":case"PRE":case"SECTION":case"TABLE":case"UL":r.hasChildNodes()&&(t.appendChild(r),r=document.createElement("p")),t.appendChild(a);continue}}r.appendChild(a)}r.hasChildNodes()&&t.appendChild(r),e.appendChild(t)}function r(){try{return document.activeElement||null}catch(e){return null}}function a(e,t,r){var a="object"===(void 0===e?"undefined":_typeof(e))?e:document.getElementById(e);if(null==a)return null;var n=Array.isArray(t)?t:[t];jQuery(a).empty();for(var i=0,o=n.length;i<o;++i)if(Story.has(n[i]))return new Wikifier(a,Story.get(n[i]).processText().trim()),a;if(null!=r){var s=String(r).trim();""!==s&&new Wikifier(a,s)}return a}function n(e,t,r){var a=jQuery(document.createElement("div")),n=jQuery(document.createElement("button")),i=jQuery(document.createElement("pre")),o=L10n.get("errorTitle")+": "+(t||"unknown error");return n.addClass("error-toggle").ariaClick({label:L10n.get("errorToggle")},function(){n.hasClass("enabled")?(n.removeClass("enabled"),i.attr({"aria-hidden":!0,hidden:"hidden"})):(n.addClass("enabled"),i.removeAttr("aria-hidden hidden"))}).appendTo(a),jQuery(document.createElement("span")).addClass("error").text(o).appendTo(a),jQuery(document.createElement("code")).text(r).appendTo(i),i.addClass("error-source").attr({"aria-hidden":!0,hidden:"hidden"}).appendTo(a),a.addClass("error-view").appendTo(e),console.warn(o+"\n\t"+r.replace(/\n/g,"\n\t")),!1}function i(e,t){var r=i;switch(void 0===e?"undefined":_typeof(e)){case"number":if(Number.isNaN(e))return t;break;case"object":if(null===e)return t;if(Array.isArray(e))return e.map(function(e){return r(e,t)}).join(", ");if(e instanceof Set)return[].concat(_toConsumableArray(e)).map(function(e){return r(e,t)}).join(", ");if(e instanceof Map){return"{ "+[].concat(_toConsumableArray(e)).map(function(e){var a=_slicedToArray(e,2),n=a[0],i=a[1];return r(n,t)+" → "+r(i,t)}).join(", ")+" }"}return e instanceof Date?e.toLocaleString():"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e);case"function":case"undefined":return t}return String(e)}return Object.freeze(Object.defineProperties({},{clone:{value:e},convertBreaks:{value:t},safeActiveElement:{value:r},setPageElement:{value:a},throwError:{value:n},toStringOrDefault:{value:i}}))}(),clone=_ref3.clone,convertBreaks=_ref3.convertBreaks,safeActiveElement=_ref3.safeActiveElement,setPageElement=_ref3.setPageElement,throwError=_ref3.throwError,toStringOrDefault=_ref3.toStringOrDefault;!function(){function e(e){13!==e.which&&32!==e.which||(e.preventDefault(),jQuery(safeActiveElement()||this).trigger("click"))}function t(e){return function(){ - var t=jQuery(this); - const dataPassage = t.attr('data-passage'); + var t=jQuery(this); + const dataPassage = t.attr('data-passage'); + const initialDataPassage = window && window.SugarCube && window.SugarCube.State && window.SugarCube.State.passage; const savedYOffset = window.pageYOffset; t.is("[aria-pressed]")&&t.attr("aria-pressed","true"===t.attr("aria-pressed")?"false":"true"),e.apply(this,arguments); const doJump = function(){ window.scrollTo(0, savedYOffset); } - if ( dataPassage && (window.lastDataPassageLink === dataPassage)) + if ( dataPassage && (window.lastDataPassageLink === dataPassage || initialDataPassage === dataPassage)) doJump(); - else if (dataPassage && dataPassage.includes('Workaround')) { - doJump(); /* Horrible hack to workaround the workaround... */ - setTimeout(doJump, 10); setTimeout(doJump, 100); setTimeout(doJump, 300); - } window.lastDataPassageLink = dataPassage; }}function r(e){return t(function(){jQuery(this).off(".aria-clickable").removeAttr("tabindex aria-controls aria-pressed").not("a,button").removeAttr("role").end().filter("button").prop("disabled",!0),e.apply(this,arguments)})}jQuery.fn.extend({ariaClick:function(a,n){if(0===this.length||0===arguments.length)return this;var i=a,o=n;return null==o&&(o=i,i=undefined),i=jQuery.extend({namespace:undefined,one:!1,selector:undefined,data:undefined,controls:undefined,pressed:undefined,label:undefined},i),"string"!=typeof i.namespace?i.namespace="":"."!==i.namespace[0]&&(i.namespace="."+i.namespace),"boolean"==typeof i.pressed&&(i.pressed=i.pressed?"true":"false"),this.filter("button").prop("type","button"),this.not("a,button").attr("role","button"),this.attr("tabindex",0),null!=i.controls&&this.attr("aria-controls",i.controls),null!=i.pressed&&this.attr("aria-pressed",i.pressed),null!=i.label&&this.attr({"aria-label":i.label,title:i.label}),this.not("button").on("keypress.aria-clickable"+i.namespace,i.selector,e),this.on("click.aria-clickable"+i.namespace,i.selector,i.data,i.one?r(o):t(o)),this}})}(),function(){jQuery.extend({wikiWithOptions:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];if(0!==r.length){var n=document.createDocumentFragment();r.forEach(function(t){return new Wikifier(n,t,e)});var i=[].concat(_toConsumableArray(n.querySelectorAll(".error"))).map(function(e){return e.textContent.replace(errorPrologRegExp,"")});if(i.length>0)throw new Error(i.join("; "))}},wiki:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];this.wikiWithOptions.apply(this,[undefined].concat(t))}}),jQuery.fn.extend({wikiWithOptions:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];if(0===this.length||0===r.length)return this;var n=document.createDocumentFragment();return r.forEach(function(t){return new Wikifier(n,t,e)}),this.append(n),this},wiki:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.wikiWithOptions.apply(this,[undefined].concat(t))}})}();var Util=function(){function e(e){return Object.freeze(Object.assign(Object.create(null),e))}function t(e){return Object.prototype.toString.call(e).slice(8,-1)}function r(e){var t=void 0;switch(void 0===e?"undefined":_typeof(e)){case"number":t=e;break;case"string":t=Number(e);break;default:return!1}return!Number.isNaN(t)&&Number.isFinite(t)}function a(e){return"boolean"==typeof e||"string"==typeof e&&("true"===e||"false"===e)}function n(e){return String(e).trim().replace(/[^\w\s\u2013\u2014-]+/g,"").replace(/[_\s\u2013\u2014-]+/g,"-").toLocaleLowerCase()}function i(e){if(null==e)return"";var t=String(e);return t&&p.test(t)?t.replace(f,function(e){return g[e]}):t}function o(e){if(null==e)return"";var t=String(e);return t&&v.test(t)?t.replace(m,function(e){return y[e.toLowerCase()]}):t}function s(e,t){var r=String(e),a=Math.trunc(t),n=r.charCodeAt(a);if(Number.isNaN(n))return{char:"",start:-1,end:-1};var i={char:r.charAt(a),start:a,end:a};if(n<55296||n>57343)return i;if(n>=55296&&n<=56319){var o=a+1;if(o>=r.length)return i;var s=r.charCodeAt(o);return s<56320||s>57343?i:(i.char=i.char+r.charAt(o),i.end=o,i)}if(0===a)return i;var u=a-1,l=r.charCodeAt(u);return l<55296||l>56319?i:(i.char=r.charAt(u)+i.char,i.start=u,i)}function u(){return b.now()}function l(e){var t=w.exec(String(e));if(null===t)throw new SyntaxError('invalid time value syntax: "'+e+'"');var r=Number(t[1]);if(1===t[2].length&&(r*=1e3),Number.isNaN(r)||!Number.isFinite(r))throw new RangeError('invalid time value: "'+e+'"');return r}function c(e){if("number"!=typeof e||Number.isNaN(e)||!Number.isFinite(e)){var r=void 0;switch(void 0===e?"undefined":_typeof(e)){case"string":r='"'+e+'"';break;case"number":r=String(e);break;default:r=t(e)}throw new Error("invalid milliseconds: "+r)}return e+"ms"}function d(e){if(!e.includes("-"))switch(e){case"bgcolor":return"backgroundColor";case"float":return"cssFloat";default:return e}return("-ms-"===e.slice(0,4)?e.slice(1):e).split("-").map(function(e,t){return 0===t?e:e.toUpperFirst()}).join("")}function h(e){var t=document.createElement("a"),r=Object.create(null);t.href=e,t.search&&t.search.replace(/^\?/,"").splitOrEmpty(/(?:&(?:amp;)?|;)/).forEach(function(e){var t=e.split("="),a=_slicedToArray(t,2),n=a[0],i=a[1];r[n]=i});var a=t.host&&"/"!==t.pathname[0]?"/"+t.pathname:t.pathname;return{href:t.href,protocol:t.protocol,host:t.host,hostname:t.hostname,port:t.port,path:""+a+t.search,pathname:a,query:t.search,search:t.search,queries:r,searches:r,hash:t.hash}}var f=/[&<>"'`]/g,p=new RegExp(f.source),g=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"}),m=/&(?:amp|#38|#x26|lt|#60|#x3c|gt|#62|#x3e|quot|#34|#x22|apos|#39|#x27|#96|#x60);/gi,v=new RegExp(m.source,"i"),y=Object.freeze({"&":"&","&":"&","&":"&","<":"<","<":"<","<":"<",">":">",">":">",">":">",""":'"',""":'"',""":'"',"'":"'","'":"'","'":"'","`":"`","`":"`"}),b=Has.performance?performance:Date,w=/^([+-]?(?:\d*\.)?\d+)([Mm]?[Ss])$/;return Object.freeze(Object.defineProperties({},{toEnum:{value:e},toStringTag:{value:t},isNumeric:{value:r},isBoolean:{value:a},slugify:{value:n},escape:{value:i},unescape:{value:o},charAndPosAt:{value:s},fromCssTime:{value:l},toCssTime:{value:c},fromCssProperty:{value:d},parseUrl:{value:h},now:{value:u},random:{value:Math.random},entityEncode:{value:i},entityDecode:{value:o}, evalExpression:{value:function(){return Scripting.evalJavaScript.apply(Scripting,arguments)}},evalStatements:{value:function(){return Scripting.evalJavaScript.apply(Scripting,arguments)}}}))}(),SimpleAudio=function(){function e(){return g}function t(e){g=!!e,l("mute",g)}function r(){return f}function a(e){f=Math.clamp(e,.2,5),l("rate",f)}function n(){return p}function i(e){p=Math.clamp(e,0,1),l("volume",p)}function o(){l("stop")}function s(e,t){if("function"!=typeof t)throw new Error("callback parameter must be a function");h.set(e,t)}function u(e){h.delete(e)}function l(e,t){h.forEach(function(r){return r(e,t)})}function c(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return new(Function.prototype.bind.apply(m,[null].concat(t)))}function d(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return new(Function.prototype.bind.apply(v,[null].concat(t)))}var h=new Map,f=1,p=1,g=!1,m=function(){function e(t){if(_classCallCheck(this,e),Array.isArray(t))this._create(t);else{if(!(t instanceof e))throw new Error("sources parameter must be an array of either URLs or source objects");this._copy(t)}}return _createClass(e,[{key:"_create",value:function(t){if(!Array.isArray(t)||0===t.length)throw new Error("sources parameter must be an array of either URLs or source objects");var r=/^data:\s*audio\/([^;,]+)\s*[;,]/i,a=/\.([^.\/\\]+)$/,n=e.getType,i=[],o=document.createElement("audio");if(t.forEach(function(e){var t=null;switch(void 0===e?"undefined":_typeof(e)){case"string":var s=void 0;if("data:"===e.slice(0,5)){if(null===(s=r.exec(e)))throw new Error("source data URI missing media type")}else if(null===(s=a.exec(Util.parseUrl(e).pathname)))throw new Error("source URL missing file extension");var u=n(s[1]);null!==u&&(t={src:e,type:u});break;case"object":if(null===e)throw new Error("source object cannot be null");if(!e.hasOwnProperty("src"))throw new Error('source object missing required "src" property');if(!e.hasOwnProperty("format"))throw new Error('source object missing required "format" property');var l=n(e.format);null!==l&&(t={src:e.src,type:l});break;default:throw new Error("invalid source value (type: "+(void 0===e?"undefined":_typeof(e))+")")}if(null!==t){var c=document.createElement("source");c.src=t.src,c.type=Browser.isOpera?t.type.replace(/;.*$/,""):t.type,o.appendChild(c),i.push(t)}}),!o.hasChildNodes())if(Browser.isIE)o.src=undefined;else{var s=document.createElement("source");s.src=undefined,s.type=undefined,o.appendChild(s)}this._finalize(o,i,clone(t))}},{key:"_copy",value:function(t){if(!(t instanceof e))throw new Error("original parameter must be an instance of AudioWrapper");this._finalize(t.audio.cloneNode(!0),clone(t.sources),clone(t.originalSources))}},{key:"_finalize",value:function(e,t,r){var a=this;Object.defineProperties(this,{audio:{configurable:!0,value:e},sources:{configurable:!0,value:Object.freeze(t)},originalSources:{configurable:!0,value:Object.freeze(r)},_error:{writable:!0,value:!1},_faderId:{writable:!0,value:null},_mute:{writable:!0,value:!1},_rate:{writable:!0,value:1},_volume:{writable:!0,value:1}}),jQuery(this.audio).on("loadstart",function(){return a._error=!1}).on("error",function(){return a._error=!0}).find("source:last-of-type").on("error",function(){return a._trigger("error")}),SimpleAudio.subscribe(this,function(e){if(!a.audio)return void SimpleAudio.unsubscribe(a);switch(e){case"mute":a._updateAudioMute();break;case"rate":a._updateAudioRate();break;case"stop":a.stop();break;case"volume":a._updateAudioVolume()}}),this.load()}},{key:"_trigger",value:function(e){jQuery(this.audio).triggerHandler(e)}},{key:"clone",value:function(){return new e(this)}},{key:"destroy",value:function(){SimpleAudio.unsubscribe(this);var e=this.audio;if(e){for(this.fadeStop(),this.stop(),jQuery(e).off();e.hasChildNodes();)e.removeChild(e.firstChild);e.load(),this._error=!0,delete this.audio,delete this.sources,delete this.originalSources}}},{key:"_updateAudioMute",value:function(){this.audio&&(this.audio.muted=this._mute||SimpleAudio.mute)}},{key:"_updateAudioRate",value:function(){this.audio&&(this.audio.playbackRate=this._rate*SimpleAudio.rate)}},{key:"_updateAudioVolume",value:function(){this.audio&&(this.audio.volume=this._volume*SimpleAudio.volume)}},{key:"hasSource",value:function(){return this.sources.length>0}},{key:"hasNoData",value:function(){return!this.audio||this.audio.readyState===HTMLMediaElement.HAVE_NOTHING}},{key:"hasMetadata",value:function(){return!!this.audio&&this.audio.readyState>=HTMLMediaElement.HAVE_METADATA}},{key:"hasSomeData",value:function(){return!!this.audio&&this.audio.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA}},{key:"hasData",value:function(){return!!this.audio&&this.audio.readyState===HTMLMediaElement.HAVE_ENOUGH_DATA}},{key:"isFailed",value:function(){return this._error}},{key:"isLoading",value:function(){return!!this.audio&&this.audio.networkState===HTMLMediaElement.NETWORK_LOADING}},{key:"isPlaying",value:function(){return!!this.audio&&!(this.audio.ended||this.audio.paused||!this.hasSomeData())}},{key:"isPaused",value:function(){return!!this.audio&&(this.audio.paused&&(this.audio.duration===1/0||this.audio.currentTime>0)&&!this.audio.ended)}},{key:"isEnded",value:function(){return!this.audio||this.audio.ended}},{key:"isFading",value:function(){return null!==this._faderId}},{key:"isMuted",value:function(){return this._mute}},{key:"isLooped",value:function(){return!!this.audio&&this.audio.loop}},{key:"load",value:function(){this.audio&&("auto"!==this.audio.preload&&(this.audio.preload="auto"),this.isLoading()||this.audio.load())}},{key:"play",value:function(){this.audio&&this.audio.play()}},{key:"pause",value:function(){this.audio&&this.audio.pause()}},{key:"stop",value:function(){this.audio&&(this.pause(),this.time=0,this._trigger(":stop"))}},{key:"fadeWithDuration",value:function(e,t,r){var a=this;if(this.audio){this.fadeStop();var n=Math.clamp(null==r?this.volume:r,0,1),i=Math.clamp(t,0,1);n!==i&&(this.volume=n,jQuery(this.audio).off("timeupdate.AudioWrapper:fadeWithDuration").one("timeupdate.AudioWrapper:fadeWithDuration",function(){var t=void 0,r=void 0;n<i?(t=n,r=i):(t=i,r=n);var o=Number(e);o<1&&(o=1);var s=(i-n)/(o/.025);a._faderId=setInterval(function(){if(!a.isPlaying())return void a.fadeStop();a.volume=Math.clamp(a.volume+s,t,r),0===a.volume&&a.pause(),a.volume===i&&(a.fadeStop(),a._trigger(":fade"))},25)}),this.play())}}},{key:"fade",value:function(e,t){this.fadeWithDuration(5,e,t)}},{key:"fadeIn",value:function(){this.fade(1)}},{key:"fadeOut",value:function(){this.fade(0)}},{key:"fadeStop",value:function(){null!==this._faderId&&(clearInterval(this._faderId),this._faderId=null)}},{key:"on",value:function(t,r){if(this.audio){if("function"!=typeof r)throw new Error("listener parameter must be a function");var a=e._events,n=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(!a.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(a).join(", "));return e.replace(t,a[t])+".AudioWrapperEvent"}).join(" ");if(""===n)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).on(n,r),this}}},{key:"one",value:function(t,r){if(this.audio){if("function"!=typeof r)throw new Error("listener parameter must be a function");var a=e._events,n=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(!a.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(a).join(", "));return e.replace(t,a[t])+".AudioWrapperEvent"}).join(" ");if(""===n)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).one(n,r),this}}},{key:"off",value:function(t,r){if(this.audio){if(r&&"function"!=typeof r)throw new Error("listener parameter must be a function");if(!t)return jQuery(this.audio).off(".AudioWrapperEvent",r);var a=e._events,n=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(t){if(!a.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(a).join(", "));return e.replace(t,a[t])+".AudioWrapperEvent"}return e+".AudioWrapperEvent"}).join(" ");if(""===n)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).off(n,r),this}}},{key:"duration",get:function(){return this.audio?this.audio.duration:NaN}},{key:"ended",get:function(){return!this.audio||this.audio.ended}},{key:"loop",get:function(){return!!this.audio&&this.audio.loop},set:function(e){this.audio&&(this.audio.loop=!!e)}},{key:"mute",get:function(){return this._mute},set:function(e){this._mute=!!e,this._updateAudioMute()}},{key:"paused",get:function(){return!!this.audio&&this.audio.paused}},{key:"rate",get:function(){return this._rate},set:function(e){this._rate=Math.clamp(e,.2,5),this._updateAudioRate()}},{key:"remaining",get:function(){return this.audio?this.audio.duration-this.audio.currentTime:NaN}},{key:"time",get:function(){return this.audio?this.audio.currentTime:NaN},set:function(e){var t=this;if(this.audio)try{this.audio.currentTime=e}catch(r){jQuery(this.audio).off("loadedmetadata.AudioWrapper:time").one("loadedmetadata.AudioWrapper:time",function(){return t.audio.currentTime=e})}}},{key:"volume",get:function(){return this._volume},set:function(e){this._volume=Math.clamp(e,0,1),this._updateAudioVolume()}}],[{key:"_verifyType",value:function(t){if(!t||!Has.audio)return null;var r=e._types;if(!r.hasOwnProperty(t)){var a=document.createElement("audio");r[t]=""!==a.canPlayType(t).replace(/^no$/i,"")}return r[t]?t:null}},{key:"getType",value:function(t){if(!t||!Has.audio)return null;var r=e.formats,a=t.toLowerCase(),n=r.hasOwnProperty(a)?r[a]:"audio/"+a;return e._verifyType(n)}},{key:"canPlayFormat",value:function(t){return null!==e.getType(t)}},{key:"canPlayType",value:function(t){return null!==e._verifyType(t)}}]),e}();Object.defineProperties(m,{formats:{value:{aac:"audio/aac",caf:"audio/x-caf","x-caf":"audio/x-caf",mp3:'audio/mpeg; codecs="mp3"',mpeg:'audio/mpeg; codecs="mp3"',m4a:"audio/mp4",mp4:"audio/mp4","x-m4a":"audio/mp4","x-mp4":"audio/mp4",oga:"audio/ogg",ogg:"audio/ogg",opus:'audio/ogg; codecs="opus"',wav:"audio/wav",wave:"audio/wav",weba:"audio/webm",webm:"audio/webm"}},_types:{value:{}},_events:{value:Object.freeze({canplay:"canplaythrough",end:"ended",error:"error",fade:":fade",pause:"pause",play:"playing",rate:"ratechange",seek:"seeked",stop:":stop",volume:"volumechange"})}});var v=function(){function e(t){var r=this;_classCallCheck(this,e),Object.defineProperties(this,{tracks:{configurable:!0,value:[]},queue:{configurable:!0,value:[]},current:{writable:!0,value:null},_rate:{writable:!0,value:1},_volume:{writable:!0,value:1},_mute:{writable:!0,value:!1},_loop:{writable:!0,value:!1},_shuffle:{writable:!0,value:!1}}),Array.isArray(t)?t.forEach(function(e){return r.add(e)}):t instanceof e&&t.tracks.forEach(function(e){return r.add(e)})}return _createClass(e,[{key:"add",value:function(e){var t=this;if(null==e||"object"!==(void 0===e?"undefined":_typeof(e)))throw new Error("track parameter must be an object");var r=void 0,a=void 0,n=void 0,i=void 0;if(e instanceof m)r=!0,a=e.clone(),n=e.volume,i=e.rate;else{if(!e.hasOwnProperty("track"))throw new Error('track object missing required "track" property');if(!(e.track instanceof m))throw new Error('track object\'s "track" property must be an AudioWrapper object');r=e.hasOwnProperty("copy")&&e.copy,a=r?e.track.clone():e.track,n=e.hasOwnProperty("volume")?e.volume:e.track.volume,i=e.hasOwnProperty("rate")?e.rate:e.track.rate}a.stop(),a.loop=!1,a.mute=!1,a.volume=n,a.rate=i,a.on("end.AudioListEvent",function(){return t._onEnd()}),this.tracks.push({copy:r,track:a,volume:n,rate:i})}},{key:"destroy",value:function(){this.stop(),this.tracks.filter(function(e){return e.copy}).forEach(function(e){return e.track.destroy()}),delete this.tracks,delete this.queue}},{key:"isPlaying",value:function(){return null!==this.current&&this.current.track.isPlaying()}},{key:"isEnded",value:function(){return 0===this.queue.length&&(null===this.current||this.current.track.isEnded())}},{key:"isPaused",value:function(){return null===this.current||this.current.track.isPaused()}},{key:"isMuted",value:function(){return this._mute}},{key:"isLooped",value:function(){return this._loop}},{key:"isShuffled",value:function(){return this._shuffle}},{key:"play",value:function(){(null!==this.current&&!this.current.track.isEnded()||(0===this.queue.length&&this._buildList(),this._next()))&&this.current.track.play()}},{key:"pause",value:function(){null!==this.current&&this.current.track.pause()}},{key:"stop",value:function(){null!==this.current&&(this.current.track.stop(),this.current=null),this.queue.splice(0)}},{key:"skip",value:function(){this._next()?this.current.track.play():this._loop&&this.play()}},{key:"fadeWithDuration",value:function(e,t,r){if(0===this.queue.length&&this._buildList(),null!==this.current&&!this.current.track.isEnded()||this._next()){var a=Math.clamp(t,0,1)*this.current.volume,n=void 0;null!=r&&(n=Math.clamp(r,0,1)*this.current.volume),this.current.track.fadeWithDuration(e,a,n),this._volume=t}}},{key:"fade",value:function(e,t){this.fadeWithDuration(5,e,t)}},{key:"fadeIn",value:function(){this.fade(1)}},{key:"fadeOut",value:function(){this.fade(0)}},{key:"_next",value:function(){return null!==this.current&&this.current.track.stop(),0===this.queue.length?(this.current=null,!1):(this.current=this.queue.shift(),!this.current.track.hasSource()||this.current.track.isFailed()?this._next():(this.current.track.mute=this._mute,this.current.track.rate=this.rate*this.current.rate,this.current.track.volume=this.volume*this.current.volume,!0))}},{key:"_onEnd",value:function(){if(0===this.queue.length){if(!this._loop)return;this._buildList()}this._next()&&this.current.track.play()}},{key:"_buildList",value:function(){var e;this.queue.splice(0),(e=this.queue).push.apply(e,_toConsumableArray(this.tracks)),0!==this.queue.length&&this._shuffle&&(this.queue.shuffle(),this.queue.length>1&&this.queue[0]===this.current&&this.queue.push(this.queue.shift()))}},{key:"duration",get:function(){return this.tracks.map(function(e){return e.track.duration}).reduce(function(e,t){return e+t},0)}},{key:"loop",get:function(){return this._loop},set:function(e){this._loop=!!e}},{key:"mute",get:function(){return this._mute},set:function(e){this._mute=!!e,null!==this.current&&(this.current.track.mute=this._mute)}},{key:"rate",get:function(){return this._rate},set:function(e){this._rate=Math.clamp(e,.2,5),null!==this.current&&(this.current.track.rate=this.rate*this.current.rate)}},{key:"remaining",get:function(){var e=this.queue.map(function(e){return e.track.duration}).reduce(function(e,t){return e+t},0);return null!==this.current&&(e+=this.current.track.remaining),e}},{key:"shuffle",get:function(){return this._shuffle},set:function(e){this._shuffle=!!e}},{key:"time",get:function(){return this.duration-this.remaining}},{key:"volume",get:function(){return this._volume},set:function(e){this._volume=Math.clamp(e,0,1),null!==this.current&&(this.current.track.volume=this.volume*this.current.volume)}}]),e}();return Object.freeze(Object.defineProperties({},{mute:{get:e,set:t},rate:{get:r,set:a},volume:{get:n,set:i},stop:{value:o},subscribe:{value:s},unsubscribe:{value:u},publish:{value:l},create:{value:c},createList:{value:d}}))}(),SimpleStore=function(){function e(e,a){if(r)return r.create(e,a);for(var n=0;n<t.length;++n)if(t[n].init(e,a))return r=t[n],r.create(e,a);throw new Error("no valid storage adapters found")}var t=[],r=null;return Object.freeze(Object.defineProperties({},{adapters:{value:t},create:{value:e}}))}();SimpleStore.adapters.push(function(){function e(){function e(e){try{var t=window[e],r="_sc_"+String(Date.now());t.setItem(r,r);var a=t.getItem(r)===r;return t.removeItem(r),a}catch(e){}return!1}return r=e("localStorage")&&e("sessionStorage")}function t(e,t){if(!r)throw new Error("adapter not initialized");return new a(e,t)}var r=!1,a=function(){function e(t,r){_classCallCheck(this,e);var a=t+".",n=null,i=null;r?(n=window.localStorage,i="localStorage"):(n=window.sessionStorage,i="sessionStorage"),Object.defineProperties(this,{_engine:{value:n},_prefix:{value:a},_prefixRe:{value:new RegExp("^"+RegExp.escape(a))},name:{value:i},id:{value:t},persistent:{value:!!r}})}return _createClass(e,[{key:"size",value:function(){return this.keys().length}},{key:"keys",value:function(){for(var e=[],t=0;t<this._engine.length;++t){var r=this._engine.key(t);this._prefixRe.test(r)&&e.push(r.replace(this._prefixRe,""))}return e}},{key:"has",value:function(e){return!("string"!=typeof e||!e)&&this._engine.hasOwnProperty(this._prefix+e)}},{key:"get",value:function(t){if("string"!=typeof t||!t)return null;var r=this._engine.getItem(this._prefix+t);return null==r?null:e._deserialize(r)}},{key:"set",value:function(t,r){if("string"!=typeof t||!t)return!1;try{this._engine.setItem(this._prefix+t,e._serialize(r))}catch(e){throw/quota[_\s]?(?:exceeded|reached)/i.test(e.name)&&(e.message=this.name+" quota exceeded"),e}return!0}},{key:"delete",value:function(e){return!("string"!=typeof e||!e)&&(this._engine.removeItem(this._prefix+e),!0)}},{key:"clear",value:function(){for(var e=this.keys(),t=0,r=e.length;t<r;++t)this.delete(e[t]);return!0}},{key:"length",get:function(){return this.keys().length}}],[{key:"_serialize",value:function(e) diff --git a/devTools/tweeGo/storyFormats/sugarcube-2/header.html b/devTools/tweeGo/storyFormats/sugarcube-2/header.html index 7b2220405618010a392de163d87b2c93df79341a..25017cf00a53428e9cc5a372ac8a4861717bd46b 100644 --- a/devTools/tweeGo/storyFormats/sugarcube-2/header.html +++ b/devTools/tweeGo/storyFormats/sugarcube-2/header.html @@ -115,17 +115,14 @@ var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||f <script id="script-sugarcube" type="text/javascript"> /*! SugarCube JS */ if(document.documentElement.getAttribute("data-init")==="loading"){!function(window,document,jQuery,undefined){"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),_slicedToArray=function(){function e(e,t){var r=[],a=!0,n=!1,i=undefined;try{for(var o,s=e[Symbol.iterator]();!(a=(o=s.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){n=!0,i=e}finally{try{!a&&s.return&&s.return()}finally{if(n)throw i}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},errorPrologRegExp=/^(?:(?:uncaught\s+(?:exception:\s+)?)?error:\s+)+/i,Alert=function(){function e(e,t,r,a){var n="fatal"===e,i="Apologies! "+(n?"A fatal":"An")+" error has occurred.";i+=n?" Aborting.":" You may be able to continue, but some parts may not work properly.",null==t&&null==r||(i+="\n\nError",null!=t&&(i+=" ["+t+"]"),i+=null!=r?": "+r.replace(errorPrologRegExp,"")+".":": unknown error."),"object"===(void 0===a?"undefined":_typeof(a))&&a.stack&&(i+="\n\nStack Trace:\n"+a.stack),window.alert(i)}function t(t,r,a){e(null,t,r,a)}function r(t,r,a){e("fatal",t,r,a)}return function(e){window.onerror=function(a,n,i,o,s){"complete"===document.readyState?t(null,a,s):(r(null,a,s),window.onerror=e,"function"==typeof window.onerror&&window.onerror.apply(this,arguments))}}(window.onerror),Object.freeze(Object.defineProperties({},{error:{value:t},fatal:{value:r}}))}(),Patterns=function(){var e=function(){var e=new Map([[" ","\\u0020"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],[" ","\\u00a0"],[" ","\\u1680"],["á Ž","\\u180e"],[" ","\\u2000"],["â€","\\u2001"],[" ","\\u2002"],[" ","\\u2003"],[" ","\\u2004"],[" ","\\u2005"],[" ","\\u2006"],[" ","\\u2007"],[" ","\\u2008"],[" ","\\u2009"],[" ","\\u200a"],["\u2028","\\u2028"],["\u2029","\\u2029"],[" ","\\u202f"],["âŸ","\\u205f"],[" ","\\u3000"],["\ufeff","\\ufeff"]]),t=/\s/,r="";return e.forEach(function(e,a){t.test(a)||(r+=e)}),r?"[\\s"+r+"]":"\\s"}(),t="[0-9A-Z_a-z\\-\\u00c0-\\u00d6\\u00d8-\\u00f6\\u00f8-\\u00ff\\u0150\\u0170\\u0151\\u0171]",r=t.replace("\\-",""),a="("+t+"+)\\(([^\\)\\|\\n]+)\\):",n="("+t+"+):([^;\\|\\n]+);",i="((?:\\."+t+"+)+);",o="((?:#"+t+"+)+);",s=a+"|"+n+"|"+i+"|"+o;return Object.freeze({space:e,spaceNoTerminator:"[\\u0020\\f\\t\\v\\u00a0\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]",lineTerminator:"[\\n\\r\\u2028\\u2029]",anyLetter:t,anyLetterStrict:r,identifierFirstChar:"[$A-Z_a-z]",identifier:"[$A-Z_a-z][$0-9A-Z_a-z]*",variableSigil:"[$_]",variable:"[$_][$A-Z_a-z][$0-9A-Z_a-z]*",macroName:"[A-Za-z][\\w-]*|[=-]",cssImage:"\\[[<>]?[Ii][Mm][Gg]\\[(?:\\s|\\S)*?\\]\\]+",inlineCss:s,url:"(?:file|https?|mailto|ftp|javascript|irc|news|data):[^\\s'\"]+"})}();!function(){function e(e,t){var n=String(e);switch(t){case"start":return n&&r.test(n)?n.replace(r,""):n;case"end":return n&&a.test(n)?n.replace(a,""):n;default:throw new Error('_trimFrom called with incorrect where parameter value: "'+t+'"')}}function t(e,t){var r=Number.parseInt(e,10)||0;if(r<1)return"";var a=void 0===t?"":String(t);for(""===a&&(a=" ");a.length<r;){var n=a.length,i=r-n;a+=n>i?a.slice(0,i):a}return a.length>r&&(a=a.slice(0,r)),a}var r=/^[\s\u00A0\uFEFF][\s\u00A0\uFEFF]*/,a=/[\s\u00A0\uFEFF][\s\u00A0\uFEFF]*$/;Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");if(0===arguments.length)return!1;var e=this.length>>>0;if(0===e)return!1;var t=arguments[0],r=Number(arguments[1])||0;for(r<0&&(r=Math.max(0,e+r));r<e;++r){var a=this[r];if(t===a||t!==t&&a!==a)return!0}return!1}}),String.prototype.padStart||Object.defineProperty(String.prototype,"padStart",{configurable:!0,writable:!0,value:function(e,r){if(null==this)throw new TypeError("String.prototype.padStart called on null or undefined");var a=String(this),n=a.length,i=Number.parseInt(e,10);return i<=n?a:t(i-n,r)+a}}),String.prototype.padEnd||Object.defineProperty(String.prototype,"padEnd",{configurable:!0,writable:!0,value:function(e,r){if(null==this)throw new TypeError("String.prototype.padEnd called on null or undefined");var a=String(this),n=a.length,i=Number.parseInt(e,10);return i<=n?a:a+t(i-n,r)}}),String.prototype.trimStart||Object.defineProperty(String.prototype,"trimStart",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.trimStart called on null or undefined");return e(this,"start")}}),String.prototype.trimLeft||Object.defineProperty(String.prototype,"trimLeft",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.trimLeft called on null or undefined");return e(this,"start")}}),String.prototype.trimEnd||Object.defineProperty(String.prototype,"trimEnd",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.trimEnd called on null or undefined");return e(this,"end")}}),String.prototype.trimRight||Object.defineProperty(String.prototype,"trimRight",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.trimRight called on null or undefined");return e(this,"end")}})}(),function(){function _random(){var e=void 0,t=void 0;switch(arguments.length){case 0:throw new Error("_random called with insufficient parameters");case 1:e=0,t=arguments[0];break;default:e=arguments[0],t=arguments[1]}if(e>t){var r=[t,e];e=r[0],t=r[1]}return Math.floor(_nativeMathRandom()*(t-e+1))+e}function _randomIndex(e,t){var r=void 0,a=void 0;switch(t.length){case 1:r=0,a=e-1;break;case 2:r=0,a=Math.trunc(t[1]);break;default:r=Math.trunc(t[1]),a=Math.trunc(t[2])}return Number.isNaN(r)?r=0:!Number.isFinite(r)||r>=e?r=e-1:r<0&&(r=e+r)<0&&(r=0),Number.isNaN(a)?a=0:!Number.isFinite(a)||a>=e?a=e-1:a<0&&(a=e+a)<0&&(a=e-1),_random(r,a)}function _getCodePointStartAndEnd(e,t){var r=e.charCodeAt(t);if(Number.isNaN(r))return{char:"",start:-1,end:-1};if(r<55296||r>57343)return{char:e.charAt(t),start:t,end:t};if(r>=55296&&r<=56319){var a=t+1;if(a>=e.length)throw new Error("high surrogate without trailing low surrogate");var n=e.charCodeAt(a);if(n<56320||n>57343)throw new Error("high surrogate without trailing low surrogate");return{char:e.charAt(t)+e.charAt(a),start:t,end:a}}if(0===t)throw new Error("low surrogate without leading high surrogate");var i=t-1,o=e.charCodeAt(i);if(o<55296||o>56319)throw new Error("low surrogate without leading high surrogate");return{char:e.charAt(i)+e.charAt(t),start:i,end:t}}var _nativeMathRandom=Math.random;Object.defineProperty(Array,"random",{configurable:!0,writable:!0,value:function(e){if(null==e||"object"!==(void 0===e?"undefined":_typeof(e))||!Object.prototype.hasOwnProperty.call(e,"length"))throw new TypeError("Array.random array parameter must be an array or array-lke object");var t=e.length>>>0;if(0!==t){return e[0===arguments.length?_random(0,t-1):_randomIndex(t,Array.prototype.slice.call(arguments,1))]}}}),Object.defineProperty(Array.prototype,"concatUnique",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.concatUnique called on null or undefined");var e=Array.from(this);if(0===arguments.length)return e;var t=Array.prototype.reduce.call(arguments,function(e,t){return e.concat(t)},[]),r=t.length;if(0===r)return e;for(var a=Array.prototype.indexOf,n=Array.prototype.push,i=0;i<r;++i){var o=t[i];-1===a.call(e,o)&&n.call(e,o)}return e}}),Object.defineProperty(Array.prototype,"count",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.count called on null or undefined");for(var e=Array.prototype.indexOf,t=arguments[0],r=Number(arguments[1])||0,a=0;-1!==(r=e.call(this,t,r));)++a,++r;return a}}),Object.defineProperty(Array.prototype,"delete",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.delete called on null or undefined");if(0===arguments.length)return[];if(0==this.length>>>0)return[];for(var e=Array.prototype.indexOf,t=Array.prototype.push,r=Array.prototype.splice,a=Array.prototype.concat.apply([],arguments),n=[],i=0,o=a.length;i<o;++i)for(var s=a[i],u=0;-1!==(u=e.call(this,s,u));)t.apply(n,r.call(this,u,1));return n}}),Object.defineProperty(Array.prototype,"deleteAt",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.deleteAt called on null or undefined");if(0===arguments.length)return[];var e=this.length>>>0;if(0===e)return[];for(var t=Array.prototype.splice,r=[].concat(_toConsumableArray(new Set(Array.prototype.concat.apply([],arguments).map(function(t){return t<0?Math.max(0,e+t):t})).values())),a=[].concat(_toConsumableArray(r)).sort(function(e,t){return t-e}),n=[],i=0,o=r.length;i<o;++i)n[i]=this[r[i]];for(var s=0,u=a.length;s<u;++s)t.call(this,a[s],1);return n}}),Object.defineProperty(Array.prototype,"flatten",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.flatten called on null or undefined");return Array.prototype.reduce.call(this,function(e,t){return e.concat(Array.isArray(t)?t.flatten():t)},[])}}),Object.defineProperty(Array.prototype,"includesAll",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.includesAll called on null or undefined");if(1===arguments.length)return Array.isArray(arguments[0])?Array.prototype.includesAll.apply(this,arguments[0]):Array.prototype.includes.apply(this,arguments);for(var e=0,t=arguments.length;e<t;++e)if(!Array.prototype.some.call(this,function(e){return e===this.val||e!==e&&this.val!==this.val},{val:arguments[e]}))return!1;return!0}}),Object.defineProperty(Array.prototype,"includesAny",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.includesAny called on null or undefined");if(1===arguments.length)return Array.isArray(arguments[0])?Array.prototype.includesAny.apply(this,arguments[0]):Array.prototype.includes.apply(this,arguments);for(var e=0,t=arguments.length;e<t;++e)if(Array.prototype.some.call(this,function(e){return e===this.val||e!==e&&this.val!==this.val},{val:arguments[e]}))return!0;return!1}}),Object.defineProperty(Array.prototype,"pluck",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.pluck called on null or undefined");var e=this.length>>>0;if(0!==e){var t=0===arguments.length?_random(0,e-1):_randomIndex(e,[].concat(Array.prototype.slice.call(arguments)));return Array.prototype.splice.call(this,t,1)[0]}}}),Object.defineProperty(Array.prototype,"pluckMany",{configurable:!0,writable:!0,value:function(e){if(null==this)throw new TypeError("Array.prototype.pluckMany called on null or undefined");var t=this.length>>>0;if(0===t)return[];var r=Math.trunc(e);if(!Number.isInteger(r))throw new Error("Array.prototype.pluckMany want parameter must be an integer");if(r<1)return[];r>t&&(r=t);var a=Array.prototype.splice,n=[],i=t-1;do{n.push(a.call(this,_random(0,i--),1)[0])}while(n.length<r);return n}}),Object.defineProperty(Array.prototype,"pushUnique",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.pushUnique called on null or undefined");var e=arguments.length;if(0===e)return this.length>>>0;for(var t=Array.prototype.indexOf,r=Array.prototype.push,a=0;a<e;++a){var n=arguments[a];-1===t.call(this,n)&&r.call(this,n)}return this.length>>>0}}),Object.defineProperty(Array.prototype,"random",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.random called on null or undefined");var e=this.length>>>0;if(0!==e){return this[0===arguments.length?_random(0,e-1):_randomIndex(e,[].concat(Array.prototype.slice.call(arguments)))]}}}),Object.defineProperty(Array.prototype,"randomMany",{configurable:!0,writable:!0,value:function(e){if(null==this)throw new TypeError("Array.prototype.randomMany called on null or undefined");var t=this.length>>>0;if(0===t)return[];var r=Math.trunc(e);if(!Number.isInteger(r))throw new Error("Array.prototype.randomMany want parameter must be an integer");if(r<1)return[];r>t&&(r=t);var a=new Map,n=[],i=t-1;do{var o=void 0;do{o=_random(0,i)}while(a.has(o));a.set(o,!0),n.push(this[o])}while(n.length<r);return n}}),Object.defineProperty(Array.prototype,"shuffle",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.shuffle called on null or undefined");var e=this.length>>>0;if(0===e)return this;for(var t=e-1;t>0;--t){var r=Math.floor(_nativeMathRandom()*(t+1));if(t!==r){var a=this[t];this[t]=this[r],this[r]=a}}return this}}),Object.defineProperty(Array.prototype,"unshiftUnique",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.unshiftUnique called on null or undefined");var e=arguments.length;if(0===e)return this.length>>>0;for(var t=Array.prototype.indexOf,r=Array.prototype.unshift,a=0;a<e;++a){var n=arguments[a];-1===t.call(this,n)&&r.call(this,n)}return this.length>>>0}}),Object.defineProperty(Function.prototype,"partial",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Function.prototype.partial called on null or undefined");var e=Array.prototype.slice,t=this,r=e.call(arguments,0);return function(){for(var a=[],n=0,i=0;i<r.length;++i)a.push(r[i]===undefined?arguments[n++]:r[i]);return t.apply(this,a.concat(e.call(arguments,n)))}}}),Object.defineProperty(Math,"clamp",{configurable:!0,writable:!0,value:function(e,t,r){var a=Number(e);return Number.isNaN(a)?NaN:a.clamp(t,r)}}),Object.defineProperty(Math,"easeInOut",{configurable:!0,writable:!0,value:function(e){return 1-(Math.cos(Number(e)*Math.PI)+1)/2}}),Object.defineProperty(Number.prototype,"clamp",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Number.prototype.clamp called on null or undefined");if(2!==arguments.length)throw new Error("Number.prototype.clamp called with an incorrect number of parameters");var e=Number(arguments[0]),t=Number(arguments[1]);if(e>t){var r=[t,e];e=r[0],t=r[1]}return Math.min(Math.max(this,e),t)}}),RegExp.escape||function(){var e=/[\\^$*+?.()|[\]{}]/g,t=new RegExp(e.source);Object.defineProperty(RegExp,"escape",{configurable:!0,writable:!0,value:function(r){var a=String(r);return a&&t.test(a)?a.replace(e,"\\$&"):a}})}(),function(){var e=/{(\d+)(?:,([+-]?\d+))?}/g,t=new RegExp(e.source);Object.defineProperty(String,"format",{configurable:!0,writable:!0,value:function(r){function a(e,t,r){if(!t)return e;var a=Math.abs(t)-e.length;if(a<1)return e;var n=String(r).repeat(a);return t<0?e+n:n+e}if(arguments.length<2)return 0===arguments.length?"":r;var n=2===arguments.length&&Array.isArray(arguments[1])?[].concat(_toConsumableArray(arguments[1])):Array.prototype.slice.call(arguments,1);return 0===n.length?r:t.test(r)?(e.lastIndex=0,r.replace(e,function(e,t,r){var i=n[t];if(null==i)return"";for(;"function"==typeof i;)i=i();switch(void 0===i?"undefined":_typeof(i)){case"string":break;case"object":i=JSON.stringify(i);break;default:i=String(i)}return a(i,r?Number.parseInt(r,10):0," ")})):r}})}(),Object.defineProperty(String.prototype,"contains",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.contains called on null or undefined");return-1!==String.prototype.indexOf.apply(this,arguments)}}),Object.defineProperty(String.prototype,"count",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.count called on null or undefined");var e=String(arguments[0]||"");if(""===e)return 0;for(var t=String.prototype.indexOf,r=e.length,a=Number(arguments[1])||0,n=0;-1!==(a=t.call(this,e,a));)++n,a+=r;return n}}),Object.defineProperty(String.prototype,"splice",{configurable:!0,writable:!0,value:function(e,t,r){if(null==this)throw new TypeError("String.prototype.splice called on null or undefined");var a=this.length>>>0;if(0===a)return"";var n=Number(e);Number.isSafeInteger(n)?n<0&&(n+=a)<0&&(n=0):n=0,n>a&&(n=a);var i=Number(t);(!Number.isSafeInteger(i)||i<0)&&(i=0);var o=this.slice(0,n);return void 0!==r&&(o+=r),n+i<a&&(o+=this.slice(n+i)),o}}),Object.defineProperty(String.prototype,"splitOrEmpty",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.splitOrEmpty called on null or undefined");return""===String(this)?[]:String.prototype.split.apply(this,arguments)}}),Object.defineProperty(String.prototype,"toLocaleUpperFirst",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.toLocaleUpperFirst called on null or undefined");var e=String(this),t=_getCodePointStartAndEnd(e,0),r=t.char,a=t.end;return-1===a?"":r.toLocaleUpperCase()+e.slice(a+1)}}),Object.defineProperty(String.prototype,"toUpperFirst",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.toUpperFirst called on null or undefined");var e=String(this),t=_getCodePointStartAndEnd(e,0),r=t.char,a=t.end;return-1===a?"":r.toUpperCase()+e.slice(a+1)}}),Object.defineProperty(Date.prototype,"toJSON",{configurable:!0,writable:!0,value:function(){return["(revive:date)",this.toISOString()]}}),Object.defineProperty(Function.prototype,"toJSON",{configurable:!0,writable:!0,value:function(){return["(revive:eval)","("+this.toString()+")"]}}),Object.defineProperty(Map.prototype,"toJSON",{configurable:!0,writable:!0,value:function(){return["(revive:map)",[].concat(_toConsumableArray(this))]}}),Object.defineProperty(RegExp.prototype,"toJSON",{configurable:!0,writable:!0,value:function(){return["(revive:eval)",this.toString()]}}),Object.defineProperty(Set.prototype,"toJSON",{configurable:!0,writable:!0,value:function(){return["(revive:set)",[].concat(_toConsumableArray(this))]}}),Object.defineProperty(JSON,"reviveWrapper",{configurable:!0,writable:!0,value:function(e,t){if("string"!=typeof e)throw new TypeError("JSON.reviveWrapper code parameter must be a string");return["(revive:eval)",[e,t]]}}),Object.defineProperty(JSON,"_real_parse",{value:JSON.parse}),Object.defineProperty(JSON,"parse",{configurable:!0,writable:!0,value:function value(text,reviver){return JSON._real_parse(text,function(key,val){var value=val;if(Array.isArray(value)&&2===value.length)switch(value[0]){case"(revive:set)":value=new Set(value[1]);break;case"(revive:map)":value=new Map(value[1]);break;case"(revive:date)":value=new Date(value[1]);break;case"(revive:eval)":try{if(Array.isArray(value[1])){var $ReviveData$=value[1][1];value=eval(value[1][0])}else value=eval(value[1])}catch(e){}}else if("string"==typeof value&&"@@revive@@"===value.slice(0,10))try{value=eval(value.slice(10))}catch(e){}if("function"==typeof reviver)try{value=reviver(key,value)}catch(e){}return value})}}),Object.defineProperty(Array.prototype,"contains",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.contains called on null or undefined");return Array.prototype.includes.apply(this,arguments)}}),Object.defineProperty(Array.prototype,"containsAll",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.containsAll called on null or undefined");return Array.prototype.includesAll.apply(this,arguments)}}),Object.defineProperty(Array.prototype,"containsAny",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("Array.prototype.containsAny called on null or undefined");return Array.prototype.includesAny.apply(this,arguments)}}),Object.defineProperty(String.prototype,"readBracketedList",{configurable:!0,writable:!0,value:function(){if(null==this)throw new TypeError("String.prototype.readBracketedList called on null or undefined");for(var e=new RegExp("(?:\\[\\[((?:\\s|\\S)*?)\\]\\])|([^\"'\\s]\\S*)","gm"),t=[],r=void 0;null!==(r=e.exec(this));)r[1]?t.push(r[1]):r[2]&&t.push(r[2]);return t}})}();var Browser=function(){var e=navigator.userAgent.toLowerCase(),t=e.includes("windows phone"),r=Object.freeze({Android:!t&&e.includes("android"),BlackBerry:/blackberry|bb10/.test(e),iOS:!t&&/ip(?:hone|ad|od)/.test(e),Windows:t||e.includes("iemobile"),any:function(){return r.Android||r.BlackBerry||r.iOS||r.Windows}}),a=!r.Windows&&!/khtml|trident|edge/.test(e)&&e.includes("gecko"),n=!e.includes("opera")&&/msie|trident/.test(e),i=n?function(){var t=/(?:msie\s+|rv:)(\d+\.\d)/.exec(e);return t?Number(t[1]):0}():null,o=e.includes("opera")||e.includes(" opr/"),s=o?function(){var t=new RegExp((/khtml|chrome/.test(e)?"opr":"version")+"\\/(\\d+\\.\\d+)"),r=t.exec(e);return r?Number(r[1]):0}():null;return Object.freeze({userAgent:e,isMobile:r,isGecko:a,isIE:n,ieVersion:i,isOpera:o,operaVersion:s})}(),Has=function(){var e=function(){try{return"function"==typeof document.createElement("audio").canPlayType}catch(e){}return!1}(),t=function(){try{return"Blob"in window&&"File"in window&&"FileList"in window&&"FileReader"in window&&!Browser.isMobile.any()&&(!Browser.isOpera||Browser.operaVersion>=15)}catch(e){}return!1}(),r=function(){try{return"geolocation"in navigator&&"function"==typeof navigator.geolocation.getCurrentPosition&&"function"==typeof navigator.geolocation.watchPosition}catch(e){}return!1}(),a=function(){try{return"MutationObserver"in window&&"function"==typeof window.MutationObserver}catch(e){}return!1}(),n=function(){try{return"performance"in window&&"function"==typeof window.performance.now}catch(e){}return!1}();return Object.freeze({audio:e,fileAPI:t,geolocation:r,mutationObserver:a,performance:n})}(),_ref3=function(){function e(t){if("object"!==(void 0===t?"undefined":_typeof(t))||null===t)return t;if(t instanceof String)return String(t);if(t instanceof Number)return Number(t);if(t instanceof Boolean)return Boolean(t);if("function"==typeof t.clone)return t.clone(!0);if(t.nodeType&&"function"==typeof t.cloneNode)return t.cloneNode(!0);var r=void 0;return t instanceof Array?r=new Array(t.length):t instanceof Date?r=new Date(t.getTime()):t instanceof Map?(r=new Map,t.forEach(function(t,a){return r.set(a,e(t))})):t instanceof RegExp?r=new RegExp(t):t instanceof Set?(r=new Set,t.forEach(function(t){return r.add(e(t))})):r=Object.create(Object.getPrototypeOf(t)),Object.keys(t).forEach(function(a){return r[a]=e(t[a])}),r}function t(e){for(var t=document.createDocumentFragment(),r=document.createElement("p"),a=void 0;null!==(a=e.firstChild);){if(a.nodeType===Node.ELEMENT_NODE){switch(a.nodeName.toUpperCase()){case"BR":if(null!==a.nextSibling&&a.nextSibling.nodeType===Node.ELEMENT_NODE&&"BR"===a.nextSibling.nodeName.toUpperCase()){e.removeChild(a.nextSibling),e.removeChild(a),t.appendChild(r),r=document.createElement("p");continue}if(!r.hasChildNodes()){e.removeChild(a);continue}break;case"ADDRESS":case"ARTICLE":case"ASIDE":case"BLOCKQUOTE":case"CENTER":case"DIV":case"DL":case"FIGURE":case"FOOTER":case"FORM":case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":case"HEADER":case"HR":case"MAIN":case"NAV":case"OL":case"P":case"PRE":case"SECTION":case"TABLE":case"UL":r.hasChildNodes()&&(t.appendChild(r),r=document.createElement("p")),t.appendChild(a);continue}}r.appendChild(a)}r.hasChildNodes()&&t.appendChild(r),e.appendChild(t)}function r(){try{return document.activeElement||null}catch(e){return null}}function a(e,t,r){var a="object"===(void 0===e?"undefined":_typeof(e))?e:document.getElementById(e);if(null==a)return null;var n=Array.isArray(t)?t:[t];jQuery(a).empty();for(var i=0,o=n.length;i<o;++i)if(Story.has(n[i]))return new Wikifier(a,Story.get(n[i]).processText().trim()),a;if(null!=r){var s=String(r).trim();""!==s&&new Wikifier(a,s)}return a}function n(e,t,r){var a=jQuery(document.createElement("div")),n=jQuery(document.createElement("button")),i=jQuery(document.createElement("pre")),o=L10n.get("errorTitle")+": "+(t||"unknown error");return n.addClass("error-toggle").ariaClick({label:L10n.get("errorToggle")},function(){n.hasClass("enabled")?(n.removeClass("enabled"),i.attr({"aria-hidden":!0,hidden:"hidden"})):(n.addClass("enabled"),i.removeAttr("aria-hidden hidden"))}).appendTo(a),jQuery(document.createElement("span")).addClass("error").text(o).appendTo(a),jQuery(document.createElement("code")).text(r).appendTo(i),i.addClass("error-source").attr({"aria-hidden":!0,hidden:"hidden"}).appendTo(a),a.addClass("error-view").appendTo(e),console.warn(o+"\n\t"+r.replace(/\n/g,"\n\t")),!1}function i(e,t){var r=i;switch(void 0===e?"undefined":_typeof(e)){case"number":if(Number.isNaN(e))return t;break;case"object":if(null===e)return t;if(Array.isArray(e))return e.map(function(e){return r(e,t)}).join(", ");if(e instanceof Set)return[].concat(_toConsumableArray(e)).map(function(e){return r(e,t)}).join(", ");if(e instanceof Map){return"{ "+[].concat(_toConsumableArray(e)).map(function(e){var a=_slicedToArray(e,2),n=a[0],i=a[1];return r(n,t)+" → "+r(i,t)}).join(", ")+" }"}return e instanceof Date?e.toLocaleString():"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e);case"function":case"undefined":return t}return String(e)}return Object.freeze(Object.defineProperties({},{clone:{value:e},convertBreaks:{value:t},safeActiveElement:{value:r},setPageElement:{value:a},throwError:{value:n},toStringOrDefault:{value:i}}))}(),clone=_ref3.clone,convertBreaks=_ref3.convertBreaks,safeActiveElement=_ref3.safeActiveElement,setPageElement=_ref3.setPageElement,throwError=_ref3.throwError,toStringOrDefault=_ref3.toStringOrDefault;!function(){function e(e){13!==e.which&&32!==e.which||(e.preventDefault(),jQuery(safeActiveElement()||this).trigger("click"))}function t(e){return function(){ - var t=jQuery(this); - const dataPassage = t.attr('data-passage'); + var t=jQuery(this); + const dataPassage = t.attr('data-passage'); + const initialDataPassage = window && window.SugarCube && window.SugarCube.State && window.SugarCube.State.passage; const savedYOffset = window.pageYOffset; t.is("[aria-pressed]")&&t.attr("aria-pressed","true"===t.attr("aria-pressed")?"false":"true"),e.apply(this,arguments); const doJump = function(){ window.scrollTo(0, savedYOffset); } - if ( dataPassage && (window.lastDataPassageLink === dataPassage)) + if ( dataPassage && (window.lastDataPassageLink === dataPassage || initialDataPassage === dataPassage)) doJump(); - else if (dataPassage && dataPassage.includes('Workaround')) { - doJump(); /* Horrible hack to workaround the workaround... */ - setTimeout(doJump, 10); setTimeout(doJump, 100); setTimeout(doJump, 300); - } window.lastDataPassageLink = dataPassage; }}function r(e){return t(function(){jQuery(this).off(".aria-clickable").removeAttr("tabindex aria-controls aria-pressed").not("a,button").removeAttr("role").end().filter("button").prop("disabled",!0),e.apply(this,arguments)})}jQuery.fn.extend({ariaClick:function(a,n){if(0===this.length||0===arguments.length)return this;var i=a,o=n;return null==o&&(o=i,i=undefined),i=jQuery.extend({namespace:undefined,one:!1,selector:undefined,data:undefined,controls:undefined,pressed:undefined,label:undefined},i),"string"!=typeof i.namespace?i.namespace="":"."!==i.namespace[0]&&(i.namespace="."+i.namespace),"boolean"==typeof i.pressed&&(i.pressed=i.pressed?"true":"false"),this.filter("button").prop("type","button"),this.not("a,button").attr("role","button"),this.attr("tabindex",0),null!=i.controls&&this.attr("aria-controls",i.controls),null!=i.pressed&&this.attr("aria-pressed",i.pressed),null!=i.label&&this.attr({"aria-label":i.label,title:i.label}),this.not("button").on("keypress.aria-clickable"+i.namespace,i.selector,e),this.on("click.aria-clickable"+i.namespace,i.selector,i.data,i.one?r(o):t(o)),this}})}(),function(){jQuery.extend({wikiWithOptions:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];if(0!==r.length){var n=document.createDocumentFragment();r.forEach(function(t){return new Wikifier(n,t,e)});var i=[].concat(_toConsumableArray(n.querySelectorAll(".error"))).map(function(e){return e.textContent.replace(errorPrologRegExp,"")});if(i.length>0)throw new Error(i.join("; "))}},wiki:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];this.wikiWithOptions.apply(this,[undefined].concat(t))}}),jQuery.fn.extend({wikiWithOptions:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];if(0===this.length||0===r.length)return this;var n=document.createDocumentFragment();return r.forEach(function(t){return new Wikifier(n,t,e)}),this.append(n),this},wiki:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.wikiWithOptions.apply(this,[undefined].concat(t))}})}();var Util=function(){function e(e){return Object.freeze(Object.assign(Object.create(null),e))}function t(e){return Object.prototype.toString.call(e).slice(8,-1)}function r(e){var t=void 0;switch(void 0===e?"undefined":_typeof(e)){case"number":t=e;break;case"string":t=Number(e);break;default:return!1}return!Number.isNaN(t)&&Number.isFinite(t)}function a(e){return"boolean"==typeof e||"string"==typeof e&&("true"===e||"false"===e)}function n(e){return String(e).trim().replace(/[^\w\s\u2013\u2014-]+/g,"").replace(/[_\s\u2013\u2014-]+/g,"-").toLocaleLowerCase()}function i(e){if(null==e)return"";var t=String(e);return t&&p.test(t)?t.replace(f,function(e){return g[e]}):t}function o(e){if(null==e)return"";var t=String(e);return t&&v.test(t)?t.replace(m,function(e){return y[e.toLowerCase()]}):t}function s(e,t){var r=String(e),a=Math.trunc(t),n=r.charCodeAt(a);if(Number.isNaN(n))return{char:"",start:-1,end:-1};var i={char:r.charAt(a),start:a,end:a};if(n<55296||n>57343)return i;if(n>=55296&&n<=56319){var o=a+1;if(o>=r.length)return i;var s=r.charCodeAt(o);return s<56320||s>57343?i:(i.char=i.char+r.charAt(o),i.end=o,i)}if(0===a)return i;var u=a-1,l=r.charCodeAt(u);return l<55296||l>56319?i:(i.char=r.charAt(u)+i.char,i.start=u,i)}function u(){return b.now()}function l(e){var t=w.exec(String(e));if(null===t)throw new SyntaxError('invalid time value syntax: "'+e+'"');var r=Number(t[1]);if(1===t[2].length&&(r*=1e3),Number.isNaN(r)||!Number.isFinite(r))throw new RangeError('invalid time value: "'+e+'"');return r}function c(e){if("number"!=typeof e||Number.isNaN(e)||!Number.isFinite(e)){var r=void 0;switch(void 0===e?"undefined":_typeof(e)){case"string":r='"'+e+'"';break;case"number":r=String(e);break;default:r=t(e)}throw new Error("invalid milliseconds: "+r)}return e+"ms"}function d(e){if(!e.includes("-"))switch(e){case"bgcolor":return"backgroundColor";case"float":return"cssFloat";default:return e}return("-ms-"===e.slice(0,4)?e.slice(1):e).split("-").map(function(e,t){return 0===t?e:e.toUpperFirst()}).join("")}function h(e){var t=document.createElement("a"),r=Object.create(null);t.href=e,t.search&&t.search.replace(/^\?/,"").splitOrEmpty(/(?:&(?:amp;)?|;)/).forEach(function(e){var t=e.split("="),a=_slicedToArray(t,2),n=a[0],i=a[1];r[n]=i});var a=t.host&&"/"!==t.pathname[0]?"/"+t.pathname:t.pathname;return{href:t.href,protocol:t.protocol,host:t.host,hostname:t.hostname,port:t.port,path:""+a+t.search,pathname:a,query:t.search,search:t.search,queries:r,searches:r,hash:t.hash}}var f=/[&<>"'`]/g,p=new RegExp(f.source),g=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"}),m=/&(?:amp|#38|#x26|lt|#60|#x3c|gt|#62|#x3e|quot|#34|#x22|apos|#39|#x27|#96|#x60);/gi,v=new RegExp(m.source,"i"),y=Object.freeze({"&":"&","&":"&","&":"&","<":"<","<":"<","<":"<",">":">",">":">",">":">",""":'"',""":'"',""":'"',"'":"'","'":"'","'":"'","`":"`","`":"`"}),b=Has.performance?performance:Date,w=/^([+-]?(?:\d*\.)?\d+)([Mm]?[Ss])$/;return Object.freeze(Object.defineProperties({},{toEnum:{value:e},toStringTag:{value:t},isNumeric:{value:r},isBoolean:{value:a},slugify:{value:n},escape:{value:i},unescape:{value:o},charAndPosAt:{value:s},fromCssTime:{value:l},toCssTime:{value:c},fromCssProperty:{value:d},parseUrl:{value:h},now:{value:u},random:{value:Math.random},entityEncode:{value:i},entityDecode:{value:o}, evalExpression:{value:function(){return Scripting.evalJavaScript.apply(Scripting,arguments)}},evalStatements:{value:function(){return Scripting.evalJavaScript.apply(Scripting,arguments)}}}))}(),SimpleAudio=function(){function e(){return g}function t(e){g=!!e,l("mute",g)}function r(){return f}function a(e){f=Math.clamp(e,.2,5),l("rate",f)}function n(){return p}function i(e){p=Math.clamp(e,0,1),l("volume",p)}function o(){l("stop")}function s(e,t){if("function"!=typeof t)throw new Error("callback parameter must be a function");h.set(e,t)}function u(e){h.delete(e)}function l(e,t){h.forEach(function(r){return r(e,t)})}function c(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return new(Function.prototype.bind.apply(m,[null].concat(t)))}function d(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return new(Function.prototype.bind.apply(v,[null].concat(t)))}var h=new Map,f=1,p=1,g=!1,m=function(){function e(t){if(_classCallCheck(this,e),Array.isArray(t))this._create(t);else{if(!(t instanceof e))throw new Error("sources parameter must be an array of either URLs or source objects");this._copy(t)}}return _createClass(e,[{key:"_create",value:function(t){if(!Array.isArray(t)||0===t.length)throw new Error("sources parameter must be an array of either URLs or source objects");var r=/^data:\s*audio\/([^;,]+)\s*[;,]/i,a=/\.([^.\/\\]+)$/,n=e.getType,i=[],o=document.createElement("audio");if(t.forEach(function(e){var t=null;switch(void 0===e?"undefined":_typeof(e)){case"string":var s=void 0;if("data:"===e.slice(0,5)){if(null===(s=r.exec(e)))throw new Error("source data URI missing media type")}else if(null===(s=a.exec(Util.parseUrl(e).pathname)))throw new Error("source URL missing file extension");var u=n(s[1]);null!==u&&(t={src:e,type:u});break;case"object":if(null===e)throw new Error("source object cannot be null");if(!e.hasOwnProperty("src"))throw new Error('source object missing required "src" property');if(!e.hasOwnProperty("format"))throw new Error('source object missing required "format" property');var l=n(e.format);null!==l&&(t={src:e.src,type:l});break;default:throw new Error("invalid source value (type: "+(void 0===e?"undefined":_typeof(e))+")")}if(null!==t){var c=document.createElement("source");c.src=t.src,c.type=Browser.isOpera?t.type.replace(/;.*$/,""):t.type,o.appendChild(c),i.push(t)}}),!o.hasChildNodes())if(Browser.isIE)o.src=undefined;else{var s=document.createElement("source");s.src=undefined,s.type=undefined,o.appendChild(s)}this._finalize(o,i,clone(t))}},{key:"_copy",value:function(t){if(!(t instanceof e))throw new Error("original parameter must be an instance of AudioWrapper");this._finalize(t.audio.cloneNode(!0),clone(t.sources),clone(t.originalSources))}},{key:"_finalize",value:function(e,t,r){var a=this;Object.defineProperties(this,{audio:{configurable:!0,value:e},sources:{configurable:!0,value:Object.freeze(t)},originalSources:{configurable:!0,value:Object.freeze(r)},_error:{writable:!0,value:!1},_faderId:{writable:!0,value:null},_mute:{writable:!0,value:!1},_rate:{writable:!0,value:1},_volume:{writable:!0,value:1}}),jQuery(this.audio).on("loadstart",function(){return a._error=!1}).on("error",function(){return a._error=!0}).find("source:last-of-type").on("error",function(){return a._trigger("error")}),SimpleAudio.subscribe(this,function(e){if(!a.audio)return void SimpleAudio.unsubscribe(a);switch(e){case"mute":a._updateAudioMute();break;case"rate":a._updateAudioRate();break;case"stop":a.stop();break;case"volume":a._updateAudioVolume()}}),this.load()}},{key:"_trigger",value:function(e){jQuery(this.audio).triggerHandler(e)}},{key:"clone",value:function(){return new e(this)}},{key:"destroy",value:function(){SimpleAudio.unsubscribe(this);var e=this.audio;if(e){for(this.fadeStop(),this.stop(),jQuery(e).off();e.hasChildNodes();)e.removeChild(e.firstChild);e.load(),this._error=!0,delete this.audio,delete this.sources,delete this.originalSources}}},{key:"_updateAudioMute",value:function(){this.audio&&(this.audio.muted=this._mute||SimpleAudio.mute)}},{key:"_updateAudioRate",value:function(){this.audio&&(this.audio.playbackRate=this._rate*SimpleAudio.rate)}},{key:"_updateAudioVolume",value:function(){this.audio&&(this.audio.volume=this._volume*SimpleAudio.volume)}},{key:"hasSource",value:function(){return this.sources.length>0}},{key:"hasNoData",value:function(){return!this.audio||this.audio.readyState===HTMLMediaElement.HAVE_NOTHING}},{key:"hasMetadata",value:function(){return!!this.audio&&this.audio.readyState>=HTMLMediaElement.HAVE_METADATA}},{key:"hasSomeData",value:function(){return!!this.audio&&this.audio.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA}},{key:"hasData",value:function(){return!!this.audio&&this.audio.readyState===HTMLMediaElement.HAVE_ENOUGH_DATA}},{key:"isFailed",value:function(){return this._error}},{key:"isLoading",value:function(){return!!this.audio&&this.audio.networkState===HTMLMediaElement.NETWORK_LOADING}},{key:"isPlaying",value:function(){return!!this.audio&&!(this.audio.ended||this.audio.paused||!this.hasSomeData())}},{key:"isPaused",value:function(){return!!this.audio&&(this.audio.paused&&(this.audio.duration===1/0||this.audio.currentTime>0)&&!this.audio.ended)}},{key:"isEnded",value:function(){return!this.audio||this.audio.ended}},{key:"isFading",value:function(){return null!==this._faderId}},{key:"isMuted",value:function(){return this._mute}},{key:"isLooped",value:function(){return!!this.audio&&this.audio.loop}},{key:"load",value:function(){this.audio&&("auto"!==this.audio.preload&&(this.audio.preload="auto"),this.isLoading()||this.audio.load())}},{key:"play",value:function(){this.audio&&this.audio.play()}},{key:"pause",value:function(){this.audio&&this.audio.pause()}},{key:"stop",value:function(){this.audio&&(this.pause(),this.time=0,this._trigger(":stop"))}},{key:"fadeWithDuration",value:function(e,t,r){var a=this;if(this.audio){this.fadeStop();var n=Math.clamp(null==r?this.volume:r,0,1),i=Math.clamp(t,0,1);n!==i&&(this.volume=n,jQuery(this.audio).off("timeupdate.AudioWrapper:fadeWithDuration").one("timeupdate.AudioWrapper:fadeWithDuration",function(){var t=void 0,r=void 0;n<i?(t=n,r=i):(t=i,r=n);var o=Number(e);o<1&&(o=1);var s=(i-n)/(o/.025);a._faderId=setInterval(function(){if(!a.isPlaying())return void a.fadeStop();a.volume=Math.clamp(a.volume+s,t,r),0===a.volume&&a.pause(),a.volume===i&&(a.fadeStop(),a._trigger(":fade"))},25)}),this.play())}}},{key:"fade",value:function(e,t){this.fadeWithDuration(5,e,t)}},{key:"fadeIn",value:function(){this.fade(1)}},{key:"fadeOut",value:function(){this.fade(0)}},{key:"fadeStop",value:function(){null!==this._faderId&&(clearInterval(this._faderId),this._faderId=null)}},{key:"on",value:function(t,r){if(this.audio){if("function"!=typeof r)throw new Error("listener parameter must be a function");var a=e._events,n=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(!a.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(a).join(", "));return e.replace(t,a[t])+".AudioWrapperEvent"}).join(" ");if(""===n)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).on(n,r),this}}},{key:"one",value:function(t,r){if(this.audio){if("function"!=typeof r)throw new Error("listener parameter must be a function");var a=e._events,n=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(!a.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(a).join(", "));return e.replace(t,a[t])+".AudioWrapperEvent"}).join(" ");if(""===n)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).one(n,r),this}}},{key:"off",value:function(t,r){if(this.audio){if(r&&"function"!=typeof r)throw new Error("listener parameter must be a function");if(!t)return jQuery(this.audio).off(".AudioWrapperEvent",r);var a=e._events,n=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(t){if(!a.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(a).join(", "));return e.replace(t,a[t])+".AudioWrapperEvent"}return e+".AudioWrapperEvent"}).join(" ");if(""===n)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).off(n,r),this}}},{key:"duration",get:function(){return this.audio?this.audio.duration:NaN}},{key:"ended",get:function(){return!this.audio||this.audio.ended}},{key:"loop",get:function(){return!!this.audio&&this.audio.loop},set:function(e){this.audio&&(this.audio.loop=!!e)}},{key:"mute",get:function(){return this._mute},set:function(e){this._mute=!!e,this._updateAudioMute()}},{key:"paused",get:function(){return!!this.audio&&this.audio.paused}},{key:"rate",get:function(){return this._rate},set:function(e){this._rate=Math.clamp(e,.2,5),this._updateAudioRate()}},{key:"remaining",get:function(){return this.audio?this.audio.duration-this.audio.currentTime:NaN}},{key:"time",get:function(){return this.audio?this.audio.currentTime:NaN},set:function(e){var t=this;if(this.audio)try{this.audio.currentTime=e}catch(r){jQuery(this.audio).off("loadedmetadata.AudioWrapper:time").one("loadedmetadata.AudioWrapper:time",function(){return t.audio.currentTime=e})}}},{key:"volume",get:function(){return this._volume},set:function(e){this._volume=Math.clamp(e,0,1),this._updateAudioVolume()}}],[{key:"_verifyType",value:function(t){if(!t||!Has.audio)return null;var r=e._types;if(!r.hasOwnProperty(t)){var a=document.createElement("audio");r[t]=""!==a.canPlayType(t).replace(/^no$/i,"")}return r[t]?t:null}},{key:"getType",value:function(t){if(!t||!Has.audio)return null;var r=e.formats,a=t.toLowerCase(),n=r.hasOwnProperty(a)?r[a]:"audio/"+a;return e._verifyType(n)}},{key:"canPlayFormat",value:function(t){return null!==e.getType(t)}},{key:"canPlayType",value:function(t){return null!==e._verifyType(t)}}]),e}();Object.defineProperties(m,{formats:{value:{aac:"audio/aac",caf:"audio/x-caf","x-caf":"audio/x-caf",mp3:'audio/mpeg; codecs="mp3"',mpeg:'audio/mpeg; codecs="mp3"',m4a:"audio/mp4",mp4:"audio/mp4","x-m4a":"audio/mp4","x-mp4":"audio/mp4",oga:"audio/ogg",ogg:"audio/ogg",opus:'audio/ogg; codecs="opus"',wav:"audio/wav",wave:"audio/wav",weba:"audio/webm",webm:"audio/webm"}},_types:{value:{}},_events:{value:Object.freeze({canplay:"canplaythrough",end:"ended",error:"error",fade:":fade",pause:"pause",play:"playing",rate:"ratechange",seek:"seeked",stop:":stop",volume:"volumechange"})}});var v=function(){function e(t){var r=this;_classCallCheck(this,e),Object.defineProperties(this,{tracks:{configurable:!0,value:[]},queue:{configurable:!0,value:[]},current:{writable:!0,value:null},_rate:{writable:!0,value:1},_volume:{writable:!0,value:1},_mute:{writable:!0,value:!1},_loop:{writable:!0,value:!1},_shuffle:{writable:!0,value:!1}}),Array.isArray(t)?t.forEach(function(e){return r.add(e)}):t instanceof e&&t.tracks.forEach(function(e){return r.add(e)})}return _createClass(e,[{key:"add",value:function(e){var t=this;if(null==e||"object"!==(void 0===e?"undefined":_typeof(e)))throw new Error("track parameter must be an object");var r=void 0,a=void 0,n=void 0,i=void 0;if(e instanceof m)r=!0,a=e.clone(),n=e.volume,i=e.rate;else{if(!e.hasOwnProperty("track"))throw new Error('track object missing required "track" property');if(!(e.track instanceof m))throw new Error('track object\'s "track" property must be an AudioWrapper object');r=e.hasOwnProperty("copy")&&e.copy,a=r?e.track.clone():e.track,n=e.hasOwnProperty("volume")?e.volume:e.track.volume,i=e.hasOwnProperty("rate")?e.rate:e.track.rate}a.stop(),a.loop=!1,a.mute=!1,a.volume=n,a.rate=i,a.on("end.AudioListEvent",function(){return t._onEnd()}),this.tracks.push({copy:r,track:a,volume:n,rate:i})}},{key:"destroy",value:function(){this.stop(),this.tracks.filter(function(e){return e.copy}).forEach(function(e){return e.track.destroy()}),delete this.tracks,delete this.queue}},{key:"isPlaying",value:function(){return null!==this.current&&this.current.track.isPlaying()}},{key:"isEnded",value:function(){return 0===this.queue.length&&(null===this.current||this.current.track.isEnded())}},{key:"isPaused",value:function(){return null===this.current||this.current.track.isPaused()}},{key:"isMuted",value:function(){return this._mute}},{key:"isLooped",value:function(){return this._loop}},{key:"isShuffled",value:function(){return this._shuffle}},{key:"play",value:function(){(null!==this.current&&!this.current.track.isEnded()||(0===this.queue.length&&this._buildList(),this._next()))&&this.current.track.play()}},{key:"pause",value:function(){null!==this.current&&this.current.track.pause()}},{key:"stop",value:function(){null!==this.current&&(this.current.track.stop(),this.current=null),this.queue.splice(0)}},{key:"skip",value:function(){this._next()?this.current.track.play():this._loop&&this.play()}},{key:"fadeWithDuration",value:function(e,t,r){if(0===this.queue.length&&this._buildList(),null!==this.current&&!this.current.track.isEnded()||this._next()){var a=Math.clamp(t,0,1)*this.current.volume,n=void 0;null!=r&&(n=Math.clamp(r,0,1)*this.current.volume),this.current.track.fadeWithDuration(e,a,n),this._volume=t}}},{key:"fade",value:function(e,t){this.fadeWithDuration(5,e,t)}},{key:"fadeIn",value:function(){this.fade(1)}},{key:"fadeOut",value:function(){this.fade(0)}},{key:"_next",value:function(){return null!==this.current&&this.current.track.stop(),0===this.queue.length?(this.current=null,!1):(this.current=this.queue.shift(),!this.current.track.hasSource()||this.current.track.isFailed()?this._next():(this.current.track.mute=this._mute,this.current.track.rate=this.rate*this.current.rate,this.current.track.volume=this.volume*this.current.volume,!0))}},{key:"_onEnd",value:function(){if(0===this.queue.length){if(!this._loop)return;this._buildList()}this._next()&&this.current.track.play()}},{key:"_buildList",value:function(){var e;this.queue.splice(0),(e=this.queue).push.apply(e,_toConsumableArray(this.tracks)),0!==this.queue.length&&this._shuffle&&(this.queue.shuffle(),this.queue.length>1&&this.queue[0]===this.current&&this.queue.push(this.queue.shift()))}},{key:"duration",get:function(){return this.tracks.map(function(e){return e.track.duration}).reduce(function(e,t){return e+t},0)}},{key:"loop",get:function(){return this._loop},set:function(e){this._loop=!!e}},{key:"mute",get:function(){return this._mute},set:function(e){this._mute=!!e,null!==this.current&&(this.current.track.mute=this._mute)}},{key:"rate",get:function(){return this._rate},set:function(e){this._rate=Math.clamp(e,.2,5),null!==this.current&&(this.current.track.rate=this.rate*this.current.rate)}},{key:"remaining",get:function(){var e=this.queue.map(function(e){return e.track.duration}).reduce(function(e,t){return e+t},0);return null!==this.current&&(e+=this.current.track.remaining),e}},{key:"shuffle",get:function(){return this._shuffle},set:function(e){this._shuffle=!!e}},{key:"time",get:function(){return this.duration-this.remaining}},{key:"volume",get:function(){return this._volume},set:function(e){this._volume=Math.clamp(e,0,1),null!==this.current&&(this.current.track.volume=this.volume*this.current.volume)}}]),e}();return Object.freeze(Object.defineProperties({},{mute:{get:e,set:t},rate:{get:r,set:a},volume:{get:n,set:i},stop:{value:o},subscribe:{value:s},unsubscribe:{value:u},publish:{value:l},create:{value:c},createList:{value:d}}))}(),SimpleStore=function(){function e(e,a){if(r)return r.create(e,a);for(var n=0;n<t.length;++n)if(t[n].init(e,a))return r=t[n],r.create(e,a);throw new Error("no valid storage adapters found")}var t=[],r=null;return Object.freeze(Object.defineProperties({},{adapters:{value:t},create:{value:e}}))}();SimpleStore.adapters.push(function(){function e(){function e(e){try{var t=window[e],r="_sc_"+String(Date.now());t.setItem(r,r);var a=t.getItem(r)===r;return t.removeItem(r),a}catch(e){}return!1}return r=e("localStorage")&&e("sessionStorage")}function t(e,t){if(!r)throw new Error("adapter not initialized");return new a(e,t)}var r=!1,a=function(){function e(t,r){_classCallCheck(this,e);var a=t+".",n=null,i=null;r?(n=window.localStorage,i="localStorage"):(n=window.sessionStorage,i="sessionStorage"),Object.defineProperties(this,{_engine:{value:n},_prefix:{value:a},_prefixRe:{value:new RegExp("^"+RegExp.escape(a))},name:{value:i},id:{value:t},persistent:{value:!!r}})}return _createClass(e,[{key:"size",value:function(){return this.keys().length}},{key:"keys",value:function(){for(var e=[],t=0;t<this._engine.length;++t){var r=this._engine.key(t);this._prefixRe.test(r)&&e.push(r.replace(this._prefixRe,""))}return e}},{key:"has",value:function(e){return!("string"!=typeof e||!e)&&this._engine.hasOwnProperty(this._prefix+e)}},{key:"get",value:function(t){if("string"!=typeof t||!t)return null;var r=this._engine.getItem(this._prefix+t);return null==r?null:e._deserialize(r)}},{key:"set",value:function(t,r){if("string"!=typeof t||!t)return!1;try{this._engine.setItem(this._prefix+t,e._serialize(r))}catch(e){throw/quota[_\s]?(?:exceeded|reached)/i.test(e.name)&&(e.message=this.name+" quota exceeded"),e}return!0}},{key:"delete",value:function(e){return!("string"!=typeof e||!e)&&(this._engine.removeItem(this._prefix+e),!0)}},{key:"clear",value:function(){for(var e=this.keys(),t=0,r=e.length;t<r;++t)this.delete(e[t]);return!0}},{key:"length",get:function(){return this.keys().length}}],[{key:"_serialize",value:function(e)