easyeda 0.0.356 → 0.0.358

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/main.cjs CHANGED
@@ -1078,7 +1078,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
1078
1078
  var package_default = {
1079
1079
  name: "easyeda",
1080
1080
  type: "module",
1081
- version: "0.0.355",
1081
+ version: "0.0.357",
1082
1082
  files: [
1083
1083
  "dist"
1084
1084
  ],
@@ -1135,6 +1135,121 @@ var package_default = {
1135
1135
  types: "./dist/index.d.ts"
1136
1136
  };
1137
1137
 
1138
+ // node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
1139
+ function orientation(p, q, r) {
1140
+ const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
1141
+ if (val === 0) return 0;
1142
+ return val > 0 ? 1 : 2;
1143
+ }
1144
+ function distance(p1, p2) {
1145
+ const dx = p1.x - p2.x;
1146
+ const dy = p1.y - p2.y;
1147
+ return Math.sqrt(dx * dx + dy * dy);
1148
+ }
1149
+
1150
+ // node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
1151
+ var getUnitVectorFromDirection = (direction) => {
1152
+ switch (direction) {
1153
+ case "up":
1154
+ return { x: 0, y: 1 };
1155
+ case "down":
1156
+ return { x: 0, y: -1 };
1157
+ case "left":
1158
+ return { x: -1, y: 0 };
1159
+ case "right":
1160
+ return { x: 1, y: 0 };
1161
+ }
1162
+ };
1163
+
1164
+ // node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
1165
+ var getBoundsCenter = (bounds) => ({
1166
+ x: (bounds.minX + bounds.maxX) / 2,
1167
+ y: (bounds.minY + bounds.maxY) / 2
1168
+ });
1169
+
1170
+ // node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
1171
+ var getBoundsFromPoints = (points) => {
1172
+ if (points.length === 0) {
1173
+ return null;
1174
+ }
1175
+ let minX = points[0].x;
1176
+ let minY = points[0].y;
1177
+ let maxX = points[0].x;
1178
+ let maxY = points[0].y;
1179
+ for (let i = 1; i < points.length; i++) {
1180
+ const point2 = points[i];
1181
+ if (point2.x < minX) minX = point2.x;
1182
+ if (point2.y < minY) minY = point2.y;
1183
+ if (point2.x > maxX) maxX = point2.x;
1184
+ if (point2.y > maxY) maxY = point2.y;
1185
+ }
1186
+ return { minX, minY, maxX, maxY };
1187
+ };
1188
+
1189
+ // lib/utils/get-board-outline-polygons.ts
1190
+ var same = (a, b) => distance(a, b) < 1e-4;
1191
+ var getBoardOutlinePolygons = (tracks) => {
1192
+ const remainingEdges = tracks.flatMap(
1193
+ (track) => track.points.slice(1).map((point2, i) => [track.points[i], point2])
1194
+ ).filter(([a, b]) => !same(a, b));
1195
+ const polygons = [];
1196
+ while (remainingEdges.length) {
1197
+ const edges = [remainingEdges.shift()];
1198
+ while (true) {
1199
+ const index = remainingEdges.findIndex(
1200
+ (edge) => edge.some((p) => edges.flat().some((q) => same(p, q)))
1201
+ );
1202
+ if (index === -1) break;
1203
+ edges.push(remainingEdges.splice(index, 1)[0]);
1204
+ }
1205
+ const endpoints = edges.flat();
1206
+ if (endpoints.some((p) => endpoints.filter((q) => same(p, q)).length > 2))
1207
+ continue;
1208
+ const route = edges.shift();
1209
+ let changed = true;
1210
+ while (changed) {
1211
+ changed = false;
1212
+ for (let i = 0; i < edges.length; i++) {
1213
+ const [a, b] = edges[i];
1214
+ if (same(route.at(-1), a)) route.push(b);
1215
+ else if (same(route.at(-1), b)) route.push(a);
1216
+ else if (same(route[0], b)) route.unshift(a);
1217
+ else if (same(route[0], a)) route.unshift(b);
1218
+ else continue;
1219
+ edges.splice(i, 1);
1220
+ changed = true;
1221
+ break;
1222
+ }
1223
+ }
1224
+ if (same(route[0], route.at(-1))) route.pop();
1225
+ else {
1226
+ const first = route[0];
1227
+ const last = route.at(-1);
1228
+ if (Math.abs(first.x - last.x) > 1e-4 && Math.abs(first.y - last.y) > 1e-4)
1229
+ continue;
1230
+ }
1231
+ if (route.some((p, i) => route.slice(i + 1).some((q) => same(p, q))))
1232
+ continue;
1233
+ while (route.length > 2) {
1234
+ const index = route.findIndex(
1235
+ (p, i) => orientation(
1236
+ route[(i + route.length - 1) % route.length],
1237
+ p,
1238
+ route[(i + 1) % route.length]
1239
+ ) === 0
1240
+ );
1241
+ if (index === -1) break;
1242
+ route.splice(index, 1);
1243
+ }
1244
+ const area = route.reduce((sum, p, i) => {
1245
+ const q = route[(i + 1) % route.length];
1246
+ return sum + p.x * q.y - q.x * p.y;
1247
+ }, 0);
1248
+ if (route.length >= 3 && Math.abs(area) > 1e-8) polygons.push(route);
1249
+ }
1250
+ return polygons;
1251
+ };
1252
+
1138
1253
  // node_modules/circuit-json/dist/index.mjs
1139
1254
  var dist_exports = {};
1140
1255
  __export(dist_exports, {
@@ -1153,7 +1268,7 @@ __export(dist_exports, {
1153
1268
  capacitance: () => capacitance,
1154
1269
  circuit_json_footprint_load_error: () => circuit_json_footprint_load_error,
1155
1270
  current: () => current,
1156
- distance: () => distance,
1271
+ distance: () => distance2,
1157
1272
  duration_ms: () => duration_ms,
1158
1273
  experiment_type: () => experiment_type,
1159
1274
  external_footprint_load_error: () => external_footprint_load_error,
@@ -1900,7 +2015,7 @@ var inductance = import_zod2.z.string().or(import_zod2.z.number()).transform((v)
1900
2015
  var voltage = import_zod2.z.string().or(import_zod2.z.number()).transform((v) => parseAndConvertSiUnit(v, "V").value);
1901
2016
  var length = import_zod2.z.string().or(import_zod2.z.number()).transform((v) => parseAndConvertSiUnit(v).value);
1902
2017
  var frequency = import_zod2.z.string().or(import_zod2.z.number()).transform((v) => parseAndConvertSiUnit(v, "Hz").value);
1903
- var distance = length;
2018
+ var distance2 = length;
1904
2019
  var current = import_zod2.z.string().or(import_zod2.z.number()).transform((v) => parseAndConvertSiUnit(v, "A").value);
1905
2020
  var duration_ms = import_zod2.z.string().or(import_zod2.z.number()).transform((v) => parseAndConvertSiUnit(v).value);
1906
2021
  var time = duration_ms;
@@ -1946,16 +2061,16 @@ expectStringUnionsMatch(
1946
2061
  );
1947
2062
  expectStringUnionsMatch(true);
1948
2063
  var point = import_zod3.z.object({
1949
- x: distance,
1950
- y: distance
2064
+ x: distance2,
2065
+ y: distance2
1951
2066
  });
1952
2067
  var position = point;
1953
2068
  expectTypesMatch(true);
1954
2069
  expectTypesMatch(true);
1955
2070
  var point3 = import_zod4.z.object({
1956
- x: distance,
1957
- y: distance,
1958
- z: distance
2071
+ x: distance2,
2072
+ y: distance2,
2073
+ z: distance2
1959
2074
  });
1960
2075
  var position3 = point3;
1961
2076
  expectTypesMatch(true);
@@ -2023,7 +2138,7 @@ var kicadAt = point.extend({
2023
2138
  expectTypesMatch(true);
2024
2139
  var kicadFont = import_zod10.z.object({
2025
2140
  size: point.optional(),
2026
- thickness: distance.optional()
2141
+ thickness: distance2.optional()
2027
2142
  });
2028
2143
  expectTypesMatch(true);
2029
2144
  var kicadEffects = import_zod10.z.object({
@@ -2063,7 +2178,7 @@ var kicadFootprintPad = import_zod10.z.object({
2063
2178
  shape: import_zod10.z.string().optional(),
2064
2179
  at: kicadAt.optional(),
2065
2180
  size: point.optional(),
2066
- drill: distance.optional(),
2181
+ drill: distance2.optional(),
2067
2182
  layers: import_zod10.z.array(import_zod10.z.string()).optional(),
2068
2183
  removeUnusedLayers: import_zod10.z.boolean().optional(),
2069
2184
  uuid: import_zod10.z.string().optional()
@@ -2094,7 +2209,7 @@ var kicadSymbolPinNumbers = import_zod11.z.object({
2094
2209
  });
2095
2210
  expectTypesMatch(true);
2096
2211
  var kicadSymbolPinNames = import_zod11.z.object({
2097
- offset: distance.optional(),
2212
+ offset: distance2.optional(),
2098
2213
  hide: import_zod11.z.boolean().optional()
2099
2214
  });
2100
2215
  expectTypesMatch(true);
@@ -2168,7 +2283,7 @@ var source_simple_capacitor = source_component_base.extend({
2168
2283
  capacitance,
2169
2284
  max_voltage_rating: voltage.optional(),
2170
2285
  display_capacitance: import_zod13.z.string().optional(),
2171
- max_decoupling_trace_length: distance.optional()
2286
+ max_decoupling_trace_length: distance2.optional()
2172
2287
  });
2173
2288
  expectTypesMatch(true);
2174
2289
  var source_simple_resistor = source_component_base.extend({
@@ -2798,11 +2913,11 @@ var schematic_box = import_zod73.z.object({
2798
2913
  schematic_sheet_id: import_zod73.z.string().optional(),
2799
2914
  schematic_component_id: import_zod73.z.string().optional(),
2800
2915
  schematic_symbol_id: import_zod73.z.string().optional(),
2801
- width: distance,
2802
- height: distance,
2916
+ width: distance2,
2917
+ height: distance2,
2803
2918
  is_dashed: import_zod73.z.boolean().default(false),
2804
- x: distance,
2805
- y: distance,
2919
+ x: distance2,
2920
+ y: distance2,
2806
2921
  subcircuit_id: import_zod73.z.string().optional()
2807
2922
  }).describe("Draws a box on the schematic");
2808
2923
  expectTypesMatch(true);
@@ -2815,10 +2930,10 @@ var schematic_path = import_zod74.z.object({
2815
2930
  fill_color: import_zod74.z.string().optional(),
2816
2931
  is_filled: import_zod74.z.boolean().optional(),
2817
2932
  is_dashed: import_zod74.z.boolean().default(false),
2818
- stroke_width: distance.nullable().optional(),
2933
+ stroke_width: distance2.nullable().optional(),
2819
2934
  stroke_color: import_zod74.z.string().optional(),
2820
- dash_length: distance.optional(),
2821
- dash_gap: distance.optional(),
2935
+ dash_length: distance2.optional(),
2936
+ dash_gap: distance2.optional(),
2822
2937
  points: import_zod74.z.array(point),
2823
2938
  subcircuit_id: import_zod74.z.string().optional()
2824
2939
  });
@@ -2905,15 +3020,15 @@ var schematic_line = import_zod77.z.object({
2905
3020
  schematic_sheet_id: import_zod77.z.string().optional(),
2906
3021
  schematic_component_id: import_zod77.z.string().optional(),
2907
3022
  schematic_symbol_id: import_zod77.z.string().optional(),
2908
- x1: distance,
2909
- y1: distance,
2910
- x2: distance,
2911
- y2: distance,
2912
- stroke_width: distance.nullable().optional(),
3023
+ x1: distance2,
3024
+ y1: distance2,
3025
+ x2: distance2,
3026
+ y2: distance2,
3027
+ stroke_width: distance2.nullable().optional(),
2913
3028
  color: import_zod77.z.string().default("#000000"),
2914
3029
  is_dashed: import_zod77.z.boolean().default(false),
2915
- dash_length: distance.optional(),
2916
- dash_gap: distance.optional(),
3030
+ dash_length: distance2.optional(),
3031
+ dash_gap: distance2.optional(),
2917
3032
  subcircuit_id: import_zod77.z.string().optional()
2918
3033
  }).describe("Draws a styled line on the schematic");
2919
3034
  expectTypesMatch(true);
@@ -2924,10 +3039,10 @@ var schematic_rect = import_zod78.z.object({
2924
3039
  schematic_component_id: import_zod78.z.string().optional(),
2925
3040
  schematic_symbol_id: import_zod78.z.string().optional(),
2926
3041
  center: point,
2927
- width: distance,
2928
- height: distance,
3042
+ width: distance2,
3043
+ height: distance2,
2929
3044
  rotation: rotation.default(0),
2930
- stroke_width: distance.nullable().optional(),
3045
+ stroke_width: distance2.nullable().optional(),
2931
3046
  color: import_zod78.z.string().default("#000000"),
2932
3047
  is_filled: import_zod78.z.boolean().default(false),
2933
3048
  fill_color: import_zod78.z.string().optional(),
@@ -2942,8 +3057,8 @@ var schematic_circle = import_zod79.z.object({
2942
3057
  schematic_component_id: import_zod79.z.string().optional(),
2943
3058
  schematic_symbol_id: import_zod79.z.string().optional(),
2944
3059
  center: point,
2945
- radius: distance,
2946
- stroke_width: distance.nullable().optional(),
3060
+ radius: distance2,
3061
+ stroke_width: distance2.nullable().optional(),
2947
3062
  color: import_zod79.z.string().default("#000000"),
2948
3063
  is_filled: import_zod79.z.boolean().default(false),
2949
3064
  fill_color: import_zod79.z.string().optional(),
@@ -2958,11 +3073,11 @@ var schematic_arc = import_zod80.z.object({
2958
3073
  schematic_component_id: import_zod80.z.string().optional(),
2959
3074
  schematic_symbol_id: import_zod80.z.string().optional(),
2960
3075
  center: point,
2961
- radius: distance,
3076
+ radius: distance2,
2962
3077
  start_angle_degrees: rotation,
2963
3078
  end_angle_degrees: rotation,
2964
3079
  direction: import_zod80.z.enum(["clockwise", "counterclockwise"]).default("counterclockwise"),
2965
- stroke_width: distance.nullable().optional(),
3080
+ stroke_width: distance2.nullable().optional(),
2966
3081
  color: import_zod80.z.string().default("#000000"),
2967
3082
  is_dashed: import_zod80.z.boolean().default(false),
2968
3083
  subcircuit_id: import_zod80.z.string().optional()
@@ -3017,8 +3132,8 @@ var schematic_text = import_zod82.z.object({
3017
3132
  text: import_zod82.z.string(),
3018
3133
  font_size: import_zod82.z.number().default(0.18),
3019
3134
  position: import_zod82.z.object({
3020
- x: distance,
3021
- y: distance
3135
+ x: distance2,
3136
+ y: distance2
3022
3137
  }),
3023
3138
  rotation: import_zod82.z.number().default(0),
3024
3139
  anchor: import_zod82.z.union([fivePointAnchor.describe("legacy"), ninePointAnchor]).default("center"),
@@ -3207,10 +3322,10 @@ var schematic_table = import_zod95.z.object({
3207
3322
  schematic_table_id: getZodPrefixedIdWithDefault("schematic_table"),
3208
3323
  schematic_sheet_id: import_zod95.z.string().optional(),
3209
3324
  anchor_position: point,
3210
- column_widths: import_zod95.z.array(distance),
3211
- row_heights: import_zod95.z.array(distance),
3212
- cell_padding: distance.optional(),
3213
- border_width: distance.optional(),
3325
+ column_widths: import_zod95.z.array(distance2),
3326
+ row_heights: import_zod95.z.array(distance2),
3327
+ cell_padding: distance2.optional(),
3328
+ border_width: distance2.optional(),
3214
3329
  subcircuit_id: import_zod95.z.string().optional(),
3215
3330
  schematic_component_id: import_zod95.z.string().optional(),
3216
3331
  anchor: ninePointAnchor.optional()
@@ -3229,11 +3344,11 @@ var schematic_table_cell = import_zod96.z.object({
3229
3344
  end_column_index: import_zod96.z.number(),
3230
3345
  text: import_zod96.z.string().optional(),
3231
3346
  center: point,
3232
- width: distance,
3233
- height: distance,
3347
+ width: distance2,
3348
+ height: distance2,
3234
3349
  horizontal_align: import_zod96.z.enum(["left", "center", "right"]).optional(),
3235
3350
  vertical_align: import_zod96.z.enum(["top", "middle", "bottom"]).optional(),
3236
- font_size: distance.optional(),
3351
+ font_size: distance2.optional(),
3237
3352
  subcircuit_id: import_zod96.z.string().optional()
3238
3353
  }).describe("Defines a cell within a schematic_table");
3239
3354
  expectTypesMatch(true);
@@ -3249,8 +3364,8 @@ var schematic_sheet = import_zod97.z.object({
3249
3364
  );
3250
3365
  expectTypesMatch(true);
3251
3366
  var point_with_bulge = import_zod98.z.object({
3252
- x: distance,
3253
- y: distance,
3367
+ x: distance2,
3368
+ y: distance2,
3254
3369
  bulge: import_zod98.z.number().optional()
3255
3370
  });
3256
3371
  expectTypesMatch(true);
@@ -3348,8 +3463,8 @@ var getRotationBetweenPcbPin1Locations = (from, to) => {
3348
3463
  return null;
3349
3464
  };
3350
3465
  var pcb_route_hint = import_zod101.z.object({
3351
- x: distance,
3352
- y: distance,
3466
+ x: distance2,
3467
+ y: distance2,
3353
3468
  via: import_zod101.z.boolean().optional(),
3354
3469
  via_to_layer: layer_ref.optional()
3355
3470
  });
@@ -3357,11 +3472,11 @@ var pcb_route_hints = import_zod101.z.array(pcb_route_hint);
3357
3472
  expectTypesMatch(true);
3358
3473
  expectTypesMatch(true);
3359
3474
  var route_hint_point = import_zod102.z.object({
3360
- x: distance,
3361
- y: distance,
3475
+ x: distance2,
3476
+ y: distance2,
3362
3477
  via: import_zod102.z.boolean().optional(),
3363
3478
  to_layer: layer_ref.optional(),
3364
- trace_width: distance.optional()
3479
+ trace_width: distance2.optional()
3365
3480
  });
3366
3481
  expectTypesMatch(true);
3367
3482
  var manufacturing_drc_properties = import_zod103.z.object({
@@ -3456,8 +3571,8 @@ var pcb_hole_circle = import_zod106.z.object({
3456
3571
  pcb_component_id: import_zod106.z.string().optional(),
3457
3572
  hole_shape: import_zod106.z.literal("circle"),
3458
3573
  hole_diameter: import_zod106.z.number(),
3459
- x: distance,
3460
- y: distance,
3574
+ x: distance2,
3575
+ y: distance2,
3461
3576
  is_covered_with_solder_mask: import_zod106.z.boolean().optional(),
3462
3577
  soldermask_margin: import_zod106.z.number().optional()
3463
3578
  });
@@ -3474,8 +3589,8 @@ var pcb_hole_rect = import_zod106.z.object({
3474
3589
  hole_shape: import_zod106.z.literal("rect"),
3475
3590
  hole_width: import_zod106.z.number(),
3476
3591
  hole_height: import_zod106.z.number(),
3477
- x: distance,
3478
- y: distance,
3592
+ x: distance2,
3593
+ y: distance2,
3479
3594
  is_covered_with_solder_mask: import_zod106.z.boolean().optional(),
3480
3595
  soldermask_margin: import_zod106.z.number().optional()
3481
3596
  });
@@ -3491,8 +3606,8 @@ var pcb_hole_circle_or_square = import_zod106.z.object({
3491
3606
  pcb_component_id: import_zod106.z.string().optional(),
3492
3607
  hole_shape: import_zod106.z.enum(["circle", "square"]),
3493
3608
  hole_diameter: import_zod106.z.number(),
3494
- x: distance,
3495
- y: distance,
3609
+ x: distance2,
3610
+ y: distance2,
3496
3611
  is_covered_with_solder_mask: import_zod106.z.boolean().optional(),
3497
3612
  soldermask_margin: import_zod106.z.number().optional()
3498
3613
  });
@@ -3509,8 +3624,8 @@ var pcb_hole_oval = import_zod106.z.object({
3509
3624
  hole_shape: import_zod106.z.literal("oval"),
3510
3625
  hole_width: import_zod106.z.number(),
3511
3626
  hole_height: import_zod106.z.number(),
3512
- x: distance,
3513
- y: distance,
3627
+ x: distance2,
3628
+ y: distance2,
3514
3629
  is_covered_with_solder_mask: import_zod106.z.boolean().optional(),
3515
3630
  soldermask_margin: import_zod106.z.number().optional()
3516
3631
  });
@@ -3527,8 +3642,8 @@ var pcb_hole_pill = import_zod106.z.object({
3527
3642
  hole_shape: import_zod106.z.literal("pill"),
3528
3643
  hole_width: import_zod106.z.number(),
3529
3644
  hole_height: import_zod106.z.number(),
3530
- x: distance,
3531
- y: distance,
3645
+ x: distance2,
3646
+ y: distance2,
3532
3647
  is_covered_with_solder_mask: import_zod106.z.boolean().optional(),
3533
3648
  soldermask_margin: import_zod106.z.number().optional()
3534
3649
  });
@@ -3545,8 +3660,8 @@ var pcb_hole_rotated_pill = import_zod106.z.object({
3545
3660
  hole_shape: import_zod106.z.literal("rotated_pill"),
3546
3661
  hole_width: import_zod106.z.number(),
3547
3662
  hole_height: import_zod106.z.number(),
3548
- x: distance,
3549
- y: distance,
3663
+ x: distance2,
3664
+ y: distance2,
3550
3665
  ccw_rotation: rotation,
3551
3666
  is_covered_with_solder_mask: import_zod106.z.boolean().optional(),
3552
3667
  soldermask_margin: import_zod106.z.number().optional()
@@ -3564,8 +3679,8 @@ var pcb_plated_hole_circle = import_zod107.z.object({
3564
3679
  outer_diameter: import_zod107.z.number(),
3565
3680
  hole_diameter: import_zod107.z.number(),
3566
3681
  is_covered_with_solder_mask: import_zod107.z.boolean().optional(),
3567
- x: distance,
3568
- y: distance,
3682
+ x: distance2,
3683
+ y: distance2,
3569
3684
  layers: import_zod107.z.array(layer_ref),
3570
3685
  port_hints: import_zod107.z.array(import_zod107.z.string()).optional(),
3571
3686
  pcb_component_id: import_zod107.z.string().optional(),
@@ -3583,8 +3698,8 @@ var pcb_plated_hole_oval = import_zod107.z.object({
3583
3698
  hole_width: import_zod107.z.number(),
3584
3699
  hole_height: import_zod107.z.number(),
3585
3700
  is_covered_with_solder_mask: import_zod107.z.boolean().optional(),
3586
- x: distance,
3587
- y: distance,
3701
+ x: distance2,
3702
+ y: distance2,
3588
3703
  ccw_rotation: rotation,
3589
3704
  layers: import_zod107.z.array(layer_ref),
3590
3705
  port_hints: import_zod107.z.array(import_zod107.z.string()).optional(),
@@ -3604,11 +3719,11 @@ var pcb_circular_hole_with_rect_pad = import_zod107.z.object({
3604
3719
  rect_pad_width: import_zod107.z.number(),
3605
3720
  rect_pad_height: import_zod107.z.number(),
3606
3721
  rect_border_radius: import_zod107.z.number().optional(),
3607
- hole_offset_x: distance.default(0),
3608
- hole_offset_y: distance.default(0),
3722
+ hole_offset_x: distance2.default(0),
3723
+ hole_offset_y: distance2.default(0),
3609
3724
  is_covered_with_solder_mask: import_zod107.z.boolean().optional(),
3610
- x: distance,
3611
- y: distance,
3725
+ x: distance2,
3726
+ y: distance2,
3612
3727
  layers: import_zod107.z.array(layer_ref),
3613
3728
  port_hints: import_zod107.z.array(import_zod107.z.string()).optional(),
3614
3729
  pcb_component_id: import_zod107.z.string().optional(),
@@ -3629,11 +3744,11 @@ var pcb_pill_hole_with_rect_pad = import_zod107.z.object({
3629
3744
  rect_pad_width: import_zod107.z.number(),
3630
3745
  rect_pad_height: import_zod107.z.number(),
3631
3746
  rect_border_radius: import_zod107.z.number().optional(),
3632
- hole_offset_x: distance.default(0),
3633
- hole_offset_y: distance.default(0),
3747
+ hole_offset_x: distance2.default(0),
3748
+ hole_offset_y: distance2.default(0),
3634
3749
  is_covered_with_solder_mask: import_zod107.z.boolean().optional(),
3635
- x: distance,
3636
- y: distance,
3750
+ x: distance2,
3751
+ y: distance2,
3637
3752
  layers: import_zod107.z.array(layer_ref),
3638
3753
  port_hints: import_zod107.z.array(import_zod107.z.string()).optional(),
3639
3754
  pcb_component_id: import_zod107.z.string().optional(),
@@ -3655,11 +3770,11 @@ var pcb_rotated_pill_hole_with_rect_pad = import_zod107.z.object({
3655
3770
  rect_pad_height: import_zod107.z.number(),
3656
3771
  rect_border_radius: import_zod107.z.number().optional(),
3657
3772
  rect_ccw_rotation: rotation,
3658
- hole_offset_x: distance.default(0),
3659
- hole_offset_y: distance.default(0),
3773
+ hole_offset_x: distance2.default(0),
3774
+ hole_offset_y: distance2.default(0),
3660
3775
  is_covered_with_solder_mask: import_zod107.z.boolean().optional(),
3661
- x: distance,
3662
- y: distance,
3776
+ x: distance2,
3777
+ y: distance2,
3663
3778
  layers: import_zod107.z.array(layer_ref),
3664
3779
  port_hints: import_zod107.z.array(import_zod107.z.string()).optional(),
3665
3780
  pcb_component_id: import_zod107.z.string().optional(),
@@ -3678,15 +3793,15 @@ var pcb_hole_with_polygon_pad = import_zod107.z.object({
3678
3793
  hole_height: import_zod107.z.number().optional(),
3679
3794
  pad_outline: import_zod107.z.array(
3680
3795
  import_zod107.z.object({
3681
- x: distance,
3682
- y: distance
3796
+ x: distance2,
3797
+ y: distance2
3683
3798
  })
3684
3799
  ).min(3),
3685
- hole_offset_x: distance.default(0),
3686
- hole_offset_y: distance.default(0),
3800
+ hole_offset_x: distance2.default(0),
3801
+ hole_offset_y: distance2.default(0),
3687
3802
  is_covered_with_solder_mask: import_zod107.z.boolean().optional(),
3688
- x: distance,
3689
- y: distance,
3803
+ x: distance2,
3804
+ y: distance2,
3690
3805
  layers: import_zod107.z.array(layer_ref),
3691
3806
  port_hints: import_zod107.z.array(import_zod107.z.string()).optional(),
3692
3807
  pcb_component_id: import_zod107.z.string().optional(),
@@ -3718,8 +3833,8 @@ var pcb_port = import_zod108.z.object({
3718
3833
  subcircuit_id: import_zod108.z.string().optional(),
3719
3834
  source_port_id: import_zod108.z.string(),
3720
3835
  pcb_component_id: import_zod108.z.string().optional(),
3721
- x: distance,
3722
- y: distance,
3836
+ x: distance2,
3837
+ y: distance2,
3723
3838
  layers: import_zod108.z.array(layer_ref),
3724
3839
  is_board_pinout: import_zod108.z.boolean().optional()
3725
3840
  }).describe("Defines a port on the PCB");
@@ -3730,8 +3845,8 @@ var pcb_smtpad_circle = import_zod109.z.object({
3730
3845
  pcb_smtpad_id: getZodPrefixedIdWithDefault("pcb_smtpad"),
3731
3846
  pcb_group_id: import_zod109.z.string().optional(),
3732
3847
  subcircuit_id: import_zod109.z.string().optional(),
3733
- x: distance,
3734
- y: distance,
3848
+ x: distance2,
3849
+ y: distance2,
3735
3850
  radius: import_zod109.z.number(),
3736
3851
  layer: layer_ref,
3737
3852
  port_hints: import_zod109.z.array(import_zod109.z.string()).optional(),
@@ -3747,8 +3862,8 @@ var pcb_smtpad_rect = import_zod109.z.object({
3747
3862
  pcb_smtpad_id: getZodPrefixedIdWithDefault("pcb_smtpad"),
3748
3863
  pcb_group_id: import_zod109.z.string().optional(),
3749
3864
  subcircuit_id: import_zod109.z.string().optional(),
3750
- x: distance,
3751
- y: distance,
3865
+ x: distance2,
3866
+ y: distance2,
3752
3867
  width: import_zod109.z.number(),
3753
3868
  height: import_zod109.z.number(),
3754
3869
  rect_border_radius: import_zod109.z.number().optional(),
@@ -3771,8 +3886,8 @@ var pcb_smtpad_rotated_rect = import_zod109.z.object({
3771
3886
  pcb_smtpad_id: getZodPrefixedIdWithDefault("pcb_smtpad"),
3772
3887
  pcb_group_id: import_zod109.z.string().optional(),
3773
3888
  subcircuit_id: import_zod109.z.string().optional(),
3774
- x: distance,
3775
- y: distance,
3889
+ x: distance2,
3890
+ y: distance2,
3776
3891
  width: import_zod109.z.number(),
3777
3892
  height: import_zod109.z.number(),
3778
3893
  rect_border_radius: import_zod109.z.number().optional(),
@@ -3796,8 +3911,8 @@ var pcb_smtpad_pill = import_zod109.z.object({
3796
3911
  pcb_smtpad_id: getZodPrefixedIdWithDefault("pcb_smtpad"),
3797
3912
  pcb_group_id: import_zod109.z.string().optional(),
3798
3913
  subcircuit_id: import_zod109.z.string().optional(),
3799
- x: distance,
3800
- y: distance,
3914
+ x: distance2,
3915
+ y: distance2,
3801
3916
  width: import_zod109.z.number(),
3802
3917
  height: import_zod109.z.number(),
3803
3918
  radius: import_zod109.z.number(),
@@ -3815,8 +3930,8 @@ var pcb_smtpad_rotated_pill = import_zod109.z.object({
3815
3930
  pcb_smtpad_id: getZodPrefixedIdWithDefault("pcb_smtpad"),
3816
3931
  pcb_group_id: import_zod109.z.string().optional(),
3817
3932
  subcircuit_id: import_zod109.z.string().optional(),
3818
- x: distance,
3819
- y: distance,
3933
+ x: distance2,
3934
+ y: distance2,
3820
3935
  width: import_zod109.z.number(),
3821
3936
  height: import_zod109.z.number(),
3822
3937
  radius: import_zod109.z.number(),
@@ -3864,8 +3979,8 @@ var pcb_solder_paste_circle = import_zod110.z.object({
3864
3979
  pcb_solder_paste_id: getZodPrefixedIdWithDefault("pcb_solder_paste"),
3865
3980
  pcb_group_id: import_zod110.z.string().optional(),
3866
3981
  subcircuit_id: import_zod110.z.string().optional(),
3867
- x: distance,
3868
- y: distance,
3982
+ x: distance2,
3983
+ y: distance2,
3869
3984
  radius: import_zod110.z.number(),
3870
3985
  layer: layer_ref,
3871
3986
  pcb_component_id: import_zod110.z.string().optional(),
@@ -3877,8 +3992,8 @@ var pcb_solder_paste_rect = import_zod110.z.object({
3877
3992
  pcb_solder_paste_id: getZodPrefixedIdWithDefault("pcb_solder_paste"),
3878
3993
  pcb_group_id: import_zod110.z.string().optional(),
3879
3994
  subcircuit_id: import_zod110.z.string().optional(),
3880
- x: distance,
3881
- y: distance,
3995
+ x: distance2,
3996
+ y: distance2,
3882
3997
  width: import_zod110.z.number(),
3883
3998
  height: import_zod110.z.number(),
3884
3999
  layer: layer_ref,
@@ -3891,8 +4006,8 @@ var pcb_solder_paste_pill = import_zod110.z.object({
3891
4006
  pcb_solder_paste_id: getZodPrefixedIdWithDefault("pcb_solder_paste"),
3892
4007
  pcb_group_id: import_zod110.z.string().optional(),
3893
4008
  subcircuit_id: import_zod110.z.string().optional(),
3894
- x: distance,
3895
- y: distance,
4009
+ x: distance2,
4010
+ y: distance2,
3896
4011
  width: import_zod110.z.number(),
3897
4012
  height: import_zod110.z.number(),
3898
4013
  radius: import_zod110.z.number(),
@@ -3906,11 +4021,11 @@ var pcb_solder_paste_rotated_rect = import_zod110.z.object({
3906
4021
  pcb_solder_paste_id: getZodPrefixedIdWithDefault("pcb_solder_paste"),
3907
4022
  pcb_group_id: import_zod110.z.string().optional(),
3908
4023
  subcircuit_id: import_zod110.z.string().optional(),
3909
- x: distance,
3910
- y: distance,
4024
+ x: distance2,
4025
+ y: distance2,
3911
4026
  width: import_zod110.z.number(),
3912
4027
  height: import_zod110.z.number(),
3913
- ccw_rotation: distance,
4028
+ ccw_rotation: distance2,
3914
4029
  layer: layer_ref,
3915
4030
  pcb_component_id: import_zod110.z.string().optional(),
3916
4031
  pcb_smtpad_id: import_zod110.z.string().optional()
@@ -3921,8 +4036,8 @@ var pcb_solder_paste_rotated_pill = import_zod110.z.object({
3921
4036
  pcb_solder_paste_id: getZodPrefixedIdWithDefault("pcb_solder_paste"),
3922
4037
  pcb_group_id: import_zod110.z.string().optional(),
3923
4038
  subcircuit_id: import_zod110.z.string().optional(),
3924
- x: distance,
3925
- y: distance,
4039
+ x: distance2,
4040
+ y: distance2,
3926
4041
  width: import_zod110.z.number(),
3927
4042
  height: import_zod110.z.number(),
3928
4043
  radius: import_zod110.z.number(),
@@ -3937,8 +4052,8 @@ var pcb_solder_paste_oval = import_zod110.z.object({
3937
4052
  pcb_solder_paste_id: getZodPrefixedIdWithDefault("pcb_solder_paste"),
3938
4053
  pcb_group_id: import_zod110.z.string().optional(),
3939
4054
  subcircuit_id: import_zod110.z.string().optional(),
3940
- x: distance,
3941
- y: distance,
4055
+ x: distance2,
4056
+ y: distance2,
3942
4057
  width: import_zod110.z.number(),
3943
4058
  height: import_zod110.z.number(),
3944
4059
  layer: layer_ref,
@@ -3980,9 +4095,9 @@ var pcb_text = import_zod111.z.object({
3980
4095
  expectTypesMatch(true);
3981
4096
  var pcb_trace_route_point_wire = import_zod112.z.object({
3982
4097
  route_type: import_zod112.z.literal("wire"),
3983
- x: distance,
3984
- y: distance,
3985
- width: distance,
4098
+ x: distance2,
4099
+ y: distance2,
4100
+ width: distance2,
3986
4101
  copper_pour_id: import_zod112.z.string().optional(),
3987
4102
  is_inside_copper_pour: import_zod112.z.boolean().optional(),
3988
4103
  start_pcb_port_id: import_zod112.z.string().optional(),
@@ -3991,12 +4106,12 @@ var pcb_trace_route_point_wire = import_zod112.z.object({
3991
4106
  });
3992
4107
  var pcb_trace_route_point_via = import_zod112.z.object({
3993
4108
  route_type: import_zod112.z.literal("via"),
3994
- x: distance,
3995
- y: distance,
4109
+ x: distance2,
4110
+ y: distance2,
3996
4111
  copper_pour_id: import_zod112.z.string().optional(),
3997
4112
  is_inside_copper_pour: import_zod112.z.boolean().optional(),
3998
- hole_diameter: distance.optional(),
3999
- outer_diameter: distance.optional(),
4113
+ hole_diameter: distance2.optional(),
4114
+ outer_diameter: distance2.optional(),
4000
4115
  from_layer: layer_ref,
4001
4116
  to_layer: layer_ref
4002
4117
  });
@@ -4004,7 +4119,7 @@ var pcb_trace_route_point_through_pad = import_zod112.z.object({
4004
4119
  route_type: import_zod112.z.literal("through_pad"),
4005
4120
  start: point,
4006
4121
  end: point,
4007
- width: distance,
4122
+ width: distance2,
4008
4123
  start_layer: layer_ref,
4009
4124
  end_layer: layer_ref,
4010
4125
  pcb_smtpad_id: import_zod112.z.string().optional(),
@@ -4054,8 +4169,8 @@ var pcb_trace_too_long_warning = import_zod114.z.object({
4054
4169
  pcb_trace_id: import_zod114.z.string(),
4055
4170
  source_net_id: import_zod114.z.string().optional(),
4056
4171
  source_trace_id: import_zod114.z.string().optional(),
4057
- actual_trace_length: distance,
4058
- maximum_trace_length: distance,
4172
+ actual_trace_length: distance2,
4173
+ maximum_trace_length: distance2,
4059
4174
  subcircuit_id: import_zod114.z.string().optional()
4060
4175
  }).describe(
4061
4176
  "Warning emitted when a PCB trace is longer than its maximum allowed length"
@@ -4139,10 +4254,10 @@ var pcb_via = import_zod121.z.object({
4139
4254
  pcb_group_id: import_zod121.z.string().optional(),
4140
4255
  subcircuit_id: import_zod121.z.string().optional(),
4141
4256
  subcircuit_connectivity_map_key: import_zod121.z.string().optional(),
4142
- x: distance,
4143
- y: distance,
4144
- outer_diameter: distance.default("0.6mm"),
4145
- hole_diameter: distance.default("0.25mm"),
4257
+ x: distance2,
4258
+ y: distance2,
4259
+ outer_diameter: distance2.default("0.6mm"),
4260
+ hole_diameter: distance2.default("0.25mm"),
4146
4261
  /** @deprecated */
4147
4262
  from_layer: layer_ref.optional(),
4148
4263
  /** @deprecated */
@@ -4240,11 +4355,11 @@ var pcb_silkscreen_line = import_zod128.z.object({
4240
4355
  pcb_component_id: import_zod128.z.string(),
4241
4356
  pcb_group_id: import_zod128.z.string().optional(),
4242
4357
  subcircuit_id: import_zod128.z.string().optional(),
4243
- stroke_width: distance.default("0.1mm"),
4244
- x1: distance,
4245
- y1: distance,
4246
- x2: distance,
4247
- y2: distance,
4358
+ stroke_width: distance2.default("0.1mm"),
4359
+ x1: distance2,
4360
+ y1: distance2,
4361
+ x2: distance2,
4362
+ y2: distance2,
4248
4363
  layer: visible_layer
4249
4364
  }).describe("Defines a silkscreen line on the PCB");
4250
4365
  expectTypesMatch(true);
@@ -4265,7 +4380,7 @@ var pcb_silkscreen_text = import_zod130.z.object({
4265
4380
  pcb_group_id: import_zod130.z.string().optional(),
4266
4381
  subcircuit_id: import_zod130.z.string().optional(),
4267
4382
  font: import_zod130.z.literal("tscircuit2024").default("tscircuit2024"),
4268
- font_size: distance.default("0.2mm"),
4383
+ font_size: distance2.default("0.2mm"),
4269
4384
  pcb_component_id: import_zod130.z.string(),
4270
4385
  text: import_zod130.z.string(),
4271
4386
  is_knockout: import_zod130.z.boolean().default(false).optional(),
@@ -4293,7 +4408,7 @@ var pcb_copper_text = import_zod131.z.object({
4293
4408
  pcb_group_id: import_zod131.z.string().optional(),
4294
4409
  subcircuit_id: import_zod131.z.string().optional(),
4295
4410
  font: import_zod131.z.literal("tscircuit2024").default("tscircuit2024"),
4296
- font_size: distance.default("0.2mm"),
4411
+ font_size: distance2.default("0.2mm"),
4297
4412
  pcb_component_id: import_zod131.z.string(),
4298
4413
  text: import_zod131.z.string(),
4299
4414
  is_knockout: import_zod131.z.boolean().default(false).optional(),
@@ -4355,8 +4470,8 @@ var pcb_silkscreen_oval = import_zod134.z.object({
4355
4470
  pcb_group_id: import_zod134.z.string().optional(),
4356
4471
  subcircuit_id: import_zod134.z.string().optional(),
4357
4472
  center: point,
4358
- radius_x: distance,
4359
- radius_y: distance,
4473
+ radius_x: distance2,
4474
+ radius_y: distance2,
4360
4475
  layer: visible_layer,
4361
4476
  ccw_rotation: rotation.optional()
4362
4477
  }).describe("Defines a silkscreen oval on the PCB");
@@ -4402,7 +4517,7 @@ var pcb_fabrication_note_text = import_zod137.z.object({
4402
4517
  subcircuit_id: import_zod137.z.string().optional(),
4403
4518
  pcb_group_id: import_zod137.z.string().optional(),
4404
4519
  font: import_zod137.z.literal("tscircuit2024").default("tscircuit2024"),
4405
- font_size: distance.default("1mm"),
4520
+ font_size: distance2.default("1mm"),
4406
4521
  pcb_component_id: import_zod137.z.string(),
4407
4522
  text: import_zod137.z.string(),
4408
4523
  ccw_rotation: import_zod137.z.number().optional(),
@@ -4482,7 +4597,7 @@ var pcb_note_text = import_zod141.z.object({
4482
4597
  subcircuit_id: import_zod141.z.string().optional(),
4483
4598
  name: import_zod141.z.string().optional(),
4484
4599
  font: import_zod141.z.literal("tscircuit2024").default("tscircuit2024"),
4485
- font_size: distance.default("1mm"),
4600
+ font_size: distance2.default("1mm"),
4486
4601
  text: import_zod141.z.string().optional(),
4487
4602
  anchor_position: point.default({ x: 0, y: 0 }),
4488
4603
  anchor_alignment: import_zod141.z.enum(["center", "top_left", "top_right", "bottom_left", "bottom_right"]).default("center"),
@@ -4533,12 +4648,12 @@ var pcb_note_line = import_zod144.z.object({
4533
4648
  subcircuit_id: import_zod144.z.string().optional(),
4534
4649
  name: import_zod144.z.string().optional(),
4535
4650
  text: import_zod144.z.string().optional(),
4536
- x1: distance,
4537
- y1: distance,
4538
- x2: distance,
4539
- y2: distance,
4651
+ x1: distance2,
4652
+ y1: distance2,
4653
+ x2: distance2,
4654
+ y2: distance2,
4540
4655
  layer: visible_layer.default("top"),
4541
- stroke_width: distance.default("0.1mm"),
4656
+ stroke_width: distance2.default("0.1mm"),
4542
4657
  color: import_zod144.z.string().optional(),
4543
4658
  is_dashed: import_zod144.z.boolean().optional()
4544
4659
  }).describe("Defines a straight documentation note line on the PCB");
@@ -4595,8 +4710,8 @@ var pcb_keepout = import_zod148.z.object({
4595
4710
  pcb_group_id: import_zod148.z.string().optional(),
4596
4711
  subcircuit_id: import_zod148.z.string().optional(),
4597
4712
  center: point,
4598
- width: distance,
4599
- height: distance,
4713
+ width: distance2,
4714
+ height: distance2,
4600
4715
  pcb_keepout_id: import_zod148.z.string(),
4601
4716
  layers: import_zod148.z.array(import_zod148.z.string()),
4602
4717
  // Specify layers where the keepout applies
@@ -4610,7 +4725,7 @@ var pcb_keepout = import_zod148.z.object({
4610
4725
  pcb_group_id: import_zod148.z.string().optional(),
4611
4726
  subcircuit_id: import_zod148.z.string().optional(),
4612
4727
  center: point,
4613
- radius: distance,
4728
+ radius: distance2,
4614
4729
  pcb_keepout_id: import_zod148.z.string(),
4615
4730
  layers: import_zod148.z.array(import_zod148.z.string()),
4616
4731
  // Specify layers where the keepout applies
@@ -4815,8 +4930,8 @@ var pcb_breakout_point = import_zod159.z.object({
4815
4930
  source_port_id: import_zod159.z.string().optional(),
4816
4931
  source_net_id: import_zod159.z.string().optional(),
4817
4932
  layer: layer_ref.optional(),
4818
- x: distance,
4819
- y: distance
4933
+ x: distance2,
4934
+ y: distance2
4820
4935
  }).describe(
4821
4936
  "Defines a routing target within a pcb_group for a source_trace or source_net"
4822
4937
  );
@@ -4848,9 +4963,9 @@ var pcb_thermal_spoke = import_zod162.z.object({
4848
4963
  pcb_ground_plane_id: import_zod162.z.string(),
4849
4964
  shape: import_zod162.z.string(),
4850
4965
  spoke_count: import_zod162.z.number(),
4851
- spoke_thickness: distance,
4852
- spoke_inner_diameter: distance,
4853
- spoke_outer_diameter: distance,
4966
+ spoke_thickness: distance2,
4967
+ spoke_inner_diameter: distance2,
4968
+ spoke_outer_diameter: distance2,
4854
4969
  pcb_plated_hole_id: import_zod162.z.string().optional(),
4855
4970
  subcircuit_id: import_zod162.z.string().optional()
4856
4971
  }).describe("Pattern for connecting a ground plane to a plated hole");
@@ -4944,8 +5059,8 @@ var pcb_via_clearance_error = base_circuit_json_error.extend({
4944
5059
  pcb_error_id: getZodPrefixedIdWithDefault("pcb_error"),
4945
5060
  error_type: import_zod167.z.literal("pcb_via_clearance_error").default("pcb_via_clearance_error"),
4946
5061
  pcb_via_ids: import_zod167.z.array(import_zod167.z.string()).min(2),
4947
- minimum_clearance: distance.optional(),
4948
- actual_clearance: distance.optional(),
5062
+ minimum_clearance: distance2.optional(),
5063
+ actual_clearance: distance2.optional(),
4949
5064
  pcb_center: import_zod167.z.object({
4950
5065
  x: import_zod167.z.number().optional(),
4951
5066
  y: import_zod167.z.number().optional()
@@ -4961,8 +5076,8 @@ var pcb_via_trace_clearance_error = base_circuit_json_error.extend({
4961
5076
  error_type: import_zod168.z.literal("pcb_via_trace_clearance_error").default("pcb_via_trace_clearance_error"),
4962
5077
  pcb_via_id: import_zod168.z.string(),
4963
5078
  pcb_trace_id: import_zod168.z.string(),
4964
- minimum_clearance: distance.optional(),
4965
- actual_clearance: distance.optional(),
5079
+ minimum_clearance: distance2.optional(),
5080
+ actual_clearance: distance2.optional(),
4966
5081
  center: import_zod168.z.object({
4967
5082
  x: import_zod168.z.number().optional(),
4968
5083
  y: import_zod168.z.number().optional()
@@ -4981,8 +5096,8 @@ var pcb_pad_pad_clearance_error = base_circuit_json_error.extend({
4981
5096
  ),
4982
5097
  error_type: import_zod169.z.literal("pcb_pad_pad_clearance_error").default("pcb_pad_pad_clearance_error"),
4983
5098
  pcb_pad_ids: import_zod169.z.array(import_zod169.z.string()).min(2),
4984
- minimum_clearance: distance.optional(),
4985
- actual_clearance: distance.optional(),
5099
+ minimum_clearance: distance2.optional(),
5100
+ actual_clearance: distance2.optional(),
4986
5101
  center: import_zod169.z.object({
4987
5102
  x: import_zod169.z.number().optional(),
4988
5103
  y: import_zod169.z.number().optional()
@@ -4998,8 +5113,8 @@ var pcb_pad_trace_clearance_error = base_circuit_json_error.extend({
4998
5113
  error_type: import_zod170.z.literal("pcb_pad_trace_clearance_error").default("pcb_pad_trace_clearance_error"),
4999
5114
  pcb_pad_id: import_zod170.z.string(),
5000
5115
  pcb_trace_id: import_zod170.z.string(),
5001
- minimum_clearance: distance.optional(),
5002
- actual_clearance: distance.optional(),
5116
+ minimum_clearance: distance2.optional(),
5117
+ actual_clearance: distance2.optional(),
5003
5118
  center: import_zod170.z.object({
5004
5119
  x: import_zod170.z.number().optional(),
5005
5120
  y: import_zod170.z.number().optional()
@@ -7135,6 +7250,225 @@ var transformPCBElements = (elms, matrix) => {
7135
7250
  }
7136
7251
  return transformedElms;
7137
7252
  };
7253
+ var mergeBounds = (currentBounds, nextBounds) => ({
7254
+ minX: Math.min(currentBounds.minX, nextBounds.minX),
7255
+ minY: Math.min(currentBounds.minY, nextBounds.minY),
7256
+ maxX: Math.max(currentBounds.maxX, nextBounds.maxX),
7257
+ maxY: Math.max(currentBounds.maxY, nextBounds.maxY)
7258
+ });
7259
+ var getCircleBounds = (x, y, diameter) => {
7260
+ const radius = diameter / 2;
7261
+ return {
7262
+ minX: x - radius,
7263
+ minY: y - radius,
7264
+ maxX: x + radius,
7265
+ maxY: y + radius
7266
+ };
7267
+ };
7268
+ var getRotatedRectBounds = (x, y, width, height, rotationDegrees) => {
7269
+ const halfWidth = width / 2;
7270
+ const halfHeight = height / 2;
7271
+ const theta = rotationDegrees * Math.PI / 180;
7272
+ const cosTheta = Math.cos(theta);
7273
+ const sinTheta = Math.sin(theta);
7274
+ const corners = [
7275
+ { x: -halfWidth, y: -halfHeight },
7276
+ { x: halfWidth, y: -halfHeight },
7277
+ { x: halfWidth, y: halfHeight },
7278
+ { x: -halfWidth, y: halfHeight }
7279
+ ].map((corner) => ({
7280
+ x: x + corner.x * cosTheta - corner.y * sinTheta,
7281
+ y: y + corner.x * sinTheta + corner.y * cosTheta
7282
+ }));
7283
+ return {
7284
+ minX: Math.min(...corners.map((corner) => corner.x)),
7285
+ minY: Math.min(...corners.map((corner) => corner.y)),
7286
+ maxX: Math.max(...corners.map((corner) => corner.x)),
7287
+ maxY: Math.max(...corners.map((corner) => corner.y))
7288
+ };
7289
+ };
7290
+ var getRotatedOvalBounds = (x, y, width, height, rotationDegrees) => {
7291
+ const radiusX = width / 2;
7292
+ const radiusY = height / 2;
7293
+ const theta = rotationDegrees * Math.PI / 180;
7294
+ const cosTheta = Math.cos(theta);
7295
+ const sinTheta = Math.sin(theta);
7296
+ const halfWidth = Math.hypot(radiusX * cosTheta, radiusY * sinTheta);
7297
+ const halfHeight = Math.hypot(radiusX * sinTheta, radiusY * cosTheta);
7298
+ return {
7299
+ minX: x - halfWidth,
7300
+ minY: y - halfHeight,
7301
+ maxX: x + halfWidth,
7302
+ maxY: y + halfHeight
7303
+ };
7304
+ };
7305
+ var getRotatedPillBounds = (x, y, width, height, rotationDegrees) => {
7306
+ const radius = Math.min(width, height) / 2;
7307
+ const halfLineLength = Math.max(width, height) / 2 - radius;
7308
+ const theta = rotationDegrees * Math.PI / 180;
7309
+ const axis = width >= height ? { x: halfLineLength, y: 0 } : { x: 0, y: halfLineLength };
7310
+ const rotatedAxis = {
7311
+ x: axis.x * Math.cos(theta) - axis.y * Math.sin(theta),
7312
+ y: axis.x * Math.sin(theta) + axis.y * Math.cos(theta)
7313
+ };
7314
+ const halfWidth = Math.abs(rotatedAxis.x) + radius;
7315
+ const halfHeight = Math.abs(rotatedAxis.y) + radius;
7316
+ return {
7317
+ minX: x - halfWidth,
7318
+ minY: y - halfHeight,
7319
+ maxX: x + halfWidth,
7320
+ maxY: y + halfHeight
7321
+ };
7322
+ };
7323
+ var getBoundsFromPoints2 = (points) => {
7324
+ if (points.length === 0) return null;
7325
+ return {
7326
+ minX: Math.min(...points.map((point2) => point2.x)),
7327
+ minY: Math.min(...points.map((point2) => point2.y)),
7328
+ maxX: Math.max(...points.map((point2) => point2.x)),
7329
+ maxY: Math.max(...points.map((point2) => point2.y))
7330
+ };
7331
+ };
7332
+ var getRoutePoints = (route) => {
7333
+ if (!Array.isArray(route)) return [];
7334
+ return route.flatMap((point2) => {
7335
+ if (!point2 || typeof point2 !== "object") return [];
7336
+ if ("x" in point2 && "y" in point2 && typeof point2.x === "number" && typeof point2.y === "number") {
7337
+ return [{ x: point2.x, y: point2.y }];
7338
+ }
7339
+ if ("start" in point2 && "end" in point2) {
7340
+ const positions = [point2.start, point2.end];
7341
+ return positions.filter(
7342
+ (position2) => Boolean(
7343
+ position2 && typeof position2 === "object" && "x" in position2 && "y" in position2 && typeof position2.x === "number" && typeof position2.y === "number"
7344
+ )
7345
+ );
7346
+ }
7347
+ return [];
7348
+ });
7349
+ };
7350
+ var getPcbElementBounds = (elm) => {
7351
+ if (!elm.type.startsWith("pcb_")) return null;
7352
+ if (elm.type === "pcb_smtpad" && elm.shape === "polygon" && Array.isArray(elm.points)) {
7353
+ return getBoundsFromPoints2(elm.points);
7354
+ }
7355
+ if (elm.type === "pcb_hole" && elm.hole_shape === "circle") {
7356
+ return getCircleBounds(elm.x, elm.y, elm.hole_diameter);
7357
+ }
7358
+ if (elm.type === "pcb_plated_hole") {
7359
+ let platedHoleBounds;
7360
+ if ("outer_diameter" in elm && typeof elm.outer_diameter === "number") {
7361
+ platedHoleBounds = getCircleBounds(elm.x, elm.y, elm.outer_diameter);
7362
+ } else if ("hole_diameter" in elm && typeof elm.hole_diameter === "number") {
7363
+ platedHoleBounds = getCircleBounds(elm.x, elm.y, elm.hole_diameter);
7364
+ }
7365
+ if ((elm.shape === "oval" || elm.shape === "pill") && typeof elm.outer_width === "number" && typeof elm.outer_height === "number") {
7366
+ const getOuterBounds = elm.shape === "pill" ? getRotatedPillBounds : getRotatedOvalBounds;
7367
+ platedHoleBounds = getOuterBounds(
7368
+ elm.x,
7369
+ elm.y,
7370
+ elm.outer_width,
7371
+ elm.outer_height,
7372
+ elm.ccw_rotation ?? 0
7373
+ );
7374
+ }
7375
+ if ("rect_pad_width" in elm && typeof elm.rect_pad_width === "number" && "rect_pad_height" in elm && typeof elm.rect_pad_height === "number") {
7376
+ const rectBounds = getRotatedRectBounds(
7377
+ elm.x,
7378
+ elm.y,
7379
+ elm.rect_pad_width,
7380
+ elm.rect_pad_height,
7381
+ "rect_ccw_rotation" in elm ? elm.rect_ccw_rotation ?? 0 : 0
7382
+ );
7383
+ platedHoleBounds = platedHoleBounds ? mergeBounds(platedHoleBounds, rectBounds) : rectBounds;
7384
+ }
7385
+ if ("hole_diameter" in elm && typeof elm.hole_diameter === "number") {
7386
+ const drillBounds = getCircleBounds(
7387
+ elm.x + ("hole_offset_x" in elm ? elm.hole_offset_x ?? 0 : 0),
7388
+ elm.y + ("hole_offset_y" in elm ? elm.hole_offset_y ?? 0 : 0),
7389
+ elm.hole_diameter
7390
+ );
7391
+ platedHoleBounds = platedHoleBounds ? mergeBounds(platedHoleBounds, drillBounds) : drillBounds;
7392
+ }
7393
+ if (platedHoleBounds) return platedHoleBounds;
7394
+ }
7395
+ const elementRecord = elm;
7396
+ const routeBounds = getBoundsFromPoints2(getRoutePoints(elementRecord.route));
7397
+ if (routeBounds) return routeBounds;
7398
+ const outlineBounds = getBoundsFromPoints2(
7399
+ getRoutePoints(elementRecord.outline)
7400
+ );
7401
+ if (outlineBounds) return outlineBounds;
7402
+ const pointsBounds = getBoundsFromPoints2(getRoutePoints(elementRecord.points));
7403
+ if (pointsBounds) return pointsBounds;
7404
+ let centerX;
7405
+ let centerY;
7406
+ let width;
7407
+ let height;
7408
+ if ("x" in elm && "y" in elm) {
7409
+ centerX = Number(elm.x);
7410
+ centerY = Number(elm.y);
7411
+ }
7412
+ if ("outer_diameter" in elm) {
7413
+ width = Number(elm.outer_diameter);
7414
+ height = Number(elm.outer_diameter);
7415
+ }
7416
+ if ("width" in elm) {
7417
+ width = Number(elm.width);
7418
+ }
7419
+ if ("height" in elm) {
7420
+ height = Number(elm.height);
7421
+ }
7422
+ if ("center" in elm && elm.center && typeof elm.center === "object" && "x" in elm.center && "y" in elm.center) {
7423
+ centerX = Number(elm.center.x);
7424
+ centerY = Number(elm.center.y);
7425
+ }
7426
+ let rotation2 = 0;
7427
+ if ("rotation" in elm && typeof elm.rotation === "number") {
7428
+ rotation2 = elm.rotation;
7429
+ }
7430
+ if ("ccw_rotation" in elm && typeof elm.ccw_rotation === "number") {
7431
+ rotation2 = elm.ccw_rotation;
7432
+ }
7433
+ if (centerX !== void 0 && centerY !== void 0) {
7434
+ if (width !== void 0 && height !== void 0) {
7435
+ return rotation2 ? getRotatedRectBounds(centerX, centerY, width, height, rotation2) : {
7436
+ minX: centerX - width / 2,
7437
+ minY: centerY - height / 2,
7438
+ maxX: centerX + width / 2,
7439
+ maxY: centerY + height / 2
7440
+ };
7441
+ }
7442
+ if ("radius" in elm && typeof elm.radius === "number") {
7443
+ return getCircleBounds(centerX, centerY, elm.radius * 2);
7444
+ }
7445
+ return { minX: centerX, minY: centerY, maxX: centerX, maxY: centerY };
7446
+ }
7447
+ const anchoredPoint = [elementRecord.anchor_position, elementRecord.position].filter(
7448
+ (position2) => Boolean(
7449
+ position2 && typeof position2 === "object" && "x" in position2 && "y" in position2 && typeof position2.x === "number" && typeof position2.y === "number"
7450
+ )
7451
+ ).at(0);
7452
+ return anchoredPoint ? {
7453
+ minX: anchoredPoint.x,
7454
+ minY: anchoredPoint.y,
7455
+ maxX: anchoredPoint.x,
7456
+ maxY: anchoredPoint.y
7457
+ } : null;
7458
+ };
7459
+ var getBoundsOfPcbElements = (elements) => {
7460
+ let bounds = {
7461
+ minX: Number.POSITIVE_INFINITY,
7462
+ minY: Number.POSITIVE_INFINITY,
7463
+ maxX: Number.NEGATIVE_INFINITY,
7464
+ maxY: Number.NEGATIVE_INFINITY
7465
+ };
7466
+ for (const element of elements) {
7467
+ const elementBounds = getPcbElementBounds(element);
7468
+ if (elementBounds) bounds = mergeBounds(bounds, elementBounds);
7469
+ }
7470
+ return bounds;
7471
+ };
7138
7472
  function stringHash(str) {
7139
7473
  let hash = 0;
7140
7474
  if (str.length == 0) return hash;
@@ -7684,52 +8018,6 @@ var isLedCategoryComponent = (betterEasy) => {
7684
8018
  ].some(categoryValueContainsLed);
7685
8019
  };
7686
8020
 
7687
- // node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
7688
- function distance2(p1, p2) {
7689
- const dx = p1.x - p2.x;
7690
- const dy = p1.y - p2.y;
7691
- return Math.sqrt(dx * dx + dy * dy);
7692
- }
7693
-
7694
- // node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
7695
- var getUnitVectorFromDirection = (direction) => {
7696
- switch (direction) {
7697
- case "up":
7698
- return { x: 0, y: 1 };
7699
- case "down":
7700
- return { x: 0, y: -1 };
7701
- case "left":
7702
- return { x: -1, y: 0 };
7703
- case "right":
7704
- return { x: 1, y: 0 };
7705
- }
7706
- };
7707
-
7708
- // node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
7709
- var getBoundsCenter = (bounds) => ({
7710
- x: (bounds.minX + bounds.maxX) / 2,
7711
- y: (bounds.minY + bounds.maxY) / 2
7712
- });
7713
-
7714
- // node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
7715
- var getBoundsFromPoints = (points) => {
7716
- if (points.length === 0) {
7717
- return null;
7718
- }
7719
- let minX = points[0].x;
7720
- let minY = points[0].y;
7721
- let maxX = points[0].x;
7722
- let maxY = points[0].y;
7723
- for (let i = 1; i < points.length; i++) {
7724
- const point2 = points[i];
7725
- if (point2.x < minX) minX = point2.x;
7726
- if (point2.y < minY) minY = point2.y;
7727
- if (point2.x > maxX) maxX = point2.x;
7728
- if (point2.y > maxY) maxY = point2.y;
7729
- }
7730
- return { minX, minY, maxX, maxY };
7731
- };
7732
-
7733
8021
  // lib/websafe/get-easyeda-cad-placement-helpers.ts
7734
8022
  var getCadSvgNode = (easyEdaJson) => {
7735
8023
  const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(
@@ -7867,6 +8155,39 @@ var parseCadOffsetsFromSvgNode = (svgNode) => {
7867
8155
  })()
7868
8156
  };
7869
8157
  };
8158
+ var getCadModelOutlineBounds = (svgNode) => {
8159
+ const points = [];
8160
+ for (const childNode of svgNode?.svgData.childNodes ?? []) {
8161
+ if (typeof childNode !== "object" || childNode === null) continue;
8162
+ const attrs = childNode.attrs;
8163
+ if (typeof attrs !== "object" || attrs === null) continue;
8164
+ const rawPoints = attrs.points;
8165
+ if (typeof rawPoints !== "string") continue;
8166
+ const coordinates = rawPoints.trim().split(/\s+/).map(Number);
8167
+ for (let index = 0; index + 1 < coordinates.length; index += 2) {
8168
+ const x = coordinates[index];
8169
+ const y = coordinates[index + 1];
8170
+ if (!Number.isFinite(x) || !Number.isFinite(y)) continue;
8171
+ points.push({ x: milx10(x), y: milx10(y) });
8172
+ }
8173
+ }
8174
+ if (points.length === 0) return void 0;
8175
+ return {
8176
+ minX: Math.min(...points.map((point2) => point2.x)),
8177
+ minY: Math.min(...points.map((point2) => point2.y)),
8178
+ maxX: Math.max(...points.map((point2) => point2.x)),
8179
+ maxY: Math.max(...points.map((point2) => point2.y))
8180
+ };
8181
+ };
8182
+ var unionBounds = (first, second) => {
8183
+ if (!second) return first;
8184
+ return {
8185
+ minX: Math.min(first.minX, second.minX),
8186
+ minY: Math.min(first.minY, second.minY),
8187
+ maxX: Math.max(first.maxX, second.maxX),
8188
+ maxY: Math.max(first.maxY, second.maxY)
8189
+ };
8190
+ };
7870
8191
  var readModelHeightMm = (raw) => {
7871
8192
  const fallback = 3.5;
7872
8193
  if (raw == null) return fallback;
@@ -8322,6 +8643,19 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
8322
8643
  ).forEach((sr, index) => {
8323
8644
  circuitElements.push(handleCutout(sr, index));
8324
8645
  });
8646
+ const boardOutlineTracks = easyEdaJson.packageDetail.dataStr.shape.filter(
8647
+ (shape) => shape.type === "TRACK" && shape.layer === 10
8648
+ );
8649
+ getBoardOutlinePolygons(boardOutlineTracks).forEach((points, index) => {
8650
+ circuitElements.push(
8651
+ pcb_cutout.parse({
8652
+ type: "pcb_cutout",
8653
+ pcb_cutout_id: `pcb_cutout_outline_${index + 1}`,
8654
+ shape: "polygon",
8655
+ points: points.map((p) => ({ x: milx10(p.x), y: milx10(p.y) }))
8656
+ })
8657
+ );
8658
+ });
8325
8659
  let hasFoundDesignator = false;
8326
8660
  const silkscreenTracks = easyEdaJson.packageDetail.dataStr.shape.filter(
8327
8661
  (shape) => shape.type === "TRACK" && isSilkscreenLayer(shape.layer)
@@ -8445,17 +8779,29 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
8445
8779
  );
8446
8780
  }
8447
8781
  const hasExplicitCourtyard = circuitElements.some(
8448
- (e) => e.type === "pcb_courtyard_outline"
8782
+ (e) => e.type === "pcb_courtyard_outline" || e.type === "pcb_courtyard_rect"
8449
8783
  );
8450
8784
  if (!hasExplicitCourtyard) {
8451
8785
  const bbox = easyEdaJson.packageDetail.dataStr.BBox;
8452
- if (bbox) {
8786
+ const modelOutlineBounds = getCadModelOutlineBounds(svgNode);
8787
+ const packageElements = circuitElements.filter(
8788
+ (element) => element.type === "pcb_smtpad" || element.type === "pcb_plated_hole" || element.type === "pcb_hole" || element.type === "pcb_via"
8789
+ );
8790
+ const packageElementBounds = packageElements.length > 0 ? getBoundsOfPcbElements(packageElements) : void 0;
8791
+ const fallbackBounds = bbox ? {
8792
+ minX: milx10(bbox.x),
8793
+ minY: milx10(bbox.y),
8794
+ maxX: milx10(bbox.x + bbox.width),
8795
+ maxY: milx10(bbox.y + bbox.height)
8796
+ } : void 0;
8797
+ const courtyardBounds = modelOutlineBounds ? unionBounds(modelOutlineBounds, packageElementBounds) : fallbackBounds;
8798
+ if (courtyardBounds) {
8453
8799
  const strokeWidth = 0.05;
8454
8800
  const margin = 0.25;
8455
- const x1 = milx10(bbox.x) - margin;
8456
- const y1 = milx10(bbox.y) - margin;
8457
- const x2 = milx10(bbox.x + bbox.width) + margin;
8458
- const y2 = milx10(bbox.y + bbox.height) + margin;
8801
+ const x1 = courtyardBounds.minX - margin;
8802
+ const y1 = courtyardBounds.minY - margin;
8803
+ const x2 = courtyardBounds.maxX + margin;
8804
+ const y2 = courtyardBounds.maxY + margin;
8459
8805
  circuitElements.push(
8460
8806
  pcb_courtyard_outline.parse({
8461
8807
  type: "pcb_courtyard_outline",
@@ -9668,7 +10014,7 @@ var alignPortToDrawing = ({
9668
10014
  const alignmentTolerance = Math.max(0.02, stemLength * 0.25);
9669
10015
  const nearestEndpoint = drawingEndpoints.map((endpoint) => ({
9670
10016
  endpoint,
9671
- distance: distance2(endpoint, expectedBodyConnection)
10017
+ distance: distance(endpoint, expectedBodyConnection)
9672
10018
  })).filter((candidate) => candidate.distance <= alignmentTolerance).sort((a, b) => a.distance - b.distance)[0]?.endpoint;
9673
10019
  if (!nearestEndpoint) return position2;
9674
10020
  return {
@@ -9892,6 +10238,13 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
9892
10238
  const pcbNoteDimensions = su(circuitJson).pcb_note_dimension.list();
9893
10239
  const courtyardOutlines = su(circuitJson).pcb_courtyard_outline.list();
9894
10240
  const elementStrings = [];
10241
+ for (const cutout of su(circuitJson).pcb_cutout.list()) {
10242
+ if (cutout.shape === "polygon") {
10243
+ elementStrings.push(
10244
+ `<cutout shape="polygon" points={${JSON.stringify(cutout.points)}} />`
10245
+ );
10246
+ }
10247
+ }
9895
10248
  for (const hole of holes) {
9896
10249
  if (hole.hole_shape === "circle") {
9897
10250
  elementStrings.push(