@fluid-topics/ft-reader-search-in-document 1.1.30 → 1.1.31

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.
@@ -1055,7 +1055,7 @@ const Zo=Symbol.for(""),Do=t=>{if(t?.r===Zo)return t?._$litStatic$},Fo=t=>({_$li
1055
1055
  ${this.i18n(this.context,this.key,...Array.isArray(this.args)?this.args:[])}
1056
1056
  </span>
1057
1057
  `:this.editorMode?"Select a context and a label key.":e.nothing}update(t){var o;super.update(t),this.context&&this.key&&this.addI18nMessages(this.context,{[this.key]:null!==(o=this.defaultMessage)&&void 0!==o?o:""})}}Mr.elementDefinitions={},Mr.styles=Or,Hr([o.redux()],Mr.prototype,"editorMode",void 0),Hr([r.property()],Mr.prototype,"context",void 0),Hr([r.property()],Mr.prototype,"key",void 0),Hr([o.jsonProperty([])],Mr.prototype,"args",void 0),Hr([r.property()],Mr.prototype,"defaultMessage",void 0);class jr{static build(t){return new jr(t)}static fromGwt(t){return new jr(t)}constructor(t){this.name=t,this.properties=new Proxy({},{get:(t,o)=>{const e=o;return t=>({context:this.name,key:e,args:"function"==typeof t?void 0:t,argsProvider:"function"==typeof t?t:void 0})}}),this.messages=new Proxy({},{get:(t,o)=>(...t)=>Ir.resolveMessage(this.name,o,...t)})}}o.customElement("ft-i18n")(Mr);const Gr=e.css`
1058
- `,_r={setRequest:(t,o)=>{t.request=o.payload},setRequestQuery:(t,o)=>{t.request.query=o.payload},setRequestContentLocale:(t,o)=>{t.request.contentLocale=o.payload},setPageSize:(t,o)=>{t.request.paging.perPage=o.payload},setPageNumber:(t,o)=>{t.request.paging.page=o.payload},setRequestSort:(t,o)=>{t.request.sort=o.payload},setRequestFilters:(t,o)=>{t.request.filters=o.payload},setRequestFacets:(t,o)=>{t.request.facets=o.payload},setRequestVirtualField:(t,o)=>{t.request.virtualField=o.payload},setRequestScope:(t,o)=>{t.request.scope=o.payload},setResults:(t,o)=>{t.results=o.payload},setFacets:(t,o)=>{t.facets=o.payload},setSpellcheck:(t,o)=>{t.spellcheck=o.payload},setLocales:(t,o)=>{t.locales=o.payload},setPaging:(t,o)=>{t.paging=o.payload},setLiveQuery:(t,o)=>{t.liveQuery=o.payload},setSuggestResults:(t,o)=>{t.suggestResults=o.payload}};var qr,Yr,Vr,Qr,Xr,Jr,ti,oi,ei,ri,ii,ni,ai,si,li,ci,pi,fi;!function(t){!function(o){var e={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(e.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&r.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 o={next:function(){var o=t.shift();return{done:void 0===o,value:o}}};return e.iterable&&(o[Symbol.iterator]=function(){return o}),o}function l(t){this.map={},t instanceof l?t.forEach((function(t,o){this.append(o,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(o){this.append(o,t[o])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(o,e){t.onload=function(){o(t.result)},t.onerror=function(){e(t.error)}}))}function f(t){var o=new FileReader,e=p(o);return o.readAsArrayBuffer(t),e}function h(t){if(t.slice)return t.slice(0);var o=new Uint8Array(t.byteLength);return o.set(new Uint8Array(t)),o.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var o;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:e.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:e.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():e.arrayBuffer&&e.blob&&((o=t)&&DataView.prototype.isPrototypeOf(o))?(this._bodyArrayBuffer=h(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):e.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=h(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):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.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(f)}),this.text=function(){var t,o,e,r=c(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,o=new FileReader,e=p(o),o.readAsText(t),e;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var o=new Uint8Array(t),e=new Array(o.length),r=0;r<o.length;r++)e[r]=String.fromCharCode(o[r]);return e.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(t,o){t=n(t),o=a(o);var e=this.map[t];this.map[t]=e?e+", "+o:o},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,o){this.map[n(t)]=a(o)},l.prototype.forEach=function(t,o){for(var e in this.map)this.map.hasOwnProperty(e)&&t.call(o,this.map[e],e,this)},l.prototype.keys=function(){var t=[];return this.forEach((function(o,e){t.push(e)})),s(t)},l.prototype.values=function(){var t=[];return this.forEach((function(o){t.push(o)})),s(t)},l.prototype.entries=function(){var t=[];return this.forEach((function(o,e){t.push([e,o])})),s(t)},e.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var u=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function g(t,o){var e,r,i=(o=o||{}).body;if(t instanceof g){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,o.headers||(this.headers=new l(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=o.credentials||this.credentials||"same-origin",!o.headers&&this.headers||(this.headers=new l(o.headers)),this.method=(e=o.method||this.method||"GET",r=e.toUpperCase(),u.indexOf(r)>-1?r:e),this.mode=o.mode||this.mode||null,this.signal=o.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function y(t){var o=new FormData;return t.trim().split("&").forEach((function(t){if(t){var e=t.split("="),r=e.shift().replace(/\+/g," "),i=e.join("=").replace(/\+/g," ");o.append(decodeURIComponent(r),decodeURIComponent(i))}})),o}function b(t,o){o||(o={}),this.type="default",this.status=void 0===o.status?200:o.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in o?o.statusText:"OK",this.headers=new l(o.headers),this.url=o.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,o){if(-1===m.indexOf(o))throw new RangeError("Invalid status code");return new b(null,{status:o,headers:{location:t}})},o.DOMException=t.DOMException;try{new o.DOMException}catch(t){o.DOMException=function(t,o){this.message=t,this.name=o;var e=Error(t);this.stack=e.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function x(t,r){return new Promise((function(i,n){var a=new g(t,r);if(a.signal&&a.signal.aborted)return n(new o.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var t,o,e={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",o=new l,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var e=t.split(":"),r=e.shift().trim();if(r){var i=e.join(":").trim();o.append(r,i)}})),o)};e.url="responseURL"in s?s.responseURL:e.headers.get("X-Request-URL");var r="response"in s?s.response:s.responseText;i(new b(r,e))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.onabort=function(){n(new o.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&&e.blob&&(s.responseType="blob"),a.headers.forEach((function(t,o){s.setRequestHeader(o,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)}))}x.polyfill=!0,t.fetch||(t.fetch=x,t.Headers=l,t.Request=g,t.Response=b),o.Headers=l,o.Request=g,o.Response=b,o.fetch=x,Object.defineProperty(o,"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"}(qr||(qr={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(Yr||(Yr={})),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"}(Vr||(Vr={})),function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"}(Qr||(Qr={})),function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"}(Xr||(Xr={})),function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"}(Jr||(Jr={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(ti||(ti={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(oi||(oi={})),function(t){t.ASC="ASC",t.DESC="DESC"}(ei||(ei={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(ri||(ri={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(ii||(ii={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(ni||(ni={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(ai||(ai={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(si||(si={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(li||(li={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS"}(ci||(ci={})),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"}(pi||(pi={})),function(t){t.VALID="VALID",t.INVALID="INVALID"}(fi||(fi={})),pi.PERSONAL_BOOK_SHARE_USER,pi.PERSONAL_BOOK_USER,pi.HTML_EXPORT_USER,pi.PERSONAL_BOOK_USER,pi.PDF_EXPORT_USER,pi.PERSONAL_BOOK_USER,pi.KHUB_ADMIN,pi.CONTENT_PUBLISHER,pi.ADMIN,pi.KHUB_ADMIN,pi.USERS_ADMIN,pi.PORTAL_ADMIN,pi.DEVELOPER,pi.BETA_USER,pi.DEBUG_USER;class hi{static async build(){return new hi(await Sr.await())}constructor(t){this.api=t,this.cache=new o.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")}}class di extends Event{constructor(){super(di.eventName)}}di.eventName="search-context-clear-all-filters";class ui{static build(t){return new ui((t=>o.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:_r}))(t.trim()||"context"),hi.build)}constructor(t,e){this.store=t,this.serviceProvider=e,this.ignoreEmptyQuery=!1,this.searchDebouncer=new o.Debouncer(100),this.suggestDebouncer=new o.Debouncer(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){return o.waitFor((()=>this.service))}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let o=this.store.getState().locales,e=this.store.getState().request.contentLocale;if(t!=e){if(o){const r=t=>o.some((o=>o.lang==t));r(t)||(t=r(e)?e:o[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 o=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(o),this.store.actions.setPageNumber(1),o.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(ii.TITLE_ONLY),this.store.actions.setRequestScope(ci.DOCUMENTS)):(this.store.actions.setRequestVirtualField(ii.EVERYWHERE),this.store.actions.setRequestScope(ci.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return(t=>t.request.virtualField===ii.TITLE_ONLY&&t.request.scope===ci.DOCUMENTS)(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new di)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,o){let e=this.facetIds.filter((o=>o!=t));o&&e.push(o),this.facetIds=e,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let o=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(o)}setFilter(t,o){let e=this.store.getState().request.filters,r={key:t,values:o,negative:!1},i=[...e.filter((o=>o.key!==t)),r];this.setFilters(i)}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()}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,e;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel();let r=this.store.getState().request;if(this.store.actions.setPaging(void 0),this.ignoreEmptyQuery&&0==r.query.length)this.store.actions.setResults(void 0),this.store.actions.setFacets(void 0),this.store.actions.setSpellcheck(void 0);else{this.cancelableSearch=o.cancelable(this.service.launchSearch(r));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 o=(null!==(e=this.store.getState().results)&&void 0!==e?e:[]).concat(t.results);this.store.actions.setResults(o)}this.store.actions.setPaging(t.paging)}}catch(t){t instanceof o.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const e=this.store.getState(),r=e.request,i={input:e.liveQuery,filters:r.filters,sort:r.sort,contentLocale:r.contentLocale,scope:r.scope};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=o.cancelable(this.service.launchSuggest(i));let n=await this.cancelableSuggest;this.store.actions.setSuggestResults(n.suggestions)}catch(t){t instanceof o.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}clear(){this.store.clear()}}var gi=function(t,o,e,r){for(var i,n=arguments.length,a=n<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r,s=t.length-1;s>=0;s--)(i=t[s])&&(a=(n<3?i(a):n>3?i(o,e,a):i(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};class yi extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const bi=Symbol("registerInterval");class mi extends(function(t){var o;class e extends t{constructor(){super(...arguments),this[o]=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[bi]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[bi]):this.dispatchEvent(new yi)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return o=bi,gi([r.state()],e.prototype,"stateManager",void 0),e}(o.FtLitElementRedux)){}var xi,vi=function(t,o,e,r){for(var i,n=arguments.length,a=n<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r,s=t.length-1;s>=0;s--)(i=t[s])&&(a=(n<3?i(a):n>3?i(o,e,a):i(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};class Oi extends CustomEvent{constructor(t){super("ft-search-load-error",{detail:t})}}class Ni extends CustomEvent{constructor(t){super("ft-search-request-change",{detail:t})}}class wi extends CustomEvent{constructor(t,o,e){super("ft-search-results-change",{detail:{request:t,paging:o,spellcheck:e}})}}class Si extends o.FtLitElementRedux{get stateManager(){return null==this._stateManager&&(this._stateManager=ui.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0")),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store,"search")),this._stateManager}constructor(){super(),this.query="",this.pageSize=20,this.searchInDocumentTitlesOnly=!1,this.ignoreEmptyQuery=!1,this.filters=[],this.sort=[],this.addStore(wr)}render(){return e.html`
1058
+ `,_r={setRequest:(t,o)=>{t.request=o.payload},setRequestQuery:(t,o)=>{t.request.query=o.payload},setRequestContentLocale:(t,o)=>{t.request.contentLocale=o.payload},setPageSize:(t,o)=>{t.request.paging.perPage=o.payload},setPageNumber:(t,o)=>{t.request.paging.page=o.payload},setRequestSort:(t,o)=>{t.request.sort=o.payload},setRequestFilters:(t,o)=>{t.request.filters=o.payload},setRequestFacets:(t,o)=>{t.request.facets=o.payload},setRequestVirtualField:(t,o)=>{t.request.virtualField=o.payload},setRequestScope:(t,o)=>{t.request.scope=o.payload},setResults:(t,o)=>{t.results=o.payload},setFacets:(t,o)=>{t.facets=o.payload},setSpellcheck:(t,o)=>{t.spellcheck=o.payload},setLocales:(t,o)=>{t.locales=o.payload},setPaging:(t,o)=>{t.paging=o.payload},setLiveQuery:(t,o)=>{t.liveQuery=o.payload},setSuggestResults:(t,o)=>{t.suggestResults=o.payload}};var qr,Yr,Vr,Qr,Xr,Jr,ti,oi,ei,ri,ii,ni,ai,si,li,ci,pi,fi;!function(t){!function(o){var e={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(e.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&r.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 o={next:function(){var o=t.shift();return{done:void 0===o,value:o}}};return e.iterable&&(o[Symbol.iterator]=function(){return o}),o}function l(t){this.map={},t instanceof l?t.forEach((function(t,o){this.append(o,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(o){this.append(o,t[o])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(o,e){t.onload=function(){o(t.result)},t.onerror=function(){e(t.error)}}))}function f(t){var o=new FileReader,e=p(o);return o.readAsArrayBuffer(t),e}function h(t){if(t.slice)return t.slice(0);var o=new Uint8Array(t.byteLength);return o.set(new Uint8Array(t)),o.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var o;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:e.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:e.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():e.arrayBuffer&&e.blob&&((o=t)&&DataView.prototype.isPrototypeOf(o))?(this._bodyArrayBuffer=h(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):e.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=h(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):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.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(f)}),this.text=function(){var t,o,e,r=c(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,o=new FileReader,e=p(o),o.readAsText(t),e;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var o=new Uint8Array(t),e=new Array(o.length),r=0;r<o.length;r++)e[r]=String.fromCharCode(o[r]);return e.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(t,o){t=n(t),o=a(o);var e=this.map[t];this.map[t]=e?e+", "+o:o},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,o){this.map[n(t)]=a(o)},l.prototype.forEach=function(t,o){for(var e in this.map)this.map.hasOwnProperty(e)&&t.call(o,this.map[e],e,this)},l.prototype.keys=function(){var t=[];return this.forEach((function(o,e){t.push(e)})),s(t)},l.prototype.values=function(){var t=[];return this.forEach((function(o){t.push(o)})),s(t)},l.prototype.entries=function(){var t=[];return this.forEach((function(o,e){t.push([e,o])})),s(t)},e.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var u=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function g(t,o){var e,r,i=(o=o||{}).body;if(t instanceof g){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,o.headers||(this.headers=new l(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=o.credentials||this.credentials||"same-origin",!o.headers&&this.headers||(this.headers=new l(o.headers)),this.method=(e=o.method||this.method||"GET",r=e.toUpperCase(),u.indexOf(r)>-1?r:e),this.mode=o.mode||this.mode||null,this.signal=o.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function y(t){var o=new FormData;return t.trim().split("&").forEach((function(t){if(t){var e=t.split("="),r=e.shift().replace(/\+/g," "),i=e.join("=").replace(/\+/g," ");o.append(decodeURIComponent(r),decodeURIComponent(i))}})),o}function b(t,o){o||(o={}),this.type="default",this.status=void 0===o.status?200:o.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in o?o.statusText:"OK",this.headers=new l(o.headers),this.url=o.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,o){if(-1===m.indexOf(o))throw new RangeError("Invalid status code");return new b(null,{status:o,headers:{location:t}})},o.DOMException=t.DOMException;try{new o.DOMException}catch(t){o.DOMException=function(t,o){this.message=t,this.name=o;var e=Error(t);this.stack=e.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function x(t,r){return new Promise((function(i,n){var a=new g(t,r);if(a.signal&&a.signal.aborted)return n(new o.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var t,o,e={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",o=new l,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var e=t.split(":"),r=e.shift().trim();if(r){var i=e.join(":").trim();o.append(r,i)}})),o)};e.url="responseURL"in s?s.responseURL:e.headers.get("X-Request-URL");var r="response"in s?s.response:s.responseText;i(new b(r,e))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.onabort=function(){n(new o.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&&e.blob&&(s.responseType="blob"),a.headers.forEach((function(t,o){s.setRequestHeader(o,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)}))}x.polyfill=!0,t.fetch||(t.fetch=x,t.Headers=l,t.Request=g,t.Response=b),o.Headers=l,o.Request=g,o.Response=b,o.fetch=x,Object.defineProperty(o,"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"}(qr||(qr={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(Yr||(Yr={})),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"}(Vr||(Vr={})),function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"}(Qr||(Qr={})),function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"}(Xr||(Xr={})),function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"}(Jr||(Jr={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(ti||(ti={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(oi||(oi={})),function(t){t.ASC="ASC",t.DESC="DESC"}(ei||(ei={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(ri||(ri={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(ii||(ii={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(ni||(ni={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(ai||(ai={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(si||(si={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(li||(li={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS"}(ci||(ci={})),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"}(pi||(pi={})),function(t){t.VALID="VALID",t.INVALID="INVALID"}(fi||(fi={})),pi.PERSONAL_BOOK_SHARE_USER,pi.PERSONAL_BOOK_USER,pi.HTML_EXPORT_USER,pi.PERSONAL_BOOK_USER,pi.PDF_EXPORT_USER,pi.PERSONAL_BOOK_USER,pi.KHUB_ADMIN,pi.CONTENT_PUBLISHER,pi.ADMIN,pi.KHUB_ADMIN,pi.USERS_ADMIN,pi.PORTAL_ADMIN,pi.DEVELOPER,pi.BETA_USER,pi.DEBUG_USER;class hi{static async build(){return new hi(await Sr.await())}constructor(t){this.api=t,this.cache=new o.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")}}class di extends Event{constructor(){super(di.eventName)}}di.eventName="search-context-clear-all-filters";class ui{static build(t){return new ui((t=>o.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:_r}))(t.trim()||"context"),hi.build)}constructor(t,e){this.store=t,this.serviceProvider=e,this.ignoreEmptyQuery=!1,this.searchDebouncer=new o.Debouncer(100),this.suggestDebouncer=new o.Debouncer(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){return o.waitFor((()=>this.service))}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let o=this.store.getState().locales,e=this.store.getState().request.contentLocale;if(t!=e){if(o){const r=t=>o.some((o=>o.lang==t));r(t)||(t=r(e)?e:o[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 o=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(o),this.store.actions.setPageNumber(1),o.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(ii.TITLE_ONLY),this.store.actions.setRequestScope(ci.DOCUMENTS)):(this.store.actions.setRequestVirtualField(ii.EVERYWHERE),this.store.actions.setRequestScope(ci.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return(t=>t.request.virtualField===ii.TITLE_ONLY&&t.request.scope===ci.DOCUMENTS)(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new di)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,o){let e=this.facetIds.filter((o=>o!=t));o&&e.push(o),this.facetIds=e,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let o=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(o)}setFilter(t,o){let e=this.store.getState().request.filters,r={key:t,values:o,negative:!1},i=[...e.filter((o=>o.key!==t)),r];this.setFilters(i)}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()}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,e;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel();let r=this.store.getState().request;if(this.store.actions.setPaging(void 0),this.ignoreEmptyQuery&&0==r.query.length)this.store.actions.setResults(void 0),this.store.actions.setFacets(void 0),this.store.actions.setSpellcheck(void 0);else{this.cancelableSearch=o.cancelable(this.service.launchSearch(r));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 o=(null!==(e=this.store.getState().results)&&void 0!==e?e:[]).concat(t.results);this.store.actions.setResults(o)}this.store.actions.setPaging(t.paging)}}catch(t){t instanceof o.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const e=this.store.getState(),r=e.request,i={input:e.liveQuery,filters:r.filters,sort:r.sort,contentLocale:r.contentLocale,scope:r.scope};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=o.cancelable(this.service.launchSuggest(i));let n=await this.cancelableSuggest;this.store.actions.setSuggestResults(n.suggestions)}catch(t){t instanceof o.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}clear(){this.store.clear()}}var gi=function(t,o,e,r){for(var i,n=arguments.length,a=n<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r,s=t.length-1;s>=0;s--)(i=t[s])&&(a=(n<3?i(a):n>3?i(o,e,a):i(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};class yi extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const bi=Symbol("registerInterval");class mi extends(function(t){var o;class e extends t{constructor(){super(...arguments),this[o]=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[bi]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[bi]):this.dispatchEvent(new yi)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return o=bi,gi([r.state()],e.prototype,"stateManager",void 0),e}(o.FtLitElementRedux)){}var xi,vi=function(t,o,e,r){for(var i,n=arguments.length,a=n<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r,s=t.length-1;s>=0;s--)(i=t[s])&&(a=(n<3?i(a):n>3?i(o,e,a):i(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};class Oi extends CustomEvent{constructor(t){super("ft-search-load-error",{detail:t})}}class Ni extends CustomEvent{constructor(t){super("ft-search-request-change",{detail:t})}}class wi extends CustomEvent{constructor(t,o,e){super("ft-search-results-change",{detail:{request:t,paging:o,spellcheck:e}})}}class Si extends o.FtLitElementRedux{get stateManager(){return null==this._stateManager&&(this._stateManager=ui.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0")),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store,"search")),this._stateManager}constructor(){super(),this.query="",this.pageSize=20,this.searchInDocumentTitlesOnly=!1,this.ignoreEmptyQuery=!1,this.filters=[],this.sort=[],this.addStore(wr)}render(){return e.html`
1059
1059
  <slot @register-ft-search-component=${this.registerComponent}></slot>
1060
1060
  `}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)}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 Ni(this.request)),t.has("paging")&&void 0!==this.paging&&this.dispatchEvent(new wi(this.request,this.paging,this.autocorrect))}registerComponent(t){t.stopPropagation();const o=t.composedPath()[0];this.register(o)}register(t){t.setSearchStateManager(this.stateManager)}handleLoadError(t){this.dispatchEvent(new Oi(t))}reloadSavedSearches(){Br.clearMySearches()}clear(){this.stateManager.clear()}}Si.elementDefinitions={},Si.styles=Gr,vi([r.property()],Si.prototype,"query",void 0),vi([r.property()],Si.prototype,"contentLocale",void 0),vi([r.property({type:Number})],Si.prototype,"pageSize",void 0),vi([r.property({type:Boolean})],Si.prototype,"searchInDocumentTitlesOnly",void 0),vi([r.property()],Si.prototype,"scope",void 0),vi([r.property({type:Boolean})],Si.prototype,"ignoreEmptyQuery",void 0),vi([o.jsonProperty([])],Si.prototype,"filters",void 0),vi([o.jsonProperty([])],Si.prototype,"sort",void 0),vi([o.redux({store:"search"})],Si.prototype,"request",void 0),vi([o.redux({store:"search"})],Si.prototype,"paging",void 0),vi([o.redux({store:"search",selector:t=>t.spellcheck})],Si.prototype,"autocorrect",void 0),vi([o.redux({store:wr.name})],Si.prototype,"session",void 0),o.customElement("ft-search-context")(Si),function(t){t.FEEDBACK="FEEDBACK",t.RATING="RATING",t.PRINT="PRINT",t.BOOKMARK="BOOKMARK",t.COLLECTIONS="COLLECTIONS",t.PERSONAL_BOOKS="PERSONAL_BOOKS"}(xi||(xi={}));var Ci=function(t,o,e,r){for(var i,n=arguments.length,a=n<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r,s=t.length-1;s>=0;s--)(i=t[s])&&(a=(n<3?i(a):n>3?i(o,e,a):i(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};class $i extends Event{constructor(){super("register-ft-reader-component",{bubbles:!0,composed:!0})}}const Ei=Symbol("registerInterval");class Ii extends(function(t){var o;class e extends t{constructor(){super(...arguments),this[o]=0}setReaderStateManager(t){this.clearStateManager(),this.stateManager=t,this.addStore(t.store,"reader")}clearStateManager(){this.stateManager&&(this.removeStore("reader"),this.stateManager=void 0)}get service(){var t;return null===(t=this.stateManager)||void 0===t?void 0:t.service}connectedCallback(){super.connectedCallback(),this[Ei]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[Ei]):this.dispatchEvent(new $i)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return o=Ei,Ci([r.state()],e.prototype,"stateManager",void 0),e}(o.FtLitElementRedux)){}const Ri=e.css`
1061
1061
 
@@ -1190,7 +1190,7 @@ class as extends Za{constructor(t){if(super(t),this.et=at,t.type!==Ta)throw Erro
1190
1190
  ${this.i18n(this.context,this.key,...Array.isArray(this.args)?this.args:[])}
1191
1191
  </span>
1192
1192
  `:this.editorMode?"Select a context and a label key.":ue}update(t){var e;super.update(t),this.context&&this.key&&this.addI18nMessages(this.context,{[this.key]:null!==(e=this.defaultMessage)&&void 0!==e?e:""})}}ec.elementDefinitions={},ec.styles=Ls,tc([Xo()],ec.prototype,"editorMode",void 0),tc([k()],ec.prototype,"context",void 0),tc([k()],ec.prototype,"key",void 0),tc([K([])],ec.prototype,"args",void 0),tc([k()],ec.prototype,"defaultMessage",void 0);class oc{static build(t){return new oc(t)}static fromGwt(t){return new oc(t)}constructor(t){this.name=t,this.properties=new Proxy({},{get:(t,e)=>{const o=e;return t=>({context:this.name,key:o,args:"function"==typeof t?void 0:t,argsProvider:"function"==typeof t?t:void 0})}}),this.messages=new Proxy({},{get:(t,e)=>(...t)=>Ds.resolveMessage(this.name,e,...t)})}}j("ft-i18n")(ec);const rc=Rt`
1193
- `,ic={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 nc,ac,sc,cc,lc,fc,hc,uc,pc,dc,yc,gc,bc,mc,vc,xc,Oc,wc;!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 r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&r.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 c(t){this.map={},t instanceof c?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 l(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 u(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function p(){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=u(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=u(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=l(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?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(h)}),this.text=function(){var t=l(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),r=0;r<e.length;r++)o[r]=String.fromCharCode(e[r]);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(g)}),this.json=function(){return this.text().then(JSON.parse)},this}c.prototype.append=function(t,e){t=n(t),e=a(e);var o=this.map[t];this.map[t]=o?o+", "+e:e},c.prototype.delete=function(t){delete this.map[n(t)]},c.prototype.get=function(t){return t=n(t),this.has(t)?this.map[t]:null},c.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},c.prototype.set=function(t,e){this.map[n(t)]=a(e)},c.prototype.forEach=function(t,e){for(var o in this.map)this.map.hasOwnProperty(o)&&t.call(e,this.map[o],o,this)},c.prototype.keys=function(){var t=[];return this.forEach((function(e,o){t.push(o)})),s(t)},c.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),s(t)},c.prototype.entries=function(){var t=[];return this.forEach((function(e,o){t.push([o,e])})),s(t)},o.iterable&&(c.prototype[Symbol.iterator]=c.prototype.entries);var d=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,e){var o,r,i=(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 c(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=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 c(e.headers)),this.method=(o=e.method||this.method||"GET",r=o.toUpperCase(),d.indexOf(r)>-1?r:o),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var o=t.split("="),r=o.shift().replace(/\+/g," "),i=o.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}})),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 c(e.headers),this.url=e.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},p.call(y.prototype),p.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new c(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,r){return new Promise((function(i,n){var a=new y(t,r);if(a.signal&&a.signal.aborted)return n(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function l(){s.abort()}s.onload=function(){var t,e,o={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new c,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var o=t.split(":"),r=o.shift().trim();if(r){var i=o.join(":").trim();e.append(r,i)}})),e)};o.url="responseURL"in s?s.responseURL:o.headers.get("X-Request-URL");var r="response"in s?s.response:s.responseText;i(new b(r,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",l),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",l)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}v.polyfill=!0,t.fetch||(t.fetch=v,t.Headers=c,t.Request=y,t.Response=b),e.Headers=c,e.Request=y,e.Response=b,e.fetch=v,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"}(nc||(nc={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(ac||(ac={})),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"}(sc||(sc={})),function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"}(cc||(cc={})),function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"}(lc||(lc={})),function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"}(fc||(fc={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(hc||(hc={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(uc||(uc={})),function(t){t.ASC="ASC",t.DESC="DESC"}(pc||(pc={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(dc||(dc={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(yc||(yc={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(gc||(gc={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(bc||(bc={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(mc||(mc={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(vc||(vc={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS"}(xc||(xc={})),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"}(Oc||(Oc={})),function(t){t.VALID="VALID",t.INVALID="INVALID"}(wc||(wc={})),Oc.PERSONAL_BOOK_SHARE_USER,Oc.PERSONAL_BOOK_USER,Oc.HTML_EXPORT_USER,Oc.PERSONAL_BOOK_USER,Oc.PDF_EXPORT_USER,Oc.PERSONAL_BOOK_USER,Oc.KHUB_ADMIN,Oc.CONTENT_PUBLISHER,Oc.ADMIN,Oc.KHUB_ADMIN,Oc.USERS_ADMIN,Oc.PORTAL_ADMIN,Oc.DEVELOPER,Oc.BETA_USER,Oc.DEBUG_USER;class Sc{static async build(){return new Sc(await Fs.await())}constructor(t){this.api=t,this.cache=new i,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")}}class Nc extends Event{constructor(){super(Nc.eventName)}}Nc.eventName="search-context-clear-all-filters";class Cc{static build(t){return new Cc((t=>qi.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:ic}))(t.trim()||"context"),Sc.build)}constructor(t,e){this.store=t,this.serviceProvider=e,this.ignoreEmptyQuery=!1,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(){return async function(t,e=10,o=2e4){let r,i,n=await t();for(r=i=performance.now();null==n&&(!o||i-r<o);)await W(e),n=await t(),i=performance.now();if(null==n)throw new Error("Timeout exceeded");return n}((()=>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 r=t=>e.some((e=>e.lang==t));r(t)||(t=r(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(yc.TITLE_ONLY),this.store.actions.setRequestScope(xc.DOCUMENTS)):(this.store.actions.setRequestVirtualField(yc.EVERYWHERE),this.store.actions.setRequestScope(xc.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return(t=>t.request.virtualField===yc.TITLE_ONLY&&t.request.scope===xc.DOCUMENTS)(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new Nc)}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,r={key:t,values:e,negative:!1},i=[...o.filter((e=>e.key!==t)),r];this.setFilters(i)}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()}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();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=r(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 e=(null!==(o=this.store.getState().results)&&void 0!==o?o:[]).concat(t.results);this.store.actions.setResults(e)}this.store.actions.setPaging(t.paging)}}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const e=this.store.getState(),o=e.request,i={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=r(this.service.launchSuggest(i));let n=await this.cancelableSuggest;this.store.actions.setSuggestResults(n.suggestions)}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}clear(){this.store.clear()}}var Ec=function(t,e,o,r){for(var i,n=arguments.length,a=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r,s=t.length-1;s>=0;s--)(i=t[s])&&(a=(n<3?i(a):n>3?i(e,o,a):i(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class $c extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const Rc=Symbol("registerInterval");class kc 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[Rc]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[Rc]):this.dispatchEvent(new $c)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return e=Rc,Ec([U()],o.prototype,"stateManager",void 0),o}(ar)){}var Uc,Ic=function(t,e,o,r){for(var i,n=arguments.length,a=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r,s=t.length-1;s>=0;s--)(i=t[s])&&(a=(n<3?i(a):n>3?i(e,o,a):i(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class Lc extends CustomEvent{constructor(t){super("ft-search-load-error",{detail:t})}}class Ac extends CustomEvent{constructor(t){super("ft-search-request-change",{detail:t})}}class Wc extends CustomEvent{constructor(t,e,o){super("ft-search-results-change",{detail:{request:t,paging:e,spellcheck:o}})}}class Fc extends ar{get stateManager(){return null==this._stateManager&&(this._stateManager=Cc.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0")),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store,"search")),this._stateManager}constructor(){super(),this.query="",this.pageSize=20,this.searchInDocumentTitlesOnly=!1,this.ignoreEmptyQuery=!1,this.filters=[],this.sort=[],this.addStore(Ws)}render(){return fe`
1193
+ `,ic={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 nc,ac,sc,cc,lc,fc,hc,uc,pc,dc,yc,gc,bc,mc,vc,xc,Oc,wc;!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 r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&r.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 c(t){this.map={},t instanceof c?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 l(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 u(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function p(){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=u(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=u(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=l(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?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(h)}),this.text=function(){var t=l(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),r=0;r<e.length;r++)o[r]=String.fromCharCode(e[r]);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(g)}),this.json=function(){return this.text().then(JSON.parse)},this}c.prototype.append=function(t,e){t=n(t),e=a(e);var o=this.map[t];this.map[t]=o?o+", "+e:e},c.prototype.delete=function(t){delete this.map[n(t)]},c.prototype.get=function(t){return t=n(t),this.has(t)?this.map[t]:null},c.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},c.prototype.set=function(t,e){this.map[n(t)]=a(e)},c.prototype.forEach=function(t,e){for(var o in this.map)this.map.hasOwnProperty(o)&&t.call(e,this.map[o],o,this)},c.prototype.keys=function(){var t=[];return this.forEach((function(e,o){t.push(o)})),s(t)},c.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),s(t)},c.prototype.entries=function(){var t=[];return this.forEach((function(e,o){t.push([o,e])})),s(t)},o.iterable&&(c.prototype[Symbol.iterator]=c.prototype.entries);var d=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,e){var o,r,i=(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 c(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=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 c(e.headers)),this.method=(o=e.method||this.method||"GET",r=o.toUpperCase(),d.indexOf(r)>-1?r:o),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var o=t.split("="),r=o.shift().replace(/\+/g," "),i=o.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}})),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 c(e.headers),this.url=e.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},p.call(y.prototype),p.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new c(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,r){return new Promise((function(i,n){var a=new y(t,r);if(a.signal&&a.signal.aborted)return n(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function l(){s.abort()}s.onload=function(){var t,e,o={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new c,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var o=t.split(":"),r=o.shift().trim();if(r){var i=o.join(":").trim();e.append(r,i)}})),e)};o.url="responseURL"in s?s.responseURL:o.headers.get("X-Request-URL");var r="response"in s?s.response:s.responseText;i(new b(r,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",l),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",l)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}v.polyfill=!0,t.fetch||(t.fetch=v,t.Headers=c,t.Request=y,t.Response=b),e.Headers=c,e.Request=y,e.Response=b,e.fetch=v,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"}(nc||(nc={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(ac||(ac={})),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"}(sc||(sc={})),function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"}(cc||(cc={})),function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"}(lc||(lc={})),function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"}(fc||(fc={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(hc||(hc={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(uc||(uc={})),function(t){t.ASC="ASC",t.DESC="DESC"}(pc||(pc={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(dc||(dc={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(yc||(yc={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(gc||(gc={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(bc||(bc={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(mc||(mc={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(vc||(vc={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS"}(xc||(xc={})),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"}(Oc||(Oc={})),function(t){t.VALID="VALID",t.INVALID="INVALID"}(wc||(wc={})),Oc.PERSONAL_BOOK_SHARE_USER,Oc.PERSONAL_BOOK_USER,Oc.HTML_EXPORT_USER,Oc.PERSONAL_BOOK_USER,Oc.PDF_EXPORT_USER,Oc.PERSONAL_BOOK_USER,Oc.KHUB_ADMIN,Oc.CONTENT_PUBLISHER,Oc.ADMIN,Oc.KHUB_ADMIN,Oc.USERS_ADMIN,Oc.PORTAL_ADMIN,Oc.DEVELOPER,Oc.BETA_USER,Oc.DEBUG_USER;class Sc{static async build(){return new Sc(await Fs.await())}constructor(t){this.api=t,this.cache=new i,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")}}class Nc extends Event{constructor(){super(Nc.eventName)}}Nc.eventName="search-context-clear-all-filters";class Cc{static build(t){return new Cc((t=>qi.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:ic}))(t.trim()||"context"),Sc.build)}constructor(t,e){this.store=t,this.serviceProvider=e,this.ignoreEmptyQuery=!1,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(){return async function(t,e=10,o=2e4){let r,i,n=await t();for(r=i=performance.now();null==n&&(!o||i-r<o);)await W(e),n=await t(),i=performance.now();if(null==n)throw new Error("Timeout exceeded");return n}((()=>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 r=t=>e.some((e=>e.lang==t));r(t)||(t=r(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(yc.TITLE_ONLY),this.store.actions.setRequestScope(xc.DOCUMENTS)):(this.store.actions.setRequestVirtualField(yc.EVERYWHERE),this.store.actions.setRequestScope(xc.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return(t=>t.request.virtualField===yc.TITLE_ONLY&&t.request.scope===xc.DOCUMENTS)(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new Nc)}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,r={key:t,values:e,negative:!1},i=[...o.filter((e=>e.key!==t)),r];this.setFilters(i)}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()}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();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=r(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 e=(null!==(o=this.store.getState().results)&&void 0!==o?o:[]).concat(t.results);this.store.actions.setResults(e)}this.store.actions.setPaging(t.paging)}}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const e=this.store.getState(),o=e.request,i={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=r(this.service.launchSuggest(i));let n=await this.cancelableSuggest;this.store.actions.setSuggestResults(n.suggestions)}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}clear(){this.store.clear()}}var Ec=function(t,e,o,r){for(var i,n=arguments.length,a=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r,s=t.length-1;s>=0;s--)(i=t[s])&&(a=(n<3?i(a):n>3?i(e,o,a):i(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class $c extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const Rc=Symbol("registerInterval");class kc 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[Rc]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[Rc]):this.dispatchEvent(new $c)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return e=Rc,Ec([U()],o.prototype,"stateManager",void 0),o}(ar)){}var Uc,Ic=function(t,e,o,r){for(var i,n=arguments.length,a=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r,s=t.length-1;s>=0;s--)(i=t[s])&&(a=(n<3?i(a):n>3?i(e,o,a):i(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class Lc extends CustomEvent{constructor(t){super("ft-search-load-error",{detail:t})}}class Ac extends CustomEvent{constructor(t){super("ft-search-request-change",{detail:t})}}class Wc extends CustomEvent{constructor(t,e,o){super("ft-search-results-change",{detail:{request:t,paging:e,spellcheck:o}})}}class Fc extends ar{get stateManager(){return null==this._stateManager&&(this._stateManager=Cc.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0")),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store,"search")),this._stateManager}constructor(){super(),this.query="",this.pageSize=20,this.searchInDocumentTitlesOnly=!1,this.ignoreEmptyQuery=!1,this.filters=[],this.sort=[],this.addStore(Ws)}render(){return fe`
1194
1194
  <slot @register-ft-search-component=${this.registerComponent}></slot>
1195
1195
  `}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)}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 Ac(this.request)),t.has("paging")&&void 0!==this.paging&&this.dispatchEvent(new Wc(this.request,this.paging,this.autocorrect))}registerComponent(t){t.stopPropagation();const e=t.composedPath()[0];this.register(e)}register(t){t.setSearchStateManager(this.stateManager)}handleLoadError(t){this.dispatchEvent(new Lc(t))}reloadSavedSearches(){Gs.clearMySearches()}clear(){this.stateManager.clear()}}Fc.elementDefinitions={},Fc.styles=rc,Ic([k()],Fc.prototype,"query",void 0),Ic([k()],Fc.prototype,"contentLocale",void 0),Ic([k({type:Number})],Fc.prototype,"pageSize",void 0),Ic([k({type:Boolean})],Fc.prototype,"searchInDocumentTitlesOnly",void 0),Ic([k()],Fc.prototype,"scope",void 0),Ic([k({type:Boolean})],Fc.prototype,"ignoreEmptyQuery",void 0),Ic([K([])],Fc.prototype,"filters",void 0),Ic([K([])],Fc.prototype,"sort",void 0),Ic([Xo({store:"search"})],Fc.prototype,"request",void 0),Ic([Xo({store:"search"})],Fc.prototype,"paging",void 0),Ic([Xo({store:"search",selector:t=>t.spellcheck})],Fc.prototype,"autocorrect",void 0),Ic([Xo({store:Ws.name})],Fc.prototype,"session",void 0),j("ft-search-context")(Fc),function(t){t.FEEDBACK="FEEDBACK",t.RATING="RATING",t.PRINT="PRINT",t.BOOKMARK="BOOKMARK",t.COLLECTIONS="COLLECTIONS",t.PERSONAL_BOOKS="PERSONAL_BOOKS"}(Uc||(Uc={}));var jc=function(t,e,o,r){for(var i,n=arguments.length,a=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r,s=t.length-1;s>=0;s--)(i=t[s])&&(a=(n<3?i(a):n>3?i(e,o,a):i(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class Kc extends Event{constructor(){super("register-ft-reader-component",{bubbles:!0,composed:!0})}}const Pc=Symbol("registerInterval");class Dc extends(function(t){var e;class o extends t{constructor(){super(...arguments),this[e]=0}setReaderStateManager(t){this.clearStateManager(),this.stateManager=t,this.addStore(t.store,"reader")}clearStateManager(){this.stateManager&&(this.removeStore("reader"),this.stateManager=void 0)}get service(){var t;return null===(t=this.stateManager)||void 0===t?void 0:t.service}connectedCallback(){super.connectedCallback(),this[Pc]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[Pc]):this.dispatchEvent(new Kc)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return e=Pc,jc([U()],o.prototype,"stateManager",void 0),o}(ar)){}const Mc=Rt`
1196
1196
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-reader-search-in-document",
3
- "version": "1.1.30",
3
+ "version": "1.1.31",
4
4
  "description": "A search component to retrieve occurrences in documents",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,20 +19,20 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-button": "1.1.30",
23
- "@fluid-topics/ft-card": "1.1.30",
24
- "@fluid-topics/ft-i18n": "1.1.30",
25
- "@fluid-topics/ft-search-context": "1.1.30",
26
- "@fluid-topics/ft-search-input": "1.1.30",
27
- "@fluid-topics/ft-search-load-more-button": "1.1.30",
28
- "@fluid-topics/ft-search-result-abstract": "1.1.30",
29
- "@fluid-topics/ft-search-result-title": "1.1.30",
30
- "@fluid-topics/ft-search-results": "1.1.30",
31
- "@fluid-topics/ft-search-results-number": "1.1.30",
32
- "@fluid-topics/ft-typography": "1.1.30",
33
- "@fluid-topics/ft-wc-utils": "1.1.30",
34
- "@fluid-topics/public-api": "1.0.57",
22
+ "@fluid-topics/ft-button": "1.1.31",
23
+ "@fluid-topics/ft-card": "1.1.31",
24
+ "@fluid-topics/ft-i18n": "1.1.31",
25
+ "@fluid-topics/ft-search-context": "1.1.31",
26
+ "@fluid-topics/ft-search-input": "1.1.31",
27
+ "@fluid-topics/ft-search-load-more-button": "1.1.31",
28
+ "@fluid-topics/ft-search-result-abstract": "1.1.31",
29
+ "@fluid-topics/ft-search-result-title": "1.1.31",
30
+ "@fluid-topics/ft-search-results": "1.1.31",
31
+ "@fluid-topics/ft-search-results-number": "1.1.31",
32
+ "@fluid-topics/ft-typography": "1.1.31",
33
+ "@fluid-topics/ft-wc-utils": "1.1.31",
34
+ "@fluid-topics/public-api": "1.0.58",
35
35
  "lit": "3.1.0"
36
36
  },
37
- "gitHead": "2eadc3ab5cdc677c1db2564a74d18440cd553d42"
37
+ "gitHead": "e9db5f3c700c9d25c85c211c8875686bb989da96"
38
38
  }