@fluid-topics/ft-reader-content 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- !function(t,e,i,s,r,n){var o;!function(t){t.FEEDBACK="FEEDBACK",t.RATING="RATING",t.PRINT="PRINT",t.BOOKMARK="BOOKMARK",t.COLLECTIONS="COLLECTIONS",t.PERSONAL_BOOKS="PERSONAL_BOOKS"}(o||(o={}));var l=function(t,e,i,s){for(var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class h extends Event{constructor(){super("register-ft-reader-component",{bubbles:!0,composed:!0})}}const a=Symbol("registerInterval");class d extends(function(t){var e;class i 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[a]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[a]):this.dispatchEvent(new h)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return e=a,l([s.state()],i.prototype,"stateManager",void 0),i}(e.FtLitElementRedux)){}const c=e.FtCssVariableFactory.create("--ft-infinite-scroll-padding","","SIZE","0"),v=e.FtCssVariableFactory.create("--ft-infinite-scroll-items-gap","","SIZE","4px"),u=e.FtCssVariableFactory.create("--ft-infinite-scroll-item-container-min-height","","SIZE",".1px"),f=i.css`
1
+ !function(t,i,e,s,r,n){var o;!function(t){t.FEEDBACK="FEEDBACK",t.RATING="RATING",t.PRINT="PRINT",t.BOOKMARK="BOOKMARK",t.COLLECTIONS="COLLECTIONS",t.PERSONAL_BOOKS="PERSONAL_BOOKS"}(o||(o={}));var l=function(t,i,e,s){for(var r,n=arguments.length,o=n<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(n<3?r(o):n>3?r(i,e,o):r(i,e))||o);return n>3&&o&&Object.defineProperty(i,e,o),o};class h extends Event{constructor(){super("register-ft-reader-component",{bubbles:!0,composed:!0})}}const a=Symbol("registerInterval");class d extends(function(t){var i;class e extends t{constructor(){super(...arguments),this[i]=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[a]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[a]):this.dispatchEvent(new h)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return i=a,l([s.state()],e.prototype,"stateManager",void 0),e}(i.FtLitElementRedux)){}const c=i.FtCssVariableFactory.create("--ft-infinite-scroll-padding","","SIZE","0"),v=i.FtCssVariableFactory.create("--ft-infinite-scroll-items-gap","","SIZE","4px"),u=i.FtCssVariableFactory.create("--ft-infinite-scroll-item-container-min-height","","SIZE",".1px"),f=e.css`
2
2
  .items-container {
3
3
  padding: ${c};
4
4
  outline: none;
@@ -28,31 +28,31 @@
28
28
  display: flow-root;
29
29
  min-height: ${u};
30
30
  }
31
- `;var p=function(t,e,i,s){for(var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class b extends CustomEvent{constructor(t,e){super("visible-items-change",{detail:{visibleIndexes:t,visibleItems:e}})}}class m extends Event{constructor(){super("scrolled-to-target")}}class g extends e.FtLitElement{constructor(){super(...arguments),this.items=[],this.renderItem=()=>i.html``,this.getItemKey=(t,e)=>`${e} - ${JSON.stringify(t)}`,this.internalScroll=!1,this.renderBeforeFirst=1,this.renderAfterLast=1,this.visibleItems=[],this.scrolledToTarget=!1,this.scrolling=!1,this.alreadyRenderedIndexes=new Set,this.scrollDebouncer=new e.Debouncer(5),this.scrollDoneDebouncer=new e.Debouncer(10),this.onVisibilityChange=t=>{let e=new Set(this.visibleItems),i=new Set;for(let s of t){let t=+s.target.attributes.getNamedItem("data-item-index").value;s.intersectionRect.height>0?(e.add(t),i.add(t)):i.has(t)||e.delete(t)}this.visibleItems=[...e].sort(((t,e)=>t-e))},this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange),this.scrollingDebouncer=new e.Debouncer(100),this.ignoreNextScrollEvent=!1,this.scrollListener=()=>{this.ignoreNextScrollEvent||(this.scrolling=!0,this.scrollingDebouncer.run((()=>this.scrolling=!1))),this.ignoreNextScrollEvent=!1,this.scrollRestorationItem=this.searchFirstVisibleItem(this.itemsContainer.children),this.scrollRestorationOffset=this.scrollable.scrollTop-this.getOffset(this.scrollRestorationItem)},this.onResize=t=>{for(const e of t)e.contentRect.height>0&&e.target.setAttribute("data-last-known-height",""+e.contentRect.height);null!=this.scrollRestorationItem&&null!=this.scrollRestorationOffset&&this.scrolledToTarget&&(this.ignoreNextScrollEvent=!0,this.scrollable.scrollTop=this.getOffset(this.scrollRestorationItem)+Math.min(Math.max(this.scrollRestorationOffset,0),this.getLastKnownHeight(this.scrollRestorationItem)+1))},this.resizeObserver=new ResizeObserver(this.onResize),this.onMutation=()=>{[...this.itemsContainer.children].forEach((t=>{this.intersectionObserver.observe(t),this.resizeObserver.observe(t)}))},this.mutationObserver=new MutationObserver(this.onMutation),this.resetVisibleItemsDebouncer=new e.Debouncer(10)}get scrollable(){var t;return null!==(t=this.internalScroll?this.internalScrollable:this.firstScrollableParent)&&void 0!==t?t:document.body}render(){return i.html`
31
+ `;var p=function(t,i,e,s){for(var r,n=arguments.length,o=n<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(n<3?r(o):n>3?r(i,e,o):r(i,e))||o);return n>3&&o&&Object.defineProperty(i,e,o),o};class b extends CustomEvent{constructor(t,i){super("visible-items-change",{detail:{visibleIndexes:t,visibleItems:i}})}}class m extends Event{constructor(){super("scrolled-to-target")}}class g extends i.FtLitElement{constructor(){super(...arguments),this.items=[],this.renderItem=()=>e.html``,this.getItemKey=(t,i)=>`${i} - ${JSON.stringify(t)}`,this.internalScroll=!1,this.renderBeforeFirst=1,this.renderAfterLast=1,this.visibleItems=[],this.scrolledToTarget=!1,this.scrolling=!1,this.alreadyRenderedIndexes=new Set,this.scrollDebouncer=new i.Debouncer(5),this.scrollDoneDebouncer=new i.Debouncer(10),this.onVisibilityChange=t=>{let i=new Set(this.visibleItems),e=new Set;for(let s of t){let t=+s.target.attributes.getNamedItem("data-item-index").value;s.intersectionRect.height>0?(i.add(t),e.add(t)):e.has(t)||i.delete(t)}this.visibleItems=[...i].sort(((t,i)=>t-i))},this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange),this.scrollingDebouncer=new i.Debouncer(100),this.ignoreNextScrollEvent=!1,this.scrollListener=()=>{this.ignoreNextScrollEvent||(this.scrolling=!0,this.scrollingDebouncer.run((()=>this.scrolling=!1))),this.ignoreNextScrollEvent=!1;const t=this.searchFirstVisibleItem(this.itemsContainer.children);this.scrollRestorationItem=t?+t.getAttribute("data-item-index"):void 0,this.scrollRestorationOffset=this.scrollable.scrollTop-this.getOffset(t)},this.onResize=t=>{for(const i of t)i.contentRect.height>0&&i.target.setAttribute("data-last-known-height",""+i.contentRect.height);if(null!=this.scrollRestorationItem&&null!=this.scrollRestorationOffset&&this.scrolledToTarget){this.ignoreNextScrollEvent=!0;const t=this.getItem(this.scrollRestorationItem),e=this.getOffset(t),s=i.minmax(0===this.scrollRestorationItem?-e:0,this.scrollRestorationOffset,this.getLastKnownHeight(t)+1);this.scrollable.scrollTop=e+s}},this.resizeObserver=new ResizeObserver(this.onResize),this.onMutation=()=>{[...this.itemsContainer.children].forEach((t=>{this.intersectionObserver.observe(t),this.resizeObserver.observe(t)}))},this.mutationObserver=new MutationObserver(this.onMutation),this.resetVisibleItemsDebouncer=new i.Debouncer(10)}get scrollable(){var t;return null!==(t=this.internalScroll?this.internalScrollable:this.firstScrollableParent)&&void 0!==t?t:document.body}render(){return e.html`
32
32
  <div class="items-container ${this.internalScroll?"scrollable":""}"
33
33
  tabindex="-1"
34
34
  @find-scrollable-parent=${this.findScrollableParent}>
35
- ${r.repeat(this.items,((t,e)=>this.getItemKey(t,e)),((t,e)=>this.renderItemContainer(t,e)))}
35
+ ${r.repeat(this.items,((t,i)=>this.getItemKey(t,i)),((t,i)=>this.renderItemContainer(t,i)))}
36
36
  </div>
37
- `}renderItemContainer(t,e){const s=!this.scrolling&&this.scrolledToTarget&&this.visibleItems.includes(e),r=e>=this.visibleItems[0]-this.renderBeforeFirst&&e<=(null!=(o=this.visibleItems)?o:[])[(null!=o?o:[]).length-1]+this.renderAfterLast;var o;const l=this.alreadyRenderedIndexes.has(e)||this.scrolledToTarget&&!this.scrolling&&r;l&&this.alreadyRenderedIndexes.add(e);return i.html`
38
- <div id="item-${e}"
37
+ `}renderItemContainer(t,i){const s=!this.scrolling&&this.scrolledToTarget&&this.visibleItems.includes(i),r=i>=this.visibleItems[0]-this.renderBeforeFirst&&i<=(null!=(o=this.visibleItems)?o:[])[(null!=o?o:[]).length-1]+this.renderAfterLast;var o;const l=this.alreadyRenderedIndexes.has(i)||this.scrolledToTarget&&!this.scrolling&&r;l&&this.alreadyRenderedIndexes.add(i);return e.html`
38
+ <div id="item-${i}"
39
39
  class="item-container ${l?"rendered":""} ${s?"visible":""}"
40
- data-item-index="${e}">
41
- ${l?(()=>{const i=this.renderItem(t,e);return"string"==typeof i?n.unsafeHTML(i):i})():i.nothing}
40
+ data-item-index="${i}">
41
+ ${l?(()=>{const e=this.renderItem(t,i);return"string"==typeof e?n.unsafeHTML(e):e})():e.nothing}
42
42
  </div>
43
- `}resetScroll(){this.triggerFindScrollableParent(),this.intersectionObserver.disconnect(),this.resizeObserver.disconnect(),this.visibleItems=[],this.scrolledToTarget=!1,this.scrollDebouncer.run((()=>{var t;let e=null!==(t=this.scrollToIndex)&&void 0!==t?t:this.scrollToItem?this.items.indexOf(this.scrollToItem):-1;e>=this.items.length&&(e=-1);const i=this.getItem(e);this.scrollToTarget(i),this.scrollDoneDebouncer.run((()=>{this.scrollRestorationItem=i,this.scrollRestorationOffset=0,this.onMutation(),this.scrolledToTarget=!0}))}))}getItem(t){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(`#item-${t}`)}scrollToTarget(t){var e;if(t){let i=+(null!==(e=t.getAttribute("data-item-index"))&&void 0!==e?e:"0");this.scrollable&&0===i?this.scrollable.scrollTop=0:this.scrollable.scrollTop=this.getOffset(t)}}getOffset(t){var e;let i=0,s=t;for(;s&&s.offsetParent!==this.scrollable.offsetParent;)i+=s.offsetTop,s=s.offsetParent;return i+(null!==(e=null==s?void 0:s.offsetTop)&&void 0!==e?e:0)-this.scrollable.offsetTop}getLastKnownHeight(t){var e;return+(null!==(e=null==t?void 0:t.getAttribute("data-last-known-height"))&&void 0!==e?e:1e3)}appendItems(...t){this.items=[...this.items,...t]}prependItems(...t){this.items=[...t,...this.items]}connectedCallback(){super.connectedCallback(),setTimeout((()=>{this.triggerFindScrollableParent(),this.initIntersectionObserver(),this.mutationObserver.disconnect(),this.mutationObserver.observe(this.itemsContainer,{childList:!0})}),0)}initIntersectionObserver(){this.intersectionObserver.disconnect(),this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange,{root:this.scrollable,rootMargin:"-8px",threshold:[0,.01,.1,1]})}triggerFindScrollableParent(){var t;null===(t=this.itemsContainer)||void 0===t||t.dispatchEvent(new Event("find-scrollable-parent",{composed:!0}))}findScrollableParent(t){var e;let i,s;t.stopPropagation();for(let e of t.composedPath()){const t=e,r=this.elementCanScroll(t);if(t.clientHeight&&t.clientHeight<t.scrollHeight&&r){i=t;break}r&&(s=t)}let r=i||s;r!==this.firstScrollableParent&&(null===(e=this.firstScrollableParent)||void 0===e||e.removeEventListener("scroll",this.scrollListener),null==r||r.addEventListener("scroll",this.scrollListener),this.firstScrollableParent=r,this.initIntersectionObserver(),this.resetScroll())}elementCanScroll(t){try{return["auto","scroll"].includes(getComputedStyle(t).overflowY)}catch(t){return!1}}searchFirstVisibleItem(t,e,i){if(e=null!=e?e:0,(i=null!=i?i:t.length-1)<=e)return t[e];const s=Math.floor((i-e)/2)+e,r=t[s];return this.getOffset(r)>this.scrollable.scrollTop?this.searchFirstVisibleItem(t,e,s-1):this.getOffset(r)+this.getLastKnownHeight(r)<this.scrollable.scrollTop?this.searchFirstVisibleItem(t,s+1,i):r}disconnectedCallback(){super.disconnectedCallback(),this.intersectionObserver.disconnect(),this.resizeObserver.disconnect(),this.mutationObserver.disconnect()}firstUpdated(t){super.firstUpdated(t),this.resetScroll()}update(t){super.update(t),t.has("items")&&(this.alreadyRenderedIndexes=new Set),!t.has("scrollToItem")&&!t.has("scrollToIndex")||null==this.scrollToItem&&null==this.scrollToIndex||this.resetScroll()}updated(t){super.updated(t),(t.has("visibleItems")||t.has("items"))&&this.onVisibleItemsChange(),t.has("scrolledToTarget")&&this.scrolledToTarget&&(null!=this.scrollToItem||null!=this.scrollToIndex)&&this.dispatchEvent(new m)}onVisibleItemsChange(){this.visibleItems.every(((t,e)=>null==this.visibleItems[e+1]||t+1===this.visibleItems[e+1]))||e.deepEqual(this.visibleItems,this.lastNotOkVisibleItems)?(this.resetVisibleItemsDebouncer.cancel(),this.dispatchVisibleItemsEvent()):this.resetVisibleItemsDebouncer.run((()=>{this.lastNotOkVisibleItems=[...this.visibleItems],this.visibleItems=[],this.initIntersectionObserver(),this.onMutation()}))}dispatchVisibleItemsEvent(){var t;null===(t=this.cancelableDispatchEvent)||void 0===t||t.cancel(),this.cancelableDispatchEvent=e.cancelable(e.waitUntil((()=>!this.scrolling))),this.cancelableDispatchEvent.then((()=>this.dispatchEvent(new b(this.visibleItems,this.visibleItems.map((t=>this.items[t])))))).catch((()=>null))}}g.styles=f,p([s.property({type:Array})],g.prototype,"items",void 0),p([s.property({attribute:!1})],g.prototype,"renderItem",void 0),p([s.property({attribute:!1})],g.prototype,"getItemKey",void 0),p([s.property({type:Object})],g.prototype,"scrollToItem",void 0),p([s.property({type:Number})],g.prototype,"scrollToIndex",void 0),p([s.property({type:Boolean})],g.prototype,"internalScroll",void 0),p([s.property({type:Number})],g.prototype,"renderBeforeFirst",void 0),p([s.property({type:Number})],g.prototype,"renderAfterLast",void 0),p([s.state({hasChanged:(t,e)=>null!=t&&null==e||t.length!==e.length||t[0]!==e[0]})],g.prototype,"visibleItems",void 0),p([s.query(".scrollable")],g.prototype,"internalScrollable",void 0),p([s.query(".items-container")],g.prototype,"itemsContainer",void 0),p([s.state()],g.prototype,"scrolledToTarget",void 0),p([s.state()],g.prototype,"scrolling",void 0),e.customElement("ft-infinite-scroll")(g);const I=i.css`
44
- `,w=i.css`
45
- `;var x=function(t,e,i,s){for(var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class $ extends d{constructor(){super(...arguments),this.disableContextInteractions=!1,this.registeredComponents=[]}render(){return i.html`
43
+ `}resetScroll(){this.triggerFindScrollableParent(),this.intersectionObserver.disconnect(),this.resizeObserver.disconnect(),this.visibleItems=[],this.scrolledToTarget=!1,this.scrollDebouncer.run((()=>{var t;let i=null!==(t=this.scrollToIndex)&&void 0!==t?t:this.scrollToItem?this.items.indexOf(this.scrollToItem):-1;i>=this.items.length&&(i=-1);const e=this.getItem(i);this.scrollToTarget(e),this.scrollDoneDebouncer.run((()=>{this.scrollRestorationItem=i>=0?i:void 0,this.scrollRestorationOffset=0===i?-this.getOffset(e):0,this.onMutation(),this.scrolledToTarget=!0}))}))}getItem(t){var i;return null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelector(`#item-${t}`)}scrollToTarget(t){var i;if(t){let e=+(null!==(i=t.getAttribute("data-item-index"))&&void 0!==i?i:"0");this.scrollable&&0===e?this.scrollable.scrollTop=0:this.scrollable.scrollTop=this.getOffset(t)}}getOffset(t){var i;let e=0,s=t;for(;s&&s.offsetParent!==this.scrollable.offsetParent;)e+=s.offsetTop,s=s.offsetParent;return e+(null!==(i=null==s?void 0:s.offsetTop)&&void 0!==i?i:0)-this.scrollable.offsetTop}getLastKnownHeight(t){var i;return+(null!==(i=null==t?void 0:t.getAttribute("data-last-known-height"))&&void 0!==i?i:1e3)}appendItems(...t){this.items=[...this.items,...t]}prependItems(...t){this.items=[...t,...this.items]}connectedCallback(){super.connectedCallback(),setTimeout((()=>{this.triggerFindScrollableParent(),this.initIntersectionObserver(),this.mutationObserver.disconnect(),this.mutationObserver.observe(this.itemsContainer,{childList:!0})}),0)}initIntersectionObserver(){this.intersectionObserver.disconnect(),this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange,{root:this.scrollable,rootMargin:"-8px",threshold:[0,.01,.1,1]})}triggerFindScrollableParent(){var t;null===(t=this.itemsContainer)||void 0===t||t.dispatchEvent(new Event("find-scrollable-parent",{composed:!0}))}findScrollableParent(t){var i;let e,s;t.stopPropagation();for(let i of t.composedPath()){const t=i,r=this.elementCanScroll(t);if(t.clientHeight&&t.clientHeight<t.scrollHeight&&r){e=t;break}r&&(s=t)}let r=e||s;r!==this.firstScrollableParent&&(null===(i=this.firstScrollableParent)||void 0===i||i.removeEventListener("scroll",this.scrollListener),null==r||r.addEventListener("scroll",this.scrollListener),this.firstScrollableParent=r,this.initIntersectionObserver(),this.resetScroll())}elementCanScroll(t){try{return["auto","scroll"].includes(getComputedStyle(t).overflowY)}catch(t){return!1}}searchFirstVisibleItem(t,i,e){if(i=null!=i?i:0,(e=null!=e?e:t.length-1)<=i)return t[i];const s=Math.floor((e-i)/2)+i,r=t[s];return this.getOffset(r)>this.scrollable.scrollTop?this.searchFirstVisibleItem(t,i,s-1):this.getOffset(r)+this.getLastKnownHeight(r)<this.scrollable.scrollTop?this.searchFirstVisibleItem(t,s+1,e):r}disconnectedCallback(){super.disconnectedCallback(),this.intersectionObserver.disconnect(),this.resizeObserver.disconnect(),this.mutationObserver.disconnect()}firstUpdated(t){super.firstUpdated(t),this.resetScroll()}update(t){super.update(t),t.has("items")&&(this.alreadyRenderedIndexes=new Set),!t.has("scrollToItem")&&!t.has("scrollToIndex")||null==this.scrollToItem&&null==this.scrollToIndex||this.resetScroll()}updated(t){super.updated(t),(t.has("visibleItems")||t.has("items"))&&this.onVisibleItemsChange(),t.has("scrolledToTarget")&&this.scrolledToTarget&&(null!=this.scrollToItem||null!=this.scrollToIndex)&&this.dispatchEvent(new m)}onVisibleItemsChange(){this.visibleItems.every(((t,i)=>null==this.visibleItems[i+1]||t+1===this.visibleItems[i+1]))||i.deepEqual(this.visibleItems,this.lastNotOkVisibleItems)?(this.resetVisibleItemsDebouncer.cancel(),this.dispatchVisibleItemsEvent()):this.resetVisibleItemsDebouncer.run((()=>{this.lastNotOkVisibleItems=[...this.visibleItems],this.visibleItems=[],this.initIntersectionObserver(),this.onMutation()}))}dispatchVisibleItemsEvent(){var t;null===(t=this.cancelableDispatchEvent)||void 0===t||t.cancel(),this.cancelableDispatchEvent=i.cancelable(i.waitUntil((()=>!this.scrolling))),this.cancelableDispatchEvent.then((()=>this.dispatchEvent(new b(this.visibleItems,this.visibleItems.map((t=>this.items[t])))))).catch((()=>null))}}g.styles=f,p([s.property({type:Array})],g.prototype,"items",void 0),p([s.property({attribute:!1})],g.prototype,"renderItem",void 0),p([s.property({attribute:!1})],g.prototype,"getItemKey",void 0),p([s.property({type:Object})],g.prototype,"scrollToItem",void 0),p([s.property({type:Number})],g.prototype,"scrollToIndex",void 0),p([s.property({type:Boolean})],g.prototype,"internalScroll",void 0),p([s.property({type:Number})],g.prototype,"renderBeforeFirst",void 0),p([s.property({type:Number})],g.prototype,"renderAfterLast",void 0),p([s.state({hasChanged:(t,i)=>null!=t&&null==i||t.length!==i.length||t[0]!==i[0]})],g.prototype,"visibleItems",void 0),p([s.query(".scrollable")],g.prototype,"internalScrollable",void 0),p([s.query(".items-container")],g.prototype,"itemsContainer",void 0),p([s.state()],g.prototype,"scrolledToTarget",void 0),p([s.state()],g.prototype,"scrolling",void 0),i.customElement("ft-infinite-scroll")(g);const I=e.css`
44
+ `,w=e.css`
45
+ `;var x=function(t,i,e,s){for(var r,n=arguments.length,o=n<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(n<3?r(o):n>3?r(i,e,o):r(i,e))||o);return n>3&&o&&Object.defineProperty(i,e,o),o};class $ extends d{constructor(){super(...arguments),this.disableContextInteractions=!1,this.registeredComponents=[]}render(){return e.html`
46
46
  <article id=${this.tocId}>
47
47
  <slot @register-ft-reader-topic-component=${this.registerComponent}></slot>
48
48
  </article>
49
- `}registerComponent(t){t.stopPropagation();const e=t.composedPath()[0];this.register(e)}register(t){this.registeredComponents.push(t),t.tocNode=this.tocNode,t.disableContextInteractions=this.disableContextInteractions}update(t){super.update(t),["mapId","tocId","stateManager"].some((e=>t.has(e)))&&this.setTocNode(),t.has("tocNode")&&this.registeredComponents.forEach((t=>t.tocNode=this.tocNode))}async setTocNode(){var t;this.tocNode=void 0,this.tocNode=this.mapId&&this.tocId?await(null===(t=this.service)||void 0===t?void 0:t.getTocNode(this.tocId)):void 0}disconnectedCallback(){super.disconnectedCallback(),this.registeredComponents=[]}}$.styles=w,x([e.redux({selector:t=>{var e;return null===(e=t.map)||void 0===e?void 0:e.id}})],$.prototype,"mapId",void 0),x([s.property()],$.prototype,"tocId",void 0),x([s.property({type:Boolean})],$.prototype,"disableContextInteractions",void 0),x([s.state()],$.prototype,"tocNode",void 0),e.customElement("ft-reader-topic-context")($);var T=function(t,e,i,s){for(var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class y extends d{constructor(){super(...arguments),this.renderTopic=()=>i.html`
49
+ `}registerComponent(t){t.stopPropagation();const i=t.composedPath()[0];this.register(i)}register(t){this.registeredComponents.push(t),t.tocNode=this.tocNode,t.disableContextInteractions=this.disableContextInteractions}update(t){super.update(t),["mapId","tocId","stateManager"].some((i=>t.has(i)))&&this.setTocNode(),t.has("tocNode")&&this.registeredComponents.forEach((t=>t.tocNode=this.tocNode))}async setTocNode(){var t;this.tocNode=void 0,this.tocNode=this.mapId&&this.tocId?await(null===(t=this.service)||void 0===t?void 0:t.getTocNode(this.tocId)):void 0}disconnectedCallback(){super.disconnectedCallback(),this.registeredComponents=[]}}$.styles=w,x([i.redux({selector:t=>{var i;return null===(i=t.map)||void 0===i?void 0:i.id}})],$.prototype,"mapId",void 0),x([s.property()],$.prototype,"tocId",void 0),x([s.property({type:Boolean})],$.prototype,"disableContextInteractions",void 0),x([s.state()],$.prototype,"tocNode",void 0),i.customElement("ft-reader-topic-context")($);var T=function(t,i,e,s){for(var r,n=arguments.length,o=n<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(n<3?r(o):n>3?r(i,e,o):r(i,e))||o);return n>3&&o&&Object.defineProperty(i,e,o),o};class y extends d{constructor(){super(...arguments),this.renderTopic=()=>e.html`
50
50
  <ft-reader-topic-title></ft-reader-topic-title>
51
51
  <ft-reader-topic-content></ft-reader-topic-content>
52
- `,this.disableContextInteractions=!1,this.renderBeforeFirst=5,this.renderAfterLast=10,this.visibleTopicsDebouncer=new e.Debouncer(50)}render(){var t;const e=(null===(t=this.currentPage)||void 0===t?void 0:t.topics)||[];return 0===e.length?i.nothing:i.html`
52
+ `,this.disableContextInteractions=!1,this.renderBeforeFirst=5,this.renderAfterLast=10,this.visibleTopicsDebouncer=new i.Debouncer(50)}render(){var t;const i=(null===(t=this.currentPage)||void 0===t?void 0:t.topics)||[];return 0===i.length?e.nothing:e.html`
53
53
  <ft-infinite-scroll class="ft-reader-content"
54
- .items=${e}
55
- .renderItem=${(t,e)=>this.renderTopicInContext(t,e)}
54
+ .items=${i}
55
+ .renderItem=${(t,i)=>this.renderTopicInContext(t,i)}
56
56
  .getItemKey=${t=>t}
57
57
  .scrollToItem=${this.getScrollTarget()}
58
58
  .renderBeforeFirst=${this.renderBeforeFirst}
@@ -62,8 +62,8 @@
62
62
  @scrolled-to-target=${this.onScrollDone}
63
63
  >
64
64
  </ft-infinite-scroll>
65
- `}renderTopicInContext(t,e){return i.html`
65
+ `}renderTopicInContext(t,i){return e.html`
66
66
  <ft-reader-topic-context tocId="${t}" ?disableContextInteractions=${this.disableContextInteractions}>
67
- ${this.renderTopic(t,e)}
67
+ ${this.renderTopic(t,i)}
68
68
  </ft-reader-topic-context>
69
- `}getScrollTarget(){var t,e,i,s,r;if(this.disableContextInteractions)return null;const n=null!==(s=null===(t=this.visibleTopics)||void 0===t?void 0:t.includes(null!==(i=null===(e=this.scrollTarget)||void 0===e?void 0:e.tocId)&&void 0!==i?i:""))&&void 0!==s&&s;return!(null===(r=this.scrollTarget)||void 0===r?void 0:r.tocId)||n&&null!=this.scrollTarget.section?null:this.scrollTarget.tocId}visibleTopicChange(t){this.disableContextInteractions||this.visibleTopicsDebouncer.run((()=>{var e;return null===(e=this.stateManager)||void 0===e?void 0:e.setVisibleTopics(t.detail.visibleItems)}))}onScrollDone(){var t,e;this.disableContextInteractions||(null===(t=this.scrollTarget)||void 0===t?void 0:t.section)||null===(e=this.stateManager)||void 0===e||e.scrollDone()}}y.elementDefinitions={"ft-infinite-scroll":g},y.styles=I,T([s.property()],y.prototype,"renderTopic",void 0),T([s.property({type:Boolean})],y.prototype,"disableContextInteractions",void 0),T([e.redux()],y.prototype,"currentPage",void 0),T([e.redux()],y.prototype,"scrollTarget",void 0),T([e.redux()],y.prototype,"visibleTopics",void 0),T([e.redux({selector:t=>{var e,i;return null!==(i=null===(e=t.configuration)||void 0===e?void 0:e.loadBeforeFirstVisibleTopic)&&void 0!==i?i:5}})],y.prototype,"renderBeforeFirst",void 0),T([e.redux({selector:t=>{var e,i;return null!==(i=null===(e=t.configuration)||void 0===e?void 0:e.loadAfterLastVisibleTopic)&&void 0!==i?i:5}})],y.prototype,"renderAfterLast",void 0),T([s.query(".ft-reader-content")],y.prototype,"container",void 0),e.customElement("ft-reader-content")(y),t.FtReaderContent=y,t.FtReaderContentCssVariables={},t.styles=I}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators,ftGlobals.litRepeat,ftGlobals.litUnsafeHTML);
69
+ `}getScrollTarget(){var t,i,e,s,r;if(this.disableContextInteractions)return null;const n=null!==(s=null===(t=this.visibleTopics)||void 0===t?void 0:t.includes(null!==(e=null===(i=this.scrollTarget)||void 0===i?void 0:i.tocId)&&void 0!==e?e:""))&&void 0!==s&&s;return!(null===(r=this.scrollTarget)||void 0===r?void 0:r.tocId)||n&&null!=this.scrollTarget.section?null:this.scrollTarget.tocId}visibleTopicChange(t){this.disableContextInteractions||this.visibleTopicsDebouncer.run((()=>{var i;return null===(i=this.stateManager)||void 0===i?void 0:i.setVisibleTopics(t.detail.visibleItems)}))}onScrollDone(){var t,i;this.disableContextInteractions||(null===(t=this.scrollTarget)||void 0===t?void 0:t.section)||null===(i=this.stateManager)||void 0===i||i.scrollDone()}}y.elementDefinitions={"ft-infinite-scroll":g},y.styles=I,T([s.property()],y.prototype,"renderTopic",void 0),T([s.property({type:Boolean})],y.prototype,"disableContextInteractions",void 0),T([i.redux()],y.prototype,"currentPage",void 0),T([i.redux()],y.prototype,"scrollTarget",void 0),T([i.redux()],y.prototype,"visibleTopics",void 0),T([i.redux({selector:t=>{var i,e;return null!==(e=null===(i=t.configuration)||void 0===i?void 0:i.loadBeforeFirstVisibleTopic)&&void 0!==e?e:5}})],y.prototype,"renderBeforeFirst",void 0),T([i.redux({selector:t=>{var i,e;return null!==(e=null===(i=t.configuration)||void 0===i?void 0:i.loadAfterLastVisibleTopic)&&void 0!==e?e:5}})],y.prototype,"renderAfterLast",void 0),T([s.query(".ft-reader-content")],y.prototype,"container",void 0),i.customElement("ft-reader-content")(y),t.FtReaderContent=y,t.FtReaderContentCssVariables={},t.styles=I}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators,ftGlobals.litRepeat,ftGlobals.litUnsafeHTML);
@@ -114,7 +114,7 @@ const Uo=window,Io=Uo.ShadowRoot&&(void 0===Uo.ShadyCSS||Uo.ShadyCSS.nativeShado
114
114
  display: inline-block;
115
115
  width: 0;
116
116
  }
117
- `;const Fo=t=>{const o=null!=t?t:{};return(t,e)=>{var r;const i={hasChanged:(t,o)=>!k(t,o),attribute:!1,...o};R(i)(t,e);const n=t;n.reduxProperties=n.reduxProperties||new Map,n.reduxProperties.set(e,{selector:null!==(r=o.selector)&&void 0!==r?r:t=>t[e],store:o.store})}};function Bo(t){var o;return null!==(o=null==t?void 0:t.isFtReduxStore)&&void 0!==o&&o}var zo,Po,To;const Do=Symbol("internalReduxEventsUnsubscribers"),_o=Symbol("internalStoresUnsubscribers"),jo=Symbol("internalStores");class Go extends Ao{constructor(){super(...arguments),this[zo]=new Map,this[Po]=new Map,this[To]=[]}update(t){var o;super.update(t),(null===(o=this.reduxReactiveProperties)||void 0===o?void 0:o.some((o=>t.has(o))))&&this.updateFromStores()}getUnnamedStore(){if(this[jo].size>1)throw new Error("Cannot resolve unnamed store when multiple stores are configured.");return[...this[jo].values()][0]}getStore(t){return null==t?this.getUnnamedStore():this[jo].get(t)}addStore(t,o){var e;o=null!==(e=null!=o?o:Bo(t)?t.name:void 0)&&void 0!==e?e:"default-store",this.unsubscribeFromStore(o),this.setupStore(o,t)}removeStore(t){const o="string"==typeof t?t:t.name;this.unsubscribeFromStore(o),this[jo].delete(o)}setupStore(t,o){this[jo].set(t,o),this.subscribeToStore(t,o),this.updateFromStores()}setupStores(){this.unsubscribeFromStores(),this[jo].forEach(((t,o)=>this.subscribeToStore(o,t))),this.updateFromStores()}updateFromStores(){this.reduxProperties&&this.reduxProperties.forEach(((t,o)=>{const e=this.constructor.getPropertyOptions(o);if(!(null==e?void 0:e.attribute)||!this.hasAttribute("string"==typeof(null==e?void 0:e.attribute)?e.attribute:o)){const e=this.getStore(t.store);e&&(t.store?this[_o].has(t.store):this[_o].size>0)&&(this[o]=t.selector(e.getState(),this))}}))}subscribeToStore(t,o){var e;this[_o].set(t,o.subscribe((()=>this.updateFromStores()))),Bo(o)&&o.eventBus&&(null===(e=this.reduxEventListeners)||void 0===e||e.forEach(((t,e)=>{if("function"==typeof this[e]&&(!t.store||o.name===t.store)){const r=t=>this[e](t);o.eventBus.addEventListener(t.eventName,r),this[Do].push((()=>o.eventBus.removeEventListener(t.eventName,r)))}}))),this.onStoreAvailable(t)}unsubscribeFromStores(){this[_o].forEach(((t,o)=>this.unsubscribeFromStore(o))),this[Do].forEach((t=>t())),this[Do]=[]}unsubscribeFromStore(t){this[_o].has(t)&&this[_o].get(t)(),this[_o].delete(t)}onStoreAvailable(t){}connectedCallback(){super.connectedCallback(),this.setupStores()}disconnectedCallback(){super.disconnectedCallback(),this.unsubscribeFromStores()}}var Ho,Yo,Jo;zo=_o,Po=jo,To=Do,window.ftReduxStores||(window.ftReduxStores={}),navigator.vendor&&navigator.vendor.match(/apple/i)||(null===(Yo=null===(Ho=window.safari)||void 0===Ho?void 0:Ho.pushNotification)||void 0===Yo||Yo.toString()),function(t){t.FEEDBACK="FEEDBACK",t.RATING="RATING",t.PRINT="PRINT",t.BOOKMARK="BOOKMARK",t.COLLECTIONS="COLLECTIONS",t.PERSONAL_BOOKS="PERSONAL_BOOKS"}(Jo||(Jo={}));var Vo=function(t,o,e,r){for(var i,n=arguments.length,s=n<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r,a=t.length-1;a>=0;a--)(i=t[a])&&(s=(n<3?i(s):n>3?i(o,e,s):i(o,e))||s);return n>3&&s&&Object.defineProperty(o,e,s),s};class qo extends Event{constructor(){super("register-ft-reader-component",{bubbles:!0,composed:!0})}}const Xo=Symbol("registerInterval");class Qo 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[Xo]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[Xo]):this.dispatchEvent(new qo)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return o=Xo,Vo([E()],e.prototype,"stateManager",void 0),e}(Go)){}
117
+ `;const Fo=t=>{const o=null!=t?t:{};return(t,e)=>{var r;const i={hasChanged:(t,o)=>!k(t,o),attribute:!1,...o};R(i)(t,e);const n=t.constructor;n.reduxProperties=new Map(n.reduxProperties),n.reduxProperties.set(e,{selector:null!==(r=o.selector)&&void 0!==r?r:t=>t[e],store:o.store})}};function Bo(t){var o;return null!==(o=null==t?void 0:t.isFtReduxStore)&&void 0!==o&&o}var zo,Po,To;const Do=Symbol("internalReduxEventsUnsubscribers"),_o=Symbol("internalStoresUnsubscribers"),jo=Symbol("internalStores");class Go extends Ao{constructor(){super(...arguments),this[zo]=new Map,this[Po]=new Map,this[To]=[]}get reduxConstructor(){return this.constructor}update(t){super.update(t),[...this.reduxConstructor.reduxReactiveProperties].some((o=>t.has(o)))&&this.updateFromStores()}getUnnamedStore(){if(this[jo].size>1)throw new Error("Cannot resolve unnamed store when multiple stores are configured.");return[...this[jo].values()][0]}getStore(t){return null==t?this.getUnnamedStore():this[jo].get(t)}addStore(t,o){var e;o=null!==(e=null!=o?o:Bo(t)?t.name:void 0)&&void 0!==e?e:"default-store",this.unsubscribeFromStore(o),this.setupStore(o,t)}removeStore(t){const o="string"==typeof t?t:t.name;this.unsubscribeFromStore(o),this[jo].delete(o)}setupStore(t,o){this[jo].set(t,o),this.subscribeToStore(t,o),this.updateFromStores()}setupStores(){this.unsubscribeFromStores(),this[jo].forEach(((t,o)=>this.subscribeToStore(o,t))),this.updateFromStores()}updateFromStores(){this.reduxConstructor.reduxProperties.forEach(((t,o)=>{const e=this.constructor.getPropertyOptions(o);if(!(null==e?void 0:e.attribute)||!this.hasAttribute("string"==typeof(null==e?void 0:e.attribute)?e.attribute:o)){const e=this.getStore(t.store);e&&(t.store?this[_o].has(t.store):this[_o].size>0)&&(this[o]=t.selector(e.getState(),this))}}))}subscribeToStore(t,o){var e;this[_o].set(t,o.subscribe((()=>this.updateFromStores()))),Bo(o)&&o.eventBus&&(null===(e=this.reduxConstructor.reduxEventListeners)||void 0===e||e.forEach(((t,e)=>{if("function"==typeof this[e]&&(!t.store||o.name===t.store)){const r=t=>this[e](t);o.eventBus.addEventListener(t.eventName,r),this[Do].push((()=>o.eventBus.removeEventListener(t.eventName,r)))}}))),this.onStoreAvailable(t)}unsubscribeFromStores(){this[_o].forEach(((t,o)=>this.unsubscribeFromStore(o))),this[Do].forEach((t=>t())),this[Do]=[]}unsubscribeFromStore(t){this[_o].has(t)&&this[_o].get(t)(),this[_o].delete(t)}onStoreAvailable(t){}connectedCallback(){super.connectedCallback(),this.setupStores()}disconnectedCallback(){super.disconnectedCallback(),this.unsubscribeFromStores()}}var Ho,Yo,Jo;zo=_o,Po=jo,To=Do,Go.reduxProperties=new Map,Go.reduxReactiveProperties=new Set,Go.reduxEventListeners=new Map,window.ftReduxStores||(window.ftReduxStores={}),navigator.vendor&&navigator.vendor.match(/apple/i)||(null===(Yo=null===(Ho=window.safari)||void 0===Ho?void 0:Ho.pushNotification)||void 0===Yo||Yo.toString()),function(t){t.FEEDBACK="FEEDBACK",t.RATING="RATING",t.PRINT="PRINT",t.BOOKMARK="BOOKMARK",t.COLLECTIONS="COLLECTIONS",t.PERSONAL_BOOKS="PERSONAL_BOOKS"}(Jo||(Jo={}));var Vo=function(t,o,e,r){for(var i,n=arguments.length,s=n<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r,a=t.length-1;a>=0;a--)(i=t[a])&&(s=(n<3?i(s):n>3?i(o,e,s):i(o,e))||s);return n>3&&s&&Object.defineProperty(o,e,s),s};class qo extends Event{constructor(){super("register-ft-reader-component",{bubbles:!0,composed:!0})}}const Xo=Symbol("registerInterval");class Qo 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[Xo]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[Xo]):this.dispatchEvent(new qo)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return o=Xo,Vo([E()],e.prototype,"stateManager",void 0),e}(Go)){}
118
118
  /**
119
119
  * @license
120
120
  * Copyright 2017 Google LLC
@@ -165,7 +165,7 @@ class fe extends ee{constructor(t){if(super(t),this.et=ot,t.type!==te)throw Erro
165
165
  display: flow-root;
166
166
  min-height: ${ye};
167
167
  }
168
- `;var be=function(t,o,e,r){for(var i,n=arguments.length,s=n<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r,a=t.length-1;a>=0;a--)(i=t[a])&&(s=(n<3?i(s):n>3?i(o,e,s):i(o,e))||s);return n>3&&s&&Object.defineProperty(o,e,s),s};class me extends CustomEvent{constructor(t,o){super("visible-items-change",{detail:{visibleIndexes:t,visibleItems:o}})}}class Oe extends Event{constructor(){super("scrolled-to-target")}}class Ne extends Ao{constructor(){super(...arguments),this.items=[],this.renderItem=()=>no``,this.getItemKey=(t,o)=>`${o} - ${JSON.stringify(t)}`,this.internalScroll=!1,this.renderBeforeFirst=1,this.renderAfterLast=1,this.visibleItems=[],this.scrolledToTarget=!1,this.scrolling=!1,this.alreadyRenderedIndexes=new Set,this.scrollDebouncer=new L(5),this.scrollDoneDebouncer=new L(10),this.onVisibilityChange=t=>{let o=new Set(this.visibleItems),e=new Set;for(let r of t){let t=+r.target.attributes.getNamedItem("data-item-index").value;r.intersectionRect.height>0?(o.add(t),e.add(t)):e.has(t)||o.delete(t)}this.visibleItems=[...o].sort(((t,o)=>t-o))},this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange),this.scrollingDebouncer=new L(100),this.ignoreNextScrollEvent=!1,this.scrollListener=()=>{this.ignoreNextScrollEvent||(this.scrolling=!0,this.scrollingDebouncer.run((()=>this.scrolling=!1))),this.ignoreNextScrollEvent=!1,this.scrollRestorationItem=this.searchFirstVisibleItem(this.itemsContainer.children),this.scrollRestorationOffset=this.scrollable.scrollTop-this.getOffset(this.scrollRestorationItem)},this.onResize=t=>{for(const o of t)o.contentRect.height>0&&o.target.setAttribute("data-last-known-height",""+o.contentRect.height);null!=this.scrollRestorationItem&&null!=this.scrollRestorationOffset&&this.scrolledToTarget&&(this.ignoreNextScrollEvent=!0,this.scrollable.scrollTop=this.getOffset(this.scrollRestorationItem)+Math.min(Math.max(this.scrollRestorationOffset,0),this.getLastKnownHeight(this.scrollRestorationItem)+1))},this.resizeObserver=new ResizeObserver(this.onResize),this.onMutation=()=>{[...this.itemsContainer.children].forEach((t=>{this.intersectionObserver.observe(t),this.resizeObserver.observe(t)}))},this.mutationObserver=new MutationObserver(this.onMutation),this.resetVisibleItemsDebouncer=new L(10)}get scrollable(){var t;return null!==(t=this.internalScroll?this.internalScrollable:this.firstScrollableParent)&&void 0!==t?t:document.body}render(){return no`
168
+ `;var be=function(t,o,e,r){for(var i,n=arguments.length,s=n<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r,a=t.length-1;a>=0;a--)(i=t[a])&&(s=(n<3?i(s):n>3?i(o,e,s):i(o,e))||s);return n>3&&s&&Object.defineProperty(o,e,s),s};class me extends CustomEvent{constructor(t,o){super("visible-items-change",{detail:{visibleIndexes:t,visibleItems:o}})}}class Oe extends Event{constructor(){super("scrolled-to-target")}}class Ne extends Ao{constructor(){super(...arguments),this.items=[],this.renderItem=()=>no``,this.getItemKey=(t,o)=>`${o} - ${JSON.stringify(t)}`,this.internalScroll=!1,this.renderBeforeFirst=1,this.renderAfterLast=1,this.visibleItems=[],this.scrolledToTarget=!1,this.scrolling=!1,this.alreadyRenderedIndexes=new Set,this.scrollDebouncer=new L(5),this.scrollDoneDebouncer=new L(10),this.onVisibilityChange=t=>{let o=new Set(this.visibleItems),e=new Set;for(let r of t){let t=+r.target.attributes.getNamedItem("data-item-index").value;r.intersectionRect.height>0?(o.add(t),e.add(t)):e.has(t)||o.delete(t)}this.visibleItems=[...o].sort(((t,o)=>t-o))},this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange),this.scrollingDebouncer=new L(100),this.ignoreNextScrollEvent=!1,this.scrollListener=()=>{this.ignoreNextScrollEvent||(this.scrolling=!0,this.scrollingDebouncer.run((()=>this.scrolling=!1))),this.ignoreNextScrollEvent=!1;const t=this.searchFirstVisibleItem(this.itemsContainer.children);this.scrollRestorationItem=t?+t.getAttribute("data-item-index"):void 0,this.scrollRestorationOffset=this.scrollable.scrollTop-this.getOffset(t)},this.onResize=t=>{for(const o of t)o.contentRect.height>0&&o.target.setAttribute("data-last-known-height",""+o.contentRect.height);if(null!=this.scrollRestorationItem&&null!=this.scrollRestorationOffset&&this.scrolledToTarget){this.ignoreNextScrollEvent=!0;const t=this.getItem(this.scrollRestorationItem),i=this.getOffset(t),n=(o=0===this.scrollRestorationItem?-i:0,e=this.scrollRestorationOffset,r=this.getLastKnownHeight(t)+1,Math.min(Math.max(o,e),r));this.scrollable.scrollTop=i+n}var o,e,r},this.resizeObserver=new ResizeObserver(this.onResize),this.onMutation=()=>{[...this.itemsContainer.children].forEach((t=>{this.intersectionObserver.observe(t),this.resizeObserver.observe(t)}))},this.mutationObserver=new MutationObserver(this.onMutation),this.resetVisibleItemsDebouncer=new L(10)}get scrollable(){var t;return null!==(t=this.internalScroll?this.internalScrollable:this.firstScrollableParent)&&void 0!==t?t:document.body}render(){return no`
169
169
  <div class="items-container ${this.internalScroll?"scrollable":""}"
170
170
  tabindex="-1"
171
171
  @find-scrollable-parent=${this.findScrollableParent}>
@@ -177,7 +177,7 @@ class fe extends ee{constructor(t){if(super(t),this.et=ot,t.type!==te)throw Erro
177
177
  data-item-index="${o}">
178
178
  ${n?(()=>{const e=this.renderItem(t,o);return"string"==typeof e?pe(e):e})():ao}
179
179
  </div>
180
- `}resetScroll(){this.triggerFindScrollableParent(),this.intersectionObserver.disconnect(),this.resizeObserver.disconnect(),this.visibleItems=[],this.scrolledToTarget=!1,this.scrollDebouncer.run((()=>{var t;let o=null!==(t=this.scrollToIndex)&&void 0!==t?t:this.scrollToItem?this.items.indexOf(this.scrollToItem):-1;o>=this.items.length&&(o=-1);const e=this.getItem(o);this.scrollToTarget(e),this.scrollDoneDebouncer.run((()=>{this.scrollRestorationItem=e,this.scrollRestorationOffset=0,this.onMutation(),this.scrolledToTarget=!0}))}))}getItem(t){var o;return null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector(`#item-${t}`)}scrollToTarget(t){var o;if(t){let e=+(null!==(o=t.getAttribute("data-item-index"))&&void 0!==o?o:"0");this.scrollable&&0===e?this.scrollable.scrollTop=0:this.scrollable.scrollTop=this.getOffset(t)}}getOffset(t){var o;let e=0,r=t;for(;r&&r.offsetParent!==this.scrollable.offsetParent;)e+=r.offsetTop,r=r.offsetParent;return e+(null!==(o=null==r?void 0:r.offsetTop)&&void 0!==o?o:0)-this.scrollable.offsetTop}getLastKnownHeight(t){var o;return+(null!==(o=null==t?void 0:t.getAttribute("data-last-known-height"))&&void 0!==o?o:1e3)}appendItems(...t){this.items=[...this.items,...t]}prependItems(...t){this.items=[...t,...this.items]}connectedCallback(){super.connectedCallback(),setTimeout((()=>{this.triggerFindScrollableParent(),this.initIntersectionObserver(),this.mutationObserver.disconnect(),this.mutationObserver.observe(this.itemsContainer,{childList:!0})}),0)}initIntersectionObserver(){this.intersectionObserver.disconnect(),this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange,{root:this.scrollable,rootMargin:"-8px",threshold:[0,.01,.1,1]})}triggerFindScrollableParent(){var t;null===(t=this.itemsContainer)||void 0===t||t.dispatchEvent(new Event("find-scrollable-parent",{composed:!0}))}findScrollableParent(t){var o;let e,r;t.stopPropagation();for(let o of t.composedPath()){const t=o,i=this.elementCanScroll(t);if(t.clientHeight&&t.clientHeight<t.scrollHeight&&i){e=t;break}i&&(r=t)}let i=e||r;i!==this.firstScrollableParent&&(null===(o=this.firstScrollableParent)||void 0===o||o.removeEventListener("scroll",this.scrollListener),null==i||i.addEventListener("scroll",this.scrollListener),this.firstScrollableParent=i,this.initIntersectionObserver(),this.resetScroll())}elementCanScroll(t){try{return["auto","scroll"].includes(getComputedStyle(t).overflowY)}catch(t){return!1}}searchFirstVisibleItem(t,o,e){if(o=null!=o?o:0,(e=null!=e?e:t.length-1)<=o)return t[o];const r=Math.floor((e-o)/2)+o,i=t[r];return this.getOffset(i)>this.scrollable.scrollTop?this.searchFirstVisibleItem(t,o,r-1):this.getOffset(i)+this.getLastKnownHeight(i)<this.scrollable.scrollTop?this.searchFirstVisibleItem(t,r+1,e):i}disconnectedCallback(){super.disconnectedCallback(),this.intersectionObserver.disconnect(),this.resizeObserver.disconnect(),this.mutationObserver.disconnect()}firstUpdated(t){super.firstUpdated(t),this.resetScroll()}update(t){super.update(t),t.has("items")&&(this.alreadyRenderedIndexes=new Set),!t.has("scrollToItem")&&!t.has("scrollToIndex")||null==this.scrollToItem&&null==this.scrollToIndex||this.resetScroll()}updated(t){super.updated(t),(t.has("visibleItems")||t.has("items"))&&this.onVisibleItemsChange(),t.has("scrolledToTarget")&&this.scrolledToTarget&&(null!=this.scrollToItem||null!=this.scrollToIndex)&&this.dispatchEvent(new Oe)}onVisibleItemsChange(){const t=this.visibleItems.every(((t,o)=>null==this.visibleItems[o+1]||t+1===this.visibleItems[o+1]));t||k(this.visibleItems,this.lastNotOkVisibleItems)?(this.resetVisibleItemsDebouncer.cancel(),this.dispatchVisibleItemsEvent()):this.resetVisibleItemsDebouncer.run((()=>{this.lastNotOkVisibleItems=[...this.visibleItems],this.visibleItems=[],this.initIntersectionObserver(),this.onMutation()}))}dispatchVisibleItemsEvent(){var t,o;null===(t=this.cancelableDispatchEvent)||void 0===t||t.cancel(),this.cancelableDispatchEvent=(o=async function(t,o=5){let e=await t();for(;!e;)await W(o),e=await t()}((()=>!this.scrolling)),new e(((t,e)=>o.then(t).catch(e)))),this.cancelableDispatchEvent.then((()=>this.dispatchEvent(new me(this.visibleItems,this.visibleItems.map((t=>this.items[t])))))).catch((()=>null))}}Ne.styles=ge,be([R({type:Array})],Ne.prototype,"items",void 0),be([R({attribute:!1})],Ne.prototype,"renderItem",void 0),be([R({attribute:!1})],Ne.prototype,"getItemKey",void 0),be([R({type:Object})],Ne.prototype,"scrollToItem",void 0),be([R({type:Number})],Ne.prototype,"scrollToIndex",void 0),be([R({type:Boolean})],Ne.prototype,"internalScroll",void 0),be([R({type:Number})],Ne.prototype,"renderBeforeFirst",void 0),be([R({type:Number})],Ne.prototype,"renderAfterLast",void 0),be([E({hasChanged:(t,o)=>null!=t&&null==o||t.length!==o.length||t[0]!==o[0]})],Ne.prototype,"visibleItems",void 0),be([I(".scrollable")],Ne.prototype,"internalScrollable",void 0),be([I(".items-container")],Ne.prototype,"itemsContainer",void 0),be([E()],Ne.prototype,"scrolledToTarget",void 0),be([E()],Ne.prototype,"scrolling",void 0),K("ft-infinite-scroll")(Ne);const ve=wt`
180
+ `}resetScroll(){this.triggerFindScrollableParent(),this.intersectionObserver.disconnect(),this.resizeObserver.disconnect(),this.visibleItems=[],this.scrolledToTarget=!1,this.scrollDebouncer.run((()=>{var t;let o=null!==(t=this.scrollToIndex)&&void 0!==t?t:this.scrollToItem?this.items.indexOf(this.scrollToItem):-1;o>=this.items.length&&(o=-1);const e=this.getItem(o);this.scrollToTarget(e),this.scrollDoneDebouncer.run((()=>{this.scrollRestorationItem=o>=0?o:void 0,this.scrollRestorationOffset=0===o?-this.getOffset(e):0,this.onMutation(),this.scrolledToTarget=!0}))}))}getItem(t){var o;return null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector(`#item-${t}`)}scrollToTarget(t){var o;if(t){let e=+(null!==(o=t.getAttribute("data-item-index"))&&void 0!==o?o:"0");this.scrollable&&0===e?this.scrollable.scrollTop=0:this.scrollable.scrollTop=this.getOffset(t)}}getOffset(t){var o;let e=0,r=t;for(;r&&r.offsetParent!==this.scrollable.offsetParent;)e+=r.offsetTop,r=r.offsetParent;return e+(null!==(o=null==r?void 0:r.offsetTop)&&void 0!==o?o:0)-this.scrollable.offsetTop}getLastKnownHeight(t){var o;return+(null!==(o=null==t?void 0:t.getAttribute("data-last-known-height"))&&void 0!==o?o:1e3)}appendItems(...t){this.items=[...this.items,...t]}prependItems(...t){this.items=[...t,...this.items]}connectedCallback(){super.connectedCallback(),setTimeout((()=>{this.triggerFindScrollableParent(),this.initIntersectionObserver(),this.mutationObserver.disconnect(),this.mutationObserver.observe(this.itemsContainer,{childList:!0})}),0)}initIntersectionObserver(){this.intersectionObserver.disconnect(),this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange,{root:this.scrollable,rootMargin:"-8px",threshold:[0,.01,.1,1]})}triggerFindScrollableParent(){var t;null===(t=this.itemsContainer)||void 0===t||t.dispatchEvent(new Event("find-scrollable-parent",{composed:!0}))}findScrollableParent(t){var o;let e,r;t.stopPropagation();for(let o of t.composedPath()){const t=o,i=this.elementCanScroll(t);if(t.clientHeight&&t.clientHeight<t.scrollHeight&&i){e=t;break}i&&(r=t)}let i=e||r;i!==this.firstScrollableParent&&(null===(o=this.firstScrollableParent)||void 0===o||o.removeEventListener("scroll",this.scrollListener),null==i||i.addEventListener("scroll",this.scrollListener),this.firstScrollableParent=i,this.initIntersectionObserver(),this.resetScroll())}elementCanScroll(t){try{return["auto","scroll"].includes(getComputedStyle(t).overflowY)}catch(t){return!1}}searchFirstVisibleItem(t,o,e){if(o=null!=o?o:0,(e=null!=e?e:t.length-1)<=o)return t[o];const r=Math.floor((e-o)/2)+o,i=t[r];return this.getOffset(i)>this.scrollable.scrollTop?this.searchFirstVisibleItem(t,o,r-1):this.getOffset(i)+this.getLastKnownHeight(i)<this.scrollable.scrollTop?this.searchFirstVisibleItem(t,r+1,e):i}disconnectedCallback(){super.disconnectedCallback(),this.intersectionObserver.disconnect(),this.resizeObserver.disconnect(),this.mutationObserver.disconnect()}firstUpdated(t){super.firstUpdated(t),this.resetScroll()}update(t){super.update(t),t.has("items")&&(this.alreadyRenderedIndexes=new Set),!t.has("scrollToItem")&&!t.has("scrollToIndex")||null==this.scrollToItem&&null==this.scrollToIndex||this.resetScroll()}updated(t){super.updated(t),(t.has("visibleItems")||t.has("items"))&&this.onVisibleItemsChange(),t.has("scrolledToTarget")&&this.scrolledToTarget&&(null!=this.scrollToItem||null!=this.scrollToIndex)&&this.dispatchEvent(new Oe)}onVisibleItemsChange(){const t=this.visibleItems.every(((t,o)=>null==this.visibleItems[o+1]||t+1===this.visibleItems[o+1]));t||k(this.visibleItems,this.lastNotOkVisibleItems)?(this.resetVisibleItemsDebouncer.cancel(),this.dispatchVisibleItemsEvent()):this.resetVisibleItemsDebouncer.run((()=>{this.lastNotOkVisibleItems=[...this.visibleItems],this.visibleItems=[],this.initIntersectionObserver(),this.onMutation()}))}dispatchVisibleItemsEvent(){var t,o;null===(t=this.cancelableDispatchEvent)||void 0===t||t.cancel(),this.cancelableDispatchEvent=(o=async function(t,o=5){let e=await t();for(;!e;)await W(o),e=await t()}((()=>!this.scrolling)),new e(((t,e)=>o.then(t).catch(e)))),this.cancelableDispatchEvent.then((()=>this.dispatchEvent(new me(this.visibleItems,this.visibleItems.map((t=>this.items[t])))))).catch((()=>null))}}Ne.styles=ge,be([R({type:Array})],Ne.prototype,"items",void 0),be([R({attribute:!1})],Ne.prototype,"renderItem",void 0),be([R({attribute:!1})],Ne.prototype,"getItemKey",void 0),be([R({type:Object})],Ne.prototype,"scrollToItem",void 0),be([R({type:Number})],Ne.prototype,"scrollToIndex",void 0),be([R({type:Boolean})],Ne.prototype,"internalScroll",void 0),be([R({type:Number})],Ne.prototype,"renderBeforeFirst",void 0),be([R({type:Number})],Ne.prototype,"renderAfterLast",void 0),be([E({hasChanged:(t,o)=>null!=t&&null==o||t.length!==o.length||t[0]!==o[0]})],Ne.prototype,"visibleItems",void 0),be([I(".scrollable")],Ne.prototype,"internalScrollable",void 0),be([I(".items-container")],Ne.prototype,"itemsContainer",void 0),be([E()],Ne.prototype,"scrolledToTarget",void 0),be([E()],Ne.prototype,"scrolling",void 0),K("ft-infinite-scroll")(Ne);const ve=wt`
181
181
  `,Se=wt`
182
182
  `;var we=function(t,o,e,r){for(var i,n=arguments.length,s=n<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,e):r,a=t.length-1;a>=0;a--)(i=t[a])&&(s=(n<3?i(s):n>3?i(o,e,s):i(o,e))||s);return n>3&&s&&Object.defineProperty(o,e,s),s};class Ce extends Qo{constructor(){super(...arguments),this.disableContextInteractions=!1,this.registeredComponents=[]}render(){return no`
183
183
  <article id=${this.tocId}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-reader-content",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "Main content for integrated reader",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,12 +19,12 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-infinite-scroll": "1.1.7",
23
- "@fluid-topics/ft-reader-topic-content": "1.1.7",
24
- "@fluid-topics/ft-reader-topic-context": "1.1.7",
25
- "@fluid-topics/ft-reader-topic-title": "1.1.7",
26
- "@fluid-topics/ft-wc-utils": "1.1.7",
22
+ "@fluid-topics/ft-infinite-scroll": "1.1.9",
23
+ "@fluid-topics/ft-reader-topic-content": "1.1.9",
24
+ "@fluid-topics/ft-reader-topic-context": "1.1.9",
25
+ "@fluid-topics/ft-reader-topic-title": "1.1.9",
26
+ "@fluid-topics/ft-wc-utils": "1.1.9",
27
27
  "lit": "3.1.0"
28
28
  },
29
- "gitHead": "732f43d1a665d4917e01d0e34665779782fdd3c9"
29
+ "gitHead": "260010bbe1de163e812ed46e15cd25b7008f2f87"
30
30
  }