'use strict';

var index = require('./index-BUvWX8u2.js');
var utils = require('./utils-7jx8T2mW.js');
var truncationTooltip = require('./truncation-tooltip-CVzAha5B.js');
require('./floating-ui.dom-BZk7Blsu.js');

const pdsTextCss = ":host{display:inline}:host([decoration=underline-dotted])>*{-webkit-text-decoration-color:var(--pine-color-text-tertiary);text-decoration-color:var(--pine-color-text-tertiary);-webkit-text-decoration-line:underline;text-decoration-line:underline;-webkit-text-decoration-style:dotted;text-decoration-style:dotted;text-decoration-thickness:12%;text-underline-offset:0.3rem;text-underline-position:under}:host([decoration=strikethrough])>*{text-decoration:line-through}h1{font:var(--pine-typography-heading-1);letter-spacing:var(--pine-letter-spacing-heading-1)}h2{font:var(--pine-typography-heading-2);letter-spacing:var(--pine-letter-spacing-heading-2)}h3{font:var(--pine-typography-heading-3);letter-spacing:var(--pine-letter-spacing-heading-3)}h4{font:var(--pine-typography-heading-4);letter-spacing:var(--pine-letter-spacing-heading-4)}h5{font:var(--pine-typography-heading-5);letter-spacing:var(--pine-letter-spacing-heading-5)}h6{font:var(--pine-typography-heading-6);letter-spacing:var(--pine-letter-spacing-heading-6)}code,em,p,pre,strong{font:var(--pine-typography-body);letter-spacing:var(--pine-letter-spacing)}code,pre{font-family:monospace;letter-spacing:0;line-height:1}em{font-style:normal}strong{font-weight:bolder}:host([truncate])>*{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host([italic])>*{font-style:italic}.pds-text{color:var(--color, var(--pine-color-text));margin:var(--pine-dimension-none)}.pds-text--size-2xl{font-size:var(--pine-font-size-body-2xl)}.pds-text--size-xl{font-size:var(--pine-font-size-body-xl)}.pds-text--size-lg{font-size:var(--pine-font-size-body-lg)}.pds-text--size-md{font-size:var(--pine-font-size-body-md)}.pds-text--size-sm{font-size:var(--pine-font-size-body-sm)}.pds-text--size-xs{font-size:var(--pine-font-size-body-xs)}.pds-text--size-2xs{font-size:var(--pine-font-size-body-2xs)}.pds-text--size-h1{font-size:var(--pine-font-size-heading-1)}.pds-text--size-h2{font-size:var(--pine-font-size-heading-2)}.pds-text--size-h3{font-size:var(--pine-font-size-heading-3)}.pds-text--size-h4{font-size:var(--pine-font-size-heading-4)}.pds-text--size-h5{font-size:var(--pine-font-size-heading-5)}.pds-text--size-h6{font-size:var(--pine-font-size-heading-6)}.pds-text--weight-extra-light{font-weight:var(--pine-font-weight-extra-light)}.pds-text--weight-light{font-weight:var(--pine-font-weight-light)}.pds-text--weight-regular{font-weight:var(--pine-font-weight-regular)}.pds-text--weight-medium{font-weight:var(--pine-font-weight-medium)}.pds-text--weight-semibold{font-weight:var(--pine-font-weight-semi-bold)}.pds-text--weight-bold{font-weight:var(--pine-font-weight-bold)}.pds-text--gutter-2xl{-webkit-margin-after:var(--pine-dimension-2xl);margin-block-end:var(--pine-dimension-2xl)}.pds-text--gutter-xl{-webkit-margin-after:var(--pine-dimension-xl);margin-block-end:var(--pine-dimension-xl)}.pds-text--gutter-lg{-webkit-margin-after:var(--pine-dimension-lg);margin-block-end:var(--pine-dimension-lg)}.pds-text--gutter-md{-webkit-margin-after:var(--pine-dimension-md);margin-block-end:var(--pine-dimension-md)}.pds-text--gutter-sm{-webkit-margin-after:var(--pine-dimension-sm);margin-block-end:var(--pine-dimension-sm)}.pds-text--gutter-xs{-webkit-margin-after:var(--pine-dimension-xs);margin-block-end:var(--pine-dimension-xs)}.pds-text--gutter-2xs{-webkit-margin-after:var(--pine-dimension-2xs);margin-block-end:var(--pine-dimension-2xs)}.pds-text--align-start{text-align:start}.pds-text--align-center{text-align:center}.pds-text--align-end{text-align:end}.pds-text--align-justify{text-align:justify}";

const PdsText = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.truncationCleanup = null;
        /**
         * Determines what semantic text tag to render.
         */
        this.tag = 'p';
    }
    handleTruncateChange(newValue) {
        if (newValue) {
            this.initTruncationTooltip();
        }
        else {
            this.destroyTruncationTooltip();
        }
    }
    componentDidLoad() {
        if (this.truncate) {
            this.initTruncationTooltip();
        }
    }
    disconnectedCallback() {
        this.destroyTruncationTooltip();
    }
    initTruncationTooltip() {
        // Clean up any existing tooltip before setting up a new one
        this.destroyTruncationTooltip();
        if (this.contentEl) {
            this.truncationCleanup = truncationTooltip.setupTruncationTooltip({
                hostEl: this.el,
                contentEl: this.contentEl,
                getTooltipText: () => this.el.textContent || '',
            });
        }
    }
    destroyTruncationTooltip() {
        if (this.truncationCleanup) {
            this.truncationCleanup();
            this.truncationCleanup = null;
        }
    }
    render() {
        const Tag = this.tag;
        const typeClasses = `
      pds-text
      ${this.align !== undefined && this.align.trim() !== ''
            ? `pds-text--align-${this.align}`
            : ''}
      ${this.gutter !== undefined && this.gutter.trim() !== ''
            ? `pds-text--gutter-${this.gutter}`
            : ''}
      ${this.size !== undefined && this.size.trim() !== ''
            ? `pds-text--size-${this.size}`
            : ''}
      ${this.weight !== undefined && this.weight.trim() !== ''
            ? `pds-text--weight-${this.weight}`
            : ''}
      ${this.decoration !== undefined && this.decoration.trim() !== ''
            ? `pds-text--decoration-${this.decoration}`
            : ''}
    `;
        return (index.h(Tag, { key: '1d4952d18c09b26a5f2c7f64574be86c90cca553', ref: (el) => (this.contentEl = el), style: this.color && utils.setColor(this.color), class: typeClasses, part: "content", tabIndex: this.truncate ? 0 : undefined }, index.h("slot", { key: '62a5caff5274601b79f35025c9382e2430118cdc' })));
    }
    get el() { return index.getElement(this); }
    static get watchers() { return {
        "truncate": ["handleTruncateChange"]
    }; }
};
PdsText.style = pdsTextCss;

exports.pds_text = PdsText;
//# sourceMappingURL=pds-text.entry.cjs.js.map
