import{css as e}from"../../../lit/index.js";import{DDD as t}from"../../d-d-d/d-d-d.js";import{SimpleTagLiteSuper as s}from"./simple-tag-lite.js";import{SimpleFieldsButtonStyles as o,SimpleFieldsTooltipStyles as r}from"./simple-fields-ui.js";export class SimpleTag extends(s(t)){constructor(){super(),this.autoAccentColor=!1}updated(e){super.updated(e),this.shadowRoot&&(e.has("autoAccentColor")||e.has("value"))&&this.value&&this.autoAccentColor&&(this.accentColor=this.calculateAccentColor(this.value))}calculateAccentColor(e){let t=54;for(let s=0;s<e.length;s++)s<32&&(t*=e.charCodeAt(s));t+="",t.length>8&&(t=t.substring(5,7));let s=Array.from(Object.keys(this.colors))[t[0]],o=0!==parseInt(t[1])?parseInt(t[1]):1;[5,6,7].includes(o)?o-=3:[8,9].includes(o)&&(o+=2);const r=this.getContrastingColors(s,o,!1);let l=r.grey[0];return o<5&&(l=r.grey.pop()),this.style.setProperty("--simple-fields-button-background-color",`var(--simple-colors-default-theme-accent-${o}, orange)`),this.style.setProperty("--simple-fields-button-color",`var(--simple-colors-fixed-theme-grey-${l}, black)`),s}static get properties(){return{...super.properties,autoAccentColor:{type:Boolean,attribute:"auto-accent-color"}}}static get styles(){return[super.styles,o,r,e`
        :host {
          --simple-fields-button-color: var(
            --simple-colors-default-theme-accent-12,
            #222222
          );
          --simple-fields-fieldset-border-color: var(
            --simple-colors-default-theme-accent-3,
            #eeeeee
          );
          --simple-fields-button-background-color: var(
            --simple-colors-default-theme-accent-3,
            #eeeeee
          );
          --simple-fields-tag-margin-left: var(--ddd-spacing-2);
          --simple-fields-tag-border-width: var(--ddd-border-xs);
          font-size: var(--ddd-font-size-4xs);
        }
      `]}static get tag(){return"simple-tag"}}customElements.define(SimpleTag.tag,SimpleTag);