@fluid-topics/ft-infinite-scroll 0.0.88

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.
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ An infinite scroller.
2
+
3
+ ## Install
4
+
5
+ ```shell
6
+ npm install @fluid-topics/ft-infinite-scroll
7
+ yarn add @fluid-topics/ft-infinite-scroll
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ### Lit
13
+
14
+ ```typescript
15
+ import { html } from "lit"
16
+ import "@fluid-topics/ft-infinite-scroll"
17
+ import { VisibleItemsChangeEvent } from "@fluid-topics/ft-infinite-scroll"
18
+
19
+ interface Model {
20
+ ...
21
+ }
22
+
23
+ function render() {
24
+ const data: Array<Model> = [ ... ]
25
+ return html`
26
+ <ft-infinite-scroll
27
+ .items=${ data }
28
+ .renderItems=${ (item: Model) => html`<div>${ item.title }</div>` }
29
+ .scrollToIndex=${ 3 }
30
+ @visible-items-change=${ (e: VisibleItemsChangeEvent<Model>) => console.log(e.detail.visibleItems) }
31
+ />
32
+ `
33
+ }
34
+ ```
@@ -0,0 +1,46 @@
1
+ import { PropertyValues, TemplateResult } from "lit";
2
+ import { FtLitElement } from "@fluid-topics/ft-wc-utils";
3
+ export interface FtInfiniteScrollProperties<T> {
4
+ items: Array<T>;
5
+ renderItem: (item: T, index: number) => TemplateResult | string;
6
+ scrollToItem?: T;
7
+ scrollToIndex?: number;
8
+ }
9
+ export interface FtInfiniteScrollCssVariables {
10
+ "--ft-infinite-scroll-padding": string;
11
+ }
12
+ export declare type VisibleItems<T> = {
13
+ visibleIndexes: Array<number>;
14
+ visibleItems: Array<T>;
15
+ };
16
+ export declare class VisibleItemsChangeEvent<T> extends CustomEvent<VisibleItems<T>> {
17
+ constructor(indexes: Array<number>, items: Array<T>);
18
+ }
19
+ export declare class FtInfiniteScroll<T> extends FtLitElement implements FtInfiniteScrollProperties<T> {
20
+ protected getStyles(): import("lit").CSSResult;
21
+ items: Array<T>;
22
+ renderItem: (item: T, index: number) => TemplateResult | string;
23
+ scrollToItem?: T;
24
+ scrollToIndex?: number;
25
+ private internalScrollToIndex;
26
+ visibleItems: Array<number>;
27
+ scrollable: HTMLDivElement;
28
+ scrolledToTarget: boolean;
29
+ protected getTemplate(): TemplateResult<1>;
30
+ private renderItemContainer;
31
+ resetScroll(): void;
32
+ appendItems(...items: Array<T>): void;
33
+ prependItems(...items: Array<T>): void;
34
+ private onVisibilityChange;
35
+ private intersectionObserver;
36
+ connectedCallback(): void;
37
+ private onResize;
38
+ private resizeObserver;
39
+ private onMutation;
40
+ private mutationObserver;
41
+ disconnectedCallback(): void;
42
+ protected firstUpdated(_changedProperties: PropertyValues): void;
43
+ protected update(props: PropertyValues<FtInfiniteScroll<T>>): void;
44
+ protected updated(props: PropertyValues<FtInfiniteScroll<T>>): void;
45
+ }
46
+ //# sourceMappingURL=ft-infinite-scroll.d.ts.map
@@ -0,0 +1,205 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { css, html } from "lit";
8
+ import { property, query, state } from "lit/decorators.js";
9
+ import { repeat } from "lit/directives/repeat.js";
10
+ import { customElement, FtLitElement, isSafari } from "@fluid-topics/ft-wc-utils";
11
+ import { unsafeHTML } from "lit-html/directives/unsafe-html.js";
12
+ export class VisibleItemsChangeEvent extends CustomEvent {
13
+ constructor(indexes, items) {
14
+ super("visible-items-change", {
15
+ detail: {
16
+ visibleIndexes: indexes,
17
+ visibleItems: items
18
+ }
19
+ });
20
+ }
21
+ }
22
+ const last = (arr) => arr[arr.length - 1];
23
+ let FtInfiniteScroll = class FtInfiniteScroll extends FtLitElement {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.items = [];
27
+ this.renderItem = () => html ``;
28
+ this.internalScrollToIndex = 0;
29
+ this.visibleItems = [];
30
+ this.scrolledToTarget = false;
31
+ this.onVisibilityChange = (items) => {
32
+ const newItems = items.filter(item => item.isIntersecting)
33
+ .map(item => +item.target.attributes.getNamedItem("data-item-index").value)
34
+ .filter(index => !this.visibleItems.includes(index));
35
+ const itemsToRemove = items.filter(item => !item.isIntersecting)
36
+ .map(item => +item.target.attributes.getNamedItem("data-item-index").value)
37
+ .filter(index => this.visibleItems.includes(index));
38
+ const stillVisible = [...this.visibleItems].filter(index => !itemsToRemove.includes(index));
39
+ this.visibleItems = [...newItems, ...stillVisible].sort((a, b) => a - b);
40
+ };
41
+ this.intersectionObserver = new IntersectionObserver(this.onVisibilityChange);
42
+ this.onResize = (resizables) => {
43
+ let diff = 0;
44
+ for (const resizable of resizables) {
45
+ let currentHeight = resizable.target.parentElement.clientHeight;
46
+ let newHeight = resizable.contentRect.height;
47
+ if (resizable.target.classList.contains("visible")) {
48
+ resizable.target.parentElement.style.height = newHeight + "px";
49
+ diff += resizable.target.parentElement.offsetTop < this.scrollable.scrollTop ? currentHeight - newHeight : 0;
50
+ }
51
+ }
52
+ if (isSafari) {
53
+ this.scrollable.scrollTop -= diff;
54
+ }
55
+ };
56
+ this.resizeObserver = new ResizeObserver(this.onResize);
57
+ this.onMutation = () => {
58
+ [...this.scrollable.children].forEach((item) => {
59
+ this.intersectionObserver.observe(item);
60
+ this.resizeObserver.observe(item.children.item(0));
61
+ });
62
+ };
63
+ this.mutationObserver = new MutationObserver(this.onMutation);
64
+ }
65
+ // language=CSS
66
+ getStyles() {
67
+ return css `
68
+ .scrollable {
69
+ height: 100%;
70
+ overflow-y: auto;
71
+ position: relative;
72
+ padding: var(--ft-infinite-scroll-padding, 0);
73
+ outline: none;
74
+ }
75
+
76
+ .item-container {
77
+ height: 100%;
78
+ }
79
+
80
+ .resizable:not(.visible) {
81
+ width: 0;
82
+ }
83
+
84
+ .resizable:not(.visible) > * {
85
+ display: none;
86
+ }
87
+ `;
88
+ }
89
+ getTemplate() {
90
+ return html `
91
+ <div class="scrollable" tabindex="-1">
92
+ ${repeat(this.items, (item, index) => this.renderItemContainer(item, index))}
93
+ </div>
94
+ `;
95
+ }
96
+ renderItemContainer(item, index) {
97
+ const isVisible = this.scrolledToTarget && (this.visibleItems.includes(index) || this.visibleItems[0] === index + 1 || last(this.visibleItems) === index - 1);
98
+ const renderItem = () => {
99
+ const rendered = this.renderItem(item, index);
100
+ if (typeof rendered === "string") {
101
+ return html `${unsafeHTML(rendered)}`;
102
+ }
103
+ return rendered;
104
+ };
105
+ return html `
106
+ <div id="item-${index}"
107
+ class="item-container"
108
+ data-item-index="${index}">
109
+ <div class="resizable ${isVisible ? "visible" : ""}">
110
+ ${isVisible ? renderItem() : null}
111
+ </div>
112
+ </div>
113
+ `;
114
+ }
115
+ resetScroll() {
116
+ var _a;
117
+ this.intersectionObserver.disconnect();
118
+ this.resizeObserver.disconnect();
119
+ this.visibleItems = [];
120
+ this.internalScrollToIndex = (_a = this.scrollToIndex) !== null && _a !== void 0 ? _a : (this.scrollToItem ? this.items.indexOf(this.scrollToItem) : 0);
121
+ if (this.internalScrollToIndex < 0 || this.internalScrollToIndex >= this.items.length) {
122
+ this.internalScrollToIndex = 0;
123
+ }
124
+ this.scrolledToTarget = false;
125
+ }
126
+ appendItems(...items) {
127
+ this.items = [...this.items, ...items];
128
+ }
129
+ prependItems(...items) {
130
+ this.items = [...items, ...this.items];
131
+ }
132
+ connectedCallback() {
133
+ super.connectedCallback();
134
+ setTimeout(() => {
135
+ this.intersectionObserver.disconnect();
136
+ this.intersectionObserver = new IntersectionObserver(this.onVisibilityChange, { root: this.scrollable });
137
+ this.mutationObserver.disconnect();
138
+ this.mutationObserver.observe(this.scrollable, { childList: true });
139
+ }, 0);
140
+ }
141
+ disconnectedCallback() {
142
+ super.disconnectedCallback();
143
+ this.intersectionObserver.disconnect();
144
+ this.resizeObserver.disconnect();
145
+ this.mutationObserver.disconnect();
146
+ }
147
+ firstUpdated(_changedProperties) {
148
+ super.firstUpdated(_changedProperties);
149
+ this.resetScroll();
150
+ }
151
+ update(props) {
152
+ super.update(props);
153
+ if (props.has("scrollToItem") || props.has("scrollToIndex")) {
154
+ this.resetScroll();
155
+ }
156
+ }
157
+ updated(props) {
158
+ super.updated(props);
159
+ if (!this.scrolledToTarget) {
160
+ setTimeout(() => {
161
+ var _a;
162
+ if (this.internalScrollToIndex === 0) {
163
+ this.scrollable.scrollTop = 0;
164
+ }
165
+ else {
166
+ let target = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#item-${this.internalScrollToIndex}`);
167
+ this.scrollable.scrollTop = target.offsetTop;
168
+ }
169
+ this.onMutation();
170
+ setTimeout(() => {
171
+ this.scrolledToTarget = true;
172
+ }, 50);
173
+ }, 50);
174
+ }
175
+ if (props.has("visibleItems") || props.has("items")) {
176
+ this.dispatchEvent(new VisibleItemsChangeEvent(this.visibleItems, this.visibleItems.map(index => this.items[index])));
177
+ }
178
+ }
179
+ };
180
+ __decorate([
181
+ property({ type: Array })
182
+ ], FtInfiniteScroll.prototype, "items", void 0);
183
+ __decorate([
184
+ property({ attribute: false })
185
+ ], FtInfiniteScroll.prototype, "renderItem", void 0);
186
+ __decorate([
187
+ property({ type: Object })
188
+ ], FtInfiniteScroll.prototype, "scrollToItem", void 0);
189
+ __decorate([
190
+ property({ type: Number })
191
+ ], FtInfiniteScroll.prototype, "scrollToIndex", void 0);
192
+ __decorate([
193
+ state()
194
+ ], FtInfiniteScroll.prototype, "visibleItems", void 0);
195
+ __decorate([
196
+ query(".scrollable")
197
+ ], FtInfiniteScroll.prototype, "scrollable", void 0);
198
+ __decorate([
199
+ state()
200
+ ], FtInfiniteScroll.prototype, "scrolledToTarget", void 0);
201
+ FtInfiniteScroll = __decorate([
202
+ customElement("ft-infinite-scroll")
203
+ ], FtInfiniteScroll);
204
+ export { FtInfiniteScroll };
205
+ //# sourceMappingURL=ft-infinite-scroll.js.map
@@ -0,0 +1,79 @@
1
+ !function(t){
2
+ /**
3
+ * @license
4
+ * Copyright 2019 Google LLC
5
+ * SPDX-License-Identifier: BSD-3-Clause
6
+ */
7
+ const i=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,e=Symbol(),s=new Map;class n{constructor(t,i){if(this._$cssResult$=!0,i!==e)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=s.get(this.cssText);return i&&void 0===t&&(s.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const o=(t,...i)=>{const s=1===t.length?t[0]:i.reduce(((i,e,s)=>i+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(e)+t[s+1]),t[0]);return new n(s,e)},r=(t,e)=>{i?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((i=>{const e=document.createElement("style"),s=window.litNonce;void 0!==s&&e.setAttribute("nonce",s),e.textContent=i.cssText,t.appendChild(e)}))},l=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let i="";for(const e of t.cssRules)i+=e.cssText;return(t=>new n("string"==typeof t?t:t+"",e))(i)})(t):t
8
+ /**
9
+ * @license
10
+ * Copyright 2017 Google LLC
11
+ * SPDX-License-Identifier: BSD-3-Clause
12
+ */;var h;const u=window.trustedTypes,a=u?u.emptyScript:"",c=window.reactiveElementPolyfillSupport,d={toAttribute(t,i){switch(i){case Boolean:t=t?a:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,i){let e=t;switch(i){case Boolean:e=null!==t;break;case Number:e=null===t?null:Number(t);break;case Object:case Array:try{e=JSON.parse(t)}catch(t){e=null}}return e}},v=(t,i)=>i!==t&&(i==i||t==t),f={attribute:!0,type:String,converter:d,reflect:!1,hasChanged:v};class w extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var i;null!==(i=this.l)&&void 0!==i||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((i,e)=>{const s=this._$Eh(e,i);void 0!==s&&(this._$Eu.set(s,e),t.push(s))})),t}static createProperty(t,i=f){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const e="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,e,i);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,e){return{get(){return this[i]},set(s){const n=this[t];this[i]=s,this.requestUpdate(t,n,e)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||f}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const e of i)this.createProperty(e,t[e])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const i=[];if(Array.isArray(t)){const e=new Set(t.flat(1/0).reverse());for(const t of e)i.unshift(l(t))}else void 0!==t&&i.push(l(t));return i}static _$Eh(t,i){const e=i.attribute;return!1===e?void 0:"string"==typeof e?e:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var i,e;(null!==(i=this._$Eg)&&void 0!==i?i:this._$Eg=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(e=t.hostConnected)||void 0===e||e.call(t))}removeController(t){var i;null===(i=this._$Eg)||void 0===i||i.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((t,i)=>{this.hasOwnProperty(i)&&(this._$Et.set(i,this[i]),delete this[i])}))}createRenderRoot(){var t;const i=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return r(i,this.constructor.elementStyles),i}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostConnected)||void 0===i?void 0:i.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostDisconnected)||void 0===i?void 0:i.call(t)}))}attributeChangedCallback(t,i,e){this._$AK(t,e)}_$ES(t,i,e=f){var s,n;const o=this.constructor._$Eh(t,e);if(void 0!==o&&!0===e.reflect){const r=(null!==(n=null===(s=e.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==n?n:d.toAttribute)(i,e.type);this._$Ei=t,null==r?this.removeAttribute(o):this.setAttribute(o,r),this._$Ei=null}}_$AK(t,i){var e,s,n;const o=this.constructor,r=o._$Eu.get(t);if(void 0!==r&&this._$Ei!==r){const t=o.getPropertyOptions(r),l=t.converter,h=null!==(n=null!==(s=null===(e=l)||void 0===e?void 0:e.fromAttribute)&&void 0!==s?s:"function"==typeof l?l:null)&&void 0!==n?n:d.fromAttribute;this._$Ei=r,this[r]=h(i,t.type),this._$Ei=null}}requestUpdate(t,i,e){let s=!0;void 0!==t&&(((e=e||this.constructor.getPropertyOptions(t)).hasChanged||v)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===e.reflect&&this._$Ei!==t&&(void 0===this._$E_&&(this._$E_=new Map),this._$E_.set(t,e))):s=!1),!this.isUpdatePending&&s&&(this._$Ep=this._$EC())}async _$EC(){this.isUpdatePending=!0;try{await this._$Ep}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,i)=>this[i]=t)),this._$Et=void 0);let i=!1;const e=this._$AL;try{i=this.shouldUpdate(e),i?(this.willUpdate(e),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostUpdate)||void 0===i?void 0:i.call(t)})),this.update(e)):this._$EU()}catch(t){throw i=!1,this._$EU(),t}i&&this._$AE(e)}willUpdate(t){}_$AE(t){var i;null===(i=this._$Eg)||void 0===i||i.forEach((t=>{var i;return null===(i=t.hostUpdated)||void 0===i?void 0:i.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(t){return!0}update(t){void 0!==this._$E_&&(this._$E_.forEach(((t,i)=>this._$ES(i,this[i],t))),this._$E_=void 0),this._$EU()}updated(t){}firstUpdated(t){}}
13
+ /**
14
+ * @license
15
+ * Copyright 2017 Google LLC
16
+ * SPDX-License-Identifier: BSD-3-Clause
17
+ */
18
+ var p;w.finalized=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},null==c||c({ReactiveElement:w}),(null!==(h=globalThis.reactiveElementVersions)&&void 0!==h?h:globalThis.reactiveElementVersions=[]).push("1.2.2");const b=globalThis.trustedTypes,m=b?b.createPolicy("lit-html",{createHTML:t=>t}):void 0,y=`lit$${(Math.random()+"").slice(9)}$`,g="?"+y,S=`<${g}>`,$=document,O=(t="")=>$.createComment(t),E=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,j=t=>{var i;return T(t)||"function"==typeof(null===(i=t)||void 0===i?void 0:i[Symbol.iterator])},C=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,k=/-->/g,A=/>/g,M=/>|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g,x=/'/g,R=/"/g,_=/^(?:script|style|textarea|title)$/i,I=(t=>(i,...e)=>({_$litType$:t,strings:i,values:e}))(1),U=Symbol.for("lit-noChange"),L=Symbol.for("lit-nothing"),H=new WeakMap,N=$.createTreeWalker($,129,null,!1),z=(t,i)=>{const e=t.length-1,s=[];let n,o=2===i?"<svg>":"",r=C;for(let i=0;i<e;i++){const e=t[i];let l,h,u=-1,a=0;for(;a<e.length&&(r.lastIndex=a,h=r.exec(e),null!==h);)a=r.lastIndex,r===C?"!--"===h[1]?r=k:void 0!==h[1]?r=A:void 0!==h[2]?(_.test(h[2])&&(n=RegExp("</"+h[2],"g")),r=M):void 0!==h[3]&&(r=M):r===M?">"===h[0]?(r=null!=n?n:C,u=-1):void 0===h[1]?u=-2:(u=r.lastIndex-h[2].length,l=h[1],r=void 0===h[3]?M:'"'===h[3]?R:x):r===R||r===x?r=M:r===k||r===A?r=C:(r=M,n=void 0);const c=r===M&&t[i+1].startsWith("/>")?" ":"";o+=r===C?e+S:u>=0?(s.push(l),e.slice(0,u)+"$lit$"+e.slice(u)+y+c):e+y+(-2===u?(s.push(void 0),i):c)}const l=o+(t[e]||"<?>")+(2===i?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==m?m.createHTML(l):l,s]};class D{constructor({strings:t,_$litType$:i},e){let s;this.parts=[];let n=0,o=0;const r=t.length-1,l=this.parts,[h,u]=z(t,i);if(this.el=D.createElement(h,e),N.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(s=N.nextNode())&&l.length<r;){if(1===s.nodeType){if(s.hasAttributes()){const t=[];for(const i of s.getAttributeNames())if(i.endsWith("$lit$")||i.startsWith(y)){const e=u[o++];if(t.push(i),void 0!==e){const t=s.getAttribute(e.toLowerCase()+"$lit$").split(y),i=/([.?@])?(.*)/.exec(e);l.push({type:1,index:n,name:i[2],strings:t,ctor:"."===i[1]?B:"?"===i[1]?J:"@"===i[1]?K:V})}else l.push({type:6,index:n})}for(const i of t)s.removeAttribute(i)}if(_.test(s.tagName)){const t=s.textContent.split(y),i=t.length-1;if(i>0){s.textContent=b?b.emptyScript:"";for(let e=0;e<i;e++)s.append(t[e],O()),N.nextNode(),l.push({type:2,index:++n});s.append(t[i],O())}}}else if(8===s.nodeType)if(s.data===g)l.push({type:2,index:n});else{let t=-1;for(;-1!==(t=s.data.indexOf(y,t+1));)l.push({type:7,index:n}),t+=y.length-1}n++}}static createElement(t,i){const e=$.createElement("template");return e.innerHTML=t,e}}function F(t,i,e=t,s){var n,o,r,l;if(i===U)return i;let h=void 0!==s?null===(n=e._$Cl)||void 0===n?void 0:n[s]:e._$Cu;const u=E(i)?void 0:i._$litDirective$;return(null==h?void 0:h.constructor)!==u&&(null===(o=null==h?void 0:h._$AO)||void 0===o||o.call(h,!1),void 0===u?h=void 0:(h=new u(t),h._$AT(t,e,s)),void 0!==s?(null!==(r=(l=e)._$Cl)&&void 0!==r?r:l._$Cl=[])[s]=h:e._$Cu=h),void 0!==h&&(i=F(t,h._$AS(t,i.values),h,s)),i}class P{constructor(t,i){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var i;const{el:{content:e},parts:s}=this._$AD,n=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:$).importNode(e,!0);N.currentNode=n;let o=N.nextNode(),r=0,l=0,h=s[0];for(;void 0!==h;){if(r===h.index){let i;2===h.type?i=new W(o,o.nextSibling,this,t):1===h.type?i=new h.ctor(o,h.name,h.strings,this,t):6===h.type&&(i=new q(o,this,t)),this.v.push(i),h=s[++l]}r!==(null==h?void 0:h.index)&&(o=N.nextNode(),r++)}return n}m(t){let i=0;for(const e of this.v)void 0!==e&&(void 0!==e.strings?(e._$AI(t,e,i),i+=e.strings.length-2):e._$AI(t[i])),i++}}class W{constructor(t,i,e,s){var n;this.type=2,this._$AH=L,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=e,this.options=s,this._$Cg=null===(n=null==s?void 0:s.isConnected)||void 0===n||n}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=F(this,t,i),E(t)?t===L||null==t||""===t?(this._$AH!==L&&this._$AR(),this._$AH=L):t!==this._$AH&&t!==U&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.S(t):j(t)?this.A(t):this.$(t)}M(t,i=this._$AB){return this._$AA.parentNode.insertBefore(t,i)}S(t){this._$AH!==t&&(this._$AR(),this._$AH=this.M(t))}$(t){this._$AH!==L&&E(this._$AH)?this._$AA.nextSibling.data=t:this.S($.createTextNode(t)),this._$AH=t}T(t){var i;const{values:e,_$litType$:s}=t,n="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=D.createElement(s.h,this.options)),s);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===n)this._$AH.m(e);else{const t=new P(n,this),i=t.p(this.options);t.m(e),this.S(i),this._$AH=t}}_$AC(t){let i=H.get(t.strings);return void 0===i&&H.set(t.strings,i=new D(t)),i}A(t){T(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let e,s=0;for(const n of t)s===i.length?i.push(e=new W(this.M(O()),this.M(O()),this,this.options)):e=i[s],e._$AI(n),s++;s<i.length&&(this._$AR(e&&e._$AB.nextSibling,s),i.length=s)}_$AR(t=this._$AA.nextSibling,i){var e;for(null===(e=this._$AP)||void 0===e||e.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cg=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class V{constructor(t,i,e,s,n){this.type=1,this._$AH=L,this._$AN=void 0,this.element=t,this.name=i,this._$AM=s,this.options=n,e.length>2||""!==e[0]||""!==e[1]?(this._$AH=Array(e.length-1).fill(new String),this.strings=e):this._$AH=L}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,e,s){const n=this.strings;let o=!1;if(void 0===n)t=F(this,t,i,0),o=!E(t)||t!==this._$AH&&t!==U,o&&(this._$AH=t);else{const s=t;let r,l;for(t=n[0],r=0;r<n.length-1;r++)l=F(this,s[e+r],i,r),l===U&&(l=this._$AH[r]),o||(o=!E(l)||l!==this._$AH[r]),l===L?t=L:t!==L&&(t+=(null!=l?l:"")+n[r+1]),this._$AH[r]=l}o&&!s&&this.k(t)}k(t){t===L?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class B extends V{constructor(){super(...arguments),this.type=3}k(t){this.element[this.name]=t===L?void 0:t}}const Z=b?b.emptyScript:"";class J extends V{constructor(){super(...arguments),this.type=4}k(t){t&&t!==L?this.element.setAttribute(this.name,Z):this.element.removeAttribute(this.name)}}class K extends V{constructor(t,i,e,s,n){super(t,i,e,s,n),this.type=5}_$AI(t,i=this){var e;if((t=null!==(e=F(this,t,i,0))&&void 0!==e?e:L)===U)return;const s=this._$AH,n=t===L&&s!==L||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==L&&(s===L||n);n&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,e;"function"==typeof this._$AH?this._$AH.call(null!==(e=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==e?e:this.element,t):this._$AH.handleEvent(t)}}class q{constructor(t,i,e){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=e}get _$AU(){return this._$AM._$AU}_$AI(t){F(this,t)}}const G={P:"$lit$",V:y,L:g,I:1,N:z,R:P,D:j,j:F,H:W,O:V,F:J,B:K,W:B,Z:q},Q=window.litHtmlPolyfillSupport;
19
+ /**
20
+ * @license
21
+ * Copyright 2017 Google LLC
22
+ * SPDX-License-Identifier: BSD-3-Clause
23
+ */
24
+ var X,Y;null==Q||Q(D,W),(null!==(p=globalThis.litHtmlVersions)&&void 0!==p?p:globalThis.litHtmlVersions=[]).push("2.1.3");class tt extends w{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,i;const e=super.createRenderRoot();return null!==(t=(i=this.renderOptions).renderBefore)&&void 0!==t||(i.renderBefore=e.firstChild),e}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=((t,i,e)=>{var s,n;const o=null!==(s=null==e?void 0:e.renderBefore)&&void 0!==s?s:i;let r=o._$litPart$;if(void 0===r){const t=null!==(n=null==e?void 0:e.renderBefore)&&void 0!==n?n:null;o._$litPart$=r=new W(i.insertBefore(O(),t),t,void 0,null!=e?e:{})}return r._$AI(t),r})(i,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return U}}tt.finalized=!0,tt._$litElement$=!0,null===(X=globalThis.litElementHydrateSupport)||void 0===X||X.call(globalThis,{LitElement:tt});const it=globalThis.litElementPolyfillSupport;null==it||it({LitElement:tt}),(null!==(Y=globalThis.litElementVersions)&&void 0!==Y?Y:globalThis.litElementVersions=[]).push("3.1.2");
25
+ /**
26
+ * @license
27
+ * Copyright 2017 Google LLC
28
+ * SPDX-License-Identifier: BSD-3-Clause
29
+ */
30
+ const et=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i,finisher(e){e.createProperty(i.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:i.key,initializer(){"function"==typeof i.initializer&&(this[i.key]=i.initializer.call(this))},finisher(e){e.createProperty(i.key,t)}};function st(t){return(i,e)=>void 0!==e?((t,i,e)=>{i.constructor.createProperty(e,t)})(t,i,e):et(t,i)
31
+ /**
32
+ * @license
33
+ * Copyright 2017 Google LLC
34
+ * SPDX-License-Identifier: BSD-3-Clause
35
+ */}function nt(t){return st({...t,state:!0})}
36
+ /**
37
+ * @license
38
+ * Copyright 2017 Google LLC
39
+ * SPDX-License-Identifier: BSD-3-Clause
40
+ */
41
+ /**
42
+ * @license
43
+ * Copyright 2021 Google LLC
44
+ * SPDX-License-Identifier: BSD-3-Clause
45
+ */
46
+ var ot;null===(ot=window.HTMLSlotElement)||void 0===ot||ot.prototype.assignedElements;
47
+ /**
48
+ * @license
49
+ * Copyright 2017 Google LLC
50
+ * SPDX-License-Identifier: BSD-3-Clause
51
+ */
52
+ const rt=2,lt=t=>(...i)=>({_$litDirective$:t,values:i});class ht{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,e){this._$Ct=t,this._$AM=i,this._$Ci=e}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}
53
+ /**
54
+ * @license
55
+ * Copyright 2020 Google LLC
56
+ * SPDX-License-Identifier: BSD-3-Clause
57
+ */const{H:ut}=G,at=()=>document.createComment(""),ct=(t,i,e)=>{var s;const n=t._$AA.parentNode,o=void 0===i?t._$AB:i._$AA;if(void 0===e){const i=n.insertBefore(at(),o),s=n.insertBefore(at(),o);e=new ut(i,s,t,t.options)}else{const i=e._$AB.nextSibling,r=e._$AM,l=r!==t;if(l){let i;null===(s=e._$AQ)||void 0===s||s.call(e,t),e._$AM=t,void 0!==e._$AP&&(i=t._$AU)!==r._$AU&&e._$AP(i)}if(i!==o||l){let t=e._$AA;for(;t!==i;){const i=t.nextSibling;n.insertBefore(t,o),t=i}}}return e},dt=(t,i,e=t)=>(t._$AI(i,e),t),vt={},ft=t=>{var i;null===(i=t._$AP)||void 0===i||i.call(t,!1,!0);let e=t._$AA;const s=t._$AB.nextSibling;for(;e!==s;){const t=e.nextSibling;e.remove(),e=t}},wt=(t,i,e)=>{const s=new Map;for(let n=i;n<=e;n++)s.set(t[n],n);return s},pt=lt(class extends ht{constructor(t){if(super(t),t.type!==rt)throw Error("repeat() can only be used in text expressions")}dt(t,i,e){let s;void 0===e?e=i:void 0!==i&&(s=i);const n=[],o=[];let r=0;for(const i of t)n[r]=s?s(i,r):r,o[r]=e(i,r),r++;return{values:o,keys:n}}render(t,i,e){return this.dt(t,i,e).values}update(t,[i,e,s]){var n;const o=(t=>t._$AH)(t),{values:r,keys:l}=this.dt(i,e,s);if(!Array.isArray(o))return this.at=l,r;const h=null!==(n=this.at)&&void 0!==n?n:this.at=[],u=[];let a,c,d=0,v=o.length-1,f=0,w=r.length-1;for(;d<=v&&f<=w;)if(null===o[d])d++;else if(null===o[v])v--;else if(h[d]===l[f])u[f]=dt(o[d],r[f]),d++,f++;else if(h[v]===l[w])u[w]=dt(o[v],r[w]),v--,w--;else if(h[d]===l[w])u[w]=dt(o[d],r[w]),ct(t,u[w+1],o[d]),d++,w--;else if(h[v]===l[f])u[f]=dt(o[v],r[f]),ct(t,o[d],o[v]),v--,f++;else if(void 0===a&&(a=wt(l,f,w),c=wt(h,d,v)),a.has(h[d]))if(a.has(h[v])){const i=c.get(l[f]),e=void 0!==i?o[i]:null;if(null===e){const i=ct(t,o[d]);dt(i,r[f]),u[f]=i}else u[f]=dt(e,r[f]),ct(t,o[d],e),o[i]=null;f++}else ft(o[v]),v--;else ft(o[d]),d++;for(;f<=w;){const i=ct(t,u[w+1]);dt(i,r[f]),u[f++]=i}for(;d<=v;){const t=o[d++];null!==t&&ft(t)}return this.at=l,((t,i=vt)=>{t._$AH=i})(t,u),U}});
58
+ /**
59
+ * @license
60
+ * Copyright 2017 Google LLC
61
+ * SPDX-License-Identifier: BSD-3-Clause
62
+ */(function(){function t(t){var i=0;return function(){return i<t.length?{done:!1,value:t[i++]}:{done:!0}}}function i(i){var e="undefined"!=typeof Symbol&&Symbol.iterator&&i[Symbol.iterator];return e?e.call(i):{next:t(i)}}function e(t){if(!(t instanceof Array)){t=i(t);for(var e,s=[];!(e=t.next()).done;)s.push(e.value);t=s}return t}var s="function"==typeof Object.create?Object.create:function(t){function i(){}return i.prototype=t,new i};var n,o=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var i=0;i<t.length;++i){var e=t[i];if(e&&e.Math==Math)return e}throw Error("Cannot find global object")}(this),r=function(){if("undefined"!=typeof Reflect&&Reflect.construct){if(function(){function t(){}return Reflect.construct(t,[],(function(){})),new t instanceof t}())return Reflect.construct;var t=Reflect.construct;return function(i,e,s){return i=t(i,e),s&&Reflect.setPrototypeOf(i,s.prototype),i}}return function(t,i,e){return void 0===e&&(e=t),e=s(e.prototype||Object.prototype),Function.prototype.apply.call(t,e,i)||e}}();if("function"==typeof Object.setPrototypeOf)n=Object.setPrototypeOf;else{var l;t:{var h={};try{h.__proto__={a:!0},l=h.a;break t}catch(t){}l=!1}n=l?function(t,i){if(t.__proto__=i,t.__proto__!==i)throw new TypeError(t+" is not extensible");return t}:null}var u=n;if(!ShadowRoot.prototype.createElement){var a,c=window.HTMLElement,d=window.customElements.define,v=window.customElements.get,f=window.customElements,w=new WeakMap,p=new WeakMap,b=new WeakMap,m=new WeakMap;window.CustomElementRegistry=function(){this.l=new Map,this.o=new Map,this.i=new Map,this.h=new Map},window.CustomElementRegistry.prototype.define=function(t,e){if(t=t.toLowerCase(),void 0!==this.j(t))throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': the name \""+t+'" has already been used with this registry');if(void 0!==this.o.get(e))throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry");var s=e.prototype.attributeChangedCallback,n=new Set(e.observedAttributes||[]);if(g(e,n,s),s={g:e,connectedCallback:e.prototype.connectedCallback,disconnectedCallback:e.prototype.disconnectedCallback,adoptedCallback:e.prototype.adoptedCallback,attributeChangedCallback:s,formAssociated:e.formAssociated,formAssociatedCallback:e.prototype.formAssociatedCallback,formDisabledCallback:e.prototype.formDisabledCallback,formResetCallback:e.prototype.formResetCallback,formStateRestoreCallback:e.prototype.formStateRestoreCallback,observedAttributes:n},this.l.set(t,s),this.o.set(e,s),(n=v.call(f,t))||(n=y(t),d.call(f,t,n)),this===window.customElements&&(b.set(e,s),s.s=n),n=this.h.get(t)){this.h.delete(t);for(var o=(n=i(n)).next();!o.done;o=n.next())o=o.value,p.delete(o),$(o,s,!0)}return void 0!==(s=this.i.get(t))&&(s.resolve(e),this.i.delete(t)),e},window.CustomElementRegistry.prototype.upgrade=function(){E.push(this),f.upgrade.apply(f,arguments),E.pop()},window.CustomElementRegistry.prototype.get=function(t){var i;return null==(i=this.l.get(t))?void 0:i.g},window.CustomElementRegistry.prototype.j=function(t){return this.l.get(t)},window.CustomElementRegistry.prototype.whenDefined=function(t){var i=this.j(t);if(void 0!==i)return Promise.resolve(i.g);var e=this.i.get(t);return void 0===e&&((e={}).promise=new Promise((function(t){return e.resolve=t})),this.i.set(t,e)),e.promise},window.CustomElementRegistry.prototype.m=function(t,i,e){var s=this.h.get(i);s||this.h.set(i,s=new Set),e?s.add(t):s.delete(t)},window.HTMLElement=function(){var t=a;if(t)return a=void 0,t;var i=b.get(this.constructor);if(!i)throw new TypeError("Illegal constructor (custom element class must be registered with global customElements registry to be newable)");return t=Reflect.construct(c,[],i.s),Object.setPrototypeOf(t,this.constructor.prototype),w.set(t,i),t},window.HTMLElement.prototype=c.prototype;var y=function(t){function i(){var i=Reflect.construct(c,[],this.constructor);Object.setPrototypeOf(i,HTMLElement.prototype);t:{var e=i.getRootNode();if(!(e===document||e instanceof ShadowRoot)){if((e=E[E.length-1])instanceof CustomElementRegistry){var s=e;break t}(e=e.getRootNode())===document||e instanceof ShadowRoot||(e=(null==(s=m.get(e))?void 0:s.getRootNode())||document)}s=e.customElements}return(e=(s=s||window.customElements).j(t))?$(i,e):p.set(i,s),i}return o.Object.defineProperty(i,"formAssociated",{configurable:!0,enumerable:!0,get:function(){return!0}}),i.prototype.connectedCallback=function(){var i=w.get(this);i?i.connectedCallback&&i.connectedCallback.apply(this,arguments):p.get(this).m(this,t,!0)},i.prototype.disconnectedCallback=function(){var i=w.get(this);i?i.disconnectedCallback&&i.disconnectedCallback.apply(this,arguments):p.get(this).m(this,t,!1)},i.prototype.adoptedCallback=function(){var t,i;null==(t=w.get(this))||null==(i=t.adoptedCallback)||i.apply(this,arguments)},i.prototype.formAssociatedCallback=function(){var t,i=w.get(this);i&&i.formAssociated&&(null==i||null==(t=i.formAssociatedCallback)||t.apply(this,arguments))},i.prototype.formDisabledCallback=function(){var t,i=w.get(this);null!=i&&i.formAssociated&&(null==i||null==(t=i.formDisabledCallback)||t.apply(this,arguments))},i.prototype.formResetCallback=function(){var t,i=w.get(this);null!=i&&i.formAssociated&&(null==i||null==(t=i.formResetCallback)||t.apply(this,arguments))},i.prototype.formStateRestoreCallback=function(){var t,i=w.get(this);null!=i&&i.formAssociated&&(null==i||null==(t=i.formStateRestoreCallback)||t.apply(this,arguments))},i},g=function(t,i,e){if(0!==i.size&&void 0!==e){var s=t.prototype.setAttribute;s&&(t.prototype.setAttribute=function(t,n){if(t=t.toLowerCase(),i.has(t)){var o=this.getAttribute(t);s.call(this,t,n),e.call(this,t,o,n)}else s.call(this,t,n)});var n=t.prototype.removeAttribute;n&&(t.prototype.removeAttribute=function(t){if(t=t.toLowerCase(),i.has(t)){var s=this.getAttribute(t);n.call(this,t),e.call(this,t,s,null)}else n.call(this,t)})}},S=function(t){var i=Object.getPrototypeOf(t);if(i!==window.HTMLElement)return i===c?Object.setPrototypeOf(t,window.HTMLElement):S(i)},$=function(t,i,e){e=void 0!==e&&e,Object.setPrototypeOf(t,i.g.prototype),w.set(t,i),a=t;try{new i.g}catch(t){S(i.g),new i.g}i.observedAttributes.forEach((function(e){t.hasAttribute(e)&&i.attributeChangedCallback.call(t,e,null,t.getAttribute(e))})),e&&i.connectedCallback&&t.isConnected&&i.connectedCallback.call(t)},O=Element.prototype.attachShadow;Element.prototype.attachShadow=function(t){var i=O.apply(this,arguments);return t.customElements&&(i.customElements=t.customElements),i};var E=[document],T=function(t,i,e){var s=(e?Object.getPrototypeOf(e):t.prototype)[i];t.prototype[i]=function(){E.push(this);var t=s.apply(e||this,arguments);return void 0!==t&&m.set(t,this),E.pop(),t}};T(ShadowRoot,"createElement",document),T(ShadowRoot,"importNode",document),T(Element,"insertAdjacentHTML");var j=function(t){var i=Object.getOwnPropertyDescriptor(t.prototype,"innerHTML");Object.defineProperty(t.prototype,"innerHTML",Object.assign({},i,{set:function(t){E.push(this),i.set.call(this,t),E.pop()}}))};if(j(Element),j(ShadowRoot),Object.defineProperty(window,"customElements",{value:new CustomElementRegistry,configurable:!0,writable:!0}),window.ElementInternals&&window.ElementInternals.prototype.setFormValue){var C=new WeakMap,k=HTMLElement.prototype.attachInternals;HTMLElement.prototype.attachInternals=function(t){for(var i=[],s=0;s<arguments.length;++s)i[s]=arguments[s];return i=k.call.apply(k,[this].concat(e(i))),C.set(i,this),i},["setFormValue","setValidity","checkValidity","reportValidity"].forEach((function(t){var i=window.ElementInternals.prototype,s=i[t];i[t]=function(t){for(var i=[],n=0;n<arguments.length;++n)i[n]=arguments[n];if(n=C.get(this),!0!==w.get(n).formAssociated)throw new DOMException("Failed to execute "+s+" on 'ElementInternals': The target element is not a form-associated custom element.");null==s||s.call.apply(s,[this].concat(e(i)))}}));var A=function(t){var i=r(Array,[].concat(e(t)),this.constructor);return i.h=t,i},M=A,x=Array;if(M.prototype=s(x.prototype),M.prototype.constructor=M,u)u(M,x);else for(var R in x)if("prototype"!=R)if(Object.defineProperties){var _=Object.getOwnPropertyDescriptor(x,R);_&&Object.defineProperty(M,R,_)}else M[R]=x[R];M.u=x.prototype,o.Object.defineProperty(A.prototype,"value",{configurable:!0,enumerable:!0,get:function(){var t;return(null==(t=this.h.find((function(t){return!0===t.checked})))?void 0:t.value)||""}});var I=function(t){var i=this,e=new Map;t.forEach((function(t,s){var n=t.getAttribute("name"),o=e.get(n)||[];i[+s]=t,o.push(t),e.set(n,o)})),this.length=t.length,e.forEach((function(t,e){t&&(i[e]=1===t.length?t[0]:new A(t))}))};I.prototype.namedItem=function(t){return this[t]};var U=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"elements");Object.defineProperty(HTMLFormElement.prototype,"elements",{get:function(){for(var t=U.get.call(this,[]),e=[],s=(t=i(t)).next();!s.done;s=t.next()){s=s.value;var n=w.get(s);n&&!0!==n.formAssociated||e.push(s)}return new I(e)}})}}}).call(self);try{window.customElements.define("custom-element",null)}catch(mt){const t=window.customElements.define;window.customElements.define=(i,e,s)=>{try{t.bind(window.customElements)(i,e,s)}catch(t){console.warn(i,e,s,t)}}}class bt extends(
63
+ /**
64
+ * @license
65
+ * Copyright 2021 Google LLC
66
+ * SPDX-License-Identifier: BSD-3-Clause
67
+ */
68
+ function(t){return class extends t{createRenderRoot(){const t=this.constructor,{registry:i,elementDefinitions:e,shadowRootOptions:s}=t;e&&!i&&(t.registry=new CustomElementRegistry,Object.entries(e).forEach((([i,e])=>t.registry.define(i,e))));const n=this.renderOptions.creationScope=this.attachShadow({...s,customElements:t.registry});return r(n,this.constructor.elementStyles),n}}}(tt)){constructor(){super(),this.constructorName=this.constructor.name,this.proto=this.constructor.prototype}getStyles(){return[]}getTemplate(){return null}render(){let t=this.getStyles();return Array.isArray(t)||(t=[t]),I`${t.map((t=>I`<style>${t}</style>`))} ${this.getTemplate()}`}adoptedCallback(){Object.getPrototypeOf(this)!==this.constructorName&&Object.setPrototypeOf(this,this.proto)}updated(t){super.updated(t),setTimeout((()=>this.contentAvailableCallback(t)),0)}contentAvailableCallback(t){}}
69
+ /**
70
+ * @license
71
+ * Copyright 2017 Google LLC
72
+ * SPDX-License-Identifier: BSD-3-Clause
73
+ */class mt extends ht{constructor(t){if(super(t),this.it=L,t.type!==rt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===L||null==t)return this.vt=void 0,this.it=t;if(t===U)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this.vt;this.it=t;const i=[t];return i.raw=i,this.vt={_$litType$:this.constructor.resultType,strings:i,values:[]}}}mt.directiveName="unsafeHTML",mt.resultType=1;const yt=lt(mt);var gt,St,$t;const Ot=navigator.vendor&&!!navigator.vendor.match(/apple/i)||"[object SafariRemoteNotification]"===(null!==($t=null===(St=null===(gt=window.safari)||void 0===gt?void 0:gt.pushNotification)||void 0===St?void 0:St.toString())&&void 0!==$t?$t:"");var Et=function(t,i,e,s){for(var n,o=arguments.length,r=o<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s,l=t.length-1;l>=0;l--)(n=t[l])&&(r=(o<3?n(r):o>3?n(i,e,r):n(i,e))||r);return o>3&&r&&Object.defineProperty(i,e,r),r};class Tt extends CustomEvent{constructor(t,i){super("visible-items-change",{detail:{visibleIndexes:t,visibleItems:i}})}}var jt;t.FtInfiniteScroll=class extends bt{constructor(){super(...arguments),this.items=[],this.renderItem=()=>I``,this.internalScrollToIndex=0,this.visibleItems=[],this.scrolledToTarget=!1,this.onVisibilityChange=t=>{const i=t.filter((t=>t.isIntersecting)).map((t=>+t.target.attributes.getNamedItem("data-item-index").value)).filter((t=>!this.visibleItems.includes(t))),e=t.filter((t=>!t.isIntersecting)).map((t=>+t.target.attributes.getNamedItem("data-item-index").value)).filter((t=>this.visibleItems.includes(t))),s=[...this.visibleItems].filter((t=>!e.includes(t)));this.visibleItems=[...i,...s].sort(((t,i)=>t-i))},this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange),this.onResize=t=>{let i=0;for(const e of t){let t=e.target.parentElement.clientHeight,s=e.contentRect.height;e.target.classList.contains("visible")&&(e.target.parentElement.style.height=s+"px",i+=e.target.parentElement.offsetTop<this.scrollable.scrollTop?t-s:0)}Ot&&(this.scrollable.scrollTop-=i)},this.resizeObserver=new ResizeObserver(this.onResize),this.onMutation=()=>{[...this.scrollable.children].forEach((t=>{this.intersectionObserver.observe(t),this.resizeObserver.observe(t.children.item(0))}))},this.mutationObserver=new MutationObserver(this.onMutation)}getStyles(){return o`.scrollable{height:100%;overflow-y:auto;position:relative;padding:var(--ft-infinite-scroll-padding,0);outline:0}.item-container{height:100%}.resizable:not(.visible){width:0}.resizable:not(.visible)>*{display:none}`}getTemplate(){return I`<div class="scrollable" tabindex="-1">${pt(this.items,((t,i)=>this.renderItemContainer(t,i)))}</div>`}renderItemContainer(t,i){const e=this.scrolledToTarget&&(this.visibleItems.includes(i)||this.visibleItems[0]===i+1||(s=this.visibleItems)[s.length-1]===i-1);var s;return I`<div id="item-${i}" class="item-container" data-item-index="${i}"><div class="resizable ${e?"visible":""}">${e?(()=>{const e=this.renderItem(t,i);return"string"==typeof e?I`${yt(e)}`:e})():null}</div></div>`}resetScroll(){var t;this.intersectionObserver.disconnect(),this.resizeObserver.disconnect(),this.visibleItems=[],this.internalScrollToIndex=null!==(t=this.scrollToIndex)&&void 0!==t?t:this.scrollToItem?this.items.indexOf(this.scrollToItem):0,(this.internalScrollToIndex<0||this.internalScrollToIndex>=this.items.length)&&(this.internalScrollToIndex=0),this.scrolledToTarget=!1}appendItems(...t){this.items=[...this.items,...t]}prependItems(...t){this.items=[...t,...this.items]}connectedCallback(){super.connectedCallback(),setTimeout((()=>{this.intersectionObserver.disconnect(),this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange,{root:this.scrollable}),this.mutationObserver.disconnect(),this.mutationObserver.observe(this.scrollable,{childList:!0})}),0)}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("scrollToItem")||t.has("scrollToIndex"))&&this.resetScroll()}updated(t){super.updated(t),this.scrolledToTarget||setTimeout((()=>{var t;if(0===this.internalScrollToIndex)this.scrollable.scrollTop=0;else{let i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(`#item-${this.internalScrollToIndex}`);this.scrollable.scrollTop=i.offsetTop}this.onMutation(),setTimeout((()=>{this.scrolledToTarget=!0}),50)}),50),(t.has("visibleItems")||t.has("items"))&&this.dispatchEvent(new Tt(this.visibleItems,this.visibleItems.map((t=>this.items[t]))))}},Et([st({type:Array})],t.FtInfiniteScroll.prototype,"items",void 0),Et([st({attribute:!1})],t.FtInfiniteScroll.prototype,"renderItem",void 0),Et([st({type:Object})],t.FtInfiniteScroll.prototype,"scrollToItem",void 0),Et([st({type:Number})],t.FtInfiniteScroll.prototype,"scrollToIndex",void 0),Et([nt()],t.FtInfiniteScroll.prototype,"visibleItems",void 0),Et([
74
+ /**
75
+ * @license
76
+ * Copyright 2017 Google LLC
77
+ * SPDX-License-Identifier: BSD-3-Clause
78
+ */
79
+ function(t,i){return(({finisher:t,descriptor:i})=>(e,s)=>{var n;if(void 0===s){const s=null!==(n=e.originalKey)&&void 0!==n?n:e.key,o=null!=i?{kind:"method",placement:"prototype",key:s,descriptor:i(e.key)}:{...e,key:s};return null!=t&&(o.finisher=function(i){t(i,s)}),o}{const n=e.constructor;void 0!==i&&Object.defineProperty(e,s,i(s)),null==t||t(n,s)}})({descriptor:e=>{const s={get(){var i,e;return null!==(e=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(t))&&void 0!==e?e:null},enumerable:!0,configurable:!0};if(i){const i="symbol"==typeof e?Symbol():"__"+e;s.get=function(){var e,s;return void 0===this[i]&&(this[i]=null!==(s=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t))&&void 0!==s?s:null),this[i]}}return s}})}(".scrollable")],t.FtInfiniteScroll.prototype,"scrollable",void 0),Et([nt()],t.FtInfiniteScroll.prototype,"scrolledToTarget",void 0),t.FtInfiniteScroll=Et([(jt="ft-infinite-scroll",t=>{window.customElements.get(jt)||window.customElements.define(jt,t)})],t.FtInfiniteScroll),t.VisibleItemsChangeEvent=Tt,Object.defineProperty(t,"t",{value:!0})}({});
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@fluid-topics/ft-infinite-scroll",
3
+ "version": "0.0.88",
4
+ "description": "An infinite scroller.",
5
+ "keywords": [
6
+ "Lit"
7
+ ],
8
+ "author": "Fluid Topics <devtopics@antidot.net>",
9
+ "license": "ISC",
10
+ "main": "build/ft-infinite-scroll.js",
11
+ "web": "build/ft-infinite-scroll.min.js",
12
+ "typings": "build/ft-infinite-scroll",
13
+ "files": [
14
+ "build/*.ts",
15
+ "build/*.js"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
+ },
21
+ "dependencies": {
22
+ "@fluid-topics/ft-wc-utils": "^0.0.88",
23
+ "lit": "^2.0.2"
24
+ },
25
+ "gitHead": "220e53dba55dfa1de1560abbc30067555f72198c"
26
+ }