import _Input from "antd/es/input";
// import * as React from 'react';
import "./index.css";
import * as XLSX from 'xlsx';
var headerMap1 = {
  "area": "地区",
  "community": "评论",
  "idc": "idc",
  "idc_community": "idc_community",
  "asn": "asn"
};
export default function FileUploadComponent(props) {
  var onChange = props.onChange;
  var onImportExcel = function onImportExcel(e, headerMap, handleResCallback, errorCallback) {
    if (headerMap === void 0) {
      headerMap = headerMap1;
    }
    var _e$target = e === null || e === void 0 ? void 0 : e.target,
      files = _e$target.files;
    if (!files) return;
    var file = files[0];
    var fileReader = new FileReader();
    fileReader.readAsBinaryString(file);
    fileReader.onload = function (event) {
      try {
        var result = event.target.result;
        var wb = XLSX.read(result, {
          type: 'binary'
        });
        var res = [];
        for (var sheet in wb.Sheets) {
          if (wb.Sheets.hasOwnProperty(sheet)) {
            console.log('sheet==', sheet);
            var data = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
            console.log('data===', data);
            res = res.concat(data);
          }
        }
        onChange(res);
      } catch (e) {
        console.log('error==', e);
      }
    };
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "Editor"
  }, /*#__PURE__*/React.createElement(_Input, {
    id: "upfile",
    type: "file",
    accept: ".xlsx",
    onChange: onImportExcel
  }));
}

// export default class EditorComponent extends React.Component<any, EditorComponentProps, void> {
//   width: any;
//   height: any;
//   language: any;
//   theme: string;
//   constructor(props) {
//     super(props);
//     this.width = props.width || '100%';
//     this.height = props.height || '500';
//     this.language = props.language || 'powershell';
//     this.theme = 'vs-dark';
//     // const { width = '100%', height = '500', language = 'powershell', theme = 'vs-dark', ...others } = props;
//   }
//   render() {
//     return (
//         <MonacoEditor 
//           width={this.width}
//           height={this.height}
//           language={this.language}
//           theme={this.theme}
//         // {...others}
//       />
//     )
//   }
// }