/**
 * Copyright IBM Corp. 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

import "../../globals/settings.js";
import { carbonElement } from "../../globals/decorators/carbon-element.js";
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.126.0/helpers/decorate.js";
import page_header_default from "./page-header.scss.js";
import { LitElement, html } from "lit";
import { property, state } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
//#region src/components/page-header/page-header-content.ts
/**
* Copyright IBM Corp. 2025, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Page header content.
* @element cds-page-header-content
*/
let CDSPageHeaderContent = class CDSPageHeaderContent extends LitElement {
	constructor(..._args) {
		super(..._args);
		this._hasContextualActions = false;
		this.title = "";
		this._hasEllipsisApplied = false;
		this.withinGrid = false;
	}
	/**
	* Handles `slotchange` event.
	*/
	_handleSlotChange({ target }) {
		this._hasContextualActions = Boolean(target.assignedNodes());
		if (this._hasContextualActions) this.setAttribute("contextual-actions", "true");
		else this.removeAttribute("contextual-actions");
		this.requestUpdate();
	}
	updated() {
		const textContainer = this.shadowRoot?.querySelector(`.cds--page-header__content__title`);
		if (!textContainer || this._hasEllipsisApplied === true) return;
		this._hasEllipsisApplied = textContainer.scrollHeight > textContainer.clientHeight;
	}
	render() {
		const { title, withinGrid, _hasEllipsisApplied: hasEllipsisApplied, _handleSlotChange: handleSlotChange } = this;
		return html` <div class="${classMap({
			[`cds--css-grid`]: !withinGrid,
			[`cds--subgrid cds--subgrid--wide`]: withinGrid
		})}">
      <div
        class="${"cds"}--sm:col-span-4 ${"cds"}--md:col-span-8 ${"cds"}--lg:col-span-16 ${"cds"}--css-grid-column">
        <div class="${"cds"}--page-header__content__title-wrapper">
          <div class="${"cds"}--page-header__content__start">
            <div class="${"cds"}--page-header__content__title-container">
              <slot name="icon"></slot>
              ${hasEllipsisApplied ? html`
                    <cds-definition-tooltip>
                      <span slot="definition">${title}</span>
                      <h4 class="${"cds"}--page-header__content__title">
                        ${title}
                      </h4>
                    </cds-definition-tooltip>
                  ` : html`
                    <h4 class="${"cds"}--page-header__content__title">
                      ${title}
                    </h4>
                  `}
            </div>
            <slot
              name="contextual-actions"
              @slotchange=${handleSlotChange}></slot>
          </div>
          <div class="${"cds"}--page-header__content__page-actions">
            <slot name="page-actions"></slot>
          </div>
        </div>
        <slot></slot>
      </div>
    </div>`;
	}
	static {
		this.styles = page_header_default;
	}
};
__decorate([property()], CDSPageHeaderContent.prototype, "title", void 0);
__decorate([state()], CDSPageHeaderContent.prototype, "_hasEllipsisApplied", void 0);
__decorate([property({
	attribute: "within-grid",
	type: Boolean
})], CDSPageHeaderContent.prototype, "withinGrid", void 0);
CDSPageHeaderContent = __decorate([carbonElement(`cds-page-header-content`)], CDSPageHeaderContent);
var page_header_content_default = CDSPageHeaderContent;
//#endregion
export { page_header_content_default as default };

//# sourceMappingURL=page-header-content.js.map