@tscircuit/cli 0.1.125 → 0.1.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +297 -424
  2. package/package.json +3 -2
package/dist/main.js CHANGED
@@ -305499,9 +305499,9 @@ var require_color_string = __commonJS((exports2, module2) => {
305499
305499
  return null;
305500
305500
  }
305501
305501
  for (i = 0;i < 3; i++) {
305502
- rgb2[i] = clamp7(rgb2[i], 0, 255);
305502
+ rgb2[i] = clamp5(rgb2[i], 0, 255);
305503
305503
  }
305504
- rgb2[3] = clamp7(rgb2[3], 0, 1);
305504
+ rgb2[3] = clamp5(rgb2[3], 0, 1);
305505
305505
  return rgb2;
305506
305506
  };
305507
305507
  cs.get.hsl = function(string) {
@@ -305513,9 +305513,9 @@ var require_color_string = __commonJS((exports2, module2) => {
305513
305513
  if (match) {
305514
305514
  var alpha = parseFloat(match[4]);
305515
305515
  var h = (parseFloat(match[1]) % 360 + 360) % 360;
305516
- var s = clamp7(parseFloat(match[2]), 0, 100);
305517
- var l = clamp7(parseFloat(match[3]), 0, 100);
305518
- var a = clamp7(isNaN(alpha) ? 1 : alpha, 0, 1);
305516
+ var s = clamp5(parseFloat(match[2]), 0, 100);
305517
+ var l = clamp5(parseFloat(match[3]), 0, 100);
305518
+ var a = clamp5(isNaN(alpha) ? 1 : alpha, 0, 1);
305519
305519
  return [h, s, l, a];
305520
305520
  }
305521
305521
  return null;
@@ -305529,9 +305529,9 @@ var require_color_string = __commonJS((exports2, module2) => {
305529
305529
  if (match) {
305530
305530
  var alpha = parseFloat(match[4]);
305531
305531
  var h = (parseFloat(match[1]) % 360 + 360) % 360;
305532
- var w = clamp7(parseFloat(match[2]), 0, 100);
305533
- var b = clamp7(parseFloat(match[3]), 0, 100);
305534
- var a = clamp7(isNaN(alpha) ? 1 : alpha, 0, 1);
305532
+ var w = clamp5(parseFloat(match[2]), 0, 100);
305533
+ var b = clamp5(parseFloat(match[3]), 0, 100);
305534
+ var a = clamp5(isNaN(alpha) ? 1 : alpha, 0, 1);
305535
305535
  return [h, w, b, a];
305536
305536
  }
305537
305537
  return null;
@@ -305566,7 +305566,7 @@ var require_color_string = __commonJS((exports2, module2) => {
305566
305566
  cs.to.keyword = function(rgb2) {
305567
305567
  return reverseNames[rgb2.slice(0, 3)];
305568
305568
  };
305569
- function clamp7(num, min, max) {
305569
+ function clamp5(num, min, max) {
305570
305570
  return Math.min(Math.max(min, num), max);
305571
305571
  }
305572
305572
  function hexDouble(num) {
@@ -305720,9 +305720,9 @@ var require_conversions = __commonJS((exports2, module2) => {
305720
305720
  let currentClosestKeyword;
305721
305721
  for (const keyword of Object.keys(cssKeywords)) {
305722
305722
  const value2 = cssKeywords[keyword];
305723
- const distance8 = comparativeDistance(rgb2, value2);
305724
- if (distance8 < currentClosestDistance) {
305725
- currentClosestDistance = distance8;
305723
+ const distance6 = comparativeDistance(rgb2, value2);
305724
+ if (distance6 < currentClosestDistance) {
305725
+ currentClosestDistance = distance6;
305726
305726
  currentClosestKeyword = keyword;
305727
305727
  }
305728
305728
  }
@@ -441906,7 +441906,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
441906
441906
  import { execSync as execSync2 } from "node:child_process";
441907
441907
  var import_semver2 = __toESM2(require_semver2(), 1);
441908
441908
  // package.json
441909
- var version = "0.1.124";
441909
+ var version = "0.1.125";
441910
441910
  var package_default = {
441911
441911
  name: "@tscircuit/cli",
441912
441912
  version,
@@ -441917,6 +441917,7 @@ var package_default = {
441917
441917
  "@tscircuit/fake-snippets": "^0.0.75",
441918
441918
  "@tscircuit/file-server": "^0.0.24",
441919
441919
  "@tscircuit/runframe": "^0.0.566",
441920
+ "@tscircuit/math-utils": "^0.0.18",
441920
441921
  "@types/bun": "^1.2.2",
441921
441922
  "@types/configstore": "^6.0.2",
441922
441923
  "@types/debug": "^4.1.12",
@@ -441948,7 +441949,7 @@ var package_default = {
441948
441949
  redaxios: "^0.5.1",
441949
441950
  semver: "^7.6.3",
441950
441951
  tempy: "^3.1.0",
441951
- tscircuit: "^0.0.485",
441952
+ tscircuit: "^0.0.491",
441952
441953
  "@tscircuit/circuit-json-util": "^0.0.47",
441953
441954
  "typed-ky": "^0.0.4"
441954
441955
  },
@@ -464847,21 +464848,221 @@ init_dist2();
464847
464848
  // node_modules/@tscircuit/math-utils/dist/index.js
464848
464849
  var exports_dist3 = {};
464849
464850
  __export2(exports_dist3, {
464851
+ segmentToSegmentMinDistance: () => segmentToSegmentMinDistance,
464852
+ segmentToCircleMinDistance: () => segmentToCircleMinDistance,
464853
+ segmentToBoxMinDistance: () => segmentToBoxMinDistance,
464854
+ segmentToBoundsMinDistance: () => segmentToBoundsMinDistance,
464850
464855
  pointToSegmentDistance: () => pointToSegmentDistance2,
464856
+ pointToSegmentClosestPoint: () => pointToSegmentClosestPoint,
464857
+ pointToBoxDistance: () => pointToBoxDistance,
464858
+ pointToBoundsDistance: () => pointToBoundsDistance,
464851
464859
  orientation: () => orientation2,
464852
464860
  onSegment: () => onSegment2,
464861
+ midpoint: () => midpoint,
464853
464862
  grid: () => grid,
464854
464863
  getUnitVectorFromPointAToB: () => getUnitVectorFromPointAToB,
464855
464864
  getUnitVectorFromDirection: () => getUnitVectorFromDirection,
464865
+ getSegmentIntersection: () => getSegmentIntersection,
464856
464866
  getBoundingBox: () => getBoundingBox2,
464857
464867
  findNearestPointsBetweenBoxSets: () => findNearestPointsBetweenBoxSets2,
464858
464868
  doesLineIntersectLine: () => doesLineIntersectLine2,
464859
464869
  doSegmentsIntersect: () => doSegmentsIntersect2,
464860
464870
  distance: () => distance4,
464871
+ distSq: () => distSq,
464861
464872
  computeDistanceBetweenBoxes: () => computeDistanceBetweenBoxes2,
464862
464873
  clamp: () => clamp2
464863
464874
  });
464864
464875
 
464876
+ // node_modules/@tscircuit/math-utils/dist/chunk-3453HRP7.js
464877
+ function doesLineIntersectLine2([a1, a2], [b1, b2], {
464878
+ lineThickness = 0
464879
+ } = {}) {
464880
+ if (lineThickness === 0) {
464881
+ return doSegmentsIntersect2(a1, a2, b1, b2);
464882
+ }
464883
+ const minDist = segmentsDistance2(a1, a2, b1, b2);
464884
+ return minDist <= lineThickness;
464885
+ }
464886
+ function doSegmentsIntersect2(p1, q1, p2, q2) {
464887
+ const o1 = orientation2(p1, q1, p2);
464888
+ const o2 = orientation2(p1, q1, q2);
464889
+ const o3 = orientation2(p2, q2, p1);
464890
+ const o4 = orientation2(p2, q2, q1);
464891
+ if (o1 !== o2 && o3 !== o4) {
464892
+ return true;
464893
+ }
464894
+ if (o1 === 0 && onSegment2(p1, p2, q1))
464895
+ return true;
464896
+ if (o2 === 0 && onSegment2(p1, q2, q1))
464897
+ return true;
464898
+ if (o3 === 0 && onSegment2(p2, p1, q2))
464899
+ return true;
464900
+ if (o4 === 0 && onSegment2(p2, q1, q2))
464901
+ return true;
464902
+ return false;
464903
+ }
464904
+ function orientation2(p, q, r) {
464905
+ const val54 = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
464906
+ if (val54 === 0)
464907
+ return 0;
464908
+ return val54 > 0 ? 1 : 2;
464909
+ }
464910
+ function onSegment2(p, q, r) {
464911
+ return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
464912
+ }
464913
+ function segmentsDistance2(a1, a2, b1, b2) {
464914
+ if (a1.x === a2.x && a1.y === a2.y) {
464915
+ return pointToSegmentDistance2(a1, b1, b2);
464916
+ }
464917
+ if (b1.x === b2.x && b1.y === b2.y) {
464918
+ return pointToSegmentDistance2(b1, a1, a2);
464919
+ }
464920
+ if (doSegmentsIntersect2(a1, a2, b1, b2)) {
464921
+ return 0;
464922
+ }
464923
+ const distances = [
464924
+ pointToSegmentDistance2(a1, b1, b2),
464925
+ pointToSegmentDistance2(a2, b1, b2),
464926
+ pointToSegmentDistance2(b1, a1, a2),
464927
+ pointToSegmentDistance2(b2, a1, a2)
464928
+ ];
464929
+ return Math.min(...distances);
464930
+ }
464931
+ function pointToSegmentDistance2(p, v, w) {
464932
+ const l2 = (w.x - v.x) ** 2 + (w.y - v.y) ** 2;
464933
+ if (l2 === 0)
464934
+ return distance4(p, v);
464935
+ let t2 = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
464936
+ t2 = Math.max(0, Math.min(1, t2));
464937
+ const projection = {
464938
+ x: v.x + t2 * (w.x - v.x),
464939
+ y: v.y + t2 * (w.y - v.y)
464940
+ };
464941
+ return distance4(p, projection);
464942
+ }
464943
+ function distance4(p1, p2) {
464944
+ const dx = p1.x - p2.x;
464945
+ const dy = p1.y - p2.y;
464946
+ return Math.sqrt(dx * dx + dy * dy);
464947
+ }
464948
+ function getSegmentIntersection(a, b, u, v) {
464949
+ const dx1 = b.x - a.x;
464950
+ const dy1 = b.y - a.y;
464951
+ const dx2 = v.x - u.x;
464952
+ const dy2 = v.y - u.y;
464953
+ const dx3 = a.x - u.x;
464954
+ const dy3 = a.y - u.y;
464955
+ const denominator = dx1 * dy2 - dy1 * dx2;
464956
+ if (Math.abs(denominator) < 0.0000000001) {
464957
+ return null;
464958
+ }
464959
+ const t2 = (dy3 * dx2 - dx3 * dy2) / denominator;
464960
+ const s = (dx1 * dy3 - dy1 * dx3) / denominator;
464961
+ const epsilon = 0.000000001;
464962
+ if (t2 >= -epsilon && t2 <= 1 + epsilon && s >= -epsilon && s <= 1 + epsilon) {
464963
+ const intersectionX = a.x + t2 * dx1;
464964
+ const intersectionY = a.y + t2 * dy1;
464965
+ return { x: intersectionX, y: intersectionY };
464966
+ }
464967
+ return null;
464968
+ }
464969
+
464970
+ // node_modules/@tscircuit/math-utils/dist/chunk-FWQGMQBW.js
464971
+ function segmentToSegmentMinDistance(a, b, u, v) {
464972
+ if (a.x === b.x && a.y === b.y) {
464973
+ return pointToSegmentDistance2(a, u, v);
464974
+ }
464975
+ if (u.x === v.x && u.y === v.y) {
464976
+ return pointToSegmentDistance2(u, a, b);
464977
+ }
464978
+ if (doSegmentsIntersect2(a, b, u, v)) {
464979
+ return 0;
464980
+ }
464981
+ const distances = [
464982
+ pointToSegmentDistance2(a, u, v),
464983
+ pointToSegmentDistance2(b, u, v),
464984
+ pointToSegmentDistance2(u, a, b),
464985
+ pointToSegmentDistance2(v, a, b)
464986
+ ];
464987
+ return Math.min(...distances);
464988
+ }
464989
+ function segmentToBoundsMinDistance(a, b, bounds6) {
464990
+ const topLeft = { x: bounds6.minX, y: bounds6.minY };
464991
+ const topRight = { x: bounds6.maxX, y: bounds6.minY };
464992
+ const bottomLeft = { x: bounds6.minX, y: bounds6.maxY };
464993
+ const bottomRight = { x: bounds6.maxX, y: bounds6.maxY };
464994
+ if (doSegmentsIntersect2(a, b, topLeft, topRight) || doSegmentsIntersect2(a, b, topRight, bottomRight) || doSegmentsIntersect2(a, b, bottomRight, bottomLeft) || doSegmentsIntersect2(a, b, bottomLeft, topLeft)) {
464995
+ return 0;
464996
+ }
464997
+ if (a.x >= bounds6.minX && a.x <= bounds6.maxX && a.y >= bounds6.minY && a.y <= bounds6.maxY && b.x >= bounds6.minX && b.x <= bounds6.maxX && b.y >= bounds6.minY && b.y <= bounds6.maxY) {
464998
+ return 0;
464999
+ }
465000
+ const distances = [
465001
+ pointToSegmentDistance2(topLeft, a, b),
465002
+ pointToSegmentDistance2(topRight, a, b),
465003
+ pointToSegmentDistance2(bottomLeft, a, b),
465004
+ pointToSegmentDistance2(bottomRight, a, b)
465005
+ ];
465006
+ if (a.x >= bounds6.minX && a.x <= bounds6.maxX && a.y >= bounds6.minY && a.y <= bounds6.maxY) {
465007
+ return 0;
465008
+ }
465009
+ if (b.x >= bounds6.minX && b.x <= bounds6.maxX && b.y >= bounds6.minY && b.y <= bounds6.maxY) {
465010
+ return 0;
465011
+ }
465012
+ if (a.x < bounds6.minX || a.x > bounds6.maxX || a.y < bounds6.minY || a.y > bounds6.maxY) {
465013
+ const closestX = clamp2(a.x, bounds6.minX, bounds6.maxX);
465014
+ const closestY = clamp2(a.y, bounds6.minY, bounds6.maxY);
465015
+ distances.push(distance4(a, { x: closestX, y: closestY }));
465016
+ }
465017
+ if (b.x < bounds6.minX || b.x > bounds6.maxX || b.y < bounds6.minY || b.y > bounds6.maxY) {
465018
+ const closestX = clamp2(b.x, bounds6.minX, bounds6.maxX);
465019
+ const closestY = clamp2(b.y, bounds6.minY, bounds6.maxY);
465020
+ distances.push(distance4(b, { x: closestX, y: closestY }));
465021
+ }
465022
+ return Math.min(...distances);
465023
+ }
465024
+ function segmentToBoxMinDistance(a, b, box) {
465025
+ const halfWidth = box.width / 2;
465026
+ const halfHeight = box.height / 2;
465027
+ const bounds6 = {
465028
+ minX: box.center.x - halfWidth,
465029
+ maxX: box.center.x + halfWidth,
465030
+ minY: box.center.y - halfHeight,
465031
+ maxY: box.center.y + halfHeight
465032
+ };
465033
+ return segmentToBoundsMinDistance(a, b, bounds6);
465034
+ }
465035
+ function segmentToCircleMinDistance(a, b, circle) {
465036
+ const circleCenter = { x: circle.x, y: circle.y };
465037
+ if (a.x === b.x && a.y === b.y) {
465038
+ return Math.max(0, distance4(a, circleCenter) - circle.radius);
465039
+ }
465040
+ const ab = { x: b.x - a.x, y: b.y - a.y };
465041
+ const ac = { x: circleCenter.x - a.x, y: circleCenter.y - a.y };
465042
+ const abLengthSq = ab.x * ab.x + ab.y * ab.y;
465043
+ const t2 = Math.max(0, Math.min(1, (ab.x * ac.x + ab.y * ac.y) / abLengthSq));
465044
+ const closestPoint = {
465045
+ x: a.x + t2 * ab.x,
465046
+ y: a.y + t2 * ab.y
465047
+ };
465048
+ const distToCenter = distance4(closestPoint, circleCenter);
465049
+ return Math.max(0, distToCenter - circle.radius);
465050
+ }
465051
+ function pointToSegmentClosestPoint(p, a, b) {
465052
+ const dx_ab = b.x - a.x;
465053
+ const dy_ab = b.y - a.y;
465054
+ const l2 = dx_ab * dx_ab + dy_ab * dy_ab;
465055
+ if (l2 === 0)
465056
+ return { x: a.x, y: a.y };
465057
+ let t2 = ((p.x - a.x) * dx_ab + (p.y - a.y) * dy_ab) / l2;
465058
+ t2 = Math.max(0, Math.min(1, t2));
465059
+ const closestPoint = {
465060
+ x: a.x + t2 * dx_ab,
465061
+ y: a.y + t2 * dy_ab
465062
+ };
465063
+ return closestPoint;
465064
+ }
465065
+
464865
465066
  // node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
464866
465067
  var getUnitVectorFromPointAToB = (a, b) => {
464867
465068
  const delta = {
@@ -464934,77 +465135,39 @@ function grid({
464934
465135
  return cells;
464935
465136
  }
464936
465137
 
464937
- // node_modules/@tscircuit/math-utils/dist/chunk-CHQOCSFB.js
464938
- function doesLineIntersectLine2([a1, a2], [b1, b2], {
464939
- lineThickness = 0
464940
- } = {}) {
464941
- if (lineThickness === 0) {
464942
- return doSegmentsIntersect2(a1, a2, b1, b2);
464943
- }
464944
- const minDist = segmentsDistance2(a1, a2, b1, b2);
464945
- return minDist <= lineThickness;
464946
- }
464947
- function doSegmentsIntersect2(p1, q1, p2, q2) {
464948
- const o1 = orientation2(p1, q1, p2);
464949
- const o2 = orientation2(p1, q1, q2);
464950
- const o3 = orientation2(p2, q2, p1);
464951
- const o4 = orientation2(p2, q2, q1);
464952
- if (o1 !== o2 && o3 !== o4) {
464953
- return true;
464954
- }
464955
- if (o1 === 0 && onSegment2(p1, p2, q1))
464956
- return true;
464957
- if (o2 === 0 && onSegment2(p1, q2, q1))
464958
- return true;
464959
- if (o3 === 0 && onSegment2(p2, p1, q2))
464960
- return true;
464961
- if (o4 === 0 && onSegment2(p2, q1, q2))
464962
- return true;
464963
- return false;
464964
- }
464965
- function orientation2(p, q, r) {
464966
- const val54 = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
464967
- if (val54 === 0)
465138
+ // node_modules/@tscircuit/math-utils/dist/chunk-SLG2OU3P.js
465139
+ function pointToBoxDistance(p, box) {
465140
+ const halfWidth = box.width / 2;
465141
+ const halfHeight = box.height / 2;
465142
+ const minX = box.center.x - halfWidth;
465143
+ const maxX = box.center.x + halfWidth;
465144
+ const minY = box.center.y - halfHeight;
465145
+ const maxY = box.center.y + halfHeight;
465146
+ if (p.x >= minX && p.x <= maxX && p.y >= minY && p.y <= maxY) {
464968
465147
  return 0;
464969
- return val54 > 0 ? 1 : 2;
464970
- }
464971
- function onSegment2(p, q, r) {
464972
- return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
464973
- }
464974
- function segmentsDistance2(a1, a2, b1, b2) {
464975
- if (a1.x === a2.x && a1.y === a2.y) {
464976
- return pointToSegmentDistance2(a1, b1, b2);
464977
465148
  }
464978
- if (b1.x === b2.x && b1.y === b2.y) {
464979
- return pointToSegmentDistance2(b1, a1, a2);
464980
- }
464981
- if (doSegmentsIntersect2(a1, a2, b1, b2)) {
465149
+ const closestX = clamp2(p.x, minX, maxX);
465150
+ const closestY = clamp2(p.y, minY, maxY);
465151
+ return distance4(p, { x: closestX, y: closestY });
465152
+ }
465153
+ function pointToBoundsDistance(p, bounds6) {
465154
+ if (p.x >= bounds6.minX && p.x <= bounds6.maxX && p.y >= bounds6.minY && p.y <= bounds6.maxY) {
464982
465155
  return 0;
464983
465156
  }
464984
- const distances = [
464985
- pointToSegmentDistance2(a1, b1, b2),
464986
- pointToSegmentDistance2(a2, b1, b2),
464987
- pointToSegmentDistance2(b1, a1, a2),
464988
- pointToSegmentDistance2(b2, a1, a2)
464989
- ];
464990
- return Math.min(...distances);
465157
+ const closestX = clamp2(p.x, bounds6.minX, bounds6.maxX);
465158
+ const closestY = clamp2(p.y, bounds6.minY, bounds6.maxY);
465159
+ return distance4(p, { x: closestX, y: closestY });
464991
465160
  }
464992
- function pointToSegmentDistance2(p, v, w) {
464993
- const l2 = (w.x - v.x) ** 2 + (w.y - v.y) ** 2;
464994
- if (l2 === 0)
464995
- return distance4(p, v);
464996
- let t2 = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
464997
- t2 = Math.max(0, Math.min(1, t2));
464998
- const projection = {
464999
- x: v.x + t2 * (w.x - v.x),
465000
- y: v.y + t2 * (w.y - v.y)
465161
+ function midpoint(p1, p2) {
465162
+ return {
465163
+ x: (p1.x + p2.x) / 2,
465164
+ y: (p1.y + p2.y) / 2
465001
465165
  };
465002
- return distance4(p, projection);
465003
465166
  }
465004
- function distance4(p1, p2) {
465167
+ function distSq(p1, p2) {
465005
465168
  const dx = p1.x - p2.x;
465006
465169
  const dy = p1.y - p2.y;
465007
- return Math.sqrt(dx * dx + dy * dy);
465170
+ return dx * dx + dy * dy;
465008
465171
  }
465009
465172
 
465010
465173
  // node_modules/@tscircuit/core/dist/index.js
@@ -468117,7 +468280,7 @@ function distance5(p1, p2) {
468117
468280
  const dy = p1.y - p2.y;
468118
468281
  return Math.sqrt(dx * dx + dy * dy);
468119
468282
  }
468120
- function getSegmentIntersection(a, b, u, v) {
468283
+ function getSegmentIntersection2(a, b, u, v) {
468121
468284
  const dx1 = b.x - a.x;
468122
468285
  const dy1 = b.y - a.y;
468123
468286
  const dx2 = v.x - u.x;
@@ -468168,7 +468331,7 @@ function computeDistanceBetweenBoxes3(boxA, boxB) {
468168
468331
  function clamp3(value2, min, max) {
468169
468332
  return Math.max(min, Math.min(max, value2));
468170
468333
  }
468171
- function segmentToSegmentMinDistance(a, b, u, v) {
468334
+ function segmentToSegmentMinDistance2(a, b, u, v) {
468172
468335
  if (a.x === b.x && a.y === b.y) {
468173
468336
  return pointToSegmentDistance3(a, u, v);
468174
468337
  }
@@ -468186,7 +468349,7 @@ function segmentToSegmentMinDistance(a, b, u, v) {
468186
468349
  ];
468187
468350
  return Math.min(...distances);
468188
468351
  }
468189
- function segmentToBoundsMinDistance(a, b, bounds6) {
468352
+ function segmentToBoundsMinDistance2(a, b, bounds6) {
468190
468353
  const topLeft = { x: bounds6.minX, y: bounds6.minY };
468191
468354
  const topRight = { x: bounds6.maxX, y: bounds6.minY };
468192
468355
  const bottomLeft = { x: bounds6.minX, y: bounds6.maxY };
@@ -468221,7 +468384,7 @@ function segmentToBoundsMinDistance(a, b, bounds6) {
468221
468384
  }
468222
468385
  return Math.min(...distances);
468223
468386
  }
468224
- function segmentToBoxMinDistance(a, b, box) {
468387
+ function segmentToBoxMinDistance2(a, b, box) {
468225
468388
  const halfWidth = box.width / 2;
468226
468389
  const halfHeight = box.height / 2;
468227
468390
  const bounds6 = {
@@ -468230,9 +468393,9 @@ function segmentToBoxMinDistance(a, b, box) {
468230
468393
  minY: box.center.y - halfHeight,
468231
468394
  maxY: box.center.y + halfHeight
468232
468395
  };
468233
- return segmentToBoundsMinDistance(a, b, bounds6);
468396
+ return segmentToBoundsMinDistance2(a, b, bounds6);
468234
468397
  }
468235
- function pointToSegmentClosestPoint(p, a, b) {
468398
+ function pointToSegmentClosestPoint2(p, a, b) {
468236
468399
  const dx_ab = b.x - a.x;
468237
468400
  const dy_ab = b.y - a.y;
468238
468401
  const l2 = dx_ab * dx_ab + dy_ab * dy_ab;
@@ -468246,7 +468409,7 @@ function pointToSegmentClosestPoint(p, a, b) {
468246
468409
  };
468247
468410
  return closestPoint;
468248
468411
  }
468249
- function midpoint(p1, p2) {
468412
+ function midpoint2(p1, p2) {
468250
468413
  return {
468251
468414
  x: (p1.x + p2.x) / 2,
468252
468415
  y: (p1.y + p2.y) / 2
@@ -469298,7 +469461,7 @@ function computeDumbbellPaths({
469298
469461
  margin,
469299
469462
  subdivisions = 0
469300
469463
  }) {
469301
- const midpoint2 = (p1, p2) => ({
469464
+ const midpoint22 = (p1, p2) => ({
469302
469465
  x: (p1.x + p2.x) / 2,
469303
469466
  y: (p1.y + p2.y) / 2
469304
469467
  });
@@ -469505,8 +469668,8 @@ function computeDumbbellPaths({
469505
469668
  innerPoints.B_Left,
469506
469669
  innerPoints.B_Opp,
469507
469670
  innerPoints.B_Right,
469508
- midpoint2(innerPoints.midpoint, midpoint2(innerPoints.B_Right, innerPoints.A_Right)),
469509
- midpoint2(innerPoints.midpoint, midpoint2(innerPoints.A_Left, innerPoints.B_Left)),
469671
+ midpoint22(innerPoints.midpoint, midpoint22(innerPoints.B_Right, innerPoints.A_Right)),
469672
+ midpoint22(innerPoints.midpoint, midpoint22(innerPoints.A_Left, innerPoints.B_Left)),
469510
469673
  innerPoints.A_Left,
469511
469674
  innerPoints.A_Opp,
469512
469675
  innerPoints.A_Right,
@@ -469517,8 +469680,8 @@ function computeDumbbellPaths({
469517
469680
  innerPoints.B_Right,
469518
469681
  innerPoints.B_Opp,
469519
469682
  innerPoints.B_Left,
469520
- midpoint2(innerPoints.midpoint, midpoint2(innerPoints.A_Left, innerPoints.B_Left)),
469521
- midpoint2(innerPoints.midpoint, midpoint2(innerPoints.A_Right, innerPoints.B_Right)),
469683
+ midpoint22(innerPoints.midpoint, midpoint22(innerPoints.A_Left, innerPoints.B_Left)),
469684
+ midpoint22(innerPoints.midpoint, midpoint22(innerPoints.A_Right, innerPoints.B_Right)),
469522
469685
  innerPoints.A_Right,
469523
469686
  innerPoints.A_Opp,
469524
469687
  innerPoints.A_Left,
@@ -469529,8 +469692,8 @@ function computeDumbbellPaths({
469529
469692
  innerPoints.B_Left,
469530
469693
  innerPoints.B_Opp,
469531
469694
  innerPoints.B_Right,
469532
- midpoint2(innerPoints.midpoint, midpoint2(innerPoints.A_Right, innerPoints.B_Right)),
469533
- midpoint2(innerPoints.midpoint, midpoint2(innerPoints.A_Left, innerPoints.B_Left)),
469695
+ midpoint22(innerPoints.midpoint, midpoint22(innerPoints.A_Right, innerPoints.B_Right)),
469696
+ midpoint22(innerPoints.midpoint, midpoint22(innerPoints.A_Left, innerPoints.B_Left)),
469534
469697
  innerPoints.A_Left,
469535
469698
  innerPoints.A_Opp,
469536
469699
  innerPoints.A_Right,
@@ -469541,8 +469704,8 @@ function computeDumbbellPaths({
469541
469704
  innerPoints.B_Right,
469542
469705
  innerPoints.B_Opp,
469543
469706
  innerPoints.B_Left,
469544
- midpoint2(innerPoints.midpoint, midpoint2(innerPoints.A_Left, innerPoints.B_Left)),
469545
- midpoint2(innerPoints.midpoint, midpoint2(innerPoints.A_Right, innerPoints.B_Right)),
469707
+ midpoint22(innerPoints.midpoint, midpoint22(innerPoints.A_Left, innerPoints.B_Left)),
469708
+ midpoint22(innerPoints.midpoint, midpoint22(innerPoints.A_Right, innerPoints.B_Right)),
469546
469709
  innerPoints.A_Right,
469547
469710
  innerPoints.A_Opp,
469548
469711
  innerPoints.A_Left,
@@ -469550,8 +469713,8 @@ function computeDumbbellPaths({
469550
469713
  ]
469551
469714
  ];
469552
469715
  const getJLines = () => {
469553
- const mid_AR_BR = midpoint2(innerPoints.A_Right, innerPoints.B_Right);
469554
- const mid_AL_BL = midpoint2(innerPoints.B_Left, innerPoints.A_Left);
469716
+ const mid_AR_BR = midpoint22(innerPoints.A_Right, innerPoints.B_Right);
469717
+ const mid_AL_BL = midpoint22(innerPoints.B_Left, innerPoints.A_Left);
469555
469718
  return [
469556
469719
  { startsAt: "E", goesTo: "B", points: [E, B] },
469557
469720
  { startsAt: "E", goesTo: "A", points: [E, A] },
@@ -471246,7 +471409,7 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
471246
471409
  if (segment[0].z !== this.currentHead.z) {
471247
471410
  continue;
471248
471411
  }
471249
- const intersection = getSegmentIntersection(proposedSegment[0], proposedSegment[1], segment[0], segment[1]);
471412
+ const intersection = getSegmentIntersection2(proposedSegment[0], proposedSegment[1], segment[0], segment[1]);
471250
471413
  if (intersection) {
471251
471414
  const distToIntersection = distance5(this.currentHead, intersection);
471252
471415
  if (distToIntersection < 0.000001)
@@ -471269,7 +471432,7 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
471269
471432
  let viaXY;
471270
471433
  const distToIntersection = closestIntersection.dist;
471271
471434
  if (distToIntersection < this.VIA_INTERSECTION_BUFFER_DISTANCE) {
471272
- viaXY = midpoint(this.currentHead, closestIntersection.point);
471435
+ viaXY = midpoint2(this.currentHead, closestIntersection.point);
471273
471436
  } else {
471274
471437
  const intersectionPoint = closestIntersection.point;
471275
471438
  const vectorX = intersectionPoint.x - this.currentHead.x;
@@ -471294,7 +471457,7 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
471294
471457
  let viaXY;
471295
471458
  const distToTarget = distance5(this.currentHead, targetEnd);
471296
471459
  if (distToTarget < this.VIA_INTERSECTION_BUFFER_DISTANCE) {
471297
- viaXY = midpoint(this.currentHead, targetEnd);
471460
+ viaXY = midpoint2(this.currentHead, targetEnd);
471298
471461
  } else {
471299
471462
  const vectorX = targetEnd.x - this.currentHead.x;
471300
471463
  const vectorY = targetEnd.y - this.currentHead.y;
@@ -472304,7 +472467,7 @@ var MultiHeadPolyLineIntraNodeSolver = class extends BaseSolver {
472304
472467
  const path2Segments = path2SegmentsByLayer.get(zLayer) ?? [];
472305
472468
  for (const segment1 of path1Segments) {
472306
472469
  for (const segment2 of path2Segments) {
472307
- minGap = Math.min(minGap, segmentToSegmentMinDistance(segment1[0], segment1[1], segment2[0], segment2[1]) - this.traceWidth);
472470
+ minGap = Math.min(minGap, segmentToSegmentMinDistance2(segment1[0], segment1[1], segment2[0], segment2[1]) - this.traceWidth);
472308
472471
  }
472309
472472
  }
472310
472473
  for (const via of path1Vias) {
@@ -472513,7 +472676,7 @@ var MultiHeadPolyLineIntraNodeSolver = class extends BaseSolver {
472513
472676
  for (const seg1 of segments1) {
472514
472677
  for (const seg2 of segments2) {
472515
472678
  if (seg1.layer === seg2.layer) {
472516
- const minDist = segmentToSegmentMinDistance(seg1.p1, seg1.p2, seg2.p1, seg2.p2);
472679
+ const minDist = segmentToSegmentMinDistance2(seg1.p1, seg1.p2, seg2.p1, seg2.p2);
472517
472680
  if (minDist < EPSILON4)
472518
472681
  continue;
472519
472682
  const center1 = {
@@ -472535,7 +472698,7 @@ var MultiHeadPolyLineIntraNodeSolver = class extends BaseSolver {
472535
472698
  const sourceIdSeg2 = `seg:${j}:${seg2.p1Idx}:${seg2.p2Idx}`;
472536
472699
  const sourceIdSeg1 = `seg:${i}:${seg1.p1Idx}:${seg1.p2Idx}`;
472537
472700
  const endpointForce = (ep, epIdx, otherSeg, targetLine, oppLine, srcIdOpp, srcIdThis) => {
472538
- const cp = pointToSegmentClosestPoint(ep, otherSeg.p1, otherSeg.p2);
472701
+ const cp = pointToSegmentClosestPoint2(ep, otherSeg.p1, otherSeg.p2);
472539
472702
  const dx2 = ep.x - cp.x;
472540
472703
  const dy2 = ep.y - cp.y;
472541
472704
  const dSq2 = dx2 * dx2 + dy2 * dy2;
@@ -472560,7 +472723,7 @@ var MultiHeadPolyLineIntraNodeSolver = class extends BaseSolver {
472560
472723
  for (const via1 of vias1) {
472561
472724
  for (const seg2 of segments2) {
472562
472725
  if (via1.layers.includes(seg2.layer)) {
472563
- const closestPointOnSeg = pointToSegmentClosestPoint(via1.point, seg2.p1, seg2.p2);
472726
+ const closestPointOnSeg = pointToSegmentClosestPoint2(via1.point, seg2.p1, seg2.p2);
472564
472727
  const dx = via1.point.x - closestPointOnSeg.x;
472565
472728
  const dy = via1.point.y - closestPointOnSeg.y;
472566
472729
  const dSq = dx * dx + dy * dy;
@@ -472589,7 +472752,7 @@ var MultiHeadPolyLineIntraNodeSolver = class extends BaseSolver {
472589
472752
  for (const via2 of vias2) {
472590
472753
  for (const seg1 of segments1) {
472591
472754
  if (via2.layers.includes(seg1.layer)) {
472592
- const closestPointOnSeg = pointToSegmentClosestPoint(via2.point, seg1.p1, seg1.p2);
472755
+ const closestPointOnSeg = pointToSegmentClosestPoint2(via2.point, seg1.p1, seg1.p2);
472593
472756
  const dx = via2.point.x - closestPointOnSeg.x;
472594
472757
  const dy = via2.point.y - closestPointOnSeg.y;
472595
472758
  const dSq = dx * dx + dy * dy;
@@ -473054,7 +473217,7 @@ var MultiHeadPolyLineIntraNodeSolver2 = class extends MultiHeadPolyLineIntraNode
473054
473217
  }
473055
473218
  };
473056
473219
  const endpointForce = (ep, epIdx, otherSeg, targetLine, oppLine) => {
473057
- const cp = pointToSegmentClosestPoint(ep, otherSeg.p1, otherSeg.p2);
473220
+ const cp = pointToSegmentClosestPoint2(ep, otherSeg.p1, otherSeg.p2);
473058
473221
  const dx = ep.x - cp.x;
473059
473222
  const dy = ep.y - cp.y;
473060
473223
  const dSq = dx * dx + dy * dy;
@@ -473107,7 +473270,7 @@ var MultiHeadPolyLineIntraNodeSolver2 = class extends MultiHeadPolyLineIntraNode
473107
473270
  for (const seg1 of segments1) {
473108
473271
  for (const seg2 of segments2) {
473109
473272
  if (seg1.layer === seg2.layer) {
473110
- const minDist = segmentToSegmentMinDistance(seg1.p1, seg1.p2, seg2.p1, seg2.p2);
473273
+ const minDist = segmentToSegmentMinDistance2(seg1.p1, seg1.p2, seg2.p1, seg2.p2);
473111
473274
  endpointForce(seg1.p1, seg1.p1Idx, seg2, i, j);
473112
473275
  endpointForce(seg1.p2, seg1.p2Idx, seg2, i, j);
473113
473276
  endpointForce(seg2.p1, seg2.p1Idx, seg1, j, i);
@@ -473118,7 +473281,7 @@ var MultiHeadPolyLineIntraNodeSolver2 = class extends MultiHeadPolyLineIntraNode
473118
473281
  for (const via1 of vias1) {
473119
473282
  for (const seg2 of segments2) {
473120
473283
  if (via1.layers.includes(seg2.layer)) {
473121
- const closestPointOnSeg = pointToSegmentClosestPoint(via1.point, seg2.p1, seg2.p2);
473284
+ const closestPointOnSeg = pointToSegmentClosestPoint2(via1.point, seg2.p1, seg2.p2);
473122
473285
  const dx = via1.point.x - closestPointOnSeg.x;
473123
473286
  const dy = via1.point.y - closestPointOnSeg.y;
473124
473287
  const dSq = dx * dx + dy * dy;
@@ -473145,7 +473308,7 @@ var MultiHeadPolyLineIntraNodeSolver2 = class extends MultiHeadPolyLineIntraNode
473145
473308
  for (const via2 of vias2) {
473146
473309
  for (const seg1 of segments1) {
473147
473310
  if (via2.layers.includes(seg1.layer)) {
473148
- const closestPointOnSeg = pointToSegmentClosestPoint(via2.point, seg1.p1, seg1.p2);
473311
+ const closestPointOnSeg = pointToSegmentClosestPoint2(via2.point, seg1.p1, seg1.p2);
473149
473312
  const dx = via2.point.x - closestPointOnSeg.x;
473150
473313
  const dy = via2.point.y - closestPointOnSeg.y;
473151
473314
  const dSq = dx * dx + dy * dy;
@@ -479036,7 +479199,7 @@ var SingleSimplifiedPathSolver5 = class extends SingleSimplifiedPathSolver {
479036
479199
  if (!obstacle.zLayers?.includes(start.z)) {
479037
479200
  continue;
479038
479201
  }
479039
- const distToObstacle = segmentToBoxMinDistance(start, end, obstacle);
479202
+ const distToObstacle = segmentToBoxMinDistance2(start, end, obstacle);
479040
479203
  if (distToObstacle < this.OBSTACLE_MARGIN + this.TRACE_THICKNESS / 2) {
479041
479204
  return false;
479042
479205
  }
@@ -479954,7 +480117,7 @@ var SingleRouteUselessViaRemovalSolver = class extends BaseSolver {
479954
480117
  };
479955
480118
  const obstacles = this.obstacleSHI.searchArea(segmentBox.centerX, segmentBox.centerY, segmentBox.width + (this.TRACE_THICKNESS + this.OBSTACLE_MARGIN) * 2, segmentBox.height + (this.TRACE_THICKNESS + this.OBSTACLE_MARGIN) * 2);
479956
480119
  for (const obstacle of obstacles) {
479957
- const distToObstacle = segmentToBoxMinDistance(A, B, obstacle);
480120
+ const distToObstacle = segmentToBoxMinDistance2(A, B, obstacle);
479958
480121
  if (distToObstacle < this.TRACE_THICKNESS + this.OBSTACLE_MARGIN) {
479959
480122
  return false;
479960
480123
  }
@@ -480502,303 +480665,13 @@ init_dist2();
480502
480665
  // node_modules/@tscircuit/checks/dist/index.js
480503
480666
  init_dist4();
480504
480667
  init_dist4();
480505
-
480506
- // node_modules/@tscircuit/checks/node_modules/circuit-json-to-connectivity-map/dist/index.js
480507
- function findConnectedNetworks2(connections) {
480508
- const networks = /* @__PURE__ */ new Map;
480509
- let netCounter = 0;
480510
- function getOrCreateNetwork(nodeId) {
480511
- for (const [, network] of networks) {
480512
- if (network.has(nodeId)) {
480513
- return network;
480514
- }
480515
- }
480516
- const newNetwork = /* @__PURE__ */ new Set;
480517
- networks.set(`connectivity_net${netCounter++}`, newNetwork);
480518
- return newNetwork;
480519
- }
480520
- for (const connection of connections) {
480521
- let network = null;
480522
- for (const nodeId of connection) {
480523
- if (!network) {
480524
- network = getOrCreateNetwork(nodeId);
480525
- } else if (!network.has(nodeId)) {
480526
- const existingNetwork = getOrCreateNetwork(nodeId);
480527
- if (existingNetwork !== network) {
480528
- for (const node of existingNetwork) {
480529
- network.add(node);
480530
- }
480531
- networks.delete(Array.from(networks.entries()).find(([, net2]) => net2 === existingNetwork)[0]);
480532
- }
480533
- }
480534
- network.add(nodeId);
480535
- }
480536
- }
480537
- return Object.fromEntries(Array.from(networks.entries()).map(([netId, connectedNodes]) => [
480538
- netId,
480539
- Array.from(connectedNodes)
480540
- ]));
480541
- }
480542
- var ConnectivityMap3 = class {
480543
- netMap;
480544
- idToNetMap;
480545
- constructor(netMap) {
480546
- this.netMap = netMap;
480547
- this.idToNetMap = {};
480548
- for (const [netId, ids] of Object.entries(netMap)) {
480549
- for (const id of ids) {
480550
- this.idToNetMap[id] = netId;
480551
- }
480552
- }
480553
- }
480554
- addConnections(connections) {
480555
- for (const connection of connections) {
480556
- const existingNets = /* @__PURE__ */ new Set;
480557
- for (const id of connection) {
480558
- const existingNetId = this.idToNetMap[id];
480559
- if (existingNetId) {
480560
- existingNets.add(existingNetId);
480561
- }
480562
- }
480563
- let targetNetId;
480564
- if (existingNets.size === 0) {
480565
- targetNetId = `connectivity_net${Object.keys(this.netMap).length}`;
480566
- this.netMap[targetNetId] = [];
480567
- } else if (existingNets.size === 1) {
480568
- targetNetId = existingNets.values().next().value ?? `connectivity_net${Object.keys(this.netMap).length}`;
480569
- } else {
480570
- targetNetId = existingNets.values().next().value ?? `connectivity_net${Object.keys(this.netMap).length}`;
480571
- for (const netId of existingNets) {
480572
- if (netId !== targetNetId) {
480573
- this.netMap[targetNetId].push(...this.netMap[netId]);
480574
- this.netMap[netId] = this.netMap[targetNetId];
480575
- for (const id of this.netMap[targetNetId]) {
480576
- this.idToNetMap[id] = targetNetId;
480577
- }
480578
- }
480579
- }
480580
- }
480581
- for (const id of connection) {
480582
- if (!this.netMap[targetNetId].includes(id)) {
480583
- this.netMap[targetNetId].push(id);
480584
- }
480585
- this.idToNetMap[id] = targetNetId;
480586
- }
480587
- }
480588
- }
480589
- getIdsConnectedToNet(netId) {
480590
- return this.netMap[netId] || [];
480591
- }
480592
- getNetConnectedToId(id) {
480593
- return this.idToNetMap[id];
480594
- }
480595
- areIdsConnected(id1, id2) {
480596
- if (id1 === id2)
480597
- return true;
480598
- const netId1 = this.getNetConnectedToId(id1);
480599
- if (!netId1)
480600
- return false;
480601
- const netId2 = this.getNetConnectedToId(id2);
480602
- if (!netId2)
480603
- return false;
480604
- return netId1 === netId2 || netId2 === id1 || netId2 === id1;
480605
- }
480606
- areAllIdsConnected(ids) {
480607
- const netId = this.getNetConnectedToId(ids[0]);
480608
- for (const id of ids) {
480609
- const nextNetId = this.getNetConnectedToId(id);
480610
- if (nextNetId === undefined) {
480611
- return false;
480612
- }
480613
- if (nextNetId !== netId) {
480614
- return false;
480615
- }
480616
- }
480617
- return true;
480618
- }
480619
- };
480620
- var getFullConnectivityMapFromCircuitJson2 = (circuitJson) => {
480621
- const connections = [];
480622
- for (const element of circuitJson) {
480623
- if (element.type === "source_trace") {
480624
- connections.push([
480625
- element.source_trace_id,
480626
- ...element.connected_source_port_ids ?? [],
480627
- ...element.connected_source_net_ids ?? []
480628
- ].filter(Boolean));
480629
- } else if (element.type === "pcb_port") {
480630
- const { pcb_port_id, source_port_id } = element;
480631
- if (source_port_id && pcb_port_id) {
480632
- connections.push([source_port_id, pcb_port_id]);
480633
- }
480634
- } else if (element.type === "pcb_smtpad") {
480635
- const { pcb_smtpad_id, pcb_port_id } = element;
480636
- if (pcb_port_id && pcb_smtpad_id) {
480637
- connections.push([pcb_smtpad_id, pcb_port_id]);
480638
- }
480639
- } else if (element.type === "pcb_plated_hole") {
480640
- const { pcb_plated_hole_id, pcb_port_id } = element;
480641
- if (pcb_port_id && pcb_plated_hole_id) {
480642
- connections.push([pcb_plated_hole_id, pcb_port_id]);
480643
- }
480644
- } else if (element.type === "pcb_trace") {
480645
- const { pcb_trace_id, source_trace_id } = element;
480646
- const route = Array.isArray(element.route) ? element.route.filter((rp) => rp && rp.route_type === "wire") : [];
480647
- if (source_trace_id && pcb_trace_id) {
480648
- connections.push([pcb_trace_id, source_trace_id]);
480649
- }
480650
- if (Array.isArray(route)) {
480651
- const startId = route.find((rp) => rp && rp.start_pcb_port_id)?.start_pcb_port_id;
480652
- const endId = route.find((rp) => rp && rp.end_pcb_port_id)?.end_pcb_port_id;
480653
- if (startId && pcb_trace_id && endId) {
480654
- connections.push([startId, pcb_trace_id, endId]);
480655
- }
480656
- }
480657
- } else if (element.type === "pcb_via") {
480658
- const { pcb_via_id, pcb_trace_id } = element;
480659
- if (pcb_trace_id && pcb_via_id) {
480660
- connections.push([pcb_via_id, pcb_trace_id]);
480661
- }
480662
- } else if (element.type === "source_component") {
480663
- if (element.internally_connected_source_port_ids) {
480664
- for (const portGroup of element.internally_connected_source_port_ids) {
480665
- connections.push(portGroup);
480666
- }
480667
- }
480668
- }
480669
- }
480670
- const netMap = findConnectedNetworks2(connections);
480671
- return new ConnectivityMap3(netMap);
480672
- };
480673
-
480674
- // node_modules/@tscircuit/checks/dist/index.js
480668
+ init_dist2();
480675
480669
  init_dist4();
480676
-
480677
- // node_modules/@tscircuit/checks/node_modules/@tscircuit/math-utils/dist/chunk-3453HRP7.js
480678
- function doSegmentsIntersect5(p1, q1, p2, q2) {
480679
- const o1 = orientation5(p1, q1, p2);
480680
- const o2 = orientation5(p1, q1, q2);
480681
- const o3 = orientation5(p2, q2, p1);
480682
- const o4 = orientation5(p2, q2, q1);
480683
- if (o1 !== o2 && o3 !== o4) {
480684
- return true;
480685
- }
480686
- if (o1 === 0 && onSegment5(p1, p2, q1))
480687
- return true;
480688
- if (o2 === 0 && onSegment5(p1, q2, q1))
480689
- return true;
480690
- if (o3 === 0 && onSegment5(p2, p1, q2))
480691
- return true;
480692
- if (o4 === 0 && onSegment5(p2, q1, q2))
480693
- return true;
480694
- return false;
480695
- }
480696
- function orientation5(p, q, r) {
480697
- const val54 = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
480698
- if (val54 === 0)
480699
- return 0;
480700
- return val54 > 0 ? 1 : 2;
480701
- }
480702
- function onSegment5(p, q, r) {
480703
- return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
480704
- }
480705
- function pointToSegmentDistance5(p, v, w) {
480706
- const l2 = (w.x - v.x) ** 2 + (w.y - v.y) ** 2;
480707
- if (l2 === 0)
480708
- return distance7(p, v);
480709
- let t2 = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
480710
- t2 = Math.max(0, Math.min(1, t2));
480711
- const projection = {
480712
- x: v.x + t2 * (w.x - v.x),
480713
- y: v.y + t2 * (w.y - v.y)
480714
- };
480715
- return distance7(p, projection);
480716
- }
480717
- function distance7(p1, p2) {
480718
- const dx = p1.x - p2.x;
480719
- const dy = p1.y - p2.y;
480720
- return Math.sqrt(dx * dx + dy * dy);
480721
- }
480722
-
480723
- // node_modules/@tscircuit/checks/node_modules/@tscircuit/math-utils/dist/chunk-MHHTZHOJ.js
480724
- function clamp5(value2, min, max) {
480725
- return Math.max(min, Math.min(max, value2));
480726
- }
480727
-
480728
- // node_modules/@tscircuit/checks/node_modules/@tscircuit/math-utils/dist/chunk-FWQGMQBW.js
480729
- function segmentToSegmentMinDistance2(a, b, u, v) {
480730
- if (a.x === b.x && a.y === b.y) {
480731
- return pointToSegmentDistance5(a, u, v);
480732
- }
480733
- if (u.x === v.x && u.y === v.y) {
480734
- return pointToSegmentDistance5(u, a, b);
480735
- }
480736
- if (doSegmentsIntersect5(a, b, u, v)) {
480737
- return 0;
480738
- }
480739
- const distances = [
480740
- pointToSegmentDistance5(a, u, v),
480741
- pointToSegmentDistance5(b, u, v),
480742
- pointToSegmentDistance5(u, a, b),
480743
- pointToSegmentDistance5(v, a, b)
480744
- ];
480745
- return Math.min(...distances);
480746
- }
480747
- function segmentToBoundsMinDistance2(a, b, bounds6) {
480748
- const topLeft = { x: bounds6.minX, y: bounds6.minY };
480749
- const topRight = { x: bounds6.maxX, y: bounds6.minY };
480750
- const bottomLeft = { x: bounds6.minX, y: bounds6.maxY };
480751
- const bottomRight = { x: bounds6.maxX, y: bounds6.maxY };
480752
- if (doSegmentsIntersect5(a, b, topLeft, topRight) || doSegmentsIntersect5(a, b, topRight, bottomRight) || doSegmentsIntersect5(a, b, bottomRight, bottomLeft) || doSegmentsIntersect5(a, b, bottomLeft, topLeft)) {
480753
- return 0;
480754
- }
480755
- if (a.x >= bounds6.minX && a.x <= bounds6.maxX && a.y >= bounds6.minY && a.y <= bounds6.maxY && b.x >= bounds6.minX && b.x <= bounds6.maxX && b.y >= bounds6.minY && b.y <= bounds6.maxY) {
480756
- return 0;
480757
- }
480758
- const distances = [
480759
- pointToSegmentDistance5(topLeft, a, b),
480760
- pointToSegmentDistance5(topRight, a, b),
480761
- pointToSegmentDistance5(bottomLeft, a, b),
480762
- pointToSegmentDistance5(bottomRight, a, b)
480763
- ];
480764
- if (a.x >= bounds6.minX && a.x <= bounds6.maxX && a.y >= bounds6.minY && a.y <= bounds6.maxY) {
480765
- return 0;
480766
- }
480767
- if (b.x >= bounds6.minX && b.x <= bounds6.maxX && b.y >= bounds6.minY && b.y <= bounds6.maxY) {
480768
- return 0;
480769
- }
480770
- if (a.x < bounds6.minX || a.x > bounds6.maxX || a.y < bounds6.minY || a.y > bounds6.maxY) {
480771
- const closestX = clamp5(a.x, bounds6.minX, bounds6.maxX);
480772
- const closestY = clamp5(a.y, bounds6.minY, bounds6.maxY);
480773
- distances.push(distance7(a, { x: closestX, y: closestY }));
480774
- }
480775
- if (b.x < bounds6.minX || b.x > bounds6.maxX || b.y < bounds6.minY || b.y > bounds6.maxY) {
480776
- const closestX = clamp5(b.x, bounds6.minX, bounds6.maxX);
480777
- const closestY = clamp5(b.y, bounds6.minY, bounds6.maxY);
480778
- distances.push(distance7(b, { x: closestX, y: closestY }));
480779
- }
480780
- return Math.min(...distances);
480781
- }
480782
- function segmentToCircleMinDistance(a, b, circle) {
480783
- const circleCenter = { x: circle.x, y: circle.y };
480784
- if (a.x === b.x && a.y === b.y) {
480785
- return Math.max(0, distance7(a, circleCenter) - circle.radius);
480786
- }
480787
- const ab = { x: b.x - a.x, y: b.y - a.y };
480788
- const ac = { x: circleCenter.x - a.x, y: circleCenter.y - a.y };
480789
- const abLengthSq = ab.x * ab.x + ab.y * ab.y;
480790
- const t2 = Math.max(0, Math.min(1, (ab.x * ac.x + ab.y * ac.y) / abLengthSq));
480791
- const closestPoint = {
480792
- x: a.x + t2 * ab.x,
480793
- y: a.y + t2 * ab.y
480794
- };
480795
- const distToCenter = distance7(closestPoint, circleCenter);
480796
- return Math.max(0, distToCenter - circle.radius);
480797
- }
480798
-
480799
- // node_modules/@tscircuit/checks/dist/index.js
480800
480670
  init_dist4();
480801
480671
  init_dist3();
480672
+ init_dist4();
480673
+ init_dist4();
480674
+ init_dist2();
480802
480675
  var SpatialObjectIndex = class {
480803
480676
  buckets;
480804
480677
  objectsById;
@@ -480950,7 +480823,7 @@ var getClosestPointBetweenSegments = (segmentA, segmentB) => {
480950
480823
  };
480951
480824
  }
480952
480825
  if (lenSqrA === 0) {
480953
- const t22 = clamp6(((a1.x - b1.x) * vb.x + (a1.y - b1.y) * vb.y) / lenSqrB, 0, 1);
480826
+ const t22 = clamp4(((a1.x - b1.x) * vb.x + (a1.y - b1.y) * vb.y) / lenSqrB, 0, 1);
480954
480827
  const closestOnB2 = {
480955
480828
  x: b1.x + t22 * vb.x,
480956
480829
  y: b1.y + t22 * vb.y
@@ -480960,7 +480833,7 @@ var getClosestPointBetweenSegments = (segmentA, segmentB) => {
480960
480833
  y: (a1.y + closestOnB2.y) / 2
480961
480834
  };
480962
480835
  }
480963
- const t2 = clamp6(((b1.x - a1.x) * va.x + (b1.y - a1.y) * va.y) / lenSqrA, 0, 1);
480836
+ const t2 = clamp4(((b1.x - a1.x) * va.x + (b1.y - a1.y) * va.y) / lenSqrA, 0, 1);
480964
480837
  const closestOnA2 = {
480965
480838
  x: a1.x + t2 * va.x,
480966
480839
  y: a1.y + t2 * va.y
@@ -480982,12 +480855,12 @@ var getClosestPointBetweenSegments = (segmentA, segmentB) => {
480982
480855
  }
480983
480856
  let tA = (dotAB * dotBW - dotBB * dotAW) / denominator;
480984
480857
  let tB = (dotAA * dotBW - dotAB * dotAW) / denominator;
480985
- tA = clamp6(tA, 0, 1);
480986
- tB = clamp6(tB, 0, 1);
480858
+ tA = clamp4(tA, 0, 1);
480859
+ tB = clamp4(tB, 0, 1);
480987
480860
  tB = (tA * dotAB + dotBW) / dotBB;
480988
- tB = clamp6(tB, 0, 1);
480861
+ tB = clamp4(tB, 0, 1);
480989
480862
  tA = (tB * dotAB - dotAW) / dotAA;
480990
- tA = clamp6(tA, 0, 1);
480863
+ tA = clamp4(tA, 0, 1);
480991
480864
  const closestOnA = {
480992
480865
  x: a1.x + tA * va.x,
480993
480866
  y: a1.y + tA * va.y
@@ -480998,7 +480871,7 @@ var getClosestPointBetweenSegments = (segmentA, segmentB) => {
480998
480871
  };
480999
480872
  const dx = closestOnA.x - closestOnB.x;
481000
480873
  const dy = closestOnA.y - closestOnB.y;
481001
- const distance23 = Math.sqrt(dx * dx + dy * dy);
480874
+ const distance32 = Math.sqrt(dx * dx + dy * dy);
481002
480875
  const averagePoint = {
481003
480876
  x: (closestOnA.x + closestOnB.x) / 2,
481004
480877
  y: (closestOnA.y + closestOnB.y) / 2
@@ -481007,16 +480880,16 @@ var getClosestPointBetweenSegments = (segmentA, segmentB) => {
481007
480880
  };
481008
480881
  var closestPointsParallelSegments = (a1, a2, b1, b2, va, vb, lenSqrA, lenSqrB) => {
481009
480882
  let tA = ((b1.x - a1.x) * va.x + (b1.y - a1.y) * va.y) / lenSqrA;
481010
- tA = clamp6(tA, 0, 1);
480883
+ tA = clamp4(tA, 0, 1);
481011
480884
  const pointOnA1 = { x: a1.x + tA * va.x, y: a1.y + tA * va.y };
481012
480885
  let tA2 = ((b2.x - a1.x) * va.x + (b2.y - a1.y) * va.y) / lenSqrA;
481013
- tA2 = clamp6(tA2, 0, 1);
480886
+ tA2 = clamp4(tA2, 0, 1);
481014
480887
  const pointOnA2 = { x: a1.x + tA2 * va.x, y: a1.y + tA2 * va.y };
481015
480888
  let tB = ((a1.x - b1.x) * vb.x + (a1.y - b1.y) * vb.y) / lenSqrB;
481016
- tB = clamp6(tB, 0, 1);
480889
+ tB = clamp4(tB, 0, 1);
481017
480890
  const pointOnB1 = { x: b1.x + tB * vb.x, y: b1.y + tB * vb.y };
481018
480891
  let tB2 = ((a2.x - b1.x) * vb.x + (a2.y - b1.y) * vb.y) / lenSqrB;
481019
- tB2 = clamp6(tB2, 0, 1);
480892
+ tB2 = clamp4(tB2, 0, 1);
481020
480893
  const pointOnB2 = { x: b1.x + tB2 * vb.x, y: b1.y + tB2 * vb.y };
481021
480894
  const distances = [
481022
480895
  {
@@ -481046,7 +480919,7 @@ var closestPointsParallelSegments = (a1, a2, b1, b2, va, vb, lenSqrA, lenSqrB) =
481046
480919
  y: (closestPair.pointA.y + closestPair.pointB.y) / 2
481047
480920
  };
481048
480921
  };
481049
- var clamp6 = (value2, min, max) => {
480922
+ var clamp4 = (value2, min, max) => {
481050
480923
  return Math.max(min, Math.min(max, value2));
481051
480924
  };
481052
480925
  var getRadiusOfCircuitJsonElement = (obj) => {
@@ -481177,7 +481050,7 @@ function checkEachPcbTraceNonOverlapping(circuitJson, {
481177
481050
  connMap
481178
481051
  } = {}) {
481179
481052
  const errors = [];
481180
- connMap ??= getFullConnectivityMapFromCircuitJson2(circuitJson);
481053
+ connMap ??= getFullConnectivityMapFromCircuitJson(circuitJson);
481181
481054
  const pcbTraces = cju_default(circuitJson).pcb_trace.list();
481182
481055
  const pcbTraceSegments = pcbTraces.flatMap((pcbTrace) => {
481183
481056
  const segments = [];
@@ -481239,7 +481112,7 @@ function checkEachPcbTraceNonOverlapping(circuitJson, {
481239
481112
  continue;
481240
481113
  if (connMap.areIdsConnected(segmentA.pcb_trace_id, segmentB.pcb_trace_id))
481241
481114
  continue;
481242
- const gap2 = segmentToSegmentMinDistance2({ x: segmentA.x1, y: segmentA.y1 }, { x: segmentA.x2, y: segmentA.y2 }, { x: segmentB.x1, y: segmentB.y1 }, { x: segmentB.x2, y: segmentB.y2 }) - segmentA.thickness / 2 - segmentB.thickness / 2;
481115
+ const gap2 = segmentToSegmentMinDistance({ x: segmentA.x1, y: segmentA.y1 }, { x: segmentA.x2, y: segmentA.y2 }, { x: segmentB.x1, y: segmentB.y1 }, { x: segmentB.x2, y: segmentB.y2 }) - segmentA.thickness / 2 - segmentB.thickness / 2;
481243
481116
  if (gap2 > DEFAULT_TRACE_MARGIN - EPSILON4)
481244
481117
  continue;
481245
481118
  const pcb_trace_error_id = `overlap_${segmentA.pcb_trace_id}_${segmentB.pcb_trace_id}`;
@@ -481271,8 +481144,8 @@ function checkEachPcbTraceNonOverlapping(circuitJson, {
481271
481144
  const isCircular = obj.type === "pcb_via" || obj.type === "pcb_plated_hole" && obj.shape === "circle" || obj.type === "pcb_hole" || obj.type === "pcb_smtpad" && obj.shape === "circle";
481272
481145
  if (isCircular) {
481273
481146
  const radius = getRadiusOfCircuitJsonElement(obj);
481274
- const distance23 = segmentToCircleMinDistance({ x: segmentA.x1, y: segmentA.y1 }, { x: segmentA.x2, y: segmentA.y2 }, { x: obj.x, y: obj.y, radius });
481275
- const gap2 = distance23 - segmentA.thickness / 2;
481147
+ const distance32 = segmentToCircleMinDistance({ x: segmentA.x1, y: segmentA.y1 }, { x: segmentA.x2, y: segmentA.y2 }, { x: obj.x, y: obj.y, radius });
481148
+ const gap2 = distance32 - segmentA.thickness / 2;
481276
481149
  if (gap2 > DEFAULT_TRACE_MARGIN - EPSILON4)
481277
481150
  continue;
481278
481151
  const pcb_trace_error_id = `overlap_${segmentA.pcb_trace_id}_${primaryObjId}`;
@@ -481296,7 +481169,7 @@ function checkEachPcbTraceNonOverlapping(circuitJson, {
481296
481169
  ].filter(Boolean)
481297
481170
  });
481298
481171
  }
481299
- const gap = segmentToBoundsMinDistance2({ x: segmentA.x1, y: segmentA.y1 }, { x: segmentA.x2, y: segmentA.y2 }, getCollidableBounds(obj)) - segmentA.thickness / 2;
481172
+ const gap = segmentToBoundsMinDistance({ x: segmentA.x1, y: segmentA.y1 }, { x: segmentA.x2, y: segmentA.y2 }, getCollidableBounds(obj)) - segmentA.thickness / 2;
481300
481173
  if (gap + EPSILON4 < requiredMargin) {
481301
481174
  const pcb_trace_error_id = `overlap_${segmentA.pcb_trace_id}_${primaryObjId}`;
481302
481175
  if (errorIds.has(pcb_trace_error_id))
@@ -482231,8 +482104,8 @@ var PinBuilder = class {
482231
482104
  };
482232
482105
  pathfinder.addObstacle(obstacle);
482233
482106
  }
482234
- const distance8 = Math.abs(targetX - this.x) + Math.abs(targetY - this.y);
482235
- if (distance8 < 10) {
482107
+ const distance6 = Math.abs(targetX - this.x) + Math.abs(targetY - this.y);
482108
+ if (distance6 < 10) {
482236
482109
  const path21 = pathfinder.findPath(currentPos, targetPos);
482237
482110
  if (path21.length > 0) {
482238
482111
  for (let i = 1;i < path21.length; i++) {
@@ -484304,9 +484177,9 @@ function findBestPinToRemove(params2) {
484304
484177
  pinNumber: pin.pinNumber
484305
484178
  };
484306
484179
  applyEditOperation(testTemplate, testOp);
484307
- const distance8 = computeSimilarityDistanceAfterRemoval(testTemplate, target);
484308
- if (distance8 < bestDistance) {
484309
- bestDistance = distance8;
484180
+ const distance6 = computeSimilarityDistanceAfterRemoval(testTemplate, target);
484181
+ if (distance6 < bestDistance) {
484182
+ bestDistance = distance6;
484310
484183
  bestPinNumber = pin.pinNumber;
484311
484184
  }
484312
484185
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.125",
3
+ "version": "0.1.126",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",
@@ -8,6 +8,7 @@
8
8
  "@tscircuit/fake-snippets": "^0.0.75",
9
9
  "@tscircuit/file-server": "^0.0.24",
10
10
  "@tscircuit/runframe": "^0.0.566",
11
+ "@tscircuit/math-utils": "^0.0.18",
11
12
  "@types/bun": "^1.2.2",
12
13
  "@types/configstore": "^6.0.2",
13
14
  "@types/debug": "^4.1.12",
@@ -39,7 +40,7 @@
39
40
  "redaxios": "^0.5.1",
40
41
  "semver": "^7.6.3",
41
42
  "tempy": "^3.1.0",
42
- "tscircuit": "^0.0.485",
43
+ "tscircuit": "^0.0.491",
43
44
  "@tscircuit/circuit-json-util": "^0.0.47",
44
45
  "typed-ky": "^0.0.4"
45
46
  },