@fluid-topics/ft-search-context 1.1.49 → 1.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- !function(t,i,s,e){const n=s.css`
2
- `,r={setRequest:(t,i)=>{t.request=i.payload},setRequestQuery:(t,i)=>{t.request.query=i.payload},setRequestContentLocale:(t,i)=>{t.request.contentLocale=i.payload},setPageSize:(t,i)=>{t.request.paging.perPage=i.payload},setPageNumber:(t,i)=>{t.request.paging.page=i.payload},setRequestSort:(t,i)=>{t.request.sort=i.payload},setRequestFilters:(t,i)=>{t.request.filters=i.payload},setRequestFacets:(t,i)=>{t.request.facets=i.payload},setRequestVirtualField:(t,i)=>{t.request.virtualField=i.payload},setRequestScope:(t,i)=>{t.request.scope=i.payload},setResults:(t,i)=>{t.results=i.payload},setFacets:(t,i)=>{t.facets=i.payload},setSpellcheck:(t,i)=>{t.spellcheck=i.payload},setLocales:(t,i)=>{t.locales=i.payload},setPaging:(t,i)=>{t.paging=i.payload},setLiveQuery:(t,i)=>{t.liveQuery=i.payload},setSuggestResults:(t,i)=>{t.suggestResults=i.payload}};var o,a,h,c,u,l,d,f,v,w,y,E,p,S,b,m,A,g;!function(t){!function(i){var s={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(s.arrayBuffer)var e=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(t){return t&&e.indexOf(Object.prototype.toString.call(t))>-1};function r(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var i={next:function(){var i=t.shift();return{done:void 0===i,value:i}}};return s.iterable&&(i[Symbol.iterator]=function(){return i}),i}function h(t){this.map={},t instanceof h?t.forEach((function(t,i){this.append(i,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(i){this.append(i,t[i])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise((function(i,s){t.onload=function(){i(t.result)},t.onerror=function(){s(t.error)}}))}function l(t){var i=new FileReader,s=u(i);return i.readAsArrayBuffer(t),s}function d(t){if(t.slice)return t.slice(0);var i=new Uint8Array(t.byteLength);return i.set(new Uint8Array(t)),i.buffer}function f(){return this.bodyUsed=!1,this._initBody=function(t){var i;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:s.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:s.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:s.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s.arrayBuffer&&s.blob&&((i=t)&&DataView.prototype.isPrototypeOf(i))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||n(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):s.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s.blob&&(this.blob=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var t,i,s,e=c(this);if(e)return e;if(this._bodyBlob)return t=this._bodyBlob,i=new FileReader,s=u(i),i.readAsText(t),s;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var i=new Uint8Array(t),s=new Array(i.length),e=0;e<i.length;e++)s[e]=String.fromCharCode(i[e]);return s.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,i){t=r(t),i=o(i);var s=this.map[t];this.map[t]=s?s+", "+i:i},h.prototype.delete=function(t){delete this.map[r(t)]},h.prototype.get=function(t){return t=r(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(r(t))},h.prototype.set=function(t,i){this.map[r(t)]=o(i)},h.prototype.forEach=function(t,i){for(var s in this.map)this.map.hasOwnProperty(s)&&t.call(i,this.map[s],s,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(i,s){t.push(s)})),a(t)},h.prototype.values=function(){var t=[];return this.forEach((function(i){t.push(i)})),a(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(i,s){t.push([s,i])})),a(t)},s.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,i){var s,e,n=(i=i||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,i.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=i.credentials||this.credentials||"same-origin",!i.headers&&this.headers||(this.headers=new h(i.headers)),this.method=(s=i.method||this.method||"GET",e=s.toUpperCase(),v.indexOf(e)>-1?e:s),this.mode=i.mode||this.mode||null,this.signal=i.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function y(t){var i=new FormData;return t.trim().split("&").forEach((function(t){if(t){var s=t.split("="),e=s.shift().replace(/\+/g," "),n=s.join("=").replace(/\+/g," ");i.append(decodeURIComponent(e),decodeURIComponent(n))}})),i}function E(t,i){i||(i={}),this.type="default",this.status=void 0===i.status?200:i.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in i?i.statusText:"OK",this.headers=new h(i.headers),this.url=i.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},f.call(w.prototype),f.call(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},E.error=function(){var t=new E(null,{status:0,statusText:""});return t.type="error",t};var p=[301,302,303,307,308];E.redirect=function(t,i){if(-1===p.indexOf(i))throw new RangeError("Invalid status code");return new E(null,{status:i,headers:{location:t}})},i.DOMException=t.DOMException;try{new i.DOMException}catch(t){i.DOMException=function(t,i){this.message=t,this.name=i;var s=Error(t);this.stack=s.stack},i.DOMException.prototype=Object.create(Error.prototype),i.DOMException.prototype.constructor=i.DOMException}function S(t,e){return new Promise((function(n,r){var o=new w(t,e);if(o.signal&&o.signal.aborted)return r(new i.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var t,i,s={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",i=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var s=t.split(":"),e=s.shift().trim();if(e){var n=s.join(":").trim();i.append(e,n)}})),i)};s.url="responseURL"in a?a.responseURL:s.headers.get("X-Request-URL");var e="response"in a?a.response:a.responseText;n(new E(e,s))},a.onerror=function(){r(new TypeError("Network request failed"))},a.ontimeout=function(){r(new TypeError("Network request failed"))},a.onabort=function(){r(new i.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&s.blob&&(a.responseType="blob"),o.headers.forEach((function(t,i){a.setRequestHeader(i,t)})),o.signal&&(o.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",c)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}S.polyfill=!0,t.fetch||(t.fetch=S,t.Headers=h,t.Request=w,t.Response=E),i.Headers=h,i.Request=w,i.Response=E,i.fetch=S,Object.defineProperty(i,"t",{value:!0})}({})}("undefined"!=typeof self?self:void 0),function(t){t.black="black",t.green="green",t.blue="blue",t.purple="purple",t.red="red",t.orange="orange",t.yellow="yellow"}(o||(o={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(a||(a={})),function(t){t.THIRD_PARTY="THIRD_PARTY",t.OFF_THE_GRID="OFF_THE_GRID",t.CONTENT_PACKAGER="CONTENT_PACKAGER",t.PAGES="PAGES",t.DESIGNED_READER="DESIGNED_READER"}(h||(h={})),function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"}(c||(c={})),function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"}(u||(u={})),function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"}(l||(l={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(d||(d={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(f||(f={})),function(t){t.ASC="ASC",t.DESC="DESC"}(v||(v={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(w||(w={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(y||(y={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(E||(E={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(p||(p={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(S||(S={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(b||(b={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS"}(m||(m={})),function(t){t.PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",t.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",t.HTML_EXPORT_USER="HTML_EXPORT_USER",t.PDF_EXPORT_USER="PDF_EXPORT_USER",t.SAVED_SEARCH_USER="SAVED_SEARCH_USER",t.COLLECTION_USER="COLLECTION_USER",t.OFFLINE_USER="OFFLINE_USER",t.ANALYTICS_USER="ANALYTICS_USER",t.BETA_USER="BETA_USER",t.DEBUG_USER="DEBUG_USER",t.PRINT_USER="PRINT_USER",t.RATING_USER="RATING_USER",t.FEEDBACK_USER="FEEDBACK_USER",t.GENERATIVE_AI_USER="GENERATIVE_AI_USER",t.CONTENT_PUBLISHER="CONTENT_PUBLISHER",t.KHUB_ADMIN="KHUB_ADMIN",t.USERS_ADMIN="USERS_ADMIN",t.PORTAL_ADMIN="PORTAL_ADMIN",t.ADMIN="ADMIN",t.DEVELOPER="DEVELOPER"}(A||(A={})),function(t){t.VALID="VALID",t.INVALID="INVALID"}(g||(g={})),A.PERSONAL_BOOK_SHARE_USER,A.PERSONAL_BOOK_USER,A.HTML_EXPORT_USER,A.PERSONAL_BOOK_USER,A.PDF_EXPORT_USER,A.PERSONAL_BOOK_USER,A.KHUB_ADMIN,A.CONTENT_PUBLISHER,A.ADMIN,A.KHUB_ADMIN,A.USERS_ADMIN,A.PORTAL_ADMIN,A.DEVELOPER,A.BETA_USER,A.DEBUG_USER;const R=s.css`
3
- `,T=i.FtReduxStore.get({name:"ft-app-info",reducers:{},initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0,openExternalDocumentInNewTab:!1}});class O{static build(t){const{baseUrl:i,apiIntegrationIdentifier:s}=T.getState(),e=null!=t?t:s;if(i&&e&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(i,e,!0)}static get(t){var i;return null!=t?O.build(t):null!==(i=O.API)&&void 0!==i?i:O.API=O.build()}static await(t){return new Promise((i=>{let s=O.get(t);if(s)i(s);else{const e=T.subscribe((()=>{s=O.get(t),s&&(e(),i(s))}))}}))}}class I{constructor(t=!0,s){var e;this.overrideApi=s;let n=this.constructor;n.commonCache=null!==(e=n.commonCache)&&void 0!==e?e:new i.CacheRegistry,this.cache=t?n.commonCache:new i.CacheRegistry}get api(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:O.get()}get awaitApi(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:O.await()}clearCache(){this.cache.clearAll()}}var C;const U=Symbol("clearAfterUnitTest");class L extends I{constructor(t){super(),this.messageContextProvider=t,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[C]=()=>{this.defaultMessages={},this.cache=new i.CacheRegistry,this.listeners={}},this.currentUiLocale=T.getState().uiLocale,T.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=T.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const i=t.name.toLowerCase();this.cache.setFinal(i,t),this.notify(i)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,s){var e;if(t=t.toLowerCase(),Object.keys(s).length>0){const n={...null!==(e=this.defaultMessages[t])&&void 0!==e?e:{},...s};i.deepEqual(this.defaultMessages[t],n)||(this.defaultMessages[t]=n,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,s,...e){var n,r,o;t=t.toLowerCase(),this.fetchContext(t);const a=null!==(r=null===(n=this.cache.getNow(t))||void 0===n?void 0:n.messages)&&void 0!==r?r:{};return new i.ParametrizedLabelResolver(null!==(o=this.defaultMessages[t])&&void 0!==o?o:{},a).resolve(s,...e)}async fetchContext(t){if(!this.cache.has(t))try{await this.cache.get(t,(()=>this.messageContextProvider(this.currentUiLocale,t))),await this.notify(t)}catch(t){console.error(t)}}subscribe(t,i){var s;return t=t.toLowerCase(),this.listeners[t]=null!==(s=this.listeners[t])&&void 0!==s?s:new Set,this.listeners[t].add(i),()=>{var s;return null===(s=this.listeners[t])||void 0===s?void 0:s.delete(i)}}async notifyAll(){await Promise.all(Object.keys(this.listeners).map((t=>this.notify(t))))}async notify(t){null!=this.listeners[t]&&await Promise.all([...this.listeners[t].values()].map((t=>i.delay(0).then((()=>t())).catch((()=>null)))))}}C=U,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new class extends L{constructor(){super((async(t,i)=>(await this.awaitApi).getFluidTopicsMessageContext(t,i)))}}),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new class extends L{constructor(){super((async(t,i)=>(await this.awaitApi).getCustomMessageContext(t,i)))}});const D=window.FluidTopicsI18nService;var N=function(t,i,s,e){for(var n,r=arguments.length,o=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(i,s,o):n(i,s))||o);return r>3&&o&&Object.defineProperty(i,s,o),o};class P extends i.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>O.get(),this.cache=new i.CacheRegistry,this.cleanSessionDebouncer=new i.Debouncer}render(){return s.html`
1
+ !function(t,s,i,e){const n=i.css`
2
+ `,r={setRequest:(t,s)=>{t.request=s.payload},setRequestQuery:(t,s)=>{t.request.query=s.payload},setRequestContentLocale:(t,s)=>{t.request.contentLocale=s.payload},setPageSize:(t,s)=>{t.request.paging.perPage=s.payload},setPageNumber:(t,s)=>{t.request.paging.page=s.payload},setRequestSort:(t,s)=>{t.request.sort=s.payload},setRequestFilters:(t,s)=>{t.request.filters=s.payload},setRequestFacets:(t,s)=>{t.request.facets=s.payload},setRequestVirtualField:(t,s)=>{t.request.virtualField=s.payload},setRequestScope:(t,s)=>{t.request.scope=s.payload},setResults:(t,s)=>{t.results=s.payload},setFacets:(t,s)=>{t.facets=s.payload},setSpellcheck:(t,s)=>{t.spellcheck=s.payload},setLocales:(t,s)=>{t.locales=s.payload},setPaging:(t,s)=>{t.paging=s.payload},setLiveQuery:(t,s)=>{t.liveQuery=s.payload},setSuggestResults:(t,s)=>{t.suggestResults=s.payload}};var o,a,h,c,u,l,d,f,v,w,y,E,p,S,b,m,A,g;!function(t){!function(s){var i={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(i.arrayBuffer)var e=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(t){return t&&e.indexOf(Object.prototype.toString.call(t))>-1};function r(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var s={next:function(){var s=t.shift();return{done:void 0===s,value:s}}};return i.iterable&&(s[Symbol.iterator]=function(){return s}),s}function h(t){this.map={},t instanceof h?t.forEach((function(t,s){this.append(s,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(s){this.append(s,t[s])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise((function(s,i){t.onload=function(){s(t.result)},t.onerror=function(){i(t.error)}}))}function l(t){var s=new FileReader,i=u(s);return s.readAsArrayBuffer(t),i}function d(t){if(t.slice)return t.slice(0);var s=new Uint8Array(t.byteLength);return s.set(new Uint8Array(t)),s.buffer}function f(){return this.bodyUsed=!1,this._initBody=function(t){var s;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:i.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:i.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():i.arrayBuffer&&i.blob&&((s=t)&&DataView.prototype.isPrototypeOf(s))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):i.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||n(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?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(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i.blob&&(this.blob=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var t,s,i,e=c(this);if(e)return e;if(this._bodyBlob)return t=this._bodyBlob,s=new FileReader,i=u(s),s.readAsText(t),i;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var s=new Uint8Array(t),i=new Array(s.length),e=0;e<s.length;e++)i[e]=String.fromCharCode(s[e]);return i.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(y)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,s){t=r(t),s=o(s);var i=this.map[t];this.map[t]=i?i+", "+s:s},h.prototype.delete=function(t){delete this.map[r(t)]},h.prototype.get=function(t){return t=r(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(r(t))},h.prototype.set=function(t,s){this.map[r(t)]=o(s)},h.prototype.forEach=function(t,s){for(var i in this.map)this.map.hasOwnProperty(i)&&t.call(s,this.map[i],i,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(s,i){t.push(i)})),a(t)},h.prototype.values=function(){var t=[];return this.forEach((function(s){t.push(s)})),a(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(s,i){t.push([i,s])})),a(t)},i.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,s){var i,e,n=(s=s||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,s.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=s.credentials||this.credentials||"same-origin",!s.headers&&this.headers||(this.headers=new h(s.headers)),this.method=(i=s.method||this.method||"GET",e=i.toUpperCase(),v.indexOf(e)>-1?e:i),this.mode=s.mode||this.mode||null,this.signal=s.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function y(t){var s=new FormData;return t.trim().split("&").forEach((function(t){if(t){var i=t.split("="),e=i.shift().replace(/\+/g," "),n=i.join("=").replace(/\+/g," ");s.append(decodeURIComponent(e),decodeURIComponent(n))}})),s}function E(t,s){s||(s={}),this.type="default",this.status=void 0===s.status?200:s.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in s?s.statusText:"OK",this.headers=new h(s.headers),this.url=s.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},f.call(w.prototype),f.call(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},E.error=function(){var t=new E(null,{status:0,statusText:""});return t.type="error",t};var p=[301,302,303,307,308];E.redirect=function(t,s){if(-1===p.indexOf(s))throw new RangeError("Invalid status code");return new E(null,{status:s,headers:{location:t}})},s.DOMException=t.DOMException;try{new s.DOMException}catch(t){s.DOMException=function(t,s){this.message=t,this.name=s;var i=Error(t);this.stack=i.stack},s.DOMException.prototype=Object.create(Error.prototype),s.DOMException.prototype.constructor=s.DOMException}function S(t,e){return new Promise((function(n,r){var o=new w(t,e);if(o.signal&&o.signal.aborted)return r(new s.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var t,s,i={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",s=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var i=t.split(":"),e=i.shift().trim();if(e){var n=i.join(":").trim();s.append(e,n)}})),s)};i.url="responseURL"in a?a.responseURL:i.headers.get("X-Request-URL");var e="response"in a?a.response:a.responseText;n(new E(e,i))},a.onerror=function(){r(new TypeError("Network request failed"))},a.ontimeout=function(){r(new TypeError("Network request failed"))},a.onabort=function(){r(new s.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&i.blob&&(a.responseType="blob"),o.headers.forEach((function(t,s){a.setRequestHeader(s,t)})),o.signal&&(o.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",c)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}S.polyfill=!0,t.fetch||(t.fetch=S,t.Headers=h,t.Request=w,t.Response=E),s.Headers=h,s.Request=w,s.Response=E,s.fetch=S,Object.defineProperty(s,"t",{value:!0})}({})}("undefined"!=typeof self?self:void 0),function(t){t.black="black",t.green="green",t.blue="blue",t.purple="purple",t.red="red",t.orange="orange",t.yellow="yellow"}(o||(o={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(a||(a={})),function(t){t.THIRD_PARTY="THIRD_PARTY",t.OFF_THE_GRID="OFF_THE_GRID",t.CONTENT_PACKAGER="CONTENT_PACKAGER",t.PAGES="PAGES",t.DESIGNED_READER="DESIGNED_READER"}(h||(h={})),function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"}(c||(c={})),function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"}(u||(u={})),function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"}(l||(l={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(d||(d={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(f||(f={})),function(t){t.ASC="ASC",t.DESC="DESC"}(v||(v={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(w||(w={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(y||(y={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(E||(E={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(p||(p={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(S||(S={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(b||(b={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS"}(m||(m={})),function(t){t.PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",t.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",t.HTML_EXPORT_USER="HTML_EXPORT_USER",t.PDF_EXPORT_USER="PDF_EXPORT_USER",t.SAVED_SEARCH_USER="SAVED_SEARCH_USER",t.COLLECTION_USER="COLLECTION_USER",t.OFFLINE_USER="OFFLINE_USER",t.ANALYTICS_USER="ANALYTICS_USER",t.BETA_USER="BETA_USER",t.DEBUG_USER="DEBUG_USER",t.PRINT_USER="PRINT_USER",t.RATING_USER="RATING_USER",t.FEEDBACK_USER="FEEDBACK_USER",t.GENERATIVE_AI_USER="GENERATIVE_AI_USER",t.CONTENT_PUBLISHER="CONTENT_PUBLISHER",t.KHUB_ADMIN="KHUB_ADMIN",t.USERS_ADMIN="USERS_ADMIN",t.PORTAL_ADMIN="PORTAL_ADMIN",t.ADMIN="ADMIN",t.DEVELOPER="DEVELOPER"}(A||(A={})),function(t){t.VALID="VALID",t.INVALID="INVALID"}(g||(g={})),A.PERSONAL_BOOK_SHARE_USER,A.PERSONAL_BOOK_USER,A.HTML_EXPORT_USER,A.PERSONAL_BOOK_USER,A.PDF_EXPORT_USER,A.PERSONAL_BOOK_USER,A.KHUB_ADMIN,A.CONTENT_PUBLISHER,A.ADMIN,A.KHUB_ADMIN,A.USERS_ADMIN,A.PORTAL_ADMIN,A.DEVELOPER,A.BETA_USER,A.DEBUG_USER;const R=i.css`
3
+ `,T=s.FtReduxStore.get({name:"ft-app-info",reducers:{},initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0,openExternalDocumentInNewTab:!1}});class O{static get(t){const{baseUrl:s,apiIntegrationIdentifier:i}=T.getState(),e=null!=t?t:i;if(s&&e&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(s,e,!0)}static await(t){return new Promise((s=>{let i=O.get(t);if(i)s(i);else{const e=T.subscribe((()=>{i=O.get(t),i&&(e(),s(i))}))}}))}}class I{constructor(t=!0,i){var e;this.overrideApi=i;let n=this.constructor;n.commonCache=null!==(e=n.commonCache)&&void 0!==e?e:new s.CacheRegistry,this.cache=t?n.commonCache:new s.CacheRegistry}get api(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:O.get()}get awaitApi(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:O.await()}clearCache(){this.cache.clearAll()}}var C;const U=Symbol("clearAfterUnitTest");class L extends I{constructor(t){super(),this.messageContextProvider=t,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[C]=()=>{this.defaultMessages={},this.cache=new s.CacheRegistry,this.listeners={}},this.currentUiLocale=T.getState().uiLocale,T.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=T.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const s=t.name.toLowerCase();this.cache.setFinal(s,t),this.notify(s)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,i){var e;if(t=t.toLowerCase(),Object.keys(i).length>0){const n={...null!==(e=this.defaultMessages[t])&&void 0!==e?e:{},...i};s.deepEqual(this.defaultMessages[t],n)||(this.defaultMessages[t]=n,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,i,...e){var n,r,o;t=t.toLowerCase(),this.fetchContext(t);const a=null!==(r=null===(n=this.cache.getNow(t))||void 0===n?void 0:n.messages)&&void 0!==r?r:{};return new s.ParametrizedLabelResolver(null!==(o=this.defaultMessages[t])&&void 0!==o?o:{},a).resolve(i,...e)}async fetchContext(t){if(!this.cache.has(t))try{await this.cache.get(t,(()=>this.messageContextProvider(this.currentUiLocale,t))),await this.notify(t)}catch(t){console.error(t)}}subscribe(t,s){var i;return t=t.toLowerCase(),this.listeners[t]=null!==(i=this.listeners[t])&&void 0!==i?i:new Set,this.listeners[t].add(s),()=>{var i;return null===(i=this.listeners[t])||void 0===i?void 0:i.delete(s)}}async notifyAll(){await Promise.all(Object.keys(this.listeners).map((t=>this.notify(t))))}async notify(t){null!=this.listeners[t]&&await Promise.all([...this.listeners[t].values()].map((t=>s.delay(0).then((()=>t())).catch((()=>null)))))}}C=U,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new class extends L{constructor(){super((async(t,s)=>(await this.awaitApi).getFluidTopicsMessageContext(t,s)))}}),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new class extends L{constructor(){super((async(t,s)=>(await this.awaitApi).getCustomMessageContext(t,s)))}});const D=window.FluidTopicsI18nService;var N=function(t,s,i,e){for(var n,r=arguments.length,o=r<3?s:null===e?e=Object.getOwnPropertyDescriptor(s,i):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(s,i,o):n(s,i))||o);return r>3&&o&&Object.defineProperty(s,i,o),o};class P extends s.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>O.get(),this.cache=new s.CacheRegistry,this.cleanSessionDebouncer=new s.Debouncer}render(){return i.html`
4
4
  <slot></slot>
5
- `}update(t){super.update(t),t.has("baseUrl")&&(T.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),t.has("apiIntegrationIdentifier")&&T.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&T.actions.uiLocale(this.uiLocale),t.has("metadataConfiguration")&&T.actions.metadataConfiguration(this.metadataConfiguration),t.has("noCustom")&&T.actions.noCustom(this.noCustom),t.has("editorMode")&&T.actions.editorMode(this.editorMode),t.has("noCustomComponent")&&T.actions.noCustomComponent(this.noCustomComponent),t.has("session")&&T.actions.session(this.session),t.has("availableUiLocales")&&T.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>D.addContext(t))),t.has("openExternalDocumentInNewTab")&&T.actions.openExternalDocumentInNewTab(this.openExternalDocumentInNewTab),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){!this.withManualResources&&this.apiProvider()&&(null==this.session&&this.updateSession(),null==this.availableUiLocales&&this.updateUiLocales(),null==this.metadataConfiguration&&this.updateMetadataConfiguration())}async updateSession(){this.session=await this.cache.get("session",(async()=>{const t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),t.idleTimeoutInMillis),t}))}async updateUiLocales(){this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>this.apiProvider().getAvailableUiLocales()))}async updateMetadataConfiguration(){this.metadataConfiguration=await this.cache.get("metadataConfiguration",(()=>this.apiProvider().getMetadataConfiguration()))}}P.elementDefinitions={},P.styles=R,N([e.property()],P.prototype,"baseUrl",void 0),N([e.property()],P.prototype,"apiIntegrationIdentifier",void 0),N([e.property()],P.prototype,"uiLocale",void 0),N([i.jsonProperty(null)],P.prototype,"availableUiLocales",void 0),N([i.jsonProperty(null)],P.prototype,"metadataConfiguration",void 0),N([e.property({type:Boolean})],P.prototype,"editorMode",void 0),N([e.property({type:Boolean})],P.prototype,"noCustom",void 0),N([e.property({type:Boolean})],P.prototype,"openExternalDocumentInNewTab",void 0),N([e.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],P.prototype,"noCustomComponent",void 0),N([e.property({type:Boolean})],P.prototype,"withManualResources",void 0),N([i.jsonProperty([])],P.prototype,"messageContexts",void 0),N([i.jsonProperty(void 0)],P.prototype,"session",void 0),N([e.property({type:Object})],P.prototype,"apiProvider",void 0);class _ extends I{async listMySearches(){let t=T.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-searches",(async()=>(await this.awaitApi).listMySearches(t.profile.userId)),3e5):[]}}class x extends I{async listMyBookmarks(){let t=T.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-bookmarks",(async()=>(await this.awaitApi).listMyBookmarks(t.profile.userId)),3e5):[]}}const B=i.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const M=new class{constructor(){this.currentSession=T.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new x,this.savedSearchesService=new _,T.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:s}=T.getState();i.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==s?void 0:s.profile)||(this.currentSession=s,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),B.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),B.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();const t=await this.savedSearchesService.listMySearches();B.actions.savedSearches(t)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const i=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;B.actions.bookmarks(i)}}};i.customElement("ft-app-context")(P);class F extends I{constructor(){super(),this.cache.registerFinal("available-locales",(()=>this.api.getAvailableSearchLocales()))}async launchSearch(t){return this.api.search(t)}async launchSuggest(t){return this.api.getSuggestions(t)}async getAvailableSearchLocales(){return this.cache.get("available-locales")}}const k=t=>t.request.virtualField===y.TITLE_ONLY&&t.request.scope===m.DOCUMENTS;class j extends Event{constructor(){super(j.eventName)}}j.eventName="search-context-clear-all-filters";class q{static build(t,s){return new q((t=>i.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:r}))(t.trim()||"context"),s)}constructor(t,s){this.store=t,this.ignoreEmptyQuery=!1,this.openExternalDocumentInNewTab=!1,this.searchDebouncer=new i.Debouncer(100),this.suggestDebouncer=new i.Debouncer(300),this.service=null!=s?s:new F}async initService(){return this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let i=this.store.getState().locales,s=this.store.getState().request.contentLocale;if(t!=s){if(i){const e=t=>i.some((i=>i.lang==t));e(t)||(t=e(s)?s:i[0].lang)}this.store.actions.setRequestContentLocale(t),this.store.actions.setPageNumber(1),this.store.actions.setRequestFilters([]),this.launchSearch()}return t}setPageSize(t){this.store.actions.setPageSize(t),this.launchSearch()}setPageNumber(t){this.store.actions.setPageNumber(t),this.launchSearch()}setSort(t){this.store.actions.setRequestSort(t),this.store.actions.setPageNumber(1),this.launchSearch()}setFilters(t){const i=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(i),this.store.actions.setPageNumber(1),i.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(y.TITLE_ONLY),this.store.actions.setRequestScope(m.DOCUMENTS)):(this.store.actions.setRequestVirtualField(y.EVERYWHERE),this.store.actions.setRequestScope(m.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return k(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new j)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,i){let s=this.facetIds.filter((i=>i!=t));i&&s.push(i),this.facetIds=s,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let i=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(i)}setFilter(t,i){let s=this.store.getState().request.filters,e={key:t,values:i,negative:!1},n=[...s.filter((i=>i.key!==t)),e];this.setFilters(n)}setLiveQuery(t){this.store.actions.setLiveQuery(t),this.launchSuggest()}setRequest(t){this.store.actions.setRequest(t),this.store.actions.setLiveQuery(t.query),this.store.actions.setPageNumber(1),this.launchSearch()}setScope(t){this.store.actions.setRequestScope(t),this.launchSearch()}setIgnoreEmptyQuery(t){this.ignoreEmptyQuery=t,this.launchSearch()}setOpenExternalDocumentInNewTab(t){this.openExternalDocumentInNewTab=t}launchSearch(){return this.searchDebouncer.run((()=>this.fetchSearchData()))}launchSuggest(){return this.suggestDebouncer.run((()=>this.fetchSuggestData()))}async fetchSearchData(){var t,s;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel();let e=this.store.getState().request;if(this.store.actions.setPaging(void 0),this.ignoreEmptyQuery&&0==e.query.length)this.store.actions.setResults(void 0),this.store.actions.setFacets(void 0),this.store.actions.setSpellcheck(void 0);else{this.cancelableSearch=i.cancelable(this.service.launchSearch(e));const t=await this.cancelableSearch;if(t.paging.currentPage<=1)this.store.actions.setResults(t.results),this.store.actions.setFacets(t.facets),this.store.actions.setSpellcheck(t.spellcheck);else{let i=(null!==(s=this.store.getState().results)&&void 0!==s?s:[]).concat(t.results);this.store.actions.setResults(i)}this.store.actions.setPaging(t.paging)}}catch(t){t instanceof i.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const s=this.store.getState(),e=s.request,n={input:s.liveQuery,filters:e.filters,sort:e.sort,contentLocale:e.contentLocale,scope:e.scope};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=i.cancelable(this.service.launchSuggest(n));let r=await this.cancelableSuggest;this.store.actions.setSuggestResults(r.suggestions)}catch(t){t instanceof i.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}clear(){this.store.clear()}}var H=function(t,i,s,e){for(var n,r=arguments.length,o=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(i,s,o):n(i,s))||o);return r>3&&o&&Object.defineProperty(i,s,o),o};class G extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const K=Symbol("registerInterval");class V extends(function(t){var i;class s extends t{constructor(){super(...arguments),this[i]=0}setSearchStateManager(t){this.clearStateManager(),this.stateManager=t,this.addStore(t.store,"search")}clearStateManager(){this.stateManager&&(this.removeStore(this.stateManager.store),this.stateManager=void 0)}connectedCallback(){super.connectedCallback(),this[K]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[K]):this.dispatchEvent(new G)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return i=K,H([e.state()],s.prototype,"stateManager",void 0),s}(i.FtLitElementRedux)){}var Q=function(t,i,s,e){for(var n,r=arguments.length,o=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(i,s,o):n(i,s))||o);return r>3&&o&&Object.defineProperty(i,s,o),o};class z extends CustomEvent{constructor(t){super("ft-search-load-error",{detail:t})}}class X extends CustomEvent{constructor(t){super("ft-search-request-change",{detail:t})}}class Y extends CustomEvent{constructor(t,i,s){super("ft-search-results-change",{detail:{request:t,paging:i,spellcheck:s}})}}class W extends i.FtLitElementRedux{get stateManager(){if(null==this._stateManager){const t=this.searchServiceProvider?this.searchServiceProvider():void 0;this._stateManager=q.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0"),t),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store,"search")}return this._stateManager}constructor(){super(),this.query="",this.pageSize=20,this.searchInDocumentTitlesOnly=!1,this.ignoreEmptyQuery=!1,this.openExternalDocumentInNewTab=!1,this.filters=[],this.sort=[],this.addStore(T)}render(){return s.html`
5
+ `}update(t){super.update(t),t.has("baseUrl")&&(T.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),t.has("apiIntegrationIdentifier")&&T.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&T.actions.uiLocale(this.uiLocale),t.has("metadataConfiguration")&&T.actions.metadataConfiguration(this.metadataConfiguration),t.has("noCustom")&&T.actions.noCustom(this.noCustom),t.has("editorMode")&&T.actions.editorMode(this.editorMode),t.has("noCustomComponent")&&T.actions.noCustomComponent(this.noCustomComponent),t.has("session")&&T.actions.session(this.session),t.has("availableUiLocales")&&T.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>D.addContext(t))),t.has("openExternalDocumentInNewTab")&&T.actions.openExternalDocumentInNewTab(this.openExternalDocumentInNewTab),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){!this.withManualResources&&this.apiProvider()&&(null==this.session&&this.updateSession(),null==this.availableUiLocales&&this.updateUiLocales(),null==this.metadataConfiguration&&this.updateMetadataConfiguration())}async updateSession(){this.session=await this.cache.get("session",(async()=>{const t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),t.idleTimeoutInMillis),t}))}async updateUiLocales(){this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>this.apiProvider().getAvailableUiLocales()))}async updateMetadataConfiguration(){this.metadataConfiguration=await this.cache.get("metadataConfiguration",(()=>this.apiProvider().getMetadataConfiguration()))}}P.elementDefinitions={},P.styles=R,N([e.property()],P.prototype,"baseUrl",void 0),N([e.property()],P.prototype,"apiIntegrationIdentifier",void 0),N([e.property()],P.prototype,"uiLocale",void 0),N([s.jsonProperty(null)],P.prototype,"availableUiLocales",void 0),N([s.jsonProperty(null)],P.prototype,"metadataConfiguration",void 0),N([e.property({type:Boolean})],P.prototype,"editorMode",void 0),N([e.property({type:Boolean})],P.prototype,"noCustom",void 0),N([e.property({type:Boolean})],P.prototype,"openExternalDocumentInNewTab",void 0),N([e.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],P.prototype,"noCustomComponent",void 0),N([e.property({type:Boolean})],P.prototype,"withManualResources",void 0),N([s.jsonProperty([])],P.prototype,"messageContexts",void 0),N([s.jsonProperty(void 0)],P.prototype,"session",void 0),N([e.property({type:Object})],P.prototype,"apiProvider",void 0);class _ extends I{async listMySearches(){let t=T.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-searches",(async()=>(await this.awaitApi).listMySearches(t.profile.userId)),3e5):[]}}class x extends I{async listMyBookmarks(){let t=T.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-bookmarks",(async()=>(await this.awaitApi).listMyBookmarks(t.profile.userId)),3e5):[]}}const B=s.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const M=new class{constructor(){this.currentSession=T.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new x,this.savedSearchesService=new _,T.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:i}=T.getState();s.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==i?void 0:i.profile)||(this.currentSession=i,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),B.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),B.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();const t=await this.savedSearchesService.listMySearches();B.actions.savedSearches(t)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const s=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;B.actions.bookmarks(s)}}};s.customElement("ft-app-context")(P);class F extends I{constructor(){super(),this.cache.registerFinal("available-locales",(()=>this.api.getAvailableSearchLocales()))}async launchSearch(t){return this.api.search(t)}async launchSuggest(t){return this.api.getSuggestions(t)}async getAvailableSearchLocales(){return this.cache.get("available-locales")}}const k=t=>t.request.virtualField===y.TITLE_ONLY&&t.request.scope===m.DOCUMENTS;class j extends Event{constructor(){super(j.eventName)}}j.eventName="search-context-clear-all-filters";class q{static build(t,i){return new q((t=>s.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:r}))(t.trim()||"context"),i)}constructor(t,i){this.store=t,this.ignoreEmptyQuery=!1,this.openExternalDocumentInNewTab=!1,this.searchDebouncer=new s.Debouncer(100),this.suggestDebouncer=new s.Debouncer(300),this.service=null!=i?i:new F}async initService(){return this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let s=this.store.getState().locales,i=this.store.getState().request.contentLocale;if(t!=i){if(s){const e=t=>s.some((s=>s.lang==t));e(t)||(t=e(i)?i:s[0].lang)}this.store.actions.setRequestContentLocale(t),this.store.actions.setPageNumber(1),this.store.actions.setRequestFilters([]),this.launchSearch()}return t}setPageSize(t){this.store.actions.setPageSize(t),this.launchSearch()}setPageNumber(t){this.store.actions.setPageNumber(t),this.launchSearch()}setSort(t){this.store.actions.setRequestSort(t),this.store.actions.setPageNumber(1),this.launchSearch()}setFilters(t){const s=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(s),this.store.actions.setPageNumber(1),s.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(y.TITLE_ONLY),this.store.actions.setRequestScope(m.DOCUMENTS)):(this.store.actions.setRequestVirtualField(y.EVERYWHERE),this.store.actions.setRequestScope(m.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return k(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new j)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,s){let i=this.facetIds.filter((s=>s!=t));s&&i.push(s),this.facetIds=i,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let s=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(s)}setFilter(t,s){let i=this.store.getState().request.filters,e={key:t,values:s,negative:!1},n=[...i.filter((s=>s.key!==t)),e];this.setFilters(n)}setLiveQuery(t){this.store.actions.setLiveQuery(t),this.launchSuggest()}setRequest(t){this.store.actions.setRequest(t),this.store.actions.setLiveQuery(t.query),this.store.actions.setPageNumber(1),this.launchSearch()}setScope(t){this.store.actions.setRequestScope(t),this.launchSearch()}setIgnoreEmptyQuery(t){this.ignoreEmptyQuery=t,this.launchSearch()}setOpenExternalDocumentInNewTab(t){this.openExternalDocumentInNewTab=t}launchSearch(){return this.searchDebouncer.run((()=>this.fetchSearchData()))}launchSuggest(){return this.suggestDebouncer.run((()=>this.fetchSuggestData()))}async fetchSearchData(){var t,i;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel();let e=this.store.getState().request;if(this.store.actions.setPaging(void 0),this.ignoreEmptyQuery&&0==e.query.length)this.store.actions.setResults(void 0),this.store.actions.setFacets(void 0),this.store.actions.setSpellcheck(void 0);else{this.cancelableSearch=s.cancelable(this.service.launchSearch(e));const t=await this.cancelableSearch;if(t.paging.currentPage<=1)this.store.actions.setResults(t.results),this.store.actions.setFacets(t.facets),this.store.actions.setSpellcheck(t.spellcheck);else{let s=(null!==(i=this.store.getState().results)&&void 0!==i?i:[]).concat(t.results);this.store.actions.setResults(s)}this.store.actions.setPaging(t.paging)}}catch(t){t instanceof s.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const i=this.store.getState(),e=i.request,n={input:i.liveQuery,filters:e.filters,sort:e.sort,contentLocale:e.contentLocale,scope:e.scope};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=s.cancelable(this.service.launchSuggest(n));let r=await this.cancelableSuggest;this.store.actions.setSuggestResults(r.suggestions)}catch(t){t instanceof s.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}clear(){this.store.clear()}}var H=function(t,s,i,e){for(var n,r=arguments.length,o=r<3?s:null===e?e=Object.getOwnPropertyDescriptor(s,i):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(s,i,o):n(s,i))||o);return r>3&&o&&Object.defineProperty(s,i,o),o};class G extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const K=Symbol("registerInterval");class V extends(function(t){var s;class i extends t{constructor(){super(...arguments),this[s]=0}setSearchStateManager(t){this.clearStateManager(),this.stateManager=t,this.addStore(t.store,"search")}clearStateManager(){this.stateManager&&(this.removeStore(this.stateManager.store),this.stateManager=void 0)}connectedCallback(){super.connectedCallback(),this[K]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[K]):this.dispatchEvent(new G)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return s=K,H([e.state()],i.prototype,"stateManager",void 0),i}(s.FtLitElementRedux)){}var Q=function(t,s,i,e){for(var n,r=arguments.length,o=r<3?s:null===e?e=Object.getOwnPropertyDescriptor(s,i):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(s,i,o):n(s,i))||o);return r>3&&o&&Object.defineProperty(s,i,o),o};class z extends CustomEvent{constructor(t){super("ft-search-load-error",{detail:t})}}class X extends CustomEvent{constructor(t){super("ft-search-request-change",{detail:t})}}class Y extends CustomEvent{constructor(t,s,i){super("ft-search-results-change",{detail:{request:t,paging:s,spellcheck:i}})}}class W extends s.FtLitElementRedux{get stateManager(){if(null==this._stateManager){const t=this.searchServiceProvider?this.searchServiceProvider():void 0;this._stateManager=q.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0"),t),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store,"search")}return this._stateManager}constructor(){super(),this.query="",this.pageSize=20,this.searchInDocumentTitlesOnly=!1,this.ignoreEmptyQuery=!1,this.openExternalDocumentInNewTab=!1,this.filters=[],this.sort=[],this.addStore(T)}render(){return i.html`
6
6
  <slot @register-ft-search-component=${this.registerComponent}></slot>
7
- `}update(t){super.update(t),t.has("query")&&void 0!==this.query&&this.stateManager.setQuery(this.query),t.has("contentLocale")&&void 0!==this.contentLocale&&this.stateManager.setContentLocale(this.contentLocale),t.has("session")&&this.session&&this.stateManager.initService(),t.has("filters")&&void 0!==this.filters&&this.stateManager.setFilters(this.filters),t.has("sort")&&void 0!==this.sort&&this.stateManager.setSort(this.sort),t.has("pageSize")&&void 0!==this.pageSize&&this.stateManager.setPageSize(this.pageSize),t.has("searchInDocumentTitlesOnly")&&void 0!==this.searchInDocumentTitlesOnly&&this.stateManager.setSearchInDocumentTitlesOnly(this.searchInDocumentTitlesOnly),t.has("scope")&&void 0!==this.scope&&this.stateManager.setScope(this.scope),t.has("ignoreEmptyQuery")&&void 0!==this.ignoreEmptyQuery&&this.stateManager.setIgnoreEmptyQuery(this.ignoreEmptyQuery),t.has("openExternalDocumentInNewTab")&&void 0!==this.openExternalDocumentInNewTab&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab)}connectedCallback(){super.connectedCallback(),this.stateManager.setQuery(this.query),this.stateManager.setContentLocale(this.contentLocale),this.stateManager.setFilters(this.filters),this.stateManager.setPageSize(this.pageSize),this.stateManager.setSort(this.sort)}contentAvailableCallback(t){super.contentAvailableCallback(t),t.has("request")&&this.request&&this.dispatchEvent(new X(this.request)),t.has("paging")&&void 0!==this.paging&&this.dispatchEvent(new Y(this.request,this.paging,this.autocorrect))}registerComponent(t){t.stopPropagation();const i=t.composedPath()[0];this.register(i)}register(t){t.setSearchStateManager(this.stateManager)}handleLoadError(t){this.dispatchEvent(new z(t))}reloadSavedSearches(){M.clearMySearches()}clear(){this.stateManager.clear()}}W.elementDefinitions={},W.styles=n,Q([e.property()],W.prototype,"query",void 0),Q([e.property()],W.prototype,"contentLocale",void 0),Q([e.property({type:Number})],W.prototype,"pageSize",void 0),Q([e.property({type:Boolean})],W.prototype,"searchInDocumentTitlesOnly",void 0),Q([e.property()],W.prototype,"scope",void 0),Q([e.property({type:Boolean})],W.prototype,"ignoreEmptyQuery",void 0),Q([i.redux({store:T.name})],W.prototype,"openExternalDocumentInNewTab",void 0),Q([i.jsonProperty([])],W.prototype,"filters",void 0),Q([i.jsonProperty([])],W.prototype,"sort",void 0),Q([i.redux({store:"search"})],W.prototype,"request",void 0),Q([i.redux({store:"search"})],W.prototype,"paging",void 0),Q([i.redux({store:"search",selector:t=>t.spellcheck})],W.prototype,"autocorrect",void 0),Q([i.redux({store:T.name})],W.prototype,"session",void 0),Q([e.property({attribute:!1})],W.prototype,"searchServiceProvider",void 0),i.customElement("ft-search-context")(W),t.ClearAllFiltersEvent=j,t.FtSearchContext=W,t.FtSearchContextCssVariables={},t.FtSearchStateManager=q,t.LoadErrorEvent=z,t.SearchRequestChangeEvent=X,t.SearchResultsChangeEvent=Y,t.searchInDocumentTitlesOnlySelector=k,t.styles=n}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators);
7
+ `}update(t){super.update(t),t.has("query")&&void 0!==this.query&&this.stateManager.setQuery(this.query),t.has("contentLocale")&&void 0!==this.contentLocale&&this.stateManager.setContentLocale(this.contentLocale),t.has("session")&&this.session&&this.stateManager.initService(),t.has("filters")&&void 0!==this.filters&&this.stateManager.setFilters(this.filters),t.has("sort")&&void 0!==this.sort&&this.stateManager.setSort(this.sort),t.has("pageSize")&&void 0!==this.pageSize&&this.stateManager.setPageSize(this.pageSize),t.has("searchInDocumentTitlesOnly")&&void 0!==this.searchInDocumentTitlesOnly&&this.stateManager.setSearchInDocumentTitlesOnly(this.searchInDocumentTitlesOnly),t.has("scope")&&void 0!==this.scope&&this.stateManager.setScope(this.scope),t.has("ignoreEmptyQuery")&&void 0!==this.ignoreEmptyQuery&&this.stateManager.setIgnoreEmptyQuery(this.ignoreEmptyQuery),t.has("openExternalDocumentInNewTab")&&void 0!==this.openExternalDocumentInNewTab&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab)}connectedCallback(){super.connectedCallback(),this.stateManager.setQuery(this.query),this.stateManager.setContentLocale(this.contentLocale),this.stateManager.setFilters(this.filters),this.stateManager.setPageSize(this.pageSize),this.stateManager.setSort(this.sort)}contentAvailableCallback(t){super.contentAvailableCallback(t),t.has("request")&&this.request&&this.dispatchEvent(new X(this.request)),t.has("paging")&&void 0!==this.paging&&this.dispatchEvent(new Y(this.request,this.paging,this.autocorrect))}registerComponent(t){t.stopPropagation();const s=t.composedPath()[0];this.register(s)}register(t){t.setSearchStateManager(this.stateManager)}handleLoadError(t){this.dispatchEvent(new z(t))}reloadSavedSearches(){M.clearMySearches()}clear(){this.stateManager.clear()}}W.elementDefinitions={},W.styles=n,Q([e.property()],W.prototype,"query",void 0),Q([e.property()],W.prototype,"contentLocale",void 0),Q([e.property({type:Number})],W.prototype,"pageSize",void 0),Q([e.property({type:Boolean})],W.prototype,"searchInDocumentTitlesOnly",void 0),Q([e.property()],W.prototype,"scope",void 0),Q([e.property({type:Boolean})],W.prototype,"ignoreEmptyQuery",void 0),Q([s.redux({store:T.name})],W.prototype,"openExternalDocumentInNewTab",void 0),Q([s.jsonProperty([])],W.prototype,"filters",void 0),Q([s.jsonProperty([])],W.prototype,"sort",void 0),Q([s.redux({store:"search"})],W.prototype,"request",void 0),Q([s.redux({store:"search"})],W.prototype,"paging",void 0),Q([s.redux({store:"search",selector:t=>t.spellcheck})],W.prototype,"autocorrect",void 0),Q([s.redux({store:T.name})],W.prototype,"session",void 0),Q([e.property({attribute:!1})],W.prototype,"searchServiceProvider",void 0),s.customElement("ft-search-context")(W),t.ClearAllFiltersEvent=j,t.FtSearchContext=W,t.FtSearchContextCssVariables={},t.FtSearchStateManager=q,t.LoadErrorEvent=z,t.SearchRequestChangeEvent=X,t.SearchResultsChangeEvent=Y,t.searchInDocumentTitlesOnlySelector=k,t.styles=n}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators);