@fluid-topics/public-api 1.0.48 → 1.0.49

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.
Files changed (36) hide show
  1. package/build/rollup/fluidtopics.min.js +1 -1
  2. package/package.json +1 -1
  3. package/.yarnrc +0 -1
  4. package/build/cjs/index.js +0 -373
  5. package/build/cjs/preferences/unauthenticated-preferences.js +0 -67
  6. package/build/cjs/roles/roles.js +0 -31
  7. package/build/cjs/types/ft-common/public.js +0 -742
  8. package/build/cjs/types/ft-server/public.js +0 -69
  9. package/build/mjs/index.d.ts +0 -168
  10. package/build/mjs/index.js +0 -358
  11. package/build/mjs/preferences/unauthenticated-preferences.d.ts +0 -9
  12. package/build/mjs/preferences/unauthenticated-preferences.js +0 -61
  13. package/build/mjs/roles/roles.d.ts +0 -2
  14. package/build/mjs/roles/roles.js +0 -25
  15. package/build/mjs/types/ft-common/public.d.ts +0 -579
  16. package/build/mjs/types/ft-common/public.js +0 -666
  17. package/build/mjs/types/ft-server/public.d.ts +0 -50
  18. package/build/mjs/types/ft-server/public.js +0 -59
  19. package/dist/cjs/index.js +0 -373
  20. package/dist/cjs/package.json +0 -3
  21. package/dist/cjs/preferences/unauthenticated-preferences.js +0 -67
  22. package/dist/cjs/roles/roles.js +0 -31
  23. package/dist/cjs/types/ft-common/public.js +0 -742
  24. package/dist/cjs/types/ft-server/public.js +0 -69
  25. package/dist/fluidtopics.min.js +0 -1
  26. package/dist/mjs/index.d.ts +0 -168
  27. package/dist/mjs/index.js +0 -358
  28. package/dist/mjs/package.json +0 -3
  29. package/dist/mjs/preferences/unauthenticated-preferences.d.ts +0 -9
  30. package/dist/mjs/preferences/unauthenticated-preferences.js +0 -61
  31. package/dist/mjs/roles/roles.d.ts +0 -2
  32. package/dist/mjs/roles/roles.js +0 -25
  33. package/dist/mjs/types/ft-common/public.d.ts +0 -579
  34. package/dist/mjs/types/ft-common/public.js +0 -666
  35. package/dist/mjs/types/ft-server/public.d.ts +0 -50
  36. package/dist/mjs/types/ft-server/public.js +0 -59
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(e){return e&&i.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function o(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function u(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function d(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function h(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||n(e))?this._bodyArrayBuffer=p(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=u(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,i=u(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=s(e),t=a(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=a(t)},l.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),o(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),o(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),o(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function f(e,t){var r,i,n=(t=t||{}).body;if(e instanceof f){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(r=t.method||this.method||"GET",i=r.toUpperCase(),y.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function m(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(n))}})),t}function A(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}f.prototype.clone=function(){return new f(this,{body:this._bodyInit})},h.call(f.prototype),h.call(A.prototype),A.prototype.clone=function(){return new A(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},A.error=function(){var e=new A(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];A.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new A(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function g(e,i){return new Promise((function(n,s){var a=new f(e,i);if(a.signal&&a.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function u(){o.abort()}o.onload=function(){var e,t,r={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),i=r.shift().trim();if(i){var n=r.join(":").trim();t.append(i,n)}})),t)};r.url="responseURL"in o?o.responseURL:r.headers.get("X-Request-URL");var i="response"in o?o.response:o.responseText;n(new A(i,r))},o.onerror=function(){s(new TypeError("Network request failed"))},o.ontimeout=function(){s(new TypeError("Network request failed"))},o.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},o.open(a.method,a.url,!0),"include"===a.credentials?o.withCredentials=!0:"omit"===a.credentials&&(o.withCredentials=!1),"responseType"in o&&r.blob&&(o.responseType="blob"),a.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),a.signal&&(a.signal.addEventListener("abort",u),o.onreadystatechange=function(){4===o.readyState&&a.signal.removeEventListener("abort",u)}),o.send(void 0===a._bodyInit?null:a._bodyInit)}))}g.polyfill=!0,e.fetch||(e.fetch=g,e.Headers=l,e.Request=f,e.Response=A),t.Headers=l,t.Request=f,t.Response=A,t.fetch=g,Object.defineProperty(t,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:t);const r=e=>"object"==typeof e&&null!=e,i=e=>"boolean"==typeof e,n=e=>"number"==typeof e,s=e=>"string"==typeof e;var a;e.FtMyLibraryColors=void 0,(a=e.FtMyLibraryColors||(e.FtMyLibraryColors={})).black="black",a.green="green",a.blue="blue",a.purple="purple",a.red="red",a.orange="orange",a.yellow="yellow";const o=e=>["black","green","blue","purple","red","orange","yellow"].includes(e);var l;e.FtTopicOriginType=void 0,(l=e.FtTopicOriginType||(e.FtTopicOriginType={})).OFFICIAL="OFFICIAL",l.PERSONAL="PERSONAL",l.SHARED="SHARED";const u=e=>["OFFICIAL","PERSONAL","SHARED"].includes(e),c=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>Array.isArray(e)&&e.every((e=>s(e)))))&&s(e.key),d=e=>r(e)&&s(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>d(e)))&&(null==e.topicLink||p(e.topicLink))&&s(e.title)&&(null==e.htmlContent||s(e.htmlContent)),p=e=>r(e)&&s(e.tocId)&&s(e.contentId)&&s(e.mapId),h=e=>r(e)&&s(e.topicStylesheetUrl)&&s(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>s(e))),y=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&(null==e.hasRating||i(e.hasRating))&&s(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>y(e)))&&(null==e.origin||f(e.origin))&&s(e.contentId)&&s(e.title),f=e=>r(e)&&s(e.mapTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&s(e.contentId)&&s(e.mapId)&&u(e.type);var m;e.FtTopicContentTarget=void 0,(m=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",m.OFF_THE_GRID="OFF_THE_GRID",m.CONTENT_PACKAGER="CONTENT_PACKAGER",m.PAGES="PAGES",m.DESIGNED_READER="DESIGNED_READER";const A=e=>r(e)&&n(e.count)&&s(e.label)&&(null==e.lang||s(e.lang)),E=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>s(e))))))&&s(e.label)&&s(e.key),g=e=>r(e)&&(null==e.periodFilter||_(e.periodFilter))&&s(e.query)&&(null==e.scope||re(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>q(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>ae(e)))&&(null==e.virtualField||M(e.virtualField))&&(null==e.contentLocale||s(e.contentLocale));var b;e.FtRatingType=void 0,(b=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",b.LIKE="LIKE",b.DICHOTOMOUS="DICHOTOMOUS",b.NO_RATING="NO_RATING";const T=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),S=e=>r(e)&&s(e.date)&&T(e.type)&&n(e.value),R=e=>r(e)&&(null==e.rating||S(e.rating))&&T(e.type),F=e=>r(e)&&s(e.date)&&s(e.tocId)&&T(e.type)&&n(e.value),U=e=>r(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>F(e)))&&T(e.type),O=e=>r(e)&&Array.isArray(e.filter)&&e.filter.every((e=>s(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>s(e))),I=e=>r(e)&&s(e.from)&&s(e.to),_=e=>r(e)&&(null==e.period||I(e.period))&&C(e.periodType);var v;e.FtPeriodFilterType=void 0,(v=e.FtPeriodFilterType||(e.FtPeriodFilterType={})).LAST_WEEK="LAST_WEEK",v.LAST_MONTH="LAST_MONTH",v.LAST_YEAR="LAST_YEAR",v.CUSTOM="CUSTOM";const C=e=>["LAST_WEEK","LAST_MONTH","LAST_YEAR","CUSTOM"].includes(e),P=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&s(e.key);var D;e.FtSearchSortCriterionOrder=void 0,(D=e.FtSearchSortCriterionOrder||(e.FtSearchSortCriterionOrder={})).ASC="ASC",D.DESC="DESC";const L=e=>["ASC","DESC"].includes(e);var N;e.FtSearchSortCriterionType=void 0,(N=e.FtSearchSortCriterionType||(e.FtSearchSortCriterionType={})).ALPHA="ALPHA",N.NATURAL="NATURAL";const k=e=>["ALPHA","NATURAL"].includes(e);var w;e.FtVirtualField=void 0,(w=e.FtVirtualField||(e.FtVirtualField={})).EVERYWHERE="EVERYWHERE",w.TITLE_ONLY="TITLE_ONLY",w.NONE="NONE";const M=e=>["EVERYWHERE","TITLE_ONLY","NONE"].includes(e),B=e=>r(e)&&n(e.totalResultsCount)&&i(e.isLastPage)&&n(e.currentPage)&&n(e.totalClustersCount);var x;e.FtEditorialType=void 0,(x=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",x.BOOK="BOOK",x.SHARED_BOOK="SHARED_BOOK";const H=e=>["ARTICLE","BOOK","SHARED_BOOK"].includes(e);var K;e.FtOpenMode=void 0,(K=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",K.EXTERNAL="EXTERNAL";const $=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),V=e=>r(e)&&(null==e.perPage||n(e.perPage))&&n(e.page);var j;e.FtCollectionDocumentType=void 0,(j=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",j.DOCUMENT="DOCUMENT",j.TOPIC="TOPIC",j.PERSONAL_BOOK="PERSONAL_BOOK",j.SHARED_BOOK="SHARED_BOOK";const G=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),q=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&s(e.label)&&s(e.key),X=e=>r(e)&&n(e.weight)&&s(e.value)&&s(e.key),Y=e=>r(e)&&Array.isArray(e.entries)&&e.entries.every((e=>z(e)))&&(null==e.metadataVariableAxis||s(e.metadataVariableAxis)),z=e=>r(e)&&(null==e.document||W(e.document))&&(null==e.topic||Q(e.topic))&&ee(e.type)&&(null==e.map||J(e.map)),W=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&$(e.openMode)&&s(e.documentUrl)&&s(e.mimeType)&&s(e.title)&&(null==e.lastPublicationDate||s(e.lastPublicationDate))&&s(e.viewerUrl)&&s(e.contentUrl)&&s(e.filename)&&s(e.htmlTitle)&&(null==e.originUrl||s(e.originUrl))&&s(e.documentId)&&s(e.lastEditionDate)&&s(e.htmlExcerpt),J=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&(null==e.openMode||$(e.openMode))&&H(e.editorialType)&&s(e.title)&&(null==e.lastPublicationDate||s(e.lastPublicationDate))&&s(e.htmlTitle)&&(null==e.originUrl||s(e.originUrl))&&s(e.mapUrl)&&s(e.readerUrl)&&s(e.mapId)&&(null==e.lastEditionDate||s(e.lastEditionDate))&&s(e.htmlExcerpt),Q=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&$(e.openMode)&&s(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>le(e)))&&s(e.title)&&s(e.mapTitle)&&s(e.topicUrl)&&s(e.contentUrl)&&s(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&(null==e.originUrl||s(e.originUrl))&&s(e.readerUrl)&&s(e.mapId)&&(null==e.lastEditionDate||s(e.lastEditionDate))&&s(e.htmlExcerpt);var Z;e.FtSearchResultType=void 0,(Z=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",Z.DOCUMENT="DOCUMENT",Z.TOPIC="TOPIC";const ee=e=>["MAP","DOCUMENT","TOPIC"].includes(e);var te;e.FtSearchScope=void 0,(te=e.FtSearchScope||(e.FtSearchScope={})).DEFAULT="DEFAULT",te.DOCUMENTS="DOCUMENTS";const re=e=>["DEFAULT","DOCUMENTS"].includes(e),ie=e=>r(e)&&i(e.hierarchical)&&s(e.label)&&i(e.multiSelectionable)&&s(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>se(e))),ne=e=>r(e)&&(null==e.maxDepth||n(e.maxDepth))&&s(e.id),se=e=>r(e)&&n(e.totalResultsCount)&&i(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>se(e)))&&s(e.label)&&s(e.value)&&i(e.selected),ae=e=>r(e)&&k(e.type)&&s(e.key)&&L(e.order),oe=e=>r(e)&&s(e.suggestedQuery)&&s(e.htmlSuggestedQuery),le=e=>r(e)&&s(e.filename)&&s(e.resourceUrl)&&s(e.id)&&s(e.mimeType)&&s(e.resourceContentUrl)&&s(e.viewerUrl),ue=e=>r(e)&&(null==e.filenameExtension||s(e.filenameExtension))&&(null==e.editorialType||H(e.editorialType))&&(null==e.mimeType||s(e.mimeType))&&ee(e.type)&&s(e.value);var ce;e.FtUserRole=void 0,(ce=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",ce.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",ce.HTML_EXPORT_USER="HTML_EXPORT_USER",ce.PDF_EXPORT_USER="PDF_EXPORT_USER",ce.SAVED_SEARCH_USER="SAVED_SEARCH_USER",ce.COLLECTION_USER="COLLECTION_USER",ce.OFFLINE_USER="OFFLINE_USER",ce.ANALYTICS_USER="ANALYTICS_USER",ce.BETA_USER="BETA_USER",ce.DEBUG_USER="DEBUG_USER",ce.PRINT_USER="PRINT_USER",ce.RATING_USER="RATING_USER",ce.FEEDBACK_USER="FEEDBACK_USER",ce.CONTENT_PUBLISHER="CONTENT_PUBLISHER",ce.KHUB_ADMIN="KHUB_ADMIN",ce.USERS_ADMIN="USERS_ADMIN",ce.PORTAL_ADMIN="PORTAL_ADMIN",ce.ADMIN="ADMIN",ce.DEVELOPER="DEVELOPER";const de=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),pe=e=>r(e)&&s(e.identifier)&&s(e.realm),he=e=>r(e)&&(null==e.emailAddress||s(e.emailAddress))&&(null==e.displayName||s(e.displayName))&&Array.isArray(e.roles)&&e.roles.every((e=>de(e)))&&(null==e.userId||s(e.userId)),ye=e=>"object"==typeof e&&null!=e,fe=e=>"boolean"==typeof e,me=e=>"number"==typeof e,Ae=e=>"string"==typeof e,Ee=e=>ye(e)&&fe(e.mailsSentByFluidTopics)&&fe(e.mailsSentByFluidTopicsForUnauthenticatedUsers)&&Array.isArray(e.recipients)&&e.recipients.every((e=>Ae(e)))&&Array.isArray(e.bodyMetadataIds)&&e.bodyMetadataIds.every((e=>Ae(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>Ae(e))),ge=e=>ye(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>fe(e))))&&fe(e.isVisible),be=e=>ye(e)&&(null==e.prettyUrl||Ae(e.prettyUrl))&&(null==e.hasRating||fe(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||Ae(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>be(e)))&&(null==e.pageConfiguration||ge(e.pageConfiguration))&&(null==e.contentId||Ae(e.contentId))&&(null==e.title||Ae(e.title)),Te=e=>ye(e)&&fe(e.splitCurrentPageToc),Se={[e.FtUserRole.PERSONAL_BOOK_SHARE_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.HTML_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.PDF_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.KHUB_ADMIN]:[e.FtUserRole.CONTENT_PUBLISHER],[e.FtUserRole.ADMIN]:[e.FtUserRole.KHUB_ADMIN,e.FtUserRole.USERS_ADMIN,e.FtUserRole.PORTAL_ADMIN],[e.FtUserRole.DEVELOPER]:[e.FtUserRole.BETA_USER,e.FtUserRole.DEBUG_USER]};function Re(e,t){return e===t||(Se[e]??[]).some((e=>Re(e,t)))}const Fe="undefined"==typeof window?globalThis:window;function Ue(e){let t={};for(let r in e){let i=e[r];("object"!=typeof i||Array.isArray(i))&&(i={prior:i});for(let e of["prior","filter"])i[e]=Array.isArray(i[e])?i[e]:[i[e]],i[e]=i[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=i}return t}function Oe(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const Ie="undefined"==typeof window?globalThis:window;class _e extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function ve(e){if(!e.ok)throw new _e(e.status,e.statusText,await e.text());return e}function Ce(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class Pe{tenantBaseUrl;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})},searches:{list:`api/users/${e}/searches`},bookmarks:{list:`api/users/${e}/bookmarks`}})},stylesheets:{fonts:"api/stylesheets/fonts.css",theme:"api/stylesheets/theme.css",content:{title:"api/stylesheets/content/title.css",topic:"api/stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader"},locales:{ui:"api/locales/ui"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})},custom:{contextName:t=>({endpoint:`api/messages/${e}/custom/${t}`})}})}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=(e??Ie.__gwt_ft_moduleBase??Ie.fluidtopicsclient?.__moduleBase??Ie.__gwt_activeModules?.fluidtopicsclient?.moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",r&&void 0!==Ie.location&&Ie.location.href.startsWith(this.tenantBaseUrl)?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e,t){return this.get(this.endpoints.khub.maps.mapId(e).info,t)}getTableOfContent(e,t){return this.get(this.endpoints.khub.maps.mapId(e).toc,t)}getPages(e,t){return this.get(this.endpoints.khub.maps.mapId(e).pages,t)}getTopic(e,t,r){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info,r)}getTopicHTMLContent(e,t,r,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(r?"?target="+r:""),i)}getMapAttachments(e,t){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list,t)}getMapAttachmentContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content,r)}getMapResources(e,t){return this.get(this.endpoints.khub.maps.mapId(e).resources.list,t)}getMapResourceContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content,r)}getUnstructuredDocument(e,t){return this.get(this.endpoints.khub.documents.documentId(e).info,t)}getUnstructuredDocumentContent(e,t){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content,t)}getUnstructuredDocumentTextContent(e,t){return this.get(this.endpoints.khub.documents.documentId(e).text,t)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getAvailableUiLocales(){return this.get(this.endpoints.khub.locales)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:r})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t,from:r})}rateTopic(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:r,value:i})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:r,from:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:r})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).feedback,{message:t,from:r})}getFluidTopicsMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).fluidTopics.contextName(t).endpoint)}getCustomMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).custom.contextName(t).endpoint)}listMySearches(e){return this.get(this.endpoints.users.userId(e).searches.list)}listMyBookmarks(e){return this.get(this.endpoints.users.userId(e).bookmarks.list)}get(e,t){return this.makeRequest("GET",this.withVersion(e,t))}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}makeAbsolute(e){return e.startsWith(this.tenantBaseUrl)?e:this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const r=t;return await fetch(this.makeAbsolute(e),{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}upload(e,t,r,i=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((n,s)=>{let a=new XMLHttpRequest;a.onload=()=>{if(a.status>=200&&a.status<300){let e="application/json"===a.getResponseHeader("Content-Type")?JSON.parse(a.responseText):a.responseText;n(e)}else s(new _e(a.status,a.statusText,a.responseText))},a.upload.onprogress=e=>i(e),a.open(e,this.makeAbsolute(t),!0),a.send(r)})):this.fetch(t,{method:e,body:r}).then(ve).then(Ce)}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0,credentials:null==this.authorization?"include":void 0}).then(ve).then(Ce)}fetchRawData(e,t){return fetch(this.withVersion(e,t),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then(ve).then((e=>e.arrayBuffer()))}withVersion(e,t){let r=new URL(this.makeAbsolute(e));return t&&r.searchParams.append("v",t),r.toString()}}e.FluidTopicsApi=Pe,e.HttpError=_e,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(Fe.localStorage){const r=Oe(e),i=e=>{e.storageArea===Fe.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return Fe.addEventListener("storage",i),{removeHandler:()=>Fe.removeEventListener("storage",i)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=Pe,e.getUnauthenticatedUserSearchPreferences=function(e){if(Fe.localStorage)return JSON.parse(Fe.localStorage.getItem(Oe(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>r(e)&&pe(e.authenticationIdentifier)&&he(e.profile),e.isFtAuthenticationIdentifier=pe,e.isFtBookmark=e=>r(e)&&s(e.mapTitle)&&o(e.color)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&s(e.lastUpdate)&&s(e.readerUrl)&&s(e.mapId)&&s(e.id)&&s(e.title)&&s(e.creationDate),e.isFtCollectionDocument=e=>r(e)&&i(e.deleted)&&(null==e.apiUrl||s(e.apiUrl))&&(null==e.portalUrl||s(e.portalUrl))&&s(e.id)&&s(e.title)&&G(e.type),e.isFtCollectionDocumentType=G,e.isFtCredentials=e=>r(e)&&s(e.password)&&(null==e.newPassword||s(e.newPassword))&&i(e.rememberMe)&&s(e.login),e.isFtEditorialType=H,e.isFtFeedbackCreation=e=>r(e)&&(null==e.from||s(e.from))&&s(e.message),e.isFtLabeledSearchFilter=q,e.isFtMap=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&$(e.openMode)&&(null==e.topicsApiEndpoint||s(e.topicsApiEndpoint))&&(null==e.description||s(e.description))&&(null==e.attachmentsApiEndpoint||s(e.attachmentsApiEndpoint))&&H(e.editorialType)&&s(e.baseId)&&s(e.clusterId)&&s(e.title)&&s(e.lastPublication)&&s(e.lastEdition)&&s(e.originId)&&(null==e.rightsApiEndpoint||s(e.rightsApiEndpoint))&&h(e.contentStyles)&&(null==e.originUrl||s(e.originUrl))&&s(e.readerUrl)&&(null==e.khubVersion||s(e.khubVersion))&&s(e.id)&&(null==e.lang||s(e.lang)),e.isFtMapAttachment=e=>ye(e)&&Ae(e.file)&&(null==e.size||me(e.size))&&fe(e.externalLink)&&Ae(e.name)&&Ae(e.id)&&(null==e.mimeType||Ae(e.mimeType))&&(null==e.viewerUrl||Ae(e.viewerUrl)),e.isFtMapResource=e=>r(e)&&s(e.contentUrl)&&s(e.filename)&&s(e.id)&&s(e.mimeType),e.isFtMapStyles=h,e.isFtMessageContext=e=>r(e)&&s(e.name)&&r(e.messages)&&Object.keys(e.messages).every((e=>s(e)))&&Object.values(e.messages).every((e=>s(e)))&&s(e.locale),e.isFtMetadata=E,e.isFtMetadataPreferenceConfiguration=O,e.isFtMyLibraryColors=o,e.isFtMySearch=e=>r(e)&&g(e.searchRequest)&&o(e.color)&&i(e.alert)&&s(e.description)&&s(e.id)&&s(e.ownerId)&&s(e.title)&&s(e.creationDate),e.isFtMySearchRequest=g,e.isFtOpenMode=$,e.isFtPageConfiguration=ge,e.isFtPageRequest=V,e.isFtPaginatedToc=e=>ye(e)&&Te(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>be(e))),e.isFtPaginatedTocNode=be,e.isFtPaginationConfiguration=Te,e.isFtPeriod=I,e.isFtPeriodFilter=_,e.isFtPeriodFilterType=C,e.isFtPersonalBookCreation=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>c(e)))&&Array.isArray(e.nodes)&&e.nodes.every((e=>d(e)))&&s(e.description)&&s(e.title),e.isFtPersonalBookMetadataUpdate=c,e.isFtPersonalBookNodeCreation=d,e.isFtPersonalBookTopicLinkCreation=p,e.isFtPublicationRating=S,e.isFtPublicationRatingSummary=R,e.isFtRatingCreation=e=>r(e)&&T(e.type)&&n(e.value),e.isFtRatingSummary=e=>r(e)&&(null==e.topics||U(e.topics))&&R(e.publication),e.isFtRatingType=T,e.isFtReaderConfiguration=e=>ye(e)&&Ee(e.feedback)&&me(e.loadAfterLastVisibleTopic)&&me(e.loadBeforeFirstVisibleTopic),e.isFtReaderFeedbackConfiguration=Ee,e.isFtSearchFacet=ie,e.isFtSearchFacetConf=ne,e.isFtSearchFacetEntry=se,e.isFtSearchFilter=P,e.isFtSearchLocale=A,e.isFtSearchLocales=e=>r(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>A(e))),e.isFtSearchPreferencesConfiguration=e=>r(e)&&r(e.metadata)&&Object.keys(e.metadata).every((e=>s(e)))&&Object.values(e.metadata).every((e=>O(e))),e.isFtSearchPreset=e=>r(e)&&s(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>P(e)))&&n(e.priority)&&(null==e.contentLocale||s(e.contentLocale)),e.isFtSearchPrior=X,e.isFtSearchRequest=e=>r(e)&&(null==e.periodFilter||_(e.periodFilter))&&s(e.query)&&(null==e.scope||re(e.scope))&&V(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>P(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>ae(e)))&&(null==e.uiLocale||s(e.uiLocale))&&(null==e.virtualField||M(e.virtualField))&&(null==e.contentLocale||s(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>X(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>ne(e))),e.isFtSearchResultCluster=Y,e.isFtSearchResultClusterEntry=z,e.isFtSearchResultMap=J,e.isFtSearchResultTopic=Q,e.isFtSearchResultType=ee,e.isFtSearchResultUnstructuredDocument=W,e.isFtSearchResults=e=>r(e)&&(null==e.spellcheck||oe(e.spellcheck))&&B(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>Y(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>ie(e))),e.isFtSearchResultsPageInfo=B,e.isFtSearchScope=re,e.isFtSearchSortCriterion=ae,e.isFtSearchSortCriterionOrder=L,e.isFtSearchSortCriterionType=k,e.isFtSession=e=>r(e)&&(null==e.authenticationIdentifier||pe(e.authenticationIdentifier))&&n(e.idleTimeoutInMillis)&&he(e.profile)&&i(e.sessionAuthenticated),e.isFtSpellcheck=oe,e.isFtSuggestRequest=e=>r(e)&&s(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>P(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>ae(e)))&&(null==e.maxCount||n(e.maxCount))&&(null==e.contentLocale||s(e.contentLocale)),e.isFtSuggestResult=ue,e.isFtSuggestResults=e=>r(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>ue(e))),e.isFtTocNode=y,e.isFtTopic=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&s(e.id)&&s(e.contentApiEndpoint)&&s(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicOrigin=f,e.isFtTopicOriginType=u,e.isFtTopicRating=F,e.isFtTopicResource=le,e.isFtTopicsRatingSummary=U,e.isFtUiLocale=e=>r(e)&&s(e.displayName)&&s(e.languageTag)&&i(e.translated),e.isFtUnstructuredDocument=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&s(e.openMode)&&(null==e.description||s(e.description))&&s(e.mimeType)&&(null==e.baseId||s(e.baseId))&&(null==e.clusterId||s(e.clusterId))&&s(e.contentApiEndpoint)&&s(e.title)&&(null==e.lastPublication||s(e.lastPublication))&&s(e.viewerUrl)&&s(e.lastEdition)&&s(e.filename)&&(null==e.originId||s(e.originId))&&s(e.rightsApiEndpoint)&&(null==e.originUrl||s(e.originUrl))&&(null==e.khubVersion||s(e.khubVersion))&&s(e.id)&&(null==e.lang||s(e.lang)),e.isFtUserProfile=he,e.isFtUserRole=de,e.isFtVirtualField=M,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(Fe.localStorage){let r={...t,metadata:Ue(t.metadata??{})};const i=Oe(e),n=JSON.stringify(r);return Fe.localStorage.setItem(i,n),Fe.dispatchEvent(new StorageEvent("storage",{key:i,newValue:n,storageArea:Fe.localStorage,url:Fe.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")},e.userHasRole=function(e,t){return null!=e&&(Array.isArray(e)?e:Array.isArray(e.roles)?e.roles:Array.isArray(e.profile?.roles)?e.profile.roles:[]).some((e=>Re(e,t)))}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],s=ArrayBuffer.isView||function(e){return e&&i.indexOf(Object.prototype.toString.call(e))>-1};function n(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function o(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function u(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function d(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function h(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||s(e))?this._bodyArrayBuffer=p(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=u(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,i=u(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=n(e),t=a(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},l.prototype.delete=function(e){delete this.map[n(e)]},l.prototype.get=function(e){return e=n(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(n(e))},l.prototype.set=function(e,t){this.map[n(e)]=a(t)},l.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),o(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),o(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),o(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function f(e,t){var r,i,s=(t=t||{}).body;if(e instanceof f){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,s||null==e._bodyInit||(s=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(r=t.method||this.method||"GET",i=r.toUpperCase(),y.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function m(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(s))}})),t}function A(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}f.prototype.clone=function(){return new f(this,{body:this._bodyInit})},h.call(f.prototype),h.call(A.prototype),A.prototype.clone=function(){return new A(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},A.error=function(){var e=new A(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];A.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new A(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function g(e,i){return new Promise((function(s,n){var a=new f(e,i);if(a.signal&&a.signal.aborted)return n(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function u(){o.abort()}o.onload=function(){var e,t,r={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),i=r.shift().trim();if(i){var s=r.join(":").trim();t.append(i,s)}})),t)};r.url="responseURL"in o?o.responseURL:r.headers.get("X-Request-URL");var i="response"in o?o.response:o.responseText;s(new A(i,r))},o.onerror=function(){n(new TypeError("Network request failed"))},o.ontimeout=function(){n(new TypeError("Network request failed"))},o.onabort=function(){n(new t.DOMException("Aborted","AbortError"))},o.open(a.method,a.url,!0),"include"===a.credentials?o.withCredentials=!0:"omit"===a.credentials&&(o.withCredentials=!1),"responseType"in o&&r.blob&&(o.responseType="blob"),a.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),a.signal&&(a.signal.addEventListener("abort",u),o.onreadystatechange=function(){4===o.readyState&&a.signal.removeEventListener("abort",u)}),o.send(void 0===a._bodyInit?null:a._bodyInit)}))}g.polyfill=!0,e.fetch||(e.fetch=g,e.Headers=l,e.Request=f,e.Response=A),t.Headers=l,t.Request=f,t.Response=A,t.fetch=g,Object.defineProperty(t,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:t);const r=e=>"object"==typeof e&&null!=e,i=e=>"boolean"==typeof e,s=e=>"number"==typeof e,n=e=>"string"==typeof e;var a;e.FtMyLibraryColors=void 0,(a=e.FtMyLibraryColors||(e.FtMyLibraryColors={})).black="black",a.green="green",a.blue="blue",a.purple="purple",a.red="red",a.orange="orange",a.yellow="yellow";const o=e=>["black","green","blue","purple","red","orange","yellow"].includes(e);var l;e.FtTopicOriginType=void 0,(l=e.FtTopicOriginType||(e.FtTopicOriginType={})).OFFICIAL="OFFICIAL",l.PERSONAL="PERSONAL",l.SHARED="SHARED";const u=e=>["OFFICIAL","PERSONAL","SHARED"].includes(e),c=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>Array.isArray(e)&&e.every((e=>n(e)))))&&n(e.key),d=e=>r(e)&&n(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>d(e)))&&(null==e.topicLink||p(e.topicLink))&&n(e.title)&&(null==e.htmlContent||n(e.htmlContent)),p=e=>r(e)&&n(e.tocId)&&n(e.contentId)&&n(e.mapId),h=e=>r(e)&&n(e.topicStylesheetUrl)&&n(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>n(e))),y=e=>r(e)&&(null==e.prettyUrl||n(e.prettyUrl))&&(null==e.hasRating||i(e.hasRating))&&n(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>y(e)))&&(null==e.origin||f(e.origin))&&n(e.contentId)&&n(e.title),f=e=>r(e)&&n(e.mapTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>n(e)))&&n(e.tocId)&&n(e.contentId)&&n(e.mapId)&&u(e.type);var m;e.FtTopicContentTarget=void 0,(m=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",m.OFF_THE_GRID="OFF_THE_GRID",m.CONTENT_PACKAGER="CONTENT_PACKAGER",m.PAGES="PAGES",m.DESIGNED_READER="DESIGNED_READER";const A=e=>r(e)&&s(e.count)&&n(e.label)&&(null==e.lang||n(e.lang)),E=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>n(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>n(e))))))&&n(e.label)&&n(e.key),g=e=>r(e)&&(null==e.periodFilter||_(e.periodFilter))&&n(e.query)&&(null==e.scope||re(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>q(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>ae(e)))&&(null==e.virtualField||M(e.virtualField))&&(null==e.contentLocale||n(e.contentLocale));var b;e.FtRatingType=void 0,(b=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",b.LIKE="LIKE",b.DICHOTOMOUS="DICHOTOMOUS",b.NO_RATING="NO_RATING";const T=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),S=e=>r(e)&&n(e.date)&&T(e.type)&&s(e.value),R=e=>r(e)&&(null==e.rating||S(e.rating))&&T(e.type),F=e=>r(e)&&n(e.date)&&n(e.tocId)&&T(e.type)&&s(e.value),U=e=>r(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>F(e)))&&T(e.type),O=e=>r(e)&&Array.isArray(e.filter)&&e.filter.every((e=>n(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>n(e))),I=e=>r(e)&&n(e.from)&&n(e.to),_=e=>r(e)&&(null==e.period||I(e.period))&&C(e.periodType);var v;e.FtPeriodFilterType=void 0,(v=e.FtPeriodFilterType||(e.FtPeriodFilterType={})).LAST_WEEK="LAST_WEEK",v.LAST_MONTH="LAST_MONTH",v.LAST_YEAR="LAST_YEAR",v.CUSTOM="CUSTOM";const C=e=>["LAST_WEEK","LAST_MONTH","LAST_YEAR","CUSTOM"].includes(e),P=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>n(e)))&&n(e.key);var D;e.FtSearchSortCriterionOrder=void 0,(D=e.FtSearchSortCriterionOrder||(e.FtSearchSortCriterionOrder={})).ASC="ASC",D.DESC="DESC";const L=e=>["ASC","DESC"].includes(e);var N;e.FtSearchSortCriterionType=void 0,(N=e.FtSearchSortCriterionType||(e.FtSearchSortCriterionType={})).ALPHA="ALPHA",N.NATURAL="NATURAL";const k=e=>["ALPHA","NATURAL"].includes(e);var w;e.FtVirtualField=void 0,(w=e.FtVirtualField||(e.FtVirtualField={})).EVERYWHERE="EVERYWHERE",w.TITLE_ONLY="TITLE_ONLY",w.NONE="NONE";const M=e=>["EVERYWHERE","TITLE_ONLY","NONE"].includes(e),B=e=>r(e)&&s(e.totalResultsCount)&&i(e.isLastPage)&&s(e.currentPage)&&s(e.totalClustersCount);var x;e.FtEditorialType=void 0,(x=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",x.BOOK="BOOK",x.SHARED_BOOK="SHARED_BOOK";const H=e=>["ARTICLE","BOOK","SHARED_BOOK"].includes(e);var K;e.FtOpenMode=void 0,(K=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",K.EXTERNAL="EXTERNAL";const $=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),V=e=>r(e)&&(null==e.perPage||s(e.perPage))&&s(e.page);var j;e.FtCollectionDocumentType=void 0,(j=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",j.DOCUMENT="DOCUMENT",j.TOPIC="TOPIC",j.PERSONAL_BOOK="PERSONAL_BOOK",j.SHARED_BOOK="SHARED_BOOK";const G=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),q=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>n(e)))&&n(e.label)&&n(e.key),X=e=>r(e)&&s(e.weight)&&n(e.value)&&n(e.key),Y=e=>r(e)&&Array.isArray(e.entries)&&e.entries.every((e=>z(e)))&&(null==e.metadataVariableAxis||n(e.metadataVariableAxis)),z=e=>r(e)&&(null==e.document||W(e.document))&&(null==e.topic||Q(e.topic))&&ee(e.type)&&(null==e.map||J(e.map)),W=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&$(e.openMode)&&n(e.documentUrl)&&n(e.mimeType)&&n(e.title)&&(null==e.lastPublicationDate||n(e.lastPublicationDate))&&n(e.viewerUrl)&&n(e.contentUrl)&&n(e.filename)&&n(e.htmlTitle)&&(null==e.originUrl||n(e.originUrl))&&n(e.documentId)&&n(e.lastEditionDate)&&n(e.htmlExcerpt),J=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&(null==e.openMode||$(e.openMode))&&H(e.editorialType)&&n(e.title)&&(null==e.lastPublicationDate||n(e.lastPublicationDate))&&n(e.htmlTitle)&&(null==e.originUrl||n(e.originUrl))&&n(e.mapUrl)&&n(e.readerUrl)&&n(e.mapId)&&(null==e.lastEditionDate||n(e.lastEditionDate))&&n(e.htmlExcerpt),Q=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&$(e.openMode)&&n(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>le(e)))&&n(e.title)&&n(e.mapTitle)&&n(e.topicUrl)&&n(e.contentUrl)&&n(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>n(e)))&&n(e.tocId)&&(null==e.originUrl||n(e.originUrl))&&n(e.readerUrl)&&n(e.mapId)&&(null==e.lastEditionDate||n(e.lastEditionDate))&&n(e.htmlExcerpt);var Z;e.FtSearchResultType=void 0,(Z=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",Z.DOCUMENT="DOCUMENT",Z.TOPIC="TOPIC";const ee=e=>["MAP","DOCUMENT","TOPIC"].includes(e);var te;e.FtSearchScope=void 0,(te=e.FtSearchScope||(e.FtSearchScope={})).DEFAULT="DEFAULT",te.DOCUMENTS="DOCUMENTS";const re=e=>["DEFAULT","DOCUMENTS"].includes(e),ie=e=>r(e)&&i(e.hierarchical)&&n(e.label)&&i(e.multiSelectionable)&&n(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>ne(e))),se=e=>r(e)&&(null==e.maxDepth||s(e.maxDepth))&&n(e.id),ne=e=>r(e)&&s(e.totalResultsCount)&&i(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>ne(e)))&&n(e.label)&&n(e.value)&&i(e.selected),ae=e=>r(e)&&k(e.type)&&n(e.key)&&L(e.order),oe=e=>r(e)&&n(e.suggestedQuery)&&n(e.htmlSuggestedQuery),le=e=>r(e)&&n(e.filename)&&n(e.resourceUrl)&&n(e.id)&&n(e.mimeType)&&n(e.resourceContentUrl)&&n(e.viewerUrl),ue=e=>r(e)&&(null==e.filenameExtension||n(e.filenameExtension))&&(null==e.editorialType||H(e.editorialType))&&(null==e.mimeType||n(e.mimeType))&&ee(e.type)&&n(e.value);var ce;e.FtUserRole=void 0,(ce=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",ce.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",ce.HTML_EXPORT_USER="HTML_EXPORT_USER",ce.PDF_EXPORT_USER="PDF_EXPORT_USER",ce.SAVED_SEARCH_USER="SAVED_SEARCH_USER",ce.COLLECTION_USER="COLLECTION_USER",ce.OFFLINE_USER="OFFLINE_USER",ce.ANALYTICS_USER="ANALYTICS_USER",ce.BETA_USER="BETA_USER",ce.DEBUG_USER="DEBUG_USER",ce.PRINT_USER="PRINT_USER",ce.RATING_USER="RATING_USER",ce.FEEDBACK_USER="FEEDBACK_USER",ce.CONTENT_PUBLISHER="CONTENT_PUBLISHER",ce.KHUB_ADMIN="KHUB_ADMIN",ce.USERS_ADMIN="USERS_ADMIN",ce.PORTAL_ADMIN="PORTAL_ADMIN",ce.ADMIN="ADMIN",ce.DEVELOPER="DEVELOPER";const de=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),pe=e=>r(e)&&n(e.identifier)&&n(e.realm),he=e=>r(e)&&(null==e.emailAddress||n(e.emailAddress))&&(null==e.displayName||n(e.displayName))&&Array.isArray(e.roles)&&e.roles.every((e=>de(e)))&&(null==e.userId||n(e.userId)),ye=e=>"object"==typeof e&&null!=e,fe=e=>"boolean"==typeof e,me=e=>"number"==typeof e,Ae=e=>"string"==typeof e,Ee=e=>ye(e)&&fe(e.mailsSentByFluidTopics)&&fe(e.mailsSentByFluidTopicsForUnauthenticatedUsers)&&Array.isArray(e.recipients)&&e.recipients.every((e=>Ae(e)))&&Array.isArray(e.bodyMetadataIds)&&e.bodyMetadataIds.every((e=>Ae(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>Ae(e))),ge=e=>ye(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>fe(e))))&&fe(e.isVisible),be=e=>ye(e)&&(null==e.prettyUrl||Ae(e.prettyUrl))&&(null==e.hasRating||fe(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||Ae(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>be(e)))&&(null==e.pageConfiguration||ge(e.pageConfiguration))&&(null==e.contentId||Ae(e.contentId))&&(null==e.title||Ae(e.title)),Te=e=>ye(e)&&fe(e.splitCurrentPageToc),Se={[e.FtUserRole.PERSONAL_BOOK_SHARE_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.HTML_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.PDF_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.KHUB_ADMIN]:[e.FtUserRole.CONTENT_PUBLISHER],[e.FtUserRole.ADMIN]:[e.FtUserRole.KHUB_ADMIN,e.FtUserRole.USERS_ADMIN,e.FtUserRole.PORTAL_ADMIN],[e.FtUserRole.DEVELOPER]:[e.FtUserRole.BETA_USER,e.FtUserRole.DEBUG_USER]};function Re(e,t){return e===t||(Se[e]??[]).some((e=>Re(e,t)))}const Fe="undefined"==typeof window?globalThis:window;function Ue(e){let t={};for(let r in e){let i=e[r];("object"!=typeof i||Array.isArray(i))&&(i={prior:i});for(let e of["prior","filter"])i[e]=Array.isArray(i[e])?i[e]:[i[e]],i[e]=i[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=i}return t}function Oe(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const Ie="undefined"==typeof window?globalThis:window;class _e extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function ve(e){if(!e.ok)throw new _e(e.status,e.statusText,await e.text());return e}function Ce(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class Pe{tenantBaseUrl;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})},searches:{list:`api/users/${e}/searches`},bookmarks:{list:`api/users/${e}/bookmarks`}})},stylesheets:{fonts:"api/stylesheets/fonts.css",theme:"api/stylesheets/theme.css",content:{title:"api/stylesheets/content/title.css",topic:"api/stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader"},locales:{ui:"api/locales/ui"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})},custom:{contextName:t=>({endpoint:`api/messages/${e}/custom/${t}`})}})}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=(e??Ie.__gwt_ft_moduleBase??Ie.fluidtopicsclient?.__moduleBase??Ie.__gwt_activeModules?.fluidtopicsclient?.moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",r&&void 0!==Ie.location&&Ie.location.href.startsWith(this.tenantBaseUrl)?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e,t){return this.get(this.endpoints.khub.maps.mapId(e).info,t)}getTableOfContent(e,t){return this.get(this.endpoints.khub.maps.mapId(e).toc,t)}getPages(e,t){return this.get(this.endpoints.khub.maps.mapId(e).pages,t)}getTopic(e,t,r){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info,r)}getTopicHTMLContent(e,t,r,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(r?"?target="+r:""),i)}getMapAttachments(e,t){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list,t)}getMapAttachmentContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content,r)}getMapResources(e,t){return this.get(this.endpoints.khub.maps.mapId(e).resources.list,t)}getMapResourceContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content,r)}getUnstructuredDocument(e,t){return this.get(this.endpoints.khub.documents.documentId(e).info,t)}getUnstructuredDocumentContent(e,t){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content,t)}getUnstructuredDocumentTextContent(e,t){return this.get(this.endpoints.khub.documents.documentId(e).text,t)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getAvailableUiLocales(){return this.get(this.endpoints.khub.locales)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:r})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t,from:r})}rateTopic(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:r,value:i})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:r,from:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:r})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).feedback,{message:t,from:r})}getFluidTopicsMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).fluidTopics.contextName(t).endpoint)}getCustomMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).custom.contextName(t).endpoint)}listMySearches(e){return this.get(this.endpoints.users.userId(e).searches.list)}listMyBookmarks(e){return this.get(this.endpoints.users.userId(e).bookmarks.list)}get(e,t){return this.makeRequest("GET",this.withVersion(e,t))}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}makeAbsolute(e){return e.startsWith(this.tenantBaseUrl)?e:this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const r=t;return await fetch(this.makeAbsolute(e),{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}upload(e,t,r,i=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((s,n)=>{let a=new XMLHttpRequest;a.onload=()=>{if(a.status>=200&&a.status<300){let e="application/json"===a.getResponseHeader("Content-Type")?JSON.parse(a.responseText):a.responseText;s(e)}else n(new _e(a.status,a.statusText,a.responseText))},a.upload.onprogress=e=>i(e),a.open(e,this.makeAbsolute(t),!0),a.send(r)})):this.fetch(t,{method:e,body:r}).then(ve).then(Ce)}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0,credentials:null==this.authorization?"include":void 0}).then(ve).then(Ce)}fetchRawData(e,t){return fetch(this.withVersion(e,t),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then(ve).then((e=>e.arrayBuffer()))}withVersion(e,t){let r=new URL(this.makeAbsolute(e));return t&&r.searchParams.append("v",t),r.toString()}}e.FluidTopicsApi=Pe,e.HttpError=_e,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(Fe.localStorage){const r=Oe(e),i=e=>{e.storageArea===Fe.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return Fe.addEventListener("storage",i),{removeHandler:()=>Fe.removeEventListener("storage",i)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=Pe,e.getUnauthenticatedUserSearchPreferences=function(e){if(Fe.localStorage)return JSON.parse(Fe.localStorage.getItem(Oe(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>r(e)&&pe(e.authenticationIdentifier)&&he(e.profile),e.isFtAuthenticationIdentifier=pe,e.isFtBookmark=e=>r(e)&&n(e.mapTitle)&&o(e.color)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>n(e)))&&n(e.tocId)&&n(e.lastUpdate)&&n(e.readerUrl)&&n(e.mapId)&&n(e.id)&&n(e.title)&&n(e.creationDate),e.isFtCollectionDocument=e=>r(e)&&i(e.deleted)&&(null==e.apiUrl||n(e.apiUrl))&&(null==e.portalUrl||n(e.portalUrl))&&n(e.id)&&n(e.title)&&G(e.type),e.isFtCollectionDocumentType=G,e.isFtCredentials=e=>r(e)&&n(e.password)&&(null==e.newPassword||n(e.newPassword))&&i(e.rememberMe)&&n(e.login),e.isFtEditorialType=H,e.isFtFeedbackCreation=e=>r(e)&&(null==e.from||n(e.from))&&n(e.message),e.isFtLabeledSearchFilter=q,e.isFtMap=e=>r(e)&&(null==e.prettyUrl||n(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&$(e.openMode)&&(null==e.topicsApiEndpoint||n(e.topicsApiEndpoint))&&(null==e.description||n(e.description))&&(null==e.attachmentsApiEndpoint||n(e.attachmentsApiEndpoint))&&H(e.editorialType)&&n(e.baseId)&&n(e.clusterId)&&n(e.title)&&n(e.lastPublication)&&n(e.lastEdition)&&n(e.originId)&&(null==e.rightsApiEndpoint||n(e.rightsApiEndpoint))&&h(e.contentStyles)&&(null==e.originUrl||n(e.originUrl))&&n(e.readerUrl)&&(null==e.khubVersion||n(e.khubVersion))&&n(e.id)&&(null==e.lang||n(e.lang)),e.isFtMapAttachment=e=>ye(e)&&Ae(e.file)&&(null==e.size||me(e.size))&&fe(e.externalLink)&&Ae(e.name)&&Ae(e.id)&&(null==e.mimeType||Ae(e.mimeType))&&(null==e.viewerUrl||Ae(e.viewerUrl)),e.isFtMapResource=e=>r(e)&&n(e.contentUrl)&&n(e.filename)&&n(e.id)&&n(e.mimeType),e.isFtMapStyles=h,e.isFtMessageContext=e=>r(e)&&n(e.name)&&r(e.messages)&&Object.keys(e.messages).every((e=>n(e)))&&Object.values(e.messages).every((e=>n(e)))&&n(e.locale),e.isFtMetadata=E,e.isFtMetadataPreferenceConfiguration=O,e.isFtMyLibraryColors=o,e.isFtMySearch=e=>r(e)&&g(e.searchRequest)&&o(e.color)&&i(e.alert)&&n(e.description)&&n(e.id)&&n(e.ownerId)&&n(e.title)&&n(e.creationDate),e.isFtMySearchRequest=g,e.isFtOpenMode=$,e.isFtPageConfiguration=ge,e.isFtPageRequest=V,e.isFtPaginatedToc=e=>ye(e)&&Te(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>be(e))),e.isFtPaginatedTocNode=be,e.isFtPaginationConfiguration=Te,e.isFtPeriod=I,e.isFtPeriodFilter=_,e.isFtPeriodFilterType=C,e.isFtPersonalBookCreation=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>c(e)))&&Array.isArray(e.nodes)&&e.nodes.every((e=>d(e)))&&n(e.description)&&n(e.title),e.isFtPersonalBookMetadataUpdate=c,e.isFtPersonalBookNodeCreation=d,e.isFtPersonalBookTopicLinkCreation=p,e.isFtPublicationRating=S,e.isFtPublicationRatingSummary=R,e.isFtRatingCreation=e=>r(e)&&T(e.type)&&s(e.value),e.isFtRatingSummary=e=>r(e)&&(null==e.topics||U(e.topics))&&R(e.publication),e.isFtRatingType=T,e.isFtReaderConfiguration=e=>ye(e)&&Ee(e.feedback)&&me(e.loadAfterLastVisibleTopic)&&me(e.loadBeforeFirstVisibleTopic),e.isFtReaderFeedbackConfiguration=Ee,e.isFtSearchFacet=ie,e.isFtSearchFacetConf=se,e.isFtSearchFacetEntry=ne,e.isFtSearchFilter=P,e.isFtSearchLocale=A,e.isFtSearchLocales=e=>r(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>A(e))),e.isFtSearchPreferencesConfiguration=e=>r(e)&&r(e.metadata)&&Object.keys(e.metadata).every((e=>n(e)))&&Object.values(e.metadata).every((e=>O(e))),e.isFtSearchPreset=e=>r(e)&&n(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>P(e)))&&s(e.priority)&&(null==e.contentLocale||n(e.contentLocale)),e.isFtSearchPrior=X,e.isFtSearchRequest=e=>r(e)&&(null==e.periodFilter||_(e.periodFilter))&&n(e.query)&&(null==e.scope||re(e.scope))&&V(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>P(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>ae(e)))&&(null==e.uiLocale||n(e.uiLocale))&&(null==e.virtualField||M(e.virtualField))&&(null==e.contentLocale||n(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>X(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>se(e))),e.isFtSearchResultCluster=Y,e.isFtSearchResultClusterEntry=z,e.isFtSearchResultMap=J,e.isFtSearchResultTopic=Q,e.isFtSearchResultType=ee,e.isFtSearchResultUnstructuredDocument=W,e.isFtSearchResults=e=>r(e)&&(null==e.spellcheck||oe(e.spellcheck))&&B(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>Y(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>ie(e))),e.isFtSearchResultsPageInfo=B,e.isFtSearchScope=re,e.isFtSearchSortCriterion=ae,e.isFtSearchSortCriterionOrder=L,e.isFtSearchSortCriterionType=k,e.isFtSession=e=>r(e)&&(null==e.authenticationIdentifier||pe(e.authenticationIdentifier))&&s(e.idleTimeoutInMillis)&&he(e.profile)&&i(e.sessionAuthenticated),e.isFtSpellcheck=oe,e.isFtSuggestRequest=e=>r(e)&&n(e.input)&&(null==e.scope||re(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>P(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>ae(e)))&&(null==e.maxCount||s(e.maxCount))&&(null==e.contentLocale||n(e.contentLocale)),e.isFtSuggestResult=ue,e.isFtSuggestResults=e=>r(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>ue(e))),e.isFtTocNode=y,e.isFtTopic=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&n(e.id)&&n(e.contentApiEndpoint)&&n(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicOrigin=f,e.isFtTopicOriginType=u,e.isFtTopicRating=F,e.isFtTopicResource=le,e.isFtTopicsRatingSummary=U,e.isFtUiLocale=e=>r(e)&&n(e.displayName)&&n(e.languageTag)&&i(e.translated),e.isFtUnstructuredDocument=e=>r(e)&&(null==e.prettyUrl||n(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>E(e)))&&n(e.openMode)&&(null==e.description||n(e.description))&&n(e.mimeType)&&(null==e.baseId||n(e.baseId))&&(null==e.clusterId||n(e.clusterId))&&n(e.contentApiEndpoint)&&n(e.title)&&(null==e.lastPublication||n(e.lastPublication))&&n(e.viewerUrl)&&n(e.lastEdition)&&n(e.filename)&&(null==e.originId||n(e.originId))&&n(e.rightsApiEndpoint)&&(null==e.originUrl||n(e.originUrl))&&(null==e.khubVersion||n(e.khubVersion))&&n(e.id)&&(null==e.lang||n(e.lang)),e.isFtUserProfile=he,e.isFtUserRole=de,e.isFtVirtualField=M,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(Fe.localStorage){let r={...t,metadata:Ue(t.metadata??{})};const i=Oe(e),s=JSON.stringify(r);return Fe.localStorage.setItem(i,s),Fe.dispatchEvent(new StorageEvent("storage",{key:i,newValue:s,storageArea:Fe.localStorage,url:Fe.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")},e.userHasRole=function(e,t){return null!=e&&(Array.isArray(e)?e:Array.isArray(e.roles)?e.roles:Array.isArray(e.profile?.roles)?e.profile.roles:[]).some((e=>Re(e,t)))}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/public-api",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "description": "Fluid Topics Public API",
5
5
  "author": "Fluid Topics dev team <opensource@antidot.net>",
6
6
  "license": "LGPL-3.0-only",
package/.yarnrc DELETED
@@ -1 +0,0 @@
1
- --frozen-lockfile false
@@ -1,373 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.FluidTopicsApi = exports.HttpError = void 0;
27
- require("cross-fetch/polyfill");
28
- const wnd = (typeof window === "undefined" ? globalThis : window);
29
- __exportStar(require("./types/ft-common/public"), exports);
30
- __exportStar(require("./types/ft-server/public"), exports);
31
- __exportStar(require("./roles/roles"), exports);
32
- __exportStar(require("./preferences/unauthenticated-preferences"), exports);
33
- function toBase64(s) {
34
- return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
35
- }
36
- class HttpError extends Error {
37
- constructor(status, statusText, body) {
38
- super(`${status} - ${statusText}: ${body}`);
39
- this.status = status;
40
- this.statusText = statusText;
41
- this.body = body;
42
- }
43
- }
44
- exports.HttpError = HttpError;
45
- function handleError(response) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- if (!response.ok) {
48
- throw new HttpError(response.status, response.statusText, yield response.text());
49
- }
50
- return response;
51
- });
52
- }
53
- function getBody(response) {
54
- return response.headers.get("Content-Type") === "application/json" ? response.json() : response.text();
55
- }
56
- class FluidTopicsApi {
57
- get defaultHeaders() {
58
- return Object.assign(Object.assign(Object.assign({}, this.authorization), this.searchLabel), { "Ft-Calling-App": this.ftCallingApp });
59
- }
60
- constructor(tenantBaseUrl, integrationIdentifier, overrideIdentifierIfOnTenant) {
61
- var _a, _b, _c, _d, _e, _f;
62
- this.endpoints = {
63
- authentication: {
64
- login: `api/authentication/login`,
65
- logout: `api/authentication/logout`,
66
- currentSession: `api/authentication/current-session`,
67
- },
68
- khub: {
69
- maps: {
70
- mapId: (mapId) => ({
71
- info: `api/khub/maps/${mapId}`,
72
- toc: `api/khub/maps/${mapId}/toc`,
73
- pages: `api/khub/maps/${mapId}/pages`,
74
- feedback: `api/khub/maps/${mapId}/feedback`,
75
- rating: `api/khub/maps/${mapId}/rating`,
76
- attachments: {
77
- list: `api/khub/maps/${mapId}/attachments`,
78
- attachmentId: (attachmentId) => ({
79
- content: `api/khub/maps/${mapId}/attachments/${attachmentId}/content`,
80
- })
81
- },
82
- resources: {
83
- list: `api/khub/maps/${mapId}/resources`,
84
- resourceId: (resourceId) => ({
85
- content: `api/khub/maps/${mapId}/resources/${resourceId}/content`,
86
- })
87
- },
88
- topics: {
89
- contentId: (contentId) => ({
90
- info: `api/khub/maps/${mapId}/topics/${contentId}`,
91
- content: `api/khub/maps/${mapId}/topics/${contentId}/content`,
92
- }),
93
- tocId: (tocId) => ({
94
- feedback: `api/khub/maps/${mapId}/topics/${tocId}/feedback`,
95
- rating: `api/khub/maps/${mapId}/topics/${tocId}/rating`,
96
- })
97
- },
98
- })
99
- },
100
- documents: {
101
- documentId: (documentId) => ({
102
- info: `api/khub/documents/${documentId}`,
103
- content: `api/khub/documents/${documentId}/content`,
104
- text: `api/khub/documents/${documentId}/content/text`,
105
- feedback: `api/khub/documents/${documentId}/feedback`,
106
- rating: `api/khub/documents/${documentId}/rating`,
107
- })
108
- },
109
- suggest: `api/khub/suggest`,
110
- clusteredSearch: `api/khub/clustered-search`,
111
- locales: `api/khub/locales`,
112
- },
113
- users: {
114
- userId: (userId) => ({
115
- collections: {
116
- collectionId: (collectionId) => ({
117
- documents: `api/users/${userId}/collections/${collectionId}/documents`,
118
- })
119
- },
120
- searches: {
121
- list: `api/users/${userId}/searches`
122
- },
123
- bookmarks: {
124
- list: `api/users/${userId}/bookmarks`
125
- }
126
- }),
127
- },
128
- stylesheets: {
129
- fonts: `api/stylesheets/fonts.css`,
130
- theme: `api/stylesheets/theme.css`,
131
- content: {
132
- title: `api/stylesheets/content/title.css`,
133
- topic: `api/stylesheets/content/topic.css`,
134
- },
135
- },
136
- configuration: {
137
- reader: `api/configuration/reader`
138
- },
139
- locales: {
140
- ui: `api/locales/ui`
141
- },
142
- messages: {
143
- locale: (locale) => ({
144
- fluidTopics: {
145
- contextName: (contextName) => ({
146
- endpoint: `api/messages/${locale}/fluid-topics/${contextName}`,
147
- })
148
- },
149
- custom: {
150
- contextName: (contextName) => ({
151
- endpoint: `api/messages/${locale}/custom/${contextName}`,
152
- })
153
- }
154
- })
155
- },
156
- };
157
- //@ts-ignore
158
- tenantBaseUrl = ((_f = (_c = (_a = tenantBaseUrl !== null && tenantBaseUrl !== void 0 ? tenantBaseUrl : wnd.__gwt_ft_moduleBase) !== null && _a !== void 0 ? _a : (_b = wnd.fluidtopicsclient) === null || _b === void 0 ? void 0 : _b.__moduleBase) !== null && _c !== void 0 ? _c : (_e = (_d = wnd.__gwt_activeModules) === null || _d === void 0 ? void 0 : _d.fluidtopicsclient) === null || _e === void 0 ? void 0 : _e.moduleBase) !== null && _f !== void 0 ? _f : "").trim();
159
- this.tenantBaseUrl = tenantBaseUrl.endsWith("/") ? tenantBaseUrl : tenantBaseUrl + "/";
160
- if (overrideIdentifierIfOnTenant && typeof wnd.location !== "undefined" && wnd.location.href.startsWith(this.tenantBaseUrl)) {
161
- this.ftCallingApp = integrationIdentifier;
162
- }
163
- else {
164
- this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
165
- }
166
- }
167
- setApiKey(apiKey) {
168
- this.authorization = { "Authorization": "Bearer " + apiKey };
169
- }
170
- setCredentials(login, password) {
171
- this.authorization = { "Authorization": "Basic " + toBase64(`${login}:${password}`) };
172
- }
173
- clearAuthentication() {
174
- this.authorization = undefined;
175
- }
176
- setSearchLabel(searchLabel) {
177
- this.searchLabel = { "FT-search-label": searchLabel };
178
- }
179
- clearSearchLabel() {
180
- this.searchLabel = undefined;
181
- }
182
- login(login, password) {
183
- let credentials = {
184
- login: login,
185
- password: password,
186
- rememberMe: true
187
- };
188
- return this.post(this.endpoints.authentication.login, credentials)
189
- .then(result => {
190
- this.setCredentials(login, password);
191
- return result;
192
- });
193
- }
194
- logout() {
195
- return this.post(this.endpoints.authentication.logout)
196
- .then(() => this.clearAuthentication());
197
- }
198
- getCurrentSession() {
199
- return this.get(this.endpoints.authentication.currentSession);
200
- }
201
- getReaderConfiguration() {
202
- return this.get(this.endpoints.configuration.reader);
203
- }
204
- getMap(mapId, v) {
205
- return this.get(this.endpoints.khub.maps.mapId(mapId).info, v);
206
- }
207
- getTableOfContent(mapId, v) {
208
- return this.get(this.endpoints.khub.maps.mapId(mapId).toc, v);
209
- }
210
- getPages(mapId, v) {
211
- return this.get(this.endpoints.khub.maps.mapId(mapId).pages, v);
212
- }
213
- getTopic(mapId, topicContentId, v) {
214
- return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).info, v);
215
- }
216
- getTopicHTMLContent(mapId, topicContentId, target, v) {
217
- return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).content + (target ? "?target=" + target : ""), v);
218
- }
219
- getMapAttachments(mapId, v) {
220
- return this.get(this.endpoints.khub.maps.mapId(mapId).attachments.list, v);
221
- }
222
- getMapAttachmentContent(mapId, attachmentId, v) {
223
- return this.fetchRawData(this.endpoints.khub.maps.mapId(mapId).attachments.attachmentId(attachmentId).content, v);
224
- }
225
- getMapResources(mapId, v) {
226
- return this.get(this.endpoints.khub.maps.mapId(mapId).resources.list, v);
227
- }
228
- getMapResourceContent(mapId, resourceId, v) {
229
- return this.fetchRawData(this.endpoints.khub.maps.mapId(mapId).resources.resourceId(resourceId).content, v);
230
- }
231
- getUnstructuredDocument(documentId, v) {
232
- return this.get(this.endpoints.khub.documents.documentId(documentId).info, v);
233
- }
234
- getUnstructuredDocumentContent(documentId, v) {
235
- return this.fetchRawData(this.endpoints.khub.documents.documentId(documentId).content, v);
236
- }
237
- getUnstructuredDocumentTextContent(documentId, v) {
238
- return this.get(this.endpoints.khub.documents.documentId(documentId).text, v);
239
- }
240
- getCollectionDocuments(userId, collectionId) {
241
- return this.get(this.endpoints.users.userId(userId).collections.collectionId(collectionId).documents);
242
- }
243
- getSuggestions(request) {
244
- return this.post(this.endpoints.khub.suggest, request);
245
- }
246
- search(request) {
247
- return this.post(this.endpoints.khub.clusteredSearch, request);
248
- }
249
- getAvailableSearchLocales() {
250
- return this.get(this.endpoints.khub.locales);
251
- }
252
- getAvailableUiLocales() {
253
- return this.get(this.endpoints.khub.locales);
254
- }
255
- getMapRating(mapId) {
256
- return this.get(this.endpoints.khub.maps.mapId(mapId).rating);
257
- }
258
- rateMap(mapId, type, value) {
259
- return this.post(this.endpoints.khub.maps.mapId(mapId).rating, { type, value });
260
- }
261
- unrateMap(mapId) {
262
- return this.delete(this.endpoints.khub.maps.mapId(mapId).rating);
263
- }
264
- sendMapFeedback(mapId, message, from) {
265
- return this.post(this.endpoints.khub.maps.mapId(mapId).feedback, { message, from });
266
- }
267
- rateTopic(mapId, tocId, type, value) {
268
- return this.post(this.endpoints.khub.maps.mapId(mapId).topics.tocId(tocId).rating, {
269
- type, value
270
- });
271
- }
272
- unrateTopic(mapId, tocId) {
273
- return this.delete(this.endpoints.khub.maps.mapId(mapId).topics.tocId(tocId).rating);
274
- }
275
- sendTopicFeedback(mapId, tocId, message, from) {
276
- return this.post(this.endpoints.khub.maps.mapId(mapId).topics.tocId(tocId).feedback, { message, from });
277
- }
278
- getDocumentRating(docId) {
279
- return this.get(this.endpoints.khub.documents.documentId(docId).rating);
280
- }
281
- rateDocument(docId, type, value) {
282
- return this.post(this.endpoints.khub.documents.documentId(docId).rating, { type, value });
283
- }
284
- unrateDocument(docId) {
285
- return this.delete(this.endpoints.khub.documents.documentId(docId).rating);
286
- }
287
- sendDocumentFeedback(docId, message, from) {
288
- return this.post(this.endpoints.khub.documents.documentId(docId).feedback, { message, from });
289
- }
290
- getFluidTopicsMessageContext(locale, name) {
291
- return this.get(this.endpoints.messages.locale(locale).fluidTopics.contextName(name).endpoint);
292
- }
293
- getCustomMessageContext(locale, name) {
294
- return this.get(this.endpoints.messages.locale(locale).custom.contextName(name).endpoint);
295
- }
296
- listMySearches(userId) {
297
- return this.get(this.endpoints.users.userId(userId).searches.list);
298
- }
299
- listMyBookmarks(userId) {
300
- return this.get(this.endpoints.users.userId(userId).bookmarks.list);
301
- }
302
- get(endpoint, v) {
303
- return this.makeRequest("GET", this.withVersion(endpoint, v));
304
- }
305
- post(endpoint, data) {
306
- return this.makeRequest("POST", endpoint, data);
307
- }
308
- put(endpoint, data) {
309
- return this.makeRequest("PUT", endpoint, data);
310
- }
311
- delete(endpoint) {
312
- return this.makeRequest("DELETE", endpoint);
313
- }
314
- makeAbsolute(endpoint) {
315
- return endpoint.startsWith(this.tenantBaseUrl) ? endpoint : (this.tenantBaseUrl + endpoint.replace(/^\//, ""));
316
- }
317
- fetch(endpoint, init) {
318
- var _a;
319
- return __awaiter(this, void 0, void 0, function* () {
320
- const requestInit = init;
321
- return yield fetch(this.makeAbsolute(endpoint), Object.assign(Object.assign({}, (requestInit !== null && requestInit !== void 0 ? requestInit : {})), { headers: Object.assign(Object.assign({}, this.defaultHeaders), ((_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers) !== null && _a !== void 0 ? _a : {})) }));
322
- });
323
- }
324
- upload(method, endpoint, body, onProgress = () => undefined) {
325
- if (typeof XMLHttpRequest !== "undefined") {
326
- return new Promise((resolve, reject) => {
327
- let xhr = new XMLHttpRequest();
328
- xhr.onload = () => {
329
- if (xhr.status >= 200 && xhr.status < 300) {
330
- let data = xhr.getResponseHeader("Content-Type") === "application/json" ? JSON.parse(xhr.responseText) : xhr.responseText;
331
- resolve(data);
332
- }
333
- else {
334
- reject(new HttpError(xhr.status, xhr.statusText, xhr.responseText));
335
- }
336
- };
337
- xhr.upload.onprogress = (e) => onProgress(e);
338
- xhr.open(method, this.makeAbsolute(endpoint), true);
339
- xhr.send(body);
340
- });
341
- }
342
- else {
343
- return this.fetch(endpoint, { method, body }).then(handleError).then(getBody);
344
- }
345
- }
346
- makeRequest(method, endpoint, data) {
347
- return this.fetch(endpoint, {
348
- method: method,
349
- headers: Object.assign({}, (data != null ? { "Content-Type": "application/json" } : {})),
350
- body: data != null ? JSON.stringify(data) : undefined,
351
- credentials: this.authorization == null ? "include" : undefined
352
- })
353
- .then(handleError)
354
- .then(getBody);
355
- }
356
- fetchRawData(endpoint, v) {
357
- return fetch(this.withVersion(endpoint, v), {
358
- headers: this.defaultHeaders,
359
- credentials: this.authorization == null ? "include" : undefined
360
- })
361
- .then(handleError)
362
- .then(response => response.arrayBuffer());
363
- }
364
- withVersion(endpoint, v) {
365
- let url = new URL(this.makeAbsolute(endpoint));
366
- if (v) {
367
- url.searchParams.append("v", v);
368
- }
369
- return url.toString();
370
- }
371
- }
372
- exports.FluidTopicsApi = FluidTopicsApi;
373
- exports.default = FluidTopicsApi;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addUnauthenticatedUserSearchPreferencesChangeHandler = exports.getUnauthenticatedUserSearchPreferences = exports.setUnauthenticatedUserSearchPreferences = void 0;
4
- const wnd = (typeof window === "undefined" ? globalThis : window);
5
- function normalizeMetadataPreferences(metadata) {
6
- let normalized = {};
7
- for (let key in metadata) {
8
- let values = metadata[key];
9
- if (typeof values !== "object" || Array.isArray(values)) {
10
- values = { prior: values };
11
- }
12
- for (let property of ["prior", "filter"]) {
13
- values[property] = Array.isArray(values[property]) ? values[property] : [values[property]];
14
- values[property] = values[property]
15
- .map(v => v != null ? "" + v : "")
16
- .filter(v => v !== "");
17
- }
18
- normalized[key] = values;
19
- }
20
- return normalized;
21
- }
22
- function getStorageKey(tenantBaseUrl) {
23
- return `${tenantBaseUrl}-FluidTopicsUnauthenticatedUserSearchPreferences`;
24
- }
25
- function setUnauthenticatedUserSearchPreferences(tenantBaseUrl, input) {
26
- var _a;
27
- if (wnd.localStorage) {
28
- let preferences = Object.assign(Object.assign({}, input), { metadata: normalizeMetadataPreferences((_a = input.metadata) !== null && _a !== void 0 ? _a : {}) });
29
- const key = getStorageKey(tenantBaseUrl);
30
- const newValue = JSON.stringify(preferences);
31
- wnd.localStorage.setItem(key, newValue);
32
- wnd.dispatchEvent(new StorageEvent("storage", {
33
- key,
34
- newValue,
35
- storageArea: wnd.localStorage,
36
- url: wnd.location.href
37
- }));
38
- return preferences;
39
- }
40
- console.error("Cannot set unauthenticated preferences: local storage is unavailable.");
41
- }
42
- exports.setUnauthenticatedUserSearchPreferences = setUnauthenticatedUserSearchPreferences;
43
- function getUnauthenticatedUserSearchPreferences(tenantBaseUrl) {
44
- var _a;
45
- if (wnd.localStorage) {
46
- return JSON.parse((_a = wnd.localStorage.getItem(getStorageKey(tenantBaseUrl))) !== null && _a !== void 0 ? _a : "{}");
47
- }
48
- console.error("Cannot get unauthenticated preferences: local storage is unavailable.");
49
- }
50
- exports.getUnauthenticatedUserSearchPreferences = getUnauthenticatedUserSearchPreferences;
51
- function addUnauthenticatedUserSearchPreferencesChangeHandler(tenantBaseUrl, handler) {
52
- if (wnd.localStorage) {
53
- const key = getStorageKey(tenantBaseUrl);
54
- const eventListener = (event) => {
55
- var _a;
56
- if (event.storageArea === wnd.localStorage && event.key === key) {
57
- handler(JSON.parse((_a = event.newValue) !== null && _a !== void 0 ? _a : "{}"));
58
- }
59
- };
60
- wnd.addEventListener("storage", eventListener);
61
- return {
62
- removeHandler: () => wnd.removeEventListener("storage", eventListener)
63
- };
64
- }
65
- console.error("Cannot handle unauthenticated preferences: local storage is unavailable.");
66
- }
67
- exports.addUnauthenticatedUserSearchPreferencesChangeHandler = addUnauthenticatedUserSearchPreferencesChangeHandler;