import{__decorate as t}from"tslib";import{LitElement as s,html as e,nothing as r}from"lit";import{property as a,customElement as o}from"lit/decorators.js";import{s as i}from"./nile-color-swatch.css.esm.js";let c=class extends s{constructor(){super(...arguments),this.color="#000000",this.active=!1}static get styles(){return[i]}_tickColor(){const t=this.color.replace("#","");if(6!==t.length)return"#FFFFFF";const s=parseInt(t.substring(0,2),16)/255,e=parseInt(t.substring(2,4),16)/255,r=parseInt(t.substring(4,6),16)/255,a=t=>t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4),o=.2126*a(s)+.7152*a(e)+.0722*a(r);return 1.05/(o+.05)>(o+.05)/.05?"#FFFFFF":"#111827"}render(){const t="swatch"+(this.active?" swatch--active":""),s=this._tickColor();return e`
      <button
        class=${t}
        part="base"
        type="button"
        aria-pressed=${this.active?"true":"false"}
        aria-label=${this.color}
      >
        <span class="swatch__fill" style="background:${this.color}"></span>
        ${this.active?e`
              <span class="swatch__check">
                <nile-glyph name="tick" color=${s}></nile-glyph>
              </span>
            `:r}
      </button>
    `}};t([a({type:String,reflect:!0})],c.prototype,"color",void 0),t([a({type:Boolean,reflect:!0})],c.prototype,"active",void 0),c=t([o("nile-color-swatch")],c);export{c as N};
