import { b as $3ef42575df84b30b$export$9d1611c77c2fe928, a as $64fa3d84918910a7$export$29f1550f4b0d4415, f as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, h as $64fa3d84918910a7$export$4d86445c2cf5e3, d as $bdb11010cef70236$export$f680877a34711e37 } from "./utils-cvK1vxO7.js";
import { a as $01b77f81d0f07f68$export$75b6ee27786ba447 } from "./Label-DWVaNd2E.js";
import { $ as $9446cca9a3875146$export$7d15b64cf5a3a4c4 } from "./number-7sOvrqo0.js";
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "./filterDOMProps-D2C6R0DK.js";
import React__default, { forwardRef, createContext, useRef, useEffect } from "react";
import { $ as $d191a55c9702f145$export$8467354a121f1b9f } from "./useLabel-C8umX0gk.js";
import { $ as $a916eb452884faea$export$b7a616150fdb9f44 } from "./useNumberFormatter-BCmkV-7c.js";
import { $ as $f39a9eba43920ace$export$86427a43e3e48ebb } from "./Hidden-rE6uR-lr.js";
import { $ as $701a24aa0da5b062$export$ea18c227d4417cc3 } from "./useButton-Bn4ZT295.js";
import { a as $f7dceffc5ad7768b$export$4e328f61c538687f } from "./useFocusRing-CUxgjvAY.js";
import { w as $6179b936705e76d3$export$ae780daf29e6d456 } from "./useHover-LmGemtHE.js";
const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7e3;
let $319e236875307eab$var$liveAnnouncer = null;
function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
  if (!$319e236875307eab$var$liveAnnouncer) {
    $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();
    if (!(typeof IS_REACT_ACT_ENVIRONMENT === "boolean" ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== "undefined")) setTimeout(() => {
      if ($319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.isAttached()) $319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
    }, 100);
    else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
  } else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
}
function $319e236875307eab$export$d10ae4f68404609a(assertiveness) {
  if ($319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer.clear(assertiveness);
}
class $319e236875307eab$var$LiveAnnouncer {
  isAttached() {
    var _this_node;
    return (_this_node = this.node) === null || _this_node === void 0 ? void 0 : _this_node.isConnected;
  }
  createLog(ariaLive) {
    let node = document.createElement("div");
    node.setAttribute("role", "log");
    node.setAttribute("aria-live", ariaLive);
    node.setAttribute("aria-relevant", "additions");
    return node;
  }
  destroy() {
    if (!this.node) return;
    document.body.removeChild(this.node);
    this.node = null;
  }
  announce(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
    var _this_assertiveLog, _this_politeLog;
    if (!this.node) return;
    let node = document.createElement("div");
    if (typeof message === "object") {
      node.setAttribute("role", "img");
      node.setAttribute("aria-labelledby", message["aria-labelledby"]);
    } else node.textContent = message;
    if (assertiveness === "assertive") (_this_assertiveLog = this.assertiveLog) === null || _this_assertiveLog === void 0 ? void 0 : _this_assertiveLog.appendChild(node);
    else (_this_politeLog = this.politeLog) === null || _this_politeLog === void 0 ? void 0 : _this_politeLog.appendChild(node);
    if (message !== "") setTimeout(() => {
      node.remove();
    }, timeout);
  }
  clear(assertiveness) {
    if (!this.node) return;
    if ((!assertiveness || assertiveness === "assertive") && this.assertiveLog) this.assertiveLog.innerHTML = "";
    if ((!assertiveness || assertiveness === "polite") && this.politeLog) this.politeLog.innerHTML = "";
  }
  constructor() {
    this.node = null;
    this.assertiveLog = null;
    this.politeLog = null;
    if (typeof document !== "undefined") {
      this.node = document.createElement("div");
      this.node.dataset.liveAnnouncer = "true";
      Object.assign(this.node.style, {
        border: 0,
        clip: "rect(0 0 0 0)",
        clipPath: "inset(50%)",
        height: "1px",
        margin: "-1px",
        overflow: "hidden",
        padding: 0,
        position: "absolute",
        width: "1px",
        whiteSpace: "nowrap"
      });
      this.assertiveLog = this.createLog("assertive");
      this.node.appendChild(this.assertiveLog);
      this.politeLog = this.createLog("polite");
      this.node.appendChild(this.politeLog);
      document.body.prepend(this.node);
    }
  }
}
function $204d9ebcedfb8806$export$ed5abd763a836edc(props) {
  let { value = 0, minValue = 0, maxValue = 100, valueLabel, isIndeterminate, formatOptions = {
    style: "percent"
  } } = props;
  let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
    labelable: true
  });
  let { labelProps, fieldProps } = $d191a55c9702f145$export$8467354a121f1b9f({
    ...props,
    // Progress bar is not an HTML input element so it
    // shouldn't be labeled by a <label> element.
    labelElementType: "span"
  });
  value = $9446cca9a3875146$export$7d15b64cf5a3a4c4(value, minValue, maxValue);
  let percentage = (value - minValue) / (maxValue - minValue);
  let formatter = $a916eb452884faea$export$b7a616150fdb9f44(formatOptions);
  if (!isIndeterminate && !valueLabel) {
    let valueToFormat = formatOptions.style === "percent" ? percentage : value;
    valueLabel = formatter.format(valueToFormat);
  }
  return {
    progressBarProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, {
      ...fieldProps,
      "aria-valuenow": isIndeterminate ? void 0 : value,
      "aria-valuemin": minValue,
      "aria-valuemax": maxValue,
      "aria-valuetext": isIndeterminate ? void 0 : valueLabel,
      role: "progressbar"
    }),
    labelProps
  };
}
const $0393f8ab869a0f1a$export$e9f3bf65a26ce129 = /* @__PURE__ */ createContext(null);
const $0393f8ab869a0f1a$export$c17561cb55d4db30 = /* @__PURE__ */ forwardRef(function ProgressBar(props, ref) {
  [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $0393f8ab869a0f1a$export$e9f3bf65a26ce129);
  let { value = 0, minValue = 0, maxValue = 100, isIndeterminate = false } = props;
  value = $9446cca9a3875146$export$7d15b64cf5a3a4c4(value, minValue, maxValue);
  let [labelRef, label] = $64fa3d84918910a7$export$9d4c57ee4c6ffdd8(!props["aria-label"] && !props["aria-labelledby"]);
  let { progressBarProps, labelProps } = $204d9ebcedfb8806$export$ed5abd763a836edc({
    ...props,
    label
  });
  let percentage = isIndeterminate ? void 0 : (value - minValue) / (maxValue - minValue) * 100;
  let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
    ...props,
    defaultClassName: "react-aria-ProgressBar",
    values: {
      percentage,
      valueText: progressBarProps["aria-valuetext"],
      isIndeterminate
    }
  });
  let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
    global: true
  });
  return /* @__PURE__ */ React__default.createElement("div", {
    ...$3ef42575df84b30b$export$9d1611c77c2fe928(DOMProps, renderProps, progressBarProps),
    ref,
    slot: props.slot || void 0
  }, /* @__PURE__ */ React__default.createElement($01b77f81d0f07f68$export$75b6ee27786ba447.Provider, {
    value: {
      ...labelProps,
      ref: labelRef,
      elementType: "span"
    }
  }, renderProps.children));
});
const $d2b4bc8c273e7be6$export$24d547caef80ccd1 = /* @__PURE__ */ createContext({});
const $d2b4bc8c273e7be6$export$353f5b6fc5456de1 = /* @__PURE__ */ $f39a9eba43920ace$export$86427a43e3e48ebb(function Button(props, ref) {
  [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $d2b4bc8c273e7be6$export$24d547caef80ccd1);
  props = $d2b4bc8c273e7be6$var$disablePendingProps(props);
  let ctx = props;
  let { isPending } = ctx;
  let { buttonProps, isPressed } = $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref);
  let { focusProps, isFocused, isFocusVisible } = $f7dceffc5ad7768b$export$4e328f61c538687f(props);
  let { hoverProps, isHovered } = $6179b936705e76d3$export$ae780daf29e6d456({
    ...props,
    isDisabled: props.isDisabled || isPending
  });
  let renderValues = {
    isHovered,
    isPressed: (ctx.isPressed || isPressed) && !isPending,
    isFocused,
    isFocusVisible,
    isDisabled: props.isDisabled || false,
    isPending: isPending !== null && isPending !== void 0 ? isPending : false
  };
  let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
    ...props,
    values: renderValues,
    defaultClassName: "react-aria-Button"
  });
  let buttonId = $bdb11010cef70236$export$f680877a34711e37(buttonProps.id);
  let progressId = $bdb11010cef70236$export$f680877a34711e37();
  let ariaLabelledby = buttonProps["aria-labelledby"];
  if (isPending) {
    if (ariaLabelledby) ariaLabelledby = `${ariaLabelledby} ${progressId}`;
    else if (buttonProps["aria-label"]) ariaLabelledby = `${buttonId} ${progressId}`;
  }
  let wasPending = useRef(isPending);
  useEffect(() => {
    let message = {
      "aria-labelledby": ariaLabelledby || buttonId
    };
    if (!wasPending.current && isFocused && isPending) $319e236875307eab$export$a9b970dcc4ae71a9(message, "assertive");
    else if (wasPending.current && isFocused && !isPending) $319e236875307eab$export$a9b970dcc4ae71a9(message, "assertive");
    wasPending.current = isPending;
  }, [
    isPending,
    isFocused,
    ariaLabelledby,
    buttonId
  ]);
  let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
    global: true
  });
  delete DOMProps.onClick;
  return /* @__PURE__ */ React__default.createElement("button", {
    ...$3ef42575df84b30b$export$9d1611c77c2fe928(DOMProps, renderProps, buttonProps, focusProps, hoverProps),
    // When the button is in a pending state, we want to stop implicit form submission (ie. when the user presses enter on a text input).
    // We do this by changing the button's type to button.
    type: buttonProps.type === "submit" && isPending ? "button" : buttonProps.type,
    id: buttonId,
    ref,
    "aria-labelledby": ariaLabelledby,
    slot: props.slot || void 0,
    "aria-disabled": isPending ? "true" : buttonProps["aria-disabled"],
    "data-disabled": props.isDisabled || void 0,
    "data-pressed": renderValues.isPressed || void 0,
    "data-hovered": isHovered || void 0,
    "data-focused": isFocused || void 0,
    "data-pending": isPending || void 0,
    "data-focus-visible": isFocusVisible || void 0
  }, /* @__PURE__ */ React__default.createElement($0393f8ab869a0f1a$export$e9f3bf65a26ce129.Provider, {
    value: {
      id: progressId
    }
  }, renderProps.children));
});
function $d2b4bc8c273e7be6$var$disablePendingProps(props) {
  if (props.isPending) {
    props.onPress = void 0;
    props.onPressStart = void 0;
    props.onPressEnd = void 0;
    props.onPressChange = void 0;
    props.onPressUp = void 0;
    props.onKeyDown = void 0;
    props.onKeyUp = void 0;
    props.onClick = void 0;
    props.href = void 0;
  }
  return props;
}
export {
  $d2b4bc8c273e7be6$export$353f5b6fc5456de1 as $,
  $d2b4bc8c273e7be6$export$24d547caef80ccd1 as a,
  $0393f8ab869a0f1a$export$c17561cb55d4db30 as b,
  $319e236875307eab$export$a9b970dcc4ae71a9 as c,
  $319e236875307eab$export$d10ae4f68404609a as d
};
