{e.searchParams.append(n,t[n])})),e}function fcn_buildErrorNotice(t,e=!1,n=!0){console.error("Error:",t);const a=document.createElement("div");let o=t;return e&&(a.id=e),a.classList="notice _warning","object"==typeof t&&(o="",t.status&&(o=`${t.status}: `),t.statusText&&(o+=t.statusText),o||(o="Unknown error.")),a.innerHTML=`${n?fcn_sanitizeHTML(o):o}
`,a}function fcn_sanitizeHTML(t){const e=document.createElement("div");return e.innerText=t instanceof HTMLElement?t.innerHTML:t,e.textContent="string"==typeof t?t:t.textContent,e.innerHTML}function fcn_validateCss(t){return(t.match(/{/g)||[]).length===(t.match(/}/g)||[]).length&&!t.includes("<")}function fcn_detectScreenCollision(t){const e=t.getBoundingClientRect(),n=window.innerHeight??document.documentElement.clientHeight,a=window.innerWidth??document.documentElement.clientWidth,o=(t.closest(".popup-menu-toggle")?.clientHeight??32)+16,c=n-e.bottom,s=[];return e.top<=50&&c>50+o&&s.push("top"),e.bottom>=n-50&&e.top>50+o&&s.push("bottom"),e.left<=10&&s.push("left"),e.right>=a-10&&s.push("right"),s}function fcn_scrollTo(t,e=64){window.scrollTo({top:t.getBoundingClientRect().top+window.scrollY-e,behavior:"smooth"})}function fcn_html(...t){const e=document.createElement("template");return e.innerHTML=String.raw(...t).trim(),e.content.firstChild}function fcn_splitList(t,e=","){if(!t||""===t.trim())return[];let n=t.replace(/\r?\n|\r/g,"").split(e);return n=n.map((t=>t.trim())).filter((t=>t.length>0)),n}function fcn_isSearchEngineCrawler(){const t=navigator.userAgent.toLowerCase();return["googlebot","bingbot","slurp","duckduckbot","baiduspider","yandexbot","sogou","exabot","facebot","ia_archiver"].some((e=>t.includes(e)))}function fcn_isUserLoggedIn(){const t=document.cookie.split(";");for(let e=0;e{const e=t.target.closest(".toggle-last-clicked");!["BUTTON","A"].includes(t.target.tagName)&&e||null!==t.target.closest(".escape-last-click")||fcn_lastClicked&&e!=fcn_lastClicked&&fcn_removeLastClick(fcn_lastClicked)})),_$("body").addEventListener("keydown",(t=>{27==t.keyCode&&fcn_lastClicked&&(fcn_removeLastClick(fcn_lastClicked),document.activeElement?.blur())})),_$$$("full-navigation")?.addEventListener("mouseover",(()=>{fcn_lastClicked&&(fcn_removeLastClick(fcn_lastClicked),document.activeElement?.blur())}));const fcn_theSite=_$$$("site"),fcn_theBody=_$("body"),fcn_theRoot=document.documentElement,fcn_urlParams=Object.fromEntries(new URLSearchParams(window.location.search).entries()),fcn_pageLoadTimestamp=Date.now(),fcn_ajaxLimitThreshold=Date.now()-parseInt(fictioneer_ajax.ttl);var fcn_isLoggedIn=fcn_theBody.classList.contains("logged-in");function fcn_cleanupWebStorage(t=!1){const e=["fcnProfileAvatar","fcnBookshelfContent"];t||e.push("fcnChapterBookmarks"),e.forEach((t=>localStorage.removeItem(t)));const n=["loggedIn","follows","reminders","checkmarks","bookmarks","fingerprint"],a=fcn_parseJSON(localStorage.getItem("fcnUserData"));a&&(n.forEach((t=>a[t]=!1)),localStorage.setItem("fcnUserData",JSON.stringify(a)));const o=fcn_parseJSON(localStorage.getItem("fcnAuth"));o?.loggedIn&&localStorage.removeItem("fcnAuth")}function fcn_prepareLogin(){localStorage.removeItem("fcnUserData"),localStorage.removeItem("fcnAuth")}function fcn_cleanupGuestView(){fcn_isLoggedIn=!1,fcn_theBody.classList.remove("logged-in","is-admin","is-moderator","is-editor","is-author"),_$$$("fictioneer-ajax-nonce")?.remove(),_$$(".only-moderators, .only-admins, .only-authors, .only-editors, .chapter-group__list-item-checkmark").forEach((t=>{t.remove()}))}function fcn_ajaxAuth(){let t=!1,e=fcn_parseJSON(localStorage.getItem("fcnAuth"))??!1;if(fcn_isLoggedIn&&!e?.loggedIn&&(localStorage.removeItem("fcnAuth"),e=!1),e){fcn_addNonceHTML(e.nonceHtml);const n=new CustomEvent("fcnAuthReady",{detail:{nonceHtml:e.nonceHtml,nonce:e.nonce,loggedIn:e.loggedIn,isAdmin:e.isAdmin,isModerator:e.isModerator,isAuthor:e.isAuthor,isEditor:e.isEditor},bubbles:!0,cancelable:!1});if(document.dispatchEvent(n),t=!0,fcn_ajaxLimitThreshold{if(e.success){fcn_addNonceHTML(e.data.nonceHtml);const n={lastLoaded:Date.now(),nonceHtml:e.data.nonceHtml,nonce:e.data.nonce,loggedIn:e.data.loggedIn,isAdmin:e.data.isAdmin,isModerator:e.data.isModerator,isAuthor:e.data.isAuthor,isEditor:e.data.isEditor};if(!t){const t=new CustomEvent("fcnAuthReady",{detail:n,bubbles:!0,cancelable:!1});document.dispatchEvent(t)}localStorage.setItem("fcnAuth",JSON.stringify(n))}else{fcn_cleanupGuestView();const t=new Event("fcnAuthFailed");document.dispatchEvent(t)}})).catch((()=>{localStorage.removeItem("fcnAuth"),fcn_cleanupGuestView();const t=new Event("fcnAuthError");document.dispatchEvent(t)}))}function fcn_addNonceHTML(t){_$$$("fictioneer-ajax-nonce")?.remove(),fcn_theBody.appendChild(fcn_html`${t}`)}function fcn_setLoggedInState(t){fcn_isLoggedIn=t.loggedIn,fcn_theBody.classList.add("logged-in"),fcn_theBody.classList.toggle("is-admin",t.isAdmin),fcn_theBody.classList.toggle("is-moderator",t.isModerator),fcn_theBody.classList.toggle("is-author",t.isAuthor),fcn_theBody.classList.toggle("is-editor",t.isEditor);const e=['label[for="modal-login-toggle"]',"#modal-login-toggle","#login-modal"];t.isAdmin||(e.push(".only-admins"),t.isModerator||e.push(".only-moderators"),t.isAuthor||e.push(".only-authors"),t.isEditor||e.push(".only-editors")),_$$(e.join(", ")).forEach((t=>t.remove())),fcn_getProfileImage(),fcn_fetchUserData()}function fcn_loadEmbed(t){t.target.parentNode.querySelectorAll("iframe, script")[0].src=t.target.dataset.src,t.target.parentElement.querySelector(".embed-logo")?.remove(),t.target.remove()}function fcn_appendTermMenu(t,e){const n=_$$$(`term-submenu-${t}`);if(!n)return;const a=n.content.cloneNode(!0);e.classList.add("menu-item-has-children"),e.querySelector('[href="#"]').addEventListener("click",(t=>{t.preventDefault()})),e.appendChild(a)}fcn_isLoggedIn||fcn_theRoot.dataset.ajaxAuth||(fcn_cleanupWebStorage(!0),fcn_cleanupGuestView()),"function"==typeof fcn_removeQueryArgs&&fcn_removeQueryArgs(),_$("#wp-admin-bar-logout a")?.addEventListener("click",(()=>{fcn_cleanupWebStorage()})),_$$(".subscriber-login, .oauth-login-link, [data-prepare-login]").forEach((t=>{t.addEventListener("click",(()=>{fcn_prepareLogin()}))})),document.addEventListener("DOMContentLoaded",(()=>{fcn_theRoot.dataset.ajaxAuth&&fcn_ajaxAuth()})),!fcn_isLoggedIn&&fcn_theRoot.dataset.ajaxAuth&&document.addEventListener("fcnAuthReady",(t=>{t.detail.loggedIn?fcn_setLoggedInState(t.detail):(fcn_cleanupWebStorage(!0),fcn_cleanupGuestView())})),fcn_bindEventToAnimationFrame("scroll","scroll.rAF"),fcn_bindEventToAnimationFrame("resize","resize.rAF"),fcn_theBody.addEventListener("click",(t=>{const e=t.target.closest(".toggle-last-clicked");if(e&&(!["BUTTON","A","INPUT","SELECT"].includes(t.target.tagName)||t.target.classList.contains("toggle-last-clicked")))return fcn_toggleLastClicked?.(e),"function"==typeof fcn_popupPosition&&fcn_popupPosition(),void t.stopPropagation();const n=t.target.closest(".page-numbers.dots:not(button)");if(n)return void fcn_jumpPage(n);const a=t.target.closest(".spoiler");if(a)return void a.classList.toggle("_open");t.target.closest(".oauth-login-link, .subscriber-login, [data-prepare-login]")&&fcn_prepareLogin();const o=t.target.closest("[data-click]"),c=o?.dataset.click;if(c)switch(c){case"copy-to-clipboard":o.select(),fcn_copyToClipboard(o.value,o.dataset.message);break;case"reset-consent":fcn_deleteCookie("fcn_cookie_consent"),location.reload();break;case"clear-cookies":fcn_deleteAllCookies(),alert(o.dataset.message);break;case"logout":fcn_cleanupWebStorage();break;case"card-toggle-follow":fcn_isLoggedIn?fcn_toggleFollow(o.dataset.storyId):_$$$("modal-login-toggle")?.click();break;case"card-toggle-reminder":fcn_isLoggedIn?fcn_toggleReminder(o.dataset.storyId):_$$$("modal-login-toggle")?.click();break;case"card-toggle-checkmarks":fcn_isLoggedIn?(fcn_toggleCheckmark(parseInt(o.dataset.storyId),o.dataset.type,parseInt(o.dataset.chapterId),null,o.dataset.mode),fcn_updateCheckmarksView()):_$$$("modal-login-toggle")?.click();break;case"toggle-obfuscation":o.closest("[data-obfuscation-target]").classList.toggle("_obfuscated")}})),fcn_theBody.addEventListener("change",(t=>{const e=t.target.closest('[type="checkbox"]');if(!e)return;const n=e.name,a=n?_$$(`label[for="${n}"]`):[],o=e.checked;e.closest("[aria-checked]")?.setAttribute("aria-checked",o),a.forEach((t=>{t.closest("[aria-checked]")?.setAttribute("aria-checked",o)}))})),_$$(".iframe-consent, .twitter-consent").forEach((t=>{t.onclick=t=>{fcn_loadEmbed(t)}})),document.addEventListener("DOMContentLoaded",(()=>{const t=_$("#menu-navigation > .menu-item"),e=_$$$("full-navigation");t&&e&&t.offsetHeight{fcn_appendTermMenu("category",t)})),_$$(".main-navigation .trigger-term-menu-tags").forEach((t=>{fcn_appendTermMenu("post_tag",t)})),_$$(".main-navigation .trigger-term-menu-genres").forEach((t=>{fcn_appendTermMenu("fcn_genre",t)})),_$$(".main-navigation .trigger-term-menu-fandoms").forEach((t=>{fcn_appendTermMenu("fcn_fandom",t)})),_$$(".main-navigation .trigger-term-menu-characters").forEach((t=>{fcn_appendTermMenu("fcn_character",t)})),_$$(".main-navigation .trigger-term-menu-warnings").forEach((t=>{fcn_appendTermMenu("fcn_content_warning",t)}))}));var fcn_lastScrollTop=0;function fcn_scrollDirection(){if(fcn_theSite.classList.contains("transformed-scroll"))return;const t="hidden"!==window.getComputedStyle(document.documentElement).overflow?window.scrollY??document.documentElement.scrollTop:fcn_theBody.scrollTop??1;fcn_theBody.classList.toggle("scrolled-to-top",0===t),t>fcn_lastScrollTop&&Math.abs(fcn_lastScrollTop-t)>=10?(fcn_theBody.classList.add("scrolling-down"),fcn_theBody.classList.remove("scrolling-up"),fcn_lastScrollTop=Math.max(t,0)):t=50&&(fcn_theBody.classList.add("scrolling-up"),fcn_theBody.classList.remove("scrolling-down"),fcn_lastScrollTop=Math.max(t,0))}function fcn_observe(t,e,n={}){const a=_$(t);if(!a)return null;new IntersectionObserver((t=>e(t[0])),n).observe(a)}function fcn_dragElement(t){const e=t.querySelector(".drag-anchor")??t;let n,a;function o(e){e.preventDefault(),t.style.top=t.offsetTop-(a-e.clientY)+"px",t.style.left=t.offsetLeft-(n-e.clientX)+"px",n=e.clientX,a=e.clientY}function c(){e.onmouseup=null,e.onmousemove=null}e.onmousedown=function(t){t.preventDefault(),n=t.clientX,a=t.clientY,e.onmousemove=o,e.onmouseup=c}}function fcn_showNotification(t,e=3,n="base"){const a=_$("#notifications"),o=document.createElement("div");o.innerHTML=t,o.classList.add("notifications__message",`_${n}`),o.style.opacity=1,o.style.transitionDelay=`${e}s`,a.prepend(o),o.addEventListener("transitionend",(t=>{"opacity"===t.propertyName&&a.removeChild(t.target)})),o.addEventListener("click",(t=>{a.removeChild(t.currentTarget)})),setTimeout((()=>{o.style.opacity=0}),100)}if(window.addEventListener("scroll.rAF",fcn_throttle(fcn_scrollDirection,200)),fcn_scrollDirection(),document.addEventListener("DOMContentLoaded",(()=>{fcn_observe(".main-observer",(t=>{fcn_theBody.classList.toggle("is-inside-main",t.intersectionRatio<1&&t.boundingClientRect.top<=0)}),{threshold:[1]}),fcn_observe(".chapter-end",(t=>{fcn_theBody.classList.toggle("is-end-of-chapter",t.isIntersecting||t.boundingClientRect.top<0)}),{root:null,threshold:0}),fcn_observe("#nav-observer-sticky",(t=>{_$$$("full-navigation").classList.toggle("is-sticky",t.intersectionRatio<1)}),{threshold:[1]})})),_$$(".modal__header.drag-anchor").forEach((t=>{fcn_dragElement(t.closest(".modal__wrapper"))})),fcn_urlParams){switch(fcn_urlParams.failure&&console.error("Failure:",fcn_urlParams.failure),fcn_urlParams.failure){case"oauth_email_taken":fcn_showNotification(fictioneer_tl.notification.oauthEmailTaken,5,"warning");break;case"oauth_already_linked":fcn_showNotification(fictioneer_tl.notification.oauthAccountAlreadyLinked,5,"warning")}if("oauth_new"===fcn_urlParams.success)fcn_showNotification(fictioneer_tl.notification.oauthNew,10);else fcn_urlParams.success?.startsWith("oauth_merged_")&&fcn_showNotification(fictioneer_tl.notification.oauthAccountLinked,3,"success");if(fcn_urlParams["fictioneer-notice"]){let t="1"===fcn_urlParams.failure?"warning":"base";t="1"===fcn_urlParams.success?"success":t,fcn_showNotification(fcn_sanitizeHTML(fcn_urlParams["fictioneer-notice"]),3,t)}}const fcn_settingMinimal=_$$$("site-setting-minimal"),fcn_settingChapterProgressBar=_$$$("site-setting-chapter-progress-bar"),fcn_settingHueRotateRange=_$$$("site-setting-hue-rotate-range"),fcn_settingHueRotateText=_$$$("site-setting-hue-rotate-text"),fcn_settingHueRotateReset=_$$$("site-setting-hue-rotate-reset"),fcn_settingDarkenRanges=_$$(".setting-darken-range"),fcn_settingDarkenTexts=_$$(".setting-darken-text"),fcn_settingDarkenResets=_$$(".setting-darken-reset"),fcn_settingSaturationRanges=_$$(".setting-saturation-range"),fcn_settingSaturationTexts=_$$(".setting-saturation-text"),fcn_settingSaturationResets=_$$(".setting-saturation-reset"),fcn_settingFontLightnessRanges=_$$(".setting-font-lightness-range"),fcn_settingFontLightnessTexts=_$$(".setting-font-lightness-text"),fcn_settingFontLightnessResets=_$$(".setting-font-lightness-reset"),fcn_settingEvents=["nav-sticky","background-textures","polygons","covers","taxonomies","text-shadows","minimal","chapter-progress-bar"];var fcn_siteSettings=fcn_getSiteSettings();function fcn_updateSiteSetting(t,e,n){t.checked=n,fcn_siteSettings[e]=n,fcn_applySiteSettings(fcn_siteSettings)}function fcn_toggleLightMode(){fcn_setLightMode(!(localStorage.getItem("fcnLightmode")?"true"==localStorage.getItem("fcnLightmode"):"light"==fcn_theRoot.dataset.modeDefault))}function fcn_setLightMode(t,e=!1){localStorage.setItem("fcnLightmode",t),fcn_theRoot.dataset.mode=t?"light":"dark",_$$(".toggle-light-mode").forEach((e=>{e.closest("[aria-checked]")?.setAttribute("aria-checked",t)})),e||fcn_updateThemeColor()}function fcn_updateFontWeight(){const t="default"!=fcn_siteSettings["font-weight"];_$$(".site-setting-font-weight").forEach((t=>{t.value=fcn_siteSettings["font-weight"]})),_$$(".font-weight-reset").forEach((e=>{e.classList.toggle("_modified",t)}))}function fcn_resetFontWeight(){fcn_siteSettings["font-weight"]="default",fcn_theRoot.dataset.fontWeight="default",fcn_applySiteSettings(fcn_siteSettings)}function fcn_updateHueRotate(t){t=fcn_clamp(0,360,t??0),fcn_settingHueRotateText.value=t,fcn_settingHueRotateRange.value=t,fcn_settingHueRotateReset.classList.toggle("_modified",0!=t),fcn_theRoot.style.setProperty("--hue-rotate",`(${t}deg + var(--hue-offset))`),fcn_siteSettings["hue-rotate"]=t,fcn_setSiteSettings(),fcn_updateThemeColor()}function fcn_setHueRotate(){fcn_updateHueRotate(this.value)}function fcn_updateDarken(t=null){t=fcn_clamp(-1,1,t??fcn_siteSettings.darken),t=Math.round(100*(t+Number.EPSILON))/100,fcn_settingDarkenResets.forEach((e=>{e.classList.toggle("_modified",0!=t)})),fcn_settingDarkenRanges.forEach((e=>{e.value=t})),fcn_settingDarkenTexts.forEach((e=>{e.value=parseInt(100*t)}));const e=t>=0?1+t**2:1-t**2;fcn_theRoot.style.setProperty("--darken",`(${e} + var(--lightness-offset))`),fcn_siteSettings.darken=t,fcn_setSiteSettings(),fcn_updateThemeColor()}function fcn_setDarkenFromRange(){fcn_updateDarken(this.value)}function fcn_setDarkenFromText(){"-"!=this.value&&""!=this.value&&fcn_updateDarken((parseInt(this.value)??0)/100)}function fcn_updateSaturation(t=null){t=fcn_clamp(-1,1,t??fcn_siteSettings.saturation),fcn_settingSaturationResets.forEach((e=>{e.classList.toggle("_modified",0!=t)})),fcn_settingSaturationRanges.forEach((e=>{e.value=t})),fcn_settingSaturationTexts.forEach((e=>{e.value=parseInt(100*t)}));const e=t>=0?1+t**2:1-t**2;fcn_theRoot.style.setProperty("--saturation",`(${e} + var(--saturation-offset))`),fcn_siteSettings.saturation=t,fcn_setSiteSettings(),fcn_updateThemeColor()}function fcn_setSaturationFromRange(){fcn_updateSaturation(this.value)}function fcn_setSaturationFromText(){"-"!=this.value&&""!=this.value&&fcn_updateSaturation((parseInt(this.value)??0)/100)}function fcn_updateFontLightness(t=null){t=fcn_clamp(-1,1,t??fcn_siteSettings["font-lightness"]??1),fcn_settingFontLightnessResets.forEach((e=>{e.classList.toggle("_modified",0!=t)})),fcn_settingFontLightnessRanges.forEach((e=>{e.value=t})),fcn_settingFontLightnessTexts.forEach((e=>{e.value=parseInt(100*t)}));const e=t>=0?1+t**2:1-t**2;fcn_theRoot.style.setProperty("--font-lightness",`(${e} + var(--font-lightness-offset))`),fcn_siteSettings["font-lightness"]=t,fcn_setSiteSettings(),fcn_updateThemeColor()}function fcn_setFontLightnessFromRange(){fcn_updateFontLightness(this.value)}function fcn_setFontLightnessFromText(){"-"!=this.value&&""!=this.value&&fcn_updateFontLightness((parseInt(this.value)??0)/100)}function fcn_defaultSiteSettings(){return{"nav-sticky":!0,"background-textures":!0,polygons:!0,covers:!0,taxonomies:!0,"text-shadows":!1,minimal:!1,"chapter-progress-bar":!0,"site-theme":"default","font-weight":"default",darken:0,saturation:0,"font-saturation":0,"font-lightness":0,"hue-rotate":0}}function fcn_getSiteSettings(){const t=fcn_parseJSON(localStorage.getItem("fcnSiteSettings"))??fcn_defaultSiteSettings();return fcn_setSiteSettings(t),t}function fcn_setSiteSettings(t=null){"object"==typeof(t=t||fcn_siteSettings)&&(fcn_siteSettings=t,localStorage.setItem("fcnSiteSettings",JSON.stringify(t)))}function fcn_applySiteSettings(t){t="object"!=typeof t?fcn_defaultSiteSettings():t,Object.entries(t).forEach((t=>{const e=_$$$(`site-setting-${t[0]}`);switch(e&&(e.checked=t[1]),t[0]){case"minimal":fcn_theRoot.classList.toggle("minimal",t[1]);break;case"darken":fcn_updateDarken();break;case"saturation":fcn_updateSaturation();break;case"font-saturation":break;case"font-lightness":fcn_updateFontLightness();break;case"hue-rotate":fcn_updateHueRotate(t[1]);break;case"font-weight":fcn_updateFontWeight();break;default:fcn_theRoot.classList.toggle(`no-${t[0]}`,!t[1])}})),fcn_setSiteSettings(t)}function fcn_updateSiteTheme(t){fcn_siteSettings["site-theme"]=t,fcn_theRoot.dataset.theme=t,_$$$("site-setting-theme-reset").classList.toggle("_modified","default"!=t),fcn_applySiteSettings(fcn_siteSettings),fcn_updateThemeColor()}function fcn_resetSiteTheme(){fcn_updateSiteTheme("default"),_$$(".site-setting-site-theme").forEach((t=>{t.value="default"}))}function fcn_jumpPage(t){if(fcn_theRoot.dataset.disablePageJump)return;const e=parseInt(window.prompt(fictioneer_tl.notification.enterPageNumber));if(e>0){const n=t.nextElementSibling.getAttribute("href"),a=["page=","paged=","comment-page-","pg="];for(const t of a)if(n.includes(t))return void(window.location.href=n.replace(new RegExp(`${t}\\d+`),t+e));window.location.href=n.replace(/page\/\d+/,`page/${e}`)}}fcn_settingEvents.forEach((t=>{_$$$(`site-setting-${t}`)?.addEventListener("change",(e=>{fcn_updateSiteSetting(e.currentTarget,t,e.currentTarget.checked)}))})),fcn_setLightMode(localStorage.getItem("fcnLightmode")?"true"==localStorage.getItem("fcnLightmode"):"light"==fcn_theRoot.dataset.modeDefault,!0),_$$(".toggle-light-mode").forEach((t=>{t.onclick=()=>fcn_toggleLightMode()})),_$$(".font-weight-reset").forEach((t=>{t.addEventListener("click",fcn_resetFontWeight)})),_$$(".site-setting-font-weight").forEach((t=>{t.onchange=t=>{fcn_siteSettings["font-weight"]=t.target.value,fcn_theRoot.dataset.fontWeight=t.target.value,fcn_applySiteSettings(fcn_siteSettings),fcn_updateFontWeight()}})),fcn_settingHueRotateReset?.addEventListener("click",(()=>{fcn_updateHueRotate(0)})),fcn_settingHueRotateRange?.addEventListener("input",fcn_throttle(fcn_setHueRotate,1e3/24)),fcn_settingHueRotateText?.addEventListener("input",fcn_setHueRotate),fcn_settingDarkenResets.forEach((t=>{t.addEventListener("click",(()=>{fcn_updateDarken(0)}))})),fcn_settingDarkenRanges.forEach((t=>{t.addEventListener("input",fcn_throttle(fcn_setDarkenFromRange,1e3/24))})),fcn_settingDarkenTexts.forEach((t=>{t.addEventListener("input",fcn_setDarkenFromText)})),fcn_settingSaturationResets.forEach((t=>{t.addEventListener("click",(()=>{fcn_updateSaturation(0)}))})),fcn_settingSaturationRanges.forEach((t=>{t.addEventListener("input",fcn_throttle(fcn_setSaturationFromRange,1e3/24))})),fcn_settingSaturationTexts.forEach((t=>{t.addEventListener("input",fcn_setSaturationFromText)})),fcn_settingFontLightnessResets.forEach((t=>{t.addEventListener("click",(()=>{fcn_updateFontLightness(0)}))})),fcn_settingFontLightnessRanges.forEach((t=>{t.addEventListener("input",fcn_throttle(fcn_setFontLightnessFromRange,1e3/24))})),fcn_settingFontLightnessTexts.forEach((t=>{t.addEventListener("input",fcn_setFontLightnessFromText)})),fcn_applySiteSettings(fcn_siteSettings),_$$(".site-setting-site-theme").forEach((t=>{t.value=fcn_siteSettings["site-theme"]?fcn_siteSettings["site-theme"]:"default",_$$$("site-setting-theme-reset").classList.toggle("_modified","default"!=t.value),t.addEventListener("change",(t=>{fcn_updateSiteTheme(t.target.value)}))})),_$$$("site-setting-theme-reset")?.addEventListener("click",fcn_resetSiteTheme),fcn_updateThemeColor();const fcn_cardListMutationObserver=new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.length>0&&("function"==typeof fcn_updateFollowsView&&fcn_updateFollowsView(),"function"==typeof fcn_updateCheckmarksView&&fcn_updateCheckmarksView(),"function"==typeof fcn_updateRemindersView&&fcn_updateRemindersView())}))}));function fcn_revealCommentImage(t){const e=t.parentElement.querySelector("img");e.src=e.dataset.src,t.remove()}function fcn_contactFormSubmit(t){const e=t.closest("form"),n=new FormData(e),a={action:"fictioneer_ajax_submit_contact_form"};if(e.reportValidity()&&(t.disabled=!0,t.innerHTML=t.dataset.disabled,!(Date.now(){n.success?(e.querySelector("textarea").value="",t.innerHTML=t.dataset.done,fcn_showNotification(n.data.success,3,"success")):n.data.failure&&(t.disabled=!1,t.innerHTML=t.dataset.enabled,fcn_showNotification(n.data.failure,5,"warning"))})).catch((e=>{e.status&&e.statusText&&(fcn_showNotification(`${e.status}: ${e.statusText}`,5,"warning"),t.disabled=!1,t.innerHTML=t.dataset.enabled),console.error(e)})).then((()=>{e.classList.remove("ajax-in-progress")}))}}_$$(".card-list:not(._no-mutation-observer)").forEach((t=>fcn_cardListMutationObserver.observe(t,{childList:!0,subtree:!0}))),_$$(".chapter-group__name").forEach((t=>{t.addEventListener("click",(t=>{const e=t.currentTarget.closest(".chapter-group"),n=e.querySelector(".chapter-group__list"),a=!e.classList.contains("_closed");_$(".main__background")?.classList.add("will-change"),n.style.height=`${n.scrollHeight}px`,requestAnimationFrame((()=>{requestAnimationFrame((()=>{e.classList.toggle("_closed",a),n.style.height=a?"0":`${n.scrollHeight}px`}))}))}))})),_$$(".chapter-group__list").forEach((t=>{t.addEventListener("transitionend",(e=>{t.style.height="",t.querySelectorAll("a, button, label, input:not([hidden])").forEach((e=>{e.tabIndex=t.parentElement.classList.contains("_closed")?"-1":"0"})),_$(".main__background")?.classList.remove("will-change")}))})),_$(".fictioneer-comments")?.addEventListener("click",(t=>{t.target?.classList.contains("consent-button")&&fcn_revealCommentImage(t.target)})),_$$(".fcn-contact-form").forEach((t=>{t.querySelector(".fcn-contact-form__submit").addEventListener("click",(t=>{fcn_contactFormSubmit(t.currentTarget)}))})),fcn_theBody.querySelectorAll(".modal-toggle").forEach((t=>{t.addEventListener("change",(t=>{if(t.currentTarget.checked){const e=t.currentTarget.nextElementSibling.querySelector('[tabindex="0"]');e?.focus(),e?.blur()}else fcn_theBody.classList.contains("user-is-tabbing")&&fcn_theSite.querySelector(`label[for="${t.currentTarget.id}"]`)?.focus()}))})),_$$('[data-click-action*="open-dialog-modal"]').forEach((t=>{t.addEventListener("click",(t=>{document.querySelector(t.currentTarget.dataset.clickTarget).showModal()}))})),_$$('[data-click-action*="close-dialog-modal"], button[formmethod="dialog"][value="cancel"]').forEach((t=>{t.addEventListener("click",(t=>{t.preventDefault(),t.target.closest("dialog").close()}))})),_$$("dialog").forEach((t=>{t.addEventListener("mousedown",(e=>{if(e.target===e.currentTarget){const n=t.getBoundingClientRect();(e.clientXn.right||e.clientYn.bottom)&&(e.preventDefault(),e.target.close())}}))})),_$$(".content-section").forEach((t=>{t.addEventListener("click",(t=>{if(t.target.closest('[data-click-action*="open-tooltip-modal"]')&&!window.getSelection().toString()){const e=_$$$("fictioneer-tooltip-dialog"),n=t.target.dataset.dialogHeader,a=t.target.dataset.dialogContent;a.length>200?e.style.setProperty("--modal-width","400px"):e.style.removeProperty("--modal-width"),n&&(e.querySelector('[data-finder="tooltip-dialog-header"]').innerHTML=n),e.querySelector('[data-finder="tooltip-dialog-content"]').innerHTML=a,e.showModal()}}))})),fcn_theBody.addEventListener("keydown",(t=>{let e=document.activeElement.closest('[tabindex="0"]:not(a, input, button, select)');if(["BUTTON","A","INPUT","SELECT"].includes(document.activeElement.tagName)&&(e=null),e&&(32!=t.keyCode&&13!=t.keyCode||(t.preventDefault(),e.click())),27==t.keyCode){_$$(".modal-toggle:checked").forEach((t=>{t.checked=!1,t.dispatchEvent(new Event("change"))}));const t=_$(".lightbox.show");if(t)return void t.querySelector(".lightbox__close").click();const e=_$(".selected-paragraph #button-close-paragraph-tools");if(e)return void e.click();const n=_$("#tts-interface:not(.hidden)");if(n){if(n.classList.contains("playing")){const t=_$$$("button-tts-pause");t?.click(),t?.focus(),t?.blur()}else _$$$("button-tts-stop").click();return}}}));class FCN_KeywordInput{constructor(t){this.input=t,this.operator=t.closest(".keyword-input").querySelector(".keyword-input__operator input"),this.inputWrapper=t.closest(".keyword-input__input-wrapper"),this.block=t.closest(".keyword-input"),this.form=this.block.closest(".search-form"),this.collection=this.block.querySelector(".keyword-input__collection"),this.suggestionList=this.block.querySelector(".keyword-input__suggestion-list"),
-this.tabSuggestion=this.block.querySelector(".keyword-input__tab-suggestion"),this.allowText=this.form.querySelector(".allow-list")?.innerText??"{}",this.allowList=JSON.parse(this.allowText),this.hints=this.block.querySelector(".keyword-input__hints"),this.noHint=this.block.querySelector(".keyword-input__no-suggestions"),this.keywords=this.collection.value.length>0?this.collection.value.split(","):[],this.bindEvents(),this.resize(),this.filterSuggestions()}resize(){const t=this.tabSuggestion.innerText.length>0?this.tabSuggestion.innerText.length:this.input.value.length;this.input.style.width=.88*t+2+"ch"}reset(){this.keywords=[],this.block.querySelectorAll(".node").forEach((t=>{t.remove()})),this.block.querySelectorAll(".keyword-input__operator > input").forEach((t=>{t.checked=!1})),this.input.value="",this.updateCollection(),this.filterSuggestions(),this.resize()}encode(t){const e=(new TextEncoder).encode(t.toLowerCase());return btoa(String.fromCharCode.apply(null,e))}filterSuggestions(){const t=this.input.value.toLowerCase();let e=0,n="";""==t?this.suggestionList.querySelectorAll(".keyword-button").forEach((t=>{t.hidden=!0})):this.suggestionList.querySelectorAll(".keyword-button").forEach((a=>{const o=a.innerText.toLowerCase();o.includes(t)&&this.keywords.indexOf(o)<0?(a.hidden=!1,e++,""==n&&o.startsWith(t)&&(n=o)):a.hidden=!0})),this.hints.querySelectorAll(".keyword-button").forEach((t=>{this.keywords.indexOf(t.value.toLowerCase())>-1?t.hidden=!0:t.hidden=!1})),this.tabSuggestion.innerHTML=n,this.hints.hidden=!(""==t),this.noHint.hidden=!(""!=t&&e<1)}addNode(t=null,e=null){const n=t??this.input.value.replace(",","");let a=this.allowList[this.encode(n)];if("authors"!=this.collection.name&&"ex_authors"!=this.collection.name||!e||(a=this.allowList[this.encode(n)+`_${e.value}`]),!a||this.keywords.indexOf(a)>-1)return;this.keywords.push(a);const o=document.createElement("div");o.innerHTML=`${n}`,o.classList.add("node"),o.dataset.value=a,this.inputWrapper.parentNode.insertBefore(o,this.inputWrapper),this.input.value="",this.updateCollection(),this.filterSuggestions(),this.resize()}removeNodeByValue(t){this.block.querySelector(`[data-value="${t}"]`)?.remove(),this.keywords=this.keywords.filter((e=>e!=t)),this.updateCollection(),this.filterSuggestions(),this.resize()}updateCollection(){this.collection.value=this.keywords.join(","),this.block.classList.toggle("_empty",""===this.collection.value),this.form.querySelector(".search-form__current").innerHTML=""}bindEvents(){this.input.addEventListener("input",(t=>{t.currentTarget.value.includes(",")&&this.addNode(),this.block.classList.toggle("_empty",""===t.currentTarget.value&&""===this.collection.value),this.filterSuggestions(),this.resize()})),this.input.addEventListener("keydown",(t=>{9!=t.keyCode&&13!=t.keyCode||""!=this.tabSuggestion.innerText&&(t.preventDefault(),this.input.value=this.tabSuggestion.innerText,this.addNode()),27==t.keyCode&&(this.input.value="",this.tabSuggestion.innerHTML="",document.activeElement.blur()),8==t.keyCode&&""==this.input.value&&this.keywords.length>0&&this.removeNodeByValue(this.keywords.slice(-1))})),this.input.addEventListener("blur",(()=>{const t=this.allowList[this.encode(this.input.value)];this.blurTimeout=t?setTimeout((()=>{this.addNode()}),150):setTimeout((()=>{this.input.value="",this.tabSuggestion.innerHTML="",this.filterSuggestions(),this.resize()}),150)})),this.block.addEventListener("click",(t=>{t.target.closest(".node-delete")&&(t.preventDefault(),this.removeNodeByValue(t.target.closest(".node").dataset.value))})),this.block.querySelectorAll(".keyword-button").forEach((t=>{t.addEventListener("click",(t=>{clearTimeout(this.blurTimeout),this.addNode(t.currentTarget.innerText,t.currentTarget)}))}))}}function fcn_resetSearchForm(t,e,n){n.forEach((t=>t.reset())),e.querySelectorAll("input, select").forEach((t=>{t.value=t.dataset.default??t.value})),e.querySelector(".search-form__current").innerHTML="",fcn_showNotification(t.dataset.reset,2)}function fcn_handleTabInput(t){9==t.keyCode&&(fcn_theBody.classList.add("user-is-tabbing"),window.removeEventListener("keydown",fcn_handleTabInput),window.addEventListener("mousedown",fcn_handleMouseInput))}function fcn_handleMouseInput(){fcn_theBody.classList.remove("user-is-tabbing"),window.removeEventListener("mousedown",fcn_handleMouseInput),window.addEventListener("keydown",fcn_handleTabInput)}function fcn_popupPosition(){_$$(".popup-menu-toggle.last-clicked .popup-menu:not(._fixed-position)").forEach((t=>{if("none"===window.getComputedStyle(t).display)return;const e=fcn_detectScreenCollision(t);e&&0===e.length||(e.includes("top")?(t.classList.remove("_top"),t.classList.add("_bottom")):e.includes("bottom")&&(t.classList.remove("_bottom"),t.classList.add("_top")),t.closest("._fixed-horizontal")||(e.includes("left")?(t.classList.remove("_center","_justify-right"),t.classList.add("_justify-left")):e.includes("right")&&(t.classList.remove("_center","_justify-left"),t.classList.add("_justify-right"))))}))}function fcn_markCurrentMenuItem(){_$$(`.menu-item > [data-nav-object-id="${fcn_theBody.dataset.postId}"]`).forEach((t=>{t.setAttribute("aria-current","page"),t.closest(".menu-item").classList.add("current-menu-item")}))}function fcn_showAgeConfirmationModal(){const t=_$(".story__article, .chapter__article")?.dataset.ageRating;if(!fcn_theRoot.dataset.ageConfirmation&&t&&"adult"!==t)return void _$$$("age-confirmation-modal")?.remove();const e=_$$$("age-confirmation-leave");fcn_theRoot.classList.add("age-modal-open"),_$$$("age-confirmation-modal").classList.add("_open"),_$$$("age-confirmation-confirm")?.addEventListener("click",(t=>{fcn_theRoot.classList.remove("age-modal-open"),t.currentTarget.closest(".modal").remove(),localStorage.setItem("fcnAgeConfirmation","1")})),e?.addEventListener("click",(()=>{window.location.href=e.dataset.redirect??"https://search.brave.com/",localStorage.removeItem("fcnAgeConfirmation")}))}function fcn_showLightbox(t){const e=_$$$("fictioneer-lightbox"),n=_$(".lightbox__content");let a=!1,o=null;if(n.innerHTML="",t.classList.add("lightbox-last-trigger"),"IMG"==t.tagName?(o=t.cloneNode(),a=!0):t.href&&(o=document.createElement("img"),o.src=t.href,a=!0),a&&o){["class","style","height","width"].forEach((t=>o.removeAttribute(t))),n.appendChild(o),e.classList.add("show");const t=e.querySelector(".lightbox__close");t?.focus(),t?.blur()}}function fcn_toggleMobileMenu(t){_$(".mobile-menu._advanced-mobile-menu")?fcn_toggleAdvancedMobileMenu(t):fcn_toggleSimpleMobileMenu(t)}function fcn_toggleSimpleMobileMenu(t){t?(fcn_theBody.classList.add("mobile-menu-open","scrolling-down"),fcn_theBody.classList.remove("scrolling-up")):(fcn_theBody.classList.remove("mobile-menu-open"),fcn_closeMobileFrames(),fcn_openMobileFrame("main"),_$$$("mobile-menu-toggle").checked=!1)}function fcn_toggleAdvancedMobileMenu(t){const e=_$$$("wpadminbar")?.offsetHeight??0,n=window.scrollY,a=fcn_theSite.scrollTop;t?(fcn_theBody.classList.add("mobile-menu-open","scrolling-down","scrolled-to-top"),fcn_theBody.classList.remove("scrolling-up"),fcn_theSite.classList.add("transformed-scroll","transformed-site"),fcn_theSite.scrollTop=n-e,fcn_updateThemeColor()):(fcn_theSite.classList.remove("transformed-site","transformed-scroll"),fcn_theBody.classList.remove("mobile-menu-open"),fcn_updateThemeColor(),fcn_closeMobileFrames(),fcn_openMobileFrame("main"),fcn_theRoot.style.scrollBehavior="auto",window.scroll(0,a+e),fcn_theRoot.style.scrollBehavior="",_$$$("mobile-menu-toggle").checked=!1,"function"==typeof fcn_trackProgress&&fcn_trackProgress())}function fcn_setupMobileJumpButton(t,e){const n=_$(t);n&&n.addEventListener("click",(()=>{fcn_toggleMobileMenu(!1),setTimeout((()=>{const t=e();t&&fcn_scrollTo(t)}),200)}))}function fcn_openMobileFrame(t){fcn_closeMobileFrames(),_$(`.mobile-menu__frame[data-frame="${t}"]`)?.classList.add("_active")}function fcn_closeMobileFrames(){_$$(".mobile-menu__frame._active").forEach((t=>{t.classList.remove("_active")}));const t=_$(".mobile-menu__bookmarks-panel");t&&(t.dataset.editing="false")}_$$(".search-form").forEach((t=>{if(t.classList.contains("_simple"))return;const e=[];t.querySelectorAll(".keyword-input__input").forEach((t=>{e.push(new FCN_KeywordInput(t))})),t.querySelector(".allow-list")?.remove(),t.addEventListener("change",(e=>{e.target.classList.contains("search-form__advanced-control")||e.target.classList.contains("search-form__string")||(t.querySelector(".search-form__current").innerHTML="")})),t.querySelectorAll(".reset").forEach((n=>{n.addEventListener("click",(()=>{fcn_resetSearchForm(n,t,e)}))}))})),_$$(".search-form__advanced-toggle").forEach((t=>{t.addEventListener("click",(t=>{const e=t.currentTarget.closest("form");e.dataset.advanced="true"==e.dataset.advanced?"false":"true"}))})),window.addEventListener("keydown",fcn_handleTabInput),window.addEventListener("scroll.rAF",fcn_throttle(fcn_popupPosition,250)),_$$(".modal-toggle").forEach((t=>{t.addEventListener("change",(t=>{const e=_$$$(t.currentTarget.dataset.target);e.classList.toggle("_open",t.currentTarget.checked),e.hidden=!t.currentTarget.checked;const n=e.querySelector(".close");n?.focus(),n?.blur()}))})),fcn_theBody.addEventListener("click",(t=>{const e=t.target.closest("[href]"),n=e?.getAttribute("href");if(!e||"A"===!e.tagName||!n.startsWith("#")||n.length<2||"#respond"===n)return;const a=n.replace("#",""),o=_$$(`[name="${a}"], [id="${a}"]`)[0],c=e.closest(".comment._story-comment");c&&(window.location.href=c.querySelector(".fictioneer-comment__link").href+n),o&&(t.preventDefault(),o.scrollIntoView({behavior:"smooth",block:e.dataset?.block??"start"}))})),fcn_markCurrentMenuItem(),_$$$("age-confirmation-modal")&&"1"!==localStorage.getItem("fcnAgeConfirmation")&&!fcn_isSearchEngineCrawler()?setTimeout((()=>{fcn_showAgeConfirmationModal()}),2500):_$$$("age-confirmation-modal")?.remove(),document.addEventListener("DOMContentLoaded",(()=>{_$$(".splide:not(.no-auto-splide, .is-initialized)").forEach((t=>{t.querySelector(".splide__list")&&"undefined"!=typeof Splide&&(t.classList.remove("_splide-placeholder"),new Splide(t).mount())})),_$$(".temp-script, .splide-placeholder-styles").forEach((t=>{t.remove()}))})),fcn_theBody.addEventListener("click",(t=>{const e=t.target.closest("[data-lightbox]:not(.no-auto-lightbox)");e&&(t.preventDefault(),fcn_showLightbox(e))})),fcn_theBody.addEventListener("keydown",(t=>{const e=t.target.closest("[data-lightbox]:not(.no-auto-lightbox)");e&&(32!=t.keyCode&&13!=t.keyCode||(t.preventDefault(),fcn_showLightbox(e)))})),document.querySelectorAll(".lightbox__close, .lightbox").forEach((t=>{t.addEventListener("click",(t=>{if("IMG"!=t.target.tagName){_$$$("fictioneer-lightbox").classList.remove("show");const t=_$(".lightbox-last-trigger");t?.focus(),t?.blur(),t?.classList.remove("lightbox-last-trigger")}}))})),_$$$("mobile-menu-toggle")?.addEventListener("change",(t=>{fcn_toggleMobileMenu(t.currentTarget.checked)})),fcn_theSite.addEventListener("click",(t=>{fcn_theBody.classList.contains("mobile-menu-open")&&(t.preventDefault(),fcn_toggleMobileMenu(!1))})),fcn_setupMobileJumpButton("#mobile-menu-comment-jump",(()=>_$$$("comments"))),fcn_setupMobileJumpButton("#mobile-menu-bookmark-jump",(()=>_$(`[data-paragraph-id="${fcn_bookmarks.data[_$("article").id]["paragraph-id"]}"]`))),_$$(".button-change-lightness").forEach((t=>{t.addEventListener("click",(t=>{fcn_updateDarken(fcn_siteSettings.darken+parseFloat(t.currentTarget.value))}))})),_$$(".mobile-menu__frame-button").forEach((t=>{t.addEventListener("click",(t=>{fcn_openMobileFrame(t.currentTarget.dataset.frameTarget)}))})),_$$(".mobile-menu__back-button").forEach((t=>{t.addEventListener("click",(()=>{fcn_openMobileFrame("main")}))})),_$$$("button-mobile-menu-toggle-bookmarks-edit")?.addEventListener("click",(t=>{const e=t.currentTarget.closest(".mobile-menu__bookmarks-panel");e.dataset.editing="false"==e.dataset.editing?"true":"false"})),_$('.mobile-menu__frame-button[data-frame-target="bookmarks"]')?.addEventListener("click",(()=>{fcn_setMobileMenuBookmarks()}),{once:!0});const fcn_consentBanner=_$$$("consent-banner");function fcn_loadConsentBanner(){fcn_consentBanner.classList.remove("hidden"),fcn_consentBanner.hidden=!1,_$$$("consent-accept-button")?.addEventListener("click",(()=>{fcn_setCookie("fcn_cookie_consent","full"),fcn_consentBanner.classList.add("hidden"),fcn_consentBanner.hidden=!0})),_$$$("consent-reject-button")?.addEventListener("click",(()=>{fcn_setCookie("fcn_cookie_consent","necessary"),fcn_consentBanner.classList.add("hidden"),fcn_consentBanner.hidden=!0}))}fcn_consentBanner&&""===(fcn_getCookie("fcn_cookie_consent")??"")&&!fcn_isSearchEngineCrawler()?setTimeout((()=>{fcn_loadConsentBanner()}),4e3):fcn_consentBanner.remove();const fcn_chapterFormatting=_$(".chapter-formatting");var fcn_formatting=fcn_getFormatting();const fcn_paragraphTools=_$$$("paragraph-tools");var fcn_lastSelectedParagraphId,fcn_bookmarkColor="none";function fcn_toggleParagraphTools(t=!1,e=null){e&&e.classList.contains("spoiler")&&!e.classList.contains("_open")||(_$$$(`paragraph-${fcn_lastSelectedParagraphId}`)?.classList.remove("selected-paragraph"),t&&fcn_formatting["show-paragraph-tools"]?(fcn_lastSelectedParagraphId=t,e.classList.add("selected-paragraph"),e.classList.contains("is-wrapped")||(e.innerHTML=`${e.innerHTML}`,e.classList.add("is-wrapped")),e.append(fcn_paragraphTools)):fcn_lastSelectedParagraphId=null)}function fcn_touchParagraph(t){if(t.target.classList.contains("spoiler")||t.target.closest(".popup-menu-toggle, .skip-tools, a, button, label, input, textarea")||!t.target.closest("p")?.textContent.trim().length)return;if(!t.target.closest("p")?.parentElement?.classList.contains("chapter-formatting"))return;if(t.target.closest(".hidden, .inside-epub"))return;if(""!=window.getSelection().toString())return;const e=t.target.closest("p[data-paragraph-id]");if(t.target.closest(".tts-interface, .paragraph-tools__actions"))return;if(!e)return void fcn_toggleParagraphTools(!1);let n=!!e.dataset.paragraphId&&e.dataset.paragraphId;n=n!=fcn_lastSelectedParagraphId&&n;const a=(new Date).getTime();e.addEventListener("mouseup",(()=>{(new Date).getTime()<=a+300&&fcn_toggleParagraphTools(n,e)}),{once:!0})}function fcn_getQuote(t){const e=fcn_cleanTextSelectionFromButtons(window.getSelection().toString()),n=`[anchor]${t.target.closest("p[data-paragraph-id]").id}[/anchor]`;let a=t.target.closest("p[data-paragraph-id]").querySelector(".paragraph-inner").innerText,o="[…] ",c=" […]";if(a.length>16&&e.replace(/\s/g,"").length){const t=Math.ceil(.25*e.length),n=a.substring(0,t+1),s=a.substring(a.length-t,a.length);e.startsWith(n)&&(o=""),e.endsWith(s)&&(c=""),a=`${o}${e}${c}`}a=`${a} ${n}`,fcn_addQuoteToStack(a),fcn_showNotification(fictioneer_tl.notification.quoteAppendedToComment)}function fcn_addQuoteToStack(t){const e=_$(fictioneer_comments.form_selector??"#comment");e?"TEXTAREA"==e.tagName?(e.value+=`\n[quote]${t}[/quote]\n`,fcn_textareaAdjust(_$("textarea#comment"))):"DIV"==e.tagName&&(e.innerHTML+=`\n[quote]${t}[/quote]\n`):fcn_commentStack?.push(`\n[quote]${t}[/quote]\n`)}function fcn_openFullscreen(){document.documentElement.requestFullscreen?document.documentElement.requestFullscreen():document.documentElement.webkitRequestFullscreen&&document.documentElement.webkitRequestFullscreen()}function fcn_closeFullscreen(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}function fcn_getFormatting(){let t=fcn_parseJSON(localStorage.getItem("fcnChapterFormatting"))??fcn_defaultFormatting();return Object.keys(t).length<15&&(t=fcn_defaultFormatting()),t.timestamp<1651164557584&&(t=fcn_defaultFormatting(),t.timestamp=Date.now()),fcn_setFormatting(t),t}function fcn_defaultFormatting(){return{"font-saturation":0,"font-color":fictioneer_font_colors[0].css,"font-name":fictioneer_fonts[0].css,"font-size":100,"letter-spacing":0,"line-height":1.7,"paragraph-spacing":1.5,"site-width":fcn_theRoot.dataset.siteWidthDefault??"960",indent:!0,"show-sensitive-content":!0,"show-chapter-notes":!0,justify:!1,"show-comments":!0,"show-paragraph-tools":!0,timestamp:1664797604825,...JSON.parse(fcn_theRoot.dataset.defaultFormatting??"{}")}}function fcn_setFormatting(t){"object"==typeof t&&(fcn_formatting=t,localStorage.setItem("fcnChapterFormatting",JSON.stringify(t)))}function fcn_updateToggle(t,e,n,a={}){a={save:!0,...a};const o=fcn_evaluateAsBoolean(t,!0),c=_$(e);if(c&&(c.checked=o,c.closest("label").setAttribute("aria-checked",o)),a.toggleClass&&fcn_chapterFormatting.classList.toggle(a.toggleClass,a.invertClass?!o:o),a.sensitiveContent){const t=_$$$("inline-sensitive-content-toggle");t?.classList.toggle("hide-sensitive",!o),t?.setAttribute("aria-checked",!o)}a.notes&&_$$(".chapter-note-hideable").forEach((t=>{t.classList.toggle("hidden",!o)})),a.comments&&_$$(".chapter-comments-hideable").forEach((t=>{t.classList.toggle("hidden",!o)})),fcn_formatting[n]=o,a.save&&fcn_setFormatting(fcn_formatting)}document.addEventListener("click",(t=>{fcn_paragraphTools?.closest("p")?.contains(t.target)||fcn_toggleParagraphTools(!1)})),fcn_paragraphTools&&(document.addEventListener("mousedown",(t=>{fcn_touchParagraph(t)})),_$$$("button-close-paragraph-tools").onclick=t=>{fcn_toggleParagraphTools(!1)},_$$$("button-get-link").onclick=t=>{fcn_copyToClipboard(`${location.host}${location.pathname}#${t.target.closest("p[data-paragraph-id]").id}`,fictioneer_tl.notification.linkCopiedToClipboard)},_$$$("button-comment-stack")?.addEventListener("click",(t=>{fcn_getQuote(t)})),_$$(".paragraph-tools__bookmark-colors > div").forEach((t=>{t.onclick=t=>{fcn_bookmarkColor=t.target.dataset.color}})),_$$$("button-set-bookmark")?.addEventListener("click",(t=>{fcn_toggleBookmark(t.target.closest("p[data-paragraph-id]").dataset.paragraphId,fcn_bookmarkColor),window.matchMedia("(min-width: 1024px)").matches&&fcn_toggleParagraphTools(!1),fcn_bookmarkColor="none"}))),_$$(".open-fullscreen").forEach((t=>{t.addEventListener("click",(()=>{fcn_openFullscreen()}))})),_$$(".close-fullscreen").forEach((t=>{t.addEventListener("click",(()=>{fcn_closeFullscreen()}))})),(()=>{"use strict";const t=_$$$("reader-settings-font-size-text"),e=_$$$("reader-settings-font-size-range"),n=_$$$("reader-settings-font-size-reset");function a(a,o=!0){a=fcn_clamp(50,200,a??100),t.value=a,e.value=a,n.classList.toggle("_modified",100!=a),_$$(".resize-font").forEach((t=>{t.style.fontSize=`${a}%`})),fcn_formatting["font-size"]=a,o&&fcn_setFormatting(fcn_formatting)}function o(){a(this.value)}function c(){a(parseFloat(fcn_formatting["font-size"])+parseFloat(this.dataset.modifier))}n&&(_$$$("reset-font")?.addEventListener("click",(()=>{a(100)})),n?.addEventListener("click",(()=>{a(100)})),e?.addEventListener("input",fcn_throttle(o,1e3/24)),t?.addEventListener("input",o),_$$$("increase-font")?.addEventListener("click",c),_$$$("decrease-font")?.addEventListener("click",c),a(fcn_formatting["font-size"],!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-font-color-reset"),e=_$$$("reader-settings-font-color-select");function n(n,a=!0){n=fcn_clamp(0,fictioneer_font_colors.length-1,n),t.classList.toggle("_modified",n>0),e.value=n,fcn_chapterFormatting.style.setProperty("--text-chapter",fictioneer_font_colors[n].css),fcn_formatting["font-color"]=fictioneer_font_colors[n].css,a&&fcn_setFormatting(fcn_formatting)}t&&(t.onclick=()=>{n(0)},e.onchange=t=>{n(t.target.value)},_$$(".font-color-stepper").forEach((t=>{t.addEventListener("click",(t=>{!function(t=1){let a=(e.selectedIndex+parseInt(t))%fictioneer_font_colors.length;a=a<0?fictioneer_font_colors.length-1:a,n(a)}(t.currentTarget.value)}))})),n(fictioneer_font_colors.findIndex((t=>t.css==fcn_formatting["font-color"])),!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-font-reset"),e=_$$$("reader-settings-font-select");function n(a,o=!0){a=fcn_clamp(0,fictioneer_fonts.length-1,a);let c=fictioneer_fonts[a].css;fictioneer_fonts[a].alt&&(c=`${c}, ${fictioneer_fonts[a].alt}`),a<0?n(0):(t.classList.toggle("_modified",a>0),e.value=a,_$$(".chapter-font-family").forEach((t=>{t.style.fontFamily=""===c?"var(--ff-system)":c+", var(--ff-system)"})),fcn_formatting["font-name"]=fictioneer_fonts[a].css,o&&fcn_setFormatting(fcn_formatting))}t&&(t.onclick=()=>{n(0)},e.onchange=t=>{n(t.target.value)},_$$(".font-stepper").forEach((t=>{t.addEventListener("click",(t=>{!function(t=1){let a=(e.selectedIndex+parseInt(t))%fictioneer_fonts.length;a=a<0?fictioneer_fonts.length-1:a,n(a)}(t.currentTarget.value)}))})),n(fictioneer_fonts.findIndex((t=>t.css==fcn_formatting["font-name"])),!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-font-saturation-text"),e=_$$$("reader-settings-font-saturation-range"),n=_$$$("reader-settings-font-saturation-reset");function a(a,o=!0){a=fcn_clamp(-1,1,a??0),t.value=parseInt(100*a),e.value=a,n.classList.toggle("_modified",0!=a),fcn_chapterFormatting.style.setProperty("--font-saturation",`(${a>=0?1+a**2:1-a**2} + var(--font-saturation-offset))`),fcn_formatting["font-saturation"]=a,o&&fcn_setFormatting(fcn_formatting)}n&&(n?.addEventListener("click",(()=>{a(0)})),e?.addEventListener("input",fcn_throttle((function(){a(this.value)}),1e3/24)),t?.addEventListener("input",(function(){a(parseInt(this.value)/100)})),a(fcn_formatting["font-saturation"],!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-letter-spacing-text"),e=_$$$("reader-settings-letter-spacing-range"),n=_$$$("reader-settings-letter-spacing-reset"),a=fcn_defaultFormatting()["letter-spacing"];function o(o,c=!0){o=fcn_clamp(-.1,.2,o??a),t.value=o,e.value=o,n.classList.toggle("_modified",o!=a),fcn_chapterFormatting.style.letterSpacing=`calc(${o}em + var(--font-letter-spacing-base))`,fcn_formatting["letter-spacing"]=o,c&&fcn_setFormatting(fcn_formatting)}function c(){o(this.value)}n&&(n?.addEventListener("click",(()=>{o(a)})),e?.addEventListener("input",fcn_throttle(c,1e3/24)),t?.addEventListener("input",c),o(fcn_formatting["letter-spacing"],!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-paragraph-spacing-text"),e=_$$$("reader-settings-paragraph-spacing-range"),n=_$$$("reader-settings-paragraph-spacing-reset"),a=fcn_defaultFormatting()["paragraph-spacing"];function o(o,c=!0){o=fcn_clamp(0,3,o??a),t.value=o,e.value=o,n.classList.toggle("_modified",o!=a),fcn_chapterFormatting.style.setProperty("--paragraph-spacing",`${o}em`),fcn_formatting["paragraph-spacing"]=o,c&&fcn_setFormatting(fcn_formatting)}function c(){o(this.value)}n&&(n?.addEventListener("click",(()=>{o(a)})),e?.addEventListener("input",fcn_throttle(c,1e3/24)),t?.addEventListener("input",c),o(fcn_formatting["paragraph-spacing"],!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-line-height-text"),e=_$$$("reader-settings-line-height-range"),n=_$$$("reader-settings-line-height-reset"),a=fcn_defaultFormatting()["line-height"];function o(o,c=!0){o=fcn_clamp(.8,3,o??a),t.value=o,e.value=o,n.classList.toggle("_modified",o!=a),fcn_chapterFormatting.style.lineHeight=`${o}`,fcn_formatting["line-height"]=o,c&&fcn_setFormatting(fcn_formatting)}function c(){o(this.value)}n&&(n?.addEventListener("click",(()=>{o(a)})),e?.addEventListener("input",fcn_throttle(c,1e3/24)),t?.addEventListener("input",c),o(fcn_formatting["line-height"],!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-site-width-text"),e=_$$$("reader-settings-site-width-range"),n=_$$$("reader-settings-site-width-reset"),a=fcn_defaultFormatting()["site-width"];function o(o,c=!0){const s=_$("main");o=fcn_clamp(640,1920,o??a),t.value=o,e.value=o,n.classList.toggle("_modified",o!=a),s.style.setProperty("--site-width",`${o}px`),s.classList.toggle("_default-width",o==fcn_theRoot.dataset.siteWidthDefault),s.classList.toggle("_below-1024",o<1024&&o>=768),s.classList.toggle("_below-768",o<768&&o>640),s.classList.toggle("_640-and-below",o<=640),fcn_formatting["site-width"]=o,c&&fcn_setFormatting(fcn_formatting)}function c(){o(this.value)}n&&(n?.addEventListener("click",(()=>{o(a)})),e?.addEventListener("input",fcn_throttle(c,1e3/24)),t?.addEventListener("input",c),o(fcn_formatting["site-width"],!1))})(),_$$("#reader-settings-indent-toggle").forEach((t=>{const e={invertClass:!0,toggleClass:"no-indent"},n="indent";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)},fcn_updateToggle(fcn_formatting[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-justify-toggle").forEach((t=>{const e={toggleClass:"justify"},n="justify";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)},fcn_updateToggle(fcn_formatting[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-paragraph-tools-toggle").forEach((t=>{const e="show-paragraph-tools";t.onclick=n=>{fcn_updateToggle(n.currentTarget.checked,`#${t.id}`,e)},fcn_updateToggle(fcn_formatting[e],`#${t.id}`,e,{save:!1})})),_$$("#reader-settings-chapter-notes-toggle").forEach((t=>{const e={notes:!0},n="show-chapter-notes";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)},fcn_updateToggle(fcn_formatting[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-comments-toggle").forEach((t=>{const e={comments:!0},n="show-comments";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)},fcn_updateToggle(fcn_formatting[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-sensitive-content-toggle").forEach((t=>{const e={toggleClass:"hide-sensitive",invertClass:!0,sensitiveContent:!0},n="show-sensitive-content";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)},fcn_updateToggle(fcn_formatting[n],`#${t.id}`,n,{save:!1,...e})}));const fcn_progressBar=_$(".progress__bar"),fcn_chapterContent=_$$$("chapter-content");var fcn_chapterCheckmarkUpdated=!1;function fcn_trackProgress(){fcn_chapterContent&&(fcn_readingProgress(),window.addEventListener("scroll.rAF",fcn_throttle(fcn_readingProgress,1e3/48)))}function fcn_readingProgress(){if(fcn_settingMinimal.checked||!fcn_settingChapterProgressBar.checked)return;const t=fcn_chapterContent.getBoundingClientRect(),e=t.height,n=window.innerHeight,a=e-t.bottom-Math.max(t.top,0)+n;let o=100*a/e;if(fcn_theBody.classList.toggle("hasProgressBar",!(o<0||a>e+500)),o=fcn_clamp(0,100,o),fcn_progressBar.style.width=`${o}%`,o>=100&&!fcn_chapterCheckmarkUpdated&&fcn_isLoggedIn){const t=fcn_theBody.dataset.storyId;if(fcn_chapterCheckmarkUpdated=!0,!t||"function"!=typeof fcn_toggleCheckmark)return;fcn_toggleCheckmark(t,"progress",parseInt(fcn_theBody.dataset.postId),null,"set")}}_$("article:not(._password)")&&fcn_trackProgress(),_$('[data-click-action*="toggle-chapter-index-order"]')?.addEventListener("click",(t=>{const e=t.currentTarget.closest(".chapter-index");e.dataset.order="asc"===e.dataset.order?"desc":"asc"})),document.addEventListener("DOMContentLoaded",(()=>{const t=_$(".chapter-index"),e=t.closest("dialog").dataset.postId??0;t&&t.querySelector(`[data-id="${e}"]`)?.classList.add("current")}));const fcn_chapterKeyboardNavigation=t=>{if(["INPUT","TEXTAREA","SELECT","OPTION"].includes(t.target.tagName)||t.target.isContentEditable)return;let e=null;"ArrowLeft"===t.code?e=_$("a.button._navigation._prev"):"ArrowRight"===t.code&&(e=_$("a.button._navigation._next")),e&&e.href&&(window.location.href=e+"#start")};if(document.addEventListener("keydown",fcn_chapterKeyboardNavigation),"#start"===window.location.hash){history.replaceState(null,document.title,window.location.pathname);const t=_$(".chapter__article");t&&fcn_scrollTo(t,128)}var diff_match_patch=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},DIFF_DELETE=-1,DIFF_INSERT=1,DIFF_EQUAL=0;diff_match_patch.Diff=function(t,e){this[0]=t,this[1]=e},diff_match_patch.Diff.prototype.length=2,diff_match_patch.Diff.prototype.toString=function(){return this[0]+","+this[1]},diff_match_patch.prototype.diff_main=function(t,e,n,a){if(void 0===a&&(a=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1e3*this.Diff_Timeout),null==t||null==e)throw Error("Null input. (diff_main)");if(t==e)return t?[new diff_match_patch.Diff(DIFF_EQUAL,t)]:[];void 0===n&&(n=!0);var o=n,c=this.diff_commonPrefix(t,e);n=t.substring(0,c),t=t.substring(c),e=e.substring(c),c=this.diff_commonSuffix(t,e);var s=t.substring(t.length-c);return t=t.substring(0,t.length-c),e=e.substring(0,e.length-c),t=this.diff_compute_(t,e,o,a),n&&t.unshift(new diff_match_patch.Diff(DIFF_EQUAL,n)),s&&t.push(new diff_match_patch.Diff(DIFF_EQUAL,s)),this.diff_cleanupMerge(t),t},diff_match_patch.prototype.diff_compute_=function(t,e,n,a){if(!t)return[new diff_match_patch.Diff(DIFF_INSERT,e)];if(!e)return[new diff_match_patch.Diff(DIFF_DELETE,t)];var o=t.length>e.length?t:e,c=t.length>e.length?e:t,s=o.indexOf(c);return-1!=s?(n=[new diff_match_patch.Diff(DIFF_INSERT,o.substring(0,s)),new diff_match_patch.Diff(DIFF_EQUAL,c),new diff_match_patch.Diff(DIFF_INSERT,o.substring(s+c.length))],t.length>e.length&&(n[0][0]=n[2][0]=DIFF_DELETE),n):1==c.length?[new diff_match_patch.Diff(DIFF_DELETE,t),new diff_match_patch.Diff(DIFF_INSERT,e)]:(o=this.diff_halfMatch_(t,e))?(e=o[1],c=o[3],t=o[4],o=this.diff_main(o[0],o[2],n,a),n=this.diff_main(e,c,n,a),o.concat([new diff_match_patch.Diff(DIFF_EQUAL,t)],n)):n&&100n);h++){for(var m=-h+d;m<=h-_;m+=2){for(var p=c+m,k=m==-h||m!=h&&i[p-1]a)_+=2;else if(b>o)d+=2;else if(f&&(0<=(p=c+l-m)&&p=v)return this.diff_bisectSplit_(t,e,k,b,n)}}for(m=-h+u;m<=h-g;m+=2){for(p=c+m,k=(v=m==-h||m!=h&&r[p-1]a)g+=2;else if(k>o)u+=2;else if(!f&&(0<=(p=c+l-m)&&p=(v=a-v))))return this.diff_bisectSplit_(t,e,k,b,n)}}return[new diff_match_patch.Diff(DIFF_DELETE,t),new diff_match_patch.Diff(DIFF_INSERT,e)]},diff_match_patch.prototype.diff_bisectSplit_=function(t,e,n,a,o){var c=t.substring(0,n),s=e.substring(0,a);return t=t.substring(n),e=e.substring(a),c=this.diff_main(c,s,!1,o),o=this.diff_main(t,e,!1,o),c.concat(o)},diff_match_patch.prototype.diff_linesToChars_=function(t,e){function n(t){for(var e="",n=0,s=-1,i=a.length;s0?this.collection.value.split(","):[],this.bindEvents(),this.resize(),this.filterSuggestions()}resize(){const t=this.tabSuggestion.innerText.length>0?this.tabSuggestion.innerText.length:this.input.value.length;this.input.style.width=.88*t+2+"ch"}reset(){this.keywords=[],this.block.querySelectorAll(".node").forEach((t=>{t.remove()})),this.block.querySelectorAll(".keyword-input__operator > input").forEach((t=>{t.checked=!1})),this.input.value="",this.updateCollection(),this.filterSuggestions(),this.resize()}encode(t){const e=(new TextEncoder).encode(t.toLowerCase());return btoa(String.fromCharCode.apply(null,e))}filterSuggestions(){const t=this.input.value.toLowerCase();let e=0,n="";""==t?this.suggestionList.querySelectorAll(".keyword-button").forEach((t=>{t.hidden=!0})):this.suggestionList.querySelectorAll(".keyword-button").forEach((a=>{const o=a.innerText.toLowerCase();o.includes(t)&&this.keywords.indexOf(o)<0?(a.hidden=!1,e++,""==n&&o.startsWith(t)&&(n=o)):a.hidden=!0})),this.hints.querySelectorAll(".keyword-button").forEach((t=>{this.keywords.indexOf(t.value.toLowerCase())>-1?t.hidden=!0:t.hidden=!1})),this.tabSuggestion.innerHTML=n,this.hints.hidden=!(""==t),this.noHint.hidden=!(""!=t&&e<1)}addNode(t=null,e=null){const n=t??this.input.value.replace(",","");let a=this.allowList[this.encode(n)];if("authors"!=this.collection.name&&"ex_authors"!=this.collection.name||!e||(a=this.allowList[this.encode(n)+`_${e.value}`]),!a||this.keywords.indexOf(a)>-1)return;this.keywords.push(a);const o=document.createElement("div");o.innerHTML=`${n}`,o.classList.add("node"),o.dataset.value=a,this.inputWrapper.parentNode.insertBefore(o,this.inputWrapper),this.input.value="",this.updateCollection(),this.filterSuggestions(),this.resize()}removeNodeByValue(t){this.block.querySelector(`[data-value="${t}"]`)?.remove(),this.keywords=this.keywords.filter((e=>e!=t)),this.updateCollection(),this.filterSuggestions(),this.resize()}updateCollection(){this.collection.value=this.keywords.join(","),this.block.classList.toggle("_empty",""===this.collection.value),this.form.querySelector(".search-form__current").innerHTML=""}bindEvents(){this.input.addEventListener("input",(t=>{t.currentTarget.value.includes(",")&&this.addNode(),this.block.classList.toggle("_empty",""===t.currentTarget.value&&""===this.collection.value),this.filterSuggestions(),this.resize()})),this.input.addEventListener("keydown",(t=>{9!=t.keyCode&&13!=t.keyCode||""!=this.tabSuggestion.innerText&&(t.preventDefault(),this.input.value=this.tabSuggestion.innerText,this.addNode()),27==t.keyCode&&(this.input.value="",this.tabSuggestion.innerHTML="",document.activeElement.blur()),8==t.keyCode&&""==this.input.value&&this.keywords.length>0&&this.removeNodeByValue(this.keywords.slice(-1))})),this.input.addEventListener("blur",(()=>{const t=this.allowList[this.encode(this.input.value)];this.blurTimeout=t?setTimeout((()=>{this.addNode()}),150):setTimeout((()=>{this.input.value="",this.tabSuggestion.innerHTML="",this.filterSuggestions(),this.resize()}),150)})),this.block.addEventListener("click",(t=>{t.target.closest(".node-delete")&&(t.preventDefault(),this.removeNodeByValue(t.target.closest(".node").dataset.value))})),this.block.querySelectorAll(".keyword-button").forEach((t=>{t.addEventListener("click",(t=>{clearTimeout(this.blurTimeout),this.addNode(t.currentTarget.innerText,t.currentTarget)}))}))}}function fcn_resetSearchForm(t,e,n){n.forEach((t=>t.reset())),e.querySelectorAll("input, select").forEach((t=>{t.value=t.dataset.default??t.value})),e.querySelector(".search-form__current").innerHTML="",fcn_showNotification(t.dataset.reset,2)}function fcn_handleTabInput(t){9==t.keyCode&&(fcn_theBody.classList.add("user-is-tabbing"),window.removeEventListener("keydown",fcn_handleTabInput),window.addEventListener("mousedown",fcn_handleMouseInput))}function fcn_handleMouseInput(){fcn_theBody.classList.remove("user-is-tabbing"),window.removeEventListener("mousedown",fcn_handleMouseInput),window.addEventListener("keydown",fcn_handleTabInput)}function fcn_popupPosition(){_$$(".popup-menu-toggle.last-clicked .popup-menu:not(._fixed-position)").forEach((t=>{if("none"===window.getComputedStyle(t).display)return;const e=fcn_detectScreenCollision(t);e&&0===e.length||(e.includes("top")?(t.classList.remove("_top"),t.classList.add("_bottom")):e.includes("bottom")&&(t.classList.remove("_bottom"),t.classList.add("_top")),t.closest("._fixed-horizontal")||(e.includes("left")?(t.classList.remove("_center","_justify-right"),t.classList.add("_justify-left")):e.includes("right")&&(t.classList.remove("_center","_justify-left"),t.classList.add("_justify-right"))))}))}function fcn_markCurrentMenuItem(){_$$(`.menu-item > [data-nav-object-id="${fcn_theBody.dataset.postId}"]`).forEach((t=>{t.setAttribute("aria-current","page"),t.closest(".menu-item").classList.add("current-menu-item")}))}function fcn_showAgeConfirmationModal(){const t=_$(".story__article, .chapter__article")?.dataset.ageRating;if(!fcn_theRoot.dataset.ageConfirmation&&t&&"adult"!==t)return void _$$$("age-confirmation-modal")?.remove();const e=_$$$("age-confirmation-leave");fcn_theRoot.classList.add("age-modal-open"),_$$$("age-confirmation-modal").classList.add("_open"),_$$$("age-confirmation-confirm")?.addEventListener("click",(t=>{fcn_theRoot.classList.remove("age-modal-open"),t.currentTarget.closest(".modal").remove(),localStorage.setItem("fcnAgeConfirmation","1")})),e?.addEventListener("click",(()=>{window.location.href=e.dataset.redirect??"https://search.brave.com/",localStorage.removeItem("fcnAgeConfirmation")}))}function fcn_showLightbox(t){const e=_$$$("fictioneer-lightbox"),n=_$(".lightbox__content");let a=!1,o=null;if(n.innerHTML="",t.classList.add("lightbox-last-trigger"),"IMG"==t.tagName?(o=t.cloneNode(),a=!0):t.href&&(o=document.createElement("img"),o.src=t.href,a=!0),a&&o){["class","style","height","width"].forEach((t=>o.removeAttribute(t))),n.appendChild(o),e.classList.add("show");const t=e.querySelector(".lightbox__close");t?.focus(),t?.blur()}}function fcn_toggleMobileMenu(t){_$(".mobile-menu._advanced-mobile-menu")?fcn_toggleAdvancedMobileMenu(t):fcn_toggleSimpleMobileMenu(t)}function fcn_toggleSimpleMobileMenu(t){t?(fcn_theBody.classList.add("mobile-menu-open","scrolling-down"),fcn_theBody.classList.remove("scrolling-up")):(fcn_theBody.classList.remove("mobile-menu-open"),fcn_closeMobileFrames(),fcn_openMobileFrame("main"),_$$$("mobile-menu-toggle").checked=!1)}function fcn_toggleAdvancedMobileMenu(t){const e=_$$$("wpadminbar")?.offsetHeight??0,n=window.scrollY,a=fcn_theSite.scrollTop;t?(fcn_theBody.classList.add("mobile-menu-open","scrolling-down","scrolled-to-top"),fcn_theBody.classList.remove("scrolling-up"),fcn_theSite.classList.add("transformed-scroll","transformed-site"),fcn_theSite.scrollTop=n-e,fcn_updateThemeColor()):(fcn_theSite.classList.remove("transformed-site","transformed-scroll"),fcn_theBody.classList.remove("mobile-menu-open"),fcn_updateThemeColor(),fcn_closeMobileFrames(),fcn_openMobileFrame("main"),fcn_theRoot.style.scrollBehavior="auto",window.scroll(0,a+e),fcn_theRoot.style.scrollBehavior="",_$$$("mobile-menu-toggle").checked=!1,"function"==typeof fcn_trackProgress&&fcn_trackProgress())}function fcn_setupMobileJumpButton(t,e){const n=_$(t);n&&n.addEventListener("click",(()=>{fcn_toggleMobileMenu(!1),setTimeout((()=>{const t=e();t&&fcn_scrollTo(t)}),200)}))}function fcn_openMobileFrame(t){fcn_closeMobileFrames(),_$(`.mobile-menu__frame[data-frame="${t}"]`)?.classList.add("_active")}function fcn_closeMobileFrames(){_$$(".mobile-menu__frame._active").forEach((t=>{t.classList.remove("_active")}));const t=_$(".mobile-menu__bookmarks-panel");t&&(t.dataset.editing="false")}_$$(".search-form").forEach((t=>{if(t.classList.contains("_simple"))return;const e=[];t.querySelectorAll(".keyword-input__input").forEach((t=>{e.push(new FCN_KeywordInput(t))})),t.querySelector(".allow-list")?.remove(),t.addEventListener("change",(e=>{e.target.classList.contains("search-form__advanced-control")||e.target.classList.contains("search-form__string")||(t.querySelector(".search-form__current").innerHTML="")})),t.querySelectorAll(".reset").forEach((n=>{n.addEventListener("click",(()=>{fcn_resetSearchForm(n,t,e)}))}))})),_$$(".search-form__advanced-toggle").forEach((t=>{t.addEventListener("click",(t=>{const e=t.currentTarget.closest("form");e.dataset.advanced="true"==e.dataset.advanced?"false":"true"}))})),window.addEventListener("keydown",fcn_handleTabInput),window.addEventListener("scroll.rAF",fcn_throttle(fcn_popupPosition,250)),_$$(".modal-toggle").forEach((t=>{t.addEventListener("change",(t=>{const e=_$$$(t.currentTarget.dataset.target);e.classList.toggle("_open",t.currentTarget.checked),e.hidden=!t.currentTarget.checked;const n=e.querySelector(".close");n?.focus(),n?.blur()}))})),fcn_theBody.addEventListener("click",(t=>{const e=t.target.closest("[href]"),n=e?.getAttribute("href");if(!e||"A"===!e.tagName||!n.startsWith("#")||n.length<2||"#respond"===n)return;const a=n.replace("#",""),o=_$$(`[name="${a}"], [id="${a}"]`)[0],c=e.closest(".comment._story-comment");c&&(window.location.href=c.querySelector(".fictioneer-comment__link").href+n),o&&(t.preventDefault(),o.scrollIntoView({behavior:"smooth",block:e.dataset?.block??"start"}))})),fcn_markCurrentMenuItem(),_$$$("age-confirmation-modal")&&"1"!==localStorage.getItem("fcnAgeConfirmation")&&!fcn_isSearchEngineCrawler()?setTimeout((()=>{fcn_showAgeConfirmationModal()}),2500):_$$$("age-confirmation-modal")?.remove(),document.addEventListener("DOMContentLoaded",(()=>{_$$(".splide:not(.no-auto-splide, .is-initialized)").forEach((t=>{t.querySelector(".splide__list")&&"undefined"!=typeof Splide&&(t.classList.remove("_splide-placeholder"),new Splide(t).mount())})),_$$(".temp-script, .splide-placeholder-styles").forEach((t=>{t.remove()}))})),fcn_theBody.addEventListener("click",(t=>{const e=t.target.closest("[data-lightbox]:not(.no-auto-lightbox)");e&&(t.preventDefault(),fcn_showLightbox(e))})),fcn_theBody.addEventListener("keydown",(t=>{const e=t.target.closest("[data-lightbox]:not(.no-auto-lightbox)");e&&(32!=t.keyCode&&13!=t.keyCode||(t.preventDefault(),fcn_showLightbox(e)))})),document.querySelectorAll(".lightbox__close, .lightbox").forEach((t=>{t.addEventListener("click",(t=>{if("IMG"!=t.target.tagName){_$$$("fictioneer-lightbox").classList.remove("show");const t=_$(".lightbox-last-trigger");t?.focus(),t?.blur(),t?.classList.remove("lightbox-last-trigger")}}))})),_$$$("mobile-menu-toggle")?.addEventListener("change",(t=>{fcn_toggleMobileMenu(t.currentTarget.checked)})),fcn_theSite.addEventListener("click",(t=>{fcn_theBody.classList.contains("mobile-menu-open")&&(t.preventDefault(),fcn_toggleMobileMenu(!1))})),fcn_setupMobileJumpButton("#mobile-menu-comment-jump",(()=>_$$$("comments"))),fcn_setupMobileJumpButton("#mobile-menu-bookmark-jump",(()=>_$(`[data-paragraph-id="${fcn_bookmarks.data[_$("article").id]["paragraph-id"]}"]`))),_$$(".button-change-lightness").forEach((t=>{t.addEventListener("click",(t=>{fcn_updateDarken(fcn_siteSettings.darken+parseFloat(t.currentTarget.value))}))})),_$$(".mobile-menu__frame-button").forEach((t=>{t.addEventListener("click",(t=>{fcn_openMobileFrame(t.currentTarget.dataset.frameTarget)}))})),_$$(".mobile-menu__back-button").forEach((t=>{t.addEventListener("click",(()=>{fcn_openMobileFrame("main")}))})),_$$$("button-mobile-menu-toggle-bookmarks-edit")?.addEventListener("click",(t=>{const e=t.currentTarget.closest(".mobile-menu__bookmarks-panel");e.dataset.editing="false"==e.dataset.editing?"true":"false"})),_$('.mobile-menu__frame-button[data-frame-target="bookmarks"]')?.addEventListener("click",(()=>{fcn_setMobileMenuBookmarks()}),{once:!0});const fcn_consentBanner=_$$$("consent-banner");function fcn_loadConsentBanner(){fcn_consentBanner.classList.remove("hidden"),fcn_consentBanner.hidden=!1,_$$$("consent-accept-button")?.addEventListener("click",(()=>{fcn_setCookie("fcn_cookie_consent","full"),fcn_consentBanner.classList.add("hidden"),fcn_consentBanner.hidden=!0})),_$$$("consent-reject-button")?.addEventListener("click",(()=>{fcn_setCookie("fcn_cookie_consent","necessary"),fcn_consentBanner.classList.add("hidden"),fcn_consentBanner.hidden=!0}))}fcn_consentBanner&&""===(fcn_getCookie("fcn_cookie_consent")??"")&&!fcn_isSearchEngineCrawler()?setTimeout((()=>{fcn_loadConsentBanner()}),4e3):fcn_consentBanner.remove();const fcn_chapterFormatting=_$(".chapter-formatting");var fcn_formatting=fcn_getFormatting();const fcn_paragraphTools=_$$$("paragraph-tools");var fcn_lastSelectedParagraphId,fcn_bookmarkColor="none";function fcn_toggleParagraphTools(t=!1,e=null){e&&e.classList.contains("spoiler")&&!e.classList.contains("_open")||(_$$$(`paragraph-${fcn_lastSelectedParagraphId}`)?.classList.remove("selected-paragraph"),t&&fcn_formatting["show-paragraph-tools"]?(fcn_lastSelectedParagraphId=t,e.classList.add("selected-paragraph"),e.classList.contains("is-wrapped")||(e.innerHTML=`${e.innerHTML}`,e.classList.add("is-wrapped")),e.append(fcn_paragraphTools)):fcn_lastSelectedParagraphId=null)}function fcn_touchParagraph(t){if(t.target.classList.contains("spoiler")||t.target.closest(".popup-menu-toggle, .skip-tools, a, button, label, input, textarea")||!t.target.closest("p")?.textContent.trim().length)return;if(!t.target.closest("p")?.parentElement?.classList.contains("chapter-formatting"))return;if(t.target.closest(".hidden, .inside-epub"))return;if(""!=window.getSelection().toString())return;const e=t.target.closest("p[data-paragraph-id]");if(t.target.closest(".tts-interface, .paragraph-tools__actions"))return;if(!e)return void fcn_toggleParagraphTools(!1);let n=!!e.dataset.paragraphId&&e.dataset.paragraphId;n=n!=fcn_lastSelectedParagraphId&&n;const a=(new Date).getTime();e.addEventListener("mouseup",(()=>{(new Date).getTime()<=a+300&&fcn_toggleParagraphTools(n,e)}),{once:!0})}function fcn_getQuote(t){const e=fcn_cleanTextSelectionFromButtons(window.getSelection().toString()),n=`[anchor]${t.target.closest("p[data-paragraph-id]").id}[/anchor]`;let a=t.target.closest("p[data-paragraph-id]").querySelector(".paragraph-inner").innerText,o="[…] ",c=" […]";if(a.length>16&&e.replace(/\s/g,"").length){const t=Math.ceil(.25*e.length),n=a.substring(0,t+1),s=a.substring(a.length-t,a.length);e.startsWith(n)&&(o=""),e.endsWith(s)&&(c=""),a=`${o}${e}${c}`}a=`${a} ${n}`,fcn_addQuoteToStack(a),fcn_showNotification(fictioneer_tl.notification.quoteAppendedToComment)}function fcn_addQuoteToStack(t){const e=_$(fictioneer_comments.form_selector??"#comment");e?"TEXTAREA"==e.tagName?(e.value+=`\n[quote]${t}[/quote]\n`,fcn_textareaAdjust(_$("textarea#comment"))):"DIV"==e.tagName&&(e.innerHTML+=`\n[quote]${t}[/quote]\n`):fcn_commentStack?.push(`\n[quote]${t}[/quote]\n`)}function fcn_openFullscreen(){document.documentElement.requestFullscreen?document.documentElement.requestFullscreen():document.documentElement.webkitRequestFullscreen&&document.documentElement.webkitRequestFullscreen()}function fcn_closeFullscreen(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}function fcn_getFormatting(){let t=fcn_parseJSON(localStorage.getItem("fcnChapterFormatting"))??fcn_defaultFormatting();return Object.keys(t).length<15&&(t=fcn_defaultFormatting()),t.timestamp<1651164557584&&(t=fcn_defaultFormatting(),t.timestamp=Date.now()),fcn_setFormatting(t),t}function fcn_defaultFormatting(){return{"font-saturation":0,"font-color":fictioneer_font_colors[0].css,"font-name":fictioneer_fonts[0].css,"font-size":100,"letter-spacing":0,"line-height":1.7,"paragraph-spacing":1.5,"site-width":fcn_theRoot.dataset.siteWidthDefault??"960",indent:!0,"show-sensitive-content":!0,"show-chapter-notes":!0,justify:!1,"show-comments":!0,"show-paragraph-tools":!0,timestamp:1664797604825,...JSON.parse(fcn_theRoot.dataset.defaultFormatting??"{}")}}function fcn_setFormatting(t){"object"==typeof t&&(fcn_formatting=t,localStorage.setItem("fcnChapterFormatting",JSON.stringify(t)))}function fcn_updateToggle(t,e,n,a={}){a={save:!0,...a};const o=fcn_evaluateAsBoolean(t,!0),c=_$(e);if(c&&(c.checked=o,c.closest("label").setAttribute("aria-checked",o)),a.toggleClass&&fcn_chapterFormatting.classList.toggle(a.toggleClass,a.invertClass?!o:o),a.sensitiveContent){const t=_$$$("inline-sensitive-content-toggle");t?.classList.toggle("hide-sensitive",!o),t?.setAttribute("aria-checked",!o)}a.notes&&_$$(".chapter-note-hideable").forEach((t=>{t.classList.toggle("hidden",!o)})),a.comments&&_$$(".chapter-comments-hideable").forEach((t=>{t.classList.toggle("hidden",!o)})),fcn_formatting[n]=o,a.save&&fcn_setFormatting(fcn_formatting)}document.addEventListener("click",(t=>{fcn_paragraphTools?.closest("p")?.contains(t.target)||fcn_toggleParagraphTools(!1)})),fcn_paragraphTools&&(document.addEventListener("mousedown",(t=>{fcn_touchParagraph(t)})),_$$$("button-close-paragraph-tools").onclick=t=>{fcn_toggleParagraphTools(!1)},_$$$("button-get-link").onclick=t=>{fcn_copyToClipboard(`${location.protocol}//${location.host}${location.pathname}#${t.target.closest("p[data-paragraph-id]").id}`,fictioneer_tl.notification.linkCopiedToClipboard)},_$$$("button-comment-stack")?.addEventListener("click",(t=>{fcn_getQuote(t)})),_$$(".paragraph-tools__bookmark-colors > div").forEach((t=>{t.onclick=t=>{fcn_bookmarkColor=t.target.dataset.color}})),_$$$("button-set-bookmark")?.addEventListener("click",(t=>{fcn_toggleBookmark(t.target.closest("p[data-paragraph-id]").dataset.paragraphId,fcn_bookmarkColor),window.matchMedia("(min-width: 1024px)").matches&&fcn_toggleParagraphTools(!1),fcn_bookmarkColor="none"}))),_$$(".open-fullscreen").forEach((t=>{t.addEventListener("click",(()=>{fcn_openFullscreen()}))})),_$$(".close-fullscreen").forEach((t=>{t.addEventListener("click",(()=>{fcn_closeFullscreen()}))})),(()=>{"use strict";const t=_$$$("reader-settings-font-size-text"),e=_$$$("reader-settings-font-size-range"),n=_$$$("reader-settings-font-size-reset");function a(a,o=!0){a=fcn_clamp(50,200,a??100),t.value=a,e.value=a,n.classList.toggle("_modified",100!=a),_$$(".resize-font").forEach((t=>{t.style.fontSize=`${a}%`})),fcn_formatting["font-size"]=a,o&&fcn_setFormatting(fcn_formatting)}function o(){a(this.value)}function c(){a(parseFloat(fcn_formatting["font-size"])+parseFloat(this.dataset.modifier))}n&&(_$$$("reset-font")?.addEventListener("click",(()=>{a(100)})),n?.addEventListener("click",(()=>{a(100)})),e?.addEventListener("input",fcn_throttle(o,1e3/24)),t?.addEventListener("input",o),_$$$("increase-font")?.addEventListener("click",c),_$$$("decrease-font")?.addEventListener("click",c),a(fcn_formatting["font-size"],!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-font-color-reset"),e=_$$$("reader-settings-font-color-select");function n(n,a=!0){n=fcn_clamp(0,fictioneer_font_colors.length-1,n),t.classList.toggle("_modified",n>0),e.value=n,fcn_chapterFormatting.style.setProperty("--text-chapter",fictioneer_font_colors[n].css),fcn_formatting["font-color"]=fictioneer_font_colors[n].css,a&&fcn_setFormatting(fcn_formatting)}t&&(t.onclick=()=>{n(0)},e.onchange=t=>{n(t.target.value)},_$$(".font-color-stepper").forEach((t=>{t.addEventListener("click",(t=>{!function(t=1){let a=(e.selectedIndex+parseInt(t))%fictioneer_font_colors.length;a=a<0?fictioneer_font_colors.length-1:a,n(a)}(t.currentTarget.value)}))})),n(fictioneer_font_colors.findIndex((t=>t.css==fcn_formatting["font-color"])),!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-font-reset"),e=_$$$("reader-settings-font-select");function n(a,o=!0){a=fcn_clamp(0,fictioneer_fonts.length-1,a);let c=fictioneer_fonts[a].css;fictioneer_fonts[a].alt&&(c=`${c}, ${fictioneer_fonts[a].alt}`),a<0?n(0):(t.classList.toggle("_modified",a>0),e.value=a,_$$(".chapter-font-family").forEach((t=>{t.style.fontFamily=""===c?"var(--ff-system)":c+", var(--ff-system)"})),fcn_formatting["font-name"]=fictioneer_fonts[a].css,o&&fcn_setFormatting(fcn_formatting))}t&&(t.onclick=()=>{n(0)},e.onchange=t=>{n(t.target.value)},_$$(".font-stepper").forEach((t=>{t.addEventListener("click",(t=>{!function(t=1){let a=(e.selectedIndex+parseInt(t))%fictioneer_fonts.length;a=a<0?fictioneer_fonts.length-1:a,n(a)}(t.currentTarget.value)}))})),n(fictioneer_fonts.findIndex((t=>t.css==fcn_formatting["font-name"])),!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-font-saturation-text"),e=_$$$("reader-settings-font-saturation-range"),n=_$$$("reader-settings-font-saturation-reset");function a(a,o=!0){a=fcn_clamp(-1,1,a??0),t.value=parseInt(100*a),e.value=a,n.classList.toggle("_modified",0!=a),fcn_chapterFormatting.style.setProperty("--font-saturation",`(${a>=0?1+a**2:1-a**2} + var(--font-saturation-offset))`),fcn_formatting["font-saturation"]=a,o&&fcn_setFormatting(fcn_formatting)}n&&(n?.addEventListener("click",(()=>{a(0)})),e?.addEventListener("input",fcn_throttle((function(){a(this.value)}),1e3/24)),t?.addEventListener("input",(function(){a(parseInt(this.value)/100)})),a(fcn_formatting["font-saturation"],!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-letter-spacing-text"),e=_$$$("reader-settings-letter-spacing-range"),n=_$$$("reader-settings-letter-spacing-reset"),a=fcn_defaultFormatting()["letter-spacing"];function o(o,c=!0){o=fcn_clamp(-.1,.2,o??a),t.value=o,e.value=o,n.classList.toggle("_modified",o!=a),fcn_chapterFormatting.style.letterSpacing=`calc(${o}em + var(--font-letter-spacing-base))`,fcn_formatting["letter-spacing"]=o,c&&fcn_setFormatting(fcn_formatting)}function c(){o(this.value)}n&&(n?.addEventListener("click",(()=>{o(a)})),e?.addEventListener("input",fcn_throttle(c,1e3/24)),t?.addEventListener("input",c),o(fcn_formatting["letter-spacing"],!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-paragraph-spacing-text"),e=_$$$("reader-settings-paragraph-spacing-range"),n=_$$$("reader-settings-paragraph-spacing-reset"),a=fcn_defaultFormatting()["paragraph-spacing"];function o(o,c=!0){o=fcn_clamp(0,3,o??a),t.value=o,e.value=o,n.classList.toggle("_modified",o!=a),fcn_chapterFormatting.style.setProperty("--paragraph-spacing",`${o}em`),fcn_formatting["paragraph-spacing"]=o,c&&fcn_setFormatting(fcn_formatting)}function c(){o(this.value)}n&&(n?.addEventListener("click",(()=>{o(a)})),e?.addEventListener("input",fcn_throttle(c,1e3/24)),t?.addEventListener("input",c),o(fcn_formatting["paragraph-spacing"],!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-line-height-text"),e=_$$$("reader-settings-line-height-range"),n=_$$$("reader-settings-line-height-reset"),a=fcn_defaultFormatting()["line-height"];function o(o,c=!0){o=fcn_clamp(.8,3,o??a),t.value=o,e.value=o,n.classList.toggle("_modified",o!=a),fcn_chapterFormatting.style.lineHeight=`${o}`,fcn_formatting["line-height"]=o,c&&fcn_setFormatting(fcn_formatting)}function c(){o(this.value)}n&&(n?.addEventListener("click",(()=>{o(a)})),e?.addEventListener("input",fcn_throttle(c,1e3/24)),t?.addEventListener("input",c),o(fcn_formatting["line-height"],!1))})(),(()=>{"use strict";const t=_$$$("reader-settings-site-width-text"),e=_$$$("reader-settings-site-width-range"),n=_$$$("reader-settings-site-width-reset"),a=fcn_defaultFormatting()["site-width"];function o(o,c=!0){const s=_$("main");o=fcn_clamp(640,1920,o??a),t.value=o,e.value=o,n.classList.toggle("_modified",o!=a),s.style.setProperty("--site-width",`${o}px`),s.classList.toggle("_default-width",o==fcn_theRoot.dataset.siteWidthDefault),s.classList.toggle("_below-1024",o<1024&&o>=768),s.classList.toggle("_below-768",o<768&&o>640),s.classList.toggle("_640-and-below",o<=640),fcn_formatting["site-width"]=o,c&&fcn_setFormatting(fcn_formatting)}function c(){o(this.value)}n&&(n?.addEventListener("click",(()=>{o(a)})),e?.addEventListener("input",fcn_throttle(c,1e3/24)),t?.addEventListener("input",c),o(fcn_formatting["site-width"],!1))})(),_$$("#reader-settings-indent-toggle").forEach((t=>{const e={invertClass:!0,toggleClass:"no-indent"},n="indent";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)},fcn_updateToggle(fcn_formatting[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-justify-toggle").forEach((t=>{const e={toggleClass:"justify"},n="justify";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)},fcn_updateToggle(fcn_formatting[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-paragraph-tools-toggle").forEach((t=>{const e="show-paragraph-tools";t.onclick=n=>{fcn_updateToggle(n.currentTarget.checked,`#${t.id}`,e)},fcn_updateToggle(fcn_formatting[e],`#${t.id}`,e,{save:!1})})),_$$("#reader-settings-chapter-notes-toggle").forEach((t=>{const e={notes:!0},n="show-chapter-notes";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)},fcn_updateToggle(fcn_formatting[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-comments-toggle").forEach((t=>{const e={comments:!0},n="show-comments";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)},fcn_updateToggle(fcn_formatting[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-sensitive-content-toggle").forEach((t=>{const e={toggleClass:"hide-sensitive",invertClass:!0,sensitiveContent:!0},n="show-sensitive-content";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)},fcn_updateToggle(fcn_formatting[n],`#${t.id}`,n,{save:!1,...e})}));const fcn_progressBar=_$(".progress__bar"),fcn_chapterContent=_$$$("chapter-content");var fcn_chapterCheckmarkUpdated=!1;function fcn_trackProgress(){fcn_chapterContent&&(fcn_readingProgress(),window.addEventListener("scroll.rAF",fcn_throttle(fcn_readingProgress,1e3/48)))}function fcn_readingProgress(){if(fcn_settingMinimal.checked||!fcn_settingChapterProgressBar.checked)return;const t=fcn_chapterContent.getBoundingClientRect(),e=t.height,n=window.innerHeight,a=e-t.bottom-Math.max(t.top,0)+n;let o=100*a/e;if(fcn_theBody.classList.toggle("hasProgressBar",!(o<0||a>e+500)),o=fcn_clamp(0,100,o),fcn_progressBar.style.width=`${o}%`,o>=100&&!fcn_chapterCheckmarkUpdated&&fcn_isLoggedIn){const t=fcn_theBody.dataset.storyId;if(fcn_chapterCheckmarkUpdated=!0,!t||"function"!=typeof fcn_toggleCheckmark)return;fcn_toggleCheckmark(t,"progress",parseInt(fcn_theBody.dataset.postId),null,"set")}}_$("article:not(._password)")&&fcn_trackProgress(),_$('[data-click-action*="toggle-chapter-index-order"]')?.addEventListener("click",(t=>{const e=t.currentTarget.closest(".chapter-index");e.dataset.order="asc"===e.dataset.order?"desc":"asc"})),document.addEventListener("DOMContentLoaded",(()=>{const t=_$(".chapter-index"),e=t.closest("dialog").dataset.postId??0;t&&t.querySelector(`[data-id="${e}"]`)?.classList.add("current")}));const fcn_chapterKeyboardNavigation=t=>{if(["INPUT","TEXTAREA","SELECT","OPTION"].includes(t.target.tagName)||t.target.isContentEditable)return;let e=null;"ArrowLeft"===t.code?e=_$("a.button._navigation._prev"):"ArrowRight"===t.code&&(e=_$("a.button._navigation._next")),e&&e.href&&(window.location.href=e+"#start")};if(document.addEventListener("keydown",fcn_chapterKeyboardNavigation),"#start"===window.location.hash){history.replaceState(null,document.title,window.location.pathname);const t=_$(".chapter__article");t&&fcn_scrollTo(t,128)}var diff_match_patch=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},DIFF_DELETE=-1,DIFF_INSERT=1,DIFF_EQUAL=0;diff_match_patch.Diff=function(t,e){this[0]=t,this[1]=e},diff_match_patch.Diff.prototype.length=2,diff_match_patch.Diff.prototype.toString=function(){return this[0]+","+this[1]},diff_match_patch.prototype.diff_main=function(t,e,n,a){if(void 0===a&&(a=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1e3*this.Diff_Timeout),null==t||null==e)throw Error("Null input. (diff_main)");if(t==e)return t?[new diff_match_patch.Diff(DIFF_EQUAL,t)]:[];void 0===n&&(n=!0);var o=n,c=this.diff_commonPrefix(t,e);n=t.substring(0,c),t=t.substring(c),e=e.substring(c),c=this.diff_commonSuffix(t,e);var s=t.substring(t.length-c);return t=t.substring(0,t.length-c),e=e.substring(0,e.length-c),t=this.diff_compute_(t,e,o,a),n&&t.unshift(new diff_match_patch.Diff(DIFF_EQUAL,n)),s&&t.push(new diff_match_patch.Diff(DIFF_EQUAL,s)),this.diff_cleanupMerge(t),t},diff_match_patch.prototype.diff_compute_=function(t,e,n,a){if(!t)return[new diff_match_patch.Diff(DIFF_INSERT,e)];if(!e)return[new diff_match_patch.Diff(DIFF_DELETE,t)];var o=t.length>e.length?t:e,c=t.length>e.length?e:t,s=o.indexOf(c);return-1!=s?(n=[new diff_match_patch.Diff(DIFF_INSERT,o.substring(0,s)),new diff_match_patch.Diff(DIFF_EQUAL,c),new diff_match_patch.Diff(DIFF_INSERT,o.substring(s+c.length))],t.length>e.length&&(n[0][0]=n[2][0]=DIFF_DELETE),n):1==c.length?[new diff_match_patch.Diff(DIFF_DELETE,t),new diff_match_patch.Diff(DIFF_INSERT,e)]:(o=this.diff_halfMatch_(t,e))?(e=o[1],c=o[3],t=o[4],o=this.diff_main(o[0],o[2],n,a),n=this.diff_main(e,c,n,a),o.concat([new diff_match_patch.Diff(DIFF_EQUAL,t)],n)):n&&100n);h++){for(var m=-h+d;m<=h-_;m+=2){for(var p=c+m,k=m==-h||m!=h&&i[p-1]a)_+=2;else if(b>o)d+=2;else if(f&&(0<=(p=c+l-m)&&p=v)return this.diff_bisectSplit_(t,e,k,b,n)}}for(m=-h+u;m<=h-g;m+=2){for(p=c+m,k=(v=m==-h||m!=h&&r[p-1]a)g+=2;else if(k>o)u+=2;else if(!f&&(0<=(p=c+l-m)&&p=(v=a-v))))return this.diff_bisectSplit_(t,e,k,b,n)}}return[new diff_match_patch.Diff(DIFF_DELETE,t),new diff_match_patch.Diff(DIFF_INSERT,e)]},diff_match_patch.prototype.diff_bisectSplit_=function(t,e,n,a,o){var c=t.substring(0,n),s=e.substring(0,a);return t=t.substring(n),e=e.substring(a),c=this.diff_main(c,s,!1,o),o=this.diff_main(t,e,!1,o),c.concat(o)},diff_match_patch.prototype.diff_linesToChars_=function(t,e){function n(t){for(var e="",n=0,s=-1,i=a.length;sa?t=t.substring(n-a):n=t.length?[a,o,s,i,f]:null}if(0>=this.Diff_Timeout)return null;var a=t.length>e.length?t:e,o=t.length>e.length?e:t;if(4>a.length||2*o.lengtha[4].length?s:a:s,t.length>e.length){a=s[0],o=s[1];var i=s[2],r=s[3]}else i=s[0],r=s[1],a=s[2],o=s[3];return[a,o,i,r,s[4]]},diff_match_patch.prototype.diff_cleanupSemantic=function(t){for(var e=!1,n=[],a=0,o=null,c=0,s=0,i=0,r=0,l=0;c=(o=this.diff_commonOverlap_(n,e))?(a>=e.length/2||a>=n.length/2)&&(t.splice(c,0,new diff_match_patch.Diff(DIFF_EQUAL,n.substring(0,a))),t[c-1][1]=e.substring(0,e.length-a),t[c+1][1]=n.substring(a),c++):(o>=e.length/2||o>=n.length/2)&&(t.splice(c,0,new diff_match_patch.Diff(DIFF_EQUAL,e.substring(0,o))),t[c-1][0]=DIFF_INSERT,t[c-1][1]=n.substring(0,n.length-o),t[c+1][0]=DIFF_DELETE,t[c+1][1]=e.substring(o),c++),c++),c++},diff_match_patch.prototype.diff_cleanupSemanticLossless=function(t){function e(t,e){if(!t||!e)return 6;var n=t.charAt(t.length-1),a=e.charAt(0),o=n.match(diff_match_patch.nonAlphaNumericRegex_),c=a.match(diff_match_patch.nonAlphaNumericRegex_),s=o&&n.match(diff_match_patch.whitespaceRegex_),i=c&&a.match(diff_match_patch.whitespaceRegex_);n=s&&n.match(diff_match_patch.linebreakRegex_),a=i&&a.match(diff_match_patch.linebreakRegex_);var r=n&&t.match(diff_match_patch.blanklineEndRegex_),l=a&&e.match(diff_match_patch.blanklineStartRegex_);return r||l?5:n||a?4:o&&!s&&i?3:s||i?2:o||c?1:0}for(var n=1;n=l&&(l=f,s=a,i=o,r=c)}t[n-1][1]!=s&&(s?t[n-1][1]=s:(t.splice(n-1,1),n--),t[n][1]=i,r?t[n+1][1]=r:(t.splice(n+1,1),n--))}n++}},diff_match_patch.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,diff_match_patch.whitespaceRegex_=/\s/,diff_match_patch.linebreakRegex_=/[\r\n]/,diff_match_patch.blanklineEndRegex_=/\n\r?\n$/,diff_match_patch.blanklineStartRegex_=/^\r?\n\r?\n/,diff_match_patch.prototype.diff_cleanupEfficiency=function(t){for(var e=!1,n=[],a=0,o=null,c=0,s=!1,i=!1,r=!1,l=!1;ce));n++)c=a,s=o;return t.length!=n&&t[n][0]===DIFF_DELETE?s:s+(e-c)},diff_match_patch.prototype.diff_prettyHtml=function(t){for(var e=[],n=/&/g,a=//g,c=/\n/g,s=0;s");switch(i){case DIFF_INSERT:e[s]=''+r+"";break;case DIFF_DELETE:e[s]=''+r+"";break;case DIFF_EQUAL:e[s]=""+r+""}}return e.join("")},diff_match_patch.prototype.diff_text1=function(t){for(var e=[],n=0;nr)throw Error("Invalid number in diff_fromDelta: "+i);i=t.substring(o,o+=r),"="==c[s].charAt(0)?n[a++]=new diff_match_patch.Diff(DIFF_EQUAL,i):n[a++]=new diff_match_patch.Diff(DIFF_DELETE,i);break;default:if(c[s])throw Error("Invalid diff operation in diff_fromDelta: "+c[s])}}if(o!=t.length)throw Error("Delta length ("+o+") does not equal source text length ("+t.length+").");return n},diff_match_patch.prototype.match_main=function(t,e,n){if(null==t||null==e||null==n)throw Error("Null input. (match_main)");return n=Math.max(0,Math.min(n,t.length)),t==e?0:t.length?t.substring(n,n+e.length)==e?n:this.match_bitap_(t,e,n):-1},diff_match_patch.prototype.match_bitap_=function(t,e,n){function a(t,a){var o=t/e.length,s=Math.abs(n-a);return c.Match_Distance?o+s/c.Match_Distance:s?1:o}if(e.length>this.Match_MaxBits)throw Error("Pattern too long for this browser.");var o=this.match_alphabet_(e),c=this,s=this.Match_Threshold,i=t.indexOf(e,n);-1!=i&&(s=Math.min(a(0,i),s),-1!=(i=t.lastIndexOf(e,n+e.length))&&(s=Math.min(a(0,i),s)));var r=1<=l;g--){var h=o[t.charAt(g-1)];if(f[g]=0===u?(f[g+1]<<1|1)&h:(f[g+1]<<1|1)&h|(d[g+1]|d[g])<<1|1|d[g+1],f[g]&r&&(h=a(u,g-1))<=s){if(s=h,!((i=g-1)>n))break;l=Math.max(1,2*n-i)}}if(a(u+1,n)>s)break;d=f}return i},diff_match_patch.prototype.match_alphabet_=function(t){for(var e={},n=0;n=2*this.Patch_Margin&&o&&(this.patch_addContext_(t,i),n.push(t),t=new diff_match_patch.patch_obj,o=0,i=a,c=s)}l!==DIFF_INSERT&&(c+=f.length),l!==DIFF_DELETE&&(s+=f.length)}return o&&(this.patch_addContext_(t,i),n.push(t)),n},diff_match_patch.prototype.patch_deepCopy=function(t){for(var e=[],n=0;nthis.Match_MaxBits){var l=this.match_main(e,i.substring(0,this.Match_MaxBits),s);-1!=l&&(-1==(r=this.match_main(e,i.substring(i.length-this.Match_MaxBits),s+i.length-this.Match_MaxBits))||l>=r)&&(l=-1)}else l=this.match_main(e,i,s);if(-1==l)o[c]=!1,a-=t[c].length2-t[c].length1;else if(o[c]=!0,a=l-s,i==(s=-1==r?e.substring(l,l+i.length):e.substring(l,r+this.Match_MaxBits)))e=e.substring(0,l)+this.diff_text2(t[c].diffs)+e.substring(l+i.length);else if(s=this.diff_main(i,s,!1),i.length>this.Match_MaxBits&&this.diff_levenshtein(s)/i.length>this.Patch_DeleteThreshold)o[c]=!1;else{var f;for(this.diff_cleanupSemanticLossless(s),i=0,r=0;ro[0][1].length){var c=e-o[0][1].length;o[0][1]=n.substring(o[0][1].length)+o[0][1],a.start1-=c,a.start2-=c,a.length1+=c,a.length2+=c}return 0==(o=(a=t[t.length-1]).diffs).length||o[o.length-1][0]!=DIFF_EQUAL?(o.push(new diff_match_patch.Diff(DIFF_EQUAL,n)),a.length1+=e,a.length2+=e):e>o[o.length-1][1].length&&(c=e-o[o.length-1][1].length,o[o.length-1][1]+=n.substring(0,c),a.length1+=c,a.length2+=c),n},diff_match_patch.prototype.patch_splitMax=function(t){for(var e=this.Match_MaxBits,n=0;n2*e?(i.length1+=l.length,o+=l.length,r=!1,i.diffs.push(new diff_match_patch.Diff(s,l)),a.diffs.shift()):(l=l.substring(0,e-i.length1-this.Patch_Margin),i.length1+=l.length,o+=l.length,s===DIFF_EQUAL?(i.length2+=l.length,c+=l.length):r=!1,i.diffs.push(new diff_match_patch.Diff(s,l)),l==a.diffs[0][1]?a.diffs.shift():a.diffs[0][1]=a.diffs[0][1].substring(l.length))}s=(s=this.diff_text2(i.diffs)).substring(s.length-this.Patch_Margin),""!==(l=this.diff_text1(a.diffs).substring(0,this.Patch_Margin))&&(i.length1+=l.length,i.length2+=l.length,0!==i.diffs.length&&i.diffs[i.diffs.length-1][0]===DIFF_EQUAL?i.diffs[i.diffs.length-1][1]+=l:i.diffs.push(new diff_match_patch.Diff(DIFF_EQUAL,l))),r||t.splice(++n,0,i)}}},diff_match_patch.prototype.patch_toText=function(t){for(var e=[],n=0;n/g,c=/\n/g,s=0;s");switch(i){case 1:e[s]=`${r}`;break;case-1:e[s]=`${r}`;break;case 0:e[s]=`${r}`}}return e.join("")};class FCN_Suggestion{constructor(){this.toggle=_$$$("suggestions-modal-toggle"),this.tools=_$$$("selection-tools"),this.button=_$$$("button-add-suggestion"),this.toolsButton=_$$$("button-tools-add-suggestion"),this.reset=_$$$("button-suggestion-reset"),this.submit=_$$$("button-suggestion-submit"),this.current=_$$$("suggestions-modal-original"),this.input=_$$$("suggestions-modal-input"),this.output=_$$$("suggestions-modal-diff"),this.chapter=_$(".chapter__article"),this.text="",this.original="",this.latest="",this.paragraph=null,this.dmp=new diff_match_patch,this.bindEvents()}getCaretCoordinates(){let t=0,e=0;if(void 0!==window.getSelection){const n=window.getSelection();if(0!==n.rangeCount){let a=n.getRangeAt(0).cloneRange().getClientRects();a=a[a.length-1],a&&(t=a.right+window.scrollX,e=a.bottom+window.scrollY)}}return{x:t,y:e}}getClosestParagraph(){const t=window.getSelection();return t.rangeCount?t.getRangeAt(0).startContainer.parentNode.closest("p"):null}showTools(t,e){const n=document.documentElement.offsetWidth/2+this.tools.offsetWidth,a=_$$$("wpadminbar")?_$$$("wpadminbar").offsetHeight:0;this.tools.style.transform=e>n?"translate(-100%)":"translate(0)",this.tools.style.top=t+4-a+"px",this.tools.style.left=`${e}px`,this.tools.classList.remove("invisible")}hideTools(){this.tools.style.top="0",this.tools.style.left="-1000px",this.tools.classList.add("invisible")}textSelection(){return fcn_cleanTextSelectionFromButtons(window.getSelection().toString())}clearSelection(){window.getSelection?window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges():document.selection&&document.selection.empty()}getDiff(t,e){const n=this.dmp.diff_main(t,e);return this.dmp.diff_cleanupEfficiency(n),this.dmp.fcn_prettyHtml(n)}toggleTools(t){fcn_theSite.classList.contains("transformed-site")||window.getSelection().rangeCount<1||!window.getSelection().getRangeAt(0).startContainer.parentNode.closest(".content-section")||setTimeout((()=>{if(t.text=t.textSelection().replaceAll("\n\n","\n"),""!==t.text){const e=t.getCaretCoordinates();t.showTools(e.y,e.x)}else t.hideTools()}),10)}toggleViaParagraphTools(t){fcn_theSite.classList.contains("transformed-site")||(t.text=_$(".selected-paragraph").querySelector(".paragraph-inner").innerText,t.showModal(t))}resizeInput(){this.input.style.height="auto",this.input.style.height=`${fcn_clamp(32,108,this.input.scrollHeight+4)}px`}showModal(t){fcn_lastSelectedParagraphId&&fcn_toggleParagraphTools(!1),t.original=t.text,t.current.innerHTML=t.text.replaceAll("\n","
"),t.input.value=t.text,t.output.innerHTML=t.getDiff(t.original,t.text),t.paragraph=t.getClosestParagraph(),t.toggle.click(),t.toggle.checked=!0,t.clearSelection(),t.hideTools(),t.resizeInput(),t.input.focus()}editSuggestion(t){t.resizeInput(),t.output.innerHTML=t.getDiff(t.original,t.input.value)}resetSuggestion(t){t.input.value=t.original,t.resizeInput(),t.output.innerHTML=t.getDiff(t.original,t.original)}submitSuggestion(t){const e=_$(fictioneer_comments.form_selector??"#comment"),n=t.paragraph?.id??null;let a=t.output.innerHTML;[["¶","¶\n"],["
","\n"],["","[ins]"],["","[/ins]"],["","[del]"],["","[/del]"]].forEach((([t,e])=>{a=a.replaceAll(t,e)})),t.latest=n?`\n[quote]${a} [anchor]${n}[/anchor][/quote]\n`:`\n[quote]${a}[/quote]\n`,e?"TEXTAREA"==e.tagName?(e.value+=t.latest,fcn_textareaAdjust(_$("textarea#comment"))):"DIV"==e.tagName&&(e.innerHTML+=t.latest):fcn_commentStack?.push(t.latest),t.toggle.click(),t.toggle.checked=!1,fcn_showNotification(fictioneer_tl.notification.suggestionAppendedToComment)}bindEvents(){this.chapter?.addEventListener("mouseup",this.toggleTools.bind(null,this)),this.button?.addEventListener("click",this.showModal.bind(null,this)),this.toolsButton?.addEventListener("click",this.toggleViaParagraphTools.bind(null,this)),this.input?.addEventListener("input",this.editSuggestion.bind(null,this)),this.reset?.addEventListener("click",this.resetSuggestion.bind(null,this)),this.submit?.addEventListener("click",this.submitSuggestion.bind(null,this))}}const fcn_suggestions=_$(".chapter__article")&&_$(".comment-section")&&_$$$("selection-tools")?new FCN_Suggestion:null;fcn_suggestions&&document.addEventListener("click",(function(t){t.target.closest(".content-section")||fcn_suggestions.hideTools()}));const fcn_ttsInterface=_$$$("tts-interface");var fcn_utter,fcn_synth,fcn_ttsStack=[],fcn_currentReadingId=-1,fcn_ttsPauseTimestamp=-1,fcn_ttsCurrentText="",fcn_ttsSettings=fcn_getTTSsettings(),fcn_voices=[];if("undefined"!=typeof speechSynthesis&&fcn_ttsInterface){fcn_synth=window.speechSynthesis,(fcn_utter=new SpeechSynthesisUtterance).lang=fcn_theRoot.lang;const t=setTimeout((()=>{fcn_setupTTS()}),2e3);"onvoiceschanged"in speechSynthesis&&fcn_synth.addEventListener("voiceschanged",(()=>{fcn_setupTTS(),clearTimeout(t)}),{once:!0})}function fcn_setupTTS(){fcn_voices.length>0||(fcn_setUpVoices(),fcn_updateVolume(fcn_ttsSettings.volume),fcn_updatePitch(fcn_ttsSettings.pitch),fcn_updateRate(fcn_ttsSettings.rate))}function fcn_setTTSsettings(t){fcn_ttsSettings=t,localStorage.setItem("ttsSettings",JSON.stringify(t))}function fcn_getTTSsettings(){const t=fcn_parseJSON(localStorage.getItem("ttsSettings"))??{};return fcn_setTTSsettings(t),t}function fcn_setUpVoices(){const t=fcn_synth.getVoices(),e=_$$$("tts-voice-select");if(!e)return;let n=0;for(let a=0;a{fcn_updateVoice(t.currentTarget.value)})),fcn_updateVoice(fcn_ttsSettings.voice))}function fcn_updateVoice(t){if(isNaN(t)||void 0===fcn_voices[t]){let e=fcn_voices.findIndex((t=>"Samantha"===t.name&&("en-US"===t.lang||"en_US"===t.lang)));e<0&&(e=fcn_voices.findIndex((t=>"en-US"===t.lang||"en_US"===t.lang))),t=e>-1?e:0}fcn_utter.voice=fcn_voices[t],_$$$("tts-voice-select").value=t,fcn_ttsSettings.voice=t,fcn_setTTSsettings(fcn_ttsSettings)}function fcn_updateVolume(t){t=fcn_clamp(0,100,t=isNaN(t)?100:parseInt(t)),_$$$("tts-volume-range").value=t,_$$$("tts-volume-text").value=t,_$$$("tts-volume-reset").classList.toggle("_modified",100!=t),fcn_ttsSettings.volume=t,fcn_setTTSsettings(fcn_ttsSettings),fcn_utter.volume=t/100}function fcn_updatePitch(t){t=fcn_clamp(.2,1.8,t=isNaN(t)?1:parseFloat(t)),_$$$("tts-pitch-range").value=t,_$$$("tts-pitch-text").value=t,_$$$("tts-pitch-reset").classList.toggle("_modified",1!=t),fcn_ttsSettings.pitch=t,fcn_setTTSsettings(fcn_ttsSettings),fcn_utter.pitch=t}function fcn_updateRate(t){t=fcn_clamp(.2,1.8,t=isNaN(t)?1:parseFloat(t)),_$$$("tts-rate-range").value=t,_$$$("tts-rate-text").value=t,_$$$("tts-rate-reset").classList.toggle("_modified",1!=t),fcn_ttsSettings.rate=t,fcn_setTTSsettings(fcn_ttsSettings),fcn_utter.rate=t}function fcn_readTextStack(){const t=_$(".current-reading");if(0===fcn_ttsStack.length)return fcn_ttsInterface.classList.add("ended"),t&&t.classList.remove("current-reading"),fcn_currentReadingId=-1,void(fcn_ttsCurrentText="");const e=fcn_ttsStack.shift();fcn_ttsCurrentText=e[1],fcn_currentReadingId!=e[0]&&(fcn_currentReadingId=e[0],t&&t.classList.remove("current-reading"),_$$$(fcn_currentReadingId).classList.add("current-reading")),fcn_utter.text=fcn_ttsCurrentText,fcn_utter.addEventListener("end",fcn_readTextStack,{once:!0}),fcn_synth.speak(fcn_utter)}"undefined"!=typeof speechSynthesis&&fcn_ttsInterface&&(_$$$("button-tts-set").addEventListener("click",(t=>{fcn_ttsStack=[],fcn_currentReadingId=-1;const e=_$(".chapter-formatting")?.classList.contains("hide-sensitive")??!1?"sensitive-content":"sensitive-alternative",n=_$$$("button-tts-play"),a=new RegExp(fcn_ttsInterface.dataset.regex,"gm");fcn_synth.speaking&&fcn_utter.removeEventListener("end",fcn_readTextStack),fcn_synth.cancel();const o=new Set(["P","H1","H2","H3","H4","H5","H6"]),c=["skip-tts","inside-epub",e];let s=t.target.closest("p[data-paragraph-id]");for(fcn_ttsStack.push(s);s=s.nextElementSibling;)o.has(s.tagName)&&!c.some((t=>s.classList.contains(t)))&&fcn_ttsStack.push(s);fcn_ttsStack=fcn_ttsStack.flatMap((t=>{const e=[],n=t.querySelector(".paragraph-inner");return(n?n.textContent:t.textContent).replace(a,"$1|").split("|").forEach((n=>{const a=n.trim();a.length>0&&e.push([t.id,a])})),e})),fcn_readTextStack(),fcn_theBody.classList.add("tts-open"),fcn_ttsInterface.classList.remove("hidden","ended","paused"),fcn_ttsInterface.classList.add("playing"),n.focus(),n.blur()})),_$$$("button-tts-stop")?.addEventListener("click",(()=>{const t=_$(".current-reading");fcn_ttsInterface.classList.add("hidden","ended"),fcn_ttsInterface.classList.remove("playing","paused"),fcn_theBody.classList.remove("tts-open"),t&&t.classList.remove("current-reading"),fcn_ttsStack=[],fcn_currentReadingId=-1,fcn_utter.removeEventListener("end",fcn_readTextStack),fcn_synth.cancel()})),_$$$("button-tts-play")?.addEventListener("click",(()=>{fcn_synth.resume(),-1!==fcn_ttsPauseTimestamp&&Date.now()-fcn_ttsPauseTimestamp>1e4&&(fcn_ttsStack.unshift([fcn_currentReadingId,fcn_ttsCurrentText]),fcn_synth.cancel(),fcn_readTextStack(),fcn_ttsPauseTimestamp=-1),fcn_ttsInterface.classList.add("playing"),fcn_ttsInterface.classList.remove("paused")})),_$$$("button-tts-pause")?.addEventListener("click",(()=>{fcn_synth.pause(),fcn_ttsPauseTimestamp=Date.now(),fcn_ttsInterface.classList.remove("playing"),fcn_ttsInterface.classList.add("paused")})),_$$$("button-tts-skip")?.addEventListener("click",(()=>{fcn_utter.removeEventListener("end",fcn_readTextStack),fcn_synth.cancel(),fcn_readTextStack(),fcn_ttsInterface.classList.remove("paused"),fcn_ttsInterface.classList.add("playing")})),_$$$("button-tts-scroll")?.addEventListener("click",(()=>{fcn_scrollTo(_$(`p[id="${fcn_currentReadingId}"]`),128)})),_$$("#tts-volume-range, #tts-volume-text").forEach((t=>{t.addEventListener("input",(t=>{fcn_updateVolume(t.target.value)}))})),_$$$("tts-volume-reset")?.addEventListener("click",(()=>{fcn_updateVolume(100)})),_$$("#tts-pitch-range, #tts-pitch-text").forEach((t=>{t.addEventListener("input",(t=>{fcn_updatePitch(t.target.value)}))})),_$$$("tts-pitch-reset")?.addEventListener("click",(()=>{fcn_updatePitch(1)})),_$$("#tts-rate-range, #tts-rate-text").forEach((t=>{t.addEventListener("input",(t=>{fcn_updateRate(t.target.value)}))})),_$$$("tts-rate-reset")?.addEventListener("click",(()=>{fcn_updateRate(1)})),window.addEventListener("beforeunload",(()=>{fcn_synth.cancel()})));var fcn_storyCommentPage=1,fcn_storySettings=fcn_getStorySettings();function fcn_cleanUpActions(){_$$(".story__actions > *").forEach((t=>{const e=window.getComputedStyle(t);"none"!==e.display&&"hidden"!==e.visibility||t.remove()}))}function fcn_getStorySettings(){let t=fcn_parseJSON(localStorage.getItem("fcnStorySettings"))??fcn_defaultStorySettings();return t.timestamp<1674770712849&&(t=fcn_defaultStorySettings(),t.timestamp=Date.now()),fcn_setStorySettings(t),t}function fcn_defaultStorySettings(){return{view:"list",order:"asc",timestamp:1674770712849}}function fcn_setStorySettings(t){"object"==typeof t&&(fcn_storySettings=t,localStorage.setItem("fcnStorySettings",JSON.stringify(t)))}function fcn_applyStorySettings(){"object"==typeof fcn_storySettings&&(_$$("[data-view]").forEach((t=>{t.dataset.view="grid"==fcn_storySettings.view?"grid":"list"})),_$$("[data-order]").forEach((t=>{t.dataset.order="desc"==fcn_storySettings.order?"desc":"asc"})))}fcn_theRoot.dataset.ajaxAuth?document.addEventListener("fcnAuthReady",(()=>{fcn_cleanUpActions()})):document.addEventListener("DOMContentLoaded",(()=>{fcn_cleanUpActions()})),fcn_applyStorySettings();var fcn_isToggling=!1;function fcn_toggleStoryTab(t){const e=t.closest(".story");e.querySelectorAll(".story__tab-target._current, .story__tabs ._current").forEach((t=>{t.classList.remove("_current")})),e.querySelectorAll(`[data-finder="${t.dataset.target}"]`).forEach((t=>{t.classList.add("_current")})),e.querySelector(".story__tabs").dataset.current=t.dataset.target,t.classList.add("_current")}function fcn_loadStoryComments(t){let e;_$(".load-more-list-item").remove(),_$(".comments-loading-placeholder").classList.remove("hidden"),fcn_ajaxGet({post_id:t.dataset.storyId??fcn_theBody.dataset.postId,page:fcn_storyCommentPage},"get_story_comments").then((t=>{t.success?(_$(".fictioneer-comments__list > ul").innerHTML+=t.data.html,fcn_storyCommentPage++):t.data?.error&&(e=fcn_buildErrorNotice(t.data.error))})).catch((t=>{e=fcn_buildErrorNotice(t)})).then((()=>{_$(".comments-loading-placeholder").remove(),e&&_$(".fictioneer-comments__list > ul").appendChild(e)}))}function fcn_startEpubDownload(t,e=0){e>3?t.classList.remove("ajax-in-progress"):fcn_ajaxGet({action:"fictioneer_ajax_download_epub",story_id:t.dataset.storyId}).then((n=>{n.success?(window.location.href=t.href,setTimeout((()=>{t.classList.remove("ajax-in-progress")}),2e3)):setTimeout((()=>{fcn_startEpubDownload(t,e+1)}),2e3)})).catch((e=>{t.classList.remove("ajax-in-progress"),e.status&&e.statusText&&fcn_showNotification(`${e.status}: ${e.statusText}`,5,"warning")}))}function fcn_replaceProfileImage(t,e){const n=t.querySelector(".user-icon");if(n){const a=document.createElement("img");a.classList.add("user-profile-image"),a.src=e,n.remove(),t.appendChild(a)}}function fcn_setProfileImage(t,e=!0){t&&fcn_isValidUrl(t)&&(e&&localStorage.setItem("fcnProfileAvatar",t),_$$("a.subscriber-profile")?.forEach((e=>{fcn_replaceProfileImage(e,t)})),!1===fcn_getUserData().loggedIn&&fcn_prepareLogin())}function fcn_getProfileImage(){let t=localStorage.getItem("fcnProfileAvatar");fcn_isLoggedIn?(fcn_isValidUrl(t)||(t=!1),t?fcn_setProfileImage(t):fcn_getUserAvatar()):localStorage.removeItem("fcnProfileAvatar")}function fcn_getUserAvatar(){fcn_ajaxGet({action:"fictioneer_ajax_get_avatar",fcn_fast_ajax:1}).then((t=>{t.success&&fcn_setProfileImage(t.data.url)})).catch((()=>{fcn_theRoot.dataset.defaultAvatar&&fcn_setProfileImage(fcn_theRoot.dataset.defaultAvatar,!1)}))}function fcn_getUserData(){return fcn_parseJSON(localStorage.getItem("fcnUserData"))??{lastLoaded:0,timestamp:0,loggedIn:"pending",follows:!1,reminders:!1,checkmarks:!1,bookmarks:{},fingerprint:!1}}function fcn_setUserData(t){localStorage.setItem("fcnUserData",JSON.stringify(t))}function fcn_fetchUserData(){let t=fcn_getUserData();if(fcn_isLoggedIn&&!1===t.loggedIn&&(fcn_prepareLogin(),t=fcn_getUserData()),fcn_ajaxLimitThreshold{if(t.success){let e=fcn_getUserData();e=t.data,e.lastLoaded=Date.now(),fcn_setUserData(e);const n=new CustomEvent("fcnUserDataReady",{detail:{data:t.data,time:new Date},bubbles:!0,cancelable:!1});document.dispatchEvent(n)}else{const e=fcn_getUserData();e.lastLoaded=Date.now(),e.loggedIn=!1,fcn_setUserData(e);const n=new CustomEvent("fcnUserDataFailed",{detail:{response:t,time:new Date},bubbles:!0,cancelable:!1});document.dispatchEvent(n)}})).catch((t=>{localStorage.removeItem("fcnUserData");const e=new CustomEvent("fcnUserDataError",{detail:{error:t,time:new Date},bubbles:!0,cancelable:!1});document.dispatchEvent(e)}))}function fcn_unsetOauth(t){const e=prompt(t.dataset.warning);if(!e||e.toLowerCase()!=t.dataset.confirm.toLowerCase())return;const n=_$$$(`oauth-${t.dataset.channel}`);n.classList.add("ajax-in-progress"),fcn_ajaxPost(payload={action:"fictioneer_ajax_unset_my_oauth",nonce:t.dataset.nonce,channel:t.dataset.channel,id:t.dataset.id}).then((t=>{t.success?(n.classList.remove("_connected"),n.classList.add("_disconnected"),n.querySelector("button").remove(),fcn_showNotification(n.dataset.unset)):(n.style.background="var(--notice-warning-background)",fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,5,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{t.status&&t.statusText&&(n.style.background="var(--notice-warning-background)",fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning")),console.error(t)})).then((()=>{n.classList.remove("ajax-in-progress")}))}function fcn_deleteMyAccount(t){if(_$$$("button-delete-my-account").hasAttribute("disabled"))return;const e=prompt(t.dataset.warning);e&&e.toLowerCase()==t.dataset.confirm.toLowerCase()&&(_$$$("button-delete-my-account").setAttribute("disabled",!0),fcn_ajaxPost({action:"fictioneer_ajax_delete_my_account",nonce:t.dataset.nonce,id:t.dataset.id}).then((t=>{t.success?(localStorage.removeItem("fcnAuth"),localStorage.removeItem("fcnProfileAvatar"),location.reload()):(_$$$("button-delete-my-account").innerHTML=t.data.button,fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,5,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{t.status&&t.statusText&&(fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"),_$$$("button-delete-my-account").innerHTML=response.data.button),console.error(t)})))}_$$('[data-click-action*="toggle-chapter-order"]').forEach((t=>{t.addEventListener("click",(t=>{fcn_isToggling||(fcn_isToggling=!0,setTimeout((()=>fcn_isToggling=!1),50),fcn_storySettings.order="asc"===t.currentTarget.dataset.order?"desc":"asc",fcn_setStorySettings(fcn_storySettings),fcn_applyStorySettings())}))})),_$$('[data-click-action*="toggle-chapter-view"]').forEach((t=>{t.addEventListener("click",(t=>{fcn_isToggling||(fcn_isToggling=!0,setTimeout((()=>fcn_isToggling=!1),50),fcn_storySettings.view="list"===t.currentTarget.dataset.view?"grid":"list",fcn_setStorySettings(fcn_storySettings),fcn_applyStorySettings())}))})),_$$(".chapter-group__folding-toggle").forEach((t=>{t.addEventListener("click",(t=>{const e=t.currentTarget.closest(".chapter-group[data-folded]");e&&(e.dataset.folded="true"==e.dataset.folded?"false":"true")}))})),_$$(".tabs__item").forEach((t=>{t.addEventListener("click",(t=>{fcn_toggleStoryTab(t.currentTarget)}))})),_$(".comment-section")?.addEventListener("click",(t=>{t.target?.classList.contains("load-more-comments-button")&&fcn_loadStoryComments(t.target)})),_$$('[data-action="download-epub"]').forEach((t=>{t.addEventListener("click",(t=>{t.preventDefault(),t.currentTarget.classList.contains("ajax-in-progress")||(t.currentTarget.classList.add("ajax-in-progress"),fcn_startEpubDownload(t.currentTarget))}))})),document.addEventListener("DOMContentLoaded",(()=>{fcn_isLoggedIn&&!fcn_theRoot.dataset.ajaxAuth&&fcn_getProfileImage()})),fcn_theRoot.dataset.ajaxAuth&&document.addEventListener("fcnAuthReady",(()=>{fcn_getProfileImage()})),fcn_theRoot.dataset.ajaxAuth?document.addEventListener("fcnAuthReady",(()=>{fcn_fetchUserData()})):document.addEventListener("DOMContentLoaded",(()=>{fcn_isLoggedIn&&fcn_fetchUserData()})),_$$(".button-unset-oauth").forEach((t=>{t.addEventListener("click",(t=>{fcn_unsetOauth(t.currentTarget)}))})),_$$$("button-delete-my-account")?.addEventListener("click",(t=>{fcn_deleteMyAccount(t.currentTarget)}));const fcn_profileDataTranslations=_$$$("profile-data-translations")?.dataset;function fcn_dataDeletionPrompt(t){const e=prompt(t.dataset.warning);return!(!e||e.toLowerCase()!=t.dataset.confirm.toLowerCase())}function fcn_clearData(t,e){const n=t.closest(".card");localStorage.removeItem("fcnBookshelfContent"),n.classList.add("ajax-in-progress"),t.remove(),fcn_ajaxPost({action:e,fcn_fast_ajax:1,nonce:t.dataset.nonce}).then((t=>{t.success?n.querySelector(".card__content").innerHTML=t.data.success:(fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,10,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,10,"warning"),console.error(t)})).then((()=>{n.classList.remove("ajax-in-progress")}))}_$(".button-clear-comments")?.addEventListener("click",(t=>{fcn_dataDeletionPrompt(t.currentTarget)&&fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_comments")})),_$(".button-clear-comment-subscriptions")?.addEventListener("click",(t=>{fcn_dataDeletionPrompt(t.currentTarget)&&fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_comment_subscriptions")})),_$(".button-clear-checkmarks")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.checkmarks={data:{},updated:Date.now()},fcn_setUserData(e),fcn_updateCheckmarksView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_checkmarks",!0)})),_$(".button-clear-reminders")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.reminders={data:{}},fcn_setUserData(e),fcn_updateRemindersView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_reminders",!0)})),_$(".button-clear-follows")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.follows={data:{}},fcn_setUserData(e),fcn_updateFollowsView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_follows",!0)})),_$(".button-clear-bookmarks")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.bookmarks="{}",fcn_setUserData(e),fcn_bookmarks.data={},t.currentTarget.closest(".card").querySelector(".card__content").innerHTML=fcn_profileDataTranslations.clearedSuccess,fcn_setBookmarks(fcn_bookmarks)}));const fcn_jumpToBookmarkButtons=_$$(".button--bookmark"),fcn_mobileBookmarkJump=_$$$("mobile-menu-bookmark-jump"),fcn_mobileBookmarkList=_$(".mobile-menu__bookmark-list"),fcn_bookmarksSmallCardBlock=_$(".bookmarks-block"),fcn_bookmarksSmallCardTemplate=_$(".bookmark-small-card-template");var fcn_bookmarks,fcn_userBookmarksTimeout;function fcn_initializeLocalBookmarks(){fcn_setBookmarks(fcn_bookmarks=fcn_getBookmarks(),!0),fcn_updateBookmarksView()}function fcn_initializeUserBookmarks(t){fcn_setBookmarks(JSON.parse(t.detail.data.bookmarks),!0),fcn_updateBookmarksView()}function fcn_getBookmarks(){let t=fcn_parseJSON(localStorage.getItem("fcnChapterBookmarks"))??{data:{}};return Array.isArray(t.data)&&0===t.data.length&&(t.data={}),t=fcn_fixBookmarks(t),!t||Object.keys(t).length<1?{data:{}}:t}function fcn_fixBookmarks(t){const e={};for(const n in t.data)if(n.startsWith("ch-")){const a=fcn_fixBookmarksNode(t.data[n]);a&&(e[n]=a)}return{data:e}}function fcn_fixBookmarksNode(t){const e={},n={"paragraph-id":"",progress:0,date:"",color:"",chapter:"",link:"",thumb:"",image:"",story:"",content:""};for(const a in n){if(typeof t[a]!=typeof n[a])return null;e[a]=t[a]}const a=new Date(e.date);return a&&"[object Date]"===Object.prototype.toString.call(a)&&!isNaN(a)||(e.date=(new Date).toISOString()),("number"!=typeof e.progress||e.progress<0)&&(e.progress=0),e}function fcn_setBookmarks(t,e=!1){if("object"==typeof t){if(fcn_bookmarks=t,localStorage.setItem("fcnChapterBookmarks",JSON.stringify(t)),fcn_isLoggedIn){const e=fcn_getUserData();e&&(e.bookmarks=JSON.stringify(t),fcn_setUserData(e))}e||fcn_saveUserBookmarks(t)}}function fcn_updateBookmarksView(){if(!fcn_bookmarks||!fcn_bookmarks.data)return;const t=_$(".profile-bookmarks-stats"),e=Object.keys(fcn_bookmarks.data).length;t&&(t.innerHTML=t.innerHTML.replace("%s",e)),e>0&&_$$(".icon-menu-bookmarks").forEach((t=>{t.classList.remove("hidden")})),fcn_showBookmarkCards(),fcn_showChapterBookmark()}function fcn_saveUserBookmarks(t){fcn_isLoggedIn&&(clearTimeout(fcn_userBookmarksTimeout),t=fcn_fixBookmarks(t),fcn_userBookmarksTimeout=setTimeout((()=>{fcn_ajaxPost({action:"fictioneer_ajax_save_bookmarks",fcn_fast_ajax:1,bookmarks:JSON.stringify(t)}).then((t=>{t.success||(fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,3,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,3,"warning"),console.error(t)}))}),fictioneer_ajax.post_debounce_rate))}function fcn_toggleBookmark(t,e="none"){fcn_bookmarks=fcn_getBookmarks();const n=_$(".chapter__article"),a=_$(".current-bookmark");if(!n)return;const o=fcn_bookmarks.data[n.id];if(o&&o["paragraph-id"]==t&&a)"none"!=e&&e!=o.color?(_$(".current-bookmark").dataset.bookmarkColor=e,o.color=e):fcn_removeBookmark(n.id);else{Object.keys(fcn_bookmarks.data).length>=50&&fcn_removeBookmark(Object.keys(fcn_bookmarks.data)[0]);const o=_$(`[data-paragraph-id="${t}"]`),c=_$$$("chapter-bookmark-data").dataset;fcn_bookmarks.data[n.id]={"paragraph-id":t,progress:100*(fcn_offset(o).top-fcn_offset(o.parentElement).top)/o.parentElement.clientHeight,date:(new Date).toISOString(),color:e,chapter:c.title.trim(),link:c.link,thumb:c.thumb,image:c.image,story:c.storyTitle.trim(),content:o.querySelector("span").innerHTML.substring(0,128)+"…"},fcn_jumpToBookmarkButtons.forEach((t=>{t.classList.remove("hidden")})),fcn_mobileBookmarkJump?.removeAttribute("hidden"),a?.classList.remove("current-bookmark"),o.classList.add("current-bookmark"),o.setAttribute("data-bookmark-color",e)}fcn_setMobileMenuBookmarks(),fcn_setBookmarks(fcn_bookmarks)}function fcn_showChapterBookmark(){_$(".current-bookmark")?.classList.remove("current-bookmark");const t=_$(".chapter__article");if(!t||!fcn_bookmarks.data[t.id])return;const e=fcn_bookmarks.data[t.id]["paragraph-id"],n=_$(`[data-paragraph-id="${e}"]`),a=fcn_bookmarks.data[t.id].color??"none";e&&n&&(fcn_jumpToBookmarkButtons.forEach((t=>{t.classList.remove("hidden")})),fcn_mobileBookmarkJump?.removeAttribute("hidden"),n.classList.add("current-bookmark"),n.setAttribute("data-bookmark-color",a))}function fcn_setMobileMenuBookmarks(){fcn_mobileBookmarkList.innerHTML="";const t=Object.entries(fcn_bookmarks.data),e=_$("#mobile-bookmark-template");if(t.length>0){const n=document.createDocumentFragment();t.forEach((([t,{color:a,progress:o,link:c,chapter:s,"paragraph-id":i}])=>{const r=e.content.cloneNode(!0),l=r.querySelector(".mobile-menu__bookmark");l.classList.add(`bookmark-${t}`),l.dataset.color=a,r.querySelector(".mobile-menu__bookmark-progress > div > div").style.width=`${o.toFixed(1)}%`,r.querySelector(".mobile-menu__bookmark a").href=`${c}#paragraph-${i}`,r.querySelector(".mobile-menu__bookmark a span").innerText=s,r.querySelector(".mobile-menu-bookmark-delete-button").setAttribute("data-bookmark-id",t),n.appendChild(r)})),fcn_mobileBookmarkList.appendChild(n),fcn_bookmarkDeleteHandler(_$$(".mobile-menu-bookmark-delete-button"))}else{const t=document.createElement("li");t.classList.add("no-bookmarks"),t.textContent=fcn_mobileBookmarkList.dataset.empty,fcn_mobileBookmarkList.appendChild(t)}}function fcn_showBookmarkCards(){if(!fcn_bookmarks||!fcn_bookmarksSmallCardBlock||!fcn_bookmarksSmallCardTemplate||Object.keys(fcn_bookmarks.data).length<1||_$(".bookmark-card"))return;fcn_bookmarksSmallCardBlock.classList.remove("hidden"),_$(".bookmarks-block__no-bookmarks")?.remove(),_$$(".show-if-bookmarks").forEach((t=>t.classList.remove("hidden")));let t=parseInt(fcn_bookmarksSmallCardBlock.dataset.count);const e=document.createDocumentFragment();Object.entries(fcn_bookmarks.data).sort(((t,e)=>new Date(e[1].date)-new Date(t[1].date))).forEach((([n,{color:a,progress:o,link:c,chapter:s,"paragraph-id":i,date:r,image:l,thumb:f,content:d}])=>{if(0==t)return;t--;const _=fcn_bookmarksSmallCardTemplate.content.cloneNode(!0),u=new Date(r).toLocaleDateString(navigator.language??"en-US",{year:"2-digit",month:"short",day:"numeric"});l&&_.querySelector(".bookmark-card__image")?(_.querySelector(".bookmark-card__image").href=l,_.querySelector(".bookmark-card__image img").src=f):_.querySelector(".bookmark-card__image")?.remove(),_.querySelector(".bookmark-card__excerpt").innerHTML+=d,_.querySelector(".bookmark-card").classList.add(`bookmark-${n}`),_.querySelector(".bookmark-card").dataset.color=a,_.querySelector(".bookmark-card__title > a").href=`${c}#paragraph-${i}`,_.querySelector(".bookmark-card__title > a").innerText=s,_.querySelector(".bookmark-card__percentage").innerText=`${o.toFixed(1)} %`,_.querySelector(".bookmark-card__progress").style.width=`calc(${o.toFixed(1)}% - var(--bookmark-progress-offset, 0px))`,_.querySelector("time").innerText=u,_.querySelector(".button-delete-bookmark").setAttribute("data-bookmark-id",n),e.appendChild(_)})),fcn_bookmarksSmallCardBlock.querySelector("ul").appendChild(e),fcn_bookmarkDeleteHandler(_$$(".button-delete-bookmark"))}function fcn_bookmarkDeleteHandler(t){("object"==typeof t?t:[t]).forEach((t=>{t.addEventListener("click",(t=>{fcn_removeBookmark(t.currentTarget.dataset.bookmarkId),fcn_setBookmarks(fcn_bookmarks),Object.keys(fcn_bookmarks.data).length<1&&(_$(".bookmarks-block")?.classList.add("hidden"),_$$(".show-if-bookmarks").forEach((t=>{t.classList.add("hidden")})))}))}))}function fcn_removeBookmark(t){const e=_$(".chapter__article"),n=_$(".current-bookmark");delete fcn_bookmarks.data[t],e&&e.id==t&&(fcn_jumpToBookmarkButtons.forEach((t=>{t.classList.add("hidden")})),fcn_mobileBookmarkJump?.setAttribute("hidden",!0),n&&(n.classList.remove("current-bookmark"),n.removeAttribute("data-bookmark-color"))),_$$(`.bookmark-${t}`)?.forEach((t=>{t.remove()}))}fcn_initializeLocalBookmarks(),document.addEventListener("fcnUserDataReady",(t=>{fcn_initializeUserBookmarks(t)})),fcn_jumpToBookmarkButtons.forEach((t=>{t.addEventListener("click",(()=>{_$(`[data-paragraph-id="${fcn_bookmarks.data[_$("article").id]["paragraph-id"]}"]`).scrollIntoView({behavior:"smooth"})}))}));const fcn_followsMenuItem=_$$$("follow-menu-button");var fcn_userFollowsTimeout,fcn_follows,fcn_checkmarks,fcn_userCheckmarksTimeout,fcn_userRemindersTimeout,fcn_reminders;function fcn_initializeFollows(t){const e=t.detail.data.follows;!1!==e&&(Array.isArray(e.data)&&0===e.data.length&&(e.data={}),fcn_follows=e,fcn_updateFollowsView(),localStorage.removeItem("fcnBookshelfContent"))}function fcn_toggleFollow(t){const e=fcn_getUserData();if(fcn_follows&&e.follows){if(localStorage.removeItem("fcnBookshelfContent"),JSON.stringify(fcn_follows.data[t])!==JSON.stringify(e.follows.data[t]))return fcn_follows=e.follows,fcn_showNotification(fictioneer_tl.notification.followsResynchronized),void fcn_updateFollowsView();fcn_follows.data[t]?delete fcn_follows.data[t]:fcn_follows.data[t]={story_id:parseInt(t),timestamp:Date.now()},e.follows.data[t]=fcn_follows.data[t],e.lastLoaded=0,fcn_setUserData(e),fcn_updateFollowsView(),clearTimeout(fcn_userFollowsTimeout),fcn_userFollowsTimeout=setTimeout((()=>{fcn_ajaxPost({action:"fictioneer_ajax_toggle_follow",fcn_fast_ajax:1,story_id:t,set:!!fcn_follows.data[t]}).then((t=>{t.success||(fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,5,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{429===t.status?fcn_showNotification(fictioneer_tl.notification.slowDown,3,"warning"):t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"),console.error(t)}))}),fictioneer_ajax.post_debounce_rate)}}function fcn_updateFollowsView(){const t=fcn_getUserData();if(!fcn_follows||!t.follows)return;_$$(".button-follow-story").forEach((t=>{t.classList.toggle("_followed",!!fcn_follows?.data[t.dataset.storyId])})),_$$(".card").forEach((t=>{t.classList.toggle("has-follow",!!fcn_follows?.data[t.dataset.storyId])}));const e=parseInt(fcn_follows.new)>0;_$$(".mark-follows-read, .follows-alert-number, .mobile-menu-button").forEach((t=>{t.classList.toggle("_new",e),e>0&&(t.dataset.newCount=fcn_follows.new)}))}function fcn_setupFollowsHTML(){fcn_followsMenuItem.classList.contains("_loaded")||fcn_ajaxGet({action:"fictioneer_ajax_get_follows_notifications",fcn_fast_ajax:1}).then((t=>{if(t.data.html){const e=_$$$("follow-menu-scroll");e&&(e.innerHTML=t.data.html);const n=_$$$("mobile-menu-follows-list");n&&(n.innerHTML=t.data.html),!1===fcn_getUserData().loggedIn&&(fcn_prepareLogin(),fcn_fetchUserData())}})).catch((t=>{429===t.status?fcn_showNotification(fictioneer_tl.notification.slowDown,3,"warning"):t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"),_$$$("follow-menu-scroll")?.remove(),_$$$("mobile-menu-follows-list")?.remove()})).then((()=>{fcn_followsMenuItem.classList.add("_loaded")}))}function fcn_markFollowsRead(){if(!fcn_followsMenuItem.classList.contains("_new")||!fcn_followsMenuItem.classList.contains("_loaded"))return;_$$(".mark-follows-read, .follows-alert-number, .follow-item, .mobile-menu-button").forEach((t=>{t.classList.remove("_new")}));const t=fcn_getUserData();t.new=0,t.lastLoaded=0,fcn_setUserData(t),fcn_ajaxPost({action:"fictioneer_ajax_mark_follows_read",fcn_fast_ajax:1}).catch((t=>{t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning")}))}function fcn_initializeCheckmarks(t){const e=t.detail.data.checkmarks;!1!==e&&(Array.isArray(e.data)&&0===e.data.length&&(e.data={}),fcn_checkmarks=e,fcn_updateCheckmarksView(),localStorage.removeItem("fcnBookshelfContent"),_$$("button.checkmark").forEach((t=>{t.addEventListener("click",(t=>{fcn_clickCheckmark(t.currentTarget)}))})))}function fcn_toggleCheckmark(t,e,n=null,a=null,o="toggle"){const c=fcn_getUserData();if(fcn_checkmarks&&c.checkmarks){if(localStorage.removeItem("fcnBookshelfContent"),"toggle"===o&&JSON.stringify(fcn_checkmarks.data[t])!==JSON.stringify(c.checkmarks.data[t]))return fcn_checkmarks=c.checkmarks,fcn_showNotification(fictioneer_tl.notification.checkmarksResynchronized),void fcn_updateCheckmarksView();if(fcn_checkmarks.data[t]||(fcn_checkmarks.data[t]=[]),c.checkmarks.data[t]||(c.checkmarks.data[t]=[]),n&&"progress"===e&&!fcn_checkmarks.data[t].includes(n)&&fcn_checkmarks.data[t].push(n),n&&"chapter"===e)if(!fcn_checkmarks.data[t].includes(n)&&"unset"!==o||"set"===o)fcn_checkmarks.data[t].push(n),a&&(a.classList.add("marked"),a.setAttribute("aria-checked",!0));else{fcn_removeItemOnce(fcn_checkmarks.data[t],n),a&&(a.classList.remove("marked"),a.setAttribute("aria-checked",!1)),fcn_removeItemOnce(fcn_checkmarks.data[t],t);const e=_$('button[data-type="story"]');e&&(e.classList.remove("marked"),e.setAttribute("aria-checked",!1))}if("story"===e){const e=(fcn_checkmarks.data[t].includes(t)||"unset"===o)&&"set"!==o;fcn_checkmarks.data[t]=[],e||(_$$("button.checkmark").forEach((e=>{fcn_checkmarks.data[t].push(parseInt(e.dataset.id))})),fcn_checkmarks.data[t].includes(t)||fcn_checkmarks.data[t].push(t))}fcn_checkmarks.data[t]=fcn_checkmarks.data[t].filter(((t,e,n)=>n.indexOf(t)==e)),c.checkmarks.data[t]=fcn_checkmarks.data[t],c.lastLoaded=0,fcn_setUserData(c),fcn_updateCheckmarksView(),clearTimeout(fcn_userCheckmarksTimeout),fcn_userCheckmarksTimeout=setTimeout((()=>{fcn_updateCheckmarks(t,fcn_checkmarks.data[t])}),fictioneer_ajax.post_debounce_rate)}}function fcn_clickCheckmark(t){fcn_toggleCheckmark(parseInt(t.dataset.storyId),t.dataset.type,parseInt(t.dataset.id),t)}function fcn_updateCheckmarks(t,e=null){fcn_ajaxPost({action:"fictioneer_ajax_set_checkmark",fcn_fast_ajax:1,story_id:t,update:(e=e||fcn_getUserData().checkmarks.data[t]).join(" ")}).then((t=>{t.success||(fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,3,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"),console.error(t)}))}function fcn_updateCheckmarksView(){const t=fcn_getUserData(),e=t.checkmarks;if(!e)return;const n=parseInt(fcn_theBody.dataset.storyId);if(n){const a=e.data[n]&&e.data[n].includes(n);if(a){let a=!1;_$$("button.checkmark").forEach((t=>{const o=parseInt(t.dataset.id);e.data[n].includes(o)||(e.data[n].push(o),a=!0)})),a&&(t.checkmarks=e,fcn_setUserData(t),fcn_updateCheckmarks(n,e.data[n]))}_$$$("ribbon-read")?.classList.toggle("hidden",!a)}_$$("button.checkmark").forEach((t=>{const n=parseInt(t.dataset.storyId);if(e.data[n]){const a=e.data[n].includes(parseInt(t.dataset.id));t.classList.toggle("marked",a),t.setAttribute("aria-checked",a)}})),_$$(".card").forEach((t=>{const n=parseInt(t.dataset.storyId),a=e.data[n]&&(e.data[n].includes(parseInt(t.dataset.checkId))||e.data[n].includes(n));t.classList.toggle("has-checkmark",1==a)}))}function fcn_initializeReminders(t){const e=t.detail.data.reminders;!1!==e&&(Array.isArray(e.data)&&0===e.data.length&&(e.data={}),fcn_reminders=e,fcn_updateRemindersView(),localStorage.removeItem("fcnBookshelfContent"))}function fcn_toggleReminder(t){const e=fcn_getUserData();if(fcn_reminders&&e.reminders){if(localStorage.removeItem("fcnBookshelfContent"),JSON.stringify(fcn_reminders.data[t])!==JSON.stringify(e.reminders.data[t]))return fcn_reminders=e.reminders,fcn_showNotification(fictioneer_tl.notification.remindersResynchronized),void fcn_updateRemindersView();fcn_reminders.data[t]?delete fcn_reminders.data[t]:fcn_reminders.data[t]={story_id:parseInt(t),timestamp:Date.now()},e.reminders.data[t]=fcn_reminders.data[t],e.lastLoaded=0,fcn_setUserData(e),fcn_updateRemindersView(),clearTimeout(fcn_userRemindersTimeout),fcn_userRemindersTimeout=setTimeout((()=>{fcn_ajaxPost({action:"fictioneer_ajax_toggle_reminder",fcn_fast_ajax:1,story_id:t,set:!!fcn_reminders.data[t]}).then((t=>{t.success||(fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,5,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{429===t.status?fcn_showNotification(fictioneer_tl.notification.slowDown,3,"warning"):t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"),console.error(t)}))}),fictioneer_ajax.post_debounce_rate)}}function fcn_updateRemindersView(){const t=fcn_getUserData();fcn_reminders&&t.reminders&&(_$$(".button-read-later").forEach((t=>{t.classList.toggle("_remembered",!!fcn_reminders.data[t.dataset.storyId])})),_$$(".card").forEach((t=>{t.classList.toggle("has-reminder",!!fcn_reminders.data[t.dataset.storyId])})))}function fcn_addJSTrap(){const t=document.querySelector(".comment-form");t&&t.appendChild(fcn_html`
diff --git a/src/js/chapter.js b/src/js/chapter.js
index b4f99293..f4550f98 100644
--- a/src/js/chapter.js
+++ b/src/js/chapter.js
@@ -203,7 +203,7 @@ if (fcn_paragraphTools) {
// Listen for click on paragraph tools copy link button
_$$$('button-get-link').onclick = (e) => {
fcn_copyToClipboard(
- `${location.host}${location.pathname}#${e.target.closest('p[data-paragraph-id]').id}`,
+ `${location.protocol}//${location.host}${location.pathname}#${e.target.closest('p[data-paragraph-id]').id}`,
fictioneer_tl.notification.linkCopiedToClipboard
);
}