@fluid-topics/ft-reader-content 2.1.1 → 2.1.3
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.
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
`;var At=v(F()),Oe=v(K()),M=v(T());var H=v(T());var Xn=v(T()),Ka={setTranslationDestinationLanguage:(r,e)=>{r.translation.destinationLanguage=e.payload},setTranslationSourceLanguage:(r,e)=>{r.translation.sourceLanguage=e.payload},setTranslationProfileId:(r,e)=>{r.translation.profileId=e.payload},setTranslationLoading:(r,e)=>{r.translation.isLoading=e.payload},setTranslationError:(r,e)=>{r.translation.isError=e.payload},setTopicsRating:(r,e)=>{for(let t in e.payload)r.topicsRating[t]=e.payload[t]}},Zn=r=>Xn.FtReduxStore.get({name:"ft-reader-"+r,initialState:{mapId:void 0,renderedTopics:[],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,mapRating:void 0,topicsRating:{},translation:{sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1},linkPreviewDialogId:void 0},reducers:Ka});var _r=class{constructor(e,t){this.mapId=e,this.paginatedToc=t,this.nodeByTocId={},this.nodeByUrl={},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,nodeByUrl:this.nodeByUrl,duplicatedPrettyUrls:this.duplicatedPrettyUrls,pages:this.pages,pageByTocId:this.pageByTocId,translationError:this.paginatedToc.translationError}}extractPagesToc(e,t,n){return e.flatMap(i=>{var s;return i.pageConfiguration&&this.registerPage(this.buildPage(i,n)),i.tocId==null?this.extractPagesToc(i.children,t,n):[{tocId:i.tocId,title:(s=i.title)!==null&&s!==void 0?s:"",untranslatedTitle:i.untranslatedTitle,depth:t,children:this.extractPagesToc(i.children,t+1,i.tocId)}]})}convertNodes(e,t,n){return e.flatMap(i=>{var s,a,o;if(i.tocId==null)return[...this.convertSectionNodes((s=i.pageToc)!==null&&s!==void 0?s:[],t,i.tocId),...this.convertNodes(i.children,t,i.tocId)];let c=(a=i.prettyUrl)===null||a===void 0?void 0:a.replace(/^\//,""),l={tocId:i.tocId,contentId:i.contentId,title:i.title,untranslatedTitle:i.untranslatedTitle,hasRating:i.hasRating,origin:i.origin,prettyUrl:c,depth:t,parentTocId:n,children:[]};this.register(l);let u=this.convertSectionNodes((o=i.pageToc)!==null&&o!==void 0?o:[],t+1,i.tocId),d=this.convertNodes(i.children,t+1,l.tocId);return l.children=[...u,...d],[l]})}convertSectionNodes(e,t,n){return e.flatMap(i=>{var s;let a=(s=i.prettyUrl)===null||s===void 0?void 0:s.replace(/^\//,""),o={...i,prettyUrl:a,depth:t,parentTocId:n,children:[]};return this.register(o),o.children=this.convertSectionNodes(i.children,t+1,i.tocId),[o]})}buildPage(e,t){var n,i,s,a,o,c,l,u;let d={number:this.pages.length+1,title:(n=e.title)!==null&&n!==void 0?n:"",untranslatedTitle:e.untranslatedTitle,rootTocId:(a=(i=e.tocId)!==null&&i!==void 0?i:(s=e.pageToc)===null||s===void 0?void 0:s[0].tocId)!==null&&a!==void 0?a:"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]):[]},h=(p,g)=>(g?d.topics:d.hiddenTopics).push(p),f=(l=(c=e.pageConfiguration)===null||c===void 0?void 0:c.parentsVisibility)!==null&&l!==void 0?l:[];return d.breadcrumb.forEach((p,g)=>{h(p,f[g])}),e.tocId&&h(e.tocId,e.pageConfiguration.isVisible),d.topics.push(...this.tocIds((u=e.pageToc)!==null&&u!==void 0?u:[])),d}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.nodeByUrl[e.prettyUrl]==null?this.nodeByUrl[e.prettyUrl]=e:this.duplicatedPrettyUrls.add(e.prettyUrl)),this.nodeByUrl[`${this.mapId}/${e.tocId}`]=e,this.nodeByTocId[e.tocId]=e}},Ot=class{convertPaginatedToc(e,t){return new _r(e,t).build()}};var ei;(function(r){r.black="black",r.green="green",r.blue="blue",r.purple="purple",r.red="red",r.orange="orange",r.yellow="yellow"})(ei||(ei={}));var ti;(function(r){r.OFFICIAL="OFFICIAL",r.PERSONAL="PERSONAL",r.SHARED="SHARED"})(ti||(ti={}));var ri;(function(r){r.STRUCTURED_DOCUMENT="STRUCTURED_DOCUMENT",r.UNSTRUCTURED_DOCUMENT="UNSTRUCTURED_DOCUMENT",r.SHARED_PERSONAL_BOOK="SHARED_PERSONAL_BOOK",r.PERSONAL_BOOK="PERSONAL_BOOK",r.ATTACHMENT="ATTACHMENT",r.RESOURCE="RESOURCE",r.HTML_PACKAGE="HTML_PACKAGE"})(ri||(ri={}));var ni;(function(r){r.STRUCTURED_DOCUMENT="STRUCTURED_DOCUMENT",r.UNSTRUCTURED_DOCUMENT="UNSTRUCTURED_DOCUMENT",r.SHARED_PERSONAL_BOOK="SHARED_PERSONAL_BOOK",r.PERSONAL_BOOK="PERSONAL_BOOK",r.ATTACHMENT="ATTACHMENT",r.RESOURCE="RESOURCE",r.HTML_PACKAGE="HTML_PACKAGE"})(ni||(ni={}));var ii;(function(r){r.LAST_WEEK="LAST_WEEK",r.LAST_MONTH="LAST_MONTH",r.LAST_QUARTER="LAST_QUARTER",r.LAST_YEAR="LAST_YEAR"})(ii||(ii={}));var si;(function(r){r.VALUE="VALUE",r.DATE="DATE",r.RANGE="RANGE"})(si||(si={}));var Lt;(function(r){r.OFFICIAL="OFFICIAL",r.AI="AI"})(Lt||(Lt={}));var ai;(function(r){r.BOOKMARK__CREATE="BOOKMARK__CREATE",r.BOOKMARK__DELETE="BOOKMARK__DELETE",r.CASE_DEFLECTION__START="CASE_DEFLECTION__START",r.CASE_DEFLECTION__OPEN_TICKET="CASE_DEFLECTION__OPEN_TICKET",r.CASE_DEFLECTION__RATE="CASE_DEFLECTION__RATE",r.CHATBOT__RATE="CHATBOT__RATE",r.COLLECTION__CREATE="COLLECTION__CREATE",r.COLLECTION__UPDATE="COLLECTION__UPDATE",r.COLLECTION__DELETE="COLLECTION__DELETE",r.CUSTOM_EVENT__TRIGGER="CUSTOM_EVENT__TRIGGER",r.DOCUMENT__ON_DEMAND_TRANSLATE="DOCUMENT__ON_DEMAND_TRANSLATE",r.DOCUMENT__DOWNLOAD="DOCUMENT__DOWNLOAD",r.DOCUMENT__PRINT="DOCUMENT__PRINT",r.DOCUMENT__PROCESS="DOCUMENT__PROCESS",r.DOCUMENT__RATE="DOCUMENT__RATE",r.DOCUMENT__SEARCH="DOCUMENT__SEARCH",r.DOCUMENT__START_DISPLAY="DOCUMENT__START_DISPLAY",r.DOCUMENT__UNRATE="DOCUMENT__UNRATE",r.FEEDBACK__SEND="FEEDBACK__SEND",r.AI__COMPLETED_QUERY="AI__COMPLETED_QUERY",r.AI__RATE="AI__RATE",r.AI_CASE_DEFLECTION__START="AI_CASE_DEFLECTION__START",r.AI_CASE_DEFLECTION__OPEN_TICKET="AI_CASE_DEFLECTION__OPEN_TICKET",r.KHUB__PROCESS="KHUB__PROCESS",r.KHUB__SEARCH="KHUB__SEARCH",r.LABELS__DOWNLOAD="LABELS__DOWNLOAD",r.LINK__SHARE="LINK__SHARE",r.PAGE__DISPLAY="PAGE__DISPLAY",r.PERSONAL_BOOK__CREATE="PERSONAL_BOOK__CREATE",r.PERSONAL_BOOK__DELETE="PERSONAL_BOOK__DELETE",r.PERSONAL_BOOK__UPDATE="PERSONAL_BOOK__UPDATE",r.PERSONAL_TOPIC__CREATE="PERSONAL_TOPIC__CREATE",r.PERSONAL_TOPIC__UPDATE="PERSONAL_TOPIC__UPDATE",r.PERSONAL_TOPIC__DELETE="PERSONAL_TOPIC__DELETE",r.SAVED_SEARCH__CREATE="SAVED_SEARCH__CREATE",r.SAVED_SEARCH__DELETE="SAVED_SEARCH__DELETE",r.SAVED_SEARCH__UPDATE="SAVED_SEARCH__UPDATE",r.SEARCH_PAGE__SELECT="SEARCH_PAGE__SELECT",r.SEARCH_RESULT__OPEN_BROWSER_CONTEXT_MENU="SEARCH_RESULT__OPEN_BROWSER_CONTEXT_MENU",r.TOPIC__AI_TRANSLATE="TOPIC__AI_TRANSLATE",r.TOPIC__RATE="TOPIC__RATE",r.TOPIC__START_DISPLAY="TOPIC__START_DISPLAY",r.TOPIC__UNRATE="TOPIC__UNRATE",r.USER__LOGIN="USER__LOGIN",r.USER__LOGOUT="USER__LOGOUT",r.HEARTBEAT="HEARTBEAT"})(ai||(ai={}));var oi;(function(r){r.STANDARD="STANDARD",r.STRUCTURAL="STRUCTURAL"})(oi||(oi={}));var ci;(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"})(ci||(ci={}));var li;(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",r.SEARCH_ANNOUNCEMENT="SEARCH_ANNOUNCEMENT",r.LINK_PREVIEW="LINK_PREVIEW",r.UD_VIEWER="UD_VIEWER",r.ASSET_VIEWER="ASSET_VIEWER"})(li||(li={}));var ui;(function(r){r.CLASSIC="CLASSIC",r.CUSTOM="CUSTOM",r.DESIGNER="DESIGNER"})(ui||(ui={}));var di;(function(r){r.AND="AND",r.OR="OR",r.MONOVALUED="MONOVALUED"})(di||(di={}));var hi;(function(r){r.NONE="NONE",r.ALPHABET="ALPHABET",r.VERSION="VERSION"})(hi||(hi={}));var pi;(function(r){r.STARS="STARS",r.LIKE="LIKE",r.DICHOTOMOUS="DICHOTOMOUS",r.NO_RATING="NO_RATING"})(pi||(pi={}));var fi;(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"})(fi||(fi={}));var mi;(function(r){r.OPTIONAL="OPTIONAL",r.MANDATORY="MANDATORY"})(mi||(mi={}));var gi;(function(r){r.ASC="ASC",r.DESC="DESC"})(gi||(gi={}));var vi;(function(r){r.ALPHA="ALPHA",r.NATURAL="NATURAL"})(vi||(vi={}));var yi;(function(r){r.EVERYWHERE="EVERYWHERE",r.TITLE_ONLY="TITLE_ONLY",r.NONE="NONE"})(yi||(yi={}));var bi;(function(r){r.ARTICLE="ARTICLE",r.BOOK="BOOK",r.SHARED_BOOK="SHARED_BOOK",r.HTML_PACKAGE="HTML_PACKAGE"})(bi||(bi={}));var Si;(function(r){r.FLUIDTOPICS="FLUIDTOPICS",r.EXTERNAL="EXTERNAL"})(Si||(Si={}));var Ai;(function(r){r.MAP="MAP",r.DOCUMENT="DOCUMENT",r.TOPIC="TOPIC",r.PERSONAL_BOOK="PERSONAL_BOOK",r.SHARED_BOOK="SHARED_BOOK",r.HTML_PACKAGE="HTML_PACKAGE"})(Ai||(Ai={}));var Ei;(function(r){r.LAST_WEEK="LAST_WEEK",r.LAST_MONTH="LAST_MONTH",r.LAST_QUARTER="LAST_QUARTER",r.LAST_YEAR="LAST_YEAR"})(Ei||(Ei={}));var Ti;(function(r){r.MAP="MAP",r.DOCUMENT="DOCUMENT",r.TOPIC="TOPIC",r.HTML_PACKAGE="HTML_PACKAGE",r.HTML_PACKAGE_PAGE="HTML_PACKAGE_PAGE"})(Ti||(Ti={}));var xi;(function(r){r.DEFAULT="DEFAULT",r.DOCUMENTS="DOCUMENTS",r.ALL_TOPICS="ALL_TOPICS",r.TOPICS_AND_UNSTRUCTURED_DOCUMENTS="TOPICS_AND_UNSTRUCTURED_DOCUMENTS"})(xi||(xi={}));var Ci;(function(r){r.PLAIN_TEXT="PLAIN_TEXT",r.LOCALIZED_OFFICIAL="LOCALIZED_OFFICIAL",r.LOCALIZED_CUSTOM="LOCALIZED_CUSTOM"})(Ci||(Ci={}));var C;(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.GENERATIVE_AI_EXPORT_USER="GENERATIVE_AI_EXPORT_USER",r.CONTENT_PUBLISHER="CONTENT_PUBLISHER",r.BEHAVIOR_DATA_USER="BEHAVIOR_DATA_USER",r.ANNOUNCEMENT_ADMIN="ANNOUNCEMENT_ADMIN",r.KHUB_ADMIN="KHUB_ADMIN",r.USERS_ADMIN="USERS_ADMIN",r.PORTAL_ADMIN="PORTAL_ADMIN",r.ADMIN="ADMIN"})(C||(C={}));var Y;(function(r){r.SEARCHES="SEARCHES",r.BOOKMARKS="BOOKMARKS",r.BOOKS="BOOKS",r.COLLECTIONS="COLLECTIONS"})(Y||(Y={}));var wi;(function(r){r.UNAUTHENTICATED="UNAUTHENTICATED",r.USER_INCOMPLETE="USER_INCOMPLETE",r.MFA_REQUIRED="MFA_REQUIRED",r.AUTHENTICATED="AUTHENTICATED"})(wi||(wi={}));var Ii;(function(r){r.UNREACHABLE="UNREACHABLE",r.UNAUTHORIZED="UNAUTHORIZED",r.FORBIDDEN="FORBIDDEN",r.INCOMPATIBLE="INCOMPATIBLE",r.FAILED="FAILED",r.OK="OK"})(Ii||(Ii={}));var _i;(function(r){r.VALID="VALID",r.INVALID="INVALID"})(_i||(_i={}));var Ri;(function(r){r.INACCURATE="INACCURATE",r.INCOMPLETE="INCOMPLETE",r.OFF_TOPIC="OFF_TOPIC",r.IRRELEVANT_SOURCES="IRRELEVANT_SOURCES",r.SUMMARY="SUMMARY",r.SEMANTIC_SEARCH="SEMANTIC_SEARCH",r.CHATBOT_INSTRUCTIONS="CHATBOT_INSTRUCTIONS",r.OTHER="OTHER"})(Ri||(Ri={}));var Oi;(function(r){r.INACCURATE="INACCURATE",r.INCOMPLETE="INCOMPLETE",r.OFF_TOPIC="OFF_TOPIC",r.IRRELEVANT_SOURCES="IRRELEVANT_SOURCES",r.SLOW="SLOW",r.OTHER="OTHER"})(Oi||(Oi={}));var Li;(function(r){r.JSON="JSON",r.TEXT="TEXT"})(Li||(Li={}));var Mi;(function(r){r.JSON="JSON",r.TEXT="TEXT"})(Mi||(Mi={}));var Pi;(function(r){r.TEXT="TEXT",r.HTML="HTML"})(Pi||(Pi={}));var Ni;(function(r){r.IN_PROGRESS="IN_PROGRESS",r.ERROR="ERROR",r.DONE="DONE"})(Ni||(Ni={}));var Di;(function(r){r.HTML="HTML",r.MARKDOWN="MARKDOWN"})(Di||(Di={}));var ki;(function(r){r.SOURCES="SOURCES",r.ENRICH_AND_CLEAN="ENRICH_AND_CLEAN",r.VOCABULARIES="VOCABULARIES",r.METADATA="METADATA",r.PRETTY_URL="PRETTY_URL",r.ACCESS_RULE="ACCESS_RULE",r.DESIGNED_PAGES="DESIGNED_PAGES",r.THEME_STUDIO="THEME_STUDIO",r.PORTAL_GENERAL="PORTAL_GENERAL",r.ASSETS="ASSETS",r.CODE_LIBRARY="CODE_LIBRARY",r.THEME="THEME",r.CONTENT_STYLES="CONTENT_STYLES",r.HOMEPAGE="HOMEPAGE",r.CLASSIC_SEARCH_PAGE="CLASSIC_SEARCH_PAGE",r.CLASSIC_READER_PAGE="CLASSIC_READER_PAGE",r.PORTAL_METADATA="PORTAL_METADATA",r.LANGUAGES="LANGUAGES",r.PRINT_TEMPLATES="PRINT_TEMPLATES",r.OFFLINE="OFFLINE",r.CUSTOM_JS="CUSTOM_JS",r.CONFIDENTIALITY="CONFIDENTIALITY",r.NOTIFICATIONS="NOTIFICATIONS"})(ki||(ki={}));var Ui;(function(r){r.MAP="MAP",r.UNSTRUCTURED_DOCUMENT="UNSTRUCTURED_DOCUMENT"})(Ui||(Ui={}));var qa={[C.PERSONAL_BOOK_SHARE_USER]:[C.PERSONAL_BOOK_USER],[C.HTML_EXPORT_USER]:[C.PERSONAL_BOOK_USER],[C.PDF_EXPORT_USER]:[C.PERSONAL_BOOK_USER],[C.KHUB_ADMIN]:[C.CONTENT_PUBLISHER],[C.ADMIN]:[C.KHUB_ADMIN,C.USERS_ADMIN,C.PORTAL_ADMIN,C.BEHAVIOR_DATA_USER],[C.GENERATIVE_AI_EXPORT_USER]:[C.GENERATIVE_AI_USER]};function Fi(r,e){return r===e||(qa[r]??[]).some(t=>Fi(t,e))}function oe(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(n=>Fi(n,e))}var en=v(K());var $i=v(K(),1);var Rr=r=>e=>{window.customElements.get(r)||window.customElements.define(r,e)};function ji(r,e){return(0,$i.property)({type:Object,converter:{fromAttribute:t=>{if(t==null)return ht(r);try{return JSON.parse(t)}catch{return ht(r)}},toAttribute:t=>JSON.stringify(t)},hasChanged:pt,...e??{}})}function za(r,e){if(r===e)return!0;if(r&&e&&typeof r=="object"&&typeof e=="object"){if(r.constructor!==e.constructor)return!1;let t,n;if(Array.isArray(r)){if(t=r.length,t!=e.length)return!1;for(n=t;n--!==0;)if(!Mt(r[n],e[n]))return!1;return!0}if(r instanceof Map&&e instanceof Map){if(r.size!==e.size)return!1;for(n of r.entries())if(!e.has(n[0]))return!1;for(n of r.entries())if(!Mt(n[1],e.get(n[0])))return!1;return!0}if(r instanceof Set&&e instanceof Set){if(r.size!==e.size)return!1;for(n of r.entries())if(!e.has(n[0]))return!1;return!0}if(r.constructor===RegExp)return r.source===e.source&&r.flags===e.flags;if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===e.valueOf();let i=a=>Object.keys(a).filter(o=>a[o]!=null),s=i(r);if(t=s.length,t!==i(e).length)return!1;for(n=t;n--!==0;)if(!Object.prototype.hasOwnProperty.call(e,s[n]))return!1;for(n=t;n--!==0;){let a=s[n];if(!Mt(r[a],e[a]))return!1}return!0}return r!==r&&e!==e||r==null&&e==null}function Mt(r,e){try{return za(r,e)}catch{return!1}}function pt(r,e){return!Mt(r,e)}function ht(r){return typeof window.structuredClone=="function"?structuredClone(r):r!=null?JSON.parse(JSON.stringify(r)):r}function Pt(r,e){let t=n=>n[r]===!0;return n=>{if(t(n))return n;let i=e(n);return i[r]=!0,i}}var Bi=v(K(),1);var Or=r=>{let e=r??{};return(t,n)=>{var i;let s={hasChanged:pt,attribute:!1,...e};(0,Bi.property)(s)(t,n);let a=t.constructor;a.reduxProperties=new Map(a.reduxProperties),a.reduxProperties.set(n,{selector:(i=e.selector)!==null&&i!==void 0?i:(o=>o[n]),store:e.store})}};var Nt=class{constructor(){this.queue=[]}add(e,t=!1){t&&this.clear(e.type),this.queue.push(e)}consume(e){let t=this.queue.find(n=>n.type===e);return t&&(this.queue=this.queue.filter(n=>n!==t)),t}clear(e){typeof e=="string"?this.queue=this.queue.filter(t=>t.type!==e):this.queue=this.queue.filter(t=>!e.test(t.type))}};var Ae=v(K(),1);var Dt=class{constructor(e=0){this.timeout=e,this.callbacks=[]}run(e,t){return this.callbacks=[e],this.debounce(t)}queue(e,t){return this.callbacks.push(e),this.debounce(t)}cancel(){this.clearTimeout(),this.resolvePromise&&this.resolvePromise(!1),this.clearPromise()}debounce(e){return this.promise==null&&(this.promise=new Promise((t,n)=>{this.resolvePromise=t,this.rejectPromise=n})),this.clearTimeout(),this._debounce=window.setTimeout(()=>this.runCallbacks(),e??this.timeout),this.promise}async runCallbacks(){var e,t;let n=[...this.callbacks];this.callbacks=[];let i=(e=this.rejectPromise)!==null&&e!==void 0?e:(()=>null),s=(t=this.resolvePromise)!==null&&t!==void 0?t:(()=>null);this.clearPromise();for(let a of n)try{await a()}catch(o){i(o);return}s(!0)}clearTimeout(){this._debounce!=null&&window.clearTimeout(this._debounce)}clearPromise(){this.promise=void 0,this.resolvePromise=void 0,this.rejectPromise=void 0}};var Vi=v(F(),1);var kt=globalThis,Wa=kt.ShadowRoot&&(kt.ShadyCSS===void 0||kt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype;var Hi=(r,e)=>{if(Wa)r.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(let t of e){let n=document.createElement("style"),i=kt.litNonce;i!==void 0&&n.setAttribute("nonce",i),n.textContent=t.cssText,r.appendChild(n)}};var Ut=class extends Vi.LitElement{get scopedRegistryConstructor(){return this.constructor}createRenderRoot(){let e=this.scopedRegistryConstructor;e.elementDefinitions&&!e.registry&&(e.registry=new CustomElementRegistry,e.defineScopedElements(e.elementDefinitions));let t={...e.shadowRootOptions,customElements:e.registry},n=this.renderOptions.creationScope=this.attachShadow(t);return Hi(n,e.elementStyles),n}static canDefineScopedElement(e){return!!this.registry&&!this.registry.get(e)}static defineScopedElements(e){Object.entries(e).forEach(([t,n])=>this.defineScopedElement(t,n))}static defineScopedElement(e,t){Rr(e)(t),this.canDefineScopedElement(e)&&this.registry.define(e,t)}canDefineScopedElement(e){return this.scopedRegistryConstructor.canDefineScopedElement(e)}defineScopedElements(e){this.scopedRegistryConstructor.defineScopedElements(e)}defineScopedElement(e,t){this.scopedRegistryConstructor.defineScopedElement(e,t)}};function Ki(r,e,...t){var n;let i=r.querySelector(e);for(let s of t)i=(n=i?.shadowRoot)===null||n===void 0?void 0:n.querySelector(s);return i}var Be=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Gi,qi=Symbol("constructorPrototype"),zi=Symbol("constructorName"),Yi=Symbol("exportpartsDebouncer"),Wi=Symbol("dynamicDependenciesLoaded"),je=class r extends CustomEvent{constructor(){super(r.eventName,{bubbles:!0})}};je.eventName="exportparts-updated";var ne=class extends Ut{constructor(){super(),this.useAdoptedStyleSheets=!0,this.adoptedCustomStyleSheet=new CSSStyleSheet,this[Gi]=new Dt(5),this.scheduleExportpartsUpdate=()=>{var e,t,n;(!((e=this.exportpartsPrefix)===null||e===void 0)&&e.trim()||(n=(t=this.exportpartsPrefixes)===null||t===void 0?void 0:t.length)!==null&&n!==void 0&&n)&&this[Yi].run(()=>{var i,s;!((i=this.exportpartsPrefix)===null||i===void 0)&&i.trim()?this.setExportpartsAttribute([this.exportpartsPrefix]):this.exportpartsPrefixes!=null&&((s=this.exportpartsPrefixes)===null||s===void 0?void 0:s.length)>0&&this.setExportpartsAttribute(this.exportpartsPrefixes)})},this[zi]=this.constructor.name,this[qi]=this.constructor.prototype}adoptedCallback(){this.constructor.name!==this[zi]&&Object.setPrototypeOf(this,this[qi])}connectedCallback(){var e;super.connectedCallback();try{this.shadowRoot&&!this.shadowRoot.adoptedStyleSheets.includes(this.adoptedCustomStyleSheet)&&(this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,this.adoptedCustomStyleSheet]),this.useAdoptedStyleSheets=!0}catch(n){this.useAdoptedStyleSheets=!1,console.error("Cannot use adopted stylesheets",n)}let t=this.constructor;t[Wi]||(t[Wi]=!0,this.importDynamicDependencies()),(e=this.shadowRoot)===null||e===void 0||e.addEventListener(je.eventName,this.scheduleExportpartsUpdate)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.shadowRoot)===null||e===void 0||e.removeEventListener(je.eventName,this.scheduleExportpartsUpdate)}importDynamicDependencies(){}updated(e){super.updated(e),this.updateComplete.then(()=>{this.contentAvailableCallback(e),this.focusElementToFocus(e),this.applyCustomStylesheet(e),this.scheduleExportpartsUpdate(),e.has("exportparts")&&this.dispatchEvent(new je)})}contentAvailableCallback(e){}focusElementToFocus(e){if(e.has("elementToFocus")&&this.elementToFocus!=null){let{element:t,selector:n,shadowPath:i}=this.elementToFocus;if(n!=null){let s=[...i??[],n];t=Ki(this.shadowRoot,...s)}t?.focus(),window.FluidTopicsA11yHints.isKeyboardNavigation||t?.blur(),this.elementToFocus=void 0}}applyCustomStylesheet(e){var t,n,i;if(((n=(t=this.shadowRoot)===null||t===void 0?void 0:t.querySelectorAll(".ft-lit-element--custom-stylesheet"))!==null&&n!==void 0?n:[]).forEach(s=>s.remove()),this.useAdoptedStyleSheets){if(e.has("customStylesheet"))try{this.adoptedCustomStyleSheet.replaceSync((i=this.customStylesheet)!==null&&i!==void 0?i:"")}catch(s){console.error(s,this.customStylesheet),this.useAdoptedStyleSheets=!1}}else if(this.customStylesheet){let s=document.createElement("style");s.classList.add("ft-lit-element--custom-stylesheet"),s.innerHTML=this.customStylesheet,this.shadowRoot.append(s)}}setExportpartsAttribute(e){var t,n,i,s,a,o;let c=h=>h!=null&&h.trim().length>0,l=e.filter(c).map(h=>h.trim());if(l.length===0){this.exportparts=void 0;return}let u=new Set;for(let h of(n=(t=this.shadowRoot)===null||t===void 0?void 0:t.querySelectorAll("[part],[exportparts]"))!==null&&n!==void 0?n:[]){let f=(s=(i=h.getAttribute("part"))===null||i===void 0?void 0:i.split(" "))!==null&&s!==void 0?s:[],p=(o=(a=h.getAttribute("exportparts"))===null||a===void 0?void 0:a.split(",").map(S=>S.split(":")[1]))!==null&&o!==void 0?o:[],g=[...f,...p].filter(c).map(S=>S.trim());for(let S of g)u.add(S)}if(u.size===0){this.exportparts=void 0;return}let d=[...u.values()].flatMap(h=>l.map(f=>`${h}:${f}--${h}`));this.exportparts=[...this.part,...d].join(", ")}};Gi=Yi;Be([(0,Ae.property)()],ne.prototype,"exportpartsPrefix",void 0);Be([ji([])],ne.prototype,"exportpartsPrefixes",void 0);Be([(0,Ae.property)({reflect:!0})],ne.prototype,"exportparts",void 0);Be([(0,Ae.property)()],ne.prototype,"customStylesheet",void 0);Be([(0,Ae.property)()],ne.prototype,"elementToFocus",void 0);Be([(0,Ae.state)()],ne.prototype,"useAdoptedStyleSheets",void 0);function Ft(r){var e;return(e=r?.isFtReduxStore)!==null&&e!==void 0?e:!1}var ft=Symbol("internalReduxEventsUnsubscribers"),fe=Symbol("internalStoresUnsubscribers"),Ee=Symbol("internalStores"),Ga=Pt(Symbol("withRedux"),function(r){var e,t,n;class i extends r{constructor(){super(...arguments),this[e]=new Map,this[t]=new Map,this[n]=new Map}get reduxConstructor(){return this.constructor}willUpdate(a){super.willUpdate(a),[...this.reduxConstructor.reduxReactiveProperties].some(o=>a.has(o))&&this.updateFromStores()}getUnnamedStore(){if(this[Ee].size>1)throw new Error("Cannot resolve unnamed store when multiple stores are configured.");return[...this[Ee].values()][0]}getStore(a){return a==null?this.getUnnamedStore():this[Ee].get(a)}addStore(a,o){var c;o=(c=o??a.name)!==null&&c!==void 0?c:"default-store",this.unsubscribeFromStore(o),this[Ee].set(o,a),this.subscribeToStore(o,a),this.updateFromStores()}removeStore(a){let o=typeof a=="string"?a:a.name;this.unsubscribeFromStore(o),this[Ee].delete(o)}setupStores(){this.unsubscribeFromStores(),this[Ee].forEach((a,o)=>this.subscribeToStore(o,a)),this.updateFromStores()}updateFromStores(){this.reduxConstructor.reduxProperties.forEach((a,o)=>{let c=this.constructor.getPropertyOptions(o);if(!c?.attribute||!this.hasAttribute(typeof c?.attribute=="string"?c.attribute:o)){let l=this.getStore(a.store);l&&(a.store?this[fe].has(a.store):this[fe].size>0)&&(this[o]=a.selector(l.getState(),this))}})}subscribeToStore(a,o){var c;this[fe].set(a,o.subscribe(()=>this.updateFromStores())),this[ft].set(a,[]),Ft(o)&&o.eventBus&&((c=this.reduxConstructor.reduxEventListeners)===null||c===void 0||c.forEach((l,u)=>{if(typeof this[u]=="function"&&(!l.store||o.name===l.store)){let d=h=>this[u](h);o.addEventListener(l.eventName,d),this[ft].get(a).push(()=>o.removeEventListener(l.eventName,d))}})),this.onStoreAvailable(a)}unsubscribeFromStores(){this[fe].forEach((a,o)=>this.unsubscribeFromStore(o))}unsubscribeFromStore(a){var o;this[fe].has(a)&&this[fe].get(a)(),this[fe].delete(a),(o=this[ft].get(a))===null||o===void 0||o.forEach(c=>c()),this[ft].delete(a)}onStoreAvailable(a){}connectedCallback(){super.connectedCallback(),this.setupStores()}disconnectedCallback(){super.disconnectedCallback(),this.unsubscribeFromStores()}}return e=fe,t=Ee,n=ft,i.reduxProperties=new Map,i.reduxReactiveProperties=new Set,i.reduxEventListeners=new Map,i}),Qi=class extends Ga(ne){};function Q(r){for(var e=arguments.length,t=Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];if(0)var i,s;throw Error("[Immer] minified error nr: "+r+(t.length?" "+t.map((function(a){return"'"+a+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function ce(r){return!!r&&!!r[I]}function ee(r){var e;return!!r&&((function(t){if(!t||typeof t!="object")return!1;var n=Object.getPrototypeOf(t);if(n===null)return!0;var i=Object.hasOwnProperty.call(n,"constructor")&&n.constructor;return i===Object||typeof i=="function"&&Function.toString.call(i)===ro})(r)||Array.isArray(r)||!!r[ns]||!!(!((e=r.constructor)===null||e===void 0)&&e[ns])||$r(r)||jr(r))}function Te(r,e,t){t===void 0&&(t=!1),Ke(r)===0?(t?Object.keys:Ve)(r).forEach((function(n){t&&typeof n=="symbol"||e(n,r[n],r)})):r.forEach((function(n,i){return e(i,n,r)}))}function Ke(r){var e=r[I];return e?e.i>3?e.i-4:e.i:Array.isArray(r)?1:$r(r)?2:jr(r)?3:0}function He(r,e){return Ke(r)===2?r.has(e):Object.prototype.hasOwnProperty.call(r,e)}function Ya(r,e){return Ke(r)===2?r.get(e):r[e]}function is(r,e,t){var n=Ke(r);n===2?r.set(e,t):n===3?r.add(t):r[e]=t}function ss(r,e){return r===e?r!==0||1/r==1/e:r!=r&&e!=e}function $r(r){return eo&&r instanceof Map}function jr(r){return to&&r instanceof Set}function me(r){return r.o||r.t}function Br(r){if(Array.isArray(r))return Array.prototype.slice.call(r);var e=cs(r);delete e[I];for(var t=Ve(e),n=0;n<t.length;n++){var i=t[n],s=e[i];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(e[i]={configurable:!0,writable:!0,enumerable:s.enumerable,value:r[i]})}return Object.create(Object.getPrototypeOf(r),e)}function Hr(r,e){return e===void 0&&(e=!1),Vr(r)||ce(r)||!ee(r)||(Ke(r)>1&&(r.set=r.add=r.clear=r.delete=Qa),Object.freeze(r),e&&Te(r,(function(t,n){return Hr(n,!0)}),!0)),r}function Qa(){Q(2)}function Vr(r){return r==null||typeof r!="object"||Object.isFrozen(r)}function ie(r){var e=Fr[r];return e||Q(18,r),e}function Ja(r,e){Fr[r]||(Fr[r]=e)}function Dr(){return gt}function Lr(r,e){e&&(ie("Patches"),r.u=[],r.s=[],r.v=e)}function $t(r){kr(r),r.p.forEach(Xa),r.p=null}function kr(r){r===gt&&(gt=r.l)}function Ji(r){return gt={p:[],l:gt,h:r,m:!0,_:0}}function Xa(r){var e=r[I];e.i===0||e.i===1?e.j():e.g=!0}function Mr(r,e){e._=e.p.length;var t=e.p[0],n=r!==void 0&&r!==t;return e.h.O||ie("ES5").S(e,r,n),n?(t[I].P&&($t(e),Q(4)),ee(r)&&(r=jt(e,r),e.l||Bt(e,r)),e.u&&ie("Patches").M(t[I].t,r,e.u,e.s)):r=jt(e,t,[]),$t(e),e.u&&e.v(e.u,e.s),r!==os?r:void 0}function jt(r,e,t){if(Vr(e))return e;var n=e[I];if(!n)return Te(e,(function(o,c){return Xi(r,n,e,o,c,t)}),!0),e;if(n.A!==r)return e;if(!n.P)return Bt(r,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=n.i===4||n.i===5?n.o=Br(n.k):n.o,s=i,a=!1;n.i===3&&(s=new Set(i),i.clear(),a=!0),Te(s,(function(o,c){return Xi(r,n,i,o,c,t,a)})),Bt(r,i,!1),t&&r.u&&ie("Patches").N(n,t,r.u,r.s)}return n.o}function Xi(r,e,t,n,i,s,a){if(ce(i)){var o=jt(r,i,s&&e&&e.i!==3&&!He(e.R,n)?s.concat(n):void 0);if(is(t,n,o),!ce(o))return;r.m=!1}else a&&t.add(i);if(ee(i)&&!Vr(i)){if(!r.h.D&&r._<1)return;jt(r,i),e&&e.A.l||Bt(r,i)}}function Bt(r,e,t){t===void 0&&(t=!1),!r.l&&r.h.D&&r.m&&Hr(e,t)}function Pr(r,e){var t=r[I];return(t?me(t):r)[e]}function Zi(r,e){if(e in r)for(var t=Object.getPrototypeOf(r);t;){var n=Object.getOwnPropertyDescriptor(t,e);if(n)return n;t=Object.getPrototypeOf(t)}}function ge(r){r.P||(r.P=!0,r.l&&ge(r.l))}function Nr(r){r.o||(r.o=Br(r.t))}function Ur(r,e,t){var n=$r(e)?ie("MapSet").F(e,t):jr(e)?ie("MapSet").T(e,t):r.O?(function(i,s){var a=Array.isArray(i),o={i:a?1:0,A:s?s.A:Dr(),P:!1,I:!1,R:{},l:s,t:i,k:null,o:null,j:null,C:!1},c=o,l=vt;a&&(c=[o],l=mt);var u=Proxy.revocable(c,l),d=u.revoke,h=u.proxy;return o.k=h,o.j=d,h})(e,t):ie("ES5").J(e,t);return(t?t.A:Dr()).p.push(n),n}function Za(r){return ce(r)||Q(22,r),(function e(t){if(!ee(t))return t;var n,i=t[I],s=Ke(t);if(i){if(!i.P&&(i.i<4||!ie("ES5").K(i)))return i.t;i.I=!0,n=es(t,s),i.I=!1}else n=es(t,s);return Te(n,(function(a,o){i&&Ya(i.t,a)===o||is(n,a,e(o))})),s===3?new Set(n):n})(r)}function es(r,e){switch(e){case 2:return new Map(r);case 3:return Array.from(r)}return Br(r)}function as(){function r(a,o){var c=s[a];return c?c.enumerable=o:s[a]=c={configurable:!0,enumerable:o,get:function(){var l=this[I];return vt.get(l,a)},set:function(l){var u=this[I];vt.set(u,a,l)}},c}function e(a){for(var o=a.length-1;o>=0;o--){var c=a[o][I];if(!c.P)switch(c.i){case 5:n(c)&&ge(c);break;case 4:t(c)&&ge(c)}}}function t(a){for(var o=a.t,c=a.k,l=Ve(c),u=l.length-1;u>=0;u--){var d=l[u];if(d!==I){var h=o[d];if(h===void 0&&!He(o,d))return!0;var f=c[d],p=f&&f[I];if(p?p.t!==h:!ss(f,h))return!0}}var g=!!o[I];return l.length!==Ve(o).length+(g?0:1)}function n(a){var o=a.k;if(o.length!==a.t.length)return!0;var c=Object.getOwnPropertyDescriptor(o,o.length-1);if(c&&!c.get)return!0;for(var l=0;l<o.length;l++)if(!o.hasOwnProperty(l))return!0;return!1}function i(a){a.g&&Q(3,JSON.stringify(me(a)))}var s={};Ja("ES5",{J:function(a,o){var c=Array.isArray(a),l=(function(d,h){if(d){for(var f=Array(h.length),p=0;p<h.length;p++)Object.defineProperty(f,""+p,r(p,!0));return f}var g=cs(h);delete g[I];for(var S=Ve(g),A=0;A<S.length;A++){var E=S[A];g[E]=r(E,d||!!g[E].enumerable)}return Object.create(Object.getPrototypeOf(h),g)})(c,a),u={i:c?5:4,A:o?o.A:Dr(),P:!1,I:!1,R:{},l:o,t:a,k:l,o:null,g:!1,C:!1};return Object.defineProperty(l,I,{value:u,writable:!0}),l},S:function(a,o,c){c?ce(o)&&o[I].A===a&&e(a.p):(a.u&&(function l(u){if(u&&typeof u=="object"){var d=u[I];if(d){var h=d.t,f=d.k,p=d.R,g=d.i;if(g===4)Te(f,(function(w){w!==I&&(h[w]!==void 0||He(h,w)?p[w]||l(f[w]):(p[w]=!0,ge(d)))})),Te(h,(function(w){f[w]!==void 0||He(f,w)||(p[w]=!1,ge(d))}));else if(g===5){if(n(d)&&(ge(d),p.length=!0),f.length<h.length)for(var S=f.length;S<h.length;S++)p[S]=!1;else for(var A=h.length;A<f.length;A++)p[A]=!0;for(var E=Math.min(f.length,h.length),_=0;_<E;_++)f.hasOwnProperty(_)||(p[_]=!0),p[_]===void 0&&l(f[_])}}}})(a.p[0]),e(a.p))},K:function(a){return a.i===4?t(a):n(a)}})}var ts,gt,Kr=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",eo=typeof Map<"u",to=typeof Set<"u",rs=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",os=Kr?Symbol.for("immer-nothing"):((ts={})["immer-nothing"]=!0,ts),ns=Kr?Symbol.for("immer-draftable"):"__$immer_draftable",I=Kr?Symbol.for("immer-state"):"__$immer_state";var ro=""+Object.prototype.constructor,Ve=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(r){return Object.getOwnPropertyNames(r).concat(Object.getOwnPropertySymbols(r))}:Object.getOwnPropertyNames,cs=Object.getOwnPropertyDescriptors||function(r){var e={};return Ve(r).forEach((function(t){e[t]=Object.getOwnPropertyDescriptor(r,t)})),e},Fr={},vt={get:function(r,e){if(e===I)return r;var t=me(r);if(!He(t,e))return(function(i,s,a){var o,c=Zi(s,a);return c?"value"in c?c.value:(o=c.get)===null||o===void 0?void 0:o.call(i.k):void 0})(r,t,e);var n=t[e];return r.I||!ee(n)?n:n===Pr(r.t,e)?(Nr(r),r.o[e]=Ur(r.A.h,n,r)):n},has:function(r,e){return e in me(r)},ownKeys:function(r){return Reflect.ownKeys(me(r))},set:function(r,e,t){var n=Zi(me(r),e);if(n?.set)return n.set.call(r.k,t),!0;if(!r.P){var i=Pr(me(r),e),s=i?.[I];if(s&&s.t===t)return r.o[e]=t,r.R[e]=!1,!0;if(ss(t,i)&&(t!==void 0||He(r.t,e)))return!0;Nr(r),ge(r)}return r.o[e]===t&&(t!==void 0||e in r.o)||Number.isNaN(t)&&Number.isNaN(r.o[e])||(r.o[e]=t,r.R[e]=!0),!0},deleteProperty:function(r,e){return Pr(r.t,e)!==void 0||e in r.t?(r.R[e]=!1,Nr(r),ge(r)):delete r.R[e],r.o&&delete r.o[e],!0},getOwnPropertyDescriptor:function(r,e){var t=me(r),n=Reflect.getOwnPropertyDescriptor(t,e);return n&&{writable:!0,configurable:r.i!==1||e!=="length",enumerable:n.enumerable,value:t[e]}},defineProperty:function(){Q(11)},getPrototypeOf:function(r){return Object.getPrototypeOf(r.t)},setPrototypeOf:function(){Q(12)}},mt={};Te(vt,(function(r,e){mt[r]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),mt.deleteProperty=function(r,e){return mt.set.call(this,r,e,void 0)},mt.set=function(r,e,t){return vt.set.call(this,r[0],e,t,r[0])};var no=(function(){function r(t){var n=this;this.O=rs,this.D=!0,this.produce=function(i,s,a){if(typeof i=="function"&&typeof s!="function"){var o=s;s=i;var c=n;return function(g){var S=this;g===void 0&&(g=o);for(var A=arguments.length,E=Array(A>1?A-1:0),_=1;_<A;_++)E[_-1]=arguments[_];return c.produce(g,(function(w){var he;return(he=s).call.apply(he,[S,w].concat(E))}))}}var l;if(typeof s!="function"&&Q(6),a!==void 0&&typeof a!="function"&&Q(7),ee(i)){var u=Ji(n),d=Ur(n,i,void 0),h=!0;try{l=s(d),h=!1}finally{h?$t(u):kr(u)}return typeof Promise<"u"&&l instanceof Promise?l.then((function(g){return Lr(u,a),Mr(g,u)}),(function(g){throw $t(u),g})):(Lr(u,a),Mr(l,u))}if(!i||typeof i!="object"){if((l=s(i))===void 0&&(l=i),l===os&&(l=void 0),n.D&&Hr(l,!0),a){var f=[],p=[];ie("Patches").M(i,l,f,p),a(f,p)}return l}Q(21,i)},this.produceWithPatches=function(i,s){if(typeof i=="function")return function(l){for(var u=arguments.length,d=Array(u>1?u-1:0),h=1;h<u;h++)d[h-1]=arguments[h];return n.produceWithPatches(l,(function(f){return i.apply(void 0,[f].concat(d))}))};var a,o,c=n.produce(i,s,(function(l,u){a=l,o=u}));return typeof Promise<"u"&&c instanceof Promise?c.then((function(l){return[l,a,o]})):[c,a,o]},typeof t?.useProxies=="boolean"&&this.setUseProxies(t.useProxies),typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze)}var e=r.prototype;return e.createDraft=function(t){ee(t)||Q(8),ce(t)&&(t=Za(t));var n=Ji(this),i=Ur(this,t,void 0);return i[I].C=!0,kr(n),i},e.finishDraft=function(t,n){var i=t&&t[I],s=i.A;return Lr(s,n),Mr(void 0,s)},e.setAutoFreeze=function(t){this.D=t},e.setUseProxies=function(t){t&&!rs&&Q(20),this.O=t},e.applyPatches=function(t,n){var i;for(i=n.length-1;i>=0;i--){var s=n[i];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}i>-1&&(n=n.slice(i+1));var a=ie("Patches").$;return ce(t)?a(t,n):this.produce(t,(function(o){return a(o,n)}))},r})(),q=new no,io=q.produce,ml=q.produceWithPatches.bind(q),gl=q.setAutoFreeze.bind(q),vl=q.setUseProxies.bind(q),yl=q.applyPatches.bind(q),bl=q.createDraft.bind(q),Sl=q.finishDraft.bind(q),Ht=io;function xe(r){"@babel/helpers - typeof";return xe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xe(r)}function ls(r,e){if(xe(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e||"default");if(xe(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function us(r){var e=ls(r,"string");return xe(e)=="symbol"?e:e+""}function ds(r,e,t){return(e=us(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function hs(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function qr(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?hs(Object(t),!0).forEach(function(n){ds(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):hs(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function D(r){return"Minified Redux error #"+r+"; visit https://redux.js.org/Errors?code="+r+" for the full message or use the non-minified dev environment for full errors. "}var ps=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})(),zr=function(){return Math.random().toString(36).substring(7).split("").join(".")},Vt={INIT:"@@redux/INIT"+zr(),REPLACE:"@@redux/REPLACE"+zr(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+zr()}};function so(r){if(typeof r!="object"||r===null)return!1;for(var e=r;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(r)===e}function Wr(r,e,t){var n;if(typeof e=="function"&&typeof t=="function"||typeof t=="function"&&typeof arguments[3]=="function")throw new Error(D(0));if(typeof e=="function"&&typeof t>"u"&&(t=e,e=void 0),typeof t<"u"){if(typeof t!="function")throw new Error(D(1));return t(Wr)(r,e)}if(typeof r!="function")throw new Error(D(2));var i=r,s=e,a=[],o=a,c=!1;function l(){o===a&&(o=a.slice())}function u(){if(c)throw new Error(D(3));return s}function d(g){if(typeof g!="function")throw new Error(D(4));if(c)throw new Error(D(5));var S=!0;return l(),o.push(g),function(){if(S){if(c)throw new Error(D(6));S=!1,l();var E=o.indexOf(g);o.splice(E,1),a=null}}}function h(g){if(!so(g))throw new Error(D(7));if(typeof g.type>"u")throw new Error(D(8));if(c)throw new Error(D(9));try{c=!0,s=i(s,g)}finally{c=!1}for(var S=a=o,A=0;A<S.length;A++){var E=S[A];E()}return g}function f(g){if(typeof g!="function")throw new Error(D(10));i=g,h({type:Vt.REPLACE})}function p(){var g,S=d;return g={subscribe:function(E){if(typeof E!="object"||E===null)throw new Error(D(11));function _(){E.next&&E.next(u())}_();var w=S(_);return{unsubscribe:w}}},g[ps]=function(){return this},g}return h({type:Vt.INIT}),n={dispatch:h,subscribe:d,getState:u,replaceReducer:f},n[ps]=p,n}function ao(r){Object.keys(r).forEach(function(e){var t=r[e],n=t(void 0,{type:Vt.INIT});if(typeof n>"u")throw new Error(D(12));if(typeof t(void 0,{type:Vt.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(D(13))})}function fs(r){for(var e=Object.keys(r),t={},n=0;n<e.length;n++){var i=e[n];typeof r[i]=="function"&&(t[i]=r[i])}var s=Object.keys(t),a,o;try{ao(t)}catch(c){o=c}return function(l,u){if(l===void 0&&(l={}),o)throw o;if(0)var d;for(var h=!1,f={},p=0;p<s.length;p++){var g=s[p],S=t[g],A=l[g],E=S(A,u);if(typeof E>"u"){var _=u&&u.type;throw new Error(D(14))}f[g]=E,h=h||E!==A}return h=h||s.length!==Object.keys(l).length,h?f:l}}function qe(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return e.length===0?function(n){return n}:e.length===1?e[0]:e.reduce(function(n,i){return function(){return n(i.apply(void 0,arguments))}})}function ms(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return function(n){return function(){var i=n.apply(void 0,arguments),s=function(){throw new Error(D(15))},a={getState:i.getState,dispatch:function(){return s.apply(void 0,arguments)}},o=e.map(function(c){return c(a)});return s=qe.apply(void 0,o)(i.dispatch),qr(qr({},i),{},{dispatch:s})}}}function gs(r){var e=function(n){var i=n.dispatch,s=n.getState;return function(a){return function(o){return typeof o=="function"?o(i,s,r):a(o)}}};return e}var vs=gs();vs.withExtraArgument=gs;var Gr=vs;var Es=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),oo=function(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(u){return c([l,u])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ze=function(r,e){for(var t=0,n=e.length,i=r.length;t<n;t++,i++)r[i]=e[t];return r},co=Object.defineProperty,lo=Object.defineProperties,uo=Object.getOwnPropertyDescriptors,ys=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,bs=function(r,e,t){return e in r?co(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t},ve=function(r,e){for(var t in e||(e={}))ho.call(e,t)&&bs(r,t,e[t]);if(ys)for(var n=0,i=ys(e);n<i.length;n++){var t=i[n];po.call(e,t)&&bs(r,t,e[t])}return r},Yr=function(r,e){return lo(r,uo(e))},fo=function(r,e,t){return new Promise(function(n,i){var s=function(c){try{o(t.next(c))}catch(l){i(l)}},a=function(c){try{o(t.throw(c))}catch(l){i(l)}},o=function(c){return c.done?n(c.value):Promise.resolve(c.value).then(s,a)};o((t=t.apply(r,e)).next())})};var mo=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?qe:qe.apply(null,arguments)},Fl=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(r){return r}};function go(r){if(typeof r!="object"||r===null)return!1;var e=Object.getPrototypeOf(r);if(e===null)return!0;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return e===t}function ye(r,e){function t(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];if(e){var s=e.apply(void 0,n);if(!s)throw new Error("prepareAction did not return an object");return ve(ve({type:r,payload:s.payload},"meta"in s&&{meta:s.meta}),"error"in s&&{error:s.error})}return{type:r,payload:n[0]}}return t.toString=function(){return""+r},t.type=r,t.match=function(n){return n.type===r},t}var vo=(function(r){Es(e,r);function e(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var i=r.apply(this,t)||this;return Object.setPrototypeOf(i,e.prototype),i}return Object.defineProperty(e,Symbol.species,{get:function(){return e},enumerable:!1,configurable:!0}),e.prototype.concat=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return r.prototype.concat.apply(this,t)},e.prototype.prepend=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.length===1&&Array.isArray(t[0])?new(e.bind.apply(e,ze([void 0],t[0].concat(this)))):new(e.bind.apply(e,ze([void 0],t.concat(this))))},e})(Array),yo=(function(r){Es(e,r);function e(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var i=r.apply(this,t)||this;return Object.setPrototypeOf(i,e.prototype),i}return Object.defineProperty(e,Symbol.species,{get:function(){return e},enumerable:!1,configurable:!0}),e.prototype.concat=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return r.prototype.concat.apply(this,t)},e.prototype.prepend=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.length===1&&Array.isArray(t[0])?new(e.bind.apply(e,ze([void 0],t[0].concat(this)))):new(e.bind.apply(e,ze([void 0],t.concat(this))))},e})(Array);function Xr(r){return ee(r)?Ht(r,function(){}):r}function bo(r){return typeof r=="boolean"}function So(){return function(e){return Ao(e)}}function Ao(r){r===void 0&&(r={});var e=r.thunk,t=e===void 0?!0:e,n=r.immutableCheck,i=n===void 0?!0:n,s=r.serializableCheck,a=s===void 0?!0:s,o=r.actionCreatorCheck,c=o===void 0?!0:o,l=new vo;if(t&&(bo(t)?l.push(Gr):l.push(Gr.withExtraArgument(t.extraArgument))),0){if(i)var u;if(a)var d;if(c)var h}return l}var Qr=!0;function Ts(r){var e=So(),t=r||{},n=t.reducer,i=n===void 0?void 0:n,s=t.middleware,a=s===void 0?e():s,o=t.devTools,c=o===void 0?!0:o,l=t.preloadedState,u=l===void 0?void 0:l,d=t.enhancers,h=d===void 0?void 0:d,f;if(typeof i=="function")f=i;else if(go(i))f=fs(i);else throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');var p=a;if(typeof p=="function"&&(p=p(e),!Qr&&!Array.isArray(p)))throw new Error("when using a middleware builder function, an array of middleware must be returned");if(!Qr&&p.some(function(w){return typeof w!="function"}))throw new Error("each middleware provided to configureStore must be a function");var g=ms.apply(void 0,p),S=qe;c&&(S=mo(ve({trace:!Qr},typeof c=="object"&&c)));var A=new yo(g),E=A;Array.isArray(h)?E=ze([g],h):typeof h=="function"&&(E=h(A));var _=S.apply(void 0,E);return Wr(f,u,_)}function xs(r){var e={},t=[],n,i={addCase:function(s,a){var o=typeof s=="string"?s:s.type;if(!o)throw new Error("`builder.addCase` cannot be called with an empty action type");if(o in e)throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");return e[o]=a,i},addMatcher:function(s,a){return t.push({matcher:s,reducer:a}),i},addDefaultCase:function(s){return n=s,i}};return r(i),[e,t,n]}function Eo(r){return typeof r=="function"}function To(r,e,t,n){t===void 0&&(t=[]);var i=typeof e=="function"?xs(e):[e,t,n],s=i[0],a=i[1],o=i[2],c;if(Eo(r))c=function(){return Xr(r())};else{var l=Xr(r);c=function(){return l}}function u(d,h){d===void 0&&(d=c());var f=ze([s[h.type]],a.filter(function(p){var g=p.matcher;return g(h)}).map(function(p){var g=p.reducer;return g}));return f.filter(function(p){return!!p}).length===0&&(f=[o]),f.reduce(function(p,g){if(g)if(ce(p)){var S=p,A=g(S,h);return A===void 0?p:A}else{if(ee(p))return Ht(p,function(E){return g(E,h)});var A=g(p,h);if(A===void 0){if(p===null)return p;throw Error("A case reducer on a non-draftable value must not return undefined")}return A}return p},d)}return u.getInitialState=c,u}function xo(r,e){return r+"/"+e}function Cs(r){var e=r.name;if(!e)throw new Error("`name` is a required option for createSlice");typeof process<"u";var t=typeof r.initialState=="function"?r.initialState:Xr(r.initialState),n=r.reducers||{},i=Object.keys(n),s={},a={},o={};i.forEach(function(u){var d=n[u],h=xo(e,u),f,p;"reducer"in d?(f=d.reducer,p=d.prepare):f=d,s[u]=f,a[h]=f,o[u]=p?ye(h,p):ye(h)});function c(){var u=typeof r.extraReducers=="function"?xs(r.extraReducers):[r.extraReducers],d=u[0],h=d===void 0?{}:d,f=u[1],p=f===void 0?[]:f,g=u[2],S=g===void 0?void 0:g,A=ve(ve({},h),a);return To(t,function(E){for(var _ in A)E.addCase(_,A[_]);for(var w=0,he=p;w<he.length;w++){var se=he[w];E.addMatcher(se.matcher,se.reducer)}S&&E.addDefaultCase(S)})}var l;return{name:e,reducer:function(u,d){return l||(l=c()),l(u,d)},actions:o,caseReducers:s,getInitialState:function(){return l||(l=c()),l.getInitialState()}}}var Co="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",wo=function(r){r===void 0&&(r=21);for(var e="",t=r;t--;)e+=Co[Math.random()*64|0];return e},Io=["name","message","stack","code"],Jr=(function(){function r(e,t){this.payload=e,this.meta=t}return r})(),Ss=(function(){function r(e,t){this.payload=e,this.meta=t}return r})(),_o=function(r){if(typeof r=="object"&&r!==null){for(var e={},t=0,n=Io;t<n.length;t++){var i=n[t];typeof r[i]=="string"&&(e[i]=r[i])}return e}return{message:String(r)}},Hl=(function(){function r(e,t,n){var i=ye(e+"/fulfilled",function(u,d,h,f){return{payload:u,meta:Yr(ve({},f||{}),{arg:h,requestId:d,requestStatus:"fulfilled"})}}),s=ye(e+"/pending",function(u,d,h){return{payload:void 0,meta:Yr(ve({},h||{}),{arg:d,requestId:u,requestStatus:"pending"})}}),a=ye(e+"/rejected",function(u,d,h,f,p){return{payload:f,error:(n&&n.serializeError||_o)(u||"Rejected"),meta:Yr(ve({},p||{}),{arg:h,requestId:d,rejectedWithValue:!!f,requestStatus:"rejected",aborted:u?.name==="AbortError",condition:u?.name==="ConditionError"})}}),o=!1,c=typeof AbortController<"u"?AbortController:(function(){function u(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){},reason:void 0,throwIfAborted:function(){}}}return u.prototype.abort=function(){},u})();function l(u){return function(d,h,f){var p=n?.idGenerator?n.idGenerator(u):wo(),g=new c,S,A=!1;function E(w){S=w,g.abort()}var _=(function(){return fo(this,null,function(){var w,he,se,ct,In,lt,_n;return oo(this,function(ke){switch(ke.label){case 0:return ke.trys.push([0,4,,5]),ct=(w=n?.condition)==null?void 0:w.call(n,u,{getState:h,extra:f}),Oo(ct)?[4,ct]:[3,2];case 1:ct=ke.sent(),ke.label=2;case 2:if(ct===!1||g.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return A=!0,In=new Promise(function(Z,ut){return g.signal.addEventListener("abort",function(){return ut({name:"AbortError",message:S||"Aborted"})})}),d(s(p,u,(he=n?.getPendingMeta)==null?void 0:he.call(n,{requestId:p,arg:u},{getState:h,extra:f}))),[4,Promise.race([In,Promise.resolve(t(u,{dispatch:d,getState:h,extra:f,requestId:p,signal:g.signal,abort:E,rejectWithValue:function(Z,ut){return new Jr(Z,ut)},fulfillWithValue:function(Z,ut){return new Ss(Z,ut)}})).then(function(Z){if(Z instanceof Jr)throw Z;return Z instanceof Ss?i(Z.payload,p,u,Z.meta):i(Z,p,u)})])];case 3:return se=ke.sent(),[3,5];case 4:return lt=ke.sent(),se=lt instanceof Jr?a(null,p,u,lt.payload,lt.meta):a(lt,p,u),[3,5];case 5:return _n=n&&!n.dispatchConditionRejection&&a.match(se)&&se.meta.condition,_n||d(se),[2,se]}})})})();return Object.assign(_,{abort:E,requestId:p,arg:u,unwrap:function(){return _.then(Ro)}})}}return Object.assign(l,{pending:s,rejected:a,fulfilled:i,typePrefix:e})}return r.withTypes=function(){return r},r})();function Ro(r){if(r.meta&&r.meta.rejectedWithValue)throw r.payload;if(r.error)throw r.error;return r.payload}function Oo(r){return r!==null&&typeof r=="object"&&typeof r.then=="function"}var ws="listener",Is="completed",_s="cancelled",Vl="task-"+_s,Kl="task-"+Is,ql=ws+"-"+_s,zl=ws+"-"+Is;var Zr="listenerMiddleware";var Wl=ye(Zr+"/add"),Gl=ye(Zr+"/removeAll"),Yl=ye(Zr+"/remove");var As,Ql=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:typeof global<"u"?global:globalThis):function(r){return(As||(As=Promise.resolve())).then(r).catch(function(e){return setTimeout(function(){throw e},0)})},Lo=function(r){return function(e){setTimeout(e,r)}},Jl=typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Lo(10);as();var Mo=Pt(Symbol("withEventBus"),function(r,e){return class extends r{constructor(){super(...arguments),this.eventBus=e??document.createElement("span")}addEventListener(t,n,i){this.eventBus.addEventListener(t,n,i)}dispatchEvent(t){return this.eventBus.dispatchEvent(t)}removeEventListener(t,n,i){this.eventBus.removeEventListener(t,n,i)}}}),Kt=class extends Mo(Object){};window.ftReduxStores||(window.ftReduxStores={});var Rs=class r extends Kt{static get(e){var t;let n=typeof e=="string"?e:e.name,i=typeof e=="string"?void 0:e,s=window.ftReduxStores[n];if(Ft(s))return s;if(i==null)return;let a=Cs({...i,reducers:(t=i.reducers)!==null&&t!==void 0?t:{}}),o=Ts({reducer:(c,l)=>{if(l.type==="CLEAR_FT_REDUX_STORE"){let u=ht(a.getInitialState());for(let d of l.keeping)u[d]=(c??u)[d];return u}else if(typeof l.type=="string"&&l.type.startsWith("DEFAULT_VALUE_SETTER__"))return{...c,...l.overwrites};return a.reducer(c,l)}});return window.ftReduxStores[i.name]=new r(a,o,i.eventBus)}constructor(e,t,n){super(),this.reduxSlice=e,this.reduxStore=t,this.isFtReduxStore=!0,this.commands=new Nt;let i=s=>s!=null?JSON.parse(JSON.stringify(s)):s;this.actions=new Proxy(this.reduxSlice.actions,{get:(s,a,o)=>{let c=a,l=s[c];return l?(...u)=>{let d=l(...u.map(i));return this.reduxStore.dispatch(d),d}:u=>{this.setState({[c]:i(u)})}}}),this.eventBus=n??this.eventBus}clear(){this.reduxStore.dispatch({type:"CLEAR_FT_REDUX_STORE",keeping:[]})}clearKeeping(...e){this.reduxStore.dispatch({type:"CLEAR_FT_REDUX_STORE",keeping:e})}setState(e){this.reduxStore.dispatch({type:"DEFAULT_VALUE_SETTER__"+Object.keys(e).join("_"),overwrites:e})}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(e){throw new Error("Not implemented yet.")}subscribe(e){return this.reduxStore.subscribe(e)}get name(){return this.reduxSlice.name}get reducer(){return this.reduxSlice.reducer}get caseReducers(){return this.reduxSlice.caseReducers}getInitialState(){return this.reduxSlice.getInitialState()}};var qt=class{static format(e,t,n,i,s){return window.moment?window.moment(e).locale(t).format(this.getMomentDateFormat(n,i,!!s)):this.getIntlDateTime(e,t,n,i,!!s)}static getMomentDateFormat(e,t,n){return n?"LT":e?t?"lll":"ll":t?"L LT":"L"}static getIntlDateTime(e,t,n,i,s){let a=typeof e=="string"?new Date(e):e,o=new Intl.DateTimeFormat(t,{dateStyle:n?"medium":"short"}).format(a),c=new Intl.DateTimeFormat(t,{timeStyle:"short"}).format(a);return s?c:i?`${o} ${c}`:o}static getTimezoneAsString(){let e=n=>String(Math.floor(n)).padStart(2,"0"),t=new Date().getTimezoneOffset();return`${t<0?"+":"-"}${e(Math.abs(t)/60)}:${e(Math.abs(t)%60)}`}};var zt=v(T()),Po="ft-app-info",le=class r extends CustomEvent{constructor(e){super(r.eventName,{detail:e})}};le.eventName="authentication-change";var yt=class r extends CustomEvent{constructor(e){super(r.eventName,{detail:e})}};yt.eventName="ui-locale-changed";var No={session:(r,e)=>{(0,zt.deepEqual)(r.session,e.payload)||(r.session=e.payload,setTimeout(()=>y.dispatchEvent(new le(e.payload)),0))}},y=zt.FtReduxStore.get({name:Po,reducers:No,initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,apiIntegrationAppVersion:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],availableContentLocales:[],defaultLocales:void 0,searchInAllLanguagesAllowed:!1,searchLanguageSetsUiLanguage:!1,uiLanguageSetsSearchLanguage:!1,uiLanguageSetsReaderLanguage:!1,metadataConfiguration:void 0,privacyPolicyConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0,openExternalDocumentInNewTab:!1,navigatorOnline:!0,forcedOffline:!1,authenticationRequired:!1}});var Os=v(T()),Wt=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Cu=(0,Os.applyMixinOnce)(Symbol("withDateFormat"),function(r){class e extends r{constructor(...n){super(n),this.useLongDateFormat=!1,this.useDateTimeFormat=!1,this.metadataDescriptors=[],this.uiLocale="en-US",this.addStore(y)}dateFormatOptionsChanged(n){return n.has("metadataDescriptors")||n.has("useLongDateFormat")||n.has("useDateTimeFormat")||n.has("uiLocale")}getDateFormatter(n){var i,s;return((s=(i=this.metadataDescriptors.find(o=>o.key===n))===null||i===void 0?void 0:i.date)!==null&&s!==void 0?s:!1)?o=>qt.format(o,this.uiLocale,this.useLongDateFormat,this.useDateTimeFormat):void 0}}return Wt([(0,en.property)({type:Boolean})],e.prototype,"useLongDateFormat",void 0),Wt([(0,en.property)({type:Boolean})],e.prototype,"useDateTimeFormat",void 0),Wt([Or({store:y.name,selector:t=>{var n,i;return(i=(n=t.metadataConfiguration)===null||n===void 0?void 0:n.descriptors)!==null&&i!==void 0?i:[]}})],e.prototype,"metadataDescriptors",void 0),Wt([Or({store:y.name})],e.prototype,"uiLocale",void 0),e});var Xt=v(T());var tn=v(T());var Ce=class r{static get(e){let{baseUrl:t,apiIntegrationIdentifier:n}=y.getState(),i=e??n;if(t&&i&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(t,i,!0)}static await(e){return new Promise(t=>{let n=r.get(e);if(n)t(n);else{let i=y.subscribe(()=>{n=r.get(e),n&&(i(),t(n))})}})}};var We=class{constructor(e){this.overrideApi=e}get api(){var e;return(e=this.overrideApi)!==null&&e!==void 0?e:Ce.get()}get awaitApi(){return this.overrideApi?Promise.resolve(this.overrideApi):Ce.await()}};var k=class extends We{constructor(e=!0,t){var n;super(t),this.sortObjectFields=(s,a)=>typeof a!="object"||a==null||Array.isArray(a)?a:Object.fromEntries(Object.entries(a).sort(([o],[c])=>o.localeCompare(c)));let i=this.constructor;i.commonCache=(n=i.commonCache)!==null&&n!==void 0?n:new tn.CacheRegistry,this.cache=e?i.commonCache:new tn.CacheRegistry}clearCache(){this.cache.clearAll()}hash(e){return String(Array.from(JSON.stringify(e,this.sortObjectFields)).reduce((t,n)=>0|31*t+n.charCodeAt(0),0))}};var Gt=class extends k{async listMySearches(){let{session:e}=y.getState();return oe(e,C.SAVED_SEARCH_USER)?this.cache.get("my-searches",async()=>(await this.awaitApi).listMySearches(e.profile.userId),300*1e3):[]}};var Yt=class extends k{async listMyBookmarks(){let e=y.getState().session;return e?.sessionAuthenticated?this.cache.get("my-bookmarks",async()=>(await this.awaitApi).listMyBookmarks(e.profile.userId),300*1e3):[]}};var Qt=class extends k{constructor(){super(...arguments),this.CACHE_DURATION=180*1e3}async getUserAssetCount(e){if(this.isAuthenticated())return this.cache.get(`user-asset-count-${e}`,async()=>(await this.awaitApi).get(`/internal/api/webapp/user/assets/count/${e}`),this.CACHE_DURATION)}async getUserBookmarkCountByMap(e){if(this.isAuthenticated())return this.cache.get(`user-bookmark-count-by-map-${e}`,async()=>(await this.awaitApi).get(`/internal/api/webapp/user/assets/count/BOOKMARKS/${e}`),this.CACHE_DURATION)}isAuthenticated(){let e=y.getState().session;return!!e?.sessionAuthenticated}};var Jt=class extends k{constructor(){super(...arguments),this.CACHE_DURATION=180*1e3}async getUserAssetLabels(){return this.isAuthenticated()?this.cache.get("user-asset-labels",async()=>(await this.awaitApi).get("/internal/api/webapp/user/assets/labels"),this.CACHE_DURATION):[]}isAuthenticated(){let e=y.getState().session;return!!e?.sessionAuthenticated}};var Do="ft-user-assets",ko={setAssetCount:(r,e)=>{let{userAssetType:t,count:n}=e.payload.assetCount;r.assetCounts.allAsset[t]=n},clearAssetCount:r=>{Object.values(Y).forEach(e=>{r.assetCounts.allAsset[e]=void 0})},setBookmarkCountByMap:(r,e)=>{let t=e.payload.mapId;r.assetCounts.bookmarkByMap[t]=e.payload.count},clearBookmarkCountByMap:r=>{r.assetCounts.bookmarkByMap={}},addAsset:(r,e)=>{let{assetType:t,mapId:n,asset:i}=e.payload;nn(r,t,[...rn(r,t),i]),Ls(r,t,1,n),Ms(r,i)},editAsset:(r,e)=>{let{assetType:t,asset:n}=e.payload;nn(r,t,rn(r,t).map(i=>i.id===n.id?n:i)),Ms(r,n)},removeAsset:(r,e)=>{let{assetType:t,mapId:n,assetId:i}=e.payload;nn(r,t,rn(r,t).filter(s=>s.id!==i)),Ls(r,t,-1,n)}},Ps={[Y.SEARCHES]:"savedSearches",[Y.BOOKMARKS]:"bookmarks",[Y.BOOKS]:void 0,[Y.COLLECTIONS]:void 0},rn=(r,e)=>{var t;let n=Ps[e];return n?(t=r[n])!==null&&t!==void 0?t:[]:[]},nn=(r,e,t)=>{let n=Ps[e];n&&(r[n]=t)},Ls=(r,e,t,n)=>{let i=r.assetCounts.allAsset[e];if(i!==void 0&&(r.assetCounts.allAsset[e]=Math.max(0,i+t),e===Y.BOOKMARKS&&n)){let s=r.assetCounts.bookmarkByMap[n];r.assetCounts.bookmarkByMap[n]=Math.max(0,s+t)}},Ms=(r,e)=>{let t=r.assetLabels.map(i=>i.title),n=e.labels.filter(i=>!t.includes(i)).map(i=>({title:i}));r.assetLabels.push(...n)},B=Xt.FtReduxStore.get({name:Do,reducers:ko,initialState:{savedSearches:void 0,bookmarks:void 0,assetCounts:{allAsset:Object.fromEntries(Object.values(Y).map(r=>[r,void 0])),bookmarkByMap:{}},assetLabels:[]}}),sn=class{constructor(e=new Qt,t=new Jt){this.assetCountsService=e,this.assetLabelsService=t,this.currentSession=y.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new Yt,this.savedSearchesService=new Gt,y.subscribe(()=>this.reloadWhenUserSessionChanges())}reloadWhenUserSessionChanges(){var e;let{session:t}=y.getState();(0,Xt.deepEqual)((e=this.currentSession)===null||e===void 0?void 0:e.profile,t?.profile)||(this.currentSession=t,this.clearMySearches(),this.reloadBookmarks(),this.clearUserAssetCounts(),this.reloadAssetLabels())}clearUserAssetCounts(){this.assetCountsService.clearCache(),B.actions.clearAssetCount(),B.actions.clearBookmarkCountByMap()}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),B.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),B.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();let e=await this.savedSearchesService.listMySearches();B.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async reloadAssetLabels(){this.assetLabelsService.clearCache();let e=await this.assetLabelsService.getUserAssetLabels();B.actions.assetLabels(e)}async loadAssetCount(e){let t=await this.assetCountsService.getUserAssetCount(e);t&&B.getState().assetCounts.allAsset[e]!==t.count&&B.actions.setAssetCount({assetCount:t})}async loadBookmarkByMapId(e){let t=await this.assetCountsService.getUserBookmarkCountByMap(e);t&&B.getState().assetCounts.bookmarkByMap[e]!==t.count&&B.actions.setBookmarkCountByMap({count:t.count,mapId:e})}async reloadAssetCount(e){this.assetCountsService.clearCache();let t=Object.keys(B.getState().assetCounts.bookmarkByMap).length!==0;e===Y.BOOKMARKS&&t&&B.actions.clearBookmarkCountByMap(),B.getState().assetCounts.allAsset[e]!==void 0&&await this.loadAssetCount(e)}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;B.actions.bookmarks(t)}}},an=new sn;window.FluidTopicsUserAssetsActions==null&&(window.FluidTopicsUserAssetsActions=an);var on=class{addCommand(e,t=!1){y.commands.add(e,t)}consumeCommand(e){return y.commands.consume(e)}};window.FluidTopicsAppInfoStoreService=new on;var J=v(T());var Ns,Ge=class extends CustomEvent{constructor(e){super("ft-i18n-context-loaded",{detail:e})}},Uo=Symbol("clearAfterUnitTest"),Zt=class extends(0,J.withEventBus)(k){constructor(e){super(),this.messageContextProvider=e,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[Ns]=()=>{this.defaultMessages={},this.cache=new J.CacheRegistry,this.listeners={}},this.currentUiLocale=y.getState().uiLocale,y.subscribe(()=>this.clearWhenUiLocaleChanges())}clearWhenUiLocaleChanges(){let{uiLocale:e}=y.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 n;if(e=e.toLowerCase(),t&&Object.keys(t).length>0){let i={...(n=this.defaultMessages[e])!==null&&n!==void 0?n:{},...t};(0,J.deepEqual)(this.defaultMessages[e],i)||(this.defaultMessages[e]=i,await this.notify(e))}return this.fetchContext(e)}resolveContext(e){var t,n;return this.fetchContext(e),(n=(t=this.cache.getNow(e))===null||t===void 0?void 0:t.messages)!==null&&n!==void 0?n:{}}resolveRawMessage(e,t){let n=e.toLowerCase();return this.resolveContext(n)[t]}resolveMessage(e,t,...n){var i;let s=e.toLowerCase(),a=this.resolveContext(s);return new J.ParametrizedLabelResolver((i=this.defaultMessages[s])!==null&&i!==void 0?i:{},a).resolve(t,...n)}async fetchContext(e){let t=!this.cache.has(e),n;try{n=await this.cache.get(e,()=>this.messageContextProvider(this.currentUiLocale,e)),t&&await this.notify(e)}catch(i){!(i instanceof J.CanceledPromiseError)&&t&&console.error(i)}return n}subscribe(e,t){var n;return e=e.toLowerCase(),this.listeners[e]=(n=this.listeners[e])!==null&&n!==void 0?n:new Set,this.listeners[e].add(t),()=>{var i;return(i=this.listeners[e])===null||i===void 0?void 0:i.delete(t)}}async notifyAll(){let e=Object.keys(this.listeners);document.body.dispatchEvent(new Ge({loadedContexts:e})),this.dispatchEvent(new Ge({loadedContexts:e})),await Promise.all(e.map(t=>this.notify(t,!1)))}async notify(e,t=!0){t&&(document.body.dispatchEvent(new Ge({loadedContexts:[e]})),this.dispatchEvent(new Ge({loadedContexts:[e]}))),this.listeners[e]!=null&&await Promise.all([...this.listeners[e].values()].map(n=>(0,J.delay)(0).then(()=>n()).catch(()=>null)))}};Ns=Uo;window.FluidTopicsI18nService==null&&(window.FluidTopicsI18nService=new class extends Zt{constructor(){super(async(r,e)=>(await this.awaitApi).getFluidTopicsMessageContext(r,e))}});window.FluidTopicsCustomI18nService==null&&(window.FluidTopicsCustomI18nService=new class extends Zt{constructor(){super(async(r,e)=>(await this.awaitApi).getCustomMessageContext(r,e))}});var Ds=window.FluidTopicsI18nService,ad=window.FluidTopicsCustomI18nService;var ks=v(T()),cn=class{highlightHtml(e,t,n){(0,ks.highlightHtml)(e,t,n)}};window.FluidTopicsHighlightHtmlService=new cn;var Us=v(T());var ln=class{isDate(e){var t,n,i,s;return(s=(i=((n=(t=y.getState().metadataConfiguration)===null||t===void 0?void 0:t.descriptors)!==null&&n!==void 0?n:[]).find(o=>o.key===e))===null||i===void 0?void 0:i.date)!==null&&s!==void 0?s:!1}format(e,t){var n,i,s,a;if(e==null)return"";try{return Us.DateFormatter.format(e,(n=t?.locale)!==null&&n!==void 0?n:y.getState().uiLocale,(i=t?.longFormat)!==null&&i!==void 0?i:!1,(s=t?.withTime)!==null&&s!==void 0?s:!1,(a=t?.onlyTime)!==null&&a!==void 0?a:!1)}catch(o){throw console.error(`Date ${JSON.stringify(e)} is not valid`,o),o}}};window.FluidTopicsDateService=new ln;var Fs=v(T());var bt=class{static get(e,t){var n,i;let s=y.getState(),{lang:a,region:o}=(i=(n=s.defaultLocales)===null||n===void 0?void 0:n.defaultContentLocale)!==null&&i!==void 0?i:{lang:"en",region:"US"};return new Fs.SearchPlaceConverter(s.baseUrl,e??20,s.searchInAllLanguagesAllowed,t??`${a}-${o}`)}};var er=class extends k{async sendDocumentStartDisplayEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.start_display event")}async sendTopicStartDisplayEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send topic.start_display event")}async sendKhubSearchEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send khub.search event")}async sendDocumentSearchEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.search event")}async sendSearchPageSelectEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send search_page.select event")}async sendSearchResultOpenContextMenuEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send search_result.open_context_menu event")}async sendDocumentOnDemandTranslateEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.on_demand_translate event")}async sendTopicAiTranslateEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send topic.ai_translate event")}convertMapToAnalyticsDocument(e){let t;switch(e.editorialType){case"BOOK":t="STRUCTURED_DOCUMENT";break;case"SHARED_BOOK":t="SHARED_PERSONAL_BOOK";break;case"ARTICLE":t="RESOURCE";break;case"HTML_PACKAGE":t="HTML_PACKAGE";break;default:throw new TypeError("Unknown editorial type for map : "+e.editorialType)}return{id:e.id,title:e.title,type:t,metadata:e.metadata}}sortEventArrays(e){let t=Object.entries(e).map(([n,i])=>Array.isArray(i)?[n,i.map(s=>typeof s=="object"&&s!=null&&!Array.isArray(s)?this.sortEventArrays(s):s).sort((s,a)=>typeof s=="object"&&s!==null&&"key"in s?s.key.localeCompare(a.key):typeof s=="string"&&typeof a=="string"?s.localeCompare(a):String(s).localeCompare(String(a)))]:typeof i=="object"&&i!==null?[n,this.sortEventArrays(i)]:[n,i]);return Object.fromEntries(t)}sendEvents(e,t){let n="anything not undefined";return this.cache.get("analytics-event-"+this.hash(e),async()=>(await this.awaitApi).sendEvents(e).then(()=>n).catch(i=>(console.info(t),console.debug(i),n)),1e3)}};var un=class{urlToSearchRequest(e){return bt.get().parse(e)}searchRequestToUrl(e){return bt.get().serialize(e)}};window.FluidTopicsUrlService=new un;var ue=v(T());var we=class r extends CustomEvent{constructor(e){super(r.eventName,{detail:{currentItem:e}})}};we.eventName="change";var dn=class{itemName(e){return`fluid-topics-history-item-${e}`}get(e){let t=sessionStorage.getItem(this.itemName(e));return t?JSON.parse(t):void 0}set(e,t){sessionStorage.setItem(this.itemName(e),JSON.stringify(t))}},$s=new dn;var tr=class r extends ue.WithEventBus{static build(){return new r(window.history,$s,()=>window.location,!1)}constructor(e,t,n,i){var s,a;super(),this.history=e,this.historyStorage=t,this.windowLocation=n,this.states=[],this.realPushState=e.pushState,this.realReplaceState=e.replaceState,this.initialIndex=(a=(s=e.state)===null||s===void 0?void 0:s.index)!==null&&a!==void 0?a:e.length-1,this.currentIndex=this.initialIndex,this.setCurrentState(this.buildCurrentState()),this.installProxies(),this.initEventListeners(),this.initData(i)}setCurrentState(e,t=!1){let n=t&&this.currentIndex===e.index-1;this.currentState={...this.buildCurrentState(),...e},this.currentIndex=this.currentState.index,this.states[this.currentIndex]=this.currentState,n&&(this.states=this.states.slice(0,this.currentIndex+1)),this.historyStorage.set(this.currentIndex,this.currentState),(0,ue.deepEqual)(this.currentState,this.history.state)||this.realReplaceState.apply(this.history,[this.currentState,this.currentState.title,window.location.href]),setTimeout(()=>this.dispatchEvent(new we(this.currentItem())),0)}installProxies(){let e=t=>(n,i,[s,a,o])=>{let c=t(),l={...c===this.currentIndex?this.currentState:void 0,...s,index:c,href:typeof o=="string"?o:(o??this.windowLocation()).href};n.apply(i,[l,a,o]),this.setCurrentState(l,!0)};this.history.pushState=new Proxy(this.history.pushState,{apply:e(()=>this.currentIndex+1)}),this.history.replaceState=new Proxy(this.history.replaceState,{apply:e(()=>this.currentIndex)})}initEventListeners(){window.addEventListener("popstate",e=>this.setCurrentState(e.state)),document.querySelector("title")==null&&document.head.append(document.createElement("title")),new MutationObserver(()=>this.updateCurrentState({title:document.title})).observe(document.querySelector("title"),{subtree:!0,characterData:!0,childList:!0})}initData(e){for(let t=this.history.length-1;t>=0;t--)e?this.states[t]=this.historyStorage.get(t):setTimeout(()=>this.states[t]=this.historyStorage.get(t),this.history.length-t)}updateCurrentState(e){var t;let n={...this.buildCurrentState(),...e,index:this.currentIndex,title:(t=e?.title)!==null&&t!==void 0?t:this.currentState.title};this.setCurrentState(n)}addHistoryChangeListener(e){this.addEventListener(we.eventName,e)}removeHistoryChangeListener(e){this.removeEventListener(we.eventName,e)}currentItem(){return(0,ue.deepCopy)(this.currentState)}back(){let e=this.previousDifferentMajorPosition();e>=0?this.history.go(e-this.currentIndex):this.currentIndex!==this.initialIndex?this.history.go(this.initialIndex-this.currentIndex):this.history.back()}backwardItem(){return(0,ue.deepCopy)(this.states[this.previousDifferentMajorPosition()])}backwardItemMatching(e){let t=this.states.filter(n=>!!n).filter(n=>n.index<this.currentIndex).reverse();return(0,ue.deepCopy)(t.find(n=>e(n)))}previousDifferentMajorPosition(){let e=this.currentIndex>0?this.currentIndex-1:0;for(;e>0&&!this.isDifferentMajorState(e);)e--;return e}forward(){let e=this.nextMajorPosition();e&&e<this.states.length?this.history.go(e-this.currentIndex):this.history.forward()}forwardItem(){let e=this.nextMajorPosition();if(e)return(0,ue.deepCopy)(this.states[e])}nextMajorPosition(){let e=this.currentIndex;if(!(e>=this.states.length)){do e++;while(e<this.states.length&&!this.isDifferentMajorState(e));return this.getHigherPositionInTheSameState(e)}}getHigherPositionInTheSameState(e){var t;let n=(t=this.states[e])===null||t===void 0?void 0:t.majorStateId;if(!n)return e;let i=e,s=e+1;for(;this.states.length>s&&!this.isDifferentMajorState(s,n);)this.hasState(s)&&(i=s),s++;return i}buildCurrentState(){var e,t;return{...this.history.state,index:this.currentIndex,href:this.windowLocation().href,title:(t=(e=this.history.state)===null||e===void 0?void 0:e.title)!==null&&t!==void 0?t:document.title}}hasState(e){return this.states[e]!=null}isDifferentMajorState(e,t){var n;if(!this.hasState(e))return!1;let i=t??this.currentState.majorStateId,s=(n=this.states[e])===null||n===void 0?void 0:n.majorStateId;return s==null||s!=i}};window.FluidTopicsInternalHistoryService==null&&(window.FluidTopicsInternalHistoryService=tr.build(),window.FluidTopicsHistoryService={currentItem:()=>window.FluidTopicsInternalHistoryService.currentItem(),back:()=>window.FluidTopicsInternalHistoryService.back(),forward:()=>window.FluidTopicsInternalHistoryService.forward(),backwardItem:()=>window.FluidTopicsInternalHistoryService.backwardItem(),forwardItem:()=>window.FluidTopicsInternalHistoryService.forwardItem(),backwardItemMatching:r=>window.FluidTopicsInternalHistoryService.backwardItemMatching(r),addHistoryChangeListener:r=>window.FluidTopicsInternalHistoryService.addHistoryChangeListener(r),removeHistoryChangeListener:r=>window.FluidTopicsInternalHistoryService.removeHistoryChangeListener(r)});var js=v(F());var Bs=js.css`
|
|
49
49
|
`;var Ks=v(F()),z=v(K()),Re=v(T());var Ie=v(T());function Hs(r,e){let{authenticationRequired:t,session:n}=y.getState();return t&&!n?.sessionAuthenticated?Promise.resolve(e):r()}var rr=class extends We{async updateUiLocale(e){return(await this.awaitApi).updateUiLocale(e)}};var hn=class r extends Ie.FtStateManager{static build(e){return new r(y,e)}constructor(e,t){super(),this.store=e,this.cache=new Ie.CacheRegistry,this.withManualResources=!0,this.localesConfiguration=null,this.userLocaleService=new rr,this.cleanSessionDebouncer=new Ie.Debouncer,this.reloadDebouncer=new Ie.Debouncer(500),this.apiProvider=t??(()=>Ce.get())}setWithManualResources(e){this.withManualResources=e,this.updateIfNeeded()}async initService(){this.store.addEventListener(le.eventName,this.reloadConfiguration)}async updateIfNeeded(){this.apiProvider()&&(this.withManualResources||(this.store.getState().session==null&&this.updateSession(),this.store.getState().metadataConfiguration==null&&this.updateMetadataConfiguration()),this.localesConfiguration==null&&this.updateLocalesConfiguration(),(this.store.getState().availableContentLocales==null||this.store.getState().availableContentLocales.length==0)&&this.updateAvailableContentLocales())}async updateSession(){let e=await this.cache.get("session",async()=>{let t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run(()=>{this.cache.clear("session"),this.setSession(void 0)},t.idleTimeoutInMillis),t});this.setSession(e)}async updateMetadataConfiguration(){this.setMetadataConfiguration(await this.cache.get("metadataConfiguration",()=>this.apiProvider().getMetadataConfiguration()))}async updateLocalesConfiguration(){this.setLocalesConfiguration(await this.cache.get("localesConfiguration",()=>this.apiProvider().getLocalesConfiguration()))}async updateAvailableContentLocales(){var e;let t=await this.cache.get("availableContentLocales",()=>Hs(()=>this.apiProvider().getAvailableSearchLocales(),{contentLocales:[]}));this.setAvailableContentLocales((e=t.contentLocales)!==null&&e!==void 0?e:[])}reloadConfiguration(){var e;(e=this.cache)===null||e===void 0||e.clear("availableContentLocales"),typeof this.updateAvailableContentLocales=="function"&&this.updateAvailableContentLocales()}setBaseUrl(e){this.store.actions.baseUrl(e),window.fluidTopicsBaseUrl=e}setApiIntegrationIdentifier(e){this.store.actions.apiIntegrationIdentifier(e)}setApiIntegrationAppVersion(e){this.store.actions.apiIntegrationAppVersion(e)}setUiLocale(e){this.store.actions.uiLocale(e)}setLocalesConfiguration(e){var t,n,i,s,a;this.localesConfiguration=e,this.store.actions.defaultLocales(this.localesConfiguration.defaultLocales),this.store.actions.availableUiLocales((t=this.localesConfiguration.availableUiLocales)!==null&&t!==void 0?t:[]),this.store.actions.searchInAllLanguagesAllowed((n=this.localesConfiguration.allLanguagesAllowed)!==null&&n!==void 0?n:!1),this.store.actions.searchLanguageSetsUiLanguage((i=this.localesConfiguration.searchLanguageSetsUiLanguage)!==null&&i!==void 0?i:!1),this.store.actions.uiLanguageSetsSearchLanguage((s=this.localesConfiguration.uiLanguageSetsSearchLanguage)!==null&&s!==void 0?s:!1),this.store.actions.uiLanguageSetsReaderLanguage((a=this.localesConfiguration.uiLanguageSetsReaderLanguage)!==null&&a!==void 0?a:!1),setTimeout(()=>this.updateIfNeeded())}setAvailableContentLocales(e){this.store.actions.availableContentLocales(e),setTimeout(()=>this.updateIfNeeded())}stopReloadDebouncer(){this.reloadDebouncer.cancel()}requestUiLocaleUpdate(e){this.userLocaleService.updateUiLocale({uiLocale:e}).then(t=>{t.uiLocaleChanged&&(this.reloadDebouncer.run(()=>window.location.reload()),this.store.dispatchEvent(new yt(t)))}).catch(()=>{})}setMetadataConfiguration(e){this.store.actions.metadataConfiguration(e),setTimeout(()=>this.updateIfNeeded())}setNoCustom(e){this.store.actions.noCustom(e)}setEditorMode(e){this.store.actions.editorMode(e)}setNoCustomComponent(e){this.store.actions.noCustomComponent(e)}setSession(e){this.store.actions.session(e),setTimeout(()=>this.updateIfNeeded())}setOpenExternalDocumentInNewTab(e){this.store.actions.openExternalDocumentInNewTab(e)}setNavigatorOnline(e){this.store.actions.navigatorOnline(e)}setForcedOffline(e){this.store.actions.forcedOffline(e)}setAuthenticationRequired(e){this.store.actions.authenticationRequired(e)}},Vs=hn.build();var _e=class extends Event{constructor(e,t,n,i){super("context-request",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t,this.callback=n,this.subscribe=i??!1}};var St=class{constructor(){this.pendingContextRequests=new Map,this.onContextProvider=e=>{let t=this.pendingContextRequests.get(e.context);if(t===void 0)return;this.pendingContextRequests.delete(e.context);let{requests:n}=t;for(let{elementRef:i,callbackRef:s}of n){let a=i.deref(),o=s.deref();a===void 0||o===void 0||a.dispatchEvent(new _e(e.context,a,o,!0))}},this.onContextRequest=e=>{if(e.subscribe!==!0)return;let t=e.contextTarget??e.composedPath()[0],n=e.callback,i=this.pendingContextRequests.get(e.context);i===void 0&&this.pendingContextRequests.set(e.context,i={callbacks:new WeakMap,requests:[]});let s=i.callbacks.get(t);s===void 0&&i.callbacks.set(t,s=new WeakSet),s.has(n)||(s.add(n),i.requests.push({elementRef:new WeakRef(t),callbackRef:new WeakRef(n)}))}}attach(e){e.addEventListener("context-request",this.onContextRequest),e.addEventListener("context-provider",this.onContextProvider)}detach(e){e.removeEventListener("context-request",this.onContextRequest),e.removeEventListener("context-provider",this.onContextProvider)}};var U=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},O=class extends Re.FtLitElementRedux{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.apiIntegrationAppVersion="ft-integration-app-version",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.authenticationRequired=!1,this.messageContexts=[],this.stateManager=Vs,this.contextRoot=new St}render(){return Ks.html`
|
|
50
50
|
<slot></slot>
|
|
51
|
-
`}connectedCallback(){super.connectedCallback(),this.stateManager.initService(),this.contextRoot.attach(document.body)}disconnectedCallback(){super.disconnectedCallback(),this.contextRoot.detach(document.body)}update(e){var t;super.update(e),e.has("baseUrl")&&this.stateManager.setBaseUrl(this.baseUrl),e.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),e.has("apiIntegrationAppVersion")&&this.stateManager.setApiIntegrationAppVersion(this.apiIntegrationAppVersion),e.has("uiLocale")&&this.stateManager.setUiLocale(this.uiLocale),e.has("metadataConfiguration")&&this.stateManager.setMetadataConfiguration(this.metadataConfiguration),e.has("noCustom")&&this.stateManager.setNoCustom(this.noCustom),e.has("editorMode")&&this.stateManager.setEditorMode(this.editorMode),e.has("noCustomComponent")&&this.stateManager.setNoCustomComponent(this.noCustomComponent),e.has("session")&&this.stateManager.setSession(this.session),e.has("messageContexts")&&this.messageContexts!=null&&this.messageContexts.forEach(n=>Ds.addContext(n)),e.has("openExternalDocumentInNewTab")&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab),e.has("navigatorOnline")&&this.stateManager.setNavigatorOnline(this.navigatorOnline),e.has("forcedOffline")&&this.stateManager.setForcedOffline(this.forcedOffline),e.has("authenticationRequired")&&this.stateManager.setAuthenticationRequired(this.authenticationRequired),e.has("withManualResources")&&((t=this.stateManager)===null||t===void 0||t.setWithManualResources(this.withManualResources)),setTimeout(()=>this.stateManager.updateIfNeeded())}};O.elementDefinitions={};O.styles=Bs;U([(0,z.property)()],O.prototype,"baseUrl",void 0);U([(0,z.property)()],O.prototype,"apiIntegrationIdentifier",void 0);U([(0,z.property)()],O.prototype,"apiIntegrationAppVersion",void 0);U([(0,z.property)()],O.prototype,"uiLocale",void 0);U([(0,Re.jsonProperty)(null)],O.prototype,"availableUiLocales",void 0);U([(0,Re.jsonProperty)(null)],O.prototype,"metadataConfiguration",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"editorMode",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"noCustom",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"openExternalDocumentInNewTab",void 0);U([(0,z.property)({converter:{fromAttribute(r){return r==="false"?!1:r==="true"||(r??!1)}}})],O.prototype,"noCustomComponent",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"withManualResources",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"navigatorOnline",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"forcedOffline",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"authenticationRequired",void 0);U([(0,Re.jsonProperty)([])],O.prototype,"messageContexts",void 0);U([(0,Re.jsonProperty)(void 0)],O.prototype,"session",void 0);var zs=v(T());var qs={"ft-app-context":O};(0,zs.customElements)(qs);var nr=class extends k{get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,t,n){super(!1,t),this.converter=e,this._mapId=n,this.initCache()}async withMapId(e){return this._mapId?e(this._mapId):void 0}initCache(){this.cache.register("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(e,t)))),this.cache.register("ratingSummary",()=>{var e,t;return oe((t=(e=y.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&t!==void 0?t:[],"RATING_USER")?this.withMapId(i=>this.fetchMapRating(i)):Promise.resolve()})}clear(){this.cache.clearMatching(e=>e!=="configuration")}makeCacheKey(e,t){return e+(t?"-destinationLanguage-"+t?.destinationLanguage:"")}getMap(e){return this.cache.get(this.makeCacheKey("map",e),()=>this.fetchMap(this.mapId,e))}getMapNow(e){return this.cache.getNow(this.makeCacheKey("map",e))}getConfiguration(){return this.cache.get("configuration")}clearConfiguration(){this.cache.clear("configuration")}getEnrichedToc(e){return this.cache.get(this.makeCacheKey("enrichedToc",e),()=>this.fetchPages(this.mapId,e).then(t=>this.converter.convertPaginatedToc(this.mapId,t)))}getEnrichedTocNow(e){return this.cache.getNow(this.makeCacheKey("enrichedToc",e))}async getPaginationConfiguration(){return(await this.getEnrichedToc()).paginationConfiguration}async getToc(e){return(await this.getEnrichedToc(e)).toc}async getPagesToc(e){return(await this.getEnrichedToc(e)).pagesToc}async getTranslationError(e){return(await this.getEnrichedToc(e)).translationError}async getTocNode(e,t){return(await this.getEnrichedToc(t)).nodeByTocId[e]}getTocNodeNow(e,t){var n;return(n=this.getEnrichedTocNow(t))===null||n===void 0?void 0:n.nodeByTocId[e]}getTocNodeNowByUrl(e,t){var n,i;let s=this.getMapNow(t);return s?.prettyUrl==e||`${s?.id}/root`===e?(n=this.getEnrichedTocNow(t))===null||n===void 0?void 0:n.toc[0]:(i=this.getEnrichedTocNow(t))===null||i===void 0?void 0:i.nodeByUrl[e]}async getPage(e,t){let n=await this.getEnrichedToc(t);return n.pages[e-1]||n.pages[0]}async getPageByTocId(e,t){let n=await this.getEnrichedToc(t);return n.pageByTocId[e]||n.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))}getTranslatedTopicContent(e,t){return this.cache.get(this.makeCacheKey("translated-topic-content-"+e.tocId,t),()=>this.fetchTranslatedTopicHTMLContent(e,t))}async getTopicMetadataValue(e,t){let n=this.getTocNodeNow(e);if(!n)return;let i=await this.getTopicInfo(n);return i?.metadata.find(s=>s.key==t)}getAttachments(){return this.cache.get("map-attachments",()=>this.fetchAttachments())}clearMapAttachments(){this.cache.clear("map-attachments")}getRelativesForDocument(e,t){return this.cache.get("document-relatives-"+e+"-"+t.join("-"),()=>this.fetchRelativesForDocument(e,t))}getRelativesForTopicInMap(e,t,n){return this.cache.get("topic-relatives-"+[e,t,...n].join("-"),()=>this.fetchRelativesForTopicInMap(e,t,n))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true&locationValue=reader`)}getLink(e,t,n){let i=this.getNavigationData(e,t,n),s=this.getReaderLinkPrefix()+(i.prettyUrl?i.prettyUrl:`${i.mapId}/${i.tocId}`),a=new URL(s,this.api.tenantBaseUrl);return i.page!=null&&a.searchParams.set("page",`${i.page}`),i.prettyUrlDuplicated&&a.searchParams.set("tocId",i.tocId),i.section!=null&&a.searchParams.set("section",i.section),a.href}getNavigationData(e,t,n,i){var s,a;e=e||"root";let o=this.getEnrichedTocNow(i),c=o?.pageByTocId[e],l=o?.nodeByTocId[e],u=l?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(s=l?.title)!==null&&s!==void 0?s:"",untranslatedTopicTitle:l?.untranslatedTitle,page:t&&c&&c.number!==t?t:void 0,prettyUrl:u?.replace(/^r\//,""),prettyUrlDuplicated:(a=o?.duplicatedPrettyUrls.has(u??""))!==null&&a!==void 0?a:!1,section:n}}async getAccurateNavigationData(e,t,n,i){return await this.getEnrichedToc(i),this.getNavigationData(e,t,n,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 n;return t?{type:t.topics.type,rating:(n=t.topics)===null||n===void 0?void 0:n.ratings.find(i=>i.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,n){return this.makeRateTopicRequest(e,t,n).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=y.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,t,n){return this.makeTopicFeedbackRequest(e,t,n)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e,t){let n=this.getTocNodeNow(e,t),i=[{tocId:n.tocId,title:n.title,untranslatedTitle:n.untranslatedTitle}],s=this.getTocNodeNow(n.parentTocId,t);for(;s;)i.unshift({tocId:s.tocId,title:s.title,untranslatedTitle:s.untranslatedTitle}),s=this.getTocNodeNow(s.parentTocId,t);return i}isFeatureAccessible(e,{session:t}){var n;if(!this.isFeatureAvailable(e))return!1;switch(e){case ae.FEEDBACK:return oe(t??[],C.FEEDBACK_USER);case ae.RATING:return oe(t??[],C.RATING_USER);case ae.PRINT:return oe(t??[],C.PRINT_USER);case ae.BOOKMARK:return!!t?.sessionAuthenticated;case ae.COLLECTIONS:return oe(t??[],C.COLLECTION_USER);case ae.PERSONAL_BOOKS:return oe(t??[],C.PERSONAL_BOOK_USER)&&!(!((n=this.getMapNow())===null||n===void 0)&&n.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var ir=class r extends nr{static async build(e){return new r(new Ot,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e,t){let n=await this.api.getMap(e,t);return this.fingerprint=n.fingerprint,n}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e,t){return await this.getMap(t),this.api.getPages(e,this.fingerprint,t)}fetchTopicHTMLContent(e){return this.api.getTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint)}fetchTranslatedTopicHTMLContent(e,t){return this.api.getTranslatedTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint,t)}fetchTopicMetadata(e){return this.api.getTopic(this.mapId,e.contentId,this.fingerprint)}fetchAttachments(){return this.api.getMapAttachments(this.mapId).catch(()=>[])}fetchRelativesForDocument(e,t){let n={query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",metadataFilters:[{key:e,valueFilter:{negative:!1,values:t}}],sort:[],facets:[]};return this.api.search(n)}fetchRelativesForTopicInMap(e,t,n){let i={query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",metadataFilters:[{key:t,valueFilter:{negative:!1,values:n}},{key:"ft:publicationId",valueFilter:{negative:!1,values:[e]}}],sort:[],facets:[]};return this.api.search(i)}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,n){return this.api.rateTopic(this.mapId,e,t,n)}makeTopicFeedbackRequest(e,t,n){return this.api.sendTopicFeedback(this.mapId,e,t,n)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var jo="topicPivot";function Ws(r,e){let t=new URL(r);return e?.values.forEach(n=>{t.searchParams.append(jo,n)}),t.href}var sr=class r{static build(e,t){return new r(Zn(e.trim()||"context"),t??ir.build)}loaded(){return(0,H.waitUntil)(()=>this._loaded)}constructor(e,t,n,i){this.store=e,this.clusteringHelperProvider=n,this.metadataForSwitchToRelatives=new Set,this._loaded=!1,this.loadDebouncer=new H.Debouncer(10),this.analyticsEventsService=i??new er,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())}setRenderedTopics(e){this.store.actions.renderedTopics(e)}setVisibleTopics(e){this.store.actions.visibleTopics(e)}async awaitService(){return(0,H.waitFor)(()=>this.service)}async navigateToTopic(e,t,n){await this.loaded();let i=await this.awaitService(),s=await(n!=null?i.getPage(n,this.getTranslationSettings()):i.getPageByTocId(e??"root",this.getTranslationSettings()));this.store.actions.currentPage(s);let a=this.resolveValidNonRootTocId(e,s);this.store.actions.scrollTarget({tocId:a,section:t}),this.store.getState().visibleTopics[0]!==a&&this.store.actions.visibleTopics([])}resolveValidNonRootTocId(e,t){var n,i,s;let a=(n=e==="root"?void 0:e)!==null&&n!==void 0?n:t.rootTocId;return t.topics.includes(a)?a:(e!="root"&&this.store.dispatchEvent(new CustomEvent(pe.requestedTopicNotFound,{detail:{tocId:a}})),(s=(i=t.topics[0])!==null&&i!==void 0?i:t.hiddenTopics[0])!==null&&s!==void 0?s:"root")}async navigateToPage(e){await this.loaded();let n=await(await this.awaitService()).getPage(e,this.getTranslationSettings());this.store.actions.currentPage(n)}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(this.getTranslationSettings()))}clear(){var e;this._loaded=!1,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),this.store.actions.renderedTopics([]),this.store.actions.visibleTopics([]),this.store.actions.translation({sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1}),this.store.actions.mapRating(void 0),(e=this.service)===null||e===void 0||e.clear(),this.clusteringHelper=void 0}reload(){return this.clear(),this.load()}async fetchData(e){var t,n,i,s,a;try{e&&this.setTranslationLoading(!0);let o=c=>{throw e&&this.setTranslationError(!0),c};await Promise.all([this.loadConfiguration(),(t=this.service)===null||t===void 0?void 0:t.getMap(e).then(c=>this.store.actions.map(c)).catch(o),(n=this.service)===null||n===void 0?void 0:n.getToc(e).then(c=>this.store.actions.toc(c)).catch(o),(i=this.service)===null||i===void 0?void 0:i.getPagesToc(e).then(c=>this.store.actions.pagesToc(c)).catch(o),(s=this.service)===null||s===void 0?void 0:s.getPaginationConfiguration().then(c=>this.store.actions.paginationConfiguration(c)).catch(o),(a=this.service)===null||a===void 0?void 0:a.getTranslationError(e).then(c=>this.setTranslationError(c))]),this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives(),this._loaded=!0,e&&this.setTranslationLoading(!1)}catch(o){this.errorHandler&&!(o instanceof H.CanceledPromiseError)&&this.errorHandler(o)}}loadConfiguration(){var e;return(e=this.service)===null||e===void 0?void 0:e.getConfiguration().then(t=>this.store.actions.configuration(t))}reloadConfiguration(){var e;return(e=this.service)===null||e===void 0||e.clearConfiguration(),this.loadConfiguration()}async fetchRelatives(){var e,t;let n=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(i=>{var s;return i.key==((s=this.store.getState().configuration)===null||s===void 0?void 0:s.relativePivotMetadata)}).flatMap(i=>i.values);if(n!==void 0&&n.length>0){let i=await((t=this.service)===null||t===void 0?void 0:t.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata,n)),s=i?.results.flatMap(a=>a.entries);this.store.actions.relatives(s)}this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.dispatchEvent(new Event(pe.clusteringHelperCreated))}createClusteringHelper(){var e,t;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let n=this.store.getState().relatives;if(n){let i=n.find(a=>{var o;return((o=a.map)===null||o===void 0?void 0:o.mapId)==this.store.getState().mapId}),s=(t=(e=y.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&t!==void 0?t:[];return new H.ClusteringHelper(n,i,this.metadataForSwitchToRelatives,s)}}async navigateToRelativeTopicIfFound(e){var t,n,i;await this.loaded();let s=await(0,H.waitFor)(()=>{var l;return(l=this.store.getState().configuration)===null||l===void 0?void 0:l.relativeTopicPivotMetadata}),a=this.store.getState().mapId,c=await(await this.awaitService()).getRelativesForTopicInMap(a,s,[e]);if(!((i=(n=(t=c?.results)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.entries)===null||i===void 0)&&i[0]){let l=c.results[0].entries[0].topic.tocId;return await this.navigateToTopic(l),!0}else return await this.navigateToTopic("root"),!1}setSearchInDocumentQuery(e){this.store.actions.searchInDocumentQuery(e)}async setTranslationDestinationLanguage(e){this.store.actions.setTranslationDestinationLanguage(e),e&&this.sendDocumentOnDemandTranslateEvent(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationSourceLanguage(e){this.store.actions.setTranslationSourceLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationProfileId(e){this.store.actions.setTranslationProfileId(e)}async setTranslationLoading(e){this.store.actions.setTranslationLoading(e)}async setTranslationError(e){this.store.actions.setTranslationError(e)}getTranslationSettings(){var e;let t=this.store.getState();return t.translation.profileId&&t.translation.destinationLanguage?{profileId:t.translation.profileId,destinationLanguage:t.translation.destinationLanguage.code,sourceLanguage:(e=t.map)===null||e===void 0?void 0:e.lang}:void 0}setLinkPreviewDialogId(e){this.store.actions.linkPreviewDialogId(e)}async fetchMapRating(){var e;this.store.actions.mapRating(await((e=this.service)===null||e===void 0?void 0:e.getMapRating()))}async fetchTopicRating(e){var t;let n=await((t=this.service)===null||t===void 0?void 0:t.getTopicRating(e));n&&this.store.actions.setTopicsRating({[e]:n})}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}getAccurateNavigationData(e,t,n){return this.service.getAccurateNavigationData(e,t?.number,n?.section,this.getTranslationSettings())}buildBreadcrumb(e){var t;return(t=this.service)===null||t===void 0?void 0:t.buildBreadcrumb(e,this.getTranslationSettings())}fetchTopicContent(e){var t,n;let i=this.getTranslationSettings();return i?(this.sendTopicAiTranslateEvent(i.destinationLanguage,e),(t=this.service)===null||t===void 0?void 0:t.getTranslatedTopicContent(e,i).then(s=>(s.isTranslationError&&this.setTranslationError(!0),s.content))):(n=this.service)===null||n===void 0?void 0:n.getTopicContent(e)}getTocNode(e){return this.service.getTocNode(e,this.getTranslationSettings())}getPage(e){return this.service.getPage(e,this.getTranslationSettings())}onMapAttachmentsUpdate(){var e;(e=this.service)===null||e===void 0||e.clearMapAttachments(),this.store.dispatchEvent(new Event(pe.mapAttachmentsUpdate))}async getRelativeDocumentUrlForLocale(e){var t,n,i;this.store.getState().relatives==null&&await this.fetchRelatives();let s=H.ClusteringHelper.findResultWithMetadataValue((t=this.store.getState().relatives)!==null&&t!==void 0?t:[],"ft:locale",e),a=(0,H.accessResultUrl)(s);if(a){let o=this.store.getState().visibleTopics[0],c=(n=this.store.getState().configuration)===null||n===void 0?void 0:n.relativeTopicPivotMetadata;if(c&&o){let l=await((i=this.service)===null||i===void 0?void 0:i.getTopicMetadataValue(o,c));a=Ws(a,l)}}return a}sendDocumentOnDemandTranslateEvent(e){var t;let{editorMode:n,apiIntegrationIdentifier:i,apiIntegrationAppVersion:s}=y.getState(),a=this.store.getState(),o=a.map,c=a.translation.profileId;if(!(n||!o||!i||!s||!c))try{let u={...this.analyticsEventsService.convertMapToAnalyticsDocument(o),title:(t=o.untranslatedTitle)!==null&&t!==void 0?t:o.title};this.analyticsEventsService.sendDocumentOnDemandTranslateEvent({name:"DOCUMENT__ON_DEMAND_TRANSLATE",offline:!1,appName:i,appVersion:s,sourceLanguage:this.parseLanguageToAnalyticsFormat(o.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e.code),profileId:c,document:u,translationOrigin:Lt.AI})}catch(l){console.warn("Failed to send on-demand document translate event:",l)}}sendTopicAiTranslateEvent(e,t){var n;let{editorMode:i,apiIntegrationIdentifier:s,apiIntegrationAppVersion:a}=y.getState(),o=this.store.getState(),c=o.map,l=o.translation.profileId;if(!(i||!c||!s||!a||!l))try{let u=this.buildBreadcrumb(t.tocId);if(!u){console.warn("Failed to build breadcrumb for topic ai translate event");return}let h={...this.analyticsEventsService.convertMapToAnalyticsDocument(c),title:(n=c.untranslatedTitle)!==null&&n!==void 0?n:c.title};this.analyticsEventsService.sendTopicAiTranslateEvent({name:"TOPIC__AI_TRANSLATE",offline:!1,appName:s,appVersion:a,sourceLanguage:this.parseLanguageToAnalyticsFormat(c.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e),breadcrumb:u.map(f=>{var p;return{tocId:f.tocId,title:(p=f.untranslatedTitle)!==null&&p!==void 0?p:f.title}}),document:h,profileId:l})}catch(u){console.warn("Failed to send topic ai translate event:",u)}}parseLanguageToAnalyticsFormat(e){if(!e)return;let t=e.split("-");return t.length===2?{languageCode:t[0],countryCode:t[1]}:{languageCode:t[0],countryCode:""}}};var ar=class extends CustomEvent{constructor(e,t){super("ft-reader-map-loaded",{detail:{map:e,toc:t}})}},or=class extends CustomEvent{constructor(e,t){super("ft-reader-visible-topics-change",{detail:{visibleTopics:t}})}},cr=class extends CustomEvent{constructor(e){super("ft-reader-navigation-done",{detail:e})}},lr=class extends CustomEvent{constructor(e){super("ft-reader-load-error",{detail:e})}},ur=class extends Event{constructor(){super("ft-reader-map-not-found")}},dr=class extends Event{constructor(){super("ft-reader-map-unauthorized")}},hr=class extends Event{constructor(){super("ft-reader-map-forbidden")}},pr=class extends Event{constructor(){super("ft-reader-topic-relative-not-found",{bubbles:!0,composed:!0})}};var V=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},pn=class{constructor(e){this.stateManager=e}searchInDocument(e){this.stateManager.setSearchInDocumentQuery(e??"")}},L=class extends M.FtLitElementRedux{constructor(){super(),this.visibleTopics=[],this.updateConfiguration=()=>{this.stateManager.reloadConfiguration()},this.scrollToTargetDebouncer=new M.Debouncer(5),this.navigationDebouncer=new M.Debouncer(10),this.mapLoadedEventDebouncer=new M.Debouncer(50),this.addStore(y)}render(){return At.html`
|
|
51
|
+
`}connectedCallback(){super.connectedCallback(),this.stateManager.initService(),this.contextRoot.attach(document.body)}disconnectedCallback(){super.disconnectedCallback(),this.contextRoot.detach(document.body)}update(e){var t;super.update(e),e.has("baseUrl")&&this.stateManager.setBaseUrl(this.baseUrl),e.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),e.has("apiIntegrationAppVersion")&&this.stateManager.setApiIntegrationAppVersion(this.apiIntegrationAppVersion),e.has("uiLocale")&&this.stateManager.setUiLocale(this.uiLocale),e.has("metadataConfiguration")&&this.stateManager.setMetadataConfiguration(this.metadataConfiguration),e.has("noCustom")&&this.stateManager.setNoCustom(this.noCustom),e.has("editorMode")&&this.stateManager.setEditorMode(this.editorMode),e.has("noCustomComponent")&&this.stateManager.setNoCustomComponent(this.noCustomComponent),e.has("session")&&this.stateManager.setSession(this.session),e.has("messageContexts")&&this.messageContexts!=null&&this.messageContexts.forEach(n=>Ds.addContext(n)),e.has("openExternalDocumentInNewTab")&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab),e.has("navigatorOnline")&&this.stateManager.setNavigatorOnline(this.navigatorOnline),e.has("forcedOffline")&&this.stateManager.setForcedOffline(this.forcedOffline),e.has("authenticationRequired")&&this.stateManager.setAuthenticationRequired(this.authenticationRequired),e.has("withManualResources")&&((t=this.stateManager)===null||t===void 0||t.setWithManualResources(this.withManualResources)),setTimeout(()=>this.stateManager.updateIfNeeded())}};O.elementDefinitions={};O.styles=Bs;U([(0,z.property)()],O.prototype,"baseUrl",void 0);U([(0,z.property)()],O.prototype,"apiIntegrationIdentifier",void 0);U([(0,z.property)()],O.prototype,"apiIntegrationAppVersion",void 0);U([(0,z.property)()],O.prototype,"uiLocale",void 0);U([(0,Re.jsonProperty)(null)],O.prototype,"availableUiLocales",void 0);U([(0,Re.jsonProperty)(null)],O.prototype,"metadataConfiguration",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"editorMode",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"noCustom",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"openExternalDocumentInNewTab",void 0);U([(0,z.property)({converter:{fromAttribute(r){return r==="false"?!1:r==="true"||(r??!1)}}})],O.prototype,"noCustomComponent",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"withManualResources",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"navigatorOnline",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"forcedOffline",void 0);U([(0,z.property)({type:Boolean})],O.prototype,"authenticationRequired",void 0);U([(0,Re.jsonProperty)([])],O.prototype,"messageContexts",void 0);U([(0,Re.jsonProperty)(void 0)],O.prototype,"session",void 0);var zs=v(T());var qs={"ft-app-context":O};(0,zs.customElements)(qs);var nr=class extends k{get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,t,n){super(!1,t),this.converter=e,this._mapId=n,this.initCache()}async withMapId(e){return this._mapId?e(this._mapId):void 0}initCache(){this.cache.register("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(e,t)))),this.cache.register("ratingSummary",()=>{var e,t;return oe((t=(e=y.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&t!==void 0?t:[],"RATING_USER")?this.withMapId(i=>this.fetchMapRating(i)):Promise.resolve()})}clear(){this.cache.clearMatching(e=>e!=="configuration")}makeCacheKey(e,t){return e+(t?"-destinationLanguage-"+t?.destinationLanguage:"")}getMap(e){return this.cache.get(this.makeCacheKey("map",e),()=>this.fetchMap(this.mapId,e))}getMapNow(e){return this.cache.getNow(this.makeCacheKey("map",e))}getConfiguration(){return this.cache.get("configuration")}clearConfiguration(){this.cache.clear("configuration")}getEnrichedToc(e){return this.cache.get(this.makeCacheKey("enrichedToc",e),()=>this.fetchPages(this.mapId,e).then(t=>this.converter.convertPaginatedToc(this.mapId,t)))}getEnrichedTocNow(e){return this.cache.getNow(this.makeCacheKey("enrichedToc",e))}async getPaginationConfiguration(){return(await this.getEnrichedToc()).paginationConfiguration}async getToc(e){return(await this.getEnrichedToc(e)).toc}async getPagesToc(e){return(await this.getEnrichedToc(e)).pagesToc}async getTranslationError(e){return(await this.getEnrichedToc(e)).translationError}async getTocNode(e,t){return(await this.getEnrichedToc(t)).nodeByTocId[e]}getTocNodeNow(e,t){var n;return(n=this.getEnrichedTocNow(t))===null||n===void 0?void 0:n.nodeByTocId[e]}getTocNodeNowByUrl(e,t){var n,i;let s=this.getMapNow(t);return s?.prettyUrl==e||`${s?.id}/root`===e?(n=this.getEnrichedTocNow(t))===null||n===void 0?void 0:n.toc[0]:(i=this.getEnrichedTocNow(t))===null||i===void 0?void 0:i.nodeByUrl[e]}async getPage(e,t){let n=await this.getEnrichedToc(t);return n.pages[e-1]||n.pages[0]}async getPageByTocId(e,t){let n=await this.getEnrichedToc(t);return n.pageByTocId[e]||n.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))}getTranslatedTopicContent(e,t){return this.cache.get(this.makeCacheKey("translated-topic-content-"+e.tocId,t),()=>this.fetchTranslatedTopicHTMLContent(e,t))}async getTopicMetadataValue(e,t){let n=this.getTocNodeNow(e);if(!n)return;let i=await this.getTopicInfo(n);return i?.metadata.find(s=>s.key==t)}getAttachments(){return this.cache.get("map-attachments",()=>this.fetchAttachments())}clearMapAttachments(){this.cache.clear("map-attachments")}getRelativesForDocument(e,t){return this.cache.get("document-relatives-"+e+"-"+t.join("-"),()=>this.fetchRelativesForDocument(e,t))}getRelativesForTopicInMap(e,t,n){return this.cache.get("topic-relatives-"+[e,t,...n].join("-"),()=>this.fetchRelativesForTopicInMap(e,t,n))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true&locationValue=reader`)}getLink(e,t,n){let i=this.getNavigationData(e,t,n),s=this.getReaderLinkPrefix()+(i.prettyUrl?i.prettyUrl:`${i.mapId}/${i.tocId}`),a=new URL(s,this.api.tenantBaseUrl);return i.page!=null&&a.searchParams.set("page",`${i.page}`),i.prettyUrlDuplicated&&a.searchParams.set("tocId",i.tocId),i.section!=null&&a.searchParams.set("section",i.section),a.href}getNavigationData(e,t,n,i){var s,a;e=e||"root";let o=this.getEnrichedTocNow(i),c=o?.pageByTocId[e],l=o?.nodeByTocId[e],u=l?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(s=l?.title)!==null&&s!==void 0?s:"",untranslatedTopicTitle:l?.untranslatedTitle,page:t&&c&&c.number!==t?t:void 0,prettyUrl:u?.replace(/^r\//,""),prettyUrlDuplicated:(a=o?.duplicatedPrettyUrls.has(u??""))!==null&&a!==void 0?a:!1,section:n}}async getAccurateNavigationData(e,t,n,i){return await this.getEnrichedToc(i),this.getNavigationData(e,t,n,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 n;return t?{type:t.topics.type,rating:(n=t.topics)===null||n===void 0?void 0:n.ratings.find(i=>i.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,n){return this.makeRateTopicRequest(e,t,n).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=y.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,t,n){return this.makeTopicFeedbackRequest(e,t,n)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e,t){let n=this.getTocNodeNow(e,t),i=[{tocId:n.tocId,title:n.title,untranslatedTitle:n.untranslatedTitle}],s=this.getTocNodeNow(n.parentTocId,t);for(;s;)i.unshift({tocId:s.tocId,title:s.title,untranslatedTitle:s.untranslatedTitle}),s=this.getTocNodeNow(s.parentTocId,t);return i}isFeatureAccessible(e,{session:t}){var n;if(!this.isFeatureAvailable(e))return!1;switch(e){case ae.FEEDBACK:return oe(t??[],C.FEEDBACK_USER);case ae.RATING:return oe(t??[],C.RATING_USER);case ae.PRINT:return oe(t??[],C.PRINT_USER);case ae.BOOKMARK:return!!t?.sessionAuthenticated;case ae.COLLECTIONS:return oe(t??[],C.COLLECTION_USER);case ae.PERSONAL_BOOKS:return oe(t??[],C.PERSONAL_BOOK_USER)&&!(!((n=this.getMapNow())===null||n===void 0)&&n.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var ir=class r extends nr{static async build(e){return new r(new Ot,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e,t){let n=await this.api.getMap(e,t);return this.fingerprint=n.fingerprint,n}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e,t){return await this.getMap(t),this.api.getPages(e,this.fingerprint,t)}fetchTopicHTMLContent(e){return this.api.getTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint)}fetchTranslatedTopicHTMLContent(e,t){return this.api.getTranslatedTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint,t)}fetchTopicMetadata(e){return this.api.getTopic(this.mapId,e.contentId,this.fingerprint)}fetchAttachments(){return this.api.getMapAttachments(this.mapId).catch(()=>[])}fetchRelativesForDocument(e,t){let n={query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",metadataFilters:[{key:e,valueFilter:{negative:!1,values:t}}],sort:[],facets:[]};return this.api.search(n)}fetchRelativesForTopicInMap(e,t,n){let i={query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",metadataFilters:[{key:t,valueFilter:{negative:!1,values:n}},{key:"ft:publicationId",valueFilter:{negative:!1,values:[e]}}],sort:[],facets:[]};return this.api.search(i)}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,n){return this.api.rateTopic(this.mapId,e,t,n)}makeTopicFeedbackRequest(e,t,n){return this.api.sendTopicFeedback(this.mapId,e,t,n)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var jo="topicPivot";function Ws(r,e){let t=new URL(r);return e?.values.forEach(n=>{t.searchParams.append(jo,n)}),t.href}var sr=class r{static build(e,t){return new r(Zn(e.trim()||"context"),t??ir.build)}loaded(){return(0,H.waitUntil)(()=>this._loaded)}constructor(e,t,n,i){this.store=e,this.clusteringHelperProvider=n,this.metadataForSwitchToRelatives=new Set,this._loaded=!1,this.loadDebouncer=new H.Debouncer(10),this.analyticsEventsService=i??new er,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())}setRenderedTopics(e){this.store.actions.renderedTopics(e)}setVisibleTopics(e){this.store.actions.visibleTopics(e)}async awaitService(){return(0,H.waitFor)(()=>this.service)}async navigateToTopic(e,t,n){await this.loaded();let i=await this.awaitService(),s=await(n!=null?i.getPage(n,this.getTranslationSettings()):i.getPageByTocId(e??"root",this.getTranslationSettings()));this.store.actions.currentPage(s);let a=this.resolveValidNonRootTocId(e,s);this.store.actions.scrollTarget({tocId:a,section:t}),this.store.getState().visibleTopics[0]!==a&&this.store.actions.visibleTopics([])}resolveValidNonRootTocId(e,t){var n,i,s;let a=(n=e==="root"?void 0:e)!==null&&n!==void 0?n:t.rootTocId;return t.topics.includes(a)?a:(e!="root"&&!t.hiddenTopics.includes(a)&&this.store.dispatchEvent(new CustomEvent(pe.requestedTopicNotFound,{detail:{tocId:a}})),(s=(i=t.topics[0])!==null&&i!==void 0?i:t.hiddenTopics[0])!==null&&s!==void 0?s:"root")}async navigateToPage(e){await this.loaded();let n=await(await this.awaitService()).getPage(e,this.getTranslationSettings());this.store.actions.currentPage(n)}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(this.getTranslationSettings()))}clear(){var e;this._loaded=!1,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),this.store.actions.renderedTopics([]),this.store.actions.visibleTopics([]),this.store.actions.translation({sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1}),this.store.actions.mapRating(void 0),(e=this.service)===null||e===void 0||e.clear(),this.clusteringHelper=void 0}reload(){return this.clear(),this.load()}async fetchData(e){var t,n,i,s,a;try{e&&this.setTranslationLoading(!0);let o=c=>{throw e&&this.setTranslationError(!0),c};await Promise.all([this.loadConfiguration(),(t=this.service)===null||t===void 0?void 0:t.getMap(e).then(c=>this.store.actions.map(c)).catch(o),(n=this.service)===null||n===void 0?void 0:n.getToc(e).then(c=>this.store.actions.toc(c)).catch(o),(i=this.service)===null||i===void 0?void 0:i.getPagesToc(e).then(c=>this.store.actions.pagesToc(c)).catch(o),(s=this.service)===null||s===void 0?void 0:s.getPaginationConfiguration().then(c=>this.store.actions.paginationConfiguration(c)).catch(o),(a=this.service)===null||a===void 0?void 0:a.getTranslationError(e).then(c=>this.setTranslationError(c))]),this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives(),this._loaded=!0,e&&this.setTranslationLoading(!1)}catch(o){this.errorHandler&&!(o instanceof H.CanceledPromiseError)&&this.errorHandler(o)}}loadConfiguration(){var e;return(e=this.service)===null||e===void 0?void 0:e.getConfiguration().then(t=>this.store.actions.configuration(t))}reloadConfiguration(){var e;return(e=this.service)===null||e===void 0||e.clearConfiguration(),this.loadConfiguration()}async fetchRelatives(){var e,t;let n=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(i=>{var s;return i.key==((s=this.store.getState().configuration)===null||s===void 0?void 0:s.relativePivotMetadata)}).flatMap(i=>i.values);if(n!==void 0&&n.length>0){let i=await((t=this.service)===null||t===void 0?void 0:t.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata,n)),s=i?.results.flatMap(a=>a.entries);this.store.actions.relatives(s)}this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.dispatchEvent(new Event(pe.clusteringHelperCreated))}createClusteringHelper(){var e,t;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let n=this.store.getState().relatives;if(n){let i=n.find(a=>{var o;return((o=a.map)===null||o===void 0?void 0:o.mapId)==this.store.getState().mapId}),s=(t=(e=y.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&t!==void 0?t:[];return new H.ClusteringHelper(n,i,this.metadataForSwitchToRelatives,s)}}async navigateToRelativeTopicIfFound(e){var t,n,i;await this.loaded();let s=await(0,H.waitFor)(()=>{var l;return(l=this.store.getState().configuration)===null||l===void 0?void 0:l.relativeTopicPivotMetadata}),a=this.store.getState().mapId,c=await(await this.awaitService()).getRelativesForTopicInMap(a,s,[e]);if(!((i=(n=(t=c?.results)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.entries)===null||i===void 0)&&i[0]){let l=c.results[0].entries[0].topic.tocId;return await this.navigateToTopic(l),!0}else return await this.navigateToTopic("root"),!1}setSearchInDocumentQuery(e){this.store.actions.searchInDocumentQuery(e)}async setTranslationDestinationLanguage(e){this.store.actions.setTranslationDestinationLanguage(e),e&&this.sendDocumentOnDemandTranslateEvent(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationSourceLanguage(e){this.store.actions.setTranslationSourceLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationProfileId(e){this.store.actions.setTranslationProfileId(e)}async setTranslationLoading(e){this.store.actions.setTranslationLoading(e)}async setTranslationError(e){this.store.actions.setTranslationError(e)}getTranslationSettings(){var e;let t=this.store.getState();return t.translation.profileId&&t.translation.destinationLanguage?{profileId:t.translation.profileId,destinationLanguage:t.translation.destinationLanguage.code,sourceLanguage:(e=t.map)===null||e===void 0?void 0:e.lang}:void 0}setLinkPreviewDialogId(e){this.store.actions.linkPreviewDialogId(e)}async fetchMapRating(){var e;this.store.actions.mapRating(await((e=this.service)===null||e===void 0?void 0:e.getMapRating()))}async fetchTopicRating(e){var t;let n=await((t=this.service)===null||t===void 0?void 0:t.getTopicRating(e));n&&this.store.actions.setTopicsRating({[e]:n})}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}getAccurateNavigationData(e,t,n){return this.service.getAccurateNavigationData(e,t?.number,n?.section,this.getTranslationSettings())}buildBreadcrumb(e){var t;return(t=this.service)===null||t===void 0?void 0:t.buildBreadcrumb(e,this.getTranslationSettings())}fetchTopicContent(e){var t,n;let i=this.getTranslationSettings();return i?(this.sendTopicAiTranslateEvent(i.destinationLanguage,e),(t=this.service)===null||t===void 0?void 0:t.getTranslatedTopicContent(e,i).then(s=>(s.isTranslationError&&this.setTranslationError(!0),s.content))):(n=this.service)===null||n===void 0?void 0:n.getTopicContent(e)}getTocNode(e){return this.service.getTocNode(e,this.getTranslationSettings())}getPage(e){return this.service.getPage(e,this.getTranslationSettings())}onMapAttachmentsUpdate(){var e;(e=this.service)===null||e===void 0||e.clearMapAttachments(),this.store.dispatchEvent(new Event(pe.mapAttachmentsUpdate))}async getRelativeDocumentUrlForLocale(e){var t,n,i;this.store.getState().relatives==null&&await this.fetchRelatives();let s=H.ClusteringHelper.findResultWithMetadataValue((t=this.store.getState().relatives)!==null&&t!==void 0?t:[],"ft:locale",e),a=(0,H.accessResultUrl)(s);if(a){let o=this.store.getState().visibleTopics[0],c=(n=this.store.getState().configuration)===null||n===void 0?void 0:n.relativeTopicPivotMetadata;if(c&&o){let l=await((i=this.service)===null||i===void 0?void 0:i.getTopicMetadataValue(o,c));a=Ws(a,l)}}return a}sendDocumentOnDemandTranslateEvent(e){var t;let{editorMode:n,apiIntegrationIdentifier:i,apiIntegrationAppVersion:s}=y.getState(),a=this.store.getState(),o=a.map,c=a.translation.profileId;if(!(n||!o||!i||!s||!c))try{let u={...this.analyticsEventsService.convertMapToAnalyticsDocument(o),title:(t=o.untranslatedTitle)!==null&&t!==void 0?t:o.title};this.analyticsEventsService.sendDocumentOnDemandTranslateEvent({name:"DOCUMENT__ON_DEMAND_TRANSLATE",offline:!1,appName:i,appVersion:s,sourceLanguage:this.parseLanguageToAnalyticsFormat(o.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e.code),profileId:c,document:u,translationOrigin:Lt.AI})}catch(l){console.warn("Failed to send on-demand document translate event:",l)}}sendTopicAiTranslateEvent(e,t){var n;let{editorMode:i,apiIntegrationIdentifier:s,apiIntegrationAppVersion:a}=y.getState(),o=this.store.getState(),c=o.map,l=o.translation.profileId;if(!(i||!c||!s||!a||!l))try{let u=this.buildBreadcrumb(t.tocId);if(!u){console.warn("Failed to build breadcrumb for topic ai translate event");return}let h={...this.analyticsEventsService.convertMapToAnalyticsDocument(c),title:(n=c.untranslatedTitle)!==null&&n!==void 0?n:c.title};this.analyticsEventsService.sendTopicAiTranslateEvent({name:"TOPIC__AI_TRANSLATE",offline:!1,appName:s,appVersion:a,sourceLanguage:this.parseLanguageToAnalyticsFormat(c.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e),breadcrumb:u.map(f=>{var p;return{tocId:f.tocId,title:(p=f.untranslatedTitle)!==null&&p!==void 0?p:f.title}}),document:h,profileId:l})}catch(u){console.warn("Failed to send topic ai translate event:",u)}}parseLanguageToAnalyticsFormat(e){if(!e)return;let t=e.split("-");return t.length===2?{languageCode:t[0],countryCode:t[1]}:{languageCode:t[0],countryCode:""}}};var ar=class extends CustomEvent{constructor(e,t){super("ft-reader-map-loaded",{detail:{map:e,toc:t}})}},or=class extends CustomEvent{constructor(e,t){super("ft-reader-visible-topics-change",{detail:{visibleTopics:t}})}},cr=class extends CustomEvent{constructor(e){super("ft-reader-navigation-done",{detail:e})}},lr=class extends CustomEvent{constructor(e){super("ft-reader-load-error",{detail:e})}},ur=class extends Event{constructor(){super("ft-reader-map-not-found")}},dr=class extends Event{constructor(){super("ft-reader-map-unauthorized")}},hr=class extends Event{constructor(){super("ft-reader-map-forbidden")}},pr=class extends Event{constructor(){super("ft-reader-topic-relative-not-found",{bubbles:!0,composed:!0})}};var V=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},pn=class{constructor(e){this.stateManager=e}searchInDocument(e){this.stateManager.setSearchInDocumentQuery(e??"")}},L=class extends M.FtLitElementRedux{constructor(){super(),this.visibleTopics=[],this.updateConfiguration=()=>{this.stateManager.reloadConfiguration()},this.scrollToTargetDebouncer=new M.Debouncer(5),this.navigationDebouncer=new M.Debouncer(10),this.mapLoadedEventDebouncer=new M.Debouncer(50),this.addStore(y)}render(){return At.html`
|
|
52
52
|
${this.importStyleIfNeeded()}
|
|
53
53
|
<slot @register-ft-reader-component=${this.registerComponent}></slot>
|
|
54
54
|
`}importStyleIfNeeded(){var e,t;let n=(e=this.stateManager.service)===null||e===void 0?void 0:e.themeStylesheet();return!n||window.location.href.startsWith((t=this.baseUrl)!==null&&t!==void 0?t:"")?At.nothing:At.html`
|
|
@@ -131,7 +131,7 @@ Also for action icons.`,c.colorGray200),contentGlobalSubtle:o.extend("--ftds-con
|
|
|
131
131
|
`;var tf={setTranslationDestinationLanguage:(r,e)=>{r.translation.destinationLanguage=e.payload},setTranslationSourceLanguage:(r,e)=>{r.translation.sourceLanguage=e.payload},setTranslationProfileId:(r,e)=>{r.translation.profileId=e.payload},setTranslationLoading:(r,e)=>{r.translation.isLoading=e.payload},setTranslationError:(r,e)=>{r.translation.isError=e.payload},setTopicsRating:(r,e)=>{for(let t in e.payload)r.topicsRating[t]=e.payload[t]}},El=r=>ze.get({name:"ft-reader-"+r,initialState:{mapId:void 0,renderedTopics:[],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,mapRating:void 0,topicsRating:{},translation:{sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1},linkPreviewDialogId:void 0},reducers:tf});var ri=class{constructor(e,t){this.mapId=e,this.paginatedToc=t,this.nodeByTocId={},this.nodeByUrl={},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,nodeByUrl:this.nodeByUrl,duplicatedPrettyUrls:this.duplicatedPrettyUrls,pages:this.pages,pageByTocId:this.pageByTocId,translationError:this.paginatedToc.translationError}}extractPagesToc(e,t,n){return e.flatMap(a=>{var i;return a.pageConfiguration&&this.registerPage(this.buildPage(a,n)),a.tocId==null?this.extractPagesToc(a.children,t,n):[{tocId:a.tocId,title:(i=a.title)!==null&&i!==void 0?i:"",untranslatedTitle:a.untranslatedTitle,depth:t,children:this.extractPagesToc(a.children,t+1,a.tocId)}]})}convertNodes(e,t,n){return e.flatMap(a=>{var i,s,l;if(a.tocId==null)return[...this.convertSectionNodes((i=a.pageToc)!==null&&i!==void 0?i:[],t,a.tocId),...this.convertNodes(a.children,t,a.tocId)];let d=(s=a.prettyUrl)===null||s===void 0?void 0:s.replace(/^\//,""),p={tocId:a.tocId,contentId:a.contentId,title:a.title,untranslatedTitle:a.untranslatedTitle,hasRating:a.hasRating,origin:a.origin,prettyUrl:d,depth:t,parentTocId:n,children:[]};this.register(p);let f=this.convertSectionNodes((l=a.pageToc)!==null&&l!==void 0?l:[],t+1,a.tocId),h=this.convertNodes(a.children,t+1,p.tocId);return p.children=[...f,...h],[p]})}convertSectionNodes(e,t,n){return e.flatMap(a=>{var i;let s=(i=a.prettyUrl)===null||i===void 0?void 0:i.replace(/^\//,""),l={...a,prettyUrl:s,depth:t,parentTocId:n,children:[]};return this.register(l),l.children=this.convertSectionNodes(a.children,t+1,a.tocId),[l]})}buildPage(e,t){var n,a,i,s,l,d,p,f;let h={number:this.pages.length+1,title:(n=e.title)!==null&&n!==void 0?n:"",untranslatedTitle:e.untranslatedTitle,rootTocId:(s=(a=e.tocId)!==null&&a!==void 0?a:(i=e.pageToc)===null||i===void 0?void 0:i[0].tocId)!==null&&s!==void 0?s:"root",toc:((l=e.pageToc)!==null&&l!==void 0?l:[]).map(g=>this.nodeByTocId[g.tocId]),topics:[],hiddenTopics:[],breadcrumb:t?this.buildBreadcrumb(this.nodeByTocId[t]):[]},m=(g,x)=>(x?h.topics:h.hiddenTopics).push(g),y=(p=(d=e.pageConfiguration)===null||d===void 0?void 0:d.parentsVisibility)!==null&&p!==void 0?p:[];return h.breadcrumb.forEach((g,x)=>{m(g,y[x])}),e.tocId&&m(e.tocId,e.pageConfiguration.isVisible),h.topics.push(...this.tocIds((f=e.pageToc)!==null&&f!==void 0?f:[])),h}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.nodeByUrl[e.prettyUrl]==null?this.nodeByUrl[e.prettyUrl]=e:this.duplicatedPrettyUrls.add(e.prettyUrl)),this.nodeByUrl[`${this.mapId}/${e.tocId}`]=e,this.nodeByTocId[e.tocId]=e}},Eo=class{convertPaginatedToc(e,t){return new ri(e,t).build()}};var rf="ft-app-info",je=class r extends CustomEvent{constructor(e){super(r.eventName,{detail:e})}};je.eventName="authentication-change";var Gr=class r extends CustomEvent{constructor(e){super(r.eventName,{detail:e})}};Gr.eventName="ui-locale-changed";var of={session:(r,e)=>{de(r.session,e.payload)||(r.session=e.payload,setTimeout(()=>T.dispatchEvent(new je(e.payload)),0))}},T=ze.get({name:rf,reducers:of,initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,apiIntegrationAppVersion:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],availableContentLocales:[],defaultLocales:void 0,searchInAllLanguagesAllowed:!1,searchLanguageSetsUiLanguage:!1,uiLanguageSetsSearchLanguage:!1,uiLanguageSetsReaderLanguage:!1,metadataConfiguration:void 0,privacyPolicyConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0,openExternalDocumentInNewTab:!1,navigatorOnline:!0,forcedOffline:!1,authenticationRequired:!1}});var Oo=function(r,e,t,n){var a=arguments.length,i=a<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var l=r.length-1;l>=0;l--)(s=r[l])&&(i=(a<3?s(i):a>3?s(e,t,i):s(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},eC=J(Symbol("withDateFormat"),function(r){class e extends r{constructor(...n){super(n),this.useLongDateFormat=!1,this.useDateTimeFormat=!1,this.metadataDescriptors=[],this.uiLocale="en-US",this.addStore(T)}dateFormatOptionsChanged(n){return n.has("metadataDescriptors")||n.has("useLongDateFormat")||n.has("useDateTimeFormat")||n.has("uiLocale")}getDateFormatter(n){var a,i;return((i=(a=this.metadataDescriptors.find(l=>l.key===n))===null||a===void 0?void 0:a.date)!==null&&i!==void 0?i:!1)?l=>xt.format(l,this.uiLocale,this.useLongDateFormat,this.useDateTimeFormat):void 0}}return Oo([O({type:Boolean})],e.prototype,"useLongDateFormat",void 0),Oo([O({type:Boolean})],e.prototype,"useDateTimeFormat",void 0),Oo([$({store:T.name,selector:t=>{var n,a;return(a=(n=t.metadataConfiguration)===null||n===void 0?void 0:n.descriptors)!==null&&a!==void 0?a:[]}})],e.prototype,"metadataDescriptors",void 0),Oo([$({store:T.name})],e.prototype,"uiLocale",void 0),e});var Ot=class r{static get(e){let{baseUrl:t,apiIntegrationIdentifier:n}=T.getState(),a=e??n;if(t&&a&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(t,a,!0)}static await(e){return new Promise(t=>{let n=r.get(e);if(n)t(n);else{let a=T.subscribe(()=>{n=r.get(e),n&&(a(),t(n))})}})}};var tr=class{constructor(e){this.overrideApi=e}get api(){var e;return(e=this.overrideApi)!==null&&e!==void 0?e:Ot.get()}get awaitApi(){return this.overrideApi?Promise.resolve(this.overrideApi):Ot.await()}};var te=class extends tr{constructor(e=!0,t){var n;super(t),this.sortObjectFields=(i,s)=>typeof s!="object"||s==null||Array.isArray(s)?s:Object.fromEntries(Object.entries(s).sort(([l],[d])=>l.localeCompare(d)));let a=this.constructor;a.commonCache=(n=a.commonCache)!==null&&n!==void 0?n:new Te,this.cache=e?a.commonCache:new Te}clearCache(){this.cache.clearAll()}hash(e){return String(Array.from(JSON.stringify(e,this.sortObjectFields)).reduce((t,n)=>0|31*t+n.charCodeAt(0),0))}};var wo=class extends te{async listMySearches(){let{session:e}=T.getState();return We(e,U.SAVED_SEARCH_USER)?this.cache.get("my-searches",async()=>(await this.awaitApi).listMySearches(e.profile.userId),300*1e3):[]}};var Ao=class extends te{async listMyBookmarks(){let e=T.getState().session;return e?.sessionAuthenticated?this.cache.get("my-bookmarks",async()=>(await this.awaitApi).listMyBookmarks(e.profile.userId),300*1e3):[]}};var Ro=class extends te{constructor(){super(...arguments),this.CACHE_DURATION=180*1e3}async getUserAssetCount(e){if(this.isAuthenticated())return this.cache.get(`user-asset-count-${e}`,async()=>(await this.awaitApi).get(`/internal/api/webapp/user/assets/count/${e}`),this.CACHE_DURATION)}async getUserBookmarkCountByMap(e){if(this.isAuthenticated())return this.cache.get(`user-bookmark-count-by-map-${e}`,async()=>(await this.awaitApi).get(`/internal/api/webapp/user/assets/count/BOOKMARKS/${e}`),this.CACHE_DURATION)}isAuthenticated(){let e=T.getState().session;return!!e?.sessionAuthenticated}};var To=class extends te{constructor(){super(...arguments),this.CACHE_DURATION=180*1e3}async getUserAssetLabels(){return this.isAuthenticated()?this.cache.get("user-asset-labels",async()=>(await this.awaitApi).get("/internal/api/webapp/user/assets/labels"),this.CACHE_DURATION):[]}isAuthenticated(){let e=T.getState().session;return!!e?.sessionAuthenticated}};var nf="ft-user-assets",af={setAssetCount:(r,e)=>{let{userAssetType:t,count:n}=e.payload.assetCount;r.assetCounts.allAsset[t]=n},clearAssetCount:r=>{Object.values(ye).forEach(e=>{r.assetCounts.allAsset[e]=void 0})},setBookmarkCountByMap:(r,e)=>{let t=e.payload.mapId;r.assetCounts.bookmarkByMap[t]=e.payload.count},clearBookmarkCountByMap:r=>{r.assetCounts.bookmarkByMap={}},addAsset:(r,e)=>{let{assetType:t,mapId:n,asset:a}=e.payload;ni(r,t,[...oi(r,t),a]),Ol(r,t,1,n),wl(r,a)},editAsset:(r,e)=>{let{assetType:t,asset:n}=e.payload;ni(r,t,oi(r,t).map(a=>a.id===n.id?n:a)),wl(r,n)},removeAsset:(r,e)=>{let{assetType:t,mapId:n,assetId:a}=e.payload;ni(r,t,oi(r,t).filter(i=>i.id!==a)),Ol(r,t,-1,n)}},Al={[ye.SEARCHES]:"savedSearches",[ye.BOOKMARKS]:"bookmarks",[ye.BOOKS]:void 0,[ye.COLLECTIONS]:void 0},oi=(r,e)=>{var t;let n=Al[e];return n?(t=r[n])!==null&&t!==void 0?t:[]:[]},ni=(r,e,t)=>{let n=Al[e];n&&(r[n]=t)},Ol=(r,e,t,n)=>{let a=r.assetCounts.allAsset[e];if(a!==void 0&&(r.assetCounts.allAsset[e]=Math.max(0,a+t),e===ye.BOOKMARKS&&n)){let i=r.assetCounts.bookmarkByMap[n];r.assetCounts.bookmarkByMap[n]=Math.max(0,i+t)}},wl=(r,e)=>{let t=r.assetLabels.map(a=>a.title),n=e.labels.filter(a=>!t.includes(a)).map(a=>({title:a}));r.assetLabels.push(...n)},ae=ze.get({name:nf,reducers:af,initialState:{savedSearches:void 0,bookmarks:void 0,assetCounts:{allAsset:Object.fromEntries(Object.values(ye).map(r=>[r,void 0])),bookmarkByMap:{}},assetLabels:[]}}),ai=class{constructor(e=new Ro,t=new To){this.assetCountsService=e,this.assetLabelsService=t,this.currentSession=T.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new Ao,this.savedSearchesService=new wo,T.subscribe(()=>this.reloadWhenUserSessionChanges())}reloadWhenUserSessionChanges(){var e;let{session:t}=T.getState();de((e=this.currentSession)===null||e===void 0?void 0:e.profile,t?.profile)||(this.currentSession=t,this.clearMySearches(),this.reloadBookmarks(),this.clearUserAssetCounts(),this.reloadAssetLabels())}clearUserAssetCounts(){this.assetCountsService.clearCache(),ae.actions.clearAssetCount(),ae.actions.clearBookmarkCountByMap()}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),ae.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),ae.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();let e=await this.savedSearchesService.listMySearches();ae.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async reloadAssetLabels(){this.assetLabelsService.clearCache();let e=await this.assetLabelsService.getUserAssetLabels();ae.actions.assetLabels(e)}async loadAssetCount(e){let t=await this.assetCountsService.getUserAssetCount(e);t&&ae.getState().assetCounts.allAsset[e]!==t.count&&ae.actions.setAssetCount({assetCount:t})}async loadBookmarkByMapId(e){let t=await this.assetCountsService.getUserBookmarkCountByMap(e);t&&ae.getState().assetCounts.bookmarkByMap[e]!==t.count&&ae.actions.setBookmarkCountByMap({count:t.count,mapId:e})}async reloadAssetCount(e){this.assetCountsService.clearCache();let t=Object.keys(ae.getState().assetCounts.bookmarkByMap).length!==0;e===ye.BOOKMARKS&&t&&ae.actions.clearBookmarkCountByMap(),ae.getState().assetCounts.allAsset[e]!==void 0&&await this.loadAssetCount(e)}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;ae.actions.bookmarks(t)}}},ii=new ai;window.FluidTopicsUserAssetsActions==null&&(window.FluidTopicsUserAssetsActions=ii);var si=class{addCommand(e,t=!1){T.commands.add(e,t)}consumeCommand(e){return T.commands.consume(e)}};window.FluidTopicsAppInfoStoreService=new si;var Rl,rr=class extends CustomEvent{constructor(e){super("ft-i18n-context-loaded",{detail:e})}},sf=Symbol("clearAfterUnitTest"),Io=class extends ao(te){constructor(e){super(),this.messageContextProvider=e,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[Rl]=()=>{this.defaultMessages={},this.cache=new Te,this.listeners={}},this.currentUiLocale=T.getState().uiLocale,T.subscribe(()=>this.clearWhenUiLocaleChanges())}clearWhenUiLocaleChanges(){let{uiLocale:e}=T.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 n;if(e=e.toLowerCase(),t&&Object.keys(t).length>0){let a={...(n=this.defaultMessages[e])!==null&&n!==void 0?n:{},...t};de(this.defaultMessages[e],a)||(this.defaultMessages[e]=a,await this.notify(e))}return this.fetchContext(e)}resolveContext(e){var t,n;return this.fetchContext(e),(n=(t=this.cache.getNow(e))===null||t===void 0?void 0:t.messages)!==null&&n!==void 0?n:{}}resolveRawMessage(e,t){let n=e.toLowerCase();return this.resolveContext(n)[t]}resolveMessage(e,t,...n){var a;let i=e.toLowerCase(),s=this.resolveContext(i);return new Dr((a=this.defaultMessages[i])!==null&&a!==void 0?a:{},s).resolve(t,...n)}async fetchContext(e){let t=!this.cache.has(e),n;try{n=await this.cache.get(e,()=>this.messageContextProvider(this.currentUiLocale,e)),t&&await this.notify(e)}catch(a){!(a instanceof Ne)&&t&&console.error(a)}return n}subscribe(e,t){var n;return e=e.toLowerCase(),this.listeners[e]=(n=this.listeners[e])!==null&&n!==void 0?n:new Set,this.listeners[e].add(t),()=>{var a;return(a=this.listeners[e])===null||a===void 0?void 0:a.delete(t)}}async notifyAll(){let e=Object.keys(this.listeners);document.body.dispatchEvent(new rr({loadedContexts:e})),this.dispatchEvent(new rr({loadedContexts:e})),await Promise.all(e.map(t=>this.notify(t,!1)))}async notify(e,t=!0){t&&(document.body.dispatchEvent(new rr({loadedContexts:[e]})),this.dispatchEvent(new rr({loadedContexts:[e]}))),this.listeners[e]!=null&&await Promise.all([...this.listeners[e].values()].map(n=>no(0).then(()=>n()).catch(()=>null)))}};Rl=sf;window.FluidTopicsI18nService==null&&(window.FluidTopicsI18nService=new class extends Io{constructor(){super(async(r,e)=>(await this.awaitApi).getFluidTopicsMessageContext(r,e))}});window.FluidTopicsCustomI18nService==null&&(window.FluidTopicsCustomI18nService=new class extends Io{constructor(){super(async(r,e)=>(await this.awaitApi).getCustomMessageContext(r,e))}});var Tl=window.FluidTopicsI18nService,UC=window.FluidTopicsCustomI18nService;var ci=class{highlightHtml(e,t,n){ea(e,t,n)}};window.FluidTopicsHighlightHtmlService=new ci;var li=class{isDate(e){var t,n,a,i;return(i=(a=((n=(t=T.getState().metadataConfiguration)===null||t===void 0?void 0:t.descriptors)!==null&&n!==void 0?n:[]).find(l=>l.key===e))===null||a===void 0?void 0:a.date)!==null&&i!==void 0?i:!1}format(e,t){var n,a,i,s;if(e==null)return"";try{return xt.format(e,(n=t?.locale)!==null&&n!==void 0?n:T.getState().uiLocale,(a=t?.longFormat)!==null&&a!==void 0?a:!1,(i=t?.withTime)!==null&&i!==void 0?i:!1,(s=t?.onlyTime)!==null&&s!==void 0?s:!1)}catch(l){throw console.error(`Date ${JSON.stringify(e)} is not valid`,l),l}}};window.FluidTopicsDateService=new li;var jr=class{static get(e,t){var n,a;let i=T.getState(),{lang:s,region:l}=(a=(n=i.defaultLocales)===null||n===void 0?void 0:n.defaultContentLocale)!==null&&a!==void 0?a:{lang:"en",region:"US"};return new Jt(i.baseUrl,e??20,i.searchInAllLanguagesAllowed,t??`${s}-${l}`)}};var Lo=class extends te{async sendDocumentStartDisplayEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.start_display event")}async sendTopicStartDisplayEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send topic.start_display event")}async sendKhubSearchEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send khub.search event")}async sendDocumentSearchEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.search event")}async sendSearchPageSelectEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send search_page.select event")}async sendSearchResultOpenContextMenuEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send search_result.open_context_menu event")}async sendDocumentOnDemandTranslateEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.on_demand_translate event")}async sendTopicAiTranslateEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send topic.ai_translate event")}convertMapToAnalyticsDocument(e){let t;switch(e.editorialType){case"BOOK":t="STRUCTURED_DOCUMENT";break;case"SHARED_BOOK":t="SHARED_PERSONAL_BOOK";break;case"ARTICLE":t="RESOURCE";break;case"HTML_PACKAGE":t="HTML_PACKAGE";break;default:throw new TypeError("Unknown editorial type for map : "+e.editorialType)}return{id:e.id,title:e.title,type:t,metadata:e.metadata}}sortEventArrays(e){let t=Object.entries(e).map(([n,a])=>Array.isArray(a)?[n,a.map(i=>typeof i=="object"&&i!=null&&!Array.isArray(i)?this.sortEventArrays(i):i).sort((i,s)=>typeof i=="object"&&i!==null&&"key"in i?i.key.localeCompare(s.key):typeof i=="string"&&typeof s=="string"?i.localeCompare(s):String(i).localeCompare(String(s)))]:typeof a=="object"&&a!==null?[n,this.sortEventArrays(a)]:[n,a]);return Object.fromEntries(t)}sendEvents(e,t){let n="anything not undefined";return this.cache.get("analytics-event-"+this.hash(e),async()=>(await this.awaitApi).sendEvents(e).then(()=>n).catch(a=>(console.info(t),console.debug(a),n)),1e3)}};var di=class{urlToSearchRequest(e){return jr.get().parse(e)}searchRequestToUrl(e){return jr.get().serialize(e)}};window.FluidTopicsUrlService=new di;var wt=class r extends CustomEvent{constructor(e){super(r.eventName,{detail:{currentItem:e}})}};wt.eventName="change";var ui=class{itemName(e){return`fluid-topics-history-item-${e}`}get(e){let t=sessionStorage.getItem(this.itemName(e));return t?JSON.parse(t):void 0}set(e,t){sessionStorage.setItem(this.itemName(e),JSON.stringify(t))}},Il=new ui;var _o=class r extends Ue{static build(){return new r(window.history,Il,()=>window.location,!1)}constructor(e,t,n,a){var i,s;super(),this.history=e,this.historyStorage=t,this.windowLocation=n,this.states=[],this.realPushState=e.pushState,this.realReplaceState=e.replaceState,this.initialIndex=(s=(i=e.state)===null||i===void 0?void 0:i.index)!==null&&s!==void 0?s:e.length-1,this.currentIndex=this.initialIndex,this.setCurrentState(this.buildCurrentState()),this.installProxies(),this.initEventListeners(),this.initData(a)}setCurrentState(e,t=!1){let n=t&&this.currentIndex===e.index-1;this.currentState={...this.buildCurrentState(),...e},this.currentIndex=this.currentState.index,this.states[this.currentIndex]=this.currentState,n&&(this.states=this.states.slice(0,this.currentIndex+1)),this.historyStorage.set(this.currentIndex,this.currentState),de(this.currentState,this.history.state)||this.realReplaceState.apply(this.history,[this.currentState,this.currentState.title,window.location.href]),setTimeout(()=>this.dispatchEvent(new wt(this.currentItem())),0)}installProxies(){let e=t=>(n,a,[i,s,l])=>{let d=t(),p={...d===this.currentIndex?this.currentState:void 0,...i,index:d,href:typeof l=="string"?l:(l??this.windowLocation()).href};n.apply(a,[p,s,l]),this.setCurrentState(p,!0)};this.history.pushState=new Proxy(this.history.pushState,{apply:e(()=>this.currentIndex+1)}),this.history.replaceState=new Proxy(this.history.replaceState,{apply:e(()=>this.currentIndex)})}initEventListeners(){window.addEventListener("popstate",e=>this.setCurrentState(e.state)),document.querySelector("title")==null&&document.head.append(document.createElement("title")),new MutationObserver(()=>this.updateCurrentState({title:document.title})).observe(document.querySelector("title"),{subtree:!0,characterData:!0,childList:!0})}initData(e){for(let t=this.history.length-1;t>=0;t--)e?this.states[t]=this.historyStorage.get(t):setTimeout(()=>this.states[t]=this.historyStorage.get(t),this.history.length-t)}updateCurrentState(e){var t;let n={...this.buildCurrentState(),...e,index:this.currentIndex,title:(t=e?.title)!==null&&t!==void 0?t:this.currentState.title};this.setCurrentState(n)}addHistoryChangeListener(e){this.addEventListener(wt.eventName,e)}removeHistoryChangeListener(e){this.removeEventListener(wt.eventName,e)}currentItem(){return xe(this.currentState)}back(){let e=this.previousDifferentMajorPosition();e>=0?this.history.go(e-this.currentIndex):this.currentIndex!==this.initialIndex?this.history.go(this.initialIndex-this.currentIndex):this.history.back()}backwardItem(){return xe(this.states[this.previousDifferentMajorPosition()])}backwardItemMatching(e){let t=this.states.filter(n=>!!n).filter(n=>n.index<this.currentIndex).reverse();return xe(t.find(n=>e(n)))}previousDifferentMajorPosition(){let e=this.currentIndex>0?this.currentIndex-1:0;for(;e>0&&!this.isDifferentMajorState(e);)e--;return e}forward(){let e=this.nextMajorPosition();e&&e<this.states.length?this.history.go(e-this.currentIndex):this.history.forward()}forwardItem(){let e=this.nextMajorPosition();if(e)return xe(this.states[e])}nextMajorPosition(){let e=this.currentIndex;if(!(e>=this.states.length)){do e++;while(e<this.states.length&&!this.isDifferentMajorState(e));return this.getHigherPositionInTheSameState(e)}}getHigherPositionInTheSameState(e){var t;let n=(t=this.states[e])===null||t===void 0?void 0:t.majorStateId;if(!n)return e;let a=e,i=e+1;for(;this.states.length>i&&!this.isDifferentMajorState(i,n);)this.hasState(i)&&(a=i),i++;return a}buildCurrentState(){var e,t;return{...this.history.state,index:this.currentIndex,href:this.windowLocation().href,title:(t=(e=this.history.state)===null||e===void 0?void 0:e.title)!==null&&t!==void 0?t:document.title}}hasState(e){return this.states[e]!=null}isDifferentMajorState(e,t){var n;if(!this.hasState(e))return!1;let a=t??this.currentState.majorStateId,i=(n=this.states[e])===null||n===void 0?void 0:n.majorStateId;return i==null||i!=a}};window.FluidTopicsInternalHistoryService==null&&(window.FluidTopicsInternalHistoryService=_o.build(),window.FluidTopicsHistoryService={currentItem:()=>window.FluidTopicsInternalHistoryService.currentItem(),back:()=>window.FluidTopicsInternalHistoryService.back(),forward:()=>window.FluidTopicsInternalHistoryService.forward(),backwardItem:()=>window.FluidTopicsInternalHistoryService.backwardItem(),forwardItem:()=>window.FluidTopicsInternalHistoryService.forwardItem(),backwardItemMatching:r=>window.FluidTopicsInternalHistoryService.backwardItemMatching(r),addHistoryChangeListener:r=>window.FluidTopicsInternalHistoryService.addHistoryChangeListener(r),removeHistoryChangeListener:r=>window.FluidTopicsInternalHistoryService.removeHistoryChangeListener(r)});var Ll=_`
|
|
132
132
|
`;function _l(r,e){let{authenticationRequired:t,session:n}=T.getState();return t&&!n?.sessionAuthenticated?Promise.resolve(e):r()}var Po=class extends tr{async updateUiLocale(e){return(await this.awaitApi).updateUiLocale(e)}};var pi=class r extends zr{static build(e){return new r(T,e)}constructor(e,t){super(),this.store=e,this.cache=new Te,this.withManualResources=!0,this.localesConfiguration=null,this.userLocaleService=new Po,this.cleanSessionDebouncer=new W,this.reloadDebouncer=new W(500),this.apiProvider=t??(()=>Ot.get())}setWithManualResources(e){this.withManualResources=e,this.updateIfNeeded()}async initService(){this.store.addEventListener(je.eventName,this.reloadConfiguration)}async updateIfNeeded(){this.apiProvider()&&(this.withManualResources||(this.store.getState().session==null&&this.updateSession(),this.store.getState().metadataConfiguration==null&&this.updateMetadataConfiguration()),this.localesConfiguration==null&&this.updateLocalesConfiguration(),(this.store.getState().availableContentLocales==null||this.store.getState().availableContentLocales.length==0)&&this.updateAvailableContentLocales())}async updateSession(){let e=await this.cache.get("session",async()=>{let t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run(()=>{this.cache.clear("session"),this.setSession(void 0)},t.idleTimeoutInMillis),t});this.setSession(e)}async updateMetadataConfiguration(){this.setMetadataConfiguration(await this.cache.get("metadataConfiguration",()=>this.apiProvider().getMetadataConfiguration()))}async updateLocalesConfiguration(){this.setLocalesConfiguration(await this.cache.get("localesConfiguration",()=>this.apiProvider().getLocalesConfiguration()))}async updateAvailableContentLocales(){var e;let t=await this.cache.get("availableContentLocales",()=>_l(()=>this.apiProvider().getAvailableSearchLocales(),{contentLocales:[]}));this.setAvailableContentLocales((e=t.contentLocales)!==null&&e!==void 0?e:[])}reloadConfiguration(){var e;(e=this.cache)===null||e===void 0||e.clear("availableContentLocales"),typeof this.updateAvailableContentLocales=="function"&&this.updateAvailableContentLocales()}setBaseUrl(e){this.store.actions.baseUrl(e),window.fluidTopicsBaseUrl=e}setApiIntegrationIdentifier(e){this.store.actions.apiIntegrationIdentifier(e)}setApiIntegrationAppVersion(e){this.store.actions.apiIntegrationAppVersion(e)}setUiLocale(e){this.store.actions.uiLocale(e)}setLocalesConfiguration(e){var t,n,a,i,s;this.localesConfiguration=e,this.store.actions.defaultLocales(this.localesConfiguration.defaultLocales),this.store.actions.availableUiLocales((t=this.localesConfiguration.availableUiLocales)!==null&&t!==void 0?t:[]),this.store.actions.searchInAllLanguagesAllowed((n=this.localesConfiguration.allLanguagesAllowed)!==null&&n!==void 0?n:!1),this.store.actions.searchLanguageSetsUiLanguage((a=this.localesConfiguration.searchLanguageSetsUiLanguage)!==null&&a!==void 0?a:!1),this.store.actions.uiLanguageSetsSearchLanguage((i=this.localesConfiguration.uiLanguageSetsSearchLanguage)!==null&&i!==void 0?i:!1),this.store.actions.uiLanguageSetsReaderLanguage((s=this.localesConfiguration.uiLanguageSetsReaderLanguage)!==null&&s!==void 0?s:!1),setTimeout(()=>this.updateIfNeeded())}setAvailableContentLocales(e){this.store.actions.availableContentLocales(e),setTimeout(()=>this.updateIfNeeded())}stopReloadDebouncer(){this.reloadDebouncer.cancel()}requestUiLocaleUpdate(e){this.userLocaleService.updateUiLocale({uiLocale:e}).then(t=>{t.uiLocaleChanged&&(this.reloadDebouncer.run(()=>window.location.reload()),this.store.dispatchEvent(new Gr(t)))}).catch(()=>{})}setMetadataConfiguration(e){this.store.actions.metadataConfiguration(e),setTimeout(()=>this.updateIfNeeded())}setNoCustom(e){this.store.actions.noCustom(e)}setEditorMode(e){this.store.actions.editorMode(e)}setNoCustomComponent(e){this.store.actions.noCustomComponent(e)}setSession(e){this.store.actions.session(e),setTimeout(()=>this.updateIfNeeded())}setOpenExternalDocumentInNewTab(e){this.store.actions.openExternalDocumentInNewTab(e)}setNavigatorOnline(e){this.store.actions.navigatorOnline(e)}setForcedOffline(e){this.store.actions.forcedOffline(e)}setAuthenticationRequired(e){this.store.actions.authenticationRequired(e)}},Pl=pi.build();var At=class extends Event{constructor(e,t,n,a){super("context-request",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t,this.callback=n,this.subscribe=a??!1}};var Vr=class{constructor(){this.pendingContextRequests=new Map,this.onContextProvider=e=>{let t=this.pendingContextRequests.get(e.context);if(t===void 0)return;this.pendingContextRequests.delete(e.context);let{requests:n}=t;for(let{elementRef:a,callbackRef:i}of n){let s=a.deref(),l=i.deref();s===void 0||l===void 0||s.dispatchEvent(new At(e.context,s,l,!0))}},this.onContextRequest=e=>{if(e.subscribe!==!0)return;let t=e.contextTarget??e.composedPath()[0],n=e.callback,a=this.pendingContextRequests.get(e.context);a===void 0&&this.pendingContextRequests.set(e.context,a={callbacks:new WeakMap,requests:[]});let i=a.callbacks.get(t);i===void 0&&a.callbacks.set(t,i=new WeakSet),i.has(n)||(i.add(n),a.requests.push({elementRef:new WeakRef(t),callbackRef:new WeakRef(n)}))}}attach(e){e.addEventListener("context-request",this.onContextRequest),e.addEventListener("context-provider",this.onContextProvider)}detach(e){e.removeEventListener("context-request",this.onContextRequest),e.removeEventListener("context-provider",this.onContextProvider)}};var re=function(r,e,t,n){var a=arguments.length,i=a<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var l=r.length-1;l>=0;l--)(s=r[l])&&(i=(a<3?s(i):a>3?s(e,t,i):s(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},j=class extends $e{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.apiIntegrationAppVersion="ft-integration-app-version",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.authenticationRequired=!1,this.messageContexts=[],this.stateManager=Pl,this.contextRoot=new Vr}render(){return B`
|
|
133
133
|
<slot></slot>
|
|
134
|
-
`}connectedCallback(){super.connectedCallback(),this.stateManager.initService(),this.contextRoot.attach(document.body)}disconnectedCallback(){super.disconnectedCallback(),this.contextRoot.detach(document.body)}update(e){var t;super.update(e),e.has("baseUrl")&&this.stateManager.setBaseUrl(this.baseUrl),e.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),e.has("apiIntegrationAppVersion")&&this.stateManager.setApiIntegrationAppVersion(this.apiIntegrationAppVersion),e.has("uiLocale")&&this.stateManager.setUiLocale(this.uiLocale),e.has("metadataConfiguration")&&this.stateManager.setMetadataConfiguration(this.metadataConfiguration),e.has("noCustom")&&this.stateManager.setNoCustom(this.noCustom),e.has("editorMode")&&this.stateManager.setEditorMode(this.editorMode),e.has("noCustomComponent")&&this.stateManager.setNoCustomComponent(this.noCustomComponent),e.has("session")&&this.stateManager.setSession(this.session),e.has("messageContexts")&&this.messageContexts!=null&&this.messageContexts.forEach(n=>Tl.addContext(n)),e.has("openExternalDocumentInNewTab")&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab),e.has("navigatorOnline")&&this.stateManager.setNavigatorOnline(this.navigatorOnline),e.has("forcedOffline")&&this.stateManager.setForcedOffline(this.forcedOffline),e.has("authenticationRequired")&&this.stateManager.setAuthenticationRequired(this.authenticationRequired),e.has("withManualResources")&&((t=this.stateManager)===null||t===void 0||t.setWithManualResources(this.withManualResources)),setTimeout(()=>this.stateManager.updateIfNeeded())}};j.elementDefinitions={};j.styles=Ll;re([O()],j.prototype,"baseUrl",void 0);re([O()],j.prototype,"apiIntegrationIdentifier",void 0);re([O()],j.prototype,"apiIntegrationAppVersion",void 0);re([O()],j.prototype,"uiLocale",void 0);re([Me(null)],j.prototype,"availableUiLocales",void 0);re([Me(null)],j.prototype,"metadataConfiguration",void 0);re([O({type:Boolean})],j.prototype,"editorMode",void 0);re([O({type:Boolean})],j.prototype,"noCustom",void 0);re([O({type:Boolean})],j.prototype,"openExternalDocumentInNewTab",void 0);re([O({converter:{fromAttribute(r){return r==="false"?!1:r==="true"||(r??!1)}}})],j.prototype,"noCustomComponent",void 0);re([O({type:Boolean})],j.prototype,"withManualResources",void 0);re([O({type:Boolean})],j.prototype,"navigatorOnline",void 0);re([O({type:Boolean})],j.prototype,"forcedOffline",void 0);re([O({type:Boolean})],j.prototype,"authenticationRequired",void 0);re([Me([])],j.prototype,"messageContexts",void 0);re([Me(void 0)],j.prototype,"session",void 0);var kl={"ft-app-context":j};oe(kl);var ko=class extends te{get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,t,n){super(!1,t),this.converter=e,this._mapId=n,this.initCache()}async withMapId(e){return this._mapId?e(this._mapId):void 0}initCache(){this.cache.register("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(e,t)))),this.cache.register("ratingSummary",()=>{var e,t;return We((t=(e=T.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&t!==void 0?t:[],"RATING_USER")?this.withMapId(a=>this.fetchMapRating(a)):Promise.resolve()})}clear(){this.cache.clearMatching(e=>e!=="configuration")}makeCacheKey(e,t){return e+(t?"-destinationLanguage-"+t?.destinationLanguage:"")}getMap(e){return this.cache.get(this.makeCacheKey("map",e),()=>this.fetchMap(this.mapId,e))}getMapNow(e){return this.cache.getNow(this.makeCacheKey("map",e))}getConfiguration(){return this.cache.get("configuration")}clearConfiguration(){this.cache.clear("configuration")}getEnrichedToc(e){return this.cache.get(this.makeCacheKey("enrichedToc",e),()=>this.fetchPages(this.mapId,e).then(t=>this.converter.convertPaginatedToc(this.mapId,t)))}getEnrichedTocNow(e){return this.cache.getNow(this.makeCacheKey("enrichedToc",e))}async getPaginationConfiguration(){return(await this.getEnrichedToc()).paginationConfiguration}async getToc(e){return(await this.getEnrichedToc(e)).toc}async getPagesToc(e){return(await this.getEnrichedToc(e)).pagesToc}async getTranslationError(e){return(await this.getEnrichedToc(e)).translationError}async getTocNode(e,t){return(await this.getEnrichedToc(t)).nodeByTocId[e]}getTocNodeNow(e,t){var n;return(n=this.getEnrichedTocNow(t))===null||n===void 0?void 0:n.nodeByTocId[e]}getTocNodeNowByUrl(e,t){var n,a;let i=this.getMapNow(t);return i?.prettyUrl==e||`${i?.id}/root`===e?(n=this.getEnrichedTocNow(t))===null||n===void 0?void 0:n.toc[0]:(a=this.getEnrichedTocNow(t))===null||a===void 0?void 0:a.nodeByUrl[e]}async getPage(e,t){let n=await this.getEnrichedToc(t);return n.pages[e-1]||n.pages[0]}async getPageByTocId(e,t){let n=await this.getEnrichedToc(t);return n.pageByTocId[e]||n.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))}getTranslatedTopicContent(e,t){return this.cache.get(this.makeCacheKey("translated-topic-content-"+e.tocId,t),()=>this.fetchTranslatedTopicHTMLContent(e,t))}async getTopicMetadataValue(e,t){let n=this.getTocNodeNow(e);if(!n)return;let a=await this.getTopicInfo(n);return a?.metadata.find(i=>i.key==t)}getAttachments(){return this.cache.get("map-attachments",()=>this.fetchAttachments())}clearMapAttachments(){this.cache.clear("map-attachments")}getRelativesForDocument(e,t){return this.cache.get("document-relatives-"+e+"-"+t.join("-"),()=>this.fetchRelativesForDocument(e,t))}getRelativesForTopicInMap(e,t,n){return this.cache.get("topic-relatives-"+[e,t,...n].join("-"),()=>this.fetchRelativesForTopicInMap(e,t,n))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true&locationValue=reader`)}getLink(e,t,n){let a=this.getNavigationData(e,t,n),i=this.getReaderLinkPrefix()+(a.prettyUrl?a.prettyUrl:`${a.mapId}/${a.tocId}`),s=new URL(i,this.api.tenantBaseUrl);return a.page!=null&&s.searchParams.set("page",`${a.page}`),a.prettyUrlDuplicated&&s.searchParams.set("tocId",a.tocId),a.section!=null&&s.searchParams.set("section",a.section),s.href}getNavigationData(e,t,n,a){var i,s;e=e||"root";let l=this.getEnrichedTocNow(a),d=l?.pageByTocId[e],p=l?.nodeByTocId[e],f=p?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(i=p?.title)!==null&&i!==void 0?i:"",untranslatedTopicTitle:p?.untranslatedTitle,page:t&&d&&d.number!==t?t:void 0,prettyUrl:f?.replace(/^r\//,""),prettyUrlDuplicated:(s=l?.duplicatedPrettyUrls.has(f??""))!==null&&s!==void 0?s:!1,section:n}}async getAccurateNavigationData(e,t,n,a){return await this.getEnrichedToc(a),this.getNavigationData(e,t,n,a)}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 n;return t?{type:t.topics.type,rating:(n=t.topics)===null||n===void 0?void 0:n.ratings.find(a=>a.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,n){return this.makeRateTopicRequest(e,t,n).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=T.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,t,n){return this.makeTopicFeedbackRequest(e,t,n)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e,t){let n=this.getTocNodeNow(e,t),a=[{tocId:n.tocId,title:n.title,untranslatedTitle:n.untranslatedTitle}],i=this.getTocNodeNow(n.parentTocId,t);for(;i;)a.unshift({tocId:i.tocId,title:i.title,untranslatedTitle:i.untranslatedTitle}),i=this.getTocNodeNow(i.parentTocId,t);return a}isFeatureAccessible(e,{session:t}){var n;if(!this.isFeatureAvailable(e))return!1;switch(e){case Ge.FEEDBACK:return We(t??[],U.FEEDBACK_USER);case Ge.RATING:return We(t??[],U.RATING_USER);case Ge.PRINT:return We(t??[],U.PRINT_USER);case Ge.BOOKMARK:return!!t?.sessionAuthenticated;case Ge.COLLECTIONS:return We(t??[],U.COLLECTION_USER);case Ge.PERSONAL_BOOKS:return We(t??[],U.PERSONAL_BOOK_USER)&&!(!((n=this.getMapNow())===null||n===void 0)&&n.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var No=class r extends ko{static async build(e){return new r(new Eo,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e,t){let n=await this.api.getMap(e,t);return this.fingerprint=n.fingerprint,n}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e,t){return await this.getMap(t),this.api.getPages(e,this.fingerprint,t)}fetchTopicHTMLContent(e){return this.api.getTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint)}fetchTranslatedTopicHTMLContent(e,t){return this.api.getTranslatedTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint,t)}fetchTopicMetadata(e){return this.api.getTopic(this.mapId,e.contentId,this.fingerprint)}fetchAttachments(){return this.api.getMapAttachments(this.mapId).catch(()=>[])}fetchRelativesForDocument(e,t){let n={query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",metadataFilters:[{key:e,valueFilter:{negative:!1,values:t}}],sort:[],facets:[]};return this.api.search(n)}fetchRelativesForTopicInMap(e,t,n){let a={query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",metadataFilters:[{key:t,valueFilter:{negative:!1,values:n}},{key:"ft:publicationId",valueFilter:{negative:!1,values:[e]}}],sort:[],facets:[]};return this.api.search(a)}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,n){return this.api.rateTopic(this.mapId,e,t,n)}makeTopicFeedbackRequest(e,t,n){return this.api.sendTopicFeedback(this.mapId,e,t,n)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var df="topicPivot";function Nl(r,e){let t=new URL(r);return e?.values.forEach(n=>{t.searchParams.append(df,n)}),t.href}var Mo=class r{static build(e,t){return new r(El(e.trim()||"context"),t??No.build)}loaded(){return wr(()=>this._loaded)}constructor(e,t,n,a){this.store=e,this.clusteringHelperProvider=n,this.metadataForSwitchToRelatives=new Set,this._loaded=!1,this.loadDebouncer=new W(10),this.analyticsEventsService=a??new Lo,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())}setRenderedTopics(e){this.store.actions.renderedTopics(e)}setVisibleTopics(e){this.store.actions.visibleTopics(e)}async awaitService(){return lt(()=>this.service)}async navigateToTopic(e,t,n){await this.loaded();let a=await this.awaitService(),i=await(n!=null?a.getPage(n,this.getTranslationSettings()):a.getPageByTocId(e??"root",this.getTranslationSettings()));this.store.actions.currentPage(i);let s=this.resolveValidNonRootTocId(e,i);this.store.actions.scrollTarget({tocId:s,section:t}),this.store.getState().visibleTopics[0]!==s&&this.store.actions.visibleTopics([])}resolveValidNonRootTocId(e,t){var n,a,i;let s=(n=e==="root"?void 0:e)!==null&&n!==void 0?n:t.rootTocId;return t.topics.includes(s)?s:(e!="root"&&this.store.dispatchEvent(new CustomEvent(ot.requestedTopicNotFound,{detail:{tocId:s}})),(i=(a=t.topics[0])!==null&&a!==void 0?a:t.hiddenTopics[0])!==null&&i!==void 0?i:"root")}async navigateToPage(e){await this.loaded();let n=await(await this.awaitService()).getPage(e,this.getTranslationSettings());this.store.actions.currentPage(n)}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(this.getTranslationSettings()))}clear(){var e;this._loaded=!1,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),this.store.actions.renderedTopics([]),this.store.actions.visibleTopics([]),this.store.actions.translation({sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1}),this.store.actions.mapRating(void 0),(e=this.service)===null||e===void 0||e.clear(),this.clusteringHelper=void 0}reload(){return this.clear(),this.load()}async fetchData(e){var t,n,a,i,s;try{e&&this.setTranslationLoading(!0);let l=d=>{throw e&&this.setTranslationError(!0),d};await Promise.all([this.loadConfiguration(),(t=this.service)===null||t===void 0?void 0:t.getMap(e).then(d=>this.store.actions.map(d)).catch(l),(n=this.service)===null||n===void 0?void 0:n.getToc(e).then(d=>this.store.actions.toc(d)).catch(l),(a=this.service)===null||a===void 0?void 0:a.getPagesToc(e).then(d=>this.store.actions.pagesToc(d)).catch(l),(i=this.service)===null||i===void 0?void 0:i.getPaginationConfiguration().then(d=>this.store.actions.paginationConfiguration(d)).catch(l),(s=this.service)===null||s===void 0?void 0:s.getTranslationError(e).then(d=>this.setTranslationError(d))]),this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives(),this._loaded=!0,e&&this.setTranslationLoading(!1)}catch(l){this.errorHandler&&!(l instanceof Ne)&&this.errorHandler(l)}}loadConfiguration(){var e;return(e=this.service)===null||e===void 0?void 0:e.getConfiguration().then(t=>this.store.actions.configuration(t))}reloadConfiguration(){var e;return(e=this.service)===null||e===void 0||e.clearConfiguration(),this.loadConfiguration()}async fetchRelatives(){var e,t;let n=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(a=>{var i;return a.key==((i=this.store.getState().configuration)===null||i===void 0?void 0:i.relativePivotMetadata)}).flatMap(a=>a.values);if(n!==void 0&&n.length>0){let a=await((t=this.service)===null||t===void 0?void 0:t.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata,n)),i=a?.results.flatMap(s=>s.entries);this.store.actions.relatives(i)}this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.dispatchEvent(new Event(ot.clusteringHelperCreated))}createClusteringHelper(){var e,t;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let n=this.store.getState().relatives;if(n){let a=n.find(s=>{var l;return((l=s.map)===null||l===void 0?void 0:l.mapId)==this.store.getState().mapId}),i=(t=(e=T.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&t!==void 0?t:[];return new kt(n,a,this.metadataForSwitchToRelatives,i)}}async navigateToRelativeTopicIfFound(e){var t,n,a;await this.loaded();let i=await lt(()=>{var p;return(p=this.store.getState().configuration)===null||p===void 0?void 0:p.relativeTopicPivotMetadata}),s=this.store.getState().mapId,d=await(await this.awaitService()).getRelativesForTopicInMap(s,i,[e]);if(!((a=(n=(t=d?.results)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.entries)===null||a===void 0)&&a[0]){let p=d.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)}async setTranslationDestinationLanguage(e){this.store.actions.setTranslationDestinationLanguage(e),e&&this.sendDocumentOnDemandTranslateEvent(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationSourceLanguage(e){this.store.actions.setTranslationSourceLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationProfileId(e){this.store.actions.setTranslationProfileId(e)}async setTranslationLoading(e){this.store.actions.setTranslationLoading(e)}async setTranslationError(e){this.store.actions.setTranslationError(e)}getTranslationSettings(){var e;let t=this.store.getState();return t.translation.profileId&&t.translation.destinationLanguage?{profileId:t.translation.profileId,destinationLanguage:t.translation.destinationLanguage.code,sourceLanguage:(e=t.map)===null||e===void 0?void 0:e.lang}:void 0}setLinkPreviewDialogId(e){this.store.actions.linkPreviewDialogId(e)}async fetchMapRating(){var e;this.store.actions.mapRating(await((e=this.service)===null||e===void 0?void 0:e.getMapRating()))}async fetchTopicRating(e){var t;let n=await((t=this.service)===null||t===void 0?void 0:t.getTopicRating(e));n&&this.store.actions.setTopicsRating({[e]:n})}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}getAccurateNavigationData(e,t,n){return this.service.getAccurateNavigationData(e,t?.number,n?.section,this.getTranslationSettings())}buildBreadcrumb(e){var t;return(t=this.service)===null||t===void 0?void 0:t.buildBreadcrumb(e,this.getTranslationSettings())}fetchTopicContent(e){var t,n;let a=this.getTranslationSettings();return a?(this.sendTopicAiTranslateEvent(a.destinationLanguage,e),(t=this.service)===null||t===void 0?void 0:t.getTranslatedTopicContent(e,a).then(i=>(i.isTranslationError&&this.setTranslationError(!0),i.content))):(n=this.service)===null||n===void 0?void 0:n.getTopicContent(e)}getTocNode(e){return this.service.getTocNode(e,this.getTranslationSettings())}getPage(e){return this.service.getPage(e,this.getTranslationSettings())}onMapAttachmentsUpdate(){var e;(e=this.service)===null||e===void 0||e.clearMapAttachments(),this.store.dispatchEvent(new Event(ot.mapAttachmentsUpdate))}async getRelativeDocumentUrlForLocale(e){var t,n,a;this.store.getState().relatives==null&&await this.fetchRelatives();let i=kt.findResultWithMetadataValue((t=this.store.getState().relatives)!==null&&t!==void 0?t:[],"ft:locale",e),s=En(i);if(s){let l=this.store.getState().visibleTopics[0],d=(n=this.store.getState().configuration)===null||n===void 0?void 0:n.relativeTopicPivotMetadata;if(d&&l){let p=await((a=this.service)===null||a===void 0?void 0:a.getTopicMetadataValue(l,d));s=Nl(s,p)}}return s}sendDocumentOnDemandTranslateEvent(e){var t;let{editorMode:n,apiIntegrationIdentifier:a,apiIntegrationAppVersion:i}=T.getState(),s=this.store.getState(),l=s.map,d=s.translation.profileId;if(!(n||!l||!a||!i||!d))try{let f={...this.analyticsEventsService.convertMapToAnalyticsDocument(l),title:(t=l.untranslatedTitle)!==null&&t!==void 0?t:l.title};this.analyticsEventsService.sendDocumentOnDemandTranslateEvent({name:"DOCUMENT__ON_DEMAND_TRANSLATE",offline:!1,appName:a,appVersion:i,sourceLanguage:this.parseLanguageToAnalyticsFormat(l.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e.code),profileId:d,document:f,translationOrigin:So.AI})}catch(p){console.warn("Failed to send on-demand document translate event:",p)}}sendTopicAiTranslateEvent(e,t){var n;let{editorMode:a,apiIntegrationIdentifier:i,apiIntegrationAppVersion:s}=T.getState(),l=this.store.getState(),d=l.map,p=l.translation.profileId;if(!(a||!d||!i||!s||!p))try{let f=this.buildBreadcrumb(t.tocId);if(!f){console.warn("Failed to build breadcrumb for topic ai translate event");return}let m={...this.analyticsEventsService.convertMapToAnalyticsDocument(d),title:(n=d.untranslatedTitle)!==null&&n!==void 0?n:d.title};this.analyticsEventsService.sendTopicAiTranslateEvent({name:"TOPIC__AI_TRANSLATE",offline:!1,appName:i,appVersion:s,sourceLanguage:this.parseLanguageToAnalyticsFormat(d.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e),breadcrumb:f.map(y=>{var g;return{tocId:y.tocId,title:(g=y.untranslatedTitle)!==null&&g!==void 0?g:y.title}}),document:m,profileId:p})}catch(f){console.warn("Failed to send topic ai translate event:",f)}}parseLanguageToAnalyticsFormat(e){if(!e)return;let t=e.split("-");return t.length===2?{languageCode:t[0],countryCode:t[1]}:{languageCode:t[0],countryCode:""}}};var Do=class extends CustomEvent{constructor(e,t){super("ft-reader-map-loaded",{detail:{map:e,toc:t}})}},Fo=class extends CustomEvent{constructor(e,t){super("ft-reader-visible-topics-change",{detail:{visibleTopics:t}})}},Uo=class extends CustomEvent{constructor(e){super("ft-reader-navigation-done",{detail:e})}},Bo=class extends CustomEvent{constructor(e){super("ft-reader-load-error",{detail:e})}},$o=class extends Event{constructor(){super("ft-reader-map-not-found")}},Ho=class extends Event{constructor(){super("ft-reader-map-unauthorized")}},zo=class extends Event{constructor(){super("ft-reader-map-forbidden")}},Wo=class extends Event{constructor(){super("ft-reader-topic-relative-not-found",{bubbles:!0,composed:!0})}};var ce=function(r,e,t,n){var a=arguments.length,i=a<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var l=r.length-1;l>=0;l--)(s=r[l])&&(i=(a<3?s(i):a>3?s(e,t,i):s(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},fi=class{constructor(e){this.stateManager=e}searchInDocument(e){this.stateManager.setSearchInDocumentQuery(e??"")}},Y=class extends $e{constructor(){super(),this.visibleTopics=[],this.updateConfiguration=()=>{this.stateManager.reloadConfiguration()},this.scrollToTargetDebouncer=new W(5),this.navigationDebouncer=new W(10),this.mapLoadedEventDebouncer=new W(50),this.addStore(T)}render(){return B`
|
|
134
|
+
`}connectedCallback(){super.connectedCallback(),this.stateManager.initService(),this.contextRoot.attach(document.body)}disconnectedCallback(){super.disconnectedCallback(),this.contextRoot.detach(document.body)}update(e){var t;super.update(e),e.has("baseUrl")&&this.stateManager.setBaseUrl(this.baseUrl),e.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),e.has("apiIntegrationAppVersion")&&this.stateManager.setApiIntegrationAppVersion(this.apiIntegrationAppVersion),e.has("uiLocale")&&this.stateManager.setUiLocale(this.uiLocale),e.has("metadataConfiguration")&&this.stateManager.setMetadataConfiguration(this.metadataConfiguration),e.has("noCustom")&&this.stateManager.setNoCustom(this.noCustom),e.has("editorMode")&&this.stateManager.setEditorMode(this.editorMode),e.has("noCustomComponent")&&this.stateManager.setNoCustomComponent(this.noCustomComponent),e.has("session")&&this.stateManager.setSession(this.session),e.has("messageContexts")&&this.messageContexts!=null&&this.messageContexts.forEach(n=>Tl.addContext(n)),e.has("openExternalDocumentInNewTab")&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab),e.has("navigatorOnline")&&this.stateManager.setNavigatorOnline(this.navigatorOnline),e.has("forcedOffline")&&this.stateManager.setForcedOffline(this.forcedOffline),e.has("authenticationRequired")&&this.stateManager.setAuthenticationRequired(this.authenticationRequired),e.has("withManualResources")&&((t=this.stateManager)===null||t===void 0||t.setWithManualResources(this.withManualResources)),setTimeout(()=>this.stateManager.updateIfNeeded())}};j.elementDefinitions={};j.styles=Ll;re([O()],j.prototype,"baseUrl",void 0);re([O()],j.prototype,"apiIntegrationIdentifier",void 0);re([O()],j.prototype,"apiIntegrationAppVersion",void 0);re([O()],j.prototype,"uiLocale",void 0);re([Me(null)],j.prototype,"availableUiLocales",void 0);re([Me(null)],j.prototype,"metadataConfiguration",void 0);re([O({type:Boolean})],j.prototype,"editorMode",void 0);re([O({type:Boolean})],j.prototype,"noCustom",void 0);re([O({type:Boolean})],j.prototype,"openExternalDocumentInNewTab",void 0);re([O({converter:{fromAttribute(r){return r==="false"?!1:r==="true"||(r??!1)}}})],j.prototype,"noCustomComponent",void 0);re([O({type:Boolean})],j.prototype,"withManualResources",void 0);re([O({type:Boolean})],j.prototype,"navigatorOnline",void 0);re([O({type:Boolean})],j.prototype,"forcedOffline",void 0);re([O({type:Boolean})],j.prototype,"authenticationRequired",void 0);re([Me([])],j.prototype,"messageContexts",void 0);re([Me(void 0)],j.prototype,"session",void 0);var kl={"ft-app-context":j};oe(kl);var ko=class extends te{get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,t,n){super(!1,t),this.converter=e,this._mapId=n,this.initCache()}async withMapId(e){return this._mapId?e(this._mapId):void 0}initCache(){this.cache.register("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(e,t)))),this.cache.register("ratingSummary",()=>{var e,t;return We((t=(e=T.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&t!==void 0?t:[],"RATING_USER")?this.withMapId(a=>this.fetchMapRating(a)):Promise.resolve()})}clear(){this.cache.clearMatching(e=>e!=="configuration")}makeCacheKey(e,t){return e+(t?"-destinationLanguage-"+t?.destinationLanguage:"")}getMap(e){return this.cache.get(this.makeCacheKey("map",e),()=>this.fetchMap(this.mapId,e))}getMapNow(e){return this.cache.getNow(this.makeCacheKey("map",e))}getConfiguration(){return this.cache.get("configuration")}clearConfiguration(){this.cache.clear("configuration")}getEnrichedToc(e){return this.cache.get(this.makeCacheKey("enrichedToc",e),()=>this.fetchPages(this.mapId,e).then(t=>this.converter.convertPaginatedToc(this.mapId,t)))}getEnrichedTocNow(e){return this.cache.getNow(this.makeCacheKey("enrichedToc",e))}async getPaginationConfiguration(){return(await this.getEnrichedToc()).paginationConfiguration}async getToc(e){return(await this.getEnrichedToc(e)).toc}async getPagesToc(e){return(await this.getEnrichedToc(e)).pagesToc}async getTranslationError(e){return(await this.getEnrichedToc(e)).translationError}async getTocNode(e,t){return(await this.getEnrichedToc(t)).nodeByTocId[e]}getTocNodeNow(e,t){var n;return(n=this.getEnrichedTocNow(t))===null||n===void 0?void 0:n.nodeByTocId[e]}getTocNodeNowByUrl(e,t){var n,a;let i=this.getMapNow(t);return i?.prettyUrl==e||`${i?.id}/root`===e?(n=this.getEnrichedTocNow(t))===null||n===void 0?void 0:n.toc[0]:(a=this.getEnrichedTocNow(t))===null||a===void 0?void 0:a.nodeByUrl[e]}async getPage(e,t){let n=await this.getEnrichedToc(t);return n.pages[e-1]||n.pages[0]}async getPageByTocId(e,t){let n=await this.getEnrichedToc(t);return n.pageByTocId[e]||n.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))}getTranslatedTopicContent(e,t){return this.cache.get(this.makeCacheKey("translated-topic-content-"+e.tocId,t),()=>this.fetchTranslatedTopicHTMLContent(e,t))}async getTopicMetadataValue(e,t){let n=this.getTocNodeNow(e);if(!n)return;let a=await this.getTopicInfo(n);return a?.metadata.find(i=>i.key==t)}getAttachments(){return this.cache.get("map-attachments",()=>this.fetchAttachments())}clearMapAttachments(){this.cache.clear("map-attachments")}getRelativesForDocument(e,t){return this.cache.get("document-relatives-"+e+"-"+t.join("-"),()=>this.fetchRelativesForDocument(e,t))}getRelativesForTopicInMap(e,t,n){return this.cache.get("topic-relatives-"+[e,t,...n].join("-"),()=>this.fetchRelativesForTopicInMap(e,t,n))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true&locationValue=reader`)}getLink(e,t,n){let a=this.getNavigationData(e,t,n),i=this.getReaderLinkPrefix()+(a.prettyUrl?a.prettyUrl:`${a.mapId}/${a.tocId}`),s=new URL(i,this.api.tenantBaseUrl);return a.page!=null&&s.searchParams.set("page",`${a.page}`),a.prettyUrlDuplicated&&s.searchParams.set("tocId",a.tocId),a.section!=null&&s.searchParams.set("section",a.section),s.href}getNavigationData(e,t,n,a){var i,s;e=e||"root";let l=this.getEnrichedTocNow(a),d=l?.pageByTocId[e],p=l?.nodeByTocId[e],f=p?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(i=p?.title)!==null&&i!==void 0?i:"",untranslatedTopicTitle:p?.untranslatedTitle,page:t&&d&&d.number!==t?t:void 0,prettyUrl:f?.replace(/^r\//,""),prettyUrlDuplicated:(s=l?.duplicatedPrettyUrls.has(f??""))!==null&&s!==void 0?s:!1,section:n}}async getAccurateNavigationData(e,t,n,a){return await this.getEnrichedToc(a),this.getNavigationData(e,t,n,a)}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 n;return t?{type:t.topics.type,rating:(n=t.topics)===null||n===void 0?void 0:n.ratings.find(a=>a.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,n){return this.makeRateTopicRequest(e,t,n).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=T.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,t,n){return this.makeTopicFeedbackRequest(e,t,n)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e,t){let n=this.getTocNodeNow(e,t),a=[{tocId:n.tocId,title:n.title,untranslatedTitle:n.untranslatedTitle}],i=this.getTocNodeNow(n.parentTocId,t);for(;i;)a.unshift({tocId:i.tocId,title:i.title,untranslatedTitle:i.untranslatedTitle}),i=this.getTocNodeNow(i.parentTocId,t);return a}isFeatureAccessible(e,{session:t}){var n;if(!this.isFeatureAvailable(e))return!1;switch(e){case Ge.FEEDBACK:return We(t??[],U.FEEDBACK_USER);case Ge.RATING:return We(t??[],U.RATING_USER);case Ge.PRINT:return We(t??[],U.PRINT_USER);case Ge.BOOKMARK:return!!t?.sessionAuthenticated;case Ge.COLLECTIONS:return We(t??[],U.COLLECTION_USER);case Ge.PERSONAL_BOOKS:return We(t??[],U.PERSONAL_BOOK_USER)&&!(!((n=this.getMapNow())===null||n===void 0)&&n.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var No=class r extends ko{static async build(e){return new r(new Eo,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e,t){let n=await this.api.getMap(e,t);return this.fingerprint=n.fingerprint,n}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e,t){return await this.getMap(t),this.api.getPages(e,this.fingerprint,t)}fetchTopicHTMLContent(e){return this.api.getTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint)}fetchTranslatedTopicHTMLContent(e,t){return this.api.getTranslatedTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint,t)}fetchTopicMetadata(e){return this.api.getTopic(this.mapId,e.contentId,this.fingerprint)}fetchAttachments(){return this.api.getMapAttachments(this.mapId).catch(()=>[])}fetchRelativesForDocument(e,t){let n={query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",metadataFilters:[{key:e,valueFilter:{negative:!1,values:t}}],sort:[],facets:[]};return this.api.search(n)}fetchRelativesForTopicInMap(e,t,n){let a={query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",metadataFilters:[{key:t,valueFilter:{negative:!1,values:n}},{key:"ft:publicationId",valueFilter:{negative:!1,values:[e]}}],sort:[],facets:[]};return this.api.search(a)}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,n){return this.api.rateTopic(this.mapId,e,t,n)}makeTopicFeedbackRequest(e,t,n){return this.api.sendTopicFeedback(this.mapId,e,t,n)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var df="topicPivot";function Nl(r,e){let t=new URL(r);return e?.values.forEach(n=>{t.searchParams.append(df,n)}),t.href}var Mo=class r{static build(e,t){return new r(El(e.trim()||"context"),t??No.build)}loaded(){return wr(()=>this._loaded)}constructor(e,t,n,a){this.store=e,this.clusteringHelperProvider=n,this.metadataForSwitchToRelatives=new Set,this._loaded=!1,this.loadDebouncer=new W(10),this.analyticsEventsService=a??new Lo,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())}setRenderedTopics(e){this.store.actions.renderedTopics(e)}setVisibleTopics(e){this.store.actions.visibleTopics(e)}async awaitService(){return lt(()=>this.service)}async navigateToTopic(e,t,n){await this.loaded();let a=await this.awaitService(),i=await(n!=null?a.getPage(n,this.getTranslationSettings()):a.getPageByTocId(e??"root",this.getTranslationSettings()));this.store.actions.currentPage(i);let s=this.resolveValidNonRootTocId(e,i);this.store.actions.scrollTarget({tocId:s,section:t}),this.store.getState().visibleTopics[0]!==s&&this.store.actions.visibleTopics([])}resolveValidNonRootTocId(e,t){var n,a,i;let s=(n=e==="root"?void 0:e)!==null&&n!==void 0?n:t.rootTocId;return t.topics.includes(s)?s:(e!="root"&&!t.hiddenTopics.includes(s)&&this.store.dispatchEvent(new CustomEvent(ot.requestedTopicNotFound,{detail:{tocId:s}})),(i=(a=t.topics[0])!==null&&a!==void 0?a:t.hiddenTopics[0])!==null&&i!==void 0?i:"root")}async navigateToPage(e){await this.loaded();let n=await(await this.awaitService()).getPage(e,this.getTranslationSettings());this.store.actions.currentPage(n)}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(this.getTranslationSettings()))}clear(){var e;this._loaded=!1,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),this.store.actions.renderedTopics([]),this.store.actions.visibleTopics([]),this.store.actions.translation({sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1}),this.store.actions.mapRating(void 0),(e=this.service)===null||e===void 0||e.clear(),this.clusteringHelper=void 0}reload(){return this.clear(),this.load()}async fetchData(e){var t,n,a,i,s;try{e&&this.setTranslationLoading(!0);let l=d=>{throw e&&this.setTranslationError(!0),d};await Promise.all([this.loadConfiguration(),(t=this.service)===null||t===void 0?void 0:t.getMap(e).then(d=>this.store.actions.map(d)).catch(l),(n=this.service)===null||n===void 0?void 0:n.getToc(e).then(d=>this.store.actions.toc(d)).catch(l),(a=this.service)===null||a===void 0?void 0:a.getPagesToc(e).then(d=>this.store.actions.pagesToc(d)).catch(l),(i=this.service)===null||i===void 0?void 0:i.getPaginationConfiguration().then(d=>this.store.actions.paginationConfiguration(d)).catch(l),(s=this.service)===null||s===void 0?void 0:s.getTranslationError(e).then(d=>this.setTranslationError(d))]),this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives(),this._loaded=!0,e&&this.setTranslationLoading(!1)}catch(l){this.errorHandler&&!(l instanceof Ne)&&this.errorHandler(l)}}loadConfiguration(){var e;return(e=this.service)===null||e===void 0?void 0:e.getConfiguration().then(t=>this.store.actions.configuration(t))}reloadConfiguration(){var e;return(e=this.service)===null||e===void 0||e.clearConfiguration(),this.loadConfiguration()}async fetchRelatives(){var e,t;let n=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(a=>{var i;return a.key==((i=this.store.getState().configuration)===null||i===void 0?void 0:i.relativePivotMetadata)}).flatMap(a=>a.values);if(n!==void 0&&n.length>0){let a=await((t=this.service)===null||t===void 0?void 0:t.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata,n)),i=a?.results.flatMap(s=>s.entries);this.store.actions.relatives(i)}this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.dispatchEvent(new Event(ot.clusteringHelperCreated))}createClusteringHelper(){var e,t;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let n=this.store.getState().relatives;if(n){let a=n.find(s=>{var l;return((l=s.map)===null||l===void 0?void 0:l.mapId)==this.store.getState().mapId}),i=(t=(e=T.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&t!==void 0?t:[];return new kt(n,a,this.metadataForSwitchToRelatives,i)}}async navigateToRelativeTopicIfFound(e){var t,n,a;await this.loaded();let i=await lt(()=>{var p;return(p=this.store.getState().configuration)===null||p===void 0?void 0:p.relativeTopicPivotMetadata}),s=this.store.getState().mapId,d=await(await this.awaitService()).getRelativesForTopicInMap(s,i,[e]);if(!((a=(n=(t=d?.results)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.entries)===null||a===void 0)&&a[0]){let p=d.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)}async setTranslationDestinationLanguage(e){this.store.actions.setTranslationDestinationLanguage(e),e&&this.sendDocumentOnDemandTranslateEvent(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationSourceLanguage(e){this.store.actions.setTranslationSourceLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationProfileId(e){this.store.actions.setTranslationProfileId(e)}async setTranslationLoading(e){this.store.actions.setTranslationLoading(e)}async setTranslationError(e){this.store.actions.setTranslationError(e)}getTranslationSettings(){var e;let t=this.store.getState();return t.translation.profileId&&t.translation.destinationLanguage?{profileId:t.translation.profileId,destinationLanguage:t.translation.destinationLanguage.code,sourceLanguage:(e=t.map)===null||e===void 0?void 0:e.lang}:void 0}setLinkPreviewDialogId(e){this.store.actions.linkPreviewDialogId(e)}async fetchMapRating(){var e;this.store.actions.mapRating(await((e=this.service)===null||e===void 0?void 0:e.getMapRating()))}async fetchTopicRating(e){var t;let n=await((t=this.service)===null||t===void 0?void 0:t.getTopicRating(e));n&&this.store.actions.setTopicsRating({[e]:n})}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}getAccurateNavigationData(e,t,n){return this.service.getAccurateNavigationData(e,t?.number,n?.section,this.getTranslationSettings())}buildBreadcrumb(e){var t;return(t=this.service)===null||t===void 0?void 0:t.buildBreadcrumb(e,this.getTranslationSettings())}fetchTopicContent(e){var t,n;let a=this.getTranslationSettings();return a?(this.sendTopicAiTranslateEvent(a.destinationLanguage,e),(t=this.service)===null||t===void 0?void 0:t.getTranslatedTopicContent(e,a).then(i=>(i.isTranslationError&&this.setTranslationError(!0),i.content))):(n=this.service)===null||n===void 0?void 0:n.getTopicContent(e)}getTocNode(e){return this.service.getTocNode(e,this.getTranslationSettings())}getPage(e){return this.service.getPage(e,this.getTranslationSettings())}onMapAttachmentsUpdate(){var e;(e=this.service)===null||e===void 0||e.clearMapAttachments(),this.store.dispatchEvent(new Event(ot.mapAttachmentsUpdate))}async getRelativeDocumentUrlForLocale(e){var t,n,a;this.store.getState().relatives==null&&await this.fetchRelatives();let i=kt.findResultWithMetadataValue((t=this.store.getState().relatives)!==null&&t!==void 0?t:[],"ft:locale",e),s=En(i);if(s){let l=this.store.getState().visibleTopics[0],d=(n=this.store.getState().configuration)===null||n===void 0?void 0:n.relativeTopicPivotMetadata;if(d&&l){let p=await((a=this.service)===null||a===void 0?void 0:a.getTopicMetadataValue(l,d));s=Nl(s,p)}}return s}sendDocumentOnDemandTranslateEvent(e){var t;let{editorMode:n,apiIntegrationIdentifier:a,apiIntegrationAppVersion:i}=T.getState(),s=this.store.getState(),l=s.map,d=s.translation.profileId;if(!(n||!l||!a||!i||!d))try{let f={...this.analyticsEventsService.convertMapToAnalyticsDocument(l),title:(t=l.untranslatedTitle)!==null&&t!==void 0?t:l.title};this.analyticsEventsService.sendDocumentOnDemandTranslateEvent({name:"DOCUMENT__ON_DEMAND_TRANSLATE",offline:!1,appName:a,appVersion:i,sourceLanguage:this.parseLanguageToAnalyticsFormat(l.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e.code),profileId:d,document:f,translationOrigin:So.AI})}catch(p){console.warn("Failed to send on-demand document translate event:",p)}}sendTopicAiTranslateEvent(e,t){var n;let{editorMode:a,apiIntegrationIdentifier:i,apiIntegrationAppVersion:s}=T.getState(),l=this.store.getState(),d=l.map,p=l.translation.profileId;if(!(a||!d||!i||!s||!p))try{let f=this.buildBreadcrumb(t.tocId);if(!f){console.warn("Failed to build breadcrumb for topic ai translate event");return}let m={...this.analyticsEventsService.convertMapToAnalyticsDocument(d),title:(n=d.untranslatedTitle)!==null&&n!==void 0?n:d.title};this.analyticsEventsService.sendTopicAiTranslateEvent({name:"TOPIC__AI_TRANSLATE",offline:!1,appName:i,appVersion:s,sourceLanguage:this.parseLanguageToAnalyticsFormat(d.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e),breadcrumb:f.map(y=>{var g;return{tocId:y.tocId,title:(g=y.untranslatedTitle)!==null&&g!==void 0?g:y.title}}),document:m,profileId:p})}catch(f){console.warn("Failed to send topic ai translate event:",f)}}parseLanguageToAnalyticsFormat(e){if(!e)return;let t=e.split("-");return t.length===2?{languageCode:t[0],countryCode:t[1]}:{languageCode:t[0],countryCode:""}}};var Do=class extends CustomEvent{constructor(e,t){super("ft-reader-map-loaded",{detail:{map:e,toc:t}})}},Fo=class extends CustomEvent{constructor(e,t){super("ft-reader-visible-topics-change",{detail:{visibleTopics:t}})}},Uo=class extends CustomEvent{constructor(e){super("ft-reader-navigation-done",{detail:e})}},Bo=class extends CustomEvent{constructor(e){super("ft-reader-load-error",{detail:e})}},$o=class extends Event{constructor(){super("ft-reader-map-not-found")}},Ho=class extends Event{constructor(){super("ft-reader-map-unauthorized")}},zo=class extends Event{constructor(){super("ft-reader-map-forbidden")}},Wo=class extends Event{constructor(){super("ft-reader-topic-relative-not-found",{bubbles:!0,composed:!0})}};var ce=function(r,e,t,n){var a=arguments.length,i=a<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var l=r.length-1;l>=0;l--)(s=r[l])&&(i=(a<3?s(i):a>3?s(e,t,i):s(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},fi=class{constructor(e){this.stateManager=e}searchInDocument(e){this.stateManager.setSearchInDocumentQuery(e??"")}},Y=class extends $e{constructor(){super(),this.visibleTopics=[],this.updateConfiguration=()=>{this.stateManager.reloadConfiguration()},this.scrollToTargetDebouncer=new W(5),this.navigationDebouncer=new W(10),this.mapLoadedEventDebouncer=new W(50),this.addStore(T)}render(){return B`
|
|
135
135
|
${this.importStyleIfNeeded()}
|
|
136
136
|
<slot @register-ft-reader-component=${this.registerComponent}></slot>
|
|
137
137
|
`}importStyleIfNeeded(){var e,t;let n=(e=this.stateManager.service)===null||e===void 0?void 0:e.themeStylesheet();return!n||window.location.href.startsWith((t=this.baseUrl)!==null&&t!==void 0?t:"")?F:B`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-reader-content",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Main content for integrated reader",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-content-watermark": "2.1.
|
|
23
|
-
"@fluid-topics/ft-infinite-scroll": "2.1.
|
|
24
|
-
"@fluid-topics/ft-reader-topic-content": "2.1.
|
|
25
|
-
"@fluid-topics/ft-reader-topic-context": "2.1.
|
|
26
|
-
"@fluid-topics/ft-reader-topic-title": "2.1.
|
|
27
|
-
"@fluid-topics/ft-wc-utils": "2.1.
|
|
22
|
+
"@fluid-topics/ft-content-watermark": "2.1.3",
|
|
23
|
+
"@fluid-topics/ft-infinite-scroll": "2.1.3",
|
|
24
|
+
"@fluid-topics/ft-reader-topic-content": "2.1.3",
|
|
25
|
+
"@fluid-topics/ft-reader-topic-context": "2.1.3",
|
|
26
|
+
"@fluid-topics/ft-reader-topic-title": "2.1.3",
|
|
27
|
+
"@fluid-topics/ft-wc-utils": "2.1.3",
|
|
28
28
|
"lit": "3.1.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "1432414b3c12e054e03bab4d15c0959e25699faf"
|
|
31
31
|
}
|