@fluid-topics/ft-search-type 1.1.50 → 1.1.52

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.
@@ -1489,7 +1489,7 @@ const M=Symbol.for(""),j=t=>{if(t?.r===M)return t?._$litStatic$},_=t=>({_$litSta
1489
1489
  <slot class="ft-filter-option--slot" @slotchange=${this.updateSubOptionsFromSlot}></slot>
1490
1490
  `}updateSubOptionsFromSlot(t){t.stopPropagation(),this.subOptions=this.slotElement.assignedElements().map((t=>t))}update(t){super.update(t),this.dispatchEvent(new CustomEvent("option-change",{detail:this,bubbles:!0}))}}Xi.elementDefinitions={},Qi([i.property({type:String})],Xi.prototype,"label",void 0),Qi([i.property({type:Object,converter:t=>t})],Xi.prototype,"value",void 0),Qi([i.property({type:Boolean,reflect:!0})],Xi.prototype,"selected",void 0),Qi([i.property({type:Object})],Xi.prototype,"subOptions",void 0),Qi([o.jsonProperty({})],Xi.prototype,"renderOption",void 0),Qi([i.query(".ft-filter-option--slot")],Xi.prototype,"slotElement",void 0),o.customElement("ft-filter")(Yi),o.customElement("ft-filter-option")(Xi);const Ji=e.css`
1491
1491
  `,tr=e.css`
1492
- `,or=o.FtReduxStore.get({name:"ft-app-info",reducers:{},initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0,openExternalDocumentInNewTab:!1}});class er{static build(t){const{baseUrl:o,apiIntegrationIdentifier:e}=or.getState(),i=null!=t?t:e;if(o&&i&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(o,i,!0)}static get(t){var o;return null!=t?er.build(t):null!==(o=er.API)&&void 0!==o?o:er.API=er.build()}static await(t){return new Promise((o=>{let e=er.get(t);if(e)o(e);else{const i=or.subscribe((()=>{e=er.get(t),e&&(i(),o(e))}))}}))}}class ir{constructor(t=!0,e){var i;this.overrideApi=e;let r=this.constructor;r.commonCache=null!==(i=r.commonCache)&&void 0!==i?i:new o.CacheRegistry,this.cache=t?r.commonCache:new o.CacheRegistry}get api(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:er.get()}get awaitApi(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:er.await()}clearCache(){this.cache.clearAll()}}var rr;const nr=Symbol("clearAfterUnitTest");class ar extends ir{constructor(t){super(),this.messageContextProvider=t,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[rr]=()=>{this.defaultMessages={},this.cache=new o.CacheRegistry,this.listeners={}},this.currentUiLocale=or.getState().uiLocale,or.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=or.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const o=t.name.toLowerCase();this.cache.setFinal(o,t),this.notify(o)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,e){var i;if(t=t.toLowerCase(),Object.keys(e).length>0){const r={...null!==(i=this.defaultMessages[t])&&void 0!==i?i:{},...e};o.deepEqual(this.defaultMessages[t],r)||(this.defaultMessages[t]=r,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,e,...i){var r,n,a;t=t.toLowerCase(),this.fetchContext(t);const l=null!==(n=null===(r=this.cache.getNow(t))||void 0===r?void 0:r.messages)&&void 0!==n?n:{};return new o.ParametrizedLabelResolver(null!==(a=this.defaultMessages[t])&&void 0!==a?a:{},l).resolve(e,...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,o){var e;return t=t.toLowerCase(),this.listeners[t]=null!==(e=this.listeners[t])&&void 0!==e?e:new Set,this.listeners[t].add(o),()=>{var e;return null===(e=this.listeners[t])||void 0===e?void 0:e.delete(o)}}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=>o.delay(0).then((()=>t())).catch((()=>null)))))}}rr=nr,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new class extends ar{constructor(){super((async(t,o)=>(await this.awaitApi).getFluidTopicsMessageContext(t,o)))}}),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new class extends ar{constructor(){super((async(t,o)=>(await this.awaitApi).getCustomMessageContext(t,o)))}});const lr=window.FluidTopicsI18nService,sr=window.FluidTopicsCustomI18nService;var cr=function(t,o,e,i){for(var r,n=arguments.length,a=n<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i,l=t.length-1;l>=0;l--)(r=t[l])&&(a=(n<3?r(a):n>3?r(o,e,a):r(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};class fr extends o.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>er.get(),this.cache=new o.CacheRegistry,this.cleanSessionDebouncer=new o.Debouncer}render(){return e.html`
1492
+ `,or=o.FtReduxStore.get({name:"ft-app-info",reducers:{},initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0,openExternalDocumentInNewTab:!1}});class er{static get(t){const{baseUrl:o,apiIntegrationIdentifier:e}=or.getState(),i=null!=t?t:e;if(o&&i&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(o,i,!0)}static await(t){return new Promise((o=>{let e=er.get(t);if(e)o(e);else{const i=or.subscribe((()=>{e=er.get(t),e&&(i(),o(e))}))}}))}}class ir{constructor(t=!0,e){var i;this.overrideApi=e;let r=this.constructor;r.commonCache=null!==(i=r.commonCache)&&void 0!==i?i:new o.CacheRegistry,this.cache=t?r.commonCache:new o.CacheRegistry}get api(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:er.get()}get awaitApi(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:er.await()}clearCache(){this.cache.clearAll()}}var rr;const nr=Symbol("clearAfterUnitTest");class ar extends ir{constructor(t){super(),this.messageContextProvider=t,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[rr]=()=>{this.defaultMessages={},this.cache=new o.CacheRegistry,this.listeners={}},this.currentUiLocale=or.getState().uiLocale,or.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=or.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const o=t.name.toLowerCase();this.cache.setFinal(o,t),this.notify(o)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,e){var i;if(t=t.toLowerCase(),Object.keys(e).length>0){const r={...null!==(i=this.defaultMessages[t])&&void 0!==i?i:{},...e};o.deepEqual(this.defaultMessages[t],r)||(this.defaultMessages[t]=r,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,e,...i){var r,n,a;t=t.toLowerCase(),this.fetchContext(t);const l=null!==(n=null===(r=this.cache.getNow(t))||void 0===r?void 0:r.messages)&&void 0!==n?n:{};return new o.ParametrizedLabelResolver(null!==(a=this.defaultMessages[t])&&void 0!==a?a:{},l).resolve(e,...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,o){var e;return t=t.toLowerCase(),this.listeners[t]=null!==(e=this.listeners[t])&&void 0!==e?e:new Set,this.listeners[t].add(o),()=>{var e;return null===(e=this.listeners[t])||void 0===e?void 0:e.delete(o)}}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=>o.delay(0).then((()=>t())).catch((()=>null)))))}}rr=nr,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new class extends ar{constructor(){super((async(t,o)=>(await this.awaitApi).getFluidTopicsMessageContext(t,o)))}}),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new class extends ar{constructor(){super((async(t,o)=>(await this.awaitApi).getCustomMessageContext(t,o)))}});const lr=window.FluidTopicsI18nService,sr=window.FluidTopicsCustomI18nService;var cr=function(t,o,e,i){for(var r,n=arguments.length,a=n<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i,l=t.length-1;l>=0;l--)(r=t[l])&&(a=(n<3?r(a):n>3?r(o,e,a):r(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};class fr extends o.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>er.get(),this.cache=new o.CacheRegistry,this.cleanSessionDebouncer=new o.Debouncer}render(){return e.html`
1493
1493
  <slot></slot>
1494
1494
  `}update(t){super.update(t),t.has("baseUrl")&&(or.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),t.has("apiIntegrationIdentifier")&&or.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&or.actions.uiLocale(this.uiLocale),t.has("metadataConfiguration")&&or.actions.metadataConfiguration(this.metadataConfiguration),t.has("noCustom")&&or.actions.noCustom(this.noCustom),t.has("editorMode")&&or.actions.editorMode(this.editorMode),t.has("noCustomComponent")&&or.actions.noCustomComponent(this.noCustomComponent),t.has("session")&&or.actions.session(this.session),t.has("availableUiLocales")&&or.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>lr.addContext(t))),t.has("openExternalDocumentInNewTab")&&or.actions.openExternalDocumentInNewTab(this.openExternalDocumentInNewTab),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){!this.withManualResources&&this.apiProvider()&&(null==this.session&&this.updateSession(),null==this.availableUiLocales&&this.updateUiLocales(),null==this.metadataConfiguration&&this.updateMetadataConfiguration())}async updateSession(){this.session=await this.cache.get("session",(async()=>{const t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),t.idleTimeoutInMillis),t}))}async updateUiLocales(){this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>this.apiProvider().getAvailableUiLocales()))}async updateMetadataConfiguration(){this.metadataConfiguration=await this.cache.get("metadataConfiguration",(()=>this.apiProvider().getMetadataConfiguration()))}}fr.elementDefinitions={},fr.styles=tr,cr([i.property()],fr.prototype,"baseUrl",void 0),cr([i.property()],fr.prototype,"apiIntegrationIdentifier",void 0),cr([i.property()],fr.prototype,"uiLocale",void 0),cr([o.jsonProperty(null)],fr.prototype,"availableUiLocales",void 0),cr([o.jsonProperty(null)],fr.prototype,"metadataConfiguration",void 0),cr([i.property({type:Boolean})],fr.prototype,"editorMode",void 0),cr([i.property({type:Boolean})],fr.prototype,"noCustom",void 0),cr([i.property({type:Boolean})],fr.prototype,"openExternalDocumentInNewTab",void 0),cr([i.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],fr.prototype,"noCustomComponent",void 0),cr([i.property({type:Boolean})],fr.prototype,"withManualResources",void 0),cr([o.jsonProperty([])],fr.prototype,"messageContexts",void 0),cr([o.jsonProperty(void 0)],fr.prototype,"session",void 0),cr([i.property({type:Object})],fr.prototype,"apiProvider",void 0);class pr extends ir{async listMySearches(){let t=or.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-searches",(async()=>(await this.awaitApi).listMySearches(t.profile.userId)),3e5):[]}}class hr extends ir{async listMyBookmarks(){let t=or.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-bookmarks",(async()=>(await this.awaitApi).listMyBookmarks(t.profile.userId)),3e5):[]}}const dr=o.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const ur=new class{constructor(){this.currentSession=or.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new hr,this.savedSearchesService=new pr,or.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:e}=or.getState();o.deepEqual(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(){this.savedSearchesService.clearCache(),dr.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),dr.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();const t=await this.savedSearchesService.listMySearches();dr.actions.savedSearches(t)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const o=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;dr.actions.bookmarks(o)}}};o.customElement("ft-app-context")(fr);var gr=function(t,o,e,i){for(var r,n=arguments.length,a=n<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i,l=t.length-1;l>=0;l--)(r=t[l])&&(a=(n<3?r(a):n>3?r(o,e,a):r(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};const yr=Symbol("i18nAttributes"),br=Symbol("i18nProperties"),mr=Symbol("i18nUnsubs");function xr(t){var o;class e extends t{constructor(){super(...arguments),this.useCustomMessageContexts=!1,this[o]=new Map}get i18nService(){return this.useCustomMessageContexts?sr:lr}i18n(t,o,...e){var i;if("string"==typeof t)return this.i18nService.resolveMessage(t,o,...e);const r=null!==(i=t.args)&&void 0!==i?i:t.argsProvider?t.argsProvider(this):[];return this.i18nService.resolveMessage(t.context,t.key,...r)}onI18nUpdate(t){var o,e;null===(o=this[yr])||void 0===o||o.forEach(((o,e)=>{var i;const r=this.getI18nAttributeValue(e);(null===(i=null==r?void 0:r.context)||void 0===i?void 0:i.toLowerCase())===t.toLowerCase()&&this.updateI18nAttributeMessage(e,r,o)})),null===(e=this[br])||void 0===e||e.forEach(((o,e)=>{o.context.toLowerCase()===t.toLowerCase()&&(this[e]=this.i18n(o))})),setTimeout((()=>this.requestUpdate()),0)}updateI18nAttributeMessage(t,o,e){this[t]={...o,message:this.i18n({context:o.context,key:o.key,...e})}}update(t){var o,e;super.update(t),null===(o=this[yr])||void 0===o||o.forEach(((o,e)=>{const i=this.getI18nAttributeValue(e);(null==i?void 0:i.context)&&i.key&&(t.has(e)||null!=o.argsProvider)&&(t.has(e)&&this.addI18nContext(i.context),this.updateI18nAttributeMessage(e,i,o))})),null===(e=this[br])||void 0===e||e.forEach(((t,o)=>{null!=t.argsProvider&&(this[o]=this.i18n(t))}))}getI18nAttributeValue(t){return this[t]}connectedCallback(){var t,o,e,i;super.connectedCallback(),new Set([...null!==(o=null===(t=this[br])||void 0===t?void 0:t.values())&&void 0!==o?o:[],...[...null!==(i=null===(e=this[yr])||void 0===e?void 0:e.keys())&&void 0!==i?i:[]].map((t=>this.getI18nAttributeValue(t)))].map((t=>null==t?void 0:t.context))).forEach((t=>t&&this.addI18nMessages(t)))}addI18nMessages(t,o){t=t.toLowerCase(),this[mr].has(t)||this[mr].set(t,this.i18nService.subscribe(t,(()=>this.onI18nUpdate(t)))),this.i18nService.prepareContext(t,null!=o?o:{})}addI18nContext(t,o){this.addI18nMessages("string"==typeof t?t:t.name,o)}disconnectedCallback(){super.disconnectedCallback(),this[mr].forEach((t=>t())),this[mr].clear()}}return o=mr,gr([i.property({type:Boolean})],e.prototype,"useCustomMessageContexts",void 0),e}class vr extends(xr(o.FtLitElement)){}class Or extends(xr(o.FtLitElementRedux)){}var wr=function(t,o,e,i){for(var r,n=arguments.length,a=n<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i,l=t.length-1;l>=0;l--)(r=t[l])&&(a=(n<3?r(a):n>3?r(o,e,a):r(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};class Sr extends Or{constructor(){super(),this.editorMode=!1,this.addStore(or)}render(){return this.key&&this.context?e.html`
1495
1495
  <span class="ft-i18n">