"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_react_native = require("react-native");
var import_prop_types = require("prop-types");
var import_styled_components = require("styled-components");
var import_react_native_multi_slider = __toESM(require("@ptomasroos/react-native-multi-slider"));
var import_Label = require("./Label");
var import_Marker = __toESM(require("./Marker"));
var import_Step = __toESM(require("./Step"));
const Slider = (_a) => {
  var _b = _a, {
    max = 10,
    maxLabel = void 0,
    min = 0,
    minLabel = void 0,
    snapped = false,
    values = [0],
    tooltip = [],
    sliderLength = 280,
    theme: {
      yoga: {
        components: { slider }
      }
    }
  } = _b, props = __objRest(_b, [
    "max",
    "maxLabel",
    "min",
    "minLabel",
    "snapped",
    "values",
    "tooltip",
    "sliderLength",
    "theme"
  ]);
  const renderSnapDots = () => {
    const items = [];
    for (let i = min; i <= max; i++) {
      if (values.length > 1) {
        items.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Step.default, { active: values[0] < i && values[1] > i }, i));
      } else {
        items.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Step.default, { active: values[0] > i }, i));
      }
    }
    return items;
  };
  const renderTooltip = (side) => {
    const tooltipSide = side === "left" ? 0 : 1;
    return tooltip.filter(({ step, visible }) => {
      if (!step && step !== 0) {
        return visible;
      }
      return visible && values[tooltipSide] === step;
    })[0];
  };
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native.View, { style: { width: sliderLength }, children: [
    snapped && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      import_react_native.View,
      {
        style: {
          flexDirection: "row",
          alignItems: "center",
          justifyContent: "space-between",
          bottom: -30
        },
        children: renderSnapDots()
      }
    ),
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      import_react_native_multi_slider.default,
      __spreadProps(__spreadValues({}, props), {
        values,
        sliderLength,
        trackStyle: {
          backgroundColor: slider.track.backgroundColor.inactive,
          height: 4,
          borderRadius: slider.track.border.radius
        },
        selectedStyle: {
          backgroundColor: slider.track.backgroundColor.active
        },
        isMarkersSeparated: true,
        min,
        max,
        snapped,
        customMarkerLeft: ({ pressed }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Marker.default, { tooltip: renderTooltip("left"), pressed }),
        customMarkerRight: ({ pressed }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Marker.default, { tooltip: renderTooltip("right"), pressed }),
        touchDimensions: {
          slipDisplacement: 400
        }
      })
    ),
    (minLabel || maxLabel) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_Label.LabelView, { children: [
      minLabel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Label.LabelText, { placement: "left", children: minLabel }),
      maxLabel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Label.LabelText, { placement: "right", children: maxLabel })
    ] })
  ] });
};
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]),
  sliderLength: 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)({
      description: import_prop_types.string,
      title: import_prop_types.string,
      ribbon: 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);
