easyeda 0.0.176 → 0.0.178
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 +40 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-SRGPYV5T.js → chunk-SQYZHX3A.js} +41 -5
- package/dist/{chunk-SRGPYV5T.js.map → chunk-SQYZHX3A.js.map} +1 -1
- package/dist/cli/main.js +3 -3
- package/dist/cli/main.js.map +1 -1
- package/dist/lib/index.d.ts +712 -712
- package/dist/lib/index.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../lib/schemas/easy-eda-json-schema.ts","../../lib/schemas/package-detail-shape-schema.ts","../../lib/schemas/single-letter-shape-schema.ts","../../lib/utils/easyeda-unit-to-mm.ts","../../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/common/point3.ts","../../node_modules/circuit-json/src/common/size.ts","../../node_modules/circuit-json/src/common/getZodPrefixedIdWithDefault.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/utils/expect-types-match.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_led.ts","../../node_modules/circuit-json/src/source/source_simple_ground.ts","../../node_modules/circuit-json/src/source/source_simple_bug.ts","../../node_modules/circuit-json/src/source/source_simple_chip.ts","../../node_modules/circuit-json/src/source/source_led.ts","../../node_modules/circuit-json/src/source/source_simple_power_source.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_resonator.ts","../../node_modules/circuit-json/src/source/source_simple_transistor.ts","../../node_modules/circuit-json/src/source/source_simple_mosfet.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_port.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/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_line.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/NinePointAnchor.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_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/pcb/properties/layer_ref.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_port_not_matched_error.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_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_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_fabrication_note_text.ts","../../node_modules/circuit-json/src/pcb/pcb_fabrication_note_path.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/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/cad/cad_component.ts","../../node_modules/circuit-json/src/any_circuit_element.ts","../../node_modules/nanoid/url-alphabet/index.js","../../node_modules/nanoid/index.browser.js","../../node_modules/@tscircuit/soup-util/lib/su.ts","../../node_modules/@tscircuit/soup-util/lib/transform-soup-elements.ts","../../node_modules/@tscircuit/soup-util/lib/direction-to-vec.ts","../../node_modules/@tscircuit/soup-util/lib/apply-selector.ts","../../node_modules/@tscircuit/soup-util/lib/convert-abbreviation-to-soup-element-type.ts","../../node_modules/@tscircuit/soup-util/lib/get-element-id.ts","../../node_modules/@tscircuit/soup-util/lib/get-element-by-id.ts","../../node_modules/@tscircuit/soup-util/lib/readable-name-functions/get-readable-name-for-pcb-trace.ts","../../node_modules/@tscircuit/soup-util/lib/readable-name-functions/get-readable-name-for-pcb-port.ts","../../node_modules/@tscircuit/soup-util/lib/readable-name-functions/get-readable-name-for-pcb-smtpad.ts","../../node_modules/@tscircuit/soup-util/lib/readable-name-functions/get-readable-name-for-element.ts","../../node_modules/@tscircuit/soup-util/lib/get-bounds-of-pcb-elements.ts","../../node_modules/@tscircuit/soup-util/lib/utils/string-hash.ts","../../node_modules/@tscircuit/soup-util/lib/utils/get-layout-debug-object.ts","../../node_modules/@tscircuit/soup-util/lib/utils/is-truthy.ts","../../node_modules/@tscircuit/soup-util/lib/find-bounds-and-center.ts","../../lib/websafe/generate-footprint-tsx.ts","../../lib/websafe/convert-to-typescript-component/generate-typescript-component.ts","../../lib/math/arc-utils.ts","../../lib/convert-easyeda-json-to-tscircuit-soup-json.ts","../../lib/compute-center-offset.ts","../../lib/utils/normalize-manufacturer-part-number.ts","../../lib/websafe/convert-to-typescript-component/index.tsx","../../lib/websafe/fetch-easyeda-json.ts","../../lib/websafe/get-model-cdn-url.ts"],"sourcesContent":["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.union([z.string(), z.number()]).transform((val) => val.toString()),\n editorVersion: z.string(),\n c_para: z.record(z.string(), z.union([z.string(), z.null()])),\n x: z.number(),\n y: z.number(),\n puuid: z.string().optional(),\n uuid: z.string(),\n utime: z\n .union([z.string(), z.number()])\n .transform((val) => (val === \"\" ? 0 : Number(val))),\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.array(z.unknown()),\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 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})\n\nexport type RawEasyEdaJson = z.input<typeof EasyEdaJsonSchema>\nexport type BetterEasyEdaJson = z.infer<typeof EasyEdaJsonSchema>\n","import { z } from \"zod\"\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 } else 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\"]),\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: z.number().optional(),\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 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 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 const [firstParam, ...restParams] = shape.data.split(\"~\")\n const lastParam = restParams.pop()\n\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) => (isNaN(Number(p)) ? p : Number(p)))\n const center = { x: centerX, y: centerY }\n let points, rotation\n if (padShape === \"RECT\") {\n points = parsePoints(rest[0] as any)\n const r = Number(rest[1])\n 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 \"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 return BaseShapeSchema.parse({ type: shape.type })\n }\n })\n .pipe(PackageDetailShapeSchema)\n\nexport const ShapesArraySchema = z.array(ShapeItemSchema)\n","import { z } from \"zod\"\nimport { mm } from \"@tscircuit/mm\"\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 = 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\"]),\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 const label = nameMatch ? nameMatch[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 = parseFloat(rotation)\n return {\n type: \"PIN\",\n visibility: visibility as \"show\" | \"hide\",\n id,\n pinNumber: isNaN(Number(pinNumber)) ? pinNumber : Number(pinNumber),\n x: parseFloat(x),\n y: 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.enum([\"normal\", \"bold\"]).optional().default(\"normal\"),\n fontStyle: z.enum([\"normal\", \"italic\"]).optional().default(\"normal\"),\n fontDecoration: z.enum([\"\", \"underline\"]),\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\") as \"normal\" | \"bold\",\n fontStyle: (fontStyle || \"normal\") as \"normal\" | \"italic\",\n fontDecoration: fontDecoration as \"\" | \"underline\",\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","/**\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","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 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 const parseAndConvertSiUnit = <\n T extends\n | string\n | number\n | undefined\n | { x: string | number; y: string | number },\n>(\n v: T,\n): {\n parsedUnit: string | null\n unitOfValue: BaseTscircuitUnit | null\n value: T extends { x: string | number; y: string | number }\n ? null | { x: number; y: number }\n : null | number\n} => {\n if (typeof v === \"undefined\")\n return { parsedUnit: null, unitOfValue: null, value: null }\n if (typeof v === \"string\" && v.match(/^-?[\\d\\.]+$/))\n return {\n value: Number.parseFloat(v) as any,\n parsedUnit: null,\n unitOfValue: null,\n }\n if (typeof v === \"number\")\n return { value: v as any, parsedUnit: null, unitOfValue: null }\n if (typeof v === \"object\" && \"x\" in v && \"y\" in v) {\n const { parsedUnit, unitOfValue } = parseAndConvertSiUnit(v.x)\n return {\n parsedUnit: parsedUnit,\n unitOfValue: unitOfValue,\n value: {\n x: parseAndConvertSiUnit(v.x as any).value as number,\n y: parseAndConvertSiUnit(v.y as any).value as number,\n } as any,\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) as any,\n }\n }\n\n const { baseUnit, conversionFactor } = getBaseTscircuitUnit(unit)\n\n return {\n parsedUnit: unit,\n unitOfValue: baseUnit,\n value: (conversionFactor * Number.parseFloat(numberPart)) as any,\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 time = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\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\"\n\nexport const point = z.object({\n x: distance,\n y: distance,\n})\n\nexport const position = point\n\nexport type Point = z.infer<typeof point>\nexport type InputPoint = z.input<typeof point>\nexport type InputPosition = z.input<typeof position>\nexport type Position = z.infer<typeof position>\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\n\nexport const point3 = z.object({\n x: distance,\n y: distance,\n z: distance,\n})\n\nexport const position3 = point3\n\nexport type Point3 = z.infer<typeof point3>\n","import { z } from \"zod\"\n\nexport const size = z.object({\n width: z.number(),\n height: z.number(),\n})\n\nexport type Size = z.infer<typeof size>\n","import { z } from \"zod\"\nimport { nanoid } from \"nanoid\"\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}_${nanoid(10)}`)\n}\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\"\n\nexport const supplier_name = z.enum([\n \"jlcpcb\",\n \"macrofab\",\n \"pcbway\",\n \"digikey\",\n \"mouser\",\n \"lcsc\",\n])\n\nexport type SupplierName = z.infer<typeof supplier_name>\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 {\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 are_pins_interchangeable?: boolean\n internally_connected_source_port_ids?: string[][]\n source_group_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 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})\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 {\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 { source_component_base } from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\n\n/**\n * @deprecated Use source_simple_chip instead. This will be removed in a future version.\n */\nexport const source_simple_bug = source_component_base\n .extend({\n ftype: z.literal(\"simple_bug\"),\n })\n .describe(\"@deprecated\")\n\nexport type source_simple_bug = z.infer<typeof source_simple_bug>\nexport type SourceSimpleBugInput = z.input<typeof source_simple_bug>\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 { source_simple_diode } from \"./source_simple_diode\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport type { SourceComponentBase } from \"./base/source_component_base\"\n\nexport const source_led = source_simple_diode.extend({\n ftype: z.literal(\"led\"),\n})\n\nexport type SourceLedInput = z.input<typeof source_led>\ntype InferredSourceLed = z.infer<typeof source_led>\n\n/**\n * Defines an LED component that extends the simple diode\n */\nexport interface SourceLed extends SourceComponentBase {\n ftype: \"led\"\n}\n\nexpectTypesMatch<SourceLed, InferredSourceLed>(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_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 { 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_bug } from \"./source_simple_bug\"\nimport { source_simple_chip, type SourceSimpleChip } from \"./source_simple_chip\"\nimport { source_led, type SourceLed } from \"./source_led\"\nimport {\n source_simple_power_source,\n type SourceSimplePowerSource,\n} from \"./source_simple_power_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_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_mosfet,\n type SourceSimpleMosfet,\n} from \"./source_simple_mosfet\"\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\"\n\nexport const any_source_component = z.union([\n source_simple_resistor,\n source_simple_capacitor,\n source_simple_diode,\n source_simple_led,\n source_simple_ground,\n source_simple_chip,\n source_simple_bug,\n source_led,\n source_simple_power_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_resonator,\n source_simple_switch,\n source_simple_transistor,\n source_simple_mosfet,\n source_simple_fuse,\n source_project_metadata,\n source_missing_property_error,\n source_failed_to_create_component_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 | SourceSimpleLed\n | SourceSimpleGround\n | SourceSimpleChip\n | SourceLed\n | SourceSimplePowerSource\n | SourceSimpleBattery\n | SourceSimpleInductor\n | SourceSimplePushButton\n | SourceSimplePotentiometer\n | SourceSimpleCrystal\n | SourceSimplePinHeader\n | SourceSimpleResonator\n | SourceSimpleSwitch\n | SourceSimpleTransistor\n | SourceSimpleMosfet\n | SourceSimpleFuse\n | SourceProjectMetadata\n | SourceMissingPropertyError\n | SourceFailedToCreateComponentError\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})\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}\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 { source_component_base } from \"src/source/base/source_component_base\"\nimport { resistance } from \"src/units\"\n\nexport const source_simple_potentiometer = source_component_base.extend({\n ftype: z.literal(\"simple_potentiometer\"),\n max_resistance: resistance,\n})\n\nexport type SourceSimplePotentiometer = z.infer<\n typeof source_simple_potentiometer\n>\nexport type SourceSimplePotentiometerInput = z.input<\n typeof source_simple_potentiometer\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})\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}\n\nexpectTypesMatch<SourceSimpleCrystal, InferredSourceSimpleCrystal>(true)\n","import { source_component_base } from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\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 SourceSimplePinHeader = z.infer<typeof source_simple_pin_header>\nexport type SourceSimplePinHeaderInput = z.input<\n typeof source_simple_pin_header\n>\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_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_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\"\n\nexport interface SourceProjectMetadata {\n type: \"source_project_metadata\"\n name?: string\n software_used_string?: 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 created_at: z.string().datetime().optional(),\n})\n\nexport type InferredProjectMetadata = z.infer<typeof source_project_metadata>\nexpectTypesMatch<SourceProjectMetadata, InferredProjectMetadata>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_missing_property_error = z\n .object({\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 error_type: z.literal(\"source_missing_property_error\"),\n message: z.string(),\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 {\n type: \"source_missing_property_error\"\n source_missing_property_error_id: string\n source_component_id: string\n property_name: string\n error_type: \"source_missing_property_error\"\n message: string\n}\n\nexpectTypesMatch<\n SourceMissingPropertyError,\n InferredSourceMissingPropertyError\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_failed_to_create_component_error = z\n .object({\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 component_name: z.string().optional(),\n subcircuit_id: z.string().optional(),\n parent_source_component_id: z.string().optional(),\n message: z.string(),\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 type: \"source_failed_to_create_component_error\"\n source_failed_to_create_component_error_id: string\n message: string\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 { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_port = z.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(),\n subcircuit_id: z.string().optional(),\n})\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 {\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 subcircuit_id?: string\n}\n\nexpectTypesMatch<SourcePort, InferredSourcePort>(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\"\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 is_subcircuit: z.boolean().optional(),\n name: z.string().optional(),\n})\n\nexport type SourceGroup = z.infer<typeof source_group>\nexport type SourceGroupInput = z.input<typeof source_group>\n","import { z } from \"zod\"\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 trace_width: z.number().optional(),\n subcircuit_id: z.string().optional(),\n})\n\nexport type SourceNet = z.infer<typeof source_net>\nexport type SourceNetInput = z.input<typeof source_net>\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 width: number\n height: number\n is_dashed: boolean\n x: number\n y: number\n}\n\nexport const schematic_box = z\n .object({\n type: z.literal(\"schematic_box\"),\n schematic_component_id: z.string(),\n width: distance,\n height: distance,\n is_dashed: z.boolean().default(false),\n x: distance,\n y: distance,\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 { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicPath {\n type: \"schematic_path\"\n schematic_component_id: string\n fill_color?: \"red\" | \"blue\"\n is_filled?: boolean\n points: Point[]\n}\n\nexport const schematic_path = z.object({\n type: z.literal(\"schematic_path\"),\n schematic_component_id: z.string(),\n fill_color: z.enum([\"red\", \"blue\"]).optional(),\n is_filled: z.boolean().optional(),\n points: z.array(point),\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 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}\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(),\n schematic_component_id: z.string(),\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})\n\nexport type SchematicComponentInput = z.input<typeof schematic_component>\ntype InferredSchematicComponent = z.infer<typeof schematic_component>\n\nexpectTypesMatch<SchematicComponent, InferredSchematicComponent>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/**\n * Defines a line on the schematic, this can be used for adding arbitrary lines\n * to a schematic, but don't use it for drawing traces, schematic boxes or where\n * other schematic elements are more appropriate.\n */\nexport interface SchematicLine {\n type: \"schematic_line\"\n schematic_component_id: string\n x1: number\n x2: number\n y1: number\n y2: number\n}\n\nexport const schematic_line = z.object({\n type: z.literal(\"schematic_line\"),\n schematic_component_id: z.string(),\n x1: distance,\n x2: distance,\n y1: distance,\n y2: distance,\n})\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 { 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}\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(),\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})\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_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}\n\nexport const schematic_text = z.object({\n type: z.literal(\"schematic_text\"),\n schematic_component_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})\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\"\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","import { z } from \"zod\"\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","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}\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 })\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\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})\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 { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicError {\n type: \"schematic_error\"\n schematic_error_id: string\n error_type: \"schematic_port_not_found\"\n message: string\n}\n\nexport const schematic_error = z\n .object({\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.literal(\"schematic_port_not_found\"),\n message: z.string(),\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 { 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})\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}\n\nexport interface SchematicDebugLine {\n type: \"schematic_debug_object\"\n label?: string\n shape: \"line\"\n start: Point\n end: Point\n}\n\nexport interface SchematicDebugPoint {\n type: \"schematic_debug_object\"\n label?: string\n shape: \"point\"\n center: Point\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\"\n\nexport interface SchematicVoltageProbe {\n type: \"schematic_voltage_probe\"\n schematic_voltage_probe_id: string\n position: Point\n schematic_trace_id: string\n voltage?: number\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 position: point,\n schematic_trace_id: z.string(),\n voltage: voltage.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 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 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 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 name?: string\n description?: string\n}\n\nexpectTypesMatch<SchematicGroup, InferredSchematicGroup>(true)\n","import { z } from \"zod\"\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>\nexport type LayerRef = z.output<typeof layer_ref>\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 { distance } from \"src/units\"\nimport { layer_ref } from \"./layer_ref\"\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>\nexport type PcbRouteHint = z.output<typeof pcb_route_hint>\nexport type PcbRouteHints = z.output<typeof pcb_route_hints>\n","import { z } from \"zod\"\nimport { distance } from \"../../units\"\nimport { layer_ref } from \"./layer_ref\"\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 RouteHintPoint = z.infer<typeof route_hint_point>\nexport type RouteHintPointInput = z.input<typeof route_hint_point>\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 { rotation, length, type Rotation, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\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 width: length,\n height: length,\n subcircuit_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\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 width: Length\n height: Length\n pcb_group_id?: string\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 } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\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 hole_shape: z.enum([\"circle\", \"square\"]),\n hole_diameter: z.number(),\n x: distance,\n y: distance,\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 */\nexport interface PcbHoleCircleOrSquare {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n hole_shape: \"circle\" | \"square\"\n hole_diameter: number\n x: Distance\n y: Distance\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 hole_shape: z.literal(\"oval\"),\n hole_width: z.number(),\n hole_height: z.number(),\n x: distance,\n y: distance,\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 hole_shape: \"oval\"\n hole_width: number\n hole_height: number\n x: Distance\n y: Distance\n}\n\nexpectTypesMatch<PcbHoleOval, InferredPcbHoleOval>(true)\n\nexport const pcb_hole = pcb_hole_circle_or_square.or(pcb_hole_oval)\n\n/**\n * @deprecated Use PcbHoleCircleOrSquare or PcbHoleOval\n */\nexport type PCBHoleInput = z.input<typeof pcb_hole>\n/**\n * @deprecated Use PcbHoleCircleOrSquare or PcbHoleOval\n */\nexport type PCBHole = z.infer<typeof pcb_hole>\n\nexport type PcbHole = PcbHoleCircleOrSquare | PcbHoleOval\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_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 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})\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 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}\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 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})\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 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}\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 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})\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 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})\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 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}\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 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}\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])\nexport type PcbPlatedHole =\n | PcbPlatedHoleCircle\n | PcbPlatedHoleOval\n | PcbHoleCircularWithRectPad\n | PcbHolePillWithRectPad\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)\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(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\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}\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 } 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})\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 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})\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 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})\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})\n\nexport const pcb_smtpad = z\n .union([\n pcb_smtpad_circle,\n pcb_smtpad_rect,\n pcb_smtpad_rotated_rect,\n pcb_smtpad_pill,\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 PCBSMTPadPill = z.infer<typeof pcb_smtpad_pill>\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}\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 layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\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 ccw_rotation: Rotation\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\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}\n\nexport type PcbSmtPad =\n | PcbSmtPadCircle\n | PcbSmtPadRect\n | PcbSmtPadRotatedRect\n | PcbSmtPadPill\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<PcbSmtPadPill, PCBSMTPadPill>(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 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 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 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 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 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 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 { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_trace_error = z\n .object({\n type: z.literal(\"pcb_trace_error\"),\n pcb_trace_error_id: getZodPrefixedIdWithDefault(\"pcb_trace_error\"),\n error_type: z.literal(\"pcb_trace_error\"),\n message: z.string(),\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 })\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 {\n type: \"pcb_trace_error\"\n pcb_trace_error_id: string\n error_type: \"pcb_trace_error\"\n message: string\n center?: Point\n pcb_trace_id: string\n source_trace_id: string\n pcb_component_ids: string[]\n pcb_port_ids: string[]\n}\n\n/**\n * @deprecated use PcbTraceError\n */\nexport type PCBTraceError = PcbTraceError\n\nexpectTypesMatch<PcbTraceError, InferredPcbTraceError>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_port_not_matched_error = z\n .object({\n type: z.literal(\"pcb_port_not_matched_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_error\"),\n message: z.string(),\n pcb_component_ids: z.array(z.string()),\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 {\n type: \"pcb_port_not_matched_error\"\n pcb_error_id: string\n message: string\n pcb_component_ids: string[]\n}\n\n/**\n * @deprecated use PcbPortNotMatchedError\n */\nexport type PCBPortNotMatchedError = PcbPortNotMatchedError\n\nexpectTypesMatch<PcbPortNotMatchedError, InferredPcbPortNotMatchedError>(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 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 })\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 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}\n\n/**\n * @deprecated use PcbVia\n */\nexport type PCBVia = PcbVia\n\nexpectTypesMatch<PcbVia, InferredPcbVia>(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_board = z\n .object({\n type: z.literal(\"pcb_board\"),\n pcb_board_id: getZodPrefixedIdWithDefault(\"pcb_board\"),\n is_subcircuit: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n width: length,\n height: length,\n center: point,\n thickness: length.optional().default(1.4),\n num_layers: z.number().optional().default(4),\n outline: z.array(point).optional(),\n material: z.enum([\"fr4\", \"fr1\"]).default(\"fr4\"),\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 is_subcircuit?: boolean\n subcircuit_id?: string\n width: Length\n height: Length\n thickness: Length\n num_layers: number\n center: Point\n outline?: Point[]\n material: \"fr4\" | \"fr1\"\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 } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_placement_error = z\n .object({\n type: z.literal(\"pcb_placement_error\"),\n pcb_placement_error_id: getZodPrefixedIdWithDefault(\"pcb_placement_error\"),\n message: z.string(),\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 {\n type: \"pcb_placement_error\"\n pcb_placement_error_id: string\n message: string\n}\n\n/**\n * @deprecated use PcbPlacementError\n */\nexport type PCBPlacementError = PcbPlacementError\n\nexpectTypesMatch<PcbPlacementError, InferredPcbPlacementError>(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}\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 })\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 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 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 { 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 })\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}\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, 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 })\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}\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 } 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 } from \"../common\"\nimport { distance } from \"../units\"\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>\nexport type PCBKeepout = z.infer<typeof pcb_keepout>\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})\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})\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 shape: \"rect\"\n center: Point\n width: Length\n height: Length\n rotation?: Rotation\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 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 shape: \"polygon\"\n points: Point[]\n}\nexpectTypesMatch<PcbCutoutPolygon, InferredPcbCutoutPolygon>(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 ])\n .describe(\"Defines a cutout on the PCB, removing board material.\")\n\nexport type PcbCutoutInput = z.input<typeof pcb_cutout>\nexport type PcbCutout = PcbCutoutRect | PcbCutoutCircle | PcbCutoutPolygon\n\ntype InferredPcbCutout = z.infer<typeof pcb_cutout>\nexpectTypesMatch<PcbCutout, InferredPcbCutout>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_missing_footprint_error = z\n .object({\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.literal(\"pcb_missing_footprint_error\"),\n source_component_id: z.string(),\n message: 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 {\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 message: 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 { 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_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,\n height: length,\n center: point,\n pcb_component_ids: z.array(z.string()),\n name: z.string().optional(),\n description: 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 pcb_component_ids: string[]\n name?: string\n description?: string\n}\n\nexpectTypesMatch<PcbGroup, InferredPcbGroup>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_autorouting_error = z\n .object({\n type: z.literal(\"pcb_autorouting_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_autorouting_error\"),\n message: z.string(),\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 {\n type: \"pcb_autorouting_error\"\n pcb_error_id: string\n message: 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 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 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 { point3 } from \"../common\"\nimport { rotation, length } from \"../units\"\nimport { layer_ref } from \"src/pcb\"\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\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_jscad: z.any().optional(),\n })\n .describe(\"Defines a component on the PCB\")\n\nexport type CadComponentInput = z.input<typeof cad_component>\nexport type CadComponent = z.infer<typeof cad_component>\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 {\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.any_source_component,\n src.source_led,\n src.source_net,\n src.source_group,\n src.source_simple_bug,\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_resonator,\n src.source_simple_switch,\n src.source_simple_transistor,\n src.source_simple_mosfet,\n src.source_simple_potentiometer,\n src.source_simple_push_button,\n src.source_project_metadata,\n pcb.pcb_component,\n pcb.pcb_hole,\n pcb.pcb_missing_footprint_error,\n pcb.pcb_manual_edit_conflict_warning,\n pcb.pcb_plated_hole,\n pcb.pcb_keepout,\n pcb.pcb_port,\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_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_rect,\n pcb.pcb_silkscreen_circle,\n pcb.pcb_silkscreen_oval,\n pcb.pcb_trace_error,\n pcb.pcb_placement_error,\n pcb.pcb_port_not_matched_error,\n pcb.pcb_fabrication_note_path,\n pcb.pcb_fabrication_note_text,\n pcb.pcb_autorouting_error,\n pcb.pcb_cutout,\n sch.schematic_box,\n sch.schematic_text,\n sch.schematic_line,\n sch.schematic_component,\n sch.schematic_port,\n sch.schematic_trace,\n sch.schematic_path,\n sch.schematic_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 cad.cad_component,\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 | \"schematic_debug_object DOES NOT HAVE AN schematic_debug_object_id PROPERTY\"\n | \"schematic_box DOES NOT HAVE AN schematic_box_id PROPERTY\"\n | \"schematic_line DOES NOT HAVE AN schematic_line_id PROPERTY\"\n | \"schematic_path DOES NOT HAVE AN schematic_path_id PROPERTY\"\n>(true)\n","export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array(size))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","import type {\n AnyCircuitElement,\n AnyCircuitElementInput,\n SourceComponentBase,\n SourcePort,\n} from \"circuit-json\"\nimport * as Soup from \"circuit-json\"\n\ntype SoupOps<\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 SoupUtilObjects = {\n [K in AnyCircuitElement[\"type\"]]: SoupOps<K, AnyCircuitElement>\n} & {\n toArray: () => AnyCircuitElement[]\n}\nexport type SoupInputUtilObjects = {\n [K in AnyCircuitElementInput[\"type\"]]: SoupOps<K, AnyCircuitElementInput>\n}\n\nexport type SoupUtilOptions = {\n validateInserts?: boolean\n}\n\nexport type GetSoupUtilFn = ((\n soup: AnyCircuitElement[],\n options?: SoupUtilOptions,\n) => SoupUtilObjects) & {\n unparsed: (soup: AnyCircuitElementInput[]) => SoupInputUtilObjects\n}\n\ninterface InternalStore {\n counts: Record<string, number>\n}\n\nexport const su: GetSoupUtilFn = ((\n soup: AnyCircuitElement[],\n options: SoupUtilOptions = {},\n) => {\n let internalStore: InternalStore = (soup as any)._internal_store\n if (!internalStore) {\n internalStore = {\n counts: {},\n } as InternalStore\n ;(soup as any)._internal_store = 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 const su = new Proxy(\n {},\n {\n get: (proxy_target: any, component_type: string) => {\n if (component_type === \"toArray\") {\n return () => soup\n }\n\n return {\n get: (id: string) =>\n soup.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 = soup.find(\n (e: any) =>\n e.type === join_type && e[join_key] === using[join_key],\n )\n if (!joiner) return null\n return soup.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 soup.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 soup.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 soup.push(newElm)\n return newElm\n },\n delete: (id: string) => {\n const elm = soup.find(\n (e) => (e as any)[`${component_type}_id`] === id,\n )\n if (!elm) return\n soup.splice(soup.indexOf(elm), 1)\n },\n update: (id: string, newProps: any) => {\n const elm = soup.find(\n (e) =>\n e.type === component_type &&\n (e as any)[`${component_type}_id`] === id,\n )\n if (!elm) return\n Object.assign(elm, newProps)\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 soup.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 = 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\") return source_port\n\n if (component_type === \"pcb_port\") {\n return soup.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 soup.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\nsu.unparsed = su as any\n\nexport default su\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 } 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 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, { x: elm.x, y: elm.y })\n elm.x = x\n elm.y = y\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 ) {\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_component\"\n ) {\n elm.center = applyToPoint(matrix, elm.center)\n } else if (\n elm.type === \"pcb_silkscreen_path\" ||\n elm.type === \"pcb_trace\" ||\n elm.type === \"pcb_fabrication_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 (elm.type === \"pcb_silkscreen_line\") {\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 flipPadWidthHeight =\n Math.round(tsr.rotation.angle / (Math.PI / 2)) % 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`] && 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 }\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 { su } from \"../su\"\n\nexport function getReadableNameForPcbTrace(\n soup: AnyCircuitElement[],\n pcb_trace_id: string,\n) {\n // Find the pcb_trace object\n const pcbTrace = su(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 = su(soup).pcb_port.get(pcb_port_id)\n if (!pcbPort) return null\n\n const pcbComponent = su(soup).pcb_component.get(pcbPort.pcb_component_id)\n if (!pcbComponent) return null\n const sourceComponent = su(soup).source_component.get(\n pcbComponent.source_component_id,\n )\n if (!sourceComponent) return null\n\n const sourcePort = su(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 { su } from \"../su\"\n\nexport const getReadableNameForPcbPort = (\n soup: AnyCircuitElement[],\n pcb_port_id: string,\n): string => {\n const pcbPort = su(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 = su(soup).pcb_component.get(pcbPort?.pcb_component_id)\n\n if (!pcbComponent) {\n return `pcb_port[#${pcb_port_id}]`\n }\n\n // Get the source component information\n const sourceComponent = su(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 = su(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 { su } from \"../su\"\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 = su(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\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 if (\"x\" in elm && \"y\" in elm) {\n minX = Math.min(minX, elm.x)\n minY = Math.min(minY, elm.y)\n maxX = Math.max(maxX, elm.x)\n maxY = Math.max(maxY, elm.y)\n\n if (\"width\" in elm) {\n maxX = Math.max(maxX, elm.x + elm.width)\n }\n if (\"height\" in elm) {\n maxY = Math.max(maxY, elm.y + elm.height)\n }\n if (\"radius\" in elm) {\n minX = Math.min(minX, elm.x - elm.radius)\n minY = Math.min(minY, elm.y - elm.radius)\n maxX = Math.max(maxX, elm.x + elm.radius)\n maxY = Math.max(maxY, elm.y + elm.radius)\n }\n } else if (elm.type === \"pcb_trace\") {\n for (const point of elm.route) {\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","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 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((elm) => elm.type.startsWith(\"pcb_\"))\n .concat(\n elements\n .filter((elm) => elm.type === \"pcb_trace\")\n // @ts-ignore\n .flatMap((elm: PcbTrace) => 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 { mmStr } from \"@tscircuit/mm\"\nimport type { AnyCircuitElement } from \"circuit-json\"\nimport { su } from \"@tscircuit/soup-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 silkscreenPaths = su(circuitJson).pcb_silkscreen_path.list()\n const silkscreenTexts = su(circuitJson).pcb_silkscreen_text.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 === \"oval\" || platedHole.shape === \"pill\") {\n elementStrings.push(\n `<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX=\"${mmStr(platedHole.x)}\" pcbY=\"${mmStr(platedHole.y)}\" outerHeight=\"${mmStr(platedHole.outer_height)}\" outerWidth=\"${mmStr(platedHole.outer_width)}\" holeHeight=\"${mmStr(platedHole.hole_height)}\" holeWidth=\"${mmStr(platedHole.hole_width)}\" shape=\"${platedHole.shape}\" />`,\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 }\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 }\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 elementStrings.push(\n `<silkscreentext text=\"${silkscreenText.text}\" 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 return `\n <footprint>\n ${elementStrings.join(\"\\n\")}\n </footprint>\n `.trim()\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport type { ChipProps } from \"@tscircuit/props\"\nimport { generateFootprintTsx } from \"../generate-footprint-tsx\"\n\ninterface Params {\n pinLabels: ChipProps[\"pinLabels\"]\n componentName: string\n objUrl?: string\n circuitJson: AnyCircuitElement[]\n supplierPartNumbers: ChipProps[\"supplierPartNumbers\"]\n manufacturerPartNumber: string\n}\n\nexport const generateTypescriptComponent = ({\n pinLabels,\n componentName,\n objUrl,\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 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\n ? `cadModel={{\n objUrl: \"${objUrl}\",\n rotationOffset: { x: 0, y: 0, z: ${cadComponent?.rotation?.z ?? 0} },\n positionOffset: { x: 0, y: 0, z: 0 },\n }}`\n : \"\"\n }\n {...props}\n />\n )\n}\n`.trim()\n}\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","import type {\n PadSchema,\n TrackSchema,\n ArcSchema,\n SVGNodeSchema,\n HoleSchema,\n} from \"./schemas/package-detail-shape-schema\"\nimport type { z } from \"zod\"\nimport type { BetterEasyEdaJson } from \"./schemas/easy-eda-json-schema\"\nimport type {\n AnySoupElement,\n PCBSMTPad,\n PcbSilkscreenPath,\n PCBPlatedHole,\n PcbPlatedHoleInput,\n PcbComponentInput,\n} from \"circuit-json\"\nimport {\n any_source_component,\n pcb_smtpad,\n pcb_silkscreen_path,\n pcb_plated_hole,\n pcb_hole,\n} from \"circuit-json\"\nimport * as Soup from \"circuit-json\"\nimport { generateArcFromSweep, generateArcPathWithMid } from \"./math/arc-utils\"\nimport { findBoundsAndCenter, transformPCBElements } from \"@tscircuit/soup-util\"\nimport { compose, scale, translate } from \"transformation-matrix\"\nimport { computeCenterOffset } from \"./compute-center-offset\"\nimport { mm } from \"@tscircuit/mm\"\nimport { mil10ToMm } from \"./utils/easyeda-unit-to-mm\"\nimport { normalizePinLabels } from \"@tscircuit/core\"\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 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 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\ninterface Options {\n useModelCdn?: boolean\n shouldRecenter?: boolean\n}\n\nexport const convertEasyEdaJsonToCircuitJson = (\n easyEdaJson: BetterEasyEdaJson,\n { useModelCdn, shouldRecenter = true }: Options = {},\n): AnySoupElement[] => {\n const soupElements: AnySoupElement[] = []\n const centerOffset = computeCenterOffset(easyEdaJson)\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_bug\",\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_bug\",\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 soupElements.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(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 soupElements.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 commonPlatedHoleProps = {\n type: \"pcb_plated_hole\",\n pcb_plated_hole_id: `pcb_plated_hole_${index + 1}`,\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\",\n outer_width: mil2mm(pad.width),\n outer_height: mil2mm(pad.height),\n hole_width: innerWidth,\n hole_height: innerHeight,\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 soupElements.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 }\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 x: mil2mm(pad.center.x),\n y: mil2mm(pad.center.y),\n ...(soupShape === \"rect\"\n ? rectSize\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 soupElements.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 soupElements.push(handleHole(h, index))\n })\n\n // Add silkscreen paths, arcs and text\n easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {\n if (shape.type === \"TRACK\") {\n soupElements.push(handleSilkscreenPath(shape, index))\n } else if (shape.type === \"ARC\") {\n soupElements.push(handleSilkscreenArc(shape, index))\n } else if (shape.type === \"TEXT\") {\n soupElements.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: shape.text,\n anchor_position: {\n x: mil2mm(shape.x),\n y: mil2mm(shape.y),\n },\n anchor_alignment: {\n L: \"bottom_left\",\n C: \"center\",\n R: \"bottom_right\",\n }[shape.textAnchor ?? \"L\"],\n font_size: shape.size_mm ? shape.size_mm : undefined,\n layer: \"top\",\n } as Soup.PcbSilkscreenTextInput),\n )\n }\n })\n\n // TODO Change pcb_component width & height\n\n // TODO compute pcb center based on all elements and transform elements such\n // that the center is (0,0)\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 objFileUuid = svgNode?.svgData?.attrs?.uuid\n\n const objFileUrl = objFileUuid\n ? useModelCdn\n ? `https://modelcdn.tscircuit.com/easyeda_models/download?uuid=${objFileUuid}&pn=${easyEdaJson.lcsc.number}`\n : `https://modules.easyeda.com/3dmodel/${objFileUuid}`\n : undefined\n\n if (objFileUrl !== undefined) {\n const [rx, ry, rz] = (svgNode?.svgData.attrs?.c_rotation ?? \"0,0,0\")\n .split(\",\")\n .map(Number)\n soupElements.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 position: { x: 0, y: 0, z: 0 },\n rotation: { x: rx, y: ry, z: rz },\n model_obj_url: objFileUrl,\n } as Soup.CadComponentInput),\n )\n }\n\n if (shouldRecenter) {\n const bounds = findBoundsAndCenter(\n // exclude the pcb_component because it's center is currently incorrect,\n // we set it to (0,0)\n soupElements.filter((e) => e.type !== \"pcb_component\"),\n )\n transformPCBElements(\n soupElements,\n compose(translate(-bounds.center.x, bounds.center.y), scale(1, -1)),\n )\n pcb_component.center = { x: 0, y: 0 }\n }\n\n return soupElements\n}\n\n/** @deprecated Use `convertEasyEdaJsonToCircuitJson` instead. */\nexport const convertEasyEdaJsonToTscircuitSoupJson =\n convertEasyEdaJsonToCircuitJson\n","import type { z } from \"zod\"\nimport type { BetterEasyEdaJson } from \"./schemas/easy-eda-json-schema\"\nimport type { PadSchema } from \"./schemas/package-detail-shape-schema\"\nimport { mm } from \"@tscircuit/mm\"\n\nexport const computeCenterOffset = (easyeda: BetterEasyEdaJson) => {\n const pads = easyeda.packageDetail.dataStr.shape.filter(\n (shape): shape is z.infer<typeof PadSchema> => shape.type === \"PAD\",\n )\n\n const minX = Math.min(...pads.map((pad) => mm(pad.center.x)))\n const maxX = Math.max(...pads.map((pad) => mm(pad.center.x)))\n const minY = Math.min(...pads.map((pad) => mm(pad.center.y)))\n const maxY = Math.max(...pads.map((pad) => mm(pad.center.y)))\n\n const centerX = (minX + maxX) / 2\n const centerY = (minY + maxY) / 2\n\n return {\n x: centerX,\n y: centerY,\n }\n}\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 {\n EasyEdaJsonSchema,\n type BetterEasyEdaJson,\n} from \"lib/schemas/easy-eda-json-schema\"\nimport { su } from \"@tscircuit/soup-util\"\nimport { generateTypescriptComponent } from \"./generate-typescript-component\"\nimport { convertEasyEdaJsonToCircuitJson } from \"lib/convert-easyeda-json-to-tscircuit-soup-json\"\nimport { normalizeManufacturerPartNumber } from \"lib/utils/normalize-manufacturer-part-number\"\n\nexport const convertRawEasyToTsx = async (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 circuitJson = convertEasyEdaJsonToCircuitJson(betterEasy, {\n useModelCdn: true,\n shouldRecenter: true,\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 = parseInt(a.name.replace(\"pin\", \"\"))\n const bNum = 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 const [cadComponent] = su(circuitJson).cad_component.list()\n let modelObjUrl: string | undefined\n 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 }\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 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 type { RawEasyEdaJson } from \"../schemas/easy-eda-json-schema\"\n\nexport async function fetchEasyEDAComponent(\n jlcpcbPartNumber: string,\n { fetch = globalThis.fetch }: { fetch?: typeof globalThis.fetch } = {},\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 return componentResult.result\n}\n\n// Usage example\n// fetchEasyEDAComponent(\"C558438\")\n// .then((component) => console.log(component))\n// .catch((error) => console.error(error))\n","type Params = {\n easyedaPartNumber: string\n easyedaModelUuid: string\n}\n\nexport const getModelCdnUrl = ({\n easyedaModelUuid,\n easyedaPartNumber,\n}: Params): string => {\n return `https://modelcdn.tscircuit.com/easyeda_models/download?uuid=${easyedaModelUuid}&pn=${easyedaPartNumber}`\n}\n"],"mappings":";;;;;;;AAAA,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;A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AAK,CAAC;AAEvC,QAAM,gBAAgB,mBAAmB;AAGzC,QAAM,oBAAoB,MAAMA,OAAM,aAAa,aAAa,GAAG;AAAA,IACjE,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,GAAG;AAAA,MACH,SAAS,mCAAmC,aAAa;AAAA,IAC3D;AAAA,EACF,CAAC;AAED,MAAI,CAAC,kBAAkB,IAAI;AACzB,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AAEA,QAAM,kBAAkB,MAAM,kBAAkB,KAAK;AACrD,SAAO,gBAAgB;AACzB;;;AChEO,IAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AACF,MAAsB;AACpB,SAAO,+DAA+D,gBAAgB,OAAO,iBAAiB;AAChH;","names":["z","pairs","rotation","point","size","z","PointSchema","z","rotation","parsePoints","z","z","size","z","su","source_port","distance","angle","mm","mm","mm","point","pcb_component","fetch"]}
|
|
1
|
+
{"version":3,"sources":["../../lib/schemas/easy-eda-json-schema.ts","../../lib/schemas/package-detail-shape-schema.ts","../../lib/schemas/single-letter-shape-schema.ts","../../lib/utils/easyeda-unit-to-mm.ts","../../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/common/point3.ts","../../node_modules/circuit-json/src/common/size.ts","../../node_modules/circuit-json/src/common/getZodPrefixedIdWithDefault.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/utils/expect-types-match.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_led.ts","../../node_modules/circuit-json/src/source/source_simple_ground.ts","../../node_modules/circuit-json/src/source/source_simple_bug.ts","../../node_modules/circuit-json/src/source/source_simple_chip.ts","../../node_modules/circuit-json/src/source/source_led.ts","../../node_modules/circuit-json/src/source/source_simple_power_source.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_resonator.ts","../../node_modules/circuit-json/src/source/source_simple_transistor.ts","../../node_modules/circuit-json/src/source/source_simple_mosfet.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_port.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/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_line.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/NinePointAnchor.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_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/pcb/properties/layer_ref.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_port_not_matched_error.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_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_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_fabrication_note_text.ts","../../node_modules/circuit-json/src/pcb/pcb_fabrication_note_path.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/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/cad/cad_component.ts","../../node_modules/circuit-json/src/any_circuit_element.ts","../../node_modules/nanoid/url-alphabet/index.js","../../node_modules/nanoid/index.browser.js","../../node_modules/@tscircuit/soup-util/lib/su.ts","../../node_modules/@tscircuit/soup-util/lib/transform-soup-elements.ts","../../node_modules/@tscircuit/soup-util/lib/direction-to-vec.ts","../../node_modules/@tscircuit/soup-util/lib/apply-selector.ts","../../node_modules/@tscircuit/soup-util/lib/convert-abbreviation-to-soup-element-type.ts","../../node_modules/@tscircuit/soup-util/lib/get-element-id.ts","../../node_modules/@tscircuit/soup-util/lib/get-element-by-id.ts","../../node_modules/@tscircuit/soup-util/lib/readable-name-functions/get-readable-name-for-pcb-trace.ts","../../node_modules/@tscircuit/soup-util/lib/readable-name-functions/get-readable-name-for-pcb-port.ts","../../node_modules/@tscircuit/soup-util/lib/readable-name-functions/get-readable-name-for-pcb-smtpad.ts","../../node_modules/@tscircuit/soup-util/lib/readable-name-functions/get-readable-name-for-element.ts","../../node_modules/@tscircuit/soup-util/lib/get-bounds-of-pcb-elements.ts","../../node_modules/@tscircuit/soup-util/lib/utils/string-hash.ts","../../node_modules/@tscircuit/soup-util/lib/utils/get-layout-debug-object.ts","../../node_modules/@tscircuit/soup-util/lib/utils/is-truthy.ts","../../node_modules/@tscircuit/soup-util/lib/find-bounds-and-center.ts","../../lib/websafe/generate-footprint-tsx.ts","../../lib/websafe/convert-to-typescript-component/generate-typescript-component.ts","../../lib/math/arc-utils.ts","../../lib/convert-easyeda-json-to-tscircuit-soup-json.ts","../../lib/compute-center-offset.ts","../../lib/utils/normalize-manufacturer-part-number.ts","../../lib/websafe/convert-to-typescript-component/index.tsx","../../lib/websafe/fetch-easyeda-json.ts","../../lib/websafe/get-model-cdn-url.ts"],"sourcesContent":["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.union([z.string(), z.number()]).transform((val) => val.toString()),\n editorVersion: z.string(),\n c_para: z.record(z.string(), z.union([z.string(), z.null()])),\n x: z.number(),\n y: z.number(),\n puuid: z.string().optional(),\n uuid: z.string(),\n utime: z\n .union([z.string(), z.number()])\n .transform((val) => (val === \"\" ? 0 : Number(val))),\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.array(z.unknown()),\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 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})\n\nexport type RawEasyEdaJson = z.input<typeof EasyEdaJsonSchema>\nexport type BetterEasyEdaJson = z.infer<typeof EasyEdaJsonSchema>\n","import { z } from \"zod\"\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 } else 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\"]),\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: z.number().optional(),\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 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 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 const [firstParam, ...restParams] = shape.data.split(\"~\")\n const lastParam = restParams.pop()\n\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) => (isNaN(Number(p)) ? p : Number(p)))\n const center = { x: centerX, y: centerY }\n let points, rotation\n if (padShape === \"RECT\") {\n points = parsePoints(rest[0] as any)\n const r = Number(rest[1])\n 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 \"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 return BaseShapeSchema.parse({ type: shape.type })\n }\n })\n .pipe(PackageDetailShapeSchema)\n\nexport const ShapesArraySchema = z.array(ShapeItemSchema)\n","import { z } from \"zod\"\nimport { mm } from \"@tscircuit/mm\"\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 = 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\"]),\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 const label = nameMatch ? nameMatch[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 = parseFloat(rotation)\n return {\n type: \"PIN\",\n visibility: visibility as \"show\" | \"hide\",\n id,\n pinNumber: isNaN(Number(pinNumber)) ? pinNumber : Number(pinNumber),\n x: parseFloat(x),\n y: 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.enum([\"normal\", \"bold\"]).optional().default(\"normal\"),\n fontStyle: z.enum([\"normal\", \"italic\"]).optional().default(\"normal\"),\n fontDecoration: z.enum([\"\", \"underline\"]),\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\") as \"normal\" | \"bold\",\n fontStyle: (fontStyle || \"normal\") as \"normal\" | \"italic\",\n fontDecoration: fontDecoration as \"\" | \"underline\",\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","/**\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","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 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 const parseAndConvertSiUnit = <\n T extends\n | string\n | number\n | undefined\n | { x: string | number; y: string | number },\n>(\n v: T,\n): {\n parsedUnit: string | null\n unitOfValue: BaseTscircuitUnit | null\n value: T extends { x: string | number; y: string | number }\n ? null | { x: number; y: number }\n : null | number\n} => {\n if (typeof v === \"undefined\")\n return { parsedUnit: null, unitOfValue: null, value: null }\n if (typeof v === \"string\" && v.match(/^-?[\\d\\.]+$/))\n return {\n value: Number.parseFloat(v) as any,\n parsedUnit: null,\n unitOfValue: null,\n }\n if (typeof v === \"number\")\n return { value: v as any, parsedUnit: null, unitOfValue: null }\n if (typeof v === \"object\" && \"x\" in v && \"y\" in v) {\n const { parsedUnit, unitOfValue } = parseAndConvertSiUnit(v.x)\n return {\n parsedUnit: parsedUnit,\n unitOfValue: unitOfValue,\n value: {\n x: parseAndConvertSiUnit(v.x as any).value as number,\n y: parseAndConvertSiUnit(v.y as any).value as number,\n } as any,\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) as any,\n }\n }\n\n const { baseUnit, conversionFactor } = getBaseTscircuitUnit(unit)\n\n return {\n parsedUnit: unit,\n unitOfValue: baseUnit,\n value: (conversionFactor * Number.parseFloat(numberPart)) as any,\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 time = z\n .string()\n .or(z.number())\n .transform((v) => parseAndConvertSiUnit(v).value!)\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\"\n\nexport const point = z.object({\n x: distance,\n y: distance,\n})\n\nexport const position = point\n\nexport type Point = z.infer<typeof point>\nexport type InputPoint = z.input<typeof point>\nexport type InputPosition = z.input<typeof position>\nexport type Position = z.infer<typeof position>\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\n\nexport const point3 = z.object({\n x: distance,\n y: distance,\n z: distance,\n})\n\nexport const position3 = point3\n\nexport type Point3 = z.infer<typeof point3>\n","import { z } from \"zod\"\n\nexport const size = z.object({\n width: z.number(),\n height: z.number(),\n})\n\nexport type Size = z.infer<typeof size>\n","import { z } from \"zod\"\nimport { nanoid } from \"nanoid\"\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}_${nanoid(10)}`)\n}\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\"\n\nexport const supplier_name = z.enum([\n \"jlcpcb\",\n \"macrofab\",\n \"pcbway\",\n \"digikey\",\n \"mouser\",\n \"lcsc\",\n])\n\nexport type SupplierName = z.infer<typeof supplier_name>\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 {\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 are_pins_interchangeable?: boolean\n internally_connected_source_port_ids?: string[][]\n source_group_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 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})\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 {\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 { source_component_base } from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\n\n/**\n * @deprecated Use source_simple_chip instead. This will be removed in a future version.\n */\nexport const source_simple_bug = source_component_base\n .extend({\n ftype: z.literal(\"simple_bug\"),\n })\n .describe(\"@deprecated\")\n\nexport type source_simple_bug = z.infer<typeof source_simple_bug>\nexport type SourceSimpleBugInput = z.input<typeof source_simple_bug>\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 { source_simple_diode } from \"./source_simple_diode\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\nimport type { SourceComponentBase } from \"./base/source_component_base\"\n\nexport const source_led = source_simple_diode.extend({\n ftype: z.literal(\"led\"),\n})\n\nexport type SourceLedInput = z.input<typeof source_led>\ntype InferredSourceLed = z.infer<typeof source_led>\n\n/**\n * Defines an LED component that extends the simple diode\n */\nexport interface SourceLed extends SourceComponentBase {\n ftype: \"led\"\n}\n\nexpectTypesMatch<SourceLed, InferredSourceLed>(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_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 { 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_bug } from \"./source_simple_bug\"\nimport { source_simple_chip, type SourceSimpleChip } from \"./source_simple_chip\"\nimport { source_led, type SourceLed } from \"./source_led\"\nimport {\n source_simple_power_source,\n type SourceSimplePowerSource,\n} from \"./source_simple_power_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_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_mosfet,\n type SourceSimpleMosfet,\n} from \"./source_simple_mosfet\"\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\"\n\nexport const any_source_component = z.union([\n source_simple_resistor,\n source_simple_capacitor,\n source_simple_diode,\n source_simple_led,\n source_simple_ground,\n source_simple_chip,\n source_simple_bug,\n source_led,\n source_simple_power_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_resonator,\n source_simple_switch,\n source_simple_transistor,\n source_simple_mosfet,\n source_simple_fuse,\n source_project_metadata,\n source_missing_property_error,\n source_failed_to_create_component_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 | SourceSimpleLed\n | SourceSimpleGround\n | SourceSimpleChip\n | SourceLed\n | SourceSimplePowerSource\n | SourceSimpleBattery\n | SourceSimpleInductor\n | SourceSimplePushButton\n | SourceSimplePotentiometer\n | SourceSimpleCrystal\n | SourceSimplePinHeader\n | SourceSimpleResonator\n | SourceSimpleSwitch\n | SourceSimpleTransistor\n | SourceSimpleMosfet\n | SourceSimpleFuse\n | SourceProjectMetadata\n | SourceMissingPropertyError\n | SourceFailedToCreateComponentError\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})\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}\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 { source_component_base } from \"src/source/base/source_component_base\"\nimport { resistance } from \"src/units\"\n\nexport const source_simple_potentiometer = source_component_base.extend({\n ftype: z.literal(\"simple_potentiometer\"),\n max_resistance: resistance,\n})\n\nexport type SourceSimplePotentiometer = z.infer<\n typeof source_simple_potentiometer\n>\nexport type SourceSimplePotentiometerInput = z.input<\n typeof source_simple_potentiometer\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})\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}\n\nexpectTypesMatch<SourceSimpleCrystal, InferredSourceSimpleCrystal>(true)\n","import { source_component_base } from \"src/source/base/source_component_base\"\nimport { z } from \"zod\"\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 SourceSimplePinHeader = z.infer<typeof source_simple_pin_header>\nexport type SourceSimplePinHeaderInput = z.input<\n typeof source_simple_pin_header\n>\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_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_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\"\n\nexport interface SourceProjectMetadata {\n type: \"source_project_metadata\"\n name?: string\n software_used_string?: 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 created_at: z.string().datetime().optional(),\n})\n\nexport type InferredProjectMetadata = z.infer<typeof source_project_metadata>\nexpectTypesMatch<SourceProjectMetadata, InferredProjectMetadata>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_missing_property_error = z\n .object({\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 error_type: z.literal(\"source_missing_property_error\"),\n message: z.string(),\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 {\n type: \"source_missing_property_error\"\n source_missing_property_error_id: string\n source_component_id: string\n property_name: string\n error_type: \"source_missing_property_error\"\n message: string\n}\n\nexpectTypesMatch<\n SourceMissingPropertyError,\n InferredSourceMissingPropertyError\n>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_failed_to_create_component_error = z\n .object({\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 component_name: z.string().optional(),\n subcircuit_id: z.string().optional(),\n parent_source_component_id: z.string().optional(),\n message: z.string(),\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 type: \"source_failed_to_create_component_error\"\n source_failed_to_create_component_error_id: string\n message: string\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 { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const source_port = z.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(),\n subcircuit_id: z.string().optional(),\n})\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 {\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 subcircuit_id?: string\n}\n\nexpectTypesMatch<SourcePort, InferredSourcePort>(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\"\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 is_subcircuit: z.boolean().optional(),\n name: z.string().optional(),\n})\n\nexport type SourceGroup = z.infer<typeof source_group>\nexport type SourceGroupInput = z.input<typeof source_group>\n","import { z } from \"zod\"\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 trace_width: z.number().optional(),\n subcircuit_id: z.string().optional(),\n})\n\nexport type SourceNet = z.infer<typeof source_net>\nexport type SourceNetInput = z.input<typeof source_net>\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 width: number\n height: number\n is_dashed: boolean\n x: number\n y: number\n}\n\nexport const schematic_box = z\n .object({\n type: z.literal(\"schematic_box\"),\n schematic_component_id: z.string(),\n width: distance,\n height: distance,\n is_dashed: z.boolean().default(false),\n x: distance,\n y: distance,\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 { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicPath {\n type: \"schematic_path\"\n schematic_component_id: string\n fill_color?: \"red\" | \"blue\"\n is_filled?: boolean\n points: Point[]\n}\n\nexport const schematic_path = z.object({\n type: z.literal(\"schematic_path\"),\n schematic_component_id: z.string(),\n fill_color: z.enum([\"red\", \"blue\"]).optional(),\n is_filled: z.boolean().optional(),\n points: z.array(point),\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 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}\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(),\n schematic_component_id: z.string(),\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})\n\nexport type SchematicComponentInput = z.input<typeof schematic_component>\ntype InferredSchematicComponent = z.infer<typeof schematic_component>\n\nexpectTypesMatch<SchematicComponent, InferredSchematicComponent>(true)\n","import { z } from \"zod\"\nimport { distance } from \"../units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\n/**\n * Defines a line on the schematic, this can be used for adding arbitrary lines\n * to a schematic, but don't use it for drawing traces, schematic boxes or where\n * other schematic elements are more appropriate.\n */\nexport interface SchematicLine {\n type: \"schematic_line\"\n schematic_component_id: string\n x1: number\n x2: number\n y1: number\n y2: number\n}\n\nexport const schematic_line = z.object({\n type: z.literal(\"schematic_line\"),\n schematic_component_id: z.string(),\n x1: distance,\n x2: distance,\n y1: distance,\n y2: distance,\n})\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 { 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}\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(),\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})\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_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}\n\nexport const schematic_text = z.object({\n type: z.literal(\"schematic_text\"),\n schematic_component_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})\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\"\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","import { z } from \"zod\"\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","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}\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 })\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\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})\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 { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport interface SchematicError {\n type: \"schematic_error\"\n schematic_error_id: string\n error_type: \"schematic_port_not_found\"\n message: string\n}\n\nexport const schematic_error = z\n .object({\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.literal(\"schematic_port_not_found\"),\n message: z.string(),\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 { 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})\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}\n\nexport interface SchematicDebugLine {\n type: \"schematic_debug_object\"\n label?: string\n shape: \"line\"\n start: Point\n end: Point\n}\n\nexport interface SchematicDebugPoint {\n type: \"schematic_debug_object\"\n label?: string\n shape: \"point\"\n center: Point\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\"\n\nexport interface SchematicVoltageProbe {\n type: \"schematic_voltage_probe\"\n schematic_voltage_probe_id: string\n position: Point\n schematic_trace_id: string\n voltage?: number\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 position: point,\n schematic_trace_id: z.string(),\n voltage: voltage.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 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 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 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 name?: string\n description?: string\n}\n\nexpectTypesMatch<SchematicGroup, InferredSchematicGroup>(true)\n","import { z } from \"zod\"\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>\nexport type LayerRef = z.output<typeof layer_ref>\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 { distance } from \"src/units\"\nimport { layer_ref } from \"./layer_ref\"\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>\nexport type PcbRouteHint = z.output<typeof pcb_route_hint>\nexport type PcbRouteHints = z.output<typeof pcb_route_hints>\n","import { z } from \"zod\"\nimport { distance } from \"../../units\"\nimport { layer_ref } from \"./layer_ref\"\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 RouteHintPoint = z.infer<typeof route_hint_point>\nexport type RouteHintPointInput = z.input<typeof route_hint_point>\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 { rotation, length, type Rotation, type Length } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\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 width: length,\n height: length,\n subcircuit_id: z.string().optional(),\n pcb_group_id: z.string().optional(),\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 width: Length\n height: Length\n pcb_group_id?: string\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 } from \"src/units\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\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 hole_shape: z.enum([\"circle\", \"square\"]),\n hole_diameter: z.number(),\n x: distance,\n y: distance,\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 */\nexport interface PcbHoleCircleOrSquare {\n type: \"pcb_hole\"\n pcb_hole_id: string\n pcb_group_id?: string\n subcircuit_id?: string\n hole_shape: \"circle\" | \"square\"\n hole_diameter: number\n x: Distance\n y: Distance\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 hole_shape: z.literal(\"oval\"),\n hole_width: z.number(),\n hole_height: z.number(),\n x: distance,\n y: distance,\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 hole_shape: \"oval\"\n hole_width: number\n hole_height: number\n x: Distance\n y: Distance\n}\n\nexpectTypesMatch<PcbHoleOval, InferredPcbHoleOval>(true)\n\nexport const pcb_hole = pcb_hole_circle_or_square.or(pcb_hole_oval)\n\n/**\n * @deprecated Use PcbHoleCircleOrSquare or PcbHoleOval\n */\nexport type PCBHoleInput = z.input<typeof pcb_hole>\n/**\n * @deprecated Use PcbHoleCircleOrSquare or PcbHoleOval\n */\nexport type PCBHole = z.infer<typeof pcb_hole>\n\nexport type PcbHole = PcbHoleCircleOrSquare | PcbHoleOval\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_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 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})\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 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}\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 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})\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 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}\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 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})\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 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})\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 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}\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 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}\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])\nexport type PcbPlatedHole =\n | PcbPlatedHoleCircle\n | PcbPlatedHoleOval\n | PcbHoleCircularWithRectPad\n | PcbHolePillWithRectPad\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)\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(),\n x: distance,\n y: distance,\n layers: z.array(layer_ref),\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}\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 } 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})\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 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})\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 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})\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})\n\nexport const pcb_smtpad = z\n .union([\n pcb_smtpad_circle,\n pcb_smtpad_rect,\n pcb_smtpad_rotated_rect,\n pcb_smtpad_pill,\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 PCBSMTPadPill = z.infer<typeof pcb_smtpad_pill>\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}\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 layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\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 ccw_rotation: Rotation\n layer: LayerRef\n port_hints?: string[]\n pcb_component_id?: string\n pcb_port_id?: string\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}\n\nexport type PcbSmtPad =\n | PcbSmtPadCircle\n | PcbSmtPadRect\n | PcbSmtPadRotatedRect\n | PcbSmtPadPill\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<PcbSmtPadPill, PCBSMTPadPill>(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 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 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 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 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 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 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 { point, type Point, getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_trace_error = z\n .object({\n type: z.literal(\"pcb_trace_error\"),\n pcb_trace_error_id: getZodPrefixedIdWithDefault(\"pcb_trace_error\"),\n error_type: z.literal(\"pcb_trace_error\"),\n message: z.string(),\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 })\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 {\n type: \"pcb_trace_error\"\n pcb_trace_error_id: string\n error_type: \"pcb_trace_error\"\n message: string\n center?: Point\n pcb_trace_id: string\n source_trace_id: string\n pcb_component_ids: string[]\n pcb_port_ids: string[]\n}\n\n/**\n * @deprecated use PcbTraceError\n */\nexport type PCBTraceError = PcbTraceError\n\nexpectTypesMatch<PcbTraceError, InferredPcbTraceError>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_port_not_matched_error = z\n .object({\n type: z.literal(\"pcb_port_not_matched_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_error\"),\n message: z.string(),\n pcb_component_ids: z.array(z.string()),\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 {\n type: \"pcb_port_not_matched_error\"\n pcb_error_id: string\n message: string\n pcb_component_ids: string[]\n}\n\n/**\n * @deprecated use PcbPortNotMatchedError\n */\nexport type PCBPortNotMatchedError = PcbPortNotMatchedError\n\nexpectTypesMatch<PcbPortNotMatchedError, InferredPcbPortNotMatchedError>(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 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 })\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 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}\n\n/**\n * @deprecated use PcbVia\n */\nexport type PCBVia = PcbVia\n\nexpectTypesMatch<PcbVia, InferredPcbVia>(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_board = z\n .object({\n type: z.literal(\"pcb_board\"),\n pcb_board_id: getZodPrefixedIdWithDefault(\"pcb_board\"),\n is_subcircuit: z.boolean().optional(),\n subcircuit_id: z.string().optional(),\n width: length,\n height: length,\n center: point,\n thickness: length.optional().default(1.4),\n num_layers: z.number().optional().default(4),\n outline: z.array(point).optional(),\n material: z.enum([\"fr4\", \"fr1\"]).default(\"fr4\"),\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 is_subcircuit?: boolean\n subcircuit_id?: string\n width: Length\n height: Length\n thickness: Length\n num_layers: number\n center: Point\n outline?: Point[]\n material: \"fr4\" | \"fr1\"\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 } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_placement_error = z\n .object({\n type: z.literal(\"pcb_placement_error\"),\n pcb_placement_error_id: getZodPrefixedIdWithDefault(\"pcb_placement_error\"),\n message: z.string(),\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 {\n type: \"pcb_placement_error\"\n pcb_placement_error_id: string\n message: string\n}\n\n/**\n * @deprecated use PcbPlacementError\n */\nexport type PCBPlacementError = PcbPlacementError\n\nexpectTypesMatch<PcbPlacementError, InferredPcbPlacementError>(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}\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 })\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 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 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 { 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 })\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}\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, 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 })\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}\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 } 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 } from \"../common\"\nimport { distance } from \"../units\"\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>\nexport type PCBKeepout = z.infer<typeof pcb_keepout>\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})\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})\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 shape: \"rect\"\n center: Point\n width: Length\n height: Length\n rotation?: Rotation\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 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 shape: \"polygon\"\n points: Point[]\n}\nexpectTypesMatch<PcbCutoutPolygon, InferredPcbCutoutPolygon>(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 ])\n .describe(\"Defines a cutout on the PCB, removing board material.\")\n\nexport type PcbCutoutInput = z.input<typeof pcb_cutout>\nexport type PcbCutout = PcbCutoutRect | PcbCutoutCircle | PcbCutoutPolygon\n\ntype InferredPcbCutout = z.infer<typeof pcb_cutout>\nexpectTypesMatch<PcbCutout, InferredPcbCutout>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_missing_footprint_error = z\n .object({\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.literal(\"pcb_missing_footprint_error\"),\n source_component_id: z.string(),\n message: 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 {\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 message: 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 { 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_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,\n height: length,\n center: point,\n pcb_component_ids: z.array(z.string()),\n name: z.string().optional(),\n description: 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 pcb_component_ids: string[]\n name?: string\n description?: string\n}\n\nexpectTypesMatch<PcbGroup, InferredPcbGroup>(true)\n","import { z } from \"zod\"\nimport { getZodPrefixedIdWithDefault } from \"src/common\"\nimport { expectTypesMatch } from \"src/utils/expect-types-match\"\n\nexport const pcb_autorouting_error = z\n .object({\n type: z.literal(\"pcb_autorouting_error\"),\n pcb_error_id: getZodPrefixedIdWithDefault(\"pcb_autorouting_error\"),\n message: z.string(),\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 {\n type: \"pcb_autorouting_error\"\n pcb_error_id: string\n message: 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 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 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 { point3 } from \"../common\"\nimport { rotation, length } from \"../units\"\nimport { layer_ref } from \"src/pcb\"\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\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_jscad: z.any().optional(),\n })\n .describe(\"Defines a component on the PCB\")\n\nexport type CadComponentInput = z.input<typeof cad_component>\nexport type CadComponent = z.infer<typeof cad_component>\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 {\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.any_source_component,\n src.source_led,\n src.source_net,\n src.source_group,\n src.source_simple_bug,\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_resonator,\n src.source_simple_switch,\n src.source_simple_transistor,\n src.source_simple_mosfet,\n src.source_simple_potentiometer,\n src.source_simple_push_button,\n src.source_project_metadata,\n pcb.pcb_component,\n pcb.pcb_hole,\n pcb.pcb_missing_footprint_error,\n pcb.pcb_manual_edit_conflict_warning,\n pcb.pcb_plated_hole,\n pcb.pcb_keepout,\n pcb.pcb_port,\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_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_rect,\n pcb.pcb_silkscreen_circle,\n pcb.pcb_silkscreen_oval,\n pcb.pcb_trace_error,\n pcb.pcb_placement_error,\n pcb.pcb_port_not_matched_error,\n pcb.pcb_fabrication_note_path,\n pcb.pcb_fabrication_note_text,\n pcb.pcb_autorouting_error,\n pcb.pcb_cutout,\n sch.schematic_box,\n sch.schematic_text,\n sch.schematic_line,\n sch.schematic_component,\n sch.schematic_port,\n sch.schematic_trace,\n sch.schematic_path,\n sch.schematic_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 cad.cad_component,\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 | \"schematic_debug_object DOES NOT HAVE AN schematic_debug_object_id PROPERTY\"\n | \"schematic_box DOES NOT HAVE AN schematic_box_id PROPERTY\"\n | \"schematic_line DOES NOT HAVE AN schematic_line_id PROPERTY\"\n | \"schematic_path DOES NOT HAVE AN schematic_path_id PROPERTY\"\n>(true)\n","export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array(size))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","import type {\n AnyCircuitElement,\n AnyCircuitElementInput,\n SourceComponentBase,\n SourcePort,\n} from \"circuit-json\"\nimport * as Soup from \"circuit-json\"\n\ntype SoupOps<\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 SoupUtilObjects = {\n [K in AnyCircuitElement[\"type\"]]: SoupOps<K, AnyCircuitElement>\n} & {\n toArray: () => AnyCircuitElement[]\n}\nexport type SoupInputUtilObjects = {\n [K in AnyCircuitElementInput[\"type\"]]: SoupOps<K, AnyCircuitElementInput>\n}\n\nexport type SoupUtilOptions = {\n validateInserts?: boolean\n}\n\nexport type GetSoupUtilFn = ((\n soup: AnyCircuitElement[],\n options?: SoupUtilOptions,\n) => SoupUtilObjects) & {\n unparsed: (soup: AnyCircuitElementInput[]) => SoupInputUtilObjects\n}\n\ninterface InternalStore {\n counts: Record<string, number>\n}\n\nexport const su: GetSoupUtilFn = ((\n soup: AnyCircuitElement[],\n options: SoupUtilOptions = {},\n) => {\n let internalStore: InternalStore = (soup as any)._internal_store\n if (!internalStore) {\n internalStore = {\n counts: {},\n } as InternalStore\n ;(soup as any)._internal_store = 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 const su = new Proxy(\n {},\n {\n get: (proxy_target: any, component_type: string) => {\n if (component_type === \"toArray\") {\n return () => soup\n }\n\n return {\n get: (id: string) =>\n soup.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 = soup.find(\n (e: any) =>\n e.type === join_type && e[join_key] === using[join_key],\n )\n if (!joiner) return null\n return soup.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 soup.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 soup.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 soup.push(newElm)\n return newElm\n },\n delete: (id: string) => {\n const elm = soup.find(\n (e) => (e as any)[`${component_type}_id`] === id,\n )\n if (!elm) return\n soup.splice(soup.indexOf(elm), 1)\n },\n update: (id: string, newProps: any) => {\n const elm = soup.find(\n (e) =>\n e.type === component_type &&\n (e as any)[`${component_type}_id`] === id,\n )\n if (!elm) return\n Object.assign(elm, newProps)\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 soup.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 = 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\") return source_port\n\n if (component_type === \"pcb_port\") {\n return soup.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 soup.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\nsu.unparsed = su as any\n\nexport default su\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 } 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 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, { x: elm.x, y: elm.y })\n elm.x = x\n elm.y = y\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 ) {\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_component\"\n ) {\n elm.center = applyToPoint(matrix, elm.center)\n } else if (\n elm.type === \"pcb_silkscreen_path\" ||\n elm.type === \"pcb_trace\" ||\n elm.type === \"pcb_fabrication_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 (elm.type === \"pcb_silkscreen_line\") {\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 flipPadWidthHeight =\n Math.round(tsr.rotation.angle / (Math.PI / 2)) % 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`] && 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 }\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 { su } from \"../su\"\n\nexport function getReadableNameForPcbTrace(\n soup: AnyCircuitElement[],\n pcb_trace_id: string,\n) {\n // Find the pcb_trace object\n const pcbTrace = su(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 = su(soup).pcb_port.get(pcb_port_id)\n if (!pcbPort) return null\n\n const pcbComponent = su(soup).pcb_component.get(pcbPort.pcb_component_id)\n if (!pcbComponent) return null\n const sourceComponent = su(soup).source_component.get(\n pcbComponent.source_component_id,\n )\n if (!sourceComponent) return null\n\n const sourcePort = su(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 { su } from \"../su\"\n\nexport const getReadableNameForPcbPort = (\n soup: AnyCircuitElement[],\n pcb_port_id: string,\n): string => {\n const pcbPort = su(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 = su(soup).pcb_component.get(pcbPort?.pcb_component_id)\n\n if (!pcbComponent) {\n return `pcb_port[#${pcb_port_id}]`\n }\n\n // Get the source component information\n const sourceComponent = su(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 = su(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 { su } from \"../su\"\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 = su(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\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 if (\"x\" in elm && \"y\" in elm) {\n minX = Math.min(minX, elm.x)\n minY = Math.min(minY, elm.y)\n maxX = Math.max(maxX, elm.x)\n maxY = Math.max(maxY, elm.y)\n\n if (\"width\" in elm) {\n maxX = Math.max(maxX, elm.x + elm.width)\n }\n if (\"height\" in elm) {\n maxY = Math.max(maxY, elm.y + elm.height)\n }\n if (\"radius\" in elm) {\n minX = Math.min(minX, elm.x - elm.radius)\n minY = Math.min(minY, elm.y - elm.radius)\n maxX = Math.max(maxX, elm.x + elm.radius)\n maxY = Math.max(maxY, elm.y + elm.radius)\n }\n } else if (elm.type === \"pcb_trace\") {\n for (const point of elm.route) {\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","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 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((elm) => elm.type.startsWith(\"pcb_\"))\n .concat(\n elements\n .filter((elm) => elm.type === \"pcb_trace\")\n // @ts-ignore\n .flatMap((elm: PcbTrace) => 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 { mmStr } from \"@tscircuit/mm\"\nimport type { AnyCircuitElement } from \"circuit-json\"\nimport { su } from \"@tscircuit/soup-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 silkscreenPaths = su(circuitJson).pcb_silkscreen_path.list()\n const silkscreenTexts = su(circuitJson).pcb_silkscreen_text.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 === \"oval\" || platedHole.shape === \"pill\") {\n elementStrings.push(\n `<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX=\"${mmStr(platedHole.x)}\" pcbY=\"${mmStr(platedHole.y)}\" outerHeight=\"${mmStr(platedHole.outer_height)}\" outerWidth=\"${mmStr(platedHole.outer_width)}\" holeHeight=\"${mmStr(platedHole.hole_height)}\" holeWidth=\"${mmStr(platedHole.hole_width)}\" shape=\"${platedHole.shape}\" />`,\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 }\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 }\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 elementStrings.push(\n `<silkscreentext text=\"${silkscreenText.text}\" 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 return `\n <footprint>\n ${elementStrings.join(\"\\n\")}\n </footprint>\n `.trim()\n}\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport type { ChipProps } from \"@tscircuit/props\"\nimport { generateFootprintTsx } from \"../generate-footprint-tsx\"\n\ninterface Params {\n pinLabels: ChipProps[\"pinLabels\"]\n componentName: string\n objUrl?: string\n circuitJson: AnyCircuitElement[]\n supplierPartNumbers: ChipProps[\"supplierPartNumbers\"]\n manufacturerPartNumber: string\n}\n\nexport const generateTypescriptComponent = ({\n pinLabels,\n componentName,\n objUrl,\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 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\n ? `cadModel={{\n objUrl: \"${objUrl}\",\n rotationOffset: { x: 0, y: 0, z: ${cadComponent?.rotation?.z ?? 0} },\n positionOffset: { x: 0, y: 0, z: 0 },\n }}`\n : \"\"\n }\n {...props}\n />\n )\n}\n`.trim()\n}\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","import type {\n PadSchema,\n TrackSchema,\n ArcSchema,\n SVGNodeSchema,\n HoleSchema,\n SolidRegionSchema,\n} from \"./schemas/package-detail-shape-schema\"\nimport type { z } from \"zod\"\nimport type { BetterEasyEdaJson } from \"./schemas/easy-eda-json-schema\"\nimport type {\n AnySoupElement,\n PCBSMTPad,\n PcbSilkscreenPath,\n PCBPlatedHole,\n PcbPlatedHoleInput,\n PcbComponentInput,\n PcbCutoutPolygonInput,\n PcbCutoutCircleInput,\n} from \"circuit-json\"\nimport {\n any_source_component,\n pcb_smtpad,\n pcb_silkscreen_path,\n pcb_plated_hole,\n pcb_hole,\n} from \"circuit-json\"\nimport * as Soup from \"circuit-json\"\nimport { generateArcFromSweep, generateArcPathWithMid } from \"./math/arc-utils\"\nimport { findBoundsAndCenter, transformPCBElements } from \"@tscircuit/soup-util\"\nimport { compose, scale, translate, applyToPoint } from \"transformation-matrix\"\nimport { computeCenterOffset } from \"./compute-center-offset\"\nimport { mm } from \"@tscircuit/mm\"\nimport { mil10ToMm } from \"./utils/easyeda-unit-to-mm\"\nimport { normalizePinLabels } from \"@tscircuit/core\"\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 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 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 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}\n\nexport const convertEasyEdaJsonToCircuitJson = (\n easyEdaJson: BetterEasyEdaJson,\n { useModelCdn, shouldRecenter = true }: Options = {},\n): AnySoupElement[] => {\n const soupElements: AnySoupElement[] = []\n const centerOffset = computeCenterOffset(easyEdaJson)\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_bug\",\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_bug\",\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 soupElements.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(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 soupElements.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 commonPlatedHoleProps = {\n type: \"pcb_plated_hole\",\n pcb_plated_hole_id: `pcb_plated_hole_${index + 1}`,\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\",\n outer_width: mil2mm(pad.width),\n outer_height: mil2mm(pad.height),\n hole_width: innerWidth,\n hole_height: innerHeight,\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 soupElements.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 }\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 x: mil2mm(pad.center.x),\n y: mil2mm(pad.center.y),\n ...(soupShape === \"rect\"\n ? rectSize\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 soupElements.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 soupElements.push(handleHole(h, index))\n soupElements.push(handleHoleCutout(h, 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 soupElements.push(handleCutout(sr, index))\n })\n\n // Add silkscreen paths, arcs and text\n easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {\n if (shape.type === \"TRACK\") {\n soupElements.push(handleSilkscreenPath(shape, index))\n } else if (shape.type === \"ARC\") {\n soupElements.push(handleSilkscreenArc(shape, index))\n } else if (shape.type === \"TEXT\") {\n soupElements.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: shape.text,\n anchor_position: {\n x: mil2mm(shape.x),\n y: mil2mm(shape.y),\n },\n anchor_alignment: {\n L: \"bottom_left\",\n C: \"center\",\n R: \"bottom_right\",\n }[shape.textAnchor ?? \"L\"],\n font_size: shape.size_mm ? shape.size_mm : undefined,\n layer: \"top\",\n } as Soup.PcbSilkscreenTextInput),\n )\n }\n })\n\n // TODO Change pcb_component width & height\n\n // TODO compute pcb center based on all elements and transform elements such\n // that the center is (0,0)\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 objFileUuid = svgNode?.svgData?.attrs?.uuid\n\n const objFileUrl = objFileUuid\n ? useModelCdn\n ? `https://modelcdn.tscircuit.com/easyeda_models/download?uuid=${objFileUuid}&pn=${easyEdaJson.lcsc.number}`\n : `https://modules.easyeda.com/3dmodel/${objFileUuid}`\n : undefined\n\n if (objFileUrl !== undefined) {\n const [rx, ry, rz] = (svgNode?.svgData.attrs?.c_rotation ?? \"0,0,0\")\n .split(\",\")\n .map(Number)\n soupElements.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 position: { x: 0, y: 0, z: 0 },\n rotation: { x: rx, y: ry, z: rz },\n model_obj_url: objFileUrl,\n } as Soup.CadComponentInput),\n )\n }\n\n if (shouldRecenter) {\n const bounds = findBoundsAndCenter(\n // exclude the pcb_component because it's center is currently incorrect,\n // we set it to (0,0)\n soupElements.filter((e) => e.type !== \"pcb_component\"),\n )\n const matrix = compose(\n translate(-bounds.center.x, bounds.center.y),\n scale(1, -1),\n )\n transformPCBElements(soupElements, matrix)\n soupElements.forEach((e) => {\n if (e.type === \"pcb_cutout\") {\n if (e.shape === \"polygon\") {\n e.points = e.points.map((p) => applyToPoint(matrix, p))\n } else {\n e.center = applyToPoint(matrix, e.center)\n }\n }\n })\n pcb_component.center = { x: 0, y: 0 }\n }\n\n return soupElements\n}\n\n/** @deprecated Use `convertEasyEdaJsonToCircuitJson` instead. */\nexport const convertEasyEdaJsonToTscircuitSoupJson =\n convertEasyEdaJsonToCircuitJson\n","import type { z } from \"zod\"\nimport type { BetterEasyEdaJson } from \"./schemas/easy-eda-json-schema\"\nimport type { PadSchema } from \"./schemas/package-detail-shape-schema\"\nimport { mm } from \"@tscircuit/mm\"\n\nexport const computeCenterOffset = (easyeda: BetterEasyEdaJson) => {\n const pads = easyeda.packageDetail.dataStr.shape.filter(\n (shape): shape is z.infer<typeof PadSchema> => shape.type === \"PAD\",\n )\n\n const minX = Math.min(...pads.map((pad) => mm(pad.center.x)))\n const maxX = Math.max(...pads.map((pad) => mm(pad.center.x)))\n const minY = Math.min(...pads.map((pad) => mm(pad.center.y)))\n const maxY = Math.max(...pads.map((pad) => mm(pad.center.y)))\n\n const centerX = (minX + maxX) / 2\n const centerY = (minY + maxY) / 2\n\n return {\n x: centerX,\n y: centerY,\n }\n}\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 {\n EasyEdaJsonSchema,\n type BetterEasyEdaJson,\n} from \"lib/schemas/easy-eda-json-schema\"\nimport { su } from \"@tscircuit/soup-util\"\nimport { generateTypescriptComponent } from \"./generate-typescript-component\"\nimport { convertEasyEdaJsonToCircuitJson } from \"lib/convert-easyeda-json-to-tscircuit-soup-json\"\nimport { normalizeManufacturerPartNumber } from \"lib/utils/normalize-manufacturer-part-number\"\n\nexport const convertRawEasyToTsx = async (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 circuitJson = convertEasyEdaJsonToCircuitJson(betterEasy, {\n useModelCdn: true,\n shouldRecenter: true,\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 = parseInt(a.name.replace(\"pin\", \"\"))\n const bNum = 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 const [cadComponent] = su(circuitJson).cad_component.list()\n let modelObjUrl: string | undefined\n 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 }\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 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 type { RawEasyEdaJson } from \"../schemas/easy-eda-json-schema\"\n\nexport async function fetchEasyEDAComponent(\n jlcpcbPartNumber: string,\n { fetch = globalThis.fetch }: { fetch?: typeof globalThis.fetch } = {},\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 return componentResult.result\n}\n\n// Usage example\n// fetchEasyEDAComponent(\"C558438\")\n// .then((component) => console.log(component))\n// .catch((error) => console.error(error))\n","type Params = {\n easyedaPartNumber: string\n easyedaModelUuid: string\n}\n\nexport const getModelCdnUrl = ({\n easyedaModelUuid,\n easyedaPartNumber,\n}: Params): string => {\n return `https://modelcdn.tscircuit.com/easyeda_models/download?uuid=${easyedaModelUuid}&pn=${easyedaPartNumber}`\n}\n"],"mappings":";;;;;;;AAAA,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAElB,IAAM,WAAW,EACd,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAC9B,SAAS,EACT;AAAA,EAAU,CAAC,MACV,OAAO,MAAM,YAAY,EAAE,SAAS,KAAK,IACrC,I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,MAAM,uCAAuC;AAAA,EACzD;AAEA,QAAM,kBAAkB,MAAM,kBAAkB,KAAK;AACrD,SAAO,gBAAgB;AACzB;;;AChEO,IAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AACF,MAAsB;AACpB,SAAO,+DAA+D,gBAAgB,OAAO,iBAAiB;AAChH;","names":["z","pairs","rotation","point","size","z","PointSchema","z","rotation","parsePoints","z","z","size","z","su","source_port","distance","angle","applyToPoint","mm","mm","mm","point","pcb_component","applyToPoint","fetch"]}
|