@fileverse-dev/fortune-core 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/{dist/packages/core/src → es}/api/cell.d.ts +10 -10
  2. package/es/api/cell.js +204 -0
  3. package/{dist/packages/core/src → es}/api/common.d.ts +66 -66
  4. package/es/api/common.js +79 -0
  5. package/{dist/packages/core/src → es}/api/errors.d.ts +2 -2
  6. package/es/api/errors.js +2 -0
  7. package/{dist/packages/core/src → es}/api/index.d.ts +9 -9
  8. package/es/api/index.js +8 -0
  9. package/{dist/packages/core/src → es}/api/merge.d.ts +5 -5
  10. package/es/api/merge.js +15 -0
  11. package/{dist/packages/core/src → es}/api/range.d.ts +22 -22
  12. package/es/api/range.js +123 -0
  13. package/{dist/packages/core/src → es}/api/rowcol.d.ts +14 -14
  14. package/es/api/rowcol.js +207 -0
  15. package/{dist/packages/core/src → es}/api/sheet.d.ts +10 -10
  16. package/es/api/sheet.js +128 -0
  17. package/{dist/packages/core/src → es}/api/workbook.d.ts +15 -15
  18. package/es/api/workbook.js +85 -0
  19. package/{dist/packages/core/src → es}/canvas.d.ts +46 -46
  20. package/es/canvas.js +1350 -0
  21. package/{dist/packages/core/src → es}/context.d.ts +197 -197
  22. package/es/context.js +380 -0
  23. package/{dist/packages/core/src → es}/events/copy.d.ts +2 -2
  24. package/es/events/copy.js +78 -0
  25. package/{dist/packages/core/src → es}/events/index.d.ts +4 -4
  26. package/es/events/index.js +4 -0
  27. package/{dist/packages/core/src → es}/events/keyboard.d.ts +6 -6
  28. package/es/events/keyboard.js +332 -0
  29. package/{dist/packages/core/src → es}/events/mouse.d.ts +22 -22
  30. package/es/events/mouse.js +1725 -0
  31. package/{dist/packages/core/src → es}/events/paste.d.ts +3 -3
  32. package/es/events/paste.js +1358 -0
  33. package/{dist/packages/core/src → es}/index.d.ts +10 -10
  34. package/es/index.js +10 -0
  35. package/{dist/packages/core/src → es}/locale/en.d.ts +992 -992
  36. package/es/locale/en.js +10564 -0
  37. package/{dist/packages/core/src → es}/locale/es.d.ts +1134 -1134
  38. package/es/locale/es.js +10010 -0
  39. package/{dist/packages/core/src → es}/locale/hi.d.ts +1030 -1030
  40. package/es/locale/hi.js +10550 -0
  41. package/{dist/packages/core/src → es}/locale/index.d.ts +1049 -1049
  42. package/es/locale/index.js +23 -0
  43. package/{dist/packages/core/src → es}/locale/zh.d.ts +1048 -1048
  44. package/es/locale/zh.js +10568 -0
  45. package/{dist/packages/core/src → es}/locale/zh_tw.d.ts +1187 -1187
  46. package/es/locale/zh_tw.js +10072 -0
  47. package/{dist/packages/core/src → es}/modules/ConditionFormat.d.ts +17 -17
  48. package/es/modules/ConditionFormat.js +1258 -0
  49. package/{dist/packages/core/src → es}/modules/border.d.ts +3 -3
  50. package/es/modules/border.js +1240 -0
  51. package/{dist/packages/core/src → es}/modules/cell.d.ts +32 -32
  52. package/es/modules/cell.js +1055 -0
  53. package/{dist/packages/core/src → es}/modules/clipboard.d.ts +3 -3
  54. package/es/modules/clipboard.js +36 -0
  55. package/{dist/packages/core/src → es}/modules/color.d.ts +1 -1
  56. package/es/modules/color.js +1 -0
  57. package/{dist/packages/core/src → es}/modules/comment.d.ts +97 -97
  58. package/es/modules/comment.js +597 -0
  59. package/{dist/packages/core/src → es}/modules/conditionalFormat.d.ts +2 -2
  60. package/es/modules/conditionalFormat.js +441 -0
  61. package/{dist/packages/core/src → es}/modules/cursor.d.ts +3 -3
  62. package/es/modules/cursor.js +62 -0
  63. package/{dist/packages/core/src → es}/modules/dataVerification.d.ts +11 -11
  64. package/es/modules/dataVerification.js +700 -0
  65. package/{dist/packages/core/src → es}/modules/dropCell.d.ts +10 -10
  66. package/es/modules/dropCell.js +2266 -0
  67. package/{dist/packages/core/src → es}/modules/filter.d.ts +45 -45
  68. package/es/modules/filter.js +434 -0
  69. package/{dist/packages/core/src → es}/modules/format.d.ts +6 -6
  70. package/es/modules/format.js +323 -0
  71. package/{dist/packages/core/src → es}/modules/formula.d.ts +54 -54
  72. package/es/modules/formula.js +2301 -0
  73. package/{dist/packages/core/src → es}/modules/freeze.d.ts +5 -5
  74. package/es/modules/freeze.js +148 -0
  75. package/{dist/packages/core/src → es}/modules/hyperlink.d.ts +21 -21
  76. package/es/modules/hyperlink.js +216 -0
  77. package/{dist/packages/core/src → es}/modules/iframe.d.ts +12 -12
  78. package/es/modules/iframe.js +220 -0
  79. package/{dist/packages/core/src → es}/modules/image.d.ts +31 -31
  80. package/es/modules/image.js +253 -0
  81. package/{dist/packages/core/src → es}/modules/index.d.ts +36 -36
  82. package/es/modules/index.js +36 -0
  83. package/{dist/packages/core/src → es}/modules/inline-string.d.ts +36 -36
  84. package/es/modules/inline-string.js +437 -0
  85. package/{dist/packages/core/src → es}/modules/location.d.ts +6 -6
  86. package/es/modules/location.js +46 -0
  87. package/{dist/packages/core/src → es}/modules/locationCondition.d.ts +21 -21
  88. package/es/modules/locationCondition.js +218 -0
  89. package/{dist/packages/core/src → es}/modules/merge.d.ts +3 -3
  90. package/es/modules/merge.js +216 -0
  91. package/{dist/packages/core/src → es}/modules/mobile.d.ts +5 -5
  92. package/es/modules/mobile.js +33 -0
  93. package/{dist/packages/core/src → es}/modules/moveCells.d.ts +5 -5
  94. package/es/modules/moveCells.js +348 -0
  95. package/{dist/packages/core/src → es}/modules/protection.d.ts +5 -5
  96. package/es/modules/protection.js +96 -0
  97. package/{dist/packages/core/src → es}/modules/refresh.d.ts +3 -3
  98. package/es/modules/refresh.js +34 -0
  99. package/{dist/packages/core/src → es}/modules/rowcol.d.ts +19 -19
  100. package/es/modules/rowcol.js +1922 -0
  101. package/{dist/packages/core/src → es}/modules/screenshot.d.ts +2 -2
  102. package/es/modules/screenshot.js +90 -0
  103. package/{dist/packages/core/src → es}/modules/searchReplace.d.ts +36 -36
  104. package/es/modules/searchReplace.js +388 -0
  105. package/{dist/packages/core/src → es}/modules/selection.d.ts +46 -46
  106. package/es/modules/selection.js +1674 -0
  107. package/{dist/packages/core/src → es}/modules/sheet.d.ts +10 -10
  108. package/es/modules/sheet.js +237 -0
  109. package/{dist/packages/core/src → es}/modules/sort.d.ts +7 -7
  110. package/es/modules/sort.js +150 -0
  111. package/{dist/packages/core/src → es}/modules/splitColumn.d.ts +5 -5
  112. package/es/modules/splitColumn.js +126 -0
  113. package/es/modules/ssf.js +1533 -0
  114. package/{dist/packages/core/src → es}/modules/text.d.ts +10 -10
  115. package/es/modules/text.js +1207 -0
  116. package/{dist/packages/core/src → es}/modules/toolbar.d.ts +32 -32
  117. package/es/modules/toolbar.js +970 -0
  118. package/{dist/packages/core/src → es}/modules/validation.d.ts +19 -19
  119. package/es/modules/validation.js +190 -0
  120. package/{dist/packages/core/src → es}/modules/zoom.d.ts +3 -3
  121. package/es/modules/zoom.js +29 -0
  122. package/{dist/packages/core/src → es}/settings.d.ts +100 -100
  123. package/es/settings.js +36 -0
  124. package/{dist/packages/core/src → es}/types.d.ts +371 -371
  125. package/es/types.js +1 -0
  126. package/{dist/packages/core/src → es}/utils/freeze.d.ts +7 -7
  127. package/es/utils/freeze.js +86 -0
  128. package/{dist/packages/core/src → es}/utils/index.d.ts +18 -18
  129. package/es/utils/index.js +173 -0
  130. package/{dist/packages/core/src → es}/utils/patch.d.ts +37 -37
  131. package/es/utils/patch.js +381 -0
  132. package/lib/api/cell.d.ts +10 -0
  133. package/lib/api/cell.js +215 -0
  134. package/lib/api/common.d.ts +66 -0
  135. package/lib/api/common.js +88 -0
  136. package/lib/api/errors.d.ts +2 -0
  137. package/lib/api/errors.js +8 -0
  138. package/lib/api/index.d.ts +9 -0
  139. package/lib/api/index.js +101 -0
  140. package/lib/api/merge.d.ts +5 -0
  141. package/lib/api/merge.js +22 -0
  142. package/lib/api/range.d.ts +22 -0
  143. package/lib/api/range.js +138 -0
  144. package/lib/api/rowcol.d.ts +14 -0
  145. package/lib/api/rowcol.js +222 -0
  146. package/lib/api/sheet.d.ts +10 -0
  147. package/lib/api/sheet.js +145 -0
  148. package/lib/api/workbook.d.ts +15 -0
  149. package/lib/api/workbook.js +98 -0
  150. package/lib/canvas.d.ts +46 -0
  151. package/lib/canvas.js +1356 -0
  152. package/lib/context.d.ts +197 -0
  153. package/lib/context.js +392 -0
  154. package/lib/events/copy.d.ts +2 -0
  155. package/lib/events/copy.js +85 -0
  156. package/lib/events/index.d.ts +4 -0
  157. package/lib/events/index.js +49 -0
  158. package/lib/events/keyboard.d.ts +6 -0
  159. package/lib/events/keyboard.js +342 -0
  160. package/lib/events/mouse.d.ts +22 -0
  161. package/lib/events/mouse.js +1744 -0
  162. package/lib/events/paste.d.ts +3 -0
  163. package/lib/events/paste.js +1366 -0
  164. package/lib/index.d.ts +10 -0
  165. package/lib/index.js +109 -0
  166. package/lib/locale/en.d.ts +992 -0
  167. package/lib/locale/en.js +10570 -0
  168. package/lib/locale/es.d.ts +1134 -0
  169. package/lib/locale/es.js +10016 -0
  170. package/lib/locale/hi.d.ts +1030 -0
  171. package/lib/locale/hi.js +10556 -0
  172. package/lib/locale/index.d.ts +1049 -0
  173. package/lib/locale/index.js +29 -0
  174. package/lib/locale/zh.d.ts +1048 -0
  175. package/lib/locale/zh.js +10574 -0
  176. package/lib/locale/zh_tw.d.ts +1187 -0
  177. package/lib/locale/zh_tw.js +10078 -0
  178. package/lib/modules/ConditionFormat.d.ts +17 -0
  179. package/lib/modules/ConditionFormat.js +1273 -0
  180. package/lib/modules/border.d.ts +3 -0
  181. package/lib/modules/border.js +1248 -0
  182. package/lib/modules/cell.d.ts +32 -0
  183. package/lib/modules/cell.js +1085 -0
  184. package/lib/modules/clipboard.d.ts +3 -0
  185. package/lib/modules/clipboard.js +42 -0
  186. package/lib/modules/color.d.ts +1 -0
  187. package/lib/modules/color.js +7 -0
  188. package/lib/modules/comment.d.ts +97 -0
  189. package/lib/modules/comment.js +625 -0
  190. package/lib/modules/conditionalFormat.d.ts +2 -0
  191. package/lib/modules/conditionalFormat.js +447 -0
  192. package/lib/modules/cursor.d.ts +3 -0
  193. package/lib/modules/cursor.js +70 -0
  194. package/lib/modules/dataVerification.d.ts +11 -0
  195. package/lib/modules/dataVerification.js +715 -0
  196. package/lib/modules/dropCell.d.ts +10 -0
  197. package/lib/modules/dropCell.js +2282 -0
  198. package/lib/modules/filter.d.ts +45 -0
  199. package/lib/modules/filter.js +448 -0
  200. package/lib/modules/format.d.ts +6 -0
  201. package/lib/modules/format.js +334 -0
  202. package/lib/modules/formula.d.ts +54 -0
  203. package/lib/modules/formula.js +2330 -0
  204. package/lib/modules/freeze.d.ts +5 -0
  205. package/lib/modules/freeze.js +158 -0
  206. package/lib/modules/hyperlink.d.ts +21 -0
  207. package/lib/modules/hyperlink.js +232 -0
  208. package/lib/modules/iframe.d.ts +12 -0
  209. package/lib/modules/iframe.js +236 -0
  210. package/lib/modules/image.d.ts +31 -0
  211. package/lib/modules/image.js +272 -0
  212. package/lib/modules/index.d.ts +36 -0
  213. package/lib/modules/index.js +401 -0
  214. package/lib/modules/inline-string.d.ts +36 -0
  215. package/lib/modules/inline-string.js +452 -0
  216. package/lib/modules/location.d.ts +6 -0
  217. package/lib/modules/location.js +57 -0
  218. package/lib/modules/locationCondition.d.ts +21 -0
  219. package/lib/modules/locationCondition.js +229 -0
  220. package/lib/modules/merge.d.ts +3 -0
  221. package/lib/modules/merge.js +223 -0
  222. package/lib/modules/mobile.d.ts +5 -0
  223. package/lib/modules/mobile.js +41 -0
  224. package/lib/modules/moveCells.d.ts +5 -0
  225. package/lib/modules/moveCells.js +357 -0
  226. package/lib/modules/protection.d.ts +5 -0
  227. package/lib/modules/protection.js +106 -0
  228. package/lib/modules/refresh.d.ts +3 -0
  229. package/lib/modules/refresh.js +40 -0
  230. package/lib/modules/rowcol.d.ts +19 -0
  231. package/lib/modules/rowcol.js +1935 -0
  232. package/lib/modules/screenshot.d.ts +2 -0
  233. package/lib/modules/screenshot.js +96 -0
  234. package/lib/modules/searchReplace.d.ts +36 -0
  235. package/lib/modules/searchReplace.js +402 -0
  236. package/lib/modules/selection.d.ts +46 -0
  237. package/lib/modules/selection.js +1703 -0
  238. package/lib/modules/sheet.d.ts +10 -0
  239. package/lib/modules/sheet.js +250 -0
  240. package/lib/modules/sort.d.ts +7 -0
  241. package/lib/modules/sort.js +159 -0
  242. package/lib/modules/splitColumn.d.ts +5 -0
  243. package/lib/modules/splitColumn.js +136 -0
  244. package/lib/modules/ssf.js +1539 -0
  245. package/lib/modules/text.d.ts +10 -0
  246. package/lib/modules/text.js +1221 -0
  247. package/lib/modules/toolbar.d.ts +32 -0
  248. package/lib/modules/toolbar.js +1003 -0
  249. package/lib/modules/validation.d.ts +19 -0
  250. package/lib/modules/validation.js +205 -0
  251. package/lib/modules/zoom.d.ts +3 -0
  252. package/lib/modules/zoom.js +36 -0
  253. package/lib/settings.d.ts +100 -0
  254. package/lib/settings.js +42 -0
  255. package/lib/types.d.ts +371 -0
  256. package/lib/types.js +5 -0
  257. package/lib/utils/freeze.d.ts +7 -0
  258. package/lib/utils/freeze.js +92 -0
  259. package/lib/utils/index.d.ts +18 -0
  260. package/lib/utils/index.js +231 -0
  261. package/lib/utils/patch.d.ts +37 -0
  262. package/lib/utils/patch.js +392 -0
  263. package/package.json +7 -6
  264. package/dist/index.esm.js +0 -80255
  265. package/dist/index.js +0 -80601
  266. package/dist/packages/react/src/components/ChangeColor/index.d.ts +0 -7
  267. package/dist/packages/react/src/components/ConditionFormat/ConditionRules.d.ts +0 -6
  268. package/dist/packages/react/src/components/ConditionFormat/index.d.ts +0 -7
  269. package/dist/packages/react/src/components/ContextMenu/Divider.d.ts +0 -3
  270. package/dist/packages/react/src/components/ContextMenu/FilterMenu.d.ts +0 -3
  271. package/dist/packages/react/src/components/ContextMenu/Menu.d.ts +0 -8
  272. package/dist/packages/react/src/components/ContextMenu/SheetTab.d.ts +0 -4
  273. package/dist/packages/react/src/components/ContextMenu/index.d.ts +0 -5
  274. package/dist/packages/react/src/components/CustomSort/index.d.ts +0 -4
  275. package/dist/packages/react/src/components/DataVerification/DropdownList.d.ts +0 -4
  276. package/dist/packages/react/src/components/DataVerification/RangeDialog.d.ts +0 -4
  277. package/dist/packages/react/src/components/DataVerification/getDisplayedRangeTxt.d.ts +0 -2
  278. package/dist/packages/react/src/components/DataVerification/index.d.ts +0 -4
  279. package/dist/packages/react/src/components/Dialog/index.d.ts +0 -15
  280. package/dist/packages/react/src/components/DuneChartsInputModal/DuneChartsInputModal.d.ts +0 -11
  281. package/dist/packages/react/src/components/DunePreview/DunePreview.d.ts +0 -13
  282. package/dist/packages/react/src/components/FilterOption/index.d.ts +0 -5
  283. package/dist/packages/react/src/components/FormatSearch/index.d.ts +0 -6
  284. package/dist/packages/react/src/components/FormulaSearch/index.d.ts +0 -5
  285. package/dist/packages/react/src/components/FxEditor/NameBox.d.ts +0 -3
  286. package/dist/packages/react/src/components/FxEditor/index.d.ts +0 -4
  287. package/dist/packages/react/src/components/IFrameBoxs/iFrameBoxs.d.ts +0 -4
  288. package/dist/packages/react/src/components/ImgBoxs/index.d.ts +0 -3
  289. package/dist/packages/react/src/components/LinkEidtCard/index.d.ts +0 -5
  290. package/dist/packages/react/src/components/LocationCondition/index.d.ts +0 -3
  291. package/dist/packages/react/src/components/MessageBox/index.d.ts +0 -9
  292. package/dist/packages/react/src/components/NotationBoxes/index.d.ts +0 -3
  293. package/dist/packages/react/src/components/ResetColumnWidth/index.d.ts +0 -2
  294. package/dist/packages/react/src/components/SVGDefines.d.ts +0 -5
  295. package/dist/packages/react/src/components/SVGIcon.d.ts +0 -9
  296. package/dist/packages/react/src/components/SearchReplace/index.d.ts +0 -6
  297. package/dist/packages/react/src/components/Sheet/index.d.ts +0 -8
  298. package/dist/packages/react/src/components/SheetList/SheetHiddenButton.d.ts +0 -8
  299. package/dist/packages/react/src/components/SheetList/SheetListItem.d.ts +0 -9
  300. package/dist/packages/react/src/components/SheetList/index.d.ts +0 -4
  301. package/dist/packages/react/src/components/SheetOverlay/ColumnHeader.d.ts +0 -3
  302. package/dist/packages/react/src/components/SheetOverlay/ContentEditable.d.ts +0 -11
  303. package/dist/packages/react/src/components/SheetOverlay/FormulaHint/index.d.ts +0 -4
  304. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/constant.d.ts +0 -63
  305. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/index.d.ts +0 -4
  306. package/dist/packages/react/src/components/SheetOverlay/InputBox.d.ts +0 -3
  307. package/dist/packages/react/src/components/SheetOverlay/RowHeader.d.ts +0 -3
  308. package/dist/packages/react/src/components/SheetOverlay/ScrollBar/index.d.ts +0 -7
  309. package/dist/packages/react/src/components/SheetOverlay/index.d.ts +0 -4
  310. package/dist/packages/react/src/components/SheetTab/SheetItem.d.ts +0 -8
  311. package/dist/packages/react/src/components/SheetTab/index.d.ts +0 -4
  312. package/dist/packages/react/src/components/SplitColumn/index.d.ts +0 -3
  313. package/dist/packages/react/src/components/Toolbar/Button.d.ts +0 -12
  314. package/dist/packages/react/src/components/Toolbar/ColorPicker.d.ts +0 -6
  315. package/dist/packages/react/src/components/Toolbar/Combo.d.ts +0 -12
  316. package/dist/packages/react/src/components/Toolbar/CustomBorder.d.ts +0 -7
  317. package/dist/packages/react/src/components/Toolbar/CustomButton.d.ts +0 -11
  318. package/dist/packages/react/src/components/Toolbar/CustomColor.d.ts +0 -8
  319. package/dist/packages/react/src/components/Toolbar/CustomIcon.d.ts +0 -9
  320. package/dist/packages/react/src/components/Toolbar/Divider.d.ts +0 -4
  321. package/dist/packages/react/src/components/Toolbar/MoreItemsContainer.d.ts +0 -6
  322. package/dist/packages/react/src/components/Toolbar/Select.d.ts +0 -14
  323. package/dist/packages/react/src/components/Toolbar/index.d.ts +0 -10
  324. package/dist/packages/react/src/components/Workbook/api.d.ts +0 -1177
  325. package/dist/packages/react/src/components/Workbook/index.d.ts +0 -1185
  326. package/dist/packages/react/src/components/ZoomControl/index.d.ts +0 -4
  327. package/dist/packages/react/src/components/index.d.ts +0 -4
  328. package/dist/packages/react/src/constants.d.ts +0 -1
  329. package/dist/packages/react/src/context/index.d.ts +0 -25
  330. package/dist/packages/react/src/context/modal.d.ts +0 -10
  331. package/dist/packages/react/src/hooks/useAlert.d.ts +0 -4
  332. package/dist/packages/react/src/hooks/useDialog.d.ts +0 -5
  333. package/dist/packages/react/src/hooks/useOutsideClick.d.ts +0 -2
  334. package/dist/packages/react/src/hooks/usePrevious.d.ts +0 -2
  335. package/dist/packages/react/src/index.d.ts +0 -1
  336. package/dist/packages/react/src/utils/datepickerStyles.d.ts +0 -2
  337. package/dist/stories/API.stories.d.ts +0 -1210
  338. package/dist/stories/Collabration.stories.d.ts +0 -2359
  339. package/dist/stories/Features.stories.d.ts +0 -9430
  340. package/dist/stories/data/cell.d.ts +0 -983
  341. package/dist/stories/data/dataVerification.d.ts +0 -131
  342. package/dist/stories/data/empty.d.ts +0 -10
  343. package/dist/stories/data/formula.d.ts +0 -362
  344. package/dist/stories/data/freeze.d.ts +0 -34
  345. package/dist/stories/data/protected.d.ts +0 -40
  346. package/dist/stories/utils.d.ts +0 -1
@@ -0,0 +1,1674 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ import _, { isPlainObject } from "lodash";
3
+ import { getFlowdata } from "../context";
4
+ import { getCellValue, getdatabyselection, getDataBySelectionNoCopy, getStyleByCell, mergeBorder, mergeMoveMain } from "./cell";
5
+ import { delFunctionGroup } from "./formula";
6
+ import clipboard from "./clipboard";
7
+ import { getBorderInfoCompute } from "./border";
8
+ import { escapeHTMLTag, getSheetIndex, isAllowEdit, replaceHtml } from "../utils";
9
+ import { hasPartMC } from "./validation";
10
+ import { update } from "./format";
11
+ import SSF from "./ssf";
12
+ import { CFSplitRange } from "./ConditionFormat";
13
+ export var selectionCache = {
14
+ isPasteAction: false
15
+ };
16
+ export function scrollToHighlightCell(ctx, r, c) {
17
+ var _a, _b, _c, _d;
18
+ var scrollLeft = ctx.scrollLeft,
19
+ scrollTop = ctx.scrollTop;
20
+ var winH = ctx.cellmainHeight;
21
+ var winW = ctx.cellmainWidth;
22
+ var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
23
+ var sheet = sheetIndex == null ? null : ctx.luckysheetfile[sheetIndex];
24
+ if (!sheet) return;
25
+ var frozen = sheet === null || sheet === void 0 ? void 0 : sheet.frozen;
26
+ if (r >= 0) {
27
+ var row_focus = ((_b = (_a = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _a === void 0 ? void 0 : _a.range) === null || _b === void 0 ? void 0 : _b.row_focus) || 0;
28
+ var freezeH = frozen && r > row_focus ? ctx.visibledatarow[row_focus] : 0;
29
+ var row = ctx.visibledatarow[r];
30
+ var row_pre = r - 1 === -1 ? 0 : ctx.visibledatarow[r - 1];
31
+ if (row - scrollTop - winH + 20 > 0) {
32
+ ctx.scrollTop = row - winH + 20;
33
+ } else if (row_pre - scrollTop - freezeH < 0) {
34
+ var scrollAmount = Math.max(20, freezeH);
35
+ ctx.scrollTop = row_pre - scrollAmount;
36
+ }
37
+ }
38
+ if (c >= 0) {
39
+ var column_focus = ((_d = (_c = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _c === void 0 ? void 0 : _c.range) === null || _d === void 0 ? void 0 : _d.column_focus) || 0;
40
+ var freezeW = frozen && c > column_focus ? ctx.visibledatacolumn[column_focus] : 0;
41
+ var col = ctx.visibledatacolumn[c];
42
+ var col_pre = c - 1 === -1 ? 0 : ctx.visibledatacolumn[c - 1];
43
+ if (col - scrollLeft - winW + 20 > 0) {
44
+ ctx.scrollLeft = col - winW + 20;
45
+ } else if (col_pre - scrollLeft - freezeW < 0) {
46
+ var scrollAmount = Math.max(20, freezeW);
47
+ ctx.scrollLeft = col_pre - scrollAmount;
48
+ }
49
+ }
50
+ }
51
+ export function seletedHighlistByindex(ctx, r1, r2, c1, c2) {
52
+ var row = ctx.visibledatarow[r2];
53
+ var row_pre = r1 - 1 === -1 ? 0 : ctx.visibledatarow[r1 - 1];
54
+ var col = ctx.visibledatacolumn[c2];
55
+ var col_pre = c1 - 1 === -1 ? 0 : ctx.visibledatacolumn[c1 - 1];
56
+ if (_.isNumber(row) && _.isNumber(row_pre) && _.isNumber(col) && _.isNumber(col_pre)) {
57
+ return {
58
+ left: col_pre,
59
+ width: col - col_pre - 1,
60
+ top: row_pre,
61
+ height: row - row_pre - 1
62
+ };
63
+ }
64
+ return null;
65
+ }
66
+ export function normalizeSelection(ctx, selection) {
67
+ var _a, _b;
68
+ if (!selection) return selection;
69
+ var flowdata = getFlowdata(ctx);
70
+ if (!flowdata) return selection;
71
+ for (var i = 0; i < selection.length; i += 1) {
72
+ var r1 = selection[i].row[0];
73
+ var r2 = selection[i].row[1];
74
+ var c1 = selection[i].column[0];
75
+ var c2 = selection[i].column[1];
76
+ var rf = void 0;
77
+ var cf = void 0;
78
+ if (_.isNil(selection[i].row_focus)) {
79
+ rf = r1;
80
+ } else {
81
+ rf = selection[i].row_focus;
82
+ }
83
+ if (_.isNil(selection[i].column_focus)) {
84
+ cf = c1;
85
+ } else {
86
+ cf = selection[i].column_focus;
87
+ }
88
+ if (_.isNil(rf) || _.isNil(cf)) {
89
+ console.error("normalizeSelection: rf and cf is nil");
90
+ return selection;
91
+ }
92
+ var row = ctx.visibledatarow[r2];
93
+ var row_pre = r1 - 1 === -1 ? 0 : ctx.visibledatarow[r1 - 1];
94
+ var col = ctx.visibledatacolumn[c2];
95
+ var col_pre = c1 - 1 === -1 ? 0 : ctx.visibledatacolumn[c1 - 1];
96
+ var row_f = ctx.visibledatarow[rf];
97
+ var row_pre_f = rf - 1 === -1 ? 0 : ctx.visibledatarow[rf - 1];
98
+ var col_f = ctx.visibledatacolumn[cf];
99
+ var col_pre_f = cf - 1 === -1 ? 0 : ctx.visibledatacolumn[cf - 1];
100
+ var margeset = mergeBorder(ctx, flowdata, rf, cf);
101
+ if (margeset) {
102
+ _a = margeset.row, row_pre_f = _a[0], row_f = _a[1];
103
+ _b = margeset.column, col_pre_f = _b[0], col_f = _b[1];
104
+ }
105
+ selection[i].row = [r1, r2];
106
+ selection[i].column = [c1, c2];
107
+ selection[i].row_focus = rf;
108
+ selection[i].column_focus = cf;
109
+ selection[i].left = col_pre_f;
110
+ selection[i].width = col_f - col_pre_f <= 0 ? 0 : col_f - col_pre_f - 1;
111
+ selection[i].top = row_pre_f;
112
+ selection[i].height = row_f - row_pre_f <= 0 ? 0 : row_f - row_pre_f - 1;
113
+ selection[i].left_move = col_pre;
114
+ selection[i].width_move = col - col_pre <= 0 ? 0 : col - col_pre - 1;
115
+ selection[i].top_move = row_pre;
116
+ selection[i].height_move = row - row_pre <= 0 ? 0 : row - row_pre - 1;
117
+ }
118
+ return selection;
119
+ }
120
+ export function selectTitlesMap(rangeMap, range1, range2) {
121
+ var map = rangeMap || {};
122
+ for (var i = range1; i <= range2; i += 1) {
123
+ if (i in map) {
124
+ continue;
125
+ }
126
+ map[i] = 0;
127
+ }
128
+ return map;
129
+ }
130
+ export function selectTitlesRange(map) {
131
+ var mapArr = Object.keys(map).map(Number);
132
+ mapArr.sort(function (a, b) {
133
+ return a - b;
134
+ });
135
+ var rangeArr;
136
+ var item = [];
137
+ if (mapArr.length > 1) {
138
+ rangeArr = [];
139
+ for (var j = 1; j < mapArr.length; j += 1) {
140
+ if (mapArr[j] - mapArr[j - 1] === 1) {
141
+ item.push(mapArr[j - 1]);
142
+ if (j === mapArr.length - 1) {
143
+ item.push(mapArr[j]);
144
+ rangeArr.push(item);
145
+ }
146
+ } else {
147
+ if (j === 1) {
148
+ if (j === mapArr.length - 1) {
149
+ item.push(mapArr[j - 1]);
150
+ rangeArr.push(item);
151
+ rangeArr.push([mapArr[j]]);
152
+ } else {
153
+ rangeArr.push([mapArr[0]]);
154
+ }
155
+ } else if (j === mapArr.length - 1) {
156
+ item.push(mapArr[j - 1]);
157
+ rangeArr.push(item);
158
+ rangeArr.push([mapArr[j]]);
159
+ } else {
160
+ item.push(mapArr[j - 1]);
161
+ rangeArr.push(item);
162
+ item = [];
163
+ }
164
+ }
165
+ }
166
+ } else {
167
+ rangeArr = [];
168
+ rangeArr.push([mapArr[0]]);
169
+ }
170
+ return rangeArr;
171
+ }
172
+ export function pasteHandlerOfPaintModel(ctx, copyRange) {
173
+ var cfg = ctx.config;
174
+ if (cfg.merge == null) {
175
+ cfg.merge = {};
176
+ }
177
+ if (!copyRange) return;
178
+ var copyHasMC = copyRange.HasMC;
179
+ var copySheetIndex = copyRange.dataSheetId;
180
+ var c_r1 = copyRange.copyRange[0].row[0];
181
+ var c_r2 = copyRange.copyRange[0].row[1];
182
+ var c_c1 = copyRange.copyRange[0].column[0];
183
+ var c_c2 = copyRange.copyRange[0].column[1];
184
+ var copyData = _.cloneDeep(getdatabyselection(ctx, {
185
+ row: [c_r1, c_r2],
186
+ column: [c_c1, c_c2]
187
+ }, copySheetIndex));
188
+ if (!ctx.luckysheet_select_save) return;
189
+ var last = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
190
+ var minh = last.row[0];
191
+ var maxh = last.row[1];
192
+ var minc = last.column[0];
193
+ var maxc = last.column[1];
194
+ var copyh = copyData.length;
195
+ var copyc = copyData[0].length;
196
+ if (minh === maxh && minc === maxc) {
197
+ var has_PartMC = false;
198
+ if (cfg.merge != null) {
199
+ has_PartMC = hasPartMC(ctx, cfg, minh, minh + copyh - 1, minc, minc + copyc - 1);
200
+ }
201
+ if (has_PartMC) {
202
+ return;
203
+ }
204
+ maxh = minh + copyh - 1;
205
+ maxc = minc + copyc - 1;
206
+ }
207
+ var timesH = Math.ceil((maxh - minh + 1) / copyh);
208
+ var timesC = Math.ceil((maxc - minc + 1) / copyc);
209
+ var flowdata = getFlowdata(ctx);
210
+ if (flowdata == null) return;
211
+ var cellMaxLength = flowdata[0].length;
212
+ var rowMaxLength = flowdata.length;
213
+ var borderInfoCompute = getBorderInfoCompute(ctx, copySheetIndex);
214
+ var c_dataVerification = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, copySheetIndex)].dataVerification) || {};
215
+ var dataVerification = null;
216
+ var mth = 0;
217
+ var mtc = 0;
218
+ var maxcellCahe = 0;
219
+ var maxrowCache = 0;
220
+ for (var th = 1; th <= timesH; th += 1) {
221
+ for (var tc = 1; tc <= timesC; tc += 1) {
222
+ mth = minh + (th - 1) * copyh;
223
+ mtc = minc + (tc - 1) * copyc;
224
+ maxrowCache = minh + th * copyh > rowMaxLength ? rowMaxLength : minh + th * copyh;
225
+ if (maxrowCache > maxh + 1) {
226
+ maxrowCache = maxh + 1;
227
+ }
228
+ maxcellCahe = minc + tc * copyc > cellMaxLength ? cellMaxLength : minc + tc * copyc;
229
+ if (maxcellCahe > maxc + 1) {
230
+ maxcellCahe = maxc + 1;
231
+ }
232
+ var offsetMC = {};
233
+ var _loop_1 = function _loop_1(h) {
234
+ if (h == null) return {
235
+ value: void 0
236
+ };
237
+ if (flowdata[h] == null) return {
238
+ value: void 0
239
+ };
240
+ var x = [];
241
+ x = flowdata[h];
242
+ var _loop_2 = function _loop_2(c) {
243
+ if (borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)]) {
244
+ var bd_obj = {
245
+ rangeType: "cell",
246
+ value: {
247
+ row_index: h,
248
+ col_index: c,
249
+ l: borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)].l,
250
+ r: borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)].r,
251
+ t: borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)].t,
252
+ b: borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)].b
253
+ }
254
+ };
255
+ if (cfg.borderInfo == null) {
256
+ cfg.borderInfo = [];
257
+ }
258
+ cfg.borderInfo.push(bd_obj);
259
+ } else if (borderInfoCompute["".concat(h, "_").concat(c)]) {
260
+ var bd_obj = {
261
+ rangeType: "cell",
262
+ value: {
263
+ row_index: h,
264
+ col_index: c,
265
+ l: null,
266
+ r: null,
267
+ t: null,
268
+ b: null
269
+ }
270
+ };
271
+ if (cfg.borderInfo == null) {
272
+ cfg.borderInfo = [];
273
+ }
274
+ cfg.borderInfo.push(bd_obj);
275
+ }
276
+ if (c_dataVerification["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)]) {
277
+ if (dataVerification == null) {
278
+ dataVerification = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].dataVerification);
279
+ }
280
+ dataVerification["".concat(h, "_").concat(c)] = c_dataVerification["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)];
281
+ }
282
+ if (isPlainObject(x[c]) && x[c].mc) {
283
+ if (x[c].mc.rs) {
284
+ delete cfg.merge["".concat(x[c].mc.r, "_").concat(x[c].mc.c)];
285
+ }
286
+ delete x[c].mc;
287
+ }
288
+ var value = null;
289
+ if (copyData[h - mth] != null && copyData[h - mth][c - mtc] != null) {
290
+ value = copyData[h - mth][c - mtc];
291
+ }
292
+ if (isPlainObject(x[c])) {
293
+ if (x[c].ct && x[c].ct.t === "inlineStr" && value) {
294
+ delete value.ct;
295
+ } else {
296
+ var format = ["bg", "fc", "ct", "ht", "vt", "bl", "it", "cl", "un", "fs", "ff", "tb"];
297
+ format.forEach(function (item) {
298
+ Reflect.deleteProperty(x[c], item);
299
+ });
300
+ }
301
+ } else {
302
+ x[c] = {
303
+ v: x[c]
304
+ };
305
+ }
306
+ if (value != null) {
307
+ delete value.v;
308
+ delete value.m;
309
+ delete value.f;
310
+ delete value.spl;
311
+ if (value.ct && value.ct.t === "inlineStr") {
312
+ delete value.ct;
313
+ }
314
+ x[c] = _.assign(x[c], _.cloneDeep(value));
315
+ if (x[c].ct && x[c].ct.t === "inlineStr") {
316
+ x[c].ct.s.forEach(function (item) {
317
+ return _.assign(item, value);
318
+ });
319
+ }
320
+ if (copyHasMC && x[c].mc) {
321
+ if (x[c].mc.rs != null) {
322
+ x[c].mc.r = h;
323
+ if (x[c].mc.rs + h >= maxrowCache) {
324
+ x[c].mc.rs = maxrowCache - h;
325
+ }
326
+ x[c].mc.c = c;
327
+ if (x[c].mc.cs + c >= maxcellCahe) {
328
+ x[c].mc.cs = maxcellCahe - c;
329
+ }
330
+ cfg.merge["".concat(x[c].mc.r, "_").concat(x[c].mc.c)] = x[c].mc;
331
+ offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)] = [x[c].mc.r, x[c].mc.c];
332
+ } else {
333
+ x[c] = {
334
+ mc: {
335
+ r: offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)][0],
336
+ c: offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)][1]
337
+ }
338
+ };
339
+ }
340
+ }
341
+ if (x[c].v != null) {
342
+ if (value.ct != null && value.ct.fa != null) {
343
+ var mask = update(value.ct.fa, x[c].v);
344
+ x[c].m = mask;
345
+ }
346
+ }
347
+ }
348
+ };
349
+ for (var c = mtc; c < maxcellCahe; c += 1) {
350
+ _loop_2(c);
351
+ }
352
+ flowdata[h] = x;
353
+ };
354
+ for (var h = mth; h < maxrowCache; h += 1) {
355
+ var state_1 = _loop_1(h);
356
+ if (_typeof(state_1) === "object") return state_1.value;
357
+ }
358
+ }
359
+ }
360
+ var currFile = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)];
361
+ currFile.config = cfg;
362
+ currFile.dataVerification = dataVerification;
363
+ var cdformat = null;
364
+ var copyIndex = getSheetIndex(ctx, copySheetIndex);
365
+ if (!copyIndex) return;
366
+ var ruleArr = _.cloneDeep(ctx.luckysheetfile[copyIndex].luckysheet_conditionformat_save);
367
+ if (!_.isNil(ruleArr) && ruleArr.length > 0) {
368
+ var currentIndex = getSheetIndex(ctx, ctx.currentSheetId);
369
+ cdformat = _.cloneDeep(ctx.luckysheetfile[currentIndex].luckysheet_conditionformat_save);
370
+ for (var i = 0; i < ruleArr.length; i += 1) {
371
+ var cdformat_cellrange = ruleArr[i].cellrange;
372
+ var emptyRange = [];
373
+ for (var j = 0; j < cdformat_cellrange.length; j += 1) {
374
+ var range = CFSplitRange(cdformat_cellrange[j], {
375
+ row: [c_r1, c_r2],
376
+ column: [c_c1, c_c2]
377
+ }, {
378
+ row: [minh, maxh],
379
+ column: [minc, maxc]
380
+ }, "operatePart");
381
+ if (range.length > 0) {
382
+ emptyRange = emptyRange.concat(range);
383
+ }
384
+ }
385
+ if (emptyRange.length > 0) {
386
+ ruleArr[i].cellrange = [{
387
+ row: [minh, maxh],
388
+ column: [minc, maxc]
389
+ }];
390
+ cdformat.push(ruleArr[i]);
391
+ }
392
+ }
393
+ }
394
+ }
395
+ export function selectionCopyShow(range, ctx) {
396
+ if (range == null) {
397
+ range = ctx.luckysheet_selection_range;
398
+ }
399
+ range = JSON.parse(JSON.stringify(range));
400
+ }
401
+ export function rowHasMerged(ctx, r, c1, c2) {
402
+ var hasMerged = false;
403
+ var flowData = getFlowdata(ctx);
404
+ if (_.isNil(flowData) || _.isNil(flowData[r])) return false;
405
+ for (var c = c1; c <= c2; c += 1) {
406
+ var cell = flowData[r][c];
407
+ if (!_.isNil(cell) && "mc" in cell) {
408
+ hasMerged = true;
409
+ break;
410
+ }
411
+ }
412
+ return hasMerged;
413
+ }
414
+ export function colHasMerged(ctx, c, r1, r2) {
415
+ var _a;
416
+ var hasMerged = false;
417
+ var flowData = getFlowdata(ctx);
418
+ if (_.isNil(flowData)) return false;
419
+ for (var r = r1; r <= r2; r += 1) {
420
+ var cell = (_a = flowData[r]) === null || _a === void 0 ? void 0 : _a[c];
421
+ if (!_.isNil(ctx.config.merge) && !_.isNil(cell) && "mc" in cell && !_.isNil(cell.mc)) {
422
+ hasMerged = true;
423
+ break;
424
+ }
425
+ }
426
+ return hasMerged;
427
+ }
428
+ export function getRowMerge(ctx, rIndex, c1, c2) {
429
+ var flowData = getFlowdata(ctx);
430
+ if (_.isNil(flowData)) return [null, null];
431
+ var r2 = flowData.length - 1;
432
+ var str = null;
433
+ if (rIndex > 0) {
434
+ for (var r = rIndex; r >= 0; r -= 1) {
435
+ for (var c = c1; c <= c2; c += 1) {
436
+ var cell = flowData[r][c];
437
+ if (!_.isNil(cell) && !_.isNil(cell.mc) && "mc" in cell && !_.isNil(ctx.config.merge)) {
438
+ var mc = ctx.config.merge["".concat(cell.mc.r, "_").concat(cell.mc.c)];
439
+ if (_.isNil(str) || mc.r < str) {
440
+ str = mc.r;
441
+ }
442
+ }
443
+ }
444
+ if (!_.isNil(str) && rowHasMerged(ctx, str - 1, c1, c2) && str > 0) {
445
+ r = str;
446
+ } else {
447
+ break;
448
+ }
449
+ }
450
+ } else {
451
+ str = 0;
452
+ }
453
+ var end = null;
454
+ if (rIndex < r2) {
455
+ for (var r = rIndex; r <= r2; r += 1) {
456
+ for (var c = c1; c <= c2; c += 1) {
457
+ var cell = flowData[r][c];
458
+ if (!_.isNil(cell) && !_.isNil(cell.mc) && "mc" in cell && !_.isNil(ctx.config.merge)) {
459
+ var mc = ctx.config.merge["".concat(cell.mc.r, "_").concat(cell.mc.c)];
460
+ if (_.isNil(end) || mc.r + mc.rs - 1 > end) {
461
+ end = mc.r + mc.rs - 1;
462
+ }
463
+ }
464
+ }
465
+ if (!_.isNil(end) && rowHasMerged(ctx, end + 1, c1, c2) && end < r2) {
466
+ r = end;
467
+ } else {
468
+ break;
469
+ }
470
+ }
471
+ } else {
472
+ end = r2;
473
+ }
474
+ return [str, end];
475
+ }
476
+ export function getColMerge(ctx, cIndex, r1, r2) {
477
+ var flowData = getFlowdata(ctx);
478
+ if (_.isNil(flowData)) {
479
+ return [null, null];
480
+ }
481
+ var c2 = flowData[0].length - 1;
482
+ var str = null;
483
+ if (cIndex > 0) {
484
+ for (var c = cIndex; c >= 0; c -= 1) {
485
+ for (var r = r1; r <= r2; r += 1) {
486
+ var cell = flowData[r][c];
487
+ if (!_.isNil(ctx.config.merge) && !_.isNil(cell) && "mc" in cell && !_.isNil(cell.mc)) {
488
+ var mc = ctx.config.merge["".concat(cell.mc.r, "_").concat(cell.mc.c)];
489
+ if (_.isNil(str) || mc.c < str) {
490
+ str = mc.c;
491
+ }
492
+ }
493
+ }
494
+ if (!_.isNil(str) && colHasMerged(ctx, str - 1, r1, r2) && str > 0) {
495
+ c = str;
496
+ } else {
497
+ break;
498
+ }
499
+ }
500
+ } else {
501
+ str = 0;
502
+ }
503
+ var end = null;
504
+ if (cIndex < c2) {
505
+ for (var c = cIndex; c <= c2; c += 1) {
506
+ for (var r = r1; r <= r2; r += 1) {
507
+ var cell = flowData[r][c];
508
+ if (!_.isNil(ctx.config.merge) && !_.isNil(cell) && "mc" in cell && !_.isNil(cell.mc)) {
509
+ var mc = ctx.config.merge["".concat(cell.mc.r, "_").concat(cell.mc.c)];
510
+ if (_.isNil(end) || mc.c + mc.cs - 1 > end) {
511
+ end = mc.c + mc.cs - 1;
512
+ }
513
+ }
514
+ }
515
+ if (!_.isNil(end) && colHasMerged(ctx, end + 1, r1, r2) && end < c2) {
516
+ c = end;
517
+ } else {
518
+ break;
519
+ }
520
+ }
521
+ } else {
522
+ end = c2;
523
+ }
524
+ return [str, end];
525
+ }
526
+ export function moveHighlightCell(ctx, postion, index, type) {
527
+ var _a, _b, _c, _d;
528
+ var _e;
529
+ var flowdata = getFlowdata(ctx);
530
+ if (!flowdata) return;
531
+ var datarowlen = flowdata.length;
532
+ var datacolumnlen = flowdata[0].length;
533
+ var row;
534
+ var row_pre;
535
+ var row_index;
536
+ var row_index_ed;
537
+ var col;
538
+ var col_pre;
539
+ var col_index;
540
+ var col_index_ed;
541
+ if (type === "rangeOfSelect") {
542
+ var last = (_e = ctx.luckysheet_select_save) === null || _e === void 0 ? void 0 : _e[ctx.luckysheet_select_save.length - 1];
543
+ if (!last) {
544
+ console.error("moveHighlightCell: no selection found");
545
+ return;
546
+ }
547
+ var curR = void 0;
548
+ if (_.isNil(last.row_focus)) {
549
+ curR = last.row[0];
550
+ } else {
551
+ curR = last.row_focus;
552
+ }
553
+ var curC = void 0;
554
+ if (_.isNil(last.column_focus)) {
555
+ curC = last.column[0];
556
+ } else {
557
+ curC = last.column_focus;
558
+ }
559
+ var margeset = mergeBorder(ctx, flowdata, curR, curC);
560
+ if (margeset) {
561
+ var str_r = margeset.row[2];
562
+ var end_r = margeset.row[3];
563
+ var str_c = margeset.column[2];
564
+ var end_c = margeset.column[3];
565
+ if (index > 0) {
566
+ if (postion === "down") {
567
+ curR = end_r;
568
+ curC = str_c;
569
+ } else if (postion === "right") {
570
+ curR = str_r;
571
+ curC = end_c;
572
+ }
573
+ } else {
574
+ curR = str_r;
575
+ curC = str_c;
576
+ }
577
+ }
578
+ if (_.isNil(curR) || _.isNil(curC)) {
579
+ console.error("moveHighlightCell: curR or curC is nil");
580
+ return;
581
+ }
582
+ var moveX = _.isNil(last.moveXY) ? curR : last.moveXY.x;
583
+ var moveY = _.isNil(last.moveXY) ? curC : last.moveXY.y;
584
+ if (postion === "down") {
585
+ curR += index;
586
+ moveX = curR;
587
+ } else if (postion === "right") {
588
+ curC += index;
589
+ moveY = curC;
590
+ }
591
+ if (curR >= datarowlen) {
592
+ curR = datarowlen - 1;
593
+ moveX = curR;
594
+ }
595
+ if (curR < 0) {
596
+ curR = 0;
597
+ moveX = curR;
598
+ }
599
+ if (curC >= datacolumnlen) {
600
+ curC = datacolumnlen - 1;
601
+ moveY = curC;
602
+ }
603
+ if (curC < 0) {
604
+ curC = 0;
605
+ moveY = curC;
606
+ }
607
+ var margeset2 = mergeBorder(ctx, flowdata, curR, curC);
608
+ if (margeset2) {
609
+ _a = margeset2.row, row_pre = _a[0], row = _a[1], row_index = _a[2], row_index_ed = _a[3];
610
+ _b = margeset2.column, col_pre = _b[0], col = _b[1], col_index = _b[2], col_index_ed = _b[3];
611
+ } else {
612
+ row = ctx.visibledatarow[moveX];
613
+ row_pre = moveX - 1 === -1 ? 0 : ctx.visibledatarow[moveX - 1];
614
+ col = ctx.visibledatacolumn[moveY];
615
+ col_pre = moveY - 1 === -1 ? 0 : ctx.visibledatacolumn[moveY - 1];
616
+ row_index = curR;
617
+ row_index_ed = curR;
618
+ col_index = curC;
619
+ col_index_ed = curC;
620
+ }
621
+ if (_.isNil(row_index) || _.isNil(row_index_ed) || _.isNil(col_index) || _.isNil(col_index_ed)) {
622
+ console.error("moveHighlightCell: row_index or row_index_ed or col_index or col_index_ed is nil");
623
+ return;
624
+ }
625
+ last.row = [row_index, row_index_ed];
626
+ last.column = [col_index, col_index_ed];
627
+ last.row_focus = row_index;
628
+ last.column_focus = col_index;
629
+ last.moveXY = {
630
+ x: moveX,
631
+ y: moveY
632
+ };
633
+ normalizeSelection(ctx, ctx.luckysheet_select_save);
634
+ scrollToHighlightCell(ctx, row_index, col_index);
635
+ } else if (type === "rangeOfFormula") {
636
+ var last = ctx.formulaCache.func_selectedrange;
637
+ if (!last) return;
638
+ var curR = void 0;
639
+ if (_.isNil(last.row_focus)) {
640
+ curR = last.row[0];
641
+ } else {
642
+ curR = last.row_focus;
643
+ }
644
+ var curC = void 0;
645
+ if (_.isNil(last.column_focus)) {
646
+ curC = last.column[0];
647
+ } else {
648
+ curC = last.column_focus;
649
+ }
650
+ var margeset = mergeBorder(ctx, flowdata, curR, curC);
651
+ if (margeset) {
652
+ var str_r = margeset.row[2];
653
+ var end_r = margeset.row[3];
654
+ var str_c = margeset.column[2];
655
+ var end_c = margeset.column[3];
656
+ if (index > 0) {
657
+ if (postion === "down") {
658
+ curR = end_r;
659
+ curC = str_c;
660
+ } else if (postion === "right") {
661
+ curR = str_r;
662
+ curC = end_c;
663
+ }
664
+ } else {
665
+ curR = str_r;
666
+ curC = str_c;
667
+ }
668
+ }
669
+ if (_.isNil(curR) || _.isNil(curC)) {
670
+ console.error("moveHighlightCell: curR or curC is nil");
671
+ return;
672
+ }
673
+ var moveX = _.isNil(last.moveXY) ? curR : last.moveXY.x;
674
+ var moveY = _.isNil(last.moveXY) ? curC : last.moveXY.y;
675
+ if (postion === "down") {
676
+ curR += index;
677
+ moveX = curR;
678
+ } else if (postion === "right") {
679
+ curC += index;
680
+ moveY = curC;
681
+ }
682
+ if (curR >= datarowlen) {
683
+ curR = datarowlen - 1;
684
+ moveX = curR;
685
+ }
686
+ if (curR < 0) {
687
+ curR = 0;
688
+ moveX = curR;
689
+ }
690
+ if (curC >= datacolumnlen) {
691
+ curC = datacolumnlen - 1;
692
+ moveY = curC;
693
+ }
694
+ if (curC < 0) {
695
+ curC = 0;
696
+ moveY = curC;
697
+ }
698
+ var margeset2 = mergeBorder(ctx, flowdata, curR, curC);
699
+ if (margeset2) {
700
+ _c = margeset2.row, row_pre = _c[0], row = _c[1], row_index = _c[2], row_index_ed = _c[3];
701
+ _d = margeset2.column, col_pre = _d[0], col = _d[1], col_index = _d[2], col_index_ed = _d[3];
702
+ } else {
703
+ row = ctx.visibledatarow[moveX];
704
+ row_pre = moveX - 1 === -1 ? 0 : ctx.visibledatarow[moveX - 1];
705
+ row_index = moveX;
706
+ row_index_ed = moveX;
707
+ col = ctx.visibledatacolumn[moveY];
708
+ col_pre = moveY - 1 === -1 ? 0 : ctx.visibledatacolumn[moveY - 1];
709
+ col_index = moveY;
710
+ col_index_ed = moveY;
711
+ }
712
+ if (_.isNil(col) || _.isNil(col_pre) || _.isNil(row) || _.isNil(row_pre) || _.isNil(row_index) || _.isNil(row_index_ed) || _.isNil(col_index) || _.isNil(col_index_ed)) {
713
+ console.error("moveHighlightCell: some values of func_selectedrange is nil");
714
+ return;
715
+ }
716
+ ctx.formulaCache.func_selectedrange = {
717
+ left: col_pre,
718
+ width: col - col_pre - 1,
719
+ top: row_pre,
720
+ height: row - row_pre - 1,
721
+ left_move: col_pre,
722
+ width_move: col - col_pre - 1,
723
+ top_move: row_pre,
724
+ height_move: row - row_pre - 1,
725
+ row: [row_index, row_index_ed],
726
+ column: [col_index, col_index_ed],
727
+ row_focus: row_index,
728
+ column_focus: col_index,
729
+ moveXY: {
730
+ x: moveX,
731
+ y: moveY
732
+ }
733
+ };
734
+ }
735
+ }
736
+ export function moveHighlightRange(ctx, postion, index, type) {
737
+ var row;
738
+ var row_pre;
739
+ var col;
740
+ var col_pre;
741
+ var flowData = getFlowdata(ctx);
742
+ if (_.isNil(flowData)) return;
743
+ if (_.isNil(ctx.luckysheet_select_save)) return;
744
+ if (type === "rangeOfSelect") {
745
+ var last = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
746
+ var curR = last.row[0];
747
+ var endR = last.row[1];
748
+ var curC = last.column[0];
749
+ var endC = last.column[1];
750
+ var rf = last.row_focus;
751
+ var cf = last.column_focus;
752
+ if (_.isNil(rf) || _.isNil(cf)) return;
753
+ var datarowlen = flowData.length;
754
+ var datacolumnlen = flowData[0].length;
755
+ if (postion === "down") {
756
+ if (rowHasMerged(ctx, rf, curC, endC)) {
757
+ var rfMerge = getRowMerge(ctx, rf, curC, endC);
758
+ var rf_str = rfMerge[0];
759
+ var rf_end = rfMerge[1];
760
+ if (!_.isNil(rf_str) && rf_str > curR && rf_end === endR) {
761
+ if (index > 0 && rowHasMerged(ctx, curR, curC, endC)) {
762
+ var v = getRowMerge(ctx, curR, curC, endC)[1];
763
+ if (!_.isNil(v)) {
764
+ curR = v;
765
+ }
766
+ }
767
+ curR += index;
768
+ } else if (!_.isNil(rf_end) && rf_end < endR && rf_str === curR) {
769
+ if (index < 0 && rowHasMerged(ctx, endR, curC, endC)) {
770
+ var v = getRowMerge(ctx, curR, curC, endC)[0];
771
+ if (!_.isNil(v)) {
772
+ endR = v;
773
+ }
774
+ }
775
+ endR += index;
776
+ } else {
777
+ if (index > 0) {
778
+ endR += index;
779
+ } else {
780
+ curR += index;
781
+ }
782
+ }
783
+ } else {
784
+ if (rf > curR && rf === endR) {
785
+ if (index > 0 && rowHasMerged(ctx, curR, curC, endC)) {
786
+ var v = getRowMerge(ctx, curR, curC, endC)[1];
787
+ if (!_.isNil(v)) {
788
+ curR = v;
789
+ }
790
+ }
791
+ curR += index;
792
+ } else if (rf < endR && rf === curR) {
793
+ if (index < 0 && rowHasMerged(ctx, endR, curC, endC)) {
794
+ var v = getRowMerge(ctx, endR, curC, endC)[0];
795
+ if (!_.isNil(v)) {
796
+ endR = v;
797
+ }
798
+ }
799
+ endR += index;
800
+ } else if (rf === curR && rf === endR) {
801
+ if (index > 0) {
802
+ endR += index;
803
+ } else {
804
+ curR += index;
805
+ }
806
+ }
807
+ }
808
+ if (endR >= datarowlen) {
809
+ endR = datarowlen - 1;
810
+ }
811
+ if (endR < 0) {
812
+ endR = 0;
813
+ }
814
+ if (curR >= datarowlen) {
815
+ curR = datarowlen - 1;
816
+ }
817
+ if (curR < 0) {
818
+ curR = 0;
819
+ }
820
+ } else {
821
+ if (colHasMerged(ctx, cf, curR, endR)) {
822
+ var cfMerge = getColMerge(ctx, cf, curR, endR);
823
+ var cf_str = cfMerge[0];
824
+ var cf_end = cfMerge[1];
825
+ if (!_.isNil(cf_str) && cf_str > curC && cf_end === endC) {
826
+ if (index > 0 && colHasMerged(ctx, curC, curR, endR)) {
827
+ var v = getColMerge(ctx, curC, curR, endR)[1];
828
+ if (!_.isNil(v)) {
829
+ curC = v;
830
+ }
831
+ curC += index;
832
+ }
833
+ curC += index;
834
+ } else if (!_.isNil(cf_end) && cf_end < endC && cf_str === curC) {
835
+ if (index < 0 && colHasMerged(ctx, endC, curR, endR)) {
836
+ var v = getColMerge(ctx, endC, curR, endR)[0];
837
+ if (!_.isNil(v)) {
838
+ endC = v;
839
+ }
840
+ }
841
+ endC += index;
842
+ } else {
843
+ if (index > 0) {
844
+ endC += index;
845
+ } else {
846
+ curC += index;
847
+ }
848
+ }
849
+ } else {
850
+ if (cf > curC && cf === endC) {
851
+ if (index > 0 && colHasMerged(ctx, curC, curR, endR)) {
852
+ var v = getColMerge(ctx, curC, curR, endR)[1];
853
+ if (!_.isNil(v)) {
854
+ curC = v;
855
+ }
856
+ curC += index;
857
+ }
858
+ curC += index;
859
+ } else if (cf < endC && cf === curC) {
860
+ if (index < 0 && colHasMerged(ctx, endC, curR, endR)) {
861
+ var v = getColMerge(ctx, endC, curR, endR)[0];
862
+ if (!_.isNil(v)) {
863
+ endC = v;
864
+ }
865
+ }
866
+ endC += index;
867
+ } else if (cf === curC && cf === endC) {
868
+ if (index > 0) {
869
+ endC += index;
870
+ } else {
871
+ curC += index;
872
+ }
873
+ }
874
+ }
875
+ if (endC >= datacolumnlen) {
876
+ endC = datacolumnlen - 1;
877
+ }
878
+ if (endC < 0) {
879
+ endC = 0;
880
+ }
881
+ if (curC >= datacolumnlen) {
882
+ curC = datacolumnlen - 1;
883
+ }
884
+ if (curC < 0) {
885
+ curC = 0;
886
+ }
887
+ }
888
+ var rowseleted = [curR, endR];
889
+ var columnseleted = [curC, endC];
890
+ row = ctx.visibledatarow[endR];
891
+ row_pre = curR - 1 === -1 ? 0 : ctx.visibledatarow[curR - 1];
892
+ col = ctx.visibledatacolumn[endC];
893
+ col_pre = curC - 1 === -1 ? 0 : ctx.visibledatacolumn[curC - 1];
894
+ var changeparam = mergeMoveMain(ctx, columnseleted, rowseleted, last, row_pre, row - row_pre - 1, col_pre, col - col_pre - 1);
895
+ if (!_.isNil(changeparam)) {
896
+ columnseleted = changeparam[0], rowseleted = changeparam[1];
897
+ }
898
+ last.row = rowseleted;
899
+ last.column = columnseleted;
900
+ normalizeSelection(ctx, ctx.luckysheet_select_save);
901
+ if (postion === "down") {
902
+ var rowToScroll = last.row_focus === last.row[0] ? last.row[1] : last.row[0];
903
+ scrollToHighlightCell(ctx, rowToScroll, -1);
904
+ } else {
905
+ var columnToScroll = last.column_focus === last.column[0] ? last.column[1] : last.column[0];
906
+ scrollToHighlightCell(ctx, -1, columnToScroll);
907
+ }
908
+ } else if (type === "rangeOfFormula") {
909
+ var last = ctx.formulaCache.func_selectedrange;
910
+ if (_.isNil(last)) return;
911
+ var curR = last.row[0];
912
+ var endR = last.row[1];
913
+ var curC = last.column[0];
914
+ var endC = last.column[1];
915
+ var rf = last.row_focus;
916
+ var cf = last.column_focus;
917
+ var datarowlen = flowData.length;
918
+ var datacolumnlen = flowData[0].length;
919
+ if (postion === "down") {
920
+ if (!_.isNil(rf) && rowHasMerged(ctx, rf, curC, endC)) {
921
+ var rfMerge = getRowMerge(ctx, rf, curC, endC);
922
+ var rf_str = rfMerge[0];
923
+ var rf_end = rfMerge[1];
924
+ if (!_.isNil(rf_str) && rf_str > curR && rf_end === endR) {
925
+ if (index > 0 && rowHasMerged(ctx, curR, curC, endC)) {
926
+ var v = getRowMerge(ctx, curR, curC, endC)[1];
927
+ if (!_.isNil(v)) {
928
+ curR = v;
929
+ }
930
+ }
931
+ curR += index;
932
+ } else if (!_.isNil(rf_end) && rf_end < endR && rf_str === curR) {
933
+ if (index < 0 && rowHasMerged(ctx, endR, curC, endC)) {
934
+ var v = getRowMerge(ctx, endR, curC, endC)[0];
935
+ if (!_.isNil(v)) {
936
+ endR = v;
937
+ }
938
+ endR += index;
939
+ }
940
+ } else {
941
+ if (index > 0) {
942
+ endR += index;
943
+ } else {
944
+ curR += index;
945
+ }
946
+ }
947
+ } else {
948
+ if (!_.isNil(rf) && rf > curR && rf === endR) {
949
+ if (index > 0 && rowHasMerged(ctx, curR, curC, endC)) {
950
+ var v = getRowMerge(ctx, curR, curC, endC)[1];
951
+ if (!_.isNil(v)) {
952
+ curR = v;
953
+ }
954
+ }
955
+ curR += index;
956
+ } else if (!_.isNil(rf) && rf < endR && rf === curR) {
957
+ if (index < 0 && rowHasMerged(ctx, endR, curC, endC)) {
958
+ var v = getRowMerge(ctx, endR, curC, endC)[0];
959
+ if (!_.isNil(v)) {
960
+ endR = v;
961
+ }
962
+ }
963
+ endR += index;
964
+ } else if (rf === curR && rf === endR) {
965
+ if (index > 0) {
966
+ endR += index;
967
+ } else {
968
+ curR += index;
969
+ }
970
+ }
971
+ }
972
+ if (endR >= datarowlen) {
973
+ endR = datarowlen - 1;
974
+ }
975
+ if (endR < 0) {
976
+ endR = 0;
977
+ }
978
+ if (curR >= datarowlen) {
979
+ curR = datarowlen - 1;
980
+ }
981
+ if (curR < 0) {
982
+ curR = 0;
983
+ }
984
+ } else {
985
+ if (!_.isNil(cf) && colHasMerged(ctx, cf, curR, endR)) {
986
+ var cfMerge = getColMerge(ctx, cf, curR, endR);
987
+ var cf_str = cfMerge[0];
988
+ var cf_end = cfMerge[1];
989
+ if (!_.isNil(cf_str) && cf_str > curC && cf_end === endC) {
990
+ if (index > 0 && colHasMerged(ctx, curC, curR, endR)) {
991
+ var v = getColMerge(ctx, curC, curR, endR)[1];
992
+ if (!_.isNil(v)) {
993
+ curC = v;
994
+ }
995
+ }
996
+ curC += index;
997
+ } else if (!_.isNil(cf_end) && cf_end < endC && cf_str === curC) {
998
+ if (index < 0 && colHasMerged(ctx, endC, curR, endR)) {
999
+ var v = getColMerge(ctx, endC, curR, endR)[0];
1000
+ if (!_.isNil(v)) {
1001
+ endC = v;
1002
+ }
1003
+ }
1004
+ endC += index;
1005
+ } else {
1006
+ if (index > 0) {
1007
+ endC += index;
1008
+ } else {
1009
+ curC += index;
1010
+ }
1011
+ }
1012
+ } else {
1013
+ if (!_.isNil(cf) && cf > curC && cf === endC) {
1014
+ if (index > 0 && colHasMerged(ctx, curC, curR, endR)) {
1015
+ var v = getColMerge(ctx, curC, curR, endR)[1];
1016
+ if (!_.isNil(v)) {
1017
+ curC = v;
1018
+ }
1019
+ }
1020
+ curC += index;
1021
+ } else if (!_.isNil(cf) && cf < endC && cf === curC) {
1022
+ if (index < 0 && colHasMerged(ctx, endC, curR, endR)) {
1023
+ var v = getColMerge(ctx, endC, curR, endR)[0];
1024
+ if (!_.isNil(v)) {
1025
+ endC = v;
1026
+ }
1027
+ }
1028
+ endC += index;
1029
+ } else if (cf === curC && cf === endC) {
1030
+ if (index > 0) {
1031
+ endC += index;
1032
+ } else {
1033
+ curC += index;
1034
+ }
1035
+ }
1036
+ }
1037
+ if (endC >= datacolumnlen) {
1038
+ endC = datacolumnlen - 1;
1039
+ }
1040
+ if (endC < 0) {
1041
+ endC = 0;
1042
+ }
1043
+ if (curC >= datacolumnlen) {
1044
+ curC = datacolumnlen - 1;
1045
+ }
1046
+ if (curC < 0) {
1047
+ curC = 0;
1048
+ }
1049
+ }
1050
+ var rowseleted = [curR, endR];
1051
+ var columnseleted = [curC, endC];
1052
+ row = ctx.visibledatarow[endR];
1053
+ row_pre = curR - 1 === -1 ? 0 : ctx.visibledatarow[curR - 1];
1054
+ col = ctx.visibledatacolumn[endC];
1055
+ col_pre = curC - 1 === -1 ? 0 : ctx.visibledatacolumn[curC - 1];
1056
+ var top_1 = row_pre;
1057
+ var height = row - row_pre - 1;
1058
+ var left = col_pre;
1059
+ var width = col - col_pre - 1;
1060
+ var changeparam = mergeMoveMain(ctx, columnseleted, rowseleted, last, top_1, height, left, width);
1061
+ if (!_.isNil(changeparam)) {
1062
+ columnseleted = changeparam[0], rowseleted = changeparam[1], top_1 = changeparam[2], height = changeparam[3], left = changeparam[4], width = changeparam[5];
1063
+ }
1064
+ ctx.formulaCache.func_selectedrange = {
1065
+ left: left,
1066
+ width: width,
1067
+ top: top_1,
1068
+ height: height,
1069
+ left_move: left,
1070
+ width_move: width,
1071
+ top_move: top_1,
1072
+ height_move: height,
1073
+ row: rowseleted,
1074
+ column: columnseleted,
1075
+ row_focus: rf,
1076
+ column_focus: cf
1077
+ };
1078
+ }
1079
+ }
1080
+ function getHtmlBorderStyle(type, color) {
1081
+ var style = "";
1082
+ var borderType = {
1083
+ "0": "none",
1084
+ "1": "Thin",
1085
+ "2": "Hair",
1086
+ "3": "Dotted",
1087
+ "4": "Dashed",
1088
+ "5": "DashDot",
1089
+ "6": "DashDotDot",
1090
+ "7": "Double",
1091
+ "8": "Medium",
1092
+ "9": "MediumDashed",
1093
+ "10": "MediumDashDot",
1094
+ "11": "MediumDashDotDot",
1095
+ "12": "SlantedDashDot",
1096
+ "13": "Thick"
1097
+ };
1098
+ type = borderType[type.toString()];
1099
+ if (type.indexOf("Medium") > -1) {
1100
+ style += "1pt ";
1101
+ } else if (type === "Thick") {
1102
+ style += "1.5pt ";
1103
+ } else {
1104
+ style += "0.5pt ";
1105
+ }
1106
+ if (type === "Hair") {
1107
+ style += "double ";
1108
+ } else if (type.indexOf("DashDotDot") > -1) {
1109
+ style += "dotted ";
1110
+ } else if (type.indexOf("DashDot") > -1) {
1111
+ style += "dashed ";
1112
+ } else if (type.indexOf("Dotted") > -1) {
1113
+ style += "dotted ";
1114
+ } else if (type.indexOf("Dashed") > -1) {
1115
+ style += "dashed ";
1116
+ } else {
1117
+ style += "solid ";
1118
+ }
1119
+ return "".concat(style + color, ";");
1120
+ }
1121
+ export function rangeValueToHtml(ctx, sheetId, ranges) {
1122
+ var _a, _b, _c;
1123
+ var idx = getSheetIndex(ctx, sheetId);
1124
+ if (idx == null) return "";
1125
+ var sheet = ctx.luckysheetfile[idx];
1126
+ var rowIndexArr = [];
1127
+ var colIndexArr = [];
1128
+ for (var s = 0; s < ((_a = ranges === null || ranges === void 0 ? void 0 : ranges.length) !== null && _a !== void 0 ? _a : 0); s += 1) {
1129
+ var range = ranges[s];
1130
+ var r1 = range.row[0];
1131
+ var r2 = range.row[1];
1132
+ var c1 = range.column[0];
1133
+ var c2 = range.column[1];
1134
+ for (var copyR = r1; copyR <= r2; copyR += 1) {
1135
+ if (!rowIndexArr.includes(copyR)) {
1136
+ rowIndexArr.push(copyR);
1137
+ }
1138
+ for (var copyC = c1; copyC <= c2; copyC += 1) {
1139
+ if (!colIndexArr.includes(copyC)) {
1140
+ colIndexArr.push(copyC);
1141
+ }
1142
+ }
1143
+ }
1144
+ }
1145
+ var borderInfoCompute;
1146
+ if (((_b = sheet.config) === null || _b === void 0 ? void 0 : _b.borderInfo) && sheet.config.borderInfo.length > 0) {
1147
+ borderInfoCompute = getBorderInfoCompute(ctx, sheetId);
1148
+ }
1149
+ var cpdata = "";
1150
+ var d = sheet.data;
1151
+ if (!d) return null;
1152
+ var colgroup = "";
1153
+ for (var i = 0; i < rowIndexArr.length; i += 1) {
1154
+ var r = rowIndexArr[i];
1155
+ cpdata += "<tr>";
1156
+ var _loop_3 = function _loop_3(j) {
1157
+ var c = colIndexArr[j];
1158
+ var column = '<td ${span} style="${style}">';
1159
+ var cell = (_c = d[r]) === null || _c === void 0 ? void 0 : _c[c];
1160
+ if (cell != null) {
1161
+ var style = "";
1162
+ var span = "";
1163
+ if (r === rowIndexArr[0]) {
1164
+ if (_.isNil(sheet.config) || _.isNil(sheet.config.columnlen) || _.isNil(sheet.config.columnlen[c.toString()])) {
1165
+ colgroup += '<colgroup width="72px"></colgroup>';
1166
+ } else {
1167
+ colgroup += "<colgroup width=\"".concat(sheet.config.columnlen[c.toString()], "px\"></colgroup>");
1168
+ }
1169
+ }
1170
+ if (c === colIndexArr[0]) {
1171
+ if (_.isNil(sheet.config) || _.isNil(sheet.config.rowlen) || _.isNil(sheet.config.rowlen[r.toString()])) {
1172
+ style += "height:19px;";
1173
+ } else {
1174
+ style += "height:".concat(sheet.config.rowlen[r.toString()], "px;");
1175
+ }
1176
+ }
1177
+ var reg = /^(w|W)((0?)|(0\.0+))$/;
1178
+ var c_value = void 0;
1179
+ if (!_.isNil(cell.ct) && !_.isNil(cell.ct.fa) && cell.ct.fa.match(reg)) {
1180
+ c_value = getCellValue(r, c, d);
1181
+ } else {
1182
+ c_value = getCellValue(r, c, d, "m");
1183
+ }
1184
+ var styleObj = getStyleByCell(ctx, d, r, c);
1185
+ style += _.map(styleObj, function (v, key) {
1186
+ return "".concat(_.kebabCase(key), ":").concat(_.isNumber(v) ? "".concat(v, "px") : v, ";");
1187
+ }).join("");
1188
+ if (cell.mc) {
1189
+ if ("rs" in cell.mc) {
1190
+ span = "rowspan=\"".concat(cell.mc.rs, "\" colspan=\"").concat(cell.mc.cs, "\"");
1191
+ if (borderInfoCompute && borderInfoCompute["".concat(r, "_").concat(c)]) {
1192
+ var bl_obj_1 = {
1193
+ color: {},
1194
+ style: {}
1195
+ };
1196
+ var br_obj_1 = {
1197
+ color: {},
1198
+ style: {}
1199
+ };
1200
+ var bt_obj_1 = {
1201
+ color: {},
1202
+ style: {}
1203
+ };
1204
+ var bb_obj_1 = {
1205
+ color: {},
1206
+ style: {}
1207
+ };
1208
+ for (var bd_r = r; bd_r < r + cell.mc.rs; bd_r += 1) {
1209
+ for (var bd_c = c; bd_c < c + cell.mc.cs; bd_c += 1) {
1210
+ if (bd_r === r && borderInfoCompute["".concat(bd_r, "_").concat(bd_c)] && borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].t) {
1211
+ var linetype = borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].t.style;
1212
+ var bcolor = borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].t.color;
1213
+ if (_.isNil(bt_obj_1.style[linetype])) {
1214
+ bt_obj_1.style[linetype] = 1;
1215
+ } else {
1216
+ bt_obj_1.style[linetype] += 1;
1217
+ }
1218
+ if (_.isNil(bt_obj_1.color[bcolor])) {
1219
+ bt_obj_1.color[bcolor] = 1;
1220
+ } else {
1221
+ bt_obj_1.color[bcolor] += 1;
1222
+ }
1223
+ }
1224
+ if (bd_r === r + cell.mc.rs - 1 && borderInfoCompute["".concat(bd_r, "_").concat(bd_c)] && borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].b) {
1225
+ var linetype = borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].b.style;
1226
+ var bcolor = borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].b.color;
1227
+ if (_.isNil(bb_obj_1.style[linetype])) {
1228
+ bb_obj_1.style[linetype] = 1;
1229
+ } else {
1230
+ bb_obj_1.style[linetype] += 1;
1231
+ }
1232
+ if (_.isNil(bb_obj_1.color[bcolor])) {
1233
+ bb_obj_1.color[bcolor] = 1;
1234
+ } else {
1235
+ bb_obj_1.color[bcolor] += 1;
1236
+ }
1237
+ }
1238
+ if (bd_c === c && borderInfoCompute["".concat(bd_r, "_").concat(bd_c)] && borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].l) {
1239
+ var linetype = borderInfoCompute["".concat(r, "_").concat(c)].l.style;
1240
+ var bcolor = borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].l.color;
1241
+ if (_.isNil(bl_obj_1.style[linetype])) {
1242
+ bl_obj_1.style[linetype] = 1;
1243
+ } else {
1244
+ bl_obj_1.style[linetype] += 1;
1245
+ }
1246
+ if (_.isNil(bl_obj_1.color[bcolor])) {
1247
+ bl_obj_1.color[bcolor] = 1;
1248
+ } else {
1249
+ bl_obj_1.color[bcolor] += 1;
1250
+ }
1251
+ }
1252
+ if (bd_c === c + cell.mc.cs - 1 && borderInfoCompute["".concat(bd_r, "_").concat(bd_c)] && borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].r) {
1253
+ var linetype = borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].r.style;
1254
+ var bcolor = borderInfoCompute["".concat(bd_r, "_").concat(bd_c)].r.color;
1255
+ if (_.isNil(br_obj_1.style[linetype])) {
1256
+ br_obj_1.style[linetype] = 1;
1257
+ } else {
1258
+ br_obj_1.style[linetype] += 1;
1259
+ }
1260
+ if (_.isNil(br_obj_1.color[bcolor])) {
1261
+ br_obj_1.color[bcolor] = 1;
1262
+ } else {
1263
+ br_obj_1.color[bcolor] += 1;
1264
+ }
1265
+ }
1266
+ }
1267
+ }
1268
+ var rowlen_1 = cell.mc.rs;
1269
+ var collen_1 = cell.mc.cs;
1270
+ if (JSON.stringify(bl_obj_1).length > 23) {
1271
+ var bl_color_1 = null;
1272
+ var bl_style_1 = null;
1273
+ Object.keys(bl_obj_1.color).forEach(function (x) {
1274
+ if (bl_obj_1.color[x] >= rowlen_1 / 2) {
1275
+ bl_color_1 = x;
1276
+ }
1277
+ });
1278
+ Object.keys(bl_obj_1.style).forEach(function (x) {
1279
+ if (bl_obj_1.style[x] >= rowlen_1 / 2) {
1280
+ bl_style_1 = x;
1281
+ }
1282
+ });
1283
+ if (!_.isNil(bl_color_1) && !_.isNil(bl_style_1)) {
1284
+ style += "border-left:".concat(getHtmlBorderStyle(bl_style_1, bl_color_1));
1285
+ }
1286
+ }
1287
+ if (JSON.stringify(br_obj_1).length > 23) {
1288
+ var br_color_1 = null;
1289
+ var br_style_1 = null;
1290
+ Object.keys(br_obj_1.color).forEach(function (x) {
1291
+ if (br_obj_1.color[x] >= rowlen_1 / 2) {
1292
+ br_color_1 = x;
1293
+ }
1294
+ });
1295
+ Object.keys(br_obj_1.style).forEach(function (x) {
1296
+ if (br_obj_1.style[x] >= rowlen_1 / 2) {
1297
+ br_style_1 = x;
1298
+ }
1299
+ });
1300
+ if (!_.isNil(br_color_1) && !_.isNil(br_style_1)) {
1301
+ style += "border-right:".concat(getHtmlBorderStyle(br_style_1, br_color_1));
1302
+ }
1303
+ }
1304
+ if (JSON.stringify(bt_obj_1).length > 23) {
1305
+ var bt_color_1 = null;
1306
+ var bt_style_1 = null;
1307
+ Object.keys(bt_obj_1.color).forEach(function (x) {
1308
+ if (bt_obj_1.color[x] >= collen_1 / 2) {
1309
+ bt_color_1 = x;
1310
+ }
1311
+ });
1312
+ Object.keys(bt_obj_1.style).forEach(function (x) {
1313
+ if (bt_obj_1.style[x] >= collen_1 / 2) {
1314
+ bt_style_1 = x;
1315
+ }
1316
+ });
1317
+ if (!_.isNil(bt_color_1) && !_.isNil(bt_style_1)) {
1318
+ style += "border-top:".concat(getHtmlBorderStyle(bt_style_1, bt_color_1));
1319
+ }
1320
+ }
1321
+ if (JSON.stringify(bb_obj_1).length > 23) {
1322
+ var bb_color_1 = null;
1323
+ var bb_style_1 = null;
1324
+ Object.keys(bb_obj_1.color).forEach(function (x) {
1325
+ if (bb_obj_1.color[x] >= collen_1 / 2) {
1326
+ bb_color_1 = x;
1327
+ }
1328
+ });
1329
+ Object.keys(bb_obj_1.style).forEach(function (x) {
1330
+ if (bb_obj_1.style[x] >= collen_1 / 2) {
1331
+ bb_style_1 = x;
1332
+ }
1333
+ });
1334
+ if (!_.isNil(bb_color_1) && !_.isNil(bb_style_1)) {
1335
+ style += "border-bottom:".concat(getHtmlBorderStyle(bb_style_1, bb_color_1));
1336
+ }
1337
+ }
1338
+ }
1339
+ } else {
1340
+ return "continue";
1341
+ }
1342
+ } else {
1343
+ if (borderInfoCompute && borderInfoCompute["".concat(r, "_").concat(c)]) {
1344
+ if (borderInfoCompute["".concat(r, "_").concat(c)].l) {
1345
+ var linetype = borderInfoCompute["".concat(r, "_").concat(c)].l.style;
1346
+ var bcolor = borderInfoCompute["".concat(r, "_").concat(c)].l.color;
1347
+ style += "border-left:".concat(getHtmlBorderStyle(linetype, bcolor));
1348
+ }
1349
+ if (borderInfoCompute["".concat(r, "_").concat(c)].r) {
1350
+ var linetype = borderInfoCompute["".concat(r, "_").concat(c)].r.style;
1351
+ var bcolor = borderInfoCompute["".concat(r, "_").concat(c)].r.color;
1352
+ style += "border-right:".concat(getHtmlBorderStyle(linetype, bcolor));
1353
+ }
1354
+ if (borderInfoCompute["".concat(r, "_").concat(c)].b) {
1355
+ var linetype = borderInfoCompute["".concat(r, "_").concat(c)].b.style;
1356
+ var bcolor = borderInfoCompute["".concat(r, "_").concat(c)].b.color;
1357
+ style += "border-bottom:".concat(getHtmlBorderStyle(linetype, bcolor));
1358
+ }
1359
+ if (borderInfoCompute["".concat(r, "_").concat(c)].t) {
1360
+ var linetype = borderInfoCompute["".concat(r, "_").concat(c)].t.style;
1361
+ var bcolor = borderInfoCompute["".concat(r, "_").concat(c)].t.color;
1362
+ style += "border-top:".concat(getHtmlBorderStyle(linetype, bcolor));
1363
+ }
1364
+ }
1365
+ }
1366
+ column = replaceHtml(column, {
1367
+ style: style,
1368
+ span: span
1369
+ });
1370
+ if (_.isNil(c_value)) {
1371
+ c_value = getCellValue(r, c, d);
1372
+ }
1373
+ if (_.isNil(c_value)) {
1374
+ c_value = "";
1375
+ }
1376
+ column += escapeHTMLTag(c_value);
1377
+ } else {
1378
+ var style = "";
1379
+ if (borderInfoCompute && borderInfoCompute["".concat(r, "_").concat(c)]) {
1380
+ if (borderInfoCompute["".concat(r, "_").concat(c)].l) {
1381
+ var linetype = borderInfoCompute["".concat(r, "_").concat(c)].l.style;
1382
+ var bcolor = borderInfoCompute["".concat(r, "_").concat(c)].l.color;
1383
+ style += "border-left:".concat(getHtmlBorderStyle(linetype, bcolor));
1384
+ }
1385
+ if (borderInfoCompute["".concat(r, "_").concat(c)].r) {
1386
+ var linetype = borderInfoCompute["".concat(r, "_").concat(c)].r.style;
1387
+ var bcolor = borderInfoCompute["".concat(r, "_").concat(c)].r.color;
1388
+ style += "border-right:".concat(getHtmlBorderStyle(linetype, bcolor));
1389
+ }
1390
+ if (borderInfoCompute["".concat(r, "_").concat(c)].b) {
1391
+ var linetype = borderInfoCompute["".concat(r, "_").concat(c)].b.style;
1392
+ var bcolor = borderInfoCompute["".concat(r, "_").concat(c)].b.color;
1393
+ style += "border-bottom:".concat(getHtmlBorderStyle(linetype, bcolor));
1394
+ }
1395
+ if (borderInfoCompute["".concat(r, "_").concat(c)].t) {
1396
+ var linetype = borderInfoCompute["".concat(r, "_").concat(c)].t.style;
1397
+ var bcolor = borderInfoCompute["".concat(r, "_").concat(c)].t.color;
1398
+ style += "border-top:".concat(getHtmlBorderStyle(linetype, bcolor));
1399
+ }
1400
+ }
1401
+ column += "";
1402
+ if (r === rowIndexArr[0]) {
1403
+ if (_.isNil(sheet.config) || _.isNil(sheet.config.columnlen) || _.isNil(sheet.config.columnlen[c.toString()])) {
1404
+ colgroup += '<colgroup width="72px"></colgroup>';
1405
+ } else {
1406
+ colgroup += "<colgroup width=\"".concat(sheet.config.columnlen[c.toString()], "px\"></colgroup>");
1407
+ }
1408
+ }
1409
+ if (c === colIndexArr[0]) {
1410
+ if (_.isNil(sheet.config) || _.isNil(sheet.config.rowlen) || _.isNil(sheet.config.rowlen[r.toString()])) {
1411
+ style += "height:19px;";
1412
+ } else {
1413
+ style += "height:".concat(sheet.config.rowlen[r.toString()], "px;");
1414
+ }
1415
+ }
1416
+ column = replaceHtml(column, {
1417
+ style: style,
1418
+ span: ""
1419
+ });
1420
+ column += "";
1421
+ }
1422
+ column += "</td>";
1423
+ cpdata += column;
1424
+ };
1425
+ for (var j = 0; j < colIndexArr.length; j += 1) {
1426
+ _loop_3(j);
1427
+ }
1428
+ cpdata += "</tr>";
1429
+ }
1430
+ return "<table data-type=\"fortune-copy-action-table\">".concat(colgroup).concat(cpdata, "</table>");
1431
+ }
1432
+ export function copy(ctx) {
1433
+ var _a, _b, _c, _d;
1434
+ var flowdata = getFlowdata(ctx);
1435
+ ctx.luckysheet_selection_range = [];
1436
+ var copyRange = [];
1437
+ var RowlChange = false;
1438
+ var HasMC = false;
1439
+ for (var s = 0; s < ((_b = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); s += 1) {
1440
+ var range = ctx.luckysheet_select_save[s];
1441
+ var r1 = range.row[0];
1442
+ var r2 = range.row[1];
1443
+ var c1 = range.column[0];
1444
+ var c2 = range.column[1];
1445
+ for (var copyR = r1; copyR <= r2; copyR += 1) {
1446
+ if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[copyR])) {
1447
+ continue;
1448
+ }
1449
+ if (!_.isNil(ctx.config.rowlen) && copyR in ctx.config.rowlen) {
1450
+ RowlChange = true;
1451
+ }
1452
+ for (var copyC = c1; copyC <= c2; copyC += 1) {
1453
+ if (!_.isNil(ctx.config.colhidden) && !_.isNil(ctx.config.colhidden[copyC])) {
1454
+ continue;
1455
+ }
1456
+ var cell = (_c = flowdata === null || flowdata === void 0 ? void 0 : flowdata[copyR]) === null || _c === void 0 ? void 0 : _c[copyC];
1457
+ if (!_.isNil((_d = cell === null || cell === void 0 ? void 0 : cell.mc) === null || _d === void 0 ? void 0 : _d.rs)) {
1458
+ HasMC = true;
1459
+ }
1460
+ }
1461
+ }
1462
+ ctx.luckysheet_selection_range.push({
1463
+ row: range.row,
1464
+ column: range.column
1465
+ });
1466
+ copyRange.push({
1467
+ row: range.row,
1468
+ column: range.column
1469
+ });
1470
+ }
1471
+ ctx.luckysheet_copy_save = {
1472
+ dataSheetId: ctx.currentSheetId,
1473
+ copyRange: copyRange,
1474
+ RowlChange: RowlChange,
1475
+ HasMC: HasMC
1476
+ };
1477
+ var cpdata = rangeValueToHtml(ctx, ctx.currentSheetId, ctx.luckysheet_select_save);
1478
+ if (cpdata) {
1479
+ ctx.iscopyself = true;
1480
+ clipboard.writeHtml(cpdata);
1481
+ }
1482
+ }
1483
+ export function deleteSelectedCellText(ctx) {
1484
+ var allowEdit = isAllowEdit(ctx);
1485
+ if (allowEdit === false) {
1486
+ return "allowEdit";
1487
+ }
1488
+ var selection = ctx.luckysheet_select_save;
1489
+ if (selection && !_.isEmpty(selection)) {
1490
+ var d = getFlowdata(ctx);
1491
+ if (!d) return "dataNullError";
1492
+ var has_PartMC = false;
1493
+ for (var s = 0; s < selection.length; s += 1) {
1494
+ var r1 = selection[s].row[0];
1495
+ var r2 = selection[s].row[1];
1496
+ var c1 = selection[s].column[0];
1497
+ var c2 = selection[s].column[1];
1498
+ if (hasPartMC(ctx, ctx.config, r1, r2, c1, c2)) {
1499
+ has_PartMC = true;
1500
+ break;
1501
+ }
1502
+ }
1503
+ if (has_PartMC) {
1504
+ return "partMC";
1505
+ }
1506
+ var hyperlinkMap = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].hyperlink;
1507
+ for (var s = 0; s < selection.length; s += 1) {
1508
+ var r1 = selection[s].row[0];
1509
+ var r2 = selection[s].row[1];
1510
+ var c1 = selection[s].column[0];
1511
+ var c2 = selection[s].column[1];
1512
+ for (var r = r1; r <= r2; r += 1) {
1513
+ for (var c = c1; c <= c2; c += 1) {
1514
+ if (_.isPlainObject(d[r][c])) {
1515
+ var cell = d[r][c];
1516
+ delete cell.m;
1517
+ delete cell.v;
1518
+ if (cell.f != null) {
1519
+ delete cell.f;
1520
+ delFunctionGroup(ctx, r, c, ctx.currentSheetId);
1521
+ delete cell.spl;
1522
+ }
1523
+ if (cell.ct != null && cell.ct.t === "inlineStr") {
1524
+ delete cell.ct;
1525
+ }
1526
+ } else {
1527
+ d[r][c] = null;
1528
+ }
1529
+ if (hyperlinkMap && hyperlinkMap["".concat(r, "_").concat(c)]) {
1530
+ delete hyperlinkMap["".concat(r, "_").concat(c)];
1531
+ }
1532
+ }
1533
+ }
1534
+ }
1535
+ }
1536
+ return "success";
1537
+ }
1538
+ export function selectIsOverlap(ctx, range) {
1539
+ return false;
1540
+ }
1541
+ export function selectAll(ctx) {
1542
+ var flowdata = getFlowdata(ctx);
1543
+ if (!flowdata) return;
1544
+ ctx.luckysheet_select_status = false;
1545
+ ctx.luckysheet_select_save = [{
1546
+ row: [0, flowdata.length - 1],
1547
+ column: [0, flowdata[0].length - 1],
1548
+ row_focus: 0,
1549
+ column_focus: 0,
1550
+ row_select: true,
1551
+ column_select: true
1552
+ }];
1553
+ normalizeSelection(ctx, ctx.luckysheet_select_save);
1554
+ }
1555
+ export function fixRowStyleOverflowInFreeze(ctx, r1, r2, freeze) {
1556
+ var _a;
1557
+ if (!freeze) return {};
1558
+ var ret = {};
1559
+ var scrollTop = ctx.scrollTop;
1560
+ var freezenhorizontaldata = (_a = freeze.horizontal) === null || _a === void 0 ? void 0 : _a.freezenhorizontaldata;
1561
+ var rangeshow = true;
1562
+ if (freezenhorizontaldata != null) {
1563
+ var freezenTop = freezenhorizontaldata[0];
1564
+ var freezen_rowindex = freezenhorizontaldata[1];
1565
+ var offTop = scrollTop - freezenhorizontaldata[2];
1566
+ var row = ctx.visibledatarow[r2];
1567
+ var row_pre = r1 - 1 === -1 ? 0 : ctx.visibledatarow[r1 - 1];
1568
+ var top_move = row_pre;
1569
+ var height_move = row - row_pre - 1;
1570
+ if (r1 >= freezen_rowindex) {
1571
+ if (top_move + height_move < freezenTop + offTop) {
1572
+ rangeshow = false;
1573
+ } else if (top_move < freezenTop + offTop) {
1574
+ ret.top = freezenTop + offTop;
1575
+ ret.height = height_move - (freezenTop + offTop - top_move);
1576
+ } else {}
1577
+ } else if (r2 >= freezen_rowindex) {
1578
+ if (top_move + height_move < freezenTop + offTop) {
1579
+ ret.top = top_move + offTop;
1580
+ ret.height = freezenTop - top_move;
1581
+ } else {
1582
+ ret.top = top_move + offTop;
1583
+ ret.height = height_move - offTop;
1584
+ }
1585
+ } else {
1586
+ ret.top = top_move + offTop;
1587
+ }
1588
+ }
1589
+ if (!rangeshow) {
1590
+ ret.display = "none";
1591
+ }
1592
+ return ret;
1593
+ }
1594
+ export function fixColumnStyleOverflowInFreeze(ctx, c1, c2, freeze) {
1595
+ var _a;
1596
+ if (!freeze) return {};
1597
+ var ret = {};
1598
+ var scrollLeft = ctx.scrollLeft;
1599
+ var freezenverticaldata = (_a = freeze.vertical) === null || _a === void 0 ? void 0 : _a.freezenverticaldata;
1600
+ var rangeshow = true;
1601
+ if (freezenverticaldata != null) {
1602
+ var freezenLeft = freezenverticaldata[0];
1603
+ var freezen_colindex = freezenverticaldata[1];
1604
+ var offLeft = scrollLeft - freezenverticaldata[2];
1605
+ var col = ctx.visibledatacolumn[c2];
1606
+ var col_pre = c1 - 1 === -1 ? 0 : ctx.visibledatacolumn[c1 - 1];
1607
+ var left_move = col_pre;
1608
+ var width_move = col - col_pre - 1;
1609
+ if (c1 >= freezen_colindex) {
1610
+ if (left_move + width_move < freezenLeft + offLeft) {
1611
+ rangeshow = false;
1612
+ } else if (left_move < freezenLeft + offLeft) {
1613
+ ret.left = freezenLeft + offLeft;
1614
+ ret.width = width_move - (freezenLeft + offLeft - left_move);
1615
+ } else {}
1616
+ } else if (c2 >= freezen_colindex) {
1617
+ if (left_move + width_move < freezenLeft + offLeft) {
1618
+ ret.left = left_move + offLeft;
1619
+ ret.width = freezenLeft - left_move;
1620
+ } else {
1621
+ ret.left = left_move + offLeft;
1622
+ ret.width = width_move - offLeft;
1623
+ }
1624
+ } else {
1625
+ ret.left = left_move + offLeft;
1626
+ }
1627
+ }
1628
+ if (!rangeshow) {
1629
+ ret.display = "none";
1630
+ }
1631
+ return ret;
1632
+ }
1633
+ export function calcSelectionInfo(ctx, lang) {
1634
+ var _a, _b, _c;
1635
+ var selection = ctx.luckysheet_select_save;
1636
+ var numberC = 0;
1637
+ var count = 0;
1638
+ var sum = 0;
1639
+ var max = -Infinity;
1640
+ var min = Infinity;
1641
+ for (var s = 0; s < selection.length; s += 1) {
1642
+ var data = getDataBySelectionNoCopy(ctx, selection[s]);
1643
+ for (var r = 0; r < data.length; r += 1) {
1644
+ for (var c = 0; c < data[0].length; c += 1) {
1645
+ if (r >= data.length || c >= data[0].length) break;
1646
+ var ct = (_b = (_a = data[r][c]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.t;
1647
+ var value = (_c = data[r][c]) === null || _c === void 0 ? void 0 : _c.m;
1648
+ if (ct === "n" || ct === "g" && parseFloat(value).toString() !== "NaN") {
1649
+ var valueNumber = parseFloat(value);
1650
+ count += 1;
1651
+ sum += valueNumber;
1652
+ max = Math.max(valueNumber, max);
1653
+ min = Math.min(valueNumber, min);
1654
+ numberC += 1;
1655
+ } else if (value != null) {
1656
+ count += 1;
1657
+ }
1658
+ }
1659
+ }
1660
+ }
1661
+ var formatString = lang && !["zh", "zh_tw"].includes(lang) ? "0.00" : "w0.00";
1662
+ var average = SSF.format(formatString, sum / numberC);
1663
+ sum = SSF.format(formatString, sum);
1664
+ max = SSF.format(formatString, max);
1665
+ min = SSF.format(formatString, min);
1666
+ return {
1667
+ numberC: numberC,
1668
+ count: count,
1669
+ sum: sum,
1670
+ max: max,
1671
+ min: min,
1672
+ average: average
1673
+ };
1674
+ }