@nanoporetech-digital/components 8.0.0 → 8.1.1

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.
Files changed (64) hide show
  1. package/dist/cjs/nano-algolia-results.cjs.entry.js +24 -26
  2. package/dist/cjs/nano-algolia.cjs.entry.js +4 -0
  3. package/dist/cjs/nano-avatar_5.cjs.entry.js +120 -117
  4. package/dist/cjs/nano-dropdown_2.cjs.entry.js +10 -6
  5. package/dist/cjs/nano-icon_3.cjs.entry.js +1 -1
  6. package/dist/cjs/nano-in-page-nav.cjs.entry.js +1 -1
  7. package/dist/cjs/nano-tab-group.cjs.entry.js +1 -1
  8. package/dist/cjs/{popover-D_uJstEp.js → popover-BxNxwqMv.js} +5 -3
  9. package/dist/collection/components/algolia/algolia-results.js +25 -27
  10. package/dist/collection/components/algolia/lib/template.js +4 -0
  11. package/dist/collection/components/breadcrumb/breadcrumb.js +1 -1
  12. package/dist/collection/components/dropdown/dropdown.js +9 -5
  13. package/dist/collection/components/global-search-results/global-search-results.css +121 -189
  14. package/dist/collection/components/global-search-results/global-search-results.js +121 -117
  15. package/dist/collection/components/in-page-nav/in-page-nav.css +3 -1
  16. package/dist/collection/components/tabs/tab-group.js +1 -1
  17. package/dist/collection/utils/popover.js +5 -3
  18. package/dist/components/algolia.js +4 -0
  19. package/dist/components/dropdown.js +9 -5
  20. package/dist/components/global-search-results.js +122 -118
  21. package/dist/components/nano-algolia-results.js +25 -27
  22. package/dist/components/nano-in-page-nav.js +1 -1
  23. package/dist/components/nano-tab-group.js +1 -1
  24. package/dist/components/popover.js +5 -3
  25. package/dist/esm/nano-algolia-results.entry.js +25 -27
  26. package/dist/esm/nano-algolia.entry.js +4 -0
  27. package/dist/esm/nano-avatar_5.entry.js +120 -117
  28. package/dist/esm/nano-dropdown_2.entry.js +10 -6
  29. package/dist/esm/nano-icon_3.entry.js +1 -1
  30. package/dist/esm/nano-in-page-nav.entry.js +1 -1
  31. package/dist/esm/nano-tab-group.entry.js +1 -1
  32. package/dist/esm/{popover-BKomgCqQ.js → popover-CWVbjtKn.js} +5 -3
  33. package/dist/nano-components/nano-algolia-results.entry.js +1 -1
  34. package/dist/nano-components/nano-algolia.entry.js +1 -1
  35. package/dist/nano-components/nano-avatar_5.entry.js +1 -1
  36. package/dist/nano-components/nano-components.css +8 -6
  37. package/dist/nano-components/nano-dropdown_2.entry.js +1 -1
  38. package/dist/nano-components/nano-icon_3.entry.js +1 -1
  39. package/dist/nano-components/nano-in-page-nav.entry.js +1 -1
  40. package/dist/nano-components/nano-tab-group.entry.js +1 -1
  41. package/dist/nano-components/{popover-BKomgCqQ.js → popover-CWVbjtKn.js} +1 -1
  42. package/dist/style/components.css +1 -1
  43. package/dist/style/components.css.map +1 -1
  44. package/dist/style/core.css +1 -1
  45. package/dist/style/core.css.map +1 -1
  46. package/dist/style/nano.css +1 -1
  47. package/dist/style/nano.css.map +1 -1
  48. package/dist/types/{Users/John.Jenkins/projects → builds/W1hp42tj/0/Digital}/nano-components/packages/components/.stencil/plugins/stencil/vue-output/generate-vue-component.d.ts +1 -1
  49. package/dist/types/{Users/John.Jenkins/projects → builds/W1hp42tj/0/Digital}/nano-components/packages/components/.stencil/plugins/stencil/vue-output/output-vue.d.ts +1 -1
  50. package/dist/types/{Users/John.Jenkins/projects → builds/W1hp42tj/0/Digital}/nano-components/packages/components/.stencil/plugins/stencil/vue-output/plugin.d.ts +1 -1
  51. package/dist/types/builds/W1hp42tj/0/Digital/nano-components/packages/components/.stencil/stencil.config.d.ts +2 -0
  52. package/dist/types/builds/W1hp42tj/0/Digital/nano-components/packages/components/.stencil/stencil.config.prod.d.ts +2 -0
  53. package/dist/types/components/global-search-results/global-search-results.d.ts +2 -0
  54. package/docs-json.json +2 -2
  55. package/hydrate/index.js +162 -153
  56. package/hydrate/index.mjs +162 -153
  57. package/package.json +2 -2
  58. package/dist/types/Users/John.Jenkins/projects/nano-components/packages/components/.stencil/stencil.config.d.ts +0 -2
  59. package/dist/types/Users/John.Jenkins/projects/nano-components/packages/components/.stencil/stencil.config.prod.d.ts +0 -2
  60. /package/dist/types/{Users/John.Jenkins/projects → builds/W1hp42tj/0/Digital}/nano-components/packages/components/.stencil/plugins/stencil/vue-output/index.d.ts +0 -0
  61. /package/dist/types/{Users/John.Jenkins/projects → builds/W1hp42tj/0/Digital}/nano-components/packages/components/.stencil/plugins/stencil/vue-output/types.d.ts +0 -0
  62. /package/dist/types/{Users/John.Jenkins/projects → builds/W1hp42tj/0/Digital}/nano-components/packages/components/.stencil/plugins/stencil/vue-output/utils.d.ts +0 -0
  63. /package/dist/types/{Users/John.Jenkins/projects → builds/W1hp42tj/0/Digital}/nano-components/packages/components/.stencil/testing/mocks/intersection-observer.d.ts +0 -0
  64. /package/dist/types/{Users/John.Jenkins/projects → builds/W1hp42tj/0/Digital}/nano-components/packages/components/.stencil/wdio.conf.d.ts +0 -0
@@ -1831,7 +1831,7 @@ class Popover {
1831
1831
  // this.isVisible = false;
1832
1832
  this.popover.hidden = true;
1833
1833
  this.popover.classList.remove(this.options.visibleClass);
1834
- this.popover.addEventListener('transitionend', this.handleTransitionEnd.bind(this));
1834
+ this.popover.addEventListener('transitionend', this.handleTransitionEnd);
1835
1835
  }
1836
1836
  handleTransitionEnd(event) {
1837
1837
  const target = event.target;
@@ -1846,10 +1846,13 @@ class Popover {
1846
1846
  this.popover.classList.remove(this.options.visibleClass);
1847
1847
  this.options.onAfterHide.call(this);
1848
1848
  }
1849
+ else {
1850
+ this.options.onAfterShow.call(this);
1851
+ }
1849
1852
  }
1850
1853
  }
1851
1854
  destroy() {
1852
- this.popover.removeEventListener('transitionend', this.handleTransitionEnd.bind(this));
1855
+ this.popover.removeEventListener('transitionend', this.handleTransitionEnd);
1853
1856
  if (this.popper) {
1854
1857
  this.popper.destroy();
1855
1858
  this.popper = null;
@@ -1901,7 +1904,6 @@ class Popover {
1901
1904
  },
1902
1905
  ],
1903
1906
  });
1904
- this.popover.addEventListener('transitionend', () => this.options.onAfterShow.call(this), { once: true });
1905
1907
  // Reposition the menu after it appears in case a modifier kicked in
1906
1908
  requestAnimationFrame(() => {
1907
1909
  this.popper?.update().catch((e) => {
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Custom elements for Nanopore-Digital Web applications
3
3
  */
4
- import{r as t,c as s,g as e,e as i,a as h}from"./index-DgO0qeQ9.js";import{h as a}from"./renderer-T8etwwhk.js";import{W as n,S as l}from"./algolia-data-D9ZAstcC.js";const d=class{constructor(e){t(this,e),this.nanoPageChanged=s(this,"nanoPageChanged",7),this.nanoTplUpdated=s(this,"nanoTplUpdated",7)}get el(){return e(this)}resultTpl;resultTplSlot;startTpl;startTplSlot;endTpl;endTplSlot;outputSlot;outputEle;outputTo;startOutputSlot;endOutputSlot;io;infiniteScrollBar;append=!1;shouldClear=!0;currHitNum=0;showResults=!1;tplRenderFn;results=null;indexResults=null;resultsPage=0;changeEvent=l.Init;facets;isLoading=!0;infiniteScroll=!1;appendPages=!1;nanoPageChanged;nanoTplUpdated;addContentIndex(){this.shouldPageClear(),(this.shouldClear||0===this.resultsPage)&&(this.currHitNum=0),this.indexResults&&this.indexResults.results&&this.indexResults.results.map((t=>{t._uIndex=this.currHitNum++}))}resultsChange(){this.shouldPageClear(),this.updateResultContent(),this.infiniteScrollChange()}headerFooterChange(){this.updateStartEndContent()}appendChange(){this.append=!!this.infiniteScroll||this.appendPages}infiniteScrollChange(){this.append=!!this.infiniteScroll||this.appendPages,this.infiniteScroll?this.attachIO():this.detachIO()}handlePageChage(){this.infiniteScroll?this.attachIO():this.detachIO()}handleLoading(){this.isLoading||this.infiniteScrollChange()}shouldPageClear(){this.shouldClear=this.changeEvent!==l.Page||!this.append}nextPage(){this.shouldClear=!this.append,this.nanoPageChanged.emit({page:this.resultsPage+1})}attachIO(){this.infiniteScrollBar&&this.infiniteScroll&&!this.io&&"undefined"!=typeof window&&window.IntersectionObserver&&(this.io=new window.IntersectionObserver((async t=>{(t[0].isIntersecting||t[1]&&t[1].isIntersecting)&&(this.nextPage(),this.detachIO())}),{document,rootMargin:"100px",threshold:1}),this.io.observe(this.infiniteScrollBar))}detachIO(){this.io&&(this.io.disconnect(),this.io=null)}updateStartEndContent(){this.startTpl&&this.startOutputSlot&&(this.startOutputSlot.innerHTML=this.tplRenderFn(this.startTpl,this.indexResults)),this.endOutputSlot&&this.endTpl&&(this.endOutputSlot.innerHTML=this.tplRenderFn(this.endTpl,this.indexResults)),this.nanoTplUpdated.emit(this.el)}updateResultContent(){if(this.outputTo=this.outputSlot||this.outputEle,!this.resultTpl||!this.indexResults)return;if(this.shouldClear&&(this.outputTo.innerHTML=""),!this.tplRenderFn)return;const t=document.createElement("div");t.innerHTML=this.tplRenderFn(this.resultTpl,this.indexResults),Array.from(t.children).forEach((t=>{this.outputTo.appendChild(t)})),this.shouldClear=!0,this.nanoTplUpdated.emit(this.el)}connectedCallback(){i((()=>{this.startTplSlot=this.el.querySelector('[slot="start-template"]'),this.startOutputSlot=this.el.querySelector('[slot="start-output"]'),this.startTplSlot&&(this.startTpl=this.startTplSlot.innerHTML,this.startTpl=this.startTpl.replace(/=>/gm,"=>")),this.resultTplSlot=this.el.querySelector('[slot="result-template"]'),this.outputSlot=this.el.querySelector('[slot="result-output"]'),this.resultTplSlot&&(this.resultTpl=this.resultTplSlot.innerHTML,this.resultTpl=this.resultTpl.replace(/=>/gm,"=>")),this.endTplSlot=this.el.querySelector('[slot="end-template"]'),this.endOutputSlot=this.el.querySelector('[slot="end-output"]'),this.endTplSlot&&(this.endTpl=this.endTplSlot.innerHTML,this.endTpl=this.endTpl.replace(/=>/gm,"=>")),this.indexResults&&(this.addContentIndex(),this.updateResultContent())}))}componentDidLoad(){this.updateStartEndContent()}disconnectedCallback(){this.io&&(this.io.disconnect(),this.io=void 0)}render(){return a(h,{key:"14939adaa742d13214faf5375692737010467a7c",class:{"show-results":this.showResults,"nano-results":!0}},a("div",{key:"8153995d81af56df593694ca7902e93f6efb0565",class:"default"},a("slot",{key:"60e2c4a10cdf5f6fbd609972114be5d04ccfe3f0"})),a("div",{key:"cf589b852a52ffc84b8d9dd48c193603e733f02e",ref:t=>this.outputEle=t},a("slot",{key:"aad8bfb81edca4af57503bc80b4eac5cbe69a97e",name:"start-output"}),a("slot",{key:"30e848bcf8b1d0f03d57b65cb805abcca87aefd5",name:"result-output"}),a("div",{key:"8663b935facbe62a5b30d4e6446cc978083369d7",ref:t=>this.infiniteScrollBar=t}),a("slot",{key:"b8652a198cd7fefe5a127b8bc9387305971be922",name:"end-output"})))}static get watchers(){return{results:["addContentIndex","resultsChange"],tplRenderFn:["resultsChange"],facets:["headerFooterChange"],appendPages:["appendChange"],infiniteScroll:["infiniteScrollChange"],resultsPage:["handlePageChage"],isLoading:["handleLoading"]}}};n(d,["indexResults","results","tplRenderFn","resultsPage","changeEvent","facets","isLoading"]);export{d as nano_algolia_results}
4
+ import{r as t,c as s,g as e,a as i}from"./index-DgO0qeQ9.js";import{h}from"./renderer-T8etwwhk.js";import{W as a,S as n}from"./algolia-data-D9ZAstcC.js";const d=class{constructor(e){t(this,e),this.nanoPageChanged=s(this,"nanoPageChanged",7),this.nanoTplUpdated=s(this,"nanoTplUpdated",7)}get el(){return e(this)}resultTpl;resultTplSlot;startTpl;startTplSlot;endTpl;endTplSlot;outputSlot;outputEle;outputTo;startOutputSlot;endOutputSlot;io;infiniteScrollBar;append=!1;shouldClear=!0;currHitNum=0;showResults=!1;tplRenderFn;results=null;indexResults=null;resultsPage=0;changeEvent=n.Init;facets;isLoading=!0;infiniteScroll=!1;appendPages=!1;nanoPageChanged;nanoTplUpdated;addContentIndex(){this.shouldPageClear(),(this.shouldClear||0===this.resultsPage)&&(this.currHitNum=0),this.indexResults&&this.indexResults.results&&this.indexResults.results.map((t=>{t._uIndex=this.currHitNum++}))}resultsChange(){this.shouldPageClear(),this.updateResultContent(),this.infiniteScrollChange()}headerFooterChange(){this.updateStartEndContent()}appendChange(){this.append=!!this.infiniteScroll||this.appendPages}infiniteScrollChange(){this.append=!!this.infiniteScroll||this.appendPages,this.infiniteScroll?this.attachIO():this.detachIO()}handlePageChage(){this.infiniteScroll?this.attachIO():this.detachIO()}handleLoading(){this.isLoading||this.infiniteScrollChange()}shouldPageClear(){this.shouldClear=this.changeEvent!==n.Page||!this.append}nextPage(){this.shouldClear=!this.append,this.nanoPageChanged.emit({page:this.resultsPage+1})}attachIO(){this.infiniteScrollBar&&this.infiniteScroll&&!this.io&&"undefined"!=typeof window&&window.IntersectionObserver&&(this.io=new window.IntersectionObserver((async t=>{(t[0].isIntersecting||t[1]&&t[1].isIntersecting)&&(this.nextPage(),this.detachIO())}),{document,rootMargin:"100px",threshold:1}),this.io.observe(this.infiniteScrollBar))}detachIO(){this.io&&(this.io.disconnect(),this.io=null)}updateStartEndContent(){this.startTpl&&this.startOutputSlot&&(this.startOutputSlot.innerHTML=this.tplRenderFn(this.startTpl,this.indexResults)),this.endOutputSlot&&this.endTpl&&(this.endOutputSlot.innerHTML=this.tplRenderFn(this.endTpl,this.indexResults)),this.nanoTplUpdated.emit(this.el)}updateResultContent(){if(this.outputTo=this.outputSlot||this.outputEle,!this.resultTpl||!this.indexResults)return;if(this.shouldClear&&(this.outputTo.innerHTML=""),!this.tplRenderFn)return;const t=document.createElement("div");t.innerHTML=this.tplRenderFn(this.resultTpl,this.indexResults),Array.from(t.children).forEach((t=>{this.outputTo.appendChild(t)})),this.shouldClear=!0,this.nanoTplUpdated.emit(this.el)}connectedCallback(){this.startTplSlot=this.el.querySelector('[slot="start-template"]'),this.startOutputSlot=this.el.querySelector('[slot="start-output"]'),this.startTplSlot&&(this.startTpl=this.startTplSlot.innerHTML,this.startTpl=this.startTpl.replace(/=>/gm,"=>")),this.resultTplSlot=this.el.querySelector('[slot="result-template"]'),this.outputSlot=this.el.querySelector('[slot="result-output"]'),this.resultTplSlot&&(this.resultTpl=this.resultTplSlot.innerHTML,this.resultTpl=this.resultTpl.replace(/=>/gm,"=>")),this.endTplSlot=this.el.querySelector('[slot="end-template"]'),this.endOutputSlot=this.el.querySelector('[slot="end-output"]'),this.endTplSlot&&(this.endTpl=this.endTplSlot.innerHTML,this.endTpl=this.endTpl.replace(/=>/gm,"=>")),this.indexResults&&(this.addContentIndex(),this.updateResultContent())}componentDidLoad(){this.updateStartEndContent()}disconnectedCallback(){this.io&&(this.io.disconnect(),this.io=void 0)}render(){return h(i,{key:"857784ead2b9536559ef2220bff26d508061781c",class:{"show-results":this.showResults,"nano-results":!0}},h("div",{key:"be165b02c4ec5d2358e15dadfd4695fd5901f0b0",class:"default"},h("slot",{key:"1ab64bb71c75531e8f6b0c65833de7d2dc1ee0ca"})),h("div",{key:"cee981cead8b921e29fd4223e4985c3615e0e063",ref:t=>this.outputEle=t},h("slot",{key:"cff96070ca2acf18f7b8165444b28f433ca3601d",name:"start-output"}),h("slot",{key:"76833dd55d415baf083527ed5580049f90c36b40",name:"result-output"}),h("div",{key:"dac7a9081d1a65b4e17dec60044467e17575568e",ref:t=>this.infiniteScrollBar=t}),h("slot",{key:"07c82d60a58c11bcc50807ab95d63cf3fd59d768",name:"end-output"})))}static get watchers(){return{results:["addContentIndex","resultsChange"],tplRenderFn:["resultsChange"],facets:["headerFooterChange"],appendPages:["appendChange"],infiniteScroll:["infiniteScrollChange"],resultsPage:["handlePageChage"],isLoading:["handleLoading"]}}};a(d,["indexResults","results","tplRenderFn","resultsPage","changeEvent","facets","isLoading"]);export{d as nano_algolia_results}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Custom elements for Nanopore-Digital Web applications
3
3
  */
4
- import{i as t,g as e,r as i,c as s,d as n,e as o,a as r}from"./index-DgO0qeQ9.js";import{a}from"./algoliasearch-lite.esm.browser-BTIloVU8.js";import{g as h}from"./dom-CrrHp_I_.js";import{C as l}from"./component-store-DeKxotC5.js";import{d as c}from"./throttle-C93FMm2Z.js";import{t as u,h as f}from"./renderer-T8etwwhk.js";import{S as d}from"./algolia-data-D9ZAstcC.js";var p=new Map,m=function(t,e){var i=t.updater;t.fields.forEach((function(t){i(t,e[t])}))},g=function(e,i){var s=e.state,n=t();if(p.has(n)){var o=p.get(n);o.state=s,o.wormholes.forEach((function(t){m(t,s)}))}return i};class b{queue=[];workingOnPromise=!1;static pendingPromise=!1;stop=!1;limit=null;enqueue(t){return new Promise(((e,i)=>{this.queue.push({promise:t,resolve:e,reject:i}),this.dequeue()}))}dequeue(){if(this.workingOnPromise)return!1;if(this.stop)return this.queue=[],void(this.stop=!1);const t=this.queue.shift();if(!t)return!1;try{this.workingOnPromise=!0,t.promise().then((e=>{this.workingOnPromise=!1,t.resolve(e),this.dequeue()})).catch((e=>{this.workingOnPromise=!1,t.reject(e),this.dequeue()}))}catch(e){this.workingOnPromise=!1,t.reject(e),this.dequeue()}return!0}}function y(t){const e=new Error(t);var i,s;return i=e,s=y.prototype,Object.setPrototypeOf?Object.setPrototypeOf(i,s):i.__proto__=s,e}function w(t,e,i){const s=e.slice(0,i).split(/\n/),n=s.length,o=s[n-1].length+1;throw y(t+=" at line "+n+" col "+o+":\n\n "+e.split(/\n/)[n-1]+"\n "+Array(o).join(" ")+"^")}y.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});const v=new Function("return this")().Promise;let x=!1;try{x=new Function("return (async function(){}).constructor")()}catch(t){if(!(t instanceof SyntaxError))throw t}function F(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function C(t,e,i){for(const s in e)F(e,s)&&(t[s]=null==e[s]||"object"!=typeof e[s]||"storage"!==s&&"prefixes"!==s||i?e[s]:C({},e[s]));return t}const I=/^async +/,k=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,S=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,R=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,_=/[.*+\-?^${}()|[\]\\]/g;function j(t){return _.test(t)?t.replace(_,"\\$&"):t}function A(t,e){e.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),k.lastIndex=0,S.lastIndex=0,R.lastIndex=0;const i=e.prefixes,s=[i.h,i.b,i.i,i.r,i.c,i.e].reduce((function(t,e){return t&&e?t+"|"+j(e):e?j(e):t}),""),n=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+j(e.tags[1])+")","g"),o=new RegExp("([^]*?)"+j(e.tags[0])+"(-|_)?\\s*("+s+")?\\s*","g");let r=0,a=!1;function h(i,s){const h={f:[]};let l,c=0,u="c";function f(i){const s=t.slice(r,i);let n=s.trim();if("f"===u)"safe"===n?h.raw=!0:e.async&&I.test(n)?(n=n.replace(I,""),h.f.push([n,"",!0])):h.f.push([n,""]);else if("fp"===u)h.f[h.f.length-1][1]+=n;else if("err"===u){if(n){const e=s.search(/\S/);w("invalid syntax",t,r+e)}}else h[u]=n;r=i+1}for("h"===s||"b"===s||"c"===s?u="n":"r"===s&&(h.raw=!0,s="i"),n.lastIndex=r;null!==(l=n.exec(t));){const e=l[1],i=l[2],d=l[3],p=l[4],m=l[5],g=l.index;if(e)"("===e?(0===c&&("n"===u?(f(g),u="p"):"f"===u&&(f(g),u="fp")),c++):")"===e?(c--,0===c&&"c"!==u&&(f(g),u="err")):0===c&&"|"===e?(f(g),u="f"):"=>"===e&&(f(g),r+=1,u="res");else if(i)if("/*"===i){const e=t.indexOf("*/",n.lastIndex);-1===e&&w("unclosed comment",t,l.index),n.lastIndex=e+2}else"'"===i?(S.lastIndex=l.index,S.exec(t)?n.lastIndex=S.lastIndex:w("unclosed string",t,l.index)):'"'===i?(R.lastIndex=l.index,R.exec(t)?n.lastIndex=R.lastIndex:w("unclosed string",t,l.index)):"`"===i&&(k.lastIndex=l.index,k.exec(t)?n.lastIndex=k.lastIndex:w("unclosed string",t,l.index));else if(d)return f(g),r=g+l[0].length,o.lastIndex=r,a=m,p&&"h"===s&&(s="s"),h.t=s,h}return w("unclosed tag",t,i),h}const l=function s(n,l){n.b=[],n.d=[];let c,u=!1,f=[];function d(t,i){t&&(t=function(t,e,i,s){let n,o;return"string"==typeof e.autoTrim?n=o=e.autoTrim:Array.isArray(e.autoTrim)&&(n=e.autoTrim[1],o=e.autoTrim[0]),(i||!1===i)&&(n=i),(s||!1===s)&&(o=s),"slurp"===n&&"slurp"===o?t.trim():("_"===n||"slurp"===n?t=String.prototype.trimLeft?t.trimLeft():t.replace(/^[\s\uFEFF\xA0]+/,""):"-"!==n&&"nl"!==n||(t=t.replace(/^(?:\n|\r|\r\n)/,"")),"_"===o||"slurp"===o?t=String.prototype.trimRight?t.trimRight():t.replace(/[\s\uFEFF\xA0]+$/,""):"-"!==o&&"nl"!==o||(t=t.replace(/(?:\n|\r|\r\n)$/,"")),t)}(t,e,a,i),t&&(t=t.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),f.push(t)))}for(;null!==(c=o.exec(t));){const o=c[1],a=c[2],l=c[3]||"";let p;for(const t in i)if(i[t]===l){p=t;break}d(o,a),r=c.index+c[0].length,p||w("unrecognized tag type: "+l,t,r);let m=h(c.index,p);const g=m.t;if("h"===g){const t=m.n||"";e.async&&I.test(t)&&(m.a=!0,m.n=t.replace(I,"")),m=s(m),f.push(m)}else if("c"===g){if(n.n===m.n)return u?(u.d=f,n.b.push(u)):n.d=f,n;w("Helper start and end don't match",t,c.index+c[0].length)}else if("b"===g){u?(u.d=f,n.b.push(u)):n.d=f;const t=m.n||"";e.async&&I.test(t)&&(m.a=!0,m.n=t.replace(I,"")),u=m,f=[]}else if("s"===g){const t=m.n||"";e.async&&I.test(t)&&(m.a=!0,m.n=t.replace(I,"")),f.push(m)}else f.push(m)}if(!l)throw y('unclosed helper "'+n.n+'"');return d(t.slice(r,t.length),!1),n.d=f,n}({f:[]},!0);if(e.plugins)for(let t=0;t<e.plugins.length;t++){const i=e.plugins[t];i.processAST&&(l.d=i.processAST(l.d,e))}return l.d}function z(t,e){const i=A(t,e);let s="var tR='';"+(e.useWith?"with("+e.varName+"||{}){":"")+E(i,e)+"if(cb){cb(null,tR)} return tR"+(e.useWith?"}":"");if(e.plugins)for(let t=0;t<e.plugins.length;t++){const i=e.plugins[t];i.processFnString&&(s=i.processFnString(s,e))}return s}function T(t,e){for(let i=0;i<e.length;i++){const s=e[i][1];t=(e[i][2]?"await ":"")+"c.l('F','"+e[i][0]+"')("+t,s&&(t+=","+s),t+=")"}return t}function P(t,e,i,s,n,o){let r="{exec:"+(n?"async ":"")+q(i,e,t)+",params:["+s+"]";return o&&(r+=",name:'"+o+"'"),n&&(r+=",async:true"),r+="}",r}function O(t,e){let i="[";for(let s=0;s<t.length;s++){const n=t[s];i+=P(e,n.res||"",n.d,n.p||"",n.a,n.n),s<t.length&&(i+=",")}return i+="]",i}function q(t,e,i){return"function("+e+"){var tR='';"+E(t,i)+"return tR}"}function E(t,e){let i=0;const s=t.length;let n="";for(;i<s;i++){const s=t[i];if("string"==typeof s)n+="tR+='"+s+"';";else{const t=s.t;let i=s.c||"";const o=s.f,r=s.n||"",a=s.p||"",h=s.res||"",l=s.b,c=!!s.a;if("i"===t){e.defaultFilter&&(i="c.l('F','"+e.defaultFilter+"')("+i+")");let t=T(i,o);!s.raw&&e.autoEscape&&(t="c.l('F','e')("+t+")"),n+="tR+="+t+";"}else if("h"===t)if(e.storage.nativeHelpers.get(r))n+=e.storage.nativeHelpers.get(r)(s,e);else{let t=(c?"await ":"")+"c.l('H','"+r+"')("+P(e,h,s.d,a,c);t+=l?","+O(l,e):",[]",t+=",c)",n+="tR+="+T(t,o)+";"}else"s"===t?n+="tR+="+T((c?"await ":"")+"c.l('H','"+r+"')({params:["+a+"]},[],c)",o)+";":"e"===t&&(n+=i+"\n")}}return n}class D{cache;constructor(t){this.cache=t}define(t,e){this.cache[t]=e}get(t){return this.cache[t]}remove(t){delete this.cache[t]}reset(){this.cache={}}load(t){C(this.cache,t,!0)}}function H(t,e,i,s){if(e&&e.length>0)throw y((s?"Native":"")+"Helper '"+t+"' doesn't accept blocks");if(i&&i.length>0)throw y((s?"Native":"")+"Helper '"+t+"' doesn't accept filters")}function N(t,e,i,s,n){i(t[e],e).then((function(o){s+=o,e===t.length-1?n(s):N(t,e+1,i,s,n)}))}function $(t,e,i,s,n,o){s(e[i],t[e[i]]).then((function(r){n+=r,i===e.length-1?o(n):$(t,e,i+1,s,n,o)}))}const L={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function M(t){return L[t]}const Q=new D({}),W=new D({each:function(t,e){let i="";const s=t.params[0];if(H("each",e,!1),t.async)return new Promise((function(e){N(s,0,t.exec,i,e)}));for(let e=0;e<s.length;e++)i+=t.exec(s[e],e);return i},foreach:function(t,e){const i=t.params[0];if(H("foreach",e,!1),t.async)return new Promise((function(e){$(i,Object.keys(i),0,t.exec,"",e)}));{let e="";for(const s in i)F(i,s)&&(e+=t.exec(s,i[s]));return e}},include:function(t,e,i){H("include",e,!1);const s=i.storage.templates.get(t.params[0]);if(!s)throw y('Could not fetch template "'+t.params[0]+'"');return s(t.params[1],i)},extends:function(t,e,i){const s=t.params[1]||{};s.content=t.exec();for(let t=0;t<e.length;t++){const i=e[t];s[i.name]=i.exec()}const n=i.storage.templates.get(t.params[0]);if(!n)throw y('Could not fetch template "'+t.params[0]+'"');return n(s,i)},useScope:function(t,e){return H("useScope",e,!1),t.exec(t.params[0])}}),B=new D({if:function(t,e){H("if",!1,t.f,!0);let i="if("+t.p+"){"+E(t.d,e)+"}";if(t.b)for(let s=0;s<t.b.length;s++){const n=t.b[s];"else"===n.n?i+="else{"+E(n.d,e)+"}":"elif"===n.n&&(i+="else if("+n.p+"){"+E(n.d,e)+"}")}return i},try:function(t,e){if(H("try",!1,t.f,!0),!t.b||1!==t.b.length||"catch"!==t.b[0].n)throw y("native helper 'try' only accepts 1 block, 'catch'");let i="try{"+E(t.d,e)+"}";const s=t.b[0];return i+="catch"+(s.res?"("+s.res+")":"")+"{"+E(s.d,e)+"}",i},block:function(t,e){return H("block",t.b,t.f,!0),"if(!"+e.varName+"["+t.p+"]){tR+=("+q(t.d,"",e)+")()}else{tR+="+e.varName+"["+t.p+"]}"}}),K=new D({e:function(t){const e=String(t);return/[&<>"']/.test(e)?e.replace(/[&<>"']/g,M):e}}),U={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(t,e){if("H"===t){const t=this.storage.helpers.get(e);if(t)return t;throw y("Can't find helper '"+e+"'")}if("F"===t){const t=this.storage.filters.get(e);if(t)return t;throw y("Can't find filter '"+e+"'")}},async:!1,storage:{helpers:W,nativeHelpers:B,filters:K,templates:Q},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function Z(t,e){const i={};return C(i,U),e&&C(i,e),t&&C(i,t),i.l.bind(i),i}function G(t,e){const i=Z(e||{});let s=Function;if(i.async){if(!x)throw y("This environment doesn't support async/await");s=x}try{return new s(i.varName,"c","cb",z(t,i))}catch(e){throw e instanceof SyntaxError?y("Bad template syntax\n\n"+e.message+"\n"+Array(e.message.length+1).join("=")+"\n"+z(t,i)):e}}function V(t,e){let i;return e.cache&&e.name&&e.storage.templates.get(e.name)?e.storage.templates.get(e.name):(i="function"==typeof t?t:G(t,e),e.cache&&e.name&&e.storage.templates.define(e.name,i),i)}U.l.bind(U);var J=Object.freeze({__proto__:null,compile:G,compileScope:E,compileScopeIntoFunction:q,compileToString:z,defaultConfig:U,filters:K,getConfig:Z,helpers:W,nativeHelpers:B,parse:A,render:function(t,e,i,s){const n=Z(i||{});if(!n.async)return V(t,n)(e,n);{let i;if(!s){if("function"==typeof v)return new v((function(s,o){try{i=V(t,n)(e,n),s(i)}catch(t){o(t)}}));throw y("Please provide a callback function, this env doesn't support Promises")}try{V(t,n)(e,n,s)}catch(t){return s(t)}}},templates:Q});K.define("date_long",((t,e={year:"numeric",month:"long",day:"numeric"})=>{if(t)return new Date(1e3*parseInt(t)).toLocaleDateString("en-GB",e)})),K.define("date_short",((t,e="d/m/y")=>{if(!t)return;const i=new Date(1e3*parseInt(t));return(t=(t=e.replace(/(d)/,i.getDate().toString())).replace(/(m)/,(i.getMonth()+1).toString())).replace(/(y)/,i.getFullYear().toString())})),K.define("public_name",(t=>{if(t)return(t=t.split("_").map((t=>t.length<3?t.toUpperCase():t)).join(" ")).charAt(0).toUpperCase()+t.slice(1)})),K.define("trim_to",((t,e=100)=>{if(t)return t.length<=e?t:t.substr(0,e)+"..."})),K.define("classname",(t=>{if(t)return t.replace(/[\W]+/g,"")})),K.define("abs_url",((t,e=null,i)=>{if(!e)return t;if(!t)return;let s;if(e.domains&&i&&i.origin){const t=e.domains.find((t=>t.origin===i.origin));s=t?t.domain:""}else e.domain&&(s=e.domain);return t.match(/^http/)||!s?t:(t.startsWith("/")||(t="/"+t),location.protocol+"//"+s+t)})),K.define("replace",((t,e,i)=>t.replace(e,i))),K.define("remove_spaces",(t=>t.replace(/ /g,"_"))),K.define("add_spaces",(t=>t.replace(/[_\-]/g," "))),K.define("capitalise",(t=>t.charAt(0).toUpperCase()+t.slice(1))),K.define("lowercase",(t=>t.toLowerCase()));const X=J,Y=class{constructor(t){i(this,t),this.nanoDidLoad=s(this,"nanoDidLoad",7),this.nanoResultsShown=s(this,"nanoResultsShown",3),this.nanoBeforeQuery=s(this,"nanoBeforeQuery",7),this.nanoAfterQuery=s(this,"nanoAfterQuery",7),this.nanoNewResults=s(this,"nanoNewResults",7)}staticFacetFilters={};dynFacetFilters={};tplSlot;outputSlot;slottedInput;hasLoadSlot=!1;resultsDiv;defaultDiv;tpl;facets;placedAlgoliaEles=[];algoliaClient;promiseQueue=new b;get host(){return e(this)}_dynFacetFilters={};inputField;algoliaIndex;indeces=[];indexResults;filterChanged="";currentHits;changeEvent=d.Init;isLoading=!1;wormholeState=this;showResults=!1;resultsPage=0;appId;apiKey;searchIndex={};searchIndexName="";listenTo=null;handleListenToChange(){if(!this.listenTo)return;const t=document.querySelector(this.listenTo);["nano-input","input"].includes(t.tagName.toLocaleLowerCase())&&(this.inputField=t)}query="";operator="and";filters=[];tplRenderFn=X.render;replicaIndex="";browseIndex=!1;minChars=2;storeId;storeMethod="session";nanoDidLoad;nanoResultsShown;nanoBeforeQuery;nanoAfterQuery;nanoNewResults;async removeFilters(t,e){t||e?Object.keys(this._dynFacetFilters).forEach((i=>{t&&this._dynFacetFilters[i].facetName===t&&(this._dynFacetFilters[i].element.value=e?this._dynFacetFilters[i].value.filter((t=>t!==e)):"")})):this.clearAllFacetFilters()}onAllTplUpdate(t){t.stopPropagation(),t.target.tagName.toLowerCase()===u("nano-algolia-results")&&requestAnimationFrame((()=>{this.nanoNewResults.emit(this.indexResults)}))}async onPageChange(t){if(!this.indexResults)return;let e=this.resultsPage;t&&(t.stopPropagation(),e=t.detail.page),e=Math.min(this.indexResults.totalPages-1,e),e=Math.max(e,0),this.indexResults.currentPage!==e&&(this.indexResults.currentPage=e,await this.algoliaSearch(d.Page))}async onFilterChange(t){t.stopPropagation();const e={},i=t.detail;i.element=t.target,this.indexResults?(this.staticFacetFilters[i.filterId]?this.staticFacetFilters[i.filterId]=i:(e[i.filterId]=i,this._dynFacetFilters={...this._dynFacetFilters,...e}),this.indexResults.appliedFilters=this.makeAppliedFilters()):this.staticFacetFilters[i.filterId]=i,this.filterChanged=i.value&&i.value.length?i.filterId:"all",this.resetPage(),this.algoliaSearch(d.Filter)}dynFacetFiltersChange(){Object.values(this._dynFacetFilters).forEach((t=>{this.host.ownerDocument===t.element.ownerDocument?this.dynFacetFilters[t.filterId]=t:delete this.dynFacetFilters[t.filterId]}))}browseIndexChange(){this.browseIndex&&(!this.query||this.query.length<this.minChars)&&(this.query="*")}inputFieldSet(){this.inputField&&"*"!==this.query&&this.inputField&&this.inputField.value!==this.query&&(this.inputField.value=this.query)}queryChange(){this.searchChange()}searchChange=async()=>{if(this.algoliaIndex){if(!this.query||this.query.length<this.minChars){if(!this.browseIndex)return this.query&&0!==this.query.length?void 0:void this.handleSearchReset();if("*"!==this.query)return void(this.query="*")}this.isLoading=!0,setTimeout((async()=>{this.resetPage(),await this.algoliaSearch(d.Init),await this.updateContent(),setTimeout((()=>this.isLoading=!1),800),this.showResults=!0,this.nanoResultsShown.emit({meta:this.indexResults,client:{appId:this.appId,apiKey:this.apiKey}})}),200)}};async internalIndexSwitch(){this.replicaIndex&&this.indexResults&&this.indexResults.index!==this.replicaIndex&&(this.indexResults.index=this.replicaIndex,this.algoliaIndex=this.algoliaClient.initIndex(this.indexResults.index),this.resetPage(),this.algoliaSearch(d.Replica))}pageChange(){this.onPageChange()}searchIndexNameChange(){!this.searchIndexName||!this.searchIndexName.length||this.searchIndex&&this.searchIndex.index===this.searchIndexName||(this.searchIndex={index:this.searchIndexName})}initAlgoliaClient(){this.appId&&this.apiKey&&(this.algoliaClient=a(this.appId,this.apiKey))}initAlgoliaIndex(){this.algoliaClient&&this.searchIndex&&this.searchIndex.index&&(this.searchIndex.hitsPerPage||(this.searchIndex.hitsPerPage=100),this.replicaIndex&&(this.searchIndex.index=this.replicaIndex),this.searchIndexName=this.searchIndex.index,this.algoliaIndex=this.algoliaClient.initIndex(this.searchIndex.index),this.searchChange())}showResultsChange(){this.resultsDiv&&this.defaultDiv&&(this.showResults?(this.resultsDiv.style.width=this.host.scrollWidth+"px",this.resultsDiv.style.minHeight=this.host.scrollHeight+"px",n((()=>{this.resultsDiv.addEventListener("transitionend",this.onResultDisplay),this.resultsDiv.style.display="block",setTimeout((()=>this.resultsDiv.classList.add("show")),50)}))):n((()=>{this.resultsDiv.classList.remove("shown"),this.defaultDiv.style.display="block",setTimeout((()=>{this.resultsDiv.addEventListener("transitionend",this.onResultDisplay),this.resultsDiv.classList.remove("show"),this.slottedInput?this.slottedInput.focus({preventScroll:!0}):this.defaultDiv.focus({preventScroll:!0})}),50)})))}handleFilterpropChange(){this.algoliaSearch(d.Init)}fixDomain(t){return this.searchIndex&&this.searchIndex.domain?(t.hits.map((t=>{t.url&&!t.url.match(/^http/)&&(t.url=location.protocol+"//"+this.searchIndex.domain+t.url)})),t):t}makeAppliedFilters=()=>{const t=[],e=e=>{Object.values(e).forEach((e=>{if(e.value&&e.value.length){const i=t.find((t=>t.name===e.facetName));i?i.values=[...i.values,...e.value]:t.push({name:e.facetName,values:[...e.value]})}}))};return e(this.dynFacetFilters),e(this.staticFacetFilters),t.length?t:null};algoliaSearch=async t=>this.promiseQueue.enqueue((()=>this.queueSearch(t)));queueSearch=async t=>{if(!(this.algoliaIndex&&this.query&&this.searchIndex&&this.searchIndex.index))return;this.nanoBeforeQuery.emit(this.indexResults),d.Init===t&&this.clearAllFacetFilters();const e={filters:this.algoliaFilterStr(),page:this.indexResults?this.indexResults.currentPage:0,clickAnalytics:!0};this.searchIndex.filters&&(e.facets=this.searchIndex.filters),this.searchIndex.hitsPerPage&&(e.hitsPerPage=this.searchIndex.hitsPerPage);let i=await this.algoliaIndex.search(this.query,e);return i=this.fixDomain(i),this.changeEvent=t,t!==d.Init&&this.indexResults||(this.indexResults={queryID:i.queryID,currentPage:0,totalHits:i.nbHits,hitsPerPage:null,origFilters:i.facets,query:this.query,domain:this.searchIndex.domain||null,totalHitsWithFilters:0,results:[],totalPages:0,appliedFilters:this.makeAppliedFilters(),indexName:this.searchIndex.name||null,index:this.searchIndex.index,searchIndex:this.searchIndex}),this.indexResults.dynFilters=i.facets,this.indexResults.results=i.hits,this.indexResults.totalHitsWithFilters=i.nbHits,this.indexResults.currentPage=i.page,this.indexResults.totalPages=i.nbPages,this.indexResults.hitsPerPage=i.hitsPerPage,this.indexResults.query=i.query,this.changeEvent!==d.Page&&this.changeEvent!==d.Replica&&(this.facets=i.facets),this.nanoAfterQuery.emit(this.indexResults),new Promise((t=>{setTimeout((()=>t("tpl updated")),20)})).then((()=>{this.currentHits=this.indexResults.results,this.resultsPage=this.indexResults.currentPage}))};resetPage(){this.indexResults&&(this.indexResults.currentPage=0)}clearAllFacetFilters(){Object.values(this._dynFacetFilters).forEach((t=>{t.element.value=""})),this._dynFacetFilters={}}algoliaFilterStr(){const t={},e=e=>{let i,s;Object.keys(e).forEach((n=>{i=e[n],t[n]=t[n]||{name:i.facetName,or:[],and:[],not:[]},s=t[n][i.operator],i.value&&i.value.length&&(t[n][i.operator]=[...s,...i.value])}))};e(this.dynFacetFilters),e(this.staticFacetFilters);const i=(t,e)=>e.indexOf(" ")>-1?t+':"'+e+'"':t+":"+e;let s,n,o=[];return Object.values(t).forEach((function(t){Object.keys(t).filter((t=>t.match(/(or|and|not)/))).forEach((e=>{s=t,n=t.name,"or"===e||"and"===e?s[e].length&&o.push("( "+s[e].map((t=>{if(t.length)return i(n,t)})).join(" "+e.toLocaleUpperCase()+" ")+" )"):s.not.length&&o.push("( "+s[e].map((t=>{if(t.length)return"NOT "+i(n,t)})).join(" AND ")+" )")}))})),o=[...this.filters,...o],o.join(" "+this.operator.toLocaleUpperCase()+" ")}handleInputChange(t){t.target===this.inputField&&(this.query=this.inputField.value)}handleSearchReset=()=>{this.showResults=!1,this.indexResults=null};onResultDisplay=()=>{n((()=>{this.resultsDiv.removeEventListener("transitionend",this.onResultDisplay),this.showResults?(this.defaultDiv.style.display="none",this.resultsDiv.classList.add("shown"),this.resultsDiv.style.minHeight="",this.resultsDiv.style.width=""):this.resultsDiv.style.display="none"}))};async updateContent(){return this.promiseQueue.enqueue((()=>this.updateContentQueue()))}async updateContentQueue(){const t=this.outputSlot||this.resultsDiv;if(!t||!this.tpl)return"no tpl";const e=document.createElement("div");e.innerHTML=this.tpl;const i=[];return this.placedAlgoliaEles=[],Array.from(e.querySelectorAll(`${u("nano-algolia")}, ${u("nano-algolia-filter")}, ${u("nano-algolia-results")}`)).forEach(((t,e)=>{const s=document.createElement("div");s.dataset.placeholderId=e.toString(),s.classList.add("nano-ele-placeholder"),i.push(t),t.parentNode.replaceChild(s,t)})),t.innerHTML=this.tplRenderFn(e.innerHTML.replace(/&gt;/gm,">").replace(/&lt;/gm,"<").replace(/&amp;/gm,"&"),this.indexResults),Array.from(t.querySelectorAll("div.nano-ele-placeholder")).forEach((t=>{t.parentNode.replaceChild(i[parseInt(t.dataset.placeholderId)],t),this.placedAlgoliaEles.push(i[parseInt(t.dataset.placeholderId)])})),this.placedAlgoliaEles.length?new Promise((e=>{const i=s=>{this.placedAlgoliaEles=this.placedAlgoliaEles.filter((t=>t!==s.detail)),this.placedAlgoliaEles.length||(setTimeout((()=>e("tpl updated")),500),t.removeEventListener("nanoTplUpdated",i))};t.addEventListener("nanoTplUpdated",i)})):Promise.resolve("algolia setup")}componentWillLoad(){o((()=>{this.tplSlot=h(this.host,'[slot="template"]')[0],this.outputSlot=h(this.host,'[slot="output"]')[0],this.slottedInput=h(this.host,'[slot="search-input"]')[0],this.hasLoadSlot=!!h(this.host,'[slot="loader"]')[0],this.tplSlot&&(this.tpl=this.tplSlot.innerHTML||this.tplSlot.innerText),this.slottedInput&&(this.slottedInput.tagName.toLocaleLowerCase()===u("nano-input")||this.slottedInput instanceof HTMLInputElement)?this.inputField=this.slottedInput:this.slottedInput?this.inputField=this.slottedInput.querySelector(`${u("nano-input")}, input:not([type="radio"]):not([type="checkbox"])`):this.handleListenToChange(),n((()=>{this.showResults&&this.tpl&&this.searchChange()}))})),this.searchIndexNameChange(),this.initAlgoliaClient(),this.initAlgoliaIndex(),function(t,i){var s=e(t),n=new Map,o={wormholes:n,state:i};p.set(t,o);var r=t.connectedCallback;t.connectedCallback=function(){p.set(t,o),r&&r.call(t)};var a=t.disconnectedCallback;t.disconnectedCallback=function(){p.delete(t),a&&a.call(t)},s.addEventListener("openWormhole",(function(t){t.stopPropagation();var e=t.detail,i=e.consumer,s=e.onOpen;if(!n.has(i)){if("symbol"!=typeof i){var r=i.connectedCallback,a=i.disconnectedCallback;i.connectedCallback=function(){n.set(i,t.detail),r&&r.call(i)},i.disconnectedCallback=function(){n.delete(i),a&&a.call(i)}}n.set(i,t.detail),m(t.detail,o.state),null==s||s.resolve((function(){n.delete(i)}))}})),s.addEventListener("closeWormhole",(function(t){n.delete(t.detail)}))}(this,this.wormholeState),this.storeId&&(l.init(this,["query","replicaIndex"],this.storeMethod,this.storeId),l.init(this,["apiKey","appId","searchIndex"],"session",this.storeId+"_api")),this.internalIndexSwitch()}connectedCallback(){this.searchChange=c(this.searchChange,300),this.browseIndexChange(),this.host.dispatchEvent(new CustomEvent("nanoDidLoad",{detail:this.host}))}render(){const t={indexResults:this.indexResults,results:this.currentHits,filterChanged:this.filterChanged,tplRenderFn:this.tplRenderFn,resultsPage:this.resultsPage,changeEvent:this.changeEvent,facets:this.facets,algoliaIndex:this.algoliaIndex,searchIndex:this.searchIndex,globalStoreMethod:this.storeMethod,isLoading:this.isLoading};return f(r,{key:"e5a080bf3b11c991465f1b44521b75539f80d5ec",class:{"show-results":this.showResults,"is-loading":this.isLoading,"nano-algolia":!0},"aria-busy":this.isLoading},this.hasLoadSlot&&f("div",{key:"586696526af9ba7b721ebfe8aeba2b5a45b8a19a",hidden:!this.isLoading},f("slot",{key:"40556633911954fd20b756fedf71aea7e15b15e1",name:"loader"})),!this.hasLoadSlot&&f("div",{key:"e5ee4968b6864b656b3537ec46b69e64ebe76370",class:{loader:!0,loading:this.isLoading}},f("nano-spinner",{key:"420a97d058127ea029329d6eca5055c0c54f4c1f",overlay:!0})),f(g,{key:"9c271e35ea7f850eb1ec2f99415ab2eebf014387",state:t},f("slot",{key:"7a7a5ac869321d6db0a2f6f784a28e638cbe1a3f",name:"search-input"}),f("div",{key:"91b799022bee756066f1eb60038fdb428c98d3dc",class:"results-container","aria-live":"polite"},f("div",{key:"4209e438e0cefbc244dde4c3a9c10e3e5bf56137",ref:t=>this.resultsDiv=t,class:"results"},f("slot",{key:"44b89a4cae72f8ff38c08dd605df32df03a2fc9a",name:"output"})))),f("div",{key:"a584e0f2f10c38ffc46decc5b4b6bd2a1e14118a",ref:t=>this.defaultDiv=t,class:"default",tabindex:"-1",part:"default-content"},f("slot",{key:"dcf3c87479d48774b63bf32b4e2de2bfe9a6b1ea"})))}static get watchers(){return{listenTo:["handleListenToChange"],_dynFacetFilters:["dynFacetFiltersChange"],browseIndex:["browseIndexChange"],inputField:["inputFieldSet"],query:["queryChange"],replicaIndex:["internalIndexSwitch"],resultsPage:["pageChange"],searchIndexName:["searchIndexNameChange"],apiKey:["initAlgoliaClient"],appId:["initAlgoliaClient"],searchIndex:["initAlgoliaIndex"],showResults:["showResultsChange"],filters:["handleFilterpropChange"]}}};Y.style=":host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host{position:relative;display:block}:host ::slotted([slot=search-template]){display:none !important}.loader{opacity:0;position:fixed;block-size:100%;inline-size:100%;min-block-size:100%;max-block-size:100vh !important;max-inline-size:100vw !important;inset-inline-start:0;inset-block-start:0;z-index:-10;font-size:60px;display:flex;align-items:center;justify-content:center;transition:opacity 0.2s ease, z-index 0.01s ease 0.2s}.loader.loading{opacity:1;z-index:10;transition:z-index 0.01s ease, opacity 0.2s ease 0.01s}.default{block-size:100%}.default:focus{outline:none}.results{opacity:0;outline:none;overflow:auto;transition:transform 0.3s ease, opacity 0.3s ease, visibility 0.01s ease 0.3s, z-index 0.01s ease 0.3s;transform:translate(0, 100px);visibility:hidden;z-index:-1;position:absolute;inset-block-start:0;inset-inline-start:0;display:none}.results-container{position:relative}.results.show{transition:z-index 0.01s ease, visibility 0.01s ease, transform 0.3s ease 0.01s, opacity 0.3s ease 0.01s, overflow 0.01s ease 0.31s;transform:translate(0, 0);visibility:visible;opacity:1;z-index:10;overflow:hidden}.results.shown{block-size:auto !important;inline-size:auto !important;display:block;position:static;transform:none;z-index:auto;visibility:inherit;opacity:initial;overflow:visible}";export{Y as nano_algolia}
4
+ import{i as t,g as e,r as i,c as s,d as n,e as o,a as r}from"./index-DgO0qeQ9.js";import{a}from"./algoliasearch-lite.esm.browser-BTIloVU8.js";import{g as h}from"./dom-CrrHp_I_.js";import{C as l}from"./component-store-DeKxotC5.js";import{d as c}from"./throttle-C93FMm2Z.js";import{t as u,h as f}from"./renderer-T8etwwhk.js";import{S as d}from"./algolia-data-D9ZAstcC.js";var p=new Map,m=function(t,e){var i=t.updater;t.fields.forEach((function(t){i(t,e[t])}))},g=function(e,i){var s=e.state,n=t();if(p.has(n)){var o=p.get(n);o.state=s,o.wormholes.forEach((function(t){m(t,s)}))}return i};class y{queue=[];workingOnPromise=!1;static pendingPromise=!1;stop=!1;limit=null;enqueue(t){return new Promise(((e,i)=>{this.queue.push({promise:t,resolve:e,reject:i}),this.dequeue()}))}dequeue(){if(this.workingOnPromise)return!1;if(this.stop)return this.queue=[],void(this.stop=!1);const t=this.queue.shift();if(!t)return!1;try{this.workingOnPromise=!0,t.promise().then((e=>{this.workingOnPromise=!1,t.resolve(e),this.dequeue()})).catch((e=>{this.workingOnPromise=!1,t.reject(e),this.dequeue()}))}catch(e){this.workingOnPromise=!1,t.reject(e),this.dequeue()}return!0}}function b(t){const e=new Error(t);var i,s;return i=e,s=b.prototype,Object.setPrototypeOf?Object.setPrototypeOf(i,s):i.__proto__=s,e}function w(t,e,i){const s=e.slice(0,i).split(/\n/),n=s.length,o=s[n-1].length+1;throw b(t+=" at line "+n+" col "+o+":\n\n "+e.split(/\n/)[n-1]+"\n "+Array(o).join(" ")+"^")}b.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});const v=new Function("return this")().Promise;let x=!1;try{x=new Function("return (async function(){}).constructor")()}catch(t){if(!(t instanceof SyntaxError))throw t}function F(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function C(t,e,i){for(const s in e)F(e,s)&&(t[s]=null==e[s]||"object"!=typeof e[s]||"storage"!==s&&"prefixes"!==s||i?e[s]:C({},e[s]));return t}const I=/^async +/,k=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,S=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,R=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,_=/[.*+\-?^${}()|[\]\\]/g;function j(t){return _.test(t)?t.replace(_,"\\$&"):t}function A(t,e){e.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),k.lastIndex=0,S.lastIndex=0,R.lastIndex=0;const i=e.prefixes,s=[i.h,i.b,i.i,i.r,i.c,i.e].reduce((function(t,e){return t&&e?t+"|"+j(e):e?j(e):t}),""),n=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+j(e.tags[1])+")","g"),o=new RegExp("([^]*?)"+j(e.tags[0])+"(-|_)?\\s*("+s+")?\\s*","g");let r=0,a=!1;function h(i,s){const h={f:[]};let l,c=0,u="c";function f(i){const s=t.slice(r,i);let n=s.trim();if("f"===u)"safe"===n?h.raw=!0:e.async&&I.test(n)?(n=n.replace(I,""),h.f.push([n,"",!0])):h.f.push([n,""]);else if("fp"===u)h.f[h.f.length-1][1]+=n;else if("err"===u){if(n){const e=s.search(/\S/);w("invalid syntax",t,r+e)}}else h[u]=n;r=i+1}for("h"===s||"b"===s||"c"===s?u="n":"r"===s&&(h.raw=!0,s="i"),n.lastIndex=r;null!==(l=n.exec(t));){const e=l[1],i=l[2],d=l[3],p=l[4],m=l[5],g=l.index;if(e)"("===e?(0===c&&("n"===u?(f(g),u="p"):"f"===u&&(f(g),u="fp")),c++):")"===e?(c--,0===c&&"c"!==u&&(f(g),u="err")):0===c&&"|"===e?(f(g),u="f"):"=>"===e&&(f(g),r+=1,u="res");else if(i)if("/*"===i){const e=t.indexOf("*/",n.lastIndex);-1===e&&w("unclosed comment",t,l.index),n.lastIndex=e+2}else"'"===i?(S.lastIndex=l.index,S.exec(t)?n.lastIndex=S.lastIndex:w("unclosed string",t,l.index)):'"'===i?(R.lastIndex=l.index,R.exec(t)?n.lastIndex=R.lastIndex:w("unclosed string",t,l.index)):"`"===i&&(k.lastIndex=l.index,k.exec(t)?n.lastIndex=k.lastIndex:w("unclosed string",t,l.index));else if(d)return f(g),r=g+l[0].length,o.lastIndex=r,a=m,p&&"h"===s&&(s="s"),h.t=s,h}return w("unclosed tag",t,i),h}const l=function s(n,l){n.b=[],n.d=[];let c,u=!1,f=[];function d(t,i){t&&(t=function(t,e,i,s){let n,o;return"string"==typeof e.autoTrim?n=o=e.autoTrim:Array.isArray(e.autoTrim)&&(n=e.autoTrim[1],o=e.autoTrim[0]),(i||!1===i)&&(n=i),(s||!1===s)&&(o=s),"slurp"===n&&"slurp"===o?t.trim():("_"===n||"slurp"===n?t=String.prototype.trimLeft?t.trimLeft():t.replace(/^[\s\uFEFF\xA0]+/,""):"-"!==n&&"nl"!==n||(t=t.replace(/^(?:\n|\r|\r\n)/,"")),"_"===o||"slurp"===o?t=String.prototype.trimRight?t.trimRight():t.replace(/[\s\uFEFF\xA0]+$/,""):"-"!==o&&"nl"!==o||(t=t.replace(/(?:\n|\r|\r\n)$/,"")),t)}(t,e,a,i),t&&(t=t.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),f.push(t)))}for(;null!==(c=o.exec(t));){const o=c[1],a=c[2],l=c[3]||"";let p;for(const t in i)if(i[t]===l){p=t;break}d(o,a),r=c.index+c[0].length,p||w("unrecognized tag type: "+l,t,r);let m=h(c.index,p);const g=m.t;if("h"===g){const t=m.n||"";e.async&&I.test(t)&&(m.a=!0,m.n=t.replace(I,"")),m=s(m),f.push(m)}else if("c"===g){if(n.n===m.n)return u?(u.d=f,n.b.push(u)):n.d=f,n;w("Helper start and end don't match",t,c.index+c[0].length)}else if("b"===g){u?(u.d=f,n.b.push(u)):n.d=f;const t=m.n||"";e.async&&I.test(t)&&(m.a=!0,m.n=t.replace(I,"")),u=m,f=[]}else if("s"===g){const t=m.n||"";e.async&&I.test(t)&&(m.a=!0,m.n=t.replace(I,"")),f.push(m)}else f.push(m)}if(!l)throw b('unclosed helper "'+n.n+'"');return d(t.slice(r,t.length),!1),n.d=f,n}({f:[]},!0);if(e.plugins)for(let t=0;t<e.plugins.length;t++){const i=e.plugins[t];i.processAST&&(l.d=i.processAST(l.d,e))}return l.d}function z(t,e){const i=A(t,e);let s="var tR='';"+(e.useWith?"with("+e.varName+"||{}){":"")+E(i,e)+"if(cb){cb(null,tR)} return tR"+(e.useWith?"}":"");if(e.plugins)for(let t=0;t<e.plugins.length;t++){const i=e.plugins[t];i.processFnString&&(s=i.processFnString(s,e))}return s}function T(t,e){for(let i=0;i<e.length;i++){const s=e[i][1];t=(e[i][2]?"await ":"")+"c.l('F','"+e[i][0]+"')("+t,s&&(t+=","+s),t+=")"}return t}function P(t,e,i,s,n,o){let r="{exec:"+(n?"async ":"")+q(i,e,t)+",params:["+s+"]";return o&&(r+=",name:'"+o+"'"),n&&(r+=",async:true"),r+="}",r}function O(t,e){let i="[";for(let s=0;s<t.length;s++){const n=t[s];i+=P(e,n.res||"",n.d,n.p||"",n.a,n.n),s<t.length&&(i+=",")}return i+="]",i}function q(t,e,i){return"function("+e+"){var tR='';"+E(t,i)+"return tR}"}function E(t,e){let i=0;const s=t.length;let n="";for(;i<s;i++){const s=t[i];if("string"==typeof s)n+="tR+='"+s+"';";else{const t=s.t;let i=s.c||"";const o=s.f,r=s.n||"",a=s.p||"",h=s.res||"",l=s.b,c=!!s.a;if("i"===t){e.defaultFilter&&(i="c.l('F','"+e.defaultFilter+"')("+i+")");let t=T(i,o);!s.raw&&e.autoEscape&&(t="c.l('F','e')("+t+")"),n+="tR+="+t+";"}else if("h"===t)if(e.storage.nativeHelpers.get(r))n+=e.storage.nativeHelpers.get(r)(s,e);else{let t=(c?"await ":"")+"c.l('H','"+r+"')("+P(e,h,s.d,a,c);t+=l?","+O(l,e):",[]",t+=",c)",n+="tR+="+T(t,o)+";"}else"s"===t?n+="tR+="+T((c?"await ":"")+"c.l('H','"+r+"')({params:["+a+"]},[],c)",o)+";":"e"===t&&(n+=i+"\n")}}return n}class D{cache;constructor(t){this.cache=t}define(t,e){this.cache[t]=e}get(t){return this.cache[t]}remove(t){delete this.cache[t]}reset(){this.cache={}}load(t){C(this.cache,t,!0)}}function H(t,e,i,s){if(e&&e.length>0)throw b((s?"Native":"")+"Helper '"+t+"' doesn't accept blocks");if(i&&i.length>0)throw b((s?"Native":"")+"Helper '"+t+"' doesn't accept filters")}function N(t,e,i,s,n){i(t[e],e).then((function(o){s+=o,e===t.length-1?n(s):N(t,e+1,i,s,n)}))}function $(t,e,i,s,n,o){s(e[i],t[e[i]]).then((function(r){n+=r,i===e.length-1?o(n):$(t,e,i+1,s,n,o)}))}const L={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function M(t){return L[t]}const Q=new D({}),W=new D({each:function(t,e){let i="";const s=t.params[0];if(H("each",e,!1),t.async)return new Promise((function(e){N(s,0,t.exec,i,e)}));for(let e=0;e<s.length;e++)i+=t.exec(s[e],e);return i},foreach:function(t,e){const i=t.params[0];if(H("foreach",e,!1),t.async)return new Promise((function(e){$(i,Object.keys(i),0,t.exec,"",e)}));{let e="";for(const s in i)F(i,s)&&(e+=t.exec(s,i[s]));return e}},include:function(t,e,i){H("include",e,!1);const s=i.storage.templates.get(t.params[0]);if(!s)throw b('Could not fetch template "'+t.params[0]+'"');return s(t.params[1],i)},extends:function(t,e,i){const s=t.params[1]||{};s.content=t.exec();for(let t=0;t<e.length;t++){const i=e[t];s[i.name]=i.exec()}const n=i.storage.templates.get(t.params[0]);if(!n)throw b('Could not fetch template "'+t.params[0]+'"');return n(s,i)},useScope:function(t,e){return H("useScope",e,!1),t.exec(t.params[0])}}),B=new D({if:function(t,e){H("if",!1,t.f,!0);let i="if("+t.p+"){"+E(t.d,e)+"}";if(t.b)for(let s=0;s<t.b.length;s++){const n=t.b[s];"else"===n.n?i+="else{"+E(n.d,e)+"}":"elif"===n.n&&(i+="else if("+n.p+"){"+E(n.d,e)+"}")}return i},try:function(t,e){if(H("try",!1,t.f,!0),!t.b||1!==t.b.length||"catch"!==t.b[0].n)throw b("native helper 'try' only accepts 1 block, 'catch'");let i="try{"+E(t.d,e)+"}";const s=t.b[0];return i+="catch"+(s.res?"("+s.res+")":"")+"{"+E(s.d,e)+"}",i},block:function(t,e){return H("block",t.b,t.f,!0),"if(!"+e.varName+"["+t.p+"]){tR+=("+q(t.d,"",e)+")()}else{tR+="+e.varName+"["+t.p+"]}"}}),K=new D({e:function(t){const e=String(t);return/[&<>"']/.test(e)?e.replace(/[&<>"']/g,M):e}}),U={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(t,e){if("H"===t){const t=this.storage.helpers.get(e);if(t)return t;throw b("Can't find helper '"+e+"'")}if("F"===t){const t=this.storage.filters.get(e);if(t)return t;throw b("Can't find filter '"+e+"'")}},async:!1,storage:{helpers:W,nativeHelpers:B,filters:K,templates:Q},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function Z(t,e){const i={};return C(i,U),e&&C(i,e),t&&C(i,t),i.l.bind(i),i}function G(t,e){const i=Z(e||{});let s=Function;if(i.async){if(!x)throw b("This environment doesn't support async/await");s=x}try{return new s(i.varName,"c","cb",z(t,i))}catch(e){throw e instanceof SyntaxError?b("Bad template syntax\n\n"+e.message+"\n"+Array(e.message.length+1).join("=")+"\n"+z(t,i)):e}}function V(t,e){let i;return e.cache&&e.name&&e.storage.templates.get(e.name)?e.storage.templates.get(e.name):(i="function"==typeof t?t:G(t,e),e.cache&&e.name&&e.storage.templates.define(e.name,i),i)}U.l.bind(U);var J=Object.freeze({__proto__:null,compile:G,compileScope:E,compileScopeIntoFunction:q,compileToString:z,defaultConfig:U,filters:K,getConfig:Z,helpers:W,nativeHelpers:B,parse:A,render:function(t,e,i,s){const n=Z(i||{});if(!n.async)return V(t,n)(e,n);{let i;if(!s){if("function"==typeof v)return new v((function(s,o){try{i=V(t,n)(e,n),s(i)}catch(t){o(t)}}));throw b("Please provide a callback function, this env doesn't support Promises")}try{V(t,n)(e,n,s)}catch(t){return s(t)}}},templates:Q});K.define("date_long",((t,e={year:"numeric",month:"long",day:"numeric"})=>{if(t)return new Date(1e3*parseInt(t)).toLocaleDateString("en-GB",e)})),K.define("date_short",((t,e="d/m/y")=>{if(!t)return;const i=new Date(1e3*parseInt(t));return(t=(t=e.replace(/(d)/,i.getDate().toString())).replace(/(m)/,(i.getMonth()+1).toString())).replace(/(y)/,i.getFullYear().toString())})),K.define("public_name",(t=>{if(t)return(t=t.split("_").map((t=>t.length<3?t.toUpperCase():t)).join(" ")).charAt(0).toUpperCase()+t.slice(1)})),K.define("trim_to",((t,e=100)=>{if(t)return t.length<=e?t:t.substr(0,e)+"..."})),K.define("classname",(t=>{if(t)return t.replace(/[\W]+/g,"")})),K.define("abs_url",((t,e=null,i)=>{if(!e)return t;if(!t)return;let s;if(e.domains&&i&&i.origin){const t=e.domains.find((t=>t.origin===i.origin));s=t?t.domain:""}else e.domain&&(s=e.domain);return t.match(/^http/)||!s?t:(t.startsWith("/")||(t="/"+t),location.protocol+"//"+s+t)})),K.define("replace",((t,e,i)=>t.replace(e,i))),K.define("remove_spaces",(t=>t.replace(/ /g,"_"))),K.define("add_spaces",(t=>t.replace(/[_\-]/g," "))),K.define("capitalise",(t=>t.charAt(0).toUpperCase()+t.slice(1))),K.define("lowercase",(t=>t.toLowerCase())),K.define("tag_tidy",(t=>{const e=t.split(">");return e.map((t=>t.trim()))[e.length-1]}));const X=J,Y=class{constructor(t){i(this,t),this.nanoDidLoad=s(this,"nanoDidLoad",7),this.nanoResultsShown=s(this,"nanoResultsShown",3),this.nanoBeforeQuery=s(this,"nanoBeforeQuery",7),this.nanoAfterQuery=s(this,"nanoAfterQuery",7),this.nanoNewResults=s(this,"nanoNewResults",7)}staticFacetFilters={};dynFacetFilters={};tplSlot;outputSlot;slottedInput;hasLoadSlot=!1;resultsDiv;defaultDiv;tpl;facets;placedAlgoliaEles=[];algoliaClient;promiseQueue=new y;get host(){return e(this)}_dynFacetFilters={};inputField;algoliaIndex;indeces=[];indexResults;filterChanged="";currentHits;changeEvent=d.Init;isLoading=!1;wormholeState=this;showResults=!1;resultsPage=0;appId;apiKey;searchIndex={};searchIndexName="";listenTo=null;handleListenToChange(){if(!this.listenTo)return;const t=document.querySelector(this.listenTo);["nano-input","input"].includes(t.tagName.toLocaleLowerCase())&&(this.inputField=t)}query="";operator="and";filters=[];tplRenderFn=X.render;replicaIndex="";browseIndex=!1;minChars=2;storeId;storeMethod="session";nanoDidLoad;nanoResultsShown;nanoBeforeQuery;nanoAfterQuery;nanoNewResults;async removeFilters(t,e){t||e?Object.keys(this._dynFacetFilters).forEach((i=>{t&&this._dynFacetFilters[i].facetName===t&&(this._dynFacetFilters[i].element.value=e?this._dynFacetFilters[i].value.filter((t=>t!==e)):"")})):this.clearAllFacetFilters()}onAllTplUpdate(t){t.stopPropagation(),t.target.tagName.toLowerCase()===u("nano-algolia-results")&&requestAnimationFrame((()=>{this.nanoNewResults.emit(this.indexResults)}))}async onPageChange(t){if(!this.indexResults)return;let e=this.resultsPage;t&&(t.stopPropagation(),e=t.detail.page),e=Math.min(this.indexResults.totalPages-1,e),e=Math.max(e,0),this.indexResults.currentPage!==e&&(this.indexResults.currentPage=e,await this.algoliaSearch(d.Page))}async onFilterChange(t){t.stopPropagation();const e={},i=t.detail;i.element=t.target,this.indexResults?(this.staticFacetFilters[i.filterId]?this.staticFacetFilters[i.filterId]=i:(e[i.filterId]=i,this._dynFacetFilters={...this._dynFacetFilters,...e}),this.indexResults.appliedFilters=this.makeAppliedFilters()):this.staticFacetFilters[i.filterId]=i,this.filterChanged=i.value&&i.value.length?i.filterId:"all",this.resetPage(),this.algoliaSearch(d.Filter)}dynFacetFiltersChange(){Object.values(this._dynFacetFilters).forEach((t=>{this.host.ownerDocument===t.element.ownerDocument?this.dynFacetFilters[t.filterId]=t:delete this.dynFacetFilters[t.filterId]}))}browseIndexChange(){this.browseIndex&&(!this.query||this.query.length<this.minChars)&&(this.query="*")}inputFieldSet(){this.inputField&&"*"!==this.query&&this.inputField&&this.inputField.value!==this.query&&(this.inputField.value=this.query)}queryChange(){this.searchChange()}searchChange=async()=>{if(this.algoliaIndex){if(!this.query||this.query.length<this.minChars){if(!this.browseIndex)return this.query&&0!==this.query.length?void 0:void this.handleSearchReset();if("*"!==this.query)return void(this.query="*")}this.isLoading=!0,setTimeout((async()=>{this.resetPage(),await this.algoliaSearch(d.Init),await this.updateContent(),setTimeout((()=>this.isLoading=!1),800),this.showResults=!0,this.nanoResultsShown.emit({meta:this.indexResults,client:{appId:this.appId,apiKey:this.apiKey}})}),200)}};async internalIndexSwitch(){this.replicaIndex&&this.indexResults&&this.indexResults.index!==this.replicaIndex&&(this.indexResults.index=this.replicaIndex,this.algoliaIndex=this.algoliaClient.initIndex(this.indexResults.index),this.resetPage(),this.algoliaSearch(d.Replica))}pageChange(){this.onPageChange()}searchIndexNameChange(){!this.searchIndexName||!this.searchIndexName.length||this.searchIndex&&this.searchIndex.index===this.searchIndexName||(this.searchIndex={index:this.searchIndexName})}initAlgoliaClient(){this.appId&&this.apiKey&&(this.algoliaClient=a(this.appId,this.apiKey))}initAlgoliaIndex(){this.algoliaClient&&this.searchIndex&&this.searchIndex.index&&(this.searchIndex.hitsPerPage||(this.searchIndex.hitsPerPage=100),this.replicaIndex&&(this.searchIndex.index=this.replicaIndex),this.searchIndexName=this.searchIndex.index,this.algoliaIndex=this.algoliaClient.initIndex(this.searchIndex.index),this.searchChange())}showResultsChange(){this.resultsDiv&&this.defaultDiv&&(this.showResults?(this.resultsDiv.style.width=this.host.scrollWidth+"px",this.resultsDiv.style.minHeight=this.host.scrollHeight+"px",n((()=>{this.resultsDiv.addEventListener("transitionend",this.onResultDisplay),this.resultsDiv.style.display="block",setTimeout((()=>this.resultsDiv.classList.add("show")),50)}))):n((()=>{this.resultsDiv.classList.remove("shown"),this.defaultDiv.style.display="block",setTimeout((()=>{this.resultsDiv.addEventListener("transitionend",this.onResultDisplay),this.resultsDiv.classList.remove("show"),this.slottedInput?this.slottedInput.focus({preventScroll:!0}):this.defaultDiv.focus({preventScroll:!0})}),50)})))}handleFilterpropChange(){this.algoliaSearch(d.Init)}fixDomain(t){return this.searchIndex&&this.searchIndex.domain?(t.hits.map((t=>{t.url&&!t.url.match(/^http/)&&(t.url=location.protocol+"//"+this.searchIndex.domain+t.url)})),t):t}makeAppliedFilters=()=>{const t=[],e=e=>{Object.values(e).forEach((e=>{if(e.value&&e.value.length){const i=t.find((t=>t.name===e.facetName));i?i.values=[...i.values,...e.value]:t.push({name:e.facetName,values:[...e.value]})}}))};return e(this.dynFacetFilters),e(this.staticFacetFilters),t.length?t:null};algoliaSearch=async t=>this.promiseQueue.enqueue((()=>this.queueSearch(t)));queueSearch=async t=>{if(!(this.algoliaIndex&&this.query&&this.searchIndex&&this.searchIndex.index))return;this.nanoBeforeQuery.emit(this.indexResults),d.Init===t&&this.clearAllFacetFilters();const e={filters:this.algoliaFilterStr(),page:this.indexResults?this.indexResults.currentPage:0,clickAnalytics:!0};this.searchIndex.filters&&(e.facets=this.searchIndex.filters),this.searchIndex.hitsPerPage&&(e.hitsPerPage=this.searchIndex.hitsPerPage);let i=await this.algoliaIndex.search(this.query,e);return i=this.fixDomain(i),this.changeEvent=t,t!==d.Init&&this.indexResults||(this.indexResults={queryID:i.queryID,currentPage:0,totalHits:i.nbHits,hitsPerPage:null,origFilters:i.facets,query:this.query,domain:this.searchIndex.domain||null,totalHitsWithFilters:0,results:[],totalPages:0,appliedFilters:this.makeAppliedFilters(),indexName:this.searchIndex.name||null,index:this.searchIndex.index,searchIndex:this.searchIndex}),this.indexResults.dynFilters=i.facets,this.indexResults.results=i.hits,this.indexResults.totalHitsWithFilters=i.nbHits,this.indexResults.currentPage=i.page,this.indexResults.totalPages=i.nbPages,this.indexResults.hitsPerPage=i.hitsPerPage,this.indexResults.query=i.query,this.changeEvent!==d.Page&&this.changeEvent!==d.Replica&&(this.facets=i.facets),this.nanoAfterQuery.emit(this.indexResults),new Promise((t=>{setTimeout((()=>t("tpl updated")),20)})).then((()=>{this.currentHits=this.indexResults.results,this.resultsPage=this.indexResults.currentPage}))};resetPage(){this.indexResults&&(this.indexResults.currentPage=0)}clearAllFacetFilters(){Object.values(this._dynFacetFilters).forEach((t=>{t.element.value=""})),this._dynFacetFilters={}}algoliaFilterStr(){const t={},e=e=>{let i,s;Object.keys(e).forEach((n=>{i=e[n],t[n]=t[n]||{name:i.facetName,or:[],and:[],not:[]},s=t[n][i.operator],i.value&&i.value.length&&(t[n][i.operator]=[...s,...i.value])}))};e(this.dynFacetFilters),e(this.staticFacetFilters);const i=(t,e)=>e.indexOf(" ")>-1?t+':"'+e+'"':t+":"+e;let s,n,o=[];return Object.values(t).forEach((function(t){Object.keys(t).filter((t=>t.match(/(or|and|not)/))).forEach((e=>{s=t,n=t.name,"or"===e||"and"===e?s[e].length&&o.push("( "+s[e].map((t=>{if(t.length)return i(n,t)})).join(" "+e.toLocaleUpperCase()+" ")+" )"):s.not.length&&o.push("( "+s[e].map((t=>{if(t.length)return"NOT "+i(n,t)})).join(" AND ")+" )")}))})),o=[...this.filters,...o],o.join(" "+this.operator.toLocaleUpperCase()+" ")}handleInputChange(t){t.target===this.inputField&&(this.query=this.inputField.value)}handleSearchReset=()=>{this.showResults=!1,this.indexResults=null};onResultDisplay=()=>{n((()=>{this.resultsDiv.removeEventListener("transitionend",this.onResultDisplay),this.showResults?(this.defaultDiv.style.display="none",this.resultsDiv.classList.add("shown"),this.resultsDiv.style.minHeight="",this.resultsDiv.style.width=""):this.resultsDiv.style.display="none"}))};async updateContent(){return this.promiseQueue.enqueue((()=>this.updateContentQueue()))}async updateContentQueue(){const t=this.outputSlot||this.resultsDiv;if(!t||!this.tpl)return"no tpl";const e=document.createElement("div");e.innerHTML=this.tpl;const i=[];return this.placedAlgoliaEles=[],Array.from(e.querySelectorAll(`${u("nano-algolia")}, ${u("nano-algolia-filter")}, ${u("nano-algolia-results")}`)).forEach(((t,e)=>{const s=document.createElement("div");s.dataset.placeholderId=e.toString(),s.classList.add("nano-ele-placeholder"),i.push(t),t.parentNode.replaceChild(s,t)})),t.innerHTML=this.tplRenderFn(e.innerHTML.replace(/&gt;/gm,">").replace(/&lt;/gm,"<").replace(/&amp;/gm,"&"),this.indexResults),Array.from(t.querySelectorAll("div.nano-ele-placeholder")).forEach((t=>{t.parentNode.replaceChild(i[parseInt(t.dataset.placeholderId)],t),this.placedAlgoliaEles.push(i[parseInt(t.dataset.placeholderId)])})),this.placedAlgoliaEles.length?new Promise((e=>{const i=s=>{this.placedAlgoliaEles=this.placedAlgoliaEles.filter((t=>t!==s.detail)),this.placedAlgoliaEles.length||(setTimeout((()=>e("tpl updated")),500),t.removeEventListener("nanoTplUpdated",i))};t.addEventListener("nanoTplUpdated",i)})):Promise.resolve("algolia setup")}componentWillLoad(){o((()=>{this.tplSlot=h(this.host,'[slot="template"]')[0],this.outputSlot=h(this.host,'[slot="output"]')[0],this.slottedInput=h(this.host,'[slot="search-input"]')[0],this.hasLoadSlot=!!h(this.host,'[slot="loader"]')[0],this.tplSlot&&(this.tpl=this.tplSlot.innerHTML||this.tplSlot.innerText),this.slottedInput&&(this.slottedInput.tagName.toLocaleLowerCase()===u("nano-input")||this.slottedInput instanceof HTMLInputElement)?this.inputField=this.slottedInput:this.slottedInput?this.inputField=this.slottedInput.querySelector(`${u("nano-input")}, input:not([type="radio"]):not([type="checkbox"])`):this.handleListenToChange(),n((()=>{this.showResults&&this.tpl&&this.searchChange()}))})),this.searchIndexNameChange(),this.initAlgoliaClient(),this.initAlgoliaIndex(),function(t,i){var s=e(t),n=new Map,o={wormholes:n,state:i};p.set(t,o);var r=t.connectedCallback;t.connectedCallback=function(){p.set(t,o),r&&r.call(t)};var a=t.disconnectedCallback;t.disconnectedCallback=function(){p.delete(t),a&&a.call(t)},s.addEventListener("openWormhole",(function(t){t.stopPropagation();var e=t.detail,i=e.consumer,s=e.onOpen;if(!n.has(i)){if("symbol"!=typeof i){var r=i.connectedCallback,a=i.disconnectedCallback;i.connectedCallback=function(){n.set(i,t.detail),r&&r.call(i)},i.disconnectedCallback=function(){n.delete(i),a&&a.call(i)}}n.set(i,t.detail),m(t.detail,o.state),null==s||s.resolve((function(){n.delete(i)}))}})),s.addEventListener("closeWormhole",(function(t){n.delete(t.detail)}))}(this,this.wormholeState),this.storeId&&(l.init(this,["query","replicaIndex"],this.storeMethod,this.storeId),l.init(this,["apiKey","appId","searchIndex"],"session",this.storeId+"_api")),this.internalIndexSwitch()}connectedCallback(){this.searchChange=c(this.searchChange,300),this.browseIndexChange(),this.host.dispatchEvent(new CustomEvent("nanoDidLoad",{detail:this.host}))}render(){const t={indexResults:this.indexResults,results:this.currentHits,filterChanged:this.filterChanged,tplRenderFn:this.tplRenderFn,resultsPage:this.resultsPage,changeEvent:this.changeEvent,facets:this.facets,algoliaIndex:this.algoliaIndex,searchIndex:this.searchIndex,globalStoreMethod:this.storeMethod,isLoading:this.isLoading};return f(r,{key:"e5a080bf3b11c991465f1b44521b75539f80d5ec",class:{"show-results":this.showResults,"is-loading":this.isLoading,"nano-algolia":!0},"aria-busy":this.isLoading},this.hasLoadSlot&&f("div",{key:"586696526af9ba7b721ebfe8aeba2b5a45b8a19a",hidden:!this.isLoading},f("slot",{key:"40556633911954fd20b756fedf71aea7e15b15e1",name:"loader"})),!this.hasLoadSlot&&f("div",{key:"e5ee4968b6864b656b3537ec46b69e64ebe76370",class:{loader:!0,loading:this.isLoading}},f("nano-spinner",{key:"420a97d058127ea029329d6eca5055c0c54f4c1f",overlay:!0})),f(g,{key:"9c271e35ea7f850eb1ec2f99415ab2eebf014387",state:t},f("slot",{key:"7a7a5ac869321d6db0a2f6f784a28e638cbe1a3f",name:"search-input"}),f("div",{key:"91b799022bee756066f1eb60038fdb428c98d3dc",class:"results-container","aria-live":"polite"},f("div",{key:"4209e438e0cefbc244dde4c3a9c10e3e5bf56137",ref:t=>this.resultsDiv=t,class:"results"},f("slot",{key:"44b89a4cae72f8ff38c08dd605df32df03a2fc9a",name:"output"})))),f("div",{key:"a584e0f2f10c38ffc46decc5b4b6bd2a1e14118a",ref:t=>this.defaultDiv=t,class:"default",tabindex:"-1",part:"default-content"},f("slot",{key:"dcf3c87479d48774b63bf32b4e2de2bfe9a6b1ea"})))}static get watchers(){return{listenTo:["handleListenToChange"],_dynFacetFilters:["dynFacetFiltersChange"],browseIndex:["browseIndexChange"],inputField:["inputFieldSet"],query:["queryChange"],replicaIndex:["internalIndexSwitch"],resultsPage:["pageChange"],searchIndexName:["searchIndexNameChange"],apiKey:["initAlgoliaClient"],appId:["initAlgoliaClient"],searchIndex:["initAlgoliaIndex"],showResults:["showResultsChange"],filters:["handleFilterpropChange"]}}};Y.style=":host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host{position:relative;display:block}:host ::slotted([slot=search-template]){display:none !important}.loader{opacity:0;position:fixed;block-size:100%;inline-size:100%;min-block-size:100%;max-block-size:100vh !important;max-inline-size:100vw !important;inset-inline-start:0;inset-block-start:0;z-index:-10;font-size:60px;display:flex;align-items:center;justify-content:center;transition:opacity 0.2s ease, z-index 0.01s ease 0.2s}.loader.loading{opacity:1;z-index:10;transition:z-index 0.01s ease, opacity 0.2s ease 0.01s}.default{block-size:100%}.default:focus{outline:none}.results{opacity:0;outline:none;overflow:auto;transition:transform 0.3s ease, opacity 0.3s ease, visibility 0.01s ease 0.3s, z-index 0.01s ease 0.3s;transform:translate(0, 100px);visibility:hidden;z-index:-1;position:absolute;inset-block-start:0;inset-inline-start:0;display:none}.results-container{position:relative}.results.show{transition:z-index 0.01s ease, visibility 0.01s ease, transform 0.3s ease 0.01s, opacity 0.3s ease 0.01s, overflow 0.01s ease 0.31s;transform:translate(0, 0);visibility:visible;opacity:1;z-index:10;overflow:hidden}.results.shown{block-size:auto !important;inline-size:auto !important;display:block;position:static;transform:none;z-index:auto;visibility:inherit;opacity:initial;overflow:visible}";export{Y as nano_algolia}