"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Slider_exports = {};
__export(Slider_exports, {
  default: () => Slider_default
});
module.exports = __toCommonJS(Slider_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = __toESM(require("react"));
var import_prop_types = require("prop-types");
var import_styled_components = __toESM(require("styled-components"));
var import_Slider = __toESM(require("rc-slider/lib/Slider"));
var import_Range = __toESM(require("rc-slider/lib/Range"));
var import_Marker = __toESM(require("./Marker"));
const StyledSlider = (0, import_styled_components.default)(import_Slider.default)`
  position: relative;
  width: 100%;

  ${({ marks }) => `
    padding-bottom: ${marks ? 40 : 15}px;
  `}

  * {
    box-sizing: border-box;
  }
`;
const StyledRange = (0, import_styled_components.default)(import_Range.default)`
  position: relative;
  width: 100%;

  ${({ marks }) => `
    padding-bottom: ${marks ? 40 : 15}px;
  `}

  * {
    box-sizing: border-box;
  }
`;
const emptyArr = [];
const defaultValues = [0];
const Slider = (_a) => {
  var _b = _a, {
    snapped = false,
    tooltip = emptyArr,
    values = defaultValues,
    max = 10,
    maxLabel,
    min = 0,
    minLabel,
    theme: {
      yoga: {
        components: { slider }
      }
    }
  } = _b, props = __objRest(_b, [
    "snapped",
    "tooltip",
    "values",
    "max",
    "maxLabel",
    "min",
    "minLabel",
    "theme"
  ]);
  const styles = {
    commonTrackStyle: {
      borderRadius: slider.track.border.radius,
      height: 4,
      position: "absolute",
      width: "100%"
    },
    trackStyle: {
      backgroundColor: slider.track.backgroundColor.active
    },
    railStyle: {
      backgroundColor: slider.track.backgroundColor.inactive
    },
    commonStepStyle: {
      borderRadius: slider.step.border.radius,
      marginLeft: -4,
      position: "absolute",
      height: 10,
      top: -3,
      width: 10
    },
    activeStepStyle: {
      backgroundColor: slider.track.backgroundColor.active
    },
    inactiveStepStyle: {
      backgroundColor: slider.track.backgroundColor.inactive
    },
    labelStyle: {
      position: "absolute",
      top: 15
    }
  };
  return values.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    StyledRange,
    __spreadProps(__spreadValues({}, props), {
      dots: snapped,
      value: values,
      allowCross: false,
      marks: {
        [min]: {
          label: minLabel,
          style: __spreadProps(__spreadValues({}, styles.labelStyle), { transform: "translateX(0%)" })
        },
        [max]: {
          label: maxLabel,
          style: __spreadProps(__spreadValues({}, styles.labelStyle), { transform: "translateX(-100%)" })
        }
      },
      trackStyle: [
        __spreadValues(__spreadValues({}, styles.commonTrackStyle), styles.trackStyle)
      ],
      railStyle: __spreadValues(__spreadValues({}, styles.commonTrackStyle), styles.railStyle),
      dotStyle: snapped ? __spreadValues(__spreadValues({}, styles.commonStepStyle), styles.inactiveStepStyle) : void 0,
      activeDotStyle: snapped ? __spreadValues(__spreadValues({}, styles.commonStepStyle), styles.activeStepStyle) : void 0,
      max,
      min,
      handle: (_a2) => {
        var _b2 = _a2, { ref, index } = _b2, rest = __objRest(_b2, ["ref", "index"]);
        return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import_Marker.default,
          __spreadValues({
            values,
            tooltip,
            index
          }, rest),
          index
        );
      }
    })
  ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    StyledSlider,
    __spreadProps(__spreadValues({}, props), {
      prefixCls: "yoga",
      dots: snapped,
      value: values[0],
      marks: {
        [min]: {
          label: minLabel,
          style: __spreadProps(__spreadValues({}, styles.labelStyle), { transform: "translateX(0%)" })
        },
        [max]: {
          label: maxLabel,
          style: __spreadProps(__spreadValues({}, styles.labelStyle), { transform: "translateX(-100%)" })
        }
      },
      trackStyle: __spreadValues(__spreadValues({}, styles.commonTrackStyle), styles.trackStyle),
      railStyle: __spreadValues(__spreadValues({}, styles.commonTrackStyle), styles.railStyle),
      dotStyle: snapped ? __spreadValues(__spreadValues({}, styles.commonStepStyle), styles.inactiveStepStyle) : void 0,
      activeDotStyle: snapped ? __spreadValues(__spreadValues({}, styles.commonStepStyle), styles.activeStepStyle) : void 0,
      max,
      min,
      handle: (_c) => {
        var _d = _c, { ref, index } = _d, rest = __objRest(_d, ["ref", "index"]);
        return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import_Marker.default,
          __spreadValues({
            values,
            tooltip,
            index
          }, rest),
          index
        );
      }
    })
  );
};
Slider.propTypes = {
  /** set the max value */
  max: import_prop_types.number,
  /** label to be displayed at max value */
  maxLabel: (0, import_prop_types.oneOfType)([import_prop_types.string, import_prop_types.number]),
  /** set the min value */
  min: import_prop_types.number,
  /** label to be displayed at min value */
  minLabel: (0, import_prop_types.oneOfType)([import_prop_types.string, import_prop_types.number]),
  /** make slider be snap through dots */
  snapped: import_prop_types.bool,
  /** accepts a shape with 'ribbon', 'title', 'description', 'visible' and 'step' properties */
  tooltip: (0, import_prop_types.arrayOf)(
    (0, import_prop_types.shape)({
      ribbon: import_prop_types.string,
      title: import_prop_types.string,
      description: import_prop_types.string,
      visible: import_prop_types.bool,
      step: import_prop_types.number
    })
  ),
  /** an array that accepts one or two numbers, this determines how many markers will be displayed */
  values: (0, import_prop_types.arrayOf)(import_prop_types.number)
};
Slider.displayName = "Slider";
var Slider_default = (0, import_styled_components.withTheme)(Slider);
