Devesh36/usb-c-phone-stand-light

A 3D-printed tilted phone stand integrating USB‑C PD power, a Qi wireless charging coil with magnetic alignment ring, indicator LEDs/light pipes, control and protection PCBs, wiring, fasteners, and rubber feet.

Version
0.0.6
License
unset
Stars
0

dist/index.cjs

'use strict';

var jsxRuntime = require('react/jsx-runtime');
var tscircuit = require('tscircuit');
var react = require('react');

function WireHeader({ name, x, y, pins = 2, labels, schX = 0, schY = 0 }) {
    return jsxRuntime.jsx("pinheader", { name: name, pinCount: pins, pinLabels: labels, pcbX: x, pcbY: y, schX: schX, schY: schY, manufacturerPartNumber: pins === 2 ? "Solder wire pads, 5.08mm" : "Solder wire pads, 2.54mm", footprint: jsxRuntime.jsx("footprint", { children: Array.from({ length: pins }, (_, i) => jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx("platedhole", { portHints: [`pin${i + 1}`], pcbY: ((pins - 1) / 2 - i) * (pins === 2 ? 5.08 : 2.54), shape: "circle", holeDiameter: pins === 2 ? 1.2 : 0.9, outerDiameter: pins === 2 ? 2.4 : 1.8 }) }, i)) }), cadModel: null });
}
function LightingBoard() {
    return jsxRuntime.jsxs("board", { name: "POWER", width: 72, height: 28, thickness: 1.6, mountedTo: "BASE.pcb", mountGap: 0.2, routingDisabled: true, minTraceToPadEdgeClearance: "0.2mm", children: [jsxRuntime.jsx(WireHeader, { name: "J_USB", x: -27, y: 0, schX: -8, labels: { pin1: "5V", pin2: "GND" } }), jsxRuntime.jsx(WireHeader, { name: "J_QI", x: -7, y: 0, schX: -1, schY: 4, labels: { pin1: "5V_QI", pin2: "GND" } }), jsxRuntime.jsx(WireHeader, { name: "J_STATUS", x: 10, y: 6, schX: 1, schY: -3, labels: { pin1: "LED_A_3V3", pin2: "GND" } }), jsxRuntime.jsx(WireHeader, { name: "J_PANEL", x: 26, y: 0, pins: 4, schX: 8, labels: { pin1: "UV_A", pin2: "UV_K", pin3: "IR_A", pin4: "IR_K" } }), jsxRuntime.jsx("fuse", { name: "F_QI", footprint: "1812", pcbX: -17, pcbY: 6, currentRating: "2A", voltageRating: 6, manufacturerPartNumber: "MF-MSMF200-2", schX: -5, schY: 4 }), jsxRuntime.jsx("fuse", { name: "F_LED", footprint: "1812", pcbX: -17, pcbY: -7, currentRating: "250mA", voltageRating: 16, manufacturerPartNumber: "MF-MSMF025-2", schX: -5, schY: -1 }), jsxRuntime.jsx("resistor", { name: "R_UV", resistance: "1kohm", footprint: "0805", pcbX: 5, pcbY: -7, schX: 1, schY: 0, manufacturerPartNumber: "RC0805FR-071KL" }), jsxRuntime.jsx("resistor", { name: "R_IR", resistance: "470ohm", footprint: "0805", pcbX: 19, pcbY: 7, schX: 4, schY: -3, manufacturerPartNumber: "RC0805FR-07470RL" }), jsxRuntime.jsx("capacitor", { name: "C1", manufacturerPartNumber: "GRM21BR61C475KA73L", capacitance: "4.7uF", maxVoltageRating: 16, footprint: "0805", pcbX: -3, pcbY: -7, pcbRotation: 90, schX: -2, schY: -2 }), jsxRuntime.jsx("net", { name: "GND", isGroundNet: true, connectsTo: ["J_USB.pin2", "J_QI.pin2", "J_STATUS.pin2", "J_PANEL.pin2", "J_PANEL.pin4", "C1.pin2"] }), jsxRuntime.jsx("trace", { name: "J_USB_pin1_TO_F_QI_pin1", from: "J_USB.pin1", to: "F_QI.pin1", thickness: 1, pcbPath: ["J_USB.pin1", { x: 0, y: 6 }, "F_QI.pin1"] }), jsxRuntime.jsx("trace", { name: "F_QI_pin2_TO_J_QI_pin1", from: "F_QI.pin2", to: "J_QI.pin1", thickness: 1, pcbPath: ["F_QI.pin2", { x: 10, y: 0 }, "J_QI.pin1"] }), jsxRuntime.jsx("trace", { name: "J_USB_pin1_TO_F_LED_pin1", from: "J_USB.pin1", to: "F_LED.pin1", thickness: 0.5, pcbPath: ["J_USB.pin1", { x: -4, y: 2.54 }, { x: -4, y: -7 }, "F_LED.pin1"] }), jsxRuntime.jsx("trace", { name: "F_LED_pin2_TO_R_UV_pin1", from: "F_LED.pin2", to: "R_UV.pin1", thickness: 0.3, pcbPath: ["F_LED.pin2", { x: 6, y: 0 }, { x: 6, y: -4 }, { x: 21.025, y: -4 }, "R_UV.pin1"] }), jsxRuntime.jsx("trace", { name: "F_LED_pin2_TO_C1_pin1", from: "F_LED.pin2", to: "C1.pin1", thickness: 0.3, pcbPath: ["F_LED.pin2", { x: 6, y: 0 }, { x: 6, y: -4 }, { x: 14, y: -4 }, "C1.pin1"] }), jsxRuntime.jsx("trace", { name: "R_UV_pin2_TO_J_PANEL_pin1", from: "R_UV.pin2", to: "J_PANEL.pin1", thickness: 0.3, pcbPath: ["R_UV.pin2", { x: 13, y: 0 }, { x: 13, y: 10.81 }, "J_PANEL.pin1"] }), jsxRuntime.jsx("trace", { name: "J_STATUS_pin1_TO_R_IR_pin1", from: "J_STATUS.pin1", to: "R_IR.pin1", thickness: 0.25, pcbPath: ["J_STATUS.pin1", { x: 4, y: 2.54 }, "R_IR.pin1"] }), jsxRuntime.jsx("trace", { name: "R_IR_pin2_TO_J_PANEL_pin3", from: "R_IR.pin2", to: "J_PANEL.pin3", thickness: 0.25, pcbPath: ["R_IR.pin2", { x: 11, y: 0 }, { x: 11, y: -8.27 }, "J_PANEL.pin3"] }), jsxRuntime.jsx("via", { name: "C_GND", pcbX: -1, pcbY: -6, holeDiameter: 0.3, outerDiameter: 0.6, connectsTo: "net.GND" }), jsxRuntime.jsx("trace", { name: "C1_pin2_TO_C_GND_top", from: "C1.pin2", to: "C_GND.top", pcbPath: ["C1.pin2", "C_GND.top"] }), jsxRuntime.jsx("copperpour", { name: "GND_PLANE", layer: "bottom", connectsTo: "net.GND", useThermalReliefs: false, clearance: 0.3, boardEdgeMargin: 0.6 }), [-31, 31].flatMap(x => [-10, 10].map(y => jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx("hole", { name: `M_${x}_${y}`, pcbX: x, pcbY: y, diameter: 2.2 }) }, `${x}_${y}`))), jsxRuntime.jsx("silkscreentext", { text: "USB TO QI", pcbX: -13, pcbY: 11, fontSize: 0.9 }), jsxRuntime.jsx("silkscreentext", { text: "POWER / CHARGE", pcbX: 17, pcbY: -11, fontSize: 0.7 })] });
}

const dock = {
    tilt: (70 * Math.PI) / 180,
    chargerHeight: 85};
const chargerFrame = {
    x: 0,
    y: -8 + 1 + dock.chargerHeight * Math.cos(dock.tilt),
    z: 14 + 5 + dock.chargerHeight * Math.sin(dock.tilt),
};
function BaseBody() {
    return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsxs(tscircuit.jscad.union, { children: [jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsx(RoundedPlate, { width: 92, length: 110, thickness: 12.2, radius: 16, z: 6.1 }), jsxRuntime.jsx(RoundedPlate, { width: 88, length: 106, thickness: 25, radius: 14, z: 14.3 })] }), [-31, 31].flatMap((x) => [-10, 10].map((y) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 3.2, height: 3, center: [x - 3, y - 29, 1.5] }) }, `${x}_${y}`)))), [-24, 24].flatMap((x) => [-4, 4].map((y) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 4, height: 12.2, center: [x, y - 8, 6.1] }) }, `b_${x}_${y}`)))), [-34, 34].flatMap((x) => [-42, 42].map((y) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 3.5, height: 12.2, center: [x, y, 6.1] }) }, `l_${x}_${y}`)))), [-17, 17].map(x => jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 4, height: 12.2, center: [x, 39, 6.1] }, x)), jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [25, 22, 2], center: [-32, 12, 2] }), jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [2, 22, 5], center: [-20, 12, 3.5] }), jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [25, 2, 5], center: [-32, 24, 3.5] }), jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [25, 2, 5], center: [-32, 0, 3.5] })] }), [-31, 31].flatMap((x) => [-10, 10].map((y) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 0.85, height: 4.8, center: [x - 3, y - 29, 3.2] }) }, `p_${x}_${y}`)))), [-24, 24].flatMap((x) => [-4, 4].map((y) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 1.25, height: 11, center: [x, y - 8, 8] }) }, `s_${x}_${y}`)))), [-34, 34].flatMap((x) => [-42, 42].map((y) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 0.85, height: 8, center: [x, y, 10] }) }, `ls_${x}_${y}`)))), [-17, 17].map(x => jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 1.25, height: 10, center: [x, 39, 9] }, x)), jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [6, 8, 5], center: [-20, 12, 6.6] }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [-45, 12, 6.6], children: jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [0, Math.PI / 2, 0], children: jsxRuntime.jsx(RoundedPlate, { width: 7, length: 13, thickness: 8, radius: 1.3 }) }) }), [-22, -14, -6, 2, 10, 18, 26].map((x) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [4, 2, 8], center: [x, 54, 7] }) }, `v_${x}`)))] }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [-3, -29, 3], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "pcb", reference: true, size: [72, 28] }) }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 0, 12.2], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "lid", reference: true, size: [92, 110] }) })] }));
}
function BaseLid() {
    return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsx(RoundedPlate, { width: 92, length: 110, thickness: 1.8, radius: 16, z: 0.9 }), [-9, 9].map(x => jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 2.7, height: 6, center: [x, -39, 1] }, x)), jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 3, height: 5, center: [20, 4, 1] }), [-17, 17].map(x => jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 1.7, height: 6, center: [x, 39, 1] }, x)), [-24, 24].flatMap((x) => [-4, 4].map((y) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 1.7, height: 6, center: [x, y - 8, 1] }) }, `b_${x}_${y}`)))), [-34, 34].flatMap((x) => [-42, 42].map((y) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 1.1, height: 6, center: [x, y, 1] }) }, `l_${x}_${y}`))))] }), jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [Math.PI, 0, 0], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "bottom", reference: true, size: [92, 110] }) }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 0, 1.8], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "support", reference: true, size: [42, 14] }) }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, -8, 1.8], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "backrest", reference: true, size: [64, 14] }) }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, -39, -1.6], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "indicators", reference: true, size: [34, 14] }) }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, -39, 1.8], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "light", reference: true, size: [34, 14] }) }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [-14, -20, 1.8], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "switch", reference: true, size: [13, 6] }) })] }));
}
function Backrest() {
    return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsxs(tscircuit.jscad.union, { children: [jsxRuntime.jsx(tscircuit.jscad.roundedCuboid, { size: [64, 14, 5], center: [0, 0, 2.5], roundRadius: 1.5 }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 1, 5], children: jsxRuntime.jsxs(tscircuit.jscad.rotate, { angles: [dock.tilt, 0, 0], children: [jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsxs(tscircuit.jscad.union, { children: [jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [84, 108, 4], center: [0, 54, 0] }), jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 42, height: 4, center: [0, 108, 0] })] }), jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [56.6, 56.6, 12], center: [0, dock.chargerHeight, 0] }), [-38, 38].map((x) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 1.25, height: 12, center: [x, dock.chargerHeight, 0] }) }, x)))] }), [-25, 25].flatMap(x => [-25, 25].map(y => jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [8, 4, 1], center: [x, dock.chargerHeight + y, -1] }, `${x}_${y}`))), [-26, 26].map((x) => (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [26, 4, 20], center: [x, 0, 9] }), jsxRuntime.jsx(tscircuit.jscad.roundedCuboid, { size: [26, 12, 4], center: [x, 6, 19], roundRadius: 1.5 })] }, `c_${x}`)))] }) })] }), [-24, 24].flatMap((x) => [-4, 4].map((y) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 1.7, height: 12, center: [x, y, 3] }) }, `f_${x}_${y}`))))] }), jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [Math.PI, 0, 0], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "foot", reference: true, size: [64, 14] }) }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 1, 5], children: jsxRuntime.jsxs(tscircuit.jscad.rotate, { angles: [dock.tilt, 0, 0], children: [jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, dock.chargerHeight, 2], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "charger", reference: true, size: [66, 66] }) }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, dock.chargerHeight, -2], children: jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [Math.PI, 0, 0], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "charger_rear", reference: true, size: [66, 66] }) }) })] }) })] }));
}
function ChargingCover() {
    return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsxs(tscircuit.jscad.union, { children: [jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 42, height: 1.2, center: [0, 0, 6] }), [-38, 38].map((x) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [7, 9, 4.3], center: [x, 0, 4.15] }) }, x)))] }), jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 29.2, height: 4, center: [0, 0, 7.9] }), jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 23.8, height: 6, center: [0, 0, 7.9] })] }), [-38, 38].map((x) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 1.7, height: 14, center: [x, 0, 3] }) }, `h_${x}`))), [-38, 38].map((x) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 3, height: 2, center: [x, 0, 5.7] }) }, `head_${x}`)))] }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 0, 2], children: jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [Math.PI, 0, 0], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "back", reference: true, size: [76, 76] }) }) })] }));
}
function RearOutline({ inset = 0, thickness, z }) {
    const r = 42 - inset;
    return jsxRuntime.jsxs(tscircuit.jscad.union, { children: [jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [84 - 2 * inset, 101 - inset, thickness], center: [0, -27.5 + inset / 2, z] }), jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: r, height: thickness, center: [0, 23, z] })] });
}
function ChargerRearHousing() {
    return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsxs(tscircuit.jscad.union, { children: [jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsx(RearOutline, { thickness: 10, z: -7 }), jsxRuntime.jsx(RearOutline, { inset: 2, thickness: 10, z: -5.5 })] }), [-25, 25].flatMap(x => [-20, 20].map(y => jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 2.5, height: 0.5, center: [x, y, -10.25] }, `${x}_${y}`))), [-38, 38].map(x => jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [7, 9, 8], center: [x, 0, -6] }, x)), [-60, -50, -40, -30, 30, 40, 50, 57].map(y => jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [y > 40 ? 48 : 72, 1.8, 0.8], center: [0, y, -12.4] }, y)), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, -18, -15.5], children: jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [0, Math.PI / 2, 0], children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 4.3, height: 36 }) }) })] }), jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [14, 8, 12], center: [20, -78, -9] }), [-12, -4, 4, 12].map(y => jsxRuntime.jsx(tscircuit.jscad.cuboid, { size: [54, 2, 5], center: [0, y, -11.5] }, y)), [-38, 38].map(x => jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 1.25, height: 12, center: [x, 0, -4] }, x))] }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 0, -2], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "front", reference: true, size: [84, 140] }) })] });
}
// Separate clear light pipes above the two indicator-board LEDs.
function LightWindow({ positions = [-9, 9] } = {}) {
    return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [positions.map(x => jsxRuntime.jsx(tscircuit.jscad.colorize, { color: "#d9dce2", children: jsxRuntime.jsxs(tscircuit.jscad.union, { children: [jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 2.5, height: 0.6, center: [x, 0, 0.3] }), jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 3.6, height: 0.4, center: [x, 0, 0.7] })] }) }, x)), jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [Math.PI, 0, 0], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "bottom", reference: true, size: [34, 14] }) })] });
}
function RoundedPlate({ width, length, thickness, radius, z = 0 }) {
    return jsxRuntime.jsx(tscircuit.jscad.hull, { children: [-1, 1].flatMap(x => [-1, 1].map(y => jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: radius, height: thickness, center: [x * (width / 2 - radius), y * (length / 2 - radius), z] }, `${x}_${y}`))) });
}
// Fixed-angle rear brace: rounded central strut and two transverse hinge barrels.
function RearSupport() {
    return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(tscircuit.jscad.union, { children: [jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 39, 23.5], children: jsxRuntime.jsx(RoundedPlate, { width: 42, length: 14, thickness: 3, radius: 3 }) }), [-17, 17].map(x => jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 1.7, height: 8, center: [x, 39, 24] }, x))] }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 39, 26.2], children: jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [98.08 * Math.PI / 180, 0, 0], children: jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 29.52, 0], children: jsxRuntime.jsx(RoundedPlate, { width: 24, length: 59.04, thickness: 3.5, radius: 11 }) }) }) }), [[0, 39, 26.2], [0, 30.7, 84.65]].map((p, i) => jsxRuntime.jsx(tscircuit.jscad.translate, { offset: p, children: jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [0, Math.PI / 2, 0], children: jsxRuntime.jsx(tscircuit.jscad.cylinder, { radius: 4.2, height: 34 }) }) }, i))] }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 0, 22], children: jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [Math.PI, 0, 0], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "bottom", reference: true, size: [42, 14] }) }) })] });
}
function PowerLens() { return jsxRuntime.jsx(LightWindow, { positions: [-9] }); }
function ChargeLens() { return jsxRuntime.jsx(LightWindow, { positions: [9] }); }
// Black printed surround around the exposed, flush USB-C connector.
function UsbBezel() {
    return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [-46.15, 12, 6.6], children: jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [0, Math.PI / 2, 0], children: jsxRuntime.jsxs(tscircuit.jscad.subtract, { children: [jsxRuntime.jsx(RoundedPlate, { width: 9, length: 16, thickness: 0.8, radius: 2 }), jsxRuntime.jsx(RoundedPlate, { width: 7, length: 13, thickness: 2, radius: 1.3 })] }) }) }), jsxRuntime.jsx(tscircuit.jscad.translate, { offset: [0, 0, 12.2], children: jsxRuntime.jsx(tscircuit.jscad.rotate, { angles: [Math.PI, 0, 0], children: jsxRuntime.jsx(tscircuit.jscad.rectangle, { name: "datum", reference: true, size: [92, 110] }) }) })] });
}

const box = (size, center) => ({
    type: "translate",
    vector: center,
    shape: { type: "cuboid", size },
});
const cylinder = (radius, height, center) => ({
    type: "cylinder",
    radius,
    height,
    center,
    resolution: 64,
});
const union = (...shapes) => ({
    type: "union",
    shapes,
});
const subtract = (...shapes) => ({
    type: "subtract",
    shapes,
});
const color = (rgb, shape) => ({
    type: "colorize",
    color: rgb,
    shape,
});
function usbCapsule(depth, width, height, center) {
    return { type: "hull", shapes: [-1, 1].map(side => ({ type: "translate", vector: [center[0], center[1] + side * (width - height) / 2, center[2]], shape: { type: "rotate", angles: [0, Math.PI / 2, 0], shape: cylinder(height / 2, depth, [0, 0, 0]) } })) };
}
const pdModuleLocal = union(color([0.1, 0.4, 0.68], box([20.8, 20.2, 1.6], [-26.9, 12, 6.2])), color([0.08, 0.09, 0.12], box([5, 5, 1.5], [-24, 12, 7.75])), color([0.68, 0.71, 0.75], subtract(usbCapsule(7.3, 8.9, 3.2, [-37.35, 12, 8.6]), usbCapsule(7.6, 8.25, 2.5, [-38.4, 12, 8.6]))), color([0.06, 0.07, 0.09], box([3.5, 5.8, 0.65], [-38.2, 12, 8.6])), color([0.06, 0.07, 0.09], box([5.8, 5.1, 1.8], [-17.5, 12, 7.9])));
const pdModule = { type: "translate", vector: [-5, 0, -2], shape: pdModuleLocal };
const qiControllerLocal = union(color([0.09, 0.39, 0.64], box([68.58, 54.61, 1.6], [0, 0, -9.2])), color([0.04, 0.05, 0.07], box([9, 9, 3], [0, 3, -6.9])), color([0.12, 0.13, 0.16], box([9, 9, 4.4], [-16, 0, -6.2])), color([0.65, 0.68, 0.72], subtract(box([7, 5, 2.4], [-30, -1.27, -7.2]), box([5.6, 5.1, 1.4], [-31.2, -1.27, -7.2]))));
const qiController = union({ type: "rotate", angles: [0, 0, Math.PI / 2], shape: qiControllerLocal }, color([.18, .19, .21], box([5, 5, 2.6], [1.27, -37, -7.2])), color([.65, .68, .72], box([5, 4, 2.2], [1.27, -32.5, -7.2])));
const qiPlate = union(color([0.1, 0.11, 0.13], box([53, 53, 1], [0, 0, 0])), color([0.69, 0.37, 0.12], subtract(cylinder(22.5, 3, [0, 0, 2]), cylinder(9, 4, [0, 0, 2]))), color([0.76, 0.66, 0.43], cylinder(8, 3, [0, 0, 2])));
const magneticRing = color([0.24, 0.27, 0.3], subtract(cylinder(29, 1.4, [0, 0, 6.6]), cylinder(24, 3, [0, 0, 6.6])));
const rubberFeet = color([0.06, 0.065, 0.07], union(...[-34, 34].flatMap((x) => [-41, 41].map((y) => cylinder(4, 2, [x, y, -1])))));
const standScrews = color([0.17, 0.19, 0.22], union(...[-24, 24].flatMap((x) => [-4, 4].map((y) => union(cylinder(1.5, 12, [x, y - 8, 13]), cylinder(2.8, 1.8, [x, y - 8, 19.9]))))));
const supportScrews = color([.17, .19, .22], union(...[-17, 17].map(x => union(cylinder(1.5, 12, [x, 39, 11]), cylinder(2.8, 1.8, [x, 39, 17.9])))));
const lidScrews = color([0.17, 0.19, 0.22], union(...[-34, 34].flatMap((x) => [-42, 42].map((y) => union(cylinder(1, 6, [x, y, 11]), cylinder(2, 1.2, [x, y, 14.6]))))));
const coverScrews = color([0.3, 0.32, 0.34], union(...[-38, 38].map((x) => union(cylinder(1.5, 12, [x, 0, -1.275]), cylinder(2.8, 1.65, [x, 0, 5.55])))));
function toChargerWorld([x, y, z]) {
    const c = Math.cos(dock.tilt), s = Math.sin(dock.tilt);
    return [x, chargerFrame.y + y * c - z * s, chargerFrame.z + y * s + z * c];
}
function wire(points, rgb) {
    return color(rgb, union(...points.slice(1).map((p, i) => ({
        type: "hull",
        shapes: [
            {
                type: "sphere",
                radius: 0.7,
                center: points[i],
                resolution: 12,
            },
            { type: "sphere", radius: 0.7, center: p, resolution: 12 },
        ],
    }))));
}
// All harness vertices are in assembly millimeters. Positive and return
// conductors terminate at separate connector pads; they are not decorative loops.
const chargePath = [
    [-10, -26.46, 5], [-10, -12, 8], [20, 4, 8], [20, 4, 15],
    toChargerWorld([20, -78, -9]), toChargerWorld([1.27, -56, -9.5]),
    toChargerWorld([1.27, -38, -7.2]),
];
const chargingHarness = union(wire(chargePath, [.77, .09, .08]), wire([[-10, -31.54, 5], ...chargePath.slice(1).map(([x, y, z]) => [x + 1.8, y, z])], [.07, .08, .1]));
const supplyHarness = union(wire([[-22.5, 12, 7], [-33, 4, 8], [-30, -26.46, 5]], [.77, .09, .08]), wire([[-20.9, 12, 7], [-31.4, 4, 8], [-30, -31.54, 5]], [.07, .08, .1]));
const statusPath = [toChargerWorld([-14.6, -13.3, -7.6]), toChargerWorld([20, -30, -7.6]), toChargerWorld([20, -78, -9]), [20, 4, 15], [20, 4, 8], [7, -20.46, 5]];
const statusHarness = union(wire(statusPath, [.13, .63, .24]), wire([...statusPath.slice(0, -1).map(([x, y, z]) => [x + 1.7, y, z]), [7, -25.54, 5]], [.08, .1, .12]));
const panelHarness = union(...[[.8, .07, .06], [.07, .08, .1], [.1, .65, .24], [.12, .13, .15]].map((rgb, i) => wire([[23, -25.19 - i * 2.54, 5], [18, -34 - i * 1.2, 7], [5, -35.19 - i * 2.54, 9], [0, -35.19 - i * 2.54, 11.2]], rgb)));
const coilHarness = union(wire([[27, 12, -7], [27.4, 20, -5], [27.4, 20, 4.5], [16, 15, 3.2]], [.7, .34, .1]), wire([[27, 14, -7], [27.4, 21, -5], [27.4, 21, 4.5], [14, 17, 3.2]], [.66, .3, .08]));
// Nominal 3.45 x 3.45 x 1.9 mm packages; both footprints rotate 45 degrees.
// Neutral lens colors describe the unpowered parts, not visible red/green light.
const indicatorModule = union(color([.05, .32, .18], box([34, 14, .8], [0, -39, 11.1])), ...[-9, 9].flatMap(x => [
    color([.92, .92, .9], { type: "translate", vector: [x, -39, 11.75], shape: { type: "rotate", angles: [0, 0, Math.PI / 4], shape: box([3.45, 3.45, .5], [0, 0, 0]) } }),
    color([.8, .82, .85], cylinder(1.5, 1.4, [x, -39, 12.7])),
]));

// Generic CAD offsets use the PCB coordinate frame; mounted printed parts
// resolve their named world frames automatically.
const assemblyOrigin = {
    x: 3,
    y: 29,
    z: -4,
};
const chargerPosition = {
    x: chargerFrame.x + assemblyOrigin.x,
    y: chargerFrame.y + assemblyOrigin.y,
    z: chargerFrame.z + assemblyOrigin.z,
};
const chargerRotation = { x: 70, y: 0, z: 0 };
function DeskGlowChargingStand() {
    return (jsxRuntime.jsxs(tscircuit.assembly.device, { name: "DeskGlow", children: [jsxRuntime.jsx(tscircuit.assembly.printedpart, { name: "BASE", displayName: "Electronics enclosure", material: "petg", color: "#60656b", jscad: jsxRuntime.jsx(BaseBody, {}) }), jsxRuntime.jsx(tscircuit.assembly.printedpart, { name: "LID", displayName: "Base lid", material: "petg", color: "#747a80", mountedTo: "BASE.lid", mountFace: "bottom", jscad: jsxRuntime.jsx(BaseLid, {}) }), jsxRuntime.jsx(tscircuit.assembly.printedpart, { name: "BACKREST", displayName: "Tilted phone cradle", material: "petg", color: "#60656b", mountedTo: "LID.backrest", mountFace: "foot", jscad: jsxRuntime.jsx(Backrest, {}) }), jsxRuntime.jsx(tscircuit.assembly.printedpart, { name: "COIL_COVER", displayName: "Wireless charging face", material: "petg", color: "#e6e9ee", mountedTo: "BACKREST.charger", mountFace: "back", jscad: jsxRuntime.jsx(ChargingCover, {}) }), jsxRuntime.jsx(tscircuit.assembly.printedpart, { name: "REAR_HOUSING", displayName: "Qi controller enclosure", material: "petg", color: "#747a80", mountedTo: "BACKREST.charger_rear", mountFace: "front", jscad: jsxRuntime.jsx(ChargerRearHousing, {}) }), jsxRuntime.jsx(tscircuit.assembly.printedpart, { name: "LIGHT_WINDOW", displayName: "UV channel window", material: "petg", color: "#d9dce2", mountedTo: "LID.light", mountFace: "bottom", jscad: jsxRuntime.jsx(PowerLens, {}) }), jsxRuntime.jsx(tscircuit.assembly.printedpart, { name: "CHARGE_WINDOW", displayName: "IR channel window", material: "petg", color: "#d9dce2", mountedTo: "LID.light", mountFace: "bottom", jscad: jsxRuntime.jsx(ChargeLens, {}) }), jsxRuntime.jsx(tscircuit.assembly.printedpart, { name: "REAR_SUPPORT", mountedTo: "LID.support", mountFace: "bottom", displayName: "Rounded central rear support", material: "petg", color: "#747a80", jscad: jsxRuntime.jsx(RearSupport, {}) }), jsxRuntime.jsx(tscircuit.assembly.printedpart, { name: "USB_BEZEL", displayName: "USB-C input surround", material: "petg", color: "#15191d", mountedTo: "BASE.lid", mountFace: "datum", jscad: jsxRuntime.jsx(UsbBezel, {}) }), jsxRuntime.jsx(LightingBoard, {}), jsxRuntime.jsx(tscircuit.assembly.part, { name: "INDICATOR_MODULE", displayName: "C540985 UV and C540986 IR emitter board", cadModel: { jscad: indicatorModule, positionOffset: assemblyOrigin } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "STATUS_LEAD", displayName: "Qi LED_A and ground to PCB status input", cadModel: { jscad: statusHarness, positionOffset: assemblyOrigin } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "INDICATOR_LEAD", displayName: "Four-wire PCB to front indicators", cadModel: { jscad: panelHarness, positionOffset: assemblyOrigin } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "COIL_LEADS", displayName: "Short matched transmitter-to-coil pair", cadModel: { jscad: coilHarness, positionOffset: chargerPosition, rotationOffset: chargerRotation } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "USB_PD_MODULE", displayName: "Adafruit HUSB238 USB-C PD module / 5V 3A", cadModel: { jscad: pdModule, positionOffset: assemblyOrigin } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "QI_CONTROLLER", displayName: "Seeed BQ500211 Qi transmitter v1, LED mode 4", cadModel: {
                    jscad: qiController,
                    positionOffset: chargerPosition,
                    rotationOffset: chargerRotation,
                } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "QI_COIL", displayName: "Supplied Qi coil and ferrite plate", cadModel: {
                    jscad: qiPlate,
                    positionOffset: chargerPosition,
                    rotationOffset: chargerRotation,
                } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "MAGNET_RING", displayName: "58mm magnetic phone-alignment ring", cadModel: {
                    jscad: magneticRing,
                    positionOffset: chargerPosition,
                    rotationOffset: chargerRotation,
                } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "FEET", displayName: "Four rubber feet", cadModel: { jscad: rubberFeet, positionOffset: assemblyOrigin } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "STAND_SCREWS", displayName: "Four M3 stand screws", cadModel: { jscad: standScrews, positionOffset: assemblyOrigin } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "SUPPORT_SCREWS", displayName: "Rear support foot screws", cadModel: { jscad: supportScrews, positionOffset: assemblyOrigin } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "LID_SCREWS", displayName: "Four M2 lid screws", cadModel: { jscad: lidScrews, positionOffset: assemblyOrigin } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "COVER_SCREWS", displayName: "Two M3 charging-cover screws", cadModel: {
                    jscad: coverScrews,
                    positionOffset: chargerPosition,
                    rotationOffset: chargerRotation,
                } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "CHARGER_POWER_LEAD", displayName: "5V power lead with micro-USB plug", cadModel: { jscad: chargingHarness, positionOffset: assemblyOrigin } }), jsxRuntime.jsx(tscircuit.assembly.part, { name: "SUPPLY_LEAD", displayName: "PD-module output wiring", cadModel: { jscad: supplyHarness, positionOffset: assemblyOrigin } })] }));
}

module.exports = DeskGlowChargingStand;