@univerjs/sheets-ui 0.1.0-alpha.1 → 0.1.0-alpha.2

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 (351) hide show
  1. package/LICENSE.txt +178 -0
  2. package/lib/cjs/index.js +17 -21729
  3. package/lib/es/index.js +15314 -0
  4. package/lib/index.css +1 -587
  5. package/lib/types/basics/const/default-univer-sheet-config.d.ts +15 -1
  6. package/lib/types/basics/const/index.d.ts +15 -1
  7. package/lib/types/basics/const/plugin-name.d.ts +15 -1
  8. package/lib/types/basics/editor/get-editor-object.d.ts +15 -1
  9. package/lib/types/basics/index.d.ts +15 -1
  10. package/lib/types/basics/interfaces/cell.d.ts +15 -1
  11. package/lib/types/basics/interfaces/component-config/i-sheet-ui-plugin-config.d.ts +16 -2
  12. package/lib/types/basics/interfaces/component-config/index.d.ts +15 -1
  13. package/lib/types/basics/interfaces/component-config/sheet-container-config.d.ts +15 -1
  14. package/lib/types/basics/interfaces/component-config/toolbar-config.d.ts +15 -1
  15. package/lib/types/basics/interfaces/index.d.ts +15 -1
  16. package/lib/types/commands/commands/__tests__/add-worksheet-merge.command.spec.d.ts +16 -0
  17. package/lib/types/commands/commands/__tests__/auto-fill.controller.spec.d.ts +15 -1
  18. package/lib/types/commands/commands/__tests__/create-selection-command-test-bed.d.ts +15 -1
  19. package/lib/types/commands/commands/__tests__/set-format-painter.command.spec.d.ts +16 -0
  20. package/lib/types/commands/commands/__tests__/set-frozen.command.spec.d.ts +15 -1
  21. package/lib/types/commands/commands/__tests__/set-selections.command.spec.d.ts +15 -1
  22. package/lib/types/commands/commands/add-worksheet-merge.command.d.ts +27 -0
  23. package/lib/types/commands/commands/auto-fill.command.d.ts +15 -1
  24. package/lib/types/commands/commands/clipboard.command.d.ts +15 -1
  25. package/lib/types/commands/commands/inline-format.command.d.ts +15 -1
  26. package/lib/types/commands/commands/refill.command.d.ts +15 -1
  27. package/lib/types/commands/commands/rename.command.d.ts +15 -1
  28. package/lib/types/commands/commands/set-format-painter.command.d.ts +23 -5
  29. package/lib/types/commands/commands/set-frozen.command.d.ts +15 -1
  30. package/lib/types/commands/commands/set-scroll.command.d.ts +15 -1
  31. package/lib/types/commands/commands/set-selection-frozen.command.d.ts +15 -1
  32. package/lib/types/commands/commands/set-selection.command.d.ts +15 -1
  33. package/lib/types/commands/commands/set-zoom-ratio.command.d.ts +15 -1
  34. package/lib/types/commands/commands/unhide.command.d.ts +15 -1
  35. package/lib/types/commands/operations/activate-cell-edit.operation.d.ts +15 -1
  36. package/lib/types/commands/operations/cell-edit.operation.d.ts +15 -1
  37. package/lib/types/commands/operations/scroll.operation.d.ts +15 -1
  38. package/lib/types/commands/operations/set-editor-resize.operation.d.ts +15 -1
  39. package/lib/types/commands/operations/set-format-painter.operation.d.ts +15 -1
  40. package/lib/types/commands/operations/set-zoom-ratio.operation.d.ts +15 -1
  41. package/lib/types/common/keys.d.ts +15 -1
  42. package/lib/types/common/utils.d.ts +25 -0
  43. package/lib/types/components/border-panel/BorderPanel.d.ts +15 -1
  44. package/lib/types/components/border-panel/border-line/BorderLine.d.ts +15 -1
  45. package/lib/types/components/border-panel/border-line/icons/BorderDashDot.d.ts +15 -1
  46. package/lib/types/components/border-panel/border-line/icons/BorderDashDotDot.d.ts +15 -1
  47. package/lib/types/components/border-panel/border-line/icons/BorderDashed.d.ts +15 -1
  48. package/lib/types/components/border-panel/border-line/icons/BorderDotted.d.ts +15 -1
  49. package/lib/types/components/border-panel/border-line/icons/BorderHair.d.ts +15 -1
  50. package/lib/types/components/border-panel/border-line/icons/BorderMedium.d.ts +15 -1
  51. package/lib/types/components/border-panel/border-line/icons/BorderMediumDashDot.d.ts +15 -1
  52. package/lib/types/components/border-panel/border-line/icons/BorderMediumDashDotDot.d.ts +15 -1
  53. package/lib/types/components/border-panel/border-line/icons/BorderMediumDashed.d.ts +15 -1
  54. package/lib/types/components/border-panel/border-line/icons/BorderThick.d.ts +15 -1
  55. package/lib/types/components/border-panel/border-line/icons/BorderThin.d.ts +15 -1
  56. package/lib/types/components/border-panel/interface.d.ts +15 -1
  57. package/lib/types/components/color-picker/index.d.ts +15 -1
  58. package/lib/types/components/color-picker/interface.d.ts +15 -1
  59. package/lib/types/components/const.d.ts +15 -1
  60. package/lib/types/components/font-family/FontFamily.d.ts +15 -1
  61. package/lib/types/components/font-family/FontFamilyItem.d.ts +15 -1
  62. package/lib/types/components/font-family/index.d.ts +15 -1
  63. package/lib/types/components/font-family/interface.d.ts +15 -1
  64. package/lib/types/components/font-size/FontSize.d.ts +15 -1
  65. package/lib/types/components/font-size/index.d.ts +15 -1
  66. package/lib/types/components/font-size/interface.d.ts +15 -1
  67. package/lib/types/components/menu-item-input/MenuItemInput.d.ts +15 -1
  68. package/lib/types/components/menu-item-input/index.d.ts +15 -1
  69. package/lib/types/components/menu-item-input/interface.d.ts +15 -1
  70. package/lib/types/components/range-selector/RangeSelector.d.ts +15 -1
  71. package/lib/types/controllers/active-worksheet/active-worksheet.controller.d.ts +33 -0
  72. package/lib/types/controllers/auto-fill.controller.d.ts +15 -1
  73. package/lib/types/controllers/auto-height.controller.d.ts +15 -1
  74. package/lib/types/controllers/clipboard/clipboard.controller.d.ts +15 -1
  75. package/lib/types/controllers/clipboard/utils.d.ts +15 -1
  76. package/lib/types/controllers/contextmenu/contextmenu.controller.d.ts +15 -1
  77. package/lib/types/controllers/editor/editing.controller.d.ts +20 -8
  78. package/lib/types/controllers/editor/end-edit.controller.d.ts +18 -4
  79. package/lib/types/controllers/editor/formula-editor.controller.d.ts +16 -1
  80. package/lib/types/controllers/editor/initialize-editor.controller.d.ts +15 -1
  81. package/lib/types/controllers/editor/start-edit.controller.d.ts +16 -1
  82. package/lib/types/controllers/editor-bridge.controller.d.ts +19 -3
  83. package/lib/types/controllers/format-painter/format-painter.controller.d.ts +18 -3
  84. package/lib/types/controllers/freeze.controller.d.ts +15 -1
  85. package/lib/types/controllers/header-menu.controller.d.ts +15 -1
  86. package/lib/types/controllers/header-move.controller.d.ts +15 -1
  87. package/lib/types/controllers/header-resize.controller.d.ts +15 -1
  88. package/lib/types/controllers/header-unhide.controller.d.ts +15 -1
  89. package/lib/types/controllers/menu/__tests__/create-menu-test-bed.d.ts +15 -1
  90. package/lib/types/controllers/menu/__tests__/menu.spec.d.ts +15 -1
  91. package/lib/types/controllers/menu/__tests__/row-col.menu.spec.d.ts +15 -1
  92. package/lib/types/controllers/menu/border.menu.d.ts +15 -1
  93. package/lib/types/controllers/menu/clear.menu.d.ts +15 -1
  94. package/lib/types/controllers/menu/delete.menu.d.ts +15 -1
  95. package/lib/types/controllers/menu/insert.menu.d.ts +15 -1
  96. package/lib/types/controllers/menu/menu.d.ts +16 -1
  97. package/lib/types/controllers/menu/merge.menu.d.ts +15 -1
  98. package/lib/types/controllers/menu/sheet.menu.d.ts +15 -1
  99. package/lib/types/controllers/move-range.controller.d.ts +15 -1
  100. package/lib/types/controllers/navigation/navigation.controller.d.ts +15 -1
  101. package/lib/types/controllers/scroll.controller.d.ts +15 -1
  102. package/lib/types/controllers/selection.controller.d.ts +16 -1
  103. package/lib/types/controllers/sheet-render.controller.d.ts +15 -1
  104. package/lib/types/controllers/sheet-ui.controller.d.ts +20 -1
  105. package/lib/types/controllers/shortcuts/editor.shortcut.d.ts +15 -1
  106. package/lib/types/controllers/shortcuts/operation.shortcut.d.ts +15 -1
  107. package/lib/types/controllers/shortcuts/selection.shortcut.d.ts +15 -1
  108. package/lib/types/controllers/shortcuts/style.shortcut.d.ts +15 -1
  109. package/lib/types/controllers/shortcuts/utils.d.ts +15 -1
  110. package/lib/types/controllers/shortcuts/value.shortcut.d.ts +15 -1
  111. package/lib/types/controllers/shortcuts/view.shortcut.d.ts +15 -1
  112. package/lib/types/controllers/status-bar.controller.d.ts +18 -4
  113. package/lib/types/controllers/utils/component-tools.d.ts +15 -1
  114. package/lib/types/controllers/zoom.controller.d.ts +15 -1
  115. package/lib/types/index.d.ts +29 -3
  116. package/lib/types/locale/en-US.d.ts +20 -1
  117. package/lib/types/locale/index.d.ts +15 -1
  118. package/lib/types/locale/zh-CN.d.ts +20 -1
  119. package/lib/types/services/auto-fill/auto-fill.service.d.ts +15 -1
  120. package/lib/types/services/auto-fill/rules.d.ts +15 -1
  121. package/lib/types/services/auto-fill/tools.d.ts +16 -2
  122. package/lib/types/services/auto-fill/type.d.ts +15 -1
  123. package/lib/types/services/clipboard/__tests__/clipboard-service.spec.d.ts +15 -1
  124. package/lib/types/services/clipboard/__tests__/clipboard-test-bed.d.ts +15 -1
  125. package/lib/types/services/clipboard/__tests__/mock-clipboard.d.ts +15 -1
  126. package/lib/types/services/clipboard/__tests__/utils.spec.d.ts +16 -0
  127. package/lib/types/services/clipboard/clipboard.service.d.ts +18 -2
  128. package/lib/types/services/clipboard/copy-content-cache.d.ts +15 -1
  129. package/lib/types/services/clipboard/html-to-usm/converter.d.ts +24 -2
  130. package/lib/types/services/clipboard/html-to-usm/parse-node-style.d.ts +15 -1
  131. package/lib/types/services/clipboard/html-to-usm/paste-plugins/plugin-lark.d.ts +15 -1
  132. package/lib/types/services/clipboard/html-to-usm/paste-plugins/plugin-word.d.ts +15 -1
  133. package/lib/types/services/clipboard/html-to-usm/paste-plugins/type.d.ts +15 -1
  134. package/lib/types/services/clipboard/html-to-usm/utils.d.ts +15 -1
  135. package/lib/types/services/clipboard/type.d.ts +17 -1
  136. package/lib/types/services/clipboard/usm-to-html/convertor.d.ts +15 -1
  137. package/lib/types/services/clipboard/utils.d.ts +28 -0
  138. package/lib/types/services/editor/cell-editor-manager.service.d.ts +15 -1
  139. package/lib/types/services/editor/formula-editor-manager.service.d.ts +15 -1
  140. package/lib/types/services/editor-bridge.service.d.ts +21 -6
  141. package/lib/types/services/format-painter/format-painter.service.d.ts +30 -8
  142. package/lib/types/services/mark-selection/mark-selection.service.d.ts +18 -2
  143. package/lib/types/services/scroll-manager.service.d.ts +15 -1
  144. package/lib/types/services/selection/selection-render-model.d.ts +15 -1
  145. package/lib/types/services/selection/selection-render.service.d.ts +28 -12
  146. package/lib/types/services/selection/selection-shape-extension.d.ts +15 -1
  147. package/lib/types/services/selection/selection-shape.d.ts +15 -1
  148. package/lib/types/services/sheet-bar/sheet-bar.service.d.ts +15 -1
  149. package/lib/types/services/sheet-skeleton-manager.service.d.ts +15 -1
  150. package/lib/types/services/status-bar.service.d.ts +19 -5
  151. package/lib/types/sheets-ui-plugin.d.ts +16 -2
  152. package/lib/types/views/count-bar/CountBar.d.ts +15 -1
  153. package/lib/types/views/count-bar/index.d.ts +15 -1
  154. package/lib/types/views/count-bar/zoom-slider.d.ts +15 -1
  155. package/lib/types/views/editor-container/EditorContainer.d.ts +15 -1
  156. package/lib/types/views/editor-container/index.d.ts +15 -1
  157. package/lib/types/views/formula-bar/FormulaBar.d.ts +15 -1
  158. package/lib/types/views/formula-bar/index.d.ts +15 -1
  159. package/lib/types/views/header-menu-shape.d.ts +15 -1
  160. package/lib/types/views/header-resize-shape.d.ts +15 -1
  161. package/lib/types/views/header-unhide-shape.d.ts +15 -1
  162. package/lib/types/views/operate-container/AutoFillPopupMenu.d.ts +15 -1
  163. package/lib/types/views/operate-container/OperateContainer.d.ts +15 -1
  164. package/lib/types/views/operate-container/index.d.ts +15 -1
  165. package/lib/types/views/sheet-bar/SheetBar.d.ts +15 -1
  166. package/lib/types/views/sheet-bar/sheet-bar-button/SheetBarButton.d.ts +15 -1
  167. package/lib/types/views/sheet-bar/sheet-bar-menu/SheetBarMenu.d.ts +15 -1
  168. package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarItem.d.ts +15 -1
  169. package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.d.ts +15 -1
  170. package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/animate.d.ts +17 -2
  171. package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.d.ts +17 -2
  172. package/lib/types/views/sheet-canvas-view.d.ts +15 -1
  173. package/lib/types/views/sheet-container/SheetContainer.d.ts +17 -3
  174. package/lib/types/views/status-bar/CopyableStatisticItem.d.ts +17 -3
  175. package/lib/types/views/status-bar/StatusBar.d.ts +15 -1
  176. package/lib/umd/index.js +17 -0
  177. package/package.json +41 -30
  178. package/LICENSE +0 -21
  179. package/lib/cjs/locale/en-US.js +0 -605
  180. package/lib/cjs/locale/zh-CN.js +0 -442
  181. package/lib/esm/index.js +0 -21640
  182. package/lib/esm/locale/en-US.js +0 -584
  183. package/lib/esm/locale/zh-CN.js +0 -421
  184. package/lib/types/basics/const/default-univer-sheet-config.d.ts.map +0 -1
  185. package/lib/types/basics/const/index.d.ts.map +0 -1
  186. package/lib/types/basics/const/plugin-name.d.ts.map +0 -1
  187. package/lib/types/basics/editor/get-editor-object.d.ts.map +0 -1
  188. package/lib/types/basics/index.d.ts.map +0 -1
  189. package/lib/types/basics/interfaces/cell.d.ts.map +0 -1
  190. package/lib/types/basics/interfaces/component-config/i-sheet-ui-plugin-config.d.ts.map +0 -1
  191. package/lib/types/basics/interfaces/component-config/index.d.ts.map +0 -1
  192. package/lib/types/basics/interfaces/component-config/sheet-container-config.d.ts.map +0 -1
  193. package/lib/types/basics/interfaces/component-config/toolbar-config.d.ts.map +0 -1
  194. package/lib/types/basics/interfaces/index.d.ts.map +0 -1
  195. package/lib/types/commands/commands/__tests__/auto-fill.controller.spec.d.ts.map +0 -1
  196. package/lib/types/commands/commands/__tests__/create-selection-command-test-bed.d.ts.map +0 -1
  197. package/lib/types/commands/commands/__tests__/set-frozen.command.spec.d.ts.map +0 -1
  198. package/lib/types/commands/commands/__tests__/set-selections.command.spec.d.ts.map +0 -1
  199. package/lib/types/commands/commands/auto-fill.command.d.ts.map +0 -1
  200. package/lib/types/commands/commands/clipboard.command.d.ts.map +0 -1
  201. package/lib/types/commands/commands/inline-format.command.d.ts.map +0 -1
  202. package/lib/types/commands/commands/refill.command.d.ts.map +0 -1
  203. package/lib/types/commands/commands/rename.command.d.ts.map +0 -1
  204. package/lib/types/commands/commands/set-format-painter.command.d.ts.map +0 -1
  205. package/lib/types/commands/commands/set-frozen.command.d.ts.map +0 -1
  206. package/lib/types/commands/commands/set-scroll.command.d.ts.map +0 -1
  207. package/lib/types/commands/commands/set-selection-frozen.command.d.ts.map +0 -1
  208. package/lib/types/commands/commands/set-selection.command.d.ts.map +0 -1
  209. package/lib/types/commands/commands/set-zoom-ratio.command.d.ts.map +0 -1
  210. package/lib/types/commands/commands/unhide.command.d.ts.map +0 -1
  211. package/lib/types/commands/operations/activate-cell-edit.operation.d.ts.map +0 -1
  212. package/lib/types/commands/operations/cell-edit.operation.d.ts.map +0 -1
  213. package/lib/types/commands/operations/scroll.operation.d.ts.map +0 -1
  214. package/lib/types/commands/operations/selection.operation.d.ts +0 -12
  215. package/lib/types/commands/operations/selection.operation.d.ts.map +0 -1
  216. package/lib/types/commands/operations/set-editor-resize.operation.d.ts.map +0 -1
  217. package/lib/types/commands/operations/set-format-painter.operation.d.ts.map +0 -1
  218. package/lib/types/commands/operations/set-zoom-ratio.operation.d.ts.map +0 -1
  219. package/lib/types/common/keys.d.ts.map +0 -1
  220. package/lib/types/components/border-panel/BorderPanel.d.ts.map +0 -1
  221. package/lib/types/components/border-panel/border-line/BorderLine.d.ts.map +0 -1
  222. package/lib/types/components/border-panel/border-line/icons/BorderDashDot.d.ts.map +0 -1
  223. package/lib/types/components/border-panel/border-line/icons/BorderDashDotDot.d.ts.map +0 -1
  224. package/lib/types/components/border-panel/border-line/icons/BorderDashed.d.ts.map +0 -1
  225. package/lib/types/components/border-panel/border-line/icons/BorderDotted.d.ts.map +0 -1
  226. package/lib/types/components/border-panel/border-line/icons/BorderHair.d.ts.map +0 -1
  227. package/lib/types/components/border-panel/border-line/icons/BorderMedium.d.ts.map +0 -1
  228. package/lib/types/components/border-panel/border-line/icons/BorderMediumDashDot.d.ts.map +0 -1
  229. package/lib/types/components/border-panel/border-line/icons/BorderMediumDashDotDot.d.ts.map +0 -1
  230. package/lib/types/components/border-panel/border-line/icons/BorderMediumDashed.d.ts.map +0 -1
  231. package/lib/types/components/border-panel/border-line/icons/BorderThick.d.ts.map +0 -1
  232. package/lib/types/components/border-panel/border-line/icons/BorderThin.d.ts.map +0 -1
  233. package/lib/types/components/border-panel/index.d.ts +0 -1
  234. package/lib/types/components/border-panel/index.d.ts.map +0 -1
  235. package/lib/types/components/border-panel/interface.d.ts.map +0 -1
  236. package/lib/types/components/color-picker/index.d.ts.map +0 -1
  237. package/lib/types/components/color-picker/interface.d.ts.map +0 -1
  238. package/lib/types/components/const.d.ts.map +0 -1
  239. package/lib/types/components/font-family/FontFamily.d.ts.map +0 -1
  240. package/lib/types/components/font-family/FontFamilyItem.d.ts.map +0 -1
  241. package/lib/types/components/font-family/index.d.ts.map +0 -1
  242. package/lib/types/components/font-family/interface.d.ts.map +0 -1
  243. package/lib/types/components/font-size/FontSize.d.ts.map +0 -1
  244. package/lib/types/components/font-size/index.d.ts.map +0 -1
  245. package/lib/types/components/font-size/interface.d.ts.map +0 -1
  246. package/lib/types/components/menu-item-input/MenuItemInput.d.ts.map +0 -1
  247. package/lib/types/components/menu-item-input/index.d.ts.map +0 -1
  248. package/lib/types/components/menu-item-input/interface.d.ts.map +0 -1
  249. package/lib/types/components/range-selector/RangeSelector.d.ts.map +0 -1
  250. package/lib/types/controllers/auto-fill.controller.d.ts.map +0 -1
  251. package/lib/types/controllers/auto-height.controller.d.ts.map +0 -1
  252. package/lib/types/controllers/clipboard/clipboard.controller.d.ts.map +0 -1
  253. package/lib/types/controllers/clipboard/utils.d.ts.map +0 -1
  254. package/lib/types/controllers/contextmenu/contextmenu.controller.d.ts.map +0 -1
  255. package/lib/types/controllers/editor/editing.controller.d.ts.map +0 -1
  256. package/lib/types/controllers/editor/end-edit.controller.d.ts.map +0 -1
  257. package/lib/types/controllers/editor/formula-editor.controller.d.ts.map +0 -1
  258. package/lib/types/controllers/editor/initialize-editor.controller.d.ts.map +0 -1
  259. package/lib/types/controllers/editor/start-edit.controller.d.ts.map +0 -1
  260. package/lib/types/controllers/editor-bridge.controller.d.ts.map +0 -1
  261. package/lib/types/controllers/format-painter/format-painter.controller.d.ts.map +0 -1
  262. package/lib/types/controllers/freeze.controller.d.ts.map +0 -1
  263. package/lib/types/controllers/header-menu.controller.d.ts.map +0 -1
  264. package/lib/types/controllers/header-move.controller.d.ts.map +0 -1
  265. package/lib/types/controllers/header-resize.controller.d.ts.map +0 -1
  266. package/lib/types/controllers/header-unhide.controller.d.ts.map +0 -1
  267. package/lib/types/controllers/menu/__tests__/create-menu-test-bed.d.ts.map +0 -1
  268. package/lib/types/controllers/menu/__tests__/menu.spec.d.ts.map +0 -1
  269. package/lib/types/controllers/menu/__tests__/row-col.menu.spec.d.ts.map +0 -1
  270. package/lib/types/controllers/menu/border.menu.d.ts.map +0 -1
  271. package/lib/types/controllers/menu/clear.menu.d.ts.map +0 -1
  272. package/lib/types/controllers/menu/delete.menu.d.ts.map +0 -1
  273. package/lib/types/controllers/menu/insert.menu.d.ts.map +0 -1
  274. package/lib/types/controllers/menu/menu.d.ts.map +0 -1
  275. package/lib/types/controllers/menu/merge.menu.d.ts.map +0 -1
  276. package/lib/types/controllers/menu/sheet.menu.d.ts.map +0 -1
  277. package/lib/types/controllers/move-range.controller.d.ts.map +0 -1
  278. package/lib/types/controllers/navigation/navigation.controller.d.ts.map +0 -1
  279. package/lib/types/controllers/scroll.controller.d.ts.map +0 -1
  280. package/lib/types/controllers/selection.controller.d.ts.map +0 -1
  281. package/lib/types/controllers/sheet-render.controller.d.ts.map +0 -1
  282. package/lib/types/controllers/sheet-ui.controller.d.ts.map +0 -1
  283. package/lib/types/controllers/shortcuts/editor.shortcut.d.ts.map +0 -1
  284. package/lib/types/controllers/shortcuts/operation.shortcut.d.ts.map +0 -1
  285. package/lib/types/controllers/shortcuts/selection.shortcut.d.ts.map +0 -1
  286. package/lib/types/controllers/shortcuts/style.shortcut.d.ts.map +0 -1
  287. package/lib/types/controllers/shortcuts/utils.d.ts.map +0 -1
  288. package/lib/types/controllers/shortcuts/value.shortcut.d.ts.map +0 -1
  289. package/lib/types/controllers/shortcuts/view.shortcut.d.ts.map +0 -1
  290. package/lib/types/controllers/status-bar.controller.d.ts.map +0 -1
  291. package/lib/types/controllers/utils/component-tools.d.ts.map +0 -1
  292. package/lib/types/controllers/zoom.controller.d.ts.map +0 -1
  293. package/lib/types/index.d.ts.map +0 -1
  294. package/lib/types/locale/en-US.d.ts.map +0 -1
  295. package/lib/types/locale/index.d.ts.map +0 -1
  296. package/lib/types/locale/zh-CN.d.ts.map +0 -1
  297. package/lib/types/services/auto-fill/auto-fill.service.d.ts.map +0 -1
  298. package/lib/types/services/auto-fill/rules.d.ts.map +0 -1
  299. package/lib/types/services/auto-fill/tools.d.ts.map +0 -1
  300. package/lib/types/services/auto-fill/type.d.ts.map +0 -1
  301. package/lib/types/services/clipboard/__tests__/clipboard-service.spec.d.ts.map +0 -1
  302. package/lib/types/services/clipboard/__tests__/clipboard-test-bed.d.ts.map +0 -1
  303. package/lib/types/services/clipboard/__tests__/mock-clipboard.d.ts.map +0 -1
  304. package/lib/types/services/clipboard/clipboard.service.d.ts.map +0 -1
  305. package/lib/types/services/clipboard/copy-content-cache.d.ts.map +0 -1
  306. package/lib/types/services/clipboard/html-to-usm/converter.d.ts.map +0 -1
  307. package/lib/types/services/clipboard/html-to-usm/parse-node-style.d.ts.map +0 -1
  308. package/lib/types/services/clipboard/html-to-usm/paste-plugins/plugin-lark.d.ts.map +0 -1
  309. package/lib/types/services/clipboard/html-to-usm/paste-plugins/plugin-word.d.ts.map +0 -1
  310. package/lib/types/services/clipboard/html-to-usm/paste-plugins/type.d.ts.map +0 -1
  311. package/lib/types/services/clipboard/html-to-usm/utils.d.ts.map +0 -1
  312. package/lib/types/services/clipboard/type.d.ts.map +0 -1
  313. package/lib/types/services/clipboard/usm-to-html/convertor.d.ts.map +0 -1
  314. package/lib/types/services/editor/cell-editor-manager.service.d.ts.map +0 -1
  315. package/lib/types/services/editor/formula-editor-manager.service.d.ts.map +0 -1
  316. package/lib/types/services/editor-bridge.service.d.ts.map +0 -1
  317. package/lib/types/services/format-painter/format-painter.service.d.ts.map +0 -1
  318. package/lib/types/services/mark-selection/mark-selection.service.d.ts.map +0 -1
  319. package/lib/types/services/scroll-manager.service.d.ts.map +0 -1
  320. package/lib/types/services/selection/selection-render-model.d.ts.map +0 -1
  321. package/lib/types/services/selection/selection-render.service.d.ts.map +0 -1
  322. package/lib/types/services/selection/selection-shape-extension.d.ts.map +0 -1
  323. package/lib/types/services/selection/selection-shape.d.ts.map +0 -1
  324. package/lib/types/services/sheet-bar/sheet-bar.service.d.ts.map +0 -1
  325. package/lib/types/services/sheet-skeleton-manager.service.d.ts.map +0 -1
  326. package/lib/types/services/status-bar.service.d.ts.map +0 -1
  327. package/lib/types/sheets-ui-plugin.d.ts.map +0 -1
  328. package/lib/types/views/count-bar/CountBar.d.ts.map +0 -1
  329. package/lib/types/views/count-bar/index.d.ts.map +0 -1
  330. package/lib/types/views/count-bar/zoom-slider.d.ts.map +0 -1
  331. package/lib/types/views/editor-container/EditorContainer.d.ts.map +0 -1
  332. package/lib/types/views/editor-container/index.d.ts.map +0 -1
  333. package/lib/types/views/formula-bar/FormulaBar.d.ts.map +0 -1
  334. package/lib/types/views/formula-bar/index.d.ts.map +0 -1
  335. package/lib/types/views/header-menu-shape.d.ts.map +0 -1
  336. package/lib/types/views/header-resize-shape.d.ts.map +0 -1
  337. package/lib/types/views/header-unhide-shape.d.ts.map +0 -1
  338. package/lib/types/views/operate-container/AutoFillPopupMenu.d.ts.map +0 -1
  339. package/lib/types/views/operate-container/OperateContainer.d.ts.map +0 -1
  340. package/lib/types/views/operate-container/index.d.ts.map +0 -1
  341. package/lib/types/views/sheet-bar/SheetBar.d.ts.map +0 -1
  342. package/lib/types/views/sheet-bar/sheet-bar-button/SheetBarButton.d.ts.map +0 -1
  343. package/lib/types/views/sheet-bar/sheet-bar-menu/SheetBarMenu.d.ts.map +0 -1
  344. package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarItem.d.ts.map +0 -1
  345. package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.d.ts.map +0 -1
  346. package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/animate.d.ts.map +0 -1
  347. package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.d.ts.map +0 -1
  348. package/lib/types/views/sheet-canvas-view.d.ts.map +0 -1
  349. package/lib/types/views/sheet-container/SheetContainer.d.ts.map +0 -1
  350. package/lib/types/views/status-bar/CopyableStatisticItem.d.ts.map +0 -1
  351. package/lib/types/views/status-bar/StatusBar.d.ts.map +0 -1
@@ -0,0 +1,17 @@
1
+ (function(k,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@wendellhu/redi"),require("rxjs"),require("@univerjs/engine-render"),require("@ctrl/tinycolor"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings"),require("@univerjs/docs"),require("@univerjs/engine-formula"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/ui","@wendellhu/redi","rxjs","@univerjs/engine-render","@ctrl/tinycolor","react","@univerjs/design","@wendellhu/redi/react-bindings","@univerjs/docs","@univerjs/engine-formula","clsx"],l):(k=typeof globalThis<"u"?globalThis:k||self,l(k.UniverSheetsUi={},k.UniverCore,k.UniverSheets,k.UniverUi,k["@wendellhu/redi"],k.rxjs,k.UniverEngineRender,k.tinycolor,k.React,k.UniverDesign,k["@wendellhu/redi/react-bindings"],k.UniverDocs,k.UniverEngineFormula,k.clsx))})(this,function(k,l,p,b,L,V,w,De,U,te,F,Z,re,gt){"use strict";var lm=Object.defineProperty;var cm=(k,l,p)=>l in k?lm(k,l,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[l]=p;var v=(k,l,p)=>(cm(k,typeof l!="symbol"?l+"":l,p),p);var Do;const Lo={InsertRow:!0,InsertColumn:!0,AddRowTop:!1,AddRowBottom:!1,AddColumnLeft:!1,AddColumnRight:!1,DeleteRow:!0,DeleteColumn:!0,HideRow:!1,ShowRow:!1,RowHeight:!1,HideColumn:!1,ShowColumn:!1,ColumnWidth:!1,DeleteCell:!0,ClearContent:!0,Matrix:!1},No={undo:!0,redo:!0,paintFormat:!0,currencyFormat:!0,percentageFormat:!0,numberDecrease:!0,numberIncrease:!0,moreFormats:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,border:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0,mergeCell:!0},Uo={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0,formulaBar:!0,rightMenu:!0,countBar:!0,sheetBar:!0},Wr={layout:{sheetContainerConfig:Uo,rightMenuConfig:Lo,toolbarConfig:No}},Bo="SheetUI";function Bt(o,e){if(o==null)return;const t=e.getRenderById(o);if(t==null)return;const{mainComponent:n,scene:i,engine:r}=t;return{document:n,scene:i,engine:r}}const Vt={type:l.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(o,e)=>{const t=o.get(l.ICommandService),n=o.get(l.IUniverInstanceService),i=o.get(l.IUndoRedoService),{applyRange:r,selectionRange:s,applyDatas:a,workbookId:c=n.getCurrentUniverSheetInstance().getUnitId(),worksheetId:d=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),applyMergeRanges:u}=e||{};if(!r||!a||!s)return!1;const m=new l.ObjectMatrix,{startRow:h,startColumn:_,endRow:f,endColumn:S}=r;for(let A=0;A<=f-h;A++)for(let D=0;D<=S-_;D++)m.setValue(A+h,D+_,a[A][D]);const I={worksheetId:d,workbookId:c,cellValue:m.getMatrix()},C=p.SetRangeValuesUndoMutationFactory(o,I),M=t.syncExecuteCommand(p.SetRangeValuesMutation.id,I),R=t.syncExecuteCommand(p.SetSelectionsOperation.id,{selections:[{primary:{...s,endColumn:s.startColumn,endRow:s.startRow},range:{...s,rangeType:l.RANGE_TYPE.NORMAL}}],workbookId:c,worksheetId:d}),y=[{id:p.SetRangeValuesMutation.id,params:C}],T=[{id:p.SetRangeValuesMutation.id,params:I}];let E=!0,O=!0;if(u!=null&&u.length){const A=p.getAddMergeMutationRangeByType(u),D={workbookId:c,worksheetId:d,ranges:A},N=p.RemoveMergeUndoMutationFactory(o,D);E=t.syncExecuteCommand(p.RemoveWorksheetMergeMutation.id,D);const B={workbookId:c,worksheetId:d,ranges:A},$=p.AddMergeUndoMutationFactory(o,B);O=t.syncExecuteCommand(p.AddWorksheetMergeMutation.id,B),y.push({id:p.AddWorksheetMergeMutation.id,params:N}),y.push({id:p.RemoveWorksheetMergeMutation.id,params:$}),T.push({id:p.RemoveWorksheetMergeMutation.id,params:D}),T.push({id:p.AddWorksheetMergeMutation.id,params:B})}const{undo:x,redo:P}=e==null?void 0:e.extendMutations,H=P.every(A=>t.syncExecuteCommand(A.id,A.params));return x.forEach(A=>{y.push(A)}),P.forEach(A=>{T.push(A)}),M&&E&&O&&R&&H&&i.pushUndoRedo({unitID:c,undoMutations:y,redoMutations:T}),!0}},Ft={id:"sheet.command.auto-clear-content",type:l.CommandType.COMMAND,handler:async(o,e)=>{const t=o.get(l.IUniverInstanceService),n=o.get(l.ICommandService),i=o.get(l.IUndoRedoService),r=t.getCurrentUniverSheetInstance(),s=r.getUnitId(),c=r.getActiveSheet().getSheetId(),{clearRange:d,selectionRange:u}=e,m={worksheetId:c,workbookId:s,cellValue:zr([d])},h=p.SetRangeValuesUndoMutationFactory(o,m);return n.executeCommand(p.SetSelectionsOperation.id,{selections:[{primary:{...u},range:{...u}}],workbookId:s,worksheetId:c}),n.syncExecuteCommand(p.SetRangeValuesMutation.id,m)?(i.pushUndoRedo({unitID:s,undoMutations:[{id:p.SetRangeValuesMutation.id,params:h}],redoMutations:[{id:p.SetRangeValuesMutation.id,params:m}],undo(){return n.syncExecuteCommand(p.SetRangeValuesMutation.id,h)},redo(){return n.syncExecuteCommand(p.SetRangeValuesMutation.id,m)}}),!0):!1}};function zr(o){const e=new l.ObjectMatrix;return o.forEach(t=>{const{startRow:n,startColumn:i,endRow:r,endColumn:s}=t;for(let a=n;a<=r;a++)for(let c=i;c<=s;c++)e.setValue(a,c,{v:null,p:null,f:null,si:null})}),e.getData()}function X(o){return o.getContextValue(l.FOCUSING_SHEET)&&!o.getContextValue(l.FOCUSING_EDITOR)}function Xr(o){return o.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)&&!o.getContextValue(l.FOCUSING_EDITOR)}function Yr(o){return o.getContextValue(l.FOCUSING_EDITOR)&&o.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)}function Vo(o){return o.getContextValue(l.FOCUSING_FORMULA_EDITOR)}function $r(o){return o.getContextValue(l.FOCUSING_EDITOR)&&o.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)}function jt(o){return o.getContextValue(l.FOCUSING_EDITOR)&&!o.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)}const Zr=l.createInterceptorKey("BEFORE_CELL_EDIT"),Gr=l.createInterceptorKey("AFTER_CELL_EDIT");class Fo extends l.Disposable{constructor(){super();v(this,"_state",null);v(this,"_isForceKeepVisible",!1);v(this,"_editorIsDirty",!1);v(this,"_visible",{visible:!1,eventType:w.DeviceInputEventType.Dblclick});v(this,"_state$",new V.BehaviorSubject(null));v(this,"state$",this._state$.asObservable());v(this,"_visible$",new V.BehaviorSubject(this._visible));v(this,"visible$",this._visible$.asObservable());v(this,"_afterVisible$",new V.BehaviorSubject(this._visible));v(this,"afterVisible$",this._afterVisible$.asObservable());v(this,"interceptor",new l.InterceptorManager({BEFORE_CELL_EDIT:Zr,AFTER_CELL_EDIT:Gr}));this.disposeWithMe(l.toDisposable(()=>{this._state$.complete(),this._state=null})),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:t=>t}))),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:t=>t})))}setState(t){this._state=t,this._state$.next(t)}getState(){return this._state}getCurrentEditorId(){var t;return(t=this._state)==null?void 0:t.editorUnitId}changeVisible(t){this._visible=t,t.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(t){this._editorIsDirty=t}getEditorDirty(){return this._editorIsDirty}}const Te=L.createIdentifier("univer.sheet-editor-bridge.service"),Ie={id:"sheet.operation.set-cell-edit-visible",type:l.CommandType.OPERATION,handler:(o,e)=>{const t=o.get(Te);return e==null?!1:(t.changeVisible(e),!0)}},vt={id:"sheet.operation.set-cell-edit-visible-arrow",type:l.CommandType.OPERATION,handler:()=>!0};class Kr{constructor(){v(this,"_startColumn",-1);v(this,"_startRow",-1);v(this,"_endColumn",-1);v(this,"_endRow",-1);v(this,"_startX",0);v(this,"_startY",0);v(this,"_endX",0);v(this,"_endY",0);v(this,"_currentCell");v(this,"_rangeType",l.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._currentCell}get rangeType(){return this._rangeType}isEqual(e){const{startColumn:t,startRow:n,endColumn:i,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=e;return t===s&&n===a&&i===c&&r===d}isInclude(e){const{startColumn:t,startRow:n,endColumn:i,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=e;return!(c<t||s>i||a>r||d<n)}highlightToSelection(){return l.makeCellToSelection(this._currentCell)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this._rangeType},primaryWithCoord:this._currentCell}}setValue(e,t){const{startColumn:n,startRow:i,endColumn:r,endRow:s,startX:a,startY:c,endX:d,endY:u,rangeType:m}=e;this._startColumn=n,this._startRow=i,this._endColumn=r,this._endRow=s,this._startX=a,this._startY=c,this._endX=d,this._endY=u,m!=null&&(this._rangeType=m),this.setCurrentCell(t)}setCurrentCell(e){e&&(this._currentCell=e)}clearCurrentCell(){this._currentCell=null}}const jo=.3;class Wt{constructor(e,t,n=!0,i){v(this,"_leftControl");v(this,"_rightControl");v(this,"_topControl");v(this,"_bottomControl");v(this,"_backgroundControlTop");v(this,"_backgroundControlBottom");v(this,"_backgroundControlMiddleLeft");v(this,"_backgroundControlMiddleRight");v(this,"_fillControl");v(this,"_selectionShape");v(this,"_rowHeaderBackground");v(this,"_rowHeaderBorder");v(this,"_rowHeaderGroup");v(this,"_rowHeaderHighlight");v(this,"_columnHeaderBackground");v(this,"_columnHeaderBorder");v(this,"_columnHeaderGroup");v(this,"_columnHeaderHighlight");v(this,"_topLeftWidget");v(this,"_topCenterWidget");v(this,"_topRightWidget");v(this,"_middleLeftWidget");v(this,"_middleRightWidget");v(this,"_bottomLeftWidget");v(this,"_bottomCenterWidget");v(this,"_bottomRightWidget");v(this,"_dashRect");v(this,"_selectionModel");v(this,"_selectionStyle");v(this,"_rowHeaderWidth",0);v(this,"_columnHeaderHeight",0);v(this,"_widgetRects",[]);v(this,"_dispose$",new V.BehaviorSubject(this));v(this,"dispose$",this._dispose$.asObservable());v(this,"selectionMoving$",new V.Subject);v(this,"selectionMoved$",new V.Subject);v(this,"selectionScaling$",new V.Subject);v(this,"selectionScaled$",new V.Subject);v(this,"selectionFilling$",new V.Subject);v(this,"_selectionFilled$",new V.Subject);v(this,"selectionFilled$",this._selectionFilled$.asObservable());v(this,"_defaultStyle");v(this,"_isHelperSelection",!0);this._scene=e,this._zIndex=t,this._isHeaderHighlight=n,this._themeService=i,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,t=0,n=0,i,r){this._selectionModel.setValue(e,r),i==null&&(i=this._selectionStyle),this._updateControl(i,t,n)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,t,n,i,r,s,a,c,d,u,m,h,_,f,S,I,C,M,R,y,T,E,O,x,P;(e=this._leftControl)==null||e.dispose(),(t=this._rightControl)==null||t.dispose(),(n=this._topControl)==null||n.dispose(),(i=this._bottomControl)==null||i.dispose(),(r=this._backgroundControlTop)==null||r.dispose(),(s=this._backgroundControlMiddleLeft)==null||s.dispose(),(a=this._backgroundControlMiddleRight)==null||a.dispose(),(c=this._backgroundControlBottom)==null||c.dispose(),(d=this._fillControl)==null||d.dispose(),(u=this._selectionShape)==null||u.dispose(),(m=this._rowHeaderBackground)==null||m.dispose(),(h=this._rowHeaderBorder)==null||h.dispose(),(_=this._rowHeaderGroup)==null||_.dispose(),(f=this._rowHeaderBackground)==null||f.dispose(),(S=this._columnHeaderBackground)==null||S.dispose(),(I=this._columnHeaderBorder)==null||I.dispose(),(C=this._columnHeaderGroup)==null||C.dispose(),(M=this._topLeftWidget)==null||M.dispose(),(R=this._topCenterWidget)==null||R.dispose(),(y=this._topRightWidget)==null||y.dispose(),(T=this._middleLeftWidget)==null||T.dispose(),(E=this._middleRightWidget)==null||E.dispose(),(O=this._bottomLeftWidget)==null||O.dispose(),(x=this._bottomCenterWidget)==null||x.dispose(),(P=this._bottomRightWidget)==null||P.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const n=e.mergeInfo;t={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn,startX:n.startX,endX:n.endX,startY:n.startY,endY:n.endY}}else{const{actualRow:n,actualColumn:i,startX:r,endX:s,startY:a,endY:c}=e;t={startRow:n,endRow:n,startColumn:i,endColumn:i,startX:r,endX:s,startY:a,endY:c}}return t}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,t,n){const{startX:i,startY:r,endX:s,endY:a}=this._selectionModel,c=this._defaultStyle;e==null&&(e=c);const{stroke:d=c.stroke,widgets:u=c.widgets,hasAutoFill:m=c.hasAutoFill,AutofillStroke:h=c.AutofillStroke,strokeDash:_}=e;let{strokeWidth:f=c.strokeWidth,AutofillSize:S=c.AutofillSize,AutofillStrokeWidth:I=c.AutofillStrokeWidth}=e;const C=this._getScale();f/=C,S/=C,I/=C;const M=p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/C,R=f+M;this.leftControl.transformByState({height:a-r,left:-R/2,width:f,strokeWidth:M,top:-M/2}),this.leftControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:a-r,left:s-i-R/2,width:f,strokeWidth:M,top:-M/2}),this.rightControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:s-i+f,top:-R/2,left:-R/2,height:f,strokeWidth:M}),this.topControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:s-i+f,top:a-r-R/2,height:f,left:-R/2,strokeWidth:M}),this.bottomControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),_==null?this.dashRect.hide():(this.dashRect.transformByState({height:a-r,width:s-i,strokeWidth:f,left:-1,top:-1}),this.dashRect.setProps({strokeDashArray:[0,_]}),this.dashRect.show()),m===!0&&!this._hasWidgets(u)?(this.fillControl.setProps({fill:d,stroke:h}),this.fillControl.transformByState({width:S-I,height:S-I,left:s-i-S/2,top:a-r-S/2,strokeWidth:I}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,t,n),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(i,r),this._selectionStyle=e,this._rowHeaderWidth=t||0,this._columnHeaderHeight=n||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=p.getNormalSelectionStyle(this._themeService),this._selectionModel=new Kr;const e=this._zIndex;this._leftControl=new w.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new w.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new w.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new w.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new w.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new w.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new w.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new w.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new w.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e,this.getScene().addObject(this._selectionShape),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new w.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new w.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new w.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new w.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new w.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new w.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],w.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new w.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new w.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new w.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new w.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new w.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new w.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new w.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new w.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,t,n){const{startX:i,startY:r,endX:s,endY:a,rangeType:c}=this._selectionModel,d=this._defaultStyle;e==null&&(e=d);const u=this._getScale(),{stroke:m,hasRowHeader:h,rowHeaderFill:_=d.rowHeaderFill,rowHeaderStroke:f=d.rowHeaderStroke,hasColumnHeader:S,columnHeaderFill:I=d.columnHeaderFill,columnHeaderStroke:C=d.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:M=d.rowHeaderStrokeWidth,columnHeaderStrokeWidth:R=d.columnHeaderStrokeWidth}=e;if(M/=u,R/=u,S===!0){let y=I;this._isHeaderHighlight&&c===l.RANGE_TYPE.COLUMN&&(y=new De.TinyColor(m).setAlpha(jo).toString()),this._columnHeaderBackground.setProps({fill:y}),this._columnHeaderBackground.resize(s-i,n),this._columnHeaderBorder.setProps({fill:C}),this._columnHeaderBorder.transformByState({width:s-i,height:R,top:n-R+1/u}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(i,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),h===!0){let y=_;this._isHeaderHighlight&&c===l.RANGE_TYPE.ROW&&(y=new De.TinyColor(m).setAlpha(jo).toString()),this._rowHeaderBackground.setProps({fill:y}),this._rowHeaderBackground.resize(t,a-r),this._rowHeaderBorder.setProps({fill:f}),this._rowHeaderBorder.transformByState({width:M,height:a-r,left:t-M+1/u}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,r)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:n,endX:i,endY:r}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const a=this._getScale(),{fill:c=s.fill}=e;let{strokeWidth:d=s.strokeWidth}=e;d/=a;const u=this._selectionModel.highlightToSelection();if(!u){this._backgroundControlTop.resize(i-t,r-n),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:m,startY:h,endX:_,endY:f}=u,S=d/2,I={left:-S,top:-S,width:i-t+S*2,height:h-n+S};I.height<0&&(I.width=0,I.height=0),this._backgroundControlTop.transformByState(I);const C={left:-S,top:h-n,width:m-t+S,height:f-h};C.width<0&&(C.width=0,C.height=0),this._backgroundControlMiddleLeft.transformByState(C);const M={left:_-t-S,top:h-n,width:i-_+S*2,height:f-h};M.width<0&&(M.width=0,M.height=0),this._backgroundControlMiddleRight.transformByState(M);const R={left:-S,top:f-n,width:i-t+S*2,height:r-f+S};R.height<0&&(R.width=0,R.height=0),this._backgroundControlBottom.transformByState(R),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlMiddleLeft.setProps({fill:c}),this._backgroundControlMiddleRight.setProps({fill:c}),this._backgroundControlBottom.setProps({fill:c})}_updateWidgets(e){const{startX:t,startY:n,endX:i,endY:r}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const{stroke:a=s.stroke,widgets:c=s.widgets,widgetStroke:d=s.widgetStroke}=e,u=this._getScale();let{widgetSize:m=s.widgetSize,widgetStrokeWidth:h=s.widgetStrokeWidth}=e;m/=u,h/=u;const _={left:-m/2,center:(i-t)/2-m/2,right:i-t-m/2,top:-m/2,middle:(r-n)/2-m/2,bottom:r-n-m/2},f=m-h;this._widgetRects.forEach(S=>{S.setProps({fill:a,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:f,width:f,left:_.left,top:_.top,strokeWidth:h}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:f,width:f,left:_.center,top:_.top,strokeWidth:h}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:f,width:f,left:_.right,top:_.top,strokeWidth:h}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:f,width:f,left:_.left,top:_.middle,strokeWidth:h}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:f,width:f,left:_.right,top:_.middle,strokeWidth:h}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:f,width:f,left:_.left,top:_.bottom,strokeWidth:h}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:f,width:f,left:_.center,top:_.bottom,strokeWidth:h}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:f,width:f,left:_.right,top:_.bottom,strokeWidth:h}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const t=Object.keys(e);if(t.length===0)return!1;for(const n of t)if(e[n]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}const Wo="__SpreadsheetHelperSelectionTempRect",Jr=35;class zo{constructor(e,t,n,i){v(this,"_startOffsetX",0);v(this,"_startOffsetY",0);v(this,"_relativeSelectionPositionRow",0);v(this,"_relativeSelectionPositionColumn",0);v(this,"_relativeSelectionRowLength",0);v(this,"_relativeSelectionColumnLength",0);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_helperSelection");v(this,"_scrollTimer");v(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});v(this,"_isInMergeState",!1);v(this,"_fillControlColors",[]);this._control=e,this._skeleton=t,this._scene=n,this._themeService=i,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var e,t;(e=this._scrollTimer)==null||e.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(t=this._helperSelection)==null||t.dispose()}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:e,rightControl:t,topControl:n,bottomControl:i}=this._control;[e,t,n,i].forEach(r=>{r.onPointerEnterObserver.add(()=>{r.setCursor(w.CURSOR_TYPE.MOVE)}),r.onPointerLeaveObserver.add(()=>{r.resetCursor()}),r.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(e,t){var E;const n=this._scene,i=n.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,r,s,i),{row:c,column:d}=a,u=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let h=c+this._relativeSelectionPositionRow;h<0&&(h=0);let _=h+this._relativeSelectionRowLength;_>u&&(_=u,_-h<this._relativeSelectionRowLength&&(h=_-this._relativeSelectionRowLength));let f=d+this._relativeSelectionPositionColumn;f<0&&(f=0);let S=f+this._relativeSelectionColumnLength;S>m&&(S=m,S-f<this._relativeSelectionColumnLength&&(f=S-this._relativeSelectionColumnLength));const I=this._skeleton.getNoMergeCellPositionByIndex(h,f,r,s),C=this._skeleton.getNoMergeCellPositionByIndex(_,S,r,s),M=(I==null?void 0:I.startY)||0,R=(C==null?void 0:C.endY)||0,y=(I==null?void 0:I.startX)||0,T=(C==null?void 0:C.endX)||0;(E=this._helperSelection)==null||E.transformByState({left:y,top:M,width:T-y,height:R-M}),this._targetSelection={startY:M,endY:R,startX:y,endX:T,startRow:h,endRow:_,startColumn:f,endColumn:S},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(e){const{offsetX:t,offsetY:n}=e,i=this._scene,r=i.getRelativeCoord(w.Vector2.FromArray([t,n])),{x:s,y:a}=r,c=i.getScrollXYByRelativeCoords(r),{scaleX:d,scaleY:u}=i.getAncestorScale(),m=this._skeleton.getCellPositionByOffset(s,a,d,u,c);this._startOffsetX=s,this._startOffsetY=a;const{row:h,column:_}=m,{startRow:f,startColumn:S,endRow:I,endColumn:C}=this._control.model;let M=0,R=0;h<f?M-=1:h>I&&(M+=1),_<S?R-=1:_>C&&(R+=1),this._relativeSelectionPositionRow=f-h+M,this._relativeSelectionPositionColumn=S-_+R,this._relativeSelectionRowLength=I-f,this._relativeSelectionColumnLength=C-S;const y=this._control.selectionStyle,T=this._getScale();this.isHelperSelection&&(this._helperSelection=new w.Rect(Wo,{stroke:y.stroke,strokeWidth:y.strokeWidth/T}),i.addObject(this._helperSelection));const E=w.ScrollTimer.create(i);E.startScroll(s,a),this._scrollTimer=E,i.disableEvent(),this._moveObserver=i.onPointerMoveObserver.add(O=>{const{offsetX:x,offsetY:P}=O,{x:H,y:A}=i.getRelativeCoord(w.Vector2.FromArray([x,P]));this._controlMoving(H,A),i.setCursor(w.CURSOR_TYPE.MOVE),E.scrolling(H,A,()=>{this._controlMoving(H,A)})}),this._upObserver=i.onPointerUpObserver.add(O=>{var P,H;(P=this._helperSelection)==null||P.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableEvent(),(H=this._scrollTimer)==null||H.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:e,topCenterWidget:t,topRightWidget:n,middleLeftWidget:i,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:a,bottomRightWidget:c}=this._control,d=[w.CURSOR_TYPE.NORTH_WEST_RESIZE,w.CURSOR_TYPE.NORTH_RESIZE,w.CURSOR_TYPE.NORTH_EAST_RESIZE,w.CURSOR_TYPE.WEST_RESIZE,w.CURSOR_TYPE.EAST_RESIZE,w.CURSOR_TYPE.SOUTH_WEST_RESIZE,w.CURSOR_TYPE.SOUTH_RESIZE,w.CURSOR_TYPE.SOUTH_EAST_RESIZE];[e,t,n,i,r,s,a,c].forEach((u,m)=>{u.onPointerEnterObserver.add(h=>{u.setCursor(d[m])}),u.onPointerLeaveObserver.add(h=>{u.resetCursor()}),u.onPointerDownObserver.add(h=>{this._widgetEvent(h,d[m])})})}_widgetMoving(e,t,n){const i=this._scene,r=i.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:a}=i.getAncestorScale(),c=this._skeleton.getCellPositionByOffset(e,t,s,a,r),{row:d,column:u}=c,{rowHeaderWidth:m,columnHeaderHeight:h}=this._skeleton;this._skeleton.getRowCount()-1,this._skeleton.getColumnCount()-1;let _=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,S=d,I=u;n===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(_=d,f=u,S=this._relativeSelectionPositionRow,I=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.NORTH_RESIZE?(_=d,f=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,I=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===w.CURSOR_TYPE.NORTH_EAST_RESIZE?(_=d,f=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,I=u):n===w.CURSOR_TYPE.WEST_RESIZE?(_=this._relativeSelectionPositionRow,f=u,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,I=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.EAST_RESIZE?S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===w.CURSOR_TYPE.SOUTH_WEST_RESIZE?(_=this._relativeSelectionPositionRow,f=u,S=d,I=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.SOUTH_RESIZE&&(_=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,S=d,I=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:C,startColumn:M,endRow:R,endColumn:y}=this._swapPositions(_,f,S,I),T=this._skeleton.getNoMergeCellPositionByIndex(C,M,s,a),E=this._skeleton.getNoMergeCellPositionByIndex(R,y,s,a),O=(T==null?void 0:T.startY)||0,x=(E==null?void 0:E.endY)||0,P=(T==null?void 0:T.startX)||0,H=(E==null?void 0:E.endX)||0;this._targetSelection={startY:O,endY:x,startX:P,endX:H,startRow:_,endRow:S,startColumn:f,endColumn:I},this._control.update(this._targetSelection,m,h,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(e,t){const{offsetX:n,offsetY:i}=e,r=this._scene,s=r.getRelativeCoord(w.Vector2.FromArray([n,i])),{x:a,y:c}=s;this._startOffsetX=n,this._startOffsetY=i;const{startRow:d,startColumn:u,endRow:m,endColumn:h}=this._control.model;this._relativeSelectionPositionRow=d,this._relativeSelectionPositionColumn=u,this._relativeSelectionRowLength=m-d,this._relativeSelectionColumnLength=h-u,t===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=m,this._relativeSelectionPositionColumn=h):t===w.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=m:t===w.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=m:t===w.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=h:t===w.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=h);const _=w.ScrollTimer.create(r);_.startScroll(a,c),this._scrollTimer=_,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(f=>{const{offsetX:S,offsetY:I}=f,{x:C,y:M}=r.getRelativeCoord(w.Vector2.FromArray([S,I]));this._widgetMoving(C,M,t),r.setCursor(t),_.scrolling(C,M,()=>{this._widgetMoving(C,M,t)})}),this._upObserver=r.onPointerUpObserver.add(f=>{var I;const S=this._scene;S.resetCursor(),this._clearObserverEvent(),S.enableEvent(),(I=this._scrollTimer)==null||I.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:e}=this._control;e.onPointerEnterObserver.add(t=>{e.setCursor(w.CURSOR_TYPE.CROSSHAIR)}),e.onPointerLeaveObserver.add(t=>{e.resetCursor()}),e.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(e,t){var H,A,D;const n=this._scene,i=n.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,r,s,i),{row:c,column:d}=a,u=n.getRelativeCoord(w.Vector2.FromArray([e,t])),m=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let _=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,I=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,C=!1,M=!0;if((d<f||d>I)&&c>=_&&c<=S){const N=this._FillRuler(d,f,I,this._relativeSelectionColumnLength,h);f=N.startRowOrColumn,I=N.endRowOrColumn,C=N.isLighten,M=!1}else if((c<_||c>S)&&d>=f&&d<=I){const N=this._FillRuler(c,_,S,this._relativeSelectionRowLength,m);_=N.startRowOrColumn,S=N.endRowOrColumn,C=N.isLighten}else if(Math.abs(this._startOffsetX-u.x-i.x)/2>Math.abs(this._startOffsetY-u.y-i.y)){const N=this._FillRuler(d,f,I,this._relativeSelectionColumnLength,h);f=N.startRowOrColumn,I=N.endRowOrColumn,C=N.isLighten,M=!1}else{const N=this._FillRuler(c,_,S,this._relativeSelectionRowLength,m);_=N.startRowOrColumn,S=N.endRowOrColumn,C=N.isLighten}const R=this._skeleton.getNoMergeCellPositionByIndex(_,f,r,s),y=this._skeleton.getNoMergeCellPositionByIndex(S,I,r,s),T=(R==null?void 0:R.startY)||0,E=(y==null?void 0:y.endY)||0,O=(R==null?void 0:R.startX)||0,x=(y==null?void 0:y.endX)||0;C?this._controlHandler((N,B)=>{const $=new De.TinyColor(this._fillControlColors[B]).lighten(Jr).toString();N.setProps({fill:$})}):this._controlHandler((N,B)=>{N.setProps({fill:this._fillControlColors[B]})});const P=p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();_===S&&M===!0||f===I&&M===!1?(H=this._helperSelection)==null||H.hide():((A=this._helperSelection)==null||A.transformByState({left:O-P/2,top:T-P/2,width:x-O,height:E-T}),(D=this._helperSelection)==null||D.show()),this._targetSelection={startY:T,endY:E,startX:O,endX:x,startRow:_,endRow:S,startColumn:f,endColumn:I},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(e){const{offsetX:t,offsetY:n}=e,i=this._scene,r=i.getRelativeCoord(w.Vector2.FromArray([t,n])),{x:s,y:a}=r;this._startOffsetX=s,this._startOffsetY=a;const{startRow:c,startColumn:d,endRow:u,endColumn:m}=this._control.model;this._isInMergeState=this._hasMergeInRange(c,d,u,m),this._relativeSelectionPositionRow=c,this._relativeSelectionPositionColumn=d,this._relativeSelectionRowLength=u-c,this._relativeSelectionColumnLength=m-d;const h=this._control.selectionStyle;let _=h==null?void 0:h.stroke,f=h==null?void 0:h.strokeWidth;const S=p.getNormalSelectionStyle(this._themeService);_==null&&(_=S.stroke),f==null&&(f=S.strokeWidth);const I=this._getScale();f/=I;const C=p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/I,M=new De.TinyColor(_).darken(2).toString();this.isHelperSelection&&(this._helperSelection=new w.Rect(Wo,{stroke:M,strokeWidth:f+C/2}),i.addObject(this._helperSelection));const R=w.ScrollTimer.create(i);R.startScroll(s,a),this._scrollTimer=R,i.disableEvent(),this._controlHandler(y=>{this._fillControlColors.push(y.fill)}),this._moveObserver=i.onPointerMoveObserver.add(y=>{const{offsetX:T,offsetY:E}=y,{x:O,y:x}=i.getRelativeCoord(w.Vector2.FromArray([T,E]));this._fillMoving(O,x),i.setCursor(w.CURSOR_TYPE.CROSSHAIR),R.scrolling(O,x,()=>{this._fillMoving(O,x)})}),this._upObserver=i.onPointerUpObserver.add(y=>{var E,O;(E=this._helperSelection)==null||E.dispose();const T=this._scene;T.resetCursor(),this._clearObserverEvent(),T.enableEvent(),(O=this._scrollTimer)==null||O.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,P)=>{x.setProps({fill:this._fillControlColors[P]})}),this._fillControlColors=[]})}_hasMergeInRange(e,t,n,i){const r=this._skeleton.mergeData;if(!r)return!1;for(const s of r){const{startRow:a,startColumn:c,endRow:d,endColumn:u}=s,m={left:t,top:e,right:i,bottom:n},h={left:c,top:a,right:u,bottom:d};if(w.isRectIntersect(m,h))return!0}return!1}_swapPositions(e,t,n,i){const r=Math.min(e,n),s=Math.min(t,i),a=Math.max(e,n),c=Math.max(t,i);return{startRow:r,startColumn:s,endRow:a,endColumn:c}}_controlHandler(e){const{leftControl:t,rightControl:n,topControl:i,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:a,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,m=[t,n,i,r,s,a,c,d,u];for(let h=0,_=m.length;h<_;h++){const f=m[h];e(f,h)}}_FillRuler(e,t,n,i,r){let s=!1;if(e<t)if(this._isInMergeState&&e<t){const a=t-e,c=i+1,d=Math.ceil(a/c);let u=t-d*c;u<0&&(u=t-(d-1)*c),t=u}else t=e;else if(e>=t&&e<=n)s=!0,n=e;else if(this._isInMergeState&&e>n){const a=e-n,c=i+1,d=Math.ceil(a/c);let u=n+d*c;u>r&&(u=n+(d-1)*c),n=u}else n=e;return{rowOrColumn:e,startRowOrColumn:t,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}var Qr=Object.defineProperty,qr=Object.getOwnPropertyDescriptor,es=(o,e,t,n)=>{for(var i=n>1?void 0:n?qr(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Qr(e,t,i),i},Xo=(o,e)=>(t,n)=>e(t,n,o);k.SelectionRenderService=class{constructor(e,t){v(this,"hasSelection",!1);v(this,"_downObserver");v(this,"_moveObserver");v(this,"_upObserver");v(this,"_controlFillConfig$",new V.BehaviorSubject(null));v(this,"controlFillConfig$",this._controlFillConfig$.asObservable());v(this,"_selectionControls",[]);v(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});v(this,"_startOffsetX",0);v(this,"_startOffsetY",0);v(this,"_scrollTimer");v(this,"_cancelDownObserver");v(this,"_cancelUpObserver");v(this,"_skeleton");v(this,"_scene");v(this,"_isHeaderHighlight",!0);v(this,"_isDetectMergedCell",!0);v(this,"_selectionStyle");v(this,"_isSelectionEnabled",!0);v(this,"_isShowPreviousEnable",0);v(this,"_isRemainLastEnable",!0);v(this,"_isSkipRemainLastEnable",!1);v(this,"_selectionMoveEnd$",new V.BehaviorSubject([]));v(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());v(this,"_selectionMoving$",new V.Subject);v(this,"selectionMoving$",this._selectionMoving$.asObservable());v(this,"_selectionMoveStart$",new V.Subject);v(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());v(this,"_activeViewport");this._themeService=e,this._shortcutService=t,this._selectionStyle=p.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(e){this._selectionStyle=e}resetStyle(){this.setStyle(p.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(e){const t=this.getCurrentControls();if(!t)return;const{rangeWithCoord:n,primaryWithCoord:i}=e,r=this._skeleton;let s=e.style;s==null&&(s=p.getNormalSelectionStyle(this._themeService));const a=this._scene;if(a==null||r==null)return;const c=new Wt(a,t.length,this._isHeaderHighlight,this._themeService);new zo(c,r,a,this._themeService);const{rowHeaderWidth:d,columnHeaderHeight:u}=r;c.update(n,d,u,s,i),this._isHeaderHighlight?c.enableHeaderHighlight():c.disableHeaderHighlight(),t.push(c)}changeRuntime(e,t,n){this._skeleton=e,this._scene=t,this._activeViewport=n||t.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(t=>t.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const e=this.getCurrentControls();if(e.length>0){for(const t of e)t.dispose();e.length=0}}getActiveSelections(){const e=this.getCurrentControls();if(e&&e.length>0)return e==null?void 0:e.map(n=>{const i=n.model,r=i.currentCell;let s=null;return r&&(s={actualRow:r.actualRow,actualColumn:r.actualColumn,isMerged:r.isMerged,isMergedMainCell:r.isMergedMainCell,startRow:r.mergeInfo.startRow,startColumn:r.mergeInfo.startColumn,endRow:r.mergeInfo.endRow,endColumn:r.mergeInfo.endColumn}),{range:{startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn},primary:s}})}getActiveRange(){const e=this.getCurrentControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}getActiveSelection(){const e=this.getCurrentControls();return e&&e[e.length-1]}endSelection(){this._endSelection()}reset(){this._clearSelectionControls(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(e,t=0,n=l.RANGE_TYPE.NORMAL,i,r=w.ScrollTimerType.ALL){if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:a,offsetY:c}=e,d=this._scene;if(d==null||s==null)return;i!=null&&(this._activeViewport=i);const u=d.getRelativeCoord(w.Vector2.FromArray([a,c]));let{x:m,y:h}=u;this._startOffsetX=m,this._startOffsetY=h;const _=d.getScrollXYByRelativeCoords(u),{scaleX:f,scaleY:S}=d.getAncestorScale();n===l.RANGE_TYPE.ROW?m=0:n===l.RANGE_TYPE.COLUMN&&(h=0);const I=this._getSelectedRangeWithMerge(m,h,f,S,_);if(!I)return!1;const{rangeWithCoord:C,primaryWithCoord:M}=I,{startRow:R,startColumn:y,endColumn:T,endRow:E,startY:O,endY:x,startX:P,endX:H}=C,{rowHeaderWidth:A,columnHeaderHeight:D}=s,N={startColumn:y,startRow:R,endColumn:T,endRow:E,startY:O,endY:x,startX:P,endX:H,rangeType:n};this._startSelectionRange=N;let B=this.getActiveSelection();const $=this.getCurrentControls();if(!$)return!1;for(const G of $){if(e.button===2&&G.model.isInclude(N)){B=G;return}if(G.model.isEqual(N)){B=G;break}e.shiftKey||G.clearHighlight()}if($.length>0&&!e.ctrlKey&&!e.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable){for(const G of $)G.dispose();$.length=0}const z=B&&B.model.currentCell;if(B&&e.shiftKey&&z){const{actualRow:G,actualColumn:Q,mergeInfo:j}=z,ee=Math.min(G,N.startRow,j.startRow),K=Math.max(G,N.endRow,j.endRow),ke=Math.min(Q,N.startColumn,j.startColumn),de=Math.max(Q,N.endColumn,j.endColumn),Ce=s.getMergeBounding(ee,ke,K,de),pt=s.getNoMergeCellPositionByIndex(Ce.startRow,Ce.startColumn,f,S),Qe=s.getNoMergeCellPositionByIndex(Ce.endRow,Ce.endColumn,f,S),He={startColumn:Ce.startColumn,startRow:Ce.startRow,endColumn:Ce.endColumn,endRow:Ce.endRow,startY:pt.startY,endY:Qe.endY,startX:pt.startX,endX:Qe.endX,rangeType:n},me=s.getCellByIndex(G,Q,f,S);this._startSelectionRange={startColumn:me.mergeInfo.startColumn,startRow:me.mergeInfo.startRow,endColumn:me.mergeInfo.endColumn,endRow:me.mergeInfo.endRow,startY:me.mergeInfo.startY||0,endY:me.mergeInfo.endY||0,startX:me.mergeInfo.startX||0,endX:me.mergeInfo.endX||0,rangeType:n},B.update(He,A,D,this._selectionStyle,z)}else this._isRemainLastEnable&&B&&!e.ctrlKey&&!e.shiftKey&&!this._isSkipRemainLastEnable?B.update(N,A,D,this._selectionStyle,M):(B=new Wt(d,$.length+t,this._isHeaderHighlight,this._themeService),new zo(B,s,d,this._themeService),B.update(N,A,D,this._selectionStyle,M),$.push(B));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),d.disableEvent();const J=w.ScrollTimer.create(this._scene,r);J.startScroll(m,h,i),this._scrollTimer=J,this._addCancelObserver(),(n===l.RANGE_TYPE.ROW||n===l.RANGE_TYPE.COLUMN)&&this._moving(m,h,B,n),this._moveObserver=d.onPointerMoveObserver.add(G=>{const{offsetX:Q,offsetY:j}=G,{x:ee,y:K}=d.getRelativeCoord(w.Vector2.FromArray([Q,j]));this._moving(ee,K,B,n),J.scrolling(ee,K,()=>{this._moving(ee,K,B,n)})}),this._upObserver=d.onPointerUpObserver.add(G=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(e){const{range:t,primary:n,style:i}=e;let r=this.convertRangeDataToSelection(t);return r==null&&(r={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:l.RANGE_TYPE.NORMAL}),{rangeWithCoord:r,primaryWithCoord:this.convertCellRangeToInfo(n),style:i}}convertRangeDataToSelection(e){const{startRow:t,startColumn:n,endRow:i,endColumn:r,rangeType:s}=e,a=this._scene,c=this._skeleton;if(a==null||c==null)return;const{scaleX:d,scaleY:u}=a.getAncestorScale(),m=c.getNoMergeCellPositionByIndex(t,n,d,u),h=c.getNoMergeCellPositionByIndex(i,r,d,u);return{startRow:t,startColumn:n,endRow:i,endColumn:r,rangeType:s,startY:(m==null?void 0:m.startY)||0,endY:(h==null?void 0:h.endY)||0,startX:(m==null?void 0:m.startX)||0,endX:(h==null?void 0:h.endX)||0}}convertCellRangeToInfo(e){if(e==null)return;const t=this._scene,n=this._skeleton;if(t==null||n==null)return;const{actualRow:i,actualColumn:r,isMerged:s,isMergedMainCell:a,startRow:c,startColumn:d,endRow:u,endColumn:m}=e,{scaleX:h,scaleY:_}=t.getAncestorScale(),f=n.getNoMergeCellPositionByIndex(i,r,h,_),S=n.getNoMergeCellPositionByIndex(c,d,h,_),I=n.getNoMergeCellPositionByIndex(u,m,h,_);return{actualRow:i,actualColumn:r,isMerged:s,isMergedMainCell:a,startX:f.startX,startY:f.startY,endX:f.endX,endY:f.endY,mergeInfo:{startRow:c,startColumn:d,endRow:u,endColumn:m,startY:(S==null?void 0:S.startY)||0,endY:(I==null?void 0:I.endY)||0,startX:(S==null?void 0:S.startX)||0,endX:(I==null?void 0:I.endX)||0}}}_moving(e,t,n,i){const r=this._skeleton,s=this._scene;if(s==null||r==null)return!1;const{startRow:a,startColumn:c,endRow:d,endColumn:u}=this._startSelectionRange,m=s.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),this._activeViewport),{scaleX:h,scaleY:_}=s.getAncestorScale(),{rowHeaderWidth:f,columnHeaderHeight:S}=r;i===l.RANGE_TYPE.ROW?e=1/0:i===l.RANGE_TYPE.COLUMN&&(t=1/0);const I=this._getSelectedRangeWithMerge(e,t,h,_,m);if(!I)return!1;const{rangeWithCoord:C,primaryWithCoord:M}=I,{startRow:R,startColumn:y,endColumn:T,endRow:E}=C,O=Math.min(R,a),x=Math.min(y,c),P=Math.max(E,d),H=Math.max(T,u);let A={startRow:O,startColumn:x,endRow:P,endColumn:H};if(this._isDetectMergedCell&&(A=r.getSelectionBounding(O,x,P,H)),!A)return!1;const{startRow:D,startColumn:N,endRow:B,endColumn:$}=A,z=r.getNoMergeCellPositionByIndex(D,N,h,_),J=r.getNoMergeCellPositionByIndex(B,$,h,_),G={startColumn:N,startRow:D,endColumn:$,endRow:B,startY:(z==null?void 0:z.startY)||0,endY:(J==null?void 0:J.endY)||0,startX:(z==null?void 0:z.startX)||0,endX:(J==null?void 0:J.endX)||0},{startRow:Q,endRow:j,startColumn:ee,endColumn:K}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1};(ee!==N||Q!==D||K!==$||j!==B)&&n!=null&&(n.update(G,f,S),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,i;const e=this._scene;if(e==null)return;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),e.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const t=(i=e.getEngine())==null?void 0:i.activeScene;t==null||t.onPointerDownObserver.remove(this._cancelDownObserver),t==null||t.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const e=this._scene;if(e==null)return;const t=(n=e.getEngine())==null?void 0:n.activeScene;t==null||t===e||(t.onPointerDownObserver.remove(this._cancelDownObserver),t.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=t.onPointerDownObserver.add(i=>{this._endSelection()}),this._cancelUpObserver=t.onPointerUpObserver.add(i=>{this._endSelection()}))}_getSelectedRangeWithMerge(e,t,n,i,r){var C;if(this._isDetectMergedCell){const M=(C=this._skeleton)==null?void 0:C.calculateCellIndexByPosition(e,t,n,i,r),R=l.makeCellToSelection(M);return R==null?void 0:{primaryWithCoord:M,rangeWithCoord:R}}const s=this._skeleton;if(s==null)return;const a=s.getCellPositionByOffset(e,t,n,i,r),{row:c,column:d}=a,u=s.getNoMergeCellPositionByIndex(c,d,n,i),{startX:m,startY:h,endX:_,endY:f}=u,S={startY:h,endY:f,startX:m,endX:_,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:h,endY:f,startX:m,endX:_,mergeInfo:S},rangeWithCoord:S}}},k.SelectionRenderService=es([Xo(0,L.Inject(l.ThemeService)),Xo(1,b.IShortcutService)],k.SelectionRenderService);const ae=L.createIdentifier("deprecated.univer.sheet.selection-render-service");var ts=Object.defineProperty,ns=Object.getOwnPropertyDescriptor,os=(o,e,t,n)=>{for(var i=n>1?void 0:n?ns(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&ts(e,t,i),i},Yo=(o,e)=>(t,n)=>e(t,n,o);k.SheetSkeletonManagerService=class{constructor(e,t){v(this,"_currentSkeleton",{unitId:"",sheetId:""});v(this,"_sheetSkeletonParam",[]);v(this,"_currentSkeleton$",new V.BehaviorSubject(null));v(this,"currentSkeleton$",this._currentSkeleton$.asObservable());v(this,"_currentSkeletonBefore$",new V.BehaviorSubject(null));v(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._currentUniverService=e,this._localeService=t}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getCurrentBySearch(this._currentSkeleton)}setCurrent(e){const t=this._getCurrentBySearch(e);if(t!=null)this._reCalculate(t);else{const{unitId:i,sheetId:r}=e,s=this._currentUniverService.getUniverSheetInstance(e.unitId),a=s==null?void 0:s.getSheetBySheetId(e.sheetId);if(a==null||s==null)return;const c=this._buildSkeleton(a,s);this._sheetSkeletonParam.push({unitId:i,sheetId:r,skeleton:c,dirty:!1})}this._currentSkeleton=e;const n=this.getCurrent();return this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n),this.getCurrent()}reCalculate(){const e=this.getCurrent();e!=null&&this._reCalculate(e)}_reCalculate(e){e.dirty&&(e.skeleton.makeDirty(!0),e.dirty=!1),e.skeleton.calculate()}makeDirtyCurrent(e=!0){this.makeDirty(this._currentSkeleton,e)}makeDirty(e,t=!0){const n=this._getCurrentBySearch(e);n!=null&&(n.dirty=t)}_getCurrentBySearch(e){const t=this._sheetSkeletonParam.find(n=>n.unitId===e.unitId&&n.sheetId===e.sheetId);return t!=null&&(t.commandId=e.commandId),t}_buildSkeleton(e,t){const n=e.getConfig();return w.SpreadsheetSkeleton.create(e,n,e.getCellMatrix(),t.getStyles(),this._localeService)}},k.SheetSkeletonManagerService=os([Yo(0,l.IUniverInstanceService),Yo(1,L.Inject(l.LocaleService))],k.SheetSkeletonManagerService);var is=Object.defineProperty,rs=Object.getOwnPropertyDescriptor,ss=(o,e,t,n)=>{for(var i=n>1?void 0:n?rs(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&is(e,t,i),i},Fe=(o,e)=>(t,n)=>e(t,n,o);const as=1e4,zt=L.createIdentifier("univer.mark-selection-service");k.MarkSelectionService=class extends l.Disposable{constructor(t,n,i,r,s,a,c){super();v(this,"_shapeMap",new Map);this._currentService=t,this._renderManagerService=n,this._selectionRenderService=i,this._commandService=r,this._sheetSkeletonManagerService=s,this._themeService=a,this._selectionManagerService=c,this._addRemoveListener(),this._addRefreshListener()}addShape(t,n=as){const i=this._currentService.getCurrentUniverSheetInstance(),r=i.getActiveSheet().getSheetId(),s=l.Tools.generateRandomId();return this._shapeMap.set(s,{selection:t,worksheetId:r,workbookId:i.getUnitId(),zIndex:n,control:null}),this.refreshShapes(),s}refreshShapes(){const t=this._currentService.getCurrentUniverSheetInstance().getUnitId(),n=this._currentService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();setTimeout(()=>{this._shapeMap.forEach(i=>{var M;const{workbookId:r,worksheetId:s,selection:a,control:c,zIndex:d}=i;if(r!==t||s!==n){c&&c.dispose();return}const{style:u}=a,{scene:m}=this._renderManagerService.getRenderById(r)||{},{rangeWithCoord:h,primaryWithCoord:_}=this._selectionRenderService.convertSelectionRangeToData(a),f=(M=this._sheetSkeletonManagerService.getCurrent())==null?void 0:M.skeleton;if(!m||!f)return;const{rowHeaderWidth:S,columnHeaderHeight:I}=f,C=new Wt(m,d,!1,this._themeService);C.update(h,S,I,u,_),i.control=C})},0)}removeShape(t){const n=this._shapeMap.get(t);if(!n)return;const{control:i}=n;i&&i.dispose(),this._shapeMap.delete(t)}removeAllShapes(){for(const t of this._shapeMap.values()){const{control:n}=t;n&&n.dispose()}this._shapeMap.clear()}_addRemoveListener(){const t=[Ie.id,p.SetRangeValuesMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{t.includes(n.id)&&this.removeAllShapes()}))}_addRefreshListener(){const t=[p.SetWorksheetActiveOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{t.includes(n.id)&&this.refreshShapes()}))}},k.MarkSelectionService=ss([Fe(0,l.IUniverInstanceService),Fe(1,w.IRenderManagerService),Fe(2,ae),Fe(3,l.ICommandService),Fe(4,L.Inject(k.SheetSkeletonManagerService)),Fe(5,L.Inject(l.ThemeService)),Fe(6,L.Inject(p.SelectionManagerService))],k.MarkSelectionService);const ls=10,cs=6;function ds(){return l.Tools.generateRandomId(cs)}function us(o){const e=o.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class hs{constructor(){v(this,"_cache",new l.LRUMap(ls))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}del(e){this._cache.delete(e)}clear(){this._cache.clear()}}const Wn=new hs;function ms(o){const e=new DOMParser,t=`<x-univer id="univer-root">${o}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function _s(o){const e=o.style,t={};for(let n=0;n<e.length;n++){const i=e[n],r=e.getPropertyValue(i);switch(i){case"margin-top":{const s=parseInt(r);t.spaceAbove=/pt/.test(r)?zn(s):s;break}case"margin-bottom":{const s=parseInt(r);t.spaceBelow=/pt/.test(r)?zn(s):s;break}}}return Object.getOwnPropertyNames(t).length?t:null}function zn(o){return o/.75}function Xn(o){const e=o.style,t={},n=o.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{t.bl=l.BooleanNumber.TRUE;break}case"s":{t.st={s:l.BooleanNumber.TRUE};break}case"u":{t.ul={s:l.BooleanNumber.TRUE};break}case"i":{t.it=l.BooleanNumber.TRUE;break}case"sub":case"sup":{t.va=n==="sup"?l.BaselineOffset.SUPERSCRIPT:l.BaselineOffset.SUBSCRIPT;break}}for(let i=0;i<e.length;i++){const r=e[i],s=e.getPropertyValue(r);switch(r){case"font-family":{t.ff=s;break}case"font-size":{const a=parseInt(s);Number.isNaN(a)||(t.fs=/pt$/.test(s)?zn(a):a);break}case"font-style":{s==="italic"&&(t.it=l.BooleanNumber.TRUE);break}case"font-weight":{Number(s)>400&&(t.bl=l.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(s)?t.ul={s:l.BooleanNumber.TRUE}:/overline/.test(s)?t.ol={s:l.BooleanNumber.TRUE}:/line-through/.test(s)&&(t.st={s:l.BooleanNumber.TRUE});break}case"color":{const a=new De.TinyColor(s);a.isValid&&(t.cl={rgb:a.toRgbString()});break}case"background-color":{const a=new De.TinyColor(s);a.isValid&&(t.bg={rgb:a.toRgbString()});break}}}return t}function $o(o,e){const t=o.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(o)}const Bn=class Bn{constructor(e){v(this,"styleCache",new Map);v(this,"styleRules",[]);v(this,"afterProcessRules",[]);v(this,"getCurrentSkeleton");this.getCurrentSkeleton=e.getCurrentSkeleton}static use(e){if(this.pluginList.includes(e))throw new Error(`Univer paste plugin ${e.name} already added`);this.pluginList.push(e)}convert(e){const t=Bn.pluginList.find(h=>h.checkPasteType(e));t&&(this.styleRules=[...t.stylesRules],this.afterProcessRules=[...t.afterProcessRules]);const n=new l.ObjectMatrix,i=ms(e),r={dataStream:"",textRuns:[]},s=[],a=e.match(/<table.*?>([\s\S]*?)<\/table>/gi),c=[];this.process(null,i==null?void 0:i.childNodes,r,c);const{paragraphs:d,dataStream:u,textRuns:m}=r;if(d){const h=d.map(_=>_.startIndex+1);h.unshift(0);for(let _=0;_<h.length;_++){let f;_===h.length-1?f=`${u.substring(h[_])}\r
2
+ `:f=`${u.substring(h[_],h[_+1]-1)}\r
3
+ `;const S=[];m==null||m.forEach(C=>{C.st>=h[_]&&C.ed<=h[_+1]&&S.push({st:C.st-h[_],ed:C.ed-h[_],ts:C.ts})});const I=this._generateDocumentDataModelSnapshot({body:{dataStream:f,textRuns:S}});n.setValue(n.getLength(),0,{v:f,p:I}),s.push({}),a&&c.forEach(C=>{const M=n.getLength();if(C.index===_){const R=a.shift(),{cellMatrix:y,colProperties:T,rowProperties:E}=this._parseTable(R);y&&y.forValue((O,x,P)=>{n.setValue(M+O,x,P)}),s.push(...E)}})}}else{if(u){const h=this._generateDocumentDataModelSnapshot({body:r});n.setValue(0,0,{v:u,p:h}),s.push({})}a&&a.forEach(h=>{const _=n.getLength(),{cellMatrix:f}=this._parseTable(h);f&&f.forValue((S,I,C)=>{n.setValue(_+S,I,C)}),s.push(...s)})}return{rowProperties:[],colProperties:[],cellMatrix:n}}_parseTable(e){const t=new l.ObjectMatrix;ps(e);const{rowProperties:n,rowCount:i,cellMatrix:r}=Ss(e);return r&&r.forValue((s,a,c)=>{var u;const d=b.handleStringToStyle(void 0,(u=c.properties)==null?void 0:u.style);t.setValue(s,a,{v:c.content,s:d,rowSpan:c.rowSpan,colSpan:c.colSpan})}),{rowProperties:[],colProperties:[],cellMatrix:t}}_generateDocumentDataModelSnapshot(e){var a;const t=this.getCurrentSkeleton();if(t==null)return null;const{skeleton:n}=t,i=(a=n.getBlankCellDocumentModel())==null?void 0:a.documentModel,s={...i==null?void 0:i.getSnapshot(),...e};return i==null||i.reset(s),i==null?void 0:i.getSnapshot()}process(e,t,n,i){var r,s;for(const a of t)if(a.nodeName.toLowerCase()==="table")i.push({index:((r=n==null?void 0:n.paragraphs)==null?void 0:r.length)||0});else if(a.nodeType===Node.TEXT_NODE){const c=(s=a.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let d;e&&this.styleCache.has(e)&&(d=this.styleCache.get(e));const u={dataStream:"",textRuns:[]};n.dataStream+=c,u.dataStream+=c,d&&Object.getOwnPropertyNames(d).length&&(n.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}),u.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}))}else if(a.nodeType===Node.ELEMENT_NODE){const c=e?this.styleCache.get(e):{},d=this.styleRules.find(({filter:_})=>$o(a,_)),u=d?d.getStyle(a):Xn(a);this.styleCache.set(a,{...c,...u});const{childNodes:m}=a;this.process(a,m,n,i);const h=this.afterProcessRules.find(({filter:_})=>$o(a,_));h&&h.handler(n,a)}}};v(Bn,"pluginList",[]);let Ct=Bn;function Ss(o){const e=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,t=o.matchAll(e);if(!t)return{rowProperties:[],rowCount:0,colCount:0,cellMatrix:null};const n=Array.from(t),i=n.map(a=>Yn(a[1])),{colCount:r,cellMatrix:s}=fs(n.map(a=>a[2]));return{rowProperties:i,rowCount:i.length,colCount:r,cellMatrix:s}}function fs(o){const e=new l.ObjectMatrix,t=new Map,n=/<td([\s\S]*?)>([\s\S]*?)<\/td>/gi;let i=0,r=0,s=0;return o.forEach((a,c)=>{const d=c===0,u=a.matchAll(n);r=0,Array.from(u).forEach(m=>{const h=Yn(m[1]),_=m[2].replace(/&nbsp;/g," "),f=h.rowspan?+h.rowspan:1,S=h.colspan?+h.colspan:1;if(!d){for(let C=r;C<i;C++)if(!(t.get(C)>=s)){r=C;break}}const I={content:_,properties:h};S>1&&(I.colSpan=+S),f>1&&(I.rowSpan=+f),d&&(i+=S);for(let C=r;C<r+S;C++)t.set(C,s+f-1);e.setValue(s,r,I),r+=S}),s+=1}),{colCount:i,cellMatrix:e}}function Yn(o){if(!o)return{};const e=/([\w-]+)="([^"]*)"/gi,t=o.matchAll(e),n={};return Array.from(t).forEach(i=>{const[r,s,a]=i;n[s]=a}),n}function ps(o){const e=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,t=o.match(e);if(!t||!t[2])return null;const n=/<col([\s\S]*?)>/g,i=t[2].matchAll(n);return i?Array.from(i).map(r=>Yn(r[1])):null}const gs={name:"univer-doc-paste-plugin-lark",checkPasteType(o){return/lark-record-clipboard/i.test(o)},stylesRules:[{filter:["s"],getStyle(o){const e=Xn(o);return{st:{s:l.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(o){return o.tagName==="DIV"&&/ace-line/i.test(o.className)},handler(o){o.paragraphs==null&&(o.paragraphs=[]),o.paragraphs.push({startIndex:o.dataStream.length}),o.dataStream+="\r"}}]},vs={name:"univer-doc-paste-plugin-word",checkPasteType(o){return/word|mso/i.test(o)},stylesRules:[{filter:["b"],getStyle(o){const e=Xn(o);return{bl:l.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(o){return o.tagName==="P"&&/mso/i.test(o.className)},handler(o,e){o.paragraphs==null&&(o.paragraphs=[]);const t={startIndex:o.dataStream.length},n=_s(e);n&&(t.paragraphStyle=n),o.paragraphs.push(t),o.dataStream+="\r"}}]};var je=(o=>(o.COPY="COPY",o.CUT="CUT",o))(je||{});function Cs(o,e,t,n){const i=t.map(c=>{var d;return(d=c.onCopyRow)==null?void 0:d.call(c,o)}).filter(c=>!!c),r=$n(i),s=Zn(r),a=e.map(c=>Is(o,c,t,n)).filter(c=>!!c).join("");return`<tr${s}>${a}</tr>`}function Is(o,e,t,n){const i=n.getValue(o,e),r=t.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,o,e,i==null?void 0:i.rowSpan,i==null?void 0:i.colSpan)}).filter(d=>!!d),s=$n(r),a=Zn(s),c=t.reduce((d,u)=>{var m;return d||((m=u.onCopyCellContent)==null?void 0:m.call(u,o,e))||""},"");return`<td${a}>${c}</td>`}function bs(o,e){return`<colgroup>${o.map(n=>{const i=e.map(a=>{var c;return(c=a.onCopyColumn)==null?void 0:c.call(a,n)}).filter(a=>!!a),r=$n(i);return`<col ${Zn(r)}>`}).join("")}</colgroup>`}function $n(o){return o.reduce((e,t)=>(Object.keys(t).forEach(i=>{e[i]?e[i]+=`;${t[i]}`:e[i]=t[i]}),e),{})}function Zn(o){return Object.keys(o).reduce((e,t)=>(e+=` ${t}="${o[t]}"`,e),"")}function Ms(o,e){const t=[];for(let n=o;n<=e;n++)t.push(n);return t}class Rs{convert(e,t,n){const{startColumn:i,endColumn:r}=t,s=bs(Ms(i,r),n),a=[];return e.forRow((d,u)=>{a.push(Cs(d,u,n,e))}),`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" border="1" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
4
+ <tbody>${a.join("")}</tbody></table>`}}var ws=Object.defineProperty,ys=Object.getOwnPropertyDescriptor,Ts=(o,e,t,n)=>{for(var i=n>1?void 0:n?ys(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&ws(e,t,i),i},Le=(o,e)=>(t,n)=>e(t,n,o);const ue={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border"};Ct.use(vs),Ct.use(gs);const qe=L.createIdentifier("sheet.clipboard-service");k.SheetClipboardService=class extends l.Disposable{constructor(t,n,i,r,s,a,c,d){super();v(this,"_clipboardHooks",[]);v(this,"_clipboardHooks$",new V.BehaviorSubject([]));v(this,"clipboardHooks$",this._clipboardHooks$.asObservable());v(this,"_htmlToUSM");v(this,"_usmToHtml");v(this,"_copyMarkId",null);v(this,"_pasteType",ue.DEFAULT_PASTE);this._logService=t,this._currentUniverService=n,this._selectionManagerService=i,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=a,this._markSelectionService=c,this._sheetSkeletonManagerService=d,this._htmlToUSM=new Ct({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new Rs}async copy(t=je.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const i=this._clipboardHooks;i.reduce((C,M)=>{var y;const R=(y=M.getFilteredOutRows)==null?void 0:y.call(M);return R==null||R.forEach(T=>C.add(T)),C},new Set);const{startColumn:r,startRow:s,endColumn:a,endRow:c}=n.range,d=this._currentUniverService.getCurrentUniverSheetInstance(),u=d.getActiveSheet(),m=u.getMatrixWithMergedCells(s,r,c,a),h=new l.ObjectMatrix;for(let C=s;C<=c;C++)for(let M=r;M<=a;M++){const R=m.getValue(C,M);R?h.setValue(C-s,M-r,{...Zo(),...l.Tools.deepClone(R)}):h.setValue(C-s,M-r,Zo())}i.forEach(C=>{var M;return(M=C.onBeforeCopy)==null?void 0:M.call(C,d.getUnitId(),u.getSheetId(),n.range)});let _=this._usmToHtml.convert(m,n.range,i);const f=Es(h),S=ds();_=_.replace(/(<[a-z]+)/,(C,M)=>`${M} data-copy-id="${S}"`),Wn.set(S,{workbookId:d.getUnitId(),worksheetId:u.getSheetId(),range:n.range,matrix:h,copyType:t}),await this._clipboardInterfaceService.write(f,_),this._markSelectionService.removeAllShapes();const I=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:I}),i.forEach(C=>{var M;return(M=C.onAfterCopy)==null?void 0:M.call(C)}),!0}async cut(){return this.copy(je.CUT)}async paste(t,n=ue.DEFAULT_PASTE){const i=t.types,r=i.indexOf(b.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(b.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"",s=i.indexOf(b.HTML_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(b.HTML_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"";return s?this._pasteHTML(s,n):r?this._pastePlainText(r):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}addClipboardHook(t){if(this._clipboardHooks.findIndex(i=>i.hookName===t.hookName)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",t.hookName),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(i=>{const r=i.priority||0;return(t.priority||0)<r});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,t),this._notifyClipboardHook(),l.toDisposable(()=>{const i=this._clipboardHooks.indexOf(t);i>-1&&(this._clipboardHooks.splice(i,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(t){const n=this._getPastingTarget();if(!n.selection)return!1;const i=n.selection.range,r={[i.startRow]:{[i.endColumn]:{v:t}}},s={workbookId:n.workbookId,worksheetId:n.worksheetId,cellValue:r};return this._commandService.syncExecuteCommand(p.SetRangeValuesMutation.id,s)}async _pasteHTML(t,n){const i=us(t);return i?this._pasteInternal(i,n):this._pasteExternal(t,n)}async _pasteExternal(t,n){const i=this._getPastingTarget(),{selection:r,workbookId:s,worksheetId:a}=i;if(!r)return!1;const{rowProperties:c,colProperties:d,cellMatrix:u}=this._htmlToUSM.convert(t),{startColumn:m,endColumn:h,startRow:_,endRow:f}=u.getDataRange(),S=f-_+1,I=h-m+1;if(!u)return!1;const C=this._transformPastedData(S,I,u,r.range);return C?this._pasteUSM({rowProperties:c,colProperties:d,cellMatrix:u},{workbookId:s,worksheetId:a,pastedRange:C},n):!1}async _pasteInternal(t,n){var M;const i=this._getPastingTarget(),{selection:r,workbookId:s,worksheetId:a}=i,c=l.Tools.deepClone(Wn.get(t)),{range:d,matrix:u}=c||{};if(!r||!u||!c||!d||!r||!u||!c)return!1;const m=(M=this._currentUniverService.getUniverSheetInstance(s))==null?void 0:M.getStyles();u.forValue((R,y,T)=>{if(typeof T.s=="string"){const E=l.Tools.deepClone(T);E.s=m==null?void 0:m.getStyleByCell(T),u.setValue(R,y,E)}});const{startColumn:h,endColumn:_,startRow:f,endRow:S}=d,I=this._transformPastedData(S-f+1,_-h+1,u,r.range);if(!I)return!1;const C=this._pasteUSM({cellMatrix:u},{workbookId:s,worksheetId:a,pastedRange:I},n,{range:d,workbookId:c.workbookId,worksheetId:c.worksheetId,copyType:c.copyType,copyId:t});return c.copyType===je.CUT&&(Wn.del(t),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),C}_pasteUSM(t,n,i,r){const{rowProperties:s,colProperties:a,cellMatrix:c}=t,{workbookId:d,worksheetId:u,pastedRange:m}=n,{startColumn:h,endColumn:_}=m,f=_-h+1,S=this._clipboardHooks,I=[];if(S.some(x=>{var P;return I.push(x)&&((P=x.onBeforePaste)==null?void 0:P.call(x,d,u,m))===!1}))return I.forEach(x=>{var P;return(P=x.onAfterPaste)==null?void 0:P.call(x,!1)}),!1;if(!c)return!1;const M=r?{copyRange:r.range,copyType:r.copyType,workbookId:r.workbookId,worksheetId:r.worksheetId}:{copyType:je.COPY},R=[],y=[];S.filter(x=>x.specialPasteInfo&&i===x.hookName||!x.specialPasteInfo&&i===ue.DEFAULT_PASTE).forEach(x=>{var A,D,N;if(s){const B=(A=x.onPasteRows)==null?void 0:A.call(x,m,s,i);B&&(R.push(...B.redos),y.push(...B.undos))}const P=(D=x.onPasteColumns)==null?void 0:D.call(x,m,a||new Array(f).map(()=>({})),i);P&&(R.push(...P.redos),y.push(...P.undos));const H=(N=x.onPasteCells)==null?void 0:N.call(x,m,c,i,M);H&&(R.push(...H.redos),y.push(...H.undos))});const E=this._getSetSelectionOperation(d,u,m,c);E&&R.push(E),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:y,redoMutationsInfo:R});const O=R.every(x=>this._commandService.executeCommand(x.id,x.params));return O&&this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:y,redoMutations:R}),O}_getSetSelectionOperation(t,n,i,r){var S;const s=(S=this._currentUniverService.getUniverSheetInstance(t))==null?void 0:S.getSheetBySheetId(n);if(!s)return null;const{startRow:a,startColumn:c}=i,d={startRow:a,endRow:a,startColumn:c,endColumn:c},u=p.getPrimaryForRange(d,s),m=r.getValue(0,0),h=(m==null?void 0:m.rowSpan)||1,_=(m==null?void 0:m.colSpan)||1;if(h>1||_>1){const I={startRow:a,endRow:a+h-1,startColumn:c,endColumn:c+_-1};u.startRow=I.startRow,u.endRow=I.endRow,u.startColumn=I.startColumn,u.endColumn=I.endColumn,u.isMerged=!0,u.isMergedMainCell=!0}const f={workbookId:t,worksheetId:n,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:i,primary:u,style:null}]};return{id:p.SetSelectionsOperation.id,params:f}}_getPastingTarget(){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),i=this._selectionManagerService.getLast();return{workbookId:t.getUnitId(),worksheetId:n.getSheetId(),selection:i}}_transformPastedData(t,n,i,r){const{startRow:s,startColumn:a,endRow:c,endColumn:d}=r,u=c-s+1,m=d-a+1,S=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData().filter(T=>l.Rectangle.intersects({startRow:s,startColumn:a,endRow:c,endColumn:d},T)),I=S[0];let C=0,M=0,R=0,y=0;if(I&&(C=I.startRow,M=I.startColumn,R=I.endRow,y=I.endColumn),u%t===0&&m%n===0)if(S.length>0&&(u!==t||m!==n))if(C===s&&M===a&&R===c&&y===d)if(ks(i))for(let E=0;E<u;E++)for(let O=0;O<m;O++){const x=i.getValue(E%t,O%n);x&&i.setValue(E,O,x)}else i.forValue((E,O,x)=>{x.s=null,delete x.colSpan,delete x.rowSpan});else for(let T=0;T<u;T++)for(let E=0;E<m;E++){const O=i.getValue(T%t,E%n);O&&i.setValue(T,E,O)}else for(let T=0;T<u;T++)for(let E=0;E<m;E++){const O=i.getValue(T%t,E%n);O&&i.setValue(T,E,O)}else if(S.length>0)if(this._topLeftCellsMatch(t,n,r))r.endRow=s+t-1,r.endColumn=a+n-1;else{if(c>I.endRow||d>I.endColumn)return alert("We can't do that to a merged cell "),null;i.forValue((E,O,x)=>{x.s=null,delete x.colSpan,delete x.rowSpan})}else r.endRow=s+t-1,r.endColumn=a+n-1;return r}_topLeftCellsMatch(t,n,i){const s=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startRow:a,startColumn:c,endRow:d,endColumn:u}=i,m=Ps(a+t-1,c,c+t-1,s),h=As(c+n-1,a,a+t-1,s);return!m&&!h}},k.SheetClipboardService=Ts([Le(0,l.ILogService),Le(1,l.IUniverInstanceService),Le(2,L.Inject(p.SelectionManagerService)),Le(3,b.IClipboardInterfaceService),Le(4,l.IUndoRedoService),Le(5,l.ICommandService),Le(6,zt),Le(7,L.Inject(k.SheetSkeletonManagerService))],k.SheetClipboardService);function Es(o){let e="";return o.forRow((t,n)=>{const i=[];n.forEach(r=>{const s=o.getValue(t,r);if(s){const a=Os(s);i.push(a)}}),e+=i.join(" "),t!==o.getLength()-1&&(e+=`
5
+ `)}),e}function Os(o){const e=o.v;return xs((e==null?void 0:e.toString())||"")}const xs=o=>o.replace(/&/g,"&amp;").replace(/\ufeff/g,"").replace(/</g,"&lt;").replace(/>/g,"&gt;");function Ps(o,e,t,n){return n.getMergeData().some(i=>i.startRow<=o&&o<i.endRow&&e<=i.startColumn&&i.startColumn<=t)}function As(o,e,t,n){return n.getMergeData().some(i=>i.startColumn<=o&&o<i.endColumn&&e<=i.startRow&&i.startRow<=t)}function ks(o){let e=0;return o.forValue((t,n,i)=>{if(i&&e++,e>1)return!1}),e>1}function Zo(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Go={id:b.CopyCommand.id,name:"sheet.command.copy",type:l.CommandType.COMMAND,multi:!0,priority:1e3,preconditions:X,handler:async o=>o.get(qe).copy()},Hs={id:b.CutCommand.id,name:"sheet.command.cut",type:l.CommandType.COMMAND,multi:!0,priority:1e3,preconditions:X,handler:async o=>o.get(qe).cut()},et={id:b.PasteCommand.id,type:l.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:1e3,preconditions:X,handler:async(o,e)=>{const t=o.get(l.ILogService);if(t.log("[SheetPasteCommand]","the focusing element is",document.activeElement),!document.execCommand("paste")){t.log("[SheetPasteCommand]","failed to execute paste command on the activeElement, trying to use clipboard API.");const r=await o.get(b.IClipboardInterfaceService).read(),s=o.get(qe);return r.length!==0?s.paste(r[0],e==null?void 0:e.value):!1}return!1}},Ko={id:"sheet.command.paste-value",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(et.id,{value:ue.SPECIAL_PASTE_VALUE})},Jo={id:"sheet.command.paste-format",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(et.id,{value:ue.SPECIAL_PASTE_FORMAT})},Qo={id:"sheet.command.paste-col-width",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(et.id,{value:ue.SPECIAL_PASTE_COL_WIDTH})},qo={id:"sheet.command.paste-besides-border",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(et.id,{value:ue.SPECIAL_PASTE_BESIDES_BORDER})};var be=(o=>(o[o.moveStopeOne=0]="moveStopeOne",o[o.moveGap=1]="moveGap",o[o.moveStepPage=2]="moveStepPage",o[o.moveStepEnd=3]="moveStepEnd",o))(be||{});const _e={id:"sheet.command.move-selection",type:l.CommandType.COMMAND,handler:async(o,e)=>{if(!e)return!1;const t=o.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),i=o.get(p.SelectionManagerService).getLast();if(!i)return!1;const{direction:r,jumpOver:s}=e,{range:a,primary:c}=i,d=p.getStartRange(a,c,r),u=s===1?p.findNextGapRange(d,r,n):p.findNextRange(d,r,n),m=p.getCellAtRowCol(u.startRow,u.startColumn,n);return l.Rectangle.equals(m,d)?!1:(o.get(b.ShortcutExperienceService).remove({unitId:t.getUnitId(),sheetId:n.getSheetId(),keycode:b.KeyCode.TAB}),o.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:t.getUnitId(),sheetId:n.getSheetId(),pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:l.Rectangle.clone(m),primary:{startRow:m.startRow,startColumn:m.startColumn,endRow:m.endRow,endColumn:m.endColumn,actualRow:u.startRow,actualColumn:u.startColumn,isMerged:m.isMerged,isMergedMainCell:m.startRow===u.startRow&&m.startColumn===u.startColumn}}]}))}},We={id:"sheet.command.move-selection-enter-tab",type:l.CommandType.COMMAND,handler:async(o,e)=>{if(!e)return!1;const t=o.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),i=o.get(p.SelectionManagerService).getLast(),r=t.getUnitId(),s=n.getSheetId();if(!i)return!1;const{direction:a,keycode:c}=e,{range:d,primary:u}=i;let m=p.getStartRange(d,u,a);const h=o.get(b.ShortcutExperienceService),_=h.getCurrentBySearch({unitId:r,sheetId:s,keycode:b.KeyCode.TAB});let f;const{startRow:S,endRow:I,startColumn:C,endColumn:M}=d;if(l.Rectangle.equals(d,u)){if(c===b.KeyCode.TAB)_==null&&h.addOrUpdate({unitId:r,sheetId:s,keycode:b.KeyCode.TAB,selection:i});else{const T=_==null?void 0:_.selection;if(T!=null){const{range:E,primary:O}=T;m=p.getStartRange(E,O,a)}h.remove({unitId:r,sheetId:s,keycode:b.KeyCode.TAB})}const R=p.findNextRange(m,a,n),y=p.getCellAtRowCol(R.startRow,R.startColumn,n);if(l.Rectangle.equals(y,m))return!1;f={range:l.Rectangle.clone(y),primary:{startRow:y.startRow,startColumn:y.startColumn,endRow:y.endRow,endColumn:y.endColumn,actualRow:R.startRow,actualColumn:R.startColumn,isMerged:y.isMerged,isMergedMainCell:y.startRow===R.startRow&&y.startColumn===R.startColumn}}}else{h.remove({unitId:r,sheetId:s,keycode:b.KeyCode.TAB});const R=l.Tools.deepClone(u),y=p.findNextRange({startRow:R.startRow,startColumn:R.startColumn,endRow:R.endRow,endColumn:R.endColumn},a,n,{startRow:S,endRow:I,startColumn:C,endColumn:M}),T=p.getCellAtRowCol(y.startRow,y.startColumn,n);f={range:l.Rectangle.clone(d),primary:{startRow:T.startRow,startColumn:T.startColumn,endRow:T.endRow,endColumn:T.endColumn,actualRow:y.startRow,actualColumn:y.startColumn,isMerged:T.isMerged,isMergedMainCell:T.startRow===y.startRow&&T.startColumn===y.startColumn}}}return o.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:r,sheetId:s,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[f]})}},Me={id:"sheet.command.expand-selection",type:l.CommandType.COMMAND,handler:async(o,e)=>{if(!e)return!1;const t=o.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),i=o.get(p.SelectionManagerService).getLast();if(!i)return!1;const{range:r,primary:s}=i,{jumpOver:a,direction:c}=e,u=p.checkIfShrink(i,c,n)?a===1?p.shrinkToNextGapRange(r,{...l.Rectangle.clone(s),rangeType:l.RANGE_TYPE.NORMAL},c,n):p.shrinkToNextCell(r,c,n):a===1?p.expandToNextGapRange(r,c,n):p.expandToNextCell(r,c,n);return l.Rectangle.equals(u,r)?!1:o.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:t.getUnitId(),sheetId:n.getSheetId(),pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u,primary:s}]})}};let Re=[],Gn="";const ei={id:"sheet.command.select-all",type:l.CommandType.COMMAND,onDispose(){Re=[],Gn=""},handler:async(o,e={expandToGapFirst:!0,loop:!1})=>{const t=o.get(p.SelectionManagerService).getLast(),n=o.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),i=n.getActiveSheet();if(!t||!i)return!1;const r=`${n.getUnitId()}|${i.getSheetId()}`;r!==Gn&&(Re=[],Gn=r);const s=i.getMaxRows(),a=i.getMaxColumns(),{expandToGapFirst:c,loop:d}=e,{range:u,primary:m}=t,h=u.endColumn===a-1&&u.endRow===s-1&&u.startRow===0&&u.startColumn===0;Re.some(f=>l.Rectangle.equals(f,u))||(Re=[],Re.push(u));let _;if(h)if(d){if(Re.findIndex(S=>l.Rectangle.equals(S,u))!==Re.length-1)return!1;_=Re[0]}else return!1;else c?(_=p.expandToContinuousRange(u,{left:!0,right:!0,up:!0,down:!0},i),l.Rectangle.equals(_,u)&&(_=p.expandToWholeSheet(i))):_=p.expandToWholeSheet(i);return Re.some(f=>l.Rectangle.equals(f,_))||Re.push(_),o.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:n.getUnitId(),sheetId:i.getSheetId(),pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:_,primary:m}]})}};class Ne{constructor(){v(this,"_scrollInfo",new Map);v(this,"_currentScroll",null);v(this,"_scrollInfo$",new V.BehaviorSubject(null));v(this,"scrollInfo$",this._scrollInfo$.asObservable())}dispose(){this._scrollInfo$.complete()}setCurrentScroll(e){this._currentScroll=e,this._refresh(e)}getScrollByParam(e){return this._getCurrentScroll(e)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e})}addOrReplaceNoRefresh(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e},!1)}addOrReplaceByParam(e){this._addByParam(e)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(e,t=!0){const{unitId:n,sheetId:i,sheetViewStartColumn:r,sheetViewStartRow:s,offsetX:a,offsetY:c}=e;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(i,{sheetViewStartRow:s,sheetViewStartColumn:r,offsetX:a,offsetY:c}),t===!0&&this._refresh({unitId:n,sheetId:i})}_clearByParam(e){this._addByParam({...e,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(e)}_getCurrentScroll(e){var i;if(e==null)return;const{unitId:t,sheetId:n}=e;return(i=this._scrollInfo.get(t))==null?void 0:i.get(n)}_refresh(e){this._scrollInfo$.next(this._getCurrentScroll(e))}}const tt={id:"sheet.operation.set-scroll",type:l.CommandType.OPERATION,handler:(o,e)=>{if(!e)return!1;const t=o.get(Ne),r=o.get(l.IUniverInstanceService).getUniverSheetInstance(e.unitId).getSheetBySheetId(e.sheetId),{xSplit:s,ySplit:a}=r.getConfig().freeze;return t.addOrReplaceByParam({...e,sheetViewStartRow:e.sheetViewStartRow-a,sheetViewStartColumn:e.sheetViewStartColumn-s}),!0}},Xt={id:"sheet.operation.set-editor-resize",type:l.CommandType.OPERATION,handler:(o,e)=>!0},Ee={id:"sheet.operation.set-zoom-ratio",type:l.CommandType.OPERATION,handler:(o,e)=>{const t=o.get(l.IUniverInstanceService).getUniverSheetInstance(e.workbookId);if(!t)return!1;const n=t.getSheetBySheetId(e.worksheetId);return n?(n.getConfig().zoomRatio=e.zoomRatio,!0):!1}};var ti={exports:{}},Yt={};/**
6
+ * @license React
7
+ * react-jsx-runtime.production.min.js
8
+ *
9
+ * Copyright (c) Facebook, Inc. and its affiliates.
10
+ *
11
+ * This source code is licensed under the MIT license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ */var Ds=U,Ls=Symbol.for("react.element"),Ns=Symbol.for("react.fragment"),Us=Object.prototype.hasOwnProperty,Bs=Ds.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Vs={key:!0,ref:!0,__self:!0,__source:!0};function ni(o,e,t){var n,i={},r=null,s=null;t!==void 0&&(r=""+t),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)Us.call(e,n)&&!Vs.hasOwnProperty(n)&&(i[n]=e[n]);if(o&&o.defaultProps)for(n in e=o.defaultProps,e)i[n]===void 0&&(i[n]=e[n]);return{$$typeof:Ls,type:o,key:r,ref:s,props:i,_owner:Bs.current}}Yt.Fragment=Ns,Yt.jsx=ni,Yt.jsxs=ni,ti.exports=Yt;var g=ti.exports,Se=function(){return Se=Object.assign||function(o){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(o[i]=e[i])}return o},Se.apply(this,arguments)},Fs=function(o,e){var t={};for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&e.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(o);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(o,n[i])&&(t[n[i]]=o[n[i]]);return t},he=U.forwardRef(function(o,e){var t=o.icon,n=o.id,i=o.className,r=o.extend,s=Fs(o,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=U.useRef("_".concat(zs()));return oi(t,"".concat(n),{defIds:t.defIds,idSuffix:c.current},Se({ref:e,className:a},s),r)});function oi(o,e,t,n,i){return U.createElement(o.tag,Se(Se({key:e},js(o,t,i)),n),(Ws(o,t).children||[]).map(function(r,s){return oi(r,"".concat(e,"-").concat(o.tag,"-").concat(s),t,void 0,i)}))}function js(o,e,t){var n=Se({},o.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var i=e.defIds;return!i||i.length===0||(o.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],a=r[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Ws(o,e){var t,n=e.defIds;return!n||n.length===0?o:o.tag==="defs"&&(!((t=o.children)===null||t===void 0)&&t.length)?Se(Se({},o),{children:o.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?Se(Se({},i),{attrs:Se(Se({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):o}function zs(){return Math.random().toString(36).substring(2,8)}he.displayName="UniverIcon";var Xs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.5261 12.834V14.634C11.5261 14.9654 11.7948 15.234 12.1261 15.234V15.234C12.4575 15.234 12.7261 14.9654 12.7261 14.634V12.834H14.5262C14.8576 12.834 15.1262 12.5654 15.1262 12.234V12.234C15.1262 11.9027 14.8576 11.634 14.5262 11.634H12.7261V9.83401C12.7261 9.50264 12.4575 9.23401 12.1261 9.23401V9.23401C11.7948 9.23401 11.5261 9.50264 11.5261 9.83401V11.634H9.72622C9.39485 11.634 9.12622 11.9027 9.12622 12.234V12.234C9.12622 12.5654 9.39485 12.834 9.72622 12.834H11.5261Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.05352 1.9613C2.39077 1.9613 1.85352 2.49856 1.85352 3.1613V6.7613C1.85352 7.42405 2.39077 7.9613 3.05352 7.9613H6.65352C7.31626 7.9613 7.85352 7.42405 7.85352 6.7613V3.1613C7.85352 2.49856 7.31626 1.9613 6.65352 1.9613H3.05352zM6.65352 3.1613H3.05352L3.05352 6.7613H6.65352V3.1613zM3.05352 9.23401C2.39077 9.23401 1.85352 9.77127 1.85352 10.434V14.034C1.85352 14.6968 2.39077 15.234 3.05352 15.234H6.65352C7.31626 15.234 7.85352 14.6968 7.85352 14.034V10.434C7.85352 9.77127 7.31626 9.23401 6.65352 9.23401H3.05352zM6.65352 10.434H3.05352L3.05352 14.034H6.65352V10.434zM10.3262 7.9613C9.66348 7.9613 9.12622 7.42405 9.12622 6.7613V3.1613C9.12622 2.49856 9.66348 1.9613 10.3262 1.9613H13.9262C14.589 1.9613 15.1262 2.49856 15.1262 3.1613V6.7613C15.1262 7.42405 14.589 7.9613 13.9262 7.9613H10.3262zM10.3262 6.7613V3.1613L13.9262 3.1613V6.7613H10.3262z",fillRule:"evenodd",clipRule:"evenodd"}}]},ii=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"autofill",ref:e,icon:Xs}))});ii.displayName="Autofill";const Ys=ii;var $s={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.6152 4.52067C14.8732 4.77869 14.8732 5.19703 14.6152 5.45505L6.61862 13.4514C6.46241 13.6077 6.20915 13.6077 6.05294 13.4514L1.73512 9.13354C1.4771 8.87551 1.4771 8.45718 1.73513 8.19915C1.99315 7.94113 2.41149 7.94114 2.66951 8.19916L6.19436 11.7241C6.27247 11.8022 6.3991 11.8022 6.47721 11.7241L13.6808 4.52067C13.9388 4.26264 14.3571 4.26264 14.6152 4.52067Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ri=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"check-mark-single",ref:e,icon:$s}))});ri.displayName="CheckMarkSingle";const $t=ri;var Zs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.48712 4.59907C5.23328 4.34523 4.82172 4.34523 4.56788 4.59907C4.31404 4.85291 4.31404 5.26447 4.56788 5.51831L7.9973 8.94773L4.56773 12.3773C4.31389 12.6311 4.31389 13.0427 4.56773 13.2965C4.82157 13.5504 5.23313 13.5504 5.48697 13.2965L8.91654 9.86697L12.3461 13.2965C12.5999 13.5503 13.0114 13.5503 13.2653 13.2965C13.5191 13.0426 13.5191 12.6311 13.2653 12.3772L9.83577 8.94773L13.2651 5.51836C13.519 5.26452 13.519 4.85296 13.2651 4.59912C13.0113 4.34528 12.5997 4.34528 12.3459 4.59912L8.91654 8.02849L5.48712 4.59907Z"}}]},si=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"close-single",ref:e,icon:Zs}))});si.displayName="CloseSingle";const Gs=si;var Ks={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.54 0.32H16.54V16.32H0.54z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_1213)"},children:[{tag:"path",attrs:{d:"M1.76539 1.27148C1.89532 1.2465 2.05784 1.23193 2.25712 1.23193H7.39957C7.59852 1.23193 7.76228 1.24644 7.89394 1.27682 8.02979 1.30817 8.13912 1.36697 8.22237 1.45577 8.30591 1.54488 8.35813 1.6636 8.38857 1.80057L8.38913 1.80311C8.41406 1.93772 8.42854 2.10966 8.42854 2.31825V7.47982C8.42854 7.67924 8.41396 7.84153 8.38908 7.97584 8.36281 8.11247 8.3041 8.22717 8.22073 8.31054 8.13704 8.39424 8.02807 8.4472 7.89934 8.4781 7.77208 8.50864 7.60803 8.52313 7.41869 8.52313H2.25712C2.06419 8.52313 1.90591 8.51354 1.77494 8.48836 1.64209 8.46281 1.53156 8.41527 1.4464 8.33054 1.3606 8.24999 1.30815 8.13434 1.27781 8.00286 1.2476 7.87192 1.22815 7.69892 1.22815 7.47982V2.27524C1.22815 2.07123 1.24271 1.90413 1.26761 1.76966 1.29388 1.63303 1.35259 1.51833 1.43596 1.43496 1.52104 1.34988 1.63137 1.30236 1.76275 1.27204L1.76539 1.27148zM2.56975 2.39137C2.49306 2.39568 2.45433 2.41469 2.43395 2.43562 2.41191 2.46884 2.39718 2.51452 2.39715 2.57614L2.40631 4.24285H4.26296V2.39137H2.56975zM5.44152 2.39615V4.24285H7.24998V2.51898C7.24998 2.47398 7.24652 2.44245 7.24141 2.42201 7.23917 2.41305 7.23709 2.40806 7.23591 2.40567 7.22586 2.40059 7.20631 2.39615 7.16061 2.39615H5.44152zM2.40708 5.39751L2.41626 7.22616C2.41626 7.26829 2.41965 7.29933 2.42492 7.32085 2.42882 7.33675 2.43309 7.34502 2.43572 7.34893 2.43572 7.34893 2.43928 7.35079 2.44202 7.35193 2.44831 7.35455 2.45718 7.35739 2.46908 7.35996 2.49304 7.36512 2.52583 7.36847 2.56777 7.36847H4.26774V5.39751H2.40708zM5.44152 5.39751V7.36847H7.09848C7.1739 7.36847 7.21416 7.35941 7.23151 7.35088 7.23281 7.34891 7.23591 7.34357 7.23933 7.33216 7.24553 7.3115 7.24998 7.27978 7.24998 7.23608V5.39751H5.44152zM9.19356 8.15082C9.3235 8.12583 9.48601 8.11127 9.6853 8.11127H14.8277C15.0267 8.11127 15.1905 8.12577 15.3221 8.15616 15.458 8.18751 15.5673 8.2463 15.6506 8.33511 15.7341 8.42421 15.7863 8.54294 15.8167 8.67991L15.8173 8.68245C15.8422 8.81705 15.8567 8.98899 15.8567 9.19759V14.3592C15.8567 14.5586 15.8421 14.7209 15.8173 14.8552 15.791 14.9918 15.7323 15.1065 15.6489 15.1899 15.5652 15.2736 15.4562 15.3265 15.3275 15.3574 15.2003 15.388 15.0362 15.4025 14.8469 15.4025H9.6853C9.49237 15.4025 9.33408 15.3929 9.20312 15.3677 9.07027 15.3421 8.95974 15.2946 8.87458 15.2099 8.78878 15.1293 8.73633 15.0137 8.70599 14.8822 8.67578 14.7513 8.65633 14.5783 8.65633 14.3592V9.15457C8.65633 8.95057 8.67088 8.78346 8.69579 8.649 8.72206 8.51237 8.78077 8.39767 8.86414 8.3143 8.94922 8.22922 9.05955 8.1817 9.19093 8.15138L9.19356 8.15082zM9.99793 9.27071C9.92124 9.27501 9.88251 9.29403 9.86212 9.31496 9.84009 9.34817 9.82536 9.39386 9.82533 9.45548L9.83448 11.1222H11.6911V9.27071H9.99793zM12.8697 9.27549V11.1222H14.6782V9.39831C14.6782 9.35332 14.6747 9.32178 14.6696 9.30135 14.6673 9.29238 14.6653 9.2874 14.6641 9.285 14.654 9.27992 14.6345 9.27549 14.5888 9.27549H12.8697zM9.83525 12.2768L9.84444 14.1055C9.84444 14.1476 9.84783 14.1787 9.8531 14.2002 9.85699 14.2161 9.86127 14.2244 9.86389 14.2283L9.86689 14.2298 9.87019 14.2313C9.87648 14.2339 9.88535 14.2367 9.89726 14.2393 9.92122 14.2445 9.95401 14.2478 9.99594 14.2478H11.6959V12.2768H9.83525zM12.8697 12.2768V14.2478H14.5267C14.6021 14.2478 14.6423 14.2387 14.6597 14.2302 14.661 14.2282 14.6641 14.2229 14.6675 14.2115 14.6737 14.1908 14.6782 14.1591 14.6782 14.1154V12.2768H12.8697z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M10.0049 2.46747C10.0049 2.06363 10.3323 1.73625 10.7361 1.73625H12.9298C14.1413 1.73625 15.1234 2.71838 15.1234 3.9299V6.12354C15.1234 6.52738 14.796 6.85476 14.3922 6.85476 13.9883 6.85476 13.661 6.52738 13.661 6.12354V3.9299C13.661 3.52606 13.3336 3.19868 12.9298 3.19868H10.7361C10.3323 3.19868 10.0049 2.87131 10.0049 2.46747zM3.42396 10.5108C3.42396 10.107 3.09658 9.77962 2.69274 9.77962 2.2889 9.77962 1.96152 10.107 1.96152 10.5108V12.7045C1.96152 13.916 2.94365 14.8981 4.15517 14.8981H6.34882C6.75266 14.8981 7.08003 14.5707 7.08003 14.1669 7.08003 13.7631 6.75266 13.4357 6.34882 13.4357H4.15517C3.75134 13.4357 3.42396 13.1083 3.42396 12.7045V10.5108z"}}]}]},ai=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"convert-single",ref:e,icon:Ks}))});ai.displayName="ConvertSingle";const Js=ai;var Qs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.87 0.63H16.87V16.63H0.87z"}}]},{tag:"g",attrs:{mask:"url(#mask0_371_77)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.72636 13.5549C9.25212 14.1041 8.48323 14.1041 8.00899 13.5549L1.22579 5.70056C0.46078 4.81474 1.00259 3.30013 2.08448 3.30013L15.6509 3.30013C16.7328 3.30013 17.2746 4.81474 16.5096 5.70056L9.72636 13.5549Z"}}]}]},li=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"dropdown-single",ref:e,icon:Qs}))});li.displayName="DropdownSingle";const ci=li;var qs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.90535 4.99197C2.23194 4.82196 2.63451 4.94889 2.80452 5.27548C2.96702 5.58764 3.22397 5.8971 3.57667 6.18615C4.57587 7.00507 6.2535 7.58331 8.21318 7.58331C10.1728 7.58331 11.8505 7.00508 12.8497 6.18616C13.2024 5.8971 13.4593 5.58763 13.6218 5.27549C13.7918 4.94889 14.1944 4.82196 14.521 4.99196C14.8476 5.16197 14.9745 5.56454 14.8045 5.89113C14.5439 6.39185 14.1596 6.83646 13.6948 7.2174C13.6514 7.25301 13.6071 7.28815 13.5621 7.3228L15.0214 8.78205C15.2817 9.0424 15.2817 9.46451 15.0214 9.72486C14.761 9.98521 14.3389 9.98521 14.0785 9.72486L12.3889 8.03522C11.8643 8.28584 11.2846 8.48827 10.6659 8.63563L11.2065 10.6532C11.3018 11.0088 11.0907 11.3744 10.7351 11.4697C10.3794 11.565 10.0139 11.3539 9.91857 10.9983L9.34529 8.85869C8.97555 8.89693 8.59724 8.91664 8.21318 8.91664C7.82639 8.91664 7.44544 8.89665 7.07321 8.85788L6.49971 10.9983C6.40441 11.354 6.03886 11.565 5.68321 11.4697C5.32757 11.3744 5.11651 11.0089 5.2118 10.6532L5.75288 8.63382C5.13793 8.48682 4.5615 8.28539 4.03968 8.03629L2.35121 9.72477C2.09086 9.98512 1.66875 9.98512 1.4084 9.72477C1.14805 9.46442 1.14805 9.04231 1.4084 8.78196L2.86611 7.32424C2.82044 7.28912 2.77557 7.2535 2.73152 7.2174C2.26668 6.83645 1.88248 6.39184 1.62183 5.89114C1.45182 5.56455 1.57876 5.16198 1.90535 4.99197Z"}}]},di=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"eyelash-single",ref:e,icon:qs}))});di.displayName="EyelashSingle";const ea=di;var ta={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.06 0.78H16.06V16.78H0.06z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_367_60)"},children:[{tag:"path",attrs:{d:"M5.54303 5.67809C5.41486 5.67809 5.31977 5.55923 5.34791 5.43419L5.43336 5.05446C5.53338 4.62534 5.71701 4.25903 5.99076 3.96308 6.28977 3.63984 6.73293 3.49761 7.27633 3.49761 7.47741 3.49761 7.69254 3.52131 7.92082 3.56601 7.93983 3.56973 7.95869 3.57361 7.9774 3.57766 8.18885 3.62335 8.41593 3.52833 8.49925 3.32869L8.72661 2.78395C8.81351 2.57574 8.71072 2.3376 8.49476 2.27229 8.46253 2.26255 8.42923 2.25268 8.39485 2.24269 8.10639 2.15986 7.76287 2.11572 7.35969 2.11572 6.29909 2.11572 5.50608 2.38292 4.95354 2.88796 4.38882 3.40424 3.98783 4.14273 3.76308 5.11976L2.31598 11.3345C2.2402 11.6722 2.14495 12.0353 2.02739 12.4247 1.90869 12.8169 1.76625 13.2031 1.60116 13.5809 1.43472 13.9595 1.24707 14.3197 1.0385 14.6607.972389 14.7687.904093 14.8718.833608 14.9698.744025 15.0945.813644 15.2766.965497 15.2989 1.6153 15.3945 2.29684 15.2198 2.66091 14.6732 2.80556 14.456 2.94673 14.2082 3.08403 13.9287 3.44529 13.1932 3.78416 12.1538 4.09761 10.801L4.94794 7.15889C4.96907 7.06839 5.04977 7.00436 5.14271 7.00436H7.10372C7.28864 7.00436 7.44946 6.87761 7.49265 6.6978L7.61908 6.17153C7.67951 5.91998 7.48886 5.67809 7.23015 5.67809H5.54303zM13.8 5.86392L11.9914 8.11319 10.8878 5.92109C10.8211 5.77368 10.6743 5.67896 10.5125 5.67896H9.79183C9.48739 5.67896 9.28816 5.99784 9.42165 6.27145L10.8878 9.19857 8.27677 12.2928C8.04481 12.5594 8.23414 12.9751 8.58749 12.9751H9.16501C9.28566 12.9751 9.43944 12.9258 9.5177 12.834L11.5897 10.4084 12.5966 12.7046C12.6575 12.8666 12.8119 12.9751 12.9851 12.9751H13.779C14.062 12.9751 14.2207 12.7611 14.1216 12.4959L12.6517 9.42983C12.6517 9.42983 14.8799 6.59898 15.0802 6.32247 15.2756 6.05285 15.0812 5.67896 14.7482 5.67896H14.145C14.0064 5.67896 13.9122 5.73242 13.8 5.86392z"}}]}]},ui=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"fx-single",ref:e,icon:ta}))});ui.displayName="FxSingle";const na=ui;var oa={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.37 0.77H16.37V16.77H0.37z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_249)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.12107 2.86418C9.12107 2.45648 8.78669 2.12598 8.37422 2.12598C7.96175 2.12598 7.62737 2.45648 7.62737 2.86418V8.03164H2.39931C1.98684 8.03164 1.65247 8.36214 1.65247 8.76984C1.65247 9.17754 1.98684 9.50805 2.39931 9.50805H7.62737V14.6754C7.62737 15.0831 7.96175 15.4136 8.37422 15.4136C8.78669 15.4136 9.12107 15.0831 9.12107 14.6754V9.50805H14.3489C14.7613 9.50805 15.0957 9.17754 15.0957 8.76984C15.0957 8.36214 14.7613 8.03164 14.3489 8.03164H9.12107V2.86418Z"}}]}]},hi=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"increase-single",ref:e,icon:oa}))});hi.displayName="IncreaseSingle";const ia=hi;var ra={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.56 0.77H16.56V16.77H0.56z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.19318 4.76988C1.70089 4.26222 2.524 4.26226 3.03166 4.76997L8.13929 9.87808C8.3736 10.1124 8.75352 10.1124 8.98784 9.8781L14.0959 4.77C14.6036 4.26232 15.4267 4.26232 15.9344 4.77C16.4421 5.27768 16.4421 6.1008 15.9344 6.60848L9.97775 12.5651C9.19667 13.3462 7.93029 13.3462 7.14925 12.5651L1.1931 6.60836C0.685438 6.10065 0.685477 5.27753 1.19318 4.76988Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},mi=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"more-down-single",ref:e,icon:ra}))});mi.displayName="MoreDownSingle";const Kn=mi;var sa={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.52628 3.57095C5.81918 3.26411 6.29405 3.26411 6.58695 3.57095L11.0869 8.28525C11.3798 8.59209 11.3798 9.08958 11.0869 9.39642L6.51623 14.04C6.22334 14.3468 5.74846 14.3468 5.45557 14.04C5.16268 13.7331 5.16268 13.2357 5.45557 12.9288L9.35939 8.979C9.43544 8.90205 9.43652 8.77857 9.36182 8.70031L5.52628 4.68212C5.23339 4.37528 5.23339 3.87779 5.52628 3.57095Z",fillRule:"evenodd",clipRule:"evenodd"}}]},_i=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"more-single",ref:e,icon:sa}))});_i.displayName="MoreSingle";const Jn=_i;var aa={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.25 0.41H16.25V16.41H0.25z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1204)"},children:[{tag:"rect",attrs:{width:12.62,height:2.79,x:1.94,y:12.66,fill:"colorChannel1",rx:1.4}},{tag:"path",attrs:{fill:"currentColor",d:"M7.99664 2.57069C7.59302 2.05771 7.10966 1.68854 6.63466 1.50243C6.11882 1.30028 5.40184 1.25862 4.95066 1.83566C4.5486 2.34994 4.581 3.10899 4.82709 3.91045C4.93826 4.27259 5.11865 4.62903 5.37541 4.97266C5.38713 4.98834 5.39945 5.00329 5.41229 5.01752C5.4217 5.02789 5.4314 5.03788 5.44133 5.04746C5.45477 5.06043 5.46874 5.07267 5.48315 5.08419L3.75659 6.81071C3.51774 7.04955 3.51774 7.43683 3.75659 7.67569L7.48775 11.4068C7.72666 11.6457 8.11394 11.6457 8.35278 11.4068L13.0831 6.67651C13.3219 6.43766 13.3219 6.05039 13.0831 5.81155L9.35191 2.08037C9.11306 1.84153 8.72579 1.84153 8.48695 2.08037L7.99664 2.57069ZM7.71181 4.91288C7.72271 4.98224 7.73182 5.05302 7.73898 5.12518C7.77251 5.46131 8.07213 5.70663 8.40825 5.6731C8.74438 5.6396 8.98972 5.33994 8.9562 5.00382C8.90804 4.52113 8.79269 4.0731 8.6291 3.66819L8.91946 3.37784L11.7856 6.24403L10.8608 7.16886H5.12843L7.6582 4.63909C7.67903 4.72777 7.69702 4.81905 7.71181 4.91288ZM7.12302 3.44433C6.8246 3.02658 6.47279 2.75283 6.18833 2.64136C6.05252 2.58814 5.96546 2.58477 5.92656 2.58984C5.92268 2.59037 5.91947 2.59093 5.91678 2.59147L5.91208 2.59257C5.89185 2.62604 5.78612 2.86628 5.99645 3.5514C6.0626 3.76685 6.1728 3.99252 6.34325 4.2241L7.12302 3.44433Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4434 11.9528C12.8956 11.9528 13.2622 11.5862 13.2622 11.134C13.2622 10.854 12.9483 10.3347 12.7092 9.9798C12.5801 9.78823 12.3066 9.78823 12.1776 9.97981C11.9385 10.3347 11.6246 10.854 11.6246 11.134C11.6246 11.5862 11.9912 11.9528 12.4434 11.9528Z"}}]}]},Si=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"paint-bucket",ref:e,icon:aa}))});Si.displayName="PaintBucket";const la=Si;var ca={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.80805 1.53809C2.10674 1.53809 1.53821 2.10661 1.53821 2.80793V13.6016C1.53821 14.3029 2.10674 14.8714 2.80805 14.8714H9.74456C10.2968 14.8714 10.7446 14.4237 10.7446 13.8714V13.6016V11.128C10.7446 10.9623 10.8789 10.828 11.0446 10.828H13.6017H13.8715C14.4238 10.828 14.8715 10.3803 14.8715 9.82802V2.80793C14.8715 2.10661 14.303 1.53809 13.6017 1.53809H2.80805ZM9.17472 13.6016C9.3404 13.6016 9.47472 13.4673 9.47472 13.3016V11.128C9.47472 10.9623 9.3404 10.828 9.17472 10.828H6.91757C6.75189 10.828 6.61757 10.9623 6.61757 11.128V13.3016C6.61757 13.4673 6.75189 13.6016 6.91757 13.6016H9.17472ZM13.6017 9.25817C13.6017 9.42386 13.4674 9.55818 13.3017 9.55818H11.0446C10.8789 9.55818 10.7446 9.42386 10.7446 9.25818V7.17177C10.7446 7.00608 10.8789 6.87177 11.0446 6.87177H13.3017C13.4674 6.87177 13.6017 7.00608 13.6017 7.17177V9.25817ZM9.17472 9.55818C9.3404 9.55818 9.47472 9.42386 9.47472 9.25818V7.17177C9.47472 7.00608 9.3404 6.87177 9.17472 6.87177H6.91757C6.75189 6.87177 6.61757 7.00608 6.61757 7.17177V9.25817C6.61757 9.42386 6.75189 9.55818 6.91757 9.55818H9.17472ZM13.6017 5.30193C13.6017 5.46761 13.4674 5.60193 13.3017 5.60193H11.0446C10.8789 5.60193 10.7446 5.46761 10.7446 5.30193V3.10793C10.7446 2.94224 10.8789 2.80793 11.0446 2.80793H13.3017C13.4674 2.80793 13.6017 2.94224 13.6017 3.10793V5.30193ZM9.17472 5.60193C9.3404 5.60193 9.47472 5.46761 9.47472 5.30193V3.10793C9.47472 2.94224 9.3404 2.80793 9.17472 2.80793H6.91757C6.75189 2.80793 6.61757 2.94224 6.61757 3.10793V5.30193C6.61757 5.46761 6.75189 5.60193 6.91757 5.60193H9.17472ZM5.34773 3.10793C5.34773 2.94224 5.21342 2.80793 5.04773 2.80793H3.10805C2.94236 2.80793 2.80805 2.94224 2.80805 3.10793V5.30193C2.80805 5.46761 2.94236 5.60193 3.10805 5.60193H5.04773C5.21342 5.60193 5.34773 5.46761 5.34773 5.30193V3.10793ZM5.34773 7.17177C5.34773 7.00608 5.21342 6.87177 5.04773 6.87177H3.10805C2.94236 6.87177 2.80805 7.00608 2.80805 7.17177V9.25817C2.80805 9.42386 2.94236 9.55818 3.10805 9.55818H5.04773C5.21342 9.55818 5.34773 9.42386 5.34773 9.25818V7.17177ZM5.34773 11.128C5.34773 10.9623 5.21342 10.828 5.04773 10.828H3.10805C2.94236 10.828 2.80805 10.9623 2.80805 11.128V13.3016C2.80805 13.4673 2.94236 13.6016 3.10805 13.6016H5.04773C5.21342 13.6016 5.34773 13.4673 5.34773 13.3016V11.128Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.3869 12.1183C12.361 11.9546 12.5342 11.8323 12.6798 11.9114L14.9901 13.1655C15.1577 13.2565 15.1137 13.5049 14.932 13.5378C14.9212 13.5398 14.9102 13.5417 14.8996 13.5446L13.8966 13.8224L13.1603 14.7467C13.0651 14.9084 12.8197 14.8618 12.7904 14.6764L12.3869 12.1183Z"}}]},fi=U.forwardRef(function(o,e){return U.createElement(he,Object.assign({},o,{id:"select-range-single",ref:e,icon:ca}))});fi.displayName="SelectRangeSingle";const da=fi,ze={rangeSelector:"univer-range-selector",rangeSelectorEditor:"univer-range-selector-editor",rangeSelectorIcon:"univer-range-selector-icon",rangeSelectorActive:"univer-range-selector-active"};function ua(o){const{onChange:e,onActive:t}=o,[n,i]=U.useState(!1),r=U.useRef(null),s=F.useDependency(l.LocaleService),a=F.useDependency(p.SelectionManagerService);U.useEffect(()=>{var h;if(n){t(n);const _=a.selectionMoveEnd$.subscribe(f=>{const S=["A1","B2:C3","Sheet2!A1:B2","D10:E11,F1:G2,H3:I4"],I=Math.floor(Math.random()*S.length),C=S[I];r.current&&(r.current.innerHTML=C)});return document.addEventListener("click",c),()=>{document.removeEventListener("click",c),_.unsubscribe()}}e(((h=r.current)==null?void 0:h.innerHTML)||"")},[n]);function c(h){var I,C,M;if(((I=h.target)==null?void 0:I.closest('[data-range-selector="true"]'))||h.target===r.current)return;const f=(C=h.target)==null?void 0:C.closest(`.${ze.rangeSelector}`);(f==null?void 0:f.querySelector(`.${ze.rangeSelectorEditor}`))!==r.current&&(i(!1),(M=r.current)==null||M.blur())}function d(h){h.stopPropagation(),h.key==="Enter"&&(h.preventDefault(),h.currentTarget.blur(),i(!1))}function u(){i(!0)}function m(){var h;if(!n){(h=r.current)==null||h.focus();return}i(!n)}return g.jsxs("div",{className:n?`${ze.rangeSelector} ${ze.rangeSelectorActive}`:ze.rangeSelector,children:[g.jsx("div",{ref:r,className:ze.rangeSelectorEditor,contentEditable:!0,"data-placeholder":s.t("rangeSelector.placeholder"),onKeyDown:d,onFocus:u}),g.jsx(te.Tooltip,{title:s.t("rangeSelector.tooltip"),placement:"bottom",children:g.jsx("button",{className:ze.rangeSelectorIcon,onClick:m,children:g.jsx(da,{})})})]})}const Qn={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Zt=["零","一","二","三","四","五","六","七","八","九"],pi=["","万","亿","万亿","亿亿"],ha=["","十","百","千"],gi={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function Oe(o){if(!o)return 0;let e=0,t=0,n=0,i=!1;const r=o.split("");for(let s=0;s<r.length;s++){const a=Qn[r[s]];if(typeof a<"u")n=a,s===r.length-1&&(t+=n);else{const c=gi[r[s]],d=c.value;i=c.secUnit,i?(t=(t+n)*d,e+=t,t=0):t+=n*d,n=0}}return e+t}function ma(o){let e="",t="",n=0,i=!0;for(;o>0;){const r=o%10;r===0?i||(i=!0,t=Zt[r]+t):(i=!1,e=Zt[r],e+=ha[n],t=e+t),n++,o=Math.floor(o/10)}return t}function _a(o){let e=0,t="",n="",i=!1;if(o===0)return Zt[0];for(;o>0;){const r=o%1e4;i&&(n=Zt[0]+n),t=ma(r),t+=r!==0?pi[e]:pi[0],n=t+n,i=r<1e3&&r>0,o=Math.floor(o/1e4),e++}return n}function Sa(o){if(!o)return!1;let e=!0;if(o)if(o.length===1)o==="日"||o in Qn?e=!0:e=!1;else{const t=o.split("");for(let n=0;n<t.length;n++)if(!(t[n]in Qn||t[n]in gi)){e=!1;break}}return e}function Gt(o){if(!o)return{isExtendNumber:!1};const e=/0|([1-9]+[0-9]*)/g,t=e.test(o);if(t){const n=o.match(e);if(n&&n.length>0){const i=n[n.length-1],r=o.lastIndexOf(i),s=o.substr(0,r),a=o.substr(r+i.length);return{isExtendNumber:!0,matchTxt:Number(i),beforeTxt:s,afterTxt:a}}return{isExtendNumber:!1}}return{isExtendNumber:t}}function fa(o){let e;return o.length===2&&(o==="周一"||o==="周二"||o==="周三"||o==="周四"||o==="周五"||o==="周六"||o==="周日")?e=!0:e=!1,e}function pa(o){let e;return o.length===3&&(o==="星期一"||o==="星期二"||o==="星期三"||o==="星期四"||o==="星期五"||o==="星期六"||o==="星期日")?e=!0:e=!1,e}function ga(o,e){let t=0;for(let n=0;n<o.length&&o[n]<e;n++)t++;return t}function It(o){let e=!0;const t=o[1]-o[0];for(let n=1;n<o.length;n++)if(o[n]-o[n-1]!==t){e=!1;break}return e}function va(o,e,t){const n=[],i=Math.floor(e/o),r=e%o;let s=0;if(i>0){for(let a=0;a<i;a++)for(let c=0;c<t.length;c++)n[t[c]+a*o]=s,s++;for(let a=0;a<t.length&&t[a]<r;a++)n[t[a]+o*i]=s,s++}else for(let a=0;a<t.length&&t[a]<r;a++)n[t[a]]=s,s++;return n}function Xe(o,e){const t=[];for(let n=1;n<=e;n++){const i=(n-1)%o.length,r=l.Tools.deepClone(o[i]);t.push(r)}return t}function Ca(o,e){var n;const t=[];for(let i=1;i<=e;i++){const r=(i-1)%o.length,s={s:(n=o[r])==null?void 0:n.s};t.push(s)}return t}function Ia(o){let e=!0;const t=o[1]/o[0];for(let n=1;n<o.length;n++)if(o[n]/o[n-1]!==t){e=!1;break}return e}function ba(o){const e=[];for(let t=1;t<=o;t++)e.push(t);return e}function Ma(o,e,t){var r,s,a,c,d,u,m;const n=[],i=[];for(let h=0;h<o.length;h++)i.push(Number((r=o[h])==null?void 0:r.v));if(o.length>2&&Ia(i))for(let h=1;h<=e;h++){const _=(h-1)%o.length,f=l.Tools.deepClone(o[_]);let S;t===l.Direction.DOWN||t===l.Direction.RIGHT?S=Number((s=o[o.length-1])==null?void 0:s.v)*(Number((a=o[1])==null?void 0:a.v)/Number((c=o[0])==null?void 0:c.v))**h:(t===l.Direction.UP||t===l.Direction.LEFT)&&(S=Number((d=o[0])==null?void 0:d.v)/(Number((u=o[1])==null?void 0:u.v)/Number((m=o[0])==null?void 0:m.v))**h),f&&(f.v=S,n.push(f))}else{const h=ba(o.length);for(let _=1;_<=e;_++){const f=(_-1)%o.length,S=l.Tools.deepClone(o[f]);let I;t===l.Direction.DOWN||t===l.Direction.RIGHT?I=vi(o.length+_,i,h):I=vi(1-_,i,h),S&&(S.v=I,n.push(S))}}return n}function vi(o,e,t){function n(u){let m=0;for(let h=0;h<u.length;h++)m+=u[h];return m/u.length}const i=n(t),r=n(e);let s=0,a=0;for(let u=0;u<t.length;u++)s+=(t[u]-i)*(e[u]-r),a+=(t[u]-i)*(t[u]-i);let c;a===0?c=1:c=s/a;const d=r-c*i;return Math.round((d+c*o)*1e5)/1e5}function Ci(o,e,t){var r;const n=[],i=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=e;s++){const a=(s-1)%o.length,c=l.Tools.deepClone(o[a]),d=`${(r=o[o.length-1])==null?void 0:r.v}`,u=d==null?void 0:d.match(i),m=u==null?void 0:u[u.length-1],h=Math.abs(Number(m)+t*s);if(!d||!m)continue;const _=d.lastIndexOf(m),f=d.substr(0,_)+h.toString()+d.substr(_+m.length);c&&(c.v=f,n.push(c))}return n}function nt(o,e,t,n=0){var a,c;const i=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=i.length)return[];const r=i[n],s=[];for(let d=1;d<=e;d++){const u=(d-1)%o.length,m=l.Tools.deepClone(o[u]);let h=0;if(((a=o[o.length-1])==null?void 0:a.v)===r[0])h=7+t*d;else{const f=`${(c=o[o.length-1])==null?void 0:c.v}`;if(f){const S=f.substr(f.length-1,1);h=Oe(S)+t*d}}h<0&&(h=Math.ceil(Math.abs(h)/7)*7+h);const _=h%7;m&&(m.v=r[_],s.push(m))}return s}function Ii(o,e,t){var i;const n=[];for(let r=1;r<=e;r++){const s=(r-1)%o.length,a=l.Tools.deepClone(o[s]),c=`${(i=o[o.length-1])==null?void 0:i.v}`,d=Oe(c)+t*r;let u;d<=0?u="零":u=_a(d),a&&(a.v=u,n.push(a))}return n}const bt={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function Ra(o){let e=!1;return Object.keys(bt).forEach(t=>{bt[t].includes(o)&&(e=!0)}),e}function qn(o){let e="";const t=[];return Object.keys(bt).forEach(n=>{bt[n].includes(o)&&(e=n,t.push(...bt[n]))}),{name:e,series:t}}function bi(o,e,t,n){var s;const i=n.length,r=[];for(let a=1;a<=e;a++){const c=(a-1)%o.length,d=l.Tools.deepClone(o[c]),u=`${(s=o[o.length-1])==null?void 0:s.v}`,h=(n.indexOf(u)+t*a)%i;d&&(d.v=n[h],r.push(d))}return r}function wa(o,e){const t=[];let n;if(e.startRow<o.startRow)n=l.Direction.UP;else if(e.endRow>o.endRow)n=l.Direction.DOWN;else if(e.startColumn<o.startColumn)n=l.Direction.LEFT;else if(e.endColumn>o.endColumn)n=l.Direction.RIGHT;else return[];if(n===l.Direction.DOWN||n===l.Direction.UP){const i=o.endRow-o.startRow+1,r=e.endRow-e.startRow+1,s=r/i,a=r%i,c={startRow:0,startColumn:0,endRow:o.endRow-o.startRow,endColumn:o.endColumn-o.startColumn};if(n===l.Direction.DOWN){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:o.startRow+(d+1)*i,col:o.startColumn},relativeRange:c});a>0&&t.push({repeatStartCell:{row:o.startRow+(s+1)*i,col:o.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:a-1,endColumn:o.endColumn-o.startColumn}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:o.startRow-(d+1)*i,col:o.startColumn},relativeRange:c});a>0&&t.push({repeatStartCell:{row:o.startRow-(s+1)*i,col:o.startColumn},relativeRange:{startRow:i-a,endRow:i-1,startColumn:0,endColumn:o.endColumn-o.startColumn}})}}if(n===l.Direction.RIGHT||n===l.Direction.LEFT){const i=o.endColumn-o.startColumn+1,r=e.endColumn-e.startColumn+1,s=r/i,a=r%i,c={startRow:0,startColumn:0,endRow:o.endRow-o.startRow,endColumn:o.endColumn-o.startColumn};if(n===l.Direction.RIGHT){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:o.startRow,col:o.startColumn+(d+1)*i},relativeRange:c});a>0&&t.push({repeatStartCell:{row:o.startRow,col:o.startColumn+(s+1)*i},relativeRange:{startRow:0,startColumn:0,endRow:o.endRow-o.startRow,endColumn:a-1}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:o.startRow,col:o.startColumn-(d+1)*i},relativeRange:c});a>0&&t.push({repeatStartCell:{row:o.startRow,col:o.startColumn-(s+1)*i},relativeRange:{startRow:0,startColumn:i-a,endRow:o.endRow-o.startRow,endColumn:i-1}})}}return t}var ne=(o=>(o.NUMBER="number",o.DATE="date",o.EXTEND_NUMBER="extendNumber",o.CHN_NUMBER="chnNumber",o.CHN_WEEK2="chnWeek2",o.CHN_WEEK3="chnWeek3",o.LOOP_SERIES="loopSeries",o.FORMULA="formula",o.OTHER="other",o))(ne||{}),W=(o=>(o.COPY="0",o.SERIES="1",o.ONLY_FORMAT="2",o.NO_FORMAT="3",o))(W||{});const ya={type:ne.NUMBER,priority:1e3,match:o=>typeof(o==null?void 0:o.v)=="number"||!isNaN(Number(o==null?void 0:o.v)),isContinue:(o,e)=>o.type===ne.NUMBER,applyFunctions:{[W.SERIES]:(o,e,t)=>{const{data:n}=o;return(t===l.Direction.LEFT||t===l.Direction.UP)&&n.reverse(),Ma(n,e,t)}}},Mi={type:ne.OTHER,priority:0,match:()=>!0,isContinue:(o,e)=>o.type===ne.OTHER},Ta={type:ne.EXTEND_NUMBER,priority:900,match:o=>Gt(`${o==null?void 0:o.v}`||"").isExtendNumber,isContinue:(o,e)=>{var t;if(o.type===ne.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:i}=Gt(`${(t=o.cellData)==null?void 0:t.v}`||""),{beforeTxt:r,afterTxt:s}=Gt(`${e==null?void 0:e.v}`||"");if(n===r&&i===s)return!0}return!1},applyFunctions:{[W.SERIES]:(o,e,t)=>{var s;const{data:n}=o;let i;if(n.length===1)return i=t===l.Direction.DOWN||t===l.Direction.RIGHT?1:-1,Ci(n,e,i);const r=[];for(let a=0;a<n.length;a++){const c=`${(s=n[a])==null?void 0:s.v}`;c&&r.push(Number(Gt(c).matchTxt))}return(t===l.Direction.UP||t===l.Direction.LEFT)&&(n.reverse(),r.reverse()),It(r)?(i=r[1]-r[0],Ci(n,e,i)):Xe(n,e)}}},Ea={type:ne.CHN_NUMBER,priority:830,match:o=>!!Sa(`${o==null?void 0:o.v}`||""),isContinue:(o,e)=>o.type===ne.CHN_NUMBER,applyFunctions:{[W.SERIES]:(o,e,t)=>{var c,d,u;const{data:n}=o,i=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){const m=`${(c=n[0])==null?void 0:c.v}`;let h;return i?h=-1:h=1,m&&(m==="日"||Oe(m)<7)?nt(n,e,h):Ii(n,e,h)}let r=!1;for(let m=0;m<n.length;m++)if(((d=n[m])==null?void 0:d.v)==="日"){r=!0;break}const s=[];let a=0;for(let m=0;m<n.length;m++){const h=`${(u=n[m])==null?void 0:u.v}`;h==="日"?m===0?s.push(0):(a++,s.push(a*7)):r&&Oe(h)>0&&Oe(h)<7?s.push(Oe(h)+a*7):s.push(Oe(h))}if(i&&(n.reverse(),s.reverse()),It(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const h=s[1]-s[0];return nt(n,e,h)}const m=s[1]-s[0];return Ii(n,e,m)}return Xe(n,e)}}},Oa={type:ne.CHN_WEEK2,priority:820,match:o=>!!fa(`${o==null?void 0:o.v}`||""),isContinue:(o,e)=>o.type===ne.CHN_WEEK2,applyFunctions:{[W.SERIES]:(o,e,t)=>{var a;const{data:n}=o,i=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){let c;return i?c=-1:c=1,nt(n,e,c,1)}const r=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`,u=d==null?void 0:d.substr(d.length-1,1);d==="周日"?c===0?r.push(0):(s++,r.push(s*7)):r.push(Oe(u)+s*7)}if(i&&(n.reverse(),r.reverse()),It(r)){const c=r[1]-r[0];return nt(n,e,c,1)}return Xe(n,e)}}},xa={type:ne.CHN_WEEK3,priority:810,match:o=>pa(`${o==null?void 0:o.v}`||""),isContinue:(o,e)=>o.type===ne.CHN_WEEK3,applyFunctions:{[W.SERIES]:(o,e,t)=>{var a;const{data:n}=o,i=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){let c;return i?c=-1:c=1,nt(n,e,c,2)}const r=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?r.push(0):(s++,r.push(s*7)):r.push(Oe(u)+s*7)}}if(i&&(n.reverse(),r.reverse()),It(r)){const c=r[1]-r[0];return nt(n,e,c,2)}return Xe(n,e)}}},Pa={type:ne.LOOP_SERIES,priority:800,match:o=>Ra(`${o==null?void 0:o.v}`||""),isContinue:(o,e)=>{var t;return o.type===ne.LOOP_SERIES?qn(`${(t=o.cellData)==null?void 0:t.v}`||"").name===qn(`${e==null?void 0:e.v}`||"").name:!1},applyFunctions:{[W.SERIES]:(o,e,t)=>{var c,d;const{data:n}=o,i=t===l.Direction.LEFT||t===l.Direction.UP,{series:r}=qn(`${(c=n[0])==null?void 0:c.v}`||"");if(n.length===1){let u;return i?u=-1:u=1,bi(n,e,u,r)}const s=[];let a=0;for(let u=0;u<n.length;u++){const m=`${(d=n[u])==null?void 0:d.v}`;m&&(m===r[0]?u===0?s.push(0):(a++,s.push(a*r.length)):s.push(r.indexOf(m)+a*7))}if(i&&(n.reverse(),s.reverse()),It(s)){const u=s[1]-s[0];return bi(n,e,u,r)}return Xe(n,e)}}};var Aa=Object.defineProperty,ka=Object.getOwnPropertyDescriptor,Ha=(o,e,t,n)=>{for(var i=n>1?void 0:n?ka(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Aa(e,t,i),i},eo=(o,e)=>(t,n)=>e(t,n,o);k.AutoFillService=class extends l.Disposable{constructor(t,n,i){super();v(this,"_rules",[]);v(this,"_hooks",[]);v(this,"_applyType$",new V.BehaviorSubject(W.SERIES));v(this,"_isFillingStyle",!0);v(this,"_sourceRange",null);v(this,"_destRange",null);v(this,"_applyRange",null);v(this,"applyType$",this._applyType$.asObservable());v(this,"_menu$",new V.BehaviorSubject([{label:"autoFill.copy",value:W.COPY,disable:!1},{label:"autoFill.series",value:W.SERIES,disable:!1},{label:"autoFill.formatOnly",value:W.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:W.NO_FORMAT,disable:!1}]));v(this,"menu$",this._menu$.asObservable());this._sheetInterceptorService=t,this._univerInstanceService=n,this._selectionManagerService=i,this._init()}_init(){this._rules=[ya,Ta,Ea,Oa,xa,Pa,Mi].sort((t,n)=>n.priority-t.priority),this._isFillingStyle=!0}addHook(t){if(this._hooks.find(n=>n.hookName===t.hookName))throw new Error(`Add hook failed, hook name '${t.hookName}' already exist!`);return this._hooks.push(t),l.toDisposable(()=>{const n=this._hooks.findIndex(i=>i===t);n>-1&&this._hooks.splice(n,1)})}registerRule(t){if(this._rules.find(i=>i.type===t.type))throw new Error(`Registry rule failed, type '${t.type}' already exist!`);const n=this._rules.findIndex(i=>i.priority<t.priority);this._rules.splice(n===-1?this._rules.length:n,0,t)}getRules(){return this._rules}getHooks(){return this._hooks}getApplyType(){return this._applyType$.getValue()}setApplyType(t){this._applyType$.next(t)}isFillingStyle(){return this._isFillingStyle}setFillingStyle(t){this._isFillingStyle=t}setRanges(t,n,i){this._sourceRange=n,this._destRange=t,this._applyRange=i}getRanges(){return{sourceRange:this._sourceRange,destRange:this._destRange,applyRange:this._applyRange}}setDisableApplyType(t,n){this._menu$.next(this._menu$.getValue().map(i=>i.value===t?{...i,disable:n}:i))}},k.AutoFillService=Ha([l.OnLifecycle(l.LifecycleStages.Rendered,k.AutoFillService),eo(0,L.Inject(p.SheetInterceptorService)),eo(1,L.Inject(l.IUniverInstanceService)),eo(2,L.Inject(p.SelectionManagerService))],k.AutoFillService);const Mt=L.createIdentifier("univer.auto-fill-service");var Da=Object.defineProperty,La=Object.getOwnPropertyDescriptor,Na=(o,e,t,n)=>{for(var i=n>1?void 0:n?La(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Da(e,t,i),i},Rt=(o,e)=>(t,n)=>e(t,n,o);k.AutoFillController=class extends l.Disposable{constructor(t,n,i,r,s){super();v(this,"_direction",null);v(this,"_beforeApplyData",[]);v(this,"_applyType",W.SERIES);v(this,"_hasFillingStyle",!0);v(this,"_copyData",[]);this._univerInstanceService=t,this._selectionRenderService=n,this._commandService=i,this._autoFillService=r,this._selectionManagerService=s,this._init()}_init(){this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),[Vt,Ft].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_handleDbClickFill(t){const n=this._detectFillRange(t);n.endRow<=t.endRow||this._handleFill(t,n)}_detectFillRange(t){var h,_,f,S,I,C;const{startRow:n,endRow:i,startColumn:r,endColumn:s}=t,a=(h=this._univerInstanceService.getCurrentUniverSheetInstance())==null?void 0:h.getActiveSheet();if(!a)return t;const c=a.getCellMatrix(),d=a.getMaxRows()-1,u=a.getMaxColumns()-1;let m=i;if(r>0&&((_=c.getValue(n,r-1))==null?void 0:_.v)!=null){let M=n;for(;((f=c.getValue(M,r-1))==null?void 0:f.v)!=null&&M<d;)M+=1;m=M}else if(s<u&&((S=c.getValue(i,s+1))==null?void 0:S.v)!=null){let M=n;for(;((I=c.getValue(M,s+1))==null?void 0:I.v)!=null&&M<d;)M++;m=M}for(let M=i+1;M<=m;M++)for(let R=r;R<=s;R++)if(((C=c.getValue(M,R))==null?void 0:C.v)!=null){m=M-1;break}return{startColumn:r,endColumn:s,startRow:n,endRow:m}}_handleFill(t,n){if(!(t.startColumn===n.startColumn&&t.startRow===n.startRow&&t.endColumn===n.endColumn&&t.endRow===n.endRow)){if(n.endColumn<t.endColumn&&n.endColumn>t.startColumn){this._commandService.executeCommand(Ft.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:t.endColumn},selectionRange:n});return}if(n.endRow<t.endRow&&n.endRow>t.startRow){this._commandService.executeCommand(Ft.id,{clearRange:{startRow:n.endRow+1,endRow:t.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}this._presetAndCacheData(t,n)}}_onSelectionControlFillChanged(){const t=new l.DisposableCollection;this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{t.dispose();const n=this._selectionManagerService.getCurrent();if((n==null?void 0:n.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(r=>{t.add(l.toDisposable(r.selectionFilled$.subscribe(s=>{if(s==null)return;const a={startColumn:r.model.startColumn,endColumn:r.model.endColumn,startRow:r.model.startRow,endRow:r.model.endRow},c={startColumn:s.startColumn,endColumn:s.endColumn,startRow:s.startRow,endRow:s.endRow};this._handleFill(a,c)}))),t.add(l.toDisposable(r.fillControl.onDblclickObserver.add(()=>{const s={startColumn:r.model.startColumn,endColumn:r.model.endColumn,startRow:r.model.startRow,endRow:r.model.endRow};this._handleDbClickFill(s)})))})})))}_onApplyTypeChanged(){this.disposeWithMe(l.toDisposable(this._autoFillService.applyType$.subscribe(t=>{t===W.NO_FORMAT?(this._applyType=W.SERIES,this._hasFillingStyle=!1):(this._applyType=t||W.SERIES,this._hasFillingStyle=!0),this._fillData()})))}_getApplyData(t,n,i,r,s,a=!0){const c=[],d=Math.floor(i/n),u=i%n,m=this._autoFillService.getRules();if(!a&&s===W.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const h={};m.forEach(_=>{h[_.type]=[]}),m.forEach(_=>{const{type:f,applyFunctions:S={}}=_,I=t[f];I&&I.forEach(C=>{const M=ga(C.index,u),R=C.index.length*d+M,y=this._applyFunctions(C,R,r,s,S,t),T=va(n,i,C.index);h[f].push({data:y,index:T})})});for(let _=0;_<i;_++)m.forEach(f=>{const{type:S}=f,I=h[S];for(let C=0;C<I.length;C++)_ in I[C].index&&c.push(I[C].data[I[C].index[_]])});return c}_applyFunctions(t,n,i,r,s,a){const{data:c}=t,d=i===l.Direction.UP||i===l.Direction.LEFT;if(r===W.COPY){const u=s==null?void 0:s[W.COPY];return u?u(t,n,i,a):(d&&c.reverse(),Xe(c,n))}if(r===W.SERIES){const u=s==null?void 0:s[W.SERIES];return u?u(t,n,i,a):(d&&c.reverse(),s!=null&&s[W.COPY]?s[W.COPY](t,n,i,a):Xe(c,n))}if(r===W.ONLY_FORMAT){const u=s==null?void 0:s[W.ONLY_FORMAT];return u?u(t,n,i,a):Ca(c,n)}}_getCopyData(t,n){const{startRow:i,startColumn:r,endRow:s,endColumn:a}=t,c=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),d=this._autoFillService.getRules(),u=[],m=n===l.Direction.DOWN||n===l.Direction.UP;let h,_,f,S;m?(h=r,_=a,f=i,S=s):(h=i,_=s,f=r,S=a);for(let I=h;I<=_;I++){const C=this._getEmptyCopyDataPiece(),M={type:void 0,cellData:void 0};for(let R=f;R<=S;R++){let y;m?y=c.getValue(R,I):y=c.getValue(I,R);const{type:T,isContinue:E}=d.find(O=>O.match(y))||Mi;if(E(M,y)){const O=C[T],x=O[O.length-1];x.data.push(y),x.index.push(R-f)}else{const O=C[T];O?O.push({data:[y],index:[R-f]}):C[T]=[{data:[y],index:[R-f]}]}M.type=T,M.cellData=y}u.push(C)}return u}_getEmptyCopyDataPiece(){const t={};return this._autoFillService.getRules().forEach(n=>{t[n.type]=[]}),t}_getMergeApplyData(t,n,i,r){const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),a=[];for(let c=t.startRow;c<=t.endRow;c++)for(let d=t.startColumn;d<=t.endColumn;d++){const{isMergedMainCell:u,startRow:m,startColumn:h,endRow:_,endColumn:f}=w.getCellInfoInMergeData(c,d,s);if(u){if(i===l.Direction.DOWN){let S=m+r,I=_+r;for(;I<=n.endRow;)a.push({startRow:S,startColumn:h,endRow:I,endColumn:f}),S+=r,I+=r}else if(i===l.Direction.UP){let S=m-r,I=_-r;for(;S>=n.startRow;)a.push({startRow:S,startColumn:h,endRow:I,endColumn:f}),S-=r,I-=r}else if(i===l.Direction.RIGHT){let S=h+r,I=f+r;for(;I<=n.endColumn;)a.push({startRow:m,startColumn:S,endRow:_,endColumn:I}),S+=r,I+=r}else if(i===l.Direction.LEFT){const S=h-r,I=f-r;for(;S>=n.startColumn;)a.push({startRow:m,startColumn:S,endRow:_,endColumn:I})}}}return a}_presetAndCacheData(t,n){const i={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let r=null;if(n.startRow<t.startRow)r=l.Direction.UP,i.endRow=t.startRow-1;else if(n.endRow>t.endRow)r=l.Direction.DOWN,i.startRow=t.endRow+1;else if(n.startColumn<t.startColumn)r=l.Direction.LEFT,i.endColumn=t.startColumn-1;else if(n.endColumn>t.endColumn)r=l.Direction.RIGHT,i.startColumn=t.endColumn+1;else return;this._direction=r;const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),a=[];for(let c=i.startRow;c<=i.endRow;c++){const d=[];for(let u=i.startColumn;u<=i.endColumn;u++)d.push(l.Tools.deepClone(s.getValue(c,u)));a.push(d)}this._beforeApplyData=a,this._autoFillService.setRanges(n,t,i),this._copyData=this._getCopyData(t,r),this._hasSeries(this._copyData)?(this._autoFillService.setDisableApplyType(W.SERIES,!1),this._autoFillService.setApplyType(W.SERIES)):(this._autoFillService.setDisableApplyType(W.SERIES,!0),this._autoFillService.setApplyType(W.COPY))}_fillData(){const{destRange:t,sourceRange:n,applyRange:i}=this._autoFillService.getRanges(),r=this._applyType,s=this._hasFillingStyle,a=this._direction;if(!t||!n||!i||a==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:m}=n,{startRow:h,startColumn:_,endRow:f,endColumn:S}=i,I=this._copyData;let C;a===l.Direction.DOWN||a===l.Direction.UP?C=u-c+1:C=m-d+1;const M=[];if(a===l.Direction.DOWN||a===l.Direction.UP){const P=f-h+1,H=[];for(let A=_;A<=S;A++){const D=I[A-_],N=this._getApplyData(D,C,P,a,r,s);H.push(N)}for(let A=0;A<H[0].length;A++){const D=[];for(let N=0;N<H.length;N++)D.push({v:null,s:null,...this._beforeApplyData[A][N],...H[N][A]});M.push(D)}}else{const P=S-_+1;for(let H=h;H<=f;H++){const A=I[H-h],D=this._getApplyData(A,C,P,a,r,s),N=[];for(let B=0;B<D.length;B++)N.push({v:null,s:null,...this._beforeApplyData[H-h][B],...D[B]});M.push(N)}}let R;const y=this._univerInstanceService.getCurrentUniverSheetInstance().getStyles();s?(R=this._getMergeApplyData(n,t,a,C),M.forEach(P=>{P.forEach(H=>{H&&y&&y&&(H.s=y.getStyleByCell(H))})})):M.forEach((P,H)=>{P.forEach((A,D)=>{A&&y&&(A.s=y.getStyleByCell(this._beforeApplyData[H][D])||null)})});const T=this._autoFillService.getHooks(),E=[],O=[],x=this._hasFillingStyle?r:W.NO_FORMAT;T.forEach(P=>{const{hook:H}=P,{redos:A,undos:D}=H==null?void 0:H[x](n,i);E.push(...A),O.push(...D)}),this._commandService.executeCommand(Vt.id,{selectionRange:t,applyRange:i,applyDatas:M,workbookId:this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),worksheetId:this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),extendMutations:{undo:O,redo:E},applyMergeRanges:R})}_hasSeries(t){return t.some(n=>Object.keys(n).some(r=>{var s;return!!((s=n[r])!=null&&s.length&&![ne.OTHER,ne.FORMULA].includes(r))}))}},k.AutoFillController=Na([l.OnLifecycle(l.LifecycleStages.Steady,k.AutoFillController),Rt(0,l.IUniverInstanceService),Rt(1,ae),Rt(2,l.ICommandService),Rt(3,Mt),Rt(4,L.Inject(p.SelectionManagerService))],k.AutoFillController);const Ri={type:l.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async o=>{const e=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(Z.SetInlineFormatBoldCommand.id):e.executeCommand(p.SetBoldCommand.id)}},wi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async o=>{const e=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(Z.SetInlineFormatItalicCommand.id):e.executeCommand(p.SetItalicCommand.id)}},yi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async o=>{const e=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(Z.SetInlineFormatUnderlineCommand.id):e.executeCommand(p.SetUnderlineCommand.id)}},Ti={type:l.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async o=>{const e=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(Z.SetInlineFormatStrikethroughCommand.id):e.executeCommand(p.SetStrikeThroughCommand.id)}},Ei={type:l.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(o,e)=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(Z.SetInlineFormatFontSizeCommand.id,e):t.executeCommand(p.SetFontSizeCommand.id,e)}},Oi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(o,e)=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(Z.SetInlineFormatFontFamilyCommand.id,e):t.executeCommand(p.SetFontFamilyCommand.id,e)}},Kt={type:l.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(o,e)=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(Z.SetInlineFormatTextColorCommand.id,e):t.executeCommand(p.SetTextColorCommand.id,e)}};function xi(o,e){return e.some(t=>Ua(o,t))}function Ua(o,e){const{startRow:t,startColumn:n,endColumn:i,endRow:r}=e,s=o.getMatrixWithMergedCells(t,n,r,i);let a=!1;return s.forValue((c,d,u)=>{if(u&&(c!==t||d!==n)&&o.cellHasValue(u))return a=!0,!1}),a}function Pi(o,e,t,n){const i=[],r=[],s=t.getSheetId();return n.forEach(a=>{const c=Ba(t,a),d={workbookId:e,worksheetId:s,cellValue:c.getData()},u=p.SetRangeValuesUndoMutationFactory(o,d);i.push({id:p.SetRangeValuesMutation.id,params:u}),r.push({id:p.SetRangeValuesMutation.id,params:d})}),{undos:i,redos:r}}function Ba(o,e){const{startRow:t,startColumn:n,endColumn:i,endRow:r}=e,s=o.getMatrixWithMergedCells(t,n,r,i),a=new l.ObjectMatrix;return s.forValue((c,d,u)=>{u&&(c!==t||d!==n)&&a.setValue(c,d,null)}),a}var Va=Object.defineProperty,Fa=Object.getOwnPropertyDescriptor,ja=(o,e,t,n)=>{for(var i=n>1?void 0:n?Fa(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Va(e,t,i),i},to=(o,e)=>(t,n)=>e(t,n,o),fe=(o=>(o[o.OFF=0]="OFF",o[o.ONCE=1]="ONCE",o[o.INFINITE=2]="INFINITE",o))(fe||{});const ot=L.createIdentifier("univer.format-painter-service");let no=class extends l.Disposable{constructor(e,t,n){super();v(this,"status$");v(this,"_selectionFormat");v(this,"_markId",null);v(this,"_status$");this._selectionManagerService=e,this._univerInstanceService=t,this._markSelectionService=n,this._status$=new V.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new l.ObjectMatrix,merges:[]}}setStatus(e){e!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(e),this._status$.next(e)}getStatus(){return this._status$.getValue()}_updateRangeMark(e){if(this._markSelectionService.removeAllShapes(),this._markId=null,e!==0){const t=this._selectionManagerService.getLast();if(t){const n=this._selectionManagerService.createCopyPasteSelection();this._markId=this._markSelectionService.addShape({...t,style:n})}}}_getSelectionRangeFormat(){const e=this._selectionManagerService.getLast(),t=e==null?void 0:e.range;if(!t)return;const{startRow:n,endRow:i,startColumn:r,endColumn:s}=t,a=this._univerInstanceService.getCurrentUniverSheetInstance(),d=(a==null?void 0:a.getActiveSheet()).getCellMatrix(),u=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),m=a.getStyles(),h=new l.ObjectMatrix;for(let _=n;_<=i;_++)for(let f=r;f<=s;f++){const S=d.getValue(_,f);h.setValue(_,f,m.getStyleByCell(S)||{});const{isMergedMainCell:I,...C}=w.getCellInfoInMergeData(_,f,u);I&&this._selectionFormat.merges.push({startRow:C.startRow,startColumn:C.startColumn,endRow:C.endRow,endColumn:C.endColumn})}this._selectionFormat.styles=h}getSelectionFormat(){return this._selectionFormat}};no=ja([to(0,L.Inject(p.SelectionManagerService)),to(1,l.IUniverInstanceService),to(2,zt)],no);const oo={id:"sheet.operation.set-format-painter",type:l.CommandType.OPERATION,handler:(o,e)=>e?(o.get(ot).setStatus(e.status),!0):!1},Ai={type:l.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async o=>{const t=o.get(ot).getStatus();let n;return t!==fe.OFF?n=fe.OFF:n=fe.INFINITE,o.get(l.ICommandService).executeCommand(oo.id,{status:n})}},io={type:l.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async o=>{const t=o.get(ot).getStatus();let n;return t!==fe.OFF?n=fe.OFF:n=fe.ONCE,o.get(l.ICommandService).executeCommand(oo.id,{status:n})}},ki={type:l.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(o,e)=>{const t=o.get(l.ICommandService),n=o.get(l.IUndoRedoService),i=o.get(l.IUniverInstanceService),r=o.get(p.SelectionManagerService),s=o.get(p.SheetInterceptorService),{styleValues:a,styleRange:c,mergeRanges:d,workbookId:u=i.getCurrentUniverSheetInstance().getUnitId(),worksheetId:m=i.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=e,h=c?[c]:r.getSelectionRanges();if(!h||!h.length)return!1;const _=new l.ObjectMatrix;let f;if(l.Tools.isArray(a))for(let B=0;B<h.length;B++){const{startRow:$,startColumn:z,endRow:J,endColumn:G}=h[B];for(let Q=0;Q<=J-$;Q++)for(let j=0;j<=G-z;j++)_.setValue(Q+$,j+z,a[Q][j])}else if(l.isICellData(a))for(let B=0;B<h.length;B++){const{startRow:$,startColumn:z}=h[B];_.setValue($,z,a)}else f=a;const S={worksheetId:m,workbookId:u,cellValue:f??_.getMatrix()},I=p.SetRangeValuesUndoMutationFactory(o,S);if(!s.fetchThroughInterceptors(p.INTERCEPTOR_POINT.PERMISSION)(null,{id:p.SetRangeValuesCommand.id,params:S}))return!1;const C=t.syncExecuteCommand(p.SetRangeValuesMutation.id,S),{undos:M,redos:R}=s.onCommandExecute({id:p.SetRangeValuesCommand.id,params:{...S,range:h}}),y=p.getAddMergeMutationRangeByType(d),T=i.getUniverSheetInstance(u).getSheetBySheetId(m),E=[],O=[],x=xi(T,y),P={workbookId:u,worksheetId:m,ranges:y},H={workbookId:u,worksheetId:m,ranges:y};E.push({id:p.RemoveWorksheetMergeMutation.id,params:P}),E.push({id:p.AddWorksheetMergeMutation.id,params:H});const A=p.RemoveMergeUndoMutationFactory(o,P),D=p.AddMergeUndoMutationFactory(o,H);if(O.push({id:p.RemoveWorksheetMergeMutation.id,params:D}),O.push({id:p.AddWorksheetMergeMutation.id,params:A}),x){const B=Pi(o,u,T,y);E.unshift(...B.redos),O.push(...B.undos)}const N=await l.sequenceExecute([...R,...E],t);return C&&N.result?(n.pushUndoRedo({unitID:u,undoMutations:[{id:p.SetRangeValuesMutation.id,params:I},...M,...O],redoMutations:[{id:p.SetRangeValuesMutation.id,params:S},...R,...E]}),!0):!1}},Jt={type:l.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(o,e)=>{const{type:t}=e||{},n=o.get(l.IUniverInstanceService),i=o.get(l.IUndoRedoService),r=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),a=o.get(l.ICommandService),d=o.get(p.SelectionManagerService).getSelections();if(!d)return!1;const u=d[(d==null?void 0:d.length)-1],{range:m}=u,h=o.get(Ne),{sheetViewStartRow:_=0,sheetViewStartColumn:f=0}=h.getCurrentScroll()||{};let S,I,C,M;const{startRow:R,startColumn:y,rangeType:T}=m;if(T===l.RANGE_TYPE.ROW||t===1)S=R,C=R-_,I=-1,M=0;else if(T===l.RANGE_TYPE.COLUMN||t===2)S=-1,C=0,I=y,M=y-f;else if(T===l.RANGE_TYPE.NORMAL)S=R,C=R-_,I=y,M=y-f;else return!1;const E={workbookId:r,worksheetId:s,startRow:S,startColumn:I,xSplit:M,ySplit:C},O=p.SetFrozenMutationFactory(o,E);return a.syncExecuteCommand(p.SetFrozenMutation.id,E)&&i.pushUndoRedo({unitID:r,undoMutations:[{id:p.SetFrozenMutation.id,params:O}],redoMutations:[{id:p.SetFrozenMutation.id,params:E}]}),!0}},Hi={type:l.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async o=>(o.get(l.ICommandService).executeCommand(Jt.id,{type:1}),!0)},Di={type:l.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async o=>(o.get(l.ICommandService).executeCommand(Jt.id,{type:2}),!0)},Li={type:l.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async o=>{const e=o.get(l.ICommandService),t=o.get(l.IUniverInstanceService),n=o.get(l.IUndoRedoService),i=t.getCurrentUniverSheetInstance().getUnitId(),r=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s={workbookId:i,worksheetId:r,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},a=p.SetFrozenMutationFactory(o,s);return e.syncExecuteCommand(p.SetFrozenMutation.id,s)&&n.pushUndoRedo({unitID:i,undoMutations:[{id:p.SetFrozenMutation.id,params:a}],redoMutations:[{id:p.SetFrozenMutation.id,params:s}]}),!0}},it="UI_PLUGIN_SHEETS",Qt=`${it}_COLOR_PICKER_COMPONENT`,Ni={uiPluginSheetsFontFamily:"univer-ui-plugin-sheets-font-family",uiPluginSheetsFontFamilyItem:"univer-ui-plugin-sheets-font-family-item"},Wa=o=>{const{value:e}=o,t=F.useDependency(l.LocaleService);return g.jsx("div",{className:Ni.uiPluginSheetsFontFamily,style:{fontFamily:e},children:t.t(`fontFamily.${(`${e}`??"").replace(/\s/g,"")}`)})},za=o=>{const{value:e}=o,t=F.useDependency(l.LocaleService);return g.jsx("span",{className:Ni.uiPluginSheetsFontFamilyItem,style:{fontFamily:e},children:t.t(`fontFamily.${(`${e}`??"").replace(/\s/g,"")}`)})},Ui=`${it}_FONT_FAMILY_COMPONENT`,le=`${it}_FONT_FAMILY_ITEM_COMPONENT`,Bi={uiPluginSheetsFontSize:"univer-ui-plugin-sheets-font-size",uiPluginSheetsFontSizeInput:"univer-ui-plugin-sheets-font-size-input"},Xa=o=>{const{value:e,min:t,max:n,onChange:i}=o,[r,s]=U.useState(Number(e??0)),a=U.useMemo(()=>Number(e??r),[e]);function c(u){u!==null&&s(u)}function d(u){u.stopPropagation(),u.code==="Enter"&&i(r.toString())}return g.jsx("div",{className:Bi.uiPluginSheetsFontSize,children:g.jsx(te.InputNumber,{className:Bi.uiPluginSheetsFontSizeInput,value:a,controls:!1,min:t,max:n,onKeyDown:d,onChange:c})})},Vi=`${it}_FONT_SIZE_COMPONENT`,ro=`${it}_MENU_ITEM_INPUT_COMPONENT`,Fi={uiPluginSheetsContextMenuInput:"univer-ui-plugin-sheets-context-menu-input",uiPluginSheetsContextMenuInputContainer:"univer-ui-plugin-sheets-context-menu-input-container"},Ya=o=>{const{prefix:e,suffix:t,value:n,onChange:i}=o,r=F.useDependency(l.LocaleService),[s,a]=U.useState(),c=u=>{a(u==null?void 0:u.toString()),i((u==null?void 0:u.toString())??"")};U.useEffect(()=>{a(n)},[n]);function d(u){u.key==="Backspace"&&u.stopPropagation()}return g.jsxs("div",{className:Fi.uiPluginSheetsContextMenuInput,children:[r.t(e),g.jsx("span",{className:Fi.uiPluginSheetsContextMenuInputContainer,onClick:u=>u.stopPropagation(),children:g.jsx(te.InputNumber,{value:Number(s),precision:0,onKeyDown:d,onChange:c})}),r.t(t)]})};var q=(o=>(o.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",o.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",o.SHEET_BAR="sheetBar",o))(q||{});function $a(o){const e=o.get(ot);return{id:io.id,subId:Ai.id,group:b.MenuGroup.TOOLBAR_FORMAT,type:b.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[b.MenuPosition.TOOLBAR_START],activated$:new V.Observable(t=>{let n=!1;const i=e.status$.subscribe(r=>{n=r!==fe.OFF,t.next(n)});return t.next(n),()=>{i.unsubscribe()}})}}function Za(o){const e=o.get(l.ICommandService),t=o.get(p.SheetPermissionService),n=o.get(l.IUniverInstanceService),i=o.get(p.SelectionManagerService),r=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:Ri.id,group:b.MenuGroup.TOOLBAR_FORMAT,type:b.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[b.MenuPosition.TOOLBAR_START],disabled$:new V.Observable(a=>{var d;const c=(d=t.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new V.Observable(a=>{const c=e.onCommandExecuted(d=>{var f;const u=d.id;if(u!==p.SetRangeValuesMutation.id&&u!==p.SetSelectionsOperation.id)return;const m=(f=i.getLast())==null?void 0:f.primary,h=n.getCurrentUniverSheetInstance().getActiveSheet();let _=l.FontWeight.NORMAL;if(m!=null){const S=h.getRange(m.startRow,m.startColumn);_=S==null?void 0:S.getFontWeight()}a.next(_===l.FontWeight.BOLD)});return a.next(!1),c.dispose})}}function Ga(o){const e=o.get(l.ICommandService),t=o.get(l.IUniverInstanceService),n=o.get(p.SelectionManagerService),i=o.get(p.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:wi.id,group:b.MenuGroup.TOOLBAR_FORMAT,type:b.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[b.MenuPosition.TOOLBAR_START],disabled$:new V.Observable(a=>{var d;const c=(d=i.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new V.Observable(a=>{const c=e.onCommandExecuted(d=>{var f;const u=d.id;if(u!==p.SetRangeValuesMutation.id&&u!==p.SetSelectionsOperation.id)return;const m=(f=n.getLast())==null?void 0:f.primary,h=t.getCurrentUniverSheetInstance().getActiveSheet();let _=l.FontItalic.NORMAL;if(m!=null){const S=h.getRange(m.startRow,m.startColumn);_=S==null?void 0:S.getFontStyle()}a.next(_===l.FontItalic.ITALIC)});return a.next(!1),c.dispose})}}function Ka(o){const e=o.get(l.ICommandService),t=o.get(l.IUniverInstanceService),n=o.get(p.SelectionManagerService),i=o.get(p.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:yi.id,group:b.MenuGroup.TOOLBAR_FORMAT,type:b.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[b.MenuPosition.TOOLBAR_START],disabled$:new V.Observable(a=>{var d;const c=(d=i.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new V.Observable(a=>{const c=e.onCommandExecuted(d=>{var f;const u=d.id;if(u!==p.SetRangeValuesMutation.id&&u!==p.SetSelectionsOperation.id)return;const m=(f=n.getLast())==null?void 0:f.primary,h=t.getCurrentUniverSheetInstance().getActiveSheet();let _;if(m!=null){const S=h.getRange(m.startRow,m.startColumn);_=S==null?void 0:S.getUnderline()}a.next(!!(_&&_.s))});return a.next(!1),c.dispose})}}function Ja(o){const e=o.get(l.ICommandService),t=o.get(l.IUniverInstanceService),n=o.get(p.SelectionManagerService),i=o.get(p.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:Ti.id,group:b.MenuGroup.TOOLBAR_FORMAT,type:b.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[b.MenuPosition.TOOLBAR_START],disabled$:new V.Observable(a=>{var d;const c=(d=i.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new V.Observable(a=>{const c=e.onCommandExecuted(d=>{var f;const u=d.id;if(u!==p.SetRangeValuesMutation.id&&u!==p.SetSelectionsOperation.id)return;const m=(f=n.getLast())==null?void 0:f.primary,h=t.getCurrentUniverSheetInstance().getActiveSheet();let _;if(m!=null){const S=h.getRange(m.startRow,m.startColumn);_=S==null?void 0:S.getStrikeThrough()}a.next(!!(_&&_.s))});return a.next(!1),c.dispose})}}const Qa=[{label:"9",value:9},{label:"10",value:10},{label:"11",value:11},{label:"12",value:12},{label:"14",value:14},{label:"16",value:16},{label:"18",value:18},{label:"20",value:20},{label:"22",value:22},{label:"24",value:24},{label:"26",value:26},{label:"28",value:28},{label:"36",value:36},{label:"48",value:48},{label:"72",value:72}],ji=[{label:le,value:"Times New Roman"},{label:le,value:"Arial"},{label:le,value:"Tahoma"},{label:le,value:"Verdana"},{label:le,value:"Microsoft YaHei"},{label:le,value:"SimSun"},{label:le,value:"SimHei"},{label:le,value:"Kaiti"},{label:le,value:"FangSong"},{label:le,value:"NSimSun"},{label:le,value:"STXinwei"},{label:le,value:"STXingkai"},{label:le,value:"STLiti"}];function qa(o){const e=o.get(l.ICommandService),t=o.get(l.IUniverInstanceService),n=o.get(p.SelectionManagerService),i=o.get(p.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:Oi.id,tooltip:"toolbar.font",group:b.MenuGroup.TOOLBAR_FORMAT,type:b.MenuItemType.SELECTOR,label:Ui,positions:[b.MenuPosition.TOOLBAR_START],selections:ji,disabled$:new V.Observable(a=>{var d;const c=(d=i.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),value$:new V.Observable(a=>{const c=ji[0].value,d=e.onCommandExecuted(u=>{var S;const m=u.id;if(m!==p.SetRangeValuesMutation.id&&m!==p.SetSelectionsOperation.id)return;const h=(S=n.getLast())==null?void 0:S.primary,_=t.getCurrentUniverSheetInstance().getActiveSheet();let f;if(h!=null){const I=_.getRange(h.startRow,h.startColumn);f=I==null?void 0:I.getFontFamily()}a.next(f??c)});return a.next(c),d.dispose})}}function el(o){const e=o.get(l.ICommandService),t=o.get(l.IUniverInstanceService),n=o.get(p.SelectionManagerService),i=o.get(p.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:Ei.id,group:b.MenuGroup.TOOLBAR_FORMAT,type:b.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Vi,props:{min:1,max:400}},positions:[b.MenuPosition.TOOLBAR_START],selections:Qa,disabled$:new V.Observable(a=>{var d;const c=(d=i.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),value$:new V.Observable(a=>{const d=e.onCommandExecuted(u=>{var S;const m=u.id;if(m!==p.SetRangeValuesMutation.id&&m!==p.SetSelectionsOperation.id)return;const h=(S=n.getLast())==null?void 0:S.primary,_=t.getCurrentUniverSheetInstance().getActiveSheet();let f;if(h!=null){const I=_.getRange(h.startRow,h.startColumn);f=I==null?void 0:I.getFontSize()}a.next(f??14)});return a.next(14),d.dispose})}}function tl(){return{id:p.ResetTextColorCommand.id,type:b.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:Kt.id}}function nl(o){const e=o.get(l.ICommandService),t=o.get(l.ThemeService);return{id:Kt.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:b.MenuGroup.TOOLBAR_FORMAT,type:b.MenuItemType.BUTTON_SELECTOR,positions:[b.MenuPosition.TOOLBAR_START],selections:[{label:{name:Qt,hoverable:!1}}],value$:new V.Observable(n=>{const i=t.getCurrentTheme().textColor,r=e.onCommandExecuted(s=>{if(s.id===Kt.id){const a=s.params.value;n.next(a??i)}});return n.next(i),r.dispose})}}function ol(){return{id:p.ResetBackgroundColorCommand.id,type:b.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:p.SetBackgroundColorCommand.id}}function il(o){const e=o.get(l.ICommandService),t=o.get(l.ThemeService);return{id:p.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:b.MenuGroup.TOOLBAR_FORMAT,type:b.MenuItemType.BUTTON_SELECTOR,positions:[b.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:Qt,hoverable:!1}}],value$:new V.Observable(n=>{const i=t.getCurrentTheme().primaryColor,r=e.onCommandExecuted(s=>{if(s.id===p.SetBackgroundColorCommand.id){const a=s.params.value;n.next(a??i)}});return n.next(i),r.dispose})}}const Wi=[{label:"align.left",icon:"LeftJustifyingSingle",value:l.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:l.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:l.HorizontalAlign.RIGHT}];function rl(o){const e=o.get(l.IUniverInstanceService),t=o.get(p.SelectionManagerService);return{id:p.SetHorizontalTextAlignCommand.id,icon:Wi[0].icon,positions:[b.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:b.MenuGroup.TOOLBAR_LAYOUT,type:b.MenuItemType.SELECTOR,selections:Wi,value$:new V.Observable(n=>{const i=o.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==p.SetHorizontalTextAlignCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const m=c.getRange(a.startRow,a.startColumn);d=m==null?void 0:m.getHorizontalAlignment()}n.next(d??l.HorizontalAlign.LEFT)});return n.next(l.HorizontalAlign.LEFT),i.dispose})}}const zi=[{label:"align.top",icon:"AlignTopSingle",value:l.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:l.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:l.VerticalAlign.BOTTOM}];function sl(o){const e=o.get(l.IUniverInstanceService),t=o.get(p.SelectionManagerService);return{id:p.SetVerticalTextAlignCommand.id,icon:zi[0].icon,tooltip:"toolbar.verticalAlignMode.main",group:b.MenuGroup.TOOLBAR_LAYOUT,type:b.MenuItemType.SELECTOR,positions:[b.MenuPosition.TOOLBAR_START],selections:zi,value$:new V.Observable(n=>{const i=o.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==p.SetVerticalTextAlignCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const m=c.getRange(a.startRow,a.startColumn);d=m==null?void 0:m.getVerticalAlignment()}n.next(d??l.VerticalAlign.TOP)});return n.next(l.VerticalAlign.TOP),i.dispose})}}const Xi=[{label:"textWrap.overflow",icon:"OverflowSingle",value:l.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:l.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:l.WrapStrategy.CLIP}];function al(o){const e=o.get(l.IUniverInstanceService),t=o.get(p.SelectionManagerService);return{id:p.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:Xi[0].icon,group:b.MenuGroup.TOOLBAR_LAYOUT,type:b.MenuItemType.SELECTOR,positions:[b.MenuPosition.TOOLBAR_START],selections:Xi,value$:new V.Observable(n=>{const i=o.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==p.SetTextWrapCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const m=c.getRange(a.startRow,a.startColumn);d=m==null?void 0:m.getWrapStrategy()}n.next(d??l.WrapStrategy.OVERFLOW)});return n.next(l.WrapStrategy.OVERFLOW),i.dispose})}}const Yi=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function ll(o){const e=o.get(l.IUniverInstanceService),t=o.get(p.SelectionManagerService);return{id:p.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:Yi[0].icon,group:b.MenuGroup.TOOLBAR_LAYOUT,type:b.MenuItemType.SELECTOR,selections:Yi,positions:[b.MenuPosition.TOOLBAR_START],value$:new V.Observable(n=>{const i=o.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==p.SetTextRotationCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const m=c.getRange(a.startRow,a.startColumn);d=m==null?void 0:m.getTextRotation()}n.next((d&&d.a)??0)});return n.next(0),i.dispose})}}function cl(){return{id:b.CopyCommand.id,group:b.MenuGroup.CONTEXT_MENU_FORMAT,type:b.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[b.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function dl(){return{id:b.PasteCommand.id,group:b.MenuGroup.CONTEXT_MENU_FORMAT,type:b.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",positions:[b.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const rt="sheet.menu.paste-special";function ul(){return{id:rt,group:b.MenuGroup.CONTEXT_MENU_FORMAT,type:b.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",positions:[b.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function hl(){return{id:Ko.id,type:b.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[rt]}}function ml(){return{id:Jo.id,type:b.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[rt]}}function _l(){return{id:Qo.id,type:b.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[rt]}}function Sl(){return{id:qo.id,type:b.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[rt]}}function fl(){return{id:p.SetWorksheetRowIsAutoHeightCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const wt="sheet.menu.sheet-frozen";function pl(){return{id:wt,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[b.MenuPosition.CONTEXT_MENU]}}const so="sheet.header-menu.sheet-frozen";function gl(){return{id:so,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function vl(){return{id:Jt.id,type:b.MenuItemType.BUTTON,positions:[wt,so],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function Cl(){return{id:Hi.id,type:b.MenuItemType.BUTTON,positions:[wt],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function Il(){return{id:Di.id,type:b.MenuItemType.BUTTON,positions:[wt],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function bl(){return{id:Li.id,type:b.MenuItemType.BUTTON,positions:[wt,so],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function Ml(){return{id:p.SetRowHiddenCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function Rl(){return{id:p.SetColHiddenCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function wl(o){const e=o.get(l.IUniverInstanceService),t=o.get(p.SelectionManagerService);function n(){var a;const r=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=t.getSelections())==null?void 0:a.map(c=>c.range).filter(c=>c.rangeType===l.RANGE_TYPE.ROW);return!!(s!=null&&s.some(c=>{for(let d=c.startRow;d<=c.endRow;d++)if(!r.getRowVisible(d))return!0;return!1}))}const i=o.get(l.ICommandService);return{id:p.SetSelectedRowsVisibleCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:new V.Observable(r=>{const s=i.onCommandExecuted(a=>{(a.id===p.SetSelectionsOperation.id||a.id===p.SetRowHiddenMutation.id||a.id===p.SetRowVisibleMutation.id)&&r.next(!n())});return r.next(!n()),()=>s.dispose()})}}function yl(o){const e=o.get(l.IUniverInstanceService),t=o.get(p.SelectionManagerService);function n(){var a;const r=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=t.getSelections())==null?void 0:a.map(c=>c.range).filter(c=>c.rangeType===l.RANGE_TYPE.COLUMN);return!!(s!=null&&s.some(c=>{for(let d=c.startRow;d<=c.endRow;d++)if(!r.getColVisible(d))return!0;return!1}))}const i=o.get(l.ICommandService);return{id:p.SetSelectedColsVisibleCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:new V.Observable(r=>{const s=i.onCommandExecuted(a=>{(a.id===p.SetSelectionsOperation.id||a.id===p.SetColHiddenMutation.id||a.id===p.SetColVisibleMutation.id)&&r.next(!n())});return r.next(!n()),()=>s.dispose()})}}function Tl(o){const e=o.get(l.ICommandService),t=o.get(l.IUniverInstanceService),n=o.get(p.SelectionManagerService);return{id:p.SetRowHeightCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:ro,props:{prefix:"rightClick.rowHeight",suffix:"px"}},value$:new V.Observable(i=>{function r(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;a!=null&&(d=c.getRowHeight(a.startRow)),i.next(d??0)}const s=e.onCommandExecuted(a=>{const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id)return r()});return r(),s.dispose})}}function El(o){const e=o.get(l.ICommandService),t=o.get(l.IUniverInstanceService),n=o.get(p.SelectionManagerService);return{id:p.SetColWidthCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:ro,props:{prefix:"rightClick.columnWidth",suffix:"px"}},value$:new V.Observable(i=>{function r(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d=0;a!=null&&(d=c.getColumnWidth(a.startColumn)),i.next(d)}const s=e.onCommandExecuted(a=>{const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id)return r()});return r(),s.dispose})}}var se=(o=>(o.MAIN="__SpreadsheetRender__",o.ROW="__SpreadsheetRowHeader__",o.COLUMN="__SpreadsheetColumnHeader__",o.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",o))(se||{}),Y=(o=>(o.VIEW_MAIN="viewMain",o.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",o.VIEW_MAIN_TOP="viewMainTop",o.VIEW_MAIN_LEFT="viewMainLeft",o.VIEW_ROW_TOP="viewRowTop",o.VIEW_ROW_BOTTOM="viewRowBottom",o.VIEW_COLUMN_LEFT="viewColumnLeft",o.VIEW_COLUMN_RIGHT="viewColumnRight",o.VIEW_LEFT_TOP="viewLeftTop",o))(Y||{});const Ol=0,Ye=2,ao=[10,400],$i=1001;function ce(o,e){const n=o.getCurrentUniverSheetInstance().getUnitId(),i=e.getRenderById(n);if(i==null)return;const{components:r,mainComponent:s,scene:a,engine:c}=i,d=s,u=r.get(se.ROW),m=r.get(se.COLUMN),h=r.get(se.LEFT_TOP);return{spreadsheet:d,spreadsheetRowHeader:u,spreadsheetColumnHeader:m,spreadsheetLeftTopPlaceholder:h,scene:a,engine:c}}function lo(o,e,t,n){const{scaleX:i,scaleY:r}=t.getAncestorScale(),{startX:s,startY:a,endX:c,endY:d}=n.getCellByIndex(o,e,i,r);return{startX:s,startY:a,endX:c,endY:d}}function st(o,e,t,n,i){const r=t.getRelativeCoord(w.Vector2.FromArray([o,e])),{x:s,y:a}=r,c=t.getScrollXYByRelativeCoords(r,i),{scaleX:d,scaleY:u}=t.getAncestorScale(),m=n.getCellPositionByOffset(s,a,d,u,c),{row:h,column:_}=m,f=n.getNoMergeCellPositionByIndex(h,_,d,u),{startX:S,startY:I,endX:C,endY:M}=f;return{startX:S,startY:I,endX:C,endY:M,row:h,column:_}}function qt(o,e,t,n){const i=t.getRelativeCoord(w.Vector2.FromArray([o,e])),r=t.getViewport(Y.VIEW_MAIN),s=t.getScrollXYByRelativeCoords(i,r),{scaleX:a,scaleY:c}=t.getAncestorScale(),{x:d,y:u}=s,m=o/a+d,h=e/c+u;return{x:m,y:h}}const xl={spreadsheetLabel:"Spreadsheet",spreadsheetRightLabel:"more Sheets",toolbar:{undo:"Undo",redo:"Redo",formatPainter:"Paint format",currencyFormat:"Format as currency",percentageFormat:"Format as percent",numberDecrease:"Decrease decimal places",numberIncrease:"Increase decimal places",moreFormats:"More formats",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",customColor:"CUSTOM",alternatingColors:"Alternating colors",confirmColor:"OK",cancelColor:"Cancel",collapse:"Collapse",fillColor:{main:"Fill color",right:"Choose color"},border:{main:"Border",right:"Border style"},mergeCell:{main:"Merge cells",right:"Choose merge type"},horizontalAlignMode:{main:"Horizontal align",right:"Alignment"},verticalAlignMode:{main:"Vertical align",right:"Alignment"},textWrapMode:{main:"Text wrap",right:"Text wrap mode"},textRotateMode:{main:"Text rotate",right:"Text rotate mode"},freezeTopRow:"Freeze top row",sortAndFilter:"Sort and filter",findAndReplace:"Find and replace",sum:"SUM",autoSum:"Auto SUM",moreFunction:"More functions",conditionalFormat:"Conditional format",comment:"Comment",pivotTable:"Pivot Table",chart:"Chart",screenshot:"Screenshot",splitColumn:"Split text",insertImage:"Insert image",insertLink:"Insert link",dataValidation:"Data validation",protection:"Protect the sheet",clearText:"Clear color",noColorSelectedText:"No color is selected",toolMore:"More",toolLess:"Less",toolClose:"Close",toolMoreTip:"More features",moreOptions:"More options",cellFormat:"Cell format config",print:"Print",borderMethod:{top:"Upper frame line",bottom:"Lower frame line",left:"Left frame line",right:"Right frame line"},more:"More"},defaultFmt:{Automatic:{text:"Automatic",value:"General",example:""},Number:{text:"Number",value:"##0.00",example:"1000.12"},Percent:{text:"Percent",value:"#0.00%",example:"12.21%"},PlainText:{text:"Plain text",value:"@",example:""},Scientific:{text:"Scientific",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Accounting",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Ten Thousand",value:"w",example:"1亿2000万2500"},Currency:{text:"Currency",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"Date",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Time",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Time 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Date time",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Date time 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Custom Formats",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"More currency formats",moreDateTime:"More date and time formats",moreNumber:"More number formats",titleCurrency:"Currency formats",decimalPlaces:"Decimal places",titleDateTime:"Date and time formats",titleNumber:"Number formats"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},print:{normalBtn:"Normal",layoutBtn:"Page Layout",pageBtn:"Page break preview",menuItemPrint:"Print (Ctrl+P)",menuItemAreas:"Print areas",menuItemRows:"Print title rows",menuItemColumns:"Print title columns"},align:{left:"left",center:"center",right:"right",top:"top",middle:"middle",bottom:"bottom"},dateFmtList:[{name:"1930-08-05",value:"yyyy-MM-dd"},{name:"1930/8/5",value:"yyyy/MM/dd"},{name:"08-05",value:"MM-dd"},{name:"8-5",value:"M-d"},{name:"13:30:30",value:"h:mm:ss"},{name:"13:30",value:"h:mm"},{name:"PM 01:30",value:"AM/PM hh:mm"},{name:"PM 1:30",value:"AM/PM h:mm"},{name:"PM 1:30:30",value:"AM/PM h:mm:ss"},{name:"08-05 PM 01:30",value:"MM-dd AM/PM hh:mm"}],numFmtList:[{name:"1235",value:"0"},{name:"1234.56",value:"0.00"},{name:"1,235",value:"#,##0"},{name:"1,234.56",value:"#,##0.00"},{name:"1,235",value:"#,##0_);(#,##0)"},{name:"1,235",value:"#,##0_);[Red](#,##0)"},{name:"1,234.56",value:"#,##0.00_);(#,##0.00)"},{name:"1,234.56",value:"#,##0.00_);[Red](#,##0.00)"},{name:"$1,235",value:"$#,##0_);($#,##0)"},{name:"$1,235",value:"$#,##0_);[Red]($#,##0)"},{name:"$1,234.56",value:"$#,##0.00_);($#,##0.00)"},{name:"$1,234.56",value:"$#,##0.00_);[Red]($#,##0.00)"},{name:"1234.56",value:"@"},{name:"123456%",value:"0%"},{name:"123456.00%",value:"0.00%"},{name:"1.23E+03",value:"0.00E+00"},{name:"1.2E+3",value:"##0.0E+0"},{name:"1234 5/9",value:"# ?/?"},{name:"1234 14/25",value:"# ??/??"},{name:"$ 1,235",value:'_($* #,##0_);_(...($* "-"_);_(@_)'},{name:"1,235",value:'_(* #,##0_);_(*..._(* "-"_);_(@_)'},{name:"$ 1,234.56",value:'_($* #,##0.00_);_(...($* "-"_);_(@_)'},{name:"1,234.56",value:'_(* #,##0.00_);...* "-"??_);_(@_)'}],button:{confirm:"OK",cancel:"Cancel",close:"Close",update:"Update",delete:"Delete",insert:"Insert",prevPage:"Previous",nextPage:"Next",total:"total:"},punctuation:{tab:"Tab",semicolon:"semicolond",comma:"comma",space:"space"},colorPicker:{collapse:"Collapse",customColor:"CUSTOM",change:"Change",confirmColor:"OK",cancelColor:"Cancel"},borderLine:{borderTop:"borderTop",borderBottom:"borderBottom",borderLeft:"borderLeft",borderRight:"borderRight",borderNone:"borderNone",borderAll:"borderAll",borderOutside:"borderOutside",borderInside:"borderInside",borderHorizontal:"borderHorizontal",borderVertical:"borderVertical",borderColor:"borderColor",borderSize:"borderSize",borderType:"borderType"},merge:{all:"Merge all",vertical:"Vertical merge",horizontal:"Horizontal merge",cancel:"Cancel merge",overlappingError:"Cannot merge overlapping areas",partiallyError:"Cannot perform this operation on partially merged cells",confirm:{title:"Continue merging would only keep the upper-left cell value, discard other values. Are you sure to continue?",cancel:"Cancel merging",confirm:"Continue merging"}},textWrap:{overflow:"Overflow",wrap:"Wrap",clip:"Clip"},textRotate:{none:"None",angleUp:"Tilt Up",angleDown:"Tilt Down",vertical:"Stack Vertically",rotationUp:"Rotate Up",rotationDown:"Rotate Down"},sheetConfig:{delete:"Delete",copy:"Copy",rename:"Rename",changeColor:"Change color",hide:"Hide",unhide:"Unhide",moveLeft:"Move left",moveRight:"Move right",resetColor:"Reset color",cancelText:"Cancel",chooseText:"Confirm color",tipNameRepeat:"The name of the tab page cannot be repeated! Please revise",noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.",confirmDelete:"Are you sure to delete",redoDelete:"Can be undo by Ctrl+Z",noHide:"Can't hide, at least keep one sheet tag",chartEditNoOpt:"This operation is not allowed in chart editing mode!",sheetNameSpecCharError:`The name cannot contain:[ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"The sheet name cannot be empty"},rightClick:{copy:"Copy",copyAs:"Copy as",cut:"Cut",paste:"Paste",pasteSpecial:"Paste Special",pasteValue:"Paste Value",pasteFormat:"Paste Format",pasteColWidth:"Paste Column Width",pasteBesidesBorder:"Paste Besides Border Styles",insert:"Insert",insertRow:"InsertRow",insertColumn:"InsertColumn",delete:"Delete",deleteCell:"Delete cell",insertCell:"Insert cell",deleteSelected:"Delete selected ",hide:"Hide",hideSelected:"Hide selected ",showHide:"Show hidden ",toTopAdd:"Towards Top Add",toBottomAdd:"Towards Bottom Add",toLeftAdd:"Towards Left Add",toRightAdd:"Towards Right Add",deleteSelectedRow:"Delete selected row",deleteSelectedColumn:"Delete selected column",hideSelectedRow:"Hide selected row",showHideRow:"Show selected row",rowHeight:"Row height",hideSelectedColumn:"Hide selected column",showHideColumn:"Show hide column",columnWidth:"Column width",to:"Towards",left:"Left",right:"Right",top:"Top",bottom:"Bottom",moveLeft:"Move left",moveUp:"Move up",moveRight:"Move right",moveDown:"Move down",add:"Add",row:"Row",column:"Column",width:"Width",height:"Height",number:"Number",confirm:"Confirm",orderAZ:"A-Z order",orderZA:"Z-A order",clearSelection:"Clear",clearContent:"Clear Contents",clearFormat:"Clear Formats",clearAll:"Clear All",matrix:"Matrix operation",sortSelection:"Sort",filterSelection:"Filter",chartGeneration:"Create chart",firstLineTitle:"first line title",untitled:"untitled",array1:"One-dimensional array",array2:"Two-dimensional array",array3:"Multidimensional Arrays",diagonal:"Diagonal",antiDiagonal:"Anti-diagonal",diagonalOffset:"Diagonal offset",offset:"Offset",boolean:"Boolean",flip:"Flip",upAndDown:"Up and down",leftAndRight:"Left and right",clockwise:"Clockwise",counterclockwise:"Counterclockwise",transpose:"Transpose",matrixCalculation:"Matrix calculation",plus:"Plus",minus:"Minus",multiply:"Multiply",divided:"Divided",power:"Power",root:"Root",log:"Log",delete0:"Delete 0 values at both ends",removeDuplicate:"Remove duplicate values",byRow:"By row",byCol:"By column",generateNewMatrix:"Generate new matrix",fitContent:"Fit for data",freeze:"Freeze",freezeCol:"Freeze to this column",freezeRow:"Freeze to this row",cancelFreeze:"Cancel freeze"},info:{tooltip:"Tooltip",notChangeMerge:"You cannot make partial changes to the merged cells",detailUpdate:"New opened",detailSave:"Local cache restored",row:"",column:"",loading:"Loading...",copy:"Copy",return:"Exit",rename:"Rename",tips:"Rename",noName:"Untitled spreadsheet",wait:"waiting for update",add:"Add",addLast:"more rows at bottom",backTop:"Back to the top",pageInfo:"Total ${total},${totalPage} page,current ${currentPage}",nextPage:"Next",tipInputNumber:"Please enter the number",tipInputNumberLimit:"The increase range is limited to 1-100",tipRowHeightLimit:"Row height must be between 0 ~ 545",tipColumnWidthLimit:"The column width must be between 0 ~ 2038",pageInfoFull:"Total ${total},${totalPage} page,All data displayed"},clipboard:{paste:{exceedMaxCells:"The number of cells pasted exceeds the maximum number of cells"}},statusbar:{sum:"sum",average:"average",min:"min",max:"max",count:"count",clickToCopy:"click to copy",copied:"copied!"},autoFill:{copy:"Copy Cell",series:"Fill Series",formatOnly:"Format Only",noFormat:"No Format"},rangeSelector:{placeholder:"Select range or input value",tooltip:"Select range"},shortcut:{sheet:{"zoom-in":"Zoom in","zoom-out":"Zoom out","reset-zoom":"Reset zoom level","select-below-cell":"Select the cell below","select-up-cell":"Select the cell above","select-left-cell":"Select the left cell","select-right-cell":"Select the right cell","select-next-cell":"Select the next cell","select-previous-cell":"Select the previous cell","select-up-value-cell":"Select the cell above that has value","select-below-value-cell":"Select the cell below that has value","select-left-value-cell":"Select the cell left that has value","select-right-value-cell":"Select the cell right that has value","expand-selection-down":"Expand selection down","expand-selection-up":"Expand selection up","expand-selection-left":"Expand selection left","expand-selection-right":"Expand selection right","expand-selection-to-left-gap":"Expand selection to the left gap","expand-selection-to-below-gap":"Expand selection to the below gap","expand-selection-to-right-gap":"Expand selection to the right gap","expand-selection-to-up-gap":"Expand selection to the up gap","select-all":"Select all"}},"sheet-view":"Sheet View"},Zi={spreadsheetLabel:"插件",spreadsheetRightLabel:"更多 Sheets",toolbar:{undo:"撤销",redo:"重做",formatPainter:"格式刷",currencyFormat:"货币格式",percentageFormat:"百分比格式",numberDecrease:"减少小数位数",numberIncrease:"增加小数位数",moreFormats:"更多格式",font:"字体",fontSize:"字号大小",bold:"粗体",italic:"斜体",strikethrough:"删除线",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",customColor:"自定义",alternatingColors:"交替颜色",confirmColor:"确定颜色",cancelColor:"取消",collapse:"收起",fillColor:{main:"单元格颜色",right:"颜色选择"},border:{main:"边框",right:"边框类型"},mergeCell:{main:"合并单元格",right:"选择合并类型"},horizontalAlignMode:{main:"水平对齐",right:"对齐方式"},verticalAlignMode:{main:"垂直对齐",right:"对齐方式"},textWrapMode:{main:"文本换行",right:"换行方式"},textRotateMode:{main:"文本旋转",right:"旋转方式"},freezeTopRow:"冻结首行",sortAndFilter:"排序和筛选",findAndReplace:"查找替换",sum:"求和",autoSum:"自动求和",moreFunction:"更多函数",conditionalalFormat:"条件格式",comment:"批注",pivotTable:"数据透视表",chart:"图表",screenshot:"截图",splitColumn:"分列",insertImage:"插入图片",insertLink:"插入链接",dataValidation:"数据验证",protection:"保护工作表内容",clearText:"清除颜色选择",noColorSelectedText:"没有颜色被选择",toolMore:"更多",toolLess:"少于",toolClose:"收起",toolMoreTip:"更多功能",moreOptions:"更多选项",cellFormat:"设置单元格格式",print:"打印",borderMethod:{top:"上框线",bottom:"下框线",left:"左框线",right:"右框线"},more:"更多"},defaultFmt:{Automatic:{text:"自动",value:"General",example:""},Number:{text:"数字",value:"##0.00",example:"1000.12"},Percent:{text:"百分比",value:"#0.00%",example:"12.21%"},PlainText:{text:"纯文本",value:"@",example:""},Scientific:{text:"科学计数",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"会计",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"万元",value:"w",example:"1亿2000万2500"},Currency:{text:"货币",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"日期",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"时间",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"时间24H",value:"hh:mm",example:"15:00"},DateTime:{text:"日期时间",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"日期时间24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"自定义格式",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"更多货币格式",moreDateTime:"更多日期与时间格式",moreNumber:"更多数字格式",titleCurrency:"货币格式",decimalPlaces:"小数位数",titleDateTime:"日期与时间格式",titleNumber:"数字格式"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"微软雅黑",SimSun:"宋体",SimHei:"黑体",Kaiti:"楷体",FangSong:"仿宋",NSimSun:"新宋体",STXinwei:"华文新魏",STXingkai:"华文行楷",STLiti:"华文隶书",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},print:{normalBtn:"常规视图",layoutBtn:"页面布局",pageBtn:"分页预览",menuItemPrint:"打印(Ctrl+P)",menuItemAreas:"打印区域",menuItemRows:"打印标题行",menuItemColumns:"打印标题列"},align:{left:"左对齐",center:"中间对齐",right:"右对齐",top:"顶部对齐",middle:"居中对齐",bottom:"底部对齐"},button:{confirm:"确定",cancel:"取消",close:"关闭",update:"Update",delete:"Delete",insert:"新建",prevPage:"上一页",nextPage:"下一页",total:"总共:"},punctuation:{tab:"Tab 键",semicolon:"分号",comma:"逗号",space:"空格"},colorPicker:{collapse:"收起",customColor:"自定义",change:"切换",confirmColor:"确定",cancelColor:"取消"},borderLine:{borderTop:"上框线",borderBottom:"下框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无",borderAll:"所有",borderOutside:"外侧",borderInside:"内侧",borderHorizontal:"内侧横线",borderVertical:"内侧竖线",borderColor:"边框颜色",borderSize:"边框粗细",borderType:"边框线类型"},merge:{all:"全部合并",vertical:"垂直合并",horizontal:"水平合并",cancel:"取消合并",overlappingError:"不能合并重叠区域",partiallyError:"无法对部分合并单元格执行此操作",confirm:{title:"合并单元格仅保存左上角单元格的值,是否继续?",cancel:"取消合并",confirm:"继续合并"}},textWrap:{overflow:"溢出",wrap:"自动换行",clip:"截断"},textRotate:{none:"无旋转",angleUp:"向上倾斜",angleDown:"向下倾斜",vertical:"竖排文字",rotationUp:"向上90°",rotationDown:"向下90°"},sheetConfig:{delete:"删除",copy:"复制",rename:"重命名",changeColor:"更改颜色",hide:"隐藏",unhide:"取消隐藏",moveLeft:"向左移",moveRight:"向右移",resetColor:"重置颜色",cancelText:"取消",chooseText:"确定颜色",tipNameRepeat:"标签页的名称不能重复!请重新修改",noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",confirmDelete:"是否删除",redoDelete:"可以通过Ctrl+Z撤销删除",noHide:"不能隐藏, 至少保留一个sheet标签",chartEditNoOpt:"图表编辑模式下不允许该操作!",sheetNameSpecCharError:`名称不能超过31个字符,首尾不能是' 且名称不能包含:\r
14
+ [ ] : \\ ? * /`,sheetNameCannotIsEmptyError:"名称不能为空"},rightClick:{copy:"复制",copyAs:"复制为",cut:"剪切",paste:"粘贴",pasteSpecial:"选择性粘贴",pasteValue:"仅粘贴值",pasteFormat:"仅粘贴格式",pasteColWidth:"仅粘贴列宽",pasteBesidesBorder:"仅粘贴边框以外内容",insert:"插入",delete:"删除",insertRow:"插入行",insertColumn:"插入列",deleteCell:"删除单元格",insertCell:"插入单元格",deleteSelected:"删除选中",hide:"隐藏",hideSelected:"隐藏选中",showHide:"显示隐藏",toTopAdd:"向上增加",toBottomAdd:"向下增加",toLeftAdd:"向左增加",toRightAdd:"向右增加",deleteSelectedRow:"删除选中行",deleteSelectedColumn:"删除选中列",hideSelectedRow:"隐藏选中行",showHideRow:"显示隐藏行",rowHeight:"行高",hideSelectedColumn:"隐藏选中列",showHideColumn:"显示隐藏列",columnWidth:"列宽",to:"向",left:"左",right:"右",top:"上",bottom:"下",moveLeft:"左移",moveUp:"上移",moveRight:"右移",moveDown:"下移",add:"增加",row:"行",column:"列",width:"宽",height:"高",number:"数字",confirm:"确认",orderAZ:"A-Z顺序排列",orderZA:"Z-A降序排列",clearSelection:"清除",clearContent:"清除内容",clearFormat:"清除格式",clearAll:"清除全部",matrix:"矩阵操作选区",sortSelection:"排序选区",filterSelection:"筛选选区",chartGeneration:"图表生成",firstLineTitle:"首行为标题",untitled:"无标题",array1:"一维数组",array2:"二维数组",array3:"多维数组",diagonal:"对角线",antiDiagonal:"反对角线",diagonalOffset:"对角偏移",offset:"偏移量",boolean:"布尔值",flip:"翻转",upAndDown:"上下",leftAndRight:"左右",clockwise:"顺时针",counterclockwise:"逆时针",transpose:"转置",matrixCalculation:"矩阵计算",plus:"加",minus:"减",multiply:"乘",divided:"除",power:"次方",root:"次方根",log:"log",delete0:"删除两端0值",removeDuplicate:"删除重复值",byRow:"按行",byCol:"按列",generateNewMatrix:"生成新矩阵",fitContent:"适合数据",freeze:"冻结",freezeCol:"冻结列",freezeRow:"冻结行",cancelFreeze:"取消冻结"},info:{tooltip:"提示",notChangeMerge:"不能对合并单元格做部分更改",detailUpdate:"新打开",detailSave:"已恢复本地缓存",row:"行",column:"列",loading:"渲染中···",copy:"副本",return:"返回",rename:"重命名",tips:"重命名",noName:"无标题的电子表格",wait:"待更新",add:"添加",addLast:"在底部添加",backTop:"回到顶部",pageInfo:"共${total}条,${totalPage}页,当前已显示${currentPage}页",nextPage:"下一页",tipInputNumber:"请输入数字",tipInputNumberLimit:"增加范围限制在1-100",tipRowHeightLimit:"行高必须在0 ~ 545之间",tipColumnWidthLimit:"列宽必须在0 ~ 2038之间",pageInfoFull:"共${total}条,${totalPage}页,已显示全部数据"},clipboard:{paste:{exceedMaxCells:"粘贴区域超出最大单元格数"}},statusbar:{sum:"求和",average:"平均值",min:"最小值",max:"最大值",count:"计数",clickToCopy:"点击复制数值",copied:"数据复制成功,快去粘贴数据吧!"},autoFill:{copy:"复制单元格",series:"填充序列",formatOnly:"仅填充格式",noFormat:"不带格式填充"},rangeSelector:{placeholder:"选择范围或输入值",tooltip:"选择范围"}},Pl=(o,e,t=!1)=>{const n=m=>m.endRow-m.startRow+1,i=m=>m.endColumn-m.startColumn+1,r=n(e)%n(o),s=i(e)%i(o),a={startRow:0,endRow:n(o)-1,startColumn:0,endColumn:i(o)-1},c=Math.floor(n(e)/n(o)),d=Math.floor(i(e)/i(o)),u=[];if(!r&&!s)for(let m=1;m<=c;m++)for(let h=1;h<=d;h++){const _=n(o)*(m-1),f=i(o)*(h-1),S={startRow:_+e.startRow,endRow:_+e.startRow,startColumn:f+e.startColumn,endColumn:f+e.startColumn};u.push({repeatRelativeRange:a,startRange:S})}else if(!r&&s&&!t)for(let m=1;m<=c;m++){const h=n(o)*(m-1),_=0,f={startRow:h+e.startRow,endRow:h+e.startRow,startColumn:_+e.startColumn,endColumn:_+e.startColumn};u.push({repeatRelativeRange:a,startRange:f})}else if(r&&!s&&!t)for(let m=1;m<=d;m++){const _=i(o)*(m-1),f={startRow:0+e.startRow,endRow:0+e.startRow,startColumn:_+e.startColumn,endColumn:_+e.startColumn};u.push({repeatRelativeRange:a,startRange:f})}else{const m={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};u.push({startRange:m,repeatRelativeRange:a})}return u};class Gi{constructor(){v(this,"_state",null);v(this,"_rect",null);v(this,"_focus",!1);v(this,"_state$",new V.BehaviorSubject(null));v(this,"state$",this._state$.asObservable());v(this,"_rect$",new V.BehaviorSubject(null));v(this,"rect$",this._rect$.asObservable());v(this,"_focus$",new V.BehaviorSubject(this._focus));v(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(e){this._state=e,this._refresh(e)}getRect(){return this._rect}setRect(e){this._rect=e,this._rect$.next(e)}getState(){return this._state}setFocus(e=!1){this._focus=e,this._focus$.next(e)}_refresh(e){this._state$.next(e)}}const yt=L.createIdentifier("univer.sheet-cell-editor-manager.service");class Al{constructor(){v(this,"_position",null);v(this,"_position$",new V.BehaviorSubject(null));v(this,"position$",this._position$.asObservable());v(this,"_focus",!1);v(this,"_focus$",new V.BehaviorSubject(this._focus));v(this,"focus$",this._focus$.asObservable());v(this,"_fxBtnClick$",new V.BehaviorSubject(!1));v(this,"fxBtnClick$",this._fxBtnClick$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}setFocus(e=!1){this._focus=e,this._focus$.next(e)}handleFxBtnClick(e){this._fxBtnClick$.next(e)}_refresh(e){this._position$.next(e)}}const en=L.createIdentifier("univer.sheet-formula-editor-manager.service");function ie(o){return typeof o=="function"}function kl(o){return ie(o==null?void 0:o.lift)}function Ki(o){return function(e){if(kl(e))return e.lift(function(t){try{return o(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}var co=function(o,e){return co=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},co(o,e)};function uo(o,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");co(o,e);function t(){this.constructor=o}o.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Hl(o,e,t,n){function i(r){return r instanceof t?r:new t(function(s){s(r)})}return new(t||(t=Promise))(function(r,s){function a(u){try{d(n.next(u))}catch(m){s(m)}}function c(u){try{d(n.throw(u))}catch(m){s(m)}}function d(u){u.done?r(u.value):i(u.value).then(a,c)}d((n=n.apply(o,e||[])).next())})}function Ji(o,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,i,r,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(d){return function(u){return c([d,u])}}function c(d){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,d[0]&&(t=0)),t;)try{if(n=1,i&&(r=d[0]&2?i.return:d[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,d[1])).done)return r;switch(i=0,r&&(d=[d[0]&2,r.value]),d[0]){case 0:case 1:r=d;break;case 4:return t.label++,{value:d[1],done:!1};case 5:t.label++,i=d[1],d=[0];continue;case 7:d=t.ops.pop(),t.trys.pop();continue;default:if(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(d[0]===6||d[0]===2)){t=0;continue}if(d[0]===3&&(!r||d[1]>r[0]&&d[1]<r[3])){t.label=d[1];break}if(d[0]===6&&t.label<r[1]){t.label=r[1],r=d;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(d);break}r[2]&&t.ops.pop(),t.trys.pop();continue}d=e.call(o,t)}catch(u){d=[6,u],i=0}finally{n=r=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function Tt(o){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&o[e],n=0;if(t)return t.call(o);if(o&&typeof o.length=="number")return{next:function(){return o&&n>=o.length&&(o=void 0),{value:o&&o[n++],done:!o}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function tn(o,e){var t=typeof Symbol=="function"&&o[Symbol.iterator];if(!t)return o;var n=t.call(o),i,r=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)r.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(s)throw s.error}}return r}function nn(o,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,r;n<i;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return o.concat(r||Array.prototype.slice.call(e))}function at(o){return this instanceof at?(this.v=o,this):new at(o)}function Dl(o,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(o,e||[]),i,r=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(h){n[h]&&(i[h]=function(_){return new Promise(function(f,S){r.push([h,_,f,S])>1||a(h,_)})})}function a(h,_){try{c(n[h](_))}catch(f){m(r[0][3],f)}}function c(h){h.value instanceof at?Promise.resolve(h.value.v).then(d,u):m(r[0][2],h)}function d(h){a("next",h)}function u(h){a("throw",h)}function m(h,_){h(_),r.shift(),r.length&&a(r[0][0],r[0][1])}}function Ll(o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=o[Symbol.asyncIterator],t;return e?e.call(o):(o=typeof Tt=="function"?Tt(o):o[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=o[r]&&function(s){return new Promise(function(a,c){s=o[r](s),i(a,c,s.done,s.value)})}}function i(r,s,a,c){Promise.resolve(c).then(function(d){r({value:d,done:a})},s)}}typeof SuppressedError=="function"&&SuppressedError;var Nl=function(o){return o&&typeof o.length=="number"&&typeof o!="function"};function Ul(o){return ie(o==null?void 0:o.then)}function Bl(o){var e=function(n){Error.call(n),n.stack=new Error().stack},t=o(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ho=Bl(function(o){return function(t){o(this),this.message=t?t.length+` errors occurred during unsubscription:
15
+ `+t.map(function(n,i){return i+1+") "+n.toString()}).join(`
16
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function Qi(o,e){if(o){var t=o.indexOf(e);0<=t&&o.splice(t,1)}}var mo=function(){function o(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return o.prototype.unsubscribe=function(){var e,t,n,i,r;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=Tt(s),c=a.next();!c.done;c=a.next()){var d=c.value;d.remove(this)}}catch(S){e={error:S}}finally{try{c&&!c.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else s.remove(this);var u=this.initialTeardown;if(ie(u))try{u()}catch(S){r=S instanceof ho?S.errors:[S]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var h=Tt(m),_=h.next();!_.done;_=h.next()){var f=_.value;try{er(f)}catch(S){r=r??[],S instanceof ho?r=nn(nn([],tn(r)),tn(S.errors)):r.push(S)}}}catch(S){n={error:S}}finally{try{_&&!_.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}}if(r)throw new ho(r)}},o.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)er(e);else{if(e instanceof o){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},o.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},o.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},o.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Qi(t,e)},o.prototype.remove=function(e){var t=this._finalizers;t&&Qi(t,e),e instanceof o&&e._removeParent(this)},o.EMPTY=function(){var e=new o;return e.closed=!0,e}(),o}();mo.EMPTY;function qi(o){return o instanceof mo||o&&"closed"in o&&ie(o.remove)&&ie(o.add)&&ie(o.unsubscribe)}function er(o){ie(o)?o():o.unsubscribe()}var tr={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},_o={setTimeout:function(o,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=_o.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,nn([o,e],tn(t))):setTimeout.apply(void 0,nn([o,e],tn(t)))},clearTimeout:function(o){var e=_o.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(o)},delegate:void 0};function nr(o){_o.setTimeout(function(){throw o})}function or(){}function Vl(o){o()}var So=function(o){uo(e,o);function e(t){var n=o.call(this)||this;return n.isStopped=!1,t?(n.destination=t,qi(t)&&t.add(n)):n.destination=zl,n}return e.create=function(t,n,i){return new po(t,n,i)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,o.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(mo),Fl=Function.prototype.bind;function fo(o,e){return Fl.call(o,e)}var jl=function(){function o(e){this.partialObserver=e}return o.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){on(n)}},o.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){on(n)}else on(e)},o.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){on(t)}},o}(),po=function(o){uo(e,o);function e(t,n,i){var r=o.call(this)||this,s;if(ie(t)||!t)s={next:t??void 0,error:n??void 0,complete:i??void 0};else{var a;r&&tr.useDeprecatedNextContext?(a=Object.create(t),a.unsubscribe=function(){return r.unsubscribe()},s={next:t.next&&fo(t.next,a),error:t.error&&fo(t.error,a),complete:t.complete&&fo(t.complete,a)}):s=t}return r.destination=new jl(s),r}return e}(So);function on(o){nr(o)}function Wl(o){throw o}var zl={closed:!0,next:or,error:Wl,complete:or},go=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Xl(o){return o}function Yl(o){return o.length===0?Xl:o.length===1?o[0]:function(t){return o.reduce(function(n,i){return i(n)},t)}}var lt=function(){function o(e){e&&(this._subscribe=e)}return o.prototype.lift=function(e){var t=new o;return t.source=this,t.operator=e,t},o.prototype.subscribe=function(e,t,n){var i=this,r=Zl(e)?e:new po(e,t,n);return Vl(function(){var s=i,a=s.operator,c=s.source;r.add(a?a.call(r,c):c?i._subscribe(r):i._trySubscribe(r))}),r},o.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},o.prototype.forEach=function(e,t){var n=this;return t=ir(t),new t(function(i,r){var s=new po({next:function(a){try{e(a)}catch(c){r(c),s.unsubscribe()}},error:r,complete:i});n.subscribe(s)})},o.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},o.prototype[go]=function(){return this},o.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Yl(e)(this)},o.prototype.toPromise=function(e){var t=this;return e=ir(e),new e(function(n,i){var r;t.subscribe(function(s){return r=s},function(s){return i(s)},function(){return n(r)})})},o.create=function(e){return new o(e)},o}();function ir(o){var e;return(e=o??tr.Promise)!==null&&e!==void 0?e:Promise}function $l(o){return o&&ie(o.next)&&ie(o.error)&&ie(o.complete)}function Zl(o){return o&&o instanceof So||$l(o)&&qi(o)}function Gl(o){return ie(o[go])}function Kl(o){return Symbol.asyncIterator&&ie(o==null?void 0:o[Symbol.asyncIterator])}function Jl(o){return new TypeError("You provided "+(o!==null&&typeof o=="object"?"an invalid object":"'"+o+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Ql(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ql=Ql();function ec(o){return ie(o==null?void 0:o[ql])}function tc(o){return Dl(this,arguments,function(){var t,n,i,r;return Ji(this,function(s){switch(s.label){case 0:t=o.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,at(t.read())];case 3:return n=s.sent(),i=n.value,r=n.done,r?[4,at(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,at(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function nc(o){return ie(o==null?void 0:o.getReader)}function oc(o){if(o instanceof lt)return o;if(o!=null){if(Gl(o))return ic(o);if(Nl(o))return rc(o);if(Ul(o))return sc(o);if(Kl(o))return rr(o);if(ec(o))return ac(o);if(nc(o))return lc(o)}throw Jl(o)}function ic(o){return new lt(function(e){var t=o[go]();if(ie(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function rc(o){return new lt(function(e){for(var t=0;t<o.length&&!e.closed;t++)e.next(o[t]);e.complete()})}function sc(o){return new lt(function(e){o.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,nr)})}function ac(o){return new lt(function(e){var t,n;try{for(var i=Tt(o),r=i.next();!r.done;r=i.next()){var s=r.value;if(e.next(s),e.closed)return}}catch(a){t={error:a}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.complete()})}function rr(o){return new lt(function(e){cc(o,e).catch(function(t){return e.error(t)})})}function lc(o){return rr(tc(o))}function cc(o,e){var t,n,i,r;return Hl(this,void 0,void 0,function(){var s,a;return Ji(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),t=Ll(o),c.label=1;case 1:return[4,t.next()];case 2:if(n=c.sent(),!!n.done)return[3,4];if(s=n.value,e.next(s),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(r=t.return)?[4,r.call(t)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function vo(o,e,t,n,i){return new dc(o,e,t,n,i)}var dc=function(o){uo(e,o);function e(t,n,i,r,s,a){var c=o.call(this,t)||this;return c.onFinalize=s,c.shouldUnsubscribe=a,c._next=n?function(d){try{n(d)}catch(u){t.error(u)}}:o.prototype._next,c._error=r?function(d){try{r(d)}catch(u){t.error(u)}finally{this.unsubscribe()}}:o.prototype._error,c._complete=i?function(){try{i()}catch(d){t.error(d)}finally{this.unsubscribe()}}:o.prototype._complete,c}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;o.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(So);function uc(o,e){return Ki(function(t,n){var i=0;t.subscribe(vo(n,function(r){return o.call(e,r,i++)&&n.next(r)}))})}function hc(o,e){return Ki(function(t,n){var i=null,r=0,s=!1,a=function(){return s&&!i&&n.complete()};t.subscribe(vo(n,function(c){i==null||i.unsubscribe();var d=0,u=r++;oc(o(c,u)).subscribe(i=vo(n,function(m){return n.next(e?e(c,m,u,d++):m)},function(){i=null,a()}))},function(){s=!0,a()}))})}var mc=Object.defineProperty,_c=Object.getOwnPropertyDescriptor,Sc=(o,e,t,n)=>{for(var i=n>1?void 0:n?_c(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&mc(e,t,i),i},sr=(o,e)=>(t,n)=>e(t,n,o);let rn=class extends l.Disposable{constructor(e,t){super();v(this,"_previousSheetIndex",-1);this._commandService=e,this._univerInstanceService=t,this.disposeWithMe(this._commandService.onCommandExecuted((n,i)=>{if(n.id===p.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,i)=>{if(n.id===p.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===p.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(i!=null&&i.local)){if(n.id===p.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===p.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(e){const{workbookId:t,worksheetId:n}=e.params,i=this._univerInstanceService.getUniverSheetInstance(t);if(!i||(i==null?void 0:i.getRawActiveSheet())!==n)return;const s=i.getActiveSheetIndex(),a=fc(i,s);this._switchToNextSheet(t,a)}_beforeAdjustActiveSheetOnRemoveSheet(e){const{workbookId:t,worksheetId:n}=e.params,i=this._univerInstanceService.getUniverSheetInstance(t);if(!i)return;const r=i.getSheetBySheetId(n);r&&(this._previousSheetIndex=i.getSheetIndex(r))}_adjustActiveSheetOnRemoveSheet(e){if(this._previousSheetIndex===-1)return;const{workbookId:t}=e.params,n=this._univerInstanceService.getUniverSheetInstance(t);if(!n||n.getRawActiveSheet())return;const r=this._previousSheetIndex,s=r>=1?r-1:0,a=n.getSheetByIndex(s);if(!a)throw new Error("[ActiveWorksheetController]: cannot find the next sheet!");this._switchToNextSheet(t,a.getSheetId())}_adjustActiveSheetOnInsertSheet(e){const{workbookId:t,sheet:n}=e.params;this._switchToNextSheet(t,n.id)}_adjustActiveSheetOnShowSheet(e){const{workbookId:t,worksheetId:n}=e.params;this._switchToNextSheet(t,n)}_switchToNextSheet(e,t){this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{workbookId:e,worksheetId:t})}};rn=Sc([l.OnLifecycle(l.LifecycleStages.Ready,rn),sr(0,l.ICommandService),sr(1,l.IUniverInstanceService)],rn);function fc(o,e){const t=o.getSheetSize();for(let n=e;n>-1;n--){const i=o.getSheetByIndex(n);if(!i.getConfig().hidden)return i.getSheetId()}for(let n=e;n<t;n++){const i=o.getSheetByIndex(n);if(!i.getConfig().hidden)return i.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var pc=Object.defineProperty,gc=Object.getOwnPropertyDescriptor,vc=(o,e,t,n)=>{for(var i=n>1?void 0:n?gc(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&pc(e,t,i),i},Et=(o,e)=>(t,n)=>e(t,n,o);let sn=class{constructor(o,e,t,n,i){this._injector=o,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=n,this._sheetSkeletonManagerService=i,this._initialize()}_getUndoRedoParamsOfAutoHeight(o){const{_univerInstanceService:e,_sheetSkeletonManagerService:t,_injector:n}=this,{skeleton:i}=t.getCurrent(),r=i.calculateAutoHeightInRange(o),s=e.getCurrentUniverSheetInstance(),a=s.getUnitId(),d={worksheetId:s.getActiveSheet().getSheetId(),workbookId:a,rowsAutoHeightInfo:r},u=p.SetWorksheetRowAutoHeightMutationFactory(n,d);return{undos:[{id:p.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:p.SetWorksheetRowAutoHeightMutation.id,params:d}]}}_initialize(){const{_sheetInterceptorService:o,_selectionManagerService:e}=this;o.interceptCommand({getMutations:t=>t.id!==p.SetRangeValuesCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.range)}),o.interceptCommand({getMutations:t=>t.id!==p.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.ranges)}),o.interceptCommand({getMutations:t=>t.id!==p.DeltaColumnWidthCommand.id&&t.id!==p.SetColWidthCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.ranges)}),o.interceptCommand({getMutations:t=>{var r;if(t.id!==p.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((r=t.params)==null?void 0:r.style.type))return{redos:[],undos:[]};const i=e.getSelectionRanges();return i!=null&&i.length?this._getUndoRedoParamsOfAutoHeight(i):{redos:[],undos:[]}}})}};sn=vc([l.OnLifecycle(l.LifecycleStages.Ready,sn),Et(0,L.Inject(L.Injector)),Et(1,L.Inject(p.SheetInterceptorService)),Et(2,L.Inject(p.SelectionManagerService)),Et(3,L.Inject(l.IUniverInstanceService)),Et(4,L.Inject(k.SheetSkeletonManagerService))],sn);function Cc(o,e,t,n,i,r){const s=[],a=[];if(i.copyType===je.CUT){const{undos:c,redos:d}=Ic(o,t,n,i,r);s.push(...d),a.push(...c)}else{const{undos:c,redos:d}=cr(t,n,o,e,r);s.push(...d),a.push(...c);const{undos:u,redos:m}=ar(t,n,o,e,r);s.push(...m),a.push(...u);const{undos:h,redos:_}=lr(t,n,o,e,r);s.push(..._),a.push(...h);const{undos:f,redos:S}=Co(t,n,o,e,r);s.push(...S),a.push(...f)}return{undos:a,redos:s}}function Ic(o,e,t,n,i){let r=[],s=[];const{copyRange:a}=n;if(a){const c=i.get(l.IUniverInstanceService),d=i.get(p.SheetInterceptorService),u=c.getUniverSheetInstance(e),m=u==null?void 0:u.getSheetBySheetId(t);if(m){const h=m.getRange(a).getValues(),_=h.reduce((y,T,E)=>(T.forEach((O,x)=>{y.setValue(a.startRow+E,a.startColumn+x,null)}),y),new l.ObjectMatrix),f=h.reduce((y,T,E)=>(T.forEach((O,x)=>{y.setValue(a.startRow+E,a.startColumn+x,O)}),y),new l.ObjectMatrix),S=h.reduce((y,T,E)=>(T.forEach((O,x)=>{y.setValue(o.startRow+E,o.startColumn+x,O)}),y),new l.ObjectMatrix),I=m.getRange(o).getValues().reduce((y,T,E)=>(T.forEach((O,x)=>{y.setValue(o.startRow+E,o.startColumn+x,O)}),y),new l.ObjectMatrix),C={from:_.getMatrix(),to:S.getMatrix(),workbookId:e,worksheetId:t},M={from:f.getMatrix(),to:I.getMatrix(),workbookId:e,worksheetId:t},R=d.onCommandExecute({id:p.MoveRangeCommand.id,params:{toRange:o,fromRange:a}});r=[{id:p.MoveRangeMutation.id,params:C},...R.redos,{id:p.SetSelectionsOperation.id,params:{unitId:e,sheetId:t,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o}]}}],s=[{id:p.SetSelectionsOperation.id,params:{unitId:e,sheetId:t,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:a}]}},...R.undos,{id:p.MoveRangeMutation.id,params:M}]}}return{undos:s,redos:r}}function ar(o,e,t,n,i){const r=[],s=[],{startColumn:a,startRow:c}=t,d=new l.ObjectMatrix;n.forValue((h,_,f)=>{d.setValue(h+c,_+a,{v:f.v})});const u={workbookId:o,worksheetId:e,cellValue:d.getData()};r.push({id:p.SetRangeValuesMutation.id,params:u});const m=p.SetRangeValuesUndoMutationFactory(i,u);return s.push({id:p.SetRangeValuesMutation.id,params:m}),{undos:s,redos:r}}function lr(o,e,t,n,i){const r=[],s=[],{startColumn:a,startRow:c}=t,d=new l.ObjectMatrix;n.forValue((h,_,f)=>{var S;d.setValue(h+c,_+a,{s:f.s}),(S=f.p)!=null&&S.body&&d.setValue(h+c,_+a,{p:f.p})});const u={workbookId:o,worksheetId:e,cellValue:d.getData()};r.push({id:p.SetRangeValuesMutation.id,params:u});const m=p.SetRangeValuesUndoMutationFactory(i,u);return s.push({id:p.SetRangeValuesMutation.id,params:m}),{undos:s,redos:r}}function cr(o,e,t,n,i){const r=[],s=[],a=new l.ObjectMatrix,{startColumn:c,startRow:d}=t;if(n.forValue((u,m,h)=>{h.s&&a.setValue(u+d,m+c,{s:null})}),a.getLength()>0){const u={worksheetId:e,workbookId:o,cellValue:a.getData()};r.push({id:p.SetRangeValuesMutation.id,params:u});const m=p.SetRangeValuesUndoMutationFactory(i,u);s.push({id:p.SetRangeValuesMutation.id,params:m})}return{undos:s,redos:r}}function Co(o,e,t,n,i){const r=[],s=[],{startColumn:a,startRow:c,endColumn:d,endRow:u}=t;let m=!1;const h=[];if(n.forValue((S,I,C)=>{if(C.rowSpan){const M=C.colSpan||1,R={startRow:c+S,endRow:c+S+C.rowSpan-1,startColumn:a+I,endColumn:a+I+M-1};h.push(R),m=!0}else if(C.colSpan){const M=C.rowSpan||1,R={startRow:c+S,endRow:c+S+M-1,startColumn:a+I,endColumn:a+I+C.colSpan-1};h.push(R),m=!0}}),m){const I=i.get(l.IUniverInstanceService).getUniverSheetInstance(o),C=I==null?void 0:I.getSheetBySheetId(e);if(I&&C){const R=C.getMergeData().filter(E=>l.Rectangle.intersects({startRow:c,startColumn:a,endRow:u,endColumn:d},E)),y={workbookId:o,worksheetId:e,ranges:R};r.push({id:p.RemoveWorksheetMergeMutation.id,params:y});const T=p.RemoveMergeUndoMutationFactory(i,y);s.push({id:p.AddWorksheetMergeMutation.id,params:T})}}const _={workbookId:o,worksheetId:e,ranges:h};r.push({id:p.AddWorksheetMergeMutation.id,params:_});const f=p.AddMergeUndoMutationFactory(i,_);return s.push({id:p.RemoveWorksheetMergeMutation.id,params:f}),{undos:s,redos:r}}var bc=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,Rc=(o,e,t,n)=>{for(var i=n>1?void 0:n?Mc(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&bc(e,t,i),i},$e=(o,e)=>(t,n)=>e(t,n,o);let an=class extends l.Disposable{constructor(o,e,t,n,i,r,s){super(),this._currentUniverSheet=o,this._commandService=e,this._configService=t,this._sheetClipboardService=n,this._messageService=i,this._injector=r,this._localService=s,this._init()}_init(){[Go,Hs,et].forEach(e=>this.disposeWithMe(this._commandService.registerAsMultipleCommand(e))),[Ko,Jo,Qo,qo].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const o=this._initSpecialPasteHooks().map(e=>this._sheetClipboardService.addClipboardHook(e));this.disposeWithMe({dispose:()=>o.forEach(e=>e.dispose())})}_initCopyingHooks(){const o=this;let e=null;return{hookName:ue.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(t,n){e=o._getWorksheet(t,n)},onCopyCellContent(t,n){const i=e.getCell(t,n);return`${i==null?void 0:i.v}`||""},onCopyCellStyle:(t,n,i,r)=>{const s={};(i||r)&&(s.rowspan=`${i||1}`,s.colspan=`${r||1}`);const c=e.getRange(t,n).getTextStyle();let d="";return c&&(d=l.handleStyleToString(c)),d&&(s.style=d),s},onCopyColumn(t){return{width:`${e.getColumnWidth(t)}`}},onCopyRow(t){return{style:`height: ${e.getRowHeight(t)}px;`}},onAfterCopy(){e=null}}}_initPastingHook(){const o=this;let e=null,t=null,n=null;return{hookName:ue.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste(i,r,s){n=o._getWorksheet(i,r),e=i,t=r;const a=o._configService.getConfig(p.MAX_CELL_PER_SHEET_KEY),{endRow:c,endColumn:d}=s;return a&&c*d>a?(o._messageService.show({type:te.MessageType.Error,content:o._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(i,r){const s=[],a=n.getMaxRows(),c=i.endRow-a,d=r.length-c;if(c>0){const h=new l.ObjectArray;r.slice(d).forEach((f,S)=>{const I=f==null?void 0:f.style;if(!I)return;const C=I.split(";");let M=l.DEFAULT_WORKSHEET_ROW_HEIGHT;C.find(R=>{R=R.toLowerCase();const y=b.textTrim(R.substr(0,R.indexOf(":"))),T=b.textTrim(R.substr(R.indexOf(":")+1));return y==="height"?(M=parseFloat(T),!0):!1}),h.set(S,{h:M,hd:l.BooleanNumber.FALSE})});const _={workbookId:e,worksheetId:t,ranges:[{...i,startRow:a}],rowInfo:h};s.push({id:p.InsertRowMutation.id,params:_})}const u=new l.ObjectArray;r.slice(0,d).forEach((h,_)=>{const f=h.style;if(!f)return;const S=f.split(";");let I=l.DEFAULT_WORKSHEET_ROW_HEIGHT;S.find(C=>{C=C.toLowerCase();const M=b.textTrim(C.substr(0,C.indexOf(":"))),R=b.textTrim(C.substr(C.indexOf(":")+1));return M==="height"?(I=parseFloat(R),!0):!1}),u.set(_,I)});const m={workbookId:e,worksheetId:t,ranges:[{...i,endRow:Math.min(i.endRow,a)}],rowHeight:u};return s.push({id:p.SetWorksheetRowHeightMutation.id,params:m}),{redos:s,undos:[]}},onPasteColumns(i,r,s){const a=[],c=n.getMaxColumns(),d=i.endColumn-c,u=r.length-d;if(d>0){const h={workbookId:e,worksheetId:t,ranges:[{...i,startColumn:c}],colInfo:new l.ObjectArray(r.slice(u).map(_=>({w:_.width?+_.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH,hd:l.BooleanNumber.FALSE})))};a.push({id:p.InsertColMutation.id,params:h})}const m={workbookId:e,worksheetId:t,ranges:[{...i,endRow:Math.min(i.endColumn,c)}],colWidth:new l.ObjectArray(r.slice(0,u).map(h=>h.width?+h.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH))};return a.push({id:p.SetWorksheetColWidthMutation.id,params:m}),{redos:a,undos:[]}},onPasteCells(i,r,s,a){return o._onPasteCells(i,r,e,t,s,a)},onAfterPaste(i){n=null}}}_onPasteCells(o,e,t,n,i,r){const s={get:this._injector.get.bind(this._injector)};return Cc(o,e,t,n,r,s)}_initSpecialPasteHooks(){const o={get:this._injector.get.bind(this._injector)},e=this,t={hookName:ue.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,a,c,d)=>{const u=e._currentUniverSheet.getCurrentUniverSheetInstance(),m=u.getUnitId(),h=u.getActiveSheet().getSheetId();return ar(m,h,s,a,o)}},n={hookName:ue.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,a,c,d){const u=e._currentUniverSheet.getCurrentUniverSheetInstance(),m=u.getUnitId(),h=u.getActiveSheet().getSheetId(),_=[],f=[],{undos:S,redos:I}=cr(m,h,s,a,o);_.push(...I),f.push(...S);const{undos:C,redos:M}=Co(m,h,s,a,o);_.push(...M),f.push(...C);const{undos:R,redos:y}=lr(m,h,s,a,o);return _.push(...y),f.push(...R),{undos:f,redos:_}}},i={hookName:ue.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,a,c){const d=e._currentUniverSheet.getCurrentUniverSheetInstance(),u=d.getUnitId(),m=d.getActiveSheet().getSheetId(),h=[],f=e._getWorksheet(u,m).getMaxColumns(),S=s.endColumn-f,I=a.length-S,C={workbookId:u,worksheetId:m,ranges:[{...s,endRow:Math.min(s.endColumn,f)}],colWidth:new l.ObjectArray(a.slice(0,I).map(M=>M.width?+M.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH))};return h.push({id:p.SetWorksheetColWidthMutation.id,params:C}),h.push({id:p.SetWorksheetColWidthMutation.id,params:C}),{redos:h,undos:[]}}},r={hookName:ue.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,a,c,d){const u=e._currentUniverSheet.getCurrentUniverSheetInstance(),m=u.getUnitId(),h=u.getActiveSheet().getSheetId(),_=[],f=[],{startColumn:S,startRow:I,endColumn:C,endRow:M}=s,R=new l.ObjectMatrix;a.forValue((x,P,H)=>{const A=H.s;typeof A=="object"&&R.setValue(x+I,P+S,{s:{...A,bd:void 0},v:H.v})});const y={workbookId:m,worksheetId:h,cellValue:R.getData()};_.push({id:p.SetRangeValuesMutation.id,params:y});const T=p.SetRangeValuesUndoMutationFactory(o,y);f.push({id:p.SetRangeValuesMutation.id,params:T});const{undos:E,redos:O}=Co(m,h,s,a,o);return f.push(...E),_.push(...O),{redos:_,undos:f}}};return[t,n,i,r]}_getWorksheet(o,e){var n;const t=(n=this._currentUniverSheet.getUniverSheetInstance(o))==null?void 0:n.getSheetBySheetId(e);if(!t)throw new Error(`[SheetClipboardController]: cannot find a worksheet with workbookId ${o} and worksheetId ${e}.`);return t}};an=Rc([l.OnLifecycle(l.LifecycleStages.Rendered,an),$e(0,l.IUniverInstanceService),$e(1,l.ICommandService),$e(2,l.IConfigService),$e(3,qe),$e(4,b.IMessageService),$e(5,L.Inject(L.Injector)),$e(6,L.Inject(l.LocaleService))],an);var wc=Object.defineProperty,yc=Object.getOwnPropertyDescriptor,Tc=(o,e,t,n)=>{for(var i=n>1?void 0:n?yc(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&wc(e,t,i),i},Ot=(o,e)=>(t,n)=>e(t,n,o);let ln=class extends l.Disposable{constructor(o,e,t,n,i){super(),this._currentUniverService=o,this._contextMenuService=e,this._renderManagerService=t,this._selectionManagerService=n,this._selectionRenderService=i,this._currentUniverService.currentSheet$.subscribe(r=>{if(r==null)throw new Error("workbook is null");this._addListeners()})}_addListeners(){const o=ce(this._currentUniverService,this._renderManagerService);if(!o)return;const e=o.spreadsheet.onPointerDownObserver,t=e.add(a=>{if(a.button===2){const c=this._selectionManagerService.getSelections(),d=c==null?void 0:c[0];if(!d)return;const u=d.range.rangeType,m=this._selectionRenderService.convertSelectionRangeToData(d).rangeWithCoord,h=()=>{if(!m)return!1;const f=a.offsetX,S=a.offsetY;switch(u){case l.RANGE_TYPE.ROW:return m.startY<=S&&m.endY>=S;case l.RANGE_TYPE.COLUMN:return m.startX<=f&&m.endX>=f;default:return m.startX<=f&&m.endX>=f&&m.startY<=S&&m.endY>=S}},_=f=>{this._contextMenuService.triggerContextMenu(a,f)};h()?u===l.RANGE_TYPE.COLUMN?_(q.COL_HEADER_CONTEXT_MENU):u===l.RANGE_TYPE.ROW?_(q.ROW_HEADER_CONTEXT_MENU):_(b.MenuPosition.CONTEXT_MENU):_(b.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(l.toDisposable(()=>e.remove(t)));const i=o.spreadsheetRowHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,q.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>e.remove(i)));const s=o.spreadsheetColumnHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,q.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>e.remove(s)))}};ln=Tc([l.OnLifecycle(l.LifecycleStages.Rendered,ln),Ot(0,l.IUniverInstanceService),Ot(1,b.IContextMenuService),Ot(2,w.IRenderManagerService),Ot(3,L.Inject(p.SelectionManagerService)),Ot(4,ae)],ln);var Ec=Object.defineProperty,Oc=Object.getOwnPropertyDescriptor,xc=(o,e,t,n)=>{for(var i=n>1?void 0:n?Oc(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Ec(e,t,i),i},Io=(o,e)=>(t,n)=>e(t,n,o);let cn=class extends l.RxDisposable{constructor(o,e,t){super(),this._currentUniverService=o,this._renderManagerService=e,this._undoRedoService=t,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._currentUniverService.currentDoc$.pipe(V.takeUntil(this.dispose$)).subscribe(o=>{if(o==null)return;o.getUnitId()!==l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._undoRedoService.clearUndoRedo(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})}_initialNormalInput(){const o={};this._currentUniverService.getCurrentUniverSheetInstance().getSheets().forEach(e=>{const t=e.getConfig();o[e.getSheetId()]={cellData:new l.ObjectMatrix(t.cellData),rowCount:t.rowCount,columnCount:t.columnCount}})}_commandExecutedListener(){}_getDocObject(){return Z.getDocObject(this._currentUniverService,this._renderManagerService)}};cn=xc([l.OnLifecycle(l.LifecycleStages.Steady,cn),Io(0,l.IUniverInstanceService),Io(1,w.IRenderManagerService),Io(2,L.Inject(l.IUndoRedoService))],cn);const dr=[b.KeyCode.ARROW_DOWN,b.KeyCode.ARROW_UP,b.KeyCode.ARROW_LEFT,b.KeyCode.ARROW_RIGHT],Pc=[b.KeyCode.ENTER,b.KeyCode.TAB,...dr];function Ac(){const o=[];for(const e of dr)o.push({id:vt.id,binding:e,preconditions:t=>jt(t),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:e,isShift:!1}}),o.push({id:vt.id,binding:e|b.MetaKeys.SHIFT,preconditions:t=>jt(t),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:e,isShift:!0}});return o}const kc={id:Ie.id,binding:b.KeyCode.ENTER,preconditions:o=>jt(o),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:b.KeyCode.ENTER}},Hc={id:Ie.id,binding:b.KeyCode.TAB,preconditions:o=>jt(o),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:b.KeyCode.TAB}},Dc={id:Ie.id,binding:b.KeyCode.ESC,preconditions:o=>o.getContextValue(l.FOCUSING_EDITOR),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:b.KeyCode.ESC}},Lc={id:Z.BreakLineCommand.id,preconditions:o=>o.getContextValue(l.FOCUSING_EDITOR),binding:b.KeyCode.ENTER|b.MetaKeys.ALT},Nc={id:Z.DeleteLeftCommand.id,preconditions:o=>Yr(o)||Vo(o),binding:b.KeyCode.BACKSPACE},Uc={id:Ie.id,preconditions:o=>Xr(o)&&!Vo(o),binding:b.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:b.KeyCode.BACKSPACE}};var Bc=Object.defineProperty,Vc=Object.getOwnPropertyDescriptor,Fc=(o,e,t,n)=>{for(var i=n>1?void 0:n?Vc(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Bc(e,t,i),i},we=(o,e)=>(t,n)=>e(t,n,o);let dn=class extends l.Disposable{constructor(e,t,n,i,r,s,a,c,d,u){super();v(this,"_onInputSubscription");v(this,"_cursorChangeObservers");v(this,"_editorVisiblePrevious",!1);v(this,"_isCursorChange",0);this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._editorBridgeService=i,this._contextService=r,this._cellEditorManagerService=s,this._lexerTreeBuilder=a,this._undoRedoService=c,this._sheetInterceptorService=d,this._selectionManagerService=u,this._initialize(),this._commandExecutedListener()}dispose(){var n;(n=this._onInputSubscription)==null||n.unsubscribe();const e=this._getEditorObject();if(e==null)return;const{document:t}=e;t.onPointerDownObserver.remove(this._cursorChangeObservers)}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this._onInputSubscription=this._editorBridgeService.visible$.subscribe(e=>{const{visible:t,keycode:n,eventType:i}=e;if(t===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=t,t===!0){this._isCursorChange=i===w.DeviceInputEventType.PointerDown?2:1;return}this._isCursorChange=0;const r=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:a,sheetId:c,pluginName:d}=s;if(this._exitInput(e),n===b.KeyCode.ESC){this._commandService.syncExecuteCommand(p.SetSelectionsOperation.id,{workbookId:a,worksheetId:c,pluginName:d,selections:r});return}const u=this._editorBridgeService.getState();if(u==null)return;const{unitId:m,sheetId:h,row:_,column:f,documentLayoutObject:S}=u;if(S==null||(this._moveCursor(n),this._editorBridgeService.getEditorDirty()===!1))return;const C=this._currentUniverService.getUniverSheetInstance(m),M=C==null?void 0:C.getSheetBySheetId(h);if(M==null)return;const R=l.Tools.deepClone(M.getCell(_,f)||{}),T=S.documentModel.getSnapshot(),E=T.body;if(E==null)return;const O=E.dataStream;let P=O.substring(O.length-2,O.length)===l.DEFAULT_EMPTY_DOCUMENT_VALUE?O.substring(0,O.length-2):O;if(l.isFormulaString(P)){if(R.f===P)return;const D=this._lexerTreeBuilder.checkIfAddBracket(P);for(let N=0;N<D;N++)P+=re.matchToken.CLOSE_BRACKET;R.f=P,R.v=null,R.p=null}else if(E.textRuns&&E.textRuns.length>1)R.p=T,R.v=null,R.f=null;else{if(P==R.v||P==""&&R.v==null)return;R.v=P,R.f=null,R.p=null}const H={worksheetId:h,workbookId:m,workbook:C,worksheet:M,row:_,col:f},A=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(R,H);this._commandService.executeCommand(p.SetRangeValuesCommand.id,{worksheetId:h,workbookId:m,range:{startRow:_,startColumn:f,endRow:_,endColumn:f},value:A}),a===m&&h!==c&&this._commandService.executeCommand(p.SetWorksheetActivateCommand.id,{worksheetId:h,workbookId:m})})}_exitInput(e){this._contextService.setContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!1),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._cellEditorManagerService.setState({show:e.visible});const t=this._editorBridgeService.getCurrentEditorId();t!=null&&(this._undoRedoService.clearUndoRedo(t),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(e){if(e==null||!Pc.includes(e))return;let t=l.Direction.LEFT;switch(e){case b.KeyCode.ENTER:t=l.Direction.DOWN;break;case b.KeyCode.TAB:t=l.Direction.RIGHT;break;case b.KeyCode.ARROW_DOWN:t=l.Direction.DOWN;break;case b.KeyCode.ARROW_UP:t=l.Direction.UP;break;case b.KeyCode.ARROW_LEFT:t=l.Direction.LEFT;break;case b.KeyCode.ARROW_RIGHT:t=l.Direction.RIGHT;break}e===b.KeyCode.ENTER||e===b.KeyCode.TAB?this._commandService.executeCommand(We.id,{keycode:e,direction:t}):this._commandService.executeCommand(_e.id,{direction:t})}_cursorStateListener(){const e=this._getEditorObject();if(e==null)return;const{document:t}=e;this._cursorChangeObservers=t.onPointerDownObserver.add(()=>{this._isCursorChange===1&&(this._isCursorChange=2)})}_commandExecutedListener(){const e=[vt.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{keycode:i,isShift:r}=n;if(i!=null&&this._isCursorChange===2){this._moveInEditor(i,r);return}this._editorBridgeService.changeVisible(n)}}))}_moveInEditor(e,t){let n=l.Direction.LEFT;e===b.KeyCode.ARROW_DOWN?n=l.Direction.DOWN:e===b.KeyCode.ARROW_UP?n=l.Direction.UP:e===b.KeyCode.ARROW_RIGHT&&(n=l.Direction.RIGHT),t?this._commandService.executeCommand(Z.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(Z.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return Bt(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};dn=Fc([l.OnLifecycle(l.LifecycleStages.Steady,dn),we(0,l.IUniverInstanceService),we(1,w.IRenderManagerService),we(2,l.ICommandService),we(3,Te),we(4,l.IContextService),we(5,yt),we(6,L.Inject(re.LexerTreeBuilder)),we(7,l.IUndoRedoService),we(8,L.Inject(p.SheetInterceptorService)),we(9,L.Inject(p.SelectionManagerService))],dn);var jc=Object.defineProperty,Wc=Object.getOwnPropertyDescriptor,zc=(o,e,t,n)=>{for(var i=n>1?void 0:n?Wc(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&jc(e,t,i),i},ye=(o,e)=>(t,n)=>e(t,n,o);let un=class extends l.RxDisposable{constructor(e,t,n,i,r,s,a,c,d,u){super();v(this,"_loadedMap",new Set);this._univerInstanceService=e,this._renderManagerService=t,this._editorBridgeService=n,this._docSkeletonManagerService=i,this._docViewModelManagerService=r,this._commandService=s,this._contextService=a,this._formulaEditorManagerService=c,this._undoRedoService=d,this._textSelectionManagerService=u,this._initialize()}_initialize(){this._syncFormulaEditorContent(),this._commandExecutedListener(),this._syncEditorSize(),this._listenFxBtnClick(),this._renderManagerService.currentRender$.pipe(V.takeUntil(this.dispose$)).subscribe(e=>{e===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._loadedMap.has(e)||(this._initialMain(e),this._loadedMap.add(e)))})}_listenFxBtnClick(){this._formulaEditorManagerService.fxBtnClick$.pipe(V.takeUntil(this.dispose$)).subscribe(()=>{var t;if(this._contextService.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)&&!this._contextService.getContextValue(l.FOCUSING_EDITOR)){this._univerInstanceService.setCurrentUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0);const n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:w.DeviceInputEventType.PointerDown});const r=(t=n==null?void 0:n.getBody())==null?void 0:t.dataStream;if(r==null)return;let s=r.startsWith("=")?r:`=${r}`;s=s.replace(/\r\n$/,"");const a=[{startOffset:s.length,endOffset:s.length,collapsed:!0}],c={unitId:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:s},segmentId:""};this._commandService.executeCommand(Z.CoverContentCommand.id,c),this._textSelectionManagerService.replaceTextRanges(a)}})}_initialMain(e){const t=this._renderManagerService.getRenderById(e);if(t==null)return;const{mainComponent:n}=t;n!=null&&this.disposeWithMe(l.toDisposable(n.onPointerDownObserver.add(()=>{this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:w.DeviceInputEventType.PointerDown})})))}_syncEditorSize(){this._formulaEditorManagerService.position$.pipe(V.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const t=Bt(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,this._renderManagerService),n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||n==null)return;const{width:i,height:r}=e,{engine:s}=t;n.updateDocumentDataPageSize(i),this._autoScroll(),requestIdleCallback(()=>{s.resizeBySize(i,r)})})}_syncFormulaEditorContent(){this._editorBridgeService.state$.pipe(V.takeUntil(this.dispose$)).subscribe(e=>{e==null||this._editorBridgeService.isForceKeepVisible()||this._editorSyncHandler(e)}),this._editorBridgeService.visible$.pipe(V.takeUntil(this.dispose$)).subscribe(e=>{if(e==null||e.visible===!1||this._editorBridgeService.isForceKeepVisible())return;const t=this._editorBridgeService.getState();t!=null&&this._editorSyncHandler(t)})}_editorSyncHandler(e){var s;const t=(s=e.documentLayoutObject.documentModel)==null?void 0:s.getBody();let n=t==null?void 0:t.dataStream,i=t==null?void 0:t.paragraphs,r=[];n==null||i==null||(e.isInArrayFormulaRange===!0&&this._editorBridgeService.isVisible().eventType===w.DeviceInputEventType.Dblclick?(n=`\r
17
+ `,i=[{startIndex:0}]):e.isInArrayFormulaRange===!0&&(r=(t==null?void 0:t.textRuns)||[]),this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,i,r),this._autoScroll())}_commandExecutedListener(){const e=[Z.RichTextEditingMutation.id,Xt.id],t=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var i,r;if(e.includes(n.id)){const s=n.params,{unitId:a}=s;if(t.includes(a)){const c=this._univerInstanceService.getUniverDocInstance(a),d=(i=c==null?void 0:c.getBody())==null?void 0:i.dataStream,u=(r=c==null?void 0:c.getBody())==null?void 0:r.paragraphs,m=a===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;if(d==null||u==null)return;this._syncContentAndRender(m,d,u),this._autoScroll()}}if(n.id===Z.SetTextSelectionsOperation.id){const{unitId:s}=n.params;s!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}}))}_syncContentAndRender(e,t,n,i=[]){var m;const r=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(e),a=this._univerInstanceService.getUniverDocInstance(e),c=this._docViewModelManagerService.getViewModel(e);if(a==null||c==null||s==null)return;a.getBody().dataStream=t,a.getBody().paragraphs=n,e===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(a.getBody().textRuns=[]),i.length>0&&(a.getBody().textRuns=i),c.reset(a);const{skeleton:d}=s,u=this._renderManagerService.getRenderById(e);u!=null&&(d.calculate(),r.includes(e)&&((m=u.mainComponent)==null||m.makeDirty()))}_autoScroll(){var f,S;const e=(f=this._docSkeletonManagerService.getSkeletonByUnitId(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:f.skeleton,t=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),i=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(e==null||t==null||n==null||i==null)return;const{marginTop:r=0,marginBottom:s=0}=i.getSnapshot().documentStyle,{scene:a,mainComponent:c}=n;let{actualHeight:d}=e.getActualSize();d+=r+s;const{width:u,height:m}=t,h=a.getViewport(Z.VIEWPORT_KEY.VIEW_MAIN);let _=h==null?void 0:h.getScrollBar();d>m?_==null?h&&new w.ScrollBar(h,{enableHorizontal:!1}):h==null||h.resetSizeAndScrollBar():(_=null,h==null||h.scrollTo({x:0,y:0}),(S=h==null?void 0:h.getScrollBar())==null||S.dispose()),a.transformByState({width:u,height:d}),c==null||c.resize(u,d)}};un=zc([l.OnLifecycle(l.LifecycleStages.Steady,un),ye(0,l.IUniverInstanceService),ye(1,w.IRenderManagerService),ye(2,Te),ye(3,L.Inject(Z.DocSkeletonManagerService)),ye(4,L.Inject(Z.DocViewModelManagerService)),ye(5,l.ICommandService),ye(6,l.IContextService),ye(7,en),ye(8,l.IUndoRedoService),ye(9,L.Inject(Z.TextSelectionManagerService))],un);var Xc=Object.defineProperty,Yc=Object.getOwnPropertyDescriptor,$c=(o,e,t,n)=>{for(var i=n>1?void 0:n?Yc(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Xc(e,t,i),i},ur=(o,e)=>(t,n)=>e(t,n,o);let hn=class extends l.Disposable{constructor(e,t){super();v(this,"_onInputSubscription");this._currentUniverService=e,this._renderManagerService=t,setTimeout(()=>{this._initialize()},0),this._commandExecutedListener()}dispose(){var e;(e=this._onInputSubscription)==null||e.unsubscribe()}_initialize(){this._currentUniverService.createDoc({id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}});const e={id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:l.HorizontalAlign.UNSPECIFIED,verticalAlign:l.VerticalAlign.UNSPECIFIED,centerAngle:0,vertexAngle:0,wrapStrategy:l.WrapStrategy.WRAP}}};this._currentUniverService.createDoc(e)}_commandExecutedListener(){}_getDocObject(){return Z.getDocObject(this._currentUniverService,this._renderManagerService)}};hn=$c([l.OnLifecycle(l.LifecycleStages.Rendered,hn),ur(0,l.IUniverInstanceService),ur(1,w.IRenderManagerService)],hn);const hr={sheetFooterBarHeight:"36",sheetContainer:"univer-sheet-container"};var Zc=Object.defineProperty,Gc=Object.getOwnPropertyDescriptor,Kc=(o,e,t,n)=>{for(var i=n>1?void 0:n?Gc(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Zc(e,t,i),i},pe=(o,e)=>(t,n)=>e(t,n,o);const mr=-1e3,_r=5,Jc=2;let mn=class extends l.Disposable{constructor(e,t,n,i,r,s,a,c,d,u,m){super();v(this,"_onInputSubscription");v(this,"_onInputActivateSubscription");v(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=e,this._docViewModelManagerService=t,this._contextService=n,this._currentUniverService=i,this._renderManagerService=r,this._editorBridgeService=s,this._cellEditorManagerService=a,this._textSelectionRenderManager=c,this._textSelectionManagerService=d,this._commandService=u,this._localService=m,this._initialize(),this._commandExecutedListener()}dispose(){var e,t;(e=this._onInputSubscription)==null||e.unsubscribe(),(t=this._onInputActivateSubscription)==null||t.unsubscribe()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const e=this._getEditorObject();e!=null&&this.disposeWithMe(l.toDisposable(e.document.onPointerDownObserver.add(()=>{var t;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getState(),i=this._editorBridgeService.getCurrentEditorId();if(n==null||i==null)return;const r=(t=this._docSkeletonManagerService.getSkeletonByUnitId(i))==null?void 0:t.skeleton;if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u}=n;this._fitTextSize(s,c,r,a,d,u)}})))}_initialCursorSync(){this._cellEditorManagerService.focus$.subscribe(()=>{this._textSelectionRenderManager.sync()})}_initialEditFocusListener(){this._onInputSubscription=this._editorBridgeService.state$.subscribe(e=>{if(e==null||this._editorBridgeService.isForceKeepVisible())return;const{position:t,documentLayoutObject:n,scaleX:i,editorUnitId:r}=e;if(this._getEditorObject()==null)return;const{startX:a,endX:c}=t,{textRotation:d,wrapStrategy:u,documentModel:m}=n,{a:h}=d;m.updateDocumentId(r),u===l.WrapStrategy.WRAP&&h===0&&m.updateDocumentDataPageSize((c-a)/i),this._currentUniverService.changeDoc(r,m),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0,collapsed:!0}]),this._textSelectionRenderManager.activate(mr,mr)})}_fitTextSize(e,t,n,i,r=1,s=1){const{startX:a,startY:c,endX:d,endY:u}=e,m=i.documentModel;if(m==null)return;const{actualWidth:h,actualHeight:_}=this._predictingSize(e,t,n,i,r,s),{verticalAlign:f,paddingData:S,fill:I}=i;let C=d-a,M=u-c;if(C<h&&(C=h),M<_)M=_,m.updateDocumentDataMargin(S);else{let R=S.t||0;f===l.VerticalAlign.MIDDLE?R=(M-_)/2:f===l.VerticalAlign.BOTTOM&&(R=M-_),R/=s,R=R<(S.t||0)?S.t||0:R,m.updateDocumentDataMargin({t:R})}n.calculate(),this._editAreaProcessing(C,M,e,t,I)}_predictingSize(e,t,n,i,r=1,s=1){const{startX:a,endX:c}=e,{textRotation:d,wrapStrategy:u}=i,m=i.documentModel,{a:h}=d,_=document.body.clientWidth;if(u===l.WrapStrategy.WRAP&&h===0){const{actualWidth:I,actualHeight:C}=n.getActualSize();return{actualWidth:I*r,actualHeight:C*s}}m==null||m.updateDocumentDataPageSize(_-a-t.left),n.calculate();const f=n.getActualSize();let S=c-a;return S<f.actualWidth*r+_r&&(S=f.actualWidth*r+_r),m==null||m.updateDocumentDataPageSize(S/r),m==null||m.updateDocumentRenderConfig({horizontalAlign:l.HorizontalAlign.UNSPECIFIED}),{actualWidth:S,actualHeight:f.actualHeight*s}}_editAreaProcessing(e,t,n,i,r,s=1,a=1){var R;const c=this._getEditorObject();if(c==null)return;const{startX:d,startY:u}=n,{document:m,scene:h,engine:_}=c,f=h.getViewport(Z.VIEWPORT_KEY.VIEW_MAIN),S=document.body.clientHeight-u-parseFloat(hr.sheetFooterBarHeight)-i.top-Jc*2,I=document.body.clientWidth-d-i.left;let C=t,M=f==null?void 0:f.getScrollBar();C>S?(C=S,M==null?f&&new w.ScrollBar(f,{enableHorizontal:!1}):f==null||f.resetSizeAndScrollBar()):(M=null,(R=f==null?void 0:f.getScrollBar())==null||R.dispose()),e+=(M==null?void 0:M.barSize)||0,e>I&&(e=I),h.transformByState({width:e,height:t}),m.resize(e,t),this._addBackground(h,e,t,r),requestIdleCallback(()=>{_.resizeBySize(e,C)}),this._cellEditorManagerService.setState({startX:d,startY:u,endX:e+d,endY:C+u,show:!0})}_addBackground(e,t,n,i){const r="_backgroundRectHelperColor_",s=e.getObject(r);s==null&&i==null||(s==null?e.addObjects([new w.Rect(r,{width:t,height:n,fill:i,evented:!1})],Z.DOCS_COMPONENT_MAIN_LAYER_INDEX):i==null?s.dispose():(s.setProps({fill:i}),s.transformByState({width:t,height:n})))}_initialStartEdit(){this._onInputActivateSubscription=this._editorBridgeService.visible$.subscribe(e=>{var y,T,E;const{visible:t,eventType:n,keycode:i}=e;if(t===this._editorVisiblePrevious||(this._editorVisiblePrevious=t,t===!1))return;const r=this._editorBridgeService.getState();if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u,editorUnitId:m,unitId:h,isInArrayFormulaRange:_=!1}=r,f=this._getEditorObject();if(f==null)return;const{document:S,scene:I}=f;this._contextService.setContextValue(l.FOCUSING_EDITOR,!0);const{documentModel:C}=a,M=this._docSkeletonManagerService.getSkeletonByUnitId(m);if(M==null||C==null)return;const{skeleton:R}=M;if(this._fitTextSize(s,c,R,a,d,u),n===w.DeviceInputEventType.Keyboard||n===w.DeviceInputEventType.Dblclick&&_){const O=l.Tools.deepClone(C.snapshot),x=(y=this._docViewModelManagerService.getCurrent())==null?void 0:y.docViewModel;this._resetBodyStyle(O.body),C.reset(O),x.reset(C),S.makeDirty(),(i===b.KeyCode.BACKSPACE||n===w.DeviceInputEventType.Dblclick)&&R.calculate(),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0,collapsed:!0}])}else if(n===w.DeviceInputEventType.Dblclick){const O=C.getBody().dataStream.length-2||0;(T=I.getViewport(Z.VIEWPORT_KEY.VIEW_MAIN))==null||T.scrollTo({y:1/0}),this._textSelectionManagerService.replaceTextRanges([{startOffset:O,endOffset:O,collapsed:!0}])}(E=this._renderManagerService.getRenderById(h))==null||E.scene.resetCursor()})}_resetBodyStyle(e){e.dataStream=l.DEFAULT_EMPTY_DOCUMENT_VALUE,e.textRuns!=null&&(e.textRuns.length===1?(e.textRuns[0].st=0,e.textRuns[0].ed=1):e.textRuns=void 0),e.paragraphs!=null&&(e.paragraphs.length===1?e.paragraphs[0].startIndex=0:e.paragraphs=[{startIndex:0}]),e.sectionBreaks!=null&&(e.sectionBreaks=void 0),e.tables!=null&&(e.tables=void 0),e.customRanges!=null&&(e.customRanges=void 0),e.customBlocks!=null&&(e.customBlocks=void 0)}_initialKeyboardListener(){this._textSelectionRenderManager.onInputBefore$.subscribe(e=>{this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR)||this._showEditorByKeyboard(e)})}_showEditorByKeyboard(e){if(e==null)return;const t=e.event;this._commandService.executeCommand(Ie.id,{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:t.which})}_commandExecutedListener(){const e=[Z.RichTextEditingMutation.id,Xt.id],t=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var i;if(e.includes(n.id)){const r=n.params,{unitId:s}=r,a=this._editorBridgeService.getCurrentEditorId();if(a==null)return;this._editorBridgeService.changeEditorDirty(!0);const c=(i=this._docSkeletonManagerService.getSkeletonByUnitId(a))==null?void 0:i.skeleton;if(c==null||!t.includes(s))return;const d=this._editorBridgeService.getState();if(d==null)return;const{position:u,documentLayoutObject:m,canvasOffset:h,scaleX:_,scaleY:f}=d;this._fitTextSize(u,h,c,m,_,f)}}))}_getEditorObject(){return Bt(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};mn=Kc([l.OnLifecycle(l.LifecycleStages.Steady,mn),pe(0,L.Inject(Z.DocSkeletonManagerService)),pe(1,L.Inject(Z.DocViewModelManagerService)),pe(2,l.IContextService),pe(3,l.IUniverInstanceService),pe(4,w.IRenderManagerService),pe(5,Te),pe(6,yt),pe(7,w.ITextSelectionRenderManager),pe(8,L.Inject(Z.TextSelectionManagerService)),pe(9,l.ICommandService),pe(10,L.Inject(l.LocaleService))],mn);const Sr={id:"sheet.operation.set-activate-cell-edit",type:l.CommandType.OPERATION,handler:(o,e)=>(o.get(Te).setState(e),!0)};var Qc=Object.defineProperty,qc=Object.getOwnPropertyDescriptor,ed=(o,e,t,n)=>{for(var i=n>1?void 0:n?qc(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Qc(e,t,i),i},Ue=(o,e)=>(t,n)=>e(t,n,o);let _n=class extends l.Disposable{constructor(o,e,t,n,i,r,s,a){super(),this._sheetSkeletonManagerService=o,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._editorBridgeService=i,this._selectionManagerService=r,this._selectionRenderService=s,this._themeService=a,this._initialize(),this._commandExecutedListener()}dispose(){}_initialize(){this._initialSelectionListener(),this._initialEventListener()}_initialSelectionListener(){this._selectionManagerService.selectionMoveEnd$.subscribe(o=>{this._selectionListener(o)}),this._selectionManagerService.selectionMoveStart$.subscribe(o=>{this._selectionListener(o)})}_selectionListener(o){var A,D;const e=this._selectionManagerService.getCurrent();if((e==null?void 0:e.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME)return;const t=this._sheetSkeletonManagerService.getCurrent(),n=this._getSheetObject();if(t==null||n==null)return;const{skeleton:i,unitId:r,sheetId:s}=t,{scene:a,engine:c}=n;if(o==null||o.length===0||i==null||o[o.length-1]==null)return;const{primary:d}=o[o.length-1];if(d==null)return;const{startRow:u,startColumn:m}=d,h=this._selectionRenderService.convertCellRangeToInfo(d);if(h==null)return;const _=l.makeCellToSelection(h);if(_==null)return;const f=w.getCanvasOffsetByEngine(c);let{startX:S,startY:I,endX:C,endY:M}=_;const{scaleX:R,scaleY:y}=a.getAncestorScale(),T=a.getScrollXY(this._selectionRenderService.getViewPort());S=i.convertTransformToOffsetX(S,R,T),I=i.convertTransformToOffsetY(I,y,T),C=i.convertTransformToOffsetX(C,R,T),M=i.convertTransformToOffsetY(M,y,T);const E=this._currentUniverService.getCurrentUniverSheetInstance(),O=E.getActiveSheet(),x={workbook:E,worksheet:O,workbookId:E.getUnitId(),worksheetId:O.getSheetId(),row:u,col:m},P=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(O.getCell(u,m),x);let H=P&&i.getCellDocumentModelWithFormula(P);if((!H||H.documentModel==null)&&(H=i.getBlankCellDocumentModel(P)),(A=H.documentModel)==null||A.setZoomRatio(Math.max(R,y)),(P==null?void 0:P.isInArrayFormulaRange)===!0){const N=(D=H.documentModel)==null?void 0:D.getBody();N&&(N.textRuns=[{st:0,ed:N.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}this._commandService.executeCommand(Sr.id,{position:{startX:S,startY:I,endX:C,endY:M},scaleX:R,scaleY:y,canvasOffset:f,row:u,column:m,unitId:r,sheetId:s,documentLayoutObject:H,editorUnitId:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,isInArrayFormulaRange:P==null?void 0:P.isInArrayFormulaRange})}_initialEventListener(){const o=this._getSheetObject();if(o==null)return;const{spreadsheet:e,spreadsheetColumnHeader:t,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:i}=o;e.onDblclickObserver.add(()=>{this._commandService.executeCommand(Ie.id,{visible:!0,eventType:w.DeviceInputEventType.Dblclick})}),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),i.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(Ie.id,{visible:!1,eventType:w.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_getSheetObject(){return ce(this._currentUniverService,this._renderManagerService)}_commandExecutedListener(){const o=p.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted(e=>{e.id===p.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():o.includes(e.id)&&this._hideEditor()}))}};_n=ed([l.OnLifecycle(l.LifecycleStages.Rendered,_n),Ue(0,L.Inject(k.SheetSkeletonManagerService)),Ue(1,l.IUniverInstanceService),Ue(2,l.ICommandService),Ue(3,w.IRenderManagerService),Ue(4,Te),Ue(5,L.Inject(p.SelectionManagerService)),Ue(6,ae),Ue(7,L.Inject(l.ThemeService))],_n);var td=Object.defineProperty,nd=Object.getOwnPropertyDescriptor,od=(o,e,t,n)=>{for(var i=n>1?void 0:n?nd(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&td(e,t,i),i},xt=(o,e)=>(t,n)=>e(t,n,o);let Sn=class extends l.Disposable{constructor(o,e,t,n,i){super(),this._commandService=o,this._formatPainterService=e,this._currentUniverService=t,this._renderManagerService=n,this._selectionManagerService=i,this._initialize()}_initialize(){this._commandExecutedListener(),this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this._formatPainterService.status$.subscribe(o=>{const{scene:e}=this._getSheetObject()||{};e&&(o!==fe.OFF?e.setDefaultCursor(w.CURSOR_TYPE.CELL):e.setDefaultCursor(w.CURSOR_TYPE.DEFAULT))})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{if(o.id===p.SetSelectionsOperation.id&&this._formatPainterService.getStatus()!==fe.OFF){const{selections:e}=o.params,{range:t}=e[e.length-1];this._applyFormatPainter(t),this._formatPainterService.getStatus()===fe.ONCE&&this._commandService.executeCommand(io.id)}}))}async _applyFormatPainter(o){const{styles:e,merges:t}=this._formatPainterService.getSelectionFormat(),n=this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),i=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if(!e)return;const{startRow:r,startColumn:s,endRow:a,endColumn:c}=e.getDataRange(),d=a-r+1,u=c-s+1,m=Array.from({length:o.endRow-o.startRow+1},()=>Array.from({length:o.endColumn-o.startColumn+1},()=>({}))),h=[];m.forEach((f,S)=>{f.forEach((I,C)=>{const M=S%d+r,R=C%u+s,y=e.getValue(M,R);y&&(m[S][C].s=y)})}),t.forEach(f=>{const S={startRow:f.startRow-r,startColumn:f.startColumn-s,endRow:f.endRow-r,endColumn:f.endColumn-s},I=Math.floor((o.endRow-o.startRow+1)/d),C=Math.floor((o.endColumn-o.startColumn+1)/u);for(let M=0;M<I;M++)for(let R=0;R<C;R++)h.push({startRow:S.startRow+M*d+o.startRow,startColumn:S.startColumn+R*u+o.startColumn,endRow:S.endRow+M*d+o.startRow,endColumn:S.endColumn+R*u+o.startColumn})});const _={worksheetId:i,workbookId:n,styleRange:o,styleValues:m,mergeRanges:h};await this._commandService.executeCommand(ki.id,_)}_getSheetObject(){return ce(this._currentUniverService,this._renderManagerService)}};Sn=od([l.OnLifecycle(l.LifecycleStages.Rendered,Sn),xt(0,l.ICommandService),xt(1,ot),xt(2,l.IUniverInstanceService),xt(3,w.IRenderManagerService),xt(4,L.Inject(p.SelectionManagerService))],Sn);const fn={id:"sheet.command.set-scroll-relative",type:l.CommandType.COMMAND,handler:async(o,e={offsetX:0,offsetY:0})=>{const t=o.get(l.ICommandService),n=o.get(Ne),r=o.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),s=r.getActiveSheet(),{xSplit:a,ySplit:c}=s.getConfig().freeze,d=n.getCurrentScroll(),{offsetX:u=0,offsetY:m=0}=e||{},{sheetViewStartRow:h=0,sheetViewStartColumn:_=0,offsetX:f=0,offsetY:S=0}=d||{};return t.executeCommand(tt.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:h+c,sheetViewStartColumn:_+a,offsetX:f+u,offsetY:S+m})}},ct={id:"sheet.command.scroll-view",type:l.CommandType.COMMAND,handler:async(o,e)=>{if(!e)return!1;const n=o.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),i=n.getActiveSheet(),s=o.get(Ne).getCurrentScroll();if(!i)return!1;const a=o.get(l.ICommandService),{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:u,offsetY:m}=e,{sheetViewStartColumn:h,sheetViewStartRow:_,offsetX:f,offsetY:S}=s||{};return a.executeCommand(tt.id,{unitId:n.getUnitId(),sheetId:i.getSheetId(),sheetViewStartRow:c??h,sheetViewStartColumn:d??_,offsetX:u??f,offsetY:m??S})}};l.CommandType.COMMAND;var id=Object.defineProperty,rd=Object.getOwnPropertyDescriptor,sd=(o,e,t,n)=>{for(var i=n>1?void 0:n?rd(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&id(e,t,i),i},Be=(o,e)=>(t,n)=>e(t,n,o);const ad="__SpreadsheetFreezeRowMainName__",ld="__SpreadsheetFreezeRowHeaderName__",cd="__SpreadsheetFreezeColumnMainName__",dd="__SpreadsheetFreezeColumnHeaderName__",bo=4,ud=.01;let pn=class extends l.Disposable{constructor(e,t,n,i,r,s,a,c){super();v(this,"_rowFreezeHeaderRect");v(this,"_rowFreezeMainRect");v(this,"_columnFreezeHeaderRect");v(this,"_columnFreezeMainRect");v(this,"_freezeDownObservers",[]);v(this,"_freezeMoveObservers",[]);v(this,"_freezeLeaveObservers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_viewportObservers",[]);v(this,"_changeToRow",-1);v(this,"_changeToColumn",-1);v(this,"_changeToOffsetX",0);v(this,"_changeToOffsetY",0);v(this,"_freeze_normal_header_color","");v(this,"_freeze_normal_main_color","");v(this,"_freeze_active_color","");v(this,"_freeze_hover_color","");this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=i,this._selectionRenderService=r,this._selectionManagerService=s,this._scrollManagerService=a,this._themeService=c,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener()}_createFreeze(e=0){var T;const t=this._getFreeze();if(t==null)return;const n=(T=this._sheetSkeletonManagerService.getCurrent())==null?void 0:T.skeleton;if(n==null)return;const{startRow:i,startColumn:r}=t,s=this._getPositionByIndex(i,r);if(s==null)return;const a=this._getSheetObject();if(a==null)return;const c=a.engine,d=(c==null?void 0:c.width)||0,u=(c==null?void 0:c.height)||0,m=a.scene,{startX:h,startY:_}=s,{rowTotalHeight:f,columnTotalWidth:S,rowHeaderWidthAndMarginLeft:I,columnHeaderHeightAndMarginTop:C}=n,M=d>S+I?d:S+C,R=u>f+C?u:f+C;this._changeToRow=i,this._changeToColumn=r,this._changeToOffsetX=h,this._changeToOffsetY=_;const y=bo/Math.max(m.scaleX,m.scaleY);if(e===0){this._rowFreezeHeaderRect=new w.Rect(ld,{fill:this._freeze_normal_header_color,width:I,height:y,left:0,top:_-y,zIndex:3});let E=this._freeze_normal_header_color;(i===-1||i===0)&&(E=this._freeze_normal_main_color),this._rowFreezeMainRect=new w.Rect(ad,{fill:E,width:M*2,height:y,left:I,top:_-y,zIndex:3}),m.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],Ye)}else{this._columnFreezeHeaderRect=new w.Rect(dd,{fill:this._freeze_normal_header_color,width:y,height:C,left:h-y,top:0,zIndex:3});let E=this._freeze_normal_header_color;(r===-1||r===0)&&(E=this._freeze_normal_main_color),this._columnFreezeMainRect=new w.Rect(cd,{fill:E,width:y,height:R*2,left:h-y,top:C,zIndex:3}),m.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],Ye)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const i=this._getSheetObject();if(i==null)return;const{scene:r}=i;this._freezeMoveObservers.push(t==null?void 0:t.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freeze_hover_color,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freeze_hover_color,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(t==null?void 0:t.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freeze_normal_header_color,zIndex:3}),r.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freeze_normal_header_color,zIndex:3}),r.resetCursor()})),this._freezeDownObservers.push(t==null?void 0:t.onPointerDownObserver.add(s=>{this._FreezeDown(s,t,n,e)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._FreezeDown(s,t,n,e)}))}_getCurrentLastVisibleRow(){var u;const e=this._getSheetObject();if(e==null)return;const t=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(t==null)return;const n=e.scene,i=Math.max(n.scaleX,n.scaleY),r=this._scrollManagerService.getCurrentScroll(),s=(e.engine.height-t.columnHeaderHeight)/i,a=(r==null?void 0:r.sheetViewStartRow)??0,c=a===0?-((r==null?void 0:r.offsetY)??0):t.rowHeightAccumulation[a-1]-((r==null?void 0:r.offsetY)??0);let d=0;for(let m=a,h=t.rowHeightAccumulation.length;m<h;m++)if(t.rowHeightAccumulation[m]-c>s){d=m;break}return d}_FreezeDown(e,t,n,i=0){var m;const r=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(r==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:a}=s;a.setCursor(w.CURSOR_TYPE.GRABBING),a.disableEvent();const c=this._getCurrentLastVisibleRow(),d=c===void 0?1/0:r.rowHeightAccumulation[c],u=a.getViewport(Y.VIEW_MAIN);this._moveObserver=a.onPointerMoveObserver.add(h=>{var M,R,y,T;const{startX:_,startY:f,row:S,column:I}=st(h.offsetX,h.offsetY,a,r,u);a.setCursor(w.CURSOR_TYPE.GRABBING);const C=bo/Math.max(a.scaleX,a.scaleY);i===0?((M=t.transformByState({top:Math.min(f,d)-C/2}))==null||M.setProps({fill:this._freeze_active_color}),(R=n.transformByState({top:Math.min(f,d)-C/2}))==null||R.setProps({fill:this._freeze_normal_header_color}),this._changeToRow=c===void 0?S:Math.min(S,c),this._changeToOffsetY=Math.min(f,d)):((y=t.transformByState({left:_-C/2}))==null||y.setProps({fill:this._freeze_active_color}),(T=n.transformByState({left:_-C/2}))==null||T.setProps({fill:this._freeze_normal_header_color}),this._changeToColumn=I,this._changeToOffsetX=_)}),this._upObserver=a.onPointerUpObserver.add(()=>{var O;a.resetCursor(),a.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:h,columnHeaderHeightAndMarginTop:_}=r;i===0&&(this._changeToRow===0||this._changeToRow===-1)||i===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freeze_normal_header_color}),n.setProps({fill:this._freeze_normal_main_color})):(t==null||t.setProps({fill:this._freeze_normal_header_color}),n==null||n.setProps({fill:this._freeze_normal_header_color}));const f=bo/Math.max(a.scaleX,a.scaleY);i===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:_-f}),n.transformByState({top:_-f})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:h-f}),n.transformByState({left:h-f}));const S=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:I,sheetViewStartColumn:C}=S;if(C==null||I==null)return;const M=this._currentUniverService.getCurrentUniverSheetInstance(),R=M.getActiveSheet(),y=(O=R.getConfig())==null?void 0:O.freeze;let T=(y==null?void 0:y.xSplit)||0,E=(y==null?void 0:y.ySplit)||0;i===0&&(E=this._changeToRow-I,E=E<0?0:E),i===1&&(T=this._changeToColumn-C,T=T<0?0:T),this._commandService.executeCommand(p.SetFrozenCommand.id,{startRow:this._changeToRow,startColumn:this._changeToColumn,ySplit:E,xSplit:T,workbookId:M.getUnitId(),worksheetId:R.getSheetId()})})}_updateViewport(e=-1,t=-1,n=0,i=0){var H;const r=this._getSheetObject();if(r==null)return;const{scene:s}=r,a=(H=this._sheetSkeletonManagerService.getCurrent())==null?void 0:H.skeleton;if(a==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=a,u=s.getViewport(Y.VIEW_COLUMN_LEFT),m=s.getViewport(Y.VIEW_COLUMN_RIGHT),h=s.getViewport(Y.VIEW_ROW_TOP),_=s.getViewport(Y.VIEW_ROW_BOTTOM),f=s.getViewport(Y.VIEW_LEFT_TOP),S=s.getViewport(Y.VIEW_MAIN),I=s.getViewport(Y.VIEW_MAIN_LEFT_TOP),C=s.getViewport(Y.VIEW_MAIN_LEFT),M=s.getViewport(Y.VIEW_MAIN_TOP);if(u==null||m==null||h==null||_==null||f==null||S==null||I==null||C==null||M==null)return;const{scaleX:R,scaleY:y}=s.getAncestorScale();this._viewportObservers.forEach(A=>{S.onScrollAfterObserver.remove(A)}),m.resize({left:c,top:0,height:d,right:0}),_.resize({left:0,top:d,bottom:0,width:c}),f.resize({left:0,top:0,width:c,height:d}),this._viewportObservers.push(S.onScrollAfterObserver.add(A=>{const{scrollX:D,scrollY:N,actualScrollX:B,actualScrollY:$}=A;m.updateScroll({scrollX:D,actualScrollX:B}).makeDirty(!0),_.updateScroll({scrollY:N,actualScrollY:$}).makeDirty(!0)}));let T=!0,E=!0;I.enable(),(e===-1||e===0)&&(T=!1),(t===-1||t===0)&&(E=!1);const O=a.getNoMergeCellPositionByIndexWithNoHeader(e-n,t-i,R,y),x=a.getNoMergeCellPositionByIndexWithNoHeader(e,t,R,y);I.disable(),M.disable(),C.disable(),h.disable(),u.disable(),I.resetPadding(),M.resetPadding(),C.resetPadding(),h.resetPadding(),u.resetPadding();const P=this._scrollManagerService.getCurrentScroll();if(T===!1&&E===!1)S.resize({left:c,top:d,bottom:0,right:0}),S.resetPadding(),this._commandService.executeCommand(ct.id,P??{sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0});else if(T===!0&&E===!1){const A=x.startY-O.startY;S.resize({left:c,top:d+A,bottom:0,right:0}),S.setPadding({startY:O.startY,endY:x.startY,startX:0,endX:0}),this._commandService.executeCommand(ct.id,P??{sheetViewStartRow:0,offsetY:0}),M.resize({left:c,top:d,height:A,right:0}),M.updateScroll({actualScrollY:O.startY,x:S.scrollX,actualScrollX:S.actualScrollX}).makeDirty(!0),h.resize({left:0,top:d,width:c,height:A}),h.updateScroll({actualScrollY:O.startY}).makeDirty(!0),_.resize({left:0,top:d+A,bottom:0,width:c}),this._viewportObservers.push(S.onScrollAfterObserver.add(D=>{const{scrollX:N,actualScrollX:B}=D;M.updateScroll({scrollX:N,actualScrollX:B}).makeDirty(!0)})),M.enable(),h.enable()}else if(T===!1&&E===!0){const A=x.startX-O.startX;S.resize({left:c+A,top:d,bottom:0,right:0}),S.setPadding({startX:O.startX,endX:x.startX,startY:0,endY:0}),this._commandService.executeCommand(ct.id,P??{sheetViewStartColumn:0,offsetX:0}),C.resize({left:c,top:d,width:A,bottom:0,right:0}),C.updateScroll({actualScrollX:O.startX,y:S.scrollY,actualScrollY:S.actualScrollY}).makeDirty(!0),u.resize({left:c,top:0,width:A,height:d}),u.updateScroll({actualScrollX:O.startX}).makeDirty(!0),m.resize({left:c+A,top:0,height:d,right:0}),this._viewportObservers.push(S.onScrollAfterObserver.add(D=>{const{scrollY:N,actualScrollY:B}=D;C.updateScroll({scrollY:N,actualScrollY:B}).makeDirty(!0)})),C.enable(),u.enable()}else{const A=x.startX-O.startX,D=x.startY-O.startY;S.resize({left:c+A,top:d+D,bottom:0,right:0}),S.setPadding({startY:O.startY,endY:x.startY,startX:O.startX,endX:x.startX}),this._commandService.executeCommand(ct.id,{sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),C.resize({left:c,top:d+D,width:A,bottom:0}),C.updateScroll({actualScrollX:O.startX,y:S.scrollY,actualScrollY:S.actualScrollY}).makeDirty(!0),M.resize({left:c+A,top:d,height:D,right:0}),M.updateScroll({actualScrollY:O.startY,x:S.scrollX,actualScrollX:S.actualScrollX}).makeDirty(!0),I.resize({left:c,top:d,width:A,height:D}),I.updateScroll({actualScrollX:O.startX,actualScrollY:O.startY}).makeDirty(!0),h.resize({left:0,top:d,width:c,height:D}),h.updateScroll({actualScrollY:O.startY}).makeDirty(!0),_.resize({left:0,top:d+D,bottom:0,width:c}),u.resize({left:c,top:0,width:A,height:d}),u.updateScroll({actualScrollX:O.startX}).makeDirty(!0),m.resize({left:c+A,top:0,height:d,right:0}),this._viewportObservers.forEach(N=>{S.onScrollAfterObserver.remove(N)}),this._viewportObservers.push(S.onScrollAfterObserver.add(N=>{const{scrollX:B,scrollY:$,actualScrollX:z,actualScrollY:J}=N;_.updateScroll({scrollY:$,actualScrollY:J}).makeDirty(!0),m.updateScroll({scrollX:B,actualScrollX:z}).makeDirty(!0),C.updateScroll({scrollY:$,actualScrollY:J}).makeDirty(!0),M.updateScroll({scrollX:B,actualScrollX:z}).makeDirty(!0)})),I.enable(),M.enable(),C.enable(),h.enable(),u.enable()}}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[p.SetWorksheetActiveOperation.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getConfig().freeze,{startRow:i=-1,startColumn:r=-1,ySplit:s=0,xSplit:a=0}=n;this._refreshFreeze(i,r,s,a)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()})))}_themeChange(e){this._freeze_normal_header_color=e.grey400,this._freeze_normal_main_color=new De.TinyColor(e.grey400).setAlpha(ud).toString(),this._freeze_active_color=e.primaryColor,this._freeze_hover_color=e.grey500}_commandExecutedListener(){const e=[p.SetFrozenMutation.id,Ee.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=this._currentUniverService.getCurrentUniverSheetInstance(),i=n.getActiveSheet(),r=t.params,{workbookId:s,worksheetId:a}=r;if(!(s===n.getUnitId()&&a===i.getSheetId())||i.getConfig().freeze==null)return;const{startRow:d=-1,startColumn:u=-1,ySplit:m=0,xSplit:h=0}=i.getConfig().freeze;this._refreshFreeze(d,u,m,h)}else if(t.id===p.DeltaRowHeightCommand.id){const n=this._getFreeze();t.params&&n&&t.params.anchorRow<n.startRow&&this._refreshCurrent()}else if(t.id===p.DeltaColumnWidthCommand.id){const n=this._getFreeze();t.params&&n&&t.params.anchorCol<n.startColumn&&this._refreshCurrent()}else if(t.id===p.SetWorksheetRowAutoHeightMutation.id){const n=t.params,i=this._getFreeze();if(i&&i.startRow>-1&&n.rowsAutoHeightInfo.some(r=>r.row<i.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}}))}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,i,r,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(i=this._rowFreezeMainRect)==null||i.dispose(),(r=this._columnFreezeHeaderRect)==null||r.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(a=>{t.onPointerDownObserver.remove(a),t.onPointerMoveObserver.remove(a),t.onPointerLeaveObserver.remove(a)}),t.onPointerEnterObserver.remove(this._moveObserver),t.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(e,t){var u;const n=this._getSheetObject();if(n==null)return;const{scaleX:i,scaleY:r}=n.scene.getAncestorScale(),s=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton,a=s==null?void 0:s.getNoMergeCellPositionByIndex(e,t,i,r);if(s==null)return;if(a!=null&&(!isNaN(a.endX)||!isNaN(a.endY)))return a;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=s;return{startX:c,endX:c,startY:d,endY:d}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrent())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return ce(this._currentUniverService,this._renderManagerService)}_refreshFreeze(e,t,n,i){this._clearFreeze(),this._createFreeze(0),this._createFreeze(1),this._updateViewport(e,t,n,i)}};pn=sd([l.OnLifecycle(l.LifecycleStages.Rendered,pn),Be(0,L.Inject(k.SheetSkeletonManagerService)),Be(1,l.IUniverInstanceService),Be(2,l.ICommandService),Be(3,w.IRenderManagerService),Be(4,ae),Be(5,L.Inject(p.SelectionManagerService)),Be(6,L.Inject(Ne)),Be(7,L.Inject(l.ThemeService))],pn);var Mo=(o=>(o[o.NORMAL=0]="NORMAL",o[o.HIGHLIGHT=1]="HIGHLIGHT",o))(Mo||{});const hd="rgba(0, 0, 0, 0.15)",xe="rgb(0, 0, 0)",gn="rgb(255, 255, 255, 1)";class md extends w.Shape{constructor(t,n){super(t,n);v(this,"_size",12);v(this,"_iconRatio",.4);v(this,"_mode",0);this.setShapeProps(n)}setShapeProps(t){t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),this.transformByState({width:this._size,height:this._size})}_draw(t){this._mode===1&&w.Rect.drawWith(t,{width:this._size,height:this._size,radius:this._size,fill:hd});const n=this._size*.5*this._iconRatio,i=Math.PI/180*60,r=n*Math.sin(i),s=n*Math.cos(i);w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-r+this._size/2,y:-s+this._size/2},{x:r+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:xe})}}var _d=Object.defineProperty,Sd=Object.getOwnPropertyDescriptor,fd=(o,e,t,n)=>{for(var i=n>1?void 0:n?Sd(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&_d(e,t,i),i},Pt=(o,e)=>(t,n)=>e(t,n,o);const pd="__SpreadsheetHeaderMenuSHAPEControllerShape__",gd="__SpreadsheetHeaderMenuMAINControllerShape__",vd="rgba(0, 0, 0, 0.1)";let vn=class extends l.Disposable{constructor(e,t,n,i,r){super();v(this,"_hoverRect");v(this,"_hoverMenu");v(this,"_currentColumn",1/0);v(this,"_observers",[]);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._contextMenuService=i,this._selectionManagerService=r,this._initialize()}dispose(){var i,r;(i=this._hoverRect)==null||i.dispose(),(r=this._hoverMenu)==null||r.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerEnterObserver.remove(s),t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerEnterObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)})}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._hoverRect=new w.Rect(pd,{fill:vd,evented:!1}),this._hoverMenu=new md(gd,{zIndex:100,visible:!1}),t.addObjects([this._hoverRect,this._hoverMenu],Ye),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetColumnHeader:n,spreadsheetRowHeader:i}=t,r=e===0?i:n;this._observers.push(r==null?void 0:r.onPointerEnterObserver.add(()=>{var s;(s=this._hoverRect)==null||s.show()})),this._observers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var I,C,M;const a=(I=this._sheetSkeletonManagerService.getCurrent())==null?void 0:I.skeleton;if(a==null)return;const c=this._getSheetObject();if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u}=a,{startX:m,startY:h,endX:_,endY:f,column:S}=st(s.offsetX,s.offsetY,c.scene,a);if(e===0)(C=this._hoverRect)==null||C.transformByState({width:d,height:f-h,left:0,top:h});else{if(this._currentColumn=S,(M=this._hoverRect)==null||M.transformByState({width:_-m,height:u,left:m,top:0}),this._hoverMenu==null)return;if(_-m<u*2){this._hoverMenu.hide();return}const R=u*.8;this._hoverMenu.transformByState({left:_-u,top:u/2-R/2}),this._hoverMenu.setShapeProps({size:R}),this._hoverMenu.show()}})),this._observers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,a;(s=this._hoverRect)==null||s.hide(),(a=this._hoverMenu)==null||a.hide()}))}_initialHoverMenu(){this._hoverMenu!=null&&(this._hoverMenu.onPointerEnterObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:Mo.HIGHLIGHT,visible:!0}),e.scene.setCursor(w.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:Mo.NORMAL,visible:!1}),e.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(e=>{const t=this._getSheetObject();if(t==null)return;const n=this._currentColumn,i=this._selectionManagerService.getSelectionRanges();(i==null?void 0:i.find(s=>{const{startColumn:a,endColumn:c}=s;return n>=a&&a<=c}))==null?t.spreadsheetColumnHeader.onPointerDownObserver.notifyObservers(e):(e.stopPropagation(),e.preventDefault(),this._contextMenuService.triggerContextMenu(e,q.COL_HEADER_CONTEXT_MENU))}))}_getSheetObject(){return ce(this._currentUniverService,this._renderManagerService)}};vn=fd([l.OnLifecycle(l.LifecycleStages.Rendered,vn),Pt(0,L.Inject(k.SheetSkeletonManagerService)),Pt(1,l.IUniverInstanceService),Pt(2,w.IRenderManagerService),Pt(3,b.IContextMenuService),Pt(4,L.Inject(p.SelectionManagerService))],vn);var Cd=Object.defineProperty,Id=Object.getOwnPropertyDescriptor,bd=(o,e,t,n)=>{for(var i=n>1?void 0:n?Id(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Cd(e,t,i),i},dt=(o,e)=>(t,n)=>e(t,n,o);const Md="__SpreadsheetHeaderMoveControllerBackground__",Rd="__SpreadsheetHeaderMoveControllerShapeLine__",wd="rgba(0, 0, 0, 0.1)",yd="rgb(119, 119, 119)",Td=4;let Cn=class extends l.Disposable{constructor(e,t,n,i,r,s){super();v(this,"_startOffsetX",-1/0);v(this,"_startOffsetY",-1/0);v(this,"_moveHelperBackgroundShape");v(this,"_moveHelperLineShape");v(this,"_sheetObject");v(this,"_rowOrColumnDownObservers",[]);v(this,"_rowOrColumnMoveObservers",[]);v(this,"_rowOrColumnLeaveObservers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_scrollTimer");v(this,"_changeFromColumn",-1);v(this,"_changeFromRow",-1);v(this,"_changeToColumn",-1);v(this,"_changeToRow",-1);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._commandService=i,this._selectionRenderService=r,this._selectionManagerService=s,this._initialize()}dispose(){var r,s;(r=this._moveHelperBackgroundShape)==null||r.dispose(),(s=this._moveHelperLineShape)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n,scene:i}=e;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(a=>{t.onPointerDownObserver.remove(a),n.onPointerDownObserver.remove(a)}),i.onPointerMoveObserver.remove(this._moveObserver),i.onPointerUpObserver.remove(this._upObserver),this._scrollTimer.dispose()}_initialize(){const e=this._getSheetObject();e!=null&&(this._sheetObject=e,this._initialRowOrColumn(0),this._initialRowOrColumn(1))}_initialRowOrColumn(e=0){const{spreadsheetColumnHeader:t,spreadsheetRowHeader:n,scene:i}=this._sheetObject,r=e===0?n:t;this._rowOrColumnMoveObservers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var m;const a=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(a==null)return;const{row:c,column:d}=st(s.offsetX,s.offsetY,i,a);if(this._checkInHeaderRange(e===0?c:d,e)===!1){i.resetCursor(),this._selectionRenderService.enableSelection();return}i.setCursor(w.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,a;(s=this._moveHelperBackgroundShape)==null||s.hide(),(a=this._moveHelperLineShape)==null||a.hide(),i.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(r==null?void 0:r.onPointerDownObserver.add(s=>{var M;const a=(M=this._sheetSkeletonManagerService.getCurrent())==null?void 0:M.skeleton;if(a==null)return;const{offsetX:c,offsetY:d}=s,u=i.getRelativeCoord(w.Vector2.FromArray([c,d])),{x:m,y:h}=u;this._startOffsetX=m,this._startOffsetY=h;const{row:_,column:f}=st(s.offsetX,s.offsetY,i,a);e===0?this._changeFromRow=_:this._changeFromColumn=f;const S=this._checkInHeaderRange(e===0?_:f,e);if(S===!1)return;this._newBackgroundAndLine(),i.setCursor(w.CURSOR_TYPE.GRABBING),i.disableEvent();const I=w.ScrollTimer.create(i),C=i.getViewport(Y.VIEW_MAIN);I.startScroll(m,h,C),this._scrollTimer=I,this._moveObserver=i.onPointerMoveObserver.add(R=>{const{offsetX:y,offsetY:T}=R,{x:E,y:O}=i.getRelativeCoord(w.Vector2.FromArray([y,T]));i.setCursor(w.CURSOR_TYPE.GRABBING),this._columnMoving(E,O,S,e),I.scrolling(E,O,()=>{this._columnMoving(E,O,S,e)})}),this._upObserver=i.onPointerUpObserver.add(()=>{var R;this._disposeBackgroundAndLine(),i.resetCursor(),i.enableEvent(),this._clearObserverEvent(),(R=this._scrollTimer)==null||R.dispose(),e===0?(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1&&this._commandService.executeCommand(p.MoveRowsCommand.id,{fromRow:this._changeFromRow,toRow:this._changeToRow}),this._changeToRow=this._changeFromRow=-1):(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1&&this._commandService.executeCommand(p.MoveColsCommand.id,{fromCol:this._changeFromColumn,toCol:this._changeToColumn}),this._changeToColumn=this._changeFromColumn=-1)})}))}_columnMoving(e,t,n,i){var J,G,Q,j,ee,K,ke;const{scene:r}=this._sheetObject,s=(J=this._sheetSkeletonManagerService.getCurrent())==null?void 0:J.skeleton;if(s==null)return;const{rowHeaderWidth:a,columnHeaderHeight:c,rowTotalHeight:d,columnTotalWidth:u}=s,m=r.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:h,scaleY:_}=r.getAncestorScale(),f=s.getCellPositionByOffset(e,t,h,_,m),{row:S,column:I}=f,C=s.getNoMergeCellPositionByIndex(S,I,h,_),{startX:M,startY:R,endX:y,endY:T}=C,E=this._selectionRenderService.convertRangeDataToSelection(n.range);if(E==null)return;const O=Math.max(h,h),{startX:x,endX:P,startY:H,endY:A,startRow:D,startColumn:N,endRow:B,endColumn:$}=E;i===0?(G=this._moveHelperBackgroundShape)==null||G.transformByState({height:A-H,width:u+a,left:0,top:H+(t-this._startOffsetY)/O}):(Q=this._moveHelperBackgroundShape)==null||Q.transformByState({height:d+c,width:P-x,left:x+(e-this._startOffsetX)/O,top:0}),(j=this._moveHelperBackgroundShape)==null||j.show();const z=Td/O;if(i===0){let de=0;if(S<=D)de=R-z/2,this._changeToRow=S;else if(S>B)de=T-z/2,this._changeToRow=S+1;else return;(ee=this._moveHelperLineShape)==null||ee.transformByState({height:z,width:u,left:a,top:de})}else{let de=0;if(I<=N)de=M-z/2,this._changeToColumn=I;else if(I>$)de=y-z/2,this._changeToColumn=I+1;else return;(K=this._moveHelperLineShape)==null||K.transformByState({height:d,width:z,left:de,top:c})}(ke=this._moveHelperLineShape)==null||ke.show()}_checkInHeaderRange(e,t=0){const n=this._selectionManagerService.getSelections(),i=n==null?void 0:n.find(s=>{const a=s.range,{startRow:c,endRow:d,startColumn:u,endColumn:m}=a;return t===1?e>=u&&e<=m:e>=c&&e<=d}),r=i==null?void 0:i.range;return i==null||r==null||r.rangeType===l.RANGE_TYPE.ALL||r.rangeType===l.RANGE_TYPE.NORMAL||r.rangeType===l.RANGE_TYPE.ROW&&t!==0||r.rangeType===l.RANGE_TYPE.COLUMN&&t!==1?!1:i}_clearObserverEvent(){const{scene:e}=this._sheetObject;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const{scene:e}=this._sheetObject;this._moveHelperBackgroundShape=new w.Rect(Md,{fill:wd,evented:!1,zIndex:100}),this._moveHelperLineShape=new w.Rect(Rd,{fill:yd,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],Ye)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}_getSheetObject(){return ce(this._currentUniverService,this._renderManagerService)}};Cn=bd([l.OnLifecycle(l.LifecycleStages.Rendered,Cn),dt(0,L.Inject(k.SheetSkeletonManagerService)),dt(1,l.IUniverInstanceService),dt(2,w.IRenderManagerService),dt(3,l.ICommandService),dt(4,ae),dt(5,L.Inject(p.SelectionManagerService))],Cn);var Ro=(o=>(o[o.VERTICAL=0]="VERTICAL",o[o.HORIZONTAL=1]="HORIZONTAL",o))(Ro||{});const Ed="rgba(120, 120, 120, 0.01)",wo="rgb(68, 71, 70)",At=12,yo=4;class fr extends w.Shape{constructor(t,n){super(t,n);v(this,"_size",At);v(this,"_color",wo);v(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(t){let{width:n,height:i}=this,r=0,s=0;const a=this.getScene(),{scaleX:c,scaleY:d}=a.getAncestorScale(),u=Math.max(c,d),m=At/u,h=yo/u;this.mode===0?(n=h,r=m-h):(i=h,s=m-h),w.Rect.drawWith(t,{width:this.width,height:this.height,left:0,top:0,fill:Ed}),w.Rect.drawWith(t,{width:n,height:i,fill:wo,radius:h}),t.save(),t.transform(1,0,0,1,r,s),w.Rect.drawWith(t,{width:n,height:i,fill:wo,radius:h}),t.restore()}setShapeProps(t){return t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),t!=null&&t.color&&(this._color=t.color),this.mode===0?this.transformByState({width:At,height:this.size}):this.transformByState({width:this.size,height:At}),this}}var Od=Object.defineProperty,xd=Object.getOwnPropertyDescriptor,Pd=(o,e,t,n)=>{for(var i=n>1?void 0:n?xd(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Od(e,t,i),i},In=(o,e)=>(t,n)=>e(t,n,o);const Ad="__SpreadsheetHeaderResizeControllerShapeRow__",kd="__SpreadsheetHeaderResizeControllerShapeColumn__",pr="__SpreadsheetHeaderResizeControllerShapeHelper__",gr="rgb(199, 199, 199)",Hd=2;let bn=class extends l.Disposable{constructor(e,t,n,i){super();v(this,"_currentRow",0);v(this,"_currentColumn",0);v(this,"_rowResizeRect");v(this,"_columnResizeRect");v(this,"_Observers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_resizeHelperShape");v(this,"_startOffsetX",1/0);v(this,"_startOffsetY",1/0);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=i,this._initialize()}dispose(){var i,r;(i=this._rowResizeRect)==null||i.dispose(),this._rowResizeRect=null,(r=this._columnResizeRect)==null||r.dispose(),this._columnResizeRect=null;const e=this._getSheetObject();if(e==null)throw new Error("sheetObject is null");const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._Observers.forEach(s=>{t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)}),this._Observers=[]}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._rowResizeRect=new fr(Ad,{visible:!1,mode:Ro.HORIZONTAL,zIndex:100}),this._columnResizeRect=new fr(kd,{visible:!1,mode:Ro.VERTICAL,zIndex:100}),t.addObjects([this._rowResizeRect,this._columnResizeRect],Ye),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:n,spreadsheetColumnHeader:i,scene:r}=t,s=e===0?n:i;this._Observers.push(s==null?void 0:s.onPointerMoveObserver.add((a,c)=>{var O;const d=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(d==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:m}=d,{startX:h,startY:_,endX:f,endY:S,row:I,column:C}=st(a.offsetX,a.offsetY,r,d),M=qt(a.offsetX,a.offsetY,r),{scaleX:R,scaleY:y}=r.getAncestorScale(),T=Math.max(R,y),E=At/T;if(e===0){let x=_-E/2;if(M.y<=_+E/2&&M.y>=_)this._currentRow=I-1;else if(M.y>=S-E/2&&M.y<=S)this._currentRow=I,x=S-E/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const P=u/3;this._rowResizeRect.transformByState({left:u/2-P/2,top:x}),this._rowResizeRect.setShapeProps({size:P}),this._rowResizeRect.show()}else{let x=h-E/2;if(M.x<=h+E/2&&M.x>=h)this._currentColumn=C-1;else if(M.x>=f-E/2&&M.x<=f)this._currentColumn=C,x=f-E/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const P=m*.7;this._columnResizeRect.transformByState({left:x,top:m/2-P/2}),this._columnResizeRect.setShapeProps({size:P}),this._columnResizeRect.show()}})),this._Observers.push(s==null?void 0:s.onPointerLeaveObserver.add((a,c)=>{var d,u;(d=this._rowResizeRect)==null||d.hide(),(u=this._columnResizeRect)==null||u.hide()}))}_initialHoverResize(e=0){const t=this._getSheetObject();if(t==null)return;const{scene:n}=t,i=e===0?this._rowResizeRect:this._columnResizeRect;if(i==null)return;const r=n.getEngine(),s=(r==null?void 0:r.width)||0,a=(r==null?void 0:r.height)||0;i.onPointerEnterObserver.add(()=>{i!=null&&(i.show(),n.setCursor(e===0?w.CURSOR_TYPE.ROW_RESIZE:w.CURSOR_TYPE.COLUMN_RESIZE))}),i.onPointerLeaveObserver.add(()=>{i!=null&&(i.hide(),n.resetCursor())}),i.onPointerDownObserver.add((c,d)=>{var Q,j,ee,K,ke,de,Ce;const u=(Q=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Q.skeleton;if(u==null)return;const m=this._getSheetObject();if(m==null)return;const{scene:h}=m,_=h.getViewport(Y.VIEW_MAIN),f=(((ee=(j=_==null?void 0:_.getScrollBar())==null?void 0:j.horizonBarRect)==null?void 0:ee.height)||0)+10,S=(((ke=(K=_==null?void 0:_.getScrollBar())==null?void 0:K.verticalBarRect)==null?void 0:ke.width)||0)+10,I=qt(c.offsetX,c.offsetY,h),{scaleX:C,scaleY:M}=h.getAncestorScale();this._startOffsetX=I.x,this._startOffsetY=I.y;const R=u.getOffsetByPositionX(this._currentColumn),y=u.getOffsetByPositionY(this._currentRow),T=u.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn,C,M);let E=!1,O=0,x=0;const{columnTotalWidth:P,rowHeaderWidth:H,rowTotalHeight:A,columnHeaderHeight:D}=u,N=s>P+H?s:P+H,B=a>A+D?a:A+D,$=Math.max(C,M),z=yo/$;e===0?this._resizeHelperShape=new w.Rect(pr,{width:N,height:z,fill:gr,left:0,top:y-z/2}):this._resizeHelperShape=new w.Rect(pr,{width:z,height:B,fill:gr,left:R-z/2,top:0});const J=((de=this._columnResizeRect)==null?void 0:de.left)||0,G=((Ce=this._rowResizeRect)==null?void 0:Ce.top)||0;h.addObject(this._resizeHelperShape,Ye),h.disableEvent(),this._moveObserver=h.onPointerMoveObserver.add(pt=>{var Nr,Ur,Br,Vr,Fr,jr;const Qe=h.getRelativeCoord(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),He=h.getScrollXYByRelativeCoords(Qe,_),me=qt(pt.offsetX,pt.offsetY,h),{x:Vn,y:Fn}=me,{scaleX:rm,scaleY:sm}=h.getAncestorScale(),am=Math.max(rm,sm),jn=yo/am;O=Vn-this._startOffsetX-jn/2,x=Fn-this._startOffsetY-jn/2,Math.abs(e===0?x:O)>=Hd&&(E=!0),e===0?(x<-(T.endY-T.startY)+2&&(x=-(T.endY-T.startY)+2),x>a-f+He.y-T.startY&&(x=a-f+He.y-T.startY),E&&((Nr=this._resizeHelperShape)==null||Nr.transformByState({top:y+x}),(Ur=this._rowResizeRect)==null||Ur.transformByState({top:G+x+jn/2}),(Br=this._rowResizeRect)==null||Br.show(),h.setCursor(w.CURSOR_TYPE.ROW_RESIZE))):(O<-(T.endX-T.startX)+2&&(O=-(T.endX-T.startX)+2),O>s-S+He.x-T.startX&&(O=s-S+He.x-T.startX),E&&((Vr=this._resizeHelperShape)==null||Vr.transformByState({left:R+O}),(Fr=this._columnResizeRect)==null||Fr.transformByState({left:J+O+jn/2}),(jr=this._columnResizeRect)==null||jr.show(),h.setCursor(w.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=h.onPointerUpObserver.add(pt=>{var me,Vn,Fn;const Qe=ce(this._currentUniverService,this._renderManagerService);if(Qe==null)return;this._clearObserverEvent(),(me=this._resizeHelperShape)==null||me.dispose(),this._resizeHelperShape=null;const{scene:He}=Qe;He.enableEvent(),E&&(He.resetCursor(),(Vn=this._rowResizeRect)==null||Vn.hide(),(Fn=this._columnResizeRect)==null||Fn.hide(),e===0?this._commandService.executeCommand(p.DeltaRowHeightCommand.id,{deltaY:x,anchorRow:this._currentRow}):this._commandService.executeCommand(p.DeltaColumnWidthCommand.id,{deltaX:O,anchorCol:this._currentColumn}))})}),i.onDblclickObserver.add(()=>{var c;if(e===0){const d=this._getSheetObject();if(d==null)return;const{scene:u}=d;u.resetCursor(),this._commandService.executeCommand(p.SetWorksheetRowIsAutoHeightCommand.id),(c=this._rowResizeRect)==null||c.hide()}})}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_getSheetObject(){return ce(this._currentUniverService,this._renderManagerService)}};bn=Pd([l.OnLifecycle(l.LifecycleStages.Rendered,bn),In(0,L.Inject(k.SheetSkeletonManagerService)),In(1,l.IUniverInstanceService),In(2,l.ICommandService),In(3,w.IRenderManagerService)],bn);var To=(o=>(o[o.ROW=0]="ROW",o[o.COLUMN=1]="COLUMN",o))(To||{});const kt=12,Dd=.4;class vr extends w.Shape{constructor(t,n,i){super(t,n);v(this,"_size",kt);v(this,"_iconRatio",Dd);v(this,"_hovered",!0);v(this,"_hasPrevious",!0);v(this,"_hasNext",!0);v(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>i==null?void 0:i())}setShapeProps(t){t.type!==void 0&&(this._unhideType=t.type),t.hovered!==void 0&&(this._hovered=t.hovered),t.hasPrevious!==void 0&&(this._hasPrevious=t.hasPrevious),t.hasNext!==void 0&&(this._hasNext=t.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(t){this._unhideType===0?this._drawOnRow(t):this._drawOnCol(t)}_drawOnRow(t){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(t,{width:this._size,height:this._size,stroke:xe,fill:gn}):w.Rect.drawWith(t,{width:this._size,height:2*this._size,stroke:xe,fill:gn}));const n=this._size*.5*this._iconRatio,i=Math.PI/3,r=n*Math.cos(i),s=n*Math.sin(i);if(this._hasPrevious&&w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+r},{x:this._size/2+s,y:this._size/2+r}]],fill:xe}),this._hasNext){const a=this._hasPrevious?3:1;w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size*a/2+s},{x:this._size/2-s,y:this._size*a/2-r},{x:this._size/2+s,y:this._size*a/2-r}]],fill:xe})}}_drawOnCol(t){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(t,{width:this._size,height:this._size,stroke:xe,fill:gn}):w.Rect.drawWith(t,{width:2*this._size,height:this._size,stroke:xe,fill:gn}));const n=this._size*.5*this._iconRatio,i=Math.PI/3,r=n*Math.cos(i),s=n*Math.sin(i);if(this._hasPrevious&&w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-r+this._size/2,y:this._size/2},{x:this._size/2+s,y:this._size/2-s},{x:this._size/2+s,y:this._size/2+s}]],fill:xe}),this._hasNext){const a=this._hasPrevious?3:1;w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:r+this._size*a/2,y:this._size/2},{x:-s+this._size*a/2,y:this._size/2-s},{x:-s+this._size*a/2,y:this._size/2+s}]],fill:xe})}}}var Ld=Object.defineProperty,Nd=Object.getOwnPropertyDescriptor,Ud=(o,e,t,n)=>{for(var i=n>1?void 0:n?Nd(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Ld(e,t,i),i},Mn=(o,e)=>(t,n)=>e(t,n,o);const Cr="__SpreadsheetHeaderUnhideSHAPEControllerShape__",Bd=[p.SetRowHiddenMutation.id,p.SetRowVisibleMutation.id,p.SetColHiddenMutation.id,p.SetColVisibleMutation.id];let Rn=class extends l.RxDisposable{constructor(e,t,n,i){super();v(this,"_shapes",new Map);this._sheetSkeletonManagerService=e,this._cmdSrv=t,this._univerInstanceService=n,this._rendererManagerService=i,this._init()}dispose(){super.dispose()}_init(){if(!this._getSheetObject())return;const t=this._univerInstanceService.getCurrentUniverSheetInstance(),n=t.getActiveSheet();n&&this._initForWorksheet(t,n),this._sheetSkeletonManagerService.currentSkeleton$.pipe(V.takeUntil(this.dispose$)).subscribe(i=>{if(i){const r=this._univerInstanceService.getUniverSheetInstance(i.unitId),s=r.getSheetBySheetId(i.sheetId);this._updateWorksheet(r,s)}}),this.disposeWithMe(this._cmdSrv.onCommandExecuted(i=>{if(!Bd.includes(i.id)||!i.params||!i.params.workbookId||!i.params.worksheetId)return;const r=this._univerInstanceService.getUniverSheetInstance(i.params.workbookId),s=r==null?void 0:r.getSheetBySheetId(i.params.worksheetId);s&&this._updateWorksheet(r,s)}))}_initForWorksheet(e,t){var h;const n=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(!n)return;const i=t.getHiddenRows(),r=t.getHiddenCols(),s=this._getSheetObject();if(!s)return;const{scene:a}=s,c=t.getRowCount(),d=i.map(_=>{const{startRow:f,endRow:S}=_,I=lo(f,0,a,n),C=f!==0,M=S!==c-1;return new vr(Cr,{type:To.ROW,hovered:!1,hasPrevious:C,hasNext:M,top:I.startY-(C?kt:0),left:I.startX-kt},()=>this._cmdSrv.executeCommand(p.SetSpecificRowsVisibleCommand.id,{workbookId:e.getUnitId(),worksheetId:t.getSheetId(),ranges:[_]}))}),u=t.getColumnCount(),m=r.map(_=>{const{startColumn:f,endColumn:S}=_,I=lo(0,f,a,n),C=f!==0,M=S!==u-1;return new vr(Cr,{type:To.COLUMN,hovered:!1,hasPrevious:C,hasNext:M,left:I.startX-(C?kt:0),top:20-kt},()=>this._cmdSrv.executeCommand(p.SetSpecificColsVisibleCommand.id,{workbookId:e.getUnitId(),worksheetId:t.getSheetId(),ranges:[_]}))});a.addObjects(m,$i),a.addObjects(d,$i),this._shapes.set(l.getWorksheetUID(e,t),{cols:m,rows:d})}_updateWorksheet(e,t){const n=this._shapes.get(l.getWorksheetUID(e,t));n==null||n.cols.forEach(i=>i.dispose()),n==null||n.rows.forEach(i=>i.dispose()),this._initForWorksheet(e,t)}_getSheetObject(){return ce(this._univerInstanceService,this._rendererManagerService)}};Rn=Ud([l.OnLifecycle(l.LifecycleStages.Rendered,Rn),Mn(0,L.Inject(k.SheetSkeletonManagerService)),Mn(1,l.ICommandService),Mn(2,l.IUniverInstanceService),Mn(3,w.IRenderManagerService)],Rn);var Vd=Object.defineProperty,Fd=Object.getOwnPropertyDescriptor,jd=(o,e,t,n)=>{for(var i=n>1?void 0:n?Fd(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Vd(e,t,i),i},Eo=(o,e)=>(t,n)=>e(t,n,o);let wn=class extends l.Disposable{constructor(e,t,n){super();v(this,"_initialize",()=>{const e=new l.DisposableCollection;this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{e.dispose();const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(i=>{e.add(l.toDisposable(i.selectionMoved$.subscribe(r=>{if(!r)return;const s=i.model.getRange(),a={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType},c={startRow:r.startRow,startColumn:r.startColumn,endRow:r.endRow,endColumn:r.endColumn,rangeType:s.rangeType};if(a.startRow===c.startRow&&a.startColumn===c.startColumn||c.startRow<0||c.startColumn<0)return;const d={fromRange:a,toRange:c};this._commandService.executeCommand(p.MoveRangeCommand.id,d)})))})})))});this._selectionRenderService=e,this._selectionManagerService=t,this._commandService=n,this._initialize()}};wn=jd([l.OnLifecycle(l.LifecycleStages.Steady,wn),Eo(0,L.Inject(ae)),Eo(1,L.Inject(p.SelectionManagerService)),Eo(2,L.Inject(l.ICommandService))],wn);var Wd=Object.defineProperty,zd=Object.getOwnPropertyDescriptor,Xd=(o,e,t,n)=>{for(var i=n>1?void 0:n?zd(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Wd(e,t,i),i},ut=(o,e)=>(t,n)=>e(t,n,o);let Ht=class extends l.Disposable{constructor(o,e,t,n,i,r){super(),this._sheetSkeletonManagerService=o,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionManagerService=i,this._scrollManagerService=r,this._initialize()}dispose(){super.dispose()}_initialize(){this._scrollEventBinding(),this._scrollSubscribeBinding(),this._skeletonListener()}_scrollEventBinding(){var t;const o=(t=this._getSheetObject())==null?void 0:t.scene;if(o==null)return;const e=o.getViewport(Y.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(n=>{var h;const i=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(i==null||n.isTrigger===!1)return;const r=this._getSheetObject();if(i==null||r==null)return;const{actualScrollX:s=0,actualScrollY:a=0}=n,{row:c,column:d,rowOffset:u,columnOffset:m}=i.getDecomposedOffset(s,a);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:m,offsetY:u})})))}scrollToVisible(o){var H,A,D;let e,t;const n=this._selectionManagerService.getLast();if(n==null)return;const{actualRow:i,actualColumn:r}=n.primary,{rowHeightAccumulation:s,columnWidthAccumulation:a}=((H=this._sheetSkeletonManagerService.getCurrent())==null?void 0:H.skeleton)??{};if(s==null||a==null)return;const c=(A=this._getSheetObject())==null?void 0:A.scene;if(c==null)return;const d=c.getViewport(Y.VIEW_MAIN);if(d==null||(d.getBounding(),this._getSheetObject()==null))return;const m=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startColumn:h,startRow:_,ySplit:f,xSplit:S}=m.getFreeze(),I=d.getBounding(),C=(D=this._sheetSkeletonManagerService.getCurrent())==null?void 0:D.skeleton;if(C==null)return;const{startRow:M,startColumn:R,endRow:y,endColumn:T}=C.getRowColumnSegment(I);if(i>=_&&r>=h-S&&(i<=M&&(e=i),i>=y)){const N=s[i]-d.height;for(let B=M;B<=i;B++)if(s[B]>=N){e=B+1;break}}if(r>=h&&i>=_-f&&(r<=R&&(t=r),r>=T)){const N=a[r]-d.width;for(let B=R;B<=r;B++)if(a[B]>=N){t=B+1;break}}if(e===void 0&&t===void 0)return;const{sheetViewStartColumn:E,sheetViewStartRow:O,offsetX:x,offsetY:P}=this._scrollManagerService.getCurrentScroll()||{};this._commandService.executeCommand(ct.id,{sheetViewStartRow:e??O,sheetViewStartColumn:t??E,offsetX:t===void 0?x:0,offsetY:e===void 0?P:0})}_scrollSubscribeBinding(){this.disposeWithMe(l.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(o=>{var I;const e=(I=this._sheetSkeletonManagerService.getCurrent())==null?void 0:I.skeleton,t=this._getSheetObject();if(e==null||t==null)return;const n=t.scene,{scaleX:i,scaleY:r}=t.scene.getAncestorScale(),s=n.getViewport(Y.VIEW_MAIN);if(s==null)return;if(o==null){s.scrollTo({x:0,y:0});return}const{sheetViewStartRow:a,sheetViewStartColumn:c,offsetX:d,offsetY:u}=o,{startX:m,startY:h}=e.getCellByIndexWithNoHeader(a,c,i,r),_=m+d,f=h+u,S=s.getBarScroll(_,f);s.scrollTo(S)})))}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(o=>{if(o==null)return;const{unitId:e,sheetId:t}=o;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(o),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:t}))})))}_updateSceneSize(o){var c;if(o==null)return;const{skeleton:e,unitId:t}=o,n=(c=this._renderManagerService.getRenderById(t))==null?void 0:c.scene;if(e==null||n==null)return;const{rowTotalHeight:i,columnTotalWidth:r,rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=e;n==null||n.transformByState({width:s+r,height:a+i})}_getSheetObject(){return ce(this._currentUniverService,this._renderManagerService)}};Ht=Xd([l.OnLifecycle(l.LifecycleStages.Rendered,Ht),ut(0,L.Inject(k.SheetSkeletonManagerService)),ut(1,l.IUniverInstanceService),ut(2,l.ICommandService),ut(3,w.IRenderManagerService),ut(4,L.Inject(p.SelectionManagerService)),ut(5,L.Inject(Ne))],Ht);var Yd=Object.defineProperty,$d=Object.getOwnPropertyDescriptor,Zd=(o,e,t,n)=>{for(var i=n>1?void 0:n?$d(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Yd(e,t,i),i},Ir=(o,e)=>(t,n)=>e(t,n,o);const Gd=[_e.id,We.id];let yn=class extends l.Disposable{constructor(o,e){super(),this._commandService=o,this._scrollController=e,this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(Gd.includes(t.id)){const n=t.params;this._scrollController.scrollToVisible(n.direction)}}))}};yn=Zd([l.OnLifecycle(l.LifecycleStages.Rendered,yn),Ir(0,l.ICommandService),Ir(1,L.Inject(Ht))],yn);var Kd=Object.defineProperty,Jd=Object.getOwnPropertyDescriptor,Qd=(o,e,t,n)=>{for(var i=n>1?void 0:n?Jd(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Kd(e,t,i),i},Ze=(o,e)=>(t,n)=>e(t,n,o);let Tn=class extends l.Disposable{constructor(o,e,t,n,i,r,s){super(),this._sheetSkeletonManagerService=o,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=i,this._selectionManagerService=r,this._themeService=s,this._initialize()}_initialize(){const o=this._currentUniverService.getCurrentUniverSheetInstance(),e=o.getActiveSheet(),t=this._getSheetObject();if(t==null)return;this._initViewMainListener(t),this._initRowHeader(t),this._initColumnHeader(t),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener();const n=o.getUnitId(),i=e.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:i})}_initViewMainListener(o){const{spreadsheet:e,scene:t}=o,n=t.getViewport(Y.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((i,r)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(i,e.zIndex+1,l.RANGE_TYPE.NORMAL,n),i.button!==2&&r.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const o=this._selectionManagerService.getSelections(),e=this._selectionManagerService.getCurrent();if(!(o==null||(e==null?void 0:e.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME)){this._selectionRenderService.reset();for(const t of o){if(t==null)continue;const n=this._selectionRenderService.convertSelectionRangeToData(t);n.style=p.getNormalSelectionStyle(this._themeService),this._selectionRenderService.addControlToCurrentByRangeData(n)}}})))}_initRowHeader(o){const{spreadsheetRowHeader:e,spreadsheet:t,scene:n}=o,i=n.getViewport(Y.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((r,s)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(r,((t==null?void 0:t.zIndex)||1)+1,l.RANGE_TYPE.ROW,i,w.ScrollTimerType.Y),r.button!==2&&s.stopPropagation()})))}_initColumnHeader(o){const{spreadsheetColumnHeader:e,spreadsheet:t,scene:n}=o,i=n.getViewport(Y.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((r,s)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(r,((t==null?void 0:t.zIndex)||1)+1,l.RANGE_TYPE.COLUMN,i,w.ScrollTimerType.X),r.button!==2&&s.stopPropagation()})))}_initSelectionChangeListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(o=>{if(this._selectionRenderService.reset(),o!=null)for(const e of o){if(e==null)continue;const t=this._selectionRenderService.convertSelectionRangeToData(e);this._selectionRenderService.addControlToCurrentByRangeData(t)}})))}_initUserActionSyncListener(){this._selectionRenderService.selectionMoveStart$.subscribe(o=>{this._move(o,p.SelectionMoveType.MOVE_START)}),this._selectionRenderService.selectionMoving$.subscribe(o=>{this._move(o,p.SelectionMoveType.MOVING)}),this._selectionRenderService.selectionMoveEnd$.subscribe(o=>{this._move(o,p.SelectionMoveType.MOVE_END)})}_move(o,e){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getUnitId(),i=t.getActiveSheet().getSheetId(),r=this._selectionManagerService.getCurrent();o==null||o.length===0||this._commandService.executeCommand(p.SetSelectionsOperation.id,{unitId:n,sheetId:i,type:e,pluginName:(r==null?void 0:r.pluginName)||p.NORMAL_SELECTION_PLUGIN_NAME,selections:o.map(s=>p.convertSelectionDataToRange(s))})}_getSheetObject(){return ce(this._currentUniverService,this._renderManagerService)}_initCommandListener(){const o=[Ee.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(o.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),i=e.params,{workbookId:r,worksheetId:s}=i;if(!(r===t.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this._sheetSkeletonManagerService.currentSkeleton$.subscribe(o=>{if(o==null)return;const{unitId:e,sheetId:t,skeleton:n}=o,i=this._renderManagerService.getRenderById(e);if(i==null)return;const{scene:r}=i,s=r.getViewport(Y.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,r,s);const a=this._selectionManagerService.getCurrent(),c=(a==null?void 0:a.pluginName)||p.NORMAL_SELECTION_PLUGIN_NAME;this._selectionManagerService.setCurrentSelection({pluginName:c,unitId:e,sheetId:t}),c===p.NORMAL_SELECTION_PLUGIN_NAME&&this._selectionManagerService.getLast()==null&&this._selectionManagerService.add([this._getZeroRange(n)])})}_getZeroRange(o){const e=o.mergeData;return p.transformCellDataToSelectionData(0,0,e)||{range:{startRow:0,startColumn:0,endRow:0,endColumn:0},primary:{actualRow:0,actualColumn:0,startRow:0,startColumn:0,endRow:0,endColumn:0,isMerged:!1,isMergedMainCell:!1},style:null}}};Tn=Qd([l.OnLifecycle(l.LifecycleStages.Rendered,Tn),Ze(0,L.Inject(k.SheetSkeletonManagerService)),Ze(1,l.IUniverInstanceService),Ze(2,l.ICommandService),Ze(3,w.IRenderManagerService),Ze(4,ae),Ze(5,L.Inject(p.SelectionManagerService)),Ze(6,L.Inject(l.ThemeService))],Tn);var qd=Object.defineProperty,eu=Object.getOwnPropertyDescriptor,tu=(o,e,t,n)=>{for(var i=n>1?void 0:n?eu(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&qd(e,t,i),i},ht=(o,e)=>(t,n)=>e(t,n,o);let En=class extends l.Disposable{constructor(o,e,t,n,i,r){super(),this._sheetSkeletonManagerService=o,this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._selectionRenderService=i,this._selectionManagerService=r,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(o=>{if(o==null)return;const{skeleton:e,unitId:t,sheetId:n}=o,i=this._currentUniverService.getUniverSheetInstance(t),r=i==null?void 0:i.getSheetBySheetId(n);if(i==null||r==null)return;const s=this._renderManagerService.getRenderById(t);if(s==null)return;const{mainComponent:a,components:c,scene:d}=s,u=a,m=c.get(se.ROW),h=c.get(se.COLUMN),_=c.get(se.LEFT_TOP),{rowHeaderWidth:f,columnHeaderHeight:S}=e;u==null||u.updateSkeleton(e),m==null||m.updateSkeleton(e),h==null||h.updateSkeleton(e),_==null||_.transformByState({width:f,height:S})})))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{var n,i;const e=this._currentUniverService.getCurrentUniverSheetInstance(),t=e.getUnitId();if(p.COMMAND_LISTENER_SKELETON_CHANGE.includes(o.id)){const r=e.getActiveSheet(),s=r.getSheetId(),a=o.params,{workbookId:c,worksheetId:d}=a;if(!(c===e.getUnitId()&&d===r.getSheetId()))return;o.id!==p.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:t,sheetId:s,commandId:o.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:t,sheetId:s,commandId:o.id})}else p.COMMAND_LISTENER_VALUE_CHANGE.includes(o.id)&&this._sheetSkeletonManagerService.reCalculate();(i=(n=this._renderManagerService.getRenderById(t))==null?void 0:n.mainComponent)==null||i.makeDirty()}))}};En=tu([l.OnLifecycle(l.LifecycleStages.Rendered,En),ht(0,L.Inject(k.SheetSkeletonManagerService)),ht(1,l.IUniverInstanceService),ht(2,w.IRenderManagerService),ht(3,l.ICommandService),ht(4,ae),ht(5,L.Inject(p.SelectionManagerService))],En);const Pe={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(o,e)=>{const t=o.get(l.ICommandService),n=o.get(l.IUndoRedoService),i=o.get(l.IUniverInstanceService),r=o.get(b.IConfirmService),s=o.get(l.LocaleService),a=e.workbookId,c=e.worksheetId,d=e.selections,u=p.getAddMergeMutationRangeByType(d,e.value),m=i.getUniverSheetInstance(a).getSheetBySheetId(c),h=[],_=[],f=xi(m,u);if(f&&!await r.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const S={workbookId:a,worksheetId:c,ranges:u},I={workbookId:a,worksheetId:c,ranges:u};h.push({id:p.RemoveWorksheetMergeMutation.id,params:S}),h.push({id:p.AddWorksheetMergeMutation.id,params:I});const C=p.RemoveMergeUndoMutationFactory(o,S),M=p.AddMergeUndoMutationFactory(o,I);if(_.push({id:p.RemoveWorksheetMergeMutation.id,params:M}),_.push({id:p.AddWorksheetMergeMutation.id,params:C}),f){const y=Pi(o,a,m,u);h.unshift(...y.redos),_.push(...y.undos)}return l.sequenceExecute(h,t).result?(n.pushUndoRedo({unitID:a,undoMutations:_,redoMutations:h}),!0):!1}},br={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async o=>{const e=o.get(l.ICommandService),n=o.get(p.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const r=o.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!r)return!1;const s=r.getActiveSheet();if(!s)return!1;const a=r.getUnitId(),c=s.getSheetId();return e.executeCommand(Pe.id,{selections:n,workbookId:a,worksheetId:c})}},Mr={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async o=>{const e=o.get(l.ICommandService),n=o.get(p.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const r=o.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!r)return!1;const s=r.getActiveSheet();if(!s)return!1;const a=r.getUnitId(),c=s.getSheetId();return e.executeCommand(Pe.id,{value:l.Dimension.COLUMNS,selections:n,workbookId:a,worksheetId:c})}},Rr={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async o=>{const e=o.get(l.ICommandService),n=o.get(p.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const r=o.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!r)return!1;const s=r.getActiveSheet();if(!s)return!1;const a=r.getUnitId(),c=s.getSheetId();return e.executeCommand(Pe.id,{value:l.Dimension.ROWS,selections:n,workbookId:a,worksheetId:c})}},wr={id:"sheet.command.refill",type:l.CommandType.COMMAND,handler:async(o,e)=>(o.get(Mt).setApplyType(e.type),!0)},mt=L.createIdentifier("univer.sheetbar-service");class nu extends l.Disposable{constructor(){super();v(this,"renameId$");v(this,"scroll$");v(this,"scrollX$");v(this,"addSheet$");v(this,"_renameId$");v(this,"_scroll$");v(this,"_scrollX$");v(this,"_addSheet$");v(this,"_currentHandler",null);this._renameId$=new V.Subject,this.renameId$=this._renameId$.asObservable(),this._scroll$=new V.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new V.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new V.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(t){this._renameId$.next(t)}setScroll(t){this._scroll$.next(t)}setScrollX(t){this._scrollX$.next(t)}setAddSheet(t){this._addSheet$.next(t)}triggerSheetBarMenu(){var t;(t=this._currentHandler)==null||t.handleSheetBarMenu()}registerSheetBarMenuHandler(t){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=t,l.toDisposable(()=>{this._currentHandler=null})}}const yr={id:"sheet.command.rename-sheet",type:l.CommandType.OPERATION,handler:async(o,e)=>{const t=o.get(mt);return e&&t.setRenameId(e.worksheetId),!0}},On={id:"sheet.command.change-zoom-ratio",type:l.CommandType.COMMAND,handler:async(o,e)=>{if(!e)return!1;const{delta:t,reset:n}=e,i=o.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),r=i.getActiveSheet(),s=i.getUnitId(),a=r.getSheetId();let c=n?100:Math.round((r.getConfig().zoomRatio+t)*100);c=Math.max(ao[0],c),c=Math.min(ao[1],c);const d=c/100;return o.get(l.ICommandService).executeCommand(Ee.id,{workbookId:s,worksheetId:a,zoomRatio:d})}},Oo={id:"sheet.command.set-zoom-ratio",type:l.CommandType.COMMAND,handler:async(o,e)=>{if(!e)return!1;const{workbookId:t,worksheetId:n,zoomRatio:i}=e;return o.get(l.ICommandService).executeCommand(Ee.id,{workbookId:t,worksheetId:n,zoomRatio:i})}},Tr={id:"ui-sheet.command.show-menu-list",type:l.CommandType.OPERATION,handler:async o=>(o.get(mt).triggerSheetBarMenu(),!0)},ou=()=>g.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),g.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),g.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),g.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),g.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),g.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),g.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),g.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),g.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),g.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),g.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),g.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),g.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),g.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),g.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),g.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),g.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),g.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),g.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),g.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),g.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),g.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),g.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),g.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),g.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),g.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),g.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),iu=()=>g.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),g.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),g.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),g.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),g.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),g.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),g.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),g.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),g.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),g.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),g.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),g.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),g.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),g.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),g.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),g.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),g.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),g.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),g.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),g.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),g.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),g.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),g.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),g.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),g.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),g.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),g.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),g.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),ru=()=>g.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),g.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),g.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),g.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),g.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),g.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),g.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),g.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),g.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),g.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),g.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),g.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),g.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),g.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),g.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),g.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),g.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),g.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),g.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),g.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),su=()=>g.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),g.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),g.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),g.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),g.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),g.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),g.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),g.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),g.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),g.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),g.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),g.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),g.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),g.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),g.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),g.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),g.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),g.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),g.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),g.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),g.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),g.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),g.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),g.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),g.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),g.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),g.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),g.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),g.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),g.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),g.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),g.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),g.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),g.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),g.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),g.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),g.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),g.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),g.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),g.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),g.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),g.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),g.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),g.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),g.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),g.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),g.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),g.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),g.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),g.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),g.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),g.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),au=()=>g.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),lu=()=>g.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),g.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),g.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),g.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),g.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),g.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),g.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),g.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),g.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),g.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),g.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),g.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),g.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),g.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),g.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),g.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),g.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),g.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),cu=()=>g.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),g.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),g.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),g.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),g.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),g.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),g.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),g.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),g.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),g.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),g.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),g.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),g.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),g.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),g.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),g.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),g.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),g.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),g.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),g.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),du=()=>g.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),g.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),g.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),g.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),g.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),g.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),g.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),g.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),g.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),g.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),g.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),g.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),g.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),g.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),g.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),g.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),g.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),g.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),g.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),g.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),uu=()=>g.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),Er=()=>g.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function Or(o){const{type:e=l.BorderStyleTypes.THIN}=o;switch(e){case l.BorderStyleTypes.DASH_DOT:return g.jsx(ou,{});case l.BorderStyleTypes.DASH_DOT_DOT:return g.jsx(iu,{});case l.BorderStyleTypes.DASHED:return g.jsx(ru,{});case l.BorderStyleTypes.HAIR:return g.jsx(su,{});case l.BorderStyleTypes.MEDIUM:return g.jsx(au,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT:return g.jsx(lu,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return g.jsx(cu,{});case l.BorderStyleTypes.MEDIUM_DASHED:return g.jsx(du,{});case l.BorderStyleTypes.THICK:return g.jsx(uu,{});case l.BorderStyleTypes.THIN:return g.jsx(Er,{});default:return g.jsx(Er,{})}}const Ae={uiPluginSheetsBorderPanel:"univer-ui-plugin-sheets-border-panel",uiPluginSheetsBorderPanelPosition:"univer-ui-plugin-sheets-border-panel-position",uiPluginSheetsBorderPanelPositionItem:"univer-ui-plugin-sheets-border-panel-position-item",uiPluginSheetsBorderPanelStyles:"univer-ui-plugin-sheets-border-panel-styles",uiPluginSheetsBorderPanelBoard:"univer-ui-plugin-sheets-border-panel-board",uiPluginSheetsBorderPanelButton:"univer-ui-plugin-sheets-border-panel-button",uiPluginSheetsBorderPanelMoreIcon:"univer-ui-plugin-sheets-border-panel-more-icon"},xr=`${it}_BORDER_PANEL_COMPONENT`,Pr=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"InnerBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"InnerBorder",value:"vertical"}],hu=[{label:l.BorderStyleTypes.THIN,value:l.BorderStyleTypes.THIN},{label:l.BorderStyleTypes.HAIR,value:l.BorderStyleTypes.HAIR},{label:l.BorderStyleTypes.DOTTED,value:l.BorderStyleTypes.DOTTED},{label:l.BorderStyleTypes.DASHED,value:l.BorderStyleTypes.DASHED},{label:l.BorderStyleTypes.DASH_DOT,value:l.BorderStyleTypes.DASH_DOT},{label:l.BorderStyleTypes.DASH_DOT_DOT,value:l.BorderStyleTypes.DASH_DOT_DOT},{label:l.BorderStyleTypes.MEDIUM,value:l.BorderStyleTypes.MEDIUM},{label:l.BorderStyleTypes.MEDIUM_DASHED,value:l.BorderStyleTypes.MEDIUM_DASHED},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:l.BorderStyleTypes.THICK,value:l.BorderStyleTypes.THICK}];function mu(o){const e=F.useDependency(b.ComponentManager),{onChange:t,value:n}=o;function i(a,c){t==null||t({...n,[c]:a})}function r(a){const c=e.get(a);return c&&g.jsx(c,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function s(a){a.stopPropagation()}return g.jsxs("section",{className:Ae.uiPluginSheetsBorderPanel,children:[g.jsx("div",{className:Ae.uiPluginSheetsBorderPanelPosition,children:Pr.map(a=>g.jsx("div",{className:Ae.uiPluginSheetsBorderPanelPositionItem,onClick:()=>i(a.value,"type"),children:r(a.icon)},a.value))}),g.jsxs("div",{className:Ae.uiPluginSheetsBorderPanelStyles,children:[g.jsx("div",{children:g.jsx(te.Dropdown,{align:{offset:[0,18]},overlay:g.jsx("section",{className:Ae.uiPluginSheetsBorderPanelBoard,onClick:s,children:g.jsx(te.ColorPicker,{onChange:a=>i(a,"color")})}),children:g.jsxs("a",{className:Ae.uiPluginSheetsBorderPanelButton,onClick:s,children:[g.jsx(la,{extend:{colorChannel1:n.color??"rgb(var(--primary-color))"}}),g.jsx("span",{className:Ae.uiPluginSheetsBorderPanelMoreIcon,children:g.jsx(Kn,{})})]})})}),g.jsx("div",{children:g.jsx(te.Dropdown,{align:{offset:[0,18]},overlay:g.jsx("section",{onClick:s,children:g.jsx(te.Menu,{children:hu.map(a=>g.jsx(te.MenuItem,{eventKey:a.value.toString(),onClick:()=>i(a.value,"style"),children:g.jsx(Or,{type:a.value})},a.value))})}),children:g.jsxs("a",{className:Ae.uiPluginSheetsBorderPanelButton,onClick:s,children:[g.jsx(Or,{type:l.BorderStyleTypes.THIN}),g.jsx("span",{className:Ae.uiPluginSheetsBorderPanelMoreIcon,children:g.jsx(Kn,{})})]})})})]})]})}const _u={countBar:"univer-count-bar"},Su=[50,75,100,125,150,175,200,400];function fu(){const o=F.useDependency(l.ICommandService),e=F.useDependency(l.IUniverInstanceService),t=r(),[n,i]=U.useState(t);U.useEffect(()=>o.onCommandExecuted(c=>{if(c.id===Ee.id||c.id===p.SetWorksheetActivateCommand.id){const d=r();i(d)}}).dispose,[o]);function r(){const a=e.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()*100||100;return Math.round(a)}function s(a){i(a);const c=e.getCurrentUniverSheetInstance();if(!c)return;const d=c.getActiveSheet();if(!d)return;const u=a/100;o.executeCommand(Oo.id,{workbookId:c.getUnitId(),worksheetId:d.getSheetId(),zoomRatio:u})}return g.jsx(te.Slider,{min:ao[0],value:n,shortcuts:Su,onChange:s})}function pu(o){return g.jsx("section",{className:_u.countBar,children:g.jsx(fu,{})})}const Ar={editorContainer:"univer-editor-container",editorInput:"univer-editor-input"},xn=-1e3,kr={width:0,height:0,top:xn,left:xn},gu=()=>{const[o,e]=U.useState({...kr}),t=U.useRef(null),n=F.useDependency(w.IRenderManagerService),i=F.useDependency(yt);return U.useEffect(()=>{const r=t.current;if(r==null)return;const s=n.currentRender$.pipe(hc(()=>{var c;const a=(c=n.getRenderById(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:c.engine;return a==null||a.setContainer(r),i.state$})).subscribe(a=>{if(a==null)return;const{startX:c=xn,startY:d=xn,endX:u=0,endY:m=0,show:h=!1}=a;if(!h)e({...kr});else{e({width:u-c,height:m-d,left:c-1.5,top:d-1.5});const _=t.current;if(!_)return;const{left:f,top:S,width:I,height:C}=_.getBoundingClientRect();i.setRect({left:f,top:S,width:I,height:C})}});return()=>{s.unsubscribe()}},[]),U.useEffect(()=>{i.setFocus(!0)},[o]),g.jsx("div",{className:Ar.editorContainer,style:{left:o.left,top:o.top,width:o.width,height:o.height},children:g.jsx("div",{className:Ar.editorInput,ref:t})})},oe={formulaBox:"univer-formula-box",nameRanges:"univer-name-ranges",nameRangesInput:"univer-name-ranges-input",formulaBar:"univer-formula-bar",formulaIcon:"univer-formula-icon",formulaIconWrapper:"univer-formula-icon-wrapper",iconContainer:"univer-icon-container",iconContainerSuccess:"univer-icon-container-success",formulaActive:"univer-formula-active",iconContainerError:"univer-icon-container-error",formulaInput:"univer-formula-input",formulaContent:"univer-formula-content",arrowContainer:"univer-arrow-container"};function vu(){const[o,e]=U.useState(oe.formulaGrey),[t,n]=U.useState(0),i=U.useRef(null),r=F.useDependency(w.IRenderManagerService),s=F.useDependency(en),a=F.useDependency(Te);U.useEffect(()=>{const h=i.current;if(!h)return;const _=r.currentRender$.subscribe(S=>{var C;if(S!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const I=(C=r.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:C.engine;I==null||I.setContainer(h)}),f=new ResizeObserver(()=>{const S=h.getBoundingClientRect();s.setPosition(S)});return f.observe(h),a.visible$.subscribe(S=>{e(S.visible?oe.formulaActive:oe.formulaGrey)}),()=>{f.unobserve(h),_.unsubscribe()}},[]);function c(){n(t===0?1:0)}function d(){a.isVisible().visible&&a.changeVisible({visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:b.KeyCode.ESC})}function u(){a.isVisible().visible&&a.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown})}function m(){s.handleFxBtnClick(!0)}return g.jsxs("div",{className:oe.formulaBox,style:{height:t===0?"28px":"82px"},children:[g.jsx("div",{className:oe.nameRanges,children:g.jsx("div",{className:oe.nameRangesInput})}),g.jsxs("div",{className:oe.formulaBar,children:[g.jsx("div",{className:oe.formulaIcon,children:g.jsxs("div",{className:oe.formulaIconWrapper,children:[g.jsx("span",{className:gt(oe.iconContainer,oe.iconContainerError,o),onClick:d,children:g.jsx(Gs,{})}),g.jsx("span",{className:gt(oe.iconContainer,oe.iconContainerSuccess,o),onClick:u,children:g.jsx($t,{})}),g.jsx("span",{className:oe.iconContainer,onClick:m,children:g.jsx(na,{})})]})}),g.jsxs("div",{className:oe.formulaInput,children:[g.jsx("div",{className:oe.formulaContent,ref:i}),g.jsx("div",{className:oe.arrowContainer,onClick:c,children:t===0?g.jsx(ci,{}):g.jsx(ci,{style:{transform:"rotateZ(180deg)"}})})]})]})]})}const Ge={operateContainer:"univer-operate-container",autoFillPopupMenu:"univer-auto-fill-popup-menu",autoFillPopupMenuItem:"univer-auto-fill-popup-menu-item",autoFillPopupMenuItemIcon:"univer-auto-fill-popup-menu-item-icon",autoFillPopupMenuItemTitle:"univer-auto-fill-popup-menu-item-title",autoFillPopupMenuItemHide:"univer-auto-fill-popup-menu-item-hide",btnContainer:"univer-btn-container",btnContainerExpand:"univer-btn-container-expand"},Cu=()=>{const[,o]=U.useState({});return U.useCallback(()=>o({}),[])},Iu=()=>{var Q;const o=F.useDependency(l.ICommandService),e=F.useDependency(k.SheetSkeletonManagerService),t=F.useDependency(l.IUniverInstanceService),n=F.useDependency(w.IRenderManagerService),i=F.useDependency(ae),r=F.useDependency(Mt),s=F.useDependency(l.LocaleService),[a,c]=U.useState([]),[d,u]=U.useState(!1),[m,h]=U.useState({row:-1,col:-1}),[_,f]=U.useState(W.SERIES),[S,I]=U.useState(!1),C=()=>{I(!0)},M=()=>{I(!1)},R=Cu(),y=ce(t,n);if(y==null)return null;const{scene:T}=y;if(U.useEffect(()=>{const j=[Ie.id,Ft.id,Ee.id,p.SetRangeValuesMutation.id];return o.onCommandExecuted(K=>{if(K.id===Vt.id){const{endColumn:ke,endRow:de}=(K==null?void 0:K.params).selectionRange;h({row:de,col:ke})}K.id===tt.id&&R(),j.includes(K.id)&&h({row:-1,col:-1})}).dispose},[R,o]),U.useEffect(()=>l.toDisposable(r.menu$.subscribe(ee=>{c(ee.map(K=>({...K,index:ee.indexOf(K)})))})).dispose,[r]),U.useEffect(()=>l.toDisposable(r.applyType$.subscribe(ee=>{f(ee)})).dispose,[r]),U.useEffect(()=>{function j(){u(!1)}return document.addEventListener("wheel",j),()=>{document.removeEventListener("wheel",j)}},[d]),m.col<0||m.row<0)return null;const E=(Q=e.getCurrent())==null?void 0:Q.skeleton,O=i.getViewPort(),x=T==null?void 0:T.scaleX,P=T==null?void 0:T.scaleY,H=T==null?void 0:T.getScrollXY(O);if(!x||!T||!x||!P||!H)return null;const A=(E==null?void 0:E.getNoMergeCellPositionByIndex(m.row,m.col,x,P).endX)||0,D=(E==null?void 0:E.getNoMergeCellPositionByIndex(m.row,m.col,x,P).endY)||0,N=E==null?void 0:E.convertTransformToOffsetX(A,x,H),B=E==null?void 0:E.convertTransformToOffsetY(D,P,H);if(N==null||B==null)return null;const $=j=>{u(j)},z=j=>{o.executeCommand(wr.id,{type:j.value})},J=d||S,G=a.filter(j=>!j.disable);return g.jsx("div",{onMouseEnter:C,onMouseLeave:M,style:{left:`${N+2}px`,top:`${B+2}px`,position:"absolute"},children:g.jsx(te.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:g.jsx("ul",{className:Ge.autoFillPopupMenu,children:G.map(j=>g.jsxs("li",{onClick:()=>z(j),className:Ge.autoFillPopupMenuItem,children:[g.jsx("span",{className:Ge.autoFillPopupMenuItemIcon,children:j.value===_&&g.jsx($t,{style:{color:"rgb(var(--green-700, #409f11))"}})}),g.jsx("span",{className:Ge.autoFillPopupMenuItemTitle,children:s.t(j.label)})]},j.index))}),visible:d,onVisibleChange:$,children:g.jsxs("div",{className:gt(Ge.btnContainer,{[Ge.btnContainerExpand]:d}),children:[g.jsx(Ys,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),J&&g.jsx(Kn,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},bu=()=>g.jsx("div",{className:Ge.operateContainer,children:g.jsx(Iu,{})}),Pn={sheetBar:"univer-sheet-bar",sheetBarOptions:"univer-sheet-bar-options",sheetBarOptionsDivider:"univer-sheet-bar-options-divider"},Mu={sheetBarBtn:"univer-sheet-bar-btn"};function An(o){const{children:e,className:t,style:n,disabled:i=!1,onClick:r,...s}=o,a=c=>{if(i){c.preventDefault();return}r&&r(c)};return g.jsx("button",{className:Mu.sheetBarBtn,style:n,disabled:i,onClick:a,...s,children:e})}const Ve={sheetBarMenu:"univer-sheet-bar-menu",sheetBarMenuItem:"univer-sheet-bar-menu-item",sheetBarMenuItemIcon:"univer-sheet-bar-menu-item-icon",sheetBarMenuItemHide:"univer-sheet-bar-menu-item-hide",sheetBarMenuItemSelect:"univer-sheet-bar-menu-item-select",sheetBarMenuItemLabel:"univer-sheet-bar-menu-item-label"};function Ru(o){const{style:e}=o,[t,n]=U.useState([]),[i,r]=U.useState(!1),s=F.useDependency(l.IUniverInstanceService),a=F.useDependency(l.ICommandService),c=F.useDependency(mt),d=s.getCurrentUniverSheetInstance(),u=S=>{const{sheetId:I}=S;I&&(S.hidden?a.executeCommand(p.SetWorksheetShowCommand.id,{value:I}):S.selected||a.executeCommand(p.SetWorksheetActivateCommand.id,{workbookId:d.getUnitId(),worksheetId:I}),r(!1))};U.useEffect(()=>{h();const S=new l.DisposableCollection;return S.add(m()),S.add(c.registerSheetBarMenuHandler({handleSheetBarMenu:_})),()=>{S.dispose()}},[]);const m=()=>a.onCommandExecuted(S=>{switch(S.id){case p.SetWorksheetHideMutation.id:case p.RemoveSheetMutation.id:case p.SetWorksheetNameMutation.id:case p.InsertSheetMutation.id:case p.SetWorksheetOrderMutation.id:case p.SetWorksheetActiveOperation.id:h();break}}),h=()=>{const I=d.getSheets().map((C,M)=>({label:C.getName(),index:`${M}`,sheetId:C.getSheetId(),hidden:C.isSheetHidden()===l.BooleanNumber.TRUE,selected:C.getStatus()===l.BooleanNumber.TRUE}));n(I)};function _(){r(!0)}const f=S=>{r(S)};return g.jsx(te.Dropdown,{placement:"topLeft",trigger:["click"],overlay:g.jsx("ul",{className:Ve.sheetBarMenu,style:{...e},children:t.map(S=>g.jsxs("li",{onClick:()=>u(S),className:S.selected?`${Ve.sheetBarMenuItem} ${Ve.sheetBarMenuItemSelect}`:S.hidden?`${Ve.sheetBarMenuItem} ${Ve.sheetBarMenuItemHide}`:Ve.sheetBarMenuItem,children:[g.jsx("span",{className:Ve.sheetBarMenuItemIcon,children:S.selected?g.jsx($t,{}):S.hidden?g.jsx(ea,{}):g.jsx($t,{})}),g.jsx("span",{className:Ve.sheetBarMenuItemLabel,children:S.label})]},S.index))}),visible:i,onVisibleChange:f,children:g.jsx(An,{children:g.jsx(Js,{})})})}const ge={slideTabBarContainer:"univer-slide-tab-bar-container",slideTabBar:"univer-slide-tab-bar",slideTabItem:"univer-slide-tab-item",slideTabActive:"univer-slide-tab-active",slideTabSpan:"univer-slide-tab-span",slideTabSpanEdit:"univer-slide-tab-span-edit"};function wu(o){const{sheetId:e,label:t,color:n,selected:i}=o,[r,s]=U.useState(!1),[a,c]=U.useState(i),d=F.useDependency(l.ICommandService),u=F.useDependency(l.ThemeService);U.useEffect(()=>{c(i)},[i]);const m=_=>{s(_)},h=_=>{const f=u.getCurrentTheme(),S=f.textColor,I=f.colorWhite;return new De.TinyColor(_).isDark()?I:S};return g.jsx(te.Dropdown,{visible:r,trigger:["contextMenu"],overlay:g.jsx(b.Menu,{menuType:q.SHEET_BAR,onOptionSelect:_=>{const{label:f,value:S}=_;d.executeCommand(f,{value:S,worksheetId:e}),s(!1)}}),onVisibleChange:m,children:g.jsx("div",{"data-id":e,className:a?`${ge.slideTabActive} ${ge.slideTabItem}`:ge.slideTabItem,style:{backgroundColor:!a&&n?n:"",color:!a&&n?h(n):"",boxShadow:a&&n?`0px 0px 12px rgba(0, 0, 0, 0.2), inset 0px -2px 0px 0px ${n}`:""},children:g.jsx("span",{className:ge.slideTabSpan,children:t})},e)})}const yu={easeOutStrong(o,e,t,n){return-t*((o=o/n-1)*o*o*o-1)+e},backOut(o,e,t,n,i){return typeof i>"u"&&(i=.7),t*((o=o/n-1)*o*((i+1)*o+i)+1)+e}},Tu={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(o){},success(o){},cancel(o){},complete(o){}};class Eu{constructor(e){v(this,"_config");v(this,"_status",0);v(this,"_start",0);v(this,"_handle",0);v(this,"_delayHandle",null);this._config={...Tu,...e},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...e){let t=0;return new Promise(n=>{for(let i=0;i<e.length;i++){const r=e[i],s=r._config,a=s.success;s.loop||(s.success=d=>{t++,a&&a.call(r,d),t===e.length&&n()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let e=Date.now()-this._start;e=e>=this._config.duration?this._config.duration:e;const n=yu[this._config.type](e,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(n),this._status===1){this._config.cancel(n),this._config.complete(n);return}if(e===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class Ke{constructor(e,t){v(this,"_slideTabItem");v(this,"_animate");v(this,"_midline",0);v(this,"_translateX");v(this,"_scrollbar");v(this,"_slideTabBar");v(this,"_editMode");v(this,"_placeholder");this._slideTabItem=e,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=t,this._placeholder=null,this._scrollbar=t.getScrollbar(),this.update()}static midline(e){return e.getBoundingRect().x+e.getBoundingRect().width/2}static leftLine(e){return e.getBoundingRect().x}static rightLine(e){return e.getBoundingRect().x+e.getBoundingRect().width}static make(e,t){const n=[];return e.forEach(i=>n.push(new Ke(i,t))),n}getSlideTabItem(){return this._slideTabItem}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}primeval(){return this._slideTabItem}translateX(e){return this._translateX=e,this._slideTabItem.style.transform=`translateX(${e}px)`,this.getTranslateXDirection()}editor(e){let t=!0;if(this._editMode===!1){const n=this.primeval().querySelector("span"),i=d=>{if(!this.emptyCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",i),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",a),n.removeEventListener("input",c),n.removeEventListener("keydown",r),n.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const u=(n==null?void 0:n.innerText)||"",m=this.getId();this._slideTabBar.getConfig().onChangeName(m,u)}e&&e(d)}};let r=d=>{n&&(d.stopPropagation(),d.key==="Enter"&&n.blur())};const s=d=>{t=!1},a=d=>{t=!0},c=d=>{if(!n)return;const u=50;setTimeout(()=>{if(t){const m=n.innerText;m.length>u&&(n.innerText=m.substring(0,u),Dt.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",i),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",a),n.addEventListener("input",c),n.addEventListener("keydown",r),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,Dt.keepSelectAll(n))}}emptyCheck(){const e=this.primeval().querySelector("span");return e&&e.innerText.trim()===""?(this._slideTabBar.getConfig().onEmptyAlert(),!0):!1}animate(){return{translateX:e=>{this._translateX!==e&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new Eu({begin:this._translateX,end:e,receive:t=>{this._slideTabItem.style.transform=`translateX(${t}px)`}}),this._translateX=e,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(e){this._slideTabItem.after(e._slideTabItem||e)}update(){this._midline=Ke.midline(this)}disableFixed(){if(this._placeholder){const e=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("box-shadow"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("boxSizing"),this._slideTabItem.style.removeProperty("fontSize"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("borderRadius"),this._placeholder.after(this._slideTabItem),e.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const e=document.createElement("div"),t=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),i=this._slideTabItem.querySelector("span");if(this._placeholder=e,this._placeholder.style.width=`${t.width}px`,this._placeholder.style.height=`${t.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,i){const r=getComputedStyle(i).padding;this._slideTabItem.style.padding=r}this._slideTabItem.style.boxSizing=n.boxSizing,this._slideTabItem.style.fontSize=n.fontSize,this._slideTabItem.style.color=n.color,this._slideTabItem.style.borderRadius=n.borderRadius,this._slideTabItem.style.left=`${t.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${t.y}px`,this._slideTabItem.style.width=`${t.width}px`,this._slideTabItem.style.height=`${t.height}px`,this._slideTabItem.style.boxShadow="0px 0px 1px 1px rgba(82,82,82,0.1)",this._slideTabItem.style.position="fixed",this._slideTabItem.after(e),document.body.appendChild(this._slideTabItem)}addEventListener(e,t,n){this._slideTabItem.addEventListener(e,t,n)}removeEventListener(e,t,n){this._slideTabItem.removeEventListener(e,t,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const e=this._slideTabItem.getBoundingClientRect();return e.x+=this._scrollbar.getScrollX(),e}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const e=Ke.midline(this);return e>this._midline?1:e<this._midline?-1:0}equals(e){return e&&e._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class Ou{constructor(e){v(this,"_slideTabBar");v(this,"_scrollX");const t=e.primeval();this._scrollX=t.scrollLeft,this._slideTabBar=e}scrollX(e){const t=this._slideTabBar.primeval();t.scrollLeft=e,this._scrollX=t.scrollLeft}scrollRight(){const e=this._slideTabBar.primeval();e.scrollLeft=e.scrollWidth,this._scrollX=e.scrollLeft}getScrollX(){return this._scrollX}}const ft=class ft{constructor(e){v(this,"_activeTabItemIndex",0);v(this,"_slideTabBar");v(this,"_slideTabItems",[]);v(this,"_config");v(this,"_downActionX",0);v(this,"_moveActionX",0);v(this,"_compareIndex",0);v(this,"_activeTabItem",null);v(this,"_moveAction");v(this,"_upAction");v(this,"_downAction");v(this,"_wheelAction");v(this,"_scrollIncremental",0);v(this,"_compareDirection",0);v(this,"_autoScrollTime",null);v(this,"_slideScrollbar");v(this,"_longPressTimer",null);v(this,"_leftBoundingLine",0);v(this,"_rightBoundingLine",0);v(this,"_leftMoveX",0);v(this,"_rightMoveX",0);if(e.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const t=e.slideTabBarContainer.querySelector(`.${e.slideTabBarClassName??"slide-tab-bar"}`);if(t==null)throw new Error("not found slide-tab-bar");this._slideTabBar=t,this._slideScrollbar=new Ou(this),this._config=e,this._initConfig();let n=0,i=0,r=0;this._downAction=s=>{var T,E,O,x,P;const a=(E=(T=s.target)==null?void 0:T.closest(`.${e.slideTabBarItemClassName}`))==null?void 0:E.getAttribute("data-id"),c=this._slideTabItems.findIndex(H=>H.getId()===a);if(a==null||c===-1)return;if(this._activeTabItemIndex!==c){(O=this._activeTabItem)==null||O.removeEventListener("pointermove",this._moveAction),(x=this._activeTabItem)==null||x.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(s,a);return}if(this._compareIndex=c,this._downActionX=s.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[c],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const d=this._activeTabItem.getSlideTabItem();d==null||d.setPointerCapture(s.pointerId),(P=this._activeTabItem)==null||P.addEventListener("pointerup",this._upAction);const{x:u,width:m}=this._activeTabItem.getBoundingRect(),{x:h,width:_}=this.getBoundingRect(),f=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(u-f),this._rightBoundingLine=u-f+m-this._downActionX,this._leftMoveX=u-h-f,this._rightMoveX=h+_-(u+m)+f,s.button===2||this._hasEditItem())return;const{pageX:S,pageY:I}=s,C=Date.now(),M=C-r<=ft.DoubleClickDelay,R=Math.abs(S-n)<10,y=Math.abs(I-i)<10;M&&R&&y&&this._activeTabItem.editor(),n=S,i=I,r=C,this._longPressTimer=setTimeout(()=>{var H,A;(H=this._activeTabItem)==null||H.enableFixed(),this._startAutoScroll(),d&&(d.setPointerCapture(s.pointerId),d.style.cursor="move",(A=this._activeTabItem)==null||A.addEventListener("pointermove",this._moveAction))},ft.LongPressDelay)},this._upAction=s=>{var c,d,u;if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem)return;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const a=(c=this._activeTabItem)==null?void 0:c.getSlideTabItem();a&&(a.style.cursor="",a.releasePointerCapture(s.pointerId),(d=this._activeTabItem)==null||d.removeEventListener("pointermove",this._moveAction),(u=this._activeTabItem)==null||u.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&(this.removeListener(),this._config.onSlideEnd(s,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=s=>{this._activeTabItem&&(this._moveActionX=s.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(s),this._scrollRight(s))},this._wheelAction=s=>{this.setScroll(s.deltaY)},this.addListener()}static checkedSkipSlide(e){let t=e.target;for(;t!=null&&t!==document.body;){if(t.getAttribute("data-slide-skip"))return!0;t=t.parentElement}return!1}static keepLastIndex(e){setTimeout(()=>{const t=window.getSelection();t&&(t.selectAllChildren(e),t.collapseToEnd())})}static keepSelectAll(e){setTimeout(()=>{const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)})}update(e){this._config.currentIndex=e,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let e=0;e<this._slideTabItems.length;e++)this._slideTabItems[e].animate().cancel(),this._slideTabItems[e].translateX(0),this._slideTabItems[e].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const e=this._slideTabBar.parentElement;return e?this._slideTabBar.scrollWidth-e.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.removeEventListener("pointerdown",this._downAction)})}setScroll(e){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e),e>0){const t=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(e){if(e>0){const t=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(e){let t=0;const n=4;return this._slideTabItems.some(i=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left+r.width,a=i.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c<s&&c+d+n*2>s?(t=e?c-r.left-n:c+d-s+n,!0):!1}),t}calculateRightScrollX(e){let t=0;const n=4;return this._slideTabItems.some(i=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left,a=i.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c-n*2<s&&c+d>s?(t=e?c+d-r.left-r.width+n:c-s-n,!0):!1}),t}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let e=0;e<this._slideTabItems.length;e++)if(this._slideTabItems[e].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n>t.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(t.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let e=0;e<this._slideTabItems.length;e++){const t=this._slideTabItems[e],n=this._slideTabItems[e+1];n&&t.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const e=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let r=0;r<e&&!(r>=e);r++)n.push(this._slideTabItems[r]);for(let r=e+1;r<t;r++)this._slideTabItems[r].animate().translateX(0);let i=!0;for(let r=n.length-1;r>=0;r--){const s=n[r];Ke.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=r,i=!1):(s.animate().translateX(0),i&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const e=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let r=e+1;r<t;r++)n.push(this._slideTabItems[r]);for(let r=0;r<e;r++)this._slideTabItems[r].animate().translateX(0);let i=!0;for(let r=0;r<n.length;r++){const s=n[r];Ke.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=e+r+1,i=!1):(s.animate().translateX(0),i&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){const e=this._slideTabBar.querySelectorAll(`.${this._config.slideTabBarItemClassName??"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=Ke.make(e,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};v(ft,"LongPressDelay",500),v(ft,"DoubleClickDelay",300);let Dt=ft;function xu(){const[o,e]=U.useState([]),[t,n]=U.useState(""),[i,r]=U.useState(""),s=U.useRef({slideTabBar:null}),a=U.useRef(null),c=F.useDependency(l.IUniverInstanceService),d=F.useDependency(l.ICommandService),u=F.useDependency(mt),m=F.useDependency(l.LocaleService),h=F.useDependency(b.IConfirmService),_=c.getCurrentUniverSheetInstance();U.useEffect(()=>{C();const P=f(),H=I(),A=[M(),R(),y(),T()];return()=>{H.dispose(),P.destroy(),A.forEach(D=>D.unsubscribe())}},[]),U.useEffect(()=>{o.length>0&&S()},[o]);const f=()=>{const P=new Dt({slideTabBarClassName:ge.slideTabBar,slideTabBarItemActiveClassName:ge.slideTabActive,slideTabBarItemClassName:ge.slideTabItem,slideTabBarSpanEditClassName:ge.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:a.current,currentIndex:0,onChangeName:(H,A)=>{d.executeCommand(p.SetWorksheetNameCommand.id,{worksheetId:H,name:A})},onSlideEnd:(H,A)=>{d.executeCommand(p.SetWorksheetOrderCommand.id,{order:A})},onChangeTab:(H,A)=>{d.executeCommand(p.SetWorksheetActivateCommand.id,{worksheetId:A})},onScroll:H=>{u.setScroll(H)},onEmptyAlert:()=>{const H="slideTabBarAlert";h.open({id:H,children:{title:m.t("sheetConfig.sheetNameCannotIsEmptyError")},title:{title:"There was a problem"},onClose(){h.close(H)},onConfirm(){h.close(H)}})}});return s.current.slideTabBar=P,x(P),P},S=()=>{var H;const P=o.findIndex(A=>A.selected);(H=s.current.slideTabBar)==null||H.update(P)},I=()=>d.onCommandExecuted(P=>{switch(P.id){case p.SetTabColorMutation.id:case p.SetWorksheetHideMutation.id:case p.RemoveSheetMutation.id:case p.SetWorksheetNameMutation.id:case p.InsertSheetMutation.id:case p.SetWorksheetOrderMutation.id:case p.SetWorksheetActiveOperation.id:C();break}}),C=()=>{const P=_.getActiveSheet().getSheetId();n(P);const A=_.getSheets().filter(D=>!D.isSheetHidden()).map((D,N)=>({sheetId:D.getSheetId(),label:D.getName(),index:N,selected:D.getStatus()===l.BooleanNumber.TRUE,color:D.getTabColor()??void 0}));e(A)},M=()=>u.scroll$.subscribe(P=>{E(P)}),R=()=>u.scrollX$.subscribe(P=>{var H;(H=s.current.slideTabBar)==null||H.flipPage(P)}),y=()=>u.renameId$.subscribe(()=>{var P,H;(H=(P=s.current.slideTabBar)==null?void 0:P.getActiveItem())==null||H.editor()}),T=()=>u.addSheet$.subscribe(()=>{var P;(P=s.current.slideTabBar)==null||P.getScrollbar().scrollRight()}),E=P=>{const{leftEnd:H,rightEnd:A}=P;let D="";H&&A?D="":H&&!A?D="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!H&&A?D="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!H&&!A&&(D="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),r(D)},O=P=>{u.setScroll({leftEnd:P.isLeftEnd(),rightEnd:P.isRightEnd()})},x=P=>{var D;const H=(D=a.current)==null?void 0:D.querySelector(`.${ge.slideTabBar}`);if(!H)return;new ResizeObserver(()=>{O(P)}).observe(H)};return g.jsx("div",{className:ge.slideTabBarContainer,ref:a,children:g.jsx("div",{className:ge.slideTabBar,style:{boxShadow:i},children:o.map(P=>U.createElement(wu,{...P,key:P.sheetId,selected:t===P.sheetId}))})})}const Hr=100,Pu=()=>{const[o,e]=U.useState(!0),[t,n]=U.useState(!0),i=F.useDependency(l.ICommandService),r=F.useDependency(mt);U.useEffect(()=>{const u=r.scroll$.subscribe(m=>{s(m)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:m,rightEnd:h}=u;e(m),n(h)},a=()=>{i.executeCommand(p.InsertSheetCommand.id),setTimeout(()=>{r.setAddSheet(0)},0)},c=()=>{r.setScrollX(-Hr)},d=()=>{r.setScrollX(Hr)};return g.jsxs("div",{className:Pn.sheetBar,children:[g.jsxs("div",{className:Pn.sheetBarOptions,children:[g.jsx(An,{onClick:a,children:g.jsx(ia,{})}),g.jsx(Ru,{})]}),g.jsx(xu,{}),(!o||!t)&&g.jsxs("div",{className:`${Pn.sheetBarOptions} ${Pn.sheetBarOptionsDivider}`,children:[g.jsx(An,{disabled:o,onClick:c,children:g.jsx(Jn,{style:{transform:"rotateZ(180deg)"}})}),g.jsx(An,{disabled:t,onClick:d,children:g.jsx(Jn,{})})]})]})};class Au{constructor(){v(this,"_functions",[re.FUNCTION_NAMES_MATH.SUM,re.FUNCTION_NAMES_STATISTICAL.MAX,re.FUNCTION_NAMES_STATISTICAL.MIN,re.FUNCTION_NAMES_STATISTICAL.AVERAGE,re.FUNCTION_NAMES_STATISTICAL.COUNT]);v(this,"_state$",new V.BehaviorSubject(null));v(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(e){this._state$.next(e)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}}const xo=L.createIdentifier("univer.sheet-status-bar.service"),ve={statusBar:"univer-status-bar",singleMode:"univer-single-mode",statusBarDiv:"univer-status-bar-div",statisticList:"univer-statistic-list",statisticListTwoRow:"univer-statistic-list-two-row",statisticListRow:"univer-statistic-list-row",statisticItem:"univer-statistic-item",statisticPicker:"univer-statistic-picker",statisticPickerItem:"univer-statistic-picker-item",statisticMore:"univer-statistic-more"},_t={[re.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[re.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[re.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[re.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[re.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[re.FUNCTION_NAMES_COMPATIBILITY.CONCATENATE]:"concatenate"},Po=o=>{const e=F.useDependency(l.LocaleService),t=F.useDependency(b.IMessageService),n=F.useDependency(b.IClipboardInterfaceService),i=Dr(o.value),r=async()=>{await n.writeText(o.value.toString()),t.show({type:te.MessageType.Success,content:e.t("statusbar.copied")})};return g.jsx(te.Tooltip,{title:e.t("statusbar.clickToCopy"),placement:"top",children:g.jsx("div",{className:ve.statisticItem,onClick:r,children:g.jsx("span",{children:`${e.t((_t==null?void 0:_t[o.name])||o.name)}: ${i}`})},o.name)})};function Dr(o){return typeof o!="number"?"Invalid input":o>=1e8?o.toExponential(2):o.toLocaleString()}const Lr=800,ku=()=>{const[o,e]=U.useState(window.innerWidth<Lr),[t,n]=U.useState(!0),i=F.useDependency(l.LocaleService),r=F.useDependency(xo),s=r.getFunctions().map((h,_)=>({name:h,value:0,show:o?_<1:_<3})),[a,c]=U.useState(s),d=a.filter(h=>h.show),u=h=>{const _=a.map(f=>(f.name===h.name?f.show=!f.show:o&&(f.show=!1),f));c(_)};U.useEffect(()=>{const h=r.state$.subscribe(_=>{if(!_)n(!1);else{n(!0);const f=a.map(S=>{const I=_.find(C=>C.func===S.name);return S.value=(I==null?void 0:I.value)??S.value,S});c(f)}});return()=>{h.unsubscribe()}},[r]);const m=()=>{const h=window.innerWidth<Lr;if(o!==h){if(h){const _=a.findIndex(S=>S.show),f=a.map((S,I)=>(I===_?S.show=!0:S.show=!1,S));c(f)}e(h)}};return U.useEffect(()=>(window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}),[]),t&&g.jsxs("div",{className:gt(ve.statusBar,{[ve.singleMode]:o}),children:[g.jsx("div",{className:gt(ve.statisticList,{[ve.statisticListTwoRow]:d.length>3}),children:d.length>3?g.jsxs(g.Fragment,{children:[g.jsx("div",{className:ve.statisticListRow,children:d.slice(0,3).map(h=>g.jsx(Po,{...h},h.name))}),g.jsx("div",{className:ve.statisticListRow,children:d.slice(3).map(h=>g.jsx(Po,{...h},h.name))})]}):d.map(h=>g.jsx(Po,{...h},h.name))}),g.jsx(te.Dropdown,{placement:"topRight",overlay:g.jsx("div",{className:ve.statisticPicker,children:a==null?void 0:a.map(h=>g.jsxs("a",{className:ve.statisticPickerItem,children:[g.jsx(te.Checkbox,{value:h.name,checked:h.show,onChange:()=>u&&u(h)}),g.jsx("span",{children:`${i.t((_t==null?void 0:_t[h.name])||h.name)}: ${Dr(h.value)}`})]},h.name))}),children:g.jsx("div",{className:ve.statisticMore,children:g.jsx(Jn,{})})}),g.jsx("div",{className:ve.statusBarDiv})]})};function Hu(){return g.jsxs("section",{className:hr.sheetContainer,"data-range-selector":!0,children:[g.jsx(Pu,{}),g.jsx(ku,{}),g.jsx(pu,{})]})}function Du(){return g.jsx(g.Fragment,{children:g.jsx(vu,{})})}function Lu(){return g.jsxs(g.Fragment,{children:[g.jsx(gu,{}),g.jsx(bu,{})]})}function Nu(o){const e=o.get(p.BorderStyleManagerService);return{id:p.SetBorderBasicCommand.id,icon:new V.Observable(t=>{const n="AllBorderSingle",i=o.get(p.BorderStyleManagerService),r=o.get(l.ICommandService).onCommandExecuted(s=>{if(s.id!==p.SetBorderBasicCommand.id)return;const{type:c}=i.getBorderInfo(),d=Pr.find(m=>m.value===c),u=(d==null?void 0:d.icon)??n;t.next(u)});return t.next(n),r.dispose}),group:b.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[b.MenuPosition.TOOLBAR_START],type:b.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:xr,hoverable:!1},value$:e.borderInfo$}],value$:e.borderInfo$}}const kn="sheet.menu.clear-selection";function Uu(){return{id:kn,group:b.MenuGroup.CONTEXT_MENU_FORMAT,type:b.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[b.MenuPosition.CONTEXT_MENU,q.COL_HEADER_CONTEXT_MENU,q.ROW_HEADER_CONTEXT_MENU]}}function Bu(){return{id:p.ClearSelectionContentCommand.id,type:b.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[kn]}}function Vu(){return{id:p.ClearSelectionFormatCommand.id,type:b.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[kn]}}function Fu(){return{id:p.ClearSelectionAllCommand.id,type:b.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[kn]}}const Lt="sheet.menu.delete";function ju(){return{id:Lt,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[b.MenuPosition.CONTEXT_MENU]}}function Wu(){return{id:p.RemoveColCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[Lt,q.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function zu(){return{id:p.RemoveRowCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,icon:"DeleteRow",positions:[Lt,q.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function Xu(){return{id:p.DeleteRangeMoveLeftCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[Lt]}}function Yu(){return{id:p.DeleteRangeMoveUpCommand.id,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[Lt]}}const Ao="sheet.menu.col-insert";function $u(){return{id:Ao,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[q.COL_HEADER_CONTEXT_MENU]}}const ko="sheet.menu.row-insert";function Zu(){return{id:ko,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[q.ROW_HEADER_CONTEXT_MENU]}}const Nt="sheet.menu.cell-insert";function Gu(){return{id:Nt,group:b.MenuGroup.CONTEXT_MENU_LAYOUT,type:b.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[b.MenuPosition.CONTEXT_MENU]}}function Ku(o){const e=o.get(p.SelectionManagerService);return{id:p.InsertRowBeforeCommand.id,type:b.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[ko,Nt],hidden$:new V.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function Ju(o){const e=o.get(p.SelectionManagerService);return{id:p.InsertRowAfterCommand.id,type:b.MenuItemType.BUTTON,positions:[ko],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new V.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function Qu(o){const e=o.get(p.SelectionManagerService);return{id:p.InsertColBeforeCommand.id,type:b.MenuItemType.BUTTON,positions:[Ao,Nt],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new V.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function qu(o){const e=o.get(p.SelectionManagerService);return{id:p.InsertColAfterCommand.id,type:b.MenuItemType.BUTTON,positions:[Ao],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new V.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function eh(){return{id:p.InsertRangeMoveRightCommand.id,type:b.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[Nt]}}function th(){return{id:p.InsertRangeMoveDownCommand.id,type:b.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[Nt]}}function nh(o){return{id:Pe.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[b.MenuPosition.TOOLBAR_START],group:b.MenuGroup.TOOLBAR_LAYOUT,type:b.MenuItemType.SUBITEMS}}function oh(o){return{id:br.id,type:b.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Pe.id]}}function ih(o){return{id:Mr.id,type:b.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Pe.id]}}function rh(o){return{id:Rr.id,type:b.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Pe.id]}}function sh(o){return{id:p.RemoveWorksheetMergeCommand.id,type:b.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Pe.id]}}function ah(){return{id:p.RemoveSheetCommand.id,type:b.MenuItemType.BUTTON,positions:[q.SHEET_BAR],title:"sheetConfig.delete"}}function lh(){return{id:p.CopySheetCommand.id,type:b.MenuItemType.BUTTON,positions:[q.SHEET_BAR],title:"sheetConfig.copy"}}function ch(){return{id:yr.id,type:b.MenuItemType.BUTTON,positions:[q.SHEET_BAR],title:"sheetConfig.rename"}}function dh(){return{id:p.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[q.SHEET_BAR],type:b.MenuItemType.SELECTOR,selections:[{label:{name:Qt,hoverable:!1}}]}}function uh(){return{id:p.SetWorksheetHideCommand.id,type:b.MenuItemType.BUTTON,positions:[q.SHEET_BAR],title:"sheetConfig.hide"}}function hh(){return{id:Tr.id,type:b.MenuItemType.BUTTON,positions:[q.SHEET_BAR],title:"sheetConfig.unhide"}}const mh={id:p.SetRowHiddenCommand.id,preconditions:o=>X(o),binding:b.KeyCode.Digit9|b.MetaKeys.CTRL_COMMAND},_h={id:p.SetColHiddenCommand.id,preconditions:o=>X(o),binding:b.KeyCode.Digit0|b.MetaKeys.CTRL_COMMAND|b.MetaKeys.SHIFT},Sh={id:_e.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:b.KeyCode.ARROW_DOWN,priority:100,preconditions:X,staticParameters:{direction:l.Direction.DOWN}},fh={id:_e.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:b.KeyCode.ARROW_UP,priority:100,preconditions:X,staticParameters:{direction:l.Direction.UP}},ph={id:_e.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:b.KeyCode.ARROW_LEFT,priority:100,preconditions:X,staticParameters:{direction:l.Direction.LEFT}},gh={id:_e.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:b.KeyCode.ARROW_RIGHT,priority:100,preconditions:X,staticParameters:{direction:l.Direction.RIGHT}},vh={id:We.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:b.KeyCode.TAB,priority:100,preconditions:X,staticParameters:{direction:l.Direction.RIGHT,keycode:b.KeyCode.TAB}},Ch={id:We.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:b.KeyCode.TAB|b.MetaKeys.SHIFT,priority:100,preconditions:X,staticParameters:{direction:l.Direction.LEFT,keycode:b.KeyCode.TAB}},Ih={id:We.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:b.KeyCode.ENTER,priority:100,preconditions:X,staticParameters:{direction:l.Direction.DOWN,keycode:b.KeyCode.ENTER}},bh={id:We.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:b.KeyCode.ENTER|b.MetaKeys.SHIFT,priority:100,preconditions:X,staticParameters:{direction:l.Direction.UP,keycode:b.KeyCode.ENTER}},Mh={id:_e.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:b.KeyCode.ARROW_DOWN|b.MetaKeys.CTRL_COMMAND,preconditions:X,staticParameters:{direction:l.Direction.DOWN,jumpOver:be.moveGap}},Rh={id:_e.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:b.KeyCode.ARROW_UP|b.MetaKeys.CTRL_COMMAND,preconditions:X,staticParameters:{direction:l.Direction.UP,jumpOver:be.moveGap}},wh={id:_e.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:b.KeyCode.ARROW_LEFT|b.MetaKeys.CTRL_COMMAND,preconditions:X,staticParameters:{direction:l.Direction.LEFT,jumpOver:be.moveGap}},yh={id:_e.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:b.KeyCode.ARROW_RIGHT|b.MetaKeys.CTRL_COMMAND,preconditions:X,staticParameters:{direction:l.Direction.RIGHT,jumpOver:be.moveGap}},Th={id:Me.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:b.KeyCode.ARROW_DOWN|b.MetaKeys.SHIFT,preconditions:X,staticParameters:{direction:l.Direction.DOWN}},Eh={id:Me.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:b.KeyCode.ARROW_UP|b.MetaKeys.SHIFT,preconditions:X,staticParameters:{direction:l.Direction.UP}},Oh={id:Me.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:b.KeyCode.ARROW_LEFT|b.MetaKeys.SHIFT,preconditions:X,staticParameters:{direction:l.Direction.LEFT}},xh={id:Me.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:b.KeyCode.ARROW_RIGHT|b.MetaKeys.SHIFT,preconditions:X,staticParameters:{direction:l.Direction.RIGHT}},Ph={id:Me.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:b.KeyCode.ARROW_DOWN|b.MetaKeys.SHIFT|b.MetaKeys.CTRL_COMMAND,preconditions:X,staticParameters:{direction:l.Direction.DOWN,jumpOver:be.moveGap}},Ah={id:Me.id,description:"shortcut.sheet.expand-selection-to-above-gap",group:"3_sheet-view",binding:b.KeyCode.ARROW_UP|b.MetaKeys.SHIFT|b.MetaKeys.CTRL_COMMAND,preconditions:X,staticParameters:{direction:l.Direction.UP,jumpOver:be.moveGap}},kh={id:Me.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:b.KeyCode.ARROW_LEFT|b.MetaKeys.SHIFT|b.MetaKeys.CTRL_COMMAND,preconditions:X,staticParameters:{direction:l.Direction.LEFT,jumpOver:be.moveGap}},Hh={id:Me.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:b.KeyCode.ARROW_RIGHT|b.MetaKeys.SHIFT|b.MetaKeys.CTRL_COMMAND,preconditions:X,staticParameters:{direction:l.Direction.RIGHT,jumpOver:be.moveGap}},Dh={id:ei.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:b.KeyCode.A|b.MetaKeys.CTRL_COMMAND,preconditions:X,staticParameters:{expandToGapFirst:!0,loop:!0}},Lh={id:p.SetBoldCommand.id,preconditions:o=>X(o),binding:b.KeyCode.B|b.MetaKeys.CTRL_COMMAND},Nh={id:p.SetItalicCommand.id,preconditions:o=>X(o),binding:b.KeyCode.I|b.MetaKeys.CTRL_COMMAND},Uh={id:p.SetUnderlineCommand.id,preconditions:o=>X(o),binding:b.KeyCode.U|b.MetaKeys.CTRL_COMMAND},Bh={id:p.SetStrikeThroughCommand.id,preconditions:o=>X(o),binding:b.KeyCode.X|b.MetaKeys.SHIFT|b.MetaKeys.CTRL_COMMAND},Vh={id:p.ClearSelectionContentCommand.id,preconditions:o=>X(o),binding:b.KeyCode.DELETE,mac:b.KeyCode.BACKSPACE},Fh={id:On.id,description:"shortcut.sheet.zoom-in",binding:b.KeyCode.EQUAL|b.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{delta:.2}},jh={id:On.id,description:"shortcut.sheet.zoom-out",binding:b.KeyCode.MINUS|b.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{delta:-.2}},Wh={id:On.id,description:"shortcut.sheet.reset-zoom",binding:b.KeyCode.Digit0|b.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{reset:!0}};var zh=Object.defineProperty,Xh=Object.getOwnPropertyDescriptor,Yh=(o,e,t,n)=>{for(var i=n>1?void 0:n?Xh(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&zh(e,t,i),i},St=(o,e)=>(t,n)=>e(t,n,o);let Hn=class extends l.Disposable{constructor(o,e,t,n,i,r){super(),this._injector=o,this._componentManager=e,this._commandService=t,this._shortcutService=n,this._menuService=i,this._uiController=r,this._init()}_initCustomComponents(){const o=this._componentManager;this.disposeWithMe(o.register(ro,Ya)),this.disposeWithMe(o.register(xr,mu)),this.disposeWithMe(o.register(Qt,te.ColorPicker)),this.disposeWithMe(o.register(Ui,Wa)),this.disposeWithMe(o.register(le,za)),this.disposeWithMe(o.register(Vi,Xa))}_initCommands(){[br,Pe,Rr,Mr,On,Me,_e,We,yr,ct,ei,Sr,Xt,p.SetBoldCommand,vt,Ie,Ri,wi,yi,Ti,Ei,Oi,Kt,p.SetItalicCommand,p.SetStrikeThroughCommand,p.SetFontFamilyCommand,p.SetFontSizeCommand,oo,Ai,io,ki,tt,fn,Jt,Hi,Di,Li,p.SetSelectionsOperation,p.SetUnderlineCommand,Oo,Ee,Tr,wr].forEach(o=>{this.disposeWithMe(this._commandService.registerCommand(o))})}_initMenus(){[cl,dl,ul,hl,ml,_l,Sl,Bu,Vu,Fu,Uu,$u,Zu,Gu,Ku,Ju,Qu,qu,zu,Ml,wl,Rl,yl,Wu,Tl,fl,El,ju,Xu,Yu,eh,th,vl,Cl,Il,bl,pl,gl,$a,Za,Ga,Ka,Ja,qa,el,tl,nl,ol,il,Nu,nh,oh,ih,rh,sh,rl,sl,al,ll,ah,lh,ch,dh,uh,hh].forEach(o=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(o)))})}_initShortcuts(){[Sh,fh,ph,gh,vh,Ch,Ih,bh,Mh,Rh,wh,yh,Th,Eh,Oh,xh,Ph,Ah,kh,Hh,Dh,Fh,jh,Wh,Lh,Nh,Uh,Bh,Vh,...Ac(),kc,Hc,Lc,Nc,Uc,Dc,mh,_h].forEach(o=>{this.disposeWithMe(this._shortcutService.registerShortcut(o))})}_initWorkbenchParts(){this.disposeWithMe(this._uiController.registerHeaderComponent(()=>F.connectInjector(Du,this._injector))),this.disposeWithMe(this._uiController.registerFooterComponent(()=>F.connectInjector(Hu,this._injector))),this.disposeWithMe(this._uiController.registerContentComponent(()=>F.connectInjector(Lu,this._injector)))}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts()}};Hn=Yh([l.OnLifecycle(l.LifecycleStages.Ready,Hn),St(0,L.Inject(L.Injector)),St(1,L.Inject(b.ComponentManager)),St(2,l.ICommandService),St(3,b.IShortcutService),St(4,b.IMenuService),St(5,b.IUIController)],Hn);var $h=Object.defineProperty,Zh=Object.getOwnPropertyDescriptor,Gh=(o,e,t,n)=>{for(var i=n>1?void 0:n?Zh(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&$h(e,t,i),i},Dn=(o,e)=>(t,n)=>e(t,n,o);let Ln=class extends l.Disposable{constructor(o,e,t,n){super(),this._univerInstanceService=o,this._selectionManagerService=e,this._functionService=t,this._statusBarService=n,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(o=>{o&&this._calculateSelection(o.map(e=>e.range))}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(o=>{o&&this._calculateSelection(o.map(e=>e.range))})))}_calculateSelection(o){const e=this._univerInstanceService.getCurrentUniverSheetInstance(),t=e.getUnitId(),n=e.getActiveSheet().getSheetId(),i={};if(this._univerInstanceService.getCurrentUniverSheetInstance().getSheets().forEach(r=>{const s=r.getConfig();i[r.getSheetId()]={cellData:new l.ObjectMatrix(s.cellData),rowCount:s.rowCount,columnCount:s.columnCount}}),o!=null&&o.length&&((o==null?void 0:o.length)>1||!this._isSingleCell(o[0]))){const r=o.map(d=>new re.RangeReferenceObject(d,n,t));r.forEach(d=>d.setUnitData({[t]:i}));const a=this._statusBarService.getFunctions().map(d=>{const u=this._functionService.getExecutor(d);if(!(!u||!(u==null?void 0:u.calculate(...r)).getValue))return{func:d,value:(u==null?void 0:u.calculate(...r)).getValue()}});if(a.every(d=>d===void 0))return;const c=a.filter(d=>d!==void 0);this._statusBarService.setState(c)}else this._statusBarService.setState(null)}_isSingleCell(o){return o.startRow===o.endRow&&o.startColumn===o.endColumn}};Ln=Gh([l.OnLifecycle(l.LifecycleStages.Ready,Ln),Dn(0,l.IUniverInstanceService),Dn(1,L.Inject(p.SelectionManagerService)),Dn(2,re.IFunctionService),Dn(3,xo)],Ln);var Kh=Object.defineProperty,Jh=Object.getOwnPropertyDescriptor,Qh=(o,e,t,n)=>{for(var i=n>1?void 0:n?Jh(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Kh(e,t,i),i},Je=(o,e)=>(t,n)=>e(t,n,o);let Nn=class extends l.Disposable{constructor(o,e,t,n,i,r,s){super(),this._sheetSkeletonManagerService=o,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=i,this._selectionManagerService=r,this._scrollManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._zoomEventBinding()}_zoomEventBinding(){var e;const o=(e=this._getSheetObject())==null?void 0:e.scene;o!=null&&(o.getViewport(Y.VIEW_MAIN),this.disposeWithMe(l.toDisposable(o.onMouseWheelObserver.add((t,n)=>{if(!t.ctrlKey)return;const i=Math.abs(t.deltaX);let r=i<40?.2:i<80?.4:.2;r*=t.deltaY>0?-1:1,o.scaleX<1&&(r/=2);const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getActiveSheet(),c=a.getZoomRatio();let d=+parseFloat(`${c+r}`).toFixed(1);d=d>=4?4:d<=.1?.1:d,this._commandService.executeCommand(Oo.id,{zoomRatio:d,workbookId:s.getUnitId(),worksheetId:a.getSheetId()}),t.preventDefault()}))))}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(o=>{if(o==null)return;const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()||1;this._updateViewZoom(n)})))}_commandExecutedListener(){const o=[Ee.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(o.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),i=e.params,{workbookId:r,worksheetId:s}=i;if(!(r===t.getUnitId()&&s===n.getSheetId()))return;const a=n.getConfig().zoomRatio||1;this._updateViewZoom(a)}}))}_updateViewZoom(o){const e=this._getSheetObject();e==null||e.scene.scale(o,o)}_getSheetObject(){return ce(this._currentUniverService,this._renderManagerService)}};Nn=Qh([l.OnLifecycle(l.LifecycleStages.Rendered,Nn),Je(0,L.Inject(k.SheetSkeletonManagerService)),Je(1,l.IUniverInstanceService),Je(2,l.ICommandService),Je(3,w.IRenderManagerService),Je(4,ae),Je(5,L.Inject(p.SelectionManagerService)),Je(6,L.Inject(Ne))],Nn);var qh=Object.defineProperty,em=Object.getOwnPropertyDescriptor,tm=(o,e,t,n)=>{for(var i=n>1?void 0:n?em(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&qh(e,t,i),i},Ut=(o,e)=>(t,n)=>e(t,n,o);let Un=class{constructor(o,e,t,n,i){v(this,"_scene");v(this,"_currentWorkbook");v(this,"_loadedMap",new Set);v(this,"_isLoadedEditor",!1);this._currentUniverService=o,this._commandService=e,this._renderManagerService=t,this._selectionRenderService=n,this._sheetSkeletonManagerService=i,this._currentUniverService.currentSheet$.subscribe(r=>{if(r==null)return;const s=r.getUnitId();this._loadedMap.has(s)||(this._currentWorkbook=r,this._addNewRender(),this._loadedMap.add(s))})}_addNewRender(){const o=this._currentWorkbook,e=o.getUnitId(),t=o.getContainer(),n=o.getParentRenderUnitId();if(t!=null&&n!=null)throw new Error("container or parentRenderUnitId can only exist one");const i=t==null&&n!=null;i?this._renderManagerService.createRenderWithParent(e,n):this._renderManagerService.createRender(e);const r=this._renderManagerService.getRenderById(e);if(r==null)return;const{scene:s,engine:a}=r;s.openTransformer(),this._scene=s,s.addLayer(w.Layer.create(s,[],0),w.Layer.create(s,[],2)),r!=null&&this._addComponent(r),o.getShouldRenderLoopImmediately()&&!i&&a.runRenderLoop(()=>{s.render()}),this._renderManagerService.setCurrent(e)}_addComponent(o){const e=this._scene,t=this._currentWorkbook,n=t.getActiveSheet(),i=t.getUnitId(),r=n.getSheetId();this._addViewport(n);const s=new w.Spreadsheet(se.MAIN),a=new w.SpreadsheetRowHeader(se.ROW),c=new w.SpreadsheetColumnHeader(se.COLUMN),d=new w.Rect(se.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});o.mainComponent=s,o.components.set(se.MAIN,s),o.components.set(se.ROW,a),o.components.set(se.COLUMN,c),o.components.set(se.LEFT_TOP,d),e.addObjects([s],Ol),e.addObjects([a,c,d],Ye),this._sheetSkeletonManagerService.setCurrent({sheetId:r,unitId:i})}_addViewport(o){const e=this._scene;if(e==null)return;const{rowHeader:t,columnHeader:n}=o.getConfig(),i=new w.Viewport(Y.VIEW_MAIN,e,{left:t.width,top:n.height,bottom:0,right:0,isWheelPreventDefaultX:!0}),r=new w.Viewport(Y.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),s=new w.Viewport(Y.VIEW_ROW_BOTTOM,e,{left:0,top:n.height,bottom:0,width:t.width,isWheelPreventDefaultX:!0}),a=new w.Viewport(Y.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),c=new w.Viewport(Y.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:n.height,right:0,isWheelPreventDefaultX:!0}),d=new w.Viewport(Y.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:n.height,isWheelPreventDefaultX:!0}),u=new w.Viewport(Y.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1}),m=new w.Viewport(Y.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1}),h=new w.Viewport(Y.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1});e.onMouseWheelObserver.add((_,f)=>{if(_.ctrlKey)return;let S=0,I=0;const C=i.limitedScroll();if(_.inputIndex===w.PointerInput.MouseWheelX){const R=Math.abs(_.deltaX);_.deltaX>0?S=R:S=-R,this._commandService.executeCommand(fn.id,{offsetX:S}),e.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?C!=null&&C.isLimitedX||f.stopPropagation():i.isWheelPreventDefaultX?_.preventDefault():C!=null&&C.isLimitedX||_.preventDefault()}if(_.inputIndex===w.PointerInput.MouseWheelY){let R=Math.abs(_.deltaY);_.shiftKey?(R*=3,_.deltaY>0?S=R:S=-R,this._commandService.executeCommand(fn.id,{offsetX:S}),e.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?C!=null&&C.isLimitedX||f.stopPropagation():i.isWheelPreventDefaultX?_.preventDefault():C!=null&&C.isLimitedX||_.preventDefault()):(_.deltaY>0?I=R:I=-R,this._commandService.executeCommand(fn.id,{offsetY:I}),e.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?C!=null&&C.isLimitedY||f.stopPropagation():i.isWheelPreventDefaultY?_.preventDefault():C!=null&&C.isLimitedY||_.preventDefault())}_.inputIndex,w.PointerInput.MouseWheelZ}),new w.ScrollBar(i),e.addViewport(i,a,c,r,s,d,u,m,h).attachControl()}};Un=tm([l.OnLifecycle(l.LifecycleStages.Ready,Un),Ut(0,l.IUniverInstanceService),Ut(1,l.ICommandService),Ut(2,w.IRenderManagerService),Ut(3,ae),Ut(4,L.Inject(k.SheetSkeletonManagerService))],Un);var nm=Object.defineProperty,om=Object.getOwnPropertyDescriptor,im=(o,e,t,n)=>{for(var i=n>1?void 0:n?om(e,t):e,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&nm(e,t,i),i},Ho=(o,e)=>(t,n)=>e(t,n,o);k.UniverSheetsUIPlugin=(Do=class extends l.Plugin{constructor(e,t,n,i){super(Bo),this._injector=t,this._localeService=n,this._currentUniverService=i,this._localeService.load({zhCN:Zi})}onStarting(e){[[Un],[Te,{useClass:Fo}],[qe,{useClass:k.SheetClipboardService}],[mt,{useClass:nu}],[ot,{useClass:no}],[yt,{useClass:Gi}],[en,{useClass:Al}],[Mt,{useClass:k.AutoFillService}],[Ne],[k.SheetSkeletonManagerService],[ae,{useClass:k.SelectionRenderService}],[xo,{useClass:Au}],[zt,{useClass:k.MarkSelectionService}],[rn],[sn],[_n],[dn],[un],[Sn],[pn],[vn],[Cn],[bn],[Rn],[hn],[wn],[Ht],[Tn],[an],[ln],[yn],[En],[Hn],[mn],[Nn],[k.AutoFillController],[Ln],[cn]].forEach(t=>e.add(t))}onReady(){this._markSheetAsFocused()}_markSheetAsFocused(){const e=this._currentUniverService;e.currentSheet$.pipe(uc(t=>!!t)).subscribe(t=>{e.focusUniverInstance(t.getUnitId())})}},v(Do,"type",l.PluginType.Sheet),Do),k.UniverSheetsUIPlugin=im([Ho(1,L.Inject(L.Injector)),Ho(2,L.Inject(l.LocaleService)),Ho(3,l.IUniverInstanceService)],k.UniverSheetsUIPlugin),k.APPLY_TYPE=W,k.AutoFillCommand=Vt,k.COPY_TYPE=je,k.CellEditorManagerService=Gi,k.DATA_TYPE=ne,k.DefaultRightMenuConfig=Lo,k.DefaultSheetContainerConfig=Uo,k.DefaultSheetUIConfig=Wr,k.DefaultToolbarConfig=No,k.EditorBridgeService=Fo,k.ExpandSelectionCommand=Me,k.IAutoFillService=Mt,k.ICellEditorManagerService=yt,k.IEditorBridgeService=Te,k.IFormulaEditorManagerService=en,k.IMarkSelectionService=zt,k.ISelectionRenderService=ae,k.ISheetClipboardService=qe,k.JumpOver=be,k.MoveSelectionCommand=_e,k.PASTE_SPECIAL_MENU_ID=rt,k.RangeSelector=ua,k.SHEET_UI_PLUGIN_NAME=Bo,k.SelectionShape=Wt,k.SetCellEditVisibleArrowOperation=vt,k.SetEditorResizeOperation=Xt,k.SetScrollOperation=tt,k.SetZoomRatioOperation=Ee,k.SheetCopyCommand=Go,k.SheetPasteCommand=et,k.enUS=xl,k.getAutoFillRepeatRange=wa,k.getCoordByCell=lo,k.getCoordByOffset=st,k.getEditorObject=Bt,k.getRepeatRange=Pl,k.getSheetObject=ce,k.getTransformCoord=qt,k.whenEditorInputFormulaActivated=$r,k.zhCN=Zi,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});