var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: !0 });
}, __copyProps = (to, from, except, desc) => {
  if (from && typeof from == "object" || typeof from == "function")
    for (let key of __getOwnPropNames(from))
      !__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: !0 }) : target,
  mod
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var SegmentButton_exports = {};
__export(SegmentButton_exports, {
  SegmentButton: () => SegmentButton,
  SegmentButtonGroup: () => SegmentButtonGroup
});
module.exports = __toCommonJS(SegmentButton_exports);
var import_jsx_runtime = require("react/jsx-runtime"), import_react = __toESM(require("react"), 1), import_react_native = require("react-native"), import_tamagui = require("tamagui"), import_Icon = require("./Icon"), import_typography = require("./typography"), SegmentButtonContext = (0, import_tamagui.createStyledContext)({
  disabled: !1,
  variant: void 0
}), Frame = (0, import_tamagui.styled)(import_tamagui.ThemeableStack, {
  name: "SegmentButton",
  context: SegmentButtonContext,
  borderRadius: "$shape.corner_full",
  display: "flex",
  flexDirection: "row",
  overflow: "hidden",
  variants: {
    density: {
      0: {
        height: 40,
        maxHeight: 48
      },
      "-1": {
        height: 36,
        maxHeight: 36
      },
      "-2": {
        height: 32,
        maxHeight: 32
      },
      "-3": {
        height: 28,
        maxHeight: 28
      }
    },
    variant: {
      "fill-tonal": {
        backgroundColor: "$secondaryContainer"
      }
    },
    outlined: {
      true: {
        borderWidth: 1,
        borderColor: "$outlineVariant"
      },
      false: {
        borderWidth: 0
      }
    }
  },
  defaultVariants: {
    variant: void 0,
    outlined: !0,
    density: "0"
  }
}), FrameHOC = Frame.styleable(function(param, ref) {
  var { children, ...props } = param, items = [], childCount = import_react.default.Children.count(children);
  return import_react.default.Children.forEach(children, function(child, index) {
    var isLast = index + 1 == childCount;
    items.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.ThemeableStack, {
      borderRightWidth: isLast ? 0 : 1,
      borderRightColor: isLast ? void 0 : "$outlineVariant",
      height: "100%",
      f: 1,
      fb: 1,
      justifyContent: "center",
      alignItems: "center",
      display: "flex",
      children: child
    }, `segment-stack-item-${index}`));
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Frame, {
    ...props,
    ref,
    children: items
  });
}), SegmentButtonItemContext = (0, import_tamagui.createStyledContext)({
  selected: !1
}), Item = (0, import_tamagui.styled)(import_tamagui.ThemeableStack, {
  name: "SegmentButtonItem",
  context: SegmentButtonItemContext,
  height: "100%",
  width: "100%",
  flexDirection: "row",
  alignItems: "center",
  justifyContent: "center",
  minWidth: 48,
  cursor: "pointer",
  gap: 8,
  paddingLeft: 12,
  paddingRight: 12,
  variants: {
    variant: {
      "fill-tonal": {
        backgroundColor: "unset"
      }
    },
    selected: {
      true: {
        backgroundColor: "$secondaryContainer"
      },
      false: {
        hoverStyle: {
          backgroundColor: "$surface"
        }
      }
    }
  },
  defaultVariants: {
    selected: !1
  }
}), Label = (0, import_tamagui.styled)(import_typography.Label, {
  name: "SegmentButtonLabel",
  context: SegmentButtonItemContext,
  size: "large",
  variants: {
    selected: {
      false: {
        col: "$onSurface"
      },
      true: {
        col: "$onSecondaryContainer"
      }
    },
    variant: {
      "filled-tonal": {
        col: "$onSecondaryContainer"
      }
    }
  },
  defaultVariants: {
    selected: !1
  }
}), Icon = (0, import_tamagui.styled)(import_Icon.Icon, {
  name: "SegmentButtonIcon",
  context: SegmentButtonItemContext,
  col: "$onSurface",
  size: 18,
  height: 18,
  width: 18,
  variants: {
    disabled: {
      true: {
        col: "$onSurface",
        opacity: 0.38
      }
    },
    variant: {
      "filled-tonal": {
        col: "$onSecondaryContainer"
      }
    }
  }
}), SegmentButtonItem = (0, import_tamagui.withStaticProperties)(Item, {
  Props: SegmentButtonItemContext.Provider,
  Icon,
  Label,
  Item
}), SegmentButton = (0, import_tamagui.withStaticProperties)(FrameHOC, {
  Props: SegmentButtonContext.Provider,
  Item: SegmentButtonItem
});
function SegmentButtonGroup(param) {
  var { value, items, onChange, ...props } = param;
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SegmentButton, {
    ...props,
    children: items.map(function(item, index) {
      return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Pressable, {
        onPress: function() {
          return onChange(item.value);
        },
        style: {
          width: "100%",
          height: "100%"
        },
        children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SegmentButton.Item, {
          selected: value == item.value,
          children: [
            item.Icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SegmentButton.Item.Icon, {
              Icon: item.Icon
            }),
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SegmentButton.Item.Label, {
              children: item.label
            })
          ]
        })
      }, `segment-item-${index}`);
    })
  });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  SegmentButton,
  SegmentButtonGroup
});
//# sourceMappingURL=SegmentButton.js.map
