@fluid-topics/ft-reader-context 0.3.55 → 0.3.57

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,9 +1,9 @@
1
- !function(t,i,s,e){const n={setBaseUrl:(t,i)=>{t.baseUrl=i.payload},setApiIntegrationIdentifier:(t,i)=>{t.apiIntegrationIdentifier=i.payload},setMapId:(t,i)=>{t.mapId=i.payload},setTocId:(t,i)=>{t.tocId=i.payload},setMap:(t,i)=>{t.map=i.payload},setToc:(t,i)=>{t.toc=i.payload},setPagesToc:(t,i)=>{t.pagesToc=i.payload},setPaginationConfiguration:(t,i)=>{t.paginationConfiguration=i.payload},setCurrentPage:(t,i)=>{t.currentPage=i.payload},setScrollTarget:(t,i)=>{t.scrollTarget=i.payload},setVisibleTopics:(t,i)=>{t.visibleTopics=i.payload},setLabels:(t,i)=>{t.labels=i.payload},setConfiguration:(t,i)=>{t.configuration=i.payload}},r={topicMissingAdvice:"Sorry, this topic is missing",somethingWentWrong:"Oops, something went wrong"};class o{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,s){return t.flatMap((t=>(t.pageConfiguration&&this.registerPage(this.buildPage(t,s)),null==t.tocId?this.extractPagesToc(t.children,i,s):[{tocId:t.tocId,title:t.title,depth:i,children:this.extractPagesToc(t.children,i+1,t.tocId)}])))}convertNodes(t,i,s){return t.flatMap((t=>{var e,n,r;if(null==t.tocId)return[...this.convertSectionNodes(null!==(e=t.pageToc)&&void 0!==e?e:[],i,t.tocId),...this.convertNodes(t.children,i,t.tocId)];let o=null===(n=t.prettyUrl)||void 0===n?void 0:n.replace(/^\//,"");const h={tocId:t.tocId,contentId:t.contentId,title:t.title,prettyUrl:o,depth:i,parentTocId:s,children:[]};this.register(h);const a=this.convertSectionNodes(null!==(r=t.pageToc)&&void 0!==r?r:[],i+1,t.tocId),l=this.convertNodes(t.children,i+1,h.tocId);return h.children=[...a,...l],[h]}))}convertSectionNodes(t,i,s){return t.flatMap((t=>{var e;let n=null===(e=t.prettyUrl)||void 0===e?void 0:e.replace(/^\//,"");const r={tocId:t.tocId,contentId:t.contentId,title:t.title,prettyUrl:n,depth:i,parentTocId:s,children:[]};return this.register(r),r.children=this.convertSectionNodes(t.children,i+1,t.tocId),[r]}))}buildPage(t,i){var s,e,n,r,o,h;const a={number:this.pages.length+1,title:null!==(s=t.title)&&void 0!==s?s:"",rootTocId:null!==(e=t.tocId)&&void 0!==e?e:"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]):[]},l=(t,i)=>(i?a.topics:a.hiddenTopics).push(t),d=null!==(o=null===(r=t.pageConfiguration)||void 0===r?void 0:r.parentsVisibility)&&void 0!==o?o:[];return a.breadcrumb.forEach(((t,i)=>{l(t,d[i])})),t.tocId&&l(t.tocId,t.pageConfiguration.isVisible),a.topics.push(...this.tocIds(null!==(h=t.pageToc)&&void 0!==h?h:[])),a}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 h{convertPaginatedToc(t){return new o(t).build()}}class a{constructor(t,s,e,n,o,h){this.converter=t,this.api=s,this.cache=e,this.baseUrl=n,this.cleanSessionDebouncer=new i.Debouncer,this.labelResolver=new i.ParametrizedLabelResolver(r,{}),n.endsWith("/")||(this.baseUrl=n+"/"),this.mapId=o,this.labels=null!=h?h:{},this.initCache()}static build(t,s,e,n){if(null==window.fluidtopics)throw console.error("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api"),new Error("Fluid Topics public API not found");const r=new window.fluidtopics.FluidTopicsApi(t,s,!0);return new a(new h,r,new i.CacheRegistry,t,e,n)}get mapId(){return this._mapId}set mapId(t){t!==this._mapId&&this.clear(),this._mapId=t}initCache(){this.cache.registerFinal("configuration",(()=>this.api.getReaderConfiguration())),this.cache.register("map",(()=>this.api.getMap(this.mapId))),this.cache.register("enrichedToc",(()=>this.api.getPages(this.mapId).then((t=>this.converter.convertPaginatedToc(t))))),this.cache.register("session",(async()=>{const t=await this.api.getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>this.cache.clear("session")),t.idleTimeoutInMillis),t})),this.cache.register("ratingSummary",(()=>this.api.getMapRating(this.mapId)))}clear(){this.cache.clearAll(),this.cleanSessionDebouncer.cancel()}getMap(){return this.cache.get("map")}getConfiguration(){return this.cache.get("configuration")}getSession(){return this.cache.get("session")}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,(()=>this.api.getTopic(this.mapId,t)))}getTopicContent(t){return this.cache.get("topic-content-"+t,(()=>this.api.getTopicHTMLContent(this.mapId,t,"DESIGNED_READER")))}getLink(t,i,s){const e=this.getNavigationData(t,i,s),n="r/"+(e.prettyUrl?e.prettyUrl:`${e.mapId}/${e.tocId}`),r=new URL(n,this.baseUrl);return null!=e.page&&r.searchParams.set("page",`${e.page}`),e.prettyUrlDuplicated&&r.searchParams.set("tocId",e.tocId),null!=e.section&&r.searchParams.set("section",e.section),r.href}getNavigationData(t,i,s){var e,n;t=t||"root";const r=this.enrichedToc,o=null==r?void 0:r.pageByTocId[t],h=null==r?void 0:r.nodeByTocId[t],a=null==h?void 0:h.prettyUrl;return{mapId:this.mapId,tocId:t,topicTitle:null!==(e=null==h?void 0:h.title)&&void 0!==e?e:"",page:i&&o&&o.number!==i?i:void 0,prettyUrl:null!=a?a.replace(/^r\//,""):void 0,prettyUrlDuplicated:null!==(n=null==r?void 0:r.duplicatedPrettyUrls.has(null!=a?a:""))&&void 0!==n&&n,section:s}}async getAccurateNavigationData(t,i,s){return await this.getEnrichedToc(),this.getNavigationData(t,i,s)}set labels(t){this.labelResolver=new i.ParametrizedLabelResolver(r,t)}resolveLabel(t,...i){return this.labelResolver.resolve(t,i)}getRatingSummary(){return this.cache.get("ratingSummary")}getMapRating(){return this.getRatingSummary().then((t=>t.publication))}getTopicRating(t){return this.getRatingSummary().then((i=>{var s;return{type:i.topics.type,rating:null===(s=i.topics)||void 0===s?void 0:s.ratings.find((i=>i.tocId===t))}}))}rateMap(t,i){return this.api.rateMap(this.mapId,t,i).then((()=>this.cache.clear("ratingSummary")))}unrateMap(){return this.api.unrateMap(this.mapId).then((()=>this.cache.clear("ratingSummary")))}sendMapFeedback(t){return this.api.sendMapFeedback(this.mapId,t)}rateTopic(t,i,s){return this.api.rateTopic(this.mapId,t,i,s).then((()=>this.cache.clear("ratingSummary")))}unrateTopic(t){return this.api.unrateTopic(this.mapId,t).then((()=>this.cache.clear("ratingSummary")))}sendTopicFeedback(t,i){return this.api.sendTopicFeedback(this.mapId,t,i)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}}class l{constructor(t){this.store=t,this.reloadDebouncer=new i.Debouncer(10)}static build(t){return new l((t=>i.FtReduxStore.get({name:"ft-reader-"+t,initialState:{baseUrl:void 0,apiIntegrationIdentifier:"ft-reader",mapId:void 0,visibleTopics:[],labels:{}},reducers:n}))(t.trim()||"context"))}setBaseUrl(t){this.store.actions.setBaseUrl(t),this.initService()}setApiIntegrationIdentifier(t){this.store.actions.setApiIntegrationIdentifier(t),this.initService()}initService(){const t=this.store.getState();t.baseUrl&&t.apiIntegrationIdentifier?this.service=a.build(t.baseUrl,t.apiIntegrationIdentifier,t.mapId,t.labels):this.service=void 0,this.reload()}setMapId(t){this.store.actions.setMapId(t),this.service&&(this.service.mapId=t),this.reload()}setVisibleTopics(t){this.store.actions.setVisibleTopics(t)}setLabels(t){this.store.actions.setLabels(t),this.service&&(this.service.labels=t)}async awaitService(){for(;null==this.service;)await i.delay(5);return this.service}async navigateToTopic(t,i,s){const e=await this.awaitService();let n=await(null!=s?e.getPage(s):e.getPageByTocId(t));this.store.actions.setCurrentPage(n),this.store.actions.setScrollTarget({tocId:t,section:i})}async navigateToPage(t){const i=await this.awaitService();let s=await i.getPage(t);this.store.actions.setCurrentPage(s)}scrollDone(){this.store.actions.setScrollTarget({})}async reload(){var t,i;null===(t=this.service)||void 0===t||t.clear(),this.store.actions.setConfiguration(void 0),this.store.actions.setMap(void 0),this.store.actions.setToc(void 0),this.store.actions.setPagesToc(void 0),this.store.actions.setCurrentPage(void 0),(null===(i=this.service)||void 0===i?void 0:i.mapId)&&await this.reloadDebouncer.run((()=>this.fetchData()))}async fetchData(){var t,i,s,e,n;try{await Promise.all([null===(t=this.service)||void 0===t?void 0:t.getConfiguration().then((t=>this.store.actions.setConfiguration(t))),null===(i=this.service)||void 0===i?void 0:i.getMap().then((t=>this.store.actions.setMap(t))),null===(s=this.service)||void 0===s?void 0:s.getToc().then((t=>this.store.actions.setToc(t))),null===(e=this.service)||void 0===e?void 0:e.getPagesToc().then((t=>this.store.actions.setPagesToc(t))),null===(n=this.service)||void 0===n?void 0:n.getPaginationConfiguration().then((t=>this.store.actions.setPaginationConfiguration(t)))])}catch(t){this.errorHandler&&this.errorHandler(t)}}}const d=s.css`
2
- `;var c=function(t,i,s,e){for(var n,r=arguments.length,o=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,h=t.length-1;h>=0;h--)(n=t[h])&&(o=(r<3?n(o):r>3?n(i,s,o):n(i,s))||o);return r>3&&o&&Object.defineProperty(i,s,o),o};class u extends CustomEvent{constructor(t,i){super("ft-reader-map-loaded",{detail:{map:t,toc:i}})}}class v extends CustomEvent{constructor(t,i){super("ft-reader-visible-topics-change",{detail:{visibleTopics:i}})}}class p extends CustomEvent{constructor(t){super("ft-reader-navigation-done",{detail:t})}}class g extends CustomEvent{constructor(t){super("ft-reader-load-error",{detail:t})}}class m extends Event{constructor(){super("ft-reader-map-not-found")}}class w extends Event{constructor(){super("ft-reader-map-unauthorized")}}class f extends i.FtLitElementRedux{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-reader",this.labels={},this.visibleTopics=[],this.navigationDebouncer=new i.Debouncer(5)}render(){return s.html`
1
+ !function(t,i,s,e){const n={setBaseUrl:(t,i)=>{t.baseUrl=i.payload},setApiIntegrationIdentifier:(t,i)=>{t.apiIntegrationIdentifier=i.payload},setMapId:(t,i)=>{t.mapId=i.payload},setTocId:(t,i)=>{t.tocId=i.payload},setMap:(t,i)=>{t.map=i.payload},setToc:(t,i)=>{t.toc=i.payload},setPagesToc:(t,i)=>{t.pagesToc=i.payload},setPaginationConfiguration:(t,i)=>{t.paginationConfiguration=i.payload},setCurrentPage:(t,i)=>{t.currentPage=i.payload},setScrollTarget:(t,i)=>{t.scrollTarget=i.payload},setVisibleTopics:(t,i)=>{t.visibleTopics=i.payload},setLabels:(t,i)=>{t.labels=i.payload},setConfiguration:(t,i)=>{t.configuration=i.payload}},r={topicMissingAdvice:"Sorry, this topic is missing",somethingWentWrong:"Oops, something went wrong"};class o{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,s){return t.flatMap((t=>(t.pageConfiguration&&this.registerPage(this.buildPage(t,s)),null==t.tocId?this.extractPagesToc(t.children,i,s):[{tocId:t.tocId,title:t.title,depth:i,children:this.extractPagesToc(t.children,i+1,t.tocId)}])))}convertNodes(t,i,s){return t.flatMap((t=>{var e,n,r;if(null==t.tocId)return[...this.convertSectionNodes(null!==(e=t.pageToc)&&void 0!==e?e:[],i,t.tocId),...this.convertNodes(t.children,i,t.tocId)];let o=null===(n=t.prettyUrl)||void 0===n?void 0:n.replace(/^\//,"");const h={tocId:t.tocId,contentId:t.contentId,title:t.title,hasRating:t.hasRating,prettyUrl:o,depth:i,parentTocId:s,children:[]};this.register(h);const a=this.convertSectionNodes(null!==(r=t.pageToc)&&void 0!==r?r:[],i+1,t.tocId),l=this.convertNodes(t.children,i+1,h.tocId);return h.children=[...a,...l],[h]}))}convertSectionNodes(t,i,s){return t.flatMap((t=>{var e;let n=null===(e=t.prettyUrl)||void 0===e?void 0:e.replace(/^\//,"");const r={...t,prettyUrl:n,depth:i,parentTocId:s,children:[]};return this.register(r),r.children=this.convertSectionNodes(t.children,i+1,t.tocId),[r]}))}buildPage(t,i){var s,e,n,r,o,h;const a={number:this.pages.length+1,title:null!==(s=t.title)&&void 0!==s?s:"",rootTocId:null!==(e=t.tocId)&&void 0!==e?e:"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]):[]},l=(t,i)=>(i?a.topics:a.hiddenTopics).push(t),c=null!==(o=null===(r=t.pageConfiguration)||void 0===r?void 0:r.parentsVisibility)&&void 0!==o?o:[];return a.breadcrumb.forEach(((t,i)=>{l(t,c[i])})),t.tocId&&l(t.tocId,t.pageConfiguration.isVisible),a.topics.push(...this.tocIds(null!==(h=t.pageToc)&&void 0!==h?h:[])),a}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 h{convertPaginatedToc(t){return new o(t).build()}}class a{constructor(t,s,e,n,o,h){this.converter=t,this.api=s,this.cache=e,this.baseUrl=n,this.cleanSessionDebouncer=new i.Debouncer,this.labelResolver=new i.ParametrizedLabelResolver(r,{}),n.endsWith("/")||(this.baseUrl=n+"/"),this.mapId=o,this.labels=null!=h?h:{},this.initCache()}static build(t,s,e,n){if(null==window.fluidtopics)throw console.error("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api"),new Error("Fluid Topics public API not found");const r=new window.fluidtopics.FluidTopicsApi(t,s,!0);return new a(new h,r,new i.CacheRegistry,t,e,n)}get mapId(){return this._mapId}set mapId(t){t!==this._mapId&&this.clear(),this._mapId=t}initCache(){this.cache.registerFinal("configuration",(()=>this.api.getReaderConfiguration())),this.cache.register("map",(()=>this.api.getMap(this.mapId))),this.cache.register("enrichedToc",(()=>this.api.getPages(this.mapId).then((t=>this.converter.convertPaginatedToc(t))))),this.cache.register("session",(async()=>{const t=await this.api.getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>this.cache.clear("session")),t.idleTimeoutInMillis),t})),this.cache.register("ratingSummary",(()=>this.api.getMapRating(this.mapId)))}clear(){this.cache.clearAll(),this.cleanSessionDebouncer.cancel()}getMap(){return this.cache.get("map")}getConfiguration(){return this.cache.get("configuration")}getSession(){return this.cache.get("session")}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,(()=>this.api.getTopic(this.mapId,t)))}getTopicContent(t){return this.cache.get("topic-content-"+t,(()=>this.api.getTopicHTMLContent(this.mapId,t,"DESIGNED_READER")))}getLink(t,i,s){const e=this.getNavigationData(t,i,s),n="r/"+(e.prettyUrl?e.prettyUrl:`${e.mapId}/${e.tocId}`),r=new URL(n,this.baseUrl);return null!=e.page&&r.searchParams.set("page",`${e.page}`),e.prettyUrlDuplicated&&r.searchParams.set("tocId",e.tocId),null!=e.section&&r.searchParams.set("section",e.section),r.href}getNavigationData(t,i,s){var e,n;t=t||"root";const r=this.enrichedToc,o=null==r?void 0:r.pageByTocId[t],h=null==r?void 0:r.nodeByTocId[t],a=null==h?void 0:h.prettyUrl;return{mapId:this.mapId,tocId:t,topicTitle:null!==(e=null==h?void 0:h.title)&&void 0!==e?e:"",page:i&&o&&o.number!==i?i:void 0,prettyUrl:null!=a?a.replace(/^r\//,""):void 0,prettyUrlDuplicated:null!==(n=null==r?void 0:r.duplicatedPrettyUrls.has(null!=a?a:""))&&void 0!==n&&n,section:s}}async getAccurateNavigationData(t,i,s){return await this.getEnrichedToc(),this.getNavigationData(t,i,s)}set labels(t){this.labelResolver=new i.ParametrizedLabelResolver(r,t)}resolveLabel(t,...i){return this.labelResolver.resolve(t,i)}getRatingSummary(){return this.cache.get("ratingSummary")}getMapRating(){return this.getRatingSummary().then((t=>t.publication))}getTopicRating(t){return this.getRatingSummary().then((i=>{var s;return{type:i.topics.type,rating:null===(s=i.topics)||void 0===s?void 0:s.ratings.find((i=>i.tocId===t))}}))}rateMap(t,i){return this.api.rateMap(this.mapId,t,i).then((()=>this.clearRatingIfNecessary()))}unrateMap(){return this.api.unrateMap(this.mapId).then((()=>this.clearRatingIfNecessary()))}sendMapFeedback(t){return this.api.sendMapFeedback(this.mapId,t)}rateTopic(t,i,s){return this.api.rateTopic(this.mapId,t,i,s).then((()=>this.clearRatingIfNecessary()))}unrateTopic(t){return this.api.unrateTopic(this.mapId,t).then((()=>this.clearRatingIfNecessary()))}async clearRatingIfNecessary(){(await this.getSession()).sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(t,i){return this.api.sendTopicFeedback(this.mapId,t,i)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}}class l{constructor(t){this.store=t,this.reloadDebouncer=new i.Debouncer(10)}static build(t){return new l((t=>i.FtReduxStore.get({name:"ft-reader-"+t,initialState:{baseUrl:void 0,apiIntegrationIdentifier:"ft-reader",mapId:void 0,visibleTopics:[],labels:{}},reducers:n}))(t.trim()||"context"))}setBaseUrl(t){this.store.actions.setBaseUrl(t),this.initService()}setApiIntegrationIdentifier(t){this.store.actions.setApiIntegrationIdentifier(t),this.initService()}initService(){const t=this.store.getState();t.baseUrl&&t.apiIntegrationIdentifier?this.service=a.build(t.baseUrl,t.apiIntegrationIdentifier,t.mapId,t.labels):this.service=void 0,this.reload()}setMapId(t){this.store.actions.setMapId(t),this.service&&(this.service.mapId=t),this.reload()}setVisibleTopics(t){this.store.actions.setVisibleTopics(t)}setLabels(t){this.store.actions.setLabels(t),this.service&&(this.service.labels=t)}async awaitService(){for(;null==this.service;)await i.delay(5);return this.service}async navigateToTopic(t,i,s){const e=await this.awaitService();let n=await(null!=s?e.getPage(s):e.getPageByTocId(t));this.store.actions.setCurrentPage(n),this.store.actions.setScrollTarget({tocId:t,section:i})}async navigateToPage(t){const i=await this.awaitService();let s=await i.getPage(t);this.store.actions.setCurrentPage(s)}scrollDone(){this.store.actions.setScrollTarget({})}async reload(){var t,i;null===(t=this.service)||void 0===t||t.clear(),this.store.actions.setConfiguration(void 0),this.store.actions.setMap(void 0),this.store.actions.setToc(void 0),this.store.actions.setPagesToc(void 0),this.store.actions.setCurrentPage(void 0),(null===(i=this.service)||void 0===i?void 0:i.mapId)&&await this.reloadDebouncer.run((()=>this.fetchData()))}async fetchData(){var t,i,s,e,n;try{await Promise.all([null===(t=this.service)||void 0===t?void 0:t.getConfiguration().then((t=>this.store.actions.setConfiguration(t))),null===(i=this.service)||void 0===i?void 0:i.getMap().then((t=>this.store.actions.setMap(t))),null===(s=this.service)||void 0===s?void 0:s.getToc().then((t=>this.store.actions.setToc(t))),null===(e=this.service)||void 0===e?void 0:e.getPagesToc().then((t=>this.store.actions.setPagesToc(t))),null===(n=this.service)||void 0===n?void 0:n.getPaginationConfiguration().then((t=>this.store.actions.setPaginationConfiguration(t)))])}catch(t){this.errorHandler&&this.errorHandler(t)}}}const c=s.css`
2
+ `;var d=function(t,i,s,e){for(var n,r=arguments.length,o=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,h=t.length-1;h>=0;h--)(n=t[h])&&(o=(r<3?n(o):r>3?n(i,s,o):n(i,s))||o);return r>3&&o&&Object.defineProperty(i,s,o),o};class u extends CustomEvent{constructor(t,i){super("ft-reader-map-loaded",{detail:{map:t,toc:i}})}}class v extends CustomEvent{constructor(t,i){super("ft-reader-visible-topics-change",{detail:{visibleTopics:i}})}}class p extends CustomEvent{constructor(t){super("ft-reader-navigation-done",{detail:t})}}class g extends CustomEvent{constructor(t){super("ft-reader-load-error",{detail:t})}}class w extends Event{constructor(){super("ft-reader-map-not-found")}}class f extends Event{constructor(){super("ft-reader-map-unauthorized")}}class m extends i.FtLitElementRedux{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-reader",this.labels={},this.visibleTopics=[],this.navigationDebouncer=new i.Debouncer(5)}render(){return s.html`
3
3
  ${this.importStyleIfNeeded()}
4
4
  <slot @register-ft-reader-component=${this.registerComponent}></slot>
5
5
  `}importStyleIfNeeded(){var t,i;return!this.stateManager.service||window.location.href.startsWith(null!==(t=this.baseUrl)&&void 0!==t?t:"")?s.nothing:s.html`
6
6
  <style>
7
7
  @import "${null===(i=this.stateManager.service)||void 0===i?void 0:i.themeStylesheet()}"
8
8
  </style>
9
- `}get stateManager(){return null==this._stateManager&&(this._stateManager=l.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0")),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store)),this._stateManager}connectedCallback(){super.connectedCallback(),this.stateManager.awaitService().then((t=>{const i=t.fontsStylesheet();if(!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)}}))}updated(t){super.updated(t),t.has("baseUrl")&&this.stateManager.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("mapId")&&this.stateManager.setMapId(this.mapId),(t.has("tocId")||t.has("section")||t.has("page"))&&this.tocId?this.stateManager.navigateToTopic(this.tocId,this.section,this.page):t.has("page")&&!this.tocId&&null!=this.page?this.stateManager.navigateToPage(this.page):t.has("mapId")&&this.mapId&&this.navigateToTarget(),t.has("labels")&&this.stateManager.setLabels(this.labels)}contentAvailableCallback(t){var i;if(super.contentAvailableCallback(t),(t.has("map")||t.has("toc"))&&this.map&&this.toc&&this.dispatchEvent(new u(this.map,this.toc)),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.navigationDebouncer.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 p(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=>({tocId:t.tocId,title:t.topicTitle,page:t.page,prettyUrl:t.prettyUrl,prettyUrlDuplicated:t.prettyUrlDuplicated,breadcrumb:this.buildBreadcrumb(t.tocId)})));this.dispatchEvent(new v(this.map,i))}))}buildBreadcrumb(t){var i,s,e,n;let r=[],o=null===(s=null===(i=this.stateManager.service)||void 0===i?void 0:i.getTocNodeNow(t))||void 0===s?void 0:s.parentTocId,h=null===(e=this.stateManager.service)||void 0===e?void 0:e.getTocNodeNow(o);for(;h;)r.unshift({tocId:h.tocId,title:h.title}),h=null===(n=this.stateManager.service)||void 0===n?void 0:n.getTocNodeNow(h.parentTocId);return r}async reload(){await this.stateManager.reload(),this.navigateToTarget()}navigateToTarget(){null!=this.tocId?this.stateManager.navigateToTopic(this.tocId,this.section,this.page):null!=this.page&&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;404===i.status?this.dispatchEvent(new m):401===i.status?this.dispatchEvent(new w):this.dispatchEvent(new g(t))}}var b;f.styles=d,c([e.property()],f.prototype,"baseUrl",void 0),c([e.property()],f.prototype,"apiIntegrationIdentifier",void 0),c([e.property()],f.prototype,"mapId",void 0),c([e.property()],f.prototype,"tocId",void 0),c([e.property()],f.prototype,"section",void 0),c([e.property({type:Number,converter:{fromAttribute:t=>+(null!=t?t:"NaN")>0?+t:b}})],f.prototype,"page",void 0),c([i.jsonProperty({})],f.prototype,"labels",void 0),c([i.redux()],f.prototype,"map",void 0),c([i.redux()],f.prototype,"toc",void 0),c([i.redux()],f.prototype,"visibleTopics",void 0),c([i.redux()],f.prototype,"currentPage",void 0),c([i.redux()],f.prototype,"scrollTarget",void 0),i.customElement("ft-reader-context")(f),t.FtReaderContext=f,t.FtReaderContextCssVariables={},t.LoadErrorEvent=g,t.MapLoadedEvent=u,t.NavigationDoneEvent=p,t.NotFoundErrorEvent=m,t.UnauthorizedErrorEvent=w,t.VisibleTopicsChangeEvent=v,t.styles=d,Object.defineProperty(t,"t",{value:!0})}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators);
9
+ `}get stateManager(){return null==this._stateManager&&(this._stateManager=l.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0")),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store)),this._stateManager}connectedCallback(){super.connectedCallback(),this.stateManager.awaitService().then((t=>{const i=t.fontsStylesheet();if(!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)}}))}updated(t){super.updated(t),t.has("baseUrl")&&this.stateManager.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("mapId")&&this.stateManager.setMapId(this.mapId),(t.has("tocId")||t.has("section")||t.has("page"))&&this.tocId?this.stateManager.navigateToTopic(this.tocId,this.section,this.page):t.has("page")&&!this.tocId&&null!=this.page?this.stateManager.navigateToPage(this.page):t.has("mapId")&&this.mapId&&this.navigateToTarget(),t.has("labels")&&this.stateManager.setLabels(this.labels)}contentAvailableCallback(t){var i;if(super.contentAvailableCallback(t),(t.has("map")||t.has("toc"))&&this.map&&this.toc&&this.dispatchEvent(new u(this.map,this.toc)),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.navigationDebouncer.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 p(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=>({tocId:t.tocId,title:t.topicTitle,page:t.page,prettyUrl:t.prettyUrl,prettyUrlDuplicated:t.prettyUrlDuplicated,breadcrumb:this.buildBreadcrumb(t.tocId)})));this.dispatchEvent(new v(this.map,i))}))}buildBreadcrumb(t){var i,s,e,n;let r=[],o=null===(s=null===(i=this.stateManager.service)||void 0===i?void 0:i.getTocNodeNow(t))||void 0===s?void 0:s.parentTocId,h=null===(e=this.stateManager.service)||void 0===e?void 0:e.getTocNodeNow(o);for(;h;)r.unshift({tocId:h.tocId,title:h.title}),h=null===(n=this.stateManager.service)||void 0===n?void 0:n.getTocNodeNow(h.parentTocId);return r}async reload(){await this.stateManager.reload(),this.navigateToTarget()}navigateToTarget(){null!=this.tocId?this.stateManager.navigateToTopic(this.tocId,this.section,this.page):null!=this.page&&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;404===i.status?this.dispatchEvent(new w):401===i.status?this.dispatchEvent(new f):this.dispatchEvent(new g(t))}}var b;m.styles=c,d([e.property()],m.prototype,"baseUrl",void 0),d([e.property()],m.prototype,"apiIntegrationIdentifier",void 0),d([e.property()],m.prototype,"mapId",void 0),d([e.property()],m.prototype,"tocId",void 0),d([e.property()],m.prototype,"section",void 0),d([e.property({type:Number,converter:{fromAttribute:t=>+(null!=t?t:"NaN")>0?+t:b}})],m.prototype,"page",void 0),d([i.jsonProperty({})],m.prototype,"labels",void 0),d([i.redux()],m.prototype,"map",void 0),d([i.redux()],m.prototype,"toc",void 0),d([i.redux()],m.prototype,"visibleTopics",void 0),d([i.redux()],m.prototype,"currentPage",void 0),d([i.redux()],m.prototype,"scrollTarget",void 0),i.customElement("ft-reader-context")(m),t.FtReaderContext=m,t.FtReaderContextCssVariables={},t.LoadErrorEvent=g,t.MapLoadedEvent=u,t.NavigationDoneEvent=p,t.NotFoundErrorEvent=w,t.UnauthorizedErrorEvent=f,t.VisibleTopicsChangeEvent=v,t.styles=c,Object.defineProperty(t,"t",{value:!0})}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators);
@@ -89,7 +89,7 @@ function(t){return class extends t{createRenderRoot(){const t=this.constructor,{
89
89
  display: inline-block;
90
90
  width: 0;
91
91
  }
92
- `;class pt{constructor(t,e){this.defaultLabels=t,this.labels=e}resolve(t,...e){var i,n;t=this.resolvePluralKey(t,e);let r=null!==(n=null!==(i=this.labels[t])&&void 0!==i?i:this.defaultLabels[t])&&void 0!==n?n:"";return e.forEach(((t,e)=>r=r.replace(new RegExp(`\\{${e}([^}]*)\\}`,"g"),((e,i)=>this.formatValue(t,i))))),r}resolvePluralKey(t,e){for(let i of e)if("number"==typeof i){const e=`${t}[\\=${i}]`;if(e in this.labels||e in this.defaultLabels)return e}return t}formatValue(t,e){return t instanceof Date?this.formatDate(t,e):t}formatDate(t,e){const i=i=>(null==e?void 0:e.includes("date"))?t.toLocaleDateString(i):(null==e?void 0:e.includes("time"))?t.toLocaleTimeString(i):t.toLocaleString(i);try{return i(document.documentElement.lang)}catch(t){return i()}}}function bt(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];throw Error("[Immer] minified error nr: "+t+(i.length?" "+i.map((function(t){return"'"+t+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function wt(t){return!!t&&!!t[ne]}function yt(t){return!!t&&(function(t){if(!t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);if(null===e)return!0;var i=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return i===Object||"function"==typeof i&&Function.toString.call(i)===re}(t)||Array.isArray(t)||!!t[ie]||!!t.constructor[ie]||St(t)||jt(t))}function mt(t,e,i){void 0===i&&(i=!1),0===gt(t)?(i?Object.keys:oe)(t).forEach((function(n){i&&"symbol"==typeof n||e(n,t[n],t)})):t.forEach((function(i,n){return e(n,i,t)}))}function gt(t){var e=t[ne];return e?e.i>3?e.i-4:e.i:Array.isArray(t)?1:St(t)?2:jt(t)?3:0}function xt(t,e){return 2===gt(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Ot(t,e,i){var n=gt(t);2===n?t.set(e,i):3===n?(t.delete(e),t.add(i)):t[e]=i}function Et(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function St(t){return Yt&&t instanceof Map}function jt(t){return Qt&&t instanceof Set}function Nt(t){return t.o||t.t}function Ct(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var e=se(t);delete e[ne];for(var i=oe(e),n=0;n<i.length;n++){var r=i[n],o=e[r];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(e[r]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[r]})}return Object.create(Object.getPrototypeOf(t),e)}function Rt(t,e){return void 0===e&&(e=!1),Tt(t)||wt(t)||!yt(t)||(gt(t)>1&&(t.set=t.add=t.clear=t.delete=Mt),Object.freeze(t),e&&mt(t,(function(t,e){return Rt(e,!0)}),!0)),t}function Mt(){bt(2)}function Tt(t){return null==t||"object"!=typeof t||Object.isFrozen(t)}function At(t){var e=ue[t];return e||bt(18,t),e}function Ut(){return Xt}function $t(t,e){e&&(At("Patches"),t.u=[],t.s=[],t.v=e)}function kt(t){It(t),t.p.forEach(Ft),t.p=null}function It(t){t===Xt&&(Xt=t.l)}function Pt(t){return Xt={p:[],l:Xt,h:t,m:!0,_:0}}function Ft(t){var e=t[ne];0===e.i||1===e.i?e.j():e.O=!0}function Lt(t,e){e._=e.p.length;var i=e.p[0],n=void 0!==t&&t!==i;return e.h.g||At("ES5").S(e,t,n),n?(i[ne].P&&(kt(e),bt(4)),yt(t)&&(t=_t(e,t),e.l||Dt(e,t)),e.u&&At("Patches").M(i[ne].t,t,e.u,e.s)):t=_t(e,i,[]),kt(e),e.u&&e.v(e.u,e.s),t!==ee?t:void 0}function _t(t,e,i){if(Tt(e))return e;var n=e[ne];if(!n)return mt(e,(function(r,o){return Bt(t,n,e,r,o,i)}),!0),e;if(n.A!==t)return e;if(!n.P)return Dt(t,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var r=4===n.i||5===n.i?n.o=Ct(n.k):n.o;mt(3===n.i?new Set(r):r,(function(e,o){return Bt(t,n,r,e,o,i)})),Dt(t,r,!1),i&&t.u&&At("Patches").R(n,i,t.u,t.s)}return n.o}function Bt(t,e,i,n,r,o){if(wt(r)){var s=_t(t,r,o&&e&&3!==e.i&&!xt(e.D,n)?o.concat(n):void 0);if(Ot(i,n,s),!wt(s))return;t.m=!1}if(yt(r)&&!Tt(r)){if(!t.h.F&&t._<1)return;_t(t,r),e&&e.A.l||Dt(t,r)}}function Dt(t,e,i){void 0===i&&(i=!1),t.h.F&&t.m&&Rt(e,i)}function Wt(t,e){var i=t[ne];return(i?Nt(i):t)[e]}function Kt(t,e){if(e in t)for(var i=Object.getPrototypeOf(t);i;){var n=Object.getOwnPropertyDescriptor(i,e);if(n)return n;i=Object.getPrototypeOf(i)}}function Ht(t){t.P||(t.P=!0,t.l&&Ht(t.l))}function zt(t){t.o||(t.o=Ct(t.t))}function Vt(t,e,i){var n=St(e)?At("MapSet").N(e,i):jt(e)?At("MapSet").T(e,i):t.g?function(t,e){var i=Array.isArray(t),n={i:i?1:0,A:e?e.A:Ut(),P:!1,I:!1,D:{},l:e,t,k:null,o:null,j:null,C:!1},r=n,o=ae;i&&(r=[n],o=ce);var s=Proxy.revocable(r,o),u=s.revoke,a=s.proxy;return n.k=a,n.j=u,a}(e,i):At("ES5").J(e,i);return(i?i.A:Ut()).p.push(n),n}function Jt(t){return wt(t)||bt(22,t),function t(e){if(!yt(e))return e;var i,n=e[ne],r=gt(e);if(n){if(!n.P&&(n.i<4||!At("ES5").K(n)))return n.t;n.I=!0,i=Zt(e,r),n.I=!1}else i=Zt(e,r);return mt(i,(function(e,r){n&&function(t,e){return 2===gt(t)?t.get(e):t[e]}(n.t,e)===r||Ot(i,e,t(r))})),3===r?new Set(i):i}(t)}function Zt(t,e){switch(e){case 2:return new Map(t);case 3:return Array.from(t)}return Ct(t)}var qt,Xt,Gt="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),Yt="undefined"!=typeof Map,Qt="undefined"!=typeof Set,te="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,ee=Gt?Symbol.for("immer-nothing"):((qt={})["immer-nothing"]=!0,qt),ie=Gt?Symbol.for("immer-draftable"):"__$immer_draftable",ne=Gt?Symbol.for("immer-state"):"__$immer_state",re=""+Object.prototype.constructor,oe="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,se=Object.getOwnPropertyDescriptors||function(t){var e={};return oe(t).forEach((function(i){e[i]=Object.getOwnPropertyDescriptor(t,i)})),e},ue={},ae={get:function(t,e){if(e===ne)return t;var i=Nt(t);if(!xt(i,e))return function(t,e,i){var n,r=Kt(e,i);return r?"value"in r?r.value:null===(n=r.get)||void 0===n?void 0:n.call(t.k):void 0}(t,i,e);var n=i[e];return t.I||!yt(n)?n:n===Wt(t.t,e)?(zt(t),t.o[e]=Vt(t.A.h,n,t)):n},has:function(t,e){return e in Nt(t)},ownKeys:function(t){return Reflect.ownKeys(Nt(t))},set:function(t,e,i){var n=Kt(Nt(t),e);if(null==n?void 0:n.set)return n.set.call(t.k,i),!0;if(!t.P){var r=Wt(Nt(t),e),o=null==r?void 0:r[ne];if(o&&o.t===i)return t.o[e]=i,t.D[e]=!1,!0;if(Et(i,r)&&(void 0!==i||xt(t.t,e)))return!0;zt(t),Ht(t)}return t.o[e]===i&&"number"!=typeof i&&(void 0!==i||e in t.o)||(t.o[e]=i,t.D[e]=!0,!0)},deleteProperty:function(t,e){return void 0!==Wt(t.t,e)||e in t.t?(t.D[e]=!1,zt(t),Ht(t)):delete t.D[e],t.o&&delete t.o[e],!0},getOwnPropertyDescriptor:function(t,e){var i=Nt(t),n=Reflect.getOwnPropertyDescriptor(i,e);return n?{writable:!0,configurable:1!==t.i||"length"!==e,enumerable:n.enumerable,value:i[e]}:n},defineProperty:function(){bt(11)},getPrototypeOf:function(t){return Object.getPrototypeOf(t.t)},setPrototypeOf:function(){bt(12)}},ce={};mt(ae,(function(t,e){ce[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),ce.deleteProperty=function(t,e){return ce.set.call(this,t,e,void 0)},ce.set=function(t,e,i){return ae.set.call(this,t[0],e,i,t[0])};var le=function(){function t(t){var e=this;this.g=te,this.F=!0,this.produce=function(t,i,n){if("function"==typeof t&&"function"!=typeof i){var r=i;i=t;var o=e;return function(t){var e=this;void 0===t&&(t=r);for(var n=arguments.length,s=Array(n>1?n-1:0),u=1;u<n;u++)s[u-1]=arguments[u];return o.produce(t,(function(t){var n;return(n=i).call.apply(n,[e,t].concat(s))}))}}var s;if("function"!=typeof i&&bt(6),void 0!==n&&"function"!=typeof n&&bt(7),yt(t)){var u=Pt(e),a=Vt(e,t,void 0),c=!0;try{s=i(a),c=!1}finally{c?kt(u):It(u)}return"undefined"!=typeof Promise&&s instanceof Promise?s.then((function(t){return $t(u,n),Lt(t,u)}),(function(t){throw kt(u),t})):($t(u,n),Lt(s,u))}if(!t||"object"!=typeof t){if(void 0===(s=i(t))&&(s=t),s===ee&&(s=void 0),e.F&&Rt(s,!0),n){var l=[],h=[];At("Patches").M(t,s,l,h),n(l,h)}return s}bt(21,t)},this.produceWithPatches=function(t,i){if("function"==typeof t)return function(i){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return e.produceWithPatches(i,(function(e){return t.apply(void 0,[e].concat(r))}))};var n,r,o=e.produce(t,i,(function(t,e){n=t,r=e}));return"undefined"!=typeof Promise&&o instanceof Promise?o.then((function(t){return[t,n,r]})):[o,n,r]},"boolean"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var e=t.prototype;return e.createDraft=function(t){yt(t)||bt(8),wt(t)&&(t=Jt(t));var e=Pt(this),i=Vt(this,t,void 0);return i[ne].C=!0,It(e),i},e.finishDraft=function(t,e){var i=(t&&t[ne]).A;return $t(i,e),Lt(void 0,i)},e.setAutoFreeze=function(t){this.F=t},e.setUseProxies=function(t){t&&!te&&bt(20),this.g=t},e.applyPatches=function(t,e){var i;for(i=e.length-1;i>=0;i--){var n=e[i];if(0===n.path.length&&"replace"===n.op){t=n.value;break}}i>-1&&(e=e.slice(i+1));var r=At("Patches").$;return wt(t)?r(t,e):this.produce(t,(function(t){return r(t,e)}))},t}(),he=new le,fe=he.produce;he.produceWithPatches.bind(he),he.setAutoFreeze.bind(he),he.setUseProxies.bind(he),he.applyPatches.bind(he),he.createDraft.bind(he),he.finishDraft.bind(he);var de=fe;function ve(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function pe(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function be(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?pe(Object(i),!0).forEach((function(e){ve(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):pe(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function we(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var ye="function"==typeof Symbol&&Symbol.observable||"@@observable",me=function(){return Math.random().toString(36).substring(7).split("").join(".")},ge={INIT:"@@redux/INIT"+me(),REPLACE:"@@redux/REPLACE"+me(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+me()}};function xe(t){if("object"!=typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Oe(t,e,i){var n;if("function"==typeof e&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(we(0));if("function"==typeof e&&void 0===i&&(i=e,e=void 0),void 0!==i){if("function"!=typeof i)throw new Error(we(1));return i(Oe)(t,e)}if("function"!=typeof t)throw new Error(we(2));var r=t,o=e,s=[],u=s,a=!1;function c(){u===s&&(u=s.slice())}function l(){if(a)throw new Error(we(3));return o}function h(t){if("function"!=typeof t)throw new Error(we(4));if(a)throw new Error(we(5));var e=!0;return c(),u.push(t),function(){if(e){if(a)throw new Error(we(6));e=!1,c();var i=u.indexOf(t);u.splice(i,1),s=null}}}function f(t){if(!xe(t))throw new Error(we(7));if(void 0===t.type)throw new Error(we(8));if(a)throw new Error(we(9));try{a=!0,o=r(o,t)}finally{a=!1}for(var e=s=u,i=0;i<e.length;i++){(0,e[i])()}return t}function d(t){if("function"!=typeof t)throw new Error(we(10));r=t,f({type:ge.REPLACE})}function v(){var t,e=h;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(we(11));function i(){t.next&&t.next(l())}return i(),{unsubscribe:e(i)}}})[ye]=function(){return this},t}return f({type:ge.INIT}),(n={dispatch:f,subscribe:h,getState:l,replaceReducer:d})[ye]=v,n}function Ee(t){for(var e=Object.keys(t),i={},n=0;n<e.length;n++){var r=e[n];"function"==typeof t[r]&&(i[r]=t[r])}var o,s=Object.keys(i);try{!function(t){Object.keys(t).forEach((function(e){var i=t[e];if(void 0===i(void 0,{type:ge.INIT}))throw new Error(we(12));if(void 0===i(void 0,{type:ge.PROBE_UNKNOWN_ACTION()}))throw new Error(we(13))}))}(i)}catch(t){o=t}return function(t,e){if(void 0===t&&(t={}),o)throw o;for(var n=!1,r={},u=0;u<s.length;u++){var a=s[u],c=i[a],l=t[a],h=c(l,e);if(void 0===h)throw e&&e.type,new Error(we(14));r[a]=h,n=n||h!==l}return(n=n||s.length!==Object.keys(t).length)?r:t}}function Se(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce((function(t,e){return function(){return t(e.apply(void 0,arguments))}}))}function je(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return function(t){return function(){var i=t.apply(void 0,arguments),n=function(){throw new Error(we(15))},r={getState:i.getState,dispatch:function(){return n.apply(void 0,arguments)}},o=e.map((function(t){return t(r)}));return n=Se.apply(void 0,o)(i.dispatch),be(be({},i),{},{dispatch:n})}}}function Ne(t){return function(e){var i=e.dispatch,n=e.getState;return function(e){return function(r){return"function"==typeof r?r(i,n,t):e(r)}}}}var Ce=Ne();Ce.withExtraArgument=Ne;var Re,Me=Ce,Te=(Re=function(t,e){return Re=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},Re(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}Re(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),Ae=function(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t},Ue=Object.defineProperty,$e=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Pe=function(t,e,i){return e in t?Ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i},Fe=function(t,e){for(var i in e||(e={}))ke.call(e,i)&&Pe(t,i,e[i]);if($e)for(var n=0,r=$e(e);n<r.length;n++){i=r[n];Ie.call(e,i)&&Pe(t,i,e[i])}return t},Le="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Se:Se.apply(null,arguments)};var _e=function(t){function e(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];var r=t.apply(this,i)||this;return Object.setPrototypeOf(r,e.prototype),r}return Te(e,t),Object.defineProperty(e,Symbol.species,{get:function(){return e},enumerable:!1,configurable:!0}),e.prototype.concat=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return t.prototype.concat.apply(this,e)},e.prototype.prepend=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return 1===t.length&&Array.isArray(t[0])?new(e.bind.apply(e,Ae([void 0],t[0].concat(this)))):new(e.bind.apply(e,Ae([void 0],t.concat(this))))},e}(Array);function Be(t){return yt(t)?de(t,(function(){})):t}function De(){return function(t){return function(t){void 0===t&&(t={});var e=t.thunk,i=void 0===e||e;t.immutableCheck,t.serializableCheck;var n=new _e;i&&(!function(t){return"boolean"==typeof t}(i)?n.push(Me.withExtraArgument(i.extraArgument)):n.push(Me));return n}(t)}}function We(t){var e,i=De(),n=t||{},r=n.reducer,o=void 0===r?void 0:r,s=n.middleware,u=void 0===s?i():s,a=n.devTools,c=void 0===a||a,l=n.preloadedState,h=void 0===l?void 0:l,f=n.enhancers,d=void 0===f?void 0:f;if("function"==typeof o)e=o;else{if(!function(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);if(null===e)return!0;for(var i=e;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return e===i}(o))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');e=Ee(o)}var v=u;"function"==typeof v&&(v=v(i));var p=je.apply(void 0,v),b=Se;c&&(b=Le(Fe({trace:!1},"object"==typeof c&&c)));var w=[p];return Array.isArray(d)?w=Ae([p],d):"function"==typeof d&&(w=d(w)),Oe(e,h,b.apply(void 0,w))}function Ke(t,e){function i(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];if(e){var r=e.apply(void 0,i);if(!r)throw new Error("prepareAction did not return an object");return Fe(Fe({type:t,payload:r.payload},"meta"in r&&{meta:r.meta}),"error"in r&&{error:r.error})}return{type:t,payload:i[0]}}return i.toString=function(){return""+t},i.type=t,i.match=function(e){return e.type===t},i}function He(t){var e,i={},n=[],r={addCase:function(t,e){var n="string"==typeof t?t:t.type;if(n in i)throw new Error("addCase cannot be called with two reducers for the same action type");return i[n]=e,r},addMatcher:function(t,e){return n.push({matcher:t,reducer:e}),r},addDefaultCase:function(t){return e=t,r}};return t(r),[i,n,e]}function ze(t){var e=t.name;if(!e)throw new Error("`name` is a required option for createSlice");var i,n="function"==typeof t.initialState?t.initialState:Be(t.initialState),r=t.reducers||{},o=Object.keys(r),s={},u={},a={};function c(){var e="function"==typeof t.extraReducers?He(t.extraReducers):[t.extraReducers],i=e[0],r=void 0===i?{}:i,o=e[1],s=void 0===o?[]:o,a=e[2],c=void 0===a?void 0:a,l=Fe(Fe({},r),u);return function(t,e,i,n){void 0===i&&(i=[]);var r,o="function"==typeof e?He(e):[e,i,n],s=o[0],u=o[1],a=o[2];if(function(t){return"function"==typeof t}(t))r=function(){return Be(t())};else{var c=Be(t);r=function(){return c}}function l(t,e){void 0===t&&(t=r());var i=Ae([s[e.type]],u.filter((function(t){return(0,t.matcher)(e)})).map((function(t){return t.reducer})));return 0===i.filter((function(t){return!!t})).length&&(i=[a]),i.reduce((function(t,i){if(i){var n;if(wt(t))return void 0===(n=i(t,e))?t:n;if(yt(t))return de(t,(function(t){return i(t,e)}));if(void 0===(n=i(t,e))){if(null===t)return t;throw Error("A case reducer on a non-draftable value must not return undefined")}return n}return t}),t)}return l.getInitialState=r,l}(n,l,s,c)}return o.forEach((function(t){var i,n,o=r[t],c=e+"/"+t;"reducer"in o?(i=o.reducer,n=o.prepare):i=o,s[t]=i,u[c]=i,a[t]=n?Ke(c,n):Ke(c)})),{name:e,reducer:function(t,e){return i||(i=c()),i(t,e)},actions:a,caseReducers:s,getInitialState:function(){return i||(i=c()),i.getInitialState()}}}var Ve="listenerMiddleware";Ke(Ve+"/add"),Ke(Ve+"/removeAll"),Ke(Ve+"/remove"),function(){function t(t,e){var i=r[t];return i?i.enumerable=e:r[t]=i={configurable:!0,enumerable:e,get:function(){var e=this[ne];return ae.get(e,t)},set:function(e){var i=this[ne];ae.set(i,t,e)}},i}function e(t){for(var e=t.length-1;e>=0;e--){var r=t[e][ne];if(!r.P)switch(r.i){case 5:n(r)&&Ht(r);break;case 4:i(r)&&Ht(r)}}}function i(t){for(var e=t.t,i=t.k,n=oe(i),r=n.length-1;r>=0;r--){var o=n[r];if(o!==ne){var s=e[o];if(void 0===s&&!xt(e,o))return!0;var u=i[o],a=u&&u[ne];if(a?a.t!==s:!Et(u,s))return!0}}var c=!!e[ne];return n.length!==oe(e).length+(c?0:1)}function n(t){var e=t.k;if(e.length!==t.t.length)return!0;var i=Object.getOwnPropertyDescriptor(e,e.length-1);if(i&&!i.get)return!0;for(var n=0;n<e.length;n++)if(!e.hasOwnProperty(n))return!0;return!1}var r={};!function(t,e){ue[t]||(ue[t]=e)}("ES5",{J:function(e,i){var n=Array.isArray(e),r=function(e,i){if(e){for(var n=Array(i.length),r=0;r<i.length;r++)Object.defineProperty(n,""+r,t(r,!0));return n}var o=se(i);delete o[ne];for(var s=oe(o),u=0;u<s.length;u++){var a=s[u];o[a]=t(a,e||!!o[a].enumerable)}return Object.create(Object.getPrototypeOf(i),o)}(n,e),o={i:n?5:4,A:i?i.A:Ut(),P:!1,I:!1,D:{},l:i,t:e,k:r,o:null,O:!1,C:!1};return Object.defineProperty(r,ne,{value:o,writable:!0}),r},S:function(t,i,r){r?wt(i)&&i[ne].A===t&&e(t.p):(t.u&&function t(e){if(e&&"object"==typeof e){var i=e[ne];if(i){var r=i.t,o=i.k,s=i.D,u=i.i;if(4===u)mt(o,(function(e){e!==ne&&(void 0!==r[e]||xt(r,e)?s[e]||t(o[e]):(s[e]=!0,Ht(i)))})),mt(r,(function(t){void 0!==o[t]||xt(o,t)||(s[t]=!1,Ht(i))}));else if(5===u){if(n(i)&&(Ht(i),s.length=!0),o.length<r.length)for(var a=o.length;a<r.length;a++)s[a]=!1;else for(var c=r.length;c<o.length;c++)s[c]=!0;for(var l=Math.min(o.length,r.length),h=0;h<l;h++)o.hasOwnProperty(h)||(s[h]=!0),void 0===s[h]&&t(o[h])}}}}(t.p[0]),e(t.p))},K:function(t){return 4===t.i?i(t):n(t)}})}();const Je=t=>"object"==typeof t&&(0===Object.keys(t).length||"string"==typeof t.store||null!=t.selector||"function"==typeof t.hasChanged),Ze=(t,e)=>{var i;const n=Je(t)?t:{};return e=null!==(i=null!=e?e:n.hasChanged)&&void 0!==i?i:(t,e)=>!a(t,e),(i,r)=>{var o;i.constructor.createProperty(r,{attribute:!1,hasChanged:e});const s=i;s.reduxProperties=s.reduxProperties||new Map;const u=null!==(o=Je(t)?n.selector:t)&&void 0!==o?o:t=>t[r];s.reduxProperties.set(r,{selector:u,store:n.store})}};class qe extends vt{constructor(){super(...arguments),this.internalStoresUnsubscribers=new Map,this.internalStores=new Map}getUnnamedStore(){if(this.internalStores.size>1)throw new Error("Cannot resolve unnamed store when multiple stores are configured.");return[...this.internalStores.values()][0]}get store(){return this.getUnnamedStore()}set store(t){this.unsubscribeFromStores(),this.internalStores.clear(),t&&this.addStore(t)}getStore(t){var e;return null==t?null!==(e=this.getUnnamedStore())&&void 0!==e?e:this.store:this.internalStores.get(t)}addStore(t,e){e=null!=e?e:Xe(t)?t.name:"ft-lit-element-redux-default-store",this.unsubscribeFromStore(e),this.setupStore(e,t)}removeStore(t){const e="string"==typeof t?t:Xe(t)?t.name:"ft-lit-element-redux-default-store";this.unsubscribeFromStore(e),this.internalStores.delete(e)}setupStore(t,e){this.internalStores.set(t,e),this.updateFromStores(),this.subscribeToStore(t,e)}setupStores(){this.unsubscribeFromStores(),0===this.internalStores.size&&null!=this.store?this.addStore(this.store):(this.updateFromStores(),this.internalStores.forEach(((t,e)=>this.subscribeToStore(e,t))))}updateFromStores(){this.reduxProperties&&this.reduxProperties.forEach(((t,e)=>{const i=this.getStore(t.store);i&&(this[e]=t.selector(i.getState(),this))}))}subscribeToStore(t,e){this.internalStoresUnsubscribers.set(t,e.subscribe((()=>this.updateFromStores()))),this.onStoreAvailable(t)}unsubscribeFromStores(){Object.keys(this.internalStoresUnsubscribers).forEach((t=>this.unsubscribeFromStore(t)))}unsubscribeFromStore(t){this.internalStoresUnsubscribers.has(t)&&this.internalStoresUnsubscribers.get(t)(),this.internalStoresUnsubscribers.delete(t)}onStoreAvailable(t){}connectedCallback(){super.connectedCallback(),this.setupStores()}disconnectedCallback(){this.unsubscribeFromStores(),super.disconnectedCallback()}}function Xe(t){var e;return null===(e=t)||void 0===e?void 0:e.isFtReduxStore}class Ge{constructor(t,e){this.reduxSlice=t,this.reduxStore=e,this.isFtReduxStore=!0,this.actions=new Proxy(this.reduxSlice.actions,{get:(t,e,i)=>{const n=t[e];if(n)return(...t)=>{const e=n(...t);return this.reduxStore.dispatch(e),e}}})}static get(t){window.ftReduxStores||(window.ftReduxStores={});const e=window.ftReduxStores[t.name];if(Xe(e))return e;const i=ze(t);if(e)return new Ge(i,e);const n=We({reducer:i.reducer});return window.ftReduxStores[t.name]=new Ge(i,n)}get dispatch(){throw new Error("Don't use this method, actions are automatically dispatched when called.")}[Symbol.observable](){return this.reduxStore[Symbol.observable]()}getState(){return this.reduxStore.getState()}replaceReducer(t){throw new Error("Not implemented yet.")}subscribe(t){return this.reduxStore.subscribe(t)}get name(){return this.reduxSlice.name}get reducer(){return this.reduxSlice.reducer}get caseReducers(){return this.reduxSlice.caseReducers}getInitialState(){return this.reduxSlice.getInitialState()}}var Ye,Qe;navigator.vendor&&navigator.vendor.match(/apple/i)||(null===(Qe=null===(Ye=window.safari)||void 0===Ye?void 0:Ye.pushNotification)||void 0===Qe||Qe.toString());const ti={setBaseUrl:(t,e)=>{t.baseUrl=e.payload},setApiIntegrationIdentifier:(t,e)=>{t.apiIntegrationIdentifier=e.payload},setMapId:(t,e)=>{t.mapId=e.payload},setTocId:(t,e)=>{t.tocId=e.payload},setMap:(t,e)=>{t.map=e.payload},setToc:(t,e)=>{t.toc=e.payload},setPagesToc:(t,e)=>{t.pagesToc=e.payload},setPaginationConfiguration:(t,e)=>{t.paginationConfiguration=e.payload},setCurrentPage:(t,e)=>{t.currentPage=e.payload},setScrollTarget:(t,e)=>{t.scrollTarget=e.payload},setVisibleTopics:(t,e)=>{t.visibleTopics=e.payload},setLabels:(t,e)=>{t.labels=e.payload},setConfiguration:(t,e)=>{t.configuration=e.payload}},ei={topicMissingAdvice:"Sorry, this topic is missing",somethingWentWrong:"Oops, something went wrong"};class ii{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,e,i){return t.flatMap((t=>(t.pageConfiguration&&this.registerPage(this.buildPage(t,i)),null==t.tocId?this.extractPagesToc(t.children,e,i):[{tocId:t.tocId,title:t.title,depth:e,children:this.extractPagesToc(t.children,e+1,t.tocId)}])))}convertNodes(t,e,i){return t.flatMap((t=>{var n,r,o;if(null==t.tocId)return[...this.convertSectionNodes(null!==(n=t.pageToc)&&void 0!==n?n:[],e,t.tocId),...this.convertNodes(t.children,e,t.tocId)];let s=null===(r=t.prettyUrl)||void 0===r?void 0:r.replace(/^\//,"");const u={tocId:t.tocId,contentId:t.contentId,title:t.title,prettyUrl:s,depth:e,parentTocId:i,children:[]};this.register(u);const a=this.convertSectionNodes(null!==(o=t.pageToc)&&void 0!==o?o:[],e+1,t.tocId),c=this.convertNodes(t.children,e+1,u.tocId);return u.children=[...a,...c],[u]}))}convertSectionNodes(t,e,i){return t.flatMap((t=>{var n;let r=null===(n=t.prettyUrl)||void 0===n?void 0:n.replace(/^\//,"");const o={tocId:t.tocId,contentId:t.contentId,title:t.title,prettyUrl:r,depth:e,parentTocId:i,children:[]};return this.register(o),o.children=this.convertSectionNodes(t.children,e+1,t.tocId),[o]}))}buildPage(t,e){var i,n,r,o,s,u;const a={number:this.pages.length+1,title:null!==(i=t.title)&&void 0!==i?i:"",rootTocId:null!==(n=t.tocId)&&void 0!==n?n:"root",toc:(null!==(r=t.pageToc)&&void 0!==r?r:[]).map((t=>this.nodeByTocId[t.tocId])),topics:[],hiddenTopics:[],breadcrumb:e?this.buildBreadcrumb(this.nodeByTocId[e]):[]},c=(t,e)=>(e?a.topics:a.hiddenTopics).push(t),l=null!==(s=null===(o=t.pageConfiguration)||void 0===o?void 0:o.parentsVisibility)&&void 0!==s?s:[];return a.breadcrumb.forEach(((t,e)=>{c(t,l[e])})),t.tocId&&c(t.tocId,t.pageConfiguration.isVisible),a.topics.push(...this.tocIds(null!==(u=t.pageToc)&&void 0!==u?u:[])),a}registerPage(t){for(let e of[...t.topics,...t.hiddenTopics])this.pageByTocId[e]||(this.pageByTocId[e]=t);this.pages.push(t)}tocIds(t){return t.flatMap((t=>[t.tocId,...this.tocIds(t.children)]))}buildBreadcrumb(t){const e=[t.tocId];for(;null==t?void 0:t.parentTocId;)e.unshift(t.parentTocId),t=this.nodeByTocId[t.parentTocId];return e}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 ni{convertPaginatedToc(t){return new ii(t).build()}}class ri{constructor(t,e,i,r,o,s){this.converter=t,this.api=e,this.cache=i,this.baseUrl=r,this.cleanSessionDebouncer=new n,this.labelResolver=new pt(ei,{}),r.endsWith("/")||(this.baseUrl=r+"/"),this.mapId=o,this.labels=null!=s?s:{},this.initCache()}static build(t,e,n,r){if(null==window.fluidtopics)throw console.error("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api"),new Error("Fluid Topics public API not found");const o=new window.fluidtopics.FluidTopicsApi(t,e,!0);return new ri(new ni,o,new i,t,n,r)}get mapId(){return this._mapId}set mapId(t){t!==this._mapId&&this.clear(),this._mapId=t}initCache(){this.cache.registerFinal("configuration",(()=>this.api.getReaderConfiguration())),this.cache.register("map",(()=>this.api.getMap(this.mapId))),this.cache.register("enrichedToc",(()=>this.api.getPages(this.mapId).then((t=>this.converter.convertPaginatedToc(t))))),this.cache.register("session",(async()=>{const t=await this.api.getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>this.cache.clear("session")),t.idleTimeoutInMillis),t})),this.cache.register("ratingSummary",(()=>this.api.getMapRating(this.mapId)))}clear(){this.cache.clearAll(),this.cleanSessionDebouncer.cancel()}getMap(){return this.cache.get("map")}getConfiguration(){return this.cache.get("configuration")}getSession(){return this.cache.get("session")}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 e;return null===(e=this.enrichedToc)||void 0===e?void 0:e.nodeByTocId[t]}async getPage(t){const e=await this.getEnrichedToc();return e.pages[t-1]||e.pages[0]}async getPageByTocId(t){const e=await this.getEnrichedToc();return e.pageByTocId[t]||e.pages[0]}getTopicInfo(t){return this.cache.get("topic-"+t,(()=>this.api.getTopic(this.mapId,t)))}getTopicContent(t){return this.cache.get("topic-content-"+t,(()=>this.api.getTopicHTMLContent(this.mapId,t,"DESIGNED_READER")))}getLink(t,e,i){const n=this.getNavigationData(t,e,i),r="r/"+(n.prettyUrl?n.prettyUrl:`${n.mapId}/${n.tocId}`),o=new URL(r,this.baseUrl);return null!=n.page&&o.searchParams.set("page",`${n.page}`),n.prettyUrlDuplicated&&o.searchParams.set("tocId",n.tocId),null!=n.section&&o.searchParams.set("section",n.section),o.href}getNavigationData(t,e,i){var n,r;t=t||"root";const o=this.enrichedToc,s=null==o?void 0:o.pageByTocId[t],u=null==o?void 0:o.nodeByTocId[t],a=null==u?void 0:u.prettyUrl;return{mapId:this.mapId,tocId:t,topicTitle:null!==(n=null==u?void 0:u.title)&&void 0!==n?n:"",page:e&&s&&s.number!==e?e:void 0,prettyUrl:null!=a?a.replace(/^r\//,""):void 0,prettyUrlDuplicated:null!==(r=null==o?void 0:o.duplicatedPrettyUrls.has(null!=a?a:""))&&void 0!==r&&r,section:i}}async getAccurateNavigationData(t,e,i){return await this.getEnrichedToc(),this.getNavigationData(t,e,i)}set labels(t){this.labelResolver=new pt(ei,t)}resolveLabel(t,...e){return this.labelResolver.resolve(t,e)}getRatingSummary(){return this.cache.get("ratingSummary")}getMapRating(){return this.getRatingSummary().then((t=>t.publication))}getTopicRating(t){return this.getRatingSummary().then((e=>{var i;return{type:e.topics.type,rating:null===(i=e.topics)||void 0===i?void 0:i.ratings.find((e=>e.tocId===t))}}))}rateMap(t,e){return this.api.rateMap(this.mapId,t,e).then((()=>this.cache.clear("ratingSummary")))}unrateMap(){return this.api.unrateMap(this.mapId).then((()=>this.cache.clear("ratingSummary")))}sendMapFeedback(t){return this.api.sendMapFeedback(this.mapId,t)}rateTopic(t,e,i){return this.api.rateTopic(this.mapId,t,e,i).then((()=>this.cache.clear("ratingSummary")))}unrateTopic(t){return this.api.unrateTopic(this.mapId,t).then((()=>this.cache.clear("ratingSummary")))}sendTopicFeedback(t,e){return this.api.sendTopicFeedback(this.mapId,t,e)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}}class oi{constructor(t){this.store=t,this.reloadDebouncer=new n(10)}static build(t){return new oi((t=>Ge.get({name:"ft-reader-"+t,initialState:{baseUrl:void 0,apiIntegrationIdentifier:"ft-reader",mapId:void 0,visibleTopics:[],labels:{}},reducers:ti}))(t.trim()||"context"))}setBaseUrl(t){this.store.actions.setBaseUrl(t),this.initService()}setApiIntegrationIdentifier(t){this.store.actions.setApiIntegrationIdentifier(t),this.initService()}initService(){const t=this.store.getState();t.baseUrl&&t.apiIntegrationIdentifier?this.service=ri.build(t.baseUrl,t.apiIntegrationIdentifier,t.mapId,t.labels):this.service=void 0,this.reload()}setMapId(t){this.store.actions.setMapId(t),this.service&&(this.service.mapId=t),this.reload()}setVisibleTopics(t){this.store.actions.setVisibleTopics(t)}setLabels(t){this.store.actions.setLabels(t),this.service&&(this.service.labels=t)}async awaitService(){for(;null==this.service;)await c(5);return this.service}async navigateToTopic(t,e,i){const n=await this.awaitService();let r=await(null!=i?n.getPage(i):n.getPageByTocId(t));this.store.actions.setCurrentPage(r),this.store.actions.setScrollTarget({tocId:t,section:e})}async navigateToPage(t){const e=await this.awaitService();let i=await e.getPage(t);this.store.actions.setCurrentPage(i)}scrollDone(){this.store.actions.setScrollTarget({})}async reload(){var t,e;null===(t=this.service)||void 0===t||t.clear(),this.store.actions.setConfiguration(void 0),this.store.actions.setMap(void 0),this.store.actions.setToc(void 0),this.store.actions.setPagesToc(void 0),this.store.actions.setCurrentPage(void 0),(null===(e=this.service)||void 0===e?void 0:e.mapId)&&await this.reloadDebouncer.run((()=>this.fetchData()))}async fetchData(){var t,e,i,n,r;try{await Promise.all([null===(t=this.service)||void 0===t?void 0:t.getConfiguration().then((t=>this.store.actions.setConfiguration(t))),null===(e=this.service)||void 0===e?void 0:e.getMap().then((t=>this.store.actions.setMap(t))),null===(i=this.service)||void 0===i?void 0:i.getToc().then((t=>this.store.actions.setToc(t))),null===(n=this.service)||void 0===n?void 0:n.getPagesToc().then((t=>this.store.actions.setPagesToc(t))),null===(r=this.service)||void 0===r?void 0:r.getPaginationConfiguration().then((t=>this.store.actions.setPaginationConfiguration(t)))])}catch(t){this.errorHandler&&this.errorHandler(t)}}}const si=b`
92
+ `;class pt{constructor(t,e){this.defaultLabels=t,this.labels=e}resolve(t,...e){var i,n;t=this.resolvePluralKey(t,e);let r=null!==(n=null!==(i=this.labels[t])&&void 0!==i?i:this.defaultLabels[t])&&void 0!==n?n:"";return e.forEach(((t,e)=>r=r.replace(new RegExp(`\\{${e}([^}]*)\\}`,"g"),((e,i)=>this.formatValue(t,i))))),r}resolvePluralKey(t,e){for(let i of e)if("number"==typeof i){const e=`${t}[\\=${i}]`;if(e in this.labels||e in this.defaultLabels)return e}return t}formatValue(t,e){return t instanceof Date?this.formatDate(t,e):t}formatDate(t,e){const i=i=>(null==e?void 0:e.includes("date"))?t.toLocaleDateString(i):(null==e?void 0:e.includes("time"))?t.toLocaleTimeString(i):t.toLocaleString(i);try{return i(document.documentElement.lang)}catch(t){return i()}}}function bt(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];throw Error("[Immer] minified error nr: "+t+(i.length?" "+i.map((function(t){return"'"+t+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function wt(t){return!!t&&!!t[ne]}function yt(t){return!!t&&(function(t){if(!t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);if(null===e)return!0;var i=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return i===Object||"function"==typeof i&&Function.toString.call(i)===re}(t)||Array.isArray(t)||!!t[ie]||!!t.constructor[ie]||St(t)||jt(t))}function mt(t,e,i){void 0===i&&(i=!1),0===gt(t)?(i?Object.keys:oe)(t).forEach((function(n){i&&"symbol"==typeof n||e(n,t[n],t)})):t.forEach((function(i,n){return e(n,i,t)}))}function gt(t){var e=t[ne];return e?e.i>3?e.i-4:e.i:Array.isArray(t)?1:St(t)?2:jt(t)?3:0}function xt(t,e){return 2===gt(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Ot(t,e,i){var n=gt(t);2===n?t.set(e,i):3===n?(t.delete(e),t.add(i)):t[e]=i}function Et(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function St(t){return Yt&&t instanceof Map}function jt(t){return Qt&&t instanceof Set}function Nt(t){return t.o||t.t}function Ct(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var e=se(t);delete e[ne];for(var i=oe(e),n=0;n<i.length;n++){var r=i[n],o=e[r];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(e[r]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[r]})}return Object.create(Object.getPrototypeOf(t),e)}function Rt(t,e){return void 0===e&&(e=!1),Tt(t)||wt(t)||!yt(t)||(gt(t)>1&&(t.set=t.add=t.clear=t.delete=Mt),Object.freeze(t),e&&mt(t,(function(t,e){return Rt(e,!0)}),!0)),t}function Mt(){bt(2)}function Tt(t){return null==t||"object"!=typeof t||Object.isFrozen(t)}function At(t){var e=ue[t];return e||bt(18,t),e}function Ut(){return Xt}function $t(t,e){e&&(At("Patches"),t.u=[],t.s=[],t.v=e)}function kt(t){It(t),t.p.forEach(Ft),t.p=null}function It(t){t===Xt&&(Xt=t.l)}function Pt(t){return Xt={p:[],l:Xt,h:t,m:!0,_:0}}function Ft(t){var e=t[ne];0===e.i||1===e.i?e.j():e.O=!0}function Lt(t,e){e._=e.p.length;var i=e.p[0],n=void 0!==t&&t!==i;return e.h.g||At("ES5").S(e,t,n),n?(i[ne].P&&(kt(e),bt(4)),yt(t)&&(t=_t(e,t),e.l||Dt(e,t)),e.u&&At("Patches").M(i[ne].t,t,e.u,e.s)):t=_t(e,i,[]),kt(e),e.u&&e.v(e.u,e.s),t!==ee?t:void 0}function _t(t,e,i){if(Tt(e))return e;var n=e[ne];if(!n)return mt(e,(function(r,o){return Bt(t,n,e,r,o,i)}),!0),e;if(n.A!==t)return e;if(!n.P)return Dt(t,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var r=4===n.i||5===n.i?n.o=Ct(n.k):n.o;mt(3===n.i?new Set(r):r,(function(e,o){return Bt(t,n,r,e,o,i)})),Dt(t,r,!1),i&&t.u&&At("Patches").R(n,i,t.u,t.s)}return n.o}function Bt(t,e,i,n,r,o){if(wt(r)){var s=_t(t,r,o&&e&&3!==e.i&&!xt(e.D,n)?o.concat(n):void 0);if(Ot(i,n,s),!wt(s))return;t.m=!1}if(yt(r)&&!Tt(r)){if(!t.h.F&&t._<1)return;_t(t,r),e&&e.A.l||Dt(t,r)}}function Dt(t,e,i){void 0===i&&(i=!1),t.h.F&&t.m&&Rt(e,i)}function Wt(t,e){var i=t[ne];return(i?Nt(i):t)[e]}function Kt(t,e){if(e in t)for(var i=Object.getPrototypeOf(t);i;){var n=Object.getOwnPropertyDescriptor(i,e);if(n)return n;i=Object.getPrototypeOf(i)}}function Ht(t){t.P||(t.P=!0,t.l&&Ht(t.l))}function zt(t){t.o||(t.o=Ct(t.t))}function Vt(t,e,i){var n=St(e)?At("MapSet").N(e,i):jt(e)?At("MapSet").T(e,i):t.g?function(t,e){var i=Array.isArray(t),n={i:i?1:0,A:e?e.A:Ut(),P:!1,I:!1,D:{},l:e,t,k:null,o:null,j:null,C:!1},r=n,o=ae;i&&(r=[n],o=ce);var s=Proxy.revocable(r,o),u=s.revoke,a=s.proxy;return n.k=a,n.j=u,a}(e,i):At("ES5").J(e,i);return(i?i.A:Ut()).p.push(n),n}function Jt(t){return wt(t)||bt(22,t),function t(e){if(!yt(e))return e;var i,n=e[ne],r=gt(e);if(n){if(!n.P&&(n.i<4||!At("ES5").K(n)))return n.t;n.I=!0,i=Zt(e,r),n.I=!1}else i=Zt(e,r);return mt(i,(function(e,r){n&&function(t,e){return 2===gt(t)?t.get(e):t[e]}(n.t,e)===r||Ot(i,e,t(r))})),3===r?new Set(i):i}(t)}function Zt(t,e){switch(e){case 2:return new Map(t);case 3:return Array.from(t)}return Ct(t)}var qt,Xt,Gt="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),Yt="undefined"!=typeof Map,Qt="undefined"!=typeof Set,te="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,ee=Gt?Symbol.for("immer-nothing"):((qt={})["immer-nothing"]=!0,qt),ie=Gt?Symbol.for("immer-draftable"):"__$immer_draftable",ne=Gt?Symbol.for("immer-state"):"__$immer_state",re=""+Object.prototype.constructor,oe="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,se=Object.getOwnPropertyDescriptors||function(t){var e={};return oe(t).forEach((function(i){e[i]=Object.getOwnPropertyDescriptor(t,i)})),e},ue={},ae={get:function(t,e){if(e===ne)return t;var i=Nt(t);if(!xt(i,e))return function(t,e,i){var n,r=Kt(e,i);return r?"value"in r?r.value:null===(n=r.get)||void 0===n?void 0:n.call(t.k):void 0}(t,i,e);var n=i[e];return t.I||!yt(n)?n:n===Wt(t.t,e)?(zt(t),t.o[e]=Vt(t.A.h,n,t)):n},has:function(t,e){return e in Nt(t)},ownKeys:function(t){return Reflect.ownKeys(Nt(t))},set:function(t,e,i){var n=Kt(Nt(t),e);if(null==n?void 0:n.set)return n.set.call(t.k,i),!0;if(!t.P){var r=Wt(Nt(t),e),o=null==r?void 0:r[ne];if(o&&o.t===i)return t.o[e]=i,t.D[e]=!1,!0;if(Et(i,r)&&(void 0!==i||xt(t.t,e)))return!0;zt(t),Ht(t)}return t.o[e]===i&&"number"!=typeof i&&(void 0!==i||e in t.o)||(t.o[e]=i,t.D[e]=!0,!0)},deleteProperty:function(t,e){return void 0!==Wt(t.t,e)||e in t.t?(t.D[e]=!1,zt(t),Ht(t)):delete t.D[e],t.o&&delete t.o[e],!0},getOwnPropertyDescriptor:function(t,e){var i=Nt(t),n=Reflect.getOwnPropertyDescriptor(i,e);return n?{writable:!0,configurable:1!==t.i||"length"!==e,enumerable:n.enumerable,value:i[e]}:n},defineProperty:function(){bt(11)},getPrototypeOf:function(t){return Object.getPrototypeOf(t.t)},setPrototypeOf:function(){bt(12)}},ce={};mt(ae,(function(t,e){ce[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),ce.deleteProperty=function(t,e){return ce.set.call(this,t,e,void 0)},ce.set=function(t,e,i){return ae.set.call(this,t[0],e,i,t[0])};var le=function(){function t(t){var e=this;this.g=te,this.F=!0,this.produce=function(t,i,n){if("function"==typeof t&&"function"!=typeof i){var r=i;i=t;var o=e;return function(t){var e=this;void 0===t&&(t=r);for(var n=arguments.length,s=Array(n>1?n-1:0),u=1;u<n;u++)s[u-1]=arguments[u];return o.produce(t,(function(t){var n;return(n=i).call.apply(n,[e,t].concat(s))}))}}var s;if("function"!=typeof i&&bt(6),void 0!==n&&"function"!=typeof n&&bt(7),yt(t)){var u=Pt(e),a=Vt(e,t,void 0),c=!0;try{s=i(a),c=!1}finally{c?kt(u):It(u)}return"undefined"!=typeof Promise&&s instanceof Promise?s.then((function(t){return $t(u,n),Lt(t,u)}),(function(t){throw kt(u),t})):($t(u,n),Lt(s,u))}if(!t||"object"!=typeof t){if(void 0===(s=i(t))&&(s=t),s===ee&&(s=void 0),e.F&&Rt(s,!0),n){var l=[],h=[];At("Patches").M(t,s,l,h),n(l,h)}return s}bt(21,t)},this.produceWithPatches=function(t,i){if("function"==typeof t)return function(i){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return e.produceWithPatches(i,(function(e){return t.apply(void 0,[e].concat(r))}))};var n,r,o=e.produce(t,i,(function(t,e){n=t,r=e}));return"undefined"!=typeof Promise&&o instanceof Promise?o.then((function(t){return[t,n,r]})):[o,n,r]},"boolean"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var e=t.prototype;return e.createDraft=function(t){yt(t)||bt(8),wt(t)&&(t=Jt(t));var e=Pt(this),i=Vt(this,t,void 0);return i[ne].C=!0,It(e),i},e.finishDraft=function(t,e){var i=(t&&t[ne]).A;return $t(i,e),Lt(void 0,i)},e.setAutoFreeze=function(t){this.F=t},e.setUseProxies=function(t){t&&!te&&bt(20),this.g=t},e.applyPatches=function(t,e){var i;for(i=e.length-1;i>=0;i--){var n=e[i];if(0===n.path.length&&"replace"===n.op){t=n.value;break}}i>-1&&(e=e.slice(i+1));var r=At("Patches").$;return wt(t)?r(t,e):this.produce(t,(function(t){return r(t,e)}))},t}(),he=new le,fe=he.produce;he.produceWithPatches.bind(he),he.setAutoFreeze.bind(he),he.setUseProxies.bind(he),he.applyPatches.bind(he),he.createDraft.bind(he),he.finishDraft.bind(he);var de=fe;function ve(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function pe(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function be(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?pe(Object(i),!0).forEach((function(e){ve(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):pe(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function we(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var ye="function"==typeof Symbol&&Symbol.observable||"@@observable",me=function(){return Math.random().toString(36).substring(7).split("").join(".")},ge={INIT:"@@redux/INIT"+me(),REPLACE:"@@redux/REPLACE"+me(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+me()}};function xe(t){if("object"!=typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Oe(t,e,i){var n;if("function"==typeof e&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(we(0));if("function"==typeof e&&void 0===i&&(i=e,e=void 0),void 0!==i){if("function"!=typeof i)throw new Error(we(1));return i(Oe)(t,e)}if("function"!=typeof t)throw new Error(we(2));var r=t,o=e,s=[],u=s,a=!1;function c(){u===s&&(u=s.slice())}function l(){if(a)throw new Error(we(3));return o}function h(t){if("function"!=typeof t)throw new Error(we(4));if(a)throw new Error(we(5));var e=!0;return c(),u.push(t),function(){if(e){if(a)throw new Error(we(6));e=!1,c();var i=u.indexOf(t);u.splice(i,1),s=null}}}function f(t){if(!xe(t))throw new Error(we(7));if(void 0===t.type)throw new Error(we(8));if(a)throw new Error(we(9));try{a=!0,o=r(o,t)}finally{a=!1}for(var e=s=u,i=0;i<e.length;i++){(0,e[i])()}return t}function d(t){if("function"!=typeof t)throw new Error(we(10));r=t,f({type:ge.REPLACE})}function v(){var t,e=h;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(we(11));function i(){t.next&&t.next(l())}return i(),{unsubscribe:e(i)}}})[ye]=function(){return this},t}return f({type:ge.INIT}),(n={dispatch:f,subscribe:h,getState:l,replaceReducer:d})[ye]=v,n}function Ee(t){for(var e=Object.keys(t),i={},n=0;n<e.length;n++){var r=e[n];"function"==typeof t[r]&&(i[r]=t[r])}var o,s=Object.keys(i);try{!function(t){Object.keys(t).forEach((function(e){var i=t[e];if(void 0===i(void 0,{type:ge.INIT}))throw new Error(we(12));if(void 0===i(void 0,{type:ge.PROBE_UNKNOWN_ACTION()}))throw new Error(we(13))}))}(i)}catch(t){o=t}return function(t,e){if(void 0===t&&(t={}),o)throw o;for(var n=!1,r={},u=0;u<s.length;u++){var a=s[u],c=i[a],l=t[a],h=c(l,e);if(void 0===h)throw e&&e.type,new Error(we(14));r[a]=h,n=n||h!==l}return(n=n||s.length!==Object.keys(t).length)?r:t}}function Se(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce((function(t,e){return function(){return t(e.apply(void 0,arguments))}}))}function je(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return function(t){return function(){var i=t.apply(void 0,arguments),n=function(){throw new Error(we(15))},r={getState:i.getState,dispatch:function(){return n.apply(void 0,arguments)}},o=e.map((function(t){return t(r)}));return n=Se.apply(void 0,o)(i.dispatch),be(be({},i),{},{dispatch:n})}}}function Ne(t){return function(e){var i=e.dispatch,n=e.getState;return function(e){return function(r){return"function"==typeof r?r(i,n,t):e(r)}}}}var Ce=Ne();Ce.withExtraArgument=Ne;var Re,Me=Ce,Te=(Re=function(t,e){return Re=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},Re(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}Re(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),Ae=function(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t},Ue=Object.defineProperty,$e=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Pe=function(t,e,i){return e in t?Ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i},Fe=function(t,e){for(var i in e||(e={}))ke.call(e,i)&&Pe(t,i,e[i]);if($e)for(var n=0,r=$e(e);n<r.length;n++){i=r[n];Ie.call(e,i)&&Pe(t,i,e[i])}return t},Le="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Se:Se.apply(null,arguments)};var _e=function(t){function e(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];var r=t.apply(this,i)||this;return Object.setPrototypeOf(r,e.prototype),r}return Te(e,t),Object.defineProperty(e,Symbol.species,{get:function(){return e},enumerable:!1,configurable:!0}),e.prototype.concat=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return t.prototype.concat.apply(this,e)},e.prototype.prepend=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return 1===t.length&&Array.isArray(t[0])?new(e.bind.apply(e,Ae([void 0],t[0].concat(this)))):new(e.bind.apply(e,Ae([void 0],t.concat(this))))},e}(Array);function Be(t){return yt(t)?de(t,(function(){})):t}function De(){return function(t){return function(t){void 0===t&&(t={});var e=t.thunk,i=void 0===e||e;t.immutableCheck,t.serializableCheck;var n=new _e;i&&(!function(t){return"boolean"==typeof t}(i)?n.push(Me.withExtraArgument(i.extraArgument)):n.push(Me));return n}(t)}}function We(t){var e,i=De(),n=t||{},r=n.reducer,o=void 0===r?void 0:r,s=n.middleware,u=void 0===s?i():s,a=n.devTools,c=void 0===a||a,l=n.preloadedState,h=void 0===l?void 0:l,f=n.enhancers,d=void 0===f?void 0:f;if("function"==typeof o)e=o;else{if(!function(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);if(null===e)return!0;for(var i=e;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return e===i}(o))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');e=Ee(o)}var v=u;"function"==typeof v&&(v=v(i));var p=je.apply(void 0,v),b=Se;c&&(b=Le(Fe({trace:!1},"object"==typeof c&&c)));var w=[p];return Array.isArray(d)?w=Ae([p],d):"function"==typeof d&&(w=d(w)),Oe(e,h,b.apply(void 0,w))}function Ke(t,e){function i(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];if(e){var r=e.apply(void 0,i);if(!r)throw new Error("prepareAction did not return an object");return Fe(Fe({type:t,payload:r.payload},"meta"in r&&{meta:r.meta}),"error"in r&&{error:r.error})}return{type:t,payload:i[0]}}return i.toString=function(){return""+t},i.type=t,i.match=function(e){return e.type===t},i}function He(t){var e,i={},n=[],r={addCase:function(t,e){var n="string"==typeof t?t:t.type;if(n in i)throw new Error("addCase cannot be called with two reducers for the same action type");return i[n]=e,r},addMatcher:function(t,e){return n.push({matcher:t,reducer:e}),r},addDefaultCase:function(t){return e=t,r}};return t(r),[i,n,e]}function ze(t){var e=t.name;if(!e)throw new Error("`name` is a required option for createSlice");var i,n="function"==typeof t.initialState?t.initialState:Be(t.initialState),r=t.reducers||{},o=Object.keys(r),s={},u={},a={};function c(){var e="function"==typeof t.extraReducers?He(t.extraReducers):[t.extraReducers],i=e[0],r=void 0===i?{}:i,o=e[1],s=void 0===o?[]:o,a=e[2],c=void 0===a?void 0:a,l=Fe(Fe({},r),u);return function(t,e,i,n){void 0===i&&(i=[]);var r,o="function"==typeof e?He(e):[e,i,n],s=o[0],u=o[1],a=o[2];if(function(t){return"function"==typeof t}(t))r=function(){return Be(t())};else{var c=Be(t);r=function(){return c}}function l(t,e){void 0===t&&(t=r());var i=Ae([s[e.type]],u.filter((function(t){return(0,t.matcher)(e)})).map((function(t){return t.reducer})));return 0===i.filter((function(t){return!!t})).length&&(i=[a]),i.reduce((function(t,i){if(i){var n;if(wt(t))return void 0===(n=i(t,e))?t:n;if(yt(t))return de(t,(function(t){return i(t,e)}));if(void 0===(n=i(t,e))){if(null===t)return t;throw Error("A case reducer on a non-draftable value must not return undefined")}return n}return t}),t)}return l.getInitialState=r,l}(n,l,s,c)}return o.forEach((function(t){var i,n,o=r[t],c=e+"/"+t;"reducer"in o?(i=o.reducer,n=o.prepare):i=o,s[t]=i,u[c]=i,a[t]=n?Ke(c,n):Ke(c)})),{name:e,reducer:function(t,e){return i||(i=c()),i(t,e)},actions:a,caseReducers:s,getInitialState:function(){return i||(i=c()),i.getInitialState()}}}var Ve="listenerMiddleware";Ke(Ve+"/add"),Ke(Ve+"/removeAll"),Ke(Ve+"/remove"),function(){function t(t,e){var i=r[t];return i?i.enumerable=e:r[t]=i={configurable:!0,enumerable:e,get:function(){var e=this[ne];return ae.get(e,t)},set:function(e){var i=this[ne];ae.set(i,t,e)}},i}function e(t){for(var e=t.length-1;e>=0;e--){var r=t[e][ne];if(!r.P)switch(r.i){case 5:n(r)&&Ht(r);break;case 4:i(r)&&Ht(r)}}}function i(t){for(var e=t.t,i=t.k,n=oe(i),r=n.length-1;r>=0;r--){var o=n[r];if(o!==ne){var s=e[o];if(void 0===s&&!xt(e,o))return!0;var u=i[o],a=u&&u[ne];if(a?a.t!==s:!Et(u,s))return!0}}var c=!!e[ne];return n.length!==oe(e).length+(c?0:1)}function n(t){var e=t.k;if(e.length!==t.t.length)return!0;var i=Object.getOwnPropertyDescriptor(e,e.length-1);if(i&&!i.get)return!0;for(var n=0;n<e.length;n++)if(!e.hasOwnProperty(n))return!0;return!1}var r={};!function(t,e){ue[t]||(ue[t]=e)}("ES5",{J:function(e,i){var n=Array.isArray(e),r=function(e,i){if(e){for(var n=Array(i.length),r=0;r<i.length;r++)Object.defineProperty(n,""+r,t(r,!0));return n}var o=se(i);delete o[ne];for(var s=oe(o),u=0;u<s.length;u++){var a=s[u];o[a]=t(a,e||!!o[a].enumerable)}return Object.create(Object.getPrototypeOf(i),o)}(n,e),o={i:n?5:4,A:i?i.A:Ut(),P:!1,I:!1,D:{},l:i,t:e,k:r,o:null,O:!1,C:!1};return Object.defineProperty(r,ne,{value:o,writable:!0}),r},S:function(t,i,r){r?wt(i)&&i[ne].A===t&&e(t.p):(t.u&&function t(e){if(e&&"object"==typeof e){var i=e[ne];if(i){var r=i.t,o=i.k,s=i.D,u=i.i;if(4===u)mt(o,(function(e){e!==ne&&(void 0!==r[e]||xt(r,e)?s[e]||t(o[e]):(s[e]=!0,Ht(i)))})),mt(r,(function(t){void 0!==o[t]||xt(o,t)||(s[t]=!1,Ht(i))}));else if(5===u){if(n(i)&&(Ht(i),s.length=!0),o.length<r.length)for(var a=o.length;a<r.length;a++)s[a]=!1;else for(var c=r.length;c<o.length;c++)s[c]=!0;for(var l=Math.min(o.length,r.length),h=0;h<l;h++)o.hasOwnProperty(h)||(s[h]=!0),void 0===s[h]&&t(o[h])}}}}(t.p[0]),e(t.p))},K:function(t){return 4===t.i?i(t):n(t)}})}();const Je=t=>"object"==typeof t&&(0===Object.keys(t).length||"string"==typeof t.store||null!=t.selector||"function"==typeof t.hasChanged),Ze=(t,e)=>{var i;const n=Je(t)?t:{};return e=null!==(i=null!=e?e:n.hasChanged)&&void 0!==i?i:(t,e)=>!a(t,e),(i,r)=>{var o;i.constructor.createProperty(r,{attribute:!1,hasChanged:e});const s=i;s.reduxProperties=s.reduxProperties||new Map;const u=null!==(o=Je(t)?n.selector:t)&&void 0!==o?o:t=>t[r];s.reduxProperties.set(r,{selector:u,store:n.store})}};class qe extends vt{constructor(){super(...arguments),this.internalStoresUnsubscribers=new Map,this.internalStores=new Map}getUnnamedStore(){if(this.internalStores.size>1)throw new Error("Cannot resolve unnamed store when multiple stores are configured.");return[...this.internalStores.values()][0]}get store(){return this.getUnnamedStore()}set store(t){this.unsubscribeFromStores(),this.internalStores.clear(),t&&this.addStore(t)}getStore(t){var e;return null==t?null!==(e=this.getUnnamedStore())&&void 0!==e?e:this.store:this.internalStores.get(t)}addStore(t,e){e=null!=e?e:Xe(t)?t.name:"ft-lit-element-redux-default-store",this.unsubscribeFromStore(e),this.setupStore(e,t)}removeStore(t){const e="string"==typeof t?t:Xe(t)?t.name:"ft-lit-element-redux-default-store";this.unsubscribeFromStore(e),this.internalStores.delete(e)}setupStore(t,e){this.internalStores.set(t,e),this.updateFromStores(),this.subscribeToStore(t,e)}setupStores(){this.unsubscribeFromStores(),0===this.internalStores.size&&null!=this.store?this.addStore(this.store):(this.updateFromStores(),this.internalStores.forEach(((t,e)=>this.subscribeToStore(e,t))))}updateFromStores(){this.reduxProperties&&this.reduxProperties.forEach(((t,e)=>{const i=this.getStore(t.store);i&&(this[e]=t.selector(i.getState(),this))}))}subscribeToStore(t,e){this.internalStoresUnsubscribers.set(t,e.subscribe((()=>this.updateFromStores()))),this.onStoreAvailable(t)}unsubscribeFromStores(){Object.keys(this.internalStoresUnsubscribers).forEach((t=>this.unsubscribeFromStore(t)))}unsubscribeFromStore(t){this.internalStoresUnsubscribers.has(t)&&this.internalStoresUnsubscribers.get(t)(),this.internalStoresUnsubscribers.delete(t)}onStoreAvailable(t){}connectedCallback(){super.connectedCallback(),this.setupStores()}disconnectedCallback(){this.unsubscribeFromStores(),super.disconnectedCallback()}}function Xe(t){var e;return null===(e=t)||void 0===e?void 0:e.isFtReduxStore}class Ge{constructor(t,e){this.reduxSlice=t,this.reduxStore=e,this.isFtReduxStore=!0,this.actions=new Proxy(this.reduxSlice.actions,{get:(t,e,i)=>{const n=t[e];if(n)return(...t)=>{const e=n(...t);return this.reduxStore.dispatch(e),e}}})}static get(t){window.ftReduxStores||(window.ftReduxStores={});const e=window.ftReduxStores[t.name];if(Xe(e))return e;const i=ze(t);if(e)return new Ge(i,e);const n=We({reducer:i.reducer});return window.ftReduxStores[t.name]=new Ge(i,n)}get dispatch(){throw new Error("Don't use this method, actions are automatically dispatched when called.")}[Symbol.observable](){return this.reduxStore[Symbol.observable]()}getState(){return this.reduxStore.getState()}replaceReducer(t){throw new Error("Not implemented yet.")}subscribe(t){return this.reduxStore.subscribe(t)}get name(){return this.reduxSlice.name}get reducer(){return this.reduxSlice.reducer}get caseReducers(){return this.reduxSlice.caseReducers}getInitialState(){return this.reduxSlice.getInitialState()}}var Ye,Qe;navigator.vendor&&navigator.vendor.match(/apple/i)||(null===(Qe=null===(Ye=window.safari)||void 0===Ye?void 0:Ye.pushNotification)||void 0===Qe||Qe.toString());const ti={setBaseUrl:(t,e)=>{t.baseUrl=e.payload},setApiIntegrationIdentifier:(t,e)=>{t.apiIntegrationIdentifier=e.payload},setMapId:(t,e)=>{t.mapId=e.payload},setTocId:(t,e)=>{t.tocId=e.payload},setMap:(t,e)=>{t.map=e.payload},setToc:(t,e)=>{t.toc=e.payload},setPagesToc:(t,e)=>{t.pagesToc=e.payload},setPaginationConfiguration:(t,e)=>{t.paginationConfiguration=e.payload},setCurrentPage:(t,e)=>{t.currentPage=e.payload},setScrollTarget:(t,e)=>{t.scrollTarget=e.payload},setVisibleTopics:(t,e)=>{t.visibleTopics=e.payload},setLabels:(t,e)=>{t.labels=e.payload},setConfiguration:(t,e)=>{t.configuration=e.payload}},ei={topicMissingAdvice:"Sorry, this topic is missing",somethingWentWrong:"Oops, something went wrong"};class ii{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,e,i){return t.flatMap((t=>(t.pageConfiguration&&this.registerPage(this.buildPage(t,i)),null==t.tocId?this.extractPagesToc(t.children,e,i):[{tocId:t.tocId,title:t.title,depth:e,children:this.extractPagesToc(t.children,e+1,t.tocId)}])))}convertNodes(t,e,i){return t.flatMap((t=>{var n,r,o;if(null==t.tocId)return[...this.convertSectionNodes(null!==(n=t.pageToc)&&void 0!==n?n:[],e,t.tocId),...this.convertNodes(t.children,e,t.tocId)];let s=null===(r=t.prettyUrl)||void 0===r?void 0:r.replace(/^\//,"");const u={tocId:t.tocId,contentId:t.contentId,title:t.title,hasRating:t.hasRating,prettyUrl:s,depth:e,parentTocId:i,children:[]};this.register(u);const a=this.convertSectionNodes(null!==(o=t.pageToc)&&void 0!==o?o:[],e+1,t.tocId),c=this.convertNodes(t.children,e+1,u.tocId);return u.children=[...a,...c],[u]}))}convertSectionNodes(t,e,i){return t.flatMap((t=>{var n;let r=null===(n=t.prettyUrl)||void 0===n?void 0:n.replace(/^\//,"");const o={...t,prettyUrl:r,depth:e,parentTocId:i,children:[]};return this.register(o),o.children=this.convertSectionNodes(t.children,e+1,t.tocId),[o]}))}buildPage(t,e){var i,n,r,o,s,u;const a={number:this.pages.length+1,title:null!==(i=t.title)&&void 0!==i?i:"",rootTocId:null!==(n=t.tocId)&&void 0!==n?n:"root",toc:(null!==(r=t.pageToc)&&void 0!==r?r:[]).map((t=>this.nodeByTocId[t.tocId])),topics:[],hiddenTopics:[],breadcrumb:e?this.buildBreadcrumb(this.nodeByTocId[e]):[]},c=(t,e)=>(e?a.topics:a.hiddenTopics).push(t),l=null!==(s=null===(o=t.pageConfiguration)||void 0===o?void 0:o.parentsVisibility)&&void 0!==s?s:[];return a.breadcrumb.forEach(((t,e)=>{c(t,l[e])})),t.tocId&&c(t.tocId,t.pageConfiguration.isVisible),a.topics.push(...this.tocIds(null!==(u=t.pageToc)&&void 0!==u?u:[])),a}registerPage(t){for(let e of[...t.topics,...t.hiddenTopics])this.pageByTocId[e]||(this.pageByTocId[e]=t);this.pages.push(t)}tocIds(t){return t.flatMap((t=>[t.tocId,...this.tocIds(t.children)]))}buildBreadcrumb(t){const e=[t.tocId];for(;null==t?void 0:t.parentTocId;)e.unshift(t.parentTocId),t=this.nodeByTocId[t.parentTocId];return e}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 ni{convertPaginatedToc(t){return new ii(t).build()}}class ri{constructor(t,e,i,r,o,s){this.converter=t,this.api=e,this.cache=i,this.baseUrl=r,this.cleanSessionDebouncer=new n,this.labelResolver=new pt(ei,{}),r.endsWith("/")||(this.baseUrl=r+"/"),this.mapId=o,this.labels=null!=s?s:{},this.initCache()}static build(t,e,n,r){if(null==window.fluidtopics)throw console.error("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api"),new Error("Fluid Topics public API not found");const o=new window.fluidtopics.FluidTopicsApi(t,e,!0);return new ri(new ni,o,new i,t,n,r)}get mapId(){return this._mapId}set mapId(t){t!==this._mapId&&this.clear(),this._mapId=t}initCache(){this.cache.registerFinal("configuration",(()=>this.api.getReaderConfiguration())),this.cache.register("map",(()=>this.api.getMap(this.mapId))),this.cache.register("enrichedToc",(()=>this.api.getPages(this.mapId).then((t=>this.converter.convertPaginatedToc(t))))),this.cache.register("session",(async()=>{const t=await this.api.getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>this.cache.clear("session")),t.idleTimeoutInMillis),t})),this.cache.register("ratingSummary",(()=>this.api.getMapRating(this.mapId)))}clear(){this.cache.clearAll(),this.cleanSessionDebouncer.cancel()}getMap(){return this.cache.get("map")}getConfiguration(){return this.cache.get("configuration")}getSession(){return this.cache.get("session")}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 e;return null===(e=this.enrichedToc)||void 0===e?void 0:e.nodeByTocId[t]}async getPage(t){const e=await this.getEnrichedToc();return e.pages[t-1]||e.pages[0]}async getPageByTocId(t){const e=await this.getEnrichedToc();return e.pageByTocId[t]||e.pages[0]}getTopicInfo(t){return this.cache.get("topic-"+t,(()=>this.api.getTopic(this.mapId,t)))}getTopicContent(t){return this.cache.get("topic-content-"+t,(()=>this.api.getTopicHTMLContent(this.mapId,t,"DESIGNED_READER")))}getLink(t,e,i){const n=this.getNavigationData(t,e,i),r="r/"+(n.prettyUrl?n.prettyUrl:`${n.mapId}/${n.tocId}`),o=new URL(r,this.baseUrl);return null!=n.page&&o.searchParams.set("page",`${n.page}`),n.prettyUrlDuplicated&&o.searchParams.set("tocId",n.tocId),null!=n.section&&o.searchParams.set("section",n.section),o.href}getNavigationData(t,e,i){var n,r;t=t||"root";const o=this.enrichedToc,s=null==o?void 0:o.pageByTocId[t],u=null==o?void 0:o.nodeByTocId[t],a=null==u?void 0:u.prettyUrl;return{mapId:this.mapId,tocId:t,topicTitle:null!==(n=null==u?void 0:u.title)&&void 0!==n?n:"",page:e&&s&&s.number!==e?e:void 0,prettyUrl:null!=a?a.replace(/^r\//,""):void 0,prettyUrlDuplicated:null!==(r=null==o?void 0:o.duplicatedPrettyUrls.has(null!=a?a:""))&&void 0!==r&&r,section:i}}async getAccurateNavigationData(t,e,i){return await this.getEnrichedToc(),this.getNavigationData(t,e,i)}set labels(t){this.labelResolver=new pt(ei,t)}resolveLabel(t,...e){return this.labelResolver.resolve(t,e)}getRatingSummary(){return this.cache.get("ratingSummary")}getMapRating(){return this.getRatingSummary().then((t=>t.publication))}getTopicRating(t){return this.getRatingSummary().then((e=>{var i;return{type:e.topics.type,rating:null===(i=e.topics)||void 0===i?void 0:i.ratings.find((e=>e.tocId===t))}}))}rateMap(t,e){return this.api.rateMap(this.mapId,t,e).then((()=>this.clearRatingIfNecessary()))}unrateMap(){return this.api.unrateMap(this.mapId).then((()=>this.clearRatingIfNecessary()))}sendMapFeedback(t){return this.api.sendMapFeedback(this.mapId,t)}rateTopic(t,e,i){return this.api.rateTopic(this.mapId,t,e,i).then((()=>this.clearRatingIfNecessary()))}unrateTopic(t){return this.api.unrateTopic(this.mapId,t).then((()=>this.clearRatingIfNecessary()))}async clearRatingIfNecessary(){(await this.getSession()).sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(t,e){return this.api.sendTopicFeedback(this.mapId,t,e)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}}class oi{constructor(t){this.store=t,this.reloadDebouncer=new n(10)}static build(t){return new oi((t=>Ge.get({name:"ft-reader-"+t,initialState:{baseUrl:void 0,apiIntegrationIdentifier:"ft-reader",mapId:void 0,visibleTopics:[],labels:{}},reducers:ti}))(t.trim()||"context"))}setBaseUrl(t){this.store.actions.setBaseUrl(t),this.initService()}setApiIntegrationIdentifier(t){this.store.actions.setApiIntegrationIdentifier(t),this.initService()}initService(){const t=this.store.getState();t.baseUrl&&t.apiIntegrationIdentifier?this.service=ri.build(t.baseUrl,t.apiIntegrationIdentifier,t.mapId,t.labels):this.service=void 0,this.reload()}setMapId(t){this.store.actions.setMapId(t),this.service&&(this.service.mapId=t),this.reload()}setVisibleTopics(t){this.store.actions.setVisibleTopics(t)}setLabels(t){this.store.actions.setLabels(t),this.service&&(this.service.labels=t)}async awaitService(){for(;null==this.service;)await c(5);return this.service}async navigateToTopic(t,e,i){const n=await this.awaitService();let r=await(null!=i?n.getPage(i):n.getPageByTocId(t));this.store.actions.setCurrentPage(r),this.store.actions.setScrollTarget({tocId:t,section:e})}async navigateToPage(t){const e=await this.awaitService();let i=await e.getPage(t);this.store.actions.setCurrentPage(i)}scrollDone(){this.store.actions.setScrollTarget({})}async reload(){var t,e;null===(t=this.service)||void 0===t||t.clear(),this.store.actions.setConfiguration(void 0),this.store.actions.setMap(void 0),this.store.actions.setToc(void 0),this.store.actions.setPagesToc(void 0),this.store.actions.setCurrentPage(void 0),(null===(e=this.service)||void 0===e?void 0:e.mapId)&&await this.reloadDebouncer.run((()=>this.fetchData()))}async fetchData(){var t,e,i,n,r;try{await Promise.all([null===(t=this.service)||void 0===t?void 0:t.getConfiguration().then((t=>this.store.actions.setConfiguration(t))),null===(e=this.service)||void 0===e?void 0:e.getMap().then((t=>this.store.actions.setMap(t))),null===(i=this.service)||void 0===i?void 0:i.getToc().then((t=>this.store.actions.setToc(t))),null===(n=this.service)||void 0===n?void 0:n.getPagesToc().then((t=>this.store.actions.setPagesToc(t))),null===(r=this.service)||void 0===r?void 0:r.getPaginationConfiguration().then((t=>this.store.actions.setPaginationConfiguration(t)))])}catch(t){this.errorHandler&&this.errorHandler(t)}}}const si=b`
93
93
  `;var ui=function(t,e,i,n){for(var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,u=t.length-1;u>=0;u--)(r=t[u])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s};class ai extends CustomEvent{constructor(t,e){super("ft-reader-map-loaded",{detail:{map:t,toc:e}})}}class ci extends CustomEvent{constructor(t,e){super("ft-reader-visible-topics-change",{detail:{visibleTopics:e}})}}class li extends CustomEvent{constructor(t){super("ft-reader-navigation-done",{detail:t})}}class hi extends CustomEvent{constructor(t){super("ft-reader-load-error",{detail:t})}}class fi extends Event{constructor(){super("ft-reader-map-not-found")}}class di extends Event{constructor(){super("ft-reader-map-unauthorized")}}class vi extends qe{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-reader",this.labels={},this.visibleTopics=[],this.navigationDebouncer=new n(5)}render(){return V`
94
94
  ${this.importStyleIfNeeded()}
95
95
  <slot @register-ft-reader-component=${this.registerComponent}></slot>
@@ -48,6 +48,7 @@ class EnrichedTocBuilder {
48
48
  tocId: node.tocId,
49
49
  contentId: node.contentId,
50
50
  title: node.title,
51
+ hasRating: node.hasRating,
51
52
  prettyUrl,
52
53
  depth,
53
54
  parentTocId: parentTocId,
@@ -68,9 +69,7 @@ class EnrichedTocBuilder {
68
69
  var _a;
69
70
  let prettyUrl = (_a = node.prettyUrl) === null || _a === void 0 ? void 0 : _a.replace(/^\//, "");
70
71
  const enrichedNode = {
71
- tocId: node.tocId,
72
- contentId: node.contentId,
73
- title: node.title,
72
+ ...node,
74
73
  prettyUrl,
75
74
  depth,
76
75
  parentTocId,
@@ -50,6 +50,7 @@ export declare class FtReaderService {
50
50
  sendMapFeedback(message: string): Promise<void>;
51
51
  rateTopic(tocId: string, type: FtRatingType, value: number): Promise<void>;
52
52
  unrateTopic(tocId: string): Promise<void>;
53
+ private clearRatingIfNecessary;
53
54
  sendTopicFeedback(tocId: string, message: string): Promise<void>;
54
55
  fontsStylesheet(): string;
55
56
  themeStylesheet(): string;
@@ -157,19 +157,25 @@ export class FtReaderService {
157
157
  });
158
158
  }
159
159
  rateMap(type, value) {
160
- return this.api.rateMap(this.mapId, type, value).then(() => this.cache.clear("ratingSummary"));
160
+ return this.api.rateMap(this.mapId, type, value).then(() => this.clearRatingIfNecessary());
161
161
  }
162
162
  unrateMap() {
163
- return this.api.unrateMap(this.mapId).then(() => this.cache.clear("ratingSummary"));
163
+ return this.api.unrateMap(this.mapId).then(() => this.clearRatingIfNecessary());
164
164
  }
165
165
  sendMapFeedback(message) {
166
166
  return this.api.sendMapFeedback(this.mapId, message);
167
167
  }
168
168
  rateTopic(tocId, type, value) {
169
- return this.api.rateTopic(this.mapId, tocId, type, value).then(() => this.cache.clear("ratingSummary"));
169
+ return this.api.rateTopic(this.mapId, tocId, type, value).then(() => this.clearRatingIfNecessary());
170
170
  }
171
171
  unrateTopic(tocId) {
172
- return this.api.unrateTopic(this.mapId, tocId).then(() => this.cache.clear("ratingSummary"));
172
+ return this.api.unrateTopic(this.mapId, tocId).then(() => this.clearRatingIfNecessary());
173
+ }
174
+ async clearRatingIfNecessary() {
175
+ const ftSession = await this.getSession();
176
+ if (ftSession.sessionAuthenticated) {
177
+ this.cache.clear("ratingSummary");
178
+ }
173
179
  }
174
180
  sendTopicFeedback(tocId, message) {
175
181
  return this.api.sendTopicFeedback(this.mapId, tocId, message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-reader-context",
3
- "version": "0.3.55",
3
+ "version": "0.3.57",
4
4
  "description": "Context block for integrated reader components",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,7 +19,7 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-wc-utils": "0.3.55",
22
+ "@fluid-topics/ft-wc-utils": "0.3.57",
23
23
  "@reduxjs/toolkit": "^1.6.2",
24
24
  "lit": "2.2.8"
25
25
  },
@@ -29,5 +29,5 @@
29
29
  "peerDependencies": {
30
30
  "@fluid-topics/public-api": "1.0.30"
31
31
  },
32
- "gitHead": "4106f01e238edeb1c85fba22d6d50a18757e0b3e"
32
+ "gitHead": "1c7db3887ac108c59c27a6b4af04dd6f1ecd061b"
33
33
  }