"use strict";

import React, { Children, memo } from 'react';
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
import { useTheme } from "../theme/use-theme.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// ── Item (defined first so it can be attached to GroupedButtons) ─

function ItemComponent({
  label,
  description,
  icon,
  onPress,
  destructive = false,
  disabled = false,
  testID
}) {
  const theme = useTheme();
  const labelColor = destructive ? theme.colors.negative : theme.colors.text;
  return /*#__PURE__*/_jsxs(TouchableOpacity, {
    onPress: onPress,
    disabled: disabled,
    activeOpacity: 0.6,
    testID: testID,
    style: [styles.item, disabled && styles.disabled],
    children: [icon && /*#__PURE__*/_jsx(View, {
      style: styles.iconWrapper,
      children: icon
    }), /*#__PURE__*/_jsxs(View, {
      style: styles.textWrapper,
      children: [/*#__PURE__*/_jsx(Text, {
        style: [styles.label, {
          color: labelColor
        }],
        children: label
      }), description && /*#__PURE__*/_jsx(Text, {
        style: [styles.description, {
          color: theme.colors.textSecondary
        }],
        children: description
      })]
    })]
  });
}
export const Item = /*#__PURE__*/memo(ItemComponent);
Item.displayName = 'GroupedButtons.Item';

// ── GroupedButtons ───────────────────────────────────────────────

function GroupedButtonsComponent({
  children,
  style
}) {
  const theme = useTheme();
  const childArray = Children.toArray(children);
  return /*#__PURE__*/_jsx(View, {
    style: [styles.container, {
      backgroundColor: theme.colors.card
    }, style],
    children: childArray.map((child, index) => /*#__PURE__*/_jsxs(React.Fragment, {
      children: [child, index < childArray.length - 1 && /*#__PURE__*/_jsx(View, {
        style: [styles.divider, {
          backgroundColor: theme.colors.borderLight
        }]
      })]
    }, index))
  });
}
const GroupedButtonsMemo = /*#__PURE__*/memo(GroupedButtonsComponent);
GroupedButtonsMemo.displayName = 'GroupedButtons';
export const GroupedButtons = Object.assign(GroupedButtonsMemo, {
  Item
});

// ── Styles ──────────────────────────────────────────────────────

const styles = StyleSheet.create({
  container: {
    borderRadius: 12,
    overflow: 'hidden'
  },
  divider: {
    height: 1,
    marginLeft: 16
  },
  item: {
    flexDirection: 'row',
    alignItems: 'center',
    paddingVertical: 12,
    paddingHorizontal: 16
  },
  disabled: {
    opacity: 0.5
  },
  iconWrapper: {
    marginRight: 12
  },
  textWrapper: {
    flex: 1
  },
  label: {
    fontSize: 16
  },
  description: {
    fontSize: 13,
    marginTop: 2
  }
});
//# sourceMappingURL=GroupedButtons.js.map