circuit-to-svg 0.0.458 → 0.0.460

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.js CHANGED
@@ -9115,7 +9115,7 @@ var package_default = {
9115
9115
  engines: {
9116
9116
  node: "24.x"
9117
9117
  },
9118
- version: "0.0.457",
9118
+ version: "0.0.459",
9119
9119
  repository: {
9120
9120
  type: "git",
9121
9121
  url: "https://github.com/tscircuit/circuit-to-svg.git"
@@ -9148,7 +9148,7 @@ var package_default = {
9148
9148
  "@vitejs/plugin-react": "5.0.0",
9149
9149
  biome: "^0.3.3",
9150
9150
  "bun-match-svg": "^0.0.12",
9151
- "circuit-json": "^0.0.548",
9151
+ "circuit-json": "^0.0.549",
9152
9152
  "circuit-json-to-connectivity-map": "^0.0.23",
9153
9153
  esbuild: "^0.20.2",
9154
9154
  "format-si-unit": "^0.0.12",
@@ -14629,22 +14629,351 @@ function createSvgObjects3(elm, ctx, soup) {
14629
14629
  }
14630
14630
  }
14631
14631
 
14632
+ // lib/utils/get-sch-stroke-size.ts
14633
+ var getSchStrokeSize = (transform) => {
14634
+ return Math.abs(transform.a) * 0.02;
14635
+ };
14636
+
14637
+ // lib/sch/svg-object-fns/create-svg-objects-from-sch-group.ts
14638
+ import { applyToPoint as applyToPoint69 } from "transformation-matrix";
14639
+
14640
+ // lib/sch/get-schematic-group-port-label.ts
14641
+ function getSchematicGroupPortLabel(port) {
14642
+ const direction = port.facing_direction ?? "left";
14643
+ return {
14644
+ type: "schematic_text",
14645
+ schematic_text_id: `${port.schematic_port_id}_label`,
14646
+ text: port.display_pin_label ?? "",
14647
+ font_size: port.display_pin_label_font_size ?? 0.18,
14648
+ rotation: 0,
14649
+ color: "inherit",
14650
+ anchor: direction === "left" ? "right" : direction === "right" ? "left" : "center",
14651
+ position: {
14652
+ x: port.center.x + (direction === "left" ? -0.15 : direction === "right" ? 0.15 : 0),
14653
+ y: port.center.y + (direction === "up" ? 0.22 : direction === "down" ? -0.22 : 0)
14654
+ }
14655
+ };
14656
+ }
14657
+
14658
+ // lib/utils/net-label-superscript.ts
14659
+ var SUPERSCRIPT_SCALE = 0.65;
14660
+ var SUPERSCRIPT_GAP = 0.08;
14661
+ function getNetLabelTextWidth(label) {
14662
+ return estimateTextWidth(label.text || "") + (label.display_superscript ? SUPERSCRIPT_GAP + estimateTextWidth(label.display_superscript) * SUPERSCRIPT_SCALE : 0);
14663
+ }
14664
+ function createNetLabelTextChildren(text2, superscript, fontSizePx, dominantBaseline = "central") {
14665
+ const children = [
14666
+ {
14667
+ type: "text",
14668
+ value: text2,
14669
+ name: "",
14670
+ attributes: {},
14671
+ children: []
14672
+ }
14673
+ ];
14674
+ if (superscript) {
14675
+ children.push({
14676
+ type: "element",
14677
+ name: "tspan",
14678
+ value: "",
14679
+ attributes: {
14680
+ class: "sch-net-label-superscript",
14681
+ "font-size": `${fontSizePx * SUPERSCRIPT_SCALE}px`,
14682
+ dx: `${fontSizePx * SUPERSCRIPT_GAP}`,
14683
+ // Ideographic anchoring moves smaller glyphs downward; compensate
14684
+ // so power-symbol suffixes rise like centrally anchored label text.
14685
+ dy: `${-fontSizePx * (dominantBaseline === "ideographic" ? 0.5 : 0.25)}`
14686
+ },
14687
+ children: [
14688
+ {
14689
+ type: "text",
14690
+ value: superscript,
14691
+ name: "",
14692
+ attributes: {},
14693
+ children: []
14694
+ }
14695
+ ]
14696
+ });
14697
+ }
14698
+ return children;
14699
+ }
14700
+
14701
+ // lib/utils/create-svg-text-parts.ts
14702
+ var createSvgTextPart = (part) => ({
14703
+ type: "element",
14704
+ name: "tspan",
14705
+ value: "",
14706
+ attributes: part.is_overlined ? { "text-decoration": "overline" } : {},
14707
+ children: [
14708
+ {
14709
+ type: "text",
14710
+ name: "",
14711
+ value: part.text,
14712
+ attributes: {},
14713
+ children: []
14714
+ }
14715
+ ]
14716
+ });
14717
+ var createSvgTextParts = (parts) => parts.filter((part) => part.text).map(createSvgTextPart);
14718
+ var createSvgTextPartLines = (parts) => {
14719
+ const lines = [[]];
14720
+ for (const part of parts) {
14721
+ part.text.split("\n").forEach((text2, index) => {
14722
+ if (index > 0) lines.push([]);
14723
+ if (text2) lines.at(-1).push(createSvgTextPart({ ...part, text: text2 }));
14724
+ });
14725
+ }
14726
+ return lines;
14727
+ };
14728
+
14729
+ // lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
14730
+ import { applyToPoint as applyToPoint68 } from "transformation-matrix";
14731
+ var createSvgSchText = ({
14732
+ elm,
14733
+ transform,
14734
+ colorMap: colorMap2
14735
+ }) => {
14736
+ const center = applyToPoint68(transform, elm.position);
14737
+ const textAnchorMap = {
14738
+ center: "middle",
14739
+ center_right: "end",
14740
+ bottom_left: "start",
14741
+ bottom_center: "middle",
14742
+ bottom_right: "end",
14743
+ left: "start",
14744
+ right: "end",
14745
+ top: "middle",
14746
+ bottom: "middle",
14747
+ top_left: "start",
14748
+ top_center: "middle",
14749
+ top_right: "end",
14750
+ center_left: "start"
14751
+ };
14752
+ const dominantBaselineMap = {
14753
+ center: "middle",
14754
+ center_right: "middle",
14755
+ bottom_left: "ideographic",
14756
+ bottom_center: "ideographic",
14757
+ bottom_right: "ideographic",
14758
+ left: "middle",
14759
+ right: "middle",
14760
+ top: "hanging",
14761
+ bottom: "ideographic",
14762
+ top_left: "hanging",
14763
+ top_center: "hanging",
14764
+ top_right: "hanging",
14765
+ center_left: "middle"
14766
+ };
14767
+ const lines = elm.text.split("\n");
14768
+ const styledLines = createSvgTextPartLines(elm.text_parts ?? []);
14769
+ const children = lines.length === 1 ? elm.text_parts?.length ? styledLines[0] : [
14770
+ {
14771
+ type: "text",
14772
+ value: elm.text,
14773
+ name: elm.schematic_text_id,
14774
+ attributes: {},
14775
+ children: []
14776
+ }
14777
+ ] : lines.map((line, idx) => ({
14778
+ type: "element",
14779
+ name: "tspan",
14780
+ value: "",
14781
+ attributes: {
14782
+ x: center.x.toString(),
14783
+ ...idx > 0 ? { dy: "1em" } : {}
14784
+ },
14785
+ children: elm.text_parts?.length ? styledLines[idx] ?? [] : [
14786
+ {
14787
+ type: "text",
14788
+ value: line,
14789
+ name: idx === 0 ? elm.schematic_text_id : "",
14790
+ attributes: {},
14791
+ children: []
14792
+ }
14793
+ ]
14794
+ }));
14795
+ if (elm.display_superscript) {
14796
+ const target = lines.length === 1 ? children : children[children.length - 1].children;
14797
+ target.push(
14798
+ ...createNetLabelTextChildren(
14799
+ "",
14800
+ elm.display_superscript,
14801
+ getSchScreenFontSize(transform, "reference_designator", elm.font_size),
14802
+ dominantBaselineMap[elm.anchor]
14803
+ ).slice(1)
14804
+ );
14805
+ }
14806
+ return {
14807
+ type: "element",
14808
+ name: "text",
14809
+ value: "",
14810
+ attributes: {
14811
+ class: "sch-text",
14812
+ "data-schematic-text-id": elm.schematic_text_id,
14813
+ x: center.x.toString(),
14814
+ y: center.y.toString(),
14815
+ fill: elm.color ?? colorMap2.schematic.sheet_label,
14816
+ "text-anchor": textAnchorMap[elm.anchor],
14817
+ "dominant-baseline": dominantBaselineMap[elm.anchor],
14818
+ "font-family": "sans-serif",
14819
+ "font-size": `${getSchScreenFontSize(transform, "reference_designator", elm.font_size)}px`,
14820
+ transform: `rotate(${elm.rotation}, ${center.x}, ${center.y})`
14821
+ },
14822
+ children
14823
+ };
14824
+ };
14825
+
14826
+ // lib/sch/svg-object-fns/create-svg-objects-from-sch-group.ts
14827
+ function createSvgObjectsFromSchematicGroup({
14828
+ group: group2,
14829
+ transform,
14830
+ colorMap: colorMap2
14831
+ }) {
14832
+ if (!group2.show_boundary || group2.show_as_schematic_box) return [];
14833
+ const topLeft = applyToPoint69(transform, {
14834
+ x: group2.center.x - group2.width / 2,
14835
+ y: group2.center.y + group2.height / 2
14836
+ });
14837
+ const bottomRight = applyToPoint69(transform, {
14838
+ x: group2.center.x + group2.width / 2,
14839
+ y: group2.center.y - group2.height / 2
14840
+ });
14841
+ const strokeWidth = getSchStrokeSize(transform);
14842
+ const children = [
14843
+ {
14844
+ type: "element",
14845
+ name: "rect",
14846
+ value: "",
14847
+ children: [],
14848
+ attributes: {
14849
+ class: "sch-group-boundary",
14850
+ x: String(topLeft.x),
14851
+ y: String(topLeft.y),
14852
+ width: String(bottomRight.x - topLeft.x),
14853
+ height: String(bottomRight.y - topLeft.y),
14854
+ fill: "none",
14855
+ stroke: colorMap2.schematic.sheet,
14856
+ "stroke-width": String(strokeWidth),
14857
+ "stroke-dasharray": `${strokeWidth * 8} ${strokeWidth * 4}`
14858
+ }
14859
+ }
14860
+ ];
14861
+ if (group2.name)
14862
+ children.push(
14863
+ createSvgSchText({
14864
+ elm: {
14865
+ type: "schematic_text",
14866
+ schematic_text_id: `${group2.schematic_group_id}_title`,
14867
+ text: group2.name,
14868
+ color: colorMap2.schematic.sheet_name,
14869
+ font_size: 0.22,
14870
+ rotation: 0,
14871
+ anchor: "top_left",
14872
+ position: {
14873
+ x: group2.center.x - group2.width / 2 + 0.2,
14874
+ y: group2.center.y + group2.height / 2 - 0.2
14875
+ }
14876
+ },
14877
+ transform,
14878
+ colorMap: colorMap2
14879
+ })
14880
+ );
14881
+ return [
14882
+ {
14883
+ type: "element",
14884
+ name: "g",
14885
+ value: "",
14886
+ children,
14887
+ attributes: {
14888
+ class: "sch-group",
14889
+ "data-schematic-group-id": group2.schematic_group_id,
14890
+ "data-source-group-id": group2.source_group_id
14891
+ }
14892
+ }
14893
+ ];
14894
+ }
14895
+ function createSvgObjectsFromSchematicGroupPort({
14896
+ port,
14897
+ transform,
14898
+ colorMap: colorMap2
14899
+ }) {
14900
+ if (!port.schematic_group_id || !port.boundary_position || port.schematic_component_id)
14901
+ return [];
14902
+ const boundary = applyToPoint69(transform, port.boundary_position);
14903
+ const terminal = applyToPoint69(transform, port.center);
14904
+ const strokeWidth = getSchStrokeSize(transform);
14905
+ const markerSize = Math.abs(transform.a) * 0.1;
14906
+ return [
14907
+ {
14908
+ type: "element",
14909
+ name: "g",
14910
+ value: "",
14911
+ attributes: {
14912
+ class: "sch-group-port",
14913
+ "data-schematic-port-id": port.schematic_port_id,
14914
+ "data-source-port-id": port.source_port_id,
14915
+ "data-schematic-group-id": port.schematic_group_id
14916
+ },
14917
+ children: [
14918
+ {
14919
+ type: "element",
14920
+ name: "line",
14921
+ value: "",
14922
+ children: [],
14923
+ attributes: {
14924
+ x1: String(boundary.x),
14925
+ y1: String(boundary.y),
14926
+ x2: String(terminal.x),
14927
+ y2: String(terminal.y),
14928
+ stroke: colorMap2.schematic.pin,
14929
+ "stroke-width": String(strokeWidth)
14930
+ }
14931
+ },
14932
+ {
14933
+ type: "element",
14934
+ name: "rect",
14935
+ value: "",
14936
+ children: [],
14937
+ attributes: {
14938
+ class: "sch-group-port-terminal",
14939
+ x: String(boundary.x - markerSize / 2),
14940
+ y: String(boundary.y - markerSize / 2),
14941
+ width: String(markerSize),
14942
+ height: String(markerSize),
14943
+ fill: colorMap2.schematic.background,
14944
+ stroke: colorMap2.schematic.pin,
14945
+ "stroke-width": String(strokeWidth)
14946
+ }
14947
+ },
14948
+ createSvgSchText({
14949
+ elm: {
14950
+ ...getSchematicGroupPortLabel(port),
14951
+ color: colorMap2.schematic.pin_name
14952
+ },
14953
+ transform,
14954
+ colorMap: colorMap2
14955
+ })
14956
+ ]
14957
+ }
14958
+ ];
14959
+ }
14960
+
14632
14961
  // lib/sch/convert-circuit-json-to-schematic-svg.ts
14633
14962
  import {
14634
- applyToPoint as applyToPoint97,
14963
+ applyToPoint as applyToPoint98,
14635
14964
  fromTriangles,
14636
14965
  toSVG
14637
14966
  } from "transformation-matrix";
14638
14967
 
14639
14968
  // lib/sch/draw-schematic-grid.ts
14640
- import { applyToPoint as applyToPoint68 } from "transformation-matrix";
14969
+ import { applyToPoint as applyToPoint70 } from "transformation-matrix";
14641
14970
  function drawSchematicGrid(params) {
14642
14971
  const { minX, minY, maxX, maxY } = params.bounds;
14643
14972
  const cellSize = params.cellSize ?? 1;
14644
14973
  const labelCells = params.labelCells ?? false;
14645
14974
  const gridLines = [];
14646
14975
  const transformPoint = (x, y) => {
14647
- const [transformedX, transformedY] = applyToPoint68(params.transform, [x, y]);
14976
+ const [transformedX, transformedY] = applyToPoint70(params.transform, [x, y]);
14648
14977
  return { x: transformedX, y: transformedY };
14649
14978
  };
14650
14979
  for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
@@ -14725,15 +15054,15 @@ function drawSchematicGrid(params) {
14725
15054
  }
14726
15055
 
14727
15056
  // lib/sch/draw-schematic-labeled-points.ts
14728
- import { applyToPoint as applyToPoint69 } from "transformation-matrix";
15057
+ import { applyToPoint as applyToPoint71 } from "transformation-matrix";
14729
15058
  function drawSchematicLabeledPoints(params) {
14730
15059
  const { points, transform } = params;
14731
15060
  const labeledPointsGroup = [];
14732
15061
  for (const point of points) {
14733
- const [x1, y1] = applyToPoint69(transform, [point.x - 0.1, point.y - 0.1]);
14734
- const [x2, y2] = applyToPoint69(transform, [point.x + 0.1, point.y + 0.1]);
14735
- const [x3, y3] = applyToPoint69(transform, [point.x - 0.1, point.y + 0.1]);
14736
- const [x4, y4] = applyToPoint69(transform, [point.x + 0.1, point.y - 0.1]);
15062
+ const [x1, y1] = applyToPoint71(transform, [point.x - 0.1, point.y - 0.1]);
15063
+ const [x2, y2] = applyToPoint71(transform, [point.x + 0.1, point.y + 0.1]);
15064
+ const [x3, y3] = applyToPoint71(transform, [point.x - 0.1, point.y + 0.1]);
15065
+ const [x4, y4] = applyToPoint71(transform, [point.x + 0.1, point.y - 0.1]);
14737
15066
  labeledPointsGroup.push({
14738
15067
  name: "path",
14739
15068
  type: "element",
@@ -14744,7 +15073,7 @@ function drawSchematicLabeledPoints(params) {
14744
15073
  "stroke-opacity": "0.7"
14745
15074
  }
14746
15075
  });
14747
- const [labelX, labelY] = applyToPoint69(transform, [
15076
+ const [labelX, labelY] = applyToPoint71(transform, [
14748
15077
  point.x + 0.15,
14749
15078
  point.y - 0.15
14750
15079
  ]);
@@ -14794,49 +15123,6 @@ function getDefaultSchematicSheet(schematicSheets) {
14794
15123
  );
14795
15124
  }
14796
15125
 
14797
- // lib/utils/net-label-superscript.ts
14798
- var SUPERSCRIPT_SCALE = 0.65;
14799
- var SUPERSCRIPT_GAP = 0.08;
14800
- function getNetLabelTextWidth(label) {
14801
- return estimateTextWidth(label.text || "") + (label.display_superscript ? SUPERSCRIPT_GAP + estimateTextWidth(label.display_superscript) * SUPERSCRIPT_SCALE : 0);
14802
- }
14803
- function createNetLabelTextChildren(text2, superscript, fontSizePx, dominantBaseline = "central") {
14804
- const children = [
14805
- {
14806
- type: "text",
14807
- value: text2,
14808
- name: "",
14809
- attributes: {},
14810
- children: []
14811
- }
14812
- ];
14813
- if (superscript) {
14814
- children.push({
14815
- type: "element",
14816
- name: "tspan",
14817
- value: "",
14818
- attributes: {
14819
- class: "sch-net-label-superscript",
14820
- "font-size": `${fontSizePx * SUPERSCRIPT_SCALE}px`,
14821
- dx: `${fontSizePx * SUPERSCRIPT_GAP}`,
14822
- // Ideographic anchoring moves smaller glyphs downward; compensate
14823
- // so power-symbol suffixes rise like centrally anchored label text.
14824
- dy: `${-fontSizePx * (dominantBaseline === "ideographic" ? 0.5 : 0.25)}`
14825
- },
14826
- children: [
14827
- {
14828
- type: "text",
14829
- value: superscript,
14830
- name: "",
14831
- attributes: {},
14832
- children: []
14833
- }
14834
- ]
14835
- });
14836
- }
14837
- return children;
14838
- }
14839
-
14840
15126
  // lib/utils/get-unit-vector-from-outside-to-edge.ts
14841
15127
  var getUnitVectorFromOutsideToEdge = (side) => {
14842
15128
  switch (side) {
@@ -14981,7 +15267,7 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
14981
15267
 
14982
15268
  // lib/sch/get-schematic-symbol-text-bounds.ts
14983
15269
  import { symbols } from "schematic-symbols";
14984
- import { applyToPoint as applyToPoint70 } from "transformation-matrix";
15270
+ import { applyToPoint as applyToPoint72 } from "transformation-matrix";
14985
15271
  function getSchematicSymbolTextBounds(circuitJson) {
14986
15272
  const components = [];
14987
15273
  const schematicPortsByComponentId = /* @__PURE__ */ new Map();
@@ -15041,7 +15327,7 @@ function getComponentSymbolTextBounds({
15041
15327
  sourceComponent
15042
15328
  });
15043
15329
  if (!text2) continue;
15044
- const anchorPosition = applyToPoint70(symbolToRealTransform, primitive);
15330
+ const anchorPosition = applyToPoint72(symbolToRealTransform, primitive);
15045
15331
  const fontSize = getSchMmFontSize("reference_designator");
15046
15332
  const textBounds = getTextBoundsFromAnchor({
15047
15333
  x: anchorPosition.x,
@@ -15230,10 +15516,27 @@ function getSchematicBoundsFromCircuitJson(circuitJson, padding = 0.5) {
15230
15516
  { width: layout.width, height: layout.height },
15231
15517
  0
15232
15518
  );
15519
+ } else if (item.type === "schematic_group" && item.show_boundary && !item.show_as_schematic_box) {
15520
+ updateBounds(item.center, { width: item.width, height: item.height }, 0);
15233
15521
  } else if (item.type === "schematic_component") {
15234
15522
  updateBounds(item.center, item.size, 0);
15235
15523
  } else if (item.type === "schematic_port") {
15236
15524
  updateBounds(item.center, { width: portSize, height: portSize }, 0);
15525
+ if (item.schematic_group_id && item.boundary_position && !item.schematic_component_id) {
15526
+ updateBounds(
15527
+ item.boundary_position,
15528
+ { width: portSize, height: portSize },
15529
+ 0
15530
+ );
15531
+ const label = getSchematicGroupPortLabel(item);
15532
+ const width = label.text.length * label.font_size;
15533
+ const offsetX = label.anchor === "left" ? width / 2 : label.anchor === "right" ? -width / 2 : 0;
15534
+ updateBounds(
15535
+ { x: label.position.x + offsetX, y: label.position.y },
15536
+ { width, height: label.font_size },
15537
+ 0
15538
+ );
15539
+ }
15237
15540
  } else if (item.type === "schematic_debug_object") {
15238
15541
  if (item.shape === "rect") {
15239
15542
  updateBounds(item.center, item.size, 0);
@@ -15551,14 +15854,9 @@ function getMediaType(value) {
15551
15854
  return (value.split(";", 1)[0] ?? "").trim().toLowerCase();
15552
15855
  }
15553
15856
 
15554
- // lib/utils/get-sch-stroke-size.ts
15555
- var getSchStrokeSize = (transform) => {
15556
- return Math.abs(transform.a) * 0.02;
15557
- };
15558
-
15559
15857
  // lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
15560
15858
  import {
15561
- applyToPoint as applyToPoint73,
15859
+ applyToPoint as applyToPoint75,
15562
15860
  compose as compose15,
15563
15861
  rotate as rotate10,
15564
15862
  scale as scale7,
@@ -15567,7 +15865,7 @@ import {
15567
15865
 
15568
15866
  // lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
15569
15867
  import {
15570
- applyToPoint as applyToPoint72,
15868
+ applyToPoint as applyToPoint74,
15571
15869
  compose as compose14,
15572
15870
  rotate as rotate9,
15573
15871
  scale as scale6,
@@ -15576,13 +15874,13 @@ import {
15576
15874
  import { symbols as symbols2 } from "schematic-symbols";
15577
15875
 
15578
15876
  // lib/sch/svg-object-fns/create-svg-error-text.ts
15579
- import { applyToPoint as applyToPoint71 } from "transformation-matrix";
15877
+ import { applyToPoint as applyToPoint73 } from "transformation-matrix";
15580
15878
  var createSvgSchErrorText = ({
15581
15879
  text: text2,
15582
15880
  realCenter,
15583
15881
  realToScreenTransform
15584
15882
  }) => {
15585
- const screenCenter = applyToPoint71(realToScreenTransform, realCenter);
15883
+ const screenCenter = applyToPoint73(realToScreenTransform, realCenter);
15586
15884
  return {
15587
15885
  type: "element",
15588
15886
  name: "text",
@@ -15681,7 +15979,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
15681
15979
  x: symbolBounds.minX,
15682
15980
  y: (symbolBounds.minY + symbolBounds.maxY) / 2
15683
15981
  };
15684
- const rotatedSymbolEnd = applyToPoint72(rotationMatrix, symbolEndPoint);
15982
+ const rotatedSymbolEnd = applyToPoint74(rotationMatrix, symbolEndPoint);
15685
15983
  const symbolToRealTransform = compose14(
15686
15984
  translate14(
15687
15985
  realAnchorPosition.x - rotatedSymbolEnd.x,
@@ -15691,11 +15989,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
15691
15989
  scale6(1)
15692
15990
  // Use full symbol size
15693
15991
  );
15694
- const [screenMinX, screenMinY] = applyToPoint72(
15992
+ const [screenMinX, screenMinY] = applyToPoint74(
15695
15993
  compose14(realToScreenTransform, symbolToRealTransform),
15696
15994
  [bounds.minX, bounds.minY]
15697
15995
  );
15698
- const [screenMaxX, screenMaxY] = applyToPoint72(
15996
+ const [screenMaxX, screenMaxY] = applyToPoint74(
15699
15997
  compose14(realToScreenTransform, symbolToRealTransform),
15700
15998
  [bounds.maxX, bounds.maxY]
15701
15999
  );
@@ -15720,7 +16018,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
15720
16018
  });
15721
16019
  for (const path of symbolPaths) {
15722
16020
  const symbolPath = path.points.map((p, i) => {
15723
- const [x, y] = applyToPoint72(
16021
+ const [x, y] = applyToPoint74(
15724
16022
  compose14(realToScreenTransform, symbolToRealTransform),
15725
16023
  [p.x, p.y]
15726
16024
  );
@@ -15743,7 +16041,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
15743
16041
  });
15744
16042
  }
15745
16043
  for (const text2 of symbolTexts) {
15746
- const screenTextPos = applyToPoint72(
16044
+ const screenTextPos = applyToPoint74(
15747
16045
  compose14(realToScreenTransform, symbolToRealTransform),
15748
16046
  text2
15749
16047
  );
@@ -15784,7 +16082,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
15784
16082
  });
15785
16083
  }
15786
16084
  for (const box of symbolBoxes) {
15787
- const screenBoxPos = applyToPoint72(
16085
+ const screenBoxPos = applyToPoint74(
15788
16086
  compose14(realToScreenTransform, symbolToRealTransform),
15789
16087
  box
15790
16088
  );
@@ -15809,7 +16107,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
15809
16107
  });
15810
16108
  }
15811
16109
  for (const circle of symbolCircles) {
15812
- const screenCirclePos = applyToPoint72(
16110
+ const screenCirclePos = applyToPoint74(
15813
16111
  compose14(realToScreenTransform, symbolToRealTransform),
15814
16112
  circle
15815
16113
  );
@@ -15858,14 +16156,14 @@ var createSvgObjectsForSchNetLabel = ({
15858
16156
  const fontSizeMm = getSchMmFontSize("net_label");
15859
16157
  const halfHeightFsr = NET_LABEL_HEIGHT_MM / fontSizeMm / 2;
15860
16158
  const textWidthFSR = getNetLabelTextWidth({ ...schNetLabel, text: labelText });
15861
- const screenCenter = applyToPoint73(realToScreenTransform, schNetLabel.center);
16159
+ const screenCenter = applyToPoint75(realToScreenTransform, schNetLabel.center);
15862
16160
  const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
15863
16161
  schNetLabel.anchor_side
15864
16162
  );
15865
16163
  const screenTextGrowthVec = { ...realTextGrowthVec };
15866
16164
  screenTextGrowthVec.y *= -1;
15867
16165
  const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
15868
- const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint73(realToScreenTransform, schNetLabel.anchor_position) : {
16166
+ const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint75(realToScreenTransform, schNetLabel.anchor_position) : {
15869
16167
  x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
15870
16168
  y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
15871
16169
  };
@@ -15906,7 +16204,7 @@ var createSvgObjectsForSchNetLabel = ({
15906
16204
  y: -halfHeightFsr
15907
16205
  }
15908
16206
  ].map(
15909
- (fontRelativePoint) => applyToPoint73(
16207
+ (fontRelativePoint) => applyToPoint75(
15910
16208
  compose15(
15911
16209
  realToScreenTransform,
15912
16210
  translate15(realAnchorPosition.x, realAnchorPosition.y),
@@ -15982,13 +16280,13 @@ var createSvgObjectsForSchNetLabel = ({
15982
16280
 
15983
16281
  // lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
15984
16282
  import { su as su7 } from "@tscircuit/circuit-json-util";
15985
- import { applyToPoint as applyToPoint74 } from "transformation-matrix";
16283
+ import { applyToPoint as applyToPoint76 } from "transformation-matrix";
15986
16284
  var PIN_CIRCLE_RADIUS_MM = 0.02;
15987
16285
  var createSvgObjectsForSchPortHover = ({
15988
16286
  schPort,
15989
16287
  transform
15990
16288
  }) => {
15991
- const screenSchPortPos = applyToPoint74(transform, schPort.center);
16289
+ const screenSchPortPos = applyToPoint76(transform, schPort.center);
15992
16290
  const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM * 2;
15993
16291
  return [
15994
16292
  {
@@ -16034,7 +16332,7 @@ var createSvgObjectsForSchComponentPortHovers = ({
16034
16332
  };
16035
16333
 
16036
16334
  // lib/sch/svg-object-fns/create-svg-object-for-sch-port-no-connect.ts
16037
- import { applyToPoint as applyToPoint75 } from "transformation-matrix";
16335
+ import { applyToPoint as applyToPoint77 } from "transformation-matrix";
16038
16336
  var createSvgObjectForSchPortNoConnect = ({
16039
16337
  schPort,
16040
16338
  transform,
@@ -16043,11 +16341,11 @@ var createSvgObjectForSchPortNoConnect = ({
16043
16341
  const halfSize = 0.05;
16044
16342
  const { x, y } = schPort.center;
16045
16343
  const d = [-1, 1].map((slope) => {
16046
- const start = applyToPoint75(transform, {
16344
+ const start = applyToPoint77(transform, {
16047
16345
  x: x - halfSize,
16048
16346
  y: y - slope * halfSize
16049
16347
  });
16050
- const end = applyToPoint75(transform, {
16348
+ const end = applyToPoint77(transform, {
16051
16349
  x: x + halfSize,
16052
16350
  y: y + slope * halfSize
16053
16351
  });
@@ -16072,7 +16370,7 @@ var createSvgObjectForSchPortNoConnect = ({
16072
16370
  };
16073
16371
 
16074
16372
  // lib/sch/svg-object-fns/create-svg-objects-for-sch-port-indicator.ts
16075
- import { applyToPoint as applyToPoint76 } from "transformation-matrix";
16373
+ import { applyToPoint as applyToPoint78 } from "transformation-matrix";
16076
16374
  var PIN_CIRCLE_RADIUS_MM2 = 0.02;
16077
16375
  var createSvgObjectsForSchPortIndicator = ({
16078
16376
  schPort,
@@ -16083,7 +16381,7 @@ var createSvgObjectsForSchPortIndicator = ({
16083
16381
  const svgObjects = [];
16084
16382
  const radiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2;
16085
16383
  const strokeWidth = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2;
16086
- const screenPos = applyToPoint76(transform, schPort.center);
16384
+ const screenPos = applyToPoint78(transform, schPort.center);
16087
16385
  const sourcePort = circuitJson.find(
16088
16386
  (e) => e.type === "source_port" && e.source_port_id === schPort.source_port_id
16089
16387
  );
@@ -16134,7 +16432,7 @@ var createSvgObjectsForSchPortIndicator = ({
16134
16432
  textAnchor = "middle";
16135
16433
  break;
16136
16434
  }
16137
- const screenLabelPos = applyToPoint76(transform, labelPos);
16435
+ const screenLabelPos = applyToPoint78(transform, labelPos);
16138
16436
  const fontSizePx = getSchScreenFontSize(transform, "pin_number");
16139
16437
  if (schPort.facing_direction === "up" || schPort.facing_direction === "down") {
16140
16438
  rotation = `rotate(-90 ${screenLabelPos.x} ${screenLabelPos.y})`;
@@ -16168,139 +16466,14 @@ var createSvgObjectsForSchPortIndicator = ({
16168
16466
  return svgObjects;
16169
16467
  };
16170
16468
 
16171
- // lib/utils/create-svg-text-parts.ts
16172
- var createSvgTextPart = (part) => ({
16173
- type: "element",
16174
- name: "tspan",
16175
- value: "",
16176
- attributes: part.is_overlined ? { "text-decoration": "overline" } : {},
16177
- children: [
16178
- {
16179
- type: "text",
16180
- name: "",
16181
- value: part.text,
16182
- attributes: {},
16183
- children: []
16184
- }
16185
- ]
16186
- });
16187
- var createSvgTextParts = (parts) => parts.filter((part) => part.text).map(createSvgTextPart);
16188
- var createSvgTextPartLines = (parts) => {
16189
- const lines = [[]];
16190
- for (const part of parts) {
16191
- part.text.split("\n").forEach((text2, index) => {
16192
- if (index > 0) lines.push([]);
16193
- if (text2) lines.at(-1).push(createSvgTextPart({ ...part, text: text2 }));
16194
- });
16195
- }
16196
- return lines;
16197
- };
16198
-
16199
- // lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
16200
- import { applyToPoint as applyToPoint77 } from "transformation-matrix";
16201
- var createSvgSchText = ({
16202
- elm,
16203
- transform,
16204
- colorMap: colorMap2
16205
- }) => {
16206
- const center = applyToPoint77(transform, elm.position);
16207
- const textAnchorMap = {
16208
- center: "middle",
16209
- center_right: "end",
16210
- bottom_left: "start",
16211
- bottom_center: "middle",
16212
- bottom_right: "end",
16213
- left: "start",
16214
- right: "end",
16215
- top: "middle",
16216
- bottom: "middle",
16217
- top_left: "start",
16218
- top_center: "middle",
16219
- top_right: "end",
16220
- center_left: "start"
16221
- };
16222
- const dominantBaselineMap = {
16223
- center: "middle",
16224
- center_right: "middle",
16225
- bottom_left: "ideographic",
16226
- bottom_center: "ideographic",
16227
- bottom_right: "ideographic",
16228
- left: "middle",
16229
- right: "middle",
16230
- top: "hanging",
16231
- bottom: "ideographic",
16232
- top_left: "hanging",
16233
- top_center: "hanging",
16234
- top_right: "hanging",
16235
- center_left: "middle"
16236
- };
16237
- const lines = elm.text.split("\n");
16238
- const styledLines = createSvgTextPartLines(elm.text_parts ?? []);
16239
- const children = lines.length === 1 ? elm.text_parts?.length ? styledLines[0] : [
16240
- {
16241
- type: "text",
16242
- value: elm.text,
16243
- name: elm.schematic_text_id,
16244
- attributes: {},
16245
- children: []
16246
- }
16247
- ] : lines.map((line, idx) => ({
16248
- type: "element",
16249
- name: "tspan",
16250
- value: "",
16251
- attributes: {
16252
- x: center.x.toString(),
16253
- ...idx > 0 ? { dy: "1em" } : {}
16254
- },
16255
- children: elm.text_parts?.length ? styledLines[idx] ?? [] : [
16256
- {
16257
- type: "text",
16258
- value: line,
16259
- name: idx === 0 ? elm.schematic_text_id : "",
16260
- attributes: {},
16261
- children: []
16262
- }
16263
- ]
16264
- }));
16265
- if (elm.display_superscript) {
16266
- const target = lines.length === 1 ? children : children[children.length - 1].children;
16267
- target.push(
16268
- ...createNetLabelTextChildren(
16269
- "",
16270
- elm.display_superscript,
16271
- getSchScreenFontSize(transform, "reference_designator", elm.font_size),
16272
- dominantBaselineMap[elm.anchor]
16273
- ).slice(1)
16274
- );
16275
- }
16276
- return {
16277
- type: "element",
16278
- name: "text",
16279
- value: "",
16280
- attributes: {
16281
- class: "sch-text",
16282
- "data-schematic-text-id": elm.schematic_text_id,
16283
- x: center.x.toString(),
16284
- y: center.y.toString(),
16285
- fill: elm.color ?? colorMap2.schematic.sheet_label,
16286
- "text-anchor": textAnchorMap[elm.anchor],
16287
- "dominant-baseline": dominantBaselineMap[elm.anchor],
16288
- "font-family": "sans-serif",
16289
- "font-size": `${getSchScreenFontSize(transform, "reference_designator", elm.font_size)}px`,
16290
- transform: `rotate(${elm.rotation}, ${center.x}, ${center.y})`
16291
- },
16292
- children
16293
- };
16294
- };
16295
-
16296
16469
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
16297
- import { applyToPoint as applyToPoint78 } from "transformation-matrix";
16470
+ import { applyToPoint as applyToPoint79 } from "transformation-matrix";
16298
16471
  function createSvgObjectsFromSchematicArc({
16299
16472
  schArc,
16300
16473
  transform,
16301
16474
  colorMap: colorMap2
16302
16475
  }) {
16303
- const center = applyToPoint78(transform, schArc.center);
16476
+ const center = applyToPoint79(transform, schArc.center);
16304
16477
  const transformedRadius = Math.abs(transform.a) * schArc.radius;
16305
16478
  const strokeWidth = schArc.stroke_width ?? 0.02;
16306
16479
  const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
@@ -16345,17 +16518,17 @@ function createSvgObjectsFromSchematicArc({
16345
16518
  }
16346
16519
 
16347
16520
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
16348
- import { applyToPoint as applyToPoint79 } from "transformation-matrix";
16521
+ import { applyToPoint as applyToPoint80 } from "transformation-matrix";
16349
16522
  var createSvgObjectsFromSchematicBox = ({
16350
16523
  schematicBox,
16351
16524
  transform,
16352
16525
  colorMap: colorMap2
16353
16526
  }) => {
16354
- const topLeft = applyToPoint79(transform, {
16527
+ const topLeft = applyToPoint80(transform, {
16355
16528
  x: schematicBox.x,
16356
16529
  y: schematicBox.y
16357
16530
  });
16358
- const bottomRight = applyToPoint79(transform, {
16531
+ const bottomRight = applyToPoint80(transform, {
16359
16532
  x: schematicBox.x + schematicBox.width,
16360
16533
  y: schematicBox.y + schematicBox.height
16361
16534
  });
@@ -16391,13 +16564,13 @@ var createSvgObjectsFromSchematicBox = ({
16391
16564
  };
16392
16565
 
16393
16566
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
16394
- import { applyToPoint as applyToPoint80 } from "transformation-matrix";
16567
+ import { applyToPoint as applyToPoint81 } from "transformation-matrix";
16395
16568
  function createSvgObjectsFromSchematicCircle({
16396
16569
  schCircle,
16397
16570
  transform,
16398
16571
  colorMap: colorMap2
16399
16572
  }) {
16400
- const center = applyToPoint80(transform, schCircle.center);
16573
+ const center = applyToPoint81(transform, schCircle.center);
16401
16574
  const transformedRadius = Math.abs(transform.a) * schCircle.radius;
16402
16575
  const strokeWidth = schCircle.stroke_width ?? 0.02;
16403
16576
  const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
@@ -16431,14 +16604,14 @@ function createSvgObjectsFromSchematicCircle({
16431
16604
  import { su as su11 } from "@tscircuit/circuit-json-util";
16432
16605
  import "schematic-symbols";
16433
16606
  import "svgson";
16434
- import { applyToPoint as applyToPoint86 } from "transformation-matrix";
16607
+ import { applyToPoint as applyToPoint87 } from "transformation-matrix";
16435
16608
 
16436
16609
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-component-with-symbol.ts
16437
16610
  import { su as su8 } from "@tscircuit/circuit-json-util";
16438
16611
  import { symbols as symbols3 } from "schematic-symbols";
16439
16612
  import "svgson";
16440
16613
  import {
16441
- applyToPoint as applyToPoint81,
16614
+ applyToPoint as applyToPoint82,
16442
16615
  compose as compose16
16443
16616
  } from "transformation-matrix";
16444
16617
 
@@ -16536,11 +16709,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
16536
16709
  minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
16537
16710
  maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
16538
16711
  };
16539
- const [screenMinX, screenMinY] = applyToPoint81(
16712
+ const [screenMinX, screenMinY] = applyToPoint82(
16540
16713
  compose16(realToScreenTransform, transformFromSymbolToReal),
16541
16714
  [bounds.minX, bounds.minY]
16542
16715
  );
16543
- const [screenMaxX, screenMaxY] = applyToPoint81(
16716
+ const [screenMaxX, screenMaxY] = applyToPoint82(
16544
16717
  compose16(realToScreenTransform, transformFromSymbolToReal),
16545
16718
  [bounds.maxX, bounds.maxY]
16546
16719
  );
@@ -16570,7 +16743,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
16570
16743
  attributes: {
16571
16744
  class: "sch-component-symbol-path",
16572
16745
  d: points.map((p, i) => {
16573
- const [x, y] = applyToPoint81(
16746
+ const [x, y] = applyToPoint82(
16574
16747
  compose16(realToScreenTransform, transformFromSymbolToReal),
16575
16748
  [p.x, p.y]
16576
16749
  );
@@ -16586,7 +16759,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
16586
16759
  });
16587
16760
  }
16588
16761
  for (const text2 of texts) {
16589
- const screenTextPos = applyToPoint81(
16762
+ const screenTextPos = applyToPoint82(
16590
16763
  compose16(realToScreenTransform, transformFromSymbolToReal),
16591
16764
  text2
16592
16765
  );
@@ -16629,7 +16802,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
16629
16802
  });
16630
16803
  }
16631
16804
  for (const box of boxes) {
16632
- const screenBoxPos = applyToPoint81(
16805
+ const screenBoxPos = applyToPoint82(
16633
16806
  compose16(realToScreenTransform, transformFromSymbolToReal),
16634
16807
  box
16635
16808
  );
@@ -16654,7 +16827,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
16654
16827
  }
16655
16828
  for (const port of symbol.ports) {
16656
16829
  if (portsWithoutTerminalCircle.has(port)) continue;
16657
- const screenPortPos = applyToPoint81(
16830
+ const screenPortPos = applyToPoint82(
16658
16831
  compose16(realToScreenTransform, transformFromSymbolToReal),
16659
16832
  port
16660
16833
  );
@@ -16675,7 +16848,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
16675
16848
  });
16676
16849
  }
16677
16850
  for (const circle of circles) {
16678
- const screenCirclePos = applyToPoint81(
16851
+ const screenCirclePos = applyToPoint82(
16679
16852
  compose16(realToScreenTransform, transformFromSymbolToReal),
16680
16853
  circle
16681
16854
  );
@@ -16704,7 +16877,7 @@ import "transformation-matrix";
16704
16877
  import "@tscircuit/circuit-json-util";
16705
16878
 
16706
16879
  // lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
16707
- import { applyToPoint as applyToPoint82 } from "transformation-matrix";
16880
+ import { applyToPoint as applyToPoint83 } from "transformation-matrix";
16708
16881
  import { su as su9 } from "@tscircuit/circuit-json-util";
16709
16882
  var PIN_CIRCLE_RADIUS_MM3 = 0.02;
16710
16883
  var createArrow2 = (tip, angle, size, color2, strokeWidth) => {
@@ -16757,8 +16930,8 @@ var createSvgObjectsForSchPortBoxLine = ({
16757
16930
  realEdgePos.y += realPinLineLength;
16758
16931
  break;
16759
16932
  }
16760
- const screenSchPortPos = applyToPoint82(transform, schPort.center);
16761
- const screenRealEdgePos = applyToPoint82(transform, realEdgePos);
16933
+ const screenSchPortPos = applyToPoint83(transform, schPort.center);
16934
+ const screenRealEdgePos = applyToPoint83(transform, realEdgePos);
16762
16935
  const isConnected = srcPort != null && srcPort.source_component_id == null && typeof schPort.is_connected === "boolean" ? schPort.is_connected : isSourcePortConnected(circuitJson, schPort.source_port_id);
16763
16936
  const is_drawn_with_inversion_circle = schPort.is_drawn_with_inversion_circle ?? false;
16764
16937
  const BUBBLE_RADIUS_MM = 0.06;
@@ -16779,7 +16952,7 @@ var createSvgObjectsForSchPortBoxLine = ({
16779
16952
  break;
16780
16953
  }
16781
16954
  }
16782
- const screenLineEnd = applyToPoint82(transform, realLineEnd);
16955
+ const screenLineEnd = applyToPoint83(transform, realLineEnd);
16783
16956
  if (is_drawn_with_inversion_circle) {
16784
16957
  const bubbleRadiusPx = Math.abs(transform.a) * BUBBLE_RADIUS_MM;
16785
16958
  const bubbleCenter = { ...screenRealEdgePos };
@@ -16938,7 +17111,7 @@ var createSvgObjectsForSchPortBoxLine = ({
16938
17111
  };
16939
17112
 
16940
17113
  // lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
16941
- import { applyToPoint as applyToPoint83 } from "transformation-matrix";
17114
+ import { applyToPoint as applyToPoint84 } from "transformation-matrix";
16942
17115
  var createSvgObjectsForSchPortPinNumberText = (params) => {
16943
17116
  const svgObjects = [];
16944
17117
  const { schPort, schComponent, transform, circuitJson } = params;
@@ -16956,7 +17129,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
16956
17129
  } else {
16957
17130
  realPinNumberPos.y += 0.02;
16958
17131
  }
16959
- const screenPinNumberTextPos = applyToPoint83(transform, realPinNumberPos);
17132
+ const screenPinNumberTextPos = applyToPoint84(transform, realPinNumberPos);
16960
17133
  svgObjects.push({
16961
17134
  name: "text",
16962
17135
  type: "element",
@@ -16986,7 +17159,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
16986
17159
  };
16987
17160
 
16988
17161
  // lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
16989
- import { applyToPoint as applyToPoint84 } from "transformation-matrix";
17162
+ import { applyToPoint as applyToPoint85 } from "transformation-matrix";
16990
17163
  var LABEL_DIST_FROM_EDGE_MM = 0.1;
16991
17164
  var createSvgObjectsForSchPortPinLabel = (params) => {
16992
17165
  const svgObjects = [];
@@ -17006,7 +17179,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
17006
17179
  const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
17007
17180
  realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
17008
17181
  realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
17009
- const screenPinNumberTextPos = applyToPoint84(transform, realPinNumberPos);
17182
+ const screenPinNumberTextPos = applyToPoint85(transform, realPinNumberPos);
17010
17183
  const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
17011
17184
  if (!label) return [];
17012
17185
  const isNegated = label.startsWith("N_");
@@ -17064,11 +17237,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
17064
17237
  colorMap: colorMap2
17065
17238
  }) => {
17066
17239
  const svgObjects = [];
17067
- const componentScreenTopLeft = applyToPoint86(transform, {
17240
+ const componentScreenTopLeft = applyToPoint87(transform, {
17068
17241
  x: schComponent.center.x - schComponent.size.width / 2,
17069
17242
  y: schComponent.center.y + schComponent.size.height / 2
17070
17243
  });
17071
- const componentScreenBottomRight = applyToPoint86(transform, {
17244
+ const componentScreenBottomRight = applyToPoint87(transform, {
17072
17245
  x: schComponent.center.x + schComponent.size.width / 2,
17073
17246
  y: schComponent.center.y - schComponent.size.height / 2
17074
17247
  });
@@ -17133,7 +17306,7 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
17133
17306
  };
17134
17307
 
17135
17308
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
17136
- import { applyToPoint as applyToPoint87 } from "transformation-matrix";
17309
+ import { applyToPoint as applyToPoint88 } from "transformation-matrix";
17137
17310
 
17138
17311
  // lib/sch/svg-object-fns/get-schematic-stroke-dasharray.ts
17139
17312
  function getSchematicStrokeDasharray({
@@ -17157,8 +17330,8 @@ function createSvgObjectsFromSchematicLine({
17157
17330
  transform,
17158
17331
  colorMap: colorMap2
17159
17332
  }) {
17160
- const p1 = applyToPoint87(transform, { x: schLine.x1, y: schLine.y1 });
17161
- const p2 = applyToPoint87(transform, { x: schLine.x2, y: schLine.y2 });
17333
+ const p1 = applyToPoint88(transform, { x: schLine.x1, y: schLine.y1 });
17334
+ const p2 = applyToPoint88(transform, { x: schLine.x2, y: schLine.y2 });
17162
17335
  const strokeWidth = schLine.stroke_width ?? 0.02;
17163
17336
  const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
17164
17337
  const strokeDasharray = getSchematicStrokeDasharray({
@@ -17195,13 +17368,13 @@ function createSvgObjectsFromSchematicLine({
17195
17368
  }
17196
17369
 
17197
17370
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
17198
- import { applyToPoint as applyToPoint88 } from "transformation-matrix";
17371
+ import { applyToPoint as applyToPoint89 } from "transformation-matrix";
17199
17372
  function createSvgObjectsFromSchematicRect({
17200
17373
  schRect,
17201
17374
  transform,
17202
17375
  colorMap: colorMap2
17203
17376
  }) {
17204
- const center = applyToPoint88(transform, schRect.center);
17377
+ const center = applyToPoint89(transform, schRect.center);
17205
17378
  const transformedWidth = Math.abs(transform.a) * schRect.width;
17206
17379
  const transformedHeight = Math.abs(transform.d) * schRect.height;
17207
17380
  const strokeWidth = schRect.stroke_width ?? 0.02;
@@ -17238,7 +17411,7 @@ function createSvgObjectsFromSchematicRect({
17238
17411
  }
17239
17412
 
17240
17413
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-path.ts
17241
- import { applyToPoint as applyToPoint89 } from "transformation-matrix";
17414
+ import { applyToPoint as applyToPoint90 } from "transformation-matrix";
17242
17415
  function createSvgObjectsFromSchematicPath({
17243
17416
  schPath,
17244
17417
  transform,
@@ -17259,7 +17432,7 @@ function createSvgObjectsFromSchematicPath({
17259
17432
  return [];
17260
17433
  }
17261
17434
  const transformedPoints = schPath.points.map(
17262
- (p) => applyToPoint89(transform, { x: p.x, y: p.y })
17435
+ (p) => applyToPoint90(transform, { x: p.x, y: p.y })
17263
17436
  );
17264
17437
  const pathD = transformedPoints.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`).join(" ");
17265
17438
  return [
@@ -17422,17 +17595,17 @@ function createSvgObjectsFromSchematicComponent(params) {
17422
17595
  }
17423
17596
 
17424
17597
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
17425
- import { applyToPoint as applyToPoint90 } from "transformation-matrix";
17598
+ import { applyToPoint as applyToPoint91 } from "transformation-matrix";
17426
17599
  function createSvgObjectsFromSchDebugObject({
17427
17600
  debugObject,
17428
17601
  transform
17429
17602
  }) {
17430
17603
  if (debugObject.shape === "rect") {
17431
- let [screenLeft, screenTop] = applyToPoint90(transform, [
17604
+ let [screenLeft, screenTop] = applyToPoint91(transform, [
17432
17605
  debugObject.center.x - debugObject.size.width / 2,
17433
17606
  debugObject.center.y - debugObject.size.height / 2
17434
17607
  ]);
17435
- let [screenRight, screenBottom] = applyToPoint90(transform, [
17608
+ let [screenRight, screenBottom] = applyToPoint91(transform, [
17436
17609
  debugObject.center.x + debugObject.size.width / 2,
17437
17610
  debugObject.center.y + debugObject.size.height / 2
17438
17611
  ]);
@@ -17442,7 +17615,7 @@ function createSvgObjectsFromSchDebugObject({
17442
17615
  ];
17443
17616
  const width = Math.abs(screenRight - screenLeft);
17444
17617
  const height = Math.abs(screenBottom - screenTop);
17445
- const [screenCenterX, screenCenterY] = applyToPoint90(transform, [
17618
+ const [screenCenterX, screenCenterY] = applyToPoint91(transform, [
17446
17619
  debugObject.center.x,
17447
17620
  debugObject.center.y
17448
17621
  ]);
@@ -17488,11 +17661,11 @@ function createSvgObjectsFromSchDebugObject({
17488
17661
  ];
17489
17662
  }
17490
17663
  if (debugObject.shape === "line") {
17491
- const [screenStartX, screenStartY] = applyToPoint90(transform, [
17664
+ const [screenStartX, screenStartY] = applyToPoint91(transform, [
17492
17665
  debugObject.start.x,
17493
17666
  debugObject.start.y
17494
17667
  ]);
17495
- const [screenEndX, screenEndY] = applyToPoint90(transform, [
17668
+ const [screenEndX, screenEndY] = applyToPoint91(transform, [
17496
17669
  debugObject.end.x,
17497
17670
  debugObject.end.y
17498
17671
  ]);
@@ -17542,7 +17715,7 @@ function createSvgObjectsFromSchDebugObject({
17542
17715
  }
17543
17716
 
17544
17717
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-sheet.ts
17545
- import { applyToPoint as applyToPoint91 } from "transformation-matrix";
17718
+ import { applyToPoint as applyToPoint92 } from "transformation-matrix";
17546
17719
  var SHEET_STROKE_WIDTH = 0.2 / SCHEMATIC_UNIT_TO_MM;
17547
17720
  var SHEET_LABEL_FONT_SIZE = 3 / SCHEMATIC_UNIT_TO_MM;
17548
17721
  var SHEET_COLUMNS = ["1", "2", "3", "4", "5", "6"];
@@ -17679,7 +17852,7 @@ function createSheetRect({
17679
17852
  transform,
17680
17853
  color: color2
17681
17854
  }) {
17682
- const screenCenter = applyToPoint91(transform, center);
17855
+ const screenCenter = applyToPoint92(transform, center);
17683
17856
  const screenWidth = Math.abs(transform.a) * width;
17684
17857
  const screenHeight = Math.abs(transform.d) * height;
17685
17858
  return {
@@ -17709,8 +17882,8 @@ function createSheetLine({
17709
17882
  transform,
17710
17883
  color: color2
17711
17884
  }) {
17712
- const p1 = applyToPoint91(transform, { x: x1, y: y1 });
17713
- const p2 = applyToPoint91(transform, { x: x2, y: y2 });
17885
+ const p1 = applyToPoint92(transform, { x: x1, y: y1 });
17886
+ const p2 = applyToPoint92(transform, { x: x2, y: y2 });
17714
17887
  return {
17715
17888
  name: "line",
17716
17889
  type: "element",
@@ -17735,7 +17908,7 @@ function createSheetText({
17735
17908
  transform,
17736
17909
  color: color2
17737
17910
  }) {
17738
- const center = applyToPoint91(transform, { x, y });
17911
+ const center = applyToPoint92(transform, { x, y });
17739
17912
  return {
17740
17913
  type: "element",
17741
17914
  name: "text",
@@ -17764,7 +17937,7 @@ function createSheetText({
17764
17937
  }
17765
17938
 
17766
17939
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
17767
- import { applyToPoint as applyToPoint92 } from "transformation-matrix";
17940
+ import { applyToPoint as applyToPoint93 } from "transformation-matrix";
17768
17941
  var createSvgObjectsFromSchematicTable = ({
17769
17942
  schematicTable,
17770
17943
  transform,
@@ -17797,11 +17970,11 @@ var createSvgObjectsFromSchematicTable = ({
17797
17970
  const svgObjects = [];
17798
17971
  const borderStrokeWidth = border_width * Math.abs(transform.a);
17799
17972
  const gridStrokeWidth = getSchStrokeSize(transform);
17800
- const [screenTopLeftX, screenTopLeftY] = applyToPoint92(transform, [
17973
+ const [screenTopLeftX, screenTopLeftY] = applyToPoint93(transform, [
17801
17974
  topLeftX,
17802
17975
  topLeftY
17803
17976
  ]);
17804
- const [screenBottomRightX, screenBottomRightY] = applyToPoint92(transform, [
17977
+ const [screenBottomRightX, screenBottomRightY] = applyToPoint93(transform, [
17805
17978
  topLeftX + totalWidth,
17806
17979
  topLeftY - totalHeight
17807
17980
  ]);
@@ -17834,8 +18007,8 @@ var createSvgObjectsFromSchematicTable = ({
17834
18007
  (cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
17835
18008
  );
17836
18009
  if (!isMerged) {
17837
- const start = applyToPoint92(transform, { x: currentX, y: segmentStartY });
17838
- const end = applyToPoint92(transform, { x: currentX, y: segmentEndY });
18010
+ const start = applyToPoint93(transform, { x: currentX, y: segmentStartY });
18011
+ const end = applyToPoint93(transform, { x: currentX, y: segmentEndY });
17839
18012
  svgObjects.push({
17840
18013
  name: "line",
17841
18014
  type: "element",
@@ -17865,11 +18038,11 @@ var createSvgObjectsFromSchematicTable = ({
17865
18038
  (cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
17866
18039
  );
17867
18040
  if (!isMerged) {
17868
- const start = applyToPoint92(transform, {
18041
+ const start = applyToPoint93(transform, {
17869
18042
  x: segmentStartX,
17870
18043
  y: currentY
17871
18044
  });
17872
- const end = applyToPoint92(transform, { x: segmentEndX, y: currentY });
18045
+ const end = applyToPoint93(transform, { x: segmentEndX, y: currentY });
17873
18046
  svgObjects.push({
17874
18047
  name: "line",
17875
18048
  type: "element",
@@ -17912,7 +18085,7 @@ var createSvgObjectsFromSchematicTable = ({
17912
18085
  } else if (vertical_align === "bottom") {
17913
18086
  realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
17914
18087
  }
17915
- const screenTextAnchorPos = applyToPoint92(transform, realTextAnchorPos);
18088
+ const screenTextAnchorPos = applyToPoint93(transform, realTextAnchorPos);
17916
18089
  const fontSize = getSchScreenFontSize(
17917
18090
  transform,
17918
18091
  "reference_designator",
@@ -17969,7 +18142,7 @@ var createSvgObjectsFromSchematicTable = ({
17969
18142
  };
17970
18143
 
17971
18144
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
17972
- import { applyToPoint as applyToPoint93 } from "transformation-matrix";
18145
+ import { applyToPoint as applyToPoint94 } from "transformation-matrix";
17973
18146
  function createSchematicTrace({
17974
18147
  trace,
17975
18148
  transform,
@@ -17983,11 +18156,11 @@ function createSchematicTrace({
17983
18156
  for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
17984
18157
  const edge = edges[edgeIndex];
17985
18158
  if (edge.is_crossing) continue;
17986
- const [screenFromX, screenFromY] = applyToPoint93(transform, [
18159
+ const [screenFromX, screenFromY] = applyToPoint94(transform, [
17987
18160
  edge.from.x,
17988
18161
  edge.from.y
17989
18162
  ]);
17990
- const [screenToX, screenToY] = applyToPoint93(transform, [
18163
+ const [screenToX, screenToY] = applyToPoint94(transform, [
17991
18164
  edge.to.x,
17992
18165
  edge.to.y
17993
18166
  ]);
@@ -18032,11 +18205,11 @@ function createSchematicTrace({
18032
18205
  }
18033
18206
  for (const edge of edges) {
18034
18207
  if (!edge.is_crossing) continue;
18035
- const [screenFromX, screenFromY] = applyToPoint93(transform, [
18208
+ const [screenFromX, screenFromY] = applyToPoint94(transform, [
18036
18209
  edge.from.x,
18037
18210
  edge.from.y
18038
18211
  ]);
18039
- const [screenToX, screenToY] = applyToPoint93(transform, [
18212
+ const [screenToX, screenToY] = applyToPoint94(transform, [
18040
18213
  edge.to.x,
18041
18214
  edge.to.y
18042
18215
  ]);
@@ -18081,7 +18254,7 @@ function createSchematicTrace({
18081
18254
  }
18082
18255
  if (trace.junctions) {
18083
18256
  for (const junction of trace.junctions) {
18084
- const [screenX, screenY] = applyToPoint93(transform, [
18257
+ const [screenX, screenY] = applyToPoint94(transform, [
18085
18258
  junction.x,
18086
18259
  junction.y
18087
18260
  ]);
@@ -18135,14 +18308,14 @@ function createSchematicTrace({
18135
18308
  }
18136
18309
 
18137
18310
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
18138
- import { applyToPoint as applyToPoint94 } from "transformation-matrix";
18311
+ import { applyToPoint as applyToPoint95 } from "transformation-matrix";
18139
18312
  function createSvgObjectsFromSchVoltageProbe({
18140
18313
  probe,
18141
18314
  transform,
18142
18315
  colorMap: colorMap2,
18143
18316
  fallbackColor
18144
18317
  }) {
18145
- const [screenX, screenY] = applyToPoint94(transform, [
18318
+ const [screenX, screenY] = applyToPoint95(transform, [
18146
18319
  probe.position.x,
18147
18320
  probe.position.y
18148
18321
  ]);
@@ -18318,7 +18491,7 @@ function createSvgObjectsFromSchVoltageProbe({
18318
18491
  }
18319
18492
 
18320
18493
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-warning.ts
18321
- import { applyToPoint as applyToPoint95 } from "transformation-matrix";
18494
+ import { applyToPoint as applyToPoint96 } from "transformation-matrix";
18322
18495
 
18323
18496
  // lib/sch/svg-object-fns/schematic-diagnostic-callout-layout.ts
18324
18497
  var TARGET_PADDING = 6;
@@ -18703,27 +18876,27 @@ function getElementScreenBounds(element2, transform) {
18703
18876
  if (element2.type === "schematic_sheet") {
18704
18877
  const layout = getSchematicSheetLayout(element2);
18705
18878
  return boundsFromPoints([
18706
- applyToPoint95(transform, { x: layout.minX, y: layout.maxY }),
18707
- applyToPoint95(transform, { x: layout.maxX, y: layout.minY })
18879
+ applyToPoint96(transform, { x: layout.minX, y: layout.maxY }),
18880
+ applyToPoint96(transform, { x: layout.maxX, y: layout.minY })
18708
18881
  ]);
18709
18882
  }
18710
18883
  if (element2.type === "schematic_component") {
18711
- const topLeft = applyToPoint95(transform, {
18884
+ const topLeft = applyToPoint96(transform, {
18712
18885
  x: element2.center.x - element2.size.width / 2,
18713
18886
  y: element2.center.y + element2.size.height / 2
18714
18887
  });
18715
- const bottomRight = applyToPoint95(transform, {
18888
+ const bottomRight = applyToPoint96(transform, {
18716
18889
  x: element2.center.x + element2.size.width / 2,
18717
18890
  y: element2.center.y - element2.size.height / 2
18718
18891
  });
18719
18892
  return boundsFromPoints([topLeft, bottomRight]);
18720
18893
  }
18721
18894
  if (element2.type === "schematic_port") {
18722
- const center = applyToPoint95(transform, element2.center);
18895
+ const center = applyToPoint96(transform, element2.center);
18723
18896
  return expandBounds2(boundsFromPoints([center]), 4);
18724
18897
  }
18725
18898
  if (element2.type === "schematic_net_label") {
18726
- const center = applyToPoint95(
18899
+ const center = applyToPoint96(
18727
18900
  transform,
18728
18901
  element2.anchor_position ?? element2.center
18729
18902
  );
@@ -18737,8 +18910,8 @@ function getElementScreenBounds(element2, transform) {
18737
18910
  }
18738
18911
  if (element2.type === "schematic_trace") {
18739
18912
  const points = element2.edges.flatMap((edge) => [
18740
- applyToPoint95(transform, edge.from),
18741
- applyToPoint95(transform, edge.to)
18913
+ applyToPoint96(transform, edge.from),
18914
+ applyToPoint96(transform, edge.to)
18742
18915
  ]);
18743
18916
  if (points.length === 0) return null;
18744
18917
  return expandBounds2(boundsFromPoints(points), 4);
@@ -18794,7 +18967,7 @@ function createTextNode(value) {
18794
18967
  }
18795
18968
 
18796
18969
  // lib/sch/svg-object-fns/create-svg-objects-from-source-port-error.ts
18797
- import { applyToPoint as applyToPoint96 } from "transformation-matrix";
18970
+ import { applyToPoint as applyToPoint97 } from "transformation-matrix";
18798
18971
  function createSvgObjectsFromSourcePortErrors({
18799
18972
  circuitJson,
18800
18973
  transform,
@@ -18811,7 +18984,7 @@ function createSvgObjectsFromSourcePortErrors({
18811
18984
  const firstPort = ports[0];
18812
18985
  if (!firstPort) return [];
18813
18986
  const markers = ports.flatMap((port) => {
18814
- const center2 = applyToPoint96(transform, port.center);
18987
+ const center2 = applyToPoint97(transform, port.center);
18815
18988
  return [
18816
18989
  {
18817
18990
  name: "circle",
@@ -18850,7 +19023,7 @@ function createSvgObjectsFromSourcePortErrors({
18850
19023
  }
18851
19024
  ];
18852
19025
  });
18853
- const center = applyToPoint96(transform, firstPort.center);
19026
+ const center = applyToPoint97(transform, firstPort.center);
18854
19027
  const { placement, leader, messageLines, calloutWidth, calloutHeight } = getSchematicDiagnosticCalloutLayout({
18855
19028
  message: references.message,
18856
19029
  targetBounds: {
@@ -18958,7 +19131,7 @@ function getComponentScreenBounds(circuitJson, transform) {
18958
19131
  { x: bounds.minX, y: bounds.maxY },
18959
19132
  { x: bounds.maxX, y: bounds.minY },
18960
19133
  { x: bounds.maxX, y: bounds.maxY }
18961
- ].map((point) => applyToPoint96(transform, point));
19134
+ ].map((point) => applyToPoint97(transform, point));
18962
19135
  return [
18963
19136
  {
18964
19137
  minX: Math.min(...corners.map((point) => point.x)),
@@ -19087,6 +19260,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
19087
19260
  const schText = [];
19088
19261
  const voltageProbeSvgs = [];
19089
19262
  const schBoxSvgs = [];
19263
+ const schGroupSvgs = [];
19090
19264
  const schTableSvgs = [];
19091
19265
  const schPortHoverSvgs = [];
19092
19266
  const schPortIndicatorSvgs = [];
@@ -19128,6 +19302,14 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
19128
19302
  transform
19129
19303
  })
19130
19304
  );
19305
+ } else if (elm.type === "schematic_group") {
19306
+ schGroupSvgs.push(
19307
+ ...createSvgObjectsFromSchematicGroup({
19308
+ group: elm,
19309
+ transform,
19310
+ colorMap: colorMap2
19311
+ })
19312
+ );
19131
19313
  } else if (elm.type === "schematic_component") {
19132
19314
  schComponentSvgs.push(
19133
19315
  ...createSvgObjectsFromSchematicComponent({
@@ -19242,6 +19424,13 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
19242
19424
  })
19243
19425
  );
19244
19426
  } else if (elm.type === "schematic_port") {
19427
+ schPortIndicatorSvgs.push(
19428
+ ...createSvgObjectsFromSchematicGroupPort({
19429
+ port: elm,
19430
+ transform,
19431
+ colorMap: colorMap2
19432
+ })
19433
+ );
19245
19434
  const sourcePort = sheetCircuitJson.find(
19246
19435
  (source) => source.type === "source_port" && source.source_port_id === elm.source_port_id
19247
19436
  );
@@ -19276,6 +19465,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
19276
19465
  ...schGraphicSvgs,
19277
19466
  ...schDebugObjectSvgs,
19278
19467
  ...schSheetSvgs,
19468
+ ...schGroupSvgs,
19279
19469
  ...schTraceBaseSvgs,
19280
19470
  ...schTraceOverlaySvgs,
19281
19471
  ...schPrimitiveSvgs,
@@ -19389,11 +19579,11 @@ function getSchematicGraphicViewport({
19389
19579
  return { x: 0, y: 0, width: svgWidth, height: svgHeight };
19390
19580
  }
19391
19581
  const layout = getSchematicSheetLayout(schematicSheet);
19392
- const topLeft = applyToPoint97(transform, {
19582
+ const topLeft = applyToPoint98(transform, {
19393
19583
  x: layout.innerMinX,
19394
19584
  y: layout.innerMaxY
19395
19585
  });
19396
- const bottomRight = applyToPoint97(transform, {
19586
+ const bottomRight = applyToPoint98(transform, {
19397
19587
  x: layout.innerMaxX,
19398
19588
  y: layout.innerMinY
19399
19589
  });
@@ -19434,7 +19624,7 @@ function clampGraphicDimension(requestedPixels, availablePixels) {
19434
19624
 
19435
19625
  // lib/sch/convert-circuit-json-to-stacked-schematic-sheets-svg.ts
19436
19626
  import { parseSync as parseSync3 } from "svgson";
19437
- import { applyToPoint as applyToPoint98, fromString } from "transformation-matrix";
19627
+ import { applyToPoint as applyToPoint99, fromString } from "transformation-matrix";
19438
19628
  var DEFAULT_SHEET_WIDTH = 1e3;
19439
19629
  var DEFAULT_LABEL_HEIGHT = 28;
19440
19630
  var DEFAULT_GAP = 16;
@@ -19546,7 +19736,7 @@ function getSheetLabelPosition({
19546
19736
  return { x: 4, y };
19547
19737
  }
19548
19738
  const layout = getSchematicSheetLayout(schematicSheet);
19549
- const frameLeft = applyToPoint98(fromString(transformStr), {
19739
+ const frameLeft = applyToPoint99(fromString(transformStr), {
19550
19740
  x: layout.minX,
19551
19741
  y: layout.maxY
19552
19742
  });
@@ -20442,8 +20632,35 @@ function wrapLegendText(label) {
20442
20632
  return lines;
20443
20633
  }
20444
20634
 
20445
- // lib/sim/simulation-graph-svg/create-legend.ts
20635
+ // lib/sim/simulation-graph-svg/create-legend/get-legend-bounds.ts
20446
20636
  var LEGEND_MIN_SPACING = 24;
20637
+ var LEGEND_FONT_SIZE = 11;
20638
+ var LEGEND_PADDING = 16;
20639
+ function getLegendBounds({
20640
+ graphs,
20641
+ width,
20642
+ height
20643
+ }) {
20644
+ let legendY = MARGIN.top;
20645
+ let rightEdge = width;
20646
+ let bottomEdge = height;
20647
+ for (const graph of graphs) {
20648
+ const lines = wrapLegendText(graph.label);
20649
+ const textWidth = Math.max(...lines.map((line) => estimateTextWidth(line))) * LEGEND_FONT_SIZE;
20650
+ rightEdge = Math.max(
20651
+ rightEdge,
20652
+ width - MARGIN.right + 30 + textWidth * 1.2 + LEGEND_PADDING
20653
+ );
20654
+ bottomEdge = Math.max(
20655
+ bottomEdge,
20656
+ legendY + (lines.length - 1) * LEGEND_LINE_HEIGHT + LEGEND_FONT_SIZE + LEGEND_PADDING
20657
+ );
20658
+ legendY += Math.max(lines.length * LEGEND_LINE_HEIGHT, LEGEND_MIN_SPACING);
20659
+ }
20660
+ return { width: Math.ceil(rightEdge), height: Math.ceil(bottomEdge) };
20661
+ }
20662
+
20663
+ // lib/sim/simulation-graph-svg/create-legend.ts
20447
20664
  function createLegend(graphs, width) {
20448
20665
  let currentY = MARGIN.top;
20449
20666
  const children = graphs.map((entry) => {
@@ -20914,9 +21131,10 @@ function convertCircuitJsonToSimulationGraphSvg({
20914
21131
  (entry) => entry.usesScopeTraceDisplay
20915
21132
  );
20916
21133
  const scopeAxisGutters = usesScopeTraceDisplay ? getScopeAxisGutters(preparedGraphs.length) : { left: 0, right: 0 };
20917
- const outputWidth = width + scopeAxisGutters.left + scopeAxisGutters.right;
21134
+ const regularLegendBounds = usesScopeTraceDisplay ? null : getLegendBounds({ graphs: preparedGraphs, width, height });
21135
+ const outputWidth = regularLegendBounds?.width ?? width + scopeAxisGutters.left + scopeAxisGutters.right;
20918
21136
  const scopeLegendLayout = usesScopeTraceDisplay ? getScopeLegendGridLayout(preparedGraphs.length, outputWidth) : null;
20919
- const outputHeight = scopeLegendLayout ? height + SCOPE_LEGEND_GAP + scopeLegendLayout.height + SCOPE_LEGEND_GAP : height;
21137
+ const outputHeight = scopeLegendLayout ? height + SCOPE_LEGEND_GAP + scopeLegendLayout.height + SCOPE_LEGEND_GAP : regularLegendBounds.height;
20920
21138
  const plotWidth = Math.max(1, width - MARGIN.left - MARGIN.right);
20921
21139
  const plotHeight = Math.max(1, height - MARGIN.top - MARGIN.bottom);
20922
21140
  const plotLeft = MARGIN.left + scopeAxisGutters.left;
@@ -20966,7 +21184,7 @@ function convertCircuitJsonToSimulationGraphSvg({
20966
21184
  xAxisTitle: normalizedResults.xAxisTitle,
20967
21185
  usesScopeTraceDisplay
20968
21186
  }),
20969
- usesScopeTraceDisplay ? createScopeLegend(preparedGraphs, outputWidth, height) : createLegend(preparedGraphs, outputWidth),
21187
+ usesScopeTraceDisplay ? createScopeLegend(preparedGraphs, outputWidth, height) : createLegend(preparedGraphs, width),
20970
21188
  ...titleNode ? [titleNode] : []
20971
21189
  ];
20972
21190
  const svgObject = svgElement(
@@ -21130,7 +21348,7 @@ function clamp01(value) {
21130
21348
  import { distance as distance9 } from "circuit-json";
21131
21349
  import "svgson";
21132
21350
  import {
21133
- applyToPoint as applyToPoint99,
21351
+ applyToPoint as applyToPoint100,
21134
21352
  compose as compose19,
21135
21353
  scale as scale9,
21136
21354
  translate as translate19
@@ -21280,8 +21498,8 @@ function createSvgObjects4({ elm, ctx }) {
21280
21498
  }
21281
21499
  }
21282
21500
  function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
21283
- const [x1, y1] = applyToPoint99(transform, [minX, minY]);
21284
- const [x2, y2] = applyToPoint99(transform, [maxX, maxY]);
21501
+ const [x1, y1] = applyToPoint100(transform, [minX, minY]);
21502
+ const [x2, y2] = applyToPoint100(transform, [maxX, maxY]);
21285
21503
  const width = Math.abs(x2 - x1);
21286
21504
  const height = Math.abs(y2 - y1);
21287
21505
  const x = Math.min(x1, x2);