import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { useField } from 'formik';
import { P as PhoneNumberInput, g as getPhoneData, S as SingleValue } from './phone-number-HpVGHffA.js';
export { i as isPhoneNumberValid, v as validation } from './phone-number-HpVGHffA.js';
import { jsx, jsxs } from 'react/jsx-runtime';
import { memo } from 'react';
import classnames from 'classnames';
import { isNotPresent } from '@bigbinary/neeto-cist';
import Typography from '@bigbinary/neetoui/Typography';
import Button from '@bigbinary/neetoui/Button';
import CopyToClipboardButton from './CopyToClipboardButton.js';
import '@tanstack/react-query';
import 'libphonenumber-js/min';
import '@bigbinary/neetoui/Input';
import '@bigbinary/neetoui/Select';
import 'react-i18next';
import './_commonjsHelpers-BFTU3MAI.js';
import 'ramda';
import '@bigbinary/neetoui/Tooltip';
import '@babel/runtime/helpers/asyncToGenerator';
import 'i18next';
import '@bigbinary/neeto-commons-frontend/utils';
import 'yup';
import 'axios';
import './inject-css-C2dztUxs.js';
import '@bigbinary/neeto-commons-frontend/utils/general';
import '@bigbinary/neeto-icons/Copy';
import '@bigbinary/neeto-icons/Check';

var _excluded$1 = ["name"];
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var FormikPhoneNumberInput = function FormikPhoneNumberInput(_ref) {
  var name = _ref.name,
    props = _objectWithoutProperties(_ref, _excluded$1);
  var _useField = useField(name),
    _useField2 = _slicedToArray(_useField, 3),
    field = _useField2[0],
    meta = _useField2[1],
    setValue = _useField2[2].setValue;
  return /*#__PURE__*/jsx(PhoneNumberInput, _objectSpread$1(_objectSpread$1({}, field), {}, {
    error: meta.touched ? meta.error : "",
    onChange: setValue
  }, props));
};

var _excluded = ["className", "defaultCountry", "value", "showEmoji", "children", "linkable", "linkPrefix", "showCopyButton"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var PhoneNumber = function PhoneNumber(_ref) {
  var className = _ref.className,
    _ref$defaultCountry = _ref.defaultCountry,
    defaultCountry = _ref$defaultCountry === void 0 ? "IN" : _ref$defaultCountry,
    value = _ref.value,
    _ref$showEmoji = _ref.showEmoji,
    showEmoji = _ref$showEmoji === void 0 ? false : _ref$showEmoji,
    children = _ref.children,
    _ref$linkable = _ref.linkable,
    linkable = _ref$linkable === void 0 ? false : _ref$linkable,
    _ref$linkPrefix = _ref.linkPrefix,
    linkPrefix = _ref$linkPrefix === void 0 ? "tel:" : _ref$linkPrefix,
    _ref$showCopyButton = _ref.showCopyButton,
    showCopyButton = _ref$showCopyButton === void 0 ? false : _ref$showCopyButton,
    otherProps = _objectWithoutProperties(_ref, _excluded);
  if (isNotPresent(value) && isNotPresent(children)) return null;
  var _getPhoneData = getPhoneData(value || children, defaultCountry),
    international = _getPhoneData.international,
    countryCode = _getPhoneData.countryCode;
  var link = linkable ? "".concat(linkPrefix).concat(value) : undefined;
  return /*#__PURE__*/jsxs("div", {
    className: classnames(["flex items-center gap-x-2", className]),
    children: [/*#__PURE__*/jsx(SingleValue, _objectSpread({}, _objectSpread({
      countryCode: countryCode,
      showEmoji: showEmoji
    }, otherProps))), /*#__PURE__*/jsx(Typography, _objectSpread(_objectSpread({
      style: "body2"
    }, otherProps), {}, {
      children: linkable ? /*#__PURE__*/jsx(Button, {
        className: "neeto-molecules-phone-number truncate",
        "data-testid": "phone-number-link",
        href: link,
        style: "link",
        children: international
      }) : international
    })), showCopyButton && /*#__PURE__*/jsx(CopyToClipboardButton, {
      className: "flex-shrink-0",
      size: "small",
      style: "text",
      value: international
    })]
  });
};
var PhoneNumber$1 = /*#__PURE__*/memo(PhoneNumber);

export { FormikPhoneNumberInput, PhoneNumber$1 as PhoneNumber, PhoneNumberInput };
//# sourceMappingURL=PhoneNumber.js.map
