/**
 * Copyright Aquera Inc 2025
 *
 * This source code is licensed under the BSD-3-Clause license found in the
 * LICENSE file in the root directory of this source tree.
 */
import { __decorate } from "tslib";
import { html } from 'lit';
import { customElement, property, state, query } from 'lit/decorators.js';
import { styles } from './nile-inline-sidebar-item-body.css';
import NileElement from '../internal/nile-element';
/**
 * Nile inline-sidebar-item-body component.
 *
 * @tag nile-inline-sidebar-item-body
 *
 */
let NileInlineSidebarItemBody = class NileInlineSidebarItemBody extends NileElement {
    constructor() {
        super(...arguments);
        /** Maximum number of visible lines before text is truncated with an ellipsis. */
        this.lines = 2;
        this.content = '';
        this.showTooltip = false;
        this.isTruncated = false;
        this.disabled = false;
        this.active = false;
        /* #endregion */
    }
    /**
     * The styles for nile-inline-sidebar-item-body
     * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
     */
    static get styles() {
        return [styles];
    }
    /* #endregion */
    /* #region Methods */
    firstUpdated() {
        this.checkTruncation();
        if (this.bodyContentEl) {
            this.resizeObserver = new ResizeObserver(() => this.checkTruncation());
            this.resizeObserver.observe(this.bodyContentEl);
        }
    }
    disconnectedCallback() {
        super.disconnectedCallback();
        this.resizeObserver?.disconnect();
    }
    checkTruncation() {
        if (this.bodyContentEl) {
            const truncated = this.bodyContentEl.scrollHeight > this.bodyContentEl.clientHeight;
            if (truncated !== this.isTruncated) {
                this.isTruncated = truncated;
            }
        }
    }
    get contentTemplate() {
        const body = html `<div class="body-text" part="body-text">${this.content}</div>`;
        return this.isTruncated && this.showTooltip
            ? html `<nile-lite-tooltip content=${this.content} hoist>${body}</nile-lite-tooltip>`
            : body;
    }
    /**
     * Render method
     * @slot This is a slot test
     */
    render() {
        return html `
		<div class="item-body" part="item-body">
		<div class="prefix-content" part="prefix-content">
			<slot name="prefix"></slot>
		</div>
		<div class="body-content" part="body-content" style="--line-clamp: ${this.lines ? this.lines : 2}">
			${this.content ? this.contentTemplate : html `<div class="body-text" part="body-text"><slot></slot></div>`}
		</div>
		<div class="suffix-content" part="suffix-content">
			<slot name="suffix"></slot>
		</div>
		</div>
			`;
    }
};
__decorate([
    property({ type: Number, reflect: true })
], NileInlineSidebarItemBody.prototype, "lines", void 0);
__decorate([
    property({ type: String, reflect: true })
], NileInlineSidebarItemBody.prototype, "content", void 0);
__decorate([
    property({ type: Boolean, reflect: true })
], NileInlineSidebarItemBody.prototype, "showTooltip", void 0);
__decorate([
    state()
], NileInlineSidebarItemBody.prototype, "isTruncated", void 0);
__decorate([
    query('.body-content')
], NileInlineSidebarItemBody.prototype, "bodyContentEl", void 0);
__decorate([
    property({ type: Boolean, reflect: true, attribute: true })
], NileInlineSidebarItemBody.prototype, "disabled", void 0);
__decorate([
    property({ type: Boolean, reflect: true, attribute: true })
], NileInlineSidebarItemBody.prototype, "active", void 0);
NileInlineSidebarItemBody = __decorate([
    customElement('nile-inline-sidebar-item-body')
], NileInlineSidebarItemBody);
export { NileInlineSidebarItemBody };
export default NileInlineSidebarItemBody;
//# sourceMappingURL=nile-inline-sidebar-item-body.js.map