"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ProgressTypingIndicator = exports.MinimalTypingIndicator = exports.CustomTypingIndicatorExamples = exports.ChatBubbleTypingIndicator = exports.AIProcessingIndicator = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _native = _interopRequireDefault(require("styled-components/native"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/* eslint-disable react-hooks/rules-of-hooks -- pre-existing port artifacts; hooks called conditionally / inside helpers. TODO: refactor */

const AIWrapper = _native.default.View`
  flex-direction: row;
  align-items: center;
  background-color: #667eea; /* можно заменить на градиент через rn-linear-gradient */
  padding: 12px 20px;
  border-radius: 25px;

  /* тень iOS */
  shadow-color: #667eea;
  shadow-opacity: 0.3;
  shadow-offset: 0px 4px;
  shadow-radius: 10px;

  /* тень Android */
  elevation: 3;
`;
const AIAvatar = _native.default.View`
  width: 24px;
  height: 24px;
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.2);
  align-items: center;
  justify-content: center;
  margin-right: 8px;
`;
const AIAvatarText = _native.default.Text`
  color: #fff;
  font-size: 12px;
  font-weight: 600;
`;
const AIText = _native.default.Text`
  color: #fff;
  font-size: 14px;
  font-weight: 500;
`;
const AnimatedAIWrapper = (0, _native.default)(_reactNative.Animated.View)``;
const AIProcessingIndicator = ({
  text,
  isVisible
}) => {
  if (!isVisible) {
    return null;
  }
  const scale = (0, _react.useRef)(new _reactNative.Animated.Value(1)).current;
  const opacity = (0, _react.useRef)(new _reactNative.Animated.Value(0.6)).current;
  (0, _react.useEffect)(() => {
    const loop = _reactNative.Animated.loop(_reactNative.Animated.parallel([_reactNative.Animated.sequence([_reactNative.Animated.timing(scale, {
      toValue: 1.05,
      duration: 1000,
      easing: _reactNative.Easing.inOut(_reactNative.Easing.ease),
      useNativeDriver: true
    }), _reactNative.Animated.timing(scale, {
      toValue: 1,
      duration: 1000,
      easing: _reactNative.Easing.inOut(_reactNative.Easing.ease),
      useNativeDriver: true
    })]), _reactNative.Animated.sequence([_reactNative.Animated.timing(opacity, {
      toValue: 1,
      duration: 1000,
      easing: _reactNative.Easing.inOut(_reactNative.Easing.ease),
      useNativeDriver: true
    }), _reactNative.Animated.timing(opacity, {
      toValue: 0.6,
      duration: 1000,
      easing: _reactNative.Easing.inOut(_reactNative.Easing.ease),
      useNativeDriver: true
    })])]));
    loop.start();
    return () => loop.stop();
  }, [opacity, scale]);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedAIWrapper, {
    style: {
      transform: [{
        scale
      }],
      opacity
    },
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(AIWrapper, {
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(AIAvatar, {
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AIAvatarText, {
          children: "AI"
        })
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(AIText, {
        children: text
      })]
    })
  });
};
exports.AIProcessingIndicator = AIProcessingIndicator;
const MinWrapper = _native.default.View`
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 8px;
`;
const Dot = (0, _native.default)(_reactNative.Animated.View)`
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background-color: #666;
  margin: 0 2px;
`;
const MinimalTypingIndicator = ({
  isVisible
}) => {
  if (!isVisible) {
    return null;
  }
  const makeOpacity = delay => {
    const o = new _reactNative.Animated.Value(0.2);
    (0, _react.useEffect)(() => {
      const loop = _reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(o, {
        toValue: 1,
        duration: 350,
        delay,
        useNativeDriver: true
      }), _reactNative.Animated.timing(o, {
        toValue: 0.2,
        duration: 700,
        useNativeDriver: true
      })]));
      loop.start();
      return () => loop.stop();
    }, []);
    return o;
  };
  const o1 = makeOpacity(0);
  const o2 = makeOpacity(200);
  const o3 = makeOpacity(400);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(MinWrapper, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Dot, {
      style: {
        opacity: o1
      }
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Dot, {
      style: {
        opacity: o2
      }
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Dot, {
      style: {
        opacity: o3
      }
    })]
  });
};
exports.MinimalTypingIndicator = MinimalTypingIndicator;
const Bubble = _native.default.View`
  background-color: #f0f0f0;
  border-radius: 18px;
  padding: 8px 16px;
  margin: 4px 0;
  align-self: flex-start;
  max-width: 240px;
`;
const BubbleText = _native.default.Text`
  font-size: 14px;
  color: #666;
`;
const BubbleTail = _native.default.View`
  position: absolute;
  bottom: -6px;
  left: 20px;
  width: 0px;
  height: 0px;
  border-left-width: 6px;
  border-right-width: 6px;
  border-top-width: 6px;
  border-left-color: transparent;
  border-right-color: transparent;
  border-top-color: #f0f0f0;
`;
const BubbleWrapper = _native.default.View`
  position: relative;
  align-self: flex-start;
`;
const ChatBubbleTypingIndicator = ({
  text,
  isVisible
}) => {
  if (!isVisible) {
    return null;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(BubbleWrapper, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Bubble, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BubbleText, {
        children: text
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(BubbleTail, {})]
  });
};
exports.ChatBubbleTypingIndicator = ChatBubbleTypingIndicator;
const ProgressWrap = _native.default.View`
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 8px 16px;
  flex-direction: row;
  align-items: center;
`;
const ProgressLabel = _native.default.Text`
  font-size: 12px;
  color: #666;
  margin-right: 8px;
`;
const Bar = _native.default.View`
  width: 60px;
  height: 4px;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  overflow: hidden;
`;
const Runner = (0, _native.default)(_reactNative.Animated.View)`
  width: 60px;
  height: 4px;
  background-color: #007bff;
`;
const ProgressTypingIndicator = ({
  text,
  isVisible
}) => {
  if (!isVisible) {
    return null;
  }
  const tx = (0, _react.useRef)(new _reactNative.Animated.Value(-60)).current;
  (0, _react.useEffect)(() => {
    const loop = _reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(tx, {
      toValue: 60,
      duration: 1500,
      easing: _reactNative.Easing.linear,
      useNativeDriver: true
    }), _reactNative.Animated.timing(tx, {
      toValue: -60,
      duration: 0,
      useNativeDriver: true
    })]));
    loop.start();
    return () => loop.stop();
  }, [tx]);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(ProgressWrap, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ProgressLabel, {
      children: text
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Bar, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Runner, {
        style: {
          transform: [{
            translateX: tx
          }]
        }
      })
    })]
  });
};
exports.ProgressTypingIndicator = ProgressTypingIndicator;
const CustomTypingIndicatorExamples = exports.CustomTypingIndicatorExamples = {
  AIProcessingIndicator,
  MinimalTypingIndicator,
  ChatBubbleTypingIndicator,
  ProgressTypingIndicator
};
//# sourceMappingURL=CustomTypingIndicatorExamples.js.map