'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var React = require('react');
var React__default = _interopDefault(React);
var nutuiReact = require('@nutui/nutui-react');
require('@nutui/nutui-react/dist/style.css');
var ReactDOM = _interopDefault(require('react-dom'));

function styleInject(css, ref) {
  if ( ref === void 0 ) ref = {};
  var insertAt = ref.insertAt;

  if (!css || typeof document === 'undefined') { return; }

  var head = document.head || document.getElementsByTagName('head')[0];
  var style = document.createElement('style');
  style.type = 'text/css';

  if (insertAt === 'top') {
    if (head.firstChild) {
      head.insertBefore(style, head.firstChild);
    } else {
      head.appendChild(style);
    }
  } else {
    head.appendChild(style);
  }

  if (style.styleSheet) {
    style.styleSheet.cssText = css;
  } else {
    style.appendChild(document.createTextNode(css));
  }
}

var css_248z = ".title-module_container__eMlrC {\n    display: flex;\n    flex-direction: row;\n}\n\n.title-module_title__FvqO4 {\n    color: #000;\n    font-size: 14px;\n    font-weight: bold;\n}\n\n.title-module_must__Flydy {\n    color: #FA2C19;\n    font-size: 14px;\n    font-weight: bold;\n    margin-left: 4px;\n}";
var TitleStyle = {"container":"title-module_container__eMlrC","title":"title-module_title__FvqO4","must":"title-module_must__Flydy"};
styleInject(css_248z);

function CommonTitle(props) {
  return React__default.createElement("div", {
    className: TitleStyle.container
  }, React__default.createElement("div", {
    className: TitleStyle.title
  }, props == null ? void 0 : props.title), props != null && props.must ? React__default.createElement("div", {
    className: TitleStyle.must
  }, "*") : null);
}

var css_248z$1 = ".uploader-module_container__EudrL {\n  margin-top: 4px;\n  display: flex;\n  flex-direction: column;\n}\n\n.uploader-module_uploader__uh-72 {\n    --nutui-uploader-preview-margin-right: 6px;\n    --nutui-uploader-image-width: 60px;\n    --nutui-uploader-image-height: 60px;\n    --nutui-uploader-image-border-radius: 4px;\n    --nutui-uploader-preview-margin-bottom: 6px;\n    --nutui-uploader-preview-close-right:2px;\n    --nutui-uploader-preview-close-top:2px;\n}\n\n.uploader-module_tip__-vHPF {\n  margin-top: 4px;\n  font-size: 12px;\n  color: #999;\n}\n";
var UploaderStyle = {"container":"uploader-module_container__EudrL","uploader":"uploader-module_uploader__uh-72","tip":"uploader-module_tip__-vHPF"};
styleInject(css_248z$1);

var UploadIcon = /*#__PURE__*/React__default.createElement("div", {
  style: {
    width: "60px",
    height: "60px",
    borderRadius: "4px"
  }
}, /*#__PURE__*/React__default.createElement("img", {
  src: "https://storage.360buyimg.com/jmfe-m-dongdong/icons/up_pic.png",
  style: {
    width: "46px",
    height: "46px",
    marginTop: "7px",
    marginLeft: "7px"
  }
}));

function _regeneratorRuntime() {
  _regeneratorRuntime = function () {
    return e;
  };
  var t,
    e = {},
    r = Object.prototype,
    n = r.hasOwnProperty,
    o = Object.defineProperty || function (t, e, r) {
      t[e] = r.value;
    },
    i = "function" == typeof Symbol ? Symbol : {},
    a = i.iterator || "@@iterator",
    c = i.asyncIterator || "@@asyncIterator",
    u = i.toStringTag || "@@toStringTag";
  function define(t, e, r) {
    return Object.defineProperty(t, e, {
      value: r,
      enumerable: !0,
      configurable: !0,
      writable: !0
    }), t[e];
  }
  try {
    define({}, "");
  } catch (t) {
    define = function (t, e, r) {
      return t[e] = r;
    };
  }
  function wrap(t, e, r, n) {
    var i = e && e.prototype instanceof Generator ? e : Generator,
      a = Object.create(i.prototype),
      c = new Context(n || []);
    return o(a, "_invoke", {
      value: makeInvokeMethod(t, r, c)
    }), a;
  }
  function tryCatch(t, e, r) {
    try {
      return {
        type: "normal",
        arg: t.call(e, r)
      };
    } catch (t) {
      return {
        type: "throw",
        arg: t
      };
    }
  }
  e.wrap = wrap;
  var h = "suspendedStart",
    l = "suspendedYield",
    f = "executing",
    s = "completed",
    y = {};
  function Generator() {}
  function GeneratorFunction() {}
  function GeneratorFunctionPrototype() {}
  var p = {};
  define(p, a, function () {
    return this;
  });
  var d = Object.getPrototypeOf,
    v = d && d(d(values([])));
  v && v !== r && n.call(v, a) && (p = v);
  var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
  function defineIteratorMethods(t) {
    ["next", "throw", "return"].forEach(function (e) {
      define(t, e, function (t) {
        return this._invoke(e, t);
      });
    });
  }
  function AsyncIterator(t, e) {
    function invoke(r, o, i, a) {
      var c = tryCatch(t[r], t, o);
      if ("throw" !== c.type) {
        var u = c.arg,
          h = u.value;
        return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
          invoke("next", t, i, a);
        }, function (t) {
          invoke("throw", t, i, a);
        }) : e.resolve(h).then(function (t) {
          u.value = t, i(u);
        }, function (t) {
          return invoke("throw", t, i, a);
        });
      }
      a(c.arg);
    }
    var r;
    o(this, "_invoke", {
      value: function (t, n) {
        function callInvokeWithMethodAndArg() {
          return new e(function (e, r) {
            invoke(t, n, e, r);
          });
        }
        return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
      }
    });
  }
  function makeInvokeMethod(e, r, n) {
    var o = h;
    return function (i, a) {
      if (o === f) throw new Error("Generator is already running");
      if (o === s) {
        if ("throw" === i) throw a;
        return {
          value: t,
          done: !0
        };
      }
      for (n.method = i, n.arg = a;;) {
        var c = n.delegate;
        if (c) {
          var u = maybeInvokeDelegate(c, n);
          if (u) {
            if (u === y) continue;
            return u;
          }
        }
        if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
          if (o === h) throw o = s, n.arg;
          n.dispatchException(n.arg);
        } else "return" === n.method && n.abrupt("return", n.arg);
        o = f;
        var p = tryCatch(e, r, n);
        if ("normal" === p.type) {
          if (o = n.done ? s : l, p.arg === y) continue;
          return {
            value: p.arg,
            done: n.done
          };
        }
        "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
      }
    };
  }
  function maybeInvokeDelegate(e, r) {
    var n = r.method,
      o = e.iterator[n];
    if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
    var i = tryCatch(o, e.iterator, r.arg);
    if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
    var a = i.arg;
    return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
  }
  function pushTryEntry(t) {
    var e = {
      tryLoc: t[0]
    };
    1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
  }
  function resetTryEntry(t) {
    var e = t.completion || {};
    e.type = "normal", delete e.arg, t.completion = e;
  }
  function Context(t) {
    this.tryEntries = [{
      tryLoc: "root"
    }], t.forEach(pushTryEntry, this), this.reset(!0);
  }
  function values(e) {
    if (e || "" === e) {
      var r = e[a];
      if (r) return r.call(e);
      if ("function" == typeof e.next) return e;
      if (!isNaN(e.length)) {
        var o = -1,
          i = function next() {
            for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
            return next.value = t, next.done = !0, next;
          };
        return i.next = i;
      }
    }
    throw new TypeError(typeof e + " is not iterable");
  }
  return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
    value: GeneratorFunctionPrototype,
    configurable: !0
  }), o(GeneratorFunctionPrototype, "constructor", {
    value: GeneratorFunction,
    configurable: !0
  }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
    var e = "function" == typeof t && t.constructor;
    return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
  }, e.mark = function (t) {
    return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
  }, e.awrap = function (t) {
    return {
      __await: t
    };
  }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
    return this;
  }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
    void 0 === i && (i = Promise);
    var a = new AsyncIterator(wrap(t, r, n, o), i);
    return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
      return t.done ? t.value : a.next();
    });
  }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
    return this;
  }), define(g, "toString", function () {
    return "[object Generator]";
  }), e.keys = function (t) {
    var e = Object(t),
      r = [];
    for (var n in e) r.push(n);
    return r.reverse(), function next() {
      for (; r.length;) {
        var t = r.pop();
        if (t in e) return next.value = t, next.done = !1, next;
      }
      return next.done = !0, next;
    };
  }, e.values = values, Context.prototype = {
    constructor: Context,
    reset: function (e) {
      if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
    },
    stop: function () {
      this.done = !0;
      var t = this.tryEntries[0].completion;
      if ("throw" === t.type) throw t.arg;
      return this.rval;
    },
    dispatchException: function (e) {
      if (this.done) throw e;
      var r = this;
      function handle(n, o) {
        return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
      }
      for (var o = this.tryEntries.length - 1; o >= 0; --o) {
        var i = this.tryEntries[o],
          a = i.completion;
        if ("root" === i.tryLoc) return handle("end");
        if (i.tryLoc <= this.prev) {
          var c = n.call(i, "catchLoc"),
            u = n.call(i, "finallyLoc");
          if (c && u) {
            if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
            if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
          } else if (c) {
            if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
          } else {
            if (!u) throw new Error("try statement without catch or finally");
            if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
          }
        }
      }
    },
    abrupt: function (t, e) {
      for (var r = this.tryEntries.length - 1; r >= 0; --r) {
        var o = this.tryEntries[r];
        if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
          var i = o;
          break;
        }
      }
      i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
      var a = i ? i.completion : {};
      return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
    },
    complete: function (t, e) {
      if ("throw" === t.type) throw t.arg;
      return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
    },
    finish: function (t) {
      for (var e = this.tryEntries.length - 1; e >= 0; --e) {
        var r = this.tryEntries[e];
        if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
      }
    },
    catch: function (t) {
      for (var e = this.tryEntries.length - 1; e >= 0; --e) {
        var r = this.tryEntries[e];
        if (r.tryLoc === t) {
          var n = r.completion;
          if ("throw" === n.type) {
            var o = n.arg;
            resetTryEntry(r);
          }
          return o;
        }
      }
      throw new Error("illegal catch attempt");
    },
    delegateYield: function (e, r, n) {
      return this.delegate = {
        iterator: values(e),
        resultName: r,
        nextLoc: n
      }, "next" === this.method && (this.arg = t), y;
    }
  }, e;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  try {
    var info = gen[key](arg);
    var value = info.value;
  } catch (error) {
    reject(error);
    return;
  }
  if (info.done) {
    resolve(value);
  } else {
    Promise.resolve(value).then(_next, _throw);
  }
}
function _asyncToGenerator(fn) {
  return function () {
    var self = this,
      args = arguments;
    return new Promise(function (resolve, reject) {
      var gen = fn.apply(self, args);
      function _next(value) {
        asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
      }
      function _throw(err) {
        asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
      }
      _next(undefined);
    });
  };
}

var MAX_FILE_SIZE = 20 * 1000 * 1000;
// 文件转base64
var fileToDataURL = function fileToDataURL(file) {
  return new Promise(function (resolve) {
    var reader = new FileReader();
    reader.onloadend = function (e) {
      return resolve(e.target.result);
    };
    reader.readAsDataURL(file);
  });
};
// base64转图片
var dataURLToImage = function dataURLToImage(dataURL) {
  return new Promise(function (resolve) {
    var img = new Image();
    img.onload = function () {
      return resolve(img);
    };
    img.src = dataURL;
  });
};
// cavans转文件
var canvastoFile = function canvastoFile(canvas, type, quality) {
  return new Promise(function (resolve) {
    return canvas.toBlob(function (blob) {
      return resolve(blob);
    }, type, quality);
  });
};
// 批量压缩图片
var compressImgs = /*#__PURE__*/function () {
  var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(files) {
    return _regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          _context.next = 2;
          return files.map(function (file) {
            return compressImg(file);
          });
        case 2:
          return _context.abrupt("return", files);
        case 3:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
  return function compressImgs(_x) {
    return _ref.apply(this, arguments);
  };
}();
// 压缩图片
var compressImg = /*#__PURE__*/function () {
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file) {
    var canvas, context, base64, img, blob, f;
    return _regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) switch (_context2.prev = _context2.next) {
        case 0:
          if (!(file.size < MAX_FILE_SIZE)) {
            _context2.next = 2;
            break;
          }
          return _context2.abrupt("return", file);
        case 2:
          canvas = document.createElement('canvas');
          context = canvas.getContext('2d');
          _context2.next = 6;
          return fileToDataURL(file);
        case 6:
          base64 = _context2.sent;
          _context2.next = 9;
          return dataURLToImage(base64);
        case 9:
          img = _context2.sent;
          canvas.width = img.width;
          canvas.height = img.height;
          context.clearRect(0, 0, img.width, img.height);
          context.drawImage(img, 0, 0, img.width, img.height);
          _context2.next = 16;
          return canvastoFile(canvas, 'image/jpeg', 0.5);
        case 16:
          blob = _context2.sent;
          _context2.next = 19;
          return new File([blob], file.name, {
            type: file.type
          });
        case 19:
          f = _context2.sent;
          return _context2.abrupt("return", f);
        case 21:
        case "end":
          return _context2.stop();
      }
    }, _callee2);
  }));
  return function compressImg(_x2) {
    return _ref2.apply(this, arguments);
  };
}();

var ImgUploader = function ImgUploader(props) {
  var uploadUrl = "https://file-dd.jd.com/file/uploadImg.action";
  var curStatus = "";
  var operateFileList = [];
  var _useState = React.useState(0),
    showPreview = _useState[0],
    setShowPreview = _useState[1];
  var _useState2 = React.useState([]),
    previewImgs = _useState2[0],
    setPreviewImgs = _useState2[1];
  var onUploadFailed = function onUploadFailed(resp) {
    onStatusChange(resp.files);
  };
  var onUploadSuccess = function onUploadSuccess(resp) {
    onStatusChange(resp.files);
    onResult(resp.files);
  };
  var onImgDelete = function onImgDelete(delItem, items) {
    onStatusChange(items, delItem);
    onResult(items);
  };
  var showImgPreview = function showImgPreview(_file, index) {
    setShowPreview(index + 1);
  };
  var hideImgPreview = function hideImgPreview() {
    setShowPreview(0);
  };
  var onResult = function onResult(items) {
    var result = [];
    items.forEach(function (fileItem) {
      if (fileItem.status === "success") {
        if (fileItem.responseText) {
          var resp = JSON.parse(fileItem.responseText);
          if (resp && resp.code === 200 && resp.path) {
            result.push(resp.path);
          }
        }
      }
    });
    props.onResult == null || props.onResult(result);
  };
  var onStatusChange = function onStatusChange(items, delItem) {
    var newStatus = "finish";
    for (var index = 0; index < items.length; index++) {
      var fileItem = items[index];
      if (fileItem.uid !== (delItem == null ? void 0 : delItem.uid) && fileItem.status === "uploading") {
        newStatus = "uploading";
        break;
      }
    }
    if (curStatus !== newStatus) {
      curStatus = newStatus;
      props.onUploadStatusChange == null || props.onUploadStatusChange(curStatus);
    }
    setPreviewImgs(items.flatMap(function (item) {
      var _item$url;
      return {
        src: (_item$url = item.url) != null ? _item$url : ""
      };
    }));
  };
  return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
    style: props.styles
  }, props != null && props.title ? React__default.createElement(CommonTitle, {
    title: props.title,
    must: props.must
  }) : null, React__default.createElement("div", {
    className: UploaderStyle.container
  }, React__default.createElement(nutuiReact.Uploader, {
    className: UploaderStyle.uploader,
    accept: "image/*",
    url: uploadUrl,
    name: "upload",
    data: props.uploadData,
    defaultValue: operateFileList,
    uploadIcon: UploadIcon,
    maxCount: props.limit,
    deletable: true,
    fit: "cover",
    multiple: true,
    timeout: 30000,
    beforeUpload: props.enableCompress ? compressImgs : undefined,
    onSuccess: onUploadSuccess,
    onFailure: onUploadFailed,
    onDelete: onImgDelete,
    onFileItemClick: showImgPreview
  }), props.limit ? React__default.createElement("div", {
    className: UploaderStyle.tip
  }, "\u56FE\u7247\u6700\u591A\u4E0A\u4F20", props.limit, "\u5F20") : null)), React__default.createElement(nutuiReact.ImagePreview, {
    images: previewImgs,
    visible: showPreview > 0,
    defaultValue: showPreview,
    onClose: hideImgPreview,
    closeOnContentClick: true
  }));
};

var css_248z$2 = ".input-module_container__GAqzD {\n  margin-top: 4px;\n  padding-top: 8px;\n  padding-bottom: 8px;\n  padding-left: 14px;\n  padding-right: 14px;\n  width: 100%;\n  background-color: #f4f4f4;\n  border-radius: 4px;\n  height: 116px;\n  display: flex;\n  flex-direction: column;\n  justify-content: space-between;\n  box-sizing: border-box;\n}\n\n.input-module_input__F72vK {\n  background: none;\n  font-size: 14px;\n  color: #666;\n  border: none;\n  outline: none;\n  box-shadow: none;\n  -webkit-box-shadow: none;\n  flex-grow: 1;\n  vertical-align: top;\n  resize: none;\n  &::placeholder {\n    color: #999;\n  }\n}\n\n.input-module_limit__aAGNx {\n    height: auto;\n    align-self: flex-end;\n    padding: 0;\n    margin: 0;\n}\n\n.input-module_tip__9JEUT {\n  margin-top: 4px;\n  font-size: 12px;\n  color: #999;\n}\n";
var InputStyle = {"container":"input-module_container__GAqzD","input":"input-module_input__F72vK","limit":"input-module_limit__aAGNx","tip":"input-module_tip__9JEUT"};
styleInject(css_248z$2);

function LimitInput(props) {
  var _useState = React.useState(0),
    curLength = _useState[0],
    setLength = _useState[1];
  var compositionRef = React.useRef(true);
  var inputRef = React.useRef(null);
  var handleTextChange = function handleTextChange() {
    if (compositionRef.current) {
      var _inputRef$current;
      var length = inputRef == null || (_inputRef$current = inputRef.current) == null || (_inputRef$current = _inputRef$current.value) == null ? void 0 : _inputRef$current.length;
      setLength(length != null ? length : 0);
      if (typeof (props == null ? void 0 : props.onTextChanged) === "function") {
        var _inputRef$current$val, _inputRef$current2;
        props == null || props.onTextChanged((_inputRef$current$val = inputRef == null || (_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.value) != null ? _inputRef$current$val : "");
      }
    }
  };
  var handleComposition = function handleComposition(event) {
    if ("compositionend" === event.type) {
      compositionRef.current = true;
      handleTextChange();
    } else {
      compositionRef.current = false;
    }
  };
  return React__default.createElement("div", {
    style: props == null ? void 0 : props.styles
  }, props != null && props.title ? React__default.createElement(CommonTitle, {
    title: props.title,
    must: props.must
  }) : null, React__default.createElement("div", {
    className: InputStyle.container
  }, React__default.createElement("textarea", {
    ref: inputRef,
    className: InputStyle.input,
    placeholder: props == null ? void 0 : props.inputHint,
    maxLength: props == null ? void 0 : props.maxLength,
    onChange: handleTextChange,
    onCompositionStart: handleComposition,
    onCompositionEnd: handleComposition,
    onCompositionUpdate: handleComposition
  }), props.maxLength ? React__default.createElement("p", {
    className: InputStyle.limit
  }, React__default.createElement("span", {
    style: {
      color: curLength === (props == null ? void 0 : props.maxLength) ? "#F27724" : "#666",
      fontSize: "12px"
    }
  }, curLength), React__default.createElement("span", {
    style: {
      color: "#999",
      fontSize: "12px"
    }
  }, "/", props == null ? void 0 : props.maxLength)) : null), props != null && props.tip ? React__default.createElement("div", {
    className: InputStyle.tip
  }, props == null ? void 0 : props.tip) : null);
}

var css_248z$3 = ".modal-module_overlay__YpXKj {\n  position: fixed;\n  top: 0;\n  left: 0;\n  width: 100%;\n  height: 100%;\n  background-color: rgba(0, 0, 0, 0.6);\n  z-index: 1000;\n}\n\n.modal-module_container__ZLa-o {\n  position: fixed;\n  width: 72vw;\n  top: 50%;\n  left: 50%;\n  transform: translate(-50%, -50%);\n  background-color: white;\n  border-radius: 12px;\n  z-index: 1001;\n  display: flex;\n  flex-direction: column;\n  padding-top: 4px;\n  align-items: center;\n}\n\n.modal-module_title__Z1ZE4 {\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  width: 100%;\n  padding-top: 12px;\n  padding-left: 16px;\n  padding-right: 16px;\n  padding-bottom: 0;\n  color: #000;\n  font-size: 18px;\n  font-weight: bold;\n  margin: 0;\n  box-sizing: border-box;\n  text-align: center;\n}\n\n.modal-module_content__Rq325 {\n  width: 100%;\n  margin: 0;\n  padding-top: 12px;\n  padding-left: 16px;\n  padding-right: 16px;\n  padding-bottom: 0;\n  color: #000;\n  font-size: 14px;\n  font-weight: 400;\n  box-sizing: border-box;\n  text-align: center;\n}\n\n.modal-module_btnContainer__UsCjl {\n  width: 100%;\n  height: 44px;\n  display: flex;\n  flex-direction: row;\n  border-bottom-left-radius: 12px;\n  border-bottom-right-radius: 12px;\n  box-sizing: border-box;\n}\n\n.modal-module_btn__NDb9- {\n  background: none;\n  border: none;\n  padding: 0;\n  margin: 0;\n  height: 44px;\n  flex-grow: 1;\n  font-size: 17px;\n  font-weight: 500;\n}\n";
var ModalStyle = {"overlay":"modal-module_overlay__YpXKj","container":"modal-module_container__ZLa-o","title":"modal-module_title__Z1ZE4","content":"modal-module_content__Rq325","btnContainer":"modal-module_btnContainer__UsCjl","btn":"modal-module_btn__NDb9-"};
styleInject(css_248z$3);

var CommonModal = function CommonModal(props) {
  var _props$leftBtn2, _props$rightBtn2;
  var _useState = React.useState(props.show),
    isShow = _useState[0],
    setShow = _useState[1];
  var showLeftBtn = !!props.leftBtn;
  var showRightBtn = !!props.rightBtn;
  if (!isShow) {
    return null;
  }
  return ReactDOM.createPortal(React__default.createElement(React__default.Fragment, null, props.dimBackground ? React__default.createElement("div", {
    className: ModalStyle.overlay,
    onClick: props.dismissOnOutsideClick ? function () {
      return setShow(false);
    } : undefined
  }) : null, React__default.createElement("div", {
    className: ModalStyle.container
  }, props.title ? React__default.createElement("p", {
    className: ModalStyle.title
  }, props.title) : null, props.content ? React__default.createElement("p", {
    className: ModalStyle.content
  }, props.content) : null, React__default.createElement("div", {
    style: {
      width: "100%",
      height: "1px",
      backgroundColor: "#3c3c4356",
      marginTop: "16px"
    }
  }), React__default.createElement("div", {
    className: ModalStyle.btnContainer
  }, showLeftBtn ? React__default.createElement("button", {
    className: ModalStyle.btn,
    onClick: function onClick() {
      var _props$leftBtn;
      setShow(false);
      (_props$leftBtn = props.leftBtn) == null || _props$leftBtn.onClick == null || _props$leftBtn.onClick();
    }
  }, (_props$leftBtn2 = props.leftBtn) == null ? void 0 : _props$leftBtn2.btnText) : null, showLeftBtn && showRightBtn ? React__default.createElement("div", {
    style: {
      width: "1px",
      height: "100%",
      backgroundColor: "#3c3c4356"
    }
  }) : null, showRightBtn ? React__default.createElement("button", {
    className: ModalStyle.btn,
    style: {
      color: "#FA2C19"
    },
    onClick: function onClick() {
      var _props$rightBtn;
      setShow(false);
      (_props$rightBtn = props.rightBtn) == null || _props$rightBtn.onClick == null || _props$rightBtn.onClick();
    }
  }, (_props$rightBtn2 = props.rightBtn) == null ? void 0 : _props$rightBtn2.btnText) : null))), document.body);
};

var css_248z$4 = ".number_selector-module_selector__HdvC6 {\n  display: flex;\n  flex-direction: row;\n  justify-content: flex-start;\n  align-items: center;\n  margin-top: 10px;\n}\n.number_selector-module_selector__HdvC6 .number_selector-module_title__Ymnpe {\n  font-size: 12px;\n  color: #666666;\n}\n.number_selector-module_selector__HdvC6 .number_selector-module_button__n9Uok {\n  font-size: 14px;\n  color: #595959;\n  /* background-color: red; */\n  padding-left: 4px;\n  padding-right: 4px;\n}\n.number_selector-module_selector__HdvC6 .number_selector-module_number__El8nP {\n  background-color: #f4f4f4;\n  width: 30px;\n  height: 32px;\n  border-radius: 4px;\n  margin-left: 4px;\n  margin-right: 4px;\n  display: flex;\n  flex-direction: row;\n  justify-content: center;\n  align-items: center;\n}\n.number_selector-module_selector__HdvC6 .number_selector-module_number__El8nP .number_selector-module_text__ab-IO {\n  font-size: 12px;\n  color: #595959;\n}\n";
var NumberSelectorStyle = {"selector":"number_selector-module_selector__HdvC6","title":"number_selector-module_title__Ymnpe","button":"number_selector-module_button__n9Uok","number":"number_selector-module_number__El8nP","text":"number_selector-module_text__ab-IO"};
styleInject(css_248z$4);

/* eslint-disable react-hooks/exhaustive-deps */
function NumberSelector(props) {
  var _useState = React.useState(props.defaultValue),
    value = _useState[0],
    setValue = _useState[1];
  React.useEffect(function () {
    props.valueChanged(value);
  }, [value]);
  return React__default.createElement("div", {
    style: props.styles
  }, React__default.createElement(CommonTitle, Object.assign({}, props)), React__default.createElement("div", {
    className: NumberSelectorStyle.selector
  }, React__default.createElement("div", {
    className: NumberSelectorStyle.title
  }, "\u5546\u54C1\u6570\u91CF"), React__default.createElement("div", {
    style: {
      flex: 1
    }
  }), React__default.createElement("div", {
    className: NumberSelectorStyle.button,
    onClick: function onClick() {
      if (value > 1) {
        setValue(value - 1);
      }
    }
  }, "-"), React__default.createElement("div", {
    className: NumberSelectorStyle.number
  }, React__default.createElement("div", {
    className: NumberSelectorStyle.text
  }, value)), React__default.createElement("div", {
    className: NumberSelectorStyle.button,
    onClick: function onClick() {
      if (props.max) {
        if (value < props.max) {
          setValue(value + 1);
        }
      } else {
        setValue(value + 1);
      }
    }
  }, "+")));
}

var css_248z$5 = ".order-module_container__MoSOl {\n  display: flex;\n  flex-direction: column;\n  justify-content: flex-start;\n  align-items: flex-start;\n}\n\n.order-module_order__9sJ-Z {\n  display: flex;\n  flex-direction: row;\n  justify-content: flex-start;\n  align-items: center;\n  width: 100%;\n  /* background-color: red; */\n}\n.order-module_order__9sJ-Z .order-module_id__W-CFP {\n  font-size: 12px;\n  color: #999999;\n}\n\n.order-module_order__9sJ-Z .order-module_change_button__OIQOd {\n  padding-left: 12px;\n  padding-right: 12px;\n  padding-top: 5px;\n  padding-bottom: 5px;\n  font-size: 12px;\n  color: #333333;\n  border-radius: 19px;\n  border: solid 0.5px #999999;\n}\n\n.order-module_product__YUHaj {\n  display: flex;\n  flex-direction: row;\n  justify-content: flex-start;\n  align-items: flex-start;\n  width: 100%;\n  margin-top: 10px;\n}\n.order-module_product__YUHaj .order-module_img__Higta {\n  width: 60px;\n  height: 60px;\n  object-fit: cover;\n}\n.order-module_product__YUHaj .order-module_name__13ITC {\n  margin-left: 8px;\n  font-size: 14px;\n  color: #000000;\n  flex: 1;\n  display: -webkit-box;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 2;\n  overflow: hidden;\n}\n.order-module_product__YUHaj .order-module_info__A8BFm {\n  display: flex;\n  flex-direction: column;\n  justify-content: space-between;\n  align-items: flex-end;\n  height: 100%;\n  margin-left: 8px;\n  font-family: JDLZRegular;\n}\n.order-module_product__YUHaj .order-module_info__A8BFm .order-module_unit__rJSeR {\n  font-size: 10px;\n  color: black;\n}\n.order-module_product__YUHaj .order-module_info__A8BFm .order-module_price__qvUPC {\n  font-size: 12px;\n  color: black;\n}\n.order-module_product__YUHaj .order-module_info__A8BFm .order-module_decimal__vQru2 {\n  font-size: 10px;\n}\n.order-module_product__YUHaj .order-module_info__A8BFm .order-module_number__QRDij {\n  font-size: 10px;\n  color: #999999;\n}\n";
var OrderStyle = {"container":"order-module_container__MoSOl","order":"order-module_order__9sJ-Z","id":"order-module_id__W-CFP","change_button":"order-module_change_button__OIQOd","product":"order-module_product__YUHaj","img":"order-module_img__Higta","name":"order-module_name__13ITC","info":"order-module_info__A8BFm","unit":"order-module_unit__rJSeR","price":"order-module_price__qvUPC","decimal":"order-module_decimal__vQru2","number":"order-module_number__QRDij"};
styleInject(css_248z$5);

var css_248z$6 = "@font-face {\n  font-family: JDLZRegular;\n  src: url(./assets/fonts/JDLangZhengTi-Semibold.ttf);\n}\n";
styleInject(css_248z$6);

function CommonOrder(props) {
  var unit = "￥";
  var price = props.price;
  var decimal = "";
  if (price.startsWith("￥") || price.startsWith("¥")) {
    price = price.replace("¥", "").replace("￥", "");
  }
  var decimalIndex = price.indexOf(".");
  if (decimalIndex > 0) {
    decimal = price.substring(decimalIndex);
    price = price.substring(0, decimalIndex);
  }
  return React__default.createElement("div", {
    className: OrderStyle.container,
    style: props.styles
  }, React__default.createElement("div", {
    className: OrderStyle.order
  }, React__default.createElement("div", {
    className: OrderStyle.id
  }, "\u8BA2\u5355\u53F7: ", props.orderId), React__default.createElement("div", {
    style: {
      flex: 1
    }
  }), props.changeOrder ? React__default.createElement("div", {
    className: OrderStyle.change_button
  }, "\u66F4\u6362\u8BA2\u5355") : null), React__default.createElement("div", {
    className: OrderStyle.product
  }, React__default.createElement("img", {
    className: OrderStyle.img,
    src: props.imgUrl,
    alt: ""
  }), React__default.createElement("div", {
    className: OrderStyle.name
  }, props.name), React__default.createElement("div", {
    className: OrderStyle.info
  }, React__default.createElement("div", null, React__default.createElement("span", {
    className: OrderStyle.unit
  }, unit), React__default.createElement("span", {
    className: OrderStyle.price
  }, price), React__default.createElement("span", {
    className: OrderStyle.decimal
  }, decimal)), React__default.createElement("div", {
    className: OrderStyle.number
  }, "\u5171", props.num, "\u4EF6"), React__default.createElement("div", {
    className: OrderStyle.number
  }, props.status))));
}

var css_248z$7 = ".radio_group-module_container__NFEhs {\n  width: calc(100% - 24px);\n  background-color: red;\n}\n\n.radio_group-module_radio_container__-sHu8 {\n  display: flex;\n  flex-direction: row;\n  justify-content: flex-start;\n  align-items: center;\n}\n\n.radio_group-module_radio__u5kS- {\n  display: flex;\n  flex-direction: row;\n  justify-content: flex-start;\n  align-items: center;\n  margin-top: 15px;\n}\n.radio_group-module_radio__u5kS- .radio_group-module_cycle__Ffx7x {\n  width: 15px;\n  height: 15px;\n  border-radius: 100px;\n  border: solid 2px #cccccc;\n  display: flex;\n  flex-direction: column;\n  justify-content: center;\n  align-items: center;\n}\n.radio_group-module_radio__u5kS- .radio_group-module_cycle__Ffx7x .radio_group-module_cycle_center__SMBn7 {\n  border-radius: 100px;\n  width: 10px;\n  height: 10px;\n  background-color: transparent;\n}\n.radio_group-module_radio__u5kS- .radio_group-module_cycle__Ffx7x .radio_group-module_cycle_center_selected__3JNL4 {\n  background-color: red;\n  transition: 1s;\n}\n.radio_group-module_radio__u5kS- .radio_group-module_cycle_selected__rH2em {\n  border: solid 2px red;\n  transition: 1s;\n}\n.radio_group-module_radio__u5kS- .radio_group-module_title__hyUbA {\n  font-size: 12px;\n  color: #595959;\n  margin-left: 6px;\n}\n.radio_group-module_radio__u5kS- .radio_group-module_title_selected__uZa1W {\n  color: #333333;\n  transition: 1s;\n  font-size: 12px;\n}\n";
var RadioGroupStyle = {"container":"radio_group-module_container__NFEhs","radio_container":"radio_group-module_radio_container__-sHu8","radio":"radio_group-module_radio__u5kS-","cycle":"radio_group-module_cycle__Ffx7x","cycle_center":"radio_group-module_cycle_center__SMBn7","cycle_center_selected":"radio_group-module_cycle_center_selected__3JNL4","cycle_selected":"radio_group-module_cycle_selected__rH2em","title":"radio_group-module_title__hyUbA","title_selected":"radio_group-module_title_selected__uZa1W"};
styleInject(css_248z$7);

function Radio(props) {
  var selected = props.selectedValue === props.value;
  return React__default.createElement("div", {
    className: RadioGroupStyle.radio,
    style: props.style,
    onClick: props.onClick
  }, React__default.createElement("div", {
    className: RadioGroupStyle.cycle + " " + (selected ? RadioGroupStyle.cycle_selected : null)
  }, React__default.createElement("div", {
    className: RadioGroupStyle.cycle_center + " " + (selected ? RadioGroupStyle.cycle_center_selected : null)
  })), React__default.createElement("div", {
    className: RadioGroupStyle.title + " " + (selected ? RadioGroupStyle.title_selected : null)
  }, props.label));
}
function RadioGroupContainer(props) {
  var _useState = React.useState(props.defaultValue),
    selectedValue = _useState[0],
    setSelectedValue = _useState[1];
  var radios = props.options.map(function (option, index) {
    return React__default.createElement(Radio, Object.assign({}, option, {
      style: {
        marginLeft: index === 0 ? 0 : "15pt"
      },
      selectedValue: selectedValue,
      onClick: function onClick() {
        setSelectedValue(option.value);
        props.valueChanged(option);
      }
    }));
  });
  return React__default.createElement("div", {
    className: RadioGroupStyle.radio_container
  }, radios);
}
function RadioGroup(props) {
  return React__default.createElement("div", {
    className: RadioGroupStyle.container,
    style: props.styles
  }, React__default.createElement(CommonTitle, {
    title: props.title,
    must: props.must
  }), React__default.createElement(RadioGroupContainer, Object.assign({}, props)));
}

/**
 * 状态组件参数
 */
(function (Status) {
  Status[Status["LOADING"] = 0] = "LOADING";
  Status[Status["FAILED"] = 1] = "FAILED";
})(exports.Status || (exports.Status = {}));

var css_248z$8 = ".status-module_container__JhLhO {\n  display: flex;\n  flex-direction: column;\n  justify-content: center;\n  align-items: center;\n}\n\n@keyframes status-module_rotate__lqTZo {\n  100% {\n    transform: rotate(360deg);\n  }\n}\n\n.status-module_loading__d7iKM {\n  animation-name: status-module_rotate__lqTZo;\n  animation-duration: 1s;\n  animation-timing-function: ease-in-out;\n  animation-iteration-count: infinite;\n}\n";
var StatusStyle = {"container":"status-module_container__JhLhO","loading":"status-module_loading__d7iKM","rotate":"status-module_rotate__lqTZo"};
styleInject(css_248z$8);

var _path;
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var SvgLoading = function SvgLoading(props, ref) {
  return /*#__PURE__*/React.createElement("svg", _extends({
    xmlns: "http://www.w3.org/2000/svg",
    width: 128,
    height: 128,
    className: "loading_svg__icon",
    viewBox: "0 0 1024 1024",
    ref: ref
  }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
    d: "M834.765 736.358a5.632 5.632 0 1 0 11.264 0 5.632 5.632 0 0 0-11.264 0m-124.16 128.103a11.162 11.162 0 1 0 22.374 0 11.162 11.162 0 0 0-22.374 0m-167.322 65.894a16.794 16.794 0 1 0 33.639 0 16.794 16.794 0 0 0-33.639 0M363.162 921.6a22.374 22.374 0 1 0 44.748 0 22.374 22.374 0 0 0-44.748 0m-159.744-82.022a28.006 28.006 0 1 0 55.961 0 28.006 28.006 0 0 0-56.013 0zM92.672 700.16a33.638 33.638 0 1 0 67.226 0 33.638 33.638 0 0 0-67.226 0M51.2 528.998a39.168 39.168 0 1 0 78.336 0 39.168 39.168 0 0 0-78.336 0m34.15-170.086a44.8 44.8 0 1 0 89.6 0 44.8 44.8 0 0 0-89.6 0m102.554-137.114a50.432 50.432 0 1 0 100.864 0 50.432 50.432 0 0 0-100.864 0m150.528-78.438a55.962 55.962 0 1 0 111.923 0 55.962 55.962 0 0 0-111.974 0zm169.011-4.915a61.594 61.594 0 1 0 123.239 0 61.594 61.594 0 0 0-123.239 0m154.778 69.632a67.174 67.174 0 1 0 134.349 0 67.174 67.174 0 0 0-134.35 0M772.25 338.893a72.806 72.806 0 1 0 145.561 0 72.806 72.806 0 0 0-145.561 0m43.724 169.472a78.387 78.387 0 1 0 156.826 0 78.387 78.387 0 0 0-156.826 0"
  })));
};
var ForwardRef = /*#__PURE__*/React.forwardRef(SvgLoading);

var _path$1, _path2;
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
var SvgFailed = function SvgFailed(props, ref) {
  return /*#__PURE__*/React.createElement("svg", _extends$1({
    xmlns: "http://www.w3.org/2000/svg",
    width: 128,
    height: 128,
    className: "failed_svg__icon",
    viewBox: "0 0 1024 1024",
    ref: ref
  }, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
    d: "M512.5 128.2c51.9 0 102.2 10.1 149.5 30.2 45.7 19.3 86.8 47 122.1 82.3s63 76.4 82.3 122.1c20 47.3 30.2 97.6 30.2 149.5s-10.1 102.2-30.2 149.5c-19.3 45.7-47 86.8-82.3 122.1s-76.4 63-122.1 82.3c-47.3 20-97.6 30.2-149.5 30.2S410.3 886.1 363 866.1c-45.7-19.3-86.8-47-122.1-82.3s-63-76.4-82.3-122.1c-20-47.3-30.2-97.6-30.2-149.5s10.1-102.2 30.2-149.5c19.3-45.7 47-86.8 82.3-122.1s76.4-63 122.1-82.3c47.3-19.9 97.6-30.1 149.5-30.1m0-64c-247.4 0-448 200.6-448 448s200.6 448 448 448 448-200.6 448-448-200.6-448-448-448"
  })), _path2 || (_path2 = /*#__PURE__*/React.createElement("path", {
    d: "M462.5 737.7a50 50 0 1 0 100 0 50 50 0 1 0-100 0M576.5 300.8c0-35.4-28.7-64.1-64-64.1s-64 28.7-64 64v.1l24 301.6c.5 21.6 18.2 39 40 39s39.4-17.4 40-39z"
  })));
};
var ForwardRef$1 = /*#__PURE__*/React.forwardRef(SvgFailed);

var CommonStatus = function CommonStatus(props) {
  var _props$width, _props$height, _props$backgroundColo, _props$borderRadius, _props$iconSize, _props$iconSize2, _props$iconColor, _props$iconSize3, _props$iconSize4, _props$iconColor2, _props$textMargin, _props$fontSize, _props$fontColor, _props$fontWeight;
  return React__default.createElement("div", {
    className: StatusStyle.container,
    style: {
      width: (_props$width = props.width) != null ? _props$width : "auto",
      height: (_props$height = props.height) != null ? _props$height : "auto",
      backgroundColor: (_props$backgroundColo = props.backgroundColor) != null ? _props$backgroundColo : "#00000000",
      borderRadius: (_props$borderRadius = props.borderRadius) != null ? _props$borderRadius : 0
    }
  }, props.status == exports.Status.LOADING ? React__default.createElement(ForwardRef, {
    className: StatusStyle.loading,
    style: {
      width: (_props$iconSize = props.iconSize) != null ? _props$iconSize : "auto",
      height: (_props$iconSize2 = props.iconSize) != null ? _props$iconSize2 : "auto",
      fill: (_props$iconColor = props.iconColor) != null ? _props$iconColor : "#fff"
    }
  }) : React__default.createElement(ForwardRef$1, {
    style: {
      width: (_props$iconSize3 = props.iconSize) != null ? _props$iconSize3 : "auto",
      height: (_props$iconSize4 = props.iconSize) != null ? _props$iconSize4 : "auto",
      fill: (_props$iconColor2 = props.iconColor) != null ? _props$iconColor2 : "#fff"
    }
  }), props.text ? React__default.createElement("div", {
    style: {
      marginTop: (_props$textMargin = props.textMargin) != null ? _props$textMargin : "4px",
      fontSize: (_props$fontSize = props.fontSize) != null ? _props$fontSize : "14px",
      color: (_props$fontColor = props.fontColor) != null ? _props$fontColor : "#333",
      fontWeight: (_props$fontWeight = props.fontWeight) != null ? _props$fontWeight : "normal"
    }
  }, props.text) : null);
};

exports.CommonModal = CommonModal;
exports.CommonOrder = CommonOrder;
exports.CommonStatus = CommonStatus;
exports.CommonTitle = CommonTitle;
exports.ImgUploader = ImgUploader;
exports.LimitInput = LimitInput;
exports.NumberSelector = NumberSelector;
exports.RadioGroup = RadioGroup;
//# sourceMappingURL=jdimwebcomponentkit.cjs.development.js.map
