@fluid-topics/public-api 1.0.81 → 1.0.83-alpha

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.
package/.yarnrc CHANGED
@@ -1 +1 @@
1
- --frozen-lockfile true
1
+ --frozen-lockfile false
@@ -49,9 +49,10 @@ class GenAIChunkReader {
49
49
  yield* this.parseLine(this.partialChunk);
50
50
  }
51
51
  *readChunksFromValue(value) {
52
+ var _a;
52
53
  const text = this.partialChunk + this.decoder.decode(value);
53
54
  const lines = text.split("\n");
54
- this.partialChunk = lines.pop();
55
+ this.partialChunk = (_a = lines.pop()) !== null && _a !== void 0 ? _a : "";
55
56
  for (let line of lines) {
56
57
  yield* this.parseLine(line);
57
58
  }
package/dist/cjs/index.js CHANGED
@@ -210,6 +210,9 @@ class FluidTopicsApi {
210
210
  sendFeedback: `api/ai/rate`,
211
211
  chat: `/api/ai/rag/chat`,
212
212
  translate: `api/ai/translate`,
213
+ destinationLanguages: (profileId) => ({
214
+ endpoint: `api/ai/translate/${profileId}/languages`
215
+ })
213
216
  },
214
217
  assets: {
215
218
  highlightjs: `assets/scripts/highlightjs`,
@@ -263,20 +266,23 @@ class FluidTopicsApi {
263
266
  getReaderConfiguration() {
264
267
  return this.get(this.endpoints.configuration.reader);
265
268
  }
266
- getMap(mapId, v) {
267
- return this.get(this.endpoints.khub.maps.mapId(mapId).info, v);
269
+ getMap(mapId, translationSettings, v) {
270
+ const endpoint = this.endpoints.khub.maps.mapId(mapId).info;
271
+ return this.get(this.withTranslationParameters(endpoint, translationSettings), v);
268
272
  }
269
273
  getTableOfContent(mapId, v) {
270
274
  return this.get(this.endpoints.khub.maps.mapId(mapId).toc, v);
271
275
  }
272
- getPages(mapId, v) {
273
- return this.get(this.endpoints.khub.maps.mapId(mapId).pages, v);
276
+ getPages(mapId, v, translationSettings) {
277
+ const endpoint = this.endpoints.khub.maps.mapId(mapId).pages;
278
+ return this.get(this.withTranslationParameters(endpoint, translationSettings), v);
274
279
  }
275
280
  getTopic(mapId, topicContentId, v) {
276
281
  return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).info, v);
277
282
  }
278
- getTopicHTMLContent(mapId, topicContentId, target, v) {
279
- return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).content + (target ? "?target=" + target : ""), v);
283
+ getTopicHTMLContent(mapId, topicContentId, target, v, translationSettings) {
284
+ const endpoint = this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).content;
285
+ return this.get(this.withTranslationParameters(endpoint + (target ? "?target=" + target : ""), translationSettings), v);
280
286
  }
281
287
  getMapAttachments(mapId, v) {
282
288
  return this.get(this.endpoints.khub.maps.mapId(mapId).attachments.list, v);
@@ -406,6 +412,10 @@ class FluidTopicsApi {
406
412
  translate(input) {
407
413
  return this.post(this.endpoints.ai.translate, input);
408
414
  }
415
+ getDestinationLanguages(profileId, sourceLanguage) {
416
+ return this.get(this.endpoints.ai.destinationLanguages(profileId).endpoint
417
+ + (sourceLanguage ? "?sourceLanguage=" + sourceLanguage : ""));
418
+ }
409
419
  sendFeedback(rating) {
410
420
  return this.post(this.endpoints.ai.sendFeedback, rating);
411
421
  }
@@ -482,6 +492,17 @@ class FluidTopicsApi {
482
492
  }
483
493
  return url.toString();
484
494
  }
495
+ withTranslationParameters(endpoint, translationSettings) {
496
+ let url = new URL(this.makeAbsolute(endpoint));
497
+ if (translationSettings) {
498
+ url.searchParams.append("translationProfileId", translationSettings.profileId);
499
+ url.searchParams.append("translationDestinationLanguage", translationSettings.destinationLanguage);
500
+ if (translationSettings.sourceLanguage) {
501
+ url.searchParams.append("translationSourceLanguage", translationSettings.sourceLanguage.slice(0, 2)); // FIX THIS!!
502
+ }
503
+ }
504
+ return url.toString();
505
+ }
485
506
  }
486
507
  exports.FluidTopicsApi = FluidTopicsApi;
487
508
  exports.default = FluidTopicsApi;
@@ -1,67 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addUnauthenticatedUserSearchPreferencesChangeHandler = exports.getUnauthenticatedUserSearchPreferences = exports.setUnauthenticatedUserSearchPreferences = void 0;
4
3
  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
- }
4
+ // function normalizeMetadataPreferences(metadata: any): Record<string, FtMetadataPreferenceConfiguration> {
5
+ // let normalized = {}
6
+ // for (let key in metadata) {
7
+ // let values = metadata[key]
8
+ // if (typeof values !== "object" || Array.isArray(values)) {
9
+ // values = {prior: values}
10
+ // }
11
+ // for (let property of ["prior", "filter"]) {
12
+ // values[property] = Array.isArray(values[property]) ? values[property] : [values[property]]
13
+ // values[property] = values[property]
14
+ // .map((v: string) => v != null ? "" + v : "")
15
+ // .filter((v: string) => v !== "")
16
+ // }
17
+ // normalized[key] = values
18
+ // }
19
+ // return normalized
20
+ // }
22
21
  function getStorageKey(tenantBaseUrl) {
23
22
  return `${tenantBaseUrl}-FluidTopicsUnauthenticatedUserSearchPreferences`;
24
23
  }
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;
24
+ // export function addUnauthenticatedUserSearchPreferencesChangeHandler(tenantBaseUrl: string,
25
+ // handler: (newValue: FtSearchPreferencesConfiguration) => void): HandlerRegistration {
26
+ // if (wnd.localStorage) {
27
+ // const key = getStorageKey(tenantBaseUrl)
28
+ // const eventListener = (event: StorageEvent) => {
29
+ // if (event.storageArea === wnd.localStorage && event.key === key) {
30
+ // handler(JSON.parse(event.newValue ?? "{}"))
31
+ // }
32
+ // }
33
+ // wnd.addEventListener("storage", eventListener)
34
+ // return {
35
+ // removeHandler: () => wnd.removeEventListener("storage", eventListener)
36
+ // }
37
+ // }
38
+ // console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")
39
+ // return undefined
40
+ // }
@@ -11,8 +11,8 @@ const rolesInheritance = {
11
11
  [public_js_1.FtUserRole.DEVELOPER]: [public_js_1.FtUserRole.BETA_USER, public_js_1.FtUserRole.DEBUG_USER],
12
12
  };
13
13
  function roleMatches(actual, expected) {
14
- var _a;
15
- return actual === expected || ((_a = rolesInheritance[actual]) !== null && _a !== void 0 ? _a : []).some((inherited) => roleMatches(inherited, expected));
14
+ return true;
15
+ // return actual === expected || (rolesInheritance[actual] ?? []).some((inherited: FtUserRole | FtUserRoleKeys) => roleMatches(inherited, expected))
16
16
  }
17
17
  function userHasRole(sessionOrProfileOrRoles, expectedRole) {
18
18
  var _a;
@@ -117,6 +117,7 @@ const isFtMap = (o) => {
117
117
  && o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
118
118
  && (o.watermark == null || (0, exports.isFtWatermark)(o.watermark))
119
119
  && ((0, exports.isFtOpenMode)(o.openMode))
120
+ && (o.translatedTitle == null || o.translatedTitle == null || isString(o.translatedTitle))
120
121
  && (o.topicsApiEndpoint == null || isString(o.topicsApiEndpoint))
121
122
  && (o.description == null || isString(o.description))
122
123
  && (o.attachmentsApiEndpoint == null || isString(o.attachmentsApiEndpoint))
@@ -153,6 +154,7 @@ const isFtTocNode = (o) => {
153
154
  && (isString(o.tocId))
154
155
  && ((Array.isArray(o.children)
155
156
  && o.children.every((v) => (0, exports.isFtTocNode)(v))))
157
+ && (o.translatedTitle == null || o.translatedTitle == null || isString(o.translatedTitle))
156
158
  && (o.origin == null || (0, exports.isFtTopicOrigin)(o.origin))
157
159
  && (isString(o.contentId))
158
160
  && (isString(o.title));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFtSemanticSearchRequest = exports.isFtSemanticSearchFilter = exports.isFtSemanticSearchResponseItem = exports.isFtClusteredSemanticSearchReply = exports.isFtPaginationConfiguration = exports.isFtPaginatedTocNode = exports.isFtPaginatedToc = exports.isFtPageConfiguration = exports.isFtMapAttachment = exports.isFtTranslationInput = exports.isTranslationFormat = exports.TranslationFormat = exports.isFtRagInput = exports.isFtRagHistory = exports.isFtGenAIGenerateInput = exports.isFtGenAIRating = exports.isFtReaderFeedbackConfiguration = exports.isFtReaderConfiguration = exports.isFtConfigurationHistoryEntryStatus = exports.FtConfigurationHistoryEntryStatus = void 0;
3
+ exports.isFtSemanticSearchRequest = exports.isFtSemanticSearchFilter = exports.isFtSemanticSearchResponseItem = exports.isFtClusteredSemanticSearchReply = exports.isFtPaginationConfiguration = exports.isFtPaginatedTocNode = exports.isFtPaginatedToc = exports.isFtPageConfiguration = exports.isFtMapAttachment = exports.isFtTranslationLanguagesResponse = exports.isFtTranslationSettingsInput = exports.isFtTranslationLanguagesInput = exports.isFtTranslationInput = exports.isTranslationFormat = exports.TranslationFormat = exports.isFtRagInput = exports.isFtRagHistory = exports.isFtGenAIGenerateInput = exports.isFtGenAIRating = exports.isFtReaderFeedbackConfiguration = exports.isFtReaderConfiguration = exports.isFtConfigurationHistoryEntryStatus = exports.FtConfigurationHistoryEntryStatus = void 0;
4
4
  const isObject = (o) => typeof o === "object" && o != null;
5
5
  const isBoolean = (o) => typeof o === "boolean";
6
6
  const isNumber = (o) => typeof o === "number";
@@ -86,6 +86,25 @@ const isFtTranslationInput = (o) => {
86
86
  && (o.sourceLanguage == null || isString(o.sourceLanguage));
87
87
  };
88
88
  exports.isFtTranslationInput = isFtTranslationInput;
89
+ const isFtTranslationLanguagesInput = (o) => {
90
+ return isObject(o)
91
+ && (isString(o.profileId))
92
+ && (o.sourceLanguage == null || isString(o.sourceLanguage));
93
+ };
94
+ exports.isFtTranslationLanguagesInput = isFtTranslationLanguagesInput;
95
+ const isFtTranslationSettingsInput = (o) => {
96
+ return isObject(o)
97
+ && (isString(o.profileId))
98
+ && (isString(o.destinationLanguage))
99
+ && (o.sourceLanguage == null || isString(o.sourceLanguage));
100
+ };
101
+ exports.isFtTranslationSettingsInput = isFtTranslationSettingsInput;
102
+ const isFtTranslationLanguagesResponse = (o) => {
103
+ return isObject(o)
104
+ && (isString(o.code))
105
+ && (isString(o.label));
106
+ };
107
+ exports.isFtTranslationLanguagesResponse = isFtTranslationLanguagesResponse;
89
108
  const isFtMapAttachment = (o) => {
90
109
  return isObject(o)
91
110
  && (isString(o.file))
@@ -119,6 +138,7 @@ const isFtPaginatedTocNode = (o) => {
119
138
  && (o.tocId == null || isString(o.tocId))
120
139
  && ((Array.isArray(o.children)
121
140
  && o.children.every((v) => (0, exports.isFtPaginatedTocNode)(v))))
141
+ && (o.translatedTitle == null || isString(o.translatedTitle))
122
142
  && (o.pageConfiguration == null || (0, exports.isFtPageConfiguration)(o.pageConfiguration))
123
143
  && (o.contentId == null || isString(o.contentId))
124
144
  && (o.title == null || isString(o.title));
@@ -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 r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a={exports:{}};!function(e,r){var a="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==t&&t,i=function(){function e(){this.fetch=!1,this.DOMException=a.DOMException}return e.prototype=a,new e}();!function(e){!function(r){var a=void 0!==e&&e||"undefined"!=typeof self&&self||void 0!==t&&t||{},i={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};if(i.arrayBuffer)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(e){return e&&s.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function u(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i.iterable&&(t[Symbol.iterator]=function(){return t}),t}function c(e){this.map={},e instanceof c?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function p(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function h(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function f(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:i.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():i.arrayBuffer&&i.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):i.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||n(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,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):i.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i.blob&&(this.blob=function(){var e=d(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(){if(this._bodyArrayBuffer){var e=d(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(i.blob)return this.blob().then(h);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,r,a,i,s=d(this);if(s)return s;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=p(t),a=/charset=([A-Za-z0-9_-]+)/.exec(e.type),i=a?a[1]:"utf-8",t.readAsText(e,i),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),a=0;a<t.length;a++)r[a]=String.fromCharCode(t[a]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i.formData&&(this.formData=function(){return this.text().then(E)}),this.json=function(){return this.text().then(JSON.parse)},this}c.prototype.append=function(e,t){e=o(e),t=l(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},c.prototype.delete=function(e){delete this.map[o(e)]},c.prototype.get=function(e){return e=o(e),this.has(e)?this.map[e]:null},c.prototype.has=function(e){return this.map.hasOwnProperty(o(e))},c.prototype.set=function(e,t){this.map[o(e)]=l(t)},c.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},c.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),u(e)},c.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),u(e)},c.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),u(e)},i.iterable&&(c.prototype[Symbol.iterator]=c.prototype.entries);var A=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,s=(t=t||{}).body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new c(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 c(t.headers)),this.method=(r=t.method||this.method||"GET",i=r.toUpperCase(),A.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in a)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),a=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(a),decodeURIComponent(i))}})),t}function T(e,t){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new c(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},f.call(m.prototype),f.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new c(this.headers),url:this.url})},T.error=function(){var e=new T(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var g=[301,302,303,307,308];T.redirect=function(e,t){if(-1===g.indexOf(t))throw new RangeError("Invalid status code");return new T(null,{status:t,headers:{location:e}})},r.DOMException=a.DOMException;try{new r.DOMException}catch(e){r.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},r.DOMException.prototype=Object.create(Error.prototype),r.DOMException.prototype.constructor=r.DOMException}function S(e,t){return new Promise((function(s,n){var u=new m(e,t);if(u.signal&&u.signal.aborted)return n(new r.DOMException("Aborted","AbortError"));var d=new XMLHttpRequest;function p(){d.abort()}if(d.onload=function(){var e,t,r={statusText:d.statusText,headers:(e=d.getAllResponseHeaders()||"",t=new c,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),a=r.shift().trim();if(a){var i=r.join(":").trim();try{t.append(a,i)}catch(e){console.warn("Response "+e.message)}}})),t)};0===u.url.indexOf("file://")&&(d.status<200||d.status>599)?r.status=200:r.status=d.status,r.url="responseURL"in d?d.responseURL:r.headers.get("X-Request-URL");var a="response"in d?d.response:d.responseText;setTimeout((function(){s(new T(a,r))}),0)},d.onerror=function(){setTimeout((function(){n(new TypeError("Network request failed"))}),0)},d.ontimeout=function(){setTimeout((function(){n(new TypeError("Network request timed out"))}),0)},d.onabort=function(){setTimeout((function(){n(new r.DOMException("Aborted","AbortError"))}),0)},d.open(u.method,function(e){try{return""===e&&a.location.href?a.location.href:e}catch(t){return e}}(u.url),!0),"include"===u.credentials?d.withCredentials=!0:"omit"===u.credentials&&(d.withCredentials=!1),"responseType"in d&&(i.blob?d.responseType="blob":i.arrayBuffer&&(d.responseType="arraybuffer")),t&&"object"==typeof t.headers&&!(t.headers instanceof c||a.Headers&&t.headers instanceof a.Headers)){var h=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){h.push(o(e)),d.setRequestHeader(e,l(t.headers[e]))})),u.headers.forEach((function(e,t){-1===h.indexOf(t)&&d.setRequestHeader(t,e)}))}else u.headers.forEach((function(e,t){d.setRequestHeader(t,e)}));u.signal&&(u.signal.addEventListener("abort",p),d.onreadystatechange=function(){4===d.readyState&&u.signal.removeEventListener("abort",p)}),d.send(void 0===u._bodyInit?null:u._bodyInit)}))}S.polyfill=!0,a.fetch||(a.fetch=S,a.Headers=c,a.Request=m,a.Response=T),r.Headers=c,r.Request=m,r.Response=T,r.fetch=S}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var s=a.fetch?a:i;(r=s.fetch).default=s.fetch,r.fetch=s.fetch,r.Headers=s.Headers,r.Request=s.Request,r.Response=s.Response,e.exports=r}(a,a.exports);var i=r(a.exports);class s{reader;decoder=new TextDecoder;partialChunk="";constructor(e){this.reader=e}async*read(){for(;;){const{done:e,value:t}=await this.reader.read();if(e)return void(yield*this.readRemainingChunks());yield*this.readChunksFromValue(t)}}*readRemainingChunks(){yield*this.parseLine(this.partialChunk)}*readChunksFromValue(e){const t=(this.partialChunk+this.decoder.decode(e)).split("\n");this.partialChunk=t.pop();for(let e of t)yield*this.parseLine(e)}*parseLine(e){const[t,r]=e.split(/:(.*)/);"data"==t&&r.length>0&&(yield JSON.parse(r))}}const n=e=>"object"==typeof e&&null!=e,o=e=>"boolean"==typeof e,l=e=>"number"==typeof e,u=e=>"string"==typeof e;var c;e.FtMyLibraryColors=void 0,(c=e.FtMyLibraryColors||(e.FtMyLibraryColors={})).black="black",c.green="green",c.blue="blue",c.purple="purple",c.red="red",c.orange="orange",c.yellow="yellow";const d=e=>["black","green","blue","purple","red","orange","yellow"].includes(e);var p;e.FtTopicOriginType=void 0,(p=e.FtTopicOriginType||(e.FtTopicOriginType={})).OFFICIAL="OFFICIAL",p.PERSONAL="PERSONAL",p.SHARED="SHARED";const h=e=>["OFFICIAL","PERSONAL","SHARED"].includes(e),y=e=>n(e)&&Array.isArray(e.values)&&e.values.every((e=>Array.isArray(e)&&e.every((e=>u(e)))))&&u(e.key),f=e=>n(e)&&u(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>f(e)))&&(null==e.topicLink||A(e.topicLink))&&u(e.title)&&(null==e.htmlContent||u(e.htmlContent)),A=e=>n(e)&&u(e.tocId)&&u(e.contentId)&&u(e.mapId),m=e=>n(e)&&u(e.topicStylesheetUrl)&&u(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>u(e))),E=e=>n(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&(null==e.hasRating||o(e.hasRating))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>E(e)))&&(null==e.origin||T(e.origin))&&u(e.contentId)&&u(e.title),T=e=>n(e)&&u(e.mapTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>u(e)))&&u(e.tocId)&&u(e.contentId)&&u(e.mapId)&&h(e.type);var g;e.FtTopicContentTarget=void 0,(g=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",g.OFF_THE_GRID="OFF_THE_GRID",g.CONTENT_PACKAGER="CONTENT_PACKAGER",g.PAGES="PAGES",g.DESIGNED_READER="DESIGNED_READER";var S;e.FtExternalWebComponentContext=void 0,(S=e.FtExternalWebComponentContext||(e.FtExternalWebComponentContext={})).HOMEPAGE="HOMEPAGE",S.CUSTOM="CUSTOM",S.HEADER="HEADER",S.READER="READER",S.TOPIC_TEMPLATE="TOPIC_TEMPLATE",S.SEARCH="SEARCH",S.SEARCH_RESULT="SEARCH_RESULT";var b;e.FtMetadataHomeLayout=void 0,(b=e.FtMetadataHomeLayout||(e.FtMetadataHomeLayout={})).CLASSIC="CLASSIC",b.CUSTOM="CUSTOM",b.DESIGNER="DESIGNER";const R=e=>n(e)&&u(e.lang)&&u(e.region),F=e=>n(e)&&R(e.defaultUiLocale)&&R(e.defaultContentLocale)&&Array.isArray(e.defaultRegions)&&e.defaultRegions.every((e=>R(e))),O=e=>n(e)&&l(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),v=e=>n(e)&&u(e.displayName)&&u(e.languageTag)&&o(e.translated);var U;e.FtFacetType=void 0,(U=e.FtFacetType||(e.FtFacetType={})).AND="AND",U.OR="OR",U.MONOVALUED="MONOVALUED";const I=e=>n(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>u(e))))))&&u(e.label)&&u(e.key);var C;e.FtMetadataSortRule=void 0,(C=e.FtMetadataSortRule||(e.FtMetadataSortRule={})).NONE="NONE",C.ALPHABET="ALPHABET",C.VERSION="VERSION";const _=e=>["NONE","ALPHABET","VERSION"].includes(e),L=e=>n(e)&&o(e.date)&&_(e.sortRule)&&u(e.label)&&o(e.reverseSort)&&u(e.key),D=e=>n(e)&&(null==e.periodFilter||null==e.periodFilter||ue(e.periodFilter))&&u(e.query)&&(null==e.scope||be(e.scope))&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>oe(e))))&&Array.isArray(e.sort)&&e.sort.every((e=>Ue(e)))&&(null==e.virtualField||X(e.virtualField))&&(null==e.metadataFilters||Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ne(e))))&&(null==e.contentLocale||u(e.contentLocale));var P;e.FtRatingType=void 0,(P=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",P.LIKE="LIKE",P.DICHOTOMOUS="DICHOTOMOUS",P.NO_RATING="NO_RATING";const N=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),M=e=>n(e)&&u(e.date)&&N(e.type)&&l(e.value),k=e=>n(e)&&(null==e.rating||M(e.rating))&&N(e.type),w=e=>n(e)&&u(e.date)&&u(e.tocId)&&N(e.type)&&l(e.value),B=e=>n(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>w(e)))&&N(e.type),H=e=>n(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e)));var x;e.FtPeriodFilterType=void 0,(x=e.FtPeriodFilterType||(e.FtPeriodFilterType={})).LAST_WEEK="LAST_WEEK",x.LAST_MONTH="LAST_MONTH",x.LAST_QUARTER="LAST_QUARTER",x.LAST_YEAR="LAST_YEAR",x.CUSTOM="CUSTOM";const V=e=>["LAST_WEEK","LAST_MONTH","LAST_QUARTER","LAST_YEAR","CUSTOM"].includes(e);var j;e.FtSearchSortCriterionOrder=void 0,(j=e.FtSearchSortCriterionOrder||(e.FtSearchSortCriterionOrder={})).ASC="ASC",j.DESC="DESC";const $=e=>["ASC","DESC"].includes(e);var K;e.FtSearchSortCriterionType=void 0,(K=e.FtSearchSortCriterionType||(e.FtSearchSortCriterionType={})).ALPHA="ALPHA",K.NATURAL="NATURAL";const G=e=>["ALPHA","NATURAL"].includes(e);var q;e.FtVirtualField=void 0,(q=e.FtVirtualField||(e.FtVirtualField={})).EVERYWHERE="EVERYWHERE",q.TITLE_ONLY="TITLE_ONLY",q.NONE="NONE";const X=e=>["EVERYWHERE","TITLE_ONLY","NONE"].includes(e),Y=e=>n(e)&&l(e.totalResultsCount)&&o(e.isLastPage)&&l(e.currentPage)&&l(e.totalClustersCount);var W;e.FtEditorialType=void 0,(W=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",W.BOOK="BOOK",W.SHARED_BOOK="SHARED_BOOK";const z=e=>["ARTICLE","BOOK","SHARED_BOOK"].includes(e);var J;e.FtOpenMode=void 0,(J=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",J.EXTERNAL="EXTERNAL";const Q=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),Z=e=>n(e)&&(null==e.perPage||l(e.perPage))&&l(e.page),ee=e=>n(e)&&u(e.key);var te;e.FtCollectionDocumentType=void 0,(te=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",te.DOCUMENT="DOCUMENT",te.TOPIC="TOPIC",te.PERSONAL_BOOK="PERSONAL_BOOK",te.SHARED_BOOK="SHARED_BOOK";const re=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),ae=e=>n(e)&&se(e.type);var ie;e.FtDateFilterType=void 0,(ie=e.FtDateFilterType||(e.FtDateFilterType={})).LAST_WEEK="LAST_WEEK",ie.LAST_MONTH="LAST_MONTH",ie.LAST_QUARTER="LAST_QUARTER",ie.LAST_YEAR="LAST_YEAR";const se=e=>["LAST_WEEK","LAST_MONTH","LAST_QUARTER","LAST_YEAR"].includes(e),ne=e=>n(e)&&(null==e.valueFilter||Re(e.valueFilter))&&(null==e.rangeFilter||pe(e.rangeFilter))&&u(e.label)&&u(e.key)&&(null==e.dateFilter||ae(e.dateFilter)),oe=e=>n(e)&&o(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key),le=e=>n(e)&&o(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),ue=e=>n(e)&&(null==e.period||de(e.period))&&V(e.periodType)&&(null==e.key||u(e.key)),ce=e=>n(e)&&(null==e.valueFilter||Re(e.valueFilter))&&(null==e.rangeFilter||pe(e.rangeFilter))&&u(e.key)&&(null==e.dateFilter||ae(e.dateFilter)),de=e=>n(e)&&u(e.from)&&u(e.to),pe=e=>n(e)&&u(e.from)&&u(e.to),he=e=>n(e)&&l(e.weight)&&u(e.value)&&u(e.key),ye=e=>n(e)&&Array.isArray(e.entries)&&e.entries.every((e=>fe(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),fe=e=>n(e)&&Array.isArray(e.missingTerms)&&e.missingTerms.every((e=>u(e)))&&(null==e.document||Ae(e.document))&&(null==e.topic||Ee(e.topic))&&ge(e.type)&&(null==e.map||me(e.map)),Ae=e=>n(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&Q(e.openMode)&&u(e.documentUrl)&&u(e.mimeType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.viewerUrl)&&u(e.contentUrl)&&u(e.filename)&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.documentId)&&u(e.lastEditionDate)&&u(e.htmlExcerpt),me=e=>n(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&(null==e.openMode||Q(e.openMode))&&z(e.editorialType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.mapUrl)&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt),Ee=e=>n(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&Q(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>Ce(e)))&&u(e.title)&&u(e.mapTitle)&&u(e.topicUrl)&&u(e.contentUrl)&&u(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>u(e)))&&u(e.tocId)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt);var Te;e.FtSearchResultType=void 0,(Te=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",Te.DOCUMENT="DOCUMENT",Te.TOPIC="TOPIC";const ge=e=>["MAP","DOCUMENT","TOPIC"].includes(e);var Se;e.FtSearchScope=void 0,(Se=e.FtSearchScope||(e.FtSearchScope={})).DEFAULT="DEFAULT",Se.DOCUMENTS="DOCUMENTS",Se.ALL_TOPICS="ALL_TOPICS",Se.TOPICS_AND_UNSTRUCTURED_DOCUMENTS="TOPICS_AND_UNSTRUCTURED_DOCUMENTS";const be=e=>["DEFAULT","DOCUMENTS","ALL_TOPICS","TOPICS_AND_UNSTRUCTURED_DOCUMENTS"].includes(e),Re=e=>n(e)&&o(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e))),Fe=e=>n(e)&&o(e.hierarchical)&&u(e.label)&&o(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>ve(e))),Oe=e=>n(e)&&(null==e.maxDepth||l(e.maxDepth))&&u(e.id),ve=e=>n(e)&&l(e.totalResultsCount)&&o(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>ve(e)))&&u(e.label)&&u(e.value)&&o(e.selected),Ue=e=>n(e)&&G(e.type)&&u(e.key)&&$(e.order),Ie=e=>n(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),Ce=e=>n(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),_e=e=>n(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||z(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&ge(e.type)&&u(e.value);var Le;e.FtUserRole=void 0,(Le=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",Le.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",Le.HTML_EXPORT_USER="HTML_EXPORT_USER",Le.PDF_EXPORT_USER="PDF_EXPORT_USER",Le.SAVED_SEARCH_USER="SAVED_SEARCH_USER",Le.COLLECTION_USER="COLLECTION_USER",Le.OFFLINE_USER="OFFLINE_USER",Le.ANALYTICS_USER="ANALYTICS_USER",Le.BETA_USER="BETA_USER",Le.DEBUG_USER="DEBUG_USER",Le.PRINT_USER="PRINT_USER",Le.RATING_USER="RATING_USER",Le.FEEDBACK_USER="FEEDBACK_USER",Le.GENERATIVE_AI_USER="GENERATIVE_AI_USER",Le.CONTENT_PUBLISHER="CONTENT_PUBLISHER",Le.KHUB_ADMIN="KHUB_ADMIN",Le.USERS_ADMIN="USERS_ADMIN",Le.PORTAL_ADMIN="PORTAL_ADMIN",Le.ADMIN="ADMIN",Le.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","GENERATIVE_AI_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),Pe=e=>n(e)&&u(e.identifier)&&u(e.realm),Ne=e=>n(e)&&(null==e.defaultFilters||Array.isArray(e.defaultFilters)&&e.defaultFilters.every((e=>le(e))))&&Array.isArray(e.defaultMetadataFilters)&&e.defaultMetadataFilters.every((e=>ce(e))),Me=e=>n(e)&&(null==e.emailAddress||u(e.emailAddress))&&(null==e.displayName||u(e.displayName))&&Array.isArray(e.roles)&&e.roles.every((e=>De(e)))&&(null==e.userId||u(e.userId))&&Array.isArray(e.tags)&&e.tags.every((e=>u(e))),ke=e=>n(e)&&u(e.color)&&Array.isArray(e.text)&&e.text.every((e=>u(e)))&&l(e.opacity),we=e=>"object"==typeof e&&null!=e,Be=e=>"boolean"==typeof e,He=e=>"number"==typeof e,xe=e=>"string"==typeof e;var Ve;e.FtConfigurationHistoryEntryStatus=void 0,(Ve=e.FtConfigurationHistoryEntryStatus||(e.FtConfigurationHistoryEntryStatus={})).VALID="VALID",Ve.INVALID="INVALID";const je=e=>we(e)&&Be(e.mailsSentByFluidTopics)&&Be(e.mailsSentByFluidTopicsForUnauthenticatedUsers)&&Array.isArray(e.recipients)&&e.recipients.every((e=>xe(e)))&&Array.isArray(e.bodyMetadataIds)&&e.bodyMetadataIds.every((e=>xe(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>xe(e))),$e=e=>we(e)&&xe(e.role)&&xe(e.content);var Ke;e.TranslationFormat=void 0,(Ke=e.TranslationFormat||(e.TranslationFormat={})).TEXT="TEXT",Ke.HTML="HTML";const Ge=e=>["TEXT","HTML"].includes(e),qe=e=>we(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>Be(e))))&&Be(e.isVisible),Xe=e=>we(e)&&(null==e.prettyUrl||xe(e.prettyUrl))&&(null==e.hasRating||Be(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||xe(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>Xe(e)))&&(null==e.pageConfiguration||qe(e.pageConfiguration))&&(null==e.contentId||xe(e.contentId))&&(null==e.title||xe(e.title)),Ye=e=>we(e)&&Be(e.splitCurrentPageToc),We=e=>we(e)&&we(e.metadata)&&Object.keys(e.metadata).every((e=>xe(e)))&&Object.values(e.metadata).every((e=>Array.isArray(e)&&e.every((e=>xe(e)))))&&xe(e.excerpt)&&He(e.relevance),ze=e=>we(e)&&Array.isArray(e.values)&&e.values.every((e=>xe(e)))&&xe(e.key),Je={[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 Qe(e,t){return e===t||(Je[e]??[]).some((e=>Qe(e,t)))}const Ze="undefined"==typeof window?globalThis:window;function et(e){let t={};for(let r in e){let a=e[r];("object"!=typeof a||Array.isArray(a))&&(a={prior:a});for(let e of["prior","filter"])a[e]=Array.isArray(a[e])?a[e]:[a[e]],a[e]=a[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=a}return t}function tt(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const rt="undefined"==typeof window?globalThis:window;class at extends Error{method;endpoint;status;statusText;body;constructor(e,t,r,a,i){super(`${e} ${t} -> ${r} - ${a}: ${i}`),this.method=e,this.endpoint=t,this.status=r,this.statusText=a,this.body=i}}class it extends CustomEvent{constructor(e){super("ft-api-http-error",{detail:e})}}async function st(e,t,r){if(!r.ok){let a={method:e,endpoint:t,status:r.status,statusText:r.statusText,body:await r.text()};throw"function"==typeof rt.dispatchEvent&&rt.dispatchEvent(new it(a)),new at(a.method,a.endpoint,a.status,a.statusText,a.body)}return r}function nt(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class ot{tenantBaseUrl;tenantBaseUrlNoTrailingSlash;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`})},semantic:{search:"api/khub/semantic/search",clusteredSearch:"api/khub/semantic/clustered-search"},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:"stylesheets/fonts.css",theme:"stylesheets/theme.css",content:{title:"stylesheets/content/title.css",topic:"stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader",metadata:"api/configuration/metadata"},locales:{ui:"api/locales/ui",get:"api/locales"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})},custom:{contextName:t=>({endpoint:`api/messages/${e}/custom/${t}`})}})},ai:{generate:"api/ai/generate",sendFeedback:"api/ai/rate",chat:"/api/ai/rag/chat",translate:"api/ai/translate"},assets:{highlightjs:"assets/scripts/highlightjs"}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=(e??rt.fluidTopicsBaseUrl??rt.__gwt_ft_moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",this.tenantBaseUrlNoTrailingSlash=this.tenantBaseUrl.replace(/\/$/,""),r&&void 0!==rt.location&&rt.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,a){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(r?"?target="+r:""),a)}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.locales.ui)}getLocalesConfiguration(){return this.get(this.endpoints.locales.get)}getMetadataConfiguration(){return this.get(this.endpoints.configuration.metadata)}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,a){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:r,value:a})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,r,a){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:r,from:a})}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})}semanticSearch(e){return this.post(this.endpoints.khub.semantic.search,{request:e})}clusteredSemanticSearch(e){return this.post(this.endpoints.khub.semantic.clusteredSearch,{request:e})}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)}async*generate(e,t){const r=await this.fetch(this.endpoints.ai.generate,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:e,parameters:t}),credentials:null==this.authorization?"include":void 0});await st("POST",this.endpoints.ai.generate,r);const a=new s(r.body.getReader());yield*a.read()}async*chat(e){const t=await this.fetch(this.endpoints.ai.chat,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:null==this.authorization?"include":void 0});await st("POST",this.endpoints.ai.chat,t);const r=new s(t.body.getReader());yield*r.read()}translate(e){return this.post(this.endpoints.ai.translate,e)}sendFeedback(e){return this.post(this.endpoints.ai.sendFeedback,e)}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.tenantBaseUrlNoTrailingSlash?e:this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const r=t;return await i(this.makeAbsolute(e),{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}upload(e,t,r,a=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((i,s)=>{let n=new XMLHttpRequest;n.onload=()=>{if(n.status>=200&&n.status<300){let e="application/json"===n.getResponseHeader("Content-Type")?JSON.parse(n.responseText):n.responseText;i(e)}else s(new at("GET",t,n.status,n.statusText,n.responseText))},n.upload.onprogress=e=>a(e),n.open(e,this.makeAbsolute(t),!0),n.send(r)})):this.fetch(t,{method:e,body:r}).then((r=>st(e,t,r))).then(nt)}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((r=>st(e,t,r))).then(nt)}fetchRawData(e,t){return i(this.withVersion(e,t),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then((t=>st("GET",e,t))).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=ot,e.HttpError=at,e.HttpErrorEvent=it,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(Ze.localStorage){const r=tt(e),a=e=>{e.storageArea===Ze.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return Ze.addEventListener("storage",a),{removeHandler:()=>Ze.removeEventListener("storage",a)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=ot,e.getUnauthenticatedUserSearchPreferences=function(e){if(Ze.localStorage)return JSON.parse(Ze.localStorage.getItem(tt(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>n(e)&&Pe(e.authenticationIdentifier)&&Me(e.profile),e.isFtAuthenticationIdentifier=Pe,e.isFtBookmark=e=>n(e)&&u(e.mapTitle)&&d(e.color)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>u(e)))&&u(e.tocId)&&u(e.lastUpdate)&&u(e.readerUrl)&&u(e.mapId)&&u(e.id)&&u(e.title)&&u(e.creationDate),e.isFtClusteredSemanticSearchReply=e=>we(e)&&Array.isArray(e.documents)&&e.documents.every((e=>We(e)))&&Array.isArray(e.clusterId)&&e.clusterId.every((e=>xe(e))),e.isFtCollectionDocument=e=>n(e)&&o(e.deleted)&&(null==e.apiUrl||u(e.apiUrl))&&(null==e.portalUrl||u(e.portalUrl))&&u(e.id)&&u(e.title)&&re(e.type),e.isFtCollectionDocumentType=re,e.isFtConfigurationHistoryEntryStatus=e=>["VALID","INVALID"].includes(e),e.isFtCredentials=e=>n(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&o(e.rememberMe)&&u(e.login),e.isFtDateFilter=ae,e.isFtDateFilterType=se,e.isFtDefaultLocale=R,e.isFtDefaultLocales=F,e.isFtEditorialType=z,e.isFtExternalWebComponentContext=e=>["HOMEPAGE","CUSTOM","HEADER","READER","TOPIC_TEMPLATE","SEARCH","SEARCH_RESULT"].includes(e),e.isFtFacetType=e=>["AND","OR","MONOVALUED"].includes(e),e.isFtFeedbackCreation=e=>n(e)&&(null==e.from||u(e.from))&&u(e.message),e.isFtGenAIGenerateInput=e=>we(e)&&xe(e.profileId)&&(null==e.parameters||we(e.parameters)&&Object.keys(e.parameters).every((e=>xe(e)))&&Object.values(e.parameters).every((e=>xe(e)))),e.isFtGenAIRating=e=>we(e)&&He(e.rating)&&xe(e.comment)&&xe(e.queryId),e.isFtHttpErrorDetails=e=>n(e)&&u(e.endpoint)&&u(e.method)&&u(e.statusText)&&u(e.body)&&l(e.status),e.isFtLabeledMetadataFilter=ne,e.isFtLegacyLabeledMetadataFilter=oe,e.isFtLegacyMetadataFilter=le,e.isFtLocalesConfiguration=e=>n(e)&&Array.isArray(e.availableUiLocales)&&e.availableUiLocales.every((e=>v(e)))&&o(e.allLanguagesAllowed)&&F(e.defaultLocales),e.isFtMap=e=>n(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&(null==e.watermark||ke(e.watermark))&&Q(e.openMode)&&(null==e.topicsApiEndpoint||u(e.topicsApiEndpoint))&&(null==e.description||u(e.description))&&(null==e.attachmentsApiEndpoint||u(e.attachmentsApiEndpoint))&&z(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&u(e.title)&&u(e.lastPublication)&&o(e.pbkConfidential)&&u(e.lastEdition)&&u(e.originId)&&(null==e.rightsApiEndpoint||u(e.rightsApiEndpoint))&&m(e.contentStyles)&&(null==e.originUrl||u(e.originUrl))&&u(e.fingerprint)&&u(e.readerUrl)&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtMapAttachment=e=>we(e)&&xe(e.file)&&(null==e.size||He(e.size))&&Be(e.externalLink)&&xe(e.name)&&xe(e.id)&&(null==e.mimeType||xe(e.mimeType))&&(null==e.viewerUrl||xe(e.viewerUrl)),e.isFtMapResource=e=>n(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=m,e.isFtMessageContext=e=>n(e)&&u(e.name)&&n(e.messages)&&Object.keys(e.messages).every((e=>u(e)))&&Object.values(e.messages).every((e=>u(e)))&&u(e.locale),e.isFtMetadata=I,e.isFtMetadataConfiguration=e=>n(e)&&Array.isArray(e.descriptors)&&e.descriptors.every((e=>L(e))),e.isFtMetadataDescriptor=L,e.isFtMetadataFilter=ce,e.isFtMetadataHomeLayout=e=>["CLASSIC","CUSTOM","DESIGNER"].includes(e),e.isFtMetadataPreferenceConfiguration=H,e.isFtMetadataSortRule=_,e.isFtMyLibraryColors=d,e.isFtMySearch=e=>n(e)&&D(e.searchRequest)&&d(e.color)&&o(e.alert)&&u(e.description)&&u(e.id)&&u(e.ownerId)&&u(e.title)&&u(e.creationDate),e.isFtMySearchRequest=D,e.isFtOpenMode=Q,e.isFtPageConfiguration=qe,e.isFtPageRequest=Z,e.isFtPaginatedToc=e=>we(e)&&Ye(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>Xe(e))),e.isFtPaginatedTocNode=Xe,e.isFtPaginationConfiguration=Ye,e.isFtPeriod=de,e.isFtPeriodFilter=ue,e.isFtPeriodFilterType=V,e.isFtPersonalBookCreation=e=>n(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&Array.isArray(e.nodes)&&e.nodes.every((e=>f(e)))&&u(e.description)&&u(e.title),e.isFtPersonalBookMetadataUpdate=y,e.isFtPersonalBookNodeCreation=f,e.isFtPersonalBookTopicLinkCreation=A,e.isFtPublicClusterSortCriterion=ee,e.isFtPublicationRating=M,e.isFtPublicationRatingSummary=k,e.isFtRagHistory=$e,e.isFtRagInput=e=>we(e)&&xe(e.profileId)&&(null==e.conversationId||xe(e.conversationId))&&xe(e.query)&&(null==e.messages||Array.isArray(e.messages)&&e.messages.every((e=>$e(e))))&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>ze(e)))),e.isFtRangeFilter=pe,e.isFtRatingCreation=e=>n(e)&&N(e.type)&&l(e.value),e.isFtRatingSummary=e=>n(e)&&(null==e.topics||B(e.topics))&&k(e.publication),e.isFtRatingType=N,e.isFtReaderConfiguration=e=>we(e)&&je(e.feedback)&&He(e.loadAfterLastVisibleTopic)&&xe(e.relativeTopicPivotMetadata)&&He(e.loadBeforeFirstVisibleTopic)&&xe(e.relativePivotMetadata),e.isFtReaderFeedbackConfiguration=je,e.isFtSearchFacet=Fe,e.isFtSearchFacetConf=Oe,e.isFtSearchFacetEntry=ve,e.isFtSearchLocale=O,e.isFtSearchLocales=e=>n(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>O(e))),e.isFtSearchPreferences=Ne,e.isFtSearchPreferencesConfiguration=e=>n(e)&&n(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>H(e))),e.isFtSearchPreset=e=>n(e)&&u(e.name)&&l(e.priority)&&(null==e.contentLocale||u(e.contentLocale))&&Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ce(e))),e.isFtSearchPrior=he,e.isFtSearchRequest=e=>n(e)&&(null==e.periodFilter||null==e.periodFilter||ue(e.periodFilter))&&u(e.query)&&Z(e.paging)&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>le(e))))&&Array.isArray(e.sort)&&e.sort.every((e=>Ue(e)))&&(null==e.virtualField||X(e.virtualField))&&Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ce(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>Oe(e)))&&(null==e.scope||be(e.scope))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>he(e))))&&(null==e.clusterSortCriterions||Array.isArray(e.clusterSortCriterions)&&e.clusterSortCriterions.every((e=>ee(e)))),e.isFtSearchResultCluster=ye,e.isFtSearchResultClusterEntry=fe,e.isFtSearchResultMap=me,e.isFtSearchResultTopic=Ee,e.isFtSearchResultType=ge,e.isFtSearchResultUnstructuredDocument=Ae,e.isFtSearchResults=e=>n(e)&&(null==e.spellcheck||Ie(e.spellcheck))&&Y(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>ye(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>Fe(e))),e.isFtSearchResultsPageInfo=Y,e.isFtSearchScope=be,e.isFtSearchSortCriterion=Ue,e.isFtSearchSortCriterionOrder=$,e.isFtSearchSortCriterionType=G,e.isFtSemanticSearchFilter=ze,e.isFtSemanticSearchRequest=e=>we(e)&&xe(e.query)&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>ze(e))))&&(null==e.nbResults||He(e.nbResults)),e.isFtSemanticSearchResponseItem=We,e.isFtSession=e=>n(e)&&(null==e.authenticationIdentifier||Pe(e.authenticationIdentifier))&&l(e.idleTimeoutInMillis)&&Me(e.profile)&&o(e.sessionAuthenticated)&&Ne(e.searchPreferences),e.isFtSpellcheck=Ie,e.isFtSuggestRequest=e=>n(e)&&u(e.input)&&(null==e.scope||be(e.scope))&&Array.isArray(e.sort)&&e.sort.every((e=>Ue(e)))&&(null==e.maxCount||l(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale))&&Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ce(e))),e.isFtSuggestResult=_e,e.isFtSuggestResults=e=>n(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>_e(e))),e.isFtTocNode=E,e.isFtTopic=e=>n(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&u(e.id)&&u(e.contentApiEndpoint)&&u(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicOrigin=T,e.isFtTopicOriginType=h,e.isFtTopicRating=w,e.isFtTopicResource=Ce,e.isFtTopicsRatingSummary=B,e.isFtTranslationInput=e=>we(e)&&xe(e.profileId)&&(null==e.format||Ge(e.format))&&xe(e.destinationLanguage)&&xe(e.content)&&(null==e.sourceLanguage||xe(e.sourceLanguage)),e.isFtUiLocale=v,e.isFtUnstructuredDocument=e=>n(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&u(e.openMode)&&(null==e.description||u(e.description))&&u(e.mimeType)&&(null==e.baseId||u(e.baseId))&&(null==e.clusterId||u(e.clusterId))&&u(e.contentApiEndpoint)&&u(e.title)&&(null==e.lastPublication||u(e.lastPublication))&&u(e.viewerUrl)&&u(e.lastEdition)&&u(e.filename)&&(null==e.originId||u(e.originId))&&u(e.rightsApiEndpoint)&&(null==e.originUrl||u(e.originUrl))&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtUserProfile=Me,e.isFtUserRole=De,e.isFtValueFilter=Re,e.isFtVirtualField=X,e.isFtWatermark=ke,e.isTranslationFormat=Ge,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(Ze.localStorage){let r={...t,metadata:et(t.metadata??{})};const a=tt(e),i=JSON.stringify(r);return Ze.localStorage.setItem(a,i),Ze.dispatchEvent(new StorageEvent("storage",{key:a,newValue:i,storageArea:Ze.localStorage,url:Ze.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=>Qe(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 r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a={exports:{}};!function(e,r){var a="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==t&&t,i=function(){function e(){this.fetch=!1,this.DOMException=a.DOMException}return e.prototype=a,new e}();!function(e){!function(r){var a=void 0!==e&&e||"undefined"!=typeof self&&self||void 0!==t&&t||{},i={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};if(i.arrayBuffer)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(e){return e&&s.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function u(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i.iterable&&(t[Symbol.iterator]=function(){return t}),t}function c(e){this.map={},e instanceof c?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function p(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function h(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function f(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:i.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():i.arrayBuffer&&i.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):i.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||n(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,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):i.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i.blob&&(this.blob=function(){var e=d(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(){if(this._bodyArrayBuffer){var e=d(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(i.blob)return this.blob().then(h);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,r,a,i,s=d(this);if(s)return s;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=p(t),a=/charset=([A-Za-z0-9_-]+)/.exec(e.type),i=a?a[1]:"utf-8",t.readAsText(e,i),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),a=0;a<t.length;a++)r[a]=String.fromCharCode(t[a]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i.formData&&(this.formData=function(){return this.text().then(E)}),this.json=function(){return this.text().then(JSON.parse)},this}c.prototype.append=function(e,t){e=o(e),t=l(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},c.prototype.delete=function(e){delete this.map[o(e)]},c.prototype.get=function(e){return e=o(e),this.has(e)?this.map[e]:null},c.prototype.has=function(e){return this.map.hasOwnProperty(o(e))},c.prototype.set=function(e,t){this.map[o(e)]=l(t)},c.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},c.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),u(e)},c.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),u(e)},c.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),u(e)},i.iterable&&(c.prototype[Symbol.iterator]=c.prototype.entries);var A=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,s=(t=t||{}).body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new c(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 c(t.headers)),this.method=(r=t.method||this.method||"GET",i=r.toUpperCase(),A.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in a)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),a=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(a),decodeURIComponent(i))}})),t}function T(e,t){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new c(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},f.call(m.prototype),f.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new c(this.headers),url:this.url})},T.error=function(){var e=new T(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var g=[301,302,303,307,308];T.redirect=function(e,t){if(-1===g.indexOf(t))throw new RangeError("Invalid status code");return new T(null,{status:t,headers:{location:e}})},r.DOMException=a.DOMException;try{new r.DOMException}catch(e){r.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},r.DOMException.prototype=Object.create(Error.prototype),r.DOMException.prototype.constructor=r.DOMException}function R(e,t){return new Promise((function(s,n){var u=new m(e,t);if(u.signal&&u.signal.aborted)return n(new r.DOMException("Aborted","AbortError"));var d=new XMLHttpRequest;function p(){d.abort()}if(d.onload=function(){var e,t,r={statusText:d.statusText,headers:(e=d.getAllResponseHeaders()||"",t=new c,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),a=r.shift().trim();if(a){var i=r.join(":").trim();try{t.append(a,i)}catch(e){console.warn("Response "+e.message)}}})),t)};0===u.url.indexOf("file://")&&(d.status<200||d.status>599)?r.status=200:r.status=d.status,r.url="responseURL"in d?d.responseURL:r.headers.get("X-Request-URL");var a="response"in d?d.response:d.responseText;setTimeout((function(){s(new T(a,r))}),0)},d.onerror=function(){setTimeout((function(){n(new TypeError("Network request failed"))}),0)},d.ontimeout=function(){setTimeout((function(){n(new TypeError("Network request timed out"))}),0)},d.onabort=function(){setTimeout((function(){n(new r.DOMException("Aborted","AbortError"))}),0)},d.open(u.method,function(e){try{return""===e&&a.location.href?a.location.href:e}catch(t){return e}}(u.url),!0),"include"===u.credentials?d.withCredentials=!0:"omit"===u.credentials&&(d.withCredentials=!1),"responseType"in d&&(i.blob?d.responseType="blob":i.arrayBuffer&&(d.responseType="arraybuffer")),t&&"object"==typeof t.headers&&!(t.headers instanceof c||a.Headers&&t.headers instanceof a.Headers)){var h=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){h.push(o(e)),d.setRequestHeader(e,l(t.headers[e]))})),u.headers.forEach((function(e,t){-1===h.indexOf(t)&&d.setRequestHeader(t,e)}))}else u.headers.forEach((function(e,t){d.setRequestHeader(t,e)}));u.signal&&(u.signal.addEventListener("abort",p),d.onreadystatechange=function(){4===d.readyState&&u.signal.removeEventListener("abort",p)}),d.send(void 0===u._bodyInit?null:u._bodyInit)}))}R.polyfill=!0,a.fetch||(a.fetch=R,a.Headers=c,a.Request=m,a.Response=T),r.Headers=c,r.Request=m,r.Response=T,r.fetch=R}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var s=a.fetch?a:i;(r=s.fetch).default=s.fetch,r.fetch=s.fetch,r.Headers=s.Headers,r.Request=s.Request,r.Response=s.Response,e.exports=r}(a,a.exports);var i=r(a.exports);class s{reader;decoder=new TextDecoder;partialChunk="";constructor(e){this.reader=e}async*read(){for(;;){const{done:e,value:t}=await this.reader.read();if(e)return void(yield*this.readRemainingChunks());yield*this.readChunksFromValue(t)}}*readRemainingChunks(){yield*this.parseLine(this.partialChunk)}*readChunksFromValue(e){const t=(this.partialChunk+this.decoder.decode(e)).split("\n");this.partialChunk=t.pop()??"";for(let e of t)yield*this.parseLine(e)}*parseLine(e){const[t,r]=e.split(/:(.*)/);"data"==t&&r.length>0&&(yield JSON.parse(r))}}const n=e=>"object"==typeof e&&null!=e,o=e=>"boolean"==typeof e,l=e=>"number"==typeof e,u=e=>"string"==typeof e;var c;e.FtMyLibraryColors=void 0,(c=e.FtMyLibraryColors||(e.FtMyLibraryColors={})).black="black",c.green="green",c.blue="blue",c.purple="purple",c.red="red",c.orange="orange",c.yellow="yellow";const d=e=>["black","green","blue","purple","red","orange","yellow"].includes(e);var p;e.FtTopicOriginType=void 0,(p=e.FtTopicOriginType||(e.FtTopicOriginType={})).OFFICIAL="OFFICIAL",p.PERSONAL="PERSONAL",p.SHARED="SHARED";const h=e=>["OFFICIAL","PERSONAL","SHARED"].includes(e),y=e=>n(e)&&Array.isArray(e.values)&&e.values.every((e=>Array.isArray(e)&&e.every((e=>u(e)))))&&u(e.key),f=e=>n(e)&&u(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>f(e)))&&(null==e.topicLink||A(e.topicLink))&&u(e.title)&&(null==e.htmlContent||u(e.htmlContent)),A=e=>n(e)&&u(e.tocId)&&u(e.contentId)&&u(e.mapId),m=e=>n(e)&&u(e.topicStylesheetUrl)&&u(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>u(e))),E=e=>n(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&(null==e.hasRating||o(e.hasRating))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>E(e)))&&(null==e.translatedTitle||null==e.translatedTitle||u(e.translatedTitle))&&(null==e.origin||T(e.origin))&&u(e.contentId)&&u(e.title),T=e=>n(e)&&u(e.mapTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>u(e)))&&u(e.tocId)&&u(e.contentId)&&u(e.mapId)&&h(e.type);var g;e.FtTopicContentTarget=void 0,(g=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",g.OFF_THE_GRID="OFF_THE_GRID",g.CONTENT_PACKAGER="CONTENT_PACKAGER",g.PAGES="PAGES",g.DESIGNED_READER="DESIGNED_READER";var R;e.FtExternalWebComponentContext=void 0,(R=e.FtExternalWebComponentContext||(e.FtExternalWebComponentContext={})).HOMEPAGE="HOMEPAGE",R.CUSTOM="CUSTOM",R.HEADER="HEADER",R.READER="READER",R.TOPIC_TEMPLATE="TOPIC_TEMPLATE",R.SEARCH="SEARCH",R.SEARCH_RESULT="SEARCH_RESULT";var b;e.FtMetadataHomeLayout=void 0,(b=e.FtMetadataHomeLayout||(e.FtMetadataHomeLayout={})).CLASSIC="CLASSIC",b.CUSTOM="CUSTOM",b.DESIGNER="DESIGNER";const S=e=>n(e)&&u(e.lang)&&u(e.region),F=e=>n(e)&&S(e.defaultUiLocale)&&S(e.defaultContentLocale)&&Array.isArray(e.defaultRegions)&&e.defaultRegions.every((e=>S(e))),O=e=>n(e)&&l(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),v=e=>n(e)&&u(e.displayName)&&u(e.languageTag)&&o(e.translated);var U;e.FtFacetType=void 0,(U=e.FtFacetType||(e.FtFacetType={})).AND="AND",U.OR="OR",U.MONOVALUED="MONOVALUED";const I=e=>n(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>u(e))))))&&u(e.label)&&u(e.key);var _;e.FtMetadataSortRule=void 0,(_=e.FtMetadataSortRule||(e.FtMetadataSortRule={})).NONE="NONE",_.ALPHABET="ALPHABET",_.VERSION="VERSION";const C=e=>["NONE","ALPHABET","VERSION"].includes(e),L=e=>n(e)&&o(e.date)&&C(e.sortRule)&&u(e.label)&&o(e.reverseSort)&&u(e.key),D=e=>n(e)&&(null==e.periodFilter||null==e.periodFilter||ue(e.periodFilter))&&u(e.query)&&(null==e.scope||be(e.scope))&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>oe(e))))&&Array.isArray(e.sort)&&e.sort.every((e=>Ue(e)))&&(null==e.virtualField||X(e.virtualField))&&(null==e.metadataFilters||Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ne(e))))&&(null==e.contentLocale||u(e.contentLocale));var P;e.FtRatingType=void 0,(P=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",P.LIKE="LIKE",P.DICHOTOMOUS="DICHOTOMOUS",P.NO_RATING="NO_RATING";const N=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),M=e=>n(e)&&u(e.date)&&N(e.type)&&l(e.value),k=e=>n(e)&&(null==e.rating||M(e.rating))&&N(e.type),w=e=>n(e)&&u(e.date)&&u(e.tocId)&&N(e.type)&&l(e.value),B=e=>n(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>w(e)))&&N(e.type),H=e=>n(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e)));var x;e.FtPeriodFilterType=void 0,(x=e.FtPeriodFilterType||(e.FtPeriodFilterType={})).LAST_WEEK="LAST_WEEK",x.LAST_MONTH="LAST_MONTH",x.LAST_QUARTER="LAST_QUARTER",x.LAST_YEAR="LAST_YEAR",x.CUSTOM="CUSTOM";const V=e=>["LAST_WEEK","LAST_MONTH","LAST_QUARTER","LAST_YEAR","CUSTOM"].includes(e);var j;e.FtSearchSortCriterionOrder=void 0,(j=e.FtSearchSortCriterionOrder||(e.FtSearchSortCriterionOrder={})).ASC="ASC",j.DESC="DESC";const $=e=>["ASC","DESC"].includes(e);var K;e.FtSearchSortCriterionType=void 0,(K=e.FtSearchSortCriterionType||(e.FtSearchSortCriterionType={})).ALPHA="ALPHA",K.NATURAL="NATURAL";const G=e=>["ALPHA","NATURAL"].includes(e);var q;e.FtVirtualField=void 0,(q=e.FtVirtualField||(e.FtVirtualField={})).EVERYWHERE="EVERYWHERE",q.TITLE_ONLY="TITLE_ONLY",q.NONE="NONE";const X=e=>["EVERYWHERE","TITLE_ONLY","NONE"].includes(e),Y=e=>n(e)&&l(e.totalResultsCount)&&o(e.isLastPage)&&l(e.currentPage)&&l(e.totalClustersCount);var W;e.FtEditorialType=void 0,(W=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",W.BOOK="BOOK",W.SHARED_BOOK="SHARED_BOOK";const z=e=>["ARTICLE","BOOK","SHARED_BOOK"].includes(e);var Q;e.FtOpenMode=void 0,(Q=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",Q.EXTERNAL="EXTERNAL";const J=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),Z=e=>n(e)&&(null==e.perPage||l(e.perPage))&&l(e.page),ee=e=>n(e)&&u(e.key);var te;e.FtCollectionDocumentType=void 0,(te=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",te.DOCUMENT="DOCUMENT",te.TOPIC="TOPIC",te.PERSONAL_BOOK="PERSONAL_BOOK",te.SHARED_BOOK="SHARED_BOOK";const re=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),ae=e=>n(e)&&se(e.type);var ie;e.FtDateFilterType=void 0,(ie=e.FtDateFilterType||(e.FtDateFilterType={})).LAST_WEEK="LAST_WEEK",ie.LAST_MONTH="LAST_MONTH",ie.LAST_QUARTER="LAST_QUARTER",ie.LAST_YEAR="LAST_YEAR";const se=e=>["LAST_WEEK","LAST_MONTH","LAST_QUARTER","LAST_YEAR"].includes(e),ne=e=>n(e)&&(null==e.valueFilter||Se(e.valueFilter))&&(null==e.rangeFilter||pe(e.rangeFilter))&&u(e.label)&&u(e.key)&&(null==e.dateFilter||ae(e.dateFilter)),oe=e=>n(e)&&o(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key),le=e=>n(e)&&o(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),ue=e=>n(e)&&(null==e.period||de(e.period))&&V(e.periodType)&&(null==e.key||u(e.key)),ce=e=>n(e)&&(null==e.valueFilter||Se(e.valueFilter))&&(null==e.rangeFilter||pe(e.rangeFilter))&&u(e.key)&&(null==e.dateFilter||ae(e.dateFilter)),de=e=>n(e)&&u(e.from)&&u(e.to),pe=e=>n(e)&&u(e.from)&&u(e.to),he=e=>n(e)&&l(e.weight)&&u(e.value)&&u(e.key),ye=e=>n(e)&&Array.isArray(e.entries)&&e.entries.every((e=>fe(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),fe=e=>n(e)&&Array.isArray(e.missingTerms)&&e.missingTerms.every((e=>u(e)))&&(null==e.document||Ae(e.document))&&(null==e.topic||Ee(e.topic))&&ge(e.type)&&(null==e.map||me(e.map)),Ae=e=>n(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&J(e.openMode)&&u(e.documentUrl)&&u(e.mimeType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.viewerUrl)&&u(e.contentUrl)&&u(e.filename)&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.documentId)&&u(e.lastEditionDate)&&u(e.htmlExcerpt),me=e=>n(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&(null==e.openMode||J(e.openMode))&&z(e.editorialType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.mapUrl)&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt),Ee=e=>n(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&J(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>_e(e)))&&u(e.title)&&u(e.mapTitle)&&u(e.topicUrl)&&u(e.contentUrl)&&u(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>u(e)))&&u(e.tocId)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt);var Te;e.FtSearchResultType=void 0,(Te=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",Te.DOCUMENT="DOCUMENT",Te.TOPIC="TOPIC";const ge=e=>["MAP","DOCUMENT","TOPIC"].includes(e);var Re;e.FtSearchScope=void 0,(Re=e.FtSearchScope||(e.FtSearchScope={})).DEFAULT="DEFAULT",Re.DOCUMENTS="DOCUMENTS",Re.ALL_TOPICS="ALL_TOPICS",Re.TOPICS_AND_UNSTRUCTURED_DOCUMENTS="TOPICS_AND_UNSTRUCTURED_DOCUMENTS";const be=e=>["DEFAULT","DOCUMENTS","ALL_TOPICS","TOPICS_AND_UNSTRUCTURED_DOCUMENTS"].includes(e),Se=e=>n(e)&&o(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e))),Fe=e=>n(e)&&o(e.hierarchical)&&u(e.label)&&o(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>ve(e))),Oe=e=>n(e)&&(null==e.maxDepth||l(e.maxDepth))&&u(e.id),ve=e=>n(e)&&l(e.totalResultsCount)&&o(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>ve(e)))&&u(e.label)&&u(e.value)&&o(e.selected),Ue=e=>n(e)&&G(e.type)&&u(e.key)&&$(e.order),Ie=e=>n(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),_e=e=>n(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),Ce=e=>n(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||z(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&ge(e.type)&&u(e.value);var Le;e.FtUserRole=void 0,(Le=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",Le.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",Le.HTML_EXPORT_USER="HTML_EXPORT_USER",Le.PDF_EXPORT_USER="PDF_EXPORT_USER",Le.SAVED_SEARCH_USER="SAVED_SEARCH_USER",Le.COLLECTION_USER="COLLECTION_USER",Le.OFFLINE_USER="OFFLINE_USER",Le.ANALYTICS_USER="ANALYTICS_USER",Le.BETA_USER="BETA_USER",Le.DEBUG_USER="DEBUG_USER",Le.PRINT_USER="PRINT_USER",Le.RATING_USER="RATING_USER",Le.FEEDBACK_USER="FEEDBACK_USER",Le.GENERATIVE_AI_USER="GENERATIVE_AI_USER",Le.CONTENT_PUBLISHER="CONTENT_PUBLISHER",Le.KHUB_ADMIN="KHUB_ADMIN",Le.USERS_ADMIN="USERS_ADMIN",Le.PORTAL_ADMIN="PORTAL_ADMIN",Le.ADMIN="ADMIN",Le.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","GENERATIVE_AI_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),Pe=e=>n(e)&&u(e.identifier)&&u(e.realm),Ne=e=>n(e)&&(null==e.defaultFilters||Array.isArray(e.defaultFilters)&&e.defaultFilters.every((e=>le(e))))&&Array.isArray(e.defaultMetadataFilters)&&e.defaultMetadataFilters.every((e=>ce(e))),Me=e=>n(e)&&(null==e.emailAddress||u(e.emailAddress))&&(null==e.displayName||u(e.displayName))&&Array.isArray(e.roles)&&e.roles.every((e=>De(e)))&&(null==e.userId||u(e.userId))&&Array.isArray(e.tags)&&e.tags.every((e=>u(e))),ke=e=>n(e)&&u(e.color)&&Array.isArray(e.text)&&e.text.every((e=>u(e)))&&l(e.opacity),we=e=>"object"==typeof e&&null!=e,Be=e=>"boolean"==typeof e,He=e=>"number"==typeof e,xe=e=>"string"==typeof e;var Ve;e.FtConfigurationHistoryEntryStatus=void 0,(Ve=e.FtConfigurationHistoryEntryStatus||(e.FtConfigurationHistoryEntryStatus={})).VALID="VALID",Ve.INVALID="INVALID";const je=e=>we(e)&&Be(e.mailsSentByFluidTopics)&&Be(e.mailsSentByFluidTopicsForUnauthenticatedUsers)&&Array.isArray(e.recipients)&&e.recipients.every((e=>xe(e)))&&Array.isArray(e.bodyMetadataIds)&&e.bodyMetadataIds.every((e=>xe(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>xe(e))),$e=e=>we(e)&&xe(e.role)&&xe(e.content);var Ke;e.TranslationFormat=void 0,(Ke=e.TranslationFormat||(e.TranslationFormat={})).TEXT="TEXT",Ke.HTML="HTML";const Ge=e=>["TEXT","HTML"].includes(e),qe=e=>we(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>Be(e))))&&Be(e.isVisible),Xe=e=>we(e)&&(null==e.prettyUrl||xe(e.prettyUrl))&&(null==e.hasRating||Be(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||xe(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>Xe(e)))&&(null==e.translatedTitle||xe(e.translatedTitle))&&(null==e.pageConfiguration||qe(e.pageConfiguration))&&(null==e.contentId||xe(e.contentId))&&(null==e.title||xe(e.title)),Ye=e=>we(e)&&Be(e.splitCurrentPageToc),We=e=>we(e)&&we(e.metadata)&&Object.keys(e.metadata).every((e=>xe(e)))&&Object.values(e.metadata).every((e=>Array.isArray(e)&&e.every((e=>xe(e)))))&&xe(e.excerpt)&&He(e.relevance),ze=e=>we(e)&&Array.isArray(e.values)&&e.values.every((e=>xe(e)))&&xe(e.key);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;const Qe="undefined"==typeof window?globalThis:window;class Je extends Error{method;endpoint;status;statusText;body;constructor(e,t,r,a,i){super(`${e} ${t} -> ${r} - ${a}: ${i}`),this.method=e,this.endpoint=t,this.status=r,this.statusText=a,this.body=i}}class Ze extends CustomEvent{constructor(e){super("ft-api-http-error",{detail:e})}}async function et(e,t,r){if(!r.ok){let a={method:e,endpoint:t,status:r.status,statusText:r.statusText,body:await r.text()};throw"function"==typeof Qe.dispatchEvent&&Qe.dispatchEvent(new Ze(a)),new Je(a.method,a.endpoint,a.status,a.statusText,a.body)}return r}function tt(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class rt{tenantBaseUrl;tenantBaseUrlNoTrailingSlash;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`})},semantic:{search:"api/khub/semantic/search",clusteredSearch:"api/khub/semantic/clustered-search"},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:"stylesheets/fonts.css",theme:"stylesheets/theme.css",content:{title:"stylesheets/content/title.css",topic:"stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader",metadata:"api/configuration/metadata"},locales:{ui:"api/locales/ui",get:"api/locales"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})},custom:{contextName:t=>({endpoint:`api/messages/${e}/custom/${t}`})}})},ai:{generate:"api/ai/generate",sendFeedback:"api/ai/rate",chat:"/api/ai/rag/chat",translate:"api/ai/translate",destinationLanguages:e=>({endpoint:`api/ai/translate/${e}/languages`})},assets:{highlightjs:"assets/scripts/highlightjs"}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=(e??Qe.fluidTopicsBaseUrl??Qe.__gwt_ft_moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",this.tenantBaseUrlNoTrailingSlash=this.tenantBaseUrl.replace(/\/$/,""),r&&void 0!==Qe.location&&Qe.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,r){const a=this.endpoints.khub.maps.mapId(e).info;return this.get(this.withTranslationParameters(a,t),r)}getTableOfContent(e,t){return this.get(this.endpoints.khub.maps.mapId(e).toc,t)}getPages(e,t,r){const a=this.endpoints.khub.maps.mapId(e).pages;return this.get(this.withTranslationParameters(a,r),t)}getTopic(e,t,r){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info,r)}getTopicHTMLContent(e,t,r,a,i){const s=this.endpoints.khub.maps.mapId(e).topics.contentId(t).content;return this.get(this.withTranslationParameters(s+(r?"?target="+r:""),i),a)}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.locales.ui)}getLocalesConfiguration(){return this.get(this.endpoints.locales.get)}getMetadataConfiguration(){return this.get(this.endpoints.configuration.metadata)}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,a){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:r,value:a})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,r,a){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:r,from:a})}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})}semanticSearch(e){return this.post(this.endpoints.khub.semantic.search,{request:e})}clusteredSemanticSearch(e){return this.post(this.endpoints.khub.semantic.clusteredSearch,{request:e})}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)}async*generate(e,t){const r=await this.fetch(this.endpoints.ai.generate,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:e,parameters:t}),credentials:null==this.authorization?"include":void 0});await et("POST",this.endpoints.ai.generate,r);const a=new s(r.body.getReader());yield*a.read()}async*chat(e){const t=await this.fetch(this.endpoints.ai.chat,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:null==this.authorization?"include":void 0});await et("POST",this.endpoints.ai.chat,t);const r=new s(t.body.getReader());yield*r.read()}translate(e){return this.post(this.endpoints.ai.translate,e)}getDestinationLanguages(e,t){return this.get(this.endpoints.ai.destinationLanguages(e).endpoint+(t?"?sourceLanguage="+t:""))}sendFeedback(e){return this.post(this.endpoints.ai.sendFeedback,e)}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.tenantBaseUrlNoTrailingSlash?e:this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const r=t;return await i(this.makeAbsolute(e),{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}upload(e,t,r,a=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((i,s)=>{let n=new XMLHttpRequest;n.onload=()=>{if(n.status>=200&&n.status<300){let e="application/json"===n.getResponseHeader("Content-Type")?JSON.parse(n.responseText):n.responseText;i(e)}else s(new Je("GET",t,n.status,n.statusText,n.responseText))},n.upload.onprogress=e=>a(e),n.open(e,this.makeAbsolute(t),!0),n.send(r)})):this.fetch(t,{method:e,body:r}).then((r=>et(e,t,r))).then(tt)}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((r=>et(e,t,r))).then(tt)}fetchRawData(e,t){return i(this.withVersion(e,t),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then((t=>et("GET",e,t))).then((e=>e.arrayBuffer()))}withVersion(e,t){let r=new URL(this.makeAbsolute(e));return t&&r.searchParams.append("v",t),r.toString()}withTranslationParameters(e,t){let r=new URL(this.makeAbsolute(e));return t&&(r.searchParams.append("translationProfileId",t.profileId),r.searchParams.append("translationDestinationLanguage",t.destinationLanguage),t.sourceLanguage&&r.searchParams.append("translationSourceLanguage",t.sourceLanguage.slice(0,2))),r.toString()}}e.FluidTopicsApi=rt,e.HttpError=Je,e.HttpErrorEvent=Ze,e.default=rt,e.isFtAuthenticatedSession=e=>n(e)&&Pe(e.authenticationIdentifier)&&Me(e.profile),e.isFtAuthenticationIdentifier=Pe,e.isFtBookmark=e=>n(e)&&u(e.mapTitle)&&d(e.color)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>u(e)))&&u(e.tocId)&&u(e.lastUpdate)&&u(e.readerUrl)&&u(e.mapId)&&u(e.id)&&u(e.title)&&u(e.creationDate),e.isFtClusteredSemanticSearchReply=e=>we(e)&&Array.isArray(e.documents)&&e.documents.every((e=>We(e)))&&Array.isArray(e.clusterId)&&e.clusterId.every((e=>xe(e))),e.isFtCollectionDocument=e=>n(e)&&o(e.deleted)&&(null==e.apiUrl||u(e.apiUrl))&&(null==e.portalUrl||u(e.portalUrl))&&u(e.id)&&u(e.title)&&re(e.type),e.isFtCollectionDocumentType=re,e.isFtConfigurationHistoryEntryStatus=e=>["VALID","INVALID"].includes(e),e.isFtCredentials=e=>n(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&o(e.rememberMe)&&u(e.login),e.isFtDateFilter=ae,e.isFtDateFilterType=se,e.isFtDefaultLocale=S,e.isFtDefaultLocales=F,e.isFtEditorialType=z,e.isFtExternalWebComponentContext=e=>["HOMEPAGE","CUSTOM","HEADER","READER","TOPIC_TEMPLATE","SEARCH","SEARCH_RESULT"].includes(e),e.isFtFacetType=e=>["AND","OR","MONOVALUED"].includes(e),e.isFtFeedbackCreation=e=>n(e)&&(null==e.from||u(e.from))&&u(e.message),e.isFtGenAIGenerateInput=e=>we(e)&&xe(e.profileId)&&(null==e.parameters||we(e.parameters)&&Object.keys(e.parameters).every((e=>xe(e)))&&Object.values(e.parameters).every((e=>xe(e)))),e.isFtGenAIRating=e=>we(e)&&He(e.rating)&&xe(e.comment)&&xe(e.queryId),e.isFtHttpErrorDetails=e=>n(e)&&u(e.endpoint)&&u(e.method)&&u(e.statusText)&&u(e.body)&&l(e.status),e.isFtLabeledMetadataFilter=ne,e.isFtLegacyLabeledMetadataFilter=oe,e.isFtLegacyMetadataFilter=le,e.isFtLocalesConfiguration=e=>n(e)&&Array.isArray(e.availableUiLocales)&&e.availableUiLocales.every((e=>v(e)))&&o(e.allLanguagesAllowed)&&F(e.defaultLocales),e.isFtMap=e=>n(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&(null==e.watermark||ke(e.watermark))&&J(e.openMode)&&(null==e.translatedTitle||null==e.translatedTitle||u(e.translatedTitle))&&(null==e.topicsApiEndpoint||u(e.topicsApiEndpoint))&&(null==e.description||u(e.description))&&(null==e.attachmentsApiEndpoint||u(e.attachmentsApiEndpoint))&&z(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&u(e.title)&&u(e.lastPublication)&&o(e.pbkConfidential)&&u(e.lastEdition)&&u(e.originId)&&(null==e.rightsApiEndpoint||u(e.rightsApiEndpoint))&&m(e.contentStyles)&&(null==e.originUrl||u(e.originUrl))&&u(e.fingerprint)&&u(e.readerUrl)&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtMapAttachment=e=>we(e)&&xe(e.file)&&(null==e.size||He(e.size))&&Be(e.externalLink)&&xe(e.name)&&xe(e.id)&&(null==e.mimeType||xe(e.mimeType))&&(null==e.viewerUrl||xe(e.viewerUrl)),e.isFtMapResource=e=>n(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=m,e.isFtMessageContext=e=>n(e)&&u(e.name)&&n(e.messages)&&Object.keys(e.messages).every((e=>u(e)))&&Object.values(e.messages).every((e=>u(e)))&&u(e.locale),e.isFtMetadata=I,e.isFtMetadataConfiguration=e=>n(e)&&Array.isArray(e.descriptors)&&e.descriptors.every((e=>L(e))),e.isFtMetadataDescriptor=L,e.isFtMetadataFilter=ce,e.isFtMetadataHomeLayout=e=>["CLASSIC","CUSTOM","DESIGNER"].includes(e),e.isFtMetadataPreferenceConfiguration=H,e.isFtMetadataSortRule=C,e.isFtMyLibraryColors=d,e.isFtMySearch=e=>n(e)&&D(e.searchRequest)&&d(e.color)&&o(e.alert)&&u(e.description)&&u(e.id)&&u(e.ownerId)&&u(e.title)&&u(e.creationDate),e.isFtMySearchRequest=D,e.isFtOpenMode=J,e.isFtPageConfiguration=qe,e.isFtPageRequest=Z,e.isFtPaginatedToc=e=>we(e)&&Ye(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>Xe(e))),e.isFtPaginatedTocNode=Xe,e.isFtPaginationConfiguration=Ye,e.isFtPeriod=de,e.isFtPeriodFilter=ue,e.isFtPeriodFilterType=V,e.isFtPersonalBookCreation=e=>n(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&Array.isArray(e.nodes)&&e.nodes.every((e=>f(e)))&&u(e.description)&&u(e.title),e.isFtPersonalBookMetadataUpdate=y,e.isFtPersonalBookNodeCreation=f,e.isFtPersonalBookTopicLinkCreation=A,e.isFtPublicClusterSortCriterion=ee,e.isFtPublicationRating=M,e.isFtPublicationRatingSummary=k,e.isFtRagHistory=$e,e.isFtRagInput=e=>we(e)&&xe(e.profileId)&&(null==e.conversationId||xe(e.conversationId))&&xe(e.query)&&(null==e.messages||Array.isArray(e.messages)&&e.messages.every((e=>$e(e))))&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>ze(e)))),e.isFtRangeFilter=pe,e.isFtRatingCreation=e=>n(e)&&N(e.type)&&l(e.value),e.isFtRatingSummary=e=>n(e)&&(null==e.topics||B(e.topics))&&k(e.publication),e.isFtRatingType=N,e.isFtReaderConfiguration=e=>we(e)&&je(e.feedback)&&He(e.loadAfterLastVisibleTopic)&&xe(e.relativeTopicPivotMetadata)&&He(e.loadBeforeFirstVisibleTopic)&&xe(e.relativePivotMetadata),e.isFtReaderFeedbackConfiguration=je,e.isFtSearchFacet=Fe,e.isFtSearchFacetConf=Oe,e.isFtSearchFacetEntry=ve,e.isFtSearchLocale=O,e.isFtSearchLocales=e=>n(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>O(e))),e.isFtSearchPreferences=Ne,e.isFtSearchPreferencesConfiguration=e=>n(e)&&n(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>H(e))),e.isFtSearchPreset=e=>n(e)&&u(e.name)&&l(e.priority)&&(null==e.contentLocale||u(e.contentLocale))&&Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ce(e))),e.isFtSearchPrior=he,e.isFtSearchRequest=e=>n(e)&&(null==e.periodFilter||null==e.periodFilter||ue(e.periodFilter))&&u(e.query)&&Z(e.paging)&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>le(e))))&&Array.isArray(e.sort)&&e.sort.every((e=>Ue(e)))&&(null==e.virtualField||X(e.virtualField))&&Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ce(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>Oe(e)))&&(null==e.scope||be(e.scope))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>he(e))))&&(null==e.clusterSortCriterions||Array.isArray(e.clusterSortCriterions)&&e.clusterSortCriterions.every((e=>ee(e)))),e.isFtSearchResultCluster=ye,e.isFtSearchResultClusterEntry=fe,e.isFtSearchResultMap=me,e.isFtSearchResultTopic=Ee,e.isFtSearchResultType=ge,e.isFtSearchResultUnstructuredDocument=Ae,e.isFtSearchResults=e=>n(e)&&(null==e.spellcheck||Ie(e.spellcheck))&&Y(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>ye(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>Fe(e))),e.isFtSearchResultsPageInfo=Y,e.isFtSearchScope=be,e.isFtSearchSortCriterion=Ue,e.isFtSearchSortCriterionOrder=$,e.isFtSearchSortCriterionType=G,e.isFtSemanticSearchFilter=ze,e.isFtSemanticSearchRequest=e=>we(e)&&xe(e.query)&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>ze(e))))&&(null==e.nbResults||He(e.nbResults)),e.isFtSemanticSearchResponseItem=We,e.isFtSession=e=>n(e)&&(null==e.authenticationIdentifier||Pe(e.authenticationIdentifier))&&l(e.idleTimeoutInMillis)&&Me(e.profile)&&o(e.sessionAuthenticated)&&Ne(e.searchPreferences),e.isFtSpellcheck=Ie,e.isFtSuggestRequest=e=>n(e)&&u(e.input)&&(null==e.scope||be(e.scope))&&Array.isArray(e.sort)&&e.sort.every((e=>Ue(e)))&&(null==e.maxCount||l(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale))&&Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ce(e))),e.isFtSuggestResult=Ce,e.isFtSuggestResults=e=>n(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>Ce(e))),e.isFtTocNode=E,e.isFtTopic=e=>n(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&u(e.id)&&u(e.contentApiEndpoint)&&u(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicOrigin=T,e.isFtTopicOriginType=h,e.isFtTopicRating=w,e.isFtTopicResource=_e,e.isFtTopicsRatingSummary=B,e.isFtTranslationInput=e=>we(e)&&xe(e.profileId)&&(null==e.format||Ge(e.format))&&xe(e.destinationLanguage)&&xe(e.content)&&(null==e.sourceLanguage||xe(e.sourceLanguage)),e.isFtTranslationLanguagesInput=e=>we(e)&&xe(e.profileId)&&(null==e.sourceLanguage||xe(e.sourceLanguage)),e.isFtTranslationLanguagesResponse=e=>we(e)&&xe(e.code)&&xe(e.label),e.isFtTranslationSettingsInput=e=>we(e)&&xe(e.profileId)&&xe(e.destinationLanguage)&&(null==e.sourceLanguage||xe(e.sourceLanguage)),e.isFtUiLocale=v,e.isFtUnstructuredDocument=e=>n(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>I(e)))&&u(e.openMode)&&(null==e.description||u(e.description))&&u(e.mimeType)&&(null==e.baseId||u(e.baseId))&&(null==e.clusterId||u(e.clusterId))&&u(e.contentApiEndpoint)&&u(e.title)&&(null==e.lastPublication||u(e.lastPublication))&&u(e.viewerUrl)&&u(e.lastEdition)&&u(e.filename)&&(null==e.originId||u(e.originId))&&u(e.rightsApiEndpoint)&&(null==e.originUrl||u(e.originUrl))&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtUserProfile=Me,e.isFtUserRole=De,e.isFtValueFilter=Se,e.isFtVirtualField=X,e.isFtWatermark=ke,e.isTranslationFormat=Ge,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=>!0))}}));
@@ -23,7 +23,7 @@ export class GenAIChunkReader {
23
23
  *readChunksFromValue(value) {
24
24
  const text = this.partialChunk + this.decoder.decode(value);
25
25
  const lines = text.split("\n");
26
- this.partialChunk = lines.pop();
26
+ this.partialChunk = lines.pop() ?? "";
27
27
  for (let line of lines) {
28
28
  yield* this.parseLine(line);
29
29
  }
@@ -1,5 +1,5 @@
1
1
  import { FtAuthenticatedSession, FtBookmark, FtCollectionDocument, FtHttpErrorDetails, FtLocalesConfiguration, FtMap, FtMapResource, FtMessageContext, FtMetadataConfiguration, FtMySearch, FtRatingSummary, FtRatingType, FtRatingTypeKeys, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSession, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUiLocale, FtUnstructuredDocument } from "./types/ft-common/public.js";
2
- import { FtClusteredSemanticSearchReply, FtGenAIRating, FtMapAttachment, FtPaginatedToc, FtRagInput, FtReaderConfiguration, FtSemanticSearchRequest, FtSemanticSearchResponseItem, FtTranslationInput } from "./types/ft-server/public.js";
2
+ import { FtClusteredSemanticSearchReply, FtGenAIRating, FtMapAttachment, FtPaginatedToc, FtRagInput, FtReaderConfiguration, FtSemanticSearchRequest, FtSemanticSearchResponseItem, FtTranslationInput, FtTranslationLanguagesResponse, FtTranslationSettingsInput } from "./types/ft-server/public.js";
3
3
  import { GenAIChunk } from "./helpers/GenAIChunkReader.js";
4
4
  export * from "./types/ft-common/public.js";
5
5
  export * from "./types/ft-server/public.js";
@@ -127,6 +127,9 @@ export declare class FluidTopicsApi {
127
127
  sendFeedback: string;
128
128
  chat: string;
129
129
  translate: string;
130
+ destinationLanguages: (profileId: string) => {
131
+ endpoint: string;
132
+ };
130
133
  };
131
134
  assets: {
132
135
  highlightjs: string;
@@ -143,11 +146,11 @@ export declare class FluidTopicsApi {
143
146
  logout(): Promise<void>;
144
147
  getCurrentSession(): Promise<FtSession>;
145
148
  getReaderConfiguration(): Promise<FtReaderConfiguration>;
146
- getMap(mapId: string, v?: string): Promise<FtMap>;
149
+ getMap(mapId: string, translationSettings?: FtTranslationSettingsInput, v?: string): Promise<FtMap>;
147
150
  getTableOfContent(mapId: string, v?: string): Promise<Array<FtTocNode>>;
148
- getPages(mapId: string, v?: string): Promise<FtPaginatedToc>;
151
+ getPages(mapId: string, v?: string, translationSettings?: FtTranslationSettingsInput): Promise<FtPaginatedToc>;
149
152
  getTopic(mapId: string, topicContentId: string, v?: string): Promise<FtTopic>;
150
- getTopicHTMLContent(mapId: string, topicContentId: string, target?: FtTopicContentTarget | FtTopicContentTargetKeys, v?: string): Promise<string>;
153
+ getTopicHTMLContent(mapId: string, topicContentId: string, target?: FtTopicContentTarget | FtTopicContentTargetKeys, v?: string, translationSettings?: FtTranslationSettingsInput): Promise<string>;
151
154
  getMapAttachments(mapId: string, v?: string): Promise<Array<FtMapAttachment>>;
152
155
  getMapAttachmentContent(mapId: string, attachmentId: string, v?: string): Promise<ArrayBuffer>;
153
156
  getMapResources(mapId: string, v?: string): Promise<Array<FtMapResource>>;
@@ -182,6 +185,7 @@ export declare class FluidTopicsApi {
182
185
  generate(profileId: string, parameters?: Record<string, string>): AsyncGenerator<GenAIChunk>;
183
186
  chat(input: FtRagInput): AsyncGenerator<GenAIChunk>;
184
187
  translate(input: FtTranslationInput): Promise<string>;
188
+ getDestinationLanguages(profileId: string, sourceLanguage?: string): Promise<FtTranslationLanguagesResponse[]>;
185
189
  sendFeedback(rating: FtGenAIRating): Promise<unknown>;
186
190
  get<T>(endpoint: string, v?: string): Promise<T>;
187
191
  post<T>(endpoint: string, data?: any): Promise<T>;
@@ -193,5 +197,6 @@ export declare class FluidTopicsApi {
193
197
  private makeRequest;
194
198
  private fetchRawData;
195
199
  withVersion(endpoint: string, v: string | undefined): string;
200
+ withTranslationParameters(endpoint: string, translationSettings?: FtTranslationSettingsInput): string;
196
201
  }
197
202
  export default FluidTopicsApi;
package/dist/mjs/index.js CHANGED
@@ -158,6 +158,9 @@ export class FluidTopicsApi {
158
158
  sendFeedback: `api/ai/rate`,
159
159
  chat: `/api/ai/rag/chat`,
160
160
  translate: `api/ai/translate`,
161
+ destinationLanguages: (profileId) => ({
162
+ endpoint: `api/ai/translate/${profileId}/languages`
163
+ })
161
164
  },
162
165
  assets: {
163
166
  highlightjs: `assets/scripts/highlightjs`,
@@ -219,20 +222,23 @@ export class FluidTopicsApi {
219
222
  getReaderConfiguration() {
220
223
  return this.get(this.endpoints.configuration.reader);
221
224
  }
222
- getMap(mapId, v) {
223
- return this.get(this.endpoints.khub.maps.mapId(mapId).info, v);
225
+ getMap(mapId, translationSettings, v) {
226
+ const endpoint = this.endpoints.khub.maps.mapId(mapId).info;
227
+ return this.get(this.withTranslationParameters(endpoint, translationSettings), v);
224
228
  }
225
229
  getTableOfContent(mapId, v) {
226
230
  return this.get(this.endpoints.khub.maps.mapId(mapId).toc, v);
227
231
  }
228
- getPages(mapId, v) {
229
- return this.get(this.endpoints.khub.maps.mapId(mapId).pages, v);
232
+ getPages(mapId, v, translationSettings) {
233
+ const endpoint = this.endpoints.khub.maps.mapId(mapId).pages;
234
+ return this.get(this.withTranslationParameters(endpoint, translationSettings), v);
230
235
  }
231
236
  getTopic(mapId, topicContentId, v) {
232
237
  return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).info, v);
233
238
  }
234
- getTopicHTMLContent(mapId, topicContentId, target, v) {
235
- return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).content + (target ? "?target=" + target : ""), v);
239
+ getTopicHTMLContent(mapId, topicContentId, target, v, translationSettings) {
240
+ const endpoint = this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).content;
241
+ return this.get(this.withTranslationParameters(endpoint + (target ? "?target=" + target : ""), translationSettings), v);
236
242
  }
237
243
  getMapAttachments(mapId, v) {
238
244
  return this.get(this.endpoints.khub.maps.mapId(mapId).attachments.list, v);
@@ -358,6 +364,10 @@ export class FluidTopicsApi {
358
364
  translate(input) {
359
365
  return this.post(this.endpoints.ai.translate, input);
360
366
  }
367
+ getDestinationLanguages(profileId, sourceLanguage) {
368
+ return this.get(this.endpoints.ai.destinationLanguages(profileId).endpoint
369
+ + (sourceLanguage ? "?sourceLanguage=" + sourceLanguage : ""));
370
+ }
361
371
  sendFeedback(rating) {
362
372
  return this.post(this.endpoints.ai.sendFeedback, rating);
363
373
  }
@@ -439,5 +449,16 @@ export class FluidTopicsApi {
439
449
  }
440
450
  return url.toString();
441
451
  }
452
+ withTranslationParameters(endpoint, translationSettings) {
453
+ let url = new URL(this.makeAbsolute(endpoint));
454
+ if (translationSettings) {
455
+ url.searchParams.append("translationProfileId", translationSettings.profileId);
456
+ url.searchParams.append("translationDestinationLanguage", translationSettings.destinationLanguage);
457
+ if (translationSettings.sourceLanguage) {
458
+ url.searchParams.append("translationSourceLanguage", translationSettings.sourceLanguage.slice(0, 2)); // FIX THIS!!
459
+ }
460
+ }
461
+ return url.toString();
462
+ }
442
463
  }
443
464
  export default FluidTopicsApi;
@@ -1,9 +1,3 @@
1
- import { FtMetadataPreferenceConfiguration, FtSearchPreferencesConfiguration } from "../types/ft-common/public.js";
2
- export declare function setUnauthenticatedUserSearchPreferences(tenantBaseUrl: string, input: FtSearchPreferencesConfiguration): {
3
- metadata: Record<string, FtMetadataPreferenceConfiguration>;
4
- };
5
- export declare function getUnauthenticatedUserSearchPreferences(tenantBaseUrl: string): FtSearchPreferencesConfiguration;
6
1
  export type HandlerRegistration = {
7
2
  removeHandler: () => void;
8
3
  };
9
- export declare function addUnauthenticatedUserSearchPreferencesChangeHandler(tenantBaseUrl: string, handler: (newValue: FtSearchPreferencesConfiguration) => void): HandlerRegistration;
@@ -1,61 +1,39 @@
1
1
  const wnd = (typeof window === "undefined" ? globalThis : window);
2
- function normalizeMetadataPreferences(metadata) {
3
- let normalized = {};
4
- for (let key in metadata) {
5
- let values = metadata[key];
6
- if (typeof values !== "object" || Array.isArray(values)) {
7
- values = { prior: values };
8
- }
9
- for (let property of ["prior", "filter"]) {
10
- values[property] = Array.isArray(values[property]) ? values[property] : [values[property]];
11
- values[property] = values[property]
12
- .map(v => v != null ? "" + v : "")
13
- .filter(v => v !== "");
14
- }
15
- normalized[key] = values;
16
- }
17
- return normalized;
18
- }
2
+ // function normalizeMetadataPreferences(metadata: any): Record<string, FtMetadataPreferenceConfiguration> {
3
+ // let normalized = {}
4
+ // for (let key in metadata) {
5
+ // let values = metadata[key]
6
+ // if (typeof values !== "object" || Array.isArray(values)) {
7
+ // values = {prior: values}
8
+ // }
9
+ // for (let property of ["prior", "filter"]) {
10
+ // values[property] = Array.isArray(values[property]) ? values[property] : [values[property]]
11
+ // values[property] = values[property]
12
+ // .map((v: string) => v != null ? "" + v : "")
13
+ // .filter((v: string) => v !== "")
14
+ // }
15
+ // normalized[key] = values
16
+ // }
17
+ // return normalized
18
+ // }
19
19
  function getStorageKey(tenantBaseUrl) {
20
20
  return `${tenantBaseUrl}-FluidTopicsUnauthenticatedUserSearchPreferences`;
21
21
  }
22
- export function setUnauthenticatedUserSearchPreferences(tenantBaseUrl, input) {
23
- if (wnd.localStorage) {
24
- let preferences = {
25
- ...input,
26
- metadata: normalizeMetadataPreferences(input.metadata ?? {})
27
- };
28
- const key = getStorageKey(tenantBaseUrl);
29
- const newValue = JSON.stringify(preferences);
30
- wnd.localStorage.setItem(key, newValue);
31
- wnd.dispatchEvent(new StorageEvent("storage", {
32
- key,
33
- newValue,
34
- storageArea: wnd.localStorage,
35
- url: wnd.location.href
36
- }));
37
- return preferences;
38
- }
39
- console.error("Cannot set unauthenticated preferences: local storage is unavailable.");
40
- }
41
- export function getUnauthenticatedUserSearchPreferences(tenantBaseUrl) {
42
- if (wnd.localStorage) {
43
- return JSON.parse(wnd.localStorage.getItem(getStorageKey(tenantBaseUrl)) ?? "{}");
44
- }
45
- console.error("Cannot get unauthenticated preferences: local storage is unavailable.");
46
- }
47
- export function addUnauthenticatedUserSearchPreferencesChangeHandler(tenantBaseUrl, handler) {
48
- if (wnd.localStorage) {
49
- const key = getStorageKey(tenantBaseUrl);
50
- const eventListener = (event) => {
51
- if (event.storageArea === wnd.localStorage && event.key === key) {
52
- handler(JSON.parse(event.newValue ?? "{}"));
53
- }
54
- };
55
- wnd.addEventListener("storage", eventListener);
56
- return {
57
- removeHandler: () => wnd.removeEventListener("storage", eventListener)
58
- };
59
- }
60
- console.error("Cannot handle unauthenticated preferences: local storage is unavailable.");
61
- }
22
+ export {};
23
+ // export function addUnauthenticatedUserSearchPreferencesChangeHandler(tenantBaseUrl: string,
24
+ // handler: (newValue: FtSearchPreferencesConfiguration) => void): HandlerRegistration {
25
+ // if (wnd.localStorage) {
26
+ // const key = getStorageKey(tenantBaseUrl)
27
+ // const eventListener = (event: StorageEvent) => {
28
+ // if (event.storageArea === wnd.localStorage && event.key === key) {
29
+ // handler(JSON.parse(event.newValue ?? "{}"))
30
+ // }
31
+ // }
32
+ // wnd.addEventListener("storage", eventListener)
33
+ // return {
34
+ // removeHandler: () => wnd.removeEventListener("storage", eventListener)
35
+ // }
36
+ // }
37
+ // console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")
38
+ // return undefined
39
+ // }
@@ -8,7 +8,8 @@ const rolesInheritance = {
8
8
  [FtUserRole.DEVELOPER]: [FtUserRole.BETA_USER, FtUserRole.DEBUG_USER],
9
9
  };
10
10
  function roleMatches(actual, expected) {
11
- return actual === expected || (rolesInheritance[actual] ?? []).some((inherited) => roleMatches(inherited, expected));
11
+ return true;
12
+ // return actual === expected || (rolesInheritance[actual] ?? []).some((inherited: FtUserRole | FtUserRoleKeys) => roleMatches(inherited, expected))
12
13
  }
13
14
  export function userHasRole(sessionOrProfileOrRoles, expectedRole) {
14
15
  if (sessionOrProfileOrRoles == null) {
@@ -85,6 +85,7 @@ export interface FtMap {
85
85
  metadata: Array<FtMetadata>;
86
86
  watermark?: FtWatermark;
87
87
  openMode: FtOpenModeKeys;
88
+ translatedTitle?: string;
88
89
  topicsApiEndpoint?: string;
89
90
  description?: string;
90
91
  attachmentsApiEndpoint?: string;
@@ -117,6 +118,7 @@ export interface FtTocNode {
117
118
  hasRating?: boolean;
118
119
  tocId: string;
119
120
  children: Array<FtTocNode>;
121
+ translatedTitle?: string;
120
122
  origin?: FtTopicOrigin;
121
123
  contentId: string;
122
124
  title: string;
@@ -102,6 +102,7 @@ export const isFtMap = (o) => {
102
102
  && o.metadata.every((v) => isFtMetadata(v))))
103
103
  && (o.watermark == null || isFtWatermark(o.watermark))
104
104
  && (isFtOpenMode(o.openMode))
105
+ && (o.translatedTitle == null || o.translatedTitle == null || isString(o.translatedTitle))
105
106
  && (o.topicsApiEndpoint == null || isString(o.topicsApiEndpoint))
106
107
  && (o.description == null || isString(o.description))
107
108
  && (o.attachmentsApiEndpoint == null || isString(o.attachmentsApiEndpoint))
@@ -136,6 +137,7 @@ export const isFtTocNode = (o) => {
136
137
  && (isString(o.tocId))
137
138
  && ((Array.isArray(o.children)
138
139
  && o.children.every((v) => isFtTocNode(v))))
140
+ && (o.translatedTitle == null || o.translatedTitle == null || isString(o.translatedTitle))
139
141
  && (o.origin == null || isFtTopicOrigin(o.origin))
140
142
  && (isString(o.contentId))
141
143
  && (isString(o.title));
@@ -58,6 +58,22 @@ export interface FtTranslationInput {
58
58
  sourceLanguage?: string;
59
59
  }
60
60
  export declare const isFtTranslationInput: (o: any) => o is FtTranslationInput;
61
+ export interface FtTranslationLanguagesInput {
62
+ profileId: string;
63
+ sourceLanguage?: string;
64
+ }
65
+ export declare const isFtTranslationLanguagesInput: (o: any) => o is FtTranslationLanguagesInput;
66
+ export interface FtTranslationSettingsInput {
67
+ profileId: string;
68
+ destinationLanguage: string;
69
+ sourceLanguage?: string;
70
+ }
71
+ export declare const isFtTranslationSettingsInput: (o: any) => o is FtTranslationSettingsInput;
72
+ export interface FtTranslationLanguagesResponse {
73
+ code: string;
74
+ label: string;
75
+ }
76
+ export declare const isFtTranslationLanguagesResponse: (o: any) => o is FtTranslationLanguagesResponse;
61
77
  export interface FtMapAttachment {
62
78
  file: string;
63
79
  size?: number;
@@ -84,6 +100,7 @@ export interface FtPaginatedTocNode {
84
100
  pageToc?: Array<any>;
85
101
  tocId?: string;
86
102
  children: Array<FtPaginatedTocNode>;
103
+ translatedTitle?: string;
87
104
  pageConfiguration?: FtPageConfiguration;
88
105
  origin?: any;
89
106
  contentId?: string;
@@ -74,6 +74,22 @@ export const isFtTranslationInput = (o) => {
74
74
  && (isString(o.content))
75
75
  && (o.sourceLanguage == null || isString(o.sourceLanguage));
76
76
  };
77
+ export const isFtTranslationLanguagesInput = (o) => {
78
+ return isObject(o)
79
+ && (isString(o.profileId))
80
+ && (o.sourceLanguage == null || isString(o.sourceLanguage));
81
+ };
82
+ export const isFtTranslationSettingsInput = (o) => {
83
+ return isObject(o)
84
+ && (isString(o.profileId))
85
+ && (isString(o.destinationLanguage))
86
+ && (o.sourceLanguage == null || isString(o.sourceLanguage));
87
+ };
88
+ export const isFtTranslationLanguagesResponse = (o) => {
89
+ return isObject(o)
90
+ && (isString(o.code))
91
+ && (isString(o.label));
92
+ };
77
93
  export const isFtMapAttachment = (o) => {
78
94
  return isObject(o)
79
95
  && (isString(o.file))
@@ -104,6 +120,7 @@ export const isFtPaginatedTocNode = (o) => {
104
120
  && (o.tocId == null || isString(o.tocId))
105
121
  && ((Array.isArray(o.children)
106
122
  && o.children.every((v) => isFtPaginatedTocNode(v))))
123
+ && (o.translatedTitle == null || isString(o.translatedTitle))
107
124
  && (o.pageConfiguration == null || isFtPageConfiguration(o.pageConfiguration))
108
125
  && (o.contentId == null || isString(o.contentId))
109
126
  && (o.title == null || isString(o.title));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/public-api",
3
- "version": "1.0.81",
3
+ "version": "1.0.83-alpha",
4
4
  "description": "Fluid Topics Public API",
5
5
  "author": "Fluid Topics dev team <opensource@antidot.net>",
6
6
  "license": "LGPL-3.0-only",