"use strict";
/*
 * ATTENTION: An "eval-source-map" devtool has been used.
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file with attached SourceMaps in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
(self["webpackChunknocode_platform"] = self["webpackChunknocode_platform"] || []).push([[4428],{

/***/ "./src/web/component/common/Ellipsis.tsx":
/*!***********************************************!*\
  !*** ./src/web/component/common/Ellipsis.tsx ***!
  \***********************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

eval("\n\nvar _typeof = __webpack_require__(/*! @babel/runtime-corejs3/helpers/typeof */ \"../../node_modules/@babel/runtime-corejs3/helpers/typeof.js\");\nvar _Object$keys = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/keys */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols.js\");\nvar _filterInstanceProperty = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/filter */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/filter.js\");\nvar _Object$getOwnPropertyDescriptor = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/define-properties */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/define-property */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/define-property.js\");\nvar _sliceInstanceProperty2 = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/slice */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/slice.js\");\nvar _Array$from2 = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/array/from */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/array/from.js\");\nvar _Symbol = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/symbol */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/symbol.js\");\nvar _getIteratorMethod = __webpack_require__(/*! @babel/runtime-corejs3/core-js/get-iterator-method */ \"../../node_modules/@babel/runtime-corejs3/core-js/get-iterator-method.js\");\nvar _WeakMap = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/weak-map */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/weak-map.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs3/helpers/interopRequireDefault */ \"../../node_modules/@babel/runtime-corejs3/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports[\"default\"] = void 0;\nexports.mergeProps = mergeProps;\nexports.withNativeProps = withNativeProps;\nexports.withStopPropagation = withStopPropagation;\nvar _startsWith = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/starts-with */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/starts-with.js\"));\nvar _from = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/array/from */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/array/from.js\"));\nvar _slice = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/slice */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/slice.js\"));\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs3/helpers/slicedToArray */ \"../../node_modules/@babel/runtime-corejs3/helpers/slicedToArray.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs3/helpers/defineProperty */ \"../../node_modules/@babel/runtime-corejs3/helpers/defineProperty.js\"));\nvar _react = _interopRequireWildcard(__webpack_require__(/*! kd_libs/react */ \"webpack/container/remote/kd_libs/react\"));\nvar _classnames = _interopRequireDefault(__webpack_require__(/*! classnames */ \"../../node_modules/classnames/index.js\"));\nvar _lodash = __webpack_require__(/*! kd_libs/lodash */ \"webpack/container/remote/kd_libs/lodash\");\nfunction _getRequireWildcardCache(e) { if (\"function\" != typeof _WeakMap) return null; var r = new _WeakMap(), t = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }\nfunction _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \"object\" != _typeof(e) && \"function\" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var u in e) if (\"default\" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== \"undefined\" && _getIteratorMethod(o) || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (_e) { function e(_x) { return _e.apply(this, arguments); } e.toString = function () { return _e.toString(); }; return e; }(function (e) { throw e; }), f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function (_e2) { function e(_x2) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty2(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return _Array$from2(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _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; }\nfunction ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(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; }\nfunction mergeProps() {\n  function customizer(objValue, srcValue) {\n    return srcValue === undefined ? objValue : srcValue;\n  }\n  var ret = _objectSpread({}, arguments.length <= 0 ? undefined : arguments[0]);\n  for (var i = 1; i < arguments.length; i++) {\n    ret = (0, _lodash.assignWith)(ret, i < 0 || arguments.length <= i ? undefined : arguments[i], customizer);\n  }\n  return ret;\n}\nvar classPrefix = \"adm-ellipsis\";\nfunction withNativeProps(props, element) {\n  var p = _objectSpread({}, element.props);\n  if (props.className) {\n    p.className = (0, _classnames.default)(element.props.className, props.className);\n  }\n  if (props.style) {\n    p.style = _objectSpread(_objectSpread({}, p.style), props.style);\n  }\n  if (props.tabIndex !== undefined) {\n    p.tabIndex = props.tabIndex;\n  }\n  for (var key in props) {\n    if (!props.hasOwnProperty(key)) continue;\n    if ((0, _startsWith.default)(key).call(key, 'data-') || (0, _startsWith.default)(key).call(key, 'aria-')) {\n      p[key] = props[key];\n    }\n  }\n  return _react.default.cloneElement(element, p);\n}\nvar eventToPropRecord = {\n  'click': 'onClick'\n};\nfunction withStopPropagation(events, element) {\n  var props = _objectSpread({}, element.props);\n  var _iterator = _createForOfIteratorHelper(events),\n    _step;\n  try {\n    var _loop = function _loop() {\n      var key = _step.value;\n      var prop = eventToPropRecord[key];\n      props[prop] = function (e) {\n        var _element$props$prop, _element$props;\n        e.stopPropagation();\n        (_element$props$prop = (_element$props = element.props)[prop]) === null || _element$props$prop === void 0 || _element$props$prop.call(_element$props, e);\n      };\n    };\n    for (_iterator.s(); !(_step = _iterator.n()).done;) {\n      _loop();\n    }\n  } catch (err) {\n    _iterator.e(err);\n  } finally {\n    _iterator.f();\n  }\n  return _react.default.cloneElement(element, props);\n}\nfunction useMemoizedFn(fn) {\n  var fnRef = (0, _react.useRef)(fn);\n\n  // why not write `fnRef.current = fn`?\n  // https://github.com/alibaba/hooks/issues/728\n  fnRef.current = (0, _react.useMemo)(function () {\n    return fn;\n  }, [fn]);\n  var memoizedFn = (0, _react.useRef)();\n  if (!memoizedFn.current) {\n    memoizedFn.current = function () {\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      return fnRef.current.apply(this, args);\n    };\n  }\n  return memoizedFn.current;\n}\nfunction useResizeEffect(effect, targetRef) {\n  var fn = useMemoizedFn(effect);\n  (0, _react.useLayoutEffect)(function () {\n    var target = targetRef.current;\n    if (!target) return;\n    if (window.ResizeObserver) {\n      var animationFrame;\n      var observer = new ResizeObserver(function () {\n        animationFrame = window.requestAnimationFrame(function () {\n          return fn(target);\n        });\n      });\n      observer.observe(target);\n      return function () {\n        window.cancelAnimationFrame(animationFrame);\n        observer.disconnect();\n      };\n    } else {\n      fn(target);\n    }\n  }, [targetRef]);\n}\nvar defaultProps = {\n  direction: 'end',\n  rows: 1,\n  expandText: '',\n  content: '',\n  collapseText: '',\n  stopPropagationForActionButtons: [],\n  onContentClick: function onContentClick() {}\n};\nvar Ellipsis = function Ellipsis(p) {\n  var props = mergeProps(defaultProps, p);\n  var rootRef = (0, _react.useRef)(null);\n  var _useState = (0, _react.useState)({}),\n    _useState2 = (0, _slicedToArray2.default)(_useState, 2),\n    ellipsised = _useState2[0],\n    setEllipsised = _useState2[1];\n  var _useState3 = (0, _react.useState)(false),\n    _useState4 = (0, _slicedToArray2.default)(_useState3, 2),\n    expanded = _useState4[0],\n    setExpanded = _useState4[1];\n  var _useState5 = (0, _react.useState)(false),\n    _useState6 = (0, _slicedToArray2.default)(_useState5, 2),\n    exceeded = _useState6[0],\n    setExceeded = _useState6[1];\n  var chars = (0, _react.useMemo)(function () {\n    return (0, _from.default)(props.content);\n  }, [props.content]);\n  function getSubString(start, end) {\n    return (0, _slice.default)(chars).call(chars, start, end).join('');\n  }\n  function calcEllipsised() {\n    var root = rootRef.current;\n    if (!root) return;\n    if (!root.offsetParent) return;\n    var originStyle = window.getComputedStyle(root);\n    var container = document.createElement('div');\n    var styleNames = (0, _slice.default)(Array.prototype).apply(originStyle);\n    styleNames.forEach(function (name) {\n      container.style.setProperty(name, originStyle.getPropertyValue(name));\n    });\n    container.style.position = 'fixed';\n    container.style.left = '999999px';\n    container.style.top = '999999px';\n    container.style.zIndex = '-1000';\n    container.style.height = 'auto';\n    container.style.minHeight = 'auto';\n    container.style.maxHeight = 'auto';\n    container.style.textOverflow = 'clip';\n    container.style.whiteSpace = 'normal';\n    container.style.wordBreak = 'break-all';\n    container.style.webkitLineClamp = 'unset';\n    container.style.display = 'block';\n    var lineHeight = pxToNumber(originStyle.lineHeight);\n    var maxHeight = Math.floor(lineHeight * (props.rows + 0.5) + pxToNumber(originStyle.paddingTop) + pxToNumber(originStyle.paddingBottom));\n    container.innerText = props.content;\n    document.body.appendChild(container);\n    if (container.offsetHeight <= maxHeight) {\n      setExceeded(false);\n    } else {\n      var check = function check(left, right) {\n        if (right - left <= 1) {\n          if (props.direction === 'end') {\n            return {\n              leading: getSubString(0, left) + '...'\n            };\n          } else {\n            return {\n              tailing: '...' + getSubString(right, end)\n            };\n          }\n        }\n        var middle = Math.round((left + right) / 2);\n        if (props.direction === 'end') {\n          container.innerText = getSubString(0, middle) + '...' + actionText;\n        } else {\n          container.innerText = actionText + '...' + getSubString(middle, end);\n        }\n        if (container.offsetHeight <= maxHeight) {\n          if (props.direction === 'end') {\n            return check(middle, right);\n          } else {\n            return check(left, middle);\n          }\n        } else {\n          if (props.direction === 'end') {\n            return check(left, middle);\n          } else {\n            return check(middle, right);\n          }\n        }\n      };\n      var checkMiddle = function checkMiddle(leftPart, rightPart) {\n        if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {\n          return {\n            leading: getSubString(0, leftPart[0]) + '...',\n            tailing: '...' + getSubString(rightPart[1], end)\n          };\n        }\n        var leftPartMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);\n        var rightPartMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);\n        container.innerText = getSubString(0, leftPartMiddle) + '...' + actionText + '...' + getSubString(rightPartMiddle, end);\n        if (container.offsetHeight <= maxHeight) {\n          return checkMiddle([leftPartMiddle, leftPart[1]], [rightPart[0], rightPartMiddle]);\n        } else {\n          return checkMiddle([leftPart[0], leftPartMiddle], [rightPartMiddle, rightPart[1]]);\n        }\n      };\n      setExceeded(true);\n      var end = props.content.length;\n      var actionText = expanded ? props.collapseText : props.expandText;\n      var middle = Math.floor((0 + end) / 2);\n      var _ellipsised = props.direction === 'middle' ? checkMiddle([0, middle], [middle, end]) : check(0, end);\n      setEllipsised(_ellipsised);\n    }\n    document.body.removeChild(container);\n  }\n  useResizeEffect(calcEllipsised, rootRef);\n  (0, _react.useLayoutEffect)(function () {\n    calcEllipsised();\n  }, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);\n  var expandActionElement = exceeded && props.expandText ? withStopPropagation(props.stopPropagationForActionButtons, /*#__PURE__*/_react.default.createElement(\"a\", {\n    onClick: function onClick() {\n      setExpanded(true);\n    }\n  }, props.expandText)) : null;\n  var collapseActionElement = exceeded && props.expandText ? withStopPropagation(props.stopPropagationForActionButtons, /*#__PURE__*/_react.default.createElement(\"a\", {\n    onClick: function onClick() {\n      setExpanded(false);\n    }\n  }, props.collapseText)) : null;\n  var renderContent = function renderContent() {\n    if (!exceeded) {\n      return props.content;\n    }\n    if (expanded) {\n      return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.content, collapseActionElement);\n    } else {\n      return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, ellipsised.leading, expandActionElement, ellipsised.tailing);\n    }\n  };\n  return withNativeProps(props, /*#__PURE__*/_react.default.createElement(\"div\", {\n    ref: rootRef,\n    className: classPrefix,\n    style: {\n      wordBreak: 'break-all'\n    },\n    onClick: function onClick(e) {\n      if (e.target === e.currentTarget) {\n        props.onContentClick(e);\n      }\n    }\n  }, renderContent()));\n};\nfunction pxToNumber(value) {\n  if (!value) return 0;\n  var match = value.match(/^\\d*(\\.\\d*)?/);\n  return match ? Number(match[0]) : 0;\n}\nvar _default = exports[\"default\"] = Ellipsis;//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64, \n//# sourceURL=webpack-internal:///./src/web/component/common/Ellipsis.tsx\n");

/***/ })

}]);