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 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-125);--border-radius-hover:var(--pine-border-radius-0);--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-semi-bold);--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-medium) var(--pine-font-size-100)/var(--pine-line-height-150) var(--pine-font-family-circular)}: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):hover{background-color:var(--copytext-color-background-hover);border-radius:var(--border-radius-hover);color:var(--color-text-hover)}:host(.pds-copytext) pds-button span{-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 PdsCopytextStyle0 = 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: '9960146a3ac3810bc14834a976f2e50627569dad', class: this.classNames(), id: this.componentId }, h("pds-button", { key: '9d8c6dc9824be2483982d4362a5c8d8c4c232432', type: "button", variant: "unstyled", onClick: this.handleClick }, h("span", { key: '7c093ec0ae96afdbad02adda3901be87989c9ce4' }, this.value), h("pds-icon", { key: '466f5c685e32be0067938869afee751db522d3d3', icon: copy, size: "16px" }))));
    }
    static get style() { return PdsCopytextStyle0; }
}, [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