diff --git a/devTools/tweeGo/targets/sugarcube-2/header.html b/devTools/tweeGo/targets/sugarcube-2/header.html
index ca7475c51d512e74afb2ea09b84dc1db7a38075c..e74641cbe77c95c4473a1464d74b0ed1f2c6b108 100644
--- a/devTools/tweeGo/targets/sugarcube-2/header.html
+++ b/devTools/tweeGo/targets/sugarcube-2/header.html
@@ -6,7 +6,7 @@
 <meta name="viewport" content="width=device-width,initial-scale=1" />
 <!--
 
-SugarCube (v2.15.0): A free (gratis and libre) story format, based on TiddlyWiki.
+SugarCube (v2.16.0): A free (gratis and libre) story format, based on TiddlyWiki.
 
 Copyright © 2013–2017 Thomas Michael Edwards <tmedwards@motoslave.net>.
 All rights reserved.
@@ -145,12 +145,12 @@ var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||f
 	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 	--------------------------------------------------------------------------------
 	*/
-	if(document.documentElement.classList.contains("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 n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),_slicedToArray=function(){function e(e,t){var r=[],n=!0,a=!1,i=undefined;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done)&&(r.push(o.value),!t||r.length!==t);n=!0);}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)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},Alert=function(){function e(e,t,r,n){var a="fatal"===e,i="Apologies! "+(a?"A fatal":"An")+" error has occurred.";i+=a?" 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(/^(?:(?:uncaught\s+(?:exception:\s+)?)?error:\s+)+/i,"")+".":": unknown error."),n&&n.stack&&(i+="\n\nStack Trace:\n"+n.stack),window.alert(i)}function t(t,r,n){e(null,t,r,n)}function r(t,r,n){e("fatal",t,r,n)}return function(e){window.onerror=function(n,a,i,o,s){"complete"===document.readyState?t(null,n,s):(r(null,n,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}}))}();!function(){function e(e,t){var a=String(e);switch(t){case"start":return a&&r.test(a)?a.replace(r,""):a;case"end":return a&&n.test(a)?a.replace(n,""):a;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 n="undefined"==typeof t?"":String(t);for(""===n&&(n=" ");n.length<r;){var a=n.length,i=r-a;n+=a>i?n.slice(0,i):n}return n.length>r&&(n=n.slice(0,r)),n}var r=/^[\s\u00A0\uFEFF][\s\u00A0\uFEFF]*/,n=/[\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 n=this[r];if(t===n||t!==t&&n!==n)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 n=String(this),a=n.length,i=Number.parseInt(e,10);return i<=a?n:t(i-a,r)+n}}),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 n=String(this),a=n.length,i=Number.parseInt(e,10);return i<=a?n:n+t(i-a,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(){if(0===arguments.length)throw new Error("_random called with insufficient parameters");var e=void 0,t=void 0;if(1===arguments.length?(e=0,t=arguments[0]):(e=arguments[0],t=arguments[1]),e>t){var r=[t,e];e=r[0],t=r[1]}return Math.floor(_nativeMathRandom()*(t-e+1))+e}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 n=t+1;if(n>=e.length)throw new Error("high surrogate without trailing low surrogate");var a=e.charCodeAt(n);if(a<56320||a>57343)throw new Error("high surrogate without trailing low surrogate");return{char:e.charAt(t)+e.charAt(n),start:t,end:n}}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,t,r){var n=t,a=r;return 2===arguments.length&&(a=n,n=0),Array.isArray(e)?e.random(n,a):e.hasOwnProperty("length")?[].concat(_toConsumableArray(e)).random(n,a):void 0}}),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,n=0;(r=e.call(this,t,r))!==-1;)++n,++r;return n}}),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[];var e=this.length>>>0;if(0===e)return[];for(var t=Array.prototype.indexOf,r=Array.prototype.push,n=Array.prototype.splice,a=Array.prototype.concat.apply([],arguments),i=[],o=0,s=a.length;o<s;++o)for(var u=a[o],l=0;(l=t.call(this,u,l))!==-1;)r.apply(i,n.call(this,l,1));return i}}),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())),n=[].concat(_toConsumableArray(r)).sort(function(e,t){return t-e}),a=[],i=0,o=r.length;i<o;++i)a[i]=this[r[i]];for(var s=0,u=n.length;s<u;++s)t.call(this,n[s],1);return a}}),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(e,t){if(null==this)throw new TypeError("Array.prototype.pluck called on null or undefined");var r=this.length>>>0;if(0!==r){var n=e,a=t;return 1===arguments.length&&(a=n,n=0),null==n?n=0:n<0?(n=r+n,n<0&&(n=0)):n>=r&&(n=r-1),null==a?a=r-1:a<0?(a=r+a,a<0&&(a=r-1)):a>=r&&(a=r-1),Array.prototype.splice.call(this,_random(n,a),1)[0]}}}),Object.defineProperty(Array.prototype,"random",{configurable:!0,writable:!0,value:function(e,t){if(null==this)throw new TypeError("Array.prototype.random called on null or undefined");var r=this.length>>>0;if(0!==r){var n=e,a=t;return 1===arguments.length&&(a=n,n=0),null==n?n=0:n<0?(n=r+n,n<0&&(n=0)):n>=r&&(n=r-1),null==a?a=r-1:a<0?(a=r+a,a<0&&(a=r-1)):a>=r&&(a=r-1),this[_random(n,a)]}}}),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){for(var t=e-1;t>0;--t){var r=Math.floor(_nativeMathRandom()*(t+1)),n=[this[r],this[t]];this[t]=n[0],this[r]=n[1]}return this}}}),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 n=[],a=0,i=0;i<r.length;++i)n.push(r[i]===undefined?arguments[a++]:r[i]);return t.apply(this,n.concat(e.call(arguments,a)))}}}),Object.defineProperty(Math,"clamp",{configurable:!0,writable:!0,value:function e(t,r,n){var e=Number(t);return Number.isNaN(e)?NaN:e.clamp(r,n)}}),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 n=String(r);return n&&t.test(n)?n.replace(e,"\\$&"):n}})}(),function(){var e=/{(\d+)(?:,([+-]?\d+))?}/g,t=new RegExp(e.source);Object.defineProperty(String,"format",{configurable:!0,writable:!0,value:function(r){function n(e,t,r){if(!t)return e;var n=Math.abs(t)-e.length;if(n<1)return e;var a=String(r).repeat(n);return t<0?e+a:a+e}if(arguments.length<2)return 0===arguments.length?"":r;var a=2===arguments.length&&Array.isArray(arguments[1])?[].concat(_toConsumableArray(arguments[1])):Array.prototype.slice.call(arguments,1);return 0===a.length?r:t.test(r)?(e.lastIndex=0,r.replace(e,function(e,t,r){var i=a[t];if(null==i)return"";for(;"function"==typeof i;)i=i();switch("undefined"==typeof i?"undefined":_typeof(i)){case"string":break;case"object":i=JSON.stringify(i);break;default:i=String(i)}return n(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 String.prototype.indexOf.apply(this,arguments)!==-1}}),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,n=Number(arguments[1])||0,a=0;(n=t.call(this,e,n))!==-1;)++a,n+=r;return a}}),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 n=this.length>>>0;if(0===n)return"";var a=Number(e);Number.isSafeInteger(a)?a<0&&(a+=n,a<0&&(a=0)):a=0,a>n&&(a=n);var i=Number(t);(!Number.isSafeInteger(i)||i<0)&&(i=0);var o=this.slice(0,a);return"undefined"!=typeof r&&(o+=r),a+i<n&&(o+=this.slice(a+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,n=t.end;return n===-1?"":r.toLocaleUpperCase()+e.slice(n+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,n=t.end;return n===-1?"":r.toUpperCase()+e.slice(n+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={userAgent:navigator.userAgent.toLowerCase()};return e.isGecko=navigator&&"Gecko"===navigator.product&&!/webkit|trident/.test(e.userAgent),e.isIE=/msie|trident/.test(e.userAgent)&&!e.userAgent.includes("opera"),e.ieVersion=function(){var t=/(?:msie\s+|rv:)(\d{1,2}\.\d)/.exec(e.userAgent);return t?Number([1]):0}(),e.isOpera=e.userAgent.includes("opera")||e.userAgent.includes(" opr/"),e.operaVersion=function(){var t=new RegExp((/applewebkit|chrome/.test(e.userAgent)?"opr":"version")+"\\/(\\d{1,2}\\.\\d+)"),r=t.exec(e.userAgent);return r?Number(r[1]):0}(),e.isMobile=Object.freeze({Android:/android/.test(e.userAgent),BlackBerry:/blackberry/.test(e.userAgent),iOS:/ip(?:hone|ad|od)/.test(e.userAgent),Windows:/iemobile/.test(e.userAgent),any:function(){var t=e.isMobile;return t.Android||t.BlackBerry||t.iOS||t.Windows}}),Object.freeze(e)}(),Has=function(){function e(e){try{if(null!=e&&e.length>=0){var t="SugarCube.WebStorage.Test",r="1701 Guilty Scott";if(e.setItem(t,r),e.getItem(t)===r)return e.removeItem(t),!0}}catch(e){}return!1}return Object.freeze({audio:"function"==typeof document.createElement("audio").canPlayType,fileAPI:"File"in window&&"FileList"in window&&"FileReader"in window&&!Browser.isMobile.any()&&(!Browser.isOpera||Browser.operaVersion>=15),geolocation:"geolocation"in navigator&&"function"==typeof navigator.geolocation.getCurrentPosition&&"function"==typeof navigator.geolocation.watchPosition,localStorage:"localStorage"in window&&e(window.localStorage),sessionStorage:"sessionStorage"in window&&e(window.sessionStorage)})}(),_ref4=function(){function e(t){if("object"!==("undefined"==typeof t?"undefined":_typeof(t))||null==t)return 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 Array.isArray(t)?r=[]:t instanceof Date?r=new Date(t.getTime()):t instanceof Map?(r=new Map,t.forEach(function(t,n){r.set(n,e(t))})):t instanceof RegExp?r=new RegExp(t):t instanceof Set?(r=new Set,t.forEach(function(t){r.add(e(t))})):r=Object.create(Object.getPrototypeOf(t)),Object.keys(t).forEach(function(n){return r[n]=e(t[n])}),r}function t(e){for(var t=document.createDocumentFragment(),r=document.createElement("p"),n=void 0;null!==(n=e.firstChild);){if(n.nodeType===Node.ELEMENT_NODE){var a=n.nodeName.toUpperCase();switch(a){case"BR":if(null!==n.nextSibling&&n.nextSibling.nodeType===Node.ELEMENT_NODE&&"BR"===n.nextSibling.nodeName.toUpperCase()){e.removeChild(n.nextSibling),e.removeChild(n),t.appendChild(r),r=document.createElement("p");continue}if(!r.hasChildNodes()){e.removeChild(n);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(n);continue}}r.appendChild(n)}r.hasChildNodes()&&t.appendChild(r),e.appendChild(t)}function r(){try{return document.activeElement||null}catch(e){return null}}function n(e,t,r){var n="object"===("undefined"==typeof e?"undefined":_typeof(e))?e:document.getElementById(e);if(null==n)return null;var a=Array.isArray(t)?t:[t];jQuery(n).empty();for(var i=0,o=a.length;i<o;++i)if(Story.has(a[i]))return new Wikifier(n,Story.get(a[i]).processText().trim()),n;if(null!=r){var s=String(r).trim();""!==s&&new Wikifier(n,s)}return n}function a(e,t,r){return jQuery(document.createElement("span")).addClass("error").attr("title",r).text(L10n.get("errorTitle")+": "+(t||"unknown error")).appendTo(e),!1}function i(e,t){switch("undefined"==typeof e?"undefined":_typeof(e)){case"number":if(Number.isNaN(e))return t;break;case"object":if(null===e)return t;if(Array.isArray(e)||e instanceof Set)return[].concat(_toConsumableArray(e)).map(function(e){return i(e,t)}).join(", ");if(e instanceof Map){var r=function(){var r=i,n=[].concat(_toConsumableArray(e)).map(function(e){return r(e[0],t)+" ⇒ "+r(e[1],t)}).join("; ");return{v:"( "+n+" )"}}();if("object"===("undefined"==typeof r?"undefined":_typeof(r)))return r.v}else{if(e instanceof Date)return e.toLocaleString();if("function"==typeof e.toString)return e.toString()}return 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:n},throwError:{value:a},toStringOrDefault:{value:i}}))}(),clone=_ref4.clone,convertBreaks=_ref4.convertBreaks,safeActiveElement=_ref4.safeActiveElement,setPageElement=_ref4.setPageElement,throwError=_ref4.throwError,toStringOrDefault=_ref4.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);t.is("[aria-pressed]")&&t.attr("aria-pressed","true"===t.attr("aria-pressed")?"false":"true"),e.apply(this,arguments)}}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(n,a){if(0===this.length||0===arguments.length)return this;var i=n,o=a;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.fn.extend({wikiWithOptions:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(0===this.length||0===r.length)return this;var a=document.createDocumentFragment();return r.forEach(function(t){return new Wikifier(a,t,e)}),this.append(a),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){var t=void 0;switch("undefined"==typeof 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 t(e){return"boolean"==typeof e||"string"==typeof e&&("true"===e||"false"===e)}function r(e){return String(e).trim().replace(/[^\w\s\u2013\u2014-]+/g,"").replace(/[_\s\u2013\u2014-]+/g,"-").toLocaleLowerCase()}function n(e){if(null==e)return"";var t=String(e);return t&&p.test(t)?t.replace(d,function(e){return f[e]}):t}function a(e){if(null==e)return"";var t=String(e);return t&&g.test(t)?t.replace(h,function(e){return m[e]}):t}function i(e){var t=/^([+-]?(?:\d*\.)?\d+)([Mm]?[Ss])$/,r=t.exec(String(e));if(null===r)throw new SyntaxError('invalid time value syntax: "'+e+'"');var n=Number(r[1]);if(/^[Ss]$/.test(r[2])&&(n*=1e3),Number.isNaN(n)||!Number.isFinite(n))throw new RangeError('invalid time value: "'+e+'"');return n}function o(e){if("number"!=typeof e||Number.isNaN(e)||!Number.isFinite(e)){var t=void 0;switch("undefined"==typeof e?"undefined":_typeof(e)){case"string":t='"'+e+'"';break;case"number":t=String(e);break;default:t=Object.prototype.toString.call(e)}throw new Error("invalid milliseconds: "+t)}return e+"ms"}function s(e){if(!e.includes("-"))switch(e){case"bgcolor":return"backgroundColor";case"float":return"cssFloat";default:return e}var t="-ms-"===e.slice(0,4)?e.slice(1):e;return t.split("-").map(function(e,t){return 0===t?e:e.toUpperFirst()}).join("")}function u(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("="),n=_slicedToArray(t,2),a=n[0],i=n[1];r[a]=i});var n=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:""+n+t.search,pathname:n,query:t.search,search:t.search,queries:r,searches:r,hash:t.hash}}function l(e,t){for(var r=Object.prototype.toString,n=Array.isArray(e),a=[].concat(Object.keys(e),Object.keys(t)).sort().filter(function(e,t,r){return 0===t||r[t-1]!==e}),i={},o=void 0,s=function(e){return e===o},u=0,l=a.length;u<l;++u){var c=a[u],d=e[c],p=t[c];if(e.hasOwnProperty(c))if(t.hasOwnProperty(c)){if(d===p)continue;if(("undefined"==typeof d?"undefined":_typeof(d))===("undefined"==typeof p?"undefined":_typeof(p)))if("function"==typeof d)d.toString()!==p.toString()&&(i[c]=[v.Copy,p]);else if("object"!==("undefined"==typeof d?"undefined":_typeof(d))||null===d)i[c]=[v.Copy,p];else{var f=r.call(d),h=r.call(p);if(f===h)if("[object Date]"===f){var g=Number(p);Number(d)!==g&&(i[c]=[v.CopyDate,g])}else if("[object RegExp]"===f)d.toString()!==p.toString()&&(i[c]=[v.Copy,clone(p)]);else{var m=Util.diff(d,p);null!==m&&(i[c]=m)}else i[c]=[v.Copy,clone(p)]}else i[c]=[v.Copy,"object"!==("undefined"==typeof p?"undefined":_typeof(p))||null===p?p:clone(p)]}else if(n&&Util.isNumeric(c)){var y=Number(c);if(!o){o="";do o+="~";while(a.some(s));i[o]=[v.SpliceArray,y,y]}y<i[o][1]&&(i[o][1]=y),y>i[o][2]&&(i[o][2]=y)}else i[c]=v.Delete;else i[c]=[v.Copy,"object"!==("undefined"==typeof p?"undefined":_typeof(p))||null===p?p:clone(p)]}return Object.keys(i).length>0?i:null}function c(e,t){for(var r=Object.keys(t||{}),n=clone(e),a=0,i=r.length;a<i;++a){var o=r[a],s=t[o];if(s===v.Delete)delete n[o];else if(Array.isArray(s))switch(s[0]){case v.SpliceArray:n.splice(s[1],1+(s[2]-s[1]));break;case v.Copy:n[o]=clone(s[1]);break;case v.CopyDate:n[o]=new Date(s[1])}else n[o]=Util.patch(n[o],s)}return n}var d=/[&<>"'`]/g,p=new RegExp(d.source),f=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"}),h=/&(?:amp|lt|gt|quot|apos|#39|#x27|#96|#x60);/g,g=new RegExp(h.source),m=Object.freeze({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&#39;":"'","&#x27;":"'","&#96;":"`","&#x60;":"`"}),v=Object.freeze({Delete:0,SpliceArray:1,Copy:2,CopyDate:3});return Object.freeze(Object.defineProperties({},{isNumeric:{value:e},isBoolean:{value:t},slugify:{value:r},escape:{value:n},unescape:{value:a},fromCssTime:{value:i},toCssTime:{value:o},fromCssProperty:{value:s},parseUrl:{value:u},DiffOp:{value:v},diff:{value:l},patch:{value:c},random:{value:Math.random},entityEncode:{value:n},entityDecode:{value:a},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 n(e){f=Math.clamp(e,.2,5),l("rate",f)}function a(){return h}function i(e){h=Math.clamp(e,0,1),l("volume",h)}function o(){l("stop")}function s(e,t){if("function"!=typeof t)throw new Error("callback parameter must be a function");p.set(e,t)}function u(e){p.delete(e)}function l(e,t){p.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 p=new Map,f=1,h=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,n=/\.([^.\/\\]+)$/,a=e.getType,i=[],o=document.createElement("audio");if(t.forEach(function(e){var t=null;switch("undefined"==typeof e?"undefined":_typeof(e)){case"string":var s=void 0;if("data:"===e.slice(0,5)){if(s=r.exec(e),null===s)throw new Error("source data URI missing media type")}else if(s=n.exec(Util.parseUrl(e).pathname),null===s)throw new Error("source URL missing file extension");var u=a(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=a(e.format);null!==l&&(t={src:e.src,type:l});break;default:throw new Error("invalid source value (type: "+("undefined"==typeof e?"undefined":_typeof(e))+")")}if(null!==t){var c=document.createElement("source");c.src=t.src,c.type=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 n=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 n._error=!1}).on("error",function(){return n._error=!0}).find("source:last-of-type").on("error",function(){return n._trigger("error")}),SimpleAudio.subscribe(this,function(e){if(!n.audio)return void SimpleAudio.unsubscribe(n);switch(e){case"mute":n._updateAudioMute();break;case"rate":n._updateAudioRate();break;case"stop":n.stop();break;case"volume":n._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),this.fadeStop(),this.stop();var e=this.audio;for(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.muted=this._mute||SimpleAudio.mute}},{key:"_updateAudioRate",value:function(){this.audio.playbackRate=this._rate*SimpleAudio.rate}},{key:"_updateAudioVolume",value:function(){this.audio.volume=this._volume*SimpleAudio.volume}},{key:"hasSource",value:function(){return this.sources.length>0}},{key:"hasNoData",value:function(){return this.audio.readyState===HTMLMediaElement.HAVE_NOTHING}},{key:"hasMetadata",value:function(){
-return this.audio.readyState>=HTMLMediaElement.HAVE_METADATA}},{key:"hasSomeData",value:function(){return this.audio.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA}},{key:"hasData",value:function(){return this.audio.readyState===HTMLMediaElement.HAVE_ENOUGH_DATA}},{key:"isFailed",value:function(){return this._error}},{key:"isLoading",value:function(){return this.audio.networkState===HTMLMediaElement.NETWORK_LOADING}},{key:"isPlaying",value:function(){return!(this.audio.ended||this.audio.paused||!this.hasSomeData())}},{key:"isPaused",value:function(){return this.audio.paused&&(this.audio.duration===1/0||this.audio.currentTime>0)&&!this.audio.ended}},{key:"isEnded",value:function(){return 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.loop}},{key:"load",value:function(){"auto"!==this.audio.preload&&(this.audio.preload="auto"),this.isLoading()||this.audio.load()}},{key:"play",value:function(){this.audio.play()}},{key:"pause",value:function(){this.audio.pause()}},{key:"stop",value:function(){this.audio.pause(),this.time=0,this._trigger("aw:stop")}},{key:"fadeWithDuration",value:function(e,t,r){var n=this;this.fadeStop();var a=Math.clamp(null==r?this.volume:r,0,1),i=Math.clamp(t,0,1);a!==i&&(this.volume=a,jQuery(this.audio).off("timeupdate.AudioWrapper:fadeWithDuration").one("timeupdate.AudioWrapper:fadeWithDuration",function(){var t=void 0,r=void 0;a<i?(t=a,r=i):(t=i,r=a);var o=Number(e);o<1&&(o=1);var s=25,u=(i-a)/(o/(s/1e3));n._faderId=setInterval(function(){return n.isPlaying()?(n.volume=Math.clamp(n.volume+u,t,r),0===n.volume&&n.pause(),void(n.volume===i&&(n.fadeStop(),n._trigger("aw:fade")))):void n.fadeStop()},s)}),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("function"!=typeof r)throw new Error("listener parameter must be a function");var n=e._events,a=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(!n.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(n).join(", "));return e.replace(t,n[t])+".AudioWrapperEvent"}).join(" ");if(""===a)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).on(a,r),this}},{key:"one",value:function(t,r){if("function"!=typeof r)throw new Error("listener parameter must be a function");var n=e._events,a=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(!n.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(n).join(", "));return e.replace(t,n[t])+".AudioWrapperEvent"}).join(" ");if(""===a)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).one(a,r),this}},{key:"off",value:function(t,r){if(r&&"function"!=typeof r)throw new Error("listener parameter must be a function");if(!t)return jQuery(this.audio).off(".AudioWrapperEvent",r);var n=e._events,a=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(t){if(!n.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(n).join(", "));return e.replace(t,n[t])+".AudioWrapperEvent"}return e+".AudioWrapperEvent"}).join(" ");if(""===a)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).off(a,r),this}},{key:"duration",get:function(){return this.audio.duration}},{key:"ended",get:function(){return this.audio.ended}},{key:"loop",get:function(){return this.audio.loop},set:function(e){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.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.duration-this.audio.currentTime}},{key:"time",get:function(){return this.audio.currentTime},set:function(e){var t=this;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 n=document.createElement("audio");r[t]=""!==n.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,n=t.toLowerCase(),a=r.hasOwnProperty(n)?r[n]:"audio/"+n;return e._verifyType(a)}},{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:"aw:fade",pause:"pause",play:"playing",rate:"ratechange",seek:"seeked",stop:"aw: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"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("track parameter must be an object");var r=void 0,n=void 0,a=void 0,i=void 0;if(e instanceof m)r=!0,n=e.clone(),a=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,n=r?e.track.clone():e.track,a=e.hasOwnProperty("volume")?e.volume:e.track.volume,i=e.hasOwnProperty("rate")?e.rate:e.track.rate}n.stop(),n.loop=!1,n.mute=!1,n.volume=a,n.rate=i,n.on("end.AudioListEvent",function(){return t._onEnd()}),this.tracks.push({copy:r,track:n,volume:a,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 n=Math.clamp(t,0,1)*this.current.volume,a=void 0;null!=r&&(a=Math.clamp(r,0,1)*this.current.volume),this.current.track.fadeWithDuration(e,n,a),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:n},volume:{get:a,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,n){if(r)return r.create(e,n);for(var a=0;a<t.length;++a)if(t[a].init(e,n))return r=t[a],r.create(e,n);throw new Error("no valid adapters found")}var t=[],r=null;return Object.freeze(Object.defineProperties({},{adapters:{value:t},create:{value:e}}))}();SimpleStore.adapters.push(function(){function e(){return r=Has.localStorage&&Has.sessionStorage}function t(e,t){if(!r)throw new Error("adapter not initialized");return new n(e,t)}var r=!1,n=function(){function e(t,r){_classCallCheck(this,e);var n=t+".",a=null,i=null;r?(a=window.localStorage,i="localStorage"):(a=window.sessionStorage,i="sessionStorage"),Object.defineProperties(this,{_engine:{value:a},_prefix:{value:n},_prefixRe:{value:new RegExp("^"+RegExp.escape(n))},name:{value:i},id:{value:t},persistent:{value:!!r}})}return _createClass(e,[{key:"size",value:function(){return this.keys().length}},{key:"keys",value:function e(){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_?(?: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){return LZString.compressToUTF16(JSON.stringify(e))}},{key:"_deserialize",value:function(e){return JSON.parse(LZString.decompressFromUTF16(e))}}]),e}();return Object.freeze(Object.defineProperties({},{init:{value:e},create:{value:t}}))}()),SimpleStore.adapters.push(function(){function e(e){return n="cookie"in document,n&&r(e),n}function t(e,t){if(!n)throw new Error("adapter not initialized");return new a(e,t)}function r(e){if(""!==document.cookie)for(var t=e+".",r=new RegExp("^"+RegExp.escape(t)),n=e+"!.",i=e+"*.",o=/\.(?:state|rcWarn)$/,s=document.cookie.split(/;\s*/),u=0;u<s.length;++u){var l=s[u].split("="),c=decodeURIComponent(l[0]);if(r.test(c)){var d=decodeURIComponent(l[1]);""!==d&&!function(){var e=!o.test(c);a._setCookie(c,undefined,"Thu, 01 Jan 1970 00:00:00 GMT"),a._setCookie(c.replace(r,function(){return e?n:i}),d,e?"Tue, 19 Jan 2038 03:14:07 GMT":undefined)}()}}}var n=!1,a=function(){function e(t,r){_classCallCheck(this,e);var n=""+t+(r?"!":"*")+".";Object.defineProperties(this,{_prefix:{value:n},_prefixRe:{value:new RegExp("^"+RegExp.escape(n))},name:{value:"cookie"},id:{value:t},persistent:{value:!!r}})}return _createClass(e,[{key:"size",value:function(){return this.keys().length}},{key:"keys",value:function e(){if(""===document.cookie)return[];for(var t=document.cookie.split(/;\s*/),e=[],r=0;r<t.length;++r){var n=t[r].split("="),a=decodeURIComponent(n[0]);if(this._prefixRe.test(a)){var i=decodeURIComponent(n[1]);""!==i&&e.push(a.replace(this._prefixRe,""))}}return e}},{key:"has",value:function(t){return!("string"!=typeof t||!t)&&null!==e._getCookie(this._prefix+t)}},{key:"get",value:function(t){if("string"!=typeof t||!t)return null;var r=e._getCookie(this._prefix+t);return null===r?null:e._deserialize(r)}},{key:"set",value:function(t,r){if("string"!=typeof t||!t)return!1;try{if(e._setCookie(this._prefix+t,e._serialize(r),this.persistent?"Tue, 19 Jan 2038 03:14:07 GMT":undefined),!this.has(t))throw new Error("unknown validation error during set")}catch(e){throw e.message="cookie error: "+e.message,e}return!0}},{key:"delete",value:function(t){if("string"!=typeof t||!t||!this.has(t))return!1;try{if(e._setCookie(this._prefix+t,undefined,"Thu, 01 Jan 1970 00:00:00 GMT"),this.has(t))throw new Error("unknown validation error during delete")}catch(e){throw e.message="cookie error: "+e.message,e}return!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:"_getCookie",value:function(e){if(!e||""===document.cookie)return null;for(var t=document.cookie.split(/;\s*/),r=0;r<t.length;++r){var n=t[r].split("="),a=decodeURIComponent(n[0]);if(e===a){var i=decodeURIComponent(n[1]);return i||null}}return null}},{key:"_setCookie",value:function(e,t,r){if(e){var n=encodeURIComponent(e)+"=";null!=t&&(n+=encodeURIComponent(t)),null!=r&&(n+="; "+r),n+="; path=/",document.cookie=n}}},{key:"_serialize",value:function(e){return LZString.compressToBase64(JSON.stringify(e))}},{key:"_deserialize",value:function(e){return JSON.parse(LZString.decompressFromBase64(e))}}]),e}();return Object.freeze(Object.defineProperties({},{init:{value:e},create:{value:t}}))}());var DebugView=function(){var e=function(){function e(t,r,n,a){_classCallCheck(this,e),Object.defineProperties(this,{parent:{value:t},view:{value:document.createElement("span")},break:{value:document.createElement("wbr")}}),jQuery(this.view).attr({title:a,"aria-label":a,"data-type":null!=r?r:"","data-name":null!=n?n:""}).addClass("debug"),this.parent.appendChild(this.view),this.parent.appendChild(this.break)}return _createClass(e,[{key:"append",value:function(e){return jQuery(this.view).append(e),this}},{key:"modes",value:function(e){var t=this;if(null==e){var r=function(){var e={};return t.view.className.splitOrEmpty(/\s+/).forEach(function(t){"debug"!==t&&(e[t]=!0)}),{v:e}}();if("object"===("undefined"==typeof r?"undefined":_typeof(r)))return r.v}else if("object"===("undefined"==typeof e?"undefined":_typeof(e)))return Object.keys(e).forEach(function(t){this[e[t]?"addClass":"removeClass"](t)},jQuery(this.view)),this;throw new Error("DebugView.prototype.modes options parameter must be an object or null/undefined")}},{key:"remove",value:function(){var e=jQuery(this.view);this.view.hasChildNodes()&&e.contents().appendTo(this.parent),e.remove(),jQuery(this.break).remove()}},{key:"output",get:function(){return this.view}},{key:"type",get:function(){return this.view.getAttribute("data-type")},set:function(e){this.view.setAttribute("data-type",null!=e?e:"")}},{key:"name",get:function(){return this.view.getAttribute("data-name")},set:function(e){this.view.setAttribute("data-name",null!=e?e:"")}},{key:"title",get:function(){return this.view.title},set:function(e){this.view.title=e}}],[{key:"init",value:function(){jQuery('<button id="debug-view-toggle">'+L10n.get("debugViewTitle")+"</button>").ariaClick({label:L10n.get("debugViewToggle")},function(){return e.toggle()}).prependTo("#ui-bar-body"),e.enable()}},{key:"enable",value:function(){jQuery(document.documentElement).addClass("debug-view"),jQuery.event.trigger("tw:debugviewupdate")}},{key:"disable",value:function(){jQuery(document.documentElement).removeClass("debug-view"),jQuery.event.trigger("tw:debugviewupdate")}},{key:"toggle",value:function(){jQuery(document.documentElement).toggleClass("debug-view"),jQuery.event.trigger("tw:debugviewupdate")}}]),e}();return e}(),PRNGWrapper=function(){var e=function(){function e(t,r){_classCallCheck(this,e),Object.defineProperties(this,new Math.seedrandom(t,r,function(e,t){return{_prng:{value:e},seed:{writable:!0,value:t},pull:{writable:!0,value:0},random:{value:function(){return++this.pull,this._prng()}}}}))}return _createClass(e,null,[{key:"marshal",value:function(e){if(!e||!e.hasOwnProperty("seed")||!e.hasOwnProperty("pull"))throw new Error("PRNG is missing required data");return{seed:e.seed,pull:e.pull}}},{key:"unmarshal",value:function(t){if(!t||!t.hasOwnProperty("seed")||!t.hasOwnProperty("pull"))throw new Error("PRNG object is missing required data");for(var r=new e(t.seed,!1),n=t.pull;n>0;--n)r.random();return r}}]),e}();return e}(),StyleWrapper=function(){var e=/\[[<>]?[Ii][Mm][Gg]\[(?:\s|\S)*?\]\]+/g,t=new RegExp(e.source),r=function(){function r(e){if(_classCallCheck(this,r),null==e)throw new TypeError("StyleWrapper style parameter must be an HTMLStyleElement object");Object.defineProperties(this,{style:{value:e}})}return _createClass(r,[{key:"isEmpty",value:function(){return 0===this.style.cssRules.length}},{key:"set",value:function(e){this.clear(),this.add(e)}},{key:"add",value:function(r){var n=r;t.test(n)&&(e.lastIndex=0,n=n.replace(e,function(e){var t=Wikifier.helpers.parseSquareBracketedMarkup({source:e,matchStart:0});if(t.hasOwnProperty("error")||t.pos<e.length)return e;var r=t.source;if("data:"!==r.slice(0,5)&&Story.has(r)){var n=Story.get(r);n.tags.includes("Twine.image")&&(r=n.text)}return'url("'+r.replace(/"/g,"%22")+'")'})),this.style.styleSheet?this.style.styleSheet.cssText+=n:this.style.appendChild(document.createTextNode(n))}},{key:"clear",value:function(){this.style.styleSheet?this.style.styleSheet.cssText="":jQuery(this.style).empty()}}]),r}();return r}(),L10n=function(){function e(){r()}function t(e,t){if(!e)return"";var r=function(e){var t=void 0;return e.some(function(e){return!!l10nStrings.hasOwnProperty(e)&&(t=e,!0)}),t}(Array.isArray(e)?e:[e]);if(!r)return"";for(var i=50,o=l10nStrings[r],s=0;a.test(o);){if(++s>i)throw new Error("L10n.get exceeded maximum replacement iterations, probable infinite loop");n.lastIndex=0,o=o.replace(n,function(e){var r=e.slice(1,-1);return t&&t.hasOwnProperty(r)?t[r]:l10nStrings.hasOwnProperty(r)?l10nStrings[r]:void 0})}return o}function r(){strings&&Object.keys(strings).length>0&&Object.keys(l10nStrings).forEach(function(e){try{var t=void 0;switch(e){case"identity":t=strings.identity;break;case"aborting":t=strings.aborting;break;case"cancel":t=strings.cancel;break;case"close":t=strings.close;break;case"ok":t=strings.ok;break;case"errorTitle":t=strings.errors.title;break;case"errorNonexistentPassage":t=strings.errors.nonexistentPassage;break;case"errorSaveMissingData":t=strings.errors.saveMissingData;break;case"errorSaveIdMismatch":t=strings.errors.saveIdMismatch;break;case"warningDegraded":t=strings.warnings.degraded;break;case"debugViewTitle":t=strings.debugView.title;break;case"debugViewToggle":t=strings.debugView.toggle;break;case"uiBarToggle":t=strings.uiBar.toggle;break;case"uiBarBackward":t=strings.uiBar.backward;break;case"uiBarForward":t=strings.uiBar.forward;break;case"uiBarJumpto":t=strings.uiBar.jumpto;break;case"jumptoTitle":t=strings.jumpto.title;break;case"jumptoTurn":t=strings.jumpto.turn;break;case"jumptoUnavailable":t=strings.jumpto.unavailable;break;case"savesTitle":t=strings.saves.title;break;case"savesDisallowed":t=strings.saves.disallowed;break;case"savesEmptySlot":t=strings.saves.emptySlot;break;case"savesIncapable":t=strings.saves.incapable;break;case"savesLabelAuto":t=strings.saves.labelAuto;break;case"savesLabelDelete":t=strings.saves.labelDelete;break;case"savesLabelExport":t=strings.saves.labelExport;break;case"savesLabelImport":t=strings.saves.labelImport;break;case"savesLabelLoad":t=strings.saves.labelLoad;break;case"savesLabelClear":t=strings.saves.labelClear;break;case"savesLabelSave":t=strings.saves.labelSave;break;case"savesLabelSlot":t=strings.saves.labelSlot;break;case"savesSavedOn":t=strings.saves.savedOn;break;case"savesUnavailable":t=strings.saves.unavailable;break;case"savesUnknownDate":t=strings.saves.unknownDate;break;case"settingsTitle":t=strings.settings.title;break;case"settingsOff":t=strings.settings.off;break;case"settingsOn":t=strings.settings.on;break;case"settingsReset":t=strings.settings.reset;break;case"restartTitle":t=strings.restart.title;break;case"restartPrompt":t=strings.restart.prompt;break;case"shareTitle":t=strings.share.title;break;case"autoloadTitle":t=strings.autoload.title;break;case"autoloadCancel":t=strings.autoload.cancel;break;case"autoloadOk":t=strings.autoload.ok;break;case"autoloadPrompt":t=strings.autoload.prompt;break;case"macroBackText":t=strings.macros.back.text;break;case"macroReturnText":t=strings.macros.return.text}t&&(l10nStrings[e]=t.replace(/%\w+%/g,function(e){return"{"+e.slice(1,-1)+"}"}))}catch(e){}})}var n=/\{\w+\}/g,a=new RegExp(n.source);return Object.freeze(Object.defineProperties({},{init:{value:e},get:{value:t}}))}(),strings={errors:{},warnings:{},debugView:{},uiBar:{},jumpto:{},saves:{},settings:{},restart:{},share:{},autoload:{},macros:{back:{},return:{}}},l10nStrings={identity:"game",aborting:"Aborting",cancel:"Cancel",close:"Close",ok:"OK",errorTitle:"Error",errorNonexistentPassage:'the passage "{passage}" does not exist',errorSaveMissingData:"save is missing required data. Either the loaded file is not a save or the save has become corrupted",errorSaveIdMismatch:"save is from the wrong {identity}",_warningIntroLacking:"Your browser either lacks or has disabled",_warningOutroDegraded:", so this {identity} is running in a degraded mode. You may be able to continue, however, some parts may not work properly.",warningNoWebStorage:"{_warningIntroLacking} the Web Storage API{_warningOutroDegraded}",warningDegraded:"{_warningIntroLacking} some of the capabilities required by this {identity}{_warningOutroDegraded}",debugViewTitle:"Debug View",debugViewToggle:"Toggle the debug view",uiBarToggle:"Toggle the UI bar",uiBarBackward:"Go backward within the {identity} history",uiBarForward:"Go forward within the {identity} history",uiBarJumpto:"Jump to a specific point within the {identity} history",jumptoTitle:"Jump To",jumptoTurn:"Turn",jumptoUnavailable:"No jump points currently available…",savesTitle:"Saves",savesDisallowed:"Saving has been disallowed on this passage.",savesEmptySlot:"— slot empty —",savesIncapable:"{_warningIntroLacking} the capabilities required to support saves, so saves have been disabled for this session.",savesLabelAuto:"Autosave",savesLabelDelete:"Delete",savesLabelExport:"Save to Disk…",savesLabelImport:"Load from Disk…",savesLabelLoad:"Load",savesLabelClear:"Delete All",savesLabelSave:"Save",savesLabelSlot:"Slot",savesSavedOn:"Saved on",savesUnavailable:"No save slots found…",savesUnknownDate:"unknown",settingsTitle:"Settings",settingsOff:"Off",settingsOn:"On",settingsReset:"Reset to Defaults",restartTitle:"Restart",restartPrompt:"Are you sure that you want to restart? Unsaved progress will be lost.",shareTitle:"Share",autoloadTitle:"Autoload",autoloadCancel:"Go to start",autoloadOk:"Load autosave",autoloadPrompt:"An autosave exists. Load it now or go to the start?",macroBackText:"Back",macroReturnText:"Return"},Config=function(){function e(){throw new Error("Config.history.mode has been deprecated and is no longer used by SugarCube, please remove it from your code")}function t(){throw new Error("Config.history.tracking has been deprecated, use Config.history.maxStates instead")}var r=Object.seal({debug:!1,addVisitedLinkClass:!1,cleanupWikifierOutput:!1,loadDelay:0,history:Object.seal({controls:!0,maxStates:100,get mode(){e()},set mode(t){e()},get tracking(){t()},set tracking(e){t()}}),macros:Object.seal({ifAssignmentError:!0,maxLoopIterations:1e3}),navigation:Object.seal({override:undefined}),passages:Object.seal({descriptions:undefined,displayTitles:!1,start:undefined,transitionOut:undefined}),saves:Object.seal({autoload:undefined,autosave:undefined,id:"untitled-story",isAllowed:undefined,onLoad:undefined,onSave:undefined,slots:8,version:undefined}),ui:Object.seal({stowBarInitially:800,updateStoryElements:!0}),transitionEndEventName:function(){for(var e=new Map([["transition","transitionend"],["MSTransition","msTransitionEnd"],["WebkitTransition","webkitTransitionEnd"],["MozTransition","transitionend"]]),t=[].concat(_toConsumableArray(e.keys())),r=document.createElement("div"),n=0;n<t.length;++n)if(r.style[t[n]]!==undefined)return e.get(t[n]);return""}()});return r}(),Patterns=function(){var e=/[\u0150\u0170]/g.test("Ő"),t="[\\s\\u00A0\\u2028\\u2029]",r="[0-9A-Z_a-z\\-\\u00C0-\\u00D6\\u00D8-\\u00DE\\u00DF-\\u00F6\\u00F8-\\u00FF"+(e?"\\u0150\\u0170\\u0151\\u0171":"")+"]",n=r.replace("\\-",""),a="[$A-Z_a-z]",i=a+"[$0-9A-Z_a-z]*",o="[$_]",s=o+i,u="[A-Za-z][\\w-]*|[=-]",l="("+r+"+)\\(([^\\)\\|\\n]+)\\):",c="("+r+"+):([^;\\|\\n]+);",d="((?:\\."+r+"+)+);",p="((?:#"+r+"+)+);",f=l+"|"+c+"|"+d+"|"+p,h="(?:file|https?|mailto|ftp|javascript|irc|news|data):[^\\s'\"]+";return Object.freeze({space:t,anyLetter:r,anyLetterStrict:n,identifierFirstChar:a,identifier:i,variableSigil:o,variable:s,macroName:u,inlineCss:f,url:h})}(),Scripting=function(){function addAccessibleClickHandler(e,t,r,n,a){if(arguments.length<2)throw new Error("addAccessibleClickHandler insufficient number of parameters");var i=void 0,o=void 0;if("function"==typeof t?(i=t,o={namespace:n,one:!!r}):(i=r,o={namespace:a,one:!!n,selector:t}),"function"!=typeof i)throw new TypeError("addAccessibleClickHandler handler parameter must be a function");return jQuery(e).ariaClick(o,i)}function insertElement(e,t,r,n,a,i){var o=jQuery(document.createElement(t));return r&&o.attr("id",r),n&&o.addClass(n),i&&o.attr("title",i),a&&o.text(a),e&&o.appendTo(e),o[0]}function insertText(e,t){jQuery(e).append(document.createTextNode(t))}function removeChildren(e){jQuery(e).empty()}function removeElement(e){jQuery(e).remove()}function fade(e,t){function r(){i+=.05*a,n(o,Math.easeInOut(i)),(1===a&&i>=1||a===-1&&i<=0)&&(e.style.visibility="in"===t.fade?"visible":"hidden",o.parentNode.replaceChild(e,o),o=null,window.clearInterval(s),t.onComplete&&t.onComplete())}function n(e,t){e.style.zoom=1,e.style.filter="alpha(opacity="+Math.floor(100*t)+")",e.style.opacity=t}var a="in"===t.fade?1:-1,i=void 0,o=e.cloneNode(!0),s=void 0;e.parentNode.replaceChild(o,e),"in"===t.fade?(i=0,o.style.visibility="visible"):i=1,n(o,i),s=window.setInterval(r,25)}function scrollWindowTo(e,t){function r(){c+=i,window.scroll(0,o+l*(u*Math.easeInOut(c))),c>=1&&window.clearInterval(d)}function n(e){for(var t=0;e.offsetParent;)t+=e.offsetTop,e=e.offsetParent;return t}function a(e){var t=n(e),r=t+e.offsetHeight,a=window.scrollY?window.scrollY:document.body.scrollTop,i=window.innerHeight?window.innerHeight:document.body.clientHeight,o=a+i;return t>=a&&r>o&&e.offsetHeight<i?t-(i-e.offsetHeight)+20:t}var i=null!=t?Number(t):.1;Number.isNaN(i)||!Number.isFinite(i)||i<0?i=.1:i>1&&(i=1);var o=window.scrollY?window.scrollY:document.body.scrollTop,s=a(e),u=Math.abs(o-s),l=o>s?-1:1,c=0,d=void 0;d=window.setInterval(r,25)}function either(){if(0!==arguments.length)return Array.prototype.concat.apply([],arguments).random()}function hasVisited(){if(0===arguments.length)throw new Error("hasVisited called with insufficient parameters");if(State.isEmpty())return!1;for(var e=Array.prototype.concat.apply([],arguments),t=State.passages,r=0,n=e.length;r<n;++r)if(!t.includes(e[r]))return!1;return!0}function lastVisited(){if(0===arguments.length)throw new Error("lastVisited called with insufficient parameters");if(State.isEmpty())return-1;for(var e=Array.prototype.concat.apply([],arguments),t=State.passages,r=t.length-1,n=State.turns,a=0,i=e.length;a<i&&n>-1;++a){var o=t.lastIndexOf(e[a]);n=Math.min(n,o===-1?-1:r-o)}return n}function passage(){return State.passage}function previous(){var e=State.passages;if(arguments.length>0){var t=Number(arguments[0]);if(!Number.isSafeInteger(t)||t<1)throw new RangeError("previous offset parameter must be a positive integer greater than zero");return e.length>t?e[e.length-1-t]:""}for(var r=e.length-2;r>=0;--r)if(e[r]!==State.passage)return e[r];return""}function random(){if(0===arguments.length)throw new Error("random called with insufficient parameters");var e=void 0,t=void 0;if(1===arguments.length?(e=0,t=arguments[0]):(e=arguments[0],t=arguments[1]),e>t){var r=[t,e];e=r[0],t=r[1]}return Math.floor(State.random()*(t-e+1))+e}function randomFloat(){if(0===arguments.length)throw new Error("randomFloat called with insufficient parameters");var e=void 0,t=void 0;if(1===arguments.length?(e=0,t=arguments[0]):(e=arguments[0],t=arguments[1]),e>t){var r=[t,e];e=r[0],t=r[1]}return State.random()*(t-e)+e}function tags(){if(0===arguments.length)return Story.get(State.passage).tags.slice(0);for(var e=Array.prototype.concat.apply([],arguments),t=[],r=0,n=e.length;r<n;++r)t=t.concat(Story.get(e[r]).tags);return t}function time(){return null===Engine.lastPlay?0:Date.now()-Engine.lastPlay}function turns(){return State.turns}function variables(){return State.variables}function visited(){if(State.isEmpty())return 0;for(var e=Array.prototype.concat.apply([],0===arguments.length?[State.passage]:arguments),t=State.passages,r=State.turns,n=0,a=e.length;n<a&&r>0;++n)r=Math.min(r,t.count(e[n]));return r}function visitedTags(){if(0===arguments.length)throw new Error("visitedTags called with insufficient parameters");if(State.isEmpty())return 0;for(var e=Array.prototype.concat.apply([],arguments),t=e.length,r=State.passages,n=new Map,a=0,i=0,o=r.length;i<o;++i){var s=r[i];if(n.has(s))n.get(s)&&++a;else{var u=Story.get(s).tags;if(u.length>0){for(var l=0,c=0;c<t;++c)u.includes(e[c])&&++l;l===t?(++a,n.set(s,!0)):n.set(s,!1)}}}return a}function evalJavaScript(code,output){return function(code,output){return eval(code)}.call(output?{output:output}:null,String(code),output)}function evalTwineScript(code,output){return function(code,output){return eval(code)}.call(output?{output:output}:null,parse(String(code)),output);
-}var parse=function(){function e(e){if(0!==r.lastIndex)throw new RangeError("Scripting.parse last index is non-zero at start");for(var a=e,i=void 0;null!==(i=r.exec(a));)if(i[5]){var o=i[5];if("$"===o||"_"===o)continue;if(n.test(o))o=o[0];else if("is"===o){var s=r.lastIndex,u=a.slice(s);/^\s+not\b/.test(u)&&(a=a.splice(s,u.search(/\S/)),o="isnot")}t.hasOwnProperty(o)&&(a=a.splice(i.index,o.length,t[o]),r.lastIndex+=t[o].length-o.length)}return a}var t=Object.freeze({$:"State.variables.",_:"State.temporary.",to:"=",eq:"==",neq:"!=",is:"===",isnot:"!==",gt:">",gte:">=",lt:"<",lte:"<=",and:"&&",or:"||",not:"!",def:'"undefined" !== typeof',ndef:'"undefined" === typeof'}),r=new RegExp(["(\"\"|'')",'("(?:\\\\.|[^"\\\\])+")',"('(?:\\\\.|[^'\\\\])+')","([=+\\-*\\/%<>&\\|\\^~!?:,;\\(\\)\\[\\]{}]+)","([^\"'=+\\-*\\/%<>&\\|\\^~!?:,;\\(\\)\\[\\]{}\\s]+)"].join("|"),"g"),n=new RegExp("^"+Patterns.variable);return e}();return Object.freeze(Object.defineProperties({},{parse:{value:parse},evalJavaScript:{value:evalJavaScript},evalTwineScript:{value:evalTwineScript}}))}(),Wikifier=function(){var e=void 0,t=0,r=function(){function r(n,a,i){_classCallCheck(this,r),"object"!==("undefined"==typeof e?"undefined":_typeof(e))&&r.compileFormatters(),Object.defineProperties(this,{source:{value:String(a)},options:{writable:!0,value:Object.assign({profile:"all"},i)},nextMatch:{writable:!0,value:0},output:{writable:!0,value:null},_rawArgs:{writable:!0,value:""}}),null==n?this.output=document.createDocumentFragment():n.jquery?this.output=n[0]:this.output=n;try{++t,this.subWikify(this.output),1===t&&Config.cleanupWikifierOutput&&convertBreaks(this.output)}finally{--t}}return _createClass(r,[{key:"subWikify",value:function(e,t,r){var n=this.output,a=void 0;this.output=e,null!=r&&"object"===("undefined"==typeof r?"undefined":_typeof(r))&&(a=this.options,this.options=Object.assign({},this.options,r));var i=t?new RegExp("(?:"+t+")",this.options.ignoreTerminatorCase?"gim":"gm"):null,o=void 0,s=void 0;do{if(this.formatter.formatterRegExp.lastIndex=this.nextMatch,i&&(i.lastIndex=this.nextMatch),s=this.formatter.formatterRegExp.exec(this.source),o=i?i.exec(this.source):null,o&&(!s||o.index<=s.index))return o.index>this.nextMatch&&this.outputText(this.output,this.nextMatch,o.index),this.matchStart=o.index,this.matchLength=o[0].length,this.matchText=o[0],this.nextMatch=i.lastIndex,this.output=n,void(a&&(this.options=a));if(s){s.index>this.nextMatch&&this.outputText(this.output,this.nextMatch,s.index),this.matchStart=s.index,this.matchLength=s[0].length,this.matchText=s[0],this.nextMatch=this.formatter.formatterRegExp.lastIndex;for(var u=void 0,l=1,c=s.length;l<c;++l)if(s[l]){u=l-1;break}if(this.formatter.formatters[u].handler(this),null!=TempState.break)break}}while(o||s);null==TempState.break?this.nextMatch<this.source.length&&(this.outputText(this.output,this.nextMatch,this.source.length),this.nextMatch=this.source.length):this.output.lastChild&&this.output.lastChild.nodeType===Node.ELEMENT_NODE&&"BR"===this.output.lastChild.nodeName.toUpperCase()&&jQuery(this.output.lastChild).remove(),this.output=n,a&&(this.options=a)}},{key:"outputText",value:function(e,t,r){jQuery(e).append(document.createTextNode(this.source.substring(t,r)))}},{key:"rawArgs",value:function(){return this._rawArgs}},{key:"fullArgs",value:function(){return Scripting.parse(this.rawArgs())}},{key:"formatter",get:function(){if(!e.hasOwnProperty(this.options.profile))throw new Error('nonexistent formatter profile "'+this.options.profile+'"');return e[this.options.profile]}}],[{key:"compileFormatters",value:function(){var t=r.formatters,n=t.filter(function(e){return!Array.isArray(e.profiles)||e.profiles.includes("core")});return e={all:{formatters:t,formatterRegExp:new RegExp(t.map(function(e){return"("+e.match+")"}).join("|"),"gm")},core:{formatters:n,formatterRegExp:new RegExp(n.map(function(e){return"("+e.match+")"}).join("|"),"gm")}}}},{key:"getValue",value:function(e){var t=r.parseStoryVariable(e),n=void 0;if(null!==t){n=t.store;for(var a=t.names,i=0,o=a.length;i<o;++i){if("undefined"==typeof n[a[i]]){n=undefined;break}n=n[a[i]]}}return n}},{key:"setValue",value:function(e,t){var n=r.parseStoryVariable(e);if(null!==n){for(var a=n.names,i=a.pop(),o=n.store,s=0,u=a.length;s<u;++s){if("undefined"==typeof o[a[s]]){o=undefined;break}o=o[a[s]]}if(o!==undefined)return o[i]=t,!0}return!1}},{key:"parseStoryVariable",value:function(e){for(var t={store:"$"===e[0]?State.variables:State.temporary,names:[]},n=e,a=void 0;null!==(a=r._parseVarRegExp.exec(n));)n=n.slice(a[0].length),a[1]?t.names.push(a[1]):a[2]?t.names.push(a[2]):a[3]?t.names.push(a[3]):a[4]?t.names.push(a[4]):a[5]?t.names.push(r.getValue(a[5])):a[6]&&t.names.push(Number(a[6]));return""===n?t:null}},{key:"wikifyEval",value:function(e){var t=document.createDocumentFragment();new r(t,e);var n=t.querySelector(".error");if(null!==n)throw new Error(n.textContent.replace(/^(?:(?:Uncaught\s+)?Error:\s+)+/,""));return t}},{key:"createInternalLink",value:function(e,t,r,n){var a=jQuery(document.createElement("a"));return null!=t&&(a.attr("data-passage",t),Story.has(t)?(a.addClass("link-internal"),Config.addVisitedLinkClass&&State.hasPlayed(t)&&a.addClass("link-visited")):a.addClass("link-broken"),a.ariaClick({one:!0},function(){"function"==typeof n&&n(),Engine.play(t)})),r&&a.append(document.createTextNode(r)),e&&a.appendTo(e),a[0]}},{key:"createExternalLink",value:function(e,t,r){var n=jQuery(document.createElement("a")).attr("target","_blank").addClass("link-external").text(r).appendTo(e);return null!=t&&n.attr({href:t,tabindex:0}),n[0]}},{key:"isExternalLink",value:function(e){if(Story.has(e))return!1;var t=new RegExp("^"+Patterns.url,"gim");return t.test(e)||/[\/.?#]/.test(e)}}]),r}();return Object.defineProperties(r,{_parseVarRegExp:{value:new RegExp(["^(?:",Patterns.variableSigil,"(",Patterns.identifier,")|\\.(",Patterns.identifier,")|\\[(?:(?:\"((?:\\\\.|[^\"\\\\])+)\")|(?:'((?:\\\\.|[^'\\\\])+)')|(",Patterns.variableSigil,Patterns.identifierFirstChar,".*)|(\\d+))\\])"].join(""))},helpers:{value:{}},parse:{value:Scripting.parse},evalExpression:{value:Scripting.evalTwineScript},evalStatements:{value:Scripting.evalTwineScript},textPrimitives:{value:Patterns}}),Object.defineProperties(r.helpers,{inlineCss:{value:function(){function e(e){var r={classes:[],id:"",styles:{}},n=void 0;do{t.lastIndex=e.nextMatch;var a=t.exec(e.source);n=a&&a.index===e.nextMatch,n&&(a[1]?r.styles[Util.fromCssProperty(a[1])]=a[2].trim():a[3]?r.styles[Util.fromCssProperty(a[3])]=a[4].trim():a[5]?r.classes=r.classes.concat(a[5].slice(1).split(/\./)):a[6]&&(r.id=a[6].slice(1).split(/#/).pop()),e.nextMatch=t.lastIndex)}while(n);return r}var t=new RegExp(Patterns.inlineCss,"gm");return e}()},evalText:{value:function(e){var t=void 0;try{t=Scripting.evalTwineScript(e),null==t||"function"==typeof t?t=e:(t=String(t),/\[(?:object(?:\s+[^\]]+)?|native\s+code)\]/.test(t)&&(t=e))}catch(r){t=e}return t}},evalPassageId:{value:function(e){return null==e||Story.has(e)?e:r.helpers.evalText(e)}},hasBlockContext:{value:function(e){for(var t="function"==typeof window.getComputedStyle,r=e.length-1;r>=0;--r){var n=e[r];switch(n.nodeType){case Node.ELEMENT_NODE:var a=n.nodeName.toUpperCase();if("BR"===a)return!0;var i=t?window.getComputedStyle(n,null):n.currentStyle;if(i&&i.display){if("none"===i.display)continue;return"block"===i.display}switch(a){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":return!0}return!1;case Node.COMMENT_NODE:continue;default:return!1}}return!0}},createShadowSetterCallback:{value:function(){function e(){if(!a&&(a=r.formatters.find(function(e){return"macro"===e.name}),!a))throw new Error('cannot find "macro" formatter');return a}function t(){for(var t=a||e(),r=new Set,n=t.context;null!==n;n=n.parent)n._shadows&&n._shadows.forEach(function(e){return r.add(e)});return[].concat(_toConsumableArray(r))}function n(e){var r={};return t().forEach(function(e){var t=e.slice(1),n="$"===e[0]?State.variables:State.temporary;r[e]=n[t]}),function(){var t=Object.keys(r),n=t.length>0?{}:null;try{return t.forEach(function(e){var t=e.slice(1),a="$"===e[0]?State.variables:State.temporary;a.hasOwnProperty(t)&&(n[t]=a[t]),a[t]=r[e]}),Scripting.evalJavaScript(e)}finally{t.forEach(function(e){var t=e.slice(1),a="$"===e[0]?State.variables:State.temporary;r[e]=a[t],n.hasOwnProperty(t)?a[t]=n[t]:delete a[t]})}}}var a=null;return n}()},parseSquareBracketedMarkup:{value:function(e){function t(){return d>=e.source.length?u:e.source[d++]}function r(){return d>=e.source.length?u:e.source[d]}function n(t){return t<1||d+t>=e.source.length?u:e.source[d+t]}function a(){return{error:String.format.apply(String,arguments),pos:d}}function i(){c=d}function o(t){var r=e.source.slice(c,d).trim();if(""===r)throw new Error("malformed wiki "+(h?"link":"image")+", empty "+t+" component");"link"===t&&"~"===r[0]?(l.forceInternal=!0,l.link=r.slice(1)):l[t]=r,c=d}function s(e){++d;e:for(;;){switch(r()){case"\\":++d;var t=r();if(t!==u&&"\n"!==t)break;case u:case"\n":return u;case e:break e}++d}return d}var u=-1,l={},c=e.matchStart,d=c+1,p=void 0,f=void 0,h=void 0,g=void 0;if(g=r(),"["===g)h=l.isLink=!0;else{switch(h=!1,g){case"<":l.align="left",++d;break;case">":l.align="right",++d}if(!/^[Ii][Mm][Gg]$/.test(e.source.slice(d,d+3)))return a("malformed square-bracketed wiki markup");d+=3,l.isImage=!0}if("["!==t())return a("malformed wiki {0}",h?"link":"image");p=1,f=0,i();try{e:for(;;){switch(g=r()){case u:case"\n":return a("unterminated wiki {0}",h?"link":"image");case'"':if(s(g)===u)return a("unterminated double quoted string in wiki {0}",h?"link":"image");break;case"'":if((4===f||3===f&&h)&&s(g)===u)return a("unterminated single quoted string in wiki {0}",h?"link":"image");break;case"|":0===f&&(o(h?"text":"title"),++c,f=1);break;case"-":0===f&&">"===n(1)&&(o(h?"text":"title"),++d,c+=2,f=1);break;case"<":0===f&&"-"===n(1)&&(o(h?"link":"source"),++d,c+=2,f=2);break;case"[":if(f===-1)return a("unexpected left square bracket '['");++p,1===p&&(i(),++c);break;case"]":if(--p,0===p){switch(f){case 0:case 1:o(h?"link":"source"),f=3;break;case 2:o(h?"text":"title"),f=3;break;case 3:h?(o("setter"),f=-1):(o("link"),f=4);break;case 4:o("setter"),f=-1}if(++d,"]"===r()){++d;break e}--d}}++d}}catch(e){return a(e.message)}return l.pos=d,l}}}),Object.defineProperty(r,"formatters",{value:[{name:"macro",profiles:["core"],match:"<<",lookahead:new RegExp("<<(\\/?"+Patterns.macroName+")(?:\\s*)((?:(?:\"(?:\\\\.|[^\"\\\\])*\")|(?:'(?:\\\\.|[^'\\\\])*')|(?:\\[(?:[<>]?[Ii][Mm][Gg])?\\[[^\\r\\n]*?\\]\\]+)|[^>]|(?:>(?!>)))*)>>","gm"),argsPattern:["(``)","`((?:\\\\.|[^`\\\\])+)`","(\"\"|'')",'("(?:\\\\.|[^"\\\\])+")',"('(?:\\\\.|[^'\\\\])+')","(\\[(?:[<>]?[Ii][Mm][Gg])?\\[[^\\r\\n]*?\\]\\]+)","([^`\"'\\s]+)","(`|\"|')"].join("|"),working:{source:"",name:"",arguments:"",index:0},context:null,handler:function(e){var t=this.lookahead.lastIndex=e.matchStart;if(this.parseTag(e)){var r=e.nextMatch,n=this.working.source,a=this.working.name,i=this.working.arguments,o=void 0;try{if(o=Macro.get(a),!o){if(Macro.tags.has(a)){var s=Macro.tags.get(a);return throwError(e.output,"child tag <<"+a+">> was found outside of a call to its parent macro"+(1===s.length?"":"s")+" <<"+s.join(">>, <<")+">>",e.source.slice(t,e.nextMatch))}return throwError(e.output,"macro <<"+a+">> does not exist",e.source.slice(t,e.nextMatch))}var u=null;if(o.hasOwnProperty("tags")&&(u=this.parseBody(e,o),!u))return e.nextMatch=r,throwError(e.output,"cannot find a closing tag for macro <<"+a+">>",e.source.slice(t,e.nextMatch)+"…");if("function"!=typeof o.handler)return throwError(e.output,"macro <<"+a+">> handler function "+(o.hasOwnProperty("handler")?"is not a function":"does not exist"),e.source.slice(t,e.nextMatch));var l=u?u[0].args:this.createArgs(i,o.hasOwnProperty("skipArgs")&&!!o.skipArgs||o.hasOwnProperty("skipArg0")&&!!o.skipArg0);if(o.hasOwnProperty("_MACRO_API")){this.context=new MacroContext({parent:this.context,macro:o,name:a,args:l,payload:u,parser:e,source:n});try{o.handler.call(this.context)}finally{this.context=this.context.parent}}else{var c=e._rawArgs;e._rawArgs=i,o.handler(e.output,a,l,e,u),e._rawArgs=c}}catch(r){return throwError(e.output,"cannot execute "+(o&&o.isWidget?"widget":"macro")+" <<"+a+">>: "+r.message,e.source.slice(t,e.nextMatch))}finally{this.working.source="",this.working.name="",this.working.arguments="",this.working.index=0}}else e.outputText(e.output,e.matchStart,e.nextMatch)},parseTag:function(e){var t=this.lookahead.exec(e.source);return!(!t||t.index!==e.matchStart||!t[1])&&(e.nextMatch=this.lookahead.lastIndex,this.working.source=e.source.slice(t.index,this.lookahead.lastIndex),this.working.name=t[1],this.working.arguments=t[2],this.working.index=t.index,!0)},parseBody:function(e,t){for(var r=this.working.name,n="/"+r,a="end"+r,i=!!Array.isArray(t.tags)&&t.tags,o=[],s=t.hasOwnProperty("skipArgs")&&t.skipArgs,u=t.hasOwnProperty("skipArg0")&&t.skipArg0,l=-1,c=1,d=this.working.source,p=this.working.name,f=this.working.arguments,h=e.nextMatch;(e.matchStart=e.source.indexOf(this.match,e.nextMatch))!==-1;)if(this.parseTag(e)){var g=this.working.source,m=this.working.name,v=this.working.arguments,y=this.working.index,b=e.nextMatch;switch(m){case r:++c;break;case a:case n:--c;break;default:if(1===c&&i)for(var w=0,k=i.length;w<k;++w)m===i[w]&&(o.push({source:d,name:p,arguments:f,args:this.createArgs(f,s||0===o.length&&u),contents:e.source.slice(h,y)}),d=g,p=m,f=v,h=b)}if(0===c){o.push({source:d,name:p,arguments:f,args:this.createArgs(f,s||0===o.length&&u),contents:e.source.slice(h,y)}),l=b;break}}else this.lookahead.lastIndex=e.nextMatch=e.matchStart+this.match.length;return l!==-1?(e.nextMatch=l,o):null},createArgs:function(e,t){var r=t?[]:this.parseArgs(e);return Object.defineProperties(r,{raw:{value:e},full:{value:Scripting.parse(e)}}),r},parseArgs:function(e){for(var t=new RegExp(this.argsPattern,"gm"),n=[],a=new RegExp("^"+Patterns.variable),i=void 0;null!==(i=t.exec(e));){var o=void 0;if(i[1])o=undefined;else if(i[2]){o=i[2];try{o=Scripting.evalTwineScript(o)}catch(e){throw new Error('unable to parse macro argument "'+o+'": '+e.message)}}else if(i[3])o="";else if(i[4]){o=i[4];try{o=Scripting.evalJavaScript(o)}catch(e){throw new Error("unable to parse macro argument '"+o+"': "+e.message)}}else if(i[5]){o=i[5];try{o=Scripting.evalJavaScript(o)}catch(e){throw new Error('unable to parse macro argument "'+o+'": '+e.message)}}else if(i[6]){o=i[6];var s=r.helpers.parseSquareBracketedMarkup({source:o,matchStart:0});if(s.hasOwnProperty("error"))throw new Error('unable to parse macro argument "'+o+'": '+s.error);if(s.pos<o.length)throw new Error('unable to parse macro argument "'+o+'": unexpected character(s) "'+o.slice(s.pos)+'" (pos: '+s.pos+")");s.isLink?(o={isLink:!0},o.count=s.hasOwnProperty("text")?2:1,o.link=r.helpers.evalPassageId(s.link),o.text=s.hasOwnProperty("text")?r.helpers.evalText(s.text):o.link,o.external=!s.forceInternal&&r.isExternalLink(o.link),o.setFn=s.hasOwnProperty("setter")?r.helpers.createShadowSetterCallback(Scripting.parse(s.setter)):null):s.isImage&&(o=function(e){var t={source:e,isImage:!0};if("data:"!==e.slice(0,5)&&Story.has(e)){var r=Story.get(e);r.tags.includes("Twine.image")&&(t.source=r.text,t.passage=r.title)}return t}(r.helpers.evalPassageId(s.source)),s.hasOwnProperty("align")&&(o.align=s.align),s.hasOwnProperty("title")&&(o.title=r.helpers.evalText(s.title)),s.hasOwnProperty("link")&&(o.link=r.helpers.evalPassageId(s.link),o.external=!s.forceInternal&&r.isExternalLink(o.link)),o.setFn=s.hasOwnProperty("setter")?r.helpers.createShadowSetterCallback(Scripting.parse(s.setter)):null)}else if(i[7])if(o=i[7],a.test(o))o=r.getValue(o);else if(/^(?:settings|setup)[.[]/.test(o))try{o=Scripting.evalTwineScript(o)}catch(e){throw new Error('unable to parse macro argument "'+o+'": '+e.message)}else if("null"===o)o=null;else if("undefined"===o)o=undefined;else if("true"===o)o=!0;else if("false"===o)o=!1;else{var u=Number(o);Number.isNaN(u)||(o=u)}else if(i[8]){var l=void 0;switch(i[8]){case"`":l="backtick expression";break;case'"':l="double quoted string";break;case"'":l="single quoted string"}throw new Error("unterminated "+l+" in macro argument string")}n.push(o)}return n}},{name:"prettyLink",profiles:["core"],match:"\\[\\[[^[]",handler:function(e){var t=r.helpers.parseSquareBracketedMarkup(e);if(t.hasOwnProperty("error"))return void e.outputText(e.output,e.matchStart,e.nextMatch);e.nextMatch=t.pos;var n=r.helpers.evalPassageId(t.link),a=t.hasOwnProperty("text")?r.helpers.evalText(t.text):n,i=t.hasOwnProperty("setter")?r.helpers.createShadowSetterCallback(Scripting.parse(t.setter)):null,o=(Config.debug?new DebugView(e.output,"wiki-link","[[link]]",e.source.slice(e.matchStart,e.nextMatch)):e).output;t.forceInternal||!r.isExternalLink(n)?r.createInternalLink(o,n,a,i):r.createExternalLink(o,n,a)}},{name:"urlLink",profiles:["core"],match:Patterns.url,handler:function(e){e.outputText(r.createExternalLink(e.output,e.matchText),e.matchStart,e.nextMatch)}},{name:"image",profiles:["core"],match:"\\[[<>]?[Ii][Mm][Gg]\\[",handler:function(e){var t=r.helpers.parseSquareBracketedMarkup(e);if(t.hasOwnProperty("error"))return void e.outputText(e.output,e.matchStart,e.nextMatch);e.nextMatch=t.pos;var n=void 0;Config.debug&&(n=new DebugView(e.output,"wiki-image",t.hasOwnProperty("link")?"[img[][link]]":"[img[]]",e.source.slice(e.matchStart,e.nextMatch)),n.modes({block:!0}));var a=t.hasOwnProperty("setter")?r.helpers.createShadowSetterCallback(Scripting.parse(t.setter)):null,i=(Config.debug?n:e).output,o=void 0;if(t.hasOwnProperty("link")){var s=r.helpers.evalPassageId(t.link);i=t.forceInternal||!r.isExternalLink(s)?r.createInternalLink(i,s,null,a):r.createExternalLink(i,s),i.classList.add("link-image")}if(i=jQuery(document.createElement("img")).appendTo(i).get(0),o=r.helpers.evalPassageId(t.source),"data:"!==o.slice(0,5)&&Story.has(o)){var u=Story.get(o);u.tags.includes("Twine.image")&&(i.setAttribute("data-passage",u.title),o=u.text)}i.src=o,t.hasOwnProperty("title")&&(i.title=r.helpers.evalText(t.title)),t.hasOwnProperty("align")&&(i.align=t.align)}},{name:"monospacedByBlock",profiles:["block"],match:"^\\{\\{\\{\\n",lookahead:/^\{\{\{\n((?:^[^\n]*\n)+?)(^\}\}\}$\n?)/gm,handler:function(e){this.lookahead.lastIndex=e.matchStart;var t=this.lookahead.exec(e.source);t&&t.index===e.matchStart&&(jQuery(document.createElement("pre")).text(t[1]).appendTo(e.output),e.nextMatch=this.lookahead.lastIndex)}},{name:"formatByChar",profiles:["core"],match:"''|//|__|\\^\\^|~~|==|\\{\\{\\{",handler:function(e){switch(e.matchText){case"''":e.subWikify(jQuery(document.createElement("strong")).appendTo(e.output).get(0),"''");break;case"//":e.subWikify(jQuery(document.createElement("em")).appendTo(e.output).get(0),"//");break;case"__":e.subWikify(jQuery(document.createElement("u")).appendTo(e.output).get(0),"__");break;case"^^":e.subWikify(jQuery(document.createElement("sup")).appendTo(e.output).get(0),"\\^\\^");break;case"~~":e.subWikify(jQuery(document.createElement("sub")).appendTo(e.output).get(0),"~~");break;case"==":e.subWikify(jQuery(document.createElement("s")).appendTo(e.output).get(0),"==");break;case"{{{":var t=/\{\{\{((?:.|\n)*?)\}\}\}/gm;t.lastIndex=e.matchStart;var r=t.exec(e.source);r&&r.index===e.matchStart&&(jQuery(document.createElement("code")).text(r[1]).appendTo(e.output),e.nextMatch=t.lastIndex)}}},{name:"customStyle",profiles:["core"],match:"@@",terminator:"@@",blockRegExp:/\s*\n/gm,handler:function(e){var t=r.helpers.inlineCss(e);this.blockRegExp.lastIndex=e.nextMatch;var n=this.blockRegExp.exec(e.source),a=n&&n.index===e.nextMatch,i=jQuery(document.createElement(a?"div":"span")).appendTo(e.output);0===t.classes.length&&""===t.id&&0===Object.keys(t.styles).length?i.addClass("marked"):(t.classes.forEach(function(e){return i.addClass(e)}),""!==t.id&&i.attr("id",t.id),i.css(t.styles)),a?(e.nextMatch+=n[0].length,e.subWikify(i[0],"\\n?"+this.terminator)):e.subWikify(i[0],this.terminator)}},{name:"verbatimText",profiles:["core"],match:'"{3}|<nowiki>',lookahead:/(?:"{3}((?:.|\n)*?)"{3})|(?:<nowiki>((?:.|\n)*?)<\/nowiki>)/gm,handler:function(e){this.lookahead.lastIndex=e.matchStart;var t=this.lookahead.exec(e.source);t&&t.index===e.matchStart&&(jQuery(document.createElement("span")).addClass("verbatim").text(t[1]||t[2]).appendTo(e.output),e.nextMatch=this.lookahead.lastIndex)}},{name:"horizontalRule",profiles:["core"],match:"^----+$\\n?|<hr\\s*/?>\\n?",handler:function(e){jQuery(document.createElement("hr")).appendTo(e.output)}},{name:"emdash",profiles:["core"],match:"--",handler:function(e){jQuery(document.createTextNode("—")).appendTo(e.output)}},{name:"doubleDollarSign",profiles:["core"],match:"\\${2}",handler:function(e){jQuery(document.createTextNode("$")).appendTo(e.output)}},{name:"nakedVariable",profiles:["core"],match:Patterns.variable+"(?:(?:\\."+Patterns.identifier+")|(?:\\[\\d+\\])|(?:\\[\"(?:\\\\.|[^\"\\\\])+\"\\])|(?:\\['(?:\\\\.|[^'\\\\])+'\\])|(?:\\["+Patterns.variable+"\\]))*",handler:function(e){var t=toStringOrDefault(r.getValue(e.matchText),null);null===t?jQuery(document.createTextNode(e.matchText)).appendTo(e.output):new r((Config.debug?new DebugView(e.output,"variable",e.matchText,e.matchText):e).output,t)}},{name:"heading",profiles:["block"],match:"^!{1,6}",terminator:"\\n",handler:function(e){return r.helpers.hasBlockContext(e.output.childNodes)?void e.subWikify(jQuery(document.createElement("h"+e.matchLength)).appendTo(e.output).get(0),this.terminator):void jQuery(e.output).append(document.createTextNode(e.matchText))}},{name:"table",profiles:["block"],match:"^\\|(?:[^\\n]*)\\|(?:[fhck]?)$",lookahead:/^\|([^\n]*)\|([fhck]?)$/gm,rowTerminator:"\\|(?:[cfhk]?)$\\n?",cellPattern:"(?:\\|([^\\n\\|]*)\\|)|(\\|[cfhk]?$\\n?)",cellTerminator:"(?:\\u0020*)\\|",rowTypes:{c:"caption",f:"tfoot",h:"thead","":"tbody"},handler:function(e){if(!r.helpers.hasBlockContext(e.output.childNodes))return void jQuery(e.output).append(document.createTextNode(e.matchText));var t=jQuery(document.createElement("table")).appendTo(e.output).get(0),n=[],a=null,i=null,o=0,s=void 0;e.nextMatch=e.matchStart;do{this.lookahead.lastIndex=e.nextMatch;var u=this.lookahead.exec(e.source);if(s=u&&u.index===e.nextMatch){var l=u[2];"k"===l?(t.className=u[1],e.nextMatch+=u[0].length+1):(l!==a&&(a=l,i=jQuery(document.createElement(this.rowTypes[l])).appendTo(t)),"c"===a?(i.css("caption-side",0===o?"top":"bottom"),e.nextMatch+=1,e.subWikify(i[0],this.rowTerminator)):this.rowHandler(e,jQuery(document.createElement("tr")).appendTo(i).get(0),n),++o)}}while(s)},rowHandler:function(e,t,n){var a=this,i=new RegExp(this.cellPattern,"gm"),o=0,s=1,u=void 0;do{i.lastIndex=e.nextMatch;var l=i.exec(e.source);if(u=l&&l.index===e.nextMatch){if("~"===l[1]){var c=n[o];c&&(++c.rowCount,c.$element.attr("rowspan",c.rowCount).css("vertical-align","middle")),e.nextMatch=l.index+l[0].length-1}else if(">"===l[1])++s,e.nextMatch=l.index+l[0].length-1;else{if(l[2]){e.nextMatch=l.index+l[0].length;break}!function(){++e.nextMatch;for(var i=r.helpers.inlineCss(e),u=!1,l=!1,c=void 0;" "===e.source.substr(e.nextMatch,1);)u=!0,++e.nextMatch;"!"===e.source.substr(e.nextMatch,1)?(c=jQuery(document.createElement("th")).appendTo(t),++e.nextMatch):c=jQuery(document.createElement("td")).appendTo(t),n[o]={rowCount:1,$element:c},s>1&&(c.attr("colspan",s),s=1),e.subWikify(c[0],a.cellTerminator)," "===e.matchText.substr(e.matchText.length-2,1)&&(l=!0),i.classes.forEach(function(e){return c.addClass(e)}),""!==i.id&&c.attr("id",i.id),u&&l?i.styles["text-align"]="center":u?i.styles["text-align"]="right":l&&(i.styles["text-align"]="left"),c.css(i.styles),e.nextMatch=e.nextMatch-1}()}++o}}while(u)}},{name:"list",profiles:["block"],match:"^(?:(?:\\*+)|(?:#+))",lookahead:/^(?:(\*+)|(#+))/gm,terminator:"\\n",handler:function(e){if(!r.helpers.hasBlockContext(e.output.childNodes))return void jQuery(e.output).append(document.createTextNode(e.matchText));e.nextMatch=e.matchStart;var t=[e.output],n=null,a=0,i=void 0,o=void 0;do{this.lookahead.lastIndex=e.nextMatch;var s=this.lookahead.exec(e.source);if(i=s&&s.index===e.nextMatch){var u=s[2]?"ol":"ul",l=s[0].length;if(e.nextMatch+=s[0].length,l>a)for(o=a;o<l;++o)t.push(jQuery(document.createElement(u)).appendTo(t[t.length-1]).get(0));else if(l<a)for(o=a;o>l;--o)t.pop();else l===a&&u!==n&&(t.pop(),t.push(jQuery(document.createElement(u)).appendTo(t[t.length-1]).get(0)));a=l,n=u,e.subWikify(jQuery(document.createElement("li")).appendTo(t[t.length-1]).get(0),this.terminator)}}while(i)}},{name:"quoteByBlock",profiles:["block"],match:"^<<<\\n",terminator:"^<<<\\n",handler:function(e){return r.helpers.hasBlockContext(e.output.childNodes)?void e.subWikify(jQuery(document.createElement("blockquote")).appendTo(e.output).get(0),this.terminator):void jQuery(e.output).append(document.createTextNode(e.matchText))}},{name:"quoteByLine",profiles:["block"],match:"^>+",lookahead:/^>+/gm,terminator:"\\n",handler:function(e){if(!r.helpers.hasBlockContext(e.output.childNodes))return void jQuery(e.output).append(document.createTextNode(e.matchText));var t=[e.output],n=0,a=e.matchLength,i=void 0,o=void 0;do{if(a>n)for(o=n;o<a;++o)t.push(jQuery(document.createElement("blockquote")).appendTo(t[t.length-1]).get(0));else if(a<n)for(o=n;o>a;--o)t.pop();n=a,e.subWikify(t[t.length-1],this.terminator),jQuery(document.createElement("br")).appendTo(t[t.length-1]),this.lookahead.lastIndex=e.nextMatch;var s=this.lookahead.exec(e.source);i=s&&s.index===e.nextMatch,i&&(a=s[0].length,e.nextMatch+=s[0].length)}while(i)}},{name:"html",profiles:["core"],match:"<[Hh][Tt][Mm][Ll]>",lookahead:/<[Hh][Tt][Mm][Ll]>((?:.|\n)*?)<\/[Hh][Tt][Mm][Ll]>/gm,handler:function(e){this.lookahead.lastIndex=e.matchStart;var t=this.lookahead.exec(e.source);t&&t.index===e.matchStart&&(e.nextMatch=this.lookahead.lastIndex,jQuery(document.createDocumentFragment()).append(t[1]).appendTo(e.output))}},{name:"commentByBlock",profiles:["core"],match:"(?:/(?:%|\\*))|(?:<!--)",lookahead:/(?:\/(%|\*)(?:(?:.|\n)*?)\1\/)|(?:<!--(?:(?:.|\n)*?)-->)/gm,handler:function(e){this.lookahead.lastIndex=e.matchStart;var t=this.lookahead.exec(e.source);t&&t.index===e.matchStart&&(e.nextMatch=this.lookahead.lastIndex)}},{name:"lineContinuation",profiles:["core"],match:"\\\\"+Patterns.space+"*?(?:\\n|$)|(?:^|\\n)"+Patterns.space+"*?\\\\",handler:function(e){e.nextMatch=e.matchStart+e.matchLength}},{name:"lineBreak",profiles:["core"],match:"\\n|<br\\s*/?>",handler:function(e){e.options.nobr||jQuery(document.createElement("br")).appendTo(e.output)}},{name:"htmlCharacterReference",profiles:["core"],match:"(?:(?:&#?[0-9A-Za-z]{2,8};|.)(?:&#?(?:x0*(?:3[0-6][0-9A-Fa-f]|1D[C-Fc-f][0-9A-Fa-f]|20[D-Fd-f][0-9A-Fa-f]|FE2[0-9A-Fa-f])|0*(?:76[89]|7[7-9][0-9]|8[0-7][0-9]|761[6-9]|76[2-7][0-9]|84[0-3][0-9]|844[0-7]|6505[6-9]|6506[0-9]|6507[0-1]));)+|&#?[0-9A-Za-z]{2,8};)",handler:function(e){jQuery(document.createDocumentFragment()).append(e.matchText).appendTo(e.output)}},{name:"htmlTag",profiles:["core"],match:"<\\w+(?:\\s+[^\\u0000-\\u001F\\u007F-\\u009F\\s\"'>\\/=]+(?:\\s*=\\s*(?:\"[^\"]*?\"|'[^']*?'|[^\\s\"'=<>`]+))?)*\\s*\\/?>",tagPattern:"<(\\w+)",voidElements:["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],nobrElements:["colgroup","datalist","dl","figure","ol","optgroup","select","table","tbody","tfoot","thead","tr","ul"],handler:function(e){var t=new RegExp(this.tagPattern).exec(e.matchText),r=t&&t[1],n=r&&r.toLowerCase();if(n){var a=this.voidElements.includes(n),i=this.nobrElements.includes(n),o=void 0,s=void 0;if(!a){o="<\\/"+n+"\\s*>";var u=new RegExp(o,"gim");u.lastIndex=e.matchStart,s=u.exec(e.source)}if(a||s){var l=e.output,c=document.createElement(e.output.tagName),d=void 0;for(c.innerHTML=e.matchText;c.firstChild;)c=c.firstChild;c.hasAttribute("data-passage")&&(this.processDataAttributes(c),Config.debug&&(d=new DebugView(e.output,"html-"+n,n,e.matchText),d.modes({block:"img"===n,nonvoid:s}),l=d.output)),s&&(e.subWikify(c,o,{ignoreTerminatorCase:!0,nobr:i}),d&&jQuery(c).find(".debug.block").length>0&&d.modes({block:!0})),l.appendChild(c)}else throwError(e.output,'HTML tag "'+r+'" is not closed',e.matchText+"…")}},processDataAttributes:function(e){var t=e.getAttribute("data-passage");if(null!=t){var n=r.helpers.evalPassageId(t);n!==t&&(t=n,e.setAttribute("data-passage",n)),""!==t&&("IMG"===e.tagName.toUpperCase()?"data:"!==t.slice(0,5)&&Story.has(t)&&(t=Story.get(t),t.tags.includes("Twine.image")&&(e.src=t.text.trim())):!function(){var n=e.getAttribute("data-setter"),a=void 0;null!=n&&(n=String(n).trim(),""!==n&&(a=r.helpers.createShadowSetterCallback(Scripting.parse(n)))),Story.has(t)?(e.classList.add("link-internal"),Config.addVisitedLinkClass&&State.hasPlayed(t)&&e.classList.add("link-visited")):e.classList.add("link-broken"),jQuery(e).ariaClick({one:!0},function(){"function"==typeof a&&a.call(this),Engine.play(t)})}())}}}]}),r}(),Macro=function(){function e(t,r,a){if(Array.isArray(t))return void t.forEach(function(t){return e(t,r,a)});if(!p.test(t))throw new Error('invalid macro name "'+t+'"');if(n(t))throw new Error("cannot clobber existing macro <<"+t+">>");if(u(t))throw new Error("cannot clobber child tag <<"+t+">> of parent macro"+(1===d[t].length?"":"s")+" <<"+d[t].join(">>, <<")+">>");try{if("object"===("undefined"==typeof r?"undefined":_typeof(r)))c[t]=a?clone(r):r;else{if(!n(r))throw new Error("cannot create alias of nonexistent macro <<"+r+">>");c[t]=a?clone(c[r]):c[r]}Object.defineProperty(c,t,{writable:!1}),c[t]._MACRO_API=!0}catch(e){throw"TypeError"===e.name?new Error("cannot clobber protected macro <<"+t+">>"):new Error("unknown error when attempting to add macro <<"+t+">>: ["+e.name+"] "+e.message)}if(c[t].hasOwnProperty("tags"))if(null==c[t].tags)o(t);else{if(!Array.isArray(c[t].tags))throw new Error('bad value for "tags" property of macro <<'+t+">>");o(t,c[t].tags)}}function t(e){if(Array.isArray(e))return void e.forEach(function(e){return t(e)});if(n(e)){c[e].hasOwnProperty("tags")&&s(e);try{Object.defineProperty(c,e,{writable:!0}),delete c[e]}catch(t){throw new Error("unknown error removing macro <<"+e+">>: "+t.message)}}else if(u(e))throw new Error("cannot remove child tag <<"+e+">> of parent macro <<"+d[e]+">>")}function r(){return 0===Object.keys(c).length}function n(e){return c.hasOwnProperty(e)}function a(e){var t=null;return n(e)&&"function"==typeof c[e].handler?t=c[e]:macros.hasOwnProperty(e)&&"function"==typeof macros[e].handler&&(t=macros[e]),t}function i(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"init";Object.keys(c).forEach(function(t){"function"==typeof c[t][e]&&c[t][e](t)}),Object.keys(macros).forEach(function(t){"function"==typeof macros[t][e]&&macros[t][e](t)})}function o(e,t){if(!e)throw new Error("no parent specified");for(var r=["/"+e,"end"+e],a=[].concat(r,Array.isArray(t)?t:[]),i=0;i<a.length;++i){var o=a[i];if(n(o))throw new Error("cannot register tag for an existing macro");u(o)?d[o].includes(e)||(d[o].push(e),d[o].sort()):d[o]=[e]}}function s(e){if(!e)throw new Error("no parent specified");Object.keys(d).forEach(function(t){var r=d[t].indexOf(e);r!==-1&&(1===d[t].length?delete d[t]:d[t].splice(r,1))})}function u(e){return d.hasOwnProperty(e)}function l(e){return u(e)?d[e]:null}var c={},d={},p=new RegExp("^(?:"+Patterns.macroName+")$");return Object.freeze(Object.defineProperties({},{add:{value:e},delete:{value:t},isEmpty:{value:r},has:{value:n},get:{value:a},init:{value:i},tags:{value:Object.freeze(Object.defineProperties({},{register:{value:o},unregister:{value:s},has:{value:u},get:{value:l}}))},evalStatements:{value:function(){return Scripting.evalJavaScript.apply(Scripting,arguments);
-}}}))}(),MacroContext=function(){var e=function(){function e(t){_classCallCheck(this,e);var r=Object.assign({parent:null,macro:null,name:"",args:null,payload:null,parser:null,source:""},t);if(null===r.macro||""===r.name||null===r.parser)throw new TypeError("context object missing required properties");Object.defineProperties(this,{parent:{value:r.parent},self:{value:r.macro},name:{value:r.name},args:{value:r.args},payload:{value:r.payload},source:{value:r.source},parser:{value:r.parser},_output:{value:r.parser.output},_shadows:{writable:!0,value:null},_debugView:{writable:!0,value:null},_debugViewEnabled:{writable:!0,value:Config.debug}})}return _createClass(e,[{key:"contextHas",value:function(e){for(var t=this;null!==(t=t.parent);)if(e(t))return!0;return!1}},{key:"contextSelect",value:function(e){for(var t=this;null!==(t=t.parent);)if(e(t))return t;return null}},{key:"contextSelectAll",value:function(e){for(var t=[],r=this;null!==(r=r.parent);)e(r)&&t.push(r);return t}},{key:"addShadow",value:function(){var e=this;this._shadows||(this._shadows=new Set);for(var t=new RegExp("^"+Patterns.variable+"$"),r=arguments.length,n=Array(r),a=0;a<r;a++)n[a]=arguments[a];n.flatten().forEach(function(r){if("string"!=typeof r)throw new TypeError("variable name must be a string; type: "+("undefined"==typeof r?"undefined":_typeof(r)));if(!t.test(r))throw new Error('invalid variable name "'+r+'"');e._shadows.add(r)})}},{key:"createShadowWrapper",value:function(e,t,r){var n=void 0;return"function"==typeof e&&(n={},this.shadowView.forEach(function(e){var t=e.slice(1),r="$"===e[0]?State.variables:State.temporary;n[e]=r[t]})),function(){for(var a=this,i=arguments.length,o=Array(i),s=0;s<i;s++)o[s]=arguments[s];"function"==typeof r&&r.apply(this,o),"function"==typeof e&&!function(){var t=Object.keys(n),r=t.length>0?{}:null;try{t.forEach(function(e){var t=e.slice(1),a="$"===e[0]?State.variables:State.temporary;a.hasOwnProperty(t)&&(r[t]=a[t]),a[t]=n[e]}),e.apply(a,o)}finally{t.forEach(function(e){var t=e.slice(1),a="$"===e[0]?State.variables:State.temporary;n[e]=a[t],r.hasOwnProperty(t)?a[t]=r[t]:delete a[t]})}}(),"function"==typeof t&&t.apply(this,o)}}},{key:"createDebugView",value:function(e,t){return this._debugView=new DebugView(this._output,"macro",e?e:this.name,t?t:this.source),null!==this.payload&&this.payload.length>0&&this._debugView.modes({nonvoid:!0}),this._debugViewEnabled=!0,this._debugView}},{key:"removeDebugView",value:function(){null!==this._debugView&&(this._debugView.remove(),this._debugView=null),this._debugViewEnabled=!1}},{key:"error",value:function(e,t){return throwError(this._output,"<<"+this.name+">>: "+e,t?t:this.source)}},{key:"output",get:function(){return this._debugViewEnabled?this.debugView.output:this._output}},{key:"shadows",get:function(){return[].concat(_toConsumableArray(this._shadows))}},{key:"shadowView",get:function(){var e=new Set;return this.contextSelectAll(function(e){return e._shadows}).forEach(function(t){return t._shadows.forEach(function(t){return e.add(t)})}),[].concat(_toConsumableArray(e))}},{key:"debugView",get:function(){return this._debugViewEnabled?null!==this._debugView?this._debugView:this.createDebugView():null}}]),e}();return e}();!function(){Macro.add("capture",{skipArgs:!0,tags:null,handler:function(){if(0===this.args.raw.length)return this.error("no story/temporary variable list specified");var e={};try{for(var t=new RegExp("("+Patterns.variable+")","g"),r=void 0;null!==(r=t.exec(this.args.raw));){var n=r[1],a=n.slice(1),i="$"===n[0]?State.variables:State.temporary;i.hasOwnProperty(a)&&(e[a]=i[a]),this.addShadow(n)}new Wikifier(this.output,this.payload[0].contents)}finally{this.shadows.forEach(function(t){var r=t.slice(1),n="$"===t[0]?State.variables:State.temporary;e.hasOwnProperty(r)?n[r]=e[r]:delete n[r]})}}}),Macro.add("set",{skipArgs:!0,handler:function(){if(0===this.args.full.length)return this.error("no expression specified");try{Scripting.evalJavaScript(this.args.full)}catch(e){return this.error("bad evaluation: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}Config.debug&&this.debugView.modes({hidden:!0})}}),Macro.add("unset",{skipArgs:!0,handler:function(){if(0===this.args.full.length)return this.error("no story/temporary variable list specified");for(var e=new RegExp("State\\.(variables|temporary)\\.("+Patterns.identifier+")","g"),t=void 0;null!==(t=e.exec(this.args.full));){var r=State[t[1]],n=t[2];r.hasOwnProperty(n)&&delete r[n]}Config.debug&&this.debugView.modes({hidden:!0})}}),Macro.add("remember",{skipArgs:!0,handler:function(){if(0===this.args.full.length)return this.error("no expression specified");try{Scripting.evalJavaScript(this.args.full)}catch(e){return this.error("bad evaluation: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}for(var e=storage.get("remember")||{},t=new RegExp("State\\.variables\\.("+Patterns.identifier+")","g"),r=void 0;null!==(r=t.exec(this.args.full));){var n=r[1];e[n]=State.variables[n]}return storage.set("remember",e)?void(Config.debug&&this.debugView.modes({hidden:!0})):this.error("unknown error, cannot remember: "+this.args.raw)},init:function(){var e=storage.get("remember");e&&Object.keys(e).forEach(function(t){return State.variables[t]=e[t]})}}),Macro.add("forget",{skipArgs:!0,handler:function(){if(0===this.args.full.length)return this.error("no story variable list specified");for(var e=storage.get("remember"),t=new RegExp("State\\.variables\\.("+Patterns.identifier+")","g"),r=void 0,n=!1;null!==(r=t.exec(this.args.full));){var a=r[1];State.variables.hasOwnProperty(a)&&delete State.variables[a],e&&e.hasOwnProperty(a)&&(n=!0,delete e[a])}return n&&!storage.set("remember",e)?this.error("unknown error, cannot update remember store"):void(Config.debug&&this.debugView.modes({hidden:!0}))}}),Macro.add("run","set"),Macro.add("script",{skipArgs:!0,tags:null,handler:function(){var e=document.createDocumentFragment();try{Scripting.evalJavaScript(this.payload[0].contents,e),Config.debug&&this.createDebugView(this.name,this.source+this.payload[0].contents+"<</"+this.name+">>")}catch(e){return this.error("bad evaluation: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e),this.source+this.payload[0].contents+"<</"+this.name+">>")}e.hasChildNodes()&&this.output.appendChild(e)}}),Macro.add("include",{handler:function(){if(0===this.args.length)return this.error("no passage specified");var e=void 0;if(e="object"===_typeof(this.args[0])?this.args[0].link:this.args[0],!Story.has(e))return this.error('passage "'+e+'" does not exist');Config.debug&&this.debugView.modes({block:!0}),e=Story.get(e);var t=void 0;t=this.args[1]?jQuery(document.createElement(this.args[1])).addClass(e.domId+" macro-"+this.name).attr("data-passage",e.title).appendTo(this.output):jQuery(this.output),t.wiki(e.processText())}}),Macro.add("nobr",{skipArgs:!0,tags:null,handler:function(){new Wikifier(this.output,this.payload[0].contents.replace(/^\n+|\n+$/g,"").replace(/\n+/g," "))}}),Macro.add(["print","=","-"],{skipArgs:!0,handler:function(){if(0===this.args.full.length)return this.error("no expression specified");try{var e=toStringOrDefault(Scripting.evalJavaScript(this.args.full),null);null!==e&&new Wikifier(this.output,"-"===this.name?Util.escape(e):e)}catch(e){return this.error("bad evaluation: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}}}),Macro.add("silently",{skipArgs:!0,tags:null,handler:function(){var e=document.createDocumentFragment();if(new Wikifier(e,this.payload[0].contents.trim()),Config.debug)this.debugView.modes({hidden:!0}),this.output.appendChild(e);else{var t=[].concat(_toConsumableArray(e.querySelectorAll(".error"))).map(function(e){return e.textContent});if(t.length>0)return this.error("error"+(1===t.length?"":"s")+" within contents ("+t.join("; ")+")",this.source+this.payload[0].contents+"<</"+this.name+">>")}}}),Macro.add("display","include"),Macro.add("if",{skipArgs:!0,tags:["elseif","else"],handler:function(){var e=0;try{for(var t=Scripting.evalJavaScript,r=this.payload.length,n=!1;e<r;++e){switch(this.payload[e].name){case"else":if(e+1!==r)return this.error("<<else>> must be the final clause");if(this.payload[e].args.raw.length>0)return/^\s*if\b/i.test(this.payload[e].args.raw)?this.error('whitespace is not allowed between the "else" and "if" in <<elseif>> clause'+(e>0?" (#"+e+")":"")):this.error("<<else>> does not accept a conditional expression (perhaps you meant to use <<elseif>>), invalid: "+this.payload[e].args.raw);break;default:if(0===this.payload[e].args.full.length)return this.error("no conditional expression specified for <<"+this.payload[e].name+">> clause"+(e>0?" (#"+e+")":""));if(Config.macros.ifAssignmentError&&/[^!=&^|<>*\/%+-]=[^=]/.test(this.payload[e].args.full))return this.error("assignment operator found within <<"+this.payload[e].name+">> clause"+(e>0?" (#"+e+")":"")+" (perhaps you meant to use an equality operator: ==, ===, eq, is), invalid: "+this.payload[e].args.raw)}if(Config.debug&&this.createDebugView(this.payload[e].name,this.payload[e].source).modes({nonvoid:!1}),"else"===this.payload[e].name||t(this.payload[e].args.full)){n=!0,new Wikifier(this.output,this.payload[e].contents);break}Config.debug&&this.debugView.modes({hidden:!0,invalid:!0})}if(Config.debug){for(++e;e<r;++e)this.createDebugView(this.payload[e].name,this.payload[e].source).modes({nonvoid:!1,hidden:!0,invalid:!0});this.createDebugView("/"+this.name,"<</"+this.name+">>").modes({nonvoid:!1,hidden:!n,invalid:!n})}}catch(t){return this.error("bad conditional expression in <<"+(0===e?"if":"elseif")+">> clause"+(e>0?" (#"+e+")":"")+": "+("object"===("undefined"==typeof t?"undefined":_typeof(t))?t.message:t))}}}),Macro.add("switch",{skipArg0:!0,tags:["case","default"],handler:function(){if(0===this.args.full.length)return this.error("no expression specified");var e=this.payload.length,t=void 0;if(1===e)return this.error("no cases specified");try{t=Scripting.evalJavaScript(this.args.full)}catch(e){return this.error("bad evaluation: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}var r=this.debugView,n=1,a=!1;for(Config.debug&&r.modes({nonvoid:!1,hidden:!0});n<e;++n){switch(this.payload[n].name){case"default":if(n+1!==e)return this.error("<<default>> must be the final case");if(this.payload[n].args.length>0)return this.error("<<default>> does not accept values, invalid: "+this.payload[n].args.raw);break;default:if(0===this.payload[n].args.length)return this.error("no value(s) specified for <<"+this.payload[n].name+">> (#"+n+")")}if(Config.debug&&this.createDebugView(this.payload[n].name,this.payload[n].source).modes({nonvoid:!1}),"default"===this.payload[n].name||this.payload[n].args.some(function(e){return e===t})){a=!0,new Wikifier(this.output,this.payload[n].contents);break}Config.debug&&this.debugView.modes({hidden:!0,invalid:!0})}if(Config.debug){for(++n;n<e;++n)this.createDebugView(this.payload[n].name,this.payload[n].source).modes({nonvoid:!1,hidden:!0,invalid:!0});r.modes({nonvoid:!1,hidden:!0,invalid:!a}),this.createDebugView("/"+this.name,"<</"+this.name+">>").modes({nonvoid:!1,hidden:!0,invalid:!a})}}}),Macro.add("for",{skipArgs:!0,tags:null,handler:function(){var e=Scripting.evalJavaScript,t=this.payload[0].contents.replace(/\n$/,""),r=void 0,n=this.args.full.trim(),a=void 0,i=!0,o=Config.macros.maxLoopIterations;if(0===n.length)n=!0;else if(n.indexOf(";")!==-1){var s=n.match(/^([^;]*?)\s*;\s*([^;]*?)\s*;\s*([^;]*?)$/);if(null===s)return this.error("invalid 3-part syntax, format: init ; condition ; post");r=s[1],n=s[2],a=s[3]}if("string"==typeof n){if(/^\S+\s+in\s+\S+/i.test(n))return this.error("invalid syntax, for…in is not supported");if(/^\S+\s+of\s+\S+/i.test(n))return this.error("invalid syntax, for…of is not supported")}Config.debug&&this.debugView.modes({block:!0});try{if(TempState.break=null,r)try{e(r)}catch(e){return this.error("bad init expression: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}for(;e(n);){if(--o<0)return this.error("exceeded configured maximum loop iterations ("+Config.macros.maxLoopIterations+")");if(new Wikifier(this.output,i?t.replace(/^\n/,""):t),i&&(i=!1),null!=TempState.break)if(1===TempState.break)TempState.break=null;else if(2===TempState.break){TempState.break=null;break}if(a)try{e(a)}catch(e){return this.error("bad post expression: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}}}catch(e){return this.error("bad conditional expression: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}finally{TempState.break=null}}}),Macro.add(["break","continue"],{skipArgs:!0,handler:function(){return this.contextHas(function(e){return"for"===e.name})?(TempState.break="continue"===this.name?1:2,void(Config.debug&&this.debugView.modes({hidden:!0}))):this.error("must only be used in conjunction with its parent macro <<for>>")}}),Macro.add(["button","link"],{isAsync:!0,tags:null,handler:function(){var e=this;if(0===this.args.length)return this.error("no "+("button"===this.name?"button":"link")+" text specified");Config.debug&&this.createDebugView(this.name,this.source+this.payload[0].contents+"<</"+this.name+">>");var t=jQuery(document.createElement("button"===this.name?"button":"a")),r=void 0;if("object"===_typeof(this.args[0]))if(this.args[0].isImage){var n=jQuery(document.createElement("img")).attr("src",this.args[0].source).appendTo(t);this.args[0].hasOwnProperty("passage")&&n.attr("data-passage",this.args[0].passage),this.args[0].hasOwnProperty("title")&&n.attr("title",this.args[0].title),this.args[0].hasOwnProperty("align")&&n.attr("align",this.args[0].align),this.args[0].hasOwnProperty("link")&&(r=this.args[0].link),r=this.args[0].link}else t.append(document.createTextNode(this.args[0].text)),r=this.args[0].link;else t.wikiWithOptions({profile:"core"},this.args[0]),r=this.args.length>1?this.args[1]:undefined;null!=r?(t.attr("data-passage",r),Story.has(r)?(t.addClass("link-internal"),Config.addVisitedLinkClass&&State.hasPlayed(r)&&t.addClass("link-visited")):t.addClass("link-broken")):t.addClass("link-internal"),t.addClass("macro-"+this.name).ariaClick({namespace:".macros",one:null!=r},this.createShadowWrapper(""!==this.payload[0].contents?function(){return Wikifier.wikifyEval(e.payload[0].contents.trim())}:null,null!=r?function(){return Engine.play(r)}:null)).appendTo(this.output)}}),Macro.add("checkbox",{handler:function(){if(this.args.length<3){var e=[];return this.args.length<1&&e.push("variable name"),this.args.length<2&&e.push("unchecked value"),this.args.length<3&&e.push("checked value"),this.error("no "+e.join(" or ")+" specified")}if("string"!=typeof this.args[0])return this.error("variable name argument is not a string");var t=this.args[0].trim();if("$"!==t[0]&&"_"!==t[0])return this.error('variable name "'+this.args[0]+'" is missing its sigil ($ or _)');var r=Util.slugify(t),n=this.args[1],a=this.args[2],i=document.createElement("input");jQuery(i).attr({id:this.name+"-"+r,name:this.name+"-"+r,type:"checkbox",tabindex:0}).addClass("macro-"+this.name).on("change",function(){Wikifier.setValue(t,this.checked?a:n)}).appendTo(this.output),this.args.length>3&&"checked"===this.args[3]?(i.checked=!0,Wikifier.setValue(t,a)):Wikifier.setValue(t,n)}}),Macro.add(["linkappend","linkprepend","linkreplace"],{isAsync:!0,tags:null,handler:function(){var e=this;if(0===this.args.length)return this.error("no link text specified");Config.debug&&this.createDebugView(this.name,this.source+this.payload[0].contents+"<</"+this.name+">>");var t=jQuery(document.createElement("a")),r=jQuery(document.createElement("span")),n=this.args.length>1&&/^(?:transition|t8n)$/.test(this.args[1]);t.wikiWithOptions({profile:"core"},this.args[0]).addClass("link-internal macro-"+this.name).ariaClick({namespace:".macros",one:!0},this.createShadowWrapper(function(){if("linkreplace"===e.name?t.remove():t.wrap('<span class="macro-'+e.name+'"></span>').replaceWith(function(){return t.html()}),""!==e.payload[0].contents){var a=document.createDocumentFragment();new Wikifier(a,e.payload[0].contents),r.append(a)}n&&setTimeout(function(){return r.removeClass("macro-"+e.name+"-in")},Engine.minDomActionDelay)})).appendTo(this.output),r.addClass("macro-"+this.name+"-insert"),n&&r.addClass("macro-"+this.name+"-in"),"linkprepend"===this.name?r.insertBefore(t):r.insertAfter(t)}}),Macro.add("radiobutton",{handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("variable name"),this.args.length<2&&e.push("checked value"),this.error("no "+e.join(" or ")+" specified")}if("string"!=typeof this.args[0])return this.error("variable name argument is not a string");var t=this.args[0].trim();if("$"!==t[0]&&"_"!==t[0])return this.error('variable name "'+this.args[0]+'" is missing its sigil ($ or _)');var r=Util.slugify(t),n=this.args[1],a=document.createElement("input");TempState.hasOwnProperty(this.name)||(TempState[this.name]={}),TempState[this.name].hasOwnProperty(r)||(TempState[this.name][r]=0),jQuery(a).attr({id:this.name+"-"+r+"-"+TempState[this.name][r]++,name:this.name+"-"+r,type:"radio",tabindex:0}).addClass("macro-"+this.name).on("change",function(){this.checked&&Wikifier.setValue(t,n)}).appendTo(this.output),this.args.length>2&&"checked"===this.args[2]&&(a.checked=!0,Wikifier.setValue(t,n))}}),Macro.add("textarea",{handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("variable name"),this.args.length<2&&e.push("default value"),this.error("no "+e.join(" or ")+" specified")}if("string"!=typeof this.args[0])return this.error("variable name argument is not a string");var t=this.args[0].trim();if("$"!==t[0]&&"_"!==t[0])return this.error('variable name "'+this.args[0]+'" is missing its sigil ($ or _)');Config.debug&&this.debugView.modes({block:!0});var r=Util.slugify(t),n=this.args[1],a="autofocus"===this.args[2],i=document.createElement("textarea");jQuery(i).attr({id:this.name+"-"+r,name:this.name+"-"+r,rows:4,tabindex:0}).addClass("macro-"+this.name).on("change",function(){Wikifier.setValue(t,this.value)}).appendTo(this.output),Wikifier.setValue(t,n),i.textContent=n,a&&(i.setAttribute("autofocus","autofocus"),postdisplay["#autofocus:"+i.id]=function(e){delete postdisplay[e],setTimeout(function(){return i.focus()},Engine.minDomActionDelay)})}}),Macro.add("textbox",{handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("variable name"),this.args.length<2&&e.push("default value"),this.error("no "+e.join(" or ")+" specified")}if("string"!=typeof this.args[0])return this.error("variable name argument is not a string");var t=this.args[0].trim();if("$"!==t[0]&&"_"!==t[0])return this.error('variable name "'+this.args[0]+'" is missing its sigil ($ or _)');Config.debug&&this.debugView.modes({block:!0});var r=Util.slugify(t),n=this.args[1],a=document.createElement("input"),i=!1,o=void 0;this.args.length>3?(o=this.args[2],i="autofocus"===this.args[3]):this.args.length>2&&("autofocus"===this.args[2]?i=!0:o=this.args[2]),jQuery(a).attr({id:this.name+"-"+r,name:this.name+"-"+r,type:"text",tabindex:0}).addClass("macro-"+this.name).on("change",function(){Wikifier.setValue(t,this.value)}).on("keypress",function(e){13===e.which&&(e.preventDefault(),Wikifier.setValue(t,this.value),null!=o&&Engine.play(o))}).appendTo(this.output),Wikifier.setValue(t,n),a.value=n,i&&(a.setAttribute("autofocus","autofocus"),postdisplay["#autofocus:"+a.id]=function(e){delete postdisplay[e],setTimeout(function(){return a.focus()},Engine.minDomActionDelay)})}}),Macro.add("click","link"),Macro.add("actions",{handler:function(){for(var e=jQuery(document.createElement("ul")).addClass(this.name).appendTo(this.output),t=0;t<this.args.length;++t){var r=void 0,n=void 0,a=void 0,i=void 0;"object"===_typeof(this.args[t])?this.args[t].isImage?(a=jQuery(document.createElement("img")).attr("src",this.args[t].source),this.args[t].hasOwnProperty("passage")&&a.attr("data-passage",this.args[t].passage),this.args[t].hasOwnProperty("title")&&a.attr("title",this.args[t].title),this.args[t].hasOwnProperty("align")&&a.attr("align",this.args[t].align),r=this.args[t].link,i=this.args[t].setFn):(n=this.args[t].text,r=this.args[t].link,i=this.args[t].setFn):n=r=this.args[t],State.variables.hasOwnProperty("#actions")&&State.variables["#actions"].hasOwnProperty(r)&&State.variables["#actions"][r]||jQuery(Wikifier.createInternalLink(jQuery(document.createElement("li")).appendTo(e),r,null,function(e,t){return function(){State.variables.hasOwnProperty("#actions")||(State.variables["#actions"]={}),State.variables["#actions"][e]=!0,"function"==typeof t&&t()}}(r,i))).addClass("macro-"+this.name).append(a||document.createTextNode(n))}}}),Macro.add(["back","return"],{handler:function(){if(this.args.length>1)return this.error("too many arguments specified, check the documentation for details");var e=-1,t=void 0,r=void 0,n=void 0;if(1===this.args.length&&("object"===_typeof(this.args[0])?this.args[0].isImage?(n=jQuery(document.createElement("img")).attr("src",this.args[0].source),this.args[0].hasOwnProperty("passage")&&n.attr("data-passage",this.args[0].passage),this.args[0].hasOwnProperty("title")&&n.attr("title",this.args[0].title),this.args[0].hasOwnProperty("align")&&n.attr("align",this.args[0].align),this.args[0].hasOwnProperty("link")&&(t=this.args[0].link)):1===this.args[0].count?t=this.args[0].link:(r=this.args[0].text,t=this.args[0].link):1===this.args.length&&(r=this.args[0])),null==t){for(var a=State.length-2;a>=0;--a)if(State.history[a].title!==State.passage){e=a,t=State.history[a].title;break}if(null==t&&"return"===this.name)for(var i=State.expired.length-1;i>=0;--i)if(State.expired[i]!==State.passage){t=State.expired[i];break}}else{if(!Story.has(t))return this.error('passage "'+t+'" does not exist');if("back"===this.name){for(var o=State.length-2;o>=0;--o)if(State.history[o].title===t){e=o;break}if(e===-1)return this.error('cannot find passage "'+t+'" in the current story history')}}if(null==t)return this.error("cannot find passage");var s=void 0;s="back"!==this.name||e!==-1?jQuery(document.createElement("a")).addClass("link-internal").ariaClick({one:!0},"return"===this.name?function(){return Engine.play(t)}:function(){return Engine.goTo(e)}):jQuery(document.createElement("span")).addClass("link-disabled"),s.addClass("macro-"+this.name).append(n||document.createTextNode(r||L10n.get("macro"+this.name.toUpperFirst()+"Text"))).appendTo(this.output)}}),Macro.add("choice",{handler:function(){if(0===this.args.length)return this.error("no passage specified");var e=State.passage,t=void 0,r=void 0,n=void 0,a=void 0;return 1===this.args.length?"object"===_typeof(this.args[0])?this.args[0].isImage?(n=jQuery(document.createElement("img")).attr("src",this.args[0].source),this.args[0].hasOwnProperty("passage")&&n.attr("data-passage",this.args[0].passage),this.args[0].hasOwnProperty("title")&&n.attr("title",this.args[0].title),this.args[0].hasOwnProperty("align")&&n.attr("align",this.args[0].align),t=this.args[0].link,a=this.args[0].setFn):(r=this.args[0].text,t=this.args[0].link,a=this.args[0].setFn):r=t=this.args[0]:(t=this.args[0],r=this.args[1]),State.variables.hasOwnProperty("#choice")&&State.variables["#choice"].hasOwnProperty(e)&&State.variables["#choice"][e]?void jQuery(document.createElement("span")).addClass("link-disabled macro-"+this.name).attr("tabindex",-1).append(n||document.createTextNode(r)).appendTo(this.output):void jQuery(Wikifier.createInternalLink(this.output,t,null,function(){State.variables.hasOwnProperty("#choice")||(State.variables["#choice"]={}),State.variables["#choice"][e]=!0,"function"==typeof a&&a()})).addClass("macro-"+this.name).append(n||document.createTextNode(r))}}),Macro.add(["addclass","toggleclass"],{handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("selector"),this.args.length<2&&e.push("class names"),this.error("no "+e.join(" or ")+" specified")}var t=jQuery(this.args[0]);if(0===t.length)return this.error('no elements matched the selector "'+this.args[0]+'"');switch(this.name){case"addclass":t.addClass(this.args[1].trim());break;case"toggleclass":t.toggleClass(this.args[1].trim())}}}),Macro.add("removeclass",{handler:function(){if(0===this.args.length)return this.error("no selector specified");var e=jQuery(this.args[0]);return 0===e.length?this.error('no elements matched the selector "'+this.args[0]+'"'):void(this.args.length>1?e.removeClass(this.args[1].trim()):e.removeClass())}}),Macro.add("copy",{handler:function(){if(0===this.args.length)return this.error("no selector specified");var e=jQuery(this.args[0]);return 0===e.length?this.error('no elements matched the selector "'+this.args[0]+'"'):void jQuery(this.output).append(e.html())}}),Macro.add(["append","prepend","replace"],{tags:null,handler:function(){if(0===this.args.length)return this.error("no selector specified");var e=jQuery(this.args[0]);if(0===e.length)return this.error('no elements matched the selector "'+this.args[0]+'"');if(""!==this.payload[0].contents){var t=document.createDocumentFragment();switch(new Wikifier(t,this.payload[0].contents),this.name){case"replace":e.empty();case"append":e.append(t);break;case"prepend":e.prepend(t)}}else"replace"===this.name&&e.empty()}}),Macro.add("remove",{handler:function(){if(0===this.args.length)return this.error("no selector specified");var e=jQuery(this.args[0]);return 0===e.length?this.error('no elements matched the selector "'+this.args[0]+'"'):void e.remove()}}),Has.audio?(Macro.add("audio",{handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("track ID"),this.args.length<2&&e.push("actions"),this.error("no "+e.join(" or ")+" specified")}var t=Macro.get("cacheaudio").tracks,r=[":all",":looped",":muted",":paused",":playing"],n=String(this.args[0]).trim();if(!r.includes(n)&&!t.hasOwnProperty(n))return this.error('track "'+n+'" does not exist');for(var a=this.args.slice(1),i=void 0,o=void 0,s=void 0,u=void 0,l=void 0,c=void 0,d=5,p=void 0,f=void 0;a.length>0;){var h=a.shift();switch(h){case"play":case"pause":case"stop":i=h;break;case"fadein":i="fade",c=1;break;case"fadeout":i="fade",c=0;break;case"fadeto":if(0===a.length)return this.error("fadeto missing required level value");if(i="fade",f=a.shift(),c=Number.parseFloat(f),Number.isNaN(c)||!Number.isFinite(c))return this.error("cannot parse fadeto: "+f);break;case"fadeoverto":if(a.length<2){var g=[];return a.length<1&&g.push("seconds"),a.length<2&&g.push("level"),this.error("fadeoverto missing required "+g.join(" and ")+" value"+(g.length>1?"s":""))}if(i="fade",f=a.shift(),d=Number.parseFloat(f),Number.isNaN(d)||!Number.isFinite(d))return this.error("cannot parse fadeoverto: "+f);if(f=a.shift(),c=Number.parseFloat(f),Number.isNaN(c)||!Number.isFinite(c))return this.error("cannot parse fadeoverto: "+f);break;case"volume":if(0===a.length)return this.error("volume missing required level value");if(f=a.shift(),o=Number.parseFloat(f),Number.isNaN(o)||!Number.isFinite(o))return this.error("cannot parse volume: "+f);break;case"mute":case"unmute":s="mute"===h;break;case"time":if(0===a.length)return this.error("time missing required seconds value");if(f=a.shift(),u=Number.parseFloat(f),Number.isNaN(u)||!Number.isFinite(u))return this.error("cannot parse time: "+f);break;case"loop":case"unloop":l="loop"===h;break;case"goto":if(0===a.length)return this.error("goto missing required passage title");if(f=a.shift(),p="object"===("undefined"==typeof f?"undefined":_typeof(f))?f.link:f,!Story.has(p))return this.error('passage "'+p+'" does not exist');break;default:return this.error("unknown action: "+h)}}var m=void 0;switch(n){case":all":m=Object.keys(t);break;case":looped":m=Object.keys(t).filter(function(e){return t[e].isLooped()});break;case":muted":m=Object.keys(t).filter(function(e){return t[e].isMuted()});break;case":paused":m=Object.keys(t).filter(function(e){return t[e].isPaused()});break;case":playing":m=Object.keys(t).filter(function(e){return t[e].isPlaying()});break;default:m=[n]}try{m.forEach(function(e){var r=t[e];switch(null!=o&&(r.volume=o),null!=u&&(r.time=u),null!=s&&(r.mute=s),null!=l&&(r.loop=l),null!=p&&r.one("end",function(){return Engine.play(p)}),i){case"play":r.play();break;case"pause":r.pause();break;case"stop":r.stop();break;case"fade":r.fadeWithDuration(d,c)}}),Config.debug&&this.createDebugView()}catch(e){return this.error("error executing audio action: "+e.message)}}}),Macro.add("cacheaudio",{tracks:{},handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("track ID"),this.args.length<2&&e.push("sources"),this.error("no "+e.join(" or ")+" specified")}var t=String(this.args[0]).trim(),r=/^:|\s/;if(r.test(t))return this.error('invalid track ID "'+t+'": track IDs may not start with a colon or contain whitespace');var n=/^format:\s*([\w-]+)\s*;\s*(\S.*)$/i,a=void 0;try{a=SimpleAudio.create(this.args.slice(1).map(function(e){var t=n.exec(e);return null===t?e:{format:t[1],src:t[2]}}))}catch(e){return this.error('error during track initialization for "'+t+'": '+e.message)}if(Config.debug&&!a.hasSource())return this.error('no supported audio sources found for "'+t+'"');var i=this.self.tracks;i.hasOwnProperty(t)&&i[t].destroy(),i[t]=a,Config.debug&&this.createDebugView()}}),Macro.add("createplaylist",{tags:["track"],lists:{},handler:function(){if(0===this.args.length)return this.error("no list ID specified");var e=Macro.get("playlist");if(null!==e.from&&"createplaylist"!==e.from)return this.error("a playlist has already been defined with <<setplaylist>>");var t=Macro.get("cacheaudio").tracks,r=String(this.args[0]).trim(),n=/^:|\s/;if(n.test(r))return this.error('invalid list ID "'+r+'": list IDs may not start with a colon or contain whitespace');if(1===this.payload.length)return this.error("no tracks defined via <<track>>");Config.debug&&this.debugView.modes({nonvoid:!1,hidden:!0});for(var a=SimpleAudio.createList(),i=1,o=this.payload.length;i<o;++i){if(this.payload[i].args.length<2){var s=[];return this.payload[i].args.length<1&&s.push("track ID"),this.payload[i].args.length<2&&s.push("actions"),this.error("no "+s.join(" or ")+" specified")}var u=String(this.payload[i].args[0]).trim();if(!t.hasOwnProperty(u))return this.error('track "'+u+'" does not exist');for(var l=this.payload[i].args.slice(1),c=!1,d=void 0;l.length>0;){var p=l.shift(),f=void 0;switch(p){case"copy":c=!0;break;case"rate":l.length>0&&l.shift();break;case"volume":if(0===l.length)return this.error("volume missing required level value");if(f=l.shift(),d=Number.parseFloat(f),Number.isNaN(d)||!Number.isFinite(d))return this.error("cannot parse volume: "+f);break;default:return this.error("unknown action: "+p)}}var h=t[u];a.add({copy:c,track:h,volume:null!=d?d:h.volume}),Config.debug&&this.createDebugView(this.payload[i].name,this.payload[i].source).modes({nonvoid:!1,hidden:!0})}var g=this.self.lists;g.hasOwnProperty(r)&&g[r].destroy(),g[r]=a,null===e.from&&(e.from="createplaylist"),this.createDebugView("/"+this.name,"<</"+this.name+">>").modes({nonvoid:!1,hidden:!0})}}),Macro.add("masteraudio",{handler:function(){if(0===this.args.length)return this.error("no actions specified");for(var e=this.args.slice(0),t=!1,r=void 0,n=void 0;e.length>0;){var a=e.shift(),i=void 0;switch(a){case"stop":t=!0;break;case"mute":case"unmute":r="mute"===a;break;case"volume":if(0===e.length)return this.error("volume missing required level value");if(i=e.shift(),n=Number.parseFloat(i),Number.isNaN(n)||!Number.isFinite(n))return this.error("cannot parse volume: "+i);break;default:return this.error("unknown action: "+a)}}try{null!=r&&(SimpleAudio.mute=r),null!=n&&(SimpleAudio.volume=n),t&&SimpleAudio.stop(),Config.debug&&this.createDebugView()}catch(e){return this.error("error executing master audio action: "+e.message)}}}),Macro.add("playlist",{from:null,handler:function(){var e=this.self.from;
-if(null===e)return this.error("no playlists have been created");var t=void 0,r=void 0;if("createplaylist"===e){if(this.args.length<2){var n=[];return this.args.length<1&&n.push("list ID"),this.args.length<2&&n.push("actions"),this.error("no "+n.join(" or ")+" specified")}var a=Macro.get("createplaylist").lists,i=String(this.args[0]).trim();if(!a.hasOwnProperty(i))return this.error('playlist "'+i+'" does not exist');t=a[i],r=this.args.slice(1)}else{if(0===this.args.length)return this.error("no actions specified");t=Macro.get("setplaylist").list,r=this.args.slice(0)}for(var o=void 0,s=void 0,u=void 0,l=void 0,c=void 0,d=void 0,p=5,f=void 0;r.length>0;){var h=r.shift();switch(h){case"play":case"pause":case"stop":case"skip":o=h;break;case"fadein":o="fade",d=1;break;case"fadeout":o="fade",d=0;break;case"fadeto":if(0===r.length)return this.error("fadeto missing required level value");if(o="fade",f=r.shift(),d=Number.parseFloat(f),Number.isNaN(d)||!Number.isFinite(d))return this.error("cannot parse fadeto: "+f);break;case"fadeoverto":if(r.length<2){var g=[];return r.length<1&&g.push("seconds"),r.length<2&&g.push("level"),this.error("fadeoverto missing required "+g.join(" and ")+" value"+(g.length>1?"s":""))}if(o="fade",f=r.shift(),p=Number.parseFloat(f),Number.isNaN(p)||!Number.isFinite(p))return this.error("cannot parse fadeoverto: "+f);if(f=r.shift(),d=Number.parseFloat(f),Number.isNaN(d)||!Number.isFinite(d))return this.error("cannot parse fadeoverto: "+f);break;case"volume":if(0===r.length)return this.error("volume missing required level value");if(f=r.shift(),s=Number.parseFloat(f),Number.isNaN(s)||!Number.isFinite(s))return this.error("cannot parse volume: "+f);break;case"mute":case"unmute":u="mute"===h;break;case"loop":case"unloop":l="loop"===h;break;case"shuffle":case"unshuffle":c="shuffle"===h;break;default:return this.error("unknown action: "+h)}}try{switch(null!=s&&(t.volume=s),null!=u&&(t.mute=u),null!=l&&(t.loop=l),null!=c&&(t.shuffle=c),o){case"play":t.play();break;case"pause":t.pause();break;case"stop":t.stop();break;case"skip":t.skip();break;case"fade":t.fadeWithDuration(p,d)}Config.debug&&this.createDebugView()}catch(e){return this.error("error playing audio: "+e.message)}}}),Macro.add("removeplaylist",{handler:function(){if(0===this.args.length)return this.error("no list ID specified");var e=Macro.get("createplaylist").lists,t=String(this.args[0]).trim();return e.hasOwnProperty(t)?(e[t].destroy(),delete e[t],void(Config.debug&&this.createDebugView())):this.error('playlist "'+t+'" does not exist')}}),Macro.add("waitforaudio",{skipArgs:!0,queue:[],handler:function(){function e(){if(0===t.length)return LoadScreen.unlock(r);var n=t.shift();return n.hasData()?e():void n.one("canplay.waitforaudio error.waitforaudio",function(){jQuery(this).off(".waitforaudio"),e()}).load()}var t=this.self.queue,r=void 0;t.length>0||(this.self.fillQueue(t),t.length>0&&(r=LoadScreen.lock(),e()))},fillQueue:function(e){var t=Macro.get("cacheaudio").tracks;Object.keys(t).forEach(function(r){return e.push(t[r])});var r=Macro.get("createplaylist").lists;if(Object.keys(r).map(function(e){return r[e].tracks}).flatten().filter(function(e){return e.copy}).forEach(function(t){return e.push(t.track)}),Macro.has("setplaylist")){var n=Macro.get("setplaylist").list;null!==n&&n.tracks.forEach(function(t){return e.push(t.track)})}}}),Macro.add("setplaylist",{list:null,handler:function(){if(0===this.args.length)return this.error("no track ID(s) specified");var e=Macro.get("playlist");if(null!==e.from&&"setplaylist"!==e.from)return this.error("playlists have already been defined with <<createplaylist>>");var t=this.self,r=Macro.get("cacheaudio").tracks;null!==t.list&&t.list.destroy(),t.list=SimpleAudio.createList();for(var n=0;n<this.args.length;++n){var a=this.args[n];if(!r.hasOwnProperty(a))return this.error('track "'+a+'" does not exist');t.list.add(r[a])}null===e.from&&(e.from="setplaylist"),Config.debug&&this.createDebugView()}}),Macro.add("stopallaudio",{skipArgs:!0,handler:function(){var e=Macro.get("cacheaudio").tracks;Object.keys(e).forEach(function(t){return e[t].stop()}),Config.debug&&this.createDebugView()}})):Macro.add(["audio","cacheaudio","createplaylist","masteraudio","playlist","removeplaylist","waitforaudio","setplaylist","stopallaudio"],{skipArgs:!0,handler:function(){}}),Macro.add("goto",{handler:function(){if(0===this.args.length)return this.error("no passage specified");var e=void 0;return e="object"===_typeof(this.args[0])?this.args[0].link:this.args[0],Story.has(e)?void setTimeout(function(){return Engine.play(e)},Engine.minDomActionDelay):this.error('passage "'+e+'" does not exist')}}),Macro.add("timed",{isAsync:!0,tags:["next"],timers:new Set,handler:function(){if(0===this.args.length)return this.error("no time value specified in <<timed>>");var e=[];try{e.push({name:this.name,source:this.source,delay:Math.max(Engine.minDomActionDelay,Util.fromCssTime(this.args[0])),content:this.payload[0].contents})}catch(e){return this.error(e.message+" in <<timed>>")}if(this.payload.length>1){var t=void 0;try{var r=void 0;for(t=1,r=this.payload.length;t<r;++t)e.push({name:this.payload[t].name,source:this.payload[t].source,delay:0===this.payload[t].args.length?e[e.length-1].delay:Math.max(Engine.minDomActionDelay,Util.fromCssTime(this.payload[t].args[0])),content:this.payload[t].contents})}catch(e){return this.error(e.message+" in <<next>> (#"+t+")")}}Config.debug&&this.debugView.modes({block:!0});var n=this.args.length>1&&/^(?:transition|t8n)$/.test(this.args[1]),a=jQuery(document.createElement("span")).addClass("macro-"+this.name).appendTo(this.output);this.self.registerTimeout(this.createShadowWrapper(function(e){var t=document.createDocumentFragment();new Wikifier(t,e.content);var r=a;Config.debug&&"next"===e.name&&(r=jQuery(new DebugView(r[0],"macro",e.name,e.source).output)),n&&(r=jQuery(document.createElement("span")).addClass("macro-timed-insert macro-timed-in").appendTo(r)),r.append(t),n&&setTimeout(function(){return r.removeClass("macro-timed-in")},Engine.minDomActionDelay)}),e)},registerTimeout:function(e,t){if("function"!=typeof e)throw new TypeError("callback parameter must be a function");var r=State.turns,n=this.timers,a=null,i=t.shift(),o=function o(){if(n.delete(a),r===State.turns){var s=i;null!=(i=t.shift())&&(a=setTimeout(o,i.delay),n.add(a)),e.call(this,s)}};a=setTimeout(o,i.delay),n.add(a),prehistory.hasOwnProperty("#timed-timers-cleanup")||(prehistory["#timed-timers-cleanup"]=function(e){delete prehistory[e],n.forEach(function(e){return clearTimeout(e)}),n.clear()})}}),Macro.add("repeat",{isAsync:!0,tags:null,timers:new Set,handler:function(){var e=this;if(0===this.args.length)return this.error("no time value specified");var t=void 0;try{t=Math.max(Engine.minDomActionDelay,Util.fromCssTime(this.args[0]))}catch(e){return this.error(e.message)}Config.debug&&this.debugView.modes({block:!0});var r=this.args.length>1&&/^(?:transition|t8n)$/.test(this.args[1]),n=jQuery(document.createElement("span")).addClass("macro-"+this.name).appendTo(this.output);this.self.registerInterval(this.createShadowWrapper(function(){var t=document.createDocumentFragment();new Wikifier(t,e.payload[0].contents);var a=n;r&&(a=jQuery(document.createElement("span")).addClass("macro-repeat-insert macro-repeat-in").appendTo(a)),a.append(t),r&&setTimeout(function(){return a.removeClass("macro-repeat-in")},Engine.minDomActionDelay)}),t)},registerInterval:function(e,t){var r=this;if("function"!=typeof e)throw new TypeError("callback parameter must be a function");var n=State.turns,a=this.timers,i=null;i=setInterval(function(){if(n!==State.turns)return clearInterval(i),void a.delete(i);var t=void 0;try{TempState.break=null,TempState.hasOwnProperty("repeatTimerId")&&(t=TempState.repeatTimerId),TempState.repeatTimerId=i,e.call(r)}finally{"undefined"!=typeof t?TempState.repeatTimerId=t:delete TempState.repeatTimerId,TempState.break=null}},t),a.add(i),prehistory.hasOwnProperty("#repeat-timers-cleanup")||(prehistory["#repeat-timers-cleanup"]=function(e){delete prehistory[e],a.forEach(function(e){return clearInterval(e)}),a.clear()})}}),Macro.add("stop",{skipArgs:!0,handler:function(){if(!TempState.hasOwnProperty("repeatTimerId"))return this.error("must only be used in conjunction with its parent macro <<repeat>>");var e=Macro.get("repeat").timers,t=TempState.repeatTimerId;clearInterval(t),e.delete(t),TempState.break=2,Config.debug&&this.debugView.modes({hidden:!0})}}),Macro.add("widget",{tags:null,handler:function(){if(0===this.args.length)return this.error("no widget name specified");var e=this.args[0];if(Macro.has(e)){if(!Macro.get(e).isWidget)return this.error('cannot clobber existing macro "'+e+'"');Macro.delete(e)}try{Macro.add(e,{isWidget:!0,handler:function(e){return function(){var t=this,r=void 0;try{var n=function(){State.variables.hasOwnProperty("args")&&(r=State.variables.args),State.variables.args=[].concat(_toConsumableArray(t.args)),State.variables.args.raw=t.args.raw,State.variables.args.full=t.args.full,t.addShadow("$args");var n=document.createDocumentFragment(),a=[];return new Wikifier(n,e),Array.from(n.querySelectorAll(".error")).forEach(function(e){a.push(e.textContent)}),0!==a.length?{v:t.error("error"+(a.length>1?"s":"")+" within widget contents ("+a.join("; ")+")")}:void t.output.appendChild(n)}();if("object"===("undefined"==typeof n?"undefined":_typeof(n)))return n.v}catch(e){return this.error("cannot execute widget: "+e.message)}finally{"undefined"!=typeof r?State.variables.args=r:delete State.variables.args}}}(this.payload[0].contents)}),Config.debug&&this.createDebugView(this.name,this.source+this.payload[0].contents+"<</"+this.name+">>")}catch(t){return this.error('cannot create widget macro "'+e+'": '+t.message)}}})}();var Dialog=function(){function e(){m=function(){var e=void 0;try{var t=document.createElement("p"),r=document.createElement("div");t.style.width="100%",t.style.height="200px",r.style.position="absolute",r.style.left="0px",r.style.top="0px",r.style.width="100px",r.style.height="100px",r.style.visibility="hidden",r.style.overflow="hidden",r.appendChild(t),document.body.appendChild(r);var n=t.offsetWidth;r.style.overflow="auto";var a=t.offsetWidth;n===a&&(a=r.clientWidth),document.body.removeChild(r),e=n-a}catch(e){}return e||17}();var e=jQuery(document.createDocumentFragment()).append('<div id="ui-overlay" class="ui-close"></div><div id="ui-dialog" tabindex="0" role="dialog" aria-labelledby="ui-dialog-title"><div id="ui-dialog-titlebar"><h1 id="ui-dialog-title"></h1>'+('<button id="ui-dialog-close" class="ui-close" tabindex="0" aria-label="'+L10n.get("close")+'"></button>')+'</div><div id="ui-dialog-body"></div></div>');d=jQuery(e.find("#ui-overlay").get(0)),p=jQuery(e.find("#ui-dialog").get(0)),f=jQuery(e.find("#ui-dialog-title").get(0)),h=jQuery(e.find("#ui-dialog-body").get(0)),e.insertBefore("#store-area")}function t(e){return p.hasClass("open")&&(!e||e.splitOrEmpty(/\s+/).every(function(e){return h.hasClass(e)}))}function r(e,t){return h.empty().removeClass(),null!=t&&h.addClass(t),f.empty().append((null!=e?String(e):"")||" "),h.get(0)}function n(){return h.get(0)}function a(){var e;return(e=h).append.apply(e,arguments),Dialog}function i(){var e;return(e=h).wiki.apply(e,arguments),Dialog}function o(e,t,r,n,a){return jQuery(e).ariaClick(function(e){e.preventDefault(),"function"==typeof r&&r(e),s(t,a),"function"==typeof n&&n(e)})}function s(e,r){var n=jQuery.extend({top:50},e),a=n.top;t()||(g=safeActiveElement()),jQuery(document.documentElement).addClass("ui-dialog-open"),d.addClass("open"),null!==h[0].querySelector("img")&&h.imagesLoaded().always(function(){return l({data:{top:a}})}),jQuery("body>:not(script,#store-area,#ui-bar,#ui-overlay,#ui-dialog)").attr("tabindex",-3).attr("aria-hidden",!0),jQuery("#ui-bar,#story").find("[tabindex]:not([tabindex^=-])").attr("tabindex",-2).attr("aria-hidden",!0);var i=c(a);return p.css(i).addClass("open").focus(),jQuery(window).on("resize.ui-resize",null,{top:a},jQuery.throttle(40,l)),jQuery(document).on("click.ui-close",".ui-close",{closeFn:r},u).on("keypress.ui-close",".ui-close",function(e){13!==e.which&&32!==e.which||jQuery(this).trigger("click")}),setTimeout(function(){return jQuery.event.trigger("tw:dialogopened")},Engine.minDomActionDelay),Dialog}function u(e){return jQuery(document).off(".ui-close"),jQuery(window).off("resize.ui-resize"),p.removeClass("open").css({left:"",right:"",top:"",bottom:""}),jQuery("#ui-bar,#story").find("[tabindex=-2]").removeAttr("aria-hidden").attr("tabindex",0),jQuery("body>[tabindex=-3]").removeAttr("aria-hidden").removeAttr("tabindex"),f.empty(),h.empty().removeClass(),d.removeClass("open"),jQuery(document.documentElement).removeClass("ui-dialog-open"),null!==g&&(jQuery(g).focus(),g=null),e&&e.data&&"function"==typeof e.data.closeFn&&e.data.closeFn(e),setTimeout(function(){return jQuery.event.trigger("tw:dialogclosed")},Engine.minDomActionDelay),Dialog}function l(e){var t=e&&e.data&&"undefined"!=typeof e.data.top?e.data.top:50;"block"===p.css("display")&&(p.css({display:"none"}),p.css(jQuery.extend({display:""},c(t))))}function c(e){var t=null!=e?e:50,r=jQuery(window),n={left:"",right:"",top:"",bottom:""};p.css(n);var a=r.width()-p.outerWidth(!0)-1,i=r.height()-p.outerHeight(!0)-1;return a<=32+m&&(i-=m),i<=32+m&&(a-=m),a<=32?n.left=n.right=16:n.left=n.right=~~(a/2),i<=32?n.top=n.bottom=16:i/2>t?n.top=t:n.top=n.bottom=~~(i/2),Object.keys(n).forEach(function(e){""!==n[e]&&(n[e]+="px")}),n}var d=null,p=null,f=null,h=null,g=null,m=0;return Object.freeze(Object.defineProperties({},{init:{value:e},isOpen:{value:t},setup:{value:r},body:{value:n},append:{value:a},wiki:{value:i},addClickHandler:{value:o},open:{value:s},close:{value:u},resize:{value:function(){return l()}}}))}(),Engine=function(){function e(){if(Story.has("StoryInit"))try{var e=Wikifier.wikifyEval(Story.get("StoryInit").text);if(Config.debug){var t=new DebugView(document.createDocumentFragment(),"special","StoryInit","StoryInit");t.modes({hidden:!0}),t.append(e),h=t.output}}catch(e){Alert.error("StoryInit",e.message)}if(Config.history.maxStates=Math.max(0,Config.history.maxStates),Number.isSafeInteger(Config.history.maxStates)||(Config.history.maxStates=100),1===Config.history.maxStates&&(Config.history.controls=!1),Config.debug&&DebugView.init(),null==Config.passages.start)throw new Error("starting passage not selected");if(!Story.has(Config.passages.start))throw new Error('starting passage ("'+Config.passages.start+'") not found');if(State.restore())u();else{var r=!0;switch(_typeof(Config.saves.autoload)){case"boolean":Config.saves.autoload&&Save.autosave.ok()&&Save.autosave.has()&&(r=!Save.autosave.load());break;case"string":"prompt"===Config.saves.autoload&&Save.autosave.ok()&&Save.autosave.has()&&(r=!1,UI.buildDialogAutoload(),UI.open());break;case"function":Save.autosave.ok()&&Save.autosave.has()&&Config.saves.autoload()&&(r=!Save.autosave.load())}r&&l(Config.passages.start)}}function t(){LoadScreen.show(),window.scroll(0,0),State.reset(),window.location.reload()}function r(){return p}function n(){return f}function a(e){var t=State.goTo(e);return t&&u(),t}function i(e){var t=State.go(e);return t&&u(),t}function o(){return i(-1)}function s(){return i(1)}function u(){return l(State.passage,!0)}function l(e,t){var r=e;p="playing",TempState={},State.clearTemporary();var n=void 0,a=void 0;if("function"==typeof Config.navigation.override)try{var i=Config.navigation.override(r);i&&(r=i)}catch(e){}var o=Story.get(r);if(Object.keys(prehistory).forEach(function(e){"function"==typeof prehistory[e]&&prehistory[e].call(this,e)},o),t||State.create(o.title),document.body.className&&(document.body.className=""),Object.keys(predisplay).forEach(function(e){"function"==typeof predisplay[e]&&predisplay[e].call(this,e)},o),Story.has("PassageReady"))try{n=Wikifier.wikifyEval(Story.get("PassageReady").text)}catch(e){Alert.error("PassageReady",e.message)}p="rendering";var s=jQuery(o.render()),u=document.getElementById("passages");if(u.hasChildNodes()&&("number"==typeof Config.passages.transitionOut||"string"==typeof Config.passages.transitionOut&&""!==Config.passages.transitionOut&&""!==Config.transitionEndEventName?[].concat(_toConsumableArray(u.childNodes)).forEach(function(e){var t=jQuery(e);if(e.nodeType===Node.ELEMENT_NODE&&t.hasClass("passage")){if(t.hasClass("passage-out"))return;t.attr("id","out-"+t.attr("id")).addClass("passage-out"),"string"==typeof Config.passages.transitionOut?t.on(Config.transitionEndEventName,function(e){e.originalEvent.propertyName===Config.passages.transitionOut&&t.remove()}):setTimeout(function(){return t.remove()},Math.max(d,Config.passages.transitionOut))}else t.remove()}):jQuery(u).empty()),s.addClass("passage-in").appendTo(u),setTimeout(function(){return s.removeClass("passage-in")},d),document.title=Config.passages.displayTitles&&o.title!==Config.passages.start?o.title+" | "+Story.title:Story.title,window.scroll(0,0),p="playing",Story.has("PassageDone"))try{a=Wikifier.wikifyEval(Story.get("PassageDone").text)}catch(e){Alert.error("PassageDone",e.message)}if(Object.keys(postdisplay).forEach(function(e){"function"==typeof postdisplay[e]&&postdisplay[e].call(this,e)},o),Config.ui.updateStoryElements&&UI.setStoryElements(),Config.debug){var l=void 0;null!=n&&(l=new DebugView(document.createDocumentFragment(),"special","PassageReady","PassageReady"),l.modes({hidden:!0}),l.append(n),s.prepend(l.output)),null!=a&&(l=new DebugView(document.createDocumentFragment(),"special","PassageDone","PassageDone"),l.modes({hidden:!0}),l.append(a),s.append(l.output)),1===State.turns&&null!=h&&s.prepend(h)}switch(f=Date.now(),UI.hideOutlines(),jQuery("#story").find("a[href]:not(.link-external)").addClass("link-external").end().find("a,link,button,input,select,textarea").not("[tabindex]").attr("tabindex",0),_typeof(Config.saves.autosave)){case"boolean":Config.saves.autosave&&Save.autosave.save();break;case"string":o.tags.includes(Config.saves.autosave)&&Save.autosave.save();break;case"object":Array.isArray(Config.saves.autosave)&&o.tags.some(function(e){return Config.saves.autosave.includes(e)})&&Save.autosave.save()}return p="idle",s[0]}function c(e,t,r){var n=!1;switch(r){case undefined:break;case"replace":case"back":n=!0;break;default:throw new Error('Engine.display option parameter called with obsolete value "'+r+'"; please notify the developer')}l(e,n)}var d=40,p="idle",f=null,h=null;return Object.freeze(Object.defineProperties({},{minDomActionDelay:{value:d},start:{value:e},restart:{value:t},state:{get:r},lastPlay:{get:n},goTo:{value:a},go:{value:i},backward:{value:o},forward:{value:s},show:{value:u},play:{value:l},display:{value:c}}))}(),Passage=function(){var e=void 0,t=void 0;e=/^(?:debug|nobr|passage|script|stylesheet|widget|twine\..*)$/i,!function(){var e=/(?:\\n|\\t|\\s|\\|\r)/g,r=new RegExp(e.source),n=Object.freeze({"\\n":"\n","\\t":"\t","\\s":"\\","\\":"\\","\r":""});t=function(t){if(null==t)return"";var a=String(t);return a&&r.test(a)?a.replace(e,function(e){return n[e]}):a}}();var r=function(){function r(t,n){var a=this;_classCallCheck(this,r),Object.defineProperties(this,{title:{value:Util.unescape(t)},element:{value:n||null},tags:{value:Object.freeze(n&&n.hasAttribute("tags")?n.getAttribute("tags").trim().splitOrEmpty(/\s+/).sort().filter(function(e,t,r){return 0===t||r[t-1]!==e}):[])},_excerpt:{writable:!0,value:null}}),Object.defineProperties(this,{domId:{value:"passage-"+Util.slugify(this.title)},classes:{value:Object.freeze(0===this.tags.length?[]:function(){return a.tags.filter(function(t){return!e.test(t)}).map(function(e){return Util.slugify(e)})}())}})}return _createClass(r,[{key:"description",value:function(){var e=Config.passages.descriptions;if(null!=e)switch("undefined"==typeof e?"undefined":_typeof(e)){case"boolean":if(e)return this.title;break;case"object":if(e instanceof Map&&e.has(this.title))return e.get(this.title);if(e.hasOwnProperty(this.title))return e[this.title];break;case"function":var t=e.call(this);if(t)return t;break;default:throw new TypeError("Config.passages.descriptions must be a boolean, object, or function")}return null===this._excerpt&&(this._excerpt=r.getExcerptFromText(this.text)),this._excerpt}},{key:"processText",value:function(){var e=this.text;return this.tags.includes("nobr")&&(e=e.replace(/^\n+|\n+$/g,"").replace(/\n+/g," ")),this.tags.includes("Twine.image")&&(e="[img["+e+"]]"),e}},{key:"render",value:function(){var e=this,t=document.createElement("div");return jQuery(t).attr({id:this.domId,"data-passage":this.title,"data-tags":this.tags.join(" ")}).addClass("passage "+this.className),jQuery(document.body).addClass(this.className),Object.keys(prerender).forEach(function(r){"function"==typeof prerender[r]&&prerender[r].call(e,t,r)}),Story.has("PassageHeader")&&new Wikifier(t,Story.get("PassageHeader").processText()),new Wikifier(t,this.processText()),Story.has("PassageFooter")&&new Wikifier(t,Story.get("PassageFooter").processText()),Object.keys(postrender).forEach(function(r){"function"==typeof postrender[r]&&postrender[r].call(e,t,r)}),this._excerpt=r.getExcerptFromNode(t),t}},{key:"className",get:function(){return this.classes.join(" ")}},{key:"text",get:function(){if(null==this.element){var e=Util.escape(this.title);return'<span class="error" title="'+e+'">'+L10n.get("errorTitle")+": "+L10n.get("errorNonexistentPassage",{passage:e})+"</span>"}return t(this.element.textContent)}}],[{key:"getExcerptFromNode",value:function(e,t){if(!e.hasChildNodes())return"";var r=e.textContent.trim();if(""!==r){var n=new RegExp("(\\S+(?:\\s+\\S+){0,"+(t>0?t-1:7)+"})");r=r.replace(/\s+/g," ").match(n)}return r?r[1]+"…":"…"}},{key:"getExcerptFromText",value:function(e,t){if(""===e)return"";var r=new RegExp("(\\S+(?:\\s+\\S+){0,"+(t>0?t-1:7)+"})"),n=e.replace(/<<.*?>>/g," ").replace(/<.*?>/g," ").trim().replace(/^\s*\|.*\|.*?$/gm,"").replace(/\[[<>]?img\[[^\]]*\]\]/g,"").replace(/\[\[([^|\]]*)(?:|[^\]]*)?\]\]/g,"$1").replace(/^\s*!+(.*?)$/gm,"$1").replace(/'{2}|\/{2}|_{2}|@{2}/g,"").trim().replace(/\s+/g," ").match(r);return n?n[1]+"…":"…"}}]),r}();return r}(),Save=function(){function e(){if("cookie"===storage.name)return n(),Config.saves.autosave=undefined,Config.saves.slots=0,!1;Config.saves.slots=Math.max(0,Config.saves.slots),Number.isSafeInteger(Config.saves.slots)||(Config.saves.slots=8);var e=r(),t=!1;Array.isArray(e)&&(e={autosave:null,slots:e},t=!0),Config.saves.slots!==e.slots.length&&(Config.saves.slots<e.slots.length?(e.slots.reverse(),e.slots=e.slots.filter(function(e){return!(null===e&&this.count>0)||(--this.count,!1)},{count:e.slots.length-Config.saves.slots}),e.slots.reverse()):Config.saves.slots>e.slots.length&&S(e.slots,Config.saves.slots-e.slots.length),t=!0),j(e.autosave)&&(t=!0);for(var a=0;a<e.slots.length;++a)j(e.slots[a])&&(t=!0);return E(e)&&(storage.delete("saves"),t=!1),t&&x(e),T=e.slots.length-1,!0}function t(){return{autosave:null,slots:S([],Config.saves.slots)}}function r(){var e=storage.get("saves");return null===e?t():e}function n(){return storage.delete("saves"),!0}function a(){return i()||d()}function i(){return"cookie"!==storage.name&&"undefined"!=typeof Config.saves.autosave}function o(){var e=r();return null!==e.autosave}function s(){var e=r();return e.autosave}function u(){var e=r();return null!==e.autosave&&O(e.autosave)}function l(e,t){if("function"==typeof Config.saves.isAllowed&&!Config.saves.isAllowed())return!1;var n=r(),a={title:e||Story.get(State.passage).description(),date:Date.now()};return null!=t&&(a.metadata=t),n.autosave=C(a),x(n)}function c(){var e=r();return e.autosave=null,x(e)}function d(){return"cookie"!==storage.name&&T!==-1}function p(){return T+1}function f(){if(!d())return 0;for(var e=r(),t=0,n=0,a=e.slots.length;n<a;++n)null!==e.slots[n]&&++t;return t}function h(){return 0===f()}function g(e){if(e<0||e>T)return!1;var t=r();return!(e>=t.slots.length||null===t.slots[e])}function m(e){if(e<0||e>T)return null;var t=r();return e>=t.slots.length?null:t.slots[e]}function v(e){if(e<0||e>T)return!1;var t=r();return!(e>=t.slots.length||null===t.slots[e])&&O(t.slots[e])}function y(e,t,n){if("function"==typeof Config.saves.isAllowed&&!Config.saves.isAllowed())return UI.alert(L10n.get("savesDisallowed")),!1;if(e<0||e>T)return!1;var a=r();if(e>=a.slots.length)return!1;var i={title:t||Story.get(State.passage).description(),date:Date.now()};return null!=n&&(i.metadata=n),a.slots[e]=C(i),x(a)}function b(e){if(e<0||e>T)return!1;var t=r();return!(e>=t.slots.length)&&(t.slots[e]=null,x(t))}function w(e,t){function r(){var e=new Date,t=e.getMonth()+1,r=e.getDate(),n=e.getHours(),a=e.getMinutes(),i=e.getSeconds();return t<10&&(t="0"+t),r<10&&(r="0"+r),n<10&&(n="0"+n),a<10&&(a="0"+a),i<10&&(i="0"+i),""+e.getFullYear()+t+r+"-"+n+a+i}if("function"==typeof Config.saves.isAllowed&&!Config.saves.isAllowed())return void UI.alert(L10n.get("savesDisallowed"));var n=null==e?Story.domId:Util.slugify(e),a=n+"-"+r()+".save",i=null==t?{}:{metadata:t},o=LZString.compressToBase64(JSON.stringify(C(i)));saveAs(new Blob([o],{type:"text/plain;charset=UTF-8"}),a)}function k(e){var t=e.target.files[0],r=new FileReader;jQuery(r).on("load",function(e){var r=e.currentTarget;if(r.result){var n=void 0;try{n=JSON.parse(/\.json$/i.test(t.name)||/^\{/.test(r.result)?r.result:LZString.decompressFromBase64(r.result))}catch(e){}O(n)}}),r.readAsText(t)}function S(e,t){for(var r=0;r<t;++r)e.push(null);return e}function E(e){for(var t=e.slots,r=!0,n=0,a=t.length;n<a;++n)if(null!==t[n]){r=!1;break}return null===e.autosave&&r}function x(e){return E(e)?(storage.delete("saves"),!0):storage.set("saves",e)}function j(e){if(null===e)return!1;var t=!1;return e.hasOwnProperty("state")&&e.state.hasOwnProperty("delta")&&e.state.hasOwnProperty("index")||(e.hasOwnProperty("data")?(delete e.mode,e.state={delta:State.deltaEncode(e.data)},delete e.data):e.state.hasOwnProperty("delta")?e.state.hasOwnProperty("index")||delete e.state.mode:(delete e.state.mode,e.state.delta=State.deltaEncode(e.state.history),delete e.state.history),e.state.index=e.state.delta.length-1,t=!0),e.state.hasOwnProperty("rseed")&&(e.state.seed=e.state.rseed,delete e.state.rseed,e.state.delta.forEach(function(e,t,r){r[t].hasOwnProperty("rcount")&&(r[t].pull=r[t].rcount,delete r[t].rcount)}),t=!0),(e.state.hasOwnProperty("expired")&&"number"==typeof e.state.expired||e.state.hasOwnProperty("unique")||e.state.hasOwnProperty("last"))&&(e.state.hasOwnProperty("expired")&&"number"==typeof e.state.expired&&delete e.state.expired,(e.state.hasOwnProperty("unique")||e.state.hasOwnProperty("last"))&&(e.state.expired=[],e.state.hasOwnProperty("unique")&&(e.state.expired.push(e.state.unique),delete e.state.unique),e.state.hasOwnProperty("last")&&(e.state.expired.push(e.state.last),delete e.state.last)),t=!0),t}function C(e){if(null!=e&&"object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("supplemental parameter must be an object");var t=Object.assign({},e,{id:Config.saves.id,state:State.marshalForSave()});return Config.saves.version&&(t.version=Config.saves.version),"function"==typeof Config.saves.onSave&&Config.saves.onSave(t),t.state.delta=State.deltaEncode(t.state.history),delete t.state.history,t}function O(e){try{if(j(e),!e||!e.hasOwnProperty("id")||!e.hasOwnProperty("state"))throw new Error(L10n.get("errorSaveMissingData"));if(e.state.history=State.deltaDecode(e.state.delta),delete e.state.delta,"function"==typeof Config.saves.onLoad&&Config.saves.onLoad(e),e.id!==Config.saves.id)throw new Error(L10n.get("errorSaveIdMismatch"));State.unmarshalForSave(e.state),Engine.show()}catch(e){return UI.alert(e.message.toUpperFirst()+".</p><p>"+L10n.get("aborting")+"."),!1}return!0}var T=-1;return Object.freeze(Object.defineProperties({},{init:{value:e},get:{value:r},clear:{value:n},ok:{value:a},autosave:{value:Object.freeze(Object.defineProperties({},{ok:{value:i},has:{value:o},get:{value:s},load:{value:u},save:{value:l},delete:{value:c}}))},slots:{value:Object.freeze(Object.defineProperties({},{ok:{value:d},length:{get:p},isEmpty:{value:h},count:{value:f},has:{value:g},get:{value:m},load:{value:v},save:{value:y},delete:{value:b}}))},export:{value:w},import:{value:k}}))}(),Setting=function(){function e(){if(storage.has("options")){var e=storage.get("options");null!==e&&(window.SugarCube.settings=settings=Object.assign(t(),e)),r(),storage.delete("options")}n(),g.forEach(function(e){if(e.hasOwnProperty("onInit")){var t={name:e.name,value:settings[e.name],default:e.default};e.hasOwnProperty("list")&&(t.list=e.list),e.onInit.call(t)}})}function t(){return Object.create(null)}function r(){var e=t();return Object.keys(settings).length>0&&g.filter(function(e){return e.type!==m.Header&&settings[e.name]!==e.default}).forEach(function(t){return e[t.name]=settings[t.name]}),0===Object.keys(e).length?(storage.delete("settings"),!0):storage.set("settings",e)}function n(){var e=t(),r=storage.get("settings")||t();g.filter(function(e){return e.type!==m.Header}).forEach(function(t){return e[t.name]=t.default}),window.SugarCube.settings=settings=Object.assign(e,r)}function a(){return window.SugarCube.settings=settings=t(),storage.delete("settings"),!0}function i(e){if(0===arguments.length)a(),n();else{if(null==e||!p(e))throw new Error('nonexistent setting "'+e+'"');var t=f(e);t.type!==m.Header&&(settings[e]=t.default)}return r()}function o(e,t){g.forEach(e,t)}function s(e,t,r){if(arguments.length<3){var n=[];throw arguments.length<1&&n.push("type"),arguments.length<2&&n.push("name"),arguments.length<3&&n.push("definition"),new Error("missing parameters, no "+n.join(" or ")+" specified")}if("object"!==("undefined"==typeof r?"undefined":_typeof(r)))throw new TypeError("definition parameter must be an object");if(p(t))throw new Error('cannot clobber existing setting "'+t+'"');var a={type:e,name:t,label:null==r.label?"":String(r.label).trim()};switch(e){case m.Header:break;case m.Toggle:a.default=!!r.default;break;case m.List:if(!r.hasOwnProperty("list"))throw new Error("no list specified");if(!Array.isArray(r.list))throw new TypeError("list must be an array");if(0===r.list.length)throw new Error("list must not be empty");if(a.list=Object.freeze(r.list),null==r.default)a.default=r.list[0];else{var i=r.list.indexOf(r.default);if(i===-1)throw new Error("list does not contain default");a.default=r.list[i]}break;default:throw new Error("unknown Setting type: "+e)}"function"==typeof r.onInit&&(a.onInit=Object.freeze(r.onInit)),"function"==typeof r.onChange&&(a.onChange=Object.freeze(r.onChange)),g.push(Object.freeze(a))}function u(e,t){s(m.Header,e,{label:t})}function l(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];s.apply(undefined,[m.Toggle].concat(t))}function c(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];s.apply(undefined,[m.List].concat(t))}function d(){return 0===g.length}function p(e){return g.some(function(t){return t.name===e})}function f(e){return g.find(function(t){return t.name===e})}function h(e){p(e)&&delete settings[e];for(var t=0;t<g.length;++t)if(g[t].name===e){g.splice(t,1),h(e);break}}var g=[],m=Object.freeze({Header:0,Toggle:1,List:2});return Object.freeze(Object.defineProperties({},{Types:{value:m},init:{value:e},create:{value:t},save:{value:r},load:{value:n},clear:{value:a},reset:{value:i},forEach:{value:o},add:{value:s},addHeader:{value:u},addToggle:{value:l},addList:{value:c},isEmpty:{value:d},has:{value:p},get:{value:f},delete:{value:h}}))}(),State=function(){function e(){session.delete("state"),L=[],Q=c(),I=-1,R=[],F=null===F?null:new PRNGWrapper(F.seed,!1)}function t(){if(session.has("state")){var e=session.get("state");return null!=e&&(n(e),!0)}return!1}function r(e){var t={index:I};return e?t.history=clone(L):t.delta=A(L),R.length>0&&(t.expired=[].concat(_toConsumableArray(R))),null!==F&&(t.seed=F.seed),t}function n(e,t){if(null==e)throw new Error("state object is null or undefined");if(!e.hasOwnProperty(t?"history":"delta")||0===e[t?"history":"delta"].length)throw new Error("state object has no history or history is empty");
-if(!e.hasOwnProperty("index"))throw new Error("state object has no index");if(null!==F&&!e.hasOwnProperty("seed"))throw new Error("state object has no seed, but PRNG is enabled");if(null===F&&e.hasOwnProperty("seed"))throw new Error("state object has seed, but PRNG is disabled");L=t?clone(e.history):_(e.delta),I=e.index,R=e.hasOwnProperty("expired")?[].concat(_toConsumableArray(e.expired)):[],e.hasOwnProperty("seed")&&(F.seed=e.seed),g(I)}function a(){return r(!0)}function i(e){return n(e,!0)}function o(){return R}function s(){return R.length+v()}function u(){return R.concat(L.slice(0,v()).map(function(e){return e.title}))}function l(e){return null!=e&&""!==e&&(!!R.includes(e)||!!L.slice(0,v()).some(function(t){return t.title===e}))}function c(e,t){return{title:null==e?"":String(e),variables:null==t?{}:clone(t)}}function d(){return Q}function p(){return I}function f(){return Q.title}function h(){return Q.variables}function g(e){if(null==e)throw new Error("moment activation attempted with null or undefined");switch("undefined"==typeof e?"undefined":_typeof(e)){case"object":Q=clone(e);break;case"number":if(b())throw new Error("moment activation attempted with index on empty history");if(e<0||e>=y())throw new RangeError("moment activation attempted with out-of-bounds index; need [0, "+(y()-1)+"], got "+e);Q=clone(L[e]);break;default:throw new TypeError('moment activation attempted with a "'+("undefined"==typeof e?"undefined":_typeof(e))+'"; must be an object or valid history stack index')}return null!==F&&(F=PRNGWrapper.unmarshal({seed:F.seed,pull:Q.pull})),session.set("state",r()),jQuery.event.trigger("tw:historyupdate"),Q}function m(){return L}function v(){return I+1}function y(){return L.length}function b(){return 0===L.length}function w(){return L.length>0?L[I]:null}function k(){return L.length>0?L[L.length-1]:null}function S(){return L.length>0?L[0]:null}function E(e){return b()||e<0||e>I?null:L[e]}function x(e){if(b())return null;var t=1+(e?Math.abs(e):0);return t>v()?null:L[v()-t]}function j(e){if(b()||null==e||""===e)return!1;for(var t=I;t>=0;--t)if(L[t].title===e)return!0;return!1}function C(e){if(v()<y()&&L.splice(v(),y()-v()),L.push(c(e,Q.variables)),F&&(k().pull=F.pull),Config.history.maxStates>0)for(;y()>Config.history.maxStates;)R.push(L.shift().title);return I=y()-1,g(I),v()}function O(e){return!(null==e||e<0||e>=y()||e===I)&&(I=e,g(I),!0)}function T(e){return null!=e&&0!==e&&O(I+e)}function A(e){if(!Array.isArray(e))return null;if(0===e.length)return[];for(var t=[clone(e[0])],r=1,n=e.length;r<n;++r)t.push(Util.diff(e[r-1],e[r]));return t}function _(e){if(!Array.isArray(e))return null;if(0===e.length)return[];for(var t=[clone(e[0])],r=1,n=e.length;r<n;++r)t.push(Util.patch(t[r-1],e[r]));return t}function P(e,t){if(!b()){var r=void 0;throw r="a script-tagged passage",new Error("State.initPRNG must be called during initialization, within either "+r+" or the StoryInit special passage")}F=new PRNGWrapper(e,t),Q.pull=F.pull}function D(){return F?F.random():Math.random()}function M(){V={},TempVariables=V}function N(){return V}var L=[],Q=c(),I=-1,R=[],F=null,V={};return Object.freeze(Object.defineProperties({},{reset:{value:e},restore:{value:t},marshalForSave:{value:a},unmarshalForSave:{value:i},expired:{get:o},turns:{get:s},passages:{get:u},hasPlayed:{value:l},active:{get:d},activeIndex:{get:p},passage:{get:f},variables:{get:h},history:{get:m},length:{get:v},size:{get:y},isEmpty:{value:b},current:{get:w},top:{get:k},bottom:{get:S},index:{value:E},peek:{value:x},has:{value:j},create:{value:C},goTo:{value:O},go:{value:T},deltaEncode:{value:A},deltaDecode:{value:_},initPRNG:{value:P},random:{value:D},clearTemporary:{value:M},temporary:{get:N},restart:{value:function(){return Engine.restart()}},backward:{value:function(){return Engine.backward()}},forward:{value:function(){return Engine.forward()}},display:{value:function(){return Engine.display.apply(Engine,arguments)}},show:{value:function(){return Engine.show.apply(Engine,arguments)}},play:{value:function(){return Engine.play.apply(Engine,arguments)}}}))}(),Story=function(){function e(){function e(e){if(e.tags.includesAny(n))throw new Error('starting passage "'+e.title+'" contains illegal tags; invalid: "'+e.tags.filter(function(e){return n.includes(e)}).sort().join('", "')+'"')}function t(e){if(a.includes(e.title)&&e.tags.includesAny(n))throw new Error('special passage "'+e.title+'" contains illegal tags; invalid: "'+e.tags.filter(function(e){return n.includes(e)}).sort().join('", "')+'"')}var n=["widget"],a=["PassageDone","PassageFooter","PassageHeader","PassageReady","StoryAuthor","StoryBanner","StoryCaption","StoryInit","StoryMenu","StoryShare","StorySubtitle"];!function(){var i=function(e){var t=[].concat(n),r=[];if(e.tags.forEach(function(e){t.includes(e)&&r.push.apply(r,_toConsumableArray(t.delete(e)))}),r.length>1)throw new Error('code passage "'+e.title+'" contains multiple code tags; invalid: "'+r.sort().join('", "')+'"')};if(n.unshift("script","stylesheet"),a.push("StoryTitle"),Config.passages.start=function(){var e="START_AT";return""!==e?(Config.debug=!0,e):"Start"}(),jQuery("#store-area").children(':not([tags~="Twine.private"],[tags~="annotation"])').each(function(){var r=jQuery(this),n=new Passage(r.attr("tiddler"),this);n.title===Config.passages.start?(e(n),c[n.title]=n):n.tags.includes("stylesheet")?(i(n),d.push(n)):n.tags.includes("script")?(i(n),p.push(n)):n.tags.includes("widget")?(i(n),f.push(n)):(t(n),c[n.title]=n)}),!c.hasOwnProperty("StoryTitle"))throw new Error('cannot find the "StoryTitle" special passage');var o=document.createDocumentFragment();new Wikifier(o,c.StoryTitle.processText().trim()),r(o.textContent.trim()),Config.saves.id=Story.domId}()}function t(){!function(){var e=LoadScreen.lock(),t=document.createElement("style");jQuery(t).attr({id:"style-story",type:"text/css"}).one("load",function(){return LoadScreen.unlock(e)}),new StyleWrapper(t).add(d.map(function(e){return e.text.trim()}).join("\n")),document.head.appendChild(t)}();for(var e=0;e<p.length;++e)try{Scripting.evalJavaScript(p[e].text)}catch(t){Alert.error(p[e].title,"object"===("undefined"==typeof t?"undefined":_typeof(t))?t.message:t)}for(var t=0;t<f.length;++t)try{Wikifier.wikifyEval(f[t].processText())}catch(e){Alert.error(f[t].title,"object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e)}}function r(e){if(null==e||""===e)throw new Error("story title cannot be null or empty");document.title=h=Util.unescape(e),m=Util.slugify(h)}function n(){return h}function a(){return m}function i(){return g}function o(e){var t="undefined"==typeof e?"undefined":_typeof(e);switch(t){case"number":case"string":var r=String(e);return c.hasOwnProperty(r);case"boolean":case"function":t="a "+t;break;case"undefined":break;default:t=null===e?"null":"an "+t}throw new TypeError("Story.has title parameter cannot be "+t)}function s(e){var t="undefined"==typeof e?"undefined":_typeof(e);switch(t){case"number":case"string":var r=String(e);return c.hasOwnProperty(r)?c[r]:new Passage(r||"(unknown)");case"boolean":case"function":t="a "+t;break;case"undefined":break;default:t=null===e?"null":"an "+t}throw new TypeError("Story.get title parameter cannot be "+t)}function u(e,t){for(var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"title",n=Object.keys(c),a=[],i=0;i<n.length;++i){var o=c[n[i]];if(o.hasOwnProperty(e))switch(_typeof(o[e])){case"undefined":break;case"object":for(var s=0,u=o[e].length;s<u;++s)if(o[e][s]==t){a.push(o);break}break;default:o[e]==t&&a.push(o)}}return a.sort(function(e,t){return e[r]==t[r]?0:e[r]<t[r]?-1:1}),a}function l(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"title";if("function"!=typeof e)throw new Error("Story.lookupWith filter parameter must be a function");for(var r=Object.keys(c),n=[],a=0;a<r.length;++a){var i=c[r[a]];e(i)&&n.push(i)}return n.sort(function(e,r){return e[t]==r[t]?0:e[t]<r[t]?-1:1}),n}var c={},d=[],p=[],f=[],h="",g="",m="";return Object.freeze(Object.defineProperties({},{passages:{value:c},styles:{value:d},scripts:{value:p},widgets:{value:f},load:{value:e},init:{value:t},title:{get:n},domId:{get:a},ifId:{get:i},has:{value:o},get:{value:s},lookup:{value:u},lookupWith:{value:l}}))}(),UI=function(){function e(){jQuery("#init-no-js,#init-lacking").remove(),w=new StyleWrapper(function(){return jQuery(document.createElement("style")).attr({id:"style-outline-patch",type:"text/css"}).appendTo(document.head).get(0)}()),function(){var e=jQuery(document.createDocumentFragment()),t=L10n.get("uiBarToggle"),r=L10n.get("uiBarBackward"),n=L10n.get("uiBarJumpto"),a=L10n.get("uiBarForward");e.append('<div id="ui-bar"><div id="ui-bar-tray">'+('<button id="ui-bar-toggle" tabindex="0" title="'+t+'" aria-label="'+t+'"></button>')+'<div id="ui-bar-history">'+('<button id="history-backward" tabindex="0" title="'+r+'" aria-label="'+r+'">î ¡</button>')+('<button id="history-jumpto" tabindex="0" title="'+n+'" aria-label="'+n+'">î ¹</button>')+('<button id="history-forward" tabindex="0" title="'+a+'" aria-label="'+a+'">î ¢</button>')+'</div></div><div id="ui-bar-body"><header id="title" role="banner"><div id="story-banner"></div><h1 id="story-title"></h1><div id="story-subtitle"></div><div id="story-title-separator"></div><p id="story-author"></p></header><div id="story-caption"></div><nav id="menu" role="navigation"><ul id="menu-story"></ul><ul id="menu-core">'+('<li id="menu-item-saves"><a tabindex="0">'+L10n.get("savesTitle")+"</a></li>")+('<li id="menu-item-settings"><a tabindex="0">'+L10n.get("settingsTitle")+"</a></li>")+('<li id="menu-item-restart"><a tabindex="0">'+L10n.get("restartTitle")+"</a></li>")+('<li id="menu-item-share"><a tabindex="0">'+L10n.get("shareTitle")+"</a></li>")+'</ul></nav></div></div><div id="story" role="main"><div id="passages"></div></div>').insertBefore("#store-area")}(),jQuery(document).on("tw:historyupdate",function(e,t){return function(){e.prop("disabled",State.length<2),t.prop("disabled",State.length===State.size)}}(jQuery("#history-backward"),jQuery("#history-forward"))).on("mousedown.outline-handler keydown.outline-handler",function(e){switch(e.type){case"mousedown":i();break;case"keydown":o()}})}function t(){var e=jQuery("#ui-bar");("boolean"==typeof Config.ui.stowBarInitially?Config.ui.stowBarInitially:jQuery(window).width()<=Config.ui.stowBarInitially)&&!function(){var t=jQuery(e).add("#story");t.addClass("no-transition"),e.addClass("stowed"),setTimeout(function(){return t.removeClass("no-transition")},Engine.minDomActionDelay)}(),jQuery("#ui-bar-toggle").ariaClick({label:L10n.get("uiBarToggle")},function(){return e.toggleClass("stowed")}),Config.history.controls?(jQuery("#history-backward").prop("disabled",State.length<2).ariaClick({label:L10n.get("uiBarBackward")},function(){return Engine.backward()}),Story.lookup("tags","bookmark").length>0?jQuery("#history-jumpto").ariaClick({label:L10n.get("uiBarJumpto")},function(){return UI.jumpto()}):jQuery("#history-jumpto").remove(),jQuery("#history-forward").prop("disabled",State.length===State.size).ariaClick({label:L10n.get("uiBarForward")},function(){return Engine.forward()})):jQuery("#ui-bar-history").remove(),setPageElement("story-title","StoryTitle",Story.title),Story.has("StoryCaption")||jQuery("#story-caption").remove(),Story.has("StoryMenu")||jQuery("#menu-story").remove(),Config.ui.updateStoryElements||a(),Dialog.addClickHandler("#menu-item-saves a",null,v).text(L10n.get("savesTitle")),Setting.isEmpty()?jQuery("#menu-item-settings").remove():Dialog.addClickHandler("#menu-item-settings a",null,y).text(L10n.get("settingsTitle")),Dialog.addClickHandler("#menu-item-restart a",null,m).text(L10n.get("restartTitle")),Story.has("StoryShare")?Dialog.addClickHandler("#menu-item-share a",null,b).text(L10n.get("shareTitle")):jQuery("#menu-item-share").remove(),jQuery(document.documentElement).focus()}function r(){jQuery("#ui-bar").addClass("stow")}function n(){jQuery("#ui-bar").removeClass("stow")}function a(){setPageElement("story-banner","StoryBanner"),setPageElement("story-subtitle","StorySubtitle"),setPageElement("story-author","StoryAuthor"),setPageElement("story-caption","StoryCaption");var e=document.getElementById("menu-story");null!==e&&(jQuery(e).empty(),Story.has("StoryMenu")&&s("StoryMenu",e))}function i(){w.set("*:focus{outline:none}")}function o(){w.clear()}function s(e,t){var r=t,n=Config.debug;Config.debug=!1;try{null==r&&(r=document.createElement("ul"));var a=document.createDocumentFragment();if(new Wikifier(a,Story.get(e).processText().trim()),a.hasChildNodes())for(var i=null;a.hasChildNodes();){var o=a.firstChild;o.nodeType!==Node.ELEMENT_NODE||"A"!==o.nodeName.toUpperCase()?(a.removeChild(o),null!==i&&(i=null)):(null===i&&(i=document.createElement("li"),r.appendChild(i)),i.appendChild(o))}}finally{Config.debug=n}return r}function u(e){jQuery(Dialog.setup("Alert","alert")).append("<p>"+e+'</p><ul class="buttons">'+('<li><button id="alert-ok" class="ui-close">'+L10n.get(["alertOk","ok"])+"</button></li>")+"</ul>");for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];Dialog.open.apply(Dialog,r)}function l(){g(),Dialog.open.apply(Dialog,arguments)}function c(){m(),Dialog.open.apply(Dialog,arguments)}function d(){v(),Dialog.open.apply(Dialog,arguments)}function p(){y(),Dialog.open.apply(Dialog,arguments)}function f(){b(),Dialog.open.apply(Dialog,arguments)}function h(){return jQuery(Dialog.setup(L10n.get("autoloadTitle"),"autoload")).append("<p>"+L10n.get("autoloadPrompt")+'</p><ul class="buttons">'+('<li><button id="autoload-ok" class="ui-close">'+L10n.get(["autoloadOk","ok"])+"</button></li>")+('<li><button id="autoload-cancel" class="ui-close">'+L10n.get(["autoloadCancel","cancel"])+"</button></li>")+"</ul>"),jQuery(document).one("click.autoload",".ui-close",function(e){var t="autoload-ok"===e.target.id;jQuery(document).one("tw:dialogclosed",function(){t&&Save.autosave.load()||Engine.play(Config.passages.start)})}),!0}function g(){var e=document.createElement("ul");jQuery(Dialog.setup(L10n.get("jumptoTitle"),"jumpto list")).append(e);for(var t=State.expired.length,r=State.size-1;r>=0;--r)if(r!==State.activeIndex){var n=Story.get(State.history[r].title);n&&n.tags.includes("bookmark")&&jQuery(document.createElement("li")).append(jQuery(document.createElement("a")).ariaClick({one:!0},function(e){return function(){return jQuery(document).one("tw:dialogclosed",function(){return Engine.goTo(e)})}}(r)).addClass("ui-close").text(L10n.get("jumptoTurn")+" "+(t+r+1)+": "+n.description())).appendTo(e)}e.hasChildNodes()||jQuery(e).append("<li><a><em>"+L10n.get("jumptoUnavailable")+"</em></a></li>")}function m(){return jQuery(Dialog.setup(L10n.get("restartTitle"),"restart")).append("<p>"+L10n.get("restartPrompt")+'</p><ul class="buttons">'+('<li><button id="restart-ok">'+L10n.get(["restartOk","ok"])+"</button></li>")+('<li><button id="restart-cancel" class="ui-close">'+L10n.get(["restartCancel","cancel"])+"</button></li>")+"</ul>").find("#restart-ok").ariaClick({one:!0},function(){jQuery(document).one("tw:dialogclosed",function(){return Engine.restart()}),Dialog.close()}),!0}function v(){function e(e,t,r,n){var a=jQuery(document.createElement("button")).attr("id","saves-"+e).html(r);return t&&a.addClass(t),n?a.ariaClick(n):a.prop("disabled",!0),jQuery(document.createElement("li")).append(a)}function t(){function e(e,t,r,n,a){var i=jQuery(document.createElement("button")).attr("id","saves-"+e+"-"+n).addClass(e).html(r);return t&&i.addClass(t),a?"auto"===n?i.ariaClick({label:r+" "+L10n.get("savesLabelAuto")},function(){return a()}):i.ariaClick({label:r+" "+L10n.get("savesLabelSlot")+" "+(n+1)},function(){return a(n)}):i.prop("disabled",!0),i}var t=Save.get(),r=jQuery(document.createElement("tbody"));if(Save.autosave.ok()){var n=jQuery(document.createElement("td")),a=jQuery(document.createElement("td")),i=jQuery(document.createElement("td")),o=jQuery(document.createElement("td"));jQuery(document.createElement("b")).attr({title:L10n.get("savesLabelAuto"),"aria-label":L10n.get("savesLabelAuto")}).text("A").appendTo(n),t.autosave?(a.append(e("load","ui-close",L10n.get("savesLabelLoad"),"auto",function(){jQuery(document).one("tw:dialogclosed",function(){return Save.autosave.load()})})),jQuery(document.createElement("div")).text(t.autosave.title).appendTo(i),jQuery(document.createElement("div")).addClass("datestamp").html(t.autosave.date?L10n.get("savesSavedOn")+" "+new Date(t.autosave.date).toLocaleString():L10n.get("savesSavedOn")+" <em>"+L10n.get("savesUnknownDate")+"</em>").appendTo(i),o.append(e("delete",null,L10n.get("savesLabelDelete"),"auto",function(){Save.autosave.delete(),v(),Dialog.resize()}))):(a.append(e("load",null,L10n.get("savesLabelLoad"),"auto")),jQuery(document.createElement("em")).text(L10n.get("savesEmptySlot")).appendTo(i),i.addClass("empty"),o.append(e("delete",null,L10n.get("savesLabelDelete"),"auto"))),jQuery(document.createElement("tr")).append(n).append(a).append(i).append(o).appendTo(r)}for(var s=0,u=t.slots.length;s<u;++s){var l=jQuery(document.createElement("td")),c=jQuery(document.createElement("td")),d=jQuery(document.createElement("td")),p=jQuery(document.createElement("td"));l.append(document.createTextNode(s+1)),t.slots[s]?(c.append(e("load","ui-close",L10n.get("savesLabelLoad"),s,function(e){jQuery(document).one("tw:dialogclosed",function(){return Save.slots.load(e)})})),jQuery(document.createElement("div")).text(t.slots[s].title).appendTo(d),jQuery(document.createElement("div")).addClass("datestamp").html(t.slots[s].date?L10n.get("savesSavedOn")+" "+new Date(t.slots[s].date).toLocaleString():L10n.get("savesSavedOn")+" <em>"+L10n.get("savesUnknownDate")+"</em>").appendTo(d),p.append(e("delete",null,L10n.get("savesLabelDelete"),s,function(e){Save.slots.delete(e),v(),Dialog.resize()}))):(c.append(e("save","ui-close",L10n.get("savesLabelSave"),s,Save.slots.save)),jQuery(document.createElement("em")).text(L10n.get("savesEmptySlot")).appendTo(d),d.addClass("empty"),p.append(e("delete",null,L10n.get("savesLabelDelete"),s))),jQuery(document.createElement("tr")).append(l).append(c).append(d).append(p).appendTo(r)}return jQuery(document.createElement("table")).attr("id","saves-list").append(r)}var r=jQuery(Dialog.setup(L10n.get("savesTitle"),"saves")),n=Save.ok();if(n&&r.append(t()),n||Has.fileAPI){var a=jQuery(document.createElement("ul")).addClass("buttons").appendTo(r);return Has.fileAPI&&(a.append(e("export","ui-close",L10n.get("savesLabelExport"),function(){return Save.export()})),a.append(e("import",null,L10n.get("savesLabelImport"),function(){return r.find("#saves-import-file").trigger("click")})),jQuery(document.createElement("input")).css({display:"block",visibility:"hidden",position:"fixed",left:"-9999px",top:"-9999px",width:"1px",height:"1px"}).attr({type:"file",id:"saves-import-file",tabindex:-1,"aria-hidden":!0}).on("change",function(e){jQuery(document).one("tw:dialogclosed",function(){return Save.import(e)}),Dialog.close()}).appendTo(r)),n&&a.append(e("clear",null,L10n.get("savesLabelClear"),Save.autosave.has()||!Save.slots.isEmpty()?function(){Save.clear(),v(),Dialog.resize()}:null)),!0}return u(L10n.get("savesIncapable")),!1}function y(){var e=jQuery(Dialog.setup(L10n.get("settingsTitle"),"settings"));return Setting.forEach(function(t){if(t.type===Setting.Types.Header){var r=t.name,n=Util.slugify(r),a=jQuery(document.createElement("div")),i=jQuery(document.createElement("h2")),o=jQuery(document.createElement("p"));return a.attr("id","header-body-"+n).append(i).append(o).appendTo(e),i.attr("id","header-heading-"+n).wiki(r),void o.attr("id","header-label-"+n).wiki(t.label)}var s=t.name,u=Util.slugify(s),l=jQuery(document.createElement("div")),c=jQuery(document.createElement("label")),d=jQuery(document.createElement("div")),p=void 0;switch(l.attr("id","setting-body-"+u).append(c).append(d).appendTo(e),c.attr({id:"setting-label-"+u,for:"setting-control-"+u}).wiki(t.label),null==settings[s]&&(settings[s]=t.default),t.type){case Setting.Types.Toggle:p=jQuery(document.createElement("button")),settings[s]?p.addClass("enabled").text(L10n.get("settingsOn")):p.text(L10n.get("settingsOff")),p.ariaClick(function(){settings[s]?(jQuery(this).removeClass("enabled").text(L10n.get("settingsOff")),settings[s]=!1):(jQuery(this).addClass("enabled").text(L10n.get("settingsOn")),settings[s]=!0),Setting.save(),t.hasOwnProperty("onChange")&&t.onChange.call({name:s,value:settings[s],default:t.default})});break;case Setting.Types.List:p=jQuery(document.createElement("select"));for(var f=0,h=t.list.length;f<h;++f)jQuery(document.createElement("option")).val(f).text(t.list[f]).appendTo(p);p.val(t.list.indexOf(settings[s])).attr("tabindex",0).on("change",function(){settings[s]=t.list[Number(this.value)],Setting.save(),t.hasOwnProperty("onChange")&&t.onChange.call({name:s,value:settings[s],default:t.default,list:t.list})})}p.attr("id","setting-control-"+u).appendTo(d)}),e.append('<ul class="buttons">'+('<li><button id="settings-ok" class="ui-close">'+L10n.get(["settingsOk","ok"])+"</button></li>")+('<li><button id="settings-reset">'+L10n.get("settingsReset")+"</button></li>")+"</ul>").find("#settings-reset").ariaClick({one:!0},function(){jQuery(document).one("tw:dialogclosed",function(){Setting.reset(),window.location.reload()}),Dialog.close()}),!0}function b(){return jQuery(Dialog.setup(L10n.get("shareTitle"),"share list")).append(s("StoryShare")),!0}var w=null;return Object.freeze(Object.defineProperties({},{init:{value:e},start:{value:t},stow:{value:r},unstow:{value:n},setStoryElements:{value:a},hideOutlines:{value:i},showOutlines:{value:o},assembleLinkList:{value:s},alert:{value:u},jumpto:{value:l},restart:{value:c},saves:{value:d},settings:{value:p},share:{value:f},buildAutoload:{value:h},buildJumpto:{value:g},buildRestart:{value:m},buildSaves:{value:v},buildSettings:{value:y},buildShare:{value:b},isOpen:{value:function(){return Dialog.isOpen.apply(Dialog,arguments)}},body:{value:function(){return Dialog.body()}},setup:{value:function(){return Dialog.setup.apply(Dialog,arguments)}},addClickHandler:{value:function(){return Dialog.addClickHandler.apply(Dialog,arguments)}},open:{value:function(){return Dialog.open.apply(Dialog,arguments)}},close:{value:function(){return Dialog.close.apply(Dialog,arguments)}},resize:{value:function(){return Dialog.resize()}},buildDialogAutoload:{value:h},buildDialogJumpto:{value:g},buildDialogRestart:{value:m},buildDialogSaves:{value:v},buildDialogSettings:{value:y},buildDialogShare:{value:b},buildLinkListFromPassage:{value:s}}))}(),LoadScreen=function(){function e(){jQuery(document).on("readystatechange.SugarCube",function(){if(!(o.size>0)){var e=jQuery(document.documentElement);"complete"===document.readyState?e.hasClass("init-loading")&&(Config.loadDelay>0?setTimeout(function(){return e.removeClass("init-loading")},Math.max(Engine.minDomActionDelay,Config.loadDelay)):e.removeClass("init-loading")):e.addClass("init-loading")}})}function t(){jQuery(document).off("readystatechange.SugarCube"),o.clear(),r()}function r(){jQuery(document.documentElement).removeClass("init-loading")}function n(){jQuery(document.documentElement).addClass("init-loading")}function a(){return++s,o.add(s),n(),s}function i(e){if(null==e)throw new Error("LoadScreen.unlock called with a null or undefined ID");o.has(e)&&o.delete(e),0===o.size&&jQuery(document).trigger("readystatechange")}var o=new Set,s=0;return Object.freeze(Object.defineProperties({},{init:{value:e},clear:{value:t},hide:{value:r},show:{value:n},lock:{value:a},unlock:{value:i}}))}(),version=Object.freeze({title:"SugarCube",major:2,minor:15,patch:0,prerelease:null,build:7847,date:new Date("2017-03-13T14:24:21.491Z"),extensions:{},toString:function(){var e=this.prerelease?"-"+this.prerelease:"";return this.major+"."+this.minor+"."+this.patch+e+"+"+this.build},short:function(){var e=this.prerelease?"-"+this.prerelease:"";return this.title+" (v"+this.major+"."+this.minor+"."+this.patch+e+")"},long:function(){return this.title+" v"+this.toString()+" ("+this.date.toUTCString()+")"}}),TempState={},macros={},postdisplay={},postrender={},predisplay={},prehistory={},prerender={},session=null,settings={},setup={},storage=null,browser=Browser,config=Config,has=Has,History=State,state=State,tale=Story,TempVariables=State.temporary;window.SugarCube={},jQuery(function(){try{var e=LoadScreen.lock();LoadScreen.init(),document.normalize&&document.normalize(),Story.load(),storage=SimpleStore.create(Story.domId,!0),session=SimpleStore.create(Story.domId,!1),Dialog.init(),UI.init(),Story.init(),L10n.init(),session.has("rcWarn")||"cookie"!==storage.name||(session.set("rcWarn",1),window.alert(L10n.get("warningNoWebStorage"))),Save.init(),Setting.init(),Macro.init(),Engine.start(),UI.start(),window.SugarCube={Browser:Browser,Config:Config,Dialog:Dialog,DebugView:DebugView,Engine:Engine,Has:Has,L10n:L10n,Macro:Macro,Passage:Passage,Save:Save,Scripting:Scripting,Setting:Setting,SimpleAudio:SimpleAudio,State:State,Story:Story,UI:UI,Util:Util,Wikifier:Wikifier,macros:macros,session:session,settings:settings,setup:setup,storage:storage,version:version},LoadScreen.unlock(e)}catch(e){return LoadScreen.clear(),Alert.fatal(null,e.message,e)}})}(window,window.document,jQuery);}
+	if(document.documentElement.classList.contains("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 n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),_slicedToArray=function(){function e(e,t){var r=[],n=!0,a=!1,i=undefined;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done)&&(r.push(o.value),!t||r.length!==t);n=!0);}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)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},Alert=function(){function e(e,t,r,n){var a="fatal"===e,i="Apologies! "+(a?"A fatal":"An")+" error has occurred.";i+=a?" 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(/^(?:(?:uncaught\s+(?:exception:\s+)?)?error:\s+)+/i,"")+".":": unknown error."),n&&n.stack&&(i+="\n\nStack Trace:\n"+n.stack),window.alert(i)}function t(t,r,n){e(null,t,r,n)}function r(t,r,n){e("fatal",t,r,n)}return function(e){window.onerror=function(n,a,i,o,s){"complete"===document.readyState?t(null,n,s):(r(null,n,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}}))}();!function(){function e(e,t){var a=String(e);switch(t){case"start":return a&&r.test(a)?a.replace(r,""):a;case"end":return a&&n.test(a)?a.replace(n,""):a;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 n="undefined"==typeof t?"":String(t);for(""===n&&(n=" ");n.length<r;){var a=n.length,i=r-a;n+=a>i?n.slice(0,i):n}return n.length>r&&(n=n.slice(0,r)),n}var r=/^[\s\u00A0\uFEFF][\s\u00A0\uFEFF]*/,n=/[\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 n=this[r];if(t===n||t!==t&&n!==n)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 n=String(this),a=n.length,i=Number.parseInt(e,10);return i<=a?n:t(i-a,r)+n}}),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 n=String(this),a=n.length,i=Number.parseInt(e,10);return i<=a?n:n+t(i-a,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(){if(0===arguments.length)throw new Error("_random called with insufficient parameters");var e=void 0,t=void 0;if(1===arguments.length?(e=0,t=arguments[0]):(e=arguments[0],t=arguments[1]),e>t){var r=[t,e];e=r[0],t=r[1]}return Math.floor(_nativeMathRandom()*(t-e+1))+e}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 n=t+1;if(n>=e.length)throw new Error("high surrogate without trailing low surrogate");var a=e.charCodeAt(n);if(a<56320||a>57343)throw new Error("high surrogate without trailing low surrogate");return{char:e.charAt(t)+e.charAt(n),start:t,end:n}}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,t,r){var n=t,a=r;return 2===arguments.length&&(a=n,n=0),Array.isArray(e)?e.random(n,a):e.hasOwnProperty("length")?[].concat(_toConsumableArray(e)).random(n,a):void 0}}),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,n=0;(r=e.call(this,t,r))!==-1;)++n,++r;return n}}),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[];var e=this.length>>>0;if(0===e)return[];for(var t=Array.prototype.indexOf,r=Array.prototype.push,n=Array.prototype.splice,a=Array.prototype.concat.apply([],arguments),i=[],o=0,s=a.length;o<s;++o)for(var u=a[o],l=0;(l=t.call(this,u,l))!==-1;)r.apply(i,n.call(this,l,1));return i}}),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())),n=[].concat(_toConsumableArray(r)).sort(function(e,t){return t-e}),a=[],i=0,o=r.length;i<o;++i)a[i]=this[r[i]];for(var s=0,u=n.length;s<u;++s)t.call(this,n[s],1);return a}}),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(e,t){if(null==this)throw new TypeError("Array.prototype.pluck called on null or undefined");var r=this.length>>>0;if(0!==r){var n=e,a=t;return 1===arguments.length&&(a=n,n=0),null==n?n=0:n<0?(n=r+n,n<0&&(n=0)):n>=r&&(n=r-1),null==a?a=r-1:a<0?(a=r+a,a<0&&(a=r-1)):a>=r&&(a=r-1),Array.prototype.splice.call(this,_random(n,a),1)[0]}}}),Object.defineProperty(Array.prototype,"random",{configurable:!0,writable:!0,value:function(e,t){if(null==this)throw new TypeError("Array.prototype.random called on null or undefined");var r=this.length>>>0;if(0!==r){var n=e,a=t;return 1===arguments.length&&(a=n,n=0),null==n?n=0:n<0?(n=r+n,n<0&&(n=0)):n>=r&&(n=r-1),null==a?a=r-1:a<0?(a=r+a,a<0&&(a=r-1)):a>=r&&(a=r-1),this[_random(n,a)]}}}),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){for(var t=e-1;t>0;--t){var r=Math.floor(_nativeMathRandom()*(t+1)),n=[this[r],this[t]];this[t]=n[0],this[r]=n[1]}return this}}}),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 n=[],a=0,i=0;i<r.length;++i)n.push(r[i]===undefined?arguments[a++]:r[i]);return t.apply(this,n.concat(e.call(arguments,a)))}}}),Object.defineProperty(Math,"clamp",{configurable:!0,writable:!0,value:function e(t,r,n){var e=Number(t);return Number.isNaN(e)?NaN:e.clamp(r,n)}}),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 n=String(r);return n&&t.test(n)?n.replace(e,"\\$&"):n}})}(),function(){var e=/{(\d+)(?:,([+-]?\d+))?}/g,t=new RegExp(e.source);Object.defineProperty(String,"format",{configurable:!0,writable:!0,value:function(r){function n(e,t,r){if(!t)return e;var n=Math.abs(t)-e.length;if(n<1)return e;var a=String(r).repeat(n);return t<0?e+a:a+e}if(arguments.length<2)return 0===arguments.length?"":r;var a=2===arguments.length&&Array.isArray(arguments[1])?[].concat(_toConsumableArray(arguments[1])):Array.prototype.slice.call(arguments,1);return 0===a.length?r:t.test(r)?(e.lastIndex=0,r.replace(e,function(e,t,r){var i=a[t];if(null==i)return"";for(;"function"==typeof i;)i=i();switch("undefined"==typeof i?"undefined":_typeof(i)){case"string":break;case"object":i=JSON.stringify(i);break;default:i=String(i)}return n(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 String.prototype.indexOf.apply(this,arguments)!==-1}}),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,n=Number(arguments[1])||0,a=0;(n=t.call(this,e,n))!==-1;)++a,n+=r;return a}}),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 n=this.length>>>0;if(0===n)return"";var a=Number(e);Number.isSafeInteger(a)?a<0&&(a+=n,a<0&&(a=0)):a=0,a>n&&(a=n);var i=Number(t);(!Number.isSafeInteger(i)||i<0)&&(i=0);var o=this.slice(0,a);return"undefined"!=typeof r&&(o+=r),a+i<n&&(o+=this.slice(a+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,n=t.end;return n===-1?"":r.toLocaleUpperCase()+e.slice(n+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,n=t.end;return n===-1?"":r.toUpperCase()+e.slice(n+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={userAgent:navigator.userAgent.toLowerCase()};return e.isGecko=navigator&&"Gecko"===navigator.product&&!/webkit|trident/.test(e.userAgent),e.isIE=/msie|trident/.test(e.userAgent)&&!e.userAgent.includes("opera"),e.ieVersion=function(){var t=/(?:msie\s+|rv:)(\d{1,2}\.\d)/.exec(e.userAgent);return t?Number([1]):0}(),e.isOpera=e.userAgent.includes("opera")||e.userAgent.includes(" opr/"),e.operaVersion=function(){var t=new RegExp((/applewebkit|chrome/.test(e.userAgent)?"opr":"version")+"\\/(\\d{1,2}\\.\\d+)"),r=t.exec(e.userAgent);return r?Number(r[1]):0}(),e.isMobile=Object.freeze({Android:/android/.test(e.userAgent),BlackBerry:/blackberry/.test(e.userAgent),iOS:/ip(?:hone|ad|od)/.test(e.userAgent),Windows:/iemobile/.test(e.userAgent),any:function(){var t=e.isMobile;return t.Android||t.BlackBerry||t.iOS||t.Windows}}),Object.freeze(e)}(),Has=function(){function e(e){try{if(null!=e&&e.length>=0){var t="SugarCube.WebStorage.Test",r="1701 Guilty Scott";if(e.setItem(t,r),e.getItem(t)===r)return e.removeItem(t),!0}}catch(e){}return!1}return Object.freeze({audio:"function"==typeof document.createElement("audio").canPlayType,fileAPI:"File"in window&&"FileList"in window&&"FileReader"in window&&!Browser.isMobile.any()&&(!Browser.isOpera||Browser.operaVersion>=15),geolocation:"geolocation"in navigator&&"function"==typeof navigator.geolocation.getCurrentPosition&&"function"==typeof navigator.geolocation.watchPosition,localStorage:"localStorage"in window&&e(window.localStorage),sessionStorage:"sessionStorage"in window&&e(window.sessionStorage)})}(),_ref4=function(){function e(t){if("object"!==("undefined"==typeof t?"undefined":_typeof(t))||null==t)return 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 Array.isArray(t)?r=[]:t instanceof Date?r=new Date(t.getTime()):t instanceof Map?(r=new Map,t.forEach(function(t,n){r.set(n,e(t))})):t instanceof RegExp?r=new RegExp(t):t instanceof Set?(r=new Set,t.forEach(function(t){r.add(e(t))})):r=Object.create(Object.getPrototypeOf(t)),Object.keys(t).forEach(function(n){return r[n]=e(t[n])}),r}function t(e){for(var t=document.createDocumentFragment(),r=document.createElement("p"),n=void 0;null!==(n=e.firstChild);){if(n.nodeType===Node.ELEMENT_NODE){var a=n.nodeName.toUpperCase();switch(a){case"BR":if(null!==n.nextSibling&&n.nextSibling.nodeType===Node.ELEMENT_NODE&&"BR"===n.nextSibling.nodeName.toUpperCase()){e.removeChild(n.nextSibling),e.removeChild(n),t.appendChild(r),r=document.createElement("p");continue}if(!r.hasChildNodes()){e.removeChild(n);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(n);continue}}r.appendChild(n)}r.hasChildNodes()&&t.appendChild(r),e.appendChild(t)}function r(){try{return document.activeElement||null}catch(e){return null}}function n(e,t,r){var n="object"===("undefined"==typeof e?"undefined":_typeof(e))?e:document.getElementById(e);if(null==n)return null;var a=Array.isArray(t)?t:[t];jQuery(n).empty();for(var i=0,o=a.length;i<o;++i)if(Story.has(a[i]))return new Wikifier(n,Story.get(a[i]).processText().trim()),n;if(null!=r){var s=String(r).trim();""!==s&&new Wikifier(n,s)}return n}function a(e,t,r){return jQuery(document.createElement("span")).addClass("error").attr("title",r).text(L10n.get("errorTitle")+": "+(t||"unknown error")).appendTo(e),!1}function i(e,t){switch("undefined"==typeof e?"undefined":_typeof(e)){case"number":if(Number.isNaN(e))return t;break;case"object":if(null===e)return t;if(Array.isArray(e)||e instanceof Set)return[].concat(_toConsumableArray(e)).map(function(e){return i(e,t)}).join(", ");if(e instanceof Map){var r=function(){var r=i,n=[].concat(_toConsumableArray(e)).map(function(e){return r(e[0],t)+" ⇒ "+r(e[1],t)}).join("; ");return{v:"( "+n+" )"}}();if("object"===("undefined"==typeof r?"undefined":_typeof(r)))return r.v}else{if(e instanceof Date)return e.toLocaleString();if("function"==typeof e.toString)return e.toString()}return 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:n},throwError:{value:a},toStringOrDefault:{value:i}}))}(),clone=_ref4.clone,convertBreaks=_ref4.convertBreaks,safeActiveElement=_ref4.safeActiveElement,setPageElement=_ref4.setPageElement,throwError=_ref4.throwError,toStringOrDefault=_ref4.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);t.is("[aria-pressed]")&&t.attr("aria-pressed","true"===t.attr("aria-pressed")?"false":"true"),e.apply(this,arguments)}}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(n,a){if(0===this.length||0===arguments.length)return this;var i=n,o=a;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.fn.extend({wikiWithOptions:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(0===this.length||0===r.length)return this;var a=document.createDocumentFragment();return r.forEach(function(t){return new Wikifier(a,t,e)}),this.append(a),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){var t=void 0;switch("undefined"==typeof 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 r(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 a(e){if(null==e)return"";var t=String(e);return t&&f.test(t)?t.replace(p,function(e){return h[e]}):t}function i(e){if(null==e)return"";var t=String(e);return t&&m.test(t)?t.replace(g,function(e){return v[e]}):t}function o(e){var t=/^([+-]?(?:\d*\.)?\d+)([Mm]?[Ss])$/,r=t.exec(String(e));if(null===r)throw new SyntaxError('invalid time value syntax: "'+e+'"');var n=Number(r[1]);if(/^[Ss]$/.test(r[2])&&(n*=1e3),Number.isNaN(n)||!Number.isFinite(n))throw new RangeError('invalid time value: "'+e+'"');return n}function s(e){if("number"!=typeof e||Number.isNaN(e)||!Number.isFinite(e)){var t=void 0;switch("undefined"==typeof e?"undefined":_typeof(e)){case"string":t='"'+e+'"';break;case"number":t=String(e);break;default:t=Object.prototype.toString.call(e)}throw new Error("invalid milliseconds: "+t)}return e+"ms"}function u(e){if(!e.includes("-"))switch(e){case"bgcolor":return"backgroundColor";case"float":return"cssFloat";default:return e}var t="-ms-"===e.slice(0,4)?e.slice(1):e;return t.split("-").map(function(e,t){return 0===t?e:e.toUpperFirst()}).join("")}function l(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("="),n=_slicedToArray(t,2),a=n[0],i=n[1];r[a]=i});var n=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:""+n+t.search,pathname:n,query:t.search,search:t.search,queries:r,searches:r,hash:t.hash}}function c(e,t){for(var r=Object.prototype.toString,n=Array.isArray(e),a=[].concat(Object.keys(e),Object.keys(t)).sort().filter(function(e,t,r){return 0===t||r[t-1]!==e}),i={},o=void 0,s=function(e){return e===o},u=0,l=a.length;u<l;++u){var c=a[u],d=e[c],p=t[c];if(e.hasOwnProperty(c))if(t.hasOwnProperty(c)){if(d===p)continue;if(("undefined"==typeof d?"undefined":_typeof(d))===("undefined"==typeof p?"undefined":_typeof(p)))if("function"==typeof d)d.toString()!==p.toString()&&(i[c]=[y.Copy,p]);else if("object"!==("undefined"==typeof d?"undefined":_typeof(d))||null===d)i[c]=[y.Copy,p];else{var f=r.call(d),h=r.call(p);if(f===h)if("[object Date]"===f){var g=Number(p);Number(d)!==g&&(i[c]=[y.CopyDate,g])}else if("[object RegExp]"===f)d.toString()!==p.toString()&&(i[c]=[y.Copy,clone(p)]);else{var m=Util.diff(d,p);null!==m&&(i[c]=m)}else i[c]=[y.Copy,clone(p)]}else i[c]=[y.Copy,"object"!==("undefined"==typeof p?"undefined":_typeof(p))||null===p?p:clone(p)]}else if(n&&Util.isNumeric(c)){var v=Number(c);if(!o){o="";do o+="~";while(a.some(s));i[o]=[y.SpliceArray,v,v]}v<i[o][1]&&(i[o][1]=v),v>i[o][2]&&(i[o][2]=v)}else i[c]=y.Delete;else i[c]=[y.Copy,"object"!==("undefined"==typeof p?"undefined":_typeof(p))||null===p?p:clone(p)]}return Object.keys(i).length>0?i:null}function d(e,t){for(var r=Object.keys(t||{}),n=clone(e),a=0,i=r.length;a<i;++a){var o=r[a],s=t[o];if(s===y.Delete)delete n[o];else if(Array.isArray(s))switch(s[0]){case y.SpliceArray:n.splice(s[1],1+(s[2]-s[1]));break;case y.Copy:n[o]=clone(s[1]);break;case y.CopyDate:n[o]=new Date(s[1])}else n[o]=Util.patch(n[o],s)}return n}var p=/[&<>"'`]/g,f=new RegExp(p.source),h=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"}),g=/&(?:amp|lt|gt|quot|apos|#39|#x27|#96|#x60);/g,m=new RegExp(g.source),v=Object.freeze({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&#39;":"'","&#x27;":"'","&#96;":"`","&#x60;":"`"}),y=e({Delete:0,SpliceArray:1,Copy:2,CopyDate:3});return Object.freeze(Object.defineProperties({},{toEnum:{value:e},isNumeric:{value:t},isBoolean:{value:r},slugify:{value:n},escape:{value:a},unescape:{value:i},fromCssTime:{value:o},toCssTime:{value:s},fromCssProperty:{value:u},parseUrl:{value:l},DiffOp:{value:y},diff:{value:c},patch:{value:d},random:{value:Math.random},entityEncode:{value:a},entityDecode:{value:i},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 n(e){f=Math.clamp(e,.2,5),l("rate",f)}function a(){return h}function i(e){h=Math.clamp(e,0,1),l("volume",h)}function o(){l("stop")}function s(e,t){if("function"!=typeof t)throw new Error("callback parameter must be a function");p.set(e,t)}function u(e){p.delete(e)}function l(e,t){p.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 p=new Map,f=1,h=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,n=/\.([^.\/\\]+)$/,a=e.getType,i=[],o=document.createElement("audio");if(t.forEach(function(e){var t=null;switch("undefined"==typeof e?"undefined":_typeof(e)){case"string":var s=void 0;if("data:"===e.slice(0,5)){if(s=r.exec(e),null===s)throw new Error("source data URI missing media type")}else if(s=n.exec(Util.parseUrl(e).pathname),null===s)throw new Error("source URL missing file extension");var u=a(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=a(e.format);null!==l&&(t={src:e.src,type:l});break;default:throw new Error("invalid source value (type: "+("undefined"==typeof e?"undefined":_typeof(e))+")")}if(null!==t){var c=document.createElement("source");c.src=t.src,c.type=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 n=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 n._error=!1}).on("error",function(){return n._error=!0}).find("source:last-of-type").on("error",function(){return n._trigger("error")}),SimpleAudio.subscribe(this,function(e){if(!n.audio)return void SimpleAudio.unsubscribe(n);switch(e){case"mute":n._updateAudioMute();break;case"rate":n._updateAudioRate();break;case"stop":n.stop();break;case"volume":n._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),this.fadeStop(),this.stop();var e=this.audio;for(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.muted=this._mute||SimpleAudio.mute}},{key:"_updateAudioRate",value:function(){this.audio.playbackRate=this._rate*SimpleAudio.rate}},{key:"_updateAudioVolume",value:function(){this.audio.volume=this._volume*SimpleAudio.volume}},{key:"hasSource",value:function(){return this.sources.length>0}},{key:"hasNoData",value:function(){return this.audio.readyState===HTMLMediaElement.HAVE_NOTHING;
+}},{key:"hasMetadata",value:function(){return this.audio.readyState>=HTMLMediaElement.HAVE_METADATA}},{key:"hasSomeData",value:function(){return this.audio.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA}},{key:"hasData",value:function(){return this.audio.readyState===HTMLMediaElement.HAVE_ENOUGH_DATA}},{key:"isFailed",value:function(){return this._error}},{key:"isLoading",value:function(){return this.audio.networkState===HTMLMediaElement.NETWORK_LOADING}},{key:"isPlaying",value:function(){return!(this.audio.ended||this.audio.paused||!this.hasSomeData())}},{key:"isPaused",value:function(){return this.audio.paused&&(this.audio.duration===1/0||this.audio.currentTime>0)&&!this.audio.ended}},{key:"isEnded",value:function(){return 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.loop}},{key:"load",value:function(){"auto"!==this.audio.preload&&(this.audio.preload="auto"),this.isLoading()||this.audio.load()}},{key:"play",value:function(){this.audio.play()}},{key:"pause",value:function(){this.audio.pause()}},{key:"stop",value:function(){this.audio.pause(),this.time=0,this._trigger("aw:stop")}},{key:"fadeWithDuration",value:function(e,t,r){var n=this;this.fadeStop();var a=Math.clamp(null==r?this.volume:r,0,1),i=Math.clamp(t,0,1);a!==i&&(this.volume=a,jQuery(this.audio).off("timeupdate.AudioWrapper:fadeWithDuration").one("timeupdate.AudioWrapper:fadeWithDuration",function(){var t=void 0,r=void 0;a<i?(t=a,r=i):(t=i,r=a);var o=Number(e);o<1&&(o=1);var s=25,u=(i-a)/(o/(s/1e3));n._faderId=setInterval(function(){return n.isPlaying()?(n.volume=Math.clamp(n.volume+u,t,r),0===n.volume&&n.pause(),void(n.volume===i&&(n.fadeStop(),n._trigger("aw:fade")))):void n.fadeStop()},s)}),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("function"!=typeof r)throw new Error("listener parameter must be a function");var n=e._events,a=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(!n.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(n).join(", "));return e.replace(t,n[t])+".AudioWrapperEvent"}).join(" ");if(""===a)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).on(a,r),this}},{key:"one",value:function(t,r){if("function"!=typeof r)throw new Error("listener parameter must be a function");var n=e._events,a=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(!n.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(n).join(", "));return e.replace(t,n[t])+".AudioWrapperEvent"}).join(" ");if(""===a)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).one(a,r),this}},{key:"off",value:function(t,r){if(r&&"function"!=typeof r)throw new Error("listener parameter must be a function");if(!t)return jQuery(this.audio).off(".AudioWrapperEvent",r);var n=e._events,a=t.trim().splitOrEmpty(/\s+/).map(function(e){var t=e.split(".",1)[0];if(t){if(!n.hasOwnProperty(t))throw new Error('unknown event "'+t+'"; valid: '+Object.keys(n).join(", "));return e.replace(t,n[t])+".AudioWrapperEvent"}return e+".AudioWrapperEvent"}).join(" ");if(""===a)throw new Error('invalid eventNames parameter "'+t+'"');return jQuery(this.audio).off(a,r),this}},{key:"duration",get:function(){return this.audio.duration}},{key:"ended",get:function(){return this.audio.ended}},{key:"loop",get:function(){return this.audio.loop},set:function(e){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.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.duration-this.audio.currentTime}},{key:"time",get:function(){return this.audio.currentTime},set:function(e){var t=this;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 n=document.createElement("audio");r[t]=""!==n.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,n=t.toLowerCase(),a=r.hasOwnProperty(n)?r[n]:"audio/"+n;return e._verifyType(a)}},{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:"aw:fade",pause:"pause",play:"playing",rate:"ratechange",seek:"seeked",stop:"aw: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"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("track parameter must be an object");var r=void 0,n=void 0,a=void 0,i=void 0;if(e instanceof m)r=!0,n=e.clone(),a=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,n=r?e.track.clone():e.track,a=e.hasOwnProperty("volume")?e.volume:e.track.volume,i=e.hasOwnProperty("rate")?e.rate:e.track.rate}n.stop(),n.loop=!1,n.mute=!1,n.volume=a,n.rate=i,n.on("end.AudioListEvent",function(){return t._onEnd()}),this.tracks.push({copy:r,track:n,volume:a,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 n=Math.clamp(t,0,1)*this.current.volume,a=void 0;null!=r&&(a=Math.clamp(r,0,1)*this.current.volume),this.current.track.fadeWithDuration(e,n,a),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:n},volume:{get:a,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,n){if(r)return r.create(e,n);for(var a=0;a<t.length;++a)if(t[a].init(e,n))return r=t[a],r.create(e,n);throw new Error("no valid adapters found")}var t=[],r=null;return Object.freeze(Object.defineProperties({},{adapters:{value:t},create:{value:e}}))}();SimpleStore.adapters.push(function(){function e(){return r=Has.localStorage&&Has.sessionStorage}function t(e,t){if(!r)throw new Error("adapter not initialized");return new n(e,t)}var r=!1,n=function(){function e(t,r){_classCallCheck(this,e);var n=t+".",a=null,i=null;r?(a=window.localStorage,i="localStorage"):(a=window.sessionStorage,i="sessionStorage"),Object.defineProperties(this,{_engine:{value:a},_prefix:{value:n},_prefixRe:{value:new RegExp("^"+RegExp.escape(n))},name:{value:i},id:{value:t},persistent:{value:!!r}})}return _createClass(e,[{key:"size",value:function(){return this.keys().length}},{key:"keys",value:function e(){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_?(?: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){return LZString.compressToUTF16(JSON.stringify(e))}},{key:"_deserialize",value:function(e){return JSON.parse(LZString.decompressFromUTF16(e))}}]),e}();return Object.freeze(Object.defineProperties({},{init:{value:e},create:{value:t}}))}()),SimpleStore.adapters.push(function(){function e(e){return n="cookie"in document,n&&r(e),n}function t(e,t){if(!n)throw new Error("adapter not initialized");return new a(e,t)}function r(e){if(""!==document.cookie)for(var t=e+".",r=new RegExp("^"+RegExp.escape(t)),n=e+"!.",i=e+"*.",o=/\.(?:state|rcWarn)$/,s=document.cookie.split(/;\s*/),u=0;u<s.length;++u){var l=s[u].split("="),c=decodeURIComponent(l[0]);if(r.test(c)){var d=decodeURIComponent(l[1]);""!==d&&!function(){var e=!o.test(c);a._setCookie(c,undefined,"Thu, 01 Jan 1970 00:00:00 GMT"),a._setCookie(c.replace(r,function(){return e?n:i}),d,e?"Tue, 19 Jan 2038 03:14:07 GMT":undefined)}()}}}var n=!1,a=function(){function e(t,r){_classCallCheck(this,e);var n=""+t+(r?"!":"*")+".";Object.defineProperties(this,{_prefix:{value:n},_prefixRe:{value:new RegExp("^"+RegExp.escape(n))},name:{value:"cookie"},id:{value:t},persistent:{value:!!r}})}return _createClass(e,[{key:"size",value:function(){return this.keys().length}},{key:"keys",value:function e(){if(""===document.cookie)return[];for(var t=document.cookie.split(/;\s*/),e=[],r=0;r<t.length;++r){var n=t[r].split("="),a=decodeURIComponent(n[0]);if(this._prefixRe.test(a)){var i=decodeURIComponent(n[1]);""!==i&&e.push(a.replace(this._prefixRe,""))}}return e}},{key:"has",value:function(t){return!("string"!=typeof t||!t)&&null!==e._getCookie(this._prefix+t)}},{key:"get",value:function(t){if("string"!=typeof t||!t)return null;var r=e._getCookie(this._prefix+t);return null===r?null:e._deserialize(r)}},{key:"set",value:function(t,r){if("string"!=typeof t||!t)return!1;try{if(e._setCookie(this._prefix+t,e._serialize(r),this.persistent?"Tue, 19 Jan 2038 03:14:07 GMT":undefined),!this.has(t))throw new Error("unknown validation error during set")}catch(e){throw e.message="cookie error: "+e.message,e}return!0}},{key:"delete",value:function(t){if("string"!=typeof t||!t||!this.has(t))return!1;try{if(e._setCookie(this._prefix+t,undefined,"Thu, 01 Jan 1970 00:00:00 GMT"),this.has(t))throw new Error("unknown validation error during delete")}catch(e){throw e.message="cookie error: "+e.message,e}return!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:"_getCookie",value:function(e){if(!e||""===document.cookie)return null;for(var t=document.cookie.split(/;\s*/),r=0;r<t.length;++r){var n=t[r].split("="),a=decodeURIComponent(n[0]);if(e===a){var i=decodeURIComponent(n[1]);return i||null}}return null}},{key:"_setCookie",value:function(e,t,r){if(e){var n=encodeURIComponent(e)+"=";null!=t&&(n+=encodeURIComponent(t)),null!=r&&(n+="; "+r),n+="; path=/",document.cookie=n}}},{key:"_serialize",value:function(e){return LZString.compressToBase64(JSON.stringify(e))}},{key:"_deserialize",value:function(e){return JSON.parse(LZString.decompressFromBase64(e))}}]),e}();return Object.freeze(Object.defineProperties({},{init:{value:e},create:{value:t}}))}());var DebugView=function(){var e=function(){function e(t,r,n,a){_classCallCheck(this,e),Object.defineProperties(this,{parent:{value:t},view:{value:document.createElement("span")},break:{value:document.createElement("wbr")}}),jQuery(this.view).attr({title:a,"aria-label":a,"data-type":null!=r?r:"","data-name":null!=n?n:""}).addClass("debug"),this.parent.appendChild(this.view),this.parent.appendChild(this.break)}return _createClass(e,[{key:"append",value:function(e){return jQuery(this.view).append(e),this}},{key:"modes",value:function(e){var t=this;if(null==e){var r=function(){var e={};return t.view.className.splitOrEmpty(/\s+/).forEach(function(t){"debug"!==t&&(e[t]=!0)}),{v:e}}();if("object"===("undefined"==typeof r?"undefined":_typeof(r)))return r.v}else if("object"===("undefined"==typeof e?"undefined":_typeof(e)))return Object.keys(e).forEach(function(t){this[e[t]?"addClass":"removeClass"](t)},jQuery(this.view)),this;throw new Error("DebugView.prototype.modes options parameter must be an object or null/undefined")}},{key:"remove",value:function(){var e=jQuery(this.view);this.view.hasChildNodes()&&e.contents().appendTo(this.parent),e.remove(),jQuery(this.break).remove()}},{key:"output",get:function(){return this.view}},{key:"type",get:function(){return this.view.getAttribute("data-type")},set:function(e){this.view.setAttribute("data-type",null!=e?e:"")}},{key:"name",get:function(){return this.view.getAttribute("data-name")},set:function(e){this.view.setAttribute("data-name",null!=e?e:"")}},{key:"title",get:function(){return this.view.title},set:function(e){this.view.title=e}}],[{key:"init",value:function(){jQuery('<button id="debug-view-toggle">'+L10n.get("debugViewTitle")+"</button>").ariaClick({label:L10n.get("debugViewToggle")},function(){return e.toggle()}).prependTo("#ui-bar-body"),e.enable()}},{key:"enable",value:function(){jQuery(document.documentElement).addClass("debug-view"),jQuery.event.trigger("tw:debugviewupdate")}},{key:"disable",value:function(){jQuery(document.documentElement).removeClass("debug-view"),jQuery.event.trigger("tw:debugviewupdate")}},{key:"toggle",value:function(){jQuery(document.documentElement).toggleClass("debug-view"),jQuery.event.trigger("tw:debugviewupdate")}}]),e}();return e}(),PRNGWrapper=function(){var e=function(){function e(t,r){_classCallCheck(this,e),Object.defineProperties(this,new Math.seedrandom(t,r,function(e,t){return{_prng:{value:e},seed:{writable:!0,value:t},pull:{writable:!0,value:0},random:{value:function(){return++this.pull,this._prng()}}}}))}return _createClass(e,null,[{key:"marshal",value:function(e){if(!e||!e.hasOwnProperty("seed")||!e.hasOwnProperty("pull"))throw new Error("PRNG is missing required data");return{seed:e.seed,pull:e.pull}}},{key:"unmarshal",value:function(t){if(!t||!t.hasOwnProperty("seed")||!t.hasOwnProperty("pull"))throw new Error("PRNG object is missing required data");for(var r=new e(t.seed,!1),n=t.pull;n>0;--n)r.random();return r}}]),e}();return e}(),StyleWrapper=function(){var e=/\[[<>]?[Ii][Mm][Gg]\[(?:\s|\S)*?\]\]+/g,t=new RegExp(e.source),r=function(){function r(e){if(_classCallCheck(this,r),null==e)throw new TypeError("StyleWrapper style parameter must be an HTMLStyleElement object");Object.defineProperties(this,{style:{value:e}})}return _createClass(r,[{key:"isEmpty",value:function(){return 0===this.style.cssRules.length}},{key:"set",value:function(e){this.clear(),this.add(e)}},{key:"add",value:function(r){var n=r;t.test(n)&&(e.lastIndex=0,n=n.replace(e,function(e){var t=Wikifier.helpers.parseSquareBracketedMarkup({source:e,matchStart:0});if(t.hasOwnProperty("error")||t.pos<e.length)return e;var r=t.source;if("data:"!==r.slice(0,5)&&Story.has(r)){var n=Story.get(r);n.tags.includes("Twine.image")&&(r=n.text)}return'url("'+r.replace(/"/g,"%22")+'")'})),this.style.styleSheet?this.style.styleSheet.cssText+=n:this.style.appendChild(document.createTextNode(n))}},{key:"clear",value:function(){this.style.styleSheet?this.style.styleSheet.cssText="":jQuery(this.style).empty()}}]),r}();return r}(),L10n=function(){function e(){r()}function t(e,t){if(!e)return"";var r=function(e){var t=void 0;return e.some(function(e){return!!l10nStrings.hasOwnProperty(e)&&(t=e,!0)}),t}(Array.isArray(e)?e:[e]);if(!r)return"";for(var i=50,o=l10nStrings[r],s=0;a.test(o);){if(++s>i)throw new Error("L10n.get exceeded maximum replacement iterations, probable infinite loop");n.lastIndex=0,o=o.replace(n,function(e){var r=e.slice(1,-1);return t&&t.hasOwnProperty(r)?t[r]:l10nStrings.hasOwnProperty(r)?l10nStrings[r]:void 0})}return o}function r(){strings&&Object.keys(strings).length>0&&Object.keys(l10nStrings).forEach(function(e){try{var t=void 0;switch(e){case"identity":t=strings.identity;break;case"aborting":t=strings.aborting;break;case"cancel":t=strings.cancel;break;case"close":t=strings.close;break;case"ok":t=strings.ok;break;case"errorTitle":t=strings.errors.title;break;case"errorNonexistentPassage":t=strings.errors.nonexistentPassage;break;case"errorSaveMissingData":t=strings.errors.saveMissingData;break;case"errorSaveIdMismatch":t=strings.errors.saveIdMismatch;break;case"warningDegraded":t=strings.warnings.degraded;break;case"debugViewTitle":t=strings.debugView.title;break;case"debugViewToggle":t=strings.debugView.toggle;break;case"uiBarToggle":t=strings.uiBar.toggle;break;case"uiBarBackward":t=strings.uiBar.backward;break;case"uiBarForward":t=strings.uiBar.forward;break;case"uiBarJumpto":t=strings.uiBar.jumpto;break;case"jumptoTitle":t=strings.jumpto.title;break;case"jumptoTurn":t=strings.jumpto.turn;break;case"jumptoUnavailable":t=strings.jumpto.unavailable;break;case"savesTitle":t=strings.saves.title;break;case"savesDisallowed":t=strings.saves.disallowed;break;case"savesEmptySlot":t=strings.saves.emptySlot;break;case"savesIncapable":t=strings.saves.incapable;break;case"savesLabelAuto":t=strings.saves.labelAuto;break;case"savesLabelDelete":t=strings.saves.labelDelete;break;case"savesLabelExport":t=strings.saves.labelExport;break;case"savesLabelImport":t=strings.saves.labelImport;break;case"savesLabelLoad":t=strings.saves.labelLoad;break;case"savesLabelClear":t=strings.saves.labelClear;break;case"savesLabelSave":t=strings.saves.labelSave;break;case"savesLabelSlot":t=strings.saves.labelSlot;break;case"savesSavedOn":t=strings.saves.savedOn;break;case"savesUnavailable":t=strings.saves.unavailable;break;case"savesUnknownDate":t=strings.saves.unknownDate;break;case"settingsTitle":t=strings.settings.title;break;case"settingsOff":t=strings.settings.off;break;case"settingsOn":t=strings.settings.on;break;case"settingsReset":t=strings.settings.reset;break;case"restartTitle":t=strings.restart.title;break;case"restartPrompt":t=strings.restart.prompt;break;case"shareTitle":t=strings.share.title;break;case"autoloadTitle":t=strings.autoload.title;break;case"autoloadCancel":t=strings.autoload.cancel;break;case"autoloadOk":t=strings.autoload.ok;break;case"autoloadPrompt":t=strings.autoload.prompt;break;case"macroBackText":t=strings.macros.back.text;break;case"macroReturnText":t=strings.macros.return.text}t&&(l10nStrings[e]=t.replace(/%\w+%/g,function(e){return"{"+e.slice(1,-1)+"}"}))}catch(e){}})}var n=/\{\w+\}/g,a=new RegExp(n.source);return Object.freeze(Object.defineProperties({},{init:{value:e},get:{value:t}}))}(),strings={errors:{},warnings:{},debugView:{},uiBar:{},jumpto:{},saves:{},settings:{},restart:{},share:{},autoload:{},macros:{back:{},return:{}}},l10nStrings={identity:"game",aborting:"Aborting",cancel:"Cancel",close:"Close",ok:"OK",errorTitle:"Error",errorNonexistentPassage:'the passage "{passage}" does not exist',errorSaveMissingData:"save is missing required data. Either the loaded file is not a save or the save has become corrupted",errorSaveIdMismatch:"save is from the wrong {identity}",_warningIntroLacking:"Your browser either lacks or has disabled",_warningOutroDegraded:", so this {identity} is running in a degraded mode. You may be able to continue, however, some parts may not work properly.",warningNoWebStorage:"{_warningIntroLacking} the Web Storage API{_warningOutroDegraded}",warningDegraded:"{_warningIntroLacking} some of the capabilities required by this {identity}{_warningOutroDegraded}",debugViewTitle:"Debug View",debugViewToggle:"Toggle the debug view",uiBarToggle:"Toggle the UI bar",uiBarBackward:"Go backward within the {identity} history",uiBarForward:"Go forward within the {identity} history",uiBarJumpto:"Jump to a specific point within the {identity} history",jumptoTitle:"Jump To",jumptoTurn:"Turn",jumptoUnavailable:"No jump points currently available…",savesTitle:"Saves",savesDisallowed:"Saving has been disallowed on this passage.",savesEmptySlot:"— slot empty —",savesIncapable:"{_warningIntroLacking} the capabilities required to support saves, so saves have been disabled for this session.",savesLabelAuto:"Autosave",savesLabelDelete:"Delete",savesLabelExport:"Save to Disk…",savesLabelImport:"Load from Disk…",savesLabelLoad:"Load",savesLabelClear:"Delete All",savesLabelSave:"Save",savesLabelSlot:"Slot",savesSavedOn:"Saved on",savesUnavailable:"No save slots found…",savesUnknownDate:"unknown",settingsTitle:"Settings",settingsOff:"Off",settingsOn:"On",settingsReset:"Reset to Defaults",restartTitle:"Restart",restartPrompt:"Are you sure that you want to restart? Unsaved progress will be lost.",shareTitle:"Share",autoloadTitle:"Autoload",autoloadCancel:"Go to start",autoloadOk:"Load autosave",autoloadPrompt:"An autosave exists. Load it now or go to the start?",macroBackText:"Back",macroReturnText:"Return"},Config=function(){function e(){throw new Error("Config.history.mode has been deprecated and is no longer used by SugarCube, please remove it from your code")}function t(){throw new Error("Config.history.tracking has been deprecated, use Config.history.maxStates instead")}var r=Object.seal({debug:!1,addVisitedLinkClass:!1,cleanupWikifierOutput:!1,loadDelay:0,history:Object.seal({controls:!0,maxStates:100,get mode(){e()},set mode(t){e()},get tracking(){t()},set tracking(e){t()}}),macros:Object.seal({ifAssignmentError:!0,maxLoopIterations:1e3}),navigation:Object.seal({override:undefined}),passages:Object.seal({descriptions:undefined,displayTitles:!1,start:undefined,transitionOut:undefined}),saves:Object.seal({autoload:undefined,autosave:undefined,id:"untitled-story",isAllowed:undefined,onLoad:undefined,onSave:undefined,slots:8,version:undefined}),ui:Object.seal({stowBarInitially:800,updateStoryElements:!0}),transitionEndEventName:function(){for(var e=new Map([["transition","transitionend"],["MSTransition","msTransitionEnd"],["WebkitTransition","webkitTransitionEnd"],["MozTransition","transitionend"]]),t=[].concat(_toConsumableArray(e.keys())),r=document.createElement("div"),n=0;n<t.length;++n)if(r.style[t[n]]!==undefined)return e.get(t[n]);return""}()});return r}(),Patterns=function(){var e=/[\u0150\u0170]/g.test("Ő"),t="[\\s\\u00A0\\u2028\\u2029]",r="[0-9A-Z_a-z\\-\\u00C0-\\u00D6\\u00D8-\\u00DE\\u00DF-\\u00F6\\u00F8-\\u00FF"+(e?"\\u0150\\u0170\\u0151\\u0171":"")+"]",n=r.replace("\\-",""),a="[$A-Z_a-z]",i=a+"[$0-9A-Z_a-z]*",o="[$_]",s=o+i,u="[A-Za-z][\\w-]*|[=-]",l="("+r+"+)\\(([^\\)\\|\\n]+)\\):",c="("+r+"+):([^;\\|\\n]+);",d="((?:\\."+r+"+)+);",p="((?:#"+r+"+)+);",f=l+"|"+c+"|"+d+"|"+p,h="(?:file|https?|mailto|ftp|javascript|irc|news|data):[^\\s'\"]+";return Object.freeze({space:t,anyLetter:r,anyLetterStrict:n,identifierFirstChar:a,identifier:i,variableSigil:o,variable:s,macroName:u,inlineCss:f,url:h})}(),Scripting=function(){function addAccessibleClickHandler(e,t,r,n,a){if(arguments.length<2)throw new Error("addAccessibleClickHandler insufficient number of parameters");var i=void 0,o=void 0;if("function"==typeof t?(i=t,o={namespace:n,one:!!r}):(i=r,o={namespace:a,one:!!n,selector:t}),"function"!=typeof i)throw new TypeError("addAccessibleClickHandler handler parameter must be a function");return jQuery(e).ariaClick(o,i)}function insertElement(e,t,r,n,a,i){var o=jQuery(document.createElement(t));return r&&o.attr("id",r),n&&o.addClass(n),i&&o.attr("title",i),a&&o.text(a),e&&o.appendTo(e),o[0]}function insertText(e,t){jQuery(e).append(document.createTextNode(t))}function removeChildren(e){jQuery(e).empty()}function removeElement(e){jQuery(e).remove()}function fade(e,t){function r(){i+=.05*a,n(o,Math.easeInOut(i)),(1===a&&i>=1||a===-1&&i<=0)&&(e.style.visibility="in"===t.fade?"visible":"hidden",o.parentNode.replaceChild(e,o),o=null,window.clearInterval(s),t.onComplete&&t.onComplete())}function n(e,t){e.style.zoom=1,e.style.filter="alpha(opacity="+Math.floor(100*t)+")",e.style.opacity=t}var a="in"===t.fade?1:-1,i=void 0,o=e.cloneNode(!0),s=void 0;e.parentNode.replaceChild(o,e),"in"===t.fade?(i=0,o.style.visibility="visible"):i=1,n(o,i),s=window.setInterval(r,25)}function scrollWindowTo(e,t){function r(){c+=i,window.scroll(0,o+l*(u*Math.easeInOut(c))),c>=1&&window.clearInterval(d)}function n(e){for(var t=0;e.offsetParent;)t+=e.offsetTop,e=e.offsetParent;return t}function a(e){var t=n(e),r=t+e.offsetHeight,a=window.scrollY?window.scrollY:document.body.scrollTop,i=window.innerHeight?window.innerHeight:document.body.clientHeight,o=a+i;return t>=a&&r>o&&e.offsetHeight<i?t-(i-e.offsetHeight)+20:t}var i=null!=t?Number(t):.1;Number.isNaN(i)||!Number.isFinite(i)||i<0?i=.1:i>1&&(i=1);var o=window.scrollY?window.scrollY:document.body.scrollTop,s=a(e),u=Math.abs(o-s),l=o>s?-1:1,c=0,d=void 0;d=window.setInterval(r,25)}function either(){if(0!==arguments.length)return Array.prototype.concat.apply([],arguments).random()}function hasVisited(){if(0===arguments.length)throw new Error("hasVisited called with insufficient parameters");if(State.isEmpty())return!1;for(var e=Array.prototype.concat.apply([],arguments),t=State.passages,r=0,n=e.length;r<n;++r)if(!t.includes(e[r]))return!1;return!0}function lastVisited(){if(0===arguments.length)throw new Error("lastVisited called with insufficient parameters");if(State.isEmpty())return-1;for(var e=Array.prototype.concat.apply([],arguments),t=State.passages,r=t.length-1,n=State.turns,a=0,i=e.length;a<i&&n>-1;++a){var o=t.lastIndexOf(e[a]);n=Math.min(n,o===-1?-1:r-o)}return n}function passage(){return State.passage}function previous(){var e=State.passages;if(arguments.length>0){var t=Number(arguments[0]);if(!Number.isSafeInteger(t)||t<1)throw new RangeError("previous offset parameter must be a positive integer greater than zero");return e.length>t?e[e.length-1-t]:""}for(var r=e.length-2;r>=0;--r)if(e[r]!==State.passage)return e[r];return""}function random(){if(0===arguments.length)throw new Error("random called with insufficient parameters");var e=void 0,t=void 0;if(1===arguments.length?(e=0,t=arguments[0]):(e=arguments[0],t=arguments[1]),e>t){var r=[t,e];e=r[0],t=r[1]}return Math.floor(State.random()*(t-e+1))+e}function randomFloat(){if(0===arguments.length)throw new Error("randomFloat called with insufficient parameters");var e=void 0,t=void 0;if(1===arguments.length?(e=0,t=arguments[0]):(e=arguments[0],t=arguments[1]),e>t){var r=[t,e];e=r[0],t=r[1]}return State.random()*(t-e)+e}function tags(){if(0===arguments.length)return Story.get(State.passage).tags.slice(0);for(var e=Array.prototype.concat.apply([],arguments),t=[],r=0,n=e.length;r<n;++r)t=t.concat(Story.get(e[r]).tags);return t}function time(){return null===Engine.lastPlay?0:Date.now()-Engine.lastPlay}function turns(){return State.turns}function variables(){return State.variables}function visited(){if(State.isEmpty())return 0;for(var e=Array.prototype.concat.apply([],0===arguments.length?[State.passage]:arguments),t=State.passages,r=State.turns,n=0,a=e.length;n<a&&r>0;++n)r=Math.min(r,t.count(e[n]));return r}function visitedTags(){if(0===arguments.length)throw new Error("visitedTags called with insufficient parameters");if(State.isEmpty())return 0;for(var e=Array.prototype.concat.apply([],arguments),t=e.length,r=State.passages,n=new Map,a=0,i=0,o=r.length;i<o;++i){var s=r[i];if(n.has(s))n.get(s)&&++a;else{var u=Story.get(s).tags;if(u.length>0){for(var l=0,c=0;c<t;++c)u.includes(e[c])&&++l;l===t?(++a,n.set(s,!0)):n.set(s,!1)}}}return a}function evalJavaScript(code,output){return function(code,output){return eval(code)}.call(output?{output:output}:null,String(code),output)}function evalTwineScript(code,output){return function(code,output){return eval(code)}.call(output?{
+output:output}:null,parse(String(code)),output)}var _ref7=function(){function e(e){return e.reduce(function(e,t){return e=e.then(t)},Promise.resolve())}function t(e){return Util.parseUrl(e).path.replace(/^[^\w]+|[^\w]+$/g,"").replace(/[^\w]+/g,"-").toLocaleLowerCase()}function r(){function r(e){return new Promise(function(r,n){jQuery(document.createElement("script")).one("load abort error",function(e){jQuery(e.target).off(),"load"===e.type?r(e.target):n(e.target)}).appendTo(document.head).attr({id:"script-imported-"+t(e),type:"text/javascript",src:e})})}for(var n=arguments.length,a=Array(n),i=0;i<n;i++)a[i]=arguments[i];return Promise.all(a.map(function(t){return Array.isArray(t)?e(t.map(function(e){return function(){return r(e)}})):r(t)}))}function n(){function r(e){return new Promise(function(r,n){jQuery(document.createElement("link")).one("load abort error",function(e){jQuery(e.target).off(),"load"===e.type?r(e.target):n(e.target)}).appendTo(document.head).attr({id:"style-imported-"+t(e),rel:"stylesheet",href:e})})}for(var n=arguments.length,a=Array(n),i=0;i<n;i++)a[i]=arguments[i];return Promise.all(a.map(function(t){return Array.isArray(t)?e(t.map(function(e){return function(){return r(e)}})):r(t)}))}return{importScripts:r,importStyles:n}}(),importScripts=_ref7.importScripts,importStyles=_ref7.importStyles,parse=function(){function e(e){if(0!==r.lastIndex)throw new RangeError("Scripting.parse last index is non-zero at start");for(var a=e,i=void 0;null!==(i=r.exec(a));)if(i[5]){var o=i[5];if("$"===o||"_"===o)continue;if(n.test(o))o=o[0];else if("is"===o){var s=r.lastIndex,u=a.slice(s);/^\s+not\b/.test(u)&&(a=a.splice(s,u.search(/\S/)),o="isnot")}t.hasOwnProperty(o)&&(a=a.splice(i.index,o.length,t[o]),r.lastIndex+=t[o].length-o.length)}return a}var t=Object.freeze({$:"State.variables.",_:"State.temporary.",to:"=",eq:"==",neq:"!=",is:"===",isnot:"!==",gt:">",gte:">=",lt:"<",lte:"<=",and:"&&",or:"||",not:"!",def:'"undefined" !== typeof',ndef:'"undefined" === typeof'}),r=new RegExp(["(\"\"|'')",'("(?:\\\\.|[^"\\\\])+")',"('(?:\\\\.|[^'\\\\])+')","([=+\\-*\\/%<>&\\|\\^~!?:,;\\(\\)\\[\\]{}]+)","([^\"'=+\\-*\\/%<>&\\|\\^~!?:,;\\(\\)\\[\\]{}\\s]+)"].join("|"),"g"),n=new RegExp("^"+Patterns.variable);return e}();return Object.freeze(Object.defineProperties({},{parse:{value:parse},evalJavaScript:{value:evalJavaScript},evalTwineScript:{value:evalTwineScript}}))}(),Wikifier=function(){var e=void 0,t=0,r=function(){function r(n,a,i){_classCallCheck(this,r),"object"!==("undefined"==typeof e?"undefined":_typeof(e))&&r.compileFormatters(),Object.defineProperties(this,{source:{value:String(a)},options:{writable:!0,value:Object.assign({profile:"all"},i)},nextMatch:{writable:!0,value:0},output:{writable:!0,value:null},_rawArgs:{writable:!0,value:""}}),null==n?this.output=document.createDocumentFragment():n.jquery?this.output=n[0]:this.output=n;try{++t,this.subWikify(this.output),1===t&&Config.cleanupWikifierOutput&&convertBreaks(this.output)}finally{--t}}return _createClass(r,[{key:"subWikify",value:function(e,t,r){var n=this.output,a=void 0;this.output=e,null!=r&&"object"===("undefined"==typeof r?"undefined":_typeof(r))&&(a=this.options,this.options=Object.assign({},this.options,r));var i=t?new RegExp("(?:"+t+")",this.options.ignoreTerminatorCase?"gim":"gm"):null,o=void 0,s=void 0;do{if(this.formatter.formatterRegExp.lastIndex=this.nextMatch,i&&(i.lastIndex=this.nextMatch),s=this.formatter.formatterRegExp.exec(this.source),o=i?i.exec(this.source):null,o&&(!s||o.index<=s.index))return o.index>this.nextMatch&&this.outputText(this.output,this.nextMatch,o.index),this.matchStart=o.index,this.matchLength=o[0].length,this.matchText=o[0],this.nextMatch=i.lastIndex,this.output=n,void(a&&(this.options=a));if(s){s.index>this.nextMatch&&this.outputText(this.output,this.nextMatch,s.index),this.matchStart=s.index,this.matchLength=s[0].length,this.matchText=s[0],this.nextMatch=this.formatter.formatterRegExp.lastIndex;for(var u=void 0,l=1,c=s.length;l<c;++l)if(s[l]){u=l-1;break}if(this.formatter.formatters[u].handler(this),null!=TempState.break)break}}while(o||s);null==TempState.break?this.nextMatch<this.source.length&&(this.outputText(this.output,this.nextMatch,this.source.length),this.nextMatch=this.source.length):this.output.lastChild&&this.output.lastChild.nodeType===Node.ELEMENT_NODE&&"BR"===this.output.lastChild.nodeName.toUpperCase()&&jQuery(this.output.lastChild).remove(),this.output=n,a&&(this.options=a)}},{key:"outputText",value:function(e,t,r){jQuery(e).append(document.createTextNode(this.source.substring(t,r)))}},{key:"rawArgs",value:function(){return this._rawArgs}},{key:"fullArgs",value:function(){return Scripting.parse(this.rawArgs())}},{key:"formatter",get:function(){if(!e.hasOwnProperty(this.options.profile))throw new Error('nonexistent formatter profile "'+this.options.profile+'"');return e[this.options.profile]}}],[{key:"compileFormatters",value:function(){var t=r.formatters,n=t.filter(function(e){return!Array.isArray(e.profiles)||e.profiles.includes("core")});return e={all:{formatters:t,formatterRegExp:new RegExp(t.map(function(e){return"("+e.match+")"}).join("|"),"gm")},core:{formatters:n,formatterRegExp:new RegExp(n.map(function(e){return"("+e.match+")"}).join("|"),"gm")}}}},{key:"getValue",value:function(e){var t=r.parseStoryVariable(e),n=void 0;if(null!==t){n=t.store;for(var a=t.names,i=0,o=a.length;i<o;++i){if("undefined"==typeof n[a[i]]){n=undefined;break}n=n[a[i]]}}return n}},{key:"setValue",value:function(e,t){var n=r.parseStoryVariable(e);if(null!==n){for(var a=n.names,i=a.pop(),o=n.store,s=0,u=a.length;s<u;++s){if("undefined"==typeof o[a[s]]){o=undefined;break}o=o[a[s]]}if(o!==undefined)return o[i]=t,!0}return!1}},{key:"parseStoryVariable",value:function(e){for(var t={store:"$"===e[0]?State.variables:State.temporary,names:[]},n=e,a=void 0;null!==(a=r._parseVarRegExp.exec(n));)n=n.slice(a[0].length),a[1]?t.names.push(a[1]):a[2]?t.names.push(a[2]):a[3]?t.names.push(a[3]):a[4]?t.names.push(a[4]):a[5]?t.names.push(r.getValue(a[5])):a[6]&&t.names.push(Number(a[6]));return""===n?t:null}},{key:"wikifyEval",value:function(e){var t=document.createDocumentFragment();new r(t,e);var n=t.querySelector(".error");if(null!==n)throw new Error(n.textContent.replace(/^(?:(?:Uncaught\s+)?Error:\s+)+/,""));return t}},{key:"createInternalLink",value:function(e,t,r,n){var a=jQuery(document.createElement("a"));return null!=t&&(a.attr("data-passage",t),Story.has(t)?(a.addClass("link-internal"),Config.addVisitedLinkClass&&State.hasPlayed(t)&&a.addClass("link-visited")):a.addClass("link-broken"),a.ariaClick({one:!0},function(){"function"==typeof n&&n(),Engine.play(t)})),r&&a.append(document.createTextNode(r)),e&&a.appendTo(e),a[0]}},{key:"createExternalLink",value:function(e,t,r){var n=jQuery(document.createElement("a")).attr("target","_blank").addClass("link-external").text(r).appendTo(e);return null!=t&&n.attr({href:t,tabindex:0}),n[0]}},{key:"isExternalLink",value:function(e){if(Story.has(e))return!1;var t=new RegExp("^"+Patterns.url,"gim");return t.test(e)||/[\/.?#]/.test(e)}}]),r}();return Object.defineProperties(r,{_parseVarRegExp:{value:new RegExp(["^(?:",Patterns.variableSigil,"(",Patterns.identifier,")|\\.(",Patterns.identifier,")|\\[(?:(?:\"((?:\\\\.|[^\"\\\\])+)\")|(?:'((?:\\\\.|[^'\\\\])+)')|(",Patterns.variableSigil,Patterns.identifierFirstChar,".*)|(\\d+))\\])"].join(""))},helpers:{value:{}},parse:{value:Scripting.parse},evalExpression:{value:Scripting.evalTwineScript},evalStatements:{value:Scripting.evalTwineScript},textPrimitives:{value:Patterns}}),Object.defineProperties(r.helpers,{inlineCss:{value:function(){function e(e){var r={classes:[],id:"",styles:{}},n=void 0;do{t.lastIndex=e.nextMatch;var a=t.exec(e.source);n=a&&a.index===e.nextMatch,n&&(a[1]?r.styles[Util.fromCssProperty(a[1])]=a[2].trim():a[3]?r.styles[Util.fromCssProperty(a[3])]=a[4].trim():a[5]?r.classes=r.classes.concat(a[5].slice(1).split(/\./)):a[6]&&(r.id=a[6].slice(1).split(/#/).pop()),e.nextMatch=t.lastIndex)}while(n);return r}var t=new RegExp(Patterns.inlineCss,"gm");return e}()},evalText:{value:function(e){var t=void 0;try{t=Scripting.evalTwineScript(e),null==t||"function"==typeof t?t=e:(t=String(t),/\[(?:object(?:\s+[^\]]+)?|native\s+code)\]/.test(t)&&(t=e))}catch(r){t=e}return t}},evalPassageId:{value:function(e){return null==e||Story.has(e)?e:r.helpers.evalText(e)}},hasBlockContext:{value:function(e){for(var t="function"==typeof window.getComputedStyle,r=e.length-1;r>=0;--r){var n=e[r];switch(n.nodeType){case Node.ELEMENT_NODE:var a=n.nodeName.toUpperCase();if("BR"===a)return!0;var i=t?window.getComputedStyle(n,null):n.currentStyle;if(i&&i.display){if("none"===i.display)continue;return"block"===i.display}switch(a){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":return!0}return!1;case Node.COMMENT_NODE:continue;default:return!1}}return!0}},createShadowSetterCallback:{value:function(){function e(){if(!a&&(a=r.formatters.find(function(e){return"macro"===e.name}),!a))throw new Error('cannot find "macro" formatter');return a}function t(){for(var t=a||e(),r=new Set,n=t.context;null!==n;n=n.parent)n._shadows&&n._shadows.forEach(function(e){return r.add(e)});return[].concat(_toConsumableArray(r))}function n(e){var r={};return t().forEach(function(e){var t=e.slice(1),n="$"===e[0]?State.variables:State.temporary;r[e]=n[t]}),function(){var t=Object.keys(r),n=t.length>0?{}:null;try{return t.forEach(function(e){var t=e.slice(1),a="$"===e[0]?State.variables:State.temporary;a.hasOwnProperty(t)&&(n[t]=a[t]),a[t]=r[e]}),Scripting.evalJavaScript(e)}finally{t.forEach(function(e){var t=e.slice(1),a="$"===e[0]?State.variables:State.temporary;r[e]=a[t],n.hasOwnProperty(t)?a[t]=n[t]:delete a[t]})}}}var a=null;return n}()},parseSquareBracketedMarkup:{value:function(e){function t(){return d>=e.source.length?u:e.source[d++]}function r(){return d>=e.source.length?u:e.source[d]}function n(t){return t<1||d+t>=e.source.length?u:e.source[d+t]}function a(){return{error:String.format.apply(String,arguments),pos:d}}function i(){c=d}function o(t){var r=e.source.slice(c,d).trim();if(""===r)throw new Error("malformed wiki "+(h?"link":"image")+", empty "+t+" component");"link"===t&&"~"===r[0]?(l.forceInternal=!0,l.link=r.slice(1)):l[t]=r,c=d}function s(e){++d;e:for(;;){switch(r()){case"\\":++d;var t=r();if(t!==u&&"\n"!==t)break;case u:case"\n":return u;case e:break e}++d}return d}var u=-1,l={},c=e.matchStart,d=c+1,p=void 0,f=void 0,h=void 0,g=void 0;if(g=r(),"["===g)h=l.isLink=!0;else{switch(h=!1,g){case"<":l.align="left",++d;break;case">":l.align="right",++d}if(!/^[Ii][Mm][Gg]$/.test(e.source.slice(d,d+3)))return a("malformed square-bracketed wiki markup");d+=3,l.isImage=!0}if("["!==t())return a("malformed wiki {0}",h?"link":"image");p=1,f=0,i();try{e:for(;;){switch(g=r()){case u:case"\n":return a("unterminated wiki {0}",h?"link":"image");case'"':if(s(g)===u)return a("unterminated double quoted string in wiki {0}",h?"link":"image");break;case"'":if((4===f||3===f&&h)&&s(g)===u)return a("unterminated single quoted string in wiki {0}",h?"link":"image");break;case"|":0===f&&(o(h?"text":"title"),++c,f=1);break;case"-":0===f&&">"===n(1)&&(o(h?"text":"title"),++d,c+=2,f=1);break;case"<":0===f&&"-"===n(1)&&(o(h?"link":"source"),++d,c+=2,f=2);break;case"[":if(f===-1)return a("unexpected left square bracket '['");++p,1===p&&(i(),++c);break;case"]":if(--p,0===p){switch(f){case 0:case 1:o(h?"link":"source"),f=3;break;case 2:o(h?"text":"title"),f=3;break;case 3:h?(o("setter"),f=-1):(o("link"),f=4);break;case 4:o("setter"),f=-1}if(++d,"]"===r()){++d;break e}--d}}++d}}catch(e){return a(e.message)}return l.pos=d,l}}}),Object.defineProperty(r,"formatters",{value:[{name:"macro",profiles:["core"],match:"<<",lookahead:new RegExp("<<(\\/?"+Patterns.macroName+")(?:\\s*)((?:(?:\"(?:\\\\.|[^\"\\\\])*\")|(?:'(?:\\\\.|[^'\\\\])*')|(?:\\[(?:[<>]?[Ii][Mm][Gg])?\\[[^\\r\\n]*?\\]\\]+)|[^>]|(?:>(?!>)))*)>>","gm"),argsPattern:["(``)","`((?:\\\\.|[^`\\\\])+)`","(\"\"|'')",'("(?:\\\\.|[^"\\\\])+")',"('(?:\\\\.|[^'\\\\])+')","(\\[(?:[<>]?[Ii][Mm][Gg])?\\[[^\\r\\n]*?\\]\\]+)","([^`\"'\\s]+)","(`|\"|')"].join("|"),working:{source:"",name:"",arguments:"",index:0},context:null,handler:function(e){var t=this.lookahead.lastIndex=e.matchStart;if(this.parseTag(e)){var r=e.nextMatch,n=this.working.source,a=this.working.name,i=this.working.arguments,o=void 0;try{if(o=Macro.get(a),!o){if(Macro.tags.has(a)){var s=Macro.tags.get(a);return throwError(e.output,"child tag <<"+a+">> was found outside of a call to its parent macro"+(1===s.length?"":"s")+" <<"+s.join(">>, <<")+">>",e.source.slice(t,e.nextMatch))}return throwError(e.output,"macro <<"+a+">> does not exist",e.source.slice(t,e.nextMatch))}var u=null;if(o.hasOwnProperty("tags")&&(u=this.parseBody(e,o),!u))return e.nextMatch=r,throwError(e.output,"cannot find a closing tag for macro <<"+a+">>",e.source.slice(t,e.nextMatch)+"…");if("function"!=typeof o.handler)return throwError(e.output,"macro <<"+a+">> handler function "+(o.hasOwnProperty("handler")?"is not a function":"does not exist"),e.source.slice(t,e.nextMatch));var l=u?u[0].args:this.createArgs(i,o.hasOwnProperty("skipArgs")&&!!o.skipArgs||o.hasOwnProperty("skipArg0")&&!!o.skipArg0);if(o.hasOwnProperty("_MACRO_API")){this.context=new MacroContext({parent:this.context,macro:o,name:a,args:l,payload:u,parser:e,source:n});try{o.handler.call(this.context)}finally{this.context=this.context.parent}}else{var c=e._rawArgs;e._rawArgs=i,o.handler(e.output,a,l,e,u),e._rawArgs=c}}catch(r){return throwError(e.output,"cannot execute "+(o&&o.isWidget?"widget":"macro")+" <<"+a+">>: "+r.message,e.source.slice(t,e.nextMatch))}finally{this.working.source="",this.working.name="",this.working.arguments="",this.working.index=0}}else e.outputText(e.output,e.matchStart,e.nextMatch)},parseTag:function(e){var t=this.lookahead.exec(e.source);return!(!t||t.index!==e.matchStart||!t[1])&&(e.nextMatch=this.lookahead.lastIndex,this.working.source=e.source.slice(t.index,this.lookahead.lastIndex),this.working.name=t[1],this.working.arguments=t[2],this.working.index=t.index,!0)},parseBody:function(e,t){for(var r=this.working.name,n="/"+r,a="end"+r,i=!!Array.isArray(t.tags)&&t.tags,o=[],s=t.hasOwnProperty("skipArgs")&&t.skipArgs,u=t.hasOwnProperty("skipArg0")&&t.skipArg0,l=-1,c=1,d=this.working.source,p=this.working.name,f=this.working.arguments,h=e.nextMatch;(e.matchStart=e.source.indexOf(this.match,e.nextMatch))!==-1;)if(this.parseTag(e)){var g=this.working.source,m=this.working.name,v=this.working.arguments,y=this.working.index,b=e.nextMatch;switch(m){case r:++c;break;case a:case n:--c;break;default:if(1===c&&i)for(var w=0,k=i.length;w<k;++w)m===i[w]&&(o.push({source:d,name:p,arguments:f,args:this.createArgs(f,s||0===o.length&&u),contents:e.source.slice(h,y)}),d=g,p=m,f=v,h=b)}if(0===c){o.push({source:d,name:p,arguments:f,args:this.createArgs(f,s||0===o.length&&u),contents:e.source.slice(h,y)}),l=b;break}}else this.lookahead.lastIndex=e.nextMatch=e.matchStart+this.match.length;return l!==-1?(e.nextMatch=l,o):null},createArgs:function(e,t){var r=t?[]:this.parseArgs(e);return Object.defineProperties(r,{raw:{value:e},full:{value:Scripting.parse(e)}}),r},parseArgs:function(e){for(var t=new RegExp(this.argsPattern,"gm"),n=[],a=new RegExp("^"+Patterns.variable),i=void 0;null!==(i=t.exec(e));){var o=void 0;if(i[1])o=undefined;else if(i[2]){o=i[2];try{o=Scripting.evalTwineScript(o)}catch(e){throw new Error('unable to parse macro argument "'+o+'": '+e.message)}}else if(i[3])o="";else if(i[4]){o=i[4];try{o=Scripting.evalJavaScript(o)}catch(e){throw new Error("unable to parse macro argument '"+o+"': "+e.message)}}else if(i[5]){o=i[5];try{o=Scripting.evalJavaScript(o)}catch(e){throw new Error('unable to parse macro argument "'+o+'": '+e.message)}}else if(i[6]){o=i[6];var s=r.helpers.parseSquareBracketedMarkup({source:o,matchStart:0});if(s.hasOwnProperty("error"))throw new Error('unable to parse macro argument "'+o+'": '+s.error);if(s.pos<o.length)throw new Error('unable to parse macro argument "'+o+'": unexpected character(s) "'+o.slice(s.pos)+'" (pos: '+s.pos+")");s.isLink?(o={isLink:!0},o.count=s.hasOwnProperty("text")?2:1,o.link=r.helpers.evalPassageId(s.link),o.text=s.hasOwnProperty("text")?r.helpers.evalText(s.text):o.link,o.external=!s.forceInternal&&r.isExternalLink(o.link),o.setFn=s.hasOwnProperty("setter")?r.helpers.createShadowSetterCallback(Scripting.parse(s.setter)):null):s.isImage&&(o=function(e){var t={source:e,isImage:!0};if("data:"!==e.slice(0,5)&&Story.has(e)){var r=Story.get(e);r.tags.includes("Twine.image")&&(t.source=r.text,t.passage=r.title)}return t}(r.helpers.evalPassageId(s.source)),s.hasOwnProperty("align")&&(o.align=s.align),s.hasOwnProperty("title")&&(o.title=r.helpers.evalText(s.title)),s.hasOwnProperty("link")&&(o.link=r.helpers.evalPassageId(s.link),o.external=!s.forceInternal&&r.isExternalLink(o.link)),o.setFn=s.hasOwnProperty("setter")?r.helpers.createShadowSetterCallback(Scripting.parse(s.setter)):null)}else if(i[7])if(o=i[7],a.test(o))o=r.getValue(o);else if(/^(?:settings|setup)[.[]/.test(o))try{o=Scripting.evalTwineScript(o)}catch(e){throw new Error('unable to parse macro argument "'+o+'": '+e.message)}else if("null"===o)o=null;else if("undefined"===o)o=undefined;else if("true"===o)o=!0;else if("false"===o)o=!1;else{var u=Number(o);Number.isNaN(u)||(o=u)}else if(i[8]){var l=void 0;switch(i[8]){case"`":l="backtick expression";break;case'"':l="double quoted string";break;case"'":l="single quoted string"}throw new Error("unterminated "+l+" in macro argument string")}n.push(o)}return n}},{name:"prettyLink",profiles:["core"],match:"\\[\\[[^[]",handler:function(e){var t=r.helpers.parseSquareBracketedMarkup(e);if(t.hasOwnProperty("error"))return void e.outputText(e.output,e.matchStart,e.nextMatch);e.nextMatch=t.pos;var n=r.helpers.evalPassageId(t.link),a=t.hasOwnProperty("text")?r.helpers.evalText(t.text):n,i=t.hasOwnProperty("setter")?r.helpers.createShadowSetterCallback(Scripting.parse(t.setter)):null,o=(Config.debug?new DebugView(e.output,"wiki-link","[[link]]",e.source.slice(e.matchStart,e.nextMatch)):e).output;t.forceInternal||!r.isExternalLink(n)?r.createInternalLink(o,n,a,i):r.createExternalLink(o,n,a)}},{name:"urlLink",profiles:["core"],match:Patterns.url,handler:function(e){e.outputText(r.createExternalLink(e.output,e.matchText),e.matchStart,e.nextMatch)}},{name:"image",profiles:["core"],match:"\\[[<>]?[Ii][Mm][Gg]\\[",handler:function(e){var t=r.helpers.parseSquareBracketedMarkup(e);if(t.hasOwnProperty("error"))return void e.outputText(e.output,e.matchStart,e.nextMatch);e.nextMatch=t.pos;var n=void 0;Config.debug&&(n=new DebugView(e.output,"wiki-image",t.hasOwnProperty("link")?"[img[][link]]":"[img[]]",e.source.slice(e.matchStart,e.nextMatch)),n.modes({block:!0}));var a=t.hasOwnProperty("setter")?r.helpers.createShadowSetterCallback(Scripting.parse(t.setter)):null,i=(Config.debug?n:e).output,o=void 0;if(t.hasOwnProperty("link")){var s=r.helpers.evalPassageId(t.link);i=t.forceInternal||!r.isExternalLink(s)?r.createInternalLink(i,s,null,a):r.createExternalLink(i,s),i.classList.add("link-image")}if(i=jQuery(document.createElement("img")).appendTo(i).get(0),o=r.helpers.evalPassageId(t.source),"data:"!==o.slice(0,5)&&Story.has(o)){var u=Story.get(o);u.tags.includes("Twine.image")&&(i.setAttribute("data-passage",u.title),o=u.text)}i.src=o,t.hasOwnProperty("title")&&(i.title=r.helpers.evalText(t.title)),t.hasOwnProperty("align")&&(i.align=t.align)}},{name:"monospacedByBlock",profiles:["block"],match:"^\\{\\{\\{\\n",lookahead:/^\{\{\{\n((?:^[^\n]*\n)+?)(^\}\}\}$\n?)/gm,handler:function(e){this.lookahead.lastIndex=e.matchStart;var t=this.lookahead.exec(e.source);t&&t.index===e.matchStart&&(jQuery(document.createElement("pre")).text(t[1]).appendTo(e.output),e.nextMatch=this.lookahead.lastIndex)}},{name:"formatByChar",profiles:["core"],match:"''|//|__|\\^\\^|~~|==|\\{\\{\\{",handler:function(e){switch(e.matchText){case"''":e.subWikify(jQuery(document.createElement("strong")).appendTo(e.output).get(0),"''");break;case"//":e.subWikify(jQuery(document.createElement("em")).appendTo(e.output).get(0),"//");break;case"__":e.subWikify(jQuery(document.createElement("u")).appendTo(e.output).get(0),"__");break;case"^^":e.subWikify(jQuery(document.createElement("sup")).appendTo(e.output).get(0),"\\^\\^");break;case"~~":e.subWikify(jQuery(document.createElement("sub")).appendTo(e.output).get(0),"~~");break;case"==":e.subWikify(jQuery(document.createElement("s")).appendTo(e.output).get(0),"==");break;case"{{{":var t=/\{\{\{((?:.|\n)*?)\}\}\}/gm;t.lastIndex=e.matchStart;var r=t.exec(e.source);r&&r.index===e.matchStart&&(jQuery(document.createElement("code")).text(r[1]).appendTo(e.output),e.nextMatch=t.lastIndex)}}},{name:"customStyle",profiles:["core"],match:"@@",terminator:"@@",blockRegExp:/\s*\n/gm,handler:function(e){var t=r.helpers.inlineCss(e);this.blockRegExp.lastIndex=e.nextMatch;var n=this.blockRegExp.exec(e.source),a=n&&n.index===e.nextMatch,i=jQuery(document.createElement(a?"div":"span")).appendTo(e.output);0===t.classes.length&&""===t.id&&0===Object.keys(t.styles).length?i.addClass("marked"):(t.classes.forEach(function(e){return i.addClass(e)}),""!==t.id&&i.attr("id",t.id),i.css(t.styles)),a?(e.nextMatch+=n[0].length,e.subWikify(i[0],"\\n?"+this.terminator)):e.subWikify(i[0],this.terminator)}},{name:"verbatimText",profiles:["core"],match:'"{3}|<nowiki>',lookahead:/(?:"{3}((?:.|\n)*?)"{3})|(?:<nowiki>((?:.|\n)*?)<\/nowiki>)/gm,handler:function(e){this.lookahead.lastIndex=e.matchStart;var t=this.lookahead.exec(e.source);t&&t.index===e.matchStart&&(jQuery(document.createElement("span")).addClass("verbatim").text(t[1]||t[2]).appendTo(e.output),e.nextMatch=this.lookahead.lastIndex)}},{name:"horizontalRule",profiles:["core"],match:"^----+$\\n?|<hr\\s*/?>\\n?",handler:function(e){jQuery(document.createElement("hr")).appendTo(e.output)}},{name:"emdash",profiles:["core"],match:"--",handler:function(e){jQuery(document.createTextNode("—")).appendTo(e.output)}},{name:"doubleDollarSign",profiles:["core"],match:"\\${2}",handler:function(e){jQuery(document.createTextNode("$")).appendTo(e.output)}},{name:"nakedVariable",profiles:["core"],match:Patterns.variable+"(?:(?:\\."+Patterns.identifier+")|(?:\\[\\d+\\])|(?:\\[\"(?:\\\\.|[^\"\\\\])+\"\\])|(?:\\['(?:\\\\.|[^'\\\\])+'\\])|(?:\\["+Patterns.variable+"\\]))*",handler:function(e){var t=toStringOrDefault(r.getValue(e.matchText),null);null===t?jQuery(document.createTextNode(e.matchText)).appendTo(e.output):new r((Config.debug?new DebugView(e.output,"variable",e.matchText,e.matchText):e).output,t)}},{name:"heading",profiles:["block"],match:"^!{1,6}",terminator:"\\n",handler:function(e){return r.helpers.hasBlockContext(e.output.childNodes)?void e.subWikify(jQuery(document.createElement("h"+e.matchLength)).appendTo(e.output).get(0),this.terminator):void jQuery(e.output).append(document.createTextNode(e.matchText))}},{name:"table",profiles:["block"],match:"^\\|(?:[^\\n]*)\\|(?:[fhck]?)$",lookahead:/^\|([^\n]*)\|([fhck]?)$/gm,rowTerminator:"\\|(?:[cfhk]?)$\\n?",cellPattern:"(?:\\|([^\\n\\|]*)\\|)|(\\|[cfhk]?$\\n?)",cellTerminator:"(?:\\u0020*)\\|",rowTypes:{c:"caption",f:"tfoot",h:"thead","":"tbody"},handler:function(e){if(!r.helpers.hasBlockContext(e.output.childNodes))return void jQuery(e.output).append(document.createTextNode(e.matchText));var t=jQuery(document.createElement("table")).appendTo(e.output).get(0),n=[],a=null,i=null,o=0,s=void 0;e.nextMatch=e.matchStart;do{this.lookahead.lastIndex=e.nextMatch;var u=this.lookahead.exec(e.source);if(s=u&&u.index===e.nextMatch){var l=u[2];"k"===l?(t.className=u[1],e.nextMatch+=u[0].length+1):(l!==a&&(a=l,i=jQuery(document.createElement(this.rowTypes[l])).appendTo(t)),"c"===a?(i.css("caption-side",0===o?"top":"bottom"),e.nextMatch+=1,e.subWikify(i[0],this.rowTerminator)):this.rowHandler(e,jQuery(document.createElement("tr")).appendTo(i).get(0),n),++o)}}while(s)},rowHandler:function(e,t,n){var a=this,i=new RegExp(this.cellPattern,"gm"),o=0,s=1,u=void 0;do{i.lastIndex=e.nextMatch;var l=i.exec(e.source);if(u=l&&l.index===e.nextMatch){if("~"===l[1]){var c=n[o];c&&(++c.rowCount,c.$element.attr("rowspan",c.rowCount).css("vertical-align","middle")),e.nextMatch=l.index+l[0].length-1}else if(">"===l[1])++s,e.nextMatch=l.index+l[0].length-1;else{if(l[2]){e.nextMatch=l.index+l[0].length;break}!function(){++e.nextMatch;for(var i=r.helpers.inlineCss(e),u=!1,l=!1,c=void 0;" "===e.source.substr(e.nextMatch,1);)u=!0,++e.nextMatch;"!"===e.source.substr(e.nextMatch,1)?(c=jQuery(document.createElement("th")).appendTo(t),++e.nextMatch):c=jQuery(document.createElement("td")).appendTo(t),n[o]={rowCount:1,$element:c},s>1&&(c.attr("colspan",s),s=1),e.subWikify(c[0],a.cellTerminator)," "===e.matchText.substr(e.matchText.length-2,1)&&(l=!0),i.classes.forEach(function(e){return c.addClass(e)}),""!==i.id&&c.attr("id",i.id),u&&l?i.styles["text-align"]="center":u?i.styles["text-align"]="right":l&&(i.styles["text-align"]="left"),c.css(i.styles),e.nextMatch=e.nextMatch-1}()}++o}}while(u)}},{name:"list",profiles:["block"],match:"^(?:(?:\\*+)|(?:#+))",lookahead:/^(?:(\*+)|(#+))/gm,terminator:"\\n",handler:function(e){if(!r.helpers.hasBlockContext(e.output.childNodes))return void jQuery(e.output).append(document.createTextNode(e.matchText));e.nextMatch=e.matchStart;var t=[e.output],n=null,a=0,i=void 0,o=void 0;do{this.lookahead.lastIndex=e.nextMatch;var s=this.lookahead.exec(e.source);if(i=s&&s.index===e.nextMatch){var u=s[2]?"ol":"ul",l=s[0].length;if(e.nextMatch+=s[0].length,l>a)for(o=a;o<l;++o)t.push(jQuery(document.createElement(u)).appendTo(t[t.length-1]).get(0));else if(l<a)for(o=a;o>l;--o)t.pop();else l===a&&u!==n&&(t.pop(),t.push(jQuery(document.createElement(u)).appendTo(t[t.length-1]).get(0)));a=l,n=u,e.subWikify(jQuery(document.createElement("li")).appendTo(t[t.length-1]).get(0),this.terminator)}}while(i)}},{name:"quoteByBlock",profiles:["block"],match:"^<<<\\n",terminator:"^<<<\\n",handler:function(e){return r.helpers.hasBlockContext(e.output.childNodes)?void e.subWikify(jQuery(document.createElement("blockquote")).appendTo(e.output).get(0),this.terminator):void jQuery(e.output).append(document.createTextNode(e.matchText))}},{name:"quoteByLine",profiles:["block"],match:"^>+",lookahead:/^>+/gm,terminator:"\\n",handler:function(e){if(!r.helpers.hasBlockContext(e.output.childNodes))return void jQuery(e.output).append(document.createTextNode(e.matchText));var t=[e.output],n=0,a=e.matchLength,i=void 0,o=void 0;do{if(a>n)for(o=n;o<a;++o)t.push(jQuery(document.createElement("blockquote")).appendTo(t[t.length-1]).get(0));else if(a<n)for(o=n;o>a;--o)t.pop();n=a,e.subWikify(t[t.length-1],this.terminator),jQuery(document.createElement("br")).appendTo(t[t.length-1]),this.lookahead.lastIndex=e.nextMatch;var s=this.lookahead.exec(e.source);i=s&&s.index===e.nextMatch,i&&(a=s[0].length,e.nextMatch+=s[0].length)}while(i)}},{name:"html",profiles:["core"],match:"<[Hh][Tt][Mm][Ll]>",lookahead:/<[Hh][Tt][Mm][Ll]>((?:.|\n)*?)<\/[Hh][Tt][Mm][Ll]>/gm,handler:function(e){this.lookahead.lastIndex=e.matchStart;var t=this.lookahead.exec(e.source);t&&t.index===e.matchStart&&(e.nextMatch=this.lookahead.lastIndex,jQuery(document.createDocumentFragment()).append(t[1]).appendTo(e.output))}},{name:"commentByBlock",profiles:["core"],match:"(?:/(?:%|\\*))|(?:<!--)",lookahead:/(?:\/(%|\*)(?:(?:.|\n)*?)\1\/)|(?:<!--(?:(?:.|\n)*?)-->)/gm,handler:function(e){this.lookahead.lastIndex=e.matchStart;var t=this.lookahead.exec(e.source);t&&t.index===e.matchStart&&(e.nextMatch=this.lookahead.lastIndex)}},{name:"lineContinuation",profiles:["core"],match:"\\\\"+Patterns.space+"*?(?:\\n|$)|(?:^|\\n)"+Patterns.space+"*?\\\\",handler:function(e){e.nextMatch=e.matchStart+e.matchLength}},{name:"lineBreak",profiles:["core"],match:"\\n|<br\\s*/?>",handler:function(e){e.options.nobr||jQuery(document.createElement("br")).appendTo(e.output)}},{name:"htmlCharacterReference",profiles:["core"],match:"(?:(?:&#?[0-9A-Za-z]{2,8};|.)(?:&#?(?:x0*(?:3[0-6][0-9A-Fa-f]|1D[C-Fc-f][0-9A-Fa-f]|20[D-Fd-f][0-9A-Fa-f]|FE2[0-9A-Fa-f])|0*(?:76[89]|7[7-9][0-9]|8[0-7][0-9]|761[6-9]|76[2-7][0-9]|84[0-3][0-9]|844[0-7]|6505[6-9]|6506[0-9]|6507[0-1]));)+|&#?[0-9A-Za-z]{2,8};)",handler:function(e){jQuery(document.createDocumentFragment()).append(e.matchText).appendTo(e.output)}},{name:"htmlTag",profiles:["core"],match:"<\\w+(?:\\s+[^\\u0000-\\u001F\\u007F-\\u009F\\s\"'>\\/=]+(?:\\s*=\\s*(?:\"[^\"]*?\"|'[^']*?'|[^\\s\"'=<>`]+))?)*\\s*\\/?>",tagPattern:"<(\\w+)",voidElements:["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],nobrElements:["colgroup","datalist","dl","figure","ol","optgroup","select","table","tbody","tfoot","thead","tr","ul"],handler:function(e){var t=new RegExp(this.tagPattern).exec(e.matchText),r=t&&t[1],n=r&&r.toLowerCase();if(n){var a=this.voidElements.includes(n),i=this.nobrElements.includes(n),o=void 0,s=void 0;if(!a){o="<\\/"+n+"\\s*>";var u=new RegExp(o,"gim");u.lastIndex=e.matchStart,s=u.exec(e.source)}if(a||s){var l=e.output,c=document.createElement(e.output.tagName),d=void 0;for(c.innerHTML=e.matchText;c.firstChild;)c=c.firstChild;c.hasAttribute("data-passage")&&(this.processDataAttributes(c),Config.debug&&(d=new DebugView(e.output,"html-"+n,n,e.matchText),d.modes({block:"img"===n,nonvoid:s}),l=d.output)),s&&(e.subWikify(c,o,{ignoreTerminatorCase:!0,nobr:i}),d&&jQuery(c).find(".debug.block").length>0&&d.modes({block:!0})),l.appendChild(c)}else throwError(e.output,'HTML tag "'+r+'" is not closed',e.matchText+"…")}},processDataAttributes:function(e){var t=e.getAttribute("data-passage");if(null!=t){var n=r.helpers.evalPassageId(t);n!==t&&(t=n,e.setAttribute("data-passage",n)),""!==t&&("IMG"===e.tagName.toUpperCase()?"data:"!==t.slice(0,5)&&Story.has(t)&&(t=Story.get(t),t.tags.includes("Twine.image")&&(e.src=t.text.trim())):!function(){var n=e.getAttribute("data-setter"),a=void 0;null!=n&&(n=String(n).trim(),""!==n&&(a=r.helpers.createShadowSetterCallback(Scripting.parse(n)))),Story.has(t)?(e.classList.add("link-internal"),Config.addVisitedLinkClass&&State.hasPlayed(t)&&e.classList.add("link-visited")):e.classList.add("link-broken"),jQuery(e).ariaClick({one:!0},function(){"function"==typeof a&&a.call(this),Engine.play(t)})}())}}}]}),r}(),Macro=function(){function e(t,r,a){if(Array.isArray(t))return void t.forEach(function(t){return e(t,r,a)});if(!p.test(t))throw new Error('invalid macro name "'+t+'"');if(n(t))throw new Error("cannot clobber existing macro <<"+t+">>");if(u(t))throw new Error("cannot clobber child tag <<"+t+">> of parent macro"+(1===d[t].length?"":"s")+" <<"+d[t].join(">>, <<")+">>");try{if("object"===("undefined"==typeof r?"undefined":_typeof(r)))c[t]=a?clone(r):r;else{if(!n(r))throw new Error("cannot create alias of nonexistent macro <<"+r+">>");c[t]=a?clone(c[r]):c[r]}Object.defineProperty(c,t,{writable:!1}),c[t]._MACRO_API=!0}catch(e){throw"TypeError"===e.name?new Error("cannot clobber protected macro <<"+t+">>"):new Error("unknown error when attempting to add macro <<"+t+">>: ["+e.name+"] "+e.message)}if(c[t].hasOwnProperty("tags"))if(null==c[t].tags)o(t);else{if(!Array.isArray(c[t].tags))throw new Error('bad value for "tags" property of macro <<'+t+">>");o(t,c[t].tags)}}function t(e){if(Array.isArray(e))return void e.forEach(function(e){return t(e)});if(n(e)){c[e].hasOwnProperty("tags")&&s(e);try{Object.defineProperty(c,e,{writable:!0}),delete c[e]}catch(t){throw new Error("unknown error removing macro <<"+e+">>: "+t.message)}}else if(u(e))throw new Error("cannot remove child tag <<"+e+">> of parent macro <<"+d[e]+">>")}function r(){return 0===Object.keys(c).length}function n(e){return c.hasOwnProperty(e);
+}function a(e){var t=null;return n(e)&&"function"==typeof c[e].handler?t=c[e]:macros.hasOwnProperty(e)&&"function"==typeof macros[e].handler&&(t=macros[e]),t}function i(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"init";Object.keys(c).forEach(function(t){"function"==typeof c[t][e]&&c[t][e](t)}),Object.keys(macros).forEach(function(t){"function"==typeof macros[t][e]&&macros[t][e](t)})}function o(e,t){if(!e)throw new Error("no parent specified");for(var r=["/"+e,"end"+e],a=[].concat(r,Array.isArray(t)?t:[]),i=0;i<a.length;++i){var o=a[i];if(n(o))throw new Error("cannot register tag for an existing macro");u(o)?d[o].includes(e)||(d[o].push(e),d[o].sort()):d[o]=[e]}}function s(e){if(!e)throw new Error("no parent specified");Object.keys(d).forEach(function(t){var r=d[t].indexOf(e);r!==-1&&(1===d[t].length?delete d[t]:d[t].splice(r,1))})}function u(e){return d.hasOwnProperty(e)}function l(e){return u(e)?d[e]:null}var c={},d={},p=new RegExp("^(?:"+Patterns.macroName+")$");return Object.freeze(Object.defineProperties({},{add:{value:e},delete:{value:t},isEmpty:{value:r},has:{value:n},get:{value:a},init:{value:i},tags:{value:Object.freeze(Object.defineProperties({},{register:{value:o},unregister:{value:s},has:{value:u},get:{value:l}}))},evalStatements:{value:function(){return Scripting.evalJavaScript.apply(Scripting,arguments)}}}))}(),MacroContext=function(){var e=function(){function e(t){_classCallCheck(this,e);var r=Object.assign({parent:null,macro:null,name:"",args:null,payload:null,parser:null,source:""},t);if(null===r.macro||""===r.name||null===r.parser)throw new TypeError("context object missing required properties");Object.defineProperties(this,{parent:{value:r.parent},self:{value:r.macro},name:{value:r.name},args:{value:r.args},payload:{value:r.payload},source:{value:r.source},parser:{value:r.parser},_output:{value:r.parser.output},_shadows:{writable:!0,value:null},_debugView:{writable:!0,value:null},_debugViewEnabled:{writable:!0,value:Config.debug}})}return _createClass(e,[{key:"contextHas",value:function(e){for(var t=this;null!==(t=t.parent);)if(e(t))return!0;return!1}},{key:"contextSelect",value:function(e){for(var t=this;null!==(t=t.parent);)if(e(t))return t;return null}},{key:"contextSelectAll",value:function(e){for(var t=[],r=this;null!==(r=r.parent);)e(r)&&t.push(r);return t}},{key:"addShadow",value:function(){var e=this;this._shadows||(this._shadows=new Set);for(var t=new RegExp("^"+Patterns.variable+"$"),r=arguments.length,n=Array(r),a=0;a<r;a++)n[a]=arguments[a];n.flatten().forEach(function(r){if("string"!=typeof r)throw new TypeError("variable name must be a string; type: "+("undefined"==typeof r?"undefined":_typeof(r)));if(!t.test(r))throw new Error('invalid variable name "'+r+'"');e._shadows.add(r)})}},{key:"createShadowWrapper",value:function(e,t,r){var n=void 0;return"function"==typeof e&&(n={},this.shadowView.forEach(function(e){var t=e.slice(1),r="$"===e[0]?State.variables:State.temporary;n[e]=r[t]})),function(){for(var a=this,i=arguments.length,o=Array(i),s=0;s<i;s++)o[s]=arguments[s];"function"==typeof r&&r.apply(this,o),"function"==typeof e&&!function(){var t=Object.keys(n),r=t.length>0?{}:null;try{t.forEach(function(e){var t=e.slice(1),a="$"===e[0]?State.variables:State.temporary;a.hasOwnProperty(t)&&(r[t]=a[t]),a[t]=n[e]}),e.apply(a,o)}finally{t.forEach(function(e){var t=e.slice(1),a="$"===e[0]?State.variables:State.temporary;n[e]=a[t],r.hasOwnProperty(t)?a[t]=r[t]:delete a[t]})}}(),"function"==typeof t&&t.apply(this,o)}}},{key:"createDebugView",value:function(e,t){return this._debugView=new DebugView(this._output,"macro",e?e:this.name,t?t:this.source),null!==this.payload&&this.payload.length>0&&this._debugView.modes({nonvoid:!0}),this._debugViewEnabled=!0,this._debugView}},{key:"removeDebugView",value:function(){null!==this._debugView&&(this._debugView.remove(),this._debugView=null),this._debugViewEnabled=!1}},{key:"error",value:function(e,t){return throwError(this._output,"<<"+this.name+">>: "+e,t?t:this.source)}},{key:"output",get:function(){return this._debugViewEnabled?this.debugView.output:this._output}},{key:"shadows",get:function(){return[].concat(_toConsumableArray(this._shadows))}},{key:"shadowView",get:function(){var e=new Set;return this.contextSelectAll(function(e){return e._shadows}).forEach(function(t){return t._shadows.forEach(function(t){return e.add(t)})}),[].concat(_toConsumableArray(e))}},{key:"debugView",get:function(){return this._debugViewEnabled?null!==this._debugView?this._debugView:this.createDebugView():null}}]),e}();return e}();!function(){Macro.add("capture",{skipArgs:!0,tags:null,handler:function(){if(0===this.args.raw.length)return this.error("no story/temporary variable list specified");var e={};try{for(var t=new RegExp("("+Patterns.variable+")","g"),r=void 0;null!==(r=t.exec(this.args.raw));){var n=r[1],a=n.slice(1),i="$"===n[0]?State.variables:State.temporary;i.hasOwnProperty(a)&&(e[a]=i[a]),this.addShadow(n)}new Wikifier(this.output,this.payload[0].contents)}finally{this.shadows.forEach(function(t){var r=t.slice(1),n="$"===t[0]?State.variables:State.temporary;e.hasOwnProperty(r)?n[r]=e[r]:delete n[r]})}}}),Macro.add("set",{skipArgs:!0,handler:function(){if(0===this.args.full.length)return this.error("no expression specified");try{Scripting.evalJavaScript(this.args.full)}catch(e){return this.error("bad evaluation: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}Config.debug&&this.debugView.modes({hidden:!0})}}),Macro.add("unset",{skipArgs:!0,handler:function(){if(0===this.args.full.length)return this.error("no story/temporary variable list specified");for(var e=new RegExp("State\\.(variables|temporary)\\.("+Patterns.identifier+")","g"),t=void 0;null!==(t=e.exec(this.args.full));){var r=State[t[1]],n=t[2];r.hasOwnProperty(n)&&delete r[n]}Config.debug&&this.debugView.modes({hidden:!0})}}),Macro.add("remember",{skipArgs:!0,handler:function(){if(0===this.args.full.length)return this.error("no expression specified");try{Scripting.evalJavaScript(this.args.full)}catch(e){return this.error("bad evaluation: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}for(var e=storage.get("remember")||{},t=new RegExp("State\\.variables\\.("+Patterns.identifier+")","g"),r=void 0;null!==(r=t.exec(this.args.full));){var n=r[1];e[n]=State.variables[n]}return storage.set("remember",e)?void(Config.debug&&this.debugView.modes({hidden:!0})):this.error("unknown error, cannot remember: "+this.args.raw)},init:function(){var e=storage.get("remember");e&&Object.keys(e).forEach(function(t){return State.variables[t]=e[t]})}}),Macro.add("forget",{skipArgs:!0,handler:function(){if(0===this.args.full.length)return this.error("no story variable list specified");for(var e=storage.get("remember"),t=new RegExp("State\\.variables\\.("+Patterns.identifier+")","g"),r=void 0,n=!1;null!==(r=t.exec(this.args.full));){var a=r[1];State.variables.hasOwnProperty(a)&&delete State.variables[a],e&&e.hasOwnProperty(a)&&(n=!0,delete e[a])}return n&&!storage.set("remember",e)?this.error("unknown error, cannot update remember store"):void(Config.debug&&this.debugView.modes({hidden:!0}))}}),Macro.add("run","set"),Macro.add("script",{skipArgs:!0,tags:null,handler:function(){var e=document.createDocumentFragment();try{Scripting.evalJavaScript(this.payload[0].contents,e),Config.debug&&this.createDebugView(this.name,this.source+this.payload[0].contents+"<</"+this.name+">>")}catch(e){return this.error("bad evaluation: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e),this.source+this.payload[0].contents+"<</"+this.name+">>")}e.hasChildNodes()&&this.output.appendChild(e)}}),Macro.add("include",{handler:function(){if(0===this.args.length)return this.error("no passage specified");var e=void 0;if(e="object"===_typeof(this.args[0])?this.args[0].link:this.args[0],!Story.has(e))return this.error('passage "'+e+'" does not exist');Config.debug&&this.debugView.modes({block:!0}),e=Story.get(e);var t=void 0;t=this.args[1]?jQuery(document.createElement(this.args[1])).addClass(e.domId+" macro-"+this.name).attr("data-passage",e.title).appendTo(this.output):jQuery(this.output),t.wiki(e.processText())}}),Macro.add("nobr",{skipArgs:!0,tags:null,handler:function(){new Wikifier(this.output,this.payload[0].contents.replace(/^\n+|\n+$/g,"").replace(/\n+/g," "))}}),Macro.add(["print","=","-"],{skipArgs:!0,handler:function(){if(0===this.args.full.length)return this.error("no expression specified");try{var e=toStringOrDefault(Scripting.evalJavaScript(this.args.full),null);null!==e&&new Wikifier(this.output,"-"===this.name?Util.escape(e):e)}catch(e){return this.error("bad evaluation: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}}}),Macro.add("silently",{skipArgs:!0,tags:null,handler:function(){var e=document.createDocumentFragment();if(new Wikifier(e,this.payload[0].contents.trim()),Config.debug)this.debugView.modes({hidden:!0}),this.output.appendChild(e);else{var t=[].concat(_toConsumableArray(e.querySelectorAll(".error"))).map(function(e){return e.textContent});if(t.length>0)return this.error("error"+(1===t.length?"":"s")+" within contents ("+t.join("; ")+")",this.source+this.payload[0].contents+"<</"+this.name+">>")}}}),Macro.add("display","include"),Macro.add("if",{skipArgs:!0,tags:["elseif","else"],handler:function(){var e=0;try{for(var t=Scripting.evalJavaScript,r=this.payload.length,n=!1;e<r;++e){switch(this.payload[e].name){case"else":if(e+1!==r)return this.error("<<else>> must be the final clause");if(this.payload[e].args.raw.length>0)return/^\s*if\b/i.test(this.payload[e].args.raw)?this.error('whitespace is not allowed between the "else" and "if" in <<elseif>> clause'+(e>0?" (#"+e+")":"")):this.error("<<else>> does not accept a conditional expression (perhaps you meant to use <<elseif>>), invalid: "+this.payload[e].args.raw);break;default:if(0===this.payload[e].args.full.length)return this.error("no conditional expression specified for <<"+this.payload[e].name+">> clause"+(e>0?" (#"+e+")":""));if(Config.macros.ifAssignmentError&&/[^!=&^|<>*\/%+-]=[^=]/.test(this.payload[e].args.full))return this.error("assignment operator found within <<"+this.payload[e].name+">> clause"+(e>0?" (#"+e+")":"")+" (perhaps you meant to use an equality operator: ==, ===, eq, is), invalid: "+this.payload[e].args.raw)}if(Config.debug&&this.createDebugView(this.payload[e].name,this.payload[e].source).modes({nonvoid:!1}),"else"===this.payload[e].name||t(this.payload[e].args.full)){n=!0,new Wikifier(this.output,this.payload[e].contents);break}Config.debug&&this.debugView.modes({hidden:!0,invalid:!0})}if(Config.debug){for(++e;e<r;++e)this.createDebugView(this.payload[e].name,this.payload[e].source).modes({nonvoid:!1,hidden:!0,invalid:!0});this.createDebugView("/"+this.name,"<</"+this.name+">>").modes({nonvoid:!1,hidden:!n,invalid:!n})}}catch(t){return this.error("bad conditional expression in <<"+(0===e?"if":"elseif")+">> clause"+(e>0?" (#"+e+")":"")+": "+("object"===("undefined"==typeof t?"undefined":_typeof(t))?t.message:t))}}}),Macro.add("switch",{skipArg0:!0,tags:["case","default"],handler:function(){if(0===this.args.full.length)return this.error("no expression specified");var e=this.payload.length,t=void 0;if(1===e)return this.error("no cases specified");try{t=Scripting.evalJavaScript(this.args.full)}catch(e){return this.error("bad evaluation: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}var r=this.debugView,n=1,a=!1;for(Config.debug&&r.modes({nonvoid:!1,hidden:!0});n<e;++n){switch(this.payload[n].name){case"default":if(n+1!==e)return this.error("<<default>> must be the final case");if(this.payload[n].args.length>0)return this.error("<<default>> does not accept values, invalid: "+this.payload[n].args.raw);break;default:if(0===this.payload[n].args.length)return this.error("no value(s) specified for <<"+this.payload[n].name+">> (#"+n+")")}if(Config.debug&&this.createDebugView(this.payload[n].name,this.payload[n].source).modes({nonvoid:!1}),"default"===this.payload[n].name||this.payload[n].args.some(function(e){return e===t})){a=!0,new Wikifier(this.output,this.payload[n].contents);break}Config.debug&&this.debugView.modes({hidden:!0,invalid:!0})}if(Config.debug){for(++n;n<e;++n)this.createDebugView(this.payload[n].name,this.payload[n].source).modes({nonvoid:!1,hidden:!0,invalid:!0});r.modes({nonvoid:!1,hidden:!0,invalid:!a}),this.createDebugView("/"+this.name,"<</"+this.name+">>").modes({nonvoid:!1,hidden:!0,invalid:!a})}}}),Macro.add("for",{skipArgs:!0,tags:null,handler:function(){var e=Scripting.evalJavaScript,t=this.payload[0].contents.replace(/\n$/,""),r=void 0,n=this.args.full.trim(),a=void 0,i=!0,o=Config.macros.maxLoopIterations;if(0===n.length)n=!0;else if(n.indexOf(";")!==-1){var s=n.match(/^([^;]*?)\s*;\s*([^;]*?)\s*;\s*([^;]*?)$/);if(null===s)return this.error("invalid 3-part syntax, format: init ; condition ; post");r=s[1],n=s[2],a=s[3]}if("string"==typeof n){if(/^\S+\s+in\s+\S+/i.test(n))return this.error("invalid syntax, for…in is not supported");if(/^\S+\s+of\s+\S+/i.test(n))return this.error("invalid syntax, for…of is not supported")}Config.debug&&this.debugView.modes({block:!0});try{if(TempState.break=null,r)try{e(r)}catch(e){return this.error("bad init expression: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}for(;e(n);){if(--o<0)return this.error("exceeded configured maximum loop iterations ("+Config.macros.maxLoopIterations+")");if(new Wikifier(this.output,i?t.replace(/^\n/,""):t),i&&(i=!1),null!=TempState.break)if(1===TempState.break)TempState.break=null;else if(2===TempState.break){TempState.break=null;break}if(a)try{e(a)}catch(e){return this.error("bad post expression: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}}}catch(e){return this.error("bad conditional expression: "+("object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e))}finally{TempState.break=null}}}),Macro.add(["break","continue"],{skipArgs:!0,handler:function(){return this.contextHas(function(e){return"for"===e.name})?(TempState.break="continue"===this.name?1:2,void(Config.debug&&this.debugView.modes({hidden:!0}))):this.error("must only be used in conjunction with its parent macro <<for>>")}}),Macro.add(["button","link"],{isAsync:!0,tags:null,handler:function(){var e=this;if(0===this.args.length)return this.error("no "+("button"===this.name?"button":"link")+" text specified");Config.debug&&this.createDebugView(this.name,this.source+this.payload[0].contents+"<</"+this.name+">>");var t=jQuery(document.createElement("button"===this.name?"button":"a")),r=void 0;if("object"===_typeof(this.args[0]))if(this.args[0].isImage){var n=jQuery(document.createElement("img")).attr("src",this.args[0].source).appendTo(t);this.args[0].hasOwnProperty("passage")&&n.attr("data-passage",this.args[0].passage),this.args[0].hasOwnProperty("title")&&n.attr("title",this.args[0].title),this.args[0].hasOwnProperty("align")&&n.attr("align",this.args[0].align),this.args[0].hasOwnProperty("link")&&(r=this.args[0].link),r=this.args[0].link}else t.append(document.createTextNode(this.args[0].text)),r=this.args[0].link;else t.wikiWithOptions({profile:"core"},this.args[0]),r=this.args.length>1?this.args[1]:undefined;null!=r?(t.attr("data-passage",r),Story.has(r)?(t.addClass("link-internal"),Config.addVisitedLinkClass&&State.hasPlayed(r)&&t.addClass("link-visited")):t.addClass("link-broken")):t.addClass("link-internal"),t.addClass("macro-"+this.name).ariaClick({namespace:".macros",one:null!=r},this.createShadowWrapper(""!==this.payload[0].contents?function(){return Wikifier.wikifyEval(e.payload[0].contents.trim())}:null,null!=r?function(){return Engine.play(r)}:null)).appendTo(this.output)}}),Macro.add("checkbox",{handler:function(){if(this.args.length<3){var e=[];return this.args.length<1&&e.push("variable name"),this.args.length<2&&e.push("unchecked value"),this.args.length<3&&e.push("checked value"),this.error("no "+e.join(" or ")+" specified")}if("string"!=typeof this.args[0])return this.error("variable name argument is not a string");var t=this.args[0].trim();if("$"!==t[0]&&"_"!==t[0])return this.error('variable name "'+this.args[0]+'" is missing its sigil ($ or _)');var r=Util.slugify(t),n=this.args[1],a=this.args[2],i=document.createElement("input");jQuery(i).attr({id:this.name+"-"+r,name:this.name+"-"+r,type:"checkbox",tabindex:0}).addClass("macro-"+this.name).on("change",function(){Wikifier.setValue(t,this.checked?a:n)}).appendTo(this.output),this.args.length>3&&"checked"===this.args[3]?(i.checked=!0,Wikifier.setValue(t,a)):Wikifier.setValue(t,n)}}),Macro.add(["linkappend","linkprepend","linkreplace"],{isAsync:!0,tags:null,handler:function(){var e=this;if(0===this.args.length)return this.error("no link text specified");Config.debug&&this.createDebugView(this.name,this.source+this.payload[0].contents+"<</"+this.name+">>");var t=jQuery(document.createElement("a")),r=jQuery(document.createElement("span")),n=this.args.length>1&&/^(?:transition|t8n)$/.test(this.args[1]);t.wikiWithOptions({profile:"core"},this.args[0]).addClass("link-internal macro-"+this.name).ariaClick({namespace:".macros",one:!0},this.createShadowWrapper(function(){if("linkreplace"===e.name?t.remove():t.wrap('<span class="macro-'+e.name+'"></span>').replaceWith(function(){return t.html()}),""!==e.payload[0].contents){var a=document.createDocumentFragment();new Wikifier(a,e.payload[0].contents),r.append(a)}n&&setTimeout(function(){return r.removeClass("macro-"+e.name+"-in")},Engine.minDomActionDelay)})).appendTo(this.output),r.addClass("macro-"+this.name+"-insert"),n&&r.addClass("macro-"+this.name+"-in"),"linkprepend"===this.name?r.insertBefore(t):r.insertAfter(t)}}),Macro.add("radiobutton",{handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("variable name"),this.args.length<2&&e.push("checked value"),this.error("no "+e.join(" or ")+" specified")}if("string"!=typeof this.args[0])return this.error("variable name argument is not a string");var t=this.args[0].trim();if("$"!==t[0]&&"_"!==t[0])return this.error('variable name "'+this.args[0]+'" is missing its sigil ($ or _)');var r=Util.slugify(t),n=this.args[1],a=document.createElement("input");TempState.hasOwnProperty(this.name)||(TempState[this.name]={}),TempState[this.name].hasOwnProperty(r)||(TempState[this.name][r]=0),jQuery(a).attr({id:this.name+"-"+r+"-"+TempState[this.name][r]++,name:this.name+"-"+r,type:"radio",tabindex:0}).addClass("macro-"+this.name).on("change",function(){this.checked&&Wikifier.setValue(t,n)}).appendTo(this.output),this.args.length>2&&"checked"===this.args[2]&&(a.checked=!0,Wikifier.setValue(t,n))}}),Macro.add("textarea",{handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("variable name"),this.args.length<2&&e.push("default value"),this.error("no "+e.join(" or ")+" specified")}if("string"!=typeof this.args[0])return this.error("variable name argument is not a string");var t=this.args[0].trim();if("$"!==t[0]&&"_"!==t[0])return this.error('variable name "'+this.args[0]+'" is missing its sigil ($ or _)');Config.debug&&this.debugView.modes({block:!0});var r=Util.slugify(t),n=this.args[1],a="autofocus"===this.args[2],i=document.createElement("textarea");jQuery(i).attr({id:this.name+"-"+r,name:this.name+"-"+r,rows:4,tabindex:0}).addClass("macro-"+this.name).on("change",function(){Wikifier.setValue(t,this.value)}).appendTo(this.output),Wikifier.setValue(t,n),i.textContent=n,a&&(i.setAttribute("autofocus","autofocus"),postdisplay["#autofocus:"+i.id]=function(e){delete postdisplay[e],setTimeout(function(){return i.focus()},Engine.minDomActionDelay)})}}),Macro.add("textbox",{handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("variable name"),this.args.length<2&&e.push("default value"),this.error("no "+e.join(" or ")+" specified")}if("string"!=typeof this.args[0])return this.error("variable name argument is not a string");var t=this.args[0].trim();if("$"!==t[0]&&"_"!==t[0])return this.error('variable name "'+this.args[0]+'" is missing its sigil ($ or _)');Config.debug&&this.debugView.modes({block:!0});var r=Util.slugify(t),n=this.args[1],a=document.createElement("input"),i=!1,o=void 0;this.args.length>3?(o=this.args[2],i="autofocus"===this.args[3]):this.args.length>2&&("autofocus"===this.args[2]?i=!0:o=this.args[2]),jQuery(a).attr({id:this.name+"-"+r,name:this.name+"-"+r,type:"text",tabindex:0}).addClass("macro-"+this.name).on("change",function(){Wikifier.setValue(t,this.value)}).on("keypress",function(e){13===e.which&&(e.preventDefault(),Wikifier.setValue(t,this.value),null!=o&&Engine.play(o))}).appendTo(this.output),Wikifier.setValue(t,n),a.value=n,i&&(a.setAttribute("autofocus","autofocus"),postdisplay["#autofocus:"+a.id]=function(e){delete postdisplay[e],setTimeout(function(){return a.focus()},Engine.minDomActionDelay)})}}),Macro.add("click","link"),Macro.add("actions",{handler:function(){for(var e=jQuery(document.createElement("ul")).addClass(this.name).appendTo(this.output),t=0;t<this.args.length;++t){var r=void 0,n=void 0,a=void 0,i=void 0;"object"===_typeof(this.args[t])?this.args[t].isImage?(a=jQuery(document.createElement("img")).attr("src",this.args[t].source),this.args[t].hasOwnProperty("passage")&&a.attr("data-passage",this.args[t].passage),this.args[t].hasOwnProperty("title")&&a.attr("title",this.args[t].title),this.args[t].hasOwnProperty("align")&&a.attr("align",this.args[t].align),r=this.args[t].link,i=this.args[t].setFn):(n=this.args[t].text,r=this.args[t].link,i=this.args[t].setFn):n=r=this.args[t],State.variables.hasOwnProperty("#actions")&&State.variables["#actions"].hasOwnProperty(r)&&State.variables["#actions"][r]||jQuery(Wikifier.createInternalLink(jQuery(document.createElement("li")).appendTo(e),r,null,function(e,t){return function(){State.variables.hasOwnProperty("#actions")||(State.variables["#actions"]={}),State.variables["#actions"][e]=!0,"function"==typeof t&&t()}}(r,i))).addClass("macro-"+this.name).append(a||document.createTextNode(n))}}}),Macro.add(["back","return"],{handler:function(){if(this.args.length>1)return this.error("too many arguments specified, check the documentation for details");var e=-1,t=void 0,r=void 0,n=void 0;if(1===this.args.length&&("object"===_typeof(this.args[0])?this.args[0].isImage?(n=jQuery(document.createElement("img")).attr("src",this.args[0].source),this.args[0].hasOwnProperty("passage")&&n.attr("data-passage",this.args[0].passage),this.args[0].hasOwnProperty("title")&&n.attr("title",this.args[0].title),this.args[0].hasOwnProperty("align")&&n.attr("align",this.args[0].align),this.args[0].hasOwnProperty("link")&&(t=this.args[0].link)):1===this.args[0].count?t=this.args[0].link:(r=this.args[0].text,t=this.args[0].link):1===this.args.length&&(r=this.args[0])),null==t){for(var a=State.length-2;a>=0;--a)if(State.history[a].title!==State.passage){e=a,t=State.history[a].title;break}if(null==t&&"return"===this.name)for(var i=State.expired.length-1;i>=0;--i)if(State.expired[i]!==State.passage){t=State.expired[i];break}}else{if(!Story.has(t))return this.error('passage "'+t+'" does not exist');if("back"===this.name){for(var o=State.length-2;o>=0;--o)if(State.history[o].title===t){e=o;break}if(e===-1)return this.error('cannot find passage "'+t+'" in the current story history')}}if(null==t)return this.error("cannot find passage");var s=void 0;s="back"!==this.name||e!==-1?jQuery(document.createElement("a")).addClass("link-internal").ariaClick({one:!0},"return"===this.name?function(){return Engine.play(t)}:function(){return Engine.goTo(e)}):jQuery(document.createElement("span")).addClass("link-disabled"),s.addClass("macro-"+this.name).append(n||document.createTextNode(r||L10n.get("macro"+this.name.toUpperFirst()+"Text"))).appendTo(this.output)}}),Macro.add("choice",{handler:function(){if(0===this.args.length)return this.error("no passage specified");var e=State.passage,t=void 0,r=void 0,n=void 0,a=void 0;return 1===this.args.length?"object"===_typeof(this.args[0])?this.args[0].isImage?(n=jQuery(document.createElement("img")).attr("src",this.args[0].source),this.args[0].hasOwnProperty("passage")&&n.attr("data-passage",this.args[0].passage),this.args[0].hasOwnProperty("title")&&n.attr("title",this.args[0].title),this.args[0].hasOwnProperty("align")&&n.attr("align",this.args[0].align),t=this.args[0].link,a=this.args[0].setFn):(r=this.args[0].text,t=this.args[0].link,a=this.args[0].setFn):r=t=this.args[0]:(t=this.args[0],r=this.args[1]),State.variables.hasOwnProperty("#choice")&&State.variables["#choice"].hasOwnProperty(e)&&State.variables["#choice"][e]?void jQuery(document.createElement("span")).addClass("link-disabled macro-"+this.name).attr("tabindex",-1).append(n||document.createTextNode(r)).appendTo(this.output):void jQuery(Wikifier.createInternalLink(this.output,t,null,function(){State.variables.hasOwnProperty("#choice")||(State.variables["#choice"]={}),State.variables["#choice"][e]=!0,"function"==typeof a&&a()})).addClass("macro-"+this.name).append(n||document.createTextNode(r))}}),Macro.add(["addclass","toggleclass"],{handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("selector"),this.args.length<2&&e.push("class names"),this.error("no "+e.join(" or ")+" specified")}var t=jQuery(this.args[0]);if(0===t.length)return this.error('no elements matched the selector "'+this.args[0]+'"');switch(this.name){case"addclass":t.addClass(this.args[1].trim());break;case"toggleclass":t.toggleClass(this.args[1].trim())}}}),Macro.add("removeclass",{handler:function(){if(0===this.args.length)return this.error("no selector specified");var e=jQuery(this.args[0]);return 0===e.length?this.error('no elements matched the selector "'+this.args[0]+'"'):void(this.args.length>1?e.removeClass(this.args[1].trim()):e.removeClass())}}),Macro.add("copy",{handler:function(){if(0===this.args.length)return this.error("no selector specified");var e=jQuery(this.args[0]);return 0===e.length?this.error('no elements matched the selector "'+this.args[0]+'"'):void jQuery(this.output).append(e.html())}}),Macro.add(["append","prepend","replace"],{tags:null,handler:function(){if(0===this.args.length)return this.error("no selector specified");var e=jQuery(this.args[0]);if(0===e.length)return this.error('no elements matched the selector "'+this.args[0]+'"');if(""!==this.payload[0].contents){var t=document.createDocumentFragment();switch(new Wikifier(t,this.payload[0].contents),this.name){case"replace":e.empty();case"append":e.append(t);break;case"prepend":e.prepend(t)}}else"replace"===this.name&&e.empty()}}),Macro.add("remove",{handler:function(){if(0===this.args.length)return this.error("no selector specified");var e=jQuery(this.args[0]);return 0===e.length?this.error('no elements matched the selector "'+this.args[0]+'"'):void e.remove()}}),Has.audio?(Macro.add("audio",{handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("track ID"),this.args.length<2&&e.push("actions"),this.error("no "+e.join(" or ")+" specified")}var t=Macro.get("cacheaudio").tracks,r=[":all",":looped",":muted",":paused",":playing"],n=String(this.args[0]).trim();if(!r.includes(n)&&!t.hasOwnProperty(n))return this.error('track "'+n+'" does not exist');for(var a=this.args.slice(1),i=void 0,o=void 0,s=void 0,u=void 0,l=void 0,c=void 0,d=5,p=void 0,f=void 0;a.length>0;){var h=a.shift();switch(h){case"play":case"pause":case"stop":i=h;break;case"fadein":i="fade",c=1;break;case"fadeout":i="fade",c=0;break;case"fadeto":if(0===a.length)return this.error("fadeto missing required level value");if(i="fade",f=a.shift(),c=Number.parseFloat(f),Number.isNaN(c)||!Number.isFinite(c))return this.error("cannot parse fadeto: "+f);break;case"fadeoverto":if(a.length<2){var g=[];return a.length<1&&g.push("seconds"),a.length<2&&g.push("level"),this.error("fadeoverto missing required "+g.join(" and ")+" value"+(g.length>1?"s":""))}if(i="fade",f=a.shift(),d=Number.parseFloat(f),Number.isNaN(d)||!Number.isFinite(d))return this.error("cannot parse fadeoverto: "+f);if(f=a.shift(),c=Number.parseFloat(f),Number.isNaN(c)||!Number.isFinite(c))return this.error("cannot parse fadeoverto: "+f);break;case"volume":if(0===a.length)return this.error("volume missing required level value");if(f=a.shift(),o=Number.parseFloat(f),Number.isNaN(o)||!Number.isFinite(o))return this.error("cannot parse volume: "+f);break;case"mute":case"unmute":s="mute"===h;break;case"time":if(0===a.length)return this.error("time missing required seconds value");if(f=a.shift(),u=Number.parseFloat(f),Number.isNaN(u)||!Number.isFinite(u))return this.error("cannot parse time: "+f);break;case"loop":case"unloop":l="loop"===h;break;case"goto":if(0===a.length)return this.error("goto missing required passage title");if(f=a.shift(),p="object"===("undefined"==typeof f?"undefined":_typeof(f))?f.link:f,!Story.has(p))return this.error('passage "'+p+'" does not exist');break;default:return this.error("unknown action: "+h)}}var m=void 0;switch(n){case":all":m=Object.keys(t);break;case":looped":m=Object.keys(t).filter(function(e){return t[e].isLooped()});break;case":muted":m=Object.keys(t).filter(function(e){return t[e].isMuted()});break;case":paused":m=Object.keys(t).filter(function(e){return t[e].isPaused()});break;case":playing":m=Object.keys(t).filter(function(e){return t[e].isPlaying()});break;default:m=[n]}try{m.forEach(function(e){var r=t[e];switch(null!=o&&(r.volume=o),null!=u&&(r.time=u),null!=s&&(r.mute=s),null!=l&&(r.loop=l),null!=p&&r.one("end",function(){return Engine.play(p)}),i){case"play":r.play();break;case"pause":r.pause();break;case"stop":r.stop();break;case"fade":r.fadeWithDuration(d,c)}}),Config.debug&&this.createDebugView()}catch(e){return this.error("error executing audio action: "+e.message)}}}),Macro.add("cacheaudio",{tracks:{},handler:function(){if(this.args.length<2){var e=[];return this.args.length<1&&e.push("track ID"),this.args.length<2&&e.push("sources"),this.error("no "+e.join(" or ")+" specified")}var t=String(this.args[0]).trim(),r=/^:|\s/;if(r.test(t))return this.error('invalid track ID "'+t+'": track IDs may not start with a colon or contain whitespace');var n=/^format:\s*([\w-]+)\s*;\s*(\S.*)$/i,a=void 0;try{a=SimpleAudio.create(this.args.slice(1).map(function(e){var t=n.exec(e);return null===t?e:{format:t[1],src:t[2]}}))}catch(e){return this.error('error during track initialization for "'+t+'": '+e.message)}if(Config.debug&&!a.hasSource())return this.error('no supported audio sources found for "'+t+'"');var i=this.self.tracks;i.hasOwnProperty(t)&&i[t].destroy(),i[t]=a,Config.debug&&this.createDebugView()}}),Macro.add("createplaylist",{tags:["track"],lists:{},handler:function(){if(0===this.args.length)return this.error("no list ID specified");var e=Macro.get("playlist");if(null!==e.from&&"createplaylist"!==e.from)return this.error("a playlist has already been defined with <<setplaylist>>");var t=Macro.get("cacheaudio").tracks,r=String(this.args[0]).trim(),n=/^:|\s/;if(n.test(r))return this.error('invalid list ID "'+r+'": list IDs may not start with a colon or contain whitespace');if(1===this.payload.length)return this.error("no tracks defined via <<track>>");Config.debug&&this.debugView.modes({nonvoid:!1,hidden:!0});for(var a=SimpleAudio.createList(),i=1,o=this.payload.length;i<o;++i){if(this.payload[i].args.length<2){var s=[];return this.payload[i].args.length<1&&s.push("track ID"),this.payload[i].args.length<2&&s.push("actions"),this.error("no "+s.join(" or ")+" specified")}var u=String(this.payload[i].args[0]).trim();if(!t.hasOwnProperty(u))return this.error('track "'+u+'" does not exist');for(var l=this.payload[i].args.slice(1),c=!1,d=void 0;l.length>0;){var p=l.shift(),f=void 0;switch(p){case"copy":c=!0;break;case"rate":l.length>0&&l.shift();break;case"volume":if(0===l.length)return this.error("volume missing required level value");
+if(f=l.shift(),d=Number.parseFloat(f),Number.isNaN(d)||!Number.isFinite(d))return this.error("cannot parse volume: "+f);break;default:return this.error("unknown action: "+p)}}var h=t[u];a.add({copy:c,track:h,volume:null!=d?d:h.volume}),Config.debug&&this.createDebugView(this.payload[i].name,this.payload[i].source).modes({nonvoid:!1,hidden:!0})}var g=this.self.lists;g.hasOwnProperty(r)&&g[r].destroy(),g[r]=a,null===e.from&&(e.from="createplaylist"),this.createDebugView("/"+this.name,"<</"+this.name+">>").modes({nonvoid:!1,hidden:!0})}}),Macro.add("masteraudio",{handler:function(){if(0===this.args.length)return this.error("no actions specified");for(var e=this.args.slice(0),t=!1,r=void 0,n=void 0;e.length>0;){var a=e.shift(),i=void 0;switch(a){case"stop":t=!0;break;case"mute":case"unmute":r="mute"===a;break;case"volume":if(0===e.length)return this.error("volume missing required level value");if(i=e.shift(),n=Number.parseFloat(i),Number.isNaN(n)||!Number.isFinite(n))return this.error("cannot parse volume: "+i);break;default:return this.error("unknown action: "+a)}}try{null!=r&&(SimpleAudio.mute=r),null!=n&&(SimpleAudio.volume=n),t&&SimpleAudio.stop(),Config.debug&&this.createDebugView()}catch(e){return this.error("error executing master audio action: "+e.message)}}}),Macro.add("playlist",{from:null,handler:function(){var e=this.self.from;if(null===e)return this.error("no playlists have been created");var t=void 0,r=void 0;if("createplaylist"===e){if(this.args.length<2){var n=[];return this.args.length<1&&n.push("list ID"),this.args.length<2&&n.push("actions"),this.error("no "+n.join(" or ")+" specified")}var a=Macro.get("createplaylist").lists,i=String(this.args[0]).trim();if(!a.hasOwnProperty(i))return this.error('playlist "'+i+'" does not exist');t=a[i],r=this.args.slice(1)}else{if(0===this.args.length)return this.error("no actions specified");t=Macro.get("setplaylist").list,r=this.args.slice(0)}for(var o=void 0,s=void 0,u=void 0,l=void 0,c=void 0,d=void 0,p=5,f=void 0;r.length>0;){var h=r.shift();switch(h){case"play":case"pause":case"stop":case"skip":o=h;break;case"fadein":o="fade",d=1;break;case"fadeout":o="fade",d=0;break;case"fadeto":if(0===r.length)return this.error("fadeto missing required level value");if(o="fade",f=r.shift(),d=Number.parseFloat(f),Number.isNaN(d)||!Number.isFinite(d))return this.error("cannot parse fadeto: "+f);break;case"fadeoverto":if(r.length<2){var g=[];return r.length<1&&g.push("seconds"),r.length<2&&g.push("level"),this.error("fadeoverto missing required "+g.join(" and ")+" value"+(g.length>1?"s":""))}if(o="fade",f=r.shift(),p=Number.parseFloat(f),Number.isNaN(p)||!Number.isFinite(p))return this.error("cannot parse fadeoverto: "+f);if(f=r.shift(),d=Number.parseFloat(f),Number.isNaN(d)||!Number.isFinite(d))return this.error("cannot parse fadeoverto: "+f);break;case"volume":if(0===r.length)return this.error("volume missing required level value");if(f=r.shift(),s=Number.parseFloat(f),Number.isNaN(s)||!Number.isFinite(s))return this.error("cannot parse volume: "+f);break;case"mute":case"unmute":u="mute"===h;break;case"loop":case"unloop":l="loop"===h;break;case"shuffle":case"unshuffle":c="shuffle"===h;break;default:return this.error("unknown action: "+h)}}try{switch(null!=s&&(t.volume=s),null!=u&&(t.mute=u),null!=l&&(t.loop=l),null!=c&&(t.shuffle=c),o){case"play":t.play();break;case"pause":t.pause();break;case"stop":t.stop();break;case"skip":t.skip();break;case"fade":t.fadeWithDuration(p,d)}Config.debug&&this.createDebugView()}catch(e){return this.error("error playing audio: "+e.message)}}}),Macro.add("removeplaylist",{handler:function(){if(0===this.args.length)return this.error("no list ID specified");var e=Macro.get("createplaylist").lists,t=String(this.args[0]).trim();return e.hasOwnProperty(t)?(e[t].destroy(),delete e[t],void(Config.debug&&this.createDebugView())):this.error('playlist "'+t+'" does not exist')}}),Macro.add("waitforaudio",{skipArgs:!0,queue:[],handler:function(){function e(){if(0===t.length)return LoadScreen.unlock(r);var n=t.shift();return n.hasData()?e():void n.one("canplay.waitforaudio error.waitforaudio",function(){jQuery(this).off(".waitforaudio"),e()}).load()}var t=this.self.queue,r=void 0;t.length>0||(this.self.fillQueue(t),t.length>0&&(r=LoadScreen.lock(),e()))},fillQueue:function(e){var t=Macro.get("cacheaudio").tracks;Object.keys(t).forEach(function(r){return e.push(t[r])});var r=Macro.get("createplaylist").lists;if(Object.keys(r).map(function(e){return r[e].tracks}).flatten().filter(function(e){return e.copy}).forEach(function(t){return e.push(t.track)}),Macro.has("setplaylist")){var n=Macro.get("setplaylist").list;null!==n&&n.tracks.forEach(function(t){return e.push(t.track)})}}}),Macro.add("setplaylist",{list:null,handler:function(){if(0===this.args.length)return this.error("no track ID(s) specified");var e=Macro.get("playlist");if(null!==e.from&&"setplaylist"!==e.from)return this.error("playlists have already been defined with <<createplaylist>>");var t=this.self,r=Macro.get("cacheaudio").tracks;null!==t.list&&t.list.destroy(),t.list=SimpleAudio.createList();for(var n=0;n<this.args.length;++n){var a=this.args[n];if(!r.hasOwnProperty(a))return this.error('track "'+a+'" does not exist');t.list.add(r[a])}null===e.from&&(e.from="setplaylist"),Config.debug&&this.createDebugView()}}),Macro.add("stopallaudio",{skipArgs:!0,handler:function(){var e=Macro.get("cacheaudio").tracks;Object.keys(e).forEach(function(t){return e[t].stop()}),Config.debug&&this.createDebugView()}})):Macro.add(["audio","cacheaudio","createplaylist","masteraudio","playlist","removeplaylist","waitforaudio","setplaylist","stopallaudio"],{skipArgs:!0,handler:function(){}}),Macro.add("goto",{handler:function(){if(0===this.args.length)return this.error("no passage specified");var e=void 0;return e="object"===_typeof(this.args[0])?this.args[0].link:this.args[0],Story.has(e)?void setTimeout(function(){return Engine.play(e)},Engine.minDomActionDelay):this.error('passage "'+e+'" does not exist')}}),Macro.add("timed",{isAsync:!0,tags:["next"],timers:new Set,handler:function(){if(0===this.args.length)return this.error("no time value specified in <<timed>>");var e=[];try{e.push({name:this.name,source:this.source,delay:Math.max(Engine.minDomActionDelay,Util.fromCssTime(this.args[0])),content:this.payload[0].contents})}catch(e){return this.error(e.message+" in <<timed>>")}if(this.payload.length>1){var t=void 0;try{var r=void 0;for(t=1,r=this.payload.length;t<r;++t)e.push({name:this.payload[t].name,source:this.payload[t].source,delay:0===this.payload[t].args.length?e[e.length-1].delay:Math.max(Engine.minDomActionDelay,Util.fromCssTime(this.payload[t].args[0])),content:this.payload[t].contents})}catch(e){return this.error(e.message+" in <<next>> (#"+t+")")}}Config.debug&&this.debugView.modes({block:!0});var n=this.args.length>1&&/^(?:transition|t8n)$/.test(this.args[1]),a=jQuery(document.createElement("span")).addClass("macro-"+this.name).appendTo(this.output);this.self.registerTimeout(this.createShadowWrapper(function(e){var t=document.createDocumentFragment();new Wikifier(t,e.content);var r=a;Config.debug&&"next"===e.name&&(r=jQuery(new DebugView(r[0],"macro",e.name,e.source).output)),n&&(r=jQuery(document.createElement("span")).addClass("macro-timed-insert macro-timed-in").appendTo(r)),r.append(t),n&&setTimeout(function(){return r.removeClass("macro-timed-in")},Engine.minDomActionDelay)}),e)},registerTimeout:function(e,t){if("function"!=typeof e)throw new TypeError("callback parameter must be a function");var r=State.turns,n=this.timers,a=null,i=t.shift(),o=function o(){if(n.delete(a),r===State.turns){var s=i;null!=(i=t.shift())&&(a=setTimeout(o,i.delay),n.add(a)),e.call(this,s)}};a=setTimeout(o,i.delay),n.add(a),prehistory.hasOwnProperty("#timed-timers-cleanup")||(prehistory["#timed-timers-cleanup"]=function(e){delete prehistory[e],n.forEach(function(e){return clearTimeout(e)}),n.clear()})}}),Macro.add("repeat",{isAsync:!0,tags:null,timers:new Set,handler:function(){var e=this;if(0===this.args.length)return this.error("no time value specified");var t=void 0;try{t=Math.max(Engine.minDomActionDelay,Util.fromCssTime(this.args[0]))}catch(e){return this.error(e.message)}Config.debug&&this.debugView.modes({block:!0});var r=this.args.length>1&&/^(?:transition|t8n)$/.test(this.args[1]),n=jQuery(document.createElement("span")).addClass("macro-"+this.name).appendTo(this.output);this.self.registerInterval(this.createShadowWrapper(function(){var t=document.createDocumentFragment();new Wikifier(t,e.payload[0].contents);var a=n;r&&(a=jQuery(document.createElement("span")).addClass("macro-repeat-insert macro-repeat-in").appendTo(a)),a.append(t),r&&setTimeout(function(){return a.removeClass("macro-repeat-in")},Engine.minDomActionDelay)}),t)},registerInterval:function(e,t){var r=this;if("function"!=typeof e)throw new TypeError("callback parameter must be a function");var n=State.turns,a=this.timers,i=null;i=setInterval(function(){if(n!==State.turns)return clearInterval(i),void a.delete(i);var t=void 0;try{TempState.break=null,TempState.hasOwnProperty("repeatTimerId")&&(t=TempState.repeatTimerId),TempState.repeatTimerId=i,e.call(r)}finally{"undefined"!=typeof t?TempState.repeatTimerId=t:delete TempState.repeatTimerId,TempState.break=null}},t),a.add(i),prehistory.hasOwnProperty("#repeat-timers-cleanup")||(prehistory["#repeat-timers-cleanup"]=function(e){delete prehistory[e],a.forEach(function(e){return clearInterval(e)}),a.clear()})}}),Macro.add("stop",{skipArgs:!0,handler:function(){if(!TempState.hasOwnProperty("repeatTimerId"))return this.error("must only be used in conjunction with its parent macro <<repeat>>");var e=Macro.get("repeat").timers,t=TempState.repeatTimerId;clearInterval(t),e.delete(t),TempState.break=2,Config.debug&&this.debugView.modes({hidden:!0})}}),Macro.add("widget",{tags:null,handler:function(){if(0===this.args.length)return this.error("no widget name specified");var e=this.args[0];if(Macro.has(e)){if(!Macro.get(e).isWidget)return this.error('cannot clobber existing macro "'+e+'"');Macro.delete(e)}try{Macro.add(e,{isWidget:!0,handler:function(e){return function(){var t=this,r=void 0;try{var n=function(){State.variables.hasOwnProperty("args")&&(r=State.variables.args),State.variables.args=[].concat(_toConsumableArray(t.args)),State.variables.args.raw=t.args.raw,State.variables.args.full=t.args.full,t.addShadow("$args");var n=document.createDocumentFragment(),a=[];return new Wikifier(n,e),Array.from(n.querySelectorAll(".error")).forEach(function(e){a.push(e.textContent)}),0!==a.length?{v:t.error("error"+(a.length>1?"s":"")+" within widget contents ("+a.join("; ")+")")}:void t.output.appendChild(n)}();if("object"===("undefined"==typeof n?"undefined":_typeof(n)))return n.v}catch(e){return this.error("cannot execute widget: "+e.message)}finally{"undefined"!=typeof r?State.variables.args=r:delete State.variables.args}}}(this.payload[0].contents)}),Config.debug&&this.createDebugView(this.name,this.source+this.payload[0].contents+"<</"+this.name+">>")}catch(t){return this.error('cannot create widget macro "'+e+'": '+t.message)}}})}();var Dialog=function(){function e(){m=function(){var e=void 0;try{var t=document.createElement("p"),r=document.createElement("div");t.style.width="100%",t.style.height="200px",r.style.position="absolute",r.style.left="0px",r.style.top="0px",r.style.width="100px",r.style.height="100px",r.style.visibility="hidden",r.style.overflow="hidden",r.appendChild(t),document.body.appendChild(r);var n=t.offsetWidth;r.style.overflow="auto";var a=t.offsetWidth;n===a&&(a=r.clientWidth),document.body.removeChild(r),e=n-a}catch(e){}return e||17}();var e=jQuery(document.createDocumentFragment()).append('<div id="ui-overlay" class="ui-close"></div><div id="ui-dialog" tabindex="0" role="dialog" aria-labelledby="ui-dialog-title"><div id="ui-dialog-titlebar"><h1 id="ui-dialog-title"></h1>'+('<button id="ui-dialog-close" class="ui-close" tabindex="0" aria-label="'+L10n.get("close")+'"></button>')+'</div><div id="ui-dialog-body"></div></div>');d=jQuery(e.find("#ui-overlay").get(0)),p=jQuery(e.find("#ui-dialog").get(0)),f=jQuery(e.find("#ui-dialog-title").get(0)),h=jQuery(e.find("#ui-dialog-body").get(0)),e.insertBefore("#store-area")}function t(e){return p.hasClass("open")&&(!e||e.splitOrEmpty(/\s+/).every(function(e){return h.hasClass(e)}))}function r(e,t){return h.empty().removeClass(),null!=t&&h.addClass(t),f.empty().append((null!=e?String(e):"")||" "),h.get(0)}function n(){return h.get(0)}function a(){var e;return(e=h).append.apply(e,arguments),Dialog}function i(){var e;return(e=h).wiki.apply(e,arguments),Dialog}function o(e,t,r,n,a){return jQuery(e).ariaClick(function(e){e.preventDefault(),"function"==typeof r&&r(e),s(t,a),"function"==typeof n&&n(e)})}function s(e,r){var n=jQuery.extend({top:50},e),a=n.top;t()||(g=safeActiveElement()),jQuery(document.documentElement).addClass("ui-dialog-open"),d.addClass("open"),null!==h[0].querySelector("img")&&h.imagesLoaded().always(function(){return l({data:{top:a}})}),jQuery("body>:not(script,#store-area,#ui-bar,#ui-overlay,#ui-dialog)").attr("tabindex",-3).attr("aria-hidden",!0),jQuery("#ui-bar,#story").find("[tabindex]:not([tabindex^=-])").attr("tabindex",-2).attr("aria-hidden",!0);var i=c(a);return p.css(i).addClass("open").focus(),jQuery(window).on("resize.ui-resize",null,{top:a},jQuery.throttle(40,l)),jQuery(document).on("click.ui-close",".ui-close",{closeFn:r},u).on("keypress.ui-close",".ui-close",function(e){13!==e.which&&32!==e.which||jQuery(this).trigger("click")}),setTimeout(function(){return jQuery.event.trigger("tw:dialogopened")},Engine.minDomActionDelay),Dialog}function u(e){return jQuery(document).off(".ui-close"),jQuery(window).off("resize.ui-resize"),p.removeClass("open").css({left:"",right:"",top:"",bottom:""}),jQuery("#ui-bar,#story").find("[tabindex=-2]").removeAttr("aria-hidden").attr("tabindex",0),jQuery("body>[tabindex=-3]").removeAttr("aria-hidden").removeAttr("tabindex"),f.empty(),h.empty().removeClass(),d.removeClass("open"),jQuery(document.documentElement).removeClass("ui-dialog-open"),null!==g&&(jQuery(g).focus(),g=null),e&&e.data&&"function"==typeof e.data.closeFn&&e.data.closeFn(e),setTimeout(function(){return jQuery.event.trigger("tw:dialogclosed")},Engine.minDomActionDelay),Dialog}function l(e){var t=e&&e.data&&"undefined"!=typeof e.data.top?e.data.top:50;"block"===p.css("display")&&(p.css({display:"none"}),p.css(jQuery.extend({display:""},c(t))))}function c(e){var t=null!=e?e:50,r=jQuery(window),n={left:"",right:"",top:"",bottom:""};p.css(n);var a=r.width()-p.outerWidth(!0)-1,i=r.height()-p.outerHeight(!0)-1;return a<=32+m&&(i-=m),i<=32+m&&(a-=m),a<=32?n.left=n.right=16:n.left=n.right=~~(a/2),i<=32?n.top=n.bottom=16:i/2>t?n.top=t:n.top=n.bottom=~~(i/2),Object.keys(n).forEach(function(e){""!==n[e]&&(n[e]+="px")}),n}var d=null,p=null,f=null,h=null,g=null,m=0;return Object.freeze(Object.defineProperties({},{init:{value:e},isOpen:{value:t},setup:{value:r},body:{value:n},append:{value:a},wiki:{value:i},addClickHandler:{value:o},open:{value:s},close:{value:u},resize:{value:function(){return l()}}}))}(),Engine=function(){function e(){if(Story.has("StoryInit"))try{var e=Wikifier.wikifyEval(Story.get("StoryInit").text);if(Config.debug){var t=new DebugView(document.createDocumentFragment(),"special","StoryInit","StoryInit");t.modes({hidden:!0}),t.append(e),y=t.output}}catch(e){Alert.error("StoryInit",e.message)}if(Config.history.maxStates=Math.max(0,Config.history.maxStates),Number.isSafeInteger(Config.history.maxStates)||(Config.history.maxStates=100),1===Config.history.maxStates&&(Config.history.controls=!1),Config.debug&&DebugView.init(),null==Config.passages.start)throw new Error("starting passage not selected");if(!Story.has(Config.passages.start))throw new Error('starting passage ("'+Config.passages.start+'") not found');if(State.restore())d();else{var r=!0;switch(_typeof(Config.saves.autoload)){case"boolean":Config.saves.autoload&&Save.autosave.ok()&&Save.autosave.has()&&(r=!Save.autosave.load());break;case"string":"prompt"===Config.saves.autoload&&Save.autosave.ok()&&Save.autosave.has()&&(r=!1,UI.buildDialogAutoload(),UI.open());break;case"function":Save.autosave.ok()&&Save.autosave.has()&&Config.saves.autoload()&&(r=!Save.autosave.load())}r&&p(Config.passages.start)}}function t(){LoadScreen.show(),window.scroll(0,0),State.reset(),window.location.reload()}function r(){return m}function n(){return m===h.Idle}function a(){return m!==h.Idle}function i(){return m===h.Rendering}function o(){return v}function s(e){var t=State.goTo(e);return t&&d(),t}function u(e){var t=State.go(e);return t&&d(),t}function l(){return u(-1)}function c(){return u(1)}function d(){return p(State.passage,!0)}function p(e,t){var r=e;m=h.Playing,TempState={},State.clearTemporary();var n=void 0,a=void 0;if("function"==typeof Config.navigation.override)try{var i=Config.navigation.override(r);i&&(r=i)}catch(e){}var o=Story.get(r);if(Object.keys(prehistory).forEach(function(e){"function"==typeof prehistory[e]&&prehistory[e].call(this,e)},o),t||State.create(o.title),document.body.className&&(document.body.className=""),Object.keys(predisplay).forEach(function(e){"function"==typeof predisplay[e]&&predisplay[e].call(this,e)},o),Story.has("PassageReady"))try{n=Wikifier.wikifyEval(Story.get("PassageReady").text)}catch(e){Alert.error("PassageReady",e.message)}m=h.Rendering;var s=jQuery(o.render()),u=document.getElementById("passages");if(u.hasChildNodes()&&("number"==typeof Config.passages.transitionOut||"string"==typeof Config.passages.transitionOut&&""!==Config.passages.transitionOut&&""!==Config.transitionEndEventName?[].concat(_toConsumableArray(u.childNodes)).forEach(function(e){var t=jQuery(e);if(e.nodeType===Node.ELEMENT_NODE&&t.hasClass("passage")){if(t.hasClass("passage-out"))return;t.attr("id","out-"+t.attr("id")).addClass("passage-out"),"string"==typeof Config.passages.transitionOut?t.on(Config.transitionEndEventName,function(e){e.originalEvent.propertyName===Config.passages.transitionOut&&t.remove()}):setTimeout(function(){return t.remove()},Math.max(g,Config.passages.transitionOut))}else t.remove()}):jQuery(u).empty()),s.addClass("passage-in").appendTo(u),setTimeout(function(){return s.removeClass("passage-in")},g),document.title=Config.passages.displayTitles&&o.title!==Config.passages.start?o.title+" | "+Story.title:Story.title,window.scroll(0,0),m=h.Playing,Story.has("PassageDone"))try{a=Wikifier.wikifyEval(Story.get("PassageDone").text)}catch(e){Alert.error("PassageDone",e.message)}if(Object.keys(postdisplay).forEach(function(e){"function"==typeof postdisplay[e]&&postdisplay[e].call(this,e)},o),Config.ui.updateStoryElements&&UI.setStoryElements(),Config.debug){var l=void 0;null!=n&&(l=new DebugView(document.createDocumentFragment(),"special","PassageReady","PassageReady"),l.modes({hidden:!0}),l.append(n),s.prepend(l.output)),null!=a&&(l=new DebugView(document.createDocumentFragment(),"special","PassageDone","PassageDone"),l.modes({hidden:!0}),l.append(a),s.append(l.output)),1===State.turns&&null!=y&&s.prepend(y)}switch(v=Date.now(),UI.hideOutlines(),jQuery("#story").find("a[href]:not(.link-external)").addClass("link-external").end().find("a,link,button,input,select,textarea").not("[tabindex]").attr("tabindex",0),_typeof(Config.saves.autosave)){case"boolean":Config.saves.autosave&&Save.autosave.save();break;case"string":o.tags.includes(Config.saves.autosave)&&Save.autosave.save();break;case"object":Array.isArray(Config.saves.autosave)&&o.tags.some(function(e){return Config.saves.autosave.includes(e)})&&Save.autosave.save()}return m=h.Idle,s[0]}function f(e,t,r){var n=!1;switch(r){case undefined:break;case"replace":case"back":n=!0;break;default:throw new Error('Engine.display option parameter called with obsolete value "'+r+'"; please notify the developer')}p(e,n)}var h=Util.toEnum({Idle:"idle",Playing:"playing",Rendering:"rendering"}),g=40,m=h.Idle,v=null,y=null;return Object.freeze(Object.defineProperties({},{States:{value:h},minDomActionDelay:{value:g},start:{value:e},restart:{value:t},state:{get:r},isIdle:{value:n},isPlaying:{value:a},isRendering:{value:i},lastPlay:{get:o},goTo:{value:s},go:{value:u},backward:{value:l},forward:{value:c},show:{value:d},play:{value:p},display:{value:f}}))}(),Passage=function(){var e=void 0,t=void 0;e=/^(?:debug|nobr|passage|script|stylesheet|widget|twine\..*)$/i,!function(){var e=/(?:\\n|\\t|\\s|\\|\r)/g,r=new RegExp(e.source),n=Object.freeze({"\\n":"\n","\\t":"\t","\\s":"\\","\\":"\\","\r":""});t=function(t){if(null==t)return"";var a=String(t);return a&&r.test(a)?a.replace(e,function(e){return n[e]}):a}}();var r=function(){function r(t,n){var a=this;_classCallCheck(this,r),Object.defineProperties(this,{title:{value:Util.unescape(t)},element:{value:n||null},tags:{value:Object.freeze(n&&n.hasAttribute("tags")?n.getAttribute("tags").trim().splitOrEmpty(/\s+/).sort().filter(function(e,t,r){return 0===t||r[t-1]!==e}):[])},_excerpt:{writable:!0,value:null}}),Object.defineProperties(this,{domId:{value:"passage-"+Util.slugify(this.title)},classes:{value:Object.freeze(0===this.tags.length?[]:function(){return a.tags.filter(function(t){return!e.test(t)}).map(function(e){return Util.slugify(e)})}())}})}return _createClass(r,[{key:"description",value:function(){var e=Config.passages.descriptions;if(null!=e)switch("undefined"==typeof e?"undefined":_typeof(e)){case"boolean":if(e)return this.title;break;case"object":if(e instanceof Map&&e.has(this.title))return e.get(this.title);if(e.hasOwnProperty(this.title))return e[this.title];break;case"function":var t=e.call(this);if(t)return t;break;default:throw new TypeError("Config.passages.descriptions must be a boolean, object, or function")}return null===this._excerpt&&(this._excerpt=r.getExcerptFromText(this.text)),this._excerpt}},{key:"processText",value:function(){var e=this.text;return this.tags.includes("nobr")&&(e=e.replace(/^\n+|\n+$/g,"").replace(/\n+/g," ")),this.tags.includes("Twine.image")&&(e="[img["+e+"]]"),e}},{key:"render",value:function(){var e=this,t=document.createElement("div");return jQuery(t).attr({id:this.domId,"data-passage":this.title,"data-tags":this.tags.join(" ")}).addClass("passage "+this.className),jQuery(document.body).addClass(this.className),Object.keys(prerender).forEach(function(r){"function"==typeof prerender[r]&&prerender[r].call(e,t,r)}),Story.has("PassageHeader")&&new Wikifier(t,Story.get("PassageHeader").processText()),new Wikifier(t,this.processText()),Story.has("PassageFooter")&&new Wikifier(t,Story.get("PassageFooter").processText()),Object.keys(postrender).forEach(function(r){"function"==typeof postrender[r]&&postrender[r].call(e,t,r)}),this._excerpt=r.getExcerptFromNode(t),t}},{key:"className",get:function(){return this.classes.join(" ")}},{key:"text",get:function(){if(null==this.element){var e=Util.escape(this.title);return'<span class="error" title="'+e+'">'+L10n.get("errorTitle")+": "+L10n.get("errorNonexistentPassage",{passage:e})+"</span>"}return t(this.element.textContent)}}],[{key:"getExcerptFromNode",value:function(e,t){if(!e.hasChildNodes())return"";var r=e.textContent.trim();if(""!==r){var n=new RegExp("(\\S+(?:\\s+\\S+){0,"+(t>0?t-1:7)+"})");r=r.replace(/\s+/g," ").match(n)}return r?r[1]+"…":"…"}},{key:"getExcerptFromText",value:function(e,t){if(""===e)return"";var r=new RegExp("(\\S+(?:\\s+\\S+){0,"+(t>0?t-1:7)+"})"),n=e.replace(/<<.*?>>/g," ").replace(/<.*?>/g," ").trim().replace(/^\s*\|.*\|.*?$/gm,"").replace(/\[[<>]?img\[[^\]]*\]\]/g,"").replace(/\[\[([^|\]]*)(?:|[^\]]*)?\]\]/g,"$1").replace(/^\s*!+(.*?)$/gm,"$1").replace(/'{2}|\/{2}|_{2}|@{2}/g,"").trim().replace(/\s+/g," ").match(r);return n?n[1]+"…":"…"}}]),r}();return r}(),Save=function(){function e(){if("cookie"===storage.name)return n(),Config.saves.autosave=undefined,Config.saves.slots=0,!1;Config.saves.slots=Math.max(0,Config.saves.slots),Number.isSafeInteger(Config.saves.slots)||(Config.saves.slots=8);var e=r(),t=!1;Array.isArray(e)&&(e={autosave:null,slots:e},t=!0),Config.saves.slots!==e.slots.length&&(Config.saves.slots<e.slots.length?(e.slots.reverse(),e.slots=e.slots.filter(function(e){return!(null===e&&this.count>0)||(--this.count,!1)},{count:e.slots.length-Config.saves.slots}),e.slots.reverse()):Config.saves.slots>e.slots.length&&S(e.slots,Config.saves.slots-e.slots.length),t=!0),j(e.autosave)&&(t=!0);for(var a=0;a<e.slots.length;++a)j(e.slots[a])&&(t=!0);return E(e)&&(storage.delete("saves"),t=!1),t&&x(e),T=e.slots.length-1,!0}function t(){return{autosave:null,slots:S([],Config.saves.slots)}}function r(){var e=storage.get("saves");return null===e?t():e}function n(){return storage.delete("saves"),!0}function a(){return i()||d()}function i(){return"cookie"!==storage.name&&"undefined"!=typeof Config.saves.autosave}function o(){var e=r();return null!==e.autosave}function s(){var e=r();return e.autosave}function u(){var e=r();return null!==e.autosave&&O(e.autosave)}function l(e,t){if("function"==typeof Config.saves.isAllowed&&!Config.saves.isAllowed())return!1;var n=r(),a={title:e||Story.get(State.passage).description(),date:Date.now()};return null!=t&&(a.metadata=t),n.autosave=C(a),x(n)}function c(){var e=r();return e.autosave=null,x(e)}function d(){return"cookie"!==storage.name&&T!==-1}function p(){return T+1}function f(){if(!d())return 0;for(var e=r(),t=0,n=0,a=e.slots.length;n<a;++n)null!==e.slots[n]&&++t;return t}function h(){return 0===f()}function g(e){if(e<0||e>T)return!1;var t=r();return!(e>=t.slots.length||null===t.slots[e])}function m(e){if(e<0||e>T)return null;var t=r();return e>=t.slots.length?null:t.slots[e]}function v(e){if(e<0||e>T)return!1;var t=r();return!(e>=t.slots.length||null===t.slots[e])&&O(t.slots[e])}function y(e,t,n){if("function"==typeof Config.saves.isAllowed&&!Config.saves.isAllowed())return UI.alert(L10n.get("savesDisallowed")),!1;if(e<0||e>T)return!1;var a=r();if(e>=a.slots.length)return!1;var i={title:t||Story.get(State.passage).description(),date:Date.now()};return null!=n&&(i.metadata=n),a.slots[e]=C(i),x(a)}function b(e){if(e<0||e>T)return!1;var t=r();return!(e>=t.slots.length)&&(t.slots[e]=null,x(t))}function w(e,t){function r(){var e=new Date,t=e.getMonth()+1,r=e.getDate(),n=e.getHours(),a=e.getMinutes(),i=e.getSeconds();return t<10&&(t="0"+t),r<10&&(r="0"+r),n<10&&(n="0"+n),a<10&&(a="0"+a),i<10&&(i="0"+i),""+e.getFullYear()+t+r+"-"+n+a+i}if("function"==typeof Config.saves.isAllowed&&!Config.saves.isAllowed())return void UI.alert(L10n.get("savesDisallowed"));var n=null==e?Story.domId:Util.slugify(e),a=n+"-"+r()+".save",i=null==t?{}:{metadata:t},o=LZString.compressToBase64(JSON.stringify(C(i)));saveAs(new Blob([o],{type:"text/plain;charset=UTF-8"}),a)}function k(e){var t=e.target.files[0],r=new FileReader;jQuery(r).on("load",function(e){var r=e.currentTarget;if(r.result){var n=void 0;try{n=JSON.parse(/\.json$/i.test(t.name)||/^\{/.test(r.result)?r.result:LZString.decompressFromBase64(r.result))}catch(e){}O(n)}}),r.readAsText(t)}function S(e,t){for(var r=0;r<t;++r)e.push(null);return e}function E(e){for(var t=e.slots,r=!0,n=0,a=t.length;n<a;++n)if(null!==t[n]){r=!1;break}return null===e.autosave&&r}function x(e){return E(e)?(storage.delete("saves"),!0):storage.set("saves",e)}function j(e){if(null===e)return!1;var t=!1;return e.hasOwnProperty("state")&&e.state.hasOwnProperty("delta")&&e.state.hasOwnProperty("index")||(e.hasOwnProperty("data")?(delete e.mode,e.state={delta:State.deltaEncode(e.data)},delete e.data):e.state.hasOwnProperty("delta")?e.state.hasOwnProperty("index")||delete e.state.mode:(delete e.state.mode,e.state.delta=State.deltaEncode(e.state.history),delete e.state.history),e.state.index=e.state.delta.length-1,t=!0),e.state.hasOwnProperty("rseed")&&(e.state.seed=e.state.rseed,delete e.state.rseed,e.state.delta.forEach(function(e,t,r){r[t].hasOwnProperty("rcount")&&(r[t].pull=r[t].rcount,delete r[t].rcount)}),t=!0),(e.state.hasOwnProperty("expired")&&"number"==typeof e.state.expired||e.state.hasOwnProperty("unique")||e.state.hasOwnProperty("last"))&&(e.state.hasOwnProperty("expired")&&"number"==typeof e.state.expired&&delete e.state.expired,(e.state.hasOwnProperty("unique")||e.state.hasOwnProperty("last"))&&(e.state.expired=[],e.state.hasOwnProperty("unique")&&(e.state.expired.push(e.state.unique),delete e.state.unique),e.state.hasOwnProperty("last")&&(e.state.expired.push(e.state.last),delete e.state.last)),t=!0),t}function C(e){if(null!=e&&"object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("supplemental parameter must be an object");var t=Object.assign({},e,{id:Config.saves.id,state:State.marshalForSave()});return Config.saves.version&&(t.version=Config.saves.version),"function"==typeof Config.saves.onSave&&Config.saves.onSave(t),t.state.delta=State.deltaEncode(t.state.history),delete t.state.history,t}function O(e){try{if(j(e),!e||!e.hasOwnProperty("id")||!e.hasOwnProperty("state"))throw new Error(L10n.get("errorSaveMissingData"));if(e.state.history=State.deltaDecode(e.state.delta),delete e.state.delta,"function"==typeof Config.saves.onLoad&&Config.saves.onLoad(e),e.id!==Config.saves.id)throw new Error(L10n.get("errorSaveIdMismatch"));State.unmarshalForSave(e.state),Engine.show()}catch(e){return UI.alert(e.message.toUpperFirst()+".</p><p>"+L10n.get("aborting")+"."),!1}return!0}var T=-1;return Object.freeze(Object.defineProperties({},{init:{value:e},get:{value:r},clear:{value:n},ok:{value:a},autosave:{value:Object.freeze(Object.defineProperties({},{ok:{value:i},has:{value:o},get:{value:s},load:{value:u},save:{value:l},delete:{value:c}}))},slots:{value:Object.freeze(Object.defineProperties({},{ok:{value:d},length:{get:p},isEmpty:{value:h},count:{value:f},has:{value:g},get:{value:m},load:{value:v},save:{value:y},delete:{value:b}}))},export:{value:w},import:{value:k}}))}(),Setting=function(){function e(){if(storage.has("options")){var e=storage.get("options");null!==e&&(window.SugarCube.settings=settings=Object.assign(t(),e)),r(),storage.delete("options")}n(),g.forEach(function(e){if(e.hasOwnProperty("onInit")){var t={name:e.name,value:settings[e.name],default:e.default};e.hasOwnProperty("list")&&(t.list=e.list),e.onInit.call(t)}})}function t(){return Object.create(null)}function r(){var e=t();return Object.keys(settings).length>0&&g.filter(function(e){return e.type!==m.Header&&settings[e.name]!==e.default}).forEach(function(t){return e[t.name]=settings[t.name]}),0===Object.keys(e).length?(storage.delete("settings"),!0):storage.set("settings",e)}function n(){var e=t(),r=storage.get("settings")||t();g.filter(function(e){return e.type!==m.Header}).forEach(function(t){return e[t.name]=t.default}),window.SugarCube.settings=settings=Object.assign(e,r)}function a(){return window.SugarCube.settings=settings=t(),storage.delete("settings"),!0}function i(e){if(0===arguments.length)a(),n();else{if(null==e||!p(e))throw new Error('nonexistent setting "'+e+'"');var t=f(e);t.type!==m.Header&&(settings[e]=t.default)}return r()}function o(e,t){g.forEach(e,t)}function s(e,t,r){if(arguments.length<3){var n=[];throw arguments.length<1&&n.push("type"),arguments.length<2&&n.push("name"),arguments.length<3&&n.push("definition"),new Error("missing parameters, no "+n.join(" or ")+" specified")}if("object"!==("undefined"==typeof r?"undefined":_typeof(r)))throw new TypeError("definition parameter must be an object");if(p(t))throw new Error('cannot clobber existing setting "'+t+'"');var a={type:e,name:t,label:null==r.label?"":String(r.label).trim()};switch(e){case m.Header:break;case m.Toggle:a.default=!!r.default;break;case m.List:if(!r.hasOwnProperty("list"))throw new Error("no list specified");if(!Array.isArray(r.list))throw new TypeError("list must be an array");if(0===r.list.length)throw new Error("list must not be empty");if(a.list=Object.freeze(r.list),null==r.default)a.default=r.list[0];else{var i=r.list.indexOf(r.default);if(i===-1)throw new Error("list does not contain default");a.default=r.list[i];
+}break;default:throw new Error("unknown Setting type: "+e)}"function"==typeof r.onInit&&(a.onInit=Object.freeze(r.onInit)),"function"==typeof r.onChange&&(a.onChange=Object.freeze(r.onChange)),g.push(Object.freeze(a))}function u(e,t){s(m.Header,e,{label:t})}function l(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];s.apply(undefined,[m.Toggle].concat(t))}function c(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];s.apply(undefined,[m.List].concat(t))}function d(){return 0===g.length}function p(e){return g.some(function(t){return t.name===e})}function f(e){return g.find(function(t){return t.name===e})}function h(e){p(e)&&delete settings[e];for(var t=0;t<g.length;++t)if(g[t].name===e){g.splice(t,1),h(e);break}}var g=[],m=Util.toEnum({Header:0,Toggle:1,List:2});return Object.freeze(Object.defineProperties({},{Types:{value:m},init:{value:e},create:{value:t},save:{value:r},load:{value:n},clear:{value:a},reset:{value:i},forEach:{value:o},add:{value:s},addHeader:{value:u},addToggle:{value:l},addList:{value:c},isEmpty:{value:d},has:{value:p},get:{value:f},delete:{value:h}}))}(),State=function(){function e(){session.delete("state"),L=[],I=c(),Q=-1,R=[],F=null===F?null:new PRNGWrapper(F.seed,!1)}function t(){if(session.has("state")){var e=session.get("state");return null!=e&&(n(e),!0)}return!1}function r(e){var t={index:Q};return e?t.history=clone(L):t.delta=A(L),R.length>0&&(t.expired=[].concat(_toConsumableArray(R))),null!==F&&(t.seed=F.seed),t}function n(e,t){if(null==e)throw new Error("state object is null or undefined");if(!e.hasOwnProperty(t?"history":"delta")||0===e[t?"history":"delta"].length)throw new Error("state object has no history or history is empty");if(!e.hasOwnProperty("index"))throw new Error("state object has no index");if(null!==F&&!e.hasOwnProperty("seed"))throw new Error("state object has no seed, but PRNG is enabled");if(null===F&&e.hasOwnProperty("seed"))throw new Error("state object has seed, but PRNG is disabled");L=t?clone(e.history):P(e.delta),Q=e.index,R=e.hasOwnProperty("expired")?[].concat(_toConsumableArray(e.expired)):[],e.hasOwnProperty("seed")&&(F.seed=e.seed),g(Q)}function a(){return r(!0)}function i(e){return n(e,!0)}function o(){return R}function s(){return R.length+v()}function u(){return R.concat(L.slice(0,v()).map(function(e){return e.title}))}function l(e){return null!=e&&""!==e&&(!!R.includes(e)||!!L.slice(0,v()).some(function(t){return t.title===e}))}function c(e,t){return{title:null==e?"":String(e),variables:null==t?{}:clone(t)}}function d(){return I}function p(){return Q}function f(){return I.title}function h(){return I.variables}function g(e){if(null==e)throw new Error("moment activation attempted with null or undefined");switch("undefined"==typeof e?"undefined":_typeof(e)){case"object":I=clone(e);break;case"number":if(b())throw new Error("moment activation attempted with index on empty history");if(e<0||e>=y())throw new RangeError("moment activation attempted with out-of-bounds index; need [0, "+(y()-1)+"], got "+e);I=clone(L[e]);break;default:throw new TypeError('moment activation attempted with a "'+("undefined"==typeof e?"undefined":_typeof(e))+'"; must be an object or valid history stack index')}return null!==F&&(F=PRNGWrapper.unmarshal({seed:F.seed,pull:I.pull})),session.set("state",r()),jQuery.event.trigger("tw:historyupdate"),I}function m(){return L}function v(){return Q+1}function y(){return L.length}function b(){return 0===L.length}function w(){return L.length>0?L[Q]:null}function k(){return L.length>0?L[L.length-1]:null}function S(){return L.length>0?L[0]:null}function E(e){return b()||e<0||e>Q?null:L[e]}function x(e){if(b())return null;var t=1+(e?Math.abs(e):0);return t>v()?null:L[v()-t]}function j(e){if(b()||null==e||""===e)return!1;for(var t=Q;t>=0;--t)if(L[t].title===e)return!0;return!1}function C(e){if(v()<y()&&L.splice(v(),y()-v()),L.push(c(e,I.variables)),F&&(k().pull=F.pull),Config.history.maxStates>0)for(;y()>Config.history.maxStates;)R.push(L.shift().title);return Q=y()-1,g(Q),v()}function O(e){return!(null==e||e<0||e>=y()||e===Q)&&(Q=e,g(Q),!0)}function T(e){return null!=e&&0!==e&&O(Q+e)}function A(e){if(!Array.isArray(e))return null;if(0===e.length)return[];for(var t=[clone(e[0])],r=1,n=e.length;r<n;++r)t.push(Util.diff(e[r-1],e[r]));return t}function P(e){if(!Array.isArray(e))return null;if(0===e.length)return[];for(var t=[clone(e[0])],r=1,n=e.length;r<n;++r)t.push(Util.patch(t[r-1],e[r]));return t}function _(e,t){if(!b()){var r=void 0;throw r="a script-tagged passage",new Error("State.initPRNG must be called during initialization, within either "+r+" or the StoryInit special passage")}F=new PRNGWrapper(e,t),I.pull=F.pull}function D(){return F?F.random():Math.random()}function M(){V={},TempVariables=V}function N(){return V}var L=[],I=c(),Q=-1,R=[],F=null,V={};return Object.freeze(Object.defineProperties({},{reset:{value:e},restore:{value:t},marshalForSave:{value:a},unmarshalForSave:{value:i},expired:{get:o},turns:{get:s},passages:{get:u},hasPlayed:{value:l},active:{get:d},activeIndex:{get:p},passage:{get:f},variables:{get:h},history:{get:m},length:{get:v},size:{get:y},isEmpty:{value:b},current:{get:w},top:{get:k},bottom:{get:S},index:{value:E},peek:{value:x},has:{value:j},create:{value:C},goTo:{value:O},go:{value:T},deltaEncode:{value:A},deltaDecode:{value:P},initPRNG:{value:_},random:{value:D},clearTemporary:{value:M},temporary:{get:N},restart:{value:function(){return Engine.restart()}},backward:{value:function(){return Engine.backward()}},forward:{value:function(){return Engine.forward()}},display:{value:function(){return Engine.display.apply(Engine,arguments)}},show:{value:function(){return Engine.show.apply(Engine,arguments)}},play:{value:function(){return Engine.play.apply(Engine,arguments)}}}))}(),Story=function(){function e(){function e(e){if(e.tags.includesAny(n))throw new Error('starting passage "'+e.title+'" contains illegal tags; invalid: "'+e.tags.filter(function(e){return n.includes(e)}).sort().join('", "')+'"')}function t(e){if(a.includes(e.title)&&e.tags.includesAny(n))throw new Error('special passage "'+e.title+'" contains illegal tags; invalid: "'+e.tags.filter(function(e){return n.includes(e)}).sort().join('", "')+'"')}var n=["widget"],a=["PassageDone","PassageFooter","PassageHeader","PassageReady","StoryAuthor","StoryBanner","StoryCaption","StoryInit","StoryMenu","StoryShare","StorySubtitle"];!function(){var i=function(e){var t=[].concat(n),r=[];if(e.tags.forEach(function(e){t.includes(e)&&r.push.apply(r,_toConsumableArray(t.delete(e)))}),r.length>1)throw new Error('code passage "'+e.title+'" contains multiple code tags; invalid: "'+r.sort().join('", "')+'"')};if(n.unshift("script","stylesheet"),a.push("StoryTitle"),Config.passages.start=function(){var e="START_AT";return""!==e?(Config.debug=!0,e):"Start"}(),jQuery("#store-area").children(':not([tags~="Twine.private"],[tags~="annotation"])').each(function(){var r=jQuery(this),n=new Passage(r.attr("tiddler"),this);n.title===Config.passages.start?(e(n),c[n.title]=n):n.tags.includes("stylesheet")?(i(n),d.push(n)):n.tags.includes("script")?(i(n),p.push(n)):n.tags.includes("widget")?(i(n),f.push(n)):(t(n),c[n.title]=n)}),!c.hasOwnProperty("StoryTitle"))throw new Error('cannot find the "StoryTitle" special passage');var o=document.createDocumentFragment();new Wikifier(o,c.StoryTitle.processText().trim()),r(o.textContent.trim()),Config.saves.id=Story.domId}()}function t(){!function(){var e=document.createElement("style");new StyleWrapper(e).add(d.map(function(e){return e.text.trim()}).join("\n")),jQuery(e).appendTo(document.head).attr({id:"style-story",type:"text/css"})}();for(var e=0;e<p.length;++e)try{Scripting.evalJavaScript(p[e].text)}catch(t){Alert.error(p[e].title,"object"===("undefined"==typeof t?"undefined":_typeof(t))?t.message:t)}for(var t=0;t<f.length;++t)try{Wikifier.wikifyEval(f[t].processText())}catch(e){Alert.error(f[t].title,"object"===("undefined"==typeof e?"undefined":_typeof(e))?e.message:e)}}function r(e){if(null==e||""===e)throw new Error("story title cannot be null or empty");document.title=h=Util.unescape(e),m=Util.slugify(h)}function n(){return h}function a(){return m}function i(){return g}function o(e){var t="undefined"==typeof e?"undefined":_typeof(e);switch(t){case"number":case"string":var r=String(e);return c.hasOwnProperty(r);case"boolean":case"function":t="a "+t;break;case"undefined":break;default:t=null===e?"null":"an "+t}throw new TypeError("Story.has title parameter cannot be "+t)}function s(e){var t="undefined"==typeof e?"undefined":_typeof(e);switch(t){case"number":case"string":var r=String(e);return c.hasOwnProperty(r)?c[r]:new Passage(r||"(unknown)");case"boolean":case"function":t="a "+t;break;case"undefined":break;default:t=null===e?"null":"an "+t}throw new TypeError("Story.get title parameter cannot be "+t)}function u(e,t){for(var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"title",n=Object.keys(c),a=[],i=0;i<n.length;++i){var o=c[n[i]];if(o.hasOwnProperty(e))switch(_typeof(o[e])){case"undefined":break;case"object":for(var s=0,u=o[e].length;s<u;++s)if(o[e][s]==t){a.push(o);break}break;default:o[e]==t&&a.push(o)}}return a.sort(function(e,t){return e[r]==t[r]?0:e[r]<t[r]?-1:1}),a}function l(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"title";if("function"!=typeof e)throw new Error("Story.lookupWith filter parameter must be a function");for(var r=Object.keys(c),n=[],a=0;a<r.length;++a){var i=c[r[a]];e(i)&&n.push(i)}return n.sort(function(e,r){return e[t]==r[t]?0:e[t]<r[t]?-1:1}),n}var c={},d=[],p=[],f=[],h="",g="",m="";return Object.freeze(Object.defineProperties({},{passages:{value:c},styles:{value:d},scripts:{value:p},widgets:{value:f},load:{value:e},init:{value:t},title:{get:n},domId:{get:a},ifId:{get:i},has:{value:o},get:{value:s},lookup:{value:u},lookupWith:{value:l}}))}(),UI=function(){function e(){jQuery("#init-no-js,#init-lacking").remove(),w=new StyleWrapper(function(){return jQuery(document.createElement("style")).attr({id:"style-outline-patch",type:"text/css"}).appendTo(document.head).get(0)}()),function(){var e=jQuery(document.createDocumentFragment()),t=L10n.get("uiBarToggle"),r=L10n.get("uiBarBackward"),n=L10n.get("uiBarJumpto"),a=L10n.get("uiBarForward");e.append('<div id="ui-bar"><div id="ui-bar-tray">'+('<button id="ui-bar-toggle" tabindex="0" title="'+t+'" aria-label="'+t+'"></button>')+'<div id="ui-bar-history">'+('<button id="history-backward" tabindex="0" title="'+r+'" aria-label="'+r+'">î ¡</button>')+('<button id="history-jumpto" tabindex="0" title="'+n+'" aria-label="'+n+'">î ¹</button>')+('<button id="history-forward" tabindex="0" title="'+a+'" aria-label="'+a+'">î ¢</button>')+'</div></div><div id="ui-bar-body"><header id="title" role="banner"><div id="story-banner"></div><h1 id="story-title"></h1><div id="story-subtitle"></div><div id="story-title-separator"></div><p id="story-author"></p></header><div id="story-caption"></div><nav id="menu" role="navigation"><ul id="menu-story"></ul><ul id="menu-core">'+('<li id="menu-item-saves"><a tabindex="0">'+L10n.get("savesTitle")+"</a></li>")+('<li id="menu-item-settings"><a tabindex="0">'+L10n.get("settingsTitle")+"</a></li>")+('<li id="menu-item-restart"><a tabindex="0">'+L10n.get("restartTitle")+"</a></li>")+('<li id="menu-item-share"><a tabindex="0">'+L10n.get("shareTitle")+"</a></li>")+'</ul></nav></div></div><div id="story" role="main"><div id="passages"></div></div>').insertBefore("#store-area")}(),jQuery(document).on("tw:historyupdate",function(e,t){return function(){e.prop("disabled",State.length<2),t.prop("disabled",State.length===State.size)}}(jQuery("#history-backward"),jQuery("#history-forward"))).on("mousedown.outline-handler keydown.outline-handler",function(e){switch(e.type){case"mousedown":i();break;case"keydown":o()}})}function t(){var e=jQuery("#ui-bar");("boolean"==typeof Config.ui.stowBarInitially?Config.ui.stowBarInitially:jQuery(window).width()<=Config.ui.stowBarInitially)&&!function(){var t=jQuery(e).add("#story");t.addClass("no-transition"),e.addClass("stowed"),setTimeout(function(){return t.removeClass("no-transition")},Engine.minDomActionDelay)}(),jQuery("#ui-bar-toggle").ariaClick({label:L10n.get("uiBarToggle")},function(){return e.toggleClass("stowed")}),Config.history.controls?(jQuery("#history-backward").prop("disabled",State.length<2).ariaClick({label:L10n.get("uiBarBackward")},function(){return Engine.backward()}),Story.lookup("tags","bookmark").length>0?jQuery("#history-jumpto").ariaClick({label:L10n.get("uiBarJumpto")},function(){return UI.jumpto()}):jQuery("#history-jumpto").remove(),jQuery("#history-forward").prop("disabled",State.length===State.size).ariaClick({label:L10n.get("uiBarForward")},function(){return Engine.forward()})):jQuery("#ui-bar-history").remove(),setPageElement("story-title","StoryTitle",Story.title),Story.has("StoryCaption")||jQuery("#story-caption").remove(),Story.has("StoryMenu")||jQuery("#menu-story").remove(),Config.ui.updateStoryElements||a(),Dialog.addClickHandler("#menu-item-saves a",null,v).text(L10n.get("savesTitle")),Setting.isEmpty()?jQuery("#menu-item-settings").remove():Dialog.addClickHandler("#menu-item-settings a",null,y).text(L10n.get("settingsTitle")),Dialog.addClickHandler("#menu-item-restart a",null,m).text(L10n.get("restartTitle")),Story.has("StoryShare")?Dialog.addClickHandler("#menu-item-share a",null,b).text(L10n.get("shareTitle")):jQuery("#menu-item-share").remove(),jQuery(document.documentElement).focus()}function r(){jQuery("#ui-bar").addClass("stow")}function n(){jQuery("#ui-bar").removeClass("stow")}function a(){setPageElement("story-banner","StoryBanner"),setPageElement("story-subtitle","StorySubtitle"),setPageElement("story-author","StoryAuthor"),setPageElement("story-caption","StoryCaption");var e=document.getElementById("menu-story");null!==e&&(jQuery(e).empty(),Story.has("StoryMenu")&&s("StoryMenu",e))}function i(){w.set("*:focus{outline:none}")}function o(){w.clear()}function s(e,t){var r=t,n=Config.debug;Config.debug=!1;try{null==r&&(r=document.createElement("ul"));var a=document.createDocumentFragment();if(new Wikifier(a,Story.get(e).processText().trim()),a.hasChildNodes())for(var i=null;a.hasChildNodes();){var o=a.firstChild;o.nodeType!==Node.ELEMENT_NODE||"A"!==o.nodeName.toUpperCase()?(a.removeChild(o),null!==i&&(i=null)):(null===i&&(i=document.createElement("li"),r.appendChild(i)),i.appendChild(o))}}finally{Config.debug=n}return r}function u(e){jQuery(Dialog.setup("Alert","alert")).append("<p>"+e+'</p><ul class="buttons">'+('<li><button id="alert-ok" class="ui-close">'+L10n.get(["alertOk","ok"])+"</button></li>")+"</ul>");for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];Dialog.open.apply(Dialog,r)}function l(){g(),Dialog.open.apply(Dialog,arguments)}function c(){m(),Dialog.open.apply(Dialog,arguments)}function d(){v(),Dialog.open.apply(Dialog,arguments)}function p(){y(),Dialog.open.apply(Dialog,arguments)}function f(){b(),Dialog.open.apply(Dialog,arguments)}function h(){return jQuery(Dialog.setup(L10n.get("autoloadTitle"),"autoload")).append("<p>"+L10n.get("autoloadPrompt")+'</p><ul class="buttons">'+('<li><button id="autoload-ok" class="ui-close">'+L10n.get(["autoloadOk","ok"])+"</button></li>")+('<li><button id="autoload-cancel" class="ui-close">'+L10n.get(["autoloadCancel","cancel"])+"</button></li>")+"</ul>"),jQuery(document).one("click.autoload",".ui-close",function(e){var t="autoload-ok"===e.target.id;jQuery(document).one("tw:dialogclosed",function(){t&&Save.autosave.load()||Engine.play(Config.passages.start)})}),!0}function g(){var e=document.createElement("ul");jQuery(Dialog.setup(L10n.get("jumptoTitle"),"jumpto list")).append(e);for(var t=State.expired.length,r=State.size-1;r>=0;--r)if(r!==State.activeIndex){var n=Story.get(State.history[r].title);n&&n.tags.includes("bookmark")&&jQuery(document.createElement("li")).append(jQuery(document.createElement("a")).ariaClick({one:!0},function(e){return function(){return jQuery(document).one("tw:dialogclosed",function(){return Engine.goTo(e)})}}(r)).addClass("ui-close").text(L10n.get("jumptoTurn")+" "+(t+r+1)+": "+n.description())).appendTo(e)}e.hasChildNodes()||jQuery(e).append("<li><a><em>"+L10n.get("jumptoUnavailable")+"</em></a></li>")}function m(){return jQuery(Dialog.setup(L10n.get("restartTitle"),"restart")).append("<p>"+L10n.get("restartPrompt")+'</p><ul class="buttons">'+('<li><button id="restart-ok">'+L10n.get(["restartOk","ok"])+"</button></li>")+('<li><button id="restart-cancel" class="ui-close">'+L10n.get(["restartCancel","cancel"])+"</button></li>")+"</ul>").find("#restart-ok").ariaClick({one:!0},function(){jQuery(document).one("tw:dialogclosed",function(){return Engine.restart()}),Dialog.close()}),!0}function v(){function e(e,t,r,n){var a=jQuery(document.createElement("button")).attr("id","saves-"+e).html(r);return t&&a.addClass(t),n?a.ariaClick(n):a.prop("disabled",!0),jQuery(document.createElement("li")).append(a)}function t(){function e(e,t,r,n,a){var i=jQuery(document.createElement("button")).attr("id","saves-"+e+"-"+n).addClass(e).html(r);return t&&i.addClass(t),a?"auto"===n?i.ariaClick({label:r+" "+L10n.get("savesLabelAuto")},function(){return a()}):i.ariaClick({label:r+" "+L10n.get("savesLabelSlot")+" "+(n+1)},function(){return a(n)}):i.prop("disabled",!0),i}var t=Save.get(),r=jQuery(document.createElement("tbody"));if(Save.autosave.ok()){var n=jQuery(document.createElement("td")),a=jQuery(document.createElement("td")),i=jQuery(document.createElement("td")),o=jQuery(document.createElement("td"));jQuery(document.createElement("b")).attr({title:L10n.get("savesLabelAuto"),"aria-label":L10n.get("savesLabelAuto")}).text("A").appendTo(n),t.autosave?(a.append(e("load","ui-close",L10n.get("savesLabelLoad"),"auto",function(){jQuery(document).one("tw:dialogclosed",function(){return Save.autosave.load()})})),jQuery(document.createElement("div")).text(t.autosave.title).appendTo(i),jQuery(document.createElement("div")).addClass("datestamp").html(t.autosave.date?L10n.get("savesSavedOn")+" "+new Date(t.autosave.date).toLocaleString():L10n.get("savesSavedOn")+" <em>"+L10n.get("savesUnknownDate")+"</em>").appendTo(i),o.append(e("delete",null,L10n.get("savesLabelDelete"),"auto",function(){Save.autosave.delete(),v(),Dialog.resize()}))):(a.append(e("load",null,L10n.get("savesLabelLoad"),"auto")),jQuery(document.createElement("em")).text(L10n.get("savesEmptySlot")).appendTo(i),i.addClass("empty"),o.append(e("delete",null,L10n.get("savesLabelDelete"),"auto"))),jQuery(document.createElement("tr")).append(n).append(a).append(i).append(o).appendTo(r)}for(var s=0,u=t.slots.length;s<u;++s){var l=jQuery(document.createElement("td")),c=jQuery(document.createElement("td")),d=jQuery(document.createElement("td")),p=jQuery(document.createElement("td"));l.append(document.createTextNode(s+1)),t.slots[s]?(c.append(e("load","ui-close",L10n.get("savesLabelLoad"),s,function(e){jQuery(document).one("tw:dialogclosed",function(){return Save.slots.load(e)})})),jQuery(document.createElement("div")).text(t.slots[s].title).appendTo(d),jQuery(document.createElement("div")).addClass("datestamp").html(t.slots[s].date?L10n.get("savesSavedOn")+" "+new Date(t.slots[s].date).toLocaleString():L10n.get("savesSavedOn")+" <em>"+L10n.get("savesUnknownDate")+"</em>").appendTo(d),p.append(e("delete",null,L10n.get("savesLabelDelete"),s,function(e){Save.slots.delete(e),v(),Dialog.resize()}))):(c.append(e("save","ui-close",L10n.get("savesLabelSave"),s,Save.slots.save)),jQuery(document.createElement("em")).text(L10n.get("savesEmptySlot")).appendTo(d),d.addClass("empty"),p.append(e("delete",null,L10n.get("savesLabelDelete"),s))),jQuery(document.createElement("tr")).append(l).append(c).append(d).append(p).appendTo(r)}return jQuery(document.createElement("table")).attr("id","saves-list").append(r)}var r=jQuery(Dialog.setup(L10n.get("savesTitle"),"saves")),n=Save.ok();if(n&&r.append(t()),n||Has.fileAPI){var a=jQuery(document.createElement("ul")).addClass("buttons").appendTo(r);return Has.fileAPI&&(a.append(e("export","ui-close",L10n.get("savesLabelExport"),function(){return Save.export()})),a.append(e("import",null,L10n.get("savesLabelImport"),function(){return r.find("#saves-import-file").trigger("click")})),jQuery(document.createElement("input")).css({display:"block",visibility:"hidden",position:"fixed",left:"-9999px",top:"-9999px",width:"1px",height:"1px"}).attr({type:"file",id:"saves-import-file",tabindex:-1,"aria-hidden":!0}).on("change",function(e){jQuery(document).one("tw:dialogclosed",function(){return Save.import(e)}),Dialog.close()}).appendTo(r)),n&&a.append(e("clear",null,L10n.get("savesLabelClear"),Save.autosave.has()||!Save.slots.isEmpty()?function(){Save.clear(),v(),Dialog.resize()}:null)),!0}return u(L10n.get("savesIncapable")),!1}function y(){var e=jQuery(Dialog.setup(L10n.get("settingsTitle"),"settings"));return Setting.forEach(function(t){if(t.type===Setting.Types.Header){var r=t.name,n=Util.slugify(r),a=jQuery(document.createElement("div")),i=jQuery(document.createElement("h2")),o=jQuery(document.createElement("p"));return a.attr("id","header-body-"+n).append(i).append(o).appendTo(e),i.attr("id","header-heading-"+n).wiki(r),void o.attr("id","header-label-"+n).wiki(t.label)}var s=t.name,u=Util.slugify(s),l=jQuery(document.createElement("div")),c=jQuery(document.createElement("label")),d=jQuery(document.createElement("div")),p=void 0;switch(l.attr("id","setting-body-"+u).append(c).append(d).appendTo(e),c.attr({id:"setting-label-"+u,for:"setting-control-"+u}).wiki(t.label),null==settings[s]&&(settings[s]=t.default),t.type){case Setting.Types.Toggle:p=jQuery(document.createElement("button")),settings[s]?p.addClass("enabled").text(L10n.get("settingsOn")):p.text(L10n.get("settingsOff")),p.ariaClick(function(){settings[s]?(jQuery(this).removeClass("enabled").text(L10n.get("settingsOff")),settings[s]=!1):(jQuery(this).addClass("enabled").text(L10n.get("settingsOn")),settings[s]=!0),Setting.save(),t.hasOwnProperty("onChange")&&t.onChange.call({name:s,value:settings[s],default:t.default})});break;case Setting.Types.List:p=jQuery(document.createElement("select"));for(var f=0,h=t.list.length;f<h;++f)jQuery(document.createElement("option")).val(f).text(t.list[f]).appendTo(p);p.val(t.list.indexOf(settings[s])).attr("tabindex",0).on("change",function(){settings[s]=t.list[Number(this.value)],Setting.save(),t.hasOwnProperty("onChange")&&t.onChange.call({name:s,value:settings[s],default:t.default,list:t.list})})}p.attr("id","setting-control-"+u).appendTo(d)}),e.append('<ul class="buttons">'+('<li><button id="settings-ok" class="ui-close">'+L10n.get(["settingsOk","ok"])+"</button></li>")+('<li><button id="settings-reset">'+L10n.get("settingsReset")+"</button></li>")+"</ul>").find("#settings-reset").ariaClick({one:!0},function(){jQuery(document).one("tw:dialogclosed",function(){Setting.reset(),window.location.reload()}),Dialog.close()}),!0}function b(){return jQuery(Dialog.setup(L10n.get("shareTitle"),"share list")).append(s("StoryShare")),!0}var w=null;return Object.freeze(Object.defineProperties({},{init:{value:e},start:{value:t},stow:{value:r},unstow:{value:n},setStoryElements:{value:a},hideOutlines:{value:i},showOutlines:{value:o},assembleLinkList:{value:s},alert:{value:u},jumpto:{value:l},restart:{value:c},saves:{value:d},settings:{value:p},share:{value:f},buildAutoload:{value:h},buildJumpto:{value:g},buildRestart:{value:m},buildSaves:{value:v},buildSettings:{value:y},buildShare:{value:b},isOpen:{value:function(){return Dialog.isOpen.apply(Dialog,arguments)}},body:{value:function(){return Dialog.body()}},setup:{value:function(){return Dialog.setup.apply(Dialog,arguments)}},addClickHandler:{value:function(){return Dialog.addClickHandler.apply(Dialog,arguments)}},open:{value:function(){return Dialog.open.apply(Dialog,arguments)}},close:{value:function(){return Dialog.close.apply(Dialog,arguments)}},resize:{value:function(){return Dialog.resize()}},buildDialogAutoload:{value:h},buildDialogJumpto:{value:g},buildDialogRestart:{value:m},buildDialogSaves:{value:v},buildDialogSettings:{value:y},buildDialogShare:{value:b},buildLinkListFromPassage:{value:s}}))}(),LoadScreen=function(){function e(){jQuery(document).on("readystatechange.SugarCube",function(){if(!(o.size>0)){var e=jQuery(document.documentElement);"complete"===document.readyState?e.hasClass("init-loading")&&(Config.loadDelay>0?setTimeout(function(){return e.removeClass("init-loading")},Math.max(Engine.minDomActionDelay,Config.loadDelay)):e.removeClass("init-loading")):e.addClass("init-loading")}})}function t(){jQuery(document).off("readystatechange.SugarCube"),o.clear(),r()}function r(){jQuery(document.documentElement).removeClass("init-loading")}function n(){jQuery(document.documentElement).addClass("init-loading")}function a(){return++s,o.add(s),n(),s}function i(e){if(null==e)throw new Error("LoadScreen.unlock called with a null or undefined ID");o.has(e)&&o.delete(e),0===o.size&&jQuery(document).trigger("readystatechange")}var o=new Set,s=0;return Object.freeze(Object.defineProperties({},{init:{value:e},clear:{value:t},hide:{value:r},show:{value:n},lock:{value:a},unlock:{value:i}}))}(),version=Object.freeze({title:"SugarCube",major:2,minor:16,patch:0,prerelease:null,build:7903,date:new Date("2017-03-14T20:35:33.734Z"),extensions:{},toString:function(){var e=this.prerelease?"-"+this.prerelease:"";return this.major+"."+this.minor+"."+this.patch+e+"+"+this.build},short:function(){var e=this.prerelease?"-"+this.prerelease:"";return this.title+" (v"+this.major+"."+this.minor+"."+this.patch+e+")"},long:function(){return this.title+" v"+this.toString()+" ("+this.date.toUTCString()+")"}}),TempState={},macros={},postdisplay={},postrender={},predisplay={},prehistory={},prerender={},session=null,settings={},setup={},storage=null,browser=Browser,config=Config,has=Has,History=State,state=State,tale=Story,TempVariables=State.temporary;window.SugarCube={},jQuery(function(){try{var e=LoadScreen.lock();LoadScreen.init(),document.normalize&&document.normalize(),Story.load(),storage=SimpleStore.create(Story.domId,!0),session=SimpleStore.create(Story.domId,!1),Dialog.init(),UI.init(),Story.init(),L10n.init(),session.has("rcWarn")||"cookie"!==storage.name||(session.set("rcWarn",1),window.alert(L10n.get("warningNoWebStorage"))),Save.init(),Setting.init(),Macro.init(),Engine.start(),UI.start(),window.SugarCube={Browser:Browser,Config:Config,Dialog:Dialog,DebugView:DebugView,Engine:Engine,Has:Has,L10n:L10n,Macro:Macro,Passage:Passage,Save:Save,Scripting:Scripting,Setting:Setting,SimpleAudio:SimpleAudio,State:State,Story:Story,UI:UI,Util:Util,Wikifier:Wikifier,macros:macros,session:session,settings:settings,setup:setup,storage:storage,version:version},LoadScreen.unlock(e)}catch(e){return LoadScreen.clear(),Alert.fatal(null,e.message,e)}})}(window,window.document,jQuery);}
 	</script>
 </body>
 </html>
diff --git a/src/events/intro/initNationalities.tw b/src/events/intro/initNationalities.tw
index d908e7326e9ab872b9b68f297594bce23f2f5a87..e6d130551b4a2739884096e104ee7cfa7ab57ba3 100644
--- a/src/events/intro/initNationalities.tw
+++ b/src/events/intro/initNationalities.tw
@@ -65,7 +65,7 @@
 /* SET HEROES */
 
 <<set $heroSlaves = []>>
-<<set $activeSlave to {slaveName: "blank", birthName: "blank", weekAcquired: 1, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), actualAge: 18, visualAge: 18, physicalAge: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race: "white", markings: "none", eyes: 1, eyeColor: "brown", eyewear: "none", hColor: "brown", pubicHColor: "brown", skin: "light", hLength: 60, hStyle: "short", pubicHStyle: "neat", waist: 0, corsetPiercing: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 0, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 0, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "normal", tonguePiercing: 0, vagina: 0, vaginaLube: 0, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregSource: 0, pregType: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 0, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, balls: 0, scrotum: 0, ovaries: 0, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules:"restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", buttplug: "none", intelligence: 0,  intelligenceImplant: 0, energy: 50, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, publicCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customImage: 0, currentRules: [], bellyTat: 0, induce: 0, mpreg: 0, inflation: 0, inflationType: 0, inflationMethod: 0, milkSource: 0, cumSource: 0, burst: 0, bellyImplant: 0, bellySag: 0, birthsTotal: 0, pubertyAgeXX: 13, pubertyAgeXY: 13, father: 0, mother: 0, daughters: 0, sisters: 0, canRecruit: 0, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none"}>>
+<<set $activeSlave to {slaveName: "blank", birthName: "blank", weekAcquired: 1, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), actualAge: 18, visualAge: 18, physicalAge: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race: "white", markings: "none", eyes: 1, eyeColor: "brown", eyewear: "none", hColor: "brown", pubicHColor: "brown", skin: "light", hLength: 60, hStyle: "short", pubicHStyle: "neat", waist: 0, corsetPiercing: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 0, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 0, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "normal", tonguePiercing: 0, vagina: 0, vaginaLube: 0, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregSource: 0, pregType: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 0, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, balls: 0, scrotum: 0, ovaries: 0, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules:"restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", buttplug: "none", intelligence: 0,  intelligenceImplant: 0, energy: 50, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, publicCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customImage: 0, currentRules: [], bellyTat: 0, induce: 0, mpreg: 0, inflation: 0, inflationType: 0, inflationMethod: 0, milkSource: 0, cumSource: 0, burst: 0, bellyImplant: 0, bellySag: 0, birthsTotal: 0, pubertyAgeXX: 13, pubertyAgeXY: 13, father: 0, mother: 0, daughters: 0, sisters: 0, canRecruit: 0, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none", readyLimbs: []}>>
 <<if ($seeDicks > 0) && ($seeDicks < 100)>>
 	<<display "D Slaves Database">>
 	<<display "DD Slaves Database">>
diff --git a/src/gui/Encyclopedia/encyclopedia.tw b/src/gui/Encyclopedia/encyclopedia.tw
index 4f15a7ad77edcb39df9adf7e95f2dcff9b87f26c..870d7d4507d519c9b34938a23074e97f2a0da997 100644
--- a/src/gui/Encyclopedia/encyclopedia.tw
+++ b/src/gui/Encyclopedia/encyclopedia.tw
@@ -1276,7 +1276,7 @@ Slaves' ''health'' is extremely important. It can be reduced by tough assignment
 ''Trust'' is a measure of a slave's expectations of the player character, and secondarily, how confident she is of her ability to do well. (Low Trust is also referred to as fear.) Along with [[Devotion|Encyclopedia][$encyclopedia to "Devotion"]], it is the main measure of a slave's mental state. A highly trusting slave is often more expensive to keep, but will do better in a leadership position and is more valuable. Slaves who are not intended for special assignments or resale can usually be kept terrified. Trust is negative if a slave is not sufficiently devoted: in this case, she will not obey since she neither likes nor fears the player character. Many game mechanics can effect Trust in some way: @@color:mediumaquamarine;aquamarine text@@ text indicates a Trust gain, while @@color:gold;gold@@ indicates a Trust loss. Maximized or minimized Trust is somewhat sticky: lightly abusing a perfectly trusting slave will not damage Trust, while minor confidence boosts will not affect an abjectly terrified slave. Extremely high Trust will boost Devotion weekly, and any Trust gains that push it over its maximum value will overflow into Devotion. If both are maximized, the slave's sex drive is increased. If she's already a nympho, Reputation is increased instead.
 \
 <<case "Relationships">>\
-Slaves can develop many different ''relationships'' as they become accustomed to their lives, which offer many benefits and some downsides. It is possible for the player to push slaves towards one kind of relationship or another, but slaves' feelings are less suceptible to complete control than their bodies. All relationships in Free Cities are one-to-one, which is a limitation imposed by Twine.
+Slaves can develop many different ''relationships'' as they become accustomed to their lives, which offer many benefits and some downsides. It is possible for the player to push slaves towards one kind of relationship or another, but slaves' feelings are less susceptible to complete control than their bodies. All relationships in Free Cities are one-to-one, which is a limitation imposed by Twine.
 \
 <<case "Rivalries">>\
 ''Rivalries'' tend to arise naturally between slaves on the same assignment. Slaves may enjoy rivals' misfortunes, but bickering on the job between rivals will impede performance if the rivals remain on the same assignment. Rivals will also dislike working with each other. Rivalries may be defused naturally with time apart, or suppressed by rules. Rivalries impede the formation of [[Romances|Encyclopedia][$encyclopedia to "Romances"]], but a Romance can defuse a Rivalry.
@@ -1358,7 +1358,7 @@ Sexual ''maliciousness'' is a paraphilia, an intense form of sexual [[Flaw|Encyc
 Sexual ''self hatred'' is a paraphilia, an intense form of sexual [[Flaw|Encyclopedia][$encyclopedia to "Flaws"]] that cannot be softened. [[Masochists|Encyclopedia][$encyclopedia to "Masochists"]] serving in an industrialized [[Dairy|Encyclopedia][$encyclopedia to "Dairy"]], in an [[Arcade|Encyclopedia][$encyclopedia to "Arcade"]], or in a [[glory hole|Encyclopedia][$encyclopedia to "Glory Hole"]] may become self hating. They can be satisfied by work in an industrialized Dairy, in an Arcade, or in a glory hole; or by extremely low [[Trust|Encyclopedia][$encyclopedia to "trust"]]. Self hating slaves will not suffer negative mental effects from serving in an industrialized Dairy, in an Arcade, or in a glory hole.
 \
 <<case "Self Neglect">>
-Sexual ''self neglect'' is a paraphilia, an intense form of sexual [[Flaw|Encyclopedia][$encyclopedia to "Flaws"]] that cannot be softened. [[Submissives|Encyclopedia][$encyclopedia to "Submissives"]] serving on public sexual assigment may become sexually self neglectful. Such slaves can be satisfied by most kinds of sex work. Slaves willing to neglect their own pleasure do very well at [[Whoring|Encyclopedia][$encyclopedia to "Whoring"]].
+Sexual ''self neglect'' is a paraphilia, an intense form of sexual [[Flaw|Encyclopedia][$encyclopedia to "Flaws"]] that cannot be softened. [[Submissives|Encyclopedia][$encyclopedia to "Submissives"]] serving on public sexual assignment may become sexually self neglectful. Such slaves can be satisfied by most kinds of sex work. Slaves willing to neglect their own pleasure do very well at [[Whoring|Encyclopedia][$encyclopedia to "Whoring"]].
 \
 <<case "Breeding Obsession">>
 ''Breeding obsession'' is a paraphilia, an intense form of sexual [[Flaw|Encyclopedia][$encyclopedia to "Flaws"]] that cannot be softened. [[Pregnancy Fetishists|Encyclopedia][$encyclopedia to "Pregnancy Fetishists"]] who are repeatedly bred or are serving in an industrialized [[Dairy|Encyclopedia][$encyclopedia to "Dairy"]] may develop breeding obsessions. They can be satisfied by pregnancy. Slaves with breeding obsessions will not suffer negative mental effects from serving in an industrialized Dairy that keeps them pregnant.
diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw
index 8f751154684c3bdf0da5995a7000f9bdbb696ca4..b80989807082d87f89e932a1e89c37364b7ef3cc 100644
--- a/src/init/storyInit.tw
+++ b/src/init/storyInit.tw
@@ -1387,7 +1387,7 @@ DairyRestraintsSetting($dairyRestraintsSetting)
 <<set $nextLink to "EW Slaves">>
 
 <<set $customSlaveOrdered = 0>>
-<<set $customSlave to {slaveName: "custom", birthName: "custom", weekAcquired: 1, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), age: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race:"white", markings: "none", eyes: 1, eyeColor: "brown", hColor: "brown", pubicHColor: "brown", skin: 0, hLength: 60, hStyle: 0, pubicHStyle: "neat", waist: 0, corsetPiercing: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 500, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 2, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "no default setting", tonguePiercing: 0, vagina: 1, vaginaLube: 0, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregType: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 1, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, balls: 0, scrotum: 0, ovaries: 1, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules:"restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", buttplug: "none", intelligence: 0,  intelligenceImplant: 0, energy: 50, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customImage: 0, currentRules: [], bellyTat: 0, induce: 0, mpreg: 0, inflation: 0, inflationType: "none", inflationMethod: 0, milkSource: 0, cumSource: 0, burst: 0, bellyImplant: 0, bellySag: 0, birthsTotal: 0, pubertyAgeXX: 13, pubertyAgeXY: 13, actualAge: 18, visualAge: 18, physicalAge: 18, mother: 0, father: 0, sisters: 0, daughters: 0, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none"}>>
+<<set $customSlave to {slaveName: "custom", birthName: "custom", weekAcquired: 1, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), age: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race:"white", markings: "none", eyes: 1, eyeColor: "brown", hColor: "brown", pubicHColor: "brown", skin: 0, hLength: 60, hStyle: 0, pubicHStyle: "neat", waist: 0, corsetPiercing: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 500, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 2, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "no default setting", tonguePiercing: 0, vagina: 1, vaginaLube: 0, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregType: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 1, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, balls: 0, scrotum: 0, ovaries: 1, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules:"restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", buttplug: "none", intelligence: 0,  intelligenceImplant: 0, energy: 50, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customImage: 0, currentRules: [], bellyTat: 0, induce: 0, mpreg: 0, inflation: 0, inflationType: "none", inflationMethod: 0, milkSource: 0, cumSource: 0, burst: 0, bellyImplant: 0, bellySag: 0, birthsTotal: 0, pubertyAgeXX: 13, pubertyAgeXY: 13, actualAge: 18, visualAge: 18, physicalAge: 18, mother: 0, father: 0, sisters: 0, daughters: 0, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none", readyLimbs: []}>>
 
 <<set $huskSlaveOrdered = 0>>
 <<set $huskSlave = {age: 18, nationality: "slave", race: "white", sex: 1, virgin: 0}>>
diff --git a/src/js/accordianJS.tw b/src/js/accordianJS.tw
index b08ece1e15e002a34223e1136d060def95eb0b26..bf2c993036737a272fff62c5e8675670888ee312 100644
--- a/src/js/accordianJS.tw
+++ b/src/js/accordianJS.tw
@@ -15,11 +15,11 @@
 */
 
 postdisplay["doAccordionSet"] = function (content) {
-    if (variables().useAccordion == 1) {
-        Array.prototype.slice.call(document.querySelectorAll('.macro-display'))
-        .forEach(function(element) {
-            element.classList.add('accHidden');
-        });
+    if (variables().useAccordion === 1) {
+        Array.prototype.slice.call(document.querySelectorAll(".macro-display"))
+            .forEach(function (element) {
+                element.classList.add("accHidden");
+            });
     }
 }
 
@@ -27,16 +27,16 @@ postdisplay["doAccordion"] = function (content) {
     var acc = document.getElementsByClassName("accordion");
     var i;
 
-    for (i = 0; i < acc.length; i++) {
-        acc[i].onclick = function() {
+    for (i = 0; i < acc.length; i += 1) {
+        acc[i].onclick = function () {
             this.classList.toggle("active");
             var panel = this.nextElementSibling;
-            if (panel.style.maxHeight){
+            if (panel.style.maxHeight) {
                 panel.style.maxHeight = null;
             } else {
                 panel.style.maxHeight = panel.scrollHeight + "px";
-            } 
-        }
+            }
+        };
     }
-}
+};
 
diff --git a/src/npc/databases/cheatmodeDatabase.tw b/src/npc/databases/cheatmodeDatabase.tw
index 10dd3b9cac0c555c17019326bf585380befc004e..8d3fb2dfc514f9db35fb9f9adf22c94a76df66f7 100644
--- a/src/npc/databases/cheatmodeDatabase.tw
+++ b/src/npc/databases/cheatmodeDatabase.tw
@@ -1,6 +1,6 @@
 :: Cheatmode Database [nobr]
 
-<<set $activeSlave to {slaveName: "blank", birthName: "blank", weekAcquired: 1, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), actualAge: 18, physicalAge: 18, visualAge: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race: "white", markings: "none", eyes: 1, eyeColor: "brown", eyewear: "none", hColor: "brown", pubicHColor: "brown", skin: "light", hLength: 60, hStyle: "short", pubicHStyle: "neat", waist: 0, corsetPiercing: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 0, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 0, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "normal", tonguePiercing: 0, vagina: 0, vaginaLube: 0, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregSource: 0, pregType: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 0, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, balls: 0, scrotum: 0, ovaries: 0, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules:"restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", buttplug: "none", intelligence: 0,  intelligenceImplant: 0, energy: 50, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, publicCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customImage: 0, currentRules: [], father: 0, mother: 0, sisters: 0, daughters: 0, canRecruit: 0, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none"}>>
+<<set $activeSlave to {slaveName: "blank", birthName: "blank", weekAcquired: 1, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), actualAge: 18, physicalAge: 18, visualAge: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race: "white", markings: "none", eyes: 1, eyeColor: "brown", eyewear: "none", hColor: "brown", pubicHColor: "brown", skin: "light", hLength: 60, hStyle: "short", pubicHStyle: "neat", waist: 0, corsetPiercing: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 0, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 0, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "normal", tonguePiercing: 0, vagina: 0, vaginaLube: 0, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregSource: 0, pregType: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 0, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, balls: 0, scrotum: 0, ovaries: 0, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules:"restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", buttplug: "none", intelligence: 0,  intelligenceImplant: 0, energy: 50, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, publicCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customImage: 0, currentRules: [], father: 0, mother: 0, sisters: 0, daughters: 0, canRecruit: 0, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none", readyLimbs: []}>>
 
 <<set _HS = clone($activeSlave)>>
 <<set _HS.slaveName = "Miss Anne", _HS.birthName = "Lindy Anne", _HS.ID = 990000, _HS.relation = "mother", _HS.relationTarget = 990004, _HS.relationship = 4, _HS.relationshipTarget = 990001, _HS.rivalry = 1, _HS.rivalryTarget = 990002, _HS.assignment = "be your Head Girl", _HS.birthWeek = random(0,51), _HS.actualAge = 42, _HS.physicalAge = 42, _HS.visualAge = 42, _HS.ageImplant = 1, _HS.health = 50, _HS.devotion = 100, _HS.height = 175, _HS.eyeColor = "green", _HS.hColor = "honey blonde", _HS.skin = "pale", _HS.hStyle = "long", _HS.waist = 1, _HS.boobs = 1000, _HS.boobsImplant = 600, _HS.areolae = 1, _HS.butt = 4, _HS.buttImplant = 2, _HS.face = 2, _HS.lips = 35, _HS.vagina = 2, _HS.anus = 1, _HS.ovaries = 1, _HS.makeup = 1, _HS.nails = 1, _HS.earPiercing = 1, _HS.vaginalSkill = 100, _HS.oralSkill = 100, _HS.analSkill = 100, _HS.whoreSkill = 100, _HS.entertainSkill = 100, _HS.clothes = "a slave gown", _HS.intelligence = 3, _HS.energy = 65, _HS.attrXY = 40, _HS.fetishKnown = 1, _HS.customTat = "'Miss Anne' is tattooed in lovely flowing script over her collarbone.", _HS.customDesc = "She speaks with the rich accent of the Old South.">>
diff --git a/src/npc/fFeelings.tw b/src/npc/fFeelings.tw
index 92c74691d80c0e44b787ffc77d7dfb64d02cd98e..583d687c20ddcbafc4b4fc0e26cbd7e0c131957d 100644
--- a/src/npc/fFeelings.tw
+++ b/src/npc/fFeelings.tw
@@ -57,7 +57,7 @@
 	<<if canTalk($activeSlave) == false>>
 		She makes a simple gesture, meaning "I love you." She continues to sign<<if $activeSlave.accent == 3>>, using gestures to supplant her poor $language<</if>>:
 	<<else>>
-		"I love you," she <<says>> in her <<if ($activeSlave.voice == 1)>>deep<<elseif ($activeSlave.voice == 2)>>pretty<<else>><<if ($activeSlave.voiceImplant == 1)>>high bimbo<<else>>girly<</if>><</if>> voice.
+		"I love you," she <<say>>s in her <<if ($activeSlave.voice == 1)>>deep<<elseif ($activeSlave.voice == 2)>>pretty<<else>><<if ($activeSlave.voiceImplant == 1)>>high bimbo<<else>>girly<</if>><</if>> voice.
 	<</if>>
 <</if>>
 
@@ -362,7 +362,7 @@ My favorite part of my body i<<s>>
 			<<if $PC.vagina == 1>>Um, and your vagina, too.<</if>>
 		<</if>>
 	<<elseif ($activeSlave.fetish == "buttslut") && ($activeSlave.fetishStrength > 60)>>
-		<<if $PC.dick == 1>>I love your cock, <<Master>>," she <<says>>	eagerly. "I love it in my backdoor.<</if>>
+		<<if $PC.dick == 1>>I love your cock, <<Master>>," she <<say>>s	eagerly. "I love it in my backdoor.<</if>>
 	<<elseif ($activeSlave.fetish == "pregnancy") && ($activeSlave.fetishStrength > 60)>>
 		<<if $PC.boobs == 1>>You, uh." She looks down, hesitating. "You have really ni<<c>>e breast<<s>>, <<Master>>.<</if>>
 	<<elseif ($activeSlave.fetish == "boobs") && ($activeSlave.fetishStrength > 60)>>
diff --git a/src/pregmod/pregmodWidgets.tw b/src/pregmod/pregmodWidgets.tw
index 009e833121c57eb0d5b294835c76a7ec48d877ff..8d789be5d6dc2b3a2811e469ddeef204de960d51 100644
--- a/src/pregmod/pregmodWidgets.tw
+++ b/src/pregmod/pregmodWidgets.tw
@@ -118,6 +118,9 @@
 <<if ndef $args[0].pregControl>>
 	<<set $args[0].pregControl = "none">>
 <</if>>
+<<if ndef $args[0].readyLimbs>>
+	<<set $args[0].readyLimbs = []>>
+<</if>>
 
 <<if ndef $args[0].pubertyXX>>
 	<<if $args[0].physicalAge >= $args[0].pubertyAgeXX>>
diff --git a/src/uncategorized/RESSTR.tw b/src/uncategorized/RESSTR.tw
index f9f5cfd47ad8e4edca98a274edb81afe814bc3b1..b756545b68bc5ad3842fc56678f4000e2b8b6b33 100644
--- a/src/uncategorized/RESSTR.tw
+++ b/src/uncategorized/RESSTR.tw
@@ -10,106 +10,28 @@
 
 <<switch $RESSTRevent>>
 
-<<case "gaped asshole">>
+<<case "comfortable seat">>
 
-You encounter <span id="name"><<print "[[$activeSlave.slaveName|Long Slave Description][$nextLink to passage(), $eventDescription to 1]]">></span> at the beginning of her day, as she finishes her morning ablutions and heads off to <<if $activeSlave.clothes != "no clothing">>get dressed<<else>>her assignment, since she's not allowed clothes and therefore doesn't need to dress<</if>>. She seems happy today, and her $activeSlave.skin body glows with warmth and cleanliness from the hot shower. When she sees you, she greets you properly, yet positively, smiling at you and <<if $activeSlave.boobs > 3000>>presenting her enormous breasts<<elseif $activeSlave.lips > 70>>pursing her huge lips<<elseif $activeSlave.boobs > 800>>bouncing her big breasts<<elseif $activeSlave.lips > 20>>pursing her pretty lips<<else>>sticking out her chest<</if>> in an automatic gesture of easy sexual availability. Suddenly, she remembers something, and looks thoughtful. Since she's so trusting, she asks you the question that just occurred to her.
+There are sturdy leather seats placed strategically throughout your penthouse. They offer something convenient to bend your slaves over, wherever you happen to encounter them, and they're comfortable, too. At the moment, you're sitting on one, using a tablet to take care of some business that caught you away from your office, but isn't worth heading back to your desk for. Slaves move by your impromptu throne as you work, mostly <<if $averageTrust > 50>>greeting you cheerfully<<elseif $averageTrust > 20>>greeting you properly<<elseif $averageTrust > -20>>doing their best to greet you properly<<elseif $averageTrust > -50>>greeting you fearfully<<else>>struggling to greet you through their terror<</if>> as they pass. Busy, you spare few of them more than a glance.
 <br><br>
-"<<Master>>," she <<say>>s, "may I have my a<<ss>>hole tightened?"
+One of them slows as she goes by, however. Looking up, you see that it's <span id="name"><<print "[[$activeSlave.slaveName|Long Slave Description][$nextLink to passage(), $eventDescription to 1]]">></span>. <<if canTalk($activeSlave)>>"Hi <<Master>>," she says flirtily. "That look<<s>> like a really comfortable <<s>>eat. Can I <<s>>it down and re<<s>>t for a little while?"<<else>>She greets you properly, but adds a flirtiness to her gestures, and asks if she can sit down and rest on the comfortable seat for a little while.<</if>> She is not pointing at the soft leather cushion next to you: she's pointing at your crotch.
 <br><br>
-There's no trace of awareness on her face of the open lewdness of the question; she's <<if $activeSlave.career == "a bioreactor">>spent time in an industrial Dairy with a phallus the size of a horse's pounding her ass day and night<<elseif ($activeSlave.career == "a slave") || ($week-$activeSlave.weekAcquired > 50)>>been a sex slave so long that she's completely internalized the idea of her ass being a sex organ<<elseif $activeSlave.analCount > 2000>>had her ass fucked so many times that she thinks of it as an inherently sexy thing<<else>>so devoted to you that she's made a conscious effort to think of her ass as sexy<</if>>. She continues in her <<if $activeSlave.voice == 1>>deep<<elseif $activeSlave.voice == 2>>soft<<else>>bubblegum bimbo's<</if>> voice, <<say>>ing, "It'<<s>> not //bad.// It'<<s>> ea<<s>>y to take anything up it. And when I walk I can feel my anal <<s>>lit sort of working around back there, which is kind of fun. But I wa<<s>> just thinking, a<<s>> I was washing my a<<ss>>pu<<ss>>y. It'd be ni<<c>>e
-<<switch $activeSlave.fetish>>
-<<case "submissive">>
-	to feel ju<<s>>t a little afraid when I'm on my fa<<c>>e and about to get fucked.
-<<case "cumslut">>
-	to be able to keep loads of cum in my a<<ss>> for later, in<<s>>tead of having them ju<<s>>t drip right out.
-<<case "buttslut">>
-	to be able to feel a little more <<s>>en<<s>>ation back there again. Butt<<s>>ex is <<s>>till fun and ab<<s>>olutely my favorite thing, but I remember it being even better.
-<<case "masochist">>
-	if I could feel anal pain again. That burning feeling u<<s>>ed to be one of my favorite<<s>>.
-<<default>>
-	to be able to be a better anal lover. I do my be<<s>>t, but I can't <<s>>queeze very well any more.
-<</switch>>
-May I?" She spins, bending at the waist<<if $activeSlave.butt > 6>> and prising her monstrous buttocks apart<<elseif $activeSlave.butt > 3>> spreading her healthy buttocks<</if>> to reveal her gaping anus. It could indeed benefit from surgical repair.
-
-<<case "passing declaration">>
-
-As you manage your empire from your office, a constant traffic of slaves passes by its door. The glass walls allow a good view of them, and since you naturally own what you find appealing, the passing girls often draw your eye. For example, this morning you notice <span id="name"><<print "[[$activeSlave.slaveName|Long Slave Description][$nextLink to passage(), $eventDescription to 1]]">></span> almost bounce into view. She's physically fit, at a healthy weight, <<if $activeSlave.physicalAge > 35>>and is getting such excellent modern medical care that despite her age, she has the energy of a teenager<<elseif $activeSlave.physicalAge > 19>>is full of youth and vigor, and is in truly perfect health due to the miracles of modern medicine<<else>>and is a teenager, not to mention the perfect health she owes to the miracles of modern medicine<</if>>. <<if $activeSlave.energy > 95>>Apart from her absurd sex drive<<elseif $activeSlave.energy > 40>>In addition to her very healthy libido<<else>>Despite her mediocre libido<</if>>, she's overflowing with energy. She half-runs, half-skips down the hallway, slowing in the doorway as she feels your gaze. Without stopping, she turns to meet your eyes, winks trustingly, and bursts out, "Hi <<Master>>! Love you!" Then she continues on her merry way.
-<br><br>
-Someone's a happy $desc today.
-
-<<case "ara ara">>
-
-Passing by the kitchen in the morning, you take a moment to listen to the low hum of your slaves chatting as they <<if $feeder != 0>>wait their turn at the phallic feeders<<else>>drink their breakfasts<</if>>. <span id="name"><<print "[[$activeSlave.slaveName|Long Slave Description][$nextLink to passage(), $eventDescription to 1]]">></span> is nearest the door, and you overhear her <<if $activeSlave.voice == 1>>low<<elseif $activeSlave.voice == 2>>pretty<<else>>high<</if>> voice clearly as she expresses confusion to another slave. "I don't under<<s>>tand it," she <<say>>s. Why are so many men intere<<s>>ted in an old <<s>>lave like me? I never got thi<<s>> much attention when I wa<<s>> free! Now <<if $activeSlave.assignment == "whore">>guy<<s>> line up to pay<<else>>every guy I approach want<<s>><</if>> to fuck me!"
-<br><br>
-<<if $arcologies[0].FSMaturityPreferentialist != "unset">>
-	"It's different here," the other slave explains. "Almost everyone here has a thing for older women. MILFs get all the attention."
-<<elseif ($arcologies[0].FSGenderRadicalist != "unset") && ($activeSlave.dick > 0)>>
-	<<if $activeSlave.vagina > -1>>
-		"Well, you're a futa," the other slave explains. "A chick with a dick. Everyone here is going to want to fuck you, since you've got both."
-	<<elseif $activeSlave.balls > 0>>
-		"Well, I bet you cum when they fuck you," the other slave explains. "They love it when you do that here."
-	<<else>>
-		"You've got a soft girldick," the other slave explains. "That's like an advertisement that you love it up the butt, here."
-	<</if>>
-<<elseif ($arcologies[0].FSAssetExpansionist != "unset") && ($activeSlave.boobs > 4000)>>
-	"It's your boobs," the other slave explains. "There's no such thing as too big, here. Everyone who sees your boobs here is going to want to fuck you."
-<<elseif ($arcologies[0].FSTransformationFetishist != "unset") && ($activeSlave.boobsImplant > 1000)>>
-	"It's your fake tits," the other slave explains. "They love how fake they look, here. If you look like a bimbo, they don't care if you're a little mature."
-<<elseif ($arcologies[0].FSSlimnessEnthusiast != "unset") && ($activeSlave.boobs < 800) && ($activeSlave.butt < 3)>>
-	"You're so slim," the other slave explains. "Everyone here loves slender girls. They don't care that you're a little mature; they think you're hot."
-<<elseif ($arcologies[0].FSBodyPurist != "unset") && ($activeSlave.boobsImplant == 0) && ($activeSlave.health > 50)>>
-	"It's how healthy you are, and your natural boobs," the other slave explains. "You look good and natural, and everyone likes that here, especially if you're mature."
-<<elseif $activeSlave.face > 2>>
-	"It might have something to do with how incredibly beautiful you are," the other slave explains sarcastically. "Come on, you could be a model. Of course they want you."
-<<elseif $activeSlave.boobs > 4000>>
-	"It might have something to do with the fact that your tits are bigger than your head," the other slave explains sarcastically. "You look like a teenager's wet dream."
-<<elseif $activeSlave.face > 0>>
-	"You're very pretty," the other slave explains reassuringly. "Come on, you are. It's not surprising that guys want you."
-<<else>>
-	"Is it really that surprising?" the other slave asks rhetorically. "Guys like sex. You're sex. Why shouldn't they like you? I bet fucking you feels great."
-<</if>>
-There's a pause, and then the other slave continues in a more serious tone, asking, "You're not, like, unhappy with that, are you? It's really good for a slave to be in demand, you know."
-<br><br>
-"Oh no, I didn't mean it like that," replies $activeSlave.slaveName hurriedly.
-<<if $activeSlave.energy > 80>>
-	"I'm <<s>>o horny all the time, it'<<s>> good. I'd probably go crazy if I didn't get that much attention. Whenever anyone'<<s>> done with me I can't wait for the next.
-<<elseif $activeSlave.fetish == "humiliation">>
-	"It's embarra<<ss>>ing, but I, um, really like being <<s>>o popular in public, um, like that. Where everyone can <<s>>ee.
-<<elseif $activeSlave.devotion > 50>>
-	"I really want to do well, and it feel<<s>> good that I'm able to help.
-<<elseif $activeSlave.devotion > 20>>
-	"I, um, know I have to. And it'<<s>> not bad, I mean, it'<<s>> okay.
+You're nude, a consequence of <<if $Concubine != 0>>recent activities involving $Concubine.slaveName<<else>>recent unrelated activities<</if>>. <<if $PC.dick == 1>>Your formidable dick is three quarters hard,<<else>>Nude, that is, all except for the strap-on you were just using and haven't taken off yet,<</if>> and $activeSlave.slaveName is pointing right at it. She knows exactly what she's asking for and gives her <<if $activeSlave.hips > 0>>broad<<elseif $activeSlave.hips > -1>>trim<<else>>narrow<</if>> hips a little wiggle to make it even more abundantly clear.
+<<if ($eventSlave.dickAccessory == "chastity")>>
+	Her poor dick is visibly straining against the restrictive chastity belt she's wearing.
+<<elseif canAchieveErection($activeSlave)>>
+	Her <<if $activeSlave.dick > 4>>big dick<<elseif $activeSlave.dick > 2>>dick<<else>>tiny dick<</if>> is jutting out stiffly and there's a bead of precum <<if $activeSlave.foreskin == 0>>forming at its smooth tip<<else>>escaping from her foreskin<</if>>.
+<<elseif $activeSlave.dick > 0>>
+	Her <<if $activeSlave.dick > 4>>big dick<<elseif $activeSlave.dick > 2>>dick<<else>>tiny dick<</if>> is as soft as ever, but there's a string of precum running between <<if $activeSlave.foreskin == 0>>its smooth tip<<else>>the soft foreskin that completely covers its tip<</if>> and her inner thigh.
+<<elseif $activeSlave.clit > 0>>
+	Her <<if $activeSlave.clit > 1>>formidable<<else>>big<</if>> clit is visibly erect. <<if $activeSlave.clitPiercing > 1>>Her sizeable clit piercing never lets its hood completely cover hide her bitch button, but it's completely retracted now,<<else>>Her delicate clitoral hood has been pushed back by her female erection,<</if>>  leaving her proudly aroused.
+<<elseif $activeSlave.labia > 0>>
+	Her <<if $activeSlave.labia > 1>>dangling<<else>>thick<</if>> labia are visibly swollen, flushing and growing prouder as the blood rushes to her womanhood.
 <<else>>
-	"I know it mean<<s>> I'm worth something. It'<<s>> rea<<ss>>uring, and I remind my<<s>>elf of it whenever I get <<s>>cared about being a <<s>>lave, you know.
+	She has a shapely womanhood, with trim labia and a demure clit, but it's a little flushed.
 <</if>>
-I didn't mean to <<s>>ound con<<c>>eited, either. I gue<<ss>> I'm <<s>>till getting u<<s>>ed to life here, that'<<s>> all. <<S>>ometime<<s>> I think like I'm not, um, here, and I'm <<s>>urpri<<s>>ed so many people want me. It's kind of ni<<c>>e, actually," she <<say>>s with some self-confidence.
-<<if $activeSlave.fetish == "humiliation">>
-<<if $activeSlave.fetishKnown == 0>>
-	It sounds like she has a @@color:lightsalmon;humiliation fetish!@@
-	<<set $activeSlave.fetishKnown == 1>>
-<</if>>
-<</if>>
-
-<<case "im scared">>
-
-During her weekly inspection, <span id="name"><<print "[[$activeSlave.slaveName|Long Slave Description][$nextLink to passage(), $eventDescription to 1]]">></span> has trouble following the routine orders that position her so you can examine her body. The cause is not difficult to determine: she's so cripplingly terrified that she's having difficulty functioning. She seems to be trying to obey you, but she's so scared that her mind is having trouble translating your simple verbal commands into physical obedience. You ask her what she's so frightened of. The question stuns her, and she stares at you in mute horror, looking even more terrified than she has up to this point and completely devoid of any idea how to respond. You order her to respond, and this starts her out of her fugue. She begins to cry, makes two false starts, sobs, and then begins forcing out words.
-<br><br>
-"E-e-everything," she cries. "I'm <<s>>-<<s>>o <<s>>-<<s>>orry b-but I c-can't help," she chokes on a sob and hiccups, "help it. This, this pla<<c>>e, being a <<s>>ex <<s>>lave,
-<<switch $activeSlave.standardPunishment>>
-<<case "confinement">>b-being sh-shut up in the d-dark
-<<case "whipping">>b-being wh-wh-whip-ped
-<<case "chastity">>h-having my p-part<<s>> locked up in ch-cha<<s>>tity
-<<default>>n-never knowing what th-the p-punishment will be
-<</switch>>
-wh-when I'm bad, e-everything, <<Master>>. Oh, oh, I'm <<s>>orry, p-plea<<s>>e, I'm <<s>>orry I, I'm like thi<<s>>, I'm crying, p-plea<<s>>e <<Master>>, plea<<s>>e don't..." She trails off, giving you a look of supplication.
-
-<<case "frightening dick">>
-
-In a fortuitous confluence of circumstances, <span id="name"><<print "[[$activeSlave.slaveName|Long Slave Description][$nextLink to passage(), $eventDescription to 1]]">></span> happens to be polishing your office one evening. Keeping every surface in the penthouse at a state of perfect shine is one of your servants' endless tasks, and your office is her area of responsibility today. At the key moment, she's working on an area at waist height, directly next to the door that leads to your suite; and she's crouching to polish this area most comfortably. She is working diligently, and is paying close attention to what she's doing. Meanwhile, and for completely unrelated reasons, you have just finished having fun inside said suite. You are naked, and your penis remains fully erect despite your having climaxed only moments before; you are in excellent physical and sexual condition and this happens frequently. You have decided to address a likewise unrelated matter in your office, and walk into it from your suite, naked and erect.
-<br><br>
-This is how $activeSlave.slaveName comes face to face with your cock, unexpectedly, at a distance of about ten centimeters.
-<br><br>
-She shrieks, backpedaling, and then falls backward, her <<if $activeSlave.butt > 6>>monstrous bottom<<elseif $activeSlave.butt > 3>>healthy rear end<<else>>cute butt<</if>> hitting the floor with an audible whack. The light cloth she was using to polish with went flying, and flutters to the ground accusingly. After scrabbling back a short distance, looking up at you hesitantly, and visibly recollecting herself, she swallows twice and then says, "I'm <<s>>orry, <<Master>>," in a tone of voice with a great deal of effort applied to keep it even. A frantic, embarrassed search for her cloth ensues. Finding it at last, she returns to her original, low position, and crouch-walks back to the place she was polishing, doing her absolute best to look diligent and industrious and not at all aware that your cock is pointing at her like a gun barrel.
+<<if $activeSlave.vaginalLube > 0>>Her wet cunt is already lubricating itself generously for you, slicking her labia with female arousal.<</if>>
+The $slaveTitle wants it badly.
 
 <<default>>
 	ERROR: bad event
@@ -119,242 +41,126 @@ She shrieks, backpedaling, and then falls backward, her <<if $activeSlave.butt >
 <span id="result">
 <<switch $RESSTRevent>>
 
-<<case "gaped asshole">>
+<<case "comfortable seat">>
 
-<<click "Give her the surgery">>
+<<click "Let her do what she wants">>
 	<<replace "#name">>$activeSlave.slaveName<</replace>>
 	<<replace "#result">>
-		You schedule her for the surgery. Like all invasive procedures, it @@color:red;affects her health,@@ but @@color:lime;she's effectively an anal virgin again.@@ She @@color:mediumaquamarine;trusts you a bit more@@ for granting her request, and is eager for buttsex that's more interesting than having a hotdog thrown down her hallway.
-		<<set $activeSlave.trust += 3, $activeSlave.health -= 10, $activeSlave.anus = 0, $cash -= $surgeryCost>>
-		<<if $activeSlave.analSkill > 10>><<set $activeSlave.analSkill -= 10>><</if>>
+		You tell her to sit down if she'd like to. She looks at you quizzically, <<if $activeSlave.intelligence < 0>>her dim mind slowly <</if>>realizing that you're letting her choose what to do. <<if canTalk($activeSlave)>>"Oh, thank you, <<Master>>," she <<say>>s,<<else>>She gestures her thanks,<</if>> and then makes a show of deciding. She <<if $activeSlave.intelligence < 0>>doesn't have to pretend<<else>>cheekily pretends<</if>> to be an airheaded bimbo puzzling over how she wants to approach a fuck, bouncing <<if $activeSlave.boobsImplant > 0>>her fake tits a little<<elseif $activeSlave.boobs > 4000>>her monstrous udders heavily<<elseif $activeSlave.boobs > 1000>>her heavy breasts a little<<elseif $activeSlave.boobs > 200>>her boobs a little<<else>>on her heels<</if>> and putting a finger to her slightly parted lips as she stares down at your <<if $PC.dick == 1>>stiff prick<<else>>strap-on<</if>>.
 		<br><br>
-		<span id="result2">
-			<<click "Break her in again">>
-				<<replace "#result2">>
-					Her ass is yours all over again. As soon as her newly tight rosebud has recovered enough, you visit her in the surgery, without even waiting for her to leave it. You flip her over on the recovery bed and force <<if $PC.dick == 1>>your cock<<else>>a strap-on<</if>> up her butt while she wriggles with eager discomfort, squealing in pretended horror. Her renewed anal virginity was very brief; her ass is once again @@color:lime;broken in for penetration.@@ For her part, she @@color:hotpink;thoroughly enjoyed losing her anal cherry,@@ again.
-					<<set $activeSlave.devotion += 5, $activeSlave.analCount++, $analTotal++, $activeSlave.anus = 1>>
-				<</replace>>
-			<</click>> //This option will take anal virginity//
-		</span>
-	<</replace>>
-<</click>><<if $activeSlave.vagina == 0>> //This option will take virginity//<</if>>
-<br><<click "Fill her gape">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		You announce that you can fill her just fine, and you'll make her feel it just as though she were an anal virgin again. She looks simultaneously intrigued and apprehensive, but starts to get to her knees like a good anal slut. You stop her before she can face the ground and offer you her ass. You're going to need some lubricant for this, but the $desc's saliva should be plenty. As you <<if $PC.dick == 1>>aim your dick<<else>>swiftly pull on a strap-on and aim it<</if>> at her face, she realizes that her spit is going to be the only relief her fucked-out butt is going to have for whatever you're planning. She blows you with desperate eagerness, doing her absolute best to coat your<<if $PC.dick != 1>> weapon's<</if>> shaft with as much saliva as she can. You pull it free of her mouth with a wet pop, and she immediately faces the floor, cocking her hips and spreading her huge asspussy for you.
-		<br><br>
-		After watching the way it contracts slightly as she breathes hard for a while, letting her feel the apprehension, you shove <<if $PC.dick == 1>>yourself<<else>>the phallus<</if>> inside her. She takes it without any reaction at all, and her gaped hole cups it only loosely. Grabbing her by the shoulders, you haul her torso up so it's against your <<if $PC.boobs == 1>>breasts, capped by their rock-hard nipples<<else>>muscular chest<</if>>, and push three of your fingers into her mouth. She gags, surprised, but you shove them in farther, collecting as much spit as you can reach. Then you let her fall back down again. She knows what you're going to do, and moans as you slide your fingers in alongside your <<if $PC.dick == 1>>cock<<else>>strap-on<</if>>, taking huge shuddering gasps as she feels her sphincter accommodate the abuse. Slowly, you slide your thumb in as well, pushing it around <<if $PC.dick == 1>>your stiff prick<<else>>the unyielding phallus<</if>> until you're holding it as if masturbating. And then you masturbate. Inside her ass. She begins to scream, but manages to prevent herself from resisting. She does her desperate best to take your crushing abuse of her worn-out hole, and collapses when you finally orgasm and let her go. She does her best to offer some sort of @@color:hotpink;submissive thanks,@@ but is barely coherent, and crawls off to shower again, her lewd sphincter pulsing as she goes.
-		<<set $activeSlave.devotion += 5, $activeSlave.analCount++, $analTotal++>>
-		<<EventFetish $activeSlave "buttslut">>
-		<<EventFetish $activeSlave "masochist">>
-	<</replace>>
-<</click>>
-<<if $HeadGirl != 0>>
-<br><<click "Double up on her ass with your Head Girl">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		You page $HeadGirl.slaveName for some assistance filling up a loose hole, and she comes quickly, <<if canAchieveErection($HeadGirl)>>precum already visible at the tip of her erection<<else>>bringing a strap-on<</if>>. When she arrives, it's to the sight of $activeSlave.slaveName sitting on your lap with your <<if $PC.dick == 1>>cock<<else>>strap-on<</if>> up her ridiculous anal gape, waiting for a second phallus while your hands tease her $activeSlave.nipples nipples. Seeing that backup has arrived, you lean back and shift your grip to the back of the receptacle's lower thighs, pulling her up and shifting her hips to offer your Head Girl another berth in $activeSlave.slaveName's ass. This pulls her loose sphincter up, producing a little gape above the top of your invading shaft, and $HeadGirl.slaveName loses no time in fucking it. She gives $activeSlave.slaveName a kiss, but soon breaks the lip lock, since she's more interested in making eyes at you over your mutual anal conquest's shuddering shoulder. As
-		<<if $PC.dick == 1>><<if canAchieveErection($HeadGirl)>>your dicks slide against each other<<else>>your dick slides against her strap-on<</if>><<else>><<if canAchieveErection($HeadGirl)>>your strap-on slides against her dick<<else>>your strap-ons slide against each other<</if>><</if>>, your trusty Head Girl whispers that @@color:hotpink;she loves you.@@ $activeSlave.slaveName makes an inarticulate noise of anal distress that probably means @@color:hotpink;approximately the same thing.@@
-		<<set $activeSlave.devotion += 4, $activeSlave.analCount++, $analTotal++>>
-		<<for $i to 0; $i < $slaves.length; $i++>><<if $slaves[$i].ID == $HeadGirl.ID>><<set $slaves[$i].devotion += 4>><</if>><</for>>
-		<<EventFetish $activeSlave "buttslut">>
-		<<EventFetish $activeSlave "submissive">>
-	<</replace>>
-<</click>>
-<</if>>
-
-<<case "passing declaration">>
-
-<<click "Follow her">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		Her sheer joie de vivre is irresistible, and it certainly draws you out of your office. You're not slow, and of course you know where she's going, so you catch up quickly. She gives you the careful measuring glance of a devoted sex slave who's checking whether her owner wants to fuck her right now, and correctly decides that that isn't your intent, at least right this minute. Instead, you continue the direction she was going, and she follows. "<<Master>>," she <<say>>s hesitantly, "I hope that wa<<s>> an okay thing for me to do." You assure her it was. "Thank<<s>>, <<Master>>," she beams, grinning like an idiot. Smiling at her infectious enthusiasm for life, you ask her why she's so happy this morning. She looks momentarily perplexed<<if $activeSlave.intelligence > 1>>, not a common look for a slave as smart as her<</if>>. "I don't know! I just woke up thi<<s>> morning feeling really, really good. <<if $activeSlave.intelligence > 1>>I'm sure the fact that I'm benefiting from incredibly advanced medi<<c>>ine ha<<s>> <<s>>omething to do with it; thank you very much for that, <<Master>>. Other than that,<</if>>
-		I ju<<s>>t feel happy." This has to be some sort of milestone for her, and for you, and maybe for slavery in general: if she can be this pleased with life, something must be going right. You walk her to where she's going
-		<<switch $activeSlave.assignment>>
-		<<case "whore">>(one of the arcology's nicer streets, where she'll spend the day selling her body),
-		<<case "serve the public">>(one of the arcology's nicer streets, where she'll spend the day flirting with citizens and having sex with anyone that's willing),
-		<<case "work a glory hole">>(a wall mounting that will render her a helpless target for dicks all day),
-		<<case "get milked">>(her favorite milker in the penthouse),
-		<<case "take classes">>(a quiet area with a touchscreen where she can review material from the slave etiquette class she's working on),
-		<<case "please you">>(the wardrobe, where she'll get dressed before attending to you for the rest of the day),
-		<<case "be a subordinate slave">>(the living area of the slave she's been assigned to serve),
-		<<case "be a servant">>(the closet that contains the cleaning items she'll use to dust and polish the penthouse today),
-		<<case "stay confined">>(her cell),
-		<<case "guard you">>(the armory where her weapons are kept),
-		<<case "be your Head Girl">>(the assignment location of a slave who needs some hands-on guidance from your Head Girl),
-		<<case "recruit girls">>(the camera station she uses to convince people from the old world that becoming your slave is a good idea),
-		<<default>>(a waiting area for further assignment),
-		<</switch>>
-		and when you get there, she gives you a peck on the cheek. <<if $activeSlave.height < 170>>The short $desc has to go up on tiptoe to reach.<</if>>
-		"@@color:hotpink;I really do love you,@@ <<Master>>," she <<say>>s, $activeSlave.eyeColor eyes shining.
-		<<set $activeSlave.devotion += 5>>
-	<</replace>>
-<</click>>
-<br><<click "Play with her">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		You're not a slave, so you can't understand her inner workings through direct empathy. But in your experience, a quick orgasm never fails to make a good day better. You're not slow, and of course you know where she's going, so you catch up to her on quiet feet and <<if $activeSlave.butt > 6>>set her enormous ass jiggling with a smack<<elseif $activeSlave.butt > 3>>give her womanly bottom a squeeze<<else>>pinch her cute rear<</if>>. She squeals and whirls around, <<if $activeSlave.energy > 60>>eagerly flinging herself into your arms, ready for some action<<else>>trustingly throwing herself into your arms<</if>>. Feeling spontaneous, you decide to get everyone off quickly and cleanly, right here.
-		<<switch $eventSlave.fetish>>
-		<<case "submissive">>
-			You place a dominant hand around her throat, firmly but not harshly, almost sending the submissive to her knees. Your other hand
-		<<case "cumslut">>
-			You kiss her, sliding your tongue all the way into her mouth. She melts into you, rhapsodically entranced by the intense oral stimulation, and her tongue presses against yours with frankly sexual significance. Your hand
-		<<case "humiliation">>
-			Slaves are constantly passing the two of you, and you constantly turn her to show her body to each of them, spreading her to display her most intimate parts. Her cheeks flush with arousal and delicious shame. Your hand
-		<<case "buttslut">>
-			You slide a hand all the way under her, pulling the flesh of her buttock to one side and then nestling possessive fingers over her anus, teasing and stimulating, but not penetrating. Your other hand
-		<<case "boobs">>
-			She gasps as your hot mouth finds one of her $activeSlave.nipples nipples, and then moans openly as one of your hands mauls her other breast. Your other hand
-		<<case "pregnancy">>
-			One of your hands begins to caress her<<if $activeSlave.pregnancy > 0>> pregnant<</if>> belly, worshipping its curve. Your other hand
-		<<case "dom" "sadist">>
-			You press yourself aggressively against her, and she presses back; you grind harder still, letting her know that she can let herself be a little aggressive, too. Groaning with pleasure and satisfaction, she kisses you furiously. One of your hands
-		<<case "masochist">>
-			You caress one of her nipples, bringing it completely erect before gripping it firmly. You twist it, pull it, pinch it; she moans with masochistic pleasure. Your other hand
-		<</switch>>
-		<<if $activeSlave.vagina > -1>>finds her pussy<<else>>reaches around behind her to tease her ass and play with her sensitive perineum<</if>>, and you press your groin towards her. Getting the idea, she begins to <<if $PC.dick == 1>>jack you off<<else>>finger your clit<</if>> energetically, taking the pace from your lusty demeanor and her own feeling of energy and well-being. The two of you orgasm almost together. <<if $PC.dick == 1>>You angle your hips to shoot your seed onto the floor<<else>>You climax so violently that some of your femcum makes it onto the floor<</if>>. <<if canAchieveErection($activeSlave)>>She blows her own load right after<<elseif $activeSlave.balls > 0>>Her limp dick pours cum<<elseif $activeSlave.dick > 0>>Her bitchclit produces a little watery fluid<<elseif $activeSlave.vaginalLube > 1>>She squirts copiously<<else>>Unusually for her, she manages to squirt a little<</if>>, adding to the mess. You tell her another slave will clean up, and order her to go about her business. She turns to go, @@color:mediumaquamarine;smiling with sexual satisfaction.@@
-		<<set $activeSlave.trust += 5, $activeSlave.oralCount++, $oralTotal++>>
-	<</replace>>
-<</click>>
-<br><<click "Punish her">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		That was not quite the prescribed way of greeting you, there was no need to greet you as she passed, and most importantly, she's simply too cheery. Resolving to crush her happiness, you call her back to the office in a thunderous voice you know will reach her. She knows she's made a mistake, but comes promptly, lower lip quivering. Her feelings are plain to see on her face: surprise, @@color:mediumorchid;betrayal,@@ @@color:gold;fear.@@ She thought she could be friendly, and now she knows she was wrong. What's more, she thought she could be happy, and now she's realizing that that was also wrong. As you
-		<<switch $activeSlave.standardPunishment>>
-		<<case "confinement">>close her into a confinement cell,
-		<<case "whipping">>tie her up for a brief whipping,
-		<<case "chastity">>lock her into harsh chastity,
-		<<default>>gag her for speaking out of turn,
-		<</switch>>
-		a wail of despair tears its way out of her throat, far out of proportion to the standard punishment you're applying. It's perhaps the saddest sound you've ever heard a slave make. Slaves cry all the time, but usually they already understand that happiness is out of their reach. This one just woke up thinking that she could be happy and was happy, and now she's realizing it isn't allowed.
-		<<set $activeSlave.devotion -= 10, $activeSlave.trust -= 10>>
-	<</replace>>
-<</click>><<if ($PC.dick == 1) && ((($activeSlave.anus == 0) && ($activeSlave.vagina == -1)) || ($activeSlave.vagina == 0))>> //This option will take virginity//<</if>>
-
-<<case "ara ara">>
-
-<<click "Praise her outlook">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		You speak from where you are, and without preamble, startling both slaves badly. Doing their best to recover, they listen as you tell $activeSlave.slaveName that she has a good, praiseworthy outlook on life as a sex slave.
-		<<if $activeSlave.energy > 80>>
-			Her extreme appetite for sex will serve her well. It's important to love what you do, and if she wakes up every morning wanting to get fucked, she'll enjoy her life as a <<if $activeSlave.assignment == "whore">>slave prostitute<<else>>public slut<</if>>.
-		<<elseif $activeSlave.fetish == "humiliation">>
-			She should feel lucky to have a fetish for public use. It's important to love what you do, and if being openly passed around gets her off, she'll enjoy her life as a <<if $activeSlave.assignment == "whore">>slave prostitute<<else>>public slut<</if>>.
-		<<elseif $activeSlave.devotion > 50>>
-			It's great that she's internalized her role, and wants to do well. As long as she wants to perform well and applies herself, you're confident that she'll continue to improve and become a better and more valuable slave.
-		<<elseif $activeSlave.devotion > 20>>
-			Her obedience is commendable. You understand that she struggles with her life as an involuntary sex object at times. She'll learn to do better, and as she improves, she'll be all right as long as she obeys you and does her best.
-		<<else>>
-			To describe her situation bluntly, the best possible approach for her is to obey you and do her best. There's not really any possible outcome in which slaves can lose out by doing their best to be useful and valuable. It's in her interest to do her best.
+		Finally making her decision, she
+		<<set _fucked = 0>>
+		<<if $activeSlave.fetishKnown == 1>>
+			<<switch $eventSlave.fetish>>
+			<<case "submissive">>
+				turns around and carefully perches herself on <<if $PC.dick == 1>>your cock<<else>>the phallus<</if>>,
+				<<if $canDoVaginal($activeSlave) && ($activeSlave.vagina > 0)>>
+					letting her weight slide it inside her wet pussy.
+					<<set $activeSlave.vaginalCount++, $vaginalTotal++>>
+				<<elseif $canDoAnal($activeSlave) && ($activeSlave.anus > 0)>>
+					letting her weight push it up her asshole.
+					<<set $activeSlave.analCount++, $analTotal++>>
+				<<else>>
+					putting it between her thighs.
+					<<set $activeSlave.oralCount++, $oralTotal++>>
+				<</if>>
+				She's not used to being on top, but she uses herself to service you as submissively as she can. She pays her own pleasure no attention at all,
+				<<set _fucked = 1>>
+			<<case "cumslut">>
+				squats down, coming face to face with <<if $PC.dick == 1>>your cock<<else>>the phallus<</if>>. <<if canTalk($activeSlave)>>"<<Master>>, I changed my mind about <<s>>itting," she <<say>>s<<else>>She gestures that she changed her mind about sitting<</if>>, and licks her lips sluttily. Then she gives <<if $PC.dick == 1>>you<<else>>the phallus<</if>> a lusty blowjob, humming and licking happily. <<if $PC.dick == 1>>She swallows your load hungrily,<<else>>She helps you out of the harness with your permission and eats you out too,<</if>>
+				<<set $activeSlave.oralCount++, $oralTotal++>>
+				<<set _fucked = 1>>
+			<<case "humiliation">>
+				turns around and sits on <<if $PC.dick == 1>>your cock<<else>>the phallus<</if>>, leaning back against you and making sure all the other slaves who pass by can see
+				<<if $canDoVaginal($activeSlave) && ($activeSlave.vagina > 0)>>
+					where it penetrates her cunt.
+					<<set $activeSlave.vaginalCount++, $vaginalTotal++>>
+				<<elseif $canDoAnal($activeSlave) && ($activeSlave.anus > 0)>>
+					where it's lodged up her butt.
+					<<set $activeSlave.analCount++, $analTotal++>>
+				<<else>>
+					where it's rubbing her intimately between her thighs.
+					<<set $activeSlave.oralCount++, $oralTotal++>>
+				<</if>>
+				She gets off on their looks,
+				<<set _fucked = 1>>
+			<<case "buttslut">>
+				<<if $canDoAnal($activeSlave) && ($activeSlave.anus > 0)>>
+					turns around and shivers with pleasure as she hilts her anal sphincter around the base of <<if $PC.dick == 1>>your cock<<else>>the phallus<</if>>. She bounces on it happily, reaming her own ass,
+					<<set $activeSlave.analCount++, $analTotal++>>
+					<<set _fucked = 1>>
+				<</if>>
+			<<case "boobs">>
+				squats down, placing <<if $PC.dick == 1>>your cock<<else>>the phallus<</if>> <<if $activeSlave.boobs > 4000>>in the virtual hole formed in the place between her breasts, which are so massive they rest together<<elseif $activeSlave.boobs > 1000>>in the valley between her tits<<elseif $activeSlave.boobs > 200>>between her breasts<<else>>against one of her nipples<</if>>. <<if canTalk($activeSlave)>>"<<Master>>, I changed my mind about <<s>>itting," she <<say>>s<<else>>She gestures that she changed her mind about sitting<</if>>, and starts giving you a boob job. She enjoys the breast play,
+				<<set $activeSlave.mammaryCount++, $mammaryTotal++>>
+				<<set _fucked = 1>>
+			<<case "pregnancy">>
+				<<if $canDoVaginal($activeSlave) && ($activeSlave.vagina > 0)>>
+					turns around and lovingly lowers her pussy onto you. <<if $PC.dick == 1>><<if $activeSlave.preg > 0>>She's already pregnant, so this isn't a direct satisfaction of her impregnation fetish, but being fucked while pregnant is almost as good as far as she's concerned.<<elseif canGetPregnant($activeSlave)>>This might be the moment she gets pregnant, and she's quivering with anticipations.<<else>>She knows she isn't fertile, but she's good at fantasizing.<</if>><<else>>Your strap-on might not be able to impregnate anyone, but she's good at fantasizing.<</if>> She rides you hungrily,
+					<<set $activeSlave.vaginalCount++, $vaginalTotal++>>
+					<<set _fucked = 1>>
+				<</if>>
+			<<case "dom">>
+				turns around and sits right down on <<if $PC.dick == 1>>your cock<<else>>the phallus<</if>>, eagerly
+				<<if $canDoVaginal($activeSlave) && ($activeSlave.vagina > 0)>>
+					taking it into her cunt.
+					<<set $activeSlave.vaginalCount++, $vaginalTotal++>>
+				<<elseif $canDoAnal($activeSlave) && ($activeSlave.anus > 0)>>
+					getting it shoved up her butt.
+					<<set $activeSlave.analCount++, $analTotal++>>
+				<<else>>
+					squeezing it between her thighs.
+					<<set $activeSlave.oralCount++, $oralTotal++>>
+				<</if>>
+				She loves being on top, even if she's the one who's getting fucked. She rides you happily,
+				<<set _fucked = 1>>
+			<</switch>>
 		<</if>>
-		"Yes, <<Master>>," they chorus automatically. You turn and go. $activeSlave.slaveName is taken a bit aback by your apparent omnipresence in the penthouse, but reminds herself that your guidance seemed straightforward and genuine. She's @@color:mediumaquamarine;confirmed in her understanding@@ of what it means to be a good $desc.
-		<<set $activeSlave.trust += 5>>
-	<</replace>>
-<</click>><<if ($PC.dick == 1) && (($activeSlave.anus == 0) && ($activeSlave.vagina <= -1))>> //This option will take anal virginity//<</if>>
-<br><<click "Let her know you think she's attractive, too">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		The slaves continue their gossip until $activeSlave.slaveName feels a pair of <<if $PC.title == 1>>strong<<else>>firm, feminine<</if>> hands grip the sides of her <<if $activeSlave.waist > 1>>cartoonishly narrow<<elseif $activeSlave.weight > 30>>pudgy<<elseif $activeSlave.muscle > 30>>ripped<<elseif $activeSlave.waist > 0>>wasp<<elseif $activeSlave.weight > 10>>plush<<elseif $activeSlave.muscle > 5>>toned<<elseif $activeSlave.weight >= -10>>soft<<else>>thin<</if>> waist. She starts but doesn't try to turn, and shivers as you run your hands up <<if $activeSlave.muscle > 30>>the muscles that jacket her ribs<<elseif $activeSlave.weight > 30>>the soft flesh that pads her ribs<<else>>her ribcage<</if>> and forward <<if $activeSlave.boobs > 3000>>into the soft, weighty place formed by the overhang of her massive breasts<<elseif $activeSlave.boobs > 300>>to cup her breasts<<else>>to clasp her around the sternum<</if>> and pull her back into your arms. The other slave watches silently, awaiting some cue as to whether she's to join in or return to breakfast; you give her a flick of your chin, and she turns away, leaving you with $activeSlave.slaveName, embracing among the eating slaves.
-		<br><br>
-		You whisper into her ear that you think she's attractive, <<if $PC.dick == 1>>and point out that she can feel the proof between her buttocks. You're hard, and your stiff prick is poking her in the rear. She gasps and shifts a little, and you nestle your dick even closer into the warm place between her legs and ass.<<else>>and tell her that you can prove it. You grab one of her hands and pull it around behind her, between you, making her feel your pussy. She gasps at how wet it is.<</if>> "An old <<s>>lave like me, <<Master>>?" she echoes in a small voice. An old slave like her, you confirm, and tell her that right now,
-		<<if $PC.dick == 1>>
-			<<if $activeSlave.vagina > 0>>
-				you've decided to fuck her pussy. She starts at the sudden vulgarity, even with your cock resting against the soft skin between the bottom of her vulva and her anus, and shudders with sudden pleasure as you use a hand to guide yourself inside her welcoming channel.
+		<<if _fucked == 1>>
+			and after you've <<if $PC.dick == 1>>cum<<else>>climaxed<</if>>, she @@color:mediumaquamarine;thanks you trustingly,@@ happy she's still allowed a sexy choice with you now and then.
+		<<else>>
+			<<if $activeSlave.fetishKnown == 1>>She can't really think of how to accommodate the situation to her own preferred approach to sex,<<else>>She isn't well versed in how her own sexual needs might fit into the situation,<</if>> so she just services you like a good girl. She turns around and sits on <<if $PC.dick == 1>>your cock<<else>>the phallus<</if>>,
+			<<if $canDoVaginal($activeSlave) && ($activeSlave.vagina > 0)>>
+				squatting to bounce her cunt up and down on it.
+				<<set $activeSlave.vaginalCount++, $vaginalTotal++>>
+			<<elseif $canDoAnal($activeSlave) && ($activeSlave.anus > 0)>>
+				squatting to bounce her butthole up and down on it.
+				<<set $activeSlave.analCount++, $analTotal++>>
 			<<else>>
-				her ass is yours. She starts at the sudden vulgarity, even though hearing that the cock that's pressing against her butt will be going inside it soon can't be that surprising. She cocks her hips obediently, letting you force your dick up her asshole.
+				putting it between her thighs for some intercrural sex, since her <<if $activeSlave.vagina > -1>>holes aren't<<else>>hole isn't<</if>> appropriate.
+				<<set $activeSlave.oralCount++, $oralTotal++>>
 			<</if>>
-			You take her standing,
-		<<else>>
-			some oral sex from a slave like her sounds just right. You push her to her knees and hold her mouth to your cunt, taking your pleasure from her
-			<<set $activeSlave.oralCount++, $oralTotal++>>
-		<</if>>
-		right there among your breakfasting slaves, who try to ignore you or watch with appreciation, according to their own natures. When you're finished, you <<if $PC.dick == 1>>spin her around and kiss her,<<else>>pull her up to her feet and kiss her, tasting yourself on her lips and<</if>> making sure she knows @@color:hotpink;you appreciate her mature body@@ just as much as <<if $activeSlave.assignment == "whore">>her customers do<<else>>your citizens do<</if>>.
-		<<set $activeSlave.devotion += 5>>
-		<<if $PC.dick == 1>><<if $activeSlave.vagina <= 0>><<AnalVCheck>><<else>><<set $activeSlave.vaginalCount++, $vaginalTotal++>><</if>><</if>>
-	<</replace>>
-<</click>><<if ($PC.dick == 1) && (($activeSlave.anus == 0) && ($activeSlave.vagina <= 0))>> //This option will take anal virginity//<</if>>
-
-<<case "im scared">>
-
-<<click "Punish her">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		She obviously knows that breaking down like this would displease you, but you patiently explain that it's against the rules anyway. She cries harder, nodding through her tears. She knows that interrupting you to beg would be profoundly stupid, so she clasps her hands in wordless submission. You tell her that she's to keep herself under control; if she fails, she will be punished. Since she failed, she will now suffer her standard punishment, and be
-		<<switch $activeSlave.standardPunishment>>
-		<<case "confinement">>
-			shut up in a box. @@color:gold;She breaks down,@@ falling to her knees, begging abjectly for mercy. "It'<<s>> dark in there," she screams as you open the box for her. She knows that if she doesn't climb in, it'll be longer before she's let out, so she does, scrabbling inside and sobbing desperately as you close the lid.
-		<<case "whipping">>
-			whipped. @@color:gold;She breaks down,@@ falling to her knees, begging abjectly for mercy. "It'll h-hu-hurt," she blubbers weakly as you attach her hands to shackles high on the office wall. The first stroke across her buttocks draws a long shriek out of her.
-		<<case "chastity">>
-			locked up in chastity. @@color:gold;She breaks down,@@ falling to her knees, begging abjectly for mercy. "I c-can't," she moans. "I can't take it. I can't <<s>>tand it." As you lock the chastity onto her, she sobs inconsolably, knowing that any arousal will be torturous until she's released.
-		<<default>>
-			gagged, since that's the appropriate castigation for failure to control her mouth and deportment. She tries to behave, but @@color:gold;breaks down@@ as you slide a dildo gag into her throat, choking and struggling to breathe as she tries to cry past it.
-		<</switch>>
-		The thing she's most frightened of is that she won't be able to control her fear in the future, and will continue to suffer.
-		<<set $activeSlave.trust -= 5>>
+			When she's gotten you off, she @@color:mediumaquamarine;thanks you trustingly.@@ Even though she wasn't able to figure out how to seat herself in a really satisfactorily sexy way, she's glad you gave her some agency.
+		<</if>>	
 	<</replace>>
+	<<set $activeSlave.trust += 5>>
 <</click>>
-<<if $dairyRestraintsSetting == 2>>
-<br><<click "Threaten her with the industrial Dairy">>
+<br><<click "Have her service you while you work">>
 	<<replace "#name">>$activeSlave.slaveName<</replace>>
 	<<replace "#result">>
-		You grab her by the scruff of her neck and drag her down to $dairyName. She tries to control herself, but breaks down in tears when you haul her to a stop, forcing her to get a good look at the rows of bodies being mercilessly milked. You explain that if she continues to fail to control herself, your patience with her will eventually expire, and you'll be forced to immure her here. Indicating a slave who's being
-		<<if ($activeSlave.balls > 0) && ($dairyStimulatorsSetting == 2)>>
-			cockmilked by the machines, you tell $activeSlave.slaveName to pay close attention. She watches in horror as a dildo the size of her forearm slides in and out of the slave's rectum, pounding it harder and harder until the slave stiffens and the transparent tubing coming off its cockhead whitens with cum. As the slave relaxes slightly in the restrains, the powerful milkers continue their relentless tugging at her gigantic udders. You tell $activeSlave.slaveName that unless she wants her ass ruined by constant machine rape and her tits turned into immobilizing milk factories,
-		<<elseif ($activeSlave.vagina > -1) && ($dairyPregSetting == 2)>>
-			used for reproduction by the machines, you tell $activeSlave.slaveName to pay close attention. She watches in horror as a dildo the size of her forearm fucks the slave's enormous cunt, keeping it as gaped as possible to ease birth and constantly ejaculating preparatory drugs against her cervix. The slave is gigantically pregnant. You tell $activeSlave.slaveName that this is the vaginal treatment she can expect when pregnant; when impregnation is required, the dildos ejaculate more than a liter of cum a minute. Unless she wants her womb converted into an industrial component,
+		You order her to sit on your <<if $PC.dick == 1>>dick<<else>>strap-on<</if>> and get you off like a good girl, and not to disturb you while you're working. She <<if canTalk($activeSlave)>>shuts up immediately<<else>>obediently drops her hands to her sides and stops communicating with them<</if>>, and approaches you carefully. Meanwhile, you go back to your tablet, ignoring her completely. She gingerly straddles your legs, positioning her intimate areas directly over the pointing head of <<if $PC.dick == 1>>your erection<<else>>the phallus<</if>>. Deciding that she shouldn't use her hands to guide it, she lowers herself slowly,
+		<<if $canDoVaginal($activeSlave) && ($activeSlave.vagina > 0)>>
+			breathing a little harder as she feels its head spread her pussylips and then slide inside her.
+			<<set $activeSlave.vaginalCount++, $vaginalTotal++>>
+		<<elseif $canDoAnal($activeSlave) && ($activeSlave.anus > 0)>>
+			letting out a breath and relaxing as she feels its head press past her sphincter and then all the way up her butt.
+			<<set $activeSlave.analCount++, $analTotal++>>
 		<<else>>
-			drained of her milk, you tell $activeSlave.slaveName to pay close attention. She watches in horror as the slave's gigantic breasts are massaged and squeezed, while the milkers attached to her absurd nipples tug and pull with industrial power. She can't look away; the orbs of jiggling flesh being manipulated are each as big as the slave's torso. It's good for milk production to drain slaves completely on occasion, and the machine doesn't stop until every drop is wrung from both udders. You tell $activeSlave.slaveName that unless she wants to experience that twice a day,
+			getting it situated between her thighs, since that's the best option she has available.
+			<<set $activeSlave.oralCount++, $oralTotal++>>
 		<</if>>
-		she had better behave herself. She nods furiously, @@color:gold;terrified beyond the ability to speak.@@
-		<<set $activeSlave.trust -= 8>>
-	<</replace>>
-<</click>>
-<</if>>
-<<if $seeExtreme != 0>>
-<br><<click "Threaten to convert her into a Fuckdoll">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		You order a Fuckdoll brought to your office. $activeSlave.slaveName watches it totter in, automatically following the tugs on its leash and the tonal commands passed by its suit. She already understands the implicit threat, and she shivers uncontrollably, @@color:gold;almost falling to her knees in fear.@@ Not content with that, you tell her that she's trying your patience with her behavior. If she doesn't control herself better in the future, you'll give up on her and convert her into a Fuckdoll. At the spoken threat $activeSlave.slaveName does collapse, but you order her to get back to her feet and watch. She does, shakily, tears streaming down her face as you put the Fuckdoll on its all fours, as though it were about to take dick. Its <<if $activeSlave.vagina > -1>>holes are pointed straight at $activeSlave.slaveName's face, and she can't avoid seeing how loose and used they look<<else>>rear hole is pointed straight at $activeSlave.slaveName's face, and she can't avoid seeing how loose and used it looks<</if>>. Suddenly, you activate the Fuckdoll's suit's punishment systems. It does not and cannot scream, but a slight stiffening of its posture communicates extreme anguish, and its sphincter spasms tightly closed with obviously involuntary force. $activeSlave.slaveName is almost incapacitated by terror.
-		<<set $activeSlave.trust -= 8>>
+		Still crouched over you, she begins to move up and down, milking <<if $PC.dick == 1>>your penis<<else>>the strap-on<</if>>. As she works into it, she lets her butt touch you once, but you make a nonverbal sound of disapproval, letting her know not to disturb your work like that. Realizing that she needs to play the human sex toy, she <<if $activeSlave.butt > 5>>grabs her huge buttocks and holds them apart, doing her best to keep them out of the way<<elseif $activeSlave.butt > 2>>takes hold of her healthy asscheeks and spreads them as far as they'll go, doing her best to keep them out of the way<<else>>uses her arms for balance, since her cute butt can stay out of the way on its own and doesn't need to be spread by hand<</if>>. She bobs up and down, getting you off without ever touching you. <<if $activeSlave.energy > 80>>She has such a powerful sex drive that even this sterile intercourse brings her to orgasm.<<elseif $activeSlave.releaseRules == "restrictive">>She obeys the rules about orgasm and hasn't gotten off as part of her assignment recently, so she orgasms despite the sterility of the intercourse.<<else>>She does not orgasm, serving you properly and showing appropriate disregard for her own pleasure.<</if>> When she's done, she makes the perfect exit, @@color:hotpink;silently padding away like the passive sex object she is.@@
 	<</replace>>
+	<<set $activeSlave.devotion += 5>>
 <</click>>
-<</if>>
-<br><<click "Comfort her">>
+<br><<click "Drive her off for breaking in on your work">>
 	<<replace "#name">>$activeSlave.slaveName<</replace>>
 	<<replace "#result">>
-		You rise from behind your desk, and $activeSlave.slaveName collapses to the floor, sure that she's about to be severely punished. She's shocked to feel your arms encircle her as you kneel down beside her and embrace her huddled form. You pull her head <<if $PC.boobs == 1>>against your soft breasts<<else>>into your shoulder<</if>>, stroking it reassuringly and murmuring kindness. She clings to you, mostly for lack of any other comfort in the whole world, and sobs convulsively, @@color:mediumaquamarine;her terror flowing out of her@@ in a torrent as you gently rub her back. When she's mostly cried herself out, you tell her that she'll be all right. You're sure she'll be a good slave one day. You understand that her life is hard. She'll make mistakes, and you'll punish her for them, but that's part of slave training, and that's all right. If she does her best, she'll be all right. She sniffles, cuffing tears away. "Th-thank you, <<Master>>, I'll d-do my b-be<<s>>t," she manages to <<say>>.
-		<<set $activeSlave.trust += 5>>
+		You command her to turn around and show you her ass. She obeys eagerly, spinning and bringing you face to face with her <<if $activeSlave.butt > 5>>monstrous bottom<<elseif $activeSlave.butt > 2>>womanly butt<<else>>cute little rear end<</if>>. She's expecting something sexy, and she's wrong. You give her right asscheek a stinging, open-handed slap. It's so unexpected that she jumps with surprise, takes a step forward, and instantly bursts into tears. Knowing that she has to accept whatever you think she deserves, she takes a step back towards you to come back within range. <<if canTalk($activeSlave)>>"<<Master>>, I'm <<s>>-<<s>>orry," she sobs. "I d-don't understand. What did I d-do?"<<else>>She shakily gestures a question, begging to know what she did.<</if>> You tell her not to disturb you when you're working, tanning her ass viciously, first one buttock and then the other. She stands there and takes her beating, weeping, more from the @@color:gold;bitter disappointment that she's not allowed to approach you@@ like that.
 	<</replace>>
+	<<set $activeSlave.trust -= 5>>
 <</click>>
 
-<<case "frightening dick">>
-
-<<click "Polish this">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		You tell her to polish this instead, advancing even closer. She turns, finding your cockhead so close to her face that her eyes cross ludicrously as they attempt to focus on it. She does not like dicks, and obviously does not find the prospect of sucking this one appealing right now, but she knows it's in her best interests to <<if $activeSlave.oralSkill > 10>>put her oral knowledge to work<<else>>do her best<</if>> right now. She closes her eyes and takes you into her mouth, forming a seal around your cock with her <<if $activeSlave.lips > 40>>ridiculous<<elseif $activeSlave.lips > 20>>pillowy<<elseif $activeSlave.lips > 10>>pretty<<else>>disappointingly thin<</if>> lips before starting to suck dick. Dissatisfied with her reluctance, you order her to open her eyes and look up at you; she obeys, the $activeSlave.eyeColor orbs glittering with a little moisture as she concentrates on breathing past your penis. You ask if your cock tastes any different than usual. "Mmm hmm, M'," she mumbles, producing a nice humming sensation against your cock. You tell her that she's tasting another slave's <<if $activeSlave.vagina > -1>>pussy<<else>>ass<</if>>. She gags, but only slightly, and controls herself immediately. Your dick is desensitized from vigorous use, and she has to suck it a long time before you cup the back of her head, ram yourself all the way in, and blow your load straight down her gullet. You tell her she's a good $desc. "Thank you, <<Master>>," she <<say>>s @@color:hotpink;submissively,@@ going back to her polishing.
-		<<set $activeSlave.oralCount++, $oralTotal++>>
-		<<set $activeSlave.devotion += 5>>
-	<</replace>>
-<</click>><<if ($activeSlave.anus == 0) && ($activeSlave.vagina <= 0)>> //This option will take anal virginity//<</if>>
-<br><<click "Talk to her about her issues with dick">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		You sit yourself down in the doorway, right next to her, and pat your thighs. She sits on your lap, obeying despite some evident reluctance to sit atop your moist cock. It nestles easily between her lower buttocks and upper thighs, and she gets herself situated, doing her best to ignore the feeling of your hot hard meat, hard against her fundament. You encircle her with your arms, possessively and dominantly but not sexually, and tell her that you're concerned about her relationship with cock. She shifts uncomfortably. "<<S>>orry, <<Master>>, <<s>>orry I'm not better at hiding that. I should be a good $desc and not react like that. I mean, in a bad way. You <<s>>tartled me, but I don't alway<<s>> react well to dick even when I'm not <<s>>tartled. I'll try harder." This is more contrition and submission than you were expecting, and you probe further, asking her pointedly whether she's attracted to dicks now. "N-no," she admits, after only a moment's hesitation to remember that honesty is the most important rule for her to follow. "No, I don't. But I'll do my be<<s>>t to be a good <<s>>ex <<s>>lave anyway, <<Master>>." Pleased, you tell her that things will get easier for her. <<if $activeSlave.hormones > 0>>The hormone treatments she's currently taking will slowly reorient her sexuality, and eventually she'll lust after every cock she sees.<<elseif $activeSlave.aphrodisiacs > 0>>The aphrodisiacs she's on will make her so omnisexually horny that soon she won't care how anyone's equipped, as long as they'll fuck her.<<elseif $activeSlave.energy > 60>>Her excellent and improving libido will eventually soften her to all kinds of sex, with all kinds of people.<<else>>Habit and training will get her used to dick, and eventually she'll barely remember that she ever had a problem with sucking a quick cock.<</if>> She's a little unsure whether or not to be reassured by this, but she's @@color:mediumaquamarine;relieved she's not in trouble.@@
-		<<set $activeSlave.trust += 5>>
-	<</replace>>
-<</click>><<if ($activeSlave.anus == 0) && ($activeSlave.vagina <= 0)>> //This option will take anal virginity//<</if>>
-<br><<click "Rape her">>
-	<<replace "#name">>$activeSlave.slaveName<</replace>>
-	<<replace "#result">>
-		Sometimes there's really no need to overthink things. You reach down, grab her under the armpits, and haul her up, throwing her across your desk. She lands on her back, and the impact drives the wind out of her, so she lies there, @@color:gold;all possibility of resistance driven out of her.@@ <<if $activeSlave.clothes == "no clothing">>She's already naked, so there's no need to<<else>>You<</if>> tear the clothes off her. You force yourself in between her legs as she struggles to get her breath back, and she gets another good look at the formidable dick that's about to be slammed inside her. Her eyes go wide with fear, and you enhance the effect by smacking yourself against <<if $activeSlave.vagina > -1>>her<<if $activeSlave.vagina == 0>> virgin<</if>> vulva<<else>>limp bitchclit<</if>>. You tell her not to worry, because you're still pretty wet from the last slave you fucked, so this shouldn't hurt too much. Then you ram your cock <<if $activeSlave.vagina > 0>>inside her<<else>>up her spasming ass<</if>>. She whines and bucks, but she's entirely at your mercy. She doesn't like dicks, and to go by her facial expression as you piston in and out of her, this experience isn't going to make her reconsider. When you fill her with cum, pull out, and let her retreat to clean herself up, she's relieved to go.
-		<<if $activeSlave.vagina <= 0>><<AnalVCheck>><<else>><<set $activeSlave.vaginalCount++, $vaginalTotal++>><</if>>
-		<<set $activeSlave.trust -= 5>>
-	<</replace>>
-<</click>><<if ($activeSlave.anus == 0) && ($activeSlave.vagina <= 0)>> //This option will take anal virginity//<</if>>
-
 <<default>>
 	ERROR: bad event
 <</switch>>
diff --git a/src/uncategorized/clinicReport.tw b/src/uncategorized/clinicReport.tw
index 56afcb0ec10ff2aecca6044fdf97f81265708a24..b39c8e4efa12336e42ba8d8848f3e178373c3b0a 100644
--- a/src/uncategorized/clinicReport.tw
+++ b/src/uncategorized/clinicReport.tw
@@ -1,123 +1,145 @@
 :: Clinic Report [nobr]
 
+<<set $clinicSlaves = 0, _idleBonus = 0, _nurseFetish = 0, _restedSlaves = 0, _SL = $slaves.length, _NR = -1>>
 
-<<set $nurseUsedCure to 0>>
-<<set $restedSlaves to 0>>
-<<set $clinicSlaves to 0>>
-<<set $nurseFetish to 0>>
-<<set $idleBonus to 0>>
+<<if $Nurse != 0>>
+<<for _NR = 0; _NR < _SL; _NR++>>
+<<if $slaves[_NR].ID is $Nurse.ID>>
+<<break>>
+<</if>>
+<</for>>
+<</if>>
+<<if _NR != -1>>
+	<<if $seeImages == 1>><<SlaveArt $slaves[_NR] 0 0>><</if>>
+	<<silently>>
+	<<set $i = _NR>>
+	<<display "SA long term effects">>
+	<<display "SA relationships">>
+	<<display "SA rivalries">>
+	<</silently>>
+	<<if ($slaves[_NR].health < 100)>>
+	<<set $slaves[_NR].health += 20>>
+	<</if>>
+	<<if ($slaves[_NR].devotion <= 60)>>
+	<<set $slaves[_NR].devotion += 1>>
+	<</if>>
+	<<if $clinicDecoration != "standard">>
+	<<set $slaves[_NR].devotion += 1>>
+	<</if>>
+	<<if $slaves[_NR].trust < 60>>
+	<<set $slaves[_NR].trust += 1>>
+	<</if>>
+	<<if $slaves[_NR].fetishStrength <= 95>>
+	<<if $slaves[_NR].fetish != "dom">>
+		<<fetishChangeChance $slaves[_NR]>>
+		<<if $fetishChangeChance > random(0,100)>>
+			<<set _nurseFetish to 1, $slaves[_NR].fetishKnown to 1, $slaves[_NR].fetish to "dom">>
+		<</if>>
+	<<elseif $slaves[_i].fetishKnown == 0>>
+		<<set _nurseFetish to 1, $slaves[_NR].fetishKnown to 1>>
+	<<else>>
+		<<set _nurseFetish to 2, $slaves[_NR].fetishStrength += 4>>
+	<</if>>
+	<</if>>
+	<<set $Nurse = $slaves[_NR]>>
+<</if>>
 
-<<for $i to 0; $i < $slaves.length; $i++>>
-<<if ($slaves[$i].assignment is "get treatment in the clinic")>>
-	<<if $seeImages == 1>><<SlaveArt $slaves[$i] 0 0>><</if>>
-	<<set $clinicSlaves += 1>>
+<<for _i to 0; _i < _SL; _i++>>
+	<<if ($slaves[_i].assignment != "get treatment in the clinic")>><<continue>><</if>>
+	<<if $seeImages == 1>><<SlaveArt $slaves[_i] 0 0>><</if>>
+	<<set $clinicSlaves++>>
 	<<silently>>
-	<<display [[SA rest]]>>
+	<<set $i = _i>>
+	<<display "SA rest">>
 	<<display "SA long term effects">>
 	<<display "SA relationships">>
 	<<display "SA rivalries">>
 	<</silently>>
-	<<set $slaves[$i].health += 10>>
-	<<set $slaves[$i].health += $curativeUpgrade*10>>
-	<<if $slaves[$i].health > 100>>
-	<<set $slaves[$i].health = 100>>
+	<<set $slaves[_i].health += 10 + ($curativeUpgrade * 10)>>
+	<<if $slaves[_i].health > 100>>
+	<<set $slaves[_i].health = 100>>
 	<</if>>
-	<<if $slaves[$i].devotion < 45>>
-	<<set $slaves[$i].devotion += 4>>
+	<<if $slaves[_i].devotion < 45>>
+	<<set $slaves[_i].devotion += 4>>
 	<</if>>
 	<<if $clinicDecoration != "standard">>
-	<<set $slaves[$i].devotion += 1>>
+	<<set $slaves[_i].devotion += 1>>
 	<</if>>
-	<<if $slaves[$i].trust < 45>>
-	<<set $slaves[$i].trust += 4>>
+	<<if $slaves[_i].trust < 45>>
+	<<set $slaves[_i].trust += 4>>
 	<</if>>
 	<<if $Nurse != 0>>
 	<<if ($Nurse.fetish is "dom")>>
-		<<set $slaves[$i].health += 1>>
+		<<set $slaves[_i].health += 1>>
 	<</if>>
-	<<if ($Nurse.muscles > 5)>>
-		<<set $slaves[$i].health += 1>>
-	<<elseif ($slaves[$i].devotion >= -20)>>
-		<<set $slaves[$i].health += 1>>
+	<<if ($Nurse.muscles > 5) || ($slaves[_i].devotion >= -20)>>
+		<<set $slaves[_i].health += 1>>
 	<</if>>
 	<<if ($Nurse.intelligence > 1)>>
-		<<set $slaves[$i].health += 1>>
+		<<set $slaves[_i].health += 1>>
 	<</if>>
 	<<if ($Nurse.face > 1)>>
-		<<set $slaves[$i].devotion += 1>>
+		<<set $slaves[_i].devotion += 1>>
 	<</if>>
 	<<if $nurseCareers.contains($Nurse.career)>>
-		<<set $slaves[$i].health += 1>>
+		<<set $slaves[_i].health += 1>>
 	<</if>>
 	<<if $Nurse.relationship is -3>>
-		<<set $slaves[$i].health += 2>>
+		<<set $slaves[_i].health += 2>>
 	<</if>>
 	<<if $familyTesting == 1>>
-		<<if $slaves[$i].assignment == "get treatment in the clinic">>
-		<<if $slaves[$i].mother == $Nurse.ID>>
-			<<set $slaves[$i].health += 1>>
-		<</if>>
-		<<if $slaves[$i].father == $Nurse.ID>>
-			<<set $slaves[$i].health += 1>>
+		<<if $slaves[_i].mother == $Nurse.ID>>
+			<<set $slaves[_i].health += 1>>
 		<</if>>
-		<<if $slaves[$i].ID == $Nurse.father>>
-			<<set $slaves[$i].health += 1>>
+		<<if $slaves[_i].father == $Nurse.ID>>
+			<<set $slaves[_i].health += 1>>
 		<</if>>
-		<<if $slaves[$i].ID == $Nurse.mother>>
-			<<set $slaves[$i].health += 1>>
+		<<if $slaves[_i].ID == $Nurse.father>>
+			<<set $slaves[_i].health += 1>>
 		<</if>>
-		<<if areSisters($slaves[$i], $Nurse) == 1>>
-			<<set $slaves[$i].health += 1>>
-		<<elseif areSisters($slaves[$i], $Nurse) == 2>>
-			<<set $slaves[$i].health += 1>>
-		<<elseif areSisters($slaves[$i], $Nurse) == 3>>
-			<<set $slaves[$i].health += 1>>
+		<<if $slaves[_i].ID == $Nurse.mother>>
+			<<set $slaves[_i].health += 1>>
 		<</if>>
+		<<if areSisters($slaves[_i], $Nurse) == 1>>
+			<<set $slaves[_i].health += 1>>
+		<<elseif areSisters($slaves[_i], $Nurse) == 2>>
+			<<set $slaves[_i].health += 1>>
+		<<elseif areSisters($slaves[_i], $Nurse) == 3>>
+			<<set $slaves[_i].health += 1>>
 		<</if>>
 	<<else>>
-		<<if $Nurse.relationTarget is $slaves[$i].ID and $slaves[$i].assignment is "get treatment in the clinic">>
-			<<set $slaves[$i].health += 1>>
+		<<if $Nurse.relationTarget is $slaves[_i].ID>>
+			<<set $slaves[_i].health += 1>>
 		<</if>>
 	<</if>>
-	<<if $Nurse.relationshipTarget is $slaves[$i].ID and $slaves[$i].assignment is "get treatment in the clinic">>
-		<<set $slaves[$i].health += 3>>
-	<</if>>
-	<<if $Nurse.rivalryTarget is $slaves[$i].ID and $slaves[$i].assignment is "get treatment in the clinic">>
-		<<set $slaves[$i].health -= 3>>
-	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is a famed Free Cities whore, and commands top prices." and $slaves[$i].assignment is "get treatment in the clinic">>
-		<<set $slaves[$i].health += 2>>
-	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is a famed Free Cities slut, and can please anyone." and $slaves[$i].assignment is "get treatment in the clinic">>
-		<<set $slaves[$i].health += 2>>
-	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is remembered for winning best in show as a cockmilker." and $slaves[$i].assignment is "get treatment in the clinic">>
-		<<set $slaves[$i].health += 4>>
+	<<if $Nurse.relationshipTarget is $slaves[_i].ID>>
+		<<set $slaves[_i].health += 3>>
 	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is remembered for winning best in show as a dairy cow." and $slaves[$i].assignment is "get treatment in the clinic">>
-		<<set $slaves[$i].health += 4>>
-	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is remembered for winning best in show as a breeder." and $slaves[$i].assignment is "get treatment in the clinic">>
-		<<set $slaves[$i].health += 4>>
+	<<if $Nurse.rivalryTarget is $slaves[_i].ID>>
+		<<set $slaves[_i].health -= 3>>
 	<</if>>
+	<<switch $slaves[_i].prestigeDesc>>
+	<<case "She is a famed Free Cities whore, and commands top prices." "She is a famed Free Cities slut, and can please anyone.">>
+		<<set $slaves[_i].health += 2>>
+	<<case "She is remembered for winning best in show as a cockmilker." "She is remembered for winning best in show as a dairy cow." "She is remembered for winning best in show as a breeder.">>
+		<<set $slaves[_i].health += 4>>
+	<</switch>>
 	<</if>>
 	<<if $clinicSpeedGestation == 1>>
-		<<if $slaves[$i].preg > 0>>
-			<<set $slaves[$i].pregControl = "speed up">>
+		<<if $slaves[_i].preg > 0>>
+			<<set $slaves[_i].pregControl = "speed up">>
 		<</if>>
 	<</if>>
-	<<if ($slaves[$i].chem > 15)>>
-	<<if ($clinicUpgradeFilters == 1)>>
-		<<set $slaves[$i].chem -= 5>>
+	<<if ($slaves[_i].chem > 15) && ($clinicUpgradeFilters == 1)>>
+		<<set $slaves[_i].chem -= 5>>
 		<<if $clinicUpgradePurge == 1>>
-			<<set $slaves[$i].chem -= 50>>
-			<<set slaves[$i].chem = Math.clamp(slaves[$i].chem, 0, 10000)>>
-			<<if $slaves[$i].health > -50>>
-				<<set $slaves[$i].health = -50>>
+			<<set $slaves[_i].chem -= 50>>
+			<<set slaves[_i].chem = Math.clamp(slaves[_i].chem, 0, 10000)>>
+			<<if $slaves[_i].health > -50>>
+				<<set $slaves[_i].health = -50>>
 			<</if>>
 		<</if>>
 	<</if>>
-	<</if>>
 	/* slave release block become too much a mess, need to change structure*/
 	<<set _stay = 0>>
 	<<if ($slaves[$i].health <= 40)>>
@@ -141,41 +163,6 @@
 		<<set $clinicSlaves-->>
 	<</if>>
 	/* end of rewriten slave release check */
-
-<<elseif ($Nurse != 0) && ($slaves[$i].ID is $Nurse.ID)>>
-	<<silently>>
-	<<display "SA long term effects">>
-	<<display "SA relationships">>
-	<<display "SA rivalries">>
-	<</silently>>
-	<<if ($slaves[$i].health < 100)>>
-	<<set $slaves[$i].health += 20>>
-	<</if>>
-	<<if ($slaves[$i].devotion <= 60)>>
-	<<set $slaves[$i].devotion += 1>>
-	<</if>>
-	<<if $clinicDecoration != "standard">>
-	<<set $slaves[$i].devotion += 1>>
-	<</if>>
-	<<if $slaves[$i].trust < 60>>
-	<<set $slaves[$i].trust += 1>>
-	<</if>>
-	<<if $slaves[$i].fetishStrength <= 95>>
-	<<if $slaves[$i].fetish != "dom">>
-		<<fetishChangeChance $slaves[$i]>>
-		<<if $fetishChangeChance > random(0,100)>>
-			<<set $nurseFetish to 1>>
-			<<set $slaves[$i].fetishKnown to 1>>
-			<<set $slaves[$i].fetish to "dom">>
-		<</if>>
-	<<elseif $slaves[$i].fetishKnown == 0>>
-		<<set $nurseFetish to 1>>
-		<<set $slaves[$i].fetishKnown to 1>>
-	<<else>>
-		<<set $nurseFetish to 2>>
-		<<set $slaves[$i].fetishStrength += 4>>
-	<</if>>
-	<</if>>
 <</if>>
 <</for>>
 
@@ -184,180 +171,171 @@
 	<<if ($clinicSlaves == 1)>>''There is one slave receiving treatment in the clinic.''<<else>>''There are $clinicSlaves slaves receiving treatment in the clinic.''<</if>>
 
 	<<if ($Nurse != 0)>>
-	$Nurse.slaveName is serving as the clinical nurse.<<if $Nurse.relationship is -3>>  She does her best to be a caring and nurturing wife.<</if>>
-	<<if ($nurseFetish == 1)>>
+	$Nurse.slaveName is serving as the clinical nurse.<<if $Nurse.relationship is -3>> She does her best to be a caring and nurturing wife.<</if>>
+	<<if (_nurseFetish == 1)>>
 		Her job involves giving naked sex slaves orders for their own good. Even though most of these commands are medical rather than sexual, she can be forgiven for not always seeing the difference, and @@color:lightsalmon;becomes more dominant.@@
-	<<elseif ($nurseFetish == 2)>>
+	<<elseif (_nurseFetish == 2)>>
 		Every new patient in the clinic is a new target for her authority. @@color:lightsalmon;She becomes more dominant.@@
 	<</if>>
 	<<if $nurseCareers.contains($Nurse.career)>>
 		She has experience with medicine from her life before she was a slave, and can often recognize conditions before even the medical scanners can.
-		<<set $idleBonus += 1>>
+		<<set _idleBonus++>>
 	<</if>>
 	<<if ($Nurse.fetish is "dom")>>
 		She raps out commands with the confidence of long and partly sexual experience, so patients are inclined to follow even unpleasant medical instructions.
-		<<set $idleBonus += 1>>
+		<<set _idleBonus++>>
 	<</if>>
 	<<if ($Nurse.muscles > 5)>>
 		She's strong enough to gently but firmly restrain resistant slaves, allowing her to be sparing with the inescapable but less healthy restraints.
-		<<set $idleBonus += 1>>
+		<<set _idleBonus++>>
 	<</if>>
 	<<if ($Nurse.intelligence > 1)>>
 		The diagnostic equipment is state-of-the-art, but she's smart and perceptive enough that on occasion, she can add meaningfully to its medical scans.
-		<<set $idleBonus += 1>>
+		<<set _idleBonus++>>
 	<</if>>
 	<<if ($Nurse.face > 1)>>
 		Patients rarely object to seeing her gorgeous face hovering over them.
-		<<set $idleBonus += 1>>
+		<<set _idleBonus++>>
 	<</if>>
-	<<for $i to 0; $i < $slaves.length; $i++>>
+	<<for _i to 0; _i < _SL; _i++>>
+	<<if ($slaves[_i].assignment != "get treatment in the clinic")>><<continue>><</if>>
 	<<if $familyTesting == 1>>
-		<<if $slaves[$i].assignment == "get treatment in the clinic">>
-		<<if $slaves[$i].mother == $Nurse.ID>>
-			She makes sure to spend extra time caring for her daughter, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
+		<<if $slaves[_i].mother == $Nurse.ID>>
+			She makes sure to spend extra time caring for her daughter, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
-		<<if $slaves[$i].father == $Nurse.ID>>
-			She makes sure to spend extra time caring for her daughter, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
+		<<if $slaves[_i].father == $Nurse.ID>>
+			She makes sure to spend extra time caring for her daughter, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
-		<<if $slaves[$i].ID == $Nurse.father>>
-			She makes sure to spend extra time caring for her father, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
+		<<if $slaves[_i].ID == $Nurse.father>>
+			She makes sure to spend extra time caring for her father, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
-		<<if $slaves[$i].ID == $Schoolteacher.mother>>
-			She makes sure to spend extra time caring for her mother, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
-		<</if>>
-		<<if areSisters($slaves[$i], $Nurse) == 1>>
-			She makes sure to spend extra time caring for her twin sister, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
-		<<elseif areSisters($slaves[$i], $Nurse) == 2>>
-			She makes sure to spend extra time caring for her sister, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
-		<<elseif areSisters($slaves[$i], $Nurse) == 3>>
-			She makes sure to spend extra time caring for her half-sister, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
+		<<if $slaves[_i].ID == $Nurse.mother>>
+			She makes sure to spend extra time caring for her mother, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
+		<<if areSisters($slaves[_i], $Nurse) == 1>>
+			She makes sure to spend extra time caring for her twin sister, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
+		<<elseif areSisters($slaves[_i], $Nurse) == 2>>
+			She makes sure to spend extra time caring for her sister, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
+		<<elseif areSisters($slaves[_i], $Nurse) == 3>>
+			She makes sure to spend extra time caring for her half-sister, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
 	<<else>>
-		<<if $Nurse.relationTarget is $slaves[$i].ID and $slaves[$i].assignment is "get treatment in the clinic">>
-			She makes sure to spend extra time caring for her $slaves[$i].relation, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
+		<<if $Nurse.relationTarget is $slaves[_i].ID>>
+			She makes sure to spend extra time caring for her $slaves[_i].relation, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
 	<</if>>
-	<<if $Nurse.relationshipTarget is $slaves[$i].ID and $slaves[$i].assignment is "get treatment in the clinic">>
-		She dedicates most of her attention to her <<if $Nurse.relationship == 1>>friend<<elseif $Nurse.relationship is 2>>best friend<<elseif $Nurse.relationship is 3>>friend with benefits<<elseif $Nurse.relationship is 4>>lover<<elseif $Nurse.relationship is 5>>slave wife<</if>>, $slaves[$i].slaveName, making sure she has everything she needs and more.  This lavish attention detracts from her overall effectiveness.
-		<<set $idleBonus -= 3>>
-		<<set $slaves[$i].devotion += 1>>
-		<<set $slaves[$i].trust += 1>>
+	<<if $Nurse.relationshipTarget is $slaves[_i].ID>>
+		She dedicates most of her attention to her <<if $Nurse.relationship == 1>>friend<<elseif $Nurse.relationship is 2>>best friend<<elseif $Nurse.relationship is 3>>friend with benefits<<elseif $Nurse.relationship is 4>>lover<<elseif $Nurse.relationship is 5>>slave wife<</if>>, $slaves[_i].slaveName, making sure she has everything she needs and more.  This lavish attention detracts from her overall effectiveness.
+		<<set _idleBonus -= 3, $slaves[_i].devotion += 1, $slaves[_i].trust += 1>>
 	<</if>>
-	<<if $Nurse.rivalryTarget is $slaves[$i].ID and $slaves[$i].assignment is "get treatment in the clinic">>
-		She purposefully neglects the needs of her <<if $Nurse.rivalry == 1>>growing rival<<elseif $Nurse.rivalry is 2>>rival<<elseif $Nurse.rivalry is 3>>bitter rival<</if>>, $slaves[$i].slaveName, hindering her recovery and deepening their dislike for each other.
-		<<set $slaves[$i].devotion -= 1>>
-		<<set $slaves[$i].trust -= 1>>
+	<<if $Nurse.rivalryTarget is $slaves[_i].ID>>
+		She purposefully neglects the needs of her <<if $Nurse.rivalry == 1>>growing rival<<elseif $Nurse.rivalry is 2>>rival<<elseif $Nurse.rivalry is 3>>bitter rival<</if>>, $slaves[_i].slaveName, hindering her recovery and deepening their dislike for each other.
+		<<set $slaves[_i].devotion -= 1, $slaves[_i].trust -= 1>>
 		<<if random(1,100) > 65>>
-			<<set $Nurse.rivalry += 1>>
-		<<set $slaves[$i].rivalry += 1>>
+			<<set $Nurse.rivalry += 1, $slaves[_NR].rivalry += 1, $slaves[_i].rivalry += 1>>
 		<</if>>
 	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is a famed Free Cities whore, and commands top prices." and $slaves[$i].assignment is "get treatment in the clinic">>
-		She does her best to aid the famous whore, $slaves[$i].slaveName, making sure to pay special attention to her worn holes.
+	<<if $slaves[_i].prestigeDesc is "She is a famed Free Cities whore, and commands top prices.">>
+		She does her best to aid the famous whore, $slaves[_i].slaveName, making sure to pay special attention to her worn holes.
 	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is a famed Free Cities slut, and can please anyone." and $slaves[$i].assignment is "get treatment in the clinic">>
-		She does her best to aid the famous entertainer, $slaves[$i].slaveName, making sure she can show off as soon as possible.
+	<<if $slaves[_i].prestigeDesc is "She is a famed Free Cities slut, and can please anyone.">>
+		She does her best to aid the famous entertainer, $slaves[_i].slaveName, making sure she can show off as soon as possible.
 	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is remembered for winning best in show as a cockmilker." and $slaves[$i].assignment is "get treatment in the clinic">>
-		She does her best to aid the dribbling $slaves[$i].slaveName, paying special attention to her huge cock and balls as well as making sure to milk her erect dick hourly.
-		<<if random(1,100) > 65 and $Nurse.fetish is "none" or $Nurse.fetish is "cumslut">>
-		<<if $Nurse.fetish is "none">>
-		<<set $Nurse.fetish to "cumslut">>
+	<<if $slaves[_i].prestigeDesc is "She is remembered for winning best in show as a cockmilker.">>
+		She does her best to aid the dribbling $slaves[_i].slaveName, paying special attention to her huge cock and balls as well as making sure to milk her erect dick hourly.
+		<<if (random(1,100) > 65) && (($Nurse.fetish == "none") || ($Nurse.fetish == "cumslut"))>>
+		<<if $Nurse.fetish == "none">>
+		<<set $Nurse.fetish = "cumslut", $slaves[_NR].fetish = "cumslut">>
 		<<else>>
-		<<set $Nurse.fetishStrength += 4>>
+		<<set $Nurse.fetishStrength += 4, $slaves[_NR].fetishStrength += 4>>
 		<</if>>
 		<</if>>
 	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is remembered for winning best in show as a dairy cow." and $slaves[$i].assignment is "get treatment in the clinic">>
-		She does her best to aid the leaking $slaves[$i].slaveName, paying special attention to her huge breasts as well as making sure to milk her hourly.
-		<<if random(1,100) > 65 and $Nurse.fetish is "none" or $Nurse.fetish is "boobs">>
-		<<if $Nurse.fetish is "none">>
-		<<set $Nurse.fetish to "boobs">>
+	<<if $slaves[_i].prestigeDesc is "She is remembered for winning best in show as a dairy cow.">>
+		She does her best to aid the leaking $slaves[_i].slaveName, paying special attention to her huge breasts as well as making sure to milk her hourly.
+		<<if (random(1,100) > 65) && (($Nurse.fetish is "none") || ($Nurse.fetish is "boobs"))>>
+		<<if $Nurse.fetish == "none">>
+		<<set $Nurse.fetish = "boobs", $slaves[_NR].fetish = "boobs">>
 		<<else>>
-		<<set $Nurse.fetishStrength += 4>>
+		<<set $Nurse.fetishStrength += 4, $slaves[_NR].fetishStrength += 4>>
 		<</if>>
 		<</if>>
 	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is remembered for winning best in show as a breeder." and $slaves[$i].assignment is "get treatment in the clinic" and $slaves[$i].preg > 10>>
-		She does her best to aid the pregnant $slaves[$i].slaveName, paying special attention to her swollen belly and the welfare of the life within.
-	<</if>>
-	<<if $slaves[$i].prestigeDesc is "She is remembered for winning best in show as a breeder." and $slaves[$i].assignment is "get treatment in the clinic">>
-		She does her best to aid the breeder $slaves[$i].slaveName, paying special attention to her fertility and reproductive organs.
-	<</if>>
-	<<if $slaves[$i].bellyImplant > 0 && $clinicInflateBelly == 1 && $slaves[$i].assignment == "get treatment in the clinic">>
-		<br>''@@color:pink;$slaves[$i].slaveName@@'' spent a lot of time during the week under IV-like stands with bags of innert filler steadily flowing into her belly implant, slowly pushing her belly further and further out. Careful attention, along with several drug injections, were used to make sure her body was able to safely adjust to the implant's rapid growth.
-		<<set $slaves[$i].bellyImplant += 1000>>
-		<<set $slaves[$i].health -= 10>>
-		<<if ($slaves[$i].devotion > 50)>>
-			<<set $slaves[$i].devotion += 4>>
-			<<set $slaves[$i].trust += 3>>
-		<<elseif ($slaves[$i].devotion >= -20)>>
-			<<set $slaves[$i].trust -= 5>>
+	<<if $slaves[_i].prestigeDesc is "She is remembered for winning best in show as a breeder." && $slaves[$i].preg > 10>>
+		She does her best to aid the pregnant $slaves[_i].slaveName, paying special attention to her swollen belly and the welfare of the life within.
+	<</if>>
+	<<if $slaves[_i].prestigeDesc is "She is remembered for winning best in show as a breeder.">>
+		She does her best to aid the breeder $slaves[_i].slaveName, paying special attention to her fertility and reproductive organs.
+	<</if>>
+	<<if $slaves[_i].bellyImplant > 0 && $clinicInflateBelly == 1>>
+		<br>''@@color:pink;$slaves[_i].slaveName@@'' spent a lot of time during the week under IV-like stands with bags of innert filler steadily flowing into her belly implant, slowly pushing her belly further and further out. Careful attention, along with several drug injections, were used to make sure her body was able to safely adjust to the implant's rapid growth.
+		<<set $slaves[_i].bellyImplant += 1000>>
+		<<set $slaves[_i].health -= 10>>
+		<<if ($slaves[_i].devotion > 50)>>
+			<<set $slaves[_i].devotion += 4, $slaves[_i].trust += 3>>
+		<<elseif ($slaves[_i].devotion >= -20)>>
+			<<set $slaves[_i].trust -= 5>>
 		<<else>>
-			<<set $slaves[$i].devotion -= 5>>
-			<<set $slaves[$i].trust -= 10>>
+			<<set $slaves[_i].devotion -= 5, $slaves[_i].trust -= 10>>
 		<</if>>
-		<<if $slaves[$i].bellyImplant > 10000 && $arcologies[0].FSTransformationFetishistResearch != 1>>
-			<<set $slaves[$i].bellyImplant = 10000 >>
+		<<if $slaves[_i].bellyImplant > 10000 && $arcologies[0].FSTransformationFetishistResearch != 1>>
+			<<set $slaves[_i].bellyImplant = 10000 >>
 			She filled to the maximum that her body can stand.
-		<<elseif $slaves[$i].bellyImplant > 40000 >>
-			<<set $slaves[$i].bellyImplant = 40000 >>
+		<<elseif $slaves[_i].bellyImplant > 40000 >>
+			<<set $slaves[_i].bellyImplant = 40000 >>
 			She filled to the maximum that her body can stand.
 		<</if>>
 	<</if>>
-	<<if $slaves[$i].preg >= 1 && $slaves[$i].preg < 31 && $slaves[$i].pregControl == "speed up")>>
-		<br>''@@color:pink;$slaves[$i].slaveName@@'' spends most of her time on bedrest being filled with rapid gestation agents and concentrated slave food. All she can do is <<if $slaves[$i].amp != 1 && canSee($slaves[$i])>>watch and feel her belly pushing further and further out with life<<elseif $slaves[$i].amp != 1>>watch her belly bulging further and further out with life<<elseif !canSee($slaves[$i])>>feel her belly pushing further and further out with life beneath her fingers<<else>>feel the every growing pressure inside her abdomen<</if>>. Careful attention, along with numerous drug injections, are used to make sure her body is able to safely adjust to her pregnancy's rapid growth.
-		<<set $slaves[$i].health -= 10>>
-		<<if ($slaves[$i].devotion > 50)>>
-			<<set $slaves[$i].devotion += 2>>
-			<<set $slaves[$i].trust += 1>>
-		<<elseif ($slaves[$i].devotion >= -20)>>
-			<<set $slaves[$i].trust -= 5>>
+	<<if $slaves[_i].preg >= 1 && $slaves[_i].preg < 31 && $slaves[_i].pregControl == "speed up")>>
+		<br>''@@color:pink;$slaves[_i].slaveName@@'' spends most of her time on bedrest being filled with rapid gestation agents and concentrated slave food. All she can do is <<if $slaves[_i].amp != 1 && canSee($slaves[_i])>>watch and feel her belly pushing further and further out with life<<elseif $slaves[_i].amp != 1>>watch her belly bulging further and further out with life<<elseif !canSee($slaves[_i])>>feel her belly pushing further and further out with life beneath her fingers<<else>>feel the every growing pressure inside her abdomen<</if>>. Careful attention, along with numerous drug injections, are used to make sure her body is able to safely adjust to her pregnancy's rapid growth.
+		<<set $slaves[_i].health -= 10>>
+		<<if ($slaves[_i].devotion > 50)>>
+			<<set $slaves[_i].devotion += 2, $slaves[_i].trust += 1>>
+		<<elseif ($slaves[_i].devotion >= -20)>>
+			<<set $slaves[_i].trust -= 5>>
 		<<else>>
-			<<set $slaves[$i].devotion -= 5>>
-			<<set $slaves[$i].trust -= 10>>
+			<<set $slaves[_i].devotion -= 5, $slaves[_i].trust -= 10>>
 		<</if>>
-		<<if $slaves[$i].preg >= 31 && $slaves[$i].pregControl == "speed up">>
-			<<set $slaves[$i].pregControl == "none">>
-			''@@color:pink;$slaves[$i].slaveName's@@'' child is ready to pop out of her womb, ''@@color:yellow;her course of rapid gestation agents is finished''.
+		<<if $slaves[_i].preg >= 31 && $slaves[_i].pregControl == "speed up">>
+			<<set $slaves[_i].pregControl == "none">>
+			''@@color:pink;$slaves[_i].slaveName's@@'' child is ready to pop out of her womb, ''@@color:yellow;her course of rapid gestation agents is finished''.
 		<</if>>
 	<</if>>
 	<</for>>
 	<<if ($clinicSlaves < $clinic)>>
-		<<set $seed to random(1,10)+(($clinic-$clinicSlaves)*(random(150,170)+($idleBonus*10)))>>
-		<<set $cash += $seed>>
-		Since $Nurse.slaveName doesn't have enough girls to occupy all her time, the clinic takes in citizens' slaves on a contract basis and she helps them too, earning @@color:yellowgreen;¤$seed.@@
+		<<set _seed to random(1,10)+(($clinic-$clinicSlaves)*(random(150,170)+(_idleBonus*10)))>>
+		<<set $cash += _seed>>
+		Since $Nurse.slaveName doesn't have enough girls to occupy all her time, the clinic takes in citizens' slaves on a contract basis and she helps them too, earning @@color:yellowgreen;¤_seed.@@
 	<</if>>
 	<</if>>
 
-	<<if ($restedSlaves > 0)>>
-	<<if ($restedSlaves == 1)>>
-		One slave has been returned to @@color:green;health@@<<if $clinicUpgradeFilters == 1>> and @@color:green;purity@@<</if>> and will be released from the clinic before the end of the week.
+	<<if (_restedSlaves > 0)>>
+	<<if (_restedSlaves == 1)>>
+		One slave has
 	<<else>>
-		$restedSlaves slaves have been returned to @@color:green;health@@<<if $clinicUpgradeFilters == 1>> and @@color:green;purity@@<</if>> and will be released from the clinic before the end of the week.
+		_restedSlaves slaves have
 	<</if>>
+	been returned to @@color:green;health@@<<if $clinicUpgradeFilters == 1>> and @@color:green;purity@@<</if>> and will be released from the clinic before the end of the week.
 	<<if $clinicDecoration != "standard">>
-		$clinicNameCaps's $clinicDecoration atmosphere @@color:hotpink;had an impact on <<if $restedSlaves == 1>>her while she<<else>>them while they<</if>>@@ were getting treatment.
+		$clinicNameCaps's $clinicDecoration atmosphere @@color:hotpink;had an impact on <<if _restedSlaves == 1>>her while she<<else>>them while they<</if>>@@ were getting treatment.
 	<</if>>
-	<<set $clinicSlaves -= $restedSlaves>>
+	<<set $clinicSlaves -= _restedSlaves>>
 	<</if>>
 
-<<elseif ($Nurse != 0)>>
-	''$clinicNameCaps is empty'' except for $Nurse.slaveName, the nurse.
-	<<set $seed to random(1,10)+(($clinic-$clinicSlaves)*(random(150,170)+($idleBonus*10)))>>
-	<<set $cash += $seed>>
-	Since she doesn't have enough of your slaves under her care to fill her time, the Clinic admits citizens' slaves, earning @@color:yellowgreen;¤$seed.@@
-
 <<else>>
 	''$clinicNameCaps is empty.''
+	<<if ($Nurse != 0)>>
+		<<set _seed to random(1,10)+(($clinic-$clinicSlaves)*(random(150,170)+(_idleBonus*10)))>>
+		<<set $cash += _seed>>
+		except for $Nurse.slaveName, the nurse. Since she doesn't have any of your slaves under her care to fill her time, the Clinic admits citizens' slaves, earning @@color:yellowgreen;¤_seed.@@
+	<</if>>
 <</if>>
 <br><br>
diff --git a/src/uncategorized/fsDevelopments.tw b/src/uncategorized/fsDevelopments.tw
index 84db7564601820c49676dd6d23cbbc2aabee181e..229a4ce773582f537dfee70720fbaea7158015f9 100644
--- a/src/uncategorized/fsDevelopments.tw
+++ b/src/uncategorized/fsDevelopments.tw
@@ -117,7 +117,7 @@ __Society__
 	<</if>>
 	<</if>>
 	<<if ($FSGotRepCreditFour != 1)>>
-	<<if ($rep > 1500)>>
+	<<if ($rep > 15000)>>
 		@@color:yellow;Your reputation is so great that $arcologies[0].name's society is ready to begin accepting a fifth societal direction.@@
 		<<set $FSGotRepCreditFour = 1>>
 		<<set $FSCredits += 1>>
diff --git a/src/uncategorized/generateXXSlave.tw b/src/uncategorized/generateXXSlave.tw
index ab5e14b7e3a4e4187436d00a58f1867fadaa5308..9fc4c6363caa024d20fcac9be59bdb8cc7a7bac1 100644
--- a/src/uncategorized/generateXXSlave.tw
+++ b/src/uncategorized/generateXXSlave.tw
@@ -1,6 +1,6 @@
 :: Generate XX Slave [nobr]
 
-<<set $activeSlave to {slaveName: "blank", birthName: "blank", weekAcquired: 0, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), age: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race:"white", markings: "none", eyes: 1, eyeColor: "brown", eyewear: "none", hColor: "brown", pubicHColor: "brown", skin: "light", hLength: 60, hStyle: "short", pubicHStyle: "neat", waist: 0, corsetPiercing: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 0, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 0, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "normal", tonguePiercing: 0, vagina: 0, vaginaLube: 1, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregSource: 0, pregType: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 0, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, balls: 0, scrotum: 0, ovaries: 1, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules:"restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", buttplug: "none", intelligence: 0,  intelligenceImplant: 0, energy: 50, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customImage: 0, currentRules: [], bellyTat: 0, induce: 0, mpreg: 0, inflation: 0, inflationType: "none", inflationMethod: 0, milkSource: 0, cumSource: 0, burst: 0, bellyImplant: 0, bellySag: 0, birthsTotal: 0, pubertyAgeXX: 13, pubertyAgeXY: 13, underArmHStyle: "waxed", physicalAge: 18, actualAge: 18, visualAge: 18, father: 0, mother: 0, sisters: 0, daughters: 0, canRecruit: 1, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none"}>>
+<<set $activeSlave to {slaveName: "blank", birthName: "blank", weekAcquired: 0, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), age: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race:"white", markings: "none", eyes: 1, eyeColor: "brown", eyewear: "none", hColor: "brown", pubicHColor: "brown", skin: "light", hLength: 60, hStyle: "short", pubicHStyle: "neat", waist: 0, corsetPiercing: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 0, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 0, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "normal", tonguePiercing: 0, vagina: 0, vaginaLube: 1, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregSource: 0, pregType: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 0, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, balls: 0, scrotum: 0, ovaries: 1, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules:"restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", buttplug: "none", intelligence: 0,  intelligenceImplant: 0, energy: 50, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customImage: 0, currentRules: [], bellyTat: 0, induce: 0, mpreg: 0, inflation: 0, inflationType: "none", inflationMethod: 0, milkSource: 0, cumSource: 0, burst: 0, bellyImplant: 0, bellySag: 0, birthsTotal: 0, pubertyAgeXX: 13, pubertyAgeXY: 13, underArmHStyle: "waxed", physicalAge: 18, actualAge: 18, visualAge: 18, father: 0, mother: 0, sisters: 0, daughters: 0, canRecruit: 1, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none", readyLimbs: []}>>
 
 <<set $activeSlave.publicCount to 0>>
 <<if $activeSlaveOneTimeMaxAge > 998>>
diff --git a/src/uncategorized/generateXYSlave.tw b/src/uncategorized/generateXYSlave.tw
index 72cb0e72ab434e22868d38a7ad005ab8113efdad..224c0b5833dea8e508c0fc6cf034abc3173e9f2b 100644
--- a/src/uncategorized/generateXYSlave.tw
+++ b/src/uncategorized/generateXYSlave.tw
@@ -1,6 +1,6 @@
 :: Generate XY Slave [nobr]
 
-<<set $activeSlave to {slaveName: "blank", birthName: "blank", weekAcquired: 0, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), age: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race:"white", markings: "none", eyes: 1, eyeColor: "brown", eyewear: "none", hColor: "brown", pubicHColor: "brown", skin: "light", hLength: 10, hStyle: "short", pubicHStyle: "neat", waist: 0, corsetPiercing: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 0, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 0, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "normal", tonguePiercing: 0, vagina: 0, vaginaLube: 0, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregSource: 0, pregType: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 0, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, balls: 0, scrotum: 0, ovaries: 0, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules:"restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", buttplug: "none", intelligence: 0,  intelligenceImplant: 0, energy: 50, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customImage: 0, currentRules: [], bellyTat: 0, induce: 0, mpreg: 0, inflation: 0, inflationType: "none", inflationMethod: 0, milkSource: 0, cumSource: 0, burst: 0, bellyImplant: 0, bellySag: 0, birthsTotal: 0, pubertyAgeXX: 13, pubertyAgeXY: 13, underArmHStyle: "waxed", physicalAge: 18, actualAge: 18, visualAge: 18, father: 0, mother: 0, sisters: 0, daughters: 0, canRecruit: 1, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none"}>>
+<<set $activeSlave to {slaveName: "blank", birthName: "blank", weekAcquired: 0, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), age: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race:"white", markings: "none", eyes: 1, eyeColor: "brown", eyewear: "none", hColor: "brown", pubicHColor: "brown", skin: "light", hLength: 10, hStyle: "short", pubicHStyle: "neat", waist: 0, corsetPiercing: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 0, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 0, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "normal", tonguePiercing: 0, vagina: 0, vaginaLube: 0, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregSource: 0, pregType: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 0, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, balls: 0, scrotum: 0, ovaries: 0, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules:"restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", buttplug: "none", intelligence: 0,  intelligenceImplant: 0, energy: 50, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customImage: 0, currentRules: [], bellyTat: 0, induce: 0, mpreg: 0, inflation: 0, inflationType: "none", inflationMethod: 0, milkSource: 0, cumSource: 0, burst: 0, bellyImplant: 0, bellySag: 0, birthsTotal: 0, pubertyAgeXX: 13, pubertyAgeXY: 13, underArmHStyle: "waxed", physicalAge: 18, actualAge: 18, visualAge: 18, father: 0, mother: 0, sisters: 0, daughters: 0, canRecruit: 1, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none", readyLimbs: []}>>
 
 <<set $activeSlave.publicCount to 0>>
 <<if $activeSlaveOneTimeMaxAge > 998>>
diff --git a/src/uncategorized/options.tw b/src/uncategorized/options.tw
index 69aedcb06e75ad7e9d20d81c3f9c6acec4ba295b..c13a02ff86a9b786c9b83b8da6478a661f24bb89 100644
--- a/src/uncategorized/options.tw
+++ b/src/uncategorized/options.tw
@@ -144,14 +144,13 @@ Assignment performance vignettes on the end week report are
 /* Accordion 000-250-006 */
 <br />
 	Accordion effects on weekly reports are 
-<<if ndef $useAccordion>>
+<<if ($useAccordion neq 1)>>
 	@@color:red;DISABLED@@. [[Enable|Options][$useAccordion to 1]]
 <<else>>
-	@@color:cyan;ENABLED@@. [[Disable|Options][unset $useAccordion]]
+	@@color:cyan;ENABLED@@. [[Disable|Options][$useAccordion to 0]]
 <</if>>
 /* Accordion 000-250-006 */
 
-
 <br>
 
 <<if $verboseDescriptions == 1>>
diff --git a/src/uncategorized/personalAssistantAppearance.tw b/src/uncategorized/personalAssistantAppearance.tw
index f278b6c13d638d19409b1c054a7f0da199e827e1..9bbbdaa81bd2a351323654b1a88580d77e5b48be 100644
--- a/src/uncategorized/personalAssistantAppearance.tw
+++ b/src/uncategorized/personalAssistantAppearance.tw
@@ -89,7 +89,7 @@ She's a cute little <<if $arcologies[0].FSSupremacist != "unset">>$arcologies[0]
 	<<case "edo revivalist">>
 		She's wearing a brief Japanese bathhouse robe.
 	<<case "arabian revivalist">>
-		She's dressed herself like an oil millionare, with aviator sunglasses and a headscarf.
+		She's dressed herself like an oil millionaire, with aviator sunglasses and a headscarf.
 	<<case "chinese revivalist">>
 		She's added various tattoos of rude Chinese characters to her body recently.
 	<<case "chattel religionist">>
@@ -474,7 +474,7 @@ She's a cute little <<if $arcologies[0].FSSupremacist != "unset">>$arcologies[0]
 	<<case "edo revivalist">>
 	  She's wearing a brief Japanese bathhouse robe.  Occasionally a stream of liquid pours from her crotch along with a healthy baby.
 	<<case "arabian revivalist">>
-	  She's dressed herself like an oil millionare's broodmother, with silken linens.  Occasionally a stream of liquid pours from her crotch along with a healthy baby.
+	  She's dressed herself like an oil millionaire's broodmother, with silken linens.  Occasionally a stream of liquid pours from her crotch along with a healthy baby.
 	<<case "chinese revivalist">>
 	  She's added various tattoos of rude Chinese characters to her body recently.  Occasionally a stream of liquid pours from her crotch along with a healthy baby.
 	<<case "chattel religionist">>
diff --git a/src/uncategorized/reMilfTourist.tw b/src/uncategorized/reMilfTourist.tw
index 1607c1e98387bfc298a353e31cb817fe346e3b59..8b31df3b8538d950c47c98db4c8871e6e278d6ee 100644
--- a/src/uncategorized/reMilfTourist.tw
+++ b/src/uncategorized/reMilfTourist.tw
@@ -32,7 +32,7 @@
 		<<else>>
 			$assistantAppearance avatar
 		<</if>>
-		appears on your desk in the middle of the day. "Something unusual for you, <<if $PC.title == 1>>Sir<<else>>Ma'am<</if>>," she says. "$subSlave.slaveName is out doing public service. A tourist from the old world accosted her. $subSlave.slaveName thought she was a rich citizen who wanted to fuck her, but it turns out she just wanted a tour guide. It was a reasonable mistake; she seems wealthy. $subSlave.slaveName has been showing her around for the last half hour. Now she's asked $subSlave.slaveName if she can meet you." She displays a video feed showing $subSlave.slaveName standing with the tourist in question out on the main plaza. She's just into middle age, and extremely plush, wearing capri pants over her motherly hips and a cashmere sweater that understates her generous bust. She's blushing as she asks $subSlave.slaveName a discreet question about public sex in the arcology, brought on by the sight of a couple of citizens spitroasting a slave. Your personal assisant's avatar
+		appears on your desk in the middle of the day. "Something unusual for you, <<if $PC.title == 1>>Sir<<else>>Ma'am<</if>>," she says. "$subSlave.slaveName is out doing public service. A tourist from the old world accosted her. $subSlave.slaveName thought she was a rich citizen who wanted to fuck her, but it turns out she just wanted a tour guide. It was a reasonable mistake; she seems wealthy. $subSlave.slaveName has been showing her around for the last half hour. Now she's asked $subSlave.slaveName if she can meet you." She displays a video feed showing $subSlave.slaveName standing with the tourist in question out on the main plaza. She's just into middle age, and extremely plush, wearing capri pants over her motherly hips and a cashmere sweater that understates her generous bust. She's blushing as she asks $subSlave.slaveName a discreet question about public sex in the arcology, brought on by the sight of a couple of citizens spitroasting a slave. Your personal assistant's avatar
 		<<if $assistantAppearance is "monstergirl">>
 			bares her fangs and makes pinching gestures at nipple height.
 		<<elseif $assistantAppearance is "shemale">>
diff --git a/src/uncategorized/reRecruit.tw b/src/uncategorized/reRecruit.tw
index b75a49aa56417b12d311ae309c362769ad7bef25..3137c112fd502e7c974816114380aace84103b1f 100644
--- a/src/uncategorized/reRecruit.tw
+++ b/src/uncategorized/reRecruit.tw
@@ -1339,12 +1339,12 @@ Knowing what's coming, the teachers in the facility do train their pupils accord
 
 You've been kept busy until late at night. The warm blue glow of your desk screen illuminates your work. Suddenly, your assistant flags an incoming vidcall as urgent. The call had decent encryption, but could be traced to a rural location several miles away from your arcology. The callers only specified that they had a good deal to offer.
 <br><br>
-With apprehension, you decide to let the call through. The screen switches from your work to the vidcall. Several armed men, cloaked in black, are standing around a pretty young girl. She's gagged and bound to a chair. b
+With apprehension, you decide to let the call through. The screen switches from your work to the vidcall. Several armed men, cloaked in black, are standing around a pretty young girl. She's gagged and bound to a chair.
 <br><br>
 The men explain that they've captured the young daughter of a wealthy old-world businessman, by abducting her straight from a gated community. It's far from uncommon for girls to be captured and sold as slaves, but that these men had the balls to raid a gated community is something else. There are still some places in the world that are considered safe, where the world's deterioration isn't readily apparent. Showing that these places aren't safe from the predations of slavers upsets what little balance that the old world still has left, and that isn't always a good thing for the Free Cities.<br><br>
 At any rate, she's a fine capture. And unsurprisingly, they want to get rid of her. Fast. They're willing to offer a below-market price for her enslavement.
 <br><br>
-//You can buy out her auction for ¤10000.
+//You can buy out her auction for ¤10000.//
 
 <<else>>
 
diff --git a/src/uncategorized/schoolroomReport.tw b/src/uncategorized/schoolroomReport.tw
index c4b8d3a253c816e497bfe808143e2175e2ebd1ca..3dff4a806db8a68cf5fc5c3576f122f21a431440 100644
--- a/src/uncategorized/schoolroomReport.tw
+++ b/src/uncategorized/schoolroomReport.tw
@@ -1,73 +1,78 @@
 :: Schoolroom Report [nobr]
 
+<<set $schoolroomSlaves = 0, _idleBonus = 0, _schoolteacherFetish = 0, _SL = $slaves.length, _ST = -1>>
 
-<<set $schoolroomSlaves to 0>>
-<<set $schoolteacherFetish to 0>>
-<<set $idleBonus to 0>>
-
-<<for $i to 0; $i < $slaves.length; $i++>>
-<<if ($slaves[$i].assignment is "learn in the schoolroom")>>
-	<<if $seeImages == 1>><<SlaveArt $slaves[$i] 0 0>><</if>>
-	<<set $schoolroomSlaves += 1>>
-	<<silently>>
-	<<display [[SA take classes]]>>
-	<<display "SA long term effects">>
-	<<display "SA relationships">>
-	<<display "SA rivalries">>
-	<</silently>>
-	<<if $schoolroomDecoration != "standard">>
-	<<set $slaves[$i].devotion += 1>>
-	<</if>>
-	<<if ($slaves[$i].health < -80)>>
-	<<set $slaves[$i].health += 20>>
-	<<elseif ($slaves[$i].health < -40)>>
-	<<set $slaves[$i].health += 10>>
-	<<elseif ($slaves[$i].health < 0)>>
-	<<set $slaves[$i].health += 7>>
-	<<elseif ($slaves[$i].health < 90)>>
-	<<set $slaves[$i].health += 3>>
-	<</if>>
-<<elseif ($Schoolteacher != 0) && ($slaves[$i].ID is $Schoolteacher.ID)>>
+<<if $Schoolteacher != 0>>
+<<for _ST = 0; _ST < _SL; _ST++>>
+<<if $slaves[_ST].ID == $Schoolteacher.ID>>
+	<<break>>
+<</if>>
+<</for>>
+<</if>>
+<<if _ST != -1>>
+	<<if $seeImages == 1>><<SlaveArt $slaves[_ST] 0 0>><</if>>
+	<<set $i = _ST>>
 	<<silently>>
 	<<display "SA long term effects">>
 	<<display "SA relationships">>
 	<<display "SA rivalries">>
 	<</silently>>
-	<<if ($slaves[$i].health < -80)>>
-	<<set $slaves[$i].health += 20>>
-	<<elseif ($slaves[$i].health < -40)>>
-	<<set $slaves[$i].health += 15>>
-	<<elseif ($slaves[$i].health < 0)>>
-	<<set $slaves[$i].health += 10>>
-	<<elseif ($slaves[$i].health < 90)>>
-	<<set $slaves[$i].health += 7>>
-	<</if>>
-	<<if ($slaves[$i].devotion <= 60)>>
-	<<set $slaves[$i].devotion += 1>>
+	<<if ($slaves[_ST].health < -80)>>
+	<<set $slaves[_ST].health += 20>>
+	<<elseif ($slaves[_ST].health < -40)>>
+	<<set $slaves[_ST].health += 15>>
+	<<elseif ($slaves[_ST].health < 0)>>
+	<<set $slaves[_ST].health += 10>>
+	<<elseif ($slaves[_ST].health < 90)>>
+	<<set $slaves[_ST].health += 7>>
+	<</if>>
+	<<if ($slaves[_ST].devotion <= 60)>>
+	<<set $slaves[_ST].devotion += 1>>
 	<</if>>
 	<<if $schoolroomDecoration != "standard">>
-	<<set $slaves[$i].devotion += 1>>
+	<<set $slaves[_ST].devotion += 1>>
 	<</if>>
-	<<if ($slaves[$i].trust < -30)>>
-	<<set $slaves[$i].trust += 1>>
+	<<if ($slaves[_ST].trust < -30)>>
+	<<set $slaves[_ST].trust += 1>>
 	<</if>>
-	<<if $slaves[$i].fetishStrength <= 95>>
-	<<if $slaves[$i].fetish != "dom">>
-		<<fetishChangeChance $slaves[$i]>>
+	<<if $slaves[_ST].fetishStrength <= 95>>
+	<<if $slaves[_ST].fetish != "dom">>
+		<<fetishChangeChance $slaves[_ST]>>
 		<<if $fetishChangeChance > random(0,100)>>
-			<<set $schoolteacherFetish to 1>>
-			<<set $slaves[$i].fetishKnown to 1>>
-			<<set $slaves[$i].fetish to "dom">>
+			<<set _schoolteacherFetish to 1, $slaves[_ST].fetishKnown to 1, $slaves[_ST].fetish to "dom">>
 		<</if>>
-	<<elseif $slaves[$i].fetishKnown == 0>>
-		<<set $schoolteacherFetish to 1>>
-		<<set $slaves[$i].fetishKnown to 1>>
+	<<elseif $slaves[_ST].fetishKnown == 0>>
+		<<set _schoolteacherFetish to 1, $slaves[_ST].fetishKnown to 1>>
 	<<else>>
-		<<set $schoolteacherFetish to 2>>
-		<<set $slaves[$i].fetishStrength += 4>>
+		<<set _schoolteacherFetish to 2, $slaves[_ST].fetishStrength += 4>>
 	<</if>>
 	<</if>>
+	<<set $Schoolteacher = $slaves[_ST]>>
 <</if>>
+
+<<for _i to 0; _i < _SL; _i++>>
+	<<if ($slaves[_i].assignment != "learn in the schoolroom")>><<continue>><</if>>
+	<<if $seeImages == 1>><<SlaveArt $slaves[_i] 0 0>><</if>>
+	<<set $schoolroomSlaves++>>
+	<<silently>>
+	<<set $i = _i>>
+	<<display "SA take classes">>
+	<<display "SA long term effects">>
+	<<display "SA relationships">>
+	<<display "SA rivalries">>
+	<</silently>>
+	<<if $schoolroomDecoration != "standard">>
+	<<set $slaves[_i].devotion++>>
+	<</if>>
+	<<if ($slaves[_i].health < -80)>>
+	<<set $slaves[_i].health += 20>>
+	<<elseif ($slaves[_i].health < -40)>>
+	<<set $slaves[_i].health += 10>>
+	<<elseif ($slaves[_i].health < 0)>>
+	<<set $slaves[_i].health += 7>>
+	<<elseif ($slaves[_i].health < 90)>>
+	<<set $slaves[_i].health += 3>>
+	<</if>>
 <</for>>
 
 <<if ($schoolroomSlaves > 0)>>
@@ -75,10 +80,10 @@
 	<<if ($schoolroomSlaves == 1)>>''There is one slave studying in $schoolroomName.''<<else>>''There are $schoolroomSlaves slaves studying in $schoolroomName.''<</if>>
 
 	<<if ($Schoolteacher != 0)>>
-	$Schoolteacher.slaveName is serving as your schoolteacher.<<if $Schoolteacher.relationship is -3>>  As your wife, she tries her best to teach her pupils how to please you.<</if>>
-	<<if ($schoolteacherFetish == 1)>>
+	$Schoolteacher.slaveName is serving as your schoolteacher.<<if $Schoolteacher.relationship is -3>> As your wife, she tries her best to teach her pupils how to please you.<</if>>
+	<<if (_schoolteacherFetish == 1)>>
 		She's allowed and even expected to use her students for her own sexual gratification, and in their own way her students are complicit, offering sexual favors for an easier time in the classroom. Before long, she's running a hungry eye over the tits and asses of new trainees; she now @@color:lightcoral;more dominant.@@
-	<<elseif ($schoolteacherFetish == 2)>>
+	<<elseif (_schoolteacherFetish == 2)>>
 		Every new student in class is a new target for her personal educational attention. @@color:lightsalmon;She becomes more dominant.@@
 	<</if>>
 	<<if $schoolteacherCareers.contains($Schoolteacher.career)>>
@@ -86,75 +91,70 @@
 	<</if>>
 	<<if ($Schoolteacher.visualAge > 35)>>
 		Her age earns her the respect of her students.
-		<<set $idleBonus += 1>>
+		<<set _idleBonus++>>
 	<</if>>
 	<<if ($Schoolteacher.intelligence > 0)>>
 		She's intelligent enough to be a good teacher.
-		<<set $idleBonus += 1>>
+		<<set _idleBonus++>>
 	<</if>>
 	<<if ($Schoolteacher.intelligenceImplant == 1)>>
 		Since she's educated herself, she understands her students.
-		<<set $idleBonus += 1>>
+		<<set _idleBonus++>>
 	<</if>>
 	<<if ($Schoolteacher.face > 1)>>
 		Her students want to be just like their beautiful teacher.
-		<<set $idleBonus += 1>>
+		<<set _idleBonus++>>
 	<</if>>
-	<<for $i to 0; $i < $slaves.length; $i++>>
+	<<for _i to 0; _i < _SL; _i++>>
+	<<if $slaves[_i].assignment != "learn in the schoolroom">><<continue>><</if>>
 	<<if $familyTesting == 1>>
-		<<if $slaves[$i].assignment == "learn in the schoolroom">>
-		<<if $slaves[$i].mother == $Schoolteacher.ID>>
-			She makes sure to spend extra time teaching her daughter, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
+		<<if $slaves[_i].mother == $Schoolteacher.ID>>
+			She makes sure to spend extra time teaching her daughter, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
-		<<if $slaves[$i].father == $Schoolteacher.ID>>
-			She makes sure to spend extra time teaching her daughter, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
+		<<if $slaves[_i].father == $Schoolteacher.ID>>
+			She makes sure to spend extra time teaching her daughter, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
-		<<if $slaves[$i].ID == $Schoolteacher.father>>
-			She makes sure to spend extra time teaching her father, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
+		<<if $slaves[_i].ID == $Schoolteacher.father>>
+			She makes sure to spend extra time teaching her father, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
-		<<if $slaves[$i].ID == $Schoolteacher.mother>>
-			She makes sure to spend extra time teaching her mother, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
-		<</if>>
-		<<if areSisters($slaves[$i], $Schoolteacher) == 1>>
-			She makes sure to spend extra time teaching her twin, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
-		<<elseif areSisters($slaves[$i], $Schoolteacher) == 2>>
-			She makes sure to spend extra time teaching her sister, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
-		<<elseif areSisters($slaves[$i], $Schoolteacher) == 3>>
-			She makes sure to spend extra time teaching her half-sister, $slaves[$i].slaveName.
-			<<set $slaves[$i].trust += 1>>
+		<<if $slaves[_i].ID == $Schoolteacher.mother>>
+			She makes sure to spend extra time teaching her mother, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
+		<<if areSisters($slaves[_i], $Schoolteacher) == 1>>
+			She makes sure to spend extra time teaching her twin, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
+		<<elseif areSisters($slaves[_i], $Schoolteacher) == 2>>
+			She makes sure to spend extra time teaching her sister, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
+		<<elseif areSisters($slaves[_i], $Schoolteacher) == 3>>
+			She makes sure to spend extra time teaching her half-sister, $slaves[_i].slaveName.
+			<<set $slaves[_i].trust += 1>>
 		<</if>>
 	<<else>>
-	<<if $Schoolteacher.relationTarget is $slaves[$i].ID and $slaves[$i].assignment is "learn in the schoolroom">>
-		She makes sure to spend extra time teaching her $slaves[$i].relation, $slaves[$i].slaveName.
-		<<set $slaves[$i].trust += 1>>
-	<</if>>
+	<<if $Schoolteacher.relationTarget is $slaves[_i].ID>>
+		She makes sure to spend extra time teaching her $slaves[_i].relation, $slaves[_i].slaveName.
+		<<set $slaves[_i].trust += 1>>
 	<</if>>
-	<<if $Schoolteacher.relationshipTarget is $slaves[$i].ID and $slaves[$i].assignment is "learn in the schoolroom">>
-		She dedicates most of her attention to her <<if $Schoolteacher.relationship == 1>>friend<<elseif $Schoolteacher.relationship is 2>>best friend<<elseif $Schoolteacher.relationship is 3>>friend with benefits<<elseif $Schoolteacher.relationship is 4>>lover<<elseif $Schoolteacher.relationship is 5>>slave wife<</if>>, $slaves[$i].slaveName making sure she understands that day's lesson.
-		<<set $slaves[$i].devotion += 2>>
-		<<set $slaves[$i].trust += 2>>
+	<<if $Schoolteacher.relationshipTarget is $slaves[_i].ID>>
+		She dedicates most of her attention to her <<if $Schoolteacher.relationship == 1>>friend<<elseif $Schoolteacher.relationship is 2>>best friend<<elseif $Schoolteacher.relationship is 3>>friend with benefits<<elseif $Schoolteacher.relationship is 4>>lover<<elseif $Schoolteacher.relationship is 5>>slave wife<</if>>, $slaves[_i].slaveName making sure she understands that day's lesson.
+		<<set $slaves[_i].devotion += 2, $slaves[_i].trust += 2>>
 	<</if>>
-	<<if $Schoolteacher.rivalryTarget is $slaves[$i].ID and $slaves[$i].assignment is "learn in the schoolroom">>
-		Ever since her <<if $Schoolteacher.rivalry == 1>>growing rival<<elseif $Schoolteacher.rivalry is 2>>rival<<elseif $Schoolteacher.rivalry is 3>>bitter rival<</if>>, was enrolled, she began stalking the classroom carrying a large paddle, much to $slaves[$i].slaveName terror.
-		<<set $slaves[$i].devotion -= 4>>
-		<<set $slaves[$i].trust -= 4>>
+	<<if $Schoolteacher.rivalryTarget is $slaves[_i].ID>>
+		Ever since her <<if $Schoolteacher.rivalry == 1>>growing rival<<elseif $Schoolteacher.rivalry is 2>>rival<<elseif $Schoolteacher.rivalry is 3>>bitter rival<</if>>, was enrolled, she began stalking the classroom carrying a large paddle, much to $slaves[_i].slaveName terror.
+		<<set $slaves[_i].devotion -= 4, $slaves[_i].trust -= 4>>
 		<<if random(1,100) > 35>>
-			<<set $Schoolteacher.rivalry += 1>>
-		<<set $slaves[$i].rivalry += 1>>
+			<<set $Schoolteacher.rivalry += 1, $slaves[_ST].rivalry += 1, $slaves[_i].rivalry += 1>>
 		<</if>>
 	<</if>>
 	<</for>>
 	<<if ($schoolroomSlaves < $schoolroom)>>
-		<<set $seed to random(1,10)+(($schoolroom-$schoolroomSlaves)*(random(150,170)+($idleBonus*10)))>>
-		<<set $cash += $seed>>
-		Since she doesn't have enough students to occupy all her time, $schoolroomName takes in citizens' slaves on a contract basis and she teaches them too, earning @@color:yellowgreen;¤$seed.@@
+		<<set _seed to random(1,10)+(($schoolroom-$schoolroomSlaves)*(random(150,170)+(_idleBonus*10)))>>
+		<<set $cash += _seed>>
+		Since she doesn't have enough students to occupy all her time, $schoolroomName takes in citizens' slaves on a contract basis and she teaches them too, earning @@color:yellowgreen;¤_seed.@@
 	<</if>>
 	<</if>>
 
@@ -163,10 +163,9 @@
 	<</if>>
 
 <<elseif ($Schoolteacher != 0)>>
-	''$schoolroomNameCaps is empty'' except for $Schoolteacher.slaveName, the schoolteacher.
-	<<set $seed to random(1,10)+(($schoolroom-$schoolroomSlaves)*(random(150,170)+($idleBonus*10)))>>
-	<<set $cash += $seed>>
-	Since she doesn't have anyone to teach, she teaches citizens' slaves, earning @@color:yellowgreen;¤$seed.@@
+	<<set _seed to random(1,10)+(($schoolroom-$schoolroomSlaves)*(random(150,170)+(_idleBonus*10)))>>
+	<<set $cash += _seed>>
+	''$schoolroomNameCaps is empty'' except for $Schoolteacher.slaveName, the schoolteacher. Since she doesn't have anyone to teach, she teaches citizens' slaves, earning @@color:yellowgreen;¤_seed.@@
 
 <<else>>
 	''$schoolroomNameCaps is empty.''
diff --git a/src/uncategorized/slaveAssignmentsReport.tw b/src/uncategorized/slaveAssignmentsReport.tw
index 9568688d9d0553480abe50960965985496d3fcea..6200b3d933eda6c66f30755527e137a113e30136 100644
--- a/src/uncategorized/slaveAssignmentsReport.tw
+++ b/src/uncategorized/slaveAssignmentsReport.tw
@@ -331,7 +331,7 @@
 
 /* Accordion 000-250-006 */
  <<if ($brothel > 0)>>
-    <<if def $useAccordion >>
+    <<if $useAccordion eq 1>>
         <button class="passage-brothel-report accordion">''$brothelNameCaps Report''</button>
     <<else>>
         ''$brothelNameCaps Report''
@@ -341,7 +341,7 @@
 <</if>>
 
 <<if ($club > 0)>>
-    <<if def $useAccordion>>
+    <<if $useAccordion eq 1>>
         <button class="passage-club-report accordion">''$clubNameCaps Report''</button>
     <<else>>
         ''$clubNameCaps Report''
@@ -351,7 +351,7 @@
 <</if>>
 
 <<if ($arcade > 0)>>
-    <<if def $useAccordion>>
+    <<if $useAccordion eq 1>>
         <button class="passage-arcade-report accordion">''$arcadeNameCaps Report''</button>
     <<else>>
         ''$arcadeNameCaps Report''
@@ -361,7 +361,7 @@
 <</if>>
 
 <<if ($dairy > 0)>>
-    <<if def $useAccordion>>
+    <<if $useAccordion eq 1>>
         <button class="passage-dairy-report accordion">''$dairyNameCaps Report''</button>
     <<else>>
         ''$dairyNameCaps Report''
@@ -371,7 +371,7 @@
 <</if>>
 
 <<if ($servantsQuarters > 0)>>
-    <<if def $useAccordion>>
+    <<if $useAccordion eq 0>>
         <button class="passage-servants-quarters-report accordion">''$servantsQuartersNameCaps Quarters Report''</button>
     <<else>>
         ''$servantsQuartersNameCaps Report''
@@ -381,7 +381,7 @@
 <</if>>
 
 <<if ($schoolroom > 0)>>
-    <<if def $useAccordion>>
+    <<if $useAccordion eq 0>>
         <button class="passage-schoolroom-report accordion">''$schoolroomNameCaps Report''</button>
     <<else>>
         ''$schoolroomNameCaps Report''
@@ -391,7 +391,7 @@
 <</if>>
 
 <<if ($spa > 0)>>
-    <<if def $useAccordion>>
+    <<if $useAccordion eq 0>>
         <button class="passage-spa-report accordion">''$spaNameCaps Report''</button>
     <<else>>
         ''$spaNameCaps Report''
@@ -401,7 +401,7 @@
 <</if>>
 
 <<if ($clinic > 0)>>
-    <<if def $useAccordion>>
+    <<if $useAccordion eq 0>>
         <button class="passage-clinic-report accordion">''$clinicNameCaps Report''</button>
     <<else>>
         ''$clinicNameCaps Report''
@@ -411,7 +411,7 @@
 <</if>>
 
 <<if ($cellblock > 0)>>
-    <<if def $useAccordion>>
+    <<if $useAccordion eq 0>>
         <button class="passage-cellblock-report accordion">''$cellblockNameCaps Report''</button>
     <<else>>
         ''$cellblockNameCaps Report''
@@ -420,7 +420,7 @@
     <<display "Cellblock Report" "div">>
 <</if>>
 <<if ($incubator > 0)>>
-	<<if def $useAccordion>>
+	<<if $useAccordion == 1>>
 		<button class="passage-incubator-report accordion">''$incubatorNameCaps Report''</button>
 	<<else>>
 		''$incubatorNameCaps Report''
@@ -429,7 +429,7 @@
 	<<display "Incubator Report" "div">>
 <</if>>
 <<if ($masterSuite > 0)>>
-    <<if def $useAccordion>>
+    <<if $useAccordion eq 0>>
         <button class="passage-master-suite-report accordion">''$masterSuiteNameCaps Report''</button>
     <<else>>
         ''$masterSuiteNameCaps Report''
diff --git a/src/utility/slaveCreationWidgets.tw b/src/utility/slaveCreationWidgets.tw
index de9e9e307b0829d7c1df5341402f63e5fd77cfaa..7ab41fc876f465ec09355edec631a0744d8fddb5 100644
--- a/src/utility/slaveCreationWidgets.tw
+++ b/src/utility/slaveCreationWidgets.tw
@@ -1040,7 +1040,7 @@
 	<<else>>
 		<<click "Known">>
 			<<ToggleSexuality 1>>
-		</click>>
+		<</click>>
 	<</if>>
 	<</replace>>
 	<<StartingGirlsCost>>