import type { AnyCircuitElement } from "circuit-json"
import { PinoutViewer } from "lib/components/PinoutViewer"
import { renderToCircuitJson } from "lib/dev/render-to-circuit-json"

const circuiJson: any[] = [
  {
    name: "pin1",
    type: "source_port",
    pin_number: 1,
    port_hints: ["pin1", "1", "PWR"],
    source_port_id: "source_port_0",
    source_component_id: "source_component_0",
  },
  {
    name: "pin2",
    type: "source_port",
    pin_number: 2,
    port_hints: ["pin2", "2"],
    source_port_id: "source_port_1",
    source_component_id: "source_component_0",
  },
  {
    name: "pin3",
    type: "source_port",
    pin_number: 3,
    port_hints: ["pin3", "3"],
    source_port_id: "source_port_2",
    source_component_id: "source_component_0",
  },
  {
    name: "pin4",
    type: "source_port",
    pin_number: 4,
    port_hints: ["pin4", "4"],
    source_port_id: "source_port_3",
    source_component_id: "source_component_0",
  },
  {
    name: "pin5",
    type: "source_port",
    pin_number: 5,
    port_hints: ["pin5", "5"],
    source_port_id: "source_port_4",
    source_component_id: "source_component_0",
  },
  {
    name: "pin6",
    type: "source_port",
    pin_number: 6,
    port_hints: ["pin6", "6"],
    source_port_id: "source_port_5",
    source_component_id: "source_component_0",
  },
  {
    name: "pin7",
    type: "source_port",
    pin_number: 7,
    port_hints: ["pin7", "7"],
    source_port_id: "source_port_6",
    source_component_id: "source_component_0",
  },
  {
    name: "pin8",
    type: "source_port",
    pin_number: 8,
    port_hints: ["pin8", "8", "GND"],
    source_port_id: "source_port_7",
    source_component_id: "source_component_0",
  },
  {
    name: "U1",
    type: "source_component",
    ftype: "simple_chip",
    source_component_id: "source_component_0",
  },
  {
    name: "pin1",
    type: "source_port",
    pin_number: 1,
    port_hints: ["-", "left", "pin1", "1"],
    source_port_id: "source_port_8",
    source_component_id: "source_component_1",
  },
  {
    name: "pin2",
    type: "source_port",
    pin_number: 2,
    port_hints: ["+", "right", "pin2", "2"],
    source_port_id: "source_port_9",
    source_component_id: "source_component_1",
  },
  {
    name: "R1",
    type: "source_component",
    ftype: "simple_resistor",
    resistance: 100000,
    source_component_id: "source_component_1",
  },
  {
    name: "pin1",
    type: "source_port",
    pin_number: 1,
    port_hints: ["left", "pin1", "1"],
    source_port_id: "source_port_10",
    source_component_id: "source_component_2",
  },
  {
    name: "pin2",
    type: "source_port",
    pin_number: 2,
    port_hints: ["right", "pin2", "2"],
    source_port_id: "source_port_11",
    source_component_id: "source_component_2",
  },
  {
    name: "C1",
    type: "source_component",
    ftype: "simple_capacitor",
    source_component_id: "source_component_2",
  },
  {
    name: "pin1",
    type: "source_port",
    pin_number: 1,
    port_hints: ["pin1", "1"],
    source_port_id: "source_port_12",
    source_component_id: "source_component_3",
  },
  {
    name: "pin2",
    type: "source_port",
    pin_number: 2,
    port_hints: ["pin2", "2"],
    source_port_id: "source_port_13",
    source_component_id: "source_component_3",
  },
  {
    name: "pin3",
    type: "source_port",
    pin_number: 3,
    port_hints: ["pin3", "3"],
    source_port_id: "source_port_14",
    source_component_id: "source_component_3",
  },
  {
    name: "pin4",
    type: "source_port",
    pin_number: 4,
    port_hints: ["pin4", "4"],
    source_port_id: "source_port_15",
    source_component_id: "source_component_3",
  },
  {
    name: "J1",
    type: "source_component",
    ftype: "simple_chip",
    source_component_id: "source_component_3",
  },
  {
    type: "pcb_component",
    layer: "top",
    width: 5.2,
    center: {
      x: 0,
      y: 0,
    },
    height: 5,
    rotation: 0,
    pcb_component_id: "pcb_component_0",
    source_component_id: "source_component_0",
  },
  {
    type: "pcb_component",
    layer: "top",
    width: 2,
    center: {
      x: 0,
      y: -4,
    },
    height: 8.6,
    rotation: 90,
    pcb_component_id: "pcb_component_3",
    source_component_id: "source_component_3",
  },
  {
    type: "pcb_board",
    width: 10,
    outline: [
      { x: -10, y: -10 },
      { x: 10, y: -10 },
      { x: 10, y: 10 },
      { x: 3, y: 3 },
      { x: -7, y: 3 },
      { x: -7, y: -7 },
    ],
    center: {
      x: 0,
      y: 0,
    },
    height: 10,
    pcb_board_id: "pcb_board_0",
  },
  {
    x: -2.15,
    y: 1.905,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_0",
    source_port_id: "source_port_0",
    pcb_component_id: "pcb_component_0",
    is_board_pinout: true,
  },
  {
    x: -2.15,
    y: 0.635,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_1",
    source_port_id: "source_port_1",
    pcb_component_id: "pcb_component_0",
  },
  {
    x: -2.15,
    y: -0.635,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_2",
    source_port_id: "source_port_2",
    pcb_component_id: "pcb_component_0",
  },
  {
    x: -2.15,
    y: -1.905,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_3",
    source_port_id: "source_port_3",
    pcb_component_id: "pcb_component_0",
  },
  {
    x: 2.15,
    y: -1.905,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_4",
    source_port_id: "source_port_4",
    pcb_component_id: "pcb_component_0",
  },
  {
    x: 2.15,
    y: -0.635,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_5",
    source_port_id: "source_port_5",
    pcb_component_id: "pcb_component_0",
  },
  {
    x: 2.15,
    y: 0.635,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_6",
    source_port_id: "source_port_6",
    pcb_component_id: "pcb_component_0",
  },
  {
    x: 2.15,
    y: 1.905,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_7",
    source_port_id: "source_port_7",
    pcb_component_id: "pcb_component_0",
    is_board_pinout: true,
  },
  {
    x: -3.8099998780800037,
    y: -4,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_12",
    source_port_id: "source_port_12",
    pcb_component_id: "pcb_component_3",
    is_board_pinout: true,
  },
  {
    x: -1.269999959360001,
    y: -4,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_13",
    source_port_id: "source_port_13",
    pcb_component_id: "pcb_component_3",
  },
  {
    x: 1.2699999593600015,
    y: -4,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_14",
    source_port_id: "source_port_14",
    pcb_component_id: "pcb_component_3",
  },
  {
    x: 3.8099998780800037,
    y: -4,
    type: "pcb_port",
    layers: ["top"],
    pcb_port_id: "pcb_port_15",
    source_port_id: "source_port_15",
    pcb_component_id: "pcb_component_3",
    is_board_pinout: true,
  },
  {
    type: "pcb_smtpad",
    shape: "rect",
    x: -2.15,
    y: 1.905,
    width: 0.6,
    height: 1,
    layer: "top",
    pcb_port_id: "pcb_port_0",
  },
  {
    type: "pcb_smtpad",
    shape: "rect",
    x: 2.15,
    y: 1.905,
    width: 0.6,
    height: 1,
    layer: "top",
    pcb_port_id: "pcb_port_7",
  },
  {
    type: "pcb_plated_hole",
    shape: "circle",
    x: -3.8099998780800037,
    y: -4,
    hole_diameter: 0.6,
    outer_diameter: 1,
    pcb_port_id: "pcb_port_12",
  },
  {
    type: "pcb_plated_hole",
    shape: "circle",
    x: 3.8099998780800037,
    y: -4,
    hole_diameter: 0.6,
    outer_diameter: 1,
    pcb_port_id: "pcb_port_15",
  },
]

export default () => (
  <PinoutViewer
    circuitJson={circuiJson}
    editingEnabled
    containerStyle={{ height: "100%" }}
    debugGrid
    debug
  />
)
