import{LitElement as o,html as t,css as c}from"lit";import{iconRemixCheckLine as i,iconRemixFileCopyLine as e}from"./assets/cc-remix.icons.js";import{copyToClipboard as r}from"./lib/clipboard.js";import{isStringEmpty as s}from"./lib/utils.js";import{accessibilityStyles as a}from"./styles/accessibility.js";import{i18n as l}from"./translation.js";import"./cc-icon.js";class n extends o{static get properties(){return{value:{type:String},_copied:{type:Boolean,state:!0}}}constructor(){super(),this.value=null,this._copied=!1}async _copyToClipboard(){await r(this.value),this._copied=!0,setTimeout((()=>{this._copied=!1}),2e3)}render(){return t`
      <button
        type="button"
        @click=${this._copyToClipboard}
        title=" ${s(this.value)?l("cc-clipboard.copy.empty"):l("cc-clipboard.copy",{text:this.value})}"
      >
        <cc-icon class="copy-icon" .icon="${this._copied?i:e}" size="lg"></cc-icon>
        <span class="visually-hidden">
          ${s(this.value)?l("cc-clipboard.copy.empty"):l("cc-clipboard.copy",{text:this.value})}
        </span>
      </button>
      <span class="visually-hidden" aria-live="polite"> ${this._copied?l("cc-clipboard.copied"):""} </span>
    `}static get styles(){return[a,c`
        :host {
          display: block;
        }

        button {
          background: transparent;
          border: none;
          border-radius: var(--cc-border-radius-small, 0.15em);
          color: var(--cc-clipboard-color, var(--cc-color-text-default, #000));
          cursor: pointer;
          display: block;
          font-family: inherit;
          font-size: unset;
          margin: 0;
          padding: 0;
        }

        button:focus {
          outline: var(--cc-focus-outline, #000 solid 2px);
          outline-offset: var(--cc-focus-outline-offset, 2px);
        }

        button:hover {
          background-color: var(--cc-color-bg-neutral-hovered);
        }

        .copy-icon {
          box-sizing: border-box;
          padding: 15%;
        }
      `]}}window.customElements.define("cc-clipboard",n);export{n as CcClipboard};
//# sourceMappingURL=cc-clipboard.js.map
