@8sheets/data-grid 0.0.0-stage → 1.0.1

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 (292) hide show
  1. package/LICENSE.md +36 -0
  2. package/README.md +52 -2
  3. package/a11y/cell-alt-text.js +1 -0
  4. package/api/overlay.js +1 -0
  5. package/api/serialize.js +1 -0
  6. package/api/skins.js +1 -0
  7. package/api/style-refs.js +1 -0
  8. package/api/watermark-xml.js +2 -0
  9. package/calc/adjust.js +1 -0
  10. package/calc/cell-set.js +1 -0
  11. package/calc/compile.js +1 -0
  12. package/calc/engine.js +1 -0
  13. package/calc/fill-shape.js +2 -0
  14. package/calc/functions/array.js +1 -0
  15. package/calc/functions/database.js +1 -0
  16. package/calc/functions/date.js +1 -0
  17. package/calc/functions/engineering.js +1 -0
  18. package/calc/functions/financial.js +1 -0
  19. package/calc/functions/helpers.js +1 -0
  20. package/calc/functions/index.js +1 -0
  21. package/calc/functions/info.js +1 -0
  22. package/calc/functions/logical.js +1 -0
  23. package/calc/functions/lookup.js +1 -0
  24. package/calc/functions/math.js +1 -0
  25. package/calc/functions/registry.js +1 -0
  26. package/calc/functions/stat.js +1 -0
  27. package/calc/functions/text.js +1 -0
  28. package/calc/parser.js +3 -0
  29. package/calc/values.js +1 -0
  30. package/calcx/ai/client.js +1 -0
  31. package/calcx/ai/functions.js +15 -0
  32. package/calcx/ai/settings.js +1 -0
  33. package/calcx/async.js +1 -0
  34. package/calcx/culture/format-locale.js +1 -0
  35. package/calcx/culture/lcid.js +1 -0
  36. package/calcx/external-read.js +1 -0
  37. package/calcx/external-write.js +3 -0
  38. package/calcx/external.js +1 -0
  39. package/calcx/functions/dynamic.js +1 -0
  40. package/calcx/functions/ets.js +1 -0
  41. package/calcx/functions/index.js +1 -0
  42. package/calcx/functions/misc.js +1 -0
  43. package/calcx/functions/text.js +1 -0
  44. package/calcx/functions/xml.js +1 -0
  45. package/calcx/refresh.js +1 -0
  46. package/cells/auto-merge.js +1 -0
  47. package/cells/axis-limits.js +1 -0
  48. package/cells/axis-ops.js +1 -0
  49. package/cells/background-xml.js +1 -0
  50. package/cells/background.js +1 -0
  51. package/cells/book-css.js +206 -0
  52. package/cells/book-read.js +1 -0
  53. package/cells/book-view.js +1 -0
  54. package/cells/cell-defaults.js +1 -0
  55. package/cells/cell-extras.js +1 -0
  56. package/cells/cell-options-ui.js +1 -0
  57. package/cells/cell-styles-xml.js +1 -0
  58. package/cells/cf-engine.js +1 -0
  59. package/cells/cf-file.js +1 -0
  60. package/cells/cf-paint.js +1 -0
  61. package/cells/consolidate-links.js +1 -0
  62. package/cells/docprops-xml.js +2 -0
  63. package/cells/filter-file.js +1 -0
  64. package/cells/find-engine.js +2 -0
  65. package/cells/find.js +1 -0
  66. package/cells/format-code.js +1 -0
  67. package/cells/format-panes.js +3 -0
  68. package/cells/format-tabs.js +102 -0
  69. package/cells/goto.js +1 -0
  70. package/cells/header-colors.js +1 -0
  71. package/cells/mask.js +1 -0
  72. package/cells/menu-extras.js +1 -0
  73. package/cells/name-box.js +1 -0
  74. package/cells/note-xml.js +1 -0
  75. package/cells/options.js +1 -0
  76. package/cells/outline-column.js +1 -0
  77. package/cells/paint.js +1 -0
  78. package/cells/panes.js +1 -0
  79. package/cells/rich-data-xml.js +2 -0
  80. package/cells/rich-data.js +1 -0
  81. package/cells/rich-runs.js +2 -0
  82. package/cells/rich-values.js +1 -0
  83. package/cells/rich-xml.js +1 -0
  84. package/cells/rounded.js +1 -0
  85. package/cells/sections.js +2 -0
  86. package/cells/selection-modes.js +1 -0
  87. package/cells/style-xml.js +1 -0
  88. package/cells/text-layout.js +8 -0
  89. package/cells/undo-group.js +1 -0
  90. package/cells/validation-alert.js +2 -0
  91. package/cells/view-options.js +1 -0
  92. package/cells/view-xml.js +1 -0
  93. package/celltypes/barcode-tables.js +31 -0
  94. package/celltypes/barcode.js +2 -0
  95. package/celltypes/base.js +1 -0
  96. package/celltypes/cell-buttons.js +1 -0
  97. package/celltypes/cell-types.js +2 -0
  98. package/celltypes/data-object.js +1 -0
  99. package/celltypes/diagonal.js +1 -0
  100. package/celltypes/dropdowns-more.js +13 -0
  101. package/celltypes/dropdowns.js +42 -0
  102. package/celltypes/file-cell.js +2 -0
  103. package/celltypes/glyphs.js +1 -0
  104. package/celltypes/persist.js +2 -0
  105. package/celltypes/range-template.js +2 -0
  106. package/charts/chartex.js +3 -0
  107. package/charts/geo/geo-xml.js +1 -0
  108. package/charts/geo/map-state.js +1 -0
  109. package/charts/patterns.js +1 -0
  110. package/core/address.js +1 -0
  111. package/core/axis.js +1 -0
  112. package/core/base64.js +1 -0
  113. package/core/changes.js +1 -0
  114. package/core/color.js +1 -0
  115. package/core/cond-format.js +1 -0
  116. package/core/custom-views.js +1 -0
  117. package/core/default-names.js +1 -0
  118. package/core/formula-refs.js +1 -0
  119. package/core/formula-store.js +1 -0
  120. package/core/input.js +1 -0
  121. package/core/math.js +1 -0
  122. package/core/numfmt.js +1 -0
  123. package/core/online.js +1 -0
  124. package/core/protection.js +1 -0
  125. package/core/regexp.js +1 -0
  126. package/core/sheet-group.js +1 -0
  127. package/core/sheet.js +1 -0
  128. package/core/sparklines.js +1 -0
  129. package/core/sparse.js +1 -0
  130. package/core/strings.js +1 -0
  131. package/core/styles.js +1 -0
  132. package/core/table-presets.js +7 -0
  133. package/core/tables.js +2 -0
  134. package/core/tsv.js +4 -0
  135. package/core/whatif.js +1 -0
  136. package/core/workbook.js +1 -0
  137. package/datasheets/bind.js +1 -0
  138. package/datasheets/calendar.js +1 -0
  139. package/datasheets/cross.js +1 -0
  140. package/datasheets/data-core.js +1 -0
  141. package/datasheets/data.js +1 -0
  142. package/datasheets/formula.js +1 -0
  143. package/datasheets/gantt-paint.js +1 -0
  144. package/datasheets/gantt-resources.js +1 -0
  145. package/datasheets/gantt-shapes.js +1 -0
  146. package/datasheets/gantt.js +1 -0
  147. package/datasheets/manager.js +1 -0
  148. package/datasheets/path-binding.js +2 -0
  149. package/datasheets/persist-writer.js +2 -0
  150. package/datasheets/persist.js +1 -0
  151. package/datasheets/query-function.js +1 -0
  152. package/datasheets/remote.js +3 -0
  153. package/datasheets/report-entry.js +1 -0
  154. package/datasheets/report.js +1 -0
  155. package/datasheets/rules.js +1 -0
  156. package/datasheets/sort.js +1 -0
  157. package/datasheets/table-sheet.js +1 -0
  158. package/datasheets/view.js +3 -0
  159. package/datasheets/virtual-sheet.js +1 -0
  160. package/datasheets/window.js +1 -0
  161. package/extras/getdata/persist.js +2 -0
  162. package/extras/getdata/rows.js +1 -0
  163. package/extras/getdata/steps.js +1 -0
  164. package/i18n/dom.js +1 -0
  165. package/i18n/en/a11y.js +1 -0
  166. package/i18n/en/cells.js +1 -0
  167. package/i18n/en/charts.js +1 -0
  168. package/i18n/en/common.js +1 -0
  169. package/i18n/en/datasheets.js +1 -0
  170. package/i18n/en/format.js +1 -0
  171. package/i18n/en/misc.js +1 -0
  172. package/i18n/en/pivot.js +1 -0
  173. package/i18n/en/proofing.js +1 -0
  174. package/i18n/en/ribbon.js +1 -0
  175. package/i18n/en/shapes.js +1 -0
  176. package/i18n/en/shell.js +1 -0
  177. package/i18n/en/touch.js +1 -0
  178. package/i18n/en.js +1 -0
  179. package/i18n/index.js +1 -0
  180. package/i18n/key-text.js +1 -0
  181. package/i18n/languages.js +1 -0
  182. package/i18n/pl/a11y.js +1 -0
  183. package/i18n/pl/cells.js +1 -0
  184. package/i18n/pl/charts.js +1 -0
  185. package/i18n/pl/common.js +1 -0
  186. package/i18n/pl/datasheets.js +1 -0
  187. package/i18n/pl/format.js +1 -0
  188. package/i18n/pl/misc.js +1 -0
  189. package/i18n/pl/pivot.js +1 -0
  190. package/i18n/pl/proofing.js +1 -0
  191. package/i18n/pl/ribbon.js +1 -0
  192. package/i18n/pl/shapes.js +1 -0
  193. package/i18n/pl/shell.js +1 -0
  194. package/i18n/pl/touch.js +1 -0
  195. package/i18n/pl.js +1 -0
  196. package/io/client.js +1 -0
  197. package/io/crc32.js +1 -0
  198. package/io/crypto/aes.js +1 -0
  199. package/io/crypto/agile.js +2 -0
  200. package/io/crypto/cfb-read.js +1 -0
  201. package/io/crypto/cfb-write.js +1 -0
  202. package/io/crypto/dataspaces.js +1 -0
  203. package/io/crypto/errors.js +1 -0
  204. package/io/crypto/hash.js +1 -0
  205. package/io/crypto/index.js +1 -0
  206. package/io/crypto/package-read.js +1 -0
  207. package/io/crypto/package-write.js +1 -0
  208. package/io/crypto/spool.js +1 -0
  209. package/io/crypto/standard.js +1 -0
  210. package/io/csv.js +8 -0
  211. package/io/export-blocks.js +1 -0
  212. package/io/foreign-parts.js +1 -0
  213. package/io/foreign-sheets.js +2 -0
  214. package/io/io.worker.js +1 -0
  215. package/io/package-paths.js +1 -0
  216. package/io/plan.js +1 -0
  217. package/io/text-split.js +3 -0
  218. package/io/xlsx-read.js +1 -0
  219. package/io/xlsx-styles.js +2 -0
  220. package/io/xlsx-tail.js +1 -0
  221. package/io/xlsx-write.js +2 -0
  222. package/io/xml-escape.js +1 -0
  223. package/io/xml-scan.js +1 -0
  224. package/io/zip-reader.js +1 -0
  225. package/io/zip-writer.js +1 -0
  226. package/objects/chart-model.js +1 -0
  227. package/objects/dml.js +5 -0
  228. package/objects/drawing-xml.js +1 -0
  229. package/objects/picture-url.js +1 -0
  230. package/package.json +57 -4
  231. package/pivot/engine.js +1 -0
  232. package/pivot/xml.js +2 -0
  233. package/print/page-setup.js +1 -0
  234. package/print/paginate.js +1 -0
  235. package/print/pdf.js +35 -0
  236. package/print/render-page.js +3 -0
  237. package/render/patterns.js +1 -0
  238. package/shapes/form-xml.js +1 -0
  239. package/shapes/watermark.js +1 -0
  240. package/slicers/custom-styles.js +1 -0
  241. package/slicers/date-filters.js +1 -0
  242. package/slicers/format.js +2 -0
  243. package/slicers/pivot-file.js +1 -0
  244. package/slicers/structured.js +1 -0
  245. package/slicers/table-file.js +1 -0
  246. package/slicers/write.js +1 -0
  247. package/sparklines/colors.js +1 -0
  248. package/sparklines/data.js +1 -0
  249. package/sparklines/descriptor.js +1 -0
  250. package/sparklines/excel-paint.js +1 -0
  251. package/sparklines/functions.js +1 -0
  252. package/sparklines/paint-core.js +1 -0
  253. package/sparklines/paint-measure.js +1 -0
  254. package/sparklines/paint-other.js +2 -0
  255. package/sparklines/paint-series.js +1 -0
  256. package/sparklines/paint.js +1 -0
  257. package/sparklines/print.js +1 -0
  258. package/sparklines/rule.js +1 -0
  259. package/table-view/api.js +1 -0
  260. package/table-view/cell-editor.js +1 -0
  261. package/table-view/cell-format.js +1 -0
  262. package/table-view/chrome.js +1 -0
  263. package/table-view/client.js +1 -0
  264. package/table-view/column-drag.js +1 -0
  265. package/table-view/column-input.js +1 -0
  266. package/table-view/column-window.js +1 -0
  267. package/table-view/events.js +1 -0
  268. package/table-view/files.js +1 -0
  269. package/table-view/grid-keys.js +2 -0
  270. package/table-view/index.d.ts +4 -0
  271. package/table-view/index.js +1 -0
  272. package/table-view/labels.js +1 -0
  273. package/table-view/model.js +1 -0
  274. package/table-view/mount.js +1 -0
  275. package/table-view/panel.js +1 -0
  276. package/table-view/pivot.js +1 -0
  277. package/table-view/public.d.ts +841 -0
  278. package/table-view/quick-filter.js +1 -0
  279. package/table-view/reader.worker.js +1 -0
  280. package/table-view/remote.js +1 -0
  281. package/table-view/row-cache.js +1 -0
  282. package/table-view/row-selection.js +1 -0
  283. package/table-view/table-css.js +1207 -0
  284. package/table-view/totals.js +1 -0
  285. package/table-view/version.js +1 -0
  286. package/table-view/worksheet-table.js +1 -0
  287. package/ui/dialogs.js +3 -0
  288. package/ui/dom.js +1 -0
  289. package/ui/icons.js +1 -0
  290. package/ui/menu-base.js +1 -0
  291. package/ui/protection-ui.js +1 -0
  292. package/ui/ui-scale.js +1 -0
@@ -0,0 +1,206 @@
1
+ const r=`
2
+ .menu button[aria-checked] { padding-left: 28px; position: relative; }
3
+ .menu.menu-icons > button[aria-checked] { padding-left: 36px; }
4
+ .menu button[aria-checked="true"]::before { content: "✓"; position: absolute; left: 10px; }
5
+ .menu.menu-icons > button[aria-checked="true"]::before { left: 12px; }
6
+ .menu .bk-kbd { margin-left: auto; padding-left: 24px; color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
7
+ .menu .bk-sub::after { content: ""; flex: none; width: 6px; height: 6px; margin-left: auto; margin-right: 2px; border: solid var(--ink-soft); border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); }
8
+ .menu .bk-sub:has(.bk-kbd)::after { margin-left: 12px; }
9
+ .menu .bk-sub-menu { position: fixed; }
10
+
11
+ #sheetbar { position: relative; min-width: 0; }
12
+ #sheetbar[dir="rtl"] .sheet-nav svg { transform: scaleX(-1); }
13
+ #sheetbar .bk-tab-area { display: flex; align-items: stretch; min-width: 0; flex: 0 0 var(--bk-tab-share, 60%); }
14
+ #sheetbar .bk-tab-area #sheet-tabs { flex: 0 1 auto; }
15
+ #sheet-tabs { scrollbar-width: none; }
16
+ .sheet-nav button:disabled { opacity: 0.35; }
17
+ .bk-tab-split { flex: none; width: 7px; cursor: col-resize; display: grid; place-items: center; }
18
+ .bk-tab-split::before { content: ""; width: 1px; height: 14px; background: var(--ink-off); }
19
+ .bk-tab-split:hover::before { background: var(--accent); width: 3px; border-radius: 2px; }
20
+ .bk-hbar-slot { flex: 1 1 0; min-width: 0; position: relative; }
21
+ .bk-hbar-slot .sb { position: absolute; left: 0; right: 8px; top: 6px; bottom: auto; height: 12px; opacity: 1; }
22
+ .bk-hbar-slot .sb-thumb { background: var(--ink-off); }
23
+ .bk-hbar-slot .sb-thumb:hover { background: var(--ink-soft); }
24
+ #grid-host.bk-hbar-out .sb-v { bottom: 0; }
25
+ .sheet-tab.bk-grouped { background: var(--sheet-active-bg); color: var(--sheet-active-ink); }
26
+ .sheet-tab[aria-selected="true"] { box-shadow: inset 0 -2px 0 var(--accent); }
27
+ .bk-insert-mark { position: fixed; z-index: 40; width: 0; height: 0; border: 5px solid transparent; border-top-color: var(--accent); pointer-events: none; transform: translate(-5px, -2px); }
28
+ .bk-insert-mark.vertical { border-top-color: transparent; border-left-color: var(--accent); transform: translate(0, -5px); }
29
+ .bk-tab-drag { cursor: grabbing; }
30
+ .bk-tab-drag.bk-tab-copy { cursor: copy; }
31
+ #app.bk-tabs-left #workspace, #app.bk-tabs-right #workspace { flex-direction: row; }
32
+ #workspace > #sheetbar { flex: 0 0 var(--bk-tab-width, 120px); flex-direction: column; border-top: 0; order: -1; border-right: 1px solid var(--bar-line); overflow: hidden; }
33
+ #app.bk-tabs-right #workspace > #sheetbar { order: 3; border-right: 0; border-left: 1px solid var(--bar-line); }
34
+ #workspace > #sheetbar .bk-tab-area { flex: 1 1 0; flex-direction: column; min-height: 0; }
35
+ #workspace > #sheetbar #sheet-tabs { flex-direction: column; flex: 1 1 0; overflow-y: auto; }
36
+ #workspace > #sheetbar .sheet-tab { padding: 4px 10px; min-height: 24px; }
37
+ #workspace > #sheetbar .sheet-nav { justify-content: center; padding: 4px; }
38
+ #workspace > #sheetbar #sheet-add { align-self: center; margin: 2px; }
39
+ #app > #sheetbar.bk-top { border-top: 0; border-bottom: 1px solid var(--bar-line); }
40
+
41
+ .bk-status-item { margin-left: 12px; white-space: nowrap; }
42
+ .bk-status-item.clickable { cursor: default; border-radius: 3px; padding: 0 4px; }
43
+ .bk-status-item.clickable:hover { background: var(--hover); }
44
+ #status-left { display: flex; align-items: center; gap: 0; }
45
+ .bk-view-shortcuts { display: flex; gap: 2px; margin-right: 8px; }
46
+ .bk-view-shortcuts button { display: inline-grid; place-items: center; width: 22px; height: 18px; border-radius: 3px; color: var(--ink-soft); font-size: 11px; }
47
+ .bk-view-shortcuts button:hover { background: var(--hover); }
48
+ .bk-view-shortcuts button[aria-pressed="true"] { background: var(--pressed); }
49
+
50
+ .bk-tip { position: fixed; z-index: 60; padding: 2px 6px; border-radius: 3px; background: #ffffe1; color: #000; border: 1px solid #8a8a60; font-size: 11px; white-space: nowrap; pointer-events: none; box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.25); }
51
+
52
+ .bk-panel { position: fixed; z-index: 30; width: 460px; max-width: calc(100vw - 24px); padding: 12px 14px; border: 1px solid var(--panel-line); border-radius: 10px; background: var(--menu); color: var(--ink); box-shadow: var(--shadow); }
53
+ .bk-panel.xl-dlg { width: 615px; padding: 8px 20px 18px; }
54
+ .bk-panel.xl-dlg .bk-panel-title { margin: 0 0 12px; font-size: 13px; color: var(--ink-soft); }
55
+ .bk-find-box { padding: 26px 20px 10px; }
56
+ .bk-find-box .bk-find-grid { grid-template-columns: 92px minmax(0, 1fr); row-gap: 8px; }
57
+ .bk-find-box .bk-find-grid > span { text-align: right; }
58
+ .bk-find-box .dlg-row { min-height: 24px; }
59
+ .bk-find-field { position: relative; flex: 1; min-width: 0; display: flex; }
60
+ .bk-find-field input { width: 100%; padding-right: 22px; }
61
+ .bk-find-history { position: absolute; right: 3px; top: 3px; display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; color: var(--ink); }
62
+ .bk-find-box .bk-find-opts { grid-template-columns: 92px 170px minmax(0, 1fr); margin-top: 10px; }
63
+ .bk-find-box .bk-find-opts > span:not(:empty) { text-align: right; }
64
+ .bk-find-low { display: flex; align-items: center; gap: 8px; min-height: 24px; margin-top: 14px; }
65
+ .bk-find-low .dlg-status { flex: 1; min-width: 0; margin: 0; }
66
+ .bk-panel.xl-dlg .bk-find-foot { flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
67
+ /* Buttons keep their words whole; longer labels, as in Polish, take a second row. */
68
+ .bk-panel.xl-dlg .bk-find-foot .dlg-btn { flex: 0 0 auto; min-width: 90px; }
69
+ .bk-panel.xl-dlg .bk-find-fmt[hidden] { display: none; }
70
+ .bk-special .bk-grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 8px; }
71
+ .bk-special .dlg-check { min-height: 22px; }
72
+ .bk-special-low { min-height: 46px; }
73
+ .bk-special-opts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 8px; }
74
+ .bk-special-none { margin: 0; }
75
+ .bk-above { display: block; }
76
+ .bk-above > span { display: block; margin-bottom: 5px; }
77
+ .bk-goto-list { display: block; height: 138px; min-width: 0; }
78
+ .xl-zoom { gap: 0; }
79
+ .xl-zoom .dlg-check { min-height: 19px; }
80
+ .xl-zoom .dlg-label { margin-bottom: 4px; }
81
+ .xl-zoom .fc-num { width: 40px; margin: 0 2px 0 4px; }
82
+ .bk-style-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
83
+ .bk-style-top label, .bk-style-top-prev { display: flex; align-items: center; gap: 6px; white-space: nowrap; min-width: 0; }
84
+ .bk-style-top input { flex: 1; min-width: 0; width: auto; }
85
+ .bk-style-preview { flex: 1; min-width: 0; height: 22px; display: flex; align-items: center; padding: 0 6px; overflow: hidden; white-space: nowrap; }
86
+ .bk-style-list { padding-bottom: 4px; }
87
+ .bk-style-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; min-height: 18px; padding: 0 8px; }
88
+ .bk-style-row > span:first-child { display: flex; align-items: center; }
89
+ .bk-style-format { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
90
+ .bk-style-head { min-height: 24px; font-size: 11px; font-weight: 600; border-bottom: 1px solid var(--xl-box-line); margin-bottom: 2px; }
91
+ .xl-dlg .bk-form { grid-template-columns: 96px minmax(0, 1fr); }
92
+ .xl-dlg .bk-form > span { text-align: right; }
93
+ .bk-tabbed-panes { height: 100%; }
94
+ .bk-box-tabs { flex: 1; min-height: 0; overflow: auto; padding: 22px 18px 12px; }
95
+ .bk-props-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
96
+ .bk-props-head svg { flex: none; }
97
+ .bk-props-rule { border: 0; border-top: 1px solid var(--xl-box-line); margin: 0 0 12px; }
98
+ .xl-dlg .bk-facts { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px 8px; margin: 0; }
99
+ .xl-dlg .bk-facts dt { text-align: right; color: var(--ink-soft); }
100
+ .xl-dlg .bk-facts dd { margin: 0; word-break: break-word; }
101
+ .bk-attr { display: flex; gap: 12px; }
102
+ .bk-outline-col { gap: 0; }
103
+ .xl-tall .ln-tabs { flex: 1; min-height: 0; }
104
+ .xl-tall .ln-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
105
+ .xl-tall .ln-tabs .dlg-panes { flex: 1; min-height: 0; overflow: auto; }
106
+ .xl-tall[open] { display: flex; flex-direction: column; overflow: hidden; }
107
+ .xl-tall .dlg-body { flex: 1; min-height: 0; display: flex; }
108
+ .xl-tall .xl-tabbed { flex: 1; min-width: 0; }
109
+ .dv-grid { display: grid; grid-template-columns: minmax(0, 1fr) 118px; gap: 8px 16px; align-items: end; }
110
+ .dv-grid select.dlg-input { width: 100%; }
111
+ .dv-field { margin-top: 8px; }
112
+ .dv-apply { position: absolute; left: 18px; bottom: 12px; right: 18px; }
113
+ .bk-box-tabs.dv-pane { position: relative; }
114
+ .dv-pane .dlg-check { min-height: 22px; }
115
+ .dv-pane textarea { display: block; width: 100%; height: 60px; resize: none; }
116
+ .ln-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-bottom: 14px; }
117
+ .ln-tabs .dlg-panes { padding: 22px 18px 16px; }
118
+ .ln-tabs .ln-say { margin: 0 0 8px; }
119
+ .ln-line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; }
120
+ .bk-panel-title { font-size: 13px; font-weight: 600; margin: 0 0 8px; cursor: move; }
121
+ .bk-panel .dlg-row label { display: inline-flex; align-items: center; gap: 4px; }
122
+ .bk-find-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 8px; align-items: center; }
123
+ .bk-find-opts { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 8px; align-items: center; margin-top: 8px; }
124
+ .bk-find-foot { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-top: 10px; }
125
+ .bk-progress { height: 3px; background: var(--panel-line); border-radius: 2px; overflow: hidden; margin-top: 6px; }
126
+ .bk-progress div { height: 100%; width: 0; background: var(--accent); }
127
+ .bk-results { margin-top: 8px; font-size: 11px; }
128
+ .bk-results-head { display: grid; grid-template-columns: 1fr 70px 1.4fr 1.4fr; border-bottom: 1px solid var(--field-line); }
129
+ .bk-results-head button { text-align: left; padding: 3px 6px; font-weight: 600; }
130
+ .bk-results-head button:hover { background: var(--hover); }
131
+ .bk-results-body { position: relative; height: 180px; overflow-y: auto; }
132
+ .bk-results-row { position: absolute; left: 0; right: 0; height: 20px; display: grid; grid-template-columns: 1fr 70px 1.4fr 1.4fr; align-items: center; }
133
+ .bk-results-row:hover { background: var(--hover); }
134
+ .bk-results-row.active { background: var(--pressed); }
135
+ .bk-results-row span { padding: 0 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
136
+ .bk-fmt-chip { min-width: 90px; height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; border: 1px solid var(--field-line); border-radius: 3px; background: #fff; color: #000; font-size: 11px; }
137
+
138
+ .bk-table { width: 100%; border-collapse: collapse; font-size: 12px; }
139
+ .bk-table th { text-align: left; font-weight: 600; padding: 3px 6px; position: sticky; top: 0; background: var(--menu); }
140
+ .bk-table td { padding: 2px 6px; vertical-align: top; }
141
+ .bk-table tr.selected td { background: var(--pressed); }
142
+ .bk-table tr:hover td { background: var(--hover); }
143
+ .bk-table .bk-kbd-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
144
+ .bk-table .bk-dim { color: var(--ink-soft); }
145
+ .bk-scroll { max-height: 56vh; overflow: auto; }
146
+ .bk-section { font-weight: 600; margin: 10px 0 4px; }
147
+ .bk-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
148
+ .bk-form { display: grid; grid-template-columns: 110px 1fr; gap: 6px 8px; align-items: center; }
149
+ .bk-form textarea { resize: vertical; min-height: 54px; height: 54px; }
150
+ .bk-facts { display: grid; grid-template-columns: 110px 1fr; gap: 4px 8px; }
151
+ .bk-facts dt { color: var(--ink-soft); }
152
+ .bk-facts dd { margin: 0; user-select: text; word-break: break-all; }
153
+
154
+ .bk-style-gallery { display: grid; grid-template-columns: repeat(4, 112px); gap: 4px; padding: 2px; }
155
+ .bk-style-label { grid-column: 1 / -1; color: var(--ink-soft); font-size: 11px; margin-top: 6px; }
156
+ .bk-style-swatch { min-height: 26px; width: 112px; padding: 2px 6px; display: flex !important; align-items: center; overflow: hidden; white-space: nowrap; border: 1px solid var(--field-line) !important; border-radius: 2px !important; background: #fff; color: #000; font-size: 11px; }
157
+ .bk-style-swatch:hover { outline: 2px solid var(--accent); }
158
+ .bk-style-swatch.current { outline: 2px solid var(--accent); }
159
+
160
+ .name-box-wrap { position: relative; display: flex; align-items: center; }
161
+ .bk-name-drop { flex: none; width: 14px; height: 22px; display: grid; place-items: center; color: var(--ink-soft); border-radius: 3px; }
162
+ .bk-name-drop:hover { background: var(--hover); }
163
+ .bk-name-grip { flex: none; width: 5px; align-self: stretch; cursor: col-resize; }
164
+ .bk-fx-toggle { flex: none; width: 18px; height: 22px; display: grid; place-items: center; color: var(--ink-soft); border-radius: 3px; }
165
+ .bk-fx-toggle:hover { background: var(--hover); }
166
+ #app.bk-fx-expanded #formula-bar { align-items: flex-start; padding-top: 3px; padding-bottom: 3px; }
167
+ #app.bk-fx-expanded #formula-input { height: 72px; }
168
+
169
+ .bk-note { position: absolute; z-index: 6; border: 1px solid #808080; background: #ffffe1; color: #000; box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.3); padding: 2px 3px; white-space: pre-wrap; overflow: hidden; cursor: move; font-size: 10px; line-height: 1.25; }
170
+ .bk-note-edit { padding: 4px 5px; border-style: dashed !important; }
171
+ .bk-note-text { display: block; width: 100%; height: 100%; resize: none; outline: 0; padding: 0; background: transparent; color: inherit; cursor: text; user-select: text; }
172
+ .bk-note-body { height: 100%; overflow: hidden; pointer-events: none; }
173
+ .bk-note-grip { position: absolute; right: 0; bottom: 0; width: 8px; height: 8px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, #808080 50%); }
174
+ .bk-mentions { position: fixed; z-index: 50; min-width: 150px; max-height: 40vh; overflow-y: auto; padding: 5px; border-radius: 8px; background: var(--menu); color: var(--ink); box-shadow: var(--shadow); }
175
+ .bk-mentions button { display: block; width: 100%; min-height: 24px; padding: 3px 8px; border-radius: 4px; text-align: left; }
176
+ .bk-mentions button:hover { background: var(--hover); }
177
+ .tb-caret { width: 12px !important; margin-left: -2px; }
178
+ .bk-undo-list button { min-width: 180px; }
179
+ .bk-undo-count { padding: 4px 8px 2px; color: var(--ink-soft); font-size: 11px; border-top: 1px solid var(--panel-line); margin-top: 4px; }
180
+
181
+ #grid-host.bk-sb-skin .sb { opacity: 1; background: var(--bk-sb-track, rgba(0, 0, 0, 0.05)); }
182
+ .sb-end { display: none; position: absolute; width: 12px; height: 12px; padding: 0; border: 0; background: var(--bar); color: var(--ink-soft); }
183
+ .bk-has-ends .sb-end { display: block; }
184
+ .sb-end:hover { background: var(--hover); }
185
+ .sb-end::before { content: ""; position: absolute; inset: 0; margin: auto; width: 0; height: 0; border: 4px solid transparent; }
186
+ .sb-v .sb-end { left: 0; }
187
+ .sb-v .sb-end-start { top: 0; }
188
+ .sb-v .sb-end-start::before { border-bottom-color: currentColor; transform: translateY(-2px); }
189
+ .sb-v .sb-end-stop { bottom: 0; }
190
+ .sb-v .sb-end-stop::before { border-top-color: currentColor; transform: translateY(2px); }
191
+ .sb-h .sb-end { top: 0; }
192
+ .sb-h .sb-end-start { left: 0; }
193
+ .sb-h .sb-end-start::before { border-right-color: currentColor; transform: translateX(-2px); }
194
+ .sb-h .sb-end-stop { right: 0; }
195
+ .sb-h .sb-end-stop::before { border-left-color: currentColor; transform: translateX(2px); }
196
+ .bk-tab-icon { flex: none; margin: 0 3px; }
197
+ .sheet-tab[data-tstyle] { color: var(--bk-tab-fg, inherit); background: var(--bk-tab-bg, none); font: var(--bk-tab-font, inherit); }
198
+ .sheet-tab[data-tstyle]:hover { color: var(--bk-tab-hover-fg, var(--bk-tab-fg, inherit)); background: var(--bk-tab-hover-bg, var(--bk-tab-bg, none)); font: var(--bk-tab-hover-font, var(--bk-tab-font, inherit)); }
199
+ #grid-host.bk-sb-mobile .sb-v { width: 6px; }
200
+ #grid-host.bk-sb-mobile .sb-h { height: 6px; }
201
+ #grid-host.bk-sb-mobile .sb-thumb { border-radius: 3px; }
202
+ #grid-host.bk-sb-mobile .sb-v .sb-thumb { left: 1px; right: 1px; }
203
+ #grid-host.bk-sb-mobile .sb-h .sb-thumb { top: 1px; bottom: 1px; }
204
+ .bk-sb-colors .sb-thumb { background: var(--bk-sb-thumb) !important; }
205
+ .bk-sb-colors .sb { background: var(--bk-sb-track, transparent); }
206
+ `;let t=!1;function i(){if(t)return;t=!0;const e=document.createElement("style");e.dataset.module="book",e.textContent=r,document.head.append(e)}export{i as ensureBookCss};
@@ -0,0 +1 @@
1
+ import{child as x,parseTree as S}from"../io/xml-scan.js";import{parseStyles as g}from"../io/xlsx-styles.js";import{docPropsPaths as T,parseDocProps as v,PARTS as w}from"./docprops-xml.js";import{countStyleXfs as D,readNamedStyles as R}from"./cell-styles-xml.js";import{readBookView as b}from"./view-xml.js";import{viewOf as B}from"./book-view.js";import{applyNoteShapes as N}from"./note-xml.js";import{relsPathOf as y,resolveTarget as d,sheetPartsByName as O}from"../io/package-paths.js";let P=null;function j(t){P=t}async function s(t,e){return e&&t.has(e)?t.text(e):null}async function V(t,e,r){if(!r||!e.sheets.some(o=>o.comments?.size))return;const n=await O(t);for(const o of e.sheets){if(!o.comments?.size)continue;const a=n.get(o.name);if(!a)continue;const c=await s(t,y(a));if(!c)continue;const m=[...c.matchAll(/<Relationship\b[^>]*\/>/g)].map(f=>f[0]).find(f=>/\/vmlDrawing"/.test(f)),i=m&&await s(t,d(a,/\bTarget="([^"]+)"/.exec(m)?.[1]??""));i&&N(o,i)}}async function q(t,e){try{const r=await s(t,"_rels/.rels")??"",n=T(r);e.docProps=v({core:await s(t,n.core??w.core.path),app:await s(t,n.app??w.app.path),custom:await s(t,n.custom??w.custom.path)},n);const o=/<Relationship\b[^>]*officeDocument\/2006\/relationships\/officeDocument[^>]*\/>/.exec(r)?.[0],a=o?d("",/\bTarget="([^"]+)"/.exec(o)?.[1]??"xl/workbook.xml"):"xl/workbook.xml",c=await s(t,a);if(c){const l=S(new TextEncoder().encode(c));b(x(x(l,"bookViews"),"workbookView")?.a,B(e))}const m=await s(t,y(a))??"",i=/<Relationship\b[^>]*relationships\/styles"[^>]*\/>/.exec(m)?.[0],f=i?d(a,/\bTarget="([^"]+)"/.exec(i)?.[1]??""):"xl/styles.xml",h=await s(t,f);h&&(e.namedStyles=R(h,e.theme??[],g),e.styleXfCount=D(h)),await V(t,e,c);const u=e.view?.normalDefaults;if(u)for(const l of e.sheets)l.cols.changeDefaultSize(u.col);const p=e.sheets.filter(l=>l.tabSelected&&!l.hidden);p.length>1&&p.includes(e.sheet)&&(e.selectedSheets=new Set(p))}catch(r){console.warn("Workbook options could not be read",r)}P?.(e)}export{q as loadBookParts,j as setBookPartsListener};
@@ -0,0 +1 @@
1
+ import{registerSection as f}from"./sections.js";const n=Object.freeze({showHScroll:!0,showVScroll:!0,showTabs:!0,tabRatio:.6,firstSheet:0,tabPosition:"bottom",tabWidth:120,newTab:!0,tabNav:!0,allSheets:"auto",allowSheetReorder:!0,tabEditable:!0,showFormulaBar:!0,showStatusBar:!0,formulaBarExpanded:!1,nameBoxWidth:88,ribbonMinimized:!1,widgetBorder:null,selectionBackColor:null,selectionBorderColor:null,defaultSheetTabStyles:null,deselectKeys:!1,normalDefaults:null,scrollAppearance:"overlay",scrollColors:null,scrollbarShowMax:!1,scrollbarMaxAlign:!1,scrollIgnoreHidden:!0,scrollByCell:!1,scrollPixel:1,allowUserZoom:!0,allowContextMenu:!0,allowUndo:!0,allowUserDeselect:!0,enterDirection:"down",fixedDecimal:0,tips:{resize:!0,scroll:!0,fill:!0,drop:!0},statusItems:null,statusCustom:null,focusCell:null,keymap:null}),s=new Set(["showHScroll","showVScroll","showTabs","tabRatio","firstSheet"]);function c(e){return e.view||(e.view={}),e.view}function w(e,t){const l=e.view?.[t];return l===void 0?n[t]:l}function b(e,t,l){c(e)[t]=l,e.dirty=!0}const u=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t),r=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);f("bookView",{book:{save(e){const t=e.view;if(!t)return;const l={};for(const[i,o]of Object.entries(t))!s.has(i)&&i in n&&!u(o,n[i])&&(l[i]=o);return Object.keys(l).length?l:void 0},load(e,t){if(!r(t))return;const l=c(e);for(const[i,o]of Object.entries(t)){if(s.has(i)||!(i in n))continue;const a=n[i];a!==null&&typeof a!=typeof o||(l[i]=o)}}},sheet:{save(e){const t={};return e.areaOffset&&(t.areaOffset=e.areaOffset),e.selectionPolicy&&(t.selectionPolicy=e.selectionPolicy),e.selectionUnit&&(t.selectionUnit=e.selectionUnit),e.gridlineAxes&&(t.gridlineAxes=e.gridlineAxes),e.gridColor&&(t.gridColor=e.gridColor),e.protectionExtras&&(t.protectionExtras=e.protectionExtras),e.tabStyles&&(t.tabStyles=e.tabStyles),Object.keys(t).length?t:void 0},load(e,t){if(r(t)){if(r(t.areaOffset)){const l=i=>Number.isFinite(i)?Math.max(0,Math.min(200,i)):0;e.areaOffset={left:l(t.areaOffset.left),top:l(t.areaOffset.top)}}["single","range","multiRange"].includes(t.selectionPolicy)&&(e.selectionPolicy=t.selectionPolicy),["cell","row","column"].includes(t.selectionUnit)&&(e.selectionUnit=t.selectionUnit),r(t.gridlineAxes)&&(e.gridlineAxes={horizontal:t.gridlineAxes.horizontal!==!1,vertical:t.gridlineAxes.vertical!==!1}),typeof t.gridColor=="string"&&(e.gridColor=t.gridColor),r(t.protectionExtras)&&(e.protectionExtras={outline:t.protectionExtras.outline===!0}),r(t.tabStyles)&&(e.tabStyles=t.tabStyles)}}}});export{n as BOOK_VIEW_DEFAULTS,w as viewGet,c as viewOf,b as viewSet};
@@ -0,0 +1 @@
1
+ import{BOOL as y,EMPTY as v,ERR as z,ERRORS as T,NUM as g,STR as k}from"../core/sheet.js";import{registerSparseMap as E,sparseKey as O}from"../core/sparse.js";import{registerSection as Y}from"./sections.js";E("cellDefaults");const m=16384;function R(t,l,f,i,o){if(o.f===void 0)return typeof o.v=="number"?{kind:g,value:o.v}:typeof o.v=="boolean"?{kind:y,value:o.v?1:0}:{kind:k,value:t.strings.add(String(o.v))};const{engine:n}=t;if(!n)return{kind:v,value:0};try{const r=n.template(o.f,f,i).fn(f,i,l),e=r?.sheet?n.refAuto(r,f,i):r;return typeof e=="number"?{kind:g,value:e}:typeof e=="boolean"?{kind:y,value:e?1:0}:typeof e=="string"?{kind:k,value:t.strings.add(e)}:e&&e.code!==void 0?{kind:z,value:Math.max(0,T.indexOf(e.code))}:{kind:v,value:0}}catch{return{kind:v,value:0}}}function B(t,l,f,i,o,n,r,e,s,a,u){const{book:p,dpr:M}=t;for(const[x,S]of f.cellDefaults){const c=Math.floor(x/m),d=x-c*m;if(c<o||c>n||d<r||d>e||f.kind(c,d)!==0)continue;const{kind:D,value:C}=R(p,f,c,d,S);if(D===v)continue;const b=Math.round(i.x*M+(f.cols.offsetOf(d)-i.originX)*s),A=Math.round(i.y*M+(f.rows.offsetOf(c)-i.originY)*s),h=Math.round(f.cols.sizeOf(d)*s),w=Math.round(f.rows.sizeOf(c)*s);h>0&&w>0&&t._paintText(l,c,d,D,C,b,A,h,w,s,r,e,a,u)}}function H(t,l,f){const{book:i,grid:o}=t,n=i.sheet;i.guardHint={ranges:l},i.transact("entry",()=>{const r=n.cellDefaults??null,e=new Map(r??[]);for(const a of l)for(let u=a.r0;u<=Math.min(a.r1,a.r0+1e5);u++)for(let p=a.c0;p<=Math.min(a.c1,a.c0+1e3);p++)f===void 0?e.delete(O(u,p)):e.set(O(u,p),f);n.cellDefaults=e.size>0?e:null,n.cellTypesChanged=!0;const s=a=>()=>{const u=n.cellDefaults;return n.cellDefaults=a,n.cellTypesChanged=!0,s(u)};return s(r)}),o.invalidate()}function I(t){for(const l of t.sheets){if(!l.cellDefaults)continue;const f=new Map;for(const[i,o]of l.cellDefaults){const n=Math.floor(i/m),r=i-n*m;if(l.kind(n,r)!==0)continue;const e=R(t,l,n,r,o);e.kind!==v&&(l._ensure(n,r),n>l.maxRow&&(l.maxRow=n),r>l.maxCol&&(l.maxCol=r),f.set(i,e))}l.defaultsForSave=f.size>0?f:null}}const F=t=>typeof t=="number"||typeof t=="boolean"||typeof t=="string";Y("cellDefaults",{sheet:{save(t){return t.cellDefaults?.size>0?[...t.cellDefaults]:void 0},load(t,l,f){if(!Array.isArray(l))return;const i=l.filter(o=>Array.isArray(o)&&Number.isInteger(o[0])&&o[1]&&(typeof o[1].f=="string"||F(o[1].v)));t.cellDefaults=i.length>0?new Map(i):null;for(const[o,n]of i){const r=Math.floor(o/m),e=o-r*m,s=t.kind(r,e)&7;if(s===v)continue;(n.f!==void 0||(s===g?t.value(r,e)===n.v:s===k?f.strings.get(t.value(r,e))===String(n.v):s===y))&&!(t.kind(r,e)&8)&&t.setCell(r,e,0,0)}}}});export{R as defaultValueAt,B as paintCellDefaults,I as prepareDefaultsForSave,H as setCellDefaults};
@@ -0,0 +1 @@
1
+ import{registerSection as d}from"./sections.js";import{rangeRef as u,parseRangeRef as S,MAX_COLS as m,MAX_ROWS as b}from"../core/address.js";import{CHUNK_BITS as A,CHUNK_MASK as T}from"../core/sheet.js";import{registerSparseMap as k,setSparse as v}from"../core/sparse.js";import{makeCellButtons as M}from"../celltypes/cell-buttons.js";k("valueMeta",{moved:!1});const w=4e6;function B(e,r,t){e.applyStyle(r,{ext:t})}function H(e,r,t){e.transact("tag",l=>v(l.sheet,"cellTags",r,t===null?void 0:t))}const C=(e,r,t)=>e.cellTags?.get(r*16384+t)??null;function K(e,r,t,l){const n=r==="row"?"rowTags":"colTags";e[n]??=new Map,l===null?e[n].delete(t):e[n].set(t,l)}function F(e,r,t){return C(e,r,t)??e.rowTags?.get(r)??e.colTags?.get(t)??e.tag??null}const g=/^#[0-9a-fA-F]{6}$/,c=(e,r,t)=>typeof e=="number"&&e>=r&&e<=t?e:void 0;function E(e){const r={};if(!e||typeof e!="object")return r;if(Array.isArray(e.pad)&&e.pad.length===4&&e.pad.every(t=>c(t,0,2e3)!==void 0)&&(r.pad=e.pad),typeof e.watermark=="string"&&(r.watermark=e.watermark.slice(0,1e3)),e.label&&typeof e.label=="object"){const t={};["visible","hidden","auto"].includes(e.label.visibility)&&(t.visibility=e.label.visibility),["topLeft","topCenter","topRight","bottomLeft","bottomCenter","bottomRight","leftCenter","rightCenter"].includes(e.label.alignment)&&(t.alignment=e.label.alignment),g.test(e.label.color)&&(t.color=e.label.color),typeof e.label.font=="string"&&(t.font=e.label.font.replace(/["\\]/g,"").slice(0,60)),c(e.label.size,4,72)&&(t.size=e.label.size),c(e.label.margin,0,100)!==void 0&&(t.margin=e.label.margin),r.label=t}if(e.ellipsis===!0&&(r.ellipsis=!0),Array.isArray(e.buttons)){const t=M(e.buttons);t!==null&&(r.buttons=t)}if(e.tip===!0&&(r.tip=!0),e.overline===!0&&(r.overline=!0),e.noEdit===!0&&(r.noEdit=!0),e.fold&&typeof e.fold=="object"){const t={};["topLeft","topRight","bottomLeft","bottomRight"].includes(e.fold.pos)&&(t.pos=e.fold.pos),c(e.fold.size,2,100)&&(t.size=e.fold.size),g.test(e.fold.color)&&(t.color=e.fold.color),g.test(e.fold.markColor)&&(t.markColor=e.fold.markColor),r.fold=t}return Array.isArray(e.icons)&&(r.icons=e.icons.slice(0,8).filter(t=>typeof t?.id=="string").map(t=>({id:t.id,pos:t.pos==="right"?"right":"left",...c(t.w,2,200)?{w:t.w}:{},...c(t.h,2,200)?{h:t.h}:{}}))),e.bg&&typeof e.bg.id=="string"&&(r.bg={id:e.bg.id,layout:["stretch","center","zoom","none"].includes(e.bg.layout)?e.bg.layout:"stretch"}),e.mask&&typeof e.mask.pattern=="string"&&(r.mask={pattern:e.mask.pattern.slice(0,200)},typeof e.mask.placeholder=="string"&&(r.mask.placeholder=e.mask.placeholder.slice(0,1)),e.mask.excludeLiteral===!0&&(r.mask.excludeLiteral=!0),e.mask.excludePlaceholder===!0&&(r.mask.excludePlaceholder=!0)),["auto","active","inactive","disabled"].includes(e.ime)&&(r.ime=e.ime),r}function z(e){e.sort((i,s)=>i%16384-s%16384||i-s);const r=[];let t=-1,l=-1;const n=()=>{if(t<0)return;const i=Math.floor(t/16384),s=t-i*16384;r.push(u({r0:i,c0:s,r1:Math.floor(l/16384),c1:s}))};for(const i of e)t>=0&&i===l+16384||(n(),t=i),l=i;return n(),r}function _(e,r){const{styles:t}=r;if(!t.hasExt)return;const l=new Map,n=(i,s)=>{let o=l.get(i);o===void 0&&(o={keys:[],axes:[]},l.set(i,o)),typeof s=="number"?o.keys.push(s):o.axes.push(s)};if(e.columns.forEach((i,s)=>{i.forEach((o,a)=>{if(o.styles!==null)for(let f=0;f<=T;f++){const p=o.styles[f];if(p===0)continue;const y=t.list[p]?.ext;y!==void 0&&n(JSON.stringify(y),((a<<A)+f)*16384+s)}})}),e.colStyles)for(const[i,s]of e.colStyles){const o=t.list[s]?.ext;o!==void 0&&n(JSON.stringify(o),u({r0:0,c0:i,r1:b-1,c1:i}))}if(e.rowStyles)for(const[i,s]of e.rowStyles){const o=t.list[s]?.ext;o!==void 0&&n(JSON.stringify(o),u({r0:i,c0:0,r1:i,c1:m-1}))}if(l.size!==0)return[...l].map(([i,s])=>({ext:JSON.parse(i),ref:[...z(s.keys),...s.axes].join(" ")}))}function h(e,r,t){if(!Array.isArray(r))return;let l=0;for(const n of r){const i=E(n?.ext);if(Object.keys(i).length!==0)for(const s of String(n.ref??"").split(/\s+/)){const o=S(s);if(o){if(o.r0===0&&o.r1===b-1){e.colStyles??=new Map;for(let a=o.c0;a<=o.c1;a++)e.colStyles.set(a,t.styles.derive(e.colStyles.get(a)??0,{ext:i}));continue}if(o.c0===0&&o.c1===m-1){e.rowStyles??=new Map;for(let a=o.r0;a<=o.r1;a++)e.rowStyles.set(a,t.styles.derive(e.rowStyles.get(a)??0,{ext:i}));continue}for(let a=o.r0;a<=o.r1&&l<w;a++)for(let f=o.c0;f<=o.c1&&l<w;f++,l++)e.setStyle(a,f,t.styles.derive(e.style(a,f),{ext:i}))}}}}d("ext",{sheet:{save:_,load:h}}),d("tags",{sheet:{save(e){if(!(!e.cellTags&&e.tag===void 0&&!e.rowTags&&!e.colTags))return{cells:e.cellTags?[...e.cellTags]:[],sheet:e.tag,rows:e.rowTags?[...e.rowTags]:void 0,cols:e.colTags?[...e.colTags]:void 0}},load(e,r){if(!r||typeof r!="object")return;const t=(Array.isArray(r.cells)?r.cells:[]).filter(l=>Array.isArray(l)&&Number.isInteger(l[0])&&l[0]>=0);t.length>0&&(e.cellTags=new Map(t.slice(0,1e6))),r.sheet!==void 0&&(e.tag=r.sheet),Array.isArray(r.rows)&&(e.rowTags=new Map(r.rows)),Array.isArray(r.cols)&&(e.colTags=new Map(r.cols))}}});function L(e){const r=new Set;if(!e.styles.hasExt)return r;for(const t of e.styles.list)if(t?.ext?.bg&&r.add(t.ext.bg.id),t?.ext?.icons)for(const l of t.ext.icons)r.add(l.id);return r}d("images",{book:{save(e){const r=L(e);if(r.size===0||!e.images)return;const t=[];for(const l of r){const n=e.images.get(l);n&&t.push({id:l,mime:n.mime,data:n.data})}return t.length?t:void 0},load(e,r){if(Array.isArray(r)){e.images??=new Map;for(const t of r)typeof t?.id=="string"&&typeof t.mime=="string"&&typeof t.data=="string"&&/^[A-Za-z0-9+/=]*$/.test(t.data)&&e.images.set(t.id,{mime:t.mime,data:t.data})}}}});export{B as applyExt,E as cleanExt,C as getCellTag,F as getEffectiveTag,K as setAxisTag,H as setCellTag};
@@ -0,0 +1 @@
1
+ import{charsToWidth as j,widthToChars as Y}from"./axis-ops.js";import{el as i,openModal as x}from"../ui/dialogs.js";import{applyExt as T,getCellTag as q,setAxisTag as H,setCellTag as J}from"./cell-extras.js";import{addImage as B,gradientCss as G}from"./paint.js";import{setAutoMerge as N}from"./auto-merge.js";import{clearDirty as Z,getDirtyCells as Q,startTracking as ee,stopTracking as te}from"../core/changes.js";import{cellRef as oe,MAX_COLS as le,MAX_ROWS as ne}from"../core/address.js";import{maskedEntry as se,shapeMasked as re,validatePattern as K}from"./mask.js";import{parseSizeSpec as ie,setAxisSizing as U,setTrailing as ce,toggleSplit as ae}from"./panes.js";import{editOptions as E,setEditOption as I}from"./options.js";import{chooseBackground as ue,removeBackground as de}from"./background.js";import{pictureToFloating as ge,placePictureInCell as W,setPictureAlt as me,setPictureOptions as he}from"./rich-data.js";import{fetchPicture as fe,pictureUrlProblem as be}from"../objects/picture-url.js";import{t as m}from"../i18n/index.js";const a=(e,t)=>i("label",{class:"dlg-row"},`${m(e)} `,t),R=(e,t)=>i("label",{class:"dlg-row"},e,` ${m(t)}`),y=(e,t,s,o=1)=>i("input",{class:"dlg-input short",type:"number",min:t,max:s,step:o,value:e}),A=(e,t="")=>i("input",{class:"dlg-input",value:e,placeholder:t,spellcheck:!1}),D=e=>i("input",{type:"color",class:"dlg-color",value:e}),z=e=>i("input",{type:"checkbox",checked:e}),v=(e,t)=>{const s=i("select",{class:"dlg-input"});for(const[o,l]of e)s.append(i("option",{value:l,textContent:m(o)}));return s.value=t,s},P=e=>e.commands.activeStyle().ext??{},S=e=>e.grid.selection.ranges;function k(e){e.grid.invalidate(),e.afterCommand?.()}const O=[["Horizontal",[90,270,null]],["Vertical",[0,180,null]],["Diagonal up",[45,225,null]],["Diagonal down",[135,315,null]],["From corner",["tl","tr","bl","br"]],["From center",["center"]]];function pe(e,t,s,o){const l=O[e][1][t]??O[e][1][0],n=[{pos:0,color:s},{pos:1,color:o}];if(l==="center")return{type:"path",left:.5,right:.5,top:.5,bottom:.5,stops:n};if(typeof l=="string"){const r=l.endsWith("r")?1:0,c=l.startsWith("b")?1:0;return{type:"path",left:r,right:1-r,top:c,bottom:1-c,stops:n}}return l===null?{type:"linear",degree:O[e][1][0],stops:[{pos:0,color:s},{pos:.5,color:o},{pos:1,color:s}]}:{type:"linear",degree:l,stops:n}}function Ue(e,t,s){const o=D(t?.stops?.[0]?.color??"#FFFFFF"),l=D(t?.stops?.[t.stops.length-1]?.color??"#5B9BD5"),n=v(O.map(([g],h)=>[g,String(h)]),"0"),r=v([["1","0"],["2","1"],["3","2"],["4","3"]],"0"),c=i("div",{style:"width:150px;height:64px;border:1px solid var(--line,#999)","aria-label":m("Sample")}),u=()=>pe(Number(n.value),Number(r.value),o.value.toUpperCase(),l.value.toUpperCase()),d=()=>{const g=O[Number(n.value)][1].length;[...r.options].forEach((h,b)=>{h.hidden=b>=g}),Number(r.value)>=g&&(r.value="0"),c.style.background=G(u())};for(const g of[o,l,n,r])g.addEventListener("input",d);d(),x(e,"Fill Effects",i("div",{class:"dlg-form"},a("Color 1:",o),a("Color 2:",l),a("Shading styles:",n),a("Variants:",r),i("div",{class:"dlg-label",textContent:m("Sample")}),c),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>s(u())}],{width:340})}function ve(e){const t=P(e),s=t.pad??[0,0,0,0],[o,l,n,r]=s.map(w=>y(w,0,2e3)),c=A(t.watermark??"",m("Text shown in an empty cell")),u=z(t.label!==void 0),d=v([["Always","visible"],["When the cell is empty or active","auto"],["Only when empty","hidden"]],t.label?.visibility??"visible"),g=v([["Top left","topLeft"],["Top center","topCenter"],["Top right","topRight"],["Bottom left","bottomLeft"],["Bottom center","bottomCenter"],["Bottom right","bottomRight"],["Left center","leftCenter"],["Right center","rightCenter"]],t.label?.alignment??"topLeft"),h=D(t.label?.color??"#808080"),b=y(t.label?.size??9,4,72),f=y(t.label?.margin??2,0,100);x(e,"Cell Padding and Label",i("div",{class:"dlg-form"},i("div",{class:"dlg-label",textContent:m("Padding, in points")}),i("div",{class:"dlg-row wrap"},a("Top",o),a("Right",l),a("Bottom",n),a("Left",r)),i("div",{class:"dlg-label",textContent:m("Watermark or label")}),c,R(u,"Keep it visible as a label"),a("Show:",d),a("Position:",g),a("Color:",h),a("Size:",b),a("Margin:",f)),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{const w=[o,l,n,r].map(C=>Math.max(0,Number(C.value)||0));T(e.book,S(e),{pad:w.some(C=>C>0)?w:null,watermark:c.value===""?null:c.value,label:u.checked&&c.value!==""?{visibility:d.value,alignment:g.value,color:h.value.toUpperCase(),size:Number(b.value)||9,margin:Number(f.value)||0}:null}),k(e)}}],{width:420})}function we(e){const t=P(e).fold,s=z(t!==void 0),o=v([["Top right","topRight"],["Top left","topLeft"],["Bottom right","bottomRight"],["Bottom left","bottomLeft"]],t?.pos??"topRight"),l=y(t?.size??8,2,100),n=D(t?.color??"#3A7BD5"),r=i("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml"}),c=v([["Left","left"],["Right","right"]],"left"),u=z(!1);x(e,"Cell Decoration",i("div",{class:"dlg-form"},R(s,"Corner fold"),a("Corner:",o),a("Size:",l),a("Color:",n),i("div",{class:"dlg-label",textContent:m("Icon")}),a("Add icon:",r),a("Side:",c),R(u,"Remove icons")),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{const d={fold:s.checked?{pos:o.value,size:Number(l.value)||8,color:n.value.toUpperCase()}:null},g=r.files[0],h=b=>{b!==void 0&&(d.icons=b),T(e.book,S(e),d),k(e)};g?$(g).then(({mime:b,data:f})=>{const w=B(e.book,b,f),C=u.checked?[]:P(e).icons??[];h([...C,{id:w,pos:c.value}])}):h(u.checked?null:void 0)}}],{width:380})}function $(e){return new Promise((t,s)=>{const o=new FileReader;o.onload=()=>{const[l,n]=String(o.result).split(",");t({mime:/^data:([^;]+)/.exec(l)?.[1]??e.type,data:n})},o.onerror=s,o.readAsDataURL(e)})}function Ce(e){const t=P(e).bg,s=i("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/svg+xml"}),o=v([["Stretch","stretch"],["layout|Center","center"],["layout|Zoom","zoom"],["None","none"]],t?.layout??"stretch"),l=z(!1);x(e,"Cell Background Image",i("div",{class:"dlg-form"},a("Picture:",s),a("Layout:",o),R(l,"Remove the picture")),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{const n=s.files[0];l.checked?(T(e.book,S(e),{bg:null}),k(e)):n?$(n).then(({mime:r,data:c})=>{T(e.book,S(e),{bg:{id:B(e.book,r,c),layout:o.value}}),k(e)}):t&&(T(e.book,S(e),{bg:{id:t.id,layout:o.value}}),k(e))}}],{width:380})}function xe(e){const{grid:t,book:s}=e,o=s.sheet,{row:l,col:n}=t.selection,r=()=>{switch(u.value){case"row":return o.rowTags?.get(l)??null;case"col":return o.colTags?.get(n)??null;case"sheet":return o.tag??null;default:return q(o,l,n)}},c=g=>g===null?"":typeof g=="string"?g:JSON.stringify(g),u=v([["Selected cells","cell"],["This row","row"],["This column","col"],["This sheet","sheet"]],"cell"),d=i("textarea",{class:"dlg-input",rows:3,value:c(r()),spellcheck:!1,"aria-label":m("Tag")});u.addEventListener("change",()=>{d.value=c(r())}),x(e,"Cell Tag",i("div",{class:"dlg-form"},i("p",{class:"dlg-note",textContent:m("A note for formulas and scripts. It is not shown in the cell.")}),a("Apply to:",u),d),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{const g=d.value;let h=g===""?null:g;if(g!=="")try{h=JSON.parse(g)}catch{h=g}u.value==="row"?H(o,"row",l,h):u.value==="col"?H(o,"col",n,h):u.value==="sheet"?o.tag=h??void 0:J(s,S(e),h),s.dirty=!0}}],{width:360})}function ye(e){const t=P(e).mask,s=A(t?.pattern??"","(000) 000-0000"),o=A(t?.placeholder??"_");o.maxLength=1;const l=z(t?.excludeLiteral===!0),n=z(t?.excludePlaceholder===!0),r=A("",m("Try typing here")),c=i("output",{class:"dlg-note"}),u=()=>({pattern:s.value,placeholder:o.value||"_",...l.checked?{excludeLiteral:!0}:{},...n.checked?{excludePlaceholder:!0}:{}});r.addEventListener("input",()=>{if(s.value[0]==="="||!K(s.value))return;const d=re(u(),r.value,r.selectionStart);r.value=d.text,r.setSelectionRange(d.caret,d.caret),c.textContent=m("Stores: {value}",{value:se(u(),d.text)})}),x(e,"Input Mask",i("div",{class:"dlg-form"},a("Pattern:",s),i("p",{class:"dlg-note",textContent:m("a letter, 0 digit, # any, > upper, < lower, [a-f] set, (am|pm) choice, \\x fixed x, {n,m} length; dates: yyyy MM dd HH mm ss tt; = takes the pattern from a formula.")}),a("Placeholder:",o),R(l,"Store without fixed characters"),R(n,"Store without placeholders"),a("Sample:",r),c),[{label:"Remove",action:()=>{T(e.book,S(e),{mask:null}),k(e)}},{label:"Cancel"},{label:"OK",primary:!0,action:()=>s.value[0]!=="="&&!K(s.value)?(e.shell.setStatus("That pattern has no place to type."),!1):(T(e.book,S(e),{mask:u()}),k(e),!0)}],{width:440})}function ke(e){const{book:t,grid:s}=e,o=t.sheet,{row:l,col:n}=s.selection,r=t.richImages?.get(o.valueMeta?.get(l*16384+n));if(!r){e.shell.setStatus("Select a cell with a picture in it first. Use Insert > Pictures > Place in Cell.");return}const c=o.cellPicOpts?.get(l*16384+n)??{},u=A(r.alt??"",m("Describes the picture; sort and filter use it")),d=y(c.w??0,0,2e4),g=y(c.h??0,0,2e4),h=y(c.clipX??0,0,2e4),b=y(c.clipY??0,0,2e4),f=y(c.clipW??0,0,2e4),w=y(c.clipH??0,0,2e4),C=v([["Center","center"],["Left","left"],["Right","right"]],c.hAlign??"center"),F=v([["Center","center"],["Top","top"],["Bottom","bottom"]],c.vAlign??"center");x(e,"Picture in Cell",i("div",{class:"dlg-form"},a("Alt text:",u),i("div",{class:"dlg-label",textContent:m("Size, in points; 0 fits the cell")}),i("div",{class:"dlg-row wrap"},a("Width",d),a("Height",g)),i("div",{class:"dlg-label",textContent:m("Crop, in the picture's pixels; 0 keeps all of it")}),i("div",{class:"dlg-row wrap"},a("Left",h),a("Top",b),a("Width",f),a("Height",w)),a("Horizontal:",C),a("Vertical:",F),i("p",{class:"dlg-note",textContent:m("Excel has no size or crop for a picture in a cell, and fits it there.")})),[{label:"Place over Cells",action:()=>{ge(e,l,n)}},{label:"Cancel"},{label:"OK",primary:!0,action:()=>{me(e,l,n,u.value);const L=_=>Math.max(0,Number(_.value)||0),M={w:L(d),h:L(g),clipX:L(h),clipY:L(b),clipW:L(f),clipH:L(w),hAlign:C.value,vAlign:F.value},X=!M.w&&!M.h&&!M.clipX&&!M.clipY&&!M.clipW&&!M.clipH&&M.hAlign==="center"&&M.vAlign==="center";he(t,[{r0:l,c0:n,r1:l,c1:n}],X?null:M),k(e)}}],{width:440})}function Se(e){const{book:t,grid:s}=e,o=s.selection.ranges[s.selection.ranges.length-1],l=t.sheet,n={r0:o.r0,c0:o.c0,r1:Math.min(o.r1,Math.max(l.maxRow,o.r0)),c1:Math.min(o.c1,Math.max(l.maxCol,o.c0))},r=v([["Down columns","col"],["Across rows","row"],["Both","both"]],"col"),c=v([["Free: equal neighbors merge","free"],["Restricted: only where the columns to the left also merge","restricted"]],"free"),u=v([["Selecting a cell selects that cell","source"],["Selecting a cell selects the merged area","merged"]],"source");x(e,"Auto Merge",i("div",{class:"dlg-form"},i("p",{class:"dlg-note",textContent:m("Equal neighbors show as one cell. The data stays as it is.")}),a("Direction:",r),a("Mode:",c),a("Selection:",u)),[{label:"Remove",action:()=>{t.transact("merge",d=>N(d.sheet,n,null)),k(e)}},{label:"Cancel"},{label:"OK",primary:!0,action:()=>{t.transact("merge",d=>N(d.sheet,n,{dir:r.value,mode:c.value,sel:u.value})),k(e)}}],{width:460})}function V(e,t){const{book:s,grid:o}=e,l=s.sheet,n=o.selection.ranges[o.selection.ranges.length-1],r=t==="col"?n.c0:n.r0,u=(l.axisSizing&&(t==="col"?l.axisSizing.cols:l.axisSizing.rows))?.get(r),d=t==="col"?l.cols:l.rows,g=A(u==="auto"?"auto":u?`${u}*`:String(t==="col"?Y(d.sizeOf(r)):d.sizeOf(r)));x(e,t==="col"?"Column Width":"Row Height",i("div",{class:"dlg-form"},a(t==="col"?"Column width:":"Row height:",g),i("p",{class:"dlg-note",textContent:m("Also * or 2* for a share of the free space, or auto to follow the content.")})),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{const h=ie(g.value),b=t==="col"?Math.min(n.c1,n.c0+le):Math.min(n.r1,n.r0+4096);if(h===null){const f=Number(g.value),w=t==="col"?255:409;if(g.value.trim()===""||!(f>=0&&f<=w))return e.shell?.setStatus(m("The value must be between 0 and {max}.",{max:w})),g.focus(),g.select(),!1;for(let C=r;C<=b;C++)U(l,t,C,null);e.commands.setAxisSize(t,t==="col"?j(f):f)}else{for(let f=r;f<=b;f++)U(l,t,f,h);s.dirty=!0}return o.invalidate(),!0}}],{width:360})}function Me(e){const t=e.book.sheet,s=y(t.frozenTrailingRows,0,999),o=y(t.frozenTrailingCols,0,999),l=z(t.trailingStick!==!1);x(e,"Freeze Last Rows and Columns",i("div",{class:"dlg-form"},a("Last rows of the data:",s),a("Last columns of the data:",o),R(l,"Keep them at the edge of the window"),i("p",{class:"dlg-note",textContent:m("Excel has no such panes: in Excel these rows and columns scroll with the sheet.")})),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{ce(e,Number(s.value)||0,Number(o.value)||0,l.checked)}}],{width:360})}function Te(e){const{book:t,grid:s}=e,o=t.sheet,l=i("div",{class:"dlg-list",style:"max-height:260px;overflow:auto;white-space:pre"}),n=u=>u===null?m("(empty)"):String(u),r=()=>{const u=Q(t,o);l.replaceChildren(...u.length===0?[i("div",{textContent:o.changes?m("No changes."):m("Tracking is off.")})]:u.slice(0,2e3).map(d=>i("button",{type:"button",class:"dlg-btn",style:"display:block;width:100%;text-align:left",textContent:`${oe(d.row,d.col)}: ${n(d.oldValue)} → ${n(d.newValue)}`,on:{click:()=>e.controller.moveTo(d.row,d.col)}})))},c=z(o.changes!==null);c.addEventListener("change",()=>{c.checked?ee(o):te(o),r(),s.invalidate()}),r(),x(e,"Changed Cells",i("div",{class:"dlg-form"},R(c,"Keep track of changed cells on this sheet"),l),[{label:"Clear",action:()=>(Z(o),r(),s.invalidate(),!1)},{label:"Close",primary:!0}],{width:460})}const p=(e,t)=>`${e?"✓ ":""}${m(t)}`;function We(e){const t=P(e),s=e.commands.activeStyle(),o=n=>{T(e.book,S(e),{[n]:t[n]?null:!0}),k(e)},l=n=>{T(e.book,S(e),{ime:n==="auto"?null:n}),k(e)};return{items:[["Padding and Label…",()=>ve(e)],["Corner Fold and Icons…",()=>we(e)],["Background Image…",()=>Ce(e)],["Input Mask…",()=>ye(e)],["Cell Tag…",()=>xe(e)],["Picture in Cell…",()=>ke(e)],null,[p(t.ellipsis===!0,"Ellipsis for Long Text"),()=>o("ellipsis")],[p(t.tip===!0,"Tip for Cut Text"),()=>o("tip")],[p(t.overline===!0,"Overline"),()=>o("overline")],[p(s.underline===3,"Single Accounting Underline"),()=>{e.commands.apply({underline:s.underline===3?0:3}),e.afterCommand()}],[p(s.underline===4,"Double Accounting Underline"),()=>{e.commands.apply({underline:s.underline===4?0:4}),e.afterCommand()}],null,[p((t.ime??"auto")==="auto","IME: Automatic"),()=>l("auto")],[p(t.ime==="active","IME: On"),()=>l("active")],[p(t.ime==="inactive","IME: Off"),()=>l("inactive")],[p(t.ime==="disabled","IME: Disabled"),()=>l("disabled")],null,["Auto Merge…",()=>Se(e)],[p(E().dragMerge===!0,"Drag the Selection to Merge"),()=>{I("dragMerge",!E().dragMerge),e.grid.dragMergeGrip=E().dragMerge,e.grid.invalidateTop()}],["Changed Cells…",()=>Te(e)]]}}function $e(e){const t=e.book.sheet,s=E().dragHeaders??"none",o=t.columnResizeMode==="split";return{items:[[p(t.split!==null,"Split"),()=>ae(e)],["Freeze Last Rows and Columns…",()=>Me(e)],null,["Column Size…",()=>V(e,"col")],["Row Size…",()=>V(e,"row")],[p(o,"Split Resize"),()=>{const l=o?null:"split";t.columnResizeMode=l,t.rowResizeMode=l}],null,[p(s==="both","Drag Column and Row Headers to Move"),()=>I("dragHeaders",s==="both"?"none":"both")],[p(s==="col","Drag Column Headers to Move"),()=>I("dragHeaders",s==="col"?"none":"col")],[p(s==="row","Drag Row Headers to Move"),()=>I("dragHeaders",s==="row"?"none":"row")]]}}function Ve(e,t){const s=l=>{const n=document.createElement("input");n.type="file",n.accept="image/png,image/jpeg,image/gif,image/bmp,image/webp,image/svg+xml",n.addEventListener("change",async()=>{n.files[0]&&await l(n.files[0]),e.afterCommand()}),n.click()},o=l=>{const n=i("input",{class:"dlg-input",type:"url",value:"https://","aria-label":m("Address"),spellcheck:!1}),r=i("p",{class:"dlg-message",role:"status"});let c=!1;const u=x(e,"Picture from URL",i("div",{class:"dlg-col"},i("label",{class:"dlg-row"},`${m("Address")} `,n),r),[{label:"Cancel"},{label:"Insert",primary:!0,action:()=>{if(c)return!1;const d=be(n.value);return d?(r.textContent=d,!1):(c=!0,r.textContent=m("Downloading the picture…"),fe(n.value).then(async g=>{u.close("Insert"),await l(g),e.afterCommand()},g=>{c=!1,r.textContent=g.message}),!1)}}],{width:460});n.focus()};return{items:[["Place over Cells…",()=>s(t)],["Place over Cells from URL…",()=>o(t)],["Place in Cell…",()=>s(l=>W(e,l))],["Place in Cell from URL…",()=>o(l=>W(e,l))]]}}function Xe(e){return e.book.sheet.background===null?null:()=>de(e)}export{ne as MAX_ROWS,Xe as backgroundMenu,We as cellOptionsMenu,ue as chooseBackground,Se as openAutoMerge,Ce as openCellPicture,Te as openChanges,we as openCornerFold,Ue as openFillEffects,ye as openMaskDialog,ve as openPaddingLabel,ke as openPictureOptions,xe as openTagDialog,V as openTrackSize,Me as openTrailingFreeze,$e as panesMenu,Ve as picturesMenu};
@@ -0,0 +1 @@
1
+ import{child as m,children as y,parseTree as X,unescapeOoxml as b,unescapeXstring as g}from"../io/xml-scan.js";import{xmlAttr as h}from"../io/xml-escape.js";function $(l){const t=new Map;for(const e of y(m(l,"cellStyles"),"cellStyle")){const n=Number(e.a.xfId??0);t.has(n)||t.set(n,{name:b(e.a.name),builtinId:e.a.builtinId===void 0?void 0:Number(e.a.builtinId)})}return t}function C(l,t){const e=$(t);return e.size<=1||y(m(t,"cellXfs"),"xf").forEach((n,c)=>{const s=e.get(Number(n.a.xfId??0));s&&s.name!=="Normal"&&l[c]&&(l[c].namedStyle=s.name)}),l}function P(l,t,e){const n=X(new TextEncoder().encode(l)),c=l.replace(/<cellXfs\b[\s\S]*?<\/cellXfs>/,"").replace(/<cellXfs\b[^>]*\/>/,"").replace(/cellStyleXfs/g,"cellXfs"),s=e(new TextEncoder().encode(c),t),o=y(m(n,"cellStyleXfs"),"xf"),u=new Map;for(const r of y(m(n,"cellStyles"),"cellStyle")){const i=Number(r.a.xfId??0),a=s[i];if(!a||!r.a.name)continue;const f=o[i]?.a??{},d=x=>x!=="0"&&x!=="false",p={number:d(f.applyNumberFormat),alignment:d(f.applyAlignment),font:d(f.applyFont),border:d(f.applyBorder),fill:d(f.applyFill),protection:d(f.applyProtection)},S=b(r.a.name);u.set(S,{name:S,style:a,builtinId:r.a.builtinId===void 0?void 0:Number(r.a.builtinId),xfId:i,includes:p,inFile:!0})}return u}function B(l){const t=l.namedStyles;if(!t||t.size===0)return null;const e=[];let n=Math.max(1,l.styleXfCount??1);for(const c of t.values()){if(c.deleted&&!c.inFile)continue;if(l.source!==null&&c.inFile&&!c.changed&&!c.deleted){e.push({name:c.name,xfId:c.xfId,keep:!0});continue}const s=!c.inFile&&c.name!=="Normal";s&&(c.pendingXf=n++),e.push({name:c.name,builtinId:c.builtinId,style:c.style,includes:c.includes,xfId:s?c.pendingXf:c.xfId??0,isNew:s,deleted:c.deleted===!0})}return l.styleXfNext=n,e}function M(l,t,e=!0){if(l.namedStyles){for(const n of t??[]){const c=n.name,s=l.namedStyles.get(c);if(s){if(n.deleted&&!s.deleted){s.inFile=!1;continue}if(n.deleted){l.namedStyles.delete(c);continue}!s.inFile&&s.name!=="Normal"&&(s.xfId=n.xfId),s.inFile=!0,e&&(s.changed=!1)}}l.styleXfNext&&(l.styleXfCount=l.styleXfNext)}}const N=l=>l.number?' applyNumberFormat="1"':' applyNumberFormat="0"';function F(l,t){let e=l.replace(/\s+xfId="\d+"/,"").replace(/\s+apply(?:NumberFormat|Font|Fill|Border|Alignment|Protection)="\d"/g,"");const n=t??{number:!0,font:!0,fill:!0,border:!0,alignment:!0,protection:!0},c=`${N(n)}${n.font?' applyFont="1"':' applyFont="0"'}${n.fill?' applyFill="1"':' applyFill="0"'}${n.border?' applyBorder="1"':' applyBorder="0"'}${n.alignment?' applyAlignment="1"':' applyAlignment="0"'}${n.protection?' applyProtection="1"':' applyProtection="0"'}`;return e=e.replace(/^<xf\b/,"<xf").replace(/(<xf\b[^>]*?)(\/?>)/,`$1${c}$2`),e}function E(l,t){if(!t)return{styles:l,finish:()=>null};const e=new Map([["Normal",0]]);for(const o of t)o.deleted||e.set(o.name,o.xfId);const n=t.filter(o=>!o.keep&&!o.deleted),c=l.map(o=>o.namedStyle&&e.has(o.namedStyle)?{...o,_xfId:e.get(o.namedStyle)}:o),s=c.length;return{styles:[...c,...n.map(o=>o.style)],finish(o){const u=o.xfs.slice(s);o.xfs=o.xfs.slice(0,s);let r=null;const i=new Map,a=[];return n.forEach((f,d)=>{const p=F(u[d],f.includes);f.isNew?a.push(p):i.set(f.xfId,p),f.name==="Normal"&&(r=u[d])}),{replaced:i,appended:a,rows:t,ids:e,normalCell:r}}}}function I(l,t,e){const n=/^(?:Row|Col)Level_([1-7])$/.exec(l);return`<cellStyle name="${h(l)}" xfId="${t}"${e!==void 0?` builtinId="${e}"`:""}${n?` iLevel="${Number(n[1])-1}"`:""}/>`}function j(l){const t='<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>';if(!l?.rows)return`<cellStyleXfs count="1">${t}</cellStyleXfs>`;const e=[l.replaced?.get(0)??t,...l.appended??[]];return`<cellStyleXfs count="${e.length}">${e.join("")}</cellStyleXfs>`}function v(l){const t=['<cellStyle name="Normal" xfId="0" builtinId="0"/>'];if(l?.rows)for(const e of l.rows)!e.deleted&&e.name!=="Normal"&&t.push(I(e.name,l.ids.get(e.name),e.builtinId));return`<cellStyles count="${t.length}">${t.join("")}</cellStyles>`}function L(l){const t=/<cellStyleXfs\b[^>]*>([\s\S]*?)<\/cellStyleXfs>/.exec(l);return t?(t[1].match(/<xf\b/g)??[]).length:0}function T(l,t){if(!t?.rows)return l;let e=l;/<cellStyleXfs\b/.test(e)||(e=e.replace(/<cellXfs\b/,'<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs')),e=e.replace(/<cellStyleXfs\b[^>]*>([\s\S]*?)<\/cellStyleXfs>/,(r,i)=>{const a=[...i.matchAll(/<xf\b[^>]*?(?:\/>|>[\s\S]*?<\/xf>)/g)].map(f=>f[0]);for(const[f,d]of t.replaced)f<a.length&&(a[f]=d);return a.push(...t.appended),`<cellStyleXfs count="${a.length}">${a.join("")}</cellStyleXfs>`}),t.normalCell&&(e=e.replace(/(<cellXfs\b[^>]*>)\s*<xf\b[^>]*?(?:\/>|>[\s\S]*?<\/xf>)/,(r,i)=>`${i}${t.normalCell.replace(/\s+xfId="\d+"/,' xfId="0"')}`));const n=/<cellStyles\b[^>]*>([\s\S]*?)<\/cellStyles>/.exec(e),c=n?[...n[1].matchAll(/<cellStyle\b[^>]*?(?:\/>|>[\s\S]*?<\/cellStyle>)/g)].map(r=>r[0]):['<cellStyle name="Normal" xfId="0" builtinId="0"/>'],s=r=>{const i=/\bname="([^"]*)"/.exec(r)?.[1];return i===void 0?void 0:g(i)},o=c.filter(r=>!t.rows.some(i=>i.deleted&&i.name===s(r)));for(const r of t.rows)r.deleted||r.keep||o.some(i=>s(i)===r.name)||o.push(I(r.name,t.ids.get(r.name),r.builtinId));const u=`<cellStyles count="${o.length}">${o.join("")}</cellStyles>`;return n?e.replace(/<cellStyles\b[^>]*>[\s\S]*?<\/cellStyles>/,u):e.replace("</cellXfs>",`</cellXfs>${u}`)}export{L as countStyleXfs,M as namedStylesCommitted,B as namedStylesPlan,v as newCellStyles,j as newStyleSections,T as patchStyleSections,P as readNamedStyles,C as tagNamedStyles,E as withNamedStyles};
@@ -0,0 +1 @@
1
+ import{parseRangeRef as D}from"../core/address.js";import{CHUNK_BITS as C,CHUNK_MASK as q,DIRTY as P,KIND_MASK as B,NUM as E}from"../core/sheet.js";import{partsToSerial as R,serialToParts as F}from"../core/numfmt.js";import{compareValues as v,XlError as g}from"../calc/values.js";import{resolveColor as V}from"../io/xlsx-styles.js";const W=c=>c.split(/\s+/).map(D).filter(Boolean),K=1<<19,L=Object.freeze({}),O=new Set(["colorScale","dataBar","iconSet"]),$=c=>[parseInt(c.slice(1,3),16),parseInt(c.slice(3,5),16),parseInt(c.slice(5,7),16)],I=c=>(c<16?"0":"")+c.toString(16),k=c=>c<0?0:c>1?1:c;function U(c,s){const o={...s,...c};return(c.fill!==void 0||c.pattern!==void 0||c.gradient!==void 0||c.noFill)&&(c.pattern===void 0&&delete o.pattern,c.gradient===void 0&&delete o.gradient,c.fill===void 0&&delete o.fill,c.noFill||delete o.noFill),c.borders&&s.borders&&(o.borders={l:c.borders.l??s.borders.l,r:c.borders.r??s.borders.r,t:c.borders.t??s.borders.t,b:c.borders.b??s.borders.b}),o}const N=c=>c instanceof g?String(c.code??c.message??c).toLowerCase():typeof c=="boolean"?c?"true":"false":String(c).toLowerCase();class H{constructor(s,o,n){this.book=s,this.sheet=o,this.colorOf=n??(e=>V(e,s.theme??[])),this.cache=new Map,this.stats=new Map,this.data=new Map,this.flat=null,this.flatOf=null,this.today=0}invalidate(){this.cache.clear(),this.stats.clear(),this.data.clear(),this.flat=null,this.today=0}_rules(){const{cf:s}=this.sheet;if(this.flat!==null&&this.flatOf===s)return this.flat;const o=[];for(const n of s??[]){n._ranges===void 0&&(n._ranges=W(n.sqref));const e=n._ranges;if(e.length===0)continue;let t=1/0,r=1/0,i=-1,l=-1;for(const a of e)a.r0<t&&(t=a.r0),a.c0<r&&(r=a.c0),a.r1>i&&(i=a.r1),a.c1>l&&(l=a.c1);n._base={r0:t,c0:r};for(const a of n.rules)o.push({rule:a,block:n,r0:t,c0:r,r1:i,c1:l,single:e.length===1})}return o.sort((n,e)=>n.rule.priority-e.rule.priority),this.flat=o,this.flatOf=s,this.stoppers=o.filter(n=>n.rule.stopIfTrue&&!O.has(n.rule.type)),o}stoppedBefore(s,o,n){this._rules();for(const e of this.stoppers){if(e.rule.priority>=s)break;if(!(o<e.r0||o>e.r1||n<e.c0||n>e.c1)&&!(!e.single&&!e.block._ranges.some(t=>o>=t.r0&&o<=t.r1&&n>=t.c0&&n<=t.c1))&&this._evaluate(e.rule,e.block,o,n)!==null)return!0}return!1}at(s,o){const n=s*16384+o,e=this.cache.get(n);if(e!==void 0)return e;const t=this._rules();let r=null;for(let i=0;i<t.length;i++){const l=t[i];if(s<l.r0||s>l.r1||o<l.c0||o>l.c1)continue;if(!l.single){const u=l.block._ranges;let h=!1;for(let d=0;d<u.length&&!h;d++){const f=u[d];h=s>=f.r0&&s<=f.r1&&o>=f.c0&&o<=f.c1}if(!h)continue}const a=this._evaluate(l.rule,l.block,s,o);if(a!==null&&(r=r===null?a:U(r,a),l.rule.stopIfTrue&&!O.has(l.rule.type)))break}return this.cache.size>=K&&this.cache.clear(),this.cache.set(n,r),r}_value(s,o){return this.book.engine?this.book.engine.read(this.sheet,s,o):null}_stat(s){let o=this.stats.get(s);if(o!==void 0)return o;const{sheet:n}=this,{engine:e}=this.book;let t=new Float64Array(1024),r=0;for(const u of s._ranges){const h=Math.min(u.c1,n.maxCol),d=Math.min(u.r1,n.maxRow);for(let f=u.c0;f<=h;f++){const m=n.columns[f];if(m!==void 0)for(let p=u.r0>>>C;p<=d>>>C;p++){const _=m[p];if(_===void 0)continue;const x=p<<C,y=Math.max(u.r0-x,0),M=Math.min(d-x,q),{kinds:A,values:T}=_;if(r+(M-y+1)>t.length){const b=new Float64Array(Math.max(t.length*2,r+M-y+1));b.set(t),t=b}for(let b=y;b<=M;b++){const S=A[b];S!==0&&(S&P?(e&&e.read(n,x+b,f),(A[b]&B)===E&&(t[r++]=T[b])):(S&B)===E&&(t[r++]=T[b]))}}}}t=t.subarray(0,r).sort();let i=0;for(let u=0;u<r;u++)i+=t[u];const l=r?i/r:0;let a=0;for(let u=0;u<r;u++)a+=(t[u]-l)**2;return o={nums:t,n:r,mean:l,stdP:r>0?Math.sqrt(a/r):0,min:r?t[0]:0,max:r?t[r-1]:0,others:null},this.stats.set(s,o),o}_others(s){const o=this._stat(s);if(o.others!==null)return o.others;const n=new Map;for(const e of s._ranges)this.book.engine?.scan({sheet:this.sheet,r0:e.r0,c0:e.c0,r1:e.r1,c1:e.c1},t=>{if(typeof t=="number")return;const r=N(t);n.set(r,(n.get(r)??0)+1)});return o.others=n,n}_numberCount(s,o){const{nums:n,n:e}=this._stat(s);let t=0,r=e;for(;t<r;){const i=t+r>>>1;n[i]<o?t=i+1:r=i}return t>=e||n[t]!==o?0:t+1<e&&n[t+1]===o?2:1}_occurrences(s,o){const n=this._others(s);if(typeof o=="number")return this._numberCount(s,o)+(n.get(String(o))??0);const e=N(o),t=n.get(e)??0;return typeof o=="string"&&e!==""&&!Number.isNaN(Number(e))?t+this._numberCount(s,Number(e)):t}_template(s,o,n,e){const t=this._ruleData(s),r=`t${o}`;if(t[r]===void 0){const i=e._base;t[r]=this.book.engine.template(n,i.r0,i.c0)}return t[r]}_formula(s,o,n,e,t){const{engine:r}=this.book,i=s.formulas?.[o];return i===void 0||!r?null:this._run(this._template(s,o,i,n),e,t)}_run(s,o,n){const{engine:e}=this.book,t=e.legacy;e.legacy=!0;try{let r=s.fn(o,n,this.sheet);return(r&&r.sheet||r&&r.refs)&&(r=e.refAuto(r,o,n)),r&&r.data&&([r]=r.data),r===void 0?null:r}catch(r){return r instanceof g?r:null}finally{e.legacy=t}}_dxf(s){return s.dxf?s.dxf:s.dxfId!==null&&s.dxfId!==void 0?this.book.dxfs?.[s.dxfId]??L:L}_threshold(s,o){const n=this._stat(o);switch(s.type){case"min":return n.min;case"max":return n.max;case"autoMin":return Math.min(n.min,0);case"autoMax":return Math.max(n.max,0);default:break}const e=s.val;let t;if(typeof e=="string"&&!/^\s*[-+]?[\d.]+(?:[eE][-+]?\d+)?\s*$/.test(e)){const{engine:r}=this.book;if(!r)return 0;const i=o._base,l=this._run(r.template(e,i.r0,i.c0),i.r0,i.c0);t=typeof l=="number"?l:0}else t=e==null?0:Number(e);switch(s.type){case"percent":return n.min+(n.max-n.min)*t/100;case"percentile":{if(n.n===0)return 0;const r=k(t/100)*(n.n-1),i=Math.floor(r);return i+1<n.n?n.nums[i]+(r-i)*(n.nums[i+1]-n.nums[i]):n.nums[i]}default:return t}}_ruleData(s){let o=this.data.get(s);return o===void 0&&(o={},this.data.set(s,o)),o}_evaluate(s,o,n,e){switch(s.type){case"cellIs":{const t=this._value(n,e);if(t instanceof g)return null;const r=this._formula(s,0,o,n,e);if(r instanceof g)return null;const i=s.operator;let l=!1;if(i==="between"||i==="notBetween"){const a=this._formula(s,1,o,n,e);if(a instanceof g)return null;const u=v(r,a)<=0,h=u?r:a,d=u?a:r,f=v(t,h)>=0&&v(t,d)<=0;l=i==="between"?f:!f}else{const a=v(t,r);l=i==="greaterThan"?a>0:i==="lessThan"?a<0:i==="greaterThanOrEqual"?a>=0:i==="lessThanOrEqual"?a<=0:i==="equal"?a===0:i==="notEqual"?a!==0:!1}return l?this._dxf(s):null}case"expression":{const t=this._formula(s,0,o,n,e);return typeof t=="boolean"?t?this._dxf(s):null:typeof t=="number"&&t!==0?this._dxf(s):null}case"containsText":case"notContainsText":case"beginsWith":case"endsWith":return this._textRule(s,o,n,e)?this._dxf(s):null;case"containsBlanks":{const t=this._value(n,e);return t===null||typeof t=="string"&&t.trim()===""?this._dxf(s):null}case"notContainsBlanks":{const t=this._value(n,e);return t!==null&&!(t instanceof g)&&!(typeof t=="string"&&t.trim()==="")?this._dxf(s):null}case"containsErrors":return this._value(n,e)instanceof g?this._dxf(s):null;case"notContainsErrors":return this._value(n,e)instanceof g?null:this._dxf(s);case"duplicateValues":case"uniqueValues":{const t=this._value(n,e);if(t===null)return null;const r=this._occurrences(o,t);return(s.type==="duplicateValues"?r>1:r===1)?this._dxf(s):null}case"top10":{const t=this._value(n,e);if(typeof t!="number")return null;const r=this._stat(o);let i=s.rank??10;return s.percent&&(i=Math.max(1,Math.floor(r.n*i/100))),i=Math.min(i,r.n),i<=0?null:(s.bottom?t<=r.nums[i-1]:t>=r.nums[r.n-i])?this._dxf(s):null}case"aboveAverage":{const t=this._value(n,e);if(typeof t!="number")return null;const r=this._stat(o),i=s.aboveAverage!==!1,l=r.mean+(i?1:-1)*(s.stdDev||0)*r.stdP;return(i?s.equalAverage?t>=l:t>l:s.equalAverage?t<=l:t<l)?this._dxf(s):null}case"timePeriod":{const t=this._value(n,e);return typeof t=="number"&&this._inPeriod(t,s.timePeriod)?this._dxf(s):null}case"colorScale":{const t=this._value(n,e);return typeof t=="number"?this._colorScale(s,o,t):null}case"dataBar":{const t=this._value(n,e);return typeof t=="number"?this._dataBar(s,o,t):null}case"iconSet":{const t=this._value(n,e);return typeof t=="number"?this._iconSet(s,o,t):null}default:return null}}_textRule(s,o,n,e){if(s.formulas&&s.formulas.length>0&&this.book.engine){const l=this._formula(s,0,o,n,e);return l===!0||typeof l=="number"&&l!==0}const t=this._value(n,e),r=String(s.text??"").toLowerCase();if(t instanceof g)return s.type==="notContainsText";const i=t===null?"":typeof t=="boolean"?t?"true":"false":String(t).toLowerCase();switch(s.type){case"containsText":return i.includes(r);case"notContainsText":return!i.includes(r);case"beginsWith":return i.startsWith(r);default:return i.endsWith(r)}}_colorScale(s,o,n){const e=this._ruleData(s);if(e.stops===void 0){const{cfvo:i,colors:l}=s.colorScale;e.stops=i.map(a=>this._threshold(a,o)),e.css=l.map(a=>this.colorOf({a})??"#FFFFFF"),e.rgb=e.css.map($),e.ends=e.css.map(a=>({fill:a}))}const{stops:t}=e,r=t.length-1;if(n>=t[r])return e.ends[r];if(n<=t[0])return e.ends[0];for(let i=1;i<=r;i++)if(n<t[i]){const l=t[i]-t[i-1],a=l===0?1:(n-t[i-1])/l,u=e.rgb[i-1],h=e.rgb[i];return{fill:`#${I(Math.round(u[0]+(h[0]-u[0])*a))}${I(Math.round(u[1]+(h[1]-u[1])*a))}${I(Math.round(u[2]+(h[2]-u[2])*a))}`}}return e.ends[r]}_barStyle(s,o){const n=this._ruleData(s);if(n.bar!==void 0)return n.bar;const e=s.dataBar,t=e.ext,r=t?.cfvo??e.cfvo;let i=this._threshold(r[0],o),l=this._threshold(r[1],o);l<i&&([i,l]=[l,i]);const a=this.colorOf({a:e.color})??"#638EC6",u=(_,x)=>_?this.colorOf({a:_})??x:x,h=(t?t.minLength:e.minLength??10)/100,d=(t?t.maxLength:e.maxLength??90)/100,f=t?t.axisPosition??"automatic":"none";let m=-1;f==="middle"?m=.5:f==="automatic"&&(i<0&&l>0?m=-i/(l-i):l<=0&&i<0&&(m=1));const p=t?.border?u(t.borderColor,a):null;return n.bar={lo:i,hi:l,minL:h,maxL:d,start:t?h/2:h,axisAt:m,color:a,gradient:t?t.gradient!==!1:!0,border:p,negColor:t&&!t.negFillSame?u(t.negFill,"#FF0000"):a,negBorder:t?.border&&t.negBorderSame===!1?u(t.negBorder,"#FF0000"):p,axisColor:t?u(t.axisColor,"#000000"):"#000000",direction:t?.direction??"context",hide:e.showValue===!1},n.bar}_dataBar(s,o,n){const e=this._barStyle(s,o),{lo:t,hi:r,minL:i,maxL:l,axisAt:a,start:u}=e,h=l-i;let d,f;if(a<0)d=0,f=u+h*(r===t?1:k((n-t)/(r-t)));else{const _=s.dataBar.ext?.axisPosition==="middle"?Math.max(Math.abs(t),Math.abs(r)):n>=0?r:-t,y=(n>=0?1-a:a)*(u+h*(_>0?k(Math.abs(n)/_):0));n>=0?(d=a,f=a+y):(f=a,d=a-y)}return{bar:{style:e,x0:d,x1:f,negative:n<0,pct:f-d,color:n<0?e.negColor:e.color},hideValue:e.hide}}_iconSet(s,o,n){const e=this._ruleData(s),t=s.iconSet;if(e.levels===void 0){e.thresholds=t.cfvo.map(u=>this._threshold(u,o));const a=t.cfvo.length;e.levels=t.cfvo.map((u,h)=>{const d=t.reverse?a-1-h:h,f=t.custom?.[h],m=f?f.iconSet:t.name,p=f?f.iconId:d,_=t.showValue===!1;return m==="NoIcons"?{hideValue:_}:{icon:{name:m,level:p,count:a},hideValue:_}})}const{thresholds:r,levels:i}=e;let l=0;for(let a=r.length-1;a>=1;a--){const u=r[a];if(t.cfvo[a].gte===!1?n>u:n>=u){l=a;break}}return i[l]}_inPeriod(s,o){if(this.today===0){const a=new Date;this.today=R(a.getFullYear(),a.getMonth()+1,a.getDate())}const{today:n}=this,e=Math.floor(s);if(e<0)return!1;switch(o){case"today":return e===n;case"yesterday":return e===n-1;case"tomorrow":return e===n+1;case"last7Days":return e<=n&&e>n-7;default:break}const t=a=>a-F(a).weekday;switch(o){case"thisWeek":return t(e)===t(n);case"lastWeek":return t(e)===t(n)-7;case"nextWeek":return t(e)===t(n)+7;default:break}const r=F(e),i=F(n),l=(r.year-i.year)*12+r.month-i.month;switch(o){case"thisMonth":return l===0;case"lastMonth":return l===-1;case"nextMonth":return l===1;default:return!1}}}function j(c,s){if(!c.cfEval){if(!s)return null;c.cfEval=new H(s,c)}return c.cfEval}function w(c,s,o,n){if(!c.cf||c.cf.length===0)return null;const e=j(c,n),t=e?e.at(s,o):null;return t===null?null:{fill:t.fill??null,noFill:t.noFill===!0,color:t.color??null,iconSet:t.icon?.name??null,iconId:t.icon?.level??null}}function Q(c,s,o,n){const e=w(c,s,o,n);return e&&e.iconSet!==null?{iconSet:e.iconSet,iconId:e.iconId}:null}export{H as CondFormats,w as cfEffectAt,j as evaluatorOf,Q as iconAt};
@@ -0,0 +1 @@
1
+ import{child as a,children as p,parseTree as N,unescapeOoxml as P}from"../io/xml-scan.js";import{escapeMarkup as $,xmlAttr as E}from"../io/xml-escape.js";const V=new TextEncoder,u=t=>t==="1"||t==="true",L="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",T="http://schemas.microsoft.com/office/excel/2006/main",R="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}",M="{78C0D931-6437-407d-A8EE-F0AAD7539E65}",D=new Set(["3Stars","3Triangles","5Boxes"]),j=()=>{const t=()=>Math.floor(Math.random()*65536).toString(16).padStart(4,"0");return`{${t()}${t()}-${t()}-4${t().slice(1)}-a${t().slice(1)}-${t()}${t()}${t()}}`.toUpperCase()};function ot(t,e){const o=a(e,"dataBar");o&&t.dataBar&&(o.a.minLength!==void 0&&(t.dataBar.minLength=Number(o.a.minLength)),o.a.maxLength!==void 0&&(t.dataBar.maxLength=Number(o.a.maxLength)));for(const n of p(a(e,"extLst"),"ext")){const i=a(n,"id");i&&(t.id=i.t.trim())}return t}const F=t=>t.map(e=>{const o=a(e,"f"),n={type:e.a.type,val:o?o.t:e.a.val??null};return e.a.gte!==void 0&&!u(e.a.gte)&&(n.gte=!1),n}),w=t=>{const e=t.type==="autoMin"?"min":t.type==="autoMax"?"max":t.type;return e==="min"||e==="max"?{type:e}:{type:e,val:t.val}};function q(t){const e=t.a,o=n=>a(t,n)?.a??null;return{cfvo:F(p(t,"cfvo")),minLength:e.minLength!==void 0?Number(e.minLength):10,maxLength:e.maxLength!==void 0?Number(e.maxLength):90,gradient:e.gradient===void 0?!0:u(e.gradient),border:u(e.border),borderColor:o("borderColor"),negFill:o("negativeFillColor"),negBorder:o("negativeBorderColor"),negFillSame:u(e.negativeBarColorSameAsPositive),negBorderSame:e.negativeBarBorderColorSameAsPositive===void 0?!0:u(e.negativeBarBorderColorSameAsPositive),axisPosition:e.axisPosition??"automatic",axisColor:o("axisColor"),direction:e.direction??"context"}}function X(t,e){const o=t.a,n={type:o.type,priority:Number(o.priority??0),dxfId:null,operator:o.operator??null,formulas:p(t,"f").map(f=>f.t),text:P(o.text??null),rank:o.rank!==void 0?Number(o.rank):null,percent:u(o.percent),bottom:u(o.bottom),aboveAverage:o.aboveAverage===void 0?!0:u(o.aboveAverage),equalAverage:u(o.equalAverage),stdDev:o.stdDev!==void 0?Number(o.stdDev):0,stopIfTrue:u(o.stopIfTrue),timePeriod:o.timePeriod??null,x14:!0};o.id&&(n.id=o.id);const i=a(t,"dxf");i&&(n.dxf=I(i,e));const r=a(t,"colorScale");r&&(n.colorScale={cfvo:F(p(r,"cfvo")),colors:p(r,"color").map(f=>f.a)});const l=a(t,"dataBar");if(l){const f=q(l);n.dataBar={cfvo:f.cfvo.map(w),color:a(l,"fillColor")?.a??{rgb:"FF638EC6"},showValue:l.a.showValue===void 0?!0:u(l.a.showValue),ext:f}}const s=a(t,"iconSet");return s&&(n.iconSet={name:s.a.iconSet??"3TrafficLights1",cfvo:F(p(s,"cfvo")),reverse:u(s.a.reverse),showValue:s.a.showValue===void 0?!0:u(s.a.showValue),x14:!0},u(s.a.custom)&&(n.iconSet.custom=p(s,"cfIcon").map(f=>({iconSet:f.a.iconSet,iconId:Number(f.a.iconId??0)})))),n}function A(t){return/<ext\b[^>]*>\s*<(\w+:)?conditionalFormattings\b[\s\S]*?<\/(\w+:)?conditionalFormattings>\s*<\/ext>/.exec(t)}function nt(t,e,o){if(!e.includes("conditionalFormattings"))return;const n=A(e);if(n===null)return;let i;try{i=N(V.encode(`<r xmlns:x14="x" xmlns:xm="m" xmlns:xr="x">${n[0]}</r>`))}catch{return}const r=new Map;for(const s of t.cf)for(const f of s.rules)f.id&&r.set(f.id.toUpperCase(),f);const l=a(a(i,"ext"),"conditionalFormattings");for(const s of p(l,"conditionalFormatting")){const f=a(s,"sqref")?.t.trim()??"",c=[];for(const d of p(s,"cfRule")){const m=X(d,o),x=m.id?r.get(m.id.toUpperCase()):void 0;x!==void 0&&x.dataBar&&m.dataBar?(x.dataBar.ext=m.dataBar.ext,x.dataBar.showValue=x.dataBar.showValue&&m.dataBar.showValue):x===void 0&&c.push(m)}c.length>0&&f!==""&&t.cf.push({sqref:f,rules:c})}}function I(t,e){const o={},n=a(t,"font");if(n){const c=x=>{const g=a(n,x);return g!==void 0&&g.a.val!=="0"&&g.a.val!=="false"};a(n,"b")&&(o.bold=c("b")),a(n,"i")&&(o.italic=c("i")),a(n,"strike")&&(o.strike=c("strike"));const d=a(n,"u");d&&(o.underline=d.a.val==="none"?0:d.a.val==="double"||d.a.val==="doubleAccounting"?2:1);const m=e(a(n,"color"));m&&(o.color=m)}const i=a(t,"numFmt");i?.a.formatCode!==void 0&&(o.numFmt=i.a.formatCode);const r=a(t,"fill"),l=a(r,"patternFill");if(l){const c=l.a.patternType,d=a(l,"fgColor");o.pf={none:c==="none",auto:d?.a.auto==="1",fg:d&&d.a.auto!=="1"?e(d):null};const m=e(a(l,"bgColor")),x=e(a(l,"fgColor"));if(c===void 0||c==="solid"){const g=m??x;g&&(o.fill=g)}else c==="none"?o.noFill=!0:(o.pattern={type:c,fg:x??"#000000"},o.fill=m??"#FFFFFF")}const s=a(r,"gradientFill");if(s){const c=p(s,"stop").map(d=>({pos:Number(d.a.position??0),color:e(a(d,"color"))??"#FFFFFF"}));c.length>1&&(o.gradient={type:s.a.type==="path"?"path":"linear",degree:Number(s.a.degree??0),left:Number(s.a.left??0),right:Number(s.a.right??0),top:Number(s.a.top??0),bottom:Number(s.a.bottom??0),stops:c},o.fill=c[0].color)}const f=a(t,"border");if(f){const c=g=>{const b=a(f,g);return b&&b.a.style?{style:b.a.style,color:e(a(b,"color"))??"#000000"}:null},d={l:c("left"),r:c("right"),t:c("top"),b:c("bottom")},m=c("vertical"),x=c("horizontal");m&&(d.v=m),x&&(d.h=x),(d.l||d.r||d.t||d.b||m||x)&&(o.borders=d)}return o}const it=(t,e)=>p(a(t,"dxfs"),"dxf").map(o=>I(o,e)),v=t=>`FF${t.slice(1).toUpperCase()}`,U={General:0,0:1,"0.00":2,"#,##0":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mmm-yy":15,"d-mmm":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"@":49};function _(t){const e=U[t];if(e!==void 0)return e;let o=0;for(let n=0;n<t.length;n++)o=(o*31+t.charCodeAt(n))%6e4;return 1e3+o}function z(t,e="dxf"){let o="";t.bold!==void 0&&(o+=t.bold?"<b/>":'<b val="0"/>'),t.italic!==void 0&&(o+=t.italic?"<i/>":'<i val="0"/>'),t.strike!==void 0&&(o+=t.strike?"<strike/>":'<strike val="0"/>'),t.underline?o+=t.underline===2?'<u val="double"/>':"<u/>":t.underline===0&&(o+='<u val="none"/>'),t.color&&(o+=`<color rgb="${v(t.color)}"/>`);const n=t.numFmt?`<numFmt numFmtId="${_(t.numFmt)}" formatCode="${$(t.numFmt)}"/>`:"";let i="";t.noFill?i='<fill><patternFill patternType="none"/></fill>':t.pattern?i=`<fill><patternFill patternType="${t.pattern.type}"><fgColor rgb="${v(t.pattern.fg??"#000000")}"/>${t.fill?`<bgColor rgb="${v(t.fill)}"/>`:""}</patternFill></fill>`:t.fill&&(i=`<fill><patternFill><bgColor rgb="${v(t.fill)}"/></patternFill></fill>`);let r="";if(t.borders){const l=(f,c)=>c?`<${f} style="${c.style}"><color rgb="${v(c.color??"#000000")}"/></${f}>`:"",s=l("left",t.borders.l)+l("right",t.borders.r)+l("top",t.borders.t)+l("bottom",t.borders.b)+l("vertical",t.borders.v)+l("horizontal",t.borders.h);s&&(r=`<border>${s}</border>`)}return`<${e}>${o?`<font>${o}</font>`:""}${n}${i}${r}</${e}>`}const B=t=>t.map(e=>`<cfvo type="${e.type}"${e.val!==null&&e.val!==void 0?` val="${$(e.val)}"`:""}${e.gte===!1?' gte="0"':""}/>`).join(""),h=t=>Object.entries(t).map(([e,o])=>`${e}="${$(o)}"`).join(" "),S=(t,e)=>e?`<x14:${t} ${h(e)}/>`:"";function y(t){return t.map(e=>{const o=e.gte===!1?' gte="0"':"";return e.val===null||e.val===void 0?`<x14:cfvo type="${e.type}"${o}/>`:`<x14:cfvo type="${e.type}"${o}><xm:f>${$(e.val)}</xm:f></x14:cfvo>`}).join("")}function C(t){return t.x14&&!t.dataBar?!0:!!t.iconSet&&(t.iconSet.x14||t.iconSet.custom!==void 0||D.has(t.iconSet.name))}function k(t){let e=`type="${t.type}" priority="${t.priority}"`;return t.stopIfTrue&&(e+=' stopIfTrue="1"'),t.operator&&(e+=` operator="${t.operator}"`),t.text!==null&&t.text!==void 0&&(e+=` text="${E(t.text)}"`),t.rank!==null&&t.rank!==void 0&&(e+=` rank="${t.rank}"`),t.percent&&(e+=' percent="1"'),t.bottom&&(e+=' bottom="1"'),t.type==="aboveAverage"&&(t.aboveAverage===!1&&(e+=' aboveAverage="0"'),t.equalAverage&&(e+=' equalAverage="1"'),t.stdDev&&(e+=` stdDev="${t.stdDev}"`)),t.timePeriod&&(e+=` timePeriod="${t.timePeriod}"`),e}function G(t){let e=k(t);t.dxfId!==null&&t.dxfId!==void 0&&(e=e.replace(/( priority="\d+")/,` dxfId="${t.dxfId}"$1`));let o=(t.formulas??[]).map(n=>`<formula>${$(n)}</formula>`).join("");if(t.colorScale&&(o+=`<colorScale>${B(t.colorScale.cfvo)}${t.colorScale.colors.map(n=>`<color ${h(n)}/>`).join("")}</colorScale>`),t.dataBar){const n=t.dataBar,i=n.ext,r=i?i.minLength===0&&i.maxLength===100?[10,90]:[i.minLength,i.maxLength]:[n.minLength??10,n.maxLength??90],l=`${r[0]!==10?` minLength="${r[0]}"`:""}${r[1]!==90?` maxLength="${r[1]}"`:""}${n.showValue===!1?' showValue="0"':""}`;o+=`<dataBar${l}>${B(i?i.cfvo.map(w):n.cfvo)}<color ${h(n.color)}/></dataBar>`,n.ext&&(o+=`<extLst><ext xmlns:x14="${L}" uri="${R}"><x14:id>${t.id}</x14:id></ext></extLst>`)}return t.iconSet&&(o+=`<iconSet iconSet="${t.iconSet.name}"${t.iconSet.reverse?' reverse="1"':""}${t.iconSet.showValue===!1?' showValue="0"':""}>${B(t.iconSet.cfvo)}</iconSet>`),`<cfRule ${e}>${o}</cfRule>`}function O(t){const e=t.ext;let o=` minLength="${e.minLength}" maxLength="${e.maxLength}"`;t.showValue===!1&&(o+=' showValue="0"'),e.gradient===!1&&(o+=' gradient="0"'),e.border&&(o+=' border="1"'),e.direction&&e.direction!=="context"&&(o+=` direction="${e.direction}"`),e.negFillSame&&(o+=' negativeBarColorSameAsPositive="1"'),e.negBorderSame===!1&&(o+=' negativeBarBorderColorSameAsPositive="0"'),e.axisPosition&&e.axisPosition!=="automatic"&&(o+=` axisPosition="${e.axisPosition}"`);const n=(e.border?S("borderColor",e.borderColor):"")+(e.negFillSame?"":S("negativeFillColor",e.negFill))+(e.border&&e.negBorderSame===!1?S("negativeBorderColor",e.negBorder):"")+(e.axisPosition==="none"?"":S("axisColor",e.axisColor));return`<x14:dataBar${o}>${y(e.cfvo)}${n}</x14:dataBar>`}function H(t){if(t.dataBar)return`<x14:cfRule type="dataBar" id="${t.id}">${O(t.dataBar)}</x14:cfRule>`;let e=(t.formulas??[]).map(o=>`<xm:f>${$(o)}</xm:f>`).join("");if(t.colorScale&&(e+=`<x14:colorScale>${y(t.colorScale.cfvo)}${t.colorScale.colors.map(o=>`<x14:color ${h(o)}/>`).join("")}</x14:colorScale>`),t.iconSet){const o=t.iconSet,n=o.custom!==void 0;e+=`<x14:iconSet iconSet="${o.name}"${o.showValue===!1?' showValue="0"':""}${o.reverse?' reverse="1"':""}${n?' custom="1"':""}>${y(o.cfvo)}${n?o.custom.map(i=>`<x14:cfIcon iconSet="${i.iconSet}" iconId="${i.iconId}"/>`).join(""):""}</x14:iconSet>`}return t.dxf&&(e+=z(t.dxf,"x14:dxf")),`<x14:cfRule ${k(t)} id="${t.id}">${e}</x14:cfRule>`}function J(t){let e="";for(const o of t){const n=o.rules.filter(i=>!C(i));n.length!==0&&(e+=`<conditionalFormatting${o.pivot?' pivot="1"':""} sqref="${$(o.sqref)}">${n.map(G).join("")}</conditionalFormatting>`)}return e}function K(t){let e="";for(const o of t){const n=o.rules.filter(i=>C(i)||i.dataBar?.ext);n.length!==0&&(e+=`<x14:conditionalFormatting xmlns:xm="${T}"${o.pivot?' pivot="1"':""}>${n.map(H).join("")}<xm:sqref>${$(o.sqref)}</xm:sqref></x14:conditionalFormatting>`)}return e?`<ext xmlns:x14="${L}" uri="${M}"><x14:conditionalFormattings>${e}</x14:conditionalFormattings></ext>`:""}function Q(t){for(const e of t)for(const o of e.rules)(C(o)||o.dataBar?.ext)&&!o.id&&(o.id=j())}function W(t){const e=/<\/extLst>\s*(?:<\/(?:\w+:)?worksheet>\s*)?$/.exec(t);return e?e.index:-1}function Y(t,e){const o=A(t);let n=o?t.slice(0,o.index)+t.slice(o.index+o[0].length):t;const i=K(e),r=W(n);if(!i)return r>=0?n.replace(/<extLst>\s*<\/extLst>(\s*(?:<\/(?:\w+:)?worksheet>\s*)?)$/,"$1"):n;if(r>=0)return n.slice(0,r)+i+n.slice(r);const l=n.lastIndexOf("</worksheet>"),s=`<extLst>${i}</extLst>`;return l>=0?n.slice(0,l)+s+n.slice(l):n+s}function at(t,e,o){const n=e??[];return Q(n),Y(o(t,"conditionalFormatting",J(n)),n)}const Z=t=>/^\s*[-+]?[\d.]+(?:[eE][-+]?\d+)?\s*$/.test(t);function rt(t,e){const o=i=>i.map(r=>typeof r.val=="string"&&!Z(r.val)?{...r,val:e(r.val)}:r),n={...t};return t.formulas&&(n.formulas=t.formulas.map(e)),t.colorScale&&(n.colorScale={...t.colorScale,cfvo:o(t.colorScale.cfvo)}),t.iconSet&&(n.iconSet={...t.iconSet,cfvo:o(t.iconSet.cfvo)}),t.dataBar&&(n.dataBar={...t.dataBar,cfvo:o(t.dataBar.cfvo)},t.dataBar.ext&&(n.dataBar.ext={...t.dataBar.ext,cfvo:o(t.dataBar.ext.cfvo)})),n}function st(t){return t.replace(/<conditionalFormatting\b[\s\S]*?<\/conditionalFormatting>/g,e=>" ".repeat(e.length))}export{D as X14_ICON_SETS,nt as applyCfExt,K as cfExtXml,J as cfMainXml,B as cfvoXml,h as colorAttrs,z as dxfToXml,C as extOnly,ot as extendRule,st as maskCfBlocks,it as parseDxfList,I as parseDxfNode,at as patchCf,Y as patchCfExt,W as sheetExtLstEnd,rt as shiftRuleFormulas};
@@ -0,0 +1 @@
1
+ const S="#5DAE63",et="#2F7D3A",d="#F9BE57",ot="#CF8A23",p="#DE5D59",st="#A83A36",B="#8A8A8A",it="#565656",K=new Map([[S,et],[d,ot],[p,st],[B,it]]),Y="#2B2B2B",k="#000000",lt="#3A3A3A",at="#BDBDBD",rt="#F2968F",ft="#EC2D21",ct="#1F4E8C",ht="#D5D5D5",dt="#A6A6A6",Et="#3E6BA8",gt="#E6E6E6",q="#F5C842",Rt="#C9971C",H="#DEDEDE",At="#A9A9A9",U="#FFFFFF",St=[[8,1],[14.5,8],[10.75,8],[10.75,15],[5.25,15],[5.25,8],[1.5,8]],v=0,J=45,V=90,Q=135,b=180;function j(t,o,e,s,n,i=0){const l=i*Math.PI/180,a=Math.cos(l),c=Math.sin(l);t.beginPath(),o.forEach(([r,f],E)=>{const h=r-8,T=f-8,A=e+(8+h*a-T*c)*n,P=s+(8+h*c+T*a)*n;E===0?t.moveTo(A,P):t.lineTo(A,P)}),t.closePath()}function M(t,o,e,s,n,i,l){j(t,o,s,n,i,l),t.fillStyle=e,t.fill();const a=K.get(e);a!==void 0&&(t.strokeStyle=a,t.lineWidth=1*i,t.lineJoin="miter",t.stroke())}function C(t,o,e,s,n,i=7,l=K.get(o)){t.beginPath(),t.arc(e+8*n,s+8*n,i*n,0,Math.PI*2),t.closePath(),t.fillStyle=o,t.fill(),l&&(t.strokeStyle=l,t.lineWidth=.9*n,t.stroke())}function u(t,o,e,s,n,i,l){t.strokeStyle=e,t.fillStyle=e,t.lineWidth=l*i,t.lineCap="round",t.lineJoin="round";const a=c=>{t.beginPath(),c.forEach(([r,f],E)=>E===0?t.moveTo(s+r*i,n+f*i):t.lineTo(s+r*i,n+f*i)),t.stroke()};o==="x"?(a([[4.6,4.6],[11.4,11.4]]),a([[11.4,4.6],[4.6,11.4]])):o==="check"?a([[3.8,8.4],[6.8,11.4],[12.2,4.8]]):(a([[8,3.4],[8,8.8]]),t.beginPath(),t.arc(s+8*i,n+12*i,l*.62*i,0,Math.PI*2),t.fill())}function pt(t,o,e,s,n){t.fillStyle=Y,t.fillRect(e+3.2*n,s+1.5*n,1.3*n,13.5*n),M(t,[[4.5,1.5],[14,5.5],[4.5,9.5]],o,e,s,n)}const R=[];for(let t=0;t<10;t++){const o=t%2===0?7.4:3,e=-Math.PI/2+t*Math.PI/5;R.push([8+Math.cos(e)*o,8.4+Math.sin(e)*o])}const Mt=[R[0],[8,12.2],R[6],R[7],R[8],R[9]],Tt=[R[0],R[1],R[2],R[3],R[4],[8,12.2]];function Dt(t,o,e,s,n){o===0?M(t,R,H,e,s,n):(M(t,Tt,H,e,s,n),M(t,Mt,q,e,s,n))}function Pt(t,o,e,s,n){o===2&&M(t,R,q,e,s,n),o<2&&Dt(t,o,e,s,n),j(t,R,e,s,n),t.strokeStyle=o===0?At:Rt,t.lineWidth=.9*n,t.lineJoin="round",t.stroke()}function X(t,o,e,s,n){for(let i=0;i<4;i++){const l=3.5+i*3.8,a=e+(1+i*3.6)*n,c=s+(15-l)*n;t.fillStyle=i<o?ct:ht,t.fillRect(a,c,2.8*n,l*n),i>=o&&(t.strokeStyle=dt,t.lineWidth=.6*n,t.strokeRect(a,c,2.8*n,l*n))}}function Ct(t,o,e,s,n){const i=e+8*n,l=s+8*n;t.beginPath(),t.arc(i,l,6.6*n,0,Math.PI*2),t.closePath(),t.fillStyle=U,t.fill(),o>0&&(t.beginPath(),o<4&&(t.moveTo(i,l),t.lineTo(i,l-6.6*n)),t.arc(i,l,6.6*n,-Math.PI/2,-Math.PI/2+o*Math.PI/2),t.closePath(),t.fillStyle=k,t.fill()),t.beginPath(),t.arc(i,l,6.6*n,0,Math.PI*2),t.closePath(),t.strokeStyle=k,t.lineWidth=1.5*n,t.stroke()}function It(t,o,e,s,n){[[1.5,8.5],[8.5,8.5],[1.5,1.5],[8.5,1.5]].forEach(([l,a],c)=>{t.fillStyle=c<o?Et:gt,t.fillRect(e+l*n,s+a*n,6.2*n,6.2*n)})}function I(t,o,e,s,n,i){M(t,St,o,s,n,i,e)}const y=[[p,b],[d,V],[S,v]],$=[[p,b],[d,Q],[d,J],[S,v]],N=[[p,b],[d,Q],[d,V],[d,J],[S,v]],mt={"3Arrows":(t,o,e,s,n)=>I(t,y[o][0],y[o][1],e,s,n),"3ArrowsGray":(t,o,e,s,n)=>I(t,B,y[o][1],e,s,n),"4Arrows":(t,o,e,s,n)=>I(t,$[o][0],$[o][1],e,s,n),"4ArrowsGray":(t,o,e,s,n)=>I(t,B,$[o][1],e,s,n),"5Arrows":(t,o,e,s,n)=>I(t,N[o][0],N[o][1],e,s,n),"5ArrowsGray":(t,o,e,s,n)=>I(t,B,N[o][1],e,s,n),"3Flags":(t,o,e,s,n)=>pt(t,[p,d,S][o],e,s,n),"3TrafficLights1":(t,o,e,s,n)=>C(t,[p,d,S][o],e,s,n),"3TrafficLights2":(t,o,e,s,n)=>{t.fillStyle=Y,t.beginPath(),t.moveTo(e+3*n,s+1*n),t.lineTo(e+13*n,s+1*n),t.quadraticCurveTo(e+15*n,s+1*n,e+15*n,s+3*n),t.lineTo(e+15*n,s+13*n),t.quadraticCurveTo(e+15*n,s+15*n,e+13*n,s+15*n),t.lineTo(e+3*n,s+15*n),t.quadraticCurveTo(e+1*n,s+15*n,e+1*n,s+13*n),t.lineTo(e+1*n,s+3*n),t.quadraticCurveTo(e+1*n,s+1*n,e+3*n,s+1*n),t.closePath(),t.fill(),C(t,[p,d,S][o],e,s,n,5.2)},"4TrafficLights":(t,o,e,s,n)=>C(t,[lt,p,d,S][o],e,s,n,7,o===0?k:void 0),"4RedToBlack":(t,o,e,s,n)=>C(t,[k,at,rt,ft][o],e,s,n,7,null),"3Signs":(t,o,e,s,n)=>{o===0?M(t,[[8,1],[15,8],[8,15],[1,8]],p,e,s,n):o===1?M(t,[[8,1.5],[15,14.5],[1,14.5]],d,e,s,n):C(t,S,e,s,n)},"3Symbols":(t,o,e,s,n)=>{C(t,[p,d,S][o],e,s,n),u(t,["x","!","check"][o],U,e,s,n,2)},"3Symbols2":(t,o,e,s,n)=>u(t,["x","!","check"][o],[p,d,S][o],e,s,n,3),"4Rating":(t,o,e,s,n)=>X(t,o+1,e,s,n),"5Rating":(t,o,e,s,n)=>X(t,o,e,s,n),"5Quarters":(t,o,e,s,n)=>Ct(t,o,e,s,n),"3Stars":(t,o,e,s,n)=>Pt(t,o,e,s,n),"3Triangles":(t,o,e,s,n)=>{o===0?M(t,[[2,5],[14,5],[8,12]],p,e,s,n):o===1?M(t,[[2,6.5],[14,6.5],[14,9.5],[2,9.5]],d,e,s,n):M(t,[[8,4],[14,11],[2,11]],S,e,s,n)},"5Boxes":(t,o,e,s,n)=>It(t,o,e,s,n)},Gt=t=>Number(t[0]);function Z(t,o,e,s,n,i){const l=mt[o];if(l===void 0)return;const a=Gt(o)-1;l(t,e<0?0:e>a?a:e,s,n,i/16)}function wt(t){return new Proxy(t,{set(o,e,s){return o[e]=e==="fillStyle"||e==="strokeStyle"?"#000000":s,!0},get(o,e){const s=o[e];return typeof s=="function"?s.bind(o):s}})}function Bt(t,o,e=16){const s=Math.max(1,Math.round(globalThis.devicePixelRatio??1)),n=document.createElement("canvas");return n.width=e*s,n.height=e*s,n.style.width=`${e}px`,n.style.height=`${e}px`,Z(n.getContext("2d"),t,o,0,0,e*s),n}const Lt=(t,o,e=12)=>Math.max(4,Math.min(t-Math.round(o),Math.round(e*o))),W=new Map;function Ft(t,o,e){const s=`${t}/${o}/${e}`;let n=W.get(s);return n===void 0&&(W.size>2048&&W.clear(),n=typeof OffscreenCanvas=="function"?new OffscreenCanvas(e,e):document.createElement("canvas"),n.width=e,n.height=e,Z(n.getContext("2d"),t,o,0,0,e),W.set(s,n)),n}function kt(t,o,e,s,n,i,l,a,c,r){const f=Lt(i,l,c);o._px!==f&&(o._px=f,o._sprite=Ft(o.name,o.level,f));const E=a==="top"?s+Math.round(l):a==="center"?s+Math.round((i-f)/2):s+i-f-Math.round(l);if(r){const h=e+n-Math.round(l)-f;t.save(),t.transform(-1,0,0,1,2*h+f,0),t.drawImage(o._sprite,h,E,f,f),t.restore();return}t.drawImage(o._sprite,e+Math.round(l),E,f,f)}const m=(t,o)=>parseInt(t.slice(o,o+2),16),z=new Map,x=.857;function Ot(t){let o=z.get(t);if(o===void 0){const e=s=>Math.round(s+(255-s)*x);o=`rgb(${e(m(t,1))},${e(m(t,3))},${e(m(t,5))})`,z.set(t,o)}return o}function _t(t,o,e,s,n,i,l){const a=Math.max(1,Math.min(24,Math.ceil(n))),c=[m(o,1),m(o,3),m(o,5)];for(let r=0;r<a;r++){const f=(r+.5)/a*x,E=A=>Math.round(A+(255-A)*f).toString(16).padStart(2,"0");t.fillStyle=`#${E(c[0])}${E(c[1])}${E(c[2])}`;const h=r/a*n,T=(r+1)/a*n;t.fillRect(l?e+n-T-.2:e+h,s,T-h+.2,i)}}function Wt(t,o,e,s,n,i,l,a,c=!1){const r=o.style,f=l,E=e+f,h=s+f,T=n-f*2,A=i-f*2;if(T<=0||A<=0)return;const P=r.direction==="rightToLeft"?!a:r.direction==="leftToRight"?!!a:!1,tt=P?1-o.x1:o.x0,nt=P?1-o.x0:o.x1,D=Math.round(E+tt*T),F=Math.round(E+nt*T),G=F-D,O=o.negative?r.negColor:r.color;if(G>0){const L=(o.negative&&r.axisAt>=0)!==P;if(r.gradient&&c)_t(t,O,D,h,G,A,L);else if(r.gradient){const g=t.createLinearGradient(L?F:D,0,L?D:F,0);g.addColorStop(0,O),g.addColorStop(1,Ot(O)),t.fillStyle=g}else t.fillStyle=O;(!r.gradient||!c)&&t.fillRect(D,h,G,A);const _=o.negative?r.negBorder:r.border;if(_){const g=l;t.fillStyle=_,t.fillRect(D,h,G,g),t.fillRect(D,h+A-g,G,g),t.fillRect(D,h,g,A),t.fillRect(F-g,h,g,A)}}if(r.axisAt>=0&&r.axisColor){const L=P?1-r.axisAt:r.axisAt,_=Math.round(E+L*T),g=l;t.fillStyle=r.axisColor;for(let w=s;w<s+i;w+=g*2)t.fillRect(_,w,g,Math.min(g,s+i-w))}}export{Z as drawCfIcon,Bt as iconCanvas,Gt as iconCount,Lt as iconSide,wt as monoContext,Wt as paintCfBar,kt as paintCfIcon};
@@ -0,0 +1 @@
1
+ import{colName as E,rangeRef as K,sheetPrefix as O}from"../core/address.js";import{KIND_MASK as P,NUM as z}from"../core/sheet.js";import{changeOutline as H}from"../core/whatif.js";import{outlineChanged as I,setFlag as R}from"./outline-column.js";import{xmlAttr as j}from"../io/xml-escape.js";const M={Sum:["SUM",null],Count:["COUNTA","count"],Average:["AVERAGE","average"],Max:["MAX","max"],Min:["MIN","min"],Product:["PRODUCT","product"],"Count Numbers":["COUNT","countNums"],StdDev:["STDEV","stdDev"],StdDevp:["STDEVP","stdDevp"],Var:["VAR","var"],Varp:["VARP","varp"]},A=n=>typeof n=="string"&&/^[=+\-@']/.test(n)?`'${n}`:String(n??"");function F(n){return String(n??"Book1").replace(/\.[^.]+$/,"").toLowerCase().replace(/(^|[^\p{L}])(\p{L})/gu,(m,i,c)=>i+c.toUpperCase())}function J(n){if(!n)return"";const t=M[n.fn]?.[1],m=`${t?` function="${t}"`:""}${n.leftLabels?' leftLabels="1"':""}${n.topLabels?' topLabels="1"':""}${n.link?' link="1"':""}`,i=n.refs.map(c=>`<dataRef ref="${K(c.range)}" sheet="${j(c.sheet.name)}"/>`).join("");return`<dataConsolidate${m}><dataRefs count="${n.refs.length}">${i}</dataRefs></dataConsolidate>`}function Q(n,t,m,i,{topRow:c=!1,leftCol:w=!1}={}){const{book:d}=n,u=d.sheet;if(m.some(r=>r.sheet===u))return{error:"Links can't be created to source areas on the destination sheet."};const x=d.engine,v=M[i]?.[0]??"SUM",S=[],y=new Map,C=[],D=new Map,L=(r,l,a)=>{const p=String(a).toLowerCase();let s=r.get(p);return s===void 0&&(s=l.length,r.set(p,s),l.push(a)),s},T=m.map(({sheet:r,range:l})=>{const a=l.r0+(c?1:0),p=l.c0+(w?1:0),s=[];for(let e=p;e<=l.c1;e++){const o=c?x.read(r,l.r0,e):e-p;c&&(o===null||o==="")||s.push([e,L(D,C,o)])}const h=[];for(let e=a;e<=l.r1;e++){const o=w?x.read(r,e,l.c0):e-a;w&&(o===null||o==="")||h.push([e,L(y,S,o)])}return{from:r,cols:s,rows:h}}),$=t.col+(w?2:0),V=F(d.fileName??n.fileName);let f=t.row+(c?1:0);return d.guardHint={ranges:[{r0:t.row,c0:t.col,r1:t.row+1,c1:$+C.length}]},d.transact("consolidate",r=>{const l=U(u);return c&&C.forEach((a,p)=>d.setInput(r,t.row,$+p,A(a))),S.forEach((a,p)=>{const s=f,h=new Set;for(const o of T)for(const[g,b]of o.rows)if(b===p){w&&d.setInput(r,f,t.col+1,V);for(const[k,N]of o.cols)(o.from.kind(g,k)&P)===z&&(d.setInput(r,f,$+N,`=${O(o.from.name)}$${E(k)}$${g+1}`),h.add(N));f++}if(f===s)return;const e=f-1;H(u,"row",s,e,1);for(let o=s;o<=e;o++)u.rows.setHidden(o,!0);w&&d.setInput(r,f,t.col,A(a));for(const o of[...h].sort((g,b)=>g-b)){const g=E($+o);d.setInput(r,f,$+o,`=${v}(${g}${s+1}${e>s?`:${g}${e+1}`:""})`)}R(u,"row",f,!0),f++}),u.dataConsolidate={fn:i,leftLabels:w,topLabels:c,link:!0,refs:m.map(a=>({sheet:a.sheet,range:a.range}))},u.dataConsolidateChanged=!0,I(u),u.colsChanged=!0,l}),d.dirty=!0,n.objects?.geometryChanged?.(),n.grid.invalidate(),{rows:S.length,cols:C.length}}function U(n){const t={rowExtras:n.rowExtras?new Map(n.rowExtras):null,hidden:new Set(n.rows.hiddenSizes?n.rows.hiddenSizes.keys():[]),consolidate:n.dataConsolidate??null};return()=>{const m=U(n);if(n.rows.hiddenSizes)for(const i of[...n.rows.hiddenSizes.keys()])t.hidden.has(i)||n.rows.setHidden(i,!1);for(const i of t.hidden)n.rows.setHidden(i,!0);return n.rowExtras=t.rowExtras,n.dataConsolidate=t.consolidate,n.dataConsolidateChanged=!0,I(n),n.revision++,m}}export{M as LINK_FUNCTIONS,F as bookLabel,Q as consolidateLinked,J as dataConsolidateXml};
@@ -0,0 +1,2 @@
1
+ import{children as A,parseTree as R,unescapeOoxml as b}from"../io/xml-scan.js";import{xmlAttr as j,xmlText as g}from"../io/xml-escape.js";const y=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ `,k="http://schemas.openxmlformats.org/package/2006/metadata/core-properties",v="http://purl.org/dc/elements/1.1/",C="http://purl.org/dc/terms/",S="http://www.w3.org/2001/XMLSchema-instance",B="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",D="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",I="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",M="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",l={core:{path:"docProps/core.xml",type:"application/vnd.openxmlformats-package.core-properties+xml",rel:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"},app:{path:"docProps/app.xml",type:"application/vnd.openxmlformats-officedocument.extended-properties+xml",rel:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"},custom:{path:"docProps/custom.xml",type:"application/vnd.openxmlformats-officedocument.custom-properties+xml",rel:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"}},N={title:"dc:title",subject:"dc:subject",creator:"dc:creator",keywords:"cp:keywords",description:"dc:description",category:"cp:category",contentStatus:"cp:contentStatus",lastModifiedBy:"cp:lastModifiedBy",lastPrinted:"cp:lastPrinted",revision:"cp:revision"},_={created:"dcterms:created",modified:"dcterms:modified"},E={manager:"Manager",company:"Company",hyperlinkBase:"HyperlinkBase"},$=e=>e.slice(e.indexOf(":")+1);function h(e,t){const o=e?.c.find(s=>$(s.n)===t);return o?b(o.t):void 0}function K(e,t={}){const o={custom:[],sources:{core:e.core??null,app:e.app??null,custom:e.custom??null},paths:{core:l.core.path,app:l.app.path,custom:l.custom.path,...t},changed:!1},s=p=>{if(!p)return null;try{return R(new TextEncoder().encode(p))}catch{return null}},r=s(e.core);for(const p of[...Object.keys(N),...Object.keys(_)]){const d=h(r,p);d!==void 0&&(o[p]=d)}const c=s(e.app);for(const[p,d]of Object.entries(E)){const f=h(c,d);f!==void 0&&(o[p]=f)}const i=h(c,"Application");i!==void 0&&(o.application=i);const n=h(c,"AppVersion");n!==void 0&&(o.appVersion=n);const u=h(c,"TotalTime");u!==void 0&&(o.totalTime=Number(u)||0);const a=s(e.custom),m=e.custom?[...e.custom.matchAll(/<property\b[\s\S]*?<\/property>/g)].map(p=>p[0]):[];return A(a,"property").forEach((p,d)=>{const f=p.c[0];if(!f)return;const T=$(f.n),x=V[T],w=b(f.t);o.custom.push({name:b(p.a.name??""),type:x??"text",value:x?F(x,w):w,raw:m[d]??null,vt:T})}),o}const V={lpwstr:"text",lpstr:"text",bstr:"text",i1:"number",i2:"number",i4:"number",i8:"number",int:"number",ui1:"number",ui2:"number",ui4:"number",ui8:"number",uint:"number",r4:"number",r8:"number",decimal:"number",bool:"bool",filetime:"date",date:"date"};function F(e,t){return e==="number"?Number(t):e==="bool"?t==="true"||t==="1":t}function L(e){switch(e.type){case"number":{const t=Number(e.value)||0;return Number.isInteger(t)&&Math.abs(t)<2147483648?`<vt:i4>${t}</vt:i4>`:`<vt:r8>${t}</vt:r8>`}case"bool":return`<vt:bool>${e.value?"true":"false"}</vt:bool>`;case"date":return`<vt:filetime>${g(e.value)}</vt:filetime>`;default:return`<vt:lpwstr>${g(e.value)}</vt:lpwstr>`}}function P(e,t,o,s=""){const r=$(t),c=new RegExp(`<((?:[\\w.-]+:)?${r})\\b[^>]*?(?:/>|>[\\s\\S]*?</\\1\\s*>)`),i=o==null||o==="",n=c.exec(e);if(i)return n?e.slice(0,n.index)+e.slice(n.index+n[0].length):e;const u=n?n[1]:t,a=`<${u}${s}>${g(o)}</${u}>`;if(n)return e.slice(0,n.index)+a+e.slice(n.index+n[0].length);const m=e.lastIndexOf("</");return e.slice(0,m)+a+e.slice(m)}function X(e,t,o){return new RegExp(`\\bxmlns:${t}=`).test(e)?e:e.replace(/<((?:[\w.-]+:)?coreProperties|Properties)\b/,s=>`${s} xmlns:${t}="${o}"`)}function H(e){let t=e.sources?.core;t||(t=`${y}<cp:coreProperties xmlns:cp="${k}" xmlns:dc="${v}" xmlns:dcterms="${C}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${S}"></cp:coreProperties>`);for(const[o,s]of[["dc",v],["dcterms",C],["xsi",S]])t=X(t,o,s);for(const[o,s]of Object.entries(N))t=P(t,s,e[o]);for(const[o,s]of Object.entries(_))t=P(t,s,e[o],' xsi:type="dcterms:W3CDTF"');return t}function U(e){let t=e.sources?.app;t||(t=`${y}<Properties xmlns="${B}" xmlns:vt="${D}"><Application>8sheets</Application></Properties>`);for(const[o,s]of Object.entries(E))t=P(t,s,e[o]);return t}function q(e){const t=e.custom.map((o,s)=>{const r=s+2;return o.raw&&!o.edited?o.raw.replace(/\bpid="\d+"/,`pid="${r}"`):`<property fmtid="${M}" pid="${r}" name="${j(o.name)}">${L(o)}</property>`});return`${y}<Properties xmlns="${I}" xmlns:vt="${D}">${t.join("")}</Properties>`}let O=()=>new Date;function Q(e){O=e??(()=>new Date)}const W=()=>O();function Z(e){const t=e.docProps,o=e.source===null;if(!t&&!o)return null;const s=W().toISOString().replace(/\.\d+Z$/,"Z"),r=t??{custom:[],sources:{},paths:{},changed:!1};e.docProps=r,!r.created&&o&&(r.created=s),r.modified=s;const c=[],i=r.paths??{},n=(a,m)=>c.push({key:a,path:i[a]??l[a].path,type:l[a].type,rel:l[a].rel,xml:m});(o||r.changed||r.sources?.core)&&n("core",H(r)),(o||r.changed&&(r.sources?.app||r.manager||r.company||r.hyperlinkBase))&&n("app",U(r)),r.custom.length>0&&(o||r.customChanged)&&n("custom",q(r));const u=r.customChanged===!0&&r.custom.length===0&&!!r.sources?.custom;return c.length||u?{parts:c,dropCustom:u,customPath:i.custom??l.custom.path}:null}function z(e,t,o=!0){const s=e.docProps;if(!(!s||!t)){for(const r of t.parts)s.sources[r.key]=r.xml;if(t.dropCustom&&(s.sources.custom=null),!!o){for(const r of s.custom)r.edited=!1;s.changed=!1,s.customChanged=!1}}}function ee(e,t){if(!t)return e;let o=e;t.dropCustom&&(o=o.replace(new RegExp(`<Override\\b[^>]*PartName="/${t.customPath.replace(/[.]/g,"\\.")}"[^>]*/>`),""));const s=t.parts.filter(r=>!o.includes(`PartName="/${r.path}"`)).map(r=>`<Override PartName="/${r.path}" ContentType="${r.type}"/>`).join("");return s?o.replace("</Types>",`${s}</Types>`):o}function Y(e){return e?e.parts.map(t=>`<Relationship Id="rIdProps_${t.key}" Type="${t.rel}" Target="${t.path}"/>`).join(""):""}async function te(e,t,o,s){if(!o)return;for(const n of o.parts)await e.addBytes(n.path,n.xml),s.add(n.path);if(o.dropCustom&&s.add(o.customPath),!t||!t.has("_rels/.rels"))return;let r=await t.text("_rels/.rels");const c=r;o.dropCustom&&(r=r.replace(/<Relationship\b[^>]*custom-properties[^>]*\/>/,""));const i=o.parts.filter(n=>!r.includes(`Type="${n.rel}"`));i.length&&(r=r.replace("</Relationships>",`${Y({parts:i})}</Relationships>`)),r!==c&&(await e.addBytes("_rels/.rels",r),s.add("_rels/.rels"))}function oe(e){const t={};for(const o of e.matchAll(/<Relationship\b[^>]*\/>/g)){const s=/\bType="([^"]+)"/.exec(o[0])?.[1],r=/\bTarget="([^"]+)"/.exec(o[0])?.[1];if(!(!s||!r))for(const[c,i]of Object.entries(l))s===i.rel&&(t[c]=r.replace(/^\//,""))}return t}export{l as PARTS,z as docPropsCommitted,oe as docPropsPaths,Z as docPropsPlan,Y as docPropsRels,ee as docPropsTypes,K as parseDocProps,Q as setSaveClock,te as writeDocProps};
@@ -0,0 +1 @@
1
+ import{child as p,children as g,parseTree as V,unescapeOoxml as y}from"../io/xml-scan.js";import{escapeMarkup as F,xmlAttr as v}from"../io/xml-escape.js";import{parseRangeRef as C,rangeRef as I,sheetPrefix as j}from"../core/address.js";const q=new TextEncoder,$=e=>e==="1"||e==="true",b=e=>e==="0"||e==="false",x=e=>e===void 0||e===""?void 0:Number(e),Y=["equal","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"];function D(e){if(e instanceof Set){const t=[];let n=!1;for(const r of e)r===""?n=!0:t.push(r);return{kind:"values",values:t,blank:n,dates:[]}}return e}function k(e){return{group:e.dateTimeGrouping??"year",y:x(e.year),m:x(e.month),d:x(e.day),h:x(e.hour),i:x(e.minute),s:x(e.second)}}const N=e=>e.slice(e.indexOf(":")+1);function P(e,t){for(const n of e.c){if(N(n.n)===t)return n;const r=P(n,t);if(r)return r}return null}function W(e,t){const n=p(e,"filters");if(n)return{kind:"values",values:g(n,"filter").map(u=>y(u.a.val??"")),blank:$(n.a.blank),dates:g(n,"dateGroupItem").map(u=>k(u.a)),calendarType:n.a.calendarType};const r=p(e,"customFilters");if(r)return{kind:"custom",and:$(r.a.and),rules:g(r,"customFilter").map(u=>({op:u.a.operator??"equal",val:y(u.a.val??"")}))};const o=p(e,"top10");if(o)return{kind:"top10",top:!b(o.a.top),percent:$(o.a.percent),val:Number(o.a.val??10),filterVal:x(o.a.filterVal)};const i=p(e,"dynamicFilter");if(i)return{kind:"dynamic",type:i.a.type??"null",val:x(i.a.val),maxVal:x(i.a.maxVal)};const l=p(e,"colorFilter");if(l)return{kind:"color",cell:!b(l.a.cellColor),dxfId:x(l.a.dxfId)};const a=p(e,"iconFilter");if(a)return{kind:"icon",iconSet:a.a.iconSet??"3Arrows",iconId:x(a.a.iconId)};const s=p(e,"extLst");if(s){const u=P(s,"filters");if(u)return{kind:"values",values:u.c.filter(f=>N(f.n)==="filter").map(f=>y(f.a.val??"")),blank:$(u.a.blank),dates:u.c.filter(f=>N(f.n)==="dateGroupItem").map(f=>k(f.a))}}return e.c.length>0?{kind:"raw",xml:t}:null}const S=(e,t,n=0)=>{const r=e.indexOf(`<${t}`,n);if(r<0)return null;const o=e.charCodeAt(r+t.length+1);if(o!==32&&o!==47&&o!==62&&o!==10&&o!==13&&o!==9)return S(e,t,r+1);const i=e.indexOf(">",r);if(i<0)return null;if(e[i-1]==="/")return{at:r,end:i+1,text:e.slice(r,i+1)};const l=e.indexOf(`</${t}>`,i);if(l<0)return null;const a=l+t.length+3;return{at:r,end:a,text:e.slice(r,a)}},G='xmlns:xr="x" xmlns:xr3="x" xmlns:x14="x" xmlns:xlrd2="x" xmlns:mc="x" xmlns:xm="x" xmlns:r="x" xmlns:x="x" xmlns:xr2="x" xmlns:xr6="x" xmlns:xr10="x"',T=e=>V(q.encode(`<root ${G}>${e}</root>`)).c[0];function B(e){const t=C(e.a.ref??"");return t?{...t,byColumns:$(e.a.columnSort),caseSensitive:$(e.a.caseSensitive),conditions:g(e,"sortCondition").map(n=>({...C(n.a.ref??"")??t,desc:$(n.a.descending),sortBy:n.a.sortBy??"value",customList:y(n.a.customList),dxfId:x(n.a.dxfId),iconSet:n.a.iconSet,iconId:x(n.a.iconId)}))}:null}function L(e){const t=T(e),n=C(t?.a.ref??"");if(!n)return null;const r=new Map;let o=null,i=0;for(const a of g(t,"filterColumn")){const s=S(e,"filterColumn",i);i=s?s.end:i;const u=n.c0+Number(a.a.colId??0),f=W(a,s?.text??"");f&&r.set(u,f),($(a.a.hiddenButton)||b(a.a.showButton))&&(o??=new Map,o.set(u,{hidden:$(a.a.hiddenButton),noShow:b(a.a.showButton)}))}const l=p(t,"sortState");return{...n,columns:r,buttons:o,sortState:l?B(l):null}}function A(e){const t=T(e);return t?B(t):null}function ee(e){const t={autoFilter:null,sortState:null};if(!e)return t;try{const n=S(e,"autoFilter");n&&(t.autoFilter=L(n.text));const r=n?n.end:0,o=S(e,"sortState",r),i=e.indexOf("<mergeCells");o&&(i<0||o.at<i)&&(t.sortState=A(o.text))}catch{}return t}function w(e){return String(e)}function X(e){const t=[];return e.y!==void 0&&t.push(`year="${e.y}"`),e.m!==void 0&&t.push(`month="${e.m}"`),e.d!==void 0&&t.push(`day="${e.d}"`),e.h!==void 0&&t.push(`hour="${e.h}"`),e.i!==void 0&&t.push(`minute="${e.i}"`),e.s!==void 0&&t.push(`second="${e.s}"`),t.push(`dateTimeGrouping="${e.group}"`),`<dateGroupItem ${t.join(" ")}/>`}function z(e){switch(e.kind){case"values":{const t=e.values.map(r=>`<filter val="${v(r)}"/>`).join("")+(e.dates??[]).map(X).join(""),n=`${e.blank?' blank="1"':""}${e.calendarType?` calendarType="${F(e.calendarType)}"`:""}`;return t?`<filters${n}>${t}</filters>`:`<filters${n}/>`}case"custom":return`<customFilters${e.and?' and="1"':""}>${e.rules.map(t=>`<customFilter${t.op&&t.op!=="equal"?` operator="${t.op}"`:""} val="${v(t.val)}"/>`).join("")}</customFilters>`;case"top10":return`<top10${e.top?"":' top="0"'}${e.percent?' percent="1"':""} val="${w(e.val)}"${e.filterVal!==void 0?` filterVal="${w(e.filterVal)}"`:""}/>`;case"dynamic":return`<dynamicFilter type="${F(e.type)}"${e.val!==void 0?` val="${w(e.val)}"`:""}${e.maxVal!==void 0?` maxVal="${w(e.maxVal)}"`:""}/>`;case"color":return`<colorFilter${e.dxfId!==void 0?` dxfId="${e.dxfId}"`:""}${e.cell?"":' cellColor="0"'}/>`;case"icon":return`<iconFilter iconSet="${F(e.iconSet)}"${e.iconId!==void 0?` iconId="${e.iconId}"`:""}/>`;default:return""}}function U(e,t,n){if(t?.kind==="raw")return t.xml.replace(/\bcolId="\d+"/,`colId="${e}"`);const r=`${n?.hidden?' hiddenButton="1"':""}${n?.noShow?' showButton="0"':""}`,o=t?z(D(t)):"";return o?`<filterColumn colId="${e}"${r}>${o}</filterColumn>`:`<filterColumn colId="${e}"${r}/>`}function E(e){if(!e||e.conditions.length===0)return"";const t=e.conditions.map(n=>{const r=[`ref="${I(n)}"`];return n.desc&&r.push('descending="1"'),n.sortBy&&n.sortBy!=="value"&&r.push(`sortBy="${n.sortBy}"`),n.customList&&r.push(`customList="${v(n.customList)}"`),n.dxfId!==void 0&&r.push(`dxfId="${n.dxfId}"`),n.iconSet&&r.push(`iconSet="${F(n.iconSet)}"`),n.iconId!==void 0&&r.push(`iconId="${n.iconId}"`),`<sortCondition ${r.join(" ")}/>`}).join("");return`<sortState ref="${I(e)}"${e.byColumns?' columnSort="1"':""}${e.caseSensitive?' caseSensitive="1"':""}>${t}</sortState>`}function Z(e,t=!0){const n=new Set(e.columns?.keys()??[]);if(e.buttons)for(const l of e.buttons.keys())n.add(l);const r=[...n].sort((l,a)=>l-a).map(l=>U(l-e.c0,e.columns?.get(l)??null,e.buttons?.get(l))).join(""),o=t?E(e.sortState):"",i=I(e);return r||o?`<autoFilter ref="${i}">${r}${o}</autoFilter>`:`<autoFilter ref="${i}"/>`}function te(e){return`${e.autoFilter?Z(e.autoFilter):""}${E(e.sortState)}`}function ne(e){try{const t=new TextDecoder().decode(e),n=S(t,"autoFilter");if(!n)return null;const r=L(n.text);if(!r)return null;const o=S(t,"sortState",n.end);return o&&(r.sortState=A(o.text)),r}catch{return null}}function O(e,t){if(t.columns.size===0)return;const n=e.rows.hiddenSizes;if(n)for(const r of n.keys())r>t.r0&&r<=t.r1&&(e.filteredRows??=new Set,e.filteredRows.add(r))}function re(e,t){t&&(t.sortState&&(e.sortState=t.sortState),t.autoFilter&&(e.autoFilter=t.autoFilter,O(e,t.autoFilter)))}function oe(e,t){const n={r0:e.r0,c0:e.c0,r1:e.r1-e.totalsRows,c1:e.c1},r=e.fileFilter,o={...n,columns:r?.columns??new Map,buttons:r?.buttons??null,sortState:r?.sortState??null};return t&&O(t,o),o}function le(e){const t=o=>{let i=0;if(o)for(const l of o.values()){const a=l.indexOf('outlineLevel="');a>=0&&(i=Math.max(i,l.charCodeAt(a+14)-48))}return i},n=e.autoFilter??(e.advancedFilter?.inPlace?e.advancedFilter:null);let r=!1;if(n&&e.filteredRows){for(const o of e.filteredRows)if(o>n.r0&&o<=n.r1){r=!0;break}}return{filterMode:r,summaryBelow:e.summaryAbove!==!0,summaryRight:e.summaryLeft!==!0,applyStyles:e.outlineAutoStyles===!0,standardWidth:e.standardWidthChanged?e.cols.defaultSize:null,levelRow:t(e.rowExtras),levelCol:t(e.colExtras)}}function h(e,t,n){const r=new RegExp(`\\s${t}="[^"]*"`),o=e.replace(r,"");return n===null?o:o.replace(/\s*(\/?)>$/,` ${t}="${n}"$1>`)}function ie(e,t){if(!t)return e;let n=e;const r=/<sheetPr\b[^>]*?(\/?)>/.exec(n),o=t.filterMode||!t.summaryBelow||!t.summaryRight||t.applyStyles;if(r||o){let i=r?r[0]:"<sheetPr/>";i=h(i,"filterMode",t.filterMode?"1":null);let l="",a=n;if(r)if(r[1]==="/")a=n.slice(0,r.index)+n.slice(r.index+r[0].length);else{const m=n.indexOf("</sheetPr>",r.index);l=n.slice(r.index+r[0].length,m),a=n.slice(0,r.index)+n.slice(m+10)}const s=/<outlinePr\b[^>]*\/>/.exec(l);let u=s?s[0]:"<outlinePr/>";if(u=h(u,"summaryBelow",t.summaryBelow?null:"0"),u=h(u,"summaryRight",t.summaryRight?null:"0"),u=h(u,"applyStyles",t.applyStyles?"1":null),s&&(l=l.replace(s[0],"")),u!=="<outlinePr/>"){const m=l.indexOf("<pageSetUpPr");l=m>=0?`${l.slice(0,m)}${u}${l.slice(m)}`:`${l}${u}`}const f=r?r.index:(()=>{const m=/<worksheet\b[^>]*>/.exec(a);return m?m.index+m[0].length:0})(),d=/<sheetPr\b([^>]*?)\/?>/.exec(i)[1],c=l||d.trim()?l?`<sheetPr${d}>${l}</sheetPr>`:`<sheetPr${d}/>`:"";n=a.slice(0,f)+c+a.slice(f)}return n=n.replace(/<sheetFormatPr\b[^>]*\/>/,i=>{let l=h(i,"outlineLevelRow",t.levelRow>0?String(t.levelRow):null);return l=h(l,"outlineLevelCol",t.levelCol>0?String(t.levelCol):null),t.standardWidth&&(l=h(l,"defaultColWidth",String(Math.trunc(t.standardWidth/6*256)/256))),l}),n}function ae(e){const t=[];return e.forEach((n,r)=>{const o=n.autoFilter?null:n.advancedFilter,i=n.autoFilter??o;if(!i)return;const l=(a,s)=>`${j((a??n).name)}$${M(s.c0)}$${s.r0+1}:$${M(s.c1)}$${s.r1+1}`;t.push({localSheetId:r,text:l(o?.listSheet,i)}),o?.criteria&&t.push({name:"_xlnm.Criteria",localSheetId:r,text:l(o.criteriaSheet,o.criteria),visible:!0}),o?.extract&&t.push({name:"_xlnm.Extract",localSheetId:r,text:l(n,o.extract),visible:!0})}),t}function ue(e,t){const n=r=>{const o=/^(?:'((?:[^']|'')*)'|([^'!]+))!\$?([A-Z]+)\$?(\d+)(?::\$?([A-Z]+)\$?(\d+))?$/.exec(r??"");if(!o)return null;const i=a=>[...a].reduce((s,u)=>s*26+u.charCodeAt(0)-64,0)-1,l=e.sheets.find(a=>a.name===(o[1]?.replace(/''/g,"'")??o[2]));return l?{sheet:l,range:{r0:Number(o[4])-1,c0:i(o[3]),r1:Number(o[6]??o[4])-1,c1:i(o[5]??o[3])}}:null};e.sheets.forEach((r,o)=>{if(r.autoFilter)return;const i=(t??[]).filter(d=>d.localSheetId===o),l=n(i.find(d=>d.name==="_xlnm._FilterDatabase")?.text);if(!l)return;const a=n(i.find(d=>d.name==="_xlnm.Criteria")?.text),s=n(i.find(d=>d.name==="_xlnm.Extract")?.text),u=r.rows.hiddenSizes;let f=!1;if(l.sheet===r&&u)for(const d of u.keys())d>l.range.r0&&d<=l.range.r1&&((r.filteredRows??=new Set).add(d),f=!0);r.advancedFilter={...l.range,listSheet:l.sheet,criteria:a?.range??null,criteriaSheet:a?.sheet??null,extract:s?.range??null,unique:!1,inPlace:f}})}function M(e){let t="";for(let n=e+1;n>0;n=Math.floor((n-1)/26))t=String.fromCharCode(65+(n-1)%26)+t;return t}function se(e,t,n=[]){if(!t)return e;const r=/<definedName\b[^>]*name="_xlnm\._FilterDatabase"[^>]*>[\s\S]*?<\/definedName>/g,o=new Set(t.map(c=>c.localSheetId));let i=e.replace(r,c=>{const m=Number(/\blocalSheetId="(\d+)"/.exec(c)?.[1]??-1);return!o.has(m)&&n[m]?.sourceIndex===m?c:""});const l=new Set(t.filter(c=>c.name).map(c=>`${c.name}|${c.localSheetId}`));i=i.replace(/<definedName\b[^>]*name="(_xlnm\.(?:Criteria|Extract))"[^>]*>[\s\S]*?<\/definedName>/g,(c,m)=>{const _=/\blocalSheetId="(\d+)"/.exec(c)?.[1]??"-1";return l.has(`${m}|${_}`)?"":c});const a=t.map(c=>`<definedName name="${c.name??"_xlnm._FilterDatabase"}" localSheetId="${c.localSheetId}"${c.visible?"":' hidden="1"'}>${F(c.text)}</definedName>`).join(""),s=/<definedNames\b[^>]*>([\s\S]*?)<\/definedNames>/.exec(i);if(s){const c=a+s[1];return i.slice(0,s.index)+(c.trim()?`<definedNames>${c}</definedNames>`:"")+i.slice(s.index+s[0].length)}if(!a)return i;const u=/<\/sheets>/.exec(i);if(!u)return i;let f=u.index+u[0].length;const d=/<\/externalReferences>/.exec(i);return d&&(f=Math.max(f,d.index+d[0].length)),`${i.slice(0,f)}<definedNames>${a}</definedNames>${i.slice(f)}`}function ce(e,t){if(!e)return{color:null,auto:!0};if(t){const r=e.pf;if(r){if(r.none)return{color:null,none:!0};if(r.auto)return{color:null,auto:!0};if(r.fg)return{color:r.fg.toLowerCase()}}return e.fill?{color:e.fill.toLowerCase()}:{color:null,none:!0}}const n=e.pf;return n?.fg?{color:n.fg.toLowerCase()}:e.color?{color:e.color.toLowerCase()}:{color:null,auto:!0}}const R=e=>`FF${e.slice(1).toUpperCase()}`;function H(e,t,n=!1){return n&&!t?{color:e??void 0,pf:null,raw:`<dxf><font><color ${e===null?'auto="1"':`rgb="${R(e)}"`}/></font></dxf>`}:t?e===null?{pf:{none:!0},raw:'<dxf><fill><patternFill patternType="none"><fgColor indexed="64"/><bgColor indexed="65"/></patternFill></fill></dxf>'}:{pf:{fg:e},raw:`<dxf><fill><patternFill patternType="solid"><fgColor rgb="${R(e)}"/><bgColor rgb="FF000000"/></patternFill></fill></dxf>`}:e===null?{pf:{auto:!0},raw:'<dxf><fill><patternFill patternType="solid"><fgColor auto="1"/><bgColor indexed="65"/></patternFill></fill></dxf>'}:{pf:{fg:e},raw:`<dxf><fill><patternFill patternType="solid"><fgColor rgb="${R(e)}"/><bgColor rgb="FF000000"/></patternFill></fill></dxf>`}}function fe(e,t,n,r=!1){const o=H(t,n,r);e.dxfs??=[];const i=e.dxfs.findIndex(l=>l.raw===o.raw);return i>=0?i:(e.dxfs.push(o),e.dxfs.length-1)}export{Y as OPERATORS,ue as adoptAdvancedFilter,re as applySheetFilter,D as asSpec,Z as autoFilterXml,fe as colorDxfId,ce as dxfFilterColor,ae as filterNameEntries,H as makeColorDxf,L as parseAutoFilter,A as parseSortState,se as patchFilterNames,ie as patchSheetProps,ee as readSheetFilter,ne as readTableFilter,te as sheetFilterXml,le as sheetProps,E as sortStateXml,oe as tableFilterFromFile};
@@ -0,0 +1,2 @@
1
+ import{CHUNK_BITS as T,CHUNK_MASK as R,EMPTY as B,FORMULA as U,KIND_MASK as J,SPILL as W,STR as D}from"../core/sheet.js";const N=/[.+^${}()|[\]\\]/g;function H(e){if(!/[*?~]/.test(e))return null;let t="";for(let n=0;n<e.length;n++){const s=e[n];s==="~"&&n+1<e.length&&"*?~".includes(e[n+1])?t+=e[++n].replace(/[*?]/,"\\$&"):s==="*"?t+="[\\s\\S]*":s==="?"?t+="[\\s\\S]":t+=s.replace(N,"\\$&")}return t}function v(e,{matchCase:t=!1,whole:n=!1}={}){const s=H(e);if(s===null&&!n){if(t)return r=>r.includes(e);const i=e.toLowerCase();return r=>r.toLowerCase().includes(i)}if(s===null){if(t)return r=>r===e;const i=e.toLowerCase();return r=>r.toLowerCase()===i}const o=new RegExp(n?`^(?:${s})$`:s,t?"":"i");return i=>o.test(i)}function G(e,t,{matchCase:n=!1,whole:s=!1}={}){const o=H(e)??e.replace(N,"\\$&").replace(/[*?]/g,"\\$&"),i=new RegExp(s?`^(?:${o})$`:o,n?"g":"gi");return r=>r.replace(i,()=>t)}const X=(e,t)=>e===t||e&&t&&typeof e=="object"&&JSON.stringify(e)===JSON.stringify(t);function Y(e,t,n){const{styles:s,strings:o}=e,{what:i,look:r,format:h}=t,u=i===""?null:v(i,t),d=new Uint8Array(o.size+1),c=new Map,m=l=>{let a=c.get(l);if(a===void 0){const w=s.get(l);a=Object.keys(h).every(x=>X(w[x]??null,h[x]??null)),c.set(l,a)}return a};return(l,a,w,x,f)=>{if(r==="values"&&(l.rows.isHidden(a)||l.cols.isHidden(w)||l.filteredRows?.has(a))||h!==null&&!m(l.style(a,w)))return!1;if(u===null)return!0;const p=x&J,S=l.protection&&x&U&&s.get(l.style(a,w)).hiddenFormula;if(r==="formulas"&&x&U&&!S)return u(e.editText(l,a,w));if(p===B)return!1;if(p===D){if(f>=d.length)return u(o.get(f));let y=d[f];return y===0&&(y=u(o.get(f))?1:2,d[f]=y),y===1}const g=r==="formulas"&&!S?e.editText(l,a,w):n(p,f,s.get(l.style(a,w)));return u(g)}}const P=12,F=()=>new Promise(e=>setTimeout(e,0));class K{constructor(t){this.ctrl=t,this.start=performance.now()}async pause(){return performance.now()-this.start<P?!this.ctrl.cancelled:(this.ctrl.onProgress?.(),await F(),this.start=performance.now(),!this.ctrl.cancelled)}}const A=(e,t,n)=>e?n*1048576+t:t*16384+n;function q(e){const t=[];for(let n=0;n<=e.maxCol;n++)e.columns[n]!==void 0&&t.push(n);return t}async function _(e,{byCols:t,dir:n,from:s,to:o,withEmpty:i},r,h){const u=q(e);n<0&&u.reverse();const d=s===null?-n*(1/0):s,c=o===null?n*(1/0):o,m=n>0?f=>f>=d&&f<=c:f=>f<=d&&f>=c,l=i===!0;if(t){for(const f of u){const p=e.columns[f],S=n>0?0:p.length-1,g=n>0?p.length:-1;for(let y=S;y!==g;y+=n){const L=p[y];if(L===void 0)continue;const k=y<<T,{kinds:I,values:M,styles:O}=L;for(let C=n>0?0:R;C>=0&&C<=R;C+=n){const $=I[C];if($===0&&!(l&&O!==null&&O[C]!==0))continue;const E=k+C;if(m(A(!0,E,f))&&r(E,f,$,M[C]))return!0}if(!await h.pause())return!1}}return!1}const a=e.maxRow>>>T,w=n>0?0:a,x=n>0?a+1:-1;for(let f=w;f!==x;f+=n){const p=[];for(const g of u){const y=e.columns[g][f];y!==void 0&&p.push(g,y)}if(p.length===0)continue;const S=f<<T;for(let g=n>0?0:R;g>=0&&g<=R;g+=n){const y=S+g;for(let L=0;L<p.length;L+=2){const k=p[L+1],I=k.kinds[g];if(I===0&&!(l&&k.styles!==null&&k.styles[g]!==0))continue;const M=p[L];if(m(A(!1,y,M))&&r(y,M,I,k.values[g]))return!0}}if(!await h.pause())return!1}return!1}function Q(e,t){if(!t.author?.startsWith("tc="))return t;const n=t.author.slice(3),s=(e.threads??[]).filter(o=>o.id===n||o.parentId===n).map(o=>o.text).join(`
2
+ `);return{...t,text:s}}function z(e,t,n){if(!e.comments)return[];const s=[];for(const[o,i]of e.comments){const r=Math.floor(o/16384);s.push({row:r,col:o-r*16384,note:Q(e,i)})}return s.sort((o,i)=>n*(A(t,o.row,o.col)-A(t,i.row,i.col))),s}function V(e,t,n){const s=e.sheets.filter(r=>!r.hidden);if(t.within!=="workbook")return[e.sheet];const o=s.indexOf(e.sheet),i=[];for(let r=0;r<s.length;r++)i.push(s[(o+n*r+s.length*2)%s.length]);return i}const Z=(e,t,n)=>e.some(s=>t>=s.r0&&t<=s.r1&&n>=s.c0&&n<=s.c1);function j(e,t,n){const s=Y(e,t,n);if(!t.ranges)return s;const o=t.sheet??e.sheet;return(i,r,h,u,d)=>(i!==o||Z(t.ranges,r,h))&&s(i,r,h,u,d)}async function it(e,t,n,s,o,i={}){const r=t.byColumns===!0,h=new K(i),u=V(e,t,s),d=A(r,n.row,n.col);if(t.look==="notes")return b(e,t,u,d,r,s);const c=j(e,t,o),m=t.what===""&&t.format!==null;let l=null;const a=async(w,x,f,p)=>(await _(w,{byCols:r,dir:s,from:x,to:f,withEmpty:m},(S,g,y,L)=>p&&A(r,S,g)===d||!c(w,S,g,y,L)?!1:(l={sheet:w,row:S,col:g},!0),h),l!==null||i.cancelled===!0);if(await a(u[0],d,null,!0))return l;for(let w=1;w<u.length;w++)if(await a(u[w],null,null,!1))return l;return await a(u[0],null,d,!1),l}function b(e,t,n,s,o,i){const r=v(t.what,t),h=c=>r(c.note.text??""),u=z(n[0],o,i),d=i>0?c=>c>s:c=>c<s;for(const c of u)if(d(A(o,c.row,c.col))&&h(c))return{sheet:n[0],row:c.row,col:c.col};for(let c=1;c<n.length;c++)for(const m of z(n[c],o,i))if(h(m))return{sheet:n[c],row:m.row,col:m.col};for(const c of u)if(!d(A(o,c.row,c.col))&&h(c))return{sheet:n[0],row:c.row,col:c.col};return null}class tt{constructor(t){this.cap=t,this.count=0,this.overflow=!1,this.size=Math.min(t,1024),this.rows=new Uint32Array(this.size),this.cols=new Uint16Array(this.size),this.sheets=new Uint16Array(this.size),this.sheetList=[]}push(t,n,s){if(this.count===this.cap)return this.overflow=!0,!1;if(this.count===this.size){this.size=Math.min(this.cap,this.size*2);const r=(h,u)=>{const d=new h(this.size);return d.set(u),d};this.rows=r(Uint32Array,this.rows),this.cols=r(Uint16Array,this.cols),this.sheets=r(Uint16Array,this.sheets)}let o=this.sheetList.indexOf(t);o<0&&(o=this.sheetList.length,this.sheetList.push(t));const i=this.count++;return this.rows[i]=n,this.cols[i]=s,this.sheets[i]=o,!0}}async function et(e,t,n,s={},o=1e5){const i=new tt(o),r=t.byColumns===!0,h=new K(s),u=t.sheet?[t.sheet]:t.within==="workbook"?e.sheets.filter(m=>!m.hidden):[e.sheet];if(t.look==="notes"){const m=v(t.what,t);for(const l of u)for(const a of z(l,r,1))m(a.note.text??"")&&i.push(l,a.row,a.col);return i}const d=j(e,t,n),c=t.what===""&&t.format!==null;for(const m of u)if(await _(m,{byCols:r,dir:1,from:null,to:null,withEmpty:c},(a,w,x,f)=>d(m,a,w,x,f)?!i.push(m,a,w):!1,h)||s.cancelled)break;return i}function nt(e,t,n,s,o,i,r=null){const{sheet:h}=t;let u=!1;if(o!==null){const d=h.formula(n,s);if(d&&d.t==="array")return!1;const c=h.kind(n,s);if(c&W&&!(c&U))return!1;const m=e.editText(h,n,s),l=o(m);if(l!==m&&l.startsWith("=")&&l.length>1&&!st(e,l.slice(1)))return r!==null&&r.invalid++,!1;l!==m&&(e.setInput(t,n,s,l),u=!0)}return i&&(u||t.saveCell(n,s),h.setStyle(n,s,e.styles.derive(h.style(n,s),i)),u=!0),u}async function ot(e,t,n,s,o,i={}){const r=await et(e,{...t,look:"formulas"},o,i,4294967295);if(i.cancelled)return{count:0,sheets:0,cancelled:!0};const h=t.what===""?null:G(t.what,n??"",t);let u=0,d=0;const c={locked:0,invalid:0},m=[];for(let l=0;l<r.sheetList.length;l++){const a=r.sheetList[l],w=[];let x=0,f=0;for(;f<r.count;){const p=performance.now(),S=e.runSlice(a,"replace",g=>{for(let y=0;f<r.count&&!(y%1024===1023&&performance.now()-p>P);f++,y++){if(r.sheets[f]!==l)continue;const L=r.rows[f],k=r.cols[f];if(a.protection&&e.styles.get(a.style(L,k)).unlocked!==!0){c.locked++;continue}nt(e,g,L,k,h,s,c)&&x++}});if(S!==null&&w.push(S),i.onProgress?.(),f<r.count&&await F(),i.cancelled)return e.rollbackSlices([...m,...w]),{count:0,sheets:0,cancelled:!0}}m.push(...w),x>0&&(u+=x,d++)}return e.pushFolded(m,"replace",e.sheet),{count:u,sheets:d,...c}}function st(e,t){if(!e.engine)return!0;try{return e.engine.validate(t),!0}catch{return!1}}export{tt as FoundList,et as findAll,it as findNext,v as makeMatcher,G as makeReplacer,Y as makeTest,ot as replaceAll,nt as replaceInCell};
package/cells/find.js ADDED
@@ -0,0 +1 @@
1
+ import{overlayRoot as S}from"../api/overlay.js";import{el as l,openFormatCells as T}from"../ui/dialogs.js";import{cellRef as _,MAX_COLS as L,MAX_ROWS as B}from"../core/address.js";import{KIND_MASK as E}from"../core/sheet.js";import{formatCount as g}from"../core/numfmt.js";import{findAll as $,findNext as b,makeReplacer as W,makeTest as O,replaceAll as N,replaceInCell as H}from"./find-engine.js";import{ensureBookCss as D}from"./book-css.js";import{svgNode as P}from"./format-tabs.js";import{t as a,tc as F}from"../i18n/index.js";const m=20,j=["fontName","fontSize","bold","italic","underline","strike","color","fill","pattern","borders","numFmt","hAlign","vAlign","wrap","indent","rotation","shrink","unlocked","hiddenFormula"];let p=null,v=null;const w=[];function R(c){const t=l("span",{class:"bk-fmt-chip",textContent:c?a("Preview*"):a("No Format Set")});return y(t,c),t}function y(c,t){c.textContent=t?a("Preview*"):a("No Format Set"),c.style.background=t?.fill??"",c.style.color=t?.color??"",c.style.fontWeight=t?.bold?"700":"",c.style.fontStyle=t?.italic?"italic":"",c.style.textDecoration=t?.underline?"underline":""}function I(c){const t={};for(const e of j)c[e]!==void 0&&c[e]!==null&&c[e]!==!1&&c[e]!==0&&c[e]!=="General"&&(t[e]=c[e]);return t}class V{constructor(t){this.app=t,this.findFormat=null,this.replaceFormat=null,this.ctrl=null,this.results=null,this.order=null,this.activeRow=-1,this.sort={key:null,dir:1},this._build()}_build(){D();const t=(i,d)=>{const u=l("select",{class:"dlg-input","aria-label":a(i)});for(const[f,k]of d)u.append(l("option",{value:k,textContent:a(f)}));return u},e=(i,d,u=!1)=>l("button",{class:`dlg-btn${u?" primary":""}`,type:"button",textContent:a(i),on:{click:d}}),s=l("button",{type:"button",class:"bk-find-history",title:a("Recent searches"),"aria-label":a("Recent searches"),on:{click:i=>this.app.ribbon.openMenu(i.currentTarget,{items:w.length?w.map(d=>[d,()=>{this.what.value=d,this.what.focus()},{raw:!0}]):[["No recent searches",()=>{}]]})}},P('<svg width="9" height="6" viewBox="0 0 9 6" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M1 1l3.5 3.5L8 1"/></svg>'));this.what=l("input",{class:"dlg-input","aria-label":a("Find what"),spellcheck:!1}),this.repl=l("input",{class:"dlg-input","aria-label":a("Replace with"),spellcheck:!1}),this.within=t("Within",[["Sheet","sheet"],["Workbook","workbook"]]),this.searchBy=t("Search",[["By Rows","rows"],["By Columns","cols"]]),this.look=t("Look in",[["Formulas","formulas"],["Values","values"],["Notes","notes"]]),this.matchCase=l("input",{type:"checkbox","aria-label":a("Match case")}),this.whole=l("input",{type:"checkbox","aria-label":a("Match entire cell contents")}),this.status=l("div",{class:"dlg-status",role:"status"}),this.progress=l("div",{class:"bk-progress",hidden:!0},l("div")),this.findChip=R(null),this.replaceChip=R(null);const o=i=>e("Format…",d=>this._formatMenu(i,d.currentTarget)),r=(...i)=>l("span",{class:"dlg-row bk-find-fmt",hidden:!0},...i);this.fmtFind=r(this.findChip,o("find")),this.fmtReplace=r(this.replaceChip,o("replace")),this.replaceRow=[l("span",{textContent:a("Replace with:")}),l("div",{class:"dlg-row"},this.repl,this.fmtReplace)],this.modeFind=l("button",{type:"button",role:"tab",class:"dlg-tab",textContent:a("Find"),on:{click:()=>this.setMode(!1)}}),this.modeReplace=l("button",{type:"button",role:"tab",class:"dlg-tab",textContent:a("Replace"),on:{click:()=>this.setMode(!0)}}),this.opts=l("div",{class:"bk-find-opts",hidden:!0},l("span",{textContent:a("Within:")}),this.within,l("label",{class:"dlg-row dlg-check"},this.matchCase,` ${a("Match case")}`),l("span",{textContent:a("Search:")}),this.searchBy,l("label",{class:"dlg-row dlg-check"},this.whole,` ${a("Match entire cell contents")}`),l("span",{textContent:a("Look in:")}),this.look,l("span")),this.btnReplaceAll=e("Replace All",()=>this.doReplaceAll()),this.btnReplace=e("Replace",()=>this.doReplace()),this.resultsHost=l("div",{class:"bk-results",hidden:!0});const n=l("h2",{class:"bk-panel-title",textContent:a("Find & Replace")});this.node=l("div",{class:"bk-panel xl-dlg",role:"dialog","aria-label":a("Find & Replace")},n,l("div",{class:"xl-tabbed"},l("div",{class:"dlg-tabs",role:"tablist"},this.modeFind,this.modeReplace),l("div",{class:"xl-box bk-find-box"},l("div",{class:"bk-find-grid"},l("span",{textContent:a("Find what:")}),l("div",{class:"dlg-row"},l("span",{class:"bk-find-field"},this.what,s),this.fmtFind),...this.replaceRow),this.opts,this.progress,this.resultsHost,l("div",{class:"bk-find-low"},this.status,e("Options",()=>this.toggleOptions())))),l("div",{class:"bk-find-foot"},this.btnReplaceAll,this.btnReplace,e("Find All",()=>this.doFindAll()),e(F("find","Previous"),()=>this.doFind(-1)),e(F("find","Next"),()=>this.doFind(1),!0),e("Close",()=>this.close()))),this.node.addEventListener("keydown",i=>{i.stopPropagation(),i.key==="Escape"?(i.preventDefault(),this.ctrl?this.cancel():this.close()):i.key==="Enter"&&i.target.tagName!=="BUTTON"&&(i.preventDefault(),this.doFind(i.shiftKey?-1:1))}),n.addEventListener("pointerdown",i=>{i.preventDefault(),n.setPointerCapture(i.pointerId);const d=this.node.getBoundingClientRect(),u=i.clientX-d.left,f=i.clientY-d.top,k=x=>{this.node.style.left=`${Math.max(0,Math.min(window.innerWidth-80,x.clientX-u))}px`,this.node.style.top=`${Math.max(0,Math.min(window.innerHeight-40,x.clientY-f))}px`},C=()=>{n.removeEventListener("pointermove",k),n.removeEventListener("pointerup",C)};n.addEventListener("pointermove",k),n.addEventListener("pointerup",C)}),this.node.style.right="24px",this.node.style.top="120px",S().append(this.node);const h=this.node.getBoundingClientRect();this.node.style.left=`${h.left}px`,this.node.style.right="auto"}toggleOptions(){const t=this.opts.hidden||!!(this.findFormat||this.replaceFormat);this.opts.hidden=!t,this.fmtFind.hidden=!t,this.fmtReplace.hidden=!t}setMode(t){this.withReplace=t,this.modeFind.setAttribute("aria-selected",String(!t)),this.modeReplace.setAttribute("aria-selected",String(t));for(const e of this.replaceRow)e.hidden=!t;this.btnReplaceAll.hidden=!t,this.btnReplace.hidden=!t,t&&(this.look.value="formulas"),this.look.querySelector('option[value="values"]').disabled=t,this.look.querySelector('option[value="notes"]').disabled=t}focus(){this.what.focus(),this.what.select()}close(){this.cancel(),(this.what.value!==""||this.findFormat)&&(v=this._options(!1)),this.node.remove(),p=null,this.app.controller.pickCell=null,this.app.controller.focusGrid()}cancel(){this.ctrl&&(this.ctrl.cancelled=!0)}_formatMenu(t,e){const{app:s}=this,o=r=>{t==="find"?(this.findFormat=r,y(this.findChip,r)):(this.replaceFormat=r,y(this.replaceChip,r))};s.ribbon.openMenu(e,{items:[["Format…",()=>T(s,"Number",{onPick:r=>o(Object.keys(r).length?r:null)})],["Choose Format from Cell…",()=>{this.status.textContent=a("Click the cell whose format you want."),s.controller.pickCell=(r,n)=>{const{book:h}=s;o(I(h.styles.get(h.sheet.style(r,n)))),this.status.textContent=""}}],["Clear Format",()=>o(null)]]})}_options(t=!0){const{app:e}=this,s=e.grid.selection,o=s.ranges.length===1&&s.ranges[0].r0===s.ranges[0].r1&&s.ranges[0].c0===s.ranges[0].c1,r=e.book.sheet.mergeAt(s.row,s.col),n=o||r&&s.ranges.length===1;return{what:this.what.value,matchCase:this.matchCase.checked,whole:this.whole.checked,look:this.look.value,format:this.findFormat,byColumns:this.searchBy.value==="cols",within:this.within.value,ranges:t&&!n?s.ranges:null}}_display(){const{grid:t}=this.app;return(e,s,o)=>t.displayText(e,s,o)}_ready(t){if(t.what===""&&t.format===null)return this.status.textContent=a("Enter what to find, or choose a format."),this.what.focus(),!1;if(t.what!==""){const e=w.indexOf(t.what);e>=0&&w.splice(e,1),w.unshift(t.what),w.length=Math.min(w.length,12)}return!0}_begin(){this.cancel();const t={cancelled:!1};this.ctrl=t;const e=this.progress,s=performance.now();return t.onProgress=()=>{if(performance.now()-s>150){e.hidden=!1;const o=e.firstChild;o.style.width=`${((performance.now()-s)/40%100).toFixed(0)}%`,this.status.textContent=a("Searching… Press Esc to stop.")}},t}_end(t){this.ctrl===t&&(this.ctrl=null),this.progress.hidden=!0}_jump(t){const{app:e}=this,{book:s}=e;t.sheet!==s.sheet&&(s.selectedSheets&&!s.selectedSheets.has(t.sheet)&&(s.selectedSheets=null),e.switchSheet(s.sheets.indexOf(t.sheet)));const o=e.grid.selection;o.ranges.some(n=>(n.r0!==n.r1||n.c0!==n.c1)&&t.row>=n.r0&&t.row<=n.r1&&t.col>=n.c0&&t.col<=n.c1)?(e.grid.setSelection({ranges:o.ranges,row:t.row,col:t.col}),e.grid.ensureVisible(t.row,t.col)):e.controller.moveTo(t.row,t.col)}async doFind(t){const e=this._options();if(!this._ready(e))return null;const s=this._begin(),o=performance.now(),r=this.app.grid.selection,n=await b(this.app.book,e,{row:r.row,col:r.col},t,this._display(),s);return this._end(s),s.cancelled?(this.status.textContent=a("Stopped."),null):(this.lastMs=performance.now()-o,n?(this._jump(n),this.status.textContent=`${n.sheet===this.app.book.sheet?"":`${n.sheet.name}!`}${_(n.row,n.col)}`,n):(this.status.textContent=a("We couldn't find what you were looking for."),null))}async doFindAll(){const t=this._options();if(!this._ready(t))return;const e=this._begin(),s=performance.now(),o=await $(this.app.book,t,this._display(),e);if(this._end(e),e.cancelled){this.status.textContent=a("Stopped.");return}this.lastMs=performance.now()-s,this.results=o,this.order=new Uint32Array(o.count);for(let n=0;n<o.count;n++)this.order[n]=n;this.sort={key:null,dir:1},this.activeRow=-1;const r=g(o.count);this.status.textContent=o.overflow?a("The first {shown} cells found. There are more.",{shown:r}):a("{shown} cells found.",{count:o.count,shown:r}),this._renderResults()}_cellValue(t){const{book:e,grid:s}=this.app,{results:o}=this,r=o.sheetList[o.sheets[t]],n=o.rows[t],h=o.cols[t];if(this.look.value==="notes")return r.comments?.get(n*L+h)?.text??"";const i=r.kind(n,h)&E;return s.displayText(i,r.value(n,h),e.styles.get(r.style(n,h))).replace(/\u0001.?\u0001/g," ")}_cellFormula(t){const{book:e}=this.app,{results:s}=this,o=e.editText(s.sheetList[s.sheets[t]],s.rows[t],s.cols[t]);return o[0]==="="||o.startsWith("{=")?o:""}_sortBy(t){const{results:e}=this;if(!e)return;const s=this.sort.key===t?-this.sort.dir:1;this.sort={key:t,dir:s};const o={sheet:i=>e.sheetList[e.sheets[i]].name,cell:i=>e.cols[i]*B+e.rows[i],value:i=>this._cellValue(i),formula:i=>this._cellFormula(i)}[t],r=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}),n=new Array(e.count);for(let i=0;i<e.count;i++)n[i]=o(i);const h=Array.from(this.order);h.sort((i,d)=>s*(typeof n[i]=="number"?n[i]-n[d]:r.compare(n[i],n[d]))),this.order=Uint32Array.from(h),this._renderResults()}_renderResults(){const{results:t}=this,e=(h,i)=>l("button",{type:"button",textContent:`${a(h)}${this.sort.key===i?this.sort.dir>0?" ▴":" ▾":""}`,on:{click:()=>this._sortBy(i)}}),s=l("div",{class:"bk-results-body",tabIndex:0}),o=l("div",{style:`height:${t.count*m}px`}),r=l("div");s.append(o,r);const n=()=>{const h=Math.floor(s.scrollTop/m),i=Math.min(t.count,h+Math.ceil(s.clientHeight/m)+2),d=[];for(let u=h;u<i;u++){const f=this.order[u],k=l("div",{class:`bk-results-row${u===this.activeRow?" active":""}`,style:`top:${u*m}px`,on:{click:()=>this._pick(u)}},l("span",{textContent:t.sheetList[t.sheets[f]].name}),l("span",{textContent:_(t.rows[f],t.cols[f])}),l("span",{textContent:this._cellValue(f)}),l("span",{textContent:this._cellFormula(f)}));d.push(k)}r.replaceChildren(...d)};this.drawResults=n,s.addEventListener("scroll",n,{passive:!0}),s.addEventListener("keydown",h=>{h.key!=="ArrowDown"&&h.key!=="ArrowUp"||(h.preventDefault(),this._pick(Math.max(0,Math.min(t.count-1,this.activeRow+(h.key==="ArrowDown"?1:-1)))))}),this.resultsHost.replaceChildren(l("div",{class:"bk-results-head"},e("Sheet","sheet"),e("Cell","cell"),e("Value","value"),e("Formula","formula")),s),this.resultsHost.hidden=t.count===0,n(),this.resultsBody=s}_pick(t){const{results:e}=this,s=this.order[t];this.activeRow=t,this._jump({sheet:e.sheetList[e.sheets[s]],row:e.rows[s],col:e.cols[s]});const o=this.resultsBody;t*m<o.scrollTop?o.scrollTop=t*m:(t+1)*m>o.scrollTop+o.clientHeight&&(o.scrollTop=(t+1)*m-o.clientHeight),this.drawResults()}async doReplace(){const t=this._options(!1);if(!this._ready(t))return;const{app:e}=this,{book:s}=e,{sheet:o}=s,{row:r,col:n}=e.grid.selection;if(await b(s,{...t,within:"sheet",look:"formulas"},{row:r,col:n},1,this._display(),{})!==null&&this._matchesHere(t,r,n))if(o.protection&&s.styles.get(o.style(r,n)).unlocked!==!0)this.status.textContent=a("This cell is locked.");else{const d=t.what===""?null:W(t.what,this.repl.value,t),u={invalid:0};if(s.transact("replace",f=>{H(s,f,r,n,d,this.replaceFormat,u)}),e.grid.invalidate(),u.invalid>0){this.status.textContent=a("There's a problem with this formula after the replacement, so the cell was left as it was.");return}}await this.doFind(1)}_matchesHere(t,e,s){const{book:o}=this.app,{sheet:r}=o;return O(o,{...t,look:"formulas"},this._display())(r,e,s,r.kind(e,s),r.value(e,s))}async doReplaceAll(){const t=this._options();if(!this._ready(t))return;const e=this._begin(),s=performance.now(),o=await N(this.app.book,t,this.repl.value,this.replaceFormat,this._display(),e);if(this._end(e),this.lastMs=performance.now()-s,o.cancelled){this.status.textContent=a("Stopped; nothing was replaced.");return}const r={count:o.count,shown:g(o.count),sheets:o.sheets},n=[o.count===0&&o.locked===0&&o.invalid===0?a("We couldn't find anything to replace."):o.sheets>1?a("All done. We made {shown} replacements on {sheets} sheets.",r):a("All done. We made {shown} replacements.",r)];o.locked>0&&n.push(a("{shown} locked cells on protected sheets were left as they were.",{count:o.locked,shown:g(o.locked)})),o.invalid>0&&n.push(a("{shown} cells were left as they were, as the replacement would break their formulas.",{count:o.invalid,shown:g(o.invalid)})),this.status.textContent=n.join(" "),this.app.grid.invalidate(),this.app.afterCommand(),this.what.focus()}}function tt(c,t){if(!p&&v){const e=c.grid.selection;return b(c.book,v,{row:e.row,col:e.col},t,(s,o,r)=>c.grid.displayText(s,o,r),{}).then(s=>s?(s.sheet&&s.sheet!==c.book.sheet&&c.switchSheet(c.book.sheets.indexOf(s.sheet)),c.controller.moveTo(s.row,s.col),s):(c.shell?.setStatus(a("We couldn't find what you were looking for.")),null))}return p?(M(c),p.doFind(t)):(U(c),null)}const A=new WeakSet;function M(c){p.app=c,!A.has(c)&&(A.add(c),c.signal?.addEventListener("abort",()=>{p?.app===c&&(p.cancel(),p.node.remove(),p=null)},{once:!0}))}function U(c,t=!1){p??=new V(c),M(c),p.setMode(t),p.focus();const e=p;return setTimeout(()=>{p===e&&document.activeElement!==e.what&&!e.node.contains(document.activeElement)&&e.focus()},0),p}export{tt as findAgain,U as openFind};
@@ -0,0 +1 @@
1
+ function s(i){const o=[];let n="",r=!1;for(let t=0;t<i.length;t++){const e=i[t];if(e==='"'&&(r=!r),e==="\\"||e==="_"||e==="*"){n+=e+(i[t+1]??""),t++;continue}e===";"&&!r?(o.push(n),n=""):n+=e}if(o.push(n),r)return"A quotation mark in this format isn’t closed.";if(o.length>4)return"A number format can have at most four sections.";const l=o.map(t=>t.replace(/"[^"]*"|\\.|_.|\*./g,"").includes("@"));for(let t=0;t<l.length-1;t++)if(l[t])return"The text placeholder @ can only be in the last section.";return null}export{s as formatCodeProblem};