/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { c as customElement } from "../../chunks/runtime.js";
import { css, html } from "lit";
import { LitElement, createEvent, stringOrBoolean, safeClassMap } from "@arcgis/lumina";
import { u as useSetFocus } from "../../chunks/useSetFocus.js";
import { u as useInteractive } from "../../chunks/useInteractive.js";
const CSS = {
  container: "container",
  dividerContainer: "divider-container",
  divider: "divider"
};
const SLOTS = {
  trigger: "trigger"
};
const ICONS = {
  chevronDown: "chevronDown",
  caretDown: "caretDown",
  ellipsis: "ellipsis",
  handleVertical: "handle-vertical"
};
const styles = css`:host([disabled]){cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-opacity-disabled)}:host([disabled]) *,:host([disabled]) ::slotted(*){pointer-events:none}:host{display:inline-block}:host([width=auto]){inline-size:auto}:host([width=half]){inline-size:50%}:host([width=full]){inline-size:100%}:host([kind=brand]){--calcite-internal-split-button-divider-border-color: var(--calcite-color-brand);--calcite-internal-split-button-divider-color: var(--calcite-color-foreground-1)}:host([kind=danger]){--calcite-internal-split-button-divider-border-color: var(--calcite-color-status-danger);--calcite-internal-split-button-divider-color: var(--calcite-color-foreground-1)}:host([kind=neutral]){--calcite-internal-split-button-divider-border-color: var(--calcite-color-foreground-3);--calcite-internal-split-button-divider-color: var(--calcite-color-text-1)}:host([kind=inverse]){--calcite-internal-split-button-divider-border-color: var(--calcite-color-inverse);--calcite-internal-split-button-divider-color: var(--calcite-color-foreground-1)}:host([appearance=transparent]){--calcite-internal-split-button-divider-border-color: transparent}:host([appearance=transparent]):host([kind=brand]){--calcite-internal-split-button-divider-color: var(--calcite-color-brand)}:host([appearance=transparent]):host([kind=danger]){--calcite-internal-split-button-divider-color: var(--calcite-color-status-danger)}:host([appearance=transparent]):host([kind=neutral]){--calcite-internal-split-button-divider-color: var(--calcite-color-text-1)}:host([appearance=transparent]):host([kind=inverse]){--calcite-internal-split-button-divider-color: var(--calcite-color-foreground-1)}:host([appearance=outline]):host([kind=brand]),:host([appearance=outline]):host([kind=danger]),:host([appearance=outline]):host([kind=neutral]),:host([appearance=outline]):host([kind=inverse]){--calcite-internal-split-button-divider-border-color: transparent}:host([appearance=outline-fill]):host([kind=brand]),:host([appearance=outline-fill]):host([kind=danger]),:host([appearance=outline-fill]):host([kind=neutral]),:host([appearance=outline-fill]):host([kind=inverse]){--calcite-internal-split-button-divider-border-color: var(--calcite-color-background)}:host([appearance=outline]):host([kind=brand]),:host([appearance=outline-fill]):host([kind=brand]){--calcite-internal-split-button-divider-color: var(--calcite-color-brand)}:host([appearance=outline]):host([kind=danger]),:host([appearance=outline-fill]):host([kind=danger]){--calcite-internal-split-button-divider-color: var(--calcite-color-status-danger)}:host([appearance=outline]):host([kind=neutral]),:host([appearance=outline-fill]):host([kind=neutral]){--calcite-internal-split-button-divider-color: var(--calcite-color-border-1)}:host([appearance=outline]):host([kind=inverse]),:host([appearance=outline-fill]):host([kind=inverse]){--calcite-internal-split-button-divider-color: var(--calcite-color-inverse)}.container{display:flex;align-items:stretch}.container>calcite-dropdown>calcite-button{block-size:100%;vertical-align:top}.divider-container{display:flex;inline-size:1px;align-items:stretch;transition-property:background-color,block-size,border-color,box-shadow,color,inset-block-end,inset-block-start,inset-inline-end,inset-inline-start,inset-size,opacity,outline-color,transform;transition-duration:var(--calcite-animation-timing);transition-timing-function:ease-in-out;background-color:var(--calcite-split-button-divider-color, var(--calcite-internal-split-button-divider-border-color))}.divider{margin-block:.25rem;display:inline-block;inline-size:1px;background-color:var(--calcite-split-button-divider-border-color, var(--calcite-internal-split-button-divider-color))}:host([appearance=outline-fill]) .divider-container,:host([appearance=outline]) .divider-container{border-block:1px solid var(--calcite-internal-split-button-divider-color)}:host([appearance=outline-fill]):hover .divider-container,:host([appearance=outline]):hover .divider-container{background-color:var(--calcite-internal-split-button-divider-color)}:host([appearance=outline-fill]:hover) .divider-container,:host([appearance=outline]:hover) .divider-container{background-color:var(--calcite-internal-split-button-divider-color)}:host([appearance=outline-fill]:focus-within):host([kind=brand]),:host([appearance=outline]:focus-within):host([kind=brand]){--calcite-internal-split-button-divider-color: var(--calcite-color-brand-press)}:host([appearance=outline-fill]:focus-within):host([kind=danger]),:host([appearance=outline]:focus-within):host([kind=danger]){--calcite-internal-split-button-divider-color: var(--calcite-color-danger-press)}:host([appearance=outline-fill]:focus-within) .divider-container,:host([appearance=outline]:focus-within) .divider-container{background-color:var(--calcite-internal-split-button-divider-color)}calcite-button[split-child=primary],calcite-button[split-child=secondary]{--calcite-button-background-color: var(--calcite-split-button-background-color);--calcite-button-border-color: var(--calcite-split-button-border-color);--calcite-button-text-color: var(--calcite-split-button-text-color);--calcite-button-icon-color: var(--calcite-split-button-icon-color);--calcite-button-loading-color: var(--calcite-split-button-loading-color);--calcite-button-shadow: var(--calcite-split-button-shadow)}calcite-button[split-child=primary]:hover,calcite-button[split-child=secondary]:hover{--calcite-button-background-color: var(--calcite-split-button-background-color-hover)}calcite-button[split-child=primary]:focus,calcite-button[split-child=secondary]:focus{--calcite-button-background-color: var(--calcite-split-button-background-color-focus)}calcite-button[split-child=primary]:active,calcite-button[split-child=secondary]:active{--calcite-button-background-color: var(--calcite-split-button-background-color-press)}calcite-button[split-child=primary]{--calcite-button-corner-radius: var(--calcite-split-button-corner-radius) var(--calcite-corner-radius-none) var(--calcite-corner-radius-none) var(--calcite-split-button-corner-radius)}calcite-button[split-child=secondary]{--calcite-button-corner-radius: var(--calcite-corner-radius-none) var(--calcite-split-button-corner-radius) var(--calcite-split-button-corner-radius) var(--calcite-corner-radius-none)}calcite-dropdown{--calcite-dropdown-shadow: var(--calcite-split-button-dropdown-shadow);--calcite-dropdown-background-color: var(--calcite-split-button-dropdown-background-color);--calcite-dropdown-width: var(--calcite-split-button-dropdown-width)}:host([disabled]) calcite-dropdown>calcite-button{pointer-events:none}:host([disabled]):host([appearance=outline-fill]) .divider-container{background-color:var(--calcite-color-background)}:host([disabled]):host([appearance=outline]) .divider-container{background-color:transparent}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}:host([hidden]){display:none}[hidden]{display:none}`;
class SplitButton extends LitElement {
  constructor() {
    super(...arguments);
    this.focusSetter = useSetFocus()(this);
    this.interactiveContainer = useInteractive(this);
    this.active = false;
    this.appearance = "solid";
    this.disabled = false;
    this.download = false;
    this.dropdownIconType = "chevron";
    this.kind = "brand";
    this.loading = false;
    this.overlayPositioning = "absolute";
    this.placement = "bottom-end";
    this.scale = "m";
    this.topLayerDisabled = false;
    this.width = "auto";
    this.calciteSplitButtonPrimaryClick = createEvent({ cancelable: false });
    this.calciteSplitButtonSecondaryClick = createEvent({ cancelable: false });
  }
  static {
    this.properties = { active: [7, {}, { reflect: true, type: Boolean }], appearance: [3, {}, { reflect: true }], disabled: [7, {}, { reflect: true, type: Boolean }], download: [3, { converter: stringOrBoolean }, { reflect: true }], dropdownIconType: [3, {}, { reflect: true }], dropdownLabel: [3, {}, { reflect: true }], flipPlacements: [0, {}, { attribute: false }], href: [3, {}, { reflect: true }], kind: [3, {}, { reflect: true }], loading: [7, {}, { reflect: true, type: Boolean }], overlayPositioning: [3, {}, { reflect: true }], rel: [3, {}, { reflect: true }], placement: [3, {}, { reflect: true }], primaryIconEnd: [3, { type: String }, { reflect: true }], primaryIconFlipRtl: [3, {}, { reflect: true }], primaryIconStart: [3, { type: String }, { reflect: true }], primaryLabel: [3, {}, { reflect: true }], primaryText: [3, {}, { reflect: true }], scale: [3, {}, { reflect: true }], target: [3, {}, { reflect: true }], topLayerDisabled: [7, {}, { reflect: true, type: Boolean }], width: [3, {}, { reflect: true }] };
  }
  static {
    this.shadowRootOptions = { mode: "open", delegatesFocus: true };
  }
  static {
    this.styles = styles;
  }
  get dropdownIcon() {
    return this.dropdownIconType === "chevron" ? ICONS.chevronDown : this.dropdownIconType === "caret" ? ICONS.caretDown : this.dropdownIconType === "ellipsis" ? ICONS.ellipsis : ICONS.handleVertical;
  }
  async setFocus(options) {
    return this.focusSetter(() => this.el, options);
  }
  calciteSplitButtonPrimaryClickHandler() {
    this.calciteSplitButtonPrimaryClick.emit();
  }
  calciteSplitButtonSecondaryClickHandler() {
    this.calciteSplitButtonSecondaryClick.emit();
  }
  render() {
    const buttonWidth = this.width === "auto" ? "auto" : "full";
    return this.interactiveContainer({ disabled: this.disabled, children: html`<div class=${safeClassMap(CSS.container)}><calcite-button .appearance=${this.appearance} .disabled=${this.disabled} .download=${this.download} .href=${this.href} .iconEnd=${this.primaryIconEnd ? this.primaryIconEnd : null} .iconFlipRtl=${this.primaryIconFlipRtl ? this.primaryIconFlipRtl : null} .iconStart=${this.primaryIconStart ? this.primaryIconStart : null} .kind=${this.kind} .label=${this.primaryLabel} .loading=${this.loading} @click=${this.calciteSplitButtonPrimaryClickHandler} .rel=${this.rel} .scale=${this.scale} split-child=primary .target=${this.target} type=button .width=${buttonWidth}>${this.primaryText}</calcite-button><div class=${safeClassMap(CSS.dividerContainer)}><div class=${safeClassMap(CSS.divider)}></div></div><calcite-dropdown .disabled=${this.disabled} .flipPlacements=${this.flipPlacements} @click=${this.calciteSplitButtonSecondaryClickHandler} .open=${this.active} .overlayPositioning=${this.overlayPositioning} .placement=${this.placement} .scale=${this.scale} .topLayerDisabled=${this.topLayerDisabled} .widthScale=${this.scale}><calcite-button .appearance=${this.appearance} .disabled=${this.disabled} .iconStart=${this.dropdownIcon} .kind=${this.kind} .label=${this.dropdownLabel} .scale=${this.scale} slot=${SLOTS.trigger} split-child=secondary type=button></calcite-button><slot></slot></calcite-dropdown></div>` });
  }
}
customElement("calcite-split-button", SplitButton);
export {
  SplitButton
};
