import {
  __decorateClass,
  __privateAdd,
  __privateMethod
} from "../../chunks/chunk.QU3DSPNU.js";
var _GdsBadge_instances, handleSlotChange_fn, renderLeadSlot_fn, renderMainSlot_fn, renderTrailSlot_fn;
import { property, state } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
import { GdsElement } from "../../gds-element.js";
import { html } from "../../scoping.js";
import { tokens } from "../../tokens.style.js";
import { gdsCustomElement } from "../../utils/helpers/custom-element-scoping.js";
import {
  withLayoutChildProps,
  withMarginProps,
  withSizeXProps
} from "../../utils/mixins/declarative-layout-mixins.js";
import { GdsFlex } from "../flex/flex.component.js";
import BadgeStyles from "./badge.styles.js";
let GdsBadge = class extends withSizeXProps(
  withMarginProps(withLayoutChildProps(GdsElement))
) {
  constructor() {
    super(...arguments);
    __privateAdd(this, _GdsBadge_instances);
    this.variant = "information";
    this.size = "default";
    this.notification = false;
    this.rounded = false;
    this.mainSlotOccupied = false;
    this.leadSlotOccupied = false;
  }
  render() {
    const classes = classMap({
      badge: true,
      [this.variant]: true,
      [this.size]: this.size === "small",
      notification: this.notification,
      "with-content": this.notification && this.mainSlotOccupied,
      rounded: this.rounded
    });
    return html`
      <div class="${classes}">
        ${[
      __privateMethod(this, _GdsBadge_instances, renderLeadSlot_fn).call(this),
      __privateMethod(this, _GdsBadge_instances, renderMainSlot_fn).call(this),
      __privateMethod(this, _GdsBadge_instances, renderTrailSlot_fn).call(this)
    ]}
      </div>
    `;
  }
};
_GdsBadge_instances = new WeakSet();
handleSlotChange_fn = function(event, stateProperty) {
  const slot = event.target;
  const assignedNodes = slot.assignedNodes({ flatten: true });
  this[stateProperty] = assignedNodes.length > 0 && assignedNodes.some(
    (node) => node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.TEXT_NODE && node.textContent?.trim() !== ""
  );
};
renderLeadSlot_fn = function() {
  if (this.size !== "small" || !this.notification) {
    return html`<slot
        name="lead"
        @slotchange=${(e) => __privateMethod(this, _GdsBadge_instances, handleSlotChange_fn).call(this, e, "leadSlotOccupied")}
      ></slot>`;
  }
};
renderMainSlot_fn = function() {
  return html`<slot
      @slotchange=${(e) => __privateMethod(this, _GdsBadge_instances, handleSlotChange_fn).call(this, e, "mainSlotOccupied")}
    ></slot>`;
};
renderTrailSlot_fn = function() {
  return html`<slot name="trail"></slot>`;
};
GdsBadge.styles = [tokens, BadgeStyles];
__decorateClass([
  property()
], GdsBadge.prototype, "variant", 2);
__decorateClass([
  property({ type: String })
], GdsBadge.prototype, "size", 2);
__decorateClass([
  property({
    attribute: "notification",
    type: Boolean,
    reflect: true
  })
], GdsBadge.prototype, "notification", 2);
__decorateClass([
  property({
    attribute: "rounded",
    type: Boolean,
    reflect: true
  })
], GdsBadge.prototype, "rounded", 2);
__decorateClass([
  state()
], GdsBadge.prototype, "mainSlotOccupied", 2);
__decorateClass([
  state()
], GdsBadge.prototype, "leadSlotOccupied", 2);
GdsBadge = __decorateClass([
  gdsCustomElement("gds-badge", { dependsOn: [GdsFlex] })
], GdsBadge);
export {
  GdsBadge
};
