@fluid-topics/ft-search-selected-facets 1.0.62 → 1.0.63

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.
@@ -7,7 +7,7 @@
7
7
  `,c={setRequest:(t,e)=>{t.request=e.payload},setRequestQuery:(t,e)=>{t.request.query=e.payload},setRequestContentLocale:(t,e)=>{t.request.contentLocale=e.payload},setPageSize:(t,e)=>{t.request.paging.perPage=e.payload},setPageNumber:(t,e)=>{t.request.paging.page=e.payload},setRequestSort:(t,e)=>{t.request.sort=e.payload},setRequestFilters:(t,e)=>{t.request.filters=e.payload},setRequestFacets:(t,e)=>{t.request.facets=e.payload},setRequestVirtualField:(t,e)=>{t.request.virtualField=e.payload},setRequestScope:(t,e)=>{t.request.scope=e.payload},setResults:(t,e)=>{t.results=e.payload},setFacets:(t,e)=>{t.facets=e.payload},setSpellcheck:(t,e)=>{t.spellcheck=e.payload},setLocales:(t,e)=>{t.locales=e.payload},setPaging:(t,e)=>{t.paging=e.payload},setLiveQuery:(t,e)=>{t.liveQuery=e.payload},setSuggestResults:(t,e)=>{t.suggestResults=e.payload}};var h,p,f,d,u,g,y,b,m,v,x,O,S,N;!function(t){!function(e){var o={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(o.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],r=ArrayBuffer.isView||function(t){return t&&i.indexOf(Object.prototype.toString.call(t))>-1};function n(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 a(t){return"string"!=typeof t&&(t=String(t)),t}function s(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return o.iterable&&(e[Symbol.iterator]=function(){return e}),e}function l(t){this.map={},t instanceof l?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function h(t){return new Promise((function(e,o){t.onload=function(){e(t.result)},t.onerror=function(){o(t.error)}}))}function p(t){var e=new FileReader,o=h(e);return e.readAsArrayBuffer(t),o}function f(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:o.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():o.arrayBuffer&&o.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=f(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||r(t))?this._bodyArrayBuffer=f(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):o.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o.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(p)}),this.text=function(){var t,e,o,i=c(this);if(i)return i;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,o=h(e),e.readAsText(t),o;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),o=new Array(e.length),i=0;i<e.length;i++)o[i]=String.fromCharCode(e[i]);return o.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(t,e){t=n(t),e=a(e);var o=this.map[t];this.map[t]=o?o+", "+e:e},l.prototype.delete=function(t){delete this.map[n(t)]},l.prototype.get=function(t){return t=n(t),this.has(t)?this.map[t]:null},l.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},l.prototype.set=function(t,e){this.map[n(t)]=a(e)},l.prototype.forEach=function(t,e){for(var o in this.map)this.map.hasOwnProperty(o)&&t.call(e,this.map[o],o,this)},l.prototype.keys=function(){var t=[];return this.forEach((function(e,o){t.push(o)})),s(t)},l.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),s(t)},l.prototype.entries=function(){var t=[];return this.forEach((function(e,o){t.push([o,e])})),s(t)},o.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var u=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function g(t,e){var o,i,r=(e=e||{}).body;if(t instanceof g){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new l(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new l(e.headers)),this.method=(o=e.method||this.method||"GET",i=o.toUpperCase(),u.indexOf(i)>-1?i:o),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function y(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var o=t.split("="),i=o.shift().replace(/\+/g," "),r=o.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(r))}})),e}function b(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new l(e.headers),this.url=e.url||"",this._initBody(t)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},d.call(g.prototype),d.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},b.error=function(){var t=new b(null,{status:0,statusText:""});return t.type="error",t};var m=[301,302,303,307,308];b.redirect=function(t,e){if(-1===m.indexOf(e))throw new RangeError("Invalid status code");return new b(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var o=Error(t);this.stack=o.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function v(t,i){return new Promise((function(r,n){var a=new g(t,i);if(a.signal&&a.signal.aborted)return n(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var t,e,o={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new l,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var o=t.split(":"),i=o.shift().trim();if(i){var r=o.join(":").trim();e.append(i,r)}})),e)};o.url="responseURL"in s?s.responseURL:o.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;r(new b(i,o))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.onabort=function(){n(new e.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&o.blob&&(s.responseType="blob"),a.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),a.signal&&(a.signal.addEventListener("abort",c),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",c)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}v.polyfill=!0,t.fetch||(t.fetch=v,t.Headers=l,t.Request=g,t.Response=b),e.Headers=l,e.Request=g,e.Response=b,e.fetch=v,Object.defineProperty(e,"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"}(h||(h={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(p||(p={})),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"}(f||(f={})),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"}(u||(u={})),function(t){t.ASC="ASC",t.DESC="DESC"}(g||(g={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(y||(y={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(b||(b={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(m||(m={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(v||(v={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(x||(x={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(O||(O={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS"}(S||(S={})),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.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"}(N||(N={})),N.PERSONAL_BOOK_SHARE_USER,N.PERSONAL_BOOK_USER,N.HTML_EXPORT_USER,N.PERSONAL_BOOK_USER,N.PDF_EXPORT_USER,N.PERSONAL_BOOK_USER,N.KHUB_ADMIN,N.CONTENT_PUBLISHER,N.ADMIN,N.KHUB_ADMIN,N.USERS_ADMIN,N.PORTAL_ADMIN,N.DEVELOPER,N.BETA_USER,N.DEBUG_USER;const $=o.css`
8
8
  `,w=e.FtReduxStore.get({name:"ft-app-info",reducers:{setBaseUrl:(t,e)=>{t.baseUrl=e.payload},setApiIntegrationIdentifier:(t,e)=>{t.apiIntegrationIdentifier=e.payload},setUiLocale:(t,e)=>{t.uiLocale=e.payload},setAvailableUiLocales:(t,e)=>{t.availableUiLocales=e.payload},setEditorMode:(t,e)=>{t.editorMode=e.payload},setNoCustom:(t,e)=>{t.noCustom=e.payload},setNoCustomComponent:(t,e)=>{t.noCustomComponent=e.payload},setSession:(t,e)=>{t.session=e.payload}},initialState:{uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],editorMode:!1,noCustom:!1,noCustomComponent:!1}});class C{static build(t){const{baseUrl:e,apiIntegrationIdentifier:o}=w.getState(),i=null!=t?t:o;if(e&&i&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(e,i,!0)}static get(t){var e;return null!=t?C.build(t):null!==(e=C.API)&&void 0!==e?e:C.API=C.build()}static await(t){return new Promise((e=>{let o=C.get(t);if(o)e(o);else{const i=w.subscribe((()=>{o=C.get(t),o&&(i(),e(o))}))}}))}}var k;const I=Symbol("clearAfterUnitTest");class E{constructor(t){this.messageContextProvider=t,this.defaultMessages={},this.cache=new e.CacheRegistry,this.listeners={},this.currentUiLocale="",this[k]=()=>{this.defaultMessages={},this.cache=new e.CacheRegistry,this.listeners={}},this.currentUiLocale=w.getState().uiLocale,w.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=w.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const e=t.name.toLowerCase();this.cache.setFinal(e,t),this.notify(e)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,o){var i;if(t=t.toLowerCase(),Object.keys(o).length>0){const r={...null!==(i=this.defaultMessages[t])&&void 0!==i?i:{},...o};e.deepEqual(this.defaultMessages[t],r)||(this.defaultMessages[t]=r,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,o,...i){var r,n,a;t=t.toLowerCase(),this.fetchContext(t);const s=null!==(n=null===(r=this.cache.getNow(t))||void 0===r?void 0:r.messages)&&void 0!==n?n:{};return new e.ParametrizedLabelResolver(null!==(a=this.defaultMessages[t])&&void 0!==a?a:{},s).resolve(o,...i)}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,e){var o;return t=t.toLowerCase(),this.listeners[t]=null!==(o=this.listeners[t])&&void 0!==o?o:new Set,this.listeners[t].add(e),()=>{var o;return null===(o=this.listeners[t])||void 0===o?void 0:o.delete(e)}}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=>e.delay(0).then((()=>t())).catch((()=>null)))))}}k=I,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new E((async(t,e)=>(await C.await()).getFluidTopicsMessageContext(t,e)))),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new E((async(t,e)=>(await C.await()).getCustomMessageContext(t,e))));const R=window.FluidTopicsI18nService,U=window.FluidTopicsCustomI18nService;var L=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class W extends e.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.availableUiLocales=[],this.editorMode=!1,this.noCustom=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>C.get(),this.cache=new e.CacheRegistry,this.cleanSessionDebouncer=new e.Debouncer}render(){return o.html`
9
9
  <slot></slot>
10
- `}update(t){super.update(t),t.has("baseUrl")&&w.actions.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&w.actions.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&w.actions.setUiLocale(this.uiLocale),t.has("noCustom")&&w.actions.setNoCustom(this.noCustom),t.has("editorMode")&&w.actions.setEditorMode(this.editorMode),t.has("noCustomComponent")&&w.actions.setNoCustomComponent(this.noCustomComponent),t.has("session")&&w.actions.setSession(this.session),t.has("availableUiLocales")&&w.actions.setAvailableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>R.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){const t=this.apiProvider();!this.withManualResources&&t&&(null==this.session&&(this.session=await this.cache.get("session",(async()=>{const e=await t.getCurrentSession();return e.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),e.idleTimeoutInMillis),e}))),null==this.availableUiLocales&&(this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>t.getAvailableUiLocales()))))}}W.elementDefinitions={},W.styles=$,L([r.property()],W.prototype,"baseUrl",void 0),L([r.property()],W.prototype,"apiIntegrationIdentifier",void 0),L([r.property()],W.prototype,"uiLocale",void 0),L([e.jsonProperty([])],W.prototype,"availableUiLocales",void 0),L([r.property({type:Boolean})],W.prototype,"editorMode",void 0),L([r.property({type:Boolean})],W.prototype,"noCustom",void 0),L([r.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],W.prototype,"noCustomComponent",void 0),L([r.property({type:Boolean})],W.prototype,"withManualResources",void 0),L([e.jsonProperty([])],W.prototype,"messageContexts",void 0),L([e.jsonProperty(void 0)],W.prototype,"session",void 0),L([r.property({type:Object})],W.prototype,"apiProvider",void 0);class z{async listMySearches(){var t;return(null===(t=w.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await C.await()).listMySearches(w.getState().session.profile.userId):[]}}const B=new e.CacheRegistry;class K{async listMyBookmarks(){return B.get("bookmarks",(async()=>(await C.await()).listMyBookmarks(w.getState().session.profile.userId)))}clearCache(){B.clear("bookmarks")}}const D=e.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const A=new class{constructor(){this.currentSession=w.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new K,w.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:o}=w.getState();e.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==o?void 0:o.profile)||(this.currentSession=o,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){D.actions.savedSearches(void 0)}clearMyBookmarks(){D.actions.bookmarks(void 0)}async reloadMySearches(){const t=new z,e=await t.listMySearches();D.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const e=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;D.actions.bookmarks(e)}}};e.customElement("ft-app-context")(W);class Z{static async build(){return new Z(await C.await())}constructor(t){this.api=t,this.cache=new e.CacheRegistry,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 F=t=>t.request.virtualField===b.TITLE_ONLY&&t.request.scope===S.DOCUMENTS;class T extends Event{constructor(){super(T.eventName)}}T.eventName="search-context-clear-all-filters";class H{static build(t){return new H((t=>e.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:c}))(t.trim()||"context"),Z.build)}constructor(t,o){this.store=t,this.serviceProvider=o,this.searchDebouncer=new e.Debouncer(100),this.suggestDebouncer=new e.Debouncer(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){for(;null==this.service;)await e.delay(5);return this.service}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let e=this.store.getState().locales,o=this.store.getState().request.contentLocale;if(t!=o){if(e){const i=t=>e.some((e=>e.lang==t));i(t)||(t=i(o)?o:e[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 e=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(e),this.store.actions.setPageNumber(1),e.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(b.TITLE_ONLY),this.store.actions.setRequestScope(S.DOCUMENTS)):(this.store.actions.setRequestVirtualField(b.EVERYWHERE),this.store.actions.setRequestScope(S.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return F(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new T)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,e){let o=this.facetIds.filter((e=>e!=t));e&&o.push(e),this.facetIds=o,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let e=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(e)}setFilter(t,e){let o=this.store.getState().request.filters,i={key:t,values:e,negative:!1},r=[...o.filter((e=>e.key!==t)),i];this.setFilters(r)}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()}async launchSearch(){return await this.awaitService(),this.searchDebouncer.run((()=>this.fetchSearchData()))}async launchSuggest(){await this.awaitService(),this.suggestDebouncer.run((()=>this.fetchSuggestData()))}async fetchSearchData(){var t,o;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel(),this.cancelableSearch=e.cancelable(this.service.launchSearch(this.store.getState().request));const i=await this.cancelableSearch;if(i.paging.currentPage<=1)this.store.actions.setResults(i.results),this.store.actions.setFacets(i.facets),this.store.actions.setSpellcheck(i.spellcheck);else{let t=(null!==(o=this.store.getState().results)&&void 0!==o?o:[]).concat(i.results);this.store.actions.setResults(t)}this.store.actions.setPaging(i.paging)}catch(t){t instanceof e.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{let o={input:this.store.getState().liveQuery,filters:this.store.getState().request.filters,sort:this.store.getState().request.sort,contentLocale:this.store.getState().request.contentLocale};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=e.cancelable(this.service.launchSuggest(o));let i=await this.cancelableSuggest;this.store.actions.setSuggestResults(i.suggestions)}catch(t){t instanceof e.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}}var P=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class j extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const M=Symbol("registerInterval");class _ extends(function(t){var e;class o extends t{constructor(){super(...arguments),this[e]=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[M]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[M]):this.dispatchEvent(new j)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return e=M,P([r.state()],o.prototype,"stateManager",void 0),o}(e.FtLitElementRedux)){}const G=e.FtCssVariableFactory.extend("--ft-ripple-color","",e.designSystemVariables.colorContent),V={color:G,backgroundColor:e.FtCssVariableFactory.extend("--ft-ripple-background-color","",G),opacityContentOnSurfacePressed:e.FtCssVariableFactory.external(e.designSystemVariables.opacityContentOnSurfacePressed,"Design system"),opacityContentOnSurfaceHover:e.FtCssVariableFactory.external(e.designSystemVariables.opacityContentOnSurfaceHover,"Design system"),opacityContentOnSurfaceFocused:e.FtCssVariableFactory.external(e.designSystemVariables.opacityContentOnSurfaceFocused,"Design system"),opacityContentOnSurfaceSelected:e.FtCssVariableFactory.external(e.designSystemVariables.opacityContentOnSurfaceSelected,"Design system"),borderRadius:e.FtCssVariableFactory.create("--ft-ripple-border-radius","","SIZE","0px")},q=e.FtCssVariableFactory.extend("--ft-ripple-color","",e.designSystemVariables.colorPrimary),Y=q,X=e.FtCssVariableFactory.extend("--ft-ripple-background-color","",q),Q=e.FtCssVariableFactory.extend("--ft-ripple-color","",e.designSystemVariables.colorSecondary),J=Q,tt=e.FtCssVariableFactory.extend("--ft-ripple-background-color","",Q),et=o.css`
10
+ `}update(t){super.update(t),t.has("baseUrl")&&w.actions.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&w.actions.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&w.actions.setUiLocale(this.uiLocale),t.has("noCustom")&&w.actions.setNoCustom(this.noCustom),t.has("editorMode")&&w.actions.setEditorMode(this.editorMode),t.has("noCustomComponent")&&w.actions.setNoCustomComponent(this.noCustomComponent),t.has("session")&&w.actions.setSession(this.session),t.has("availableUiLocales")&&w.actions.setAvailableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>R.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){const t=this.apiProvider();!this.withManualResources&&t&&(null==this.session&&(this.session=await this.cache.get("session",(async()=>{const e=await t.getCurrentSession();return e.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),e.idleTimeoutInMillis),e}))),null==this.availableUiLocales&&(this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>t.getAvailableUiLocales()))))}}W.elementDefinitions={},W.styles=$,L([r.property()],W.prototype,"baseUrl",void 0),L([r.property()],W.prototype,"apiIntegrationIdentifier",void 0),L([r.property()],W.prototype,"uiLocale",void 0),L([e.jsonProperty([])],W.prototype,"availableUiLocales",void 0),L([r.property({type:Boolean})],W.prototype,"editorMode",void 0),L([r.property({type:Boolean})],W.prototype,"noCustom",void 0),L([r.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],W.prototype,"noCustomComponent",void 0),L([r.property({type:Boolean})],W.prototype,"withManualResources",void 0),L([e.jsonProperty([])],W.prototype,"messageContexts",void 0),L([e.jsonProperty(void 0)],W.prototype,"session",void 0),L([r.property({type:Object})],W.prototype,"apiProvider",void 0);class z{async listMySearches(){var t;return(null===(t=w.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await C.await()).listMySearches(w.getState().session.profile.userId):[]}}const B=new e.CacheRegistry;class K{async listMyBookmarks(){return B.get("bookmarks",(async()=>(await C.await()).listMyBookmarks(w.getState().session.profile.userId)))}clearCache(){B.clear("bookmarks")}}const D=e.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const A=new class{constructor(){this.currentSession=w.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new K,w.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:o}=w.getState();e.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==o?void 0:o.profile)||(this.currentSession=o,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){D.actions.savedSearches(void 0)}clearMyBookmarks(){D.actions.bookmarks(void 0)}async reloadMySearches(){const t=new z,e=await t.listMySearches();D.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const e=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;D.actions.bookmarks(e)}}};e.customElement("ft-app-context")(W);class Z{static async build(){return new Z(await C.await())}constructor(t){this.api=t,this.cache=new e.CacheRegistry,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 F=t=>t.request.virtualField===b.TITLE_ONLY&&t.request.scope===S.DOCUMENTS;class T extends Event{constructor(){super(T.eventName)}}T.eventName="search-context-clear-all-filters";class H{static build(t){return new H((t=>e.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:c}))(t.trim()||"context"),Z.build)}constructor(t,o){this.store=t,this.serviceProvider=o,this.searchDebouncer=new e.Debouncer(100),this.suggestDebouncer=new e.Debouncer(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){for(;null==this.service;)await e.delay(5);return this.service}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let e=this.store.getState().locales,o=this.store.getState().request.contentLocale;if(t!=o){if(e){const i=t=>e.some((e=>e.lang==t));i(t)||(t=i(o)?o:e[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 e=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(e),this.store.actions.setPageNumber(1),e.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(b.TITLE_ONLY),this.store.actions.setRequestScope(S.DOCUMENTS)):(this.store.actions.setRequestVirtualField(b.EVERYWHERE),this.store.actions.setRequestScope(S.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return F(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new T)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,e){let o=this.facetIds.filter((e=>e!=t));e&&o.push(e),this.facetIds=o,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let e=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(e)}setFilter(t,e){let o=this.store.getState().request.filters,i={key:t,values:e,negative:!1},r=[...o.filter((e=>e.key!==t)),i];this.setFilters(r)}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()}async launchSearch(){return await this.awaitService(),this.searchDebouncer.run((()=>this.fetchSearchData()))}async launchSuggest(){await this.awaitService(),this.suggestDebouncer.run((()=>this.fetchSuggestData()))}async fetchSearchData(){var t,o;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel(),this.cancelableSearch=e.cancelable(this.service.launchSearch(this.store.getState().request));const i=await this.cancelableSearch;if(i.paging.currentPage<=1)this.store.actions.setResults(i.results),this.store.actions.setFacets(i.facets),this.store.actions.setSpellcheck(i.spellcheck);else{let t=(null!==(o=this.store.getState().results)&&void 0!==o?o:[]).concat(i.results);this.store.actions.setResults(t)}this.store.actions.setPaging(i.paging)}catch(t){t instanceof e.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const o=this.store.getState(),i=o.request,r={input:o.liveQuery,filters:i.filters,sort:i.sort,contentLocale:i.contentLocale,scope:i.scope};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=e.cancelable(this.service.launchSuggest(r));let n=await this.cancelableSuggest;this.store.actions.setSuggestResults(n.suggestions)}catch(t){t instanceof e.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}}var P=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class j extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const M=Symbol("registerInterval");class _ extends(function(t){var e;class o extends t{constructor(){super(...arguments),this[e]=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[M]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[M]):this.dispatchEvent(new j)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return e=M,P([r.state()],o.prototype,"stateManager",void 0),o}(e.FtLitElementRedux)){}const G=e.FtCssVariableFactory.extend("--ft-ripple-color","",e.designSystemVariables.colorContent),V={color:G,backgroundColor:e.FtCssVariableFactory.extend("--ft-ripple-background-color","",G),opacityContentOnSurfacePressed:e.FtCssVariableFactory.external(e.designSystemVariables.opacityContentOnSurfacePressed,"Design system"),opacityContentOnSurfaceHover:e.FtCssVariableFactory.external(e.designSystemVariables.opacityContentOnSurfaceHover,"Design system"),opacityContentOnSurfaceFocused:e.FtCssVariableFactory.external(e.designSystemVariables.opacityContentOnSurfaceFocused,"Design system"),opacityContentOnSurfaceSelected:e.FtCssVariableFactory.external(e.designSystemVariables.opacityContentOnSurfaceSelected,"Design system"),borderRadius:e.FtCssVariableFactory.create("--ft-ripple-border-radius","","SIZE","0px")},q=e.FtCssVariableFactory.extend("--ft-ripple-color","",e.designSystemVariables.colorPrimary),Y=q,X=e.FtCssVariableFactory.extend("--ft-ripple-background-color","",q),Q=e.FtCssVariableFactory.extend("--ft-ripple-color","",e.designSystemVariables.colorSecondary),J=Q,tt=e.FtCssVariableFactory.extend("--ft-ripple-background-color","",Q),et=o.css`
11
11
  :host {
12
12
  display: contents;
13
13
  }
@@ -128,7 +128,7 @@ var wt,St;let Nt=class extends F{constructor(){super(...arguments),this.renderOp
128
128
  */var li,ci,fi,hi,pi,di,ui,yi,bi,gi,vi,mi,xi,Oi;!function(t){!function(e){var o={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(o.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],r=ArrayBuffer.isView||function(t){return t&&i.indexOf(Object.prototype.toString.call(t))>-1};function n(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 a(t){return"string"!=typeof t&&(t=String(t)),t}function s(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return o.iterable&&(e[Symbol.iterator]=function(){return e}),e}function l(t){this.map={},t instanceof l?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise((function(e,o){t.onload=function(){e(t.result)},t.onerror=function(){o(t.error)}}))}function h(t){var e=new FileReader,o=f(e);return e.readAsArrayBuffer(t),o}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:o.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():o.arrayBuffer&&o.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||r(t))?this._bodyArrayBuffer=p(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):o.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o.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(h)}),this.text=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,o=f(e);return e.readAsText(t),o}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),o=new Array(e.length),i=0;i<e.length;i++)o[i]=String.fromCharCode(e[i]);return o.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o.formData&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(t,e){t=n(t),e=a(e);var o=this.map[t];this.map[t]=o?o+", "+e:e},l.prototype.delete=function(t){delete this.map[n(t)]},l.prototype.get=function(t){return t=n(t),this.has(t)?this.map[t]:null},l.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},l.prototype.set=function(t,e){this.map[n(t)]=a(e)},l.prototype.forEach=function(t,e){for(var o in this.map)this.map.hasOwnProperty(o)&&t.call(e,this.map[o],o,this)},l.prototype.keys=function(){var t=[];return this.forEach((function(e,o){t.push(o)})),s(t)},l.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),s(t)},l.prototype.entries=function(){var t=[];return this.forEach((function(e,o){t.push([o,e])})),s(t)},o.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var u=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,e){var o,i,r=(e=e||{}).body;if(t instanceof y){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new l(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new l(e.headers)),this.method=(o=e.method||this.method||"GET",i=o.toUpperCase(),u.indexOf(i)>-1?i:o),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function b(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var o=t.split("="),i=o.shift().replace(/\+/g," "),r=o.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(r))}})),e}function g(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new l(e.headers),this.url=e.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},d.call(y.prototype),d.call(g.prototype),g.prototype.clone=function(){return new g(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},g.error=function(){var t=new g(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];g.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new g(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var o=Error(t);this.stack=o.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function m(t,i){return new Promise((function(r,n){var a=new y(t,i);if(a.signal&&a.signal.aborted)return n(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var t,e,o={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new l,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var o=t.split(":"),i=o.shift().trim();if(i){var r=o.join(":").trim();e.append(i,r)}})),e)};o.url="responseURL"in s?s.responseURL:o.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;r(new g(i,o))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.onabort=function(){n(new e.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&o.blob&&(s.responseType="blob"),a.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),a.signal&&(a.signal.addEventListener("abort",c),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",c)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}m.polyfill=!0,t.fetch||(t.fetch=m,t.Headers=l,t.Request=y,t.Response=g),e.Headers=l,e.Request=y,e.Response=g,e.fetch=m,Object.defineProperty(e,"W",{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"}(li||(li={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(ci||(ci={})),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"}(fi||(fi={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(hi||(hi={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(pi||(pi={})),function(t){t.ASC="ASC",t.DESC="DESC"}(di||(di={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(ui||(ui={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(yi||(yi={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(bi||(bi={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(gi||(gi={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(vi||(vi={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(mi||(mi={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS"}(xi||(xi={})),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.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"}(Oi||(Oi={})),Oi.PERSONAL_BOOK_SHARE_USER,Oi.PERSONAL_BOOK_USER,Oi.HTML_EXPORT_USER,Oi.PERSONAL_BOOK_USER,Oi.PDF_EXPORT_USER,Oi.PERSONAL_BOOK_USER,Oi.KHUB_ADMIN,Oi.CONTENT_PUBLISHER,Oi.ADMIN,Oi.KHUB_ADMIN,Oi.USERS_ADMIN,Oi.PORTAL_ADMIN,Oi.DEVELOPER,Oi.BETA_USER,Oi.DEBUG_USER;const wi=$`
129
129
  `,Si=Ko.get({name:"ft-app-info",reducers:{setBaseUrl:(t,e)=>{t.baseUrl=e.payload},setApiIntegrationIdentifier:(t,e)=>{t.apiIntegrationIdentifier=e.payload},setUiLocale:(t,e)=>{t.uiLocale=e.payload},setAvailableUiLocales:(t,e)=>{t.availableUiLocales=e.payload},setEditorMode:(t,e)=>{t.editorMode=e.payload},setNoCustom:(t,e)=>{t.noCustom=e.payload},setNoCustomComponent:(t,e)=>{t.noCustomComponent=e.payload},setSession:(t,e)=>{t.session=e.payload}},initialState:{uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],editorMode:!1,noCustom:!1,noCustomComponent:!1}});class Ni{static build(t){const{baseUrl:e,apiIntegrationIdentifier:o}=Si.getState(),i=null!=t?t:o;if(e&&i&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(e,i,!0)}static get(t){var e;return null!=t?Ni.build(t):null!==(e=Ni.API)&&void 0!==e?e:Ni.API=Ni.build()}static await(t){return new Promise((e=>{let o=Ni.get(t);if(o)e(o);else{const i=Si.subscribe((()=>{o=Ni.get(t),o&&(i(),e(o))}))}}))}}var $i;const Ci=Symbol("clearAfterUnitTest");class Ei{constructor(t){this.messageContextProvider=t,this.defaultMessages={},this.cache=new r,this.listeners={},this.currentUiLocale="",this[$i]=()=>{this.defaultMessages={},this.cache=new r,this.listeners={}},this.currentUiLocale=Si.getState().uiLocale,Si.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=Si.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const e=t.name.toLowerCase();this.cache.setFinal(e,t),this.notify(e)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,e){var o;if(t=t.toLowerCase(),Object.keys(e).length>0){const i={...null!==(o=this.defaultMessages[t])&&void 0!==o?o:{},...e};b(this.defaultMessages[t],i)||(this.defaultMessages[t]=i,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,e,...o){var i,r,n;t=t.toLowerCase(),this.fetchContext(t);const a=null!==(r=null===(i=this.cache.getNow(t))||void 0===i?void 0:i.messages)&&void 0!==r?r:{};return new Tt(null!==(n=this.defaultMessages[t])&&void 0!==n?n:{},a).resolve(e,...o)}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,e){var o;return t=t.toLowerCase(),this.listeners[t]=null!==(o=this.listeners[t])&&void 0!==o?o:new Set,this.listeners[t].add(e),()=>{var o;return null===(o=this.listeners[t])||void 0===o?void 0:o.delete(e)}}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=>u(0).then((()=>t())).catch((()=>null)))))}}$i=Ci,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new Ei((async(t,e)=>(await Ni.await()).getFluidTopicsMessageContext(t,e)))),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new Ei((async(t,e)=>(await Ni.await()).getCustomMessageContext(t,e))));const ki=window.FluidTopicsI18nService,Ri=window.FluidTopicsCustomI18nService;var Ii=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class Ui extends Kt{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.availableUiLocales=[],this.editorMode=!1,this.noCustom=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>Ni.get(),this.cache=new r,this.cleanSessionDebouncer=new n}render(){return rt`
130
130
  <slot></slot>
131
- `}update(t){super.update(t),t.has("baseUrl")&&Si.actions.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&Si.actions.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&Si.actions.setUiLocale(this.uiLocale),t.has("noCustom")&&Si.actions.setNoCustom(this.noCustom),t.has("editorMode")&&Si.actions.setEditorMode(this.editorMode),t.has("noCustomComponent")&&Si.actions.setNoCustomComponent(this.noCustomComponent),t.has("session")&&Si.actions.setSession(this.session),t.has("availableUiLocales")&&Si.actions.setAvailableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>ki.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){const t=this.apiProvider();!this.withManualResources&&t&&(null==this.session&&(this.session=await this.cache.get("session",(async()=>{const e=await t.getCurrentSession();return e.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),e.idleTimeoutInMillis),e}))),null==this.availableUiLocales&&(this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>t.getAvailableUiLocales()))))}}Ui.elementDefinitions={},Ui.styles=wi,Ii([s()],Ui.prototype,"baseUrl",void 0),Ii([s()],Ui.prototype,"apiIntegrationIdentifier",void 0),Ii([s()],Ui.prototype,"uiLocale",void 0),Ii([v([])],Ui.prototype,"availableUiLocales",void 0),Ii([s({type:Boolean})],Ui.prototype,"editorMode",void 0),Ii([s({type:Boolean})],Ui.prototype,"noCustom",void 0),Ii([s({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],Ui.prototype,"noCustomComponent",void 0),Ii([s({type:Boolean})],Ui.prototype,"withManualResources",void 0),Ii([v([])],Ui.prototype,"messageContexts",void 0),Ii([v(void 0)],Ui.prototype,"session",void 0),Ii([s({type:Object})],Ui.prototype,"apiProvider",void 0);class Li{async listMySearches(){var t;return(null===(t=Si.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await Ni.await()).listMySearches(Si.getState().session.profile.userId):[]}}const Wi=new r;class Ai{async listMyBookmarks(){return Wi.get("bookmarks",(async()=>(await Ni.await()).listMyBookmarks(Si.getState().session.profile.userId)))}clearCache(){Wi.clear("bookmarks")}}const ji=Ko.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const Fi=new class{constructor(){this.currentSession=Si.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new Ai,Si.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:e}=Si.getState();b(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==e?void 0:e.profile)||(this.currentSession=e,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){ji.actions.savedSearches(void 0)}clearMyBookmarks(){ji.actions.bookmarks(void 0)}async reloadMySearches(){const t=new Li,e=await t.listMySearches();ji.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const e=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;ji.actions.bookmarks(e)}}};g("ft-app-context")(Ui);class zi{static async build(){return new zi(await Ni.await())}constructor(t){this.api=t,this.cache=new r,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 Bi=t=>t.request.virtualField===yi.TITLE_ONLY&&t.request.scope===xi.DOCUMENTS;class Di extends Event{constructor(){super(Di.eventName)}}Di.eventName="search-context-clear-all-filters";class Ki{static build(t){return new Ki((t=>Ko.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:si}))(t.trim()||"context"),zi.build)}constructor(t,e){this.store=t,this.serviceProvider=e,this.searchDebouncer=new n(100),this.suggestDebouncer=new n(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){for(;null==this.service;)await u(5);return this.service}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let e=this.store.getState().locales,o=this.store.getState().request.contentLocale;if(t!=o){if(e){const i=t=>e.some((e=>e.lang==t));i(t)||(t=i(o)?o:e[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 e=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(e),this.store.actions.setPageNumber(1),e.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(yi.TITLE_ONLY),this.store.actions.setRequestScope(xi.DOCUMENTS)):(this.store.actions.setRequestVirtualField(yi.EVERYWHERE),this.store.actions.setRequestScope(xi.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return Bi(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new Di)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,e){let o=this.facetIds.filter((e=>e!=t));e&&o.push(e),this.facetIds=o,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let e=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(e)}setFilter(t,e){let o=this.store.getState().request.filters,i={key:t,values:e,negative:!1},r=[...o.filter((e=>e.key!==t)),i];this.setFilters(r)}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()}async launchSearch(){return await this.awaitService(),this.searchDebouncer.run((()=>this.fetchSearchData()))}async launchSuggest(){await this.awaitService(),this.suggestDebouncer.run((()=>this.fetchSuggestData()))}async fetchSearchData(){var t,o;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel(),this.cancelableSearch=i(this.service.launchSearch(this.store.getState().request));const e=await this.cancelableSearch;if(e.paging.currentPage<=1)this.store.actions.setResults(e.results),this.store.actions.setFacets(e.facets),this.store.actions.setSpellcheck(e.spellcheck);else{let t=(null!==(o=this.store.getState().results)&&void 0!==o?o:[]).concat(e.results);this.store.actions.setResults(t)}this.store.actions.setPaging(e.paging)}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{let e={input:this.store.getState().liveQuery,filters:this.store.getState().request.filters,sort:this.store.getState().request.sort,contentLocale:this.store.getState().request.contentLocale};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=i(this.service.launchSuggest(e));let o=await this.cancelableSuggest;this.store.actions.setSuggestResults(o.suggestions)}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}}var Pi=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class Mi extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const Ti=Symbol("registerInterval");class Zi extends(function(t){var e;class o extends t{constructor(){super(...arguments),this[e]=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[Ti]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[Ti]):this.dispatchEvent(new Mi)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return e=Ti,Pi([l()],o.prototype,"stateManager",void 0),o}(Xt)){}
131
+ `}update(t){super.update(t),t.has("baseUrl")&&Si.actions.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&Si.actions.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&Si.actions.setUiLocale(this.uiLocale),t.has("noCustom")&&Si.actions.setNoCustom(this.noCustom),t.has("editorMode")&&Si.actions.setEditorMode(this.editorMode),t.has("noCustomComponent")&&Si.actions.setNoCustomComponent(this.noCustomComponent),t.has("session")&&Si.actions.setSession(this.session),t.has("availableUiLocales")&&Si.actions.setAvailableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>ki.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){const t=this.apiProvider();!this.withManualResources&&t&&(null==this.session&&(this.session=await this.cache.get("session",(async()=>{const e=await t.getCurrentSession();return e.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),e.idleTimeoutInMillis),e}))),null==this.availableUiLocales&&(this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>t.getAvailableUiLocales()))))}}Ui.elementDefinitions={},Ui.styles=wi,Ii([s()],Ui.prototype,"baseUrl",void 0),Ii([s()],Ui.prototype,"apiIntegrationIdentifier",void 0),Ii([s()],Ui.prototype,"uiLocale",void 0),Ii([v([])],Ui.prototype,"availableUiLocales",void 0),Ii([s({type:Boolean})],Ui.prototype,"editorMode",void 0),Ii([s({type:Boolean})],Ui.prototype,"noCustom",void 0),Ii([s({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],Ui.prototype,"noCustomComponent",void 0),Ii([s({type:Boolean})],Ui.prototype,"withManualResources",void 0),Ii([v([])],Ui.prototype,"messageContexts",void 0),Ii([v(void 0)],Ui.prototype,"session",void 0),Ii([s({type:Object})],Ui.prototype,"apiProvider",void 0);class Li{async listMySearches(){var t;return(null===(t=Si.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await Ni.await()).listMySearches(Si.getState().session.profile.userId):[]}}const Wi=new r;class Ai{async listMyBookmarks(){return Wi.get("bookmarks",(async()=>(await Ni.await()).listMyBookmarks(Si.getState().session.profile.userId)))}clearCache(){Wi.clear("bookmarks")}}const ji=Ko.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const Fi=new class{constructor(){this.currentSession=Si.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new Ai,Si.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:e}=Si.getState();b(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==e?void 0:e.profile)||(this.currentSession=e,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){ji.actions.savedSearches(void 0)}clearMyBookmarks(){ji.actions.bookmarks(void 0)}async reloadMySearches(){const t=new Li,e=await t.listMySearches();ji.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const e=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;ji.actions.bookmarks(e)}}};g("ft-app-context")(Ui);class zi{static async build(){return new zi(await Ni.await())}constructor(t){this.api=t,this.cache=new r,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 Bi=t=>t.request.virtualField===yi.TITLE_ONLY&&t.request.scope===xi.DOCUMENTS;class Di extends Event{constructor(){super(Di.eventName)}}Di.eventName="search-context-clear-all-filters";class Ki{static build(t){return new Ki((t=>Ko.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:si}))(t.trim()||"context"),zi.build)}constructor(t,e){this.store=t,this.serviceProvider=e,this.searchDebouncer=new n(100),this.suggestDebouncer=new n(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){for(;null==this.service;)await u(5);return this.service}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let e=this.store.getState().locales,o=this.store.getState().request.contentLocale;if(t!=o){if(e){const i=t=>e.some((e=>e.lang==t));i(t)||(t=i(o)?o:e[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 e=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(e),this.store.actions.setPageNumber(1),e.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(yi.TITLE_ONLY),this.store.actions.setRequestScope(xi.DOCUMENTS)):(this.store.actions.setRequestVirtualField(yi.EVERYWHERE),this.store.actions.setRequestScope(xi.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return Bi(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new Di)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,e){let o=this.facetIds.filter((e=>e!=t));e&&o.push(e),this.facetIds=o,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let e=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(e)}setFilter(t,e){let o=this.store.getState().request.filters,i={key:t,values:e,negative:!1},r=[...o.filter((e=>e.key!==t)),i];this.setFilters(r)}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()}async launchSearch(){return await this.awaitService(),this.searchDebouncer.run((()=>this.fetchSearchData()))}async launchSuggest(){await this.awaitService(),this.suggestDebouncer.run((()=>this.fetchSuggestData()))}async fetchSearchData(){var t,o;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel(),this.cancelableSearch=i(this.service.launchSearch(this.store.getState().request));const e=await this.cancelableSearch;if(e.paging.currentPage<=1)this.store.actions.setResults(e.results),this.store.actions.setFacets(e.facets),this.store.actions.setSpellcheck(e.spellcheck);else{let t=(null!==(o=this.store.getState().results)&&void 0!==o?o:[]).concat(e.results);this.store.actions.setResults(t)}this.store.actions.setPaging(e.paging)}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const e=this.store.getState(),o=e.request,r={input:e.liveQuery,filters:o.filters,sort:o.sort,contentLocale:o.contentLocale,scope:o.scope};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=i(this.service.launchSuggest(r));let n=await this.cancelableSuggest;this.store.actions.setSuggestResults(n.suggestions)}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}}var Pi=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class Mi extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const Ti=Symbol("registerInterval");class Zi extends(function(t){var e;class o extends t{constructor(){super(...arguments),this[e]=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[Ti]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[Ti]):this.dispatchEvent(new Mi)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return e=Ti,Pi([l()],o.prototype,"stateManager",void 0),o}(Xt)){}
132
132
  /**
133
133
  * @license
134
134
  * Copyright 2018 Google LLC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-search-selected-facets",
3
- "version": "1.0.62",
3
+ "version": "1.0.63",
4
4
  "description": "List of selected facets in a designed search page context",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,12 +19,12 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-chip": "1.0.62",
23
- "@fluid-topics/ft-search-context": "1.0.62",
24
- "@fluid-topics/ft-search-type": "1.0.62",
25
- "@fluid-topics/ft-tooltip": "1.0.62",
26
- "@fluid-topics/ft-wc-utils": "1.0.62",
22
+ "@fluid-topics/ft-chip": "1.0.63",
23
+ "@fluid-topics/ft-search-context": "1.0.63",
24
+ "@fluid-topics/ft-search-type": "1.0.63",
25
+ "@fluid-topics/ft-tooltip": "1.0.63",
26
+ "@fluid-topics/ft-wc-utils": "1.0.63",
27
27
  "lit": "2.7.2"
28
28
  },
29
- "gitHead": "44e9005773fe47b2e6a9ada16802918052a146cf"
29
+ "gitHead": "020d13bf82a28437f4d7a7395ad9b628bc4342f1"
30
30
  }