@fluid-topics/ft-reader-context 1.1.69 → 1.1.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- !function(t,i,e,s){class n{constructor(t){this.paginatedToc=t,this.nodeByTocId={},this.knownPrettyUrls=new Set,this.duplicatedPrettyUrls=new Set,this.pages=[],this.pageByTocId={}}build(){return{paginationConfiguration:this.paginatedToc.configuration,toc:this.convertNodes(this.paginatedToc.paginatedToc,1),pagesToc:this.extractPagesToc(this.paginatedToc.paginatedToc,1),nodeByTocId:this.nodeByTocId,duplicatedPrettyUrls:this.duplicatedPrettyUrls,pages:this.pages,pageByTocId:this.pageByTocId}}extractPagesToc(t,i,e){return t.flatMap((t=>(t.pageConfiguration&&this.registerPage(this.buildPage(t,e)),null==t.tocId?this.extractPagesToc(t.children,i,e):[{tocId:t.tocId,title:t.title,depth:i,children:this.extractPagesToc(t.children,i+1,t.tocId)}])))}convertNodes(t,i,e){return t.flatMap((t=>{var s,n,r;if(null==t.tocId)return[...this.convertSectionNodes(null!==(s=t.pageToc)&&void 0!==s?s:[],i,t.tocId),...this.convertNodes(t.children,i,t.tocId)];let o=null===(n=t.prettyUrl)||void 0===n?void 0:n.replace(/^\//,"");const a={tocId:t.tocId,contentId:t.contentId,title:t.title,hasRating:t.hasRating,origin:t.origin,prettyUrl:o,depth:i,parentTocId:e,children:[]};this.register(a);const h=this.convertSectionNodes(null!==(r=t.pageToc)&&void 0!==r?r:[],i+1,t.tocId),u=this.convertNodes(t.children,i+1,a.tocId);return a.children=[...h,...u],[a]}))}convertSectionNodes(t,i,e){return t.flatMap((t=>{var s;let n=null===(s=t.prettyUrl)||void 0===s?void 0:s.replace(/^\//,"");const r={...t,prettyUrl:n,depth:i,parentTocId:e,children:[]};return this.register(r),r.children=this.convertSectionNodes(t.children,i+1,t.tocId),[r]}))}buildPage(t,i){var e,s,n,r,o,a;const h={number:this.pages.length+1,title:null!==(e=t.title)&&void 0!==e?e:"",rootTocId:null!==(s=t.tocId)&&void 0!==s?s:"root",toc:(null!==(n=t.pageToc)&&void 0!==n?n:[]).map((t=>this.nodeByTocId[t.tocId])),topics:[],hiddenTopics:[],breadcrumb:i?this.buildBreadcrumb(this.nodeByTocId[i]):[]},u=(t,i)=>(i?h.topics:h.hiddenTopics).push(t),l=null!==(o=null===(r=t.pageConfiguration)||void 0===r?void 0:r.parentsVisibility)&&void 0!==o?o:[];return h.breadcrumb.forEach(((t,i)=>{u(t,l[i])})),t.tocId&&u(t.tocId,t.pageConfiguration.isVisible),h.topics.push(...this.tocIds(null!==(a=t.pageToc)&&void 0!==a?a:[])),h}registerPage(t){for(let i of[...t.topics,...t.hiddenTopics])this.pageByTocId[i]||(this.pageByTocId[i]=t);this.pages.push(t)}tocIds(t){return t.flatMap((t=>[t.tocId,...this.tocIds(t.children)]))}buildBreadcrumb(t){const i=[t.tocId];for(;null==t?void 0:t.parentTocId;)i.unshift(t.parentTocId),t=this.nodeByTocId[t.parentTocId];return i}register(t){t.prettyUrl&&(this.knownPrettyUrls.has(t.prettyUrl)&&this.duplicatedPrettyUrls.add(t.prettyUrl),this.knownPrettyUrls.add(t.prettyUrl)),this.nodeByTocId[t.tocId]=t}}class r{convertPaginatedToc(t){return new n(t).build()}}var o,a,h,u,l,c,d,v,f,p,w,g,m,y,T,E,b,A;!function(t){!function(i){var e={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(e.arrayBuffer)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function r(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var i={next:function(){var i=t.shift();return{done:void 0===i,value:i}}};return e.iterable&&(i[Symbol.iterator]=function(){return i}),i}function h(t){this.map={},t instanceof h?t.forEach((function(t,i){this.append(i,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(i){this.append(i,t[i])}),this)}function u(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function l(t){return new Promise((function(i,e){t.onload=function(){i(t.result)},t.onerror=function(){e(t.error)}}))}function c(t){var i=new FileReader,e=l(i);return i.readAsArrayBuffer(t),e}function d(t){if(t.slice)return t.slice(0);var i=new Uint8Array(t.byteLength);return i.set(new Uint8Array(t)),i.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var i;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:e.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:e.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():e.arrayBuffer&&e.blob&&((i=t)&&DataView.prototype.isPrototypeOf(i))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):e.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||n(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=u(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(c)}),this.text=function(){var t,i,e,s=u(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,i=new FileReader,e=l(i),i.readAsText(t),e;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var i=new Uint8Array(t),e=new Array(i.length),s=0;s<i.length;s++)e[s]=String.fromCharCode(i[s]);return e.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,i){t=r(t),i=o(i);var e=this.map[t];this.map[t]=e?e+", "+i:i},h.prototype.delete=function(t){delete this.map[r(t)]},h.prototype.get=function(t){return t=r(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(r(t))},h.prototype.set=function(t,i){this.map[r(t)]=o(i)},h.prototype.forEach=function(t,i){for(var e in this.map)this.map.hasOwnProperty(e)&&t.call(i,this.map[e],e,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(i,e){t.push(e)})),a(t)},h.prototype.values=function(){var t=[];return this.forEach((function(i){t.push(i)})),a(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(i,e){t.push([e,i])})),a(t)},e.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var f=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function p(t,i){var e,s,n=(i=i||{}).body;if(t instanceof p){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,i.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=i.credentials||this.credentials||"same-origin",!i.headers&&this.headers||(this.headers=new h(i.headers)),this.method=(e=i.method||this.method||"GET",s=e.toUpperCase(),f.indexOf(s)>-1?s:e),this.mode=i.mode||this.mode||null,this.signal=i.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function w(t){var i=new FormData;return t.trim().split("&").forEach((function(t){if(t){var e=t.split("="),s=e.shift().replace(/\+/g," "),n=e.join("=").replace(/\+/g," ");i.append(decodeURIComponent(s),decodeURIComponent(n))}})),i}function g(t,i){i||(i={}),this.type="default",this.status=void 0===i.status?200:i.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in i?i.statusText:"OK",this.headers=new h(i.headers),this.url=i.url||"",this._initBody(t)}p.prototype.clone=function(){return new p(this,{body:this._bodyInit})},v.call(p.prototype),v.call(g.prototype),g.prototype.clone=function(){return new g(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},g.error=function(){var t=new g(null,{status:0,statusText:""});return t.type="error",t};var m=[301,302,303,307,308];g.redirect=function(t,i){if(-1===m.indexOf(i))throw new RangeError("Invalid status code");return new g(null,{status:i,headers:{location:t}})},i.DOMException=t.DOMException;try{new i.DOMException}catch(t){i.DOMException=function(t,i){this.message=t,this.name=i;var e=Error(t);this.stack=e.stack},i.DOMException.prototype=Object.create(Error.prototype),i.DOMException.prototype.constructor=i.DOMException}function y(t,s){return new Promise((function(n,r){var o=new p(t,s);if(o.signal&&o.signal.aborted)return r(new i.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,i,e={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",i=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var e=t.split(":"),s=e.shift().trim();if(s){var n=e.join(":").trim();i.append(s,n)}})),i)};e.url="responseURL"in a?a.responseURL:e.headers.get("X-Request-URL");var s="response"in a?a.response:a.responseText;n(new g(s,e))},a.onerror=function(){r(new TypeError("Network request failed"))},a.ontimeout=function(){r(new TypeError("Network request failed"))},a.onabort=function(){r(new i.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&e.blob&&(a.responseType="blob"),o.headers.forEach((function(t,i){a.setRequestHeader(i,t)})),o.signal&&(o.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",u)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}y.polyfill=!0,t.fetch||(t.fetch=y,t.Headers=h,t.Request=p,t.Response=g),i.Headers=h,i.Request=p,i.Response=g,i.fetch=y,Object.defineProperty(i,"t",{value:!0})}({})}("undefined"!=typeof self?self:void 0),function(t){t.black="black",t.green="green",t.blue="blue",t.purple="purple",t.red="red",t.orange="orange",t.yellow="yellow"}(o||(o={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(a||(a={})),function(t){t.THIRD_PARTY="THIRD_PARTY",t.OFF_THE_GRID="OFF_THE_GRID",t.CONTENT_PACKAGER="CONTENT_PACKAGER",t.PAGES="PAGES",t.DESIGNED_READER="DESIGNED_READER"}(h||(h={})),function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"}(u||(u={})),function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"}(l||(l={})),function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"}(c||(c={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(d||(d={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_QUARTER="LAST_QUARTER",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(v||(v={})),function(t){t.ASC="ASC",t.DESC="DESC"}(f||(f={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(p||(p={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(w||(w={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(g||(g={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(m||(m={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(y||(y={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(T||(T={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS"}(E||(E={})),function(t){t.PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",t.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",t.HTML_EXPORT_USER="HTML_EXPORT_USER",t.PDF_EXPORT_USER="PDF_EXPORT_USER",t.SAVED_SEARCH_USER="SAVED_SEARCH_USER",t.COLLECTION_USER="COLLECTION_USER",t.OFFLINE_USER="OFFLINE_USER",t.ANALYTICS_USER="ANALYTICS_USER",t.BETA_USER="BETA_USER",t.DEBUG_USER="DEBUG_USER",t.PRINT_USER="PRINT_USER",t.RATING_USER="RATING_USER",t.FEEDBACK_USER="FEEDBACK_USER",t.GENERATIVE_AI_USER="GENERATIVE_AI_USER",t.CONTENT_PUBLISHER="CONTENT_PUBLISHER",t.KHUB_ADMIN="KHUB_ADMIN",t.USERS_ADMIN="USERS_ADMIN",t.PORTAL_ADMIN="PORTAL_ADMIN",t.ADMIN="ADMIN",t.DEVELOPER="DEVELOPER"}(b||(b={})),function(t){t.VALID="VALID",t.INVALID="INVALID"}(A||(A={}));const S={[b.PERSONAL_BOOK_SHARE_USER]:[b.PERSONAL_BOOK_USER],[b.HTML_EXPORT_USER]:[b.PERSONAL_BOOK_USER],[b.PDF_EXPORT_USER]:[b.PERSONAL_BOOK_USER],[b.KHUB_ADMIN]:[b.CONTENT_PUBLISHER],[b.ADMIN]:[b.KHUB_ADMIN,b.USERS_ADMIN,b.PORTAL_ADMIN],[b.DEVELOPER]:[b.BETA_USER,b.DEBUG_USER]};function I(t,i){return t===i||(S[t]??[]).some((t=>I(t,i)))}function R(t,i){if(null==t)return!1;return(Array.isArray(t)?t:Array.isArray(t.roles)?t.roles:Array.isArray(t.profile?.roles)?t.profile.roles:[]).some((t=>I(t,i)))}var O;t.FtReaderFeatures=void 0,(O=t.FtReaderFeatures||(t.FtReaderFeatures={})).FEEDBACK="FEEDBACK",O.RATING="RATING",O.PRINT="PRINT",O.BOOKMARK="BOOKMARK",O.COLLECTIONS="COLLECTIONS",O.PERSONAL_BOOKS="PERSONAL_BOOKS";const C=e.css`
2
- `,U=i.FtReduxStore.get({name:"ft-app-info",reducers:{},initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0,openExternalDocumentInNewTab:!1,navigatorOnline:!0,forcedOffline:!1}});class P{static get(t){const{baseUrl:i,apiIntegrationIdentifier:e}=U.getState(),s=null!=t?t:e;if(i&&s&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(i,s,!0)}static await(t){return new Promise((i=>{let e=P.get(t);if(e)i(e);else{const s=U.subscribe((()=>{e=P.get(t),e&&(s(),i(e))}))}}))}}class N{constructor(t=!0,e){var s;this.overrideApi=e;let n=this.constructor;n.commonCache=null!==(s=n.commonCache)&&void 0!==s?s:new i.CacheRegistry,this.cache=t?n.commonCache:new i.CacheRegistry}get api(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:P.get()}get awaitApi(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:P.await()}clearCache(){this.cache.clearAll()}}var L;const D=Symbol("clearAfterUnitTest");class M extends N{constructor(t){super(),this.messageContextProvider=t,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[L]=()=>{this.defaultMessages={},this.cache=new i.CacheRegistry,this.listeners={}},this.currentUiLocale=U.getState().uiLocale,U.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=U.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const i=t.name.toLowerCase();this.cache.setFinal(i,t),this.notify(i)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,e){var s;if(t=t.toLowerCase(),Object.keys(e).length>0){const n={...null!==(s=this.defaultMessages[t])&&void 0!==s?s:{},...e};i.deepEqual(this.defaultMessages[t],n)||(this.defaultMessages[t]=n,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,e,...s){var n,r,o;t=t.toLowerCase(),this.fetchContext(t);const a=null!==(r=null===(n=this.cache.getNow(t))||void 0===n?void 0:n.messages)&&void 0!==r?r:{};return new i.ParametrizedLabelResolver(null!==(o=this.defaultMessages[t])&&void 0!==o?o:{},a).resolve(e,...s)}async fetchContext(t){if(!this.cache.has(t))try{await this.cache.get(t,(()=>this.messageContextProvider(this.currentUiLocale,t))),await this.notify(t)}catch(t){console.error(t)}}subscribe(t,i){var e;return t=t.toLowerCase(),this.listeners[t]=null!==(e=this.listeners[t])&&void 0!==e?e:new Set,this.listeners[t].add(i),()=>{var e;return null===(e=this.listeners[t])||void 0===e?void 0:e.delete(i)}}async notifyAll(){await Promise.all(Object.keys(this.listeners).map((t=>this.notify(t))))}async notify(t){null!=this.listeners[t]&&await Promise.all([...this.listeners[t].values()].map((t=>i.delay(0).then((()=>t())).catch((()=>null)))))}}L=D,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new class extends M{constructor(){super((async(t,i)=>(await this.awaitApi).getFluidTopicsMessageContext(t,i)))}}),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new class extends M{constructor(){super((async(t,i)=>(await this.awaitApi).getCustomMessageContext(t,i)))}});const _=window.FluidTopicsI18nService;var B=function(t,i,e,s){for(var n,r=arguments.length,o=r<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(i,e,o):n(i,e))||o);return r>3&&o&&Object.defineProperty(i,e,o),o};class k extends i.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.navigatorOnline=!1,this.forcedOffline=!1,this.apiProvider=()=>P.get(),this.messageContexts=[],this.cache=new i.CacheRegistry,this.cleanSessionDebouncer=new i.Debouncer}render(){return e.html`
1
+ "use strict";(()=>{var ut=Object.create;var Ae=Object.defineProperty;var dt=Object.getOwnPropertyDescriptor;var ht=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var $=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var mt=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ht(e))!ft.call(r,s)&&s!==t&&Ae(r,s,{get:()=>e[s],enumerable:!(i=dt(e,s))||i.enumerable});return r};var v=(r,e,t)=>(t=r!=null?ut(pt(r)):{},mt(e||!r||!r.__esModule?Ae(t,"default",{value:r,enumerable:!0}):t,r));var R=$((Et,Te)=>{Te.exports=ftGlobals.wcUtils});var V=$((It,Se)=>{Se.exports=ftGlobals.lit});var de=$((Rt,be)=>{be.exports=ftGlobals.litDecorators});var Ce=$(Re=>{(function(r){var e=function(t){var i={searchParams:"URLSearchParams"in r,iterable:"Symbol"in r&&"iterator"in Symbol,blob:"FileReader"in r&&"Blob"in r&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in r,arrayBuffer:"ArrayBuffer"in r};function s(a){return a&&DataView.prototype.isPrototypeOf(a)}if(i.arrayBuffer)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(a){return a&&o.indexOf(Object.prototype.toString.call(a))>-1};function d(a){if(typeof a!="string"&&(a=String(a)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(a))throw new TypeError("Invalid character in header field name");return a.toLowerCase()}function y(a){return typeof a!="string"&&(a=String(a)),a}function p(a){var n={next:function(){var u=a.shift();return{done:u===void 0,value:u}}};return i.iterable&&(n[Symbol.iterator]=function(){return n}),n}function f(a){this.map={},a instanceof f?a.forEach(function(n,u){this.append(u,n)},this):Array.isArray(a)?a.forEach(function(n){this.append(n[0],n[1])},this):a&&Object.getOwnPropertyNames(a).forEach(function(n){this.append(n,a[n])},this)}f.prototype.append=function(a,n){a=d(a),n=y(n);var u=this.map[a];this.map[a]=u?u+", "+n:n},f.prototype.delete=function(a){delete this.map[d(a)]},f.prototype.get=function(a){return a=d(a),this.has(a)?this.map[a]:null},f.prototype.has=function(a){return this.map.hasOwnProperty(d(a))},f.prototype.set=function(a,n){this.map[d(a)]=y(n)},f.prototype.forEach=function(a,n){for(var u in this.map)this.map.hasOwnProperty(u)&&a.call(n,this.map[u],u,this)},f.prototype.keys=function(){var a=[];return this.forEach(function(n,u){a.push(u)}),p(a)},f.prototype.values=function(){var a=[];return this.forEach(function(n){a.push(n)}),p(a)},f.prototype.entries=function(){var a=[];return this.forEach(function(n,u){a.push([u,n])}),p(a)},i.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function L(a){if(a.bodyUsed)return Promise.reject(new TypeError("Already read"));a.bodyUsed=!0}function P(a){return new Promise(function(n,u){a.onload=function(){n(a.result)},a.onerror=function(){u(a.error)}})}function B(a){var n=new FileReader,u=P(n);return n.readAsArrayBuffer(a),u}function it(a){var n=new FileReader,u=P(n);return n.readAsText(a),u}function st(a){for(var n=new Uint8Array(a),u=new Array(n.length),S=0;S<n.length;S++)u[S]=String.fromCharCode(n[S]);return u.join("")}function ye(a){if(a.slice)return a.slice(0);var n=new Uint8Array(a.byteLength);return n.set(new Uint8Array(a)),n.buffer}function ve(){return this.bodyUsed=!1,this._initBody=function(a){this._bodyInit=a,a?typeof a=="string"?this._bodyText=a:i.blob&&Blob.prototype.isPrototypeOf(a)?this._bodyBlob=a:i.formData&&FormData.prototype.isPrototypeOf(a)?this._bodyFormData=a:i.searchParams&&URLSearchParams.prototype.isPrototypeOf(a)?this._bodyText=a.toString():i.arrayBuffer&&i.blob&&s(a)?(this._bodyArrayBuffer=ye(a.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):i.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(a)||c(a))?this._bodyArrayBuffer=ye(a):this._bodyText=a=Object.prototype.toString.call(a):this._bodyText="",this.headers.get("content-type")||(typeof a=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):i.searchParams&&URLSearchParams.prototype.isPrototypeOf(a)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i.blob&&(this.blob=function(){var a=L(this);if(a)return a;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?L(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var a=L(this);if(a)return a;if(this._bodyBlob)return it(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(st(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i.formData&&(this.formData=function(){return this.text().then(ot)}),this.json=function(){return this.text().then(JSON.parse)},this}var at=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function nt(a){var n=a.toUpperCase();return at.indexOf(n)>-1?n:a}function D(a,n){n=n||{};var u=n.body;if(a instanceof D){if(a.bodyUsed)throw new TypeError("Already read");this.url=a.url,this.credentials=a.credentials,n.headers||(this.headers=new f(a.headers)),this.method=a.method,this.mode=a.mode,this.signal=a.signal,!u&&a._bodyInit!=null&&(u=a._bodyInit,a.bodyUsed=!0)}else this.url=String(a);if(this.credentials=n.credentials||this.credentials||"same-origin",(n.headers||!this.headers)&&(this.headers=new f(n.headers)),this.method=nt(n.method||this.method||"GET"),this.mode=n.mode||this.mode||null,this.signal=n.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&u)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(u)}D.prototype.clone=function(){return new D(this,{body:this._bodyInit})};function ot(a){var n=new FormData;return a.trim().split("&").forEach(function(u){if(u){var S=u.split("="),T=S.shift().replace(/\+/g," "),h=S.join("=").replace(/\+/g," ");n.append(decodeURIComponent(T),decodeURIComponent(h))}}),n}function ct(a){var n=new f,u=a.replace(/\r?\n[\t ]+/g," ");return u.split(/\r?\n/).forEach(function(S){var T=S.split(":"),h=T.shift().trim();if(h){var G=T.join(":").trim();n.append(h,G)}}),n}ve.call(D.prototype);function w(a,n){n||(n={}),this.type="default",this.status=n.status===void 0?200:n.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in n?n.statusText:"OK",this.headers=new f(n.headers),this.url=n.url||"",this._initBody(a)}ve.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},w.error=function(){var a=new w(null,{status:0,statusText:""});return a.type="error",a};var lt=[301,302,303,307,308];w.redirect=function(a,n){if(lt.indexOf(n)===-1)throw new RangeError("Invalid status code");return new w(null,{status:n,headers:{location:a}})},t.DOMException=r.DOMException;try{new t.DOMException}catch{t.DOMException=function(n,u){this.message=n,this.name=u;var S=Error(n);this.stack=S.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function le(a,n){return new Promise(function(u,S){var T=new D(a,n);if(T.signal&&T.signal.aborted)return S(new t.DOMException("Aborted","AbortError"));var h=new XMLHttpRequest;function G(){h.abort()}h.onload=function(){var H={status:h.status,statusText:h.statusText,headers:ct(h.getAllResponseHeaders()||"")};H.url="responseURL"in h?h.responseURL:H.headers.get("X-Request-URL");var ue="response"in h?h.response:h.responseText;u(new w(ue,H))},h.onerror=function(){S(new TypeError("Network request failed"))},h.ontimeout=function(){S(new TypeError("Network request failed"))},h.onabort=function(){S(new t.DOMException("Aborted","AbortError"))},h.open(T.method,T.url,!0),T.credentials==="include"?h.withCredentials=!0:T.credentials==="omit"&&(h.withCredentials=!1),"responseType"in h&&i.blob&&(h.responseType="blob"),T.headers.forEach(function(H,ue){h.setRequestHeader(ue,H)}),T.signal&&(T.signal.addEventListener("abort",G),h.onreadystatechange=function(){h.readyState===4&&T.signal.removeEventListener("abort",G)}),h.send(typeof T._bodyInit>"u"?null:T._bodyInit)})}return le.polyfill=!0,r.fetch||(r.fetch=le,r.Headers=f,r.Request=D,r.Response=w),t.Headers=f,t.Request=D,t.Response=w,t.fetch=le,Object.defineProperty(t,"__esModule",{value:!0}),t}({})})(typeof self<"u"?self:Re)});var rt=v(R());var K=v(V()),k=v(de()),E=v(R());var U=v(R());var Ee=v(R()),Ie=r=>Ee.FtReduxStore.get({name:"ft-reader-"+r,initialState:{mapId:void 0,visibleTopics:[],map:void 0,toc:void 0,pagesToc:void 0,paginationConfiguration:void 0,currentPage:void 0,scrollTarget:void 0,configuration:void 0,searchInDocumentQuery:void 0,relatives:void 0}});var he=class{constructor(e){this.paginatedToc=e,this.nodeByTocId={},this.knownPrettyUrls=new Set,this.duplicatedPrettyUrls=new Set,this.pages=[],this.pageByTocId={}}build(){return{paginationConfiguration:this.paginatedToc.configuration,toc:this.convertNodes(this.paginatedToc.paginatedToc,1),pagesToc:this.extractPagesToc(this.paginatedToc.paginatedToc,1),nodeByTocId:this.nodeByTocId,duplicatedPrettyUrls:this.duplicatedPrettyUrls,pages:this.pages,pageByTocId:this.pageByTocId}}extractPagesToc(e,t,i){return e.flatMap(s=>(s.pageConfiguration&&this.registerPage(this.buildPage(s,i)),s.tocId==null?this.extractPagesToc(s.children,t,i):[{tocId:s.tocId,title:s.title,depth:t,children:this.extractPagesToc(s.children,t+1,s.tocId)}]))}convertNodes(e,t,i){return e.flatMap(s=>{var o,c,d;if(s.tocId==null)return[...this.convertSectionNodes((o=s.pageToc)!==null&&o!==void 0?o:[],t,s.tocId),...this.convertNodes(s.children,t,s.tocId)];let y=(c=s.prettyUrl)===null||c===void 0?void 0:c.replace(/^\//,""),p={tocId:s.tocId,contentId:s.contentId,title:s.title,hasRating:s.hasRating,origin:s.origin,prettyUrl:y,depth:t,parentTocId:i,children:[]};this.register(p);let f=this.convertSectionNodes((d=s.pageToc)!==null&&d!==void 0?d:[],t+1,s.tocId),L=this.convertNodes(s.children,t+1,p.tocId);return p.children=[...f,...L],[p]})}convertSectionNodes(e,t,i){return e.flatMap(s=>{var o;let c=(o=s.prettyUrl)===null||o===void 0?void 0:o.replace(/^\//,""),d={...s,prettyUrl:c,depth:t,parentTocId:i,children:[]};return this.register(d),d.children=this.convertSectionNodes(s.children,t+1,s.tocId),[d]})}buildPage(e,t){var i,s,o,c,d,y;let p={number:this.pages.length+1,title:(i=e.title)!==null&&i!==void 0?i:"",rootTocId:(s=e.tocId)!==null&&s!==void 0?s:"root",toc:((o=e.pageToc)!==null&&o!==void 0?o:[]).map(P=>this.nodeByTocId[P.tocId]),topics:[],hiddenTopics:[],breadcrumb:t?this.buildBreadcrumb(this.nodeByTocId[t]):[]},f=(P,B)=>(B?p.topics:p.hiddenTopics).push(P),L=(d=(c=e.pageConfiguration)===null||c===void 0?void 0:c.parentsVisibility)!==null&&d!==void 0?d:[];return p.breadcrumb.forEach((P,B)=>{f(P,L[B])}),e.tocId&&f(e.tocId,e.pageConfiguration.isVisible),p.topics.push(...this.tocIds((y=e.pageToc)!==null&&y!==void 0?y:[])),p}registerPage(e){for(let t of[...e.topics,...e.hiddenTopics])this.pageByTocId[t]||(this.pageByTocId[t]=e);this.pages.push(e)}tocIds(e){return e.flatMap(t=>[t.tocId,...this.tocIds(t.children)])}buildBreadcrumb(e){let t=[e.tocId];for(;e?.parentTocId;)t.unshift(e.parentTocId),e=this.nodeByTocId[e.parentTocId];return t}register(e){e.prettyUrl&&(this.knownPrettyUrls.has(e.prettyUrl)&&this.duplicatedPrettyUrls.add(e.prettyUrl),this.knownPrettyUrls.add(e.prettyUrl)),this.nodeByTocId[e.tocId]=e}},j=class{convertPaginatedToc(e){return new he(e).build()}};var Dt=v(Ce(),1);var xe;(function(r){r.black="black",r.green="green",r.blue="blue",r.purple="purple",r.red="red",r.orange="orange",r.yellow="yellow"})(xe||(xe={}));var we;(function(r){r.OFFICIAL="OFFICIAL",r.PERSONAL="PERSONAL",r.SHARED="SHARED"})(we||(we={}));var _e;(function(r){r.THIRD_PARTY="THIRD_PARTY",r.OFF_THE_GRID="OFF_THE_GRID",r.CONTENT_PACKAGER="CONTENT_PACKAGER",r.PAGES="PAGES",r.DESIGNED_READER="DESIGNED_READER"})(_e||(_e={}));var Oe;(function(r){r.HOMEPAGE="HOMEPAGE",r.CUSTOM="CUSTOM",r.READER="READER",r.TOPIC_TEMPLATE="TOPIC_TEMPLATE",r.SEARCH="SEARCH",r.SEARCH_RESULT="SEARCH_RESULT"})(Oe||(Oe={}));var Ue;(function(r){r.CLASSIC="CLASSIC",r.CUSTOM="CUSTOM",r.DESIGNER="DESIGNER"})(Ue||(Ue={}));var Pe;(function(r){r.AND="AND",r.OR="OR",r.MONOVALUED="MONOVALUED"})(Pe||(Pe={}));var Me;(function(r){r.NONE="NONE",r.ALPHABET="ALPHABET",r.VERSION="VERSION"})(Me||(Me={}));var q;(function(r){r.STARS="STARS",r.LIKE="LIKE",r.DICHOTOMOUS="DICHOTOMOUS",r.NO_RATING="NO_RATING"})(q||(q={}));var ke;(function(r){r.LAST_WEEK="LAST_WEEK",r.LAST_MONTH="LAST_MONTH",r.LAST_QUARTER="LAST_QUARTER",r.LAST_YEAR="LAST_YEAR",r.CUSTOM="CUSTOM"})(ke||(ke={}));var Le;(function(r){r.ASC="ASC",r.DESC="DESC"})(Le||(Le={}));var De;(function(r){r.ALPHA="ALPHA",r.NATURAL="NATURAL"})(De||(De={}));var Ne;(function(r){r.EVERYWHERE="EVERYWHERE",r.TITLE_ONLY="TITLE_ONLY",r.NONE="NONE"})(Ne||(Ne={}));var Fe;(function(r){r.ARTICLE="ARTICLE",r.BOOK="BOOK",r.SHARED_BOOK="SHARED_BOOK"})(Fe||(Fe={}));var Be;(function(r){r.FLUIDTOPICS="FLUIDTOPICS",r.EXTERNAL="EXTERNAL"})(Be||(Be={}));var He;(function(r){r.MAP="MAP",r.DOCUMENT="DOCUMENT",r.TOPIC="TOPIC",r.PERSONAL_BOOK="PERSONAL_BOOK",r.SHARED_BOOK="SHARED_BOOK"})(He||(He={}));var Ve;(function(r){r.MAP="MAP",r.DOCUMENT="DOCUMENT",r.TOPIC="TOPIC"})(Ve||(Ve={}));var Ke;(function(r){r.DEFAULT="DEFAULT",r.DOCUMENTS="DOCUMENTS",r.ALL_TOPICS="ALL_TOPICS"})(Ke||(Ke={}));var m;(function(r){r.PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",r.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",r.HTML_EXPORT_USER="HTML_EXPORT_USER",r.PDF_EXPORT_USER="PDF_EXPORT_USER",r.SAVED_SEARCH_USER="SAVED_SEARCH_USER",r.COLLECTION_USER="COLLECTION_USER",r.OFFLINE_USER="OFFLINE_USER",r.ANALYTICS_USER="ANALYTICS_USER",r.BETA_USER="BETA_USER",r.DEBUG_USER="DEBUG_USER",r.PRINT_USER="PRINT_USER",r.RATING_USER="RATING_USER",r.FEEDBACK_USER="FEEDBACK_USER",r.GENERATIVE_AI_USER="GENERATIVE_AI_USER",r.CONTENT_PUBLISHER="CONTENT_PUBLISHER",r.KHUB_ADMIN="KHUB_ADMIN",r.USERS_ADMIN="USERS_ADMIN",r.PORTAL_ADMIN="PORTAL_ADMIN",r.ADMIN="ADMIN",r.DEVELOPER="DEVELOPER"})(m||(m={}));var Ge;(function(r){r.VALID="VALID",r.INVALID="INVALID"})(Ge||(Ge={}));var gt={[m.PERSONAL_BOOK_SHARE_USER]:[m.PERSONAL_BOOK_USER],[m.HTML_EXPORT_USER]:[m.PERSONAL_BOOK_USER],[m.PDF_EXPORT_USER]:[m.PERSONAL_BOOK_USER],[m.KHUB_ADMIN]:[m.CONTENT_PUBLISHER],[m.ADMIN]:[m.KHUB_ADMIN,m.USERS_ADMIN,m.PORTAL_ADMIN],[m.DEVELOPER]:[m.BETA_USER,m.DEBUG_USER]};function $e(r,e){return r===e||(gt[r]??[]).some(t=>$e(t,e))}function N(r,e){return r==null?!1:(Array.isArray(r)?r:Array.isArray(r.roles)?r.roles:Array.isArray(r.profile?.roles)?r.profile.roles:[]).some(i=>$e(i,e))}var O;(function(r){r.FEEDBACK="FEEDBACK",r.RATING="RATING",r.PRINT="PRINT",r.BOOKMARK="BOOKMARK",r.COLLECTIONS="COLLECTIONS",r.PERSONAL_BOOKS="PERSONAL_BOOKS"})(O||(O={}));var Ze=v(R());var Ye=v(V()),C=v(de()),x=v(R());var je=v(V());var qe=je.css`
2
+ `;var ze=v(R()),yt="ft-app-info",vt={},l=ze.FtReduxStore.get({name:yt,reducers:vt,initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0,openExternalDocumentInNewTab:!1,navigatorOnline:!0,forcedOffline:!1}});var M=v(R());var pe=v(R());var F=class r{static get(e){let{baseUrl:t,apiIntegrationIdentifier:i}=l.getState(),s=e??i;if(t&&s&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(t,s,!0)}static await(e){return new Promise(t=>{let i=r.get(e);if(i)t(i);else{let s=l.subscribe(()=>{i=r.get(e),i&&(s(),t(i))})}})}};var _=class{constructor(e=!0,t){var i;this.overrideApi=t;let s=this.constructor;s.commonCache=(i=s.commonCache)!==null&&i!==void 0?i:new pe.CacheRegistry,this.cache=e?s.commonCache:new pe.CacheRegistry}get api(){var e;return(e=this.overrideApi)!==null&&e!==void 0?e:F.get()}get awaitApi(){var e;return(e=this.overrideApi)!==null&&e!==void 0?e:F.await()}clearCache(){this.cache.clearAll()}};var We,At=Symbol("clearAfterUnitTest"),z=class extends _{constructor(e){super(),this.messageContextProvider=e,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[We]=()=>{this.defaultMessages={},this.cache=new M.CacheRegistry,this.listeners={}},this.currentUiLocale=l.getState().uiLocale,l.subscribe(()=>this.clearWhenUiLocaleChanges())}clearWhenUiLocaleChanges(){let{uiLocale:e}=l.getState();this.currentUiLocale!==e&&(this.currentUiLocale=e,this.cache.clearAll(),this.notifyAll())}addContext(e){let t=e.name.toLowerCase();this.cache.setFinal(t,e),this.notify(t)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(e,t){var i;if(e=e.toLowerCase(),Object.keys(t).length>0){let s={...(i=this.defaultMessages[e])!==null&&i!==void 0?i:{},...t};(0,M.deepEqual)(this.defaultMessages[e],s)||(this.defaultMessages[e]=s,await this.notify(e))}await this.fetchContext(e)}resolveMessage(e,t,...i){var s,o,c;e=e.toLowerCase(),this.fetchContext(e);let d=(o=(s=this.cache.getNow(e))===null||s===void 0?void 0:s.messages)!==null&&o!==void 0?o:{};return new M.ParametrizedLabelResolver((c=this.defaultMessages[e])!==null&&c!==void 0?c:{},d).resolve(t,...i)}async fetchContext(e){if(!this.cache.has(e))try{await this.cache.get(e,()=>this.messageContextProvider(this.currentUiLocale,e)),await this.notify(e)}catch(t){console.error(t)}}subscribe(e,t){var i;return e=e.toLowerCase(),this.listeners[e]=(i=this.listeners[e])!==null&&i!==void 0?i:new Set,this.listeners[e].add(t),()=>{var s;return(s=this.listeners[e])===null||s===void 0?void 0:s.delete(t)}}async notifyAll(){await Promise.all(Object.keys(this.listeners).map(e=>this.notify(e)))}async notify(e){this.listeners[e]!=null&&await Promise.all([...this.listeners[e].values()].map(t=>(0,M.delay)(0).then(()=>t()).catch(()=>null)))}};We=At;window.FluidTopicsI18nService==null&&(window.FluidTopicsI18nService=new class extends z{constructor(){super(async(r,e)=>(await this.awaitApi).getFluidTopicsMessageContext(r,e))}});window.FluidTopicsCustomI18nService==null&&(window.FluidTopicsCustomI18nService=new class extends z{constructor(){super(async(r,e)=>(await this.awaitApi).getCustomMessageContext(r,e))}});var Xe=window.FluidTopicsI18nService,Jt=window.FluidTopicsCustomI18nService;var b=function(r,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,i);else for(var d=r.length-1;d>=0;d--)(c=r[d])&&(o=(s<3?c(o):s>3?c(e,t,o):c(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o},g=class extends x.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.navigatorOnline=!1,this.forcedOffline=!1,this.apiProvider=()=>F.get(),this.messageContexts=[],this.cache=new x.CacheRegistry,this.cleanSessionDebouncer=new x.Debouncer}render(){return Ye.html`
3
3
  <slot></slot>
4
- `}update(t){super.update(t),t.has("baseUrl")&&(U.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),t.has("apiIntegrationIdentifier")&&U.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&U.actions.uiLocale(this.uiLocale),t.has("metadataConfiguration")&&U.actions.metadataConfiguration(this.metadataConfiguration),t.has("noCustom")&&U.actions.noCustom(this.noCustom),t.has("editorMode")&&U.actions.editorMode(this.editorMode),t.has("noCustomComponent")&&U.actions.noCustomComponent(this.noCustomComponent),t.has("session")&&U.actions.session(this.session),t.has("availableUiLocales")&&U.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>_.addContext(t))),t.has("openExternalDocumentInNewTab")&&U.actions.openExternalDocumentInNewTab(this.openExternalDocumentInNewTab),t.has("navigatorOnline")&&U.actions.navigatorOnline(this.navigatorOnline),t.has("forcedOffline")&&U.actions.forcedOffline(this.forcedOffline),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){!this.withManualResources&&this.apiProvider()&&(null==this.session&&this.updateSession(),null==this.availableUiLocales&&this.updateUiLocales(),null==this.metadataConfiguration&&this.updateMetadataConfiguration())}async updateSession(){this.session=await this.cache.get("session",(async()=>{const t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),t.idleTimeoutInMillis),t}))}async updateUiLocales(){this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>this.apiProvider().getAvailableUiLocales()))}async updateMetadataConfiguration(){this.metadataConfiguration=await this.cache.get("metadataConfiguration",(()=>this.apiProvider().getMetadataConfiguration()))}}k.elementDefinitions={},k.styles=C,B([s.property()],k.prototype,"baseUrl",void 0),B([s.property()],k.prototype,"apiIntegrationIdentifier",void 0),B([s.property()],k.prototype,"uiLocale",void 0),B([i.jsonProperty(null)],k.prototype,"availableUiLocales",void 0),B([i.jsonProperty(null)],k.prototype,"metadataConfiguration",void 0),B([s.property({type:Boolean})],k.prototype,"editorMode",void 0),B([s.property({type:Boolean})],k.prototype,"noCustom",void 0),B([s.property({type:Boolean})],k.prototype,"openExternalDocumentInNewTab",void 0),B([s.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],k.prototype,"noCustomComponent",void 0),B([s.property({type:Boolean})],k.prototype,"withManualResources",void 0),B([s.property({type:Boolean})],k.prototype,"navigatorOnline",void 0),B([s.property({type:Boolean})],k.prototype,"forcedOffline",void 0),B([s.property({type:Object})],k.prototype,"apiProvider",void 0),B([i.jsonProperty([])],k.prototype,"messageContexts",void 0),B([i.jsonProperty(void 0)],k.prototype,"session",void 0);class x extends N{async listMySearches(){let t=U.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-searches",(async()=>(await this.awaitApi).listMySearches(t.profile.userId)),3e5):[]}}class F extends N{async listMyBookmarks(){let t=U.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-bookmarks",(async()=>(await this.awaitApi).listMyBookmarks(t.profile.userId)),3e5):[]}}const H=i.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const j=new class{constructor(){this.currentSession=U.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new F,this.savedSearchesService=new x,U.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:e}=U.getState();i.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==e?void 0:e.profile)||(this.currentSession=e,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),H.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),H.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();const t=await this.savedSearchesService.listMySearches();H.actions.savedSearches(t)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const i=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;H.actions.bookmarks(i)}}};window.FluidTopicsAppInfoStoreService=new class{addCommand(t,i=!1){U.commands.add(t,i)}consumeCommand(t){return U.commands.consume(t)}};window.FluidTopicsHighlightHtmlService=new class{highlightHtml(t,e){i.highlightHtml(t,e)}},i.customElement("ft-app-context")(k);class G extends N{get mapId(){return this._mapId}set mapId(t){t!==this._mapId&&this.clear(),this._mapId=t}constructor(t,i,e){super(!1,i),this.converter=t,this._mapId=e,this.initCache()}async withMapId(t){return this._mapId?t(this._mapId):void 0}initCache(){this.cache.registerFinal("configuration",(()=>this.api.getReaderConfiguration())),this.cache.register("map",(()=>this.withMapId((t=>this.fetchMap(t))))),this.cache.register("enrichedToc",(()=>this.withMapId((t=>this.fetchPages(t).then((t=>this.converter.convertPaginatedToc(t))))))),this.cache.register("ratingSummary",(()=>{var t,i;return R(null!==(i=null===(t=U.getState().session)||void 0===t?void 0:t.profile.roles)&&void 0!==i?i:[],"RATING_USER")?this.withMapId((t=>this.fetchMapRating(t))):Promise.resolve()}))}clear(){this.cache.clearAll()}getMap(){return this.cache.get("map")}getMapNow(){return this.cache.getNow("map")}getConfiguration(){return this.cache.get("configuration")}getEnrichedToc(){return this.cache.get("enrichedToc")}get enrichedToc(){return this.cache.getNow("enrichedToc")}async getPaginationConfiguration(){return(await this.getEnrichedToc()).paginationConfiguration}async getToc(){return(await this.getEnrichedToc()).toc}async getPagesToc(){return(await this.getEnrichedToc()).pagesToc}async getTocNode(t){return(await this.getEnrichedToc()).nodeByTocId[t]}getTocNodeNow(t){var i;return null===(i=this.enrichedToc)||void 0===i?void 0:i.nodeByTocId[t]}async getPage(t){const i=await this.getEnrichedToc();return i.pages[t-1]||i.pages[0]}async getPageByTocId(t){const i=await this.getEnrichedToc();return i.pageByTocId[t]||i.pages[0]}getTopicInfo(t){return this.cache.get("topic-"+t.tocId,(()=>this.fetchTopicMetadata(t)))}getTopicContent(t){return this.cache.get("topic-content-"+t.tocId,(()=>this.fetchTopicHTMLContent(t)))}getAttachments(){return this.cache.get("map-attachments",(()=>this.fetchAttachments()))}getRelativesForDocument(t,i){return this.cache.get("document-relatives-"+t+"-"+i.join("-"),(()=>this.fetchRelativesForDocument(t,i)))}getRelativesForTopicInMap(t,i,e){return this.cache.get("topic-relatives-"+[t,i,...e].join("-"),(()=>this.fetchRelativesForTopicInMap(t,i,e)))}getAttachmentDownloadLink(t){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(t).content}?download=true`)}getLink(t,i,e){const s=this.getNavigationData(t,i,e),n=this.getReaderLinkPrefix()+(s.prettyUrl?s.prettyUrl:`${s.mapId}/${s.tocId}`),r=new URL(n,this.api.tenantBaseUrl);return null!=s.page&&r.searchParams.set("page",`${s.page}`),s.prettyUrlDuplicated&&r.searchParams.set("tocId",s.tocId),null!=s.section&&r.searchParams.set("section",s.section),r.href}getNavigationData(t,i,e){var s,n;t=t||"root";const r=this.enrichedToc,o=null==r?void 0:r.pageByTocId[t],a=null==r?void 0:r.nodeByTocId[t],h=null==a?void 0:a.prettyUrl;return{mapId:this.mapId,tocId:t,topicTitle:null!==(s=null==a?void 0:a.title)&&void 0!==s?s:"",page:i&&o&&o.number!==i?i:void 0,prettyUrl:null!=h?h.replace(/^r\//,""):void 0,prettyUrlDuplicated:null!==(n=null==r?void 0:r.duplicatedPrettyUrls.has(null!=h?h:""))&&void 0!==n&&n,section:e}}async getAccurateNavigationData(t,i,e){return await this.getEnrichedToc(),this.getNavigationData(t,i,e)}getRatingSummary(){return this.cache.get("ratingSummary")}reloadRating(){return this.cache.clear("ratingSummary"),this.getRatingSummary()}getMapRating(){return this.getRatingSummary().then((t=>null==t?void 0:t.publication))}getTopicRating(t){return this.getRatingSummary().then((i=>{var e;return i?{type:i.topics.type,rating:null===(e=i.topics)||void 0===e?void 0:e.ratings.find((i=>i.tocId===t))}:void 0}))}rateMap(t,i){return this.makeRateMapRequest(t,i).then((()=>this.clearRatingIfNecessary()))}unrateMap(){return this.makeUnrateMapRequest().then((()=>this.clearRatingIfNecessary()))}sendMapFeedback(t,i){return this.makeMapFeedbackRequest(t,i)}rateTopic(t,i,e){return this.makeRateTopicRequest(t,i,e).then((()=>this.clearRatingIfNecessary()))}unrateTopic(t){return this.makeUnrateTopicRequest(t).then((()=>this.clearRatingIfNecessary()))}async clearRatingIfNecessary(){const t=U.getState().session;(null==t?void 0:t.sessionAuthenticated)&&this.cache.clear("ratingSummary")}sendTopicFeedback(t,i,e){return this.makeTopicFeedbackRequest(t,i,e)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(t){let i=this.getTocNodeNow(t),e=[{tocId:i.tocId,title:i.title}],s=this.getTocNodeNow(i.parentTocId);for(;s;)e.unshift({tocId:s.tocId,title:s.title}),s=this.getTocNodeNow(s.parentTocId);return e}isFeatureAccessible(i,{session:e,ratingType:s}){var n;if(!this.isFeatureAvailable(i))return!1;switch(i){case t.FtReaderFeatures.FEEDBACK:return R(null!=e?e:[],b.FEEDBACK_USER);case t.FtReaderFeatures.RATING:return R(null!=e?e:[],b.RATING_USER)&&null!=s&&s!==d.NO_RATING;case t.FtReaderFeatures.PRINT:return R(null!=e?e:[],b.PRINT_USER);case t.FtReaderFeatures.BOOKMARK:return!!(null==e?void 0:e.sessionAuthenticated);case t.FtReaderFeatures.COLLECTIONS:return R(null!=e?e:[],b.COLLECTION_USER);case t.FtReaderFeatures.PERSONAL_BOOKS:return R(null!=e?e:[],b.PERSONAL_BOOK_USER)&&!(null===(n=this.getMapNow())||void 0===n?void 0:n.pbkConfidential);default:return!1}}makeAbsolute(t){return this.api.makeAbsolute(t)}}class K extends G{static async build(t){return new K(new r,void 0,t)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(t){const i=await this.api.getMap(t);return this.fingerprint=i.fingerprint,i}fetchMapRating(t){return this.api.getMapRating(t)}async fetchPages(t){return await this.getMap(),this.api.getPages(t,this.fingerprint)}fetchTopicHTMLContent(t){return this.api.getTopicHTMLContent(this.mapId,t.contentId,"DESIGNED_READER",this.fingerprint)}fetchTopicMetadata(t){return this.api.getTopic(this.mapId,t.contentId,this.fingerprint)}fetchAttachments(){return this.api.getMapAttachments(this.mapId).catch((()=>[]))}fetchRelativesForDocument(t,i){return this.api.search({query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",filters:[{negative:!1,values:i,key:t}],sort:[],facets:[]})}fetchRelativesForTopicInMap(t,i,e){return this.api.search({query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",filters:[{negative:!1,values:e,key:i},{negative:!1,values:[t],key:"ft:publicationId"}],sort:[],facets:[]})}makeMapFeedbackRequest(t,i){return this.api.sendMapFeedback(this.mapId,t,i)}makeRateMapRequest(t,i){return this.api.rateMap(this.mapId,t,i)}makeRateTopicRequest(t,i,e){return this.api.rateTopic(this.mapId,t,i,e)}makeTopicFeedbackRequest(t,i,e){return this.api.sendTopicFeedback(this.mapId,t,i,e)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(t){return this.api.unrateTopic(this.mapId,t)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(t){return!0}}class q{static build(t,e){return new q((t=>i.FtReduxStore.get({name:"ft-reader-"+t,initialState:{mapId:void 0,visibleTopics:[],map:void 0,toc:void 0,pagesToc:void 0,paginationConfiguration:void 0,currentPage:void 0,scrollTarget:void 0,configuration:void 0,searchInDocumentQuery:void 0,relatives:void 0}}))(t.trim()||"context"),null!=e?e:K.build)}constructor(t,e,s){this.store=t,this.clusteringHelperProvider=s,this.metadataForSwitchToRelatives=new Set,this.loadDebouncer=new i.Debouncer(10),this.initService(e)}async initService(t){return this.service=await t(),this.service.mapId=this.store.getState().mapId,this.reload()}async setMapId(t){t!==this.store.getState().mapId&&(this.store.actions.mapId(t),this.service&&(this.service.mapId=t),await this.reload())}setVisibleTopics(t){this.store.actions.visibleTopics(t)}async awaitService(){return i.waitFor((()=>this.service))}async navigateToTopic(t,i,e){const s=await this.awaitService(),n=await(null!=e?s.getPage(e):s.getPageByTocId(null!=t?t:"root"));this.store.actions.currentPage(n),this.store.actions.scrollTarget({tocId:this.resolveValidNonRootTocId(t,n),section:i})}resolveValidNonRootTocId(t,i){var e,s,n;let r=null!==(e="root"===t?void 0:t)&&void 0!==e?e:i.rootTocId;return i.topics.includes(r)?r:null!==(n=null!==(s=i.topics[0])&&void 0!==s?s:i.hiddenTopics[0])&&void 0!==n?n:"root"}async navigateToPage(t){const i=await this.awaitService();let e=await i.getPage(t);this.store.actions.currentPage(e)}scrollDone(){this.store.actions.scrollTarget({})}async load(){var t;(null===(t=this.service)||void 0===t?void 0:t.mapId)&&null==this.store.getState().map&&await this.loadDebouncer.run((()=>this.fetchData()))}clear(){var t;this.store.actions.configuration(void 0),this.store.actions.map(void 0),this.store.actions.toc(void 0),this.store.actions.pagesToc(void 0),this.store.actions.currentPage(void 0),this.store.actions.searchInDocumentQuery(""),this.store.actions.relatives(void 0),null===(t=this.service)||void 0===t||t.clear(),this.clusteringHelper=void 0}reload(){return this.clear(),this.load()}async fetchData(){var t,e,s,n,r;try{await Promise.all([null===(t=this.service)||void 0===t?void 0:t.getConfiguration().then((t=>this.store.actions.configuration(t))),null===(e=this.service)||void 0===e?void 0:e.getMap().then((t=>this.store.actions.map(t))),null===(s=this.service)||void 0===s?void 0:s.getToc().then((t=>this.store.actions.toc(t))),null===(n=this.service)||void 0===n?void 0:n.getPagesToc().then((t=>this.store.actions.pagesToc(t))),null===(r=this.service)||void 0===r?void 0:r.getPaginationConfiguration().then((t=>this.store.actions.paginationConfiguration(t)))]).then((()=>{this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives()}))}catch(t){!this.errorHandler||t instanceof i.CanceledPromiseError||this.errorHandler(t)}}fetchRelatives(){var t,i,e;const s=null===(t=this.store.getState().map)||void 0===t?void 0:t.metadata.filter((t=>{var i;return t.key==(null===(i=this.store.getState().configuration)||void 0===i?void 0:i.relativePivotMetadata)})).flatMap((t=>t.values));void 0!==s&&s.length>0?null===(i=this.service)||void 0===i||i.getRelativesForDocument(null===(e=this.store.getState().configuration)||void 0===e?void 0:e.relativePivotMetadata,s).then((t=>{const i=t.results.flatMap((t=>t.entries));this.store.actions.relatives(i),this.updateClusteringHelper()})):this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.eventBus.dispatchEvent(new CustomEvent("clustering-helper-created"))}createClusteringHelper(){var t,e;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let s=this.store.getState().relatives;if(s){let n=s.find((t=>{var i;return(null===(i=t.map)||void 0===i?void 0:i.mapId)==this.store.getState().mapId})),r=null!==(e=null===(t=U.getState().metadataConfiguration)||void 0===t?void 0:t.descriptors)&&void 0!==e?e:[];return new i.ClusteringHelper(s,n,this.metadataForSwitchToRelatives,r)}}async navigateToRelativeTopicIfFound(t){var e,s,n;const r=await i.waitFor((()=>{var t;return null===(t=this.store.getState().configuration)||void 0===t?void 0:t.relativeTopicPivotMetadata})),o=this.store.getState().mapId,a=await this.awaitService(),h=await a.getRelativesForTopicInMap(o,r,[t]);if(null===(n=null===(s=null===(e=null==h?void 0:h.results)||void 0===e?void 0:e[0])||void 0===s?void 0:s.entries)||void 0===n?void 0:n[0]){const t=h.results[0].entries[0].topic.tocId;return await this.navigateToTopic(t),!0}return await this.navigateToTopic("root"),!1}setSearchInDocumentQuery(t){this.store.actions.searchInDocumentQuery(t)}registerMetadataForSwitchToRelatives(t){this.metadataForSwitchToRelatives.add(t),null==this.store.getState().relatives?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(t){this.metadataForSwitchToRelatives.delete(t),this.updateClusteringHelper()}}const V=e.css`
5
- `;class $ extends CustomEvent{constructor(t,i){super("ft-reader-map-loaded",{detail:{map:t,toc:i}})}}class Q extends CustomEvent{constructor(t,i){super("ft-reader-visible-topics-change",{detail:{visibleTopics:i}})}}class X extends CustomEvent{constructor(t){super("ft-reader-navigation-done",{detail:t})}}class Y extends CustomEvent{constructor(t){super("ft-reader-load-error",{detail:t})}}class W extends Event{constructor(){super("ft-reader-map-not-found")}}class z extends Event{constructor(){super("ft-reader-map-unauthorized")}}class J extends Event{constructor(){super("ft-reader-map-forbidden")}}class Z extends Event{constructor(){super("ft-reader-topic-relative-not-found",{bubbles:!0,composed:!0})}}var tt=function(t,i,e,s){for(var n,r=arguments.length,o=r<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(i,e,o):n(i,e))||o);return r>3&&o&&Object.defineProperty(i,e,o),o};class it extends i.FtLitElementRedux{constructor(){super(),this.visibleTopics=[],this.scrollToTargetDebouncer=new i.Debouncer(5),this.navigationDebouncer=new i.Debouncer(10),this.mapLoadedEventDebouncer=new i.Debouncer(50),this.addStore(U)}render(){return e.html`
4
+ `}update(e){super.update(e),e.has("baseUrl")&&(l.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),e.has("apiIntegrationIdentifier")&&l.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),e.has("uiLocale")&&l.actions.uiLocale(this.uiLocale),e.has("metadataConfiguration")&&l.actions.metadataConfiguration(this.metadataConfiguration),e.has("noCustom")&&l.actions.noCustom(this.noCustom),e.has("editorMode")&&l.actions.editorMode(this.editorMode),e.has("noCustomComponent")&&l.actions.noCustomComponent(this.noCustomComponent),e.has("session")&&l.actions.session(this.session),e.has("availableUiLocales")&&l.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),e.has("messageContexts")&&this.messageContexts!=null&&this.messageContexts.forEach(t=>Xe.addContext(t)),e.has("openExternalDocumentInNewTab")&&l.actions.openExternalDocumentInNewTab(this.openExternalDocumentInNewTab),e.has("navigatorOnline")&&l.actions.navigatorOnline(this.navigatorOnline),e.has("forcedOffline")&&l.actions.forcedOffline(this.forcedOffline),setTimeout(()=>this.updateIfNeeded())}async updateIfNeeded(){!this.withManualResources&&this.apiProvider()&&(this.session==null&&this.updateSession(),this.availableUiLocales==null&&this.updateUiLocales(),this.metadataConfiguration==null&&this.updateMetadataConfiguration())}async updateSession(){this.session=await this.cache.get("session",async()=>{let e=await this.apiProvider().getCurrentSession();return e.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run(()=>{this.cache.clear("session"),this.session=void 0},e.idleTimeoutInMillis),e})}async updateUiLocales(){this.availableUiLocales=await this.cache.get("availableUiLocales",()=>this.apiProvider().getAvailableUiLocales())}async updateMetadataConfiguration(){this.metadataConfiguration=await this.cache.get("metadataConfiguration",()=>this.apiProvider().getMetadataConfiguration())}};g.elementDefinitions={};g.styles=qe;b([(0,C.property)()],g.prototype,"baseUrl",void 0);b([(0,C.property)()],g.prototype,"apiIntegrationIdentifier",void 0);b([(0,C.property)()],g.prototype,"uiLocale",void 0);b([(0,x.jsonProperty)(null)],g.prototype,"availableUiLocales",void 0);b([(0,x.jsonProperty)(null)],g.prototype,"metadataConfiguration",void 0);b([(0,C.property)({type:Boolean})],g.prototype,"editorMode",void 0);b([(0,C.property)({type:Boolean})],g.prototype,"noCustom",void 0);b([(0,C.property)({type:Boolean})],g.prototype,"openExternalDocumentInNewTab",void 0);b([(0,C.property)({converter:{fromAttribute(r){return r==="false"?!1:r==="true"||(r??!1)}}})],g.prototype,"noCustomComponent",void 0);b([(0,C.property)({type:Boolean})],g.prototype,"withManualResources",void 0);b([(0,C.property)({type:Boolean})],g.prototype,"navigatorOnline",void 0);b([(0,C.property)({type:Boolean})],g.prototype,"forcedOffline",void 0);b([(0,C.property)({type:Object})],g.prototype,"apiProvider",void 0);b([(0,x.jsonProperty)([])],g.prototype,"messageContexts",void 0);b([(0,x.jsonProperty)(void 0)],g.prototype,"session",void 0);var Q=v(R());var W=class extends _{async listMySearches(){let e=l.getState().session;return e?.sessionAuthenticated?this.cache.get("my-searches",async()=>(await this.awaitApi).listMySearches(e.profile.userId),5*60*1e3):[]}};var X=class extends _{async listMyBookmarks(){let e=l.getState().session;return e?.sessionAuthenticated?this.cache.get("my-bookmarks",async()=>(await this.awaitApi).listMyBookmarks(e.profile.userId),5*60*1e3):[]}};var Tt="ft-user-assets",Y=Q.FtReduxStore.get({name:Tt,initialState:{savedSearches:void 0,bookmarks:void 0}}),fe=class{constructor(){this.currentSession=l.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new X,this.savedSearchesService=new W,l.subscribe(()=>this.reloadWhenUserSessionChanges())}reloadWhenUserSessionChanges(){var e;let{session:t}=l.getState();(0,Q.deepEqual)((e=this.currentSession)===null||e===void 0?void 0:e.profile,t?.profile)||(this.currentSession=t,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),Y.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),Y.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();let e=await this.savedSearchesService.listMySearches();Y.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var e;if(this.bookmarksAreUsed){let t=!((e=this.currentSession)===null||e===void 0)&&e.sessionAuthenticated?await this.bookmarksService.listMyBookmarks():void 0;Y.actions.bookmarks(t)}}},Qe=new fe;var me=class{addCommand(e,t=!1){l.commands.add(e,t)}consumeCommand(e){return l.commands.consume(e)}};window.FluidTopicsAppInfoStoreService=new me;var Je=v(R()),ge=class{highlightHtml(e,t){(0,Je.highlightHtml)(e,t)}};window.FluidTopicsHighlightHtmlService=new ge;(0,Ze.customElement)("ft-app-context")(g);var J=class extends _{get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,t,i){super(!1,t),this.converter=e,this._mapId=i,this.initCache()}async withMapId(e){return this._mapId?e(this._mapId):void 0}initCache(){this.cache.registerFinal("configuration",()=>this.api.getReaderConfiguration()),this.cache.register("map",()=>this.withMapId(e=>this.fetchMap(e))),this.cache.register("enrichedToc",()=>this.withMapId(e=>this.fetchPages(e).then(t=>this.converter.convertPaginatedToc(t)))),this.cache.register("ratingSummary",()=>{var e,t;return N((t=(e=l.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&t!==void 0?t:[],"RATING_USER")?this.withMapId(s=>this.fetchMapRating(s)):Promise.resolve()})}clear(){this.cache.clearAll()}getMap(){return this.cache.get("map")}getMapNow(){return this.cache.getNow("map")}getConfiguration(){return this.cache.get("configuration")}getEnrichedToc(){return this.cache.get("enrichedToc")}get enrichedToc(){return this.cache.getNow("enrichedToc")}async getPaginationConfiguration(){return(await this.getEnrichedToc()).paginationConfiguration}async getToc(){return(await this.getEnrichedToc()).toc}async getPagesToc(){return(await this.getEnrichedToc()).pagesToc}async getTocNode(e){return(await this.getEnrichedToc()).nodeByTocId[e]}getTocNodeNow(e){var t;return(t=this.enrichedToc)===null||t===void 0?void 0:t.nodeByTocId[e]}async getPage(e){let t=await this.getEnrichedToc();return t.pages[e-1]||t.pages[0]}async getPageByTocId(e){let t=await this.getEnrichedToc();return t.pageByTocId[e]||t.pages[0]}getTopicInfo(e){return this.cache.get("topic-"+e.tocId,()=>this.fetchTopicMetadata(e))}getTopicContent(e){return this.cache.get("topic-content-"+e.tocId,()=>this.fetchTopicHTMLContent(e))}getAttachments(){return this.cache.get("map-attachments",()=>this.fetchAttachments())}getRelativesForDocument(e,t){return this.cache.get("document-relatives-"+e+"-"+t.join("-"),()=>this.fetchRelativesForDocument(e,t))}getRelativesForTopicInMap(e,t,i){return this.cache.get("topic-relatives-"+[e,t,...i].join("-"),()=>this.fetchRelativesForTopicInMap(e,t,i))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true`)}getLink(e,t,i){let s=this.getNavigationData(e,t,i),o=this.getReaderLinkPrefix()+(s.prettyUrl?s.prettyUrl:`${s.mapId}/${s.tocId}`),c=new URL(o,this.api.tenantBaseUrl);return s.page!=null&&c.searchParams.set("page",`${s.page}`),s.prettyUrlDuplicated&&c.searchParams.set("tocId",s.tocId),s.section!=null&&c.searchParams.set("section",s.section),c.href}getNavigationData(e,t,i){var s,o;e=e||"root";let c=this.enrichedToc,d=c?.pageByTocId[e],y=c?.nodeByTocId[e],p=y?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(s=y?.title)!==null&&s!==void 0?s:"",page:t&&d&&d.number!==t?t:void 0,prettyUrl:p?.replace(/^r\//,""),prettyUrlDuplicated:(o=c?.duplicatedPrettyUrls.has(p??""))!==null&&o!==void 0?o:!1,section:i}}async getAccurateNavigationData(e,t,i){return await this.getEnrichedToc(),this.getNavigationData(e,t,i)}getRatingSummary(){return this.cache.get("ratingSummary")}reloadRating(){return this.cache.clear("ratingSummary"),this.getRatingSummary()}getMapRating(){return this.getRatingSummary().then(e=>e?.publication)}getTopicRating(e){return this.getRatingSummary().then(t=>{var i;return t?{type:t.topics.type,rating:(i=t.topics)===null||i===void 0?void 0:i.ratings.find(s=>s.tocId===e)}:void 0})}rateMap(e,t){return this.makeRateMapRequest(e,t).then(()=>this.clearRatingIfNecessary())}unrateMap(){return this.makeUnrateMapRequest().then(()=>this.clearRatingIfNecessary())}sendMapFeedback(e,t){return this.makeMapFeedbackRequest(e,t)}rateTopic(e,t,i){return this.makeRateTopicRequest(e,t,i).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=l.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,t,i){return this.makeTopicFeedbackRequest(e,t,i)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e){let t=this.getTocNodeNow(e),i=[{tocId:t.tocId,title:t.title}],s=this.getTocNodeNow(t.parentTocId);for(;s;)i.unshift({tocId:s.tocId,title:s.title}),s=this.getTocNodeNow(s.parentTocId);return i}isFeatureAccessible(e,{session:t,ratingType:i}){var s;if(!this.isFeatureAvailable(e))return!1;switch(e){case O.FEEDBACK:return N(t??[],m.FEEDBACK_USER);case O.RATING:return N(t??[],m.RATING_USER)&&i!=null&&i!==q.NO_RATING;case O.PRINT:return N(t??[],m.PRINT_USER);case O.BOOKMARK:return!!t?.sessionAuthenticated;case O.COLLECTIONS:return N(t??[],m.COLLECTION_USER);case O.PERSONAL_BOOKS:return N(t??[],m.PERSONAL_BOOK_USER)&&!(!((s=this.getMapNow())===null||s===void 0)&&s.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var Z=class r extends J{static async build(e){return new r(new j,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e){let t=await this.api.getMap(e);return this.fingerprint=t.fingerprint,t}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e){return await this.getMap(),this.api.getPages(e,this.fingerprint)}fetchTopicHTMLContent(e){return this.api.getTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint)}fetchTopicMetadata(e){return this.api.getTopic(this.mapId,e.contentId,this.fingerprint)}fetchAttachments(){return this.api.getMapAttachments(this.mapId).catch(()=>[])}fetchRelativesForDocument(e,t){return this.api.search({query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",filters:[{negative:!1,values:t,key:e}],sort:[],facets:[]})}fetchRelativesForTopicInMap(e,t,i){return this.api.search({query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",filters:[{negative:!1,values:i,key:t},{negative:!1,values:[e],key:"ft:publicationId"}],sort:[],facets:[]})}makeMapFeedbackRequest(e,t){return this.api.sendMapFeedback(this.mapId,e,t)}makeRateMapRequest(e,t){return this.api.rateMap(this.mapId,e,t)}makeRateTopicRequest(e,t,i){return this.api.rateTopic(this.mapId,e,t,i)}makeTopicFeedbackRequest(e,t,i){return this.api.sendTopicFeedback(this.mapId,e,t,i)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var ee=class r{static build(e,t){return new r(Ie(e.trim()||"context"),t??Z.build)}constructor(e,t,i){this.store=e,this.clusteringHelperProvider=i,this.metadataForSwitchToRelatives=new Set,this.loadDebouncer=new U.Debouncer(10),this.initService(t)}async initService(e){return this.service=await e(),this.service.mapId=this.store.getState().mapId,this.reload()}async setMapId(e){e!==this.store.getState().mapId&&(this.store.actions.mapId(e),this.service&&(this.service.mapId=e),await this.reload())}setVisibleTopics(e){this.store.actions.visibleTopics(e)}async awaitService(){return(0,U.waitFor)(()=>this.service)}async navigateToTopic(e,t,i){let s=await this.awaitService(),o=await(i!=null?s.getPage(i):s.getPageByTocId(e??"root"));this.store.actions.currentPage(o),this.store.actions.scrollTarget({tocId:this.resolveValidNonRootTocId(e,o),section:t})}resolveValidNonRootTocId(e,t){var i,s,o;let c=(i=e==="root"?void 0:e)!==null&&i!==void 0?i:t.rootTocId;return t.topics.includes(c)?c:(o=(s=t.topics[0])!==null&&s!==void 0?s:t.hiddenTopics[0])!==null&&o!==void 0?o:"root"}async navigateToPage(e){let i=await(await this.awaitService()).getPage(e);this.store.actions.currentPage(i)}scrollDone(){this.store.actions.scrollTarget({})}async load(){var e;!((e=this.service)===null||e===void 0)&&e.mapId&&this.store.getState().map==null&&await this.loadDebouncer.run(()=>this.fetchData())}clear(){var e;this.store.actions.configuration(void 0),this.store.actions.map(void 0),this.store.actions.toc(void 0),this.store.actions.pagesToc(void 0),this.store.actions.currentPage(void 0),this.store.actions.searchInDocumentQuery(""),this.store.actions.relatives(void 0),(e=this.service)===null||e===void 0||e.clear(),this.clusteringHelper=void 0}reload(){return this.clear(),this.load()}async fetchData(){var e,t,i,s,o;try{await Promise.all([(e=this.service)===null||e===void 0?void 0:e.getConfiguration().then(c=>this.store.actions.configuration(c)),(t=this.service)===null||t===void 0?void 0:t.getMap().then(c=>this.store.actions.map(c)),(i=this.service)===null||i===void 0?void 0:i.getToc().then(c=>this.store.actions.toc(c)),(s=this.service)===null||s===void 0?void 0:s.getPagesToc().then(c=>this.store.actions.pagesToc(c)),(o=this.service)===null||o===void 0?void 0:o.getPaginationConfiguration().then(c=>this.store.actions.paginationConfiguration(c))]).then(()=>{this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives()})}catch(c){this.errorHandler&&!(c instanceof U.CanceledPromiseError)&&this.errorHandler(c)}}fetchRelatives(){var e,t,i;let s=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(o=>{var c;return o.key==((c=this.store.getState().configuration)===null||c===void 0?void 0:c.relativePivotMetadata)}).flatMap(o=>o.values);s!==void 0&&s.length>0?(t=this.service)===null||t===void 0||t.getRelativesForDocument((i=this.store.getState().configuration)===null||i===void 0?void 0:i.relativePivotMetadata,s).then(o=>{let c=o.results.flatMap(d=>d.entries);this.store.actions.relatives(c),this.updateClusteringHelper()}):this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.eventBus.dispatchEvent(new CustomEvent("clustering-helper-created"))}createClusteringHelper(){var e,t;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let i=this.store.getState().relatives;if(i){let s=i.find(c=>{var d;return((d=c.map)===null||d===void 0?void 0:d.mapId)==this.store.getState().mapId}),o=(t=(e=l.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&t!==void 0?t:[];return new U.ClusteringHelper(i,s,this.metadataForSwitchToRelatives,o)}}async navigateToRelativeTopicIfFound(e){var t,i,s;let o=await(0,U.waitFor)(()=>{var p;return(p=this.store.getState().configuration)===null||p===void 0?void 0:p.relativeTopicPivotMetadata}),c=this.store.getState().mapId,y=await(await this.awaitService()).getRelativesForTopicInMap(c,o,[e]);if(!((s=(i=(t=y?.results)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.entries)===null||s===void 0)&&s[0]){let p=y.results[0].entries[0].topic.tocId;return await this.navigateToTopic(p),!0}else return await this.navigateToTopic("root"),!1}setSearchInDocumentQuery(e){this.store.actions.searchInDocumentQuery(e)}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}};var et=v(V()),zr={},tt=et.css`
5
+ `;var te=class extends CustomEvent{constructor(e,t){super("ft-reader-map-loaded",{detail:{map:e,toc:t}})}},re=class extends CustomEvent{constructor(e,t){super("ft-reader-visible-topics-change",{detail:{visibleTopics:t}})}},ie=class extends CustomEvent{constructor(e){super("ft-reader-navigation-done",{detail:e})}},se=class extends CustomEvent{constructor(e){super("ft-reader-load-error",{detail:e})}},ae=class extends Event{constructor(){super("ft-reader-map-not-found")}},ne=class extends Event{constructor(){super("ft-reader-map-unauthorized")}},oe=class extends Event{constructor(){super("ft-reader-map-forbidden")}},ce=class extends Event{constructor(){super("ft-reader-topic-relative-not-found",{bubbles:!0,composed:!0})}};var I=function(r,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,i);else for(var d=r.length-1;d>=0;d--)(c=r[d])&&(o=(s<3?c(o):s>3?c(e,t,o):c(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o},St=r=>e=>+(e??"NaN")>0?+e:r,A=class extends E.FtLitElementRedux{constructor(){super(),this.visibleTopics=[],this.scrollToTargetDebouncer=new E.Debouncer(5),this.navigationDebouncer=new E.Debouncer(10),this.mapLoadedEventDebouncer=new E.Debouncer(50),this.addStore(l)}render(){return K.html`
6
6
  ${this.importStyleIfNeeded()}
7
7
  <slot @register-ft-reader-component=${this.registerComponent}></slot>
8
- `}importStyleIfNeeded(){var t,i;const s=null===(t=this.stateManager.service)||void 0===t?void 0:t.themeStylesheet();return!s||window.location.href.startsWith(null!==(i=this.baseUrl)&&void 0!==i?i:"")?e.nothing:e.html`
8
+ `}importStyleIfNeeded(){var e,t;let i=(e=this.stateManager.service)===null||e===void 0?void 0:e.themeStylesheet();return!i||window.location.href.startsWith((t=this.baseUrl)!==null&&t!==void 0?t:"")?K.nothing:K.html`
9
9
  <style>
10
- @import "${s}"
10
+ @import "${i}"
11
11
  </style>
12
- `}get stateManager(){return null==this._stateManager&&(this._stateManager=q.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0"),this.readerServiceProvider),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store,"reader")),this._stateManager}connectedCallback(){super.connectedCallback(),this.stateManager.setMapId(this.mapId),this.stateManager.awaitService().then((t=>{const i=t.fontsStylesheet();if(i&&!window.location.href.startsWith(this.baseUrl)&&!document.querySelector(`head link[href="${i}"]`)){const t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("href",i),document.head.append(t)}}))}update(t){super.update(t),t.has("readerServiceProvider")&&this.readerServiceProvider&&this.stateManager.initService(this.readerServiceProvider),t.has("mapId")&&this.mapId&&(this.stateManager.setMapId(this.mapId),this.lastNotifiedNotFoundRelative=void 0),t.has("searchInDocumentQuery")&&null!=this.searchInDocumentQuery&&this.stateManager.setSearchInDocumentQuery(this.searchInDocumentQuery),["tocId","section","page","mapId","topicPivot"].some((i=>t.has(i)))&&this.mapId&&this.navigateToTarget()}contentAvailableCallback(t){var i;if(super.contentAvailableCallback(t),(t.has("map")||t.has("toc"))&&this.sendLoadedEventIfLoaded(),t.has("scrollTarget")&&null==(null===(i=this.scrollTarget)||void 0===i?void 0:i.tocId)){const i=t.get("scrollTarget");null!=(null==i?void 0:i.tocId)&&this.scrollToTargetDebouncer.run((()=>{var t;return this.stateManager.service.getAccurateNavigationData(i.tocId,null===(t=this.currentPage)||void 0===t?void 0:t.number,i.section).then((t=>this.dispatchEvent(new X(t))))}))}t.has("visibleTopics")&&Promise.all(this.visibleTopics.map((t=>{var i;return this.stateManager.service.getAccurateNavigationData(t,null===(i=this.currentPage)||void 0===i?void 0:i.number)}))).then((t=>{let i=t.filter((t=>null!=t&&""!==t.topicTitle)).map((t=>{var i;return{tocId:t.tocId,title:t.topicTitle,page:t.page,prettyUrl:t.prettyUrl,prettyUrlDuplicated:t.prettyUrlDuplicated,breadcrumb:null===(i=this.stateManager.service)||void 0===i?void 0:i.buildBreadcrumb(t.tocId)}}));this.dispatchEvent(new Q(this.map,i))}))}clear(){this.stateManager.clear()}async reload(){this.clear(),await this.navigateToTarget()}async navigateToTarget(){await this.stateManager.load(),await this.navigationDebouncer.run((async()=>{if(null!=this.topicPivot){await this.stateManager.navigateToRelativeTopicIfFound(this.topicPivot)||this.lastNotifiedNotFoundRelative===this.mapId+this.topicPivot?this.lastNotifiedNotFoundRelative=void 0:(this.dispatchEvent(new Z),this.lastNotifiedNotFoundRelative=this.mapId+this.topicPivot)}else null!=this.tocId?await this.stateManager.navigateToTopic(this.tocId,this.section,this.page):null!=this.page&&await this.stateManager.navigateToPage(this.page)}))}registerComponent(t){t.stopPropagation();const i=t.composedPath()[0];this.register(i)}register(t){t.setReaderStateManager(this.stateManager)}handleLoadError(t){const i=t;401===i.status?this.dispatchEvent(new z):403===i.status?this.dispatchEvent(new J):404===i.status?this.dispatchEvent(new W):this.dispatchEvent(new Y(t))}reloadBookmarks(){j.reloadBookmarks()}async reloadRating(){var t,i;await(null===(t=this.stateManager.service)||void 0===t?void 0:t.reloadRating()),null===(i=this.stateManager.store)||void 0===i||i.eventBus.dispatchEvent(new CustomEvent("rating-changed"))}sendLoadedEventIfLoaded(){this.mapLoadedEventDebouncer.run((()=>{this.map&&this.toc&&this.dispatchEvent(new $(this.map,this.toc))}))}}var et;it.styles=V,tt([i.redux({store:U.name})],it.prototype,"baseUrl",void 0),tt([s.property()],it.prototype,"mapId",void 0),tt([s.property()],it.prototype,"tocId",void 0),tt([s.property()],it.prototype,"section",void 0),tt([s.property()],it.prototype,"topicPivot",void 0),tt([s.property()],it.prototype,"searchInDocumentQuery",void 0),tt([s.property({type:Number,converter:{fromAttribute:t=>+(null!=t?t:"NaN")>0?+t:et}})],it.prototype,"page",void 0),tt([i.redux({store:"reader"})],it.prototype,"map",void 0),tt([i.redux({store:"reader"})],it.prototype,"toc",void 0),tt([i.redux({store:"reader"})],it.prototype,"visibleTopics",void 0),tt([i.redux({store:"reader"})],it.prototype,"currentPage",void 0),tt([i.redux({store:"reader"})],it.prototype,"scrollTarget",void 0),tt([s.property({attribute:!1})],it.prototype,"readerServiceProvider",void 0),i.customElement("ft-reader-context")(it),t.ForbiddenErrorEvent=J,t.FtOfficialReaderService=K,t.FtReaderContext=it,t.FtReaderContextCssVariables={},t.FtReaderConverter=r,t.FtReaderService=G,t.LoadErrorEvent=Y,t.MapLoadedEvent=$,t.NavigationDoneEvent=X,t.NotFoundErrorEvent=W,t.TopicRelativeNotFoundEvent=Z,t.UnauthorizedErrorEvent=z,t.VisibleTopicsChangeEvent=Q,t.styles=V}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators);
12
+ `}get stateManager(){return this._stateManager==null&&(this._stateManager=ee.build(this.id||(""+Math.round(Math.random()*999e3)).padStart(6,"0"),this.readerServiceProvider),this._stateManager.errorHandler=e=>this.handleLoadError(e),this.addStore(this.stateManager.store,"reader")),this._stateManager}connectedCallback(){super.connectedCallback(),this.stateManager.setMapId(this.mapId),this.stateManager.awaitService().then(e=>{let t=e.fontsStylesheet();if(t&&!window.location.href.startsWith(this.baseUrl)&&!document.querySelector(`head link[href="${t}"]`)){let i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("href",t),document.head.append(i)}})}update(e){super.update(e),e.has("readerServiceProvider")&&this.readerServiceProvider&&this.stateManager.initService(this.readerServiceProvider),e.has("mapId")&&this.mapId&&(this.stateManager.setMapId(this.mapId),this.lastNotifiedNotFoundRelative=void 0),e.has("searchInDocumentQuery")&&this.searchInDocumentQuery!=null&&this.stateManager.setSearchInDocumentQuery(this.searchInDocumentQuery),["tocId","section","page","mapId","topicPivot"].some(t=>e.has(t))&&this.mapId&&this.navigateToTarget()}contentAvailableCallback(e){var t;if(super.contentAvailableCallback(e),(e.has("map")||e.has("toc"))&&this.sendLoadedEventIfLoaded(),e.has("scrollTarget")&&((t=this.scrollTarget)===null||t===void 0?void 0:t.tocId)==null){let i=e.get("scrollTarget");i?.tocId!=null&&this.scrollToTargetDebouncer.run(()=>{var s;return this.stateManager.service.getAccurateNavigationData(i.tocId,(s=this.currentPage)===null||s===void 0?void 0:s.number,i.section).then(o=>this.dispatchEvent(new ie(o)))})}e.has("visibleTopics")&&Promise.all(this.visibleTopics.map(i=>{var s;return this.stateManager.service.getAccurateNavigationData(i,(s=this.currentPage)===null||s===void 0?void 0:s.number)})).then(i=>{let s=i.filter(o=>o!=null&&o.topicTitle!=="").map(o=>{var c;return{tocId:o.tocId,title:o.topicTitle,page:o.page,prettyUrl:o.prettyUrl,prettyUrlDuplicated:o.prettyUrlDuplicated,breadcrumb:(c=this.stateManager.service)===null||c===void 0?void 0:c.buildBreadcrumb(o.tocId)}});this.dispatchEvent(new re(this.map,s))})}clear(){this.stateManager.clear()}async reload(){this.clear(),await this.navigateToTarget()}async navigateToTarget(){await this.stateManager.load(),await this.navigationDebouncer.run(async()=>{this.topicPivot!=null?!await this.stateManager.navigateToRelativeTopicIfFound(this.topicPivot)&&this.lastNotifiedNotFoundRelative!==this.mapId+this.topicPivot?(this.dispatchEvent(new ce),this.lastNotifiedNotFoundRelative=this.mapId+this.topicPivot):this.lastNotifiedNotFoundRelative=void 0:this.tocId!=null?await this.stateManager.navigateToTopic(this.tocId,this.section,this.page):this.page!=null&&await this.stateManager.navigateToPage(this.page)})}registerComponent(e){e.stopPropagation();let t=e.composedPath()[0];this.register(t)}register(e){e.setReaderStateManager(this.stateManager)}handleLoadError(e){let t=e;t.status===401?this.dispatchEvent(new ne):t.status===403?this.dispatchEvent(new oe):t.status===404?this.dispatchEvent(new ae):this.dispatchEvent(new se(e))}reloadBookmarks(){Qe.reloadBookmarks()}async reloadRating(){var e,t;await((e=this.stateManager.service)===null||e===void 0?void 0:e.reloadRating()),(t=this.stateManager.store)===null||t===void 0||t.eventBus.dispatchEvent(new CustomEvent("rating-changed"))}sendLoadedEventIfLoaded(){this.mapLoadedEventDebouncer.run(()=>{this.map&&this.toc&&this.dispatchEvent(new te(this.map,this.toc))})}};A.styles=tt;I([(0,E.redux)({store:l.name})],A.prototype,"baseUrl",void 0);I([(0,k.property)()],A.prototype,"mapId",void 0);I([(0,k.property)()],A.prototype,"tocId",void 0);I([(0,k.property)()],A.prototype,"section",void 0);I([(0,k.property)()],A.prototype,"topicPivot",void 0);I([(0,k.property)()],A.prototype,"searchInDocumentQuery",void 0);I([(0,k.property)({type:Number,converter:{fromAttribute:St()}})],A.prototype,"page",void 0);I([(0,E.redux)({store:"reader"})],A.prototype,"map",void 0);I([(0,E.redux)({store:"reader"})],A.prototype,"toc",void 0);I([(0,E.redux)({store:"reader"})],A.prototype,"visibleTopics",void 0);I([(0,E.redux)({store:"reader"})],A.prototype,"currentPage",void 0);I([(0,E.redux)({store:"reader"})],A.prototype,"scrollTarget",void 0);I([(0,k.property)({attribute:!1})],A.prototype,"readerServiceProvider",void 0);(0,rt.customElement)("ft-reader-context")(A);})();