import { proxyCustomElement, HTMLElement, h, Fragment } from '@stencil/core/internal/client';
import { _ as __ } from './default-i18n.js';
import './index2.js';
import { d as defineCustomElement$2 } from './sc-format-date2.js';
import { d as defineCustomElement$1 } from './sc-tag2.js';

const scSubscriptionStatusBadgeCss = ":host{display:inline-block}";

const ScSubscriptionStatusBadge = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
    /** The tag's size. */
    this.size = 'medium';
    /** Draws a pill-style tag with rounded edges. */
    this.pill = false;
    /** Makes the tag clearable. */
    this.clearable = false;
  }
  getType() {
    var _a, _b, _c;
    if ((_a = this.subscription) === null || _a === void 0 ? void 0 : _a.cancel_at_period_end) {
      return 'info';
    }
    switch (this.status || ((_b = this.subscription) === null || _b === void 0 ? void 0 : _b.status)) {
      case 'incomplete':
        return 'warning';
      case 'trialing':
        return 'info';
      case 'active':
        return 'success';
      case 'completed':
        return 'success';
      case 'past_due':
        return 'warning';
      case 'canceled':
        if ((_c = this.subscription) === null || _c === void 0 ? void 0 : _c.restore_at) {
          return 'info';
        }
        return 'danger';
      case 'unpaid':
        return 'warning';
    }
  }
  getText() {
    var _a, _b, _c, _d, _e;
    if (((_a = this.subscription) === null || _a === void 0 ? void 0 : _a.cancel_at_period_end) && this.subscription.current_period_end_at && ((_b = this.subscription) === null || _b === void 0 ? void 0 : _b.status) !== 'canceled') {
      return (h(Fragment, null, !!((_c = this.subscription) === null || _c === void 0 ? void 0 : _c.restore_at) ? __('Pauses', 'surecart') : __('Cancels', 'surecart'), ' ', h("sc-format-date", { type: "timestamp", date: this.subscription.current_period_end_at, month: "short", day: "numeric" })));
    }
    switch (this.status || ((_d = this.subscription) === null || _d === void 0 ? void 0 : _d.status)) {
      case 'incomplete':
        return __('Incomplete', 'surecart');
      case 'trialing':
        return __('Trialing', 'surecart');
      case 'active':
        return __('Active', 'surecart');
      case 'past_due':
        return __('Past Due', 'surecart');
      case 'canceled':
        if ((_e = this.subscription) === null || _e === void 0 ? void 0 : _e.restore_at) {
          return 'Paused';
        }
        return __('Canceled', 'surecart');
      case 'completed':
        return __('Completed', 'surecart');
      case 'unpaid':
        return __('Unpaid', 'surecart');
    }
  }
  render() {
    return h("sc-tag", { type: this.getType() }, this.getText());
  }
  static get style() { return scSubscriptionStatusBadgeCss; }
}, [1, "sc-subscription-status-badge", {
    "status": [1],
    "subscription": [16],
    "size": [513],
    "pill": [516],
    "clearable": [4]
  }]);
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["sc-subscription-status-badge", "sc-format-date", "sc-tag"];
  components.forEach(tagName => { switch (tagName) {
    case "sc-subscription-status-badge":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, ScSubscriptionStatusBadge);
      }
      break;
    case "sc-format-date":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
    case "sc-tag":
      if (!customElements.get(tagName)) {
        defineCustomElement$1();
      }
      break;
  } });
}
defineCustomElement();

export { ScSubscriptionStatusBadge as S, defineCustomElement as d };
