var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
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;
};
import { jsx, jsxs } from "react/jsx-runtime";
import React from "react";
import { View } from "react-native";
import { bool, number, arrayOf, shape, string, oneOfType } from "prop-types";
import { withTheme } from "styled-components";
import MultiSlider from "@ptomasroos/react-native-multi-slider";
import { LabelView, LabelText } from "./Label";
import Marker from "./Marker";
import Step from "./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__ */ jsx(Step, { active: values[0] < i && values[1] > i }, i));
      } else {
        items.push(/* @__PURE__ */ jsx(Step, { 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__ */ jsxs(View, { style: { width: sliderLength }, children: [
    snapped && /* @__PURE__ */ jsx(
      View,
      {
        style: {
          flexDirection: "row",
          alignItems: "center",
          justifyContent: "space-between",
          bottom: -30
        },
        children: renderSnapDots()
      }
    ),
    /* @__PURE__ */ jsx(
      MultiSlider,
      __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__ */ jsx(Marker, { tooltip: renderTooltip("left"), pressed }),
        customMarkerRight: ({ pressed }) => /* @__PURE__ */ jsx(Marker, { tooltip: renderTooltip("right"), pressed }),
        touchDimensions: {
          slipDisplacement: 400
        }
      })
    ),
    (minLabel || maxLabel) && /* @__PURE__ */ jsxs(LabelView, { children: [
      minLabel && /* @__PURE__ */ jsx(LabelText, { placement: "left", children: minLabel }),
      maxLabel && /* @__PURE__ */ jsx(LabelText, { placement: "right", children: maxLabel })
    ] })
  ] });
};
Slider.propTypes = {
  /** set the max value */
  max: number,
  /** label to be displayed at max value */
  maxLabel: oneOfType([string, number]),
  /** set the min value */
  min: number,
  /** label to be displayed at min value */
  minLabel: oneOfType([string, number]),
  sliderLength: number,
  /** make slider be snap through dots */
  snapped: bool,
  /** accepts a shape with 'ribbon', 'title', 'description', 'visible' and 'step' properties */
  tooltip: arrayOf(
    shape({
      description: string,
      title: string,
      ribbon: string,
      visible: bool,
      step: number
    })
  ),
  /** an array that accepts one or two numbers, this determines how many markers will be displayed */
  values: arrayOf(number)
};
Slider.displayName = "Slider";
var Slider_default = withTheme(Slider);
export {
  Slider_default as default
};
