easyeda 0.0.254 → 0.0.255
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/browser/index.js +13 -6
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +15 -8
- package/dist/main.cjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../node_modules/circuit-json/src/utils/convert-si-unit-to-number.ts","../node_modules/circuit-json/src/units/index.ts","../node_modules/circuit-json/src/common/point.ts","../node_modules/circuit-json/src/utils/expect-types-match.ts","../node_modules/circuit-json/src/common/point3.ts","../node_modules/circuit-json/src/common/size.ts","../node_modules/circuit-json/src/common/getZodPrefixedIdWithDefault.ts","../node_modules/circuit-json/src/common/NinePointAnchor.ts","../node_modules/circuit-json/src/common/PcbRenderLayer.ts","../node_modules/circuit-json/src/common/asset.ts","../node_modules/circuit-json/src/common/kicadFootprintMetadata.ts","../node_modules/circuit-json/src/common/kicadSymbolMetadata.ts","../node_modules/circuit-json/src/base_circuit_json_error.ts","../node_modules/circuit-json/src/source/source_simple_capacitor.ts","../node_modules/circuit-json/src/pcb/properties/supplier_name.ts","../node_modules/circuit-json/src/source/base/source_component_base.ts","../node_modules/circuit-json/src/source/source_simple_resistor.ts","../node_modules/circuit-json/src/source/source_simple_diode.ts","../node_modules/circuit-json/src/source/source_simple_fiducial.ts","../node_modules/circuit-json/src/source/source_simple_led.ts","../node_modules/circuit-json/src/source/source_simple_ground.ts","../node_modules/circuit-json/src/source/source_simple_chip.ts","../node_modules/circuit-json/src/source/source_simple_power_source.ts","../node_modules/circuit-json/src/source/source_simple_current_source.ts","../node_modules/circuit-json/src/source/properties/source_pin_attributes.ts","../node_modules/circuit-json/src/source/any_source_component.ts","../node_modules/circuit-json/src/source/source_simple_fuse.ts","../node_modules/circuit-json/src/source/source_simple_battery.ts","../node_modules/circuit-json/src/source/source_simple_inductor.ts","../node_modules/circuit-json/src/source/source_simple_push_button.ts","../node_modules/circuit-json/src/source/source_simple_potentiometer.ts","../node_modules/circuit-json/src/source/source_simple_crystal.ts","../node_modules/circuit-json/src/source/source_simple_pin_header.ts","../node_modules/circuit-json/src/source/source_simple_connector.ts","../node_modules/circuit-json/src/source/source_simple_pinout.ts","../node_modules/circuit-json/src/source/source_simple_resonator.ts","../node_modules/circuit-json/src/source/source_simple_transistor.ts","../node_modules/circuit-json/src/source/source_simple_test_point.ts","../node_modules/circuit-json/src/source/source_simple_mosfet.ts","../node_modules/circuit-json/src/source/source_simple_op_amp.ts","../node_modules/circuit-json/src/source/source_simple_switch.ts","../node_modules/circuit-json/src/source/source_project_metadata.ts","../node_modules/circuit-json/src/source/source_missing_property_error.ts","../node_modules/circuit-json/src/source/source_failed_to_create_component_error.ts","../node_modules/circuit-json/src/source/source_invalid_component_property_error.ts","../node_modules/circuit-json/src/source/source_trace_not_connected_error.ts","../node_modules/circuit-json/src/source/source_property_ignored_warning.ts","../node_modules/circuit-json/src/source/source_pin_missing_trace_warning.ts","../node_modules/circuit-json/src/source/source_simple_voltage_probe.ts","../node_modules/circuit-json/src/source/source_interconnect.ts","../node_modules/circuit-json/src/source/source_i2c_misconfigured_error.ts","../node_modules/circuit-json/src/source/source_simple_voltage_source.ts","../node_modules/circuit-json/src/source/source_port.ts","../node_modules/circuit-json/src/source/source_component_internal_connection.ts","../node_modules/circuit-json/src/source/source_trace.ts","../node_modules/circuit-json/src/source/source_group.ts","../node_modules/circuit-json/src/source/source_net.ts","../node_modules/circuit-json/src/source/source_board.ts","../node_modules/circuit-json/src/source/source_ambiguous_port_reference.ts","../node_modules/circuit-json/src/source/source_pcb_ground_plane.ts","../node_modules/circuit-json/src/source/source_manually_placed_via.ts","../node_modules/circuit-json/src/pcb/properties/layer_ref.ts","../node_modules/circuit-json/src/source/source_no_power_pin_defined_warning.ts","../node_modules/circuit-json/src/source/source_no_ground_pin_defined_warning.ts","../node_modules/circuit-json/src/source/source_component_pins_underspecified_warning.ts","../node_modules/circuit-json/src/source/source_pin_must_be_connected_error.ts","../node_modules/circuit-json/src/source/unknown_error_finding_part.ts","../node_modules/circuit-json/src/schematic/schematic_box.ts","../node_modules/circuit-json/src/schematic/schematic_path.ts","../node_modules/circuit-json/src/schematic/schematic_component.ts","../node_modules/circuit-json/src/schematic/schematic_symbol.ts","../node_modules/circuit-json/src/schematic/schematic_line.ts","../node_modules/circuit-json/src/schematic/schematic_rect.ts","../node_modules/circuit-json/src/schematic/schematic_circle.ts","../node_modules/circuit-json/src/schematic/schematic_arc.ts","../node_modules/circuit-json/src/schematic/schematic_trace.ts","../node_modules/circuit-json/src/schematic/schematic_text.ts","../node_modules/circuit-json/src/common/FivePointAnchor.ts","../node_modules/circuit-json/src/schematic/schematic_port.ts","../node_modules/circuit-json/src/schematic/schematic_net_label.ts","../node_modules/circuit-json/src/schematic/schematic_error.ts","../node_modules/circuit-json/src/schematic/schematic_layout_error.ts","../node_modules/circuit-json/src/schematic/schematic_debug_object.ts","../node_modules/circuit-json/src/schematic/schematic_voltage_probe.ts","../node_modules/circuit-json/src/schematic/schematic_manual_edit_conflict_warning.ts","../node_modules/circuit-json/src/schematic/schematic_group.ts","../node_modules/circuit-json/src/schematic/schematic_table.ts","../node_modules/circuit-json/src/schematic/schematic_table_cell.ts","../node_modules/circuit-json/src/schematic/schematic_sheet.ts","../node_modules/circuit-json/src/pcb/properties/brep.ts","../node_modules/circuit-json/src/pcb/properties/pcb_route_hints.ts","../node_modules/circuit-json/src/pcb/properties/route_hint_point.ts","../node_modules/circuit-json/src/pcb/pcb_component.ts","../node_modules/circuit-json/src/pcb/pcb_hole.ts","../node_modules/circuit-json/src/pcb/pcb_plated_hole.ts","../node_modules/circuit-json/src/pcb/pcb_port.ts","../node_modules/circuit-json/src/pcb/pcb_smtpad.ts","../node_modules/circuit-json/src/pcb/pcb_solder_paste.ts","../node_modules/circuit-json/src/pcb/pcb_text.ts","../node_modules/circuit-json/src/pcb/pcb_trace.ts","../node_modules/circuit-json/src/pcb/pcb_trace_error.ts","../node_modules/circuit-json/src/pcb/pcb_trace_missing_error.ts","../node_modules/circuit-json/src/pcb/pcb_port_not_matched_error.ts","../node_modules/circuit-json/src/pcb/pcb_port_not_connected_error.ts","../node_modules/circuit-json/src/pcb/pcb_net.ts","../node_modules/circuit-json/src/pcb/pcb_via.ts","../node_modules/circuit-json/src/pcb/pcb_board.ts","../node_modules/circuit-json/src/pcb/pcb_panel.ts","../node_modules/circuit-json/src/pcb/pcb_placement_error.ts","../node_modules/circuit-json/src/pcb/pcb_panelization_placement_error.ts","../node_modules/circuit-json/src/pcb/pcb_trace_hint.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_line.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_path.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_text.ts","../node_modules/circuit-json/src/pcb/pcb_copper_text.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_rect.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_circle.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_oval.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_pill.ts","../node_modules/circuit-json/src/pcb/pcb_fabrication_note_text.ts","../node_modules/circuit-json/src/pcb/pcb_fabrication_note_path.ts","../node_modules/circuit-json/src/pcb/pcb_fabrication_note_rect.ts","../node_modules/circuit-json/src/pcb/pcb_fabrication_note_dimension.ts","../node_modules/circuit-json/src/pcb/pcb_note_text.ts","../node_modules/circuit-json/src/pcb/pcb_note_rect.ts","../node_modules/circuit-json/src/pcb/pcb_note_path.ts","../node_modules/circuit-json/src/pcb/pcb_note_line.ts","../node_modules/circuit-json/src/pcb/pcb_note_dimension.ts","../node_modules/circuit-json/src/pcb/pcb_footprint_overlap_error.ts","../node_modules/circuit-json/src/pcb/pcb_courtyard_overlap_error.ts","../node_modules/circuit-json/src/pcb/pcb_keepout.ts","../node_modules/circuit-json/src/pcb/pcb_cutout.ts","../node_modules/circuit-json/src/pcb/pcb_missing_footprint_error.ts","../node_modules/circuit-json/src/pcb/external_footprint_load_error.ts","../node_modules/circuit-json/src/pcb/circuit_json_footprint_load_error.ts","../node_modules/circuit-json/src/pcb/pcb_group.ts","../node_modules/circuit-json/src/pcb/pcb_autorouting_error.ts","../node_modules/circuit-json/src/pcb/pcb_manual_edit_conflict_warning.ts","../node_modules/circuit-json/src/pcb/pcb_connector_not_in_accessible_orientation_warning.ts","../node_modules/circuit-json/src/pcb/pcb_breakout_point.ts","../node_modules/circuit-json/src/pcb/pcb_ground_plane.ts","../node_modules/circuit-json/src/pcb/pcb_ground_plane_region.ts","../node_modules/circuit-json/src/pcb/pcb_thermal_spoke.ts","../node_modules/circuit-json/src/pcb/pcb_copper_pour.ts","../node_modules/circuit-json/src/pcb/pcb_component_outside_board_error.ts","../node_modules/circuit-json/src/pcb/pcb_component_not_on_board_edge_error.ts","../node_modules/circuit-json/src/pcb/pcb_component_invalid_layer_error.ts","../node_modules/circuit-json/src/pcb/pcb_via_clearance_error.ts","../node_modules/circuit-json/src/pcb/pcb_courtyard_rect.ts","../node_modules/circuit-json/src/pcb/pcb_courtyard_outline.ts","../node_modules/circuit-json/src/pcb/pcb_courtyard_polygon.ts","../node_modules/circuit-json/src/pcb/pcb_courtyard_circle.ts","../node_modules/circuit-json/src/cad/cad_component.ts","../node_modules/circuit-json/src/cad/cad_model_conventions.ts","../node_modules/circuit-json/src/simulation/simulation_voltage_source.ts","../node_modules/circuit-json/src/simulation/simulation_current_source.ts","../node_modules/circuit-json/src/simulation/simulation_experiment.ts","../node_modules/circuit-json/src/simulation/simulation_transient_voltage_graph.ts","../node_modules/circuit-json/src/simulation/simulation_switch.ts","../node_modules/circuit-json/src/simulation/simulation_voltage_probe.ts","../node_modules/circuit-json/src/simulation/simulation_unknown_experiment_error.ts","../node_modules/circuit-json/src/simulation/simulation_op_amp.ts","../node_modules/circuit-json/src/any_circuit_element.ts","../node_modules/transformation-matrix/src/applyToPoint.js","../node_modules/transformation-matrix/src/utils.js","../node_modules/transformation-matrix/src/translate.js","../node_modules/transformation-matrix/src/transform.js","../node_modules/transformation-matrix/src/rotate.js","../node_modules/transformation-matrix/src/scale.js","../node_modules/transformation-matrix/src/skew.js","../node_modules/transformation-matrix/src/fromTransformAttribute.autogenerated.js","../node_modules/transformation-matrix/src/decompose.js","../node_modules/@tscircuit/circuit-json-util/lib/cju.ts","../node_modules/@tscircuit/circuit-json-util/lib/subtree.ts","../node_modules/@tscircuit/circuit-json-util/lib/cju-indexed.ts","../node_modules/@tscircuit/circuit-json-util/lib/transform-soup-elements.ts","../node_modules/@tscircuit/circuit-json-util/lib/direction-to-vec.ts","../node_modules/@tscircuit/circuit-json-util/lib/apply-selector.ts","../node_modules/@tscircuit/circuit-json-util/lib/convert-abbreviation-to-soup-element-type.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-element-id.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-element-by-id.ts","../node_modules/@tscircuit/circuit-json-util/lib/readable-name-functions/get-readable-name-for-pcb-trace.ts","../node_modules/@tscircuit/circuit-json-util/lib/readable-name-functions/get-readable-name-for-pcb-port.ts","../node_modules/@tscircuit/circuit-json-util/lib/readable-name-functions/get-readable-name-for-pcb-smtpad.ts","../node_modules/@tscircuit/circuit-json-util/lib/readable-name-functions/get-readable-name-for-element.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-bounds-of-pcb-elements.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-board-bounds.ts","../node_modules/@tscircuit/circuit-json-util/lib/utils/string-hash.ts","../node_modules/@tscircuit/circuit-json-util/lib/utils/get-layout-debug-object.ts","../node_modules/@tscircuit/circuit-json-util/lib/utils/is-truthy.ts","../node_modules/@tscircuit/circuit-json-util/lib/find-bounds-and-center.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-primary-id.ts","../node_modules/@tscircuit/circuit-json-util/lib/reposition-pcb-component.ts","../node_modules/@tscircuit/circuit-json-util/lib/reposition-pcb-group.ts","../node_modules/@tscircuit/circuit-json-util/lib/reposition-schematic-component.ts","../node_modules/@tscircuit/circuit-json-util/lib/reposition-schematic-group.ts","../node_modules/@tscircuit/circuit-json-util/lib/getCircuitJsonTree.ts","../node_modules/@tscircuit/circuit-json-util/lib/getStringFromCircuitJsonTree.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-minimum-flex-container.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-element-render-layers.ts","../node_modules/@tscircuit/circuit-json-util/lib/shape-distances/geometry.ts","../node_modules/@tscircuit/circuit-json-util/lib/shape-distances/decompose-copper-into-shapes.ts","../node_modules/@tscircuit/circuit-json-util/lib/shape-distances/distance-between-shapes.ts","../node_modules/@tscircuit/circuit-json-util/lib/compute-gap-between-copper.ts","../node_modules/@tscircuit/circuit-json-util/lib/shape-distances/decompose-clearance-into-shapes.ts","../node_modules/@tscircuit/circuit-json-util/lib/compute-clearance-between-elements.ts","../node_modules/@tscircuit/circuit-json-util/lib/categorize-error-or-warning.ts","../node_modules/@tscircuit/mm/index.ts","../lib/math/arc-utils.ts","../lib/utils/easyeda-unit-to-mm.ts","../lib/utils/normalize-pin-labels.ts","../lib/utils/normalize-symbol-name.ts","../lib/constants.ts","../lib/convert-easyeda-json-to-tscircuit-soup-json.ts","../lib/websafe/get-model-cdn-url.ts","../lib/websafe/fetch-easyeda-json.ts","../lib/schemas/easy-eda-json-schema.ts","../lib/schemas/package-detail-shape-schema.ts","../lib/schemas/single-letter-shape-schema.ts","../lib/utils/normalize-manufacturer-part-number.ts","../lib/websafe/get-easyeda-cad-placement-helpers.ts","../lib/websafe/get-easyeda-cad-model-placement.ts","../lib/websafe/generate-footprint-tsx.ts","../lib/websafe/convert-to-typescript-component/generate-typescript-component.ts","../lib/websafe/convert-to-typescript-component/index.tsx","../lib/convert-easyeda-json-to-various-formats.ts"],"sourcesContent":["type UnitInfo = {\n baseUnit: BaseTscircuitUnit\n conversionFactor: number\n}\n\nconst unitMappings: Record<\n string,\n { baseUnit: BaseTscircuitUnit; variants: Record<string, number> }\n> = {\n Hz: {\n baseUnit: \"Hz\",\n variants: {\n MHz: 1e6,\n kHz: 1e3,\n Hz: 1,\n },\n },\n g: {\n baseUnit: \"g\",\n variants: {\n kg: 1e3,\n g: 1,\n },\n },\n Ω: {\n baseUnit: \"Ω\",\n variants: {\n mΩ: 1e-3,\n Ω: 1,\n kΩ: 1e3,\n KΩ: 1e3,\n kohm: 1e3,\n MΩ: 1e6,\n GΩ: 1e9,\n TΩ: 1e12,\n },\n },\n V: {\n baseUnit: \"V\",\n variants: {\n mV: 1e-3,\n V: 1,\n kV: 1e3,\n KV: 1e3,\n MV: 1e6,\n GV: 1e9,\n TV: 1e12,\n },\n },\n A: {\n baseUnit: \"A\",\n variants: {\n µA: 1e-6,\n mA: 1e-3,\n ma: 1e-3,\n A: 1,\n kA: 1e3,\n MA: 1e6,\n },\n },\n F: {\n baseUnit: \"F\",\n variants: {\n pF: 1e-12,\n nF: 1e-9,\n µF: 1e-6,\n uF: 1e-6,\n mF: 1e-3,\n F: 1,\n },\n },\n ml: {\n baseUnit: \"ml\",\n variants: {\n ml: 1,\n mL: 1,\n l: 1e3,\n L: 1e3,\n },\n },\n deg: {\n baseUnit: \"deg\",\n variants: {\n rad: 180 / Math.PI,\n },\n },\n ms: {\n baseUnit: \"ms\",\n variants: {\n fs: 1e-12,\n ps: 1e-9,\n ns: 1e-6,\n us: 1e-3,\n µs: 1e-3,\n ms: 1,\n s: 1000,\n },\n },\n mm: {\n baseUnit: \"mm\",\n variants: {\n nm: 1e-6,\n µm: 1e-3,\n um: 1e-3,\n mm: 1,\n cm: 10,\n dm: 100,\n m: 1000,\n km: 1e6,\n in: 25.4,\n ft: 304.8,\n IN: 25.4,\n FT: 304.8,\n yd: 914.4,\n mi: 1.609344e6,\n mil: 0.0254,\n },\n },\n}\n\nconst unitMappingAndVariantSuffixes = new Set()\nfor (const [baseUnit, info] of Object.entries(unitMappings)) {\n unitMappingAndVariantSuffixes.add(baseUnit)\n for (const variant of Object.keys(info.variants)) {\n unitMappingAndVariantSuffixes.add(variant)\n }\n}\n\nfunction getBaseTscircuitUnit(unit: string): UnitInfo {\n for (const [baseUnit, info] of Object.entries(unitMappings)) {\n if (unit in info.variants) {\n return {\n baseUnit: info.baseUnit,\n conversionFactor: info.variants[unit]!,\n }\n }\n }\n return {\n baseUnit: unit as BaseTscircuitUnit,\n conversionFactor: 1,\n }\n}\n\nconst si_prefix_multiplier = {\n tera: 1e12,\n T: 1e12,\n giga: 1e9,\n G: 1e9,\n mega: 1e6,\n M: 1e6,\n kilo: 1e3,\n k: 1e3,\n deci: 1e-1,\n d: 1e-1,\n centi: 1e-2,\n c: 1e-2,\n milli: 1e-3,\n m: 1e-3,\n micro: 1e-6,\n u: 1e-6,\n µ: 1e-6,\n nano: 1e-9,\n n: 1e-9,\n pico: 1e-12,\n p: 1e-12,\n}\ntype BaseTscircuitUnit =\n | \"ms\"\n | \"mm\"\n | \"g\"\n | \"deg\"\n | \"Hz\"\n | \"ml\"\n | \"V\"\n | \"A\"\n | \"Ω\"\n | \"F\"\n | \"H\"\n\nexport function parseAndConvertSiUnit(v: {\n x: string | number\n y: string | number\n}): {\n parsedUnit: string | null\n unitOfValue: BaseTscircuitUnit | null\n value: { x: number; y: number } | null\n}\nexport function parseAndConvertSiUnit(v: string | number | undefined | null): {\n parsedUnit: string | null\n unitOfValue: BaseTscircuitUnit | null\n value: number | null\n}\nexport function parseAndConvertSiUnit(\n v:\n | string\n | number\n | undefined\n | null\n | { x: string | number; y: string | number },\n): {\n parsedUnit: string | null\n unitOfValue: BaseTscircuitUnit | null\n value: null | number | { x: number; y: number }\n} {\n if (v === undefined || v === null)\n return { parsedUnit: null, unitOfValue: null, value: null }\n if (typeof v === \"string\" && v.match(/^-?[\\d\\.]+$/))\n return {\n value: Number.parseFloat(v),\n parsedUnit: null,\n unitOfValue: null,\n }\n if (typeof v === \"number\")\n return { value: v, parsedUnit: null, unitOfValue: null }\n if (typeof v === \"object\" && \"x\" in v && \"y\" in v) {\n const { parsedUnit, unitOfValue } = parseAndConvertSiUnit(v.x)\n const xResult = parseAndConvertSiUnit(v.x)\n const yResult = parseAndConvertSiUnit(v.y)\n if (xResult.value === null || yResult.value === null) {\n return { parsedUnit: null, unitOfValue: null, value: null }\n }\n return {\n parsedUnit: parsedUnit,\n unitOfValue: unitOfValue,\n value: {\n x: xResult.value,\n y: yResult.value,\n },\n }\n }\n const reversed_input_string = v.toString().split(\"\").reverse().join(\"\")\n const unit_reversed = reversed_input_string.match(/[^\\d\\s]+/)?.[0]\n if (!unit_reversed) {\n throw new Error(`Could not determine unit: \"${v}\"`)\n }\n const unit = unit_reversed.split(\"\").reverse().join(\"\")\n\n const numberPart = v.slice(0, -unit.length)\n if (\n unit in si_prefix_multiplier &&\n !unitMappingAndVariantSuffixes.has(unit)\n ) {\n const siMultiplier =\n si_prefix_multiplier[unit as keyof typeof si_prefix_multiplier]\n return {\n parsedUnit: null,\n unitOfValue: null,\n value: Number.parseFloat(numberPart) * siMultiplier,\n }\n }\n\n const { baseUnit, conversionFactor } = getBaseTscircuitUnit(unit)\n\n return {\n parsedUnit: unit,\n unitOfValue: baseUnit,\n value: conversionFactor * Number.parseFloat(numberPart),\n }\n}\n","import { parseAndConvertSiUnit } from \"src/utils/convert-si-unit-to-number\"\nimport { z } from \"zod\"\n\n// // Currently, removing uncommon SI Prefixes for type simplicity.\n// export type SIPrefix =\n// // | \"y\"\n// // | \"yocto\"\n// // | \"z\"\n// // | \"zepto\"\n// // | \"atto\"\n// // | \"a\"\n// | \"femto\"\n// | \"f\"\n// | \"u\"\n// | \"micro\"\n// // | \"d\"\n// // | \"deci\"\n// | \"c\"\n// | \"centi\"\n// | \"m\"\n// | \"milli\"\n// | \"k\"\n// | \"kilo\"\n// | \"M\"\n// | \"mega\"\n// // | \"G\"\n// // | \"T\"\n// // | \"P\"\n// // | \"E\"\n// // | \"Z\"\n// // | \"Y\"\n\n// export type UnitAbbreviations = {\n// farad: \"F\"\n// ohm: \"Ω\"\n// henry: \"H\"\n// meter: \"m\"\n// volt: \"V\"\n// inch: \"in\"\n// foot: \"ft\"\n// }\n\n// export type Unit = keyof UnitAbbreviations\n// export type NumberWithUnit<T extends Unit> =\n// | `${number}${T | UnitAbbreviations[T]}`\n// | `${number} ${T | UnitAbbreviations[T]}`\n// | `${number}${SIPrefix}${T | UnitAbbreviations[T]}`\n// | `${number} ${SIPrefix}${T | UnitAbbreviations[T]}`\n// export type NumberWithAnyUnit =\n// | `${number}${UnitOrAbbreviation}`\n// | `${number} ${UnitOrAbbreviation}`\n// | `${number}${SIPrefix}${UnitOrAbbreviation}`\n// | `${number} ${SIPrefix}${UnitOrAbbreviation}`\n\n// TODO lots of validation to make sure the unit is valid etc.\nexport const resistance = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const capacitance = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n .transform((value) => {\n return Number.parseFloat(value.toPrecision(12)) // Round to 12 significant digits\n })\n\nexport const inductance = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const voltage = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const length = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const frequency = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\n/**\n * Length in meters\n */\nexport type Length = number\nexport type Distance = number\n\nexport const distance = length\n\nexport const current = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const duration_ms = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const time = duration_ms\n\nexport const ms = duration_ms\n\nexport const timestamp = z.string().datetime()\n\n/**\n * Rotation is always converted to degrees\n */\nexport const rotation = z\n .string()\n .or(z.number())\n .transform((arg): number => {\n if (typeof arg === \"number\") return arg\n if (arg.endsWith(\"deg\")) {\n return Number.parseFloat(arg.split(\"deg\")[0]!)\n }\n if (arg.endsWith(\"rad\")) {\n return (Number.parseFloat(arg.split(\"rad\")[0]!) * 180) / Math.PI\n }\n return Number.parseFloat(arg)\n })\n\nexport const battery_capacity = z\n .number()\n .or(z.string().endsWith(\"mAh\"))\n .transform((v) => {\n if (typeof v === \"string\") {\n const valString = v.replace(\"mAh\", \"\")\n const num = Number.parseFloat(valString)\n if (Number.isNaN(num)) {\n throw new Error(\"Invalid capacity\")\n }\n return num\n }\n return v\n })\n .describe(\"Battery capacity in mAh\")\n\nexport type InputRotation = number | string\nexport type Rotation = number\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const point = z.object({\n x: distance,\n y: distance,\n})\n\nexport const position = point\n\nexport type InputPoint = z.input<typeof point>\nexport type InputPosition = z.input<typeof position>\ntype InferredPoint = z.infer<typeof point>\ntype InferredPosition = z.infer<typeof position>\n\nexport interface Point {\n x: number\n y: number\n}\n\nexport interface Position {\n x: number\n y: number\n}\n\nexpectTypesMatch<Point, InferredPoint>(true)\nexpectTypesMatch<Position, InferredPosition>(true)\n","import type { TypeEqual } from \"ts-expect\"\n\ntype IsNever<T> = [T] extends [never] ? true : false\n\ntype GetMismatchedProps<T1, T2> = {\n [K in keyof T1 & keyof T2]: T1[K] extends T2[K]\n ? T2[K] extends T1[K]\n ? never\n : K\n : K\n}[keyof T1 & keyof T2]\n\nexport const expectTypesMatch = <\n const T1,\n const T2,\n T3 = Exclude<keyof T1, keyof T2>,\n T4 = Exclude<keyof T2, keyof T1>,\n T5 = GetMismatchedProps<T1, T2>,\n>(\n shouldBe: IsNever<T3> extends true\n ? IsNever<T4> extends true\n ? IsNever<T5> extends true\n ? TypeEqual<T1, T2>\n : `mismatched prop types: ${T5 extends string ? T5 : \"\"}`\n : `extra props ${T4 extends string ? T4 : \"\"}`\n : `missing props ${T3 extends string ? T3 : \"\"}`,\n): void => {}\n\n// ------ TESTS -------\n\nexpectTypesMatch<\n {\n a: number\n },\n {\n a: number\n b: number\n }\n>(\"extra props b\")\n\nexpectTypesMatch<\n {\n a: number\n b: number\n },\n {\n a: number\n }\n>(\"missing props b\")\n\nexpectTypesMatch<\n {\n a: number\n },\n {\n a: number\n }\n>(true)\n\nexpectTypesMatch<\n {\n a: number\n },\n {\n a: string\n }\n>(\"mismatched prop types: a\")\n\n// ------ String Union Matching -------\n\nexport type ExpectStringUnionsMatch<\n T1 extends string,\n T2 extends string,\n Diff1 = Exclude<T1, T2>,\n Diff2 = Exclude<T2, T1>,\n> = IsNever<Diff1> extends true\n ? IsNever<Diff2> extends true\n ? true // Unions are identical\n : `T2 has extra: \"${Diff2 extends string ? Diff2 : \"\"}\"` // T2 has elements not in T1\n : IsNever<Diff2> extends true\n ? `T1 has extra: \"${Diff1 extends string ? Diff1 : \"\"}\"` // T1 has elements not in T2\n : `T1 has extra: \"${Diff1 extends string\n ? Diff1\n : \"\"}\", T2 has extra: \"${Diff2 extends string ? Diff2 : \"\"}\"` // Both have differences\n\nexport const expectStringUnionsMatch = <\n const T1 extends string,\n const T2 extends string,\n ShouldBeTrue = ExpectStringUnionsMatch<T1, T2>,\n>(\n shouldBe: ShouldBeTrue,\n): void => {}\n\n// ------ TESTS -------\n\ntype TestUnion1 = \"a\" | \"b\" | \"c\"\ntype TestUnion2 = \"a\" | \"b\" | \"c\"\ntype TestUnion3 = \"a\" | \"b\" | \"d\"\ntype TestUnion4 = \"a\" | \"b\"\n\nexpectStringUnionsMatch<TestUnion1, TestUnion2>(true)\nexpectStringUnionsMatch<TestUnion1, TestUnion3>(\n 'T1 has extra: \"c\", T2 has extra: \"d\"',\n)\nexpectStringUnionsMatch<TestUnion1, TestUnion4>('T1 has extra: \"c\"')\nexpectStringUnionsMatch<TestUnion4, TestUnion1>('T2 has extra: \"c\"')\nexpectStringUnionsMatch<TestUnion3, TestUnion1>(\n 'T1 has extra: \"d\", T2 has extra: \"c\"',\n)\n\n// Example of using @ts-expect-error for expected failures\n// @ts-expect-error Type '\"T2 has extra: \\\"d\\\"\"' is not assignable to type 'true'.\nexpectStringUnionsMatch<TestUnion1, TestUnion3>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const point3 = z.object({\n x: distance,\n y: distance,\n z: distance,\n})\n\nexport const position3 = point3\n\ntype InferredPoint3 = z.infer<typeof point3>\n\nexport interface Point3 {\n x: number\n y: number\n z: number\n}\n\nexpectTypesMatch<Point3, InferredPoint3>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const size = z.object({\n width: z.number(),\n height: z.number(),\n})\n\nexport type SizeInput = z.input<typeof size>\ntype InferredSize = z.infer<typeof size>\n\nexport interface Size {\n width: number\n height: number\n}\n\nexpectTypesMatch<Size, InferredSize>(true)\n","import { z } from \"zod\"\n\n// Generates a random string ID of specified length using alphanumeric characters\nconst randomId = (length: number): string => {\n const chars = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\"\n return Array.from(\n { length },\n () => chars[Math.floor(Math.random() * chars.length)],\n ).join(\"\")\n}\n/**\n * Use this for primary keys for any circuit element\n */\nexport const getZodPrefixedIdWithDefault = (prefix: string) => {\n return z\n .string()\n .optional()\n .default(() => `${prefix}_${randomId(10)}`)\n}\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport type NinePointAnchor =\n | \"top_left\"\n | \"top_center\"\n | \"top_right\"\n | \"center_left\"\n | \"center\"\n | \"center_right\"\n | \"bottom_left\"\n | \"bottom_center\"\n | \"bottom_right\"\n\nexport const ninePointAnchor = z.enum([\n \"top_left\",\n \"top_center\",\n \"top_right\",\n \"center_left\",\n \"center\",\n \"center_right\",\n \"bottom_left\",\n \"bottom_center\",\n \"bottom_right\",\n])\n\ntype InferredNinePointAnchor = z.infer<typeof ninePointAnchor>\n\nexpectTypesMatch<NinePointAnchor, InferredNinePointAnchor>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport type PcbRenderLayer =\n | \"top_silkscreen\"\n | \"bottom_silkscreen\"\n | \"top_copper\"\n | \"bottom_copper\"\n | \"top_soldermask\"\n | \"bottom_soldermask\"\n | \"top_fabrication_note\"\n | \"bottom_fabrication_note\"\n | \"top_user_note\"\n | \"bottom_user_note\"\n | \"top_courtyard\"\n | \"bottom_courtyard\"\n | \"inner1_copper\"\n | \"inner2_copper\"\n | \"inner3_copper\"\n | \"inner4_copper\"\n | \"inner5_copper\"\n | \"inner6_copper\"\n | \"edge_cuts\"\n | \"drill\"\n\nexport const pcbRenderLayer = z.enum([\n \"top_silkscreen\",\n \"bottom_silkscreen\",\n \"top_copper\",\n \"bottom_copper\",\n \"top_soldermask\",\n \"bottom_soldermask\",\n \"top_fabrication_note\",\n \"bottom_fabrication_note\",\n \"top_user_note\",\n \"bottom_user_note\",\n \"top_courtyard\",\n \"bottom_courtyard\",\n \"inner1_copper\",\n \"inner2_copper\",\n \"inner3_copper\",\n \"inner4_copper\",\n \"inner5_copper\",\n \"inner6_copper\",\n \"edge_cuts\",\n \"drill\",\n])\n\ntype InferredPcbRenderLayer = z.infer<typeof pcbRenderLayer>\n\nexpectTypesMatch<PcbRenderLayer, InferredPcbRenderLayer>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const asset = z.object({\n project_relative_path: z.string(),\n url: z.string(),\n mimetype: z.string(),\n})\n\nexport type AssetInput = z.input<typeof asset>\nexport type Asset = z.infer<typeof asset>\n\nexpectTypesMatch<Asset, AssetInput>(true)\n","import { z } from \"zod\"\nimport { point } from \"./point\"\nimport { point3 } from \"./point3\"\nimport { distance, rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface KicadAt {\n x: number\n y: number\n rotation?: number\n}\n\nexport const kicadAt = point.extend({\n rotation: rotation.optional(),\n})\n\ntype InferredKicadAt = z.infer<typeof kicadAt>\nexpectTypesMatch<KicadAt, InferredKicadAt>(true)\n\nexport interface KicadFont {\n size?: { x: number; y: number }\n thickness?: number\n}\n\nexport const kicadFont = z.object({\n size: point.optional(),\n thickness: distance.optional(),\n})\n\ntype InferredKicadFont = z.infer<typeof kicadFont>\nexpectTypesMatch<KicadFont, InferredKicadFont>(true)\n\nexport interface KicadEffects {\n font?: KicadFont\n}\n\nexport const kicadEffects = z.object({\n font: kicadFont.optional(),\n})\n\ntype InferredKicadEffects = z.infer<typeof kicadEffects>\nexpectTypesMatch<KicadEffects, InferredKicadEffects>(true)\n\nexport interface KicadProperty {\n value: string\n at?: KicadAt\n layer?: string\n uuid?: string\n hide?: boolean\n effects?: KicadEffects\n}\n\nexport const kicadProperty = z.object({\n value: z.string(),\n at: kicadAt.optional(),\n layer: z.string().optional(),\n uuid: z.string().optional(),\n hide: z.boolean().optional(),\n effects: kicadEffects.optional(),\n})\n\ntype InferredKicadProperty = z.infer<typeof kicadProperty>\nexpectTypesMatch<KicadProperty, InferredKicadProperty>(true)\n\nexport interface KicadFootprintProperties {\n Reference?: KicadProperty\n Value?: KicadProperty\n Datasheet?: KicadProperty\n Description?: KicadProperty\n}\n\nexport const kicadFootprintProperties = z.object({\n Reference: kicadProperty.optional(),\n Value: kicadProperty.optional(),\n Datasheet: kicadProperty.optional(),\n Description: kicadProperty.optional(),\n})\n\ntype InferredKicadFootprintProperties = z.infer<typeof kicadFootprintProperties>\nexpectTypesMatch<KicadFootprintProperties, InferredKicadFootprintProperties>(\n true,\n)\n\nexport interface KicadFootprintAttributes {\n through_hole?: boolean\n smd?: boolean\n exclude_from_pos_files?: boolean\n exclude_from_bom?: boolean\n}\n\nexport const kicadFootprintAttributes = z.object({\n through_hole: z.boolean().optional(),\n smd: z.boolean().optional(),\n exclude_from_pos_files: z.boolean().optional(),\n exclude_from_bom: z.boolean().optional(),\n})\n\ntype InferredKicadFootprintAttributes = z.infer<typeof kicadFootprintAttributes>\nexpectTypesMatch<KicadFootprintAttributes, InferredKicadFootprintAttributes>(\n true,\n)\n\nexport interface KicadFootprintPad {\n name: string\n type: string\n shape?: string\n at?: KicadAt\n size?: { x: number; y: number }\n drill?: number\n layers?: string[]\n removeUnusedLayers?: boolean\n uuid?: string\n}\n\nexport const kicadFootprintPad = z.object({\n name: z.string(),\n type: z.string(),\n shape: z.string().optional(),\n at: kicadAt.optional(),\n size: point.optional(),\n drill: distance.optional(),\n layers: z.array(z.string()).optional(),\n removeUnusedLayers: z.boolean().optional(),\n uuid: z.string().optional(),\n})\n\ntype InferredKicadFootprintPad = z.infer<typeof kicadFootprintPad>\nexpectTypesMatch<KicadFootprintPad, InferredKicadFootprintPad>(true)\n\nexport interface KicadFootprintModel {\n path: string\n offset?: { x: number; y: number; z: number }\n scale?: { x: number; y: number; z: number }\n rotate?: { x: number; y: number; z: number }\n}\n\nexport const kicadFootprintModel = z.object({\n path: z.string(),\n offset: point3.optional(),\n scale: point3.optional(),\n rotate: point3.optional(),\n})\n\ntype InferredKicadFootprintModel = z.infer<typeof kicadFootprintModel>\nexpectTypesMatch<KicadFootprintModel, InferredKicadFootprintModel>(true)\n\nexport interface KicadFootprintMetadata {\n footprintName?: string\n version?: number | string\n generator?: string\n generatorVersion?: number | string\n layer?: string\n properties?: KicadFootprintProperties\n attributes?: KicadFootprintAttributes\n pads?: KicadFootprintPad[]\n embeddedFonts?: boolean\n model?: KicadFootprintModel\n}\n\nexport const kicadFootprintMetadata = z.object({\n footprintName: z.string().optional(),\n version: z.union([z.number(), z.string()]).optional(),\n generator: z.string().optional(),\n generatorVersion: z.union([z.number(), z.string()]).optional(),\n layer: z.string().optional(),\n properties: kicadFootprintProperties.optional(),\n attributes: kicadFootprintAttributes.optional(),\n pads: z.array(kicadFootprintPad).optional(),\n embeddedFonts: z.boolean().optional(),\n model: kicadFootprintModel.optional(),\n})\n\ntype InferredKicadFootprintMetadata = z.infer<typeof kicadFootprintMetadata>\nexpectTypesMatch<KicadFootprintMetadata, InferredKicadFootprintMetadata>(true)\n","import { z } from \"zod\"\nimport { distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n kicadAt,\n kicadFont,\n type KicadAt,\n type KicadFont,\n} from \"./kicadFootprintMetadata\"\n\nexport interface KicadSymbolPinNumbers {\n hide?: boolean\n}\n\nexport const kicadSymbolPinNumbers = z.object({\n hide: z.boolean().optional(),\n})\n\ntype InferredKicadSymbolPinNumbers = z.infer<typeof kicadSymbolPinNumbers>\nexpectTypesMatch<KicadSymbolPinNumbers, InferredKicadSymbolPinNumbers>(true)\n\nexport interface KicadSymbolPinNames {\n offset?: number\n hide?: boolean\n}\n\nexport const kicadSymbolPinNames = z.object({\n offset: distance.optional(),\n hide: z.boolean().optional(),\n})\n\ntype InferredKicadSymbolPinNames = z.infer<typeof kicadSymbolPinNames>\nexpectTypesMatch<KicadSymbolPinNames, InferredKicadSymbolPinNames>(true)\n\nexport interface KicadSymbolEffects {\n font?: KicadFont\n justify?: string | string[]\n hide?: boolean\n}\n\nexport const kicadSymbolEffects = z.object({\n font: kicadFont.optional(),\n justify: z.union([z.string(), z.array(z.string())]).optional(),\n hide: z.boolean().optional(),\n})\n\ntype InferredKicadSymbolEffects = z.infer<typeof kicadSymbolEffects>\nexpectTypesMatch<KicadSymbolEffects, InferredKicadSymbolEffects>(true)\n\nexport interface KicadSymbolProperty {\n value: string\n id?: number | string\n at?: KicadAt\n effects?: KicadSymbolEffects\n}\n\nexport const kicadSymbolProperty = z.object({\n value: z.string(),\n id: z.union([z.number(), z.string()]).optional(),\n at: kicadAt.optional(),\n effects: kicadSymbolEffects.optional(),\n})\n\ntype InferredKicadSymbolProperty = z.infer<typeof kicadSymbolProperty>\nexpectTypesMatch<KicadSymbolProperty, InferredKicadSymbolProperty>(true)\n\nexport interface KicadSymbolProperties {\n Reference?: KicadSymbolProperty\n Value?: KicadSymbolProperty\n Footprint?: KicadSymbolProperty\n Datasheet?: KicadSymbolProperty\n Description?: KicadSymbolProperty\n ki_keywords?: KicadSymbolProperty\n ki_fp_filters?: KicadSymbolProperty\n}\n\nexport const kicadSymbolProperties = z.object({\n Reference: kicadSymbolProperty.optional(),\n Value: kicadSymbolProperty.optional(),\n Footprint: kicadSymbolProperty.optional(),\n Datasheet: kicadSymbolProperty.optional(),\n Description: kicadSymbolProperty.optional(),\n ki_keywords: kicadSymbolProperty.optional(),\n ki_fp_filters: kicadSymbolProperty.optional(),\n})\n\ntype InferredKicadSymbolProperties = z.infer<typeof kicadSymbolProperties>\nexpectTypesMatch<KicadSymbolProperties, InferredKicadSymbolProperties>(true)\n\nexport interface KicadSymbolMetadata {\n symbolName?: string\n extends?: string\n pinNumbers?: KicadSymbolPinNumbers\n pinNames?: KicadSymbolPinNames\n excludeFromSim?: boolean\n inBom?: boolean\n onBoard?: boolean\n properties?: KicadSymbolProperties\n embeddedFonts?: boolean\n}\n\nexport const kicadSymbolMetadata = z.object({\n symbolName: z.string().optional(),\n extends: z.string().optional(),\n pinNumbers: kicadSymbolPinNumbers.optional(),\n pinNames: kicadSymbolPinNames.optional(),\n excludeFromSim: z.boolean().optional(),\n inBom: z.boolean().optional(),\n onBoard: z.boolean().optional(),\n properties: kicadSymbolProperties.optional(),\n embeddedFonts: z.boolean().optional(),\n})\n\ntype InferredKicadSymbolMetadata = z.infer<typeof kicadSymbolMetadata>\nexpectTypesMatch<KicadSymbolMetadata, InferredKicadSymbolMetadata>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const base_circuit_json_error = z.object({\n error_type: z.string(),\n message: z.string(),\n is_fatal: z.boolean().optional(),\n})\n\nexport type BaseCircuitJsonErrorInput = z.input<typeof base_circuit_json_error>\ntype InferredBaseCircuitJsonError = z.infer<typeof base_circuit_json_error>\n\nexport interface BaseCircuitJsonError {\n error_type: string\n message: string\n is_fatal?: boolean\n}\n\nexpectTypesMatch<BaseCircuitJsonError, InferredBaseCircuitJsonError>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { capacitance, distance, voltage } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_capacitor = source_component_base.extend({\n ftype: z.literal(\"simple_capacitor\"),\n capacitance,\n max_voltage_rating: voltage.optional(),\n display_capacitance: z.string().optional(),\n max_decoupling_trace_length: distance.optional(),\n})\n\nexport type SourceSimpleCapacitorInput = z.input<typeof source_simple_capacitor>\ntype InferredSourceSimpleCapacitor = z.infer<typeof source_simple_capacitor>\n\n/**\n * Defines a simple capacitor component\n */\nexport interface SourceSimpleCapacitor extends SourceComponentBase {\n ftype: \"simple_capacitor\"\n capacitance: number\n max_voltage_rating?: number\n display_capacitance?: string\n max_decoupling_trace_length?: number\n}\n\nexpectTypesMatch<SourceSimpleCapacitor, InferredSourceSimpleCapacitor>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const supplier_name = z.enum([\n \"jlcpcb\",\n \"macrofab\",\n \"pcbway\",\n \"digikey\",\n \"mouser\",\n \"lcsc\",\n])\n\ntype InferredSupplierName = z.infer<typeof supplier_name>\n\nexport type SupplierName =\n | \"jlcpcb\"\n | \"macrofab\"\n | \"pcbway\"\n | \"digikey\"\n | \"mouser\"\n | \"lcsc\"\n\nexpectTypesMatch<SupplierName, InferredSupplierName>(true)\n","import {\n supplier_name,\n type SupplierName,\n} from \"src/pcb/properties/supplier_name\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\n\nexport interface SourceComponentBase {\n type: \"source_component\"\n ftype?: string\n source_component_id: string\n name: string\n manufacturer_part_number?: string\n supplier_part_numbers?: Partial<Record<SupplierName, string[]>>\n display_value?: string\n display_name?: string\n are_pins_interchangeable?: boolean\n internally_connected_source_port_ids?: string[][]\n source_group_id?: string\n subcircuit_id?: string\n}\n\nexport const source_component_base = z.object({\n type: z.literal(\"source_component\"),\n ftype: z.string().optional(),\n source_component_id: z.string(),\n name: z.string(),\n manufacturer_part_number: z.string().optional(),\n supplier_part_numbers: z\n .record(supplier_name, z.array(z.string()))\n .optional(),\n display_value: z.string().optional(),\n display_name: z.string().optional(),\n are_pins_interchangeable: z.boolean().optional(),\n internally_connected_source_port_ids: z.array(z.array(z.string())).optional(),\n source_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n})\n\ntype InferredSourceComponentBase = z.infer<typeof source_component_base>\n\nexpectTypesMatch<SourceComponentBase, InferredSourceComponentBase>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { resistance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_resistor = source_component_base.extend({\n ftype: z.literal(\"simple_resistor\"),\n resistance,\n display_resistance: z.string().optional(),\n})\n\nexport type SourceSimpleResistorInput = z.input<typeof source_simple_resistor>\ntype InferredSourceSimpleResistor = z.infer<typeof source_simple_resistor>\n\n/**\n * Defines a simple resistor component\n */\nexport interface SourceSimpleResistor extends SourceComponentBase {\n ftype: \"simple_resistor\"\n resistance: number\n display_resistance?: string\n}\n\nexpectTypesMatch<SourceSimpleResistor, InferredSourceSimpleResistor>(true)\n","import {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_diode = source_component_base.extend({\n ftype: z.literal(\"simple_diode\"),\n})\n\nexport type SourceSimpleDiodeInput = z.input<typeof source_simple_diode>\ntype InferredSourceSimpleDiode = z.infer<typeof source_simple_diode>\n\n/**\n * Defines a simple diode component\n */\nexport interface SourceSimpleDiode extends SourceComponentBase {\n ftype: \"simple_diode\"\n}\n\nexpectTypesMatch<SourceSimpleDiode, InferredSourceSimpleDiode>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_fiducial = source_component_base.extend({\n ftype: z.literal(\"simple_fiducial\"),\n})\n\nexport type SourceSimpleFiducialInput = z.input<typeof source_simple_fiducial>\ntype InferredSourceSimpleFiducial = z.infer<typeof source_simple_fiducial>\n\n/**\n * Defines a simple fiducial component\n */\nexport interface SourceSimpleFiducial extends SourceComponentBase {\n ftype: \"simple_fiducial\"\n}\n\nexpectTypesMatch<SourceSimpleFiducial, InferredSourceSimpleFiducial>(true)\n","import {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n source_simple_diode,\n type SourceSimpleDiode,\n} from \"./source_simple_diode\"\n\nexport const source_simple_led = source_simple_diode.extend({\n ftype: z.literal(\"simple_led\"),\n color: z.string().optional(),\n wavelength: z.string().optional(),\n})\n\nexport type SourceSimpleLedInput = z.input<typeof source_simple_led>\ntype InferredSourceSimpleLed = z.infer<typeof source_simple_led>\n\n/**\n * Defines a simple led component\n */\nexport interface SourceSimpleLed extends Omit<SourceSimpleDiode, \"ftype\"> {\n ftype: \"simple_led\"\n color?: string\n wavelength?: string\n}\n\nexpectTypesMatch<SourceSimpleLed, InferredSourceSimpleLed>(true)\n","import {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_ground = source_component_base.extend({\n ftype: z.literal(\"simple_ground\"),\n})\n\nexport type SourceSimpleGroundInput = z.input<typeof source_simple_ground>\ntype InferredSourceSimpleGround = z.infer<typeof source_simple_ground>\n\n/**\n * Defines a simple ground component\n */\nexport interface SourceSimpleGround extends SourceComponentBase {\n ftype: \"simple_ground\"\n}\n\nexpectTypesMatch<SourceSimpleGround, InferredSourceSimpleGround>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_chip = source_component_base.extend({\n ftype: z.literal(\"simple_chip\"),\n})\n\nexport type SourceSimpleChipInput = z.input<typeof source_simple_chip>\ntype InferredSourceSimpleChip = z.infer<typeof source_simple_chip>\n\n/**\n * Defines a simple integrated circuit component\n */\nexport interface SourceSimpleChip extends SourceComponentBase {\n ftype: \"simple_chip\"\n}\n\nexpectTypesMatch<SourceSimpleChip, InferredSourceSimpleChip>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { voltage } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_power_source = source_component_base.extend({\n ftype: z.literal(\"simple_power_source\"),\n voltage,\n})\n\nexport type SourceSimplePowerSourceInput = z.input<\n typeof source_simple_power_source\n>\ntype InferredSourceSimplePowerSource = z.infer<\n typeof source_simple_power_source\n>\n\n/**\n * Defines a simple power source component\n */\nexport interface SourceSimplePowerSource extends SourceComponentBase {\n ftype: \"simple_power_source\"\n voltage: number\n}\n\nexpectTypesMatch<SourceSimplePowerSource, InferredSourceSimplePowerSource>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { current, frequency } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_current_source = source_component_base.extend({\n ftype: z.literal(\"simple_current_source\"),\n current,\n frequency: frequency.optional(),\n peak_to_peak_current: current.optional(),\n wave_shape: z\n .enum([\"sine\", \"square\", \"triangle\", \"sawtooth\", \"dc\"])\n .optional()\n .default(\"dc\"),\n phase: z.number().optional(),\n duty_cycle: z.number().min(0).max(1).optional(),\n})\n\nexport type SourceSimpleCurrentSourceInput = z.input<\n typeof source_simple_current_source\n>\ntype InferredSourceSimpleCurrentSource = z.infer<\n typeof source_simple_current_source\n>\n\n/**\n * Defines a simple current source component\n */\nexport interface SourceSimpleCurrentSource extends SourceComponentBase {\n ftype: \"simple_current_source\"\n current: number\n frequency?: number\n peak_to_peak_current?: number\n wave_shape: \"sine\" | \"square\" | \"triangle\" | \"sawtooth\" | \"dc\"\n phase?: number\n duty_cycle?: number\n}\n\nexpectTypesMatch<SourceSimpleCurrentSource, InferredSourceSimpleCurrentSource>(\n true,\n)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_pin_attributes = z.object({\n must_be_connected: z.boolean().optional(),\n provides_power: z.boolean().optional(),\n requires_power: z.boolean().optional(),\n provides_ground: z.boolean().optional(),\n requires_ground: z.boolean().optional(),\n provides_voltage: z.union([z.string(), z.number()]).optional(),\n requires_voltage: z.union([z.string(), z.number()]).optional(),\n do_not_connect: z.boolean().optional(),\n include_in_board_pinout: z.boolean().optional(),\n can_use_internal_pullup: z.boolean().optional(),\n is_using_internal_pullup: z.boolean().optional(),\n needs_external_pullup: z.boolean().optional(),\n can_use_internal_pulldown: z.boolean().optional(),\n is_using_internal_pulldown: z.boolean().optional(),\n needs_external_pulldown: z.boolean().optional(),\n can_use_open_drain: z.boolean().optional(),\n is_using_open_drain: z.boolean().optional(),\n can_use_push_pull: z.boolean().optional(),\n is_using_push_pull: z.boolean().optional(),\n should_have_decoupling_capacitor: z.boolean().optional(),\n recommended_decoupling_capacitor_capacitance: z\n .union([z.string(), z.number()])\n .optional(),\n is_configured_for_i2c_sda: z.boolean().optional(),\n is_configured_for_i2c_scl: z.boolean().optional(),\n is_configured_for_spi_mosi: z.boolean().optional(),\n is_configured_for_spi_miso: z.boolean().optional(),\n is_configured_for_spi_sck: z.boolean().optional(),\n is_configured_for_spi_cs: z.boolean().optional(),\n is_configured_for_uart_tx: z.boolean().optional(),\n is_configured_for_uart_rx: z.boolean().optional(),\n supports_i2c_sda: z.boolean().optional(),\n supports_i2c_scl: z.boolean().optional(),\n supports_spi_mosi: z.boolean().optional(),\n supports_spi_miso: z.boolean().optional(),\n supports_spi_sck: z.boolean().optional(),\n supports_spi_cs: z.boolean().optional(),\n supports_uart_tx: z.boolean().optional(),\n supports_uart_rx: z.boolean().optional(),\n})\n\ntype InferredSourcePinAttributes = z.infer<typeof source_pin_attributes>\n\nexport interface SourcePinAttributes {\n must_be_connected?: boolean\n provides_power?: boolean\n requires_power?: boolean\n provides_ground?: boolean\n requires_ground?: boolean\n provides_voltage?: string | number\n requires_voltage?: string | number\n do_not_connect?: boolean\n include_in_board_pinout?: boolean\n can_use_internal_pullup?: boolean\n is_using_internal_pullup?: boolean\n needs_external_pullup?: boolean\n can_use_internal_pulldown?: boolean\n is_using_internal_pulldown?: boolean\n needs_external_pulldown?: boolean\n can_use_open_drain?: boolean\n is_using_open_drain?: boolean\n can_use_push_pull?: boolean\n is_using_push_pull?: boolean\n should_have_decoupling_capacitor?: boolean\n recommended_decoupling_capacitor_capacitance?: string | number\n is_configured_for_i2c_sda?: boolean\n is_configured_for_i2c_scl?: boolean\n is_configured_for_spi_mosi?: boolean\n is_configured_for_spi_miso?: boolean\n is_configured_for_spi_sck?: boolean\n is_configured_for_spi_cs?: boolean\n is_configured_for_uart_tx?: boolean\n is_configured_for_uart_rx?: boolean\n supports_i2c_sda?: boolean\n supports_i2c_scl?: boolean\n supports_spi_mosi?: boolean\n supports_spi_miso?: boolean\n supports_spi_sck?: boolean\n supports_spi_cs?: boolean\n supports_uart_tx?: boolean\n supports_uart_rx?: boolean\n}\n\nexpectTypesMatch<SourcePinAttributes, InferredSourcePinAttributes>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n source_simple_resistor,\n type SourceSimpleResistor,\n} from \"./source_simple_resistor\"\nimport {\n source_simple_capacitor,\n type SourceSimpleCapacitor,\n} from \"./source_simple_capacitor\"\nimport { source_simple_fuse, type SourceSimpleFuse } from \"./source_simple_fuse\"\nimport {\n source_simple_diode,\n type SourceSimpleDiode,\n} from \"./source_simple_diode\"\nimport {\n source_simple_fiducial,\n type SourceSimpleFiducial,\n} from \"./source_simple_fiducial\"\nimport { source_simple_led, type SourceSimpleLed } from \"./source_simple_led\"\nimport {\n source_simple_ground,\n type SourceSimpleGround,\n} from \"./source_simple_ground\"\nimport { source_simple_chip, type SourceSimpleChip } from \"./source_simple_chip\"\nimport {\n source_simple_power_source,\n type SourceSimplePowerSource,\n} from \"./source_simple_power_source\"\nimport {\n source_simple_current_source,\n type SourceSimpleCurrentSource,\n} from \"./source_simple_current_source\"\nimport {\n source_simple_battery,\n type SourceSimpleBattery,\n} from \"./source_simple_battery\"\nimport {\n source_simple_inductor,\n type SourceSimpleInductor,\n} from \"./source_simple_inductor\"\nimport {\n source_simple_push_button,\n type SourceSimplePushButton,\n} from \"./source_simple_push_button\"\nimport {\n source_simple_potentiometer,\n type SourceSimplePotentiometer,\n} from \"./source_simple_potentiometer\"\nimport {\n source_simple_crystal,\n type SourceSimpleCrystal,\n} from \"./source_simple_crystal\"\nimport {\n source_simple_pin_header,\n type SourceSimplePinHeader,\n} from \"./source_simple_pin_header\"\nimport {\n source_simple_connector,\n type SourceSimpleConnector,\n} from \"./source_simple_connector\"\nimport {\n source_simple_pinout,\n type SourceSimplePinout,\n} from \"./source_simple_pinout\"\nimport {\n source_simple_resonator,\n type SourceSimpleResonator,\n} from \"./source_simple_resonator\"\nimport {\n source_simple_transistor,\n type SourceSimpleTransistor,\n} from \"./source_simple_transistor\"\nimport {\n source_simple_test_point,\n type SourceSimpleTestPoint,\n} from \"./source_simple_test_point\"\nimport {\n source_simple_mosfet,\n type SourceSimpleMosfet,\n} from \"./source_simple_mosfet\"\nimport {\n source_simple_op_amp,\n type SourceSimpleOpAmp,\n} from \"./source_simple_op_amp\"\nimport {\n source_simple_switch,\n type SourceSimpleSwitch,\n} from \"./source_simple_switch\"\nimport {\n source_project_metadata,\n type SourceProjectMetadata,\n} from \"./source_project_metadata\"\nimport {\n source_missing_property_error,\n type SourceMissingPropertyError,\n} from \"./source_missing_property_error\"\nimport {\n source_failed_to_create_component_error,\n type SourceFailedToCreateComponentError,\n} from \"./source_failed_to_create_component_error\"\nimport {\n source_invalid_component_property_error,\n type SourceInvalidComponentPropertyError,\n} from \"./source_invalid_component_property_error\"\nimport {\n source_trace_not_connected_error,\n type SourceTraceNotConnectedError,\n} from \"./source_trace_not_connected_error\"\nimport {\n source_property_ignored_warning,\n type SourcePropertyIgnoredWarning,\n} from \"./source_property_ignored_warning\"\nimport {\n source_pin_missing_trace_warning,\n type SourcePinMissingTraceWarning,\n} from \"./source_pin_missing_trace_warning\"\nimport {\n source_simple_voltage_probe,\n type SourceSimpleVoltageProbe,\n} from \"./source_simple_voltage_probe\"\nimport {\n source_interconnect,\n type SourceInterconnect,\n} from \"./source_interconnect\"\nimport {\n source_i2c_misconfigured_error,\n type SourceI2cMisconfiguredError,\n} from \"./source_i2c_misconfigured_error\"\nimport {\n source_simple_voltage_source,\n type SourceSimpleVoltageSource,\n} from \"./source_simple_voltage_source\"\n\nexport const any_source_component = z.union([\n source_simple_resistor,\n source_simple_capacitor,\n source_simple_diode,\n source_simple_fiducial,\n source_simple_led,\n source_simple_ground,\n source_simple_chip,\n source_simple_power_source,\n source_simple_current_source,\n source_simple_battery,\n source_simple_inductor,\n source_simple_push_button,\n source_simple_potentiometer,\n source_simple_crystal,\n source_simple_pin_header,\n source_simple_connector,\n source_simple_pinout,\n source_simple_resonator,\n source_simple_switch,\n source_simple_transistor,\n source_simple_test_point,\n source_simple_mosfet,\n source_simple_op_amp,\n source_simple_fuse,\n source_simple_voltage_probe,\n source_interconnect,\n source_simple_voltage_source,\n source_project_metadata,\n source_missing_property_error,\n source_invalid_component_property_error,\n source_failed_to_create_component_error,\n source_trace_not_connected_error,\n source_property_ignored_warning,\n source_pin_missing_trace_warning,\n source_i2c_misconfigured_error,\n])\n\n/**\n * Deprecated: use `AnySourceElement` instead\n */\nexport type AnySourceComponent = z.infer<typeof any_source_component>\n\nexport type AnySourceElement =\n | SourceSimpleResistor\n | SourceSimpleCapacitor\n | SourceSimpleDiode\n | SourceSimpleFiducial\n | SourceSimpleLed\n | SourceSimpleGround\n | SourceSimpleChip\n | SourceSimplePowerSource\n | SourceSimpleCurrentSource\n | SourceSimpleBattery\n | SourceSimpleInductor\n | SourceSimplePushButton\n | SourceSimplePotentiometer\n | SourceSimpleCrystal\n | SourceSimplePinHeader\n | SourceSimpleConnector\n | SourceSimplePinout\n | SourceSimpleResonator\n | SourceSimpleSwitch\n | SourceSimpleTransistor\n | SourceSimpleTestPoint\n | SourceSimpleMosfet\n | SourceSimpleFuse\n | SourceSimpleOpAmp\n | SourceSimpleVoltageProbe\n | SourceSimpleVoltageSource\n | SourceInterconnect\n | SourceProjectMetadata\n | SourceMissingPropertyError\n | SourceInvalidComponentPropertyError\n | SourceFailedToCreateComponentError\n | SourceTraceNotConnectedError\n | SourcePropertyIgnoredWarning\n | SourcePinMissingTraceWarning\n | SourceI2cMisconfiguredError\n\nexpectTypesMatch<AnySourceElement, AnySourceComponent>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"./base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_fuse = source_component_base.extend({\n ftype: z.literal(\"simple_fuse\"),\n\n current_rating_amps: z\n .number()\n .describe(\"Nominal current in amps the fuse is rated for\"),\n\n voltage_rating_volts: z\n .number()\n .describe(\"Voltage rating in volts, e.g. ±5V would be 5\"),\n})\n\nexport interface SourceSimpleFuse extends SourceComponentBase {\n ftype: \"simple_fuse\"\n current_rating_amps: number\n voltage_rating_volts: number\n}\n\nexport type SourceSimpleFuseInput = z.input<typeof source_simple_fuse>\ntype InferredSourceSimpleFuse = z.infer<typeof source_simple_fuse>\n\nexpectTypesMatch<SourceSimpleFuse, InferredSourceSimpleFuse>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { battery_capacity } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_battery = source_component_base.extend({\n ftype: z.literal(\"simple_battery\"),\n capacity: battery_capacity,\n})\n\nexport type SourceSimpleBatteryInput = z.input<typeof source_simple_battery>\ntype InferredSourceSimpleBattery = z.infer<typeof source_simple_battery>\n\n/**\n * Defines a simple battery component\n */\nexport interface SourceSimpleBattery extends SourceComponentBase {\n ftype: \"simple_battery\"\n capacity: number\n}\n\nexpectTypesMatch<SourceSimpleBattery, InferredSourceSimpleBattery>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { inductance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_inductor = source_component_base.extend({\n ftype: z.literal(\"simple_inductor\"),\n inductance,\n max_current_rating: z.number().optional(),\n})\n\nexport type SourceSimpleInductorInput = z.input<typeof source_simple_inductor>\ntype InferredSourceSimpleInductor = z.infer<typeof source_simple_inductor>\n\n/**\n * Defines a simple inductor component\n */\nexport interface SourceSimpleInductor extends SourceComponentBase {\n ftype: \"simple_inductor\"\n inductance: number\n max_current_rating?: number\n}\n\nexpectTypesMatch<SourceSimpleInductor, InferredSourceSimpleInductor>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_push_button = source_component_base.extend({\n ftype: z.literal(\"simple_push_button\"),\n})\n\nexport type SourceSimplePushButtonInput = z.input<\n typeof source_simple_push_button\n>\ntype InferredSourceSimplePushButton = z.infer<typeof source_simple_push_button>\n\n/**\n * Defines a simple push button component\n */\nexport interface SourceSimplePushButton extends SourceComponentBase {\n ftype: \"simple_push_button\"\n}\n\nexpectTypesMatch<SourceSimplePushButton, InferredSourceSimplePushButton>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { resistance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_potentiometer = source_component_base.extend({\n ftype: z.literal(\"simple_potentiometer\"),\n max_resistance: resistance,\n display_max_resistance: z.string().optional(),\n})\n\nexport type SourceSimplePotentiometerInput = z.input<\n typeof source_simple_potentiometer\n>\ntype InferredSourceSimplePotentiometer = z.infer<\n typeof source_simple_potentiometer\n>\n\nexport interface SourceSimplePotentiometer extends SourceComponentBase {\n ftype: \"simple_potentiometer\"\n max_resistance: number\n display_max_resistance?: string\n}\n\nexpectTypesMatch<SourceSimplePotentiometer, InferredSourceSimplePotentiometer>(\n true,\n)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_crystal = source_component_base.extend({\n ftype: z.literal(\"simple_crystal\"),\n frequency: z.number().describe(\"Frequency in Hz\"),\n load_capacitance: z.number().optional().describe(\"Load capacitance in pF\"),\n pin_variant: z.enum([\"two_pin\", \"four_pin\"]).optional(),\n})\n\nexport type SourceSimpleCrystalInput = z.input<typeof source_simple_crystal>\ntype InferredSourceSimpleCrystal = z.infer<typeof source_simple_crystal>\n\n/**\n * Defines a simple crystal oscillator component\n */\nexport interface SourceSimpleCrystal extends SourceComponentBase {\n ftype: \"simple_crystal\"\n frequency: number\n load_capacitance?: number\n pin_variant?: \"two_pin\" | \"four_pin\"\n}\n\nexpectTypesMatch<SourceSimpleCrystal, InferredSourceSimpleCrystal>(true)\n","import {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_pin_header = source_component_base.extend({\n ftype: z.literal(\"simple_pin_header\"),\n pin_count: z.number(),\n gender: z.enum([\"male\", \"female\"]).optional().default(\"male\"),\n})\n\nexport type SourceSimplePinHeaderInput = z.input<\n typeof source_simple_pin_header\n>\ntype InferredSourceSimplePinHeader = z.infer<typeof source_simple_pin_header>\n\nexport interface SourceSimplePinHeader extends SourceComponentBase {\n ftype: \"simple_pin_header\"\n pin_count: number\n gender: \"male\" | \"female\"\n}\n\nexpectTypesMatch<SourceSimplePinHeader, InferredSourceSimplePinHeader>(true)\n","import {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_connector = source_component_base.extend({\n ftype: z.literal(\"simple_connector\"),\n standard: z.enum([\"usb_c\", \"m2\"]).optional(),\n})\n\nexport type SourceSimpleConnectorInput = z.input<typeof source_simple_connector>\ntype InferredSourceSimpleConnector = z.infer<typeof source_simple_connector>\n\n/**\n * Defines a simple connector component\n */\nexport interface SourceSimpleConnector extends SourceComponentBase {\n ftype: \"simple_connector\"\n standard?: \"usb_c\" | \"m2\"\n}\n\nexpectTypesMatch<SourceSimpleConnector, InferredSourceSimpleConnector>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_pinout = source_component_base.extend({\n ftype: z.literal(\"simple_pinout\"),\n})\n\nexport type SourceSimplePinoutInput = z.input<typeof source_simple_pinout>\ntype InferredSourceSimplePinout = z.infer<typeof source_simple_pinout>\n\n/**\n * Defines a simple pinout component\n */\nexport interface SourceSimplePinout extends SourceComponentBase {\n ftype: \"simple_pinout\"\n}\n\nexpectTypesMatch<SourceSimplePinout, InferredSourceSimplePinout>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { capacitance, resistance, frequency } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_resonator = source_component_base.extend({\n ftype: z.literal(\"simple_resonator\"),\n load_capacitance: capacitance,\n equivalent_series_resistance: resistance.optional(),\n frequency: frequency,\n})\n\nexport type SourceSimpleResonatorInput = z.input<typeof source_simple_resonator>\ntype InferredSourceSimpleResonator = z.infer<typeof source_simple_resonator>\n\n/**\n * Defines a simple resonator component\n */\nexport interface SourceSimpleResonator extends SourceComponentBase {\n ftype: \"simple_resonator\"\n load_capacitance: number\n equivalent_series_resistance?: number\n frequency: number\n}\n\nexpectTypesMatch<SourceSimpleResonator, InferredSourceSimpleResonator>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_transistor = source_component_base.extend({\n ftype: z.literal(\"simple_transistor\"),\n transistor_type: z.enum([\"npn\", \"pnp\"]),\n})\n\nexport type SourceSimpleTransistorInput = z.input<\n typeof source_simple_transistor\n>\ntype InferredSourceSimpleTransistor = z.infer<typeof source_simple_transistor>\n\n/**\n * Defines a simple transistor component\n * This is a three-pin semiconductor device (emitter, base, collector)\n * Pin configuration is handled by the schematic port system\n */\n\nexport interface SourceSimpleTransistor extends SourceComponentBase {\n ftype: \"simple_transistor\"\n transistor_type: \"npn\" | \"pnp\"\n}\n\nexpectTypesMatch<SourceSimpleTransistor, InferredSourceSimpleTransistor>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_test_point = source_component_base.extend({\n ftype: z.literal(\"simple_test_point\"),\n footprint_variant: z.enum([\"pad\", \"through_hole\"]).optional(),\n pad_shape: z.enum([\"rect\", \"circle\"]).optional(),\n pad_diameter: z.union([z.number(), z.string()]).optional(),\n hole_diameter: z.union([z.number(), z.string()]).optional(),\n width: z.union([z.number(), z.string()]).optional(),\n height: z.union([z.number(), z.string()]).optional(),\n})\n\nexport type SourceSimpleTestPointInput = z.input<\n typeof source_simple_test_point\n>\ntype InferredSourceSimpleTestPoint = z.infer<typeof source_simple_test_point>\n\n/**\n * Defines a simple test point component\n * Can be surface-mount or through-hole.\n * Pad shape and dimensions configurable for different use cases.\n */\nexport interface SourceSimpleTestPoint extends SourceComponentBase {\n ftype: \"simple_test_point\"\n footprint_variant?: \"pad\" | \"through_hole\"\n pad_shape?: \"rect\" | \"circle\"\n pad_diameter?: number | string\n hole_diameter?: number | string\n width?: number | string\n height?: number | string\n}\n\nexpectTypesMatch<SourceSimpleTestPoint, InferredSourceSimpleTestPoint>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_mosfet = source_component_base.extend({\n ftype: z.literal(\"simple_mosfet\"),\n channel_type: z.enum([\"n\", \"p\"]),\n mosfet_mode: z.enum([\"enhancement\", \"depletion\"]),\n})\n\nexport type SourceSimpleMosfetInput = z.input<typeof source_simple_mosfet>\ntype InferredSourceSimpleMosfet = z.infer<typeof source_simple_mosfet>\n\n/**\n * Defines a simple mosfet component\n * This is a three-pin semiconductor device (source, gate, drain)\n * Pin configuration is handled by the schematic port system\n */\n\nexport interface SourceSimpleMosfet extends SourceComponentBase {\n ftype: \"simple_mosfet\"\n channel_type: \"n\" | \"p\"\n mosfet_mode: \"enhancement\" | \"depletion\"\n}\n\nexpectTypesMatch<SourceSimpleMosfet, InferredSourceSimpleMosfet>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_op_amp = source_component_base.extend({\n ftype: z.literal(\"simple_op_amp\"),\n})\n\nexport type SourceSimpleOpAmpInput = z.input<typeof source_simple_op_amp>\ntype InferredSourceSimpleOpAmp = z.infer<typeof source_simple_op_amp>\n\n/**\n * Defines a simple op-amp component\n */\nexport interface SourceSimpleOpAmp extends SourceComponentBase {\n ftype: \"simple_op_amp\"\n}\n\nexpectTypesMatch<SourceSimpleOpAmp, InferredSourceSimpleOpAmp>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_switch = source_component_base.extend({\n ftype: z.literal(\"simple_switch\"),\n})\nexport type SourceSimpleSwitchInput = z.input<typeof source_simple_switch>\ntype InferredSourceSimpleSwitch = z.infer<typeof source_simple_switch>\n\n/**\n * Defines a simple switch component\n */\nexport interface SourceSimpleSwitch extends SourceComponentBase {\n ftype: \"simple_switch\"\n}\n\nexpectTypesMatch<SourceSimpleSwitch, InferredSourceSimpleSwitch>(true)\n","import { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\nimport { timestamp } from \"src/units\"\n\nexport interface SourceProjectMetadata {\n type: \"source_project_metadata\"\n name?: string\n software_used_string?: string\n project_url?: string\n created_at?: string // ISO8601 timestamp\n}\n\nexport const source_project_metadata = z.object({\n type: z.literal(\"source_project_metadata\"),\n name: z.string().optional(),\n software_used_string: z.string().optional(),\n project_url: z.string().optional(),\n created_at: timestamp.optional(),\n})\n\nexport type InferredProjectMetadata = z.infer<typeof source_project_metadata>\nexpectTypesMatch<SourceProjectMetadata, InferredProjectMetadata>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_missing_property_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_missing_property_error\"),\n source_missing_property_error_id: getZodPrefixedIdWithDefault(\n \"source_missing_property_error\",\n ),\n source_component_id: z.string(),\n property_name: z.string(),\n subcircuit_id: z.string().optional(),\n error_type: z\n .literal(\"source_missing_property_error\")\n .default(\"source_missing_property_error\"),\n })\n .describe(\"The source code is missing a property\")\n\nexport type SourceMissingPropertyErrorInput = z.input<\n typeof source_missing_property_error\n>\ntype InferredSourceMissingPropertyError = z.infer<\n typeof source_missing_property_error\n>\n\n/**\n * The source code is missing a property\n */\nexport interface SourceMissingPropertyError extends BaseCircuitJsonError {\n type: \"source_missing_property_error\"\n source_missing_property_error_id: string\n source_component_id: string\n property_name: string\n subcircuit_id?: string\n error_type: \"source_missing_property_error\"\n}\n\nexpectTypesMatch<\n SourceMissingPropertyError,\n InferredSourceMissingPropertyError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_failed_to_create_component_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_failed_to_create_component_error\"),\n source_failed_to_create_component_error_id: getZodPrefixedIdWithDefault(\n \"source_failed_to_create_component_error\",\n ),\n error_type: z\n .literal(\"source_failed_to_create_component_error\")\n .default(\"source_failed_to_create_component_error\"),\n component_name: z.string().optional(),\n subcircuit_id: z.string().optional(),\n parent_source_component_id: z.string().optional(),\n pcb_center: z\n .object({\n x: z.number().optional(),\n y: z.number().optional(),\n })\n .optional(),\n schematic_center: z\n .object({\n x: z.number().optional(),\n y: z.number().optional(),\n })\n .optional(),\n })\n .describe(\"Error emitted when a component fails to be constructed\")\n\nexport type SourceFailedToCreateComponentErrorInput = z.input<\n typeof source_failed_to_create_component_error\n>\ntype InferredSourceFailedToCreateComponentError = z.infer<\n typeof source_failed_to_create_component_error\n>\n\n/**\n * Error emitted when a component fails to be constructed.\n * Contains details about the failure and prevents the component from being rendered.\n */\nexport interface SourceFailedToCreateComponentError\n extends BaseCircuitJsonError {\n type: \"source_failed_to_create_component_error\"\n source_failed_to_create_component_error_id: string\n error_type: \"source_failed_to_create_component_error\"\n component_name?: string\n subcircuit_id?: string\n parent_source_component_id?: string\n pcb_center?: {\n x?: number\n y?: number\n }\n schematic_center?: {\n x?: number\n y?: number\n }\n}\n\nexpectTypesMatch<\n SourceFailedToCreateComponentError,\n InferredSourceFailedToCreateComponentError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_invalid_component_property_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_invalid_component_property_error\"),\n source_invalid_component_property_error_id: getZodPrefixedIdWithDefault(\n \"source_invalid_component_property_error\",\n ),\n source_component_id: z.string(),\n property_name: z.string(),\n property_value: z.unknown().optional(),\n expected_format: z.string().optional(),\n subcircuit_id: z.string().optional(),\n error_type: z\n .literal(\"source_invalid_component_property_error\")\n .default(\"source_invalid_component_property_error\"),\n })\n .describe(\"The source component property is invalid\")\n\nexport type SourceInvalidComponentPropertyErrorInput = z.input<\n typeof source_invalid_component_property_error\n>\ntype InferredSourceInvalidComponentPropertyError = z.infer<\n typeof source_invalid_component_property_error\n>\n\n/**\n * The source component property is invalid\n */\nexport interface SourceInvalidComponentPropertyError\n extends BaseCircuitJsonError {\n type: \"source_invalid_component_property_error\"\n source_invalid_component_property_error_id: string\n source_component_id: string\n property_name: string\n property_value?: unknown\n expected_format?: string\n subcircuit_id?: string\n error_type: \"source_invalid_component_property_error\"\n}\n\nexpectTypesMatch<\n SourceInvalidComponentPropertyError,\n InferredSourceInvalidComponentPropertyError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_trace_not_connected_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_trace_not_connected_error\"),\n source_trace_not_connected_error_id: getZodPrefixedIdWithDefault(\n \"source_trace_not_connected_error\",\n ),\n error_type: z\n .literal(\"source_trace_not_connected_error\")\n .default(\"source_trace_not_connected_error\"),\n subcircuit_id: z.string().optional(),\n source_group_id: z.string().optional(),\n source_trace_id: z.string().optional(),\n connected_source_port_ids: z.array(z.string()).optional(),\n selectors_not_found: z.array(z.string()).optional(),\n })\n .describe(\"Occurs when a source trace selector does not match any ports\")\n\nexport type SourceTraceNotConnectedErrorInput = z.input<\n typeof source_trace_not_connected_error\n>\ntype InferredSourceTraceNotConnectedError = z.infer<\n typeof source_trace_not_connected_error\n>\n\n/**\n * Occurs when a source trace selector does not match any ports\n */\nexport interface SourceTraceNotConnectedError extends BaseCircuitJsonError {\n type: \"source_trace_not_connected_error\"\n source_trace_not_connected_error_id: string\n error_type: \"source_trace_not_connected_error\"\n subcircuit_id?: string\n source_group_id?: string\n source_trace_id?: string\n connected_source_port_ids?: string[]\n selectors_not_found?: string[]\n}\n\nexpectTypesMatch<\n SourceTraceNotConnectedError,\n InferredSourceTraceNotConnectedError\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_property_ignored_warning = z\n .object({\n type: z.literal(\"source_property_ignored_warning\"),\n source_property_ignored_warning_id: getZodPrefixedIdWithDefault(\n \"source_property_ignored_warning\",\n ),\n source_component_id: z.string(),\n property_name: z.string(),\n subcircuit_id: z.string().optional(),\n error_type: z\n .literal(\"source_property_ignored_warning\")\n .default(\"source_property_ignored_warning\"),\n message: z.string(),\n })\n .describe(\"The source property was ignored\")\n\nexport type SourcePropertyIgnoredWarningInput = z.input<\n typeof source_property_ignored_warning\n>\ntype InferredSourcePropertyIgnoredWarning = z.infer<\n typeof source_property_ignored_warning\n>\n\n/**\n * The source property was ignored\n */\nexport interface SourcePropertyIgnoredWarning {\n type: \"source_property_ignored_warning\"\n source_property_ignored_warning_id: string\n source_component_id: string\n property_name: string\n subcircuit_id?: string\n error_type: \"source_property_ignored_warning\"\n message: string\n}\n\nexpectTypesMatch<\n SourcePropertyIgnoredWarning,\n InferredSourcePropertyIgnoredWarning\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_pin_missing_trace_warning = z\n .object({\n type: z.literal(\"source_pin_missing_trace_warning\"),\n source_pin_missing_trace_warning_id: getZodPrefixedIdWithDefault(\n \"source_pin_missing_trace_warning\",\n ),\n warning_type: z\n .literal(\"source_pin_missing_trace_warning\")\n .default(\"source_pin_missing_trace_warning\"),\n message: z.string(),\n source_component_id: z.string(),\n source_port_id: z.string(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Warning emitted when a source component pin is missing a trace connection\",\n )\n\nexport type SourcePinMissingTraceWarningInput = z.input<\n typeof source_pin_missing_trace_warning\n>\ntype InferredSourcePinMissingTraceWarning = z.infer<\n typeof source_pin_missing_trace_warning\n>\n\n/**\n * Warning emitted when a source component pin is missing a trace connection\n */\nexport interface SourcePinMissingTraceWarning {\n type: \"source_pin_missing_trace_warning\"\n source_pin_missing_trace_warning_id: string\n warning_type: \"source_pin_missing_trace_warning\"\n message: string\n source_component_id: string\n source_port_id: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SourcePinMissingTraceWarning,\n InferredSourcePinMissingTraceWarning\n>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_voltage_probe = source_component_base.extend({\n ftype: z.literal(\"simple_voltage_probe\"),\n})\n\nexport type SourceSimpleVoltageProbeInput = z.input<\n typeof source_simple_voltage_probe\n>\ntype InferredSourceSimpleVoltageProbe = z.infer<\n typeof source_simple_voltage_probe\n>\n\n/**\n * Defines a simple voltage probe component for simulation and measurement\n */\nexport interface SourceSimpleVoltageProbe extends SourceComponentBase {\n ftype: \"simple_voltage_probe\"\n}\n\nexpectTypesMatch<SourceSimpleVoltageProbe, InferredSourceSimpleVoltageProbe>(\n true,\n)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_interconnect = source_component_base.extend({\n ftype: z.literal(\"interconnect\"),\n})\n\nexport type SourceInterconnectInput = z.input<typeof source_interconnect>\ntype InferredSourceInterconnect = z.infer<typeof source_interconnect>\n\n/**\n * Defines a generic interconnect component\n */\nexport interface SourceInterconnect extends SourceComponentBase {\n ftype: \"interconnect\"\n}\n\nexpectTypesMatch<SourceInterconnect, InferredSourceInterconnect>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_i2c_misconfigured_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_i2c_misconfigured_error\"),\n source_i2c_misconfigured_error_id: getZodPrefixedIdWithDefault(\n \"source_i2c_misconfigured_error\",\n ),\n error_type: z\n .literal(\"source_i2c_misconfigured_error\")\n .default(\"source_i2c_misconfigured_error\"),\n source_port_ids: z.array(z.string()),\n })\n .describe(\n \"Error emitted when incompatible I2C pins (e.g. SDA and SCL) are connected to the same net\",\n )\n\nexport type SourceI2cMisconfiguredErrorInput = z.input<\n typeof source_i2c_misconfigured_error\n>\ntype InferredSourceI2cMisconfiguredError = z.infer<\n typeof source_i2c_misconfigured_error\n>\n\n/**\n * Error emitted when incompatible I2C pins (e.g. SDA and SCL) are connected to the same net\n */\nexport interface SourceI2cMisconfiguredError extends BaseCircuitJsonError {\n type: \"source_i2c_misconfigured_error\"\n source_i2c_misconfigured_error_id: string\n error_type: \"source_i2c_misconfigured_error\"\n source_port_ids: string[]\n}\n\nexpectTypesMatch<\n SourceI2cMisconfiguredError,\n InferredSourceI2cMisconfiguredError\n>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { voltage, frequency, rotation } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_voltage_source = source_component_base.extend({\n ftype: z.literal(\"simple_voltage_source\"),\n voltage,\n frequency: frequency.optional(),\n peak_to_peak_voltage: voltage.optional(),\n wave_shape: z.enum([\"sinewave\", \"square\", \"triangle\", \"sawtooth\"]).optional(),\n phase: rotation.optional(),\n duty_cycle: z\n .number()\n .optional()\n .describe(\"Duty cycle as a fraction (0 to 1)\"),\n})\n\nexport type SourceSimpleVoltageSourceInput = z.input<\n typeof source_simple_voltage_source\n>\ntype InferredSourceSimpleVoltageSource = z.infer<\n typeof source_simple_voltage_source\n>\n\n/**\n * Defines a simple voltage source component\n */\nexport interface SourceSimpleVoltageSource extends SourceComponentBase {\n ftype: \"simple_voltage_source\"\n voltage: number\n frequency?: number\n peak_to_peak_voltage?: number\n wave_shape?: \"sinewave\" | \"square\" | \"triangle\" | \"sawtooth\"\n phase?: number\n duty_cycle?: number\n}\n\nexpectTypesMatch<SourceSimpleVoltageSource, InferredSourceSimpleVoltageSource>(\n true,\n)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n source_pin_attributes,\n type SourcePinAttributes,\n} from \"./properties/source_pin_attributes\"\n\nexport const source_port = z\n .object({\n type: z.literal(\"source_port\"),\n pin_number: z.number().optional(),\n port_hints: z.array(z.string()).optional(),\n name: z.string(),\n source_port_id: z.string(),\n source_component_id: z.string().optional(),\n source_group_id: z.string().optional(),\n most_frequently_referenced_by_name: z.string().optional(),\n subcircuit_id: z.string().optional(),\n subcircuit_connectivity_map_key: z.string().optional(),\n })\n .merge(source_pin_attributes)\n\nexport type SourcePortInput = z.input<typeof source_port>\ntype InferredSourcePort = z.infer<typeof source_port>\n\n/**\n * Defines a source port that can be connected to other components\n */\nexport interface SourcePort extends SourcePinAttributes {\n type: \"source_port\"\n pin_number?: number\n port_hints?: string[]\n name: string\n source_port_id: string\n source_component_id?: string\n source_group_id?: string\n most_frequently_referenced_by_name?: string\n subcircuit_id?: string\n subcircuit_connectivity_map_key?: string\n}\n\nexpectTypesMatch<SourcePort, InferredSourcePort>(true)\n","import { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\n\nexport interface SourceComponentInternalConnection {\n type: \"source_component_internal_connection\"\n source_component_internal_connection_id: string\n source_component_id: string\n source_port_ids: string[]\n subcircuit_id?: string\n}\n\nexport const source_component_internal_connection = z.object({\n type: z.literal(\"source_component_internal_connection\"),\n source_component_internal_connection_id: z.string(),\n source_component_id: z.string(),\n source_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n})\n\ntype InferredSourceComponentInternalConnection = z.infer<\n typeof source_component_internal_connection\n>\n\nexpectTypesMatch<\n SourceComponentInternalConnection,\n InferredSourceComponentInternalConnection\n>(true)\n","import { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\n\nexport interface SourceTrace {\n type: \"source_trace\"\n source_trace_id: string\n connected_source_port_ids: string[]\n connected_source_net_ids: string[]\n subcircuit_id?: string\n subcircuit_connectivity_map_key?: string\n max_length?: number\n display_name?: string\n min_trace_thickness?: number\n}\n\nexport const source_trace = z.object({\n type: z.literal(\"source_trace\"),\n source_trace_id: z.string(),\n connected_source_port_ids: z.array(z.string()),\n connected_source_net_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n subcircuit_connectivity_map_key: z.string().optional(),\n max_length: z.number().optional(),\n min_trace_thickness: z.number().optional(),\n display_name: z.string().optional(),\n})\n\ntype InferredSourceTrace = z.infer<typeof source_trace>\n\nexpectTypesMatch<SourceTrace, InferredSourceTrace>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_group = z.object({\n type: z.literal(\"source_group\"),\n source_group_id: z.string(),\n subcircuit_id: z.string().optional(),\n parent_subcircuit_id: z.string().optional(),\n parent_source_group_id: z.string().optional(),\n is_subcircuit: z.boolean().optional(),\n show_as_schematic_box: z.boolean().optional(),\n name: z.string().optional(),\n was_automatically_named: z.boolean().optional(),\n})\n\nexport type SourceGroupInput = z.input<typeof source_group>\ntype InferredSourceGroup = z.infer<typeof source_group>\n\nexport interface SourceGroup {\n type: \"source_group\"\n source_group_id: string\n subcircuit_id?: string\n parent_subcircuit_id?: string\n parent_source_group_id?: string\n is_subcircuit?: boolean\n show_as_schematic_box?: boolean\n name?: string\n was_automatically_named?: boolean\n}\n\nexpectTypesMatch<SourceGroup, InferredSourceGroup>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_net = z.object({\n type: z.literal(\"source_net\"),\n source_net_id: z.string(),\n name: z.string(),\n member_source_group_ids: z.array(z.string()),\n is_power: z.boolean().optional(),\n is_ground: z.boolean().optional(),\n is_digital_signal: z.boolean().optional(),\n is_analog_signal: z.boolean().optional(),\n is_positive_voltage_source: z.boolean().optional(),\n trace_width: z.number().optional(),\n subcircuit_id: z.string().optional(),\n subcircuit_connectivity_map_key: z.string().optional(),\n})\n\nexport type SourceNetInput = z.input<typeof source_net>\ntype InferredSourceNet = z.infer<typeof source_net>\n\nexport interface SourceNet {\n type: \"source_net\"\n source_net_id: string\n name: string\n member_source_group_ids: string[]\n is_power?: boolean\n is_ground?: boolean\n is_digital_signal?: boolean\n is_analog_signal?: boolean\n is_positive_voltage_source?: boolean\n trace_width?: number\n subcircuit_id?: string\n subcircuit_connectivity_map_key?: string\n}\n\nexpectTypesMatch<SourceNet, InferredSourceNet>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_board = z\n .object({\n type: z.literal(\"source_board\"),\n source_board_id: z.string(),\n source_group_id: z.string(),\n title: z.string().optional(),\n })\n .describe(\"Defines a board in the source domain\")\n\nexport type SourceBoardInput = z.input<typeof source_board>\ntype InferredSourceBoard = z.infer<typeof source_board>\n\n/**\n * Defines a board in the source domain\n */\nexport interface SourceBoard {\n type: \"source_board\"\n source_board_id: string\n source_group_id: string\n title?: string\n}\n\nexpectTypesMatch<SourceBoard, InferredSourceBoard>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_ambiguous_port_reference = base_circuit_json_error\n .extend({\n type: z.literal(\"source_ambiguous_port_reference\"),\n source_ambiguous_port_reference_id: getZodPrefixedIdWithDefault(\n \"source_ambiguous_port_reference\",\n ),\n error_type: z\n .literal(\"source_ambiguous_port_reference\")\n .default(\"source_ambiguous_port_reference\"),\n source_port_id: z.string().optional(),\n source_component_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when a port hint matches multiple non-overlapping pads, making the port reference ambiguous\",\n )\n\nexport type SourceAmbiguousPortReferenceInput = z.input<\n typeof source_ambiguous_port_reference\n>\ntype InferredSourceAmbiguousPortReference = z.infer<\n typeof source_ambiguous_port_reference\n>\n\n/**\n * Error emitted when a port hint matches multiple non-overlapping pads,\n * making the port reference ambiguous (e.g. multiple pads all named \"SH\").\n */\nexport interface SourceAmbiguousPortReference extends BaseCircuitJsonError {\n type: \"source_ambiguous_port_reference\"\n source_ambiguous_port_reference_id: string\n error_type: \"source_ambiguous_port_reference\"\n source_port_id?: string\n source_component_id?: string\n}\n\nexpectTypesMatch<\n SourceAmbiguousPortReference,\n InferredSourceAmbiguousPortReference\n>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_pcb_ground_plane = z\n .object({\n type: z.literal(\"source_pcb_ground_plane\"),\n source_pcb_ground_plane_id: z.string(),\n source_group_id: z.string(),\n source_net_id: z.string(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a ground plane in the source domain\")\n\nexport type SourcePcbGroundPlaneInput = z.input<typeof source_pcb_ground_plane>\ntype InferredSourcePcbGroundPlane = z.infer<typeof source_pcb_ground_plane>\n\n/**\n * Defines a ground plane in the source domain\n */\nexport interface SourcePcbGroundPlane {\n type: \"source_pcb_ground_plane\"\n source_pcb_ground_plane_id: string\n source_group_id: string\n source_net_id: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<SourcePcbGroundPlane, InferredSourcePcbGroundPlane>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_manually_placed_via = z\n .object({\n type: z.literal(\"source_manually_placed_via\"),\n source_manually_placed_via_id: z.string(),\n source_group_id: z.string(),\n source_net_id: z.string(),\n subcircuit_id: z.string().optional(),\n source_trace_id: z.string().optional(),\n })\n .describe(\"Defines a via that is manually placed in the source domain\")\n\nexport type SourceManuallyPlacedViaInput = z.input<\n typeof source_manually_placed_via\n>\ntype InferredSourceManuallyPlacedVia = z.infer<\n typeof source_manually_placed_via\n>\n\n/**\n * Defines a via that is manually placed in the source domain\n */\nexport interface SourceManuallyPlacedVia {\n type: \"source_manually_placed_via\"\n source_manually_placed_via_id: string\n source_group_id: string\n source_net_id: string\n subcircuit_id?: string\n source_trace_id?: string\n}\n\nexpectTypesMatch<SourceManuallyPlacedVia, InferredSourceManuallyPlacedVia>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const all_layers = [\n \"top\",\n \"bottom\",\n \"inner1\",\n \"inner2\",\n \"inner3\",\n \"inner4\",\n \"inner5\",\n \"inner6\",\n] as const\n\nexport const layer_string = z.enum(all_layers)\n\nexport const layer_ref = layer_string\n .or(\n z.object({\n name: layer_string,\n }),\n )\n .transform((layer) => {\n if (typeof layer === \"string\") {\n return layer\n }\n return layer.name\n })\n\nexport type LayerRefInput = z.input<typeof layer_ref>\ntype InferredLayerRef = z.output<typeof layer_ref>\nexport type LayerRef = (typeof all_layers)[number]\n\nexpectTypesMatch<LayerRef, InferredLayerRef>(true)\n\nexport const visible_layer = z.enum([\"top\", \"bottom\"])\nexport type VisibleLayerRef = z.infer<typeof visible_layer>\nexport type VisibleLayer = z.infer<typeof visible_layer>\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_no_power_pin_defined_warning = z\n .object({\n type: z.literal(\"source_no_power_pin_defined_warning\"),\n source_no_power_pin_defined_warning_id: getZodPrefixedIdWithDefault(\n \"source_no_power_pin_defined_warning\",\n ),\n warning_type: z\n .literal(\"source_no_power_pin_defined_warning\")\n .default(\"source_no_power_pin_defined_warning\"),\n message: z.string(),\n source_component_id: z.string(),\n source_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Warning emitted when a chip has no source ports with requires_power=true\",\n )\n\nexport type SourceNoPowerPinDefinedWarningInput = z.input<\n typeof source_no_power_pin_defined_warning\n>\ntype InferredSourceNoPowerPinDefinedWarning = z.infer<\n typeof source_no_power_pin_defined_warning\n>\n\n/**\n * Warning emitted when a chip has no source ports with requires_power=true\n */\nexport interface SourceNoPowerPinDefinedWarning {\n type: \"source_no_power_pin_defined_warning\"\n source_no_power_pin_defined_warning_id: string\n warning_type: \"source_no_power_pin_defined_warning\"\n message: string\n source_component_id: string\n source_port_ids: string[]\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SourceNoPowerPinDefinedWarning,\n InferredSourceNoPowerPinDefinedWarning\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_no_ground_pin_defined_warning = z\n .object({\n type: z.literal(\"source_no_ground_pin_defined_warning\"),\n source_no_ground_pin_defined_warning_id: getZodPrefixedIdWithDefault(\n \"source_no_ground_pin_defined_warning\",\n ),\n warning_type: z\n .literal(\"source_no_ground_pin_defined_warning\")\n .default(\"source_no_ground_pin_defined_warning\"),\n message: z.string(),\n source_component_id: z.string(),\n source_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Warning emitted when a chip has no source ports marked as ground pins\",\n )\n\nexport type SourceNoGroundPinDefinedWarningInput = z.input<\n typeof source_no_ground_pin_defined_warning\n>\ntype InferredSourceNoGroundPinDefinedWarning = z.infer<\n typeof source_no_ground_pin_defined_warning\n>\n\n/**\n * Warning emitted when a chip has no source ports marked as ground pins\n */\nexport interface SourceNoGroundPinDefinedWarning {\n type: \"source_no_ground_pin_defined_warning\"\n source_no_ground_pin_defined_warning_id: string\n warning_type: \"source_no_ground_pin_defined_warning\"\n message: string\n source_component_id: string\n source_port_ids: string[]\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SourceNoGroundPinDefinedWarning,\n InferredSourceNoGroundPinDefinedWarning\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_component_pins_underspecified_warning = z\n .object({\n type: z.literal(\"source_component_pins_underspecified_warning\"),\n source_component_pins_underspecified_warning_id:\n getZodPrefixedIdWithDefault(\n \"source_component_pins_underspecified_warning\",\n ),\n warning_type: z\n .literal(\"source_component_pins_underspecified_warning\")\n .default(\"source_component_pins_underspecified_warning\"),\n message: z.string(),\n source_component_id: z.string(),\n source_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Warning emitted when all ports on a source component are underspecified\",\n )\n\nexport type SourceComponentPinsUnderspecifiedWarningInput = z.input<\n typeof source_component_pins_underspecified_warning\n>\ntype InferredSourceComponentPinsUnderspecifiedWarning = z.infer<\n typeof source_component_pins_underspecified_warning\n>\n\n/**\n * Warning emitted when all ports on a source component are underspecified\n */\nexport interface SourceComponentPinsUnderspecifiedWarning {\n type: \"source_component_pins_underspecified_warning\"\n source_component_pins_underspecified_warning_id: string\n warning_type: \"source_component_pins_underspecified_warning\"\n message: string\n source_component_id: string\n source_port_ids: string[]\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SourceComponentPinsUnderspecifiedWarning,\n InferredSourceComponentPinsUnderspecifiedWarning\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_pin_must_be_connected_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_pin_must_be_connected_error\"),\n source_pin_must_be_connected_error_id: getZodPrefixedIdWithDefault(\n \"source_pin_must_be_connected_error\",\n ),\n error_type: z\n .literal(\"source_pin_must_be_connected_error\")\n .default(\"source_pin_must_be_connected_error\"),\n source_component_id: z.string(),\n source_port_id: z.string(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when a pin with mustBeConnected attribute is not connected to any trace\",\n )\n\nexport type SourcePinMustBeConnectedErrorInput = z.input<\n typeof source_pin_must_be_connected_error\n>\ntype InferredSourcePinMustBeConnectedError = z.infer<\n typeof source_pin_must_be_connected_error\n>\n\n/**\n * Error emitted when a pin with mustBeConnected attribute is not connected to any trace\n */\nexport interface SourcePinMustBeConnectedError extends BaseCircuitJsonError {\n type: \"source_pin_must_be_connected_error\"\n source_pin_must_be_connected_error_id: string\n error_type: \"source_pin_must_be_connected_error\"\n source_component_id: string\n source_port_id: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SourcePinMustBeConnectedError,\n InferredSourcePinMustBeConnectedError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const unknown_error_finding_part = base_circuit_json_error\n .extend({\n type: z.literal(\"unknown_error_finding_part\"),\n unknown_error_finding_part_id: getZodPrefixedIdWithDefault(\n \"unknown_error_finding_part\",\n ),\n error_type: z\n .literal(\"unknown_error_finding_part\")\n .default(\"unknown_error_finding_part\"),\n source_component_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when an unexpected error occurs while finding a part\",\n )\n\nexport type UnknownErrorFindingPartInput = z.input<\n typeof unknown_error_finding_part\n>\ntype InferredUnknownErrorFindingPart = z.infer<\n typeof unknown_error_finding_part\n>\n\n/**\n * Error emitted when an unexpected error occurs while finding a part.\n * This includes cases where the API returns HTML instead of JSON,\n * network failures, or other unexpected responses.\n */\nexport interface UnknownErrorFindingPart extends BaseCircuitJsonError {\n type: \"unknown_error_finding_part\"\n unknown_error_finding_part_id: string\n error_type: \"unknown_error_finding_part\"\n source_component_id?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<UnknownErrorFindingPart, InferredUnknownErrorFindingPart>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicBox {\n type: \"schematic_box\"\n schematic_component_id?: string\n schematic_symbol_id?: string\n width: number\n height: number\n is_dashed: boolean\n x: number\n y: number\n subcircuit_id?: string\n}\n\nexport const schematic_box = z\n .object({\n type: z.literal(\"schematic_box\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n width: distance,\n height: distance,\n is_dashed: z.boolean().default(false),\n x: distance,\n y: distance,\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Draws a box on the schematic\")\n\nexport type SchematicBoxInput = z.input<typeof schematic_box>\ntype InferredSchematicBox = z.infer<typeof schematic_box>\n\nexpectTypesMatch<SchematicBox, InferredSchematicBox>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { distance } from \"../units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicPath {\n type: \"schematic_path\"\n schematic_path_id: string\n schematic_component_id?: string\n schematic_symbol_id?: string\n fill_color?: string\n is_filled?: boolean\n stroke_width?: number | null\n stroke_color?: string\n points: Point[]\n subcircuit_id?: string\n}\n\nexport const schematic_path = z.object({\n type: z.literal(\"schematic_path\"),\n schematic_path_id: getZodPrefixedIdWithDefault(\"schematic_path\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n fill_color: z.string().optional(),\n is_filled: z.boolean().optional(),\n stroke_width: distance.nullable().optional(),\n stroke_color: z.string().optional(),\n points: z.array(point),\n subcircuit_id: z.string().optional(),\n})\n\nexport type SchematicPathInput = z.input<typeof schematic_path>\ntype InferredSchematicPath = z.infer<typeof schematic_path>\n\nexpectTypesMatch<SchematicPath, InferredSchematicPath>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { size, type Size } from \"../common/size\"\nimport { length } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_pin_styles = z.record(\n z.object({\n left_margin: length.optional(),\n right_margin: length.optional(),\n top_margin: length.optional(),\n bottom_margin: length.optional(),\n }),\n)\n\nexport interface SchematicPortArrangementBySize {\n left_size: number\n right_size: number\n top_size?: number\n bottom_size?: number\n}\n\nexport interface SchematicPortArrangementBySides {\n left_side?: { pins: number[]; direction?: \"top-to-bottom\" | \"bottom-to-top\" }\n right_side?: { pins: number[]; direction?: \"top-to-bottom\" | \"bottom-to-top\" }\n top_side?: { pins: number[]; direction?: \"left-to-right\" | \"right-to-left\" }\n bottom_side?: {\n pins: number[]\n direction?: \"left-to-right\" | \"right-to-left\"\n }\n}\n\nexport type SchematicPortArrangement =\n | SchematicPortArrangementBySize\n | SchematicPortArrangementBySides\n\nexport interface SchematicComponent {\n type: \"schematic_component\"\n size: Size\n center: Point\n source_component_id?: string\n schematic_component_id: string\n schematic_symbol_id?: string\n pin_spacing?: number\n pin_styles?: Record<\n string,\n {\n left_margin?: number\n right_margin?: number\n top_margin?: number\n bottom_margin?: number\n }\n >\n box_width?: number\n symbol_name?: string\n port_arrangement?: SchematicPortArrangement\n port_labels?: Record<string, string>\n symbol_display_value?: string\n subcircuit_id?: string\n schematic_group_id?: string\n is_schematic_group?: boolean\n source_group_id?: string\n is_box_with_pins: boolean\n}\n\nexport const schematic_component_port_arrangement_by_size = z.object({\n left_size: z.number(),\n right_size: z.number(),\n top_size: z.number().optional(),\n bottom_size: z.number().optional(),\n})\n\nexpectTypesMatch<\n SchematicPortArrangementBySize,\n z.infer<typeof schematic_component_port_arrangement_by_size>\n>(true)\n\nexport const schematic_component_port_arrangement_by_sides = z.object({\n left_side: z\n .object({\n pins: z.array(z.number()),\n // @ts-ignore\n direction: z.enum([\"top-to-bottom\", \"bottom-to-top\"]).optional(),\n })\n .optional(),\n right_side: z\n .object({\n pins: z.array(z.number()),\n // @ts-ignore\n direction: z.enum([\"top-to-bottom\", \"bottom-to-top\"]).optional(),\n })\n .optional(),\n top_side: z\n .object({\n pins: z.array(z.number()),\n // @ts-ignore\n direction: z.enum([\"left-to-right\", \"right-to-left\"]).optional(),\n })\n .optional(),\n bottom_side: z\n .object({\n pins: z.array(z.number()),\n // @ts-ignore\n direction: z.enum([\"left-to-right\", \"right-to-left\"]).optional(),\n })\n .optional(),\n})\n\nexpectTypesMatch<\n SchematicPortArrangementBySides,\n z.infer<typeof schematic_component_port_arrangement_by_sides>\n>(true)\n\nexport const port_arrangement = z.union([\n schematic_component_port_arrangement_by_size,\n schematic_component_port_arrangement_by_sides,\n])\n\nexport const schematic_component = z.object({\n type: z.literal(\"schematic_component\"),\n size,\n center: point,\n source_component_id: z.string().optional(),\n schematic_component_id: z.string(),\n schematic_symbol_id: z.string().optional(),\n pin_spacing: length.optional(),\n pin_styles: schematic_pin_styles.optional(),\n box_width: length.optional(),\n symbol_name: z.string().optional(),\n port_arrangement: port_arrangement.optional(),\n port_labels: z.record(z.string()).optional(),\n symbol_display_value: z.string().optional(),\n subcircuit_id: z.string().optional(),\n schematic_group_id: z.string().optional(),\n is_schematic_group: z.boolean().optional(),\n source_group_id: z.string().optional(),\n is_box_with_pins: z.boolean().optional().default(true),\n})\n\nexport type SchematicComponentInput = z.input<typeof schematic_component>\ntype InferredSchematicComponent = z.infer<typeof schematic_component>\n\nexpectTypesMatch<SchematicComponent, InferredSchematicComponent>(true)\n","import { kicadSymbolMetadata } from \"src/common/kicadSymbolMetadata\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\n\nconst schematicSymbolMetadata = z\n .object({\n kicad_symbol: kicadSymbolMetadata.optional(),\n })\n .catchall(z.unknown())\n\nexport type SchematicSymbolMetadata = z.infer<typeof schematicSymbolMetadata>\n\nexport interface SchematicSymbol {\n type: \"schematic_symbol\"\n schematic_symbol_id: string\n name?: string\n metadata?: SchematicSymbolMetadata\n}\n\nexport const schematic_symbol = z\n .object({\n type: z.literal(\"schematic_symbol\"),\n schematic_symbol_id: z.string(),\n name: z.string().optional(),\n metadata: schematicSymbolMetadata.optional(),\n })\n .describe(\n \"Defines a named schematic symbol that can be referenced by components.\",\n )\n\nexport type SchematicSymbolInput = z.input<typeof schematic_symbol>\ntype InferredSchematicSymbol = z.infer<typeof schematic_symbol>\n\nexpectTypesMatch<SchematicSymbol, InferredSchematicSymbol>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/** Draws a styled line on the schematic */\nexport interface SchematicLine {\n type: \"schematic_line\"\n schematic_line_id: string\n schematic_component_id?: string\n schematic_symbol_id?: string\n x1: number\n y1: number\n x2: number\n y2: number\n stroke_width?: number | null\n color: string\n is_dashed: boolean\n subcircuit_id?: string\n}\n\nexport const schematic_line = z\n .object({\n type: z.literal(\"schematic_line\"),\n schematic_line_id: getZodPrefixedIdWithDefault(\"schematic_line\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n x1: distance,\n y1: distance,\n x2: distance,\n y2: distance,\n stroke_width: distance.nullable().optional(),\n color: z.string().default(\"#000000\"),\n is_dashed: z.boolean().default(false),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Draws a styled line on the schematic\")\n\nexport type SchematicLineInput = z.input<typeof schematic_line>\ntype InferredSchematicLine = z.infer<typeof schematic_line>\n\nexpectTypesMatch<SchematicLine, InferredSchematicLine>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { distance, rotation } from \"../units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/** Draws a styled rectangle on the schematic */\nexport interface SchematicRect {\n type: \"schematic_rect\"\n schematic_rect_id: string\n schematic_component_id?: string\n schematic_symbol_id?: string\n center: Point\n width: number\n height: number\n rotation: number\n stroke_width?: number | null\n color: string\n is_filled: boolean\n fill_color?: string\n is_dashed: boolean\n subcircuit_id?: string\n}\n\nexport const schematic_rect = z\n .object({\n type: z.literal(\"schematic_rect\"),\n schematic_rect_id: getZodPrefixedIdWithDefault(\"schematic_rect\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n center: point,\n width: distance,\n height: distance,\n rotation: rotation.default(0),\n stroke_width: distance.nullable().optional(),\n color: z.string().default(\"#000000\"),\n is_filled: z.boolean().default(false),\n fill_color: z.string().optional(),\n is_dashed: z.boolean().default(false),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Draws a styled rectangle on the schematic\")\n\nexport type SchematicRectInput = z.input<typeof schematic_rect>\ntype InferredSchematicRect = z.infer<typeof schematic_rect>\n\nexpectTypesMatch<SchematicRect, InferredSchematicRect>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { distance } from \"../units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/** Draws a styled circle on the schematic */\nexport interface SchematicCircle {\n type: \"schematic_circle\"\n schematic_circle_id: string\n schematic_component_id?: string\n schematic_symbol_id?: string\n center: Point\n radius: number\n stroke_width?: number | null\n color: string\n is_filled: boolean\n fill_color?: string\n is_dashed: boolean\n subcircuit_id?: string\n}\n\nexport const schematic_circle = z\n .object({\n type: z.literal(\"schematic_circle\"),\n schematic_circle_id: getZodPrefixedIdWithDefault(\"schematic_circle\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n center: point,\n radius: distance,\n stroke_width: distance.nullable().optional(),\n color: z.string().default(\"#000000\"),\n is_filled: z.boolean().default(false),\n fill_color: z.string().optional(),\n is_dashed: z.boolean().default(false),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Draws a styled circle on the schematic\")\n\nexport type SchematicCircleInput = z.input<typeof schematic_circle>\ntype InferredSchematicCircle = z.infer<typeof schematic_circle>\n\nexpectTypesMatch<SchematicCircle, InferredSchematicCircle>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { distance, rotation } from \"../units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/** Draws a styled arc on the schematic */\nexport interface SchematicArc {\n type: \"schematic_arc\"\n schematic_arc_id: string\n schematic_component_id?: string\n schematic_symbol_id?: string\n center: Point\n radius: number\n start_angle_degrees: number\n end_angle_degrees: number\n direction: \"clockwise\" | \"counterclockwise\"\n stroke_width?: number | null\n color: string\n is_dashed: boolean\n subcircuit_id?: string\n}\n\nexport const schematic_arc = z\n .object({\n type: z.literal(\"schematic_arc\"),\n schematic_arc_id: getZodPrefixedIdWithDefault(\"schematic_arc\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n center: point,\n radius: distance,\n start_angle_degrees: rotation,\n end_angle_degrees: rotation,\n direction: z\n .enum([\"clockwise\", \"counterclockwise\"])\n .default(\"counterclockwise\"),\n stroke_width: distance.nullable().optional(),\n color: z.string().default(\"#000000\"),\n is_dashed: z.boolean().default(false),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Draws a styled arc on the schematic\")\n\nexport type SchematicArcInput = z.input<typeof schematic_arc>\ntype InferredSchematicArc = z.infer<typeof schematic_arc>\n\nexpectTypesMatch<SchematicArc, InferredSchematicArc>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicTraceEdge {\n from: {\n x: number\n y: number\n }\n to: {\n x: number\n y: number\n }\n is_crossing?: boolean\n from_schematic_port_id?: string\n to_schematic_port_id?: string\n}\n\nexport interface SchematicTrace {\n type: \"schematic_trace\"\n schematic_trace_id: string\n source_trace_id?: string\n junctions: {\n x: number\n y: number\n }[]\n edges: SchematicTraceEdge[]\n subcircuit_id?: string\n /** Optional for now, but will be required in a future release */\n subcircuit_connectivity_map_key?: string\n}\n\nexport const schematic_trace = z.object({\n type: z.literal(\"schematic_trace\"),\n schematic_trace_id: z.string(),\n source_trace_id: z.string().optional(),\n junctions: z.array(\n z.object({\n x: z.number(),\n y: z.number(),\n }),\n ),\n edges: z.array(\n z.object({\n from: z.object({\n x: z.number(),\n y: z.number(),\n }),\n to: z.object({\n x: z.number(),\n y: z.number(),\n }),\n is_crossing: z.boolean().optional(),\n from_schematic_port_id: z.string().optional(),\n to_schematic_port_id: z.string().optional(),\n }),\n ),\n subcircuit_id: z.string().optional(),\n // TODO: make required in a future release\n subcircuit_connectivity_map_key: z.string().optional(),\n})\n\nexport type SchematicTraceInput = z.input<typeof schematic_trace>\ntype InferredSchematicTrace = z.infer<typeof schematic_trace>\n\nexpectTypesMatch<SchematicTraceInput, InferredSchematicTrace>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { ninePointAnchor } from \"src/common/NinePointAnchor\"\nimport type { NinePointAnchor } from \"src/common/NinePointAnchor\"\nimport type { FivePointAnchor } from \"src/common/FivePointAnchor\"\nimport { fivePointAnchor } from \"src/common/FivePointAnchor\"\n\nexport interface SchematicText {\n type: \"schematic_text\"\n schematic_component_id?: string\n schematic_symbol_id?: string\n schematic_text_id: string\n text: string\n font_size: number\n position: {\n x: number\n y: number\n }\n rotation: number\n anchor: NinePointAnchor | FivePointAnchor\n color: string\n subcircuit_id?: string\n}\n\nexport const schematic_text = z.object({\n type: z.literal(\"schematic_text\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n schematic_text_id: z.string(),\n text: z.string(),\n font_size: z.number().default(0.18),\n position: z.object({\n x: distance,\n y: distance,\n }),\n rotation: z.number().default(0),\n anchor: z\n .union([fivePointAnchor.describe(\"legacy\"), ninePointAnchor])\n .default(\"center\"),\n color: z.string().default(\"#000000\"),\n subcircuit_id: z.string().optional(),\n})\n\nexport type SchematicTextInput = z.input<typeof schematic_text>\ntype InferredSchematicText = z.infer<typeof schematic_text>\n\nexpectTypesMatch<SchematicText, InferredSchematicText>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport type FivePointAnchor = \"center\" | \"left\" | \"right\" | \"top\" | \"bottom\"\n\nexport const fivePointAnchor = z.enum([\n \"center\",\n \"left\",\n \"right\",\n \"top\",\n \"bottom\",\n])\n\ntype InferredFivePointAnchor = z.infer<typeof fivePointAnchor>\n\nexpectTypesMatch<FivePointAnchor, InferredFivePointAnchor>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicPort {\n type: \"schematic_port\"\n schematic_port_id: string\n source_port_id: string\n schematic_component_id?: string\n center: Point\n facing_direction?: \"up\" | \"down\" | \"left\" | \"right\"\n distance_from_component_edge?: number\n side_of_component?: \"top\" | \"bottom\" | \"left\" | \"right\"\n true_ccw_index?: number\n pin_number?: number\n display_pin_label?: string\n subcircuit_id?: string\n is_connected?: boolean\n has_input_arrow?: boolean\n has_output_arrow?: boolean\n is_drawn_with_inversion_circle?: boolean\n}\n\nexport const schematic_port = z\n .object({\n type: z.literal(\"schematic_port\"),\n schematic_port_id: z.string(),\n source_port_id: z.string(),\n schematic_component_id: z.string().optional(),\n center: point,\n facing_direction: z.enum([\"up\", \"down\", \"left\", \"right\"]).optional(),\n distance_from_component_edge: z.number().optional(),\n side_of_component: z.enum([\"top\", \"bottom\", \"left\", \"right\"]).optional(),\n true_ccw_index: z.number().optional(),\n pin_number: z.number().optional(),\n display_pin_label: z.string().optional(),\n subcircuit_id: z.string().optional(),\n is_connected: z.boolean().optional(),\n has_input_arrow: z.boolean().optional(),\n has_output_arrow: z.boolean().optional(),\n is_drawn_with_inversion_circle: z.boolean().optional(),\n })\n .describe(\"Defines a port on a schematic component\")\n\nexport type SchematicPortInput = z.input<typeof schematic_port>\ntype InferredSchematicPort = z.infer<typeof schematic_port>\n\nexpectTypesMatch<SchematicPort, InferredSchematicPort>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\n\nexport interface SchematicNetLabel {\n type: \"schematic_net_label\"\n schematic_net_label_id: string\n schematic_trace_id?: string\n source_trace_id?: string\n source_net_id: string\n center: Point\n anchor_position?: Point | undefined\n anchor_side: \"top\" | \"bottom\" | \"left\" | \"right\"\n text: string\n symbol_name?: string | undefined\n /**\n * When true the net label can be repositioned. When false the label's\n * position is fixed by the element it is attached to.\n */\n is_movable?: boolean\n subcircuit_id?: string\n}\n\nexport const schematic_net_label = z.object({\n type: z.literal(\"schematic_net_label\"),\n schematic_net_label_id: getZodPrefixedIdWithDefault(\"schematic_net_label\"),\n schematic_trace_id: z.string().optional(),\n source_trace_id: z.string().optional(),\n source_net_id: z.string(),\n center: point,\n anchor_position: point.optional(),\n anchor_side: z.enum([\"top\", \"bottom\", \"left\", \"right\"]),\n text: z.string(),\n symbol_name: z.string().optional(),\n is_movable: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n})\n\nexport type SchematicNetLabelInput = z.input<typeof schematic_net_label>\nexport type InferredSchematicNetLabel = z.infer<typeof schematic_net_label>\n\nexpectTypesMatch<SchematicNetLabel, InferredSchematicNetLabel>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicError extends BaseCircuitJsonError {\n type: \"schematic_error\"\n schematic_error_id: string\n error_type: \"schematic_port_not_found\"\n subcircuit_id?: string\n}\n\nexport const schematic_error = base_circuit_json_error\n .extend({\n type: z.literal(\"schematic_error\"),\n schematic_error_id: z.string(),\n // eventually each error type should be broken out into a dir of files\n error_type: z\n .literal(\"schematic_port_not_found\")\n .default(\"schematic_port_not_found\"),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a schematic error on the schematic\")\n\nexport type SchematicErrorInput = z.input<typeof schematic_error>\ntype InferredSchematicError = z.infer<typeof schematic_error>\n\nexpectTypesMatch<SchematicError, InferredSchematicError>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_layout_error = base_circuit_json_error\n .extend({\n type: z.literal(\"schematic_layout_error\"),\n schematic_layout_error_id: getZodPrefixedIdWithDefault(\n \"schematic_layout_error\",\n ),\n error_type: z\n .literal(\"schematic_layout_error\")\n .default(\"schematic_layout_error\"),\n source_group_id: z.string(),\n schematic_group_id: z.string(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Error emitted when schematic layout fails for a group\")\n\nexport type SchematicLayoutErrorInput = z.input<typeof schematic_layout_error>\ntype InferredSchematicLayoutError = z.infer<typeof schematic_layout_error>\n\nexport interface SchematicLayoutError extends BaseCircuitJsonError {\n type: \"schematic_layout_error\"\n schematic_layout_error_id: string\n error_type: \"schematic_layout_error\"\n source_group_id: string\n schematic_group_id: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<SchematicLayoutError, InferredSchematicLayoutError>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { size, type Size } from \"../common/size\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_debug_object_base = z.object({\n type: z.literal(\"schematic_debug_object\"),\n label: z.string().optional(),\n subcircuit_id: z.string().optional(),\n})\n\nexport const schematic_debug_rect = schematic_debug_object_base.extend({\n shape: z.literal(\"rect\"),\n center: point,\n size: size,\n})\n\nexport const schematic_debug_line = schematic_debug_object_base.extend({\n shape: z.literal(\"line\"),\n start: point,\n end: point,\n})\n\nexport const schematic_debug_point = schematic_debug_object_base.extend({\n shape: z.literal(\"point\"),\n center: point,\n})\n\nexport const schematic_debug_object = z.discriminatedUnion(\"shape\", [\n schematic_debug_rect,\n schematic_debug_line,\n schematic_debug_point,\n])\ntype InferredSchematicDebugObject = z.infer<typeof schematic_debug_object>\n\nexport interface SchematicDebugRect {\n type: \"schematic_debug_object\"\n label?: string\n shape: \"rect\"\n center: Point\n size: Size\n subcircuit_id?: string\n}\n\nexport interface SchematicDebugLine {\n type: \"schematic_debug_object\"\n label?: string\n shape: \"line\"\n start: Point\n end: Point\n subcircuit_id?: string\n}\n\nexport interface SchematicDebugPoint {\n type: \"schematic_debug_object\"\n label?: string\n shape: \"point\"\n center: Point\n subcircuit_id?: string\n}\n\nexport type SchematicDebugObject =\n | SchematicDebugRect\n | SchematicDebugLine\n | SchematicDebugPoint\n\nexpectTypesMatch<SchematicDebugObject, InferredSchematicDebugObject>(true)\nexport type SchematicDebugObjectInput = z.input<typeof schematic_debug_object>\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { voltage } from \"src/units\"\nimport {\n ninePointAnchor,\n type NinePointAnchor,\n} from \"src/common/NinePointAnchor\"\n\nexport interface SchematicVoltageProbe {\n type: \"schematic_voltage_probe\"\n schematic_voltage_probe_id: string\n source_component_id?: string\n name?: string\n position: Point\n schematic_trace_id: string\n voltage?: number\n subcircuit_id?: string\n color?: string\n label_alignment?: NinePointAnchor\n}\n\nexport const schematic_voltage_probe = z\n .object({\n type: z.literal(\"schematic_voltage_probe\"),\n schematic_voltage_probe_id: z.string(),\n source_component_id: z.string().optional(),\n name: z.string().optional(),\n position: point,\n schematic_trace_id: z.string(),\n voltage: voltage.optional(),\n subcircuit_id: z.string().optional(),\n color: z.string().optional(),\n label_alignment: ninePointAnchor.optional(),\n })\n .describe(\"Defines a voltage probe measurement point on a schematic trace\")\n\nexport type SchematicVoltageProbeInput = z.input<typeof schematic_voltage_probe>\ntype InferredSchematicVoltageProbe = z.infer<typeof schematic_voltage_probe>\n\nexpectTypesMatch<SchematicVoltageProbe, InferredSchematicVoltageProbe>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"../common\"\nimport { expectTypesMatch } from \"../utils/expect-types-match\"\n\nexport const schematic_manual_edit_conflict_warning = z\n .object({\n type: z.literal(\"schematic_manual_edit_conflict_warning\"),\n schematic_manual_edit_conflict_warning_id: getZodPrefixedIdWithDefault(\n \"schematic_manual_edit_conflict_warning\",\n ),\n warning_type: z\n .literal(\"schematic_manual_edit_conflict_warning\")\n .default(\"schematic_manual_edit_conflict_warning\"),\n message: z.string(),\n schematic_component_id: z.string(),\n schematic_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n source_component_id: z.string(),\n })\n .describe(\n \"Warning emitted when a component has both manual placement and explicit schX/schY coordinates\",\n )\n\nexport type SchematicManualEditConflictWarningInput = z.input<\n typeof schematic_manual_edit_conflict_warning\n>\ntype InferredSchematicManualEditConflictWarning = z.infer<\n typeof schematic_manual_edit_conflict_warning\n>\n\n/**\n * Warning emitted when a component has both manual placement (via manualEdits) and explicit schX/schY coordinates\n */\nexport interface SchematicManualEditConflictWarning {\n type: \"schematic_manual_edit_conflict_warning\"\n schematic_manual_edit_conflict_warning_id: string\n warning_type: \"schematic_manual_edit_conflict_warning\"\n message: string\n schematic_component_id: string\n schematic_group_id?: string\n subcircuit_id?: string\n source_component_id: string\n}\n\nexpectTypesMatch<\n SchematicManualEditConflictWarning,\n InferredSchematicManualEditConflictWarning\n>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_group = z\n .object({\n type: z.literal(\"schematic_group\"),\n schematic_group_id: getZodPrefixedIdWithDefault(\"schematic_group\"),\n source_group_id: z.string(),\n is_subcircuit: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n width: length,\n height: length,\n center: point,\n schematic_component_ids: z.array(z.string()),\n show_as_schematic_box: z.boolean().optional(),\n name: z.string().optional(),\n description: z.string().optional(),\n })\n .describe(\"Defines a group of components on the schematic\")\n\nexport type SchematicGroupInput = z.input<typeof schematic_group>\ntype InferredSchematicGroup = z.infer<typeof schematic_group>\n\n/**\n * Defines a group of components on the schematic\n */\nexport interface SchematicGroup {\n type: \"schematic_group\"\n schematic_group_id: string\n source_group_id: string\n is_subcircuit?: boolean\n subcircuit_id?: string\n width: Length\n height: Length\n center: Point\n schematic_component_ids: string[]\n show_as_schematic_box?: boolean\n name?: string\n description?: string\n}\n\nexpectTypesMatch<SchematicGroup, InferredSchematicGroup>(true)\n","import { z } from \"zod\"\nimport {\n getZodPrefixedIdWithDefault,\n ninePointAnchor,\n point,\n type NinePointAnchor,\n type Point,\n} from \"src/common\"\nimport { distance, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_table = z\n .object({\n type: z.literal(\"schematic_table\"),\n schematic_table_id: getZodPrefixedIdWithDefault(\"schematic_table\"),\n anchor_position: point,\n column_widths: z.array(distance),\n row_heights: z.array(distance),\n cell_padding: distance.optional(),\n border_width: distance.optional(),\n subcircuit_id: z.string().optional(),\n schematic_component_id: z.string().optional(),\n anchor: ninePointAnchor.optional(),\n })\n .describe(\"Defines a table on the schematic\")\n\nexport type SchematicTableInput = z.input<typeof schematic_table>\ntype InferredSchematicTable = z.infer<typeof schematic_table>\n\n/**\n * Defines a table on the schematic, useful for displaying data in a structured format.\n */\nexport interface SchematicTable {\n type: \"schematic_table\"\n schematic_table_id: string\n anchor_position: Point\n column_widths: Length[]\n row_heights: Length[]\n cell_padding?: Length\n border_width?: Length\n subcircuit_id?: string\n schematic_component_id?: string\n anchor?: NinePointAnchor\n}\n\nexpectTypesMatch<SchematicTable, InferredSchematicTable>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault, point, type Point } from \"src/common\"\nimport { distance, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_table_cell = z\n .object({\n type: z.literal(\"schematic_table_cell\"),\n schematic_table_cell_id: getZodPrefixedIdWithDefault(\n \"schematic_table_cell\",\n ),\n schematic_table_id: z.string(),\n start_row_index: z.number(),\n end_row_index: z.number(),\n start_column_index: z.number(),\n end_column_index: z.number(),\n text: z.string().optional(),\n center: point,\n width: distance,\n height: distance,\n horizontal_align: z.enum([\"left\", \"center\", \"right\"]).optional(),\n vertical_align: z.enum([\"top\", \"middle\", \"bottom\"]).optional(),\n font_size: distance.optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a cell within a schematic_table\")\n\nexport type SchematicTableCellInput = z.input<typeof schematic_table_cell>\ntype InferredSchematicTableCell = z.infer<typeof schematic_table_cell>\n\n/**\n * Defines a cell within a schematic_table\n */\nexport interface SchematicTableCell {\n type: \"schematic_table_cell\"\n schematic_table_cell_id: string\n schematic_table_id: string\n start_row_index: number\n end_row_index: number\n start_column_index: number\n end_column_index: number\n text?: string\n center: Point\n width: Length\n height: Length\n horizontal_align?: \"left\" | \"center\" | \"right\"\n vertical_align?: \"top\" | \"middle\" | \"bottom\"\n font_size?: Length\n subcircuit_id?: string\n}\n\nexpectTypesMatch<SchematicTableCell, InferredSchematicTableCell>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_sheet = z\n .object({\n type: z.literal(\"schematic_sheet\"),\n schematic_sheet_id: getZodPrefixedIdWithDefault(\"schematic_sheet\"),\n name: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Defines a schematic sheet or page that components can be placed on\",\n )\n\nexport type SchematicSheetInput = z.input<typeof schematic_sheet>\ntype InferredSchematicSheet = z.infer<typeof schematic_sheet>\n\n/**\n * Defines a schematic sheet or page that components can be placed on.\n */\nexport interface SchematicSheet {\n type: \"schematic_sheet\"\n schematic_sheet_id: string\n name?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<SchematicSheet, InferredSchematicSheet>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const point_with_bulge = z.object({\n x: distance,\n y: distance,\n bulge: z.number().optional(),\n})\n\nexport interface PointWithBulge {\n x: Distance\n y: Distance\n bulge?: number\n}\ntype InferredPointWithBulge = z.infer<typeof point_with_bulge>\nexpectTypesMatch<PointWithBulge, InferredPointWithBulge>(true)\n\nexport const ring = z.object({\n vertices: z.array(point_with_bulge),\n})\n\nexport interface Ring {\n vertices: PointWithBulge[]\n}\ntype InferredRing = z.infer<typeof ring>\nexpectTypesMatch<Ring, InferredRing>(true)\n\nexport const brep_shape = z.object({\n outer_ring: ring,\n inner_rings: z.array(ring).default([]),\n})\n\n/**\n * B-rep shape defined by an outer ring and inner rings (holes).\n */\nexport interface BRepShape {\n /**\n * The outer boundary of the shape. Vertices must be in clockwise order.\n */\n outer_ring: Ring\n /**\n * Inner boundaries (holes). Vertices must be in counter-clockwise order.\n */\n inner_rings: Ring[]\n}\ntype InferredBRepShape = z.infer<typeof brep_shape>\nexpectTypesMatch<BRepShape, InferredBRepShape>(true)\n","import { z } from \"zod\"\nimport { distance } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"./layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n// x: string | number\n// y: string | number\n// via?: boolean\n// via_to_layer?: string\nexport const pcb_route_hint = z.object({\n x: distance,\n y: distance,\n via: z.boolean().optional(),\n via_to_layer: layer_ref.optional(),\n})\nexport const pcb_route_hints = z.array(pcb_route_hint)\n\nexport type PcbRouteHintInput = z.input<typeof pcb_route_hint>\nexport type PcbRouteHintsInput = z.input<typeof pcb_route_hints>\ntype InferredPcbRouteHint = z.output<typeof pcb_route_hint>\ntype InferredPcbRouteHints = z.output<typeof pcb_route_hints>\n\nexport interface PcbRouteHint {\n x: number\n y: number\n via?: boolean\n via_to_layer?: LayerRef\n}\n\nexport type PcbRouteHints = PcbRouteHint[]\n\nexpectTypesMatch<PcbRouteHint, InferredPcbRouteHint>(true)\nexpectTypesMatch<PcbRouteHints, InferredPcbRouteHints>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../../units\"\nimport { layer_ref, type LayerRef } from \"./layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const route_hint_point = z.object({\n x: distance,\n y: distance,\n via: z.boolean().optional(),\n to_layer: layer_ref.optional(),\n trace_width: distance.optional(),\n})\n\nexport type RouteHintPointInput = z.input<typeof route_hint_point>\ntype InferredRouteHintPoint = z.infer<typeof route_hint_point>\n\nexport interface RouteHintPoint {\n x: number\n y: number\n via?: boolean\n to_layer?: LayerRef\n trace_width?: number\n}\n\nexpectTypesMatch<RouteHintPoint, InferredRouteHintPoint>(true)\n","import { type Point, getZodPrefixedIdWithDefault, point } from \"src/common\"\nimport {\n type KicadFootprintMetadata,\n kicadFootprintMetadata,\n} from \"src/common/kicadFootprintMetadata\"\nimport {\n type NinePointAnchor,\n ninePointAnchor,\n} from \"src/common/NinePointAnchor\"\nimport { type LayerRef, layer_ref } from \"src/pcb/properties/layer_ref\"\nimport { type Length, type Rotation, length, rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\n\nexport interface PcbComponentMetadata {\n kicad_footprint?: KicadFootprintMetadata\n}\n\nexport const pcb_component = z\n .object({\n type: z.literal(\"pcb_component\"),\n pcb_component_id: getZodPrefixedIdWithDefault(\"pcb_component\"),\n source_component_id: z.string(),\n center: point,\n layer: layer_ref,\n rotation: rotation,\n display_offset_x: z\n .string()\n .optional()\n .describe(\n \"How to display the x offset for this part, usually corresponding with how the user specified it\",\n ),\n display_offset_y: z\n .string()\n .optional()\n .describe(\n \"How to display the y offset for this part, usually corresponding with how the user specified it\",\n ),\n width: length,\n height: length,\n do_not_place: z.boolean().optional(),\n is_allowed_to_be_off_board: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n position_mode: z\n .enum([\n \"packed\",\n \"relative_to_group_anchor\",\n \"relative_to_another_component\",\n \"none\",\n ])\n .optional(),\n anchor_position: point.optional(),\n anchor_alignment: ninePointAnchor.optional(),\n positioned_relative_to_pcb_group_id: z.string().optional(),\n positioned_relative_to_pcb_board_id: z.string().optional(),\n cable_insertion_center: point.optional(),\n metadata: z\n .object({\n kicad_footprint: kicadFootprintMetadata.optional(),\n })\n .optional(),\n obstructs_within_bounds: z\n .boolean()\n .default(true)\n .describe(\n \"Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath\",\n ),\n })\n .describe(\"Defines a component on the PCB\")\n\nexport type PcbComponentInput = z.input<typeof pcb_component>\ntype InferredPcbComponent = z.infer<typeof pcb_component>\n\n/**\n * Defines a component on the PCB\n */\nexport interface PcbComponent {\n type: \"pcb_component\"\n pcb_component_id: string\n source_component_id: string\n subcircuit_id?: string\n center: Point\n layer: LayerRef\n rotation: Rotation\n display_offset_x?: string\n display_offset_y?: string\n width: Length\n height: Length\n do_not_place?: boolean\n is_allowed_to_be_off_board?: boolean\n pcb_group_id?: string\n position_mode?:\n | \"packed\"\n | \"relative_to_group_anchor\"\n | \"relative_to_another_component\"\n | \"none\"\n anchor_position?: Point\n anchor_alignment?: NinePointAnchor\n positioned_relative_to_pcb_group_id?: string\n positioned_relative_to_pcb_board_id?: string\n cable_insertion_center?: Point\n metadata?: PcbComponentMetadata\n obstructs_within_bounds: boolean\n}\n\n/**\n * @deprecated use PcbComponent\n */\nexport type PCBComponent = PcbComponent\n\nexpectTypesMatch<PcbComponent, InferredPcbComponent>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance, rotation, type Rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nconst pcb_hole_circle = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.literal(\"circle\"),\n hole_diameter: z.number(),\n x: distance,\n y: distance,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_circle_shape = pcb_hole_circle.describe(\n \"Defines a circular hole on the PCB\",\n)\n\nexport type PcbHoleCircleInput = z.input<typeof pcb_hole_circle>\ntype InferredPcbHoleCircle = z.infer<typeof pcb_hole_circle>\n\n/**\n * Defines a circular hole on the PCB\n */\nexport interface PcbHoleCircle {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"circle\"\n hole_diameter: number\n x: Distance\n y: Distance\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexpectTypesMatch<PcbHoleCircle, InferredPcbHoleCircle>(true)\n\nconst pcb_hole_rect = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.literal(\"rect\"),\n hole_width: z.number(),\n hole_height: z.number(),\n x: distance,\n y: distance,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_rect_shape = pcb_hole_rect.describe(\n \"Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.\",\n)\n\nexport type PcbHoleRectInput = z.input<typeof pcb_hole_rect>\ntype InferredPcbHoleRect = z.infer<typeof pcb_hole_rect>\n\n/**\n * Defines a rectangular (or square) hole on the PCB\n */\nexport interface PcbHoleRect {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"rect\"\n hole_width: number\n hole_height: number\n x: Distance\n y: Distance\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\nexpectTypesMatch<PcbHoleRect, InferredPcbHoleRect>(true)\n\nconst pcb_hole_circle_or_square = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.enum([\"circle\", \"square\"]),\n hole_diameter: z.number(),\n x: distance,\n y: distance,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_circle_or_square_shape =\n pcb_hole_circle_or_square.describe(\n \"Defines a circular or square hole on the PCB\",\n )\n\nexport type PcbHoleCircleOrSquareInput = z.input<\n typeof pcb_hole_circle_or_square\n>\ntype InferredPcbHoleCircleOrSquare = z.infer<typeof pcb_hole_circle_or_square>\n\n/**\n * Defines a circular or square hole on the PCB\n */\n\n/**\n * @deprecated Use `PcbHoleCircle` for circular holes or `PcbHoleRect` for square holes.\n */\nexport interface PcbHoleCircleOrSquare {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"circle\" | \"square\"\n hole_diameter: number\n x: Distance\n y: Distance\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexpectTypesMatch<PcbHoleCircleOrSquare, InferredPcbHoleCircleOrSquare>(true)\n\nconst pcb_hole_oval = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.literal(\"oval\"),\n hole_width: z.number(),\n hole_height: z.number(),\n x: distance,\n y: distance,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_oval_shape = pcb_hole_oval.describe(\n \"Defines an oval hole on the PCB\",\n)\n\nexport type PcbHoleOvalInput = z.input<typeof pcb_hole_oval>\ntype InferredPcbHoleOval = z.infer<typeof pcb_hole_oval>\n\n/**\n * Defines an oval hole on the PCB\n */\nexport interface PcbHoleOval {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"oval\"\n hole_width: number\n hole_height: number\n x: Distance\n y: Distance\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexpectTypesMatch<PcbHoleOval, InferredPcbHoleOval>(true)\n\nconst pcb_hole_pill = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.literal(\"pill\"),\n hole_width: z.number(),\n hole_height: z.number(),\n x: distance,\n y: distance,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_pill_shape = pcb_hole_pill.describe(\n \"Defines a pill-shaped hole on the PCB\",\n)\n\nexport type PcbHolePillInput = z.input<typeof pcb_hole_pill>\ntype InferredPcbHolePill = z.infer<typeof pcb_hole_pill>\n\n/**\n * Defines a pill-shaped hole on the PCB\n */\nexport interface PcbHolePill {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"pill\"\n hole_width: number\n hole_height: number\n x: Distance\n y: Distance\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexpectTypesMatch<PcbHolePill, InferredPcbHolePill>(true)\n\nconst pcb_hole_rotated_pill = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.literal(\"rotated_pill\"),\n hole_width: z.number(),\n hole_height: z.number(),\n x: distance,\n y: distance,\n ccw_rotation: rotation,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_rotated_pill_shape = pcb_hole_rotated_pill.describe(\n \"Defines a rotated pill-shaped hole on the PCB\",\n)\n\nexport type PcbHoleRotatedPillInput = z.input<typeof pcb_hole_rotated_pill>\ntype InferredPcbHoleRotatedPill = z.infer<typeof pcb_hole_rotated_pill>\n\n/**\n * Defines a rotated pill-shaped hole on the PCB\n */\nexport interface PcbHoleRotatedPill {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"rotated_pill\"\n hole_width: number\n hole_height: number\n x: Distance\n y: Distance\n ccw_rotation: Rotation\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexpectTypesMatch<PcbHoleRotatedPill, InferredPcbHoleRotatedPill>(true)\n\nexport const pcb_hole = pcb_hole_circle_or_square\n .or(pcb_hole_oval)\n .or(pcb_hole_pill)\n .or(pcb_hole_rotated_pill)\n .or(pcb_hole_circle)\n .or(pcb_hole_rect)\n\n/**\n * @deprecated Use PcbHoleCircleOrSquare, PcbHoleCircle, PcbHoleRect, PcbHoleOval, PcbHolePill, or PcbHoleRotatedPill\n */\nexport type PCBHoleInput = z.input<typeof pcb_hole>\n/**\n * @deprecated Use PcbHoleCircleOrSquare, PcbHoleCircle, PcbHoleRect, PcbHoleOval, PcbHolePill, or PcbHoleRotatedPill\n */\nexport type PCBHole = z.infer<typeof pcb_hole>\n\nexport type PcbHole =\n | PcbHoleCircleOrSquare\n | PcbHoleOval\n | PcbHolePill\n | PcbHoleRotatedPill\n | PcbHoleCircle\n | PcbHoleRect\n","import { z } from \"zod\"\nimport { distance, type Distance, rotation, type Rotation } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nconst pcb_plated_hole_circle = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.literal(\"circle\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n outer_diameter: z.number(),\n hole_diameter: z.number(),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n})\n\n/**\n * Defines a circular plated hole on the PCB\n */\nexport interface PcbPlatedHoleCircle {\n type: \"pcb_plated_hole\"\n shape: \"circle\"\n pcb_group_id?: string\n subcircuit_id?: string\n outer_diameter: number\n hole_diameter: number\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n}\n\nconst pcb_plated_hole_oval = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.enum([\"oval\", \"pill\"]),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n outer_width: z.number(),\n outer_height: z.number(),\n hole_width: z.number(),\n hole_height: z.number(),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n ccw_rotation: rotation,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n})\n\n/**\n * Defines an oval or pill-shaped plated hole on the PCB\n */\nexport interface PcbPlatedHoleOval {\n type: \"pcb_plated_hole\"\n shape: \"oval\" | \"pill\"\n pcb_group_id?: string\n subcircuit_id?: string\n outer_width: number\n outer_height: number\n hole_width: number\n hole_height: number\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n ccw_rotation: Rotation\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n}\n\nconst pcb_circular_hole_with_rect_pad = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.literal(\"circular_hole_with_rect_pad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n hole_shape: z.literal(\"circle\"),\n pad_shape: z.literal(\"rect\"),\n hole_diameter: z.number(),\n rect_pad_width: z.number(),\n rect_pad_height: z.number(),\n rect_border_radius: z.number().optional(),\n hole_offset_x: distance.default(0),\n hole_offset_y: distance.default(0),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n rect_ccw_rotation: rotation.optional(),\n})\nconst pcb_pill_hole_with_rect_pad = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.literal(\"pill_hole_with_rect_pad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n hole_shape: z.literal(\"pill\"),\n pad_shape: z.literal(\"rect\"),\n hole_width: z.number(),\n hole_height: z.number(),\n rect_pad_width: z.number(),\n rect_pad_height: z.number(),\n rect_border_radius: z.number().optional(),\n hole_offset_x: distance.default(0),\n hole_offset_y: distance.default(0),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n})\nconst pcb_rotated_pill_hole_with_rect_pad = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.literal(\"rotated_pill_hole_with_rect_pad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n hole_shape: z.literal(\"rotated_pill\"),\n pad_shape: z.literal(\"rect\"),\n hole_width: z.number(),\n hole_height: z.number(),\n hole_ccw_rotation: rotation,\n rect_pad_width: z.number(),\n rect_pad_height: z.number(),\n rect_border_radius: z.number().optional(),\n rect_ccw_rotation: rotation,\n hole_offset_x: distance.default(0),\n hole_offset_y: distance.default(0),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n})\nexport interface PcbHolePillWithRectPad {\n type: \"pcb_plated_hole\"\n shape: \"pill_hole_with_rect_pad\"\n pcb_group_id?: string\n subcircuit_id?: string\n hole_shape: \"pill\"\n pad_shape: \"rect\"\n hole_width: number\n hole_height: number\n rect_pad_width: number\n rect_pad_height: number\n rect_border_radius?: number\n hole_offset_x: Distance\n hole_offset_y: Distance\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n}\n\nexport interface PcbHoleRotatedPillWithRectPad {\n type: \"pcb_plated_hole\"\n shape: \"rotated_pill_hole_with_rect_pad\"\n pcb_group_id?: string\n subcircuit_id?: string\n hole_shape: \"rotated_pill\"\n pad_shape: \"rect\"\n hole_width: number\n hole_height: number\n hole_ccw_rotation: Rotation\n rect_pad_width: number\n rect_pad_height: number\n rect_border_radius?: number\n rect_ccw_rotation: Rotation\n hole_offset_x: Distance\n hole_offset_y: Distance\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n}\n\nexport interface PcbHoleCircularWithRectPad {\n type: \"pcb_plated_hole\"\n shape: \"circular_hole_with_rect_pad\"\n pcb_group_id?: string\n subcircuit_id?: string\n hole_shape: \"circle\"\n pad_shape: \"rect\"\n hole_diameter: number\n rect_pad_width: number\n rect_pad_height: number\n rect_border_radius?: number\n hole_offset_x: Distance\n hole_offset_y: Distance\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n rect_ccw_rotation?: Rotation\n}\nconst pcb_hole_with_polygon_pad = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.literal(\"hole_with_polygon_pad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n hole_shape: z.enum([\"circle\", \"oval\", \"pill\", \"rotated_pill\"]),\n hole_diameter: z.number().optional(),\n hole_width: z.number().optional(),\n hole_height: z.number().optional(),\n\n pad_outline: z\n .array(\n z.object({\n x: distance,\n y: distance,\n }),\n )\n .min(3),\n\n hole_offset_x: distance.default(0),\n hole_offset_y: distance.default(0),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n ccw_rotation: rotation.optional(),\n})\n\n/**\n * Defines a plated hole with a polygonal pad on the PCB\n */\n\nexport interface PcbHoleWithPolygonPad {\n type: \"pcb_plated_hole\"\n shape: \"hole_with_polygon_pad\"\n pcb_group_id?: string\n subcircuit_id?: string\n hole_shape: \"circle\" | \"oval\" | \"pill\" | \"rotated_pill\"\n hole_diameter?: number\n hole_width?: number\n hole_height?: number\n pad_outline: { x: Distance; y: Distance }[]\n hole_offset_x: Distance\n hole_offset_y: Distance\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n ccw_rotation?: Rotation\n}\n\nexport const pcb_plated_hole = z.union([\n pcb_plated_hole_circle,\n pcb_plated_hole_oval,\n pcb_circular_hole_with_rect_pad,\n pcb_pill_hole_with_rect_pad,\n pcb_rotated_pill_hole_with_rect_pad,\n pcb_hole_with_polygon_pad,\n])\nexport type PcbPlatedHole =\n | PcbPlatedHoleCircle\n | PcbPlatedHoleOval\n | PcbHoleCircularWithRectPad\n | PcbHolePillWithRectPad\n | PcbHoleRotatedPillWithRectPad\n | PcbHoleWithPolygonPad\n\nexpectTypesMatch<PcbPlatedHoleCircle, z.infer<typeof pcb_plated_hole_circle>>(\n true,\n)\nexpectTypesMatch<PcbPlatedHoleOval, z.infer<typeof pcb_plated_hole_oval>>(true)\nexpectTypesMatch<\n PcbHoleCircularWithRectPad,\n z.infer<typeof pcb_circular_hole_with_rect_pad>\n>(true)\nexpectTypesMatch<\n PcbHolePillWithRectPad,\n z.infer<typeof pcb_pill_hole_with_rect_pad>\n>(true)\nexpectTypesMatch<\n PcbHoleRotatedPillWithRectPad,\n z.infer<typeof pcb_rotated_pill_hole_with_rect_pad>\n>(true)\nexpectTypesMatch<\n PcbHoleWithPolygonPad,\n z.infer<typeof pcb_hole_with_polygon_pad>\n>(true)\n/**\n * @deprecated use PcbPlatedHole\n */\nexport type PCBPlatedHole = PcbPlatedHole\n\n/**\n * @deprecated use PcbPlatedHoleInput\n */\nexport type PCBPlatedHoleInput = z.input<typeof pcb_plated_hole>\nexport type PcbPlatedHoleInput = z.input<typeof pcb_plated_hole>\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_port = z\n .object({\n type: z.literal(\"pcb_port\"),\n pcb_port_id: getZodPrefixedIdWithDefault(\"pcb_port\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n source_port_id: z.string(),\n pcb_component_id: z.string().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n is_board_pinout: z.boolean().optional(),\n })\n .describe(\"Defines a port on the PCB\")\n\nexport type PcbPortInput = z.input<typeof pcb_port>\ntype InferredPcbPort = z.infer<typeof pcb_port>\n\n/**\n * Defines a port on the PCB\n */\nexport interface PcbPort {\n type: \"pcb_port\"\n pcb_port_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n source_port_id: string\n pcb_component_id?: string\n x: Distance\n y: Distance\n layers: LayerRef[]\n is_board_pinout?: boolean\n}\n\n/**\n * @deprecated use PcbPort\n */\nexport type PCBPort = PcbPort\n\n/**\n * @deprecated use PcbPortInput\n */\nexport type PCBPortInput = PcbPortInput\n\nexpectTypesMatch<PcbPort, InferredPcbPort>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance, rotation, type Rotation } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { getZodPrefixedIdWithDefault, point, type Point } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nconst pcb_smtpad_circle = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"circle\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n radius: z.number(),\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nconst pcb_smtpad_rect = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"rect\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n rect_border_radius: z.number().optional(),\n corner_radius: z.number().optional(),\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n soldermask_margin_left: z.number().optional(),\n soldermask_margin_top: z.number().optional(),\n soldermask_margin_right: z.number().optional(),\n soldermask_margin_bottom: z.number().optional(),\n})\n\nconst pcb_smtpad_rotated_rect = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"rotated_rect\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n rect_border_radius: z.number().optional(),\n corner_radius: z.number().optional(),\n ccw_rotation: rotation,\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n soldermask_margin_left: z.number().optional(),\n soldermask_margin_top: z.number().optional(),\n soldermask_margin_right: z.number().optional(),\n soldermask_margin_bottom: z.number().optional(),\n})\n\nexport const pcb_smtpad_pill = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"pill\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n radius: z.number(),\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\nconst pcb_smtpad_rotated_pill = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"rotated_pill\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n radius: z.number(),\n ccw_rotation: rotation,\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nconst pcb_smtpad_polygon = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"polygon\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n points: z.array(point),\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_smtpad = z\n .discriminatedUnion(\"shape\", [\n pcb_smtpad_circle,\n pcb_smtpad_rect,\n pcb_smtpad_rotated_rect,\n pcb_smtpad_rotated_pill,\n pcb_smtpad_pill,\n pcb_smtpad_polygon,\n ])\n .describe(\"Defines an SMT pad on the PCB\")\n\nexport type PCBSMTPadInput = z.input<typeof pcb_smtpad>\ntype PCBSMTPadCircle = z.infer<typeof pcb_smtpad_circle>\ntype PCBSMTPadRect = z.infer<typeof pcb_smtpad_rect>\ntype PCBSMTPadRotatedRect = z.infer<typeof pcb_smtpad_rotated_rect>\ntype PCBSMTPadRotatedPill = z.infer<typeof pcb_smtpad_rotated_pill>\ntype PCBSMTPadPill = z.infer<typeof pcb_smtpad_pill>\ntype PCBSMTPadPolygon = z.infer<typeof pcb_smtpad_polygon>\n\n/**\n * Defines a circular SMT pad on the PCB\n */\nexport interface PcbSmtPadCircle {\n type: \"pcb_smtpad\"\n shape: \"circle\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n radius: number\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\n/**\n * Defines a rectangular SMT pad on the PCB\n */\nexport interface PcbSmtPadRect {\n type: \"pcb_smtpad\"\n shape: \"rect\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n rect_border_radius?: number\n corner_radius?: number\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n soldermask_margin_left?: number\n soldermask_margin_top?: number\n soldermask_margin_right?: number\n soldermask_margin_bottom?: number\n}\n\n/**\n * Defines a rotated rectangular SMT pad on the PCB\n */\nexport interface PcbSmtPadRotatedRect {\n type: \"pcb_smtpad\"\n shape: \"rotated_rect\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n rect_border_radius?: number\n corner_radius?: number\n ccw_rotation: Rotation\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n soldermask_margin_left?: number\n soldermask_margin_top?: number\n soldermask_margin_right?: number\n soldermask_margin_bottom?: number\n}\n/**\n * Defines a pill-shaped SMT pad on the PCB (rounded rectangle).\n */\nexport interface PcbSmtPadPill {\n type: \"pcb_smtpad\"\n shape: \"pill\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n radius: number\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\n/**\n * Defines a rotated pill-shaped SMT pad on the PCB\n */\nexport interface PcbSmtPadRotatedPill {\n type: \"pcb_smtpad\"\n shape: \"rotated_pill\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n radius: number\n ccw_rotation: Rotation\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\n/**\n * Defines a polygonal SMT pad on the PCB\n */\nexport interface PcbSmtPadPolygon {\n type: \"pcb_smtpad\"\n shape: \"polygon\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n points: Point[]\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexport type PcbSmtPad =\n | PcbSmtPadCircle\n | PcbSmtPadRect\n | PcbSmtPadRotatedRect\n | PcbSmtPadRotatedPill\n | PcbSmtPadPill\n | PcbSmtPadPolygon\n\n/**\n * @deprecated use PcbSmtPad\n */\nexport type PCBSMTPad = PcbSmtPad\n\nexpectTypesMatch<PcbSmtPadCircle, PCBSMTPadCircle>(true)\nexpectTypesMatch<PcbSmtPadRect, PCBSMTPadRect>(true)\nexpectTypesMatch<PcbSmtPadRotatedRect, PCBSMTPadRotatedRect>(true)\nexpectTypesMatch<PcbSmtPadRotatedPill, PCBSMTPadRotatedPill>(true)\nexpectTypesMatch<PcbSmtPadPill, PCBSMTPadPill>(true)\nexpectTypesMatch<PcbSmtPadPolygon, PCBSMTPadPolygon>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nconst pcb_solder_paste_circle = z.object({\n type: z.literal(\"pcb_solder_paste\"),\n shape: z.literal(\"circle\"),\n pcb_solder_paste_id: getZodPrefixedIdWithDefault(\"pcb_solder_paste\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n radius: z.number(),\n layer: layer_ref,\n pcb_component_id: z.string().optional(),\n pcb_smtpad_id: z.string().optional(),\n})\n\nconst pcb_solder_paste_rect = z.object({\n type: z.literal(\"pcb_solder_paste\"),\n shape: z.literal(\"rect\"),\n pcb_solder_paste_id: getZodPrefixedIdWithDefault(\"pcb_solder_paste\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n layer: layer_ref,\n pcb_component_id: z.string().optional(),\n pcb_smtpad_id: z.string().optional(),\n})\nconst pcb_solder_paste_pill = z.object({\n type: z.literal(\"pcb_solder_paste\"),\n shape: z.literal(\"pill\"),\n pcb_solder_paste_id: getZodPrefixedIdWithDefault(\"pcb_solder_paste\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n radius: z.number(),\n layer: layer_ref,\n pcb_component_id: z.string().optional(),\n pcb_smtpad_id: z.string().optional(),\n})\nconst pcb_solder_paste_rotated_rect = z.object({\n type: z.literal(\"pcb_solder_paste\"),\n shape: z.literal(\"rotated_rect\"),\n pcb_solder_paste_id: getZodPrefixedIdWithDefault(\"pcb_solder_paste\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n ccw_rotation: distance,\n layer: layer_ref,\n pcb_component_id: z.string().optional(),\n pcb_smtpad_id: z.string().optional(),\n})\n\nconst pcb_solder_paste_oval = z.object({\n type: z.literal(\"pcb_solder_paste\"),\n shape: z.literal(\"oval\"),\n pcb_solder_paste_id: getZodPrefixedIdWithDefault(\"pcb_solder_paste\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n layer: layer_ref,\n pcb_component_id: z.string().optional(),\n pcb_smtpad_id: z.string().optional(),\n})\n\nexport const pcb_solder_paste = z\n .union([\n pcb_solder_paste_circle,\n pcb_solder_paste_rect,\n pcb_solder_paste_pill,\n pcb_solder_paste_rotated_rect,\n pcb_solder_paste_oval,\n ])\n .describe(\"Defines solderpaste on the PCB\")\n\nexport type PCBSolderPasteInput = z.input<typeof pcb_solder_paste>\ntype InferredPcbSolderPasteCircle = z.infer<typeof pcb_solder_paste_circle>\ntype InferredPcbSolderPasteRect = z.infer<typeof pcb_solder_paste_rect>\ntype InferredPcbSolderPastePill = z.infer<typeof pcb_solder_paste_pill>\ntype InferredPcbSolderPasteRotatedRect = z.infer<\n typeof pcb_solder_paste_rotated_rect\n>\ntype InferredPcbSolderPasteOval = z.infer<typeof pcb_solder_paste_oval>\n\n/**\n * Defines solderpaste on the PCB\n */\nexport interface PcbSolderPasteCircle {\n type: \"pcb_solder_paste\"\n shape: \"circle\"\n pcb_solder_paste_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n radius: number\n layer: LayerRef\n pcb_component_id?: string\n pcb_smtpad_id?: string\n}\n\n/**\n * Defines solderpaste on the PCB\n */\nexport interface PcbSolderPasteRect {\n type: \"pcb_solder_paste\"\n shape: \"rect\"\n pcb_solder_paste_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n layer: LayerRef\n pcb_component_id?: string\n pcb_smtpad_id?: string\n}\n/**\n * Defines solderpaste on the PCB\n */\nexport interface PcbSolderPastePill {\n type: \"pcb_solder_paste\"\n shape: \"pill\"\n pcb_solder_paste_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n radius: number\n layer: LayerRef\n pcb_component_id?: string\n pcb_smtpad_id?: string\n}\n/**\n * Defines solderpaste on the PCB\n */\nexport interface PcbSolderPasteRotatedRect {\n type: \"pcb_solder_paste\"\n shape: \"rotated_rect\"\n pcb_solder_paste_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n ccw_rotation: Distance\n layer: LayerRef\n pcb_component_id?: string\n pcb_smtpad_id?: string\n}\n/**\n * Defines solderpaste on the PCB\n */\nexport interface PcbSolderPasteOval {\n type: \"pcb_solder_paste\"\n shape: \"oval\"\n pcb_solder_paste_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n layer: LayerRef\n pcb_component_id?: string\n pcb_smtpad_id?: string\n}\n\nexport type PcbSolderPaste =\n | PcbSolderPasteCircle\n | PcbSolderPasteRect\n | PcbSolderPastePill\n | PcbSolderPasteRotatedRect\n | PcbSolderPasteOval\n\nexpectTypesMatch<PcbSolderPasteCircle, InferredPcbSolderPasteCircle>(true)\nexpectTypesMatch<PcbSolderPasteRect, InferredPcbSolderPasteRect>(true)\nexpectTypesMatch<PcbSolderPastePill, InferredPcbSolderPastePill>(true)\nexpectTypesMatch<PcbSolderPasteRotatedRect, InferredPcbSolderPasteRotatedRect>(\n true,\n)\nexpectTypesMatch<PcbSolderPasteOval, InferredPcbSolderPasteOval>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_text = z\n .object({\n type: z.literal(\"pcb_text\"),\n pcb_text_id: getZodPrefixedIdWithDefault(\"pcb_text\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n text: z.string(),\n center: point,\n layer: layer_ref,\n width: length,\n height: length,\n lines: z.number(),\n // @ts-ignore\n align: z.enum([\"bottom-left\"]),\n })\n .describe(\"Defines text on the PCB\")\n\nexport type PcbTextInput = z.input<typeof pcb_text>\ntype InferredPcbText = z.infer<typeof pcb_text>\n\n/**\n * Defines text on the PCB\n */\nexport interface PcbText {\n type: \"pcb_text\"\n pcb_text_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n text: string\n center: Point\n layer: LayerRef\n width: Length\n height: Length\n lines: number\n // @ts-ignore\n align: \"bottom-left\"\n}\n\n/**\n * @deprecated use PcbText\n */\nexport type PCBText = PcbText\n\nexpectTypesMatch<PcbText, InferredPcbText>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_trace_route_point_wire = z.object({\n route_type: z.literal(\"wire\"),\n x: distance,\n y: distance,\n width: distance,\n copper_pour_id: z.string().optional(),\n is_inside_copper_pour: z.boolean().optional(),\n start_pcb_port_id: z.string().optional(),\n end_pcb_port_id: z.string().optional(),\n layer: layer_ref,\n})\n\nexport const pcb_trace_route_point_via = z.object({\n route_type: z.literal(\"via\"),\n x: distance,\n y: distance,\n copper_pour_id: z.string().optional(),\n is_inside_copper_pour: z.boolean().optional(),\n hole_diameter: distance.optional(),\n outer_diameter: distance.optional(),\n from_layer: z.string(),\n to_layer: z.string(),\n})\n\nexport const pcb_trace_route_point = z.union([\n pcb_trace_route_point_wire,\n pcb_trace_route_point_via,\n])\ntype InferredPcbTraceRoutePoint = z.infer<typeof pcb_trace_route_point>\n\nexport const pcb_trace = z\n .object({\n type: z.literal(\"pcb_trace\"),\n source_trace_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n pcb_trace_id: getZodPrefixedIdWithDefault(\"pcb_trace\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n route_thickness_mode: z\n .enum([\"constant\", \"interpolated\"])\n .default(\"constant\")\n .optional(),\n route_order_index: z.number().optional(),\n should_round_corners: z.boolean().optional(),\n trace_length: z.number().optional(),\n highlight_color: z.string().optional(),\n route: z.array(pcb_trace_route_point),\n })\n .describe(\"Defines a trace on the PCB\")\n\nexport type PcbTraceInput = z.input<typeof pcb_trace>\ntype InferredPcbTrace = z.infer<typeof pcb_trace>\n\nexport interface PcbTraceRoutePointWire {\n route_type: \"wire\"\n x: Distance\n y: Distance\n width: Distance\n copper_pour_id?: string\n is_inside_copper_pour?: boolean\n start_pcb_port_id?: string\n end_pcb_port_id?: string\n layer: LayerRef\n}\n\nexport interface PcbTraceRoutePointVia {\n route_type: \"via\"\n x: Distance\n y: Distance\n copper_pour_id?: string\n is_inside_copper_pour?: boolean\n hole_diameter?: Distance\n outer_diameter?: Distance\n from_layer: string\n to_layer: string\n}\n\nexport type PcbTraceRoutePoint = PcbTraceRoutePointWire | PcbTraceRoutePointVia\n\n/**\n * Defines a trace on the PCB\n */\nexport interface PcbTrace {\n type: \"pcb_trace\"\n source_trace_id?: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_trace_id: string\n /**\n * The order that this trace was routed in. This can be used to debug the\n * autorouter and to understand the trace path better\n *\n * The route_order_index should be relative to a subcircuit\n */\n route_order_index?: number\n route_thickness_mode?: \"constant\" | \"interpolated\"\n should_round_corners?: boolean\n trace_length?: number\n highlight_color?: string\n route: Array<PcbTraceRoutePoint>\n}\n\n/**\n * @deprecated use PcbTrace\n */\nexport type PCBTrace = PcbTrace\n\n/**\n * @deprecated use PcbTraceInput\n */\nexport type PCBTraceInput = PcbTraceInput\n\nexpectTypesMatch<PcbTraceRoutePoint, InferredPcbTraceRoutePoint>(true)\nexpectTypesMatch<PcbTrace, InferredPcbTrace>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_trace_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_trace_error\"),\n pcb_trace_error_id: getZodPrefixedIdWithDefault(\"pcb_trace_error\"),\n error_type: z.literal(\"pcb_trace_error\").default(\"pcb_trace_error\"),\n center: point.optional(),\n pcb_trace_id: z.string(),\n source_trace_id: z.string(),\n pcb_component_ids: z.array(z.string()),\n pcb_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a trace error on the PCB\")\n\nexport type PcbTraceErrorInput = z.input<typeof pcb_trace_error>\ntype InferredPcbTraceError = z.infer<typeof pcb_trace_error>\n\n/**\n * Defines a trace error on the PCB\n */\nexport interface PcbTraceError extends BaseCircuitJsonError {\n type: \"pcb_trace_error\"\n pcb_trace_error_id: string\n error_type: \"pcb_trace_error\"\n center?: Point\n pcb_trace_id: string\n source_trace_id: string\n pcb_component_ids: string[]\n pcb_port_ids: string[]\n subcircuit_id?: string\n}\n\n/**\n * @deprecated use PcbTraceError\n */\nexport type PCBTraceError = PcbTraceError\n\nexpectTypesMatch<PcbTraceError, InferredPcbTraceError>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_trace_missing_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_trace_missing_error\"),\n pcb_trace_missing_error_id: getZodPrefixedIdWithDefault(\n \"pcb_trace_missing_error\",\n ),\n error_type: z\n .literal(\"pcb_trace_missing_error\")\n .default(\"pcb_trace_missing_error\"),\n center: point.optional(),\n source_trace_id: z.string(),\n pcb_component_ids: z.array(z.string()),\n pcb_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Defines an error when a source trace has no corresponding PCB trace\",\n )\n\nexport type PcbTraceMissingErrorInput = z.input<typeof pcb_trace_missing_error>\ntype InferredPcbTraceMissingError = z.infer<typeof pcb_trace_missing_error>\n\n/**\n * Defines an error when a source trace has no corresponding PCB trace\n */\nexport interface PcbTraceMissingError extends BaseCircuitJsonError {\n type: \"pcb_trace_missing_error\"\n pcb_trace_missing_error_id: string\n error_type: \"pcb_trace_missing_error\"\n center?: Point\n source_trace_id: string\n pcb_component_ids: string[]\n pcb_port_ids: string[]\n subcircuit_id?: string\n}\n\n/**\n * @deprecated use PcbTraceMissingError\n */\nexport type PCBTraceMissingError = PcbTraceMissingError\n\nexpectTypesMatch<PcbTraceMissingError, InferredPcbTraceMissingError>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_port_not_matched_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_port_not_matched_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_error\"),\n error_type: z\n .literal(\"pcb_port_not_matched_error\")\n .default(\"pcb_port_not_matched_error\"),\n pcb_component_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a trace error on the PCB where a port is not matched\")\n\nexport type PcbPortNotMatchedErrorInput = z.input<\n typeof pcb_port_not_matched_error\n>\ntype InferredPcbPortNotMatchedError = z.infer<typeof pcb_port_not_matched_error>\n\n/**\n * Defines a trace error on the PCB where a port is not matched\n */\nexport interface PcbPortNotMatchedError extends BaseCircuitJsonError {\n type: \"pcb_port_not_matched_error\"\n pcb_error_id: string\n error_type: \"pcb_port_not_matched_error\"\n pcb_component_ids: string[]\n subcircuit_id?: string\n}\n\n/**\n * @deprecated use PcbPortNotMatchedError\n */\nexport type PCBPortNotMatchedError = PcbPortNotMatchedError\n\nexpectTypesMatch<PcbPortNotMatchedError, InferredPcbPortNotMatchedError>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_port_not_connected_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_port_not_connected_error\"),\n pcb_port_not_connected_error_id: getZodPrefixedIdWithDefault(\n \"pcb_port_not_connected_error\",\n ),\n error_type: z\n .literal(\"pcb_port_not_connected_error\")\n .default(\"pcb_port_not_connected_error\"),\n pcb_port_ids: z.array(z.string()),\n pcb_component_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines an error when a pcb port is not connected to any trace\")\n\nexport type PcbPortNotConnectedErrorInput = z.input<\n typeof pcb_port_not_connected_error\n>\ntype InferredPcbPortNotConnectedError = z.infer<\n typeof pcb_port_not_connected_error\n>\n\n/**\n * Defines an error when a pcb port is not connected to any trace\n */\nexport interface PcbPortNotConnectedError extends BaseCircuitJsonError {\n type: \"pcb_port_not_connected_error\"\n pcb_port_not_connected_error_id: string\n error_type: \"pcb_port_not_connected_error\"\n pcb_port_ids: string[]\n pcb_component_ids: string[]\n subcircuit_id?: string\n}\n\nexpectTypesMatch<PcbPortNotConnectedError, InferredPcbPortNotConnectedError>(\n true,\n)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_net = z\n .object({\n type: z.literal(\"pcb_net\"),\n pcb_net_id: getZodPrefixedIdWithDefault(\"pcb_net\"),\n source_net_id: z.string().optional(),\n highlight_color: z.string().optional(),\n })\n .describe(\"Defines a net on the PCB\")\n\nexport type PcbNetInput = z.input<typeof pcb_net>\ntype InferredPcbNet = z.infer<typeof pcb_net>\n\n/**\n * Defines a net on the PCB\n */\nexport interface PcbNet {\n type: \"pcb_net\"\n pcb_net_id: string\n source_net_id?: string\n highlight_color?: string\n}\n\nexpectTypesMatch<PcbNet, InferredPcbNet>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_via = z\n .object({\n type: z.literal(\"pcb_via\"),\n pcb_via_id: getZodPrefixedIdWithDefault(\"pcb_via\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n subcircuit_connectivity_map_key: z.string().optional(),\n x: distance,\n y: distance,\n outer_diameter: distance.default(\"0.6mm\"),\n hole_diameter: distance.default(\"0.25mm\"),\n /** @deprecated */\n from_layer: layer_ref.optional(),\n /** @deprecated */\n to_layer: layer_ref.optional(),\n layers: z.array(layer_ref),\n pcb_trace_id: z.string().optional(),\n net_is_assignable: z.boolean().optional(),\n net_assigned: z.boolean().optional(),\n is_tented: z.boolean().optional(),\n })\n .describe(\"Defines a via on the PCB\")\n\nexport type PcbViaInput = z.input<typeof pcb_via>\ntype InferredPcbVia = z.infer<typeof pcb_via>\n\n/**\n * Defines a via on the PCB\n */\nexport interface PcbVia {\n type: \"pcb_via\"\n pcb_via_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n subcircuit_connectivity_map_key?: string\n x: Distance\n y: Distance\n outer_diameter: Distance\n hole_diameter: Distance\n /** @deprecated */\n from_layer?: LayerRef\n /** @deprecated */\n to_layer?: LayerRef\n layers: LayerRef[]\n pcb_trace_id?: string\n net_is_assignable?: boolean\n net_assigned?: boolean\n is_tented?: boolean\n}\n\n/**\n * @deprecated use PcbVia\n */\nexport type PCBVia = PcbVia\n\nexpectTypesMatch<PcbVia, InferredPcbVia>(true)\n","import { z } from \"zod\"\nimport {\n point,\n type Point,\n getZodPrefixedIdWithDefault,\n ninePointAnchor,\n type NinePointAnchor,\n} from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_board = z\n .object({\n type: z.literal(\"pcb_board\"),\n pcb_board_id: getZodPrefixedIdWithDefault(\"pcb_board\"),\n pcb_panel_id: z.string().optional(),\n carrier_pcb_board_id: z.string().optional(),\n is_subcircuit: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n is_mounted_to_carrier_board: z.boolean().optional(),\n width: length.optional(),\n height: length.optional(),\n center: point,\n display_offset_x: z\n .string()\n .optional()\n .describe(\n \"How to display the x offset for this board, usually corresponding with how the user specified it\",\n ),\n display_offset_y: z\n .string()\n .optional()\n .describe(\n \"How to display the y offset for this board, usually corresponding with how the user specified it\",\n ),\n thickness: length.optional().default(1.4),\n num_layers: z.number().optional().default(4),\n outline: z.array(point).optional(),\n shape: z.enum([\"rect\", \"polygon\"]).optional(),\n material: z.enum([\"fr4\", \"fr1\"]).default(\"fr4\"),\n anchor_position: point.optional(),\n anchor_alignment: ninePointAnchor.optional(),\n position_mode: z.enum([\"relative_to_panel_anchor\", \"none\"]).optional(),\n })\n .describe(\"Defines the board outline of the PCB\")\n\n/**\n * Defines the board outline of the PCB\n */\nexport interface PcbBoard {\n type: \"pcb_board\"\n pcb_board_id: string\n pcb_panel_id?: string\n carrier_pcb_board_id?: string\n is_subcircuit?: boolean\n subcircuit_id?: string\n is_mounted_to_carrier_board?: boolean\n width?: Length\n height?: Length\n display_offset_x?: string\n display_offset_y?: string\n thickness: Length\n num_layers: number\n center: Point\n outline?: Point[]\n shape?: \"rect\" | \"polygon\"\n material: \"fr4\" | \"fr1\"\n anchor_position?: Point\n anchor_alignment?: NinePointAnchor\n position_mode?: \"relative_to_panel_anchor\" | \"none\"\n}\n\nexport type PcbBoardInput = z.input<typeof pcb_board>\ntype InferredPcbBoard = z.infer<typeof pcb_board>\n\n/**\n * @deprecated use PcbBoard\n */\nexport type PCBBoard = PcbBoard\n\nexpectTypesMatch<PcbBoard, InferredPcbBoard>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault, point, type Point } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_panel = z\n .object({\n type: z.literal(\"pcb_panel\"),\n pcb_panel_id: getZodPrefixedIdWithDefault(\"pcb_panel\"),\n width: length,\n height: length,\n center: point,\n covered_with_solder_mask: z.boolean().optional().default(true),\n })\n .describe(\"Defines a PCB panel that can contain multiple boards\")\n\n/**\n * Defines a PCB panel that can contain multiple boards\n */\nexport interface PcbPanel {\n type: \"pcb_panel\"\n pcb_panel_id: string\n width: Length\n height: Length\n center: Point\n covered_with_solder_mask: boolean\n}\n\nexport type PcbPanelInput = z.input<typeof pcb_panel>\ntype InferredPcbPanel = z.infer<typeof pcb_panel>\n\n/**\n * @deprecated use PcbPanel\n */\nexport type PCBPanel = PcbPanel\n\nexpectTypesMatch<PcbPanel, InferredPcbPanel>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_placement_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_placement_error\"),\n pcb_placement_error_id: getZodPrefixedIdWithDefault(\"pcb_placement_error\"),\n error_type: z.literal(\"pcb_placement_error\").default(\"pcb_placement_error\"),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a placement error on the PCB\")\n\nexport type PcbPlacementErrorInput = z.input<typeof pcb_placement_error>\ntype InferredPcbPlacementError = z.infer<typeof pcb_placement_error>\n\n/**\n * Defines a placement error on the PCB\n */\nexport interface PcbPlacementError extends BaseCircuitJsonError {\n type: \"pcb_placement_error\"\n pcb_placement_error_id: string\n error_type: \"pcb_placement_error\"\n subcircuit_id?: string\n}\n\n/**\n * @deprecated use PcbPlacementError\n */\nexport type PCBPlacementError = PcbPlacementError\n\nexpectTypesMatch<PcbPlacementError, InferredPcbPlacementError>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_panelization_placement_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_panelization_placement_error\"),\n pcb_panelization_placement_error_id: getZodPrefixedIdWithDefault(\n \"pcb_panelization_placement_error\",\n ),\n error_type: z\n .literal(\"pcb_panelization_placement_error\")\n .default(\"pcb_panelization_placement_error\"),\n pcb_panel_id: z.string().optional(),\n pcb_board_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a panelization placement error on the PCB\")\n\nexport type PcbPanelizationPlacementErrorInput = z.input<\n typeof pcb_panelization_placement_error\n>\ntype InferredPcbPanelizationPlacementError = z.infer<\n typeof pcb_panelization_placement_error\n>\n\n/**\n * Defines a panelization placement error on the PCB\n */\nexport interface PcbPanelizationPlacementError extends BaseCircuitJsonError {\n type: \"pcb_panelization_placement_error\"\n pcb_panelization_placement_error_id: string\n error_type: \"pcb_panelization_placement_error\"\n pcb_panel_id?: string\n pcb_board_id?: string\n subcircuit_id?: string\n}\n\n/**\n * @deprecated use PcbPanelizationPlacementError\n */\nexport type PCBPanelizationPlacementError = PcbPanelizationPlacementError\n\nexpectTypesMatch<\n PcbPanelizationPlacementError,\n InferredPcbPanelizationPlacementError\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { route_hint_point, type RouteHintPoint } from \"src/pcb\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/**\n * A hint that can be used during generation of a PCB trace.\n */\nexport interface PcbTraceHint {\n type: \"pcb_trace_hint\"\n pcb_trace_hint_id: string\n pcb_port_id: string\n pcb_component_id: string\n route: RouteHintPoint[]\n subcircuit_id?: string\n}\n\nexport const pcb_trace_hint = z\n .object({\n type: z.literal(\"pcb_trace_hint\"),\n pcb_trace_hint_id: getZodPrefixedIdWithDefault(\"pcb_trace_hint\"),\n pcb_port_id: z.string(),\n pcb_component_id: z.string(),\n route: z.array(route_hint_point),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"A hint that can be used during generation of a PCB trace\")\n\nexport type PcbTraceHintInput = z.input<typeof pcb_trace_hint>\ntype InferredPcbTraceHint = z.infer<typeof pcb_trace_hint>\n\n/**\n * @deprecated use PcbTraceHint\n */\nexport type PCBTraceHint = PcbTraceHint\n\nexpectTypesMatch<PcbTraceHint, InferredPcbTraceHint>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport {\n layer_ref,\n type LayerRef,\n type VisibleLayer,\n visible_layer,\n} from \"src/pcb/properties/layer_ref\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_line = z\n .object({\n type: z.literal(\"pcb_silkscreen_line\"),\n pcb_silkscreen_line_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_line\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n stroke_width: distance.default(\"0.1mm\"),\n x1: distance,\n y1: distance,\n x2: distance,\n y2: distance,\n layer: visible_layer,\n })\n .describe(\"Defines a silkscreen line on the PCB\")\n\nexport type PcbSilkscreenLineInput = z.input<typeof pcb_silkscreen_line>\ntype InferredPcbSilkscreenLine = z.infer<typeof pcb_silkscreen_line>\n\n/**\n * Defines a silkscreen line on the PCB\n */\nexport interface PcbSilkscreenLine {\n type: \"pcb_silkscreen_line\"\n pcb_silkscreen_line_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n stroke_width: Distance\n x1: Distance\n y1: Distance\n x2: Distance\n y2: Distance\n layer: VisibleLayer\n}\n\n/**\n * @deprecated use PcbSilkscreenLine\n */\nexport type PCBSilkscreenLine = PcbSilkscreenLine\n\nexpectTypesMatch<PcbSilkscreenLine, InferredPcbSilkscreenLine>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport {\n visible_layer,\n type VisibleLayerRef,\n} from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_path = z\n .object({\n type: z.literal(\"pcb_silkscreen_path\"),\n pcb_silkscreen_path_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_path\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: visible_layer,\n route: z.array(point),\n stroke_width: length,\n })\n .describe(\"Defines a silkscreen path on the PCB\")\n\nexport type PcbSilkscreenPathInput = z.input<typeof pcb_silkscreen_path>\ntype InferredPcbSilkscreenPath = z.infer<typeof pcb_silkscreen_path>\n\n/**\n * Defines a silkscreen path on the PCB\n */\nexport interface PcbSilkscreenPath {\n type: \"pcb_silkscreen_path\"\n pcb_silkscreen_path_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n layer: VisibleLayerRef\n route: Point[]\n stroke_width: Length\n}\n\n/**\n * @deprecated use PcbSilkscreenPath\n */\nexport type PcbSilkscreenPathDeprecated = PcbSilkscreenPath\n\nexpectTypesMatch<PcbSilkscreenPath, InferredPcbSilkscreenPath>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { distance, length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n ninePointAnchor,\n type NinePointAnchor,\n} from \"src/common/NinePointAnchor\"\n\nexport const pcb_silkscreen_text = z\n .object({\n type: z.literal(\"pcb_silkscreen_text\"),\n pcb_silkscreen_text_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_text\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: distance.default(\"0.2mm\"),\n pcb_component_id: z.string(),\n text: z.string(),\n is_knockout: z.boolean().default(false).optional(),\n knockout_padding: z\n .object({\n left: length,\n top: length,\n bottom: length,\n right: length,\n })\n .default({\n left: \"0.2mm\",\n top: \"0.2mm\",\n bottom: \"0.2mm\",\n right: \"0.2mm\",\n })\n .optional(),\n ccw_rotation: z.number().optional(),\n layer: layer_ref,\n is_mirrored: z.boolean().default(false).optional(),\n anchor_position: point.default({ x: 0, y: 0 }),\n anchor_alignment: ninePointAnchor.default(\"center\"),\n })\n .describe(\"Defines silkscreen text on the PCB\")\n\nexport type PcbSilkscreenTextInput = z.input<typeof pcb_silkscreen_text>\ntype InferredPcbSilkscreenText = z.infer<typeof pcb_silkscreen_text>\n\n/**\n * Defines silkscreen text on the PCB\n */\nexport interface PcbSilkscreenText {\n type: \"pcb_silkscreen_text\"\n pcb_silkscreen_text_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n font: \"tscircuit2024\"\n font_size: Length\n pcb_component_id: string\n text: string\n is_knockout?: boolean\n knockout_padding?: {\n left: Length\n top: Length\n bottom: Length\n right: Length\n }\n ccw_rotation?: number\n layer: LayerRef\n is_mirrored?: boolean\n anchor_position: Point\n anchor_alignment: NinePointAnchor\n}\n\n/**\n * @deprecated use PcbSilkscreenText\n */\nexport type PCBSilkscreenText = PcbSilkscreenText\n\nexpectTypesMatch<PcbSilkscreenText, InferredPcbSilkscreenText>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { distance, length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n ninePointAnchor,\n type NinePointAnchor,\n} from \"src/common/NinePointAnchor\"\n\nexport const pcb_copper_text = z\n .object({\n type: z.literal(\"pcb_copper_text\"),\n pcb_copper_text_id: getZodPrefixedIdWithDefault(\"pcb_copper_text\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: distance.default(\"0.2mm\"),\n pcb_component_id: z.string(),\n text: z.string(),\n is_knockout: z.boolean().default(false).optional(),\n knockout_padding: z\n .object({\n left: length,\n top: length,\n bottom: length,\n right: length,\n })\n .default({\n left: \"0.2mm\",\n top: \"0.2mm\",\n bottom: \"0.2mm\",\n right: \"0.2mm\",\n })\n .optional(),\n ccw_rotation: z.number().optional(),\n layer: layer_ref,\n is_mirrored: z.boolean().default(false).optional(),\n anchor_position: point.default({ x: 0, y: 0 }),\n anchor_alignment: ninePointAnchor.default(\"center\"),\n })\n .describe(\"Defines copper text on the PCB\")\n\nexport type PcbCopperTextInput = z.input<typeof pcb_copper_text>\ntype InferredPcbCopperText = z.infer<typeof pcb_copper_text>\n\n/**\n * Defines copper text on the PCB\n */\nexport interface PcbCopperText {\n type: \"pcb_copper_text\"\n pcb_copper_text_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n font: \"tscircuit2024\"\n font_size: Length\n pcb_component_id: string\n text: string\n is_knockout?: boolean\n knockout_padding?: {\n left: Length\n top: Length\n bottom: Length\n right: Length\n }\n ccw_rotation?: number\n layer: LayerRef\n is_mirrored?: boolean\n anchor_position: Point\n anchor_alignment: NinePointAnchor\n}\n\n/**\n * @deprecated use PcbCopperText\n */\nexport type PCBCopperText = PcbCopperText\n\nexpectTypesMatch<PcbCopperText, InferredPcbCopperText>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_rect = z\n .object({\n type: z.literal(\"pcb_silkscreen_rect\"),\n pcb_silkscreen_rect_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_rect\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n width: length,\n height: length,\n layer: layer_ref,\n stroke_width: length.default(\"1mm\"),\n corner_radius: length.optional(),\n is_filled: z.boolean().default(true).optional(),\n has_stroke: z.boolean().optional(),\n is_stroke_dashed: z.boolean().optional(),\n ccw_rotation: z.number().optional(),\n })\n .describe(\"Defines a silkscreen rect on the PCB\")\n\nexport type PcbSilkscreenRectInput = z.input<typeof pcb_silkscreen_rect>\ntype InferredPcbSilkscreenRect = z.infer<typeof pcb_silkscreen_rect>\n\n/**\n * Defines a silkscreen rect on the PCB\n */\nexport interface PcbSilkscreenRect {\n type: \"pcb_silkscreen_rect\"\n pcb_silkscreen_rect_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n width: Length\n height: Length\n layer: LayerRef\n stroke_width: Length\n corner_radius?: Length\n is_filled?: boolean\n has_stroke?: boolean\n is_stroke_dashed?: boolean\n ccw_rotation?: number\n}\n\n/**\n * @deprecated use PcbSilkscreenRect\n */\nexport type PcbSilkscreenRectOld = PcbSilkscreenRect\n\nexpectTypesMatch<PcbSilkscreenRect, InferredPcbSilkscreenRect>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport {\n layer_ref,\n visible_layer,\n type LayerRef,\n type VisibleLayer,\n} from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_circle = z\n .object({\n type: z.literal(\"pcb_silkscreen_circle\"),\n pcb_silkscreen_circle_id: getZodPrefixedIdWithDefault(\n \"pcb_silkscreen_circle\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n radius: length,\n layer: visible_layer,\n stroke_width: length.default(\"1mm\"),\n })\n .describe(\"Defines a silkscreen circle on the PCB\")\n\nexport type PcbSilkscreenCircleInput = z.input<typeof pcb_silkscreen_circle>\ntype InferredPcbSilkscreenCircle = z.infer<typeof pcb_silkscreen_circle>\n\n/**\n * Defines a silkscreen circle on the PCB\n */\nexport interface PcbSilkscreenCircle {\n type: \"pcb_silkscreen_circle\"\n pcb_silkscreen_circle_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n radius: Length\n layer: VisibleLayer\n stroke_width: Length\n}\n\nexpectTypesMatch<PcbSilkscreenCircle, InferredPcbSilkscreenCircle>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport {\n layer_ref,\n type LayerRef,\n visible_layer,\n type VisibleLayer,\n} from \"src/pcb/properties/layer_ref\"\nimport { distance, rotation, type Distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_oval = z\n .object({\n type: z.literal(\"pcb_silkscreen_oval\"),\n pcb_silkscreen_oval_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_oval\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n radius_x: distance,\n radius_y: distance,\n layer: visible_layer,\n ccw_rotation: rotation.optional(),\n })\n .describe(\"Defines a silkscreen oval on the PCB\")\n\nexport type PcbSilkscreenOvalInput = z.input<typeof pcb_silkscreen_oval>\ntype InferredPcbSilkscreenOval = z.infer<typeof pcb_silkscreen_oval>\n\n/**\n * Defines a silkscreen oval on the PCB\n */\nexport interface PcbSilkscreenOval {\n type: \"pcb_silkscreen_oval\"\n pcb_silkscreen_oval_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n radius_x: Distance\n radius_y: Distance\n layer: VisibleLayer\n ccw_rotation?: number\n}\n\n/**\n * @deprecated use PcbSilkscreenOval\n */\nexport type PcbSilkscreenOvalDeprecated = PcbSilkscreenOval\n\nexpectTypesMatch<PcbSilkscreenOval, InferredPcbSilkscreenOval>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_pill = z\n .object({\n type: z.literal(\"pcb_silkscreen_pill\"),\n pcb_silkscreen_pill_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_pill\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n width: length,\n height: length,\n layer: layer_ref,\n ccw_rotation: z.number().optional(),\n })\n .describe(\"Defines a silkscreen pill on the PCB\")\n\nexport type PcbSilkscreenPillInput = z.input<typeof pcb_silkscreen_pill>\ntype InferredPcbSilkscreenPill = z.infer<typeof pcb_silkscreen_pill>\n\n/**\n * Defines a silkscreen pill on the PCB\n */\nexport interface PcbSilkscreenPill {\n type: \"pcb_silkscreen_pill\"\n pcb_silkscreen_pill_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n width: Length\n height: Length\n layer: LayerRef\n ccw_rotation?: number\n}\n\n/**\n * @deprecated use PcbSilkscreenPill\n */\nexport type PcbSilkscreenPillDeprecated = PcbSilkscreenPill\n\nexpectTypesMatch<PcbSilkscreenPill, InferredPcbSilkscreenPill>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"src/common\"\nimport { distance, type Length } from \"src/units\"\nimport {\n visible_layer,\n type LayerRef,\n type VisibleLayer,\n} from \"src/pcb/properties/layer_ref\"\nimport { getZodPrefixedIdWithDefault } from \"src/common/getZodPrefixedIdWithDefault\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_fabrication_note_text = z\n .object({\n type: z.literal(\"pcb_fabrication_note_text\"),\n pcb_fabrication_note_text_id: getZodPrefixedIdWithDefault(\n \"pcb_fabrication_note_text\",\n ),\n subcircuit_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: distance.default(\"1mm\"),\n pcb_component_id: z.string(),\n text: z.string(),\n layer: visible_layer,\n anchor_position: point.default({ x: 0, y: 0 }),\n anchor_alignment: z\n .enum([\"center\", \"top_left\", \"top_right\", \"bottom_left\", \"bottom_right\"])\n .default(\"center\"),\n color: z.string().optional(),\n })\n .describe(\n \"Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators\",\n )\n\nexport type PcbFabricationNoteTextInput = z.input<\n typeof pcb_fabrication_note_text\n>\ntype InferredPcbFabricationNoteText = z.infer<typeof pcb_fabrication_note_text>\n\n/**\n * Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators\n */\nexport interface PcbFabricationNoteText {\n type: \"pcb_fabrication_note_text\"\n pcb_fabrication_note_text_id: string\n subcircuit_id?: string\n pcb_group_id?: string\n font: \"tscircuit2024\"\n font_size: Length\n pcb_component_id: string\n text: string\n layer: VisibleLayer\n anchor_position: Point\n anchor_alignment:\n | \"center\"\n | \"top_left\"\n | \"top_right\"\n | \"bottom_left\"\n | \"bottom_right\"\n color?: string\n}\n\n/**\n * @deprecated use PcbFabricationNoteText\n */\nexport type PCBFabricationNoteText = PcbFabricationNoteText\n\nexpectTypesMatch<PcbFabricationNoteText, InferredPcbFabricationNoteText>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport {\n layer_ref,\n visible_layer,\n type LayerRef,\n} from \"src/pcb/properties/layer_ref\"\nimport { point, type Point } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_fabrication_note_path = z\n .object({\n type: z.literal(\"pcb_fabrication_note_path\"),\n pcb_fabrication_note_path_id: getZodPrefixedIdWithDefault(\n \"pcb_fabrication_note_path\",\n ),\n pcb_component_id: z.string(),\n subcircuit_id: z.string().optional(),\n layer: layer_ref,\n route: z.array(point),\n stroke_width: length,\n color: z.string().optional(),\n })\n .describe(\n \"Defines a fabrication path on the PCB for fabricators or assemblers\",\n )\n\nexport type PcbFabricationNotePathInput = z.input<\n typeof pcb_fabrication_note_path\n>\ntype InferredPcbFabricationNotePath = z.infer<typeof pcb_fabrication_note_path>\n\n/**\n * Defines a fabrication path on the PCB for fabricators or assemblers\n */\nexport interface PcbFabricationNotePath {\n type: \"pcb_fabrication_note_path\"\n pcb_fabrication_note_path_id: string\n pcb_component_id: string\n subcircuit_id?: string\n layer: LayerRef\n route: Point[]\n stroke_width: Length\n color?: string\n}\n\n/**\n * @deprecated use PcbFabricationNotePath\n */\nexport type PCBFabricationNotePath = PcbFabricationNotePath\n\nexpectTypesMatch<PcbFabricationNotePath, InferredPcbFabricationNotePath>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_fabrication_note_rect = z\n .object({\n type: z.literal(\"pcb_fabrication_note_rect\"),\n pcb_fabrication_note_rect_id: getZodPrefixedIdWithDefault(\n \"pcb_fabrication_note_rect\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n width: length,\n height: length,\n layer: visible_layer,\n stroke_width: length.default(\"0.1mm\"),\n corner_radius: length.optional(),\n is_filled: z.boolean().optional(),\n has_stroke: z.boolean().optional(),\n is_stroke_dashed: z.boolean().optional(),\n color: z.string().optional(),\n })\n .describe(\"Defines a fabrication note rectangle on the PCB\")\n\nexport type PcbFabricationNoteRectInput = z.input<\n typeof pcb_fabrication_note_rect\n>\ntype InferredPcbFabricationNoteRect = z.infer<typeof pcb_fabrication_note_rect>\n\n/**\n * Defines a fabrication note rectangle on the PCB\n */\nexport interface PcbFabricationNoteRect {\n type: \"pcb_fabrication_note_rect\"\n pcb_fabrication_note_rect_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n width: Length\n height: Length\n layer: VisibleLayer\n stroke_width: Length\n corner_radius?: Length\n is_filled?: boolean\n has_stroke?: boolean\n is_stroke_dashed?: boolean\n color?: string\n}\n\n/**\n * @deprecated use PcbFabricationNoteRect\n */\nexport type PCBFabricationNoteRect = PcbFabricationNoteRect\n\nexpectTypesMatch<PcbFabricationNoteRect, InferredPcbFabricationNoteRect>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_fabrication_note_dimension = z\n .object({\n type: z.literal(\"pcb_fabrication_note_dimension\"),\n pcb_fabrication_note_dimension_id: getZodPrefixedIdWithDefault(\n \"pcb_fabrication_note_dimension\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: visible_layer,\n from: point,\n to: point,\n text: z.string().optional(),\n text_ccw_rotation: z.number().optional(),\n offset: length.optional(),\n offset_distance: length.optional(),\n offset_direction: z\n .object({\n x: z.number(),\n y: z.number(),\n })\n .optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: length.default(\"1mm\"),\n color: z.string().optional(),\n arrow_size: length.default(\"1mm\"),\n })\n .describe(\"Defines a measurement annotation within PCB fabrication notes\")\n\nexport type PcbFabricationNoteDimensionInput = z.input<\n typeof pcb_fabrication_note_dimension\n>\ntype InferredPcbFabricationNoteDimension = z.infer<\n typeof pcb_fabrication_note_dimension\n>\n\n/**\n * Defines a measurement annotation within PCB fabrication notes\n */\nexport interface PcbFabricationNoteDimension {\n type: \"pcb_fabrication_note_dimension\"\n pcb_fabrication_note_dimension_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n layer: VisibleLayer\n from: Point\n to: Point\n text?: string\n text_ccw_rotation?: number\n offset?: Length\n offset_distance?: Length\n offset_direction?: {\n x: number\n y: number\n }\n font: \"tscircuit2024\"\n font_size: Length\n color?: string\n arrow_size: Length\n}\n\n/**\n * @deprecated use PcbFabricationNoteDimension\n */\nexport type PCBFabricationNoteDimension = PcbFabricationNoteDimension\n\nexpectTypesMatch<\n PcbFabricationNoteDimension,\n InferredPcbFabricationNoteDimension\n>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_note_text = z\n .object({\n type: z.literal(\"pcb_note_text\"),\n pcb_note_text_id: getZodPrefixedIdWithDefault(\"pcb_note_text\"),\n pcb_component_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n name: z.string().optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: distance.default(\"1mm\"),\n text: z.string().optional(),\n anchor_position: point.default({ x: 0, y: 0 }),\n anchor_alignment: z\n .enum([\"center\", \"top_left\", \"top_right\", \"bottom_left\", \"bottom_right\"])\n .default(\"center\"),\n color: z.string().optional(),\n })\n .describe(\"Defines a documentation note in text on the PCB\")\n\nexport type PcbNoteTextInput = z.input<typeof pcb_note_text>\ntype InferredPcbNoteText = z.infer<typeof pcb_note_text>\n\n/**\n * Defines a documentation note in text on the PCB\n */\nexport interface PcbNoteText {\n type: \"pcb_note_text\"\n pcb_note_text_id: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n name?: string\n font: \"tscircuit2024\"\n font_size: Length\n text?: string\n anchor_position: Point\n anchor_alignment:\n | \"center\"\n | \"top_left\"\n | \"top_right\"\n | \"bottom_left\"\n | \"bottom_right\"\n color?: string\n}\n\nexpectTypesMatch<PcbNoteText, InferredPcbNoteText>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_note_rect = z\n .object({\n type: z.literal(\"pcb_note_rect\"),\n pcb_note_rect_id: getZodPrefixedIdWithDefault(\"pcb_note_rect\"),\n pcb_component_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n name: z.string().optional(),\n text: z.string().optional(),\n center: point,\n width: length,\n height: length,\n stroke_width: length.default(\"0.1mm\"),\n corner_radius: length.optional(),\n is_filled: z.boolean().optional(),\n has_stroke: z.boolean().optional(),\n is_stroke_dashed: z.boolean().optional(),\n color: z.string().optional(),\n })\n .describe(\"Defines a rectangular documentation note on the PCB\")\n\nexport type PcbNoteRectInput = z.input<typeof pcb_note_rect>\ntype InferredPcbNoteRect = z.infer<typeof pcb_note_rect>\n\n/**\n * Defines a rectangular documentation note on the PCB\n */\nexport interface PcbNoteRect {\n type: \"pcb_note_rect\"\n pcb_note_rect_id: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n name?: string\n text?: string\n center: Point\n width: Length\n height: Length\n stroke_width: Length\n corner_radius?: Length\n is_filled?: boolean\n has_stroke?: boolean\n is_stroke_dashed?: boolean\n color?: string\n}\n\nexpectTypesMatch<PcbNoteRect, InferredPcbNoteRect>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_note_path = z\n .object({\n type: z.literal(\"pcb_note_path\"),\n pcb_note_path_id: getZodPrefixedIdWithDefault(\"pcb_note_path\"),\n pcb_component_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n name: z.string().optional(),\n text: z.string().optional(),\n route: z.array(point),\n stroke_width: length.default(\"0.1mm\"),\n color: z.string().optional(),\n })\n .describe(\"Defines a polyline documentation note on the PCB\")\n\nexport type PcbNotePathInput = z.input<typeof pcb_note_path>\ntype InferredPcbNotePath = z.infer<typeof pcb_note_path>\n\n/**\n * Defines a polyline documentation note on the PCB\n */\nexport interface PcbNotePath {\n type: \"pcb_note_path\"\n pcb_note_path_id: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n name?: string\n text?: string\n route: Point[]\n stroke_width: Length\n color?: string\n}\n\nexpectTypesMatch<PcbNotePath, InferredPcbNotePath>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_note_line = z\n .object({\n type: z.literal(\"pcb_note_line\"),\n pcb_note_line_id: getZodPrefixedIdWithDefault(\"pcb_note_line\"),\n pcb_component_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n name: z.string().optional(),\n text: z.string().optional(),\n x1: distance,\n y1: distance,\n x2: distance,\n y2: distance,\n stroke_width: distance.default(\"0.1mm\"),\n color: z.string().optional(),\n is_dashed: z.boolean().optional(),\n })\n .describe(\"Defines a straight documentation note line on the PCB\")\n\nexport type PcbNoteLineInput = z.input<typeof pcb_note_line>\ntype InferredPcbNoteLine = z.infer<typeof pcb_note_line>\n\n/**\n * Defines a straight documentation note line on the PCB\n */\nexport interface PcbNoteLine {\n type: \"pcb_note_line\"\n pcb_note_line_id: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n name?: string\n text?: string\n x1: Distance\n y1: Distance\n x2: Distance\n y2: Distance\n stroke_width: Distance\n color?: string\n is_dashed?: boolean\n}\n\nexpectTypesMatch<PcbNoteLine, InferredPcbNoteLine>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_note_dimension = z\n .object({\n type: z.literal(\"pcb_note_dimension\"),\n pcb_note_dimension_id: getZodPrefixedIdWithDefault(\"pcb_note_dimension\"),\n pcb_component_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n name: z.string().optional(),\n from: point,\n to: point,\n text: z.string().optional(),\n text_ccw_rotation: z.number().optional(),\n offset_distance: length.optional(),\n offset_direction: z\n .object({\n x: z.number(),\n y: z.number(),\n })\n .optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: length.default(\"1mm\"),\n color: z.string().optional(),\n arrow_size: length.default(\"1mm\"),\n })\n .describe(\"Defines a measurement annotation within PCB documentation notes\")\n\nexport type PcbNoteDimensionInput = z.input<typeof pcb_note_dimension>\ntype InferredPcbNoteDimension = z.infer<typeof pcb_note_dimension>\n\n/**\n * Defines a measurement annotation within PCB documentation notes\n */\nexport interface PcbNoteDimension {\n type: \"pcb_note_dimension\"\n pcb_note_dimension_id: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n name?: string\n from: Point\n to: Point\n text?: string\n text_ccw_rotation?: number\n offset_distance?: Length\n offset_direction?: {\n x: number\n y: number\n }\n font: \"tscircuit2024\"\n font_size: Length\n color?: string\n arrow_size: Length\n}\n\nexpectTypesMatch<PcbNoteDimension, InferredPcbNoteDimension>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_footprint_overlap_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_footprint_overlap_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_error\"),\n error_type: z\n .literal(\"pcb_footprint_overlap_error\")\n .default(\"pcb_footprint_overlap_error\"),\n pcb_smtpad_ids: z.array(z.string()).optional(),\n pcb_plated_hole_ids: z.array(z.string()).optional(),\n pcb_hole_ids: z.array(z.string()).optional(),\n pcb_keepout_ids: z.array(z.string()).optional(),\n })\n .describe(\"Error emitted when a pcb footprint overlaps with another element\")\n\nexport type PcbFootprintOverlapErrorInput = z.input<\n typeof pcb_footprint_overlap_error\n>\ntype InferredPcbFootprintOverlapError = z.infer<\n typeof pcb_footprint_overlap_error\n>\n\n/** Error emitted when a pcb footprint overlaps with another element */\nexport interface PcbFootprintOverlapError extends BaseCircuitJsonError {\n type: \"pcb_footprint_overlap_error\"\n pcb_error_id: string\n error_type: \"pcb_footprint_overlap_error\"\n pcb_smtpad_ids?: string[]\n pcb_plated_hole_ids?: string[]\n pcb_hole_ids?: string[]\n pcb_keepout_ids?: string[]\n}\n\nexpectTypesMatch<PcbFootprintOverlapError, InferredPcbFootprintOverlapError>(\n true,\n)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_courtyard_overlap_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_courtyard_overlap_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_error\"),\n error_type: z\n .literal(\"pcb_courtyard_overlap_error\")\n .default(\"pcb_courtyard_overlap_error\"),\n pcb_component_ids: z.tuple([z.string(), z.string()]),\n })\n .describe(\n \"Error emitted when the courtyard (CrtYd) of one PCB component overlaps with the courtyard of another\",\n )\n\nexport type PcbCourtyardOverlapErrorInput = z.input<\n typeof pcb_courtyard_overlap_error\n>\ntype InferredPcbCourtyardOverlapError = z.infer<\n typeof pcb_courtyard_overlap_error\n>\n\n/** Error emitted when the courtyard (CrtYd) of one PCB component overlaps with the courtyard of another */\nexport interface PcbCourtyardOverlapError extends BaseCircuitJsonError {\n type: \"pcb_courtyard_overlap_error\"\n pcb_error_id: string\n error_type: \"pcb_courtyard_overlap_error\"\n pcb_component_ids: [string, string]\n}\n\nexpectTypesMatch<PcbCourtyardOverlapError, InferredPcbCourtyardOverlapError>(\n true,\n)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_keepout = z\n .object({\n type: z.literal(\"pcb_keepout\"),\n shape: z.literal(\"rect\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n width: distance,\n height: distance,\n pcb_keepout_id: z.string(),\n layers: z.array(z.string()), // Specify layers where the keepout applies\n description: z.string().optional(), // Optional description of the keepout\n })\n .or(\n z.object({\n type: z.literal(\"pcb_keepout\"),\n shape: z.literal(\"circle\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n radius: distance,\n pcb_keepout_id: z.string(),\n layers: z.array(z.string()), // Specify layers where the keepout applies\n description: z.string().optional(), // Optional description of the keepout\n }),\n )\n\nexport type PCBKeepoutInput = z.input<typeof pcb_keepout>\ntype InferredPCBKeepout = z.infer<typeof pcb_keepout>\n\nexport interface PCBKeepoutRect {\n type: \"pcb_keepout\"\n shape: \"rect\"\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n width: number\n height: number\n pcb_keepout_id: string\n layers: string[]\n description?: string\n}\n\nexport interface PCBKeepoutCircle {\n type: \"pcb_keepout\"\n shape: \"circle\"\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n radius: number\n pcb_keepout_id: string\n layers: string[]\n description?: string\n}\n\nexport type PCBKeepout = PCBKeepoutRect | PCBKeepoutCircle\n\nexpectTypesMatch<PCBKeepout, InferredPCBKeepout>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length, rotation, type Rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n// Common properties base for all cutout shapes (internal)\nconst pcb_cutout_base = z.object({\n type: z.literal(\"pcb_cutout\"),\n pcb_cutout_id: getZodPrefixedIdWithDefault(\"pcb_cutout\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_board_id: z.string().optional(),\n pcb_panel_id: z.string().optional(),\n})\n\n// Rectangular Cutout\nexport const pcb_cutout_rect = pcb_cutout_base.extend({\n shape: z.literal(\"rect\"),\n center: point,\n width: length,\n height: length,\n rotation: rotation.optional(),\n corner_radius: length.optional(),\n})\nexport type PcbCutoutRectInput = z.input<typeof pcb_cutout_rect>\ntype InferredPcbCutoutRect = z.infer<typeof pcb_cutout_rect>\n/**\n * Defines a rectangular cutout on the PCB.\n */\nexport interface PcbCutoutRect {\n type: \"pcb_cutout\"\n pcb_cutout_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_board_id?: string\n pcb_panel_id?: string\n shape: \"rect\"\n center: Point\n width: Length\n height: Length\n rotation?: Rotation\n corner_radius?: Length\n}\nexpectTypesMatch<PcbCutoutRect, InferredPcbCutoutRect>(true)\n\n// Circular Cutout\nexport const pcb_cutout_circle = pcb_cutout_base.extend({\n shape: z.literal(\"circle\"),\n center: point,\n radius: length,\n})\nexport type PcbCutoutCircleInput = z.input<typeof pcb_cutout_circle>\ntype InferredPcbCutoutCircle = z.infer<typeof pcb_cutout_circle>\n/**\n * Defines a circular cutout on the PCB.\n */\nexport interface PcbCutoutCircle {\n type: \"pcb_cutout\"\n pcb_cutout_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_board_id?: string\n pcb_panel_id?: string\n shape: \"circle\"\n center: Point\n radius: Length\n}\nexpectTypesMatch<PcbCutoutCircle, InferredPcbCutoutCircle>(true)\n\n// Polygon Cutout\nexport const pcb_cutout_polygon = pcb_cutout_base.extend({\n shape: z.literal(\"polygon\"),\n points: z.array(point),\n})\nexport type PcbCutoutPolygonInput = z.input<typeof pcb_cutout_polygon>\ntype InferredPcbCutoutPolygon = z.infer<typeof pcb_cutout_polygon>\n/**\n * Defines a polygonal cutout on the PCB, specified by a list of points.\n * The polygon should be closed (the last point implicitly connects to the first).\n */\nexport interface PcbCutoutPolygon {\n type: \"pcb_cutout\"\n pcb_cutout_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_board_id?: string\n pcb_panel_id?: string\n shape: \"polygon\"\n points: Point[]\n}\nexpectTypesMatch<PcbCutoutPolygon, InferredPcbCutoutPolygon>(true)\n\n// Path Cutout (for slots along a path)\nexport const pcb_cutout_path = pcb_cutout_base.extend({\n shape: z.literal(\"path\"),\n route: z.array(point),\n slot_width: length,\n slot_length: length.optional(),\n space_between_slots: length.optional(),\n slot_corner_radius: length.optional(),\n})\nexport type PcbCutoutPathInput = z.input<typeof pcb_cutout_path>\ntype InferredPcbCutoutPath = z.infer<typeof pcb_cutout_path>\n/**\n * Defines a path-based cutout on the PCB, creating slots along the specified path.\n * When slot_length and space_between_slots are specified, creates a dashed pattern of slots.\n * When they are omitted, creates a continuous slot along the entire path.\n * The slot_corner_radius controls the rounding of slot corners (0 = square, slot_width/2 = circle).\n */\nexport interface PcbCutoutPath {\n type: \"pcb_cutout\"\n pcb_cutout_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_board_id?: string\n pcb_panel_id?: string\n shape: \"path\"\n route: Point[]\n slot_width: Length\n slot_length?: Length\n space_between_slots?: Length\n slot_corner_radius?: Length\n}\nexpectTypesMatch<PcbCutoutPath, InferredPcbCutoutPath>(true)\n\n// Union of all cutout shapes\nexport const pcb_cutout = z\n .discriminatedUnion(\"shape\", [\n pcb_cutout_rect,\n pcb_cutout_circle,\n pcb_cutout_polygon,\n pcb_cutout_path,\n ])\n .describe(\"Defines a cutout on the PCB, removing board material.\")\n\nexport type PcbCutoutInput = z.input<typeof pcb_cutout>\nexport type PcbCutout =\n | PcbCutoutRect\n | PcbCutoutCircle\n | PcbCutoutPolygon\n | PcbCutoutPath\n\ntype InferredPcbCutout = z.infer<typeof pcb_cutout>\nexpectTypesMatch<PcbCutout, InferredPcbCutout>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_missing_footprint_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_missing_footprint_error\"),\n pcb_missing_footprint_error_id: getZodPrefixedIdWithDefault(\n \"pcb_missing_footprint_error\",\n ),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n error_type: z\n .literal(\"pcb_missing_footprint_error\")\n .default(\"pcb_missing_footprint_error\"),\n source_component_id: z.string(),\n })\n .describe(\"Defines a missing footprint error on the PCB\")\n\nexport type PcbMissingFootprintErrorInput = z.input<\n typeof pcb_missing_footprint_error\n>\ntype InferredPcbMissingFootprintError = z.infer<\n typeof pcb_missing_footprint_error\n>\n\n/**\n * Defines a placement error on the PCB\n */\nexport interface PcbMissingFootprintError extends BaseCircuitJsonError {\n type: \"pcb_missing_footprint_error\"\n pcb_missing_footprint_error_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n error_type: \"pcb_missing_footprint_error\"\n source_component_id: string\n}\n\n/**\n * @deprecated use PcbMissingFootprintError\n */\nexport type PCBMissingFootprintError = PcbMissingFootprintError\n\nexpectTypesMatch<PcbMissingFootprintError, InferredPcbMissingFootprintError>(\n true,\n)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const external_footprint_load_error = base_circuit_json_error\n .extend({\n type: z.literal(\"external_footprint_load_error\"),\n external_footprint_load_error_id: getZodPrefixedIdWithDefault(\n \"external_footprint_load_error\",\n ),\n pcb_component_id: z.string(),\n source_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n footprinter_string: z.string().optional(),\n error_type: z\n .literal(\"external_footprint_load_error\")\n .default(\"external_footprint_load_error\"),\n })\n .describe(\"Defines an error when an external footprint fails to load\")\n\nexport type ExternalFootprintLoadErrorInput = z.input<\n typeof external_footprint_load_error\n>\ntype InferredExternalFootprintLoadError = z.infer<\n typeof external_footprint_load_error\n>\n\nexport interface ExternalFootprintLoadError extends BaseCircuitJsonError {\n type: \"external_footprint_load_error\"\n external_footprint_load_error_id: string\n pcb_component_id: string\n source_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n footprinter_string?: string\n error_type: \"external_footprint_load_error\"\n}\n\nexpectTypesMatch<\n ExternalFootprintLoadError,\n InferredExternalFootprintLoadError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const circuit_json_footprint_load_error = base_circuit_json_error\n .extend({\n type: z.literal(\"circuit_json_footprint_load_error\"),\n circuit_json_footprint_load_error_id: getZodPrefixedIdWithDefault(\n \"circuit_json_footprint_load_error\",\n ),\n pcb_component_id: z.string(),\n source_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n error_type: z\n .literal(\"circuit_json_footprint_load_error\")\n .default(\"circuit_json_footprint_load_error\"),\n circuit_json: z.array(z.any()).optional(),\n })\n .describe(\"Defines an error when a circuit JSON footprint fails to load\")\n\nexport type CircuitJsonFootprintLoadErrorInput = z.input<\n typeof circuit_json_footprint_load_error\n>\ntype InferredCircuitJsonFootprintLoadError = z.infer<\n typeof circuit_json_footprint_load_error\n>\n\nexport interface CircuitJsonFootprintLoadError extends BaseCircuitJsonError {\n type: \"circuit_json_footprint_load_error\"\n circuit_json_footprint_load_error_id: string\n pcb_component_id: string\n source_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n error_type: \"circuit_json_footprint_load_error\"\n circuit_json?: any[]\n}\n\nexpectTypesMatch<\n CircuitJsonFootprintLoadError,\n InferredCircuitJsonFootprintLoadError\n>(true)\n","import { z } from \"zod\"\nimport {\n point,\n type Point,\n getZodPrefixedIdWithDefault,\n ninePointAnchor,\n type NinePointAnchor,\n} from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_group = z\n .object({\n type: z.literal(\"pcb_group\"),\n pcb_group_id: getZodPrefixedIdWithDefault(\"pcb_group\"),\n source_group_id: z.string(),\n is_subcircuit: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n width: length.optional(),\n height: length.optional(),\n center: point,\n display_offset_x: z\n .string()\n .optional()\n .describe(\n \"How to display the x offset for this group, usually corresponding with how the user specified it\",\n ),\n display_offset_y: z\n .string()\n .optional()\n .describe(\n \"How to display the y offset for this group, usually corresponding with how the user specified it\",\n ),\n outline: z.array(point).optional(),\n anchor_position: point.optional(),\n anchor_alignment: ninePointAnchor.default(\"center\"),\n position_mode: z\n .enum([\"packed\", \"relative_to_group_anchor\", \"none\"])\n .optional(),\n positioned_relative_to_pcb_group_id: z.string().optional(),\n positioned_relative_to_pcb_board_id: z.string().optional(),\n pcb_component_ids: z.array(z.string()),\n child_layout_mode: z.enum([\"packed\", \"none\"]).optional(),\n name: z.string().optional(),\n description: z.string().optional(),\n layout_mode: z.string().optional(),\n autorouter_configuration: z\n .object({\n trace_clearance: length,\n })\n .optional(),\n autorouter_used_string: z.string().optional(),\n })\n .describe(\"Defines a group of components on the PCB\")\n\nexport type PcbGroupInput = z.input<typeof pcb_group>\ntype InferredPcbGroup = z.infer<typeof pcb_group>\n\n/**\n * Defines a group of components on the PCB\n */\nexport interface PcbGroup {\n type: \"pcb_group\"\n pcb_group_id: string\n source_group_id: string\n is_subcircuit?: boolean\n subcircuit_id?: string\n width?: Length\n height?: Length\n center: Point\n display_offset_x?: string\n display_offset_y?: string\n outline?: Point[]\n anchor_position?: Point\n anchor_alignment: NinePointAnchor\n position_mode?: \"packed\" | \"relative_to_group_anchor\" | \"none\"\n positioned_relative_to_pcb_group_id?: string\n positioned_relative_to_pcb_board_id?: string\n pcb_component_ids: string[]\n child_layout_mode?: \"packed\" | \"none\"\n name?: string\n description?: string\n layout_mode?: string\n autorouter_configuration?: {\n trace_clearance: Length\n }\n autorouter_used_string?: string\n}\n\nexpectTypesMatch<PcbGroup, InferredPcbGroup>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_autorouting_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_autorouting_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_autorouting_error\"),\n error_type: z\n .literal(\"pcb_autorouting_error\")\n .default(\"pcb_autorouting_error\"),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"The autorouting has failed to route a portion of the board\")\n\nexport type PcbAutoroutingErrorInput = z.input<typeof pcb_autorouting_error>\ntype PcbInferredAutoroutingError = z.infer<typeof pcb_autorouting_error>\n\nexport interface PcbAutoroutingErrorInterface extends BaseCircuitJsonError {\n type: \"pcb_autorouting_error\"\n pcb_error_id: string\n error_type: \"pcb_autorouting_error\"\n subcircuit_id?: string\n}\n\nexport type PcbAutoroutingError = PcbAutoroutingErrorInterface\n\nexpectTypesMatch<PcbAutoroutingError, PcbInferredAutoroutingError>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"../common\"\nimport { expectTypesMatch } from \"../utils/expect-types-match\"\n\nexport const pcb_manual_edit_conflict_warning = z\n .object({\n type: z.literal(\"pcb_manual_edit_conflict_warning\"),\n pcb_manual_edit_conflict_warning_id: getZodPrefixedIdWithDefault(\n \"pcb_manual_edit_conflict_warning\",\n ),\n warning_type: z\n .literal(\"pcb_manual_edit_conflict_warning\")\n .default(\"pcb_manual_edit_conflict_warning\"),\n message: z.string(),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n source_component_id: z.string(),\n })\n .describe(\n \"Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates\",\n )\n\nexport type PcbManualEditConflictWarningInput = z.input<\n typeof pcb_manual_edit_conflict_warning\n>\ntype InferredPcbManualEditConflictWarning = z.infer<\n typeof pcb_manual_edit_conflict_warning\n>\n\n/**\n * Warning emitted when a component has both manual placement (via manualEdits) and explicit pcbX/pcbY coordinates\n */\nexport interface PcbManualEditConflictWarning {\n type: \"pcb_manual_edit_conflict_warning\"\n pcb_manual_edit_conflict_warning_id: string\n warning_type: \"pcb_manual_edit_conflict_warning\"\n message: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n source_component_id: string\n}\n\nexpectTypesMatch<\n PcbManualEditConflictWarning,\n InferredPcbManualEditConflictWarning\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nconst connectorOrientationDirection = z.enum([\"x-\", \"x+\", \"y+\", \"y-\"])\n\ntype ConnectorOrientationDirection = z.infer<\n typeof connectorOrientationDirection\n>\n\nexport const pcb_connector_not_in_accessible_orientation_warning = z\n .object({\n type: z.literal(\"pcb_connector_not_in_accessible_orientation_warning\"),\n pcb_connector_not_in_accessible_orientation_warning_id:\n getZodPrefixedIdWithDefault(\n \"pcb_connector_not_in_accessible_orientation_warning\",\n ),\n warning_type: z\n .literal(\"pcb_connector_not_in_accessible_orientation_warning\")\n .default(\"pcb_connector_not_in_accessible_orientation_warning\"),\n message: z.string(),\n pcb_component_id: z.string(),\n source_component_id: z.string().optional(),\n pcb_board_id: z.string().optional(),\n facing_direction: connectorOrientationDirection,\n recommended_facing_direction: connectorOrientationDirection,\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Warning emitted when a connector PCB component is facing inward toward the board and should be reoriented to an outward-facing direction\",\n )\n\nexport type PcbConnectorNotInAccessibleOrientationWarningInput = z.input<\n typeof pcb_connector_not_in_accessible_orientation_warning\n>\ntype InferredPcbConnectorNotInAccessibleOrientationWarning = z.infer<\n typeof pcb_connector_not_in_accessible_orientation_warning\n>\n\n/** Warning emitted when a connector PCB component is facing inward toward the board and should be reoriented */\nexport interface PcbConnectorNotInAccessibleOrientationWarning {\n type: \"pcb_connector_not_in_accessible_orientation_warning\"\n pcb_connector_not_in_accessible_orientation_warning_id: string\n warning_type: \"pcb_connector_not_in_accessible_orientation_warning\"\n message: string\n pcb_component_id: string\n source_component_id?: string\n pcb_board_id?: string\n facing_direction: ConnectorOrientationDirection\n recommended_facing_direction: ConnectorOrientationDirection\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n PcbConnectorNotInAccessibleOrientationWarning,\n InferredPcbConnectorNotInAccessibleOrientationWarning\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_breakout_point = z\n .object({\n type: z.literal(\"pcb_breakout_point\"),\n pcb_breakout_point_id: getZodPrefixedIdWithDefault(\"pcb_breakout_point\"),\n pcb_group_id: z.string(),\n subcircuit_id: z.string().optional(),\n source_trace_id: z.string().optional(),\n source_port_id: z.string().optional(),\n source_net_id: z.string().optional(),\n x: distance,\n y: distance,\n })\n .describe(\n \"Defines a routing target within a pcb_group for a source_trace or source_net\",\n )\n\nexport type PcbBreakoutPointInput = z.input<typeof pcb_breakout_point>\ntype InferredPcbBreakoutPoint = z.infer<typeof pcb_breakout_point>\n\n/**\n * Defines a routing target within a pcb_group for a source_trace or source_net\n */\nexport interface PcbBreakoutPoint {\n type: \"pcb_breakout_point\"\n pcb_breakout_point_id: string\n pcb_group_id: string\n subcircuit_id?: string\n source_trace_id?: string\n source_port_id?: string\n source_net_id?: string\n x: Distance\n y: Distance\n}\n\nexpectTypesMatch<PcbBreakoutPoint, InferredPcbBreakoutPoint>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_ground_plane = z\n .object({\n type: z.literal(\"pcb_ground_plane\"),\n pcb_ground_plane_id: getZodPrefixedIdWithDefault(\"pcb_ground_plane\"),\n source_pcb_ground_plane_id: z.string(),\n source_net_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a ground plane on the PCB\")\n\nexport type PcbGroundPlaneInput = z.input<typeof pcb_ground_plane>\ntype InferredPcbGroundPlane = z.infer<typeof pcb_ground_plane>\n\n/**\n * Defines a ground plane on the PCB\n */\nexport interface PcbGroundPlane {\n type: \"pcb_ground_plane\"\n pcb_ground_plane_id: string\n source_pcb_ground_plane_id: string\n source_net_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<PcbGroundPlane, InferredPcbGroundPlane>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_ground_plane_region = z\n .object({\n type: z.literal(\"pcb_ground_plane_region\"),\n pcb_ground_plane_region_id: getZodPrefixedIdWithDefault(\n \"pcb_ground_plane_region\",\n ),\n pcb_ground_plane_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: layer_ref,\n points: z.array(point),\n })\n .describe(\"Defines a polygon region of a ground plane\")\n\nexport type PcbGroundPlaneRegionInput = z.input<typeof pcb_ground_plane_region>\ntype InferredPcbGroundPlaneRegion = z.infer<typeof pcb_ground_plane_region>\n\n/**\n * Defines a polygon region of a ground plane\n */\nexport interface PcbGroundPlaneRegion {\n type: \"pcb_ground_plane_region\"\n pcb_ground_plane_region_id: string\n pcb_ground_plane_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n layer: LayerRef\n points: Point[]\n}\n\nexpectTypesMatch<PcbGroundPlaneRegion, InferredPcbGroundPlaneRegion>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_thermal_spoke = z\n .object({\n type: z.literal(\"pcb_thermal_spoke\"),\n pcb_thermal_spoke_id: getZodPrefixedIdWithDefault(\"pcb_thermal_spoke\"),\n pcb_ground_plane_id: z.string(),\n shape: z.string(),\n spoke_count: z.number(),\n spoke_thickness: distance,\n spoke_inner_diameter: distance,\n spoke_outer_diameter: distance,\n pcb_plated_hole_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Pattern for connecting a ground plane to a plated hole\")\n\nexport type PcbThermalSpokeInput = z.input<typeof pcb_thermal_spoke>\ntype InferredPcbThermalSpoke = z.infer<typeof pcb_thermal_spoke>\n\n/**\n * Pattern for connecting a ground plane to a plated hole\n */\nexport interface PcbThermalSpoke {\n type: \"pcb_thermal_spoke\"\n pcb_thermal_spoke_id: string\n pcb_ground_plane_id: string\n shape: string\n spoke_count: number\n spoke_thickness: Distance\n spoke_inner_diameter: Distance\n spoke_outer_diameter: Distance\n pcb_plated_hole_id?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<PcbThermalSpoke, InferredPcbThermalSpoke>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length, rotation, type Rotation } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"./properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { brep_shape, type BRepShape } from \"./properties/brep\"\n\n// Common properties base for all pour shapes (internal)\nconst pcb_copper_pour_base = z.object({\n type: z.literal(\"pcb_copper_pour\"),\n pcb_copper_pour_id: getZodPrefixedIdWithDefault(\"pcb_copper_pour\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: layer_ref,\n source_net_id: z.string().optional(),\n covered_with_solder_mask: z.boolean().optional().default(true),\n})\n\n// Rectangular Pour\nexport const pcb_copper_pour_rect = pcb_copper_pour_base.extend({\n shape: z.literal(\"rect\"),\n center: point,\n width: length,\n height: length,\n rotation: rotation.optional(),\n})\nexport type PcbCopperPourRectInput = z.input<typeof pcb_copper_pour_rect>\ntype InferredPcbCopperPourRect = z.infer<typeof pcb_copper_pour_rect>\n/**\n * Defines a rectangular copper pour on the PCB.\n */\nexport interface PcbCopperPourRect {\n type: \"pcb_copper_pour\"\n pcb_copper_pour_id: string\n covered_with_solder_mask: boolean\n pcb_group_id?: string\n subcircuit_id?: string\n layer: LayerRef\n source_net_id?: string\n shape: \"rect\"\n center: Point\n width: Length\n height: Length\n rotation?: Rotation\n}\nexpectTypesMatch<PcbCopperPourRect, InferredPcbCopperPourRect>(true)\n\n// BRep Pour\nexport const pcb_copper_pour_brep = pcb_copper_pour_base.extend({\n shape: z.literal(\"brep\"),\n brep_shape: brep_shape,\n})\nexport type PcbCopperPourBRepInput = z.input<typeof pcb_copper_pour_brep>\ntype InferredPcbCopperPourBRep = z.infer<typeof pcb_copper_pour_brep>\n/**\n * Defines a BRep copper pour on the PCB.\n */\nexport interface PcbCopperPourBRep {\n type: \"pcb_copper_pour\"\n pcb_copper_pour_id: string\n covered_with_solder_mask: boolean\n pcb_group_id?: string\n subcircuit_id?: string\n layer: LayerRef\n source_net_id?: string\n shape: \"brep\"\n brep_shape: BRepShape\n}\nexpectTypesMatch<PcbCopperPourBRep, InferredPcbCopperPourBRep>(true)\n\n// Polygon Pour\nexport const pcb_copper_pour_polygon = pcb_copper_pour_base.extend({\n shape: z.literal(\"polygon\"),\n points: z.array(point),\n})\nexport type PcbCopperPourPolygonInput = z.input<typeof pcb_copper_pour_polygon>\ntype InferredPcbCopperPourPolygon = z.infer<typeof pcb_copper_pour_polygon>\n/**\n * Defines a polygonal copper pour on the PCB, specified by a list of points.\n * The polygon should be closed (the last point implicitly connects to the first).\n */\nexport interface PcbCopperPourPolygon {\n type: \"pcb_copper_pour\"\n pcb_copper_pour_id: string\n covered_with_solder_mask: boolean\n pcb_group_id?: string\n subcircuit_id?: string\n layer: LayerRef\n source_net_id?: string\n shape: \"polygon\"\n points: Point[]\n}\nexpectTypesMatch<PcbCopperPourPolygon, InferredPcbCopperPourPolygon>(true)\n\n// Union of all pour shapes\nexport const pcb_copper_pour = z\n .discriminatedUnion(\"shape\", [\n pcb_copper_pour_rect,\n pcb_copper_pour_brep,\n pcb_copper_pour_polygon,\n ])\n .describe(\"Defines a copper pour on the PCB.\")\n\nexport type PcbCopperPourInput = z.input<typeof pcb_copper_pour>\nexport type PcbCopperPour =\n | PcbCopperPourRect\n | PcbCopperPourBRep\n | PcbCopperPourPolygon\n\ntype InferredPcbCopperPour = z.infer<typeof pcb_copper_pour>\nexpectTypesMatch<PcbCopperPour, InferredPcbCopperPour>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { point, type Point } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_component_outside_board_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_component_outside_board_error\"),\n pcb_component_outside_board_error_id: getZodPrefixedIdWithDefault(\n \"pcb_component_outside_board_error\",\n ),\n error_type: z\n .literal(\"pcb_component_outside_board_error\")\n .default(\"pcb_component_outside_board_error\"),\n pcb_component_id: z.string(),\n pcb_board_id: z.string(),\n component_center: point,\n component_bounds: z.object({\n min_x: z.number(),\n max_x: z.number(),\n min_y: z.number(),\n max_y: z.number(),\n }),\n subcircuit_id: z.string().optional(),\n source_component_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when a PCB component is placed outside the board boundaries\",\n )\n\nexport type PcbComponentOutsideBoardErrorInput = z.input<\n typeof pcb_component_outside_board_error\n>\ntype InferredPcbComponentOutsideBoardError = z.infer<\n typeof pcb_component_outside_board_error\n>\n\n/** Error emitted when a PCB component is placed outside the board boundaries */\nexport interface PcbComponentOutsideBoardError extends BaseCircuitJsonError {\n type: \"pcb_component_outside_board_error\"\n pcb_component_outside_board_error_id: string\n error_type: \"pcb_component_outside_board_error\"\n pcb_component_id: string\n pcb_board_id: string\n component_center: Point\n component_bounds: {\n min_x: number\n max_x: number\n min_y: number\n max_y: number\n }\n subcircuit_id?: string\n source_component_id?: string\n}\n\nexpectTypesMatch<\n PcbComponentOutsideBoardError,\n InferredPcbComponentOutsideBoardError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault, point, type Point } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_component_not_on_board_edge_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_component_not_on_board_edge_error\"),\n pcb_component_not_on_board_edge_error_id: getZodPrefixedIdWithDefault(\n \"pcb_component_not_on_board_edge_error\",\n ),\n error_type: z\n .literal(\"pcb_component_not_on_board_edge_error\")\n .default(\"pcb_component_not_on_board_edge_error\"),\n pcb_component_id: z.string(),\n pcb_board_id: z.string(),\n component_center: point,\n pad_to_nearest_board_edge_distance: z.number(),\n source_component_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when a component that must be placed on the board edge is centered away from the edge\",\n )\n\nexport type PcbComponentNotOnBoardEdgeErrorInput = z.input<\n typeof pcb_component_not_on_board_edge_error\n>\ntype InferredPcbComponentNotOnBoardEdgeError = z.infer<\n typeof pcb_component_not_on_board_edge_error\n>\n\n/** Error emitted when a component that must be placed on the board edge is centered away from the edge */\nexport interface PcbComponentNotOnBoardEdgeError extends BaseCircuitJsonError {\n type: \"pcb_component_not_on_board_edge_error\"\n pcb_component_not_on_board_edge_error_id: string\n error_type: \"pcb_component_not_on_board_edge_error\"\n pcb_component_id: string\n pcb_board_id: string\n component_center: Point\n pad_to_nearest_board_edge_distance: number\n source_component_id?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n PcbComponentNotOnBoardEdgeError,\n InferredPcbComponentNotOnBoardEdgeError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_component_invalid_layer_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_component_invalid_layer_error\"),\n pcb_component_invalid_layer_error_id: getZodPrefixedIdWithDefault(\n \"pcb_component_invalid_layer_error\",\n ),\n error_type: z\n .literal(\"pcb_component_invalid_layer_error\")\n .default(\"pcb_component_invalid_layer_error\"),\n pcb_component_id: z.string().optional(),\n source_component_id: z.string(),\n layer: layer_ref,\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)\",\n )\n\nexport type PcbComponentInvalidLayerErrorInput = z.input<\n typeof pcb_component_invalid_layer_error\n>\ntype InferredPcbComponentInvalidLayerError = z.infer<\n typeof pcb_component_invalid_layer_error\n>\n\n/** Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers) */\nexport interface PcbComponentInvalidLayerError extends BaseCircuitJsonError {\n type: \"pcb_component_invalid_layer_error\"\n pcb_component_invalid_layer_error_id: string\n error_type: \"pcb_component_invalid_layer_error\"\n pcb_component_id?: string\n source_component_id: string\n layer: LayerRef\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n PcbComponentInvalidLayerError,\n InferredPcbComponentInvalidLayerError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_via_clearance_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_via_clearance_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_error\"),\n error_type: z\n .literal(\"pcb_via_clearance_error\")\n .default(\"pcb_via_clearance_error\"),\n pcb_via_ids: z.array(z.string()).min(2),\n minimum_clearance: distance.optional(),\n actual_clearance: distance.optional(),\n pcb_center: z\n .object({\n x: z.number().optional(),\n y: z.number().optional(),\n })\n .optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Error emitted when vias are closer than the allowed clearance\")\n\nexport type PcbViaClearanceErrorInput = z.input<typeof pcb_via_clearance_error>\ntype InferredPcbViaClearanceError = z.infer<typeof pcb_via_clearance_error>\n\n/** Error emitted when vias are closer than the allowed clearance */\nexport interface PcbViaClearanceError extends BaseCircuitJsonError {\n type: \"pcb_via_clearance_error\"\n pcb_error_id: string\n error_type: \"pcb_via_clearance_error\"\n pcb_via_ids: string[]\n minimum_clearance?: Distance\n actual_clearance?: Distance\n pcb_center?: {\n x?: number\n y?: number\n }\n subcircuit_id?: string\n}\n\nexpectTypesMatch<PcbViaClearanceError, InferredPcbViaClearanceError>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length, rotation, type Rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_courtyard_rect = z\n .object({\n type: z.literal(\"pcb_courtyard_rect\"),\n pcb_courtyard_rect_id: getZodPrefixedIdWithDefault(\"pcb_courtyard_rect\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n width: length,\n height: length,\n layer: visible_layer,\n ccw_rotation: rotation.optional(),\n color: z.string().optional(),\n })\n .describe(\"Defines a courtyard rectangle on the PCB\")\n\nexport type PcbCourtyardRectInput = z.input<typeof pcb_courtyard_rect>\ntype InferredPcbCourtyardRect = z.infer<typeof pcb_courtyard_rect>\n\n/**\n * Defines a courtyard rectangle on the PCB\n */\nexport interface PcbCourtyardRect {\n type: \"pcb_courtyard_rect\"\n pcb_courtyard_rect_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n width: Length\n height: Length\n layer: VisibleLayer\n ccw_rotation?: Rotation\n color?: string\n}\n\n/**\n * @deprecated use PcbCourtyardRect\n */\nexport type PCBCourtyardRect = PcbCourtyardRect\n\nexpectTypesMatch<PcbCourtyardRect, InferredPcbCourtyardRect>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_courtyard_outline = z\n .object({\n type: z.literal(\"pcb_courtyard_outline\"),\n pcb_courtyard_outline_id: getZodPrefixedIdWithDefault(\n \"pcb_courtyard_outline\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: visible_layer,\n outline: z.array(point).min(2),\n })\n .describe(\"Defines a courtyard outline on the PCB\")\n\nexport type PcbCourtyardOutlineInput = z.input<typeof pcb_courtyard_outline>\ntype InferredPcbCourtyardOutline = z.infer<typeof pcb_courtyard_outline>\n\n/**\n * Defines a courtyard outline on the PCB\n */\nexport interface PcbCourtyardOutline {\n type: \"pcb_courtyard_outline\"\n pcb_courtyard_outline_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n layer: VisibleLayer\n outline: Point[]\n}\n\n/**\n * @deprecated use PcbCourtyardOutline\n */\nexport type PCBCourtyardOutline = PcbCourtyardOutline\n\nexpectTypesMatch<PcbCourtyardOutline, InferredPcbCourtyardOutline>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_courtyard_polygon = z\n .object({\n type: z.literal(\"pcb_courtyard_polygon\"),\n pcb_courtyard_polygon_id: getZodPrefixedIdWithDefault(\n \"pcb_courtyard_polygon\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: visible_layer,\n points: z.array(point).min(3),\n color: z.string().optional(),\n })\n .describe(\"Defines a courtyard polygon on the PCB\")\n\nexport type PcbCourtyardPolygonInput = z.input<typeof pcb_courtyard_polygon>\ntype InferredPcbCourtyardPolygon = z.infer<typeof pcb_courtyard_polygon>\n\n/**\n * Defines a courtyard polygon on the PCB\n */\nexport interface PcbCourtyardPolygon {\n type: \"pcb_courtyard_polygon\"\n pcb_courtyard_polygon_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n layer: VisibleLayer\n points: Point[]\n color?: string\n}\n\n/**\n * @deprecated use PcbCourtyardPolygon\n */\nexport type PCBCourtyardPolygon = PcbCourtyardPolygon\n\nexpectTypesMatch<PcbCourtyardPolygon, InferredPcbCourtyardPolygon>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_courtyard_circle = z\n .object({\n type: z.literal(\"pcb_courtyard_circle\"),\n pcb_courtyard_circle_id: getZodPrefixedIdWithDefault(\n \"pcb_courtyard_circle\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n radius: length,\n layer: visible_layer,\n color: z.string().optional(),\n })\n .describe(\"Defines a courtyard circle on the PCB\")\n\nexport type PcbCourtyardCircleInput = z.input<typeof pcb_courtyard_circle>\ntype InferredPcbCourtyardCircle = z.infer<typeof pcb_courtyard_circle>\n\n/**\n * Defines a courtyard circle on the PCB\n */\nexport interface PcbCourtyardCircle {\n type: \"pcb_courtyard_circle\"\n pcb_courtyard_circle_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n radius: Length\n layer: VisibleLayer\n color?: string\n}\n\nexpectTypesMatch<PcbCourtyardCircle, InferredPcbCourtyardCircle>(true)\n","import { z } from \"zod\"\nimport { point3, asset, type Point3, type Asset } from \"../common\"\nimport { rotation, length, type Rotation, type Length } from \"../units\"\nimport { layer_ref, type LayerRef } from \"src/pcb\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n cad_model_axis_directions,\n type CadModelAxisDirection,\n} from \"./cad_model_conventions\"\n\nexport const cad_component = z\n .object({\n type: z.literal(\"cad_component\"),\n cad_component_id: z.string(),\n pcb_component_id: z.string(),\n source_component_id: z.string(),\n position: point3,\n rotation: point3.optional(),\n size: point3.optional(),\n layer: layer_ref.optional(),\n subcircuit_id: z.string().optional(),\n\n // These are all ways to generate/load the 3d model\n footprinter_string: z.string().optional(),\n model_obj_url: z.string().optional(),\n model_stl_url: z.string().optional(),\n model_3mf_url: z.string().optional(),\n model_gltf_url: z.string().optional(),\n model_glb_url: z.string().optional(),\n model_step_url: z.string().optional(),\n model_wrl_url: z.string().optional(),\n model_asset: asset.optional(),\n model_unit_to_mm_scale_factor: z.number().optional(),\n model_board_normal_direction: z\n .enum(cad_model_axis_directions)\n .optional()\n .describe(\n 'The direction in the model\\'s coordinate space that is considered \"up\" or \"coming out of the board surface\"',\n ),\n model_origin_position: point3.optional(),\n model_origin_alignment: z\n .enum([\n \"unknown\",\n \"center\",\n \"center_of_component_on_board_surface\",\n \"bottom_center_of_component\",\n ] as const)\n .optional(),\n model_object_fit: z\n .enum([\"contain_within_bounds\", \"fill_bounds\"] as const)\n .optional()\n .default(\"contain_within_bounds\"),\n model_jscad: z.any().optional(),\n show_as_translucent_model: z.boolean().optional(),\n anchor_alignment: z\n .enum([\"center\", \"center_of_component_on_board_surface\"] as const)\n .optional()\n .default(\"center\"),\n })\n .describe(\"Defines a component on the PCB\")\n\nexport type CadComponentInput = z.input<typeof cad_component>\ntype InferredCadComponent = z.infer<typeof cad_component>\n\nexport type CadComponentAnchorAlignment = NonNullable<\n InferredCadComponent[\"anchor_alignment\"]\n>\n\nexport interface CadComponent {\n type: \"cad_component\"\n cad_component_id: string\n pcb_component_id: string\n source_component_id: string\n position: Point3\n rotation?: Point3\n size?: Point3\n layer?: LayerRef\n subcircuit_id?: string\n footprinter_string?: string\n model_obj_url?: string\n model_stl_url?: string\n model_3mf_url?: string\n model_gltf_url?: string\n model_glb_url?: string\n model_step_url?: string\n model_wrl_url?: string\n model_asset?: Asset\n model_unit_to_mm_scale_factor?: number\n model_board_normal_direction?: CadModelAxisDirection\n model_origin_position?: Point3\n model_origin_alignment?:\n | \"unknown\"\n | \"center\"\n | \"center_of_component_on_board_surface\"\n | \"bottom_center_of_component\"\n model_object_fit: \"contain_within_bounds\" | \"fill_bounds\"\n model_jscad?: any\n show_as_translucent_model?: boolean\n anchor_alignment: CadComponentAnchorAlignment\n}\n\nexpectTypesMatch<CadComponent, InferredCadComponent>(true)\n","export const cad_model_formats = [\n \"obj\",\n \"stl\",\n \"3mf\",\n \"gltf\",\n \"glb\",\n \"step\",\n \"wrl\",\n] as const\n\nexport const cad_model_axis_directions = [\n \"x+\",\n \"x-\",\n \"y+\",\n \"y-\",\n \"z+\",\n \"z-\",\n] as const\n\nexport type CadModelFormat = (typeof cad_model_formats)[number]\nexport type CadModelAxisDirection = (typeof cad_model_axis_directions)[number]\n\nexport const cadModelDefaultDirectionMap = {\n obj: \"z+\",\n stl: \"z+\",\n \"3mf\": \"z+\",\n gltf: \"y+\",\n glb: \"y+\",\n step: \"z+\",\n wrl: \"y+\",\n} as const\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { frequency, rotation, voltage } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const wave_shape = z.enum([\"sinewave\", \"square\", \"triangle\", \"sawtooth\"])\nexport type WaveShape = z.infer<typeof wave_shape>\n\nconst percentage = z\n .union([z.string(), z.number()])\n .transform((val) => {\n if (typeof val === \"string\") {\n if (val.endsWith(\"%\")) {\n return parseFloat(val.slice(0, -1)) / 100\n }\n return parseFloat(val)\n }\n return val\n })\n .pipe(\n z\n .number()\n .min(0, \"Duty cycle must be non-negative\")\n .max(1, \"Duty cycle cannot be greater than 100%\"),\n )\n\nexport const simulation_dc_voltage_source = z\n .object({\n type: z.literal(\"simulation_voltage_source\"),\n simulation_voltage_source_id: getZodPrefixedIdWithDefault(\n \"simulation_voltage_source\",\n ),\n is_dc_source: z.literal(true).optional().default(true),\n positive_source_port_id: z.string().optional(),\n negative_source_port_id: z.string().optional(),\n positive_source_net_id: z.string().optional(),\n negative_source_net_id: z.string().optional(),\n voltage: voltage,\n })\n .describe(\"Defines a DC voltage source for simulation\")\n\nexport const simulation_ac_voltage_source = z\n .object({\n type: z.literal(\"simulation_voltage_source\"),\n simulation_voltage_source_id: getZodPrefixedIdWithDefault(\n \"simulation_voltage_source\",\n ),\n is_dc_source: z.literal(false),\n terminal1_source_port_id: z.string().optional(),\n terminal2_source_port_id: z.string().optional(),\n terminal1_source_net_id: z.string().optional(),\n terminal2_source_net_id: z.string().optional(),\n voltage: voltage.optional(),\n frequency: frequency.optional(),\n peak_to_peak_voltage: voltage.optional(),\n wave_shape: wave_shape.optional(),\n phase: rotation.optional(),\n duty_cycle: percentage.optional(),\n })\n .describe(\"Defines an AC voltage source for simulation\")\n\nexport type SimulationAcVoltageSourceInput = z.input<\n typeof simulation_ac_voltage_source\n>\n\nexport const simulation_voltage_source = z\n .union([simulation_dc_voltage_source, simulation_ac_voltage_source])\n .describe(\"Defines a voltage source for simulation\")\n\nexport type SimulationVoltageSourceInput = z.input<\n typeof simulation_voltage_source\n>\ntype InferredSimulationVoltageSource = z.infer<typeof simulation_voltage_source>\n\n/**\n * Defines a DC voltage source for simulation purposes. It applies a voltage\n * difference between two source ports.\n */\nexport interface SimulationDcVoltageSource {\n type: \"simulation_voltage_source\"\n simulation_voltage_source_id: string\n is_dc_source: true\n positive_source_port_id?: string\n positive_source_net_id?: string\n negative_source_port_id?: string\n negative_source_net_id?: string\n voltage: number\n}\n\n/**\n * Defines an AC voltage source for simulation purposes.\n */\nexport interface SimulationAcVoltageSource {\n type: \"simulation_voltage_source\"\n simulation_voltage_source_id: string\n is_dc_source: false\n terminal1_source_port_id?: string\n terminal2_source_port_id?: string\n terminal1_source_net_id?: string\n terminal2_source_net_id?: string\n voltage?: number\n frequency?: number\n peak_to_peak_voltage?: number\n wave_shape?: WaveShape\n phase?: number\n duty_cycle?: number\n}\n\nexport type SimulationVoltageSource =\n | SimulationDcVoltageSource\n | SimulationAcVoltageSource\n\nexpectTypesMatch<\n SimulationDcVoltageSource,\n z.infer<typeof simulation_dc_voltage_source>\n>(true)\nexpectTypesMatch<\n SimulationAcVoltageSource,\n z.infer<typeof simulation_ac_voltage_source>\n>(true)\nexpectTypesMatch<SimulationVoltageSource, InferredSimulationVoltageSource>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { current, frequency, rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n wave_shape,\n type WaveShape,\n} from \"src/simulation/simulation_voltage_source\"\n\nconst percentage = z\n .union([z.string(), z.number()])\n .transform((val) => {\n if (typeof val === \"string\") {\n if (val.endsWith(\"%\")) {\n return parseFloat(val.slice(0, -1)) / 100\n }\n return parseFloat(val)\n }\n return val\n })\n .pipe(\n z\n .number()\n .min(0, \"Duty cycle must be non-negative\")\n .max(1, \"Duty cycle cannot be greater than 100%\"),\n )\n\nexport const simulation_dc_current_source = z\n .object({\n type: z.literal(\"simulation_current_source\"),\n simulation_current_source_id: getZodPrefixedIdWithDefault(\n \"simulation_current_source\",\n ),\n is_dc_source: z.literal(true).optional().default(true),\n positive_source_port_id: z.string().optional(),\n negative_source_port_id: z.string().optional(),\n positive_source_net_id: z.string().optional(),\n negative_source_net_id: z.string().optional(),\n current: current,\n })\n .describe(\"Defines a DC current source for simulation\")\n\nexport const simulation_ac_current_source = z\n .object({\n type: z.literal(\"simulation_current_source\"),\n simulation_current_source_id: getZodPrefixedIdWithDefault(\n \"simulation_current_source\",\n ),\n is_dc_source: z.literal(false),\n terminal1_source_port_id: z.string().optional(),\n terminal2_source_port_id: z.string().optional(),\n terminal1_source_net_id: z.string().optional(),\n terminal2_source_net_id: z.string().optional(),\n current: current.optional(),\n frequency: frequency.optional(),\n peak_to_peak_current: current.optional(),\n wave_shape: wave_shape.optional(),\n phase: rotation.optional(),\n duty_cycle: percentage.optional(),\n })\n .describe(\"Defines an AC current source for simulation\")\n\nexport type SimulationAcCurrentSourceInput = z.input<\n typeof simulation_ac_current_source\n>\n\nexport const simulation_current_source = z\n .union([simulation_dc_current_source, simulation_ac_current_source])\n .describe(\"Defines a current source for simulation\")\n\nexport type SimulationCurrentSourceInput = z.input<\n typeof simulation_current_source\n>\ntype InferredSimulationCurrentSource = z.infer<typeof simulation_current_source>\n\n/**\n * Defines a DC current source for simulation purposes. It forces a current\n * between two source ports.\n */\nexport interface SimulationDcCurrentSource {\n type: \"simulation_current_source\"\n simulation_current_source_id: string\n is_dc_source: true\n positive_source_port_id?: string\n positive_source_net_id?: string\n negative_source_port_id?: string\n negative_source_net_id?: string\n current: number\n}\n\n/**\n * Defines an AC current source for simulation purposes.\n */\nexport interface SimulationAcCurrentSource {\n type: \"simulation_current_source\"\n simulation_current_source_id: string\n is_dc_source: false\n terminal1_source_port_id?: string\n terminal2_source_port_id?: string\n terminal1_source_net_id?: string\n terminal2_source_net_id?: string\n current?: number\n frequency?: number\n peak_to_peak_current?: number\n wave_shape?: WaveShape\n phase?: number\n duty_cycle?: number\n}\n\nexport type SimulationCurrentSource =\n | SimulationDcCurrentSource\n | SimulationAcCurrentSource\n\nexpectTypesMatch<\n SimulationDcCurrentSource,\n z.infer<typeof simulation_dc_current_source>\n>(true)\nexpectTypesMatch<\n SimulationAcCurrentSource,\n z.infer<typeof simulation_ac_current_source>\n>(true)\nexpectTypesMatch<SimulationCurrentSource, InferredSimulationCurrentSource>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { duration_ms, ms } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const experiment_type = z.union([\n z.literal(\"spice_dc_sweep\"),\n z.literal(\"spice_dc_operating_point\"),\n z.literal(\"spice_transient_analysis\"),\n z.literal(\"spice_ac_analysis\"),\n])\n\nexport type ExperimentType = z.infer<typeof experiment_type>\n\nexport interface SimulationExperiment {\n type: \"simulation_experiment\"\n simulation_experiment_id: string\n name: string\n experiment_type: ExperimentType\n time_per_step?: number // ms\n start_time_ms?: number // ms\n end_time_ms?: number // ms\n}\n\nexport const simulation_experiment = z\n .object({\n type: z.literal(\"simulation_experiment\"),\n simulation_experiment_id: getZodPrefixedIdWithDefault(\n \"simulation_experiment\",\n ),\n name: z.string(),\n experiment_type,\n time_per_step: duration_ms.optional(),\n start_time_ms: ms.optional(),\n end_time_ms: ms.optional(),\n })\n .describe(\"Defines a simulation experiment configuration\")\n\nexport type SimulationExperimentInput = z.input<typeof simulation_experiment>\ntype InferredSimulationExperiment = z.infer<typeof simulation_experiment>\n\nexpectTypesMatch<SimulationExperiment, InferredSimulationExperiment>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { duration_ms, ms } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SimulationTransientVoltageGraph {\n type: \"simulation_transient_voltage_graph\"\n simulation_transient_voltage_graph_id: string\n simulation_experiment_id: string\n timestamps_ms?: number[]\n voltage_levels: number[]\n source_component_id?: string\n subcircuit_connectivity_map_key?: string\n time_per_step: number\n start_time_ms: number\n end_time_ms: number\n name?: string\n color?: string\n}\n\nexport const simulation_transient_voltage_graph = z\n .object({\n type: z.literal(\"simulation_transient_voltage_graph\"),\n simulation_transient_voltage_graph_id: getZodPrefixedIdWithDefault(\n \"simulation_transient_voltage_graph\",\n ),\n simulation_experiment_id: z.string(),\n timestamps_ms: z.array(z.number()).optional(),\n voltage_levels: z.array(z.number()),\n source_component_id: z.string().optional(),\n subcircuit_connectivity_map_key: z.string().optional(),\n time_per_step: duration_ms,\n start_time_ms: ms,\n end_time_ms: ms,\n name: z.string().optional(),\n color: z.string().optional(),\n })\n .describe(\"Stores voltage measurements over time for a simulation\")\n\nexport type SimulationTransientVoltageGraphInput = z.input<\n typeof simulation_transient_voltage_graph\n>\ntype InferredSimulationTransientVoltageGraph = z.infer<\n typeof simulation_transient_voltage_graph\n>\n\nexpectTypesMatch<\n SimulationTransientVoltageGraph,\n InferredSimulationTransientVoltageGraph\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { frequency, ms } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const simulation_switch = z\n .object({\n type: z.literal(\"simulation_switch\"),\n simulation_switch_id: getZodPrefixedIdWithDefault(\"simulation_switch\"),\n source_component_id: z.string().optional(),\n closes_at: ms.optional(),\n opens_at: ms.optional(),\n starts_closed: z.boolean().optional(),\n switching_frequency: frequency.optional(),\n })\n .describe(\"Defines a switch for simulation timing control\")\n\nexport type SimulationSwitchInput = z.input<typeof simulation_switch>\n\ntype InferredSimulationSwitch = z.infer<typeof simulation_switch>\n\nexport interface SimulationSwitch {\n type: \"simulation_switch\"\n simulation_switch_id: string\n source_component_id?: string\n closes_at?: number\n opens_at?: number\n starts_closed?: boolean\n switching_frequency?: number\n}\n\nexpectTypesMatch<SimulationSwitch, InferredSimulationSwitch>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const simulation_voltage_probe = z\n .object({\n type: z.literal(\"simulation_voltage_probe\"),\n simulation_voltage_probe_id: getZodPrefixedIdWithDefault(\n \"simulation_voltage_probe\",\n ),\n source_component_id: z.string().optional(),\n name: z.string().optional(),\n signal_input_source_port_id: z.string().optional(),\n signal_input_source_net_id: z.string().optional(),\n reference_input_source_port_id: z.string().optional(),\n reference_input_source_net_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n color: z.string().optional(),\n })\n .describe(\n \"Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.\",\n )\n .superRefine((data, ctx) => {\n const is_differential =\n data.reference_input_source_port_id || data.reference_input_source_net_id\n\n if (is_differential) {\n const has_ports =\n !!data.signal_input_source_port_id ||\n !!data.reference_input_source_port_id\n const has_nets =\n !!data.signal_input_source_net_id ||\n !!data.reference_input_source_net_id\n\n if (has_ports && has_nets) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message:\n \"Cannot mix port and net connections in a differential probe.\",\n })\n } else if (has_ports) {\n if (\n !data.signal_input_source_port_id ||\n !data.reference_input_source_port_id\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message:\n \"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id.\",\n })\n }\n } else if (has_nets) {\n if (\n !data.signal_input_source_net_id ||\n !data.reference_input_source_net_id\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message:\n \"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id.\",\n })\n }\n }\n } else {\n // Single-ended probe\n if (\n !!data.signal_input_source_port_id === !!data.signal_input_source_net_id\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message:\n \"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id.\",\n })\n }\n }\n })\n\nexport type SimulationVoltageProbeInput = z.input<\n typeof simulation_voltage_probe\n>\ntype InferredSimulationVoltageProbe = z.infer<typeof simulation_voltage_probe>\n\n/**\n * Defines a voltage probe for simulation. If a reference input is not provided,\n * it measures against ground. If a reference input is provided, it measures\n * the differential voltage between two points.\n */\nexport interface SimulationVoltageProbe {\n type: \"simulation_voltage_probe\"\n simulation_voltage_probe_id: string\n source_component_id?: string\n name?: string\n signal_input_source_port_id?: string\n signal_input_source_net_id?: string\n reference_input_source_port_id?: string\n reference_input_source_net_id?: string\n subcircuit_id?: string\n color?: string\n}\n\nexpectTypesMatch<SimulationVoltageProbe, InferredSimulationVoltageProbe>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const simulation_unknown_experiment_error = base_circuit_json_error\n .extend({\n type: z.literal(\"simulation_unknown_experiment_error\"),\n simulation_unknown_experiment_error_id: getZodPrefixedIdWithDefault(\n \"simulation_unknown_experiment_error\",\n ),\n error_type: z\n .literal(\"simulation_unknown_experiment_error\")\n .default(\"simulation_unknown_experiment_error\"),\n simulation_experiment_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"An unknown error occurred during the simulation experiment.\")\n\nexport type SimulationUnknownExperimentErrorInput = z.input<\n typeof simulation_unknown_experiment_error\n>\ntype InferredSimulationUnknownExperimentError = z.infer<\n typeof simulation_unknown_experiment_error\n>\n\n/**\n * An unknown error occurred during the simulation experiment.\n */\nexport interface SimulationUnknownExperimentError extends BaseCircuitJsonError {\n type: \"simulation_unknown_experiment_error\"\n simulation_unknown_experiment_error_id: string\n error_type: \"simulation_unknown_experiment_error\"\n simulation_experiment_id?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SimulationUnknownExperimentError,\n InferredSimulationUnknownExperimentError\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const simulation_op_amp = z\n .object({\n type: z.literal(\"simulation_op_amp\"),\n simulation_op_amp_id: getZodPrefixedIdWithDefault(\"simulation_op_amp\"),\n source_component_id: z.string().optional(),\n inverting_input_source_port_id: z.string(),\n non_inverting_input_source_port_id: z.string(),\n output_source_port_id: z.string(),\n positive_supply_source_port_id: z.string(),\n negative_supply_source_port_id: z.string(),\n })\n .describe(\"Defines a simple ideal operational amplifier for simulation\")\n\nexport type SimulationOpAmpInput = z.input<typeof simulation_op_amp>\ntype InferredSimulationOpAmp = z.infer<typeof simulation_op_amp>\n\n/**\n * Defines a simple ideal operational amplifier for simulation.\n */\nexport interface SimulationOpAmp {\n type: \"simulation_op_amp\"\n simulation_op_amp_id: string\n source_component_id?: string\n inverting_input_source_port_id: string\n non_inverting_input_source_port_id: string\n output_source_port_id: string\n positive_supply_source_port_id: string\n negative_supply_source_port_id: string\n}\n\nexpectTypesMatch<SimulationOpAmp, InferredSimulationOpAmp>(true)\n","import { z } from \"zod\"\nimport * as pcb from \"./pcb\"\nimport * as sch from \"./schematic\"\nimport * as src from \"./source\"\nimport * as cad from \"./cad\"\nimport * as sim from \"./simulation\"\nimport {\n expectStringUnionsMatch,\n expectTypesMatch,\n} from \"./utils/expect-types-match\"\n\nexport const any_circuit_element = z.union([\n // TODO source_config\n // TODO pcb_config\n // TODO schematic_config\n // TODO schematic_group\n src.source_trace,\n src.source_port,\n src.source_component_internal_connection,\n src.any_source_component,\n src.source_net,\n src.source_group,\n src.source_simple_chip,\n src.source_simple_capacitor,\n src.source_simple_diode,\n src.source_simple_led,\n src.source_simple_resistor,\n src.source_simple_power_source,\n src.source_simple_battery,\n src.source_simple_inductor,\n src.source_simple_pin_header,\n src.source_simple_pinout,\n src.source_simple_resonator,\n src.source_simple_switch,\n src.source_simple_transistor,\n src.source_simple_test_point,\n src.source_simple_mosfet,\n src.source_simple_op_amp,\n src.source_simple_potentiometer,\n src.source_simple_push_button,\n src.source_pcb_ground_plane,\n src.source_manually_placed_via,\n src.source_board,\n src.source_project_metadata,\n src.source_invalid_component_property_error,\n src.source_trace_not_connected_error,\n src.source_pin_missing_trace_warning,\n src.source_no_power_pin_defined_warning,\n src.source_no_ground_pin_defined_warning,\n src.source_component_pins_underspecified_warning,\n src.source_pin_must_be_connected_error,\n src.unknown_error_finding_part,\n src.source_i2c_misconfigured_error,\n src.source_ambiguous_port_reference,\n pcb.pcb_component,\n pcb.pcb_hole,\n pcb.pcb_missing_footprint_error,\n pcb.external_footprint_load_error,\n pcb.circuit_json_footprint_load_error,\n pcb.pcb_manual_edit_conflict_warning,\n pcb.pcb_connector_not_in_accessible_orientation_warning,\n pcb.pcb_plated_hole,\n pcb.pcb_keepout,\n pcb.pcb_port,\n pcb.pcb_net,\n pcb.pcb_text,\n pcb.pcb_trace,\n pcb.pcb_via,\n pcb.pcb_smtpad,\n pcb.pcb_solder_paste,\n pcb.pcb_board,\n pcb.pcb_panel,\n pcb.pcb_group,\n pcb.pcb_trace_hint,\n pcb.pcb_silkscreen_line,\n pcb.pcb_silkscreen_path,\n pcb.pcb_silkscreen_text,\n pcb.pcb_silkscreen_pill,\n pcb.pcb_copper_text,\n pcb.pcb_silkscreen_rect,\n pcb.pcb_silkscreen_circle,\n pcb.pcb_silkscreen_oval,\n pcb.pcb_trace_error,\n pcb.pcb_trace_missing_error,\n pcb.pcb_placement_error,\n pcb.pcb_panelization_placement_error,\n pcb.pcb_port_not_matched_error,\n pcb.pcb_port_not_connected_error,\n pcb.pcb_via_clearance_error,\n pcb.pcb_fabrication_note_path,\n pcb.pcb_fabrication_note_text,\n pcb.pcb_fabrication_note_rect,\n pcb.pcb_fabrication_note_dimension,\n pcb.pcb_note_text,\n pcb.pcb_note_rect,\n pcb.pcb_note_path,\n pcb.pcb_note_line,\n pcb.pcb_note_dimension,\n pcb.pcb_autorouting_error,\n pcb.pcb_footprint_overlap_error,\n pcb.pcb_courtyard_overlap_error,\n pcb.pcb_breakout_point,\n pcb.pcb_cutout,\n pcb.pcb_ground_plane,\n pcb.pcb_ground_plane_region,\n pcb.pcb_thermal_spoke,\n pcb.pcb_copper_pour,\n pcb.pcb_component_outside_board_error,\n pcb.pcb_component_not_on_board_edge_error,\n pcb.pcb_component_invalid_layer_error,\n pcb.pcb_courtyard_rect,\n pcb.pcb_courtyard_outline,\n pcb.pcb_courtyard_polygon,\n pcb.pcb_courtyard_circle,\n sch.schematic_box,\n sch.schematic_text,\n sch.schematic_line,\n sch.schematic_rect,\n sch.schematic_circle,\n sch.schematic_arc,\n sch.schematic_component,\n sch.schematic_symbol,\n sch.schematic_port,\n sch.schematic_trace,\n sch.schematic_path,\n sch.schematic_error,\n sch.schematic_layout_error,\n sch.schematic_net_label,\n sch.schematic_debug_object,\n sch.schematic_voltage_probe,\n sch.schematic_manual_edit_conflict_warning,\n sch.schematic_group,\n sch.schematic_sheet,\n sch.schematic_table,\n sch.schematic_table_cell,\n cad.cad_component,\n sim.simulation_voltage_source,\n sim.simulation_current_source,\n sim.simulation_experiment,\n sim.simulation_transient_voltage_graph,\n sim.simulation_switch,\n sim.simulation_voltage_probe,\n sim.simulation_unknown_experiment_error,\n sim.simulation_op_amp,\n])\n\n/**\n * @deprecated use any_circuit_element instead\n */\nexport const any_soup_element = any_circuit_element\n\nexport type AnyCircuitElement = z.infer<typeof any_circuit_element>\nexport type AnyCircuitElementInput = z.input<typeof any_circuit_element>\n/**\n * @deprecated use AnyCircuitElement instead\n */\nexport type AnySoupElement = AnyCircuitElement\n\n/**\n * @deprecated use AnyCircuitElementInput instead\n */\nexport type AnySoupElementInput = AnyCircuitElementInput\n\n/**\n * Type representing a complete Circuit JSON document, which is an array of circuit elements.\n * This is the primary type used when working with circuit-json files or API responses.\n */\nexport type CircuitJson = AnyCircuitElement[]\n\n// ------------------- SAFETY CHECKS -------------------\n\n// SAFETY CHECK: Every element has a type\nexpectTypesMatch<\n AnyCircuitElement extends { type: string } ? AnyCircuitElement : never,\n AnyCircuitElement\n>(true)\n\n// SAFETY CHECK: Every element has an id with the key name `${type}_id`\ntype FindMissingId<T extends AnyCircuitElement> = T extends {\n type: infer U extends string\n}\n ? T extends { [K in `${U}_id`]: infer V }\n ? V extends string\n ? never\n : `${U} DOES NOT HAVE AN ${U}_id PROPERTY`\n : `${U} DOES NOT HAVE AN ${U}_id PROPERTY`\n : never\n\nexpectStringUnionsMatch<\n FindMissingId<AnyCircuitElement>,\n // EXCEPTIONS TO THE RULE\n // THIS IS FOR LEGACY REASONS, DO NOT ADD MORE EXCEPTIONS\n | \"source_project_metadata DOES NOT HAVE AN source_project_metadata_id PROPERTY\"\n | \"pcb_port_not_matched_error DOES NOT HAVE AN pcb_port_not_matched_error_id PROPERTY\"\n | \"pcb_autorouting_error DOES NOT HAVE AN pcb_autorouting_error_id PROPERTY\"\n | \"pcb_footprint_overlap_error DOES NOT HAVE AN pcb_footprint_overlap_error_id PROPERTY\"\n | \"pcb_courtyard_overlap_error DOES NOT HAVE AN pcb_courtyard_overlap_error_id PROPERTY\"\n | \"pcb_via_clearance_error DOES NOT HAVE AN pcb_via_clearance_error_id PROPERTY\"\n | \"schematic_debug_object DOES NOT HAVE AN schematic_debug_object_id PROPERTY\"\n | \"schematic_box DOES NOT HAVE AN schematic_box_id PROPERTY\"\n>(true)\n","/**\n * Calculate a point transformed with an affine matrix\n * @param matrix {Matrix} Affine Matrix\n * @param point {Point} Point\n * @returns {Point} Point\n */\nexport function applyToPoint (matrix, point) {\n return Array.isArray(point)\n ? [\n matrix.a * point[0] + matrix.c * point[1] + matrix.e,\n matrix.b * point[0] + matrix.d * point[1] + matrix.f\n ]\n : {\n x: matrix.a * point.x + matrix.c * point.y + matrix.e,\n y: matrix.b * point.x + matrix.d * point.y + matrix.f\n }\n}\n\n/**\n * Calculate an array of points transformed with an affine matrix\n * @param matrix {Matrix} Affine Matrix\n * @param points {Point[]} Array of point\n * @returns {Point[]} Array of point\n */\nexport function applyToPoints (matrix, points) {\n return points.map(point => applyToPoint(matrix, point))\n}\n","export function isUndefined (val) {\n return typeof val === 'undefined'\n}\n\nexport function isNumeric (n) {\n return typeof n === 'number' &&\n !Number.isNaN(n) &&\n Number.isFinite(n)\n}\n\nexport function isObject (obj) {\n return typeof obj === 'object' &&\n obj !== null &&\n !Array.isArray(obj)\n}\n\nexport function matchesShape (obj, keys) {\n return keys.every(key => key in obj)\n}\n","/**\n * Calculate a translate matrix\n * @param tx {number} Translation on axis x\n * @param [ty = 0] {number} Translation on axis y\n * @returns {Matrix} Affine Matrix\n */\nexport function translate (tx, ty = 0) {\n return {\n a: 1,\n c: 0,\n e: tx,\n b: 0,\n d: 1,\n f: ty\n }\n}\n","/**\n * Merge multiple matrices into one\n * @param matrices {...Matrix | Matrix[]} Matrices listed as separate parameters or in an array\n * @returns {Matrix} Affine Matrix\n */\nexport function transform (...matrices) {\n matrices = Array.isArray(matrices[0]) ? matrices[0] : matrices\n\n const multiply = (m1, m2) => {\n return {\n a: m1.a * m2.a + m1.c * m2.b,\n c: m1.a * m2.c + m1.c * m2.d,\n e: m1.a * m2.e + m1.c * m2.f + m1.e,\n b: m1.b * m2.a + m1.d * m2.b,\n d: m1.b * m2.c + m1.d * m2.d,\n f: m1.b * m2.e + m1.d * m2.f + m1.f\n }\n }\n\n switch (matrices.length) {\n case 0:\n throw new Error('no matrices provided')\n\n case 1:\n return matrices[0]\n\n case 2:\n return multiply(matrices[0], matrices[1])\n\n default: {\n const [m1, m2, ...rest] = matrices\n const m = multiply(m1, m2)\n return transform(m, ...rest)\n }\n }\n}\n\n/**\n * Merge multiple matrices into one\n * @param matrices {...Matrix | Matrix[]} Matrices listed as separate parameters or in an array\n * @returns {Matrix} Affine Matrix\n */\nexport function compose (...matrices) {\n return transform(...matrices)\n}\n","import { isUndefined } from './utils'\nimport { translate } from './translate'\nimport { transform } from './transform'\n\nconst { cos, sin, PI } = Math\n/**\n * Calculate a rotation matrix\n * @param angle {number} Angle in radians\n * @param [cx] {number} If (cx,cy) are supplied the rotate is about this point\n * @param [cy] {number} If (cx,cy) are supplied the rotate is about this point\n * @returns {Matrix} Affine Matrix\n */\nexport function rotate (angle, cx, cy) {\n const cosAngle = cos(angle)\n const sinAngle = sin(angle)\n const rotationMatrix = {\n a: cosAngle,\n c: -sinAngle,\n e: 0,\n b: sinAngle,\n d: cosAngle,\n f: 0\n }\n if (isUndefined(cx) || isUndefined(cy)) {\n return rotationMatrix\n }\n\n return transform([\n translate(cx, cy),\n rotationMatrix,\n translate(-cx, -cy)\n ])\n}\n\n/**\n * Calculate a rotation matrix with a DEG angle\n * @param angle {number} Angle in degree\n * @param [cx] {number} If (cx,cy) are supplied the rotate is about this point\n * @param [cy] {number} If (cx,cy) are supplied the rotate is about this point\n * @returns {Matrix} Affine Matrix\n */\nexport function rotateDEG (angle, cx = undefined, cy = undefined) {\n return rotate(angle * PI / 180, cx, cy)\n}\n","import { isUndefined } from './utils'\nimport { translate } from './translate'\nimport { transform } from './transform'\n\n/**\n * Calculate a scaling matrix\n * @param sx {number} Scaling on axis x\n * @param [sy = sx] {number} Scaling on axis y (default sx)\n * @param [cx] {number} If (cx,cy) are supplied the scaling is about this point\n * @param [cy] {number} If (cx,cy) are supplied the scaling is about this point\n * @returns {Matrix} Affine Matrix\n */\nexport function scale (sx, sy = undefined, cx = undefined, cy = undefined) {\n if (isUndefined(sy)) sy = sx\n\n const scaleMatrix = {\n a: sx,\n c: 0,\n e: 0,\n b: 0,\n d: sy,\n f: 0\n }\n\n if (isUndefined(cx) || isUndefined(cy)) {\n return scaleMatrix\n }\n\n return transform([\n translate(cx, cy),\n scaleMatrix,\n translate(-cx, -cy)\n ])\n}\n","// https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew\nconst { tan } = Math\n\n/**\n * Calculate a skew matrix\n * @param ax {number} Skew on axis x\n * @param ay {number} Skew on axis y\n * @returns {Matrix} Affine Matrix\n */\nexport function skew (ax, ay) {\n return {\n a: 1,\n c: tan(ax),\n e: 0,\n b: tan(ay),\n d: 1,\n f: 0\n }\n}\n\n/**\n * Calculate a skew matrix using DEG angles\n * @param ax {number} Skew on axis x\n * @param ay {number} Skew on axis y\n * @returns {Matrix} Affine Matrix\n */\nexport function skewDEG (ax, ay) {\n return skew(ax * Math.PI / 180, ay * Math.PI / 180)\n}\n","// Generated by Peggy 3.0.2.\n//\n// https://peggyjs.org/\n\nfunction peg$subclass(child, parent) {\n function C() { this.constructor = child; }\n C.prototype = parent.prototype;\n child.prototype = new C();\n}\n\nfunction peg$SyntaxError(message, expected, found, location) {\n var self = Error.call(this, message);\n // istanbul ignore next Check is a necessary evil to support older environments\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(self, peg$SyntaxError.prototype);\n }\n self.expected = expected;\n self.found = found;\n self.location = location;\n self.name = \"SyntaxError\";\n return self;\n}\n\npeg$subclass(peg$SyntaxError, Error);\n\nfunction peg$padEnd(str, targetLength, padString) {\n padString = padString || \" \";\n if (str.length > targetLength) { return str; }\n targetLength -= str.length;\n padString += padString.repeat(targetLength);\n return str + padString.slice(0, targetLength);\n}\n\npeg$SyntaxError.prototype.format = function(sources) {\n var str = \"Error: \" + this.message;\n if (this.location) {\n var src = null;\n var k;\n for (k = 0; k < sources.length; k++) {\n if (sources[k].source === this.location.source) {\n src = sources[k].text.split(/\\r\\n|\\n|\\r/g);\n break;\n }\n }\n var s = this.location.start;\n var offset_s = (this.location.source && (typeof this.location.source.offset === \"function\"))\n ? this.location.source.offset(s)\n : s;\n var loc = this.location.source + \":\" + offset_s.line + \":\" + offset_s.column;\n if (src) {\n var e = this.location.end;\n var filler = peg$padEnd(\"\", offset_s.line.toString().length, ' ');\n var line = src[s.line - 1];\n var last = s.line === e.line ? e.column : line.length + 1;\n var hatLen = (last - s.column) || 1;\n str += \"\\n --> \" + loc + \"\\n\"\n + filler + \" |\\n\"\n + offset_s.line + \" | \" + line + \"\\n\"\n + filler + \" | \" + peg$padEnd(\"\", s.column - 1, ' ')\n + peg$padEnd(\"\", hatLen, \"^\");\n } else {\n str += \"\\n at \" + loc;\n }\n }\n return str;\n};\n\npeg$SyntaxError.buildMessage = function(expected, found) {\n var DESCRIBE_EXPECTATION_FNS = {\n literal: function(expectation) {\n return \"\\\"\" + literalEscape(expectation.text) + \"\\\"\";\n },\n\n class: function(expectation) {\n var escapedParts = expectation.parts.map(function(part) {\n return Array.isArray(part)\n ? classEscape(part[0]) + \"-\" + classEscape(part[1])\n : classEscape(part);\n });\n\n return \"[\" + (expectation.inverted ? \"^\" : \"\") + escapedParts.join(\"\") + \"]\";\n },\n\n any: function() {\n return \"any character\";\n },\n\n end: function() {\n return \"end of input\";\n },\n\n other: function(expectation) {\n return expectation.description;\n }\n };\n\n function hex(ch) {\n return ch.charCodeAt(0).toString(16).toUpperCase();\n }\n\n function literalEscape(s) {\n return s\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\"/g, \"\\\\\\\"\")\n .replace(/\\0/g, \"\\\\0\")\n .replace(/\\t/g, \"\\\\t\")\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/[\\x00-\\x0F]/g, function(ch) { return \"\\\\x0\" + hex(ch); })\n .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return \"\\\\x\" + hex(ch); });\n }\n\n function classEscape(s) {\n return s\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\\]/g, \"\\\\]\")\n .replace(/\\^/g, \"\\\\^\")\n .replace(/-/g, \"\\\\-\")\n .replace(/\\0/g, \"\\\\0\")\n .replace(/\\t/g, \"\\\\t\")\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/[\\x00-\\x0F]/g, function(ch) { return \"\\\\x0\" + hex(ch); })\n .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return \"\\\\x\" + hex(ch); });\n }\n\n function describeExpectation(expectation) {\n return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);\n }\n\n function describeExpected(expected) {\n var descriptions = expected.map(describeExpectation);\n var i, j;\n\n descriptions.sort();\n\n if (descriptions.length > 0) {\n for (i = 1, j = 1; i < descriptions.length; i++) {\n if (descriptions[i - 1] !== descriptions[i]) {\n descriptions[j] = descriptions[i];\n j++;\n }\n }\n descriptions.length = j;\n }\n\n switch (descriptions.length) {\n case 1:\n return descriptions[0];\n\n case 2:\n return descriptions[0] + \" or \" + descriptions[1];\n\n default:\n return descriptions.slice(0, -1).join(\", \")\n + \", or \"\n + descriptions[descriptions.length - 1];\n }\n }\n\n function describeFound(found) {\n return found ? \"\\\"\" + literalEscape(found) + \"\\\"\" : \"end of input\";\n }\n\n return \"Expected \" + describeExpected(expected) + \" but \" + describeFound(found) + \" found.\";\n};\n\nfunction peg$parse(input, options) {\n options = options !== undefined ? options : {};\n\n var peg$FAILED = {};\n var peg$source = options.grammarSource;\n\n var peg$startRuleFunctions = { transformList: peg$parsetransformList };\n var peg$startRuleFunction = peg$parsetransformList;\n\n var peg$c0 = \"matrix\";\n var peg$c1 = \"(\";\n var peg$c2 = \")\";\n var peg$c3 = \"translate\";\n var peg$c4 = \"scale\";\n var peg$c5 = \"rotate\";\n var peg$c6 = \"skewX\";\n var peg$c7 = \"skewY\";\n var peg$c8 = \",\";\n var peg$c9 = \".\";\n\n var peg$r0 = /^[eE]/;\n var peg$r1 = /^[+\\-]/;\n var peg$r2 = /^[0-9]/;\n var peg$r3 = /^[ \\t\\r\\n]/;\n\n var peg$e0 = peg$literalExpectation(\"matrix\", false);\n var peg$e1 = peg$literalExpectation(\"(\", false);\n var peg$e2 = peg$literalExpectation(\")\", false);\n var peg$e3 = peg$literalExpectation(\"translate\", false);\n var peg$e4 = peg$literalExpectation(\"scale\", false);\n var peg$e5 = peg$literalExpectation(\"rotate\", false);\n var peg$e6 = peg$literalExpectation(\"skewX\", false);\n var peg$e7 = peg$literalExpectation(\"skewY\", false);\n var peg$e8 = peg$literalExpectation(\",\", false);\n var peg$e9 = peg$otherExpectation(\"fractionalConstant\");\n var peg$e10 = peg$literalExpectation(\".\", false);\n var peg$e11 = peg$classExpectation([\"e\", \"E\"], false, false);\n var peg$e12 = peg$classExpectation([\"+\", \"-\"], false, false);\n var peg$e13 = peg$classExpectation([[\"0\", \"9\"]], false, false);\n var peg$e14 = peg$classExpectation([\" \", \"\\t\", \"\\r\", \"\\n\"], false, false);\n\n var peg$f0 = function(ts) { return ts; };\n var peg$f1 = function(t, ts) { return t.concat(ts) };\n var peg$f2 = function(a, b, c, d, e, f) {\n return [{type: 'matrix', a: a, b: b, c: c, d: d, e: e, f: f}];\n };\n var peg$f3 = function(tx, ty) {\n var t = {type: 'translate', tx: tx};\n if (ty) t.ty = ty;\n return [t];\n };\n var peg$f4 = function(sx, sy) {\n var s = {type:'scale', sx: sx};\n if (sy) s.sy = sy;\n return [s];\n };\n var peg$f5 = function(angle, c) {\n var r = {type:'rotate', angle: angle};\n if (c) {\n r.cx = c[0];\n r.cy = c[1];\n }\n return [r];\n };\n var peg$f6 = function(angle) {\n return [{type: 'skewX', angle: angle}];\n };\n var peg$f7 = function(angle) {\n return [{type: 'skewY', angle: angle}];\n };\n var peg$f8 = function(f) { return parseFloat(f.join(\"\")); };\n var peg$f9 = function(i) { return parseInt(i.join(\"\")); };\n var peg$f10 = function(n) { return n; };\n var peg$f11 = function(n1, n2) { return [n1, n2]; };\n var peg$f12 = function(ds) { return ds.join(\"\"); };\n var peg$f13 = function(f, e) { return [f, e || null].join(\"\")};\n var peg$f14 = function(d, e) { return [d, e].join(\"\")};\n var peg$f15 = function(d1, d2) { return [d1 ? d1.join(\"\") : null, \".\", d2.join(\"\")].join(\"\"); };\n var peg$f16 = function(d) { return d.join(\"\"); };\n var peg$f17 = function(s, d) { return ['e', s, d.join(\"\")].join(\"\") };\n var peg$currPos = 0;\n var peg$savedPos = 0;\n var peg$posDetailsCache = [{ line: 1, column: 1 }];\n var peg$maxFailPos = 0;\n var peg$maxFailExpected = [];\n var peg$silentFails = 0;\n\n var peg$result;\n\n if (\"startRule\" in options) {\n if (!(options.startRule in peg$startRuleFunctions)) {\n throw new Error(\"Can't start parsing from rule \\\"\" + options.startRule + \"\\\".\");\n }\n\n peg$startRuleFunction = peg$startRuleFunctions[options.startRule];\n }\n\n function text() {\n return input.substring(peg$savedPos, peg$currPos);\n }\n\n function offset() {\n return peg$savedPos;\n }\n\n function range() {\n return {\n source: peg$source,\n start: peg$savedPos,\n end: peg$currPos\n };\n }\n\n function location() {\n return peg$computeLocation(peg$savedPos, peg$currPos);\n }\n\n function expected(description, location) {\n location = location !== undefined\n ? location\n : peg$computeLocation(peg$savedPos, peg$currPos);\n\n throw peg$buildStructuredError(\n [peg$otherExpectation(description)],\n input.substring(peg$savedPos, peg$currPos),\n location\n );\n }\n\n function error(message, location) {\n location = location !== undefined\n ? location\n : peg$computeLocation(peg$savedPos, peg$currPos);\n\n throw peg$buildSimpleError(message, location);\n }\n\n function peg$literalExpectation(text, ignoreCase) {\n return { type: \"literal\", text: text, ignoreCase: ignoreCase };\n }\n\n function peg$classExpectation(parts, inverted, ignoreCase) {\n return { type: \"class\", parts: parts, inverted: inverted, ignoreCase: ignoreCase };\n }\n\n function peg$anyExpectation() {\n return { type: \"any\" };\n }\n\n function peg$endExpectation() {\n return { type: \"end\" };\n }\n\n function peg$otherExpectation(description) {\n return { type: \"other\", description: description };\n }\n\n function peg$computePosDetails(pos) {\n var details = peg$posDetailsCache[pos];\n var p;\n\n if (details) {\n return details;\n } else {\n p = pos - 1;\n while (!peg$posDetailsCache[p]) {\n p--;\n }\n\n details = peg$posDetailsCache[p];\n details = {\n line: details.line,\n column: details.column\n };\n\n while (p < pos) {\n if (input.charCodeAt(p) === 10) {\n details.line++;\n details.column = 1;\n } else {\n details.column++;\n }\n\n p++;\n }\n\n peg$posDetailsCache[pos] = details;\n\n return details;\n }\n }\n\n function peg$computeLocation(startPos, endPos, offset) {\n var startPosDetails = peg$computePosDetails(startPos);\n var endPosDetails = peg$computePosDetails(endPos);\n\n var res = {\n source: peg$source,\n start: {\n offset: startPos,\n line: startPosDetails.line,\n column: startPosDetails.column\n },\n end: {\n offset: endPos,\n line: endPosDetails.line,\n column: endPosDetails.column\n }\n };\n if (offset && peg$source && (typeof peg$source.offset === \"function\")) {\n res.start = peg$source.offset(res.start);\n res.end = peg$source.offset(res.end);\n }\n return res;\n }\n\n function peg$fail(expected) {\n if (peg$currPos < peg$maxFailPos) { return; }\n\n if (peg$currPos > peg$maxFailPos) {\n peg$maxFailPos = peg$currPos;\n peg$maxFailExpected = [];\n }\n\n peg$maxFailExpected.push(expected);\n }\n\n function peg$buildSimpleError(message, location) {\n return new peg$SyntaxError(message, null, null, location);\n }\n\n function peg$buildStructuredError(expected, found, location) {\n return new peg$SyntaxError(\n peg$SyntaxError.buildMessage(expected, found),\n expected,\n found,\n location\n );\n }\n\n function peg$parsetransformList() {\n var s0, s1, s2, s3, s4;\n\n s0 = peg$currPos;\n s1 = [];\n s2 = peg$parsewsp();\n while (s2 !== peg$FAILED) {\n s1.push(s2);\n s2 = peg$parsewsp();\n }\n s2 = peg$parsetransforms();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s3 = [];\n s4 = peg$parsewsp();\n while (s4 !== peg$FAILED) {\n s3.push(s4);\n s4 = peg$parsewsp();\n }\n peg$savedPos = s0;\n s0 = peg$f0(s2);\n\n return s0;\n }\n\n function peg$parsetransforms() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$parsetransform();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsecommaWsp();\n if (s3 !== peg$FAILED) {\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsecommaWsp();\n }\n } else {\n s2 = peg$FAILED;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parsetransforms();\n if (s3 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f1(s1, s3);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parsetransform();\n }\n\n return s0;\n }\n\n function peg$parsetransform() {\n var s0;\n\n s0 = peg$parsematrix();\n if (s0 === peg$FAILED) {\n s0 = peg$parsetranslate();\n if (s0 === peg$FAILED) {\n s0 = peg$parsescale();\n if (s0 === peg$FAILED) {\n s0 = peg$parserotate();\n if (s0 === peg$FAILED) {\n s0 = peg$parseskewX();\n if (s0 === peg$FAILED) {\n s0 = peg$parseskewY();\n }\n }\n }\n }\n }\n\n return s0;\n }\n\n function peg$parsematrix() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 6) === peg$c0) {\n s1 = peg$c0;\n peg$currPos += 6;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e0); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = peg$parsecommaWsp();\n if (s6 !== peg$FAILED) {\n s7 = peg$parsenumber();\n if (s7 !== peg$FAILED) {\n s8 = peg$parsecommaWsp();\n if (s8 !== peg$FAILED) {\n s9 = peg$parsenumber();\n if (s9 !== peg$FAILED) {\n s10 = peg$parsecommaWsp();\n if (s10 !== peg$FAILED) {\n s11 = peg$parsenumber();\n if (s11 !== peg$FAILED) {\n s12 = peg$parsecommaWsp();\n if (s12 !== peg$FAILED) {\n s13 = peg$parsenumber();\n if (s13 !== peg$FAILED) {\n s14 = peg$parsecommaWsp();\n if (s14 !== peg$FAILED) {\n s15 = peg$parsenumber();\n if (s15 !== peg$FAILED) {\n s16 = [];\n s17 = peg$parsewsp();\n while (s17 !== peg$FAILED) {\n s16.push(s17);\n s17 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s17 = peg$c2;\n peg$currPos++;\n } else {\n s17 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s17 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f2(s5, s7, s9, s11, s13, s15);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsetranslate() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 9) === peg$c3) {\n s1 = peg$c3;\n peg$currPos += 9;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e3); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = peg$parsecommaWspNumber();\n if (s6 === peg$FAILED) {\n s6 = null;\n }\n s7 = [];\n s8 = peg$parsewsp();\n while (s8 !== peg$FAILED) {\n s7.push(s8);\n s8 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s8 = peg$c2;\n peg$currPos++;\n } else {\n s8 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s8 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f3(s5, s6);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsescale() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 5) === peg$c4) {\n s1 = peg$c4;\n peg$currPos += 5;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e4); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = peg$parsecommaWspNumber();\n if (s6 === peg$FAILED) {\n s6 = null;\n }\n s7 = [];\n s8 = peg$parsewsp();\n while (s8 !== peg$FAILED) {\n s7.push(s8);\n s8 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s8 = peg$c2;\n peg$currPos++;\n } else {\n s8 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s8 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f4(s5, s6);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parserotate() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 6) === peg$c5) {\n s1 = peg$c5;\n peg$currPos += 6;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e5); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = peg$parsecommaWspTwoNumbers();\n if (s6 === peg$FAILED) {\n s6 = null;\n }\n s7 = [];\n s8 = peg$parsewsp();\n while (s8 !== peg$FAILED) {\n s7.push(s8);\n s8 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s8 = peg$c2;\n peg$currPos++;\n } else {\n s8 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s8 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f5(s5, s6);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parseskewX() {\n var s0, s1, s2, s3, s4, s5, s6, s7;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 5) === peg$c6) {\n s1 = peg$c6;\n peg$currPos += 5;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e6); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = [];\n s7 = peg$parsewsp();\n while (s7 !== peg$FAILED) {\n s6.push(s7);\n s7 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s7 = peg$c2;\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s7 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f6(s5);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parseskewY() {\n var s0, s1, s2, s3, s4, s5, s6, s7;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 5) === peg$c7) {\n s1 = peg$c7;\n peg$currPos += 5;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e7); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = [];\n s7 = peg$parsewsp();\n while (s7 !== peg$FAILED) {\n s6.push(s7);\n s7 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s7 = peg$c2;\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s7 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f7(s5);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsenumber() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$currPos;\n s2 = peg$parsesign();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s3 = peg$parsefloatingPointConstant();\n if (s3 !== peg$FAILED) {\n s2 = [s2, s3];\n s1 = s2;\n } else {\n peg$currPos = s1;\n s1 = peg$FAILED;\n }\n if (s1 !== peg$FAILED) {\n peg$savedPos = s0;\n s1 = peg$f8(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$currPos;\n s2 = peg$parsesign();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s3 = peg$parseintegerConstant();\n if (s3 !== peg$FAILED) {\n s2 = [s2, s3];\n s1 = s2;\n } else {\n peg$currPos = s1;\n s1 = peg$FAILED;\n }\n if (s1 !== peg$FAILED) {\n peg$savedPos = s0;\n s1 = peg$f9(s1);\n }\n s0 = s1;\n }\n\n return s0;\n }\n\n function peg$parsecommaWspNumber() {\n var s0, s1, s2;\n\n s0 = peg$currPos;\n s1 = peg$parsecommaWsp();\n if (s1 !== peg$FAILED) {\n s2 = peg$parsenumber();\n if (s2 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f10(s2);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsecommaWspTwoNumbers() {\n var s0, s1, s2, s3, s4;\n\n s0 = peg$currPos;\n s1 = peg$parsecommaWsp();\n if (s1 !== peg$FAILED) {\n s2 = peg$parsenumber();\n if (s2 !== peg$FAILED) {\n s3 = peg$parsecommaWsp();\n if (s3 !== peg$FAILED) {\n s4 = peg$parsenumber();\n if (s4 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f11(s2, s4);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsecommaWsp() {\n var s0, s1, s2, s3, s4;\n\n s0 = peg$currPos;\n s1 = [];\n s2 = peg$parsewsp();\n if (s2 !== peg$FAILED) {\n while (s2 !== peg$FAILED) {\n s1.push(s2);\n s2 = peg$parsewsp();\n }\n } else {\n s1 = peg$FAILED;\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parsecomma();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s3 = [];\n s4 = peg$parsewsp();\n while (s4 !== peg$FAILED) {\n s3.push(s4);\n s4 = peg$parsewsp();\n }\n s1 = [s1, s2, s3];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parsecomma();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n }\n\n return s0;\n }\n\n function peg$parsecomma() {\n var s0;\n\n if (input.charCodeAt(peg$currPos) === 44) {\n s0 = peg$c8;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e8); }\n }\n\n return s0;\n }\n\n function peg$parseintegerConstant() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parsedigitSequence();\n if (s1 !== peg$FAILED) {\n peg$savedPos = s0;\n s1 = peg$f12(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parsefloatingPointConstant() {\n var s0, s1, s2;\n\n s0 = peg$currPos;\n s1 = peg$parsefractionalConstant();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseexponent();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n peg$savedPos = s0;\n s0 = peg$f13(s1, s2);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parsedigitSequence();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseexponent();\n if (s2 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f14(s1, s2);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n }\n\n return s0;\n }\n\n function peg$parsefractionalConstant() {\n var s0, s1, s2, s3;\n\n peg$silentFails++;\n s0 = peg$currPos;\n s1 = peg$parsedigitSequence();\n if (s1 === peg$FAILED) {\n s1 = null;\n }\n if (input.charCodeAt(peg$currPos) === 46) {\n s2 = peg$c9;\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e10); }\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parsedigitSequence();\n if (s3 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f15(s1, s3);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parsedigitSequence();\n if (s1 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 46) {\n s2 = peg$c9;\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e10); }\n }\n if (s2 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f16(s1);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n }\n peg$silentFails--;\n if (s0 === peg$FAILED) {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e9); }\n }\n\n return s0;\n }\n\n function peg$parseexponent() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (peg$r0.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e11); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parsesign();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s3 = peg$parsedigitSequence();\n if (s3 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f17(s2, s3);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsesign() {\n var s0;\n\n if (peg$r1.test(input.charAt(peg$currPos))) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e12); }\n }\n\n return s0;\n }\n\n function peg$parsedigitSequence() {\n var s0, s1;\n\n s0 = [];\n s1 = peg$parsedigit();\n if (s1 !== peg$FAILED) {\n while (s1 !== peg$FAILED) {\n s0.push(s1);\n s1 = peg$parsedigit();\n }\n } else {\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsedigit() {\n var s0;\n\n if (peg$r2.test(input.charAt(peg$currPos))) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e13); }\n }\n\n return s0;\n }\n\n function peg$parsewsp() {\n var s0;\n\n if (peg$r3.test(input.charAt(peg$currPos))) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e14); }\n }\n\n return s0;\n }\n\n peg$result = peg$startRuleFunction();\n\n if (peg$result !== peg$FAILED && peg$currPos === input.length) {\n return peg$result;\n } else {\n if (peg$result !== peg$FAILED && peg$currPos < input.length) {\n peg$fail(peg$endExpectation());\n }\n\n throw peg$buildStructuredError(\n peg$maxFailExpected,\n peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,\n peg$maxFailPos < input.length\n ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)\n : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)\n );\n }\n}\n\nexport {\n peg$SyntaxError as SyntaxError,\n\n peg$parse as parse\n};\n","import { scale } from './scale'\nimport { compose } from './transform'\n/**\n * Decompose a matrix into translation, scaling and rotation components, optionally\n * take horizontal and vertical flip in to consideration.\n * Note this function decomposes a matrix in rotation -> scaling -> translation order. I.e. for\n * certain translation T {tx, ty}, rotation R and scaling S { sx, sy }, it's only true for:\n * decomposeTSR(compose(T, S, R)) === { translate: T, rotation: R, scale: S }\n * composing in a different order may yield a different decomposition result.\n * @param matrix {Matrix} Affine Matrix\n * @param flipX {boolean} Whether the matrix contains vertical flip, i.e. mirrors on x-axis\n * @param flipY {boolean} Whether the matrix contains horizontal flip, i.e. mirrors on y-axis\n * @returns {Transform} A transform object consisted by its translation, scaling\n * and rotation components.\n */\nexport function decomposeTSR (matrix, flipX = false, flipY = false) {\n // Remove flip from the matrix first - flip could be incorrectly interpreted as\n // rotations (e.g. flipX + flipY = rotate by 180 degrees).\n // Note flipX is a vertical flip, and flipY is a horizontal flip.\n if (flipX) {\n if (flipY) {\n matrix = compose(matrix, scale(-1, -1))\n } else {\n matrix = compose(matrix, scale(1, -1))\n }\n } else if (flipY) {\n matrix = compose(matrix, scale(-1, 1))\n }\n\n const a = matrix.a; const b = matrix.b\n const c = matrix.c; const d = matrix.d\n let scaleX, scaleY, rotation\n\n if (a !== 0 || c !== 0) {\n const hypotAc = Math.hypot(a, c)\n scaleX = hypotAc\n scaleY = (a * d - b * c) / hypotAc\n const acos = Math.acos(a / hypotAc)\n rotation = c > 0 ? -acos : acos\n } else if (b !== 0 || d !== 0) {\n const hypotBd = Math.hypot(b, d)\n scaleX = (a * d - b * c) / hypotBd\n scaleY = hypotBd\n const acos = Math.acos(b / hypotBd)\n rotation = Math.PI / 2 + (d > 0 ? -acos : acos)\n } else {\n scaleX = 0\n scaleY = 0\n rotation = 0\n }\n\n // put the flip factors back\n if (flipY) {\n scaleX = -scaleX\n }\n\n if (flipX) {\n scaleY = -scaleY\n }\n\n return {\n translate: { tx: matrix.e, ty: matrix.f },\n scale: { sx: scaleX, sy: scaleY },\n rotation: { angle: rotation }\n }\n}\n","import type {\n AnyCircuitElement,\n AnyCircuitElementInput,\n SourceComponentBase,\n SourcePort,\n} from \"circuit-json\"\nimport * as Soup from \"circuit-json\"\nimport type { SubtreeOptions } from \"./subtree\"\nimport { buildSubtree } from \"./subtree\"\n\nexport type CircuitJsonOps<\n K extends AnyCircuitElement[\"type\"],\n T extends AnyCircuitElement | AnyCircuitElementInput,\n> = {\n get: (id: string) => Extract<T, { type: K }> | null\n select: (selector: string) => Extract<T, { type: K }> | null\n getWhere: (where: any) => Extract<T, { type: K }> | null\n getUsing: (using: {\n [key: `${string}_id`]: string\n }) => Extract<T, { type: K }> | null\n insert: (\n elm: Omit<Extract<T, { type: K }>, \"type\" | `${K}_id`>,\n ) => Extract<T, { type: K }>\n update: (\n id: string,\n newProps: Partial<Extract<T, { type: K }>>,\n ) => Extract<T, { type: K }>\n delete: (id: string) => void\n list: (where?: any) => Extract<T, { type: K }>[]\n}\n\nexport type CircuitJsonUtilObjects = {\n [K in AnyCircuitElement[\"type\"]]: CircuitJsonOps<K, AnyCircuitElement>\n} & {\n insert: (elm: AnyCircuitElementInput) => AnyCircuitElement\n insertAll: (elms: AnyCircuitElementInput[]) => AnyCircuitElement[]\n subtree: (where?: any) => CircuitJsonUtilObjects\n toArray: () => AnyCircuitElement[]\n editCount: number\n}\nexport type CircuitJsonInputUtilObjects = {\n [K in AnyCircuitElementInput[\"type\"]]: CircuitJsonOps<\n K,\n AnyCircuitElementInput\n >\n}\n\nexport type CircuitJsonUtilOptions = {\n validateInserts?: boolean\n}\n\nexport type GetCircuitJsonUtilFn = ((\n soup: AnyCircuitElement[],\n options?: CircuitJsonUtilOptions,\n) => CircuitJsonUtilObjects) & {\n unparsed: (soup: AnyCircuitElementInput[]) => CircuitJsonInputUtilObjects\n}\n\ninterface InternalStore {\n counts: Record<string, number>\n editCount: number\n}\n\nexport const cju: GetCircuitJsonUtilFn = ((\n circuitJsonInput: any[],\n options: CircuitJsonUtilOptions = {},\n) => {\n const circuitJson = circuitJsonInput as AnyCircuitElement[]\n let internalStore: InternalStore = (circuitJson as any)._internal_store\n if (!internalStore) {\n internalStore = {\n counts: {},\n editCount: 0,\n } as InternalStore\n ;(circuitJson as any)._internal_store = internalStore\n\n // Initialize counts\n for (const elm of circuitJson) {\n const type = elm.type\n const idVal = (elm as any)[`${type}_id`]\n if (!idVal) continue\n const idNum = Number.parseInt(idVal.split(\"_\").pop())\n if (!Number.isNaN(idNum)) {\n internalStore.counts[type] = Math.max(\n internalStore.counts[type] ?? 0,\n idNum,\n )\n }\n }\n }\n const su = new Proxy(\n {},\n {\n get: (proxy_target: any, prop: string) => {\n if (prop === \"toArray\") {\n return () => {\n ;(circuitJson as any).editCount = internalStore.editCount\n return circuitJson\n }\n }\n if (prop === \"editCount\") {\n return internalStore.editCount\n }\n\n if (prop === \"subtree\") {\n return (opts: SubtreeOptions) =>\n cju(buildSubtree(circuitJson, opts), options)\n }\n\n if (prop === \"insert\") {\n return (elm: AnyCircuitElementInput) => {\n const component_type = elm.type\n if (!component_type) {\n throw new Error(\"insert requires an element with a type\")\n }\n\n internalStore.counts[component_type] ??= -1\n internalStore.counts[component_type]++\n const index = internalStore.counts[component_type]\n\n const newElm = {\n ...elm,\n type: component_type,\n [`${component_type}_id`]: `${component_type}_${index}`,\n } as AnyCircuitElement\n\n if (options.validateInserts) {\n const parser =\n (Soup as any)[component_type] ?? Soup.any_soup_element\n parser.parse(newElm)\n }\n\n circuitJson.push(newElm)\n internalStore.editCount++\n return newElm\n }\n }\n\n if (prop === \"insertAll\") {\n return (elms: AnyCircuitElementInput[]) => {\n return elms.map((elm) => su.insert(elm))\n }\n }\n\n const component_type = prop\n\n return {\n get: (id: string) =>\n circuitJson.find(\n (e: any) =>\n e.type === component_type && e[`${component_type}_id`] === id,\n ),\n getUsing: (using: any) => {\n const keys = Object.keys(using)\n if (keys.length !== 1) {\n throw new Error(\n \"getUsing requires exactly one key, e.g. { pcb_component_id }\",\n )\n }\n const join_key = keys[0] as string\n const join_type = join_key.replace(\"_id\", \"\")\n const joiner: any = circuitJson.find(\n (e: any) =>\n e.type === join_type && e[join_key] === using[join_key],\n )\n if (!joiner) return null\n return circuitJson.find(\n (e: any) =>\n e.type === component_type &&\n e[`${component_type}_id`] === joiner[`${component_type}_id`],\n )\n },\n getWhere: (where: any) => {\n const keys = Object.keys(where)\n return circuitJson.find(\n (e: any) =>\n e.type === component_type &&\n keys.every((key) => e[key] === where[key]),\n )\n },\n list: (where?: any) => {\n const keys = !where ? [] : Object.keys(where)\n return circuitJson.filter(\n (e: any) =>\n e.type === component_type &&\n keys.every((key) => e[key] === where[key]),\n )\n },\n insert: (elm: any) => {\n internalStore.counts[component_type] ??= -1\n internalStore.counts[component_type]++\n const index = internalStore.counts[component_type]\n const newElm = {\n type: component_type,\n [`${component_type}_id`]: `${component_type}_${index}`,\n ...elm,\n }\n\n if (options.validateInserts) {\n const parser =\n (Soup as any)[component_type] ?? Soup.any_soup_element\n parser.parse(newElm)\n }\n\n circuitJson.push(newElm)\n internalStore.editCount++\n return newElm\n },\n delete: (id: string) => {\n const elm = circuitJson.find(\n (e) => (e as any)[`${component_type}_id`] === id,\n )\n if (!elm) return\n circuitJson.splice(circuitJson.indexOf(elm), 1)\n internalStore.editCount++\n },\n update: (id: string, newProps: any) => {\n const elm = circuitJson.find(\n (e) =>\n e.type === component_type &&\n (e as any)[`${component_type}_id`] === id,\n )\n if (!elm) return null\n Object.assign(elm, newProps)\n internalStore.editCount++\n return elm\n },\n select: (selector: string) => {\n // TODO when applySelector is isolated we can use it, until then we\n // do a poor man's selector implementation for two common cases\n if (component_type === \"source_component\") {\n return circuitJson.find(\n (e) =>\n e.type === \"source_component\" &&\n e.name === selector.replace(/\\./g, \"\"),\n )\n } else if (\n component_type === \"pcb_port\" ||\n component_type === \"source_port\" ||\n component_type === \"schematic_port\"\n ) {\n const [component_name, port_selector] = selector\n .replace(/\\./g, \"\")\n .split(/[\\s\\>]+/)\n const source_component = circuitJson.find(\n (e) =>\n e.type === \"source_component\" && e.name === component_name,\n ) as SourceComponentBase\n if (!source_component) return null\n const source_port = circuitJson.find(\n (e) =>\n e.type === \"source_port\" &&\n e.source_component_id ===\n source_component.source_component_id &&\n (e.name === port_selector ||\n (e.port_hints ?? []).includes(port_selector!)),\n ) as SourcePort\n if (!source_port) return null\n if (component_type === \"source_port\") return source_port\n\n if (component_type === \"pcb_port\") {\n return circuitJson.find(\n (e) =>\n e.type === \"pcb_port\" &&\n e.source_port_id === source_port.source_port_id,\n )\n } else if (component_type === \"schematic_port\") {\n return circuitJson.find(\n (e) =>\n e.type === \"schematic_port\" &&\n e.source_port_id === source_port.source_port_id,\n )\n }\n }\n },\n }\n },\n },\n )\n\n return su\n}) as any\ncju.unparsed = cju as any\n\nexport const su = cju\n\nexport default cju\n","import type { AnyCircuitElement } from \"circuit-json\"\n\nexport type SubtreeOptions = {\n subcircuit_id?: string\n subcircuit_ids?: string[]\n source_group_id?: string\n source_board_id?: string\n}\n\nfunction connect(\n map: Map<AnyCircuitElement, Set<AnyCircuitElement>>,\n a: AnyCircuitElement | undefined,\n b: AnyCircuitElement | undefined,\n) {\n if (!a || !b) return\n let setA = map.get(a)\n if (!setA) {\n setA = new Set()\n map.set(a, setA)\n }\n setA.add(b)\n let setB = map.get(b)\n if (!setB) {\n setB = new Set()\n map.set(b, setB)\n }\n setB.add(a)\n}\n\nexport function buildSubtree(\n soup: AnyCircuitElement[],\n opts: SubtreeOptions,\n): AnyCircuitElement[] {\n if (!opts.subcircuit_id && !opts.source_group_id) return [...soup]\n\n // For subcircuit_id, also include nested subcircuits\n let effectiveOpts = opts\n if (opts.subcircuit_id) {\n // Find all subcircuit_ids that are children of the target subcircuit\n const subcircuitIds = new Set<string>([opts.subcircuit_id])\n\n // Build group hierarchy\n const groupChildren = new Map<string, string[]>()\n const groupSubcircuit = new Map<string, string>()\n\n for (const elm of soup) {\n if (elm.type === \"source_group\") {\n const groupId = elm.source_group_id\n const subcircuitId = elm.subcircuit_id\n if (subcircuitId) {\n groupSubcircuit.set(groupId, subcircuitId)\n }\n const parentId = elm.parent_source_group_id\n if (parentId) {\n if (!groupChildren.has(parentId)) {\n groupChildren.set(parentId, [])\n }\n groupChildren.get(parentId)!.push(groupId)\n }\n }\n }\n\n // Find the root group for the target subcircuit\n let rootGroupId: string | undefined\n for (const [groupId, subcircuitId] of groupSubcircuit) {\n if (subcircuitId === opts.subcircuit_id) {\n rootGroupId = groupId\n break\n }\n }\n\n if (rootGroupId) {\n // Recursively collect all child subcircuit_ids\n const collectChildSubcircuits = (groupId: string) => {\n const children = groupChildren.get(groupId) || []\n for (const childId of children) {\n const childSubcircuit = groupSubcircuit.get(childId)\n if (childSubcircuit) {\n subcircuitIds.add(childSubcircuit)\n }\n collectChildSubcircuits(childId)\n }\n }\n collectChildSubcircuits(rootGroupId)\n\n // Update opts to include all these subcircuits\n effectiveOpts = { ...opts, subcircuit_ids: Array.from(subcircuitIds) }\n }\n }\n\n const idMap = new Map<string, AnyCircuitElement>()\n for (const elm of soup) {\n const idKey = `${elm.type}_id` as keyof typeof elm\n const idVal = elm[idKey]\n if (typeof idVal === \"string\") {\n idMap.set(idVal, elm)\n }\n }\n\n const adj = new Map<AnyCircuitElement, Set<AnyCircuitElement>>()\n for (const elm of soup) {\n const entries = Object.entries(elm)\n for (const [key, val] of entries) {\n if (key === \"parent_source_group_id\") continue // Skip parent relationships to avoid traversing up\n if (key.endsWith(\"_id\") && typeof val === \"string\") {\n const other = idMap.get(val)\n connect(adj, elm, other)\n } else if (key.endsWith(\"_ids\") && Array.isArray(val)) {\n for (const v of val) {\n if (typeof v === \"string\") {\n const other = idMap.get(v)\n connect(adj, elm, other)\n }\n }\n }\n }\n }\n\n const queue: AnyCircuitElement[] = []\n const included = new Set<AnyCircuitElement>()\n\n for (const elm of soup) {\n let shouldInclude = false\n if (\n effectiveOpts.subcircuit_id &&\n \"subcircuit_id\" in elm &&\n elm.subcircuit_id === effectiveOpts.subcircuit_id\n ) {\n shouldInclude = true\n } else if (\n effectiveOpts.subcircuit_ids &&\n \"subcircuit_id\" in elm &&\n elm.subcircuit_id &&\n effectiveOpts.subcircuit_ids.includes(elm.subcircuit_id)\n ) {\n shouldInclude = true\n } else if (\n effectiveOpts.source_group_id &&\n \"source_group_id\" in elm &&\n elm.source_group_id === effectiveOpts.source_group_id\n ) {\n shouldInclude = true\n } else if (\n effectiveOpts.source_group_id &&\n \"member_source_group_ids\" in elm &&\n Array.isArray(elm.member_source_group_ids) &&\n elm.member_source_group_ids.includes(effectiveOpts.source_group_id)\n ) {\n shouldInclude = true\n }\n\n if (shouldInclude) {\n queue.push(elm)\n included.add(elm)\n }\n }\n\n while (queue.length > 0) {\n const elm = queue.shift()!\n const neighbors = adj.get(elm)\n if (!neighbors) continue\n for (const n of neighbors) {\n if (!included.has(n)) {\n included.add(n)\n queue.push(n)\n }\n }\n }\n\n return soup.filter((e) => included.has(e))\n}\n","import type {\n AnyCircuitElement,\n AnyCircuitElementInput,\n SourceComponentBase,\n SourcePort,\n} from \"circuit-json\"\nimport * as Soup from \"circuit-json\"\nimport type {\n CircuitJsonOps,\n CircuitJsonUtilObjects as CircuitJsonUtilObjects,\n CircuitJsonInputUtilObjects as CircuitJsonInputUtilObjects,\n} from \"./cju\"\n\nexport type IndexedCircuitJsonUtilOptions = {\n validateInserts?: boolean\n indexConfig?: {\n // Enable specific indexes for faster lookups\n byId?: boolean\n byType?: boolean\n byRelation?: boolean\n bySubcircuit?: boolean\n byCustomField?: string[]\n }\n}\n\nexport type GetIndexedCircuitJsonUtilFn = ((\n soup: AnyCircuitElement[],\n options?: IndexedCircuitJsonUtilOptions,\n) => CircuitJsonUtilObjects) & {\n unparsed: (soup: AnyCircuitElementInput[]) => CircuitJsonInputUtilObjects\n}\n\ninterface InternalStore {\n counts: Record<string, number>\n editCount: number\n // Indexes for faster lookups\n indexes: {\n byId?: Map<string, AnyCircuitElement>\n byType?: Map<string, AnyCircuitElement[]>\n // Maps relation fields (like component_id) to elements\n byRelation?: Map<string, Map<string, AnyCircuitElement[]>>\n // Maps subcircuit_id to elements\n bySubcircuit?: Map<string, AnyCircuitElement[]>\n // Custom field indexes\n byCustomField?: Map<string, Map<string, AnyCircuitElement[]>>\n }\n}\n\n// Creates a unique key for the ID index\nfunction createIdKey(element: AnyCircuitElement): string {\n const type = element.type\n return `${type}:${(element as any)[`${type}_id`]}`\n}\n\nexport const cjuIndexed: GetIndexedCircuitJsonUtilFn = ((\n soup: AnyCircuitElement[],\n options: IndexedCircuitJsonUtilOptions = {},\n) => {\n let internalStore: InternalStore = (soup as any)._internal_store_indexed\n\n if (!internalStore) {\n internalStore = {\n counts: {},\n editCount: 0,\n indexes: {},\n } as InternalStore\n\n // Initialize counts\n for (const elm of soup) {\n const type = elm.type\n const idVal = (elm as any)[`${type}_id`]\n if (!idVal) continue\n const idNum = Number.parseInt(idVal.split(\"_\").pop() || \"\")\n if (!Number.isNaN(idNum)) {\n internalStore.counts[type] = Math.max(\n internalStore.counts[type] ?? 0,\n idNum,\n )\n }\n }\n\n // Build indexes\n const indexConfig = options.indexConfig || {}\n const indexes = internalStore.indexes\n\n // Reset indexes before rebuilding\n if (indexConfig.byId) {\n indexes.byId = new Map()\n }\n\n if (indexConfig.byType) {\n indexes.byType = new Map()\n }\n\n if (indexConfig.byRelation) {\n indexes.byRelation = new Map()\n }\n\n if (indexConfig.bySubcircuit) {\n indexes.bySubcircuit = new Map()\n }\n\n if (indexConfig.byCustomField && indexConfig.byCustomField.length > 0) {\n indexes.byCustomField = new Map()\n for (const field of indexConfig.byCustomField) {\n indexes.byCustomField.set(field, new Map())\n }\n }\n\n // Build indexes\n for (const element of soup) {\n // Index by ID\n if (indexConfig.byId) {\n const idKey = createIdKey(element)\n indexes.byId!.set(idKey, element)\n }\n\n // Index by type\n if (indexConfig.byType) {\n const elementsOfType = indexes.byType!.get(element.type) || []\n elementsOfType.push(element)\n indexes.byType!.set(element.type, elementsOfType)\n }\n\n // Index by relation fields (fields ending with _id)\n if (indexConfig.byRelation) {\n const elementEntries = Object.entries(element)\n for (const [key, value] of elementEntries) {\n if (\n key.endsWith(\"_id\") &&\n key !== `${element.type}_id` &&\n typeof value === \"string\"\n ) {\n const relationTypeMap = indexes.byRelation!.get(key) || new Map()\n const relatedElements = relationTypeMap.get(value as string) || []\n relatedElements.push(element)\n relationTypeMap.set(value as string, relatedElements)\n indexes.byRelation!.set(key, relationTypeMap)\n }\n }\n }\n\n // Index by subcircuit_id\n if (indexConfig.bySubcircuit && \"subcircuit_id\" in element) {\n const subcircuitId = (element as any).subcircuit_id\n if (subcircuitId && typeof subcircuitId === \"string\") {\n const subcircuitElements =\n indexes.bySubcircuit!.get(subcircuitId) || []\n subcircuitElements.push(element)\n indexes.bySubcircuit!.set(subcircuitId, subcircuitElements)\n }\n }\n\n // Index by custom fields\n if (indexConfig.byCustomField && indexes.byCustomField) {\n for (const field of indexConfig.byCustomField) {\n if (field in element) {\n const fieldValue = (element as any)[field]\n if (\n fieldValue !== undefined &&\n (typeof fieldValue === \"string\" || typeof fieldValue === \"number\")\n ) {\n const fieldValueStr = String(fieldValue)\n const fieldMap = indexes.byCustomField.get(field)!\n const elementsWithFieldValue = fieldMap.get(fieldValueStr) || []\n elementsWithFieldValue.push(element)\n fieldMap.set(fieldValueStr, elementsWithFieldValue)\n }\n }\n }\n }\n }\n // Store internal state\n ;(soup as any)._internal_store_indexed = internalStore\n }\n\n const suIndexed = new Proxy(\n {},\n {\n get: (proxy_target: any, prop: string) => {\n if (prop === \"toArray\") {\n return () => {\n ;(soup as any).editCount = internalStore.editCount\n return soup\n }\n }\n if (prop === \"editCount\") {\n return internalStore.editCount\n }\n\n const component_type = prop\n\n return {\n get: (id: string) => {\n const indexConfig = options.indexConfig || {}\n\n // Use ID index if available\n if (indexConfig.byId && internalStore.indexes.byId) {\n return (\n (internalStore.indexes.byId.get(\n `${component_type}:${id}`,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n // Use type index if available\n if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n return (\n (elementsOfType.find(\n (e: any) => e[`${component_type}_id`] === id,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n // Fallback to regular search\n return (\n (soup.find(\n (e: any) =>\n e.type === component_type && e[`${component_type}_id`] === id,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n },\n\n getUsing: (using: any) => {\n const indexConfig = options.indexConfig || {}\n const keys = Object.keys(using)\n\n if (keys.length !== 1) {\n throw new Error(\n \"getUsing requires exactly one key, e.g. { pcb_component_id }\",\n )\n }\n\n const join_key = keys[0] as string\n const join_type = join_key.replace(\"_id\", \"\")\n\n // Use relation index if available\n if (indexConfig.byRelation && internalStore.indexes.byRelation) {\n const relationMap = internalStore.indexes.byRelation.get(join_key)\n if (relationMap) {\n const relatedElements = relationMap.get(using[join_key]) || []\n const joiner = relatedElements.find((e) => e.type === join_type)\n\n if (!joiner) return null\n\n // Now find the element of component_type with matching ID\n const joinerId =\n joiner[`${component_type}_id` as keyof typeof joiner]\n\n if (indexConfig.byId && internalStore.indexes.byId) {\n return (\n (internalStore.indexes.byId.get(\n `${component_type}:${joinerId}`,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n return (\n (elementsOfType.find(\n (e: any) => e[`${component_type}_id`] === joinerId,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n return (\n (soup.find(\n (e: any) =>\n e.type === component_type &&\n e[`${component_type}_id`] === joinerId,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n }\n\n // Fallback to regular approach\n const joiner: any = soup.find(\n (e: any) =>\n e.type === join_type && e[join_key] === using[join_key],\n )\n\n if (!joiner) return null\n\n return (\n (soup.find(\n (e: any) =>\n e.type === component_type &&\n e[`${component_type}_id`] === joiner[`${component_type}_id`],\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n },\n\n getWhere: (where: any) => {\n const indexConfig = options.indexConfig || {}\n const keys = Object.keys(where)\n\n // If we're looking by a single property and it's indexed as a custom field\n if (\n keys.length === 1 &&\n indexConfig.byCustomField &&\n internalStore.indexes.byCustomField\n ) {\n const field = keys[0]\n const fieldMap = internalStore.indexes.byCustomField.get(field!)\n\n if (fieldMap) {\n const fieldValue = String(where[field!])\n const elementsWithFieldValue = fieldMap.get(fieldValue) || []\n\n return (\n (elementsWithFieldValue.find(\n (e: any) => e.type === component_type,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n }\n\n // If we're looking by subcircuit_id and it's indexed\n if (\n \"subcircuit_id\" in where &&\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit\n ) {\n const subcircuitId = where.subcircuit_id\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(subcircuitId) || []\n\n return (\n (subcircuitElements.find(\n (e: any) =>\n e.type === component_type &&\n keys.every((key) => e[key] === where[key]),\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n // Use type index if available to reduce search space\n if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n\n return (\n (elementsOfType.find((e: any) =>\n keys.every((key) => e[key] === where[key]),\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n // Fallback to regular approach\n return (\n (soup.find(\n (e: any) =>\n e.type === component_type &&\n keys.every((key) => e[key] === where[key]),\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n },\n\n list: (where?: any) => {\n const indexConfig = options.indexConfig || {}\n const keys = !where ? [] : Object.keys(where)\n\n // If no filters, just return all elements of this type using the type index\n if (\n keys.length === 0 &&\n indexConfig.byType &&\n internalStore.indexes.byType\n ) {\n return (internalStore.indexes.byType.get(component_type) ||\n []) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >[]\n }\n\n // If filtering by subcircuit_id and it's the only filter\n if (\n keys.length === 1 &&\n keys[0] === \"subcircuit_id\" &&\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit\n ) {\n const subcircuitId = where.subcircuit_id\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(subcircuitId) || []\n\n return subcircuitElements.filter(\n (e: any) => e.type === component_type,\n ) as Extract<AnyCircuitElement, { type: typeof component_type }>[]\n }\n\n // Start with all elements of this type to reduce search space\n let elementsToFilter: AnyCircuitElement[]\n\n if (indexConfig.byType && internalStore.indexes.byType) {\n elementsToFilter =\n internalStore.indexes.byType.get(component_type) || []\n } else {\n elementsToFilter = soup.filter((e) => e.type === component_type)\n }\n\n // Apply remaining filters\n if (keys.length > 0) {\n return elementsToFilter.filter((e: any) =>\n keys.every((key) => e[key] === where[key]),\n ) as Extract<AnyCircuitElement, { type: typeof component_type }>[]\n }\n\n return elementsToFilter as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >[]\n },\n\n insert: (elm: any) => {\n internalStore.counts[component_type] ??= -1\n internalStore.counts[component_type]++\n const index = internalStore.counts[component_type]\n const newElm = {\n type: component_type,\n [`${component_type}_id`]: `${component_type}_${index}`,\n ...elm,\n }\n\n if (options.validateInserts) {\n const parser =\n (Soup as any)[component_type] ?? Soup.any_soup_element\n parser.parse(newElm)\n }\n\n soup.push(newElm)\n internalStore.editCount++\n\n // Update indexes with the new element\n const indexConfig = options.indexConfig || {}\n\n // Update ID index\n if (indexConfig.byId && internalStore.indexes.byId) {\n const idKey = createIdKey(newElm)\n internalStore.indexes.byId.set(idKey, newElm)\n }\n\n // Update type index\n if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n elementsOfType.push(newElm)\n internalStore.indexes.byType.set(component_type, elementsOfType)\n }\n\n // Update relation index\n if (indexConfig.byRelation && internalStore.indexes.byRelation) {\n const elementEntries = Object.entries(newElm)\n for (const [key, value] of elementEntries) {\n if (\n key.endsWith(\"_id\") &&\n key !== `${newElm.type}_id` &&\n typeof value === \"string\"\n ) {\n const relationTypeMap =\n internalStore.indexes.byRelation.get(key) || new Map()\n const relatedElements =\n relationTypeMap.get(value as string) || []\n relatedElements.push(newElm)\n relationTypeMap.set(value as string, relatedElements)\n internalStore.indexes.byRelation.set(key, relationTypeMap)\n }\n }\n }\n\n // Update subcircuit index\n if (\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit &&\n \"subcircuit_id\" in newElm\n ) {\n const subcircuitId = (newElm as any).subcircuit_id\n if (subcircuitId && typeof subcircuitId === \"string\") {\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(subcircuitId) || []\n subcircuitElements.push(newElm)\n internalStore.indexes.bySubcircuit.set(\n subcircuitId,\n subcircuitElements,\n )\n }\n }\n\n // Update custom field indexes\n if (\n indexConfig.byCustomField &&\n internalStore.indexes.byCustomField\n ) {\n for (const field of indexConfig.byCustomField) {\n if (field in newElm) {\n const fieldValue = (newElm as any)[field]\n if (\n fieldValue !== undefined &&\n (typeof fieldValue === \"string\" ||\n typeof fieldValue === \"number\")\n ) {\n const fieldValueStr = String(fieldValue)\n const fieldMap =\n internalStore.indexes.byCustomField.get(field)!\n const elementsWithFieldValue =\n fieldMap.get(fieldValueStr) || []\n elementsWithFieldValue.push(newElm)\n fieldMap.set(fieldValueStr, elementsWithFieldValue)\n }\n }\n }\n }\n\n return newElm\n },\n\n delete: (id: string) => {\n const indexConfig = options.indexConfig || {}\n let elm: AnyCircuitElement | undefined\n\n // Find the element to delete\n if (indexConfig.byId && internalStore.indexes.byId) {\n elm = internalStore.indexes.byId.get(`${component_type}:${id}`)\n } else if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n elm = elementsOfType.find(\n (e: any) => e[`${component_type}_id`] === id,\n )\n } else {\n elm = soup.find((e) => (e as any)[`${component_type}_id`] === id)\n }\n\n if (!elm) return\n\n // Remove from array\n const elmIndex = soup.indexOf(elm)\n if (elmIndex >= 0) {\n soup.splice(elmIndex, 1)\n internalStore.editCount++\n }\n\n // Remove from indexes\n if (indexConfig.byId && internalStore.indexes.byId) {\n const idKey = createIdKey(elm)\n internalStore.indexes.byId.delete(idKey)\n }\n\n if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n const filteredElements = elementsOfType.filter(\n (e: any) => e[`${component_type}_id`] !== id,\n )\n internalStore.indexes.byType.set(component_type, filteredElements)\n }\n\n if (indexConfig.byRelation && internalStore.indexes.byRelation) {\n // This is more complex - we need to find and remove from all relation maps\n // where this element appears\n for (const [\n relationKey,\n relationMap,\n ] of internalStore.indexes.byRelation.entries()) {\n for (const [relationValue, elements] of relationMap.entries()) {\n const updatedElements = elements.filter((e) => e !== elm)\n\n if (updatedElements.length === 0) {\n relationMap.delete(relationValue)\n } else {\n relationMap.set(relationValue, updatedElements)\n }\n }\n }\n }\n\n if (\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit &&\n \"subcircuit_id\" in elm\n ) {\n const subcircuitId = (elm as any).subcircuit_id\n if (subcircuitId) {\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(subcircuitId) || []\n const updatedElements = subcircuitElements.filter(\n (e) => e !== elm,\n )\n\n if (updatedElements.length === 0) {\n internalStore.indexes.bySubcircuit.delete(subcircuitId)\n } else {\n internalStore.indexes.bySubcircuit.set(\n subcircuitId,\n updatedElements,\n )\n }\n }\n }\n\n if (\n indexConfig.byCustomField &&\n internalStore.indexes.byCustomField\n ) {\n for (const fieldMap of internalStore.indexes.byCustomField.values()) {\n for (const [fieldValue, elements] of fieldMap.entries()) {\n const updatedElements = elements.filter((e) => e !== elm)\n\n if (updatedElements.length === 0) {\n fieldMap.delete(fieldValue)\n } else {\n fieldMap.set(fieldValue, updatedElements)\n }\n }\n }\n }\n },\n\n update: (id: string, newProps: any) => {\n const indexConfig = options.indexConfig || {}\n let elm: AnyCircuitElement | undefined | null\n\n // Find the element to update\n if (indexConfig.byId && internalStore.indexes.byId) {\n elm = internalStore.indexes.byId.get(`${component_type}:${id}`)\n } else if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n elm = elementsOfType.find(\n (e: any) => e[`${component_type}_id`] === id,\n )\n } else {\n elm = soup.find(\n (e) =>\n e.type === component_type &&\n (e as any)[`${component_type}_id`] === id,\n )\n }\n\n if (!elm) return null\n\n // Need to remove from indexes before updating\n if (indexConfig.byRelation && internalStore.indexes.byRelation) {\n // Remove from relation indexes\n const elementEntries = Object.entries(elm)\n for (const [key, value] of elementEntries) {\n if (\n key.endsWith(\"_id\") &&\n key !== `${elm.type}_id` &&\n typeof value === \"string\"\n ) {\n if (key in newProps && newProps[key] !== value) {\n const relationTypeMap =\n internalStore.indexes.byRelation.get(key)\n if (relationTypeMap) {\n const relatedElements =\n relationTypeMap.get(value as string) || []\n const updatedElements = relatedElements.filter(\n (e) => e !== elm,\n )\n\n if (updatedElements.length === 0) {\n relationTypeMap.delete(value as string)\n } else {\n relationTypeMap.set(value as string, updatedElements)\n }\n }\n }\n }\n }\n }\n\n if (\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit &&\n \"subcircuit_id\" in elm &&\n \"subcircuit_id\" in newProps\n ) {\n const oldSubcircuitId = (elm as any).subcircuit_id\n const newSubcircuitId = newProps.subcircuit_id\n\n if (oldSubcircuitId !== newSubcircuitId) {\n // Remove from old subcircuit index\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(oldSubcircuitId) || []\n const updatedElements = subcircuitElements.filter(\n (e) => e !== elm,\n )\n\n if (updatedElements.length === 0) {\n internalStore.indexes.bySubcircuit.delete(oldSubcircuitId)\n } else {\n internalStore.indexes.bySubcircuit.set(\n oldSubcircuitId,\n updatedElements,\n )\n }\n }\n }\n\n if (\n indexConfig.byCustomField &&\n internalStore.indexes.byCustomField\n ) {\n for (const field of indexConfig.byCustomField) {\n if (\n field in elm &&\n field in newProps &&\n (elm as any)[field] !== newProps[field]\n ) {\n const fieldMap =\n internalStore.indexes.byCustomField.get(field)\n if (fieldMap) {\n const oldValue = String((elm as any)[field])\n const elements = fieldMap.get(oldValue) || []\n const updatedElements = elements.filter((e) => e !== elm)\n\n if (updatedElements.length === 0) {\n fieldMap.delete(oldValue)\n } else {\n fieldMap.set(oldValue, updatedElements)\n }\n }\n }\n }\n }\n\n // Update the element\n Object.assign(elm, newProps)\n internalStore.editCount++\n\n // Add to indexes with updated values\n if (indexConfig.byRelation && internalStore.indexes.byRelation) {\n const elementEntries = Object.entries(elm)\n for (const [key, value] of elementEntries) {\n if (\n key.endsWith(\"_id\") &&\n key !== `${elm.type}_id` &&\n typeof value === \"string\"\n ) {\n if (key in newProps) {\n const relationTypeMap: any =\n internalStore.indexes.byRelation.get(key) || new Map()\n const relatedElements: any =\n relationTypeMap.get(value as string) || []\n\n if (!relatedElements.includes(elm)) {\n relatedElements.push(elm)\n relationTypeMap.set(value as string, relatedElements)\n internalStore.indexes.byRelation.set(key, relationTypeMap)\n }\n }\n }\n }\n }\n\n if (\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit &&\n \"subcircuit_id\" in elm &&\n \"subcircuit_id\" in newProps\n ) {\n const subcircuitId = (elm as any).subcircuit_id\n if (subcircuitId && typeof subcircuitId === \"string\") {\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(subcircuitId) || []\n\n if (!subcircuitElements.includes(elm)) {\n subcircuitElements.push(elm)\n internalStore.indexes.bySubcircuit.set(\n subcircuitId,\n subcircuitElements,\n )\n }\n }\n }\n\n if (\n indexConfig.byCustomField &&\n internalStore.indexes.byCustomField\n ) {\n for (const field of indexConfig.byCustomField) {\n if (field in elm && field in newProps) {\n const fieldValue: any = (elm as any)[field]\n if (\n fieldValue !== undefined &&\n (typeof fieldValue === \"string\" ||\n typeof fieldValue === \"number\")\n ) {\n const fieldValueStr = String(fieldValue)\n const fieldMap =\n internalStore.indexes.byCustomField.get(field)!\n const elementsWithFieldValue =\n fieldMap.get(fieldValueStr) || []\n\n if (!elementsWithFieldValue.includes(elm)) {\n elementsWithFieldValue.push(elm)\n fieldMap.set(fieldValueStr, elementsWithFieldValue)\n }\n }\n }\n }\n }\n\n return elm as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >\n },\n\n select: (selector: string) => {\n // Selection by selector is specialized enough that we don't use indexes here\n // TODO when applySelector is isolated we can use it, until then we\n // do a poor man's selector implementation for two common cases\n if (component_type === \"source_component\") {\n return (\n (soup.find(\n (e) =>\n e.type === \"source_component\" &&\n e.name === selector.replace(/\\./g, \"\"),\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n } else if (\n component_type === \"pcb_port\" ||\n component_type === \"source_port\" ||\n component_type === \"schematic_port\"\n ) {\n const [component_name, port_selector] = selector\n .replace(/\\./g, \"\")\n .split(/[\\s\\>]+/)\n const source_component = soup.find(\n (e) =>\n e.type === \"source_component\" && e.name === component_name,\n ) as SourceComponentBase\n if (!source_component) return null\n const source_port = soup.find(\n (e) =>\n e.type === \"source_port\" &&\n e.source_component_id ===\n source_component.source_component_id &&\n (e.name === port_selector ||\n (e.port_hints ?? []).includes(port_selector!)),\n ) as SourcePort\n if (!source_port) return null\n if (component_type === \"source_port\")\n return source_port as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >\n\n if (component_type === \"pcb_port\") {\n return (\n (soup.find(\n (e) =>\n e.type === \"pcb_port\" &&\n e.source_port_id === source_port.source_port_id,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n } else if (component_type === \"schematic_port\") {\n return (\n (soup.find(\n (e) =>\n e.type === \"schematic_port\" &&\n e.source_port_id === source_port.source_port_id,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n }\n\n return null\n },\n }\n },\n },\n )\n\n return suIndexed\n}) as any\n\ncjuIndexed.unparsed = cjuIndexed as any\n\nexport default cjuIndexed\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { type Matrix, applyToPoint, decomposeTSR } from \"transformation-matrix\"\nimport {\n directionToVec,\n rotateDirection,\n vecToDirection,\n} from \"./direction-to-vec\"\n\nexport const transformSchematicElement = (\n elm: AnyCircuitElement,\n matrix: Matrix,\n) => {\n if (elm.type === \"schematic_component\") {\n // TODO handle rotation\n elm.center = applyToPoint(matrix, elm.center)\n } else if (elm.type === \"schematic_port\") {\n elm.center = applyToPoint(matrix, elm.center)\n\n if (elm.facing_direction) {\n elm.facing_direction = rotateDirection(\n elm.facing_direction,\n -(Math.atan2(matrix.b, matrix.a) / Math.PI) * 2,\n )\n }\n } else if (elm.type === \"schematic_text\") {\n elm.position = applyToPoint(matrix, elm.position)\n // } else if (elm.type === \"schematic_group\") {\n // elm.center = applyToPoint(matrix, elm.center)\n } else if (elm.type === \"schematic_trace\") {\n const anyElm = elm as any\n anyElm.route = (anyElm.route ?? []).map((rp: any) => {\n const tp = applyToPoint(matrix, rp) as { x: number; y: number }\n rp.x = tp.x\n rp.y = tp.y\n return rp\n })\n if (Array.isArray(anyElm.junctions)) {\n anyElm.junctions = anyElm.junctions.map((j: any) => {\n const tp = applyToPoint(matrix, j) as { x: number; y: number }\n j.x = tp.x\n j.y = tp.y\n return j\n })\n }\n if (Array.isArray(anyElm.edges)) {\n anyElm.edges = anyElm.edges.map((e: any) => {\n e.from = applyToPoint(matrix, e.from)\n e.to = applyToPoint(matrix, e.to)\n return e\n })\n }\n } else if (elm.type === \"schematic_box\") {\n const { x, y } = applyToPoint(matrix, { x: elm.x, y: elm.y })\n elm.x = x\n elm.y = y\n } else if (elm.type === \"schematic_line\") {\n const { x: x1, y: y1 } = applyToPoint(matrix, { x: elm.x1, y: elm.y1 })\n const { x: x2, y: y2 } = applyToPoint(matrix, { x: elm.x2, y: elm.y2 })\n elm.x1 = x1\n elm.y1 = y1\n elm.x2 = x2\n elm.y2 = y2\n }\n return elm\n}\n\nexport const transformSchematicElements = (\n elms: AnyCircuitElement[],\n matrix: Matrix,\n) => {\n return elms.map((elm) => transformSchematicElement(elm, matrix))\n}\n\nexport const transformPCBElement = (elm: AnyCircuitElement, matrix: Matrix) => {\n const tsr = decomposeTSR(matrix)\n const flipPadWidthHeight =\n Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1\n if (\n elm.type === \"pcb_plated_hole\" ||\n elm.type === \"pcb_hole\" ||\n elm.type === \"pcb_via\" ||\n elm.type === \"pcb_smtpad\" ||\n elm.type === \"pcb_port\"\n ) {\n const { x, y } = applyToPoint(matrix, {\n x: Number((elm as any).x),\n y: Number((elm as any).y),\n })\n ;(elm as any).x = x\n ;(elm as any).y = y\n\n // Handle polygon-shaped SMT pads with points array\n if (\n elm.type === \"pcb_smtpad\" &&\n elm.shape === \"polygon\" &&\n Array.isArray(elm.points)\n ) {\n elm.points = elm.points.map((point: any) => {\n const tp = applyToPoint(matrix, { x: point.x, y: point.y })\n return {\n x: tp.x,\n y: tp.y,\n }\n })\n }\n } else if (elm.type === \"pcb_keepout\" || elm.type === \"pcb_board\") {\n // TODO adjust size/rotation\n elm.center = applyToPoint(matrix, elm.center)\n } else if (\n elm.type === \"pcb_silkscreen_text\" ||\n elm.type === \"pcb_fabrication_note_text\" ||\n elm.type === \"pcb_note_text\"\n ) {\n elm.anchor_position = applyToPoint(matrix, elm.anchor_position)\n } else if (\n elm.type === \"pcb_silkscreen_circle\" ||\n elm.type === \"pcb_silkscreen_rect\" ||\n elm.type === \"pcb_note_rect\" ||\n elm.type === \"pcb_courtyard_rect\" ||\n elm.type === \"pcb_courtyard_circle\"\n ) {\n elm.center = applyToPoint(matrix, elm.center)\n } else if (elm.type === \"pcb_component\") {\n elm.center = applyToPoint(matrix, elm.center)\n elm.rotation = elm.rotation + (tsr.rotation.angle / Math.PI) * 180\n elm.rotation = elm.rotation % 360\n if (flipPadWidthHeight) {\n ;[elm.width, elm.height] = [elm.height, elm.width]\n }\n } else if (elm.type === \"pcb_courtyard_outline\") {\n elm.outline = elm.outline.map((p) => {\n const tp = applyToPoint(matrix, p) as { x: number; y: number }\n p.x = tp.x\n p.y = tp.y\n return p\n })\n } else if (elm.type === \"pcb_courtyard_polygon\") {\n elm.points = elm.points.map((p) => {\n const tp = applyToPoint(matrix, p) as { x: number; y: number }\n p.x = tp.x\n p.y = tp.y\n return p\n })\n } else if (\n elm.type === \"pcb_silkscreen_path\" ||\n elm.type === \"pcb_trace\" ||\n elm.type === \"pcb_fabrication_note_path\" ||\n elm.type === \"pcb_note_path\"\n ) {\n elm.route = elm.route.map((rp) => {\n const tp = applyToPoint(matrix, rp) as { x: number; y: number }\n rp.x = tp.x\n rp.y = tp.y\n return rp\n })\n } else if (\n elm.type === \"pcb_silkscreen_line\" ||\n elm.type === \"pcb_note_line\"\n ) {\n const p1 = { x: elm.x1, y: elm.y1 }\n const p2 = { x: elm.x2, y: elm.y2 }\n const p1t = applyToPoint(matrix, p1)\n const p2t = applyToPoint(matrix, p2)\n elm.x1 = p1t.x\n elm.y1 = p1t.y\n elm.x2 = p2t.x\n elm.y2 = p2t.y\n } else if (elm.type === \"cad_component\") {\n const newPos = applyToPoint(matrix, {\n x: elm.position.x,\n y: elm.position.y,\n })\n elm.position.x = newPos.x\n elm.position.y = newPos.y\n }\n return elm\n}\n\nexport const transformPCBElements = (\n elms: AnyCircuitElement[],\n matrix: Matrix,\n) => {\n const tsr = decomposeTSR(matrix)\n const quarterTurns = Math.round(tsr.rotation.angle / (Math.PI / 2))\n const flipPadWidthHeight = Math.abs(quarterTurns) % 2 === 1\n let transformedElms = elms.map((elm) => transformPCBElement(elm, matrix))\n if (flipPadWidthHeight) {\n transformedElms = transformedElms.map((elm) => {\n if (elm.type === \"pcb_smtpad\" && elm.shape === \"rect\") {\n ;[elm.width, elm.height] = [elm.height, elm.width]\n }\n return elm\n })\n }\n return transformedElms\n}\n","export const directionToVec = (direction: \"up\" | \"down\" | \"left\" | \"right\") => {\n if (direction === \"up\") return { x: 0, y: 1 }\n else if (direction === \"down\") return { x: 0, y: -1 }\n else if (direction === \"left\") return { x: -1, y: 0 }\n else if (direction === \"right\") return { x: 1, y: 0 }\n else throw new Error(\"Invalid direction\")\n}\n\nexport const vecToDirection = ({ x, y }: { x: number; y: number }) => {\n if (x > y) y = 0\n if (y > x) x = 0\n if (x > 0 && y === 0) return \"right\"\n else if (x < 0 && y === 0) return \"left\"\n else if (x === 0 && y > 0) return \"up\"\n else if (x === 0 && y < 0) return \"down\"\n else throw new Error(`Invalid vector for direction conversion (${x}, ${y})`)\n}\n\nexport const rotateClockwise = (\n direction: \"up\" | \"down\" | \"left\" | \"right\",\n) => {\n if (direction === \"up\") return \"right\"\n else if (direction === \"right\") return \"down\"\n else if (direction === \"down\") return \"left\"\n else if (direction === \"left\") return \"up\"\n throw new Error(`Invalid direction: ${direction}`)\n}\n\nexport const rotateCounterClockwise = (\n direction: \"up\" | \"down\" | \"left\" | \"right\",\n) => {\n if (direction === \"up\") return \"left\"\n else if (direction === \"left\") return \"down\"\n else if (direction === \"down\") return \"right\"\n else if (direction === \"right\") return \"up\"\n throw new Error(`Invalid direction: ${direction}`)\n}\n\nexport const rotateDirection = (\n direction: \"up\" | \"down\" | \"left\" | \"right\",\n num90DegreeClockwiseTurns: number,\n) => {\n while (num90DegreeClockwiseTurns > 0) {\n direction = rotateClockwise(direction)\n num90DegreeClockwiseTurns--\n }\n while (num90DegreeClockwiseTurns < 0) {\n direction = rotateCounterClockwise(direction)\n num90DegreeClockwiseTurns++\n }\n return direction\n}\n\nexport const oppositeDirection = (\n direction: \"up\" | \"down\" | \"left\" | \"right\",\n) => {\n if (direction === \"up\") return \"down\"\n else if (direction === \"down\") return \"up\"\n else if (direction === \"left\") return \"right\"\n else if (direction === \"right\") return \"left\"\n throw new Error(`Invalid direction: ${direction}`)\n}\n\nexport const oppositeSide = (\n sideOrDir: \"up\" | \"down\" | \"top\" | \"bottom\" | \"left\" | \"right\",\n) => {\n if (sideOrDir === \"top\" || sideOrDir === \"up\") return \"bottom\"\n else if (sideOrDir === \"bottom\" || sideOrDir === \"down\") return \"top\"\n else if (sideOrDir === \"left\") return \"right\"\n else if (sideOrDir === \"right\") return \"left\"\n throw new Error(`Invalid sideOrDir: ${sideOrDir}`)\n}\n","import * as parsel from \"parsel-js\"\nimport { convertAbbrToType } from \"./convert-abbreviation-to-soup-element-type\"\nimport type { AnyCircuitElement } from \"circuit-json\"\n\nconst filterByType = (\n elements: AnyCircuitElement[],\n type: string,\n): AnyCircuitElement[] => {\n type = convertAbbrToType(type)\n return elements.filter(\n (elm) => (\"ftype\" in elm && elm.ftype === type) || elm.type === type,\n )\n}\n\n/**\n * Filter elements to match the selector, e.g. to access the left port of a\n * resistor you can do \".R1 > port.left\"\n */\nexport const applySelector = (\n elements: AnyCircuitElement[],\n selectorRaw: string,\n): AnyCircuitElement[] => {\n const selectorAST = parsel.parse(selectorRaw)\n return applySelectorAST(elements, selectorAST!)\n}\n\nconst doesElmMatchClassName = (elm: AnyCircuitElement, className: string) =>\n (\"name\" in elm && elm.name === className) ||\n (\"port_hints\" in elm && elm.port_hints?.includes(className))\n\nexport const applySelectorAST = (\n elements: AnyCircuitElement[],\n selectorAST: parsel.AST,\n): AnyCircuitElement[] => {\n switch (selectorAST.type) {\n case \"complex\": {\n switch (selectorAST.combinator) {\n case \" \": // TODO technically should do a deep search\n case \">\": {\n const { left, right } = selectorAST\n if (left.type === \"class\" || left.type === \"type\") {\n // TODO should also check if content matches any element tags\n let matchElms: AnyCircuitElement[]\n if (left.type === \"class\") {\n matchElms = elements.filter((elm) =>\n doesElmMatchClassName(elm, left.name),\n )\n } else if (left.type === \"type\") {\n matchElms = filterByType(elements, left.name)\n } else {\n matchElms = []\n }\n\n const childrenOfMatchingElms = matchElms.flatMap((matchElm) =>\n elements.filter(\n (elm: any) =>\n elm[`${matchElm.type}_id`] ===\n (matchElm as any)[`${matchElm.type}_id`] &&\n elm !== matchElm,\n ),\n )\n return applySelectorAST(childrenOfMatchingElms, right)\n } else {\n throw new Error(`unsupported selector type \"${left.type}\" `)\n }\n }\n default: {\n throw new Error(\n `Couldn't apply selector AST for complex combinator \"${selectorAST.combinator}\"`,\n )\n }\n }\n return []\n }\n case \"compound\": {\n const conditionsToMatch = selectorAST.list.map((part) => {\n switch (part.type) {\n case \"class\": {\n return (elm: any) => doesElmMatchClassName(elm, part.name)\n }\n case \"type\": {\n const name = convertAbbrToType(part.name)\n return (elm: any) => elm.type === name\n }\n }\n })\n\n return elements.filter((elm) =>\n conditionsToMatch.every((condFn) => condFn?.(elm)),\n )\n }\n case \"type\": {\n return filterByType(elements, selectorAST.name) as AnyCircuitElement[]\n }\n case \"class\": {\n return elements.filter((elm) =>\n doesElmMatchClassName(elm, selectorAST.name),\n )\n }\n default: {\n throw new Error(\n `Couldn't apply selector AST for type: \"${\n selectorAST.type\n }\" ${JSON.stringify(selectorAST, null, \" \")}`,\n )\n }\n }\n}\n","export const convertAbbrToType = (abbr: string): string => {\n switch (abbr) {\n case \"port\":\n return \"source_port\"\n case \"net\":\n return \"source_net\"\n case \"power\":\n return \"simple_power_source\"\n case \"silkscreenpath\":\n return \"pcb_silkscreen_path\"\n }\n return abbr\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\n\nexport const getElementId = (elm: AnyCircuitElement): string => {\n const type = elm.type\n const id = (elm as any)[`${type}_id`]\n return id\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { getElementId } from \"./get-element-id\"\n\nexport const getElementById = (\n soup: AnyCircuitElement[],\n id: string,\n): AnyCircuitElement | null => {\n return soup.find((elm) => getElementId(elm) === id) ?? null\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { cju } from \"../cju\"\n\nexport function getReadableNameForPcbTrace(\n soup: AnyCircuitElement[],\n pcb_trace_id: string,\n) {\n // Find the pcb_trace object\n const pcbTrace = cju(soup).pcb_trace.get(pcb_trace_id)\n\n if (!pcbTrace) {\n return `trace[${pcb_trace_id}]`\n }\n\n // Get the connected ports\n const connectedPcbPortIds: string[] = pcbTrace.route\n .flatMap((point: any) => [point.start_pcb_port_id, point.end_pcb_port_id])\n .filter(Boolean)\n\n if (connectedPcbPortIds.length === 0) {\n return `trace[${pcb_trace_id}]`\n }\n\n // Function to get component name and port hint\n function getComponentAndPortInfo(pcb_port_id: string) {\n const pcbPort = cju(soup).pcb_port.get(pcb_port_id)\n if (!pcbPort) return null\n\n const pcbComponent = pcbPort.pcb_component_id\n ? cju(soup).pcb_component.get(pcbPort.pcb_component_id)\n : undefined\n if (!pcbComponent) return null\n const sourceComponent = cju(soup).source_component.get(\n pcbComponent.source_component_id,\n )\n if (!sourceComponent) return null\n\n const sourcePort = cju(soup).source_port.get(pcbPort.source_port_id)\n const portHint = sourcePort?.port_hints ? sourcePort.port_hints[1] : \"\"\n\n return {\n componentName: sourceComponent.name,\n portHint: portHint,\n }\n }\n\n // Generate the readable selector\n const selectorParts = connectedPcbPortIds.map((portId) => {\n const info = getComponentAndPortInfo(portId)\n if (info) {\n return `.${info.componentName} > port.${info.portHint}`\n }\n return `port[${portId}]`\n })\n\n return `trace[${selectorParts.join(\", \")}]`\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { cju } from \"../cju\"\n\nexport const getReadableNameForPcbPort = (\n soup: AnyCircuitElement[],\n pcb_port_id: string,\n): string => {\n const pcbPort = cju(soup).pcb_port.get(pcb_port_id)\n if (!pcbPort) {\n return `pcb_port[#${pcb_port_id}]`\n }\n\n // Get the component information\n const pcbComponent = pcbPort.pcb_component_id\n ? cju(soup).pcb_component.get(pcbPort.pcb_component_id)\n : undefined\n\n if (!pcbComponent) {\n return `pcb_port[#${pcb_port_id}]`\n }\n\n // Get the source component information\n const sourceComponent = cju(soup).source_component.get(\n pcbComponent.source_component_id,\n )\n\n if (!sourceComponent) {\n return `pcb_port[#${pcb_port_id}]`\n }\n\n // Get the source port information\n const sourcePort = cju(soup).source_port.get(pcbPort.source_port_id)\n\n if (!sourcePort) {\n return `pcb_port[#${pcb_port_id}]`\n }\n\n // Determine the pad number or hint\n let padIdentifier: string\n if (sourcePort?.port_hints && sourcePort.port_hints.length > 0) {\n padIdentifier = sourcePort.port_hints[0]!\n } else if (sourcePort.port_hints && sourcePort.port_hints.length > 0) {\n padIdentifier = sourcePort.port_hints[0]!\n } else {\n padIdentifier = pcb_port_id\n }\n\n return `pcb_port[.${sourceComponent.name} > .${padIdentifier}]`\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { cju } from \"../cju\"\nimport { getReadableNameForPcbPort } from \"./get-readable-name-for-pcb-port\"\n\nexport function getReadableNameForPcbSmtpad(\n soup: AnyCircuitElement[],\n pcb_smtpad_id: string,\n): string {\n // Find the pcb_smtpad object\n const pcbSmtpad = cju(soup).pcb_smtpad.get(pcb_smtpad_id)\n\n if (!pcbSmtpad || !pcbSmtpad.pcb_port_id) {\n return `smtpad[${pcb_smtpad_id}]`\n }\n\n return getReadableNameForPcbPort(soup, pcbSmtpad.pcb_port_id)\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { getReadableNameForPcbTrace } from \"./get-readable-name-for-pcb-trace\"\nimport { getReadableNameForPcbSmtpad } from \"./get-readable-name-for-pcb-smtpad\"\nimport { getReadableNameForPcbPort } from \"./get-readable-name-for-pcb-port\"\nimport { getElementById } from \"lib/get-element-by-id\"\nimport { getElementId } from \"lib/get-element-id\"\n\nexport const getReadableNameForElement = (\n soup: AnyCircuitElement[],\n elm: AnyCircuitElement | string,\n): string => {\n if (typeof elm === \"string\") {\n const elmObj = getElementById(soup, elm)\n if (!elmObj) `unknown (could not find element with id ${elm})`\n return getReadableNameForElement(soup, elmObj as any)\n }\n switch (elm.type) {\n case \"pcb_port\":\n return getReadableNameForPcbPort(soup, elm.pcb_port_id)\n case \"pcb_smtpad\":\n return getReadableNameForPcbSmtpad(soup, elm.pcb_smtpad_id)\n case \"pcb_trace\":\n return getReadableNameForPcbTrace(soup, elm.pcb_trace_id)\n case \"source_component\":\n return `source_component[${elm.name}]`\n default:\n return `${elm.type}[#${getElementId(elm)}]`\n }\n}\n\nexport {\n getReadableNameForPcbPort,\n getReadableNameForPcbSmtpad,\n getReadableNameForPcbTrace,\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\n\nconst mergeBounds = (\n currentBounds: {\n minX: number\n minY: number\n maxX: number\n maxY: number\n },\n nextBounds: {\n minX: number\n minY: number\n maxX: number\n maxY: number\n },\n) => ({\n minX: Math.min(currentBounds.minX, nextBounds.minX),\n minY: Math.min(currentBounds.minY, nextBounds.minY),\n maxX: Math.max(currentBounds.maxX, nextBounds.maxX),\n maxY: Math.max(currentBounds.maxY, nextBounds.maxY),\n})\n\nconst getCircleBounds = (x: number, y: number, diameter: number) => {\n const radius = diameter / 2\n return {\n minX: x - radius,\n minY: y - radius,\n maxX: x + radius,\n maxY: y + radius,\n }\n}\n\nconst getRotatedRectBounds = (\n x: number,\n y: number,\n width: number,\n height: number,\n rotationDegrees: number,\n) => {\n const halfWidth = width / 2\n const halfHeight = height / 2\n const theta = (rotationDegrees * Math.PI) / 180\n const cosTheta = Math.cos(theta)\n const sinTheta = Math.sin(theta)\n\n const corners = [\n { x: -halfWidth, y: -halfHeight },\n { x: halfWidth, y: -halfHeight },\n { x: halfWidth, y: halfHeight },\n { x: -halfWidth, y: halfHeight },\n ].map((corner) => ({\n x: x + corner.x * cosTheta - corner.y * sinTheta,\n y: y + corner.x * sinTheta + corner.y * cosTheta,\n }))\n\n return {\n minX: Math.min(...corners.map((corner) => corner.x)),\n minY: Math.min(...corners.map((corner) => corner.y)),\n maxX: Math.max(...corners.map((corner) => corner.x)),\n maxY: Math.max(...corners.map((corner) => corner.y)),\n }\n}\n\nexport const getBoundsOfPcbElements = (\n elements: AnyCircuitElement[],\n): { minX: number; minY: number; maxX: number; maxY: number } => {\n let minX = Number.POSITIVE_INFINITY\n let minY = Number.POSITIVE_INFINITY\n let maxX = Number.NEGATIVE_INFINITY\n let maxY = Number.NEGATIVE_INFINITY\n\n for (const elm of elements) {\n if (!elm.type.startsWith(\"pcb_\")) continue\n\n // Handle polygon-shaped SMT pads with points array\n if (\n elm.type === \"pcb_smtpad\" &&\n elm.shape === \"polygon\" &&\n Array.isArray(elm.points)\n ) {\n for (const point of elm.points) {\n minX = Math.min(minX, point.x)\n minY = Math.min(minY, point.y)\n maxX = Math.max(maxX, point.x)\n maxY = Math.max(maxY, point.y)\n }\n continue\n }\n\n if (elm.type === \"pcb_hole\" && elm.hole_shape === \"circle\") {\n const holeBounds = getCircleBounds(elm.x, elm.y, elm.hole_diameter)\n minX = Math.min(minX, holeBounds.minX)\n minY = Math.min(minY, holeBounds.minY)\n maxX = Math.max(maxX, holeBounds.maxX)\n maxY = Math.max(maxY, holeBounds.maxY)\n continue\n }\n\n if (elm.type === \"pcb_plated_hole\") {\n let platedHoleBounds:\n | {\n minX: number\n minY: number\n maxX: number\n maxY: number\n }\n | undefined\n\n if (\"outer_diameter\" in elm && typeof elm.outer_diameter === \"number\") {\n platedHoleBounds = getCircleBounds(elm.x, elm.y, elm.outer_diameter)\n } else if (\n \"hole_diameter\" in elm &&\n typeof elm.hole_diameter === \"number\"\n ) {\n platedHoleBounds = getCircleBounds(elm.x, elm.y, elm.hole_diameter)\n }\n\n if (\n \"rect_pad_width\" in elm &&\n typeof elm.rect_pad_width === \"number\" &&\n \"rect_pad_height\" in elm &&\n typeof elm.rect_pad_height === \"number\"\n ) {\n const rectBounds = getRotatedRectBounds(\n elm.x,\n elm.y,\n elm.rect_pad_width,\n elm.rect_pad_height,\n \"rect_ccw_rotation\" in elm ? (elm.rect_ccw_rotation ?? 0) : 0,\n )\n platedHoleBounds = platedHoleBounds\n ? mergeBounds(platedHoleBounds, rectBounds)\n : rectBounds\n }\n\n if (\"hole_diameter\" in elm && typeof elm.hole_diameter === \"number\") {\n const drillBounds = getCircleBounds(\n elm.x +\n (\"hole_offset_x\" in elm ? ((elm.hole_offset_x as number) ?? 0) : 0),\n elm.y +\n (\"hole_offset_y\" in elm ? ((elm.hole_offset_y as number) ?? 0) : 0),\n elm.hole_diameter,\n )\n platedHoleBounds = platedHoleBounds\n ? mergeBounds(platedHoleBounds, drillBounds)\n : drillBounds\n }\n\n if (platedHoleBounds) {\n minX = Math.min(minX, platedHoleBounds.minX)\n minY = Math.min(minY, platedHoleBounds.minY)\n maxX = Math.max(maxX, platedHoleBounds.maxX)\n maxY = Math.max(maxY, platedHoleBounds.maxY)\n continue\n }\n }\n\n let centerX: number | undefined\n let centerY: number | undefined\n\n let width: number | undefined\n let height: number | undefined\n\n if (\"x\" in elm && \"y\" in elm) {\n centerX = Number((elm as any).x)\n centerY = Number((elm as any).y)\n }\n\n if (\"outer_diameter\" in elm) {\n width = Number((elm as any).outer_diameter)\n height = Number((elm as any).outer_diameter)\n }\n\n if (\"width\" in elm) {\n width = Number((elm as any).width)\n }\n\n if (\"height\" in elm) {\n height = Number((elm as any).height)\n }\n\n if (\"center\" in elm) {\n // @ts-ignore\n centerX = elm.center.x\n // @ts-ignore\n centerY = elm.center.y\n }\n\n if (centerX !== undefined && centerY !== undefined) {\n minX = Math.min(minX, centerX)\n minY = Math.min(minY, centerY)\n maxX = Math.max(maxX, centerX)\n maxY = Math.max(maxY, centerY)\n\n if (width !== undefined && height !== undefined) {\n minX = Math.min(minX, centerX - width / 2)\n minY = Math.min(minY, centerY - height / 2)\n maxX = Math.max(maxX, centerX + width / 2)\n maxY = Math.max(maxY, centerY + height / 2)\n }\n\n if (\"radius\" in elm) {\n minX = Math.min(minX, centerX - elm.radius)\n minY = Math.min(minY, centerY - elm.radius)\n maxX = Math.max(maxX, centerX + elm.radius)\n maxY = Math.max(maxY, centerY + elm.radius)\n }\n } else if (elm.type === \"pcb_trace\") {\n for (const point of elm.route) {\n // TODO add trace thickness support\n minX = Math.min(minX, point.x)\n minY = Math.min(minY, point.y)\n maxX = Math.max(maxX, point.x)\n maxY = Math.max(maxY, point.y)\n }\n } else if (elm.type === \"pcb_courtyard_outline\") {\n for (const point of elm.outline) {\n minX = Math.min(minX, point.x)\n minY = Math.min(minY, point.y)\n maxX = Math.max(maxX, point.x)\n maxY = Math.max(maxY, point.y)\n }\n } else if (elm.type === \"pcb_courtyard_polygon\") {\n for (const point of elm.points) {\n minX = Math.min(minX, point.x)\n minY = Math.min(minY, point.y)\n maxX = Math.max(maxX, point.x)\n maxY = Math.max(maxY, point.y)\n }\n }\n }\n\n return { minX, minY, maxX, maxY }\n}\n","import type { PcbBoard } from \"circuit-json\"\n\nexport interface BoardBounds {\n minX: number\n minY: number\n maxX: number\n maxY: number\n width: number\n height: number\n center: {\n x: number\n y: number\n }\n}\n\nexport const getBoardBounds = (board: PcbBoard): BoardBounds => {\n if (board.width && board.height && board.center) {\n const halfWidth = board.width / 2\n const halfHeight = board.height / 2\n\n return {\n minX: board.center.x - halfWidth,\n minY: board.center.y - halfHeight,\n maxX: board.center.x + halfWidth,\n maxY: board.center.y + halfHeight,\n width: board.width,\n height: board.height,\n center: {\n x: board.center.x,\n y: board.center.y,\n },\n }\n }\n\n if (!board.outline || board.outline.length === 0) {\n throw new Error(\n \"Unable to compute board bounds. pcb_board must include width/height/center or a non-empty outline.\",\n )\n }\n\n let minX = Number.POSITIVE_INFINITY\n let minY = Number.POSITIVE_INFINITY\n let maxX = Number.NEGATIVE_INFINITY\n let maxY = Number.NEGATIVE_INFINITY\n\n for (const point of board.outline) {\n minX = Math.min(minX, point.x)\n minY = Math.min(minY, point.y)\n maxX = Math.max(maxX, point.x)\n maxY = Math.max(maxY, point.y)\n }\n\n const width = maxX - minX\n const height = maxY - minY\n\n return {\n minX,\n minY,\n maxX,\n maxY,\n width,\n height,\n center: {\n x: minX + width / 2,\n y: minY + height / 2,\n },\n }\n}\n","export function stringHash(str: string) {\n let hash = 0\n if (str.length == 0) return hash\n for (var i = 0; i < str.length; i++) {\n var char = str.charCodeAt(i)\n hash = (hash << 5) - hash + char\n hash = hash & hash // Convert to 32bit integer\n }\n return Math.abs(hash)\n}\n","import { stringHash } from \"./string-hash\"\n\nexport type LayoutDebugObject = {\n x: number\n y: number\n width: number\n height: number\n bg_color: string\n title: string\n content: Object\n secondary?: boolean\n}\n\n/**\n * Vendored from \"nice-color-palettes\" package\n */\nconst nice_color_palettes = [\n [\"#69d2e7\", \"#a7dbd8\", \"#e0e4cc\", \"#f38630\", \"#fa6900\"],\n [\"#fe4365\", \"#fc9d9a\", \"#f9cdad\", \"#c8c8a9\", \"#83af9b\"],\n [\"#ecd078\", \"#d95b43\", \"#c02942\", \"#542437\", \"#53777a\"],\n [\"#556270\", \"#4ecdc4\", \"#c7f464\", \"#ff6b6b\", \"#c44d58\"],\n [\"#774f38\", \"#e08e79\", \"#f1d4af\", \"#ece5ce\", \"#c5e0dc\"],\n [\"#e8ddcb\", \"#cdb380\", \"#036564\", \"#033649\", \"#031634\"],\n [\"#490a3d\", \"#bd1550\", \"#e97f02\", \"#f8ca00\", \"#8a9b0f\"],\n [\"#594f4f\", \"#547980\", \"#45ada8\", \"#9de0ad\", \"#e5fcc2\"],\n [\"#00a0b0\", \"#6a4a3c\", \"#cc333f\", \"#eb6841\", \"#edc951\"],\n [\"#e94e77\", \"#d68189\", \"#c6a49a\", \"#c6e5d9\", \"#f4ead5\"],\n [\"#3fb8af\", \"#7fc7af\", \"#dad8a7\", \"#ff9e9d\", \"#ff3d7f\"],\n [\"#d9ceb2\", \"#948c75\", \"#d5ded9\", \"#7a6a53\", \"#99b2b7\"],\n [\"#ffffff\", \"#cbe86b\", \"#f2e9e1\", \"#1c140d\", \"#cbe86b\"],\n [\"#efffcd\", \"#dce9be\", \"#555152\", \"#2e2633\", \"#99173c\"],\n [\"#343838\", \"#005f6b\", \"#008c9e\", \"#00b4cc\", \"#00dffc\"],\n [\"#413e4a\", \"#73626e\", \"#b38184\", \"#f0b49e\", \"#f7e4be\"],\n [\"#ff4e50\", \"#fc913a\", \"#f9d423\", \"#ede574\", \"#e1f5c4\"],\n [\"#99b898\", \"#fecea8\", \"#ff847c\", \"#e84a5f\", \"#2a363b\"],\n [\"#655643\", \"#80bca3\", \"#f6f7bd\", \"#e6ac27\", \"#bf4d28\"],\n [\"#00a8c6\", \"#40c0cb\", \"#f9f2e7\", \"#aee239\", \"#8fbe00\"],\n [\"#351330\", \"#424254\", \"#64908a\", \"#e8caa4\", \"#cc2a41\"],\n [\"#554236\", \"#f77825\", \"#d3ce3d\", \"#f1efa5\", \"#60b99a\"],\n [\"#5d4157\", \"#838689\", \"#a8caba\", \"#cad7b2\", \"#ebe3aa\"],\n [\"#8c2318\", \"#5e8c6a\", \"#88a65e\", \"#bfb35a\", \"#f2c45a\"],\n [\"#fad089\", \"#ff9c5b\", \"#f5634a\", \"#ed303c\", \"#3b8183\"],\n [\"#ff4242\", \"#f4fad2\", \"#d4ee5e\", \"#e1edb9\", \"#f0f2eb\"],\n [\"#f8b195\", \"#f67280\", \"#c06c84\", \"#6c5b7b\", \"#355c7d\"],\n [\"#d1e751\", \"#ffffff\", \"#000000\", \"#4dbce9\", \"#26ade4\"],\n [\"#1b676b\", \"#519548\", \"#88c425\", \"#bef202\", \"#eafde6\"],\n [\"#5e412f\", \"#fcebb6\", \"#78c0a8\", \"#f07818\", \"#f0a830\"],\n [\"#bcbdac\", \"#cfbe27\", \"#f27435\", \"#f02475\", \"#3b2d38\"],\n [\"#452632\", \"#91204d\", \"#e4844a\", \"#e8bf56\", \"#e2f7ce\"],\n [\"#eee6ab\", \"#c5bc8e\", \"#696758\", \"#45484b\", \"#36393b\"],\n [\"#f0d8a8\", \"#3d1c00\", \"#86b8b1\", \"#f2d694\", \"#fa2a00\"],\n [\"#2a044a\", \"#0b2e59\", \"#0d6759\", \"#7ab317\", \"#a0c55f\"],\n [\"#f04155\", \"#ff823a\", \"#f2f26f\", \"#fff7bd\", \"#95cfb7\"],\n [\"#b9d7d9\", \"#668284\", \"#2a2829\", \"#493736\", \"#7b3b3b\"],\n [\"#bbbb88\", \"#ccc68d\", \"#eedd99\", \"#eec290\", \"#eeaa88\"],\n [\"#b3cc57\", \"#ecf081\", \"#ffbe40\", \"#ef746f\", \"#ab3e5b\"],\n [\"#a3a948\", \"#edb92e\", \"#f85931\", \"#ce1836\", \"#009989\"],\n [\"#300030\", \"#480048\", \"#601848\", \"#c04848\", \"#f07241\"],\n [\"#67917a\", \"#170409\", \"#b8af03\", \"#ccbf82\", \"#e33258\"],\n [\"#aab3ab\", \"#c4cbb7\", \"#ebefc9\", \"#eee0b7\", \"#e8caaf\"],\n [\"#e8d5b7\", \"#0e2430\", \"#fc3a51\", \"#f5b349\", \"#e8d5b9\"],\n [\"#ab526b\", \"#bca297\", \"#c5ceae\", \"#f0e2a4\", \"#f4ebc3\"],\n [\"#607848\", \"#789048\", \"#c0d860\", \"#f0f0d8\", \"#604848\"],\n [\"#b6d8c0\", \"#c8d9bf\", \"#dadabd\", \"#ecdbbc\", \"#fedcba\"],\n [\"#a8e6ce\", \"#dcedc2\", \"#ffd3b5\", \"#ffaaa6\", \"#ff8c94\"],\n [\"#3e4147\", \"#fffedf\", \"#dfba69\", \"#5a2e2e\", \"#2a2c31\"],\n [\"#fc354c\", \"#29221f\", \"#13747d\", \"#0abfbc\", \"#fcf7c5\"],\n [\"#cc0c39\", \"#e6781e\", \"#c8cf02\", \"#f8fcc1\", \"#1693a7\"],\n [\"#1c2130\", \"#028f76\", \"#b3e099\", \"#ffeaad\", \"#d14334\"],\n [\"#a7c5bd\", \"#e5ddcb\", \"#eb7b59\", \"#cf4647\", \"#524656\"],\n [\"#dad6ca\", \"#1bb0ce\", \"#4f8699\", \"#6a5e72\", \"#563444\"],\n [\"#5c323e\", \"#a82743\", \"#e15e32\", \"#c0d23e\", \"#e5f04c\"],\n [\"#edebe6\", \"#d6e1c7\", \"#94c7b6\", \"#403b33\", \"#d3643b\"],\n [\"#fdf1cc\", \"#c6d6b8\", \"#987f69\", \"#e3ad40\", \"#fcd036\"],\n [\"#230f2b\", \"#f21d41\", \"#ebebbc\", \"#bce3c5\", \"#82b3ae\"],\n [\"#b9d3b0\", \"#81bda4\", \"#b28774\", \"#f88f79\", \"#f6aa93\"],\n [\"#3a111c\", \"#574951\", \"#83988e\", \"#bcdea5\", \"#e6f9bc\"],\n [\"#5e3929\", \"#cd8c52\", \"#b7d1a3\", \"#dee8be\", \"#fcf7d3\"],\n [\"#1c0113\", \"#6b0103\", \"#a30006\", \"#c21a01\", \"#f03c02\"],\n [\"#000000\", \"#9f111b\", \"#b11623\", \"#292c37\", \"#cccccc\"],\n [\"#382f32\", \"#ffeaf2\", \"#fcd9e5\", \"#fbc5d8\", \"#f1396d\"],\n [\"#e3dfba\", \"#c8d6bf\", \"#93ccc6\", \"#6cbdb5\", \"#1a1f1e\"],\n [\"#f6f6f6\", \"#e8e8e8\", \"#333333\", \"#990100\", \"#b90504\"],\n [\"#1b325f\", \"#9cc4e4\", \"#e9f2f9\", \"#3a89c9\", \"#f26c4f\"],\n [\"#a1dbb2\", \"#fee5ad\", \"#faca66\", \"#f7a541\", \"#f45d4c\"],\n [\"#c1b398\", \"#605951\", \"#fbeec2\", \"#61a6ab\", \"#accec0\"],\n [\"#5e9fa3\", \"#dcd1b4\", \"#fab87f\", \"#f87e7b\", \"#b05574\"],\n [\"#951f2b\", \"#f5f4d7\", \"#e0dfb1\", \"#a5a36c\", \"#535233\"],\n [\"#8dccad\", \"#988864\", \"#fea6a2\", \"#f9d6ac\", \"#ffe9af\"],\n [\"#2d2d29\", \"#215a6d\", \"#3ca2a2\", \"#92c7a3\", \"#dfece6\"],\n [\"#413d3d\", \"#040004\", \"#c8ff00\", \"#fa023c\", \"#4b000f\"],\n [\"#eff3cd\", \"#b2d5ba\", \"#61ada0\", \"#248f8d\", \"#605063\"],\n [\"#ffefd3\", \"#fffee4\", \"#d0ecea\", \"#9fd6d2\", \"#8b7a5e\"],\n [\"#cfffdd\", \"#b4dec1\", \"#5c5863\", \"#a85163\", \"#ff1f4c\"],\n [\"#9dc9ac\", \"#fffec7\", \"#f56218\", \"#ff9d2e\", \"#919167\"],\n [\"#4e395d\", \"#827085\", \"#8ebe94\", \"#ccfc8e\", \"#dc5b3e\"],\n [\"#a8a7a7\", \"#cc527a\", \"#e8175d\", \"#474747\", \"#363636\"],\n [\"#f8edd1\", \"#d88a8a\", \"#474843\", \"#9d9d93\", \"#c5cfc6\"],\n [\"#046d8b\", \"#309292\", \"#2fb8ac\", \"#93a42a\", \"#ecbe13\"],\n [\"#f38a8a\", \"#55443d\", \"#a0cab5\", \"#cde9ca\", \"#f1edd0\"],\n [\"#a70267\", \"#f10c49\", \"#fb6b41\", \"#f6d86b\", \"#339194\"],\n [\"#ff003c\", \"#ff8a00\", \"#fabe28\", \"#88c100\", \"#00c176\"],\n [\"#ffedbf\", \"#f7803c\", \"#f54828\", \"#2e0d23\", \"#f8e4c1\"],\n [\"#4e4d4a\", \"#353432\", \"#94ba65\", \"#2790b0\", \"#2b4e72\"],\n [\"#0ca5b0\", \"#4e3f30\", \"#fefeeb\", \"#f8f4e4\", \"#a5b3aa\"],\n [\"#4d3b3b\", \"#de6262\", \"#ffb88c\", \"#ffd0b3\", \"#f5e0d3\"],\n [\"#fffbb7\", \"#a6f6af\", \"#66b6ab\", \"#5b7c8d\", \"#4f2958\"],\n [\"#edf6ee\", \"#d1c089\", \"#b3204d\", \"#412e28\", \"#151101\"],\n [\"#9d7e79\", \"#ccac95\", \"#9a947c\", \"#748b83\", \"#5b756c\"],\n [\"#fcfef5\", \"#e9ffe1\", \"#cdcfb7\", \"#d6e6c3\", \"#fafbe3\"],\n [\"#9cddc8\", \"#bfd8ad\", \"#ddd9ab\", \"#f7af63\", \"#633d2e\"],\n [\"#30261c\", \"#403831\", \"#36544f\", \"#1f5f61\", \"#0b8185\"],\n [\"#aaff00\", \"#ffaa00\", \"#ff00aa\", \"#aa00ff\", \"#00aaff\"],\n [\"#d1313d\", \"#e5625c\", \"#f9bf76\", \"#8eb2c5\", \"#615375\"],\n [\"#ffe181\", \"#eee9e5\", \"#fad3b2\", \"#ffba7f\", \"#ff9c97\"],\n [\"#73c8a9\", \"#dee1b6\", \"#e1b866\", \"#bd5532\", \"#373b44\"],\n [\"#805841\", \"#dcf7f3\", \"#fffcdd\", \"#ffd8d8\", \"#f5a2a2\"],\n]\n\nexport const getDebugLayoutObject = (lo: any): LayoutDebugObject | null => {\n let {\n x,\n y,\n width,\n height,\n }: { x: number; y: number; width?: number; height?: number } = {\n ...lo,\n ...(lo as any).size,\n ...(lo as any).center,\n ...(lo as any).position,\n }\n\n if (\n lo.x1 !== undefined &&\n lo.x2 !== undefined &&\n lo.y1 !== undefined &&\n lo.y2 !== undefined\n ) {\n x = (lo.x1 + lo.x2) / 2\n y = (lo.y1 + lo.y2) / 2\n width = Math.abs(lo.x1 - lo.x2)\n height = Math.abs(lo.y1 - lo.y2)\n }\n\n if (lo.points && Array.isArray(lo.points) && lo.points.length > 0) {\n const xCoords = lo.points.map((point: { x: number }) => point.x)\n const yCoords = lo.points.map((point: { y: number }) => point.y)\n\n const minX = Math.min(...xCoords)\n const maxX = Math.max(...xCoords)\n const minY = Math.min(...yCoords)\n const maxY = Math.max(...yCoords)\n\n x = (minX + maxX) / 2\n y = (minY + maxY) / 2\n width = maxX - minX\n height = maxY - minY\n }\n\n const title = lo.text || lo.name || lo.source?.text || lo.source?.name || \"?\"\n const content = lo\n\n if (x === undefined || y === undefined) return null\n\n if (width === undefined) {\n if (\"outer_diameter\" in lo) {\n width = lo.outer_diameter\n height = lo.outer_diameter\n }\n }\n\n if (width === undefined || height === undefined) {\n width = 0.1\n height = 0.1\n }\n\n return {\n x,\n y,\n width,\n height,\n title,\n content,\n bg_color:\n nice_color_palettes[\n stringHash((lo as any).type || title) % nice_color_palettes.length\n ]?.[4] ?? \"#f00\",\n }\n}\n","export const isTruthy = <T>(value: T): value is NonNullable<T> => Boolean(value)\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { getDebugLayoutObject } from \"./utils/get-layout-debug-object\"\nimport { isTruthy } from \"./utils/is-truthy\"\n\nexport const findBoundsAndCenter = (\n elements: AnyCircuitElement[],\n): { center: { x: number; y: number }; width: number; height: number } => {\n const debugObjects = elements\n .filter(\n (elm) => elm.type.startsWith(\"pcb_\") || elm.type.startsWith(\"schematic_\"),\n )\n .concat(\n elements\n .filter(\n (elm) => elm.type === \"pcb_trace\" || elm.type === \"schematic_trace\",\n )\n // @ts-ignore\n .flatMap((elm: any) => elm.route),\n )\n .map((elm) => getDebugLayoutObject(elm))\n .filter(isTruthy)\n\n if (debugObjects.length === 0)\n return { center: { x: 0, y: 0 }, width: 0, height: 0 }\n\n let minX = debugObjects[0]!.x - debugObjects[0]!.width / 2\n let maxX = debugObjects[0]!.x + debugObjects[0]!.width / 2\n let minY = debugObjects[0]!.y - debugObjects[0]!.height / 2\n let maxY = debugObjects[0]!.y + debugObjects[0]!.height / 2\n\n for (const obj of debugObjects.slice(1)) {\n minX = Math.min(minX, obj.x - obj.width / 2)\n maxX = Math.max(maxX, obj.x + obj.width / 2)\n minY = Math.min(minY, obj.y - obj.height / 2)\n maxY = Math.max(maxY, obj.y + obj.height / 2)\n }\n\n const width = maxX - minX\n const height = maxY - minY\n const center = { x: minX + width / 2, y: minY + height / 2 }\n\n return { center, width, height }\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\n\nexport const getPrimaryId = (element: AnyCircuitElement): string => {\n // @ts-ignore\n return element[`${element.type}_id`]\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { transformPCBElements } from \"./transform-soup-elements\"\nimport { translate } from \"transformation-matrix\"\n\nexport const repositionPcbComponentTo = (\n circuitJson: AnyCircuitElement[],\n pcb_component_id: string,\n newCenter: { x: number; y: number },\n) => {\n const pcbComponent = circuitJson.find(\n (e) =>\n e.type === \"pcb_component\" &&\n (e as any).pcb_component_id === pcb_component_id,\n )\n if (!pcbComponent) return\n\n const currentCenter =\n \"center\" in pcbComponent\n ? (pcbComponent as any).center\n : { x: (pcbComponent as any).x, y: (pcbComponent as any).y }\n\n const dx = newCenter.x - currentCenter.x\n const dy = newCenter.y - currentCenter.y\n\n const portIds = circuitJson\n .filter(\n (e) =>\n e.type === \"pcb_port\" &&\n (e as any).pcb_component_id === pcb_component_id,\n )\n .map((e) => (e as any).pcb_port_id)\n\n const elementsToMove = circuitJson.filter((elm) => {\n if (elm === pcbComponent) return true\n const anyElm: any = elm\n if (anyElm.pcb_component_id === pcb_component_id) return true\n if (\n Array.isArray(anyElm.pcb_component_ids) &&\n anyElm.pcb_component_ids.includes(pcb_component_id)\n )\n return true\n if (anyElm.pcb_port_id && portIds.includes(anyElm.pcb_port_id)) return true\n if (\n Array.isArray(anyElm.pcb_port_ids) &&\n anyElm.pcb_port_ids.some((id: string) => portIds.includes(id))\n )\n return true\n if (anyElm.start_pcb_port_id && portIds.includes(anyElm.start_pcb_port_id))\n return true\n if (anyElm.end_pcb_port_id && portIds.includes(anyElm.end_pcb_port_id))\n return true\n if (\n Array.isArray(anyElm.route) &&\n anyElm.route.some(\n (pt: any) =>\n (pt.start_pcb_port_id && portIds.includes(pt.start_pcb_port_id)) ||\n (pt.end_pcb_port_id && portIds.includes(pt.end_pcb_port_id)),\n )\n )\n return true\n return false\n })\n\n const matrix = translate(dx, dy)\n transformPCBElements(elementsToMove, matrix)\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { buildSubtree } from \"./subtree\"\nimport { findBoundsAndCenter } from \"./find-bounds-and-center\"\nimport { transformPCBElements } from \"./transform-soup-elements\"\nimport { translate } from \"transformation-matrix\"\n\nconst findAllDescendantGroupIds = (\n circuitJson: AnyCircuitElement[],\n parentGroupId: string,\n): string[] => {\n const childGroupIds: string[] = []\n const directChildren = circuitJson\n .filter(\n (elm) =>\n elm.type === \"source_group\" &&\n (elm as any).parent_source_group_id === parentGroupId,\n )\n .map((elm) => (elm as any).source_group_id)\n\n childGroupIds.push(...directChildren)\n\n // Recursively find descendants of child groups\n for (const childId of directChildren) {\n childGroupIds.push(...findAllDescendantGroupIds(circuitJson, childId))\n }\n\n return childGroupIds\n}\n\nexport const repositionPcbGroupTo = (\n circuitJson: AnyCircuitElement[],\n source_group_id: string,\n newCenter: { x: number; y: number },\n) => {\n // Find all descendant group IDs\n const allGroupIds = [\n source_group_id,\n ...findAllDescendantGroupIds(circuitJson, source_group_id),\n ]\n\n // Get all elements for each group (including the main group and its descendants)\n const allGroupElements = new Set<AnyCircuitElement>()\n\n for (const groupId of allGroupIds) {\n const groupElements = buildSubtree(circuitJson, {\n source_group_id: groupId,\n })\n groupElements.forEach((elm) => allGroupElements.add(elm))\n }\n\n // Get all port IDs from elements in the group\n const portIds = Array.from(allGroupElements)\n .filter((e) => e.type === \"pcb_port\")\n .map((e) => (e as any).pcb_port_id)\n\n // Find additional traces that connect to these ports (buildSubtree might miss these)\n const additionalTraces = circuitJson.filter((elm) => {\n if (elm.type !== \"pcb_trace\") return false\n if (allGroupElements.has(elm)) return false // already included\n\n const anyElm: any = elm\n\n // Check direct port connections\n if (anyElm.start_pcb_port_id && portIds.includes(anyElm.start_pcb_port_id))\n return true\n if (anyElm.end_pcb_port_id && portIds.includes(anyElm.end_pcb_port_id))\n return true\n\n // Check route point connections\n if (\n Array.isArray(anyElm.route) &&\n anyElm.route.some(\n (pt: any) =>\n (pt.start_pcb_port_id && portIds.includes(pt.start_pcb_port_id)) ||\n (pt.end_pcb_port_id && portIds.includes(pt.end_pcb_port_id)),\n )\n )\n return true\n\n return false\n })\n\n // Add additional traces to the elements to move\n additionalTraces.forEach((trace) => allGroupElements.add(trace))\n\n // Filter to only PCB elements that can be repositioned\n const pcbElements = Array.from(allGroupElements).filter((elm) =>\n elm.type.startsWith(\"pcb_\"),\n )\n\n if (pcbElements.length === 0) return\n\n // Calculate current bounds and center of the group\n const { center: currentCenter } = findBoundsAndCenter(pcbElements)\n\n // Calculate translation needed\n const dx = newCenter.x - currentCenter.x\n const dy = newCenter.y - currentCenter.y\n\n // Create translation matrix\n const matrix = translate(dx, dy)\n\n // Apply transformation to all PCB elements in the group\n transformPCBElements(pcbElements, matrix)\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { transformSchematicElements } from \"./transform-soup-elements\"\nimport { translate } from \"transformation-matrix\"\n\nexport const repositionSchematicComponentTo = (\n circuitJson: AnyCircuitElement[],\n schematic_component_id: string,\n newCenter: { x: number; y: number },\n) => {\n const schematicComponent = circuitJson.find(\n (e) =>\n e.type === \"schematic_component\" &&\n (e as any).schematic_component_id === schematic_component_id,\n )\n if (!schematicComponent) return\n\n const currentCenter =\n \"center\" in schematicComponent\n ? (schematicComponent as any).center\n : { x: (schematicComponent as any).x, y: (schematicComponent as any).y }\n\n const dx = newCenter.x - currentCenter.x\n const dy = newCenter.y - currentCenter.y\n\n const portIds = circuitJson\n .filter(\n (e) =>\n e.type === \"schematic_port\" &&\n (e as any).schematic_component_id === schematic_component_id,\n )\n .map((e) => (e as any).schematic_port_id)\n\n const elementsToMove = circuitJson.filter((elm) => {\n if (elm === schematicComponent) return true\n const anyElm: any = elm\n if (anyElm.schematic_component_id === schematic_component_id) return true\n if (\n Array.isArray(anyElm.schematic_component_ids) &&\n anyElm.schematic_component_ids.includes(schematic_component_id)\n )\n return true\n if (anyElm.schematic_port_id && portIds.includes(anyElm.schematic_port_id))\n return true\n if (\n Array.isArray(anyElm.schematic_port_ids) &&\n anyElm.schematic_port_ids.some((id: string) => portIds.includes(id))\n )\n return true\n if (\n anyElm.start_schematic_port_id &&\n portIds.includes(anyElm.start_schematic_port_id)\n )\n return true\n if (\n anyElm.end_schematic_port_id &&\n portIds.includes(anyElm.end_schematic_port_id)\n )\n return true\n if (\n Array.isArray(anyElm.route) &&\n anyElm.route.some(\n (pt: any) =>\n (pt.start_schematic_port_id &&\n portIds.includes(pt.start_schematic_port_id)) ||\n (pt.end_schematic_port_id &&\n portIds.includes(pt.end_schematic_port_id)),\n )\n )\n return true\n return false\n })\n\n const matrix = translate(dx, dy)\n transformSchematicElements(elementsToMove, matrix)\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { buildSubtree } from \"./subtree\"\nimport { findBoundsAndCenter } from \"./find-bounds-and-center\"\nimport { transformSchematicElements } from \"./transform-soup-elements\"\nimport { translate } from \"transformation-matrix\"\n\nconst findAllDescendantGroupIds = (\n circuitJson: AnyCircuitElement[],\n parentGroupId: string,\n): string[] => {\n const childGroupIds: string[] = []\n const directChildren = circuitJson\n .filter(\n (elm) =>\n elm.type === \"source_group\" &&\n (elm as any).parent_source_group_id === parentGroupId,\n )\n .map((elm) => (elm as any).source_group_id)\n\n childGroupIds.push(...directChildren)\n\n for (const childId of directChildren) {\n childGroupIds.push(...findAllDescendantGroupIds(circuitJson, childId))\n }\n\n return childGroupIds\n}\n\nexport const repositionSchematicGroupTo = (\n circuitJson: AnyCircuitElement[],\n source_group_id: string,\n newCenter: { x: number; y: number },\n) => {\n const allGroupIds = [\n source_group_id,\n ...findAllDescendantGroupIds(circuitJson, source_group_id),\n ]\n\n const allGroupElements = new Set<AnyCircuitElement>()\n\n for (const groupId of allGroupIds) {\n const groupElements = buildSubtree(circuitJson, {\n source_group_id: groupId,\n })\n groupElements.forEach((elm) => allGroupElements.add(elm))\n }\n\n const portIds = Array.from(allGroupElements)\n .filter((e) => e.type === \"schematic_port\")\n .map((e) => (e as any).schematic_port_id)\n\n const additionalTraces = circuitJson.filter((elm) => {\n if (elm.type !== \"schematic_trace\") return false\n if (allGroupElements.has(elm)) return false\n\n const anyElm: any = elm\n\n if (\n anyElm.start_schematic_port_id &&\n portIds.includes(anyElm.start_schematic_port_id)\n )\n return true\n if (\n anyElm.end_schematic_port_id &&\n portIds.includes(anyElm.end_schematic_port_id)\n )\n return true\n if (\n Array.isArray(anyElm.route) &&\n anyElm.route.some(\n (pt: any) =>\n (pt.start_schematic_port_id &&\n portIds.includes(pt.start_schematic_port_id)) ||\n (pt.end_schematic_port_id &&\n portIds.includes(pt.end_schematic_port_id)),\n )\n )\n return true\n\n return false\n })\n\n additionalTraces.forEach((trace) => allGroupElements.add(trace))\n\n const schematicElements = Array.from(allGroupElements).filter((elm) =>\n elm.type.startsWith(\"schematic_\"),\n )\n if (schematicElements.length === 0) return\n\n const { center: currentCenter } = findBoundsAndCenter(schematicElements)\n\n const dx = newCenter.x - currentCenter.x\n const dy = newCenter.y - currentCenter.y\n\n const matrix = translate(dx, dy)\n\n transformSchematicElements(schematicElements, matrix)\n}\n","import type {\n AnyCircuitElement,\n SourceComponentBase,\n SourceGroup,\n} from \"circuit-json\"\n\n/**\n * A tree of circuit elements. This is often used for layout because you want\n * to consider only the top-level elements of a group for layout (child groups\n * move together)\n */\nexport interface CircuitJsonTreeNode {\n nodeType: \"group\" | \"component\"\n sourceGroup?: SourceGroup\n sourceComponent?: SourceComponentBase\n childNodes: Array<CircuitJsonTreeNode>\n otherChildElements: Array<AnyCircuitElement>\n}\n\nexport const getCircuitJsonTree = (\n circuitJson: AnyCircuitElement[],\n opts?: {\n source_group_id?: string\n },\n): CircuitJsonTreeNode => {\n type ChildGroupId = string\n type ParentGroupId = string\n type GroupId = string\n const groupChildMap: Map<ParentGroupId, ChildGroupId[]> = new Map()\n\n // Get all source group IDs present in the circuit JSON\n const existingGroupIds = new Set<string>()\n for (const elm of circuitJson) {\n if (elm.type === \"source_group\") {\n existingGroupIds.add(elm.source_group_id)\n }\n }\n\n // Find orphaned groups (groups whose parent is not in the circuit JSON)\n const orphanedGroups: string[] = []\n\n for (const elm of circuitJson) {\n if (elm.type === \"source_group\" && elm.parent_source_group_id) {\n const parentId = elm.parent_source_group_id\n const childId = elm.source_group_id\n\n // If parent doesn't exist in circuit JSON, this is an orphaned group\n if (!existingGroupIds.has(parentId)) {\n orphanedGroups.push(childId)\n // Treat orphaned groups as root-level groups\n if (!groupChildMap.has(childId)) {\n groupChildMap.set(childId, [])\n }\n } else {\n // Normal parent-child relationship\n const children = groupChildMap.get(parentId) ?? []\n children.push(childId)\n groupChildMap.set(parentId, children)\n if (!groupChildMap.has(childId)) {\n groupChildMap.set(childId, [])\n }\n }\n }\n }\n\n // Ensure that every source_group, including root-level groups that have no parent,\n // is present in the groupChildMap. This guarantees that even standalone boards\n // (with no nested groups) are processed and appear at the top of the tree.\n for (const elm of circuitJson) {\n if (\n elm.type === \"source_group\" &&\n !groupChildMap.has(elm.source_group_id)\n ) {\n groupChildMap.set(elm.source_group_id, [])\n }\n }\n\n const groupNodes = new Map<GroupId, CircuitJsonTreeNode>()\n\n const getNextGroupId = () => {\n for (const [parentId, children] of groupChildMap) {\n if (groupNodes.has(parentId)) continue\n if (children.every((childId) => groupNodes.has(childId))) {\n return parentId\n }\n }\n return null\n }\n\n // Compute any node we have the dependencies for until we've computed all of\n // them\n let lastGroupId: GroupId | null = null\n while (true) {\n const nextGroupId = getNextGroupId()\n if (!nextGroupId) break\n\n const sourceGroup = circuitJson.find(\n (elm) =>\n elm.type === \"source_group\" && elm.source_group_id === nextGroupId,\n ) as SourceGroup\n\n // Create the tree node for this group\n const node: CircuitJsonTreeNode = {\n nodeType: \"group\",\n sourceGroup,\n otherChildElements: [],\n childNodes: [\n ...(groupChildMap\n .get(nextGroupId)\n ?.map((childId) => groupNodes.get(childId)!) ?? []),\n ...circuitJson\n .filter(\n (elm) =>\n elm.type === \"source_component\" &&\n elm.source_group_id === nextGroupId,\n )\n .map((elm) => {\n return {\n nodeType: \"component\",\n sourceComponent: elm,\n childNodes: [],\n otherChildElements: [\n ...circuitJson.filter(\n (e) =>\n e.type === \"pcb_component\" &&\n e.source_component_id ===\n (elm as SourceComponentBase).source_component_id,\n ),\n ], // TODO populate\n } as CircuitJsonTreeNode\n }),\n ],\n }\n\n groupNodes.set(nextGroupId, node)\n lastGroupId = nextGroupId\n }\n\n if (!lastGroupId) {\n console.warn(\"No groups were processed, returning tree without sourceGroup\")\n return {\n nodeType: \"group\",\n childNodes: [], // TODO populate\n otherChildElements: circuitJson,\n }\n }\n\n // Determine which group to return as root\n let rootGroupId: string | null = null\n if (opts && opts.source_group_id !== undefined) {\n // Use explicitly specified group\n rootGroupId = opts.source_group_id\n } else if (orphanedGroups.length > 0) {\n // Use the first orphaned group as root (most likely scenario when filtering circuit JSON)\n rootGroupId = orphanedGroups[0]!\n } else {\n // Fall back to the last processed group (typically the top-level parent)\n rootGroupId = lastGroupId as string | null\n }\n\n if (!rootGroupId) {\n console.warn(\n \"No valid root group found, returning tree without sourceGroup\",\n )\n return {\n nodeType: \"group\",\n childNodes: [],\n otherChildElements: circuitJson,\n }\n }\n\n return groupNodes.get(rootGroupId)!\n}\n","import type { CircuitJsonTreeNode } from \"./getCircuitJsonTree\"\n\nexport const getStringFromCircuitJsonTree = (\n circuitJsonTree: CircuitJsonTreeNode,\n indent = 0,\n): string => {\n if (circuitJsonTree.nodeType === \"component\") {\n return `${\" \".repeat(indent)}${circuitJsonTree.sourceComponent?.name ?? circuitJsonTree.sourceComponent?.source_component_id}`\n }\n const lines = []\n\n lines.push(\n `${\" \".repeat(indent)}${circuitJsonTree.sourceGroup?.name ?? circuitJsonTree.sourceGroup?.source_group_id}`,\n )\n for (const child of circuitJsonTree.childNodes) {\n lines.push(getStringFromCircuitJsonTree(child, indent + 2))\n }\n return lines.join(\"\\n\")\n}\n","export type Size = { width: number; height: number }\n\nimport type { FlexBoxOptions } from \"@tscircuit/miniflex\"\n/**\n * Compute the smallest possible dimensions (width & height) for a flex container\n * so that **all** children fit without overflowing _before_ any flex grow / shrink\n * is applied. This is a very lightweight approximation – it only considers the\n * children's explicit `width`/`height` (or `flexBasis`) plus the configured gaps\n * and the main-axis stacking rules derived from the flex direction.\n *\n * This function purposely does **not** try to implement the full flexbox sizing\n * algorithm – we only need a quick estimate so that `RootFlexBox` can be\n * instantiated even when the user did not provide explicit dimensions for the\n * container (e.g. when laying out PCB components directly on the board level\n * instead of inside a sub-circuit).\n */\nexport function getMinimumFlexContainer(\n children: Array<{ width: number; height: number }>,\n options: FlexBoxOptions = {},\n): Size {\n if (children.length === 0) return { width: 0, height: 0 }\n\n const direction = options.direction ?? \"row\"\n const columnGap = options.columnGap ?? 0\n const rowGap = options.rowGap ?? 0\n\n // Flexbox main-axis / cross-axis mapping --------------------------------\n const isRowDirection = direction === \"row\" || direction === \"row-reverse\"\n\n if (isRowDirection) {\n // Main-axis horizontally stacks children\n const totalChildWidth = children.reduce((sum, c) => sum + c.width, 0)\n const width = totalChildWidth + columnGap * Math.max(0, children.length - 1)\n\n const height = children.reduce((max, c) => Math.max(max, c.height), 0)\n return { width, height }\n } else {\n // Column direction – stack vertically\n const totalChildHeight = children.reduce((sum, c) => sum + c.height, 0)\n const height = totalChildHeight + rowGap * Math.max(0, children.length - 1)\n\n const width = children.reduce((max, c) => Math.max(max, c.width), 0)\n return { width, height }\n }\n}\n","import type { AnyCircuitElement, PcbRenderLayer } from \"circuit-json\"\n\nexport function getElementRenderLayers(\n element: AnyCircuitElement,\n): PcbRenderLayer[] {\n // Copper elements (pads, traces, copper pour, copper text)\n if (element.type === \"pcb_smtpad\") {\n const layer = element.layer\n return [`${layer}_copper` as PcbRenderLayer]\n }\n\n if (element.type === \"pcb_trace\") {\n // Traces can span multiple layers, return all layers from route\n if (!element.route || !Array.isArray(element.route)) return []\n const layers = new Set<PcbRenderLayer>()\n for (const point of element.route) {\n if (\"layer\" in point && point.layer) {\n layers.add(`${point.layer}_copper` as PcbRenderLayer)\n }\n }\n return Array.from(layers)\n }\n\n if (element.type === \"pcb_copper_pour\") {\n const layer = element.layer\n return [`${layer}_copper` as PcbRenderLayer]\n }\n\n if (element.type === \"pcb_copper_text\") {\n const layer = element.layer\n return [`${layer}_copper` as PcbRenderLayer]\n }\n\n // Silkscreen elements\n if (\n element.type === \"pcb_silkscreen_text\" ||\n element.type === \"pcb_silkscreen_rect\" ||\n element.type === \"pcb_silkscreen_circle\" ||\n element.type === \"pcb_silkscreen_line\" ||\n element.type === \"pcb_silkscreen_path\"\n ) {\n const layer = element.layer\n return [`${layer}_silkscreen` as PcbRenderLayer]\n }\n\n // Fabrication note elements\n if (\n element.type === \"pcb_fabrication_note_text\" ||\n element.type === \"pcb_fabrication_note_rect\" ||\n element.type === \"pcb_fabrication_note_path\"\n ) {\n const layer = element.layer\n return [`${layer}_fabrication_note` as PcbRenderLayer]\n }\n\n // Courtyard elements\n\n if (\n element.type === \"pcb_courtyard_circle\" ||\n element.type === \"pcb_courtyard_polygon\" ||\n element.type === \"pcb_courtyard_rect\" ||\n element.type === \"pcb_courtyard_outline\"\n ) {\n const layer = element.layer\n return [`${layer}_courtyard` as PcbRenderLayer]\n }\n\n // Elements without layer filtering (always drawn)\n // These include: pcb_board, pcb_hole, pcb_plated_hole, pcb_via, pcb_cutout,\n // pcb_note_rect, pcb_note_path, pcb_note_text, pcb_note_line, pcb_note_dimension\n return []\n}\n","import type { Point, Polygon, Rect } from \"./types\"\n\nexport const EPSILON = 1e-9\n\nexport const toRadians = (degrees: number) => (degrees * Math.PI) / 180\n\nexport const clamp = (value: number, min: number, max: number) =>\n Math.max(min, Math.min(max, value))\n\nexport const distanceBetweenPoints = (a: Point, b: Point) =>\n Math.hypot(a.x - b.x, a.y - b.y)\n\nexport const distanceBetweenPointAndSegment = (\n point: Point,\n a: Point,\n b: Point,\n) => {\n const abX = b.x - a.x\n const abY = b.y - a.y\n const lengthSquared = abX * abX + abY * abY\n\n if (lengthSquared <= EPSILON) return distanceBetweenPoints(point, a)\n\n const t = clamp(\n ((point.x - a.x) * abX + (point.y - a.y) * abY) / lengthSquared,\n 0,\n 1,\n )\n\n return Math.hypot(point.x - (a.x + t * abX), point.y - (a.y + t * abY))\n}\n\nexport const cross = (a: Point, b: Point, c: Point) =>\n (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)\n\nexport const isPointOnSegment = (point: Point, a: Point, b: Point) => {\n if (Math.abs(cross(a, b, point)) > EPSILON) return false\n\n return (\n point.x >= Math.min(a.x, b.x) - EPSILON &&\n point.x <= Math.max(a.x, b.x) + EPSILON &&\n point.y >= Math.min(a.y, b.y) - EPSILON &&\n point.y <= Math.max(a.y, b.y) + EPSILON\n )\n}\n\nexport const segmentsIntersect = (\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n) => {\n const c1 = cross(a1, a2, b1)\n const c2 = cross(a1, a2, b2)\n const c3 = cross(b1, b2, a1)\n const c4 = cross(b1, b2, a2)\n\n if (\n ((c1 > EPSILON && c2 < -EPSILON) || (c1 < -EPSILON && c2 > EPSILON)) &&\n ((c3 > EPSILON && c4 < -EPSILON) || (c3 < -EPSILON && c4 > EPSILON))\n ) {\n return true\n }\n\n return (\n isPointOnSegment(b1, a1, a2) ||\n isPointOnSegment(b2, a1, a2) ||\n isPointOnSegment(a1, b1, b2) ||\n isPointOnSegment(a2, b1, b2)\n )\n}\n\nexport const getPolygonEdges = (polygon: Polygon): Array<[Point, Point]> => {\n const edges: Array<[Point, Point]> = []\n\n if (polygon.points.length < 2) return edges\n\n for (let i = 0; i < polygon.points.length; i += 1) {\n const a = polygon.points[i]\n const b = polygon.points[(i + 1) % polygon.points.length]\n\n if (!a || !b) continue\n\n edges.push([a, b])\n }\n\n return edges\n}\n\nexport const isPointInPolygon = (point: Point, polygon: Polygon) => {\n for (const [a, b] of getPolygonEdges(polygon)) {\n if (isPointOnSegment(point, a, b)) return true\n }\n\n let inside = false\n for (\n let i = 0, j = polygon.points.length - 1;\n i < polygon.points.length;\n j = i++\n ) {\n const pi = polygon.points[i]\n const pj = polygon.points[j]\n\n if (!pi || !pj) continue\n\n const intersects =\n pi.y > point.y !== pj.y > point.y &&\n point.x < ((pj.x - pi.x) * (point.y - pi.y)) / (pj.y - pi.y) + pi.x\n\n if (intersects) inside = !inside\n }\n\n return inside\n}\n\nexport const rotatePoint = (point: Point, angleRadians: number) => ({\n x: point.x * Math.cos(angleRadians) - point.y * Math.sin(angleRadians),\n y: point.x * Math.sin(angleRadians) + point.y * Math.cos(angleRadians),\n})\n\nexport const rectToPolygon = (rect: Rect): Polygon => {\n const halfWidth = rect.width / 2\n const halfHeight = rect.height / 2\n const angle = toRadians(rect.rotationDegrees)\n\n return {\n kind: \"polygon\",\n points: [\n { x: -halfWidth, y: -halfHeight },\n { x: halfWidth, y: -halfHeight },\n { x: halfWidth, y: halfHeight },\n { x: -halfWidth, y: halfHeight },\n ].map((localPoint) => {\n const rotated = rotatePoint(localPoint, angle)\n return { x: rect.centerX + rotated.x, y: rect.centerY + rotated.y }\n }),\n }\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { EPSILON } from \"./geometry\"\nimport type { CopperShape, Point, Rect } from \"./types\"\n\nconst isFiniteNumber = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value)\n\nconst createWireSegmentRect = (\n start: Point,\n end: Point,\n width: number,\n): Rect => ({\n kind: \"rect\",\n centerX: (start.x + end.x) / 2,\n centerY: (start.y + end.y) / 2,\n width: Math.hypot(end.x - start.x, end.y - start.y),\n height: width,\n rotationDegrees:\n (Math.atan2(end.y - start.y, end.x - start.x) * 180) / Math.PI,\n})\n\nexport const decomposeCopperIntoShapes = (\n element: AnyCircuitElement,\n): CopperShape[] => {\n const elm: any = element\n const shapes: CopperShape[] = []\n\n if (elm.type === \"pcb_smtpad\") {\n if (elm.shape === \"circle\" && isFiniteNumber(elm.radius)) {\n shapes.push({ kind: \"circle\", x: elm.x, y: elm.y, radius: elm.radius })\n }\n\n if (\n elm.shape === \"rect\" &&\n isFiniteNumber(elm.width) &&\n isFiniteNumber(elm.height)\n ) {\n shapes.push({\n kind: \"rect\",\n centerX: elm.x,\n centerY: elm.y,\n width: elm.width,\n height: elm.height,\n rotationDegrees: isFiniteNumber(elm.ccw_rotation)\n ? elm.ccw_rotation\n : 0,\n })\n }\n\n if (elm.shape === \"polygon\" && Array.isArray(elm.points)) {\n const points = elm.points.filter(\n (point: any): point is Point =>\n isFiniteNumber(point?.x) && isFiniteNumber(point?.y),\n )\n\n if (points.length >= 3) {\n shapes.push({ kind: \"polygon\", points })\n }\n }\n\n return shapes\n }\n\n if (elm.type === \"pcb_trace\" && Array.isArray(elm.route)) {\n for (let i = 0; i < elm.route.length - 1; i += 1) {\n const start = elm.route[i]\n const end = elm.route[i + 1]\n\n if (\n !start ||\n !end ||\n start.route_type !== \"wire\" ||\n end.route_type !== \"wire\" ||\n !isFiniteNumber(start.x) ||\n !isFiniteNumber(start.y) ||\n !isFiniteNumber(end.x) ||\n !isFiniteNumber(end.y)\n ) {\n continue\n }\n\n const width = isFiniteNumber(start.width) ? Math.max(0, start.width) : 0\n const radius = width / 2\n\n shapes.push({ kind: \"circle\", x: start.x, y: start.y, radius })\n shapes.push({ kind: \"circle\", x: end.x, y: end.y, radius })\n\n if (Math.hypot(end.x - start.x, end.y - start.y) > EPSILON) {\n shapes.push(createWireSegmentRect(start, end, width))\n }\n }\n\n return shapes\n }\n\n if (elm.type === \"pcb_via\" && isFiniteNumber(elm.outer_diameter)) {\n shapes.push({\n kind: \"circle\",\n x: elm.x,\n y: elm.y,\n radius: elm.outer_diameter / 2,\n })\n\n return shapes\n }\n\n if (elm.type === \"pcb_plated_hole\") {\n if (isFiniteNumber(elm.outer_diameter)) {\n shapes.push({\n kind: \"circle\",\n x: elm.x,\n y: elm.y,\n radius: elm.outer_diameter / 2,\n })\n }\n\n if (\n isFiniteNumber(elm.rect_pad_width) &&\n isFiniteNumber(elm.rect_pad_height)\n ) {\n shapes.push({\n kind: \"rect\",\n centerX: elm.x,\n centerY: elm.y,\n width: elm.rect_pad_width,\n height: elm.rect_pad_height,\n rotationDegrees: isFiniteNumber(elm.rect_ccw_rotation)\n ? elm.rect_ccw_rotation\n : 0,\n })\n }\n\n if (isFiniteNumber(elm.outer_width) && isFiniteNumber(elm.outer_height)) {\n shapes.push({\n kind: \"rect\",\n centerX: elm.x,\n centerY: elm.y,\n width: elm.outer_width,\n height: elm.outer_height,\n rotationDegrees: 0,\n })\n }\n\n return shapes\n }\n\n return shapes\n}\n","import {\n distanceBetweenPointAndSegment,\n getPolygonEdges,\n isPointInPolygon,\n rectToPolygon,\n segmentsIntersect,\n} from \"./geometry\"\nimport type { Circle, CopperShape, Polygon, Rect } from \"./types\"\n\nconst distanceBetweenCircleAndCircle = (a: Circle, b: Circle) =>\n Math.max(0, Math.hypot(a.x - b.x, a.y - b.y) - a.radius - b.radius)\n\nconst distanceBetweenPolygonAndPolygon = (a: Polygon, b: Polygon) => {\n if (a.points.length < 3 || b.points.length < 3) {\n return Number.POSITIVE_INFINITY\n }\n\n for (const [a1, a2] of getPolygonEdges(a)) {\n for (const [b1, b2] of getPolygonEdges(b)) {\n if (segmentsIntersect(a1, a2, b1, b2)) {\n return 0\n }\n }\n }\n\n const aPoint = a.points[0]\n const bPoint = b.points[0]\n if (\n (aPoint && isPointInPolygon(aPoint, b)) ||\n (bPoint && isPointInPolygon(bPoint, a))\n ) {\n return 0\n }\n\n let minDistance = Number.POSITIVE_INFINITY\n\n for (const [a1, a2] of getPolygonEdges(a)) {\n for (const [b1, b2] of getPolygonEdges(b)) {\n minDistance = Math.min(\n minDistance,\n distanceBetweenPointAndSegment(a1, b1, b2),\n distanceBetweenPointAndSegment(a2, b1, b2),\n distanceBetweenPointAndSegment(b1, a1, a2),\n distanceBetweenPointAndSegment(b2, a1, a2),\n )\n }\n }\n\n return minDistance\n}\n\nconst distanceBetweenCircleAndPolygon = (circle: Circle, polygon: Polygon) => {\n if (polygon.points.length < 3) {\n return Number.POSITIVE_INFINITY\n }\n\n if (isPointInPolygon({ x: circle.x, y: circle.y }, polygon)) {\n return 0\n }\n\n let minDistanceToEdge = Number.POSITIVE_INFINITY\n\n for (const [start, end] of getPolygonEdges(polygon)) {\n minDistanceToEdge = Math.min(\n minDistanceToEdge,\n distanceBetweenPointAndSegment({ x: circle.x, y: circle.y }, start, end),\n )\n }\n\n return Math.max(0, minDistanceToEdge - circle.radius)\n}\n\nexport const distanceBetweenShapes = (\n a: CopperShape,\n b: CopperShape,\n): number => {\n if (a.kind === \"circle\" && b.kind === \"circle\") {\n return distanceBetweenCircleAndCircle(a, b)\n }\n\n if (a.kind === \"rect\" && b.kind === \"rect\") {\n return distanceBetweenPolygonAndPolygon(rectToPolygon(a), rectToPolygon(b))\n }\n\n if (a.kind === \"circle\" && b.kind === \"rect\") {\n return distanceBetweenCircleAndPolygon(a, rectToPolygon(b))\n }\n\n if (a.kind === \"rect\" && b.kind === \"circle\") {\n return distanceBetweenCircleAndPolygon(b, rectToPolygon(a))\n }\n\n if (a.kind === \"circle\" && b.kind === \"polygon\") {\n return distanceBetweenCircleAndPolygon(a, b)\n }\n\n if (a.kind === \"polygon\" && b.kind === \"circle\") {\n return distanceBetweenCircleAndPolygon(b, a)\n }\n\n if (a.kind === \"rect\" && b.kind === \"polygon\") {\n return distanceBetweenPolygonAndPolygon(rectToPolygon(a), b)\n }\n\n if (a.kind === \"polygon\" && b.kind === \"rect\") {\n return distanceBetweenPolygonAndPolygon(a, rectToPolygon(b))\n }\n\n if (a.kind === \"polygon\" && b.kind === \"polygon\") {\n return distanceBetweenPolygonAndPolygon(a, b)\n }\n\n return Number.POSITIVE_INFINITY\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { decomposeCopperIntoShapes } from \"./shape-distances/decompose-copper-into-shapes\"\nimport { distanceBetweenShapes } from \"./shape-distances/distance-between-shapes\"\n\nexport const computeGapBetweenCopper = (\n elm1: AnyCircuitElement,\n elm2: AnyCircuitElement,\n): number => {\n const shapes1 = decomposeCopperIntoShapes(elm1)\n const shapes2 = decomposeCopperIntoShapes(elm2)\n\n if (shapes1.length === 0 || shapes2.length === 0) {\n return Number.POSITIVE_INFINITY\n }\n\n let minimumGap = Number.POSITIVE_INFINITY\n\n for (const shape1 of shapes1) {\n for (const shape2 of shapes2) {\n minimumGap = Math.min(minimumGap, distanceBetweenShapes(shape1, shape2))\n }\n }\n\n return minimumGap\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { decomposeCopperIntoShapes } from \"./decompose-copper-into-shapes\"\nimport type { CopperShape, Point } from \"./types\"\n\nconst isFiniteNumber = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value)\n\nconst getCenter = (elm: any): { x: number; y: number } | null => {\n if (isFiniteNumber(elm?.x) && isFiniteNumber(elm?.y)) {\n return { x: elm.x, y: elm.y }\n }\n\n if (isFiniteNumber(elm?.center?.x) && isFiniteNumber(elm?.center?.y)) {\n return { x: elm.center.x, y: elm.center.y }\n }\n\n return null\n}\n\nconst addCenterBasedShapes = (elm: any, shapes: CopperShape[]) => {\n const center = getCenter(elm)\n if (!center) return\n\n if (elm.shape === \"circle\") {\n if (isFiniteNumber(elm.radius)) {\n shapes.push({\n kind: \"circle\",\n x: center.x,\n y: center.y,\n radius: elm.radius,\n })\n return\n }\n\n if (isFiniteNumber(elm.diameter)) {\n shapes.push({\n kind: \"circle\",\n x: center.x,\n y: center.y,\n radius: elm.diameter / 2,\n })\n return\n }\n }\n\n if (\n elm.shape === \"rect\" &&\n isFiniteNumber(elm.width) &&\n isFiniteNumber(elm.height)\n ) {\n shapes.push({\n kind: \"rect\",\n centerX: center.x,\n centerY: center.y,\n width: elm.width,\n height: elm.height,\n rotationDegrees: isFiniteNumber(elm.ccw_rotation) ? elm.ccw_rotation : 0,\n })\n return\n }\n\n if (elm.shape === \"polygon\" && Array.isArray(elm.points)) {\n const points = elm.points.filter(\n (point: any): point is Point =>\n isFiniteNumber(point?.x) && isFiniteNumber(point?.y),\n )\n\n if (points.length >= 3) {\n shapes.push({ kind: \"polygon\", points })\n }\n }\n}\n\nexport const decomposeClearanceIntoShapes = (\n element: AnyCircuitElement,\n): CopperShape[] => {\n const elm: any = element\n const shapes: CopperShape[] = [...decomposeCopperIntoShapes(element)]\n\n if (elm.type === \"pcb_hole\" && elm.hole_shape === \"circle\") {\n if (\n isFiniteNumber(elm.hole_diameter) &&\n isFiniteNumber(elm.x) &&\n isFiniteNumber(elm.y)\n ) {\n shapes.push({\n kind: \"circle\",\n x: elm.x,\n y: elm.y,\n radius: elm.hole_diameter / 2,\n })\n }\n return shapes\n }\n\n if (elm.type === \"pcb_plated_hole\") {\n if (\n isFiniteNumber(elm.hole_diameter) &&\n isFiniteNumber(elm.x) &&\n isFiniteNumber(elm.y)\n ) {\n const holeOffsetX = isFiniteNumber(elm.hole_offset_x)\n ? elm.hole_offset_x\n : 0\n const holeOffsetY = isFiniteNumber(elm.hole_offset_y)\n ? elm.hole_offset_y\n : 0\n shapes.push({\n kind: \"circle\",\n x: elm.x + holeOffsetX,\n y: elm.y + holeOffsetY,\n radius: elm.hole_diameter / 2,\n })\n }\n return shapes\n }\n\n if (\n elm.type === \"pcb_keepout\" ||\n elm.type === \"pcb_cutout\" ||\n elm.type === \"pcb_board\"\n ) {\n addCenterBasedShapes(elm, shapes)\n return shapes\n }\n\n return shapes\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { decomposeClearanceIntoShapes } from \"./shape-distances/decompose-clearance-into-shapes\"\nimport { distanceBetweenShapes } from \"./shape-distances/distance-between-shapes\"\n\nexport const computeClearanceBetweenElements = (\n elm1: AnyCircuitElement,\n elm2: AnyCircuitElement,\n): number => {\n const shapes1 = decomposeClearanceIntoShapes(elm1)\n const shapes2 = decomposeClearanceIntoShapes(elm2)\n\n if (shapes1.length === 0 || shapes2.length === 0) {\n return Number.POSITIVE_INFINITY\n }\n\n let minimumGap = Number.POSITIVE_INFINITY\n\n for (const shape1 of shapes1) {\n for (const shape2 of shapes2) {\n minimumGap = Math.min(minimumGap, distanceBetweenShapes(shape1, shape2))\n }\n }\n\n return minimumGap\n}\n","export type DrcCategory =\n | \"netlist\"\n | \"pin_specification\"\n | \"placement\"\n | \"routing\"\n | \"unknown\"\n\ntype DrcLike = {\n type?: string\n error_type?: string\n warning_type?: string\n}\n\nconst NETLIST_TYPES = new Set([\"source_pin_must_be_connected_error\"])\n\nconst PIN_SPECIFICATION_TYPES = new Set([\n \"source_component_pins_underspecified_warning\",\n \"source_no_power_pin_defined_warning\",\n \"source_no_ground_pin_defined_warning\",\n])\n\nconst PLACEMENT_TYPES = new Set([\n \"pcb_placement_error\",\n \"pcb_component_outside_board_error\",\n \"pcb_footprint_overlap_error\",\n \"pcb_connector_not_in_accessible_orientation_warning\",\n])\n\nconst ROUTING_TYPES = new Set([\n \"pcb_port_not_connected_error\",\n \"pcb_trace_missing_error\",\n \"pcb_trace_error\",\n \"pcb_via_clearance_error\",\n])\n\nexport const categorizeErrorOrWarning = (\n value: string | DrcLike,\n): DrcCategory => {\n const drcType =\n typeof value === \"string\"\n ? value\n : (value.error_type ?? value.warning_type ?? value.type)\n\n if (!drcType) return \"unknown\"\n\n if (NETLIST_TYPES.has(drcType)) return \"netlist\"\n if (PIN_SPECIFICATION_TYPES.has(drcType)) return \"pin_specification\"\n if (PLACEMENT_TYPES.has(drcType)) return \"placement\"\n if (ROUTING_TYPES.has(drcType)) return \"routing\"\n\n return \"unknown\"\n}\n","const unitToMm: { [key: string]: number } = {\n in: 25.4,\n inch: 25.4,\n mil: 0.0254,\n mm: 1,\n m: 1000,\n cm: 10,\n ft: 304.8,\n feet: 304.8,\n}\n\nexport const mm = (n: number | string): number => {\n let unit =\n typeof n === \"number\" ? \"mm\" : n.replace(/^[^a-zA-Z]+/g, \"\").toLowerCase()\n if (!unit) unit = \"mm\"\n const val = typeof n === \"number\" ? n : Number.parseFloat(n.split(unit)[0])\n\n if (unit in unitToMm) {\n return val * unitToMm[unit]\n }\n throw new Error(`Unsupported unit: ${unit}`)\n}\n\nexport const mmStr = (n: number | string): string => {\n return `${mm(n)}mm`\n}\n\nexport default mm\n","export interface Point {\n x: number\n y: number\n}\n\nexport function calculateCenter(start: Point, mid: Point, end: Point): Point {\n const mid1 = { x: (start.x + mid.x) / 2, y: (start.y + mid.y) / 2 }\n const mid2 = { x: (mid.x + end.x) / 2, y: (mid.y + end.y) / 2 }\n\n const slope1 = -(start.x - mid.x) / (start.y - mid.y)\n const slope2 = -(mid.x - end.x) / (mid.y - end.y)\n\n const centerX =\n (mid1.y - mid2.y + slope2 * mid2.x - slope1 * mid1.x) / (slope2 - slope1)\n const centerY = mid1.y + slope1 * (centerX - mid1.x)\n\n return { x: centerX, y: centerY }\n}\n\nfunction calculateRadius(center: Point, point: Point): number {\n return Math.sqrt((center.x - point.x) ** 2 + (center.y - point.y) ** 2)\n}\n\nfunction calculateAngle(center: Point, point: Point): number {\n return Math.atan2(point.y - center.y, point.x - center.x)\n}\n\nexport const getArcLength = (start: Point, mid: Point, end: Point) => {\n const center = calculateCenter(start, mid, end)\n const radius = calculateRadius(center, start)\n\n const angleStart = calculateAngle(center, start)\n const angleEnd = calculateAngle(center, end)\n\n let angleDelta = angleEnd - angleStart\n if (angleDelta < 0) {\n angleDelta += 2 * Math.PI\n }\n\n return radius * angleDelta\n}\n\nexport function generateArcPathWithMid(\n start: Point,\n mid: Point,\n end: Point,\n numPoints: number,\n): Point[] {\n const center = calculateCenter(start, mid, end)\n const radius = calculateRadius(center, start)\n\n const angleStart = calculateAngle(center, start)\n const angleEnd = calculateAngle(center, end)\n\n let angleDelta = angleEnd - angleStart\n if (angleDelta < 0) {\n angleDelta += 2 * Math.PI\n }\n\n const path: Point[] = []\n\n for (let i = 0; i <= numPoints; i++) {\n const angle = angleStart + (i / numPoints) * angleDelta\n const x = center.x + radius * Math.cos(angle)\n const y = center.y + radius * Math.sin(angle)\n // Check for NaN or Infinity values\n if (!isNaN(x) && isFinite(x) && !isNaN(y) && isFinite(y)) {\n path.push({ x, y })\n }\n }\n\n // If the path is empty, add the start and end points\n if (path.length === 0) {\n path.push(start, end)\n }\n\n return path\n}\n\n/**\nThis syntax describes an SVG path command for drawing an arc. Let's break down each part:\n\n1. \"M 3923.0512 2968.5197\": \n - M: Move to\n - 3923.0512: X-coordinate\n - 2968.5197: Y-coordinate\n\n2. \"A 2.5 2.5 0 0 0 3923.0512 2963.5197\":\n - A: Arc command\n - 2.5: X-radius of the ellipse\n - 2.5: Y-radius of the ellipse\n - 0: X-axis rotation (in degrees)\n - 0: Large arc flag (0 for small arc, 1 for large arc)\n - 0: Sweep flag (0 for counterclockwise, 1 for clockwise)\n - 3923.0512: End X-coordinate\n - 2963.5197: End Y-coordinate\n\nThis command draws an arc starting at (3923.0512, 2968.5197) and ending at (3923.0512, 2963.5197), using a circular path with a radius of 2.5 units.\n */\nexport function generateArcFromSweep(\n startX: number,\n startY: number,\n endX: number,\n endY: number,\n radius: number,\n largeArcFlag: boolean,\n sweepFlag: boolean,\n): Point[] {\n const start: Point = { x: startX, y: startY }\n const end: Point = { x: endX, y: endY }\n\n // Calculate the midpoint between start and end\n const midX = (startX + endX) / 2\n const midY = (startY + endY) / 2\n\n // Calculate the distance between start and end\n const dx = endX - startX\n const dy = endY - startY\n const distance = Math.sqrt(dx * dx + dy * dy)\n\n // If the distance is zero or the radius is too small, return a straight line\n if (distance === 0 || radius < distance / 2) {\n return [start, end]\n }\n\n // Calculate the center of the arc\n const h = Math.sqrt(radius * radius - (distance * distance) / 4)\n const angle = Math.atan2(dy, dx)\n const centerX = midX + h * Math.sin(angle) * (sweepFlag ? -1 : 1)\n const centerY = midY - h * Math.cos(angle) * (sweepFlag ? -1 : 1)\n\n // Calculate start and end angles\n const startAngle = Math.atan2(startY - centerY, startX - centerX)\n let endAngle = Math.atan2(endY - centerY, endX - centerX)\n\n // Adjust end angle based on sweep and large arc flags\n if (sweepFlag && endAngle > startAngle) {\n endAngle -= 2 * Math.PI\n } else if (!sweepFlag && endAngle < startAngle) {\n endAngle += 2 * Math.PI\n }\n\n if (\n (!largeArcFlag && Math.abs(endAngle - startAngle) > Math.PI) ||\n (largeArcFlag && Math.abs(endAngle - startAngle) < Math.PI)\n ) {\n if (endAngle > startAngle) {\n endAngle -= 2 * Math.PI\n } else {\n endAngle += 2 * Math.PI\n }\n }\n\n // Generate points along the arc\n const numPoints = Math.max(\n 2,\n Math.ceil(Math.abs(endAngle - startAngle) * radius),\n )\n const path: Point[] = []\n\n for (let i = 0; i <= numPoints; i++) {\n const t = i / numPoints\n const angle = startAngle + t * (endAngle - startAngle)\n const x = centerX + radius * Math.cos(angle)\n const y = centerY + radius * Math.sin(angle)\n path.push({ x, y })\n }\n\n return path\n}\n","/**\n * EasyEDA takes 10 mil as a basic factor, when a stroke width is 1, we can take it as 1*10mil = 10mil, is 2, we can take it as 2*10mil = 20mil,\n * Ref: https://docs.easyeda.com/en/DocumentFormat/3-EasyEDA-PCB-File-Format/#unit\n *\n * 1 mil = 0.001 inch\n * 1 inch = 25.4 mm\n * 1 mil = 25.4/1000 = 0.0254 mm\n */\nexport const mil10ToMm = (value: number): number => value * 10 * 0.0254\n","export const normalizePinLabels = (inputPinLabels: string[][]): string[][] => {\n const uniqueInputPinLabels = inputPinLabels.map((labels) => [\n ...new Set(labels),\n ])\n const result = uniqueInputPinLabels.map(() => [] as string[])\n const desiredNumbers = uniqueInputPinLabels.map(() => null as number | null)\n\n for (let i = 0; i < uniqueInputPinLabels.length; i++) {\n for (const label of uniqueInputPinLabels[i]) {\n if (/^\\d+$/.test(label)) {\n desiredNumbers[i] = Number.parseInt(label)\n break\n }\n }\n }\n\n let highestPinNumber = 0\n const acceptedDesiredNumbers = new Set<number>()\n\n for (let i = 0; i < desiredNumbers.length; i++) {\n const desiredNumber = desiredNumbers[i]\n if (desiredNumber === null || desiredNumber < 1) continue\n\n if (!acceptedDesiredNumbers.has(desiredNumber)) {\n acceptedDesiredNumbers.add(desiredNumber)\n result[i].push(`pin${desiredNumber}`)\n highestPinNumber = Math.max(highestPinNumber, desiredNumber)\n continue\n }\n\n let existingAltCount = 0\n for (const label of result[i]) {\n if (label.startsWith(`pin${desiredNumber}_alt`)) {\n existingAltCount += 1\n }\n }\n result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`)\n }\n\n for (let i = 0; i < result.length; i++) {\n const firstLabel = result[i][0]\n if (firstLabel?.includes(\"_alt\")) {\n highestPinNumber += 1\n result[i].unshift(`pin${highestPinNumber}`)\n }\n }\n\n for (let i = 0; i < result.length; i++) {\n if (result[i].length === 0) {\n highestPinNumber += 1\n result[i].push(`pin${highestPinNumber}`)\n }\n }\n\n const totalLabelCounts: Record<string, number> = {}\n for (const inputLabels of uniqueInputPinLabels) {\n for (const label of inputLabels) {\n if (/^\\d+$/.test(label)) continue\n totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1\n }\n }\n\n const incrementalLabelCounts: Record<string, number> = {}\n for (let i = 0; i < uniqueInputPinLabels.length; i++) {\n for (const label of uniqueInputPinLabels[i]) {\n if (/^\\d+$/.test(label)) continue\n\n if (totalLabelCounts[label] === 1) {\n result[i].push(label)\n } else {\n incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1\n result[i].push(`${label}${incrementalLabelCounts[label]}`)\n }\n }\n }\n\n return result\n}\n","/**\n * Normalizes symbol names that could break the converter\n * Converts \"+\" to \"_POS\" and \"-\" to \"_NEG\"\n */\nexport const normalizeSymbolName = (name: string): string => {\n const trimmedName = name.trim()\n if (trimmedName === \"+\") return \"_POS\"\n if (trimmedName === \"-\") return \"_NEG\"\n return trimmedName\n}\n","export const DEFAULT_PCB_THICKNESS_MM = 1.6\n","import {\n findBoundsAndCenter,\n transformPCBElements,\n} from \"@tscircuit/circuit-json-util\"\nimport { mm } from \"@tscircuit/mm\"\nimport type {\n AnyCircuitElement,\n PcbComponentInput,\n PcbSmtPad,\n PcbViaInput,\n} from \"circuit-json\"\nimport {\n any_source_component,\n pcb_courtyard_outline,\n pcb_hole,\n pcb_plated_hole,\n pcb_silkscreen_path,\n pcb_smtpad,\n pcb_via,\n} from \"circuit-json\"\nimport * as Soup from \"circuit-json\"\nimport { applyToPoint, compose, scale, translate } from \"transformation-matrix\"\nimport type { z } from \"zod\"\nimport { generateArcFromSweep, generateArcPathWithMid } from \"./math/arc-utils\"\nimport type { BetterEasyEdaJson } from \"./schemas/easy-eda-json-schema\"\nimport type {\n ArcSchema,\n HoleSchema,\n PadSchema,\n SVGNodeSchema,\n SolidRegionSchema,\n TrackSchema,\n ViaSchema,\n} from \"./schemas/package-detail-shape-schema\"\nimport { mil10ToMm } from \"./utils/easyeda-unit-to-mm\"\nimport { normalizePinLabels } from \"./utils/normalize-pin-labels\"\nimport { normalizeSymbolName } from \"./utils/normalize-symbol-name\"\nimport { DEFAULT_PCB_THICKNESS_MM } from \"./constants\"\n\nconst EASYEDA_STEP_MODEL_URL =\n \"https://modules.easyeda.com/qAxj6KHrDKw4blvCG8QJPs7Y\"\nconst EASYEDA_OBJ_MODEL_URL = \"https://modules.easyeda.com/3dmodel\"\nconst TSCIRCUIT_MODEL_CDN_URL = \"https://modelcdn.tscircuit.com/easyeda_models\"\n\nconst mil2mm = (mil: number | string) => {\n if (typeof mil === \"number\") return mm(`${mil}mil`)\n if (mil.match(/^\\d+$/)) return mm(`${mil}mil`)\n return mm(mil)\n}\n/**\n * Some components, like paths and \"HOLE\", seem to use mil*10 as\n * their unlabeled unit\n */\nconst milx10 = (mil10: number | string) => {\n if (typeof mil10 === \"number\") return mil2mm(mil10) * 10\n if (mil10.match(/^\\d+$/)) return mil2mm(mil10) * 10\n // If it has a unit, return the specified unit ignoring the multiplier\n return mil2mm(mil10)\n}\n\nconst parseCadOffsetsFromSvgNode = (\n svgNode?: z.infer<typeof SVGNodeSchema>,\n) => {\n const attrs = svgNode?.svgData?.attrs ?? {}\n const [cx, cy] = String(attrs.c_origin ?? \"0,0\")\n .split(\",\")\n .map((s) => Number(s.trim()))\n\n // z: bare numbers are mils; strings with units go through mm()\n const zStr = attrs.z ?? 0\n const z_mm =\n typeof zStr === \"string\" && /[a-z]/i.test(zStr)\n ? mm(zStr) // already has units\n : mm(`${Number(zStr) || 0}mil`) // bare number => mils\n\n return {\n position: {\n x: mil10ToMm(Number.isNaN(cx) ? 0 : cx),\n y: mil10ToMm(Number.isNaN(cy) ? 0 : cy),\n z: z_mm,\n },\n rotation: (() => {\n const [rx, ry, rz] = (attrs.c_rotation ?? \"0,0,0\").split(\",\").map(Number)\n return { x: rx || 0, y: ry || 0, z: rz || 0 }\n })(),\n }\n}\n\n/** Try mil and mil×10; clamp to a plausible component thickness */\nconst readModelHeightMm = (raw: unknown) => {\n const fallback = 3.5 // typical SMT component height (USB-C, QFN, etc.)\n if (raw == null) return fallback\n const n = Number(raw)\n if (!Number.isFinite(n)) return fallback\n\n const mmFromMil10 = mil10ToMm(n) // many EasyEDA unlabeled values\n const mmFromMil = mm(`${n}mil`) // sometimes plain mil\n\n // Use the larger of the two guesses, but clamp to a plausible thickness\n const upper = 12 // max reasonable package thickness (mm) - increased for connectors\n const lower = 0.1\n let chosen = Math.max(mmFromMil10, mmFromMil)\n if (chosen > upper || chosen < lower) chosen = fallback\n\n return chosen\n}\n\nconst handleSilkscreenPath = (\n track: z.infer<typeof TrackSchema>,\n index: number,\n) => {\n return pcb_silkscreen_path.parse({\n type: \"pcb_silkscreen_path\",\n pcb_silkscreen_path_id: `pcb_silkscreen_path_${index + 1}`,\n pcb_component_id: \"pcb_component_1\",\n layer: \"top\", // Assuming all silkscreen is on top layer\n route: track.points.map((point) => ({\n x: milx10(point.x),\n y: milx10(point.y),\n })),\n stroke_width: mil10ToMm(track.width),\n })\n}\n\nconst isCourtyardLayer = (layer?: number) =>\n layer === 13 || layer === 14 || layer === 15\n\nconst getSideFromLayer = (layer?: number): \"top\" | \"bottom\" => {\n if (layer === 4 || layer === 14) return \"bottom\"\n return \"top\"\n}\n\nconst handleSilkscreenArc = (arc: z.infer<typeof ArcSchema>, index: number) => {\n const arcPath = generateArcFromSweep(\n arc.start.x,\n arc.start.y,\n arc.end.x,\n arc.end.y,\n arc.radiusX,\n arc.largeArc,\n arc.sweepDirection === \"CW\",\n )\n\n return pcb_silkscreen_path.parse({\n type: \"pcb_silkscreen_path\",\n pcb_silkscreen_path_id: `pcb_silkscreen_arc_${index + 1}`,\n pcb_component_id: \"pcb_component_1\",\n layer: \"top\", // Assuming all silkscreen is on top layer\n route: arcPath.map((p) => ({\n x: milx10(p.x),\n y: milx10(p.y),\n })),\n stroke_width: mil10ToMm(arc.width),\n } as Soup.PcbSilkscreenPathInput)\n}\n\nconst handleHole = (hole: z.infer<typeof HoleSchema>, index: number) => {\n return pcb_hole.parse({\n type: \"pcb_hole\",\n x: milx10(hole.center.x),\n y: milx10(hole.center.y),\n hole_diameter: milx10(hole.radius) * 2,\n hole_shape: \"circle\",\n pcb_hole_id: `pcb_hole_${index + 1}`,\n } as Soup.PcbHole)\n}\n\nconst handleHoleCutout = (hole: z.infer<typeof HoleSchema>, index: number) => {\n return Soup.pcb_cutout.parse({\n type: \"pcb_cutout\",\n pcb_cutout_id: `pcb_cutout_from_hole_${index + 1}`,\n shape: \"circle\",\n center: { x: milx10(hole.center.x), y: milx10(hole.center.y) },\n radius: milx10(hole.radius),\n } as Soup.PcbCutoutCircleInput)\n}\n\nconst handleVia = (via: z.infer<typeof ViaSchema>, index: number) => {\n return pcb_via.parse({\n type: \"pcb_via\",\n pcb_via_id: `pcb_via_${index + 1}`,\n x: milx10(via.center.x),\n y: milx10(via.center.y),\n outer_diameter: milx10(via.outerDiameter),\n hole_diameter: milx10(via.holeDiameter),\n layers: [\"top\", \"bottom\"],\n } as PcbViaInput)\n}\n\nconst handleCutout = (\n solidRegion: z.infer<typeof SolidRegionSchema>,\n index: number,\n) => {\n return Soup.pcb_cutout.parse({\n type: \"pcb_cutout\",\n pcb_cutout_id: `pcb_cutout_${index + 1}`,\n shape: \"polygon\",\n points: solidRegion.points.map((p) => ({\n x: milx10(p.x),\n y: milx10(p.y),\n })),\n } as Soup.PcbCutoutPolygonInput)\n}\n\ninterface Options {\n useModelCdn?: boolean\n shouldRecenter?: boolean\n cadPositionXMm?: number\n cadPositionYMm?: number\n cadPositionZMm?: number\n showDesignator?: boolean\n}\n\nconst getCadPositionZMmFromMetadata = (easyEdaJson: BetterEasyEdaJson) => {\n const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(\n (shape) => shape.type === \"SVGNODE\" && shape.svgData.attrs?.uuid,\n )\n if (!svgNode || svgNode.type !== \"SVGNODE\") return undefined\n\n const svgNodeZ = Number(svgNode.svgData.attrs?.z ?? 0)\n if (!Number.isFinite(svgNodeZ)) return undefined\n\n const bounds = easyEdaJson._objMetadata?.bounds\n if (!bounds) return undefined\n\n const minZ = Math.abs(bounds.min.z) < 1e-6 ? 0 : bounds.min.z\n return minZ - mil10ToMm(svgNodeZ)\n}\n\nexport const convertEasyEdaJsonToCircuitJson = (\n easyEdaJson: BetterEasyEdaJson,\n {\n useModelCdn,\n shouldRecenter = true,\n cadPositionXMm,\n cadPositionYMm,\n cadPositionZMm,\n showDesignator = false,\n }: Options = {},\n): AnyCircuitElement[] => {\n const resolvedCadPositionZMm =\n cadPositionZMm ?? getCadPositionZMmFromMetadata(easyEdaJson)\n const circuitElements: AnyCircuitElement[] = []\n\n // Add source component\n const source_component = any_source_component.parse({\n type: \"source_component\",\n source_component_id: \"source_component_1\",\n name: \"U1\",\n ftype: \"simple_chip\",\n })\n\n const pcb_component = Soup.pcb_component.parse({\n type: \"pcb_component\",\n pcb_component_id: \"pcb_component_1\",\n source_component_id: \"source_component_1\",\n name: \"U1\",\n ftype: \"simple_chip\",\n width: 0, // we update this at the end\n height: 0, // we update this at the end\n rotation: 0,\n center: { x: 0, y: 0 },\n layer: \"top\",\n } as PcbComponentInput)\n\n circuitElements.push(source_component, pcb_component)\n\n const pads = easyEdaJson.packageDetail.dataStr.shape.filter(\n (shape): shape is z.infer<typeof PadSchema> => shape.type === \"PAD\",\n )\n const pins = easyEdaJson.dataStr.shape.filter((shape) => shape.type === \"PIN\")\n\n // Prepare pin labels for normalization\n const pinLabelSets = pads.map((pad) => {\n const labels = []\n if (pad.number) labels.push(pad.number.toString())\n\n const pin = pins.find((p) => p.pinNumber === pad.number)\n if (pin) labels.push(normalizeSymbolName(pin.label))\n\n return labels\n })\n\n const normalizedPinLabels = normalizePinLabels(pinLabelSets)\n\n // Add source ports and pcb_smtpads\n pads.forEach((pad, index) => {\n const portHints = normalizedPinLabels[index]\n const pinNumber = Number.parseInt(\n portHints.find((hint) => hint.match(/pin\\d+/))!.replace(\"pin\", \"\"),\n )\n\n // Add source port\n circuitElements.push({\n type: \"source_port\",\n source_port_id: `source_port_${index + 1}`,\n source_component_id: \"source_component_1\",\n name: `pin${pinNumber}`,\n pin_number: pinNumber,\n port_hints: portHints.filter((hint) => hint !== `pin${pinNumber}`),\n })\n\n if (pad.holeRadius !== undefined && mil2mm(pad.holeRadius) !== 0) {\n // Add pcb_plated_hole\n const platedHoleId =\n pad.shape === \"RECT\" && pad.rotation !== undefined\n ? `pcb_plated_hole_${index + 1}_rot${pad.rotation}`\n : `pcb_plated_hole_${index + 1}`\n\n const commonPlatedHoleProps = {\n type: \"pcb_plated_hole\",\n pcb_plated_hole_id: platedHoleId,\n x: mil2mm(pad.center.x),\n y: mil2mm(pad.center.y),\n layers: [\"top\"],\n port_hints: [`pin${pinNumber}`],\n pcb_component_id: \"pcb_component_1\",\n pcb_port_id: `pcb_port_${index + 1}`,\n }\n let additionalPlatedHoleProps: any\n\n if (pad.shape === \"OVAL\") {\n // A JLCPCB Oval is actually a Pill, and it's a bit tricky to compute\n // the correct dimensions, but we can use the following process:\n // 1. Find the smallest outer dimensions\n // 2. Use the holeRadius to determine the distanceFromOuterPlatingToHole\n // 3. Calculate the largest \"inner dimension\" (which is either the\n // holeWidth or holeHeight) by subtracting the distanceFromOuterPlatingToHole * 2\n // from the largest outer dimensions\n\n const largestOuterDimensionName: \"width\" | \"height\" =\n mil2mm(pad.width) > mil2mm(pad.height) ? \"width\" : \"height\"\n\n const smallestOuterDimension = Math.min(\n mil2mm(pad.width),\n mil2mm(pad.height),\n )\n const largestOuterDimension = Math.max(\n mil2mm(pad.width),\n mil2mm(pad.height),\n )\n\n const distanceFromOuterPlatingToHole =\n smallestOuterDimension / 2 - mil2mm(pad.holeRadius)\n\n const largestInnerDimension =\n largestOuterDimension - distanceFromOuterPlatingToHole * 2\n const smallestInnerDimension = mil2mm(pad.holeRadius) * 2\n\n const innerWidth =\n largestOuterDimensionName === \"width\"\n ? largestInnerDimension\n : smallestInnerDimension\n const innerHeight =\n largestOuterDimensionName === \"height\"\n ? largestInnerDimension\n : smallestInnerDimension\n\n additionalPlatedHoleProps = {\n shape: \"pill_hole_with_rect_pad\",\n hole_shape: \"pill\",\n pad_shape: \"rect\",\n hole_width: innerWidth,\n hole_height: innerHeight,\n rect_pad_width: mil2mm(pad.width),\n rect_pad_height: mil2mm(pad.height),\n hole_offset_x: 0,\n hole_offset_y: 0,\n }\n } else if (pad.shape === \"RECT\") {\n const padWidth = mil2mm(pad.width)\n const padHeight = mil2mm(pad.height)\n const holeRadius = mil2mm(pad.holeRadius)\n const holeDiameter = holeRadius * 2 // Use normal diameter\n\n // Check if the pad is significantly rectangular (not square)\n const aspectRatio =\n Math.max(padWidth, padHeight) / Math.min(padWidth, padHeight)\n const isSignificantlyRectangular = aspectRatio > 1.5 // Only use pill holes for aspect ratios > 1.5\n\n if (isSignificantlyRectangular) {\n // Simple approach: create slim pill holes with consistent proportions\n // Width = original hole diameter, Height = 2.6x width for good pill shape\n const baseWidth = holeDiameter\n const pillHeight = baseWidth * 2.6 // 2.6:1 aspect ratio for elegant pills\n\n const holeWidth = padWidth > padHeight ? pillHeight : baseWidth\n const holeHeight = padHeight > padWidth ? pillHeight : baseWidth\n\n additionalPlatedHoleProps = {\n shape: \"rotated_pill_hole_with_rect_pad\",\n hole_shape: \"rotated_pill\",\n pad_shape: \"rect\",\n hole_width: holeWidth,\n hole_height: holeHeight,\n hole_ccw_rotation: pad.rotation || 0,\n rect_ccw_rotation: pad.rotation || 0,\n rect_pad_width: padWidth,\n rect_pad_height: padHeight,\n }\n } else {\n // For square or nearly square pads, use circular holes\n additionalPlatedHoleProps = {\n shape: \"circle\",\n hole_diameter: holeDiameter,\n outer_diameter: Math.max(padWidth, padHeight),\n radius: holeDiameter / 2,\n }\n }\n } else {\n additionalPlatedHoleProps = {\n shape: \"circle\",\n hole_diameter: mil2mm(pad.holeRadius) * 2,\n outer_diameter: mil2mm(pad.width),\n radius: mil2mm(pad.holeRadius),\n }\n }\n\n circuitElements.push(\n pcb_plated_hole.parse({\n ...commonPlatedHoleProps,\n ...additionalPlatedHoleProps,\n }),\n )\n } else {\n // Add pcb_smtpad\n let soupShape: PcbSmtPad[\"shape\"] | undefined\n if (pad.shape === \"RECT\") {\n soupShape = \"rect\"\n } else if (pad.shape === \"ELLIPSE\") {\n // This is just a bug\n soupShape = \"rect\"\n } else if (pad.shape === \"OVAL\") {\n // OVAL is often a rect, especially when holeRadius is 0\n soupShape = \"rect\"\n } else if (pad.shape === \"POLYGON\") {\n soupShape = \"polygon\"\n }\n if (!soupShape) {\n throw new Error(`unknown pad.shape: \"${pad.shape}\"`)\n }\n\n const rectSize = { width: mil2mm(pad.width), height: mil2mm(pad.height) }\n if (pad.rotation === 90 || pad.rotation === 270) {\n // Swap width and height\n rectSize.width = mil2mm(pad.height)\n rectSize.height = mil2mm(pad.width)\n }\n\n const parsedPcbSmtpad = pcb_smtpad.parse({\n type: \"pcb_smtpad\",\n pcb_smtpad_id: `pcb_smtpad_${index + 1}`,\n shape: soupShape,\n ...(soupShape !== \"polygon\" && {\n x: mil2mm(pad.center.x),\n y: mil2mm(pad.center.y),\n }),\n ...(soupShape === \"rect\"\n ? rectSize\n : soupShape === \"polygon\" && pad.points\n ? {\n points: pad.points.map((p) => ({\n x: milx10(p.x),\n y: milx10(p.y),\n })),\n }\n : { radius: Math.min(mil2mm(pad.width), mil2mm(pad.height)) / 2 }),\n layer: \"top\",\n port_hints: [`pin${pinNumber}`],\n pcb_component_id: \"pcb_component_1\",\n pcb_port_id: `pcb_port_${index + 1}`,\n } as PcbSmtPad)\n circuitElements.push(parsedPcbSmtpad)\n }\n })\n\n // Add holes\n easyEdaJson.packageDetail.dataStr.shape\n .filter(\n (shape): shape is z.infer<typeof HoleSchema> => shape.type === \"HOLE\",\n )\n .forEach((h, index) => {\n circuitElements.push(handleHole(h, index))\n circuitElements.push(handleHoleCutout(h, index))\n })\n\n // Add vias\n easyEdaJson.packageDetail.dataStr.shape\n .filter((shape): shape is z.infer<typeof ViaSchema> => shape.type === \"VIA\")\n .forEach((v, index) => {\n circuitElements.push(handleVia(v, index))\n })\n\n // Add pcb cutouts from solid regions marked as cutout\n easyEdaJson.packageDetail.dataStr.shape\n .filter(\n (shape): shape is z.infer<typeof SolidRegionSchema> =>\n shape.type === \"SOLIDREGION\" && shape.fillStyle === \"cutout\",\n )\n .forEach((sr, index) => {\n circuitElements.push(handleCutout(sr, index))\n })\n\n // Add silkscreen paths, arcs and text\n let hasFoundDesignator = false\n easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {\n if (shape.type === \"TRACK\") {\n if (!isCourtyardLayer(shape.layer)) {\n circuitElements.push(handleSilkscreenPath(shape, index))\n }\n } else if (shape.type === \"ARC\") {\n if (!isCourtyardLayer(shape.layer)) {\n circuitElements.push(handleSilkscreenArc(shape, index))\n }\n } else if (shape.type === \"TEXT\") {\n if (isCourtyardLayer(shape.layer)) return\n\n let text = shape.text\n const designatorPrefix = easyEdaJson.dataStr.head.c_para.pre || \"U\"\n const normalizedPrefix = designatorPrefix.replace(/\\?/g, \"\")\n const trimmedText = text.trim()\n const isDesignator =\n trimmedText === designatorPrefix ||\n trimmedText === `${normalizedPrefix}?` ||\n trimmedText === normalizedPrefix\n\n if (isDesignator) {\n if (!showDesignator) return\n text = \"{NAME}\"\n hasFoundDesignator = true\n }\n\n circuitElements.push(\n Soup.pcb_silkscreen_text.parse({\n type: \"pcb_silkscreen_text\",\n pcb_silkscreen_text_id: `pcb_silkscreen_text_${index + 1}`,\n pcb_component_id: \"pcb_component_1\",\n text,\n anchor_position: {\n x: mil2mm(shape.x),\n y: mil2mm(shape.y),\n },\n anchor_alignment: (\n {\n L: \"bottom_left\",\n C: \"center\",\n R: \"bottom_right\",\n } as const\n )[shape.textAnchor ?? \"L\"],\n font_size: shape.size_mm || 1.0,\n layer: \"top\",\n } as Soup.PcbSilkscreenTextInput),\n )\n }\n })\n\n // Add a fallback designator if none was found in the shapes\n if (!hasFoundDesignator && showDesignator) {\n const bbox = easyEdaJson.packageDetail.dataStr.BBox\n circuitElements.push(\n Soup.pcb_silkscreen_text.parse({\n type: \"pcb_silkscreen_text\",\n pcb_silkscreen_text_id: `pcb_silkscreen_text_designator_fallback`,\n pcb_component_id: \"pcb_component_1\",\n text: \"{NAME}\",\n anchor_position: {\n x: milx10(bbox.x + bbox.width / 2),\n y: milx10(bbox.y) - 1.0, // 1mm above top edge\n },\n anchor_alignment: \"center\",\n font_size: 1.0,\n layer: \"top\",\n } as Soup.PcbSilkscreenTextInput),\n )\n }\n\n // Only add designator if found in EasyEDA\n\n // Calculate pcb_component bounds from all PCB elements\n const pcbElements = circuitElements.filter(\n (e) =>\n e.type === \"pcb_smtpad\" ||\n e.type === \"pcb_plated_hole\" ||\n e.type === \"pcb_hole\" ||\n e.type === \"pcb_via\" ||\n e.type === \"pcb_courtyard_outline\" ||\n e.type === \"pcb_silkscreen_path\" ||\n e.type === \"pcb_silkscreen_text\",\n )\n\n if (pcbElements.length > 0) {\n const bounds = findBoundsAndCenter(pcbElements)\n pcb_component.width = bounds.width\n pcb_component.height = bounds.height\n }\n\n // Add 3d component\n const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(\n (a): a is z.infer<typeof SVGNodeSchema> =>\n Boolean(a.type === \"SVGNODE\" && a.svgData.attrs?.uuid),\n )\n const modelUuid = svgNode?.svgData?.attrs?.uuid\n\n const objFileUrl = modelUuid\n ? useModelCdn\n ? `${TSCIRCUIT_MODEL_CDN_URL}/assets/${easyEdaJson.lcsc.number}.obj?uuid=${modelUuid}`\n : `${EASYEDA_OBJ_MODEL_URL}/${modelUuid}`\n : undefined\n\n const stepFileUrl = modelUuid\n ? useModelCdn\n ? `${TSCIRCUIT_MODEL_CDN_URL}/assets/${easyEdaJson.lcsc.number}.step?uuid=${modelUuid}`\n : `${EASYEDA_STEP_MODEL_URL}/${modelUuid}`\n : undefined\n\n if (objFileUrl !== undefined || stepFileUrl !== undefined) {\n const { position, rotation } = parseCadOffsetsFromSvgNode(svgNode)\n\n circuitElements.push(\n Soup.cad_component.parse({\n type: \"cad_component\",\n cad_component_id: \"cad_component_1\",\n source_component_id: \"source_component_1\",\n pcb_component_id: \"pcb_component_1\",\n anchor_alignment: \"center_of_component_on_board_surface\",\n model_origin_alignment: \"center_of_component_on_board_surface\",\n model_origin_position: {\n x: cadPositionXMm ?? 0,\n y: cadPositionYMm ?? 0,\n z: resolvedCadPositionZMm ?? position.z,\n },\n position: { x: 0, y: 0, z: 0 },\n rotation,\n model_obj_url: objFileUrl,\n model_step_url: stepFileUrl,\n } as Soup.CadComponentInput),\n )\n }\n\n // Generate courtyard outline from packageDetail.dataStr.BBox when no explicit\n // courtyard TRACK (layers 13/14/15) exists. The BBox is EasyEDA's own bounding\n // box for the footprint in canvas coordinates (milx10 units). It is added before\n // recentering so it gets transformed automatically with all other elements.\n const hasExplicitCourtyard = circuitElements.some(\n (e) => e.type === \"pcb_courtyard_outline\",\n )\n if (!hasExplicitCourtyard) {\n const bbox = easyEdaJson.packageDetail.dataStr.BBox\n if (bbox) {\n const strokeWidth = 0.05\n const margin = 0.25\n const x1 = milx10(bbox.x) - margin\n const y1 = milx10(bbox.y) - margin\n const x2 = milx10(bbox.x + bbox.width) + margin\n const y2 = milx10(bbox.y + bbox.height) + margin\n circuitElements.push(\n pcb_courtyard_outline.parse({\n type: \"pcb_courtyard_outline\",\n pcb_courtyard_outline_id: `pcb_courtyard_outline_${easyEdaJson.lcsc.number}_1`,\n pcb_component_id: \"pcb_component_1\",\n layer: \"top\",\n outline: [\n { x: x1, y: y1 },\n { x: x2, y: y1 },\n { x: x2, y: y2 },\n { x: x1, y: y2 },\n { x: x1, y: y1 },\n ],\n stroke_width: strokeWidth,\n }),\n )\n }\n }\n\n if (shouldRecenter) {\n // exclude pcb_component (its center is wrong; we'll set it to 0,0)\n const elementsForBounds = circuitElements.filter(\n (e) => e.type !== \"pcb_component\" && e.type !== \"cad_component\",\n )\n\n const bounds = findBoundsAndCenter(elementsForBounds)\n\n if (Number.isFinite(bounds.center.x) && Number.isFinite(bounds.center.y)) {\n const matrix = compose(\n translate(-bounds.center.x, bounds.center.y),\n scale(1, -1),\n )\n\n // Transform all PCB elems except polygon SMT pads (no x,y) and the cad\n const elementsForTransform = circuitElements.filter(\n (e) =>\n !(e.type === \"pcb_smtpad\" && e.shape === \"polygon\") &&\n e.type !== \"cad_component\",\n )\n transformPCBElements(elementsForTransform, matrix)\n\n // Manually transform polygons/cutouts\n for (const e of circuitElements) {\n if (e.type === \"pcb_cutout\") {\n if (e.shape === \"polygon\") {\n e.points = e.points.map((p) => applyToPoint(matrix, p))\n } else if (e.shape === \"circle\" || e.shape === \"rect\") {\n e.center = applyToPoint(matrix, e.center)\n } else if (\"route\" in e) {\n const cutoutPath = e as unknown as {\n route: { x: number; y: number }[]\n }\n cutoutPath.route = cutoutPath.route.map((p) =>\n applyToPoint(matrix, p),\n )\n }\n } else if (e.type === \"pcb_smtpad\" && e.shape === \"polygon\") {\n e.points = e.points.map((p) => applyToPoint(matrix, p))\n }\n }\n\n const cad = circuitElements.find(\n (e): e is Soup.CadComponent => e.type === \"cad_component\",\n )\n\n if (cad) {\n if (!cad.rotation) cad.rotation = { x: 0, y: 0, z: 0 }\n if (!cad.model_origin_position) {\n cad.model_origin_position = { x: 0, y: 0, z: 0 }\n }\n\n const side = (pcb_component.layer ?? \"top\") as \"top\" | \"bottom\"\n const t = DEFAULT_PCB_THICKNESS_MM / 2\n const attrs = svgNode?.svgData?.attrs ?? {}\n const modelHeight = readModelHeightMm(attrs.c_height)\n\n // Ensure we have a size; Z holds the model's thickness in local space\n if (!cad.size) {\n cad.size = {\n x: pcb_component.width,\n y: pcb_component.height,\n z: modelHeight,\n }\n }\n\n // --- Axis convention: EasyEDA models are typically Y-up ---\n // Rotate to Z-up so thickness becomes vertical in our scene.\n const ROTATE_X_FOR_YUP = 90\n const originalZRotation = (cad.rotation.z ?? 0) % 360\n\n // Improved rotation handling with tolerance for floating-point precision\n // Handle different component orientations based on EasyEDA Z rotation\n if (\n Math.abs(originalZRotation - 0) < 1 ||\n Math.abs(originalZRotation - 360) < 1\n ) {\n // For ~0° Z rotation, don't apply X rotation - keep model as-is (Y-up)\n cad.rotation.x = ((cad.rotation.x ?? 0) + 0 + 360) % 360 // no X rotation\n } else if (Math.abs(originalZRotation - 180) < 1) {\n // For ~180° Z rotation, don't apply standard X rotation - let it lie flat\n cad.rotation.x = ((cad.rotation.x ?? 0) + 0 + 360) % 360 // no X rotation\n } else if (Math.abs(originalZRotation - 90) < 1) {\n // For ~90° Z rotation, keep it flat (no X rotation)\n cad.rotation.x = ((cad.rotation.x ?? 0) + 0 + 360) % 360\n } else if (Math.abs(originalZRotation - 270) < 1) {\n // Keep EasyEDA's raw 270° orientation; adding corrective X/Y rotations\n // makes parts like C9900017879 stand on their side.\n cad.rotation.x = ((cad.rotation.x ?? 0) + 0 + 360) % 360\n cad.rotation.y = ((cad.rotation.y ?? 0) + 0 + 360) % 360\n } else {\n // Fallback for unusual angles: apply standard Y-up to Z-up conversion\n // and log for potential future refinement\n console.warn(\n `[3D] Unusual rotation angle: ${originalZRotation}° for component ${easyEdaJson.lcsc.number}`,\n )\n cad.rotation.x =\n ((cad.rotation.x ?? 0) + ROTATE_X_FOR_YUP + 360) % 360\n }\n\n // Bottom-side parts: flip across the board plane\n if (side !== \"top\") {\n cad.rotation.x = ((cad.rotation.x ?? 0) + 180) % 360\n }\n\n // For 180° rotated components (Y-up models), the z-offset indicates pin extension below body\n const USE_Z_OFFSET_FOR_180 = Math.abs(originalZRotation - 180) < 1\n const zOffRaw = cad.model_origin_position.z ?? cad.position.z ?? 0\n const zOff = USE_Z_OFFSET_FOR_180 ? -zOffRaw : 0\n\n // ---- Determine the vertical extent based on model orientation ----\n const rx = ((cad.rotation.x % 360) + 360) % 360\n\n // EasyEDA models are Y-up. Components with 0° or 180° Z-rotation don't get X-rotation applied,\n // so they remain Y-up. For Y-up models, the vertical extent is along the Y axis.\n let thicknessAlongWorldZ: number\n const is180RotatedYUp =\n (Math.abs(originalZRotation - 180) < 1 ||\n Math.abs(originalZRotation - 0) < 1 ||\n Math.abs(originalZRotation - 360) < 1) &&\n Math.abs(rx) < 1\n\n if (is180RotatedYUp) {\n // 180° Z-rotation, no X-rotation applied → model is still Y-up\n // For Y-up models, the vertical extent is along Y axis (size.y)\n thicknessAlongWorldZ = cad.size.y\n } else if (rx % 180 === 90) {\n // X-rotation of 90/270 → use local Y\n thicknessAlongWorldZ = cad.size.y\n } else {\n // Standard case → model rotated to Z-up, use Z\n thicknessAlongWorldZ = cad.size.z\n }\n\n if (Number.isFinite(resolvedCadPositionZMm)) {\n cad.model_origin_position.z =\n side === \"top\" ? resolvedCadPositionZMm! : -resolvedCadPositionZMm!\n } else {\n let centerZ: number\n if (is180RotatedYUp) {\n // For Y-up models, subtract half the thickness to lower the component to the board\n centerZ =\n side === \"top\"\n ? t - thicknessAlongWorldZ / 2\n : -t + thicknessAlongWorldZ / 2\n } else {\n // For other orientations, use standard positioning with z-offset\n centerZ =\n side === \"top\"\n ? t + zOff + thicknessAlongWorldZ / 2\n : -t - zOff - thicknessAlongWorldZ / 2\n }\n\n cad.model_origin_position.z = centerZ\n }\n }\n }\n\n // finalize pcb center after recentering\n pcb_component.center = { x: 0, y: 0 }\n }\n\n return circuitElements\n}\n","type Params = {\n easyedaPartNumber: string\n easyedaModelUuid: string\n}\n\nexport const getModelObjCdnUrl = ({\n easyedaModelUuid,\n easyedaPartNumber,\n}: Params): string => {\n return `https://modelcdn.tscircuit.com/easyeda_models/assets/${easyedaPartNumber}.obj?uuid=${easyedaModelUuid}`\n}\n\nexport const getModelStepCdnUrl = ({\n easyedaModelUuid,\n easyedaPartNumber,\n}: Params): string => {\n return `https://modelcdn.tscircuit.com/easyeda_models/assets/${easyedaPartNumber}.step?uuid=${easyedaModelUuid}`\n}\n\nexport const getModelCdnUrl = getModelObjCdnUrl\n","import type { RawEasyEdaJson } from \"../schemas/easy-eda-json-schema\"\nimport { getModelCdnUrl } from \"./get-model-cdn-url\"\n\ntype ModelBounds = {\n min: { x: number; y: number; z: number }\n max: { x: number; y: number; z: number }\n}\n\nconst getModelUuidFromRawPackageDetail = (result: RawEasyEdaJson) => {\n const shapes = result.packageDetail?.dataStr?.shape\n if (!Array.isArray(shapes)) return null\n\n for (const shape of shapes) {\n if (typeof shape !== \"string\" || !shape.startsWith(\"SVGNODE~\")) continue\n\n const svgNodeJson = shape.slice(\"SVGNODE~\".length)\n try {\n const svgNode = JSON.parse(svgNodeJson)\n const modelUuid = svgNode?.attrs?.uuid\n if (typeof modelUuid === \"string\" && modelUuid.length > 0) {\n return modelUuid\n }\n } catch {}\n }\n\n return null\n}\n\nconst parseObjBounds = (objText: string): ModelBounds | null => {\n let minX = Number.POSITIVE_INFINITY\n let minY = Number.POSITIVE_INFINITY\n let minZ = Number.POSITIVE_INFINITY\n let maxX = Number.NEGATIVE_INFINITY\n let maxY = Number.NEGATIVE_INFINITY\n let maxZ = Number.NEGATIVE_INFINITY\n let vertexCount = 0\n\n for (const line of objText.split(/\\r?\\n/)) {\n const trimmed = line.trim()\n if (!trimmed.startsWith(\"v \")) continue\n\n const [, xStr, yStr, zStr] = trimmed.split(/\\s+/, 4)\n const x = Number(xStr)\n const y = Number(yStr)\n const z = Number(zStr)\n\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) {\n continue\n }\n\n vertexCount += 1\n minX = Math.min(minX, x)\n minY = Math.min(minY, y)\n minZ = Math.min(minZ, z)\n maxX = Math.max(maxX, x)\n maxY = Math.max(maxY, y)\n maxZ = Math.max(maxZ, z)\n }\n\n if (vertexCount === 0) return null\n\n return {\n min: { x: minX, y: minY, z: minZ },\n max: { x: maxX, y: maxY, z: maxZ },\n }\n}\n\nexport async function fetchEasyEDAComponent(\n jlcpcbPartNumber: string,\n {\n fetch = globalThis.fetch,\n includeModelMetadata = true,\n }: {\n fetch?: typeof globalThis.fetch\n includeModelMetadata?: boolean\n } = {},\n): Promise<RawEasyEdaJson> {\n const searchUrl = \"https://easyeda.com/api/components/search\"\n const componentUrl = (uuid: string) =>\n `https://easyeda.com/api/components/${uuid}?version=6.4.7&uuid=${uuid}&datastrid=`\n\n const searchHeaders = {\n authority: \"easyeda.com\",\n pragma: \"no-cache\",\n \"cache-control\": \"no-cache\",\n accept: \"application/json, text/javascript, */*; q=0.01\",\n \"x-requested-with\": \"XMLHttpRequest\",\n \"user-agent\":\n \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36\",\n \"content-type\": \"application/x-www-form-urlencoded; charset=UTF-8\",\n origin: \"https://easyeda.com\",\n \"sec-fetch-site\": \"same-origin\",\n \"sec-fetch-mode\": \"cors\",\n \"sec-fetch-dest\": \"empty\",\n referer: \"https://easyeda.com/editor\",\n \"accept-language\": \"cs,en;q=0.9,sk;q=0.8,en-GB;q=0.7\",\n cookie: \"<PUT your cookies here>\",\n }\n\n const searchData = `type=3&doctype%5B%5D=2&uid=0819f05c4eef4c71ace90d822a990e87&returnListStyle=classifyarr&wd=${jlcpcbPartNumber}&version=6.4.7`\n\n // Perform the search request\n const searchResponse = await fetch(searchUrl, {\n method: \"POST\",\n headers: searchHeaders,\n body: searchData,\n })\n\n if (!searchResponse.ok) {\n throw new Error(\"Failed to search for the component\")\n }\n\n const searchResult = await searchResponse.json()\n if (!searchResult.success || !searchResult.result.lists.lcsc.length) {\n throw new Error(\"Component not found\")\n }\n\n const bestMatchComponent =\n searchResult.result.lists.lcsc.find(\n (component: any) =>\n component.dataStr.head.c_para[\"Supplier Part\"] === jlcpcbPartNumber,\n ) ?? searchResult.result.lists.lcsc[0]\n\n const componentUUID = bestMatchComponent.uuid\n\n // Perform the component fetch request\n const componentResponse = await fetch(componentUrl(componentUUID), {\n method: \"GET\",\n headers: {\n ...searchHeaders,\n referer: `https://easyeda.com/editor?uuid=${componentUUID}`,\n },\n })\n\n if (!componentResponse.ok) {\n throw new Error(\"Failed to fetch the component details\")\n }\n\n const componentResult = await componentResponse.json()\n const result = componentResult.result as RawEasyEdaJson\n\n if (includeModelMetadata) {\n const modelUuid = getModelUuidFromRawPackageDetail(result)\n const partNumber = result.lcsc?.number\n\n if (modelUuid && partNumber) {\n try {\n const objUrl = getModelCdnUrl({\n easyedaModelUuid: modelUuid,\n easyedaPartNumber: partNumber,\n })\n const objResponse = await fetch(objUrl)\n if (objResponse.ok) {\n const objText = await objResponse.text()\n const bounds = parseObjBounds(objText)\n if (bounds) {\n ;(\n result as RawEasyEdaJson & {\n _objMetadata?: { bounds: ModelBounds }\n }\n )._objMetadata = { bounds }\n }\n }\n } catch (error) {\n console.error(\n `Error fetching model metadata for ${jlcpcbPartNumber}:`,\n error,\n )\n }\n }\n }\n\n return result\n}\n\n// Usage example\n// fetchEasyEDAComponent(\"C558438\")\n// .then((component) => console.log(component))\n// .catch((error) => console.error(error))\n","import { z } from \"zod\"\nimport {\n PackageDetailShapeSchema,\n ShapeItemSchema,\n} from \"./package-detail-shape-schema\"\nimport { SingleLetterShapeSchema } from \"./single-letter-shape-schema\"\n\nexport const maybeNumber = z\n .any()\n .transform((k) => (k === \"nan\" || Number.isNaN(k) ? null : k))\n .pipe(z.number().nullable().optional())\n\nexport const SzlcscSchema = z.object({\n id: z.number(),\n number: z.string(),\n step: z.number().optional(),\n min: z.number().optional(),\n price: z.number().optional(),\n stock: z.number().optional(),\n url: z.string().url().optional(),\n image: z.string().optional().optional(),\n})\n\nexport const LcscSchema = z.object({\n id: z.number(),\n number: z.string(),\n step: z.number().optional(),\n min: z.number().optional(),\n price: z.number().optional(),\n stock: z.number().optional(),\n url: z.string().url().optional(),\n})\n\nexport const OwnerSchema = z.object({\n uuid: z.string(),\n username: z.string(),\n nickname: z.string(),\n avatar: z.string(),\n})\n\nexport const HeadSchema = z.object({\n docType: z.preprocess((val) => (val == null ? val : String(val)), z.string()),\n editorVersion: z.string(),\n c_para: z.record(z.string(), z.string().nullable()),\n x: z.number(),\n y: z.number(),\n puuid: z.string().optional(),\n uuid: z.string(),\n utime: z.preprocess((val) => {\n if (val === \"\") return 0\n if (typeof val === \"string\") return Number(val)\n return val\n }, z.number()),\n importFlag: z.number().optional(),\n c_spiceCmd: z.any().optional(),\n hasIdFlag: z.boolean(),\n})\n\nexport const BBoxSchema = z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n})\n\nexport const LayerItemSchema = z.object({\n name: z.string(),\n color: z.string(),\n visible: z.boolean(),\n active: z.boolean(),\n config: z.boolean(),\n transparency: z.boolean(),\n})\n\nexport const ObjectItemSchema = z.object({\n name: z.string(),\n visible: z.boolean(),\n locked: z.boolean(),\n})\n\nexport const DataStrSchema = z.object({\n head: HeadSchema,\n canvas: z.string(),\n shape: z.array(SingleLetterShapeSchema),\n BBox: BBoxSchema,\n colors: z.union([z.array(z.string()), z.record(z.string())]),\n})\n\nexport const PackageDetailDataStrSchema = z.object({\n head: HeadSchema,\n canvas: z.string(),\n shape: z\n .array(z.string())\n .transform((shapes) =>\n shapes.map((shape) => {\n const [type, ...data] = shape.split(\"~\")\n return ShapeItemSchema.parse({ type, data: data.join(\"~\") })\n }),\n )\n .pipe(z.array(PackageDetailShapeSchema)),\n layers: z.array(z.string()).transform((layers) =>\n layers.map((layer) => {\n const [name, color, visible, active, config, transparency] =\n layer.split(\"~\")\n return LayerItemSchema.parse({\n name,\n color,\n visible: visible === \"true\",\n active: active === \"true\",\n config: config === \"true\",\n transparency: transparency === \"true\",\n })\n }),\n ),\n objects: z.array(z.string()).transform((objects) =>\n objects.map((obj) => {\n const [name, visible, locked] = obj.split(\"~\")\n return ObjectItemSchema.parse({\n name,\n visible: visible === \"true\",\n locked: locked === \"true\",\n })\n }),\n ),\n BBox: BBoxSchema,\n netColors: z.array(z.unknown()).optional(),\n})\n\nexport const PackageDetailSchema = z.object({\n uuid: z.string(),\n title: z.string(),\n docType: z.number(),\n updateTime: z.number(),\n owner: OwnerSchema,\n datastrid: z.string(),\n writable: z.boolean(),\n dataStr: PackageDetailDataStrSchema,\n})\n\nexport const ModelBoundsSchema = z.object({\n min: z.object({\n x: z.number(),\n y: z.number(),\n z: z.number(),\n }),\n max: z.object({\n x: z.number(),\n y: z.number(),\n z: z.number(),\n }),\n})\n\nexport const EasyEdaJsonSchema = z.object({\n uuid: z.string(),\n title: z.string(),\n description: z.string(),\n docType: z.number(),\n type: z.number(),\n szlcsc: SzlcscSchema,\n lcsc: LcscSchema,\n owner: OwnerSchema,\n tags: z.array(z.string()),\n updateTime: z.number(),\n updated_at: z.string(),\n dataStr: DataStrSchema,\n verify: z.boolean(),\n SMT: z.boolean().optional(),\n datastrid: z.string(),\n jlcOnSale: z.number().optional(),\n writable: z.boolean(),\n isFavorite: z.boolean(),\n packageDetail: PackageDetailSchema,\n _objMetadata: z\n .object({\n bounds: ModelBoundsSchema,\n })\n .optional(),\n})\n\nexport type RawEasyEdaJson = z.input<typeof EasyEdaJsonSchema>\nexport type BetterEasyEdaJson = z.infer<typeof EasyEdaJsonSchema>\n","import { z } from \"zod\"\n\n// Helper function to safely convert values to numbers with a default\nconst safeNumber = (defaultValue = 0) =>\n z\n .union([z.number(), z.string()])\n .transform((val) => {\n const num = Number(val)\n return isNaN(num) ? defaultValue : num\n })\n .default(defaultValue)\n\nconst tenthmil = z\n .union([z.number(), z.string()])\n .optional()\n .transform((n) =>\n typeof n === \"string\" && n.endsWith(\"mil\")\n ? n\n : `${Number.parseFloat(n as string) * 10}mil`,\n )\n .pipe(z.string())\n\nexport const PointSchema = z\n .any()\n .transform((p) => {\n if (Array.isArray(p)) {\n const [x, y] = p\n return { x, y }\n }\n if (typeof p === \"object\") {\n return p\n }\n throw new Error(`Invalid point: ${p}`)\n })\n .pipe(\n z.object({\n x: z.number(),\n y: z.number(),\n }),\n )\n\nexport const BaseShapeSchema = z.object({\n type: z.string(),\n id: z.string().optional(),\n layer: z.coerce.number().optional(),\n})\n\nexport const TrackSchema = BaseShapeSchema.extend({\n type: z.literal(\"TRACK\"),\n width: z.coerce.number(),\n points: z.array(PointSchema),\n})\n\nexport const PadSchema = BaseShapeSchema.extend({\n type: z.literal(\"PAD\"),\n shape: z.enum([\"RECT\", \"ELLIPSE\", \"OVAL\", \"POLYGON\"]),\n center: z.object({\n x: tenthmil,\n y: tenthmil,\n }),\n width: tenthmil,\n height: tenthmil,\n layermask: z.number(),\n net: z.union([z.string(), z.number()]).optional(),\n number: z.union([z.string(), z.number()]),\n holeRadius: tenthmil,\n points: z.array(PointSchema).optional(),\n rotation: safeNumber(0), // Will default to 0 if NaN or missing\n plated: z.boolean(),\n})\n\n// TODO this should be in \"arc sweep\" format with the following fields:\n// start, end, radius, largeArc, sweepDirection\nexport const ArcSchema = BaseShapeSchema.extend({\n type: z.literal(\"ARC\"),\n width: z.number(),\n start: PointSchema,\n end: PointSchema,\n radiusX: z.number(),\n radiusY: z.number(),\n largeArc: z.boolean(),\n sweepDirection: z.enum([\"CW\", \"CCW\"]),\n})\n\nexport const CircleSchema = BaseShapeSchema.extend({\n type: z.literal(\"CIRCLE\"),\n center: PointSchema,\n radius: z.number(),\n width: z.number(),\n})\n\nexport const SolidRegionSchema = BaseShapeSchema.extend({\n type: z.literal(\"SOLIDREGION\"),\n layermask: z.number(),\n points: z.array(PointSchema),\n fillStyle: z.string(),\n})\n\nexport const SVGNodeSchema = BaseShapeSchema.extend({\n type: z.literal(\"SVGNODE\"),\n svgData: z.object({\n gId: z.string(),\n nodeName: z.string(),\n nodeType: z.number(),\n layerid: z.string(),\n attrs: z.record(z.string(), z.string()),\n childNodes: z.array(z.unknown()),\n }),\n})\n\n// e.g. \"HOLE~3999.449~3004.213~1.378~gge152~0\"\nexport const HoleSchema = BaseShapeSchema.extend({\n type: z.literal(\"HOLE\"),\n center: PointSchema,\n radius: z.number(),\n})\n\nexport const ViaSchema = BaseShapeSchema.extend({\n type: z.literal(\"VIA\"),\n center: PointSchema,\n outerDiameter: z.number(),\n holeDiameter: z.number(),\n})\n\nexport const RectSchema = BaseShapeSchema.extend({\n type: z.literal(\"RECT\"),\n x: tenthmil,\n y: tenthmil,\n width: tenthmil,\n height: tenthmil,\n lineWidth: z.number(),\n fillStyle: z.string(),\n rotation: z.number().optional(),\n})\n\nexport const TextSchema = BaseShapeSchema.extend({\n type: z.literal(\"TEXT\"),\n text: z.string(),\n x: tenthmil,\n y: tenthmil,\n size_mm: z.number(),\n rotation: z.number().optional(),\n layer: z.number().optional(),\n textAnchor: z\n .enum([\"L\", \"C\", \"R\", \"\"])\n .optional()\n .transform((val) => (val === \"\" ? undefined : val)),\n font: z.string().optional(),\n})\n\nexport const PackageDetailShapeSchema = z.discriminatedUnion(\"type\", [\n TrackSchema,\n PadSchema,\n ArcSchema,\n CircleSchema,\n SolidRegionSchema,\n SVGNodeSchema,\n HoleSchema,\n ViaSchema,\n RectSchema,\n TextSchema,\n])\n\nconst pairs = <T>(arr: T[]): [T, T][] => {\n const pairs: [T, T][] = []\n for (let i = 0; i < arr.length; i += 2) {\n pairs.push([arr[i], arr[i + 1]])\n }\n return pairs\n}\n\nconst parsePoints = (pointsStr: string): number[][] =>\n pairs(\n pointsStr\n .trim()\n .split(\" \")\n .map((n) => Number(n)),\n )\n\nexport const ShapeItemSchema = z\n .object({\n type: z.string(),\n data: z.string(),\n })\n .transform((shape) => {\n switch (shape.type) {\n case \"TRACK\": {\n const [width, layer, _, pointsStr, id, _n] = shape.data.split(\"~\")\n const points = parsePoints(pointsStr)\n return TrackSchema.parse({ type: \"TRACK\", width, layer, points, id })\n }\n case \"PAD\": {\n const [padShape, ...params] = shape.data.split(\"~\")\n const [\n centerX,\n centerY,\n width,\n height,\n layermask,\n net,\n number,\n holeRadius,\n ...rest\n ] = params.map((p) => (Number.isNaN(Number(p)) ? p : Number(p)))\n const center = { x: centerX, y: centerY }\n let points: number[][] | undefined\n\n if (padShape === \"RECT\" || padShape === \"POLYGON\") {\n points = parsePoints(rest[0] as any)\n }\n\n // Extract rotation for all pad types from position 11 (rest[1])\n const r = Number(rest[1])\n const rotation = Number.isNaN(r) ? undefined : r\n\n const padInputParams = {\n type: \"PAD\",\n shape: padShape,\n center,\n width,\n height,\n layermask,\n net,\n number,\n holeRadius,\n points,\n rotation,\n plated: rest.includes(\"Y\"),\n }\n const pad = PadSchema.parse(padInputParams)\n return pad\n }\n case \"ARC\": {\n const [width, layer, , arcData] = shape.data.split(\"~\")\n // A rx ry x-axis-rotation large-arc-flag sweep-flag x y\n // A rx ry x-axis-rotation large-arc-flag sweep-flag dx dy\n const match = arcData.match(\n /M\\s*([\\d.-]+)(?:\\s*,\\s*|\\s+)([\\d.-]+)\\s*A\\s*([\\d.-]+)(?:\\s*,\\s*|\\s+)([\\d.-]+)\\s*([\\d.-]+)\\s*([\\d.-]+)\\s*([\\d.-]+)\\s*([\\d.-]+)(?:\\s*,\\s*|\\s+)([\\d.-]+)/,\n )\n\n if (!match) {\n throw new Error(`Invalid arc data: ${arcData}`)\n }\n\n const [\n ,\n startX,\n startY,\n radiusX,\n radiusY,\n xAxisRotation,\n largeArcFlag,\n sweepFlag,\n endX,\n endY,\n ] = match\n const start: [number, number] = [Number(startX), Number(startY)]\n const end: [number, number] = [Number(endX), Number(endY)]\n return ArcSchema.parse({\n type: \"ARC\",\n width: Number(width),\n layer: Number(layer),\n start,\n end,\n radiusX: Number(radiusX),\n radiusY: Number(radiusY),\n largeArc: largeArcFlag === \"1\",\n // sweepFlag=1 means clockwise (CW), sweepFlag=0 means counter-clockwise (CCW)\n sweepDirection: sweepFlag === \"1\" ? \"CW\" : \"CCW\",\n })\n }\n case \"CIRCLE\": {\n const [centerX, centerY, radius, width, layer, id] =\n shape.data.split(\"~\")\n const center: [number, number] = [Number(centerX), Number(centerY)]\n return CircleSchema.parse({\n type: \"CIRCLE\",\n center,\n radius: Number(radius),\n width: Number(width),\n layer: Number(layer),\n id,\n })\n }\n case \"HOLE\": {\n const [centerX, centerY, radius, id] = shape.data.split(\"~\")\n const center: [number, number] = [Number(centerX), Number(centerY)]\n return HoleSchema.parse({\n type: \"HOLE\",\n center,\n radius: Number(radius),\n id,\n })\n }\n case \"VIA\": {\n const [x, y, outerDiameter, , holeDiameter, id] = shape.data.split(\"~\")\n const center: [number, number] = [Number(x), Number(y)]\n return ViaSchema.parse({\n type: \"VIA\",\n center,\n outerDiameter: Number(outerDiameter),\n holeDiameter: Number(holeDiameter),\n id,\n })\n }\n case \"SOLIDREGION\": {\n const [layermask, , pathData, fillStyle, id] = shape.data.split(\"~\")\n const points =\n pathData.match(/[ML] ?(-?[\\d.]+)[ ,](-?[\\d.]+)/g)?.map((point) => {\n const [, x, y] =\n point.match(/[ML]? ?(-?[\\d.]+)[ ,](-?[\\d.]+)/) || []\n return [Number(x), Number(y)]\n }) || []\n return SolidRegionSchema.parse({\n type: \"SOLIDREGION\",\n layermask: Number(layermask),\n points,\n fillStyle,\n id,\n })\n }\n case \"SVGNODE\": {\n const svgData = JSON.parse(shape.data)\n return SVGNodeSchema.parse({ type: \"SVGNODE\", svgData })\n }\n case \"RECT\": {\n const [x, y, width, height, lineWidth, id, rotation, layer, fillStyle] =\n shape.data.split(\"~\")\n const r = rotation ? Number(rotation) : undefined\n return RectSchema.parse({\n type: \"RECT\",\n x,\n y,\n width,\n height,\n lineWidth: Number(lineWidth),\n id,\n rotation: Number.isNaN(r as number) ? undefined : r,\n layer: layer ? Number(layer) : undefined,\n fillStyle: fillStyle || undefined,\n })\n }\n case \"TEXT\": {\n const [textAnchor, x, y, size, layer, id, rotation, , font, text] =\n shape.data.split(\"~\")\n const r = rotation ? Number(rotation) : undefined\n return TextSchema.parse({\n type: \"TEXT\",\n text,\n x,\n y,\n size_mm: Number(size) * 2.54, // empirically this seems to match, C5248081 is a good test case\n layer: layer ? Number(layer) : undefined,\n id,\n rotation: Number.isNaN(r as number) ? undefined : r,\n textAnchor: textAnchor as \"L\" | \"C\" | \"R\" | undefined,\n font: font || undefined,\n })\n }\n\n default:\n throw new Error(`Unknown shape type: ${shape.type}`)\n }\n })\n .pipe(PackageDetailShapeSchema)\n\nexport const ShapesArraySchema = z.array(ShapeItemSchema)\n","import { z } from \"zod\"\nimport { mil10ToMm } from \"lib/utils/easyeda-unit-to-mm\"\n\n/**\n I'll break down the elements in the `dataStr.head.shape` array and explain what they represent. This array contains instructions for drawing the schematic symbol of the component.\n1. `\"R~365~275~2~2~70~50~#880000~1~0~none~gge1~0~\"`\n This represents a rectangle:\n - Starting position: (365, 275)\n - Width: 70\n - Height: 50\n - Color: #880000 (dark red)\n - Line width: 1\n - Other parameters are for internal use\n2. `\"E~370~280~1.5~1.5~#880000~1~0~#880000~gge2~0\"`\n This draws an ellipse:\n - Center: (370, 280)\n - Radius X: 1.5\n - Radius Y: 1.5\n - Color: #880000 (dark red)\n - Line width: 1\n3-10. `\"P~show~0~1~355~285~180~gge5~0^^355~285^^M355,285h10~#000000^^1~368.7~289~0~GND~start~~~#000000^^1~364.5~284~0~1~end~~~#000000^^0~362~285^^0~M 365 288 L 368 285 L 365 282\"`\n These represent pins of the component. Each pin has:\n - Pin number\n - Position\n - Orientation\n - Label (e.g., GND, TRIG, OUT)\n - Color\n - Drawing instructions for the pin shape\n4. `\"A~M x1 y1 A radius radius 0 1 0 x2 y2\"`\n This represents an arc:\n - Start point: (x1, y1)\n - End point: (x2, y2)\n - Radius\n - Direction (CW or CCW)\n - Color\n - Line width\n - ID\nTo parse this data:\n1. Split the string by `~` to get individual parameters.\n2. For rectangles (R), use parameters 2-7 for position, size, and color.\n3. For ellipses (E), use parameters 2-5 for position and size, and 6 for color.\n4. For pins (P), split further by `^^` to get different sections:\n - First section: general pin properties\n - Second section: pin position\n - Third section: line drawing instruction\n - Fourth and Fifth sections: label position and text\n - Sixth section: additional drawing instruction for pin shape\n5. For arcs (A), split by `~M ` to get the path data.\n - Format: A~M x1 y1 A radius radius 0 1 0 x2 y2\n - Parse the start and end points, radius, direction, color, line width, and ID.\nThis data structure allows for a compact representation of the schematic symbol, which can be rendered by CAD software to display the component in circuit diagrams.\n */\n// Examples\n// \"R~365~275~2~2~70~50~#880000~1~0~none~gge1~0~\",\n// \"E~370~280~1.5~1.5~#880000~1~0~#880000~gge2~0\",\n// \"P~show~0~1~355~285~180~gge5~0^^355~285^^M355,285h10~#000000^^1~368.7~289~0~GND~start~~~#000000^^1~364.5~284~0~1~end~~~#000000^^0~362~285^^0~M 365 288 L 368 285 L 365 282\",\n// \"P~show~0~2~355~295~180~gge6~0^^355~295^^M355,295h10~#880000^^1~368.7~299~0~TRIG~start~~~#0000FF^^1~364.5~294~0~2~end~~~#0000FF^^0~362~295^^0~M 365 298 L 368 295 L 365 292\",\n// \"P~show~0~3~355~305~180~gge7~0^^355~305^^M355,305h10~#880000^^1~368.7~309~0~OUT~start~~~#0000FF^^1~364.5~304~0~3~end~~~#0000FF^^0~362~305^^0~M 365 308 L 368 305 L 365 302\",\n// \"P~show~0~4~355~315~180~gge8~0^^355~315^^M355,315h10~#880000^^1~368.7~319~0~RESET~start~~~#0000FF^^1~364.5~314~0~4~end~~~#0000FF^^0~362~315^^0~M 365 318 L 368 315 L 365 312\",\n// \"P~show~0~5~445~315~0~gge9~0^^445~315^^M445,315h-10~#880000^^1~431.3~319~0~CONT~end~~~#0000FF^^1~435.5~314~0~5~start~~~#0000FF^^0~438~315^^0~M 435 312 L 432 315 L 435 318\",\n// \"P~show~0~6~445~305~0~gge10~0^^445~305^^M445,305h-10~#880000^^1~431.3~309~0~THRES~end~~~#0000FF^^1~435.5~304~0~6~start~~~#0000FF^^0~438~305^^0~M 435 302 L 432 305 L 435 308\",\n// \"P~show~0~7~445~295~0~gge11~0^^445~295^^M445,295h-10~#880000^^1~431.3~299~0~DISCH~end~~~#0000FF^^1~435.5~294~0~7~start~~~#0000FF^^0~438~295^^0~M 435 292 L 432 295 L 435 298\",\n// \"P~show~0~8~445~285~0~gge12~0^^445~285^^M445,285h-10~#FF0000^^1~431.3~289~0~VCC~end~~~#FF0000^^1~435.5~284~0~8~start~~~#FF0000^^0~438~285^^0~M 435 282 L 432 285 L 435 288\",\n// \"A~M x1 y1 A radius radius 0 1 0 x2 y2\"\n\nconst PointSchema = z.object({\n x: z.number(),\n y: z.number(),\n})\n\nconst RectangleShapeOutputSchema = z.object({\n type: z.literal(\"RECTANGLE\"),\n position: PointSchema,\n width: z.number(),\n height: z.number(),\n color: z.string(),\n lineWidth: z.number(),\n id: z.string(),\n})\n\nconst parseRectangle = (\n str: string,\n): z.infer<typeof RectangleShapeOutputSchema> => {\n const [, x, y, , , width, height, color, lineWidth, , , id] = str.split(\"~\")\n return {\n type: \"RECTANGLE\",\n position: { x: Number(x), y: Number(y) },\n width: Number(width),\n height: Number(height),\n color,\n lineWidth: Number(lineWidth),\n id,\n }\n}\n\nexport const RectangleShapeSchema = z\n .string()\n .startsWith(\"R~\")\n .transform(parseRectangle)\n .pipe(RectangleShapeOutputSchema)\n\nconst EllipseShapeOutputSchema = z.object({\n type: z.literal(\"ELLIPSE\"),\n center: PointSchema,\n radiusX: z.number(),\n radiusY: z.number(),\n color: z.string(),\n lineWidth: z.number(),\n id: z.string(),\n})\n\nconst parseEllipse = (\n str: string,\n): z.infer<typeof EllipseShapeOutputSchema> => {\n const [, x, y, radiusX, radiusY, color, lineWidth, , , id] = str.split(\"~\")\n return {\n type: \"ELLIPSE\",\n center: { x: Number(x), y: Number(y) },\n radiusX: Number(radiusX),\n radiusY: Number(radiusY),\n color,\n lineWidth: Number(lineWidth),\n id,\n }\n}\n\nexport const EllipseShapeSchema = z\n .string()\n .startsWith(\"E~\")\n .transform(parseEllipse)\n .pipe(EllipseShapeOutputSchema)\n\nconst ArcShapeOutputSchema = z.object({\n type: z.literal(\"ARC\"),\n start: PointSchema,\n end: PointSchema,\n radius: z.number(),\n sweepFlag: z.boolean(),\n color: z.string(),\n lineWidth: z.number(),\n id: z.string(),\n})\n\nconst parseArc = (str: string): z.infer<typeof ArcShapeOutputSchema> => {\n // Format: A~M x1 y1 A radius radius 0 1 0 x2 y2~#880000~1~0~none~gge49~0\n const [, pathData, color, lineWidth, , , id] = str.split(\"~\")\n const parts = pathData.split(\" \")\n\n // Handle potential NaN values by defaulting to 0\n const x1 = Number(parts[1]) || 0\n const y1 = Number(parts[2]) || 0\n const radius = Number(parts[4]) || 0\n const sweepFlag = parts[7] === \"1\" // The sweep flag is the 8th parameter\n const x2 = Number(parts[8]) || 0\n const y2 = Number(parts[9]) || 0\n\n // Handle empty or invalid line width\n const parsedLineWidth = Number(lineWidth)\n const finalLineWidth = Number.isNaN(parsedLineWidth) ? 1 : parsedLineWidth\n\n return {\n type: \"ARC\",\n start: { x: x1, y: y1 },\n end: { x: x2, y: y2 },\n radius,\n sweepFlag,\n color: color || \"#880000\", // Default color\n lineWidth: finalLineWidth,\n id: id || \"gge1\",\n }\n}\n\nexport const ArcShapeSchema = z\n .string()\n .startsWith(\"A~\")\n .transform(parseArc)\n .pipe(ArcShapeOutputSchema)\n\nconst PinShapeOutputSchema = z.object({\n type: z.literal(\"PIN\"),\n visibility: z.enum([\"show\", \"hide\", \"none\"]),\n pinNumber: z.union([z.string(), z.number()]),\n x: z.number(),\n y: z.number(),\n rotation: z.number(),\n id: z.string(),\n label: z.string(),\n labelColor: z.string(),\n path: z.string(),\n arrow: z.string(),\n})\n\nconst parsePin = (pinString: string): z.infer<typeof PinShapeOutputSchema> => {\n const parts = pinString.split(\"~\")\n const [, visibility, , pinNumber, x, y, rotation, id] = parts\n\n const nameMatch = pinString.match(/~([\\w+#-]+)~(start|end)~/)\n let label = nameMatch ? nameMatch[1] : \"\"\n if (label.endsWith(\"+\")) label = label.slice(0, -1) + \"_POS\"\n if (label.endsWith(\"-\")) label = label.slice(0, -1) + \"_NEG\"\n if (label.endsWith(\"#\")) label = label.slice(0, -1)\n if (/^\\+\\d+(?:\\.\\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`\n\n const colorMatch = pinString.match(/#[0-9A-F]{6}/)\n const labelColor = colorMatch ? colorMatch[0] : \"\"\n\n const pathMatch = pinString.match(/\\^\\^([^~]+)/)\n const path = pathMatch ? pathMatch[1] : \"\"\n\n const arrowMatch = pinString.match(/\\^\\^0~(.+)$/)\n const arrow = arrowMatch ? arrowMatch[1] : \"\"\n\n const r = Number.parseFloat(rotation)\n return {\n type: \"PIN\",\n visibility: visibility as \"show\" | \"hide\" | \"none\",\n id,\n pinNumber: Number.isNaN(Number(pinNumber)) ? pinNumber : Number(pinNumber),\n x: Number.parseFloat(x),\n y: Number.parseFloat(y),\n rotation: Number.isNaN(r) ? 0 : r,\n label,\n labelColor,\n path,\n arrow,\n }\n}\n\nexport const PinShapeSchema = z\n .string()\n .startsWith(\"P~\")\n .transform(parsePin)\n .pipe(PinShapeOutputSchema)\n\nconst PolylineShapeOutputSchema = z.object({\n type: z.literal(\"POLYLINE\"),\n points: z.array(PointSchema),\n color: z.string(),\n lineWidth: z.number(),\n id: z.string(),\n})\n\nconst parsePoints = (pointsStr: string): Array<{ x: number; y: number }> => {\n return pointsStr\n .split(\" \")\n .reduce<Array<{ x: number; y: number }>>((acc, value, index) => {\n if (index % 2 === 0) {\n acc.push({ x: Number(value), y: 0 })\n } else {\n acc[acc.length - 1].y = Number(value)\n }\n return acc\n }, [])\n}\n\nconst parsePolyline = (\n str: string,\n): z.infer<typeof PolylineShapeOutputSchema> => {\n const [, ...rest] = str.split(\"~\")\n const [pointsStr, color, lineWidth, , , id] = rest\n\n return {\n type: \"POLYLINE\",\n points: parsePoints(pointsStr),\n color,\n lineWidth: Number(lineWidth),\n id,\n }\n}\n\nexport const PolylineShapeSchema = z\n .string()\n .startsWith(\"PL~\")\n .transform(parsePolyline)\n .pipe(PolylineShapeOutputSchema)\n\nconst PolygonShapeOutputSchema = z.object({\n type: z.literal(\"POLYGON\"),\n points: z.array(PointSchema),\n fillColor: z.string(),\n lineWidth: z.number(),\n lineColor: z.string(),\n id: z.string(),\n})\n\nconst parsePolygon = (\n str: string,\n): z.infer<typeof PolygonShapeOutputSchema> => {\n const [, ...rest] = str.split(\"~\")\n const [pointsStr, fillColor, lineWidth, lineColor, , id] = rest\n\n return {\n type: \"POLYGON\",\n points: parsePoints(pointsStr),\n fillColor,\n lineWidth: Number(lineWidth),\n lineColor,\n id,\n }\n}\n\nexport const PolygonShapeSchema = z\n .string()\n .startsWith(\"PG~\")\n .transform(parsePolygon)\n .pipe(PolygonShapeOutputSchema)\n\nconst PathShapeOutputSchema = z.object({\n type: z.literal(\"PATH\"),\n pathData: z.string(),\n fillColor: z.string(),\n strokeWidth: z.number(),\n strokeColor: z.string(),\n id: z.string(),\n})\n\nconst parsePath = (str: string): z.infer<typeof PathShapeOutputSchema> => {\n const [, pathData, fillColor, strokeWidth, strokeColor, , id] = str.split(\"~\")\n return {\n type: \"PATH\",\n pathData,\n fillColor,\n strokeWidth: mil10ToMm(Number(strokeWidth)),\n strokeColor,\n id,\n }\n}\n\nexport const PathShapeSchema = z\n .string()\n .startsWith(\"PT~\")\n .transform(parsePath)\n .pipe(PathShapeOutputSchema)\n\nconst TextShapeOutputSchema = z.object({\n type: z.literal(\"TEXT\"),\n alignment: z.enum([\"L\", \"C\", \"R\"]),\n x: z.number(),\n y: z.number(),\n rotation: z.number(),\n fontColor: z.string(),\n backgroundColor: z.string().optional(),\n fontSize: z.string(),\n fontWeight: z.string().optional().default(\"normal\"),\n fontStyle: z.enum([\"normal\", \"italic\"]).optional().default(\"normal\"),\n fontDecoration: z.string().optional().default(\"\"),\n content: z.string(),\n textType: z.string(),\n visibility: z.enum([\"0\", \"1\"]),\n mirror: z.string(),\n id: z.string(),\n})\n\nconst parseText = (str: string): z.infer<typeof TextShapeOutputSchema> => {\n const [\n ,\n alignment,\n x,\n y,\n rotation,\n fontColor,\n backgroundColor,\n fontSize,\n fontWeight,\n fontStyle,\n fontDecoration,\n content,\n textType,\n visibility,\n mirror,\n id,\n ] = str.split(\"~\")\n return {\n type: \"TEXT\",\n alignment: alignment as \"L\" | \"C\" | \"R\",\n x: Number(x),\n y: Number(y),\n rotation: Number(rotation),\n fontColor,\n backgroundColor: backgroundColor || undefined,\n fontSize,\n fontWeight: fontWeight || \"normal\",\n fontStyle: (fontStyle || \"normal\") as \"normal\" | \"italic\",\n fontDecoration: fontDecoration || \"\",\n content,\n textType,\n visibility: visibility as \"0\" | \"1\",\n mirror,\n id,\n }\n}\n\nexport const TextShapeSchema = z\n .string()\n .startsWith(\"T~\")\n .transform(parseText)\n .pipe(TextShapeOutputSchema)\n\nexport const SingleLetterShapeSchema = z\n .string()\n .transform((x) => {\n // We do some discrimination here for better errors\n if (x.startsWith(\"R~\")) return RectangleShapeSchema.parse(x)\n if (x.startsWith(\"E~\")) return EllipseShapeSchema.parse(x)\n if (x.startsWith(\"P~\")) return PinShapeSchema.parse(x)\n if (x.startsWith(\"PL~\")) return PolylineShapeSchema.parse(x)\n if (x.startsWith(\"PG~\")) return PolygonShapeSchema.parse(x)\n if (x.startsWith(\"PT~\")) return PathShapeSchema.parse(x)\n if (x.startsWith(\"T~\")) return TextShapeSchema.parse(x)\n if (x.startsWith(\"A~\")) return ArcShapeSchema.parse(x)\n throw new Error(`Invalid shape type: ${x}`)\n })\n .pipe(\n z.union([\n RectangleShapeOutputSchema,\n EllipseShapeOutputSchema,\n PinShapeOutputSchema,\n PolylineShapeOutputSchema,\n PolygonShapeOutputSchema,\n PathShapeOutputSchema,\n TextShapeOutputSchema,\n ArcShapeOutputSchema,\n ]),\n )\n\nexport type SingleLetterShape = z.infer<typeof SingleLetterShapeSchema>\n","export function normalizeManufacturerPartNumber(partNumber: string): string {\n // Step 1: Replace dashes and invalid symbols with underscores\n let normalized = partNumber\n .replace(/[-]/g, \"_\")\n .replace(/[^a-zA-Z0-9_$]/g, \"_\")\n\n // Step 2: If the string starts with a number, prepend 'A_'\n if (/^\\d/.test(normalized)) {\n normalized = \"A_\" + normalized\n }\n\n return normalized\n}\n","import type { BetterEasyEdaJson } from \"lib/schemas/easy-eda-json-schema\"\nimport { mil10ToMm } from \"lib/utils/easyeda-unit-to-mm\"\n\ntype XYBounds = {\n min: { x: number; y: number }\n max: { x: number; y: number }\n}\n\ntype RotationDeg = 0 | 90 | 180 | 270\n\nconst milToMm = (mil: number) => mil * 0.0254\n\nconst getBoundsCenter = (bounds: XYBounds) => ({\n x: (bounds.min.x + bounds.max.x) / 2,\n y: (bounds.min.y + bounds.max.y) / 2,\n})\n\nconst getCadSvgNode = (easyEdaJson: BetterEasyEdaJson) => {\n const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(\n (shape) => shape.type === \"SVGNODE\" && shape.svgData.attrs?.uuid,\n )\n\n return svgNode?.type === \"SVGNODE\" ? svgNode : null\n}\n\nconst parseMil10Value = (value: string | number) =>\n Number(String(value).replace(\"mil\", \"\")) / 10\n\nconst isZeroishModelCenter = (value: number) => Math.abs(value) < 1e-6\n\nconst isZeroishFootprintDelta = (value: number) => Math.abs(value) < 1e-3\n\nconst getPadCenter = (easyEdaJson: BetterEasyEdaJson) => {\n const pads = easyEdaJson.packageDetail.dataStr.shape.filter(\n (shape) => shape.type === \"PAD\",\n )\n if (pads.length === 0) return null\n\n const xs = pads.map((pad) => parseMil10Value(pad.center.x))\n const ys = pads.map((pad) => parseMil10Value(pad.center.y))\n\n return {\n x: (Math.min(...xs) + Math.max(...xs)) / 2,\n y: (Math.min(...ys) + Math.max(...ys)) / 2,\n }\n}\n\nconst getRotatedOffsetMm = ({\n bounds,\n rawOffsetMil,\n rotationDeg,\n}: {\n bounds: XYBounds\n rawOffsetMil: { x: number; y: number }\n rotationDeg: RotationDeg\n}) => {\n const center = getBoundsCenter(bounds)\n const offsetX = milToMm(rawOffsetMil.x)\n const offsetY = milToMm(rawOffsetMil.y)\n\n switch (rotationDeg) {\n case 0:\n return { x: center.x + offsetX, y: center.y + offsetY }\n case 90:\n return { x: center.x + offsetY, y: center.y + offsetX }\n case 180:\n return { x: center.x - offsetX, y: center.y - offsetY }\n case 270:\n return { x: center.x - offsetY, y: center.y - offsetX }\n }\n}\n\nexport const getCadModelOffsetMm = (easyEdaJson: BetterEasyEdaJson) => {\n const svgNode = getCadSvgNode(easyEdaJson)\n const bounds = easyEdaJson._objMetadata?.bounds\n if (!svgNode || !bounds) return null\n\n const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? \"0,0\")\n .split(\",\")\n .map((value) => Number(value.trim()))\n if (!Number.isFinite(originX) || !Number.isFinite(originY)) return null\n\n const [, , rotationZRaw] = String(\n svgNode.svgData.attrs?.c_rotation ?? \"0,0,0\",\n )\n .split(\",\")\n .map((value) => Number(value.trim()))\n const rotationDeg = (((rotationZRaw % 360) + 360) % 360) as RotationDeg\n if (![0, 90, 180, 270].includes(rotationDeg)) return null\n\n const modelCenter = getBoundsCenter(bounds)\n const footprintCenter = easyEdaJson.packageDetail.dataStr.head\n const padCenter = getPadCenter(easyEdaJson)\n const padCenterDelta = padCenter\n ? {\n x: padCenter.x - footprintCenter.x,\n y: padCenter.y - footprintCenter.y,\n }\n : null\n const rawOffsetMil = {\n x: (originX - footprintCenter.x) * 10,\n y: (originY - footprintCenter.y) * 10,\n }\n\n if (\n padCenter &&\n padCenterDelta &&\n isZeroishModelCenter(modelCenter.x) &&\n isZeroishModelCenter(modelCenter.y) &&\n isZeroishFootprintDelta(padCenterDelta.x) &&\n isZeroishFootprintDelta(padCenterDelta.y)\n ) {\n return { x: 0, y: 0 }\n }\n\n return getRotatedOffsetMm({\n bounds,\n rawOffsetMil,\n rotationDeg,\n })\n}\n\nexport const getCadSvgNodeZOffsetMm = (easyEdaJson: BetterEasyEdaJson) => {\n const svgNode = getCadSvgNode(easyEdaJson)\n if (!svgNode) return null\n\n const svgNodeZ = Number(svgNode.svgData.attrs?.z ?? 0)\n if (!Number.isFinite(svgNodeZ)) return null\n\n return mil10ToMm(svgNodeZ)\n}\n\nexport const getCadSvgNodeModelUuid = (easyEdaJson: BetterEasyEdaJson) =>\n getCadSvgNode(easyEdaJson)?.svgData.attrs?.uuid ?? null\n","import type { BetterEasyEdaJson } from \"lib/schemas/easy-eda-json-schema\"\nimport {\n getCadModelOffsetMm,\n getCadSvgNodeModelUuid,\n getCadSvgNodeZOffsetMm,\n} from \"./get-easyeda-cad-placement-helpers\"\nimport { getModelObjCdnUrl, getModelStepCdnUrl } from \"./get-model-cdn-url\"\n\ntype ModelBounds = {\n min: { x: number; y: number; z: number }\n max: { x: number; y: number; z: number }\n}\n\nexport type EasyEdaCadModelPlacement = {\n modelObjUrl: string\n positionXMm: number\n positionYMm: number\n modelStepUrl?: string\n positionZMm: number\n bounds: ModelBounds\n}\n\nconst placementCache = new Map<\n string,\n Promise<EasyEdaCadModelPlacement | null>\n>()\n\nconst parseObjBounds = (objText: string): ModelBounds | null => {\n let minX = Number.POSITIVE_INFINITY\n let minY = Number.POSITIVE_INFINITY\n let minZ = Number.POSITIVE_INFINITY\n let maxX = Number.NEGATIVE_INFINITY\n let maxY = Number.NEGATIVE_INFINITY\n let maxZ = Number.NEGATIVE_INFINITY\n let vertexCount = 0\n\n for (const line of objText.split(/\\r?\\n/)) {\n const trimmed = line.trim()\n if (!trimmed.startsWith(\"v \")) continue\n\n const [, xStr, yStr, zStr] = trimmed.split(/\\s+/, 4)\n const x = Number(xStr)\n const y = Number(yStr)\n const z = Number(zStr)\n\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) {\n continue\n }\n\n vertexCount += 1\n minX = Math.min(minX, x)\n minY = Math.min(minY, y)\n minZ = Math.min(minZ, z)\n maxX = Math.max(maxX, x)\n maxY = Math.max(maxY, y)\n maxZ = Math.max(maxZ, z)\n }\n\n if (vertexCount === 0) return null\n\n return {\n min: { x: minX, y: minY, z: minZ },\n max: { x: maxX, y: maxY, z: maxZ },\n }\n}\n\nconst getPositionZMmFromBounds = (\n bounds: ModelBounds,\n svgNodeZOffsetMm: number,\n) => {\n const minZ = Math.abs(bounds.min.z) < 1e-6 ? 0 : bounds.min.z\n return minZ - svgNodeZOffsetMm\n}\n\nexport const getEasyEdaCadModelPlacement = async (\n easyEdaJson: BetterEasyEdaJson,\n { fetch = globalThis.fetch }: { fetch?: typeof globalThis.fetch } = {},\n): Promise<EasyEdaCadModelPlacement | null> => {\n const modelUuid = getCadSvgNodeModelUuid(easyEdaJson)\n const partNumber = easyEdaJson.lcsc.number\n const derivedOffsetMm = getCadModelOffsetMm(easyEdaJson)\n const svgNodeZOffsetMm = getCadSvgNodeZOffsetMm(easyEdaJson)\n\n if (\n !modelUuid ||\n !partNumber ||\n svgNodeZOffsetMm == null ||\n !derivedOffsetMm ||\n !fetch\n ) {\n return null\n }\n\n const modelObjUrl = getModelObjCdnUrl({\n easyedaModelUuid: modelUuid,\n easyedaPartNumber: partNumber,\n })\n const modelStepUrl = getModelStepCdnUrl({\n easyedaModelUuid: modelUuid,\n easyedaPartNumber: partNumber,\n })\n\n const metadataBounds = easyEdaJson._objMetadata?.bounds\n if (metadataBounds) {\n return {\n modelObjUrl,\n positionXMm: derivedOffsetMm.x,\n positionYMm: derivedOffsetMm.y,\n modelStepUrl,\n bounds: metadataBounds,\n positionZMm: getPositionZMmFromBounds(metadataBounds, svgNodeZOffsetMm),\n }\n }\n\n const cacheKey = `${modelObjUrl}::${svgNodeZOffsetMm}`\n const cachedPlacement = placementCache.get(cacheKey)\n if (cachedPlacement) return cachedPlacement\n\n const placementPromise = (async () => {\n try {\n const response = await fetch(modelObjUrl)\n if (!response.ok) return null\n\n const objText = await response.text()\n const bounds = parseObjBounds(objText)\n if (!bounds) return null\n\n return {\n modelObjUrl,\n positionXMm: derivedOffsetMm.x,\n positionYMm: derivedOffsetMm.y,\n modelStepUrl,\n bounds,\n // Align the EasyEDA SVG-node Z against the model's minimum Z.\n positionZMm: getPositionZMmFromBounds(bounds, svgNodeZOffsetMm),\n }\n } catch (error) {\n console.error(\n `Error resolving EasyEDA CAD placement for ${partNumber}:`,\n error,\n )\n return null\n }\n })()\n\n placementCache.set(cacheKey, placementPromise)\n return placementPromise\n}\n","import { mmStr } from \"@tscircuit/mm\"\nimport type { AnyCircuitElement } from \"circuit-json\"\nimport { su } from \"@tscircuit/circuit-json-util\"\n\nexport const generateFootprintTsx = (\n circuitJson: AnyCircuitElement[],\n): string => {\n const holes = su(circuitJson).pcb_hole.list()\n const platedHoles = su(circuitJson).pcb_plated_hole.list()\n const smtPads = su(circuitJson).pcb_smtpad.list()\n const vias = su(circuitJson).pcb_via.list()\n const silkscreenPaths = su(circuitJson).pcb_silkscreen_path.list()\n const silkscreenTexts = su(circuitJson).pcb_silkscreen_text.list()\n const courtyardOutlines = su(circuitJson).pcb_courtyard_outline.list()\n\n const elementStrings: string[] = []\n\n for (const hole of holes) {\n if (hole.hole_shape === \"circle\") {\n elementStrings.push(\n `<hole pcbX=\"${mmStr(hole.x)}\" pcbY=\"${mmStr(hole.y)}\" diameter=\"${mmStr(hole.hole_diameter)}\" />`,\n )\n } else if (hole.hole_shape === \"oval\") {\n console.warn(\"Unhandled oval hole in conversion (needs implementation)\")\n }\n }\n\n for (const platedHole of platedHoles) {\n if (platedHole.shape === \"pill_hole_with_rect_pad\") {\n elementStrings.push(\n `<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX=\"${mmStr(platedHole.x)}\" pcbY=\"${mmStr(platedHole.y)}\" holeWidth=\"${mmStr(platedHole.hole_width)}\" holeHeight=\"${mmStr(platedHole.hole_height)}\" outerWidth=\"${mmStr(platedHole.rect_pad_width)}\" outerHeight=\"${mmStr(platedHole.rect_pad_height)}\" shape=\"pill\" />`,\n )\n } else if (platedHole.shape === \"circle\") {\n elementStrings.push(\n `<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX=\"${mmStr(platedHole.x)}\" pcbY=\"${mmStr(platedHole.y)}\" outerDiameter=\"${mmStr(platedHole.outer_diameter)}\" holeDiameter=\"${mmStr(platedHole.hole_diameter)}\" shape=\"circle\" />`,\n )\n } else if (platedHole.shape === \"rotated_pill_hole_with_rect_pad\") {\n const rotation = platedHole.hole_ccw_rotation || 0\n\n elementStrings.push(\n `<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX=\"${mmStr(platedHole.x)}\" pcbY=\"${mmStr(platedHole.y)}\" holeWidth=\"${mmStr(platedHole.hole_width)}\" holeHeight=\"${mmStr(platedHole.hole_height)}\" outerWidth=\"${mmStr(platedHole.rect_pad_width)}\" outerHeight=\"${mmStr(platedHole.rect_pad_height)}\" rectPad={true} pcbRotation=\"${rotation}deg\" shape=\"pill\" />`,\n )\n }\n }\n\n for (const smtPad of smtPads) {\n if (smtPad.shape === \"circle\") {\n elementStrings.push(\n `<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX=\"${mmStr(smtPad.x)}\" pcbY=\"${mmStr(smtPad.y)}\" radius=\"${mmStr(smtPad.radius)}\" shape=\"circle\" />`,\n )\n } else if (smtPad.shape === \"rect\") {\n elementStrings.push(\n `<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX=\"${mmStr(smtPad.x)}\" pcbY=\"${mmStr(smtPad.y)}\" width=\"${mmStr(smtPad.width)}\" height=\"${mmStr(smtPad.height)}\" shape=\"rect\" />`,\n )\n } else if (smtPad.shape === \"polygon\") {\n const pointsStr = smtPad.points\n .map((p) => `{x: \"${mmStr(p.x)}\", y: \"${mmStr(p.y)}\"}`)\n .join(\", \")\n elementStrings.push(\n `<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} points={[${pointsStr}]} shape=\"polygon\" />`,\n )\n }\n }\n\n for (const via of vias) {\n elementStrings.push(\n `<via pcbX=\"${mmStr(via.x)}\" pcbY=\"${mmStr(via.y)}\" outerDiameter=\"${mmStr(via.outer_diameter)}\" holeDiameter=\"${mmStr(via.hole_diameter)}\" layers={${JSON.stringify(via.layers)}} />`,\n )\n }\n\n for (const silkscreenPath of silkscreenPaths) {\n elementStrings.push(\n `<silkscreenpath route={${JSON.stringify(silkscreenPath.route)}} />`,\n )\n }\n\n for (const silkscreenText of silkscreenTexts) {\n // Inject the dynamic {props.name} for the reference designator text. \"{NAME}\" was\n // mapped during the Circuit JSON conversion step to identify the designator text.\n const isRefDes = silkscreenText.text === \"{NAME}\"\n const textValue = isRefDes\n ? \"{props.name}\"\n : JSON.stringify(silkscreenText.text)\n\n elementStrings.push(\n `<silkscreentext text=${textValue} pcbX=\"${mmStr(silkscreenText.anchor_position.x)}\" pcbY=\"${mmStr(silkscreenText.anchor_position.y)}\" anchorAlignment=\"${silkscreenText.anchor_alignment}\" ${silkscreenText.font_size ? `fontSize=\"${mmStr(silkscreenText.font_size)}\"` : \"\"} />`,\n )\n }\n\n for (const courtyardOutline of courtyardOutlines) {\n elementStrings.push(\n `<courtyardoutline outline={${JSON.stringify(courtyardOutline.outline)}} />`,\n )\n }\n\n return `\n <footprint>\n ${elementStrings.join(\"\\n\")}\n </footprint>\n `.trim()\n}\n","import type { ChipProps } from \"@tscircuit/props\"\nimport type { AnyCircuitElement } from \"circuit-json\"\nimport { generateFootprintTsx } from \"../generate-footprint-tsx\"\n\ninterface Params {\n pinLabels: ChipProps[\"pinLabels\"]\n componentName: string\n objUrl?: string\n stepUrl?: string\n circuitJson: AnyCircuitElement[]\n supplierPartNumbers: ChipProps[\"supplierPartNumbers\"]\n manufacturerPartNumber: string\n}\n\nexport const generateTypescriptComponent = ({\n pinLabels,\n componentName,\n objUrl,\n stepUrl,\n circuitJson,\n supplierPartNumbers,\n manufacturerPartNumber,\n}: Params) => {\n // Ensure pinLabels is defined\n const safePinLabels = pinLabels ?? {}\n const cadComponent = circuitJson.find((item) => item.type === \"cad_component\")\n const footprintTsx = generateFootprintTsx(circuitJson)\n\n // Simplify pin labels to include only the second element\n const simplifiedPinLabels = Object.fromEntries(\n Object.entries(safePinLabels).map(([pin, labels]) => {\n // Ensure labels is an array and has a second element\n if (Array.isArray(labels) && labels.length > 1) {\n return [pin, [labels[1]]]\n }\n return [pin, labels] // Fallback to original if not an array or missing second element\n }),\n )\n\n const pinLabelsString = Object.entries(simplifiedPinLabels)\n .map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`)\n .join(\",\\n\")\n\n const cadModelLines = [\n objUrl ? `objUrl: \"${objUrl}\",` : \"\",\n stepUrl ? `stepUrl: \"${stepUrl}\",` : \"\",\n `pcbRotationOffset: ${cadComponent?.rotation?.z ?? 0},`,\n `modelOriginPosition: { x: ${cadComponent?.model_origin_position?.x ?? 0}, y: ${cadComponent?.model_origin_position?.y ?? 0}, z: ${cadComponent?.model_origin_position?.z ?? 0} },`,\n ]\n .filter(Boolean)\n .map((line) => ` ${line}`)\n .join(\"\\n\")\n\n return `\nimport type { ChipProps } from \"@tscircuit/props\"\n\nconst pinLabels = {\n${pinLabelsString}\n} as const\n\nexport const ${componentName} = (props: ChipProps<typeof pinLabels>) => {\n return (\n <chip\n pinLabels={pinLabels}\n supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, \" \")}}\n manufacturerPartNumber=\"${manufacturerPartNumber}\"\n footprint={${footprintTsx}}\n ${\n objUrl || stepUrl\n ? `cadModel={{\n${cadModelLines}\n }}`\n : \"\"\n }\n {...props}\n />\n )\n}\n`.trim()\n}\n","import { su } from \"@tscircuit/circuit-json-util\"\nimport { convertEasyEdaJsonToCircuitJson } from \"lib/convert-easyeda-json-to-tscircuit-soup-json\"\nimport {\n type BetterEasyEdaJson,\n EasyEdaJsonSchema,\n} from \"lib/schemas/easy-eda-json-schema\"\nimport { normalizeManufacturerPartNumber } from \"lib/utils/normalize-manufacturer-part-number\"\nimport { getEasyEdaCadModelPlacement } from \"../get-easyeda-cad-model-placement\"\nimport { generateTypescriptComponent } from \"./generate-typescript-component\"\n\nexport const convertRawEasyToTsx = async ({ rawEasy }: { rawEasy: any }) => {\n const betterEasy = EasyEdaJsonSchema.parse(rawEasy)\n const result = await convertBetterEasyToTsx({\n betterEasy,\n })\n return result\n}\n\nexport const convertBetterEasyToTsx = async ({\n betterEasy,\n}: {\n betterEasy: BetterEasyEdaJson\n}): Promise<string> => {\n const cadPlacement = await getEasyEdaCadModelPlacement(betterEasy)\n const circuitJson = convertEasyEdaJsonToCircuitJson(betterEasy, {\n useModelCdn: true,\n shouldRecenter: true,\n cadPositionXMm: cadPlacement?.positionXMm,\n cadPositionYMm: cadPlacement?.positionYMm,\n cadPositionZMm: cadPlacement?.positionZMm,\n showDesignator: true,\n })\n const [cadComponent] = su(circuitJson).cad_component.list()\n if (cadComponent) {\n cadComponent.position.x = 0\n cadComponent.position.y = 0\n }\n const rawPn = betterEasy.dataStr.head.c_para[\"Manufacturer Part\"]\n const pn = rawPn ? normalizeManufacturerPartNumber(rawPn) : \"unknown\"\n const sourcePorts = su(circuitJson).source_port.list()\n\n const pinLabels: Record<string, string[]> = {}\n const sortedPorts = sourcePorts.sort((a, b) => {\n const aNum = Number.parseInt(a.name.replace(\"pin\", \"\"))\n const bNum = Number.parseInt(b.name.replace(\"pin\", \"\"))\n return aNum - bNum\n })\n for (const sourcePort of sortedPorts) {\n pinLabels[sourcePort.name] = [\n sourcePort.name,\n ...(sourcePort.port_hints ?? []),\n ]\n }\n\n let modelObjUrl: string | undefined\n let modelStepUrl: string | undefined\n if (cadPlacement?.modelObjUrl) {\n modelObjUrl = cadPlacement.modelObjUrl\n modelStepUrl = cadPlacement.modelStepUrl\n } else if (cadComponent?.model_obj_url) {\n const isValidUrl = await checkModelObjUrlValidity(\n cadComponent.model_obj_url,\n )\n if (isValidUrl) {\n modelObjUrl = cadComponent.model_obj_url\n modelStepUrl = cadComponent.model_step_url\n }\n }\n\n const supplierPartNumbers: Record<string, string[]> = {\n jlcpcb: [betterEasy.lcsc.number],\n }\n\n return generateTypescriptComponent({\n componentName: pn,\n manufacturerPartNumber: pn,\n pinLabels,\n\n objUrl: modelObjUrl,\n stepUrl: modelStepUrl,\n circuitJson,\n supplierPartNumbers,\n })\n}\n\nconst checkModelObjUrlValidity = async (url: string): Promise<boolean> => {\n try {\n const response = await fetch(url, { method: \"HEAD\" })\n return response.status === 200\n } catch (error) {\n console.error(`Error checking model object URL ${url}:`, error)\n return false\n }\n}\n","import { fetchEasyEDAComponent } from \"lib/websafe/fetch-easyeda-json\"\nimport { convertEasyEdaJsonToCircuitJson } from \"lib/convert-easyeda-json-to-tscircuit-soup-json\"\nimport fs from \"fs/promises\"\nimport { EasyEdaJsonSchema } from \"lib/schemas/easy-eda-json-schema\"\nimport { convertRawEasyToTsx } from \"lib/websafe/convert-to-typescript-component\"\nimport * as path from \"path\"\nimport { normalizeManufacturerPartNumber } from \"lib/utils/normalize-manufacturer-part-number\"\n\nexport const convertEasyEdaJsonToVariousFormats = async ({\n jlcpcbPartNumberOrFilepath,\n outputFilename,\n outputFormat,\n}: {\n jlcpcbPartNumberOrFilepath: string\n outputFilename: string\n outputFormat: string\n}) => {\n let rawEasyEdaJson\n if (\n jlcpcbPartNumberOrFilepath.includes(\".\") ||\n jlcpcbPartNumberOrFilepath.includes(\"/\")\n ) {\n rawEasyEdaJson = JSON.parse(\n await fs.readFile(jlcpcbPartNumberOrFilepath, \"utf-8\"),\n )\n } else {\n rawEasyEdaJson = await fetchEasyEDAComponent(jlcpcbPartNumberOrFilepath)\n }\n\n const tsxExtension = \"tsx\"\n if (outputFormat === \"ts\") outputFormat = tsxExtension\n\n if (!outputFilename && outputFormat) {\n let filename = path.basename(jlcpcbPartNumberOrFilepath).split(\".\")[0]\n\n if (outputFormat === tsxExtension) {\n const {\n dataStr: {\n head: {\n c_para: { \"Manufacturer Part\": manufacturerPartNumber },\n },\n },\n } = rawEasyEdaJson\n\n filename = normalizeManufacturerPartNumber(manufacturerPartNumber)\n }\n\n outputFilename = `${filename}.${outputFormat}`\n }\n\n if (!outputFilename) {\n console.log(\"specify --output file (-o) or --output-format\")\n process.exit(1)\n }\n\n if (outputFilename.endsWith(\".raweasy.json\")) {\n await fs.writeFile(outputFilename, JSON.stringify(rawEasyEdaJson, null, 2))\n console.log(`Saved raw EasyEDA JSON: ${outputFilename}`)\n return\n }\n\n try {\n const betterEasy = EasyEdaJsonSchema.parse(rawEasyEdaJson)\n const tscircuitSoup = convertEasyEdaJsonToCircuitJson(betterEasy)\n\n if (\n outputFilename.endsWith(\".soup.json\") ||\n outputFilename.endsWith(\".circuit.json\")\n ) {\n await fs.writeFile(outputFilename, JSON.stringify(tscircuitSoup, null, 2))\n console.log(\n `[${jlcpcbPartNumberOrFilepath}] Converted to circuit json: ${outputFilename}`,\n )\n } else if (outputFilename.endsWith(\".kicad_mod\")) {\n // TODO: Implement conversion to KiCad footprint\n console.log(\"Conversion to KiCad footprint not yet implemented\")\n } else if (outputFilename.endsWith(\".bettereasy.json\")) {\n await fs.writeFile(outputFilename, JSON.stringify(betterEasy, null, 2))\n console.log(\n `[${jlcpcbPartNumberOrFilepath}] Saved better EasyEDA JSON: ${outputFilename}`,\n )\n } else if (\n outputFilename.endsWith(\".tsx\") ||\n outputFilename.endsWith(\".ts\")\n ) {\n const tsComp = await convertRawEasyToTsx(rawEasyEdaJson)\n await fs.writeFile(outputFilename, tsComp)\n console.log(\n `[${jlcpcbPartNumberOrFilepath}] Saved TypeScript component: ${outputFilename}`,\n )\n } else {\n console.error(\"Unsupported output format\")\n }\n } catch (error: any) {\n console.error(\"Error:\", error.message)\n throw error\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACCA,SAAS,SAAS;ACDlB,SAAS,KAAAA,UAAS;AEAlB,SAAS,KAAAA,UAAS;ACAlB,SAAS,KAAAA,UAAS;ACAlB,SAAS,KAAAA,UAAS;ACAlB,SAAS,KAAAA,UAAS;ACAlB,SAAS,KAAAA,UAAS;ACAlB,SAAS,KAAAA,UAAS;ACAlB,SAAS,KAAAA,UAAS;ACAlB,SAAS,KAAAA,WAAS;ACAlB,SAAS,KAAAA,WAAS;ACAlB,SAAS,KAAAA,WAAS;ACAlB,SAAS,KAAAA,WAAS;ACKlB,SAAS,KAAAA,WAAS;ACLlB,SAAS,KAAAA,WAAS;ACIlB,SAAS,KAAAA,WAAS;ACJlB,SAAS,KAAAA,WAAS;ACIlB,SAAS,KAAAA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EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AACN,CAAC;AAKM,IAAM,mBAAmB;AAuBhC,iBAGE,IAAI;AAaN,wBAYE,IAAI;;;AClMC,SAAS,aAAc,QAAQG,QAAO;AAC3C,SAAO,MAAM,QAAQA,MAAK,IACtB;AAAA,IACE,OAAO,IAAIA,OAAM,CAAC,IAAI,OAAO,IAAIA,OAAM,CAAC,IAAI,OAAO;AAAA,IACnD,OAAO,IAAIA,OAAM,CAAC,IAAI,OAAO,IAAIA,OAAM,CAAC,IAAI,OAAO;AAAA,EACrD,IACA;AAAA,IACE,GAAG,OAAO,IAAIA,OAAM,IAAI,OAAO,IAAIA,OAAM,IAAI,OAAO;AAAA,IACpD,GAAG,OAAO,IAAIA,OAAM,IAAI,OAAO,IAAIA,OAAM,IAAI,OAAO;AAAA,EACtD;AACN;;;AChBO,SAAS,YAAa,KAAK;AAChC,SAAO,OAAO,QAAQ;AACxB;;;ACIO,SAAS,UAAW,IAAI,KAAK,GAAG;AACrC,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AACF;;;ACVO,SAAS,aAAc,UAAU;AACtC,aAAW,MAAM,QAAQ,SAAS,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI;AAEtD,QAAM,WAAW,CAAC,IAAI,O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C,UAAU;AAEhE,QACE,eAAe,SAAS,YAAY,KACpC,eAAe,SAAS,eAAe,GACvC;AACA,YAAM,GAAG,UAAU,gBAAgB,KAAK,UAAU,eAAe,MAAM,CAAC,CAAC;AACzE,cAAQ;AAAA,QACN,IAAI,0BAA0B,iCAAiC,cAAc;AAAA,MAC/E;AAAA,IACF,WAAW,eAAe,SAAS,YAAY,GAAG;AAEhD,cAAQ,IAAI,mDAAmD;AAAA,IACjE,WAAW,eAAe,SAAS,kBAAkB,GAAG;AACtD,YAAM,GAAG,UAAU,gBAAgB,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC;AACtE,cAAQ;AAAA,QACN,IAAI,0BAA0B,iCAAiC,cAAc;AAAA,MAC/E;AAAA,IACF,WACE,eAAe,SAAS,MAAM,KAC9B,eAAe,SAAS,KAAK,GAC7B;AACA,YAAM,SAAS,MAAM,oBAAoB,cAAc;AACvD,YAAM,GAAG,UAAU,gBAAgB,MAAM;AACzC,cAAQ;AAAA,QACN,IAAI,0BAA0B,iCAAiC,cAAc;AAAA,MAC/E;AAAA,IACF,OAAO;AACL,cAAQ,MAAM,2BAA2B;AAAA,IAC3C;AAAA,EACF,SAAS,OAAY;AACnB,YAAQ,MAAM,UAAU,MAAM,OAAO;AACrC,UAAM;AAAA,EACR;AACF;","names":["z","length","percentage","point","m","expected","found","rotation","su","component_type","source_port","joiner","Soup","source_port","point","point","distance","path","angle","point","pcb_component","position","rotation","z","fetch","z","z","pairs","rotation","point","size","z","PointSchema","z","rotation","path","parsePoints","z","parseObjBounds","z","fetch","rotation"]}
|
|
1
|
+
{"version":3,"sources":["../node_modules/circuit-json/src/utils/convert-si-unit-to-number.ts","../node_modules/circuit-json/src/units/index.ts","../node_modules/circuit-json/src/common/point.ts","../node_modules/circuit-json/src/utils/expect-types-match.ts","../node_modules/circuit-json/src/common/point3.ts","../node_modules/circuit-json/src/common/size.ts","../node_modules/circuit-json/src/common/getZodPrefixedIdWithDefault.ts","../node_modules/circuit-json/src/common/NinePointAnchor.ts","../node_modules/circuit-json/src/common/PcbRenderLayer.ts","../node_modules/circuit-json/src/common/asset.ts","../node_modules/circuit-json/src/common/kicadFootprintMetadata.ts","../node_modules/circuit-json/src/common/kicadSymbolMetadata.ts","../node_modules/circuit-json/src/base_circuit_json_error.ts","../node_modules/circuit-json/src/source/source_simple_capacitor.ts","../node_modules/circuit-json/src/pcb/properties/supplier_name.ts","../node_modules/circuit-json/src/source/base/source_component_base.ts","../node_modules/circuit-json/src/source/source_simple_resistor.ts","../node_modules/circuit-json/src/source/source_simple_diode.ts","../node_modules/circuit-json/src/source/source_simple_fiducial.ts","../node_modules/circuit-json/src/source/source_simple_led.ts","../node_modules/circuit-json/src/source/source_simple_ground.ts","../node_modules/circuit-json/src/source/source_simple_chip.ts","../node_modules/circuit-json/src/source/source_simple_power_source.ts","../node_modules/circuit-json/src/source/source_simple_current_source.ts","../node_modules/circuit-json/src/source/properties/source_pin_attributes.ts","../node_modules/circuit-json/src/source/any_source_component.ts","../node_modules/circuit-json/src/source/source_simple_fuse.ts","../node_modules/circuit-json/src/source/source_simple_battery.ts","../node_modules/circuit-json/src/source/source_simple_inductor.ts","../node_modules/circuit-json/src/source/source_simple_push_button.ts","../node_modules/circuit-json/src/source/source_simple_potentiometer.ts","../node_modules/circuit-json/src/source/source_simple_crystal.ts","../node_modules/circuit-json/src/source/source_simple_pin_header.ts","../node_modules/circuit-json/src/source/source_simple_connector.ts","../node_modules/circuit-json/src/source/source_simple_pinout.ts","../node_modules/circuit-json/src/source/source_simple_resonator.ts","../node_modules/circuit-json/src/source/source_simple_transistor.ts","../node_modules/circuit-json/src/source/source_simple_test_point.ts","../node_modules/circuit-json/src/source/source_simple_mosfet.ts","../node_modules/circuit-json/src/source/source_simple_op_amp.ts","../node_modules/circuit-json/src/source/source_simple_switch.ts","../node_modules/circuit-json/src/source/source_project_metadata.ts","../node_modules/circuit-json/src/source/source_missing_property_error.ts","../node_modules/circuit-json/src/source/source_failed_to_create_component_error.ts","../node_modules/circuit-json/src/source/source_invalid_component_property_error.ts","../node_modules/circuit-json/src/source/source_trace_not_connected_error.ts","../node_modules/circuit-json/src/source/source_property_ignored_warning.ts","../node_modules/circuit-json/src/source/source_pin_missing_trace_warning.ts","../node_modules/circuit-json/src/source/source_simple_voltage_probe.ts","../node_modules/circuit-json/src/source/source_interconnect.ts","../node_modules/circuit-json/src/source/source_i2c_misconfigured_error.ts","../node_modules/circuit-json/src/source/source_simple_voltage_source.ts","../node_modules/circuit-json/src/source/source_port.ts","../node_modules/circuit-json/src/source/source_component_internal_connection.ts","../node_modules/circuit-json/src/source/source_trace.ts","../node_modules/circuit-json/src/source/source_group.ts","../node_modules/circuit-json/src/source/source_net.ts","../node_modules/circuit-json/src/source/source_board.ts","../node_modules/circuit-json/src/source/source_ambiguous_port_reference.ts","../node_modules/circuit-json/src/source/source_pcb_ground_plane.ts","../node_modules/circuit-json/src/source/source_manually_placed_via.ts","../node_modules/circuit-json/src/pcb/properties/layer_ref.ts","../node_modules/circuit-json/src/source/source_no_power_pin_defined_warning.ts","../node_modules/circuit-json/src/source/source_no_ground_pin_defined_warning.ts","../node_modules/circuit-json/src/source/source_component_pins_underspecified_warning.ts","../node_modules/circuit-json/src/source/source_pin_must_be_connected_error.ts","../node_modules/circuit-json/src/source/unknown_error_finding_part.ts","../node_modules/circuit-json/src/schematic/schematic_box.ts","../node_modules/circuit-json/src/schematic/schematic_path.ts","../node_modules/circuit-json/src/schematic/schematic_component.ts","../node_modules/circuit-json/src/schematic/schematic_symbol.ts","../node_modules/circuit-json/src/schematic/schematic_line.ts","../node_modules/circuit-json/src/schematic/schematic_rect.ts","../node_modules/circuit-json/src/schematic/schematic_circle.ts","../node_modules/circuit-json/src/schematic/schematic_arc.ts","../node_modules/circuit-json/src/schematic/schematic_trace.ts","../node_modules/circuit-json/src/schematic/schematic_text.ts","../node_modules/circuit-json/src/common/FivePointAnchor.ts","../node_modules/circuit-json/src/schematic/schematic_port.ts","../node_modules/circuit-json/src/schematic/schematic_net_label.ts","../node_modules/circuit-json/src/schematic/schematic_error.ts","../node_modules/circuit-json/src/schematic/schematic_layout_error.ts","../node_modules/circuit-json/src/schematic/schematic_debug_object.ts","../node_modules/circuit-json/src/schematic/schematic_voltage_probe.ts","../node_modules/circuit-json/src/schematic/schematic_manual_edit_conflict_warning.ts","../node_modules/circuit-json/src/schematic/schematic_group.ts","../node_modules/circuit-json/src/schematic/schematic_table.ts","../node_modules/circuit-json/src/schematic/schematic_table_cell.ts","../node_modules/circuit-json/src/schematic/schematic_sheet.ts","../node_modules/circuit-json/src/pcb/properties/brep.ts","../node_modules/circuit-json/src/pcb/properties/pcb_route_hints.ts","../node_modules/circuit-json/src/pcb/properties/route_hint_point.ts","../node_modules/circuit-json/src/pcb/pcb_component.ts","../node_modules/circuit-json/src/pcb/pcb_hole.ts","../node_modules/circuit-json/src/pcb/pcb_plated_hole.ts","../node_modules/circuit-json/src/pcb/pcb_port.ts","../node_modules/circuit-json/src/pcb/pcb_smtpad.ts","../node_modules/circuit-json/src/pcb/pcb_solder_paste.ts","../node_modules/circuit-json/src/pcb/pcb_text.ts","../node_modules/circuit-json/src/pcb/pcb_trace.ts","../node_modules/circuit-json/src/pcb/pcb_trace_error.ts","../node_modules/circuit-json/src/pcb/pcb_trace_missing_error.ts","../node_modules/circuit-json/src/pcb/pcb_port_not_matched_error.ts","../node_modules/circuit-json/src/pcb/pcb_port_not_connected_error.ts","../node_modules/circuit-json/src/pcb/pcb_net.ts","../node_modules/circuit-json/src/pcb/pcb_via.ts","../node_modules/circuit-json/src/pcb/pcb_board.ts","../node_modules/circuit-json/src/pcb/pcb_panel.ts","../node_modules/circuit-json/src/pcb/pcb_placement_error.ts","../node_modules/circuit-json/src/pcb/pcb_panelization_placement_error.ts","../node_modules/circuit-json/src/pcb/pcb_trace_hint.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_line.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_path.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_text.ts","../node_modules/circuit-json/src/pcb/pcb_copper_text.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_rect.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_circle.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_oval.ts","../node_modules/circuit-json/src/pcb/pcb_silkscreen_pill.ts","../node_modules/circuit-json/src/pcb/pcb_fabrication_note_text.ts","../node_modules/circuit-json/src/pcb/pcb_fabrication_note_path.ts","../node_modules/circuit-json/src/pcb/pcb_fabrication_note_rect.ts","../node_modules/circuit-json/src/pcb/pcb_fabrication_note_dimension.ts","../node_modules/circuit-json/src/pcb/pcb_note_text.ts","../node_modules/circuit-json/src/pcb/pcb_note_rect.ts","../node_modules/circuit-json/src/pcb/pcb_note_path.ts","../node_modules/circuit-json/src/pcb/pcb_note_line.ts","../node_modules/circuit-json/src/pcb/pcb_note_dimension.ts","../node_modules/circuit-json/src/pcb/pcb_footprint_overlap_error.ts","../node_modules/circuit-json/src/pcb/pcb_courtyard_overlap_error.ts","../node_modules/circuit-json/src/pcb/pcb_keepout.ts","../node_modules/circuit-json/src/pcb/pcb_cutout.ts","../node_modules/circuit-json/src/pcb/pcb_missing_footprint_error.ts","../node_modules/circuit-json/src/pcb/external_footprint_load_error.ts","../node_modules/circuit-json/src/pcb/circuit_json_footprint_load_error.ts","../node_modules/circuit-json/src/pcb/pcb_group.ts","../node_modules/circuit-json/src/pcb/pcb_autorouting_error.ts","../node_modules/circuit-json/src/pcb/pcb_manual_edit_conflict_warning.ts","../node_modules/circuit-json/src/pcb/pcb_connector_not_in_accessible_orientation_warning.ts","../node_modules/circuit-json/src/pcb/pcb_breakout_point.ts","../node_modules/circuit-json/src/pcb/pcb_ground_plane.ts","../node_modules/circuit-json/src/pcb/pcb_ground_plane_region.ts","../node_modules/circuit-json/src/pcb/pcb_thermal_spoke.ts","../node_modules/circuit-json/src/pcb/pcb_copper_pour.ts","../node_modules/circuit-json/src/pcb/pcb_component_outside_board_error.ts","../node_modules/circuit-json/src/pcb/pcb_component_not_on_board_edge_error.ts","../node_modules/circuit-json/src/pcb/pcb_component_invalid_layer_error.ts","../node_modules/circuit-json/src/pcb/pcb_via_clearance_error.ts","../node_modules/circuit-json/src/pcb/pcb_courtyard_rect.ts","../node_modules/circuit-json/src/pcb/pcb_courtyard_outline.ts","../node_modules/circuit-json/src/pcb/pcb_courtyard_polygon.ts","../node_modules/circuit-json/src/pcb/pcb_courtyard_circle.ts","../node_modules/circuit-json/src/cad/cad_component.ts","../node_modules/circuit-json/src/cad/cad_model_conventions.ts","../node_modules/circuit-json/src/simulation/simulation_voltage_source.ts","../node_modules/circuit-json/src/simulation/simulation_current_source.ts","../node_modules/circuit-json/src/simulation/simulation_experiment.ts","../node_modules/circuit-json/src/simulation/simulation_transient_voltage_graph.ts","../node_modules/circuit-json/src/simulation/simulation_switch.ts","../node_modules/circuit-json/src/simulation/simulation_voltage_probe.ts","../node_modules/circuit-json/src/simulation/simulation_unknown_experiment_error.ts","../node_modules/circuit-json/src/simulation/simulation_op_amp.ts","../node_modules/circuit-json/src/any_circuit_element.ts","../node_modules/transformation-matrix/src/applyToPoint.js","../node_modules/transformation-matrix/src/utils.js","../node_modules/transformation-matrix/src/translate.js","../node_modules/transformation-matrix/src/transform.js","../node_modules/transformation-matrix/src/rotate.js","../node_modules/transformation-matrix/src/scale.js","../node_modules/transformation-matrix/src/skew.js","../node_modules/transformation-matrix/src/fromTransformAttribute.autogenerated.js","../node_modules/transformation-matrix/src/decompose.js","../node_modules/@tscircuit/circuit-json-util/lib/cju.ts","../node_modules/@tscircuit/circuit-json-util/lib/subtree.ts","../node_modules/@tscircuit/circuit-json-util/lib/cju-indexed.ts","../node_modules/@tscircuit/circuit-json-util/lib/transform-soup-elements.ts","../node_modules/@tscircuit/circuit-json-util/lib/direction-to-vec.ts","../node_modules/@tscircuit/circuit-json-util/lib/apply-selector.ts","../node_modules/@tscircuit/circuit-json-util/lib/convert-abbreviation-to-soup-element-type.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-element-id.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-element-by-id.ts","../node_modules/@tscircuit/circuit-json-util/lib/readable-name-functions/get-readable-name-for-pcb-trace.ts","../node_modules/@tscircuit/circuit-json-util/lib/readable-name-functions/get-readable-name-for-pcb-port.ts","../node_modules/@tscircuit/circuit-json-util/lib/readable-name-functions/get-readable-name-for-pcb-smtpad.ts","../node_modules/@tscircuit/circuit-json-util/lib/readable-name-functions/get-readable-name-for-element.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-bounds-of-pcb-elements.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-board-bounds.ts","../node_modules/@tscircuit/circuit-json-util/lib/utils/string-hash.ts","../node_modules/@tscircuit/circuit-json-util/lib/utils/get-layout-debug-object.ts","../node_modules/@tscircuit/circuit-json-util/lib/utils/is-truthy.ts","../node_modules/@tscircuit/circuit-json-util/lib/find-bounds-and-center.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-primary-id.ts","../node_modules/@tscircuit/circuit-json-util/lib/reposition-pcb-component.ts","../node_modules/@tscircuit/circuit-json-util/lib/reposition-pcb-group.ts","../node_modules/@tscircuit/circuit-json-util/lib/reposition-schematic-component.ts","../node_modules/@tscircuit/circuit-json-util/lib/reposition-schematic-group.ts","../node_modules/@tscircuit/circuit-json-util/lib/getCircuitJsonTree.ts","../node_modules/@tscircuit/circuit-json-util/lib/getStringFromCircuitJsonTree.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-minimum-flex-container.ts","../node_modules/@tscircuit/circuit-json-util/lib/get-element-render-layers.ts","../node_modules/@tscircuit/circuit-json-util/lib/shape-distances/geometry.ts","../node_modules/@tscircuit/circuit-json-util/lib/shape-distances/decompose-copper-into-shapes.ts","../node_modules/@tscircuit/circuit-json-util/lib/shape-distances/distance-between-shapes.ts","../node_modules/@tscircuit/circuit-json-util/lib/compute-gap-between-copper.ts","../node_modules/@tscircuit/circuit-json-util/lib/shape-distances/decompose-clearance-into-shapes.ts","../node_modules/@tscircuit/circuit-json-util/lib/compute-clearance-between-elements.ts","../node_modules/@tscircuit/circuit-json-util/lib/categorize-error-or-warning.ts","../node_modules/@tscircuit/mm/index.ts","../lib/math/arc-utils.ts","../lib/utils/easyeda-unit-to-mm.ts","../lib/utils/normalize-pin-labels.ts","../lib/utils/normalize-symbol-name.ts","../lib/constants.ts","../lib/convert-easyeda-json-to-tscircuit-soup-json.ts","../lib/websafe/get-model-cdn-url.ts","../lib/websafe/fetch-easyeda-json.ts","../lib/schemas/easy-eda-json-schema.ts","../lib/schemas/package-detail-shape-schema.ts","../lib/schemas/single-letter-shape-schema.ts","../lib/utils/normalize-manufacturer-part-number.ts","../lib/websafe/get-easyeda-cad-placement-helpers.ts","../lib/websafe/get-easyeda-cad-model-placement.ts","../lib/websafe/generate-footprint-tsx.ts","../lib/websafe/convert-to-typescript-component/generate-typescript-component.ts","../lib/websafe/convert-to-typescript-component/index.tsx","../lib/convert-easyeda-json-to-various-formats.ts"],"sourcesContent":["type UnitInfo = {\n baseUnit: BaseTscircuitUnit\n conversionFactor: number\n}\n\nconst unitMappings: Record<\n string,\n { baseUnit: BaseTscircuitUnit; variants: Record<string, number> }\n> = {\n Hz: {\n baseUnit: \"Hz\",\n variants: {\n MHz: 1e6,\n kHz: 1e3,\n Hz: 1,\n },\n },\n g: {\n baseUnit: \"g\",\n variants: {\n kg: 1e3,\n g: 1,\n },\n },\n Ω: {\n baseUnit: \"Ω\",\n variants: {\n mΩ: 1e-3,\n Ω: 1,\n kΩ: 1e3,\n KΩ: 1e3,\n kohm: 1e3,\n MΩ: 1e6,\n GΩ: 1e9,\n TΩ: 1e12,\n },\n },\n V: {\n baseUnit: \"V\",\n variants: {\n mV: 1e-3,\n V: 1,\n kV: 1e3,\n KV: 1e3,\n MV: 1e6,\n GV: 1e9,\n TV: 1e12,\n },\n },\n A: {\n baseUnit: \"A\",\n variants: {\n µA: 1e-6,\n mA: 1e-3,\n ma: 1e-3,\n A: 1,\n kA: 1e3,\n MA: 1e6,\n },\n },\n F: {\n baseUnit: \"F\",\n variants: {\n pF: 1e-12,\n nF: 1e-9,\n µF: 1e-6,\n uF: 1e-6,\n mF: 1e-3,\n F: 1,\n },\n },\n ml: {\n baseUnit: \"ml\",\n variants: {\n ml: 1,\n mL: 1,\n l: 1e3,\n L: 1e3,\n },\n },\n deg: {\n baseUnit: \"deg\",\n variants: {\n rad: 180 / Math.PI,\n },\n },\n ms: {\n baseUnit: \"ms\",\n variants: {\n fs: 1e-12,\n ps: 1e-9,\n ns: 1e-6,\n us: 1e-3,\n µs: 1e-3,\n ms: 1,\n s: 1000,\n },\n },\n mm: {\n baseUnit: \"mm\",\n variants: {\n nm: 1e-6,\n µm: 1e-3,\n um: 1e-3,\n mm: 1,\n cm: 10,\n dm: 100,\n m: 1000,\n km: 1e6,\n in: 25.4,\n ft: 304.8,\n IN: 25.4,\n FT: 304.8,\n yd: 914.4,\n mi: 1.609344e6,\n mil: 0.0254,\n },\n },\n}\n\nconst unitMappingAndVariantSuffixes = new Set()\nfor (const [baseUnit, info] of Object.entries(unitMappings)) {\n unitMappingAndVariantSuffixes.add(baseUnit)\n for (const variant of Object.keys(info.variants)) {\n unitMappingAndVariantSuffixes.add(variant)\n }\n}\n\nfunction getBaseTscircuitUnit(unit: string): UnitInfo {\n for (const [baseUnit, info] of Object.entries(unitMappings)) {\n if (unit in info.variants) {\n return {\n baseUnit: info.baseUnit,\n conversionFactor: info.variants[unit]!,\n }\n }\n }\n return {\n baseUnit: unit as BaseTscircuitUnit,\n conversionFactor: 1,\n }\n}\n\nconst si_prefix_multiplier = {\n tera: 1e12,\n T: 1e12,\n giga: 1e9,\n G: 1e9,\n mega: 1e6,\n M: 1e6,\n kilo: 1e3,\n k: 1e3,\n deci: 1e-1,\n d: 1e-1,\n centi: 1e-2,\n c: 1e-2,\n milli: 1e-3,\n m: 1e-3,\n micro: 1e-6,\n u: 1e-6,\n µ: 1e-6,\n nano: 1e-9,\n n: 1e-9,\n pico: 1e-12,\n p: 1e-12,\n}\ntype BaseTscircuitUnit =\n | \"ms\"\n | \"mm\"\n | \"g\"\n | \"deg\"\n | \"Hz\"\n | \"ml\"\n | \"V\"\n | \"A\"\n | \"Ω\"\n | \"F\"\n | \"H\"\n\nexport function parseAndConvertSiUnit(v: {\n x: string | number\n y: string | number\n}): {\n parsedUnit: string | null\n unitOfValue: BaseTscircuitUnit | null\n value: { x: number; y: number } | null\n}\nexport function parseAndConvertSiUnit(v: string | number | undefined | null): {\n parsedUnit: string | null\n unitOfValue: BaseTscircuitUnit | null\n value: number | null\n}\nexport function parseAndConvertSiUnit(\n v:\n | string\n | number\n | undefined\n | null\n | { x: string | number; y: string | number },\n): {\n parsedUnit: string | null\n unitOfValue: BaseTscircuitUnit | null\n value: null | number | { x: number; y: number }\n} {\n if (v === undefined || v === null)\n return { parsedUnit: null, unitOfValue: null, value: null }\n if (typeof v === \"string\" && v.match(/^-?[\\d\\.]+$/))\n return {\n value: Number.parseFloat(v),\n parsedUnit: null,\n unitOfValue: null,\n }\n if (typeof v === \"number\")\n return { value: v, parsedUnit: null, unitOfValue: null }\n if (typeof v === \"object\" && \"x\" in v && \"y\" in v) {\n const { parsedUnit, unitOfValue } = parseAndConvertSiUnit(v.x)\n const xResult = parseAndConvertSiUnit(v.x)\n const yResult = parseAndConvertSiUnit(v.y)\n if (xResult.value === null || yResult.value === null) {\n return { parsedUnit: null, unitOfValue: null, value: null }\n }\n return {\n parsedUnit: parsedUnit,\n unitOfValue: unitOfValue,\n value: {\n x: xResult.value,\n y: yResult.value,\n },\n }\n }\n const reversed_input_string = v.toString().split(\"\").reverse().join(\"\")\n const unit_reversed = reversed_input_string.match(/[^\\d\\s]+/)?.[0]\n if (!unit_reversed) {\n throw new Error(`Could not determine unit: \"${v}\"`)\n }\n const unit = unit_reversed.split(\"\").reverse().join(\"\")\n\n const numberPart = v.slice(0, -unit.length)\n if (\n unit in si_prefix_multiplier &&\n !unitMappingAndVariantSuffixes.has(unit)\n ) {\n const siMultiplier =\n si_prefix_multiplier[unit as keyof typeof si_prefix_multiplier]\n return {\n parsedUnit: null,\n unitOfValue: null,\n value: Number.parseFloat(numberPart) * siMultiplier,\n }\n }\n\n const { baseUnit, conversionFactor } = getBaseTscircuitUnit(unit)\n\n return {\n parsedUnit: unit,\n unitOfValue: baseUnit,\n value: conversionFactor * Number.parseFloat(numberPart),\n }\n}\n","import { parseAndConvertSiUnit } from \"src/utils/convert-si-unit-to-number\"\nimport { z } from \"zod\"\n\n// // Currently, removing uncommon SI Prefixes for type simplicity.\n// export type SIPrefix =\n// // | \"y\"\n// // | \"yocto\"\n// // | \"z\"\n// // | \"zepto\"\n// // | \"atto\"\n// // | \"a\"\n// | \"femto\"\n// | \"f\"\n// | \"u\"\n// | \"micro\"\n// // | \"d\"\n// // | \"deci\"\n// | \"c\"\n// | \"centi\"\n// | \"m\"\n// | \"milli\"\n// | \"k\"\n// | \"kilo\"\n// | \"M\"\n// | \"mega\"\n// // | \"G\"\n// // | \"T\"\n// // | \"P\"\n// // | \"E\"\n// // | \"Z\"\n// // | \"Y\"\n\n// export type UnitAbbreviations = {\n// farad: \"F\"\n// ohm: \"Ω\"\n// henry: \"H\"\n// meter: \"m\"\n// volt: \"V\"\n// inch: \"in\"\n// foot: \"ft\"\n// }\n\n// export type Unit = keyof UnitAbbreviations\n// export type NumberWithUnit<T extends Unit> =\n// | `${number}${T | UnitAbbreviations[T]}`\n// | `${number} ${T | UnitAbbreviations[T]}`\n// | `${number}${SIPrefix}${T | UnitAbbreviations[T]}`\n// | `${number} ${SIPrefix}${T | UnitAbbreviations[T]}`\n// export type NumberWithAnyUnit =\n// | `${number}${UnitOrAbbreviation}`\n// | `${number} ${UnitOrAbbreviation}`\n// | `${number}${SIPrefix}${UnitOrAbbreviation}`\n// | `${number} ${SIPrefix}${UnitOrAbbreviation}`\n\n// TODO lots of validation to make sure the unit is valid etc.\nexport const resistance = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const capacitance = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n .transform((value) => {\n return Number.parseFloat(value.toPrecision(12)) // Round to 12 significant digits\n })\n\nexport const inductance = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const voltage = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const length = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const frequency = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\n/**\n * Length in meters\n */\nexport type Length = number\nexport type Distance = number\n\nexport const distance = length\n\nexport const current = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const duration_ms = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\n\nexport const time = duration_ms\n\nexport const ms = duration_ms\n\nexport const timestamp = z.string().datetime()\n\n/**\n * Rotation is always converted to degrees\n */\nexport const rotation = z\n .string()\n .or(z.number())\n .transform((arg): number => {\n if (typeof arg === \"number\") return arg\n if (arg.endsWith(\"deg\")) {\n return Number.parseFloat(arg.split(\"deg\")[0]!)\n }\n if (arg.endsWith(\"rad\")) {\n return (Number.parseFloat(arg.split(\"rad\")[0]!) * 180) / Math.PI\n }\n return Number.parseFloat(arg)\n })\n\nexport const battery_capacity = z\n .number()\n .or(z.string().endsWith(\"mAh\"))\n .transform((v) => {\n if (typeof v === \"string\") {\n const valString = v.replace(\"mAh\", \"\")\n const num = Number.parseFloat(valString)\n if (Number.isNaN(num)) {\n throw new Error(\"Invalid capacity\")\n }\n return num\n }\n return v\n })\n .describe(\"Battery capacity in mAh\")\n\nexport type InputRotation = number | string\nexport type Rotation = number\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const point = z.object({\n x: distance,\n y: distance,\n})\n\nexport const position = point\n\nexport type InputPoint = z.input<typeof point>\nexport type InputPosition = z.input<typeof position>\ntype InferredPoint = z.infer<typeof point>\ntype InferredPosition = z.infer<typeof position>\n\nexport interface Point {\n x: number\n y: number\n}\n\nexport interface Position {\n x: number\n y: number\n}\n\nexpectTypesMatch<Point, InferredPoint>(true)\nexpectTypesMatch<Position, InferredPosition>(true)\n","import type { TypeEqual } from \"ts-expect\"\n\ntype IsNever<T> = [T] extends [never] ? true : false\n\ntype GetMismatchedProps<T1, T2> = {\n [K in keyof T1 & keyof T2]: T1[K] extends T2[K]\n ? T2[K] extends T1[K]\n ? never\n : K\n : K\n}[keyof T1 & keyof T2]\n\nexport const expectTypesMatch = <\n const T1,\n const T2,\n T3 = Exclude<keyof T1, keyof T2>,\n T4 = Exclude<keyof T2, keyof T1>,\n T5 = GetMismatchedProps<T1, T2>,\n>(\n shouldBe: IsNever<T3> extends true\n ? IsNever<T4> extends true\n ? IsNever<T5> extends true\n ? TypeEqual<T1, T2>\n : `mismatched prop types: ${T5 extends string ? T5 : \"\"}`\n : `extra props ${T4 extends string ? T4 : \"\"}`\n : `missing props ${T3 extends string ? T3 : \"\"}`,\n): void => {}\n\n// ------ TESTS -------\n\nexpectTypesMatch<\n {\n a: number\n },\n {\n a: number\n b: number\n }\n>(\"extra props b\")\n\nexpectTypesMatch<\n {\n a: number\n b: number\n },\n {\n a: number\n }\n>(\"missing props b\")\n\nexpectTypesMatch<\n {\n a: number\n },\n {\n a: number\n }\n>(true)\n\nexpectTypesMatch<\n {\n a: number\n },\n {\n a: string\n }\n>(\"mismatched prop types: a\")\n\n// ------ String Union Matching -------\n\nexport type ExpectStringUnionsMatch<\n T1 extends string,\n T2 extends string,\n Diff1 = Exclude<T1, T2>,\n Diff2 = Exclude<T2, T1>,\n> = IsNever<Diff1> extends true\n ? IsNever<Diff2> extends true\n ? true // Unions are identical\n : `T2 has extra: \"${Diff2 extends string ? Diff2 : \"\"}\"` // T2 has elements not in T1\n : IsNever<Diff2> extends true\n ? `T1 has extra: \"${Diff1 extends string ? Diff1 : \"\"}\"` // T1 has elements not in T2\n : `T1 has extra: \"${Diff1 extends string\n ? Diff1\n : \"\"}\", T2 has extra: \"${Diff2 extends string ? Diff2 : \"\"}\"` // Both have differences\n\nexport const expectStringUnionsMatch = <\n const T1 extends string,\n const T2 extends string,\n ShouldBeTrue = ExpectStringUnionsMatch<T1, T2>,\n>(\n shouldBe: ShouldBeTrue,\n): void => {}\n\n// ------ TESTS -------\n\ntype TestUnion1 = \"a\" | \"b\" | \"c\"\ntype TestUnion2 = \"a\" | \"b\" | \"c\"\ntype TestUnion3 = \"a\" | \"b\" | \"d\"\ntype TestUnion4 = \"a\" | \"b\"\n\nexpectStringUnionsMatch<TestUnion1, TestUnion2>(true)\nexpectStringUnionsMatch<TestUnion1, TestUnion3>(\n 'T1 has extra: \"c\", T2 has extra: \"d\"',\n)\nexpectStringUnionsMatch<TestUnion1, TestUnion4>('T1 has extra: \"c\"')\nexpectStringUnionsMatch<TestUnion4, TestUnion1>('T2 has extra: \"c\"')\nexpectStringUnionsMatch<TestUnion3, TestUnion1>(\n 'T1 has extra: \"d\", T2 has extra: \"c\"',\n)\n\n// Example of using @ts-expect-error for expected failures\n// @ts-expect-error Type '\"T2 has extra: \\\"d\\\"\"' is not assignable to type 'true'.\nexpectStringUnionsMatch<TestUnion1, TestUnion3>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const point3 = z.object({\n x: distance,\n y: distance,\n z: distance,\n})\n\nexport const position3 = point3\n\ntype InferredPoint3 = z.infer<typeof point3>\n\nexport interface Point3 {\n x: number\n y: number\n z: number\n}\n\nexpectTypesMatch<Point3, InferredPoint3>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const size = z.object({\n width: z.number(),\n height: z.number(),\n})\n\nexport type SizeInput = z.input<typeof size>\ntype InferredSize = z.infer<typeof size>\n\nexport interface Size {\n width: number\n height: number\n}\n\nexpectTypesMatch<Size, InferredSize>(true)\n","import { z } from \"zod\"\n\n// Generates a random string ID of specified length using alphanumeric characters\nconst randomId = (length: number): string => {\n const chars = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\"\n return Array.from(\n { length },\n () => chars[Math.floor(Math.random() * chars.length)],\n ).join(\"\")\n}\n/**\n * Use this for primary keys for any circuit element\n */\nexport const getZodPrefixedIdWithDefault = (prefix: string) => {\n return z\n .string()\n .optional()\n .default(() => `${prefix}_${randomId(10)}`)\n}\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport type NinePointAnchor =\n | \"top_left\"\n | \"top_center\"\n | \"top_right\"\n | \"center_left\"\n | \"center\"\n | \"center_right\"\n | \"bottom_left\"\n | \"bottom_center\"\n | \"bottom_right\"\n\nexport const ninePointAnchor = z.enum([\n \"top_left\",\n \"top_center\",\n \"top_right\",\n \"center_left\",\n \"center\",\n \"center_right\",\n \"bottom_left\",\n \"bottom_center\",\n \"bottom_right\",\n])\n\ntype InferredNinePointAnchor = z.infer<typeof ninePointAnchor>\n\nexpectTypesMatch<NinePointAnchor, InferredNinePointAnchor>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport type PcbRenderLayer =\n | \"top_silkscreen\"\n | \"bottom_silkscreen\"\n | \"top_copper\"\n | \"bottom_copper\"\n | \"top_soldermask\"\n | \"bottom_soldermask\"\n | \"top_fabrication_note\"\n | \"bottom_fabrication_note\"\n | \"top_user_note\"\n | \"bottom_user_note\"\n | \"top_courtyard\"\n | \"bottom_courtyard\"\n | \"inner1_copper\"\n | \"inner2_copper\"\n | \"inner3_copper\"\n | \"inner4_copper\"\n | \"inner5_copper\"\n | \"inner6_copper\"\n | \"edge_cuts\"\n | \"drill\"\n\nexport const pcbRenderLayer = z.enum([\n \"top_silkscreen\",\n \"bottom_silkscreen\",\n \"top_copper\",\n \"bottom_copper\",\n \"top_soldermask\",\n \"bottom_soldermask\",\n \"top_fabrication_note\",\n \"bottom_fabrication_note\",\n \"top_user_note\",\n \"bottom_user_note\",\n \"top_courtyard\",\n \"bottom_courtyard\",\n \"inner1_copper\",\n \"inner2_copper\",\n \"inner3_copper\",\n \"inner4_copper\",\n \"inner5_copper\",\n \"inner6_copper\",\n \"edge_cuts\",\n \"drill\",\n])\n\ntype InferredPcbRenderLayer = z.infer<typeof pcbRenderLayer>\n\nexpectTypesMatch<PcbRenderLayer, InferredPcbRenderLayer>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const asset = z.object({\n project_relative_path: z.string(),\n url: z.string(),\n mimetype: z.string(),\n})\n\nexport type AssetInput = z.input<typeof asset>\nexport type Asset = z.infer<typeof asset>\n\nexpectTypesMatch<Asset, AssetInput>(true)\n","import { z } from \"zod\"\nimport { point } from \"./point\"\nimport { point3 } from \"./point3\"\nimport { distance, rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface KicadAt {\n x: number\n y: number\n rotation?: number\n}\n\nexport const kicadAt = point.extend({\n rotation: rotation.optional(),\n})\n\ntype InferredKicadAt = z.infer<typeof kicadAt>\nexpectTypesMatch<KicadAt, InferredKicadAt>(true)\n\nexport interface KicadFont {\n size?: { x: number; y: number }\n thickness?: number\n}\n\nexport const kicadFont = z.object({\n size: point.optional(),\n thickness: distance.optional(),\n})\n\ntype InferredKicadFont = z.infer<typeof kicadFont>\nexpectTypesMatch<KicadFont, InferredKicadFont>(true)\n\nexport interface KicadEffects {\n font?: KicadFont\n}\n\nexport const kicadEffects = z.object({\n font: kicadFont.optional(),\n})\n\ntype InferredKicadEffects = z.infer<typeof kicadEffects>\nexpectTypesMatch<KicadEffects, InferredKicadEffects>(true)\n\nexport interface KicadProperty {\n value: string\n at?: KicadAt\n layer?: string\n uuid?: string\n hide?: boolean\n effects?: KicadEffects\n}\n\nexport const kicadProperty = z.object({\n value: z.string(),\n at: kicadAt.optional(),\n layer: z.string().optional(),\n uuid: z.string().optional(),\n hide: z.boolean().optional(),\n effects: kicadEffects.optional(),\n})\n\ntype InferredKicadProperty = z.infer<typeof kicadProperty>\nexpectTypesMatch<KicadProperty, InferredKicadProperty>(true)\n\nexport interface KicadFootprintProperties {\n Reference?: KicadProperty\n Value?: KicadProperty\n Datasheet?: KicadProperty\n Description?: KicadProperty\n}\n\nexport const kicadFootprintProperties = z.object({\n Reference: kicadProperty.optional(),\n Value: kicadProperty.optional(),\n Datasheet: kicadProperty.optional(),\n Description: kicadProperty.optional(),\n})\n\ntype InferredKicadFootprintProperties = z.infer<typeof kicadFootprintProperties>\nexpectTypesMatch<KicadFootprintProperties, InferredKicadFootprintProperties>(\n true,\n)\n\nexport interface KicadFootprintAttributes {\n through_hole?: boolean\n smd?: boolean\n exclude_from_pos_files?: boolean\n exclude_from_bom?: boolean\n}\n\nexport const kicadFootprintAttributes = z.object({\n through_hole: z.boolean().optional(),\n smd: z.boolean().optional(),\n exclude_from_pos_files: z.boolean().optional(),\n exclude_from_bom: z.boolean().optional(),\n})\n\ntype InferredKicadFootprintAttributes = z.infer<typeof kicadFootprintAttributes>\nexpectTypesMatch<KicadFootprintAttributes, InferredKicadFootprintAttributes>(\n true,\n)\n\nexport interface KicadFootprintPad {\n name: string\n type: string\n shape?: string\n at?: KicadAt\n size?: { x: number; y: number }\n drill?: number\n layers?: string[]\n removeUnusedLayers?: boolean\n uuid?: string\n}\n\nexport const kicadFootprintPad = z.object({\n name: z.string(),\n type: z.string(),\n shape: z.string().optional(),\n at: kicadAt.optional(),\n size: point.optional(),\n drill: distance.optional(),\n layers: z.array(z.string()).optional(),\n removeUnusedLayers: z.boolean().optional(),\n uuid: z.string().optional(),\n})\n\ntype InferredKicadFootprintPad = z.infer<typeof kicadFootprintPad>\nexpectTypesMatch<KicadFootprintPad, InferredKicadFootprintPad>(true)\n\nexport interface KicadFootprintModel {\n path: string\n offset?: { x: number; y: number; z: number }\n scale?: { x: number; y: number; z: number }\n rotate?: { x: number; y: number; z: number }\n}\n\nexport const kicadFootprintModel = z.object({\n path: z.string(),\n offset: point3.optional(),\n scale: point3.optional(),\n rotate: point3.optional(),\n})\n\ntype InferredKicadFootprintModel = z.infer<typeof kicadFootprintModel>\nexpectTypesMatch<KicadFootprintModel, InferredKicadFootprintModel>(true)\n\nexport interface KicadFootprintMetadata {\n footprintName?: string\n version?: number | string\n generator?: string\n generatorVersion?: number | string\n layer?: string\n properties?: KicadFootprintProperties\n attributes?: KicadFootprintAttributes\n pads?: KicadFootprintPad[]\n embeddedFonts?: boolean\n model?: KicadFootprintModel\n}\n\nexport const kicadFootprintMetadata = z.object({\n footprintName: z.string().optional(),\n version: z.union([z.number(), z.string()]).optional(),\n generator: z.string().optional(),\n generatorVersion: z.union([z.number(), z.string()]).optional(),\n layer: z.string().optional(),\n properties: kicadFootprintProperties.optional(),\n attributes: kicadFootprintAttributes.optional(),\n pads: z.array(kicadFootprintPad).optional(),\n embeddedFonts: z.boolean().optional(),\n model: kicadFootprintModel.optional(),\n})\n\ntype InferredKicadFootprintMetadata = z.infer<typeof kicadFootprintMetadata>\nexpectTypesMatch<KicadFootprintMetadata, InferredKicadFootprintMetadata>(true)\n","import { z } from \"zod\"\nimport { distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n kicadAt,\n kicadFont,\n type KicadAt,\n type KicadFont,\n} from \"./kicadFootprintMetadata\"\n\nexport interface KicadSymbolPinNumbers {\n hide?: boolean\n}\n\nexport const kicadSymbolPinNumbers = z.object({\n hide: z.boolean().optional(),\n})\n\ntype InferredKicadSymbolPinNumbers = z.infer<typeof kicadSymbolPinNumbers>\nexpectTypesMatch<KicadSymbolPinNumbers, InferredKicadSymbolPinNumbers>(true)\n\nexport interface KicadSymbolPinNames {\n offset?: number\n hide?: boolean\n}\n\nexport const kicadSymbolPinNames = z.object({\n offset: distance.optional(),\n hide: z.boolean().optional(),\n})\n\ntype InferredKicadSymbolPinNames = z.infer<typeof kicadSymbolPinNames>\nexpectTypesMatch<KicadSymbolPinNames, InferredKicadSymbolPinNames>(true)\n\nexport interface KicadSymbolEffects {\n font?: KicadFont\n justify?: string | string[]\n hide?: boolean\n}\n\nexport const kicadSymbolEffects = z.object({\n font: kicadFont.optional(),\n justify: z.union([z.string(), z.array(z.string())]).optional(),\n hide: z.boolean().optional(),\n})\n\ntype InferredKicadSymbolEffects = z.infer<typeof kicadSymbolEffects>\nexpectTypesMatch<KicadSymbolEffects, InferredKicadSymbolEffects>(true)\n\nexport interface KicadSymbolProperty {\n value: string\n id?: number | string\n at?: KicadAt\n effects?: KicadSymbolEffects\n}\n\nexport const kicadSymbolProperty = z.object({\n value: z.string(),\n id: z.union([z.number(), z.string()]).optional(),\n at: kicadAt.optional(),\n effects: kicadSymbolEffects.optional(),\n})\n\ntype InferredKicadSymbolProperty = z.infer<typeof kicadSymbolProperty>\nexpectTypesMatch<KicadSymbolProperty, InferredKicadSymbolProperty>(true)\n\nexport interface KicadSymbolProperties {\n Reference?: KicadSymbolProperty\n Value?: KicadSymbolProperty\n Footprint?: KicadSymbolProperty\n Datasheet?: KicadSymbolProperty\n Description?: KicadSymbolProperty\n ki_keywords?: KicadSymbolProperty\n ki_fp_filters?: KicadSymbolProperty\n}\n\nexport const kicadSymbolProperties = z.object({\n Reference: kicadSymbolProperty.optional(),\n Value: kicadSymbolProperty.optional(),\n Footprint: kicadSymbolProperty.optional(),\n Datasheet: kicadSymbolProperty.optional(),\n Description: kicadSymbolProperty.optional(),\n ki_keywords: kicadSymbolProperty.optional(),\n ki_fp_filters: kicadSymbolProperty.optional(),\n})\n\ntype InferredKicadSymbolProperties = z.infer<typeof kicadSymbolProperties>\nexpectTypesMatch<KicadSymbolProperties, InferredKicadSymbolProperties>(true)\n\nexport interface KicadSymbolMetadata {\n symbolName?: string\n extends?: string\n pinNumbers?: KicadSymbolPinNumbers\n pinNames?: KicadSymbolPinNames\n excludeFromSim?: boolean\n inBom?: boolean\n onBoard?: boolean\n properties?: KicadSymbolProperties\n embeddedFonts?: boolean\n}\n\nexport const kicadSymbolMetadata = z.object({\n symbolName: z.string().optional(),\n extends: z.string().optional(),\n pinNumbers: kicadSymbolPinNumbers.optional(),\n pinNames: kicadSymbolPinNames.optional(),\n excludeFromSim: z.boolean().optional(),\n inBom: z.boolean().optional(),\n onBoard: z.boolean().optional(),\n properties: kicadSymbolProperties.optional(),\n embeddedFonts: z.boolean().optional(),\n})\n\ntype InferredKicadSymbolMetadata = z.infer<typeof kicadSymbolMetadata>\nexpectTypesMatch<KicadSymbolMetadata, InferredKicadSymbolMetadata>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const base_circuit_json_error = z.object({\n error_type: z.string(),\n message: z.string(),\n is_fatal: z.boolean().optional(),\n})\n\nexport type BaseCircuitJsonErrorInput = z.input<typeof base_circuit_json_error>\ntype InferredBaseCircuitJsonError = z.infer<typeof base_circuit_json_error>\n\nexport interface BaseCircuitJsonError {\n error_type: string\n message: string\n is_fatal?: boolean\n}\n\nexpectTypesMatch<BaseCircuitJsonError, InferredBaseCircuitJsonError>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { capacitance, distance, voltage } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_capacitor = source_component_base.extend({\n ftype: z.literal(\"simple_capacitor\"),\n capacitance,\n max_voltage_rating: voltage.optional(),\n display_capacitance: z.string().optional(),\n max_decoupling_trace_length: distance.optional(),\n})\n\nexport type SourceSimpleCapacitorInput = z.input<typeof source_simple_capacitor>\ntype InferredSourceSimpleCapacitor = z.infer<typeof source_simple_capacitor>\n\n/**\n * Defines a simple capacitor component\n */\nexport interface SourceSimpleCapacitor extends SourceComponentBase {\n ftype: \"simple_capacitor\"\n capacitance: number\n max_voltage_rating?: number\n display_capacitance?: string\n max_decoupling_trace_length?: number\n}\n\nexpectTypesMatch<SourceSimpleCapacitor, InferredSourceSimpleCapacitor>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const supplier_name = z.enum([\n \"jlcpcb\",\n \"macrofab\",\n \"pcbway\",\n \"digikey\",\n \"mouser\",\n \"lcsc\",\n])\n\ntype InferredSupplierName = z.infer<typeof supplier_name>\n\nexport type SupplierName =\n | \"jlcpcb\"\n | \"macrofab\"\n | \"pcbway\"\n | \"digikey\"\n | \"mouser\"\n | \"lcsc\"\n\nexpectTypesMatch<SupplierName, InferredSupplierName>(true)\n","import {\n supplier_name,\n type SupplierName,\n} from \"src/pcb/properties/supplier_name\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\n\nexport interface SourceComponentBase {\n type: \"source_component\"\n ftype?: string\n source_component_id: string\n name: string\n manufacturer_part_number?: string\n supplier_part_numbers?: Partial<Record<SupplierName, string[]>>\n display_value?: string\n display_name?: string\n are_pins_interchangeable?: boolean\n internally_connected_source_port_ids?: string[][]\n source_group_id?: string\n subcircuit_id?: string\n}\n\nexport const source_component_base = z.object({\n type: z.literal(\"source_component\"),\n ftype: z.string().optional(),\n source_component_id: z.string(),\n name: z.string(),\n manufacturer_part_number: z.string().optional(),\n supplier_part_numbers: z\n .record(supplier_name, z.array(z.string()))\n .optional(),\n display_value: z.string().optional(),\n display_name: z.string().optional(),\n are_pins_interchangeable: z.boolean().optional(),\n internally_connected_source_port_ids: z.array(z.array(z.string())).optional(),\n source_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n})\n\ntype InferredSourceComponentBase = z.infer<typeof source_component_base>\n\nexpectTypesMatch<SourceComponentBase, InferredSourceComponentBase>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { resistance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_resistor = source_component_base.extend({\n ftype: z.literal(\"simple_resistor\"),\n resistance,\n display_resistance: z.string().optional(),\n})\n\nexport type SourceSimpleResistorInput = z.input<typeof source_simple_resistor>\ntype InferredSourceSimpleResistor = z.infer<typeof source_simple_resistor>\n\n/**\n * Defines a simple resistor component\n */\nexport interface SourceSimpleResistor extends SourceComponentBase {\n ftype: \"simple_resistor\"\n resistance: number\n display_resistance?: string\n}\n\nexpectTypesMatch<SourceSimpleResistor, InferredSourceSimpleResistor>(true)\n","import {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_diode = source_component_base.extend({\n ftype: z.literal(\"simple_diode\"),\n})\n\nexport type SourceSimpleDiodeInput = z.input<typeof source_simple_diode>\ntype InferredSourceSimpleDiode = z.infer<typeof source_simple_diode>\n\n/**\n * Defines a simple diode component\n */\nexport interface SourceSimpleDiode extends SourceComponentBase {\n ftype: \"simple_diode\"\n}\n\nexpectTypesMatch<SourceSimpleDiode, InferredSourceSimpleDiode>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_fiducial = source_component_base.extend({\n ftype: z.literal(\"simple_fiducial\"),\n})\n\nexport type SourceSimpleFiducialInput = z.input<typeof source_simple_fiducial>\ntype InferredSourceSimpleFiducial = z.infer<typeof source_simple_fiducial>\n\n/**\n * Defines a simple fiducial component\n */\nexport interface SourceSimpleFiducial extends SourceComponentBase {\n ftype: \"simple_fiducial\"\n}\n\nexpectTypesMatch<SourceSimpleFiducial, InferredSourceSimpleFiducial>(true)\n","import {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n source_simple_diode,\n type SourceSimpleDiode,\n} from \"./source_simple_diode\"\n\nexport const source_simple_led = source_simple_diode.extend({\n ftype: z.literal(\"simple_led\"),\n color: z.string().optional(),\n wavelength: z.string().optional(),\n})\n\nexport type SourceSimpleLedInput = z.input<typeof source_simple_led>\ntype InferredSourceSimpleLed = z.infer<typeof source_simple_led>\n\n/**\n * Defines a simple led component\n */\nexport interface SourceSimpleLed extends Omit<SourceSimpleDiode, \"ftype\"> {\n ftype: \"simple_led\"\n color?: string\n wavelength?: string\n}\n\nexpectTypesMatch<SourceSimpleLed, InferredSourceSimpleLed>(true)\n","import {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_ground = source_component_base.extend({\n ftype: z.literal(\"simple_ground\"),\n})\n\nexport type SourceSimpleGroundInput = z.input<typeof source_simple_ground>\ntype InferredSourceSimpleGround = z.infer<typeof source_simple_ground>\n\n/**\n * Defines a simple ground component\n */\nexport interface SourceSimpleGround extends SourceComponentBase {\n ftype: \"simple_ground\"\n}\n\nexpectTypesMatch<SourceSimpleGround, InferredSourceSimpleGround>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_chip = source_component_base.extend({\n ftype: z.literal(\"simple_chip\"),\n})\n\nexport type SourceSimpleChipInput = z.input<typeof source_simple_chip>\ntype InferredSourceSimpleChip = z.infer<typeof source_simple_chip>\n\n/**\n * Defines a simple integrated circuit component\n */\nexport interface SourceSimpleChip extends SourceComponentBase {\n ftype: \"simple_chip\"\n}\n\nexpectTypesMatch<SourceSimpleChip, InferredSourceSimpleChip>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { voltage } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_power_source = source_component_base.extend({\n ftype: z.literal(\"simple_power_source\"),\n voltage,\n})\n\nexport type SourceSimplePowerSourceInput = z.input<\n typeof source_simple_power_source\n>\ntype InferredSourceSimplePowerSource = z.infer<\n typeof source_simple_power_source\n>\n\n/**\n * Defines a simple power source component\n */\nexport interface SourceSimplePowerSource extends SourceComponentBase {\n ftype: \"simple_power_source\"\n voltage: number\n}\n\nexpectTypesMatch<SourceSimplePowerSource, InferredSourceSimplePowerSource>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { current, frequency } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_current_source = source_component_base.extend({\n ftype: z.literal(\"simple_current_source\"),\n current,\n frequency: frequency.optional(),\n peak_to_peak_current: current.optional(),\n wave_shape: z\n .enum([\"sine\", \"square\", \"triangle\", \"sawtooth\", \"dc\"])\n .optional()\n .default(\"dc\"),\n phase: z.number().optional(),\n duty_cycle: z.number().min(0).max(1).optional(),\n})\n\nexport type SourceSimpleCurrentSourceInput = z.input<\n typeof source_simple_current_source\n>\ntype InferredSourceSimpleCurrentSource = z.infer<\n typeof source_simple_current_source\n>\n\n/**\n * Defines a simple current source component\n */\nexport interface SourceSimpleCurrentSource extends SourceComponentBase {\n ftype: \"simple_current_source\"\n current: number\n frequency?: number\n peak_to_peak_current?: number\n wave_shape: \"sine\" | \"square\" | \"triangle\" | \"sawtooth\" | \"dc\"\n phase?: number\n duty_cycle?: number\n}\n\nexpectTypesMatch<SourceSimpleCurrentSource, InferredSourceSimpleCurrentSource>(\n true,\n)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_pin_attributes = z.object({\n must_be_connected: z.boolean().optional(),\n provides_power: z.boolean().optional(),\n requires_power: z.boolean().optional(),\n provides_ground: z.boolean().optional(),\n requires_ground: z.boolean().optional(),\n provides_voltage: z.union([z.string(), z.number()]).optional(),\n requires_voltage: z.union([z.string(), z.number()]).optional(),\n do_not_connect: z.boolean().optional(),\n include_in_board_pinout: z.boolean().optional(),\n can_use_internal_pullup: z.boolean().optional(),\n is_using_internal_pullup: z.boolean().optional(),\n needs_external_pullup: z.boolean().optional(),\n can_use_internal_pulldown: z.boolean().optional(),\n is_using_internal_pulldown: z.boolean().optional(),\n needs_external_pulldown: z.boolean().optional(),\n can_use_open_drain: z.boolean().optional(),\n is_using_open_drain: z.boolean().optional(),\n can_use_push_pull: z.boolean().optional(),\n is_using_push_pull: z.boolean().optional(),\n should_have_decoupling_capacitor: z.boolean().optional(),\n recommended_decoupling_capacitor_capacitance: z\n .union([z.string(), z.number()])\n .optional(),\n is_configured_for_i2c_sda: z.boolean().optional(),\n is_configured_for_i2c_scl: z.boolean().optional(),\n is_configured_for_spi_mosi: z.boolean().optional(),\n is_configured_for_spi_miso: z.boolean().optional(),\n is_configured_for_spi_sck: z.boolean().optional(),\n is_configured_for_spi_cs: z.boolean().optional(),\n is_configured_for_uart_tx: z.boolean().optional(),\n is_configured_for_uart_rx: z.boolean().optional(),\n supports_i2c_sda: z.boolean().optional(),\n supports_i2c_scl: z.boolean().optional(),\n supports_spi_mosi: z.boolean().optional(),\n supports_spi_miso: z.boolean().optional(),\n supports_spi_sck: z.boolean().optional(),\n supports_spi_cs: z.boolean().optional(),\n supports_uart_tx: z.boolean().optional(),\n supports_uart_rx: z.boolean().optional(),\n})\n\ntype InferredSourcePinAttributes = z.infer<typeof source_pin_attributes>\n\nexport interface SourcePinAttributes {\n must_be_connected?: boolean\n provides_power?: boolean\n requires_power?: boolean\n provides_ground?: boolean\n requires_ground?: boolean\n provides_voltage?: string | number\n requires_voltage?: string | number\n do_not_connect?: boolean\n include_in_board_pinout?: boolean\n can_use_internal_pullup?: boolean\n is_using_internal_pullup?: boolean\n needs_external_pullup?: boolean\n can_use_internal_pulldown?: boolean\n is_using_internal_pulldown?: boolean\n needs_external_pulldown?: boolean\n can_use_open_drain?: boolean\n is_using_open_drain?: boolean\n can_use_push_pull?: boolean\n is_using_push_pull?: boolean\n should_have_decoupling_capacitor?: boolean\n recommended_decoupling_capacitor_capacitance?: string | number\n is_configured_for_i2c_sda?: boolean\n is_configured_for_i2c_scl?: boolean\n is_configured_for_spi_mosi?: boolean\n is_configured_for_spi_miso?: boolean\n is_configured_for_spi_sck?: boolean\n is_configured_for_spi_cs?: boolean\n is_configured_for_uart_tx?: boolean\n is_configured_for_uart_rx?: boolean\n supports_i2c_sda?: boolean\n supports_i2c_scl?: boolean\n supports_spi_mosi?: boolean\n supports_spi_miso?: boolean\n supports_spi_sck?: boolean\n supports_spi_cs?: boolean\n supports_uart_tx?: boolean\n supports_uart_rx?: boolean\n}\n\nexpectTypesMatch<SourcePinAttributes, InferredSourcePinAttributes>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n source_simple_resistor,\n type SourceSimpleResistor,\n} from \"./source_simple_resistor\"\nimport {\n source_simple_capacitor,\n type SourceSimpleCapacitor,\n} from \"./source_simple_capacitor\"\nimport { source_simple_fuse, type SourceSimpleFuse } from \"./source_simple_fuse\"\nimport {\n source_simple_diode,\n type SourceSimpleDiode,\n} from \"./source_simple_diode\"\nimport {\n source_simple_fiducial,\n type SourceSimpleFiducial,\n} from \"./source_simple_fiducial\"\nimport { source_simple_led, type SourceSimpleLed } from \"./source_simple_led\"\nimport {\n source_simple_ground,\n type SourceSimpleGround,\n} from \"./source_simple_ground\"\nimport { source_simple_chip, type SourceSimpleChip } from \"./source_simple_chip\"\nimport {\n source_simple_power_source,\n type SourceSimplePowerSource,\n} from \"./source_simple_power_source\"\nimport {\n source_simple_current_source,\n type SourceSimpleCurrentSource,\n} from \"./source_simple_current_source\"\nimport {\n source_simple_battery,\n type SourceSimpleBattery,\n} from \"./source_simple_battery\"\nimport {\n source_simple_inductor,\n type SourceSimpleInductor,\n} from \"./source_simple_inductor\"\nimport {\n source_simple_push_button,\n type SourceSimplePushButton,\n} from \"./source_simple_push_button\"\nimport {\n source_simple_potentiometer,\n type SourceSimplePotentiometer,\n} from \"./source_simple_potentiometer\"\nimport {\n source_simple_crystal,\n type SourceSimpleCrystal,\n} from \"./source_simple_crystal\"\nimport {\n source_simple_pin_header,\n type SourceSimplePinHeader,\n} from \"./source_simple_pin_header\"\nimport {\n source_simple_connector,\n type SourceSimpleConnector,\n} from \"./source_simple_connector\"\nimport {\n source_simple_pinout,\n type SourceSimplePinout,\n} from \"./source_simple_pinout\"\nimport {\n source_simple_resonator,\n type SourceSimpleResonator,\n} from \"./source_simple_resonator\"\nimport {\n source_simple_transistor,\n type SourceSimpleTransistor,\n} from \"./source_simple_transistor\"\nimport {\n source_simple_test_point,\n type SourceSimpleTestPoint,\n} from \"./source_simple_test_point\"\nimport {\n source_simple_mosfet,\n type SourceSimpleMosfet,\n} from \"./source_simple_mosfet\"\nimport {\n source_simple_op_amp,\n type SourceSimpleOpAmp,\n} from \"./source_simple_op_amp\"\nimport {\n source_simple_switch,\n type SourceSimpleSwitch,\n} from \"./source_simple_switch\"\nimport {\n source_project_metadata,\n type SourceProjectMetadata,\n} from \"./source_project_metadata\"\nimport {\n source_missing_property_error,\n type SourceMissingPropertyError,\n} from \"./source_missing_property_error\"\nimport {\n source_failed_to_create_component_error,\n type SourceFailedToCreateComponentError,\n} from \"./source_failed_to_create_component_error\"\nimport {\n source_invalid_component_property_error,\n type SourceInvalidComponentPropertyError,\n} from \"./source_invalid_component_property_error\"\nimport {\n source_trace_not_connected_error,\n type SourceTraceNotConnectedError,\n} from \"./source_trace_not_connected_error\"\nimport {\n source_property_ignored_warning,\n type SourcePropertyIgnoredWarning,\n} from \"./source_property_ignored_warning\"\nimport {\n source_pin_missing_trace_warning,\n type SourcePinMissingTraceWarning,\n} from \"./source_pin_missing_trace_warning\"\nimport {\n source_simple_voltage_probe,\n type SourceSimpleVoltageProbe,\n} from \"./source_simple_voltage_probe\"\nimport {\n source_interconnect,\n type SourceInterconnect,\n} from \"./source_interconnect\"\nimport {\n source_i2c_misconfigured_error,\n type SourceI2cMisconfiguredError,\n} from \"./source_i2c_misconfigured_error\"\nimport {\n source_simple_voltage_source,\n type SourceSimpleVoltageSource,\n} from \"./source_simple_voltage_source\"\n\nexport const any_source_component = z.union([\n source_simple_resistor,\n source_simple_capacitor,\n source_simple_diode,\n source_simple_fiducial,\n source_simple_led,\n source_simple_ground,\n source_simple_chip,\n source_simple_power_source,\n source_simple_current_source,\n source_simple_battery,\n source_simple_inductor,\n source_simple_push_button,\n source_simple_potentiometer,\n source_simple_crystal,\n source_simple_pin_header,\n source_simple_connector,\n source_simple_pinout,\n source_simple_resonator,\n source_simple_switch,\n source_simple_transistor,\n source_simple_test_point,\n source_simple_mosfet,\n source_simple_op_amp,\n source_simple_fuse,\n source_simple_voltage_probe,\n source_interconnect,\n source_simple_voltage_source,\n source_project_metadata,\n source_missing_property_error,\n source_invalid_component_property_error,\n source_failed_to_create_component_error,\n source_trace_not_connected_error,\n source_property_ignored_warning,\n source_pin_missing_trace_warning,\n source_i2c_misconfigured_error,\n])\n\n/**\n * Deprecated: use `AnySourceElement` instead\n */\nexport type AnySourceComponent = z.infer<typeof any_source_component>\n\nexport type AnySourceElement =\n | SourceSimpleResistor\n | SourceSimpleCapacitor\n | SourceSimpleDiode\n | SourceSimpleFiducial\n | SourceSimpleLed\n | SourceSimpleGround\n | SourceSimpleChip\n | SourceSimplePowerSource\n | SourceSimpleCurrentSource\n | SourceSimpleBattery\n | SourceSimpleInductor\n | SourceSimplePushButton\n | SourceSimplePotentiometer\n | SourceSimpleCrystal\n | SourceSimplePinHeader\n | SourceSimpleConnector\n | SourceSimplePinout\n | SourceSimpleResonator\n | SourceSimpleSwitch\n | SourceSimpleTransistor\n | SourceSimpleTestPoint\n | SourceSimpleMosfet\n | SourceSimpleFuse\n | SourceSimpleOpAmp\n | SourceSimpleVoltageProbe\n | SourceSimpleVoltageSource\n | SourceInterconnect\n | SourceProjectMetadata\n | SourceMissingPropertyError\n | SourceInvalidComponentPropertyError\n | SourceFailedToCreateComponentError\n | SourceTraceNotConnectedError\n | SourcePropertyIgnoredWarning\n | SourcePinMissingTraceWarning\n | SourceI2cMisconfiguredError\n\nexpectTypesMatch<AnySourceElement, AnySourceComponent>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"./base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_fuse = source_component_base.extend({\n ftype: z.literal(\"simple_fuse\"),\n\n current_rating_amps: z\n .number()\n .describe(\"Nominal current in amps the fuse is rated for\"),\n\n voltage_rating_volts: z\n .number()\n .describe(\"Voltage rating in volts, e.g. ±5V would be 5\"),\n})\n\nexport interface SourceSimpleFuse extends SourceComponentBase {\n ftype: \"simple_fuse\"\n current_rating_amps: number\n voltage_rating_volts: number\n}\n\nexport type SourceSimpleFuseInput = z.input<typeof source_simple_fuse>\ntype InferredSourceSimpleFuse = z.infer<typeof source_simple_fuse>\n\nexpectTypesMatch<SourceSimpleFuse, InferredSourceSimpleFuse>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { battery_capacity } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_battery = source_component_base.extend({\n ftype: z.literal(\"simple_battery\"),\n capacity: battery_capacity,\n})\n\nexport type SourceSimpleBatteryInput = z.input<typeof source_simple_battery>\ntype InferredSourceSimpleBattery = z.infer<typeof source_simple_battery>\n\n/**\n * Defines a simple battery component\n */\nexport interface SourceSimpleBattery extends SourceComponentBase {\n ftype: \"simple_battery\"\n capacity: number\n}\n\nexpectTypesMatch<SourceSimpleBattery, InferredSourceSimpleBattery>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { inductance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_inductor = source_component_base.extend({\n ftype: z.literal(\"simple_inductor\"),\n inductance,\n max_current_rating: z.number().optional(),\n})\n\nexport type SourceSimpleInductorInput = z.input<typeof source_simple_inductor>\ntype InferredSourceSimpleInductor = z.infer<typeof source_simple_inductor>\n\n/**\n * Defines a simple inductor component\n */\nexport interface SourceSimpleInductor extends SourceComponentBase {\n ftype: \"simple_inductor\"\n inductance: number\n max_current_rating?: number\n}\n\nexpectTypesMatch<SourceSimpleInductor, InferredSourceSimpleInductor>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_push_button = source_component_base.extend({\n ftype: z.literal(\"simple_push_button\"),\n})\n\nexport type SourceSimplePushButtonInput = z.input<\n typeof source_simple_push_button\n>\ntype InferredSourceSimplePushButton = z.infer<typeof source_simple_push_button>\n\n/**\n * Defines a simple push button component\n */\nexport interface SourceSimplePushButton extends SourceComponentBase {\n ftype: \"simple_push_button\"\n}\n\nexpectTypesMatch<SourceSimplePushButton, InferredSourceSimplePushButton>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { resistance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_potentiometer = source_component_base.extend({\n ftype: z.literal(\"simple_potentiometer\"),\n max_resistance: resistance,\n display_max_resistance: z.string().optional(),\n})\n\nexport type SourceSimplePotentiometerInput = z.input<\n typeof source_simple_potentiometer\n>\ntype InferredSourceSimplePotentiometer = z.infer<\n typeof source_simple_potentiometer\n>\n\nexport interface SourceSimplePotentiometer extends SourceComponentBase {\n ftype: \"simple_potentiometer\"\n max_resistance: number\n display_max_resistance?: string\n}\n\nexpectTypesMatch<SourceSimplePotentiometer, InferredSourceSimplePotentiometer>(\n true,\n)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_crystal = source_component_base.extend({\n ftype: z.literal(\"simple_crystal\"),\n frequency: z.number().describe(\"Frequency in Hz\"),\n load_capacitance: z.number().optional().describe(\"Load capacitance in pF\"),\n pin_variant: z.enum([\"two_pin\", \"four_pin\"]).optional(),\n})\n\nexport type SourceSimpleCrystalInput = z.input<typeof source_simple_crystal>\ntype InferredSourceSimpleCrystal = z.infer<typeof source_simple_crystal>\n\n/**\n * Defines a simple crystal oscillator component\n */\nexport interface SourceSimpleCrystal extends SourceComponentBase {\n ftype: \"simple_crystal\"\n frequency: number\n load_capacitance?: number\n pin_variant?: \"two_pin\" | \"four_pin\"\n}\n\nexpectTypesMatch<SourceSimpleCrystal, InferredSourceSimpleCrystal>(true)\n","import {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_pin_header = source_component_base.extend({\n ftype: z.literal(\"simple_pin_header\"),\n pin_count: z.number(),\n gender: z.enum([\"male\", \"female\"]).optional().default(\"male\"),\n})\n\nexport type SourceSimplePinHeaderInput = z.input<\n typeof source_simple_pin_header\n>\ntype InferredSourceSimplePinHeader = z.infer<typeof source_simple_pin_header>\n\nexport interface SourceSimplePinHeader extends SourceComponentBase {\n ftype: \"simple_pin_header\"\n pin_count: number\n gender: \"male\" | \"female\"\n}\n\nexpectTypesMatch<SourceSimplePinHeader, InferredSourceSimplePinHeader>(true)\n","import {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_connector = source_component_base.extend({\n ftype: z.literal(\"simple_connector\"),\n standard: z.enum([\"usb_c\", \"m2\"]).optional(),\n})\n\nexport type SourceSimpleConnectorInput = z.input<typeof source_simple_connector>\ntype InferredSourceSimpleConnector = z.infer<typeof source_simple_connector>\n\n/**\n * Defines a simple connector component\n */\nexport interface SourceSimpleConnector extends SourceComponentBase {\n ftype: \"simple_connector\"\n standard?: \"usb_c\" | \"m2\"\n}\n\nexpectTypesMatch<SourceSimpleConnector, InferredSourceSimpleConnector>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_pinout = source_component_base.extend({\n ftype: z.literal(\"simple_pinout\"),\n})\n\nexport type SourceSimplePinoutInput = z.input<typeof source_simple_pinout>\ntype InferredSourceSimplePinout = z.infer<typeof source_simple_pinout>\n\n/**\n * Defines a simple pinout component\n */\nexport interface SourceSimplePinout extends SourceComponentBase {\n ftype: \"simple_pinout\"\n}\n\nexpectTypesMatch<SourceSimplePinout, InferredSourceSimplePinout>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { capacitance, resistance, frequency } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_resonator = source_component_base.extend({\n ftype: z.literal(\"simple_resonator\"),\n load_capacitance: capacitance,\n equivalent_series_resistance: resistance.optional(),\n frequency: frequency,\n})\n\nexport type SourceSimpleResonatorInput = z.input<typeof source_simple_resonator>\ntype InferredSourceSimpleResonator = z.infer<typeof source_simple_resonator>\n\n/**\n * Defines a simple resonator component\n */\nexport interface SourceSimpleResonator extends SourceComponentBase {\n ftype: \"simple_resonator\"\n load_capacitance: number\n equivalent_series_resistance?: number\n frequency: number\n}\n\nexpectTypesMatch<SourceSimpleResonator, InferredSourceSimpleResonator>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_transistor = source_component_base.extend({\n ftype: z.literal(\"simple_transistor\"),\n transistor_type: z.enum([\"npn\", \"pnp\"]),\n})\n\nexport type SourceSimpleTransistorInput = z.input<\n typeof source_simple_transistor\n>\ntype InferredSourceSimpleTransistor = z.infer<typeof source_simple_transistor>\n\n/**\n * Defines a simple transistor component\n * This is a three-pin semiconductor device (emitter, base, collector)\n * Pin configuration is handled by the schematic port system\n */\n\nexport interface SourceSimpleTransistor extends SourceComponentBase {\n ftype: \"simple_transistor\"\n transistor_type: \"npn\" | \"pnp\"\n}\n\nexpectTypesMatch<SourceSimpleTransistor, InferredSourceSimpleTransistor>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_test_point = source_component_base.extend({\n ftype: z.literal(\"simple_test_point\"),\n footprint_variant: z.enum([\"pad\", \"through_hole\"]).optional(),\n pad_shape: z.enum([\"rect\", \"circle\"]).optional(),\n pad_diameter: z.union([z.number(), z.string()]).optional(),\n hole_diameter: z.union([z.number(), z.string()]).optional(),\n width: z.union([z.number(), z.string()]).optional(),\n height: z.union([z.number(), z.string()]).optional(),\n})\n\nexport type SourceSimpleTestPointInput = z.input<\n typeof source_simple_test_point\n>\ntype InferredSourceSimpleTestPoint = z.infer<typeof source_simple_test_point>\n\n/**\n * Defines a simple test point component\n * Can be surface-mount or through-hole.\n * Pad shape and dimensions configurable for different use cases.\n */\nexport interface SourceSimpleTestPoint extends SourceComponentBase {\n ftype: \"simple_test_point\"\n footprint_variant?: \"pad\" | \"through_hole\"\n pad_shape?: \"rect\" | \"circle\"\n pad_diameter?: number | string\n hole_diameter?: number | string\n width?: number | string\n height?: number | string\n}\n\nexpectTypesMatch<SourceSimpleTestPoint, InferredSourceSimpleTestPoint>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_mosfet = source_component_base.extend({\n ftype: z.literal(\"simple_mosfet\"),\n channel_type: z.enum([\"n\", \"p\"]),\n mosfet_mode: z.enum([\"enhancement\", \"depletion\"]),\n})\n\nexport type SourceSimpleMosfetInput = z.input<typeof source_simple_mosfet>\ntype InferredSourceSimpleMosfet = z.infer<typeof source_simple_mosfet>\n\n/**\n * Defines a simple mosfet component\n * This is a three-pin semiconductor device (source, gate, drain)\n * Pin configuration is handled by the schematic port system\n */\n\nexport interface SourceSimpleMosfet extends SourceComponentBase {\n ftype: \"simple_mosfet\"\n channel_type: \"n\" | \"p\"\n mosfet_mode: \"enhancement\" | \"depletion\"\n}\n\nexpectTypesMatch<SourceSimpleMosfet, InferredSourceSimpleMosfet>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_op_amp = source_component_base.extend({\n ftype: z.literal(\"simple_op_amp\"),\n})\n\nexport type SourceSimpleOpAmpInput = z.input<typeof source_simple_op_amp>\ntype InferredSourceSimpleOpAmp = z.infer<typeof source_simple_op_amp>\n\n/**\n * Defines a simple op-amp component\n */\nexport interface SourceSimpleOpAmp extends SourceComponentBase {\n ftype: \"simple_op_amp\"\n}\n\nexpectTypesMatch<SourceSimpleOpAmp, InferredSourceSimpleOpAmp>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_switch = source_component_base.extend({\n ftype: z.literal(\"simple_switch\"),\n})\nexport type SourceSimpleSwitchInput = z.input<typeof source_simple_switch>\ntype InferredSourceSimpleSwitch = z.infer<typeof source_simple_switch>\n\n/**\n * Defines a simple switch component\n */\nexport interface SourceSimpleSwitch extends SourceComponentBase {\n ftype: \"simple_switch\"\n}\n\nexpectTypesMatch<SourceSimpleSwitch, InferredSourceSimpleSwitch>(true)\n","import { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\nimport { timestamp } from \"src/units\"\n\nexport interface SourceProjectMetadata {\n type: \"source_project_metadata\"\n name?: string\n software_used_string?: string\n project_url?: string\n created_at?: string // ISO8601 timestamp\n}\n\nexport const source_project_metadata = z.object({\n type: z.literal(\"source_project_metadata\"),\n name: z.string().optional(),\n software_used_string: z.string().optional(),\n project_url: z.string().optional(),\n created_at: timestamp.optional(),\n})\n\nexport type InferredProjectMetadata = z.infer<typeof source_project_metadata>\nexpectTypesMatch<SourceProjectMetadata, InferredProjectMetadata>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_missing_property_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_missing_property_error\"),\n source_missing_property_error_id: getZodPrefixedIdWithDefault(\n \"source_missing_property_error\",\n ),\n source_component_id: z.string(),\n property_name: z.string(),\n subcircuit_id: z.string().optional(),\n error_type: z\n .literal(\"source_missing_property_error\")\n .default(\"source_missing_property_error\"),\n })\n .describe(\"The source code is missing a property\")\n\nexport type SourceMissingPropertyErrorInput = z.input<\n typeof source_missing_property_error\n>\ntype InferredSourceMissingPropertyError = z.infer<\n typeof source_missing_property_error\n>\n\n/**\n * The source code is missing a property\n */\nexport interface SourceMissingPropertyError extends BaseCircuitJsonError {\n type: \"source_missing_property_error\"\n source_missing_property_error_id: string\n source_component_id: string\n property_name: string\n subcircuit_id?: string\n error_type: \"source_missing_property_error\"\n}\n\nexpectTypesMatch<\n SourceMissingPropertyError,\n InferredSourceMissingPropertyError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_failed_to_create_component_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_failed_to_create_component_error\"),\n source_failed_to_create_component_error_id: getZodPrefixedIdWithDefault(\n \"source_failed_to_create_component_error\",\n ),\n error_type: z\n .literal(\"source_failed_to_create_component_error\")\n .default(\"source_failed_to_create_component_error\"),\n component_name: z.string().optional(),\n subcircuit_id: z.string().optional(),\n parent_source_component_id: z.string().optional(),\n pcb_center: z\n .object({\n x: z.number().optional(),\n y: z.number().optional(),\n })\n .optional(),\n schematic_center: z\n .object({\n x: z.number().optional(),\n y: z.number().optional(),\n })\n .optional(),\n })\n .describe(\"Error emitted when a component fails to be constructed\")\n\nexport type SourceFailedToCreateComponentErrorInput = z.input<\n typeof source_failed_to_create_component_error\n>\ntype InferredSourceFailedToCreateComponentError = z.infer<\n typeof source_failed_to_create_component_error\n>\n\n/**\n * Error emitted when a component fails to be constructed.\n * Contains details about the failure and prevents the component from being rendered.\n */\nexport interface SourceFailedToCreateComponentError\n extends BaseCircuitJsonError {\n type: \"source_failed_to_create_component_error\"\n source_failed_to_create_component_error_id: string\n error_type: \"source_failed_to_create_component_error\"\n component_name?: string\n subcircuit_id?: string\n parent_source_component_id?: string\n pcb_center?: {\n x?: number\n y?: number\n }\n schematic_center?: {\n x?: number\n y?: number\n }\n}\n\nexpectTypesMatch<\n SourceFailedToCreateComponentError,\n InferredSourceFailedToCreateComponentError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_invalid_component_property_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_invalid_component_property_error\"),\n source_invalid_component_property_error_id: getZodPrefixedIdWithDefault(\n \"source_invalid_component_property_error\",\n ),\n source_component_id: z.string(),\n property_name: z.string(),\n property_value: z.unknown().optional(),\n expected_format: z.string().optional(),\n subcircuit_id: z.string().optional(),\n error_type: z\n .literal(\"source_invalid_component_property_error\")\n .default(\"source_invalid_component_property_error\"),\n })\n .describe(\"The source component property is invalid\")\n\nexport type SourceInvalidComponentPropertyErrorInput = z.input<\n typeof source_invalid_component_property_error\n>\ntype InferredSourceInvalidComponentPropertyError = z.infer<\n typeof source_invalid_component_property_error\n>\n\n/**\n * The source component property is invalid\n */\nexport interface SourceInvalidComponentPropertyError\n extends BaseCircuitJsonError {\n type: \"source_invalid_component_property_error\"\n source_invalid_component_property_error_id: string\n source_component_id: string\n property_name: string\n property_value?: unknown\n expected_format?: string\n subcircuit_id?: string\n error_type: \"source_invalid_component_property_error\"\n}\n\nexpectTypesMatch<\n SourceInvalidComponentPropertyError,\n InferredSourceInvalidComponentPropertyError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_trace_not_connected_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_trace_not_connected_error\"),\n source_trace_not_connected_error_id: getZodPrefixedIdWithDefault(\n \"source_trace_not_connected_error\",\n ),\n error_type: z\n .literal(\"source_trace_not_connected_error\")\n .default(\"source_trace_not_connected_error\"),\n subcircuit_id: z.string().optional(),\n source_group_id: z.string().optional(),\n source_trace_id: z.string().optional(),\n connected_source_port_ids: z.array(z.string()).optional(),\n selectors_not_found: z.array(z.string()).optional(),\n })\n .describe(\"Occurs when a source trace selector does not match any ports\")\n\nexport type SourceTraceNotConnectedErrorInput = z.input<\n typeof source_trace_not_connected_error\n>\ntype InferredSourceTraceNotConnectedError = z.infer<\n typeof source_trace_not_connected_error\n>\n\n/**\n * Occurs when a source trace selector does not match any ports\n */\nexport interface SourceTraceNotConnectedError extends BaseCircuitJsonError {\n type: \"source_trace_not_connected_error\"\n source_trace_not_connected_error_id: string\n error_type: \"source_trace_not_connected_error\"\n subcircuit_id?: string\n source_group_id?: string\n source_trace_id?: string\n connected_source_port_ids?: string[]\n selectors_not_found?: string[]\n}\n\nexpectTypesMatch<\n SourceTraceNotConnectedError,\n InferredSourceTraceNotConnectedError\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_property_ignored_warning = z\n .object({\n type: z.literal(\"source_property_ignored_warning\"),\n source_property_ignored_warning_id: getZodPrefixedIdWithDefault(\n \"source_property_ignored_warning\",\n ),\n source_component_id: z.string(),\n property_name: z.string(),\n subcircuit_id: z.string().optional(),\n error_type: z\n .literal(\"source_property_ignored_warning\")\n .default(\"source_property_ignored_warning\"),\n message: z.string(),\n })\n .describe(\"The source property was ignored\")\n\nexport type SourcePropertyIgnoredWarningInput = z.input<\n typeof source_property_ignored_warning\n>\ntype InferredSourcePropertyIgnoredWarning = z.infer<\n typeof source_property_ignored_warning\n>\n\n/**\n * The source property was ignored\n */\nexport interface SourcePropertyIgnoredWarning {\n type: \"source_property_ignored_warning\"\n source_property_ignored_warning_id: string\n source_component_id: string\n property_name: string\n subcircuit_id?: string\n error_type: \"source_property_ignored_warning\"\n message: string\n}\n\nexpectTypesMatch<\n SourcePropertyIgnoredWarning,\n InferredSourcePropertyIgnoredWarning\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_pin_missing_trace_warning = z\n .object({\n type: z.literal(\"source_pin_missing_trace_warning\"),\n source_pin_missing_trace_warning_id: getZodPrefixedIdWithDefault(\n \"source_pin_missing_trace_warning\",\n ),\n warning_type: z\n .literal(\"source_pin_missing_trace_warning\")\n .default(\"source_pin_missing_trace_warning\"),\n message: z.string(),\n source_component_id: z.string(),\n source_port_id: z.string(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Warning emitted when a source component pin is missing a trace connection\",\n )\n\nexport type SourcePinMissingTraceWarningInput = z.input<\n typeof source_pin_missing_trace_warning\n>\ntype InferredSourcePinMissingTraceWarning = z.infer<\n typeof source_pin_missing_trace_warning\n>\n\n/**\n * Warning emitted when a source component pin is missing a trace connection\n */\nexport interface SourcePinMissingTraceWarning {\n type: \"source_pin_missing_trace_warning\"\n source_pin_missing_trace_warning_id: string\n warning_type: \"source_pin_missing_trace_warning\"\n message: string\n source_component_id: string\n source_port_id: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SourcePinMissingTraceWarning,\n InferredSourcePinMissingTraceWarning\n>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_voltage_probe = source_component_base.extend({\n ftype: z.literal(\"simple_voltage_probe\"),\n})\n\nexport type SourceSimpleVoltageProbeInput = z.input<\n typeof source_simple_voltage_probe\n>\ntype InferredSourceSimpleVoltageProbe = z.infer<\n typeof source_simple_voltage_probe\n>\n\n/**\n * Defines a simple voltage probe component for simulation and measurement\n */\nexport interface SourceSimpleVoltageProbe extends SourceComponentBase {\n ftype: \"simple_voltage_probe\"\n}\n\nexpectTypesMatch<SourceSimpleVoltageProbe, InferredSourceSimpleVoltageProbe>(\n true,\n)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_interconnect = source_component_base.extend({\n ftype: z.literal(\"interconnect\"),\n})\n\nexport type SourceInterconnectInput = z.input<typeof source_interconnect>\ntype InferredSourceInterconnect = z.infer<typeof source_interconnect>\n\n/**\n * Defines a generic interconnect component\n */\nexport interface SourceInterconnect extends SourceComponentBase {\n ftype: \"interconnect\"\n}\n\nexpectTypesMatch<SourceInterconnect, InferredSourceInterconnect>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_i2c_misconfigured_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_i2c_misconfigured_error\"),\n source_i2c_misconfigured_error_id: getZodPrefixedIdWithDefault(\n \"source_i2c_misconfigured_error\",\n ),\n error_type: z\n .literal(\"source_i2c_misconfigured_error\")\n .default(\"source_i2c_misconfigured_error\"),\n source_port_ids: z.array(z.string()),\n })\n .describe(\n \"Error emitted when incompatible I2C pins (e.g. SDA and SCL) are connected to the same net\",\n )\n\nexport type SourceI2cMisconfiguredErrorInput = z.input<\n typeof source_i2c_misconfigured_error\n>\ntype InferredSourceI2cMisconfiguredError = z.infer<\n typeof source_i2c_misconfigured_error\n>\n\n/**\n * Error emitted when incompatible I2C pins (e.g. SDA and SCL) are connected to the same net\n */\nexport interface SourceI2cMisconfiguredError extends BaseCircuitJsonError {\n type: \"source_i2c_misconfigured_error\"\n source_i2c_misconfigured_error_id: string\n error_type: \"source_i2c_misconfigured_error\"\n source_port_ids: string[]\n}\n\nexpectTypesMatch<\n SourceI2cMisconfiguredError,\n InferredSourceI2cMisconfiguredError\n>(true)\n","import { z } from \"zod\"\nimport {\n source_component_base,\n type SourceComponentBase,\n} from \"src/source/base/source_component_base\"\nimport { voltage, frequency, rotation } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_simple_voltage_source = source_component_base.extend({\n ftype: z.literal(\"simple_voltage_source\"),\n voltage,\n frequency: frequency.optional(),\n peak_to_peak_voltage: voltage.optional(),\n wave_shape: z.enum([\"sinewave\", \"square\", \"triangle\", \"sawtooth\"]).optional(),\n phase: rotation.optional(),\n duty_cycle: z\n .number()\n .optional()\n .describe(\"Duty cycle as a fraction (0 to 1)\"),\n})\n\nexport type SourceSimpleVoltageSourceInput = z.input<\n typeof source_simple_voltage_source\n>\ntype InferredSourceSimpleVoltageSource = z.infer<\n typeof source_simple_voltage_source\n>\n\n/**\n * Defines a simple voltage source component\n */\nexport interface SourceSimpleVoltageSource extends SourceComponentBase {\n ftype: \"simple_voltage_source\"\n voltage: number\n frequency?: number\n peak_to_peak_voltage?: number\n wave_shape?: \"sinewave\" | \"square\" | \"triangle\" | \"sawtooth\"\n phase?: number\n duty_cycle?: number\n}\n\nexpectTypesMatch<SourceSimpleVoltageSource, InferredSourceSimpleVoltageSource>(\n true,\n)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n source_pin_attributes,\n type SourcePinAttributes,\n} from \"./properties/source_pin_attributes\"\n\nexport const source_port = z\n .object({\n type: z.literal(\"source_port\"),\n pin_number: z.number().optional(),\n port_hints: z.array(z.string()).optional(),\n name: z.string(),\n source_port_id: z.string(),\n source_component_id: z.string().optional(),\n source_group_id: z.string().optional(),\n most_frequently_referenced_by_name: z.string().optional(),\n subcircuit_id: z.string().optional(),\n subcircuit_connectivity_map_key: z.string().optional(),\n })\n .merge(source_pin_attributes)\n\nexport type SourcePortInput = z.input<typeof source_port>\ntype InferredSourcePort = z.infer<typeof source_port>\n\n/**\n * Defines a source port that can be connected to other components\n */\nexport interface SourcePort extends SourcePinAttributes {\n type: \"source_port\"\n pin_number?: number\n port_hints?: string[]\n name: string\n source_port_id: string\n source_component_id?: string\n source_group_id?: string\n most_frequently_referenced_by_name?: string\n subcircuit_id?: string\n subcircuit_connectivity_map_key?: string\n}\n\nexpectTypesMatch<SourcePort, InferredSourcePort>(true)\n","import { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\n\nexport interface SourceComponentInternalConnection {\n type: \"source_component_internal_connection\"\n source_component_internal_connection_id: string\n source_component_id: string\n source_port_ids: string[]\n subcircuit_id?: string\n}\n\nexport const source_component_internal_connection = z.object({\n type: z.literal(\"source_component_internal_connection\"),\n source_component_internal_connection_id: z.string(),\n source_component_id: z.string(),\n source_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n})\n\ntype InferredSourceComponentInternalConnection = z.infer<\n typeof source_component_internal_connection\n>\n\nexpectTypesMatch<\n SourceComponentInternalConnection,\n InferredSourceComponentInternalConnection\n>(true)\n","import { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\n\nexport interface SourceTrace {\n type: \"source_trace\"\n source_trace_id: string\n connected_source_port_ids: string[]\n connected_source_net_ids: string[]\n subcircuit_id?: string\n subcircuit_connectivity_map_key?: string\n max_length?: number\n display_name?: string\n min_trace_thickness?: number\n}\n\nexport const source_trace = z.object({\n type: z.literal(\"source_trace\"),\n source_trace_id: z.string(),\n connected_source_port_ids: z.array(z.string()),\n connected_source_net_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n subcircuit_connectivity_map_key: z.string().optional(),\n max_length: z.number().optional(),\n min_trace_thickness: z.number().optional(),\n display_name: z.string().optional(),\n})\n\ntype InferredSourceTrace = z.infer<typeof source_trace>\n\nexpectTypesMatch<SourceTrace, InferredSourceTrace>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_group = z.object({\n type: z.literal(\"source_group\"),\n source_group_id: z.string(),\n subcircuit_id: z.string().optional(),\n parent_subcircuit_id: z.string().optional(),\n parent_source_group_id: z.string().optional(),\n is_subcircuit: z.boolean().optional(),\n show_as_schematic_box: z.boolean().optional(),\n name: z.string().optional(),\n was_automatically_named: z.boolean().optional(),\n})\n\nexport type SourceGroupInput = z.input<typeof source_group>\ntype InferredSourceGroup = z.infer<typeof source_group>\n\nexport interface SourceGroup {\n type: \"source_group\"\n source_group_id: string\n subcircuit_id?: string\n parent_subcircuit_id?: string\n parent_source_group_id?: string\n is_subcircuit?: boolean\n show_as_schematic_box?: boolean\n name?: string\n was_automatically_named?: boolean\n}\n\nexpectTypesMatch<SourceGroup, InferredSourceGroup>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_net = z.object({\n type: z.literal(\"source_net\"),\n source_net_id: z.string(),\n name: z.string(),\n member_source_group_ids: z.array(z.string()),\n is_power: z.boolean().optional(),\n is_ground: z.boolean().optional(),\n is_digital_signal: z.boolean().optional(),\n is_analog_signal: z.boolean().optional(),\n is_positive_voltage_source: z.boolean().optional(),\n trace_width: z.number().optional(),\n subcircuit_id: z.string().optional(),\n subcircuit_connectivity_map_key: z.string().optional(),\n})\n\nexport type SourceNetInput = z.input<typeof source_net>\ntype InferredSourceNet = z.infer<typeof source_net>\n\nexport interface SourceNet {\n type: \"source_net\"\n source_net_id: string\n name: string\n member_source_group_ids: string[]\n is_power?: boolean\n is_ground?: boolean\n is_digital_signal?: boolean\n is_analog_signal?: boolean\n is_positive_voltage_source?: boolean\n trace_width?: number\n subcircuit_id?: string\n subcircuit_connectivity_map_key?: string\n}\n\nexpectTypesMatch<SourceNet, InferredSourceNet>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_board = z\n .object({\n type: z.literal(\"source_board\"),\n source_board_id: z.string(),\n source_group_id: z.string(),\n title: z.string().optional(),\n })\n .describe(\"Defines a board in the source domain\")\n\nexport type SourceBoardInput = z.input<typeof source_board>\ntype InferredSourceBoard = z.infer<typeof source_board>\n\n/**\n * Defines a board in the source domain\n */\nexport interface SourceBoard {\n type: \"source_board\"\n source_board_id: string\n source_group_id: string\n title?: string\n}\n\nexpectTypesMatch<SourceBoard, InferredSourceBoard>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_ambiguous_port_reference = base_circuit_json_error\n .extend({\n type: z.literal(\"source_ambiguous_port_reference\"),\n source_ambiguous_port_reference_id: getZodPrefixedIdWithDefault(\n \"source_ambiguous_port_reference\",\n ),\n error_type: z\n .literal(\"source_ambiguous_port_reference\")\n .default(\"source_ambiguous_port_reference\"),\n source_port_id: z.string().optional(),\n source_component_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when a port hint matches multiple non-overlapping pads, making the port reference ambiguous\",\n )\n\nexport type SourceAmbiguousPortReferenceInput = z.input<\n typeof source_ambiguous_port_reference\n>\ntype InferredSourceAmbiguousPortReference = z.infer<\n typeof source_ambiguous_port_reference\n>\n\n/**\n * Error emitted when a port hint matches multiple non-overlapping pads,\n * making the port reference ambiguous (e.g. multiple pads all named \"SH\").\n */\nexport interface SourceAmbiguousPortReference extends BaseCircuitJsonError {\n type: \"source_ambiguous_port_reference\"\n source_ambiguous_port_reference_id: string\n error_type: \"source_ambiguous_port_reference\"\n source_port_id?: string\n source_component_id?: string\n}\n\nexpectTypesMatch<\n SourceAmbiguousPortReference,\n InferredSourceAmbiguousPortReference\n>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_pcb_ground_plane = z\n .object({\n type: z.literal(\"source_pcb_ground_plane\"),\n source_pcb_ground_plane_id: z.string(),\n source_group_id: z.string(),\n source_net_id: z.string(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a ground plane in the source domain\")\n\nexport type SourcePcbGroundPlaneInput = z.input<typeof source_pcb_ground_plane>\ntype InferredSourcePcbGroundPlane = z.infer<typeof source_pcb_ground_plane>\n\n/**\n * Defines a ground plane in the source domain\n */\nexport interface SourcePcbGroundPlane {\n type: \"source_pcb_ground_plane\"\n source_pcb_ground_plane_id: string\n source_group_id: string\n source_net_id: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<SourcePcbGroundPlane, InferredSourcePcbGroundPlane>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_manually_placed_via = z\n .object({\n type: z.literal(\"source_manually_placed_via\"),\n source_manually_placed_via_id: z.string(),\n source_group_id: z.string(),\n source_net_id: z.string(),\n subcircuit_id: z.string().optional(),\n source_trace_id: z.string().optional(),\n })\n .describe(\"Defines a via that is manually placed in the source domain\")\n\nexport type SourceManuallyPlacedViaInput = z.input<\n typeof source_manually_placed_via\n>\ntype InferredSourceManuallyPlacedVia = z.infer<\n typeof source_manually_placed_via\n>\n\n/**\n * Defines a via that is manually placed in the source domain\n */\nexport interface SourceManuallyPlacedVia {\n type: \"source_manually_placed_via\"\n source_manually_placed_via_id: string\n source_group_id: string\n source_net_id: string\n subcircuit_id?: string\n source_trace_id?: string\n}\n\nexpectTypesMatch<SourceManuallyPlacedVia, InferredSourceManuallyPlacedVia>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const all_layers = [\n \"top\",\n \"bottom\",\n \"inner1\",\n \"inner2\",\n \"inner3\",\n \"inner4\",\n \"inner5\",\n \"inner6\",\n] as const\n\nexport const layer_string = z.enum(all_layers)\n\nexport const layer_ref = layer_string\n .or(\n z.object({\n name: layer_string,\n }),\n )\n .transform((layer) => {\n if (typeof layer === \"string\") {\n return layer\n }\n return layer.name\n })\n\nexport type LayerRefInput = z.input<typeof layer_ref>\ntype InferredLayerRef = z.output<typeof layer_ref>\nexport type LayerRef = (typeof all_layers)[number]\n\nexpectTypesMatch<LayerRef, InferredLayerRef>(true)\n\nexport const visible_layer = z.enum([\"top\", \"bottom\"])\nexport type VisibleLayerRef = z.infer<typeof visible_layer>\nexport type VisibleLayer = z.infer<typeof visible_layer>\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_no_power_pin_defined_warning = z\n .object({\n type: z.literal(\"source_no_power_pin_defined_warning\"),\n source_no_power_pin_defined_warning_id: getZodPrefixedIdWithDefault(\n \"source_no_power_pin_defined_warning\",\n ),\n warning_type: z\n .literal(\"source_no_power_pin_defined_warning\")\n .default(\"source_no_power_pin_defined_warning\"),\n message: z.string(),\n source_component_id: z.string(),\n source_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Warning emitted when a chip has no source ports with requires_power=true\",\n )\n\nexport type SourceNoPowerPinDefinedWarningInput = z.input<\n typeof source_no_power_pin_defined_warning\n>\ntype InferredSourceNoPowerPinDefinedWarning = z.infer<\n typeof source_no_power_pin_defined_warning\n>\n\n/**\n * Warning emitted when a chip has no source ports with requires_power=true\n */\nexport interface SourceNoPowerPinDefinedWarning {\n type: \"source_no_power_pin_defined_warning\"\n source_no_power_pin_defined_warning_id: string\n warning_type: \"source_no_power_pin_defined_warning\"\n message: string\n source_component_id: string\n source_port_ids: string[]\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SourceNoPowerPinDefinedWarning,\n InferredSourceNoPowerPinDefinedWarning\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_no_ground_pin_defined_warning = z\n .object({\n type: z.literal(\"source_no_ground_pin_defined_warning\"),\n source_no_ground_pin_defined_warning_id: getZodPrefixedIdWithDefault(\n \"source_no_ground_pin_defined_warning\",\n ),\n warning_type: z\n .literal(\"source_no_ground_pin_defined_warning\")\n .default(\"source_no_ground_pin_defined_warning\"),\n message: z.string(),\n source_component_id: z.string(),\n source_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Warning emitted when a chip has no source ports marked as ground pins\",\n )\n\nexport type SourceNoGroundPinDefinedWarningInput = z.input<\n typeof source_no_ground_pin_defined_warning\n>\ntype InferredSourceNoGroundPinDefinedWarning = z.infer<\n typeof source_no_ground_pin_defined_warning\n>\n\n/**\n * Warning emitted when a chip has no source ports marked as ground pins\n */\nexport interface SourceNoGroundPinDefinedWarning {\n type: \"source_no_ground_pin_defined_warning\"\n source_no_ground_pin_defined_warning_id: string\n warning_type: \"source_no_ground_pin_defined_warning\"\n message: string\n source_component_id: string\n source_port_ids: string[]\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SourceNoGroundPinDefinedWarning,\n InferredSourceNoGroundPinDefinedWarning\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_component_pins_underspecified_warning = z\n .object({\n type: z.literal(\"source_component_pins_underspecified_warning\"),\n source_component_pins_underspecified_warning_id:\n getZodPrefixedIdWithDefault(\n \"source_component_pins_underspecified_warning\",\n ),\n warning_type: z\n .literal(\"source_component_pins_underspecified_warning\")\n .default(\"source_component_pins_underspecified_warning\"),\n message: z.string(),\n source_component_id: z.string(),\n source_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Warning emitted when all ports on a source component are underspecified\",\n )\n\nexport type SourceComponentPinsUnderspecifiedWarningInput = z.input<\n typeof source_component_pins_underspecified_warning\n>\ntype InferredSourceComponentPinsUnderspecifiedWarning = z.infer<\n typeof source_component_pins_underspecified_warning\n>\n\n/**\n * Warning emitted when all ports on a source component are underspecified\n */\nexport interface SourceComponentPinsUnderspecifiedWarning {\n type: \"source_component_pins_underspecified_warning\"\n source_component_pins_underspecified_warning_id: string\n warning_type: \"source_component_pins_underspecified_warning\"\n message: string\n source_component_id: string\n source_port_ids: string[]\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SourceComponentPinsUnderspecifiedWarning,\n InferredSourceComponentPinsUnderspecifiedWarning\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_pin_must_be_connected_error = base_circuit_json_error\n .extend({\n type: z.literal(\"source_pin_must_be_connected_error\"),\n source_pin_must_be_connected_error_id: getZodPrefixedIdWithDefault(\n \"source_pin_must_be_connected_error\",\n ),\n error_type: z\n .literal(\"source_pin_must_be_connected_error\")\n .default(\"source_pin_must_be_connected_error\"),\n source_component_id: z.string(),\n source_port_id: z.string(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when a pin with mustBeConnected attribute is not connected to any trace\",\n )\n\nexport type SourcePinMustBeConnectedErrorInput = z.input<\n typeof source_pin_must_be_connected_error\n>\ntype InferredSourcePinMustBeConnectedError = z.infer<\n typeof source_pin_must_be_connected_error\n>\n\n/**\n * Error emitted when a pin with mustBeConnected attribute is not connected to any trace\n */\nexport interface SourcePinMustBeConnectedError extends BaseCircuitJsonError {\n type: \"source_pin_must_be_connected_error\"\n source_pin_must_be_connected_error_id: string\n error_type: \"source_pin_must_be_connected_error\"\n source_component_id: string\n source_port_id: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SourcePinMustBeConnectedError,\n InferredSourcePinMustBeConnectedError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const unknown_error_finding_part = base_circuit_json_error\n .extend({\n type: z.literal(\"unknown_error_finding_part\"),\n unknown_error_finding_part_id: getZodPrefixedIdWithDefault(\n \"unknown_error_finding_part\",\n ),\n error_type: z\n .literal(\"unknown_error_finding_part\")\n .default(\"unknown_error_finding_part\"),\n source_component_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when an unexpected error occurs while finding a part\",\n )\n\nexport type UnknownErrorFindingPartInput = z.input<\n typeof unknown_error_finding_part\n>\ntype InferredUnknownErrorFindingPart = z.infer<\n typeof unknown_error_finding_part\n>\n\n/**\n * Error emitted when an unexpected error occurs while finding a part.\n * This includes cases where the API returns HTML instead of JSON,\n * network failures, or other unexpected responses.\n */\nexport interface UnknownErrorFindingPart extends BaseCircuitJsonError {\n type: \"unknown_error_finding_part\"\n unknown_error_finding_part_id: string\n error_type: \"unknown_error_finding_part\"\n source_component_id?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<UnknownErrorFindingPart, InferredUnknownErrorFindingPart>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicBox {\n type: \"schematic_box\"\n schematic_component_id?: string\n schematic_symbol_id?: string\n width: number\n height: number\n is_dashed: boolean\n x: number\n y: number\n subcircuit_id?: string\n}\n\nexport const schematic_box = z\n .object({\n type: z.literal(\"schematic_box\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n width: distance,\n height: distance,\n is_dashed: z.boolean().default(false),\n x: distance,\n y: distance,\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Draws a box on the schematic\")\n\nexport type SchematicBoxInput = z.input<typeof schematic_box>\ntype InferredSchematicBox = z.infer<typeof schematic_box>\n\nexpectTypesMatch<SchematicBox, InferredSchematicBox>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { distance } from \"../units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicPath {\n type: \"schematic_path\"\n schematic_path_id: string\n schematic_component_id?: string\n schematic_symbol_id?: string\n fill_color?: string\n is_filled?: boolean\n stroke_width?: number | null\n stroke_color?: string\n points: Point[]\n subcircuit_id?: string\n}\n\nexport const schematic_path = z.object({\n type: z.literal(\"schematic_path\"),\n schematic_path_id: getZodPrefixedIdWithDefault(\"schematic_path\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n fill_color: z.string().optional(),\n is_filled: z.boolean().optional(),\n stroke_width: distance.nullable().optional(),\n stroke_color: z.string().optional(),\n points: z.array(point),\n subcircuit_id: z.string().optional(),\n})\n\nexport type SchematicPathInput = z.input<typeof schematic_path>\ntype InferredSchematicPath = z.infer<typeof schematic_path>\n\nexpectTypesMatch<SchematicPath, InferredSchematicPath>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { size, type Size } from \"../common/size\"\nimport { length } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_pin_styles = z.record(\n z.object({\n left_margin: length.optional(),\n right_margin: length.optional(),\n top_margin: length.optional(),\n bottom_margin: length.optional(),\n }),\n)\n\nexport interface SchematicPortArrangementBySize {\n left_size: number\n right_size: number\n top_size?: number\n bottom_size?: number\n}\n\nexport interface SchematicPortArrangementBySides {\n left_side?: { pins: number[]; direction?: \"top-to-bottom\" | \"bottom-to-top\" }\n right_side?: { pins: number[]; direction?: \"top-to-bottom\" | \"bottom-to-top\" }\n top_side?: { pins: number[]; direction?: \"left-to-right\" | \"right-to-left\" }\n bottom_side?: {\n pins: number[]\n direction?: \"left-to-right\" | \"right-to-left\"\n }\n}\n\nexport type SchematicPortArrangement =\n | SchematicPortArrangementBySize\n | SchematicPortArrangementBySides\n\nexport interface SchematicComponent {\n type: \"schematic_component\"\n size: Size\n center: Point\n source_component_id?: string\n schematic_component_id: string\n schematic_symbol_id?: string\n pin_spacing?: number\n pin_styles?: Record<\n string,\n {\n left_margin?: number\n right_margin?: number\n top_margin?: number\n bottom_margin?: number\n }\n >\n box_width?: number\n symbol_name?: string\n port_arrangement?: SchematicPortArrangement\n port_labels?: Record<string, string>\n symbol_display_value?: string\n subcircuit_id?: string\n schematic_group_id?: string\n is_schematic_group?: boolean\n source_group_id?: string\n is_box_with_pins: boolean\n}\n\nexport const schematic_component_port_arrangement_by_size = z.object({\n left_size: z.number(),\n right_size: z.number(),\n top_size: z.number().optional(),\n bottom_size: z.number().optional(),\n})\n\nexpectTypesMatch<\n SchematicPortArrangementBySize,\n z.infer<typeof schematic_component_port_arrangement_by_size>\n>(true)\n\nexport const schematic_component_port_arrangement_by_sides = z.object({\n left_side: z\n .object({\n pins: z.array(z.number()),\n // @ts-ignore\n direction: z.enum([\"top-to-bottom\", \"bottom-to-top\"]).optional(),\n })\n .optional(),\n right_side: z\n .object({\n pins: z.array(z.number()),\n // @ts-ignore\n direction: z.enum([\"top-to-bottom\", \"bottom-to-top\"]).optional(),\n })\n .optional(),\n top_side: z\n .object({\n pins: z.array(z.number()),\n // @ts-ignore\n direction: z.enum([\"left-to-right\", \"right-to-left\"]).optional(),\n })\n .optional(),\n bottom_side: z\n .object({\n pins: z.array(z.number()),\n // @ts-ignore\n direction: z.enum([\"left-to-right\", \"right-to-left\"]).optional(),\n })\n .optional(),\n})\n\nexpectTypesMatch<\n SchematicPortArrangementBySides,\n z.infer<typeof schematic_component_port_arrangement_by_sides>\n>(true)\n\nexport const port_arrangement = z.union([\n schematic_component_port_arrangement_by_size,\n schematic_component_port_arrangement_by_sides,\n])\n\nexport const schematic_component = z.object({\n type: z.literal(\"schematic_component\"),\n size,\n center: point,\n source_component_id: z.string().optional(),\n schematic_component_id: z.string(),\n schematic_symbol_id: z.string().optional(),\n pin_spacing: length.optional(),\n pin_styles: schematic_pin_styles.optional(),\n box_width: length.optional(),\n symbol_name: z.string().optional(),\n port_arrangement: port_arrangement.optional(),\n port_labels: z.record(z.string()).optional(),\n symbol_display_value: z.string().optional(),\n subcircuit_id: z.string().optional(),\n schematic_group_id: z.string().optional(),\n is_schematic_group: z.boolean().optional(),\n source_group_id: z.string().optional(),\n is_box_with_pins: z.boolean().optional().default(true),\n})\n\nexport type SchematicComponentInput = z.input<typeof schematic_component>\ntype InferredSchematicComponent = z.infer<typeof schematic_component>\n\nexpectTypesMatch<SchematicComponent, InferredSchematicComponent>(true)\n","import { kicadSymbolMetadata } from \"src/common/kicadSymbolMetadata\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\n\nconst schematicSymbolMetadata = z\n .object({\n kicad_symbol: kicadSymbolMetadata.optional(),\n })\n .catchall(z.unknown())\n\nexport type SchematicSymbolMetadata = z.infer<typeof schematicSymbolMetadata>\n\nexport interface SchematicSymbol {\n type: \"schematic_symbol\"\n schematic_symbol_id: string\n name?: string\n metadata?: SchematicSymbolMetadata\n}\n\nexport const schematic_symbol = z\n .object({\n type: z.literal(\"schematic_symbol\"),\n schematic_symbol_id: z.string(),\n name: z.string().optional(),\n metadata: schematicSymbolMetadata.optional(),\n })\n .describe(\n \"Defines a named schematic symbol that can be referenced by components.\",\n )\n\nexport type SchematicSymbolInput = z.input<typeof schematic_symbol>\ntype InferredSchematicSymbol = z.infer<typeof schematic_symbol>\n\nexpectTypesMatch<SchematicSymbol, InferredSchematicSymbol>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/** Draws a styled line on the schematic */\nexport interface SchematicLine {\n type: \"schematic_line\"\n schematic_line_id: string\n schematic_component_id?: string\n schematic_symbol_id?: string\n x1: number\n y1: number\n x2: number\n y2: number\n stroke_width?: number | null\n color: string\n is_dashed: boolean\n subcircuit_id?: string\n}\n\nexport const schematic_line = z\n .object({\n type: z.literal(\"schematic_line\"),\n schematic_line_id: getZodPrefixedIdWithDefault(\"schematic_line\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n x1: distance,\n y1: distance,\n x2: distance,\n y2: distance,\n stroke_width: distance.nullable().optional(),\n color: z.string().default(\"#000000\"),\n is_dashed: z.boolean().default(false),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Draws a styled line on the schematic\")\n\nexport type SchematicLineInput = z.input<typeof schematic_line>\ntype InferredSchematicLine = z.infer<typeof schematic_line>\n\nexpectTypesMatch<SchematicLine, InferredSchematicLine>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { distance, rotation } from \"../units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/** Draws a styled rectangle on the schematic */\nexport interface SchematicRect {\n type: \"schematic_rect\"\n schematic_rect_id: string\n schematic_component_id?: string\n schematic_symbol_id?: string\n center: Point\n width: number\n height: number\n rotation: number\n stroke_width?: number | null\n color: string\n is_filled: boolean\n fill_color?: string\n is_dashed: boolean\n subcircuit_id?: string\n}\n\nexport const schematic_rect = z\n .object({\n type: z.literal(\"schematic_rect\"),\n schematic_rect_id: getZodPrefixedIdWithDefault(\"schematic_rect\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n center: point,\n width: distance,\n height: distance,\n rotation: rotation.default(0),\n stroke_width: distance.nullable().optional(),\n color: z.string().default(\"#000000\"),\n is_filled: z.boolean().default(false),\n fill_color: z.string().optional(),\n is_dashed: z.boolean().default(false),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Draws a styled rectangle on the schematic\")\n\nexport type SchematicRectInput = z.input<typeof schematic_rect>\ntype InferredSchematicRect = z.infer<typeof schematic_rect>\n\nexpectTypesMatch<SchematicRect, InferredSchematicRect>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { distance } from \"../units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/** Draws a styled circle on the schematic */\nexport interface SchematicCircle {\n type: \"schematic_circle\"\n schematic_circle_id: string\n schematic_component_id?: string\n schematic_symbol_id?: string\n center: Point\n radius: number\n stroke_width?: number | null\n color: string\n is_filled: boolean\n fill_color?: string\n is_dashed: boolean\n subcircuit_id?: string\n}\n\nexport const schematic_circle = z\n .object({\n type: z.literal(\"schematic_circle\"),\n schematic_circle_id: getZodPrefixedIdWithDefault(\"schematic_circle\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n center: point,\n radius: distance,\n stroke_width: distance.nullable().optional(),\n color: z.string().default(\"#000000\"),\n is_filled: z.boolean().default(false),\n fill_color: z.string().optional(),\n is_dashed: z.boolean().default(false),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Draws a styled circle on the schematic\")\n\nexport type SchematicCircleInput = z.input<typeof schematic_circle>\ntype InferredSchematicCircle = z.infer<typeof schematic_circle>\n\nexpectTypesMatch<SchematicCircle, InferredSchematicCircle>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { distance, rotation } from \"../units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/** Draws a styled arc on the schematic */\nexport interface SchematicArc {\n type: \"schematic_arc\"\n schematic_arc_id: string\n schematic_component_id?: string\n schematic_symbol_id?: string\n center: Point\n radius: number\n start_angle_degrees: number\n end_angle_degrees: number\n direction: \"clockwise\" | \"counterclockwise\"\n stroke_width?: number | null\n color: string\n is_dashed: boolean\n subcircuit_id?: string\n}\n\nexport const schematic_arc = z\n .object({\n type: z.literal(\"schematic_arc\"),\n schematic_arc_id: getZodPrefixedIdWithDefault(\"schematic_arc\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n center: point,\n radius: distance,\n start_angle_degrees: rotation,\n end_angle_degrees: rotation,\n direction: z\n .enum([\"clockwise\", \"counterclockwise\"])\n .default(\"counterclockwise\"),\n stroke_width: distance.nullable().optional(),\n color: z.string().default(\"#000000\"),\n is_dashed: z.boolean().default(false),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Draws a styled arc on the schematic\")\n\nexport type SchematicArcInput = z.input<typeof schematic_arc>\ntype InferredSchematicArc = z.infer<typeof schematic_arc>\n\nexpectTypesMatch<SchematicArc, InferredSchematicArc>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicTraceEdge {\n from: {\n x: number\n y: number\n }\n to: {\n x: number\n y: number\n }\n is_crossing?: boolean\n from_schematic_port_id?: string\n to_schematic_port_id?: string\n}\n\nexport interface SchematicTrace {\n type: \"schematic_trace\"\n schematic_trace_id: string\n source_trace_id?: string\n junctions: {\n x: number\n y: number\n }[]\n edges: SchematicTraceEdge[]\n subcircuit_id?: string\n /** Optional for now, but will be required in a future release */\n subcircuit_connectivity_map_key?: string\n}\n\nexport const schematic_trace = z.object({\n type: z.literal(\"schematic_trace\"),\n schematic_trace_id: z.string(),\n source_trace_id: z.string().optional(),\n junctions: z.array(\n z.object({\n x: z.number(),\n y: z.number(),\n }),\n ),\n edges: z.array(\n z.object({\n from: z.object({\n x: z.number(),\n y: z.number(),\n }),\n to: z.object({\n x: z.number(),\n y: z.number(),\n }),\n is_crossing: z.boolean().optional(),\n from_schematic_port_id: z.string().optional(),\n to_schematic_port_id: z.string().optional(),\n }),\n ),\n subcircuit_id: z.string().optional(),\n // TODO: make required in a future release\n subcircuit_connectivity_map_key: z.string().optional(),\n})\n\nexport type SchematicTraceInput = z.input<typeof schematic_trace>\ntype InferredSchematicTrace = z.infer<typeof schematic_trace>\n\nexpectTypesMatch<SchematicTraceInput, InferredSchematicTrace>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { ninePointAnchor } from \"src/common/NinePointAnchor\"\nimport type { NinePointAnchor } from \"src/common/NinePointAnchor\"\nimport type { FivePointAnchor } from \"src/common/FivePointAnchor\"\nimport { fivePointAnchor } from \"src/common/FivePointAnchor\"\n\nexport interface SchematicText {\n type: \"schematic_text\"\n schematic_component_id?: string\n schematic_symbol_id?: string\n schematic_text_id: string\n text: string\n font_size: number\n position: {\n x: number\n y: number\n }\n rotation: number\n anchor: NinePointAnchor | FivePointAnchor\n color: string\n subcircuit_id?: string\n}\n\nexport const schematic_text = z.object({\n type: z.literal(\"schematic_text\"),\n schematic_component_id: z.string().optional(),\n schematic_symbol_id: z.string().optional(),\n schematic_text_id: z.string(),\n text: z.string(),\n font_size: z.number().default(0.18),\n position: z.object({\n x: distance,\n y: distance,\n }),\n rotation: z.number().default(0),\n anchor: z\n .union([fivePointAnchor.describe(\"legacy\"), ninePointAnchor])\n .default(\"center\"),\n color: z.string().default(\"#000000\"),\n subcircuit_id: z.string().optional(),\n})\n\nexport type SchematicTextInput = z.input<typeof schematic_text>\ntype InferredSchematicText = z.infer<typeof schematic_text>\n\nexpectTypesMatch<SchematicText, InferredSchematicText>(true)\n","import { z } from \"zod\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport type FivePointAnchor = \"center\" | \"left\" | \"right\" | \"top\" | \"bottom\"\n\nexport const fivePointAnchor = z.enum([\n \"center\",\n \"left\",\n \"right\",\n \"top\",\n \"bottom\",\n])\n\ntype InferredFivePointAnchor = z.infer<typeof fivePointAnchor>\n\nexpectTypesMatch<FivePointAnchor, InferredFivePointAnchor>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicPort {\n type: \"schematic_port\"\n schematic_port_id: string\n source_port_id: string\n schematic_component_id?: string\n center: Point\n facing_direction?: \"up\" | \"down\" | \"left\" | \"right\"\n distance_from_component_edge?: number\n side_of_component?: \"top\" | \"bottom\" | \"left\" | \"right\"\n true_ccw_index?: number\n pin_number?: number\n display_pin_label?: string\n subcircuit_id?: string\n is_connected?: boolean\n has_input_arrow?: boolean\n has_output_arrow?: boolean\n is_drawn_with_inversion_circle?: boolean\n}\n\nexport const schematic_port = z\n .object({\n type: z.literal(\"schematic_port\"),\n schematic_port_id: z.string(),\n source_port_id: z.string(),\n schematic_component_id: z.string().optional(),\n center: point,\n facing_direction: z.enum([\"up\", \"down\", \"left\", \"right\"]).optional(),\n distance_from_component_edge: z.number().optional(),\n side_of_component: z.enum([\"top\", \"bottom\", \"left\", \"right\"]).optional(),\n true_ccw_index: z.number().optional(),\n pin_number: z.number().optional(),\n display_pin_label: z.string().optional(),\n subcircuit_id: z.string().optional(),\n is_connected: z.boolean().optional(),\n has_input_arrow: z.boolean().optional(),\n has_output_arrow: z.boolean().optional(),\n is_drawn_with_inversion_circle: z.boolean().optional(),\n })\n .describe(\"Defines a port on a schematic component\")\n\nexport type SchematicPortInput = z.input<typeof schematic_port>\ntype InferredSchematicPort = z.infer<typeof schematic_port>\n\nexpectTypesMatch<SchematicPort, InferredSchematicPort>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\n\nexport interface SchematicNetLabel {\n type: \"schematic_net_label\"\n schematic_net_label_id: string\n schematic_trace_id?: string\n source_trace_id?: string\n source_net_id: string\n center: Point\n anchor_position?: Point | undefined\n anchor_side: \"top\" | \"bottom\" | \"left\" | \"right\"\n text: string\n symbol_name?: string | undefined\n /**\n * When true the net label can be repositioned. When false the label's\n * position is fixed by the element it is attached to.\n */\n is_movable?: boolean\n subcircuit_id?: string\n}\n\nexport const schematic_net_label = z.object({\n type: z.literal(\"schematic_net_label\"),\n schematic_net_label_id: getZodPrefixedIdWithDefault(\"schematic_net_label\"),\n schematic_trace_id: z.string().optional(),\n source_trace_id: z.string().optional(),\n source_net_id: z.string(),\n center: point,\n anchor_position: point.optional(),\n anchor_side: z.enum([\"top\", \"bottom\", \"left\", \"right\"]),\n text: z.string(),\n symbol_name: z.string().optional(),\n is_movable: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n})\n\nexport type SchematicNetLabelInput = z.input<typeof schematic_net_label>\nexport type InferredSchematicNetLabel = z.infer<typeof schematic_net_label>\n\nexpectTypesMatch<SchematicNetLabel, InferredSchematicNetLabel>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicError extends BaseCircuitJsonError {\n type: \"schematic_error\"\n schematic_error_id: string\n error_type: \"schematic_port_not_found\"\n subcircuit_id?: string\n}\n\nexport const schematic_error = base_circuit_json_error\n .extend({\n type: z.literal(\"schematic_error\"),\n schematic_error_id: z.string(),\n // eventually each error type should be broken out into a dir of files\n error_type: z\n .literal(\"schematic_port_not_found\")\n .default(\"schematic_port_not_found\"),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a schematic error on the schematic\")\n\nexport type SchematicErrorInput = z.input<typeof schematic_error>\ntype InferredSchematicError = z.infer<typeof schematic_error>\n\nexpectTypesMatch<SchematicError, InferredSchematicError>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_layout_error = base_circuit_json_error\n .extend({\n type: z.literal(\"schematic_layout_error\"),\n schematic_layout_error_id: getZodPrefixedIdWithDefault(\n \"schematic_layout_error\",\n ),\n error_type: z\n .literal(\"schematic_layout_error\")\n .default(\"schematic_layout_error\"),\n source_group_id: z.string(),\n schematic_group_id: z.string(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Error emitted when schematic layout fails for a group\")\n\nexport type SchematicLayoutErrorInput = z.input<typeof schematic_layout_error>\ntype InferredSchematicLayoutError = z.infer<typeof schematic_layout_error>\n\nexport interface SchematicLayoutError extends BaseCircuitJsonError {\n type: \"schematic_layout_error\"\n schematic_layout_error_id: string\n error_type: \"schematic_layout_error\"\n source_group_id: string\n schematic_group_id: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<SchematicLayoutError, InferredSchematicLayoutError>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { size, type Size } from \"../common/size\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_debug_object_base = z.object({\n type: z.literal(\"schematic_debug_object\"),\n label: z.string().optional(),\n subcircuit_id: z.string().optional(),\n})\n\nexport const schematic_debug_rect = schematic_debug_object_base.extend({\n shape: z.literal(\"rect\"),\n center: point,\n size: size,\n})\n\nexport const schematic_debug_line = schematic_debug_object_base.extend({\n shape: z.literal(\"line\"),\n start: point,\n end: point,\n})\n\nexport const schematic_debug_point = schematic_debug_object_base.extend({\n shape: z.literal(\"point\"),\n center: point,\n})\n\nexport const schematic_debug_object = z.discriminatedUnion(\"shape\", [\n schematic_debug_rect,\n schematic_debug_line,\n schematic_debug_point,\n])\ntype InferredSchematicDebugObject = z.infer<typeof schematic_debug_object>\n\nexport interface SchematicDebugRect {\n type: \"schematic_debug_object\"\n label?: string\n shape: \"rect\"\n center: Point\n size: Size\n subcircuit_id?: string\n}\n\nexport interface SchematicDebugLine {\n type: \"schematic_debug_object\"\n label?: string\n shape: \"line\"\n start: Point\n end: Point\n subcircuit_id?: string\n}\n\nexport interface SchematicDebugPoint {\n type: \"schematic_debug_object\"\n label?: string\n shape: \"point\"\n center: Point\n subcircuit_id?: string\n}\n\nexport type SchematicDebugObject =\n | SchematicDebugRect\n | SchematicDebugLine\n | SchematicDebugPoint\n\nexpectTypesMatch<SchematicDebugObject, InferredSchematicDebugObject>(true)\nexport type SchematicDebugObjectInput = z.input<typeof schematic_debug_object>\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common/point\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { voltage } from \"src/units\"\nimport {\n ninePointAnchor,\n type NinePointAnchor,\n} from \"src/common/NinePointAnchor\"\n\nexport interface SchematicVoltageProbe {\n type: \"schematic_voltage_probe\"\n schematic_voltage_probe_id: string\n source_component_id?: string\n name?: string\n position: Point\n schematic_trace_id: string\n voltage?: number\n subcircuit_id?: string\n color?: string\n label_alignment?: NinePointAnchor\n}\n\nexport const schematic_voltage_probe = z\n .object({\n type: z.literal(\"schematic_voltage_probe\"),\n schematic_voltage_probe_id: z.string(),\n source_component_id: z.string().optional(),\n name: z.string().optional(),\n position: point,\n schematic_trace_id: z.string(),\n voltage: voltage.optional(),\n subcircuit_id: z.string().optional(),\n color: z.string().optional(),\n label_alignment: ninePointAnchor.optional(),\n })\n .describe(\"Defines a voltage probe measurement point on a schematic trace\")\n\nexport type SchematicVoltageProbeInput = z.input<typeof schematic_voltage_probe>\ntype InferredSchematicVoltageProbe = z.infer<typeof schematic_voltage_probe>\n\nexpectTypesMatch<SchematicVoltageProbe, InferredSchematicVoltageProbe>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"../common\"\nimport { expectTypesMatch } from \"../utils/expect-types-match\"\n\nexport const schematic_manual_edit_conflict_warning = z\n .object({\n type: z.literal(\"schematic_manual_edit_conflict_warning\"),\n schematic_manual_edit_conflict_warning_id: getZodPrefixedIdWithDefault(\n \"schematic_manual_edit_conflict_warning\",\n ),\n warning_type: z\n .literal(\"schematic_manual_edit_conflict_warning\")\n .default(\"schematic_manual_edit_conflict_warning\"),\n message: z.string(),\n schematic_component_id: z.string(),\n schematic_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n source_component_id: z.string(),\n })\n .describe(\n \"Warning emitted when a component has both manual placement and explicit schX/schY coordinates\",\n )\n\nexport type SchematicManualEditConflictWarningInput = z.input<\n typeof schematic_manual_edit_conflict_warning\n>\ntype InferredSchematicManualEditConflictWarning = z.infer<\n typeof schematic_manual_edit_conflict_warning\n>\n\n/**\n * Warning emitted when a component has both manual placement (via manualEdits) and explicit schX/schY coordinates\n */\nexport interface SchematicManualEditConflictWarning {\n type: \"schematic_manual_edit_conflict_warning\"\n schematic_manual_edit_conflict_warning_id: string\n warning_type: \"schematic_manual_edit_conflict_warning\"\n message: string\n schematic_component_id: string\n schematic_group_id?: string\n subcircuit_id?: string\n source_component_id: string\n}\n\nexpectTypesMatch<\n SchematicManualEditConflictWarning,\n InferredSchematicManualEditConflictWarning\n>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_group = z\n .object({\n type: z.literal(\"schematic_group\"),\n schematic_group_id: getZodPrefixedIdWithDefault(\"schematic_group\"),\n source_group_id: z.string(),\n is_subcircuit: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n width: length,\n height: length,\n center: point,\n schematic_component_ids: z.array(z.string()),\n show_as_schematic_box: z.boolean().optional(),\n name: z.string().optional(),\n description: z.string().optional(),\n })\n .describe(\"Defines a group of components on the schematic\")\n\nexport type SchematicGroupInput = z.input<typeof schematic_group>\ntype InferredSchematicGroup = z.infer<typeof schematic_group>\n\n/**\n * Defines a group of components on the schematic\n */\nexport interface SchematicGroup {\n type: \"schematic_group\"\n schematic_group_id: string\n source_group_id: string\n is_subcircuit?: boolean\n subcircuit_id?: string\n width: Length\n height: Length\n center: Point\n schematic_component_ids: string[]\n show_as_schematic_box?: boolean\n name?: string\n description?: string\n}\n\nexpectTypesMatch<SchematicGroup, InferredSchematicGroup>(true)\n","import { z } from \"zod\"\nimport {\n getZodPrefixedIdWithDefault,\n ninePointAnchor,\n point,\n type NinePointAnchor,\n type Point,\n} from \"src/common\"\nimport { distance, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_table = z\n .object({\n type: z.literal(\"schematic_table\"),\n schematic_table_id: getZodPrefixedIdWithDefault(\"schematic_table\"),\n anchor_position: point,\n column_widths: z.array(distance),\n row_heights: z.array(distance),\n cell_padding: distance.optional(),\n border_width: distance.optional(),\n subcircuit_id: z.string().optional(),\n schematic_component_id: z.string().optional(),\n anchor: ninePointAnchor.optional(),\n })\n .describe(\"Defines a table on the schematic\")\n\nexport type SchematicTableInput = z.input<typeof schematic_table>\ntype InferredSchematicTable = z.infer<typeof schematic_table>\n\n/**\n * Defines a table on the schematic, useful for displaying data in a structured format.\n */\nexport interface SchematicTable {\n type: \"schematic_table\"\n schematic_table_id: string\n anchor_position: Point\n column_widths: Length[]\n row_heights: Length[]\n cell_padding?: Length\n border_width?: Length\n subcircuit_id?: string\n schematic_component_id?: string\n anchor?: NinePointAnchor\n}\n\nexpectTypesMatch<SchematicTable, InferredSchematicTable>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault, point, type Point } from \"src/common\"\nimport { distance, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_table_cell = z\n .object({\n type: z.literal(\"schematic_table_cell\"),\n schematic_table_cell_id: getZodPrefixedIdWithDefault(\n \"schematic_table_cell\",\n ),\n schematic_table_id: z.string(),\n start_row_index: z.number(),\n end_row_index: z.number(),\n start_column_index: z.number(),\n end_column_index: z.number(),\n text: z.string().optional(),\n center: point,\n width: distance,\n height: distance,\n horizontal_align: z.enum([\"left\", \"center\", \"right\"]).optional(),\n vertical_align: z.enum([\"top\", \"middle\", \"bottom\"]).optional(),\n font_size: distance.optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a cell within a schematic_table\")\n\nexport type SchematicTableCellInput = z.input<typeof schematic_table_cell>\ntype InferredSchematicTableCell = z.infer<typeof schematic_table_cell>\n\n/**\n * Defines a cell within a schematic_table\n */\nexport interface SchematicTableCell {\n type: \"schematic_table_cell\"\n schematic_table_cell_id: string\n schematic_table_id: string\n start_row_index: number\n end_row_index: number\n start_column_index: number\n end_column_index: number\n text?: string\n center: Point\n width: Length\n height: Length\n horizontal_align?: \"left\" | \"center\" | \"right\"\n vertical_align?: \"top\" | \"middle\" | \"bottom\"\n font_size?: Length\n subcircuit_id?: string\n}\n\nexpectTypesMatch<SchematicTableCell, InferredSchematicTableCell>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const schematic_sheet = z\n .object({\n type: z.literal(\"schematic_sheet\"),\n schematic_sheet_id: getZodPrefixedIdWithDefault(\"schematic_sheet\"),\n name: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Defines a schematic sheet or page that components can be placed on\",\n )\n\nexport type SchematicSheetInput = z.input<typeof schematic_sheet>\ntype InferredSchematicSheet = z.infer<typeof schematic_sheet>\n\n/**\n * Defines a schematic sheet or page that components can be placed on.\n */\nexport interface SchematicSheet {\n type: \"schematic_sheet\"\n schematic_sheet_id: string\n name?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<SchematicSheet, InferredSchematicSheet>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const point_with_bulge = z.object({\n x: distance,\n y: distance,\n bulge: z.number().optional(),\n})\n\nexport interface PointWithBulge {\n x: Distance\n y: Distance\n bulge?: number\n}\ntype InferredPointWithBulge = z.infer<typeof point_with_bulge>\nexpectTypesMatch<PointWithBulge, InferredPointWithBulge>(true)\n\nexport const ring = z.object({\n vertices: z.array(point_with_bulge),\n})\n\nexport interface Ring {\n vertices: PointWithBulge[]\n}\ntype InferredRing = z.infer<typeof ring>\nexpectTypesMatch<Ring, InferredRing>(true)\n\nexport const brep_shape = z.object({\n outer_ring: ring,\n inner_rings: z.array(ring).default([]),\n})\n\n/**\n * B-rep shape defined by an outer ring and inner rings (holes).\n */\nexport interface BRepShape {\n /**\n * The outer boundary of the shape. Vertices must be in clockwise order.\n */\n outer_ring: Ring\n /**\n * Inner boundaries (holes). Vertices must be in counter-clockwise order.\n */\n inner_rings: Ring[]\n}\ntype InferredBRepShape = z.infer<typeof brep_shape>\nexpectTypesMatch<BRepShape, InferredBRepShape>(true)\n","import { z } from \"zod\"\nimport { distance } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"./layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n// x: string | number\n// y: string | number\n// via?: boolean\n// via_to_layer?: string\nexport const pcb_route_hint = z.object({\n x: distance,\n y: distance,\n via: z.boolean().optional(),\n via_to_layer: layer_ref.optional(),\n})\nexport const pcb_route_hints = z.array(pcb_route_hint)\n\nexport type PcbRouteHintInput = z.input<typeof pcb_route_hint>\nexport type PcbRouteHintsInput = z.input<typeof pcb_route_hints>\ntype InferredPcbRouteHint = z.output<typeof pcb_route_hint>\ntype InferredPcbRouteHints = z.output<typeof pcb_route_hints>\n\nexport interface PcbRouteHint {\n x: number\n y: number\n via?: boolean\n via_to_layer?: LayerRef\n}\n\nexport type PcbRouteHints = PcbRouteHint[]\n\nexpectTypesMatch<PcbRouteHint, InferredPcbRouteHint>(true)\nexpectTypesMatch<PcbRouteHints, InferredPcbRouteHints>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../../units\"\nimport { layer_ref, type LayerRef } from \"./layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const route_hint_point = z.object({\n x: distance,\n y: distance,\n via: z.boolean().optional(),\n to_layer: layer_ref.optional(),\n trace_width: distance.optional(),\n})\n\nexport type RouteHintPointInput = z.input<typeof route_hint_point>\ntype InferredRouteHintPoint = z.infer<typeof route_hint_point>\n\nexport interface RouteHintPoint {\n x: number\n y: number\n via?: boolean\n to_layer?: LayerRef\n trace_width?: number\n}\n\nexpectTypesMatch<RouteHintPoint, InferredRouteHintPoint>(true)\n","import { type Point, getZodPrefixedIdWithDefault, point } from \"src/common\"\nimport {\n type KicadFootprintMetadata,\n kicadFootprintMetadata,\n} from \"src/common/kicadFootprintMetadata\"\nimport {\n type NinePointAnchor,\n ninePointAnchor,\n} from \"src/common/NinePointAnchor\"\nimport { type LayerRef, layer_ref } from \"src/pcb/properties/layer_ref\"\nimport { type Length, type Rotation, length, rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { z } from \"zod\"\n\nexport interface PcbComponentMetadata {\n kicad_footprint?: KicadFootprintMetadata\n}\n\nexport const pcb_component = z\n .object({\n type: z.literal(\"pcb_component\"),\n pcb_component_id: getZodPrefixedIdWithDefault(\"pcb_component\"),\n source_component_id: z.string(),\n center: point,\n layer: layer_ref,\n rotation: rotation,\n display_offset_x: z\n .string()\n .optional()\n .describe(\n \"How to display the x offset for this part, usually corresponding with how the user specified it\",\n ),\n display_offset_y: z\n .string()\n .optional()\n .describe(\n \"How to display the y offset for this part, usually corresponding with how the user specified it\",\n ),\n width: length,\n height: length,\n do_not_place: z.boolean().optional(),\n is_allowed_to_be_off_board: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n position_mode: z\n .enum([\n \"packed\",\n \"relative_to_group_anchor\",\n \"relative_to_another_component\",\n \"none\",\n ])\n .optional(),\n anchor_position: point.optional(),\n anchor_alignment: ninePointAnchor.optional(),\n positioned_relative_to_pcb_group_id: z.string().optional(),\n positioned_relative_to_pcb_board_id: z.string().optional(),\n cable_insertion_center: point.optional(),\n metadata: z\n .object({\n kicad_footprint: kicadFootprintMetadata.optional(),\n })\n .optional(),\n obstructs_within_bounds: z\n .boolean()\n .default(true)\n .describe(\n \"Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath\",\n ),\n })\n .describe(\"Defines a component on the PCB\")\n\nexport type PcbComponentInput = z.input<typeof pcb_component>\ntype InferredPcbComponent = z.infer<typeof pcb_component>\n\n/**\n * Defines a component on the PCB\n */\nexport interface PcbComponent {\n type: \"pcb_component\"\n pcb_component_id: string\n source_component_id: string\n subcircuit_id?: string\n center: Point\n layer: LayerRef\n rotation: Rotation\n display_offset_x?: string\n display_offset_y?: string\n width: Length\n height: Length\n do_not_place?: boolean\n is_allowed_to_be_off_board?: boolean\n pcb_group_id?: string\n position_mode?:\n | \"packed\"\n | \"relative_to_group_anchor\"\n | \"relative_to_another_component\"\n | \"none\"\n anchor_position?: Point\n anchor_alignment?: NinePointAnchor\n positioned_relative_to_pcb_group_id?: string\n positioned_relative_to_pcb_board_id?: string\n cable_insertion_center?: Point\n metadata?: PcbComponentMetadata\n obstructs_within_bounds: boolean\n}\n\n/**\n * @deprecated use PcbComponent\n */\nexport type PCBComponent = PcbComponent\n\nexpectTypesMatch<PcbComponent, InferredPcbComponent>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance, rotation, type Rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nconst pcb_hole_circle = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.literal(\"circle\"),\n hole_diameter: z.number(),\n x: distance,\n y: distance,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_circle_shape = pcb_hole_circle.describe(\n \"Defines a circular hole on the PCB\",\n)\n\nexport type PcbHoleCircleInput = z.input<typeof pcb_hole_circle>\ntype InferredPcbHoleCircle = z.infer<typeof pcb_hole_circle>\n\n/**\n * Defines a circular hole on the PCB\n */\nexport interface PcbHoleCircle {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"circle\"\n hole_diameter: number\n x: Distance\n y: Distance\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexpectTypesMatch<PcbHoleCircle, InferredPcbHoleCircle>(true)\n\nconst pcb_hole_rect = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.literal(\"rect\"),\n hole_width: z.number(),\n hole_height: z.number(),\n x: distance,\n y: distance,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_rect_shape = pcb_hole_rect.describe(\n \"Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.\",\n)\n\nexport type PcbHoleRectInput = z.input<typeof pcb_hole_rect>\ntype InferredPcbHoleRect = z.infer<typeof pcb_hole_rect>\n\n/**\n * Defines a rectangular (or square) hole on the PCB\n */\nexport interface PcbHoleRect {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"rect\"\n hole_width: number\n hole_height: number\n x: Distance\n y: Distance\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\nexpectTypesMatch<PcbHoleRect, InferredPcbHoleRect>(true)\n\nconst pcb_hole_circle_or_square = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.enum([\"circle\", \"square\"]),\n hole_diameter: z.number(),\n x: distance,\n y: distance,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_circle_or_square_shape =\n pcb_hole_circle_or_square.describe(\n \"Defines a circular or square hole on the PCB\",\n )\n\nexport type PcbHoleCircleOrSquareInput = z.input<\n typeof pcb_hole_circle_or_square\n>\ntype InferredPcbHoleCircleOrSquare = z.infer<typeof pcb_hole_circle_or_square>\n\n/**\n * Defines a circular or square hole on the PCB\n */\n\n/**\n * @deprecated Use `PcbHoleCircle` for circular holes or `PcbHoleRect` for square holes.\n */\nexport interface PcbHoleCircleOrSquare {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"circle\" | \"square\"\n hole_diameter: number\n x: Distance\n y: Distance\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexpectTypesMatch<PcbHoleCircleOrSquare, InferredPcbHoleCircleOrSquare>(true)\n\nconst pcb_hole_oval = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.literal(\"oval\"),\n hole_width: z.number(),\n hole_height: z.number(),\n x: distance,\n y: distance,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_oval_shape = pcb_hole_oval.describe(\n \"Defines an oval hole on the PCB\",\n)\n\nexport type PcbHoleOvalInput = z.input<typeof pcb_hole_oval>\ntype InferredPcbHoleOval = z.infer<typeof pcb_hole_oval>\n\n/**\n * Defines an oval hole on the PCB\n */\nexport interface PcbHoleOval {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"oval\"\n hole_width: number\n hole_height: number\n x: Distance\n y: Distance\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexpectTypesMatch<PcbHoleOval, InferredPcbHoleOval>(true)\n\nconst pcb_hole_pill = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.literal(\"pill\"),\n hole_width: z.number(),\n hole_height: z.number(),\n x: distance,\n y: distance,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_pill_shape = pcb_hole_pill.describe(\n \"Defines a pill-shaped hole on the PCB\",\n)\n\nexport type PcbHolePillInput = z.input<typeof pcb_hole_pill>\ntype InferredPcbHolePill = z.infer<typeof pcb_hole_pill>\n\n/**\n * Defines a pill-shaped hole on the PCB\n */\nexport interface PcbHolePill {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"pill\"\n hole_width: number\n hole_height: number\n x: Distance\n y: Distance\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexpectTypesMatch<PcbHolePill, InferredPcbHolePill>(true)\n\nconst pcb_hole_rotated_pill = z.object({\n type: z.literal(\"pcb_hole\"),\n pcb_hole_id: getZodPrefixedIdWithDefault(\"pcb_hole\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n hole_shape: z.literal(\"rotated_pill\"),\n hole_width: z.number(),\n hole_height: z.number(),\n x: distance,\n y: distance,\n ccw_rotation: rotation,\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_hole_rotated_pill_shape = pcb_hole_rotated_pill.describe(\n \"Defines a rotated pill-shaped hole on the PCB\",\n)\n\nexport type PcbHoleRotatedPillInput = z.input<typeof pcb_hole_rotated_pill>\ntype InferredPcbHoleRotatedPill = z.infer<typeof pcb_hole_rotated_pill>\n\n/**\n * Defines a rotated pill-shaped hole on the PCB\n */\nexport interface PcbHoleRotatedPill {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_component_id?: string\n hole_shape: \"rotated_pill\"\n hole_width: number\n hole_height: number\n x: Distance\n y: Distance\n ccw_rotation: Rotation\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexpectTypesMatch<PcbHoleRotatedPill, InferredPcbHoleRotatedPill>(true)\n\nexport const pcb_hole = pcb_hole_circle_or_square\n .or(pcb_hole_oval)\n .or(pcb_hole_pill)\n .or(pcb_hole_rotated_pill)\n .or(pcb_hole_circle)\n .or(pcb_hole_rect)\n\n/**\n * @deprecated Use PcbHoleCircleOrSquare, PcbHoleCircle, PcbHoleRect, PcbHoleOval, PcbHolePill, or PcbHoleRotatedPill\n */\nexport type PCBHoleInput = z.input<typeof pcb_hole>\n/**\n * @deprecated Use PcbHoleCircleOrSquare, PcbHoleCircle, PcbHoleRect, PcbHoleOval, PcbHolePill, or PcbHoleRotatedPill\n */\nexport type PCBHole = z.infer<typeof pcb_hole>\n\nexport type PcbHole =\n | PcbHoleCircleOrSquare\n | PcbHoleOval\n | PcbHolePill\n | PcbHoleRotatedPill\n | PcbHoleCircle\n | PcbHoleRect\n","import { z } from \"zod\"\nimport { distance, type Distance, rotation, type Rotation } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nconst pcb_plated_hole_circle = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.literal(\"circle\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n outer_diameter: z.number(),\n hole_diameter: z.number(),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n})\n\n/**\n * Defines a circular plated hole on the PCB\n */\nexport interface PcbPlatedHoleCircle {\n type: \"pcb_plated_hole\"\n shape: \"circle\"\n pcb_group_id?: string\n subcircuit_id?: string\n outer_diameter: number\n hole_diameter: number\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n}\n\nconst pcb_plated_hole_oval = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.enum([\"oval\", \"pill\"]),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n outer_width: z.number(),\n outer_height: z.number(),\n hole_width: z.number(),\n hole_height: z.number(),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n ccw_rotation: rotation,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n})\n\n/**\n * Defines an oval or pill-shaped plated hole on the PCB\n */\nexport interface PcbPlatedHoleOval {\n type: \"pcb_plated_hole\"\n shape: \"oval\" | \"pill\"\n pcb_group_id?: string\n subcircuit_id?: string\n outer_width: number\n outer_height: number\n hole_width: number\n hole_height: number\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n ccw_rotation: Rotation\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n}\n\nconst pcb_circular_hole_with_rect_pad = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.literal(\"circular_hole_with_rect_pad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n hole_shape: z.literal(\"circle\"),\n pad_shape: z.literal(\"rect\"),\n hole_diameter: z.number(),\n rect_pad_width: z.number(),\n rect_pad_height: z.number(),\n rect_border_radius: z.number().optional(),\n hole_offset_x: distance.default(0),\n hole_offset_y: distance.default(0),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n rect_ccw_rotation: rotation.optional(),\n})\nconst pcb_pill_hole_with_rect_pad = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.literal(\"pill_hole_with_rect_pad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n hole_shape: z.literal(\"pill\"),\n pad_shape: z.literal(\"rect\"),\n hole_width: z.number(),\n hole_height: z.number(),\n rect_pad_width: z.number(),\n rect_pad_height: z.number(),\n rect_border_radius: z.number().optional(),\n hole_offset_x: distance.default(0),\n hole_offset_y: distance.default(0),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n})\nconst pcb_rotated_pill_hole_with_rect_pad = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.literal(\"rotated_pill_hole_with_rect_pad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n hole_shape: z.literal(\"rotated_pill\"),\n pad_shape: z.literal(\"rect\"),\n hole_width: z.number(),\n hole_height: z.number(),\n hole_ccw_rotation: rotation,\n rect_pad_width: z.number(),\n rect_pad_height: z.number(),\n rect_border_radius: z.number().optional(),\n rect_ccw_rotation: rotation,\n hole_offset_x: distance.default(0),\n hole_offset_y: distance.default(0),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n})\nexport interface PcbHolePillWithRectPad {\n type: \"pcb_plated_hole\"\n shape: \"pill_hole_with_rect_pad\"\n pcb_group_id?: string\n subcircuit_id?: string\n hole_shape: \"pill\"\n pad_shape: \"rect\"\n hole_width: number\n hole_height: number\n rect_pad_width: number\n rect_pad_height: number\n rect_border_radius?: number\n hole_offset_x: Distance\n hole_offset_y: Distance\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n}\n\nexport interface PcbHoleRotatedPillWithRectPad {\n type: \"pcb_plated_hole\"\n shape: \"rotated_pill_hole_with_rect_pad\"\n pcb_group_id?: string\n subcircuit_id?: string\n hole_shape: \"rotated_pill\"\n pad_shape: \"rect\"\n hole_width: number\n hole_height: number\n hole_ccw_rotation: Rotation\n rect_pad_width: number\n rect_pad_height: number\n rect_border_radius?: number\n rect_ccw_rotation: Rotation\n hole_offset_x: Distance\n hole_offset_y: Distance\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n}\n\nexport interface PcbHoleCircularWithRectPad {\n type: \"pcb_plated_hole\"\n shape: \"circular_hole_with_rect_pad\"\n pcb_group_id?: string\n subcircuit_id?: string\n hole_shape: \"circle\"\n pad_shape: \"rect\"\n hole_diameter: number\n rect_pad_width: number\n rect_pad_height: number\n rect_border_radius?: number\n hole_offset_x: Distance\n hole_offset_y: Distance\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n rect_ccw_rotation?: Rotation\n}\nconst pcb_hole_with_polygon_pad = z.object({\n type: z.literal(\"pcb_plated_hole\"),\n shape: z.literal(\"hole_with_polygon_pad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n hole_shape: z.enum([\"circle\", \"oval\", \"pill\", \"rotated_pill\"]),\n hole_diameter: z.number().optional(),\n hole_width: z.number().optional(),\n hole_height: z.number().optional(),\n\n pad_outline: z\n .array(\n z.object({\n x: distance,\n y: distance,\n }),\n )\n .min(3),\n\n hole_offset_x: distance.default(0),\n hole_offset_y: distance.default(0),\n is_covered_with_solder_mask: z.boolean().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n pcb_plated_hole_id: getZodPrefixedIdWithDefault(\"pcb_plated_hole\"),\n soldermask_margin: z.number().optional(),\n ccw_rotation: rotation.optional(),\n})\n\n/**\n * Defines a plated hole with a polygonal pad on the PCB\n */\n\nexport interface PcbHoleWithPolygonPad {\n type: \"pcb_plated_hole\"\n shape: \"hole_with_polygon_pad\"\n pcb_group_id?: string\n subcircuit_id?: string\n hole_shape: \"circle\" | \"oval\" | \"pill\" | \"rotated_pill\"\n hole_diameter?: number\n hole_width?: number\n hole_height?: number\n pad_outline: { x: Distance; y: Distance }[]\n hole_offset_x: Distance\n hole_offset_y: Distance\n is_covered_with_solder_mask?: boolean\n x: Distance\n y: Distance\n layers: LayerRef[]\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n pcb_plated_hole_id: string\n soldermask_margin?: number\n ccw_rotation?: Rotation\n}\n\nexport const pcb_plated_hole = z.union([\n pcb_plated_hole_circle,\n pcb_plated_hole_oval,\n pcb_circular_hole_with_rect_pad,\n pcb_pill_hole_with_rect_pad,\n pcb_rotated_pill_hole_with_rect_pad,\n pcb_hole_with_polygon_pad,\n])\nexport type PcbPlatedHole =\n | PcbPlatedHoleCircle\n | PcbPlatedHoleOval\n | PcbHoleCircularWithRectPad\n | PcbHolePillWithRectPad\n | PcbHoleRotatedPillWithRectPad\n | PcbHoleWithPolygonPad\n\nexpectTypesMatch<PcbPlatedHoleCircle, z.infer<typeof pcb_plated_hole_circle>>(\n true,\n)\nexpectTypesMatch<PcbPlatedHoleOval, z.infer<typeof pcb_plated_hole_oval>>(true)\nexpectTypesMatch<\n PcbHoleCircularWithRectPad,\n z.infer<typeof pcb_circular_hole_with_rect_pad>\n>(true)\nexpectTypesMatch<\n PcbHolePillWithRectPad,\n z.infer<typeof pcb_pill_hole_with_rect_pad>\n>(true)\nexpectTypesMatch<\n PcbHoleRotatedPillWithRectPad,\n z.infer<typeof pcb_rotated_pill_hole_with_rect_pad>\n>(true)\nexpectTypesMatch<\n PcbHoleWithPolygonPad,\n z.infer<typeof pcb_hole_with_polygon_pad>\n>(true)\n/**\n * @deprecated use PcbPlatedHole\n */\nexport type PCBPlatedHole = PcbPlatedHole\n\n/**\n * @deprecated use PcbPlatedHoleInput\n */\nexport type PCBPlatedHoleInput = z.input<typeof pcb_plated_hole>\nexport type PcbPlatedHoleInput = z.input<typeof pcb_plated_hole>\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_port = z\n .object({\n type: z.literal(\"pcb_port\"),\n pcb_port_id: getZodPrefixedIdWithDefault(\"pcb_port\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n source_port_id: z.string(),\n pcb_component_id: z.string().optional(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\n is_board_pinout: z.boolean().optional(),\n })\n .describe(\"Defines a port on the PCB\")\n\nexport type PcbPortInput = z.input<typeof pcb_port>\ntype InferredPcbPort = z.infer<typeof pcb_port>\n\n/**\n * Defines a port on the PCB\n */\nexport interface PcbPort {\n type: \"pcb_port\"\n pcb_port_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n source_port_id: string\n pcb_component_id?: string\n x: Distance\n y: Distance\n layers: LayerRef[]\n is_board_pinout?: boolean\n}\n\n/**\n * @deprecated use PcbPort\n */\nexport type PCBPort = PcbPort\n\n/**\n * @deprecated use PcbPortInput\n */\nexport type PCBPortInput = PcbPortInput\n\nexpectTypesMatch<PcbPort, InferredPcbPort>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance, rotation, type Rotation } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { getZodPrefixedIdWithDefault, point, type Point } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nconst pcb_smtpad_circle = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"circle\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n radius: z.number(),\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nconst pcb_smtpad_rect = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"rect\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n rect_border_radius: z.number().optional(),\n corner_radius: z.number().optional(),\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n soldermask_margin_left: z.number().optional(),\n soldermask_margin_top: z.number().optional(),\n soldermask_margin_right: z.number().optional(),\n soldermask_margin_bottom: z.number().optional(),\n})\n\nconst pcb_smtpad_rotated_rect = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"rotated_rect\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n rect_border_radius: z.number().optional(),\n corner_radius: z.number().optional(),\n ccw_rotation: rotation,\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n soldermask_margin_left: z.number().optional(),\n soldermask_margin_top: z.number().optional(),\n soldermask_margin_right: z.number().optional(),\n soldermask_margin_bottom: z.number().optional(),\n})\n\nexport const pcb_smtpad_pill = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"pill\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n radius: z.number(),\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\nconst pcb_smtpad_rotated_pill = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"rotated_pill\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n radius: z.number(),\n ccw_rotation: rotation,\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nconst pcb_smtpad_polygon = z.object({\n type: z.literal(\"pcb_smtpad\"),\n shape: z.literal(\"polygon\"),\n pcb_smtpad_id: getZodPrefixedIdWithDefault(\"pcb_smtpad\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n points: z.array(point),\n layer: layer_ref,\n port_hints: z.array(z.string()).optional(),\n pcb_component_id: z.string().optional(),\n pcb_port_id: z.string().optional(),\n is_covered_with_solder_mask: z.boolean().optional(),\n soldermask_margin: z.number().optional(),\n})\n\nexport const pcb_smtpad = z\n .discriminatedUnion(\"shape\", [\n pcb_smtpad_circle,\n pcb_smtpad_rect,\n pcb_smtpad_rotated_rect,\n pcb_smtpad_rotated_pill,\n pcb_smtpad_pill,\n pcb_smtpad_polygon,\n ])\n .describe(\"Defines an SMT pad on the PCB\")\n\nexport type PCBSMTPadInput = z.input<typeof pcb_smtpad>\ntype PCBSMTPadCircle = z.infer<typeof pcb_smtpad_circle>\ntype PCBSMTPadRect = z.infer<typeof pcb_smtpad_rect>\ntype PCBSMTPadRotatedRect = z.infer<typeof pcb_smtpad_rotated_rect>\ntype PCBSMTPadRotatedPill = z.infer<typeof pcb_smtpad_rotated_pill>\ntype PCBSMTPadPill = z.infer<typeof pcb_smtpad_pill>\ntype PCBSMTPadPolygon = z.infer<typeof pcb_smtpad_polygon>\n\n/**\n * Defines a circular SMT pad on the PCB\n */\nexport interface PcbSmtPadCircle {\n type: \"pcb_smtpad\"\n shape: \"circle\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n radius: number\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\n/**\n * Defines a rectangular SMT pad on the PCB\n */\nexport interface PcbSmtPadRect {\n type: \"pcb_smtpad\"\n shape: \"rect\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n rect_border_radius?: number\n corner_radius?: number\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n soldermask_margin_left?: number\n soldermask_margin_top?: number\n soldermask_margin_right?: number\n soldermask_margin_bottom?: number\n}\n\n/**\n * Defines a rotated rectangular SMT pad on the PCB\n */\nexport interface PcbSmtPadRotatedRect {\n type: \"pcb_smtpad\"\n shape: \"rotated_rect\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n rect_border_radius?: number\n corner_radius?: number\n ccw_rotation: Rotation\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n soldermask_margin_left?: number\n soldermask_margin_top?: number\n soldermask_margin_right?: number\n soldermask_margin_bottom?: number\n}\n/**\n * Defines a pill-shaped SMT pad on the PCB (rounded rectangle).\n */\nexport interface PcbSmtPadPill {\n type: \"pcb_smtpad\"\n shape: \"pill\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n radius: number\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\n/**\n * Defines a rotated pill-shaped SMT pad on the PCB\n */\nexport interface PcbSmtPadRotatedPill {\n type: \"pcb_smtpad\"\n shape: \"rotated_pill\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n radius: number\n ccw_rotation: Rotation\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\n/**\n * Defines a polygonal SMT pad on the PCB\n */\nexport interface PcbSmtPadPolygon {\n type: \"pcb_smtpad\"\n shape: \"polygon\"\n pcb_smtpad_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n points: Point[]\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\n is_covered_with_solder_mask?: boolean\n soldermask_margin?: number\n}\n\nexport type PcbSmtPad =\n | PcbSmtPadCircle\n | PcbSmtPadRect\n | PcbSmtPadRotatedRect\n | PcbSmtPadRotatedPill\n | PcbSmtPadPill\n | PcbSmtPadPolygon\n\n/**\n * @deprecated use PcbSmtPad\n */\nexport type PCBSMTPad = PcbSmtPad\n\nexpectTypesMatch<PcbSmtPadCircle, PCBSMTPadCircle>(true)\nexpectTypesMatch<PcbSmtPadRect, PCBSMTPadRect>(true)\nexpectTypesMatch<PcbSmtPadRotatedRect, PCBSMTPadRotatedRect>(true)\nexpectTypesMatch<PcbSmtPadRotatedPill, PCBSMTPadRotatedPill>(true)\nexpectTypesMatch<PcbSmtPadPill, PCBSMTPadPill>(true)\nexpectTypesMatch<PcbSmtPadPolygon, PCBSMTPadPolygon>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nconst pcb_solder_paste_circle = z.object({\n type: z.literal(\"pcb_solder_paste\"),\n shape: z.literal(\"circle\"),\n pcb_solder_paste_id: getZodPrefixedIdWithDefault(\"pcb_solder_paste\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n radius: z.number(),\n layer: layer_ref,\n pcb_component_id: z.string().optional(),\n pcb_smtpad_id: z.string().optional(),\n})\n\nconst pcb_solder_paste_rect = z.object({\n type: z.literal(\"pcb_solder_paste\"),\n shape: z.literal(\"rect\"),\n pcb_solder_paste_id: getZodPrefixedIdWithDefault(\"pcb_solder_paste\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n layer: layer_ref,\n pcb_component_id: z.string().optional(),\n pcb_smtpad_id: z.string().optional(),\n})\nconst pcb_solder_paste_pill = z.object({\n type: z.literal(\"pcb_solder_paste\"),\n shape: z.literal(\"pill\"),\n pcb_solder_paste_id: getZodPrefixedIdWithDefault(\"pcb_solder_paste\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n radius: z.number(),\n layer: layer_ref,\n pcb_component_id: z.string().optional(),\n pcb_smtpad_id: z.string().optional(),\n})\nconst pcb_solder_paste_rotated_rect = z.object({\n type: z.literal(\"pcb_solder_paste\"),\n shape: z.literal(\"rotated_rect\"),\n pcb_solder_paste_id: getZodPrefixedIdWithDefault(\"pcb_solder_paste\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n ccw_rotation: distance,\n layer: layer_ref,\n pcb_component_id: z.string().optional(),\n pcb_smtpad_id: z.string().optional(),\n})\n\nconst pcb_solder_paste_oval = z.object({\n type: z.literal(\"pcb_solder_paste\"),\n shape: z.literal(\"oval\"),\n pcb_solder_paste_id: getZodPrefixedIdWithDefault(\"pcb_solder_paste\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n x: distance,\n y: distance,\n width: z.number(),\n height: z.number(),\n layer: layer_ref,\n pcb_component_id: z.string().optional(),\n pcb_smtpad_id: z.string().optional(),\n})\n\nexport const pcb_solder_paste = z\n .union([\n pcb_solder_paste_circle,\n pcb_solder_paste_rect,\n pcb_solder_paste_pill,\n pcb_solder_paste_rotated_rect,\n pcb_solder_paste_oval,\n ])\n .describe(\"Defines solderpaste on the PCB\")\n\nexport type PCBSolderPasteInput = z.input<typeof pcb_solder_paste>\ntype InferredPcbSolderPasteCircle = z.infer<typeof pcb_solder_paste_circle>\ntype InferredPcbSolderPasteRect = z.infer<typeof pcb_solder_paste_rect>\ntype InferredPcbSolderPastePill = z.infer<typeof pcb_solder_paste_pill>\ntype InferredPcbSolderPasteRotatedRect = z.infer<\n typeof pcb_solder_paste_rotated_rect\n>\ntype InferredPcbSolderPasteOval = z.infer<typeof pcb_solder_paste_oval>\n\n/**\n * Defines solderpaste on the PCB\n */\nexport interface PcbSolderPasteCircle {\n type: \"pcb_solder_paste\"\n shape: \"circle\"\n pcb_solder_paste_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n radius: number\n layer: LayerRef\n pcb_component_id?: string\n pcb_smtpad_id?: string\n}\n\n/**\n * Defines solderpaste on the PCB\n */\nexport interface PcbSolderPasteRect {\n type: \"pcb_solder_paste\"\n shape: \"rect\"\n pcb_solder_paste_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n layer: LayerRef\n pcb_component_id?: string\n pcb_smtpad_id?: string\n}\n/**\n * Defines solderpaste on the PCB\n */\nexport interface PcbSolderPastePill {\n type: \"pcb_solder_paste\"\n shape: \"pill\"\n pcb_solder_paste_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n radius: number\n layer: LayerRef\n pcb_component_id?: string\n pcb_smtpad_id?: string\n}\n/**\n * Defines solderpaste on the PCB\n */\nexport interface PcbSolderPasteRotatedRect {\n type: \"pcb_solder_paste\"\n shape: \"rotated_rect\"\n pcb_solder_paste_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n ccw_rotation: Distance\n layer: LayerRef\n pcb_component_id?: string\n pcb_smtpad_id?: string\n}\n/**\n * Defines solderpaste on the PCB\n */\nexport interface PcbSolderPasteOval {\n type: \"pcb_solder_paste\"\n shape: \"oval\"\n pcb_solder_paste_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n x: Distance\n y: Distance\n width: number\n height: number\n layer: LayerRef\n pcb_component_id?: string\n pcb_smtpad_id?: string\n}\n\nexport type PcbSolderPaste =\n | PcbSolderPasteCircle\n | PcbSolderPasteRect\n | PcbSolderPastePill\n | PcbSolderPasteRotatedRect\n | PcbSolderPasteOval\n\nexpectTypesMatch<PcbSolderPasteCircle, InferredPcbSolderPasteCircle>(true)\nexpectTypesMatch<PcbSolderPasteRect, InferredPcbSolderPasteRect>(true)\nexpectTypesMatch<PcbSolderPastePill, InferredPcbSolderPastePill>(true)\nexpectTypesMatch<PcbSolderPasteRotatedRect, InferredPcbSolderPasteRotatedRect>(\n true,\n)\nexpectTypesMatch<PcbSolderPasteOval, InferredPcbSolderPasteOval>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_text = z\n .object({\n type: z.literal(\"pcb_text\"),\n pcb_text_id: getZodPrefixedIdWithDefault(\"pcb_text\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n text: z.string(),\n center: point,\n layer: layer_ref,\n width: length,\n height: length,\n lines: z.number(),\n // @ts-ignore\n align: z.enum([\"bottom-left\"]),\n })\n .describe(\"Defines text on the PCB\")\n\nexport type PcbTextInput = z.input<typeof pcb_text>\ntype InferredPcbText = z.infer<typeof pcb_text>\n\n/**\n * Defines text on the PCB\n */\nexport interface PcbText {\n type: \"pcb_text\"\n pcb_text_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n text: string\n center: Point\n layer: LayerRef\n width: Length\n height: Length\n lines: number\n // @ts-ignore\n align: \"bottom-left\"\n}\n\n/**\n * @deprecated use PcbText\n */\nexport type PCBText = PcbText\n\nexpectTypesMatch<PcbText, InferredPcbText>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_trace_route_point_wire = z.object({\n route_type: z.literal(\"wire\"),\n x: distance,\n y: distance,\n width: distance,\n copper_pour_id: z.string().optional(),\n is_inside_copper_pour: z.boolean().optional(),\n start_pcb_port_id: z.string().optional(),\n end_pcb_port_id: z.string().optional(),\n layer: layer_ref,\n})\n\nexport const pcb_trace_route_point_via = z.object({\n route_type: z.literal(\"via\"),\n x: distance,\n y: distance,\n copper_pour_id: z.string().optional(),\n is_inside_copper_pour: z.boolean().optional(),\n hole_diameter: distance.optional(),\n outer_diameter: distance.optional(),\n from_layer: z.string(),\n to_layer: z.string(),\n})\n\nexport const pcb_trace_route_point = z.union([\n pcb_trace_route_point_wire,\n pcb_trace_route_point_via,\n])\ntype InferredPcbTraceRoutePoint = z.infer<typeof pcb_trace_route_point>\n\nexport const pcb_trace = z\n .object({\n type: z.literal(\"pcb_trace\"),\n source_trace_id: z.string().optional(),\n pcb_component_id: z.string().optional(),\n pcb_trace_id: getZodPrefixedIdWithDefault(\"pcb_trace\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n route_thickness_mode: z\n .enum([\"constant\", \"interpolated\"])\n .default(\"constant\")\n .optional(),\n route_order_index: z.number().optional(),\n should_round_corners: z.boolean().optional(),\n trace_length: z.number().optional(),\n highlight_color: z.string().optional(),\n route: z.array(pcb_trace_route_point),\n })\n .describe(\"Defines a trace on the PCB\")\n\nexport type PcbTraceInput = z.input<typeof pcb_trace>\ntype InferredPcbTrace = z.infer<typeof pcb_trace>\n\nexport interface PcbTraceRoutePointWire {\n route_type: \"wire\"\n x: Distance\n y: Distance\n width: Distance\n copper_pour_id?: string\n is_inside_copper_pour?: boolean\n start_pcb_port_id?: string\n end_pcb_port_id?: string\n layer: LayerRef\n}\n\nexport interface PcbTraceRoutePointVia {\n route_type: \"via\"\n x: Distance\n y: Distance\n copper_pour_id?: string\n is_inside_copper_pour?: boolean\n hole_diameter?: Distance\n outer_diameter?: Distance\n from_layer: string\n to_layer: string\n}\n\nexport type PcbTraceRoutePoint = PcbTraceRoutePointWire | PcbTraceRoutePointVia\n\n/**\n * Defines a trace on the PCB\n */\nexport interface PcbTrace {\n type: \"pcb_trace\"\n source_trace_id?: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_trace_id: string\n /**\n * The order that this trace was routed in. This can be used to debug the\n * autorouter and to understand the trace path better\n *\n * The route_order_index should be relative to a subcircuit\n */\n route_order_index?: number\n route_thickness_mode?: \"constant\" | \"interpolated\"\n should_round_corners?: boolean\n trace_length?: number\n highlight_color?: string\n route: Array<PcbTraceRoutePoint>\n}\n\n/**\n * @deprecated use PcbTrace\n */\nexport type PCBTrace = PcbTrace\n\n/**\n * @deprecated use PcbTraceInput\n */\nexport type PCBTraceInput = PcbTraceInput\n\nexpectTypesMatch<PcbTraceRoutePoint, InferredPcbTraceRoutePoint>(true)\nexpectTypesMatch<PcbTrace, InferredPcbTrace>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_trace_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_trace_error\"),\n pcb_trace_error_id: getZodPrefixedIdWithDefault(\"pcb_trace_error\"),\n error_type: z.literal(\"pcb_trace_error\").default(\"pcb_trace_error\"),\n center: point.optional(),\n pcb_trace_id: z.string(),\n source_trace_id: z.string(),\n pcb_component_ids: z.array(z.string()),\n pcb_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a trace error on the PCB\")\n\nexport type PcbTraceErrorInput = z.input<typeof pcb_trace_error>\ntype InferredPcbTraceError = z.infer<typeof pcb_trace_error>\n\n/**\n * Defines a trace error on the PCB\n */\nexport interface PcbTraceError extends BaseCircuitJsonError {\n type: \"pcb_trace_error\"\n pcb_trace_error_id: string\n error_type: \"pcb_trace_error\"\n center?: Point\n pcb_trace_id: string\n source_trace_id: string\n pcb_component_ids: string[]\n pcb_port_ids: string[]\n subcircuit_id?: string\n}\n\n/**\n * @deprecated use PcbTraceError\n */\nexport type PCBTraceError = PcbTraceError\n\nexpectTypesMatch<PcbTraceError, InferredPcbTraceError>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_trace_missing_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_trace_missing_error\"),\n pcb_trace_missing_error_id: getZodPrefixedIdWithDefault(\n \"pcb_trace_missing_error\",\n ),\n error_type: z\n .literal(\"pcb_trace_missing_error\")\n .default(\"pcb_trace_missing_error\"),\n center: point.optional(),\n source_trace_id: z.string(),\n pcb_component_ids: z.array(z.string()),\n pcb_port_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Defines an error when a source trace has no corresponding PCB trace\",\n )\n\nexport type PcbTraceMissingErrorInput = z.input<typeof pcb_trace_missing_error>\ntype InferredPcbTraceMissingError = z.infer<typeof pcb_trace_missing_error>\n\n/**\n * Defines an error when a source trace has no corresponding PCB trace\n */\nexport interface PcbTraceMissingError extends BaseCircuitJsonError {\n type: \"pcb_trace_missing_error\"\n pcb_trace_missing_error_id: string\n error_type: \"pcb_trace_missing_error\"\n center?: Point\n source_trace_id: string\n pcb_component_ids: string[]\n pcb_port_ids: string[]\n subcircuit_id?: string\n}\n\n/**\n * @deprecated use PcbTraceMissingError\n */\nexport type PCBTraceMissingError = PcbTraceMissingError\n\nexpectTypesMatch<PcbTraceMissingError, InferredPcbTraceMissingError>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_port_not_matched_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_port_not_matched_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_error\"),\n error_type: z\n .literal(\"pcb_port_not_matched_error\")\n .default(\"pcb_port_not_matched_error\"),\n pcb_component_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a trace error on the PCB where a port is not matched\")\n\nexport type PcbPortNotMatchedErrorInput = z.input<\n typeof pcb_port_not_matched_error\n>\ntype InferredPcbPortNotMatchedError = z.infer<typeof pcb_port_not_matched_error>\n\n/**\n * Defines a trace error on the PCB where a port is not matched\n */\nexport interface PcbPortNotMatchedError extends BaseCircuitJsonError {\n type: \"pcb_port_not_matched_error\"\n pcb_error_id: string\n error_type: \"pcb_port_not_matched_error\"\n pcb_component_ids: string[]\n subcircuit_id?: string\n}\n\n/**\n * @deprecated use PcbPortNotMatchedError\n */\nexport type PCBPortNotMatchedError = PcbPortNotMatchedError\n\nexpectTypesMatch<PcbPortNotMatchedError, InferredPcbPortNotMatchedError>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_port_not_connected_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_port_not_connected_error\"),\n pcb_port_not_connected_error_id: getZodPrefixedIdWithDefault(\n \"pcb_port_not_connected_error\",\n ),\n error_type: z\n .literal(\"pcb_port_not_connected_error\")\n .default(\"pcb_port_not_connected_error\"),\n pcb_port_ids: z.array(z.string()),\n pcb_component_ids: z.array(z.string()),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines an error when a pcb port is not connected to any trace\")\n\nexport type PcbPortNotConnectedErrorInput = z.input<\n typeof pcb_port_not_connected_error\n>\ntype InferredPcbPortNotConnectedError = z.infer<\n typeof pcb_port_not_connected_error\n>\n\n/**\n * Defines an error when a pcb port is not connected to any trace\n */\nexport interface PcbPortNotConnectedError extends BaseCircuitJsonError {\n type: \"pcb_port_not_connected_error\"\n pcb_port_not_connected_error_id: string\n error_type: \"pcb_port_not_connected_error\"\n pcb_port_ids: string[]\n pcb_component_ids: string[]\n subcircuit_id?: string\n}\n\nexpectTypesMatch<PcbPortNotConnectedError, InferredPcbPortNotConnectedError>(\n true,\n)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_net = z\n .object({\n type: z.literal(\"pcb_net\"),\n pcb_net_id: getZodPrefixedIdWithDefault(\"pcb_net\"),\n source_net_id: z.string().optional(),\n highlight_color: z.string().optional(),\n })\n .describe(\"Defines a net on the PCB\")\n\nexport type PcbNetInput = z.input<typeof pcb_net>\ntype InferredPcbNet = z.infer<typeof pcb_net>\n\n/**\n * Defines a net on the PCB\n */\nexport interface PcbNet {\n type: \"pcb_net\"\n pcb_net_id: string\n source_net_id?: string\n highlight_color?: string\n}\n\nexpectTypesMatch<PcbNet, InferredPcbNet>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_via = z\n .object({\n type: z.literal(\"pcb_via\"),\n pcb_via_id: getZodPrefixedIdWithDefault(\"pcb_via\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n subcircuit_connectivity_map_key: z.string().optional(),\n x: distance,\n y: distance,\n outer_diameter: distance.default(\"0.6mm\"),\n hole_diameter: distance.default(\"0.25mm\"),\n /** @deprecated */\n from_layer: layer_ref.optional(),\n /** @deprecated */\n to_layer: layer_ref.optional(),\n layers: z.array(layer_ref),\n pcb_trace_id: z.string().optional(),\n net_is_assignable: z.boolean().optional(),\n net_assigned: z.boolean().optional(),\n is_tented: z.boolean().optional(),\n })\n .describe(\"Defines a via on the PCB\")\n\nexport type PcbViaInput = z.input<typeof pcb_via>\ntype InferredPcbVia = z.infer<typeof pcb_via>\n\n/**\n * Defines a via on the PCB\n */\nexport interface PcbVia {\n type: \"pcb_via\"\n pcb_via_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n subcircuit_connectivity_map_key?: string\n x: Distance\n y: Distance\n outer_diameter: Distance\n hole_diameter: Distance\n /** @deprecated */\n from_layer?: LayerRef\n /** @deprecated */\n to_layer?: LayerRef\n layers: LayerRef[]\n pcb_trace_id?: string\n net_is_assignable?: boolean\n net_assigned?: boolean\n is_tented?: boolean\n}\n\n/**\n * @deprecated use PcbVia\n */\nexport type PCBVia = PcbVia\n\nexpectTypesMatch<PcbVia, InferredPcbVia>(true)\n","import { z } from \"zod\"\nimport {\n point,\n type Point,\n getZodPrefixedIdWithDefault,\n ninePointAnchor,\n type NinePointAnchor,\n} from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_board = z\n .object({\n type: z.literal(\"pcb_board\"),\n pcb_board_id: getZodPrefixedIdWithDefault(\"pcb_board\"),\n pcb_panel_id: z.string().optional(),\n carrier_pcb_board_id: z.string().optional(),\n is_subcircuit: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n is_mounted_to_carrier_board: z.boolean().optional(),\n width: length.optional(),\n height: length.optional(),\n center: point,\n display_offset_x: z\n .string()\n .optional()\n .describe(\n \"How to display the x offset for this board, usually corresponding with how the user specified it\",\n ),\n display_offset_y: z\n .string()\n .optional()\n .describe(\n \"How to display the y offset for this board, usually corresponding with how the user specified it\",\n ),\n thickness: length.optional().default(1.4),\n num_layers: z.number().optional().default(4),\n outline: z.array(point).optional(),\n shape: z.enum([\"rect\", \"polygon\"]).optional(),\n material: z.enum([\"fr4\", \"fr1\"]).default(\"fr4\"),\n anchor_position: point.optional(),\n anchor_alignment: ninePointAnchor.optional(),\n position_mode: z.enum([\"relative_to_panel_anchor\", \"none\"]).optional(),\n })\n .describe(\"Defines the board outline of the PCB\")\n\n/**\n * Defines the board outline of the PCB\n */\nexport interface PcbBoard {\n type: \"pcb_board\"\n pcb_board_id: string\n pcb_panel_id?: string\n carrier_pcb_board_id?: string\n is_subcircuit?: boolean\n subcircuit_id?: string\n is_mounted_to_carrier_board?: boolean\n width?: Length\n height?: Length\n display_offset_x?: string\n display_offset_y?: string\n thickness: Length\n num_layers: number\n center: Point\n outline?: Point[]\n shape?: \"rect\" | \"polygon\"\n material: \"fr4\" | \"fr1\"\n anchor_position?: Point\n anchor_alignment?: NinePointAnchor\n position_mode?: \"relative_to_panel_anchor\" | \"none\"\n}\n\nexport type PcbBoardInput = z.input<typeof pcb_board>\ntype InferredPcbBoard = z.infer<typeof pcb_board>\n\n/**\n * @deprecated use PcbBoard\n */\nexport type PCBBoard = PcbBoard\n\nexpectTypesMatch<PcbBoard, InferredPcbBoard>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault, point, type Point } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_panel = z\n .object({\n type: z.literal(\"pcb_panel\"),\n pcb_panel_id: getZodPrefixedIdWithDefault(\"pcb_panel\"),\n width: length,\n height: length,\n center: point,\n covered_with_solder_mask: z.boolean().optional().default(true),\n })\n .describe(\"Defines a PCB panel that can contain multiple boards\")\n\n/**\n * Defines a PCB panel that can contain multiple boards\n */\nexport interface PcbPanel {\n type: \"pcb_panel\"\n pcb_panel_id: string\n width: Length\n height: Length\n center: Point\n covered_with_solder_mask: boolean\n}\n\nexport type PcbPanelInput = z.input<typeof pcb_panel>\ntype InferredPcbPanel = z.infer<typeof pcb_panel>\n\n/**\n * @deprecated use PcbPanel\n */\nexport type PCBPanel = PcbPanel\n\nexpectTypesMatch<PcbPanel, InferredPcbPanel>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_placement_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_placement_error\"),\n pcb_placement_error_id: getZodPrefixedIdWithDefault(\"pcb_placement_error\"),\n error_type: z.literal(\"pcb_placement_error\").default(\"pcb_placement_error\"),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a placement error on the PCB\")\n\nexport type PcbPlacementErrorInput = z.input<typeof pcb_placement_error>\ntype InferredPcbPlacementError = z.infer<typeof pcb_placement_error>\n\n/**\n * Defines a placement error on the PCB\n */\nexport interface PcbPlacementError extends BaseCircuitJsonError {\n type: \"pcb_placement_error\"\n pcb_placement_error_id: string\n error_type: \"pcb_placement_error\"\n subcircuit_id?: string\n}\n\n/**\n * @deprecated use PcbPlacementError\n */\nexport type PCBPlacementError = PcbPlacementError\n\nexpectTypesMatch<PcbPlacementError, InferredPcbPlacementError>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_panelization_placement_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_panelization_placement_error\"),\n pcb_panelization_placement_error_id: getZodPrefixedIdWithDefault(\n \"pcb_panelization_placement_error\",\n ),\n error_type: z\n .literal(\"pcb_panelization_placement_error\")\n .default(\"pcb_panelization_placement_error\"),\n pcb_panel_id: z.string().optional(),\n pcb_board_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a panelization placement error on the PCB\")\n\nexport type PcbPanelizationPlacementErrorInput = z.input<\n typeof pcb_panelization_placement_error\n>\ntype InferredPcbPanelizationPlacementError = z.infer<\n typeof pcb_panelization_placement_error\n>\n\n/**\n * Defines a panelization placement error on the PCB\n */\nexport interface PcbPanelizationPlacementError extends BaseCircuitJsonError {\n type: \"pcb_panelization_placement_error\"\n pcb_panelization_placement_error_id: string\n error_type: \"pcb_panelization_placement_error\"\n pcb_panel_id?: string\n pcb_board_id?: string\n subcircuit_id?: string\n}\n\n/**\n * @deprecated use PcbPanelizationPlacementError\n */\nexport type PCBPanelizationPlacementError = PcbPanelizationPlacementError\n\nexpectTypesMatch<\n PcbPanelizationPlacementError,\n InferredPcbPanelizationPlacementError\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { route_hint_point, type RouteHintPoint } from \"src/pcb\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/**\n * A hint that can be used during generation of a PCB trace.\n */\nexport interface PcbTraceHint {\n type: \"pcb_trace_hint\"\n pcb_trace_hint_id: string\n pcb_port_id: string\n pcb_component_id: string\n route: RouteHintPoint[]\n subcircuit_id?: string\n}\n\nexport const pcb_trace_hint = z\n .object({\n type: z.literal(\"pcb_trace_hint\"),\n pcb_trace_hint_id: getZodPrefixedIdWithDefault(\"pcb_trace_hint\"),\n pcb_port_id: z.string(),\n pcb_component_id: z.string(),\n route: z.array(route_hint_point),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"A hint that can be used during generation of a PCB trace\")\n\nexport type PcbTraceHintInput = z.input<typeof pcb_trace_hint>\ntype InferredPcbTraceHint = z.infer<typeof pcb_trace_hint>\n\n/**\n * @deprecated use PcbTraceHint\n */\nexport type PCBTraceHint = PcbTraceHint\n\nexpectTypesMatch<PcbTraceHint, InferredPcbTraceHint>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport {\n layer_ref,\n type LayerRef,\n type VisibleLayer,\n visible_layer,\n} from \"src/pcb/properties/layer_ref\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_line = z\n .object({\n type: z.literal(\"pcb_silkscreen_line\"),\n pcb_silkscreen_line_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_line\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n stroke_width: distance.default(\"0.1mm\"),\n x1: distance,\n y1: distance,\n x2: distance,\n y2: distance,\n layer: visible_layer,\n })\n .describe(\"Defines a silkscreen line on the PCB\")\n\nexport type PcbSilkscreenLineInput = z.input<typeof pcb_silkscreen_line>\ntype InferredPcbSilkscreenLine = z.infer<typeof pcb_silkscreen_line>\n\n/**\n * Defines a silkscreen line on the PCB\n */\nexport interface PcbSilkscreenLine {\n type: \"pcb_silkscreen_line\"\n pcb_silkscreen_line_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n stroke_width: Distance\n x1: Distance\n y1: Distance\n x2: Distance\n y2: Distance\n layer: VisibleLayer\n}\n\n/**\n * @deprecated use PcbSilkscreenLine\n */\nexport type PCBSilkscreenLine = PcbSilkscreenLine\n\nexpectTypesMatch<PcbSilkscreenLine, InferredPcbSilkscreenLine>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport {\n visible_layer,\n type VisibleLayerRef,\n} from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_path = z\n .object({\n type: z.literal(\"pcb_silkscreen_path\"),\n pcb_silkscreen_path_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_path\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: visible_layer,\n route: z.array(point),\n stroke_width: length,\n })\n .describe(\"Defines a silkscreen path on the PCB\")\n\nexport type PcbSilkscreenPathInput = z.input<typeof pcb_silkscreen_path>\ntype InferredPcbSilkscreenPath = z.infer<typeof pcb_silkscreen_path>\n\n/**\n * Defines a silkscreen path on the PCB\n */\nexport interface PcbSilkscreenPath {\n type: \"pcb_silkscreen_path\"\n pcb_silkscreen_path_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n layer: VisibleLayerRef\n route: Point[]\n stroke_width: Length\n}\n\n/**\n * @deprecated use PcbSilkscreenPath\n */\nexport type PcbSilkscreenPathDeprecated = PcbSilkscreenPath\n\nexpectTypesMatch<PcbSilkscreenPath, InferredPcbSilkscreenPath>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { distance, length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n ninePointAnchor,\n type NinePointAnchor,\n} from \"src/common/NinePointAnchor\"\n\nexport const pcb_silkscreen_text = z\n .object({\n type: z.literal(\"pcb_silkscreen_text\"),\n pcb_silkscreen_text_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_text\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: distance.default(\"0.2mm\"),\n pcb_component_id: z.string(),\n text: z.string(),\n is_knockout: z.boolean().default(false).optional(),\n knockout_padding: z\n .object({\n left: length,\n top: length,\n bottom: length,\n right: length,\n })\n .default({\n left: \"0.2mm\",\n top: \"0.2mm\",\n bottom: \"0.2mm\",\n right: \"0.2mm\",\n })\n .optional(),\n ccw_rotation: z.number().optional(),\n layer: layer_ref,\n is_mirrored: z.boolean().default(false).optional(),\n anchor_position: point.default({ x: 0, y: 0 }),\n anchor_alignment: ninePointAnchor.default(\"center\"),\n })\n .describe(\"Defines silkscreen text on the PCB\")\n\nexport type PcbSilkscreenTextInput = z.input<typeof pcb_silkscreen_text>\ntype InferredPcbSilkscreenText = z.infer<typeof pcb_silkscreen_text>\n\n/**\n * Defines silkscreen text on the PCB\n */\nexport interface PcbSilkscreenText {\n type: \"pcb_silkscreen_text\"\n pcb_silkscreen_text_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n font: \"tscircuit2024\"\n font_size: Length\n pcb_component_id: string\n text: string\n is_knockout?: boolean\n knockout_padding?: {\n left: Length\n top: Length\n bottom: Length\n right: Length\n }\n ccw_rotation?: number\n layer: LayerRef\n is_mirrored?: boolean\n anchor_position: Point\n anchor_alignment: NinePointAnchor\n}\n\n/**\n * @deprecated use PcbSilkscreenText\n */\nexport type PCBSilkscreenText = PcbSilkscreenText\n\nexpectTypesMatch<PcbSilkscreenText, InferredPcbSilkscreenText>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { distance, length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n ninePointAnchor,\n type NinePointAnchor,\n} from \"src/common/NinePointAnchor\"\n\nexport const pcb_copper_text = z\n .object({\n type: z.literal(\"pcb_copper_text\"),\n pcb_copper_text_id: getZodPrefixedIdWithDefault(\"pcb_copper_text\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: distance.default(\"0.2mm\"),\n pcb_component_id: z.string(),\n text: z.string(),\n is_knockout: z.boolean().default(false).optional(),\n knockout_padding: z\n .object({\n left: length,\n top: length,\n bottom: length,\n right: length,\n })\n .default({\n left: \"0.2mm\",\n top: \"0.2mm\",\n bottom: \"0.2mm\",\n right: \"0.2mm\",\n })\n .optional(),\n ccw_rotation: z.number().optional(),\n layer: layer_ref,\n is_mirrored: z.boolean().default(false).optional(),\n anchor_position: point.default({ x: 0, y: 0 }),\n anchor_alignment: ninePointAnchor.default(\"center\"),\n })\n .describe(\"Defines copper text on the PCB\")\n\nexport type PcbCopperTextInput = z.input<typeof pcb_copper_text>\ntype InferredPcbCopperText = z.infer<typeof pcb_copper_text>\n\n/**\n * Defines copper text on the PCB\n */\nexport interface PcbCopperText {\n type: \"pcb_copper_text\"\n pcb_copper_text_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n font: \"tscircuit2024\"\n font_size: Length\n pcb_component_id: string\n text: string\n is_knockout?: boolean\n knockout_padding?: {\n left: Length\n top: Length\n bottom: Length\n right: Length\n }\n ccw_rotation?: number\n layer: LayerRef\n is_mirrored?: boolean\n anchor_position: Point\n anchor_alignment: NinePointAnchor\n}\n\n/**\n * @deprecated use PcbCopperText\n */\nexport type PCBCopperText = PcbCopperText\n\nexpectTypesMatch<PcbCopperText, InferredPcbCopperText>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_rect = z\n .object({\n type: z.literal(\"pcb_silkscreen_rect\"),\n pcb_silkscreen_rect_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_rect\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n width: length,\n height: length,\n layer: layer_ref,\n stroke_width: length.default(\"1mm\"),\n corner_radius: length.optional(),\n is_filled: z.boolean().default(true).optional(),\n has_stroke: z.boolean().optional(),\n is_stroke_dashed: z.boolean().optional(),\n ccw_rotation: z.number().optional(),\n })\n .describe(\"Defines a silkscreen rect on the PCB\")\n\nexport type PcbSilkscreenRectInput = z.input<typeof pcb_silkscreen_rect>\ntype InferredPcbSilkscreenRect = z.infer<typeof pcb_silkscreen_rect>\n\n/**\n * Defines a silkscreen rect on the PCB\n */\nexport interface PcbSilkscreenRect {\n type: \"pcb_silkscreen_rect\"\n pcb_silkscreen_rect_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n width: Length\n height: Length\n layer: LayerRef\n stroke_width: Length\n corner_radius?: Length\n is_filled?: boolean\n has_stroke?: boolean\n is_stroke_dashed?: boolean\n ccw_rotation?: number\n}\n\n/**\n * @deprecated use PcbSilkscreenRect\n */\nexport type PcbSilkscreenRectOld = PcbSilkscreenRect\n\nexpectTypesMatch<PcbSilkscreenRect, InferredPcbSilkscreenRect>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport {\n layer_ref,\n visible_layer,\n type LayerRef,\n type VisibleLayer,\n} from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_circle = z\n .object({\n type: z.literal(\"pcb_silkscreen_circle\"),\n pcb_silkscreen_circle_id: getZodPrefixedIdWithDefault(\n \"pcb_silkscreen_circle\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n radius: length,\n layer: visible_layer,\n stroke_width: length.default(\"1mm\"),\n })\n .describe(\"Defines a silkscreen circle on the PCB\")\n\nexport type PcbSilkscreenCircleInput = z.input<typeof pcb_silkscreen_circle>\ntype InferredPcbSilkscreenCircle = z.infer<typeof pcb_silkscreen_circle>\n\n/**\n * Defines a silkscreen circle on the PCB\n */\nexport interface PcbSilkscreenCircle {\n type: \"pcb_silkscreen_circle\"\n pcb_silkscreen_circle_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n radius: Length\n layer: VisibleLayer\n stroke_width: Length\n}\n\nexpectTypesMatch<PcbSilkscreenCircle, InferredPcbSilkscreenCircle>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport {\n layer_ref,\n type LayerRef,\n visible_layer,\n type VisibleLayer,\n} from \"src/pcb/properties/layer_ref\"\nimport { distance, rotation, type Distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_oval = z\n .object({\n type: z.literal(\"pcb_silkscreen_oval\"),\n pcb_silkscreen_oval_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_oval\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n radius_x: distance,\n radius_y: distance,\n layer: visible_layer,\n ccw_rotation: rotation.optional(),\n })\n .describe(\"Defines a silkscreen oval on the PCB\")\n\nexport type PcbSilkscreenOvalInput = z.input<typeof pcb_silkscreen_oval>\ntype InferredPcbSilkscreenOval = z.infer<typeof pcb_silkscreen_oval>\n\n/**\n * Defines a silkscreen oval on the PCB\n */\nexport interface PcbSilkscreenOval {\n type: \"pcb_silkscreen_oval\"\n pcb_silkscreen_oval_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n radius_x: Distance\n radius_y: Distance\n layer: VisibleLayer\n ccw_rotation?: number\n}\n\n/**\n * @deprecated use PcbSilkscreenOval\n */\nexport type PcbSilkscreenOvalDeprecated = PcbSilkscreenOval\n\nexpectTypesMatch<PcbSilkscreenOval, InferredPcbSilkscreenOval>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_silkscreen_pill = z\n .object({\n type: z.literal(\"pcb_silkscreen_pill\"),\n pcb_silkscreen_pill_id: getZodPrefixedIdWithDefault(\"pcb_silkscreen_pill\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n width: length,\n height: length,\n layer: layer_ref,\n ccw_rotation: z.number().optional(),\n })\n .describe(\"Defines a silkscreen pill on the PCB\")\n\nexport type PcbSilkscreenPillInput = z.input<typeof pcb_silkscreen_pill>\ntype InferredPcbSilkscreenPill = z.infer<typeof pcb_silkscreen_pill>\n\n/**\n * Defines a silkscreen pill on the PCB\n */\nexport interface PcbSilkscreenPill {\n type: \"pcb_silkscreen_pill\"\n pcb_silkscreen_pill_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n width: Length\n height: Length\n layer: LayerRef\n ccw_rotation?: number\n}\n\n/**\n * @deprecated use PcbSilkscreenPill\n */\nexport type PcbSilkscreenPillDeprecated = PcbSilkscreenPill\n\nexpectTypesMatch<PcbSilkscreenPill, InferredPcbSilkscreenPill>(true)\n","import { z } from \"zod\"\nimport { point, type Point } from \"src/common\"\nimport { distance, type Length } from \"src/units\"\nimport {\n visible_layer,\n type LayerRef,\n type VisibleLayer,\n} from \"src/pcb/properties/layer_ref\"\nimport { getZodPrefixedIdWithDefault } from \"src/common/getZodPrefixedIdWithDefault\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_fabrication_note_text = z\n .object({\n type: z.literal(\"pcb_fabrication_note_text\"),\n pcb_fabrication_note_text_id: getZodPrefixedIdWithDefault(\n \"pcb_fabrication_note_text\",\n ),\n subcircuit_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: distance.default(\"1mm\"),\n pcb_component_id: z.string(),\n text: z.string(),\n layer: visible_layer,\n anchor_position: point.default({ x: 0, y: 0 }),\n anchor_alignment: z\n .enum([\"center\", \"top_left\", \"top_right\", \"bottom_left\", \"bottom_right\"])\n .default(\"center\"),\n color: z.string().optional(),\n })\n .describe(\n \"Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators\",\n )\n\nexport type PcbFabricationNoteTextInput = z.input<\n typeof pcb_fabrication_note_text\n>\ntype InferredPcbFabricationNoteText = z.infer<typeof pcb_fabrication_note_text>\n\n/**\n * Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators\n */\nexport interface PcbFabricationNoteText {\n type: \"pcb_fabrication_note_text\"\n pcb_fabrication_note_text_id: string\n subcircuit_id?: string\n pcb_group_id?: string\n font: \"tscircuit2024\"\n font_size: Length\n pcb_component_id: string\n text: string\n layer: VisibleLayer\n anchor_position: Point\n anchor_alignment:\n | \"center\"\n | \"top_left\"\n | \"top_right\"\n | \"bottom_left\"\n | \"bottom_right\"\n color?: string\n}\n\n/**\n * @deprecated use PcbFabricationNoteText\n */\nexport type PCBFabricationNoteText = PcbFabricationNoteText\n\nexpectTypesMatch<PcbFabricationNoteText, InferredPcbFabricationNoteText>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport {\n layer_ref,\n visible_layer,\n type LayerRef,\n} from \"src/pcb/properties/layer_ref\"\nimport { point, type Point } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_fabrication_note_path = z\n .object({\n type: z.literal(\"pcb_fabrication_note_path\"),\n pcb_fabrication_note_path_id: getZodPrefixedIdWithDefault(\n \"pcb_fabrication_note_path\",\n ),\n pcb_component_id: z.string(),\n subcircuit_id: z.string().optional(),\n layer: layer_ref,\n route: z.array(point),\n stroke_width: length,\n color: z.string().optional(),\n })\n .describe(\n \"Defines a fabrication path on the PCB for fabricators or assemblers\",\n )\n\nexport type PcbFabricationNotePathInput = z.input<\n typeof pcb_fabrication_note_path\n>\ntype InferredPcbFabricationNotePath = z.infer<typeof pcb_fabrication_note_path>\n\n/**\n * Defines a fabrication path on the PCB for fabricators or assemblers\n */\nexport interface PcbFabricationNotePath {\n type: \"pcb_fabrication_note_path\"\n pcb_fabrication_note_path_id: string\n pcb_component_id: string\n subcircuit_id?: string\n layer: LayerRef\n route: Point[]\n stroke_width: Length\n color?: string\n}\n\n/**\n * @deprecated use PcbFabricationNotePath\n */\nexport type PCBFabricationNotePath = PcbFabricationNotePath\n\nexpectTypesMatch<PcbFabricationNotePath, InferredPcbFabricationNotePath>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_fabrication_note_rect = z\n .object({\n type: z.literal(\"pcb_fabrication_note_rect\"),\n pcb_fabrication_note_rect_id: getZodPrefixedIdWithDefault(\n \"pcb_fabrication_note_rect\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n width: length,\n height: length,\n layer: visible_layer,\n stroke_width: length.default(\"0.1mm\"),\n corner_radius: length.optional(),\n is_filled: z.boolean().optional(),\n has_stroke: z.boolean().optional(),\n is_stroke_dashed: z.boolean().optional(),\n color: z.string().optional(),\n })\n .describe(\"Defines a fabrication note rectangle on the PCB\")\n\nexport type PcbFabricationNoteRectInput = z.input<\n typeof pcb_fabrication_note_rect\n>\ntype InferredPcbFabricationNoteRect = z.infer<typeof pcb_fabrication_note_rect>\n\n/**\n * Defines a fabrication note rectangle on the PCB\n */\nexport interface PcbFabricationNoteRect {\n type: \"pcb_fabrication_note_rect\"\n pcb_fabrication_note_rect_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n width: Length\n height: Length\n layer: VisibleLayer\n stroke_width: Length\n corner_radius?: Length\n is_filled?: boolean\n has_stroke?: boolean\n is_stroke_dashed?: boolean\n color?: string\n}\n\n/**\n * @deprecated use PcbFabricationNoteRect\n */\nexport type PCBFabricationNoteRect = PcbFabricationNoteRect\n\nexpectTypesMatch<PcbFabricationNoteRect, InferredPcbFabricationNoteRect>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_fabrication_note_dimension = z\n .object({\n type: z.literal(\"pcb_fabrication_note_dimension\"),\n pcb_fabrication_note_dimension_id: getZodPrefixedIdWithDefault(\n \"pcb_fabrication_note_dimension\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: visible_layer,\n from: point,\n to: point,\n text: z.string().optional(),\n text_ccw_rotation: z.number().optional(),\n offset: length.optional(),\n offset_distance: length.optional(),\n offset_direction: z\n .object({\n x: z.number(),\n y: z.number(),\n })\n .optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: length.default(\"1mm\"),\n color: z.string().optional(),\n arrow_size: length.default(\"1mm\"),\n })\n .describe(\"Defines a measurement annotation within PCB fabrication notes\")\n\nexport type PcbFabricationNoteDimensionInput = z.input<\n typeof pcb_fabrication_note_dimension\n>\ntype InferredPcbFabricationNoteDimension = z.infer<\n typeof pcb_fabrication_note_dimension\n>\n\n/**\n * Defines a measurement annotation within PCB fabrication notes\n */\nexport interface PcbFabricationNoteDimension {\n type: \"pcb_fabrication_note_dimension\"\n pcb_fabrication_note_dimension_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n layer: VisibleLayer\n from: Point\n to: Point\n text?: string\n text_ccw_rotation?: number\n offset?: Length\n offset_distance?: Length\n offset_direction?: {\n x: number\n y: number\n }\n font: \"tscircuit2024\"\n font_size: Length\n color?: string\n arrow_size: Length\n}\n\n/**\n * @deprecated use PcbFabricationNoteDimension\n */\nexport type PCBFabricationNoteDimension = PcbFabricationNoteDimension\n\nexpectTypesMatch<\n PcbFabricationNoteDimension,\n InferredPcbFabricationNoteDimension\n>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_note_text = z\n .object({\n type: z.literal(\"pcb_note_text\"),\n pcb_note_text_id: getZodPrefixedIdWithDefault(\"pcb_note_text\"),\n pcb_component_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n name: z.string().optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: distance.default(\"1mm\"),\n text: z.string().optional(),\n anchor_position: point.default({ x: 0, y: 0 }),\n anchor_alignment: z\n .enum([\"center\", \"top_left\", \"top_right\", \"bottom_left\", \"bottom_right\"])\n .default(\"center\"),\n color: z.string().optional(),\n })\n .describe(\"Defines a documentation note in text on the PCB\")\n\nexport type PcbNoteTextInput = z.input<typeof pcb_note_text>\ntype InferredPcbNoteText = z.infer<typeof pcb_note_text>\n\n/**\n * Defines a documentation note in text on the PCB\n */\nexport interface PcbNoteText {\n type: \"pcb_note_text\"\n pcb_note_text_id: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n name?: string\n font: \"tscircuit2024\"\n font_size: Length\n text?: string\n anchor_position: Point\n anchor_alignment:\n | \"center\"\n | \"top_left\"\n | \"top_right\"\n | \"bottom_left\"\n | \"bottom_right\"\n color?: string\n}\n\nexpectTypesMatch<PcbNoteText, InferredPcbNoteText>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_note_rect = z\n .object({\n type: z.literal(\"pcb_note_rect\"),\n pcb_note_rect_id: getZodPrefixedIdWithDefault(\"pcb_note_rect\"),\n pcb_component_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n name: z.string().optional(),\n text: z.string().optional(),\n center: point,\n width: length,\n height: length,\n stroke_width: length.default(\"0.1mm\"),\n corner_radius: length.optional(),\n is_filled: z.boolean().optional(),\n has_stroke: z.boolean().optional(),\n is_stroke_dashed: z.boolean().optional(),\n color: z.string().optional(),\n })\n .describe(\"Defines a rectangular documentation note on the PCB\")\n\nexport type PcbNoteRectInput = z.input<typeof pcb_note_rect>\ntype InferredPcbNoteRect = z.infer<typeof pcb_note_rect>\n\n/**\n * Defines a rectangular documentation note on the PCB\n */\nexport interface PcbNoteRect {\n type: \"pcb_note_rect\"\n pcb_note_rect_id: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n name?: string\n text?: string\n center: Point\n width: Length\n height: Length\n stroke_width: Length\n corner_radius?: Length\n is_filled?: boolean\n has_stroke?: boolean\n is_stroke_dashed?: boolean\n color?: string\n}\n\nexpectTypesMatch<PcbNoteRect, InferredPcbNoteRect>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_note_path = z\n .object({\n type: z.literal(\"pcb_note_path\"),\n pcb_note_path_id: getZodPrefixedIdWithDefault(\"pcb_note_path\"),\n pcb_component_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n name: z.string().optional(),\n text: z.string().optional(),\n route: z.array(point),\n stroke_width: length.default(\"0.1mm\"),\n color: z.string().optional(),\n })\n .describe(\"Defines a polyline documentation note on the PCB\")\n\nexport type PcbNotePathInput = z.input<typeof pcb_note_path>\ntype InferredPcbNotePath = z.infer<typeof pcb_note_path>\n\n/**\n * Defines a polyline documentation note on the PCB\n */\nexport interface PcbNotePath {\n type: \"pcb_note_path\"\n pcb_note_path_id: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n name?: string\n text?: string\n route: Point[]\n stroke_width: Length\n color?: string\n}\n\nexpectTypesMatch<PcbNotePath, InferredPcbNotePath>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_note_line = z\n .object({\n type: z.literal(\"pcb_note_line\"),\n pcb_note_line_id: getZodPrefixedIdWithDefault(\"pcb_note_line\"),\n pcb_component_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n name: z.string().optional(),\n text: z.string().optional(),\n x1: distance,\n y1: distance,\n x2: distance,\n y2: distance,\n stroke_width: distance.default(\"0.1mm\"),\n color: z.string().optional(),\n is_dashed: z.boolean().optional(),\n })\n .describe(\"Defines a straight documentation note line on the PCB\")\n\nexport type PcbNoteLineInput = z.input<typeof pcb_note_line>\ntype InferredPcbNoteLine = z.infer<typeof pcb_note_line>\n\n/**\n * Defines a straight documentation note line on the PCB\n */\nexport interface PcbNoteLine {\n type: \"pcb_note_line\"\n pcb_note_line_id: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n name?: string\n text?: string\n x1: Distance\n y1: Distance\n x2: Distance\n y2: Distance\n stroke_width: Distance\n color?: string\n is_dashed?: boolean\n}\n\nexpectTypesMatch<PcbNoteLine, InferredPcbNoteLine>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_note_dimension = z\n .object({\n type: z.literal(\"pcb_note_dimension\"),\n pcb_note_dimension_id: getZodPrefixedIdWithDefault(\"pcb_note_dimension\"),\n pcb_component_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n name: z.string().optional(),\n from: point,\n to: point,\n text: z.string().optional(),\n text_ccw_rotation: z.number().optional(),\n offset_distance: length.optional(),\n offset_direction: z\n .object({\n x: z.number(),\n y: z.number(),\n })\n .optional(),\n font: z.literal(\"tscircuit2024\").default(\"tscircuit2024\"),\n font_size: length.default(\"1mm\"),\n color: z.string().optional(),\n arrow_size: length.default(\"1mm\"),\n })\n .describe(\"Defines a measurement annotation within PCB documentation notes\")\n\nexport type PcbNoteDimensionInput = z.input<typeof pcb_note_dimension>\ntype InferredPcbNoteDimension = z.infer<typeof pcb_note_dimension>\n\n/**\n * Defines a measurement annotation within PCB documentation notes\n */\nexport interface PcbNoteDimension {\n type: \"pcb_note_dimension\"\n pcb_note_dimension_id: string\n pcb_component_id?: string\n pcb_group_id?: string\n subcircuit_id?: string\n name?: string\n from: Point\n to: Point\n text?: string\n text_ccw_rotation?: number\n offset_distance?: Length\n offset_direction?: {\n x: number\n y: number\n }\n font: \"tscircuit2024\"\n font_size: Length\n color?: string\n arrow_size: Length\n}\n\nexpectTypesMatch<PcbNoteDimension, InferredPcbNoteDimension>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_footprint_overlap_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_footprint_overlap_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_error\"),\n error_type: z\n .literal(\"pcb_footprint_overlap_error\")\n .default(\"pcb_footprint_overlap_error\"),\n pcb_smtpad_ids: z.array(z.string()).optional(),\n pcb_plated_hole_ids: z.array(z.string()).optional(),\n pcb_hole_ids: z.array(z.string()).optional(),\n pcb_keepout_ids: z.array(z.string()).optional(),\n })\n .describe(\"Error emitted when a pcb footprint overlaps with another element\")\n\nexport type PcbFootprintOverlapErrorInput = z.input<\n typeof pcb_footprint_overlap_error\n>\ntype InferredPcbFootprintOverlapError = z.infer<\n typeof pcb_footprint_overlap_error\n>\n\n/** Error emitted when a pcb footprint overlaps with another element */\nexport interface PcbFootprintOverlapError extends BaseCircuitJsonError {\n type: \"pcb_footprint_overlap_error\"\n pcb_error_id: string\n error_type: \"pcb_footprint_overlap_error\"\n pcb_smtpad_ids?: string[]\n pcb_plated_hole_ids?: string[]\n pcb_hole_ids?: string[]\n pcb_keepout_ids?: string[]\n}\n\nexpectTypesMatch<PcbFootprintOverlapError, InferredPcbFootprintOverlapError>(\n true,\n)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_courtyard_overlap_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_courtyard_overlap_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_error\"),\n error_type: z\n .literal(\"pcb_courtyard_overlap_error\")\n .default(\"pcb_courtyard_overlap_error\"),\n pcb_component_ids: z.tuple([z.string(), z.string()]),\n })\n .describe(\n \"Error emitted when the courtyard (CrtYd) of one PCB component overlaps with the courtyard of another\",\n )\n\nexport type PcbCourtyardOverlapErrorInput = z.input<\n typeof pcb_courtyard_overlap_error\n>\ntype InferredPcbCourtyardOverlapError = z.infer<\n typeof pcb_courtyard_overlap_error\n>\n\n/** Error emitted when the courtyard (CrtYd) of one PCB component overlaps with the courtyard of another */\nexport interface PcbCourtyardOverlapError extends BaseCircuitJsonError {\n type: \"pcb_courtyard_overlap_error\"\n pcb_error_id: string\n error_type: \"pcb_courtyard_overlap_error\"\n pcb_component_ids: [string, string]\n}\n\nexpectTypesMatch<PcbCourtyardOverlapError, InferredPcbCourtyardOverlapError>(\n true,\n)\n","import { z } from \"zod\"\nimport { point, type Point } from \"../common\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_keepout = z\n .object({\n type: z.literal(\"pcb_keepout\"),\n shape: z.literal(\"rect\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n width: distance,\n height: distance,\n pcb_keepout_id: z.string(),\n layers: z.array(z.string()), // Specify layers where the keepout applies\n description: z.string().optional(), // Optional description of the keepout\n })\n .or(\n z.object({\n type: z.literal(\"pcb_keepout\"),\n shape: z.literal(\"circle\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n radius: distance,\n pcb_keepout_id: z.string(),\n layers: z.array(z.string()), // Specify layers where the keepout applies\n description: z.string().optional(), // Optional description of the keepout\n }),\n )\n\nexport type PCBKeepoutInput = z.input<typeof pcb_keepout>\ntype InferredPCBKeepout = z.infer<typeof pcb_keepout>\n\nexport interface PCBKeepoutRect {\n type: \"pcb_keepout\"\n shape: \"rect\"\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n width: number\n height: number\n pcb_keepout_id: string\n layers: string[]\n description?: string\n}\n\nexport interface PCBKeepoutCircle {\n type: \"pcb_keepout\"\n shape: \"circle\"\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n radius: number\n pcb_keepout_id: string\n layers: string[]\n description?: string\n}\n\nexport type PCBKeepout = PCBKeepoutRect | PCBKeepoutCircle\n\nexpectTypesMatch<PCBKeepout, InferredPCBKeepout>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length, rotation, type Rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n// Common properties base for all cutout shapes (internal)\nconst pcb_cutout_base = z.object({\n type: z.literal(\"pcb_cutout\"),\n pcb_cutout_id: getZodPrefixedIdWithDefault(\"pcb_cutout\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n pcb_board_id: z.string().optional(),\n pcb_panel_id: z.string().optional(),\n})\n\n// Rectangular Cutout\nexport const pcb_cutout_rect = pcb_cutout_base.extend({\n shape: z.literal(\"rect\"),\n center: point,\n width: length,\n height: length,\n rotation: rotation.optional(),\n corner_radius: length.optional(),\n})\nexport type PcbCutoutRectInput = z.input<typeof pcb_cutout_rect>\ntype InferredPcbCutoutRect = z.infer<typeof pcb_cutout_rect>\n/**\n * Defines a rectangular cutout on the PCB.\n */\nexport interface PcbCutoutRect {\n type: \"pcb_cutout\"\n pcb_cutout_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_board_id?: string\n pcb_panel_id?: string\n shape: \"rect\"\n center: Point\n width: Length\n height: Length\n rotation?: Rotation\n corner_radius?: Length\n}\nexpectTypesMatch<PcbCutoutRect, InferredPcbCutoutRect>(true)\n\n// Circular Cutout\nexport const pcb_cutout_circle = pcb_cutout_base.extend({\n shape: z.literal(\"circle\"),\n center: point,\n radius: length,\n})\nexport type PcbCutoutCircleInput = z.input<typeof pcb_cutout_circle>\ntype InferredPcbCutoutCircle = z.infer<typeof pcb_cutout_circle>\n/**\n * Defines a circular cutout on the PCB.\n */\nexport interface PcbCutoutCircle {\n type: \"pcb_cutout\"\n pcb_cutout_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_board_id?: string\n pcb_panel_id?: string\n shape: \"circle\"\n center: Point\n radius: Length\n}\nexpectTypesMatch<PcbCutoutCircle, InferredPcbCutoutCircle>(true)\n\n// Polygon Cutout\nexport const pcb_cutout_polygon = pcb_cutout_base.extend({\n shape: z.literal(\"polygon\"),\n points: z.array(point),\n})\nexport type PcbCutoutPolygonInput = z.input<typeof pcb_cutout_polygon>\ntype InferredPcbCutoutPolygon = z.infer<typeof pcb_cutout_polygon>\n/**\n * Defines a polygonal cutout on the PCB, specified by a list of points.\n * The polygon should be closed (the last point implicitly connects to the first).\n */\nexport interface PcbCutoutPolygon {\n type: \"pcb_cutout\"\n pcb_cutout_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_board_id?: string\n pcb_panel_id?: string\n shape: \"polygon\"\n points: Point[]\n}\nexpectTypesMatch<PcbCutoutPolygon, InferredPcbCutoutPolygon>(true)\n\n// Path Cutout (for slots along a path)\nexport const pcb_cutout_path = pcb_cutout_base.extend({\n shape: z.literal(\"path\"),\n route: z.array(point),\n slot_width: length,\n slot_length: length.optional(),\n space_between_slots: length.optional(),\n slot_corner_radius: length.optional(),\n})\nexport type PcbCutoutPathInput = z.input<typeof pcb_cutout_path>\ntype InferredPcbCutoutPath = z.infer<typeof pcb_cutout_path>\n/**\n * Defines a path-based cutout on the PCB, creating slots along the specified path.\n * When slot_length and space_between_slots are specified, creates a dashed pattern of slots.\n * When they are omitted, creates a continuous slot along the entire path.\n * The slot_corner_radius controls the rounding of slot corners (0 = square, slot_width/2 = circle).\n */\nexport interface PcbCutoutPath {\n type: \"pcb_cutout\"\n pcb_cutout_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n pcb_board_id?: string\n pcb_panel_id?: string\n shape: \"path\"\n route: Point[]\n slot_width: Length\n slot_length?: Length\n space_between_slots?: Length\n slot_corner_radius?: Length\n}\nexpectTypesMatch<PcbCutoutPath, InferredPcbCutoutPath>(true)\n\n// Union of all cutout shapes\nexport const pcb_cutout = z\n .discriminatedUnion(\"shape\", [\n pcb_cutout_rect,\n pcb_cutout_circle,\n pcb_cutout_polygon,\n pcb_cutout_path,\n ])\n .describe(\"Defines a cutout on the PCB, removing board material.\")\n\nexport type PcbCutoutInput = z.input<typeof pcb_cutout>\nexport type PcbCutout =\n | PcbCutoutRect\n | PcbCutoutCircle\n | PcbCutoutPolygon\n | PcbCutoutPath\n\ntype InferredPcbCutout = z.infer<typeof pcb_cutout>\nexpectTypesMatch<PcbCutout, InferredPcbCutout>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_missing_footprint_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_missing_footprint_error\"),\n pcb_missing_footprint_error_id: getZodPrefixedIdWithDefault(\n \"pcb_missing_footprint_error\",\n ),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n error_type: z\n .literal(\"pcb_missing_footprint_error\")\n .default(\"pcb_missing_footprint_error\"),\n source_component_id: z.string(),\n })\n .describe(\"Defines a missing footprint error on the PCB\")\n\nexport type PcbMissingFootprintErrorInput = z.input<\n typeof pcb_missing_footprint_error\n>\ntype InferredPcbMissingFootprintError = z.infer<\n typeof pcb_missing_footprint_error\n>\n\n/**\n * Defines a placement error on the PCB\n */\nexport interface PcbMissingFootprintError extends BaseCircuitJsonError {\n type: \"pcb_missing_footprint_error\"\n pcb_missing_footprint_error_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n error_type: \"pcb_missing_footprint_error\"\n source_component_id: string\n}\n\n/**\n * @deprecated use PcbMissingFootprintError\n */\nexport type PCBMissingFootprintError = PcbMissingFootprintError\n\nexpectTypesMatch<PcbMissingFootprintError, InferredPcbMissingFootprintError>(\n true,\n)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const external_footprint_load_error = base_circuit_json_error\n .extend({\n type: z.literal(\"external_footprint_load_error\"),\n external_footprint_load_error_id: getZodPrefixedIdWithDefault(\n \"external_footprint_load_error\",\n ),\n pcb_component_id: z.string(),\n source_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n footprinter_string: z.string().optional(),\n error_type: z\n .literal(\"external_footprint_load_error\")\n .default(\"external_footprint_load_error\"),\n })\n .describe(\"Defines an error when an external footprint fails to load\")\n\nexport type ExternalFootprintLoadErrorInput = z.input<\n typeof external_footprint_load_error\n>\ntype InferredExternalFootprintLoadError = z.infer<\n typeof external_footprint_load_error\n>\n\nexport interface ExternalFootprintLoadError extends BaseCircuitJsonError {\n type: \"external_footprint_load_error\"\n external_footprint_load_error_id: string\n pcb_component_id: string\n source_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n footprinter_string?: string\n error_type: \"external_footprint_load_error\"\n}\n\nexpectTypesMatch<\n ExternalFootprintLoadError,\n InferredExternalFootprintLoadError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const circuit_json_footprint_load_error = base_circuit_json_error\n .extend({\n type: z.literal(\"circuit_json_footprint_load_error\"),\n circuit_json_footprint_load_error_id: getZodPrefixedIdWithDefault(\n \"circuit_json_footprint_load_error\",\n ),\n pcb_component_id: z.string(),\n source_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n error_type: z\n .literal(\"circuit_json_footprint_load_error\")\n .default(\"circuit_json_footprint_load_error\"),\n circuit_json: z.array(z.any()).optional(),\n })\n .describe(\"Defines an error when a circuit JSON footprint fails to load\")\n\nexport type CircuitJsonFootprintLoadErrorInput = z.input<\n typeof circuit_json_footprint_load_error\n>\ntype InferredCircuitJsonFootprintLoadError = z.infer<\n typeof circuit_json_footprint_load_error\n>\n\nexport interface CircuitJsonFootprintLoadError extends BaseCircuitJsonError {\n type: \"circuit_json_footprint_load_error\"\n circuit_json_footprint_load_error_id: string\n pcb_component_id: string\n source_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n error_type: \"circuit_json_footprint_load_error\"\n circuit_json?: any[]\n}\n\nexpectTypesMatch<\n CircuitJsonFootprintLoadError,\n InferredCircuitJsonFootprintLoadError\n>(true)\n","import { z } from \"zod\"\nimport {\n point,\n type Point,\n getZodPrefixedIdWithDefault,\n ninePointAnchor,\n type NinePointAnchor,\n} from \"src/common\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_group = z\n .object({\n type: z.literal(\"pcb_group\"),\n pcb_group_id: getZodPrefixedIdWithDefault(\"pcb_group\"),\n source_group_id: z.string(),\n is_subcircuit: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n width: length.optional(),\n height: length.optional(),\n center: point,\n display_offset_x: z\n .string()\n .optional()\n .describe(\n \"How to display the x offset for this group, usually corresponding with how the user specified it\",\n ),\n display_offset_y: z\n .string()\n .optional()\n .describe(\n \"How to display the y offset for this group, usually corresponding with how the user specified it\",\n ),\n outline: z.array(point).optional(),\n anchor_position: point.optional(),\n anchor_alignment: ninePointAnchor.default(\"center\"),\n position_mode: z\n .enum([\"packed\", \"relative_to_group_anchor\", \"none\"])\n .optional(),\n positioned_relative_to_pcb_group_id: z.string().optional(),\n positioned_relative_to_pcb_board_id: z.string().optional(),\n pcb_component_ids: z.array(z.string()),\n child_layout_mode: z.enum([\"packed\", \"none\"]).optional(),\n name: z.string().optional(),\n description: z.string().optional(),\n layout_mode: z.string().optional(),\n autorouter_configuration: z\n .object({\n trace_clearance: length,\n })\n .optional(),\n autorouter_used_string: z.string().optional(),\n })\n .describe(\"Defines a group of components on the PCB\")\n\nexport type PcbGroupInput = z.input<typeof pcb_group>\ntype InferredPcbGroup = z.infer<typeof pcb_group>\n\n/**\n * Defines a group of components on the PCB\n */\nexport interface PcbGroup {\n type: \"pcb_group\"\n pcb_group_id: string\n source_group_id: string\n is_subcircuit?: boolean\n subcircuit_id?: string\n width?: Length\n height?: Length\n center: Point\n display_offset_x?: string\n display_offset_y?: string\n outline?: Point[]\n anchor_position?: Point\n anchor_alignment: NinePointAnchor\n position_mode?: \"packed\" | \"relative_to_group_anchor\" | \"none\"\n positioned_relative_to_pcb_group_id?: string\n positioned_relative_to_pcb_board_id?: string\n pcb_component_ids: string[]\n child_layout_mode?: \"packed\" | \"none\"\n name?: string\n description?: string\n layout_mode?: string\n autorouter_configuration?: {\n trace_clearance: Length\n }\n autorouter_used_string?: string\n}\n\nexpectTypesMatch<PcbGroup, InferredPcbGroup>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_autorouting_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_autorouting_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_autorouting_error\"),\n error_type: z\n .literal(\"pcb_autorouting_error\")\n .default(\"pcb_autorouting_error\"),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"The autorouting has failed to route a portion of the board\")\n\nexport type PcbAutoroutingErrorInput = z.input<typeof pcb_autorouting_error>\ntype PcbInferredAutoroutingError = z.infer<typeof pcb_autorouting_error>\n\nexport interface PcbAutoroutingErrorInterface extends BaseCircuitJsonError {\n type: \"pcb_autorouting_error\"\n pcb_error_id: string\n error_type: \"pcb_autorouting_error\"\n subcircuit_id?: string\n}\n\nexport type PcbAutoroutingError = PcbAutoroutingErrorInterface\n\nexpectTypesMatch<PcbAutoroutingError, PcbInferredAutoroutingError>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"../common\"\nimport { expectTypesMatch } from \"../utils/expect-types-match\"\n\nexport const pcb_manual_edit_conflict_warning = z\n .object({\n type: z.literal(\"pcb_manual_edit_conflict_warning\"),\n pcb_manual_edit_conflict_warning_id: getZodPrefixedIdWithDefault(\n \"pcb_manual_edit_conflict_warning\",\n ),\n warning_type: z\n .literal(\"pcb_manual_edit_conflict_warning\")\n .default(\"pcb_manual_edit_conflict_warning\"),\n message: z.string(),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n source_component_id: z.string(),\n })\n .describe(\n \"Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates\",\n )\n\nexport type PcbManualEditConflictWarningInput = z.input<\n typeof pcb_manual_edit_conflict_warning\n>\ntype InferredPcbManualEditConflictWarning = z.infer<\n typeof pcb_manual_edit_conflict_warning\n>\n\n/**\n * Warning emitted when a component has both manual placement (via manualEdits) and explicit pcbX/pcbY coordinates\n */\nexport interface PcbManualEditConflictWarning {\n type: \"pcb_manual_edit_conflict_warning\"\n pcb_manual_edit_conflict_warning_id: string\n warning_type: \"pcb_manual_edit_conflict_warning\"\n message: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n source_component_id: string\n}\n\nexpectTypesMatch<\n PcbManualEditConflictWarning,\n InferredPcbManualEditConflictWarning\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nconst connectorOrientationDirection = z.enum([\"x-\", \"x+\", \"y+\", \"y-\"])\n\ntype ConnectorOrientationDirection = z.infer<\n typeof connectorOrientationDirection\n>\n\nexport const pcb_connector_not_in_accessible_orientation_warning = z\n .object({\n type: z.literal(\"pcb_connector_not_in_accessible_orientation_warning\"),\n pcb_connector_not_in_accessible_orientation_warning_id:\n getZodPrefixedIdWithDefault(\n \"pcb_connector_not_in_accessible_orientation_warning\",\n ),\n warning_type: z\n .literal(\"pcb_connector_not_in_accessible_orientation_warning\")\n .default(\"pcb_connector_not_in_accessible_orientation_warning\"),\n message: z.string(),\n pcb_component_id: z.string(),\n source_component_id: z.string().optional(),\n pcb_board_id: z.string().optional(),\n facing_direction: connectorOrientationDirection,\n recommended_facing_direction: connectorOrientationDirection,\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Warning emitted when a connector PCB component is facing inward toward the board and should be reoriented to an outward-facing direction\",\n )\n\nexport type PcbConnectorNotInAccessibleOrientationWarningInput = z.input<\n typeof pcb_connector_not_in_accessible_orientation_warning\n>\ntype InferredPcbConnectorNotInAccessibleOrientationWarning = z.infer<\n typeof pcb_connector_not_in_accessible_orientation_warning\n>\n\n/** Warning emitted when a connector PCB component is facing inward toward the board and should be reoriented */\nexport interface PcbConnectorNotInAccessibleOrientationWarning {\n type: \"pcb_connector_not_in_accessible_orientation_warning\"\n pcb_connector_not_in_accessible_orientation_warning_id: string\n warning_type: \"pcb_connector_not_in_accessible_orientation_warning\"\n message: string\n pcb_component_id: string\n source_component_id?: string\n pcb_board_id?: string\n facing_direction: ConnectorOrientationDirection\n recommended_facing_direction: ConnectorOrientationDirection\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n PcbConnectorNotInAccessibleOrientationWarning,\n InferredPcbConnectorNotInAccessibleOrientationWarning\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_breakout_point = z\n .object({\n type: z.literal(\"pcb_breakout_point\"),\n pcb_breakout_point_id: getZodPrefixedIdWithDefault(\"pcb_breakout_point\"),\n pcb_group_id: z.string(),\n subcircuit_id: z.string().optional(),\n source_trace_id: z.string().optional(),\n source_port_id: z.string().optional(),\n source_net_id: z.string().optional(),\n x: distance,\n y: distance,\n })\n .describe(\n \"Defines a routing target within a pcb_group for a source_trace or source_net\",\n )\n\nexport type PcbBreakoutPointInput = z.input<typeof pcb_breakout_point>\ntype InferredPcbBreakoutPoint = z.infer<typeof pcb_breakout_point>\n\n/**\n * Defines a routing target within a pcb_group for a source_trace or source_net\n */\nexport interface PcbBreakoutPoint {\n type: \"pcb_breakout_point\"\n pcb_breakout_point_id: string\n pcb_group_id: string\n subcircuit_id?: string\n source_trace_id?: string\n source_port_id?: string\n source_net_id?: string\n x: Distance\n y: Distance\n}\n\nexpectTypesMatch<PcbBreakoutPoint, InferredPcbBreakoutPoint>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_ground_plane = z\n .object({\n type: z.literal(\"pcb_ground_plane\"),\n pcb_ground_plane_id: getZodPrefixedIdWithDefault(\"pcb_ground_plane\"),\n source_pcb_ground_plane_id: z.string(),\n source_net_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Defines a ground plane on the PCB\")\n\nexport type PcbGroundPlaneInput = z.input<typeof pcb_ground_plane>\ntype InferredPcbGroundPlane = z.infer<typeof pcb_ground_plane>\n\n/**\n * Defines a ground plane on the PCB\n */\nexport interface PcbGroundPlane {\n type: \"pcb_ground_plane\"\n pcb_ground_plane_id: string\n source_pcb_ground_plane_id: string\n source_net_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<PcbGroundPlane, InferredPcbGroundPlane>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_ground_plane_region = z\n .object({\n type: z.literal(\"pcb_ground_plane_region\"),\n pcb_ground_plane_region_id: getZodPrefixedIdWithDefault(\n \"pcb_ground_plane_region\",\n ),\n pcb_ground_plane_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: layer_ref,\n points: z.array(point),\n })\n .describe(\"Defines a polygon region of a ground plane\")\n\nexport type PcbGroundPlaneRegionInput = z.input<typeof pcb_ground_plane_region>\ntype InferredPcbGroundPlaneRegion = z.infer<typeof pcb_ground_plane_region>\n\n/**\n * Defines a polygon region of a ground plane\n */\nexport interface PcbGroundPlaneRegion {\n type: \"pcb_ground_plane_region\"\n pcb_ground_plane_region_id: string\n pcb_ground_plane_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n layer: LayerRef\n points: Point[]\n}\n\nexpectTypesMatch<PcbGroundPlaneRegion, InferredPcbGroundPlaneRegion>(true)\n","import { z } from \"zod\"\nimport { distance, type Distance } from \"src/units\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_thermal_spoke = z\n .object({\n type: z.literal(\"pcb_thermal_spoke\"),\n pcb_thermal_spoke_id: getZodPrefixedIdWithDefault(\"pcb_thermal_spoke\"),\n pcb_ground_plane_id: z.string(),\n shape: z.string(),\n spoke_count: z.number(),\n spoke_thickness: distance,\n spoke_inner_diameter: distance,\n spoke_outer_diameter: distance,\n pcb_plated_hole_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Pattern for connecting a ground plane to a plated hole\")\n\nexport type PcbThermalSpokeInput = z.input<typeof pcb_thermal_spoke>\ntype InferredPcbThermalSpoke = z.infer<typeof pcb_thermal_spoke>\n\n/**\n * Pattern for connecting a ground plane to a plated hole\n */\nexport interface PcbThermalSpoke {\n type: \"pcb_thermal_spoke\"\n pcb_thermal_spoke_id: string\n pcb_ground_plane_id: string\n shape: string\n spoke_count: number\n spoke_thickness: Distance\n spoke_inner_diameter: Distance\n spoke_outer_diameter: Distance\n pcb_plated_hole_id?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<PcbThermalSpoke, InferredPcbThermalSpoke>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { length, type Length, rotation, type Rotation } from \"src/units\"\nimport { layer_ref, type LayerRef } from \"./properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport { brep_shape, type BRepShape } from \"./properties/brep\"\n\n// Common properties base for all pour shapes (internal)\nconst pcb_copper_pour_base = z.object({\n type: z.literal(\"pcb_copper_pour\"),\n pcb_copper_pour_id: getZodPrefixedIdWithDefault(\"pcb_copper_pour\"),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: layer_ref,\n source_net_id: z.string().optional(),\n covered_with_solder_mask: z.boolean().optional().default(true),\n})\n\n// Rectangular Pour\nexport const pcb_copper_pour_rect = pcb_copper_pour_base.extend({\n shape: z.literal(\"rect\"),\n center: point,\n width: length,\n height: length,\n rotation: rotation.optional(),\n})\nexport type PcbCopperPourRectInput = z.input<typeof pcb_copper_pour_rect>\ntype InferredPcbCopperPourRect = z.infer<typeof pcb_copper_pour_rect>\n/**\n * Defines a rectangular copper pour on the PCB.\n */\nexport interface PcbCopperPourRect {\n type: \"pcb_copper_pour\"\n pcb_copper_pour_id: string\n covered_with_solder_mask: boolean\n pcb_group_id?: string\n subcircuit_id?: string\n layer: LayerRef\n source_net_id?: string\n shape: \"rect\"\n center: Point\n width: Length\n height: Length\n rotation?: Rotation\n}\nexpectTypesMatch<PcbCopperPourRect, InferredPcbCopperPourRect>(true)\n\n// BRep Pour\nexport const pcb_copper_pour_brep = pcb_copper_pour_base.extend({\n shape: z.literal(\"brep\"),\n brep_shape: brep_shape,\n})\nexport type PcbCopperPourBRepInput = z.input<typeof pcb_copper_pour_brep>\ntype InferredPcbCopperPourBRep = z.infer<typeof pcb_copper_pour_brep>\n/**\n * Defines a BRep copper pour on the PCB.\n */\nexport interface PcbCopperPourBRep {\n type: \"pcb_copper_pour\"\n pcb_copper_pour_id: string\n covered_with_solder_mask: boolean\n pcb_group_id?: string\n subcircuit_id?: string\n layer: LayerRef\n source_net_id?: string\n shape: \"brep\"\n brep_shape: BRepShape\n}\nexpectTypesMatch<PcbCopperPourBRep, InferredPcbCopperPourBRep>(true)\n\n// Polygon Pour\nexport const pcb_copper_pour_polygon = pcb_copper_pour_base.extend({\n shape: z.literal(\"polygon\"),\n points: z.array(point),\n})\nexport type PcbCopperPourPolygonInput = z.input<typeof pcb_copper_pour_polygon>\ntype InferredPcbCopperPourPolygon = z.infer<typeof pcb_copper_pour_polygon>\n/**\n * Defines a polygonal copper pour on the PCB, specified by a list of points.\n * The polygon should be closed (the last point implicitly connects to the first).\n */\nexport interface PcbCopperPourPolygon {\n type: \"pcb_copper_pour\"\n pcb_copper_pour_id: string\n covered_with_solder_mask: boolean\n pcb_group_id?: string\n subcircuit_id?: string\n layer: LayerRef\n source_net_id?: string\n shape: \"polygon\"\n points: Point[]\n}\nexpectTypesMatch<PcbCopperPourPolygon, InferredPcbCopperPourPolygon>(true)\n\n// Union of all pour shapes\nexport const pcb_copper_pour = z\n .discriminatedUnion(\"shape\", [\n pcb_copper_pour_rect,\n pcb_copper_pour_brep,\n pcb_copper_pour_polygon,\n ])\n .describe(\"Defines a copper pour on the PCB.\")\n\nexport type PcbCopperPourInput = z.input<typeof pcb_copper_pour>\nexport type PcbCopperPour =\n | PcbCopperPourRect\n | PcbCopperPourBRep\n | PcbCopperPourPolygon\n\ntype InferredPcbCopperPour = z.infer<typeof pcb_copper_pour>\nexpectTypesMatch<PcbCopperPour, InferredPcbCopperPour>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { point, type Point } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_component_outside_board_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_component_outside_board_error\"),\n pcb_component_outside_board_error_id: getZodPrefixedIdWithDefault(\n \"pcb_component_outside_board_error\",\n ),\n error_type: z\n .literal(\"pcb_component_outside_board_error\")\n .default(\"pcb_component_outside_board_error\"),\n pcb_component_id: z.string(),\n pcb_board_id: z.string(),\n component_center: point,\n component_bounds: z.object({\n min_x: z.number(),\n max_x: z.number(),\n min_y: z.number(),\n max_y: z.number(),\n }),\n subcircuit_id: z.string().optional(),\n source_component_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when a PCB component is placed outside the board boundaries\",\n )\n\nexport type PcbComponentOutsideBoardErrorInput = z.input<\n typeof pcb_component_outside_board_error\n>\ntype InferredPcbComponentOutsideBoardError = z.infer<\n typeof pcb_component_outside_board_error\n>\n\n/** Error emitted when a PCB component is placed outside the board boundaries */\nexport interface PcbComponentOutsideBoardError extends BaseCircuitJsonError {\n type: \"pcb_component_outside_board_error\"\n pcb_component_outside_board_error_id: string\n error_type: \"pcb_component_outside_board_error\"\n pcb_component_id: string\n pcb_board_id: string\n component_center: Point\n component_bounds: {\n min_x: number\n max_x: number\n min_y: number\n max_y: number\n }\n subcircuit_id?: string\n source_component_id?: string\n}\n\nexpectTypesMatch<\n PcbComponentOutsideBoardError,\n InferredPcbComponentOutsideBoardError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault, point, type Point } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_component_not_on_board_edge_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_component_not_on_board_edge_error\"),\n pcb_component_not_on_board_edge_error_id: getZodPrefixedIdWithDefault(\n \"pcb_component_not_on_board_edge_error\",\n ),\n error_type: z\n .literal(\"pcb_component_not_on_board_edge_error\")\n .default(\"pcb_component_not_on_board_edge_error\"),\n pcb_component_id: z.string(),\n pcb_board_id: z.string(),\n component_center: point,\n pad_to_nearest_board_edge_distance: z.number(),\n source_component_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when a component that must be placed on the board edge is centered away from the edge\",\n )\n\nexport type PcbComponentNotOnBoardEdgeErrorInput = z.input<\n typeof pcb_component_not_on_board_edge_error\n>\ntype InferredPcbComponentNotOnBoardEdgeError = z.infer<\n typeof pcb_component_not_on_board_edge_error\n>\n\n/** Error emitted when a component that must be placed on the board edge is centered away from the edge */\nexport interface PcbComponentNotOnBoardEdgeError extends BaseCircuitJsonError {\n type: \"pcb_component_not_on_board_edge_error\"\n pcb_component_not_on_board_edge_error_id: string\n error_type: \"pcb_component_not_on_board_edge_error\"\n pcb_component_id: string\n pcb_board_id: string\n component_center: Point\n pad_to_nearest_board_edge_distance: number\n source_component_id?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n PcbComponentNotOnBoardEdgeError,\n InferredPcbComponentNotOnBoardEdgeError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { layer_ref, type LayerRef } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_component_invalid_layer_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_component_invalid_layer_error\"),\n pcb_component_invalid_layer_error_id: getZodPrefixedIdWithDefault(\n \"pcb_component_invalid_layer_error\",\n ),\n error_type: z\n .literal(\"pcb_component_invalid_layer_error\")\n .default(\"pcb_component_invalid_layer_error\"),\n pcb_component_id: z.string().optional(),\n source_component_id: z.string(),\n layer: layer_ref,\n subcircuit_id: z.string().optional(),\n })\n .describe(\n \"Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)\",\n )\n\nexport type PcbComponentInvalidLayerErrorInput = z.input<\n typeof pcb_component_invalid_layer_error\n>\ntype InferredPcbComponentInvalidLayerError = z.infer<\n typeof pcb_component_invalid_layer_error\n>\n\n/** Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers) */\nexport interface PcbComponentInvalidLayerError extends BaseCircuitJsonError {\n type: \"pcb_component_invalid_layer_error\"\n pcb_component_invalid_layer_error_id: string\n error_type: \"pcb_component_invalid_layer_error\"\n pcb_component_id?: string\n source_component_id: string\n layer: LayerRef\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n PcbComponentInvalidLayerError,\n InferredPcbComponentInvalidLayerError\n>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { distance, type Distance } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_via_clearance_error = base_circuit_json_error\n .extend({\n type: z.literal(\"pcb_via_clearance_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_error\"),\n error_type: z\n .literal(\"pcb_via_clearance_error\")\n .default(\"pcb_via_clearance_error\"),\n pcb_via_ids: z.array(z.string()).min(2),\n minimum_clearance: distance.optional(),\n actual_clearance: distance.optional(),\n pcb_center: z\n .object({\n x: z.number().optional(),\n y: z.number().optional(),\n })\n .optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"Error emitted when vias are closer than the allowed clearance\")\n\nexport type PcbViaClearanceErrorInput = z.input<typeof pcb_via_clearance_error>\ntype InferredPcbViaClearanceError = z.infer<typeof pcb_via_clearance_error>\n\n/** Error emitted when vias are closer than the allowed clearance */\nexport interface PcbViaClearanceError extends BaseCircuitJsonError {\n type: \"pcb_via_clearance_error\"\n pcb_error_id: string\n error_type: \"pcb_via_clearance_error\"\n pcb_via_ids: string[]\n minimum_clearance?: Distance\n actual_clearance?: Distance\n pcb_center?: {\n x?: number\n y?: number\n }\n subcircuit_id?: string\n}\n\nexpectTypesMatch<PcbViaClearanceError, InferredPcbViaClearanceError>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length, rotation, type Rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_courtyard_rect = z\n .object({\n type: z.literal(\"pcb_courtyard_rect\"),\n pcb_courtyard_rect_id: getZodPrefixedIdWithDefault(\"pcb_courtyard_rect\"),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n width: length,\n height: length,\n layer: visible_layer,\n ccw_rotation: rotation.optional(),\n color: z.string().optional(),\n })\n .describe(\"Defines a courtyard rectangle on the PCB\")\n\nexport type PcbCourtyardRectInput = z.input<typeof pcb_courtyard_rect>\ntype InferredPcbCourtyardRect = z.infer<typeof pcb_courtyard_rect>\n\n/**\n * Defines a courtyard rectangle on the PCB\n */\nexport interface PcbCourtyardRect {\n type: \"pcb_courtyard_rect\"\n pcb_courtyard_rect_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n width: Length\n height: Length\n layer: VisibleLayer\n ccw_rotation?: Rotation\n color?: string\n}\n\n/**\n * @deprecated use PcbCourtyardRect\n */\nexport type PCBCourtyardRect = PcbCourtyardRect\n\nexpectTypesMatch<PcbCourtyardRect, InferredPcbCourtyardRect>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_courtyard_outline = z\n .object({\n type: z.literal(\"pcb_courtyard_outline\"),\n pcb_courtyard_outline_id: getZodPrefixedIdWithDefault(\n \"pcb_courtyard_outline\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: visible_layer,\n outline: z.array(point).min(2),\n })\n .describe(\"Defines a courtyard outline on the PCB\")\n\nexport type PcbCourtyardOutlineInput = z.input<typeof pcb_courtyard_outline>\ntype InferredPcbCourtyardOutline = z.infer<typeof pcb_courtyard_outline>\n\n/**\n * Defines a courtyard outline on the PCB\n */\nexport interface PcbCourtyardOutline {\n type: \"pcb_courtyard_outline\"\n pcb_courtyard_outline_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n layer: VisibleLayer\n outline: Point[]\n}\n\n/**\n * @deprecated use PcbCourtyardOutline\n */\nexport type PCBCourtyardOutline = PcbCourtyardOutline\n\nexpectTypesMatch<PcbCourtyardOutline, InferredPcbCourtyardOutline>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_courtyard_polygon = z\n .object({\n type: z.literal(\"pcb_courtyard_polygon\"),\n pcb_courtyard_polygon_id: getZodPrefixedIdWithDefault(\n \"pcb_courtyard_polygon\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n layer: visible_layer,\n points: z.array(point).min(3),\n color: z.string().optional(),\n })\n .describe(\"Defines a courtyard polygon on the PCB\")\n\nexport type PcbCourtyardPolygonInput = z.input<typeof pcb_courtyard_polygon>\ntype InferredPcbCourtyardPolygon = z.infer<typeof pcb_courtyard_polygon>\n\n/**\n * Defines a courtyard polygon on the PCB\n */\nexport interface PcbCourtyardPolygon {\n type: \"pcb_courtyard_polygon\"\n pcb_courtyard_polygon_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n layer: VisibleLayer\n points: Point[]\n color?: string\n}\n\n/**\n * @deprecated use PcbCourtyardPolygon\n */\nexport type PCBCourtyardPolygon = PcbCourtyardPolygon\n\nexpectTypesMatch<PcbCourtyardPolygon, InferredPcbCourtyardPolygon>(true)\n","import { z } from \"zod\"\nimport { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { visible_layer, type VisibleLayer } from \"src/pcb/properties/layer_ref\"\nimport { length, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_courtyard_circle = z\n .object({\n type: z.literal(\"pcb_courtyard_circle\"),\n pcb_courtyard_circle_id: getZodPrefixedIdWithDefault(\n \"pcb_courtyard_circle\",\n ),\n pcb_component_id: z.string(),\n pcb_group_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n center: point,\n radius: length,\n layer: visible_layer,\n color: z.string().optional(),\n })\n .describe(\"Defines a courtyard circle on the PCB\")\n\nexport type PcbCourtyardCircleInput = z.input<typeof pcb_courtyard_circle>\ntype InferredPcbCourtyardCircle = z.infer<typeof pcb_courtyard_circle>\n\n/**\n * Defines a courtyard circle on the PCB\n */\nexport interface PcbCourtyardCircle {\n type: \"pcb_courtyard_circle\"\n pcb_courtyard_circle_id: string\n pcb_component_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n center: Point\n radius: Length\n layer: VisibleLayer\n color?: string\n}\n\nexpectTypesMatch<PcbCourtyardCircle, InferredPcbCourtyardCircle>(true)\n","import { z } from \"zod\"\nimport { point3, asset, type Point3, type Asset } from \"../common\"\nimport { rotation, length, type Rotation, type Length } from \"../units\"\nimport { layer_ref, type LayerRef } from \"src/pcb\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n cad_model_axis_directions,\n type CadModelAxisDirection,\n} from \"./cad_model_conventions\"\n\nexport const cad_component = z\n .object({\n type: z.literal(\"cad_component\"),\n cad_component_id: z.string(),\n pcb_component_id: z.string(),\n source_component_id: z.string(),\n position: point3,\n rotation: point3.optional(),\n size: point3.optional(),\n layer: layer_ref.optional(),\n subcircuit_id: z.string().optional(),\n\n // These are all ways to generate/load the 3d model\n footprinter_string: z.string().optional(),\n model_obj_url: z.string().optional(),\n model_stl_url: z.string().optional(),\n model_3mf_url: z.string().optional(),\n model_gltf_url: z.string().optional(),\n model_glb_url: z.string().optional(),\n model_step_url: z.string().optional(),\n model_wrl_url: z.string().optional(),\n model_asset: asset.optional(),\n model_unit_to_mm_scale_factor: z.number().optional(),\n model_board_normal_direction: z\n .enum(cad_model_axis_directions)\n .optional()\n .describe(\n 'The direction in the model\\'s coordinate space that is considered \"up\" or \"coming out of the board surface\"',\n ),\n model_origin_position: point3.optional(),\n model_origin_alignment: z\n .enum([\n \"unknown\",\n \"center\",\n \"center_of_component_on_board_surface\",\n \"bottom_center_of_component\",\n ] as const)\n .optional(),\n model_object_fit: z\n .enum([\"contain_within_bounds\", \"fill_bounds\"] as const)\n .optional()\n .default(\"contain_within_bounds\"),\n model_jscad: z.any().optional(),\n show_as_translucent_model: z.boolean().optional(),\n anchor_alignment: z\n .enum([\"center\", \"center_of_component_on_board_surface\"] as const)\n .optional()\n .default(\"center\"),\n })\n .describe(\"Defines a component on the PCB\")\n\nexport type CadComponentInput = z.input<typeof cad_component>\ntype InferredCadComponent = z.infer<typeof cad_component>\n\nexport type CadComponentAnchorAlignment = NonNullable<\n InferredCadComponent[\"anchor_alignment\"]\n>\n\nexport interface CadComponent {\n type: \"cad_component\"\n cad_component_id: string\n pcb_component_id: string\n source_component_id: string\n position: Point3\n rotation?: Point3\n size?: Point3\n layer?: LayerRef\n subcircuit_id?: string\n footprinter_string?: string\n model_obj_url?: string\n model_stl_url?: string\n model_3mf_url?: string\n model_gltf_url?: string\n model_glb_url?: string\n model_step_url?: string\n model_wrl_url?: string\n model_asset?: Asset\n model_unit_to_mm_scale_factor?: number\n model_board_normal_direction?: CadModelAxisDirection\n model_origin_position?: Point3\n model_origin_alignment?:\n | \"unknown\"\n | \"center\"\n | \"center_of_component_on_board_surface\"\n | \"bottom_center_of_component\"\n model_object_fit: \"contain_within_bounds\" | \"fill_bounds\"\n model_jscad?: any\n show_as_translucent_model?: boolean\n anchor_alignment: CadComponentAnchorAlignment\n}\n\nexpectTypesMatch<CadComponent, InferredCadComponent>(true)\n","export const cad_model_formats = [\n \"obj\",\n \"stl\",\n \"3mf\",\n \"gltf\",\n \"glb\",\n \"step\",\n \"wrl\",\n] as const\n\nexport const cad_model_axis_directions = [\n \"x+\",\n \"x-\",\n \"y+\",\n \"y-\",\n \"z+\",\n \"z-\",\n] as const\n\nexport type CadModelFormat = (typeof cad_model_formats)[number]\nexport type CadModelAxisDirection = (typeof cad_model_axis_directions)[number]\n\nexport const cadModelDefaultDirectionMap = {\n obj: \"z+\",\n stl: \"z+\",\n \"3mf\": \"z+\",\n gltf: \"y+\",\n glb: \"y+\",\n step: \"z+\",\n wrl: \"y+\",\n} as const\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { frequency, rotation, voltage } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const wave_shape = z.enum([\"sinewave\", \"square\", \"triangle\", \"sawtooth\"])\nexport type WaveShape = z.infer<typeof wave_shape>\n\nconst percentage = z\n .union([z.string(), z.number()])\n .transform((val) => {\n if (typeof val === \"string\") {\n if (val.endsWith(\"%\")) {\n return parseFloat(val.slice(0, -1)) / 100\n }\n return parseFloat(val)\n }\n return val\n })\n .pipe(\n z\n .number()\n .min(0, \"Duty cycle must be non-negative\")\n .max(1, \"Duty cycle cannot be greater than 100%\"),\n )\n\nexport const simulation_dc_voltage_source = z\n .object({\n type: z.literal(\"simulation_voltage_source\"),\n simulation_voltage_source_id: getZodPrefixedIdWithDefault(\n \"simulation_voltage_source\",\n ),\n is_dc_source: z.literal(true).optional().default(true),\n positive_source_port_id: z.string().optional(),\n negative_source_port_id: z.string().optional(),\n positive_source_net_id: z.string().optional(),\n negative_source_net_id: z.string().optional(),\n voltage: voltage,\n })\n .describe(\"Defines a DC voltage source for simulation\")\n\nexport const simulation_ac_voltage_source = z\n .object({\n type: z.literal(\"simulation_voltage_source\"),\n simulation_voltage_source_id: getZodPrefixedIdWithDefault(\n \"simulation_voltage_source\",\n ),\n is_dc_source: z.literal(false),\n terminal1_source_port_id: z.string().optional(),\n terminal2_source_port_id: z.string().optional(),\n terminal1_source_net_id: z.string().optional(),\n terminal2_source_net_id: z.string().optional(),\n voltage: voltage.optional(),\n frequency: frequency.optional(),\n peak_to_peak_voltage: voltage.optional(),\n wave_shape: wave_shape.optional(),\n phase: rotation.optional(),\n duty_cycle: percentage.optional(),\n })\n .describe(\"Defines an AC voltage source for simulation\")\n\nexport type SimulationAcVoltageSourceInput = z.input<\n typeof simulation_ac_voltage_source\n>\n\nexport const simulation_voltage_source = z\n .union([simulation_dc_voltage_source, simulation_ac_voltage_source])\n .describe(\"Defines a voltage source for simulation\")\n\nexport type SimulationVoltageSourceInput = z.input<\n typeof simulation_voltage_source\n>\ntype InferredSimulationVoltageSource = z.infer<typeof simulation_voltage_source>\n\n/**\n * Defines a DC voltage source for simulation purposes. It applies a voltage\n * difference between two source ports.\n */\nexport interface SimulationDcVoltageSource {\n type: \"simulation_voltage_source\"\n simulation_voltage_source_id: string\n is_dc_source: true\n positive_source_port_id?: string\n positive_source_net_id?: string\n negative_source_port_id?: string\n negative_source_net_id?: string\n voltage: number\n}\n\n/**\n * Defines an AC voltage source for simulation purposes.\n */\nexport interface SimulationAcVoltageSource {\n type: \"simulation_voltage_source\"\n simulation_voltage_source_id: string\n is_dc_source: false\n terminal1_source_port_id?: string\n terminal2_source_port_id?: string\n terminal1_source_net_id?: string\n terminal2_source_net_id?: string\n voltage?: number\n frequency?: number\n peak_to_peak_voltage?: number\n wave_shape?: WaveShape\n phase?: number\n duty_cycle?: number\n}\n\nexport type SimulationVoltageSource =\n | SimulationDcVoltageSource\n | SimulationAcVoltageSource\n\nexpectTypesMatch<\n SimulationDcVoltageSource,\n z.infer<typeof simulation_dc_voltage_source>\n>(true)\nexpectTypesMatch<\n SimulationAcVoltageSource,\n z.infer<typeof simulation_ac_voltage_source>\n>(true)\nexpectTypesMatch<SimulationVoltageSource, InferredSimulationVoltageSource>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { current, frequency, rotation } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport {\n wave_shape,\n type WaveShape,\n} from \"src/simulation/simulation_voltage_source\"\n\nconst percentage = z\n .union([z.string(), z.number()])\n .transform((val) => {\n if (typeof val === \"string\") {\n if (val.endsWith(\"%\")) {\n return parseFloat(val.slice(0, -1)) / 100\n }\n return parseFloat(val)\n }\n return val\n })\n .pipe(\n z\n .number()\n .min(0, \"Duty cycle must be non-negative\")\n .max(1, \"Duty cycle cannot be greater than 100%\"),\n )\n\nexport const simulation_dc_current_source = z\n .object({\n type: z.literal(\"simulation_current_source\"),\n simulation_current_source_id: getZodPrefixedIdWithDefault(\n \"simulation_current_source\",\n ),\n is_dc_source: z.literal(true).optional().default(true),\n positive_source_port_id: z.string().optional(),\n negative_source_port_id: z.string().optional(),\n positive_source_net_id: z.string().optional(),\n negative_source_net_id: z.string().optional(),\n current: current,\n })\n .describe(\"Defines a DC current source for simulation\")\n\nexport const simulation_ac_current_source = z\n .object({\n type: z.literal(\"simulation_current_source\"),\n simulation_current_source_id: getZodPrefixedIdWithDefault(\n \"simulation_current_source\",\n ),\n is_dc_source: z.literal(false),\n terminal1_source_port_id: z.string().optional(),\n terminal2_source_port_id: z.string().optional(),\n terminal1_source_net_id: z.string().optional(),\n terminal2_source_net_id: z.string().optional(),\n current: current.optional(),\n frequency: frequency.optional(),\n peak_to_peak_current: current.optional(),\n wave_shape: wave_shape.optional(),\n phase: rotation.optional(),\n duty_cycle: percentage.optional(),\n })\n .describe(\"Defines an AC current source for simulation\")\n\nexport type SimulationAcCurrentSourceInput = z.input<\n typeof simulation_ac_current_source\n>\n\nexport const simulation_current_source = z\n .union([simulation_dc_current_source, simulation_ac_current_source])\n .describe(\"Defines a current source for simulation\")\n\nexport type SimulationCurrentSourceInput = z.input<\n typeof simulation_current_source\n>\ntype InferredSimulationCurrentSource = z.infer<typeof simulation_current_source>\n\n/**\n * Defines a DC current source for simulation purposes. It forces a current\n * between two source ports.\n */\nexport interface SimulationDcCurrentSource {\n type: \"simulation_current_source\"\n simulation_current_source_id: string\n is_dc_source: true\n positive_source_port_id?: string\n positive_source_net_id?: string\n negative_source_port_id?: string\n negative_source_net_id?: string\n current: number\n}\n\n/**\n * Defines an AC current source for simulation purposes.\n */\nexport interface SimulationAcCurrentSource {\n type: \"simulation_current_source\"\n simulation_current_source_id: string\n is_dc_source: false\n terminal1_source_port_id?: string\n terminal2_source_port_id?: string\n terminal1_source_net_id?: string\n terminal2_source_net_id?: string\n current?: number\n frequency?: number\n peak_to_peak_current?: number\n wave_shape?: WaveShape\n phase?: number\n duty_cycle?: number\n}\n\nexport type SimulationCurrentSource =\n | SimulationDcCurrentSource\n | SimulationAcCurrentSource\n\nexpectTypesMatch<\n SimulationDcCurrentSource,\n z.infer<typeof simulation_dc_current_source>\n>(true)\nexpectTypesMatch<\n SimulationAcCurrentSource,\n z.infer<typeof simulation_ac_current_source>\n>(true)\nexpectTypesMatch<SimulationCurrentSource, InferredSimulationCurrentSource>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { duration_ms, ms } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const experiment_type = z.union([\n z.literal(\"spice_dc_sweep\"),\n z.literal(\"spice_dc_operating_point\"),\n z.literal(\"spice_transient_analysis\"),\n z.literal(\"spice_ac_analysis\"),\n])\n\nexport type ExperimentType = z.infer<typeof experiment_type>\n\nexport interface SimulationExperiment {\n type: \"simulation_experiment\"\n simulation_experiment_id: string\n name: string\n experiment_type: ExperimentType\n time_per_step?: number // ms\n start_time_ms?: number // ms\n end_time_ms?: number // ms\n}\n\nexport const simulation_experiment = z\n .object({\n type: z.literal(\"simulation_experiment\"),\n simulation_experiment_id: getZodPrefixedIdWithDefault(\n \"simulation_experiment\",\n ),\n name: z.string(),\n experiment_type,\n time_per_step: duration_ms.optional(),\n start_time_ms: ms.optional(),\n end_time_ms: ms.optional(),\n })\n .describe(\"Defines a simulation experiment configuration\")\n\nexport type SimulationExperimentInput = z.input<typeof simulation_experiment>\ntype InferredSimulationExperiment = z.infer<typeof simulation_experiment>\n\nexpectTypesMatch<SimulationExperiment, InferredSimulationExperiment>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { duration_ms, ms } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SimulationTransientVoltageGraph {\n type: \"simulation_transient_voltage_graph\"\n simulation_transient_voltage_graph_id: string\n simulation_experiment_id: string\n timestamps_ms?: number[]\n voltage_levels: number[]\n source_component_id?: string\n subcircuit_connectivity_map_key?: string\n time_per_step: number\n start_time_ms: number\n end_time_ms: number\n name?: string\n color?: string\n}\n\nexport const simulation_transient_voltage_graph = z\n .object({\n type: z.literal(\"simulation_transient_voltage_graph\"),\n simulation_transient_voltage_graph_id: getZodPrefixedIdWithDefault(\n \"simulation_transient_voltage_graph\",\n ),\n simulation_experiment_id: z.string(),\n timestamps_ms: z.array(z.number()).optional(),\n voltage_levels: z.array(z.number()),\n source_component_id: z.string().optional(),\n subcircuit_connectivity_map_key: z.string().optional(),\n time_per_step: duration_ms,\n start_time_ms: ms,\n end_time_ms: ms,\n name: z.string().optional(),\n color: z.string().optional(),\n })\n .describe(\"Stores voltage measurements over time for a simulation\")\n\nexport type SimulationTransientVoltageGraphInput = z.input<\n typeof simulation_transient_voltage_graph\n>\ntype InferredSimulationTransientVoltageGraph = z.infer<\n typeof simulation_transient_voltage_graph\n>\n\nexpectTypesMatch<\n SimulationTransientVoltageGraph,\n InferredSimulationTransientVoltageGraph\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { frequency, ms } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const simulation_switch = z\n .object({\n type: z.literal(\"simulation_switch\"),\n simulation_switch_id: getZodPrefixedIdWithDefault(\"simulation_switch\"),\n source_component_id: z.string().optional(),\n closes_at: ms.optional(),\n opens_at: ms.optional(),\n starts_closed: z.boolean().optional(),\n switching_frequency: frequency.optional(),\n })\n .describe(\"Defines a switch for simulation timing control\")\n\nexport type SimulationSwitchInput = z.input<typeof simulation_switch>\n\ntype InferredSimulationSwitch = z.infer<typeof simulation_switch>\n\nexport interface SimulationSwitch {\n type: \"simulation_switch\"\n simulation_switch_id: string\n source_component_id?: string\n closes_at?: number\n opens_at?: number\n starts_closed?: boolean\n switching_frequency?: number\n}\n\nexpectTypesMatch<SimulationSwitch, InferredSimulationSwitch>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const simulation_voltage_probe = z\n .object({\n type: z.literal(\"simulation_voltage_probe\"),\n simulation_voltage_probe_id: getZodPrefixedIdWithDefault(\n \"simulation_voltage_probe\",\n ),\n source_component_id: z.string().optional(),\n name: z.string().optional(),\n signal_input_source_port_id: z.string().optional(),\n signal_input_source_net_id: z.string().optional(),\n reference_input_source_port_id: z.string().optional(),\n reference_input_source_net_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n color: z.string().optional(),\n })\n .describe(\n \"Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.\",\n )\n .superRefine((data, ctx) => {\n const is_differential =\n data.reference_input_source_port_id || data.reference_input_source_net_id\n\n if (is_differential) {\n const has_ports =\n !!data.signal_input_source_port_id ||\n !!data.reference_input_source_port_id\n const has_nets =\n !!data.signal_input_source_net_id ||\n !!data.reference_input_source_net_id\n\n if (has_ports && has_nets) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message:\n \"Cannot mix port and net connections in a differential probe.\",\n })\n } else if (has_ports) {\n if (\n !data.signal_input_source_port_id ||\n !data.reference_input_source_port_id\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message:\n \"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id.\",\n })\n }\n } else if (has_nets) {\n if (\n !data.signal_input_source_net_id ||\n !data.reference_input_source_net_id\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message:\n \"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id.\",\n })\n }\n }\n } else {\n // Single-ended probe\n if (\n !!data.signal_input_source_port_id === !!data.signal_input_source_net_id\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message:\n \"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id.\",\n })\n }\n }\n })\n\nexport type SimulationVoltageProbeInput = z.input<\n typeof simulation_voltage_probe\n>\ntype InferredSimulationVoltageProbe = z.infer<typeof simulation_voltage_probe>\n\n/**\n * Defines a voltage probe for simulation. If a reference input is not provided,\n * it measures against ground. If a reference input is provided, it measures\n * the differential voltage between two points.\n */\nexport interface SimulationVoltageProbe {\n type: \"simulation_voltage_probe\"\n simulation_voltage_probe_id: string\n source_component_id?: string\n name?: string\n signal_input_source_port_id?: string\n signal_input_source_net_id?: string\n reference_input_source_port_id?: string\n reference_input_source_net_id?: string\n subcircuit_id?: string\n color?: string\n}\n\nexpectTypesMatch<SimulationVoltageProbe, InferredSimulationVoltageProbe>(true)\n","import { z } from \"zod\"\nimport {\n base_circuit_json_error,\n type BaseCircuitJsonError,\n} from \"src/base_circuit_json_error\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const simulation_unknown_experiment_error = base_circuit_json_error\n .extend({\n type: z.literal(\"simulation_unknown_experiment_error\"),\n simulation_unknown_experiment_error_id: getZodPrefixedIdWithDefault(\n \"simulation_unknown_experiment_error\",\n ),\n error_type: z\n .literal(\"simulation_unknown_experiment_error\")\n .default(\"simulation_unknown_experiment_error\"),\n simulation_experiment_id: z.string().optional(),\n subcircuit_id: z.string().optional(),\n })\n .describe(\"An unknown error occurred during the simulation experiment.\")\n\nexport type SimulationUnknownExperimentErrorInput = z.input<\n typeof simulation_unknown_experiment_error\n>\ntype InferredSimulationUnknownExperimentError = z.infer<\n typeof simulation_unknown_experiment_error\n>\n\n/**\n * An unknown error occurred during the simulation experiment.\n */\nexport interface SimulationUnknownExperimentError extends BaseCircuitJsonError {\n type: \"simulation_unknown_experiment_error\"\n simulation_unknown_experiment_error_id: string\n error_type: \"simulation_unknown_experiment_error\"\n simulation_experiment_id?: string\n subcircuit_id?: string\n}\n\nexpectTypesMatch<\n SimulationUnknownExperimentError,\n InferredSimulationUnknownExperimentError\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const simulation_op_amp = z\n .object({\n type: z.literal(\"simulation_op_amp\"),\n simulation_op_amp_id: getZodPrefixedIdWithDefault(\"simulation_op_amp\"),\n source_component_id: z.string().optional(),\n inverting_input_source_port_id: z.string(),\n non_inverting_input_source_port_id: z.string(),\n output_source_port_id: z.string(),\n positive_supply_source_port_id: z.string(),\n negative_supply_source_port_id: z.string(),\n })\n .describe(\"Defines a simple ideal operational amplifier for simulation\")\n\nexport type SimulationOpAmpInput = z.input<typeof simulation_op_amp>\ntype InferredSimulationOpAmp = z.infer<typeof simulation_op_amp>\n\n/**\n * Defines a simple ideal operational amplifier for simulation.\n */\nexport interface SimulationOpAmp {\n type: \"simulation_op_amp\"\n simulation_op_amp_id: string\n source_component_id?: string\n inverting_input_source_port_id: string\n non_inverting_input_source_port_id: string\n output_source_port_id: string\n positive_supply_source_port_id: string\n negative_supply_source_port_id: string\n}\n\nexpectTypesMatch<SimulationOpAmp, InferredSimulationOpAmp>(true)\n","import { z } from \"zod\"\nimport * as pcb from \"./pcb\"\nimport * as sch from \"./schematic\"\nimport * as src from \"./source\"\nimport * as cad from \"./cad\"\nimport * as sim from \"./simulation\"\nimport {\n expectStringUnionsMatch,\n expectTypesMatch,\n} from \"./utils/expect-types-match\"\n\nexport const any_circuit_element = z.union([\n // TODO source_config\n // TODO pcb_config\n // TODO schematic_config\n // TODO schematic_group\n src.source_trace,\n src.source_port,\n src.source_component_internal_connection,\n src.any_source_component,\n src.source_net,\n src.source_group,\n src.source_simple_chip,\n src.source_simple_capacitor,\n src.source_simple_diode,\n src.source_simple_led,\n src.source_simple_resistor,\n src.source_simple_power_source,\n src.source_simple_battery,\n src.source_simple_inductor,\n src.source_simple_pin_header,\n src.source_simple_pinout,\n src.source_simple_resonator,\n src.source_simple_switch,\n src.source_simple_transistor,\n src.source_simple_test_point,\n src.source_simple_mosfet,\n src.source_simple_op_amp,\n src.source_simple_potentiometer,\n src.source_simple_push_button,\n src.source_pcb_ground_plane,\n src.source_manually_placed_via,\n src.source_board,\n src.source_project_metadata,\n src.source_invalid_component_property_error,\n src.source_trace_not_connected_error,\n src.source_pin_missing_trace_warning,\n src.source_no_power_pin_defined_warning,\n src.source_no_ground_pin_defined_warning,\n src.source_component_pins_underspecified_warning,\n src.source_pin_must_be_connected_error,\n src.unknown_error_finding_part,\n src.source_i2c_misconfigured_error,\n src.source_ambiguous_port_reference,\n pcb.pcb_component,\n pcb.pcb_hole,\n pcb.pcb_missing_footprint_error,\n pcb.external_footprint_load_error,\n pcb.circuit_json_footprint_load_error,\n pcb.pcb_manual_edit_conflict_warning,\n pcb.pcb_connector_not_in_accessible_orientation_warning,\n pcb.pcb_plated_hole,\n pcb.pcb_keepout,\n pcb.pcb_port,\n pcb.pcb_net,\n pcb.pcb_text,\n pcb.pcb_trace,\n pcb.pcb_via,\n pcb.pcb_smtpad,\n pcb.pcb_solder_paste,\n pcb.pcb_board,\n pcb.pcb_panel,\n pcb.pcb_group,\n pcb.pcb_trace_hint,\n pcb.pcb_silkscreen_line,\n pcb.pcb_silkscreen_path,\n pcb.pcb_silkscreen_text,\n pcb.pcb_silkscreen_pill,\n pcb.pcb_copper_text,\n pcb.pcb_silkscreen_rect,\n pcb.pcb_silkscreen_circle,\n pcb.pcb_silkscreen_oval,\n pcb.pcb_trace_error,\n pcb.pcb_trace_missing_error,\n pcb.pcb_placement_error,\n pcb.pcb_panelization_placement_error,\n pcb.pcb_port_not_matched_error,\n pcb.pcb_port_not_connected_error,\n pcb.pcb_via_clearance_error,\n pcb.pcb_fabrication_note_path,\n pcb.pcb_fabrication_note_text,\n pcb.pcb_fabrication_note_rect,\n pcb.pcb_fabrication_note_dimension,\n pcb.pcb_note_text,\n pcb.pcb_note_rect,\n pcb.pcb_note_path,\n pcb.pcb_note_line,\n pcb.pcb_note_dimension,\n pcb.pcb_autorouting_error,\n pcb.pcb_footprint_overlap_error,\n pcb.pcb_courtyard_overlap_error,\n pcb.pcb_breakout_point,\n pcb.pcb_cutout,\n pcb.pcb_ground_plane,\n pcb.pcb_ground_plane_region,\n pcb.pcb_thermal_spoke,\n pcb.pcb_copper_pour,\n pcb.pcb_component_outside_board_error,\n pcb.pcb_component_not_on_board_edge_error,\n pcb.pcb_component_invalid_layer_error,\n pcb.pcb_courtyard_rect,\n pcb.pcb_courtyard_outline,\n pcb.pcb_courtyard_polygon,\n pcb.pcb_courtyard_circle,\n sch.schematic_box,\n sch.schematic_text,\n sch.schematic_line,\n sch.schematic_rect,\n sch.schematic_circle,\n sch.schematic_arc,\n sch.schematic_component,\n sch.schematic_symbol,\n sch.schematic_port,\n sch.schematic_trace,\n sch.schematic_path,\n sch.schematic_error,\n sch.schematic_layout_error,\n sch.schematic_net_label,\n sch.schematic_debug_object,\n sch.schematic_voltage_probe,\n sch.schematic_manual_edit_conflict_warning,\n sch.schematic_group,\n sch.schematic_sheet,\n sch.schematic_table,\n sch.schematic_table_cell,\n cad.cad_component,\n sim.simulation_voltage_source,\n sim.simulation_current_source,\n sim.simulation_experiment,\n sim.simulation_transient_voltage_graph,\n sim.simulation_switch,\n sim.simulation_voltage_probe,\n sim.simulation_unknown_experiment_error,\n sim.simulation_op_amp,\n])\n\n/**\n * @deprecated use any_circuit_element instead\n */\nexport const any_soup_element = any_circuit_element\n\nexport type AnyCircuitElement = z.infer<typeof any_circuit_element>\nexport type AnyCircuitElementInput = z.input<typeof any_circuit_element>\n/**\n * @deprecated use AnyCircuitElement instead\n */\nexport type AnySoupElement = AnyCircuitElement\n\n/**\n * @deprecated use AnyCircuitElementInput instead\n */\nexport type AnySoupElementInput = AnyCircuitElementInput\n\n/**\n * Type representing a complete Circuit JSON document, which is an array of circuit elements.\n * This is the primary type used when working with circuit-json files or API responses.\n */\nexport type CircuitJson = AnyCircuitElement[]\n\n// ------------------- SAFETY CHECKS -------------------\n\n// SAFETY CHECK: Every element has a type\nexpectTypesMatch<\n AnyCircuitElement extends { type: string } ? AnyCircuitElement : never,\n AnyCircuitElement\n>(true)\n\n// SAFETY CHECK: Every element has an id with the key name `${type}_id`\ntype FindMissingId<T extends AnyCircuitElement> = T extends {\n type: infer U extends string\n}\n ? T extends { [K in `${U}_id`]: infer V }\n ? V extends string\n ? never\n : `${U} DOES NOT HAVE AN ${U}_id PROPERTY`\n : `${U} DOES NOT HAVE AN ${U}_id PROPERTY`\n : never\n\nexpectStringUnionsMatch<\n FindMissingId<AnyCircuitElement>,\n // EXCEPTIONS TO THE RULE\n // THIS IS FOR LEGACY REASONS, DO NOT ADD MORE EXCEPTIONS\n | \"source_project_metadata DOES NOT HAVE AN source_project_metadata_id PROPERTY\"\n | \"pcb_port_not_matched_error DOES NOT HAVE AN pcb_port_not_matched_error_id PROPERTY\"\n | \"pcb_autorouting_error DOES NOT HAVE AN pcb_autorouting_error_id PROPERTY\"\n | \"pcb_footprint_overlap_error DOES NOT HAVE AN pcb_footprint_overlap_error_id PROPERTY\"\n | \"pcb_courtyard_overlap_error DOES NOT HAVE AN pcb_courtyard_overlap_error_id PROPERTY\"\n | \"pcb_via_clearance_error DOES NOT HAVE AN pcb_via_clearance_error_id PROPERTY\"\n | \"schematic_debug_object DOES NOT HAVE AN schematic_debug_object_id PROPERTY\"\n | \"schematic_box DOES NOT HAVE AN schematic_box_id PROPERTY\"\n>(true)\n","/**\n * Calculate a point transformed with an affine matrix\n * @param matrix {Matrix} Affine Matrix\n * @param point {Point} Point\n * @returns {Point} Point\n */\nexport function applyToPoint (matrix, point) {\n return Array.isArray(point)\n ? [\n matrix.a * point[0] + matrix.c * point[1] + matrix.e,\n matrix.b * point[0] + matrix.d * point[1] + matrix.f\n ]\n : {\n x: matrix.a * point.x + matrix.c * point.y + matrix.e,\n y: matrix.b * point.x + matrix.d * point.y + matrix.f\n }\n}\n\n/**\n * Calculate an array of points transformed with an affine matrix\n * @param matrix {Matrix} Affine Matrix\n * @param points {Point[]} Array of point\n * @returns {Point[]} Array of point\n */\nexport function applyToPoints (matrix, points) {\n return points.map(point => applyToPoint(matrix, point))\n}\n","export function isUndefined (val) {\n return typeof val === 'undefined'\n}\n\nexport function isNumeric (n) {\n return typeof n === 'number' &&\n !Number.isNaN(n) &&\n Number.isFinite(n)\n}\n\nexport function isObject (obj) {\n return typeof obj === 'object' &&\n obj !== null &&\n !Array.isArray(obj)\n}\n\nexport function matchesShape (obj, keys) {\n return keys.every(key => key in obj)\n}\n","/**\n * Calculate a translate matrix\n * @param tx {number} Translation on axis x\n * @param [ty = 0] {number} Translation on axis y\n * @returns {Matrix} Affine Matrix\n */\nexport function translate (tx, ty = 0) {\n return {\n a: 1,\n c: 0,\n e: tx,\n b: 0,\n d: 1,\n f: ty\n }\n}\n","/**\n * Merge multiple matrices into one\n * @param matrices {...Matrix | Matrix[]} Matrices listed as separate parameters or in an array\n * @returns {Matrix} Affine Matrix\n */\nexport function transform (...matrices) {\n matrices = Array.isArray(matrices[0]) ? matrices[0] : matrices\n\n const multiply = (m1, m2) => {\n return {\n a: m1.a * m2.a + m1.c * m2.b,\n c: m1.a * m2.c + m1.c * m2.d,\n e: m1.a * m2.e + m1.c * m2.f + m1.e,\n b: m1.b * m2.a + m1.d * m2.b,\n d: m1.b * m2.c + m1.d * m2.d,\n f: m1.b * m2.e + m1.d * m2.f + m1.f\n }\n }\n\n switch (matrices.length) {\n case 0:\n throw new Error('no matrices provided')\n\n case 1:\n return matrices[0]\n\n case 2:\n return multiply(matrices[0], matrices[1])\n\n default: {\n const [m1, m2, ...rest] = matrices\n const m = multiply(m1, m2)\n return transform(m, ...rest)\n }\n }\n}\n\n/**\n * Merge multiple matrices into one\n * @param matrices {...Matrix | Matrix[]} Matrices listed as separate parameters or in an array\n * @returns {Matrix} Affine Matrix\n */\nexport function compose (...matrices) {\n return transform(...matrices)\n}\n","import { isUndefined } from './utils'\nimport { translate } from './translate'\nimport { transform } from './transform'\n\nconst { cos, sin, PI } = Math\n/**\n * Calculate a rotation matrix\n * @param angle {number} Angle in radians\n * @param [cx] {number} If (cx,cy) are supplied the rotate is about this point\n * @param [cy] {number} If (cx,cy) are supplied the rotate is about this point\n * @returns {Matrix} Affine Matrix\n */\nexport function rotate (angle, cx, cy) {\n const cosAngle = cos(angle)\n const sinAngle = sin(angle)\n const rotationMatrix = {\n a: cosAngle,\n c: -sinAngle,\n e: 0,\n b: sinAngle,\n d: cosAngle,\n f: 0\n }\n if (isUndefined(cx) || isUndefined(cy)) {\n return rotationMatrix\n }\n\n return transform([\n translate(cx, cy),\n rotationMatrix,\n translate(-cx, -cy)\n ])\n}\n\n/**\n * Calculate a rotation matrix with a DEG angle\n * @param angle {number} Angle in degree\n * @param [cx] {number} If (cx,cy) are supplied the rotate is about this point\n * @param [cy] {number} If (cx,cy) are supplied the rotate is about this point\n * @returns {Matrix} Affine Matrix\n */\nexport function rotateDEG (angle, cx = undefined, cy = undefined) {\n return rotate(angle * PI / 180, cx, cy)\n}\n","import { isUndefined } from './utils'\nimport { translate } from './translate'\nimport { transform } from './transform'\n\n/**\n * Calculate a scaling matrix\n * @param sx {number} Scaling on axis x\n * @param [sy = sx] {number} Scaling on axis y (default sx)\n * @param [cx] {number} If (cx,cy) are supplied the scaling is about this point\n * @param [cy] {number} If (cx,cy) are supplied the scaling is about this point\n * @returns {Matrix} Affine Matrix\n */\nexport function scale (sx, sy = undefined, cx = undefined, cy = undefined) {\n if (isUndefined(sy)) sy = sx\n\n const scaleMatrix = {\n a: sx,\n c: 0,\n e: 0,\n b: 0,\n d: sy,\n f: 0\n }\n\n if (isUndefined(cx) || isUndefined(cy)) {\n return scaleMatrix\n }\n\n return transform([\n translate(cx, cy),\n scaleMatrix,\n translate(-cx, -cy)\n ])\n}\n","// https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew\nconst { tan } = Math\n\n/**\n * Calculate a skew matrix\n * @param ax {number} Skew on axis x\n * @param ay {number} Skew on axis y\n * @returns {Matrix} Affine Matrix\n */\nexport function skew (ax, ay) {\n return {\n a: 1,\n c: tan(ax),\n e: 0,\n b: tan(ay),\n d: 1,\n f: 0\n }\n}\n\n/**\n * Calculate a skew matrix using DEG angles\n * @param ax {number} Skew on axis x\n * @param ay {number} Skew on axis y\n * @returns {Matrix} Affine Matrix\n */\nexport function skewDEG (ax, ay) {\n return skew(ax * Math.PI / 180, ay * Math.PI / 180)\n}\n","// Generated by Peggy 3.0.2.\n//\n// https://peggyjs.org/\n\nfunction peg$subclass(child, parent) {\n function C() { this.constructor = child; }\n C.prototype = parent.prototype;\n child.prototype = new C();\n}\n\nfunction peg$SyntaxError(message, expected, found, location) {\n var self = Error.call(this, message);\n // istanbul ignore next Check is a necessary evil to support older environments\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(self, peg$SyntaxError.prototype);\n }\n self.expected = expected;\n self.found = found;\n self.location = location;\n self.name = \"SyntaxError\";\n return self;\n}\n\npeg$subclass(peg$SyntaxError, Error);\n\nfunction peg$padEnd(str, targetLength, padString) {\n padString = padString || \" \";\n if (str.length > targetLength) { return str; }\n targetLength -= str.length;\n padString += padString.repeat(targetLength);\n return str + padString.slice(0, targetLength);\n}\n\npeg$SyntaxError.prototype.format = function(sources) {\n var str = \"Error: \" + this.message;\n if (this.location) {\n var src = null;\n var k;\n for (k = 0; k < sources.length; k++) {\n if (sources[k].source === this.location.source) {\n src = sources[k].text.split(/\\r\\n|\\n|\\r/g);\n break;\n }\n }\n var s = this.location.start;\n var offset_s = (this.location.source && (typeof this.location.source.offset === \"function\"))\n ? this.location.source.offset(s)\n : s;\n var loc = this.location.source + \":\" + offset_s.line + \":\" + offset_s.column;\n if (src) {\n var e = this.location.end;\n var filler = peg$padEnd(\"\", offset_s.line.toString().length, ' ');\n var line = src[s.line - 1];\n var last = s.line === e.line ? e.column : line.length + 1;\n var hatLen = (last - s.column) || 1;\n str += \"\\n --> \" + loc + \"\\n\"\n + filler + \" |\\n\"\n + offset_s.line + \" | \" + line + \"\\n\"\n + filler + \" | \" + peg$padEnd(\"\", s.column - 1, ' ')\n + peg$padEnd(\"\", hatLen, \"^\");\n } else {\n str += \"\\n at \" + loc;\n }\n }\n return str;\n};\n\npeg$SyntaxError.buildMessage = function(expected, found) {\n var DESCRIBE_EXPECTATION_FNS = {\n literal: function(expectation) {\n return \"\\\"\" + literalEscape(expectation.text) + \"\\\"\";\n },\n\n class: function(expectation) {\n var escapedParts = expectation.parts.map(function(part) {\n return Array.isArray(part)\n ? classEscape(part[0]) + \"-\" + classEscape(part[1])\n : classEscape(part);\n });\n\n return \"[\" + (expectation.inverted ? \"^\" : \"\") + escapedParts.join(\"\") + \"]\";\n },\n\n any: function() {\n return \"any character\";\n },\n\n end: function() {\n return \"end of input\";\n },\n\n other: function(expectation) {\n return expectation.description;\n }\n };\n\n function hex(ch) {\n return ch.charCodeAt(0).toString(16).toUpperCase();\n }\n\n function literalEscape(s) {\n return s\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\"/g, \"\\\\\\\"\")\n .replace(/\\0/g, \"\\\\0\")\n .replace(/\\t/g, \"\\\\t\")\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/[\\x00-\\x0F]/g, function(ch) { return \"\\\\x0\" + hex(ch); })\n .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return \"\\\\x\" + hex(ch); });\n }\n\n function classEscape(s) {\n return s\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\\]/g, \"\\\\]\")\n .replace(/\\^/g, \"\\\\^\")\n .replace(/-/g, \"\\\\-\")\n .replace(/\\0/g, \"\\\\0\")\n .replace(/\\t/g, \"\\\\t\")\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/[\\x00-\\x0F]/g, function(ch) { return \"\\\\x0\" + hex(ch); })\n .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return \"\\\\x\" + hex(ch); });\n }\n\n function describeExpectation(expectation) {\n return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);\n }\n\n function describeExpected(expected) {\n var descriptions = expected.map(describeExpectation);\n var i, j;\n\n descriptions.sort();\n\n if (descriptions.length > 0) {\n for (i = 1, j = 1; i < descriptions.length; i++) {\n if (descriptions[i - 1] !== descriptions[i]) {\n descriptions[j] = descriptions[i];\n j++;\n }\n }\n descriptions.length = j;\n }\n\n switch (descriptions.length) {\n case 1:\n return descriptions[0];\n\n case 2:\n return descriptions[0] + \" or \" + descriptions[1];\n\n default:\n return descriptions.slice(0, -1).join(\", \")\n + \", or \"\n + descriptions[descriptions.length - 1];\n }\n }\n\n function describeFound(found) {\n return found ? \"\\\"\" + literalEscape(found) + \"\\\"\" : \"end of input\";\n }\n\n return \"Expected \" + describeExpected(expected) + \" but \" + describeFound(found) + \" found.\";\n};\n\nfunction peg$parse(input, options) {\n options = options !== undefined ? options : {};\n\n var peg$FAILED = {};\n var peg$source = options.grammarSource;\n\n var peg$startRuleFunctions = { transformList: peg$parsetransformList };\n var peg$startRuleFunction = peg$parsetransformList;\n\n var peg$c0 = \"matrix\";\n var peg$c1 = \"(\";\n var peg$c2 = \")\";\n var peg$c3 = \"translate\";\n var peg$c4 = \"scale\";\n var peg$c5 = \"rotate\";\n var peg$c6 = \"skewX\";\n var peg$c7 = \"skewY\";\n var peg$c8 = \",\";\n var peg$c9 = \".\";\n\n var peg$r0 = /^[eE]/;\n var peg$r1 = /^[+\\-]/;\n var peg$r2 = /^[0-9]/;\n var peg$r3 = /^[ \\t\\r\\n]/;\n\n var peg$e0 = peg$literalExpectation(\"matrix\", false);\n var peg$e1 = peg$literalExpectation(\"(\", false);\n var peg$e2 = peg$literalExpectation(\")\", false);\n var peg$e3 = peg$literalExpectation(\"translate\", false);\n var peg$e4 = peg$literalExpectation(\"scale\", false);\n var peg$e5 = peg$literalExpectation(\"rotate\", false);\n var peg$e6 = peg$literalExpectation(\"skewX\", false);\n var peg$e7 = peg$literalExpectation(\"skewY\", false);\n var peg$e8 = peg$literalExpectation(\",\", false);\n var peg$e9 = peg$otherExpectation(\"fractionalConstant\");\n var peg$e10 = peg$literalExpectation(\".\", false);\n var peg$e11 = peg$classExpectation([\"e\", \"E\"], false, false);\n var peg$e12 = peg$classExpectation([\"+\", \"-\"], false, false);\n var peg$e13 = peg$classExpectation([[\"0\", \"9\"]], false, false);\n var peg$e14 = peg$classExpectation([\" \", \"\\t\", \"\\r\", \"\\n\"], false, false);\n\n var peg$f0 = function(ts) { return ts; };\n var peg$f1 = function(t, ts) { return t.concat(ts) };\n var peg$f2 = function(a, b, c, d, e, f) {\n return [{type: 'matrix', a: a, b: b, c: c, d: d, e: e, f: f}];\n };\n var peg$f3 = function(tx, ty) {\n var t = {type: 'translate', tx: tx};\n if (ty) t.ty = ty;\n return [t];\n };\n var peg$f4 = function(sx, sy) {\n var s = {type:'scale', sx: sx};\n if (sy) s.sy = sy;\n return [s];\n };\n var peg$f5 = function(angle, c) {\n var r = {type:'rotate', angle: angle};\n if (c) {\n r.cx = c[0];\n r.cy = c[1];\n }\n return [r];\n };\n var peg$f6 = function(angle) {\n return [{type: 'skewX', angle: angle}];\n };\n var peg$f7 = function(angle) {\n return [{type: 'skewY', angle: angle}];\n };\n var peg$f8 = function(f) { return parseFloat(f.join(\"\")); };\n var peg$f9 = function(i) { return parseInt(i.join(\"\")); };\n var peg$f10 = function(n) { return n; };\n var peg$f11 = function(n1, n2) { return [n1, n2]; };\n var peg$f12 = function(ds) { return ds.join(\"\"); };\n var peg$f13 = function(f, e) { return [f, e || null].join(\"\")};\n var peg$f14 = function(d, e) { return [d, e].join(\"\")};\n var peg$f15 = function(d1, d2) { return [d1 ? d1.join(\"\") : null, \".\", d2.join(\"\")].join(\"\"); };\n var peg$f16 = function(d) { return d.join(\"\"); };\n var peg$f17 = function(s, d) { return ['e', s, d.join(\"\")].join(\"\") };\n var peg$currPos = 0;\n var peg$savedPos = 0;\n var peg$posDetailsCache = [{ line: 1, column: 1 }];\n var peg$maxFailPos = 0;\n var peg$maxFailExpected = [];\n var peg$silentFails = 0;\n\n var peg$result;\n\n if (\"startRule\" in options) {\n if (!(options.startRule in peg$startRuleFunctions)) {\n throw new Error(\"Can't start parsing from rule \\\"\" + options.startRule + \"\\\".\");\n }\n\n peg$startRuleFunction = peg$startRuleFunctions[options.startRule];\n }\n\n function text() {\n return input.substring(peg$savedPos, peg$currPos);\n }\n\n function offset() {\n return peg$savedPos;\n }\n\n function range() {\n return {\n source: peg$source,\n start: peg$savedPos,\n end: peg$currPos\n };\n }\n\n function location() {\n return peg$computeLocation(peg$savedPos, peg$currPos);\n }\n\n function expected(description, location) {\n location = location !== undefined\n ? location\n : peg$computeLocation(peg$savedPos, peg$currPos);\n\n throw peg$buildStructuredError(\n [peg$otherExpectation(description)],\n input.substring(peg$savedPos, peg$currPos),\n location\n );\n }\n\n function error(message, location) {\n location = location !== undefined\n ? location\n : peg$computeLocation(peg$savedPos, peg$currPos);\n\n throw peg$buildSimpleError(message, location);\n }\n\n function peg$literalExpectation(text, ignoreCase) {\n return { type: \"literal\", text: text, ignoreCase: ignoreCase };\n }\n\n function peg$classExpectation(parts, inverted, ignoreCase) {\n return { type: \"class\", parts: parts, inverted: inverted, ignoreCase: ignoreCase };\n }\n\n function peg$anyExpectation() {\n return { type: \"any\" };\n }\n\n function peg$endExpectation() {\n return { type: \"end\" };\n }\n\n function peg$otherExpectation(description) {\n return { type: \"other\", description: description };\n }\n\n function peg$computePosDetails(pos) {\n var details = peg$posDetailsCache[pos];\n var p;\n\n if (details) {\n return details;\n } else {\n p = pos - 1;\n while (!peg$posDetailsCache[p]) {\n p--;\n }\n\n details = peg$posDetailsCache[p];\n details = {\n line: details.line,\n column: details.column\n };\n\n while (p < pos) {\n if (input.charCodeAt(p) === 10) {\n details.line++;\n details.column = 1;\n } else {\n details.column++;\n }\n\n p++;\n }\n\n peg$posDetailsCache[pos] = details;\n\n return details;\n }\n }\n\n function peg$computeLocation(startPos, endPos, offset) {\n var startPosDetails = peg$computePosDetails(startPos);\n var endPosDetails = peg$computePosDetails(endPos);\n\n var res = {\n source: peg$source,\n start: {\n offset: startPos,\n line: startPosDetails.line,\n column: startPosDetails.column\n },\n end: {\n offset: endPos,\n line: endPosDetails.line,\n column: endPosDetails.column\n }\n };\n if (offset && peg$source && (typeof peg$source.offset === \"function\")) {\n res.start = peg$source.offset(res.start);\n res.end = peg$source.offset(res.end);\n }\n return res;\n }\n\n function peg$fail(expected) {\n if (peg$currPos < peg$maxFailPos) { return; }\n\n if (peg$currPos > peg$maxFailPos) {\n peg$maxFailPos = peg$currPos;\n peg$maxFailExpected = [];\n }\n\n peg$maxFailExpected.push(expected);\n }\n\n function peg$buildSimpleError(message, location) {\n return new peg$SyntaxError(message, null, null, location);\n }\n\n function peg$buildStructuredError(expected, found, location) {\n return new peg$SyntaxError(\n peg$SyntaxError.buildMessage(expected, found),\n expected,\n found,\n location\n );\n }\n\n function peg$parsetransformList() {\n var s0, s1, s2, s3, s4;\n\n s0 = peg$currPos;\n s1 = [];\n s2 = peg$parsewsp();\n while (s2 !== peg$FAILED) {\n s1.push(s2);\n s2 = peg$parsewsp();\n }\n s2 = peg$parsetransforms();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s3 = [];\n s4 = peg$parsewsp();\n while (s4 !== peg$FAILED) {\n s3.push(s4);\n s4 = peg$parsewsp();\n }\n peg$savedPos = s0;\n s0 = peg$f0(s2);\n\n return s0;\n }\n\n function peg$parsetransforms() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$parsetransform();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsecommaWsp();\n if (s3 !== peg$FAILED) {\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsecommaWsp();\n }\n } else {\n s2 = peg$FAILED;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parsetransforms();\n if (s3 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f1(s1, s3);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parsetransform();\n }\n\n return s0;\n }\n\n function peg$parsetransform() {\n var s0;\n\n s0 = peg$parsematrix();\n if (s0 === peg$FAILED) {\n s0 = peg$parsetranslate();\n if (s0 === peg$FAILED) {\n s0 = peg$parsescale();\n if (s0 === peg$FAILED) {\n s0 = peg$parserotate();\n if (s0 === peg$FAILED) {\n s0 = peg$parseskewX();\n if (s0 === peg$FAILED) {\n s0 = peg$parseskewY();\n }\n }\n }\n }\n }\n\n return s0;\n }\n\n function peg$parsematrix() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 6) === peg$c0) {\n s1 = peg$c0;\n peg$currPos += 6;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e0); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = peg$parsecommaWsp();\n if (s6 !== peg$FAILED) {\n s7 = peg$parsenumber();\n if (s7 !== peg$FAILED) {\n s8 = peg$parsecommaWsp();\n if (s8 !== peg$FAILED) {\n s9 = peg$parsenumber();\n if (s9 !== peg$FAILED) {\n s10 = peg$parsecommaWsp();\n if (s10 !== peg$FAILED) {\n s11 = peg$parsenumber();\n if (s11 !== peg$FAILED) {\n s12 = peg$parsecommaWsp();\n if (s12 !== peg$FAILED) {\n s13 = peg$parsenumber();\n if (s13 !== peg$FAILED) {\n s14 = peg$parsecommaWsp();\n if (s14 !== peg$FAILED) {\n s15 = peg$parsenumber();\n if (s15 !== peg$FAILED) {\n s16 = [];\n s17 = peg$parsewsp();\n while (s17 !== peg$FAILED) {\n s16.push(s17);\n s17 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s17 = peg$c2;\n peg$currPos++;\n } else {\n s17 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s17 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f2(s5, s7, s9, s11, s13, s15);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsetranslate() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 9) === peg$c3) {\n s1 = peg$c3;\n peg$currPos += 9;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e3); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = peg$parsecommaWspNumber();\n if (s6 === peg$FAILED) {\n s6 = null;\n }\n s7 = [];\n s8 = peg$parsewsp();\n while (s8 !== peg$FAILED) {\n s7.push(s8);\n s8 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s8 = peg$c2;\n peg$currPos++;\n } else {\n s8 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s8 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f3(s5, s6);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsescale() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 5) === peg$c4) {\n s1 = peg$c4;\n peg$currPos += 5;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e4); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = peg$parsecommaWspNumber();\n if (s6 === peg$FAILED) {\n s6 = null;\n }\n s7 = [];\n s8 = peg$parsewsp();\n while (s8 !== peg$FAILED) {\n s7.push(s8);\n s8 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s8 = peg$c2;\n peg$currPos++;\n } else {\n s8 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s8 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f4(s5, s6);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parserotate() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 6) === peg$c5) {\n s1 = peg$c5;\n peg$currPos += 6;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e5); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = peg$parsecommaWspTwoNumbers();\n if (s6 === peg$FAILED) {\n s6 = null;\n }\n s7 = [];\n s8 = peg$parsewsp();\n while (s8 !== peg$FAILED) {\n s7.push(s8);\n s8 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s8 = peg$c2;\n peg$currPos++;\n } else {\n s8 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s8 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f5(s5, s6);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parseskewX() {\n var s0, s1, s2, s3, s4, s5, s6, s7;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 5) === peg$c6) {\n s1 = peg$c6;\n peg$currPos += 5;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e6); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = [];\n s7 = peg$parsewsp();\n while (s7 !== peg$FAILED) {\n s6.push(s7);\n s7 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s7 = peg$c2;\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s7 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f6(s5);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parseskewY() {\n var s0, s1, s2, s3, s4, s5, s6, s7;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 5) === peg$c7) {\n s1 = peg$c7;\n peg$currPos += 5;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e7); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e1); }\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsewsp();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsewsp();\n }\n s5 = peg$parsenumber();\n if (s5 !== peg$FAILED) {\n s6 = [];\n s7 = peg$parsewsp();\n while (s7 !== peg$FAILED) {\n s6.push(s7);\n s7 = peg$parsewsp();\n }\n if (input.charCodeAt(peg$currPos) === 41) {\n s7 = peg$c2;\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e2); }\n }\n if (s7 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f7(s5);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsenumber() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$currPos;\n s2 = peg$parsesign();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s3 = peg$parsefloatingPointConstant();\n if (s3 !== peg$FAILED) {\n s2 = [s2, s3];\n s1 = s2;\n } else {\n peg$currPos = s1;\n s1 = peg$FAILED;\n }\n if (s1 !== peg$FAILED) {\n peg$savedPos = s0;\n s1 = peg$f8(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$currPos;\n s2 = peg$parsesign();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s3 = peg$parseintegerConstant();\n if (s3 !== peg$FAILED) {\n s2 = [s2, s3];\n s1 = s2;\n } else {\n peg$currPos = s1;\n s1 = peg$FAILED;\n }\n if (s1 !== peg$FAILED) {\n peg$savedPos = s0;\n s1 = peg$f9(s1);\n }\n s0 = s1;\n }\n\n return s0;\n }\n\n function peg$parsecommaWspNumber() {\n var s0, s1, s2;\n\n s0 = peg$currPos;\n s1 = peg$parsecommaWsp();\n if (s1 !== peg$FAILED) {\n s2 = peg$parsenumber();\n if (s2 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f10(s2);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsecommaWspTwoNumbers() {\n var s0, s1, s2, s3, s4;\n\n s0 = peg$currPos;\n s1 = peg$parsecommaWsp();\n if (s1 !== peg$FAILED) {\n s2 = peg$parsenumber();\n if (s2 !== peg$FAILED) {\n s3 = peg$parsecommaWsp();\n if (s3 !== peg$FAILED) {\n s4 = peg$parsenumber();\n if (s4 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f11(s2, s4);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsecommaWsp() {\n var s0, s1, s2, s3, s4;\n\n s0 = peg$currPos;\n s1 = [];\n s2 = peg$parsewsp();\n if (s2 !== peg$FAILED) {\n while (s2 !== peg$FAILED) {\n s1.push(s2);\n s2 = peg$parsewsp();\n }\n } else {\n s1 = peg$FAILED;\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parsecomma();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s3 = [];\n s4 = peg$parsewsp();\n while (s4 !== peg$FAILED) {\n s3.push(s4);\n s4 = peg$parsewsp();\n }\n s1 = [s1, s2, s3];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parsecomma();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsewsp();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsewsp();\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n }\n\n return s0;\n }\n\n function peg$parsecomma() {\n var s0;\n\n if (input.charCodeAt(peg$currPos) === 44) {\n s0 = peg$c8;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e8); }\n }\n\n return s0;\n }\n\n function peg$parseintegerConstant() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parsedigitSequence();\n if (s1 !== peg$FAILED) {\n peg$savedPos = s0;\n s1 = peg$f12(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parsefloatingPointConstant() {\n var s0, s1, s2;\n\n s0 = peg$currPos;\n s1 = peg$parsefractionalConstant();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseexponent();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n peg$savedPos = s0;\n s0 = peg$f13(s1, s2);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parsedigitSequence();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseexponent();\n if (s2 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f14(s1, s2);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n }\n\n return s0;\n }\n\n function peg$parsefractionalConstant() {\n var s0, s1, s2, s3;\n\n peg$silentFails++;\n s0 = peg$currPos;\n s1 = peg$parsedigitSequence();\n if (s1 === peg$FAILED) {\n s1 = null;\n }\n if (input.charCodeAt(peg$currPos) === 46) {\n s2 = peg$c9;\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e10); }\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parsedigitSequence();\n if (s3 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f15(s1, s3);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parsedigitSequence();\n if (s1 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 46) {\n s2 = peg$c9;\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e10); }\n }\n if (s2 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f16(s1);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n }\n peg$silentFails--;\n if (s0 === peg$FAILED) {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e9); }\n }\n\n return s0;\n }\n\n function peg$parseexponent() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (peg$r0.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e11); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parsesign();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s3 = peg$parsedigitSequence();\n if (s3 !== peg$FAILED) {\n peg$savedPos = s0;\n s0 = peg$f17(s2, s3);\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsesign() {\n var s0;\n\n if (peg$r1.test(input.charAt(peg$currPos))) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e12); }\n }\n\n return s0;\n }\n\n function peg$parsedigitSequence() {\n var s0, s1;\n\n s0 = [];\n s1 = peg$parsedigit();\n if (s1 !== peg$FAILED) {\n while (s1 !== peg$FAILED) {\n s0.push(s1);\n s1 = peg$parsedigit();\n }\n } else {\n s0 = peg$FAILED;\n }\n\n return s0;\n }\n\n function peg$parsedigit() {\n var s0;\n\n if (peg$r2.test(input.charAt(peg$currPos))) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e13); }\n }\n\n return s0;\n }\n\n function peg$parsewsp() {\n var s0;\n\n if (peg$r3.test(input.charAt(peg$currPos))) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$e14); }\n }\n\n return s0;\n }\n\n peg$result = peg$startRuleFunction();\n\n if (peg$result !== peg$FAILED && peg$currPos === input.length) {\n return peg$result;\n } else {\n if (peg$result !== peg$FAILED && peg$currPos < input.length) {\n peg$fail(peg$endExpectation());\n }\n\n throw peg$buildStructuredError(\n peg$maxFailExpected,\n peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,\n peg$maxFailPos < input.length\n ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)\n : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)\n );\n }\n}\n\nexport {\n peg$SyntaxError as SyntaxError,\n\n peg$parse as parse\n};\n","import { scale } from './scale'\nimport { compose } from './transform'\n/**\n * Decompose a matrix into translation, scaling and rotation components, optionally\n * take horizontal and vertical flip in to consideration.\n * Note this function decomposes a matrix in rotation -> scaling -> translation order. I.e. for\n * certain translation T {tx, ty}, rotation R and scaling S { sx, sy }, it's only true for:\n * decomposeTSR(compose(T, S, R)) === { translate: T, rotation: R, scale: S }\n * composing in a different order may yield a different decomposition result.\n * @param matrix {Matrix} Affine Matrix\n * @param flipX {boolean} Whether the matrix contains vertical flip, i.e. mirrors on x-axis\n * @param flipY {boolean} Whether the matrix contains horizontal flip, i.e. mirrors on y-axis\n * @returns {Transform} A transform object consisted by its translation, scaling\n * and rotation components.\n */\nexport function decomposeTSR (matrix, flipX = false, flipY = false) {\n // Remove flip from the matrix first - flip could be incorrectly interpreted as\n // rotations (e.g. flipX + flipY = rotate by 180 degrees).\n // Note flipX is a vertical flip, and flipY is a horizontal flip.\n if (flipX) {\n if (flipY) {\n matrix = compose(matrix, scale(-1, -1))\n } else {\n matrix = compose(matrix, scale(1, -1))\n }\n } else if (flipY) {\n matrix = compose(matrix, scale(-1, 1))\n }\n\n const a = matrix.a; const b = matrix.b\n const c = matrix.c; const d = matrix.d\n let scaleX, scaleY, rotation\n\n if (a !== 0 || c !== 0) {\n const hypotAc = Math.hypot(a, c)\n scaleX = hypotAc\n scaleY = (a * d - b * c) / hypotAc\n const acos = Math.acos(a / hypotAc)\n rotation = c > 0 ? -acos : acos\n } else if (b !== 0 || d !== 0) {\n const hypotBd = Math.hypot(b, d)\n scaleX = (a * d - b * c) / hypotBd\n scaleY = hypotBd\n const acos = Math.acos(b / hypotBd)\n rotation = Math.PI / 2 + (d > 0 ? -acos : acos)\n } else {\n scaleX = 0\n scaleY = 0\n rotation = 0\n }\n\n // put the flip factors back\n if (flipY) {\n scaleX = -scaleX\n }\n\n if (flipX) {\n scaleY = -scaleY\n }\n\n return {\n translate: { tx: matrix.e, ty: matrix.f },\n scale: { sx: scaleX, sy: scaleY },\n rotation: { angle: rotation }\n }\n}\n","import type {\n AnyCircuitElement,\n AnyCircuitElementInput,\n SourceComponentBase,\n SourcePort,\n} from \"circuit-json\"\nimport * as Soup from \"circuit-json\"\nimport type { SubtreeOptions } from \"./subtree\"\nimport { buildSubtree } from \"./subtree\"\n\nexport type CircuitJsonOps<\n K extends AnyCircuitElement[\"type\"],\n T extends AnyCircuitElement | AnyCircuitElementInput,\n> = {\n get: (id: string) => Extract<T, { type: K }> | null\n select: (selector: string) => Extract<T, { type: K }> | null\n getWhere: (where: any) => Extract<T, { type: K }> | null\n getUsing: (using: {\n [key: `${string}_id`]: string\n }) => Extract<T, { type: K }> | null\n insert: (\n elm: Omit<Extract<T, { type: K }>, \"type\" | `${K}_id`>,\n ) => Extract<T, { type: K }>\n update: (\n id: string,\n newProps: Partial<Extract<T, { type: K }>>,\n ) => Extract<T, { type: K }>\n delete: (id: string) => void\n list: (where?: any) => Extract<T, { type: K }>[]\n}\n\nexport type CircuitJsonUtilObjects = {\n [K in AnyCircuitElement[\"type\"]]: CircuitJsonOps<K, AnyCircuitElement>\n} & {\n insert: (elm: AnyCircuitElementInput) => AnyCircuitElement\n insertAll: (elms: AnyCircuitElementInput[]) => AnyCircuitElement[]\n subtree: (where?: any) => CircuitJsonUtilObjects\n toArray: () => AnyCircuitElement[]\n editCount: number\n}\nexport type CircuitJsonInputUtilObjects = {\n [K in AnyCircuitElementInput[\"type\"]]: CircuitJsonOps<\n K,\n AnyCircuitElementInput\n >\n}\n\nexport type CircuitJsonUtilOptions = {\n validateInserts?: boolean\n}\n\nexport type GetCircuitJsonUtilFn = ((\n soup: AnyCircuitElement[],\n options?: CircuitJsonUtilOptions,\n) => CircuitJsonUtilObjects) & {\n unparsed: (soup: AnyCircuitElementInput[]) => CircuitJsonInputUtilObjects\n}\n\ninterface InternalStore {\n counts: Record<string, number>\n editCount: number\n}\n\nexport const cju: GetCircuitJsonUtilFn = ((\n circuitJsonInput: any[],\n options: CircuitJsonUtilOptions = {},\n) => {\n const circuitJson = circuitJsonInput as AnyCircuitElement[]\n let internalStore: InternalStore = (circuitJson as any)._internal_store\n if (!internalStore) {\n internalStore = {\n counts: {},\n editCount: 0,\n } as InternalStore\n ;(circuitJson as any)._internal_store = internalStore\n\n // Initialize counts\n for (const elm of circuitJson) {\n const type = elm.type\n const idVal = (elm as any)[`${type}_id`]\n if (!idVal) continue\n const idNum = Number.parseInt(idVal.split(\"_\").pop())\n if (!Number.isNaN(idNum)) {\n internalStore.counts[type] = Math.max(\n internalStore.counts[type] ?? 0,\n idNum,\n )\n }\n }\n }\n const su = new Proxy(\n {},\n {\n get: (proxy_target: any, prop: string) => {\n if (prop === \"toArray\") {\n return () => {\n ;(circuitJson as any).editCount = internalStore.editCount\n return circuitJson\n }\n }\n if (prop === \"editCount\") {\n return internalStore.editCount\n }\n\n if (prop === \"subtree\") {\n return (opts: SubtreeOptions) =>\n cju(buildSubtree(circuitJson, opts), options)\n }\n\n if (prop === \"insert\") {\n return (elm: AnyCircuitElementInput) => {\n const component_type = elm.type\n if (!component_type) {\n throw new Error(\"insert requires an element with a type\")\n }\n\n internalStore.counts[component_type] ??= -1\n internalStore.counts[component_type]++\n const index = internalStore.counts[component_type]\n\n const newElm = {\n ...elm,\n type: component_type,\n [`${component_type}_id`]: `${component_type}_${index}`,\n } as AnyCircuitElement\n\n if (options.validateInserts) {\n const parser =\n (Soup as any)[component_type] ?? Soup.any_soup_element\n parser.parse(newElm)\n }\n\n circuitJson.push(newElm)\n internalStore.editCount++\n return newElm\n }\n }\n\n if (prop === \"insertAll\") {\n return (elms: AnyCircuitElementInput[]) => {\n return elms.map((elm) => su.insert(elm))\n }\n }\n\n const component_type = prop\n\n return {\n get: (id: string) =>\n circuitJson.find(\n (e: any) =>\n e.type === component_type && e[`${component_type}_id`] === id,\n ),\n getUsing: (using: any) => {\n const keys = Object.keys(using)\n if (keys.length !== 1) {\n throw new Error(\n \"getUsing requires exactly one key, e.g. { pcb_component_id }\",\n )\n }\n const join_key = keys[0] as string\n const join_type = join_key.replace(\"_id\", \"\")\n const joiner: any = circuitJson.find(\n (e: any) =>\n e.type === join_type && e[join_key] === using[join_key],\n )\n if (!joiner) return null\n return circuitJson.find(\n (e: any) =>\n e.type === component_type &&\n e[`${component_type}_id`] === joiner[`${component_type}_id`],\n )\n },\n getWhere: (where: any) => {\n const keys = Object.keys(where)\n return circuitJson.find(\n (e: any) =>\n e.type === component_type &&\n keys.every((key) => e[key] === where[key]),\n )\n },\n list: (where?: any) => {\n const keys = !where ? [] : Object.keys(where)\n return circuitJson.filter(\n (e: any) =>\n e.type === component_type &&\n keys.every((key) => e[key] === where[key]),\n )\n },\n insert: (elm: any) => {\n internalStore.counts[component_type] ??= -1\n internalStore.counts[component_type]++\n const index = internalStore.counts[component_type]\n const newElm = {\n type: component_type,\n [`${component_type}_id`]: `${component_type}_${index}`,\n ...elm,\n }\n\n if (options.validateInserts) {\n const parser =\n (Soup as any)[component_type] ?? Soup.any_soup_element\n parser.parse(newElm)\n }\n\n circuitJson.push(newElm)\n internalStore.editCount++\n return newElm\n },\n delete: (id: string) => {\n const elm = circuitJson.find(\n (e) => (e as any)[`${component_type}_id`] === id,\n )\n if (!elm) return\n circuitJson.splice(circuitJson.indexOf(elm), 1)\n internalStore.editCount++\n },\n update: (id: string, newProps: any) => {\n const elm = circuitJson.find(\n (e) =>\n e.type === component_type &&\n (e as any)[`${component_type}_id`] === id,\n )\n if (!elm) return null\n Object.assign(elm, newProps)\n internalStore.editCount++\n return elm\n },\n select: (selector: string) => {\n // TODO when applySelector is isolated we can use it, until then we\n // do a poor man's selector implementation for two common cases\n if (component_type === \"source_component\") {\n return circuitJson.find(\n (e) =>\n e.type === \"source_component\" &&\n e.name === selector.replace(/\\./g, \"\"),\n )\n } else if (\n component_type === \"pcb_port\" ||\n component_type === \"source_port\" ||\n component_type === \"schematic_port\"\n ) {\n const [component_name, port_selector] = selector\n .replace(/\\./g, \"\")\n .split(/[\\s\\>]+/)\n const source_component = circuitJson.find(\n (e) =>\n e.type === \"source_component\" && e.name === component_name,\n ) as SourceComponentBase\n if (!source_component) return null\n const source_port = circuitJson.find(\n (e) =>\n e.type === \"source_port\" &&\n e.source_component_id ===\n source_component.source_component_id &&\n (e.name === port_selector ||\n (e.port_hints ?? []).includes(port_selector!)),\n ) as SourcePort\n if (!source_port) return null\n if (component_type === \"source_port\") return source_port\n\n if (component_type === \"pcb_port\") {\n return circuitJson.find(\n (e) =>\n e.type === \"pcb_port\" &&\n e.source_port_id === source_port.source_port_id,\n )\n } else if (component_type === \"schematic_port\") {\n return circuitJson.find(\n (e) =>\n e.type === \"schematic_port\" &&\n e.source_port_id === source_port.source_port_id,\n )\n }\n }\n },\n }\n },\n },\n )\n\n return su\n}) as any\ncju.unparsed = cju as any\n\nexport const su = cju\n\nexport default cju\n","import type { AnyCircuitElement } from \"circuit-json\"\n\nexport type SubtreeOptions = {\n subcircuit_id?: string\n subcircuit_ids?: string[]\n source_group_id?: string\n source_board_id?: string\n}\n\nfunction connect(\n map: Map<AnyCircuitElement, Set<AnyCircuitElement>>,\n a: AnyCircuitElement | undefined,\n b: AnyCircuitElement | undefined,\n) {\n if (!a || !b) return\n let setA = map.get(a)\n if (!setA) {\n setA = new Set()\n map.set(a, setA)\n }\n setA.add(b)\n let setB = map.get(b)\n if (!setB) {\n setB = new Set()\n map.set(b, setB)\n }\n setB.add(a)\n}\n\nexport function buildSubtree(\n soup: AnyCircuitElement[],\n opts: SubtreeOptions,\n): AnyCircuitElement[] {\n if (!opts.subcircuit_id && !opts.source_group_id) return [...soup]\n\n // For subcircuit_id, also include nested subcircuits\n let effectiveOpts = opts\n if (opts.subcircuit_id) {\n // Find all subcircuit_ids that are children of the target subcircuit\n const subcircuitIds = new Set<string>([opts.subcircuit_id])\n\n // Build group hierarchy\n const groupChildren = new Map<string, string[]>()\n const groupSubcircuit = new Map<string, string>()\n\n for (const elm of soup) {\n if (elm.type === \"source_group\") {\n const groupId = elm.source_group_id\n const subcircuitId = elm.subcircuit_id\n if (subcircuitId) {\n groupSubcircuit.set(groupId, subcircuitId)\n }\n const parentId = elm.parent_source_group_id\n if (parentId) {\n if (!groupChildren.has(parentId)) {\n groupChildren.set(parentId, [])\n }\n groupChildren.get(parentId)!.push(groupId)\n }\n }\n }\n\n // Find the root group for the target subcircuit\n let rootGroupId: string | undefined\n for (const [groupId, subcircuitId] of groupSubcircuit) {\n if (subcircuitId === opts.subcircuit_id) {\n rootGroupId = groupId\n break\n }\n }\n\n if (rootGroupId) {\n // Recursively collect all child subcircuit_ids\n const collectChildSubcircuits = (groupId: string) => {\n const children = groupChildren.get(groupId) || []\n for (const childId of children) {\n const childSubcircuit = groupSubcircuit.get(childId)\n if (childSubcircuit) {\n subcircuitIds.add(childSubcircuit)\n }\n collectChildSubcircuits(childId)\n }\n }\n collectChildSubcircuits(rootGroupId)\n\n // Update opts to include all these subcircuits\n effectiveOpts = { ...opts, subcircuit_ids: Array.from(subcircuitIds) }\n }\n }\n\n const idMap = new Map<string, AnyCircuitElement>()\n for (const elm of soup) {\n const idKey = `${elm.type}_id` as keyof typeof elm\n const idVal = elm[idKey]\n if (typeof idVal === \"string\") {\n idMap.set(idVal, elm)\n }\n }\n\n const adj = new Map<AnyCircuitElement, Set<AnyCircuitElement>>()\n for (const elm of soup) {\n const entries = Object.entries(elm)\n for (const [key, val] of entries) {\n if (key === \"parent_source_group_id\") continue // Skip parent relationships to avoid traversing up\n if (key.endsWith(\"_id\") && typeof val === \"string\") {\n const other = idMap.get(val)\n connect(adj, elm, other)\n } else if (key.endsWith(\"_ids\") && Array.isArray(val)) {\n for (const v of val) {\n if (typeof v === \"string\") {\n const other = idMap.get(v)\n connect(adj, elm, other)\n }\n }\n }\n }\n }\n\n const queue: AnyCircuitElement[] = []\n const included = new Set<AnyCircuitElement>()\n\n for (const elm of soup) {\n let shouldInclude = false\n if (\n effectiveOpts.subcircuit_id &&\n \"subcircuit_id\" in elm &&\n elm.subcircuit_id === effectiveOpts.subcircuit_id\n ) {\n shouldInclude = true\n } else if (\n effectiveOpts.subcircuit_ids &&\n \"subcircuit_id\" in elm &&\n elm.subcircuit_id &&\n effectiveOpts.subcircuit_ids.includes(elm.subcircuit_id)\n ) {\n shouldInclude = true\n } else if (\n effectiveOpts.source_group_id &&\n \"source_group_id\" in elm &&\n elm.source_group_id === effectiveOpts.source_group_id\n ) {\n shouldInclude = true\n } else if (\n effectiveOpts.source_group_id &&\n \"member_source_group_ids\" in elm &&\n Array.isArray(elm.member_source_group_ids) &&\n elm.member_source_group_ids.includes(effectiveOpts.source_group_id)\n ) {\n shouldInclude = true\n }\n\n if (shouldInclude) {\n queue.push(elm)\n included.add(elm)\n }\n }\n\n while (queue.length > 0) {\n const elm = queue.shift()!\n const neighbors = adj.get(elm)\n if (!neighbors) continue\n for (const n of neighbors) {\n if (!included.has(n)) {\n included.add(n)\n queue.push(n)\n }\n }\n }\n\n return soup.filter((e) => included.has(e))\n}\n","import type {\n AnyCircuitElement,\n AnyCircuitElementInput,\n SourceComponentBase,\n SourcePort,\n} from \"circuit-json\"\nimport * as Soup from \"circuit-json\"\nimport type {\n CircuitJsonOps,\n CircuitJsonUtilObjects as CircuitJsonUtilObjects,\n CircuitJsonInputUtilObjects as CircuitJsonInputUtilObjects,\n} from \"./cju\"\n\nexport type IndexedCircuitJsonUtilOptions = {\n validateInserts?: boolean\n indexConfig?: {\n // Enable specific indexes for faster lookups\n byId?: boolean\n byType?: boolean\n byRelation?: boolean\n bySubcircuit?: boolean\n byCustomField?: string[]\n }\n}\n\nexport type GetIndexedCircuitJsonUtilFn = ((\n soup: AnyCircuitElement[],\n options?: IndexedCircuitJsonUtilOptions,\n) => CircuitJsonUtilObjects) & {\n unparsed: (soup: AnyCircuitElementInput[]) => CircuitJsonInputUtilObjects\n}\n\ninterface InternalStore {\n counts: Record<string, number>\n editCount: number\n // Indexes for faster lookups\n indexes: {\n byId?: Map<string, AnyCircuitElement>\n byType?: Map<string, AnyCircuitElement[]>\n // Maps relation fields (like component_id) to elements\n byRelation?: Map<string, Map<string, AnyCircuitElement[]>>\n // Maps subcircuit_id to elements\n bySubcircuit?: Map<string, AnyCircuitElement[]>\n // Custom field indexes\n byCustomField?: Map<string, Map<string, AnyCircuitElement[]>>\n }\n}\n\n// Creates a unique key for the ID index\nfunction createIdKey(element: AnyCircuitElement): string {\n const type = element.type\n return `${type}:${(element as any)[`${type}_id`]}`\n}\n\nexport const cjuIndexed: GetIndexedCircuitJsonUtilFn = ((\n soup: AnyCircuitElement[],\n options: IndexedCircuitJsonUtilOptions = {},\n) => {\n let internalStore: InternalStore = (soup as any)._internal_store_indexed\n\n if (!internalStore) {\n internalStore = {\n counts: {},\n editCount: 0,\n indexes: {},\n } as InternalStore\n\n // Initialize counts\n for (const elm of soup) {\n const type = elm.type\n const idVal = (elm as any)[`${type}_id`]\n if (!idVal) continue\n const idNum = Number.parseInt(idVal.split(\"_\").pop() || \"\")\n if (!Number.isNaN(idNum)) {\n internalStore.counts[type] = Math.max(\n internalStore.counts[type] ?? 0,\n idNum,\n )\n }\n }\n\n // Build indexes\n const indexConfig = options.indexConfig || {}\n const indexes = internalStore.indexes\n\n // Reset indexes before rebuilding\n if (indexConfig.byId) {\n indexes.byId = new Map()\n }\n\n if (indexConfig.byType) {\n indexes.byType = new Map()\n }\n\n if (indexConfig.byRelation) {\n indexes.byRelation = new Map()\n }\n\n if (indexConfig.bySubcircuit) {\n indexes.bySubcircuit = new Map()\n }\n\n if (indexConfig.byCustomField && indexConfig.byCustomField.length > 0) {\n indexes.byCustomField = new Map()\n for (const field of indexConfig.byCustomField) {\n indexes.byCustomField.set(field, new Map())\n }\n }\n\n // Build indexes\n for (const element of soup) {\n // Index by ID\n if (indexConfig.byId) {\n const idKey = createIdKey(element)\n indexes.byId!.set(idKey, element)\n }\n\n // Index by type\n if (indexConfig.byType) {\n const elementsOfType = indexes.byType!.get(element.type) || []\n elementsOfType.push(element)\n indexes.byType!.set(element.type, elementsOfType)\n }\n\n // Index by relation fields (fields ending with _id)\n if (indexConfig.byRelation) {\n const elementEntries = Object.entries(element)\n for (const [key, value] of elementEntries) {\n if (\n key.endsWith(\"_id\") &&\n key !== `${element.type}_id` &&\n typeof value === \"string\"\n ) {\n const relationTypeMap = indexes.byRelation!.get(key) || new Map()\n const relatedElements = relationTypeMap.get(value as string) || []\n relatedElements.push(element)\n relationTypeMap.set(value as string, relatedElements)\n indexes.byRelation!.set(key, relationTypeMap)\n }\n }\n }\n\n // Index by subcircuit_id\n if (indexConfig.bySubcircuit && \"subcircuit_id\" in element) {\n const subcircuitId = (element as any).subcircuit_id\n if (subcircuitId && typeof subcircuitId === \"string\") {\n const subcircuitElements =\n indexes.bySubcircuit!.get(subcircuitId) || []\n subcircuitElements.push(element)\n indexes.bySubcircuit!.set(subcircuitId, subcircuitElements)\n }\n }\n\n // Index by custom fields\n if (indexConfig.byCustomField && indexes.byCustomField) {\n for (const field of indexConfig.byCustomField) {\n if (field in element) {\n const fieldValue = (element as any)[field]\n if (\n fieldValue !== undefined &&\n (typeof fieldValue === \"string\" || typeof fieldValue === \"number\")\n ) {\n const fieldValueStr = String(fieldValue)\n const fieldMap = indexes.byCustomField.get(field)!\n const elementsWithFieldValue = fieldMap.get(fieldValueStr) || []\n elementsWithFieldValue.push(element)\n fieldMap.set(fieldValueStr, elementsWithFieldValue)\n }\n }\n }\n }\n }\n // Store internal state\n ;(soup as any)._internal_store_indexed = internalStore\n }\n\n const suIndexed = new Proxy(\n {},\n {\n get: (proxy_target: any, prop: string) => {\n if (prop === \"toArray\") {\n return () => {\n ;(soup as any).editCount = internalStore.editCount\n return soup\n }\n }\n if (prop === \"editCount\") {\n return internalStore.editCount\n }\n\n const component_type = prop\n\n return {\n get: (id: string) => {\n const indexConfig = options.indexConfig || {}\n\n // Use ID index if available\n if (indexConfig.byId && internalStore.indexes.byId) {\n return (\n (internalStore.indexes.byId.get(\n `${component_type}:${id}`,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n // Use type index if available\n if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n return (\n (elementsOfType.find(\n (e: any) => e[`${component_type}_id`] === id,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n // Fallback to regular search\n return (\n (soup.find(\n (e: any) =>\n e.type === component_type && e[`${component_type}_id`] === id,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n },\n\n getUsing: (using: any) => {\n const indexConfig = options.indexConfig || {}\n const keys = Object.keys(using)\n\n if (keys.length !== 1) {\n throw new Error(\n \"getUsing requires exactly one key, e.g. { pcb_component_id }\",\n )\n }\n\n const join_key = keys[0] as string\n const join_type = join_key.replace(\"_id\", \"\")\n\n // Use relation index if available\n if (indexConfig.byRelation && internalStore.indexes.byRelation) {\n const relationMap = internalStore.indexes.byRelation.get(join_key)\n if (relationMap) {\n const relatedElements = relationMap.get(using[join_key]) || []\n const joiner = relatedElements.find((e) => e.type === join_type)\n\n if (!joiner) return null\n\n // Now find the element of component_type with matching ID\n const joinerId =\n joiner[`${component_type}_id` as keyof typeof joiner]\n\n if (indexConfig.byId && internalStore.indexes.byId) {\n return (\n (internalStore.indexes.byId.get(\n `${component_type}:${joinerId}`,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n return (\n (elementsOfType.find(\n (e: any) => e[`${component_type}_id`] === joinerId,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n return (\n (soup.find(\n (e: any) =>\n e.type === component_type &&\n e[`${component_type}_id`] === joinerId,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n }\n\n // Fallback to regular approach\n const joiner: any = soup.find(\n (e: any) =>\n e.type === join_type && e[join_key] === using[join_key],\n )\n\n if (!joiner) return null\n\n return (\n (soup.find(\n (e: any) =>\n e.type === component_type &&\n e[`${component_type}_id`] === joiner[`${component_type}_id`],\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n },\n\n getWhere: (where: any) => {\n const indexConfig = options.indexConfig || {}\n const keys = Object.keys(where)\n\n // If we're looking by a single property and it's indexed as a custom field\n if (\n keys.length === 1 &&\n indexConfig.byCustomField &&\n internalStore.indexes.byCustomField\n ) {\n const field = keys[0]\n const fieldMap = internalStore.indexes.byCustomField.get(field!)\n\n if (fieldMap) {\n const fieldValue = String(where[field!])\n const elementsWithFieldValue = fieldMap.get(fieldValue) || []\n\n return (\n (elementsWithFieldValue.find(\n (e: any) => e.type === component_type,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n }\n\n // If we're looking by subcircuit_id and it's indexed\n if (\n \"subcircuit_id\" in where &&\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit\n ) {\n const subcircuitId = where.subcircuit_id\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(subcircuitId) || []\n\n return (\n (subcircuitElements.find(\n (e: any) =>\n e.type === component_type &&\n keys.every((key) => e[key] === where[key]),\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n // Use type index if available to reduce search space\n if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n\n return (\n (elementsOfType.find((e: any) =>\n keys.every((key) => e[key] === where[key]),\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n\n // Fallback to regular approach\n return (\n (soup.find(\n (e: any) =>\n e.type === component_type &&\n keys.every((key) => e[key] === where[key]),\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n },\n\n list: (where?: any) => {\n const indexConfig = options.indexConfig || {}\n const keys = !where ? [] : Object.keys(where)\n\n // If no filters, just return all elements of this type using the type index\n if (\n keys.length === 0 &&\n indexConfig.byType &&\n internalStore.indexes.byType\n ) {\n return (internalStore.indexes.byType.get(component_type) ||\n []) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >[]\n }\n\n // If filtering by subcircuit_id and it's the only filter\n if (\n keys.length === 1 &&\n keys[0] === \"subcircuit_id\" &&\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit\n ) {\n const subcircuitId = where.subcircuit_id\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(subcircuitId) || []\n\n return subcircuitElements.filter(\n (e: any) => e.type === component_type,\n ) as Extract<AnyCircuitElement, { type: typeof component_type }>[]\n }\n\n // Start with all elements of this type to reduce search space\n let elementsToFilter: AnyCircuitElement[]\n\n if (indexConfig.byType && internalStore.indexes.byType) {\n elementsToFilter =\n internalStore.indexes.byType.get(component_type) || []\n } else {\n elementsToFilter = soup.filter((e) => e.type === component_type)\n }\n\n // Apply remaining filters\n if (keys.length > 0) {\n return elementsToFilter.filter((e: any) =>\n keys.every((key) => e[key] === where[key]),\n ) as Extract<AnyCircuitElement, { type: typeof component_type }>[]\n }\n\n return elementsToFilter as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >[]\n },\n\n insert: (elm: any) => {\n internalStore.counts[component_type] ??= -1\n internalStore.counts[component_type]++\n const index = internalStore.counts[component_type]\n const newElm = {\n type: component_type,\n [`${component_type}_id`]: `${component_type}_${index}`,\n ...elm,\n }\n\n if (options.validateInserts) {\n const parser =\n (Soup as any)[component_type] ?? Soup.any_soup_element\n parser.parse(newElm)\n }\n\n soup.push(newElm)\n internalStore.editCount++\n\n // Update indexes with the new element\n const indexConfig = options.indexConfig || {}\n\n // Update ID index\n if (indexConfig.byId && internalStore.indexes.byId) {\n const idKey = createIdKey(newElm)\n internalStore.indexes.byId.set(idKey, newElm)\n }\n\n // Update type index\n if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n elementsOfType.push(newElm)\n internalStore.indexes.byType.set(component_type, elementsOfType)\n }\n\n // Update relation index\n if (indexConfig.byRelation && internalStore.indexes.byRelation) {\n const elementEntries = Object.entries(newElm)\n for (const [key, value] of elementEntries) {\n if (\n key.endsWith(\"_id\") &&\n key !== `${newElm.type}_id` &&\n typeof value === \"string\"\n ) {\n const relationTypeMap =\n internalStore.indexes.byRelation.get(key) || new Map()\n const relatedElements =\n relationTypeMap.get(value as string) || []\n relatedElements.push(newElm)\n relationTypeMap.set(value as string, relatedElements)\n internalStore.indexes.byRelation.set(key, relationTypeMap)\n }\n }\n }\n\n // Update subcircuit index\n if (\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit &&\n \"subcircuit_id\" in newElm\n ) {\n const subcircuitId = (newElm as any).subcircuit_id\n if (subcircuitId && typeof subcircuitId === \"string\") {\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(subcircuitId) || []\n subcircuitElements.push(newElm)\n internalStore.indexes.bySubcircuit.set(\n subcircuitId,\n subcircuitElements,\n )\n }\n }\n\n // Update custom field indexes\n if (\n indexConfig.byCustomField &&\n internalStore.indexes.byCustomField\n ) {\n for (const field of indexConfig.byCustomField) {\n if (field in newElm) {\n const fieldValue = (newElm as any)[field]\n if (\n fieldValue !== undefined &&\n (typeof fieldValue === \"string\" ||\n typeof fieldValue === \"number\")\n ) {\n const fieldValueStr = String(fieldValue)\n const fieldMap =\n internalStore.indexes.byCustomField.get(field)!\n const elementsWithFieldValue =\n fieldMap.get(fieldValueStr) || []\n elementsWithFieldValue.push(newElm)\n fieldMap.set(fieldValueStr, elementsWithFieldValue)\n }\n }\n }\n }\n\n return newElm\n },\n\n delete: (id: string) => {\n const indexConfig = options.indexConfig || {}\n let elm: AnyCircuitElement | undefined\n\n // Find the element to delete\n if (indexConfig.byId && internalStore.indexes.byId) {\n elm = internalStore.indexes.byId.get(`${component_type}:${id}`)\n } else if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n elm = elementsOfType.find(\n (e: any) => e[`${component_type}_id`] === id,\n )\n } else {\n elm = soup.find((e) => (e as any)[`${component_type}_id`] === id)\n }\n\n if (!elm) return\n\n // Remove from array\n const elmIndex = soup.indexOf(elm)\n if (elmIndex >= 0) {\n soup.splice(elmIndex, 1)\n internalStore.editCount++\n }\n\n // Remove from indexes\n if (indexConfig.byId && internalStore.indexes.byId) {\n const idKey = createIdKey(elm)\n internalStore.indexes.byId.delete(idKey)\n }\n\n if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n const filteredElements = elementsOfType.filter(\n (e: any) => e[`${component_type}_id`] !== id,\n )\n internalStore.indexes.byType.set(component_type, filteredElements)\n }\n\n if (indexConfig.byRelation && internalStore.indexes.byRelation) {\n // This is more complex - we need to find and remove from all relation maps\n // where this element appears\n for (const [\n relationKey,\n relationMap,\n ] of internalStore.indexes.byRelation.entries()) {\n for (const [relationValue, elements] of relationMap.entries()) {\n const updatedElements = elements.filter((e) => e !== elm)\n\n if (updatedElements.length === 0) {\n relationMap.delete(relationValue)\n } else {\n relationMap.set(relationValue, updatedElements)\n }\n }\n }\n }\n\n if (\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit &&\n \"subcircuit_id\" in elm\n ) {\n const subcircuitId = (elm as any).subcircuit_id\n if (subcircuitId) {\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(subcircuitId) || []\n const updatedElements = subcircuitElements.filter(\n (e) => e !== elm,\n )\n\n if (updatedElements.length === 0) {\n internalStore.indexes.bySubcircuit.delete(subcircuitId)\n } else {\n internalStore.indexes.bySubcircuit.set(\n subcircuitId,\n updatedElements,\n )\n }\n }\n }\n\n if (\n indexConfig.byCustomField &&\n internalStore.indexes.byCustomField\n ) {\n for (const fieldMap of internalStore.indexes.byCustomField.values()) {\n for (const [fieldValue, elements] of fieldMap.entries()) {\n const updatedElements = elements.filter((e) => e !== elm)\n\n if (updatedElements.length === 0) {\n fieldMap.delete(fieldValue)\n } else {\n fieldMap.set(fieldValue, updatedElements)\n }\n }\n }\n }\n },\n\n update: (id: string, newProps: any) => {\n const indexConfig = options.indexConfig || {}\n let elm: AnyCircuitElement | undefined | null\n\n // Find the element to update\n if (indexConfig.byId && internalStore.indexes.byId) {\n elm = internalStore.indexes.byId.get(`${component_type}:${id}`)\n } else if (indexConfig.byType && internalStore.indexes.byType) {\n const elementsOfType =\n internalStore.indexes.byType.get(component_type) || []\n elm = elementsOfType.find(\n (e: any) => e[`${component_type}_id`] === id,\n )\n } else {\n elm = soup.find(\n (e) =>\n e.type === component_type &&\n (e as any)[`${component_type}_id`] === id,\n )\n }\n\n if (!elm) return null\n\n // Need to remove from indexes before updating\n if (indexConfig.byRelation && internalStore.indexes.byRelation) {\n // Remove from relation indexes\n const elementEntries = Object.entries(elm)\n for (const [key, value] of elementEntries) {\n if (\n key.endsWith(\"_id\") &&\n key !== `${elm.type}_id` &&\n typeof value === \"string\"\n ) {\n if (key in newProps && newProps[key] !== value) {\n const relationTypeMap =\n internalStore.indexes.byRelation.get(key)\n if (relationTypeMap) {\n const relatedElements =\n relationTypeMap.get(value as string) || []\n const updatedElements = relatedElements.filter(\n (e) => e !== elm,\n )\n\n if (updatedElements.length === 0) {\n relationTypeMap.delete(value as string)\n } else {\n relationTypeMap.set(value as string, updatedElements)\n }\n }\n }\n }\n }\n }\n\n if (\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit &&\n \"subcircuit_id\" in elm &&\n \"subcircuit_id\" in newProps\n ) {\n const oldSubcircuitId = (elm as any).subcircuit_id\n const newSubcircuitId = newProps.subcircuit_id\n\n if (oldSubcircuitId !== newSubcircuitId) {\n // Remove from old subcircuit index\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(oldSubcircuitId) || []\n const updatedElements = subcircuitElements.filter(\n (e) => e !== elm,\n )\n\n if (updatedElements.length === 0) {\n internalStore.indexes.bySubcircuit.delete(oldSubcircuitId)\n } else {\n internalStore.indexes.bySubcircuit.set(\n oldSubcircuitId,\n updatedElements,\n )\n }\n }\n }\n\n if (\n indexConfig.byCustomField &&\n internalStore.indexes.byCustomField\n ) {\n for (const field of indexConfig.byCustomField) {\n if (\n field in elm &&\n field in newProps &&\n (elm as any)[field] !== newProps[field]\n ) {\n const fieldMap =\n internalStore.indexes.byCustomField.get(field)\n if (fieldMap) {\n const oldValue = String((elm as any)[field])\n const elements = fieldMap.get(oldValue) || []\n const updatedElements = elements.filter((e) => e !== elm)\n\n if (updatedElements.length === 0) {\n fieldMap.delete(oldValue)\n } else {\n fieldMap.set(oldValue, updatedElements)\n }\n }\n }\n }\n }\n\n // Update the element\n Object.assign(elm, newProps)\n internalStore.editCount++\n\n // Add to indexes with updated values\n if (indexConfig.byRelation && internalStore.indexes.byRelation) {\n const elementEntries = Object.entries(elm)\n for (const [key, value] of elementEntries) {\n if (\n key.endsWith(\"_id\") &&\n key !== `${elm.type}_id` &&\n typeof value === \"string\"\n ) {\n if (key in newProps) {\n const relationTypeMap: any =\n internalStore.indexes.byRelation.get(key) || new Map()\n const relatedElements: any =\n relationTypeMap.get(value as string) || []\n\n if (!relatedElements.includes(elm)) {\n relatedElements.push(elm)\n relationTypeMap.set(value as string, relatedElements)\n internalStore.indexes.byRelation.set(key, relationTypeMap)\n }\n }\n }\n }\n }\n\n if (\n indexConfig.bySubcircuit &&\n internalStore.indexes.bySubcircuit &&\n \"subcircuit_id\" in elm &&\n \"subcircuit_id\" in newProps\n ) {\n const subcircuitId = (elm as any).subcircuit_id\n if (subcircuitId && typeof subcircuitId === \"string\") {\n const subcircuitElements =\n internalStore.indexes.bySubcircuit.get(subcircuitId) || []\n\n if (!subcircuitElements.includes(elm)) {\n subcircuitElements.push(elm)\n internalStore.indexes.bySubcircuit.set(\n subcircuitId,\n subcircuitElements,\n )\n }\n }\n }\n\n if (\n indexConfig.byCustomField &&\n internalStore.indexes.byCustomField\n ) {\n for (const field of indexConfig.byCustomField) {\n if (field in elm && field in newProps) {\n const fieldValue: any = (elm as any)[field]\n if (\n fieldValue !== undefined &&\n (typeof fieldValue === \"string\" ||\n typeof fieldValue === \"number\")\n ) {\n const fieldValueStr = String(fieldValue)\n const fieldMap =\n internalStore.indexes.byCustomField.get(field)!\n const elementsWithFieldValue =\n fieldMap.get(fieldValueStr) || []\n\n if (!elementsWithFieldValue.includes(elm)) {\n elementsWithFieldValue.push(elm)\n fieldMap.set(fieldValueStr, elementsWithFieldValue)\n }\n }\n }\n }\n }\n\n return elm as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >\n },\n\n select: (selector: string) => {\n // Selection by selector is specialized enough that we don't use indexes here\n // TODO when applySelector is isolated we can use it, until then we\n // do a poor man's selector implementation for two common cases\n if (component_type === \"source_component\") {\n return (\n (soup.find(\n (e) =>\n e.type === \"source_component\" &&\n e.name === selector.replace(/\\./g, \"\"),\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n } else if (\n component_type === \"pcb_port\" ||\n component_type === \"source_port\" ||\n component_type === \"schematic_port\"\n ) {\n const [component_name, port_selector] = selector\n .replace(/\\./g, \"\")\n .split(/[\\s\\>]+/)\n const source_component = soup.find(\n (e) =>\n e.type === \"source_component\" && e.name === component_name,\n ) as SourceComponentBase\n if (!source_component) return null\n const source_port = soup.find(\n (e) =>\n e.type === \"source_port\" &&\n e.source_component_id ===\n source_component.source_component_id &&\n (e.name === port_selector ||\n (e.port_hints ?? []).includes(port_selector!)),\n ) as SourcePort\n if (!source_port) return null\n if (component_type === \"source_port\")\n return source_port as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >\n\n if (component_type === \"pcb_port\") {\n return (\n (soup.find(\n (e) =>\n e.type === \"pcb_port\" &&\n e.source_port_id === source_port.source_port_id,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n } else if (component_type === \"schematic_port\") {\n return (\n (soup.find(\n (e) =>\n e.type === \"schematic_port\" &&\n e.source_port_id === source_port.source_port_id,\n ) as Extract<\n AnyCircuitElement,\n { type: typeof component_type }\n >) || null\n )\n }\n }\n\n return null\n },\n }\n },\n },\n )\n\n return suIndexed\n}) as any\n\ncjuIndexed.unparsed = cjuIndexed as any\n\nexport default cjuIndexed\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { type Matrix, applyToPoint, decomposeTSR } from \"transformation-matrix\"\nimport {\n directionToVec,\n rotateDirection,\n vecToDirection,\n} from \"./direction-to-vec\"\n\nexport const transformSchematicElement = (\n elm: AnyCircuitElement,\n matrix: Matrix,\n) => {\n if (elm.type === \"schematic_component\") {\n // TODO handle rotation\n elm.center = applyToPoint(matrix, elm.center)\n } else if (elm.type === \"schematic_port\") {\n elm.center = applyToPoint(matrix, elm.center)\n\n if (elm.facing_direction) {\n elm.facing_direction = rotateDirection(\n elm.facing_direction,\n -(Math.atan2(matrix.b, matrix.a) / Math.PI) * 2,\n )\n }\n } else if (elm.type === \"schematic_text\") {\n elm.position = applyToPoint(matrix, elm.position)\n // } else if (elm.type === \"schematic_group\") {\n // elm.center = applyToPoint(matrix, elm.center)\n } else if (elm.type === \"schematic_trace\") {\n const anyElm = elm as any\n anyElm.route = (anyElm.route ?? []).map((rp: any) => {\n const tp = applyToPoint(matrix, rp) as { x: number; y: number }\n rp.x = tp.x\n rp.y = tp.y\n return rp\n })\n if (Array.isArray(anyElm.junctions)) {\n anyElm.junctions = anyElm.junctions.map((j: any) => {\n const tp = applyToPoint(matrix, j) as { x: number; y: number }\n j.x = tp.x\n j.y = tp.y\n return j\n })\n }\n if (Array.isArray(anyElm.edges)) {\n anyElm.edges = anyElm.edges.map((e: any) => {\n e.from = applyToPoint(matrix, e.from)\n e.to = applyToPoint(matrix, e.to)\n return e\n })\n }\n } else if (elm.type === \"schematic_box\") {\n const { x, y } = applyToPoint(matrix, { x: elm.x, y: elm.y })\n elm.x = x\n elm.y = y\n } else if (elm.type === \"schematic_line\") {\n const { x: x1, y: y1 } = applyToPoint(matrix, { x: elm.x1, y: elm.y1 })\n const { x: x2, y: y2 } = applyToPoint(matrix, { x: elm.x2, y: elm.y2 })\n elm.x1 = x1\n elm.y1 = y1\n elm.x2 = x2\n elm.y2 = y2\n }\n return elm\n}\n\nexport const transformSchematicElements = (\n elms: AnyCircuitElement[],\n matrix: Matrix,\n) => {\n return elms.map((elm) => transformSchematicElement(elm, matrix))\n}\n\nexport const transformPCBElement = (elm: AnyCircuitElement, matrix: Matrix) => {\n const tsr = decomposeTSR(matrix)\n const flipPadWidthHeight =\n Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1\n if (\n elm.type === \"pcb_plated_hole\" ||\n elm.type === \"pcb_hole\" ||\n elm.type === \"pcb_via\" ||\n elm.type === \"pcb_smtpad\" ||\n elm.type === \"pcb_port\"\n ) {\n const { x, y } = applyToPoint(matrix, {\n x: Number((elm as any).x),\n y: Number((elm as any).y),\n })\n ;(elm as any).x = x\n ;(elm as any).y = y\n\n // Handle polygon-shaped SMT pads with points array\n if (\n elm.type === \"pcb_smtpad\" &&\n elm.shape === \"polygon\" &&\n Array.isArray(elm.points)\n ) {\n elm.points = elm.points.map((point: any) => {\n const tp = applyToPoint(matrix, { x: point.x, y: point.y })\n return {\n x: tp.x,\n y: tp.y,\n }\n })\n }\n } else if (elm.type === \"pcb_keepout\" || elm.type === \"pcb_board\") {\n // TODO adjust size/rotation\n elm.center = applyToPoint(matrix, elm.center)\n } else if (\n elm.type === \"pcb_silkscreen_text\" ||\n elm.type === \"pcb_fabrication_note_text\" ||\n elm.type === \"pcb_note_text\"\n ) {\n elm.anchor_position = applyToPoint(matrix, elm.anchor_position)\n } else if (\n elm.type === \"pcb_silkscreen_circle\" ||\n elm.type === \"pcb_silkscreen_rect\" ||\n elm.type === \"pcb_note_rect\" ||\n elm.type === \"pcb_courtyard_rect\" ||\n elm.type === \"pcb_courtyard_circle\"\n ) {\n elm.center = applyToPoint(matrix, elm.center)\n } else if (elm.type === \"pcb_component\") {\n elm.center = applyToPoint(matrix, elm.center)\n elm.rotation = elm.rotation + (tsr.rotation.angle / Math.PI) * 180\n elm.rotation = elm.rotation % 360\n if (flipPadWidthHeight) {\n ;[elm.width, elm.height] = [elm.height, elm.width]\n }\n } else if (elm.type === \"pcb_courtyard_outline\") {\n elm.outline = elm.outline.map((p) => {\n const tp = applyToPoint(matrix, p) as { x: number; y: number }\n p.x = tp.x\n p.y = tp.y\n return p\n })\n } else if (elm.type === \"pcb_courtyard_polygon\") {\n elm.points = elm.points.map((p) => {\n const tp = applyToPoint(matrix, p) as { x: number; y: number }\n p.x = tp.x\n p.y = tp.y\n return p\n })\n } else if (\n elm.type === \"pcb_silkscreen_path\" ||\n elm.type === \"pcb_trace\" ||\n elm.type === \"pcb_fabrication_note_path\" ||\n elm.type === \"pcb_note_path\"\n ) {\n elm.route = elm.route.map((rp) => {\n const tp = applyToPoint(matrix, rp) as { x: number; y: number }\n rp.x = tp.x\n rp.y = tp.y\n return rp\n })\n } else if (\n elm.type === \"pcb_silkscreen_line\" ||\n elm.type === \"pcb_note_line\"\n ) {\n const p1 = { x: elm.x1, y: elm.y1 }\n const p2 = { x: elm.x2, y: elm.y2 }\n const p1t = applyToPoint(matrix, p1)\n const p2t = applyToPoint(matrix, p2)\n elm.x1 = p1t.x\n elm.y1 = p1t.y\n elm.x2 = p2t.x\n elm.y2 = p2t.y\n } else if (elm.type === \"cad_component\") {\n const newPos = applyToPoint(matrix, {\n x: elm.position.x,\n y: elm.position.y,\n })\n elm.position.x = newPos.x\n elm.position.y = newPos.y\n }\n return elm\n}\n\nexport const transformPCBElements = (\n elms: AnyCircuitElement[],\n matrix: Matrix,\n) => {\n const tsr = decomposeTSR(matrix)\n const quarterTurns = Math.round(tsr.rotation.angle / (Math.PI / 2))\n const flipPadWidthHeight = Math.abs(quarterTurns) % 2 === 1\n let transformedElms = elms.map((elm) => transformPCBElement(elm, matrix))\n if (flipPadWidthHeight) {\n transformedElms = transformedElms.map((elm) => {\n if (elm.type === \"pcb_smtpad\" && elm.shape === \"rect\") {\n ;[elm.width, elm.height] = [elm.height, elm.width]\n }\n return elm\n })\n }\n return transformedElms\n}\n","export const directionToVec = (direction: \"up\" | \"down\" | \"left\" | \"right\") => {\n if (direction === \"up\") return { x: 0, y: 1 }\n else if (direction === \"down\") return { x: 0, y: -1 }\n else if (direction === \"left\") return { x: -1, y: 0 }\n else if (direction === \"right\") return { x: 1, y: 0 }\n else throw new Error(\"Invalid direction\")\n}\n\nexport const vecToDirection = ({ x, y }: { x: number; y: number }) => {\n if (x > y) y = 0\n if (y > x) x = 0\n if (x > 0 && y === 0) return \"right\"\n else if (x < 0 && y === 0) return \"left\"\n else if (x === 0 && y > 0) return \"up\"\n else if (x === 0 && y < 0) return \"down\"\n else throw new Error(`Invalid vector for direction conversion (${x}, ${y})`)\n}\n\nexport const rotateClockwise = (\n direction: \"up\" | \"down\" | \"left\" | \"right\",\n) => {\n if (direction === \"up\") return \"right\"\n else if (direction === \"right\") return \"down\"\n else if (direction === \"down\") return \"left\"\n else if (direction === \"left\") return \"up\"\n throw new Error(`Invalid direction: ${direction}`)\n}\n\nexport const rotateCounterClockwise = (\n direction: \"up\" | \"down\" | \"left\" | \"right\",\n) => {\n if (direction === \"up\") return \"left\"\n else if (direction === \"left\") return \"down\"\n else if (direction === \"down\") return \"right\"\n else if (direction === \"right\") return \"up\"\n throw new Error(`Invalid direction: ${direction}`)\n}\n\nexport const rotateDirection = (\n direction: \"up\" | \"down\" | \"left\" | \"right\",\n num90DegreeClockwiseTurns: number,\n) => {\n while (num90DegreeClockwiseTurns > 0) {\n direction = rotateClockwise(direction)\n num90DegreeClockwiseTurns--\n }\n while (num90DegreeClockwiseTurns < 0) {\n direction = rotateCounterClockwise(direction)\n num90DegreeClockwiseTurns++\n }\n return direction\n}\n\nexport const oppositeDirection = (\n direction: \"up\" | \"down\" | \"left\" | \"right\",\n) => {\n if (direction === \"up\") return \"down\"\n else if (direction === \"down\") return \"up\"\n else if (direction === \"left\") return \"right\"\n else if (direction === \"right\") return \"left\"\n throw new Error(`Invalid direction: ${direction}`)\n}\n\nexport const oppositeSide = (\n sideOrDir: \"up\" | \"down\" | \"top\" | \"bottom\" | \"left\" | \"right\",\n) => {\n if (sideOrDir === \"top\" || sideOrDir === \"up\") return \"bottom\"\n else if (sideOrDir === \"bottom\" || sideOrDir === \"down\") return \"top\"\n else if (sideOrDir === \"left\") return \"right\"\n else if (sideOrDir === \"right\") return \"left\"\n throw new Error(`Invalid sideOrDir: ${sideOrDir}`)\n}\n","import * as parsel from \"parsel-js\"\nimport { convertAbbrToType } from \"./convert-abbreviation-to-soup-element-type\"\nimport type { AnyCircuitElement } from \"circuit-json\"\n\nconst filterByType = (\n elements: AnyCircuitElement[],\n type: string,\n): AnyCircuitElement[] => {\n type = convertAbbrToType(type)\n return elements.filter(\n (elm) => (\"ftype\" in elm && elm.ftype === type) || elm.type === type,\n )\n}\n\n/**\n * Filter elements to match the selector, e.g. to access the left port of a\n * resistor you can do \".R1 > port.left\"\n */\nexport const applySelector = (\n elements: AnyCircuitElement[],\n selectorRaw: string,\n): AnyCircuitElement[] => {\n const selectorAST = parsel.parse(selectorRaw)\n return applySelectorAST(elements, selectorAST!)\n}\n\nconst doesElmMatchClassName = (elm: AnyCircuitElement, className: string) =>\n (\"name\" in elm && elm.name === className) ||\n (\"port_hints\" in elm && elm.port_hints?.includes(className))\n\nexport const applySelectorAST = (\n elements: AnyCircuitElement[],\n selectorAST: parsel.AST,\n): AnyCircuitElement[] => {\n switch (selectorAST.type) {\n case \"complex\": {\n switch (selectorAST.combinator) {\n case \" \": // TODO technically should do a deep search\n case \">\": {\n const { left, right } = selectorAST\n if (left.type === \"class\" || left.type === \"type\") {\n // TODO should also check if content matches any element tags\n let matchElms: AnyCircuitElement[]\n if (left.type === \"class\") {\n matchElms = elements.filter((elm) =>\n doesElmMatchClassName(elm, left.name),\n )\n } else if (left.type === \"type\") {\n matchElms = filterByType(elements, left.name)\n } else {\n matchElms = []\n }\n\n const childrenOfMatchingElms = matchElms.flatMap((matchElm) =>\n elements.filter(\n (elm: any) =>\n elm[`${matchElm.type}_id`] ===\n (matchElm as any)[`${matchElm.type}_id`] &&\n elm !== matchElm,\n ),\n )\n return applySelectorAST(childrenOfMatchingElms, right)\n } else {\n throw new Error(`unsupported selector type \"${left.type}\" `)\n }\n }\n default: {\n throw new Error(\n `Couldn't apply selector AST for complex combinator \"${selectorAST.combinator}\"`,\n )\n }\n }\n return []\n }\n case \"compound\": {\n const conditionsToMatch = selectorAST.list.map((part) => {\n switch (part.type) {\n case \"class\": {\n return (elm: any) => doesElmMatchClassName(elm, part.name)\n }\n case \"type\": {\n const name = convertAbbrToType(part.name)\n return (elm: any) => elm.type === name\n }\n }\n })\n\n return elements.filter((elm) =>\n conditionsToMatch.every((condFn) => condFn?.(elm)),\n )\n }\n case \"type\": {\n return filterByType(elements, selectorAST.name) as AnyCircuitElement[]\n }\n case \"class\": {\n return elements.filter((elm) =>\n doesElmMatchClassName(elm, selectorAST.name),\n )\n }\n default: {\n throw new Error(\n `Couldn't apply selector AST for type: \"${\n selectorAST.type\n }\" ${JSON.stringify(selectorAST, null, \" \")}`,\n )\n }\n }\n}\n","export const convertAbbrToType = (abbr: string): string => {\n switch (abbr) {\n case \"port\":\n return \"source_port\"\n case \"net\":\n return \"source_net\"\n case \"power\":\n return \"simple_power_source\"\n case \"silkscreenpath\":\n return \"pcb_silkscreen_path\"\n }\n return abbr\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\n\nexport const getElementId = (elm: AnyCircuitElement): string => {\n const type = elm.type\n const id = (elm as any)[`${type}_id`]\n return id\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { getElementId } from \"./get-element-id\"\n\nexport const getElementById = (\n soup: AnyCircuitElement[],\n id: string,\n): AnyCircuitElement | null => {\n return soup.find((elm) => getElementId(elm) === id) ?? null\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { cju } from \"../cju\"\n\nexport function getReadableNameForPcbTrace(\n soup: AnyCircuitElement[],\n pcb_trace_id: string,\n) {\n // Find the pcb_trace object\n const pcbTrace = cju(soup).pcb_trace.get(pcb_trace_id)\n\n if (!pcbTrace) {\n return `trace[${pcb_trace_id}]`\n }\n\n // Get the connected ports\n const connectedPcbPortIds: string[] = pcbTrace.route\n .flatMap((point: any) => [point.start_pcb_port_id, point.end_pcb_port_id])\n .filter(Boolean)\n\n if (connectedPcbPortIds.length === 0) {\n return `trace[${pcb_trace_id}]`\n }\n\n // Function to get component name and port hint\n function getComponentAndPortInfo(pcb_port_id: string) {\n const pcbPort = cju(soup).pcb_port.get(pcb_port_id)\n if (!pcbPort) return null\n\n const pcbComponent = pcbPort.pcb_component_id\n ? cju(soup).pcb_component.get(pcbPort.pcb_component_id)\n : undefined\n if (!pcbComponent) return null\n const sourceComponent = cju(soup).source_component.get(\n pcbComponent.source_component_id,\n )\n if (!sourceComponent) return null\n\n const sourcePort = cju(soup).source_port.get(pcbPort.source_port_id)\n const portHint = sourcePort?.port_hints ? sourcePort.port_hints[1] : \"\"\n\n return {\n componentName: sourceComponent.name,\n portHint: portHint,\n }\n }\n\n // Generate the readable selector\n const selectorParts = connectedPcbPortIds.map((portId) => {\n const info = getComponentAndPortInfo(portId)\n if (info) {\n return `.${info.componentName} > port.${info.portHint}`\n }\n return `port[${portId}]`\n })\n\n return `trace[${selectorParts.join(\", \")}]`\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { cju } from \"../cju\"\n\nexport const getReadableNameForPcbPort = (\n soup: AnyCircuitElement[],\n pcb_port_id: string,\n): string => {\n const pcbPort = cju(soup).pcb_port.get(pcb_port_id)\n if (!pcbPort) {\n return `pcb_port[#${pcb_port_id}]`\n }\n\n // Get the component information\n const pcbComponent = pcbPort.pcb_component_id\n ? cju(soup).pcb_component.get(pcbPort.pcb_component_id)\n : undefined\n\n if (!pcbComponent) {\n return `pcb_port[#${pcb_port_id}]`\n }\n\n // Get the source component information\n const sourceComponent = cju(soup).source_component.get(\n pcbComponent.source_component_id,\n )\n\n if (!sourceComponent) {\n return `pcb_port[#${pcb_port_id}]`\n }\n\n // Get the source port information\n const sourcePort = cju(soup).source_port.get(pcbPort.source_port_id)\n\n if (!sourcePort) {\n return `pcb_port[#${pcb_port_id}]`\n }\n\n // Determine the pad number or hint\n let padIdentifier: string\n if (sourcePort?.port_hints && sourcePort.port_hints.length > 0) {\n padIdentifier = sourcePort.port_hints[0]!\n } else if (sourcePort.port_hints && sourcePort.port_hints.length > 0) {\n padIdentifier = sourcePort.port_hints[0]!\n } else {\n padIdentifier = pcb_port_id\n }\n\n return `pcb_port[.${sourceComponent.name} > .${padIdentifier}]`\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { cju } from \"../cju\"\nimport { getReadableNameForPcbPort } from \"./get-readable-name-for-pcb-port\"\n\nexport function getReadableNameForPcbSmtpad(\n soup: AnyCircuitElement[],\n pcb_smtpad_id: string,\n): string {\n // Find the pcb_smtpad object\n const pcbSmtpad = cju(soup).pcb_smtpad.get(pcb_smtpad_id)\n\n if (!pcbSmtpad || !pcbSmtpad.pcb_port_id) {\n return `smtpad[${pcb_smtpad_id}]`\n }\n\n return getReadableNameForPcbPort(soup, pcbSmtpad.pcb_port_id)\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { getReadableNameForPcbTrace } from \"./get-readable-name-for-pcb-trace\"\nimport { getReadableNameForPcbSmtpad } from \"./get-readable-name-for-pcb-smtpad\"\nimport { getReadableNameForPcbPort } from \"./get-readable-name-for-pcb-port\"\nimport { getElementById } from \"lib/get-element-by-id\"\nimport { getElementId } from \"lib/get-element-id\"\n\nexport const getReadableNameForElement = (\n soup: AnyCircuitElement[],\n elm: AnyCircuitElement | string,\n): string => {\n if (typeof elm === \"string\") {\n const elmObj = getElementById(soup, elm)\n if (!elmObj) `unknown (could not find element with id ${elm})`\n return getReadableNameForElement(soup, elmObj as any)\n }\n switch (elm.type) {\n case \"pcb_port\":\n return getReadableNameForPcbPort(soup, elm.pcb_port_id)\n case \"pcb_smtpad\":\n return getReadableNameForPcbSmtpad(soup, elm.pcb_smtpad_id)\n case \"pcb_trace\":\n return getReadableNameForPcbTrace(soup, elm.pcb_trace_id)\n case \"source_component\":\n return `source_component[${elm.name}]`\n default:\n return `${elm.type}[#${getElementId(elm)}]`\n }\n}\n\nexport {\n getReadableNameForPcbPort,\n getReadableNameForPcbSmtpad,\n getReadableNameForPcbTrace,\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\n\nconst mergeBounds = (\n currentBounds: {\n minX: number\n minY: number\n maxX: number\n maxY: number\n },\n nextBounds: {\n minX: number\n minY: number\n maxX: number\n maxY: number\n },\n) => ({\n minX: Math.min(currentBounds.minX, nextBounds.minX),\n minY: Math.min(currentBounds.minY, nextBounds.minY),\n maxX: Math.max(currentBounds.maxX, nextBounds.maxX),\n maxY: Math.max(currentBounds.maxY, nextBounds.maxY),\n})\n\nconst getCircleBounds = (x: number, y: number, diameter: number) => {\n const radius = diameter / 2\n return {\n minX: x - radius,\n minY: y - radius,\n maxX: x + radius,\n maxY: y + radius,\n }\n}\n\nconst getRotatedRectBounds = (\n x: number,\n y: number,\n width: number,\n height: number,\n rotationDegrees: number,\n) => {\n const halfWidth = width / 2\n const halfHeight = height / 2\n const theta = (rotationDegrees * Math.PI) / 180\n const cosTheta = Math.cos(theta)\n const sinTheta = Math.sin(theta)\n\n const corners = [\n { x: -halfWidth, y: -halfHeight },\n { x: halfWidth, y: -halfHeight },\n { x: halfWidth, y: halfHeight },\n { x: -halfWidth, y: halfHeight },\n ].map((corner) => ({\n x: x + corner.x * cosTheta - corner.y * sinTheta,\n y: y + corner.x * sinTheta + corner.y * cosTheta,\n }))\n\n return {\n minX: Math.min(...corners.map((corner) => corner.x)),\n minY: Math.min(...corners.map((corner) => corner.y)),\n maxX: Math.max(...corners.map((corner) => corner.x)),\n maxY: Math.max(...corners.map((corner) => corner.y)),\n }\n}\n\nexport const getBoundsOfPcbElements = (\n elements: AnyCircuitElement[],\n): { minX: number; minY: number; maxX: number; maxY: number } => {\n let minX = Number.POSITIVE_INFINITY\n let minY = Number.POSITIVE_INFINITY\n let maxX = Number.NEGATIVE_INFINITY\n let maxY = Number.NEGATIVE_INFINITY\n\n for (const elm of elements) {\n if (!elm.type.startsWith(\"pcb_\")) continue\n\n // Handle polygon-shaped SMT pads with points array\n if (\n elm.type === \"pcb_smtpad\" &&\n elm.shape === \"polygon\" &&\n Array.isArray(elm.points)\n ) {\n for (const point of elm.points) {\n minX = Math.min(minX, point.x)\n minY = Math.min(minY, point.y)\n maxX = Math.max(maxX, point.x)\n maxY = Math.max(maxY, point.y)\n }\n continue\n }\n\n if (elm.type === \"pcb_hole\" && elm.hole_shape === \"circle\") {\n const holeBounds = getCircleBounds(elm.x, elm.y, elm.hole_diameter)\n minX = Math.min(minX, holeBounds.minX)\n minY = Math.min(minY, holeBounds.minY)\n maxX = Math.max(maxX, holeBounds.maxX)\n maxY = Math.max(maxY, holeBounds.maxY)\n continue\n }\n\n if (elm.type === \"pcb_plated_hole\") {\n let platedHoleBounds:\n | {\n minX: number\n minY: number\n maxX: number\n maxY: number\n }\n | undefined\n\n if (\"outer_diameter\" in elm && typeof elm.outer_diameter === \"number\") {\n platedHoleBounds = getCircleBounds(elm.x, elm.y, elm.outer_diameter)\n } else if (\n \"hole_diameter\" in elm &&\n typeof elm.hole_diameter === \"number\"\n ) {\n platedHoleBounds = getCircleBounds(elm.x, elm.y, elm.hole_diameter)\n }\n\n if (\n \"rect_pad_width\" in elm &&\n typeof elm.rect_pad_width === \"number\" &&\n \"rect_pad_height\" in elm &&\n typeof elm.rect_pad_height === \"number\"\n ) {\n const rectBounds = getRotatedRectBounds(\n elm.x,\n elm.y,\n elm.rect_pad_width,\n elm.rect_pad_height,\n \"rect_ccw_rotation\" in elm ? (elm.rect_ccw_rotation ?? 0) : 0,\n )\n platedHoleBounds = platedHoleBounds\n ? mergeBounds(platedHoleBounds, rectBounds)\n : rectBounds\n }\n\n if (\"hole_diameter\" in elm && typeof elm.hole_diameter === \"number\") {\n const drillBounds = getCircleBounds(\n elm.x +\n (\"hole_offset_x\" in elm ? ((elm.hole_offset_x as number) ?? 0) : 0),\n elm.y +\n (\"hole_offset_y\" in elm ? ((elm.hole_offset_y as number) ?? 0) : 0),\n elm.hole_diameter,\n )\n platedHoleBounds = platedHoleBounds\n ? mergeBounds(platedHoleBounds, drillBounds)\n : drillBounds\n }\n\n if (platedHoleBounds) {\n minX = Math.min(minX, platedHoleBounds.minX)\n minY = Math.min(minY, platedHoleBounds.minY)\n maxX = Math.max(maxX, platedHoleBounds.maxX)\n maxY = Math.max(maxY, platedHoleBounds.maxY)\n continue\n }\n }\n\n let centerX: number | undefined\n let centerY: number | undefined\n\n let width: number | undefined\n let height: number | undefined\n\n if (\"x\" in elm && \"y\" in elm) {\n centerX = Number((elm as any).x)\n centerY = Number((elm as any).y)\n }\n\n if (\"outer_diameter\" in elm) {\n width = Number((elm as any).outer_diameter)\n height = Number((elm as any).outer_diameter)\n }\n\n if (\"width\" in elm) {\n width = Number((elm as any).width)\n }\n\n if (\"height\" in elm) {\n height = Number((elm as any).height)\n }\n\n if (\"center\" in elm) {\n // @ts-ignore\n centerX = elm.center.x\n // @ts-ignore\n centerY = elm.center.y\n }\n\n if (centerX !== undefined && centerY !== undefined) {\n minX = Math.min(minX, centerX)\n minY = Math.min(minY, centerY)\n maxX = Math.max(maxX, centerX)\n maxY = Math.max(maxY, centerY)\n\n if (width !== undefined && height !== undefined) {\n minX = Math.min(minX, centerX - width / 2)\n minY = Math.min(minY, centerY - height / 2)\n maxX = Math.max(maxX, centerX + width / 2)\n maxY = Math.max(maxY, centerY + height / 2)\n }\n\n if (\"radius\" in elm) {\n minX = Math.min(minX, centerX - elm.radius)\n minY = Math.min(minY, centerY - elm.radius)\n maxX = Math.max(maxX, centerX + elm.radius)\n maxY = Math.max(maxY, centerY + elm.radius)\n }\n } else if (elm.type === \"pcb_trace\") {\n for (const point of elm.route) {\n // TODO add trace thickness support\n minX = Math.min(minX, point.x)\n minY = Math.min(minY, point.y)\n maxX = Math.max(maxX, point.x)\n maxY = Math.max(maxY, point.y)\n }\n } else if (elm.type === \"pcb_courtyard_outline\") {\n for (const point of elm.outline) {\n minX = Math.min(minX, point.x)\n minY = Math.min(minY, point.y)\n maxX = Math.max(maxX, point.x)\n maxY = Math.max(maxY, point.y)\n }\n } else if (elm.type === \"pcb_courtyard_polygon\") {\n for (const point of elm.points) {\n minX = Math.min(minX, point.x)\n minY = Math.min(minY, point.y)\n maxX = Math.max(maxX, point.x)\n maxY = Math.max(maxY, point.y)\n }\n }\n }\n\n return { minX, minY, maxX, maxY }\n}\n","import type { PcbBoard } from \"circuit-json\"\n\nexport interface BoardBounds {\n minX: number\n minY: number\n maxX: number\n maxY: number\n width: number\n height: number\n center: {\n x: number\n y: number\n }\n}\n\nexport const getBoardBounds = (board: PcbBoard): BoardBounds => {\n if (board.width && board.height && board.center) {\n const halfWidth = board.width / 2\n const halfHeight = board.height / 2\n\n return {\n minX: board.center.x - halfWidth,\n minY: board.center.y - halfHeight,\n maxX: board.center.x + halfWidth,\n maxY: board.center.y + halfHeight,\n width: board.width,\n height: board.height,\n center: {\n x: board.center.x,\n y: board.center.y,\n },\n }\n }\n\n if (!board.outline || board.outline.length === 0) {\n throw new Error(\n \"Unable to compute board bounds. pcb_board must include width/height/center or a non-empty outline.\",\n )\n }\n\n let minX = Number.POSITIVE_INFINITY\n let minY = Number.POSITIVE_INFINITY\n let maxX = Number.NEGATIVE_INFINITY\n let maxY = Number.NEGATIVE_INFINITY\n\n for (const point of board.outline) {\n minX = Math.min(minX, point.x)\n minY = Math.min(minY, point.y)\n maxX = Math.max(maxX, point.x)\n maxY = Math.max(maxY, point.y)\n }\n\n const width = maxX - minX\n const height = maxY - minY\n\n return {\n minX,\n minY,\n maxX,\n maxY,\n width,\n height,\n center: {\n x: minX + width / 2,\n y: minY + height / 2,\n },\n }\n}\n","export function stringHash(str: string) {\n let hash = 0\n if (str.length == 0) return hash\n for (var i = 0; i < str.length; i++) {\n var char = str.charCodeAt(i)\n hash = (hash << 5) - hash + char\n hash = hash & hash // Convert to 32bit integer\n }\n return Math.abs(hash)\n}\n","import { stringHash } from \"./string-hash\"\n\nexport type LayoutDebugObject = {\n x: number\n y: number\n width: number\n height: number\n bg_color: string\n title: string\n content: Object\n secondary?: boolean\n}\n\n/**\n * Vendored from \"nice-color-palettes\" package\n */\nconst nice_color_palettes = [\n [\"#69d2e7\", \"#a7dbd8\", \"#e0e4cc\", \"#f38630\", \"#fa6900\"],\n [\"#fe4365\", \"#fc9d9a\", \"#f9cdad\", \"#c8c8a9\", \"#83af9b\"],\n [\"#ecd078\", \"#d95b43\", \"#c02942\", \"#542437\", \"#53777a\"],\n [\"#556270\", \"#4ecdc4\", \"#c7f464\", \"#ff6b6b\", \"#c44d58\"],\n [\"#774f38\", \"#e08e79\", \"#f1d4af\", \"#ece5ce\", \"#c5e0dc\"],\n [\"#e8ddcb\", \"#cdb380\", \"#036564\", \"#033649\", \"#031634\"],\n [\"#490a3d\", \"#bd1550\", \"#e97f02\", \"#f8ca00\", \"#8a9b0f\"],\n [\"#594f4f\", \"#547980\", \"#45ada8\", \"#9de0ad\", \"#e5fcc2\"],\n [\"#00a0b0\", \"#6a4a3c\", \"#cc333f\", \"#eb6841\", \"#edc951\"],\n [\"#e94e77\", \"#d68189\", \"#c6a49a\", \"#c6e5d9\", \"#f4ead5\"],\n [\"#3fb8af\", \"#7fc7af\", \"#dad8a7\", \"#ff9e9d\", \"#ff3d7f\"],\n [\"#d9ceb2\", \"#948c75\", \"#d5ded9\", \"#7a6a53\", \"#99b2b7\"],\n [\"#ffffff\", \"#cbe86b\", \"#f2e9e1\", \"#1c140d\", \"#cbe86b\"],\n [\"#efffcd\", \"#dce9be\", \"#555152\", \"#2e2633\", \"#99173c\"],\n [\"#343838\", \"#005f6b\", \"#008c9e\", \"#00b4cc\", \"#00dffc\"],\n [\"#413e4a\", \"#73626e\", \"#b38184\", \"#f0b49e\", \"#f7e4be\"],\n [\"#ff4e50\", \"#fc913a\", \"#f9d423\", \"#ede574\", \"#e1f5c4\"],\n [\"#99b898\", \"#fecea8\", \"#ff847c\", \"#e84a5f\", \"#2a363b\"],\n [\"#655643\", \"#80bca3\", \"#f6f7bd\", \"#e6ac27\", \"#bf4d28\"],\n [\"#00a8c6\", \"#40c0cb\", \"#f9f2e7\", \"#aee239\", \"#8fbe00\"],\n [\"#351330\", \"#424254\", \"#64908a\", \"#e8caa4\", \"#cc2a41\"],\n [\"#554236\", \"#f77825\", \"#d3ce3d\", \"#f1efa5\", \"#60b99a\"],\n [\"#5d4157\", \"#838689\", \"#a8caba\", \"#cad7b2\", \"#ebe3aa\"],\n [\"#8c2318\", \"#5e8c6a\", \"#88a65e\", \"#bfb35a\", \"#f2c45a\"],\n [\"#fad089\", \"#ff9c5b\", \"#f5634a\", \"#ed303c\", \"#3b8183\"],\n [\"#ff4242\", \"#f4fad2\", \"#d4ee5e\", \"#e1edb9\", \"#f0f2eb\"],\n [\"#f8b195\", \"#f67280\", \"#c06c84\", \"#6c5b7b\", \"#355c7d\"],\n [\"#d1e751\", \"#ffffff\", \"#000000\", \"#4dbce9\", \"#26ade4\"],\n [\"#1b676b\", \"#519548\", \"#88c425\", \"#bef202\", \"#eafde6\"],\n [\"#5e412f\", \"#fcebb6\", \"#78c0a8\", \"#f07818\", \"#f0a830\"],\n [\"#bcbdac\", \"#cfbe27\", \"#f27435\", \"#f02475\", \"#3b2d38\"],\n [\"#452632\", \"#91204d\", \"#e4844a\", \"#e8bf56\", \"#e2f7ce\"],\n [\"#eee6ab\", \"#c5bc8e\", \"#696758\", \"#45484b\", \"#36393b\"],\n [\"#f0d8a8\", \"#3d1c00\", \"#86b8b1\", \"#f2d694\", \"#fa2a00\"],\n [\"#2a044a\", \"#0b2e59\", \"#0d6759\", \"#7ab317\", \"#a0c55f\"],\n [\"#f04155\", \"#ff823a\", \"#f2f26f\", \"#fff7bd\", \"#95cfb7\"],\n [\"#b9d7d9\", \"#668284\", \"#2a2829\", \"#493736\", \"#7b3b3b\"],\n [\"#bbbb88\", \"#ccc68d\", \"#eedd99\", \"#eec290\", \"#eeaa88\"],\n [\"#b3cc57\", \"#ecf081\", \"#ffbe40\", \"#ef746f\", \"#ab3e5b\"],\n [\"#a3a948\", \"#edb92e\", \"#f85931\", \"#ce1836\", \"#009989\"],\n [\"#300030\", \"#480048\", \"#601848\", \"#c04848\", \"#f07241\"],\n [\"#67917a\", \"#170409\", \"#b8af03\", \"#ccbf82\", \"#e33258\"],\n [\"#aab3ab\", \"#c4cbb7\", \"#ebefc9\", \"#eee0b7\", \"#e8caaf\"],\n [\"#e8d5b7\", \"#0e2430\", \"#fc3a51\", \"#f5b349\", \"#e8d5b9\"],\n [\"#ab526b\", \"#bca297\", \"#c5ceae\", \"#f0e2a4\", \"#f4ebc3\"],\n [\"#607848\", \"#789048\", \"#c0d860\", \"#f0f0d8\", \"#604848\"],\n [\"#b6d8c0\", \"#c8d9bf\", \"#dadabd\", \"#ecdbbc\", \"#fedcba\"],\n [\"#a8e6ce\", \"#dcedc2\", \"#ffd3b5\", \"#ffaaa6\", \"#ff8c94\"],\n [\"#3e4147\", \"#fffedf\", \"#dfba69\", \"#5a2e2e\", \"#2a2c31\"],\n [\"#fc354c\", \"#29221f\", \"#13747d\", \"#0abfbc\", \"#fcf7c5\"],\n [\"#cc0c39\", \"#e6781e\", \"#c8cf02\", \"#f8fcc1\", \"#1693a7\"],\n [\"#1c2130\", \"#028f76\", \"#b3e099\", \"#ffeaad\", \"#d14334\"],\n [\"#a7c5bd\", \"#e5ddcb\", \"#eb7b59\", \"#cf4647\", \"#524656\"],\n [\"#dad6ca\", \"#1bb0ce\", \"#4f8699\", \"#6a5e72\", \"#563444\"],\n [\"#5c323e\", \"#a82743\", \"#e15e32\", \"#c0d23e\", \"#e5f04c\"],\n [\"#edebe6\", \"#d6e1c7\", \"#94c7b6\", \"#403b33\", \"#d3643b\"],\n [\"#fdf1cc\", \"#c6d6b8\", \"#987f69\", \"#e3ad40\", \"#fcd036\"],\n [\"#230f2b\", \"#f21d41\", \"#ebebbc\", \"#bce3c5\", \"#82b3ae\"],\n [\"#b9d3b0\", \"#81bda4\", \"#b28774\", \"#f88f79\", \"#f6aa93\"],\n [\"#3a111c\", \"#574951\", \"#83988e\", \"#bcdea5\", \"#e6f9bc\"],\n [\"#5e3929\", \"#cd8c52\", \"#b7d1a3\", \"#dee8be\", \"#fcf7d3\"],\n [\"#1c0113\", \"#6b0103\", \"#a30006\", \"#c21a01\", \"#f03c02\"],\n [\"#000000\", \"#9f111b\", \"#b11623\", \"#292c37\", \"#cccccc\"],\n [\"#382f32\", \"#ffeaf2\", \"#fcd9e5\", \"#fbc5d8\", \"#f1396d\"],\n [\"#e3dfba\", \"#c8d6bf\", \"#93ccc6\", \"#6cbdb5\", \"#1a1f1e\"],\n [\"#f6f6f6\", \"#e8e8e8\", \"#333333\", \"#990100\", \"#b90504\"],\n [\"#1b325f\", \"#9cc4e4\", \"#e9f2f9\", \"#3a89c9\", \"#f26c4f\"],\n [\"#a1dbb2\", \"#fee5ad\", \"#faca66\", \"#f7a541\", \"#f45d4c\"],\n [\"#c1b398\", \"#605951\", \"#fbeec2\", \"#61a6ab\", \"#accec0\"],\n [\"#5e9fa3\", \"#dcd1b4\", \"#fab87f\", \"#f87e7b\", \"#b05574\"],\n [\"#951f2b\", \"#f5f4d7\", \"#e0dfb1\", \"#a5a36c\", \"#535233\"],\n [\"#8dccad\", \"#988864\", \"#fea6a2\", \"#f9d6ac\", \"#ffe9af\"],\n [\"#2d2d29\", \"#215a6d\", \"#3ca2a2\", \"#92c7a3\", \"#dfece6\"],\n [\"#413d3d\", \"#040004\", \"#c8ff00\", \"#fa023c\", \"#4b000f\"],\n [\"#eff3cd\", \"#b2d5ba\", \"#61ada0\", \"#248f8d\", \"#605063\"],\n [\"#ffefd3\", \"#fffee4\", \"#d0ecea\", \"#9fd6d2\", \"#8b7a5e\"],\n [\"#cfffdd\", \"#b4dec1\", \"#5c5863\", \"#a85163\", \"#ff1f4c\"],\n [\"#9dc9ac\", \"#fffec7\", \"#f56218\", \"#ff9d2e\", \"#919167\"],\n [\"#4e395d\", \"#827085\", \"#8ebe94\", \"#ccfc8e\", \"#dc5b3e\"],\n [\"#a8a7a7\", \"#cc527a\", \"#e8175d\", \"#474747\", \"#363636\"],\n [\"#f8edd1\", \"#d88a8a\", \"#474843\", \"#9d9d93\", \"#c5cfc6\"],\n [\"#046d8b\", \"#309292\", \"#2fb8ac\", \"#93a42a\", \"#ecbe13\"],\n [\"#f38a8a\", \"#55443d\", \"#a0cab5\", \"#cde9ca\", \"#f1edd0\"],\n [\"#a70267\", \"#f10c49\", \"#fb6b41\", \"#f6d86b\", \"#339194\"],\n [\"#ff003c\", \"#ff8a00\", \"#fabe28\", \"#88c100\", \"#00c176\"],\n [\"#ffedbf\", \"#f7803c\", \"#f54828\", \"#2e0d23\", \"#f8e4c1\"],\n [\"#4e4d4a\", \"#353432\", \"#94ba65\", \"#2790b0\", \"#2b4e72\"],\n [\"#0ca5b0\", \"#4e3f30\", \"#fefeeb\", \"#f8f4e4\", \"#a5b3aa\"],\n [\"#4d3b3b\", \"#de6262\", \"#ffb88c\", \"#ffd0b3\", \"#f5e0d3\"],\n [\"#fffbb7\", \"#a6f6af\", \"#66b6ab\", \"#5b7c8d\", \"#4f2958\"],\n [\"#edf6ee\", \"#d1c089\", \"#b3204d\", \"#412e28\", \"#151101\"],\n [\"#9d7e79\", \"#ccac95\", \"#9a947c\", \"#748b83\", \"#5b756c\"],\n [\"#fcfef5\", \"#e9ffe1\", \"#cdcfb7\", \"#d6e6c3\", \"#fafbe3\"],\n [\"#9cddc8\", \"#bfd8ad\", \"#ddd9ab\", \"#f7af63\", \"#633d2e\"],\n [\"#30261c\", \"#403831\", \"#36544f\", \"#1f5f61\", \"#0b8185\"],\n [\"#aaff00\", \"#ffaa00\", \"#ff00aa\", \"#aa00ff\", \"#00aaff\"],\n [\"#d1313d\", \"#e5625c\", \"#f9bf76\", \"#8eb2c5\", \"#615375\"],\n [\"#ffe181\", \"#eee9e5\", \"#fad3b2\", \"#ffba7f\", \"#ff9c97\"],\n [\"#73c8a9\", \"#dee1b6\", \"#e1b866\", \"#bd5532\", \"#373b44\"],\n [\"#805841\", \"#dcf7f3\", \"#fffcdd\", \"#ffd8d8\", \"#f5a2a2\"],\n]\n\nexport const getDebugLayoutObject = (lo: any): LayoutDebugObject | null => {\n let {\n x,\n y,\n width,\n height,\n }: { x: number; y: number; width?: number; height?: number } = {\n ...lo,\n ...(lo as any).size,\n ...(lo as any).center,\n ...(lo as any).position,\n }\n\n if (\n lo.x1 !== undefined &&\n lo.x2 !== undefined &&\n lo.y1 !== undefined &&\n lo.y2 !== undefined\n ) {\n x = (lo.x1 + lo.x2) / 2\n y = (lo.y1 + lo.y2) / 2\n width = Math.abs(lo.x1 - lo.x2)\n height = Math.abs(lo.y1 - lo.y2)\n }\n\n if (lo.points && Array.isArray(lo.points) && lo.points.length > 0) {\n const xCoords = lo.points.map((point: { x: number }) => point.x)\n const yCoords = lo.points.map((point: { y: number }) => point.y)\n\n const minX = Math.min(...xCoords)\n const maxX = Math.max(...xCoords)\n const minY = Math.min(...yCoords)\n const maxY = Math.max(...yCoords)\n\n x = (minX + maxX) / 2\n y = (minY + maxY) / 2\n width = maxX - minX\n height = maxY - minY\n }\n\n const title = lo.text || lo.name || lo.source?.text || lo.source?.name || \"?\"\n const content = lo\n\n if (x === undefined || y === undefined) return null\n\n if (width === undefined) {\n if (\"outer_diameter\" in lo) {\n width = lo.outer_diameter\n height = lo.outer_diameter\n }\n }\n\n if (width === undefined || height === undefined) {\n width = 0.1\n height = 0.1\n }\n\n return {\n x,\n y,\n width,\n height,\n title,\n content,\n bg_color:\n nice_color_palettes[\n stringHash((lo as any).type || title) % nice_color_palettes.length\n ]?.[4] ?? \"#f00\",\n }\n}\n","export const isTruthy = <T>(value: T): value is NonNullable<T> => Boolean(value)\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { getDebugLayoutObject } from \"./utils/get-layout-debug-object\"\nimport { isTruthy } from \"./utils/is-truthy\"\n\nexport const findBoundsAndCenter = (\n elements: AnyCircuitElement[],\n): { center: { x: number; y: number }; width: number; height: number } => {\n const debugObjects = elements\n .filter(\n (elm) => elm.type.startsWith(\"pcb_\") || elm.type.startsWith(\"schematic_\"),\n )\n .concat(\n elements\n .filter(\n (elm) => elm.type === \"pcb_trace\" || elm.type === \"schematic_trace\",\n )\n // @ts-ignore\n .flatMap((elm: any) => elm.route),\n )\n .map((elm) => getDebugLayoutObject(elm))\n .filter(isTruthy)\n\n if (debugObjects.length === 0)\n return { center: { x: 0, y: 0 }, width: 0, height: 0 }\n\n let minX = debugObjects[0]!.x - debugObjects[0]!.width / 2\n let maxX = debugObjects[0]!.x + debugObjects[0]!.width / 2\n let minY = debugObjects[0]!.y - debugObjects[0]!.height / 2\n let maxY = debugObjects[0]!.y + debugObjects[0]!.height / 2\n\n for (const obj of debugObjects.slice(1)) {\n minX = Math.min(minX, obj.x - obj.width / 2)\n maxX = Math.max(maxX, obj.x + obj.width / 2)\n minY = Math.min(minY, obj.y - obj.height / 2)\n maxY = Math.max(maxY, obj.y + obj.height / 2)\n }\n\n const width = maxX - minX\n const height = maxY - minY\n const center = { x: minX + width / 2, y: minY + height / 2 }\n\n return { center, width, height }\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\n\nexport const getPrimaryId = (element: AnyCircuitElement): string => {\n // @ts-ignore\n return element[`${element.type}_id`]\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { transformPCBElements } from \"./transform-soup-elements\"\nimport { translate } from \"transformation-matrix\"\n\nexport const repositionPcbComponentTo = (\n circuitJson: AnyCircuitElement[],\n pcb_component_id: string,\n newCenter: { x: number; y: number },\n) => {\n const pcbComponent = circuitJson.find(\n (e) =>\n e.type === \"pcb_component\" &&\n (e as any).pcb_component_id === pcb_component_id,\n )\n if (!pcbComponent) return\n\n const currentCenter =\n \"center\" in pcbComponent\n ? (pcbComponent as any).center\n : { x: (pcbComponent as any).x, y: (pcbComponent as any).y }\n\n const dx = newCenter.x - currentCenter.x\n const dy = newCenter.y - currentCenter.y\n\n const portIds = circuitJson\n .filter(\n (e) =>\n e.type === \"pcb_port\" &&\n (e as any).pcb_component_id === pcb_component_id,\n )\n .map((e) => (e as any).pcb_port_id)\n\n const elementsToMove = circuitJson.filter((elm) => {\n if (elm === pcbComponent) return true\n const anyElm: any = elm\n if (anyElm.pcb_component_id === pcb_component_id) return true\n if (\n Array.isArray(anyElm.pcb_component_ids) &&\n anyElm.pcb_component_ids.includes(pcb_component_id)\n )\n return true\n if (anyElm.pcb_port_id && portIds.includes(anyElm.pcb_port_id)) return true\n if (\n Array.isArray(anyElm.pcb_port_ids) &&\n anyElm.pcb_port_ids.some((id: string) => portIds.includes(id))\n )\n return true\n if (anyElm.start_pcb_port_id && portIds.includes(anyElm.start_pcb_port_id))\n return true\n if (anyElm.end_pcb_port_id && portIds.includes(anyElm.end_pcb_port_id))\n return true\n if (\n Array.isArray(anyElm.route) &&\n anyElm.route.some(\n (pt: any) =>\n (pt.start_pcb_port_id && portIds.includes(pt.start_pcb_port_id)) ||\n (pt.end_pcb_port_id && portIds.includes(pt.end_pcb_port_id)),\n )\n )\n return true\n return false\n })\n\n const matrix = translate(dx, dy)\n transformPCBElements(elementsToMove, matrix)\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { buildSubtree } from \"./subtree\"\nimport { findBoundsAndCenter } from \"./find-bounds-and-center\"\nimport { transformPCBElements } from \"./transform-soup-elements\"\nimport { translate } from \"transformation-matrix\"\n\nconst findAllDescendantGroupIds = (\n circuitJson: AnyCircuitElement[],\n parentGroupId: string,\n): string[] => {\n const childGroupIds: string[] = []\n const directChildren = circuitJson\n .filter(\n (elm) =>\n elm.type === \"source_group\" &&\n (elm as any).parent_source_group_id === parentGroupId,\n )\n .map((elm) => (elm as any).source_group_id)\n\n childGroupIds.push(...directChildren)\n\n // Recursively find descendants of child groups\n for (const childId of directChildren) {\n childGroupIds.push(...findAllDescendantGroupIds(circuitJson, childId))\n }\n\n return childGroupIds\n}\n\nexport const repositionPcbGroupTo = (\n circuitJson: AnyCircuitElement[],\n source_group_id: string,\n newCenter: { x: number; y: number },\n) => {\n // Find all descendant group IDs\n const allGroupIds = [\n source_group_id,\n ...findAllDescendantGroupIds(circuitJson, source_group_id),\n ]\n\n // Get all elements for each group (including the main group and its descendants)\n const allGroupElements = new Set<AnyCircuitElement>()\n\n for (const groupId of allGroupIds) {\n const groupElements = buildSubtree(circuitJson, {\n source_group_id: groupId,\n })\n groupElements.forEach((elm) => allGroupElements.add(elm))\n }\n\n // Get all port IDs from elements in the group\n const portIds = Array.from(allGroupElements)\n .filter((e) => e.type === \"pcb_port\")\n .map((e) => (e as any).pcb_port_id)\n\n // Find additional traces that connect to these ports (buildSubtree might miss these)\n const additionalTraces = circuitJson.filter((elm) => {\n if (elm.type !== \"pcb_trace\") return false\n if (allGroupElements.has(elm)) return false // already included\n\n const anyElm: any = elm\n\n // Check direct port connections\n if (anyElm.start_pcb_port_id && portIds.includes(anyElm.start_pcb_port_id))\n return true\n if (anyElm.end_pcb_port_id && portIds.includes(anyElm.end_pcb_port_id))\n return true\n\n // Check route point connections\n if (\n Array.isArray(anyElm.route) &&\n anyElm.route.some(\n (pt: any) =>\n (pt.start_pcb_port_id && portIds.includes(pt.start_pcb_port_id)) ||\n (pt.end_pcb_port_id && portIds.includes(pt.end_pcb_port_id)),\n )\n )\n return true\n\n return false\n })\n\n // Add additional traces to the elements to move\n additionalTraces.forEach((trace) => allGroupElements.add(trace))\n\n // Filter to only PCB elements that can be repositioned\n const pcbElements = Array.from(allGroupElements).filter((elm) =>\n elm.type.startsWith(\"pcb_\"),\n )\n\n if (pcbElements.length === 0) return\n\n // Calculate current bounds and center of the group\n const { center: currentCenter } = findBoundsAndCenter(pcbElements)\n\n // Calculate translation needed\n const dx = newCenter.x - currentCenter.x\n const dy = newCenter.y - currentCenter.y\n\n // Create translation matrix\n const matrix = translate(dx, dy)\n\n // Apply transformation to all PCB elements in the group\n transformPCBElements(pcbElements, matrix)\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { transformSchematicElements } from \"./transform-soup-elements\"\nimport { translate } from \"transformation-matrix\"\n\nexport const repositionSchematicComponentTo = (\n circuitJson: AnyCircuitElement[],\n schematic_component_id: string,\n newCenter: { x: number; y: number },\n) => {\n const schematicComponent = circuitJson.find(\n (e) =>\n e.type === \"schematic_component\" &&\n (e as any).schematic_component_id === schematic_component_id,\n )\n if (!schematicComponent) return\n\n const currentCenter =\n \"center\" in schematicComponent\n ? (schematicComponent as any).center\n : { x: (schematicComponent as any).x, y: (schematicComponent as any).y }\n\n const dx = newCenter.x - currentCenter.x\n const dy = newCenter.y - currentCenter.y\n\n const portIds = circuitJson\n .filter(\n (e) =>\n e.type === \"schematic_port\" &&\n (e as any).schematic_component_id === schematic_component_id,\n )\n .map((e) => (e as any).schematic_port_id)\n\n const elementsToMove = circuitJson.filter((elm) => {\n if (elm === schematicComponent) return true\n const anyElm: any = elm\n if (anyElm.schematic_component_id === schematic_component_id) return true\n if (\n Array.isArray(anyElm.schematic_component_ids) &&\n anyElm.schematic_component_ids.includes(schematic_component_id)\n )\n return true\n if (anyElm.schematic_port_id && portIds.includes(anyElm.schematic_port_id))\n return true\n if (\n Array.isArray(anyElm.schematic_port_ids) &&\n anyElm.schematic_port_ids.some((id: string) => portIds.includes(id))\n )\n return true\n if (\n anyElm.start_schematic_port_id &&\n portIds.includes(anyElm.start_schematic_port_id)\n )\n return true\n if (\n anyElm.end_schematic_port_id &&\n portIds.includes(anyElm.end_schematic_port_id)\n )\n return true\n if (\n Array.isArray(anyElm.route) &&\n anyElm.route.some(\n (pt: any) =>\n (pt.start_schematic_port_id &&\n portIds.includes(pt.start_schematic_port_id)) ||\n (pt.end_schematic_port_id &&\n portIds.includes(pt.end_schematic_port_id)),\n )\n )\n return true\n return false\n })\n\n const matrix = translate(dx, dy)\n transformSchematicElements(elementsToMove, matrix)\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { buildSubtree } from \"./subtree\"\nimport { findBoundsAndCenter } from \"./find-bounds-and-center\"\nimport { transformSchematicElements } from \"./transform-soup-elements\"\nimport { translate } from \"transformation-matrix\"\n\nconst findAllDescendantGroupIds = (\n circuitJson: AnyCircuitElement[],\n parentGroupId: string,\n): string[] => {\n const childGroupIds: string[] = []\n const directChildren = circuitJson\n .filter(\n (elm) =>\n elm.type === \"source_group\" &&\n (elm as any).parent_source_group_id === parentGroupId,\n )\n .map((elm) => (elm as any).source_group_id)\n\n childGroupIds.push(...directChildren)\n\n for (const childId of directChildren) {\n childGroupIds.push(...findAllDescendantGroupIds(circuitJson, childId))\n }\n\n return childGroupIds\n}\n\nexport const repositionSchematicGroupTo = (\n circuitJson: AnyCircuitElement[],\n source_group_id: string,\n newCenter: { x: number; y: number },\n) => {\n const allGroupIds = [\n source_group_id,\n ...findAllDescendantGroupIds(circuitJson, source_group_id),\n ]\n\n const allGroupElements = new Set<AnyCircuitElement>()\n\n for (const groupId of allGroupIds) {\n const groupElements = buildSubtree(circuitJson, {\n source_group_id: groupId,\n })\n groupElements.forEach((elm) => allGroupElements.add(elm))\n }\n\n const portIds = Array.from(allGroupElements)\n .filter((e) => e.type === \"schematic_port\")\n .map((e) => (e as any).schematic_port_id)\n\n const additionalTraces = circuitJson.filter((elm) => {\n if (elm.type !== \"schematic_trace\") return false\n if (allGroupElements.has(elm)) return false\n\n const anyElm: any = elm\n\n if (\n anyElm.start_schematic_port_id &&\n portIds.includes(anyElm.start_schematic_port_id)\n )\n return true\n if (\n anyElm.end_schematic_port_id &&\n portIds.includes(anyElm.end_schematic_port_id)\n )\n return true\n if (\n Array.isArray(anyElm.route) &&\n anyElm.route.some(\n (pt: any) =>\n (pt.start_schematic_port_id &&\n portIds.includes(pt.start_schematic_port_id)) ||\n (pt.end_schematic_port_id &&\n portIds.includes(pt.end_schematic_port_id)),\n )\n )\n return true\n\n return false\n })\n\n additionalTraces.forEach((trace) => allGroupElements.add(trace))\n\n const schematicElements = Array.from(allGroupElements).filter((elm) =>\n elm.type.startsWith(\"schematic_\"),\n )\n if (schematicElements.length === 0) return\n\n const { center: currentCenter } = findBoundsAndCenter(schematicElements)\n\n const dx = newCenter.x - currentCenter.x\n const dy = newCenter.y - currentCenter.y\n\n const matrix = translate(dx, dy)\n\n transformSchematicElements(schematicElements, matrix)\n}\n","import type {\n AnyCircuitElement,\n SourceComponentBase,\n SourceGroup,\n} from \"circuit-json\"\n\n/**\n * A tree of circuit elements. This is often used for layout because you want\n * to consider only the top-level elements of a group for layout (child groups\n * move together)\n */\nexport interface CircuitJsonTreeNode {\n nodeType: \"group\" | \"component\"\n sourceGroup?: SourceGroup\n sourceComponent?: SourceComponentBase\n childNodes: Array<CircuitJsonTreeNode>\n otherChildElements: Array<AnyCircuitElement>\n}\n\nexport const getCircuitJsonTree = (\n circuitJson: AnyCircuitElement[],\n opts?: {\n source_group_id?: string\n },\n): CircuitJsonTreeNode => {\n type ChildGroupId = string\n type ParentGroupId = string\n type GroupId = string\n const groupChildMap: Map<ParentGroupId, ChildGroupId[]> = new Map()\n\n // Get all source group IDs present in the circuit JSON\n const existingGroupIds = new Set<string>()\n for (const elm of circuitJson) {\n if (elm.type === \"source_group\") {\n existingGroupIds.add(elm.source_group_id)\n }\n }\n\n // Find orphaned groups (groups whose parent is not in the circuit JSON)\n const orphanedGroups: string[] = []\n\n for (const elm of circuitJson) {\n if (elm.type === \"source_group\" && elm.parent_source_group_id) {\n const parentId = elm.parent_source_group_id\n const childId = elm.source_group_id\n\n // If parent doesn't exist in circuit JSON, this is an orphaned group\n if (!existingGroupIds.has(parentId)) {\n orphanedGroups.push(childId)\n // Treat orphaned groups as root-level groups\n if (!groupChildMap.has(childId)) {\n groupChildMap.set(childId, [])\n }\n } else {\n // Normal parent-child relationship\n const children = groupChildMap.get(parentId) ?? []\n children.push(childId)\n groupChildMap.set(parentId, children)\n if (!groupChildMap.has(childId)) {\n groupChildMap.set(childId, [])\n }\n }\n }\n }\n\n // Ensure that every source_group, including root-level groups that have no parent,\n // is present in the groupChildMap. This guarantees that even standalone boards\n // (with no nested groups) are processed and appear at the top of the tree.\n for (const elm of circuitJson) {\n if (\n elm.type === \"source_group\" &&\n !groupChildMap.has(elm.source_group_id)\n ) {\n groupChildMap.set(elm.source_group_id, [])\n }\n }\n\n const groupNodes = new Map<GroupId, CircuitJsonTreeNode>()\n\n const getNextGroupId = () => {\n for (const [parentId, children] of groupChildMap) {\n if (groupNodes.has(parentId)) continue\n if (children.every((childId) => groupNodes.has(childId))) {\n return parentId\n }\n }\n return null\n }\n\n // Compute any node we have the dependencies for until we've computed all of\n // them\n let lastGroupId: GroupId | null = null\n while (true) {\n const nextGroupId = getNextGroupId()\n if (!nextGroupId) break\n\n const sourceGroup = circuitJson.find(\n (elm) =>\n elm.type === \"source_group\" && elm.source_group_id === nextGroupId,\n ) as SourceGroup\n\n // Create the tree node for this group\n const node: CircuitJsonTreeNode = {\n nodeType: \"group\",\n sourceGroup,\n otherChildElements: [],\n childNodes: [\n ...(groupChildMap\n .get(nextGroupId)\n ?.map((childId) => groupNodes.get(childId)!) ?? []),\n ...circuitJson\n .filter(\n (elm) =>\n elm.type === \"source_component\" &&\n elm.source_group_id === nextGroupId,\n )\n .map((elm) => {\n return {\n nodeType: \"component\",\n sourceComponent: elm,\n childNodes: [],\n otherChildElements: [\n ...circuitJson.filter(\n (e) =>\n e.type === \"pcb_component\" &&\n e.source_component_id ===\n (elm as SourceComponentBase).source_component_id,\n ),\n ], // TODO populate\n } as CircuitJsonTreeNode\n }),\n ],\n }\n\n groupNodes.set(nextGroupId, node)\n lastGroupId = nextGroupId\n }\n\n if (!lastGroupId) {\n console.warn(\"No groups were processed, returning tree without sourceGroup\")\n return {\n nodeType: \"group\",\n childNodes: [], // TODO populate\n otherChildElements: circuitJson,\n }\n }\n\n // Determine which group to return as root\n let rootGroupId: string | null = null\n if (opts && opts.source_group_id !== undefined) {\n // Use explicitly specified group\n rootGroupId = opts.source_group_id\n } else if (orphanedGroups.length > 0) {\n // Use the first orphaned group as root (most likely scenario when filtering circuit JSON)\n rootGroupId = orphanedGroups[0]!\n } else {\n // Fall back to the last processed group (typically the top-level parent)\n rootGroupId = lastGroupId as string | null\n }\n\n if (!rootGroupId) {\n console.warn(\n \"No valid root group found, returning tree without sourceGroup\",\n )\n return {\n nodeType: \"group\",\n childNodes: [],\n otherChildElements: circuitJson,\n }\n }\n\n return groupNodes.get(rootGroupId)!\n}\n","import type { CircuitJsonTreeNode } from \"./getCircuitJsonTree\"\n\nexport const getStringFromCircuitJsonTree = (\n circuitJsonTree: CircuitJsonTreeNode,\n indent = 0,\n): string => {\n if (circuitJsonTree.nodeType === \"component\") {\n return `${\" \".repeat(indent)}${circuitJsonTree.sourceComponent?.name ?? circuitJsonTree.sourceComponent?.source_component_id}`\n }\n const lines = []\n\n lines.push(\n `${\" \".repeat(indent)}${circuitJsonTree.sourceGroup?.name ?? circuitJsonTree.sourceGroup?.source_group_id}`,\n )\n for (const child of circuitJsonTree.childNodes) {\n lines.push(getStringFromCircuitJsonTree(child, indent + 2))\n }\n return lines.join(\"\\n\")\n}\n","export type Size = { width: number; height: number }\n\nimport type { FlexBoxOptions } from \"@tscircuit/miniflex\"\n/**\n * Compute the smallest possible dimensions (width & height) for a flex container\n * so that **all** children fit without overflowing _before_ any flex grow / shrink\n * is applied. This is a very lightweight approximation – it only considers the\n * children's explicit `width`/`height` (or `flexBasis`) plus the configured gaps\n * and the main-axis stacking rules derived from the flex direction.\n *\n * This function purposely does **not** try to implement the full flexbox sizing\n * algorithm – we only need a quick estimate so that `RootFlexBox` can be\n * instantiated even when the user did not provide explicit dimensions for the\n * container (e.g. when laying out PCB components directly on the board level\n * instead of inside a sub-circuit).\n */\nexport function getMinimumFlexContainer(\n children: Array<{ width: number; height: number }>,\n options: FlexBoxOptions = {},\n): Size {\n if (children.length === 0) return { width: 0, height: 0 }\n\n const direction = options.direction ?? \"row\"\n const columnGap = options.columnGap ?? 0\n const rowGap = options.rowGap ?? 0\n\n // Flexbox main-axis / cross-axis mapping --------------------------------\n const isRowDirection = direction === \"row\" || direction === \"row-reverse\"\n\n if (isRowDirection) {\n // Main-axis horizontally stacks children\n const totalChildWidth = children.reduce((sum, c) => sum + c.width, 0)\n const width = totalChildWidth + columnGap * Math.max(0, children.length - 1)\n\n const height = children.reduce((max, c) => Math.max(max, c.height), 0)\n return { width, height }\n } else {\n // Column direction – stack vertically\n const totalChildHeight = children.reduce((sum, c) => sum + c.height, 0)\n const height = totalChildHeight + rowGap * Math.max(0, children.length - 1)\n\n const width = children.reduce((max, c) => Math.max(max, c.width), 0)\n return { width, height }\n }\n}\n","import type { AnyCircuitElement, PcbRenderLayer } from \"circuit-json\"\n\nexport function getElementRenderLayers(\n element: AnyCircuitElement,\n): PcbRenderLayer[] {\n // Copper elements (pads, traces, copper pour, copper text)\n if (element.type === \"pcb_smtpad\") {\n const layer = element.layer\n return [`${layer}_copper` as PcbRenderLayer]\n }\n\n if (element.type === \"pcb_trace\") {\n // Traces can span multiple layers, return all layers from route\n if (!element.route || !Array.isArray(element.route)) return []\n const layers = new Set<PcbRenderLayer>()\n for (const point of element.route) {\n if (\"layer\" in point && point.layer) {\n layers.add(`${point.layer}_copper` as PcbRenderLayer)\n }\n }\n return Array.from(layers)\n }\n\n if (element.type === \"pcb_copper_pour\") {\n const layer = element.layer\n return [`${layer}_copper` as PcbRenderLayer]\n }\n\n if (element.type === \"pcb_copper_text\") {\n const layer = element.layer\n return [`${layer}_copper` as PcbRenderLayer]\n }\n\n // Silkscreen elements\n if (\n element.type === \"pcb_silkscreen_text\" ||\n element.type === \"pcb_silkscreen_rect\" ||\n element.type === \"pcb_silkscreen_circle\" ||\n element.type === \"pcb_silkscreen_line\" ||\n element.type === \"pcb_silkscreen_path\"\n ) {\n const layer = element.layer\n return [`${layer}_silkscreen` as PcbRenderLayer]\n }\n\n // Fabrication note elements\n if (\n element.type === \"pcb_fabrication_note_text\" ||\n element.type === \"pcb_fabrication_note_rect\" ||\n element.type === \"pcb_fabrication_note_path\"\n ) {\n const layer = element.layer\n return [`${layer}_fabrication_note` as PcbRenderLayer]\n }\n\n // Courtyard elements\n\n if (\n element.type === \"pcb_courtyard_circle\" ||\n element.type === \"pcb_courtyard_polygon\" ||\n element.type === \"pcb_courtyard_rect\" ||\n element.type === \"pcb_courtyard_outline\"\n ) {\n const layer = element.layer\n return [`${layer}_courtyard` as PcbRenderLayer]\n }\n\n // Elements without layer filtering (always drawn)\n // These include: pcb_board, pcb_hole, pcb_plated_hole, pcb_via, pcb_cutout,\n // pcb_note_rect, pcb_note_path, pcb_note_text, pcb_note_line, pcb_note_dimension\n return []\n}\n","import type { Point, Polygon, Rect } from \"./types\"\n\nexport const EPSILON = 1e-9\n\nexport const toRadians = (degrees: number) => (degrees * Math.PI) / 180\n\nexport const clamp = (value: number, min: number, max: number) =>\n Math.max(min, Math.min(max, value))\n\nexport const distanceBetweenPoints = (a: Point, b: Point) =>\n Math.hypot(a.x - b.x, a.y - b.y)\n\nexport const distanceBetweenPointAndSegment = (\n point: Point,\n a: Point,\n b: Point,\n) => {\n const abX = b.x - a.x\n const abY = b.y - a.y\n const lengthSquared = abX * abX + abY * abY\n\n if (lengthSquared <= EPSILON) return distanceBetweenPoints(point, a)\n\n const t = clamp(\n ((point.x - a.x) * abX + (point.y - a.y) * abY) / lengthSquared,\n 0,\n 1,\n )\n\n return Math.hypot(point.x - (a.x + t * abX), point.y - (a.y + t * abY))\n}\n\nexport const cross = (a: Point, b: Point, c: Point) =>\n (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)\n\nexport const isPointOnSegment = (point: Point, a: Point, b: Point) => {\n if (Math.abs(cross(a, b, point)) > EPSILON) return false\n\n return (\n point.x >= Math.min(a.x, b.x) - EPSILON &&\n point.x <= Math.max(a.x, b.x) + EPSILON &&\n point.y >= Math.min(a.y, b.y) - EPSILON &&\n point.y <= Math.max(a.y, b.y) + EPSILON\n )\n}\n\nexport const segmentsIntersect = (\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n) => {\n const c1 = cross(a1, a2, b1)\n const c2 = cross(a1, a2, b2)\n const c3 = cross(b1, b2, a1)\n const c4 = cross(b1, b2, a2)\n\n if (\n ((c1 > EPSILON && c2 < -EPSILON) || (c1 < -EPSILON && c2 > EPSILON)) &&\n ((c3 > EPSILON && c4 < -EPSILON) || (c3 < -EPSILON && c4 > EPSILON))\n ) {\n return true\n }\n\n return (\n isPointOnSegment(b1, a1, a2) ||\n isPointOnSegment(b2, a1, a2) ||\n isPointOnSegment(a1, b1, b2) ||\n isPointOnSegment(a2, b1, b2)\n )\n}\n\nexport const getPolygonEdges = (polygon: Polygon): Array<[Point, Point]> => {\n const edges: Array<[Point, Point]> = []\n\n if (polygon.points.length < 2) return edges\n\n for (let i = 0; i < polygon.points.length; i += 1) {\n const a = polygon.points[i]\n const b = polygon.points[(i + 1) % polygon.points.length]\n\n if (!a || !b) continue\n\n edges.push([a, b])\n }\n\n return edges\n}\n\nexport const isPointInPolygon = (point: Point, polygon: Polygon) => {\n for (const [a, b] of getPolygonEdges(polygon)) {\n if (isPointOnSegment(point, a, b)) return true\n }\n\n let inside = false\n for (\n let i = 0, j = polygon.points.length - 1;\n i < polygon.points.length;\n j = i++\n ) {\n const pi = polygon.points[i]\n const pj = polygon.points[j]\n\n if (!pi || !pj) continue\n\n const intersects =\n pi.y > point.y !== pj.y > point.y &&\n point.x < ((pj.x - pi.x) * (point.y - pi.y)) / (pj.y - pi.y) + pi.x\n\n if (intersects) inside = !inside\n }\n\n return inside\n}\n\nexport const rotatePoint = (point: Point, angleRadians: number) => ({\n x: point.x * Math.cos(angleRadians) - point.y * Math.sin(angleRadians),\n y: point.x * Math.sin(angleRadians) + point.y * Math.cos(angleRadians),\n})\n\nexport const rectToPolygon = (rect: Rect): Polygon => {\n const halfWidth = rect.width / 2\n const halfHeight = rect.height / 2\n const angle = toRadians(rect.rotationDegrees)\n\n return {\n kind: \"polygon\",\n points: [\n { x: -halfWidth, y: -halfHeight },\n { x: halfWidth, y: -halfHeight },\n { x: halfWidth, y: halfHeight },\n { x: -halfWidth, y: halfHeight },\n ].map((localPoint) => {\n const rotated = rotatePoint(localPoint, angle)\n return { x: rect.centerX + rotated.x, y: rect.centerY + rotated.y }\n }),\n }\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { EPSILON } from \"./geometry\"\nimport type { CopperShape, Point, Rect } from \"./types\"\n\nconst isFiniteNumber = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value)\n\nconst createWireSegmentRect = (\n start: Point,\n end: Point,\n width: number,\n): Rect => ({\n kind: \"rect\",\n centerX: (start.x + end.x) / 2,\n centerY: (start.y + end.y) / 2,\n width: Math.hypot(end.x - start.x, end.y - start.y),\n height: width,\n rotationDegrees:\n (Math.atan2(end.y - start.y, end.x - start.x) * 180) / Math.PI,\n})\n\nexport const decomposeCopperIntoShapes = (\n element: AnyCircuitElement,\n): CopperShape[] => {\n const elm: any = element\n const shapes: CopperShape[] = []\n\n if (elm.type === \"pcb_smtpad\") {\n if (elm.shape === \"circle\" && isFiniteNumber(elm.radius)) {\n shapes.push({ kind: \"circle\", x: elm.x, y: elm.y, radius: elm.radius })\n }\n\n if (\n elm.shape === \"rect\" &&\n isFiniteNumber(elm.width) &&\n isFiniteNumber(elm.height)\n ) {\n shapes.push({\n kind: \"rect\",\n centerX: elm.x,\n centerY: elm.y,\n width: elm.width,\n height: elm.height,\n rotationDegrees: isFiniteNumber(elm.ccw_rotation)\n ? elm.ccw_rotation\n : 0,\n })\n }\n\n if (elm.shape === \"polygon\" && Array.isArray(elm.points)) {\n const points = elm.points.filter(\n (point: any): point is Point =>\n isFiniteNumber(point?.x) && isFiniteNumber(point?.y),\n )\n\n if (points.length >= 3) {\n shapes.push({ kind: \"polygon\", points })\n }\n }\n\n return shapes\n }\n\n if (elm.type === \"pcb_trace\" && Array.isArray(elm.route)) {\n for (let i = 0; i < elm.route.length - 1; i += 1) {\n const start = elm.route[i]\n const end = elm.route[i + 1]\n\n if (\n !start ||\n !end ||\n start.route_type !== \"wire\" ||\n end.route_type !== \"wire\" ||\n !isFiniteNumber(start.x) ||\n !isFiniteNumber(start.y) ||\n !isFiniteNumber(end.x) ||\n !isFiniteNumber(end.y)\n ) {\n continue\n }\n\n const width = isFiniteNumber(start.width) ? Math.max(0, start.width) : 0\n const radius = width / 2\n\n shapes.push({ kind: \"circle\", x: start.x, y: start.y, radius })\n shapes.push({ kind: \"circle\", x: end.x, y: end.y, radius })\n\n if (Math.hypot(end.x - start.x, end.y - start.y) > EPSILON) {\n shapes.push(createWireSegmentRect(start, end, width))\n }\n }\n\n return shapes\n }\n\n if (elm.type === \"pcb_via\" && isFiniteNumber(elm.outer_diameter)) {\n shapes.push({\n kind: \"circle\",\n x: elm.x,\n y: elm.y,\n radius: elm.outer_diameter / 2,\n })\n\n return shapes\n }\n\n if (elm.type === \"pcb_plated_hole\") {\n if (isFiniteNumber(elm.outer_diameter)) {\n shapes.push({\n kind: \"circle\",\n x: elm.x,\n y: elm.y,\n radius: elm.outer_diameter / 2,\n })\n }\n\n if (\n isFiniteNumber(elm.rect_pad_width) &&\n isFiniteNumber(elm.rect_pad_height)\n ) {\n shapes.push({\n kind: \"rect\",\n centerX: elm.x,\n centerY: elm.y,\n width: elm.rect_pad_width,\n height: elm.rect_pad_height,\n rotationDegrees: isFiniteNumber(elm.rect_ccw_rotation)\n ? elm.rect_ccw_rotation\n : 0,\n })\n }\n\n if (isFiniteNumber(elm.outer_width) && isFiniteNumber(elm.outer_height)) {\n shapes.push({\n kind: \"rect\",\n centerX: elm.x,\n centerY: elm.y,\n width: elm.outer_width,\n height: elm.outer_height,\n rotationDegrees: 0,\n })\n }\n\n return shapes\n }\n\n return shapes\n}\n","import {\n distanceBetweenPointAndSegment,\n getPolygonEdges,\n isPointInPolygon,\n rectToPolygon,\n segmentsIntersect,\n} from \"./geometry\"\nimport type { Circle, CopperShape, Polygon, Rect } from \"./types\"\n\nconst distanceBetweenCircleAndCircle = (a: Circle, b: Circle) =>\n Math.max(0, Math.hypot(a.x - b.x, a.y - b.y) - a.radius - b.radius)\n\nconst distanceBetweenPolygonAndPolygon = (a: Polygon, b: Polygon) => {\n if (a.points.length < 3 || b.points.length < 3) {\n return Number.POSITIVE_INFINITY\n }\n\n for (const [a1, a2] of getPolygonEdges(a)) {\n for (const [b1, b2] of getPolygonEdges(b)) {\n if (segmentsIntersect(a1, a2, b1, b2)) {\n return 0\n }\n }\n }\n\n const aPoint = a.points[0]\n const bPoint = b.points[0]\n if (\n (aPoint && isPointInPolygon(aPoint, b)) ||\n (bPoint && isPointInPolygon(bPoint, a))\n ) {\n return 0\n }\n\n let minDistance = Number.POSITIVE_INFINITY\n\n for (const [a1, a2] of getPolygonEdges(a)) {\n for (const [b1, b2] of getPolygonEdges(b)) {\n minDistance = Math.min(\n minDistance,\n distanceBetweenPointAndSegment(a1, b1, b2),\n distanceBetweenPointAndSegment(a2, b1, b2),\n distanceBetweenPointAndSegment(b1, a1, a2),\n distanceBetweenPointAndSegment(b2, a1, a2),\n )\n }\n }\n\n return minDistance\n}\n\nconst distanceBetweenCircleAndPolygon = (circle: Circle, polygon: Polygon) => {\n if (polygon.points.length < 3) {\n return Number.POSITIVE_INFINITY\n }\n\n if (isPointInPolygon({ x: circle.x, y: circle.y }, polygon)) {\n return 0\n }\n\n let minDistanceToEdge = Number.POSITIVE_INFINITY\n\n for (const [start, end] of getPolygonEdges(polygon)) {\n minDistanceToEdge = Math.min(\n minDistanceToEdge,\n distanceBetweenPointAndSegment({ x: circle.x, y: circle.y }, start, end),\n )\n }\n\n return Math.max(0, minDistanceToEdge - circle.radius)\n}\n\nexport const distanceBetweenShapes = (\n a: CopperShape,\n b: CopperShape,\n): number => {\n if (a.kind === \"circle\" && b.kind === \"circle\") {\n return distanceBetweenCircleAndCircle(a, b)\n }\n\n if (a.kind === \"rect\" && b.kind === \"rect\") {\n return distanceBetweenPolygonAndPolygon(rectToPolygon(a), rectToPolygon(b))\n }\n\n if (a.kind === \"circle\" && b.kind === \"rect\") {\n return distanceBetweenCircleAndPolygon(a, rectToPolygon(b))\n }\n\n if (a.kind === \"rect\" && b.kind === \"circle\") {\n return distanceBetweenCircleAndPolygon(b, rectToPolygon(a))\n }\n\n if (a.kind === \"circle\" && b.kind === \"polygon\") {\n return distanceBetweenCircleAndPolygon(a, b)\n }\n\n if (a.kind === \"polygon\" && b.kind === \"circle\") {\n return distanceBetweenCircleAndPolygon(b, a)\n }\n\n if (a.kind === \"rect\" && b.kind === \"polygon\") {\n return distanceBetweenPolygonAndPolygon(rectToPolygon(a), b)\n }\n\n if (a.kind === \"polygon\" && b.kind === \"rect\") {\n return distanceBetweenPolygonAndPolygon(a, rectToPolygon(b))\n }\n\n if (a.kind === \"polygon\" && b.kind === \"polygon\") {\n return distanceBetweenPolygonAndPolygon(a, b)\n }\n\n return Number.POSITIVE_INFINITY\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { decomposeCopperIntoShapes } from \"./shape-distances/decompose-copper-into-shapes\"\nimport { distanceBetweenShapes } from \"./shape-distances/distance-between-shapes\"\n\nexport const computeGapBetweenCopper = (\n elm1: AnyCircuitElement,\n elm2: AnyCircuitElement,\n): number => {\n const shapes1 = decomposeCopperIntoShapes(elm1)\n const shapes2 = decomposeCopperIntoShapes(elm2)\n\n if (shapes1.length === 0 || shapes2.length === 0) {\n return Number.POSITIVE_INFINITY\n }\n\n let minimumGap = Number.POSITIVE_INFINITY\n\n for (const shape1 of shapes1) {\n for (const shape2 of shapes2) {\n minimumGap = Math.min(minimumGap, distanceBetweenShapes(shape1, shape2))\n }\n }\n\n return minimumGap\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { decomposeCopperIntoShapes } from \"./decompose-copper-into-shapes\"\nimport type { CopperShape, Point } from \"./types\"\n\nconst isFiniteNumber = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value)\n\nconst getCenter = (elm: any): { x: number; y: number } | null => {\n if (isFiniteNumber(elm?.x) && isFiniteNumber(elm?.y)) {\n return { x: elm.x, y: elm.y }\n }\n\n if (isFiniteNumber(elm?.center?.x) && isFiniteNumber(elm?.center?.y)) {\n return { x: elm.center.x, y: elm.center.y }\n }\n\n return null\n}\n\nconst addCenterBasedShapes = (elm: any, shapes: CopperShape[]) => {\n const center = getCenter(elm)\n if (!center) return\n\n if (elm.shape === \"circle\") {\n if (isFiniteNumber(elm.radius)) {\n shapes.push({\n kind: \"circle\",\n x: center.x,\n y: center.y,\n radius: elm.radius,\n })\n return\n }\n\n if (isFiniteNumber(elm.diameter)) {\n shapes.push({\n kind: \"circle\",\n x: center.x,\n y: center.y,\n radius: elm.diameter / 2,\n })\n return\n }\n }\n\n if (\n elm.shape === \"rect\" &&\n isFiniteNumber(elm.width) &&\n isFiniteNumber(elm.height)\n ) {\n shapes.push({\n kind: \"rect\",\n centerX: center.x,\n centerY: center.y,\n width: elm.width,\n height: elm.height,\n rotationDegrees: isFiniteNumber(elm.ccw_rotation) ? elm.ccw_rotation : 0,\n })\n return\n }\n\n if (elm.shape === \"polygon\" && Array.isArray(elm.points)) {\n const points = elm.points.filter(\n (point: any): point is Point =>\n isFiniteNumber(point?.x) && isFiniteNumber(point?.y),\n )\n\n if (points.length >= 3) {\n shapes.push({ kind: \"polygon\", points })\n }\n }\n}\n\nexport const decomposeClearanceIntoShapes = (\n element: AnyCircuitElement,\n): CopperShape[] => {\n const elm: any = element\n const shapes: CopperShape[] = [...decomposeCopperIntoShapes(element)]\n\n if (elm.type === \"pcb_hole\" && elm.hole_shape === \"circle\") {\n if (\n isFiniteNumber(elm.hole_diameter) &&\n isFiniteNumber(elm.x) &&\n isFiniteNumber(elm.y)\n ) {\n shapes.push({\n kind: \"circle\",\n x: elm.x,\n y: elm.y,\n radius: elm.hole_diameter / 2,\n })\n }\n return shapes\n }\n\n if (elm.type === \"pcb_plated_hole\") {\n if (\n isFiniteNumber(elm.hole_diameter) &&\n isFiniteNumber(elm.x) &&\n isFiniteNumber(elm.y)\n ) {\n const holeOffsetX = isFiniteNumber(elm.hole_offset_x)\n ? elm.hole_offset_x\n : 0\n const holeOffsetY = isFiniteNumber(elm.hole_offset_y)\n ? elm.hole_offset_y\n : 0\n shapes.push({\n kind: \"circle\",\n x: elm.x + holeOffsetX,\n y: elm.y + holeOffsetY,\n radius: elm.hole_diameter / 2,\n })\n }\n return shapes\n }\n\n if (\n elm.type === \"pcb_keepout\" ||\n elm.type === \"pcb_cutout\" ||\n elm.type === \"pcb_board\"\n ) {\n addCenterBasedShapes(elm, shapes)\n return shapes\n }\n\n return shapes\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport { decomposeClearanceIntoShapes } from \"./shape-distances/decompose-clearance-into-shapes\"\nimport { distanceBetweenShapes } from \"./shape-distances/distance-between-shapes\"\n\nexport const computeClearanceBetweenElements = (\n elm1: AnyCircuitElement,\n elm2: AnyCircuitElement,\n): number => {\n const shapes1 = decomposeClearanceIntoShapes(elm1)\n const shapes2 = decomposeClearanceIntoShapes(elm2)\n\n if (shapes1.length === 0 || shapes2.length === 0) {\n return Number.POSITIVE_INFINITY\n }\n\n let minimumGap = Number.POSITIVE_INFINITY\n\n for (const shape1 of shapes1) {\n for (const shape2 of shapes2) {\n minimumGap = Math.min(minimumGap, distanceBetweenShapes(shape1, shape2))\n }\n }\n\n return minimumGap\n}\n","export type DrcCategory =\n | \"netlist\"\n | \"pin_specification\"\n | \"placement\"\n | \"routing\"\n | \"unknown\"\n\ntype DrcLike = {\n type?: string\n error_type?: string\n warning_type?: string\n}\n\nconst NETLIST_TYPES = new Set([\"source_pin_must_be_connected_error\"])\n\nconst PIN_SPECIFICATION_TYPES = new Set([\n \"source_component_pins_underspecified_warning\",\n \"source_no_power_pin_defined_warning\",\n \"source_no_ground_pin_defined_warning\",\n])\n\nconst PLACEMENT_TYPES = new Set([\n \"pcb_placement_error\",\n \"pcb_component_outside_board_error\",\n \"pcb_footprint_overlap_error\",\n \"pcb_connector_not_in_accessible_orientation_warning\",\n])\n\nconst ROUTING_TYPES = new Set([\n \"pcb_port_not_connected_error\",\n \"pcb_trace_missing_error\",\n \"pcb_trace_error\",\n \"pcb_via_clearance_error\",\n])\n\nexport const categorizeErrorOrWarning = (\n value: string | DrcLike,\n): DrcCategory => {\n const drcType =\n typeof value === \"string\"\n ? value\n : (value.error_type ?? value.warning_type ?? value.type)\n\n if (!drcType) return \"unknown\"\n\n if (NETLIST_TYPES.has(drcType)) return \"netlist\"\n if (PIN_SPECIFICATION_TYPES.has(drcType)) return \"pin_specification\"\n if (PLACEMENT_TYPES.has(drcType)) return \"placement\"\n if (ROUTING_TYPES.has(drcType)) return \"routing\"\n\n return \"unknown\"\n}\n","const unitToMm: { [key: string]: number } = {\n in: 25.4,\n inch: 25.4,\n mil: 0.0254,\n mm: 1,\n m: 1000,\n cm: 10,\n ft: 304.8,\n feet: 304.8,\n}\n\nconst mmNumberFormatter = new Intl.NumberFormat(\"en-US\", {\n useGrouping: false,\n notation: \"standard\",\n maximumFractionDigits: 12,\n})\n\nexport const mm = (n: number | string): number => {\n let unit =\n typeof n === \"number\" ? \"mm\" : n.replace(/^[^a-zA-Z]+/g, \"\").toLowerCase()\n if (!unit) unit = \"mm\"\n const val = typeof n === \"number\" ? n : Number.parseFloat(n.split(unit)[0])\n\n if (unit in unitToMm) {\n return val * unitToMm[unit]\n }\n throw new Error(`Unsupported unit: ${unit}`)\n}\n\nexport const mmStr = (n: number | string): string => {\n return `${mmNumberFormatter.format(mm(n))}mm`\n}\n\nexport const mil2mm = (mil: number | string) => {\n if (typeof mil === \"number\") return mm(`${mil}mil`)\n if (mil.match(/^\\d+$/)) return mm(`${mil}mil`)\n return mm(mil)\n}\n\nexport default mm\n","export interface Point {\n x: number\n y: number\n}\n\nexport function calculateCenter(start: Point, mid: Point, end: Point): Point {\n const mid1 = { x: (start.x + mid.x) / 2, y: (start.y + mid.y) / 2 }\n const mid2 = { x: (mid.x + end.x) / 2, y: (mid.y + end.y) / 2 }\n\n const slope1 = -(start.x - mid.x) / (start.y - mid.y)\n const slope2 = -(mid.x - end.x) / (mid.y - end.y)\n\n const centerX =\n (mid1.y - mid2.y + slope2 * mid2.x - slope1 * mid1.x) / (slope2 - slope1)\n const centerY = mid1.y + slope1 * (centerX - mid1.x)\n\n return { x: centerX, y: centerY }\n}\n\nfunction calculateRadius(center: Point, point: Point): number {\n return Math.sqrt((center.x - point.x) ** 2 + (center.y - point.y) ** 2)\n}\n\nfunction calculateAngle(center: Point, point: Point): number {\n return Math.atan2(point.y - center.y, point.x - center.x)\n}\n\nexport const getArcLength = (start: Point, mid: Point, end: Point) => {\n const center = calculateCenter(start, mid, end)\n const radius = calculateRadius(center, start)\n\n const angleStart = calculateAngle(center, start)\n const angleEnd = calculateAngle(center, end)\n\n let angleDelta = angleEnd - angleStart\n if (angleDelta < 0) {\n angleDelta += 2 * Math.PI\n }\n\n return radius * angleDelta\n}\n\nexport function generateArcPathWithMid(\n start: Point,\n mid: Point,\n end: Point,\n numPoints: number,\n): Point[] {\n const center = calculateCenter(start, mid, end)\n const radius = calculateRadius(center, start)\n\n const angleStart = calculateAngle(center, start)\n const angleEnd = calculateAngle(center, end)\n\n let angleDelta = angleEnd - angleStart\n if (angleDelta < 0) {\n angleDelta += 2 * Math.PI\n }\n\n const path: Point[] = []\n\n for (let i = 0; i <= numPoints; i++) {\n const angle = angleStart + (i / numPoints) * angleDelta\n const x = center.x + radius * Math.cos(angle)\n const y = center.y + radius * Math.sin(angle)\n // Check for NaN or Infinity values\n if (!isNaN(x) && isFinite(x) && !isNaN(y) && isFinite(y)) {\n path.push({ x, y })\n }\n }\n\n // If the path is empty, add the start and end points\n if (path.length === 0) {\n path.push(start, end)\n }\n\n return path\n}\n\n/**\nThis syntax describes an SVG path command for drawing an arc. Let's break down each part:\n\n1. \"M 3923.0512 2968.5197\": \n - M: Move to\n - 3923.0512: X-coordinate\n - 2968.5197: Y-coordinate\n\n2. \"A 2.5 2.5 0 0 0 3923.0512 2963.5197\":\n - A: Arc command\n - 2.5: X-radius of the ellipse\n - 2.5: Y-radius of the ellipse\n - 0: X-axis rotation (in degrees)\n - 0: Large arc flag (0 for small arc, 1 for large arc)\n - 0: Sweep flag (0 for counterclockwise, 1 for clockwise)\n - 3923.0512: End X-coordinate\n - 2963.5197: End Y-coordinate\n\nThis command draws an arc starting at (3923.0512, 2968.5197) and ending at (3923.0512, 2963.5197), using a circular path with a radius of 2.5 units.\n */\nexport function generateArcFromSweep(\n startX: number,\n startY: number,\n endX: number,\n endY: number,\n radius: number,\n largeArcFlag: boolean,\n sweepFlag: boolean,\n): Point[] {\n const start: Point = { x: startX, y: startY }\n const end: Point = { x: endX, y: endY }\n\n // Calculate the midpoint between start and end\n const midX = (startX + endX) / 2\n const midY = (startY + endY) / 2\n\n // Calculate the distance between start and end\n const dx = endX - startX\n const dy = endY - startY\n const distance = Math.sqrt(dx * dx + dy * dy)\n\n // If the distance is zero or the radius is too small, return a straight line\n if (distance === 0 || radius < distance / 2) {\n return [start, end]\n }\n\n // Calculate the center of the arc\n const h = Math.sqrt(radius * radius - (distance * distance) / 4)\n const angle = Math.atan2(dy, dx)\n const centerX = midX + h * Math.sin(angle) * (sweepFlag ? -1 : 1)\n const centerY = midY - h * Math.cos(angle) * (sweepFlag ? -1 : 1)\n\n // Calculate start and end angles\n const startAngle = Math.atan2(startY - centerY, startX - centerX)\n let endAngle = Math.atan2(endY - centerY, endX - centerX)\n\n // Adjust end angle based on sweep and large arc flags\n if (sweepFlag && endAngle > startAngle) {\n endAngle -= 2 * Math.PI\n } else if (!sweepFlag && endAngle < startAngle) {\n endAngle += 2 * Math.PI\n }\n\n if (\n (!largeArcFlag && Math.abs(endAngle - startAngle) > Math.PI) ||\n (largeArcFlag && Math.abs(endAngle - startAngle) < Math.PI)\n ) {\n if (endAngle > startAngle) {\n endAngle -= 2 * Math.PI\n } else {\n endAngle += 2 * Math.PI\n }\n }\n\n // Generate points along the arc\n const numPoints = Math.max(\n 2,\n Math.ceil(Math.abs(endAngle - startAngle) * radius),\n )\n const path: Point[] = []\n\n for (let i = 0; i <= numPoints; i++) {\n const t = i / numPoints\n const angle = startAngle + t * (endAngle - startAngle)\n const x = centerX + radius * Math.cos(angle)\n const y = centerY + radius * Math.sin(angle)\n path.push({ x, y })\n }\n\n return path\n}\n","/**\n * EasyEDA takes 10 mil as a basic factor, when a stroke width is 1, we can take it as 1*10mil = 10mil, is 2, we can take it as 2*10mil = 20mil,\n * Ref: https://docs.easyeda.com/en/DocumentFormat/3-EasyEDA-PCB-File-Format/#unit\n *\n * 1 mil = 0.001 inch\n * 1 inch = 25.4 mm\n * 1 mil = 25.4/1000 = 0.0254 mm\n */\nexport const mil10ToMm = (value: number): number => value * 10 * 0.0254\n","export const normalizePinLabels = (inputPinLabels: string[][]): string[][] => {\n const uniqueInputPinLabels = inputPinLabels.map((labels) => [\n ...new Set(labels),\n ])\n const result = uniqueInputPinLabels.map(() => [] as string[])\n const desiredNumbers = uniqueInputPinLabels.map(() => null as number | null)\n\n for (let i = 0; i < uniqueInputPinLabels.length; i++) {\n for (const label of uniqueInputPinLabels[i]) {\n if (/^\\d+$/.test(label)) {\n desiredNumbers[i] = Number.parseInt(label)\n break\n }\n }\n }\n\n let highestPinNumber = 0\n const acceptedDesiredNumbers = new Set<number>()\n\n for (let i = 0; i < desiredNumbers.length; i++) {\n const desiredNumber = desiredNumbers[i]\n if (desiredNumber === null || desiredNumber < 1) continue\n\n if (!acceptedDesiredNumbers.has(desiredNumber)) {\n acceptedDesiredNumbers.add(desiredNumber)\n result[i].push(`pin${desiredNumber}`)\n highestPinNumber = Math.max(highestPinNumber, desiredNumber)\n continue\n }\n\n let existingAltCount = 0\n for (const label of result[i]) {\n if (label.startsWith(`pin${desiredNumber}_alt`)) {\n existingAltCount += 1\n }\n }\n result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`)\n }\n\n for (let i = 0; i < result.length; i++) {\n const firstLabel = result[i][0]\n if (firstLabel?.includes(\"_alt\")) {\n highestPinNumber += 1\n result[i].unshift(`pin${highestPinNumber}`)\n }\n }\n\n for (let i = 0; i < result.length; i++) {\n if (result[i].length === 0) {\n highestPinNumber += 1\n result[i].push(`pin${highestPinNumber}`)\n }\n }\n\n const totalLabelCounts: Record<string, number> = {}\n for (const inputLabels of uniqueInputPinLabels) {\n for (const label of inputLabels) {\n if (/^\\d+$/.test(label)) continue\n totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1\n }\n }\n\n const incrementalLabelCounts: Record<string, number> = {}\n for (let i = 0; i < uniqueInputPinLabels.length; i++) {\n for (const label of uniqueInputPinLabels[i]) {\n if (/^\\d+$/.test(label)) continue\n\n if (totalLabelCounts[label] === 1) {\n result[i].push(label)\n } else {\n incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1\n result[i].push(`${label}${incrementalLabelCounts[label]}`)\n }\n }\n }\n\n return result\n}\n","/**\n * Normalizes symbol names that could break the converter\n * Converts \"+\" to \"_POS\" and \"-\" to \"_NEG\"\n */\nexport const normalizeSymbolName = (name: string): string => {\n const trimmedName = name.trim()\n if (trimmedName === \"+\") return \"_POS\"\n if (trimmedName === \"-\") return \"_NEG\"\n return trimmedName\n}\n","export const DEFAULT_PCB_THICKNESS_MM = 1.6\n","import {\n findBoundsAndCenter,\n transformPCBElements,\n} from \"@tscircuit/circuit-json-util\"\nimport { mm, mil2mm } from \"@tscircuit/mm\"\nimport type {\n AnyCircuitElement,\n PcbComponentInput,\n PcbSmtPad,\n PcbViaInput,\n} from \"circuit-json\"\nimport {\n any_source_component,\n pcb_courtyard_outline,\n pcb_hole,\n pcb_plated_hole,\n pcb_silkscreen_path,\n pcb_smtpad,\n pcb_via,\n} from \"circuit-json\"\nimport * as Soup from \"circuit-json\"\nimport { applyToPoint, compose, scale, translate } from \"transformation-matrix\"\nimport type { z } from \"zod\"\nimport { generateArcFromSweep, generateArcPathWithMid } from \"./math/arc-utils\"\nimport type { BetterEasyEdaJson } from \"./schemas/easy-eda-json-schema\"\nimport type {\n ArcSchema,\n HoleSchema,\n PadSchema,\n SVGNodeSchema,\n SolidRegionSchema,\n TrackSchema,\n ViaSchema,\n} from \"./schemas/package-detail-shape-schema\"\nimport { mil10ToMm } from \"./utils/easyeda-unit-to-mm\"\nimport { normalizePinLabels } from \"./utils/normalize-pin-labels\"\nimport { normalizeSymbolName } from \"./utils/normalize-symbol-name\"\nimport { DEFAULT_PCB_THICKNESS_MM } from \"./constants\"\n\nconst EASYEDA_STEP_MODEL_URL =\n \"https://modules.easyeda.com/qAxj6KHrDKw4blvCG8QJPs7Y\"\nconst EASYEDA_OBJ_MODEL_URL = \"https://modules.easyeda.com/3dmodel\"\nconst TSCIRCUIT_MODEL_CDN_URL = \"https://modelcdn.tscircuit.com/easyeda_models\"\n\n/**\n * Some components, like paths and \"HOLE\", seem to use mil*10 as\n * their unlabeled unit\n */\nconst milx10 = (mil10: number | string) => {\n if (typeof mil10 === \"number\") return mil2mm(mil10) * 10\n if (mil10.match(/^\\d+$/)) return mil2mm(mil10) * 10\n // If it has a unit, return the specified unit ignoring the multiplier\n return mil2mm(mil10)\n}\n\nconst parseCadOffsetsFromSvgNode = (\n svgNode?: z.infer<typeof SVGNodeSchema>,\n) => {\n const attrs = svgNode?.svgData?.attrs ?? {}\n const [cx, cy] = String(attrs.c_origin ?? \"0,0\")\n .split(\",\")\n .map((s) => Number(s.trim()))\n\n // z: bare numbers are mils; strings with units go through mm()\n const zStr = attrs.z ?? 0\n const z_mm =\n typeof zStr === \"string\" && /[a-z]/i.test(zStr)\n ? mm(zStr) // already has units\n : mm(`${Number(zStr) || 0}mil`) // bare number => mils\n\n return {\n position: {\n x: mil10ToMm(Number.isNaN(cx) ? 0 : cx),\n y: mil10ToMm(Number.isNaN(cy) ? 0 : cy),\n z: z_mm,\n },\n rotation: (() => {\n const [rx, ry, rz] = (attrs.c_rotation ?? \"0,0,0\").split(\",\").map(Number)\n return { x: rx || 0, y: ry || 0, z: rz || 0 }\n })(),\n }\n}\n\n/** Try mil and mil×10; clamp to a plausible component thickness */\nconst readModelHeightMm = (raw: unknown) => {\n const fallback = 3.5 // typical SMT component height (USB-C, QFN, etc.)\n if (raw == null) return fallback\n const n = Number(raw)\n if (!Number.isFinite(n)) return fallback\n\n const mmFromMil10 = mil10ToMm(n) // many EasyEDA unlabeled values\n const mmFromMil = mm(`${n}mil`) // sometimes plain mil\n\n // Use the larger of the two guesses, but clamp to a plausible thickness\n const upper = 12 // max reasonable package thickness (mm) - increased for connectors\n const lower = 0.1\n let chosen = Math.max(mmFromMil10, mmFromMil)\n if (chosen > upper || chosen < lower) chosen = fallback\n\n return chosen\n}\n\nconst handleSilkscreenPath = (\n track: z.infer<typeof TrackSchema>,\n index: number,\n) => {\n return pcb_silkscreen_path.parse({\n type: \"pcb_silkscreen_path\",\n pcb_silkscreen_path_id: `pcb_silkscreen_path_${index + 1}`,\n pcb_component_id: \"pcb_component_1\",\n layer: \"top\", // Assuming all silkscreen is on top layer\n route: track.points.map((point) => ({\n x: milx10(point.x),\n y: milx10(point.y),\n })),\n stroke_width: mil10ToMm(track.width),\n })\n}\n\nconst isCourtyardLayer = (layer?: number) =>\n layer === 13 || layer === 14 || layer === 15\n\nconst getSideFromLayer = (layer?: number): \"top\" | \"bottom\" => {\n if (layer === 4 || layer === 14) return \"bottom\"\n return \"top\"\n}\n\nconst handleSilkscreenArc = (arc: z.infer<typeof ArcSchema>, index: number) => {\n const arcPath = generateArcFromSweep(\n arc.start.x,\n arc.start.y,\n arc.end.x,\n arc.end.y,\n arc.radiusX,\n arc.largeArc,\n arc.sweepDirection === \"CW\",\n )\n\n return pcb_silkscreen_path.parse({\n type: \"pcb_silkscreen_path\",\n pcb_silkscreen_path_id: `pcb_silkscreen_arc_${index + 1}`,\n pcb_component_id: \"pcb_component_1\",\n layer: \"top\", // Assuming all silkscreen is on top layer\n route: arcPath.map((p) => ({\n x: milx10(p.x),\n y: milx10(p.y),\n })),\n stroke_width: mil10ToMm(arc.width),\n } as Soup.PcbSilkscreenPathInput)\n}\n\nconst handleHole = (hole: z.infer<typeof HoleSchema>, index: number) => {\n return pcb_hole.parse({\n type: \"pcb_hole\",\n x: milx10(hole.center.x),\n y: milx10(hole.center.y),\n hole_diameter: milx10(hole.radius) * 2,\n hole_shape: \"circle\",\n pcb_hole_id: `pcb_hole_${index + 1}`,\n } as Soup.PcbHole)\n}\n\nconst handleHoleCutout = (hole: z.infer<typeof HoleSchema>, index: number) => {\n return Soup.pcb_cutout.parse({\n type: \"pcb_cutout\",\n pcb_cutout_id: `pcb_cutout_from_hole_${index + 1}`,\n shape: \"circle\",\n center: { x: milx10(hole.center.x), y: milx10(hole.center.y) },\n radius: milx10(hole.radius),\n } as Soup.PcbCutoutCircleInput)\n}\n\nconst handleVia = (via: z.infer<typeof ViaSchema>, index: number) => {\n return pcb_via.parse({\n type: \"pcb_via\",\n pcb_via_id: `pcb_via_${index + 1}`,\n x: milx10(via.center.x),\n y: milx10(via.center.y),\n outer_diameter: milx10(via.outerDiameter),\n hole_diameter: milx10(via.holeDiameter),\n layers: [\"top\", \"bottom\"],\n } as PcbViaInput)\n}\n\nconst handleCutout = (\n solidRegion: z.infer<typeof SolidRegionSchema>,\n index: number,\n) => {\n return Soup.pcb_cutout.parse({\n type: \"pcb_cutout\",\n pcb_cutout_id: `pcb_cutout_${index + 1}`,\n shape: \"polygon\",\n points: solidRegion.points.map((p) => ({\n x: milx10(p.x),\n y: milx10(p.y),\n })),\n } as Soup.PcbCutoutPolygonInput)\n}\n\ninterface Options {\n useModelCdn?: boolean\n shouldRecenter?: boolean\n cadPositionXMm?: number\n cadPositionYMm?: number\n cadPositionZMm?: number\n showDesignator?: boolean\n}\n\nconst getCadPositionZMmFromMetadata = (easyEdaJson: BetterEasyEdaJson) => {\n const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(\n (shape) => shape.type === \"SVGNODE\" && shape.svgData.attrs?.uuid,\n )\n if (!svgNode || svgNode.type !== \"SVGNODE\") return undefined\n\n const svgNodeZ = Number(svgNode.svgData.attrs?.z ?? 0)\n if (!Number.isFinite(svgNodeZ)) return undefined\n\n const bounds = easyEdaJson._objMetadata?.bounds\n if (!bounds) return undefined\n\n const minZ = Math.abs(bounds.min.z) < 1e-6 ? 0 : bounds.min.z\n return minZ - mil10ToMm(svgNodeZ)\n}\n\nexport const convertEasyEdaJsonToCircuitJson = (\n easyEdaJson: BetterEasyEdaJson,\n {\n useModelCdn,\n shouldRecenter = true,\n cadPositionXMm,\n cadPositionYMm,\n cadPositionZMm,\n showDesignator = false,\n }: Options = {},\n): AnyCircuitElement[] => {\n const resolvedCadPositionZMm =\n cadPositionZMm ?? getCadPositionZMmFromMetadata(easyEdaJson)\n const circuitElements: AnyCircuitElement[] = []\n\n // Add source component\n const source_component = any_source_component.parse({\n type: \"source_component\",\n source_component_id: \"source_component_1\",\n name: \"U1\",\n ftype: \"simple_chip\",\n })\n\n const pcb_component = Soup.pcb_component.parse({\n type: \"pcb_component\",\n pcb_component_id: \"pcb_component_1\",\n source_component_id: \"source_component_1\",\n name: \"U1\",\n ftype: \"simple_chip\",\n width: 0, // we update this at the end\n height: 0, // we update this at the end\n rotation: 0,\n center: { x: 0, y: 0 },\n layer: \"top\",\n } as PcbComponentInput)\n\n circuitElements.push(source_component, pcb_component)\n\n const pads = easyEdaJson.packageDetail.dataStr.shape.filter(\n (shape): shape is z.infer<typeof PadSchema> => shape.type === \"PAD\",\n )\n const pins = easyEdaJson.dataStr.shape.filter((shape) => shape.type === \"PIN\")\n\n // Prepare pin labels for normalization\n const pinLabelSets = pads.map((pad) => {\n const labels = []\n if (pad.number) labels.push(pad.number.toString())\n\n const pin = pins.find((p) => p.pinNumber === pad.number)\n if (pin) labels.push(normalizeSymbolName(pin.label))\n\n return labels\n })\n\n const normalizedPinLabels = normalizePinLabels(pinLabelSets)\n\n // Add source ports and pcb_smtpads\n pads.forEach((pad, index) => {\n const portHints = normalizedPinLabels[index]\n const pinNumber = Number.parseInt(\n portHints.find((hint) => hint.match(/pin\\d+/))!.replace(\"pin\", \"\"),\n )\n\n // Add source port\n circuitElements.push({\n type: \"source_port\",\n source_port_id: `source_port_${index + 1}`,\n source_component_id: \"source_component_1\",\n name: `pin${pinNumber}`,\n pin_number: pinNumber,\n port_hints: portHints.filter((hint) => hint !== `pin${pinNumber}`),\n })\n\n if (pad.holeRadius !== undefined && mil2mm(pad.holeRadius) !== 0) {\n // Add pcb_plated_hole\n const platedHoleId =\n pad.shape === \"RECT\" && pad.rotation !== undefined\n ? `pcb_plated_hole_${index + 1}_rot${pad.rotation}`\n : `pcb_plated_hole_${index + 1}`\n\n const commonPlatedHoleProps = {\n type: \"pcb_plated_hole\",\n pcb_plated_hole_id: platedHoleId,\n x: mil2mm(pad.center.x),\n y: mil2mm(pad.center.y),\n layers: [\"top\"],\n port_hints: [`pin${pinNumber}`],\n pcb_component_id: \"pcb_component_1\",\n pcb_port_id: `pcb_port_${index + 1}`,\n }\n let additionalPlatedHoleProps: any\n\n if (pad.shape === \"OVAL\") {\n // A JLCPCB Oval is actually a Pill, and it's a bit tricky to compute\n // the correct dimensions, but we can use the following process:\n // 1. Find the smallest outer dimensions\n // 2. Use the holeRadius to determine the distanceFromOuterPlatingToHole\n // 3. Calculate the largest \"inner dimension\" (which is either the\n // holeWidth or holeHeight) by subtracting the distanceFromOuterPlatingToHole * 2\n // from the largest outer dimensions\n\n const largestOuterDimensionName: \"width\" | \"height\" =\n mil2mm(pad.width) > mil2mm(pad.height) ? \"width\" : \"height\"\n\n const smallestOuterDimension = Math.min(\n mil2mm(pad.width),\n mil2mm(pad.height),\n )\n const largestOuterDimension = Math.max(\n mil2mm(pad.width),\n mil2mm(pad.height),\n )\n\n const distanceFromOuterPlatingToHole =\n smallestOuterDimension / 2 - mil2mm(pad.holeRadius)\n\n const largestInnerDimension =\n largestOuterDimension - distanceFromOuterPlatingToHole * 2\n const smallestInnerDimension = mil2mm(pad.holeRadius) * 2\n\n const innerWidth =\n largestOuterDimensionName === \"width\"\n ? largestInnerDimension\n : smallestInnerDimension\n const innerHeight =\n largestOuterDimensionName === \"height\"\n ? largestInnerDimension\n : smallestInnerDimension\n\n additionalPlatedHoleProps = {\n shape: \"pill_hole_with_rect_pad\",\n hole_shape: \"pill\",\n pad_shape: \"rect\",\n hole_width: innerWidth,\n hole_height: innerHeight,\n rect_pad_width: mil2mm(pad.width),\n rect_pad_height: mil2mm(pad.height),\n hole_offset_x: 0,\n hole_offset_y: 0,\n }\n } else if (pad.shape === \"RECT\") {\n const padWidth = mil2mm(pad.width)\n const padHeight = mil2mm(pad.height)\n const holeRadius = mil2mm(pad.holeRadius)\n const holeDiameter = holeRadius * 2 // Use normal diameter\n\n // Check if the pad is significantly rectangular (not square)\n const aspectRatio =\n Math.max(padWidth, padHeight) / Math.min(padWidth, padHeight)\n const isSignificantlyRectangular = aspectRatio > 1.5 // Only use pill holes for aspect ratios > 1.5\n\n if (isSignificantlyRectangular) {\n // Simple approach: create slim pill holes with consistent proportions\n // Width = original hole diameter, Height = 2.6x width for good pill shape\n const baseWidth = holeDiameter\n const pillHeight = baseWidth * 2.6 // 2.6:1 aspect ratio for elegant pills\n\n const holeWidth = padWidth > padHeight ? pillHeight : baseWidth\n const holeHeight = padHeight > padWidth ? pillHeight : baseWidth\n\n additionalPlatedHoleProps = {\n shape: \"rotated_pill_hole_with_rect_pad\",\n hole_shape: \"rotated_pill\",\n pad_shape: \"rect\",\n hole_width: holeWidth,\n hole_height: holeHeight,\n hole_ccw_rotation: pad.rotation || 0,\n rect_ccw_rotation: pad.rotation || 0,\n rect_pad_width: padWidth,\n rect_pad_height: padHeight,\n }\n } else {\n // For square or nearly square pads, use circular holes\n additionalPlatedHoleProps = {\n shape: \"circle\",\n hole_diameter: holeDiameter,\n outer_diameter: Math.max(padWidth, padHeight),\n radius: holeDiameter / 2,\n }\n }\n } else {\n additionalPlatedHoleProps = {\n shape: \"circle\",\n hole_diameter: mil2mm(pad.holeRadius) * 2,\n outer_diameter: mil2mm(pad.width),\n radius: mil2mm(pad.holeRadius),\n }\n }\n\n circuitElements.push(\n pcb_plated_hole.parse({\n ...commonPlatedHoleProps,\n ...additionalPlatedHoleProps,\n }),\n )\n } else {\n // Add pcb_smtpad\n let soupShape: PcbSmtPad[\"shape\"] | undefined\n if (pad.shape === \"RECT\") {\n soupShape = \"rect\"\n } else if (pad.shape === \"ELLIPSE\") {\n // This is just a bug\n soupShape = \"rect\"\n } else if (pad.shape === \"OVAL\") {\n // OVAL is often a rect, especially when holeRadius is 0\n soupShape = \"rect\"\n } else if (pad.shape === \"POLYGON\") {\n soupShape = \"polygon\"\n }\n if (!soupShape) {\n throw new Error(`unknown pad.shape: \"${pad.shape}\"`)\n }\n\n const rectSize = { width: mil2mm(pad.width), height: mil2mm(pad.height) }\n if (pad.rotation === 90 || pad.rotation === 270) {\n // Swap width and height\n rectSize.width = mil2mm(pad.height)\n rectSize.height = mil2mm(pad.width)\n }\n\n const parsedPcbSmtpad = pcb_smtpad.parse({\n type: \"pcb_smtpad\",\n pcb_smtpad_id: `pcb_smtpad_${index + 1}`,\n shape: soupShape,\n ...(soupShape !== \"polygon\" && {\n x: mil2mm(pad.center.x),\n y: mil2mm(pad.center.y),\n }),\n ...(soupShape === \"rect\"\n ? rectSize\n : soupShape === \"polygon\" && pad.points\n ? {\n points: pad.points.map((p) => ({\n x: milx10(p.x),\n y: milx10(p.y),\n })),\n }\n : { radius: Math.min(mil2mm(pad.width), mil2mm(pad.height)) / 2 }),\n layer: \"top\",\n port_hints: [`pin${pinNumber}`],\n pcb_component_id: \"pcb_component_1\",\n pcb_port_id: `pcb_port_${index + 1}`,\n } as PcbSmtPad)\n circuitElements.push(parsedPcbSmtpad)\n }\n })\n\n // Add holes\n easyEdaJson.packageDetail.dataStr.shape\n .filter(\n (shape): shape is z.infer<typeof HoleSchema> => shape.type === \"HOLE\",\n )\n .forEach((h, index) => {\n circuitElements.push(handleHole(h, index))\n circuitElements.push(handleHoleCutout(h, index))\n })\n\n // Add vias\n easyEdaJson.packageDetail.dataStr.shape\n .filter((shape): shape is z.infer<typeof ViaSchema> => shape.type === \"VIA\")\n .forEach((v, index) => {\n circuitElements.push(handleVia(v, index))\n })\n\n // Add pcb cutouts from solid regions marked as cutout\n easyEdaJson.packageDetail.dataStr.shape\n .filter(\n (shape): shape is z.infer<typeof SolidRegionSchema> =>\n shape.type === \"SOLIDREGION\" && shape.fillStyle === \"cutout\",\n )\n .forEach((sr, index) => {\n circuitElements.push(handleCutout(sr, index))\n })\n\n // Add silkscreen paths, arcs and text\n let hasFoundDesignator = false\n easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {\n if (shape.type === \"TRACK\") {\n if (!isCourtyardLayer(shape.layer)) {\n circuitElements.push(handleSilkscreenPath(shape, index))\n }\n } else if (shape.type === \"ARC\") {\n if (!isCourtyardLayer(shape.layer)) {\n circuitElements.push(handleSilkscreenArc(shape, index))\n }\n } else if (shape.type === \"TEXT\") {\n if (isCourtyardLayer(shape.layer)) return\n\n let text = shape.text\n const designatorPrefix = easyEdaJson.dataStr.head.c_para.pre || \"U\"\n const normalizedPrefix = designatorPrefix.replace(/\\?/g, \"\")\n const trimmedText = text.trim()\n const isDesignator =\n trimmedText === designatorPrefix ||\n trimmedText === `${normalizedPrefix}?` ||\n trimmedText === normalizedPrefix\n\n if (isDesignator) {\n if (!showDesignator) return\n text = \"{NAME}\"\n hasFoundDesignator = true\n }\n\n circuitElements.push(\n Soup.pcb_silkscreen_text.parse({\n type: \"pcb_silkscreen_text\",\n pcb_silkscreen_text_id: `pcb_silkscreen_text_${index + 1}`,\n pcb_component_id: \"pcb_component_1\",\n text,\n anchor_position: {\n x: mil2mm(shape.x),\n y: mil2mm(shape.y),\n },\n anchor_alignment: (\n {\n L: \"bottom_left\",\n C: \"center\",\n R: \"bottom_right\",\n } as const\n )[shape.textAnchor ?? \"L\"],\n font_size: shape.size_mm || 1.0,\n layer: \"top\",\n } as Soup.PcbSilkscreenTextInput),\n )\n }\n })\n\n // Add a fallback designator if none was found in the shapes\n if (!hasFoundDesignator && showDesignator) {\n const bbox = easyEdaJson.packageDetail.dataStr.BBox\n circuitElements.push(\n Soup.pcb_silkscreen_text.parse({\n type: \"pcb_silkscreen_text\",\n pcb_silkscreen_text_id: `pcb_silkscreen_text_designator_fallback`,\n pcb_component_id: \"pcb_component_1\",\n text: \"{NAME}\",\n anchor_position: {\n x: milx10(bbox.x + bbox.width / 2),\n y: milx10(bbox.y) - 1.0, // 1mm above top edge\n },\n anchor_alignment: \"center\",\n font_size: 1.0,\n layer: \"top\",\n } as Soup.PcbSilkscreenTextInput),\n )\n }\n\n // Only add designator if found in EasyEDA\n\n // Calculate pcb_component bounds from all PCB elements\n const pcbElements = circuitElements.filter(\n (e) =>\n e.type === \"pcb_smtpad\" ||\n e.type === \"pcb_plated_hole\" ||\n e.type === \"pcb_hole\" ||\n e.type === \"pcb_via\" ||\n e.type === \"pcb_courtyard_outline\" ||\n e.type === \"pcb_silkscreen_path\" ||\n e.type === \"pcb_silkscreen_text\",\n )\n\n if (pcbElements.length > 0) {\n const bounds = findBoundsAndCenter(pcbElements)\n pcb_component.width = bounds.width\n pcb_component.height = bounds.height\n }\n\n // Add 3d component\n const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(\n (a): a is z.infer<typeof SVGNodeSchema> =>\n Boolean(a.type === \"SVGNODE\" && a.svgData.attrs?.uuid),\n )\n const modelUuid = svgNode?.svgData?.attrs?.uuid\n\n const objFileUrl = modelUuid\n ? useModelCdn\n ? `${TSCIRCUIT_MODEL_CDN_URL}/assets/${easyEdaJson.lcsc.number}.obj?uuid=${modelUuid}`\n : `${EASYEDA_OBJ_MODEL_URL}/${modelUuid}`\n : undefined\n\n const stepFileUrl = modelUuid\n ? useModelCdn\n ? `${TSCIRCUIT_MODEL_CDN_URL}/assets/${easyEdaJson.lcsc.number}.step?uuid=${modelUuid}`\n : `${EASYEDA_STEP_MODEL_URL}/${modelUuid}`\n : undefined\n\n if (objFileUrl !== undefined || stepFileUrl !== undefined) {\n const { position, rotation } = parseCadOffsetsFromSvgNode(svgNode)\n\n circuitElements.push(\n Soup.cad_component.parse({\n type: \"cad_component\",\n cad_component_id: \"cad_component_1\",\n source_component_id: \"source_component_1\",\n pcb_component_id: \"pcb_component_1\",\n anchor_alignment: \"center_of_component_on_board_surface\",\n model_origin_alignment: \"center_of_component_on_board_surface\",\n model_origin_position: {\n x: cadPositionXMm ?? 0,\n y: cadPositionYMm ?? 0,\n z: resolvedCadPositionZMm ?? position.z,\n },\n position: { x: 0, y: 0, z: 0 },\n rotation,\n model_obj_url: objFileUrl,\n model_step_url: stepFileUrl,\n } as Soup.CadComponentInput),\n )\n }\n\n // Generate courtyard outline from packageDetail.dataStr.BBox when no explicit\n // courtyard TRACK (layers 13/14/15) exists. The BBox is EasyEDA's own bounding\n // box for the footprint in canvas coordinates (milx10 units). It is added before\n // recentering so it gets transformed automatically with all other elements.\n const hasExplicitCourtyard = circuitElements.some(\n (e) => e.type === \"pcb_courtyard_outline\",\n )\n if (!hasExplicitCourtyard) {\n const bbox = easyEdaJson.packageDetail.dataStr.BBox\n if (bbox) {\n const strokeWidth = 0.05\n const margin = 0.25\n const x1 = milx10(bbox.x) - margin\n const y1 = milx10(bbox.y) - margin\n const x2 = milx10(bbox.x + bbox.width) + margin\n const y2 = milx10(bbox.y + bbox.height) + margin\n circuitElements.push(\n pcb_courtyard_outline.parse({\n type: \"pcb_courtyard_outline\",\n pcb_courtyard_outline_id: `pcb_courtyard_outline_${easyEdaJson.lcsc.number}_1`,\n pcb_component_id: \"pcb_component_1\",\n layer: \"top\",\n outline: [\n { x: x1, y: y1 },\n { x: x2, y: y1 },\n { x: x2, y: y2 },\n { x: x1, y: y2 },\n { x: x1, y: y1 },\n ],\n stroke_width: strokeWidth,\n }),\n )\n }\n }\n\n if (shouldRecenter) {\n // exclude pcb_component (its center is wrong; we'll set it to 0,0)\n const elementsForBounds = circuitElements.filter(\n (e) => e.type !== \"pcb_component\" && e.type !== \"cad_component\",\n )\n\n const bounds = findBoundsAndCenter(elementsForBounds)\n\n if (Number.isFinite(bounds.center.x) && Number.isFinite(bounds.center.y)) {\n const matrix = compose(\n translate(-bounds.center.x, bounds.center.y),\n scale(1, -1),\n )\n\n // Transform all PCB elems except polygon SMT pads (no x,y) and the cad\n const elementsForTransform = circuitElements.filter(\n (e) =>\n !(e.type === \"pcb_smtpad\" && e.shape === \"polygon\") &&\n e.type !== \"cad_component\",\n )\n transformPCBElements(elementsForTransform, matrix)\n\n // Manually transform polygons/cutouts\n for (const e of circuitElements) {\n if (e.type === \"pcb_cutout\") {\n if (e.shape === \"polygon\") {\n e.points = e.points.map((p) => applyToPoint(matrix, p))\n } else if (e.shape === \"circle\" || e.shape === \"rect\") {\n e.center = applyToPoint(matrix, e.center)\n } else if (\"route\" in e) {\n const cutoutPath = e as unknown as {\n route: { x: number; y: number }[]\n }\n cutoutPath.route = cutoutPath.route.map((p) =>\n applyToPoint(matrix, p),\n )\n }\n } else if (e.type === \"pcb_smtpad\" && e.shape === \"polygon\") {\n e.points = e.points.map((p) => applyToPoint(matrix, p))\n }\n }\n\n const cad = circuitElements.find(\n (e): e is Soup.CadComponent => e.type === \"cad_component\",\n )\n\n if (cad) {\n if (!cad.rotation) cad.rotation = { x: 0, y: 0, z: 0 }\n if (!cad.model_origin_position) {\n cad.model_origin_position = { x: 0, y: 0, z: 0 }\n }\n\n const side = (pcb_component.layer ?? \"top\") as \"top\" | \"bottom\"\n const t = DEFAULT_PCB_THICKNESS_MM / 2\n const attrs = svgNode?.svgData?.attrs ?? {}\n const modelHeight = readModelHeightMm(attrs.c_height)\n\n // Ensure we have a size; Z holds the model's thickness in local space\n if (!cad.size) {\n cad.size = {\n x: pcb_component.width,\n y: pcb_component.height,\n z: modelHeight,\n }\n }\n\n // --- Axis convention: EasyEDA models are typically Y-up ---\n // Rotate to Z-up so thickness becomes vertical in our scene.\n const ROTATE_X_FOR_YUP = 90\n const originalZRotation = (cad.rotation.z ?? 0) % 360\n\n // Improved rotation handling with tolerance for floating-point precision\n // Handle different component orientations based on EasyEDA Z rotation\n if (\n Math.abs(originalZRotation - 0) < 1 ||\n Math.abs(originalZRotation - 360) < 1\n ) {\n // For ~0° Z rotation, don't apply X rotation - keep model as-is (Y-up)\n cad.rotation.x = ((cad.rotation.x ?? 0) + 0 + 360) % 360 // no X rotation\n } else if (Math.abs(originalZRotation - 180) < 1) {\n // For ~180° Z rotation, don't apply standard X rotation - let it lie flat\n cad.rotation.x = ((cad.rotation.x ?? 0) + 0 + 360) % 360 // no X rotation\n } else if (Math.abs(originalZRotation - 90) < 1) {\n // For ~90° Z rotation, keep it flat (no X rotation)\n cad.rotation.x = ((cad.rotation.x ?? 0) + 0 + 360) % 360\n } else if (Math.abs(originalZRotation - 270) < 1) {\n // Keep EasyEDA's raw 270° orientation; adding corrective X/Y rotations\n // makes parts like C9900017879 stand on their side.\n cad.rotation.x = ((cad.rotation.x ?? 0) + 0 + 360) % 360\n cad.rotation.y = ((cad.rotation.y ?? 0) + 0 + 360) % 360\n } else {\n // Fallback for unusual angles: apply standard Y-up to Z-up conversion\n // and log for potential future refinement\n console.warn(\n `[3D] Unusual rotation angle: ${originalZRotation}° for component ${easyEdaJson.lcsc.number}`,\n )\n cad.rotation.x =\n ((cad.rotation.x ?? 0) + ROTATE_X_FOR_YUP + 360) % 360\n }\n\n // Bottom-side parts: flip across the board plane\n if (side !== \"top\") {\n cad.rotation.x = ((cad.rotation.x ?? 0) + 180) % 360\n }\n\n // For 180° rotated components (Y-up models), the z-offset indicates pin extension below body\n const USE_Z_OFFSET_FOR_180 = Math.abs(originalZRotation - 180) < 1\n const zOffRaw = cad.model_origin_position.z ?? cad.position.z ?? 0\n const zOff = USE_Z_OFFSET_FOR_180 ? -zOffRaw : 0\n\n // ---- Determine the vertical extent based on model orientation ----\n const rx = ((cad.rotation.x % 360) + 360) % 360\n\n // EasyEDA models are Y-up. Components with 0° or 180° Z-rotation don't get X-rotation applied,\n // so they remain Y-up. For Y-up models, the vertical extent is along the Y axis.\n let thicknessAlongWorldZ: number\n const is180RotatedYUp =\n (Math.abs(originalZRotation - 180) < 1 ||\n Math.abs(originalZRotation - 0) < 1 ||\n Math.abs(originalZRotation - 360) < 1) &&\n Math.abs(rx) < 1\n\n if (is180RotatedYUp) {\n // 180° Z-rotation, no X-rotation applied → model is still Y-up\n // For Y-up models, the vertical extent is along Y axis (size.y)\n thicknessAlongWorldZ = cad.size.y\n } else if (rx % 180 === 90) {\n // X-rotation of 90/270 → use local Y\n thicknessAlongWorldZ = cad.size.y\n } else {\n // Standard case → model rotated to Z-up, use Z\n thicknessAlongWorldZ = cad.size.z\n }\n\n if (Number.isFinite(resolvedCadPositionZMm)) {\n cad.model_origin_position.z =\n side === \"top\" ? resolvedCadPositionZMm! : -resolvedCadPositionZMm!\n } else {\n let centerZ: number\n if (is180RotatedYUp) {\n // For Y-up models, subtract half the thickness to lower the component to the board\n centerZ =\n side === \"top\"\n ? t - thicknessAlongWorldZ / 2\n : -t + thicknessAlongWorldZ / 2\n } else {\n // For other orientations, use standard positioning with z-offset\n centerZ =\n side === \"top\"\n ? t + zOff + thicknessAlongWorldZ / 2\n : -t - zOff - thicknessAlongWorldZ / 2\n }\n\n cad.model_origin_position.z = centerZ\n }\n }\n }\n\n // finalize pcb center after recentering\n pcb_component.center = { x: 0, y: 0 }\n }\n\n return circuitElements\n}\n","type Params = {\n easyedaPartNumber: string\n easyedaModelUuid: string\n}\n\nexport const getModelObjCdnUrl = ({\n easyedaModelUuid,\n easyedaPartNumber,\n}: Params): string => {\n return `https://modelcdn.tscircuit.com/easyeda_models/assets/${easyedaPartNumber}.obj?uuid=${easyedaModelUuid}`\n}\n\nexport const getModelStepCdnUrl = ({\n easyedaModelUuid,\n easyedaPartNumber,\n}: Params): string => {\n return `https://modelcdn.tscircuit.com/easyeda_models/assets/${easyedaPartNumber}.step?uuid=${easyedaModelUuid}`\n}\n\nexport const getModelCdnUrl = getModelObjCdnUrl\n","import type { RawEasyEdaJson } from \"../schemas/easy-eda-json-schema\"\nimport { getModelCdnUrl } from \"./get-model-cdn-url\"\n\ntype ModelBounds = {\n min: { x: number; y: number; z: number }\n max: { x: number; y: number; z: number }\n}\n\nconst getModelUuidFromRawPackageDetail = (result: RawEasyEdaJson) => {\n const shapes = result.packageDetail?.dataStr?.shape\n if (!Array.isArray(shapes)) return null\n\n for (const shape of shapes) {\n if (typeof shape !== \"string\" || !shape.startsWith(\"SVGNODE~\")) continue\n\n const svgNodeJson = shape.slice(\"SVGNODE~\".length)\n try {\n const svgNode = JSON.parse(svgNodeJson)\n const modelUuid = svgNode?.attrs?.uuid\n if (typeof modelUuid === \"string\" && modelUuid.length > 0) {\n return modelUuid\n }\n } catch {}\n }\n\n return null\n}\n\nconst parseObjBounds = (objText: string): ModelBounds | null => {\n let minX = Number.POSITIVE_INFINITY\n let minY = Number.POSITIVE_INFINITY\n let minZ = Number.POSITIVE_INFINITY\n let maxX = Number.NEGATIVE_INFINITY\n let maxY = Number.NEGATIVE_INFINITY\n let maxZ = Number.NEGATIVE_INFINITY\n let vertexCount = 0\n\n for (const line of objText.split(/\\r?\\n/)) {\n const trimmed = line.trim()\n if (!trimmed.startsWith(\"v \")) continue\n\n const [, xStr, yStr, zStr] = trimmed.split(/\\s+/, 4)\n const x = Number(xStr)\n const y = Number(yStr)\n const z = Number(zStr)\n\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) {\n continue\n }\n\n vertexCount += 1\n minX = Math.min(minX, x)\n minY = Math.min(minY, y)\n minZ = Math.min(minZ, z)\n maxX = Math.max(maxX, x)\n maxY = Math.max(maxY, y)\n maxZ = Math.max(maxZ, z)\n }\n\n if (vertexCount === 0) return null\n\n return {\n min: { x: minX, y: minY, z: minZ },\n max: { x: maxX, y: maxY, z: maxZ },\n }\n}\n\nexport async function fetchEasyEDAComponent(\n jlcpcbPartNumber: string,\n {\n fetch = globalThis.fetch,\n includeModelMetadata = true,\n }: {\n fetch?: typeof globalThis.fetch\n includeModelMetadata?: boolean\n } = {},\n): Promise<RawEasyEdaJson> {\n const searchUrl = \"https://easyeda.com/api/components/search\"\n const componentUrl = (uuid: string) =>\n `https://easyeda.com/api/components/${uuid}?version=6.4.7&uuid=${uuid}&datastrid=`\n\n const searchHeaders = {\n authority: \"easyeda.com\",\n pragma: \"no-cache\",\n \"cache-control\": \"no-cache\",\n accept: \"application/json, text/javascript, */*; q=0.01\",\n \"x-requested-with\": \"XMLHttpRequest\",\n \"user-agent\":\n \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36\",\n \"content-type\": \"application/x-www-form-urlencoded; charset=UTF-8\",\n origin: \"https://easyeda.com\",\n \"sec-fetch-site\": \"same-origin\",\n \"sec-fetch-mode\": \"cors\",\n \"sec-fetch-dest\": \"empty\",\n referer: \"https://easyeda.com/editor\",\n \"accept-language\": \"cs,en;q=0.9,sk;q=0.8,en-GB;q=0.7\",\n cookie: \"<PUT your cookies here>\",\n }\n\n const searchData = `type=3&doctype%5B%5D=2&uid=0819f05c4eef4c71ace90d822a990e87&returnListStyle=classifyarr&wd=${jlcpcbPartNumber}&version=6.4.7`\n\n // Perform the search request\n const searchResponse = await fetch(searchUrl, {\n method: \"POST\",\n headers: searchHeaders,\n body: searchData,\n })\n\n if (!searchResponse.ok) {\n throw new Error(\"Failed to search for the component\")\n }\n\n const searchResult = await searchResponse.json()\n if (!searchResult.success || !searchResult.result.lists.lcsc.length) {\n throw new Error(\"Component not found\")\n }\n\n const bestMatchComponent =\n searchResult.result.lists.lcsc.find(\n (component: any) =>\n component.dataStr.head.c_para[\"Supplier Part\"] === jlcpcbPartNumber,\n ) ?? searchResult.result.lists.lcsc[0]\n\n const componentUUID = bestMatchComponent.uuid\n\n // Perform the component fetch request\n const componentResponse = await fetch(componentUrl(componentUUID), {\n method: \"GET\",\n headers: {\n ...searchHeaders,\n referer: `https://easyeda.com/editor?uuid=${componentUUID}`,\n },\n })\n\n if (!componentResponse.ok) {\n throw new Error(\"Failed to fetch the component details\")\n }\n\n const componentResult = await componentResponse.json()\n const result = componentResult.result as RawEasyEdaJson\n\n if (includeModelMetadata) {\n const modelUuid = getModelUuidFromRawPackageDetail(result)\n const partNumber = result.lcsc?.number\n\n if (modelUuid && partNumber) {\n try {\n const objUrl = getModelCdnUrl({\n easyedaModelUuid: modelUuid,\n easyedaPartNumber: partNumber,\n })\n const objResponse = await fetch(objUrl)\n if (objResponse.ok) {\n const objText = await objResponse.text()\n const bounds = parseObjBounds(objText)\n if (bounds) {\n ;(\n result as RawEasyEdaJson & {\n _objMetadata?: { bounds: ModelBounds }\n }\n )._objMetadata = { bounds }\n }\n }\n } catch (error) {\n console.error(\n `Error fetching model metadata for ${jlcpcbPartNumber}:`,\n error,\n )\n }\n }\n }\n\n return result\n}\n\n// Usage example\n// fetchEasyEDAComponent(\"C558438\")\n// .then((component) => console.log(component))\n// .catch((error) => console.error(error))\n","import { z } from \"zod\"\nimport {\n PackageDetailShapeSchema,\n ShapeItemSchema,\n} from \"./package-detail-shape-schema\"\nimport { SingleLetterShapeSchema } from \"./single-letter-shape-schema\"\n\nexport const maybeNumber = z\n .any()\n .transform((k) => (k === \"nan\" || Number.isNaN(k) ? null : k))\n .pipe(z.number().nullable().optional())\n\nexport const SzlcscSchema = z.object({\n id: z.number(),\n number: z.string(),\n step: z.number().optional(),\n min: z.number().optional(),\n price: z.number().optional(),\n stock: z.number().optional(),\n url: z.string().url().optional(),\n image: z.string().optional().optional(),\n})\n\nexport const LcscSchema = z.object({\n id: z.number(),\n number: z.string(),\n step: z.number().optional(),\n min: z.number().optional(),\n price: z.number().optional(),\n stock: z.number().optional(),\n url: z.string().url().optional(),\n})\n\nexport const OwnerSchema = z.object({\n uuid: z.string(),\n username: z.string(),\n nickname: z.string(),\n avatar: z.string(),\n})\n\nexport const HeadSchema = z.object({\n docType: z.preprocess((val) => (val == null ? val : String(val)), z.string()),\n editorVersion: z.string(),\n c_para: z.record(z.string(), z.string().nullable()),\n x: z.number(),\n y: z.number(),\n puuid: z.string().optional(),\n uuid: z.string(),\n utime: z.preprocess((val) => {\n if (val === \"\") return 0\n if (typeof val === \"string\") return Number(val)\n return val\n }, z.number()),\n importFlag: z.number().optional(),\n c_spiceCmd: z.any().optional(),\n hasIdFlag: z.boolean(),\n})\n\nexport const BBoxSchema = z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n})\n\nexport const LayerItemSchema = z.object({\n name: z.string(),\n color: z.string(),\n visible: z.boolean(),\n active: z.boolean(),\n config: z.boolean(),\n transparency: z.boolean(),\n})\n\nexport const ObjectItemSchema = z.object({\n name: z.string(),\n visible: z.boolean(),\n locked: z.boolean(),\n})\n\nexport const DataStrSchema = z.object({\n head: HeadSchema,\n canvas: z.string(),\n shape: z.array(SingleLetterShapeSchema),\n BBox: BBoxSchema,\n colors: z.union([z.array(z.string()), z.record(z.string())]),\n})\n\nexport const PackageDetailDataStrSchema = z.object({\n head: HeadSchema,\n canvas: z.string(),\n shape: z\n .array(z.string())\n .transform((shapes) =>\n shapes.map((shape) => {\n const [type, ...data] = shape.split(\"~\")\n return ShapeItemSchema.parse({ type, data: data.join(\"~\") })\n }),\n )\n .pipe(z.array(PackageDetailShapeSchema)),\n layers: z.array(z.string()).transform((layers) =>\n layers.map((layer) => {\n const [name, color, visible, active, config, transparency] =\n layer.split(\"~\")\n return LayerItemSchema.parse({\n name,\n color,\n visible: visible === \"true\",\n active: active === \"true\",\n config: config === \"true\",\n transparency: transparency === \"true\",\n })\n }),\n ),\n objects: z.array(z.string()).transform((objects) =>\n objects.map((obj) => {\n const [name, visible, locked] = obj.split(\"~\")\n return ObjectItemSchema.parse({\n name,\n visible: visible === \"true\",\n locked: locked === \"true\",\n })\n }),\n ),\n BBox: BBoxSchema,\n netColors: z.array(z.unknown()).optional(),\n})\n\nexport const PackageDetailSchema = z.object({\n uuid: z.string(),\n title: z.string(),\n docType: z.number(),\n updateTime: z.number(),\n owner: OwnerSchema,\n datastrid: z.string(),\n writable: z.boolean(),\n dataStr: PackageDetailDataStrSchema,\n})\n\nexport const ModelBoundsSchema = z.object({\n min: z.object({\n x: z.number(),\n y: z.number(),\n z: z.number(),\n }),\n max: z.object({\n x: z.number(),\n y: z.number(),\n z: z.number(),\n }),\n})\n\nexport const EasyEdaJsonSchema = z.object({\n uuid: z.string(),\n title: z.string(),\n description: z.string(),\n docType: z.number(),\n type: z.number(),\n szlcsc: SzlcscSchema,\n lcsc: LcscSchema,\n owner: OwnerSchema,\n tags: z.array(z.string()),\n updateTime: z.number(),\n updated_at: z.string(),\n dataStr: DataStrSchema,\n verify: z.boolean(),\n SMT: z.boolean().optional(),\n datastrid: z.string(),\n jlcOnSale: z.number().optional(),\n writable: z.boolean(),\n isFavorite: z.boolean(),\n packageDetail: PackageDetailSchema,\n _objMetadata: z\n .object({\n bounds: ModelBoundsSchema,\n })\n .optional(),\n})\n\nexport type RawEasyEdaJson = z.input<typeof EasyEdaJsonSchema>\nexport type BetterEasyEdaJson = z.infer<typeof EasyEdaJsonSchema>\n","import { z } from \"zod\"\n\n// Helper function to safely convert values to numbers with a default\nconst safeNumber = (defaultValue = 0) =>\n z\n .union([z.number(), z.string()])\n .transform((val) => {\n const num = Number(val)\n return isNaN(num) ? defaultValue : num\n })\n .default(defaultValue)\n\nconst tenthmil = z\n .union([z.number(), z.string()])\n .optional()\n .transform((n) =>\n typeof n === \"string\" && n.endsWith(\"mil\")\n ? n\n : `${Number.parseFloat(n as string) * 10}mil`,\n )\n .pipe(z.string())\n\nexport const PointSchema = z\n .any()\n .transform((p) => {\n if (Array.isArray(p)) {\n const [x, y] = p\n return { x, y }\n }\n if (typeof p === \"object\") {\n return p\n }\n throw new Error(`Invalid point: ${p}`)\n })\n .pipe(\n z.object({\n x: z.number(),\n y: z.number(),\n }),\n )\n\nexport const BaseShapeSchema = z.object({\n type: z.string(),\n id: z.string().optional(),\n layer: z.coerce.number().optional(),\n})\n\nexport const TrackSchema = BaseShapeSchema.extend({\n type: z.literal(\"TRACK\"),\n width: z.coerce.number(),\n points: z.array(PointSchema),\n})\n\nexport const PadSchema = BaseShapeSchema.extend({\n type: z.literal(\"PAD\"),\n shape: z.enum([\"RECT\", \"ELLIPSE\", \"OVAL\", \"POLYGON\"]),\n center: z.object({\n x: tenthmil,\n y: tenthmil,\n }),\n width: tenthmil,\n height: tenthmil,\n layermask: z.number(),\n net: z.union([z.string(), z.number()]).optional(),\n number: z.union([z.string(), z.number()]),\n holeRadius: tenthmil,\n points: z.array(PointSchema).optional(),\n rotation: safeNumber(0), // Will default to 0 if NaN or missing\n plated: z.boolean(),\n})\n\n// TODO this should be in \"arc sweep\" format with the following fields:\n// start, end, radius, largeArc, sweepDirection\nexport const ArcSchema = BaseShapeSchema.extend({\n type: z.literal(\"ARC\"),\n width: z.number(),\n start: PointSchema,\n end: PointSchema,\n radiusX: z.number(),\n radiusY: z.number(),\n largeArc: z.boolean(),\n sweepDirection: z.enum([\"CW\", \"CCW\"]),\n})\n\nexport const CircleSchema = BaseShapeSchema.extend({\n type: z.literal(\"CIRCLE\"),\n center: PointSchema,\n radius: z.number(),\n width: z.number(),\n})\n\nexport const SolidRegionSchema = BaseShapeSchema.extend({\n type: z.literal(\"SOLIDREGION\"),\n layermask: z.number(),\n points: z.array(PointSchema),\n fillStyle: z.string(),\n})\n\nexport const SVGNodeSchema = BaseShapeSchema.extend({\n type: z.literal(\"SVGNODE\"),\n svgData: z.object({\n gId: z.string(),\n nodeName: z.string(),\n nodeType: z.number(),\n layerid: z.string(),\n attrs: z.record(z.string(), z.string()),\n childNodes: z.array(z.unknown()),\n }),\n})\n\n// e.g. \"HOLE~3999.449~3004.213~1.378~gge152~0\"\nexport const HoleSchema = BaseShapeSchema.extend({\n type: z.literal(\"HOLE\"),\n center: PointSchema,\n radius: z.number(),\n})\n\nexport const ViaSchema = BaseShapeSchema.extend({\n type: z.literal(\"VIA\"),\n center: PointSchema,\n outerDiameter: z.number(),\n holeDiameter: z.number(),\n})\n\nexport const RectSchema = BaseShapeSchema.extend({\n type: z.literal(\"RECT\"),\n x: tenthmil,\n y: tenthmil,\n width: tenthmil,\n height: tenthmil,\n lineWidth: z.number(),\n fillStyle: z.string(),\n rotation: z.number().optional(),\n})\n\nexport const TextSchema = BaseShapeSchema.extend({\n type: z.literal(\"TEXT\"),\n text: z.string(),\n x: tenthmil,\n y: tenthmil,\n size_mm: z.number(),\n rotation: z.number().optional(),\n layer: z.number().optional(),\n textAnchor: z\n .enum([\"L\", \"C\", \"R\", \"\"])\n .optional()\n .transform((val) => (val === \"\" ? undefined : val)),\n font: z.string().optional(),\n})\n\nexport const PackageDetailShapeSchema = z.discriminatedUnion(\"type\", [\n TrackSchema,\n PadSchema,\n ArcSchema,\n CircleSchema,\n SolidRegionSchema,\n SVGNodeSchema,\n HoleSchema,\n ViaSchema,\n RectSchema,\n TextSchema,\n])\n\nconst pairs = <T>(arr: T[]): [T, T][] => {\n const pairs: [T, T][] = []\n for (let i = 0; i < arr.length; i += 2) {\n pairs.push([arr[i], arr[i + 1]])\n }\n return pairs\n}\n\nconst parsePoints = (pointsStr: string): number[][] =>\n pairs(\n pointsStr\n .trim()\n .split(\" \")\n .map((n) => Number(n)),\n )\n\nexport const ShapeItemSchema = z\n .object({\n type: z.string(),\n data: z.string(),\n })\n .transform((shape) => {\n switch (shape.type) {\n case \"TRACK\": {\n const [width, layer, _, pointsStr, id, _n] = shape.data.split(\"~\")\n const points = parsePoints(pointsStr)\n return TrackSchema.parse({ type: \"TRACK\", width, layer, points, id })\n }\n case \"PAD\": {\n const [padShape, ...params] = shape.data.split(\"~\")\n const [\n centerX,\n centerY,\n width,\n height,\n layermask,\n net,\n number,\n holeRadius,\n ...rest\n ] = params.map((p) => (Number.isNaN(Number(p)) ? p : Number(p)))\n const center = { x: centerX, y: centerY }\n let points: number[][] | undefined\n\n if (padShape === \"RECT\" || padShape === \"POLYGON\") {\n points = parsePoints(rest[0] as any)\n }\n\n // Extract rotation for all pad types from position 11 (rest[1])\n const r = Number(rest[1])\n const rotation = Number.isNaN(r) ? undefined : r\n\n const padInputParams = {\n type: \"PAD\",\n shape: padShape,\n center,\n width,\n height,\n layermask,\n net,\n number,\n holeRadius,\n points,\n rotation,\n plated: rest.includes(\"Y\"),\n }\n const pad = PadSchema.parse(padInputParams)\n return pad\n }\n case \"ARC\": {\n const [width, layer, , arcData] = shape.data.split(\"~\")\n // A rx ry x-axis-rotation large-arc-flag sweep-flag x y\n // A rx ry x-axis-rotation large-arc-flag sweep-flag dx dy\n const match = arcData.match(\n /M\\s*([\\d.-]+)(?:\\s*,\\s*|\\s+)([\\d.-]+)\\s*A\\s*([\\d.-]+)(?:\\s*,\\s*|\\s+)([\\d.-]+)\\s*([\\d.-]+)\\s*([\\d.-]+)\\s*([\\d.-]+)\\s*([\\d.-]+)(?:\\s*,\\s*|\\s+)([\\d.-]+)/,\n )\n\n if (!match) {\n throw new Error(`Invalid arc data: ${arcData}`)\n }\n\n const [\n ,\n startX,\n startY,\n radiusX,\n radiusY,\n xAxisRotation,\n largeArcFlag,\n sweepFlag,\n endX,\n endY,\n ] = match\n const start: [number, number] = [Number(startX), Number(startY)]\n const end: [number, number] = [Number(endX), Number(endY)]\n return ArcSchema.parse({\n type: \"ARC\",\n width: Number(width),\n layer: Number(layer),\n start,\n end,\n radiusX: Number(radiusX),\n radiusY: Number(radiusY),\n largeArc: largeArcFlag === \"1\",\n // sweepFlag=1 means clockwise (CW), sweepFlag=0 means counter-clockwise (CCW)\n sweepDirection: sweepFlag === \"1\" ? \"CW\" : \"CCW\",\n })\n }\n case \"CIRCLE\": {\n const [centerX, centerY, radius, width, layer, id] =\n shape.data.split(\"~\")\n const center: [number, number] = [Number(centerX), Number(centerY)]\n return CircleSchema.parse({\n type: \"CIRCLE\",\n center,\n radius: Number(radius),\n width: Number(width),\n layer: Number(layer),\n id,\n })\n }\n case \"HOLE\": {\n const [centerX, centerY, radius, id] = shape.data.split(\"~\")\n const center: [number, number] = [Number(centerX), Number(centerY)]\n return HoleSchema.parse({\n type: \"HOLE\",\n center,\n radius: Number(radius),\n id,\n })\n }\n case \"VIA\": {\n const [x, y, outerDiameter, , holeDiameter, id] = shape.data.split(\"~\")\n const center: [number, number] = [Number(x), Number(y)]\n return ViaSchema.parse({\n type: \"VIA\",\n center,\n outerDiameter: Number(outerDiameter),\n holeDiameter: Number(holeDiameter),\n id,\n })\n }\n case \"SOLIDREGION\": {\n const [layermask, , pathData, fillStyle, id] = shape.data.split(\"~\")\n const points =\n pathData.match(/[ML] ?(-?[\\d.]+)[ ,](-?[\\d.]+)/g)?.map((point) => {\n const [, x, y] =\n point.match(/[ML]? ?(-?[\\d.]+)[ ,](-?[\\d.]+)/) || []\n return [Number(x), Number(y)]\n }) || []\n return SolidRegionSchema.parse({\n type: \"SOLIDREGION\",\n layermask: Number(layermask),\n points,\n fillStyle,\n id,\n })\n }\n case \"SVGNODE\": {\n const svgData = JSON.parse(shape.data)\n return SVGNodeSchema.parse({ type: \"SVGNODE\", svgData })\n }\n case \"RECT\": {\n const [x, y, width, height, lineWidth, id, rotation, layer, fillStyle] =\n shape.data.split(\"~\")\n const r = rotation ? Number(rotation) : undefined\n return RectSchema.parse({\n type: \"RECT\",\n x,\n y,\n width,\n height,\n lineWidth: Number(lineWidth),\n id,\n rotation: Number.isNaN(r as number) ? undefined : r,\n layer: layer ? Number(layer) : undefined,\n fillStyle: fillStyle || undefined,\n })\n }\n case \"TEXT\": {\n const [textAnchor, x, y, size, layer, id, rotation, , font, text] =\n shape.data.split(\"~\")\n const r = rotation ? Number(rotation) : undefined\n return TextSchema.parse({\n type: \"TEXT\",\n text,\n x,\n y,\n size_mm: Number(size) * 2.54, // empirically this seems to match, C5248081 is a good test case\n layer: layer ? Number(layer) : undefined,\n id,\n rotation: Number.isNaN(r as number) ? undefined : r,\n textAnchor: textAnchor as \"L\" | \"C\" | \"R\" | undefined,\n font: font || undefined,\n })\n }\n\n default:\n throw new Error(`Unknown shape type: ${shape.type}`)\n }\n })\n .pipe(PackageDetailShapeSchema)\n\nexport const ShapesArraySchema = z.array(ShapeItemSchema)\n","import { z } from \"zod\"\nimport { mil10ToMm } from \"lib/utils/easyeda-unit-to-mm\"\n\n/**\n I'll break down the elements in the `dataStr.head.shape` array and explain what they represent. This array contains instructions for drawing the schematic symbol of the component.\n1. `\"R~365~275~2~2~70~50~#880000~1~0~none~gge1~0~\"`\n This represents a rectangle:\n - Starting position: (365, 275)\n - Width: 70\n - Height: 50\n - Color: #880000 (dark red)\n - Line width: 1\n - Other parameters are for internal use\n2. `\"E~370~280~1.5~1.5~#880000~1~0~#880000~gge2~0\"`\n This draws an ellipse:\n - Center: (370, 280)\n - Radius X: 1.5\n - Radius Y: 1.5\n - Color: #880000 (dark red)\n - Line width: 1\n3-10. `\"P~show~0~1~355~285~180~gge5~0^^355~285^^M355,285h10~#000000^^1~368.7~289~0~GND~start~~~#000000^^1~364.5~284~0~1~end~~~#000000^^0~362~285^^0~M 365 288 L 368 285 L 365 282\"`\n These represent pins of the component. Each pin has:\n - Pin number\n - Position\n - Orientation\n - Label (e.g., GND, TRIG, OUT)\n - Color\n - Drawing instructions for the pin shape\n4. `\"A~M x1 y1 A radius radius 0 1 0 x2 y2\"`\n This represents an arc:\n - Start point: (x1, y1)\n - End point: (x2, y2)\n - Radius\n - Direction (CW or CCW)\n - Color\n - Line width\n - ID\nTo parse this data:\n1. Split the string by `~` to get individual parameters.\n2. For rectangles (R), use parameters 2-7 for position, size, and color.\n3. For ellipses (E), use parameters 2-5 for position and size, and 6 for color.\n4. For pins (P), split further by `^^` to get different sections:\n - First section: general pin properties\n - Second section: pin position\n - Third section: line drawing instruction\n - Fourth and Fifth sections: label position and text\n - Sixth section: additional drawing instruction for pin shape\n5. For arcs (A), split by `~M ` to get the path data.\n - Format: A~M x1 y1 A radius radius 0 1 0 x2 y2\n - Parse the start and end points, radius, direction, color, line width, and ID.\nThis data structure allows for a compact representation of the schematic symbol, which can be rendered by CAD software to display the component in circuit diagrams.\n */\n// Examples\n// \"R~365~275~2~2~70~50~#880000~1~0~none~gge1~0~\",\n// \"E~370~280~1.5~1.5~#880000~1~0~#880000~gge2~0\",\n// \"P~show~0~1~355~285~180~gge5~0^^355~285^^M355,285h10~#000000^^1~368.7~289~0~GND~start~~~#000000^^1~364.5~284~0~1~end~~~#000000^^0~362~285^^0~M 365 288 L 368 285 L 365 282\",\n// \"P~show~0~2~355~295~180~gge6~0^^355~295^^M355,295h10~#880000^^1~368.7~299~0~TRIG~start~~~#0000FF^^1~364.5~294~0~2~end~~~#0000FF^^0~362~295^^0~M 365 298 L 368 295 L 365 292\",\n// \"P~show~0~3~355~305~180~gge7~0^^355~305^^M355,305h10~#880000^^1~368.7~309~0~OUT~start~~~#0000FF^^1~364.5~304~0~3~end~~~#0000FF^^0~362~305^^0~M 365 308 L 368 305 L 365 302\",\n// \"P~show~0~4~355~315~180~gge8~0^^355~315^^M355,315h10~#880000^^1~368.7~319~0~RESET~start~~~#0000FF^^1~364.5~314~0~4~end~~~#0000FF^^0~362~315^^0~M 365 318 L 368 315 L 365 312\",\n// \"P~show~0~5~445~315~0~gge9~0^^445~315^^M445,315h-10~#880000^^1~431.3~319~0~CONT~end~~~#0000FF^^1~435.5~314~0~5~start~~~#0000FF^^0~438~315^^0~M 435 312 L 432 315 L 435 318\",\n// \"P~show~0~6~445~305~0~gge10~0^^445~305^^M445,305h-10~#880000^^1~431.3~309~0~THRES~end~~~#0000FF^^1~435.5~304~0~6~start~~~#0000FF^^0~438~305^^0~M 435 302 L 432 305 L 435 308\",\n// \"P~show~0~7~445~295~0~gge11~0^^445~295^^M445,295h-10~#880000^^1~431.3~299~0~DISCH~end~~~#0000FF^^1~435.5~294~0~7~start~~~#0000FF^^0~438~295^^0~M 435 292 L 432 295 L 435 298\",\n// \"P~show~0~8~445~285~0~gge12~0^^445~285^^M445,285h-10~#FF0000^^1~431.3~289~0~VCC~end~~~#FF0000^^1~435.5~284~0~8~start~~~#FF0000^^0~438~285^^0~M 435 282 L 432 285 L 435 288\",\n// \"A~M x1 y1 A radius radius 0 1 0 x2 y2\"\n\nconst PointSchema = z.object({\n x: z.number(),\n y: z.number(),\n})\n\nconst RectangleShapeOutputSchema = z.object({\n type: z.literal(\"RECTANGLE\"),\n position: PointSchema,\n width: z.number(),\n height: z.number(),\n color: z.string(),\n lineWidth: z.number(),\n id: z.string(),\n})\n\nconst parseRectangle = (\n str: string,\n): z.infer<typeof RectangleShapeOutputSchema> => {\n const [, x, y, , , width, height, color, lineWidth, , , id] = str.split(\"~\")\n return {\n type: \"RECTANGLE\",\n position: { x: Number(x), y: Number(y) },\n width: Number(width),\n height: Number(height),\n color,\n lineWidth: Number(lineWidth),\n id,\n }\n}\n\nexport const RectangleShapeSchema = z\n .string()\n .startsWith(\"R~\")\n .transform(parseRectangle)\n .pipe(RectangleShapeOutputSchema)\n\nconst EllipseShapeOutputSchema = z.object({\n type: z.literal(\"ELLIPSE\"),\n center: PointSchema,\n radiusX: z.number(),\n radiusY: z.number(),\n color: z.string(),\n lineWidth: z.number(),\n id: z.string(),\n})\n\nconst parseEllipse = (\n str: string,\n): z.infer<typeof EllipseShapeOutputSchema> => {\n const [, x, y, radiusX, radiusY, color, lineWidth, , , id] = str.split(\"~\")\n return {\n type: \"ELLIPSE\",\n center: { x: Number(x), y: Number(y) },\n radiusX: Number(radiusX),\n radiusY: Number(radiusY),\n color,\n lineWidth: Number(lineWidth),\n id,\n }\n}\n\nexport const EllipseShapeSchema = z\n .string()\n .startsWith(\"E~\")\n .transform(parseEllipse)\n .pipe(EllipseShapeOutputSchema)\n\nconst ArcShapeOutputSchema = z.object({\n type: z.literal(\"ARC\"),\n start: PointSchema,\n end: PointSchema,\n radius: z.number(),\n sweepFlag: z.boolean(),\n color: z.string(),\n lineWidth: z.number(),\n id: z.string(),\n})\n\nconst parseArc = (str: string): z.infer<typeof ArcShapeOutputSchema> => {\n // Format: A~M x1 y1 A radius radius 0 1 0 x2 y2~#880000~1~0~none~gge49~0\n const [, pathData, color, lineWidth, , , id] = str.split(\"~\")\n const parts = pathData.split(\" \")\n\n // Handle potential NaN values by defaulting to 0\n const x1 = Number(parts[1]) || 0\n const y1 = Number(parts[2]) || 0\n const radius = Number(parts[4]) || 0\n const sweepFlag = parts[7] === \"1\" // The sweep flag is the 8th parameter\n const x2 = Number(parts[8]) || 0\n const y2 = Number(parts[9]) || 0\n\n // Handle empty or invalid line width\n const parsedLineWidth = Number(lineWidth)\n const finalLineWidth = Number.isNaN(parsedLineWidth) ? 1 : parsedLineWidth\n\n return {\n type: \"ARC\",\n start: { x: x1, y: y1 },\n end: { x: x2, y: y2 },\n radius,\n sweepFlag,\n color: color || \"#880000\", // Default color\n lineWidth: finalLineWidth,\n id: id || \"gge1\",\n }\n}\n\nexport const ArcShapeSchema = z\n .string()\n .startsWith(\"A~\")\n .transform(parseArc)\n .pipe(ArcShapeOutputSchema)\n\nconst PinShapeOutputSchema = z.object({\n type: z.literal(\"PIN\"),\n visibility: z.enum([\"show\", \"hide\", \"none\"]),\n pinNumber: z.union([z.string(), z.number()]),\n x: z.number(),\n y: z.number(),\n rotation: z.number(),\n id: z.string(),\n label: z.string(),\n labelColor: z.string(),\n path: z.string(),\n arrow: z.string(),\n})\n\nconst parsePin = (pinString: string): z.infer<typeof PinShapeOutputSchema> => {\n const parts = pinString.split(\"~\")\n const [, visibility, , pinNumber, x, y, rotation, id] = parts\n\n const nameMatch = pinString.match(/~([\\w+#-]+)~(start|end)~/)\n let label = nameMatch ? nameMatch[1] : \"\"\n if (label.endsWith(\"+\")) label = label.slice(0, -1) + \"_POS\"\n if (label.endsWith(\"-\")) label = label.slice(0, -1) + \"_NEG\"\n if (label.endsWith(\"#\")) label = label.slice(0, -1)\n if (/^\\+\\d+(?:\\.\\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`\n\n const colorMatch = pinString.match(/#[0-9A-F]{6}/)\n const labelColor = colorMatch ? colorMatch[0] : \"\"\n\n const pathMatch = pinString.match(/\\^\\^([^~]+)/)\n const path = pathMatch ? pathMatch[1] : \"\"\n\n const arrowMatch = pinString.match(/\\^\\^0~(.+)$/)\n const arrow = arrowMatch ? arrowMatch[1] : \"\"\n\n const r = Number.parseFloat(rotation)\n return {\n type: \"PIN\",\n visibility: visibility as \"show\" | \"hide\" | \"none\",\n id,\n pinNumber: Number.isNaN(Number(pinNumber)) ? pinNumber : Number(pinNumber),\n x: Number.parseFloat(x),\n y: Number.parseFloat(y),\n rotation: Number.isNaN(r) ? 0 : r,\n label,\n labelColor,\n path,\n arrow,\n }\n}\n\nexport const PinShapeSchema = z\n .string()\n .startsWith(\"P~\")\n .transform(parsePin)\n .pipe(PinShapeOutputSchema)\n\nconst PolylineShapeOutputSchema = z.object({\n type: z.literal(\"POLYLINE\"),\n points: z.array(PointSchema),\n color: z.string(),\n lineWidth: z.number(),\n id: z.string(),\n})\n\nconst parsePoints = (pointsStr: string): Array<{ x: number; y: number }> => {\n return pointsStr\n .split(\" \")\n .reduce<Array<{ x: number; y: number }>>((acc, value, index) => {\n if (index % 2 === 0) {\n acc.push({ x: Number(value), y: 0 })\n } else {\n acc[acc.length - 1].y = Number(value)\n }\n return acc\n }, [])\n}\n\nconst parsePolyline = (\n str: string,\n): z.infer<typeof PolylineShapeOutputSchema> => {\n const [, ...rest] = str.split(\"~\")\n const [pointsStr, color, lineWidth, , , id] = rest\n\n return {\n type: \"POLYLINE\",\n points: parsePoints(pointsStr),\n color,\n lineWidth: Number(lineWidth),\n id,\n }\n}\n\nexport const PolylineShapeSchema = z\n .string()\n .startsWith(\"PL~\")\n .transform(parsePolyline)\n .pipe(PolylineShapeOutputSchema)\n\nconst PolygonShapeOutputSchema = z.object({\n type: z.literal(\"POLYGON\"),\n points: z.array(PointSchema),\n fillColor: z.string(),\n lineWidth: z.number(),\n lineColor: z.string(),\n id: z.string(),\n})\n\nconst parsePolygon = (\n str: string,\n): z.infer<typeof PolygonShapeOutputSchema> => {\n const [, ...rest] = str.split(\"~\")\n const [pointsStr, fillColor, lineWidth, lineColor, , id] = rest\n\n return {\n type: \"POLYGON\",\n points: parsePoints(pointsStr),\n fillColor,\n lineWidth: Number(lineWidth),\n lineColor,\n id,\n }\n}\n\nexport const PolygonShapeSchema = z\n .string()\n .startsWith(\"PG~\")\n .transform(parsePolygon)\n .pipe(PolygonShapeOutputSchema)\n\nconst PathShapeOutputSchema = z.object({\n type: z.literal(\"PATH\"),\n pathData: z.string(),\n fillColor: z.string(),\n strokeWidth: z.number(),\n strokeColor: z.string(),\n id: z.string(),\n})\n\nconst parsePath = (str: string): z.infer<typeof PathShapeOutputSchema> => {\n const [, pathData, fillColor, strokeWidth, strokeColor, , id] = str.split(\"~\")\n return {\n type: \"PATH\",\n pathData,\n fillColor,\n strokeWidth: mil10ToMm(Number(strokeWidth)),\n strokeColor,\n id,\n }\n}\n\nexport const PathShapeSchema = z\n .string()\n .startsWith(\"PT~\")\n .transform(parsePath)\n .pipe(PathShapeOutputSchema)\n\nconst TextShapeOutputSchema = z.object({\n type: z.literal(\"TEXT\"),\n alignment: z.enum([\"L\", \"C\", \"R\"]),\n x: z.number(),\n y: z.number(),\n rotation: z.number(),\n fontColor: z.string(),\n backgroundColor: z.string().optional(),\n fontSize: z.string(),\n fontWeight: z.string().optional().default(\"normal\"),\n fontStyle: z.enum([\"normal\", \"italic\"]).optional().default(\"normal\"),\n fontDecoration: z.string().optional().default(\"\"),\n content: z.string(),\n textType: z.string(),\n visibility: z.enum([\"0\", \"1\"]),\n mirror: z.string(),\n id: z.string(),\n})\n\nconst parseText = (str: string): z.infer<typeof TextShapeOutputSchema> => {\n const [\n ,\n alignment,\n x,\n y,\n rotation,\n fontColor,\n backgroundColor,\n fontSize,\n fontWeight,\n fontStyle,\n fontDecoration,\n content,\n textType,\n visibility,\n mirror,\n id,\n ] = str.split(\"~\")\n return {\n type: \"TEXT\",\n alignment: alignment as \"L\" | \"C\" | \"R\",\n x: Number(x),\n y: Number(y),\n rotation: Number(rotation),\n fontColor,\n backgroundColor: backgroundColor || undefined,\n fontSize,\n fontWeight: fontWeight || \"normal\",\n fontStyle: (fontStyle || \"normal\") as \"normal\" | \"italic\",\n fontDecoration: fontDecoration || \"\",\n content,\n textType,\n visibility: visibility as \"0\" | \"1\",\n mirror,\n id,\n }\n}\n\nexport const TextShapeSchema = z\n .string()\n .startsWith(\"T~\")\n .transform(parseText)\n .pipe(TextShapeOutputSchema)\n\nexport const SingleLetterShapeSchema = z\n .string()\n .transform((x) => {\n // We do some discrimination here for better errors\n if (x.startsWith(\"R~\")) return RectangleShapeSchema.parse(x)\n if (x.startsWith(\"E~\")) return EllipseShapeSchema.parse(x)\n if (x.startsWith(\"P~\")) return PinShapeSchema.parse(x)\n if (x.startsWith(\"PL~\")) return PolylineShapeSchema.parse(x)\n if (x.startsWith(\"PG~\")) return PolygonShapeSchema.parse(x)\n if (x.startsWith(\"PT~\")) return PathShapeSchema.parse(x)\n if (x.startsWith(\"T~\")) return TextShapeSchema.parse(x)\n if (x.startsWith(\"A~\")) return ArcShapeSchema.parse(x)\n throw new Error(`Invalid shape type: ${x}`)\n })\n .pipe(\n z.union([\n RectangleShapeOutputSchema,\n EllipseShapeOutputSchema,\n PinShapeOutputSchema,\n PolylineShapeOutputSchema,\n PolygonShapeOutputSchema,\n PathShapeOutputSchema,\n TextShapeOutputSchema,\n ArcShapeOutputSchema,\n ]),\n )\n\nexport type SingleLetterShape = z.infer<typeof SingleLetterShapeSchema>\n","export function normalizeManufacturerPartNumber(partNumber: string): string {\n // Step 1: Replace dashes and invalid symbols with underscores\n let normalized = partNumber\n .replace(/[-]/g, \"_\")\n .replace(/[^a-zA-Z0-9_$]/g, \"_\")\n\n // Step 2: If the string starts with a number, prepend 'A_'\n if (/^\\d/.test(normalized)) {\n normalized = \"A_\" + normalized\n }\n\n return normalized\n}\n","import type { BetterEasyEdaJson } from \"lib/schemas/easy-eda-json-schema\"\nimport { mil10ToMm } from \"lib/utils/easyeda-unit-to-mm\"\n\ntype XYBounds = {\n min: { x: number; y: number }\n max: { x: number; y: number }\n}\n\ntype RotationDeg = 0 | 90 | 180 | 270\n\nconst milToMm = (mil: number) => mil * 0.0254\n\nconst getBoundsCenter = (bounds: XYBounds) => ({\n x: (bounds.min.x + bounds.max.x) / 2,\n y: (bounds.min.y + bounds.max.y) / 2,\n})\n\nconst getCadSvgNode = (easyEdaJson: BetterEasyEdaJson) => {\n const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(\n (shape) => shape.type === \"SVGNODE\" && shape.svgData.attrs?.uuid,\n )\n\n return svgNode?.type === \"SVGNODE\" ? svgNode : null\n}\n\nconst parseMil10Value = (value: string | number) =>\n Number(String(value).replace(\"mil\", \"\")) / 10\n\nconst isZeroishModelCenter = (value: number) => Math.abs(value) < 1e-6\n\nconst isZeroishFootprintDelta = (value: number) => Math.abs(value) < 1e-3\n\nconst getPadCenter = (easyEdaJson: BetterEasyEdaJson) => {\n const pads = easyEdaJson.packageDetail.dataStr.shape.filter(\n (shape) => shape.type === \"PAD\",\n )\n if (pads.length === 0) return null\n\n const xs = pads.map((pad) => parseMil10Value(pad.center.x))\n const ys = pads.map((pad) => parseMil10Value(pad.center.y))\n\n return {\n x: (Math.min(...xs) + Math.max(...xs)) / 2,\n y: (Math.min(...ys) + Math.max(...ys)) / 2,\n }\n}\n\nconst getRotatedOffsetMm = ({\n bounds,\n rawOffsetMil,\n rotationDeg,\n}: {\n bounds: XYBounds\n rawOffsetMil: { x: number; y: number }\n rotationDeg: RotationDeg\n}) => {\n const center = getBoundsCenter(bounds)\n const offsetX = milToMm(rawOffsetMil.x)\n const offsetY = milToMm(rawOffsetMil.y)\n\n switch (rotationDeg) {\n case 0:\n return { x: center.x + offsetX, y: center.y + offsetY }\n case 90:\n return { x: center.x + offsetY, y: center.y + offsetX }\n case 180:\n return { x: center.x - offsetX, y: center.y - offsetY }\n case 270:\n return { x: center.x - offsetY, y: center.y - offsetX }\n }\n}\n\nexport const getCadModelOffsetMm = (easyEdaJson: BetterEasyEdaJson) => {\n const svgNode = getCadSvgNode(easyEdaJson)\n const bounds = easyEdaJson._objMetadata?.bounds\n if (!svgNode || !bounds) return null\n\n const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? \"0,0\")\n .split(\",\")\n .map((value) => Number(value.trim()))\n if (!Number.isFinite(originX) || !Number.isFinite(originY)) return null\n\n const [, , rotationZRaw] = String(\n svgNode.svgData.attrs?.c_rotation ?? \"0,0,0\",\n )\n .split(\",\")\n .map((value) => Number(value.trim()))\n const rotationDeg = (((rotationZRaw % 360) + 360) % 360) as RotationDeg\n if (![0, 90, 180, 270].includes(rotationDeg)) return null\n\n const modelCenter = getBoundsCenter(bounds)\n const footprintCenter = easyEdaJson.packageDetail.dataStr.head\n const padCenter = getPadCenter(easyEdaJson)\n const padCenterDelta = padCenter\n ? {\n x: padCenter.x - footprintCenter.x,\n y: padCenter.y - footprintCenter.y,\n }\n : null\n const rawOffsetMil = {\n x: (originX - footprintCenter.x) * 10,\n y: (originY - footprintCenter.y) * 10,\n }\n\n if (\n padCenter &&\n padCenterDelta &&\n isZeroishModelCenter(modelCenter.x) &&\n isZeroishModelCenter(modelCenter.y) &&\n isZeroishFootprintDelta(padCenterDelta.x) &&\n isZeroishFootprintDelta(padCenterDelta.y)\n ) {\n return { x: 0, y: 0 }\n }\n\n return getRotatedOffsetMm({\n bounds,\n rawOffsetMil,\n rotationDeg,\n })\n}\n\nexport const getCadSvgNodeZOffsetMm = (easyEdaJson: BetterEasyEdaJson) => {\n const svgNode = getCadSvgNode(easyEdaJson)\n if (!svgNode) return null\n\n const svgNodeZ = Number(svgNode.svgData.attrs?.z ?? 0)\n if (!Number.isFinite(svgNodeZ)) return null\n\n return mil10ToMm(svgNodeZ)\n}\n\nexport const getCadSvgNodeModelUuid = (easyEdaJson: BetterEasyEdaJson) =>\n getCadSvgNode(easyEdaJson)?.svgData.attrs?.uuid ?? null\n","import type { BetterEasyEdaJson } from \"lib/schemas/easy-eda-json-schema\"\nimport {\n getCadModelOffsetMm,\n getCadSvgNodeModelUuid,\n getCadSvgNodeZOffsetMm,\n} from \"./get-easyeda-cad-placement-helpers\"\nimport { getModelObjCdnUrl, getModelStepCdnUrl } from \"./get-model-cdn-url\"\n\ntype ModelBounds = {\n min: { x: number; y: number; z: number }\n max: { x: number; y: number; z: number }\n}\n\nexport type EasyEdaCadModelPlacement = {\n modelObjUrl: string\n positionXMm: number\n positionYMm: number\n modelStepUrl?: string\n positionZMm: number\n bounds: ModelBounds\n}\n\nconst placementCache = new Map<\n string,\n Promise<EasyEdaCadModelPlacement | null>\n>()\n\nconst parseObjBounds = (objText: string): ModelBounds | null => {\n let minX = Number.POSITIVE_INFINITY\n let minY = Number.POSITIVE_INFINITY\n let minZ = Number.POSITIVE_INFINITY\n let maxX = Number.NEGATIVE_INFINITY\n let maxY = Number.NEGATIVE_INFINITY\n let maxZ = Number.NEGATIVE_INFINITY\n let vertexCount = 0\n\n for (const line of objText.split(/\\r?\\n/)) {\n const trimmed = line.trim()\n if (!trimmed.startsWith(\"v \")) continue\n\n const [, xStr, yStr, zStr] = trimmed.split(/\\s+/, 4)\n const x = Number(xStr)\n const y = Number(yStr)\n const z = Number(zStr)\n\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) {\n continue\n }\n\n vertexCount += 1\n minX = Math.min(minX, x)\n minY = Math.min(minY, y)\n minZ = Math.min(minZ, z)\n maxX = Math.max(maxX, x)\n maxY = Math.max(maxY, y)\n maxZ = Math.max(maxZ, z)\n }\n\n if (vertexCount === 0) return null\n\n return {\n min: { x: minX, y: minY, z: minZ },\n max: { x: maxX, y: maxY, z: maxZ },\n }\n}\n\nconst getPositionZMmFromBounds = (\n bounds: ModelBounds,\n svgNodeZOffsetMm: number,\n) => {\n const minZ = Math.abs(bounds.min.z) < 1e-6 ? 0 : bounds.min.z\n return minZ - svgNodeZOffsetMm\n}\n\nexport const getEasyEdaCadModelPlacement = async (\n easyEdaJson: BetterEasyEdaJson,\n { fetch = globalThis.fetch }: { fetch?: typeof globalThis.fetch } = {},\n): Promise<EasyEdaCadModelPlacement | null> => {\n const modelUuid = getCadSvgNodeModelUuid(easyEdaJson)\n const partNumber = easyEdaJson.lcsc.number\n const derivedOffsetMm = getCadModelOffsetMm(easyEdaJson)\n const svgNodeZOffsetMm = getCadSvgNodeZOffsetMm(easyEdaJson)\n\n if (\n !modelUuid ||\n !partNumber ||\n svgNodeZOffsetMm == null ||\n !derivedOffsetMm ||\n !fetch\n ) {\n return null\n }\n\n const modelObjUrl = getModelObjCdnUrl({\n easyedaModelUuid: modelUuid,\n easyedaPartNumber: partNumber,\n })\n const modelStepUrl = getModelStepCdnUrl({\n easyedaModelUuid: modelUuid,\n easyedaPartNumber: partNumber,\n })\n\n const metadataBounds = easyEdaJson._objMetadata?.bounds\n if (metadataBounds) {\n return {\n modelObjUrl,\n positionXMm: derivedOffsetMm.x,\n positionYMm: derivedOffsetMm.y,\n modelStepUrl,\n bounds: metadataBounds,\n positionZMm: getPositionZMmFromBounds(metadataBounds, svgNodeZOffsetMm),\n }\n }\n\n const cacheKey = `${modelObjUrl}::${svgNodeZOffsetMm}`\n const cachedPlacement = placementCache.get(cacheKey)\n if (cachedPlacement) return cachedPlacement\n\n const placementPromise = (async () => {\n try {\n const response = await fetch(modelObjUrl)\n if (!response.ok) return null\n\n const objText = await response.text()\n const bounds = parseObjBounds(objText)\n if (!bounds) return null\n\n return {\n modelObjUrl,\n positionXMm: derivedOffsetMm.x,\n positionYMm: derivedOffsetMm.y,\n modelStepUrl,\n bounds,\n // Align the EasyEDA SVG-node Z against the model's minimum Z.\n positionZMm: getPositionZMmFromBounds(bounds, svgNodeZOffsetMm),\n }\n } catch (error) {\n console.error(\n `Error resolving EasyEDA CAD placement for ${partNumber}:`,\n error,\n )\n return null\n }\n })()\n\n placementCache.set(cacheKey, placementPromise)\n return placementPromise\n}\n","import { mmStr } from \"@tscircuit/mm\"\nimport type { AnyCircuitElement } from \"circuit-json\"\nimport { su } from \"@tscircuit/circuit-json-util\"\n\nexport const generateFootprintTsx = (\n circuitJson: AnyCircuitElement[],\n): string => {\n const holes = su(circuitJson).pcb_hole.list()\n const platedHoles = su(circuitJson).pcb_plated_hole.list()\n const smtPads = su(circuitJson).pcb_smtpad.list()\n const vias = su(circuitJson).pcb_via.list()\n const silkscreenPaths = su(circuitJson).pcb_silkscreen_path.list()\n const silkscreenTexts = su(circuitJson).pcb_silkscreen_text.list()\n const courtyardOutlines = su(circuitJson).pcb_courtyard_outline.list()\n\n const elementStrings: string[] = []\n\n for (const hole of holes) {\n if (hole.hole_shape === \"circle\") {\n elementStrings.push(\n `<hole pcbX=\"${mmStr(hole.x)}\" pcbY=\"${mmStr(hole.y)}\" diameter=\"${mmStr(hole.hole_diameter)}\" />`,\n )\n } else if (hole.hole_shape === \"oval\") {\n console.warn(\"Unhandled oval hole in conversion (needs implementation)\")\n }\n }\n\n for (const platedHole of platedHoles) {\n if (platedHole.shape === \"pill_hole_with_rect_pad\") {\n elementStrings.push(\n `<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX=\"${mmStr(platedHole.x)}\" pcbY=\"${mmStr(platedHole.y)}\" holeWidth=\"${mmStr(platedHole.hole_width)}\" holeHeight=\"${mmStr(platedHole.hole_height)}\" outerWidth=\"${mmStr(platedHole.rect_pad_width)}\" outerHeight=\"${mmStr(platedHole.rect_pad_height)}\" shape=\"pill\" />`,\n )\n } else if (platedHole.shape === \"circle\") {\n elementStrings.push(\n `<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX=\"${mmStr(platedHole.x)}\" pcbY=\"${mmStr(platedHole.y)}\" outerDiameter=\"${mmStr(platedHole.outer_diameter)}\" holeDiameter=\"${mmStr(platedHole.hole_diameter)}\" shape=\"circle\" />`,\n )\n } else if (platedHole.shape === \"rotated_pill_hole_with_rect_pad\") {\n const rotation = platedHole.hole_ccw_rotation || 0\n\n elementStrings.push(\n `<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX=\"${mmStr(platedHole.x)}\" pcbY=\"${mmStr(platedHole.y)}\" holeWidth=\"${mmStr(platedHole.hole_width)}\" holeHeight=\"${mmStr(platedHole.hole_height)}\" outerWidth=\"${mmStr(platedHole.rect_pad_width)}\" outerHeight=\"${mmStr(platedHole.rect_pad_height)}\" rectPad={true} pcbRotation=\"${rotation}deg\" shape=\"pill\" />`,\n )\n }\n }\n\n for (const smtPad of smtPads) {\n if (smtPad.shape === \"circle\") {\n elementStrings.push(\n `<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX=\"${mmStr(smtPad.x)}\" pcbY=\"${mmStr(smtPad.y)}\" radius=\"${mmStr(smtPad.radius)}\" shape=\"circle\" />`,\n )\n } else if (smtPad.shape === \"rect\") {\n elementStrings.push(\n `<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX=\"${mmStr(smtPad.x)}\" pcbY=\"${mmStr(smtPad.y)}\" width=\"${mmStr(smtPad.width)}\" height=\"${mmStr(smtPad.height)}\" shape=\"rect\" />`,\n )\n } else if (smtPad.shape === \"polygon\") {\n const pointsStr = smtPad.points\n .map((p) => `{x: \"${mmStr(p.x)}\", y: \"${mmStr(p.y)}\"}`)\n .join(\", \")\n elementStrings.push(\n `<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} points={[${pointsStr}]} shape=\"polygon\" />`,\n )\n }\n }\n\n for (const via of vias) {\n elementStrings.push(\n `<via pcbX=\"${mmStr(via.x)}\" pcbY=\"${mmStr(via.y)}\" outerDiameter=\"${mmStr(via.outer_diameter)}\" holeDiameter=\"${mmStr(via.hole_diameter)}\" layers={${JSON.stringify(via.layers)}} />`,\n )\n }\n\n for (const silkscreenPath of silkscreenPaths) {\n elementStrings.push(\n `<silkscreenpath route={${JSON.stringify(silkscreenPath.route)}} />`,\n )\n }\n\n for (const silkscreenText of silkscreenTexts) {\n // Inject the dynamic {props.name} for the reference designator text. \"{NAME}\" was\n // mapped during the Circuit JSON conversion step to identify the designator text.\n const isRefDes = silkscreenText.text === \"{NAME}\"\n const textValue = isRefDes\n ? \"{props.name}\"\n : JSON.stringify(silkscreenText.text)\n\n elementStrings.push(\n `<silkscreentext text=${textValue} pcbX=\"${mmStr(silkscreenText.anchor_position.x)}\" pcbY=\"${mmStr(silkscreenText.anchor_position.y)}\" anchorAlignment=\"${silkscreenText.anchor_alignment}\" ${silkscreenText.font_size ? `fontSize=\"${mmStr(silkscreenText.font_size)}\"` : \"\"} />`,\n )\n }\n\n for (const courtyardOutline of courtyardOutlines) {\n elementStrings.push(\n `<courtyardoutline outline={${JSON.stringify(courtyardOutline.outline)}} />`,\n )\n }\n\n return `\n <footprint>\n ${elementStrings.join(\"\\n\")}\n </footprint>\n `.trim()\n}\n","import type { ChipProps } from \"@tscircuit/props\"\nimport type { AnyCircuitElement } from \"circuit-json\"\nimport { generateFootprintTsx } from \"../generate-footprint-tsx\"\n\ninterface Params {\n pinLabels: ChipProps[\"pinLabels\"]\n componentName: string\n objUrl?: string\n stepUrl?: string\n circuitJson: AnyCircuitElement[]\n supplierPartNumbers: ChipProps[\"supplierPartNumbers\"]\n manufacturerPartNumber: string\n}\n\nexport const generateTypescriptComponent = ({\n pinLabels,\n componentName,\n objUrl,\n stepUrl,\n circuitJson,\n supplierPartNumbers,\n manufacturerPartNumber,\n}: Params) => {\n // Ensure pinLabels is defined\n const safePinLabels = pinLabels ?? {}\n const cadComponent = circuitJson.find((item) => item.type === \"cad_component\")\n const footprintTsx = generateFootprintTsx(circuitJson)\n\n // Simplify pin labels to include only the second element\n const simplifiedPinLabels = Object.fromEntries(\n Object.entries(safePinLabels).map(([pin, labels]) => {\n // Ensure labels is an array and has a second element\n if (Array.isArray(labels) && labels.length > 1) {\n return [pin, [labels[1]]]\n }\n return [pin, labels] // Fallback to original if not an array or missing second element\n }),\n )\n\n const pinLabelsString = Object.entries(simplifiedPinLabels)\n .map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`)\n .join(\",\\n\")\n\n const cadModelLines = [\n objUrl ? `objUrl: \"${objUrl}\",` : \"\",\n stepUrl ? `stepUrl: \"${stepUrl}\",` : \"\",\n `pcbRotationOffset: ${cadComponent?.rotation?.z ?? 0},`,\n `modelOriginPosition: { x: ${cadComponent?.model_origin_position?.x ?? 0}, y: ${cadComponent?.model_origin_position?.y ?? 0}, z: ${cadComponent?.model_origin_position?.z ?? 0} },`,\n ]\n .filter(Boolean)\n .map((line) => ` ${line}`)\n .join(\"\\n\")\n\n return `\nimport type { ChipProps } from \"@tscircuit/props\"\n\nconst pinLabels = {\n${pinLabelsString}\n} as const\n\nexport const ${componentName} = (props: ChipProps<typeof pinLabels>) => {\n return (\n <chip\n pinLabels={pinLabels}\n supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, \" \")}}\n manufacturerPartNumber=\"${manufacturerPartNumber}\"\n footprint={${footprintTsx}}\n ${\n objUrl || stepUrl\n ? `cadModel={{\n${cadModelLines}\n }}`\n : \"\"\n }\n {...props}\n />\n )\n}\n`.trim()\n}\n","import { su } from \"@tscircuit/circuit-json-util\"\nimport { convertEasyEdaJsonToCircuitJson } from \"lib/convert-easyeda-json-to-tscircuit-soup-json\"\nimport {\n type BetterEasyEdaJson,\n EasyEdaJsonSchema,\n} from \"lib/schemas/easy-eda-json-schema\"\nimport { normalizeManufacturerPartNumber } from \"lib/utils/normalize-manufacturer-part-number\"\nimport { getEasyEdaCadModelPlacement } from \"../get-easyeda-cad-model-placement\"\nimport { generateTypescriptComponent } from \"./generate-typescript-component\"\n\nexport const convertRawEasyToTsx = async ({ rawEasy }: { rawEasy: any }) => {\n const betterEasy = EasyEdaJsonSchema.parse(rawEasy)\n const result = await convertBetterEasyToTsx({\n betterEasy,\n })\n return result\n}\n\nexport const convertBetterEasyToTsx = async ({\n betterEasy,\n}: {\n betterEasy: BetterEasyEdaJson\n}): Promise<string> => {\n const cadPlacement = await getEasyEdaCadModelPlacement(betterEasy)\n const circuitJson = convertEasyEdaJsonToCircuitJson(betterEasy, {\n useModelCdn: true,\n shouldRecenter: true,\n cadPositionXMm: cadPlacement?.positionXMm,\n cadPositionYMm: cadPlacement?.positionYMm,\n cadPositionZMm: cadPlacement?.positionZMm,\n showDesignator: true,\n })\n const [cadComponent] = su(circuitJson).cad_component.list()\n if (cadComponent) {\n cadComponent.position.x = 0\n cadComponent.position.y = 0\n }\n const rawPn = betterEasy.dataStr.head.c_para[\"Manufacturer Part\"]\n const pn = rawPn ? normalizeManufacturerPartNumber(rawPn) : \"unknown\"\n const sourcePorts = su(circuitJson).source_port.list()\n\n const pinLabels: Record<string, string[]> = {}\n const sortedPorts = sourcePorts.sort((a, b) => {\n const aNum = Number.parseInt(a.name.replace(\"pin\", \"\"))\n const bNum = Number.parseInt(b.name.replace(\"pin\", \"\"))\n return aNum - bNum\n })\n for (const sourcePort of sortedPorts) {\n pinLabels[sourcePort.name] = [\n sourcePort.name,\n ...(sourcePort.port_hints ?? []),\n ]\n }\n\n let modelObjUrl: string | undefined\n let modelStepUrl: string | undefined\n if (cadPlacement?.modelObjUrl) {\n modelObjUrl = cadPlacement.modelObjUrl\n modelStepUrl = cadPlacement.modelStepUrl\n } else if (cadComponent?.model_obj_url) {\n const isValidUrl = await checkModelObjUrlValidity(\n cadComponent.model_obj_url,\n )\n if (isValidUrl) {\n modelObjUrl = cadComponent.model_obj_url\n modelStepUrl = cadComponent.model_step_url\n }\n }\n\n const supplierPartNumbers: Record<string, string[]> = {\n jlcpcb: [betterEasy.lcsc.number],\n }\n\n return generateTypescriptComponent({\n componentName: pn,\n manufacturerPartNumber: pn,\n pinLabels,\n\n objUrl: modelObjUrl,\n stepUrl: modelStepUrl,\n circuitJson,\n supplierPartNumbers,\n })\n}\n\nconst checkModelObjUrlValidity = async (url: string): Promise<boolean> => {\n try {\n const response = await fetch(url, { method: \"HEAD\" })\n return response.status === 200\n } catch (error) {\n console.error(`Error checking model object URL ${url}:`, error)\n return false\n }\n}\n","import { fetchEasyEDAComponent } from \"lib/websafe/fetch-easyeda-json\"\nimport { convertEasyEdaJsonToCircuitJson } from \"lib/convert-easyeda-json-to-tscircuit-soup-json\"\nimport fs from \"fs/promises\"\nimport { EasyEdaJsonSchema } from \"lib/schemas/easy-eda-json-schema\"\nimport { convertRawEasyToTsx } from \"lib/websafe/convert-to-typescript-component\"\nimport * as path from \"path\"\nimport { normalizeManufacturerPartNumber } from \"lib/utils/normalize-manufacturer-part-number\"\n\nexport const convertEasyEdaJsonToVariousFormats = async ({\n jlcpcbPartNumberOrFilepath,\n outputFilename,\n outputFormat,\n}: {\n jlcpcbPartNumberOrFilepath: string\n outputFilename: string\n outputFormat: string\n}) => {\n let rawEasyEdaJson\n if (\n jlcpcbPartNumberOrFilepath.includes(\".\") ||\n jlcpcbPartNumberOrFilepath.includes(\"/\")\n ) {\n rawEasyEdaJson = JSON.parse(\n await fs.readFile(jlcpcbPartNumberOrFilepath, \"utf-8\"),\n )\n } else {\n rawEasyEdaJson = await fetchEasyEDAComponent(jlcpcbPartNumberOrFilepath)\n }\n\n const tsxExtension = \"tsx\"\n if (outputFormat === \"ts\") outputFormat = tsxExtension\n\n if (!outputFilename && outputFormat) {\n let filename = path.basename(jlcpcbPartNumberOrFilepath).split(\".\")[0]\n\n if (outputFormat === tsxExtension) {\n const {\n dataStr: {\n head: {\n c_para: { \"Manufacturer Part\": manufacturerPartNumber },\n },\n },\n } = rawEasyEdaJson\n\n filename = normalizeManufacturerPartNumber(manufacturerPartNumber)\n }\n\n outputFilename = `${filename}.${outputFormat}`\n }\n\n if (!outputFilename) {\n console.log(\"specify --output file (-o) or --output-format\")\n process.exit(1)\n }\n\n if (outputFilename.endsWith(\".raweasy.json\")) {\n await fs.writeFile(outputFilename, JSON.stringify(rawEasyEdaJson, null, 2))\n console.log(`Saved raw EasyEDA JSON: ${outputFilename}`)\n return\n }\n\n try {\n const betterEasy = EasyEdaJsonSchema.parse(rawEasyEdaJson)\n const tscircuitSoup = convertEasyEdaJsonToCircuitJson(betterEasy)\n\n if (\n outputFilename.endsWith(\".soup.json\") ||\n outputFilename.endsWith(\".circuit.json\")\n ) {\n await fs.writeFile(outputFilename, JSON.stringify(tscircuitSoup, null, 2))\n console.log(\n `[${jlcpcbPartNumberOrFilepath}] Converted to circuit json: ${outputFilename}`,\n )\n } else if (outputFilename.endsWith(\".kicad_mod\")) {\n // TODO: Implement conversion to KiCad footprint\n console.log(\"Conversion to KiCad footprint not yet implemented\")\n } else if (outputFilename.endsWith(\".bettereasy.json\")) {\n await fs.writeFile(outputFilename, JSON.stringify(betterEasy, null, 2))\n console.log(\n `[${jlcpcbPartNumberOrFilepath}] Saved better EasyEDA JSON: ${outputFilename}`,\n )\n } else if (\n outputFilename.endsWith(\".tsx\") ||\n outputFilename.endsWith(\".ts\")\n ) {\n const tsComp = await convertRawEasyToTsx(rawEasyEdaJson)\n await fs.writeFile(outputFilename, tsComp)\n console.log(\n `[${jlcpcbPartNumberOrFilepath}] Saved TypeScript component: ${outputFilename}`,\n )\n } else {\n console.error(\"Unsupported output format\")\n }\n }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CAAwC;IACtC;EACF;EACA,YAAYA,KACT,QAAQ,qCAAqC,EAC7C,QAAQ,qCAAqC;EAChD,0BAA0BA,KAAE,OAAO,EAAE,SAAS;EAC9C,eAAeA,KAAE,OAAO,EAAE,SAAS;AACrC,CAAC,EACA,SAAS,6DAA6D;AAoBzE,iBAGE,IAAI;ACvCC,IAAM,oBAAoBA,KAC9B,OAAO;EACN,MAAMA,KAAE,QAAQ,mBAAmB;EACnC,sBAAsB,4BAA4B,mBAAmB;EACrE,qBAAqBA,KAAE,OAAO,EAAE,SAAS;EACzC,gCAAgCA,KAAE,OAAO;EACzC,oCAAoCA,KAAE,OAAO;EAC7C,uBAAuBA,KAAE,OAAO;EAChC,gCAAgCA,KAAE,OAAO;EACzC,gCAAgCA,KAAE,OAAO;AAC3C,CAAC,EACA,SAAS,6DAA6D;AAmBzE,iBAA2D,IAAI;ACvBxD,IAAM,sBAAsBA,KAAE,MAAM;EAKrC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AACN,CAAC;AAKM,IAAM,mBAAmB;AAuBh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AACtD,YAAM,GAAG,UAAU,gBAAgB,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC;AACtE,cAAQ;AAAA,QACN,IAAI,0BAA0B,iCAAiC,cAAc;AAAA,MAC/E;AAAA,IACF,WACE,eAAe,SAAS,MAAM,KAC9B,eAAe,SAAS,KAAK,GAC7B;AACA,YAAM,SAAS,MAAM,oBAAoB,cAAc;AACvD,YAAM,GAAG,UAAU,gBAAgB,MAAM;AACzC,cAAQ;AAAA,QACN,IAAI,0BAA0B,iCAAiC,cAAc;AAAA,MAC/E;AAAA,IACF,OAAO;AACL,cAAQ,MAAM,2BAA2B;AAAA,IAC3C;AAAA,EACF,SAAS,OAAY;AACnB,YAAQ,MAAM,UAAU,MAAM,OAAO;AACrC,UAAM;AAAA,EACR;AACF;","names":["z","length","percentage","point","m","expected","found","rotation","su","component_type","source_port","joiner","Soup","source_port","point","point","distance","path","angle","point","pcb_component","position","rotation","z","fetch","z","z","pairs","rotation","point","size","z","PointSchema","z","rotation","path","parsePoints","z","parseObjBounds","z","fetch","rotation"]}
|