import{r as e,c as t,h as i,H as l,g as a}from"./p-268dca3f.js";import{f as c,g as s}from"./p-9c90d370.js";const n=class{constructor(i){e(this,i),this.calciteLabelFocus=t(this,"calciteLabelFocus",7),this.status="idle",this.scale="m",this.layout="default",this.handleClick=e=>{this.emitSelectedItem(e.target),this.requestedFor?c(document.getElementById(this.requestedFor)):this.el.querySelector("textarea")?this.el.querySelector("textarea").focus():this.el.querySelector("input")&&this.el.querySelector("input").focus()}}connectedCallback(){["invalid","valid","idle"].includes(this.status)||(this.status="idle"),["inline","inline-space-between","default"].includes(this.layout)||(this.layout="default"),["s","m","l"].includes(this.scale)||(this.scale="m")}componentDidLoad(){this.requestedFor=this.el.getAttribute("for"),"inline"!==this.layout&&"inline-space-between"!==this.layout||(this.displayedSlottedContent=this.handleSlottedContent(),this.slottedContent.innerHTML="",this.displayedSlottedContent.map(e=>{this.slottedContent.append(e)}))}render(){const e=this.getAttributes(),t=s(this.el);return i(l,{dir:t,onClick:this.handleClick},i("label",Object.assign({},e,{ref:e=>this.slottedContent=e}),i("slot",null)))}handleSlottedContent(){const e=[],t=this.el.childNodes;return t&&t.forEach((function(t){if("#text"===t.nodeName&&t.textContent.trim().length>0){const i=document.createElement("span");i.classList.add("calcite-label-text"),i.innerHTML=t.textContent.trim(),e.push(i)}else"#text"!==t.nodeName&&e.push(t)})),[...Array.from(new Set(e))]}emitSelectedItem(e){this.calciteLabelFocus.emit({labelEl:this.el,interactedEl:e,requestedInput:this.requestedFor})}getAttributes(){const e=["layout","theme","scale","status"];return Array.from(this.el.attributes).filter(t=>t&&!e.includes(t.name)).reduce((e,{name:t,value:i})=>Object.assign(Object.assign({},e),{[t]:i}),{})}get el(){return a(this)}};n.style=":host([hidden]){display:none}:host-context([theme=dark]){--calcite-ui-blue-1:#00A0FF;--calcite-ui-blue-2:#0087D7;--calcite-ui-blue-3:#47BBFF;--calcite-ui-green-1:#36DA43;--calcite-ui-green-2:#11AD1D;--calcite-ui-green-3:#44ED51;--calcite-ui-yellow-1:#FFC900;--calcite-ui-yellow-2:#F4B000;--calcite-ui-yellow-3:#FFE24D;--calcite-ui-red-1:#FE583E;--calcite-ui-red-2:#F3381B;--calcite-ui-red-3:#FF7465;--calcite-ui-background:#202020;--calcite-ui-foreground-1:#2b2b2b;--calcite-ui-foreground-2:#353535;--calcite-ui-foreground-3:#404040;--calcite-ui-text-1:#ffffff;--calcite-ui-text-2:#bfbfbf;--calcite-ui-text-3:#9f9f9f;--calcite-ui-border-1:#4a4a4a;--calcite-ui-border-2:#404040;--calcite-ui-border-3:#353535;--calcite-ui-border-4:#757575;--calcite-ui-border-5:#9f9f9f}:host([scale=s]) label{font-size:var(--calcite-label-font-size, 12px);--calcite-label-spacing-value:8px}:host([scale=m]) label{font-size:var(--calcite-label-font-size, 16px);--calcite-label-spacing-value:12px}:host([scale=l]) label{font-size:var(--calcite-label-font-size, 20px);--calcite-label-spacing-value:16px}:host{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;position:relative;text-align:left}:host([dir=rtl]){text-align:right}:host label{width:100%;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;cursor:pointer;margin:0 0 var(--calcite-label-margin-bottom, 1.5rem) 0}:host([layout=inline]) label{-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}:host([layout=inline-space-between]) label{-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center}:host([layout=default]) label .calcite-label-text{margin-bottom:8px}:host([layout=inline]) .calcite-label-text:first-child,:host([layout=inline-space-between]) .calcite-label-text:first-child{margin-right:0.75rem}:host([layout=inline]) .calcite-label-text:last-child,:host([layout=inline-space-between]) .calcite-label-text:last-child{margin-left:0.75rem}:host([status=invalid]) label{color:var(--calcite-ui-red-1)}:host([status=valid]) label{color:var(--calcite-ui-text-2)}:host([status=idle]) label{color:var(--calcite-ui-text-2)}";export{n as calcite_label}