function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import React, { useState } from 'react';
import styles from "./index.module.less";
import { AntVBanner } from "./AntVBanner";
import { PromptTextarea } from "./PromptTextarea";
import { RecommendCase } from "./RecommendCase";
import { ModeSelector } from "./ModeSelector";
import classnames from 'classnames';
import { useLocale } from 'dumi';
import { AIChatStore } from "../../../model/AIChat";
import { useSnapshot } from "valtio";
export function HomeDialog(props) {
  var locale = useLocale();
  var lang = locale.id === 'zh' ? 'zh' : 'en';
  var snap = useSnapshot(AIChatStore);
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    promptText = _useState2[0],
    setPromptText = _useState2[1];
  var _useState3 = useState(''),
    _useState4 = _slicedToArray(_useState3, 2),
    _fileSummary = _useState4[0],
    setFileSummary = _useState4[1];
  var handleConfirm = function handleConfirm() {
    // 在新标签页打开新站点，携带问题参数，并将选择的技术栈拼接在消息前面
    var libPrefix = snap.lib ? lang === 'zh' ? "\u4F7F\u7528".concat(snap.lib, "\u65F6\uFF0C") : "When using ".concat(snap.lib, ", ") : '';
    var encodedMessage = encodeURIComponent("".concat(libPrefix).concat(promptText));
    var targetUrl = "https://sive.antv.antgroup.com/qa?message=".concat(encodedMessage);
    window.open(targetUrl, '_blank', 'noopener,noreferrer');
  };
  return /*#__PURE__*/React.createElement("div", {
    className: classnames(styles.content, props.className),
    style: props.style
  }, /*#__PURE__*/React.createElement(AntVBanner, null), /*#__PURE__*/React.createElement(ModeSelector, {
    onChange: function onChange(v) {
      AIChatStore.mode = v;
    },
    value: snap.mode
  }), /*#__PURE__*/React.createElement(PromptTextarea, {
    value: promptText,
    onChange: function onChange(val) {
      setPromptText(val);
    },
    onConfirm: handleConfirm,
    skipLoginCheck: true,
    sendButtonTip: lang === 'zh' ? '现智能问答功能已迁移到 AntV 新站点 Sive，点击发送后将自动为您跳转' : 'Smart Q&A has been migrated to AntV Sive. You will be redirected automatically after clicking send.',
    style: props.promptTextareaStyle,
    onDataSummaryChange: setFileSummary
  }), /*#__PURE__*/React.createElement(RecommendCase, {
    className: props.recommendCaseClassName,
    onClick: function onClick(val) {
      if (val !== null && val !== void 0 && val.query) {
        setPromptText(val.query[lang]);
      }
    }
  }));
}