import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
import { a as copy } from './index2.js';
import { d as defineCustomElement$3 } from './pds-button2.js';
import { d as defineCustomElement$2 } from './pds-icon2.js';

const baseCss = ":where(*:not(slot),*:not(slot)::before,*:not(slot)::after){-webkit-box-sizing:border-box;box-sizing:border-box}:where(*:not(slot)){margin:0}:where(img,picture,video,canvas,svg){display:block;max-width:100%}:where(input,button,textarea,select){font:inherit}:where(p,h1,h2,h3,h4,h5,h6){overflow-wrap:break-word}:where(a:not([href]):not([class])){color:currentColor;text-decoration:none}:where(a:not([href]):not([class]):hover){color:currentColor;text-decoration:none}:where(ul[role=list],ol[role=list]){list-style:none}:where(table){border-collapse:collapse;border-spacing:0}:where(*:not(slot)){font:var(--pine-typography-body-md-default);letter-spacing:var(--pine-letter-spacing-body-md)}:where(h1,h2,h3,h4,h5,h6){font-family:var(--pine-font-family-heading);color:var(--pine-color-grey-950)}:where(h1){font:var(--pine-typography-heading-h1);letter-spacing:var(--pine-letter-spacing-heading-h1)}:where(h2){font:var(--pine-typography-heading-h2);letter-spacing:var(--pine-letter-spacing-heading-h2)}:where(h3){font:var(--pine-typography-heading-h3);letter-spacing:var(--pine-letter-spacing-heading-h3)}:where(h4){font:var(--pine-typography-heading-h4);letter-spacing:var(--pine-letter-spacing-heading-h4)}:where(h5){font:var(--pine-typography-heading-h5);letter-spacing:var(--pine-letter-spacing-heading-h5)}:where(h6){font:var(--pine-typography-heading-h6);letter-spacing:var(--pine-letter-spacing-heading-h6)}:where(div,label,p,span){color:var(--pine-color-text-default)}:where(code,kbd,pre,samp){font-family:monospace}:where([role=button]){cursor:pointer}:where(:focus){outline:0}:where(:focus-visible){outline:var(--pine-border-width-thick) solid var(--pine-color-purple-500)}:where([hidden]){display:none !important}";
const PdsCopytextStyle0 = baseCss;

const pdsCopytextCss = ":host(.pds-copytext){--border-interactive-default:var(--pine-border-width-thin) solid var(--pine-color-grey-300);--border-interactive-hover:var(--pine-border-width-thin) solid var(--pine-color-grey-400);--border-radius-default:var(--pine-border-radius-circle);--border-width-default:var(--pine-border-width-none);--box-shadow-focus:0 0 0 1px #ffffff, 0 0 0 3px var(--pine-color-purple-300);--color-background-default:var(--pine-color-white);--color-border-interactive-hover:var(--pine-color-grey-400);--color-text-hover:var(--pine-color-grey-900);--copytext-color-background-hover:var(--pine-color-grey-200);--font-size-default:var(--pine-font-size-100);--font-weight-default:var(--pine-font-weight-body-medium);--spacing-bordered-margin-inline-end:var(--pine-spacing-200);--spacing-bordered-padding-block:var(--pine-spacing-100);--spacing-bordered-padding-inline:var(--pine-spacing-200);--spacing-margin-inline-end:var(--pine-spacing-100);--spacing-padding-block:var(--pine-spacing-050);--spacing-padding-inline:var(--pine-spacing-100);--spacing-padding-none:var(--pine-spacing-0);--typography-default:var(--pine-font-weight-body-medium) var(--pine-font-size-body-md)/var(--pine-line-height-body) var(--pine-font-family-heading)}:host(.pds-copytext) pds-button{-ms-flex-align:center;align-items:center;background:var(--color-background-default);border:var(--border-width-default);border-radius:var(--border-radius-default);display:-ms-inline-flexbox;display:inline-flex;font:var(--typography-default);max-width:100%;padding:var(--spacing-padding-block) var(--spacing-padding-inline)}:host(.pds-copytext) pds-button::part(button){-webkit-padding-end:calc(var(--spacing-padding-inline) / 2);padding-inline-end:calc(var(--spacing-padding-inline) / 2)}:host(.pds-copytext) pds-button::part(button):hover{background-color:var(--copytext-color-background-hover);color:var(--color-text-hover)}:host(.pds-copytext) pds-button span{font-weight:var(--font-weight-default);-webkit-margin-end:var(--spacing-margin-inline-end);margin-inline-end:var(--spacing-margin-inline-end);white-space:nowrap}:host(.pds-copytext) pds-button :nth-child(2){-ms-flex-negative:0;flex-shrink:0}:host(.pds-copytext):host(.pds-copytext--bordered){border:var(--border-width-default);padding:var(--spacing-padding-none)}:host(.pds-copytext):host(.pds-copytext--bordered) pds-button{padding:var(--spacing-padding-none)}:host(.pds-copytext):host(.pds-copytext--bordered) pds-button:hover{background:none}:host(.pds-copytext):host(.pds-copytext--bordered) span{border:var(--border-interactive-default);border-radius:var(--border-radius-default);-webkit-margin-end:var(--spacing-bordered-margin-inline-end);margin-inline-end:var(--spacing-bordered-margin-inline-end);padding-block:var(--spacing-bordered-padding-block);padding-inline:var(--spacing-bordered-padding-inline)}:host(.pds-copytext):host(.pds-copytext--bordered) :hover span{border:var(--border-interactive-hover)}:host(.pds-copytext):host(.pds-copytext--full-width){display:-ms-flexbox;display:flex;width:100%}:host(.pds-copytext):host(.pds-copytext--full-width) pds-button{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;width:100%}:host(.pds-copytext):host(.pds-copytext--full-width) pds-button span{text-align:left;width:100%}:host(.pds-copytext):host(.pds-copytext--truncated) pds-button{display:-ms-flexbox;display:flex;width:100%}:host(.pds-copytext):host(.pds-copytext--truncated) pds-button span{overflow:hidden;text-align:left;text-overflow:ellipsis;width:100%}";
const PdsCopytextStyle1 = pdsCopytextCss;

const PdsCopytext$1 = /*@__PURE__*/ proxyCustomElement(class PdsCopytext extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.pdsCopyTextClick = createEvent(this, "pdsCopyTextClick", 7);
        this.copyToClipboard = async (value) => {
            try {
                if (typeof navigator.clipboard !== 'undefined') {
                    await navigator.clipboard.writeText(value);
                    this.pdsCopyTextClick.emit('Copied to clipboard');
                }
            }
            catch (err) {
                this.pdsCopyTextClick.emit(`Error writing text to clipboard: ${err}`);
            }
        };
        this.handleClick = () => {
            this.copyToClipboard(this.value);
        };
        this.border = true;
        this.componentId = undefined;
        this.fullWidth = false;
        this.truncate = false;
        this.value = undefined;
    }
    classNames() {
        const classNames = ['pds-copytext'];
        if (this.border) {
            classNames.push('pds-copytext--bordered');
        }
        if (this.fullWidth) {
            classNames.push('pds-copytext--full-width');
        }
        if (this.truncate) {
            classNames.push('pds-copytext--truncated');
        }
        return classNames.join('  ');
    }
    render() {
        return (h(Host, { key: '43aceb92fe0cc910613115bc882b04108efeffba', class: this.classNames(), id: this.componentId }, h("pds-button", { key: 'f152bc288e64192a80ed8f4f48d90e3edb7558cc', type: "button", variant: "unstyled", onClick: this.handleClick }, h("span", { key: 'ed9486b47835e21601047d2a915a412e664c6b4b' }, this.value), h("pds-icon", { key: 'bfbf6d92775171c36f768d654c5866f2f4ce8479', icon: copy, size: "16px" }))));
    }
    static get style() { return PdsCopytextStyle0 + PdsCopytextStyle1; }
}, [1, "pds-copytext", {
        "border": [516],
        "componentId": [1, "component-id"],
        "fullWidth": [4, "full-width"],
        "truncate": [4],
        "value": [1]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["pds-copytext", "pds-button", "pds-icon"];
    components.forEach(tagName => { switch (tagName) {
        case "pds-copytext":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, PdsCopytext$1);
            }
            break;
        case "pds-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "pds-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}

const PdsCopytext = PdsCopytext$1;
const defineCustomElement = defineCustomElement$1;

export { PdsCopytext, defineCustomElement };

//# sourceMappingURL=pds-copytext.js.map