!function(){function t(t){this.message=t}var r="undefined"!=typeof exports?exports:this,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.prototype=new Error,t.prototype.name="InvalidCharacterError",r.btoa||(r.btoa=function(r){for(var o,n,a=String(r),i=0,c=e,d="";a.charAt(0|i)||(c="=",i%1);d+=c.charAt(63&o>>8-i%1*8)){if(n=a.charCodeAt(i+=.75),n>255)throw new t("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|n}return d}),r.atob||
(r.atob=function(r){var o=String(r).replace(/=+$/,"");if(o.length%4==1)throw new t("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,a,i=0,c=0,d="";a=o.charAt(c++);~a&&(n=i%4?64*n+a:a,i++%4)?d+=String.fromCharCode(255&n>>(-2*i&6)):0)a=e.indexOf(a);return d})}();/*
 @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */
"document"in self&&("classList"in document.createElement("_")&&(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))||!function(t){if("Element"in t){var e="classList",n="prototype",i=t.Element[n],s=Object,r=String[n].trim||function(){return this.replace(/^\s+|\s+$/g,"")},o=Array[n].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},a=function(t,e){this.name=t,this.code=DOMException[t],this.message=e},
c=function(t,e){if(""===e)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new a("INVALID_CHARACTER_ERR","String contains an invalid character");return o.call(t,e)},l=function(t){for(var e=r.call(t.getAttribute("class")||""),n=e?e.split(/\s+/):[],i=0,s=n.length;s>i;i++)this.push(n[i]);this._updateClassName=function(){t.setAttribute("class",""+this)}},u=l[n]=[],h=function(){return new l(this)};if(a[n]=Error[n],u.item=function(t){return this[t]||null},u.contains=
function(t){return t+="",-1!==c(this,t)},u.add=function(){var t,e=arguments,n=0,i=e.length,s=!1;do t=e[n]+"",-1===c(this,t)&&(this.push(t),s=!0);while(++n<i);s&&this._updateClassName()},u.remove=function(){var t,e,n=arguments,i=0,s=n.length,r=!1;do for(t=n[i]+"",e=c(this,t);-1!==e;)this.splice(e,1),r=!0,e=c(this,t);while(++i<s);r&&this._updateClassName()},u.toggle=function(t,e){t+="";var n=this.contains(t),i=n?e!==!0&&"remove":e!==!1&&"add";return i&&this[i](t),e===!0||e===!1?e:!n},u.toString=function(){return this.join(" ")},
s.defineProperty){var f={get:h,enumerable:!0,configurable:!0};try{s.defineProperty(i,e,f)}catch(g){(void 0===g.number||-2146823252===g.number)&&(f.enumerable=!1,s.defineProperty(i,e,f))}}else s[n].__defineGetter__&&i.__defineGetter__(e,h)}}(self),function(){var t=document.createElement("_");if(t.classList.add("c1","c2"),!t.classList.contains("c2")){var e=function(t){var e=DOMTokenList.prototype[t];DOMTokenList.prototype[t]=function(t){var n,i=arguments.length;for(n=0;i>n;n++)t=arguments[n],e.call(this,
t)}};e("add"),e("remove")}if(t.classList.toggle("c3",!1),t.classList.contains("c3")){var n=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(t,e){return 1 in arguments&&!this.contains(t)==!e?e:n.call(this,t)}}t=null}());if(!document.documentElement.dataset&&(!Object.getOwnPropertyDescriptor(Element.prototype,"dataset")||!Object.getOwnPropertyDescriptor(Element.prototype,"dataset").get)){var propDescriptor={get:function(){var i,HTML5_DOMStringMap={},attrVal,attrName,propName,attribute,attributes=this.attributes,attsLength=attributes.length,toUpperCase=function(n0){return n0.charAt(1).toUpperCase()},getter=function(){return this},setter=function(attrName,value){return typeof value!=="undefined"?this.setAttribute(attrName,
value):this.removeAttribute(attrName)};for(i=0;i<attsLength;i++){attribute=attributes[i];if(attribute&&attribute.name&&/^data-\w[\w\-]*$/.test(attribute.name)){attrVal=attribute.value;attrName=attribute.name;propName=attrName.substr(5).replace(/-./g,toUpperCase);HTML5_DOMStringMap[propName]=attrVal}}return HTML5_DOMStringMap}};Object.defineProperty(Element.prototype,"dataset",propDescriptor)};!function(e){var a=function(){var e="s",s={DAY:864E5,HOUR:36E5,MINUTE:6E4,SECOND:1E3,BASELINE_YEAR:2014,MAX_SCORE:864E6,AMBIGUITIES:{"America/Denver":["America/Mazatlan"],"Europe/London":["Africa/Casablanca"],"America/Chicago":["America/Mexico_City"],"America/Asuncion":["America/Campo_Grande","America/Santiago"],"America/Montevideo":["America/Sao_Paulo","America/Santiago"],"Asia/Beirut":["Asia/Amman","Asia/Jerusalem","Europe/Helsinki","Asia/Damascus","Africa/Cairo","Asia/Gaza","Europe/Minsk"],"Pacific/Auckland":["Pacific/Fiji"],
"America/Los_Angeles":["America/Santa_Isabel"],"America/New_York":["America/Havana"],"America/Halifax":["America/Goose_Bay"],"America/Godthab":["America/Miquelon"],"Asia/Dubai":["Asia/Yerevan"],"Asia/Jakarta":["Asia/Krasnoyarsk"],"Asia/Shanghai":["Asia/Irkutsk","Australia/Perth"],"Australia/Sydney":["Australia/Lord_Howe"],"Asia/Tokyo":["Asia/Yakutsk"],"Asia/Dhaka":["Asia/Omsk"],"Asia/Baku":["Asia/Yerevan"],"Australia/Brisbane":["Asia/Vladivostok"],"Pacific/Noumea":["Asia/Vladivostok"],"Pacific/Majuro":["Asia/Kamchatka",
"Pacific/Fiji"],"Pacific/Tongatapu":["Pacific/Apia"],"Asia/Baghdad":["Europe/Minsk","Europe/Moscow"],"Asia/Karachi":["Asia/Yekaterinburg"],"Africa/Johannesburg":["Asia/Gaza","Africa/Cairo"]}},i=function(e){var a=-e.getTimezoneOffset();return null!==a?a:0},r=function(){var a=i(new Date(s.BASELINE_YEAR,0,2)),r=i(new Date(s.BASELINE_YEAR,5,2)),n=a-r;return 0>n?a+",1":n>0?r+",1,"+e:a+",0"},n=function(){var e,a;if("undefined"!=typeof Intl&&"undefined"!=typeof Intl.DateTimeFormat&&(e=Intl.DateTimeFormat(),
"undefined"!=typeof e&&"undefined"!=typeof e.resolvedOptions))return a=e.resolvedOptions().timeZone,a&&(a.indexOf("/")>-1||"UTC"===a)?a:void 0},o=function(e){for(var a=(new Date(e,0,1,0,0,1,0)).getTime(),s=(new Date(e,12,31,23,59,59)).getTime(),i=a,r=(new Date(i)).getTimezoneOffset(),n=null,o=null;s-864E5>i;){var t=new Date(i),A=t.getTimezoneOffset();A!==r&&(r>A&&(n=t),A>r&&(o=t),r=A),i+=864E5}return n&&o?{s:u(n).getTime(),e:u(o).getTime()}:!1},u=function l(e,a,i){"undefined"==typeof a&&(a=s.DAY,
i=s.HOUR);for(var r=(new Date(e.getTime()-a)).getTime(),n=e.getTime()+a,o=(new Date(r)).getTimezoneOffset(),u=r,t=null;n-i>u;){var A=new Date(u),c=A.getTimezoneOffset();if(c!==o){t=A;break}u+=i}return a===s.DAY?l(t,s.HOUR,s.MINUTE):a===s.HOUR?l(t,s.MINUTE,s.SECOND):t},t=function(e,a,s,i){if("N/A"!==s)return s;if("Asia/Beirut"===a){if("Africa/Cairo"===i.name&&13983768E5===e[6].s&&14116788E5===e[6].e)return 0;if("Asia/Jerusalem"===i.name&&13959648E5===e[6].s&&14118588E5===e[6].e)return 0}else if("America/Santiago"===
a){if("America/Asuncion"===i.name&&14124816E5===e[6].s&&1397358E6===e[6].e)return 0;if("America/Campo_Grande"===i.name&&14136912E5===e[6].s&&13925196E5===e[6].e)return 0}else if("America/Montevideo"===a){if("America/Sao_Paulo"===i.name&&14136876E5===e[6].s&&1392516E6===e[6].e)return 0}else if("Pacific/Auckland"===a&&"Pacific/Fiji"===i.name&&14142456E5===e[6].s&&13961016E5===e[6].e)return 0;return s},A=function(e,i){for(var r=function(a){for(var r=0,n=0;n<e.length;n++)if(a.rules[n]&&e[n]){if(!(e[n].s>=
a.rules[n].s&&e[n].e<=a.rules[n].e)){r="N/A";break}if(r=0,r+=Math.abs(e[n].s-a.rules[n].s),r+=Math.abs(a.rules[n].e-e[n].e),r>s.MAX_SCORE){r="N/A";break}}return r=t(e,i,r,a)},n={},o=a.olson.dst_rules.zones,u=o.length,A=s.AMBIGUITIES[i],c=0;u>c;c++){var m=o[c],l=r(o[c]);"N/A"!==l&&(n[m.name]=l)}for(var f in n)if(n.hasOwnProperty(f))for(var d=0;d<A.length;d++)if(A[d]===f)return f;return i},c=function(e){var s=function(){for(var e=[],s=0;s<a.olson.dst_rules.years.length;s++){var i=o(a.olson.dst_rules.years[s]);
e.push(i)}return e},i=function(e){for(var a=0;a<e.length;a++)if(e[a]!==!1)return!0;return!1},r=s(),n=i(r);return n?A(r,e):e},m=function(){var e=n();return e||(e=a.olson.timezones[r()],"undefined"!=typeof s.AMBIGUITIES[e]&&(e=c(e))),{name:function(){return e}}};return{determine:m}}();a.olson=a.olson||{},a.olson.timezones={"-720,0":"Etc/GMT+12","-660,0":"Pacific/Pago_Pago","-660,1,s":"Pacific/Apia","-600,1":"America/Adak","-600,0":"Pacific/Honolulu","-570,0":"Pacific/Marquesas","-540,0":"Pacific/Gambier",
"-540,1":"America/Anchorage","-480,1":"America/Los_Angeles","-480,0":"Pacific/Pitcairn","-420,0":"America/Phoenix","-420,1":"America/Denver","-360,0":"America/Guatemala","-360,1":"America/Chicago","-360,1,s":"Pacific/Easter","-300,0":"America/Bogota","-300,1":"America/New_York","-270,0":"America/Caracas","-240,1":"America/Halifax","-240,0":"America/Santo_Domingo","-240,1,s":"America/Asuncion","-210,1":"America/St_Johns","-180,1":"America/Godthab","-180,0":"America/Argentina/Buenos_Aires","-180,1,s":"America/Montevideo",
"-120,0":"America/Noronha","-120,1":"America/Noronha","-60,1":"Atlantic/Azores","-60,0":"Atlantic/Cape_Verde","0,0":"UTC","0,1":"Europe/London","60,1":"Europe/Berlin","60,0":"Africa/Lagos","60,1,s":"Africa/Windhoek","120,1":"Asia/Beirut","120,0":"Africa/Johannesburg","180,0":"Asia/Baghdad","180,1":"Europe/Moscow","210,1":"Asia/Tehran","240,0":"Asia/Dubai","240,1":"Asia/Baku","270,0":"Asia/Kabul","300,1":"Asia/Yekaterinburg","300,0":"Asia/Karachi","330,0":"Asia/Kolkata","345,0":"Asia/Kathmandu","360,0":"Asia/Dhaka",
"360,1":"Asia/Omsk","390,0":"Asia/Rangoon","420,1":"Asia/Krasnoyarsk","420,0":"Asia/Jakarta","480,0":"Asia/Shanghai","480,1":"Asia/Irkutsk","525,0":"Australia/Eucla","525,1,s":"Australia/Eucla","540,1":"Asia/Yakutsk","540,0":"Asia/Tokyo","570,0":"Australia/Darwin","570,1,s":"Australia/Adelaide","600,0":"Australia/Brisbane","600,1":"Asia/Vladivostok","600,1,s":"Australia/Sydney","630,1,s":"Australia/Lord_Howe","660,1":"Asia/Kamchatka","660,0":"Pacific/Noumea","690,0":"Pacific/Norfolk","720,1,s":"Pacific/Auckland",
"720,0":"Pacific/Majuro","765,1,s":"Pacific/Chatham","780,0":"Pacific/Tongatapu","780,1,s":"Pacific/Apia","840,0":"Pacific/Kiritimati"},a.olson.dst_rules={years:[2008,2009,2010,2011,2012,2013,2014],zones:[{name:"Africa/Cairo",rules:[{e:12199572E5,s:12090744E5},{e:1250802E6,s:1240524E6},{e:12858804E5,s:12840696E5},!1,!1,!1,{e:14116788E5,s:1406844E6}]},{name:"Africa/Casablanca",rules:[{e:12202236E5,s:12122784E5},{e:12508092E5,s:12438144E5},{e:1281222E6,s:12727584E5},{e:13120668E5,s:13017888E5},{e:13489704E5,
s:1345428E6},{e:13828392E5,s:13761E8},{e:14142888E5,s:14069448E5}]},{name:"America/Asuncion",rules:[{e:12050316E5,s:12243888E5},{e:12364812E5,s:12558384E5},{e:12709548E5,s:12860784E5},{e:13024044E5,s:1317528E6},{e:1333854E6,s:13495824E5},{e:1364094E6,s:1381032E6},{e:13955436E5,s:14124816E5}]},{name:"America/Campo_Grande",rules:[{e:12032172E5,s:12243888E5},{e:12346668E5,s:12558384E5},{e:12667212E5,s:1287288E6},{e:12981708E5,s:13187376E5},{e:13302252E5,s:1350792E6},{e:136107E7,s:13822416E5},{e:13925196E5,
s:14136912E5}]},{name:"America/Goose_Bay",rules:[{e:122559486E4,s:120503526E4},{e:125704446E4,s:123648486E4},{e:128909886E4,s:126853926E4},{e:13205556E5,s:129998886E4},{e:13520052E5,s:13314456E5},{e:13834548E5,s:13628952E5},{e:14149044E5,s:13943448E5}]},{name:"America/Havana",rules:[{e:12249972E5,s:12056436E5},{e:12564468E5,s:12364884E5},{e:12885012E5,s:12685428E5},{e:13211604E5,s:13005972E5},{e:13520052E5,s:13332564E5},{e:13834548E5,s:13628916E5},{e:14149044E5,s:13943412E5}]},{name:"America/Mazatlan",
rules:[{e:1225008E6,s:12074724E5},{e:12564576E5,s:1238922E6},{e:1288512E6,s:12703716E5},{e:13199616E5,s:13018212E5},{e:13514112E5,s:13332708E5},{e:13828608E5,s:13653252E5},{e:14143104E5,s:13967748E5}]},{name:"America/Mexico_City",rules:[{e:12250044E5,s:12074688E5},{e:1256454E6,s:12389184E5},{e:12885084E5,s:1270368E6},{e:1319958E6,s:13018176E5},{e:13514076E5,s:13332672E5},{e:13828572E5,s:13653216E5},{e:14143068E5,s:13967712E5}]},{name:"America/Miquelon",rules:[{e:12255984E5,s:12050388E5},{e:1257048E6,
s:12364884E5},{e:12891024E5,s:12685428E5},{e:1320552E6,s:12999924E5},{e:13520016E5,s:1331442E6},{e:13834512E5,s:13628916E5},{e:14149008E5,s:13943412E5}]},{name:"America/Santa_Isabel",rules:[{e:12250116E5,s:1207476E6},{e:12564612E5,s:12389256E5},{e:12885156E5,s:12703752E5},{e:13199652E5,s:13018248E5},{e:13514148E5,s:13332744E5},{e:13828644E5,s:13653288E5},{e:1414314E6,s:13967784E5}]},{name:"America/Santiago",rules:[{e:1206846E6,s:1223784E6},{e:1237086E6,s:12552336E5},{e:127035E7,s:12866832E5},{e:13048236E5,
s:13138992E5},{e:13356684E5,s:13465584E5},{e:1367118E6,s:13786128E5},{e:13985676E5,s:14100624E5}]},{name:"America/Sao_Paulo",rules:[{e:12032136E5,s:12243852E5},{e:12346632E5,s:12558348E5},{e:12667176E5,s:12872844E5},{e:12981672E5,s:1318734E6},{e:13302216E5,s:13507884E5},{e:13610664E5,s:1382238E6},{e:1392516E6,s:14136876E5}]},{name:"Asia/Amman",rules:[{e:1225404E6,s:12066552E5},{e:12568536E5,s:12381048E5},{e:12883032E5,s:12695544E5},{e:13197528E5,s:13016088E5},!1,!1,{e:14147064E5,s:13959576E5}]},{name:"Asia/Damascus",
rules:[{e:12254868E5,s:120726E7},{e:125685E7,s:12381048E5},{e:12882996E5,s:12701592E5},{e:13197492E5,s:13016088E5},{e:13511988E5,s:13330584E5},{e:13826484E5,s:1364508E6},{e:14147028E5,s:13959576E5}]},{name:"Asia/Dubai",rules:[!1,!1,!1,!1,!1,!1,!1]},{name:"Asia/Gaza",rules:[{e:12199572E5,s:12066552E5},{e:12520152E5,s:12381048E5},{e:1281474E6,s:126964086E4},{e:1312146E6,s:130160886E4},{e:13481784E5,s:13330584E5},{e:13802292E5,s:1364508E6},{e:1414098E6,s:13959576E5}]},{name:"Asia/Irkutsk",rules:[{e:12249576E5,
s:12068136E5},{e:12564072E5,s:12382632E5},{e:12884616E5,s:12697128E5},!1,!1,!1,!1]},{name:"Asia/Jerusalem",rules:[{e:12231612E5,s:12066624E5},{e:1254006E6,s:1238112E6},{e:1284246E6,s:12695616E5},{e:131751E7,s:1301616E6},{e:13483548E5,s:13330656E5},{e:13828284E5,s:13645152E5},{e:1414278E6,s:13959648E5}]},{name:"Asia/Kamchatka",rules:[{e:12249432E5,s:12067992E5},{e:12563928E5,s:12382488E5},{e:12884508E5,s:12696984E5},!1,!1,!1,!1]},{name:"Asia/Krasnoyarsk",rules:[{e:12249612E5,s:12068172E5},{e:12564108E5,
s:12382668E5},{e:12884652E5,s:12697164E5},!1,!1,!1,!1]},{name:"Asia/Omsk",rules:[{e:12249648E5,s:12068208E5},{e:12564144E5,s:12382704E5},{e:12884688E5,s:126972E7},!1,!1,!1,!1]},{name:"Asia/Vladivostok",rules:[{e:12249504E5,s:12068064E5},{e:12564E8,s:1238256E6},{e:12884544E5,s:12697056E5},!1,!1,!1,!1]},{name:"Asia/Yakutsk",rules:[{e:1224954E6,s:120681E7},{e:12564036E5,s:12382596E5},{e:1288458E6,s:12697092E5},!1,!1,!1,!1]},{name:"Asia/Yekaterinburg",rules:[{e:12249684E5,s:12068244E5},{e:1256418E6,s:1238274E6},
{e:12884724E5,s:12697236E5},!1,!1,!1,!1]},{name:"Asia/Yerevan",rules:[{e:1224972E6,s:1206828E6},{e:12564216E5,s:12382776E5},{e:1288476E6,s:12697272E5},{e:13199256E5,s:13011768E5},!1,!1,!1]},{name:"Australia/Lord_Howe",rules:[{e:12074076E5,s:12231342E5},{e:12388572E5,s:12545838E5},{e:12703068E5,s:12860334E5},{e:13017564E5,s:1317483E6},{e:1333206E6,s:13495374E5},{e:13652604E5,s:1380987E6},{e:139671E7,s:14124366E5}]},{name:"Australia/Perth",rules:[{e:12068136E5,s:12249576E5},!1,!1,!1,!1,!1,!1]},{name:"Europe/Helsinki",
rules:[{e:12249828E5,s:12068388E5},{e:12564324E5,s:12382884E5},{e:12884868E5,s:1269738E6},{e:13199364E5,s:13011876E5},{e:1351386E6,s:13326372E5},{e:13828356E5,s:13646916E5},{e:14142852E5,s:13961412E5}]},{name:"Europe/Minsk",rules:[{e:12249792E5,s:12068352E5},{e:12564288E5,s:12382848E5},{e:12884832E5,s:12697344E5},!1,!1,!1,!1]},{name:"Europe/Moscow",rules:[{e:12249756E5,s:12068316E5},{e:12564252E5,s:12382812E5},{e:12884796E5,s:12697308E5},!1,!1,!1,!1]},{name:"Pacific/Apia",rules:[!1,!1,!1,{e:13017528E5,
s:13168728E5},{e:13332024E5,s:13489272E5},{e:13652568E5,s:13803768E5},{e:13967064E5,s:14118264E5}]},{name:"Pacific/Fiji",rules:[!1,!1,{e:12696984E5,s:12878424E5},{e:13271544E5,s:1319292E6},{e:1358604E6,s:13507416E5},{e:139005E7,s:1382796E6},{e:14215032E5,s:14148504E5}]},{name:"Europe/London",rules:[{e:12249828E5,s:12068388E5},{e:12564324E5,s:12382884E5},{e:12884868E5,s:1269738E6},{e:13199364E5,s:13011876E5},{e:1351386E6,s:13326372E5},{e:13828356E5,s:13646916E5},{e:14142852E5,s:13961412E5}]}]},"undefined"!=
typeof module&&"undefined"!=typeof module.exports?module.exports=a:"undefined"!=typeof define&&null!==define&&null!=define.amd?define([],function(){return a}):"undefined"==typeof e?window.jstz=a:e.jstz=a}();(function(root){var ua={Android:/Android/ig.test(navigator.userAgent),iOS:/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent)};var media={WebM:"data:video/webm;base64,GkXfo0AgQoaBAUL3gQFC8oEEQvOBCEKCQAR3ZWJtQoeBAkKFgQIYU4BnQI0VSalmQCgq17FAAw9CQE2AQAZ3aGFtbXlXQUAGd2hhbW15RIlACECPQAAAAAAAFlSua0AxrkAu14EBY8WBAZyBACK1nEADdW5khkAFVl9WUDglhohAA1ZQOIOBAeBABrCBCLqBCB9DtnVAIueBAKNAHIEAAIAwAQCdASoIAAgAAUAmJaQAA3AA/vz0AAA=",MP4:"data:video/mp4;base64,AAAAHGZ0eXBpc29tAAACAGlzb21pc28ybXA0MQAAAAhmcmVlAAAAG21kYXQAAAGzABAHAAABthADAowdbb9/AAAC6W1vb3YAAABsbXZoZAAAAAB8JbCAfCWwgAAAA+gAAAAAAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIVdHJhawAAAFx0a2hkAAAAD3wlsIB8JbCAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAIAAAACAAAAAABsW1kaWEAAAAgbWRoZAAAAAB8JbCAfCWwgAAAA+gAAAAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAAVxtaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAEcc3RibAAAALhzdHNkAAAAAAAAAAEAAACobXA0dgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAIAAgASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAAFJlc2RzAAAAAANEAAEABDwgEQAAAAADDUAAAAAABS0AAAGwAQAAAbWJEwAAAQAAAAEgAMSNiB9FAEQBFGMAAAGyTGF2YzUyLjg3LjQGAQIAAAAYc3R0cwAAAAAAAAABAAAAAQAAAAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAFHN0c3oAAAAAAAAAEwAAAAEAAAAUc3RjbwAAAAAAAAABAAAALAAAAGB1ZHRhAAAAWG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAK2lsc3QAAAAjqXRvbwAAABtkYXRhAAAAAQAAAABMYXZmNTIuNzguMw=="};
function addSourceToVideo(element,type,dataURI){var source=document.createElement("source");source.src=dataURI;source.type="video/"+type;element.appendChild(source)}var NoSleep=function(){if(ua.iOS)this.noSleepTimer=null;else if(ua.Android){this.noSleepVideo=document.createElement("video");this.noSleepVideo.setAttribute("loop","");addSourceToVideo(this.noSleepVideo,"webm",media.WebM);addSourceToVideo(this.noSleepVideo,"mp4",media.MP4)}return this};NoSleep.prototype.enable=function(duration){if(ua.iOS){this.disable();
this.noSleepTimer=window.setInterval(function(){window.location.href="/";window.setTimeout(window.stop,0)},duration||15E3)}else if(ua.Android)this.noSleepVideo.play()};NoSleep.prototype.disable=function(){if(ua.iOS){if(this.noSleepTimer){window.clearInterval(this.noSleepTimer);this.noSleepTimer=null}}else if(ua.Android)this.noSleepVideo.pause()};root.NoSleep=NoSleep})(this);(function(){var root;if(typeof window==="object"&&window)root=window;else root=global;if(typeof module!=="undefined"&&module.exports)module.exports=root.Promise?root.Promise:Promise;else if(!root.Promise)root.Promise=Promise;var asap=root.setImmediate||function(fn){setTimeout(fn,1)};function bind(fn,thisArg){return function(){fn.apply(thisArg,arguments)}}var isArray=Array.isArray||function(value){return Object.prototype.toString.call(value)==="[object Array]"};function Promise(fn){if(typeof this!==
"object")throw new TypeError("Promises must be constructed via new");if(typeof fn!=="function")throw new TypeError("not a function");this._state=null;this._value=null;this._deferreds=[];doResolve(fn,bind(resolve,this),bind(reject,this))}function handle(deferred){var me=this;if(this._state===null){this._deferreds.push(deferred);return}asap(function(){var cb=me._state?deferred.onFulfilled:deferred.onRejected;if(cb===null){(me._state?deferred.resolve:deferred.reject)(me._value);return}var ret;try{ret=
cb(me._value)}catch(e){deferred.reject(e);return}deferred.resolve(ret)})}function resolve(newValue){try{if(newValue===this)throw new TypeError("A promise cannot be resolved with itself.");if(newValue&&(typeof newValue==="object"||typeof newValue==="function")){var then=newValue.then;if(typeof then==="function"){doResolve(bind(then,newValue),bind(resolve,this),bind(reject,this));return}}this._state=true;this._value=newValue;finale.call(this)}catch(e){reject.call(this,e)}}function reject(newValue){this._state=
false;this._value=newValue;finale.call(this)}function finale(){for(var i=0,len=this._deferreds.length;i<len;i++)handle.call(this,this._deferreds[i]);this._deferreds=null}function Handler(onFulfilled,onRejected,resolve,reject){this.onFulfilled=typeof onFulfilled==="function"?onFulfilled:null;this.onRejected=typeof onRejected==="function"?onRejected:null;this.resolve=resolve;this.reject=reject}function doResolve(fn,onFulfilled,onRejected){var done=false;try{fn(function(value){if(done)return;done=true;
onFulfilled(value)},function(reason){if(done)return;done=true;onRejected(reason)})}catch(ex){if(done)return;done=true;onRejected(ex)}}Promise.prototype["catch"]=function(onRejected){return this.then(null,onRejected)};Promise.prototype.then=function(onFulfilled,onRejected){var me=this;return new Promise(function(resolve,reject){handle.call(me,new Handler(onFulfilled,onRejected,resolve,reject))})};Promise.all=function(){var args=Array.prototype.slice.call(arguments.length===1&&isArray(arguments[0])?
arguments[0]:arguments);return new Promise(function(resolve,reject){if(args.length===0)return resolve([]);var remaining=args.length;function res(i,val){try{if(val&&(typeof val==="object"||typeof val==="function")){var then=val.then;if(typeof then==="function"){then.call(val,function(val){res(i,val)},reject);return}}args[i]=val;if(--remaining===0)resolve(args)}catch(ex){reject(ex)}}for(var i=0;i<args.length;i++)res(i,args[i])})};Promise.resolve=function(value){if(value&&typeof value==="object"&&value.constructor===
Promise)return value;return new Promise(function(resolve){resolve(value)})};Promise.reject=function(value){return new Promise(function(resolve,reject){reject(value)})};Promise.race=function(values){return new Promise(function(resolve,reject){for(var i=0,len=values.length;i<len;i++)values[i].then(resolve,reject)})}})();(function(root){function sendBeacon(url,data,_settings){var xhr="XMLHttpRequest"in window?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");xhr.open("POST",url,false);xhr.withCredentials=true;xhr.setRequestHeader("Accept","*/*");if(typeof data==="string"){xhr.setRequestHeader("Content-Type","text/plain;charset=UTF-8");xhr.responseType="text/plain"}else if(Object.prototype.toString.call(data)==="[object Blob]")if(data.type)xhr.setRequestHeader("Content-Type",data.type);if(typeof _settings===
"object")if(!isNaN(_settings.timeout))setTimeout(function(){if(xhr.readyState!==4)xhr.abort()},_settings.timeout);xhr.send(data);return true}if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=sendBeacon;exports.sendBeacon=sendBeacon}else if(typeof define==="function"&&define.amd)define([],function(){return sendBeacon});else if("navigator"in root&&!("sendBeacon"in root.navigator))root.navigator.sendBeacon=sendBeacon})(this);var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}};
"undefined"!==typeof module&&module.exports&&(module.exports=sjcl);"function"===typeof define&&define([],function(){return sjcl});
sjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.j(a.slice(b/32),32-(b&31)).slice(1);return void 0===c?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var d=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-d^a[b/32+1|0]>>>d:a[b/32|0]>>>d)&(1<<c)-1},concat:function(a,b){if(0===a.length||0===b.length)return a.concat(b);var c=a[a.length-1],d=sjcl.bitArray.getPartial(c);return 32===d?a.concat(b):sjcl.bitArray.j(b,d,c|0,a.slice(0,a.length-1))},bitLength:function(a){var b=a.length;return 0===
b?0:32*(b-1)+sjcl.bitArray.getPartial(a[b-1])},clamp:function(a,b){if(32*a.length<b)return a;a=a.slice(0,Math.ceil(b/32));var c=a.length;b&=31;0<c&&b&&(a[c-1]=sjcl.bitArray.partial(b,a[c-1]&2147483648>>b-1,1));return a},partial:function(a,b,c){return 32===a?b:(c?b|0:b<<32-a)+1099511627776*a},getPartial:function(a){return Math.round(a/1099511627776)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return!1;var c=0,d;for(d=0;d<a.length;d++)c|=a[d]^b[d];return 0===
c},j:function(a,b,c,d){var e;e=0;for(void 0===d&&(d=[]);32<=b;b-=32)d.push(c),c=0;if(0===b)return d.concat(a);for(e=0;e<a.length;e++)d.push(c|a[e]>>>b),c=a[e]<<32-b;e=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(e);d.push(sjcl.bitArray.partial(b+a&31,32<b+a?c:d.pop(),1));return d},l:function(a,b){return[a[0]^b[0],a[1]^b[1],a[2]^b[2],a[3]^b[3]]},byteswapM:function(a){var b,c;for(b=0;b<a.length;++b)c=a[b],a[b]=c>>>24|c>>>8&65280|(c&65280)<<8|c<<24;return a}};
sjcl.codec.utf8String={fromBits:function(a){var b="",c=sjcl.bitArray.bitLength(a),d,e;for(d=0;d<c/8;d++)0===(d&3)&&(e=a[d/4]),b+=String.fromCharCode(e>>>24),e<<=8;return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,d=0;for(c=0;c<a.length;c++)d=d<<8|a.charCodeAt(c),3===(c&3)&&(b.push(d),d=0);c&3&&b.push(sjcl.bitArray.partial(8*(c&3),d));return b}};
sjcl.codec.base64={g:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(a,b,c){var d="",e=0,g=sjcl.codec.base64.g,f=0,l=sjcl.bitArray.bitLength(a);c&&(g=g.substr(0,62)+"-_");for(c=0;6*d.length<l;)d+=g.charAt((f^a[c]>>>e)>>>26),6>e?(f=a[c]<<6-e,e+=26,c++):(f<<=6,e-=6);for(;d.length&3&&!b;)d+="=";return d},toBits:function(a,b){a=a.replace(/\s|=/g,"");var c=[],d,e=0,g=sjcl.codec.base64.g,f=0,l;b&&(g=g.substr(0,62)+"-_");for(d=0;d<a.length;d++){l=g.indexOf(a.charAt(d));
if(0>l)throw new sjcl.exception.invalid("this isn't base64!");26<e?(e-=26,c.push(f^l>>>e),f=l<<32-e):(e+=6,f^=l<<32-e)}e&56&&c.push(sjcl.bitArray.partial(e&56,f,1));return c}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}};sjcl.hash.sha256=function(a){this.e[0]||t(this);a?(this.d=a.d.slice(0),this.c=a.c.slice(0),this.a=a.a):this.reset()};sjcl.hash.sha256.hash=function(a){return(new sjcl.hash.sha256).update(a).finalize()};
sjcl.hash.sha256.prototype={blockSize:512,reset:function(){this.d=this.i.slice(0);this.c=[];this.a=0;return this},update:function(a){"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));var b,c=this.c=sjcl.bitArray.concat(this.c,a);b=this.a;a=this.a=b+sjcl.bitArray.bitLength(a);for(b=512+b&-512;b<=a;b+=512)u(this,c.splice(0,16));return this},finalize:function(){var a,b=this.c,c=this.d,b=sjcl.bitArray.concat(b,[sjcl.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this.a/
4294967296));for(b.push(this.a|0);b.length;)u(this,b.splice(0,16));this.reset();return c},i:[],e:[]};
function u(a,b){var c,d,e,g=b.slice(0),f=a.d,l=a.e,r=f[0],h=f[1],m=f[2],p=f[3],k=f[4],q=f[5],n=f[6],s=f[7];for(c=0;64>c;c++)16>c?d=g[c]:(d=g[c+1&15],e=g[c+14&15],d=g[c&15]=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+g[c&15]+g[c+9&15]|0),d=d+s+(k>>>6^k>>>11^k>>>25^k<<26^k<<21^k<<7)+(n^k&(q^n))+l[c],s=n,n=q,q=k,k=p+d|0,p=m,m=h,h=r,r=d+(h&m^p&(h^m))+(h>>>2^h>>>13^h>>>22^h<<30^h<<19^h<<10)|0;f[0]=f[0]+r|0;f[1]=f[1]+h|0;f[2]=f[2]+m|0;f[3]=f[3]+p|0;f[4]=f[4]+k|0;f[5]=f[5]+q|0;f[6]=
f[6]+n|0;f[7]=f[7]+s|0}function t(a){function b(a){return 4294967296*(a-Math.floor(a))|0}var c=0,d=2,e;a:for(;64>c;d++){for(e=2;e*e<=d;e++)if(0===d%e)continue a;8>c&&(a.i[c]=b(Math.pow(d,.5)));a.e[c]=b(Math.pow(d,1/3));c++}}sjcl.misc.hmac=function(a,b){this.h=b=b||sjcl.hash.sha256;var c=[[],[]],d,e=b.prototype.blockSize/32;this.b=[new b,new b];a.length>e&&(a=b.hash(a));for(d=0;d<e;d++)c[0][d]=a[d]^909522486,c[1][d]=a[d]^1549556828;this.b[0].update(c[0]);this.b[1].update(c[1]);this.f=new b(this.b[0])};
sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(a){if(this.k)throw new sjcl.exception.invalid("encrypt on already updated hmac called!");this.update(a);return this.digest(a)};sjcl.misc.hmac.prototype.reset=function(){this.f=new this.h(this.b[0]);this.k=!1};sjcl.misc.hmac.prototype.update=function(a){this.k=!0;this.f.update(a)};sjcl.misc.hmac.prototype.digest=function(){var a=this.f.finalize(),a=(new this.h(this.b[1])).update(a).finalize();this.reset();return a};/*
 Copyright Twitter Inc. and other contributors. Licensed under MIT */
var twemoji=function(){var twemoji={base:"https://cdnjs.cloudflare.com/ajax/libs/twemoji/2.3.0/2/",ext:".png",size:"72x72",className:"emoji",convert:{fromCodePoint:fromCodePoint,toCodePoint:toCodePoint},onerror:function onerror(){if(this.parentNode)this.parentNode.replaceChild(createText(this.alt),this)},parse:parse,replace:replace,test:test},escaper={"&":"&amp;","<":"&lt;",">":"&gt;","'":"&#39;",'"':"&quot;"},re=/\ud83d[\udc68-\udc69](?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92])|(?:\ud83c[\udfcb\udfcc]|\ud83d\udd75|\u26f9)(?:\ufe0f|\ud83c[\udffb-\udfff])\u200d[\u2640\u2642]\ufe0f|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd37-\udd39\udd3d\udd3e\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f|(?:[\u0023\u002a\u0030-\u0039])\ufe0f?\u20e3|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\uddd1-\udddd]|[\u270a\u270b])(?:\ud83c[\udffb-\udfff]|)|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud800\udc00|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a-\udc6d\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\udeeb\udeec\udef4-\udef8]|\ud83e[\udd10-\udd17\udd1d\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd40-\udd45\udd47-\udd4c\udd50-\udd6b\udd80-\udd97\uddc0\uddd0\uddde-\udde6]|[\u23e9-\u23ec\u23f0\u23f3\u2640\u2642\u2695\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a]|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u00ae\u203c\u2049\u2122\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2694\u2696\u2697\u2699\u269b\u269c\u26a0\u26a1\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))/g,
UFE0Fg=/\uFE0F/g,U200D=String.fromCharCode(8205),rescaper=/[&<>'"]/g,shouldntBeParsed=/IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA|[a-z]|TITLE/,fromCharCode=String.fromCharCode;return twemoji;function createText(text){return document.createTextNode(text)}function escapeHTML(s){return s.replace(rescaper,replacer)}function defaultImageSrcGenerator(icon,options){return"".concat(options.base,options.size,"/",icon,options.ext)}function grabAllTextNodes(node,allText){var childNodes=node.childNodes,
length=childNodes.length,subnode,nodeType;while(length--){subnode=childNodes[length];nodeType=subnode.nodeType;if(nodeType===3)allText.push(subnode);else if(nodeType===1&&!shouldntBeParsed.test(subnode.nodeName)&&!subnode.dataset.noTwemoji)grabAllTextNodes(subnode,allText)}return allText}function grabTheRightIcon(rawText){return toCodePoint(rawText.indexOf(U200D)<0?rawText.replace(UFE0Fg,""):rawText)}function parseNode(node,options){var allText=grabAllTextNodes(node,[]),length=allText.length,attrib,
attrname,modified,fragment,subnode,text,match,i,index,img,rawText,iconId,src;while(length--){modified=false;fragment=document.createDocumentFragment();subnode=allText[length];text=subnode.nodeValue;i=0;while(match=re.exec(text)){index=match.index;if(index!==i)fragment.appendChild(createText(text.slice(i,index)));rawText=match[0];iconId=grabTheRightIcon(rawText);i=index+rawText.length;src=options.callback(iconId,options);if(src){img=new Image;img.onerror=options.onerror;img.setAttribute("draggable",
"false");attrib=options.attributes(rawText,iconId);for(attrname in attrib)if(attrib.hasOwnProperty(attrname)&&attrname.indexOf("on")!==0&&!img.hasAttribute(attrname))img.setAttribute(attrname,attrib[attrname]);img.className=options.className;img.alt=rawText;img.src=src;modified=true;fragment.appendChild(img)}if(!img)fragment.appendChild(createText(rawText));img=null}if(modified){if(i<text.length)fragment.appendChild(createText(text.slice(i)));subnode.parentNode.replaceChild(fragment,subnode)}}return node}
function parseString(str,options){return replace(str,function(rawText){var ret=rawText,iconId=grabTheRightIcon(rawText),src=options.callback(iconId,options),attrib,attrname;if(src){ret="<img ".concat('class="',options.className,'" ','draggable="false" ','alt="',rawText,'"',' src="',src,'"');attrib=options.attributes(rawText,iconId);for(attrname in attrib)if(attrib.hasOwnProperty(attrname)&&attrname.indexOf("on")!==0&&ret.indexOf(" "+attrname+"=")===-1)ret=ret.concat(" ",attrname,'="',escapeHTML(attrib[attrname]),
'"');ret=ret.concat(">")}return ret})}function replacer(m){return escaper[m]}function returnNull(){return null}function toSizeSquaredAsset(value){return typeof value==="number"?value+"x"+value:value}function fromCodePoint(codepoint){var code=typeof codepoint==="string"?parseInt(codepoint,16):codepoint;if(code<65536)return fromCharCode(code);code-=65536;return fromCharCode(55296+(code>>10),56320+(code&1023))}function parse(what,how){if(!how||typeof how==="function")how={callback:how};return(typeof what===
"string"?parseString:parseNode)(what,{callback:how.callback||defaultImageSrcGenerator,attributes:typeof how.attributes==="function"?how.attributes:returnNull,base:typeof how.base==="string"?how.base:twemoji.base,ext:how.ext||twemoji.ext,size:how.folder||toSizeSquaredAsset(how.size||twemoji.size),className:how.className||twemoji.className,onerror:how.onerror||twemoji.onerror})}function replace(text,callback){return String(text).replace(re,callback)}function test(text){re.lastIndex=0;var result=re.test(text);
re.lastIndex=0;return result}function toCodePoint(unicodeSurrogates,sep){var r=[],c=0,p=0,i=0;while(i<unicodeSurrogates.length){c=unicodeSurrogates.charCodeAt(i++);if(p){r.push((65536+(p-55296<<10)+(c-56320)).toString(16));p=0}else if(55296<=c&&c<=56319)p=c;else r.push(c.toString(16))}return r.join(sep||"-")}}();
/*

 QR Code Generator for JavaScript

 Copyright (c) 2009 Kazuhiko Arase

 URL: http://www.d-project.com/

 Licensed under the MIT license:
  http://www.opensource.org/licenses/mit-license.php

 The word 'QR Code' is registered trademark of
 DENSO WAVE INCORPORATED
  http://www.denso-wave.com/qrcode/faqpatent-e.html

 qrcodejs - https://github.com/davidshimjs/qrcodejs/
 Copyright (c) 2012 davidshimjs
 Licensed under the MIT license:
  http://www.opensource.org/licenses/mit-license.php
*/
var QRCode;
(function(){function f(a){this.mode=u.MODE_8BIT_BYTE;this.data=a;this.parsedData=[];a=0;for(var b=this.data.length;a<b;a++){var d=[],c=this.data.charCodeAt(a);65536<c?(d[0]=240|(c&1835008)>>>18,d[1]=128|(c&258048)>>>12,d[2]=128|(c&4032)>>>6,d[3]=128|c&63):2048<c?(d[0]=224|(c&61440)>>>12,d[1]=128|(c&4032)>>>6,d[2]=128|c&63):128<c?(d[0]=192|(c&1984)>>>6,d[1]=128|c&63):d[0]=c;this.parsedData.push(d)}this.parsedData=Array.prototype.concat.apply([],this.parsedData);this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),
this.parsedData.unshift(187),this.parsedData.unshift(239))}function g(a,b){this.typeNumber=a;this.errorCorrectLevel=b;this.modules=null;this.moduleCount=0;this.dataCache=null;this.dataList=[]}function h(a,b){if(void 0==a.length)throw Error(a.length+"/"+b);for(var d=0;d<a.length&&0==a[d];)d++;this.num=Array(a.length-d+b);for(b=0;b<a.length-d;b++)this.num[b]=a[b+d]}function q(a,b){this.totalCount=a;this.dataCount=b}function y(){this.buffer=[];this.length=0}function z(){var a=!1,b=navigator.userAgent;
/android/i.test(b)&&(a=!0,(b=b.toString().match(/android ([0-9]\.[0-9])/i))&&b[1]&&(a=parseFloat(b[1])));return a}f.prototype={getLength:function(a){return this.parsedData.length},write:function(a){for(var b=0,d=this.parsedData.length;b<d;b++)a.put(this.parsedData[b],8)}};g.prototype={addData:function(a){a=new f(a);this.dataList.push(a);this.dataCache=null},isDark:function(a,b){if(0>a||this.moduleCount<=a||0>b||this.moduleCount<=b)throw Error(a+","+b);return this.modules[a][b]},getModuleCount:function(){return this.moduleCount},
make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(a,b){this.moduleCount=4*this.typeNumber+17;this.modules=Array(this.moduleCount);for(var d=0;d<this.moduleCount;d++){this.modules[d]=Array(this.moduleCount);for(var c=0;c<this.moduleCount;c++)this.modules[d][c]=null}this.setupPositionProbePattern(0,0);this.setupPositionProbePattern(this.moduleCount-7,0);this.setupPositionProbePattern(0,this.moduleCount-7);this.setupPositionAdjustPattern();this.setupTimingPattern();this.setupTypeInfo(a,
b);7<=this.typeNumber&&this.setupTypeNumber(a);null==this.dataCache&&(this.dataCache=g.createData(this.typeNumber,this.errorCorrectLevel,this.dataList));this.mapData(this.dataCache,b)},setupPositionProbePattern:function(a,b){for(var d=-1;7>=d;d++)if(!(-1>=a+d||this.moduleCount<=a+d))for(var c=-1;7>=c;c++)-1>=b+c||this.moduleCount<=b+c||(this.modules[a+d][b+c]=0<=d&&6>=d&&(0==c||6==c)||0<=c&&6>=c&&(0==d||6==d)||2<=d&&4>=d&&2<=c&&4>=c?!0:!1)},getBestMaskPattern:function(){for(var a=0,b=0,d=0;8>d;d++){this.makeImpl(!0,
d);var c=m.getLostPoint(this);if(0==d||a>c)a=c,b=d}return b},createMovieClip:function(a,b,d){a=a.createEmptyMovieClip(b,d);this.make();for(b=0;b<this.modules.length;b++){d=1*b;for(var c=0;c<this.modules[b].length;c++){var e=1*c;this.modules[b][c]&&(a.beginFill(0,100),a.moveTo(e,d),a.lineTo(e+1,d),a.lineTo(e+1,d+1),a.lineTo(e,d+1),a.endFill())}}return a},setupTimingPattern:function(){for(var a=8;a<this.moduleCount-8;a++)null==this.modules[a][6]&&(this.modules[a][6]=0==a%2);for(a=8;a<this.moduleCount-
8;a++)null==this.modules[6][a]&&(this.modules[6][a]=0==a%2)},setupPositionAdjustPattern:function(){for(var a=m.getPatternPosition(this.typeNumber),b=0;b<a.length;b++)for(var d=0;d<a.length;d++){var c=a[b],e=a[d];if(null==this.modules[c][e])for(var l=-2;2>=l;l++)for(var t=-2;2>=t;t++)this.modules[c+l][e+t]=-2==l||2==l||-2==t||2==t||0==l&&0==t?!0:!1}},setupTypeNumber:function(a){for(var b,d=m.getBCHTypeNumber(this.typeNumber),c=0;18>c;c++)b=!a&&1==(d>>c&1),this.modules[Math.floor(c/3)][c%3+this.moduleCount-
8-3]=b;for(c=0;18>c;c++)b=!a&&1==(d>>c&1),this.modules[c%3+this.moduleCount-8-3][Math.floor(c/3)]=b},setupTypeInfo:function(a,b){for(var d=m.getBCHTypeInfo(this.errorCorrectLevel<<3|b),c=0;15>c;c++)b=!a&&1==(d>>c&1),6>c?this.modules[c][8]=b:8>c?this.modules[c+1][8]=b:this.modules[this.moduleCount-15+c][8]=b;for(c=0;15>c;c++)b=!a&&1==(d>>c&1),8>c?this.modules[8][this.moduleCount-c-1]=b:9>c?this.modules[8][15-c-1+1]=b:this.modules[8][15-c-1]=b;this.modules[this.moduleCount-8][8]=!a},mapData:function(a,
b){for(var d=-1,c=this.moduleCount-1,e=7,l=0,t=this.moduleCount-1;0<t;t-=2)for(6==t&&t--;;){for(var k=0;2>k;k++)if(null==this.modules[c][t-k]){var f=!1;l<a.length&&(f=1==(a[l]>>>e&1));m.getMask(b,c,t-k)&&(f=!f);this.modules[c][t-k]=f;e--; -1==e&&(l++,e=7)}c+=d;if(0>c||this.moduleCount<=c){c-=d;d=-d;break}}}};g.PAD0=236;g.PAD1=17;g.createData=function(a,b,d){b=q.getRSBlocks(a,b);for(var c=new y,e=0;e<d.length;e++){var l=d[e];c.put(l.mode,4);c.put(l.getLength(),m.getLengthInBits(l.mode,a));l.write(c)}for(e=
a=0;e<b.length;e++)a+=b[e].dataCount;if(c.getLengthInBits()>8*a)throw Error("code length overflow. ("+c.getLengthInBits()+">"+8*a+")");for(c.getLengthInBits()+4<=8*a&&c.put(0,4);0!=c.getLengthInBits()%8;)c.putBit(!1);for(;!(c.getLengthInBits()>=8*a);){c.put(g.PAD0,8);if(c.getLengthInBits()>=8*a)break;c.put(g.PAD1,8)}return g.createBytes(c,b)};g.createBytes=function(a,b){for(var d=0,c=0,e=0,l=Array(b.length),f=Array(b.length),k=0;k<b.length;k++){var g=b[k].dataCount,x=b[k].totalCount-g,c=Math.max(c,
g),e=Math.max(e,x);l[k]=Array(g);for(var n=0;n<l[k].length;n++)l[k][n]=255&a.buffer[n+d];d+=g;n=m.getErrorCorrectPolynomial(x);g=(new h(l[k],n.getLength()-1)).mod(n);f[k]=Array(n.getLength()-1);for(n=0;n<f[k].length;n++)x=n+g.getLength()-f[k].length,f[k][n]=0<=x?g.get(x):0}for(n=k=0;n<b.length;n++)k+=b[n].totalCount;a=Array(k);for(n=d=0;n<c;n++)for(k=0;k<b.length;k++)n<l[k].length&&(a[d++]=l[k][n]);for(n=0;n<e;n++)for(k=0;k<b.length;k++)n<f[k].length&&(a[d++]=f[k][n]);return a};for(var u={MODE_NUMBER:1,
MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},v={L:1,M:0,Q:3,H:2},m={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,
86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(a){for(var b=a<<10;0<=m.getBCHDigit(b)-m.getBCHDigit(m.G15);)b^=m.G15<<m.getBCHDigit(b)-m.getBCHDigit(m.G15);return(a<<10|b)^m.G15_MASK},getBCHTypeNumber:function(a){for(var b=a<<12;0<=m.getBCHDigit(b)-m.getBCHDigit(m.G18);)b^=m.G18<<m.getBCHDigit(b)-
m.getBCHDigit(m.G18);return a<<12|b},getBCHDigit:function(a){for(var b=0;0!=a;)b++,a>>>=1;return b},getPatternPosition:function(a){return m.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,b,d){switch(a){case 0:return 0==(b+d)%2;case 1:return 0==b%2;case 2:return 0==d%3;case 3:return 0==(b+d)%3;case 4:return 0==(Math.floor(b/2)+Math.floor(d/3))%2;case 5:return 0==b*d%2+b*d%3;case 6:return 0==(b*d%2+b*d%3)%2;case 7:return 0==(b*d%3+(b+d)%2)%2;default:throw Error("bad maskPattern:"+a);}},getErrorCorrectPolynomial:function(a){for(var b=
new h([1],0),d=0;d<a;d++)b=b.multiply(new h([1,p.gexp(d)],0));return b},getLengthInBits:function(a,b){if(1<=b&&10>b)switch(a){case u.MODE_NUMBER:return 10;case u.MODE_ALPHA_NUM:return 9;case u.MODE_8BIT_BYTE:return 8;case u.MODE_KANJI:return 8;default:throw Error("mode:"+a);}else if(27>b)switch(a){case u.MODE_NUMBER:return 12;case u.MODE_ALPHA_NUM:return 11;case u.MODE_8BIT_BYTE:return 16;case u.MODE_KANJI:return 10;default:throw Error("mode:"+a);}else if(41>b)switch(a){case u.MODE_NUMBER:return 14;
case u.MODE_ALPHA_NUM:return 13;case u.MODE_8BIT_BYTE:return 16;case u.MODE_KANJI:return 12;default:throw Error("mode:"+a);}else throw Error("type:"+b);},getLostPoint:function(a){for(var b=a.getModuleCount(),d=0,c=0;c<b;c++)for(var e=0;e<b;e++){for(var l=0,f=a.isDark(c,e),k=-1;1>=k;k++)if(!(0>c+k||b<=c+k))for(var g=-1;1>=g;g++)0>e+g||b<=e+g||0==k&&0==g||f!=a.isDark(c+k,e+g)||l++;5<l&&(d+=3+l-5)}for(c=0;c<b-1;c++)for(e=0;e<b-1;e++)if(l=0,a.isDark(c,e)&&l++,a.isDark(c+1,e)&&l++,a.isDark(c,e+1)&&l++,
a.isDark(c+1,e+1)&&l++,0==l||4==l)d+=3;for(c=0;c<b;c++)for(e=0;e<b-6;e++)a.isDark(c,e)&&!a.isDark(c,e+1)&&a.isDark(c,e+2)&&a.isDark(c,e+3)&&a.isDark(c,e+4)&&!a.isDark(c,e+5)&&a.isDark(c,e+6)&&(d+=40);for(e=0;e<b;e++)for(c=0;c<b-6;c++)a.isDark(c,e)&&!a.isDark(c+1,e)&&a.isDark(c+2,e)&&a.isDark(c+3,e)&&a.isDark(c+4,e)&&!a.isDark(c+5,e)&&a.isDark(c+6,e)&&(d+=40);for(e=l=0;e<b;e++)for(c=0;c<b;c++)a.isDark(c,e)&&l++;return d+Math.abs(100*l/b/b-50)/5*10}},p={glog:function(a){if(1>a)throw Error("glog("+a+
")");return p.LOG_TABLE[a]},gexp:function(a){for(;0>a;)a+=255;for(;256<=a;)a-=255;return p.EXP_TABLE[a]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},r=0;8>r;r++)p.EXP_TABLE[r]=1<<r;for(r=8;256>r;r++)p.EXP_TABLE[r]=p.EXP_TABLE[r-4]^p.EXP_TABLE[r-5]^p.EXP_TABLE[r-6]^p.EXP_TABLE[r-8];for(r=0;255>r;r++)p.LOG_TABLE[p.EXP_TABLE[r]]=r;h.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var b=Array(this.getLength()+a.getLength()-1),d=0;d<this.getLength();d++)for(var c=
0;c<a.getLength();c++)b[d+c]^=p.gexp(p.glog(this.get(d))+p.glog(a.get(c)));return new h(b,0)},mod:function(a){if(0>this.getLength()-a.getLength())return this;for(var b=p.glog(this.get(0))-p.glog(a.get(0)),d=Array(this.getLength()),c=0;c<this.getLength();c++)d[c]=this.get(c);for(c=0;c<a.getLength();c++)d[c]^=p.gexp(p.glog(a.get(c))+b);return(new h(d,0)).mod(a)}};q.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],
[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,
46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,
70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,
46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],
[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,
46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];q.getRSBlocks=function(a,b){var d=q.getRsBlockTable(a,b);if(void 0==d)throw Error("bad rs block @ typeNumber:"+a+"/errorCorrectLevel:"+b);a=d.length/3;b=[];for(var c=0;c<a;c++)for(var e=d[3*c+0],f=d[3*c+1],g=d[3*c+2],k=0;k<e;k++)b.push(new q(f,g));return b};q.getRsBlockTable=function(a,
b){switch(b){case v.L:return q.RS_BLOCK_TABLE[4*(a-1)+0];case v.M:return q.RS_BLOCK_TABLE[4*(a-1)+1];case v.Q:return q.RS_BLOCK_TABLE[4*(a-1)+2];case v.H:return q.RS_BLOCK_TABLE[4*(a-1)+3]}};y.prototype={get:function(a){return 1==(this.buffer[Math.floor(a/8)]>>>7-a%8&1)},put:function(a,b){for(var d=0;d<b;d++)this.putBit(1==(a>>>b-d-1&1))},getLengthInBits:function(){return this.length},putBit:function(a){var b=Math.floor(this.length/8);this.buffer.length<=b&&this.buffer.push(0);a&&(this.buffer[b]|=
128>>>this.length%8);this.length++}};var w=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,
805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]],A=function(){var a=function(a,d){this._el=a;this._htOption=d};a.prototype.draw=function(a){function b(a,c){a=document.createElementNS("http://www.w3.org/2000/svg",a);for(var b in c)c.hasOwnProperty(b)&&a.setAttribute(b,
c[b]);return a}var c=this._htOption,e=this._el,f=a.getModuleCount();this.clear();var g=b("svg",{viewBox:"0 0 "+String(f)+" "+String(f),width:"100%",height:"100%",fill:c.colorLight});g.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink");e.appendChild(g);g.appendChild(b("rect",{fill:c.colorLight,width:"100%",height:"100%"}));g.appendChild(b("rect",{fill:c.colorDark,width:"1",height:"1",id:"template"}));for(c=0;c<f;c++)for(e=0;e<f;e++)if(a.isDark(c,e)){var k=
b("use",{x:String(c),y:String(e)});k.setAttributeNS("http://www.w3.org/1999/xlink","href","#template");g.appendChild(k)}};a.prototype.clear=function(){for(;this._el.hasChildNodes();)this._el.removeChild(this._el.lastChild)};return a}(),B="svg"===document.documentElement.tagName.toLowerCase()?A:"undefined"==typeof CanvasRenderingContext2D?function(){var a=function(a,d){this._el=a;this._htOption=d};a.prototype.draw=function(a){for(var b=this._htOption,c=this._el,e=a.getModuleCount(),f=Math.floor(b.width/
e),g=Math.floor(b.height/e),k=['<table style="border:0;border-collapse:collapse;">'],h=0;h<e;h++){k.push("<tr>");for(var m=0;m<e;m++)k.push('<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:'+f+"px;height:"+g+"px;background-color:"+(a.isDark(h,m)?b.colorDark:b.colorLight)+';"></td>');k.push("</tr>")}k.push("</table>");c.innerHTML=k.join("");a=c.childNodes[0];c=(b.width-a.offsetWidth)/2;b=(b.height-a.offsetHeight)/2;0<c&&0<b&&(a.style.margin=b+"px "+c+"px")};a.prototype.clear=
function(){this._el.innerHTML=""};return a}():function(){function a(){this._elImage.src=this._elCanvas.toDataURL("image/png");this._elImage.style.display="block";this._elCanvas.style.display="none"}function b(a,c){var b=this;b._fFail=c;b._fSuccess=a;null===b._bSupportDataURI?(a=document.createElement("img"),c=function(){b._bSupportDataURI=!1;b._fFail&&b._fFail.call(b)},a.onabort=c,a.onerror=c,a.onload=function(){b._bSupportDataURI=!0;b._fSuccess&&b._fSuccess.call(b)},a.src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="):
!0===b._bSupportDataURI&&b._fSuccess?b._fSuccess.call(b):!1===b._bSupportDataURI&&b._fFail&&b._fFail.call(b)}if(this._android&&2.1>=this._android){var d=1/window.devicePixelRatio,c=CanvasRenderingContext2D.prototype.drawImage;CanvasRenderingContext2D.prototype.drawImage=function(a,b,e,f,g,h,m,p,q){if("nodeName"in a&&/img/i.test(a.nodeName))for(var k=arguments.length-1;1<=k;k--)arguments[k]*=d;else"undefined"==typeof p&&(arguments[1]*=d,arguments[2]*=d,arguments[3]*=d,arguments[4]*=d);c.apply(this,
arguments)}}var e=function(a,b){this._bIsPainted=!1;this._android=z();this._htOption=b;this._elCanvas=document.createElement("canvas");this._elCanvas.width=b.width;this._elCanvas.height=b.height;a.appendChild(this._elCanvas);this._el=a;this._oContext=this._elCanvas.getContext("2d");this._bIsPainted=!1;this._elImage=document.createElement("img");this._elImage.alt="Scan me!";this._elImage.style.display="none";this._el.appendChild(this._elImage);this._bSupportDataURI=null};e.prototype.draw=function(a){var b=
this._elImage,c=this._oContext,d=this._htOption,e=a.getModuleCount(),f=d.width/e,g=d.height/e,h=Math.round(f),l=Math.round(g);b.style.display="none";this.clear();for(b=0;b<e;b++)for(var m=0;m<e;m++){var p=a.isDark(b,m),q=m*f,r=b*g;c.strokeStyle=p?d.colorDark:d.colorLight;c.lineWidth=1;c.fillStyle=p?d.colorDark:d.colorLight;c.fillRect(q,r,f,g);c.strokeRect(Math.floor(q)+.5,Math.floor(r)+.5,h,l);c.strokeRect(Math.ceil(q)-.5,Math.ceil(r)-.5,h,l)}this._bIsPainted=!0};e.prototype.makeImage=function(){this._bIsPainted&&
b.call(this,a)};e.prototype.isPainted=function(){return this._bIsPainted};e.prototype.clear=function(){this._oContext.clearRect(0,0,this._elCanvas.width,this._elCanvas.height);this._bIsPainted=!1};e.prototype.round=function(a){return a?Math.floor(1E3*a)/1E3:a};return e}();QRCode=function(a,b){this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:v.H};"string"===typeof b&&(b={text:b});if(b)for(var d in b)this._htOption[d]=b[d];"string"==typeof a&&(a=
document.getElementById(a));this._htOption.useSVG&&(B=A);this._android=z();this._el=a;this._oQRCode=null;this._oDrawing=new B(this._el,this._htOption);this._htOption.text&&this.makeCode(this._htOption.text)};QRCode.prototype.makeCode=function(a){var b=this._htOption.correctLevel,d=1;var c=encodeURI(a).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");c=c.length+(c.length!=a?3:0);for(var e=0,f=w.length;e<=f;e++){var h=0;switch(b){case v.L:h=w[e][0];break;case v.M:h=w[e][1];break;case v.Q:h=w[e][2];break;
case v.H:h=w[e][3]}if(c<=h)break;else d++}if(d>w.length)throw Error("Too long data");this._oQRCode=new g(d,this._htOption.correctLevel);this._oQRCode.addData(a);this._oQRCode.make();this._el.title=a;this._oDrawing.draw(this._oQRCode);this.makeImage()};QRCode.prototype.makeImage=function(){"function"==typeof this._oDrawing.makeImage&&(!this._android||3<=this._android)&&this._oDrawing.makeImage()};QRCode.prototype.clear=function(){this._oDrawing.clear()};QRCode.CorrectLevel=v})();xyzcrypto={};xyzcrypto.supported=function(){try{return"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&"subarray"in Uint8Array.prototype?!0:!1}catch(f){return!1}}();xyzcrypto.resultToBytes=function(f){for(var g=new Uint8Array(32),h=0;32>h;h++)g[h]=f[h/4|0]>>>24-h%4*8;return g};xyzcrypto.fromString=function(f,g){g||(f=unescape(encodeURIComponent(f)));g=new Uint8Array(f.length);for(var h=0;h<f.length;h++)g[h]=f.charCodeAt(h);return g};
xyzcrypto.toString=function(f,g){for(var h=Array(f.length),q=0;q<f.length;q++)h[q]=String.fromCharCode(f[q]);return g?h.join(""):decodeURIComponent(escape(h.join("")))};xyzcrypto.fromB64=function(f){return xyzcrypto.fromString(atob(f),!0)};xyzcrypto.toB64=function(f){return btoa(xyzcrypto.toString(f,!0))};xyzcrypto.fromHex=function(f){for(var g=new Uint8Array(f.length/2),h=0;h<g.length;h++)g[h]=parseInt(f.substr(2*h,2),16);return g};
xyzcrypto.toHex=function(f){for(var g=Array(f.length),h=0;h<f.length;h++)g[h]=(f[h]+256).toString(16).substr(1);return g.join("")};xyzcrypto.hmac=function(f,g){g.length>f.blocksize&&(g=f.hash(g));if(g.length<f.blocksize){var h=new Uint8Array(f.blocksize);h.set(g);g=h}this.o_key=new Uint8Array(64);this.i_key=new Uint8Array(64);for(h=0;64>h;h++)this.o_key[h]=g[h]^92,this.i_key[h]=g[h]^54;this.hash=new f;this.hash.updateBlock(this.i_key)};xyzcrypto.hmac.prototype.reset=function(){this.hash.reset();this.hash.updateBlock(this.i_key)};
xyzcrypto.hmac.prototype.update=function(f){this.hash.update(f)};xyzcrypto.hmac.prototype.finish=function(){var f=this.hash.finish();this.hash.reset();this.hash.updateBlock(this.o_key);this.hash.update(f);return this.hash.finish()};xyzcrypto.hmac.prototype.generate=function(f){this.reset();this.update(f);return this.finish()};xyzcrypto.hmac.generate=function(f,g,h){return(new xyzcrypto.hmac(f,g)).generate(h)};xyzcrypto.sha256={};
xyzcrypto.sha256.asm=function(){var f=new ArrayBuffer(65536);this.state=new Uint32Array(f,0,8);this.block=new Uint8Array(f,32,64);this.data=null;var g=this;this.asm=xyzcrypto.sha256.asm.module(window,{copyBlock:function(f,q,y){g.block.set(g.data.subarray(q,y),f)}},f);this.asm.reset()};xyzcrypto.sha256.asm.prototype.reset=function(){this.asm.reset()};xyzcrypto.sha256.asm.prototype.update=function(f){this.data=f;this.asm.update(f.length)};
xyzcrypto.sha256.asm.prototype.updateBlock=function(f){this.block.set(f);this.asm.updateBlock()};xyzcrypto.sha256.asm.prototype.finish=function(){this.asm.finish();return xyzcrypto.resultToBytes(this.state)};xyzcrypto.sha256.asm.prototype.hash=function(f){this.reset();this.update(f);return this.finish()};xyzcrypto.sha256.asm.hash=function(f){return(new xyzcrypto.sha256.asm).hash(f)};xyzcrypto.sha256.asm.blocksize=64;
'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.inherits=function(c,d){function e(){}e.prototype=d.prototype;c.superClass_=d.prototype;c.prototype=new e;c.prototype.constructor=c;for(var f in d)if(Object.defineProperties){var g=Object.getOwnPropertyDescriptor(d,f);g&&Object.defineProperty(c,f,g)}else c[f]=d[f]};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(c,d,e){c!=Array.prototype&&c!=Object.prototype&&(c[d]=e.value)};$jscomp.getGlobal=function(c){return"undefined"!=typeof window&&window===c?c:"undefined"!=typeof global&&null!=global?global:c};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};
$jscomp.symbolCounter_=0;$jscomp.Symbol=function(c){return $jscomp.SYMBOL_PREFIX+(c||"")+$jscomp.symbolCounter_++};$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var c=$jscomp.global.Symbol.iterator;c||(c=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[c]&&$jscomp.defineProperty(Array.prototype,c,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};
$jscomp.arrayIterator=function(c){var d=0;return $jscomp.iteratorPrototype(function(){return d<c.length?{done:!1,value:c[d++]}:{done:!0}})};$jscomp.iteratorPrototype=function(c){$jscomp.initSymbolIterator();c={next:c};c[$jscomp.global.Symbol.iterator]=function(){return this};return c};$jscomp.makeIterator=function(c){$jscomp.initSymbolIterator();var d=c[Symbol.iterator];return d?d.call(c):$jscomp.arrayIterator(c)};
$jscomp.polyfill=function(c,d,e,f){if(d){e=$jscomp.global;c=c.split(".");for(f=0;f<c.length-1;f++){var g=c[f];g in e||(e[g]={});e=e[g]}c=c[c.length-1];f=e[c];d=d(f);d!=f&&null!=d&&$jscomp.defineProperty(e,c,{configurable:!0,writable:!0,value:d})}};
$jscomp.polyfill("Array.from",function(c){return c?c:function(c,e,f){$jscomp.initSymbolIterator();e=null!=e?e:function(c){return c};var d=[],k=c[Symbol.iterator];if("function"==typeof k)for(c=k.call(c);!(k=c.next()).done;)d.push(e.call(f,k.value));else for(var k=c.length,l=0;l<k;l++)d.push(e.call(f,c[l]));return d}},"es6-impl","es3");$jscomp.FORCE_POLYFILL_PROMISE=!1;
$jscomp.polyfill("Promise",function(c){function d(){this.batch_=null}function e(c){return c instanceof g?c:new g(function(d,e){d(c)})}if(c&&!$jscomp.FORCE_POLYFILL_PROMISE)return c;d.prototype.asyncExecute=function(c){null==this.batch_&&(this.batch_=[],this.asyncExecuteBatch_());this.batch_.push(c);return this};d.prototype.asyncExecuteBatch_=function(){var c=this;this.asyncExecuteFunction(function(){c.executeBatch_()})};var f=$jscomp.global.setTimeout;d.prototype.asyncExecuteFunction=function(c){f(c,
0)};d.prototype.executeBatch_=function(){for(;this.batch_&&this.batch_.length;){var c=this.batch_;this.batch_=[];for(var d=0;d<c.length;++d){var e=c[d];delete c[d];try{e()}catch(p){this.asyncThrow_(p)}}}this.batch_=null};d.prototype.asyncThrow_=function(c){this.asyncExecuteFunction(function(){throw c;})};var g=function(c){this.state_=0;this.result_=void 0;this.onSettledCallbacks_=[];var d=this.createResolveAndReject_();try{c(d.resolve,d.reject)}catch(n){d.reject(n)}};g.prototype.createResolveAndReject_=
function(){function c(c){return function(f){e||(e=!0,c.call(d,f))}}var d=this,e=!1;return{resolve:c(this.resolveTo_),reject:c(this.reject_)}};g.prototype.resolveTo_=function(c){if(c===this)this.reject_(new TypeError("A Promise cannot resolve to itself"));else if(c instanceof g)this.settleSameAsPromise_(c);else{a:switch(typeof c){case "object":var d=null!=c;break a;case "function":d=!0;break a;default:d=!1}d?this.resolveToNonPromiseObj_(c):this.fulfill_(c)}};g.prototype.resolveToNonPromiseObj_=function(c){var d=
void 0;try{d=c.then}catch(n){this.reject_(n);return}"function"==typeof d?this.settleSameAsThenable_(d,c):this.fulfill_(c)};g.prototype.reject_=function(c){this.settle_(2,c)};g.prototype.fulfill_=function(c){this.settle_(1,c)};g.prototype.settle_=function(c,d){if(0!=this.state_)throw Error("Cannot settle("+c+", "+d|"): Promise already settled in state"+this.state_);this.state_=c;this.result_=d;this.executeOnSettledCallbacks_()};g.prototype.executeOnSettledCallbacks_=function(){if(null!=this.onSettledCallbacks_){for(var c=
this.onSettledCallbacks_,d=0;d<c.length;++d)c[d].call(),c[d]=null;this.onSettledCallbacks_=null}};var k=new d;g.prototype.settleSameAsPromise_=function(c){var d=this.createResolveAndReject_();c.callWhenSettled_(d.resolve,d.reject)};g.prototype.settleSameAsThenable_=function(c,d){var e=this.createResolveAndReject_();try{c.call(d,e.resolve,e.reject)}catch(p){e.reject(p)}};g.prototype.then=function(c,d){function e(c,d){return"function"==typeof c?function(d){try{f(c(d))}catch(x){k(x)}}:d}var f,k,l=new g(function(c,
d){f=c;k=d});this.callWhenSettled_(e(c,f),e(d,k));return l};g.prototype.catch=function(c){return this.then(void 0,c)};g.prototype.callWhenSettled_=function(c,d){function e(){switch(f.state_){case 1:c(f.result_);break;case 2:d(f.result_);break;default:throw Error("Unexpected state: "+f.state_);}}var f=this;null==this.onSettledCallbacks_?k.asyncExecute(e):this.onSettledCallbacks_.push(function(){k.asyncExecute(e)})};g.resolve=e;g.reject=function(c){return new g(function(d,e){e(c)})};g.race=function(c){return new g(function(d,
f){for(var g=$jscomp.makeIterator(c),k=g.next();!k.done;k=g.next())e(k.value).callWhenSettled_(d,f)})};g.all=function(c){var d=$jscomp.makeIterator(c),f=d.next();return f.done?e([]):new g(function(c,g){function k(d){return function(e){l[d]=e;m--;0==m&&c(l)}}var l=[],m=0;do l.push(void 0),m++,e(f.value).callWhenSettled_(k(l.length-1),g),f=d.next();while(!f.done)})};return g},"es6-impl","es3");
$jscomp.checkStringArgs=function(c,d,e){if(null==c)throw new TypeError("The 'this' value for String.prototype."+e+" must not be null or undefined");if(d instanceof RegExp)throw new TypeError("First argument to String.prototype."+e+" must not be a regular expression");return c+""};
$jscomp.polyfill("String.prototype.startsWith",function(c){return c?c:function(c,e){var d=$jscomp.checkStringArgs(this,c,"startsWith");c+="";var g=d.length,k=c.length;e=Math.max(0,Math.min(e|0,d.length));for(var l=0;l<k&&e<g;)if(d[e++]!=c[l++])return!1;return l>=k}},"es6-impl","es3");
$jscomp.iteratorFromArray=function(c,d){$jscomp.initSymbolIterator();c instanceof String&&(c+="");var e=0,f={next:function(){if(e<c.length){var g=e++;return{value:d(g,c[g]),done:!1}}f.next=function(){return{done:!0,value:void 0}};return f.next()}};f[Symbol.iterator]=function(){return f};return f};$jscomp.polyfill("Array.prototype.keys",function(c){return c?c:function(){return $jscomp.iteratorFromArray(this,function(c){return c})}},"es6-impl","es3");
$jscomp.owns=function(c,d){return Object.prototype.hasOwnProperty.call(c,d)};
$jscomp.polyfill("WeakMap",function(c){function d(c){$jscomp.owns(c,f)||$jscomp.defineProperty(c,f,{value:{}})}function e(c){var e=Object[c];e&&(Object[c]=function(c){d(c);return e(c)})}if(function(){if(!c||!Object.seal)return!1;try{var d=Object.seal({}),e=Object.seal({}),f=new c([[d,2],[e,3]]);if(2!=f.get(d)||3!=f.get(e))return!1;f.delete(d);f.set(e,4);return!f.has(d)&&4==f.get(e)}catch(p){return!1}}())return c;var f="$jscomp_hidden_"+Math.random().toString().substring(2);e("freeze");e("preventExtensions");
e("seal");var g=0,k=function(c){this.id_=(g+=Math.random()+1).toString();if(c){$jscomp.initSymbol();$jscomp.initSymbolIterator();c=$jscomp.makeIterator(c);for(var d;!(d=c.next()).done;)d=d.value,this.set(d[0],d[1])}};k.prototype.set=function(c,e){d(c);if(!$jscomp.owns(c,f))throw Error("WeakMap key fail: "+c);c[f][this.id_]=e;return this};k.prototype.get=function(c){return $jscomp.owns(c,f)?c[f][this.id_]:void 0};k.prototype.has=function(c){return $jscomp.owns(c,f)&&$jscomp.owns(c[f],this.id_)};k.prototype.delete=
function(c){return $jscomp.owns(c,f)&&$jscomp.owns(c[f],this.id_)?delete c[f][this.id_]:!1};return k},"es6-impl","es3");$jscomp.MapEntry=function(){};
$jscomp.polyfill("Map",function(c){if(!$jscomp.ASSUME_NO_NATIVE_MAP&&function(){if(!c||!c.prototype.entries||"function"!=typeof Object.seal)return!1;try{var d=Object.seal({x:4}),e=new c($jscomp.makeIterator([[d,"s"]]));if("s"!=e.get(d)||1!=e.size||e.get({x:4})||e.set({x:4},"t")!=e||2!=e.size)return!1;var f=e.entries(),g=f.next();if(g.done||g.value[0]!=d||"s"!=g.value[1])return!1;g=f.next();return g.done||4!=g.value[0].x||"t"!=g.value[1]||!f.next().done?!1:!0}catch(t){return!1}}())return c;$jscomp.initSymbol();
$jscomp.initSymbolIterator();var d=new WeakMap,e=function(c){this.data_={};this.head_=k();this.size=0;if(c){c=$jscomp.makeIterator(c);for(var d;!(d=c.next()).done;)d=d.value,this.set(d[0],d[1])}};e.prototype.set=function(c,d){var e=f(this,c);e.list||(e.list=this.data_[e.id]=[]);e.entry?e.entry.value=d:(e.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:c,value:d},e.list.push(e.entry),this.head_.previous.next=e.entry,this.head_.previous=e.entry,this.size++);return this};e.prototype.delete=
function(c){c=f(this,c);return c.entry&&c.list?(c.list.splice(c.index,1),c.list.length||delete this.data_[c.id],c.entry.previous.next=c.entry.next,c.entry.next.previous=c.entry.previous,c.entry.head=null,this.size--,!0):!1};e.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=k();this.size=0};e.prototype.has=function(c){return!!f(this,c).entry};e.prototype.get=function(c){return(c=f(this,c).entry)&&c.value};e.prototype.entries=function(){return g(this,function(c){return[c.key,
c.value]})};e.prototype.keys=function(){return g(this,function(c){return c.key})};e.prototype.values=function(){return g(this,function(c){return c.value})};e.prototype.forEach=function(c,d){for(var e=this.entries(),f;!(f=e.next()).done;)f=f.value,c.call(d,f[1],f[0],this)};e.prototype[Symbol.iterator]=e.prototype.entries;var f=function(c,e){var f=e&&typeof e;"object"==f||"function"==f?d.has(e)?f=d.get(e):(f=""+ ++l,d.set(e,f)):f="p_"+e;var g=c.data_[f];if(g&&$jscomp.owns(c.data_,f))for(c=0;c<g.length;c++){var k=
g[c];if(e!==e&&k.key!==k.key||e===k.key)return{id:f,list:g,index:c,entry:k}}return{id:f,list:g,index:-1,entry:void 0}},g=function(c,d){var e=c.head_;return $jscomp.iteratorPrototype(function(){if(e){for(;e.head!=c.head_;)e=e.previous;for(;e.next!=e.head;)return e=e.next,{done:!1,value:d(e)};e=null}return{done:!0,value:void 0}})},k=function(){var c={};return c.previous=c.next=c.head=c},l=0;return e},"es6-impl","es3");
function element(c,d,e){c=document.createElement(c);void 0!=d&&(c.className=d);void 0!=e&&(c.id=e);return c}function textnode(c){return document.createTextNode(c)}function addClass(c,d){if("undefined"!=typeof c.classList)c.classList.add(d);else{var e=c.className.split(" ");e.push(d);c.className=e.join(" ")}}
function removeClass(c,d){if("undefined"!=typeof c.classList)c.classList.remove(d);else{for(var e=c.className.split(" "),f=0;f<e.length;f++)e[f]==d&&(e.splice(f,1),f--);c.className=e.join(" ")}}function hasClass(c,d){if("undefined"!=typeof c.classList)return c.classList.contains(d);c=c.className.split(" ");for(var e=0;e<c.length;e++)if(c[e]==d)return!0;return!1}
function toggleClass(c,d,e){if("undefined"!=typeof c.classList)return c.classList.toggle(d,e);hasClass(c,d)||!e?removeClass(c,d):addClass(c,d)}function bindEvent(c,d,e){c.addEventListener?c.addEventListener(d,e,!1):c.attachEvent&&c.attachEvent("on"+d,e)}function unbindEvent(c,d,e){c.removeEventListener?c.removeEventListener(d,e,!1):c.detachEvent&&c.detachEvent("on"+d,e)}
function matchesSelector(c,d){var e=Element.prototype;return(e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||function(c){return-1!==[].indexOf.call(document.querySelectorAll(c),this)}).call(c,d)};var fQuery=function(){};fQuery.ready=function(c){"interactive"===document.readyState||"complete"===document.readyState?c():document.addEventListener("DOMContentLoaded",c)};fQuery.load=function(c){"complete"===document.readyState?c():window.addEventListener("load",c)};fQuery.on=function(c,d,e){Array.prototype.forEach.call(c,function(c){c.addEventListener(d,e)})};fQuery.click=function(c,d){fQuery.on(c,"click",d)};fQuery.append=function(c,d){};
fQuery.createFromHtml=function(c){var d=document.createElement("div");d.innerHTML=c.trim();return d.childNodes[0]};fQuery.addScopedEventListener=function(c,d,e,f,g){var k=function(g){for(var k=g.target;null!=k&&k!=document;){if(matchesSelector(k,d)){if(("mouseout"==e||"mouseover"==e)&&k.contains(g.relatedTarget))break;f.call(k,g)}if(c==k)break;k=k.parentNode}};c.addEventListener(e,k,void 0===g?!1:g);return k};
fQuery.removeScopedEventListener=function(c,d,e,f){c.removeEventListener(d,e,void 0===f?!1:f)};fQuery.isOrChildOf=function(c,d){do if(c==d)return!0;while(c=c.parentNode);return!1};fQuery.closestParent=function(c,d){for(;c=c.parentNode;){if(c==document)return null;if(matchesSelector(c,d))return c}};fQuery.siblings=function(c,d){d=void 0===d?!1:d;for(var e=[],f=$jscomp.makeIterator(c.parentNode.childNodes),g=f.next();!g.done;g=f.next())g=g.value,1==g.nodeType&&(d||g!=c)&&e.push(g);return e};
fQuery.addClass=function(c,d){c=$jscomp.makeIterator(c);for(var e=c.next();!e.done;e=c.next())e.value.classList.add(d)};fQuery.removeClass=function(c,d){c=$jscomp.makeIterator(c);for(var e=c.next();!e.done;e=c.next())e.value.classList.remove(d)};fQuery.toggleClass=function(c,d,e){c=$jscomp.makeIterator(c);for(var f=c.next();!f.done;f=c.next())toggleClass(f.value,d,e)};fQuery.css=function(c,d,e){c=$jscomp.makeIterator(c);for(var f=c.next();!f.done;f=c.next())f.value.style[d]=e};
fQuery.insertAfter=function(c,d){var e=c.nextSibling;null!=e?c.parentNode.insertBefore(d,e):c.parentNode.appendChild(d)};fQuery.insertBefore=function(c,d){c.parentNode.insertBefore(d,c)};fQuery.prepend=function(c,d){0==c.childNodes.length?c.appendChild(d):c.insertBefore(d,c.childNodes[0])};
fQuery.removeElement=function(c){for(var d=$jscomp.makeIterator(c.querySelectorAll("[data-controller-id]")),e=d.next();!e.done;e=d.next())App.DeleteController(App.GetControllerFromElement(e.value));c.dataset.controllerId&&App.DeleteController(App.GetControllerFromElement(c));c.parentNode.removeChild(c)};fQuery.removeElements=function(c){c=$jscomp.makeIterator(c);for(var d=c.next();!d.done;d=c.next())fQuery.removeElement(d.value)};
fQuery.scrollTop=function(c,d,e){c=void 0===c?null:c;d=void 0===d?!1:d;e=void 0===e?null:e;if(null===c)return document.body.scrollTop||document.documentElement.scrollTop;null!==e?fQuery.animateProperty(function(c){fQuery.scrollTop(c,!0)},fQuery.scrollTop(),d?c:fQuery.scrollTop()+c,e,Curves.Cos):d?(document.documentElement.scrollTop=c,document.body.scrollTop=c):(document.documentElement.scrollTop+=c,document.body.scrollTop+=c)};
fQuery.scrollTo=function(c,d){d=void 0===d?null:d;fQuery.scrollTop(c.getBoundingClientRect().top,!1,d)};fQuery.scrollLeft=function(c,d){c=void 0===c?null:c;if(null===c)return document.body.scrollLeft||document.documentElement.scrollLeft;(void 0===d?0:d)?(document.documentElement.scrollLeft=c,document.body.scrollLeft=c):(document.documentElement.scrollLeft+=c,document.body.scrollLeft+=c)};
fQuery.text=function(c){var d=[];for(c=document.createTreeWalker(c,NodeFilter.SHOW_TEXT,function(){return NodeFilter.FILTER_ACCEPT},!1);c.nextNode();)d.push(c.currentNode.data);return d.join(" ").replace(/\s+/g," ")};fQuery.nodesToArray=function(c){return Array.from(c)};
fQuery.animateProperty=function(c,d,e,f,g){g=void 0===g?null:g;return new Promise(function(k,l){var m=0,n=null,p=function(l){null===n&&(n=l);m+=(l-n)/1E3*(1/f);n=l;1>m?window.requestAnimationFrame(p):(m=1,k());l=null!=g?g.call(null,m):m;c(d+(e-d)*l)};window.requestAnimationFrame(p)})};fQuery.debounce=function(c,d,e){var f;return function(){var g=this,k=arguments,l=e&&!f;clearTimeout(f);f=setTimeout(function(){f=null;e||c.apply(g,k)},d);l&&c.apply(g,k)}};
fQuery.throttle=function(c,d){var e;return function(){var f=this,g=arguments;null==e&&(e=setTimeout(function(){e=null;c.apply(f,g)},d))}};
fQuery.loadScript=function(c,d){var e=document.querySelector("script[src='"+c+"']");if(null!=e)return null==fQuery.scripts[c]?new Promise(function(c){c(e)}):new Promise(function(c,d){if(e.readyState){var f=e.onreadystatechange;e.onreadystatechange=function(){if("loaded"==e.readyState||"complete"==e.readyState)e.onreadystatechange=null,c(e),f()}}else{var g=e.onload;e.onload=function(){c(e);g()}}});d=new Promise(function(d,e){var f=document.createElement("script");f.type="text/javascript";f.readyState?
f.onreadystatechange=function(){if("loaded"==f.readyState||"complete"==f.readyState)f.onreadystatechange=null,fQuery.scripts[c]=null,d(f)}:f.onload=function(){fQuery.scripts[c]=null;d(f)};f.src=c;document.getElementsByTagName("head")[0].appendChild(f)});return fQuery.scripts[c]=d};fQuery.animationFrame=function(c,d){var e=null,f=function(g){null==e&&(e=g);var k=Math.min((g-e)/1E3,d);e=g;!1!==c(k)&&window.requestAnimationFrame(f)};window.requestAnimationFrame(f)};
fQuery.disableScroll=function(){0==fQuery.scrollStack&&(document.addEventListener("wheel",fQuery.scrollHandler),is_mobile&&document.body.classList.add("unscrollable"));fQuery.scrollStack++;return{used:!1}};fQuery.enableScroll=function(c){c.used||(c.used=!0,fQuery.scrollStack--,0==fQuery.scrollStack&&(document.removeEventListener("wheel",fQuery.scrollHandler),document.body.classList.remove("unscrollable")))};fQuery.removeChildren=function(c){for(;c.firstChild;)c.removeChild(c.firstChild)};
fQuery.scrollStack=0;fQuery.scrollHandler=function(c){c.preventDefault()};fQuery.scripts={};var EventBus=function(){this.listeners=[]};EventBus.prototype.addListener=function(c){this.listeners.push(c)};EventBus.prototype.removeListener=function(c){c=this.listeners.indexOf(c);-1<c&&this.listeners.splice(c,1)};EventBus.prototype.fire=function(c){for(var d=[],e=0;e<arguments.length;++e)d[e-0]=arguments[e];for(var e=$jscomp.makeIterator(this.listeners),f=e.next();!f.done;f=e.next())f.value.apply(this,d)};
function LocalStorageSet(c,d){try{var e=window.localStorage.getItem(c);window.localStorage.setItem(c,d);var f=document.createEvent("StorageEvent");f.initStorageEvent("storage",!1,!1,c,e,d,null,window.localStorage);window.dispatchEvent(f)}catch(g){setCookie(c,d,365)}}function LocalStorageGet(c,d){var e=null;try{e=window.localStorage.getItem(c)}catch(f){}if(null!==e)return e;e=getCookie(c);return null!==e?e:d}
function LocalStorageRemove(c){try{window.localStorage.removeItem(c)}catch(d){}delCookie(c)}function TimeOffsetToFriendlyName(c){c=Math.max(0,c);var d=Math.floor(c/604800);c-=604800*d;var e=Math.floor(c/86400);c-=86400*e;var f=Math.floor(c/3600);c-=3600*f;var g=Math.floor(c/60);c-=60*g;var k="second";0<g&&(c=g,k="minute");0<f&&(c=f,k="hour");0<e&&(c=e,k="day");0<d&&(c=d,k="week");str="";return c+" "+k+(1!=c?"s":"")}
"undefined"==typeof window.requestAnimationFrame&&(window.requestAnimationFrame=window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(c){return window.setTimeout(c,50)});
function extractColor(c){var d={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",
darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",feldspar:"#d19275",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",
gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",
lightslateblue:"#8470ff",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",
navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",
silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",violetred:"#d02090",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};c in d&&(c=d[c]);if(d=c.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/))return[d[1],d[2],d[3]];if(d=c.match(/#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i))return[parseInt(d[1],
16),parseInt(d[2],16),parseInt(d[3],16)];if(d=c.match(/#([0-9a-f])([0-9a-f])([0-9a-f])/i))return[parseInt(d[1]+d[1],16),parseInt(d[2]+d[2],16),parseInt(d[3]+d[3],16)]}function colorBlend(c,d,e){return[c[0]*e+d[0]*(1-e),c[1]*e+d[1]*(1-e),c[2]*e+d[2]*(1-e)]}function colorMult(c,d){return[c[0]*d,c[1]*d,c[2]*d]}function rgbToCSS(c){return"rgb("+Math.round(c[0])+","+Math.round(c[1])+","+Math.round(c[2])+")"}function forceRelayout(c){c.offsetHeight}
function SafeHTML(c){return c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var events=function(){var c={},d=c.hasOwnProperty;return{subscribe:function(e,f){d.call(c,e)||(c[e]=[]);var g=c[e].push(f)-1;return{remove:function(){delete c[e][g]}}},publish:function(e,f){d.call(c,e)&&c[e].forEach(function(c){c(void 0!=f?f:{})})}}}();var Controller=function(){this.element=null;this.elements={};this.inputs={}};Controller.prototype.bind=function(c){this.element=c};Controller.prototype.findElements=function(c){return this.element.querySelectorAll(c)};Controller.prototype.findElement=function(c){return this.element.querySelector(c)};function Vec2(c,d){this.x=c;this.y=d;"freeze"in Object&&Object.freeze(this)}Vec2.Add=function(c,d){return new Vec2(c.x+d.x,c.y+d.y)};Vec2.Subtract=function(c,d){return new Vec2(c.x-d.x,c.y-d.y)};Vec2.Multiply=function(c,d){return d instanceof Vec2?new Vec2(c.x*d.x,c.y*d.y):new Vec2(c.x*d,c.y*d)};Vec2.Int=function(c){return new Vec2(Math.round(c.x),Math.round(c.y))};Vec2.prototype.Normalise=function(c){c=this.Length();return new Vec2(this.x/c,this.y/c)};
Vec2.prototype.Length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};Vec2.prototype.clone=function(){return new Vec2(this.x,this.y)};function ProjectPointToLine(c,d,e){d=(d.y-c.y)/(d.x-c.x);c=c.y-d*c.x;return new Vec2(Math.floor((d*e.y+e.x-d*c)/(d*d+1)),Math.floor((d*d*e.y+d*e.x+c)/(d*d+1)))}function saturate(c){return Math.max(Math.min(1,c),0)};var banners=[{colour:"rgb(164, 110, 60)",url:"https://static.fimfiction.net/images/custom_banners/zecora.jpg?2",source:"http://aeronjvl.deviantart.com/art/Hanging-by-the-Edge-327757722",id:"zecora"},{colour:"rgb(164, 122, 60)",url:"https://static.fimfiction.net/images/custom_banners/aeron_fluttershy.jpg?2",source:"http://aeronjvl.deviantart.com/art/Nature-326303180",id:"aeron_fluttershy"},{colour:"rgb(76, 112, 126)",url:"https://static.fimfiction.net/images/custom_banners/aeron_philomena.jpg?2",source:"http://ajvl.deviantart.com/art/Philomena-Equestria-s-Finest-Phoenix-310217164",
id:"aeron_philomena"},{colour:"rgb(76, 126, 110)",url:"https://static.fimfiction.net/images/custom_banners/aeron_celestia.jpg?2",source:"http://aeronjvl.deviantart.com/art/Path-to-Canterlot-340639474",id:"aeron_celestia"},{colour:"rgb(87, 102, 111)",url:"https://static.fimfiction.net/images/custom_banners/derpy_dash.jpg?2",source:"http://ponykillerx.deviantart.com/art/Full-Armour-D-vs-D-288729315",id:"derpy_dash"},{colour:"rgb(83, 76, 121)",url:"https://static.fimfiction.net/images/custom_banners/ponykiller_trixie.jpg?2",
source:"http://ponykillerx.deviantart.com/art/No-Title-Wallpaper-Version-287646346",id:"ponykiller_trixie"},{colour:"rgb(140, 151, 83)",url:"https://static.fimfiction.net/images/custom_banners/yamio_fluttershy.jpg?2",source:"http://yamio.deviantart.com/art/Fluttershy-285372865",id:"yamio_fluttershy"},{colour:"rgb(146, 164, 60)",url:"https://static.fimfiction.net/images/custom_banners/ratofdrawn_1.jpg?2",source:"http://ratofdrawn.deviantart.com/art/Wet-Fun-317158001",id:"ratofdrawn_1"},{colour:"rgb(100, 133, 190)",
url:"https://static.fimfiction.net/images/custom_banners/ratofdrawn_rarijack.jpg?2",source:"http://ratofdrawn.deviantart.com/art/Differences-343226962",id:"ratofdrawn_rarijack"},{colour:"rgb(72, 60, 164)",url:"https://static.fimfiction.net/images/custom_banners/solar_luna.jpg?2",source:"http://soapie-solar.deviantart.com/art/Chibi-Luna-Star-Fishing-340002341",id:"solar_luna"},{colour:"rgb(131, 164, 60)",url:"https://static.fimfiction.net/images/custom_banners/solar_group.jpg?2",source:"http://soapie-solar.deviantart.com/art/Forest-Foundation-283012970",
id:"solar_group"},{colour:"rgb(164, 135, 60)",url:"https://static.fimfiction.net/images/custom_banners/uc77_1.jpg?2",source:"http://uc77.deviantart.com/art/Ponies-Dig-Giant-Robots-281071953",id:"uc77_1"},{colour:"rgb(77, 60, 164)",url:"https://static.fimfiction.net/images/custom_banners/cmaggot_fluttershy.jpg?2",source:"http://cmaggot.deviantart.com/art/Dangerous-Mission-342068171",id:"cmaggot_fluttershy"},{colour:"rgb(164, 114, 60)",url:"https://static.fimfiction.net/images/custom_banners/rainbow_ss.jpg?2",
source:"http://derpiboo.ru/41558",id:"rainbow_ss"},{colour:"rgb(69, 100, 96)",url:"https://static.fimfiction.net/images/custom_banners/rainbow_markerpone.jpg?2",source:"http://derpiboo.ru/131068",id:"rainbow_markerpone"},{colour:"rgb(164, 60, 152)",url:"https://static.fimfiction.net/images/custom_banners/rainbow_roseluck.jpg?2",source:"http://derpiboo.ru/50361",id:"rainbow_roseluck"},{colour:"rgb(60, 114, 164)",url:"https://static.fimfiction.net/images/custom_banners/jj_trixie.jpg?2",source:"http://johnjoseco.deviantart.com/art/Trixie-s-Life-is-so-Hard-340685374",
id:"jj_trixie"},{colour:"rgb(60, 118, 164)",url:"https://static.fimfiction.net/images/custom_banners/anima_1.jpg?2",source:"http://spiritto.deviantart.com/art/C-mon-lift-your-Spirit-324914801",id:"anima_1"},{colour:"rgb(60, 147, 164)",url:"https://static.fimfiction.net/images/custom_banners/mew_pinkie.jpg?2",source:"http://mewball.deviantart.com/art/Reflect-338427890",id:"mew_pinkie"},{colour:"rgb(60, 89, 164)",url:"https://static.fimfiction.net/images/custom_banners/tsitra_dash.jpg?2",source:"http://tsitra360.deviantart.com/art/Morning-Flight-331710988",
id:"tsitra_dash"},{colour:"rgb(164, 127, 60)",url:"https://static.fimfiction.net/images/custom_banners/knifeh_scoots.jpg?2",source:"http://knifeh.deviantart.com/art/Scootaloo-326771443",id:"knifeh_scoots"},{colour:"rgb(164, 89, 60)",url:"https://static.fimfiction.net/images/custom_banners/noben_celestia.jpg?2",source:"http://noben.deviantart.com/art/Sunrise-in-Equestria-280309698",id:"noben_celestia"},{colour:"rgb(77, 60, 164)",url:"https://static.fimfiction.net/images/custom_banners/ep_shady_trough.jpg?2",
source:"http://equestria-prevails.deviantart.com/art/The-Shady-Trough-319986368",id:"ep_shady_trough"},{colour:"rgb(60, 85, 164)",url:"https://static.fimfiction.net/images/custom_banners/spittfire_1.jpg?2",source:"http://spittfireart.deviantart.com/art/The-Report-Commission-340421670",id:"spittfire_1"},{colour:"rgb(75, 77, 85)",url:"https://static.fimfiction.net/images/custom_banners/blitzpony_luna.jpg?2",source:"http://blitzpony.deviantart.com/art/S-hard-to-say-359899432",id:"blitzpony_luna"},{colour:"rgb(71, 127, 179)",
url:"https://static.fimfiction.net/images/custom_banners/gsphere_scoots.jpg?2",source:"http://lionel23.deviantart.com/art/The-Newbie-set-an-Academy-Record-356826950",id:"gsphere_scoots"},{colour:"rgb(112, 108, 167)",url:"https://static.fimfiction.net/images/custom_banners/stoic_celestia.jpg?2",source:"http://thestoicmachine.deviantart.com/art/Radiant-Malevolence-213959523",id:"stoic_celestia"},{colour:"rgb(134, 125, 88)",url:"https://static.fimfiction.net/images/custom_banners/moe_canterlot.jpg?2",
source:"http://derpibooru.org/25",id:"moe_canterlot"},{colour:"rgb(119, 88, 134)",url:"https://static.fimfiction.net/images/custom_banners/alasou_costumes.jpg?2",source:"http://alasou.deviantart.com/art/Costume-Swap-party-381670764",id:"alasou_costumes"},{colour:"rgb(82, 90, 143)",url:"https://static.fimfiction.net/images/custom_banners/pridark_luna.jpg?2",source:"http://pridark.deviantart.com/art/A-Wonderful-Night-381504014",id:"pridark_luna"},{colour:"rgb(165, 87, 68)",url:"https://static.fimfiction.net/images/custom_banners/gign_flutterdash.jpg?2",
source:"http://gign-3208.deviantart.com/art/In-the-attic-377732207",id:"gign_flutterdash"},{colour:"rgb(85, 107, 128)",url:"https://static.fimfiction.net/images/custom_banners/goben_forest.jpg?2",source:"http://noben.deviantart.com/art/Giggling-at-the-Ghosties-356451219",id:"goben_forest"},{colour:"rgb(104, 136, 90)",url:"https://static.fimfiction.net/images/custom_banners/devinian_lyra_bonbon.jpg?2",source:"http://devinian.deviantart.com/art/Story-of-the-bench-373750983",id:"devinian_lyra_bonbon"},
{colour:"rgb(116, 145, 66)",url:"https://static.fimfiction.net/images/custom_banners/devinian_fluttershy.jpg?2",source:"http://devinian.deviantart.com/art/Picnic-with-Kindness-351639714",id:"devinian_fluttershy"},{colour:"rgb(69, 132, 182)",url:"https://static.fimfiction.net/images/custom_banners/jackalynn_pinkiedash.jpg?2",source:"http://jack-a-lynn.deviantart.com/art/Following-the-Rainbow-288432950",id:"jackalynn_pinkiedash"},{colour:"#5e7520",url:"https://static.fimfiction.net/images/custom_banners/yakovlev_fluttershy.jpg?2",
source:"http://yakovlev-vad.deviantart.com/art/Simple-curiosity-468468925",id:"yakovlev_fluttershy"},{colour:"#9e75a9",url:"https://static.fimfiction.net/images/custom_banners/yakovlev_twilight.jpg?2",source:"http://yakovlev-vad.deviantart.com/art/Time-to-wash-3-490390076",id:"yakovlev_twilight"},{colour:"#77599a",url:"https://static.fimfiction.net/images/custom_banners/mymagicdream_twilight.jpg?2",source:"http://my-magic-dream.deviantart.com/art/Twilight-453477065",id:"mymagicdream_twilight"}];function setCookie(c,d,e){var f=new Date;f.setTime(f.getTime()+864E5*e);d=escape(d);document.cookie=c+"="+d+(e?";expires="+f.toUTCString():"")+";path=/"}function delCookie(c){document.cookie=c+"=null;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/"}function getCookie(c){for(var d=document.cookie.split(";"),e=0;e<d.length;e++){var f=d[e].indexOf("=");if(c==d[e].substr(0,f).replace(/^\s+|\s+$/g,""))return unescape(d[e].substr(f+1))}return null}
try{(function(){for(var c=document.cookie.split(";"),d=0;d<c.length;d++){var e;if(e=/^\s*(__utm\w*)\s*=/.exec(c[d]))try{document.cookie=e[1]+"=null;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/",document.cookie=e[1]+"=null;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=.fimfiction.net"}catch(f){}}})()}catch(c){};function ComputeNonce(){var c=window.crypto||window.msCrypto||null;if(null!=c&&"getRandomValues"in c){var d=new Uint8Array(24);c.getRandomValues(d);try{return btoa(String.fromCharCode.apply(null,d))}catch(f){c="";for(var e=0;e<d.length;e++)c+=String.fromCharCode(d[e]);return btoa(c)}}else{c="";for(e=0;24>e;e++)c+=String.fromCharCode(Math.floor(255*Math.random()));return btoa(c)}}function SigningKeyNotFoundException(){}var signing_hmac=null;
function SignString(c,d){if(null==signing_hmac){var e=LocalStorageGet("signing_key");if(null==e||"string"!=typeof e||0==e.length)throw new SigningKeyNotFoundException;signing_hmac=xyzcrypto.supported?new xyzcrypto.hmac(xyzcrypto.sha256.asm,xyzcrypto.fromB64(e)):new sjcl.misc.hmac(sjcl.codec.base64.toBits(e))}var e=ComputeNonce(),f=Math.floor((new Date-server_time_offset)/1E3);c=e+"|"+f+"|"+btoa(d)+"|"+c;return{signature:xyzcrypto.supported?xyzcrypto.toB64(signing_hmac.generate(xyzcrypto.fromString(c))):
sjcl.codec.base64.fromBits(signing_hmac.encrypt(c)),nonce:e,timestamp:f}}
function DataToURLEncodedString(c){function d(c){return encodeURIComponent(c).replace(/[^A-Za-z0-9\-_.~%]/g,function(c){return"%"+c.charCodeAt(0).toString(16).toUpperCase()})}c=c.map(function(c){c.value+="";return c});c=c.sort(function(c,d){if(c.name==d.name){if(c.value==d.value)return 0;if(c.value<d.value)return-1;if(c.value>d.value)return 1}else{if(c.name<d.name)return-1;if(c.name>d.name)return 1}});return c.map(function(c){return d(c.name)+"="+d(c.value)}).join("&")}
function SignObject(c,d){var e=[],f;for(f in c)Object.prototype.hasOwnProperty.call(c,f)&&e.push({name:f,value:c[f]});return SignArray(e,d)}function SignArray(c,d){c=DataToURLEncodedString(c);d=SignString(c,d);return""==c?"signature="+encodeURIComponent(d.signature)+"&signature_nonce="+encodeURIComponent(d.nonce)+"&signature_timestamp="+d.timestamp:c+"&signature="+encodeURIComponent(d.signature)+"&signature_nonce="+encodeURIComponent(d.nonce)+"&signature_timestamp="+d.timestamp}
function UpdateOrInsertHiddenField(c,d,e){var f=c.querySelector("input[name="+d+"]");f||(f=document.createElement("input"),f.setAttribute("type","hidden"),f.setAttribute("name",d),c.appendChild(f));f.value=e}
function SignForm(c,d){var e=AjaxRequest.serializeForm(c).filter(function(c){return!/^signature(?:_nonce|_timestamp)?$/.test(c.name)});null==d&&(d=c.getAttribute("action"));"_submitter"in c&&""!=c._submitter.name&&e.push({name:c._submitter.name,value:c._submitter.value});e=DataToURLEncodedString(e);d=SignString(e,d);UpdateOrInsertHiddenField(c,"signature",d.signature);UpdateOrInsertHiddenField(c,"signature_nonce",d.nonce);UpdateOrInsertHiddenField(c,"signature_timestamp",d.timestamp)};function getXMLHttpRequest(){if(window.XMLHttpRequest)return new window.XMLHttpRequest;try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(c){return null}}
var AjaxRequest=function(c,d){d=void 0===d?!0:d;var e=this;this.options=c;var f=c.method||"POST",g=c.url,k={};"data"in c&&(k=c.data);if("GET"==f&&null!=k){c=[];for(var l in k)c.push(encodeURIComponent(l)+"="+encodeURIComponent(k[l]));g+=(-1<g.indexOf("?")?"&":"?")+c.join("&")}if(this.options.spinner){var m=this.options.spinner.className;this.options.spinner.className="fa fa-pulse fa-spinner"}this.options.button&&(this.options.button.disabled=!0);this.options.format=this.options.format||"json";try{var n=
(new Promise(function(c,d){var l=getXMLHttpRequest();e.request=l;try{k=e.signData(k,g)}catch(u){d(l);return}l.open(f,g);l.onreadystatechange=function(){4==this.readyState&&(200==this.status?c(this):d(this))};l.onerror=function(){d(this)};l.setRequestHeader("Content-type","application/x-www-form-urlencoded");l.send(k)})).then(function(c){"spinner"in e.options&&(e.options.spinner.className=m);"button"in e.options&&(e.options.button.disabled=!1);return c}).then(function(c){e.status=c.status;if("json"==
e.options.format){try{e.data=JSON.parse(c.response||c.responseText)}catch(q){if(q instanceof SyntaxError)throw{error:"Invalid response format: "+q+". Please send this whole message to knighty: '"+c.response+"'"};throw q;}if("error"in e.data)throw e.data;return e.data}e.data=c.responseText;return e.data},function(c){var d=e.statusErrorMessage(c.status);if(0!=c.status)throw{error:d};throw{};});c=l=null;this.options.success&&(l=function(c){e.options.success(c,e);App.BindAll(document)});c=this.options.fail?
function(c){e.options.fail(c,e)}:function(c){"error"in c&&ShowErrorWindow(c.error)};n=n.then(l,c)}catch(p){throw ShowErrorWindow("Error creating request. Please PM <a href='/user/knighty'>knighty</a> with your operating system and browser"),p;}if(d)return n};
AjaxRequest.prototype.signData=function(c,d){if("signed"in this.options&&this.options.signed)try{c="string"==typeof c?SignString(c,d):c instanceof Array?SignArray(c,d):SignObject(c,d)}catch(e){throw e instanceof SigningKeyNotFoundException?ShowErrorWindow("Signing Key not found, please log in again"):ShowErrorWindow("Error signing string: "+e),e;}else"string"!=typeof c&&(c=AjaxRequest.serialize(c));return c};
AjaxRequest.prototype.statusErrorMessage=function(c){switch(c){case 400:c="Bad Request";break;case 401:c="Request Unauthorized";break;case 403:c="Request Forbidden";break;case 404:c="Request destination not found";break;case 408:c="Request timed out. Please try again";break;case 500:c="Server Error";break;case 502:c="Bad Gateway. Please try again";break;case 503:c="Service Unavailable. Please try again later";break;default:c="Request Failed ("+c+")"}return c};AjaxRequest.prototype.cancel=function(){this.request.abort()};
AjaxRequest.serialize=function(c){var d=[],e;for(e in c)Object.prototype.hasOwnProperty.call(c,e)&&d.push(encodeURIComponent(e)+"="+encodeURIComponent(c[e]));return d.join("&")};
AjaxRequest.serializeForm=function(c){for(var d,e=[],f=c.elements.length-1;0<=f;--f)if(""!==c.elements[f].name)switch(c.elements[f].nodeName){case "INPUT":switch(c.elements[f].type){case "checkbox":case "radio":c.elements[f].checked&&e.push({name:c.elements[f].name,value:c.elements[f].value});break;case "file":break;default:e.push({name:c.elements[f].name,value:c.elements[f].value})}break;case "TEXTAREA":d=c.elements[f].value;d=d.replace(/\r\n/g,"\n").replace(/\r/g,"\n").replace(/\n/g,"\r\n");e.push({name:c.elements[f].name,
value:d});break;case "SELECT":switch(c.elements[f].type){case "select-one":e.push({name:c.elements[f].name,value:c.elements[f].value});break;case "select-multiple":for(d=c.elements[f].options.length-1;0<=d;--d)c.elements[f].options[d].selected&&e.push({name:c.elements[f].name,value:c.elements[f].options[d].value})}}return e};
AjaxRequest.serializeFormToString=function(c){var d=[];c=$jscomp.makeIterator(c.querySelectorAll("input[name]:not([disabled]), textarea[name]:not([disabled]), select[name]:not([disabled])"));for(var e=c.next();!e.done;e=c.next()){var e=e.value,f=String({checkbox:1,radio:1}[e.type]?e.checked:e.value).replace(/\r?\n/g,"\r\n");d.push(encodeURIComponent(e.name)+"="+encodeURIComponent(f))}return d.join("&")};
AjaxRequest.BindForm=function(c,d,e){e=void 0===e?null:e;null==e&&(e=document);fQuery.addScopedEventListener(e,c,"submit",function(c){c.preventDefault();var e=this,f={};f.method=e.method;f.url=e.getAttribute("action");f.signed="1"==e.getAttribute("data-signed");f.button=e.querySelector("button[type=submit]");null==f.button&&(f.button=e.querySelector(".button-submit"));f.spinner=f.button.querySelector("i");f.data=f.signed?AjaxRequest.serializeForm(e):AjaxRequest.serializeFormToString(e);f.success=
function(c,f){d(c,f,e)};e.getAttribute("data-confirm")?StyledConfirm(e.getAttribute("data-confirm"),function(){new AjaxRequest(f)}):new AjaxRequest(f)})};var Konami=function(c,d,e){this.step=0;this.code=(void 0===e?null:e)||[38,38,40,40,37,39,37,39,66,65];this.callback=d;c.addEventListener("keyup",this.keyup.bind(this),!0)};Konami.prototype.keyup=function(c){/^(?:INPUT|TEXTAREA|SELECT)?$/.test(c.target.nodeName)||(this.code[this.step]==c.keyCode?(this.step++,this.step==this.code.length&&(this.step=0,this.callback())):this.step=0)};function App(){}App.controllers={};App.createdControllers={};App.binders=[];App.globalBinders=[];App.controllerId=0;App.AddController=function(c,d){App.controllers[c]=d};
App.GetController=function(c,d){if(!(c in App.controllers))return null;var e=new App.controllers[c](d);c=d.querySelectorAll("input, textarea, select, [data-element]");c=$jscomp.makeIterator(c);for(var f=c.next();!f.done;f=c.next()){f=f.value;if("INPUT"==f.nodeName||"TEXTAREA"==f.nodeName||"SELECT"==f.nodeName)e.inputs[f.getAttribute("name")]=f;if(f.hasAttribute("data-element")){var g=f.getAttribute("data-element");e.elements[g]=f;f.removeAttribute("data-element")}}fQuery.addScopedEventListener(d,
"[data-input]","input",function(c){!c.controllerHandled&&e[this.dataset.input]&&(e[this.dataset.input](this.value,c,this),c.controllerHandled=!0)});fQuery.addScopedEventListener(d,"[data-click]","click",function(c){if(!c.controllerHandled&&e[this.dataset.click]){var d=e[this.dataset.click](this,c);c.controllerHandled=!0;"undefined"===typeof d?c.preventDefault():d||c.preventDefault()}});fQuery.addScopedEventListener(d,"[data-change]","change",function(c){!c.controllerHandled&&e[this.dataset.change]&&
(e[this.dataset.change](this.value,c,this),c.controllerHandled=!0)});fQuery.addScopedEventListener(d,"[data-submit]","submit",function(c){if(!c.controllerHandled){var d=e[this.getAttribute("data-submit")](this,c);"undefined"===typeof d?c.preventDefault():d||c.preventDefault()}c.controllerHandled=!0});e.bind(d);return e};App.GetControllerFromElement=function(c){c=c.getAttribute("data-controller-id");return App.createdControllers[c]};App.DeleteController=function(c){delete App.createdControllers[c.controllerId]};
App.Bind=function(c,d,e,f){c.addEventListener(d,function(c){f[e](c)})};App.AddBinder=function(c){App.binders.push(c)};App.AddGlobalEventListener=function(c,d,e){c={event:c,selector:d,"class":null,binder:e};if(d=/^\.([^\/]*)$/.exec(d))c.class=d[1];App.globalBinders.push(c)};
App.BindGlobalEventListeners=function(){for(var c=$jscomp.makeIterator(App.globalBinders),d=c.next();!d.done;d=c.next())if(d=d.value,null!=d.class)fQuery.on(document.getElementsByClassName(d.class),d.event,d.binder);else fQuery.on(document.querySelectorAll(d.selector),d.event,d.binder)};App.BindAll=function(c){App.binders.forEach(function(d){d(c)});App.BindControllers(c);App.BindGlobalEventListeners()};
App.BindControllers=function(c){c=$jscomp.makeIterator(fQuery.nodesToArray(c.querySelectorAll("[data-controller]")).reverse());for(var d=c.next();!d.done;d=c.next()){var d=d.value,e=d.getAttribute("data-controller");try{var f=App.GetController(e,d);null!=f&&(d.removeAttribute("data-controller"),d.setAttribute("data-controller-id",App.controllerId),App.createdControllers[App.controllerId]=f,f.controllerId=App.controllerId,App.controllerId++)}catch(g){document.querySelector("body").appendChild(fQuery.createFromHtml(' \n                <div class="message"><b>Error binding \''+
e+"' controller:</b><br />"+g.message+"</div>\n            ")),console.log(g)}}};App.DispatchEvent=function(c,d,e){e=void 0===e?null:e;var f=document.createEvent("Event");f.initEvent(d,!0,!0);if(null!=e)for(var g in e)e.hasOwnProperty(g)&&(f[g]=e[g]);c.dispatchEvent(f)};(function(){window.Konami&&(new Konami(document,function(){}),new Konami(document,function(){StyledAlert("<img src='https://derpicdn.net/img/view/2014/7/11/672355.gif' style='max-width:100%; display:block;' />","God Mode Activated")},[73,68,68,81,68]),new Konami(document,function(){StyledAlert("Why would a pony need guns?")},[73,68,75,70,65]),new Konami(document,function(){StyledAlert('<iframe width="420" height="315" src="https://www.youtube.com/embed/ab8GtuPdrUQ?autoplay" frameborder="0" allowfullscreen style="max-width:100%;"></iframe>')},
[0,1,1,8,9,9,9,8,8,1,9,9,9,1,1,9,7,2,5,3].map(function(c){return c+48})),new Konami(document,function(){StyledAlert('<img src="https://derpicdn.net/img/view/2014/6/5/645529.png" style="max-width:100%;" />')},"justinbailey".split("").map(function(c){c=c.charCodeAt(0);if(48<=c&&57>=c)return c;if(97<=c&&122>=c)return c-32})))})();
function composePm(c,d){var e=new PopUpMenu("","<i class='fa fa-envelope'></i> Compose Private Message");e.LoadContent("/ajax/private-messages/new?receiver="+encodeURIComponent(d)+"&subject="+encodeURIComponent(c),!0).then(function(c){var d=App.GetControllerFromElement(c.element.querySelector(".compose-pm-controller"));d.onSend.addListener(function(){c.Close()});d.onCancel.addListener(function(){c.Close()})});e.SetWidth(500);e.SetDimmerEnabled(!0);e.Show()}
fQuery.addScopedEventListener(document,"[data-action='compose-pm']","click",function(){var c=this.getAttribute("data-subject");null==c&&(c="");composePm(c,this.getAttribute("data-recipient"))});var HashCallbacks={};function fireHashCallback(){var c=window.location.hash.substr(1).split("/",2);if(Object.prototype.hasOwnProperty.call(HashCallbacks,c[0]))HashCallbacks[c[0]](c[1])}window.addEventListener("hashchange",fireHashCallback);function AddHashCallback(c,d){HashCallbacks[c]=d}
function ShowErrorWindow(c){var d=new PopUpMenu("","<i class='fa fa-warning'></i> Error");d.SetContent("");d.SetCloseOnHoverOut(!1);d.SetFixed(!0);d.SetContent("<center style='padding:18px;'>"+c+"</center>");d.SetFooter("<center><button class='styled_button' style='padding: 5px 40px;''>Ok</button></center>");d.SetCloseOnHoverOut(!1);d.SetWidth(350);d.Show();d.element.querySelector("button").addEventListener("click",function(c){c.preventDefault();c.stopPropagation();d.Close()})}
function StyledConfirm(c,d,e,f){var g=new PopUpMenu("","<i class='fa fa-question-circle'></i> Confirm");g.SetContent("");g.SetCloseOnHoverOut(!1);g.SetFixed(!0);g.SetContent("<div style='padding:18px;'>"+c+"</div>");g.SetFooter("<div style='text-align:right;'><button id='ok_button' class='styled_button'><i class='fa fa-check'></i> Ok</button> <button id='cancel_button' class='styled_button styled_button_red'><i class='fa fa-times'></i>  Cancel</button></div>");g.SetCloseOnHoverOut(!1);g.SetWidth(350);
g.Show();document.getElementById("ok_button").addEventListener("click",function(c){c.preventDefault();c.stopPropagation();g.Close();void 0!==d&&d();void 0!==f&&f()});document.getElementById("cancel_button").addEventListener("click",function(c){c.preventDefault();c.stopPropagation();g.Close();void 0!==e&&e();void 0!==f&&f()})}
fQuery.addScopedEventListener(document.body,"[data-lightbox]","click",function(c){if(null==fQuery.closestParent(this,"a")){var d=this.dataset.src||this.src,e=d.match(/https?:\/\/([^/]*)/i);e&&(d=e[1]);var f='\n        <div class="lightbox">\n            <div class="container">\n                <img src="'+(this.dataset.fullsize||this.src)+'"/>\n                <div class="caption"><b><span class="dimensions"></span> - Source:</b> <a href="'+this.dataset.src+'">'+d+"</a></div>\n            </div>\n        </div>",
f=fQuery.createFromHtml(f),g=null,k=f.querySelector("img"),l=f.querySelector(".container");fQuery.animationFrame(function(){if(k.naturalWidth)return f.querySelector(".dimensions").textContent=k.naturalWidth+"px \u00d7 "+k.naturalHeight+"px",l.classList.add("show"),!1});f.addEventListener("click",function(c){var d=this;fQuery.isOrChildOf(c.target,f.querySelector(".caption"))||(fQuery.enableScroll(g),l.classList.remove("show"),f.classList.remove("show"),setTimeout(function(){return fQuery.removeElement(d)},
200))});document.body.appendChild(f);forceRelayout(f);f.classList.add("show");g=fQuery.disableScroll();c.preventDefault();return!0}},!0);App.AddGlobalEventListener("click",".user_image_link",function(c){c.preventDefault();(c=this.parentNode.querySelector("img"))?c.parentNode.removeChild(c):(c=document.createElement("img"),c.src=this.href,c.className="user_image",c.setAttribute("data-lightbox",!0),c.setAttribute("data-src",this.textContent),c.style.display="block",fQuery.insertAfter(this,c))});
var UpdateTimeOffsets=function(){if(!document.hidden&&!document.webkitHidden)for(var c=Math.floor((new Date-server_time_offset)/1E3),d=document.getElementsByClassName("time_offset"),d=$jscomp.makeIterator(d),e=d.next();!e.done;e=d.next())e=e.value,e.textContent=TimeOffsetToFriendlyName(c-e.dataset.time)};setInterval(UpdateTimeOffsets,5E3);document.addEventListener("visibilitychange webkitvisibilitychange",UpdateTimeOffsets);
App.AddBinder(function(c){"twemoji"==LocalStorageGet("emojis","")&&twemoji.parse(c,{folder:"svg",ext:".svg"})});
fQuery.ready(function(){fQuery.addScopedEventListener(document.body,".drop-down-expander","click",function(c){var d=this.parentNode,e=null,f=d.dataset.closeOnLink?"true"==d.dataset.closeOnLink:!0;if(d.classList.contains("drop-down-show"))App.DispatchEvent(d,"close"),c.stopPropagation();else{d.classList.add("drop-down-show");var g=function(c){fQuery.isOrChildOf(c.target,d)||(App.DispatchEvent(d,"close"),c.stopPropagation())},k=function(c){d.classList.remove("drop-down-show");document.body.removeEventListener("click",
g,!1);fQuery.removeScopedEventListener(d,"click",e);d.removeEventListener("close",k)};d.addEventListener("close",k);App.DispatchEvent(d,"opened");document.body.addEventListener("click",g,!1);e=fQuery.addScopedEventListener(d,".drop-down a","click",function(c){f&&App.DispatchEvent(d,"close")})}})});
fQuery.ready(function(){fQuery.addScopedEventListener(document.body,".form-signed","submit",function(){SignForm(this);return!0});fQuery.addScopedEventListener(document.body,".form-signed button[name]","click",function(){this.form._submitter=this});fQuery.addScopedEventListener(document.body,"[data-signed] button[name]","click",function(){this.form._submitter=this})});
window.addEventListener("load",function(){for(var c=parseInt(LocalStorageGet("adblock-message","0"),10),d=$jscomp.makeIterator(document.getElementsByClassName("dgjklsdjlgksjdg")),e=d.next();!e.done;e=d.next()){var e=e.value,f=e.dataset.adClass,g=(new Date).getTime(),k=e.querySelector("ins"),l=e.getBoundingClientRect();(null==k||0==l.height)&&g>c+2592E6&&(f=fQuery.createFromHtml("<div class='dafhgadeh4rahdfhadfhadfhadfghaergerg "+f+"'>\n                Hey there, looks like you're using adblock! We know, we know, adverts are incredibly annoying, but they really help to support the site. If you'd consider unblocking the site, we'd be extremely appreciative!\n                <a class='button-hide-ads' style='text-decoration:underline; color:inherit; font-weight:bold;'>Hide This Message</a>\n            </div>"),
e.appendChild(f))}});fQuery.addScopedEventListener(document,".button-hide-ads","click",function(c){var d=(new Date).getTime();LocalStorageSet("adblock-message",d);fQuery.removeElements(document.getElementsByClassName("dafhgadeh4rahdfhadfhadfhadfghaergerg"));c.preventDefault()});var Curves=function(){};Curves.Cos=function(c){return 1-(Math.cos(3.14159*c)+1)/2};Curves.EaseOut=function(c){return 1-(1-c)*(1-c)};
fQuery.addScopedEventListener(document,".jump-to","click",function(c){c.preventDefault();c=null;c=document.querySelector(this.dataset.jump);c=this.dataset.align&&"bottom"==this.dataset.align?c.getBoundingClientRect().bottom-window.innerHeight:c.getBoundingClientRect().top;fQuery.animateProperty(function(c){fQuery.scrollTop(c,!0)},fQuery.scrollTop(),document.body.scrollTop+c,.5,Curves.Cos)});var HTMLToBBCode=function(){this.default_block_regex=/^(?:H[1-6]|HR|BLOCKQUOTE|LI|UL|OL|P|DIV|PRE|DL|DD|DT|TABLE|TR)$/i;this.double_block_regex=/^(?:H[1-6]|HR|BLOCKQUOTE|UL|OL|P|PRE)$/i};HTMLToBBCode.prototype.isBlock=function(c){var d=this.default_block_regex.test(c.tagName);return("block"==c.style.display||d&&("table"==c.style.display||"block"==c.style.display||""==c.style.display))&&"left"!=c.style.float&&"right"!=c.style.float};
HTMLToBBCode.prototype.hasTextChildren=function(c){if(3==c.nodeType)return!0;if("childNodes"in c){c=$jscomp.makeIterator(c.childNodes);for(var d=c.next();!d.done;d=c.next())if(this.hasTextChildren(d.value))return!0}return!1};
HTMLToBBCode.prototype.processNode=function(c,d,e){var f="";if(3==c.nodeType)return f=c.nodeValue,e||(f=f.replace(/\r/g,"\n"),f=f.replace(/\n+/g," ")),""!=c.nodeValue&&(d.startBlock=!0),f;if(1==c.nodeType){var g=c.style.fontWeight,k=c.style.textDecoration,g="B"==c.tagName&&"normal"!=g||"bold"==g||500<=g,l="U"==c.tagName||/\bunderline\b/i.test(k),k=/\bline-through\b/i.test(k),m="I"==c.tagName||"italic"==c.style.fontStyle;this.default_block_regex.test(c.tagName);var n=this.isBlock(c),p=parseFloat(c.style.marginTop),
q=this.double_block_regex.test(c.tagName)&&(isNaN(p)||0!=p),p=n&&("CENTER"==c.tagName||"center"==c.style.textAlign&&""!=c.innerHTML),t=n&&"right"==c.style.textAlign,u="SUP"==c.tagName||"super"==c.style.verticalAlign,y="SUB"==c.tagName||"sub"==c.style.verticalAlign,v=this.hasTextChildren(c);if(null!=c.previousElementSibling&&this.isBlock(c.previousElementSibling)){var x=parseFloat(c.previousElementSibling.style.marginBottom);isNaN(x)||0==x||(q=!0)}if(/(?:STYLE|SCRIPT)/.test(c.tagName))return"";(n||
null!=c.previousElementSibling&&1==c.nodeType&&this.isBlock(c.previousElementSibling))&&d.startBlock&&(f=q?f+"\n\n":f+"\n",d.startBlock=!1);"BR"==c.tagName&&(f+="\n");"HR"==c.tagName&&(d.startBlock=!0,f+="[hr]");"IMG"==c.tagName&&""!=c.src&&(d.startBlock=!0,f=c.classList.contains("emoticon")||c.classList.contains("emoji")?f+c.alt:f+("[img]"+c.src+"[/img]"));"BLOCKQUOTE"==c.tagName&&(f=c.hasAttribute("data-who")?f+("[quote="+c.getAttribute("data-who")+"]"):f+"[quote]");"DIV"==c.tagName&&"embed-container"==
c.className&&(f+="[embed]"+c.getAttribute("data-original-src")+"[/embed]");"PRE"==c.tagName&&(0<c.childNodes.length&&"CODE"==c.childNodes[0].tagName||(f+="[pre]"),e=!0);"CODE"==c.tagName&&(n=(r=/language-([a-z]+)/i.exec(c.className))?"="+r[1]:"",f="PRE"==c.parentNode.tagName?f+("[codeblock"+n+"]\n"):f+("[code"+n+"]"));r=/^([0-9.]+)p[xt]$/.exec(c.style.fontSize);"A"==c.tagName&&""!=c.href&&(f+="[url="+c.href+"]",new_node=document.createElement("A"),new_node.href=c.href);"STRONG"==c.tagName&&(f+="[strong]");
"EM"==c.tagName&&(f+="[em]");"H1"==c.tagName&&(f+="[h1]");"H2"==c.tagName&&(f+="[h2]");"H3"==c.tagName&&(f+="[h3]");"H4"==c.tagName&&(f+="[h4]");"H5"==c.tagName&&(f+="[h5]");"H6"==c.tagName&&(f+="[h6]");"UL"==c.tagName&&(f+="[list]\n");"OL"==c.tagName&&(f+="[list=1]\n");"LI"==c.tagName&&(f+="[*]");g&&v&&(f+="[b]");l&&v&&(f+="[u]");m&&v&&(f+="[i]");k&&v&&(f+="[s]");u&&v&&(f+="[sup]");y&&v&&(f+="[sub]");p&&(f+="[center]");t&&(f+="[right]");"spoiler"==c.className&&(f+="[spoiler]");if("childNodes"in c)for(n=
$jscomp.makeIterator(c.childNodes),q=n.next();!q.done;q=n.next())f+=this.processNode(q.value,d,e);"spoiler"==c.className&&(f+="[/spoiler]");t&&(f+="[/right]");y&&v&&(f+="[/sub]");u&&v&&(f+="[/sup]");p&&(f+="[/center]");k&&v&&(f+="[/s]");m&&v&&(f+="[/i]");l&&v&&(f+="[/u]");g&&v&&(f+="[/b]");if("UL"==c.tagName||"OL"==c.tagName)f+="\n[/list]";"EM"==c.tagName&&(f+="[/em]");"STRONG"==c.tagName&&(f+="[/strong]");"H1"==c.tagName&&(f+="[/h1]");"H2"==c.tagName&&(f+="[/h2]");"H3"==c.tagName&&(f+="[/h3]");"H4"==
c.tagName&&(f+="[/h4]");"H5"==c.tagName&&(f+="[/h5]");"H6"==c.tagName&&(f+="[/h6]");"A"==c.tagName&&""!=c.href&&(f+="[/url]");"CODE"==c.tagName&&(f="PRE"==c.parentNode.tagName?f+"\n[/codeblock]":f+"[/code]");"PRE"==c.tagName&&(0<c.childNodes.length&&"CODE"==c.childNodes[0].tagName||(f+="[/pre]"));"BLOCKQUOTE"==c.tagName&&(f+="[/quote]")}return f};
HTMLToBBCode.prototype.convert=function(c){var d=document.createElement("div");d.innerHTML=c;"debug"in HTMLToBBCode&&console.log(c);c=this.processNode(d,{output_block:!1},!1);return c=c.replace(/([\u00A0\t ]+)(?=\n)/g,"")};function diff(c,d){for(;0<c.length;)a=c[0],b=d[0]}var BBCodeEditorController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(BBCodeEditorController,Controller);
BBCodeEditorController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.textarea=c.querySelector("textarea");this.toolbar=c.querySelector(".format-toolbar");this.settings={richPaste:!0,hotkeys:!0,smartQuotes:!1};c=JSON.parse(LocalStorageGet("bbcode_settings","{}"));for(var e in c)this.settings[e]=c[e];this.textarea.addEventListener("keypress",function(c){if('"'==c.key&&d.settings.smartQuotes)return d.textarea.value.substr(0,d.textarea.selectionStart).match(/(\s|^)$/)?
d.insertText("\u201c"):d.insertText("\u201d"),c.preventDefault(),!0;if("'"==c.key&&d.settings.smartQuotes)return d.textarea.value.substr(0,d.textarea.selectionStart).match(/(\s|^)$/)?d.insertText("\u2018"):d.insertText("\u2019"),c.preventDefault(),!0;if(c.ctrlKey&&"*"==c.key)return c.preventDefault(),d.insertUl(null,c),!0});this.textarea.addEventListener("keydown",function(c){27==c.which&&d.exitFullscreen();if(!d.settings.hotkeys)return!1;c.ctrlKey&&!c.altKey&&(66==c.which&&(c.preventDefault(),d.bold(null,
c)),69==c.which&&(c.preventDefault(),d.showAddEmbed(null,c)),72==c.which&&(c.preventDefault(),d.addHorizontalRule(null,c)),73==c.which&&(c.preventDefault(),d.italic(null,c)),75==c.which&&(c.preventDefault(),d.showAddLink(null,c)),81==c.which&&(c.preventDefault(),d.quote(null,c)),85==c.which&&(c.preventDefault(),d.underline(null,c)),83==c.which&&(c.preventDefault(),d.save(null,c)),189==c.which&&(c.preventDefault(),d.strikethrough(null,c)));if(c.altKey&&13==c.which)c.preventDefault(),d.toggleFullscreen();
else{if(13==c.which&&(d.textarea.selectionStart||"0"==d.textarea.selectionStart)){var e=d.textarea.selectionStart,f=d.textarea.selectionEnd;e==f&&(f=d.textarea.value.substring(0,f).lastIndexOf("\n"),e=d.textarea.value.substring(f,e),e=e.trim(),e.startsWith("[*]")&&(d.insertText("\n[*]"),c.preventDefault()))}9==c.which&&(d.insertText("\t"),c.preventDefault())}});this.textarea.addEventListener("paste",function(c){if(!d.settings.richPaste)return!1;var e=c.clipboardData.getData("text/html");if(""==e)return!1;
var f=null;"string"==typeof e&&""!=e?f=e:"object"==typeof e&&"outerHTML"in e&&(f=e.outerHTML());e=new HTMLToBBCode;d.insertText(e.convert(f));c.preventDefault();return!0});this.toolbarItems=this.lastToolbarWidth=null;this.maxPriority=this.element.dataset.maxPriority?this.element.dataset.maxPriority:10;"complete"===document.readyState?this.layoutToolbar():window.addEventListener("load",function(){return d.layoutToolbar(!0)});window.addEventListener("resize",function(){return d.layoutToolbar(!0)});
document.addEventListener("click",function(){return d.layoutToolbar()})};
BBCodeEditorController.prototype.layoutToolbar=function(c){c=void 0===c?!1:c;if(null==this.toolbarItems){var d=this.toolbar.querySelector(".toolbar_buttons");if(null==d.offsetParent)return;this.toolbarItems=Array.from(d.childNodes).filter(function(c){return 1==c.nodeType}).map(function(c,d){c.dataset.order=d;return{node:c,width:c.offsetWidth+(c.classList.contains("divider")?5:0),priority:c.hasAttribute("data-priority")?c.dataset.priority:0,order:d}}).sort(function(c,d){return c.priority==d.priority?
c.order-d.order:c.priority-d.priority})}d=this.toolbar.getBoundingClientRect().width-10;if(this.lastToolbarWidth!=d||c){this.lastToolbarWidth=d;c=this.toolbar.querySelector(".toolbar_buttons");fQuery.removeChildren(c);fQuery.removeChildren(this.elements.overflowList);for(var e=0,f=$jscomp.makeIterator(this.toolbarItems),g=f.next();!g.done;g=f.next()){var g=g.value,k=!1;if(g.priority<=this.maxPriority){for(var l=0;l<c.childNodes.length;l++){var m=c.childNodes.item(l);if(m.dataset.order>g.order){fQuery.insertBefore(m,
g.node);k=!0;break}}e+=g.width;k||c.appendChild(g.node);if(e>d&&"-1"!=g.priority){c.removeChild(g.node);break}}}d=[];for(e=0;e<c.childNodes.length;e++)f=c.childNodes.item(e),f.classList.contains("divider")&&(null==f.nextSibling||f.nextSibling.classList.contains("divider"))&&d.push(f);c=$jscomp.makeIterator(this.toolbarItems);for(g=c.next();!g.done;g=c.next())if(e=g.value,null==e.node.parentNode||e.node.classList.contains("divider")&&"-1"!=e.priority){f=!1;g=e.node;e.node.classList.contains("divider")&&
(g=fQuery.createFromHtml('<li data-order="'+e.order+'" class="divider"></li>'));for(k=0;k<this.elements.overflowList.childNodes.length;k++)if(l=this.elements.overflowList.childNodes.item(k),l.dataset.order>e.order){fQuery.insertBefore(l,g);f=!0;break}f||this.elements.overflowList.appendChild(g)}for(c=0;c<this.elements.overflowList.childNodes.length;c++)e=this.elements.overflowList.childNodes.item(c),e.classList.contains("divider")&&(null==e.nextSibling||e.nextSibling.classList.contains("divider"))&&
d.push(e);d=$jscomp.makeIterator(d);for(c=d.next();!c.done;c=d.next())fQuery.removeElement(c.value)}};BBCodeEditorController.prototype.focus=function(){this.textarea.focus()};BBCodeEditorController.prototype.getText=function(){return this.textarea.value};BBCodeEditorController.prototype.setText=function(c){this.textarea.value=c};
BBCodeEditorController.prototype.insertText=function(c,d){d=void 0===d?!0:d;var e=this.textarea;d&&this.focus();if(document.selection)sel=document.selection.createRange(),sel.text=c;else if(e.selectionStart||"0"==e.selectionStart){var f=e.selectionStart,g=e.selectionEnd,k=e.value.substring(0,f);0<g-f&&e.value.substring(f,g);var g=e.value.substring(g,e.value.length),l=e.value;d?(document.execCommand("insertText",!1,c),l==e.value&&(e.value=k+c+g)):e.value=k+c+g;e.selectionStart=f+c.length;e.selectionEnd=
f+c.length}else e.value+=c};BBCodeEditorController.prototype.getSelection=function(){var c=this.textarea;if(document.selection)return c.focus(),sel=document.selection.createRange(),sel.text;if(c.selectionStart||"0"==c.selectionStart){var d=c.selectionStart,e=c.selectionEnd;return 0<e-d?c.value.substring(d,e):""}return""};BBCodeEditorController.prototype.insertTag=function(c){this.insertTags("["+c+"]","[/"+c+"]")};
BBCodeEditorController.prototype.insertTags=function(c,d){var e=this.textarea;this.focus();if(document.selection)sel=document.selection.createRange(),sel.text=c+d;else if(e.selectionStart||"0"==e.selectionStart){var f=e.selectionStart,g=e.selectionEnd,k=e.value.substring(0,f),l=0<g-f?e.value.substring(f,g):"",m=e.value.substring(g,e.value.length),n=e.scrollTop;if(e.value.substring(f,f+d.length)==d)e.selectionStart=g+d.length,e.selectionEnd=g+d.length;else{var p=e.value;document.execCommand("insertText",
!1,c+l+d);p==e.value&&(e.value=k+c+l+d+m);e.selectionStart=f+c.length;e.selectionEnd=g+c.length}e.scrollTop=n}else e.value+=c+d;this.textarea.focus()};
BBCodeEditorController.prototype.showColourPicker=function(c,d){d.preventDefault();d=c.parentNode.querySelector("div");if(null==d){d=document.createElement("div");d.className="drop-down drop-down-colours";var e=document.createElement("div");e.className="arrow";var f=document.createElement("ul");d.appendChild(e);d.appendChild(f);e=[["Light Grey","#cccccc"],["Grey","#aaaaaa"],["Grey","#888888"],["Grey","#666666"],["Dark Grey","#333333"],["Break",""],["Brown","#5f4432"],["Red","#be4343"],["Orange","#be7a43"],
["Yellow","#afa426"],["Lime Green","#7aaf26"],["Green","#2caf26"],["Turquoise","#26af6d"],["Light Blue","#26a4af"],["Blue","#265daf"],["Purple","#3c26af"],["Violet","#9426af"],["Pink","#af2673"],["Break",""],["Twilight Sparkle","#a66ebe"],["Rarity","#5e51a3"],["Applejack","#e97135"],["Pinkie Pie","#ea80b0"],["Rainbow Dash","#6aaadd"],["Fluttershy","#e6b91f"]];for(i=0;i<e.length;i++){var g=document.createElement("li");if("Break"==e[i][0])g.className="divider";else{var k=document.createElement("a");
k.setAttribute("title",e[i][0]+" ( "+e[i][1]+" )");k.setAttribute("data-click","setColour");k.setAttribute("data-colour",e[i][1]);var l=document.createElement("span");l.className="colour-preview";l.style.backgroundColor=e[i][1];k.appendChild(l);g.appendChild(k)}f.appendChild(g)}c.parentNode.appendChild(d)}};BBCodeEditorController.prototype.setColour=function(c){c=c.getAttribute("data-colour");this.insertTags("[color="+c+"]","[/color]")};
BBCodeEditorController.prototype.showSizePicker=function(c,d){d.preventDefault();d=c.parentNode.querySelector("div");if(null==d){d=document.createElement("div");d.className="drop-down";var e=document.createElement("div");e.className="arrow";var f=document.createElement("ul");d.appendChild(e);d.appendChild(f);e=[[.5,"Very Small"],[.75,"Small"],[1.5,"Large"],[2,"Very Large"]];for(i=0;i<e.length;i++){var g=document.createElement("li"),k=document.createElement("a");k.setAttribute("data-click","setSize");
k.setAttribute("data-size",e[i][0]);k.style.fontSize=(e[i][0]+2)/3+"em";k.textContent=e[i][1]+" - "+e[i][0]+"x";g.appendChild(k);f.appendChild(g)}c.parentNode.appendChild(d)}};
BBCodeEditorController.prototype.showHeadingPicker=function(c,d){d.preventDefault();d=c.parentNode.querySelector("div");if(null==d){d=document.createElement("div");d.className="drop-down drop-down-headings";var e=document.createElement("div");e.className="arrow";var f=document.createElement("ul");d.appendChild(e);d.appendChild(f);for(i=1;6>=i;i++){var e=document.createElement("li"),g=document.createElement("a");g.setAttribute("data-click","setHeading");g.setAttribute("data-size",i);g.style.fontSize=
1+(6-i)/6*.8+"em";g.textContent="Heading "+i;e.appendChild(g);f.appendChild(e)}c.parentNode.appendChild(d)}};BBCodeEditorController.prototype.setHeading=function(c){c=c.getAttribute("data-size");this.insertTag("h"+c)};BBCodeEditorController.prototype.setSize=function(c){c=c.getAttribute("data-size");this.insertTags("[size="+c+"em]","[/size]")};BBCodeEditorController.prototype.bold=function(c,d){d.preventDefault();this.insertTag("b")};
BBCodeEditorController.prototype.italic=function(c,d){d.preventDefault();this.insertTag("i")};BBCodeEditorController.prototype.underline=function(c,d){d.preventDefault();this.insertTag("u")};BBCodeEditorController.prototype.strikethrough=function(c,d){d.preventDefault();this.insertTag("s")};BBCodeEditorController.prototype.superscript=function(c,d){d.preventDefault();this.insertTag("sup")};BBCodeEditorController.prototype.subscript=function(c,d){d.preventDefault();this.insertTag("sub")};
BBCodeEditorController.prototype.code=function(c,d){d.preventDefault();this.insertTag("code")};BBCodeEditorController.prototype.quote=function(c,d){d.preventDefault();this.insertTag("quote")};BBCodeEditorController.prototype.spoiler=function(c,d){d.preventDefault();this.insertTag("spoiler")};
BBCodeEditorController.prototype.curlyQuotes=function(c,d){c=this.textarea.value;c=c.replace(/(\S)\"/g,"$1\u201d");c=c.replace(/\"(?=\S)/g,"\u201c");c=c.replace(/(\S)\'/g,"$1\u2019");c=c.replace(/\'(?=\S)/g,"\u2018");this.textarea.value=c};BBCodeEditorController.prototype.insertUl=function(c,d){d.preventDefault();c=this.getSelection();d="[list]\n";for(var e=$jscomp.makeIterator(c.split("\n")),f=e.next();!f.done;f=e.next())f=f.value,""!=f&&(d+="[*]"+f+"\n");""==c&&(d+="[*]\n");this.insertText(d+"[/list]\n")};
BBCodeEditorController.prototype.insertOl=function(c,d){d.preventDefault();c=this.getSelection();d="[list=1]\n";for(var e=$jscomp.makeIterator(c.split("\n")),f=e.next();!f.done;f=e.next())f=f.value,""!=f&&(d+="[*]"+f+"\n");""==c&&(d+="[*]\n");this.insertText(d+"[/list]\n")};
BBCodeEditorController.prototype.showAddLink=function(c,d){var e=this;d.preventDefault();c=this.getSelection();null==c&&(c="");var f=new PopUpMenu("","<i class='fa fa-link'></i> Add Link");str="\n       <form id='add_link'>\n            <div class='std'>\n                <div style='padding:10px;'>\n                    <input type='url' name='link' placeholder='URL - SFW content only!' required='required' />\n                    <input type='text' name='text' placeholder='Link Text' id='add_link_title_input' style=\"margin-top:5px;\" />\n                </div>\n            </div>\n            <div class=\"drop-down-pop-up-footer-right\">\n                <button class='styled_button'> Add Link</button>\n            </div>\n       </form>";f.SetContent(str);
f.SetCloseOnHoverOut(!1);f.SetWidth(350);f.Show();f.element.querySelector("[name=text]").value=c;f.element.querySelector("[name=link]").focus();document.getElementById("add_link").addEventListener("submit",function(c){c.preventDefault();var d=c.target;c=d.querySelector("input[name='link']").value;d=d.querySelector("input[name='text']").value;""==d?e.insertText("[url]"+c+"[/url]"):e.insertText("[url="+c+"]"+d+"[/url]");f.Close()})};
BBCodeEditorController.prototype.showEmoticonsPicker=function(c,d){d.preventDefault();d=c.parentNode.querySelector("div");if(null==d){d=document.createElement("div");c.parentNode.dataset.closeOnLink=!1;d.className="drop-down drop-down-emoticons";var e=document.createElement("div");e.className="arrow";var f=fQuery.createFromHtml('\n                <div data-controller="emoji" class="emoji-selector">\n                    <div class="emoji-selector__search"><input type="search" data-input="search" placeholder="search..." /></div>\n                    <ul class="emoji-selector__list" data-element="list"></ul>\n                    <ul class="emoji-selector__tabs" data-element="tabs"></ul>\n                </div>');
d.appendChild(e);d.appendChild(f);c.parentNode.appendChild(d);App.BindAll(document)}};BBCodeEditorController.prototype.addEmoticon=function(c,d){d.preventDefault();this.insertText(c.getAttribute("data-emoticon"));d.shiftKey||d.ctrlKey||App.DispatchEvent(c,"close")};
BBCodeEditorController.prototype.showAddEmbed=function(c,d){d.preventDefault();var e={Youtube:/(?:youtube.com\/watch\S*v=|youtu.be\/)([a-z0-9-_]{11})/i,Streamable:/^https:\/\/(?:www\.)?streamable\.com\/([a-zA-Z0-9]+)/i,Gfycat:/https:\/\/(?:www\.)?gfycat\.com\/([a-zA-Z0-9]+)/i,Imgur:/^(?:https?:\/\/)?imgur\.com\/a\/([a-z0-9_-]{5})/i,Soundcloud:/^https:\/\/soundcloud.com\/(.*)$/i,Twitch:/^https?:\/\/(?:www.)?twitch\.tv\/([^/]+)$/i,Fimfiction:/^https?:\/\/(?:www.)?fimfiction.net\/story\/([0-9]+)\/.*$/i},
f=new PopUpMenu("","<i class='fa fa-picture-o'></i> Add Embed");str="\n        <form id='add_embed'>\n            <div class='std'>\n                <div style='padding:10px;'>\n                    <div style='border:1px solid #ccc; width:100%; height:200px; box-shadow: 0 0 20px rgba(0,0,0,0.2) inset; display: none;' class='pattern-checkerboard'>\n                        <iframe id='embed_preview' style='display:block; margin:auto; height:100%; width:100%;'></iframe>\n                    </div>\n                    <div style=\"margin-bottom:10px;\">\n                        <b>Supported sources:</b> "+
Object.keys(e).join(", ")+"\n                    </div>\n                    <div class=\"message hidden\" id=\"embed_message\"></div>\n                    <input name='valid' type='hidden' value='0' />\n                    <input type='url' name='url' placeholder='URL' required='required' />\n                    <div id='add_embed_error' class='error-message hidden'>Invalid Embed URL</div>\n                </div>\n            </div>\n            <div class=\"drop-down-pop-up-footer-right\">\n                <button class=\"styled_button\"><i class=\"fa fa-plus\"></i> Add Embed</button>\n            </div>\n        </form>\n        ";
f.SetContent(str);f.SetCloseOnHoverOut(!1);f.SetWidth(350);f.Show();var g=this;document.getElementById("add_embed").addEventListener("submit",function(c){c.preventDefault();c=this.querySelector("[name=url]").value;g.insertText("[embed]"+c+"[/embed]");f.Close()});document.getElementById("add_embed").querySelector("[name=url]").focus();document.getElementById("add_embed").querySelector("[name=url]").addEventListener("input",function(c){c=this.value;for(var d=!1,f=$jscomp.makeIterator(Object.keys(e)),
g=f.next();!g.done;g=f.next())g=g.value,null!=c.match(e[g])&&(document.getElementById("embed_message").innerHTML="<b>"+g+":</b><br/> "+c,d=!0);d?(this.setCustomValidity(""),document.getElementById("embed_message").classList.remove("hidden")):(this.setCustomValidity("Not a valid embeddable URL"),document.getElementById("embed_message").classList.add("hidden"))})};
BBCodeEditorController.prototype.showAddImage=function(c){var d=this,e=new PopUpMenu("","<i class='fa fa-picture-o'></i> Add Image");str="\n        <form id='add_image'>\n            <div class='std'>\n                <div style='padding:10px;'>\n                    <div style='border:1px solid #aaa; border-radius:3px; margin-bottom:10px; width:100%; height:200px; display: flex;' class='pattern-checkerboard'>\n                        <img id='bbcode_image_preview' style='display:block; margin:auto; max-height:100%; max-width:100%;'>\n                    </div>\n                    <input name='valid' type='hidden' value='0' />\n                    <input type='url' name='url' id='bbcode_image' placeholder='Image URL - SFW images only!' required='required' />\n                    <div id='add_image_error' class='error-message hidden'>Invalid Image</div>\n                </div>\n            </div>\n            <div class=\"drop-down-pop-up-footer-right\">\n                <button class='styled_button'><i class=\"fa fa-plus\"></i> Add Image</button>\n            </div>\n        </form>";
e.SetContent(str);e.SetCloseOnHoverOut(!1);e.SetWidth(350);e.Show();var f=!1;document.getElementById("bbcode_image").focus();document.getElementById("bbcode_image").addEventListener("input",function(){""!=this.value&&/:\/\//i.test(this.value)&&(document.getElementById("bbcode_image_preview").src=this.value);document.getElementById("bbcode_image_preview").classList.toggle("hidden",""==this.value)});document.getElementById("bbcode_image_preview").addEventListener("load",function(){f=!0;document.getElementById("add_image_error").classList.add("hidden")});
document.getElementById("bbcode_image_preview").addEventListener("error",function(){f=!1});document.getElementById("add_image").addEventListener("submit",function(c){if(!f)return document.getElementById("add_image_error").classList.remove("hidden"),c.preventDefault(),!1;c.preventDefault();c=document.getElementById("bbcode_image").value;d.insertText("[img]"+c+"[/img]");e.Close()})};
BBCodeEditorController.prototype.indent=function(c,d){d.preventDefault();c=this.getSelection();d=!1;""==c&&(c=this.textarea.value,d=!0);c=c.replace(/\n/g,"\n\t");d?this.textarea.value=c:this.insertText(c)};BBCodeEditorController.prototype.outdent=function(c,d){d.preventDefault();c=this.getSelection();d=!1;""==c&&(c=this.textarea.value,d=!0);c=c.replace(/\n\t/g,"\n");d?this.textarea.value=c:this.insertText(c)};BBCodeEditorController.prototype.addHorizontalRule=function(c,d){this.insertText("[hr]")};
BBCodeEditorController.prototype.center=function(c,d){this.insertTags("[center]","[/center]")};BBCodeEditorController.prototype.addPageBreak=function(c,d){this.insertText("[page_break]")};BBCodeEditorController.prototype.save=function(c,d){d.preventDefault();App.DispatchEvent(this.textarea,"save")};
BBCodeEditorController.prototype.showSettings=function(c,d){d.preventDefault();var e=new PopUpMenu("","<i class='fa fa-cog'></i> BBCode Editor Settings");str='\n            <form id="bbcode-settings">\n                <table class="properties properties--label-align-left">\n                    <tr>\n                        <td class="label" style="width:auto;">Rich Text Paste<div class="small">Can also avoid with ctrl + shift + v</div></td>\n                        <td style="width:6em;">\n                            <label class="toggleable-switch">\n                                <input name="rich_paste" type="checkbox" class="checkbox" '+(this.settings.richPaste?
"checked":"")+' /><a></a>\n                            </label>\n                        </td>\n                    </tr>\n                    <tr>\n                        <td class="label" style="width:auto;">Hotkeys</td>\n                        <td style="width:6em;">\n                            <label class="toggleable-switch">\n                                <input name="hotkeys" type="checkbox" class="checkbox" '+(this.settings.hotkeys?"checked":"")+' /><a></a>\n                            </label>\n                        </td>\n                    </tr>\n                     <tr>\n                        <td class="label" style="width:auto;">Smart Quotes</td>\n                        <td style="width:6em;">\n                            <label class="toggleable-switch">\n                                <input name="smart_quotes" type="checkbox" class="checkbox" '+
(this.settings.smartQuotes?"checked":"")+' /><a></a>\n                            </label>\n                        </td>\n                    </tr>\n                </table>\n                <div class="drop-down-pop-up-footer-right">\n                    <button class="styled_button"><i class="fa fa-check"></i> Save</button>\n                    <button class="styled_button styled_button_red" type="button" name="cancel"><i class="fa fa-times"></i> Cancel</button>\n                </div>\n            </form>';
e.SetContent(str);e.SetCloseOnHoverOut(!1);e.SetWidth(350);e.Show();var f=this;document.getElementById("bbcode-settings").addEventListener("submit",function(c){f.settings.richPaste=this.querySelector("[name=rich_paste]").checked;f.settings.hotkeys=this.querySelector("[name=hotkeys]").checked;f.settings.smartQuotes=this.querySelector("[name=smart_quotes]").checked;LocalStorageSet("bbcode_settings",JSON.stringify(f.settings));c.preventDefault();e.Close()});document.getElementById("bbcode-settings").querySelector("[name=cancel]").addEventListener("click",
function(c){e.Close()})};
BBCodeEditorController.prototype.showPreview=function(c,d){var e=this;new AjaxRequest({url:"/ajax/bbcode/html",method:"POST",button:c,spinner:c.querySelector("i"),data:{bbcode:this.textarea.value,preview_mode:this.element.dataset.previewMode},success:function(c){e.elements.preview||(e.elements.preview=fQuery.createFromHtml('<div class="bbcode bbcode-preview"></div>'),fQuery.insertAfter(e.textarea,e.elements.preview),fQuery.insertAfter(e.textarea,fQuery.createFromHtml('\n                        <div class="bbcode-preview-close" data-click="closePreview">Close Preview</div>\n                    ')));e.elements.preview.innerHTML=
c.content;e.element.setAttribute("data-previewing",!0)}})};BBCodeEditorController.prototype.closePreview=function(){this.element.removeAttribute("data-previewing",!0);this.layoutToolbar(!0)};BBCodeEditorController.prototype.toggleFullscreen=function(c){this.element.hasAttribute("data-fullscreen")?this.exitFullscreen():(this.element.setAttribute("data-fullscreen","true"),this.focus(),document.body.style.overflow="hidden",this.layoutToolbar(!0))};
BBCodeEditorController.prototype.exitFullscreen=function(){this.element.hasAttribute("data-fullscreen")&&(this.element.removeAttribute("data-fullscreen"),this.focus(),document.body.style.overflow=null,this.layoutToolbar(!0))};App.AddController("bbcode-editor",BBCodeEditorController);
function ConfirmPrompt(c,d){var e=new PopUpMenu("","<i class='fa fa-question-circle'></i> Comfirm Action");e.SetCloseOnHoverOut(!1);e.SetFixed(!0);e.SetContent("\n        <center style='padding:10px;'>"+c+"</center>\n        <div class=\"drop-down-pop-up-footer-right\">\n            <center>\n                <form id='confirm_prompt'>\n                    <button class='styled_button' type=\"submit\">Confirm</button>\n                    <button data-cancel-button class='styled_button styled_button_red' type=\"button\">Cancel</button>\n                </form>\n            </center>\n        </div>");e.SetCloseOnHoverOut(!1);
e.SetWidth(350);e.Show();e.element.querySelector("#confirm_prompt").addEventListener("submit",function(c){c.preventDefault();d();e.Close()});e.element.querySelector("#confirm_prompt [data-cancel-button").addEventListener("click",function(c){c.preventDefault();c.stopPropagation();e.Close()})}
function StyledAlert(c,d,e){e=void 0===e?[]:e;var f=new PopUpMenu("","<i class='fa fa-question-circle'></i> "+(void 0===d?"":d));e.align||(e.align="center");c="<div style='padding:18px; text-align:"+e.align+";'>"+c+"</div>";f.SetCloseOnHoverOut(!1);f.SetFixed(!0);f.SetContent(c);f.SetFooter("<center><button data-alert-button class='styled_button' style='padding: 5px 40px;''>Ok</button></center>");f.SetCloseOnHoverOut(!1);f.SetWidth(350);f.Show();f.element.querySelector("[data-alert-button]").addEventListener("click",
function(c){c.preventDefault();c.stopPropagation();f.Close()})};var dash_sayings="Do you want to come inside?;Are you a SPY?;It needs to be about 20% coo...*vomit*;I'm...an egghead!;Awesome!;Now careful [CENSORED];Excuse me!;Never fear, your friendly neighbourhood Dash is here!;And that's why you would never qualify to be my pet;Dun dun duuuun;My life is ruined!;I lost...;Best day ever!;LOUDER!;Pinkie Pie...you are SO random;Time to take out the adorable trash;Yes, it's all true;10...seconds...flat;I'd rather read Daring Do;'I love you, daddy'. Who'd write such trash?".split(";"),
InteractivePony=function(){var c=this;this.base_url="//static.fimfiction.net/images/interactive_pony/dash/";this.sprite="dashing_right.gif";this.dom_element=fQuery.createFromHtml("<div class='interactive_pony'><img class='interactive_pony' src='"+this.base_url+this.sprite+"' /><div class='speech_container'><div class='speech'>Do you want to come inside?</div></div></div>");document.body.appendChild(this.dom_element);this.x=0;this.y=175;this.max_speed=300;this.hspeed=0;this.acceleration=17;this.friction=
.93;this.facing="right";this.on_ground=!0;this.sleep_timer=0;this.text="";this.target_y=this.target_x=this.next_text_timer=this.text_counter=0;this.state="default";this.dom_element.addEventListener("click",function(){c.Clicked()});document.body.addEventListener("mousemove",function(d){var e=d.target;if(!fQuery.isOrChildOf(e,c.dom_element)){do if(50<e.getBoundingClientRect().height){c.UpdateMouse(d.pageX,d.pageY,e);break}while(e=e.parentNode)}});this.Say(dash_sayings[Math.floor(Math.random()*dash_sayings.length)])};
InteractivePony.prototype.Say=function(c){this.text=c;this.next_text_timer=this.text_counter=0};InteractivePony.prototype.Clicked=function(){"sleeping"==this.state&&(this.state="default")};
InteractivePony.prototype.Update=function(c){if("moving_container"==this.state||"default"==this.state)this.target_x>this.x+30&&(this.hspeed+=this.acceleration),this.target_x<this.x-30&&(this.hspeed-=this.acceleration),this.hspeed>this.max_speed&&(this.hspeed=this.max_speed),this.hspeed<-this.max_speed&&(this.hspeed=-this.max_speed),this.hspeed*=this.friction,2<this.hspeed&&(this.facing="right"),-2>this.hspeed&&(this.facing="left"),this.x+=this.hspeed*c;"default"==this.state&&(1>Math.abs(this.hspeed)?
(this.sleep_timer+=c,10<this.sleep_timer&&(this.state="sleeping")):this.sleep_timer=0);if("moving_container"==this.state){var d=this.container.getBoundingClientRect(),e=fQuery.scrollTop()+d.top,f=3*(e-this.y);150<f&&(f=150);-150>f&&(f=-150);this.y+=f*c;1>Math.abs(e-this.y)&&this.x>d.left&&this.x<d.right&&(this.y=e,this.state="default",this.on_ground=!0)}"sleeping"==this.state&&(this.sleep_timer=0);this.text_counter+=30*c;this.text_counter>this.text.length&&(this.next_text_timer+=c);5<this.next_text_timer&&
this.FadeOutText();10<this.next_text_timer&&"sleeping"!=this.state?this.Say(dash_sayings[Math.floor(Math.random()*dash_sayings.length)]):10<this.next_text_timer&&this.Say("zzz...")};InteractivePony.prototype.FadeOutText=function(){this.dom_element.querySelector(".speech")};
InteractivePony.prototype.UpdateMouse=function(c,d,e){this.target_x=c;"sleeping"==this.state?50<Math.abs(this.target_x-this.x)&&(this.state="default"):this.container!=e&&(this.container=e,this.state="moving_container",this.on_ground=!1)};InteractivePony.prototype.SetSprite=function(c){this.sprite!=c&&(this.sprite=c,this.dom_element.querySelector("img.interactive_pony").src=this.base_url+c)};
InteractivePony.prototype.Render=function(){"sleeping"==this.state?this.SetSprite("cloud_sleep_"+this.facing+".gif"):this.on_ground?200<this.hspeed?this.SetSprite("dashing_right.gif"):15<this.hspeed?this.SetSprite("trotcycle_rainbow_right.gif"):-200>this.hspeed?this.SetSprite("dashing_left.gif"):-15>this.hspeed?this.SetSprite("trotcycle_rainbow_left.gif"):this.SetSprite("stand_rainbow_"+this.facing+".gif"):this.SetSprite("fly_rainbow_"+this.facing+".gif");var c=parseInt(this.x-this.dom_element.getBoundingClientRect().width/
2,10)+"px",d=parseInt(this.y-this.dom_element.getBoundingClientRect().height,10)+"px";this.dom_element.style.top!=d&&(this.dom_element.style.top=d);this.dom_element.style.left!=c&&(this.dom_element.style.left=c);this.dom_element.querySelector(".speech").textContent=this.text.substr(0,parseInt(this.text_counter,10))};
function InitiateInteractivePony(){var c=new InteractivePony;window.addEventListener("blur",function(){});window.addEventListener("focus",function(){});fQuery.animationFrame(function(d){c.Update(d);c.Render()},.1)}fQuery.ready(function(){1==LocalStorageGet("show_interactive_pony",0)&&InitiateInteractivePony()});var Group=function(){};Group.showAddToGroup=function(c){var d=new PopUpMenu("","<i class='fa fa-book'></i> Add To Groups");d.SetWidth(450);d.SetCloseOnHoverOut(!1);d.SetCloseOnLinkPressed(!1);d.SetContent("<div style='text-align:center;'><i class='fa fa-spin fa-spinner' style='font-size:50px; margin:20px; color:#777;'></i></div>");d.LoadContent("/ajax/groups/list/add-story?story="+c,!0);d.Show()};var window_focused=!0,last_update_interval=60,time_since_update=0,max_interval=600,total_elapsed_time=0,num_notifications=0,flash_title=!1,title_cache="",flash_state=!1,popup_timer=0,beep_enabled=!1,debug=!1,event_source=null,event_source_interval=null,popup_interval=null,worker=null;
function ShowNotification(c,d){"undefined"===typeof d&&(d=(new Date).getTime());if(!c.nsfw||"true"==getCookie("view_mature"))if(console.log("Showing notification: "+d),"granted"==DesktopNotificationStatus()){var e=LocalStorageGet("latest_message_id",-1);if(d!=e){LocalStorageSet("latest_message_id",d);var f=new Notification(c.title,{icon:"undefined"!==typeof c.icon?c.icon:"http://static.fimfiction.net/images/notifications/story.png",body:c.text,tag:d});"show"in f&&f.show();if("link"in c){var g=c.link,
k=window;f.onclick=function(){k&&!k.closed?(k.location=g,k.focus()):window.open(g)}}setTimeout(function(){f.close()},2E4);beep_enabled&&document.getElementById("notification_beep").play()}setTimeout(function(){LocalStorageSet("latest_message_id",-1)},1E3)}else e=LocalStorageGet("latest_message_id",-1),d>e&&(LocalStorageSet("latest_message_id",d),beep_enabled&&document.getElementById("notification_beep").play()),$("#notification_popup .notification_title").text(c.title),$("#notification_popup .notification_title").attr("href",
c.link),$("#notification_popup .notification_body").text(c.text),$("#notification_popup .notification_image").attr("src","http://static.fimfiction.net/images/notifications/story.png"),$("#notification_popup").fadeIn(),popup_timer=10,null==popup_interval&&(popup_interval=setInterval(function(){UpdateNotificationsPopup()},1E3))}
function StartNotificationsWorker(){worker=new SharedWorker("/workers/notifications_worker.js");worker.port.addEventListener("message",function(c){if("ping"===c.data)worker.port.postMessage(logged_in_user.id);else{if("notification"==c.data.message){var d=JSON.parse(c.data.data);ShowNotification(d,d.identifier);console.log("Updating counts: "+c.data.counts);SetNotificationCount(c.data.counts)}"private_message"==c.data.message&&(d=JSON.parse(c.data.data),ShowNotification(d,c.data.event_id));"counts"==
c.data.message&&(console.log("Updating counts: "+c.data.data),SetNotificationCount(c.data.data))}},!1);worker.port.start();worker.port.postMessage(logged_in_user.id)}
function StartNotificationsEventSource(){var c=function(){var c=LocalStorageGet("last_event_source_ping",0);null!=event_source?LocalStorageSet("last_event_source_ping",GetTime()):c<GetTime()-4E3&&(LocalStorageSet("last_event_source_ping",GetTime()),event_source=new EventSource("/notifications/"+logged_in_user.id+"/stream"),event_source.addEventListener("message",function(c){c=JSON.parse(c.data);ShowNotification(c,c.identifier)},!1),event_source.addEventListener("private_message",function(c){c=JSON.parse(c.data);
ShowNotification(c,(new Date).getTime())},!1),event_source.addEventListener("counts",function(c){SetNotificationCount(c.data);LocalStorageSet("num_notifications",c.data)},!1),event_source.addEventListener("logout",function(c){event_source.close();clearInterval(event_source_interval)},!1))};event_source_interval=setInterval(c,2E3);c()}
function StartNotificationsPoll(){var c=!1;LocalStorageGet("last_poll",0)<GetTime()-6E4&&(LocalStorageSet("last_poll",GetTime()),c=!0);poll_interval=setInterval(function(){if(c||LocalStorageGet("last_poll",0)<GetTime()-6E4)LocalStorageSet("last_poll",GetTime()),c=!0,$.get("/notifications/"+logged_in_user.id+"/poll").done(function(c){SetNotificationCount(c);LocalStorageSet("num_notifications",c)}).fail(function(){clearInterval(poll_interval)})},3E4)}
function AttachNotificationsLocalStorage(){var c=function(c){"num_notifications"==c.key?SetNotificationCount(c.newValue):"reset_title"==c.key&&(document.title=title_cache)};window.addEventListener?window.addEventListener("storage",c,!1):window.attachEvent("onstorage",c)}
function StartNotifications(){if("function"===typeof SharedWorker)StartNotificationsWorker();else{try{window.localStorage.setItem("storage_test",!0),window.localStorage.removeItem("storage_test")}catch(c){return}"function"===typeof EventSource?StartNotificationsEventSource():StartNotificationsPoll();AttachNotificationsLocalStorage()}}function GetTime(){return(new Date).getTime()}
function SetNotificationCount(c,d){var e=c.split(" ");c=e[0];d=e[1];var e=e[2],f=parseInt(c,10)+parseInt(d,10)+parseInt(e,10),g=f>num_notifications;num_notifications=f;!window_focused&&g&&(flash_title=!0,document.title="("+num_notifications+") "+title_cache);0==d&&0==c?($("#num_notifications").parent().removeClass("new"),document.title=title_cache):$("#num_notifications").parent().addClass("new");$("#num_social_notifications").text(c);0==c?$("#num_social_notifications").parent().removeClass("new"):
$("#num_social_notifications").parent().addClass("new");$("#num_meta_notifications").text(d);0==d?$("#num_meta_notifications").parent().removeClass("new"):$("#num_meta_notifications").parent().addClass("new");$("#num_content_notifications").text(e);0==e?$("#num_content_notifications").parent().removeClass("new"):$("#num_content_notifications").parent().addClass("new");$("#num_notifications").text(parseInt(d)+parseInt(c))}
var Notifications=function(){this.num_meta_notifications=this.num_social_notifications=this.num_content_notifications=0;this.onCountsUpdated=new EventBus};Notifications.prototype.setContentNotifications=function(c){this.num_content_notifications=c;this.updateNotificationsDisplay()};Notifications.prototype.setMetaNotifications=function(c){this.num_social_notifications=c;this.updateNotificationsDisplay()};Notifications.prototype.setSocialNotifications=function(c){this.num_meta_notifications=c;this.updateNotificationsDisplay()};
Notifications.prototype.updateNotificationsDisplay=function(){this.onCountsUpdated.fire(this.num_content_notifications,this.num_meta_notifications,this.num_social_notifications)};var notifications=new Notifications;function InitialiseNotificationUpdater(c,d,e){num_notifications=c;title_cache=d;beep_enabled=e}function UpdateNotificationsPopup(){flash_state=!flash_state;popup_timer--;0==popup_timer&&($("#notification_popup").fadeOut(),clearInterval(popup_interval))}
function DesktopNotificationStatus(){if("function"!==typeof Notification)return null;if("permission"in Notification)return Notification.permission;if(window.webkitNotifications&&window.webkitNotifications.checkPermission)switch(window.webkitNotifications.checkPermission()){case 0:return"granted";case 1:return"default";case 2:return"denied"}return null};AjaxRequest.BindForm(".form-submit-story",function(c){window.setTimeout("location.reload()",0)});fQuery.addScopedEventListener(document,".button-set-featured-groups","click",function(c){c.preventDefault();c=this.dataset.story;var d=new PopUpMenu("","<i class='fa fa-group'></i> Set Featured Groups");d.LoadContent("/ajax/groups/list/featured?story="+c,!0);d.SetCloseOnHoverOut(!1);d.SetWidth(400);d.Show()});
(function(){fQuery.ready(function(c){c=document.querySelectorAll(".story-description");for(var d=0;d<c.length;d++){var e=c[d];500<e.offsetHeight&&(e.style.maxHeight="360px",e.nextElementSibling.classList.remove("hidden"))}})})();function hsltorgb(c,d,e){if(0==d)return rgbtohex(255*e,255*e,255*e);d*=1-Math.abs(2*e-1);c/=60;var f=d*(1-Math.abs(c%2-1));if(0<=c&&1>c){var g=d;var k=f;var l=0}else 1<=c&&2>c?(g=f,k=d,l=0):2<=c&&3>c?(g=0,k=d,l=f):3<=c&&4>c?(g=0,k=f,l=d):4<=c&&5>c?(g=f,k=0,l=d):5<=c&&6>c&&(g=d,k=0,l=f);e-=d/2;g+=e;k+=e;l+=e;return rgbtohex(255*(0>g?0:1<g?1:g),255*(0>k?0:1<k?1:k),255*(0>l?0:1<l?1:l))}
function rgbtohex(c,d,e){c=Math.floor(c).toString(16);d=Math.floor(d).toString(16);e=Math.floor(e).toString(16);1==c.length&&(c="0"+c);1==d.length&&(d="0"+d);1==e.length&&(e="0"+e);return"#"+c+d+e};var fimf_chart_theme={AmChart:{fontFamily:"Open Sans"},AmSlicedChart:{colors:[],outlineAlpha:1,outlineThickness:.25,outlineColor:"#000",groupedColor:"#888"},AmPieChart:{innerRadius:"50%"},AmGraph:{columnWidth:.7},AmBalloon:{fillAlpha:1,shadowAlpha:0,borderThickness:1,cornerRadius:3,animationDuration:0,fontSize:14},ValueAxesSettings:{usePrefixes:!0},CategoryAxesSettings:{gridAlpha:0,groupToPeriods:"DD 2DD WW 2WW MM 3MM 6MM YYYY".split(" "),axisAlpha:1,tickLength:5},ChartScrollbarSettings:{autoGridCount:!1,
gridCount:0,dragIcon:"dragIconRectBig",dragIconWidth:24,dragIconHight:32,height:32,updateOnReleaseOnly:!1,backgroundColor:"#eee",selectedBackgroundColor:"#777",selectedGraphFillColor:"#ccc",color:"#444",fontSize:0,usePeriod:"WW"},ChartScrollbar:{},ChartCursorSettings:{valueBalloonsEnabled:!0,fullWidth:!0,cursorAlpha:.1,valueLineAlpha:.5,cursorColor:"#000000"},StockPanel:{fontFamily:"Open Sans",showCategoryAxis:!0},StockEventsSettings:{backgroundColor:"#fff",borderColor:"#68a7e5",type:"text"}};
(function(){for(var c=0;360>c;c+=40)fimf_chart_theme.AmSlicedChart.colors.push(hsltorgb(c,1,.47));for(c=20;360>c;c+=40)fimf_chart_theme.AmSlicedChart.colors.push(hsltorgb(c,1,.47))})();var fimf_dual_axis_chart_theme=JSON.parse(JSON.stringify(fimf_chart_theme));fimf_dual_axis_chart_theme.ValueAxesSettings.inside=!0;fimf_dual_axis_chart_theme.ValueAxesSettings.integersOnly=!0;fimf_dual_axis_chart_theme.PanelsSettings={};fimf_dual_axis_chart_theme.PanelsSettings.marginLeft=0;
fimf_dual_axis_chart_theme.PanelsSettings.marginRight=0;var RegisterController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(RegisterController,Controller);
RegisterController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);c=jstz.determine();this.inputs.timezone.value=c.name();this.inputs.name.addEventListener("blur",function(c){var e=c.target;new AjaxRequest({url:"/ajax/users/validate/username",method:"POST",data:{username:e.value},success:function(c){c.ok?d.elements.username_taken.classList.add("hidden"):(d.elements.username_taken.classList.remove("hidden"),e.setCustomValidity("Username has already been used"))}})});this.inputs.email.addEventListener("blur",
function(c){var e=c.target;new AjaxRequest({url:"/ajax/users/validate/email",method:"POST",data:{email:e.value},success:function(c){c.ok?d.elements.email_taken.classList.add("hidden"):(d.elements.email_taken.classList.remove("hidden"),e.setCustomValidity("Email has already been used"))}})})};RegisterController.prototype.inputName=function(c,d,e){e.setCustomValidity("")};RegisterController.prototype.inputEmail=function(c,d,e){e.setCustomValidity("")};App.AddController("register",RegisterController);var FrontpageController=function(){Controller.call(this);this.featuredStory=Math.floor(10*Math.random())+1;this.lastFeaturedStory=null;this.selectFeaturedStory(this.featuredStory)};$jscomp.inherits(FrontpageController,Controller);
FrontpageController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.newStories=document.querySelector("new_stories");this.latestStories=document.querySelector("latest_stories");this.nextTimer=setInterval(function(){d.nextFeaturedStory()},1E4);fQuery.click(c.querySelectorAll(".featured_box ul li"),function(c){c=c.target.getAttribute("data-story");d.selectFeaturedStory(c);clearInterval(d.nextTimer)})};
FrontpageController.prototype.nextFeaturedStory=function(){var c=this.featuredStory+1;10<c&&(c=1);this.selectFeaturedStory(c)};
FrontpageController.prototype.selectFeaturedStory=function(c){700>window.innerWidth||(this.featuredStory=c,this.lastFeaturedStory!=this.featuredStory&&(this.lastFeaturedStory=this.featuredStory,fQuery.removeClass(document.querySelectorAll(".featured_box ul li"),"selected"),document.getElementById("featured_story_link_"+c).classList.add("selected"),c=document.getElementById("featured_story_"+c),document.querySelector(".featured_box .right").appendChild(c)))};App.AddController("frontpage",FrontpageController);var CommentListController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(CommentListController,Controller);
CommentListController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.container=c;this.current_page=parseInt(c.getAttribute("data-current-page"),10);this.num_pages=parseInt(c.getAttribute("data-num-pages"),10);this.comment_list=c.querySelector(".comment_list");this.type=this.comment_list.getAttribute("data-type");this.item=parseInt(this.comment_list.getAttribute("data-item"),10);this.order=this.comment_list.getAttribute("data-order");this.hoverTimeout=this.quote_container=
null;this.updatePagination();this.setupQuotes();for(var e=this,f=c.querySelectorAll(".page_list .previous"),g=0;g<f.length;g++)f[g].addEventListener("click",function(){e.previous()});c=c.querySelectorAll(".page_list .next");for(g=0;g<c.length;g++)c[g].addEventListener("click",function(){e.next()});AjaxRequest.BindForm(".form-edit-comment",function(c,e,f){fQuery.closestParent(f,".comment").querySelector(".comment_data").innerHTML=c.content;d.toggleEditComment(f)},this.element);AddHashCallback("page",
function(c){d.goToPage(c)});AddHashCallback("comment",function(c){d.goToComment(c)});fQuery.addScopedEventListener(this.element,".comment_quote_link","click",function(c){c.preventDefault();e.expandQuote(this)})};CommentListController.prototype.previous=function(){1<this.current_page&&this.goToPage(this.current_page-1)};CommentListController.prototype.next=function(){this.current_page<this.num_pages&&this.goToPage(this.current_page+1)};
CommentListController.prototype.updatePagination=function(){for(var c=$jscomp.makeIterator(this.container.querySelectorAll(".page_list .page")),d=c.next();!d.done;d=c.next())fQuery.removeElement(d.value);for(var e=this,c=function(c){c=this.getAttribute("data-page");e.goToPage(c)},d=this.element.querySelectorAll(".page_list"),d=$jscomp.makeIterator(d),f=d.next();!f.done;f=d.next()){var g=f.value;g.querySelector(".previous");f=g.querySelector(".next").parentNode;if(2>this.num_pages){g.classList.add("hidden");
break}else g.classList.remove("hidden");for(var g=400<window.innerWidth?4:1,k=400<window.innerWidth?4:1,l=1;l<=this.num_pages;l++)if(l<1+k||l>this.num_pages-k||l>this.current_page-(g+1)&&l<this.current_page+(g+1)){var m=document.createElement("li");m.className="page";var n=document.createElement("a");n.textContent=l;n.setAttribute("href","#page/"+l);n.setAttribute("data-page",l);n.addEventListener("click",c);m.appendChild(n);this.current_page==l&&m.classList.add("selected");f.parentNode.insertBefore(m,
f)}}};CommentListController.prototype.updateContent=function(c){this.comment_list.innerHTML=c;App.BindControllers(this.comment_list)};CommentListController.prototype.refresh=function(){this.goToPage(this.current_page)};CommentListController.prototype.setOrder=function(c){this.order=c.getAttribute("data-order");this.goToPage(1)};
CommentListController.prototype.goToPage=function(c){var d=this;return new Promise(function(e,f){c=parseInt(c,10);c!=d.current_page&&(f=d.container.getBoundingClientRect().top,0>f&&fQuery.scrollTop(f));d.comment_list.classList.add("loading");document.body.classList.add("loading");d.current_page=c;d.updatePagination();new AjaxRequest({url:"/ajax/comments/"+d.type,method:"GET",data:{item_id:d.item,page:c,order:d.order},success:function(f){for(var g=$jscomp.makeIterator(d.element.querySelectorAll(".comment_order")),
l=g.next();!l.done;l=g.next())l=l.value,f.order==l.getAttribute("data-order")?l.parentNode.classList.add("selected"):l.parentNode.classList.remove("selected");d.current_page=c;d.num_pages=f.num_pages;d.updatePagination();d.updateContent(f.content);d.endShowQuote();d.comment_list.classList.remove("loading");document.body.classList.remove("loading");App.DispatchEvent(document,"loadVisibleImages");d.setupQuotes();e(c);l=$jscomp.makeIterator(d.element.querySelectorAll(".start-index"));for(g=l.next();!g.done;g=
l.next())g.value.textContent=f.start_index;l=$jscomp.makeIterator(d.element.querySelectorAll(".end-index"));for(g=l.next();!g.done;g=l.next())g.value.textContent=f.end_index;l=$jscomp.makeIterator(d.element.querySelectorAll(".num-comments"));for(g=l.next();!g.done;g=l.next())g.value.textContent=f.num_comments}})})};CommentListController.prototype.getComments=function(){return this.comment_list.querySelectorAll(".comment")};
CommentListController.prototype.goToComment=function(c){var d=this;(new Promise(function(e,f){d.comment_list.querySelector("#comment_"+c)?e(d.current_page):new AjaxRequest({url:"/ajax/comments/page",method:"GET",data:{type:d.type,item:d.item,comment:c},success:function(c){0<c.page&&e(c.page)}})})).then(function(c){if(c!=d.current_page)return d.goToPage(c)}).then(function(e){e=d.comment_list.querySelector("#comment_"+c);fQuery.removeClass(d.getComments(),"comment_selected");e.classList.add("comment_selected");
fQuery.scrollTop(e.getBoundingClientRect().top-.2*window.innerHeight,!1,.3)})};
CommentListController.prototype.beginShowQuote=function(c){var d=this;this.endShowQuote();var e=c.getAttribute("data-comment_id");document.getElementById("comment_"+e);null==this.quote_container&&(this.quote_container=document.createElement("div"),this.quote_container.className="quote_container",document.body.appendChild(this.quote_container));var f=!0;this.getComment(e).then(function(e){if(f){for(d.quote_container.classList.remove("hidden");d.quote_container.firstChild;)d.quote_container.removeChild(d.quote_container.firstChild);d.quote_container.appendChild(e.cloneNode(!0));
d.quote_container.style.top=c.getBoundingClientRect().top+fQuery.scrollTop()+20+"px";e=fQuery.closestParent(c,".comment");d.quote_container.style.left=e.getBoundingClientRect().left-20+"px";d.quote_container.style.width=e.getBoundingClientRect().width+40+"px";App.DispatchEvent(d.quote_container,"loadVisibleImages")}});return function(){f=!1}};CommentListController.prototype.endShowQuote=function(){clearTimeout(this.hoverTimeout);null!=this.quote_container&&this.quote_container.classList.add("hidden")};
CommentListController.prototype.setupQuotes=function(){if(!is_mobile){var c=this;clearTimeout(this.hoverTimeout);for(var d=$jscomp.makeIterator(this.container.querySelectorAll(".comment_quote_link")),e=d.next();!e.done;e=d.next()){var f=e.value,g=f.getAttribute("data-comment_id"),k=document.getElementById("comment_"+g),l=fQuery.closestParent(f,".comment"),e=l.getAttribute("data-comment_id");null!=k&&(f.textContent=k.getAttribute("data-author"),f=document.getElementById("comment_callbacks_"+g),null!=
f&&(g=document.createElement("a"),g.className="comment_quote_link comment_callback",g.style.fontSize="0.9em",g.style.fontWeight="bold",g.setAttribute("href","#comment/"+e),l=document.createTextNode(l.getAttribute("data-author")),g.appendChild(l),g.setAttribute("data-comment_id",e),f.appendChild(g)))}var m=null;fQuery.addScopedEventListener(this.container,".comment_quote_link","mouseover",function(d){clearTimeout(c.hoverTimeout);var e=this;c.hoverTimeout=setTimeout(function(){m=c.beginShowQuote(e)},
150)});fQuery.addScopedEventListener(this.container,".comment_quote_link","mouseout",function(d){null!=m&&(m(),m=null);clearTimeout(c.hoverTimeout);c.endShowQuote()})}};
CommentListController.prototype.getComment=function(c){var d=this,e=document.getElementById("comment_"+c);return new Promise(function(f,g){null!=e?f(e):new AjaxRequest({url:"/ajax/comments/"+d.type+"/"+c,method:"GET",success:function(c){var d=document.getElementById("hidden_comments");d||(d=document.createElement("div"),d.id="hidden_comments",d.style.display="none",document.body.appendChild(d));var e=document.createElement("div");e.innerHTML=c.content;d.appendChild(e);f(e.querySelector(".comment"))}})})};
CommentListController.prototype.expandQuote=function(c){var d=c.getAttribute("data-comment_id");document.getElementById("comment_"+d);null!=this.quote_container&&this.endShowQuote();var e=fQuery.closestParent(c,".comment").querySelector(".comment[data-comment_id='"+d+"']");null!=e?fQuery.removeElement(e):this.getComment(d).then(function(d){d=d.cloneNode(!0);d.setAttribute("id","");d.classList.add("inline-quote");fQuery.insertAfter(c,d)})};
CommentListController.prototype.toggleEditComment=function(c){c=fQuery.closestParent(c,".comment");var d=c.getAttribute("data-comment_id"),e=c.getAttribute("data-type"),f=c.querySelector(".comment-edit");f.classList.contains("hidden");c.querySelector(".comment_data").classList.toggle("hidden");f.classList.toggle("hidden");0==f.childNodes.length&&new AjaxRequest({url:"/ajax/comments/"+e+"/"+d+"/edit",method:"GET",signed:!1,success:function(c){f.innerHTML=c.content;f.querySelector("form")}})};
CommentListController.prototype.deleteComment=function(c,d){var e=this,f=fQuery.closestParent(c,".comment"),g=f.getAttribute("data-comment_id");d.preventDefault();ConfirmPrompt("Are you sure you want to delete this comment?",function(){new AjaxRequest({url:"/ajax/comments/"+e.type+"/"+g,method:"DELETE",signed:!0,spinner:c.querySelector("i"),success:function(c){fQuery.removeElement(f)}})})};
CommentListController.prototype.replyToComment=function(c,d){var e=fQuery.closestParent(c,".comment").getAttribute("data-comment_id");c=App.GetControllerFromElement(document.querySelector("#add_comment_box .bbcode-editor"));e=">>"+e+"\n";c.insertText(""==c.getText()?e:"\n"+e,!d.ctrlKey&&!d.shiftKey);d.preventDefault();d.ctrlKey||d.shiftKey||fQuery.scrollTop(document.getElementById("add_comment_box").getBoundingClientRect().top)};
CommentListController.prototype.appendNewComment=function(c){"ASC"==this.order?this.comment_list.appendChild(c):fQuery.prepend(this.comment_list,c);fQuery.scrollTop(c.getBoundingClientRect().top)};
CommentListController.prototype.toggleLikeDislike=function(c,d){var e=c.parentNode,f="true"==e.dataset.liked,g="true"==e.dataset.disliked,k=e.querySelector(".like-text"),l=e.querySelector(".dislike-text"),m="POST";d&&f&&(m="DELETE");!d&&g&&(m="DELETE");new AjaxRequest({url:"/ajax/comments/"+this.type+"/"+c.dataset.comment+(d?"/like":"/dislike"),signed:!0,method:m,success:function(c){e.dataset.liked=c.liked?"true":"false";e.dataset.disliked=c.disliked?"true":"false";k.textContent=0==c.likes?"":c.likes;
l.textContent=0==c.dislikes?"":c.dislikes}})};CommentListController.prototype.toggleLike=function(c,d){this.toggleLikeDislike(c,!0)};CommentListController.prototype.toggleDislike=function(c,d){this.toggleLikeDislike(c,!1)};
CommentListController.prototype.preview=function(c,d){var e=this;new AjaxRequest({method:"POST",url:"/ajax/comments/preview",data:{comment:this.findElement("#comment_comment").value},success:function(c){var d=e.findElement("#comment_preview");d.innerHTML=c.comment;d.classList.remove("hidden");App.DispatchEvent(d,"loadVisibleImages")}})};
CommentListController.prototype.showHiddenComment=function(c){c=fQuery.closestParent(c,".comment");c.querySelector(".hidden").classList.remove("hidden");c.querySelector(".message").classList.add("hidden");App.DispatchEvent(c,"loadVisibleImages")};App.AddController("comment-list",CommentListController);(function(){function c(){if(document.querySelector(".content").contains(this)){clearTimeout(f);f=null;var c=this,d=this.getAttribute("href");if(d&&!c.hasAttribute("data-no-user-popup")&&(d=/^\/user\/([0-9]+)\/[^\/]*$/.exec(d))){var e=d[1];f=setTimeout(function(){if(e in g)g[e].CancelRemove(),g[e].Load(e),g[e].Show(c);else{var d=new k(c);d.Load(e);g[e]=d}},100)}}}function d(){var c=this.getAttribute("href");c&&!this.hasAttribute("data-no-user-popup")&&(c=/^\/user\/([0-9]+)\/[^\/]*$/.exec(c))&&(c=c[1],
c in g&&(g[c].CancelLoad(),g[c].TriggerRemove()),clearTimeout(f),f=null)}function e(e){e.addEventListener("mouseenter",c);e.addEventListener("mouseleave",d)}var f=null,g={},k=function(c){var d=this;this.dimmer=this.remove_timeout=this.ajaxRequest=null;this.link=c;this.loaded=this.showing=!1;c=document.createElement("div");c.className="info-card-container";var e=document.createElement("div");e.className="info-card";c.appendChild(e);this.infocard_container=c;this.infocard=e;d=this;this.infocard_container.addEventListener("mouseleave",
function(){d.TriggerRemove()});this.infocard_container.addEventListener("mouseenter",function(){d.CancelRemove()});document.body.appendChild(c)};k.prototype.Load=function(c){var d=this;this.loaded||(this.ajaxRequest=new AjaxRequest({url:"/ajax/users/"+c+"/infocard",method:"POST",success:function(c){d.infocard.innerHTML=c.content;d.loaded=!0;d.Show(d.link);d.ajaxRequest=null;App.BindAll(d.infocard_container)},fail:function(){d.ajaxRequest=null}},!1))};k.prototype.CancelLoad=function(){null!=this.ajaxRequest&&
this.ajaxRequest.cancel()};k.prototype.Show=function(c){this.CancelRemove();if(!this.showing&&this.loaded){this.showing=!0;var d=this.infocard_container,e=this.infocard.querySelector(".user-card");d.classList.remove("hidden");e.classList.remove("hiding");e.classList.add("shrunk");forceRelayout(e);e.classList.remove("shrunk");this.infocard_container.style.left=c.getBoundingClientRect().left+c.getBoundingClientRect().width-5+"px";this.infocard_container.style.top=c.getBoundingClientRect().top+fQuery.scrollTop()-
60+"px";forceRelayout(e);App.DispatchEvent(document,"loadVisibleImages")}};k.prototype.TriggerRemove=function(){clearTimeout(this.remove_timeout);var c=this,d=this.infocard.querySelector(".user-card");null!=d?(this.removing_timeout=setTimeout(function(){d.classList.add("hiding")},150),this.remove_timeout=setTimeout(function(){c.infocard_container.classList.add("hidden");c.showing=!1},450)):c.showing=!1};k.prototype.CancelRemove=function(){clearTimeout(this.remove_timeout);clearTimeout(this.removing_timeout);
var c=this.infocard.querySelector(".user-card");null!=c&&c.classList.remove("hiding")};App.AddBinder(function(c){Array.prototype.forEach.call(c.querySelectorAll("a[href*='/user/']"),e)})})();var PopUpMenu=function(c,d){var e=this;this.element=fQuery.createFromHtml('<div id="'+c+'" class="drop-down-pop-up-container"><div class="drop-down-pop-up"><h1>'+d+'<a class="close_button"></a></h1><div class="drop-down-pop-up-content"></div></div></div>');this.h1=this.element.querySelector("h1");this.closeButton=this.element.querySelector(".close_button");this.content=this.element.querySelector(".drop-down-pop-up-content");this.onClose=new EventBus;var f=this;this.closeButton.addEventListener("click",
function(){e.Close()});this.h1.addEventListener("mousedown",function(c){e.closeButton.contains(c.target)||e.closeButton==c.target||e.Grab()});this.h1.addEventListener("touchstart",function(c){e.closeButton.contains(c.target)||e.closeButton==c.target||e.Grab(!0)});document.body.addEventListener("mouseup",function(c){f.Release()},!0);document.body.addEventListener("touchend",function(c){f.Release()},!0);fQuery.addScopedEventListener(this.element,"a","click",function(c){e.close_on_link_pressed&&c.target!=
e.closeButton&&e.Close()});this.dimmer_enabled=!0;this.close_on_link_pressed=!1;this.dimmer=null;this.close_on_hover_out=!1;this.deltay=this.deltax=null;this.h1.style.cursor="move";this.showing=this.grabbed=this.fixed=this.soft_close=!1};PopUpMenu.prototype.SetFixed=function(c){this.fixed=c};PopUpMenu.prototype.SetDimmerEnabled=function(c){this.dimmer_enabled=c};PopUpMenu.prototype.SetSoftClose=function(c){this.soft_close=c};
PopUpMenu.prototype.SetCloseOnLinkPressed=function(c){this.close_on_link_pressed=c};PopUpMenu.prototype.SetCloseOnHoverOut=function(c){this.close_on_hover_out=c};
PopUpMenu.prototype.Grab=function(c){var d=this;this.grabbed||((void 0===c?0:c)?(this.touchmove_handler=function(c){d.MouseMove(c.changedTouches[0].pageX,c.changedTouches[0].pageY)},document.body.addEventListener("touchmove",this.touchmove_handler)):(this.mousemove_handler=function(c){d.MouseMove(c.pageX,c.pageY)},document.body.addEventListener("mousemove",this.mousemove_handler)),document.body.classList.add("unselectable"),is_mobile&&document.body.classList.add("unscrollable"),this.grabbed=!0)};
PopUpMenu.prototype.Release=function(){this.grabbed&&(document.body.classList.remove("unscrollable"),document.body.classList.remove("unselectable"),document.body.removeEventListener("mousemove",this.mousemove_handler),document.body.removeEventListener("touchmove",this.touchmove_handler),this.deltay=this.deltax=null,this.grabbed=!1)};
PopUpMenu.prototype.MouseMove=function(c,d){this.fixed&&(c-=document.body.scrollLeft,d-=document.body.scrollTop);null==this.deltax&&(this.deltax=c-this.x,this.deltay=d-this.y);this.x=c-this.deltax;this.y=d-this.deltay;d=this.element.offsetHeight;var e=this.element.offsetWidth;this.fixed?(c=0,this.x=Math.max(c,Math.min(this.x,window.innerWidth-c-e)),this.y=Math.max(c,Math.min(this.y,window.innerHeight-c-d))):(c=0,this.x=Math.max(fQuery.scrollLeft()+c,Math.min(this.x,fQuery.scrollLeft()+(window.innerWidth-
c)-e)),this.y=Math.max(fQuery.scrollTop()+c,Math.min(this.y,fQuery.scrollTop()+(window.innerHeight-c)-d)));this.element.style.left=this.x+"px";this.element.style.top=this.y+"px"};
PopUpMenu.prototype.Close=function(){var c=this;this.showing=!1;this.Release();var d=/([0-9.]+)px/i.exec(this.element.style.top),e=parseFloat(d[1]);fQuery.animateProperty(function(d){c.element.style.top=e+150*d+"px";c.element.style.opacity=1-d;c.dimmer&&(c.dimmer.style.opacity=1-d)},0,1,.15).then(function(){null!=c.dimmer&&(fQuery.removeElement(c.dimmer),c.dimmer=null,PopUpMenu.z_index--);fQuery.removeElement(c.element);c.soft_close||document.removeEventListener("keyup",c.document_keyup_handler);
c.onClose.fire(c)})};
PopUpMenu.prototype.LoadContent=function(c,d){var e=this;this.SetContent("<div style='text-align:center;'><i class='fa fa-spin fa-spinner' style='font-size:50px; margin:20px; color:#777;'></i></div>");return new Promise(function(f,g){"undefined"!==typeof d&&d?new AjaxRequest({url:c,method:"GET",success:function(c){e.content.innerHTML=c.content;e.SetPosition();f(e);App.BindAll(document)},fail:function(c){ShowErrorWindow(c.error);g(e)}}):this.content.load(c,{},function(){e.SetPosition();f(e)})})};
PopUpMenu.prototype.SetContent=function(c){var d=this.element.offsetHeight;this.content.innerHTML=c;this.showing&&this.SetPosition(this.x,fQuery.scrollTop()+this.y-(this.element.offsetHeight-d)/2)};PopUpMenu.prototype.SetFooter=function(c){c=fQuery.createFromHtml("<div class='drop-down-pop-up-footer'>"+c+"</div>");this.content.appendChild(c)};PopUpMenu.prototype.SetWidth=function(c){c>window.innerWidth-20&&(c=window.innerWidth-20);this.element.querySelector(".drop-down-pop-up").style.width=c+"px"};
PopUpMenu.prototype.SetPosition=function(c,d){c=void 0===c?null:c;d=void 0===d?null:d;null===c&&(c=window.innerWidth/2-this.element.offsetWidth/2+fQuery.scrollLeft(),d=window.innerHeight/2-this.element.offsetHeight/2+fQuery.scrollTop());this.fixed&&(c-=fQuery.scrollLeft(),d-=fQuery.scrollTop());this.element.style.left=c+"px";this.element.style.top=d+"px";this.x=c;this.y=d};
PopUpMenu.prototype.ShowDimmer=function(){var c=this;this.dimmer_enabled&&null==this.dimmer&&(PopUpMenu.z_index++,this.dimmer=fQuery.createFromHtml("<div class='dimmer' style='z-index:"+PopUpMenu.z_index+";'></div>"),document.getElementById("dimmers").appendChild(this.dimmer),fQuery.animateProperty(function(d){c.dimmer&&(c.dimmer.style.opacity=1-d)},1,0,.15,Curves.EaseOut))};
PopUpMenu.prototype.Show=function(c,d){var e=this;this.showing=!0;document.body.appendChild(this.element);this.ShowDimmer();this.document_keyup_handler=this.document_keyup_handler||function(c){27==c.keyCode&&e.Close()};document.addEventListener("keyup",this.document_keyup_handler);this.element.style.position=this.fixed?"fixed":"absolute";this.element.style.zIndex=PopUpMenu.z_index;this.SetPosition(c,d);c=/([0-9.]+)px/i.exec(this.element.style.top);var f=parseFloat(c[1]);fQuery.animateProperty(function(c){e.element.style.top=
f-150*c+"px";e.element.style.opacity=1-c},1,0,.15,Curves.EaseOut);App.BindAll(this.element)};PopUpMenu.z_index=1E3;(function(){try{var c="undefined"!==typeof Intl&&"undefined"!==typeof Intl.Collator?Intl.Collator("generic",{sensitivity:"base"}):null}catch(g){console.log("Collator could not be initialized and wouldn't be used")}var d=[],e=[],f={get:function(f,k,l){var g=l&&c&&l.useCollator;l=f.length;var n=k.length;if(0===l)return n;if(0===n)return l;var p;for(p=0;p<n;++p)d[p]=p,e[p]=k.charCodeAt(p);d[n]=n;if(g)for(p=0;p<l;++p){var q=p+1;for(g=0;g<n;++g){k=q;q=0===c.compare(f.charAt(p),String.fromCharCode(e[g]));
q=d[g]+(q?0:1);var t=k+1;q>t&&(q=t);t=d[g+1]+1;q>t&&(q=t);d[g]=k}d[g]=q}else for(p=0;p<l;++p){q=p+1;for(g=0;g<n;++g)k=q,q=f.charCodeAt(p)===e[g],q=d[g]+(q?0:1),t=k+1,q>t&&(q=t),t=d[g+1]+1,q>t&&(q=t),d[g]=k;d[g]=q}return q}};"undefined"!==typeof define&&null!==define&&define.amd?define(function(){return f}):"undefined"!==typeof module&&null!==module&&"undefined"!==typeof exports&&module.exports===exports?module.exports=f:"undefined"!==typeof self&&"function"===typeof self.postMessage&&"function"===
typeof self.importScripts?self.Levenshtein=f:"undefined"!==typeof window&&null!==window&&(window.Levenshtein=f)})();var Search=function(){};Search.levenshteinDistance=function(c,d){return window.Levenshtein.get(c,d)};
Search.characterSearch=function(c,d,e){e=void 0===e?!1:e;d=d.toLowerCase();if(""==d)return c.map(function(c){return c.item});c=c.map(function(c){var e=0,f=-1,l=c.text;Array.isArray(l)||(l=[l]);for(var m=0;m<l.length;m++){for(var n=l[m].toLowerCase(),p=0,q=!1,t=0;t<d.length;t++){var u=n.indexOf(d.charAt(t),f+1);u<=f&&(p=0,q=!0);q||(p=0==u?2:" "==n.charAt(u-1)?p+.9:p+1/(u-f));f=u}e=Math.max(p,e)}return{item:c.item,score:e}});e||(c=c.filter(function(c){return 0<c.score}));c=c.sort(function(c,d){return d.score-
c.score});e||(c=c.map(function(c){return c.item}));return c};
Search.termSearch=function(c,d,e){e=void 0===e?!1:e;d=d.toLowerCase();if(""==d)return c.map(function(c){return c.item});var f=0;c=c.map(function(c){var e=0,g=c.text;Array.isArray(g)||(g=[g]);for(var m=0;m<g.length;m++){var n=0,p=g[m].toLowerCase().indexOf(d);-1<p&&(n=1/p);e=Math.max(n,e)}return{item:c.item,score:e,pos:f++}});e||(c=c.filter(function(c){return 0<c.score}));c=c.sort(function(c,d){return c.score==d.score?c.pos-d.pos:d.score-c.score});e||(c=c.map(function(c){return c.item}));return c};var AddStoryToGroupController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(AddStoryToGroupController,Controller);AddStoryToGroupController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.storyId=this.element.dataset.storyId;this.mode="groups";this.groups=null};
AddStoryToGroupController.prototype.addToFolder=function(c){c.classList.add("loading");(new AjaxRequest({url:"/ajax/groups/"+c.dataset.group+"/folders/"+c.dataset.folder+"/items",method:"POST",signed:!0,data:{story:this.storyId},success:function(d){c.classList.remove("unselected");c.classList.add("selected")}})).then(function(){c.classList.remove("loading")})};
AddStoryToGroupController.prototype.getList=function(){if("groups"==this.mode)return this.elements.groupList.querySelectorAll("li");if("folders"==this.mode)return this.elements.folderList.querySelectorAll("li")};
AddStoryToGroupController.prototype.search=function(c){if("groups"==this.mode){null==this.groups&&(this.groups=fQuery.nodesToArray(this.elements.groupList.querySelectorAll("li")));var d=Search.characterSearch(this.groups.map(function(c){return{item:c,text:c.querySelector("a[data-name]").dataset.name}}),c);fQuery.removeChildren(this.elements.groupList);for(var e=$jscomp.makeIterator(d),d=e.next();!d.done;d=e.next())this.elements.groupList.appendChild(d.value)}if("folders"==this.mode){d=Search.characterSearch(this.folders.map(function(c){return{item:c,
text:c.querySelector("a[data-name]").dataset.name}}),c);fQuery.removeChildren(this.elements.folderList);e=$jscomp.makeIterator(d);for(d=e.next();!d.done;d=e.next())this.elements.folderList.appendChild(d.value);fQuery.toggleClass(this.elements.folderList.querySelectorAll(".folder-prefix"),"hidden",""!=c)}};
AddStoryToGroupController.prototype.closeGroup=function(){this.elements.groupList.classList.remove("hidden");this.elements.folderList.classList.add("hidden");this.elements.returnButton.disabled="disabled";this.inputs.search.value="";this.mode="groups";this.search("")};
AddStoryToGroupController.prototype.selectGroup=function(c){var d=this;this.elements.groupList.classList.add("hidden");this.elements.folderList.classList.remove("hidden");this.inputs.search.value="";fQuery.removeChildren(this.elements.folderList);this.mode="folders";new AjaxRequest({url:"/ajax/groups/"+c.dataset.group+"/folders/list/add-story?story="+c.dataset.story,method:"GET",success:function(c){d.elements.folderList.innerHTML=c.content;d.elements.returnButton.disabled=!1;d.folders=fQuery.nodesToArray(d.elements.folderList.querySelectorAll("li"))}})};
App.AddController("add-story-to-group",AddStoryToGroupController);var BlockUserController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(BlockUserController,Controller);
BlockUserController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);c.addEventListener("click",function(c){c.preventDefault();var d=this;d.classList.add("button_toggle_processing");new AjaxRequest({url:"/ajax/users/"+d.getAttribute("data-user")+"/block",signed:!0,method:"true"==d.getAttribute("data-block")?"DELETE":"POST",success:function(c){d.classList.remove("button_toggle_processing");d.setAttribute("data-block",c.block);c.block?(d.classList.add("user_is_blocking"),d.classList.remove("user_is_not_blocking")):
(d.classList.add("user_is_not_blocking"),d.classList.remove("user_is_blocking"))}})})};App.AddController("block-user",BlockUserController);var ChapterTextToSpeech=function(c,d){var e=this;this.chapter=c;this.sentence=0;this.sentences=null;this.isPlaying=!1;this.isTracking=!0;this.volume=1;this.ttsSettingsPopup=null;this.optionsElement=d;window.addEventListener("unload",function(c){speechSynthesis.cancel()});this.voices=window.speechSynthesis.getVoices();this.populateVoices();window.speechSynthesis.onvoiceschanged=function(){e.voices=window.speechSynthesis.getVoices();e.populateVoices()};this.noSleep=new NoSleep};
ChapterTextToSpeech.prototype.getParagraphs=function(){return this.chapter.chapterBody.querySelectorAll("p, pre")};
ChapterTextToSpeech.prototype.getSentences=function(){if(null==this.sentences){this.sentences=[];for(var c=this.getParagraphs(),d=0;d<c.length;d++)for(var e=c[d],f=fQuery.text(e),f=f.replace(/["]/g,""),f=f.replace(/mr\./ig,"mister"),f=f.replace(/mrs\./ig,"misses"),f=f.split(/[\?!\.]/),f=$jscomp.makeIterator(f),g=f.next();!g.done;g=f.next())g=g.value,0<g.replace(/["'\u201C\u201D ]/g,"").length&&this.sentences.push({paragraph:e,text:g})}return this.sentences};
ChapterTextToSpeech.prototype.sayNextSentence=function(){var c=this,d=this.voices.filter(function(c){return"native"==c.name})[0],e=this.getSentences()[this.sentence],f=this.getParagraphs();fQuery.removeClass(f,"reading");e.paragraph.classList.add("reading");this.isTracking&&this.chapter.scrollParagraphToView(e.paragraph);this.utterance=new SpeechSynthesisUtterance;this.utterance.voice=d;this.utterance.text=e.text;this.utterance.rate=1.2;this.utterance.volume=this.volume;this.utterance.lang="en-US";
this.utterance.onend=function(){c.sentence++;c.sayNextSentence()};speechSynthesis.speak(this.utterance)};ChapterTextToSpeech.prototype.play=function(){this.isPlaying=!0;this.enableTracking();this.sayNextSentence();this.updatePlayPause();this.noSleep.enable();this.optionsElement.classList.remove("hidden")};ChapterTextToSpeech.prototype.pause=function(){null!=this.utterance&&(this.utterance.onend=function(){});this.isPlaying=!1;speechSynthesis.cancel();this.updatePlayPause();this.noSleep.disable()};
ChapterTextToSpeech.prototype.playPause=function(){this.isPlaying?this.pause():this.play()};ChapterTextToSpeech.prototype.sayParagraph=function(c){var d=0;this.stop();for(var e=$jscomp.makeIterator(this.getSentences()),f=e.next();!f.done;f=e.next()){if(f.value.paragraph==c){this.sentence=d;this.play();break}d++}};
ChapterTextToSpeech.prototype.stop=function(){null!=this.utterance&&(this.utterance.onend=function(){});this.isPlaying=!1;var c=this.getParagraphs();fQuery.removeClass(c,"reading");this.sentence=0;speechSynthesis.cancel();this.updatePlayPause();this.optionsElement.classList.add("hidden");this.noSleep.disable()};ChapterTextToSpeech.prototype.updatePlayPause=function(){this.chapter.elements.ttsPlayPauseButton.className=this.isPlaying?"fa fa-pause":"fa fa-play"};
ChapterTextToSpeech.prototype.enableTracking=function(){0==this.isTracking&&(this.isTracking=!0,this.chapter.elements.ttsTrackingButton.className="on",this.scrollParagraph())};ChapterTextToSpeech.prototype.scrollParagraph=function(){this.chapter.scrollParagraphToView(this.getSentences()[this.sentence].paragraph)};ChapterTextToSpeech.prototype.disableTracking=function(){this.isTracking&&(this.isTracking=!1,this.chapter.elements.ttsTrackingButton.className="")};
ChapterTextToSpeech.prototype.toggleTracking=function(){this.isTracking?this.disableTracking():this.enableTracking()};
ChapterTextToSpeech.prototype.getTtsSettingsPopup=function(){null==this.ttsSettingsPopup&&(this.ttsSettingsPopup=new PopUpMenu("","<i class='fa fa-font'></i> Text to Speech Options"),this.ttsSettingsPopup.SetCloseOnHoverOut(!1),this.ttsSettingsPopup.SetSoftClose(!0),this.ttsSettingsPopup.SetWidth(250),this.ttsSettingsPopup.SetDimmerEnabled(!1),this.ttsSettingsPopup.SetFooter("These options affect how you see stories formatted throughout the whole site and affect your current device only!"),this.ttsSettingsPopup.SetFixed(!0),
this.ttsSettingsPopup.SetContent('\n                <label>\n                    <select name="ttsVoice" style="width:200px;" data-input="setTtsVoice"></select>\n                </label>'));return this.ttsSettingsPopup};
ChapterTextToSpeech.prototype.populateVoices=function(){var c=this.getTtsSettingsPopup().content.querySelector("[name=ttsVoice]");c.innerHTML="";for(var d=$jscomp.makeIterator(this.voices),e=d.next();!e.done;e=d.next())e=e.value,e=fQuery.createFromHtml('<option value="'+e.name+'">'+e.name+"</option>"),c.appendChild(e)};ChapterTextToSpeech.prototype.showSettings=function(){this.getTtsSettingsPopup().Show()};
var ChapterController=function(){Controller.call(this);this.editing=!1;this.ttsSettingsPopup=this.formatPopup=null;"speechSynthesis"in window&&window.speechSynthesis.getVoices()};$jscomp.inherits(ChapterController,Controller);
ChapterController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.storyId=c.dataset.storyId;this.settings={autoBookmark:{wait:30,pauseTime:180,offset:{begin:.5,end:.5}},markRead:{wait:30,progressThreshold:.6}};this.isRead=c.dataset.read||!1;this.toolbar=c.querySelector("#chapter_toolbar_container");this.scrubber_bar=c.querySelector("#chapter_scrubber_bar");this.scrubber=c.querySelector("#chapter_scrubber_page");this.scrubberCircle=c.querySelector("#chapter_scrubber");
this.chapterContent=c.querySelector(".chapter_content");this.chapterEdit=c.querySelector("#chapter_edit");this.editForm=c.querySelector("#chapter_edit_form");this.chapter=c.querySelector("#chapter");this.chapterBody=c.querySelector("#chapter-body");this.chapterTitle=c.querySelector("#chapter_title");this.chapterFormat=c.querySelector("#chapter_format");this.chapterId=c.dataset.chapter;this.chapterPublishButton=c.querySelector("#chapter_publish");this.manualBookmarkMode=!1;this.bookmark=c.querySelector(".chapter-bookmark");
this.bookmarkPlaced=!1;this.bookmarkedParagraph=null;this.showingParagraphOptions=!1;this.paragraphOptions=c.querySelector("#paragraph-options");this.paragraphOptions.addEventListener("click",function(c){c.target==d.paragraphOptions&&d.hideParagraphOptions()});var e=this,f=0,g=0;fQuery.addScopedEventListener(this.chapterBody,"p, pre","mousedown",function(c){f=c.clientX;g=c.clientY});var k=!0;window.addEventListener("focus",function(){setTimeout(function(){k=!0},300)});var l=!1;fQuery.addScopedEventListener(this.chapterBody,
"p, pre","mousedown",function(c){c="";window.getSelection?c=window.getSelection().toString():document.selection&&"Control"!=document.selection.type&&(c=document.selection.createRange().text);l=0<c.length});window.addEventListener("blur",function(){k=!1});fQuery.addScopedEventListener(this.chapterBody,"p, pre","click",function(c){k&&(l?l=!1:5>Math.abs(c.clientX-f)&&5>Math.abs(c.clientY-g)&&(e.isShowingParagraphOptions()&&e.selectedParagraph==this?e.hideParagraphOptions():e.showParagraphOptions(this)))});
window.addEventListener("resize",this.renderParagraphOptions.bind(this));this.fadedBackgroundColor=this.backgroundColor=null;this.lastBackgroundBlendFactor=-1;700<window.innerWidth&&(this.computeBackgroundColor(),document.addEventListener("chapterColourSchemeChanged",this.computeBackgroundColor.bind(this)),document.addEventListener("chapterColourSchemeChanged",this.updatePageBackgroundColor.bind(this)),document.addEventListener("scroll",this.updatePageBackgroundColor.bind(this)));is_mobile?(document.body.addEventListener("click",
this.showToolbar.bind(this)),document.addEventListener("scroll",this.hideToolbar.bind(this)),document.addEventListener("scroll",this.updateToolbar.bind(this))):(document.addEventListener("scroll",this.updateToolbar.bind(this)),window.addEventListener("resize",this.updateToolbar.bind(this)));is_logged_in&&setTimeout(function(){document.addEventListener("scroll",function(){var c=d.chapter.getBoundingClientRect();(c.bottom-window.innerHeight)/c.height<1-d.settings.markRead.progressThreshold&&d.markRead()})},
1E3*this.settings.markRead.wait);"true"==this.element.dataset.autoBookmark&&(setTimeout(function(){console.log("Initialised auto bookmark on onload...");window.addEventListener("unload",function(){console.log("Placing bookmark...");d.placeBookmarkAtCurrentPosition(!0)},!1)},1E3*this.settings.autoBookmark.wait),document.addEventListener("scroll",fQuery.debounce(this.placeBookmarkAtCurrentPosition.bind(this),1E3*this.settings.autoBookmark.pauseTime)),this.furthestReadParagraph=null,document.addEventListener("scroll",
fQuery.throttle(function(){var c=d.getFirstVisibleParagraph();if(null!=c)for(var e=$jscomp.makeIterator(d.chapterBody.querySelectorAll("p")),f=e.next();!f.done;f=e.next()){f=f.value;if(f==d.furthestReadParagraph||null==d.furthestReadParagraph){d.furthestReadParagraph=c;break}if(f==c)break}},200)));c.addEventListener("save",this.save.bind(this));window.addEventListener("load",this.initialiseLiveReaderCount.bind(this));AddHashCallback("edit",function(c){d.toggleEdit()});this.textToSpeech=null;"speechSynthesis"in
window||fQuery.removeElement(this.elements.ttsReadButton);this.ignoreUserScroll=!1;document.addEventListener("scroll",function(){!d.ignoreUserScroll&&d.textToSpeech&&d.textToSpeech.disableTracking()});this.handleBookmark();this.chapterEditor=this.element.querySelector("#chapter_editor");null!=this.chapterEditor&&(this.updateEditFooter(),this.chapterEditor.addEventListener("input",fQuery.debounce(this.updateEditFooter.bind(this),200)))};
ChapterController.prototype.markRead=function(){this.isRead||(this.isRead=!0,new AjaxRequest({method:"POST",url:"/ajax/chapters/"+this.chapterId+"/read",signed:!0}))};
ChapterController.prototype.updateEditFooter=function(){function c(c,d){c=c.match(d);return null==c?0:c.length}var d=this.chapterEditor.value,d=d.replace(/\[[^\] ]+\]/g,""),d=d.replace(/\//g," "),d=d.trim(),e=c(d,/\s+/g)+1;this.element.querySelector("[data-word-count]").textContent=e.toLocaleString();var f=c(d,/\n[\s^\n]*(?:\n\s*|(\t+|[ ]{4,}))/g)+1;this.element.querySelector("[data-paragraph-count]").textContent=f.toLocaleString();this.element.querySelector("[data-error-paragraphs]").classList.toggle("hidden",
f>e/200);e=c(d,/[\n\.\!\?][ "\u201C]*[a-z]/g);d=c(d,/[\n\.\!\?][ "\u201C]*[A-Z]/g);this.element.querySelector("[data-error-casing]").classList.toggle("hidden",!(d<e&&10<e))};ChapterController.prototype.fixCapitalise=function(){this.chapterEditor.value=this.chapterEditor.value.replace(/((?:^|\n|[.!?] )[ "\u201C]*)([a-z])/g,function(c,d,e){return d+e.toUpperCase()});this.updateEditFooter()};
ChapterController.prototype.handleBookmark=function(){var c=this;setTimeout(function(){var d;if(""!=c.element.dataset.bookmarkHash){var e=null,f=xyzcrypto.supported?new xyzcrypto.sha256.asm:new sjcl.hash.sha256,g=$jscomp.makeIterator(c.chapterFormat.querySelectorAll("p, pre"));for(d=g.next();!d.done;d=g.next()){var k=d.value;xyzcrypto.supported?d=xyzcrypto.toB64(f.hash(xyzcrypto.fromString(fQuery.text(k)))):(f.reset(),d=sjcl.codec.base64.fromBits(f.update(fQuery.text(k)).finalize()));d==c.element.dataset.bookmarkHash&&
(e=k)}null!=e&&(c.bookmarkedParagraph=e,c.bookmarkPlaced=!0,c.renderParagraphOptions(),"performance"in window&&(1==performance.navigation.type||2==performance.navigation.type)||fQuery.scrollTop(e.getBoundingClientRect().top-window.innerHeight/5,!1,.5))}},500)};
ChapterController.prototype.initialiseFormatPopup=function(){var c=this;if(null==this.formatPopup){var d=document.getElementById("format-options"),e=d.innerHTML;fQuery.removeElement(d);this.formatPopup=new PopUpMenu("","<i class='fa fa-font'></i> Chapter Formatting");this.formatPopup.SetCloseOnHoverOut(!1);this.formatPopup.SetSoftClose(!0);this.formatPopup.SetWidth(250);this.formatPopup.SetDimmerEnabled(!1);this.formatPopup.SetFooter("These options affect how you see stories formatted throughout the whole site and affect your current device only!");
this.formatPopup.SetFixed(!0);this.formatPopup.SetContent(e);this.formatController=App.GetController("chapter-format",this.formatPopup.element);this.formatController.setChangeListener(function(d){c.renderParagraphOptions()})}};ChapterController.prototype.toggleFormatPopup=function(){this.initialiseFormatPopup();this.formatController.initFonts();this.formatPopup.Show()};
ChapterController.prototype.initialiseLiveReaderCount=function(){function c(){l.classList.remove("hidden");f?d||(g.emit("reading",n.chapterId),d=!0):(f=!0,g=io("https://blooming-shelf-2016.herokuapp.com:443",{transports:["websocket"]}),g.on("u",function(c){m.textContent=c}),g.on("connect",function(){c()}),g.on("reconnect",function(){c()}),g.on("disconnect",function(){d=!1}),window.addEventListener("blur",function(){k=setTimeout(function(){d=!1;g.io.disconnect();k=null},3E5)}))}var d=!1,e=document.hasFocus(),
f=!1,g,k=null,l=document.getElementById("num-readers-button"),m=l.querySelector("#num-readers"),n=this;e&&c();window.addEventListener("focus",function(){null!=k?(clearTimeout(k),k=null):f?g.io.reconnect():c()})};ChapterController.prototype.showToolbar=function(){var c=this.element.getBoundingClientRect();0>c.top&&0<c.bottom&&this.toolbar.classList.add("show")};ChapterController.prototype.hideToolbar=function(){this.toolbar.classList.remove("show")};
ChapterController.prototype.updateToolbar=function(){if(1!=LocalStorageGet("show_chapter_progress_bar",1))null!=this.scrubber&&(fQuery.removeElement(this.scrubber),this.scrubber=null);else{var c=this.chapter.getBoundingClientRect(),d=window.innerHeight;is_mobile?0>c.top&&0<c.bottom?this.scrubber_bar.classList.add("scrubber-mobile"):this.scrubber_bar.classList.remove("scrubber-mobile"):0>c.top&&0<c.bottom?(this.toolbar.style.width=c.width+"px",this.toolbar.setAttribute("data-fixed",!0)):(this.toolbar.style.width=
"auto",this.toolbar.removeAttribute("data-fixed"));var e=-c.top/c.height,c=(-c.top+d)/c.height;this.scrubber.style.left=100*(1<e?1:0>e?0:e)+"%";this.scrubber.style.right=100-100*(1<c?1:0>c?0:c)+"%";e=(e+c)/2;1<e?this.scrubberCircle.style.visibility="hidden":(this.scrubberCircle.style.visibility="visible",this.scrubberCircle.style.left=100*e+"%")}};ChapterController.prototype.measureFonts=function(){};ChapterController.prototype.getBBCodeEditor=function(){return App.GetControllerFromElement(this.chapterEdit.querySelector(".bbcode-editor"))};
ChapterController.prototype.toggleEdit=function(){this.editing=!this.editing;toggleClass(this.chapterEdit,"hidden",!this.editing);toggleClass(this.chapter,"hidden",this.editing);this.editing&&this.getBBCodeEditor().layoutToolbar()};
ChapterController.prototype.togglePublish=function(){var c=this;this.chapterPublishButton.classList.add("chapter_publishing");var d=this.chapterPublishButton.classList.contains("chapter_published"),e=function(){(new AjaxRequest({method:d?"DELETE":"POST",url:"/ajax/chapters/"+c.chapterId+"/publish",signed:!0,success:function(d,e){toggleClass(c.chapterPublishButton,"chapter_published","0"!=d.published);toggleClass(c.chapterPublishButton,"chapter_unpublished","0"==d.published);c.chapterTitle.textContent=
d.title}})).then(function(){c.chapterPublishButton.classList.remove("chapter_publishing")})};d?e():this.save(this.editForm).then(e)};
ChapterController.prototype.save=function(c){var d=this;return new Promise(function(c,f){f=d.editForm.querySelector(".format-toolbar button[data-click=save] i");new AjaxRequest({method:"POST",url:d.editForm.getAttribute("action"),data:AjaxRequest.serializeForm(d.editForm),signed:!0,spinner:f,success:function(e,f){d.chapterBody.querySelector(".bbcode").innerHTML=e.content_marked_up;d.chapterTitle.innerHTML=e.title;c(d)}})})};
ChapterController.prototype.scrollParagraphToView=function(c){var d=this;c=c.getBoundingClientRect();this.ignoreUserScroll=!0;(c.bottom>.9*window.innerHeight||0>c.top)&&fQuery.scrollTop(c.top-.1*window.innerHeight,!1,.4);setTimeout(function(){d.ignoreUserScroll=!1},600)};ChapterController.prototype.ttsPlayPause=function(){this.textToSpeech.playPause()};ChapterController.prototype.ttsToggleTracking=function(){this.textToSpeech.toggleTracking()};ChapterController.prototype.ttsStop=function(){this.textToSpeech.stop()};
ChapterController.prototype.ttsHelp=function(){StyledAlert("This is an experimental feature and may have bugs due to differing browser implementations.<br /><br />If Chrome stops playing audio entirely the only option is to fully restart the browser.","Text to speech",{align:"justify"})};ChapterController.prototype.ttsSettings=function(){this.textToSpeech.showSettings()};
ChapterController.prototype.computeBackgroundColor=function(){document.body.style.backgroundColor="";this.backgroundColor=extractColor(window.getComputedStyle(document.body).backgroundColor);var c=extractColor(window.getComputedStyle(this.chapterFormat.querySelector(".chapter")).backgroundColor);if("undefined"!=typeof this.backgroundColor&&"undefined"!=typeof c){var d=127>.39*c[0]+.5*c[1]+.11*c[2];this.fadedBackgroundColor=colorMult(c,d?.85:.95);255==c[0]&&255==c[1]&&255==c[2]&&(this.fadedBackgroundColor=
null);this.border_color=colorMult(c,d?1.4:.82);this.updatePageBackgroundColor(!0)}};
ChapterController.prototype.updatePageBackgroundColor=function(c){c=void 0===c?!1:c;var d=this.elements.chapterContentBox.getBoundingClientRect(),d=1-saturate(5*Math.min(2-d.top/window.innerHeight,d.bottom/window.innerHeight)-4);if(d!=this.lastBackgroundBlendFactor||c)document.body.style.backgroundColor=null!=this.fadedBackgroundColor?rgbToCSS(colorBlend(this.backgroundColor,this.fadedBackgroundColor,d)):null,this.elements.chapterContentBox.style.borderLeftColor=rgbToCSS(this.border_color),this.elements.chapterContentBox.style.borderRightColor=
rgbToCSS(this.border_color),this.lastBackgroundBlendFactor=d};ChapterController.prototype.showParagraphOptions=function(c){this.selectedParagraph=c;this.showingParagraphOptions=!0;this.paragraphOptions.classList.add("showing");this.renderParagraphOptions()};ChapterController.prototype.hideParagraphOptions=function(){this.selectedParagraph=null;this.showingParagraphOptions=!1;this.paragraphOptions.classList.remove("showing")};
ChapterController.prototype.renderParagraphOptions=function(){if(this.showingParagraphOptions)if(this.paragraphOptions.offsetParent){this.paragraphOptions.style.top="0px";var c=this.selectedParagraph.getBoundingClientRect().top-this.paragraphOptions.offsetParent.getBoundingClientRect().top;this.paragraphOptions.style.transform="translate(0px, "+c+"px)";this.paragraphOptions.style.height=this.selectedParagraph.offsetHeight+"px"}else this.hideParagraphOptions();this.elements.bookmarkButtonText.textContent=
this.selectedParagraph==this.bookmarkedParagraph?"Unbookmark":"Bookmark";this.bookmarkPlaced?(this.bookmark.classList.add("placed"),this.bookmark.style.top=this.bookmarkedParagraph.offsetTop+"px"):this.bookmark.classList.remove("placed")};ChapterController.prototype.getFirstVisibleParagraph=function(){for(var c=null,d=null,e=$jscomp.makeIterator(this.chapterBody.querySelectorAll("p")),f=e.next();!f.done;f=e.next()){var f=f.value,g=f.getBoundingClientRect();if(g.top>c||null===d)c=g.top,d=f;if(0<g.top)return f}return d};
ChapterController.prototype.placeBookmarkAtCurrentPosition=function(c){c=void 0===c?!1:c;if(1!=this.manualBookmarkMode&&null!=this.furthestReadParagraph){var d=this.chapterBody.getBoundingClientRect();this.furthestReadParagraph.getBoundingClientRect().top-d.top<this.settings.autoBookmark.offset.begin*window.innerHeight?console.log("Not changing bookmark because didn't read far enough..."):this.saveBookmark(this.furthestReadParagraph,c,!0)}};
ChapterController.prototype.saveBookmark=function(c,d,e){d=void 0===d?!1:d;e=void 0===e?!1:e;console.log("Saving bookmark");this.bookmarkedParagraph=c;this.bookmarkPlaced=!0;var f=fQuery.text(this.bookmarkedParagraph),f=xyzcrypto.supported?xyzcrypto.toB64(xyzcrypto.sha256.asm.hash(xyzcrypto.fromString(f))):sjcl.codec.base64.fromBits(sjcl.hash.sha256.hash(f));if(is_logged_in){var g=c.getBoundingClientRect(),k=this.chapterBody.getBoundingClientRect();c=~~(100*saturate((g.top-k.top)/k.height));g.top>
k.bottom-window.innerHeight*(1+this.settings.autoBookmark.offset.end)&&e&&(f="null");d?("null"==f?console.log("Beacon bookmark move to next / delete..."):console.log("Beacon bookmark save ("+c+"% read)..."),e=DataToURLEncodedString([{name:"chapter_id",value:this.chapterId},{name:"hash",value:f},{name:"progress",value:c}]),d="/ajax/stories/"+this.storyId+"/bookmark",e=SignString(e,d),g=new FormData,g.set("chapter_id",this.chapterId),g.set("hash",f),g.set("progress",c),g.set("signature",e.signature),
g.set("signature_nonce",e.nonce),g.set("signature_timestamp",e.timestamp),navigator.sendBeacon(d,g)):new AjaxRequest({url:"/ajax/stories/"+this.storyId+"/bookmark",method:"POST",signed:!0,data:{chapter_id:this.chapterId,hash:f,progress:c}})}else window.localStorage&&LocalStorageSet("bookmark"+this.chapterId,f)};
ChapterController.prototype.placeBookmark=function(c,d){null!=this.selectedParagraph&&(d.stopPropagation(),this.bookmarkPlaced&&this.selectedParagraph==this.bookmarkedParagraph?this.removeBookmark():(this.manualBookmarkMode=!0,this.saveBookmark(this.selectedParagraph),this.bookmarkPlaced=!0),this.hideParagraphOptions(),this.renderParagraphOptions())};ChapterController.prototype.isShowingParagraphOptions=function(){return this.showingParagraphOptions};
ChapterController.prototype.togglePlaceBookmark=function(){this.showingParagraphOptions?this.placeBookmark():this.beginPlaceBookmark()};
ChapterController.prototype.removeBookmark=function(c){c=void 0===c?!1:c;this.bookmarkPlaced=!1;this.bookmarkedParagraph=null;this.renderParagraphOptions();if(is_logged_in){var d="/ajax/stories/"+this.storyId+"/bookmark";if(c){c=DataToURLEncodedString([{name:"_method",value:"DELETE"}]);c=SignString(c,d);var e=new FormData;e.set("_method","DELETE");e.set("signature",c.signature);e.set("signature_nonce",c.nonce);e.set("signature_timestamp",c.timestamp);navigator.sendBeacon(d,e)}else new AjaxRequest({url:d,
method:"DELETE",signed:!0})}else window.localStorage&&LocalStorageRemove("bookmark"+this.chapterId)};ChapterController.prototype.quoteParagraph=function(){var c=App.GetControllerFromElement(document.getElementById("add_comment_box")).getBBCodeController();c.insertText("[quote]"+fQuery.text(this.selectedParagraph)+"[/quote]\n\n");c.focus();this.hideParagraphOptions()};ChapterController.prototype.close=function(){this.hideParagraphOptions()};
ChapterController.prototype.read=function(){null==this.textToSpeech&&(this.textToSpeech=new ChapterTextToSpeech(this,this.elements.ttsOptions));this.textToSpeech.sayParagraph(this.selectedParagraph);this.hideParagraphOptions()};ChapterController.prototype.showAddToGroups=function(){Group.showAddToGroup(this.storyId)};ChapterController.prototype.showAddToBookshelves=function(){Library.getInstance().showAddToBookshelf(this.storyId)};App.AddController("chapter",ChapterController);var FontDetector=function(){this.canvas=document.createElement("canvas");"getContext"in this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.base_metrics=FontDetector.base_fonts.map(FontDetector.prototype.get_metrics.bind(this)))};FontDetector.prototype.measureText=function(c){return this.ctx.measureText(c).width};FontDetector.prototype.get_metrics=function(c){this.ctx.font="normal 50px "+c;return["M","W","I","1","font test"].map(FontDetector.prototype.measureText.bind(this))};
FontDetector.compare_metrics=function(c,d){for(var e=0;e<c.length;++e)if(c[e]!=d[e])return!1;return!0};FontDetector.prototype.test=function(c){return"ctx"in this?c.filter(function(c){for(var d=0;d<FontDetector.base_fonts.length;d++){var f=this.get_metrics('"'+c+'", '+FontDetector.base_fonts[d]);if(!FontDetector.compare_metrics(this.base_metrics[d],f))return!0}return!1},this):c};FontDetector.base_fonts=["serif","sans-serif","monospace"];
var ChapterFormatController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(ChapterFormatController,Controller);
ChapterFormatController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.text_size=LocalStorageGet("format_size",1);this.font=LocalStorageGet("format_font","Open Sans");this.colour_scheme=LocalStorageGet("format_colours","bow");this.line_spacing=LocalStorageGet("format_line_spacing",1.8);this.line_width=LocalStorageGet("format_line_width",1.2);this.paragraph_style=LocalStorageGet("paragraph_style","double");this.justify=LocalStorageGet("format_justify",is_mobile?"none":
"justify");"0"==this.justify?LocalStorageSet("format_justify",this.justify="none"):"1"==this.justify&&LocalStorageSet("format_justify",this.justify="justify");this.chapterFormat=document.getElementById("chapter_format");this.chapter=this.chapterFormat.querySelector(".chapter");this.chapterBody=document.getElementById("chapter-body");this.storyContainer=this.chapterFormat.querySelector(".story_container");this.inputs.text_size.value=this.text_size;this.inputs.font.value=this.font;this.inputs.colour_scheme.value=
this.colour_scheme;this.inputs.paragraph_style.value=this.paragraph_style;this.inputs.line_spacing.value=this.line_spacing;this.inputs.line_width.value=this.line_width;this.inputs.justify.value=this.justify;this.inputs.text_size_numeric.value=this.text_size;this.inputs.line_spacing_numeric.value=this.line_spacing;this.inputs.line_width_numeric.value=this.line_width;this.inputs.text_size.addEventListener("change",function(c){d.setSize(c.target.value)});this.inputs.line_spacing.addEventListener("change",
function(c){d.setLineSpacing(c.target.value)});this.inputs.line_width.addEventListener("change",function(c){d.setLineWidth(c.target.value)});this.apply()};ChapterFormatController.prototype.setChangeListener=function(c){this.onChangeListener=c};
ChapterFormatController.prototype.apply=function(){this.chapter.style.fontSize=this.text_size+"rem";this.chapter.style.fontFamily=this.font;this.chapterFormat.className="content_format_"+this.colour_scheme;this.chapterBody.style.lineHeight=this.line_spacing+"em";this.chapterBody.style.textAlign="none"!=this.justify?"justify":"left";var c="hyphens"==this.justify?"auto":"none";this.chapterBody.style.webkitHyphens=c;this.chapterBody.style.mozHyphens=c;this.chapterBody.style.msHyphens=c;this.chapterBody.style.hyphens=
c;this.storyContainer.style.maxWidth=50*this.text_size*this.line_width+"em";this.chapterBody.classList.toggle("double-spaced","double"==this.paragraph_style||"both"==this.paragraph_style);this.chapterBody.classList.toggle("indented","indented"==this.paragraph_style||"both"==this.paragraph_style);if(this.onChangeListener)this.onChangeListener(this)};ChapterFormatController.prototype.setSize=function(c){this.text_size=c;LocalStorageSet("format_size",c);this.inputs.text_size_numeric.value=c;this.apply()};
ChapterFormatController.prototype.setFont=function(c){this.font=c;LocalStorageSet("format_font",c);this.apply()};ChapterFormatController.prototype.setColourScheme=function(c){this.colour_scheme=c;LocalStorageSet("format_colours",this.colour_scheme);this.apply();App.DispatchEvent(document,"chapterColourSchemeChanged")};ChapterFormatController.prototype.setParagraphStyle=function(c){this.paragraph_style=c;LocalStorageSet("paragraph_style",this.paragraph_style);this.apply()};
ChapterFormatController.prototype.setJustify=function(c){this.justify=c;LocalStorageSet("format_justify",c);this.apply()};ChapterFormatController.prototype.setLineSpacing=function(c){this.line_spacing=c;LocalStorageSet("format_line_spacing",c);this.inputs.line_spacing_numeric.value=c;this.apply()};ChapterFormatController.prototype.setLineWidth=function(c){this.line_width=c;LocalStorageSet("format_line_width",c);this.inputs.line_width_numeric.value=c;this.apply()};
ChapterFormatController.prototype.initFonts=function(){var c=new FontDetector,d="<optgroup label='Browser Defaults'><option value='serif' style='font-family: serif'>Serif</option><option value='sans-serif' style='font-family: sans-serif'>Sans Serif</option><option value='monospace' style='font-family: monospace'>Monospace</option></optgroup>",e=function(e,g){e=c.test(e).sort();if(0<e.length){d+="<optgroup label='"+g+"'>";for(g=0;g<e.length;g++)d+="<option value='"+e[g]+"' style='font-family: "+e[g]+
"'>"+e[g]+"</option>";d+="</optgroup>"}};e("Georgia;Times New Roman;Constantia;Cambria;Book Antiqua;Perpetua;Rockwell;Calisto MT;Palatino;Palatino Linotype;Baskerville;Baskerville Old Face;Didot;Didot LT STD;Garamond;Hoefler Text;Lucida Bright;Bitstream Vera Serif;DejaVu Serif;Liberation Serif;Century Schoolbook L;URW Bookman L;URW Palladio L;Nimbus Roman No9 L;Roboto Slab;Droid Serif;FreeSerif".split(";"),"Serif");e("Arial;Calibri;Candara;Corbel;Century Gothic;Segoe UI;Verdana;Tahoma;Microsoft Sans Serif;Lucida Sans;Trebuchet MS;Franklin Gothic;Helvetica;Lucida Grande;Optima;Apple Gothic;Futura;Geneva;Gill Sans;Gill Sans MT;Bitstream Vera Sans;Ubuntu;DejaVu Sans;Liberation Sans;Nimbus Sans L;URW Gothic L;Roboto;Roboto Condensed;Droid Sans;Open Sans;FreeSans;Fira Sans".split(";"),
"Sans Serif");e("Bitstream Vera Sans Mono;Lucida Console;Consolas;Courier New;Lucida Sans Typewriter;Andale Mono;Ubuntu Monospace;DejaVu Sans Mono;Liberation Mono;Nimbus Mono L;Monaco;Andale Mono;Menlo;Droid Sans Mono;FreeMono;Fira Mono".split(";"),"Monospace");e("Comic Sans;Comic Sans MS;Segoe Print;Segoe Script;Maiandra GD;Kristen ITC;Pristina;Tempus Sans ITC;Viner Hand ITC;Bradley Hand;Chalkboard;Chalkboard SE;Luminari;Marker Felt;Noteworthy;Savoye LET;SignPainter;Snell Roundhand;Trattatello;Apple Chancery;Purisa".split(";"),
"Cursive");e("OpenDyslexic;OpenDyslexicAlta;OpenDyslexicMono;Dyslexie;Sylexiad Sans;Sylexiad Sans Spaced;Sylexiad Serif;Sylexiad Serif Spaced;Read Regular;Lexia Readable".split(";"),"Accessibility");e(["Equestria","Celestia Redux","Celestia Redux Alternate"],"Fantasy");this.inputs.font.innerHTML=d;this.inputs.font.value=this.font};App.AddController("chapter-format",ChapterFormatController);var ChapterListController=function(){Controller.call(this);this.chapter_dragging=null;this.mouse_offset_y=this.mouse_offset_x=0;this.eventChapterRead=new EventBus};$jscomp.inherits(ChapterListController,Controller);
ChapterListController.prototype.toggleRead=function(c){var d=this,e=c.getAttribute("data-id"),f=c.classList.contains("chapter-read");new AjaxRequest({url:"/ajax/chapters/"+e+"/read",method:f?"DELETE":"POST",signed:!0,spinner:c.querySelector("i"),success:function(e){1==e.read?c.classList.add("chapter-read"):c.classList.remove("chapter-read");d.eventChapterRead.fire(0==d.element.querySelectorAll("[data-published] .chapter-read-icon:not(.chapter-read)").length)}})};
ChapterListController.prototype.toggleAllRead=function(c,d){var e=this;return new Promise(function(f,g){new AjaxRequest({url:"/ajax/stories/"+e.storyId+"/read",signed:!0,spinner:d,method:c?"POST":"DELETE",success:function(c){for(var d=$jscomp.makeIterator(e.element.querySelectorAll("[data-published] .chapter-read-icon")),g=d.next();!g.done;g=d.next())g.value.classList.toggle("chapter-read",c.all_read);f(c.allRead)}})})};
ChapterListController.prototype.mouseMove=function(c){c=c.pageY-this.mouse_offset_y;if(null!=this.chapter_dragging){for(var d=!1,e=0;2>e;e++){var f=this.chapter_dragging,g=this.chapter_dragging.querySelector("div");if(null!=f){var k=c-f.offsetTop,l=f.nextElementSibling,m=f.previousElementSibling;null!=l&&k>l.offsetHeight/2+10&&((d=l.nextElementSibling)?f.parentNode.insertBefore(f,d):f.parentNode.appendChild(f),this.chapter_dragging=f,d=!0);null!=m&&k<-m.offsetHeight/2-10&&(f.parentNode.insertBefore(f,
m),this.chapter_dragging=f,d=!0);g.style.top=k+"px"}}d&&(this.chapter_dragging.parentNode.parentNode.querySelector(".save_ordering").classList.remove("hidden"),this.showAll())}};
ChapterListController.prototype.beginDrag=function(c,d){null==this.chapter_dragging&&(this.chapter_dragging=d.parentNode.parentNode,this.chapter_dragging.classList.add("dragging"),this.mouse_offset_x=c.pageX-this.chapter_dragging.offsetLeft,this.mouse_offset_y=c.pageY-this.chapter_dragging.offsetTop,document.body.classList.add("unselectable"),this.mouseMoveFunction=this.mouseMoveFunction||this.mouseMove.bind(this),document.addEventListener("mousemove",this.mouseMoveFunction))};
ChapterListController.prototype.endDrag=function(c){null!=this.chapter_dragging&&(document.body.classList.remove("unselectable"),this.chapter_dragging.classList.remove("dragging"),this.chapter_dragging.querySelector("div").style.top="0px",this.chapter_dragging=null);document.removeEventListener("mousemove",this.mouseMoveFunction)};
ChapterListController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);for(var d=c.querySelectorAll(".dragger"),e=this,f=function(c){e.beginDrag(c,this)},d=$jscomp.makeIterator(d),g=d.next();!g.done;g=d.next())g.value.addEventListener("mousedown",f);this.storyId=c.dataset.storyId;document.body.addEventListener("mouseup",this.endDrag.bind(this))};
ChapterListController.prototype.showAll=function(){fQuery.removeClass(this.element.querySelectorAll("li"),"hidden");for(var c=$jscomp.makeIterator(this.element.querySelectorAll(".chapter_expander")),d=c.next();!d.done;d=c.next())fQuery.removeElement(d.value.parentNode)};App.AddController("chapter-list",ChapterListController);var ComposePmController=function(){Controller.call(this);this.onSend=new EventBus;this.onCancel=new EventBus};$jscomp.inherits(ComposePmController,Controller);ComposePmController.prototype.cancel=function(){this.onCancel.fire()};ComposePmController.prototype.send=function(c,d){var e=this;d.preventDefault();new AjaxRequest({url:"/ajax/private-messages",method:"POST",signed:!0,button:c.querySelector(".button-submit"),spinner:c.querySelector(".button-submit i"),data:AjaxRequest.serializeForm(c),success:function(c){e.onSend.fire()}})};
App.AddController("compose-pm",ComposePmController);var CurrentlyReadingController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(CurrentlyReadingController,Controller);CurrentlyReadingController.prototype.remove=function(c){var d=c.dataset.storyId,e=fQuery.closestParent(c,"li");new AjaxRequest({method:"DELETE",url:"/ajax/stories/"+d+"/bookmark",spinner:c.querySelector("i"),signed:!0,success:function(){fQuery.removeElement(e)}})};App.AddController("currently-reading",CurrentlyReadingController);var CurrentlyReadingNavDrawerController=function(c){CurrentlyReadingController.apply(this,arguments)};$jscomp.inherits(CurrentlyReadingNavDrawerController,CurrentlyReadingController);
CurrentlyReadingNavDrawerController.prototype.bind=function(c){var d=this;CurrentlyReadingController.prototype.bind.call(this,c);var e=!1;this.element.addEventListener("tabSelected",function(){e||(e=!0,new AjaxRequest({url:"/ajax/currently-reading",method:"GET",success:function(c){d.elements.list.innerHTML=c.content;fQuery.removeElement(d.elements.spinner)}}))})};App.AddController("currently-reading-nav-drawer",CurrentlyReadingNavDrawerController);var DebuggerController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(DebuggerController,Controller);DebuggerController.prototype.tabClick=function(c){this.changeTab(c.dataset.tab)};
DebuggerController.prototype.changeTab=function(c){for(var d=$jscomp.makeIterator(this.element.querySelectorAll(".menu .button")),e=d.next();!e.done;e=d.next())e=e.value,toggleClass(e,"active",e.dataset.tab==c);d=$jscomp.makeIterator(this.element.querySelectorAll(".tab"));for(e=d.next();!e.done;e=d.next())e=e.value,toggleClass(e,"hidden",!e.classList.contains(c));sessionStorage.setItem("debugger_tab",c)};
DebuggerController.prototype.show=function(){document.body.classList.add("debug");sessionStorage.setItem("debugger_open",document.body.classList.contains("debug"))};DebuggerController.prototype.hide=function(){document.body.classList.remove("debug");sessionStorage.setItem("debugger_open",document.body.classList.contains("debug"))};DebuggerController.prototype.toggle=function(){document.body.classList.toggle("debug");sessionStorage.setItem("debugger_open",document.body.classList.contains("debug"))};
DebuggerController.prototype.toggleMinimised=function(){document.body.classList.toggle("debugger_minimised");sessionStorage.setItem("debugger_minimised",document.body.classList.contains("debugger_minimised"))};
DebuggerController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);"true"==sessionStorage.getItem("debugger_open")&&document.body.classList.add("debug");"true"==sessionStorage.getItem("debugger_minimised")&&document.body.classList.add("debugger_minimised");c=sessionStorage.getItem("debugger_tab");null!=c&&this.changeTab(c);fQuery.addScopedEventListener(this.element,".debugger .queries tr","click",function(){this.classList.toggle("expanded")})};App.AddController("debugger",DebuggerController);var DeleteConfirmController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(DeleteConfirmController,Controller);DeleteConfirmController.prototype.confirm=function(c,d,e){e.checked?this.elements.submitButton.removeAttribute("disabled"):this.elements.submitButton.setAttribute("disabled","disabled")};App.AddController("delete-confirm",DeleteConfirmController);var EditAccountSettingsController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(EditAccountSettingsController,Controller);
EditAccountSettingsController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.elements.shortBioCharacters.textContent=250-parseInt(this.inputs.short_bio.value.length,10)+" characters remaining";this.inputs.short_bio.addEventListener("focus",this.showShortBioPopup.bind(this));this.inputs.short_bio.addEventListener("blur",this.hideShortBioPopup.bind(this));this.thirdPartyAccountConfig=c=JSON.parse(this.element.dataset.thirdPartyAccountConfig);var d=[];for(f in c){var e=c[f];e.id=
f;d.push(e)}var f='\n            <li><a data-click="showAddAccount" data-service="url"><i class="fa fa-link"></i> URL</a></li>\n            <li><a data-click="showAddAccount" data-service="email"><i class="fa fa-envelope"></i> Email</a></li>\n            <li class="divider"></li>\n            '+d.sort(function(c,d){return c.name.localeCompare(d.name)}).map(function(c,d){return'\n                    <li>\n                        <a data-click="showAddAccount" data-id="'+c.id+'">\n                            '+
("fa"in c?'<i class="fa fa-'+c.fa+'"></i>':"")+"\n                            "+("img"in c?'<img src="'+(static_url+c.img)+'"/>':"")+"\n                            "+c.name+"\n                        </a>\n                    </li>"}).join("");this.elements.newAccountList.innerHTML=f.trim();this.inputs.timezone.value=this.inputs.timezone.dataset.value};
EditAccountSettingsController.prototype.shortBio=function(c){250<c.length&&(this.inputs.short_bio.value=this.inputs.short_bio.value.substring(0,250));this.elements.shortBioCharacters.textContent=250-parseInt(this.inputs.short_bio.value.length,10)+" characters remaining"};EditAccountSettingsController.prototype.showShortBioPopup=function(){this.elements.shortBioPopup.classList.remove("hidden")};EditAccountSettingsController.prototype.hideShortBioPopup=function(){this.elements.shortBioPopup.classList.add("hidden")};
EditAccountSettingsController.prototype.getOptionsString=function(){var c=[],d;for(d in this.externalAccountConfig)this.externalAccountConfig.hasOwnProperty(d)&&c.push('<option value="'+d+'">'+this.externalAccountConfig[d].name+"</option>");return c.join("")};
EditAccountSettingsController.prototype.showAddAccount=function(c){var d=this;if("url"==c.dataset.service||"email"==c.dataset.service){var e=new PopUpMenu("","<i class='fa fa-link'></i> Add "+("url"==c.dataset.service?"Link":"Email")),f='\n                <form id="form-new-third-party-account">\n                    <div class="std" style="padding:1rem;">\n                        <input type="'+("url"==c.dataset.service?"url":"email")+'" name="account" placeholder="'+("url"==c.dataset.service?"URL":
"Email")+'" />\n                    </div>\n                    <div class="drop-down-pop-up-footer-right">\n                        <button class="styled_button"><i class="fa fa-plus"></i> Add '+("url"==c.dataset.service?"Link":"Email")+"</button>\n                    </div>\n                </form>\n            ";e.SetWidth(400);e.SetContent(f);e.Show();e.element.querySelector("form [name=account]").focus();e.element.querySelector("form").addEventListener("submit",function(f){f.preventDefault();
d.addExternalAccount(null,("email"==c.dataset.service?"mailto:":"")+f.target.account.value);e.Close()})}else{var g=this.thirdPartyAccountConfig[c.dataset.id],k=new PopUpMenu("","<i class='fa fa-link'></i> Add "+g.name+" Account"),f='\n                <form id="form-new-third-party-account">\n                    <div class="std" style="padding:1rem;">\n                        <input type="text" name="account" placeholder="'+("placeholder"in g?g.placeholder:g.name+" Account")+'" />\n                    </div>\n                    <div class="drop-down-pop-up-footer-right">\n                        <button class="styled_button"><i class="fa fa-plus"></i> Add Account</button>\n                    </div>\n                </form>\n            ';
k.SetWidth(400);k.SetContent(f);k.Show();k.element.querySelector("form [name=account]").focus();k.element.querySelector("form").addEventListener("submit",function(c){c.preventDefault();g.id.startsWith("service:")?d.addExternalAccount(g.id.substr(8),c.target.account.value):"url"in g?d.addExternalAccount(null,g.url.replace("{account}",c.target.account.value)):d.addExternalAccount(null,c.target.account.value);k.Close()})}};
EditAccountSettingsController.prototype.addExternalAccount=function(c,d){null!=c&&(d=c+":"+d);this.elements.externalAccountList.appendChild(fQuery.createFromHtml('\n            <li class="orderable-item">\n                <div class="draggable">\n                    <a class="draggable-handle">::</a>\n                    <input name="links[]" type="text" value="'+d+'" style="max-width:25em;" />\n                    <a data-click="deleteAccount"><i class="fa fa-trash"></i></a>\n                </div>\n            </li>'))};
EditAccountSettingsController.prototype.deleteAccount=function(c){fQuery.removeElement(fQuery.closestParent(c,"li"))};App.AddController("edit-account-settings",EditAccountSettingsController);var EditBlogPostController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(EditBlogPostController,Controller);
EditBlogPostController.prototype.preview=function(c){var d=this;new AjaxRequest({url:"/ajax/bbcode/html",method:"POST",button:c,spinner:c.querySelector("i"),data:{bbcode:this.inputs.content.value},success:function(c){d.elements.preview.querySelector(".blog_post_content").innerHTML=c.content;d.elements.preview.querySelector("h1").innerHTML=d.inputs.title.value;d.elements.preview.classList.remove("hidden");fQuery.scrollTo(d.elements.preview,.3)}})};App.AddController("edit-blog-post",EditBlogPostController);var EditGroupsModuleController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(EditGroupsModuleController,Controller);EditGroupsModuleController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.setShowMode(this.inputs.show_mode.value)};EditGroupsModuleController.prototype.setShowMode=function(c){this.elements.selectGroupsList.classList.toggle("disabled","all"==c)};App.AddController("edit-groups-module",EditGroupsModuleController);var EditStoryController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(EditStoryController,Controller);
EditStoryController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.elements.shortDescriptionCharacters.textContent=250-parseInt(this.inputs.short_description.value.length,10)+" characters remaining";this.inputs.short_description.addEventListener("focus",this.showShortDescriptionPopup.bind(this));this.inputs.short_description.addEventListener("blur",this.hideShortDescriptionPopup.bind(this));this.contentRating(this.element.querySelector("input[name=content_rating]:checked").value);
this.element.querySelector("#search_characters").addEventListener("keydown",function(c){if(13==c.keyCode){c.preventDefault();var e=d.elements.characters.querySelector("label:not(.hidden) input");e&&(e.checked=!0,d.character(e.value,null,e));c.target.value="";d.searchCharacters("")}})};
EditStoryController.prototype.shortDescription=function(c){250<c.length&&(this.inputs.short_description.value=this.inputs.short_description.value.substring(0,250));this.elements.shortDescriptionCharacters.textContent=250-parseInt(this.inputs.short_description.value.length,10)+" characters remaining"};EditStoryController.prototype.showShortDescriptionPopup=function(){this.elements.shortDescriptionPopup.classList.remove("hidden")};EditStoryController.prototype.hideShortDescriptionPopup=function(){this.elements.shortDescriptionPopup.classList.add("hidden")};
EditStoryController.prototype.contentRating=function(c){0<c?this.elements.subContentRatings.classList.remove("hidden"):this.elements.subContentRatings.classList.add("hidden")};EditStoryController.prototype.isCategoryChecked=function(c){return this.getCategoryInput(c).checked};EditStoryController.prototype.getCategoryInput=function(c){return this.elements.categories.querySelector("input[value="+c+"]")};
EditStoryController.prototype.category=function(c,d,e){6<this.elements.categories.querySelectorAll("input:checked").length&&(ShowErrorWindow("Maximum of 6 categories can be selected"),e.checked=!1);this.isCategoryChecked("slice_of_life")&&this.isCategoryChecked("adventure")&&(ShowErrorWindow("Slice of life and Adventure are conflicting categories"),e.checked=!1);this.isCategoryChecked("comedy")&&this.isCategoryChecked("sad")&&(ShowErrorWindow("Sad and Comedy are conflicting categories"),e.checked=
!1)};EditStoryController.prototype.searchCharacters=function(c){c=c.toLowerCase();""==c?fQuery.removeClass(this.elements.characters.querySelectorAll("h2"),"hidden"):fQuery.addClass(this.elements.characters.querySelectorAll("h2"),"hidden");for(var d=$jscomp.makeIterator(this.elements.characters.querySelectorAll("label")),e=d.next();!e.done;e=d.next())e=e.value,""==c?e.classList.remove("hidden"):-1!=e.getAttribute("title").toLowerCase().indexOf(c)?e.classList.remove("hidden"):e.classList.add("hidden")};
EditStoryController.prototype.character=function(c,d,e){5<this.elements.characters.querySelectorAll("input:checked").length&&(ShowErrorWindow("Maximum of 5 characters can be selected"),e.checked=!1)};EditStoryController.prototype.clearCharacters=function(c,d){d.preventDefault();c=$jscomp.makeIterator(this.elements.characters.querySelectorAll("input:checked"));for(d=c.next();!d.done;d=c.next())d.value.checked=!1};App.AddController("edit-story",EditStoryController);var EmojiController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(EmojiController,Controller);
EmojiController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);var e=[];this.emojiElements=[];this.searchedElements=[];this.elements.list.addEventListener("scroll",function(){for(var c=null,e=$jscomp.makeIterator(d.elements.list.querySelectorAll(".emoji-selector__header")),k=e.next();!k.done;k=e.next())k=k.value,k.offsetTop<d.elements.list.scrollTop+.5*d.elements.list.offsetHeight&&(c=k.dataset.category);fQuery.removeClass(d.elements.tabs.querySelectorAll("li"),"selected");
d.elements.tabs.querySelector('[data-category="'+c+'"]').classList.add("selected")});new AjaxRequest({url:"/ajax/emoticons/list",method:"GET",success:function(c){new EmojiController;var f={name:"Ponies",emojis:[]};for(l in c.emoticons){var k=document.createElement("img");k.src="//static.fimfiction.net/images/emoticons/"+c.emoticons[l];f.emojis.push({code:l,name:l.replace(/:/g,""),img:k,keywords:[l.replace(/:/g,"")]})}e.push(f);c=$jscomp.makeIterator(c.emojis);for(f=c.next();!f.done;f=c.next()){f=
f.value;var l={name:f.category,emojis:[]};k=$jscomp.makeIterator(f.emojis);for(f=k.next();!f.done;f=k.next())l.emojis.push(f.value);e.push(l)}c=$jscomp.makeIterator(e);for(f=c.next();!f.done;f=c.next()){l=f.value;d.emojiElements.push({element:fQuery.createFromHtml('\n                            <li class="emoji-selector__header" data-category="'+l.name+'">'+l.name+"</li>\n                        ")});k=$jscomp.makeIterator(l.emojis);for(f=k.next();!f.done;f=k.next()){var f=f.value,m=document.createElement("li");
m.dataset.name=f.name;var n=document.createElement("a");n.setAttribute("title",f.name);n.setAttribute("data-click","addEmoticon");n.setAttribute("data-emoticon",f.code);f.img?n.appendChild(f.img):n.innerText=f.code;m.appendChild(n);d.emojiElements.push({element:m,keywords:f.keywords})}d.elements.tabs.appendChild(fQuery.createFromHtml('\n                        <li data-click="jumpTo" data-category="'+l.name+'">'+d.getEmojiForCategory(l.name)+"</li>\n                    "))}d.searchedElements=d.emojiElements;
d.render();App.BindAll(d.element)}})};EmojiController.prototype.jumpTo=function(c){c=this.elements.list.querySelector("[data-category="+c.dataset.category+"]");c.parentNode.scrollTop=c.offsetTop-5};EmojiController.prototype.search=function(c){this.searchedElements=Search.termSearch(this.emojiElements.filter(function(d){return!d.element.classList.contains("emoji-selector__header")||""==c}).map(function(c){return{item:c,text:c.keywords}}),c);this.render()};
EmojiController.prototype.render=function(){this.elements.list.scrollTop=0;fQuery.removeChildren(this.elements.list);for(var c=$jscomp.makeIterator(this.searchedElements),d=c.next();!d.done;d=c.next())this.elements.list.appendChild(d.value.element)};
EmojiController.prototype.getEmojiForCategory=function(c){switch(c){case "Ponies":return'<img src="//static.fimfiction.net/images/emoticons/yay.png" />';case "people":return"\ud83d\ude00";case "nature":return"\ud83d\udc36";case "food":return"\ud83c\udf4f";case "activity":return"\u26bd";case "travel":return"\ud83d\ude97";case "objects":return"\u231a";case "symbols":return"\ud83d\udc9b";case "flags":return"\ud83c\uddec\ud83c\udde7"}return"E"};EmojiController.prototype.selectTab=function(c){};
App.AddController("emoji",EmojiController);var FaqController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(FaqController,Controller);FaqController.prototype.bind=function(c){Controller.prototype.bind.call(this,c)};FaqController.prototype.expand=function(c){fQuery.closestParent(c,"li").classList.toggle("expanded")};FaqController.prototype.expandAll=function(){fQuery.addClass(this.element.querySelectorAll(".answers li"),"expanded")};
FaqController.prototype.collapseAll=function(){fQuery.removeClass(this.element.querySelectorAll(".answers li"),"expanded")};FaqController.prototype.goToComments=function(){fQuery.scrollTop(this.element.querySelector(".comment_content_box").getBoundingClientRect().top)};
FaqController.prototype.search=function(c){c=c.toLowerCase();var d=c.split(" ");fQuery.addClass(this.element.querySelectorAll(".category"),"hidden");for(var e=$jscomp.makeIterator(this.element.querySelectorAll("ul.answers>li")),f=e.next();!f.done;f=e.next()){for(var f=f.value,g=!0,k=f.querySelector(".question").textContent.toLowerCase(),l=0;l<d.length;l++)-1==k.indexOf(d[l])&&(g=!1);g?(f.classList.remove("hidden"),fQuery.closestParent(f,".category").classList.remove("hidden")):f.classList.add("hidden")}""==
c?this.element.querySelector(".categories").classList.remove("hidden"):is_mobile&&this.element.querySelector(".categories").classList.add("hidden")};FaqController.prototype.searchSubmit=function(){fQuery.scrollTop(this.element.querySelector("main").getBoundingClientRect().top)};App.AddController("faq",FaqController);var FaqQuestionController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(FaqQuestionController,Controller);FaqQuestionController.prototype.toggleEdit=function(){this.element.classList.toggle("faq-question-page-edit")};App.AddController("faq-question",FaqQuestionController);var FeaturedGroupsController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(FeaturedGroupsController,Controller);FeaturedGroupsController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.list=c.querySelector("ul");this.storyId=c.getAttribute("data-story")};FeaturedGroupsController.prototype.showAll=function(c){var d=this;new AjaxRequest({url:"/ajax/stories/"+this.storyId+"/groups",method:"GET",success:function(e){fQuery.removeElement(c);d.list.innerHTML=e.content}})};
App.AddController("featured-groups",FeaturedGroupsController);var FeedController=function(){Controller.call(this);this.done=this.loading=!1;this.viewMode="all"};$jscomp.inherits(FeedController,Controller);
FeedController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.column=c.querySelector(".feed");this.endMarker=c.querySelector("#feed_end_marker");window.addEventListener("scroll",function(c){d.endMarker.getBoundingClientRect().top<1.5*window.innerHeight&&d.loadOlderFeed()});c=$jscomp.makeIterator(this.column.querySelectorAll(".feed_item"));for(var e=c.next();!e.done;e=c.next())this.initItem(e.value);c=LocalStorageGet("feed_compressed","0");this.column.classList.toggle("compressed",
"1"==c);document.querySelector("#feed_compact_view").checked="1"==c};FeedController.prototype.initItem=function(c){c.querySelector(".feed_body")};FeedController.prototype.changeViewMode=function(c){this.viewMode=c;this.loadFeed()};FeedController.prototype.getLastTimestamp=function(){return this.column.querySelector(".feed_item:last-child").dataset.oldestTimestamp};FeedController.prototype.getFirstTimestamp=function(){return this.column.querySelector(".feed_item:first-child").dataset.timestamp};
FeedController.prototype.toggleCompressed=function(c,d){if("A"!=d.target.tagName)fQuery.closestParent(c,".feed_item").classList.toggle("expanded");else return!0};FeedController.prototype.loadFeed=function(){var c=this;this.loading||(this.column.innerHTML="",this.loading=!0,new AjaxRequest({url:"/ajax/feed",method:"GET",data:{feed_view:this.viewMode},success:function(d){if(0==d.items.length)c.loading=!1,c.done=!0;else{c.loading=!1;for(var e in d.items)c.addItem(d.items[e])}}}))};
FeedController.prototype.loadOlderFeed=function(){var c=this;this.loading||this.done||(this.loading=!0,new AjaxRequest({url:"/ajax/feed",method:"GET",data:{max_date:this.getLastTimestamp(),feed_view:this.viewMode},success:function(d){if(0==d.items.length)c.loading=!1,c.done=!0;else{setTimeout(function(){c.loading=!1;App.DispatchEvent(window,"scroll")},2E3);for(var e in d.items)c.addItem(d.items[e])}}}))};
FeedController.prototype.loadNewerFeed=function(c){var d=this;this.loading||(this.loading=!0,new AjaxRequest({url:"/ajax/feed",method:"GET",button:c,spinner:c.querySelector("i"),data:{min_date:this.getFirstTimestamp(),feed_view:this.viewMode},success:function(c){d.loading=!1;c.items.reverse().forEach(function(e){d.addItem(c.items[e],!0)})}}))};FeedController.prototype.addItem=function(c,d){d=void 0===d?!1:d;c=fQuery.createFromHtml(c);this.initItem(c);d?fQuery.prepend(this.column,c):this.column.appendChild(c)};
FeedController.prototype.setCompact=function(c,d,e){this.column.classList.toggle("compressed",e.checked);LocalStorageSet("feed_compressed",e.checked?"1":"0")};FeedController.prototype.expandItemBody=function(c,d){d.preventDefault();c=fQuery.closestParent(c,".feed_item");d=c.querySelector(".feed_body");var e=d.offsetHeight;d.classList.toggle("feed_body_expanded");var f=d.offsetHeight;d.classList.contains("feed_body_expanded")||0>c.getBoundingClientRect().top&&fQuery.scrollTop(f-e)};
FeedController.prototype.setShowSocialPosts=function(c,d,e){setCookie("social_site_posts",+e.checked,365)};FeedController.prototype.toggleOptions=function(){this.elements.options.classList.toggle("hidden")};App.AddController("feed",FeedController);var FolderController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(FolderController,Controller);FolderController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.groupId=this.element.dataset.groupId;this.folderId=this.element.dataset.folderId};FolderController.prototype.toggleShowAddStory=function(){this.elements.addStory.classList.toggle("hidden")};
FolderController.prototype.addStory=function(c){var d=this;new AjaxRequest({method:"POST",signed:!0,url:"/ajax/groups/"+this.groupId+"/folders/"+this.folderId+"/items",data:AjaxRequest.serializeForm(c),success:function(c){d.toggleShowAddStory()}})};App.AddController("folder",FolderController);var FormController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(FormController,Controller);FormController.prototype.submit=function(){this.element.hasAttribute("data-form-signed")&&SignForm(this.element);this.element.submit()};App.AddController("form",FormController);var ForumController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(ForumController,Controller);ForumController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.groupId=this.element.dataset.groupId};ForumController.prototype.toggleShowNewThread=function(){this.elements.newThread.classList.toggle("hidden")};
ForumController.prototype.postThread=function(c){(new AjaxRequest({method:"POST",button:c.querySelector("button[type=submit]"),spinner:c.querySelector("button[type=submit] i"),url:"/ajax/groups/"+this.groupId+"/threads",data:AjaxRequest.serializeForm(c),signed:!0})).then(function(c){window.location=c.url})};App.AddController("forum",ForumController);var GroupController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(GroupController,Controller);GroupController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.groupId=c.dataset.groupId};GroupController.prototype.join=function(c,d){d.preventDefault();new AjaxRequest({url:"/ajax/groups/"+this.groupId+"/membership",method:"POST",signed:!0,success:function(c){window.location=c.url}})};
GroupController.prototype.leave=function(c,d){d.preventDefault();new AjaxRequest({url:"/ajax/groups/"+this.groupId+"/membership",method:"DELETE",signed:!0,success:function(c){window.location=c.url}})};GroupController.prototype.toggleSettings=function(){this.elements.notificationSettings.classList.toggle("hidden")};
GroupController.prototype.saveSettings=function(c,d){var e=this;d.preventDefault();new AjaxRequest({url:"/ajax/groups/"+this.groupId+"/membership/settings",data:AjaxRequest.serializeForm(c),signed:!0,button:c.querySelector("button"),spinner:c.querySelector("button i"),success:function(c){e.elements.notificationSettings.classList.add("hidden")}})};App.AddController("group",GroupController);var GroupThreadController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(GroupThreadController,Controller);GroupThreadController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.threadId=c.dataset.threadId};GroupThreadController.prototype.toggleThreadSettings=function(){this.elements.threadSettings.classList.toggle("hidden")};
GroupThreadController.prototype.save=function(c,d){var e=this;d.preventDefault();new AjaxRequest({url:"/ajax/group-threads/"+this.threadId,method:"POST",signed:!0,button:c.querySelector(".button-submit"),spinner:c.querySelector(".button-submit i"),data:AjaxRequest.serializeForm(c),success:function(c){e.elements.threadSettings.classList.add("hidden")}})};
GroupThreadController.prototype.deleteThread=function(c,d){var e=this;StyledConfirm("Are you sure you wish to delete this thread?",function(){new AjaxRequest({url:"/ajax/group-threads/"+e.threadId,method:"DELETE",signed:!0,button:c,spinner:c.querySelector("i"),success:function(c){window.location=c.url}})})};App.AddController("group-thread",GroupThreadController);var ImageCropperController=function(){Controller.call(this);this.moving=!1;this.state="resize";this.p=this.lastMouse=this.mover=null;this.lastClick=0;this.position=new Vec2(50,50);this.anchor=this.nDelta=this.pDelta=this.direction=this.a=this.beginSize=this.beginPosition=null;this.resizeState="single";this.imageElement=this.moveOffset=null};$jscomp.inherits(ImageCropperController,Controller);
ImageCropperController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.aspectRatio=c.dataset.aspectRatio;this.size=new Vec2(150,1/this.aspectRatio*150);this.input=c.querySelector("input[type=file]");if("FileReader"in window){this.canvas=fQuery.createFromHtml('<div class="image-upload-preview image-cropper hidden" '+(this.element.hasAttribute("data-circle")?"data-circle":"")+'>\n\t\t\t\t\t<img />\n\t\t\t\t\t<div class="mover">\n\t\t\t\t\t\t<div class="centre">+</div>\n\t\t\t\t\t\t<div class="size"></div>\n\t\t\t\t\t\t<div class="anchors">\n\t\t\t\t\t\t\t<a data-anchor-x="0" data-anchor-y="0"></a>\n\t\t\t\t\t\t\t<a data-anchor-x="1" data-anchor-y="0"></a>\n\t\t\t\t\t\t\t<a data-anchor-x="0" data-anchor-y="1"></a>\n\t\t\t\t\t\t\t<a data-anchor-x="1" data-anchor-y="1"></a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>');
c=fQuery.createFromHtml('<div>\n\t\t\t\t\x3c!--<div class="message">Drag anchors to resize, hold shift to resize in all directions. Drag viewfinder to move.</div>--\x3e\n\t\t\t\t<input name="'+this.getInputName()+'_x" type="hidden" />\n\t\t\t\t<input name="'+this.getInputName()+'_y" type="hidden" />\n\t\t\t\t<input name="'+this.getInputName()+'_w" type="hidden" />\n\t\t\t\t<input name="'+this.getInputName()+'_h" type="hidden" />\n\t\t\t\t</div>');fQuery.prepend(this.element,this.canvas);fQuery.prepend(this.element,
c);this.mover=this.canvas.querySelector(".mover");this.imageElement=this.canvas.querySelector("img");this.imageElement.addEventListener("load",this.fitArea.bind(this,.9));this.input.addEventListener("change",this.setImage.bind(this));this.mouseMove=function(c){"resize"==d.state&&(d.updateResize(new Vec2(c.clientX-d.canvas.getBoundingClientRect().left,c.clientY-d.canvas.getBoundingClientRect().top)),c.preventDefault());"move"==d.state&&(d.updateMove(new Vec2(c.clientX-d.canvas.getBoundingClientRect().left,
c.clientY-d.canvas.getBoundingClientRect().top)),c.preventDefault())};this.touchMove=function(c){"resize"==d.state&&(d.updateResize(new Vec2(c.changedTouches[0].clientX-d.canvas.getBoundingClientRect().left,c.changedTouches[0].clientY-d.canvas.getBoundingClientRect().top)),c.preventDefault());"move"==d.state&&(d.updateMove(new Vec2(c.changedTouches[0].clientX-d.canvas.getBoundingClientRect().left,c.changedTouches[0].clientY-d.canvas.getBoundingClientRect().top)),c.preventDefault())};var e=this;fQuery.addScopedEventListener(this.element,
".anchors a","mousedown",function(c){e.beginResize(this);document.body.addEventListener("mousemove",e.mouseMove);c.preventDefault()});fQuery.addScopedEventListener(this.element,".anchors a","touchstart",function(c){e.beginResize(this);document.body.addEventListener("touchmove",e.touchMove);c.preventDefault()});document.addEventListener("mouseup",function(c){"resize"==d.state&&d.endResize();"move"==d.state&&d.endMove();document.body.removeEventListener("mousemove",d.mouseMove)});document.addEventListener("keydown",
function(c){c.shiftKey&&"single"==d.resizeState&&(d.resizeState="all","resize"==d.state&&d.beginResizeMode(d.resizeState))});document.addEventListener("keyup",function(c){c.shiftKey||"all"!=d.resizeState||(d.resizeState="single","resize"==d.state&&d.beginResizeMode(d.resizeState))});this.mover.addEventListener("mousedown",function(c){d.beginMove();document.addEventListener("mousemove",d.mouseMove);c.preventDefault()});this.mover.addEventListener("touchstart",function(c){d.beginMove();document.addEventListener("touchmove",
d.touchMove);c.preventDefault()});document.addEventListener("touchend",function(c){"resize"==d.state&&d.endResize();"move"==d.state&&d.endMove();document.removeEventListener("touchmove",d.touchMove)});this.mover.addEventListener("click",function(c){c=(new Date).getTime();300>c-d.lastClick&&d.fitArea(1);d.lastClick=c})}};ImageCropperController.prototype.getInputName=function(){return this.input.getAttribute("name")};ImageCropperController.prototype.showCanvas=function(){this.canvas.classList.remove("hidden")};
ImageCropperController.prototype.setImage=function(){null!=this.imageElement.src&&URL.revokeObjectURL(this.imageElement.src);this.imageElement.src=URL.createObjectURL(this.input.files[0]);this.showCanvas()};ImageCropperController.prototype.getCanvasWidth=function(){return this.canvas.offsetWidth};ImageCropperController.prototype.getCanvasHeight=function(){return this.canvas.offsetHeight};
ImageCropperController.prototype.fitArea=function(c){var d=this.getCanvasWidth()/this.getCanvasHeight();-1==this.aspectRatio?(w=this.getCanvasWidth()*c,h=this.getCanvasHeight()*c):d/this.aspectRatio<1/d/(1/this.aspectRatio)?(w=this.getCanvasWidth()*c,h=w/this.aspectRatio):(h=this.getCanvasHeight()*c,w=h*this.aspectRatio);this.size=new Vec2(w,h);this.position=new Vec2(this.getCanvasWidth()/2-w/2,this.getCanvasHeight()/2-h/2);this.render()};
ImageCropperController.prototype.beginResize=function(c){this.a=new Vec2(parseInt(c.dataset.anchorX,10),parseInt(c.dataset.anchorY,10));this.beginPosition=this.position.clone();this.beginSize=this.size.clone();this.state="resize";this.beginResizeMode(this.resizeState)};
ImageCropperController.prototype.beginResizeMode=function(c){this.anchor="all"==c?new Vec2(this.beginPosition.x+.5*this.beginSize.x,this.beginPosition.y+.5*this.beginSize.y):new Vec2(this.beginPosition.x+this.beginSize.x*(1-this.a.x),this.beginPosition.y+this.beginSize.y*(1-this.a.y));var d=new Vec2(this.beginPosition.x+this.beginSize.x*this.a.x,this.beginPosition.y+this.beginSize.y*this.a.y),e=new Vec2(this.beginPosition.x+this.beginSize.x*(1-this.a.x),this.beginPosition.y+this.beginSize.y*(1-this.a.y));
this.direction=Vec2.Subtract(d,this.anchor);this.pDelta=Vec2.Subtract(d,this.anchor);this.nDelta=Vec2.Subtract(e,this.anchor);this.resizeState=c;null!=this.lastMouse&&this.updateResize(this.lastMouse)};
ImageCropperController.prototype.updateResize=function(c){this.lastMouse=c;var d=ProjectPointToLine(this.anchor,Vec2.Add(this.anchor,this.direction),c),e=Vec2.Subtract(d,this.anchor),d=Math.min(0==this.pDelta.x?1E5:0<this.pDelta.x?(this.getCanvasWidth()-this.anchor.x)/this.pDelta.x:-this.anchor.x/this.pDelta.x,0==this.pDelta.y?1E5:0<this.pDelta.y?(this.getCanvasHeight()-this.anchor.y)/this.pDelta.y:-this.anchor.y/this.pDelta.y),f=Math.min(0==this.nDelta.x?1E5:0<this.nDelta.x?(this.getCanvasWidth()-
this.anchor.x)/this.nDelta.x:-this.anchor.x/this.nDelta.x,0==this.nDelta.y?1E5:0<this.nDelta.y?(this.getCanvasHeight()-this.anchor.y)/this.nDelta.y:-this.anchor.y/this.nDelta.y),e=e.Length()/this.pDelta.Length(),e=Math.min(e,d,f),d=Vec2.Add(this.anchor,Vec2.Multiply(this.nDelta,e)),f=Vec2.Add(this.anchor,Vec2.Multiply(this.pDelta,e));-1==this.aspectRatio&&(f=new Vec2(c.x,c.y));d=new Vec2(Math.min(this.getCanvasWidth(),Math.max(0,d.x)),Math.min(this.getCanvasHeight(),Math.max(0,d.y)));f=new Vec2(Math.min(this.getCanvasWidth(),
Math.max(0,f.x)),Math.min(this.getCanvasHeight(),Math.max(0,f.y)));c=new Vec2(Math.min(d.x,f.x),Math.min(d.y,f.y));d=new Vec2(Math.max(d.x,f.x),Math.max(d.y,f.y));this.position=c.clone();this.size=Vec2.Subtract(d,c);this.render()};ImageCropperController.prototype.endResize=function(){this.state="";this.lastMouse=null};ImageCropperController.prototype.beginMove=function(){this.state="move"};
ImageCropperController.prototype.updateMove=function(c){null===this.moveOffset&&(this.moveOffset=Vec2.Subtract(c,this.position));var d=new Vec2(0,0),e=new Vec2(this.getCanvasWidth()-this.size.x,this.getCanvasHeight()-this.size.y);this.position=Vec2.Subtract(c,this.moveOffset);this.position=new Vec2(Math.min(e.x,Math.max(d.x,this.position.x)),Math.min(e.y,Math.max(d.y,this.position.y)));this.render()};ImageCropperController.prototype.endMove=function(){this.state="";this.moveOffset=null};
ImageCropperController.prototype.render=function(){var c=Vec2.Int(this.position),d=Vec2.Int(this.size);this.mover.style.left=c.x-1+"px";this.mover.style.top=c.y-1+"px";this.mover.style.width=d.x+"px";this.mover.style.height=d.y+"px";if(null!=this.imageElement){c=Vec2.Int(new Vec2(this.size.x/this.getCanvasWidth()*this.imageElement.naturalWidth,this.size.y/this.getCanvasHeight()*this.imageElement.naturalHeight));d=Vec2.Int(new Vec2(this.position.x/this.getCanvasWidth()*this.imageElement.naturalWidth,
this.position.y/this.getCanvasHeight()*this.imageElement.naturalHeight));this.canvas.querySelector(".size").textContent=c.x+"px x "+c.y+"px";var e=fQuery.closestParent(this.canvas,"form");e.querySelector("input[name="+this.getInputName()+"_x]").value=d.x;e.querySelector("input[name="+this.getInputName()+"_y]").value=d.y;e.querySelector("input[name="+this.getInputName()+"_w]").value=c.x;e.querySelector("input[name="+this.getInputName()+"_h]").value=c.y}};App.AddController("image-cropper",ImageCropperController);var IndexController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(IndexController,Controller);
IndexController.prototype.bind=function(c){function d(c){var d=this.scrollTop,e=this.scrollHeight,f=this.offsetHeight,g=0<("DOMMouseScroll"==c.type?-40*c.detail:c.wheelDelta);this.classList.contains("fixed");if(!g&&d>=e-f||g&&0==d)return c.stopPropagation(),c.preventDefault(),!1}var e=this;Controller.prototype.bind.call(this,c);this.imageLoaderTimeout=null;this.imageLoadedMaxCallsPerSecond=10;window.addEventListener("loadVisibleImages",function(c){return e.loadVisibleImages(c.node)});c=function(){e.loadVisibleImages()};
window.addEventListener("resize",fQuery.throttle(c.bind(this),100));document.addEventListener("scroll",fQuery.throttle(c.bind(this),100));fQuery.load(c.bind(this));App.AddGlobalEventListener("click",".youtube_container",function(c){this.querySelector(".video").innerHTML='<iframe src="https://www.youtube.com/embed/'+this.getAttribute("data-id")+'?autoplay=1" frameborder="0" allowfullscreen></iframe>';c=this.querySelector(".placeholder");this.removeChild(c)});App.AddGlobalEventListener("click",".embed-container",
function(c){this.classList.add("expanded");this.querySelector(".video").innerHTML='<iframe src="'+this.getAttribute("data-src")+'" frameborder="0" allowfullscreen></iframe>';c=this.querySelector(".placeholder");this.removeChild(c)});var f=function(){""==this.value?this.classList.add("empty"):this.classList.remove("empty")};fQuery.addScopedEventListener(document,"form input","input",f);fQuery.ready(function(){for(var c=$jscomp.makeIterator(document.querySelectorAll("form input")),d=c.next();!d.done;d=
c.next())f.call(d.value)});App.AddGlobalEventListener("DOMMouseScroll",".scrollable",d);App.AddGlobalEventListener("mousewheel",".scrollable",d);window.addEventListener("storage",function(c){"font_size"==c.key&&(document.documentElement.style.fontSize=c.newValue+"px")},!1);(c=document.getElementById("view_mature_topbar"))&&c.addEventListener("change",function(c){var d=this;this.checked?StyledConfirm("Please confirm you are at least 18 years old by clicking ok. Click Cancel if this is not true.",function(){setCookie("view_mature",
!0,365);window.location.reload()},function(){d.checked=!1}):setCookie("view_mature",!1,365)});(c=document.getElementById("site-search-modes"))&&fQuery.addScopedEventListener(c,"a","click",function(c){c.preventDefault();document.getElementById("site-search").setAttribute("action",this.dataset.uri);document.getElementById("site-search-type").textContent=this.dataset.name});var g=document.querySelector("#site-search button");if(g){var k=!1;g.addEventListener("mousedown",function(c){2==c.which&&(k=!0)});
document.body.addEventListener("mouseup",function(c){fQuery.isOrChildOf(c.target,g)&&k&&(c=document.querySelector("#site-search"),c.setAttribute("target","_black"),c.submit());k=!1})}this.updateNavBarPin();window.addEventListener("storage",function(c){"pin_nav_bar"==c.key&&e.updateNavBarPin()});(c=this.element.querySelector("#pin_nav_bar"))&&c.addEventListener("click",function(){var c=LocalStorageGet("pin_nav_bar",0);LocalStorageSet("pin_nav_bar",0==c?1:0)});var l=document.querySelector(".page-tabs-container"),
m=document.querySelector(".page-tabs");document.querySelector(".page-tabs ul");var n=document.querySelector(".page-tabs > div"),p=document.querySelector(".page-tabs > div > span"),q=document.querySelector(".page-tabs .selected");q&&fQuery.load(function(){p.style.transform="translate("+(q.offsetLeft+q.offsetWidth/2)+"px,0px) scale("+q.offsetWidth/1+",1)"});fQuery.addScopedEventListener(document,".page-tabs li","click",function(c){if(c=this.dataset.tab)if(this.classList.contains("selected"))fQuery.scrollTop(l.getBoundingClientRect().top);
else{for(var d=$jscomp.makeIterator(document.querySelectorAll(".page-tabs li")),e=d.next();!e.done;e=d.next())e=e.value,e.classList.contains("selected")&&(e.setAttribute("data-scroll",fQuery.scrollTop()),e.classList.remove("selected"));this.classList.add("selected");d=this.getBoundingClientRect();d.right>window.innerWidth&&fQuery.animateProperty(function(c){n.scrollLeft=c},n.scrollLeft,n.scrollLeft+d.right-.75*window.innerWidth,.4,Curves.Cos);0>d.left&&fQuery.animateProperty(function(c){n.scrollLeft=
c},n.scrollLeft,n.scrollLeft+d.left-.25*window.innerWidth,.4,Curves.Cos);p.style.transform="translate("+(this.offsetLeft+this.offsetWidth/2)+"px,0px) scale("+this.offsetWidth/1+",1)";fQuery.removeClass(document.querySelectorAll(".tab-content"),"tab-content-selected");fQuery.addClass(document.querySelectorAll(".tab-content[data-tab="+c+"]"),"tab-content-selected");this.hasAttribute("data-scroll")?(c=this.getAttribute("data-scroll"),c<l.offsetTop&&(c=Math.max(c,Math.min(l.offsetTop,fQuery.scrollTop()))),
fQuery.scrollTop(c,!0)):fQuery.scrollTop()>l.offsetTop&&fQuery.scrollTop(l.getBoundingClientRect().top)}});null!=l&&"true"!=m.getAttribute("data-static")&&document.addEventListener("scroll",function(c){0<l.getBoundingClientRect().top?m.style.position="relative":(m.style.position="fixed",m.style.top="0px");m.style.zIndex="10"});(c=document.querySelector("#user_toolbar_toggle a"))&&c.addEventListener("click",function(c){c.preventDefault();App.GetControllerFromElement(document.querySelector(".navigation-drawer-container")).show()});
c=this.element.dataset.bookshelves;if(null!=c){c=JSON.parse(c);c=$jscomp.makeIterator(c);for(var t=c.next();!t.done;t=c.next())t=new Bookshelf(t.value.id),Library.getInstance().addBookshelf(t)}markupCode=function(){var c=document.querySelectorAll("code[class*=language]:not([data-prismified])");0<c.length&&fQuery.loadScript(static_url+"/js/prism.js?2").then(function(){Prism.plugins.customClass.prefix("prism--");Prism.plugins.autoloader.languages_path=static_url+"/js/grammars/";for(var d=$jscomp.makeIterator(c),
e=d.next();!e.done;e=d.next())e=e.value,Prism.highlightElement(e),e.dataset.prismified=!0})};markupCode();App.AddBinder(markupCode);App.AddBinder(function(){});var u=function(){this.naturalHeight>this.clientHeight?(this.setAttribute("data-resizable",!0),this.setAttribute("title","Resized to "+Math.round(this.clientHeight/this.naturalHeight*100)+"% of "+this.naturalWidth+"px \u00d7 "+this.naturalHeight+"px")):this.setAttribute("title",this.naturalWidth+"px \u00d7 "+this.naturalHeight+"px")};fQuery.addScopedEventListener(document.body,
".user_image","load",function(c){u.call(this)},!0);c=$jscomp.makeIterator(fQuery.nodesToArray(document.querySelectorAll(".user_image")));for(t=c.next();!t.done;t=c.next())u.call(t.value);"object"==typeof performance&&"object"==typeof performance.timing&&(c=document.getElementById("stat-page-load"))&&(c.textContent=Math.round(performance.timing.domInteractive-performance.timing.navigationStart)/1E3+" seconds")};
IndexController.prototype.updateNavBarPin=function(){toggleClass(document.body,"pin_nav_bar","1"==LocalStorageGet("pin_nav_bar","0"))};
IndexController.prototype.loadVisibleImages=function(c){c=void 0===c?null:c;null==c&&(c=document);var d=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,e=.3*d,f=-d*e,d=d+e;c=Array.from(c.getElementsByClassName("lazy-img"));for(var g,k,l=[],m=0;m<c.length;m++)e=c[m],l[m]=e.getBoundingClientRect();for(m=0;m<c.length;m++)e=c[m],g=l[m],0!=g.height&&0!=g.width&&(k=g.top,g=g.height,k+g>f&&k<d&&(e.addEventListener("load",function(c){this.classList.add("loaded")}),e.setAttribute("src",
e.getAttribute("data-src")),k=e.getAttribute("data-srcset"),null!=k&&e.setAttribute("srcset",k),e.classList.remove("lazy-img")));handlePwAds=function(){for(var c=$jscomp.makeIterator(document.querySelectorAll(".pw-ad-box")),d=c.next();!d.done;d=c.next())d=d.value,(d.offsetWidth<d.dataset.width||"none"==d.style.display)&&fQuery.removeElement(d)};handlePwAds();window.addEventListener("resize",fQuery.debounce(handlePwAds,200))};IndexController.prototype.toggleDebugger=function(){App.GetControllerFromElement(document.getElementById("debugger")).toggle()};
IndexController.prototype.logout=function(){new AjaxRequest({method:"POST",url:"/ajax/logout",signed:!1,success:function(c){window.location="/"}})};App.AddController("index",IndexController);var LocalSettingsController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(LocalSettingsController,Controller);
LocalSettingsController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.form=c.querySelector("form");this.inputs.show_interactive_pony.checked=1==LocalStorageGet("show_interactive_pony");this.inputs.show_chapter_progress_bar.checked=1==LocalStorageGet("show_chapter_progress_bar",1);this.inputs.font_size.value=LocalStorageGet("font_size",16);this.inputs.emojis.value=LocalStorageGet("emojis","");this.updateEmojiPreview()};
LocalSettingsController.prototype.setFontSize=function(c){LocalStorageSet("font_size",this.inputs.font_size.value)};
LocalSettingsController.prototype.setViewMature=function(c){var d=this;!this.inputs.view_mature.checked||null!=getCookie("view_mature")&&"true"==getCookie("view_mature")?setCookie("view_mature",this.inputs.view_mature.checked?!0:!1,365):StyledConfirm("Please confirm that you are at least 18 years of age by clicking OK. Click Cancel if this is not true.",function(){d.inputs.view_mature.checked=!0},function(){d.inputs.view_mature.checked=!1},function(){setCookie("view_mature",d.inputs.view_mature.checked?
!0:!1,365)})};LocalSettingsController.prototype.setShowInteractivePony=function(c){LocalStorageSet("show_interactive_pony",this.inputs.show_interactive_pony.checked?1:0)};LocalSettingsController.prototype.setShowChapterProgressBar=function(c){LocalStorageSet("show_chapter_progress_bar",this.inputs.show_chapter_progress_bar.checked?1:0)};LocalSettingsController.prototype.setEmojis=function(c){""==c?LocalStorageRemove("emojis"):LocalStorageSet("emojis",c);this.updateEmojiPreview()};
LocalSettingsController.prototype.updateEmojiPreview=function(){this.elements.emojiTest.innerHTML="\ud83d\ude00 \ud83d\ude03 \ud83d\ude04 \ud83d\ude01 \ud83d\ude06 \ud83d\ude05 \ud83d\ude02 \ud83e\udd23 \u263a \ud83d\ude0a";App.BindAll(this.elements.emojiTest)};App.AddController("local-settings",LocalSettingsController);var LoginController=function(){Controller.call(this);this.login_initalized=!1;this.ssl="https:"==document.location.protocol};$jscomp.inherits(LoginController,Controller);
LoginController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.siteUrl=c.dataset.site_url;c.querySelector("#login_submit").addEventListener("submit",function(c){c.preventDefault();"object"==typeof event&&(event.returnValue=!1);try{d.element.querySelector("#login_submit .error-message").classList.add("hidden"),document.querySelector("#login_button i").className="fa fa-spinner fa-spin",d.element.querySelector("#login_button").disabled=!0,(new AjaxRequest({url:"/ajax/login",
method:"POST",data:AjaxRequest.serializeFormToString(c.target),success:function(c){LocalStorageSet("signing_key",c.signing_key);d.doLoginRedirect()},fail:function(c){"otp_needed"==c.error||"otp_wrong"==c.error?(d.element.querySelector("#otp_entry").classList.remove("hidden"),d.element.querySelector("#username").setAttribute("readonly","readonly"),d.element.querySelector("#password").setAttribute("readonly","readonly"),d.element.querySelector("#otp").focus(),"otp_wrong"==c.error&&d.element.querySelector("#login_error_otp_wrong").classList.remove("hidden")):
d.element.querySelector("#login_error_"+c.error).classList.remove("hidden")}})).then(function(){document.querySelector("#login_button i").className="fa fa-sign-in";d.element.querySelector("#login_button").disabled=!1})}catch(f){alert("Javascript error on login:"+f)}return!1})};
LoginController.prototype.doLoginRedirect=function(){var c="http:"+this.siteUrl;try{0<document.referrer.length&&!/\/login/i.test(document.referrer)&&(c=document.referrer)}catch(d){}try{this.ssl&&(c=c.replace(/^http:/,"https:"))}catch(d){}window.location=c};App.AddController("login",LoginController);var LogoutController=function(){};LogoutController.prototype.logout=function(c){new AjaxRequest({method:"POST",url:"/ajax/logout",signed:!0,success:function(c){window.location="/"}})};App.AddController("logout",LogoutController);var MfaBackupCodesController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(MfaBackupCodesController,Controller);
MfaBackupCodesController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);c=this.elements.backupCodesFrame.contentWindow.document;c.open();c.write('\n\t\t\t<head>\n\t\t\t\t<link rel="stylesheet" href="'+static_url+'/css/mfa.css" type="text/css" />\n\t\t\t</head>\n\t\t\t<body>'+this.elements.backupCodes.innerHTML+"</body>");fQuery.removeElement(this.elements.backupCodes);c.close();this.elements.backupCodesFrame.contentWindow.focus();setTimeout(function(){d.elements.backupCodesFrame.style.height=
d.elements.backupCodesFrame.contentWindow.document.getElementById("mfa-backup-inner").offsetHeight+"px"},200)};MfaBackupCodesController.prototype.print=function(){this.elements.backupCodesFrame.contentWindow.print()};App.AddController("mfa-backup-codes",MfaBackupCodesController);var NavigationDrawerController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(NavigationDrawerController,Controller);
NavigationDrawerController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.config={openCloseSpeed:2E3,minimumSpeed:1800,leftMarginSize:.2,xMovementThreshold:25,lerpMultiplier:.3,friction:{exponent:2,minimum:.1}};this.opened=!1;this.drawer=this.element.querySelector(".navigation-drawer");this.x=-this.getDrawerWidth()||0;this.speed=0;var e=this;this.element.addEventListener("click",function(c){c.target==this&&e.hide()});this.lastX=this.deltaX=null;this.hadAttempt=this.slidingMode=
this.scrollMode=!1;this.lerpedSpeed=0;this.lastTime=Date.now();this.lastTouchTime=Date.now();this.lastRenderedX=null;document.addEventListener("scroll",function(c){d.slidingMode||(d.scrollMode=!0,d.hadAttempt=!0)},!0);this.touchStartPos=null;this.touchmove_handler=function(c){return d.move(c)};this.touchmove_bound=!1;document.body.addEventListener("touchstart",function(c){d.scrollMode=!1;d.hadAttempt=!1;d.deltaX=null;d.touchStartPos={x:c.changedTouches[0].pageX,y:c.changedTouches[0].pageY};d.lerpedSpeed=
0;d.touchmove_bound||(window.addEventListener("touchmove",d.touchmove_handler),d.touchmove_bound=!0)});document.body.addEventListener("touchend",function(c){d.touchmove_bound&&(window.removeEventListener("touchmove",d.touchmove_handler),d.touchmove_bound=!1);d.scrollMode=!1;d.slidingMode&&(document.body.classList.remove("unscrollable"),d.speed=d.lerpedSpeed,d.beginAnimation(),1>Math.abs(d.speed)?.5<d.getOpenedAmount()?d.show():d.hide():d.speed=0<d.speed?Math.min(1E4,Math.max(d.speed,d.config.minimumSpeed)):
Math.max(-1E4,Math.min(d.speed,-d.config.minimumSpeed)),d.slidingMode=!1)});this.lastY=0;this.step=function(){return d.updatePosition()};this.selectedTab="menu"};
NavigationDrawerController.prototype.move=function(c){this.lastX=this.x;var d=Math.abs(c.changedTouches[0].pageX-this.touchStartPos.x),e=Math.abs(c.changedTouches[0].pageY-this.touchStartPos.y);!this.scrollMode&&!this.hadAttempt&&d>this.config.xMovementThreshold&&(1.3*e<d&&(.05<this.getOpenedAmount()||this.touchStartPos.x/window.innerWidth<this.config.leftMarginSize)&&(null==this.deltaX&&(this.deltaX=c.changedTouches[0].pageX-this.x),this.slidingMode=!0),this.hadAttempt=!0);this.slidingMode&&(d=Date.now(),
e=(d-this.lastTouchTime)/1E3,this.lastTouchTime=d,this.speed=0,this.x=c.changedTouches[0].pageX-this.deltaX,this.lerpedSpeed+=((this.x-this.lastX)/e-this.lerpedSpeed)*this.config.lerpMultiplier,this.updatePosition(),c.preventDefault(),c.returnValue=!1)};NavigationDrawerController.prototype.getOpenedAmount=function(){return 1+this.x/this.getDrawerWidth()};NavigationDrawerController.prototype.getDrawerWidth=function(){return Math.min(320,Math.max(280,Math.floor(.8*window.innerWidth)))};
NavigationDrawerController.prototype.beginAnimation=function(){this.lastTime=Date.now();fQuery.animationFrame(this.step)};
NavigationDrawerController.prototype.updatePosition=function(){var c=Date.now(),d=(c-this.lastTime)/1E3;if(0==d)return!0;this.lastTime=c;0!=this.speed&&(c=1+this.x/this.getDrawerWidth(),c=0<this.speed?1-c:c,c=1-Math.pow(1-c,this.config.friction.exponent),c=Math.min(1,Math.max(this.config.friction.minimum,c)),this.x+=this.speed*c*d);this.x=Math.min(0,Math.max(-this.getDrawerWidth(),this.x));if(this.x==this.lastRenderedX)return!1;d=this.getOpenedAmount();c=this.x/this.getDrawerWidth()*100;this.drawer.style.msTransform=
"translate("+c+"%, 0)";this.drawer.style.webkitTransform="translate("+c+"%, 0)";this.drawer.style.transform="translate("+c+"%, 0)";this.element.style.background="rgba(0, 0, 0, "+.6*d+")";-90<c?this.element.classList.add("show"):this.element.classList.remove("show");d=this.lastRenderedX!=this.x;this.lastRenderedX=this.x;if(d!=this.x||0!=this.speed)return!0};
NavigationDrawerController.prototype.toggleAccountMenu=function(c,d){d=this.selectedTab;this.selectedTab=c.dataset.tab;c.dataset.tab=d;fQuery.addClass(this.element.querySelectorAll(".navigation-drawer-tab"),"hidden");this.element.querySelector('.navigation-drawer-tab[data-tab="'+this.selectedTab+'"]').classList.remove("hidden")};
NavigationDrawerController.prototype.setTab=function(c,d){this.selectedTab=c.dataset.tab;fQuery.addClass(this.element.querySelectorAll(".navigation-drawer-tab"),"hidden");this.element.querySelector('.navigation-drawer-tab[data-tab="'+this.selectedTab+'"]').classList.remove("hidden");App.DispatchEvent(this.element.querySelector('.navigation-drawer-tab[data-tab="'+this.selectedTab+'"]'),"tabSelected")};NavigationDrawerController.prototype.show=function(){this.speed=this.config.openCloseSpeed;this.beginAnimation()};
NavigationDrawerController.prototype.hide=function(){this.speed=-this.config.openCloseSpeed;this.beginAnimation()};NavigationDrawerController.prototype.toggle=function(){this.opened?(this.hide(),this.opened=!1):(this.hide(),this.opened=!0)};App.AddController("navigation-drawer",NavigationDrawerController);var NavBarController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(NavBarController,Controller);
NavBarController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);var e=null,f=this.elements.menu;fQuery.addScopedEventListener(f,"a","click",function(c){var d=fQuery.closestParent(this,"li"),e=d.querySelector("ul");d.classList.contains("hover")||null==e||(d.classList.add("hover"),App.DispatchEvent(d,"toolbar-hovered"),c.preventDefault())});fQuery.addScopedEventListener(f,"li","mouseover",function(c){var d=this;this.classList.contains("hover")?(clearTimeout(this.user_toolbar_timer_close),
this.user_toolbar_timer_close=null):(clearTimeout(e),e=setTimeout(function(){fQuery.removeClass(fQuery.siblings(d),"hover");d.classList.add("hover");App.DispatchEvent(d,"toolbar-hovered")},120))});fQuery.addScopedEventListener(f,"li","mouseout",function(c){var d=this;clearTimeout(e);this.classList.contains("hover")&&(this.user_toolbar_timer_close=setTimeout(function(){d.classList.remove("hover")},250))});fQuery.addScopedEventListener(c,".button-close","click",function(c){var d=fQuery.closestParent(this,
"li");d.classList.contains("hover")&&(c.preventDefault(),d.classList.remove("hover"))});this.elements.notificationsDropDown&&this.elements.notificationsDropDown.addEventListener("toolbar-hovered",function(){""==d.elements.notificationsDropDownContainer.innerHTML&&d.loadNotifications()});this.elements.privateMessagesDropDown&&this.elements.privateMessagesDropDown.addEventListener("toolbar-hovered",function(){""==d.elements.privateMessagesDropDownContainer.innerHTML&&d.loadPrivateMessages()});notifications.onCountsUpdated.addListener(function(c,
e,f){d.elements.numContentNotifications.textContent=c;toggleClass(d.elements.numContentNotifications.parentNode,"new",0<c);d.elements.numNotifications.textContent=e+f;toggleClass(d.elements.numNotifications.parentNode,"new",0<e+f)});is_logged_in&&(notifications.setContentNotifications(logged_in_user.num_content_notifications),notifications.setMetaNotifications(logged_in_user.num_meta_notifications),notifications.setSocialNotifications(logged_in_user.num_social_notifications))};
NavBarController.prototype.loadNotifications=function(){var c=this;this.elements.notificationsDropDownContainer.classList.add("loading");(new AjaxRequest({method:"get",url:"/ajax/notifications/list/drop-down",success:function(d){c.elements.notificationsDropDownContainer.innerHTML=d.content;notifications.setMetaNotifications(d.meta_notifications);notifications.setSocialNotifications(d.social_notifications);notifications.setContentNotifications(d.content_notifications)}})).then(function(){c.elements.notificationsDropDownContainer.classList.remove("loading")})};
NavBarController.prototype.loadPrivateMessages=function(){var c=this;this.elements.privateMessagesDropDownContainer.classList.add("loading");(new AjaxRequest({method:"get",url:"/ajax/private-messages/list/drop-down",success:function(d){c.elements.privateMessagesDropDownContainer.innerHTML=d.content}})).then(function(){c.elements.privateMessagesDropDownContainer.classList.remove("loading")})};
NavBarController.prototype.markAllNotificationsRead=function(c){var d=this;new AjaxRequest({method:"POST",url:"/ajax/notifications/mark-all-read",signed:!0,button:c,spinner:c.querySelector("i"),success:function(c){fQuery.removeClass(d.element.querySelectorAll(".notification"),"new");notifications.setContentNotifications(c.content_notifications);notifications.setMetaNotifications(c.meta_notifications);notifications.setSocialNotifications(c.social_notifications)}})};
NavBarController.prototype.markAllPrivateMessagesRead=function(c){new AjaxRequest({method:"POST",url:"/ajax/private-messages/mark-all-read",signed:!0,button:c,spinner:c.querySelector("i"),success:function(c){document.querySelector("#drop-down-private-messages li").classList.remove("new");document.querySelector(".mail-link").classList.remove("new")}})};
NavBarController.prototype.toggleSearch=function(){this.elements.menu.classList.toggle("hidden");this.elements.search.classList.toggle("hidden");this.elements.search.classList.contains("hidden")||App.GetControllerFromElement(this.elements.search.querySelector("form")).focus()};App.AddController("nav-bar",NavBarController);var NewCommentController=function(){Controller.call(this)};$jscomp.inherits(NewCommentController,Controller);NewCommentController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.form=this.element.querySelector("form")};NewCommentController.prototype.getBBCodeController=function(){return App.GetControllerFromElement(this.element.querySelector(".bbcode-editor"))};
NewCommentController.prototype.save=function(){var c=this.getBBCodeController();new AjaxRequest({url:this.form.getAttribute("action"),data:AjaxRequest.serializeForm(this.form),method:"POST",signed:!0,button:this.element.querySelector(".button-submit"),spinner:this.element.querySelector(".button-submit i"),success:function(d){c.setText("");d=fQuery.createFromHtml("<div class='single_comment'>"+d.comment+"</div>");App.GetControllerFromElement(document.querySelector(".comment_content_box")).appendNewComment(d)}})};
App.AddController("new-comment",NewCommentController);var NotificationsPageController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(NotificationsPageController,Controller);NotificationsPageController.prototype.toggleExpanded=function(c){c.classList.toggle("expanded");return!0};
NotificationsPageController.prototype.markRead=function(c){var d=this,e=c.dataset.identifier;new AjaxRequest({url:"/ajax/notifications/mark-all-read",data:{identifier:e},spinner:c.querySelector("i"),method:"POST",signed:!0,success:function(c){c=$jscomp.makeIterator(d.element.querySelectorAll('.notifications-list >li[data-identifier="'+e+'"]'));for(var f=c.next();!f.done;f=c.next()){f=f.value;f.classList.remove("new");for(var f=$jscomp.makeIterator(f.querySelectorAll("li")),k=f.next();!k.done;k=f.next())k.value.dataset.read=
"1"}}})};NotificationsPageController.prototype.markAllRead=function(){var c=this;new AjaxRequest({url:"/ajax/notifications/mark-all-read",method:"POST",signed:!0,success:function(d){fQuery.removeClass(c.element.querySelectorAll(".new"),"new");d=$jscomp.makeIterator(c.element.querySelectorAll(".expanded-list li"));for(var e=d.next();!e.done;e=d.next())e.value.dataset.read="1"}})};App.AddController("notifications-page",NotificationsPageController);var OEmbedController=function(){Controller.call(this);this.loading=this.embedded=!1};$jscomp.inherits(OEmbedController,Controller);OEmbedController.prototype.bind=function(c){return Controller.prototype.bind.call(this,c)};
OEmbedController.prototype.toggleEmbed=function(c,d){var e=this;d.preventDefault();c=this.element.querySelector("iframe");this.embedded=!this.embedded;this.elements.closeButton.classList.toggle("hidden",!this.embedded);c?c.classList.toggle("hidden",!this.embedded):0==this.loading&&(this.loading=!0,(new AjaxRequest({url:this.element.dataset.providerUri,data:{format:"json",url:this.element.dataset.url},success:function(c){var d=document.createElement("iframe"),f=/src="(https:\/\/w\.soundcloud\.com\/[^"]*)"/i.exec(c.html);
d.src=f[1];d.width=c.width;d.height=c.height;e.element.appendChild(d)}})).then(function(){e.loading=!1}))};App.AddController("oembed",OEmbedController);var OrderableController=function(){Controller.call(this);var c=this;this.mouseDragListener=function(d){c.drag(d.clientX,d.clientY)};this.touchDragListener=function(d){d.preventDefault();c.drag(d.changedTouches[0].clientX,d.changedTouches[0].clientY)};this.dragEndListener=function(d){c.endDrag()};this.selectedElement=null;this.ordered=!1;this.mouseOffsetY=this.mouseOffsetX=null};$jscomp.inherits(OrderableController,Controller);
OrderableController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);fQuery.addScopedEventListener(this.element,".draggable-handle","mousedown",function(c){d.beginDrag(fQuery.closestParent(c.target,".orderable-item"),c)});fQuery.addScopedEventListener(this.element,".draggable-handle","touchstart",function(c){d.beginDrag(fQuery.closestParent(c.target,".orderable-item"),c,!0)})};OrderableController.prototype.moveVertical=function(){return"false"!=this.element.dataset.vertical};
OrderableController.prototype.moveHorizontal=function(){return"false"!=this.element.dataset.horizontal};
OrderableController.prototype.beginDrag=function(c,d,e){e=void 0===e?!1:e;null==this.selectedElement&&1!=c.dataset.locked&&(this.selectedElement=c,this.draggingElement=this.selectedElement.querySelector(".draggable"),document.body.classList.add("unselectable"),this.selectedElement.classList.add("ordering"),this.draggingElement.classList.add("dragging"),e?(this.mouseOffsetX=d.changedTouches[0].clientX-this.selectedElement.getBoundingClientRect().left,this.mouseOffsetY=d.changedTouches[0].clientY-this.selectedElement.getBoundingClientRect().top,
document.addEventListener("touchmove",this.touchDragListener),document.addEventListener("touchend",this.dragEndListener)):(this.mouseOffsetX=d.clientX-this.selectedElement.getBoundingClientRect().left,this.mouseOffsetY=d.clientY-this.selectedElement.getBoundingClientRect().top,document.addEventListener("mousemove",this.mouseDragListener),document.addEventListener("mouseup",this.dragEndListener)))};OrderableController.prototype.getItems=function(){return this.element.querySelectorAll(".orderable-item")};
OrderableController.prototype.drag=function(c,d){if(null!=this.selectedElement){c-=this.mouseOffsetX;d-=this.mouseOffsetY;for(var e=this.draggingElement.getBoundingClientRect(),f=!0,g=$jscomp.makeIterator(this.getItems()),k=g.next();!k.done;k=g.next())if(k=k.value,k==this.selectedElement)f=!1;else{var l=k.getBoundingClientRect(),m=Math.max(e.left,l.left),n=Math.max(e.top,l.top),p=Math.min(e.right,l.right),q=Math.min(e.bottom,l.bottom);if(!(0>p-m||0>q-n)&&(q-n)*(p-m)>l.width*l.height/2){f?fQuery.insertBefore(k,
this.selectedElement):fQuery.insertAfter(k,this.selectedElement);this.ordered=!0;break}}d-=this.selectedElement.getBoundingClientRect().top;c-=this.selectedElement.getBoundingClientRect().left;this.moveVertical()||(d=0);this.moveHorizontal()||(c=0);this.draggingElement.style.transform="translate("+c+"px, "+d+"px)"}};
OrderableController.prototype.endDrag=function(){document.body.classList.remove("unselectable");this.selectedElement.classList.remove("ordering");this.draggingElement.classList.remove("dragging");document.removeEventListener("mousemove",this.mouseDragListener);document.removeEventListener("mouseup",this.dragEndListener);document.removeEventListener("touchmove",this.touchDragListener);document.removeEventListener("touchend",this.dragEndListener);this.draggingElement.style.top="0px";this.draggingElement.style.left=
"0px";this.draggingElement.style.transform="";this.selectedElement=null;this.ordered&&App.DispatchEvent(this.element,"orderChanged");this.ordered=!1};App.AddController("orderable",OrderableController);var EditBookshelfController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(EditBookshelfController,Controller);EditBookshelfController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.bookshelfId=c.dataset.bookshelfId;this.onSave=new EventBus;this.onCancel=new EventBus};EditBookshelfController.prototype.setBookshelf=function(c){this.bookshelf=c};
EditBookshelfController.prototype.save=function(c){var d=this,e=c.querySelector(".save-button"),f=e.querySelector("i");new AjaxRequest({url:"/ajax/bookshelves"+(0!=this.bookshelf.id?"/"+this.bookshelfId:""),method:"POST",button:e,spinner:f,signed:!0,data:AjaxRequest.serializeForm(c),success:function(c){d.bookshelf.id=c.id;d.bookshelf.updated(c);d.onSave.fire(c)}})};
EditBookshelfController.prototype.colour=function(c,d,e){fQuery.removeClass(this.element.querySelectorAll(".bookshelf-colours label"),"selected");this.elements.iconPreview.style.color="#"+c;e.parentNode.classList.add("selected")};EditBookshelfController.prototype.icon=function(c,d,e){fQuery.removeClass(this.element.querySelectorAll(".bookshelf-icons label"),"selected");this.elements.iconPreview.innerHTML=e.parentNode.querySelector("div").innerHTML;e.parentNode.classList.add("selected")};
EditBookshelfController.prototype.cancel=function(){this.onCancel.fire()};App.AddController("edit-bookshelf",EditBookshelfController);var Bookshelf=function(c){this.id=c;this.onUpdated=new EventBus};
Bookshelf.prototype.edit=function(){var c=this;return new Promise(function(d,e){e=0==c.id;var f=fQuery.createFromHtml("<div class='fullscreen-spinner'><i class='fa fa-pulse fa-spinner'></i></div>");document.body.appendChild(f);var g=new PopUpMenu("","<i class='fa fa-pencil'></i> "+(e?"New":"Edit")+" Bookshelf");g.SetWidth(650);g.SetCloseOnHoverOut(!1);g.SetCloseOnLinkPressed(!1);g.SetFixed(!1);g.ShowDimmer();new AjaxRequest({url:"/ajax/bookshelves/"+(e?"new":c.id+"/edit"),method:"GET",success:function(e){g.SetContent(e.content);
g.SetPosition();g.Show();fQuery.removeElement(f);App.BindAll(g.element);e=App.GetControllerFromElement(g.element.querySelector("form"));e.setBookshelf(c);e.onSave.addListener(function(c){d(c);g.Close()});e.onCancel.addListener(function(c){g.Close()})}})})};Bookshelf.prototype.updated=function(c){this.onUpdated.fire(c)};
Bookshelf.prototype.remove=function(){var c=this;StyledConfirm("Are you sure you want to delete this bookshelf?",function(){new AjaxRequest({url:"/ajax/bookshelves/"+c.id,method:"DELETE",signed:!0,success:function(d){Library.getInstance().removeBookshelf(c)}})});return!1};var Library=function(){this.bookshelves=new Map;this.onCreated=new EventBus;this.onDeleted=new EventBus;this.onBookshelfUpdated=new EventBus};
Library.getInstance=function(){null==Library.instance&&(Library.instance=new Library);return Library.instance};Library.prototype.addBookshelf=function(c){var d=this;this.bookshelves.set(c.id,c);c.onUpdated.addListener(function(e){d.onBookshelfUpdated.fire(c,e)})};Library.prototype.addNewBookshelf=function(c,d){this.addBookshelf(c);this.onCreated.fire(c,d)};Library.prototype.getBookshelf=function(c){return this.bookshelves.get(c)};
Library.prototype.removeBookshelf=function(c){this.bookshelves.delete(c.id);this.onDeleted.fire(c)};
Library.prototype.showAddToBookshelf=function(c){return new Promise(function(d,e){var f=fQuery.createFromHtml("<div class='fullscreen-spinner'><i class='fa fa-pulse fa-spinner'></i></div>");document.body.appendChild(f);var g=new PopUpMenu("","<i class='fa fa-book'></i> Add To Bookshelves");g.SetWidth(400);g.SetCloseOnHoverOut(!1);g.SetCloseOnLinkPressed(!1);g.ShowDimmer();g.LoadContent("/ajax/bookshelves/add-story-popup?story="+c,!0).then(function(){fQuery.removeElement(f);g.Show()});g.onClose.addListener(d)})};
Library.instance=null;var BookshelfSidebarController=function(c){OrderableController.apply(this,arguments)};$jscomp.inherits(BookshelfSidebarController,OrderableController);
BookshelfSidebarController.prototype.bind=function(c){var d=this;OrderableController.prototype.bind.call(this,c);Library.getInstance().onBookshelfUpdated.addListener(function(c,f){for(var e=$jscomp.makeIterator(d.element.querySelectorAll("li")),k=e.next();!k.done;k=e.next())k=k.value,k.dataset.id==c.id&&(k.outerHTML=f.sidebar_normal)});Library.getInstance().onCreated.addListener(function(c,f){d.element.appendChild(fQuery.createFromHtml(f.sidebar_normal))});Library.getInstance().onDeleted.addListener(function(c){for(var e=
$jscomp.makeIterator(d.element.querySelectorAll("li")),g=e.next();!g.done;g=e.next())g=g.value,g.dataset.id==c.id&&fQuery.removeElement(g)});fQuery.addScopedEventListener(this.element,"ul","orderChanged",fQuery.debounce(function(){var c=fQuery.nodesToArray(this.querySelectorAll("li")).map(function(c){return c.getAttribute("data-id")}),c=JSON.stringify(c);new AjaxRequest({method:"POST",url:"/ajax/bookshelves/order",data:{bookshelves:c},signed:!0})},2E3))};App.AddController("bookshelves-sidebar",BookshelfSidebarController);
var BookshelfLibraryController=function(c){OrderableController.apply(this,arguments)};$jscomp.inherits(BookshelfLibraryController,OrderableController);
BookshelfLibraryController.prototype.bind=function(c){var d=this;OrderableController.prototype.bind.call(this,c);Library.getInstance().onBookshelfUpdated.addListener(function(c,f){for(var e=$jscomp.makeIterator(d.element.querySelectorAll("li")),k=e.next();!k.done;k=e.next())k=k.value,k.dataset.id==c.id&&(k.outerHTML=f.card)});Library.getInstance().onCreated.addListener(function(c,f){c=d.element.querySelectorAll("li.orderable-item");c=0<c.length?c[c.length-1]:null;null!=c?fQuery.insertAfter(c,fQuery.createFromHtml(f.card)):
fQuery.prepend(d.element,fQuery.createFromHtml(f.card))});Library.getInstance().onDeleted.addListener(function(c){for(var e=$jscomp.makeIterator(d.element.querySelectorAll("li")),g=e.next();!g.done;g=e.next())g=g.value,g.dataset.id==c.id&&fQuery.removeElement(g)});fQuery.addScopedEventListener(this.element,"ul","orderChanged",function(){var c=fQuery.nodesToArray(this.querySelectorAll("li")).filter(function(c){return c.hasAttribute("data-id")}).map(function(c){return c.getAttribute("data-id")}),c=
JSON.stringify(c);new AjaxRequest({method:"POST",url:"/ajax/bookshelves/order",data:{bookshelves:c},signed:!0})})};BookshelfLibraryController.prototype.edit=function(c){c=fQuery.closestParent(c,"li").dataset.id;Library.getInstance().getBookshelf(c).edit()};BookshelfLibraryController.prototype.remove=function(c){c=fQuery.closestParent(c,"li[data-id]").dataset.id;Library.getInstance().getBookshelf(c).remove()};App.AddController("bookshelves-library",BookshelfLibraryController);
var BookshelfSidebarSelectedController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(BookshelfSidebarSelectedController,Controller);
BookshelfSidebarSelectedController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);Library.getInstance().onBookshelfUpdated.addListener(function(c,f){for(var e=$jscomp.makeIterator(d.element.querySelectorAll("li")),k=e.next();!k.done;k=e.next())k=k.value,k.dataset.id==c.id&&(k.outerHTML=f.sidebar)});Library.getInstance().onDeleted.addListener(function(c){for(var e=$jscomp.makeIterator(d.element.querySelectorAll("li")),g=e.next();!g.done;g=e.next())g.value.dataset.id==
c.id&&(window.location="/")})};BookshelfSidebarSelectedController.prototype.edit=function(c){c=fQuery.closestParent(c,"li").dataset.id;Library.getInstance().getBookshelf(c).edit()};BookshelfSidebarSelectedController.prototype.remove=function(c){c=fQuery.closestParent(c,"li").dataset.id;Library.getInstance().getBookshelf(c).remove()};App.AddController("bookshelves-sidebar-selected",BookshelfSidebarSelectedController);var BookshelfMobileHeaderController=function(c){Controller.apply(this,arguments)};
$jscomp.inherits(BookshelfMobileHeaderController,Controller);BookshelfMobileHeaderController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.id=c.dataset.id;Library.getInstance().onBookshelfUpdated.addListener(function(c,f){d.id==c.id&&(d.element.innerHTML=f.mobile_header)});Library.getInstance().onDeleted.addListener(function(c){d.id==c.id&&(window.location="/")})};BookshelfMobileHeaderController.prototype.edit=function(c){Library.getInstance().getBookshelf(this.id).edit()};
BookshelfMobileHeaderController.prototype.remove=function(c){Library.getInstance().getBookshelf(this.id).remove()};App.AddController("bookshelf-mobile-header",BookshelfMobileHeaderController);var BookshelvesToolbarDropdownController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(BookshelvesToolbarDropdownController,Controller);
BookshelvesToolbarDropdownController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);Library.getInstance().onBookshelfUpdated.addListener(function(c,f){for(var e=$jscomp.makeIterator(d.getListElements()),k=e.next();!k.done;k=e.next())k=k.value,k.dataset.id==c.id&&(k.outerHTML=f.drop_down_item)});Library.getInstance().onCreated.addListener(function(c,f){fQuery.insertBefore(d.elements.divider,fQuery.createFromHtml(f.drop_down_item))});Library.getInstance().onDeleted.addListener(function(c){for(var e=
$jscomp.makeIterator(d.getListElements()),g=e.next();!g.done;g=e.next())g=g.value,g.dataset.id==c.id&&fQuery.removeElement(g)})};BookshelvesToolbarDropdownController.prototype.getListElements=function(){return this.element.querySelectorAll("li[data-id]")};BookshelvesToolbarDropdownController.prototype.edit=function(c){c=fQuery.closestParent(c,"li[data-id]").dataset.id;Library.getInstance().getBookshelf(c).edit()};
BookshelvesToolbarDropdownController.prototype.remove=function(c){c=fQuery.closestParent(c,"li[data-id]").dataset.id;Library.getInstance().getBookshelf(c).remove()};App.AddController("bookshelves-toolbar-drop-down",BookshelvesToolbarDropdownController);function BookshelfItem(c,d,e){this.bookshelf=c;this.story=d;this.added=1==e}
BookshelfItem.prototype.Update=function(c){var d=this;if("undefined"!==typeof d.dom){if(d.dom.classList.contains("loading"))return;d.dom.classList.add("loading")}(new AjaxRequest({url:c?"/ajax/bookshelves/"+this.bookshelf+"/items":"/ajax/bookshelves/"+this.bookshelf+"/items/"+this.story,method:c?"POST":"DELETE",signed:!0,data:c?{story:this.story}:{},success:function(c){if("undefined"!==typeof d.dom){d.dom.setAttribute("data-added",c.added?"1":"0");d.dom.classList.remove("selected");d.dom.classList.remove("unselected");
d.dom.classList.add(c.added?"selected":"unselected");var e=d.dom.querySelector(".num_stories");null!=e&&(e.textContent=c.num_stories)}}})).then(function(){d.dom.classList.remove("loading")})};BookshelfItem.prototype.Add=function(){this.Update(!0)};BookshelfItem.prototype.Remove=function(){this.Update(!1)};var StoryBookshelvesController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(StoryBookshelvesController,Controller);
StoryBookshelvesController.prototype.toggle=function(c){var d=new BookshelfItem(c.getAttribute("data-bookshelf"),c.getAttribute("data-story"),c.dataset.added);d.dom=c;d.added?d.Remove():d.Add()};App.AddController("story-bookshelves",StoryBookshelvesController);App.AddGlobalEventListener("click",".show-bookshelves-popup",function(){Library.getInstance().showAddToBookshelf(this.getAttribute("data-story"))});var BookshelvesPopupListController=function(c){Controller.apply(this,arguments)};
$jscomp.inherits(BookshelvesPopupListController,Controller);BookshelvesPopupListController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.bookshelves=[].slice.call(this.element.querySelectorAll(".bookshelves-popup-list li"));Library.getInstance().onCreated.addListener(function(c,f){d.elements.list.appendChild(fQuery.createFromHtml(f.popup_item))})};
BookshelvesPopupListController.prototype.toggle=function(c,d){d=new BookshelfItem(c.getAttribute("data-bookshelf"),this.element.dataset.storyId,"1"==c.getAttribute("data-added"));d.dom=c;d.added?d.Remove():d.Add()};
BookshelvesPopupListController.prototype.createNew=function(c,d){d=c.querySelector("button");var e=d.querySelector("i");new AjaxRequest({url:"/ajax/bookshelves?story="+c.querySelector("[name=story]").value,method:"POST",signed:!0,spinner:e,button:d,data:AjaxRequest.serializeForm(c),success:function(c){var d=new Bookshelf(c.id);Library.getInstance().addNewBookshelf(d,c)}});return!1};
BookshelvesPopupListController.prototype.search=function(c){this.first_element=null;c=Search.characterSearch(this.bookshelves.map(function(c){return{item:c,text:c.querySelector(".name").textContent}}),c);fQuery.removeChildren(this.elements.list);c=$jscomp.makeIterator(c);for(var d=c.next();!d.done;d=c.next())this.elements.list.appendChild(d.value)};App.AddController("bookshelves-popup-list",BookshelvesPopupListController);
fQuery.addScopedEventListener(document,"[data-action=new-bookshelf]","click",function(){var c=new Bookshelf(0);c.edit().then(function(d){Library.getInstance().addNewBookshelf(c,d)})});var PaginatedTableController=function(){Controller.call(this);this.rows=[];this.headers=[]};$jscomp.inherits(PaginatedTableController,Controller);
PaginatedTableController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.rows=c.querySelectorAll("tbody > tr");this.num_items=this.rows.length;c.hasAttribute("data-num-per-page")&&(this.num_per_page=parseInt(c.getAttribute("data-num-per-page"),10));this.tbody=c.querySelector("tbody");this.calculateNumPages();this.renderPage();fQuery.addScopedEventListener(this.element,"a, input[type='checkbox'], input[type='radio']","click",function(c){c.stopPropagation();c.stopImmediatePropagation()});
fQuery.addScopedEventListener(this.element,"tbody tr","click",function(c){c=$jscomp.makeIterator(this.querySelectorAll("input[type='checkbox'], input[type='radio']"));for(var d=c.next();!d.done;d=c.next())d.value.click()});fQuery.addScopedEventListener(this.element,"input[type='checkbox']","change",function(c){c=c.target;c.checked?fQuery.closestParent(c,"tr").classList.add("selected"):fQuery.closestParent(c,"tr").classList.remove("selected");c=d.element.querySelectorAll("input[type='checkbox']:checked").length;
var e=d.element.querySelectorAll("input[type='checkbox']").length;d.elements.selected_info.innerHTML=c+" / "+e+" selected"});c=c.querySelectorAll("thead td");for(var e={i$137:0};e.i$137<c.length;e={i$137:e.i$137,sortType:e.sortType,secondarySortType:e.secondarySortType,secondarySortDirection:e.secondarySortDirection},e.i$137++){var f=c[e.i$137];this.headers.push(f);f.hasAttribute("data-sort-type")&&(e.sortType=f.getAttribute("data-sort-type"),e.secondarySortType=f.getAttribute("data-secondary-sort-type"),
e.secondarySortDirection=f.getAttribute("data-secondary-sort-direction"),f.addEventListener("click",function(c){return function(e){d.setSort(c.i$137,c.sortType,c.secondarySortType?c.secondarySortType:null,c.secondarySortDirection?c.secondarySortDirection:null)}}(e)),f.classList.add("sortable"))}};
PaginatedTableController.prototype.setSort=function(c,d,e,f){e=void 0===e?null:e;f=void 0===f?null:f;this.sortColumn===c?this.sortOrder="ASC"==this.sortOrder?"DESC":"ASC":(this.sortOrder="ASC",null!=this.sortColumn&&(this.headers[this.sortColumn].classList.remove("sort-asc"),this.headers[this.sortColumn].classList.remove("sort-desc")));this.sortColumn=c;"ASC"==this.sortOrder?(this.headers[this.sortColumn].classList.add("sort-asc"),this.headers[this.sortColumn].classList.remove("sort-desc")):(this.headers[this.sortColumn].classList.remove("sort-asc"),
this.headers[this.sortColumn].classList.add("sort-desc"));var g="ASC"==this.sortOrder?1:-1,k="ASC"==f?1:-1;this.rows=Array.prototype.slice.call(this.rows,0).map(function(f){var g=f.querySelector("td:nth-child("+(c+1)+")").getAttribute("data-sort-value"),k=f.querySelector("td:nth-child("+(c+1)+")").getAttribute("data-secondary-sort-value");"int"==d&&(g=parseInt(g,10));"string"==d&&(g=g.toLowerCase());"int"==e&&(k=parseInt(k,10));"string"==e&&(k=k.toLowerCase());return{row:f,value:g,secondaryValue:k}}).sort(function(c,
d){return c.value===d.value&&e?c.secondaryValue>d.secondaryValue?1*k:c.secondaryValue<d.secondaryValue?-1*k:0:c.value>d.value?1*g:c.value<d.value?-1*g:0}).map(function(c){return c.row});fQuery.removeChildren(this.tbody);f=$jscomp.makeIterator(this.rows);for(var l=f.next();!l.done;l=f.next())this.tbody.appendChild(l.value);this.renderPage()};PaginatedTableController.prototype.nextPage=function(){this.goToPage(this.page+1)};
PaginatedTableController.prototype.previousPage=function(){this.goToPage(this.page-1)};PaginatedTableController.prototype.firstPage=function(){this.goToPage(1)};PaginatedTableController.prototype.lastPage=function(){this.goToPage(this.num_pages)};PaginatedTableController.prototype.calculateNumPages=function(){this.num_pages=Math.ceil(this.num_items/this.num_per_page)};
PaginatedTableController.prototype.goToPage=function(c){this.page=parseInt(c,10);this.page>this.num_pages&&(this.page=this.num_pages);1>this.page&&(this.page=1);c=this.element.getBoundingClientRect();0>c.top&&fQuery.scrollTop(c.top,!1);this.renderPage()};
PaginatedTableController.prototype.renderPage=function(){this.elements.pageDisplay.value=this.page+" / "+this.num_pages;for(var c=(this.page-1)*this.num_per_page,d=0;d<this.num_items;d++)if(d>=c&&d<c+this.num_per_page){this.rows[d].classList.remove("hidden");var e=this.rows[d].querySelector(".row-count");e&&(e.textContent=d+1)}else this.rows[d].classList.add("hidden")};
PaginatedTableController.prototype.setNumPerPage=function(c){this.num_per_page=parseInt(c,10);this.calculateNumPages();this.goToPage(1);this.renderPage()};PaginatedTableController.prototype.page=1;PaginatedTableController.prototype.num_items=0;PaginatedTableController.prototype.num_per_page=10;PaginatedTableController.prototype.num_pages=0;PaginatedTableController.prototype.sortColumn=null;PaginatedTableController.prototype.sortOrder="ASC";App.AddController("paginated-table",PaginatedTableController);var PasswordController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(PasswordController,Controller);
PasswordController.prototype.update=function(c){var d="fimfiction twilightsparkle rarity fluttershy rainbowdash applejack pinkiepie mylittlepony brony".split(" "),e=this.elements.password.form,f=e.querySelector("input[name=name]");null!=f&&d.push(f.value);e=e.querySelector("input[name=email]");null!=e&&d.push(e.value);d=zxcvbn(c,d);this.elements.quality_meter.className=""==c?"password-quality-meter":"password-quality-meter password-quality-meter-"+d.score;2<=d.score?this.elements.password.setCustomValidity(""):
""!=c&&this.elements.password.setCustomValidity("Password needs to be stronger. Try adding some more characters/words")};App.AddController("password",PasswordController);var PasswordRepeatController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(PasswordRepeatController,Controller);
PasswordRepeatController.prototype.update=function(){var c=this.elements.input,d=this.elements.input.form.querySelector("input[type=password][data-password]");null!=d&&null!=c&&0<c.value.length&&(c.value==d.value?c.setCustomValidity(""):c.setCustomValidity("Password repeat must match password"))};App.AddController("password-repeat",PasswordRepeatController);var PostTableController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(PostTableController,Controller);PostTableController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.rows=[].slice.call(this.element.querySelectorAll("tbody tr"))};
PostTableController.prototype.search=function(c){var d=Search.termSearch(this.rows.map(function(c){return{item:c,text:[].slice.call(c.querySelectorAll(".search-text")).map(function(c){return c.textContent})}}),c);c=this.element.querySelector("tbody");fQuery.removeChildren(c);for(var e=document.createDocumentFragment(),d=$jscomp.makeIterator(d),f=d.next();!f.done;f=d.next())e.appendChild(f.value);c.appendChild(e)};App.AddController("post-table",PostTableController);var PrivateMessageBoxController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(PrivateMessageBoxController,Controller);PrivateMessageBoxController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);fQuery.addScopedEventListener(this.elements.list,"input","change",function(){d.updateSelected()})};
PrivateMessageBoxController.prototype.selectAll=function(c,d){d.preventDefault();c=$jscomp.makeIterator(this.elements.list.querySelectorAll("tr"));for(d=c.next();!d.done;d=c.next())d.value.querySelector("input").checked=!0;this.updateSelected()};PrivateMessageBoxController.prototype.selectNone=function(c,d){d.preventDefault();c=$jscomp.makeIterator(this.elements.list.querySelectorAll("tr"));for(d=c.next();!d.done;d=c.next())d.value.querySelector("input").checked=!1;this.updateSelected()};
PrivateMessageBoxController.prototype.selectInvert=function(c,d){d.preventDefault();c=$jscomp.makeIterator(this.elements.list.querySelectorAll("tr"));for(d=c.next();!d.done;d=c.next())d=d.value,d.querySelector("input").checked=!d.querySelector("input").checked;this.updateSelected()};
PrivateMessageBoxController.prototype.selectRead=function(c,d){d.preventDefault();c=$jscomp.makeIterator(this.elements.list.querySelectorAll("tr"));for(d=c.next();!d.done;d=c.next())d=d.value,d.querySelector("input").checked=!d.classList.contains("unread");this.updateSelected()};
PrivateMessageBoxController.prototype.selectUnread=function(c,d){d.preventDefault();c=$jscomp.makeIterator(this.elements.list.querySelectorAll("tr"));for(d=c.next();!d.done;d=c.next())d=d.value,d.querySelector("input").checked=d.classList.contains("unread");this.updateSelected()};
PrivateMessageBoxController.prototype.updateSelected=function(){var c=this.elements.list.querySelectorAll("input:checked").length;this.elements.numSelected.textContent=c+" selected";toggleClass(this.elements.numSelected,"hidden",0==c)};PrivateMessageBoxController.prototype.performAction=function(c,d){d.preventDefault();this.inputs.action.value=c.dataset.action;this.elements.form.submit()};App.AddController("private-message-box",PrivateMessageBoxController);var PrivateMessageConversationController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(PrivateMessageConversationController,Controller);
PrivateMessageConversationController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.privateMessageId=this.element.dataset.privateMessageId;this.beforeId=this.element.dataset.beforeId;this.hasEarlier="true"==this.element.dataset.hasEarlier;this.afterId=this.element.dataset.afterId;this.hasLater="true"==this.element.dataset.hasLater;setTimeout(function(){fQuery.scrollTop(d.elements.messageList.querySelector(".previous_message[data-jump]").getBoundingClientRect().top-
.2*window.innerHeight)},200);setTimeout(function(){d.elements.messageList.querySelector(".previous_message[data-jump]").classList.remove("highlighted")},2E3)};
PrivateMessageConversationController.prototype.sendReply=function(c,d){var e=this;d.preventDefault();new AjaxRequest({url:"/ajax/private-messages",method:"POST",signed:!0,button:c.querySelector(".button-submit"),spinner:c.querySelector(".button-submit i"),data:AjaxRequest.serializeForm(c),success:function(c){c=fQuery.createFromHtml("<div>"+c.content+"</div>");e.elements.messageList.appendChild(c);fQuery.scrollTop(c.getBoundingClientRect().top,!1,.3)}})};
PrivateMessageConversationController.prototype.showEarlierMessages=function(c){var d=this;new AjaxRequest({url:"/ajax/private-messages/"+this.privateMessageId+"/list?before="+this.beforeId,method:"GET",button:c,spinner:c.querySelector("i"),success:function(c){c.messages.reverse().forEach(function(c){fQuery.prepend(d.elements.messageList,fQuery.createFromHtml(c))});d.beforeId=c.before_id;c.has_earlier||(d.elements.previousMessages.classList.add("hidden"),d.hasEarlier=!1)}})};
PrivateMessageConversationController.prototype.showLaterMessages=function(c){var d=this;new AjaxRequest({url:"/ajax/private-messages/"+this.privateMessageId+"/list?after="+this.afterId,method:"GET",button:c,spinner:c.querySelector("i"),success:function(c){c.messages.forEach(function(c){d.elements.messageList.appendChild(fQuery.createFromHtml(c))});d.afterId=c.after_id;c.has_after||(d.elements.nextMessages.classList.add("hidden"),d.hasLater=!1)}})};
App.AddController("private-message-conversation",PrivateMessageConversationController);var RateStoryController=function(){Controller.call(this)};$jscomp.inherits(RateStoryController,Controller);
RateStoryController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.container=c;this.story_id=c.getAttribute("data-story");events.subscribe("/story/rate",function(c){if(c.id==d.story_id){var e=d.elements.like_button,g=d.elements.dislike_button,k=d.container;c=c.data;var l=c.likes,m=c.dislikes,n=c.disliked;c.liked?e.classList.add("like_button_selected"):e.classList.remove("like_button_selected");n?g.classList.add("dislike_button_selected"):g.classList.remove("dislike_button_selected");
-1!=l&&(k.querySelector(".likes").textContent=l,k.querySelector(".dislikes").textContent=m,k.querySelector(".like-bar").style.width=l/(l+m)*100+"%")}})};RateStoryController.prototype.like=function(){this.rateStory(100)};RateStoryController.prototype.dislike=function(){this.rateStory(0)};
RateStoryController.prototype.rateStory=function(c){var d=this,e=this.elements.like_button,f=this.elements.dislike_button;100==c?e.classList.add("like_button_selected"):e.classList.remove("like_button_selected");0==c?f.classList.add("dislike_button_selected"):f.classList.remove("dislike_button_selected");new AjaxRequest({method:"POST",url:"/ajax/stories/"+this.story_id+"/"+(50<=c?"like":"dislike"),signed:!0,success:function(c){events.publish("/story/rate",{id:d.story_id,data:c})}})};
App.AddController("rate-story",RateStoryController);var RelatedStoriesController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(RelatedStoriesController,Controller);RelatedStoriesController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.headerTabs=c.querySelectorAll(".header-tabs a");this.tabs=c.querySelectorAll(".tab")};
RelatedStoriesController.prototype.selectTab=function(c){c=c.getAttribute("data-tab");for(var d=$jscomp.makeIterator(this.headerTabs),e=d.next();!e.done;e=d.next())e=e.value,toggleClass(e,"selected",e.getAttribute("data-tab")==c);d=$jscomp.makeIterator(this.tabs);for(e=d.next();!e.done;e=d.next())e=e.value,toggleClass(e,"hidden",e.getAttribute("data-tab")!=c);App.DispatchEvent(document,"loadVisibleImages");c=this.element.getBoundingClientRect();0>c.top&&fQuery.scrollTop(c.top)};
App.AddController("related-stories",RelatedStoriesController);var ReportController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(ReportController,Controller);ReportController.prototype.setReason=function(c,d,e){toggleClass(this.elements.otherReason,"hidden","other"!=c);c=e.options[e.selectedIndex];c.hasAttribute("data-description")?(this.elements.reasonDescription.classList.remove("hidden"),this.elements.reasonDescription.textContent=c.dataset.description):this.elements.reasonDescription.classList.add("hidden")};App.AddController("report",ReportController);var SiteSearchController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(SiteSearchController,Controller);SiteSearchController.prototype.focus=function(){this.inputs.q.focus()};App.AddController("site-search",SiteSearchController);var SiteStatisticsController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(SiteStatisticsController,Controller);
SiteStatisticsController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.mlp_seasons={"Season 1":{from:new Date(2010,9,10),to:new Date(2011,4,6)},"Season 2":{from:new Date(2011,8,17),to:new Date(2012,3,21)},"Season 3":{from:new Date(2012,10,10),to:new Date(2013,1,16)},"Season 4":{from:new Date(2013,10,23),to:new Date(2014,4,10)},"Season 5":{from:new Date(2015,3,4),to:new Date(2015,10,28)},"Season 6":{from:new Date(2016,2,26),to:new Date(2016,9,22)},"Season 7":{from:new Date(2017,
4,15),to:new Date(2017,9,22)},"Equestria Girls":{from:new Date(2013,5,16),to:new Date(2013,5,16)},"Rainbow Rocks":{from:new Date(2014,8,27),to:new Date(2014,8,27)},"Friendship Games":{from:new Date(2015,8,26),to:new Date(2015,8,26)},"Legend of Everfree":{from:new Date(2016,9,1),to:new Date(2016,9,1)}};["/js/plugins/amcharts.js","/js/plugins/serial.js","/js/plugins/amstock.js","/js/plugins/xy.js"].reduce(function(c,d){return c.then(function(){return fQuery.loadScript(static_url+d)})},Promise.resolve()).then(function(){d.drawStoriesApprovedGraph(d.elements.storiesApproved);
d.drawBlogsPostedGraph(d.elements.blogsPosted);d.drawUsersJoinedGraph(d.elements.usersJoined)})};SiteStatisticsController.prototype.getGuides=function(){var c=[],d;for(d in this.mlp_seasons){var e=this.mlp_seasons[d];c.push({date:e.from,toDate:e.to,inside:!0,labelRotation:90,boldLabel:!0,fontSize:10,lineColor:"#CC0000",lineAlpha:.8,fillColor:"#CC0000",fillAlpha:.15,position:"left",label:d,above:!0,dashLength:2})}return c};
SiteStatisticsController.prototype.getGraph=function(c,d,e){AmCharts.makeChart(d,{theme:fimf_dual_axis_chart_theme,pathToImages:static_url+"/images/amcharts/",type:"stock",dataDateFormat:"YYYY-MM-DD",addClassNames:!0,categoryAxesSettings:{maxSeries:150,groupToPeriods:["DD","MM","YYYY"]},balloon:{textAlign:"left",fixedPosition:!1},chartCursorSettings:{animationDuration:0},dataSets:[{fieldMappings:[{fromField:"daily",toField:"daily"},{fromField:"aggregate",toField:"aggregate"}],dataProvider:c,categoryField:"date"}],
panels:[{guides:this.getGuides(),valueAxes:[{id:"column",title:"Views",position:"left"},{id:"line",title:"Accumulated Views",position:"right",gridThickness:0,minimum:0}],stockGraphs:[{animationPlayed:!0,id:"g1",type:"column",columnWidth:.8,valueField:"daily",fillAlphas:.8,lineAlpha:0,periodValue:"Sum",precision:0,useDataSetColors:!1,lineColor:e,valueAxis:"column",title:"Views",showBalloon:!1},{animationPlayed:!0,type:"line",valueField:"aggregate",fillAlphas:.3,lineAlpha:0,periodValue:"High",useDataSetColors:!1,
lineColor:e,valueAxis:"line",title:"Total views",balloonFunction:function(c,d){return"\n                                    <b>New:</b> "+AmCharts.formatNumber(c.dataContext.dailySum,{precision:-1,decimalSeparator:".",thousandsSeparator:","})+"<br/>\n                                    <b>Total:</b> "+AmCharts.formatNumber(c.dataContext.aggregateHigh,{precision:-1,decimalSeparator:".",thousandsSeparator:","})}}]}],chartScrollbarSettings:{graph:"g1",graphType:"line",usePeriod:"DD"}})};
SiteStatisticsController.prototype.drawStoriesApprovedGraph=function(c){c=JSON.parse(c.dataset.data);AmCharts.makeChart("chart-stories-posted",{theme:fimf_dual_axis_chart_theme,pathToImages:static_url+"/images/amcharts/",type:"stock",dataDateFormat:"YYYY-MM-DD",addClassNames:!0,categoryAxesSettings:{maxSeries:150,groupToPeriods:["DD","MM","YYYY"]},balloon:{textAlign:"left",fixedPosition:!1},chartCursorSettings:{animationDuration:0},dataSets:[{fieldMappings:[{fromField:"everyone",toField:"everyone"},
{fromField:"teen",toField:"teen"},{fromField:"mature",toField:"mature"}],dataProvider:c,categoryField:"date"}],panels:[{guides:this.getGuides(),valueAxes:[{id:"column",title:"Accumulated Views",position:"right",stackType:"regular"}],stockGraphs:[{animationPlayed:!0,type:"column",valueField:"mature",fillAlphas:.9,lineAlpha:0,title:"Mature",periodValue:"Sum",useDataSetColors:!1,lineColor:"#c03d2f",valueAxis:"column",showBalloon:!1},{animationPlayed:!0,type:"column",valueField:"teen",fillAlphas:.9,lineAlpha:0,
title:"Teen",periodValue:"Sum",useDataSetColors:!1,lineColor:"#ffb400",valueAxis:"column",showBalloon:!1},{animationPlayed:!0,type:"column",valueField:"everyone",fillAlphas:.9,lineAlpha:0,title:"Everyone",periodValue:"Sum",useDataSetColors:!1,lineColor:"#78ac40",valueAxis:"column",balloonFunction:function(c,e){return"\n                                    <b>Everyone:</b> "+AmCharts.formatNumber(c.dataContext.everyoneSum,{precision:-1,decimalSeparator:".",thousandsSeparator:","})+"<br/>\n                                    <b>Teen:</b> "+
AmCharts.formatNumber(c.dataContext.teenSum,{precision:-1,decimalSeparator:".",thousandsSeparator:","})+"<br/>\n                                    <b>Mature:</b> "+AmCharts.formatNumber(c.dataContext.matureSum,{precision:-1,decimalSeparator:".",thousandsSeparator:","})+"<hr/>\n                                    <b>Total:</b> "+AmCharts.formatNumber(c.dataContext.matureSum+c.dataContext.teenSum+c.dataContext.everyoneSum,{precision:-1,decimalSeparator:".",thousandsSeparator:","})}}]}],chartScrollbarSettings:{graph:"g1",
graphType:"line",usePeriod:"DD"}})};SiteStatisticsController.prototype.drawBlogsPostedGraph=function(c){c=JSON.parse(c.dataset.data);this.getGraph(c,"chart-blogs-posted","#6842d4")};SiteStatisticsController.prototype.drawUsersJoinedGraph=function(c){c=JSON.parse(c.dataset.data);this.getGraph(c,"chart-users-joined","#3fd440")};App.AddController("site-statistics",SiteStatisticsController);var StoryCardListController=function(){Controller.call(this);this.triggerTimeout=this.timer=this.last_columns=this.last_calc=null};$jscomp.inherits(StoryCardListController,Controller);
StoryCardListController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);window.addEventListener("resize",this.calculateStoryCardSizes.bind(this));window.addEventListener("load",this.calculateStoryCardSizes.bind(this));this.calculateStoryCardSizes(!0);c=$jscomp.makeIterator(this.element.querySelectorAll(".story_image"));for(var d=c.next();!d.done;d=c.next())d.value.addEventListener("load",this.calculateStoryCardSizes.bind(this))};
StoryCardListController.prototype.calculateStoryCardSizes=function(c){var d=this;(void 0===c?0:c)&&this._calculateStoryCardSizes(!0);clearTimeout(this.timer);this.timer=setTimeout(function(){d._calculateStoryCardSizes(!1);d.timer=null},100)};
StoryCardListController.prototype._calculateStoryCardSizes=function(c){var d=this.element.offsetWidth;if(this.last_calc!=this.element.offsetWidth||(void 0===c?0:c)){this.last_calc=this.element.offsetWidth;c=0;var e=[],f=[],d=Math.max(1,Math.floor(d/300));if(1!=d||1!=this.last_columns)if(this.last_columns=d,fQuery.css(this.element.querySelectorAll("li"),"width",100/d+"%"),1==d)fQuery.css(this.element.querySelectorAll(".story-card .story-card-content"),"paddingBottom",0);else for(var g=$jscomp.makeIterator(this.element.getElementsByClassName("story-card")),
k=g.next();!k.done;k=g.next())if(k=k.value,e[c]=k,f[c]=k.querySelector(".story-card-content"),c++,c==d){for(var l=k=c=0;l<d;l++){var m=""!=f[l].style.paddingBottom?parseInt(f[l].style.paddingBottom.replace("px","")):0;m=e[l].offsetHeight-m;m>k&&(k=m)}for(l=0;l<d;l++)m=""!=f[l].style.paddingBottom?parseInt(f[l].style.paddingBottom,10):0,f[l].style.paddingBottom=k-(e[l].offsetHeight-m)+"px"}}};App.AddController("story-card-list",StoryCardListController);var StoryCardController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(StoryCardController,Controller);
StoryCardController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.storyId=c.dataset.storyId;this.elements.dropDown.addEventListener("opened",function(){null==d.elements.dropDown.querySelector(".drop-down")&&d.elements.dropDown.appendChild(fQuery.createFromHtml('<div class="drop-down" style="width:13em;">\n                    <ul>\n                        <li><a href="/story/continue/'+d.storyId+'"><i class="fa fa-fw fa-arrow-right"></i> Read / Continue</a></li>\n                        <li class="divider"></li>'+
(is_logged_in?'\n                            <li><a data-click="showAddToBookshelf"><i class="fa fa-fw fa-book"></i> Add To Bookshelf</a></li>\n                            <li><a data-click="showAddToGroup"><i class="fa fa-fw fa-group"></i> Add To Group</a></li>\n                            ':"")+('\n                        <li><a href="/story/stats/'+d.storyId+'"><i class="fa fa-fw fa-bar-chart-o"></i> Statistics</a></li>                        \n                        <li class="divider"></li>\n                        <li><a href="/story/download/'+
d.storyId+'/txt"><i class="fa fa-fw fa-download"></i> Download .txt</a></li>\n                        <li><a href="/story/download/'+d.storyId+'/html"><i class="fa fa-fw fa-download"></i> Download .html</a></li>\n                        <li><a href="/story/download/'+d.storyId+'/epub"><i class="fa fa-fw fa-download"></i> Download .ePub</a></li>\n                    </ul>\n                </div>')))})};StoryCardController.prototype.showAddToGroup=function(){Group.showAddToGroup(this.storyId)};
StoryCardController.prototype.showAddToBookshelf=function(){Library.getInstance().showAddToBookshelf(this.storyId)};App.AddController("story-card",StoryCardController);var StoryContainerController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(StoryContainerController,Controller);
StoryContainerController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.story_id=c.getAttribute("data-story");this.stats_box=c.querySelector(".story_stats");this.elements.chapterList&&(this.chapterListController=App.GetControllerFromElement(this.elements.chapterList),this.chapterListController.eventChapterRead.addListener(function(c){d.elements.markAllReadButton.classList.toggle("chapter-read",c)}))};
StoryContainerController.prototype.submit=function(c,d){d.preventDefault();c=new PopUpMenu("","<i class='fa fa-cloud-upload'></i> Submit Story");c.LoadContent("/ajax/stories/"+this.story_id+"/submit-popup",!0);c.SetCloseOnHoverOut(!1);c.SetWidth(800);c.Show()};StoryContainerController.prototype.toggleRead=function(c){this.chapterListController.toggleAllRead(!c.classList.contains("chapter-read"),c.querySelector("i")).then(function(d){c.classList.toggle("chapter-read",d)})};
StoryContainerController.prototype.revoke=function(c,d){var e=this;d.preventDefault();StyledConfirm("Are you sure you wish to revoke this story? It'll have to be resubmitted again if you change your mind!",function(){new AjaxRequest({url:"/ajax/stories/"+e.story_id+"/status",method:"POST",spinner:c.querySelector("i"),button:c,signed:!0,data:{status:"revoke"},success:function(c){window.setTimeout("location.reload()",0)}})})};
StoryContainerController.prototype.addChapter=function(c,d){c=new PopUpMenu("","<i class='fa fa-file-text'></i> New Chapter");str="<form id='form-new-chapter'><input type='hidden' name='story' value='"+this.story_id+"' /><table class='properties'><tr><td class='label' style='width:140px;'>Chapter Name</td><td><input type='text' name='title' placeholder='Leave blank for auto-named chapter' /><br />Use <b>%i%</b> to insert the chapter number dynamically</td></tr></table></div><div class='drop-down-pop-up-footer'><button class='styled_button'><i class='fa fa-plus'></i> Add New Chapter</button></div></form>";
c.SetContent(str);c.SetCloseOnHoverOut(!1);c.SetWidth(550);c.Show();var e=this;c.element.querySelector("#form-new-chapter").addEventListener("submit",function(c){c.preventDefault();new AjaxRequest({url:"/ajax/stories/"+e.story_id+"/chapters",method:"POST",data:AjaxRequest.serializeForm(this),signed:!0,success:function(c){window.location=c.link}});return!1})};StoryContainerController.prototype.showAddToGroups=function(){Group.showAddToGroup(this.story_id)};
StoryContainerController.prototype.toggleFullDescription=function(c){this.element.querySelector(".description").classList.toggle("description_full");c.classList.toggle("description_expanded")};App.AddController("story-container",StoryContainerController);var GroupFolderStoriesController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(GroupFolderStoriesController,Controller);GroupFolderStoriesController.prototype.removeGroupItem=function(c){var d=c.getAttribute("data-group-item");StyledConfirm("Are you sure you want to delete this story?",function(){new AjaxRequest({url:"/ajax/group-items/"+d,method:"DELETE",signed:!0,success:function(d){d=fQuery.closestParent(c,"li");fQuery.removeElement(d)}})})};
App.AddController("group-folder-stories",GroupFolderStoriesController);var SearchOptionsController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(SearchOptionsController,Controller);SearchOptionsController.prototype.bind=function(c){Controller.prototype.bind.call(this,c)};SearchOptionsController.prototype.expand=function(){this.element.classList.add("expanded")};SearchOptionsController.prototype.toggleExpand=function(){this.element.classList.toggle("expanded")};App.AddController("search-options",SearchOptionsController);var StoryGroupsFeaturedController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(StoryGroupsFeaturedController,Controller);StoryGroupsFeaturedController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.storyId=this.element.dataset.storyId};
StoryGroupsFeaturedController.prototype.toggle=function(c){c.classList.add("loading");(new AjaxRequest({url:"/ajax/stories/"+this.storyId+"/featured-groups",method:"1"==c.dataset.featured?"DELETE":"POST",data:{group_id:c.dataset.group},success:function(d){c.dataset.featured=d.featured?"1":"0";d.featured?(c.classList.add("selected"),c.classList.remove("unselected")):(c.classList.remove("selected"),c.classList.add("unselected"))}})).then(function(){c.classList.remove("loading")})};
App.AddController("story-groups-featured",StoryGroupsFeaturedController);var StorySearchController=function(c){SearchOptionsController.apply(this,arguments)};$jscomp.inherits(StorySearchController,SearchOptionsController);
StorySearchController.prototype.bind=function(c){SearchOptionsController.prototype.bind.call(this,c);fQuery.on(c.querySelectorAll(".search_options input, .search_options select"),"focus",function(c){fQuery.closestParent(this,"label").classList.add("focus")});fQuery.on(c.querySelectorAll(".search_options input, .search_options select"),"blur",function(c){fQuery.closestParent(this,"label").classList.remove("focus")});this.tag_search_controller=App.GetControllerFromElement(c.querySelector(".tag-search"))};
StorySearchController.prototype.searchChanged=function(){this.inputs.order.value="relevance"};StorySearchController.prototype.include=function(c){c=fQuery.closestParent(c,"li");this.tag_search_controller.addTag(c.getAttribute("data-tag"),c.getAttribute("data-name"),!1)};StorySearchController.prototype.exclude=function(c){c=fQuery.closestParent(c,"li");this.tag_search_controller.addTag(c.getAttribute("data-tag"),c.getAttribute("data-name"),!0)};
StorySearchController.prototype.submit=function(c){for(var d=$jscomp.makeIterator(c.querySelectorAll("input")),e=d.next();!e.done;e=d.next())if(e=e.value,""==e.value||0==e.value)e.name="";c=$jscomp.makeIterator(c.querySelectorAll("select"));for(e=c.next();!e.done;e=c.next())d=e.value,0==d.value&&(d.name="");return!0};StorySearchController.prototype.toggleFilters=function(){toggleClass(this.elements.filters,"hidden")};App.AddController("story-search",StorySearchController);var StoryStatsController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(StoryStatsController,Controller);
StoryStatsController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.data=JSON.parse(this.element.dataset.data);["/js/plugins/amcharts.js","/js/plugins/serial.js","/js/plugins/amstock.js","/js/plugins/xy.js"].reduce(function(c,d){return c.then(function(){return fQuery.loadScript(static_url+d)})},Promise.resolve()).then(function(){d.drawChaptersGraph(d.data.chapters,d.elements.chaptersGraph);d.drawViewsGraph(d.data.stats.data,d.elements.viewsGraph);d.drawRatingsGraph(d.data.stats.data,
d.elements.ratingsGraph)});this.charts=[]};
StoryStatsController.prototype.drawChaptersGraph=function(c,d){AmCharts.makeChart(d.getAttribute("id"),{theme:fimf_dual_axis_chart_theme,pathToImages:static_url+"/images/amcharts/",type:"xy",dataDateFormat:"YYYY-MM-DD",addClassNames:!0,balloon:{textAlign:"left",animationDuration:.2},graphs:[{balloonText:'<b>[[title]]</b><hr /><i class="fa fa-calendar" style="margin-right:0.5em;"></i><b>[[x]]</b><br/>[[y]] views <b>&#xb7;</b> [[words_text]] words',bullet:"round",bulletSize:10,bulletAlpha:.5,labelText:"[[chapter_num]]",
lineAlpha:0,lineColor:"#008",fillAlphas:0,xField:"date",yField:"views"}],valueAxes:[{id:"views",axisAlpha:0,title:"Views"},{id:"date",axisAlpha:0,position:"bottom",type:"date",title:"Published Date"}],dataProvider:c})};
StoryStatsController.prototype.drawViewsGraph=function(c,d){var e=0;c=c.map(function(c){e+=c.views||0;return{date:c.date,views:c.views||0,views_accumulated:e}});for(var f=0,g=null,k=c.length-1;0<=k;k--)if(f+=c[k].views,1E3>f||k>c.length-50)g=c[k].date;var l=AmCharts.makeChart(d.getAttribute("id"),{theme:fimf_dual_axis_chart_theme,pathToImages:static_url+"/images/amcharts/",type:"stock",dataDateFormat:"YYYY-MM-DD",addClassNames:!0,categoryAxesSettings:{maxSeries:150,groupToPeriods:["DD","MM","YYYY"]},
balloon:{textAlign:"left",fixedPosition:!1},chartCursorSettings:{animationDuration:0},dataSets:[{fieldMappings:[{fromField:"views",toField:"views"},{fromField:"views_accumulated",toField:"views_accumulated"}],dataProvider:c,categoryField:"date"}],panels:[{guides:[{date:new Date(1E3*this.data.stats.first_chapter_date),toDate:new Date(1E3*this.data.stats.last_chapter_date),inside:!0,boldLabel:!0,fontSize:10,lineColor:"#CC0000",lineAlpha:.8,fillColor:"#CC0000",fillAlpha:.15,position:"left",label:"Publish period",
above:!0,dashLength:2}],valueAxes:[{id:"column",title:"Views",position:"left"},{id:"line",title:"Accumulated Views",position:"right",gridThickness:0,minimum:0,maximum:e}],stockGraphs:[{animationPlayed:!0,id:"g1",type:"column",columnWidth:.8,valueField:"views",fillAlphas:.8,lineAlpha:0,periodValue:"Sum",precision:0,useDataSetColors:!1,lineColor:"#3c6ab2",valueAxis:"column",title:"Views",showBalloon:!1},{animationPlayed:!0,type:"line",valueField:"views_accumulated",fillAlphas:.3,lineAlpha:0,periodValue:"High",
useDataSetColors:!1,lineColor:"#3c6ab2",valueAxis:"line",title:"Total views",balloonFunction:function(c,d){return"\n                                    <b>Views:</b> "+AmCharts.formatNumber(c.dataContext.viewsSum,{precision:-1,decimalSeparator:".",thousandsSeparator:","})+"<br/>\n                                    <b>Total:</b> "+AmCharts.formatNumber(c.dataContext.views_accumulatedHigh,{precision:-1,decimalSeparator:".",thousandsSeparator:","})}}]}],chartScrollbarSettings:{graph:"g1",graphType:"line",
usePeriod:"DD"}});this.charts.views=l;d=g.split("-");g=new Date(d[0],d[1]-1,d[2]);l.addListener("rendered",function(){l.zoom(g,new Date)})};
StoryStatsController.prototype.drawRatingsGraph=function(c,d){var e=0,f=0;c=c.map(function(c){e+=c.likes||0;f+=c.dislikes||0;return{date:c.date,likes:c.likes||0,total_likes:e,dislikes:-c.dislikes||0,total_dislikes:f,total:e-f}});for(var g=0,k=null,l=c.length-1;0<=l;l--)if(g+=c[l].likes+c[l].dislikes,200>g||l>c.length-50)k=c[l].date;var m=AmCharts.makeChart(d.getAttribute("id"),{theme:fimf_dual_axis_chart_theme,pathToImages:static_url+"/images/amcharts/",type:"stock",dataDateFormat:"YYYY-MM-DD",addClassNames:!0,
balloon:{textAlign:"left",fixedPosition:!1,borderColor:"#000000",borderAlpha:.5},chartCursorSettings:{animationDuration:0},categoryAxesSettings:{maxSeries:150,groupToPeriods:["DD","MM","YYYY"]},dataSets:[{fieldMappings:[{fromField:"likes",toField:"likes"},{fromField:"dislikes",toField:"dislikes"},{fromField:"total_likes",toField:"total_likes"},{fromField:"total_dislikes",toField:"total_dislikes"},{fromField:"total",toField:"total"}],dataProvider:c,categoryField:"date"}],panels:[{percentHeight:80,
guides:[{date:new Date(1E3*this.data.stats.first_chapter_date),toDate:new Date(1E3*this.data.stats.last_chapter_date),inside:!0,boldLabel:!0,fontSize:10,lineColor:"#CC0000",lineAlpha:.8,fillColor:"#CC0000",fillAlpha:.15,position:"left",label:"Publish period",above:!0,dashLength:2}],valueAxes:[{title:"Ratings",stackType:"regular",id:"column"},{title:"Ratings",stackType:"regular",id:"line",position:"right",gridThickness:0}],stockGraphs:[{id:"g1",type:"column",valueField:"likes",columnWidth:.8,fillAlphas:.8,
lineAlpha:0,periodValue:"Sum",useDataSetColors:!1,lineColor:"#080",title:"Likes",balloonFunction:function(c,d){return'\n                                    <i class="fa fa-thumbs-up" style="color:#080;"></i> '+AmCharts.formatNumber(c.dataContext.likesSum,{precision:-1,decimalSeparator:".",thousandsSeparator:","})+' <b>&#xb7;</b> <i class="fa fa-thumbs-down" style="color:#800;"></i> '+AmCharts.formatNumber(-c.dataContext.dislikesSum,{precision:-1,decimalSeparator:".",thousandsSeparator:","})+"<br/>\n                                    "},
valueAxis:"column"},{type:"column",columnWidth:.8,valueField:"dislikes",fillAlphas:.8,lineAlpha:0,periodValue:"Sum",useDataSetColors:!1,lineColor:"#800",title:"Dislikes",valueAxis:"column",showBalloon:!1}]},{percentHeight:20,showCategoryAxis:!1,valueAxes:[{title:"Ratings",stackType:"regular",id:"line",position:"right",gridThickness:0,minimum:0,maximum:f+e}],stockGraphs:[{type:"line",valueField:"total_dislikes",fillAlphas:.3,lineAlpha:0,periodValue:"High",useDataSetColors:!1,lineColor:"#800",title:"Total Dislikes",
valueAxis:"line",showBalloon:!1},{type:"line",valueField:"total_likes",fillAlphas:.3,lineAlpha:0,periodValue:"High",useDataSetColors:!1,lineColor:"#080",title:"Total Likes",valueAxis:"line",balloonFunction:function(c,d){return'\n                                    <i class="fa fa-thumbs-up" style="color:#080;"></i> '+AmCharts.formatNumber(c.dataContext.total_likesHigh,{precision:-1,decimalSeparator:".",thousandsSeparator:","})+' <b>&#xb7;</b> <i class="fa fa-thumbs-down" style="color:#800;"></i> '+
AmCharts.formatNumber(c.dataContext.total_dislikesHigh,{precision:-1,decimalSeparator:".",thousandsSeparator:","})+"<br/>\n                                    "}}]}],chartScrollbarSettings:{graph:"g1",usePeriod:"DD"}});this.charts.ratings=m;d=k.split("-");k=new Date(d[0],d[1]-1,d[2]);m.addListener("rendered",function(){m.zoom(k,new Date)})};StoryStatsController.prototype.setRange=function(c){this.charts[c.dataset.chart].zoom(new Date(1E3*c.dataset.start),new Date(1E3*c.dataset.end))};
App.AddController("story-stats",StoryStatsController);var TagSearchController=function(){Controller.call(this);this.selected_tag=null;this.showingDropdown=!1;this.inputMode="keyboard";this.mouseY=this.mouseX=0};$jscomp.inherits(TagSearchController,Controller);
TagSearchController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);var d=this;document.addEventListener("click",function(){d.hideDropDown()});this.elements.search.addEventListener("keydown",function(c){d.inputMode="keyboard";if(40==c.keyCode)d.selectNextTag();else if(38==c.keyCode)d.selectPreviousTag();else if(8==c.keyCode&&""==d.elements.search.value){var e=d.elements.selected_tags.querySelector("li:last-child");null!=e&&(e.parentNode.removeChild(e),c.preventDefault(),c.stopPropagation())}else 13==
c.keyCode&&d.showingDropdown&&(c.stopPropagation(),c.preventDefault(),null!=d.selected_tag&&d.selected_tag.click(),this.value="",d.hideDropDown())});this.elements.drop_down.addEventListener("mousemove",function(c){if(c.pageX!=d.mouseX||c.pageY!=d.mouseY)for(d.mouseX=c.pageX,d.mouseY=c.pageY,d.inputMode="mouse",c=c.target;null!=c;){if("LI"==c.tagName){d.setSelectedTag(c);break}c=c.parentNode}});fQuery.addScopedEventListener(this.elements.drop_down,"li","click",function(c){c.stopPropagation();c=d.elements.search.value;
d.addTag(this.getAttribute("data-tag"),this.getAttribute("data-name"),"-"==c.charAt(0));d.elements.search.value="";d.elements.search.focus();d.hideDropDown()});fQuery.addScopedEventListener(this.elements.selected_tags,"li","click",function(c){if("remove"!=c.target.className){this.classList.toggle("excluded");var d=this.querySelector("input");this.classList.contains("excluded")?d.value.startsWith("-")||(d.value="-"+d.value):d.value.startsWith("-")&&(d.value=d.value.substr(1));c.stopPropagation()}});
this.tags=[].slice.call(this.elements.drop_down.querySelectorAll("li"))};TagSearchController.prototype.removeTag=function(c,d){c=c.parentNode.parentNode;c.parentNode.removeChild(c)};
TagSearchController.prototype.createTag=function(c,d,e){var f=document.createElement("li");f.setAttribute("data-tag",c);var g=document.createElement("span");g.textContent=d;f.appendChild(g);d=document.createElement("div");d.className="buttons";g=document.createElement("a");g.className="remove";g.setAttribute("data-click","removeTag");d.appendChild(g);f.appendChild(d);d=document.createElement("input");d.type="hidden";d.name="tags[]";d.value=(e?"-":"")+c;f.appendChild(d);e&&f.classList.add("excluded");
return f};TagSearchController.prototype.addTag=function(c,d,e){for(var f=$jscomp.makeIterator(this.elements.selected_tags.querySelectorAll("li")),g=f.next();!g.done;g=f.next())if(g.value.getAttribute("data-tag")==c)return;this.elements.selected_tags.appendChild(this.createTag(c,d,e))};TagSearchController.prototype.hideDropDown=function(){this.elements.drop_down.classList.add("hidden");this.showingDropdown=!1};
TagSearchController.prototype.showDropDown=function(){this.showingDropdown||this.setSelectedTag(null);this.elements.drop_down.classList.remove("hidden");this.showingDropdown=!0};
TagSearchController.prototype.search=function(c){var d=c.toLowerCase();"-"==d.charAt(0)&&(d=d.substr(1));c=null;c=""!=d?this.tags.map(function(c){var e=0,f=c.getAttribute("data-name").toLowerCase();for(idx=f.indexOf(d);-1!=idx;)e=0==idx?Math.max(e,10):" "==f.charAt(idx-1)?Math.max(e,9):Math.max(e,idx/f.length),idx=f.indexOf(d,idx+1);return{tag:c,score:e}}).filter(function(c){return 0<c.score}).sort(function(c,d){return c.score==d.score?0:c.score>d.score?-1:1}).map(function(c){return c.tag}):this.tags;
fQuery.removeChildren(this.elements.drop_down);c=$jscomp.makeIterator(c);for(var e=c.next();!e.done;e=c.next())this.elements.drop_down.appendChild(e.value);this.showDropDown();null!=this.selected_tag&&null!=this.selected_tag.parentNode||this.setSelectedTag(this.elements.drop_down.querySelector("li"))};
TagSearchController.prototype.selectNextTag=function(){this.showDropDown();if(null==this.selected_tag)this.setSelectedTag(this.elements.drop_down.querySelector("li:not(.hidden)"));else if(null!=this.selected_tag.nextElementSibling){var c=this.selected_tag;do c=c.nextElementSibling;while(c.classList.contains("hidden"));this.setSelectedTag(c)}};
TagSearchController.prototype.selectPreviousTag=function(){this.showDropDown();if(null!=this.selected_tag&&null!=this.selected_tag.previousElementSibling){var c=this.selected_tag;do c=c.previousElementSibling;while(c.classList.contains("hidden"));this.setSelectedTag(c)}};
TagSearchController.prototype.setSelectedTag=function(c){null!=this.selected_tag&&this.selected_tag.classList.remove("selected");this.selected_tag=c;null!=this.selected_tag&&(this.selected_tag.classList.add("selected"),"keyboard"==this.inputMode&&(c=this.selected_tag.offsetTop-this.elements.drop_down.getBoundingClientRect().height/2+this.selected_tag.getBoundingClientRect().height/2,this.elements.drop_down.scrollTop=c))};App.AddController("tag-search",TagSearchController);var TagStoriesGraphController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(TagStoriesGraphController,Controller);
TagStoriesGraphController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);var e=0;this.data=JSON.parse(this.element.dataset.data).map(function(c){e+=c.stories;c.total_stories=e;return c});fQuery.loadScript(static_url+"/js/plugins/amcharts.js").then(function(){return fQuery.loadScript(static_url+"/js/plugins/serial.js")}).then(function(){return fQuery.loadScript(static_url+"/js/plugins/amstock.js")}).then(function(){AmCharts.makeChart(d.element.getAttribute("id"),{theme:fimf_dual_axis_chart_theme,
pathToImages:static_url+"/images/amcharts/",type:"stock",dataDateFormat:"YYYY-MM-DD",addClassNames:!0,categoryAxesSettings:{maxSeries:100,groupToPeriods:["DD","MM","YYYY"]},dataSets:[{fieldMappings:[{fromField:"stories",toField:"stories"},{fromField:"total_stories",toField:"total_stories"}],dataProvider:d.data,categoryField:"date"}],panels:[{valueAxes:[{id:"column",title:"Stories",position:"left",showLabels:!1,gridThickness:0},{id:"line",title:"Stories",position:"right"}],stockGraphs:[{id:"g1",type:"column",
valueField:"stories",fillAlphas:.8,lineAlpha:0,periodValue:"Sum",precision:0,useDataSetColors:!1,lineColor:"#3c6ab2",valueAxis:"column",showBalloon:!0},{type:"line",valueField:"total_stories",fillAlphas:.3,lineAlpha:0,periodValue:"High",precision:0,useDataSetColors:!1,lineColor:"#3c6ab2",valueAxis:"line",showBalloon:!1}]}],chartScrollbarSettings:{graph:"g1",graphType:"line",usePeriod:"DD"}})})};App.AddController("tag-stories-graph",TagStoriesGraphController);var ThreadListController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(ThreadListController,Controller);ThreadListController.prototype.markRead=function(c){return!0};
ThreadListController.prototype.goToPage=function(c){var d=new PopUpMenu("","<i class='fa fa-question-circle'></i> Go To Page");d.SetCloseOnHoverOut(!1);d.SetFixed(!0);d.SetContent('\n            <form id="form-go-to-page">\n                <center style="padding:10px;">\n                    <input type="number" id="go-to-page-input" style="width:100%" />\n                </center>\n                <div class="drop-down-pop-up-footer"><center><button class=\'styled_button\' data-confirm-button>Confirm</button><button data-cancel-button class=\'styled_button styled_button_red\'>Cancel</button></center></div>\n            </form>');d.SetCloseOnHoverOut(!1);
d.SetWidth(200);d.Show();d.element.querySelector("#form-go-to-page").addEventListener("submit",function(e){e.preventDefault();window.location=c.dataset.baseUrl+"?page="+document.getElementById("go-to-page-input").value;d.Close()});d.element.querySelector("[data-cancel-button]").addEventListener("click",function(c){c.preventDefault();c.stopPropagation();d.Close()})};App.AddController("thread-list",ThreadListController);var TimeController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(TimeController,Controller);TimeController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.date=new Date(this.element.getAttribute("datetime"));this.mode=this.element.dataset.mode;switch(this.mode){case "countdown":case "delta":this.updateDelta();setInterval(this.updateDelta.bind(this),1E3);break;case "short":this.renderShort();break;case "long":this.renderLong()}};
TimeController.prototype.updateDelta=function(){var c=new Date,c="countdown"==this.mode?Math.max(0,this.date-c):Math.abs(this.date-c),d=Math.floor(c/1E3)%60,e=Math.floor(c/6E4)%60;this.element.innerHTML='<span class="datetime__digit">'+Math.floor(c/864E5)+'</span>d <span class="datetime__digit">'+Math.floor(c/36E5)%24+'</span>h <span class="datetime__digit">'+(10>e?"0"+e:e)+'</span>m <span class="datetime__digit">'+(10>d?"0"+d:d)+"</span>s"};
TimeController.prototype.renderShort=function(){new Intl.DateTimeFormat("en",{month:"long",day:"numeric",year:"numeric"})};TimeController.prototype.renderLong=function(){new Intl.DateTimeFormat("en",{month:"long",day:"numeric",year:"numeric"})};App.AddController("time",TimeController);var UserPageController=function(){Controller.call(this);var c=this;this.editing=!1;this.mouseOffsetY=this.mouseOffsetX=this.draggingElement=this.selectedElement=this.currentEditMenu=null;this.dragListener=function(d){c.drag(d)};this.dragEndListener=function(d){c.endDrag()};this.dirty=!1;AddHashCallback("edit",this.toggleEditing.bind(this))};$jscomp.inherits(UserPageController,Controller);
UserPageController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.containers=this.element.querySelector(".columns").getElementsByClassName("module_container");this.editingButton=this.element.querySelector("#user_page_editing_button");this.editingToolbar=this.element.querySelector("#user_page_editing_toolbar");this.leftColumn=this.element.querySelector("#left_column");this.rightColumn=this.element.querySelector("#right_column");this.userId=this.element.dataset.userId;
this.setDirty(!1);fQuery.addScopedEventListener(this.element,".module-drag-overlay","mousedown",function(c){d.beginDrag(fQuery.closestParent(c.target,".module_container"),c)})};UserPageController.prototype.setDirty=function(c){this.dirty=void 0===c?!0:c;if(c=this.element.querySelector("#module_order_form button"))c.disabled=!this.dirty};
UserPageController.prototype.beginDrag=function(c,d){null==this.selectedElement&&this.editing&&!c.classList.contains("module_locked")&&(this.selectedElement=c,this.selectedElement.classList.add("module_currently_dragging"),this.mouseOffsetX=d.clientX-this.selectedElement.getBoundingClientRect().left,this.mouseOffsetY=d.clientY-this.selectedElement.getBoundingClientRect().top,document.body.classList.add("unselectable"),this.draggingElement=this.selectedElement.querySelector(".module"),document.addEventListener("mousemove",
this.dragListener),document.addEventListener("mouseup",this.dragEndListener))};UserPageController.prototype.endDrag=function(){this.draggingElement.style.top="0px";document.removeEventListener("mousemove",this.dragListener);document.removeEventListener("mouseup",this.dragEndListener);this.selectedElement.classList.remove("module_currently_dragging");document.body.classList.remove("unselectable");this.draggingElement=this.selectedElement=null};
UserPageController.prototype.drag=function(c){var d=!1,e=0;if(null!=this.selectedElement)for(var f=null!=fQuery.closestParent(this.selectedElement,".left_column")?0:1,g=this.leftColumn.getBoundingClientRect(),k=this.rightColumn.getBoundingClientRect();0==d&&10>e;){d=!0;e++;var l=c.clientY-this.mouseOffsetY-this.selectedElement.getBoundingClientRect().top;this.selectedElement.getBoundingClientRect();var m=this.selectedElement.nextElementSibling,n=this.selectedElement.previousElementSibling;m&&l>m.offsetHeight/
2+10&&!m.classList.contains("module_locked")&&(fQuery.insertAfter(m,this.selectedElement),d=!1);n&&l<-n.offsetHeight/2-10&&!n.classList.contains("module_locked")&&(fQuery.insertBefore(n,this.selectedElement),d=!1);c.clientX>g.right+20&&0==f&&"1"==this.selectedElement.dataset.columnSmall&&(this.rightColumn.appendChild(this.selectedElement),d=!1,f=1);c.clientX<k.left-20&&1==f&&"1"==this.selectedElement.dataset.columnBig&&(this.leftColumn.appendChild(this.selectedElement),d=!1,f=1);d||this.setDirty();
this.draggingElement.style.top=l+"px"}};
UserPageController.prototype.showAddModule=function(c,d){var e=this;c=c.dataset.type;d=new PopUpMenu("","<i class='fa fa-pencil'></i> Create New Module");d.SetWidth(750);d.SetCloseOnHoverOut(!1);d.SetCloseOnLinkPressed(!1);d.SetContent("<div style='text-align:center;'><i class='fa fa-spin fa-spinner' style='font-size:50px; margin:20px; color:#777;'></i></div>");d.LoadContent("/ajax/users/modules/new?type="+c,!0).then(function(c){c.element.querySelector("form").addEventListener("submit",function(c){e.createModule(c.target,
c)})},function(c){c.Close()});d.SetFixed(!0);d.Show();this.currentEditMenu=d};UserPageController.prototype.toggleEditing=function(){this.editing=!this.editing;fQuery.toggleClass(this.containers,"module_editing",this.editing);toggleClass(this.editingButton,"hidden",this.editing);toggleClass(this.editingToolbar,"hidden",!this.editing)};
UserPageController.prototype.saveLayout=function(c,d){var e=this;d.preventDefault();c=c.querySelector("button");d=Array.prototype.map.call(this.element.querySelectorAll(".left_column .module_id_input"),function(c){return c.value}).join(",");var f=Array.prototype.map.call(this.element.querySelectorAll(".right_column .module_id_input"),function(c){return c.value}).join(",");(new AjaxRequest({url:"/ajax/users/"+this.userId+"/modules/order",action:"POST",signed:!0,button:c,spinner:c.querySelector("i"),
data:{left_column:d,right_column:f},success:function(c){}})).then(function(){e.setDirty(!1)})};
UserPageController.prototype.saveModule=function(c,d){var e=this;d.preventDefault();d=c.querySelector("input[name=id]").value;var f=this.element.querySelector("#module"+d);new AjaxRequest({url:c.getAttribute("action"),method:c.getAttribute("method"),signed:!0,button:c.querySelector("button[type=submit]"),spinner:c.querySelector("button[type=submit] i"),data:AjaxRequest.serializeForm(c),success:function(c){f.querySelector(".module-content").innerHTML=c.content;e.currentEditMenu.Close()}})};
UserPageController.prototype.createModule=function(c,d){var e=this;d.preventDefault();new AjaxRequest({url:c.getAttribute("action"),method:c.getAttribute("method"),signed:!0,button:c.querySelector("button[type=submit]"),spinner:c.querySelector("button[type=submit] i"),data:AjaxRequest.serializeForm(c),success:function(c){c=fQuery.createFromHtml(c.content);c.classList.add("module_editing");e.leftColumn.appendChild(c);e.currentEditMenu.Close()}})};
UserPageController.prototype.deleteModule=function(c,d){fQuery.removeElement(this.element.querySelector("#module"+c.dataset.module));this.setDirty()};
UserPageController.prototype.showEditModule=function(c,d){var e=this;c=c.dataset.module;d=new PopUpMenu("","<i class='fa fa-pencil'></i> Edit Module");d.SetWidth(750);d.SetCloseOnHoverOut(!1);d.SetCloseOnLinkPressed(!1);d.SetContent("<div style='text-align:center;'><i class='fa fa-spin fa-spinner' style='font-size:50px; margin:20px; color:#777;'></i></div>");d.LoadContent("/ajax/users/modules/"+c+"/edit",!0).then(function(c){c.element.querySelector("form").addEventListener("submit",function(c){e.saveModule(c.target,
c)})},function(c){c.Close()});d.SetFixed(!0);d.Show();this.currentEditMenu=d};App.AddController("user-page",UserPageController);var UserPageFollowingModuleController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(UserPageFollowingModuleController,Controller);UserPageFollowingModuleController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);this.userId=c.dataset.userId};
UserPageFollowingModuleController.prototype.showAllFollowing=function(c){var d=this;new AjaxRequest({url:"/ajax/users/"+this.userId+"/following",method:"GET",button:c,spinner:c.querySelector("i"),success:function(c){d.elements.following.innerHTML=c.content}})};
UserPageFollowingModuleController.prototype.showAllFollowers=function(c){var d=this;new AjaxRequest({url:"/ajax/users/"+this.userId+"/followers",method:"GET",button:c,spinner:c.querySelector("i"),success:function(c){d.elements.followers.innerHTML=c.content}})};App.AddController("userpage-following-module",UserPageFollowingModuleController);var UserStatisticsController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(UserStatisticsController,Controller);
UserStatisticsController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);this.charts=[];this.statistics=JSON.parse(this.element.dataset.statistics);this.stories=JSON.parse(this.element.dataset.stories).stories;var e=0,f=0;this.statistics=this.statistics.map(function(c){e+=c.blog_posts;f+=c.followers;return{date:c.date,followers:c.followers,blog_posts:c.blog_posts,total_blog_posts:e,total_followers:f}});["/js/plugins/amcharts.js","/js/plugins/serial.js","/js/plugins/amstock.js",
"/js/plugins/xy.js"].reduce(function(c,d){return c.then(function(){return fQuery.loadScript(static_url+d)})},Promise.resolve()).then(function(){function c(c,d){return AmCharts.makeChart(c,{theme:fimf_dual_axis_chart_theme,pathToImages:static_url+"/images/amcharts/",type:"stock",dataDateFormat:"YYYY-MM-DD",addClassNames:!0,categoryAxesSettings:{maxSeries:80,groupToPeriods:["DD","WW","MM","YYYY"]},chartCursor:{categoryBalloonText:"[[category]] - [[toCategory]]"},dataSets:[d],mainDataSet:d,panels:[{valueAxes:[{id:"column",
title:"Views",position:"left",labelsEnabled:!1,gridThickness:0},{id:"line",title:"Total",position:"right"}],stockGraphs:[{id:"g1",type:"column",valueField:"value",fillAlphas:.8,lineAlpha:0,periodValue:"Sum",valueAxis:"column",balloonText:"<b>[[value]]</b>"},{type:"line",valueField:"total_value",fillAlphas:.3,lineAlpha:0,periodValue:"High",valueAxis:"line",showBalloon:!1,balloonText:"<b>Total:</b> [[value]]"}]}],chartScrollbarSettings:{graph:"g1",graphType:"column",usePeriod:"MM"}})}AmCharts.ready(function(){var e=
c("chart-followers",{title:"Followers",color:"#42d4ac",fieldMappings:[{fromField:"followers",toField:"value"},{fromField:"total_followers",toField:"total_value"}],dataProvider:d.statistics,categoryField:"date"});d.charts.followers=e});AmCharts.ready(function(){var e=c("chart-blog-posts",{title:"Blog Posts",color:"#6842d4",fieldMappings:[{fromField:"blog_posts",toField:"value"},{fromField:"total_blog_posts",toField:"total_value"}],dataProvider:d.statistics,categoryField:"date"});d.charts.blog_posts=
e});AmCharts.ready(function(){AmCharts.makeChart("chart-stories",{theme:fimf_dual_axis_chart_theme,pathToImages:static_url+"/images/amcharts/",type:"xy",dataDateFormat:"YYYY-MM-DD",addClassNames:!0,chartScrollbar:{},balloon:{textAlign:"left",animationDuration:.2},graphs:[{balloonText:'<b>[[title]]</b><hr /><i class="fa fa-calendar" style="margin-right:0.5em;"></i><b>[[x]]</b><br/>[[y]] views <b>&#xb7;</b> [[words_text]] words',bullet:"round",bulletSize:10,bulletAlpha:.5,lineAlpha:0,lineColor:"#008",
fillAlphas:0,xField:"date",yField:"views"}],valueAxes:[{id:"views",axisAlpha:0},{id:"date",axisAlpha:0,position:"bottom",type:"date",title:"Published Date"}],dataProvider:d.stories})})})};UserStatisticsController.prototype.setRange=function(c){this.charts[c.dataset.chart].zoom(new Date(1E3*c.dataset.start),new Date(1E3*c.dataset.end))};App.AddController("user-statistics",UserStatisticsController);var UserToolbarController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(UserToolbarController,Controller);
UserToolbarController.prototype.bind=function(c){Controller.prototype.bind.call(this,c);var d=document.getElementById("user_toolbar_blog_list_button");d&&d.addEventListener("toolbar-hovered",function(){var c=this.querySelector("ul");""==c.innerHTML&&new AjaxRequest({url:"/ajax/toolbar/blog-posts",method:"GET",success:function(d){c.innerHTML=d.content}})});(d=document.getElementById("user_toolbar_story_list_button"))&&d.addEventListener("toolbar-hovered",function(){var c=this.querySelector("ul");""==
c.innerHTML&&new AjaxRequest({url:"/ajax/toolbar/stories",method:"GET",success:function(d){c.innerHTML=d.content}})});var e=null;fQuery.addScopedEventListener(c,"a","click",function(c){var d=fQuery.closestParent(this,"li"),e=d.querySelector("ul");d.classList.contains("hover")||null==e||(d.classList.add("hover"),App.DispatchEvent(d,"toolbar-hovered"),c.preventDefault())});fQuery.addScopedEventListener(c,"li","mouseover",function(c){var d=this;this.classList.contains("hover")?(clearTimeout(this.user_toolbar_timer_close),
this.user_toolbar_timer_close=null):(clearTimeout(e),e=setTimeout(function(){fQuery.removeClass(fQuery.siblings(d),"hover");d.classList.add("hover");App.DispatchEvent(d,"toolbar-hovered")},120))});fQuery.addScopedEventListener(c,"li","mouseout",function(c){var d=this;clearTimeout(e);this.classList.contains("hover")&&(this.user_toolbar_timer_close=setTimeout(function(){d.classList.remove("hover")},250))})};App.AddController("user-toolbar",UserToolbarController);var WatchUserController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(WatchUserController,Controller);WatchUserController.prototype.bind=function(c){var d=this;Controller.prototype.bind.call(this,c);c.addEventListener("click",function(c){return d.toggle()})};
WatchUserController.prototype.toggle=function(){var c=this.element;c.classList.add("button_toggle_processing");var d="true"==c.getAttribute("data-watch");new AjaxRequest({url:"/ajax/users/"+c.getAttribute("data-user")+"/follow",method:"1"==d?"DELETE":"POST",signed:!0,success:function(d){c.classList.remove("button_toggle_processing");"error"in d?ShowErrorWindow(d.error):c.setAttribute("data-watch",d.watching?"true":"false")}})};App.AddController("watch-user",WatchUserController);var WelcomeMessageController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(WelcomeMessageController,Controller);WelcomeMessageController.prototype.bind=function(c){Controller.prototype.bind.call(this,c)};WelcomeMessageController.prototype.hide=function(c,d){var e=this;new AjaxRequest({url:"/ajax/users/welcome-message",button:c,spinner:c.querySelector("i"),method:"POST",success:function(c){e.element.classList.add("hidden")}})};App.AddController("welcome-message",WelcomeMessageController);var DevelopersLayoutNavController=function(c){Controller.apply(this,arguments)};$jscomp.inherits(DevelopersLayoutNavController,Controller);DevelopersLayoutNavController.prototype.toggleNavigation=function(){this.element.classList.toggle("show-navigation")};App.AddController("developers/layout-nav",DevelopersLayoutNavController);fQuery.ready(function(){App.BindAll(document);fireHashCallback()});
/*
 The following sha256 functions were reimplemented as an asm.js module
 by Xaquseg. The following license applies to the implementation it is based on:

 Original work Copyright (c) 2016 Project Nayuki. (MIT License)
 https://www.nayuki.io/page/fast-sha2-hashes-in-x86-assembly

 Permission is hereby granted, free of charge, to any person obtaining a copy of
 this software and associated documentation files (the "Software"), to deal in
 the Software without restriction, including without limitation the rights to
 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 the Software, and to permit persons to whom the Software is furnished to do so,
 subject to the following conditions:
 - The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.
 - The Software is provided "as is", without warranty of any kind, express or
   implied, including but not limited to the warranties of merchantability,
   fitness for a particular purpose and noninfringement. In no event shall the
   authors or copyright holders be liable for any claim, damages or other
   liability, whether in an action of contract, tort or otherwise, arising from,
   out of or in connection with the Software or the use or other dealings in the
   Software.
*/
xyzcrypto.sha256.asm.module=function(stdlib,foreign,heap){"use asm";var u32=new stdlib.Uint32Array(heap);var u8=new stdlib.Uint8Array(heap);var copyBlock=foreign.copyBlock;var used=0;var totalLen=0;function reset(){used=0;totalLen=0;u32[0]=1779033703;u32[1]=3144134277;u32[2]=1013904242;u32[3]=2773480762;u32[4]=1359893119;u32[5]=2600822924;u32[6]=528734635;u32[7]=1541459225}function update(len){len=len|0;var i=0;totalLen=~~(totalLen+len);if(~~used!=0)if(~~len>~~(64-used)){copyBlock(~~used,~~used,~~(64-
used));block();used=0}else{copyBlock(~~used,~~used,~~(used+len));used=~~(used+len);return}for(;~~(len-i)>=64;i=~~(i+64)){copyBlock(0,~~i,~~(i+64));block()}if(~~len!=~~i){used=~~(len-i);copyBlock(0,~~i,~~(i+used))}else used=0}function updateBlock(){totalLen=~~(totalLen+64);block()}function finish(){var i=0;var lengths=0;u8[~~(32+used)]=128;used=~~(used+1);if(~~(64-used)<8){for(i=used;~~i<64;i=~~(i+1))u8[~~(32+i)]=0;block();used=0}for(i=used;~~i<59;i=~~(i+1))u8[~~(32+i)]=0;lengths=totalLen<<3;u8[91]=
totalLen>>>29;u8[92]=lengths>>>24;u8[93]=lengths>>>16;u8[94]=lengths>>>8;u8[95]=lengths;block()}function block(){var a=0;var b=0;var c=0;var d=0;var e=0;var f=0;var g=0;var h=0;a=~~u32[0];b=~~u32[1];c=~~u32[2];d=~~u32[3];e=~~u32[4];f=~~u32[5];g=~~u32[6];h=~~u32[7];u32[24]=u8[32]<<24|u8[33]<<16|u8[34]<<8|u8[35];u32[25]=u8[36]<<24|u8[37]<<16|u8[38]<<8|u8[39];u32[26]=u8[40]<<24|u8[41]<<16|u8[42]<<8|u8[43];u32[27]=u8[44]<<24|u8[45]<<16|u8[46]<<8|u8[47];u32[28]=u8[48]<<24|u8[49]<<16|u8[50]<<8|u8[51];u32[29]=
u8[52]<<24|u8[53]<<16|u8[54]<<8|u8[55];u32[30]=u8[56]<<24|u8[57]<<16|u8[58]<<8|u8[59];u32[31]=u8[60]<<24|u8[61]<<16|u8[62]<<8|u8[63];u32[32]=u8[64]<<24|u8[65]<<16|u8[66]<<8|u8[67];u32[33]=u8[68]<<24|u8[69]<<16|u8[70]<<8|u8[71];u32[34]=u8[72]<<24|u8[73]<<16|u8[74]<<8|u8[75];u32[35]=u8[76]<<24|u8[77]<<16|u8[78]<<8|u8[79];u32[36]=u8[80]<<24|u8[81]<<16|u8[82]<<8|u8[83];u32[37]=u8[84]<<24|u8[85]<<16|u8[86]<<8|u8[87];u32[38]=u8[88]<<24|u8[89]<<16|u8[90]<<8|u8[91];u32[39]=u8[92]<<24|u8[93]<<16|u8[94]<<8|
u8[95];u32[40]=~~u32[24]+~~u32[33]+((u32[25]<<25|u32[25]>>>7)^(u32[25]<<14|u32[25]>>>18)^u32[25]>>>3)+((u32[38]<<15|u32[38]>>>17)^(u32[38]<<13|u32[38]>>>19)^u32[38]>>>10);u32[41]=~~u32[25]+~~u32[34]+((u32[26]<<25|u32[26]>>>7)^(u32[26]<<14|u32[26]>>>18)^u32[26]>>>3)+((u32[39]<<15|u32[39]>>>17)^(u32[39]<<13|u32[39]>>>19)^u32[39]>>>10);u32[42]=~~u32[26]+~~u32[35]+((u32[27]<<25|u32[27]>>>7)^(u32[27]<<14|u32[27]>>>18)^u32[27]>>>3)+((u32[40]<<15|u32[40]>>>17)^(u32[40]<<13|u32[40]>>>19)^u32[40]>>>10);u32[43]=
~~u32[27]+~~u32[36]+((u32[28]<<25|u32[28]>>>7)^(u32[28]<<14|u32[28]>>>18)^u32[28]>>>3)+((u32[41]<<15|u32[41]>>>17)^(u32[41]<<13|u32[41]>>>19)^u32[41]>>>10);u32[44]=~~u32[28]+~~u32[37]+((u32[29]<<25|u32[29]>>>7)^(u32[29]<<14|u32[29]>>>18)^u32[29]>>>3)+((u32[42]<<15|u32[42]>>>17)^(u32[42]<<13|u32[42]>>>19)^u32[42]>>>10);u32[45]=~~u32[29]+~~u32[38]+((u32[30]<<25|u32[30]>>>7)^(u32[30]<<14|u32[30]>>>18)^u32[30]>>>3)+((u32[43]<<15|u32[43]>>>17)^(u32[43]<<13|u32[43]>>>19)^u32[43]>>>10);u32[46]=~~u32[30]+
~~u32[39]+((u32[31]<<25|u32[31]>>>7)^(u32[31]<<14|u32[31]>>>18)^u32[31]>>>3)+((u32[44]<<15|u32[44]>>>17)^(u32[44]<<13|u32[44]>>>19)^u32[44]>>>10);u32[47]=~~u32[31]+~~u32[40]+((u32[32]<<25|u32[32]>>>7)^(u32[32]<<14|u32[32]>>>18)^u32[32]>>>3)+((u32[45]<<15|u32[45]>>>17)^(u32[45]<<13|u32[45]>>>19)^u32[45]>>>10);u32[48]=~~u32[32]+~~u32[41]+((u32[33]<<25|u32[33]>>>7)^(u32[33]<<14|u32[33]>>>18)^u32[33]>>>3)+((u32[46]<<15|u32[46]>>>17)^(u32[46]<<13|u32[46]>>>19)^u32[46]>>>10);u32[49]=~~u32[33]+~~u32[42]+
((u32[34]<<25|u32[34]>>>7)^(u32[34]<<14|u32[34]>>>18)^u32[34]>>>3)+((u32[47]<<15|u32[47]>>>17)^(u32[47]<<13|u32[47]>>>19)^u32[47]>>>10);u32[50]=~~u32[34]+~~u32[43]+((u32[35]<<25|u32[35]>>>7)^(u32[35]<<14|u32[35]>>>18)^u32[35]>>>3)+((u32[48]<<15|u32[48]>>>17)^(u32[48]<<13|u32[48]>>>19)^u32[48]>>>10);u32[51]=~~u32[35]+~~u32[44]+((u32[36]<<25|u32[36]>>>7)^(u32[36]<<14|u32[36]>>>18)^u32[36]>>>3)+((u32[49]<<15|u32[49]>>>17)^(u32[49]<<13|u32[49]>>>19)^u32[49]>>>10);u32[52]=~~u32[36]+~~u32[45]+((u32[37]<<
25|u32[37]>>>7)^(u32[37]<<14|u32[37]>>>18)^u32[37]>>>3)+((u32[50]<<15|u32[50]>>>17)^(u32[50]<<13|u32[50]>>>19)^u32[50]>>>10);u32[53]=~~u32[37]+~~u32[46]+((u32[38]<<25|u32[38]>>>7)^(u32[38]<<14|u32[38]>>>18)^u32[38]>>>3)+((u32[51]<<15|u32[51]>>>17)^(u32[51]<<13|u32[51]>>>19)^u32[51]>>>10);u32[54]=~~u32[38]+~~u32[47]+((u32[39]<<25|u32[39]>>>7)^(u32[39]<<14|u32[39]>>>18)^u32[39]>>>3)+((u32[52]<<15|u32[52]>>>17)^(u32[52]<<13|u32[52]>>>19)^u32[52]>>>10);u32[55]=~~u32[39]+~~u32[48]+((u32[40]<<25|u32[40]>>>
7)^(u32[40]<<14|u32[40]>>>18)^u32[40]>>>3)+((u32[53]<<15|u32[53]>>>17)^(u32[53]<<13|u32[53]>>>19)^u32[53]>>>10);u32[56]=~~u32[40]+~~u32[49]+((u32[41]<<25|u32[41]>>>7)^(u32[41]<<14|u32[41]>>>18)^u32[41]>>>3)+((u32[54]<<15|u32[54]>>>17)^(u32[54]<<13|u32[54]>>>19)^u32[54]>>>10);u32[57]=~~u32[41]+~~u32[50]+((u32[42]<<25|u32[42]>>>7)^(u32[42]<<14|u32[42]>>>18)^u32[42]>>>3)+((u32[55]<<15|u32[55]>>>17)^(u32[55]<<13|u32[55]>>>19)^u32[55]>>>10);u32[58]=~~u32[42]+~~u32[51]+((u32[43]<<25|u32[43]>>>7)^(u32[43]<<
14|u32[43]>>>18)^u32[43]>>>3)+((u32[56]<<15|u32[56]>>>17)^(u32[56]<<13|u32[56]>>>19)^u32[56]>>>10);u32[59]=~~u32[43]+~~u32[52]+((u32[44]<<25|u32[44]>>>7)^(u32[44]<<14|u32[44]>>>18)^u32[44]>>>3)+((u32[57]<<15|u32[57]>>>17)^(u32[57]<<13|u32[57]>>>19)^u32[57]>>>10);u32[60]=~~u32[44]+~~u32[53]+((u32[45]<<25|u32[45]>>>7)^(u32[45]<<14|u32[45]>>>18)^u32[45]>>>3)+((u32[58]<<15|u32[58]>>>17)^(u32[58]<<13|u32[58]>>>19)^u32[58]>>>10);u32[61]=~~u32[45]+~~u32[54]+((u32[46]<<25|u32[46]>>>7)^(u32[46]<<14|u32[46]>>>
18)^u32[46]>>>3)+((u32[59]<<15|u32[59]>>>17)^(u32[59]<<13|u32[59]>>>19)^u32[59]>>>10);u32[62]=~~u32[46]+~~u32[55]+((u32[47]<<25|u32[47]>>>7)^(u32[47]<<14|u32[47]>>>18)^u32[47]>>>3)+((u32[60]<<15|u32[60]>>>17)^(u32[60]<<13|u32[60]>>>19)^u32[60]>>>10);u32[63]=~~u32[47]+~~u32[56]+((u32[48]<<25|u32[48]>>>7)^(u32[48]<<14|u32[48]>>>18)^u32[48]>>>3)+((u32[61]<<15|u32[61]>>>17)^(u32[61]<<13|u32[61]>>>19)^u32[61]>>>10);u32[64]=~~u32[48]+~~u32[57]+((u32[49]<<25|u32[49]>>>7)^(u32[49]<<14|u32[49]>>>18)^u32[49]>>>
3)+((u32[62]<<15|u32[62]>>>17)^(u32[62]<<13|u32[62]>>>19)^u32[62]>>>10);u32[65]=~~u32[49]+~~u32[58]+((u32[50]<<25|u32[50]>>>7)^(u32[50]<<14|u32[50]>>>18)^u32[50]>>>3)+((u32[63]<<15|u32[63]>>>17)^(u32[63]<<13|u32[63]>>>19)^u32[63]>>>10);u32[66]=~~u32[50]+~~u32[59]+((u32[51]<<25|u32[51]>>>7)^(u32[51]<<14|u32[51]>>>18)^u32[51]>>>3)+((u32[64]<<15|u32[64]>>>17)^(u32[64]<<13|u32[64]>>>19)^u32[64]>>>10);u32[67]=~~u32[51]+~~u32[60]+((u32[52]<<25|u32[52]>>>7)^(u32[52]<<14|u32[52]>>>18)^u32[52]>>>3)+((u32[65]<<
15|u32[65]>>>17)^(u32[65]<<13|u32[65]>>>19)^u32[65]>>>10);u32[68]=~~u32[52]+~~u32[61]+((u32[53]<<25|u32[53]>>>7)^(u32[53]<<14|u32[53]>>>18)^u32[53]>>>3)+((u32[66]<<15|u32[66]>>>17)^(u32[66]<<13|u32[66]>>>19)^u32[66]>>>10);u32[69]=~~u32[53]+~~u32[62]+((u32[54]<<25|u32[54]>>>7)^(u32[54]<<14|u32[54]>>>18)^u32[54]>>>3)+((u32[67]<<15|u32[67]>>>17)^(u32[67]<<13|u32[67]>>>19)^u32[67]>>>10);u32[70]=~~u32[54]+~~u32[63]+((u32[55]<<25|u32[55]>>>7)^(u32[55]<<14|u32[55]>>>18)^u32[55]>>>3)+((u32[68]<<15|u32[68]>>>
17)^(u32[68]<<13|u32[68]>>>19)^u32[68]>>>10);u32[71]=~~u32[55]+~~u32[64]+((u32[56]<<25|u32[56]>>>7)^(u32[56]<<14|u32[56]>>>18)^u32[56]>>>3)+((u32[69]<<15|u32[69]>>>17)^(u32[69]<<13|u32[69]>>>19)^u32[69]>>>10);u32[72]=~~u32[56]+~~u32[65]+((u32[57]<<25|u32[57]>>>7)^(u32[57]<<14|u32[57]>>>18)^u32[57]>>>3)+((u32[70]<<15|u32[70]>>>17)^(u32[70]<<13|u32[70]>>>19)^u32[70]>>>10);u32[73]=~~u32[57]+~~u32[66]+((u32[58]<<25|u32[58]>>>7)^(u32[58]<<14|u32[58]>>>18)^u32[58]>>>3)+((u32[71]<<15|u32[71]>>>17)^(u32[71]<<
13|u32[71]>>>19)^u32[71]>>>10);u32[74]=~~u32[58]+~~u32[67]+((u32[59]<<25|u32[59]>>>7)^(u32[59]<<14|u32[59]>>>18)^u32[59]>>>3)+((u32[72]<<15|u32[72]>>>17)^(u32[72]<<13|u32[72]>>>19)^u32[72]>>>10);u32[75]=~~u32[59]+~~u32[68]+((u32[60]<<25|u32[60]>>>7)^(u32[60]<<14|u32[60]>>>18)^u32[60]>>>3)+((u32[73]<<15|u32[73]>>>17)^(u32[73]<<13|u32[73]>>>19)^u32[73]>>>10);u32[76]=~~u32[60]+~~u32[69]+((u32[61]<<25|u32[61]>>>7)^(u32[61]<<14|u32[61]>>>18)^u32[61]>>>3)+((u32[74]<<15|u32[74]>>>17)^(u32[74]<<13|u32[74]>>>
19)^u32[74]>>>10);u32[77]=~~u32[61]+~~u32[70]+((u32[62]<<25|u32[62]>>>7)^(u32[62]<<14|u32[62]>>>18)^u32[62]>>>3)+((u32[75]<<15|u32[75]>>>17)^(u32[75]<<13|u32[75]>>>19)^u32[75]>>>10);u32[78]=~~u32[62]+~~u32[71]+((u32[63]<<25|u32[63]>>>7)^(u32[63]<<14|u32[63]>>>18)^u32[63]>>>3)+((u32[76]<<15|u32[76]>>>17)^(u32[76]<<13|u32[76]>>>19)^u32[76]>>>10);u32[79]=~~u32[63]+~~u32[72]+((u32[64]<<25|u32[64]>>>7)^(u32[64]<<14|u32[64]>>>18)^u32[64]>>>3)+((u32[77]<<15|u32[77]>>>17)^(u32[77]<<13|u32[77]>>>19)^u32[77]>>>
10);u32[80]=~~u32[64]+~~u32[73]+((u32[65]<<25|u32[65]>>>7)^(u32[65]<<14|u32[65]>>>18)^u32[65]>>>3)+((u32[78]<<15|u32[78]>>>17)^(u32[78]<<13|u32[78]>>>19)^u32[78]>>>10);u32[81]=~~u32[65]+~~u32[74]+((u32[66]<<25|u32[66]>>>7)^(u32[66]<<14|u32[66]>>>18)^u32[66]>>>3)+((u32[79]<<15|u32[79]>>>17)^(u32[79]<<13|u32[79]>>>19)^u32[79]>>>10);u32[82]=~~u32[66]+~~u32[75]+((u32[67]<<25|u32[67]>>>7)^(u32[67]<<14|u32[67]>>>18)^u32[67]>>>3)+((u32[80]<<15|u32[80]>>>17)^(u32[80]<<13|u32[80]>>>19)^u32[80]>>>10);u32[83]=
~~u32[67]+~~u32[76]+((u32[68]<<25|u32[68]>>>7)^(u32[68]<<14|u32[68]>>>18)^u32[68]>>>3)+((u32[81]<<15|u32[81]>>>17)^(u32[81]<<13|u32[81]>>>19)^u32[81]>>>10);u32[84]=~~u32[68]+~~u32[77]+((u32[69]<<25|u32[69]>>>7)^(u32[69]<<14|u32[69]>>>18)^u32[69]>>>3)+((u32[82]<<15|u32[82]>>>17)^(u32[82]<<13|u32[82]>>>19)^u32[82]>>>10);u32[85]=~~u32[69]+~~u32[78]+((u32[70]<<25|u32[70]>>>7)^(u32[70]<<14|u32[70]>>>18)^u32[70]>>>3)+((u32[83]<<15|u32[83]>>>17)^(u32[83]<<13|u32[83]>>>19)^u32[83]>>>10);u32[86]=~~u32[70]+
~~u32[79]+((u32[71]<<25|u32[71]>>>7)^(u32[71]<<14|u32[71]>>>18)^u32[71]>>>3)+((u32[84]<<15|u32[84]>>>17)^(u32[84]<<13|u32[84]>>>19)^u32[84]>>>10);u32[87]=~~u32[71]+~~u32[80]+((u32[72]<<25|u32[72]>>>7)^(u32[72]<<14|u32[72]>>>18)^u32[72]>>>3)+((u32[85]<<15|u32[85]>>>17)^(u32[85]<<13|u32[85]>>>19)^u32[85]>>>10);h=~~(h+((e<<26|e>>>6)^(e<<21|e>>>11)^(e<<7|e>>>25))+(g^e&(f^g))+1116352408+~~u32[24]);d=~~(d+h);h=~~(h+((a<<30|a>>>2)^(a<<19|a>>>13)^(a<<10|a>>>22))+(a&(b|c)|b&c));g=~~(g+((d<<26|d>>>6)^(d<<21|
d>>>11)^(d<<7|d>>>25))+(f^d&(e^f))+1899447441+~~u32[25]);c=~~(c+g);g=~~(g+((h<<30|h>>>2)^(h<<19|h>>>13)^(h<<10|h>>>22))+(h&(a|b)|a&b));f=~~(f+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(e^c&(d^e))+3049323471+~~u32[26]);b=~~(b+f);f=~~(f+((g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22))+(g&(h|a)|h&a));e=~~(e+((b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25))+(d^b&(c^d))+3921009573+~~u32[27]);a=~~(a+e);e=~~(e+((f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22))+(f&(g|h)|g&h));d=~~(d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<
7|a>>>25))+(c^a&(b^c))+961987163+~~u32[28]);h=~~(h+d);d=~~(d+((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&(f|g)|f&g));c=~~(c+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(b^h&(a^b))+1508970993+~~u32[29]);g=~~(g+c);c=~~(c+((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&(e|f)|e&f));b=~~(b+((g<<26|g>>>6)^(g<<21|g>>>11)^(g<<7|g>>>25))+(a^g&(h^a))+2453635748+~~u32[30]);f=~~(f+b);b=~~(b+((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&(d|e)|d&e));a=~~(a+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+
(h^f&(g^h))+2870763221+~~u32[31]);e=~~(e+a);a=~~(a+((b<<30|b>>>2)^(b<<19|b>>>13)^(b<<10|b>>>22))+(b&(c|d)|c&d));h=~~(h+((e<<26|e>>>6)^(e<<21|e>>>11)^(e<<7|e>>>25))+(g^e&(f^g))+3624381080+~~u32[32]);d=~~(d+h);h=~~(h+((a<<30|a>>>2)^(a<<19|a>>>13)^(a<<10|a>>>22))+(a&(b|c)|b&c));g=~~(g+((d<<26|d>>>6)^(d<<21|d>>>11)^(d<<7|d>>>25))+(f^d&(e^f))+310598401+~~u32[33]);c=~~(c+g);g=~~(g+((h<<30|h>>>2)^(h<<19|h>>>13)^(h<<10|h>>>22))+(h&(a|b)|a&b));f=~~(f+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(e^c&(d^e))+
607225278+~~u32[34]);b=~~(b+f);f=~~(f+((g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22))+(g&(h|a)|h&a));e=~~(e+((b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25))+(d^b&(c^d))+1426881987+~~u32[35]);a=~~(a+e);e=~~(e+((f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22))+(f&(g|h)|g&h));d=~~(d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(c^a&(b^c))+1925078388+~~u32[36]);h=~~(h+d);d=~~(d+((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&(f|g)|f&g));c=~~(c+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(b^h&(a^b))+2162078206+
~~u32[37]);g=~~(g+c);c=~~(c+((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&(e|f)|e&f));b=~~(b+((g<<26|g>>>6)^(g<<21|g>>>11)^(g<<7|g>>>25))+(a^g&(h^a))+2614888103+~~u32[38]);f=~~(f+b);b=~~(b+((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&(d|e)|d&e));a=~~(a+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(h^f&(g^h))+3248222580+~~u32[39]);e=~~(e+a);a=~~(a+((b<<30|b>>>2)^(b<<19|b>>>13)^(b<<10|b>>>22))+(b&(c|d)|c&d));h=~~(h+((e<<26|e>>>6)^(e<<21|e>>>11)^(e<<7|e>>>25))+(g^e&(f^g))+3835390401+~~u32[40]);
d=~~(d+h);h=~~(h+((a<<30|a>>>2)^(a<<19|a>>>13)^(a<<10|a>>>22))+(a&(b|c)|b&c));g=~~(g+((d<<26|d>>>6)^(d<<21|d>>>11)^(d<<7|d>>>25))+(f^d&(e^f))+4022224774+~~u32[41]);c=~~(c+g);g=~~(g+((h<<30|h>>>2)^(h<<19|h>>>13)^(h<<10|h>>>22))+(h&(a|b)|a&b));f=~~(f+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(e^c&(d^e))+264347078+~~u32[42]);b=~~(b+f);f=~~(f+((g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22))+(g&(h|a)|h&a));e=~~(e+((b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25))+(d^b&(c^d))+604807628+~~u32[43]);a=~~(a+e);e=
~~(e+((f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22))+(f&(g|h)|g&h));d=~~(d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(c^a&(b^c))+770255983+~~u32[44]);h=~~(h+d);d=~~(d+((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&(f|g)|f&g));c=~~(c+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(b^h&(a^b))+1249150122+~~u32[45]);g=~~(g+c);c=~~(c+((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&(e|f)|e&f));b=~~(b+((g<<26|g>>>6)^(g<<21|g>>>11)^(g<<7|g>>>25))+(a^g&(h^a))+1555081692+~~u32[46]);f=~~(f+b);b=~~(b+((c<<
30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&(d|e)|d&e));a=~~(a+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(h^f&(g^h))+1996064986+~~u32[47]);e=~~(e+a);a=~~(a+((b<<30|b>>>2)^(b<<19|b>>>13)^(b<<10|b>>>22))+(b&(c|d)|c&d));h=~~(h+((e<<26|e>>>6)^(e<<21|e>>>11)^(e<<7|e>>>25))+(g^e&(f^g))+2554220882+~~u32[48]);d=~~(d+h);h=~~(h+((a<<30|a>>>2)^(a<<19|a>>>13)^(a<<10|a>>>22))+(a&(b|c)|b&c));g=~~(g+((d<<26|d>>>6)^(d<<21|d>>>11)^(d<<7|d>>>25))+(f^d&(e^f))+2821834349+~~u32[49]);c=~~(c+g);g=~~(g+((h<<30|h>>>2)^
(h<<19|h>>>13)^(h<<10|h>>>22))+(h&(a|b)|a&b));f=~~(f+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(e^c&(d^e))+2952996808+~~u32[50]);b=~~(b+f);f=~~(f+((g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22))+(g&(h|a)|h&a));e=~~(e+((b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25))+(d^b&(c^d))+3210313671+~~u32[51]);a=~~(a+e);e=~~(e+((f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22))+(f&(g|h)|g&h));d=~~(d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(c^a&(b^c))+3336571891+~~u32[52]);h=~~(h+d);d=~~(d+((e<<30|e>>>2)^(e<<19|e>>>
13)^(e<<10|e>>>22))+(e&(f|g)|f&g));c=~~(c+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(b^h&(a^b))+3584528711+~~u32[53]);g=~~(g+c);c=~~(c+((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&(e|f)|e&f));b=~~(b+((g<<26|g>>>6)^(g<<21|g>>>11)^(g<<7|g>>>25))+(a^g&(h^a))+113926993+~~u32[54]);f=~~(f+b);b=~~(b+((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&(d|e)|d&e));a=~~(a+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(h^f&(g^h))+338241895+~~u32[55]);e=~~(e+a);a=~~(a+((b<<30|b>>>2)^(b<<19|b>>>13)^(b<<10|
b>>>22))+(b&(c|d)|c&d));h=~~(h+((e<<26|e>>>6)^(e<<21|e>>>11)^(e<<7|e>>>25))+(g^e&(f^g))+666307205+~~u32[56]);d=~~(d+h);h=~~(h+((a<<30|a>>>2)^(a<<19|a>>>13)^(a<<10|a>>>22))+(a&(b|c)|b&c));g=~~(g+((d<<26|d>>>6)^(d<<21|d>>>11)^(d<<7|d>>>25))+(f^d&(e^f))+773529912+~~u32[57]);c=~~(c+g);g=~~(g+((h<<30|h>>>2)^(h<<19|h>>>13)^(h<<10|h>>>22))+(h&(a|b)|a&b));f=~~(f+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(e^c&(d^e))+1294757372+~~u32[58]);b=~~(b+f);f=~~(f+((g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22))+(g&
(h|a)|h&a));e=~~(e+((b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25))+(d^b&(c^d))+1396182291+~~u32[59]);a=~~(a+e);e=~~(e+((f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22))+(f&(g|h)|g&h));d=~~(d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(c^a&(b^c))+1695183700+~~u32[60]);h=~~(h+d);d=~~(d+((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&(f|g)|f&g));c=~~(c+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(b^h&(a^b))+1986661051+~~u32[61]);g=~~(g+c);c=~~(c+((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&(e|f)|e&f));
b=~~(b+((g<<26|g>>>6)^(g<<21|g>>>11)^(g<<7|g>>>25))+(a^g&(h^a))+2177026350+~~u32[62]);f=~~(f+b);b=~~(b+((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&(d|e)|d&e));a=~~(a+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(h^f&(g^h))+2456956037+~~u32[63]);e=~~(e+a);a=~~(a+((b<<30|b>>>2)^(b<<19|b>>>13)^(b<<10|b>>>22))+(b&(c|d)|c&d));h=~~(h+((e<<26|e>>>6)^(e<<21|e>>>11)^(e<<7|e>>>25))+(g^e&(f^g))+2730485921+~~u32[64]);d=~~(d+h);h=~~(h+((a<<30|a>>>2)^(a<<19|a>>>13)^(a<<10|a>>>22))+(a&(b|c)|b&c));g=~~(g+((d<<
26|d>>>6)^(d<<21|d>>>11)^(d<<7|d>>>25))+(f^d&(e^f))+2820302411+~~u32[65]);c=~~(c+g);g=~~(g+((h<<30|h>>>2)^(h<<19|h>>>13)^(h<<10|h>>>22))+(h&(a|b)|a&b));f=~~(f+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(e^c&(d^e))+3259730800+~~u32[66]);b=~~(b+f);f=~~(f+((g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22))+(g&(h|a)|h&a));e=~~(e+((b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25))+(d^b&(c^d))+3345764771+~~u32[67]);a=~~(a+e);e=~~(e+((f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22))+(f&(g|h)|g&h));d=~~(d+((a<<26|a>>>6)^
(a<<21|a>>>11)^(a<<7|a>>>25))+(c^a&(b^c))+3516065817+~~u32[68]);h=~~(h+d);d=~~(d+((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&(f|g)|f&g));c=~~(c+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(b^h&(a^b))+3600352804+~~u32[69]);g=~~(g+c);c=~~(c+((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&(e|f)|e&f));b=~~(b+((g<<26|g>>>6)^(g<<21|g>>>11)^(g<<7|g>>>25))+(a^g&(h^a))+4094571909+~~u32[70]);f=~~(f+b);b=~~(b+((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&(d|e)|d&e));a=~~(a+((f<<26|f>>>6)^(f<<21|f>>>
11)^(f<<7|f>>>25))+(h^f&(g^h))+275423344+~~u32[71]);e=~~(e+a);a=~~(a+((b<<30|b>>>2)^(b<<19|b>>>13)^(b<<10|b>>>22))+(b&(c|d)|c&d));h=~~(h+((e<<26|e>>>6)^(e<<21|e>>>11)^(e<<7|e>>>25))+(g^e&(f^g))+430227734+~~u32[72]);d=~~(d+h);h=~~(h+((a<<30|a>>>2)^(a<<19|a>>>13)^(a<<10|a>>>22))+(a&(b|c)|b&c));g=~~(g+((d<<26|d>>>6)^(d<<21|d>>>11)^(d<<7|d>>>25))+(f^d&(e^f))+506948616+~~u32[73]);c=~~(c+g);g=~~(g+((h<<30|h>>>2)^(h<<19|h>>>13)^(h<<10|h>>>22))+(h&(a|b)|a&b));f=~~(f+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>
25))+(e^c&(d^e))+659060556+~~u32[74]);b=~~(b+f);f=~~(f+((g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22))+(g&(h|a)|h&a));e=~~(e+((b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25))+(d^b&(c^d))+883997877+~~u32[75]);a=~~(a+e);e=~~(e+((f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22))+(f&(g|h)|g&h));d=~~(d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(c^a&(b^c))+958139571+~~u32[76]);h=~~(h+d);d=~~(d+((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&(f|g)|f&g));c=~~(c+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(b^h&(a^
b))+1322822218+~~u32[77]);g=~~(g+c);c=~~(c+((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&(e|f)|e&f));b=~~(b+((g<<26|g>>>6)^(g<<21|g>>>11)^(g<<7|g>>>25))+(a^g&(h^a))+1537002063+~~u32[78]);f=~~(f+b);b=~~(b+((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&(d|e)|d&e));a=~~(a+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(h^f&(g^h))+1747873779+~~u32[79]);e=~~(e+a);a=~~(a+((b<<30|b>>>2)^(b<<19|b>>>13)^(b<<10|b>>>22))+(b&(c|d)|c&d));h=~~(h+((e<<26|e>>>6)^(e<<21|e>>>11)^(e<<7|e>>>25))+(g^e&(f^g))+1955562222+
~~u32[80]);d=~~(d+h);h=~~(h+((a<<30|a>>>2)^(a<<19|a>>>13)^(a<<10|a>>>22))+(a&(b|c)|b&c));g=~~(g+((d<<26|d>>>6)^(d<<21|d>>>11)^(d<<7|d>>>25))+(f^d&(e^f))+2024104815+~~u32[81]);c=~~(c+g);g=~~(g+((h<<30|h>>>2)^(h<<19|h>>>13)^(h<<10|h>>>22))+(h&(a|b)|a&b));f=~~(f+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(e^c&(d^e))+2227730452+~~u32[82]);b=~~(b+f);f=~~(f+((g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22))+(g&(h|a)|h&a));e=~~(e+((b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25))+(d^b&(c^d))+2361852424+~~u32[83]);
a=~~(a+e);e=~~(e+((f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22))+(f&(g|h)|g&h));d=~~(d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(c^a&(b^c))+2428436474+~~u32[84]);h=~~(h+d);d=~~(d+((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&(f|g)|f&g));c=~~(c+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(b^h&(a^b))+2756734187+~~u32[85]);g=~~(g+c);c=~~(c+((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&(e|f)|e&f));b=~~(b+((g<<26|g>>>6)^(g<<21|g>>>11)^(g<<7|g>>>25))+(a^g&(h^a))+3204031479+~~u32[86]);f=~~(f+b);
b=~~(b+((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&(d|e)|d&e));a=~~(a+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(h^f&(g^h))+3329325298+~~u32[87]);e=~~(e+a);a=~~(a+((b<<30|b>>>2)^(b<<19|b>>>13)^(b<<10|b>>>22))+(b&(c|d)|c&d));u32[0]=~~(~~u32[0]+a);u32[1]=~~(~~u32[1]+b);u32[2]=~~(~~u32[2]+c);u32[3]=~~(~~u32[3]+d);u32[4]=~~(~~u32[4]+e);u32[5]=~~(~~u32[5]+f);u32[6]=~~(~~u32[6]+g);u32[7]=~~(~~u32[7]+h)}return{reset:reset,update:update,updateBlock:updateBlock,finish:finish}};
