@allyhub/sdk 0.9.0 → 0.11.0

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 (148) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  3. package/dist/node_modules/@allyhub/chart/dist/chart-xml.d.ts +3 -0
  4. package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +2 -2
  5. package/dist/node_modules/@allyhub/chart/dist/chart.d.ts +22 -0
  6. package/dist/node_modules/@allyhub/chart/dist/chart.js +1 -1
  7. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  8. package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +7 -0
  9. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  10. package/dist/node_modules/@allyhub/formats/dist/data/faces.d.ts +1 -1
  11. package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +87 -1
  12. package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
  13. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +89 -0
  14. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  15. package/dist/node_modules/@allyhub/formats/dist/note-shape.d.ts +20 -0
  16. package/dist/node_modules/@allyhub/formats/dist/note-shape.js +1 -1
  17. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +50 -0
  18. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  19. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  20. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  21. package/dist/node_modules/@allyhub/image-sdk/dist/index.d.ts +1 -1
  22. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  23. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  24. package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.js +1 -1
  25. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  26. package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +2 -0
  27. package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +16 -0
  28. package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -1
  29. package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
  30. package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +14 -1
  31. package/dist/node_modules/@allyhub/piece/dist/page/locate.js +1 -1
  32. package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +18 -0
  33. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  34. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +140 -0
  35. package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
  36. package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +19 -1
  37. package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
  38. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +157 -0
  39. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  40. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +10 -2
  41. package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
  42. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +101 -186
  43. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  44. package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +1 -0
  45. package/dist/node_modules/@allyhub/protocol/dist/mail.js +1 -1
  46. package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +92 -94
  47. package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
  48. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +17 -0
  49. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  50. package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +7 -0
  51. package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
  52. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +15 -3
  53. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  54. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  55. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  56. package/dist/node_modules/@allyhub/scenery/dist/index.d.ts +2 -2
  57. package/dist/node_modules/@allyhub/scenery/dist/index.js +1 -1
  58. package/dist/node_modules/@allyhub/scenery/dist/moire.d.ts +45 -5
  59. package/dist/node_modules/@allyhub/scenery/dist/moire.js +2 -2
  60. package/dist/node_modules/@allyhub/scenery/dist/phone.d.ts +4 -3
  61. package/dist/node_modules/@allyhub/scenery/dist/phone.js +1 -1
  62. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  63. package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
  64. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.d.ts +70 -0
  65. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
  66. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.d.ts +6 -0
  67. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
  68. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
  69. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.d.ts +3 -1
  70. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.js +1 -1
  71. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
  72. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/kernels.js +1 -1
  73. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
  74. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/maths.js +1 -1
  75. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
  76. package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.d.ts +9 -0
  77. package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.js +1 -1
  78. package/dist/node_modules/@allyhub/sheet/dist/calc/types.d.ts +6 -0
  79. package/dist/node_modules/@allyhub/sheet/dist/calc/types.js +1 -1
  80. package/dist/node_modules/@allyhub/sheet/dist/chart.d.ts +9 -0
  81. package/dist/node_modules/@allyhub/sheet/dist/chart.js +1 -1
  82. package/dist/node_modules/@allyhub/sheet/dist/export.d.ts +0 -8
  83. package/dist/node_modules/@allyhub/sheet/dist/export.js +2 -4
  84. package/dist/node_modules/@allyhub/sheet/dist/formula/ast.d.ts +12 -1
  85. package/dist/node_modules/@allyhub/sheet/dist/formula/move.d.ts +5 -1
  86. package/dist/node_modules/@allyhub/sheet/dist/formula/move.js +1 -1
  87. package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
  88. package/dist/node_modules/@allyhub/sheet/dist/formula/print.js +1 -1
  89. package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +3 -2
  90. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  91. package/dist/node_modules/@allyhub/sheet/dist/inspect.d.ts +12 -2
  92. package/dist/node_modules/@allyhub/sheet/dist/inspect.js +1 -1
  93. package/dist/node_modules/@allyhub/sheet/dist/printed.d.ts +19 -0
  94. package/dist/node_modules/@allyhub/sheet/dist/printed.js +2 -0
  95. package/dist/node_modules/@allyhub/sheet/dist/values.d.ts +2 -0
  96. package/dist/node_modules/@allyhub/sheet/dist/values.js +1 -1
  97. package/dist/node_modules/@allyhub/sheet/dist/workbook.d.ts +2 -0
  98. package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
  99. package/dist/node_modules/@allyhub/sheet/dist/write.js +15 -15
  100. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.d.ts +6 -2
  101. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  102. package/dist/node_modules/@allyhub/sheet/dist/xlsx/formula.js +2 -2
  103. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.d.ts +0 -1
  104. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  105. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.d.ts +3 -1
  106. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
  107. package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.d.ts +7 -1
  108. package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.js +3 -1
  109. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.d.ts +6 -0
  110. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
  111. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.d.ts +1 -1
  112. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  113. package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.d.ts +12 -1
  114. package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.js +3 -2
  115. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  116. package/dist/node_modules/@allyhub/slides-core/dist/api.d.ts +57 -7
  117. package/dist/node_modules/@allyhub/slides-core/dist/api.js +2 -2
  118. package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
  119. package/dist/node_modules/@allyhub/slides-core/dist/enums.d.ts +24 -0
  120. package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
  121. package/dist/node_modules/@allyhub/slides-core/dist/fact.d.ts +15 -0
  122. package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
  123. package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +6 -2
  124. package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +3 -1
  125. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  126. package/dist/node_modules/@allyhub/slides-core/dist/sdk.d.ts +1 -1
  127. package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +1 -1
  128. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  129. package/dist/node_modules/@allyhub/video-core/dist/piece.d.ts +2 -2
  130. package/dist/node_modules/@allyhub/video-core/dist/schema.d.ts +2 -2
  131. package/dist/node_modules/@allyhub/video-core/dist/schema.js +1 -1
  132. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  133. package/dist/node_modules/@allyhub/video-sdk/dist/phone.d.ts +12 -5
  134. package/dist/node_modules/@allyhub/video-sdk/dist/phone.js +1 -1
  135. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  136. package/docs/README.md +4 -0
  137. package/docs/canvas.md +28 -0
  138. package/docs/defaults.md +30 -4
  139. package/docs/docs.md +10 -10
  140. package/docs/image.md +3 -3
  141. package/docs/linkedin.md +96 -0
  142. package/docs/reports.md +89 -0
  143. package/docs/scenery.md +3 -4
  144. package/docs/sheets.md +23 -6
  145. package/docs/slides.md +50 -4
  146. package/docs/speech.md +1 -1
  147. package/docs/x.md +73 -0
  148. package/package.json +1 -1
@@ -52,4 +52,10 @@ export interface Frame {
52
52
  dc: number;
53
53
  scope?: Scope;
54
54
  }
55
+ /**
56
+ * Every item of a list put on another's end: `push(...list)` passes each as
57
+ * an argument, and a list of a hundred thousand (a column's readers, a
58
+ * whole column's values) runs past what a call can take.
59
+ */
60
+ export declare function pushAll<T>(to: T[], items: Iterable<T>): void;
55
61
  //# sourceMappingURL=types.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export class Reference{sheet;top;left;bottom;right;constructor(t,i,r,e,o){this.sheet=t,this.top=i,this.left=r,this.bottom=e,this.right=o}get rows(){return this.bottom-this.top+1}get cols(){return this.right-this.left+1}get single(){return this.top===this.bottom&&this.left===this.right}get key(){return`${String(this.sheet.index)}!${String(this.top)},${String(this.left)}:${String(this.bottom)},${String(this.right)}`}}export class Union{parts;constructor(t){this.parts=t}}export class Lambda{params;body;frame;named;constructor(t,i,r,e){this.params=t,this.body=i,this.frame=r,this.named=e}}export class Missing{missing=!0}export const MISSING=new Missing;
2
+ export class Reference{sheet;top;left;bottom;right;constructor(t,i,r,e,o){this.sheet=t,this.top=i,this.left=r,this.bottom=e,this.right=o}get rows(){return this.bottom-this.top+1}get cols(){return this.right-this.left+1}get single(){return this.top===this.bottom&&this.left===this.right}get key(){return`${String(this.sheet.index)}!${String(this.top)},${String(this.left)}:${String(this.bottom)},${String(this.right)}`}}export class Union{parts;constructor(t){this.parts=t}}export class Lambda{params;body;frame;named;constructor(t,i,r,e){this.params=t,this.body=i,this.frame=r,this.named=e}}export class Missing{missing=!0}export const MISSING=new Missing;export function pushAll(s,t){for(const i of t)s.push(i)}
@@ -15,6 +15,15 @@ export declare const SHEET_CHART_DEFAULTS: {
15
15
  /** Pixels to the point, at 96 to the inch. */
16
16
  readonly pixelsToPoints: 0.75;
17
17
  };
18
+ /**
19
+ * A chart's categories as the numbers its cells hold (dates, years) and
20
+ * their cells' number format, for its file to cache as numbers and show as
21
+ * the cells do; undefined when it names no cells.
22
+ */
23
+ export declare function categoryNumbers(calc: Calc, sheet: Worksheet, chart: Chart): {
24
+ values: (number | null)[];
25
+ format: string | undefined;
26
+ } | undefined;
18
27
  /** A chart as it is drawn now: what its cells compute, from the sheet it is on. */
19
28
  export declare function chartDef(calc: Calc, sheet: Worksheet, chart: Chart): ChartDef;
20
29
  /** A chart's size on the sheet, pixels. */
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{chartSvg as E,isRound as M,isScatter as C}from"@allyhub/chart";import{cellName as L,columnLetter as F,contains as H,rangeName as P,readAddress as U,readArea as I}from"./address.js";import{Reference as N,Union as V}from"./calc/types.js";import{shownValue as W}from"./format.js";import{sheetPrefix as k}from"./formula/print.js";import{CellError as q,Matrix as T}from"./values.js";export const SHEET_CHART_DEFAULTS={width:480,height:288,size:9,titleSize:14,ink:"#595959",pixelsToPoints:.75};function z(e,n,o){const{node:t}=o;if(!t)return[];const i=e.eval(t,{sheet:n,row:0,col:0,dr:0,dc:0}),f=l=>{const a=l.sheet,b=e.filtered(a),m=[],h=Math.min(l.bottom,a.lastRow),p=Math.min(l.right,a.columnsUsed-1);for(let u=l.top;u<=h;u++)if(!(b.has(u)||a.spec.rows?.[String(u+1)]?.hidden===!0))for(let d=l.left;d<=p;d++)a.spec.columns?.[F(d)]?.hidden!==!0&&m.push({value:e.value(a,u,d),sheet:a,row:u,col:d});return m};if(i instanceof N)return f(i);if(i instanceof V)return i.parts.flatMap(f);if(i instanceof T)return i.data.map(l=>({value:l}));const r=e.flat(i);return r instanceof T?r.data.map(l=>({value:l})):[{value:r}]}const O=e=>{if(e.value===null)return"";const n=e.sheet&&e.row!==void 0&&e.col!==void 0?e.sheet.lookAt(e.row,e.col).format:void 0;return W(e.value,n)};function j(e){return typeof e=="number"?Number.isFinite(e)?e:null:e===null||e instanceof q?null:typeof e=="boolean"&&e?1:0}const D=e=>e&&{...e.min===void 0?{}:{minimum_scale:e.min},...e.max===void 0?{}:{maximum_scale:e.max},...e.major===void 0?{}:{major_unit:e.major},...e.gridlines===void 0?{}:{has_major_gridlines:e.gridlines},...e.visible===void 0?{}:{visible:e.visible},...e.format===void 0?{}:{number_format:e.format},...e.reverse===void 0?{}:{reverse_order:e.reverse},...e.title===void 0||e.title===""?{}:{title:e.title}},R=e=>e===void 0?void 0:{rgb:e};function B(e){if(e===void 0||e===!1)return;if(e===!0)return{show_value:!0};const n=typeof e.color=="string"?R(e.color):void 0;return{...e.value===void 0?{}:{show_value:e.value},...e.percentage===void 0?{}:{show_percentage:e.percentage},...e.category===void 0?{}:{show_category_name:e.category},...e.series===void 0?{}:{show_series_name:e.series},...e.format===void 0?{}:{number_format:e.format},...e.position===void 0?{}:{position:e.position},...e.size===void 0?{}:{size:e.size},...n?{color:n}:{}}}const G=e=>{const n=e.find(o=>o.sheet);return n?.sheet&&n.row!==void 0&&n.col!==void 0?n.sheet.lookAt(n.row,n.col).format:void 0};export function chartDef(e,n,o){const{spec:t}=o,i=C(t.type),f=o.categories?z(e,n,o.categories):void 0,r=o.series.map((d,g)=>{const c=t.series[g],w=z(e,n,d.values),x=d.name?z(e,n,d.name)[0]:void 0,A=d.x?z(e,n,d.x):i?f:void 0,v=c.format??G(w),y=R(c.color);return{name:(x?O(x):c.name)??`Series${String(g+1)}`,values:w.map(s=>j(s.value)),...A?{x:A.map(s=>j(s.value))}:{},...v===void 0?{}:{number_format:v},...y?{color:y}:{},...c.smooth===void 0?{}:{smooth:c.smooth},...c.line_width===void 0?{}:{line_width:c.line_width},...c.marker_size===void 0?{}:{marker_size:c.marker_size}}}),l=Math.max(0,...r.map(d=>d.values.length)),a=f?f.map(O):Array.from({length:l},(d,g)=>String(g+1)),b=o.title?z(e,n,o.title)[0]:void 0,m=b?O(b):t.title,h=B(t.labels),p=D(t.value_axis),u=D(t.category_axis);return{type:t.type,categories:a,series:r,...m===void 0||m===""?{}:{title:m},...t.legend===void 0?{}:{legend:t.legend},...h?{labels:h}:{},...t.gap_width===void 0?{}:{gap_width:t.gap_width},...t.overlap===void 0?{}:{overlap:t.overlap},...t.vary_by_categories===void 0?{}:{vary_by_categories:t.vary_by_categories},...t.hole_size===void 0?{}:{hole_size:t.hole_size},...p?{value_axis:p}:{},...u?{category_axis:u}:{},font_size:t.size??SHEET_CHART_DEFAULTS.size,title_size:t.title_size??SHEET_CHART_DEFAULTS.titleSize,font_color:R(t.color)??{rgb:SHEET_CHART_DEFAULTS.ink}}}export const chartSize=e=>({width:e.width??SHEET_CHART_DEFAULTS.width,height:e.height??SHEET_CHART_DEFAULTS.height}),chartSvg=(e,n,o,t={})=>E(e,n,o,{pointsPerPixel:SHEET_CHART_DEFAULTS.pixelsToPoints,...t});export function chartAfter(e,n){const o=i=>i?.startsWith("=")===!0?n(i):i,t=o(e.title);return{...e,...t===void 0?{}:{title:t},...e.categories===void 0?{}:{categories:n(e.categories)},series:e.series.map(i=>{const f=o(i.name);return{...i,values:n(i.values),...i.x===void 0?{}:{x:n(i.x)},...f===void 0?{}:{name:f}}})}}function J(e,n,o,t){if(t){const i=t.data;if(o.top===i.top&&o.bottom===i.bottom&&o.left===o.right){const f=t.columns[o.left-t.at.col];if(f)return`${t.name}[${f.name}]`}}return`${n===e?"":k(n.name)}${P(o)}`}const K=(e,n,o,t)=>typeof e.value(n,o,t)=="number",Q=(e,n,o,t)=>{const i=e.value(n,o,t);if(typeof i=="string")return!0;const f=n.lookAt(o,t).format;return typeof i=="number"&&f!==void 0&&/[ymd]/iu.test(f)};export function chartOfRange(e,n,o,t,i){const f=t.bottom-t.top+1,r=t.right-t.left+1,l=n.tables.find(s=>H(s.area,t.top,t.left)),a=s=>J(o,n,s,l),b=C(i),m=f>1&&Array.from({length:r},(s,_)=>t.left+_).some(s=>!K(e,n,t.top,s)),h=r>1&&(b||Array.from({length:f-(m?1:0)},(s,_)=>_).every(s=>Q(e,n,t.top+(m?1:0)+s,t.left)||e.value(n,t.top+(m?1:0)+s,t.left)===null)),p=t.top+(m?1:0),u=t.left+(h?1:0);if(p>t.bottom||u>t.right)return;const d=!b&&!M(i)&&t.right-u>t.bottom-p,g=[],c=(s,_)=>e.value(n,s,_)===null?void 0:`=${n===o?"":k(n.name)}${L({row:s,col:_})}`,w=d?{first:p,last:t.bottom}:{first:u,last:t.right};for(let s=w.first;s<=w.last;s++){const _=d?{top:s,left:u,bottom:s,right:t.right}:{top:p,left:s,bottom:t.bottom,right:s},$=d?h?c(s,t.left):void 0:m?c(t.top,s):void 0;g.push({values:a(_),...$===void 0?{}:{name:$}})}const x=d?m?{top:t.top,left:u,bottom:t.top,right:t.right}:void 0:h?{top:p,left:t.left,bottom:t.bottom,right:t.left}:void 0,A=g.length>1&&!M(i),v=M(i)?g.slice(0,1):g,y=v.length===1?v[0]?.name:void 0;return{type:i,...x?{categories:a(x)}:{},series:v,...A||M(i)?{legend:"bottom"}:{},...y===void 0?{}:{title:y}}}function S(e,n,o){if(!o?.node)return;const t=e.eval(o.node,{sheet:n,row:0,col:0,dr:0,dc:0});return t instanceof N?{sheet:t.sheet,area:{top:t.top,left:t.left,bottom:Math.min(t.bottom,Math.max(t.top,t.sheet.lastRow)),right:t.right}}:void 0}export function chartDataRange(e,n,o){const t=[S(e,n,o.categories),...o.series.flatMap(r=>[S(e,n,r.values),S(e,n,r.name),S(e,n,r.x)])].filter(r=>r!==void 0),i=t[0];if(!i||t.some(r=>r.sheet!==i.sheet))return;const f={top:Math.min(...t.map(r=>r.area.top)),left:Math.min(...t.map(r=>r.area.left)),bottom:Math.max(...t.map(r=>r.area.bottom)),right:Math.max(...t.map(r=>r.area.right))};return`${i.sheet===n?"":k(i.sheet.name)}${P(f)}`}export function readDataRange(e,n,o){const t=o.lastIndexOf("!"),i=t<0?void 0:o.slice(0,t).replace(/^'|'$/gu,""),f=i===void 0?n:e.wb.sheet(i.replaceAll("''","'")),r=I(o.slice(t+1).replaceAll("$",""));return f&&r?{sheet:f,area:r}:void 0}export function chartPlace(e,n,o){const t=U(e.at)??{row:0,col:0};return{left:o(t.col)+(e.x??0),top:n(t.row)+(e.y??0),...chartSize(e)}}
2
+ import{chartSvg as L,isRound as M,isScatter as P}from"@allyhub/chart";import{cellName as F,columnLetter as H,contains as U,rangeName as T,readAddress as I,readArea as V}from"./address.js";import{Reference as j,Union as W}from"./calc/types.js";import{shownValue as q}from"./format.js";import{sheetPrefix as k}from"./formula/print.js";import{CellError as B,Matrix as D}from"./values.js";export const SHEET_CHART_DEFAULTS={width:480,height:288,size:9,titleSize:14,ink:"#595959",pixelsToPoints:.75};function y(e,n,o){const{node:t}=o;if(!t)return[];const i=e.eval(t,{sheet:n,row:0,col:0,dr:0,dc:0}),d=l=>{const p=l.sheet,b=e.filtered(p),a=[],_=Math.min(l.bottom,p.lastRow),h=Math.min(l.right,p.columnsUsed-1);for(let f=l.top;f<=_;f++)if(!(b.has(f)||p.spec.rows?.[String(f+1)]?.hidden===!0))for(let c=l.left;c<=h;c++)p.spec.columns?.[H(c)]?.hidden!==!0&&a.push({value:e.value(p,f,c),sheet:p,row:f,col:c});return a};if(i instanceof j)return d(i);if(i instanceof W)return i.parts.flatMap(d);if(i instanceof D)return i.data.map(l=>({value:l}));const r=e.flat(i);return r instanceof D?r.data.map(l=>({value:l})):[{value:r}]}const O=e=>{if(e.value===null)return"";const n=e.sheet&&e.row!==void 0&&e.col!==void 0?e.sheet.lookAt(e.row,e.col).format:void 0;return q(e.value,n)};function R(e){return typeof e=="number"?Number.isFinite(e)?e:null:e===null||e instanceof B?null:typeof e=="boolean"&&e?1:0}const C=e=>e&&{...e.min===void 0?{}:{minimum_scale:e.min},...e.max===void 0?{}:{maximum_scale:e.max},...e.major===void 0?{}:{major_unit:e.major},...e.gridlines===void 0?{}:{has_major_gridlines:e.gridlines},...e.visible===void 0?{}:{visible:e.visible},...e.format===void 0?{}:{number_format:e.format},...e.reverse===void 0?{}:{reverse_order:e.reverse},...e.title===void 0||e.title===""?{}:{title:e.title}},N=e=>e===void 0?void 0:{rgb:e};function G(e){if(e===void 0||e===!1)return;if(e===!0)return{show_value:!0};const n=typeof e.color=="string"?N(e.color):void 0;return{...e.value===void 0?{}:{show_value:e.value},...e.percentage===void 0?{}:{show_percentage:e.percentage},...e.category===void 0?{}:{show_category_name:e.category},...e.series===void 0?{}:{show_series_name:e.series},...e.format===void 0?{}:{number_format:e.format},...e.position===void 0?{}:{position:e.position},...e.size===void 0?{}:{size:e.size},...n?{color:n}:{}}}const E=e=>{const n=e.find(o=>o.sheet);return n?.sheet&&n.row!==void 0&&n.col!==void 0?n.sheet.lookAt(n.row,n.col).format:void 0};export function categoryNumbers(e,n,o){if(!o.categories)return;const t=y(e,n,o.categories);return{values:t.map(i=>R(i.value)),format:E(t)}}export function chartDef(e,n,o){const{spec:t}=o,i=P(t.type),d=o.categories?y(e,n,o.categories):void 0,r=o.series.map((m,v)=>{const u=t.series[v],w=y(e,n,m.values),A=m.name?y(e,n,m.name)[0]:void 0,x=m.x?y(e,n,m.x):i?d:void 0,z=u.format??E(w),s=N(u.color);return{name:(A?O(A):u.name)??`Series${String(v+1)}`,values:w.map(g=>R(g.value)),...x?{x:x.map(g=>R(g.value))}:{},...z===void 0?{}:{number_format:z},...s?{color:s}:{},...u.smooth===void 0?{}:{smooth:u.smooth},...u.line_width===void 0?{}:{line_width:u.line_width},...u.marker_size===void 0?{}:{marker_size:u.marker_size},...u.type===void 0?{}:{type:u.type},...u.secondary===!0?{secondary:!0}:{}}}),l=Math.max(0,...r.map(m=>m.values.length)),p=d?d.map(O):Array.from({length:l},(m,v)=>String(v+1)),b=o.title?y(e,n,o.title)[0]:void 0,a=b?O(b):t.title,_=G(t.labels),h=C(t.value_axis),f=C(t.category_axis),c=C(t.secondary_axis);return{type:t.type,categories:p,series:r,...a===void 0||a===""?{}:{title:a},...t.legend===void 0?{}:{legend:t.legend},..._?{labels:_}:{},...t.gap_width===void 0?{}:{gap_width:t.gap_width},...t.overlap===void 0?{}:{overlap:t.overlap},...t.vary_by_categories===void 0?{}:{vary_by_categories:t.vary_by_categories},...t.hole_size===void 0?{}:{hole_size:t.hole_size},...h?{value_axis:h}:{},...f?{category_axis:f}:{},...c?{secondary_axis:c}:{},font_size:t.size??SHEET_CHART_DEFAULTS.size,title_size:t.title_size??SHEET_CHART_DEFAULTS.titleSize,font_color:N(t.color)??{rgb:SHEET_CHART_DEFAULTS.ink}}}export const chartSize=e=>({width:e.width??SHEET_CHART_DEFAULTS.width,height:e.height??SHEET_CHART_DEFAULTS.height}),chartSvg=(e,n,o,t={})=>L(e,n,o,{pointsPerPixel:SHEET_CHART_DEFAULTS.pixelsToPoints,...t});export function chartAfter(e,n){const o=i=>i?.startsWith("=")===!0?n(i):i,t=o(e.title);return{...e,...t===void 0?{}:{title:t},...e.categories===void 0?{}:{categories:n(e.categories)},series:e.series.map(i=>{const d=o(i.name);return{...i,values:n(i.values),...i.x===void 0?{}:{x:n(i.x)},...d===void 0?{}:{name:d}}})}}function J(e,n,o,t){if(t){const i=t.data;if(o.top===i.top&&o.bottom===i.bottom&&o.left===o.right){const d=t.columns[o.left-t.at.col];if(d)return`${t.name}[${d.name}]`}}return`${n===e?"":k(n.name)}${T(o)}`}const K=(e,n,o,t)=>typeof e.value(n,o,t)=="number",Q=(e,n,o,t)=>{const i=e.value(n,o,t);if(typeof i=="string")return!0;const d=n.lookAt(o,t).format;return typeof i=="number"&&d!==void 0&&/[ymd]/iu.test(d)};export function chartOfRange(e,n,o,t,i){const d=t.bottom-t.top+1,r=t.right-t.left+1,l=n.tables.find(s=>U(s.area,t.top,t.left)),p=s=>J(o,n,s,l),b=P(i),a=d>1&&Array.from({length:r},(s,g)=>t.left+g).some(s=>!K(e,n,t.top,s)),_=r>1&&(b||Array.from({length:d-(a?1:0)},(s,g)=>g).every(s=>Q(e,n,t.top+(a?1:0)+s,t.left)||e.value(n,t.top+(a?1:0)+s,t.left)===null)),h=t.top+(a?1:0),f=t.left+(_?1:0);if(h>t.bottom||f>t.right)return;const c=!b&&!M(i)&&t.right-f>t.bottom-h,m=[],v=(s,g)=>e.value(n,s,g)===null?void 0:`=${n===o?"":k(n.name)}${F({row:s,col:g})}`,u=c?{first:h,last:t.bottom}:{first:f,last:t.right};for(let s=u.first;s<=u.last;s++){const g=c?{top:s,left:f,bottom:s,right:t.right}:{top:h,left:s,bottom:t.bottom,right:s},$=c?_?v(s,t.left):void 0:a?v(t.top,s):void 0;m.push({values:p(g),...$===void 0?{}:{name:$}})}const w=c?a?{top:t.top,left:f,bottom:t.top,right:t.right}:void 0:_?{top:h,left:t.left,bottom:t.bottom,right:t.left}:void 0,A=m.length>1&&!M(i),x=M(i)?m.slice(0,1):m,z=x.length===1?x[0]?.name:void 0;return{type:i,...w?{categories:p(w)}:{},series:x,...A||M(i)?{legend:"bottom"}:{},...z===void 0?{}:{title:z}}}function S(e,n,o){if(!o?.node)return;const t=e.eval(o.node,{sheet:n,row:0,col:0,dr:0,dc:0});return t instanceof j?{sheet:t.sheet,area:{top:t.top,left:t.left,bottom:Math.min(t.bottom,Math.max(t.top,t.sheet.lastRow)),right:t.right}}:void 0}export function chartDataRange(e,n,o){const t=[S(e,n,o.categories),...o.series.flatMap(r=>[S(e,n,r.values),S(e,n,r.name),S(e,n,r.x)])].filter(r=>r!==void 0),i=t[0];if(!i||t.some(r=>r.sheet!==i.sheet))return;const d={top:Math.min(...t.map(r=>r.area.top)),left:Math.min(...t.map(r=>r.area.left)),bottom:Math.max(...t.map(r=>r.area.bottom)),right:Math.max(...t.map(r=>r.area.right))};return`${i.sheet===n?"":k(i.sheet.name)}${T(d)}`}export function readDataRange(e,n,o){const t=o.lastIndexOf("!"),i=t<0?void 0:o.slice(0,t).replace(/^'|'$/gu,""),d=i===void 0?n:e.wb.sheet(i.replaceAll("''","'")),r=V(o.slice(t+1).replaceAll("$",""));return d&&r?{sheet:d,area:r}:void 0}export function chartPlace(e,n,o){const t=I(e.at)??{row:0,col:0};return{left:o(t.col)+(e.x??0),top:n(t.row)+(e.y??0),...chartSize(e)}}
@@ -19,14 +19,6 @@ export declare function csvText(value: Scalar, code: string | undefined, mode?:
19
19
  export declare function dataValue(value: Scalar, code: string | undefined, mode?: ValueMode): string | number | boolean | null;
20
20
  /** A sheet as CSV (RFC 4180: CRLF between records), from A1 to the last cell it uses. */
21
21
  export declare function csvOf(calc: Calc, sheet: Worksheet, o?: CsvOptions): string;
22
- /**
23
- * A sheet as a Markdown table, its first row the head: values as their
24
- * formats show them unless `values` is "data"; a column whose values are
25
- * all numbers is aligned right.
26
- */
27
- export declare function markdownOf(calc: Calc, sheet: Worksheet, o?: ValueOptions): string;
28
22
  /** A table's computed rows, by header. */
29
23
  export declare function tableRows(calc: Calc, table: Table, o?: ValueOptions): Record<string, string | number | boolean | null>[];
30
- /** The workbook as data: each sheet's rows, each table's rows by header. */
31
- export declare function jsonOf(calc: Calc, o?: ValueOptions): Record<string, unknown>;
32
24
  //# sourceMappingURL=export.d.ts.map
@@ -1,5 +1,3 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{writeCsv as S}from"@allyhub/formats";import{isDateCode as k,shownValue as b}from"./format.js";import{CellError as w,dateOf as j}from"./values.js";const y=t=>(t.split(";")[0]??"").replace(/"[^"]*"|\\.|_.|\*./gu,"").replace(/\[(?![hms]+\])[^\]]*\]/giu,""),h=new Map;function _(t){if(t===void 0)return;if(h.has(t))return h.get(t);let n;if(k(t)){const r=y(t).toLowerCase(),o=/\[(h+|m+|s+)\]/u.test(r),e=[...r.matchAll(/\[?([ydhms])\1*\]?|am\/pm|a\/p/gu)].map(c=>c[0]);let s=!1,i=!1,u=!1;for(const[c,a]of e.entries()){const f=a.replace(/[[\]]/gu,"")[0];if(f==="y"||f==="d")s=!0;else if(f==="h"||a.includes("/"))i=!0;else if(f==="s")i=!0,u=!0;else if(f==="m"){const l=e[c-1]?.replace(/[[\]]/gu,"")[0],m=e[c+1]?.replace(/[[\]]/gu,"")[0];a.startsWith("[")||l==="h"||m==="s"?i=!0:s=!0}}o?n={kind:"duration",seconds:u}:s&&i?n={kind:"datetime",seconds:u}:i?n={kind:"time",seconds:u}:s&&(n={kind:"date",seconds:!1})}return h.set(t,n),n}const $=864e5,A=2958465,d=(t,n=2)=>String(t).padStart(n,"0");export const excelNumber=t=>t===0?0:Number(t.toPrecision(15));function x(t,n,r=2){const o=Math.floor(t/1e3),e=t%1e3;let s=`${d(Math.floor(o/3600),r)}:${d(Math.floor(o/60)%60)}`;return(n||o%60!==0||e!==0)&&(s+=`:${d(o%60)}`),e!==0&&(s+=`.${d(e,3).replace(/0+$/u,"")}`),s}function T(t){const n=t<0?"-":"";let r=Math.abs(t);const o=Math.floor(r/36e5);r-=o*36e5;const e=Math.floor(r/6e4);r-=e*6e4;const s=[o>0?`${String(o)}H`:"",e>0?`${String(e)}M`:"",r>0?`${String(r/1e3)}S`:""].join("");return`${n}PT${s||"0S"}`}function M(t,n,r){const o=Math.round(t*$);if(n.kind==="duration")return r==="json"?T(o):`${o<0?"-":""}${x(Math.abs(o),n.seconds,1)}`;if(t<0||t>=A+1)return;const e=Math.floor(o/$),s=x(o-e*$,n.seconds||r==="json");if(e===0||n.kind==="time")return s;if(e===60)return;const{year:i,month:u,day:c}=j(e),a=`${d(i,4)}-${d(u)}-${d(c)}`;return n.kind==="date"?a:`${a}${r==="json"?"T":" "}${s}`}export function csvText(t,n,r="data"){if(t===null)return"";if(r==="shown")return b(t,n);if(typeof t=="boolean")return t?"TRUE":"FALSE";if(t instanceof w)return t.code;if(typeof t=="string")return t;const o=_(n);return(o&&M(t,o,"csv"))??String(excelNumber(t))}export function dataValue(t,n,r="data"){if(t===null)return null;if(r==="shown")return b(t,n);if(t instanceof w)return t.code;if(typeof t!="number")return t;const o=_(n);return(o&&M(t,o,"json"))??excelNumber(t)}const p=(t,n,r)=>t.lookAt(n,r).format;function g(t,n){const r=t.used;if(!r)return[];const o=[];for(let e=0;e<=r.bottom;e++){const s=[];for(let i=0;i<=r.right;i++)s.push(n(e,i));o.push(s)}return o}export function csvOf(t,n,r={}){const o=g(n,(e,s)=>csvText(t.value(n,e,s),p(n,e,s),r.values));return S(o,{delimiter:",",newline:`\r
3
- `,bom:r.bom??!0,finalNewline:!0})}const E=t=>t.replaceAll("|","\\|").replace(/\r?\n/gu,"<br>");export function markdownOf(t,n,r={}){const o=r.values??"shown",e=[],s=g(n,(f,l)=>{const m=t.value(n,f,l);return f>0&&m!==null&&(e[l]=(e[l]??!0)&&typeof m=="number"),csvText(m,p(n,f,l),o)}),[i,...u]=s;if(!i)return"";const c=f=>`| ${f.map(E).join(" | ")} |`,a=i.map((f,l)=>e[l]===!0?"---:":"---");return`${[c(i),`| ${a.join(" | ")} |`,...u.map(c)].join(`
4
- `)}
5
- `}export function tableRows(t,n,r={}){const{sheet:o,at:e}=n,s=[];for(let i=0;i<n.rows;i++){const u={};for(const c of n.columns){const a=e.row+1+i,f=e.col+c.index;u[c.name]=dataValue(t.value(o,a,f),p(o,a,f),r.values)}s.push(u)}return s}export function jsonOf(t,n={}){const{wb:r}=t,o={};for(const e of r.sheets){const s={};for(const i of e.tables)s[i.name]=tableRows(t,i,n);o[e.name]={rows:g(e,(i,u)=>dataValue(t.value(e,i,u),p(e,i,u),n.values)),...e.tables.length>0?{tables:s}:{}}}return{...r.title===void 0?{}:{title:r.title},sheets:o}}
2
+ import{writeCsv as b}from"@allyhub/formats";import{isDateCode as x,shownValue as p}from"./format.js";import{CellError as h,dateOf as k}from"./values.js";const y=t=>(t.split(";")[0]??"").replace(/"[^"]*"|\\.|_.|\*./gu,"").replace(/\[(?![hms]+\])[^\]]*\]/giu,""),d=new Map;function $(t){if(t===void 0)return;if(d.has(t))return d.get(t);let n;if(x(t)){const r=y(t).toLowerCase(),e=/\[(h+|m+|s+)\]/u.test(r),o=[...r.matchAll(/\[?([ydhms])\1*\]?|am\/pm|a\/p/gu)].map(u=>u[0]);let s=!1,i=!1,f=!1;for(const[u,c]of o.entries()){const a=c.replace(/[[\]]/gu,"")[0];if(a==="y"||a==="d")s=!0;else if(a==="h"||c.includes("/"))i=!0;else if(a==="s")i=!0,f=!0;else if(a==="m"){const M=o[u-1]?.replace(/[[\]]/gu,"")[0],S=o[u+1]?.replace(/[[\]]/gu,"")[0];c.startsWith("[")||M==="h"||S==="s"?i=!0:s=!0}}e?n={kind:"duration",seconds:f}:s&&i?n={kind:"datetime",seconds:f}:i?n={kind:"time",seconds:f}:s&&(n={kind:"date",seconds:!1})}return d.set(t,n),n}const m=864e5,A=2958465,l=(t,n=2)=>String(t).padStart(n,"0");export const excelNumber=t=>t===0?0:Number(t.toPrecision(15));function g(t,n,r=2){const e=Math.floor(t/1e3),o=t%1e3;let s=`${l(Math.floor(e/3600),r)}:${l(Math.floor(e/60)%60)}`;return(n||e%60!==0||o!==0)&&(s+=`:${l(e%60)}`),o!==0&&(s+=`.${l(o,3).replace(/0+$/u,"")}`),s}function T(t){const n=t<0?"-":"";let r=Math.abs(t);const e=Math.floor(r/36e5);r-=e*36e5;const o=Math.floor(r/6e4);r-=o*6e4;const s=[e>0?`${String(e)}H`:"",o>0?`${String(o)}M`:"",r>0?`${String(r/1e3)}S`:""].join("");return`${n}PT${s||"0S"}`}function w(t,n,r){const e=Math.round(t*m);if(n.kind==="duration")return r==="json"?T(e):`${e<0?"-":""}${g(Math.abs(e),n.seconds,1)}`;if(t<0||t>=A+1)return;const o=Math.floor(e/m),s=g(e-o*m,n.seconds||r==="json");if(o===0||n.kind==="time")return s;if(o===60)return;const{year:i,month:f,day:u}=k(o),c=`${l(i,4)}-${l(f)}-${l(u)}`;return n.kind==="date"?c:`${c}${r==="json"?"T":" "}${s}`}export function csvText(t,n,r="data"){if(t===null)return"";if(r==="shown")return p(t,n);if(typeof t=="boolean")return t?"TRUE":"FALSE";if(t instanceof h)return t.code;if(typeof t=="string")return t;const e=$(n);return(e&&w(t,e,"csv"))??String(excelNumber(t))}export function dataValue(t,n,r="data"){if(t===null)return null;if(r==="shown")return p(t,n);if(t instanceof h)return t.code;if(typeof t!="number")return t;const e=$(n);return(e&&w(t,e,"json"))??excelNumber(t)}const _=(t,n,r)=>t.lookAt(n,r).format;function j(t,n){const r=t.used;if(!r)return[];const e=[];for(let o=0;o<=r.bottom;o++){const s=[];for(let i=0;i<=r.right;i++)s.push(n(o,i));e.push(s)}return e}export function csvOf(t,n,r={}){const e=j(n,(o,s)=>csvText(t.value(n,o,s),_(n,o,s),r.values));return b(e,{delimiter:",",newline:`\r
3
+ `,bom:r.bom??!0,finalNewline:!0})}export function tableRows(t,n,r={}){const{sheet:e,at:o}=n,s=[];for(let i=0;i<n.rows;i++){const f={};for(const u of n.columns){const c=o.row+1+i,a=o.col+u.index;f[u.name]=dataValue(t.value(e,c,a),_(e,c,a),r.values)}s.push(f)}return s}
@@ -42,7 +42,16 @@ export type BinaryOp = "+" | "-" | "*" | "/" | "^" | "&" | "=" | "<>" | "<" | "<
42
42
  | " "
43
43
  /** Union, inside parentheses. */
44
44
  | ",";
45
- export type Node = {
45
+ /** The blanks a formula's text has around a part, kept so it prints as it was written. */
46
+ export interface Spacing {
47
+ /** Before it. */
48
+ before?: string;
49
+ /** Before a binary's operator, or before the closing bracket of a call, an invocation or parentheses. */
50
+ inner?: string;
51
+ /** After it, before the comma that ends it: an argument's. */
52
+ after?: string;
53
+ }
54
+ export type Node = ({
46
55
  kind: "number";
47
56
  value: number;
48
57
  raw: string;
@@ -96,6 +105,8 @@ export type Node = {
96
105
  } | {
97
106
  kind: "paren";
98
107
  arg: Node;
108
+ }) & {
109
+ space?: Spacing;
99
110
  };
100
111
  /** A formula that does not parse, and where in its text. */
101
112
  export interface ParseError {
@@ -1,6 +1,10 @@
1
1
  import type { Node } from "./ast.js";
2
2
  /** A formula as it reads `rows` down and `columns` across from where it is. */
3
3
  export declare function moveFormula(node: Node, rows: number, columns: number): Node;
4
- /** The same text for every cell a fill of one formula gives: its relative references as distances. */
4
+ /**
5
+ * The same text for every cell a fill of one formula gives: its relative
6
+ * references as distances. Written by hand: JSON.stringify with a replacer
7
+ * took 12 s of a sheet of 39,000 long formulas.
8
+ */
5
9
  export declare function relativeKey(node: Node, row: number, col: number): string;
6
10
  //# sourceMappingURL=move.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{MAX_COLUMNS as n,MAX_ROWS as l}from"../address.js";import{mapNode as a}from"./walk.js";function u(o,t,e){if(o.abs||t===0)return o;const r=o.index+t;return r<0||r>=e?void 0:{...o,index:r}}function m(o,t,e){const r=o.col&&u(o.col,e,n),i=o.col2&&u(o.col2,e,n),c=o.row&&u(o.row,t,l),f=o.row2&&u(o.row2,t,l),d=(s,w)=>s!==void 0&&w===void 0;return d(o.col,r)||d(o.col2,i)||d(o.row,c)||d(o.row2,f)?{kind:"error",code:"#REF!",...o.sheet===void 0?{}:{sheet:o.sheet}}:r===o.col&&i===o.col2&&c===o.row&&f===o.row2?o:{...o,...r?{col:r}:{},...i?{col2:i}:{},...c?{row:c}:{},...f?{row2:f}:{}}}export function moveFormula(o,t,e){return t===0&&e===0?o:a(o,r=>r.kind==="ref"?m(r,t,e):r)}export function relativeKey(o,t,e){return JSON.stringify(o,(r,i)=>{const c=i;return(r==="col"||r==="col2"||r==="row"||r==="row2")&&c?.abs===!1?[c.index-(r.startsWith("col")?e:t)]:i})}
2
+ import{MAX_COLUMNS as f,MAX_ROWS as p}from"../address.js";import{mapNode as d}from"./walk.js";function h(t,u,c){if(t.abs||u===0)return t;const r=t.index+u;return r<0||r>=c?void 0:{...t,index:r}}function l(t,u,c){const r=t.col&&h(t.col,c,f),s=t.col2&&h(t.col2,c,f),i=t.row&&h(t.row,u,p),a=t.row2&&h(t.row2,u,p),o=(e,n)=>e!==void 0&&n===void 0;return o(t.col,r)||o(t.col2,s)||o(t.row,i)||o(t.row2,a)?{kind:"error",code:"#REF!",...t.sheet===void 0?{}:{sheet:t.sheet}}:r===t.col&&s===t.col2&&i===t.row&&a===t.row2?t:{...t,...r?{col:r}:{},...s?{col2:s}:{},...i?{row:i}:{},...a?{row2:a}:{}}}export function moveFormula(t,u,c){return u===0&&c===0?t:d(t,r=>r.kind==="ref"?l(r,u,c):r)}export function relativeKey(t,u,c){const r=[],s=e=>e===void 0?"~":JSON.stringify(e),i=(e,n)=>e===void 0?"~":e.abs?`$${String(e.index)}`:`^${String(e.index-n)}`,a=e=>{r.push("(");for(const n of e)o(n);r.push(")")},o=e=>{switch(e.kind){case"number":r.push("n",String(e.value),s(e.raw));return;case"string":r.push("s",s(e.value));return;case"boolean":r.push(e.value?"T":"F");return;case"error":r.push("e",e.code,s(e.sheet));return;case"missing":r.push("m");return;case"ref":r.push(e.range?"R":"r",s(e.sheet),s(e.lastSheet),i(e.col,c),i(e.row,u),i(e.col2,c),i(e.row2,u));return;case"structured":r.push("t",s(e.table),JSON.stringify(e.sections),JSON.stringify(e.columns),e.thisRow?"@":"-");return;case"name":r.push("a",s(e.name),s(e.sheet));return;case"unary":case"postfix":r.push(e.kind==="unary"?"u":"p",e.op),o(e.arg);return;case"paren":r.push("{"),o(e.arg),r.push("}");return;case"binary":r.push("b",JSON.stringify(e.op)),o(e.left),o(e.right);return;case"call":r.push("c",s(e.name),s(e.written)),a(e.args);return;case"invoke":r.push("i"),o(e.callee),a(e.args);return;case"array":r.push("[");for(const n of e.rows)a(n);r.push("]");return}};return o(t),r.join(" ")}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{MAX_COLUMNS as y,MAX_ROWS as l,columnIndex as d}from"../address.js";import{errorOf as v}from"../values.js";import{TABLE_SECTIONS as N}from"./ast.js";class m extends Error{at;constructor(t,s){super(t),this.at=s}}const R=new Set(["=","<>","<","<=",">",">="]),b={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"&":2,"+":3,"-":3,"*":4,"/":4,"^":5},g=i=>i>="0"&&i<="9",p=i=>/[\p{L}_\\]/u.test(i)||i>="\uD800"&&i<="\uDFFF",w=i=>/[\p{L}\p{N}\p{M}_.?\\]/u.test(i)||i>="\uD800"&&i<="\uDFFF",f=(i,t)=>({index:i,abs:t});class C{at=0;s;constructor(t){this.s=t}blanks(){const t=this.at;for(;/\s/u.test(this.s.charAt(this.at));)this.at+=1;return this.at>t}peek(t){return this.s.startsWith(t,this.at)}eat(t){return this.peek(t)?(this.at+=t.length,!0):!1}stop(t,s=this.at){throw new m(t,s)}parse(){this.eat("="),this.blanks(),this.at>=this.s.length&&this.stop("a formula with nothing in it");const t=this.expression(0);return this.blanks(),this.at<this.s.length&&this.stop(`"${this.s.charAt(this.at)}" where an operator should be`),t}operator(){this.blanks();const t=this.s.slice(this.at,this.at+2);if(R.has(t))return t;const s=this.s.charAt(this.at);return b[s]===void 0?void 0:s}expression(t){let s=this.prefix();for(;;){const e=this.operator();if(e===void 0)return s;const n=b[e]??0;if(n<=t)return s;this.at+=e.length,this.blanks();const r=this.expression(n);s={kind:"binary",op:e,left:s,right:r}}}prefix(){this.blanks();for(const t of["-","+","@"])if(this.eat(t))return{kind:"unary",op:t,arg:this.prefix()};return this.postfix()}postfix(){let t=this.references();for(;;){const s=this.at;if(this.blanks(),this.eat("%")){t={kind:"postfix",op:"%",arg:t};continue}if(this.at=s,this.peek("#")&&!A(this.s,this.at)){this.at+=1,t={kind:"postfix",op:"#",arg:t};continue}if(this.peek("(")&&(t.kind==="call"||t.kind==="paren")){const{args:e}=this.call("");t={kind:"invoke",callee:t,args:e};continue}return t}}references(){let t=this.primary();for(;;){if(this.peek(":")){this.at+=1,this.blanks();const e=this.primary();t={kind:"binary",op:":",left:t,right:e};continue}const s=this.at;if(E(t)&&this.blanks()&&this.startsReference()){const e=this.primary();t={kind:"binary",op:" ",left:t,right:e};continue}return this.at=s,t}}startsReference(){const t=this.s.charAt(this.at);return t==="$"||t==="'"||t==="("||t==="["||p(t)}primary(){this.blanks();const t=this.s.charAt(this.at);if(t===""&&this.stop("the formula ends where a value should be"),t==="(")return this.parenthesis();if(t==="{")return this.arrayConstant();if(t==='"')return{kind:"string",value:this.text()};if(g(t)||t==="."){const s=k(this.s,this.at);return s?(this.at=s.end,{kind:"ref",...s.ref}):this.number()}return t==="#"?this.errorLiteral(void 0):t==="["?this.bracket(void 0):t==="$"||t==="'"||p(t)?this.word():this.stop(`"${t}" where a value should be`)}parenthesis(){const t=this.at;this.at+=1;let s=this.expression(0);for(this.blanks();this.eat(",");){const e=this.expression(0);s={kind:"binary",op:",",left:s,right:e},this.blanks()}return this.eat(")")||this.stop("a ( that is never closed",t),{kind:"paren",arg:s}}number(){const t=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/u.exec(this.s.slice(this.at));return t?(this.at+=t[0].length,{kind:"number",value:Number(t[0]),raw:t[0]}):this.stop("a number that is not one")}text(){const t=this.at;this.at+=1;let s="";for(;;){this.at>=this.s.length&&this.stop('a " that is never closed',t);const e=this.s.charAt(this.at);if(e==='"'){if(this.s.charAt(this.at+1)!=='"')return this.at+=1,s;this.at+=1}s+=e,this.at+=1}}errorLiteral(t){const s=A(this.s,this.at);return s===void 0?this.stop("a # that names no error"):(this.at+=s.length,{kind:"error",code:s,...t===void 0?{}:{sheet:t}})}arrayConstant(){const t=this.at;this.at+=1;const s=[[]];for(;;)if(this.blanks(),s[s.length-1]?.push(this.arrayItem()),this.blanks(),!this.eat(",")){if(this.eat(";")){s.push([]);continue}if(this.eat("}"))break;this.stop("a { that is never closed",t)}const e=s[0]?.length;return s.some(n=>n.length!==e)&&this.stop("an array whose rows are not all as long",t),{kind:"array",rows:s}}arrayItem(){const t=this.s.charAt(this.at);if(t==='"')return{kind:"string",value:this.text()};if(t==="#")return this.errorLiteral(void 0);if(t==="-"||t==="+")return this.at+=1,{kind:"unary",op:t,arg:this.number()};if(g(t)||t===".")return this.number();const s=this.name(),e=s.toUpperCase();return e==="TRUE"||e==="FALSE"?{kind:"boolean",value:e==="TRUE"}:this.stop(`${s} in an array: an array holds only constants`)}name(){const t=this.at;for(;this.at<this.s.length&&w(this.s.charAt(this.at));)this.at+=1;return this.s.slice(t,this.at)}quoted(){const t=this.at;this.at+=1;let s="";for(;;){this.at>=this.s.length&&this.stop("a ' that is never closed",t);const e=this.s.charAt(this.at);if(e==="'"){if(this.s.charAt(this.at+1)!=="'")return this.at+=1,s;this.at+=1}s+=e,this.at+=1}}word(){const t=this.sheetPrefix();if(t)return this.afterSheet(t.first,t.last);const s=k(this.s,this.at);if(s)return this.at=s.end,{kind:"ref",...s.ref};const e=x(this.s,this.at);if(e)return this.at=e.end,{kind:"ref",...e.ref};if(this.peek("$"))return this.stop('a "$" that is not part of a reference');const n=this.at,r=this.name();if(r==="")return this.stop(`"${this.s.charAt(n)}" in a name`);if(this.peek("("))return this.call(r);if(this.peek("["))return this.bracket(r);const h=r.toUpperCase();return h==="TRUE"||h==="FALSE"?{kind:"boolean",value:h==="TRUE"}:{kind:"name",name:r}}sheetPrefix(){const t=this.at;if(this.peek("'")){const e=this.quoted();if(!this.eat("!")){this.at=t;return}const n=e.indexOf(":");return n>0?{first:e.slice(0,n),last:e.slice(n+1)}:{first:e}}const s=this.name();if(s!==""&&this.eat("!"))return{first:s};if(s!==""&&this.eat(":")){const e=this.name();if(e!==""&&this.eat("!"))return{first:s,last:e}}this.at=t}afterSheet(t,s){const e={sheet:t,...s===void 0?{}:{lastSheet:s}};if(this.peek("#"))return this.errorLiteral(t);const n=k(this.s,this.at);if(n)return this.at=n.end,{kind:"ref",...e,...n.ref};const r=x(this.s,this.at);if(r)return this.at=r.end,{kind:"ref",...e,...r.ref};const h=this.name();return h===""?this.stop(`nothing after ${t}!`):{kind:"name",name:h,sheet:t}}call(t){const s=this.at;this.at+=1;const e=[];this.blanks();const n=()=>({kind:"call",name:t.toUpperCase(),written:t,args:e});if(this.eat(")"))return n();for(;;)if(this.blanks(),this.peek(",")||this.peek(")")?e.push({kind:"missing"}):e.push(this.expression(0)),this.blanks(),!this.eat(",")){if(this.eat(")"))return n();this.stop(`a ( of ${t.toUpperCase()} that is never closed`,s)}}columnName(){let t="";for(;;){this.at>=this.s.length&&this.stop("a [ that is never closed");const s=this.s.charAt(this.at);if(s==="]")return t;if(s==="["&&this.stop("a [ inside a column's name"),s==="'"){this.at+=1,t+=this.s.charAt(this.at),this.at+=1;continue}t+=s,this.at+=1}}bracket(t){const s=this.at;this.at+=1;const e={kind:"structured",...t===void 0?{}:{table:t},sections:[],columns:[],thisRow:!1};if(this.eat("]"))return e;if(!(this.peek("[")||this.peek("#")||this.peek("@"))){const r=this.columnName();return this.at+=1,t===void 0&&/[!']/u.test(this.s.charAt(this.at))&&this.stop("a formula that reaches into another workbook",s),t===void 0&&p(this.s.charAt(this.at))&&this.stop("a formula that reaches into another workbook",s),e.columns=[r.trim()],e}return this.eat("@")?(e.thisRow=!0,this.eat("]")||(this.peek("[")?this.items(e):e.columns=[this.columnName().trim()],this.eat("]")||this.stop("a [ that is never closed",s)),e):(this.items(e),this.eat("]")||this.stop("a [ that is never closed",s),e)}items(t){for(;;){if(this.blanks(),this.peek("#"))this.section(t);else if(this.eat("["))if(this.peek("#"))this.section(t),this.eat("]")||this.stop("a [ that is never closed");else{const s=this.columnName().trim();this.at+=1,t.columns.push(s),this.eat(":")&&(this.eat("[")||this.stop("a column's name after :"),t.columns.push(this.columnName().trim()),this.at+=1)}else this.stop("a column or a section of a table");if(this.blanks(),!this.eat(","))return}}section(t){const s=this.s.slice(this.at).toLowerCase(),e=N.find(n=>s.startsWith(n.toLowerCase()));e===void 0&&this.stop("a section of a table that is not one"),this.at+=e.length,e==="#This Row"?t.thisRow=!0:t.sections.push(e)}}const E=i=>i.kind==="ref"||i.kind==="name"||i.kind==="structured"||i.kind==="call"||i.kind==="paren"||i.kind==="binary"&&(i.op===":"||i.op===" ");function A(i,t){const s=/^#[A-Za-z0-9_/]+[!?]?/u.exec(i.slice(t));return s?v(s[0])?.code:void 0}const u=(i,t)=>{const s=i.charAt(t);return s!==""&&(w(s)||s==="("||s==="!"||s==="[")};function x(i,t){const s=i.slice(t),e=/^(\$?)([A-Za-z]{1,3}):(\$?)([A-Za-z]{1,3})/u.exec(s);if(e){const a=t+e[0].length,o=d(e[2]??""),c=d(e[4]??"");if(o!==void 0&&c!==void 0&&!u(i,a))return{ref:{col:f(o,e[1]==="$"),col2:f(c,e[3]==="$"),range:!0},end:a}}const n=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d*)/u.exec(s);if(!n)return;const r=$(n),h=t+n[0].length;if(!(!r||u(i,h))){if(i.charAt(h)===":"){const a=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d*)/u.exec(i.slice(h+1));if(a){const o=$(a),c=h+1+a[0].length;if(o&&!u(i,c))return{ref:{...r,col2:o.col,row2:o.row,range:!0},end:c}}}return{ref:{...r,range:!1},end:h}}}function $(i){const t=d(i[2]??""),s=Number(i[4])-1;if(!(t===void 0||t>=y||s>=l))return{col:f(t,i[1]==="$"),row:f(s,i[3]==="$")}}function k(i,t){const s=/^(\$?)([1-9]\d*):(\$?)([1-9]\d*)/u.exec(i.slice(t));if(!s)return;const e=t+s[0].length,n=Number(s[2])-1,r=Number(s[4])-1;if(!(n>=l||r>=l||u(i,e)))return{ref:{row:f(n,s[1]==="$"),row2:f(r,s[3]==="$"),range:!0},end:e}}export function parseFormula(i){try{return{ok:!0,node:new C(i).parse()}}catch(t){if(t instanceof m)return{ok:!1,error:{message:t.message,at:t.at}};throw t}}
2
+ import{MAX_COLUMNS as N,MAX_ROWS as d,columnIndex as p}from"../address.js";import{errorOf as R}from"../values.js";import{TABLE_SECTIONS as C}from"./ast.js";class g extends Error{at;constructor(t,s){super(t),this.at=s}}const E=new Set(["=","<>","<","<=",">",">="]),w={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"&":2,"+":3,"-":3,"*":4,"/":4,"^":5},x=i=>i>="0"&&i<="9",m=i=>/[\p{L}_\\]/u.test(i)||i>="\uD800"&&i<="\uDFFF",A=i=>/[\p{L}\p{N}\p{M}_.?\\]/u.test(i)||i>="\uD800"&&i<="\uDFFF",u=(i,t)=>({index:i,abs:t});function f(i,t){const s={};return t.before&&(s.before=t.before),t.inner&&(s.inner=t.inner),t.after&&(s.after=t.after),Object.keys(s).length===0?i:{...i,space:{...i.space,...s}}}class L{at=0;s;constructor(t){this.s=t}blanks(){return this.space()!==""}space(){const t=this.at;for(;/\s/u.test(this.s.charAt(this.at));)this.at+=1;return this.s.slice(t,this.at)}peek(t){return this.s.startsWith(t,this.at)}eat(t){return this.peek(t)?(this.at+=t.length,!0):!1}stop(t,s=this.at){throw new g(t,s)}parse(){this.eat("="),this.s.slice(this.at).trim()===""&&this.stop("a formula with nothing in it",this.s.length);const t=this.expression(0);return this.blanks(),this.at<this.s.length&&this.stop(`"${this.s.charAt(this.at)}" where an operator should be`),t}operator(){const t=this.at,s=this.space(),e=this.s.slice(this.at,this.at+2),n=this.s.charAt(this.at);return this.at=t,E.has(e)?{op:e,inner:s}:w[n]===void 0?void 0:{op:n,inner:s}}expression(t){let s=this.prefix();for(;;){const e=this.operator();if(e===void 0)return s;const{op:n,inner:r}=e,h=w[n]??0;if(h<=t)return s;this.at+=r.length+n.length;const a=this.expression(h);s=f({kind:"binary",op:n,left:s,right:a},{inner:r})}}prefix(){const t=this.at,s=this.space();for(const e of["-","+","@"])if(this.eat(e))return f({kind:"unary",op:e,arg:this.prefix()},{before:s});return this.at=t,this.postfix()}postfix(){let t=this.references();for(;;){const s=this.at;if(this.blanks(),this.eat("%")){t={kind:"postfix",op:"%",arg:t};continue}if(this.at=s,this.peek("#")&&!$(this.s,this.at)){this.at+=1,t={kind:"postfix",op:"#",arg:t};continue}if(this.peek("(")&&(t.kind==="call"||t.kind==="paren")){const{args:e}=this.call("");t={kind:"invoke",callee:t,args:e};continue}return t}}references(){let t=this.primary();for(;;){if(this.peek(":")){this.at+=1,this.blanks();const e=this.primary();t={kind:"binary",op:":",left:t,right:e};continue}const s=this.at;if(S(t)&&this.blanks()&&this.startsReference()){const e=this.primary();t={kind:"binary",op:" ",left:t,right:e};continue}return this.at=s,t}}startsReference(){const t=this.s.charAt(this.at);return t==="$"||t==="'"||t==="("||t==="["||m(t)}primary(){const t=this.space();return f(this.bare(),{before:t})}bare(){const t=this.s.charAt(this.at);if(t===""&&this.stop("the formula ends where a value should be"),t==="(")return this.parenthesis();if(t==="{")return this.arrayConstant();if(t==='"')return{kind:"string",value:this.text()};if(x(t)||t==="."){const s=k(this.s,this.at);return s?(this.at=s.end,{kind:"ref",...s.ref}):this.number()}return t==="#"?this.errorLiteral(void 0):t==="["?this.bracket(void 0):t==="$"||t==="'"||m(t)?this.word():this.stop(`"${t}" where a value should be`)}parenthesis(){const t=this.at;this.at+=1;let s=this.expression(0),e=this.space();for(;this.eat(",");){const n=this.expression(0);s=f({kind:"binary",op:",",left:s,right:n},{inner:e}),e=this.space()}return this.eat(")")||this.stop("a ( that is never closed",t),f({kind:"paren",arg:s},{inner:e})}number(){const t=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/u.exec(this.s.slice(this.at));return t?(this.at+=t[0].length,{kind:"number",value:Number(t[0]),raw:t[0]}):this.stop("a number that is not one")}text(){const t=this.at;this.at+=1;let s="";for(;;){this.at>=this.s.length&&this.stop('a " that is never closed',t);const e=this.s.charAt(this.at);if(e==='"'){if(this.s.charAt(this.at+1)!=='"')return this.at+=1,s;this.at+=1}s+=e,this.at+=1}}errorLiteral(t){const s=$(this.s,this.at);return s===void 0?this.stop("a # that names no error"):(this.at+=s.length,{kind:"error",code:s,...t===void 0?{}:{sheet:t}})}arrayConstant(){const t=this.at;this.at+=1;const s=[[]];for(;;)if(this.blanks(),s[s.length-1]?.push(this.arrayItem()),this.blanks(),!this.eat(",")){if(this.eat(";")){s.push([]);continue}if(this.eat("}"))break;this.stop("a { that is never closed",t)}const e=s[0]?.length;return s.some(n=>n.length!==e)&&this.stop("an array whose rows are not all as long",t),{kind:"array",rows:s}}arrayItem(){const t=this.s.charAt(this.at);if(t==='"')return{kind:"string",value:this.text()};if(t==="#")return this.errorLiteral(void 0);if(t==="-"||t==="+")return this.at+=1,{kind:"unary",op:t,arg:this.number()};if(x(t)||t===".")return this.number();const s=this.name(),e=s.toUpperCase();return e==="TRUE"||e==="FALSE"?{kind:"boolean",value:e==="TRUE"}:this.stop(`${s} in an array: an array holds only constants`)}name(){const t=this.at;for(;this.at<this.s.length&&A(this.s.charAt(this.at));)this.at+=1;return this.s.slice(t,this.at)}quoted(){const t=this.at;this.at+=1;let s="";for(;;){this.at>=this.s.length&&this.stop("a ' that is never closed",t);const e=this.s.charAt(this.at);if(e==="'"){if(this.s.charAt(this.at+1)!=="'")return this.at+=1,s;this.at+=1}s+=e,this.at+=1}}word(){const t=this.sheetPrefix();if(t)return this.afterSheet(t.first,t.last);const s=k(this.s,this.at);if(s)return this.at=s.end,{kind:"ref",...s.ref};const e=y(this.s,this.at);if(e)return this.at=e.end,{kind:"ref",...e.ref};if(this.peek("$"))return this.stop('a "$" that is not part of a reference');const n=this.at,r=this.name();if(r==="")return this.stop(`"${this.s.charAt(n)}" in a name`);if(this.peek("("))return this.call(r);if(this.peek("["))return this.bracket(r);const h=r.toUpperCase();return h==="TRUE"||h==="FALSE"?{kind:"boolean",value:h==="TRUE"}:{kind:"name",name:r}}sheetPrefix(){const t=this.at;if(this.peek("'")){const e=this.quoted();if(!this.eat("!")){this.at=t;return}const n=e.indexOf(":");return n>0?{first:e.slice(0,n),last:e.slice(n+1)}:{first:e}}const s=this.name();if(s!==""&&this.eat("!"))return{first:s};if(s!==""&&this.eat(":")){const e=this.name();if(e!==""&&this.eat("!"))return{first:s,last:e}}this.at=t}afterSheet(t,s){const e={sheet:t,...s===void 0?{}:{lastSheet:s}};if(this.peek("#"))return this.errorLiteral(t);const n=k(this.s,this.at);if(n)return this.at=n.end,{kind:"ref",...e,...n.ref};const r=y(this.s,this.at);if(r)return this.at=r.end,{kind:"ref",...e,...r.ref};const h=this.name();return h===""?this.stop(`nothing after ${t}!`):{kind:"name",name:h,sheet:t}}call(t){const s=this.at;this.at+=1;const e=[],n=a=>f({kind:"call",name:t.toUpperCase(),written:t,args:e},{inner:a}),r=this.at,h=this.space();if(this.eat(")"))return n(h);for(this.at=r;;){const a=this.at,c=this.space();let o;this.peek(",")||this.peek(")")?o=f({kind:"missing"},{before:c}):(this.at=a,o=this.expression(0));const b=this.space();if(this.eat(",")){e.push(f(o,{after:b}));continue}if(e.push(o),this.eat(")"))return n(b);this.stop(`a ( of ${t.toUpperCase()} that is never closed`,s)}}columnName(){let t="";for(;;){this.at>=this.s.length&&this.stop("a [ that is never closed");const s=this.s.charAt(this.at);if(s==="]")return t;if(s==="["&&this.stop("a [ inside a column's name"),s==="'"){this.at+=1,t+=this.s.charAt(this.at),this.at+=1;continue}t+=s,this.at+=1}}bracket(t){const s=this.at;this.at+=1;const e={kind:"structured",...t===void 0?{}:{table:t},sections:[],columns:[],thisRow:!1};if(this.eat("]"))return e;if(!(this.peek("[")||this.peek("#")||this.peek("@"))){const r=this.columnName();return this.at+=1,t===void 0&&/[!']/u.test(this.s.charAt(this.at))&&this.stop("a formula that reaches into another workbook",s),t===void 0&&m(this.s.charAt(this.at))&&this.stop("a formula that reaches into another workbook",s),e.columns=[r.trim()],e}return this.eat("@")?(e.thisRow=!0,this.eat("]")||(this.peek("[")?this.items(e):e.columns=[this.columnName().trim()],this.eat("]")||this.stop("a [ that is never closed",s)),e):(this.items(e),this.eat("]")||this.stop("a [ that is never closed",s),e)}items(t){for(;;){if(this.blanks(),this.peek("#"))this.section(t);else if(this.eat("["))if(this.peek("#"))this.section(t),this.eat("]")||this.stop("a [ that is never closed");else{const s=this.columnName().trim();this.at+=1,t.columns.push(s),this.eat(":")&&(this.eat("[")||this.stop("a column's name after :"),t.columns.push(this.columnName().trim()),this.at+=1)}else this.stop("a column or a section of a table");if(this.blanks(),!this.eat(","))return}}section(t){const s=this.s.slice(this.at).toLowerCase(),e=C.find(n=>s.startsWith(n.toLowerCase()));e===void 0&&this.stop("a section of a table that is not one"),this.at+=e.length,e==="#This Row"?t.thisRow=!0:t.sections.push(e)}}const S=i=>i.kind==="ref"||i.kind==="name"||i.kind==="structured"||i.kind==="call"||i.kind==="paren"||i.kind==="binary"&&(i.op===":"||i.op===" ");function $(i,t){const s=/^#[A-Za-z0-9_/]+[!?]?/u.exec(i.slice(t));return s?R(s[0])?.code:void 0}const l=(i,t)=>{const s=i.charAt(t);return s!==""&&(A(s)||s==="("||s==="!"||s==="[")};function y(i,t){const s=i.slice(t),e=/^(\$?)([A-Za-z]{1,3}):(\$?)([A-Za-z]{1,3})/u.exec(s);if(e){const a=t+e[0].length,c=p(e[2]??""),o=p(e[4]??"");if(c!==void 0&&o!==void 0&&!l(i,a))return{ref:{col:u(c,e[1]==="$"),col2:u(o,e[3]==="$"),range:!0},end:a}}const n=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d*)/u.exec(s);if(!n)return;const r=v(n),h=t+n[0].length;if(!(!r||l(i,h))){if(i.charAt(h)===":"){const a=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d*)/u.exec(i.slice(h+1));if(a){const c=v(a),o=h+1+a[0].length;if(c&&!l(i,o))return{ref:{...r,col2:c.col,row2:c.row,range:!0},end:o}}}return{ref:{...r,range:!1},end:h}}}function v(i){const t=p(i[2]??""),s=Number(i[4])-1;if(!(t===void 0||t>=N||s>=d))return{col:u(t,i[1]==="$"),row:u(s,i[3]==="$")}}function k(i,t){const s=/^(\$?)([1-9]\d*):(\$?)([1-9]\d*)/u.exec(i.slice(t));if(!s)return;const e=t+s[0].length,n=Number(s[2])-1,r=Number(s[4])-1;if(!(n>=d||r>=d||l(i,e)))return{ref:{row:u(n,s[1]==="$"),row2:u(r,s[3]==="$"),range:!0},end:e}}export function parseFormula(i){try{return{ok:!0,node:new L(i).parse()}}catch(t){if(t instanceof g)return{ok:!1,error:{message:t.message,at:t.at}};throw t}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{columnLetter as l}from"../address.js";const $=e=>`${e.abs?"$":""}${l(e.index)}`,s=e=>`${e.abs?"$":""}${String(e.index+1)}`;export function sheetPrefix(e,r){const t=r===void 0?e:`${e}:${r}`;return/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(e)&&!/^[A-Za-z]{1,3}\d+$/u.test(e)&&!/^(?:TRUE|FALSE)$/iu.test(e)&&(r===void 0||/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(r))?`${t}!`:`'${t.replaceAll("'","''")}'!`}function f(e){const r=e.sheet===void 0?"":sheetPrefix(e.sheet,e.lastSheet);if(e.row===void 0&&e.col&&e.col2)return`${r}${$(e.col)}:${$(e.col2)}`;if(e.col===void 0&&e.row&&e.row2)return`${r}${s(e.row)}:${s(e.row2)}`;if(!e.col||!e.row)return`${r}#REF!`;const t=`${$(e.col)}${s(e.row)}`;return e.col2&&e.row2?`${r}${t}:${$(e.col2)}${s(e.row2)}`:`${r}${t}`}const c=e=>e.replace(/([[\]#'@])/gu,"'$1"),p=e=>/^[\p{L}\p{N}_]+$/u.test(e);function d(e){const r=e.table??"",[t,i]=e.columns,u=e.columns.map(n=>`[${c(n)}]`).join(":");if(e.sections.length===0)return e.thisRow?t===void 0?`${r}[@]`:i!==void 0?`${r}[@${u}]`:`${r}[@${p(t)?c(t):u}]`:t===void 0?r===""?"[]":r:i!==void 0?`${r}[${u}]`:`${r}[${c(t)}]`;if(t===void 0&&e.sections.length===1)return`${r}[${e.sections[0]??""}]`;const a=e.sections.map(n=>`[${n}]`);return u!==""&&a.push(u),`${r}[${a.join(",")}]`}function o(e){switch(e.kind){case"number":return e.raw;case"string":return`"${e.value.replaceAll('"','""')}"`;case"boolean":return e.value?"TRUE":"FALSE";case"error":return`${e.sheet===void 0?"":sheetPrefix(e.sheet)}${e.code}`;case"missing":return"";case"ref":return f(e);case"structured":return d(e);case"name":return`${e.sheet===void 0?"":sheetPrefix(e.sheet)}${e.name}`;case"unary":return`${e.op}${o(e.arg)}`;case"postfix":return`${o(e.arg)}${e.op}`;case"binary":return`${o(e.left)}${e.op}${o(e.right)}`;case"call":return`${e.written}(${e.args.map(o).join(",")})`;case"invoke":return`${o(e.callee)}(${e.args.map(o).join(",")})`;case"array":return`{${e.rows.map(r=>r.map(o).join(",")).join(";")}}`;case"paren":return`(${o(e.arg)})`}}export const printFormula=e=>`=${o(e)}`;
2
+ import{columnLetter as f}from"../address.js";const n=e=>`${e.abs?"$":""}${f(e.index)}`,s=e=>`${e.abs?"$":""}${String(e.index+1)}`;export function sheetPrefix(e,r){const t=r===void 0?e:`${e}:${r}`;return/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(e)&&!/^[A-Za-z]{1,3}\d+$/u.test(e)&&!/^(?:TRUE|FALSE)$/iu.test(e)&&(r===void 0||/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(r))?`${t}!`:`'${t.replaceAll("'","''")}'!`}function l(e){const r=e.sheet===void 0?"":sheetPrefix(e.sheet,e.lastSheet);if(e.row===void 0&&e.col&&e.col2)return`${r}${n(e.col)}:${n(e.col2)}`;if(e.col===void 0&&e.row&&e.row2)return`${r}${s(e.row)}:${s(e.row2)}`;if(!e.col||!e.row)return`${r}#REF!`;const t=`${n(e.col)}${s(e.row)}`;return e.col2&&e.row2?`${r}${t}:${n(e.col2)}${s(e.row2)}`:`${r}${t}`}const i=e=>e.replace(/([[\]#'@])/gu,"'$1"),p=e=>/^[\p{L}\p{N}_]+$/u.test(e);function d(e){const r=e.table??"",[t,u]=e.columns,$=e.columns.map(c=>`[${i(c)}]`).join(":");if(e.sections.length===0)return e.thisRow?t===void 0?`${r}[@]`:u!==void 0?`${r}[@${$}]`:`${r}[@${p(t)?i(t):$}]`:t===void 0?r===""?"[]":r:u!==void 0?`${r}[${$}]`:`${r}[${i(t)}]`;if(t===void 0&&e.sections.length===1)return`${r}[${e.sections[0]??""}]`;const a=e.sections.map(c=>`[${c}]`);return $!==""&&a.push($),`${r}[${a.join(",")}]`}function o(e){const{before:r="",after:t=""}=e.space??{};return`${r}${m(e)}${t}`}function m(e){const r=e.space?.inner??"";switch(e.kind){case"number":return e.raw;case"string":return`"${e.value.replaceAll('"','""')}"`;case"boolean":return e.value?"TRUE":"FALSE";case"error":return`${e.sheet===void 0?"":sheetPrefix(e.sheet)}${e.code}`;case"missing":return"";case"ref":return l(e);case"structured":return d(e);case"name":return`${e.sheet===void 0?"":sheetPrefix(e.sheet)}${e.name}`;case"unary":return`${e.op}${o(e.arg)}`;case"postfix":return`${o(e.arg)}${e.op}`;case"binary":return`${o(e.left)}${r}${e.op}${o(e.right)}`;case"call":return`${e.written}(${e.args.map(o).join(",")}${r})`;case"invoke":return`${o(e.callee)}(${e.args.map(o).join(",")}${r})`;case"array":return`{${e.rows.map(t=>t.map(o).join(",")).join(";")}}`;case"paren":return`(${o(e.arg)}${r})`}}export const printFormula=e=>`=${o(e)}`;
@@ -1,5 +1,6 @@
1
1
  export * from "./address.js";
2
2
  export { patchCsv } from "./patch.js";
3
+ export { printedFacts, printedLines, type PrintedFacts } from "./printed.js";
3
4
  export * from "./values.js";
4
5
  export * from "./workbook.js";
5
6
  export * from "./calc/remote.js";
@@ -13,12 +14,12 @@ export { parseFormula } from "./formula/parse.js";
13
14
  export { printFormula, sheetPrefix } from "./formula/print.js";
14
15
  export { moveFormula } from "./formula/move.js";
15
16
  export { rewriteFormula, type StructureEdit } from "./formula/rewrite.js";
16
- export { Calc, seededRandom, type CalcOptions, type CellChange, } from "./calc/engine.js";
17
+ export { Calc, ITERATION_DEFAULTS, seededRandom, type CalcOptions, type CellChange, type Iterated, } from "./calc/engine.js";
17
18
  export { analyse, type Analysis } from "./calc/analyse.js";
18
19
  export { FUNCTIONS } from "./calc/functions/index.js";
19
20
  export { Reference } from "./calc/types.js";
20
21
  export { checkWorkbook, placeName, type CheckedWorkbook } from "./check.js";
21
- export { csvOf, csvText, dataValue, excelNumber, jsonOf, markdownOf, tableRows, type CsvOptions, type ValueMode, type ValueOptions, } from "./export.js";
22
+ export { csvOf, csvText, dataValue, excelNumber, tableRows, type CsvOptions, type ValueMode, type ValueOptions, } from "./export.js";
22
23
  export { generalForms, generalText, isDateCode, shownColor, shownValue, } from "./format.js";
23
24
  export { DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, headerFooterHtml, sheetHtml, SheetPrint, type PageFields, type PrintHtmlOptions, type SheetHtml, type SheetHtmlOptions, } from "./html.js";
24
25
  export { PAPERS, PRINT_DEFAULTS, paginate, type PaginateOptions, type PrintJob, type PrintedPage, type SheetPages, } from "./paginate.js";
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export*from"./address.js";export{patchCsv}from"./patch.js";export*from"./values.js";export*from"./workbook.js";export*from"./calc/remote.js";export*from"./calc/server.js";export{CODE as SHEET_CODE,ENTRY as SHEET_ENTRY,codeOf,dataFilesOf,readSheetFile}from"./file.js";export{GENERATED,ordinarySheet,typedNumbers,withGenerated}from"./generated.js";export{applyScenario,cellOfName,scenarioNames,scenariosByCell}from"./scenario.js";export{fileCells,hasFiles,isPicture,pictureHeight,pictureSize}from"./files.js";export*from"./formula/ast.js";export{parseFormula}from"./formula/parse.js";export{printFormula,sheetPrefix}from"./formula/print.js";export{moveFormula}from"./formula/move.js";export{rewriteFormula}from"./formula/rewrite.js";export{Calc,seededRandom}from"./calc/engine.js";export{analyse}from"./calc/analyse.js";export{FUNCTIONS}from"./calc/functions/index.js";export{Reference}from"./calc/types.js";export{checkWorkbook,placeName}from"./check.js";export{csvOf,csvText,dataValue,excelNumber,jsonOf,markdownOf,tableRows}from"./export.js";export{generalForms,generalText,isDateCode,shownColor,shownValue}from"./format.js";export{DEFAULT_COLUMN_WIDTH,DEFAULT_ROW_HEIGHT,headerFooterHtml,sheetHtml,SheetPrint}from"./html.js";export{PAPERS,PRINT_DEFAULTS,paginate}from"./paginate.js";export{DEFAULT_TABLE_STYLE,tableStyleLook,tableStyleOf}from"./table-style.js";export{PROFILE_TOP,profileTable}from"./profile.js";export{importRows}from"./import.js";export{patchYaml,writeYaml}from"./write.js";export*from"./edit.js";export*from"./arrange.js";export{NO_LOOK,autoFill,copyLooks,fillDownTo,moveCells,pasteLooks}from"./fill.js";export{seriesAfter}from"./series.js";export{compareForSort,hasHeader,sortCells,sortedOrder,sortedRows}from"./sort.js";export{filterChoices,filteredRows,regionAround}from"./filter.js";export{Rules,colorBetween,compareValues,holds,iconShape}from"./rules.js";export{choicesIn,invalidCells,joinChoices,listValues,separatorOf,valid}from"./validate.js";export{freeColumn,restructure,tableShape,uniqueColumn,withColumnsUpTo}from"./structure.js";export{SHEET_CHART_DEFAULTS,chartAfter,chartDataRange,chartDef,chartOfRange,chartPlace,chartSize,chartSvg,readDataRange}from"./chart.js";export{INSPECT_DEFAULTS,SHEET_FACT_KINDS,inspectWorkbook}from"./inspect.js";export{DIFF_DEFAULTS,diffWorkbooks}from"./diff.js";
2
+ export*from"./address.js";export{patchCsv}from"./patch.js";export{printedFacts,printedLines}from"./printed.js";export*from"./values.js";export*from"./workbook.js";export*from"./calc/remote.js";export*from"./calc/server.js";export{CODE as SHEET_CODE,ENTRY as SHEET_ENTRY,codeOf,dataFilesOf,readSheetFile}from"./file.js";export{GENERATED,ordinarySheet,typedNumbers,withGenerated}from"./generated.js";export{applyScenario,cellOfName,scenarioNames,scenariosByCell}from"./scenario.js";export{fileCells,hasFiles,isPicture,pictureHeight,pictureSize}from"./files.js";export*from"./formula/ast.js";export{parseFormula}from"./formula/parse.js";export{printFormula,sheetPrefix}from"./formula/print.js";export{moveFormula}from"./formula/move.js";export{rewriteFormula}from"./formula/rewrite.js";export{Calc,ITERATION_DEFAULTS,seededRandom}from"./calc/engine.js";export{analyse}from"./calc/analyse.js";export{FUNCTIONS}from"./calc/functions/index.js";export{Reference}from"./calc/types.js";export{checkWorkbook,placeName}from"./check.js";export{csvOf,csvText,dataValue,excelNumber,tableRows}from"./export.js";export{generalForms,generalText,isDateCode,shownColor,shownValue}from"./format.js";export{DEFAULT_COLUMN_WIDTH,DEFAULT_ROW_HEIGHT,headerFooterHtml,sheetHtml,SheetPrint}from"./html.js";export{PAPERS,PRINT_DEFAULTS,paginate}from"./paginate.js";export{DEFAULT_TABLE_STYLE,tableStyleLook,tableStyleOf}from"./table-style.js";export{PROFILE_TOP,profileTable}from"./profile.js";export{importRows}from"./import.js";export{patchYaml,writeYaml}from"./write.js";export*from"./edit.js";export*from"./arrange.js";export{NO_LOOK,autoFill,copyLooks,fillDownTo,moveCells,pasteLooks}from"./fill.js";export{seriesAfter}from"./series.js";export{compareForSort,hasHeader,sortCells,sortedOrder,sortedRows}from"./sort.js";export{filterChoices,filteredRows,regionAround}from"./filter.js";export{Rules,colorBetween,compareValues,holds,iconShape}from"./rules.js";export{choicesIn,invalidCells,joinChoices,listValues,separatorOf,valid}from"./validate.js";export{freeColumn,restructure,tableShape,uniqueColumn,withColumnsUpTo}from"./structure.js";export{SHEET_CHART_DEFAULTS,chartAfter,chartDataRange,chartDef,chartOfRange,chartPlace,chartSize,chartSvg,readDataRange}from"./chart.js";export{INSPECT_DEFAULTS,SHEET_FACT_KINDS,inspectWorkbook}from"./inspect.js";export{DIFF_DEFAULTS,diffWorkbooks}from"./diff.js";
@@ -1,4 +1,4 @@
1
- import type { Calc } from "./calc/engine.js";
1
+ import { type Calc } from "./calc/engine.js";
2
2
  /**
3
3
  * What each kind of a workbook's facts measures: `allyhub inspect`'s, never
4
4
  * problems. Each kind is the sheet extension's (its manifest's
@@ -74,6 +74,16 @@ export interface SheetFactData {
74
74
  "sheet-ordinary": {
75
75
  sheet: string;
76
76
  };
77
+ /** What iterative calculation did with the workbook's circular references. */
78
+ "sheet-iteration": {
79
+ /** Formula cells computed each round: those around a circular reference and what reads them. */
80
+ cells: number;
81
+ iterations: number;
82
+ max_iterations: number;
83
+ /** The most a value moved in the last round; null where one changed kind (a number to an error). */
84
+ change: number | null;
85
+ max_change: number;
86
+ };
77
87
  }
78
88
  export type SheetFactKind = keyof SheetFactData;
79
89
  export type SheetFinding = {
@@ -82,7 +92,7 @@ export type SheetFinding = {
82
92
  data: SheetFactData[K];
83
93
  };
84
94
  }[SheetFactKind];
85
- export declare const SHEET_FACT_KINDS: readonly ["sheet-error", "sheet-number", "sheet-unlike", "sheet-exception", "sheet-unused", "sheet-invalid", "sheet-typed", "sheet-ordinary"];
95
+ export declare const SHEET_FACT_KINDS: readonly ["sheet-error", "sheet-number", "sheet-unlike", "sheet-exception", "sheet-unused", "sheet-invalid", "sheet-typed", "sheet-ordinary", "sheet-iteration"];
86
96
  export interface InspectOptions {
87
97
  /** Numbers a formula may hold and not be said: what any formula has. */
88
98
  plain?: readonly number[];
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{cellName as g}from"./address.js";import"./calc/types.js";import{analyse as y}from"./calc/analyse.js";import{dataValue as S}from"./export.js";import{shownValue as x}from"./format.js";import{relativeKey as _}from"./formula/move.js";import{exceptionsOf as C}from"./edit.js";import{invalidCells as F}from"./validate.js";import{CellError as E}from"./values.js";import{FormulaCell as v}from"./workbook.js";export const SHEET_FACT_KINDS=["sheet-error","sheet-number","sheet-unlike","sheet-exception","sheet-unused","sheet-invalid","sheet-typed","sheet-ordinary"],INSPECT_DEFAULTS={plain:[0,1,-1],around:1};function w(o){const s=new Map;for(const t of o.formulas){const n=s.get(t.shared);n?(n.count+=1,(t.row<n.first.row||t.row===n.first.row&&t.col<n.first.col)&&(n.first=t)):s.set(t.shared,{shared:t.shared,first:t,count:1})}return[...s.values()].sort((t,n)=>t.first.row-n.first.row||t.first.col-n.first.col)}function k(o,s,t){switch(o.kind){case"number":t.push({value:o.value,in:s});return;case"unary":o.op==="-"&&o.arg.kind==="number"?t.push({value:-o.arg.value,in:s}):k(o.arg,o.op,t);return;case"postfix":k(o.arg,o.op,t);return;case"paren":k(o.arg,s,t);return;case"binary":k(o.left,o.op,t),k(o.right,o.op,t);return;case"array":for(const n of o.rows)for(const l of n)k(l,"{}",t);return;case"call":for(const n of o.args)k(n,o.name,t);return;case"invoke":k(o.callee,s,t);for(const n of o.args)k(n,"LAMBDA",t);return;default:return}}function N(o,s){const t={error:!1};for(const n of o.precedents(s))if(o.each(n,l=>{l instanceof E&&(t.error=!0)}),t.error)return!1;return!0}const b=new WeakMap;function A(o){const s=b.get(o);if(s!==void 0)return s;const t=o.node?_(o.node,o.row,o.col):o.text;return b.set(o,t),t}const I=(o,s)=>o instanceof v?o.text:x(o,s);function M(o,s,t){const n=[],l=(r,e)=>{if(r<0||e<0)return;const u=o.at(r,e);return u instanceof v?A(u.shared):void 0},c=(r,e,u,i)=>{const f=u==="column"?1:0,a=u==="row"?1:0,h=o.at(r,e);if(h===void 0||h instanceof v&&A(h.shared)===i)return;for(let d=1;d<=s;d++)if(l(r-f*d,e-a*d)!==i||l(r+f*d,e+a*d)!==i)return;if(t.has(r*16384+e))return;let m=s*2;for(let d=s+1;l(r-f*d,e-a*d)===i;d++)m+=1;for(let d=s+1;l(r+f*d,e+a*d)===i;d++)m+=1;const p=o.at(r-f,e-a);n.push({sheet:o.name,cell:g({row:r,col:e}),holds:I(h,o.lookAt(r,e).format),neighbour:p instanceof v?p.text:"",along:u,run:m})};for(const r of o.formulas){const e=A(r.shared);c(r.row+1,r.col,"column",e),c(r.row,r.col+1,"row",e)}return n.sort((r,e)=>T(r.cell,e.cell))}const T=(o,s)=>o.length-s.length||o.localeCompare(s,"en",{numeric:!0});function R(o,s){const t=[],n=(c,r)=>{c&&t.push(...o.readsOfFormula(c,r))};for(const c of s.sheets){for(const r of c.conditions)for(const e of r.formulas)n(e,c);for(const r of c.validations)for(const e of r.formulas)n(e,c);for(const r of c.charts){n(r.title,c),n(r.categories,c);for(const e of r.series)n(e.values,c),n(e.x,c),n(e.name,c)}}const l=s.sheets[0];if(l){for(const c of s.checks)n(c.formula,l);for(const c of s.names.values())n(c.formula,l)}return t}function D(o){const s=new Set,t=n=>{if(n)for(const l of y(o,n).names)s.add(l)};for(const n of o.sheets){for(const{shared:l}of w(n))t(l);for(const l of n.conditions)l.formulas.forEach(t);for(const l of n.validations)l.formulas.forEach(t);for(const l of n.charts){t(l.title),t(l.categories);for(const c of l.series)t(c.values),t(c.x),t(c.name)}}for(const n of o.checks)t(n.formula);return s}function K(o,s,t){const n=[],l=D(s);for(const e of s.names.values())l.has(e.name.toLowerCase())||n.push({what:"name",name:e.name,value:e.formula?.text??x(e.value??null)});const c=R(o,s),r=(e,u,i)=>c.some(f=>f.sheet===e&&u>=f.top&&u<=f.bottom&&i>=f.left&&i<=f.right)||o.readers(e,u,i).length>0;for(const e of s.sheets){for(let u=0;u<e.columnsUsed;u++){const[i,f]=e.span(u,0,Number.MAX_SAFE_INTEGER);for(let a=i;a<=f;a++){const h=e.at(a,u);typeof h=="number"&&(e.tableAt(a,u)||e.blockAt(a,u)||r(e,a,u)||n.push({what:"cell",sheet:e.name,name:g({row:a,col:u}),value:x(h,e.lookAt(a,u).format)}))}}if(t)for(const u of e.tables)for(const i of u.columns){const f=u.at.col+i.index,{top:a,bottom:h}=u.data;let m=!1;for(let p=a;p<=h&&!m;p++)m=r(e,p,f);m||n.push({what:"column",sheet:e.name,name:`${u.name}[${i.name}]`})}}return n}export function inspectWorkbook(o,s={}){const{wb:t}=o,n=new Set(s.plain??INSPECT_DEFAULTS.plain),l=Math.max(1,s.around??INSPECT_DEFAULTS.around),c=s.all===!0,r=[];for(const e of t.sheets){const u=[...e.formulas].sort((f,a)=>f.row-a.row||f.col-a.col);for(const f of u){const{value:a}=f;a instanceof E&&r.push({kind:"sheet-error",data:{sheet:e.name,cell:g(f),code:a.code,formula:f.text,origin:N(o,f)}})}for(let f=0;f<e.columnsUsed;f++){const[a,h]=e.span(f,0,Number.MAX_SAFE_INTEGER);for(let m=a;m<=h;m++){const p=e.at(m,f);p instanceof E&&r.push({kind:"sheet-error",data:{sheet:e.name,cell:g({row:m,col:f}),code:p.code,origin:!0}})}}for(const{shared:f,first:a,count:h}of w(e)){if(!f.node)continue;const m=[];k(f.node,"=",m);const p=c?m:m.filter(d=>!n.has(d.value));p.length>0&&r.push({kind:"sheet-number",data:{sheet:e.name,cell:g(a),cells:h,formula:a.text,numbers:p}})}const i=new Set;for(const f of e.tables)for(const a of C(f))i.add(a.row*16384+a.col),r.push({kind:"sheet-exception",data:{sheet:e.name,table:f.name,column:a.column,cell:g(a),text:a.text}});for(const f of M(e,l,i))r.push({kind:"sheet-unlike",data:f})}for(const e of K(o,t,c))r.push({kind:"sheet-unused",data:e});for(const e of F(t,o))r.push({kind:"sheet-invalid",data:{sheet:e.sheet,cell:g(e),value:S(e.value,void 0),rule:e.type,range:e.range}});for(const e of t.generated?.typed??[])t.sheet(e.sheet)?.generated===!0&&r.push({kind:"sheet-typed",data:e});for(const e of t.ordinary)r.push({kind:"sheet-ordinary",data:{sheet:e}});return r}
2
+ import{cellName as k}from"./address.js";import"./calc/types.js";import{analyse as F}from"./calc/analyse.js";import{ITERATION_DEFAULTS as b}from"./calc/engine.js";import{dataValue as N}from"./export.js";import{shownValue as E}from"./format.js";import{relativeKey as T}from"./formula/move.js";import{exceptionsOf as C}from"./edit.js";import{invalidCells as I}from"./validate.js";import{CellError as _}from"./values.js";import{FormulaCell as v}from"./workbook.js";export const SHEET_FACT_KINDS=["sheet-error","sheet-number","sheet-unlike","sheet-exception","sheet-unused","sheet-invalid","sheet-typed","sheet-ordinary","sheet-iteration"],INSPECT_DEFAULTS={plain:[0,1,-1],around:1};function w(e){const a=new Map;for(const t of e.formulas){const n=a.get(t.shared);n?(n.count+=1,(t.row<n.first.row||t.row===n.first.row&&t.col<n.first.col)&&(n.first=t)):a.set(t.shared,{shared:t.shared,first:t,count:1})}return[...a.values()].sort((t,n)=>t.first.row-n.first.row||t.first.col-n.first.col)}function g(e,a,t){switch(e.kind){case"number":t.push({value:e.value,in:a});return;case"unary":e.op==="-"&&e.arg.kind==="number"?t.push({value:-e.arg.value,in:a}):g(e.arg,e.op,t);return;case"postfix":g(e.arg,e.op,t);return;case"paren":g(e.arg,a,t);return;case"binary":g(e.left,e.op,t),g(e.right,e.op,t);return;case"array":for(const n of e.rows)for(const l of n)g(l,"{}",t);return;case"call":for(const n of e.args)g(n,e.name,t);return;case"invoke":g(e.callee,a,t);for(const n of e.args)g(n,"LAMBDA",t);return;default:return}}function M(e,a){const t={error:!1};for(const n of e.precedents(a))if(e.each(n,l=>{l instanceof _&&(t.error=!0)}),t.error)return!1;return!0}const y=new WeakMap;function A(e){const a=y.get(e);if(a!==void 0)return a;const t=e.node?T(e.node,e.row,e.col):e.text;return y.set(e,t),t}const R=(e,a)=>e instanceof v?e.text:E(e,a);function D(e,a,t){const n=[],l=(r,o)=>{if(r<0||o<0)return;const i=e.at(r,o);return i instanceof v?A(i.shared):void 0},c=(r,o,i,s)=>{const h=i==="column"?1:0,d=i==="row"?1:0,f=e.at(r,o);if(f===void 0||f instanceof v&&A(f.shared)===s)return;for(let m=1;m<=a;m++)if(l(r-h*m,o-d*m)!==s||l(r+h*m,o+d*m)!==s)return;if(t.has(r*16384+o))return;let u=a*2;for(let m=a+1;l(r-h*m,o-d*m)===s;m++)u+=1;for(let m=a+1;l(r+h*m,o+d*m)===s;m++)u+=1;const p=e.at(r-h,o-d);n.push({sheet:e.name,cell:k({row:r,col:o}),holds:R(f,e.lookAt(r,o).format),neighbour:p instanceof v?p.text:"",along:i,run:u})};for(const r of e.formulas){const o=A(r.shared);c(r.row+1,r.col,"column",o),c(r.row,r.col+1,"row",o)}return n.sort((r,o)=>L(r.cell,o.cell))}const L=(e,a)=>e.length-a.length||e.localeCompare(a,"en",{numeric:!0});function U(e,a){const t=[],n=(c,r)=>{c&&t.push(...e.readsOfFormula(c,r))};for(const c of a.sheets){for(const r of c.conditions)for(const o of r.formulas)n(o,c);for(const r of c.validations)for(const o of r.formulas)n(o,c);for(const r of c.charts){n(r.title,c),n(r.categories,c);for(const o of r.series)n(o.values,c),n(o.x,c),n(o.name,c)}}const l=a.sheets[0];if(l){for(const c of a.checks)n(c.formula,l);for(const c of a.names.values())n(c.formula,l)}return t}function K(e){const a=new Set,t=n=>{if(n)for(const l of F(e,n).names)a.add(l)};for(const n of e.sheets){for(const{shared:l}of w(n))t(l);for(const l of n.conditions)l.formulas.forEach(t);for(const l of n.validations)l.formulas.forEach(t);for(const l of n.charts){t(l.title),t(l.categories);for(const c of l.series)t(c.values),t(c.x),t(c.name)}}for(const n of e.checks)t(n.formula);return a}function O(e,a,t){const n=[],l=K(a);for(const o of a.names.values())l.has(o.name.toLowerCase())||n.push({what:"name",name:o.name,value:o.formula?.text??E(o.value??null)});const c=U(e,a),r=(o,i,s)=>c.some(h=>h.sheet===o&&i>=h.top&&i<=h.bottom&&s>=h.left&&s<=h.right)||e.readers(o,i,s).length>0;for(const o of a.sheets){for(let i=0;i<o.columnsUsed;i++){const[s,h]=o.span(i,0,Number.MAX_SAFE_INTEGER);for(let d=s;d<=h;d++){const f=o.at(d,i);typeof f=="number"&&(o.tableAt(d,i)||o.blockAt(d,i)||r(o,d,i)||n.push({what:"cell",sheet:o.name,name:k({row:d,col:i}),value:E(f,o.lookAt(d,i).format)}))}}if(t)for(const i of o.tables)for(const s of i.columns){const h=i.at.col+s.index,{top:d,bottom:f}=i.data;let u=!1;for(let p=d;p<=f&&!u;p++)u=r(o,p,h);u||n.push({what:"column",sheet:o.name,name:`${i.name}[${s.name}]`})}}return n}export function inspectWorkbook(e,a={}){const{wb:t}=e,n=new Set(a.plain??INSPECT_DEFAULTS.plain),l=Math.max(1,a.around??INSPECT_DEFAULTS.around),c=a.all===!0,r=[];for(const s of t.sheets){const h=[...s.formulas].sort((f,u)=>f.row-u.row||f.col-u.col);for(const f of h){const{value:u}=f;u instanceof _&&r.push({kind:"sheet-error",data:{sheet:s.name,cell:k(f),code:u.code,formula:f.text,origin:M(e,f)}})}for(let f=0;f<s.columnsUsed;f++){const[u,p]=s.span(f,0,Number.MAX_SAFE_INTEGER);for(let m=u;m<=p;m++){const x=s.at(m,f);x instanceof _&&r.push({kind:"sheet-error",data:{sheet:s.name,cell:k({row:m,col:f}),code:x.code,origin:!0}})}}for(const{shared:f,first:u,count:p}of w(s)){if(!f.node)continue;const m=[];g(f.node,"=",m);const x=c?m:m.filter(S=>!n.has(S.value));x.length>0&&r.push({kind:"sheet-number",data:{sheet:s.name,cell:k(u),cells:p,formula:u.text,numbers:x}})}const d=new Set;for(const f of s.tables)for(const u of C(f))d.add(u.row*16384+u.col),r.push({kind:"sheet-exception",data:{sheet:s.name,table:f.name,column:u.column,cell:k(u),text:u.text}});for(const f of D(s,l,d))r.push({kind:"sheet-unlike",data:f})}for(const s of O(e,t,c))r.push({kind:"sheet-unused",data:s});for(const s of I(t,e))r.push({kind:"sheet-invalid",data:{sheet:s.sheet,cell:k(s),value:N(s.value,void 0),rule:s.type,range:s.range}});for(const s of t.generated?.typed??[])t.sheet(s.sheet)?.generated===!0&&r.push({kind:"sheet-typed",data:s});for(const s of t.ordinary)r.push({kind:"sheet-ordinary",data:{sheet:s}});const{iterated:o}=e,{iteration:i}=t.file;if(o&&i!==void 0){const s=i===!0?{}:i;r.push({kind:"sheet-iteration",data:{cells:o.cells,iterations:o.iterations,max_iterations:s.max_iterations??b.max_iterations,change:Number.isFinite(o.change)?o.change:null,max_change:s.max_change??b.max_change}})}return r}
@@ -0,0 +1,19 @@
1
+ import type { Calc } from "./calc/engine.js";
2
+ export interface PrintedFacts {
3
+ sheet: string;
4
+ /** Pages across and down, and the scale it prints at (1 is 100%). */
5
+ across: number;
6
+ down: number;
7
+ scale: number;
8
+ /** Cells whose text its column, and the empty cells after it, cannot hold. */
9
+ cut: string[];
10
+ /** Cells whose number is wider than its column: Excel shows ####. */
11
+ hashed: string[];
12
+ /** Cells holding a number of 1,000 or more with no number format. */
13
+ unformatted: string[];
14
+ }
15
+ /** Each printed sheet's facts. */
16
+ export declare function printedFacts(calc: Calc): PrintedFacts[];
17
+ /** A render's lines on how a workbook prints and shows: every sheet's pages, then what its columns cut, show as #### or leave unformatted. */
18
+ export declare function printedLines(file: string, calc: Calc): string[];
19
+ //# sourceMappingURL=printed.d.ts.map
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{cellName as x}from"./address.js";import{shownValue as A}from"./format.js";import{paginate as j}from"./paginate.js";const y=7,D=5,S=11,E=1e3,d=6,b=(n,r)=>Math.max(0,(n-D)/y)*(S/r);export function printedFacts(n){return j(n).sheets.map(e=>{const{sheet:o}=e,t={sheet:o.name,across:e.across.length,down:e.down.length,scale:e.scale,cut:[],hashed:[],unformatted:[]},i=new Map(e.cols.map((s,u)=>[s,e.widths[u]??0]));for(const s of e.rows)for(const[u,h]of e.cols.entries()){const a=n.value(o,s,h);if(a===null||a===""||o.mergeAt(s,h)!==void 0)continue;const c=o.lookAt(s,h),l=x({row:s,col:h});if(typeof a=="number"&&Math.abs(a)>=E&&(c.format===void 0||c.format==="General")&&t.unformatted.push(l),c.wrap===!0||c.shrink===!0)continue;const $=Array.from(A(a,c.format)).length,w=c.size??S;if(typeof a=="number"){$>b(i.get(h)??0,w)&&t.hashed.push(l);continue}let g=i.get(h)??0;for(let m=u+1;m<e.cols.length;m++){const p=e.cols[m]??0;if(!M(n,o,s,p))break;g+=i.get(p)??0}$>b(g,w)&&t.cut.push(l)}return t})}const M=(n,r,e,o)=>{const t=n.value(r,e,o);return t===null||t===""},f=n=>n.length<=d?n.join(", "):`${n.slice(0,d).join(", ")} and ${String(n.length-d)} more`;export function printedLines(n,r){const e=printedFacts(r),o=[`${n}: as it prints, ${e.map(t=>`${t.sheet} ${String(t.across*t.down)} page${t.across*t.down===1?"":"s"} (${String(t.across)} across, ${String(t.down)} down, at ${String(Math.round(t.scale*100))}%)`).join("; ")}.`];for(const t of e)t.cut.length>0&&o.push(`${n}: ${t.sheet}: ${String(t.cut.length)} cell${t.cut.length===1?"'s":"s'"} text longer than its column and the empty cells after it hold, cut where the next cell starts: ${f(t.cut)}.`),t.hashed.length>0&&o.push(`${n}: ${t.sheet}: ${String(t.hashed.length)} number${t.hashed.length===1?"":"s"} wider than its column, which Excel shows as ####: ${f(t.hashed)}.`),t.unformatted.length>0&&o.push(`${n}: ${t.sheet}: ${String(t.unformatted.length)} number${t.unformatted.length===1?"":"s"} of 1,000 or more with no number format, shown as Excel's General shows them, with no separators (as a year is written): ${f(t.unformatted)}.`);return o}
@@ -55,6 +55,8 @@ export interface Typed {
55
55
  /** The formula's text, the = included, when it is one. */
56
56
  formula?: string;
57
57
  format?: string;
58
+ /** What a formula's cell holds before it is computed: where iterative calculation starts. */
59
+ start?: Scalar;
58
60
  }
59
61
  /**
60
62
  * Text as Excel reads what is typed: a number (a percent, grouped thousands
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export class CellError{static all=new Map;code;constructor(t){this.code=t}static of(t){let n=CellError.all.get(t);return n||(n=new CellError(t),CellError.all.set(t,n)),n}toString(){return this.code}toJSON(){return this.code}}export const ERR={NULL:CellError.of("#NULL!"),DIV0:CellError.of("#DIV/0!"),VALUE:CellError.of("#VALUE!"),REF:CellError.of("#REF!"),NAME:CellError.of("#NAME?"),NUM:CellError.of("#NUM!"),NA:CellError.of("#N/A"),SPILL:CellError.of("#SPILL!"),CALC:CellError.of("#CALC!"),CYCLE:CellError.of("#CYCLE!")};const $=["#NULL!","#DIV/0!","#VALUE!","#REF!","#NAME?","#NUM!","#N/A","#GETTING_DATA","#SPILL!","#CALC!","#CYCLE!"];export function errorOf(e){const t=e.toUpperCase(),n=$.find(r=>r===t);return n===void 0?void 0:CellError.of(n)}export class Matrix{rows;cols;data;constructor(t,n,r){this.rows=t,this.cols=n,this.data=r}at(t,n){return this.data[t*this.cols+n]??null}}const i=864e5,p=25569;function y(e){const t=e+p;return t<61?t-1:t}function M(e){const t=Math.floor(e);if(t!==60)return(t<60?t+1:t)-p}export function serialOf(e,t,n){const r=new Date(Date.UTC(2e3,t-1,1));return r.setUTCFullYear(r.getUTCFullYear()-2e3+e),y(Math.floor(r.getTime()/i))+n-1}export function dateOf(e){const t=M(e);if(t===void 0)return{year:1900,month:2,day:29};if(Math.floor(e)===0)return{year:1900,month:1,day:0};const n=new Date(t*i);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate()}}export function serialOfDate(e){const t=e.getTime(),n=Math.floor(t/i);return y(n)+(t-n*i)/i}export function dateOfSerial(e){const t=M(e);if(t===void 0)return;const n=e-Math.floor(e);return new Date(t*i+Math.round(n*i))}const a=(e,t=2)=>String(e).padStart(t,"0");export function isoOfSerial(e){const{year:t,month:n,day:r}=dateOf(e),s=`${a(t,4)}-${a(n)}-${a(r)}`,o=Math.round((e-Math.floor(e))*86400);if(o===0)return s;const u=o%60;return`${s}T${a(Math.floor(o/3600))}:${a(Math.floor(o/60)%60)}${u===0?"":`:${a(u)}`}`}export function numberText(e){if(e===0)return"0";const t=Number(e.toPrecision(15)),n=Math.floor(Math.log10(Math.abs(t)));if(n>=15||n<-10){const[s="",o="0"]=t.toExponential().split("e"),u=Number(o);return`${s}E${u<0?"-":"+"}${a(Math.abs(u))}`}const r=String(t);return r.includes("e")?t.toFixed(Math.min(20,Math.abs(n)+15)).replace(/0+$/u,""):r}const N=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/u,E=/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d+)?$/u,L=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/u,b=e=>/^[+-]?\d+$/u.test(e)&&e.replace(/^[+-]?0*/u,"").length>15;function A(e){const t=L.exec(e);if(!t)return;const[n,r,s]=[Number(t[1]),Number(t[2]),Number(t[3])],o=serialOf(n,r,s),u=dateOf(o);if(u.month!==r||u.day!==s)return;if(t[4]===void 0)return{value:o,format:"yyyy-mm-dd"};const[f,d,m]=[Number(t[4]),Number(t[5]),Number(t[6]??0)];if(f>23||d>59||m>59)return;const c=t[7];let h=0;if(c!==void 0&&c!=="Z"){const l=c.replace(":","");h=(l.startsWith("-")?1:-1)*(Number(l.slice(1,3))*60+Number(l.slice(3,5)))/1440}return{value:o+(f*3600+d*60+m)/86400+h,format:t[6]===void 0?"yyyy-mm-dd hh:mm":"yyyy-mm-dd hh:mm:ss"}}function U(e){const t=/^(\d{1,4}):([0-5]?\d)(?::([0-5]?\d))?(?:\s*([AaPp])[Mm]?)?$/u.exec(e)??/^(\d{1,2})()()\s*([AaPp])[Mm]?$/u.exec(e);if(!t)return;const n=Number(t[1]),r=t[2]===void 0||t[2]===""?0:Number(t[2]),s=t[3]===void 0||t[3]===""?0:Number(t[3]),o=t[4]?.toUpperCase();if(o!==void 0)return n<1||n>12?void 0:{value:((n%12+(o==="P"?12:0))*3600+r*60+s)/86400,format:t[3]?"h:mm:ss AM/PM":"h:mm AM/PM"};const u=(n*3600+r*60+s)/86400;return n>=24?{value:u,format:"[h]:mm:ss"}:{value:u,format:t[3]?"h:mm:ss":"h:mm"}}export function readTyped(e){if(e==="")return{value:null};if(e.startsWith("'"))return{value:e.slice(1)};if(e.length>1&&e.startsWith("="))return{value:null,formula:e};const t=e.trim();if(t==="")return{value:e};const n=t.toUpperCase();if(n==="TRUE")return{value:!0};if(n==="FALSE")return{value:!1};if(N.test(t))return b(t)?{value:e}:{value:Number(t)};if(t.endsWith("%")){const d=t.slice(0,-1).trim();if(N.test(d))return{value:Number(d)/100,format:d.includes(".")?"0.00%":"0%"}}if(E.test(t))return{value:Number(t.replaceAll(",","")),format:t.includes(".")?"#,##0.00":"#,##0"};const r=/^([+-]?)\$(\d[\d,]*(?:\.\d+)?)$/u.exec(t),s=r?.[2]?.replaceAll(",","");if(r&&s!==void 0)return{value:+`${r[1]??""}${s}`,format:t.includes(".")?"$#,##0.00":"$#,##0"};const o=A(t);if(o)return o;const u=U(t);if(u)return u;const f=errorOf(t);return f?{value:f}:{value:e}}export function writeTyped(e){if(e===null)return"";if(typeof e=="number"){const n=String(e);return b(n)?e.toExponential():n}if(typeof e=="boolean")return e?"TRUE":"FALSE";if(e instanceof CellError)return e.code;const t=readTyped(e);return t.value===e&&t.formula===void 0?e:`'${e}`}
2
+ export class CellError{static all=new Map;code;constructor(t){this.code=t}static of(t){let n=CellError.all.get(t);return n||(n=new CellError(t),CellError.all.set(t,n)),n}toString(){return this.code}toJSON(){return this.code}}export const ERR={NULL:CellError.of("#NULL!"),DIV0:CellError.of("#DIV/0!"),VALUE:CellError.of("#VALUE!"),REF:CellError.of("#REF!"),NAME:CellError.of("#NAME?"),NUM:CellError.of("#NUM!"),NA:CellError.of("#N/A"),SPILL:CellError.of("#SPILL!"),CALC:CellError.of("#CALC!"),CYCLE:CellError.of("#CYCLE!")};const $=["#NULL!","#DIV/0!","#VALUE!","#REF!","#NAME?","#NUM!","#N/A","#GETTING_DATA","#SPILL!","#CALC!","#CYCLE!"];export function errorOf(e){const t=e.toUpperCase(),n=$.find(r=>r===t);return n===void 0?void 0:CellError.of(n)}export class Matrix{rows;cols;data;constructor(t,n,r){this.rows=t,this.cols=n,this.data=r}at(t,n){return this.data[t*this.cols+n]??null}}const c=864e5,p=25569;function M(e){const t=e+p;return t<61?t-1:t}function y(e){const t=Math.floor(e);if(t!==60)return(t<60?t+1:t)-p}export function serialOf(e,t,n){const r=new Date(Date.UTC(2e3,t-1,1));return r.setUTCFullYear(r.getUTCFullYear()-2e3+e),M(Math.floor(r.getTime()/c))+n-1}export function dateOf(e){const t=y(e);return t===void 0?{year:1900,month:2,day:29}:Math.floor(e)===0?{year:1900,month:1,day:0}:E(t)}function E(e){const t=e+719468,n=Math.floor(t/146097),r=t-n*146097,u=Math.floor((r-Math.floor(r/1460)+Math.floor(r/36524)-Math.floor(r/146096))/365),o=r-(365*u+Math.floor(u/4)-Math.floor(u/100)),s=Math.floor((5*o+2)/153),f=o-Math.floor((153*s+2)/5)+1,i=s<10?s+3:s-9;return{year:u+n*400+(i<=2?1:0),month:i,day:f}}export function serialOfDate(e){const t=e.getTime(),n=Math.floor(t/c);return M(n)+(t-n*c)/c}export function dateOfSerial(e){const t=y(e);if(t===void 0)return;const n=e-Math.floor(e);return new Date(t*c+Math.round(n*c))}const a=(e,t=2)=>String(e).padStart(t,"0");export function isoOfSerial(e){const{year:t,month:n,day:r}=dateOf(e),u=`${a(t,4)}-${a(n)}-${a(r)}`,o=Math.round((e-Math.floor(e))*86400);if(o===0)return u;const s=o%60;return`${u}T${a(Math.floor(o/3600))}:${a(Math.floor(o/60)%60)}${s===0?"":`:${a(s)}`}`}export function numberText(e){if(e===0)return"0";const t=Number(e.toPrecision(15)),n=Math.floor(Math.log10(Math.abs(t)));if(n>=15||n<-10){const[u="",o="0"]=t.toExponential().split("e"),s=Number(o);return`${u}E${s<0?"-":"+"}${a(Math.abs(s))}`}const r=String(t);return r.includes("e")?t.toFixed(Math.min(20,Math.abs(n)+15)).replace(/0+$/u,""):r}const N=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/u,L=/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d+)?$/u,A=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/u,b=e=>/^[+-]?\d+$/u.test(e)&&e.replace(/^[+-]?0*/u,"").length>15;function U(e){const t=A.exec(e);if(!t)return;const[n,r,u]=[Number(t[1]),Number(t[2]),Number(t[3])],o=serialOf(n,r,u),s=dateOf(o);if(s.month!==r||s.day!==u)return;if(t[4]===void 0)return{value:o,format:"yyyy-mm-dd"};const[f,i,m]=[Number(t[4]),Number(t[5]),Number(t[6]??0)];if(f>23||i>59||m>59)return;const d=t[7];let h=0;if(d!==void 0&&d!=="Z"){const l=d.replace(":","");h=(l.startsWith("-")?1:-1)*(Number(l.slice(1,3))*60+Number(l.slice(3,5)))/1440}return{value:o+(f*3600+i*60+m)/86400+h,format:t[6]===void 0?"yyyy-mm-dd hh:mm":"yyyy-mm-dd hh:mm:ss"}}function C(e){const t=/^(\d{1,4}):([0-5]?\d)(?::([0-5]?\d))?(?:\s*([AaPp])[Mm]?)?$/u.exec(e)??/^(\d{1,2})()()\s*([AaPp])[Mm]?$/u.exec(e);if(!t)return;const n=Number(t[1]),r=t[2]===void 0||t[2]===""?0:Number(t[2]),u=t[3]===void 0||t[3]===""?0:Number(t[3]),o=t[4]?.toUpperCase();if(o!==void 0)return n<1||n>12?void 0:{value:((n%12+(o==="P"?12:0))*3600+r*60+u)/86400,format:t[3]?"h:mm:ss AM/PM":"h:mm AM/PM"};const s=(n*3600+r*60+u)/86400;return n>=24?{value:s,format:"[h]:mm:ss"}:{value:s,format:t[3]?"h:mm:ss":"h:mm"}}export function readTyped(e){if(e==="")return{value:null};if(e.startsWith("'"))return{value:e.slice(1)};if(e.length>1&&e.startsWith("="))return{value:null,formula:e};const t=e.trim();if(t==="")return{value:e};const n=t.toUpperCase();if(n==="TRUE")return{value:!0};if(n==="FALSE")return{value:!1};if(N.test(t))return b(t)?{value:e}:{value:Number(t)};if(t.endsWith("%")){const i=t.slice(0,-1).trim();if(N.test(i))return{value:Number(i)/100,format:i.includes(".")?"0.00%":"0%"}}if(L.test(t))return{value:Number(t.replaceAll(",","")),format:t.includes(".")?"#,##0.00":"#,##0"};const r=/^([+-]?)\$(\d[\d,]*(?:\.\d+)?)$/u.exec(t),u=r?.[2]?.replaceAll(",","");if(r&&u!==void 0)return{value:+`${r[1]??""}${u}`,format:t.includes(".")?"$#,##0.00":"$#,##0"};const o=U(t);if(o)return o;const s=C(t);if(s)return s;const f=errorOf(t);return f?{value:f}:{value:e}}export function writeTyped(e){if(e===null)return"";if(typeof e=="number"){const n=String(e);return b(n)?e.toExponential():n}if(typeof e=="boolean")return e?"TRUE":"FALSE";if(e instanceof CellError)return e.code;const t=readTyped(e);return t.value===e&&t.formula===void 0?e:`'${e}`}
@@ -135,6 +135,8 @@ interface Fill {
135
135
  shared?: SharedFormula;
136
136
  value?: Scalar;
137
137
  format?: string;
138
+ /** What its formula's cells hold before they are computed. */
139
+ start?: Scalar;
138
140
  }
139
141
  export declare const placeKey: (row: number, col: number) => number;
140
142
  export declare class Worksheet {