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