@dxos/plugin-sheet 0.7.4 → 0.7.5-main.937ce75

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 (188) hide show
  1. package/dist/lib/browser/{SheetContainer-KCLT6PEO.mjs → SheetContainer-S4NCLUYL.mjs} +16 -22
  2. package/dist/lib/browser/SheetContainer-S4NCLUYL.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-E5WQ7U7G.mjs → chunk-A374JPWV.mjs} +72 -705
  4. package/dist/lib/browser/chunk-A374JPWV.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-Q4XS4YWF.mjs +900 -0
  6. package/dist/lib/browser/chunk-Q4XS4YWF.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +74 -180
  8. package/dist/lib/browser/index.mjs.map +3 -3
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/types/index.mjs +62 -0
  11. package/dist/lib/node/{SheetContainer-VVVRYTQG.cjs → SheetContainer-TP4GYXZB.cjs} +41 -43
  12. package/dist/lib/node/SheetContainer-TP4GYXZB.cjs.map +7 -0
  13. package/dist/lib/node/{chunk-45YW2DX2.cjs → chunk-FDEQ2PGJ.cjs} +115 -726
  14. package/dist/lib/node/chunk-FDEQ2PGJ.cjs.map +7 -0
  15. package/dist/lib/node/chunk-TQOJ7DG2.cjs +935 -0
  16. package/dist/lib/node/chunk-TQOJ7DG2.cjs.map +7 -0
  17. package/dist/lib/node/index.cjs +104 -207
  18. package/dist/lib/node/index.cjs.map +3 -3
  19. package/dist/lib/node/meta.json +1 -1
  20. package/dist/lib/node/types/index.cjs +84 -0
  21. package/dist/lib/node/types/index.cjs.map +7 -0
  22. package/dist/lib/node-esm/{SheetContainer-LSBE6Q4X.mjs → SheetContainer-YB3JBVPZ.mjs} +16 -22
  23. package/dist/lib/node-esm/SheetContainer-YB3JBVPZ.mjs.map +7 -0
  24. package/dist/lib/node-esm/{chunk-NYDNXI7L.mjs → chunk-L5PQHVTX.mjs} +72 -705
  25. package/dist/lib/node-esm/chunk-L5PQHVTX.mjs.map +7 -0
  26. package/dist/lib/node-esm/chunk-NYYIDVR7.mjs +901 -0
  27. package/dist/lib/node-esm/chunk-NYYIDVR7.mjs.map +7 -0
  28. package/dist/lib/node-esm/index.mjs +74 -180
  29. package/dist/lib/node-esm/index.mjs.map +3 -3
  30. package/dist/lib/node-esm/meta.json +1 -1
  31. package/dist/lib/node-esm/types/index.mjs +63 -0
  32. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  33. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
  34. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
  35. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -0
  36. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -1
  37. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  38. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
  39. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  40. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
  41. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  42. package/dist/types/src/components/SheetContext/SheetContext.d.ts +1 -2
  43. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  44. package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -1
  45. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  46. package/dist/types/src/components/index.d.ts +1 -1
  47. package/dist/types/src/extensions/compute.d.ts +1 -1
  48. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  49. package/dist/types/src/extensions/editor/extension.d.ts +1 -1
  50. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
  51. package/dist/types/src/index.d.ts +1 -1
  52. package/dist/types/src/index.d.ts.map +1 -1
  53. package/dist/types/src/integrations/thread-ranges.d.ts +1 -1
  54. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  55. package/dist/types/src/model/sheet-model.d.ts +6 -8
  56. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  57. package/dist/types/src/model/testing.d.ts +1 -1
  58. package/dist/types/src/model/testing.d.ts.map +1 -1
  59. package/dist/types/src/model/useSheetModel.d.ts +1 -1
  60. package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
  61. package/dist/types/src/testing/testing.d.ts +2 -2
  62. package/dist/types/src/testing/testing.d.ts.map +1 -1
  63. package/dist/types/src/{defs → types}/index.d.ts +1 -0
  64. package/dist/types/src/types/index.d.ts.map +1 -0
  65. package/dist/types/src/types/schema.d.ts +105 -0
  66. package/dist/types/src/types/schema.d.ts.map +1 -0
  67. package/dist/types/src/types/sheet-range-types.d.ts.map +1 -0
  68. package/dist/types/src/types/types.d.ts +82 -0
  69. package/dist/types/src/types/types.d.ts.map +1 -0
  70. package/dist/types/src/{defs → types}/util.d.ts +5 -1
  71. package/dist/types/src/types/util.d.ts.map +1 -0
  72. package/dist/types/tsconfig.tsbuildinfo +1 -0
  73. package/package.json +46 -53
  74. package/src/SheetPlugin.tsx +44 -115
  75. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -2
  76. package/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.tsx +6 -7
  77. package/src/components/FunctionEditor/FunctionEditor.tsx +2 -1
  78. package/src/components/GridSheet/GridSheet.tsx +15 -18
  79. package/src/components/GridSheet/SheetCellEditor.stories.tsx +6 -7
  80. package/src/components/GridSheet/util.ts +3 -2
  81. package/src/components/RangeList/RangeList.tsx +2 -1
  82. package/src/components/SheetContainer/SheetContainer.stories.tsx +11 -12
  83. package/src/components/SheetContext/SheetContext.tsx +1 -2
  84. package/src/components/Toolbar/Toolbar.tsx +18 -20
  85. package/src/extensions/compute.ts +7 -4
  86. package/src/extensions/editor/extension.test.ts +2 -1
  87. package/src/extensions/editor/extension.ts +2 -3
  88. package/src/index.ts +1 -3
  89. package/src/integrations/thread-ranges.ts +28 -24
  90. package/src/model/sheet-model.test.ts +4 -10
  91. package/src/model/sheet-model.ts +30 -22
  92. package/src/model/testing.ts +3 -2
  93. package/src/model/useSheetModel.ts +2 -1
  94. package/src/sanity.test.ts +1 -1
  95. package/src/testing/testing.tsx +2 -3
  96. package/src/{defs → types}/index.ts +1 -0
  97. package/src/types/schema.ts +56 -0
  98. package/src/types/types.ts +93 -0
  99. package/src/{defs → types}/util.ts +13 -13
  100. package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs.map +0 -7
  101. package/dist/lib/browser/chunk-E5WQ7U7G.mjs.map +0 -7
  102. package/dist/lib/browser/chunk-F3HE6D3J.mjs +0 -3269
  103. package/dist/lib/browser/chunk-F3HE6D3J.mjs.map +0 -7
  104. package/dist/lib/browser/chunk-JXFPOYNA.mjs +0 -67
  105. package/dist/lib/browser/chunk-JXFPOYNA.mjs.map +0 -7
  106. package/dist/lib/browser/compute-graph-SNUS7HOH.mjs +0 -35
  107. package/dist/lib/browser/types.mjs +0 -16
  108. package/dist/lib/node/SheetContainer-VVVRYTQG.cjs.map +0 -7
  109. package/dist/lib/node/chunk-45YW2DX2.cjs.map +0 -7
  110. package/dist/lib/node/chunk-KSEEI5VC.cjs +0 -3323
  111. package/dist/lib/node/chunk-KSEEI5VC.cjs.map +0 -7
  112. package/dist/lib/node/chunk-OWH2EUHZ.cjs +0 -90
  113. package/dist/lib/node/chunk-OWH2EUHZ.cjs.map +0 -7
  114. package/dist/lib/node/compute-graph-WILPHO4A.cjs +0 -57
  115. package/dist/lib/node/compute-graph-WILPHO4A.cjs.map +0 -7
  116. package/dist/lib/node/types.cjs +0 -38
  117. package/dist/lib/node/types.cjs.map +0 -7
  118. package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs.map +0 -7
  119. package/dist/lib/node-esm/chunk-6JF2AHKO.mjs +0 -3270
  120. package/dist/lib/node-esm/chunk-6JF2AHKO.mjs.map +0 -7
  121. package/dist/lib/node-esm/chunk-BVS2IQRO.mjs +0 -68
  122. package/dist/lib/node-esm/chunk-BVS2IQRO.mjs.map +0 -7
  123. package/dist/lib/node-esm/chunk-NYDNXI7L.mjs.map +0 -7
  124. package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs +0 -36
  125. package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs.map +0 -7
  126. package/dist/lib/node-esm/types.mjs +0 -17
  127. package/dist/lib/node-esm/types.mjs.map +0 -7
  128. package/dist/types/src/compute-graph/compute-graph-registry.d.ts +0 -34
  129. package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +0 -1
  130. package/dist/types/src/compute-graph/compute-graph.d.ts +0 -64
  131. package/dist/types/src/compute-graph/compute-graph.d.ts.map +0 -1
  132. package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +0 -1
  133. package/dist/types/src/compute-graph/compute-graph.test.d.ts +0 -2
  134. package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +0 -1
  135. package/dist/types/src/compute-graph/compute-node.d.ts +0 -26
  136. package/dist/types/src/compute-graph/compute-node.d.ts.map +0 -1
  137. package/dist/types/src/compute-graph/functions/async-function.d.ts +0 -66
  138. package/dist/types/src/compute-graph/functions/async-function.d.ts.map +0 -1
  139. package/dist/types/src/compute-graph/functions/edge-function.d.ts +0 -21
  140. package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +0 -1
  141. package/dist/types/src/compute-graph/functions/function-defs.d.ts +0 -11
  142. package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +0 -1
  143. package/dist/types/src/compute-graph/functions/index.d.ts +0 -4
  144. package/dist/types/src/compute-graph/functions/index.d.ts.map +0 -1
  145. package/dist/types/src/compute-graph/hyperformula.test.d.ts +0 -2
  146. package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +0 -1
  147. package/dist/types/src/compute-graph/index.d.ts +0 -5
  148. package/dist/types/src/compute-graph/index.d.ts.map +0 -1
  149. package/dist/types/src/compute-graph/testing/index.d.ts +0 -3
  150. package/dist/types/src/compute-graph/testing/index.d.ts.map +0 -1
  151. package/dist/types/src/compute-graph/testing/test-builder.d.ts +0 -15
  152. package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +0 -1
  153. package/dist/types/src/compute-graph/testing/test-plugin.d.ts +0 -36
  154. package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +0 -1
  155. package/dist/types/src/compute-graph/util.d.ts +0 -2
  156. package/dist/types/src/compute-graph/util.d.ts.map +0 -1
  157. package/dist/types/src/defs/index.d.ts.map +0 -1
  158. package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
  159. package/dist/types/src/defs/types.d.ts +0 -26
  160. package/dist/types/src/defs/types.d.ts.map +0 -1
  161. package/dist/types/src/defs/types.test.d.ts +0 -2
  162. package/dist/types/src/defs/types.test.d.ts.map +0 -1
  163. package/dist/types/src/defs/util.d.ts.map +0 -1
  164. package/dist/types/src/types.d.ts +0 -182
  165. package/dist/types/src/types.d.ts.map +0 -1
  166. package/dist/vendor/hyperformula.mjs +0 -37145
  167. package/src/compute-graph/compute-graph-registry.ts +0 -90
  168. package/src/compute-graph/compute-graph.test.ts +0 -87
  169. package/src/compute-graph/compute-graph.ts +0 -260
  170. package/src/compute-graph/compute-node.ts +0 -62
  171. package/src/compute-graph/functions/async-function.ts +0 -179
  172. package/src/compute-graph/functions/edge-function.ts +0 -102
  173. package/src/compute-graph/functions/function-defs.ts +0 -2427
  174. package/src/compute-graph/functions/index.ts +0 -7
  175. package/src/compute-graph/hyperformula.test.ts +0 -14
  176. package/src/compute-graph/index.ts +0 -8
  177. package/src/compute-graph/testing/index.ts +0 -6
  178. package/src/compute-graph/testing/test-builder.ts +0 -54
  179. package/src/compute-graph/testing/test-plugin.ts +0 -100
  180. package/src/compute-graph/util.ts +0 -8
  181. package/src/defs/types.test.ts +0 -91
  182. package/src/defs/types.ts +0 -88
  183. package/src/types.ts +0 -125
  184. /package/dist/lib/browser/{compute-graph-SNUS7HOH.mjs.map → types/index.mjs.map} +0 -0
  185. /package/dist/lib/{browser/types.mjs.map → node-esm/types/index.mjs.map} +0 -0
  186. /package/dist/types/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.d.ts +0 -0
  187. /package/dist/types/src/{defs → types}/sheet-range-types.d.ts +0 -0
  188. /package/src/{defs → types}/sheet-range-types.ts +0 -0
@@ -0,0 +1,935 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var chunk_TQOJ7DG2_exports = {};
20
+ __export(chunk_TQOJ7DG2_exports, {
21
+ ApiError: () => ApiError,
22
+ CellValue: () => CellValue,
23
+ DEFAULT_COLS: () => DEFAULT_COLS,
24
+ DEFAULT_ROWS: () => DEFAULT_ROWS,
25
+ MAX_COLS: () => MAX_COLS,
26
+ MAX_ROWS: () => MAX_ROWS,
27
+ Range: () => Range,
28
+ RangeException: () => RangeException,
29
+ ReadonlyException: () => ReadonlyException,
30
+ RowColumnMeta: () => RowColumnMeta,
31
+ SheetAction: () => SheetAction,
32
+ SheetType: () => SheetType,
33
+ addressFromIndex: () => addressFromIndex,
34
+ addressToIndex: () => addressToIndex,
35
+ alignKey: () => alignKey,
36
+ cellClassNameForRange: () => cellClassNameForRange,
37
+ commentKey: () => commentKey,
38
+ compareIndexPositions: () => compareIndexPositions,
39
+ createIndex: () => createIndex,
40
+ createIndices: () => createIndices,
41
+ createSheet: () => createSheet,
42
+ initialize: () => initialize,
43
+ insertIndices: () => insertIndices,
44
+ mapFormulaIndicesToRefs: () => mapFormulaIndicesToRefs,
45
+ mapFormulaRefsToIndices: () => mapFormulaRefsToIndices,
46
+ rangeFromIndex: () => rangeFromIndex,
47
+ rangeToIndex: () => rangeToIndex,
48
+ styleKey: () => styleKey,
49
+ useSheetModel: () => useSheetModel
50
+ });
51
+ module.exports = __toCommonJS(chunk_TQOJ7DG2_exports);
52
+ var import_chunk_2ZVZI2KJ = require("./chunk-2ZVZI2KJ.cjs");
53
+ var import_echo_schema = require("@dxos/echo-schema");
54
+ var import_types = require("@dxos/plugin-space/types");
55
+ var import_echo_schema2 = require("@dxos/echo-schema");
56
+ var import_async = require("@dxos/async");
57
+ var import_compute = require("@dxos/compute");
58
+ var import_context = require("@dxos/context");
59
+ var import_echo_schema3 = require("@dxos/echo-schema");
60
+ var import_invariant = require("@dxos/invariant");
61
+ var import_keys = require("@dxos/keys");
62
+ var import_log = require("@dxos/log");
63
+ var import_react = require("react");
64
+ var import_compute2 = require("@dxos/compute");
65
+ var import_crypto = require("@dxos/crypto");
66
+ var import_invariant2 = require("@dxos/invariant");
67
+ var import_live_object = require("@dxos/live-object");
68
+ var CellValue = import_echo_schema.S.Struct({
69
+ // TODO(burdon): How to store dates (datetime, date, time), percentages, etc.
70
+ // Consider import/export; natural access for other plugins. Special handling for currency (precision).
71
+ // TODO(burdon): Automerge (long string) or short string or number.
72
+ value: import_echo_schema.S.Any
73
+ });
74
+ var Range = import_echo_schema.S.Struct({
75
+ range: import_echo_schema.S.String,
76
+ key: import_echo_schema.S.String,
77
+ value: import_echo_schema.S.String
78
+ });
79
+ var RowColumnMeta = import_echo_schema.S.Struct({
80
+ size: import_echo_schema.S.optional(import_echo_schema.S.Number)
81
+ });
82
+ var SheetType = class extends (0, import_echo_schema.TypedObject)({
83
+ typename: "dxos.org/type/Sheet",
84
+ version: "0.1.0"
85
+ })({
86
+ name: import_echo_schema.S.optional(import_echo_schema.S.String),
87
+ // Sparse map of cells referenced by index.
88
+ cells: import_echo_schema.S.mutable(import_echo_schema.S.Record({
89
+ key: import_echo_schema.S.String,
90
+ value: import_echo_schema.S.mutable(CellValue)
91
+ })),
92
+ // Ordered row indices.
93
+ rows: import_echo_schema.S.mutable(import_echo_schema.S.Array(import_echo_schema.S.String)),
94
+ // Ordered column indices.
95
+ columns: import_echo_schema.S.mutable(import_echo_schema.S.Array(import_echo_schema.S.String)),
96
+ // Row metadata referenced by index.
97
+ rowMeta: import_echo_schema.S.mutable(import_echo_schema.S.Record({
98
+ key: import_echo_schema.S.String,
99
+ value: import_echo_schema.S.mutable(RowColumnMeta)
100
+ })),
101
+ // Column metadata referenced by index.
102
+ columnMeta: import_echo_schema.S.mutable(import_echo_schema.S.Record({
103
+ key: import_echo_schema.S.String,
104
+ value: import_echo_schema.S.mutable(RowColumnMeta)
105
+ })),
106
+ // Cell formatting referenced by indexed range.
107
+ ranges: import_echo_schema.S.mutable(import_echo_schema.S.Array(Range)),
108
+ // Threads associated with the sheet
109
+ threads: import_echo_schema.S.optional(import_echo_schema.S.mutable(import_echo_schema.S.Array((0, import_echo_schema.Ref)(import_types.ThreadType))))
110
+ }) {
111
+ };
112
+ var alignKey = "alignment";
113
+ var commentKey = "comment";
114
+ var styleKey = "style";
115
+ var cellClassNameForRange = ({ key, value }) => {
116
+ switch (key) {
117
+ case alignKey:
118
+ switch (value) {
119
+ case "start":
120
+ return "text-start";
121
+ case "center":
122
+ return "text-center";
123
+ case "end":
124
+ return "text-end";
125
+ default:
126
+ return void 0;
127
+ }
128
+ case commentKey:
129
+ return "bg-gridComment";
130
+ case styleKey:
131
+ switch (value) {
132
+ case "highlight":
133
+ return "!bg-gridHighlight";
134
+ case "softwrap":
135
+ return "!whitespace-normal";
136
+ default:
137
+ return void 0;
138
+ }
139
+ default:
140
+ return void 0;
141
+ }
142
+ };
143
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
144
+ var typeMap = {
145
+ BOOLEAN: {
146
+ type: import_echo_schema3.TypeEnum.Boolean
147
+ },
148
+ NUMBER_RAW: {
149
+ type: import_echo_schema3.TypeEnum.Number
150
+ },
151
+ NUMBER_PERCENT: {
152
+ type: import_echo_schema3.TypeEnum.Number,
153
+ format: import_echo_schema3.FormatEnum.Percent
154
+ },
155
+ NUMBER_CURRENCY: {
156
+ type: import_echo_schema3.TypeEnum.Number,
157
+ format: import_echo_schema3.FormatEnum.Currency
158
+ },
159
+ NUMBER_DATETIME: {
160
+ type: import_echo_schema3.TypeEnum.String,
161
+ format: import_echo_schema3.FormatEnum.DateTime
162
+ },
163
+ NUMBER_DATE: {
164
+ type: import_echo_schema3.TypeEnum.String,
165
+ format: import_echo_schema3.FormatEnum.Date
166
+ },
167
+ NUMBER_TIME: {
168
+ type: import_echo_schema3.TypeEnum.String,
169
+ format: import_echo_schema3.FormatEnum.Time
170
+ }
171
+ };
172
+ var getTopLeft = (range) => {
173
+ const to = range.to ?? range.from;
174
+ return {
175
+ row: Math.min(range.from.row, to.row),
176
+ col: Math.min(range.from.col, to.col)
177
+ };
178
+ };
179
+ var toSimpleCellAddress = (sheet, cell) => ({
180
+ sheet,
181
+ row: cell.row,
182
+ col: cell.col
183
+ });
184
+ var toModelRange = (sheet, range) => ({
185
+ start: toSimpleCellAddress(sheet, range.from),
186
+ end: toSimpleCellAddress(sheet, range.to ?? range.from)
187
+ });
188
+ var SheetModel = class extends import_context.Resource {
189
+ constructor(_graph, _sheet, _options = {}) {
190
+ super();
191
+ this._graph = _graph;
192
+ this._sheet = _sheet;
193
+ this._options = _options;
194
+ this.id = `model-${import_keys.PublicKey.random().truncate()}`;
195
+ this.update = new import_async.Event();
196
+ }
197
+ get graph() {
198
+ return this._graph;
199
+ }
200
+ get sheet() {
201
+ return this._sheet;
202
+ }
203
+ get readonly() {
204
+ return this._options.readonly;
205
+ }
206
+ get bounds() {
207
+ return {
208
+ rows: this._sheet.rows.length,
209
+ columns: this._sheet.columns.length
210
+ };
211
+ }
212
+ /**
213
+ * Initialize sheet and engine.
214
+ */
215
+ async _open() {
216
+ (0, import_log.log)("initialize", {
217
+ id: this.id
218
+ }, {
219
+ F: __dxlog_file,
220
+ L: 123,
221
+ S: this,
222
+ C: (f, a) => f(...a)
223
+ });
224
+ initialize(this._sheet);
225
+ this._graph.update.on((event) => {
226
+ if (event.type === "functionsUpdated") {
227
+ this.reset();
228
+ }
229
+ });
230
+ this._node = this._graph.getOrCreateNode((0, import_compute.createSheetName)({
231
+ type: (0, import_echo_schema3.getTypename)(this._sheet),
232
+ id: this._sheet.id
233
+ }));
234
+ await this._node.open();
235
+ const unsubscribe = this._node.update.on((event) => this.update.emit(event));
236
+ this._ctx.onDispose(unsubscribe);
237
+ this.reset();
238
+ }
239
+ /**
240
+ * Update engine.
241
+ * NOTE: This resets the undo history.
242
+ * @deprecated
243
+ */
244
+ reset() {
245
+ (0, import_invariant.invariant)(this._node, void 0, {
246
+ F: __dxlog_file,
247
+ L: 149,
248
+ S: this,
249
+ A: [
250
+ "this._node",
251
+ ""
252
+ ]
253
+ });
254
+ this._node.graph.hf.clearSheet(this._node.sheetId);
255
+ Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
256
+ (0, import_invariant.invariant)(this._node, void 0, {
257
+ F: __dxlog_file,
258
+ L: 152,
259
+ S: this,
260
+ A: [
261
+ "this._node",
262
+ ""
263
+ ]
264
+ });
265
+ const { col, row } = addressFromIndex(this._sheet, key);
266
+ if ((0, import_compute.isFormula)(value)) {
267
+ const binding = this._graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs(this._sheet, value));
268
+ if (binding) {
269
+ value = this._graph.mapFormulaToNative(binding);
270
+ } else {
271
+ value = "";
272
+ }
273
+ }
274
+ this._node.graph.hf.setCellContents({
275
+ sheet: this._node.sheetId,
276
+ row,
277
+ col
278
+ }, value);
279
+ });
280
+ }
281
+ /**
282
+ * Recalculate formulas.
283
+ * NOTE: This resets the undo history.
284
+ * https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
285
+ * @deprecated
286
+ */
287
+ // TODO(burdon): Remove.
288
+ recalculate() {
289
+ this._node?.graph.hf.rebuildAndRecalculate();
290
+ }
291
+ insertRows(i, n = 1) {
292
+ const idx = insertIndices(this._sheet.rows, i, n, MAX_ROWS);
293
+ this.reset();
294
+ return idx;
295
+ }
296
+ insertColumns(i, n = 1) {
297
+ const idx = insertIndices(this._sheet.columns, i, n, MAX_COLS);
298
+ this.reset();
299
+ return idx;
300
+ }
301
+ dropRow(rowIndex) {
302
+ const range = {
303
+ from: addressFromIndex(this._sheet, `${this._sheet.columns[0]}@${rowIndex}`),
304
+ to: addressFromIndex(this._sheet, `${this._sheet.columns[this._sheet.columns.length - 1]}@${rowIndex}`)
305
+ };
306
+ const values = this.getCellValues(range).flat();
307
+ const index = this._sheet.rows.indexOf(rowIndex);
308
+ this.clear(range);
309
+ this._sheet.rows.splice(index, 1);
310
+ delete this._sheet.rowMeta[rowIndex];
311
+ this.reset();
312
+ return {
313
+ axis: "row",
314
+ index,
315
+ axisIndex: rowIndex,
316
+ axisMeta: this._sheet.rowMeta[rowIndex],
317
+ values
318
+ };
319
+ }
320
+ dropColumn(colIndex) {
321
+ const range = {
322
+ from: addressFromIndex(this._sheet, `${colIndex}@${this._sheet.rows[0]}`),
323
+ to: addressFromIndex(this._sheet, `${colIndex}@${this._sheet.rows[this._sheet.rows.length - 1]}`)
324
+ };
325
+ const values = this.getCellValues(range).flat();
326
+ const index = this._sheet.columns.indexOf(colIndex);
327
+ this.clear(range);
328
+ this._sheet.columns.splice(index, 1);
329
+ delete this._sheet.columnMeta[colIndex];
330
+ this.reset();
331
+ return {
332
+ axis: "col",
333
+ index,
334
+ axisIndex: colIndex,
335
+ axisMeta: this._sheet.rowMeta[colIndex],
336
+ values
337
+ };
338
+ }
339
+ restoreRow({ index, axisIndex, axisMeta, values }) {
340
+ this._sheet.rows.splice(index, 0, axisIndex);
341
+ values.forEach((value, col) => {
342
+ if (value) {
343
+ this._sheet.cells[`${this._sheet.columns[col]}@${axisIndex}`] = {
344
+ value
345
+ };
346
+ }
347
+ });
348
+ if (axisMeta) {
349
+ this._sheet.rowMeta[axisIndex] = axisMeta;
350
+ }
351
+ this.reset();
352
+ }
353
+ restoreColumn({ index, axisIndex, axisMeta, values }) {
354
+ this._sheet.columns.splice(index, 0, axisIndex);
355
+ values.forEach((value, row) => {
356
+ if (value) {
357
+ this._sheet.cells[`${axisIndex}@${this._sheet.rows[row]}`] = {
358
+ value
359
+ };
360
+ }
361
+ });
362
+ if (axisMeta) {
363
+ this._sheet.columnMeta[axisIndex] = axisMeta;
364
+ }
365
+ this.reset();
366
+ }
367
+ //
368
+ // Undoable actions.
369
+ // TODO(burdon): Group undoable methods; consistently update hf/sheet.
370
+ //
371
+ /**
372
+ * Clear range of values.
373
+ */
374
+ clear(range) {
375
+ (0, import_invariant.invariant)(this._node, void 0, {
376
+ F: __dxlog_file,
377
+ L: 255,
378
+ S: this,
379
+ A: [
380
+ "this._node",
381
+ ""
382
+ ]
383
+ });
384
+ const topLeft = getTopLeft(range);
385
+ const values = this._iterRange(range, () => null);
386
+ this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
387
+ this._iterRange(range, (cell) => {
388
+ const idx = addressToIndex(this._sheet, cell);
389
+ delete this._sheet.cells[idx];
390
+ });
391
+ }
392
+ cut(range) {
393
+ (0, import_invariant.invariant)(this._node, void 0, {
394
+ F: __dxlog_file,
395
+ L: 266,
396
+ S: this,
397
+ A: [
398
+ "this._node",
399
+ ""
400
+ ]
401
+ });
402
+ this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
403
+ this._iterRange(range, (cell) => {
404
+ const idx = addressToIndex(this._sheet, cell);
405
+ delete this._sheet.cells[idx];
406
+ });
407
+ }
408
+ copy(range) {
409
+ (0, import_invariant.invariant)(this._node, void 0, {
410
+ F: __dxlog_file,
411
+ L: 275,
412
+ S: this,
413
+ A: [
414
+ "this._node",
415
+ ""
416
+ ]
417
+ });
418
+ this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
419
+ }
420
+ paste(cell) {
421
+ (0, import_invariant.invariant)(this._node, void 0, {
422
+ F: __dxlog_file,
423
+ L: 280,
424
+ S: this,
425
+ A: [
426
+ "this._node",
427
+ ""
428
+ ]
429
+ });
430
+ if (!this._node.graph.hf.isClipboardEmpty()) {
431
+ const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
432
+ for (const change of changes) {
433
+ if (change instanceof import_compute.ExportedCellChange) {
434
+ const { address, newValue } = change;
435
+ const idx = addressToIndex(this._sheet, {
436
+ row: address.row,
437
+ col: address.col
438
+ });
439
+ this._sheet.cells[idx] = {
440
+ value: newValue
441
+ };
442
+ }
443
+ }
444
+ }
445
+ }
446
+ // TODO(burdon): Display undo/redo state.
447
+ undo() {
448
+ (0, import_invariant.invariant)(this._node, void 0, {
449
+ F: __dxlog_file,
450
+ L: 295,
451
+ S: this,
452
+ A: [
453
+ "this._node",
454
+ ""
455
+ ]
456
+ });
457
+ if (this._node.graph.hf.isThereSomethingToUndo()) {
458
+ this._node.graph.hf.undo();
459
+ }
460
+ }
461
+ redo() {
462
+ (0, import_invariant.invariant)(this._node, void 0, {
463
+ F: __dxlog_file,
464
+ L: 303,
465
+ S: this,
466
+ A: [
467
+ "this._node",
468
+ ""
469
+ ]
470
+ });
471
+ if (this._node.graph.hf.isThereSomethingToRedo()) {
472
+ this._node.graph.hf.redo();
473
+ }
474
+ }
475
+ /**
476
+ * Get value from sheet.
477
+ */
478
+ getCellValue(cell) {
479
+ const idx = addressToIndex(this._sheet, cell);
480
+ return this._sheet.cells[idx]?.value ?? null;
481
+ }
482
+ /**
483
+ * Get value as a string for editing.
484
+ */
485
+ getCellText(cell) {
486
+ const value = this.getCellValue(cell);
487
+ if (value == null) {
488
+ return void 0;
489
+ }
490
+ if ((0, import_compute.isFormula)(value)) {
491
+ return this._graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs(this._sheet, value));
492
+ } else {
493
+ return String(value);
494
+ }
495
+ }
496
+ /**
497
+ * Get array of raw values from sheet.
498
+ */
499
+ getCellValues(range) {
500
+ return this._iterRange(range, (cell) => this.getCellValue(cell));
501
+ }
502
+ /**
503
+ * Gets the regular or computed value from the engine.
504
+ */
505
+ getValue(cell) {
506
+ (0, import_invariant.invariant)(this._node, void 0, {
507
+ F: __dxlog_file,
508
+ L: 346,
509
+ S: this,
510
+ A: [
511
+ "this._node",
512
+ ""
513
+ ]
514
+ });
515
+ const address = toSimpleCellAddress(this._node.sheetId, cell);
516
+ const value = this._node.graph.hf.getCellValue(address);
517
+ if (value instanceof import_compute.DetailedCellError) {
518
+ import_log.log.info("cell error", {
519
+ cell,
520
+ error: value
521
+ }, {
522
+ F: __dxlog_file,
523
+ L: 351,
524
+ S: this,
525
+ C: (f, a) => f(...a)
526
+ });
527
+ return value.toString();
528
+ }
529
+ return value;
530
+ }
531
+ /**
532
+ * Get value type.
533
+ */
534
+ getValueDescription(cell) {
535
+ (0, import_invariant.invariant)(this._node, void 0, {
536
+ F: __dxlog_file,
537
+ L: 362,
538
+ S: this,
539
+ A: [
540
+ "this._node",
541
+ ""
542
+ ]
543
+ });
544
+ const addr = toSimpleCellAddress(this._node.sheetId, cell);
545
+ const type = this._node.graph.hf.getCellValueDetailedType(addr);
546
+ return typeMap[type];
547
+ }
548
+ /**
549
+ * Sets the value, updating the sheet and engine.
550
+ */
551
+ setValue(cell, value) {
552
+ (0, import_invariant.invariant)(this._node, void 0, {
553
+ F: __dxlog_file,
554
+ L: 372,
555
+ S: this,
556
+ A: [
557
+ "this._node",
558
+ ""
559
+ ]
560
+ });
561
+ if (this._options.readonly) {
562
+ throw new ReadonlyException();
563
+ }
564
+ let refresh = false;
565
+ if (cell.row >= this._sheet.rows.length) {
566
+ insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
567
+ refresh = true;
568
+ }
569
+ if (cell.col >= this._sheet.columns.length) {
570
+ insertIndices(this._sheet.columns, cell.col, 1, MAX_COLS);
571
+ refresh = true;
572
+ }
573
+ if (refresh) {
574
+ this.reset();
575
+ }
576
+ this._node.graph.hf.setCellContents({
577
+ sheet: this._node.sheetId,
578
+ row: cell.row,
579
+ col: cell.col
580
+ }, [
581
+ [
582
+ (0, import_compute.isFormula)(value) ? this._graph.mapFormulaToNative(value) : value
583
+ ]
584
+ ]);
585
+ const idx = addressToIndex(this._sheet, cell);
586
+ if (value === void 0 || value === null) {
587
+ delete this._sheet.cells[idx];
588
+ } else {
589
+ if ((0, import_compute.isFormula)(value)) {
590
+ value = this._graph.mapFunctionBindingToId(mapFormulaRefsToIndices(this._sheet, value));
591
+ }
592
+ this._sheet.cells[idx] = {
593
+ value
594
+ };
595
+ }
596
+ }
597
+ /**
598
+ * Sets values from a simple map.
599
+ */
600
+ setValues(values) {
601
+ Object.entries(values).forEach(([key, { value }]) => {
602
+ this.setValue((0, import_compute.addressFromA1Notation)(key), value);
603
+ });
604
+ }
605
+ /**
606
+ * Iterate range.
607
+ */
608
+ _iterRange(range, cb) {
609
+ const to = range.to ?? range.from;
610
+ const rowRange = [
611
+ Math.min(range.from.row, to.row),
612
+ Math.max(range.from.row, to.row)
613
+ ];
614
+ const columnRange = [
615
+ Math.min(range.from.col, to.col),
616
+ Math.max(range.from.col, to.col)
617
+ ];
618
+ const rows = [];
619
+ for (let row = rowRange[0]; row <= rowRange[1]; row++) {
620
+ const rowCells = [];
621
+ for (let column = columnRange[0]; column <= columnRange[1]; column++) {
622
+ const value = cb({
623
+ row,
624
+ col: column
625
+ });
626
+ if (value !== void 0) {
627
+ rowCells.push(value);
628
+ }
629
+ }
630
+ rows.push(rowCells);
631
+ }
632
+ return rows;
633
+ }
634
+ // TODO(burdon): Delete index.
635
+ _deleteIndices(indices, i, n) {
636
+ throw new Error("Not implemented");
637
+ }
638
+ // TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
639
+ _moveIndices(indices, i, j, n) {
640
+ throw new Error("Not implemented");
641
+ }
642
+ /**
643
+ * Map from indices to A1 notation.
644
+ */
645
+ mapFormulaIndicesToRefs(formula) {
646
+ (0, import_invariant.invariant)((0, import_compute.isFormula)(formula), void 0, {
647
+ F: __dxlog_file,
648
+ L: 457,
649
+ S: this,
650
+ A: [
651
+ "isFormula(formula)",
652
+ ""
653
+ ]
654
+ });
655
+ return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
656
+ return (0, import_compute.addressToA1Notation)(addressFromIndex(this._sheet, idx));
657
+ });
658
+ }
659
+ //
660
+ // Values
661
+ //
662
+ /**
663
+ * https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
664
+ * https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
665
+ * NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
666
+ */
667
+ toLocalDate(num) {
668
+ const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
669
+ return new Date(year, month - 1, day, hours, minutes, seconds);
670
+ }
671
+ toDateTime(num) {
672
+ (0, import_invariant.invariant)(this._node, void 0, {
673
+ F: __dxlog_file,
674
+ L: 478,
675
+ S: this,
676
+ A: [
677
+ "this._node",
678
+ ""
679
+ ]
680
+ });
681
+ return this._node.graph.hf.numberToDateTime(num);
682
+ }
683
+ toDate(num) {
684
+ (0, import_invariant.invariant)(this._node, void 0, {
685
+ F: __dxlog_file,
686
+ L: 483,
687
+ S: this,
688
+ A: [
689
+ "this._node",
690
+ ""
691
+ ]
692
+ });
693
+ return this._node.graph.hf.numberToDate(num);
694
+ }
695
+ toTime(num) {
696
+ (0, import_invariant.invariant)(this._node, void 0, {
697
+ F: __dxlog_file,
698
+ L: 488,
699
+ S: this,
700
+ A: [
701
+ "this._node",
702
+ ""
703
+ ]
704
+ });
705
+ return this._node.graph.hf.numberToTime(num);
706
+ }
707
+ };
708
+ var useSheetModel = (graph, sheet, { readonly } = {}) => {
709
+ const [model, setModel] = (0, import_react.useState)();
710
+ (0, import_react.useEffect)(() => {
711
+ if (!graph || !sheet) {
712
+ return;
713
+ }
714
+ let model2;
715
+ const t = setTimeout(async () => {
716
+ model2 = new SheetModel(graph, sheet, {
717
+ readonly
718
+ });
719
+ await model2.open();
720
+ setModel(model2);
721
+ });
722
+ return () => {
723
+ clearTimeout(t);
724
+ void model2?.close();
725
+ };
726
+ }, [
727
+ graph,
728
+ sheet,
729
+ readonly
730
+ ]);
731
+ return model;
732
+ };
733
+ var SheetAction;
734
+ (function(SheetAction2) {
735
+ const SHEET_ACTION = `${import_chunk_2ZVZI2KJ.SHEET_PLUGIN}/action`;
736
+ class Create extends import_echo_schema2.S.TaggedClass()(`${SHEET_ACTION}/create`, {
737
+ input: import_echo_schema2.S.Struct({
738
+ name: import_echo_schema2.S.optional(import_echo_schema2.S.String)
739
+ }),
740
+ output: import_echo_schema2.S.Struct({
741
+ object: SheetType
742
+ })
743
+ }) {
744
+ }
745
+ SheetAction2.Create = Create;
746
+ const Axis = import_echo_schema2.S.Union(import_echo_schema2.S.Literal("row"), import_echo_schema2.S.Literal("col"));
747
+ class InsertAxis extends import_echo_schema2.S.TaggedClass()(`${SHEET_ACTION}/axis-insert`, {
748
+ input: import_echo_schema2.S.Struct({
749
+ // TODO(wittjosiah): S.instanceOf(SheetModel) throws when running tests.
750
+ model: import_echo_schema2.S.Any.pipe(import_echo_schema2.S.filter((model) => model instanceof SheetModel)),
751
+ axis: Axis,
752
+ index: import_echo_schema2.S.Number,
753
+ count: import_echo_schema2.S.optional(import_echo_schema2.S.Number)
754
+ }),
755
+ output: import_echo_schema2.S.Void
756
+ }) {
757
+ }
758
+ SheetAction2.InsertAxis = InsertAxis;
759
+ SheetAction2.RestoreAxis = import_echo_schema2.S.Struct({
760
+ axis: Axis,
761
+ axisIndex: import_echo_schema2.S.String,
762
+ index: import_echo_schema2.S.Number,
763
+ axisMeta: RowColumnMeta,
764
+ values: import_echo_schema2.S.Array(import_echo_schema2.S.Any)
765
+ });
766
+ class DropAxis extends import_echo_schema2.S.TaggedClass()(`${SHEET_ACTION}/axis-drop`, {
767
+ input: import_echo_schema2.S.Struct({
768
+ // TODO(wittjosiah): S.instanceOf(SheetModel) throws when running tests.
769
+ model: import_echo_schema2.S.Any.pipe(import_echo_schema2.S.filter((model) => model instanceof SheetModel)),
770
+ axis: Axis,
771
+ axisIndex: import_echo_schema2.S.String,
772
+ deletionData: import_echo_schema2.S.optional(SheetAction2.RestoreAxis)
773
+ }),
774
+ output: import_echo_schema2.S.Void
775
+ }) {
776
+ }
777
+ SheetAction2.DropAxis = DropAxis;
778
+ })(SheetAction || (SheetAction = {}));
779
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/types/util.ts";
780
+ var MAX_ROWS = 500;
781
+ var MAX_COLS = 676;
782
+ var DEFAULT_ROWS = 50;
783
+ var DEFAULT_COLS = 26;
784
+ var ApiError = class extends Error {
785
+ };
786
+ var ReadonlyException = class extends ApiError {
787
+ };
788
+ var RangeException = class extends ApiError {
789
+ constructor(n) {
790
+ super();
791
+ }
792
+ };
793
+ var createIndex = (length = 8) => {
794
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
795
+ const charactersLength = characters.length;
796
+ const randomBuffer = (0, import_crypto.randomBytes)(length);
797
+ return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
798
+ };
799
+ var createIndices = (length) => Array.from({
800
+ length
801
+ }).map(() => createIndex());
802
+ var insertIndices = (indices, i, n, max) => {
803
+ if (i + n > max) {
804
+ throw new RangeException(i + n);
805
+ }
806
+ const idx = createIndices(n);
807
+ indices.splice(i, 0, ...idx);
808
+ return idx;
809
+ };
810
+ var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLS } = {}) => {
811
+ if (!sheet.rows.length) {
812
+ insertIndices(sheet.rows, 0, rows, MAX_ROWS);
813
+ }
814
+ if (!sheet.columns.length) {
815
+ insertIndices(sheet.columns, 0, columns, MAX_COLS);
816
+ }
817
+ };
818
+ var createSheet = ({ name, cells, ...size } = {}) => {
819
+ const sheet = (0, import_live_object.create)(SheetType, {
820
+ name,
821
+ cells: {},
822
+ rows: [],
823
+ columns: [],
824
+ rowMeta: {},
825
+ columnMeta: {},
826
+ ranges: [],
827
+ threads: []
828
+ });
829
+ initialize(sheet, size);
830
+ if (cells) {
831
+ Object.entries(cells).forEach(([key, { value }]) => {
832
+ const idx = addressToIndex(sheet, (0, import_compute2.addressFromA1Notation)(key));
833
+ if ((0, import_compute2.isFormula)(value)) {
834
+ value = mapFormulaRefsToIndices(sheet, value);
835
+ }
836
+ sheet.cells[idx] = {
837
+ value
838
+ };
839
+ });
840
+ }
841
+ return sheet;
842
+ };
843
+ var addressToIndex = (sheet, cell) => {
844
+ return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
845
+ };
846
+ var addressFromIndex = (sheet, idx) => {
847
+ const [column, row] = idx.split("@");
848
+ return {
849
+ col: sheet.columns.indexOf(column),
850
+ row: sheet.rows.indexOf(row)
851
+ };
852
+ };
853
+ var rangeToIndex = (sheet, range) => {
854
+ return [
855
+ range.from,
856
+ range.to ?? range.from
857
+ ].map((cell) => addressToIndex(sheet, cell)).join(":");
858
+ };
859
+ var rangeFromIndex = (sheet, idx) => {
860
+ const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
861
+ return {
862
+ from,
863
+ to
864
+ };
865
+ };
866
+ var compareIndexPositions = (sheet, indexA, indexB) => {
867
+ const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
868
+ const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
869
+ if (rowA !== rowB) {
870
+ return rowA - rowB;
871
+ } else {
872
+ return columnA - columnB;
873
+ }
874
+ };
875
+ var mapFormulaRefsToIndices = (sheet, formula) => {
876
+ (0, import_invariant2.invariant)((0, import_compute2.isFormula)(formula), void 0, {
877
+ F: __dxlog_file2,
878
+ L: 153,
879
+ S: void 0,
880
+ A: [
881
+ "isFormula(formula)",
882
+ ""
883
+ ]
884
+ });
885
+ return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
886
+ return addressToIndex(sheet, (0, import_compute2.addressFromA1Notation)(match));
887
+ });
888
+ };
889
+ var mapFormulaIndicesToRefs = (sheet, formula) => {
890
+ (0, import_invariant2.invariant)((0, import_compute2.isFormula)(formula), void 0, {
891
+ F: __dxlog_file2,
892
+ L: 163,
893
+ S: void 0,
894
+ A: [
895
+ "isFormula(formula)",
896
+ ""
897
+ ]
898
+ });
899
+ return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
900
+ return (0, import_compute2.addressToA1Notation)(addressFromIndex(sheet, idx));
901
+ });
902
+ };
903
+ // Annotate the CommonJS export names for ESM import in node:
904
+ 0 && (module.exports = {
905
+ ApiError,
906
+ CellValue,
907
+ DEFAULT_COLS,
908
+ DEFAULT_ROWS,
909
+ MAX_COLS,
910
+ MAX_ROWS,
911
+ Range,
912
+ RangeException,
913
+ ReadonlyException,
914
+ RowColumnMeta,
915
+ SheetAction,
916
+ SheetType,
917
+ addressFromIndex,
918
+ addressToIndex,
919
+ alignKey,
920
+ cellClassNameForRange,
921
+ commentKey,
922
+ compareIndexPositions,
923
+ createIndex,
924
+ createIndices,
925
+ createSheet,
926
+ initialize,
927
+ insertIndices,
928
+ mapFormulaIndicesToRefs,
929
+ mapFormulaRefsToIndices,
930
+ rangeFromIndex,
931
+ rangeToIndex,
932
+ styleKey,
933
+ useSheetModel
934
+ });
935
+ //# sourceMappingURL=chunk-TQOJ7DG2.cjs.map