import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { _ as __decorate, a as __metadata } from './tslib.es6.js';
import { B as BEM } from './bem.js';
import { b as balBrowser } from './browser.js';
import { b as balBreakpoints } from './breakpoints.subject.js';
import { L as ListenToBreakpoints } from './breakpoints.decorator.js';

const PopoverContent = /*@__PURE__*/ proxyCustomElement(class PopoverContent extends HTMLElement {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.isTouch = balBreakpoints.isTouch; // need this part to improve a none side effect import
        /**
         * If `true` the popover has no padding space.
         */
        this.spaceless = false;
        /**
         * Limit the height of the popover content. Pass the amount of pixel.
         */
        this.scrollable = 0;
        /**
         * Define the max width of the popover content.
         */
        this.contentWidth = 0;
        /**
         * Define the min width of the popover content.
         */
        this.contentMinWidth = 0;
        /**
         * Defines background color of the content.
         */
        this.color = 'white';
        /**
         * If `true` the content has a min width of 100%.
         */
        this.expanded = false;
        /**
         * Defines border-radius of popover content.
         */
        this.radius = 'normal';
        /**
         * If `true` the popover does not have the shadow
         */
        this.noShadow = false;
        /**
         * If `true` the content will have a divider line on top
         */
        this.mobileTop = false;
        this.contentHeightOnTop = 0;
    }
    breakpointListener(_breakpoints) {
        if (balBrowser.hasWindow) {
            this.contentHeightOnTop = window.innerHeight - 64;
        }
    }
    get innerStyle() {
        let scrollable = {};
        if (this.scrollable > 0) {
            scrollable = {
                'max-height': `${this.scrollable}px`,
                'overflow': 'auto',
            };
        }
        return Object.assign({}, scrollable);
    }
    get contentStyle() {
        let contentWidth = {};
        let contentMinWidth = {};
        const contentHeightOnTopNav = {
            '--bal-popover-content-height-top-nav': `${this.contentHeightOnTop / 16}rem`,
        };
        if (this.contentWidth > 0) {
            contentWidth = { 'max-width': `${this.contentWidth}px` };
        }
        if (this.contentMinWidth > 0) {
            contentMinWidth = { 'min-width': `${this.contentMinWidth}px` };
        }
        return Object.assign(Object.assign(Object.assign({}, contentWidth), contentMinWidth), contentHeightOnTopNav);
    }
    componentWillLoad() {
        if (balBrowser.hasWindow) {
            this.contentHeightOnTop = window.innerHeight - 64;
        }
    }
    render() {
        const block = BEM.block('popover').element('content');
        return (h(Host, { key: 'bc08fb0e5736f9393c5396af4a84f1127b6e4c4e', class: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, block.class()), block.modifier('expanded').class(this.expanded)), block.modifier('spaceless').class(this.spaceless)), block.modifier('no-shadow').class(this.noShadow)), block.modifier(`radius-${this.radius}`).class()), block.modifier(`color-${this.color}`).class()), block.modifier('on-top').class(this.mobileTop)), "data-testid": "bal-popover-content", role: "tooltip", style: this.contentStyle }, h("div", { key: 'f49ffa520c2e1cc95942973939eeff059900a9bc', class: Object.assign({}, block.element('inner').class()), style: this.innerStyle }, h("slot", { key: '3394b3dd89ce64a0d379e66b1ffb169e9f0401c4' })), h("div", { key: '5f75d67a77ae49667c3863b738bdc03d1dcb8121', class: Object.assign({}, block.element('arrow').class()), "data-popper-arrow": true })));
    }
    get el() { return this; }
}, [260, "bal-popover-content", {
        "spaceless": [4],
        "scrollable": [2],
        "contentWidth": [2, "content-width"],
        "contentMinWidth": [2, "content-min-width"],
        "color": [1],
        "expanded": [4],
        "radius": [1],
        "noShadow": [4, "no-shadow"],
        "mobileTop": [4, "mobile-top"],
        "contentHeightOnTop": [32]
    }]);
__decorate([
    ListenToBreakpoints(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], PopoverContent.prototype, "breakpointListener", null);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["bal-popover-content"];
    components.forEach(tagName => { switch (tagName) {
        case "bal-popover-content":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, PopoverContent);
            }
            break;
    } });
}

export { PopoverContent as P, defineCustomElement as d };
