dytools-capture-engine 1.5.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -34,6 +34,8 @@ var CapturePublicEventType = {
34
34
  // This is a call that happens when either resize or moved.
35
35
  ZoneNameChanged: "zone:name_changed",
36
36
  ZoneFilterRegexChanged: "zone:filter_regex_changed",
37
+ ZoneApplyFilterRegexToWholeLinesChanged: "zone:apply_filter_regex_to_whole_lines_changed",
38
+ ZoneIsFilterRegexNegatedChanged: "zone:is_filter_regex_negated_changed",
37
39
  ZoneExampleChanged: "zone:example_changed",
38
40
  ZoneHiddenChanged: "zone:hidden_changed",
39
41
  ZoneChanged: "zone:changed",
@@ -77,15 +79,22 @@ var CaptureZoneEventType = {
77
79
  ZoneExampleChanged: "zone_internal:example_changed",
78
80
  ZoneHiddenChanged: "zone_internal:hidden_changed",
79
81
  ZoneFilterRegexChanged: "zone_internal:filter_regex_changed",
82
+ ZoneApplyFilterRegexToWholeLinesChanged: "zone_internal:apply_filter_regex_to_whole_lines_changed",
83
+ ZoneIsFilterRegexNegatedChanged: "zone_internal:is_filter_regex_negated_changed",
80
84
  ZoneOutputRegexChanged: "zone_internal:output_regex_changed",
81
85
  ZoneOutputReplacementChanged: "zone_internal:output_replacement_changed",
86
+ ZoneOutputFunctionChanged: "zone_internal:output_function_changed",
82
87
  ZoneRequiredChanged: "zone_internal:required_changed",
83
88
  ZoneDataTypeChanged: "zone_internal:data_type_changed",
84
89
  ZoneExcludeFromOutputChanged: "zone_internal:exclude_from_output_changed",
85
90
  ZoneDefaultValueIfEmptyChanged: "zone_internal:default_value_if_empty_changed",
91
+ ZoneFeatureFlagsChanged: "zone_internal:feature_flags_changed",
86
92
  ZoneOcrMatchesChanged: "zone_internal:ocr_matches_changed",
87
93
  ZoneGroupChildrenChanged: "zone_internal:group_children_changed",
88
- ZoneAnchorLocationChanged: "zone_internal:anchor_location_changed"
94
+ ZoneAnchorLocationChanged: "zone_internal:anchor_location_changed",
95
+ ZoneHasColumnHeadersChanged: "zone_internal:has_column_headers_changed",
96
+ ZoneExcludeColumnHeadersChanged: "zone_internal:exclude_column_headers_changed",
97
+ ZoneIsAnchorPerLineChanged: "zone_internal:is_anchor_per_line_changed"
89
98
  // These are events based on the state of the zone that is handled by the engine.
90
99
  // ZoneSelected: "zone:selected",
91
100
  // ZoneDeselected: "zone:deselected",
@@ -118,8 +127,11 @@ var CaptureToEngineEventType = {
118
127
  // This is a call that happens when either resize or moved.
119
128
  ZoneNameChanged: "zone:name_changed",
120
129
  ZoneFilterRegexChanged: "zone:filter_regex_changed",
130
+ ZoneApplyFilterRegexToWholeLinesChanged: "zone:apply_filter_regex_to_whole_lines_changed",
131
+ ZoneIsFilterRegexNegatedChanged: "zone:is_filter_regex_negated_changed",
121
132
  ZoneOutputRegexChanged: "zone:output_regex_changed",
122
133
  ZoneOutputReplacementChanged: "zone:output_replacement_changed",
134
+ ZoneOutputFunctionChanged: "zone:output_function_changed",
123
135
  ZoneRequiredChanged: "zone:required_changed",
124
136
  ZoneDataTypeChanged: "zone:data_type_changed",
125
137
  ZoneExcludeFromOutputChanged: "zone:exclude_from_output_changed",
@@ -130,6 +142,10 @@ var CaptureToEngineEventType = {
130
142
  // This happens on all the above events.
131
143
  ZoneAnchorLocationChanged: "zone:anchor_location_changed",
132
144
  ZoneGroupChildrenChanged: "zone:group_children_changed",
145
+ ZoneHasColumnHeadersChanged: "zone:has_column_headers_changed",
146
+ ZoneExcludeColumnHeadersChanged: "zone:exclude_column_headers_changed",
147
+ ZoneIsAnchorPerLineChanged: "zone:is_anchor_per_line_changed",
148
+ ZoneFeatureFlagsChanged: "zone:feature_flags_changed",
133
149
  ZoneChildZoneAdded: "zone:child_zone_added",
134
150
  ZoneChildZoneRemoved: "zone:child_zone_removed",
135
151
  ZoneChildZonesChanged: "zone:child_zone_changed",
@@ -143,7 +159,7 @@ var CaptureToEngineEventType = {
143
159
  // ObjectDeselected: "object:deselected",
144
160
  };
145
161
  var CaptureZoneBase = class {
146
- constructor(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, opts = {}) {
162
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
147
163
  this._example = null;
148
164
  this.needsAnchorReposition = false;
149
165
  // This is true when the zone needs to be repositioned to the parent's anchor point when the anchor is moved.
@@ -156,12 +172,16 @@ var CaptureZoneBase = class {
156
172
  this._rect = rect;
157
173
  this._hidden = hidden;
158
174
  this._filterRegex = filterRegex;
175
+ this._applyFilterRegexToWholeLines = applyFilterRegexToWholeLines;
176
+ this._isFilterRegexNegated = isFilterRegexNegated;
159
177
  this._outputRegex = outputRegex;
160
178
  this._outputReplacement = outputReplacement;
179
+ this._outputFunction = outputFunction;
161
180
  this._required = required;
162
181
  this._dataType = dataType;
163
182
  this._excludeFromOutput = excludeFromOutput;
164
183
  this._defaultValueIfEmpty = defaultValueIfEmpty;
184
+ this._featureFlags = featureFlags;
165
185
  }
166
186
  get defaultOptions() {
167
187
  return {
@@ -237,6 +257,28 @@ var CaptureZoneBase = class {
237
257
  });
238
258
  propertiesChanged.push("filterRegex");
239
259
  }
260
+ if (type === CaptureZoneEventType.ZoneApplyFilterRegexToWholeLinesChanged) {
261
+ const zoneApplyFilterRegexToWholeLinesChangedPayload = payload;
262
+ const oldApplyFilterRegexToWholeLines = zoneApplyFilterRegexToWholeLinesChangedPayload.oldApplyFilterRegexToWholeLines;
263
+ const newApplyFilterRegexToWholeLines = zoneApplyFilterRegexToWholeLinesChangedPayload.newApplyFilterRegexToWholeLines;
264
+ this.emitToEngine(CaptureToEngineEventType.ZoneApplyFilterRegexToWholeLinesChanged, {
265
+ zone: this,
266
+ oldApplyFilterRegexToWholeLines,
267
+ newApplyFilterRegexToWholeLines
268
+ });
269
+ propertiesChanged.push("applyFilterRegexToWholeLines");
270
+ }
271
+ if (type === CaptureZoneEventType.ZoneIsFilterRegexNegatedChanged) {
272
+ const zoneIsFilterRegexNegatedChangedPayload = payload;
273
+ const oldIsFilterRegexNegated = zoneIsFilterRegexNegatedChangedPayload.oldIsFilterRegexNegated;
274
+ const newIsFilterRegexNegated = zoneIsFilterRegexNegatedChangedPayload.newIsFilterRegexNegated;
275
+ this.emitToEngine(CaptureToEngineEventType.ZoneIsFilterRegexNegatedChanged, {
276
+ zone: this,
277
+ oldIsFilterRegexNegated,
278
+ newIsFilterRegexNegated
279
+ });
280
+ propertiesChanged.push("isFilterRegexNegated");
281
+ }
240
282
  if (type === CaptureZoneEventType.ZoneOutputRegexChanged) {
241
283
  const zoneOutputRegexChangedPayload = payload;
242
284
  const oldOutputRegex = zoneOutputRegexChangedPayload.oldOutputRegex;
@@ -259,6 +301,17 @@ var CaptureZoneBase = class {
259
301
  });
260
302
  propertiesChanged.push("outputReplacement");
261
303
  }
304
+ if (type === CaptureZoneEventType.ZoneOutputFunctionChanged) {
305
+ const zoneOutputFunctionChangedPayload = payload;
306
+ const oldOutputFunction = zoneOutputFunctionChangedPayload.oldOutputFunction;
307
+ const newOutputFunction = zoneOutputFunctionChangedPayload.newOutputFunction;
308
+ this.emitToEngine(CaptureToEngineEventType.ZoneOutputFunctionChanged, {
309
+ zone: this,
310
+ oldOutputFunction,
311
+ newOutputFunction
312
+ });
313
+ propertiesChanged.push("outputFunction");
314
+ }
262
315
  if (type === CaptureZoneEventType.ZoneRequiredChanged) {
263
316
  const zoneRequiredChangedPayload = payload;
264
317
  const oldRequired = zoneRequiredChangedPayload.oldRequired;
@@ -303,6 +356,17 @@ var CaptureZoneBase = class {
303
356
  });
304
357
  propertiesChanged.push("defaultValueIfEmpty");
305
358
  }
359
+ if (type === CaptureZoneEventType.ZoneFeatureFlagsChanged) {
360
+ const zoneFeatureFlagsChangedPayload = payload;
361
+ const oldFeatureFlags = zoneFeatureFlagsChangedPayload.oldFeatureFlags;
362
+ const newFeatureFlags = zoneFeatureFlagsChangedPayload.newFeatureFlags;
363
+ this.emitToEngine(CaptureToEngineEventType.ZoneFeatureFlagsChanged, {
364
+ zone: this,
365
+ oldFeatureFlags,
366
+ newFeatureFlags
367
+ });
368
+ propertiesChanged.push("featureFlags");
369
+ }
306
370
  if (propertiesChanged.length > 0) {
307
371
  this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged });
308
372
  }
@@ -372,6 +436,24 @@ var CaptureZoneBase = class {
372
436
  this._filterRegex = value;
373
437
  this.emitZoneEvent(CaptureZoneEventType.ZoneFilterRegexChanged, { oldFilterRegex, newFilterRegex: value });
374
438
  }
439
+ get applyFilterRegexToWholeLines() {
440
+ return this._applyFilterRegexToWholeLines;
441
+ }
442
+ set applyFilterRegexToWholeLines(value) {
443
+ if (value === this._applyFilterRegexToWholeLines) return;
444
+ const oldApplyFilterRegexToWholeLines = this._applyFilterRegexToWholeLines;
445
+ this._applyFilterRegexToWholeLines = value;
446
+ this.emitZoneEvent(CaptureZoneEventType.ZoneApplyFilterRegexToWholeLinesChanged, { oldApplyFilterRegexToWholeLines, newApplyFilterRegexToWholeLines: value });
447
+ }
448
+ get isFilterRegexNegated() {
449
+ return this._isFilterRegexNegated;
450
+ }
451
+ set isFilterRegexNegated(value) {
452
+ if (value === this._isFilterRegexNegated) return;
453
+ const oldIsFilterRegexNegated = this._isFilterRegexNegated;
454
+ this._isFilterRegexNegated = value;
455
+ this.emitZoneEvent(CaptureZoneEventType.ZoneIsFilterRegexNegatedChanged, { oldIsFilterRegexNegated, newIsFilterRegexNegated: value });
456
+ }
375
457
  get outputRegex() {
376
458
  return this._outputRegex ?? null;
377
459
  }
@@ -392,6 +474,15 @@ var CaptureZoneBase = class {
392
474
  this._outputReplacement = value;
393
475
  this.emitZoneEvent(CaptureZoneEventType.ZoneOutputReplacementChanged, { oldOutputReplacement, newOutputReplacement: value });
394
476
  }
477
+ get outputFunction() {
478
+ return this._outputFunction ?? null;
479
+ }
480
+ set outputFunction(value) {
481
+ if (value === this._outputFunction) return;
482
+ const oldOutputFunction = this._outputFunction;
483
+ this._outputFunction = value;
484
+ this.emitZoneEvent(CaptureZoneEventType.ZoneOutputFunctionChanged, { oldOutputFunction, newOutputFunction: value });
485
+ }
395
486
  get required() {
396
487
  return this._required;
397
488
  }
@@ -430,6 +521,28 @@ var CaptureZoneBase = class {
430
521
  this._defaultValueIfEmpty = value;
431
522
  this.emitZoneEvent(CaptureZoneEventType.ZoneDefaultValueIfEmptyChanged, { oldDefaultValueIfEmpty, newDefaultValueIfEmpty: value });
432
523
  }
524
+ get featureFlags() {
525
+ return this._featureFlags ?? null;
526
+ }
527
+ set featureFlags(value) {
528
+ if (value === this._featureFlags) return;
529
+ if ((value === void 0 || value === null || value.length == 0) && (this._featureFlags === void 0 || this._featureFlags === null || this._featureFlags.length == 0)) return;
530
+ if (value && this._featureFlags && this.sameStrings(value, this._featureFlags)) return;
531
+ const oldFeatureFlags = this._featureFlags;
532
+ this._featureFlags = value;
533
+ this.emitZoneEvent(CaptureZoneEventType.ZoneFeatureFlagsChanged, { oldFeatureFlags, newFeatureFlags: value });
534
+ }
535
+ sameStrings(a, b) {
536
+ if (a.length !== b.length) return false;
537
+ const map = /* @__PURE__ */ new Map();
538
+ for (const s of a) map.set(s, (map.get(s) ?? 0) + 1);
539
+ for (const s of b) {
540
+ const count = map.get(s);
541
+ if (!count) return false;
542
+ count === 1 ? map.delete(s) : map.set(s, count - 1);
543
+ }
544
+ return map.size === 0;
545
+ }
433
546
  /* EVENT HANDLING METHODS */
434
547
  setEngineEventSink(callback) {
435
548
  this.engineEventSink = callback;
@@ -479,9 +592,53 @@ var CaptureZoneBase = class {
479
592
  }
480
593
  }
481
594
  };
595
+ var StaticZone = class extends CaptureZoneBase {
596
+ constructor(name, dataType = null, value = null, featureFlags, opts = {}) {
597
+ super(name, new import_dytools_geometry.Rectangle(0, 0, 10, 10), false, null, false, false, null, null, null, false, dataType, false, value, featureFlags, opts);
598
+ this.type = "static";
599
+ }
600
+ get defaultOptions() {
601
+ return {
602
+ ...super.defaultOptions
603
+ };
604
+ }
605
+ handleInternalZoneEvent(type, payload) {
606
+ if (type === CaptureZoneEventType.ZoneNameChanged || type === CaptureZoneEventType.ZoneDataTypeChanged || type === CaptureZoneEventType.ZoneDefaultValueIfEmptyChanged || type === CaptureZoneEventType.ZoneFeatureFlagsChanged) {
607
+ super.handleInternalZoneEvent(type, payload);
608
+ }
609
+ if (this.canvasManager === null) {
610
+ this.emitToEngine(CaptureToEngineEventType.ZoneError, { zone: this, message: "Missing CanvasManager" });
611
+ return;
612
+ }
613
+ if (type === CaptureZoneEventType.ZoneCanvasManagerSet) {
614
+ this.primaryCanvasRectangleId = this.canvasManager.addRectangle(this.rect, this.name, this.options.zoneColor ?? "black", true, true);
615
+ }
616
+ }
617
+ handleEvent(id, type, payload) {
618
+ if (this.id !== id) {
619
+ return;
620
+ }
621
+ }
622
+ toExternal(docWidth, docHeight) {
623
+ return {
624
+ TemplateZoneId: this.id,
625
+ Name: this.name,
626
+ Type: "TemplateStaticZone",
627
+ DataType: this.dataType,
628
+ Value: this.defaultValueIfEmpty,
629
+ FeatureFlags: this.featureFlags ?? void 0
630
+ };
631
+ }
632
+ get value() {
633
+ return this.defaultValueIfEmpty;
634
+ }
635
+ set value(value) {
636
+ this.defaultValueIfEmpty = value;
637
+ }
638
+ };
482
639
  var SimpleZone = class extends CaptureZoneBase {
483
- constructor(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, opts = {}) {
484
- super(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required, dataType, excludeFromOutput, defaultValueIfEmpty, opts);
640
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
641
+ super(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required, dataType, excludeFromOutput, defaultValueIfEmpty, featureFlags, opts);
485
642
  this.type = "simple";
486
643
  this.ocrOverlayIds = [];
487
644
  this.lastMatchHash = "";
@@ -556,12 +713,16 @@ var SimpleZone = class extends CaptureZoneBase {
556
713
  WidthAbsolute: this.rect.size.width,
557
714
  HeightAbsolute: this.rect.size.height,
558
715
  RegExFilter: this.filterRegex,
716
+ ApplyRegExFilterToWholeLines: this.applyFilterRegexToWholeLines,
717
+ IsRegExFilterNegated: this.isFilterRegexNegated,
559
718
  RegExOutput: this.outputRegex,
560
719
  RegExReplacement: this.outputReplacement,
720
+ OutputFunction: this.outputFunction,
561
721
  Required: this.required,
562
722
  DataType: this.dataType,
563
723
  ExcludeFromOutput: this.excludeFromOutput,
564
- DefaultValueIfEmpty: this.defaultValueIfEmpty
724
+ DefaultValueIfEmpty: this.defaultValueIfEmpty,
725
+ FeatureFlags: this.featureFlags ?? void 0
565
726
  };
566
727
  }
567
728
  };
@@ -588,14 +749,15 @@ var AnchorChildZone = class extends SimpleZone {
588
749
  }
589
750
  };
590
751
  var AnchorZone = class extends CaptureZoneBase {
591
- constructor(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, opts = {}) {
592
- super(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required, dataType, excludeFromOutput, defaultValueIfEmpty, opts);
752
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
753
+ super(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required, dataType, excludeFromOutput, defaultValueIfEmpty, featureFlags, opts);
593
754
  this.type = "anchor";
594
- //private primaryCanvasRectangleId: string | null = null;
595
755
  this._anchorLocation = "MiddleLeft";
596
756
  this._groupChildren = true;
757
+ this._hasColumnHeaders = false;
758
+ this._excludeColumnHeaders = false;
759
+ this._isAnchorPerLine = false;
597
760
  this.children = [];
598
- //canvasEngineIds: string[] = [];
599
761
  this.ocrOverlayIds = [];
600
762
  this.lastMatchHash = "";
601
763
  this.currentAnchorPoint = null;
@@ -692,6 +854,33 @@ var AnchorZone = class extends CaptureZoneBase {
692
854
  this._groupChildren = value;
693
855
  this.emitZoneEvent(CaptureZoneEventType.ZoneGroupChildrenChanged, { oldGroupChildren, newGroupChildren: value });
694
856
  }
857
+ get hasColumnHeaders() {
858
+ return this._hasColumnHeaders;
859
+ }
860
+ set hasColumnHeaders(value) {
861
+ if (value === this._hasColumnHeaders) return;
862
+ const oldHasColumnHeaders = this._hasColumnHeaders;
863
+ this._hasColumnHeaders = value;
864
+ this.emitZoneEvent(CaptureZoneEventType.ZoneHasColumnHeadersChanged, { oldHasColumnHeaders, newHasColumnHeaders: value });
865
+ }
866
+ get excludeColumnHeaders() {
867
+ return this._excludeColumnHeaders;
868
+ }
869
+ set excludeColumnHeaders(value) {
870
+ if (value === this._excludeColumnHeaders) return;
871
+ const oldExcludeColumnHeaders = this._excludeColumnHeaders;
872
+ this._excludeColumnHeaders = value;
873
+ this.emitZoneEvent(CaptureZoneEventType.ZoneExcludeColumnHeadersChanged, { oldExcludeColumnHeaders, newExcludeColumnHeaders: value });
874
+ }
875
+ get isAnchorPerLine() {
876
+ return this._isAnchorPerLine;
877
+ }
878
+ set isAnchorPerLine(value) {
879
+ if (value === this._isAnchorPerLine) return;
880
+ const oldIsAnchorPerLine = this._isAnchorPerLine;
881
+ this._isAnchorPerLine = value;
882
+ this.emitZoneEvent(CaptureZoneEventType.ZoneIsAnchorPerLineChanged, { oldIsAnchorPerLine, newIsAnchorPerLine: value });
883
+ }
695
884
  handleInternalZoneEvent(type, payload) {
696
885
  super.handleInternalZoneEvent(type, payload);
697
886
  if (this.canvasManager === null) {
@@ -723,6 +912,39 @@ var AnchorZone = class extends CaptureZoneBase {
723
912
  });
724
913
  this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["groupChildren"] });
725
914
  }
915
+ if (type === CaptureZoneEventType.ZoneHasColumnHeadersChanged) {
916
+ const zoneHasColumnHeadersChangedPayload = payload;
917
+ const oldHasColumnHeaders = zoneHasColumnHeadersChangedPayload.oldHasColumnHeaders;
918
+ const newHasColumnHeaders = zoneHasColumnHeadersChangedPayload.newHasColumnHeaders;
919
+ this.emitToEngine(CaptureToEngineEventType.ZoneHasColumnHeadersChanged, {
920
+ zone: this,
921
+ oldHasColumnHeaders,
922
+ newHasColumnHeaders
923
+ });
924
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["hasColumnHeaders"] });
925
+ }
926
+ if (type === CaptureZoneEventType.ZoneExcludeColumnHeadersChanged) {
927
+ const zoneExcludeColumnHeadersChangedPayload = payload;
928
+ const oldExcludeColumnHeaders = zoneExcludeColumnHeadersChangedPayload.oldExcludeColumnHeaders;
929
+ const newExcludeColumnHeaders = zoneExcludeColumnHeadersChangedPayload.newExcludeColumnHeaders;
930
+ this.emitToEngine(CaptureToEngineEventType.ZoneExcludeColumnHeadersChanged, {
931
+ zone: this,
932
+ oldExcludeColumnHeaders,
933
+ newExcludeColumnHeaders
934
+ });
935
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["excludeColumnHeaders"] });
936
+ }
937
+ if (type === CaptureZoneEventType.ZoneIsAnchorPerLineChanged) {
938
+ const zoneIsAnchorPerLineChangedPayload = payload;
939
+ const oldIsAnchorPerLine = zoneIsAnchorPerLineChangedPayload.oldIsAnchorPerLine;
940
+ const newIsAnchorPerLine = zoneIsAnchorPerLineChangedPayload.newIsAnchorPerLine;
941
+ this.emitToEngine(CaptureToEngineEventType.ZoneIsAnchorPerLineChanged, {
942
+ zone: this,
943
+ oldIsAnchorPerLine,
944
+ newIsAnchorPerLine
945
+ });
946
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["isAnchorPerLine"] });
947
+ }
726
948
  if (type === CaptureZoneEventType.ZoneHiddenChanged) {
727
949
  const zoneHiddenChangedPayload = payload;
728
950
  this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
@@ -818,8 +1040,11 @@ var AnchorZone = class extends CaptureZoneBase {
818
1040
  WidthAbsolute: this.rect.size.width,
819
1041
  HeightAbsolute: this.rect.size.height,
820
1042
  RegExFilter: this.filterRegex,
1043
+ ApplyRegExFilterToWholeLines: this.applyFilterRegexToWholeLines,
1044
+ IsRegExFilterNegated: this.isFilterRegexNegated,
821
1045
  RegExOutput: this.outputRegex,
822
1046
  RegExReplacement: this.outputReplacement,
1047
+ OutputFunction: this.outputFunction,
823
1048
  Required: this.required,
824
1049
  DataType: this.dataType,
825
1050
  ExcludeFromOutput: this.excludeFromOutput,
@@ -828,6 +1053,10 @@ var AnchorZone = class extends CaptureZoneBase {
828
1053
  AnchorLocationXAbsoluteHint: this.currentAnchorPoint?.x,
829
1054
  AnchorLocationYAbsoluteHint: this.currentAnchorPoint?.y,
830
1055
  GroupChildrenInSubRecord: this.groupChildren,
1056
+ HasColumnHeaders: this.hasColumnHeaders,
1057
+ ExcludeColumnHeaders: this.excludeColumnHeaders,
1058
+ IsAnchorPerLine: this.isAnchorPerLine,
1059
+ FeatureFlags: this.featureFlags ?? void 0,
831
1060
  ChildZones: this.children.map((e) => e instanceof AnchorChildZone ? e.toExternalChild(docWidth, docHeight, this.currentAnchorPoint || this.rect.origin) ?? null : e.toExternal(docWidth, docHeight) ?? null).filter((e) => e !== null)
832
1061
  };
833
1062
  }
@@ -1094,7 +1323,6 @@ var CaptureEngine = class {
1094
1323
  });
1095
1324
  this.engine.on(import_dytools_canvas_engine.EngineEventType.EngineRenderStarted, () => {
1096
1325
  this.emitExternal(CapturePublicEventType.CaptureRenderStarted, {});
1097
- this.doRender();
1098
1326
  });
1099
1327
  this.engine.on(import_dytools_canvas_engine.EngineEventType.EngineRenderCompleted, () => {
1100
1328
  this.emitExternal(CapturePublicEventType.CaptureRenderCompleted, {});
@@ -1179,6 +1407,18 @@ var CaptureEngine = class {
1179
1407
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1180
1408
  this.refreshMatches();
1181
1409
  }
1410
+ if (type === CaptureToEngineEventType.ZoneApplyFilterRegexToWholeLinesChanged) {
1411
+ const zoneApplyFilterRegexToWholeLinesChangedPayload = payload;
1412
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneApplyFilterRegexToWholeLinesChangedPayload.zone, propertiesChanged: ["applyFilterRegexToWholeLines"] });
1413
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1414
+ this.refreshMatches();
1415
+ }
1416
+ if (type === CaptureToEngineEventType.ZoneIsFilterRegexNegatedChanged) {
1417
+ const zoneIsFilterRegexNegatedChangedPayload = payload;
1418
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneIsFilterRegexNegatedChangedPayload.zone, propertiesChanged: ["isFilterRegexNegated"] });
1419
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1420
+ this.refreshMatches();
1421
+ }
1182
1422
  if (type === CaptureToEngineEventType.ZoneOutputRegexChanged) {
1183
1423
  const zoneOutputRegexChangedPayload = payload;
1184
1424
  this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneOutputRegexChangedPayload.zone, propertiesChanged: ["outputRegex"] });
@@ -1191,6 +1431,12 @@ var CaptureEngine = class {
1191
1431
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1192
1432
  this.refreshMatches();
1193
1433
  }
1434
+ if (type === CaptureToEngineEventType.ZoneOutputFunctionChanged) {
1435
+ const zoneOutputFunctionChangedPayload = payload;
1436
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneOutputFunctionChangedPayload.zone, propertiesChanged: ["outputFunction"] });
1437
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1438
+ this.refreshMatches();
1439
+ }
1194
1440
  if (type === CaptureToEngineEventType.ZoneRequiredChanged) {
1195
1441
  const zoneRequiredChangedPayload = payload;
1196
1442
  this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneRequiredChangedPayload.zone, propertiesChanged: ["required"] });
@@ -1223,6 +1469,30 @@ var CaptureEngine = class {
1223
1469
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1224
1470
  this.refreshMatches();
1225
1471
  }
1472
+ if (type === CaptureToEngineEventType.ZoneFeatureFlagsChanged) {
1473
+ const zoneFeatureFlagsChangedPayload = payload;
1474
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneFeatureFlagsChangedPayload.zone, propertiesChanged: ["featureFlags"] });
1475
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1476
+ this.refreshMatches();
1477
+ }
1478
+ if (type === CaptureToEngineEventType.ZoneHasColumnHeadersChanged) {
1479
+ const zoneHasColumnHeadersChangedPayload = payload;
1480
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneHasColumnHeadersChangedPayload.zone, propertiesChanged: ["hasColumnHeaders"] });
1481
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1482
+ this.refreshMatches();
1483
+ }
1484
+ if (type === CaptureToEngineEventType.ZoneExcludeColumnHeadersChanged) {
1485
+ const zoneExcludeColumnHeadersChangedPayload = payload;
1486
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneExcludeColumnHeadersChangedPayload.zone, propertiesChanged: ["excludeColumnHeaders"] });
1487
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1488
+ this.refreshMatches();
1489
+ }
1490
+ if (type === CaptureToEngineEventType.ZoneIsAnchorPerLineChanged) {
1491
+ const zoneIsAnchorPerLineChangedPayload = payload;
1492
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneIsAnchorPerLineChangedPayload.zone, propertiesChanged: ["isAnchorPerLine"] });
1493
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1494
+ this.refreshMatches();
1495
+ }
1226
1496
  }
1227
1497
  onZoneAdded(zone, parentZone, excludeOcrMatches = false) {
1228
1498
  zone.setEngineEventSink?.(
@@ -1254,10 +1524,6 @@ var CaptureEngine = class {
1254
1524
  const zoneId = parts[0];
1255
1525
  return this.allZonesFlattened.find((z) => z.id === zoneId);
1256
1526
  }
1257
- doRender() {
1258
- for (const zone of this.allZonesFlattened) {
1259
- }
1260
- }
1261
1527
  // ---- metered wrapper ----
1262
1528
  createMeteredFn(fn, minIntervalMs = 1e3) {
1263
1529
  let lastExec = 0;
@@ -1330,10 +1596,10 @@ var CaptureEngine = class {
1330
1596
  // --- in CaptureEngine.ts (or a new file) ---
1331
1597
  rectFromExternal(z, docW, docH) {
1332
1598
  return new import_dytools_geometry.Rectangle(
1333
- z.X * docW,
1334
- z.Y * docH,
1335
- z.Width * docW,
1336
- z.Height * docH
1599
+ (z.X ?? 0) * docW,
1600
+ (z.Y ?? 0) * docH,
1601
+ (z.Width ?? 10) * docW,
1602
+ (z.Height ?? 10) * docH
1337
1603
  );
1338
1604
  }
1339
1605
  zoneFromExternal(z, docW, docH, parentAnchorAbs) {
@@ -1343,12 +1609,16 @@ var CaptureEngine = class {
1343
1609
  this.rectFromExternal(z, docW, docH),
1344
1610
  false,
1345
1611
  z.RegExFilter ?? null,
1612
+ z.ApplyRegExFilterToWholeLines ?? true,
1613
+ z.IsRegExFilterNegated ?? false,
1346
1614
  z.RegExOutput ?? null,
1347
1615
  z.RegExReplacement ?? null,
1616
+ z.OutputFunction ?? null,
1348
1617
  z.Required ?? false,
1349
1618
  z.DataType ?? null,
1350
1619
  z.ExcludeFromOutput ?? false,
1351
1620
  z.DefaultValueIfEmpty ?? null,
1621
+ z.FeatureFlags ?? null,
1352
1622
  {
1353
1623
  zoneColor: this.options.anchorZoneColor,
1354
1624
  ocrMatchColor: this.options.anchorZoneOcrMatchColor,
@@ -1358,6 +1628,9 @@ var CaptureEngine = class {
1358
1628
  );
1359
1629
  if (z.AnchorLocation) anchor.anchorLocation = z.AnchorLocation;
1360
1630
  if (z.GroupChildrenInSubRecord !== void 0) anchor.groupChildren = z.GroupChildrenInSubRecord;
1631
+ if (z.HasColumnHeaders) anchor.hasColumnHeaders = z.HasColumnHeaders;
1632
+ if (z.ExcludeColumnHeaders) anchor.excludeColumnHeaders = z.ExcludeColumnHeaders;
1633
+ anchor.isAnchorPerLine = z.IsAnchorPerLine ?? true;
1361
1634
  const anchorPoint = anchor.rect.origin;
1362
1635
  for (const childDto of z.ChildZones ?? []) {
1363
1636
  const child = this.zoneFromExternal(childDto, docW, docH, anchorPoint);
@@ -1367,42 +1640,65 @@ var CaptureEngine = class {
1367
1640
  return anchor;
1368
1641
  }
1369
1642
  if (parentAnchorAbs) {
1370
- const absX = parentAnchorAbs.x / docW + z.X;
1371
- const absY = parentAnchorAbs.y / docH + z.Y;
1643
+ const absX = parentAnchorAbs.x / docW + (z.X ?? 0);
1644
+ const absY = parentAnchorAbs.y / docH + (z.Y ?? 0);
1372
1645
  const childRect = new import_dytools_geometry.Rectangle(
1373
1646
  absX * docW,
1374
1647
  absY * docH,
1375
- z.Width * docW,
1376
- z.Height * docH
1648
+ (z.Width ?? 10) * docW,
1649
+ (z.Height ?? 10) * docH
1377
1650
  );
1378
1651
  return new AnchorChildZone(
1379
1652
  z.Name,
1380
1653
  childRect,
1381
1654
  false,
1382
1655
  z.RegExFilter ?? null,
1656
+ z.ApplyRegExFilterToWholeLines ?? true,
1657
+ z.IsRegExFilterNegated ?? false,
1383
1658
  z.RegExOutput ?? null,
1384
1659
  z.RegExReplacement ?? null,
1660
+ z.OutputFunction ?? null,
1385
1661
  z.Required ?? false,
1386
1662
  z.DataType ?? null,
1387
1663
  z.ExcludeFromOutput ?? false,
1388
1664
  z.DefaultValueIfEmpty ?? null,
1665
+ z.FeatureFlags ?? null,
1389
1666
  {
1390
1667
  zoneColor: this.options.anchorChildZoneColor,
1391
1668
  ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1392
1669
  }
1393
1670
  );
1394
1671
  }
1672
+ if (z.Type === "TemplateStaticZone") {
1673
+ const staticZone = new StaticZone(
1674
+ z.Name,
1675
+ z.DataType ?? null,
1676
+ z.Value ?? null,
1677
+ z.FeatureFlags ?? null,
1678
+ {
1679
+ zoneColor: this.options.anchorZoneColor,
1680
+ ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1681
+ anchorPointColor: this.options.anchorZoneAnchorPointColor,
1682
+ zoneAdditionalChildrenColor: this.options.anchorZoneAdditionalChildrenColor
1683
+ }
1684
+ );
1685
+ return staticZone;
1686
+ }
1395
1687
  return new SimpleZone(
1396
1688
  z.Name,
1397
1689
  this.rectFromExternal(z, docW, docH),
1398
1690
  false,
1399
1691
  z.RegExFilter ?? null,
1692
+ z.ApplyRegExFilterToWholeLines ?? false,
1693
+ z.IsRegExFilterNegated ?? false,
1400
1694
  z.RegExOutput ?? null,
1401
1695
  z.RegExReplacement ?? null,
1696
+ z.OutputFunction ?? null,
1402
1697
  z.Required ?? false,
1403
1698
  z.DataType ?? null,
1404
1699
  z.ExcludeFromOutput ?? false,
1405
1700
  z.DefaultValueIfEmpty ?? null,
1701
+ z.FeatureFlags ?? null,
1406
1702
  {
1407
1703
  zoneColor: this.options.simpleZoneColor,
1408
1704
  ocrMatchColor: this.options.simpleZoneOcrMatchColor
@@ -1424,12 +1720,26 @@ var CaptureEngine = class {
1424
1720
  getZoneById(id) {
1425
1721
  return this.allZonesFlattened.find((z) => z.id === id);
1426
1722
  }
1723
+ /**
1724
+ * Add a new static zone
1725
+ */
1726
+ addStaticZone(makeCurrentSelected = false) {
1727
+ let newZone = new StaticZone(`Static ${this.zoneCounter++}`, null, null, null, {
1728
+ zoneColor: this.options.simpleZoneColor,
1729
+ ocrMatchColor: this.options.simpleZoneOcrMatchColor
1730
+ });
1731
+ this.zones.push(newZone);
1732
+ if (makeCurrentSelected) {
1733
+ this.setSelectedZones([newZone]);
1734
+ }
1735
+ return newZone;
1736
+ }
1427
1737
  /**
1428
1738
  * Add a new simple zone
1429
1739
  * @param bounds Rectangle
1430
1740
  */
1431
1741
  addSimpleZone(bounds, makeCurrentSelected = false) {
1432
- let newZone = new SimpleZone("Test1", bounds, false, null, null, null, false, null, false, null, {
1742
+ let newZone = new SimpleZone(`Simple ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1433
1743
  zoneColor: this.options.simpleZoneColor,
1434
1744
  ocrMatchColor: this.options.simpleZoneOcrMatchColor
1435
1745
  });
@@ -1444,7 +1754,7 @@ var CaptureEngine = class {
1444
1754
  * @param bounds Rectangle
1445
1755
  */
1446
1756
  addAnchorZone(bounds, makeCurrentSelected = false) {
1447
- let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1757
+ let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1448
1758
  zoneColor: this.options.anchorZoneColor,
1449
1759
  ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1450
1760
  anchorPointColor: this.options.anchorZoneAnchorPointColor,
@@ -1466,7 +1776,7 @@ var CaptureEngine = class {
1466
1776
  if (!anchorZone) {
1467
1777
  throw new Error(`Anchor zone with id ${anchorId} not found`);
1468
1778
  }
1469
- let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1779
+ let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1470
1780
  zoneColor: this.options.anchorChildZoneColor,
1471
1781
  ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1472
1782
  });
@@ -1535,18 +1845,39 @@ var CaptureEngine = class {
1535
1845
  if (patch.filterRegex !== void 0) {
1536
1846
  zone.filterRegex = patch.filterRegex;
1537
1847
  }
1848
+ if (patch.applyFilterRegexToWholeLines !== void 0) {
1849
+ zone.applyFilterRegexToWholeLines = patch.applyFilterRegexToWholeLines;
1850
+ }
1851
+ if (patch.isFilterRegexNegated !== void 0) {
1852
+ zone.isFilterRegexNegated = patch.isFilterRegexNegated;
1853
+ }
1538
1854
  if (patch.outputRegex !== void 0) {
1539
1855
  zone.outputRegex = patch.outputRegex;
1540
1856
  }
1541
1857
  if (patch.outputReplacement !== void 0) {
1542
1858
  zone.outputReplacement = patch.outputReplacement;
1543
1859
  }
1860
+ if (patch.outputFunction !== void 0) {
1861
+ zone.outputFunction = patch.outputFunction;
1862
+ }
1544
1863
  if (patch.anchorLocation !== void 0) {
1545
1864
  zone.anchorLocation = patch.anchorLocation;
1546
1865
  }
1547
1866
  if (patch.groupChildren !== void 0) {
1548
1867
  zone.groupChildren = patch.groupChildren;
1549
1868
  }
1869
+ if (patch.featureFlags !== void 0) {
1870
+ zone.featureFlags = patch.featureFlags;
1871
+ }
1872
+ if (patch.hasColumnHeaders !== void 0) {
1873
+ zone.hasColumnHeaders = patch.hasColumnHeaders;
1874
+ }
1875
+ if (patch.excludeColumnHeaders !== void 0) {
1876
+ zone.excludeColumnHeaders = patch.excludeColumnHeaders;
1877
+ }
1878
+ if (patch.isAnchorPerLine !== void 0) {
1879
+ zone.isAnchorPerLine = patch.isAnchorPerLine;
1880
+ }
1550
1881
  if (patch.rect) {
1551
1882
  const b = patch.rect;
1552
1883
  if (b instanceof import_dytools_geometry.Rectangle) {