

// =====================================================================
// GRUNDBAUTEILE
// =====================================================================

window.ComponentRegistry.register('widerstand', {
    folder: 'elektronik', title: 'Widerstand', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="50" y="45" width="20" height="70" fill="none" stroke="black" stroke-width="2"/>
            <line x1="60" y1="20" x2="60" y2="45" stroke="black" stroke-width="2"/>
            <line x1="60" y1="115" x2="60" y2="140" stroke="black" stroke-width="2"/>
            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
            <text x="75" y="85" font-size="12" font-family="Arial">R</text>
        </svg>
    `
});

window.ComponentRegistry.register('poti', {
    folder: 'elektronik', title: 'Potentiometer', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="50" y="45" width="20" height="70" fill="none" stroke="black" stroke-width="2"/>
            <line x1="60" y1="20" x2="60" y2="45" stroke="black" stroke-width="2"/>
            <line x1="60" y1="115" x2="60" y2="140" stroke="black" stroke-width="2"/>
            <!-- Pfeil für Schleifer -->
            <polyline points="20,80 45,80" fill="none" stroke="black" stroke-width="2"/>
            <polygon points="45,80 38,76 38,84" fill="black" stroke="black" stroke-width="2"/>
            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
            <circle cx="20" cy="80" r="4" fill="red" class="port"/>
        </svg>
    `
});

window.ComponentRegistry.register('ldr', {
    folder: 'elektronik', title: 'LDR (Fotowiderstand)', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="50" y="55" width="20" height="50" fill="none" stroke="black" stroke-width="2"/>
            <circle cx="60" cy="80" r="35" fill="none" stroke="black" stroke-width="1.5"/>
            <line x1="60" y1="20" x2="60" y2="55" stroke="black" stroke-width="2"/>
            <line x1="60" y1="105" x2="60" y2="140" stroke="black" stroke-width="2"/>
            <!-- Licht-Pfeile (einfallend) -->
            <polyline points="25,50 40,65" fill="none" stroke="black" stroke-width="1.5"/>
            <polygon points="40,65 34,63 38,59" fill="black"/>
            <polyline points="35,40 50,55" fill="none" stroke="black" stroke-width="1.5"/>
            <polygon points="50,55 44,53 48,49" fill="black"/>
            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
        </svg>
    `
});

window.ComponentRegistry.register('kondensator', {
    folder: 'elektronik', title: 'Kondensator', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <line x1="60" y1="20" x2="60" y2="70" stroke="black" stroke-width="2"/>
            <line x1="40" y1="70" x2="80" y2="70" stroke="black" stroke-width="3"/>
            <line x1="40" y1="90" x2="80" y2="90" stroke="black" stroke-width="3"/>
            <line x1="60" y1="90" x2="60" y2="140" stroke="black" stroke-width="2"/>
            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
            <text x="75" y="85" font-size="12" font-family="Arial">C</text>
        </svg>
    `
});

window.ComponentRegistry.register('diode', {
    folder: 'elektronik', title: 'Diode', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <line x1="60" y1="20" x2="60" y2="60" stroke="black" stroke-width="2"/>
            <polygon points="45,60 75,60 60,90" fill="none" stroke="black" stroke-width="2"/>
            <line x1="45" y1="90" x2="75" y2="90" stroke="black" stroke-width="3"/>
            <line x1="60" y1="90" x2="60" y2="140" stroke="black" stroke-width="2"/>
            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
        </svg>
    `
});

window.ComponentRegistry.register('led_elektronik', {
    folder: 'elektronik', title: 'LED', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <line x1="60" y1="20" x2="60" y2="60" stroke="black" stroke-width="2"/>
            <polygon points="45,60 75,60 60,90" fill="none" stroke="black" stroke-width="2"/>
            <line x1="45" y1="90" x2="75" y2="90" stroke="black" stroke-width="3"/>
            <line x1="60" y1="90" x2="60" y2="140" stroke="black" stroke-width="2"/>
            <!-- Licht-Pfeile (ausgehend) -->
            <polyline points="75,70 90,55" fill="none" stroke="black" stroke-width="1.5"/>
            <polygon points="90,55 84,57 88,61" fill="black"/>
            <polyline points="85,80 100,65" fill="none" stroke="black" stroke-width="1.5"/>
            <polygon points="100,65 94,67 98,71" fill="black"/>
            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
        </svg>
    `
});

// =====================================================================
// TRANSISTOREN & THYRISTOREN
// =====================================================================

window.ComponentRegistry.register('npn_transistor', {
    folder: 'elektronik', title: 'NPN Transistor', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <circle cx="60" cy="80" r="35" fill="none" stroke="black" stroke-width="1.5"/>
            <!-- Basis -->
            <line x1="20" y1="80" x2="45" y2="80" stroke="black" stroke-width="2"/>
            <line x1="45" y1="60" x2="45" y2="100" stroke="black" stroke-width="3"/>
            <!-- Kollektor -->
            <polyline points="60,20 60,55 45,70" fill="none" stroke="black" stroke-width="2"/>
            <!-- Emitter (mit Pfeil raus) -->
            <polyline points="45,90 60,105 60,140" fill="none" stroke="black" stroke-width="2"/>
            <polygon points="60,105 53,101 57,97" fill="black" stroke="black" stroke-width="1"/>
            
            <circle cx="20" cy="80" r="4" fill="red" class="port"/>
            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
            <text x="15" y="70" font-size="10" font-family="Arial">B</text>
            <text x="65" y="35" font-size="10" font-family="Arial">C</text>
            <text x="65" y="135" font-size="10" font-family="Arial">E</text>
        </svg>
    `
});

window.ComponentRegistry.register('pnp_transistor', {
    folder: 'elektronik', title: 'PNP Transistor', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <circle cx="60" cy="80" r="35" fill="none" stroke="black" stroke-width="1.5"/>
            <!-- Basis -->
            <line x1="20" y1="80" x2="45" y2="80" stroke="black" stroke-width="2"/>
            <line x1="45" y1="60" x2="45" y2="100" stroke="black" stroke-width="3"/>
            <!-- Emitter oben (mit Pfeil rein) -->
            <polyline points="60,20 60,55 45,70" fill="none" stroke="black" stroke-width="2"/>
            <polygon points="45,70 52,74 48,78" fill="black" stroke="black" stroke-width="1"/>
            <!-- Kollektor unten -->
            <polyline points="45,90 60,105 60,140" fill="none" stroke="black" stroke-width="2"/>
            
            <circle cx="20" cy="80" r="4" fill="red" class="port"/>
            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
            <text x="15" y="70" font-size="10" font-family="Arial">B</text>
            <text x="65" y="35" font-size="10" font-family="Arial">E</text>
            <text x="65" y="135" font-size="10" font-family="Arial">C</text>
        </svg>
    `
});

window.ComponentRegistry.register('triac', {
    folder: 'elektronik', title: 'TRIAC', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <line x1="60" y1="20" x2="60" y2="55" stroke="black" stroke-width="2"/>
            <line x1="60" y1="105" x2="60" y2="140" stroke="black" stroke-width="2"/>
            <!-- Dioden antiparallel -->
            <polygon points="45,55 75,55 60,80" fill="none" stroke="black" stroke-width="2"/>
            <polygon points="45,105 75,105 60,80" fill="none" stroke="black" stroke-width="2"/>
            <line x1="45" y1="80" x2="75" y2="80" stroke="black" stroke-width="2"/>
            <!-- Gate -->
            <polyline points="45,90 20,90 20,110" fill="none" stroke="black" stroke-width="2"/>
            
            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
            <circle cx="20" cy="110" r="4" fill="red" class="port"/>
            <text x="65" y="35" font-size="9" font-family="Arial">A1</text>
            <text x="65" y="135" font-size="9" font-family="Arial">A2</text>
            <text x="25" y="108" font-size="9" font-family="Arial">G</text>
        </svg>
    `
});

window.ComponentRegistry.register('diac', {
    folder: 'elektronik', title: 'DIAC', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <line x1="60" y1="20" x2="60" y2="55" stroke="black" stroke-width="2"/>
            <line x1="60" y1="105" x2="60" y2="140" stroke="black" stroke-width="2"/>
            <!-- Dioden antiparallel -->
            <polygon points="45,55 75,55 60,80" fill="none" stroke="black" stroke-width="2"/>
            <polygon points="45,105 75,105 60,80" fill="none" stroke="black" stroke-width="2"/>
            <line x1="45" y1="80" x2="75" y2="80" stroke="black" stroke-width="2"/>
            
            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
        </svg>
    `
});

// =====================================================================
// ICs & LEERFELDER (4, 6, 8, 10 Anschlüsse)
// =====================================================================

window.ComponentRegistry.register('leerfeld_4', {
    folder: 'elektronik', title: 'IC / Leerfeld (4 Pins)', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="30" y="40" width="60" height="80" fill="none" stroke="black" stroke-width="2"/>
            <line x1="10" y1="60" x2="30" y2="60" stroke="black" stroke-width="2"/>
            <line x1="10" y1="100" x2="30" y2="100" stroke="black" stroke-width="2"/>
            <line x1="110" y1="60" x2="90" y2="60" stroke="black" stroke-width="2"/>
            <line x1="110" y1="100" x2="90" y2="100" stroke="black" stroke-width="2"/>
            <circle cx="10" cy="60" r="4" fill="red" class="port"/><text x="35" y="64" font-size="9" font-family="Arial">1</text>
            <circle cx="10" cy="100" r="4" fill="red" class="port"/><text x="35" y="104" font-size="9" font-family="Arial">2</text>
            <circle cx="110" cy="60" r="4" fill="red" class="port"/><text x="78" y="64" font-size="9" font-family="Arial">4</text>
            <circle cx="110" cy="100" r="4" fill="red" class="port"/><text x="78" y="104" font-size="9" font-family="Arial">3</text>
        </svg>
    `
});

window.ComponentRegistry.register('leerfeld_6', {
    folder: 'elektronik', title: 'IC / Leerfeld (6 Pins)', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="30" y="30" width="60" height="100" fill="none" stroke="black" stroke-width="2"/>
            <line x1="10" y1="50" x2="30" y2="50" stroke="black" stroke-width="2"/><circle cx="10" cy="50" r="4" fill="red" class="port"/>
            <line x1="10" y1="80" x2="30" y2="80" stroke="black" stroke-width="2"/><circle cx="10" cy="80" r="4" fill="red" class="port"/>
            <line x1="10" y1="110" x2="30" y2="110" stroke="black" stroke-width="2"/><circle cx="10" cy="110" r="4" fill="red" class="port"/>
            
            <line x1="110" y1="50" x2="90" y2="50" stroke="black" stroke-width="2"/><circle cx="110" cy="50" r="4" fill="red" class="port"/>
            <line x1="110" y1="80" x2="90" y2="80" stroke="black" stroke-width="2"/><circle cx="110" cy="80" r="4" fill="red" class="port"/>
            <line x1="110" y1="110" x2="90" y2="110" stroke="black" stroke-width="2"/><circle cx="110" cy="110" r="4" fill="red" class="port"/>
        </svg>
    `
});

window.ComponentRegistry.register('leerfeld_8', {
    folder: 'elektronik', title: 'IC / Leerfeld (8 Pins)', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="30" y="20" width="60" height="120" fill="none" stroke="black" stroke-width="2"/>
            <line x1="10" y1="40" x2="30" y2="40" stroke="black" stroke-width="2"/><circle cx="10" cy="40" r="4" fill="red" class="port"/>
            <line x1="10" y1="66" x2="30" y2="66" stroke="black" stroke-width="2"/><circle cx="10" cy="66" r="4" fill="red" class="port"/>
            <line x1="10" y1="93" x2="30" y2="93" stroke="black" stroke-width="2"/><circle cx="10" cy="93" r="4" fill="red" class="port"/>
            <line x1="10" y1="120" x2="30" y2="120" stroke="black" stroke-width="2"/><circle cx="10" cy="120" r="4" fill="red" class="port"/>
            
            <line x1="110" y1="40" x2="90" y2="40" stroke="black" stroke-width="2"/><circle cx="110" cy="40" r="4" fill="red" class="port"/>
            <line x1="110" y1="66" x2="90" y2="66" stroke="black" stroke-width="2"/><circle cx="110" cy="66" r="4" fill="red" class="port"/>
            <line x1="110" y1="93" x2="90" y2="93" stroke="black" stroke-width="2"/><circle cx="110" cy="93" r="4" fill="red" class="port"/>
            <line x1="110" y1="120" x2="90" y2="120" stroke="black" stroke-width="2"/><circle cx="110" cy="120" r="4" fill="red" class="port"/>
        </svg>
    `
});

window.ComponentRegistry.register('leerfeld_10', {
    folder: 'elektronik', title: 'IC / Leerfeld (10 Pins)', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="30" y="10" width="60" height="140" fill="none" stroke="black" stroke-width="2"/>
            <line x1="10" y1="30" x2="30" y2="30" stroke="black" stroke-width="2"/><circle cx="10" cy="30" r="4" fill="red" class="port"/>
            <line x1="10" y1="55" x2="30" y2="55" stroke="black" stroke-width="2"/><circle cx="10" cy="55" r="4" fill="red" class="port"/>
            <line x1="10" y1="80" x2="30" y2="80" stroke="black" stroke-width="2"/><circle cx="10" cy="80" r="4" fill="red" class="port"/>
            <line x1="10" y1="105" x2="30" y2="105" stroke="black" stroke-width="2"/><circle cx="10" cy="105" r="4" fill="red" class="port"/>
            <line x1="10" y1="130" x2="30" y2="130" stroke="black" stroke-width="2"/><circle cx="10" cy="130" r="4" fill="red" class="port"/>
            
            <line x1="110" y1="30" x2="90" y2="30" stroke="black" stroke-width="2"/><circle cx="110" cy="30" r="4" fill="red" class="port"/>
            <line x1="110" y1="55" x2="90" y2="55" stroke="black" stroke-width="2"/><circle cx="110" cy="55" r="4" fill="red" class="port"/>
            <line x1="110" y1="80" x2="90" y2="80" stroke="black" stroke-width="2"/><circle cx="110" cy="80" r="4" fill="red" class="port"/>
            <line x1="110" y1="105" x2="90" y2="105" stroke="black" stroke-width="2"/><circle cx="110" cy="105" r="4" fill="red" class="port"/>
            <line x1="110" y1="130" x2="90" y2="130" stroke="black" stroke-width="2"/><circle cx="110" cy="130" r="4" fill="red" class="port"/>
        </svg>
    `
});

// =====================================================================
// ARDUINO BOARDS
// =====================================================================

// =====================================================================
// ARDUINO BOARDS (Aktualisierte Pin-Belegungen)
// =====================================================================

window.ComponentRegistry.register('arduino_uno', {
    folder: 'elektronik', title: 'Arduino Uno', defaultData: {},
    svg: `
        <svg viewBox="0 0 140 180" class="symbol">
            <rect x="30" y="10" width="80" height="160" fill="#f8f9fa" stroke="#00979d" stroke-width="2"/>
            <text x="70" y="95" font-size="14" font-weight="bold" font-family="Arial" fill="#00979d" text-anchor="middle" transform="rotate(-90 70,95)">UNO</text>
            
            <!-- Power & Analog (Links) -->
            <line x1="10" y1="25" x2="30" y2="25" stroke="black" stroke-width="2"/><circle cx="10" cy="25" r="4" fill="red" class="port"/><text x="34" y="28" font-size="7" font-family="Arial">VIN</text>
            <line x1="10" y1="40" x2="30" y2="40" stroke="black" stroke-width="2"/><circle cx="10" cy="40" r="4" fill="red" class="port"/><text x="34" y="43" font-size="7" font-family="Arial">5V</text>
            <line x1="10" y1="55" x2="30" y2="55" stroke="black" stroke-width="2"/><circle cx="10" cy="55" r="4" fill="red" class="port"/><text x="34" y="58" font-size="7" font-family="Arial">3.3V</text>
            <line x1="10" y1="70" x2="30" y2="70" stroke="black" stroke-width="2"/><circle cx="10" cy="70" r="4" fill="red" class="port"/><text x="34" y="73" font-size="7" font-family="Arial">GND</text>
            <line x1="10" y1="85" x2="30" y2="85" stroke="black" stroke-width="2"/><circle cx="10" cy="85" r="4" fill="red" class="port"/><text x="34" y="88" font-size="7" font-family="Arial">A0</text>
            <line x1="10" y1="100" x2="30" y2="100" stroke="black" stroke-width="2"/><circle cx="10" cy="100" r="4" fill="red" class="port"/><text x="34" y="103" font-size="7" font-family="Arial">A1</text>
            <line x1="10" y1="115" x2="30" y2="115" stroke="black" stroke-width="2"/><circle cx="10" cy="115" r="4" fill="red" class="port"/><text x="34" y="118" font-size="7" font-family="Arial">A2</text>
            <line x1="10" y1="130" x2="30" y2="130" stroke="black" stroke-width="2"/><circle cx="10" cy="130" r="4" fill="red" class="port"/><text x="34" y="133" font-size="7" font-family="Arial">A3</text>
            <line x1="10" y1="145" x2="30" y2="145" stroke="black" stroke-width="2"/><circle cx="10" cy="145" r="4" fill="red" class="port"/><text x="34" y="148" font-size="7" font-family="Arial">A4</text>
            <line x1="10" y1="160" x2="30" y2="160" stroke="black" stroke-width="2"/><circle cx="10" cy="160" r="4" fill="red" class="port"/><text x="34" y="163" font-size="7" font-family="Arial">A5</text>
            
            <!-- Digital D0 - D13 (Rechts) -->
            <line x1="130" y1="20" x2="110" y2="20" stroke="black" stroke-width="2"/><circle cx="130" cy="20" r="4" fill="red" class="port"/><text x="92" y="23" font-size="7" font-family="Arial">D0</text>
            <line x1="130" y1="31" x2="110" y2="31" stroke="black" stroke-width="2"/><circle cx="130" cy="31" r="4" fill="red" class="port"/><text x="92" y="34" font-size="7" font-family="Arial">D1</text>
            <line x1="130" y1="42" x2="110" y2="42" stroke="black" stroke-width="2"/><circle cx="130" cy="42" r="4" fill="red" class="port"/><text x="92" y="45" font-size="7" font-family="Arial">D2</text>
            <line x1="130" y1="53" x2="110" y2="53" stroke="black" stroke-width="2"/><circle cx="130" cy="53" r="4" fill="red" class="port"/><text x="92" y="56" font-size="7" font-family="Arial">D3</text>
            <line x1="130" y1="64" x2="110" y2="64" stroke="black" stroke-width="2"/><circle cx="130" cy="64" r="4" fill="red" class="port"/><text x="92" y="67" font-size="7" font-family="Arial">D4</text>
            <line x1="130" y1="75" x2="110" y2="75" stroke="black" stroke-width="2"/><circle cx="130" cy="75" r="4" fill="red" class="port"/><text x="92" y="78" font-size="7" font-family="Arial">D5</text>
            <line x1="130" y1="86" x2="110" y2="86" stroke="black" stroke-width="2"/><circle cx="130" cy="86" r="4" fill="red" class="port"/><text x="92" y="89" font-size="7" font-family="Arial">D6</text>
            <line x1="130" y1="97" x2="110" y2="97" stroke="black" stroke-width="2"/><circle cx="130" cy="97" r="4" fill="red" class="port"/><text x="92" y="100" font-size="7" font-family="Arial">D7</text>
            <line x1="130" y1="108" x2="110" y2="108" stroke="black" stroke-width="2"/><circle cx="130" cy="108" r="4" fill="red" class="port"/><text x="92" y="111" font-size="7" font-family="Arial">D8</text>
            <line x1="130" y1="119" x2="110" y2="119" stroke="black" stroke-width="2"/><circle cx="130" cy="119" r="4" fill="red" class="port"/><text x="92" y="122" font-size="7" font-family="Arial">D9</text>
            <line x1="130" y1="130" x2="110" y2="130" stroke="black" stroke-width="2"/><circle cx="130" cy="130" r="4" fill="red" class="port"/><text x="86" y="133" font-size="7" font-family="Arial">D10</text>
            <line x1="130" y1="141" x2="110" y2="141" stroke="black" stroke-width="2"/><circle cx="130" cy="141" r="4" fill="red" class="port"/><text x="86" y="144" font-size="7" font-family="Arial">D11</text>
            <line x1="130" y1="152" x2="110" y2="152" stroke="black" stroke-width="2"/><circle cx="130" cy="152" r="4" fill="red" class="port"/><text x="86" y="155" font-size="7" font-family="Arial">D12</text>
            <line x1="130" y1="163" x2="110" y2="163" stroke="black" stroke-width="2"/><circle cx="130" cy="163" r="4" fill="red" class="port"/><text x="86" y="166" font-size="7" font-family="Arial">D13</text>
        </svg>
    `
});

window.ComponentRegistry.register('arduino_r4', {
    folder: 'elektronik', title: 'Arduino R4', defaultData: {},
    svg: `
        <svg viewBox="0 0 140 180" class="symbol">
            <rect x="30" y="10" width="80" height="160" fill="#f8f9fa" stroke="#00979d" stroke-width="2"/>
            <text x="70" y="95" font-size="14" font-weight="bold" font-family="Arial" fill="#00979d" text-anchor="middle" transform="rotate(-90 70,95)">R4</text>
            
            <!-- Spezielle R4 & Power/Analog Pins (Links) -->
            <line x1="10" y1="20" x2="30" y2="20" stroke="black" stroke-width="2"/><circle cx="10" cy="20" r="4" fill="red" class="port"/><text x="34" y="23" font-size="7" font-family="Arial">VIN</text>
            <line x1="10" y1="32" x2="30" y2="32" stroke="black" stroke-width="2"/><circle cx="10" cy="32" r="4" fill="red" class="port"/><text x="34" y="35" font-size="7" font-family="Arial">5V</text>
            <line x1="10" y1="44" x2="30" y2="44" stroke="black" stroke-width="2"/><circle cx="10" cy="44" r="4" fill="red" class="port"/><text x="34" y="47" font-size="7" font-family="Arial">3.3V</text>
            <line x1="10" y1="56" x2="30" y2="56" stroke="black" stroke-width="2"/><circle cx="10" cy="56" r="4" fill="red" class="port"/><text x="34" y="59" font-size="7" font-family="Arial">OFF</text>
            <line x1="10" y1="68" x2="30" y2="68" stroke="black" stroke-width="2"/><circle cx="10" cy="68" r="4" fill="red" class="port"/><text x="34" y="71" font-size="7" font-family="Arial">GND</text>
            <line x1="10" y1="80" x2="30" y2="80" stroke="black" stroke-width="2"/><circle cx="10" cy="80" r="4" fill="red" class="port"/><text x="34" y="83" font-size="7" font-family="Arial">VRTC</text>
            <line x1="10" y1="92" x2="30" y2="92" stroke="black" stroke-width="2"/><circle cx="10" cy="92" r="4" fill="red" class="port"/><text x="34" y="95" font-size="7" font-family="Arial">A0</text>
            <line x1="10" y1="104" x2="30" y2="104" stroke="black" stroke-width="2"/><circle cx="10" cy="104" r="4" fill="red" class="port"/><text x="34" y="107" font-size="7" font-family="Arial">A1</text>
            <line x1="10" y1="116" x2="30" y2="116" stroke="black" stroke-width="2"/><circle cx="10" cy="116" r="4" fill="red" class="port"/><text x="34" y="119" font-size="7" font-family="Arial">A2</text>
            <line x1="10" y1="128" x2="30" y2="128" stroke="black" stroke-width="2"/><circle cx="10" cy="128" r="4" fill="red" class="port"/><text x="34" y="131" font-size="7" font-family="Arial">A3</text>
            <line x1="10" y1="140" x2="30" y2="140" stroke="black" stroke-width="2"/><circle cx="10" cy="140" r="4" fill="red" class="port"/><text x="34" y="143" font-size="7" font-family="Arial">A4</text>
            <line x1="10" y1="152" x2="30" y2="152" stroke="black" stroke-width="2"/><circle cx="10" cy="152" r="4" fill="red" class="port"/><text x="34" y="155" font-size="7" font-family="Arial">A5</text>
            
            <!-- Digital D0 - D13 (Rechts) -->
            <line x1="130" y1="20" x2="110" y2="20" stroke="black" stroke-width="2"/><circle cx="130" cy="20" r="4" fill="red" class="port"/><text x="92" y="23" font-size="7" font-family="Arial">D0</text>
            <line x1="130" y1="31" x2="110" y2="31" stroke="black" stroke-width="2"/><circle cx="130" cy="31" r="4" fill="red" class="port"/><text x="92" y="34" font-size="7" font-family="Arial">D1</text>
            <line x1="130" y1="42" x2="110" y2="42" stroke="black" stroke-width="2"/><circle cx="130" cy="42" r="4" fill="red" class="port"/><text x="92" y="45" font-size="7" font-family="Arial">D2</text>
            <line x1="130" y1="53" x2="110" y2="53" stroke="black" stroke-width="2"/><circle cx="130" cy="53" r="4" fill="red" class="port"/><text x="92" y="56" font-size="7" font-family="Arial">D3</text>
            <line x1="130" y1="64" x2="110" y2="64" stroke="black" stroke-width="2"/><circle cx="130" cy="64" r="4" fill="red" class="port"/><text x="92" y="67" font-size="7" font-family="Arial">D4</text>
            <line x1="130" y1="75" x2="110" y2="75" stroke="black" stroke-width="2"/><circle cx="130" cy="75" r="4" fill="red" class="port"/><text x="92" y="78" font-size="7" font-family="Arial">D5</text>
            <line x1="130" y1="86" x2="110" y2="86" stroke="black" stroke-width="2"/><circle cx="130" cy="86" r="4" fill="red" class="port"/><text x="92" y="89" font-size="7" font-family="Arial">D6</text>
            <line x1="130" y1="97" x2="110" y2="97" stroke="black" stroke-width="2"/><circle cx="130" cy="97" r="4" fill="red" class="port"/><text x="92" y="100" font-size="7" font-family="Arial">D7</text>
            <line x1="130" y1="108" x2="110" y2="108" stroke="black" stroke-width="2"/><circle cx="130" cy="108" r="4" fill="red" class="port"/><text x="92" y="111" font-size="7" font-family="Arial">D8</text>
            <line x1="130" y1="119" x2="110" y2="119" stroke="black" stroke-width="2"/><circle cx="130" cy="119" r="4" fill="red" class="port"/><text x="92" y="122" font-size="7" font-family="Arial">D9</text>
            <line x1="130" y1="130" x2="110" y2="130" stroke="black" stroke-width="2"/><circle cx="130" cy="130" r="4" fill="red" class="port"/><text x="86" y="133" font-size="7" font-family="Arial">D10</text>
            <line x1="130" y1="141" x2="110" y2="141" stroke="black" stroke-width="2"/><circle cx="130" cy="141" r="4" fill="red" class="port"/><text x="86" y="144" font-size="7" font-family="Arial">D11</text>
            <line x1="130" y1="152" x2="110" y2="152" stroke="black" stroke-width="2"/><circle cx="130" cy="152" r="4" fill="red" class="port"/><text x="86" y="155" font-size="7" font-family="Arial">D12</text>
            <line x1="130" y1="163" x2="110" y2="163" stroke="black" stroke-width="2"/><circle cx="130" cy="163" r="4" fill="red" class="port"/><text x="86" y="166" font-size="7" font-family="Arial">D13</text>
        </svg>
    `
});

window.ComponentRegistry.register('arduino_nano', {
    folder: 'elektronik', title: 'Arduino Nano', defaultData: {},
    svg: `
        <svg viewBox="0 0 140 180" class="symbol">
            <rect x="30" y="10" width="80" height="160" fill="#f8f9fa" stroke="#00979d" stroke-width="2"/>
            <text x="70" y="95" font-size="14" font-weight="bold" font-family="Arial" fill="#00979d" text-anchor="middle" transform="rotate(-90 70,95)">NANO</text>
            
            <!-- Power & Analog A0 - A7 (Links) -->
            <line x1="10" y1="25" x2="30" y2="25" stroke="black" stroke-width="2"/><circle cx="10" cy="25" r="4" fill="red" class="port"/><text x="34" y="28" font-size="7" font-family="Arial">VIN</text>
            <line x1="10" y1="40" x2="30" y2="40" stroke="black" stroke-width="2"/><circle cx="10" cy="40" r="4" fill="red" class="port"/><text x="34" y="43" font-size="7" font-family="Arial">5V</text>
            <line x1="10" y1="55" x2="30" y2="55" stroke="black" stroke-width="2"/><circle cx="10" cy="55" r="4" fill="red" class="port"/><text x="34" y="58" font-size="7" font-family="Arial">3V3</text>
            <line x1="10" y1="70" x2="30" y2="70" stroke="black" stroke-width="2"/><circle cx="10" cy="70" r="4" fill="red" class="port"/><text x="34" y="73" font-size="7" font-family="Arial">GND</text>
            <line x1="10" y1="85" x2="30" y2="85" stroke="black" stroke-width="2"/><circle cx="10" cy="85" r="4" fill="red" class="port"/><text x="34" y="88" font-size="7" font-family="Arial">A0</text>
            <line x1="10" y1="100" x2="30" y2="100" stroke="black" stroke-width="2"/><circle cx="10" cy="100" r="4" fill="red" class="port"/><text x="34" y="103" font-size="7" font-family="Arial">A1</text>
            <line x1="10" y1="115" x2="30" y2="115" stroke="black" stroke-width="2"/><circle cx="10" cy="115" r="4" fill="red" class="port"/><text x="34" y="118" font-size="7" font-family="Arial">A2</text>
            <line x1="10" y1="130" x2="30" y2="130" stroke="black" stroke-width="2"/><circle cx="10" cy="130" r="4" fill="red" class="port"/><text x="34" y="133" font-size="7" font-family="Arial">A3</text>
            <line x1="10" y1="145" x2="30" y2="145" stroke="black" stroke-width="2"/><circle cx="10" cy="145" r="4" fill="red" class="port"/><text x="34" y="148" font-size="7" font-family="Arial">A4</text>
            <line x1="10" y1="160" x2="30" y2="160" stroke="black" stroke-width="2"/><circle cx="10" cy="160" r="4" fill="red" class="port"/><text x="34" y="163" font-size="7" font-family="Arial">A5</text>
            <line x1="10" y1="172" x2="30" y2="172" stroke="black" stroke-width="2"/><circle cx="10" cy="172" r="4" fill="red" class="port"/><text x="34" y="175" font-size="7" font-family="Arial">A6</text>
            <line x1="10" y1="184" x2="30" y2="184" stroke="black" stroke-width="2"/><circle cx="10" cy="184" r="4" fill="red" class="port"/><text x="34" y="187" font-size="7" font-family="Arial">A7</text>
            
            <!-- Digital D0 - D13 (Rechts) -->
            <line x1="130" y1="20" x2="110" y2="20" stroke="black" stroke-width="2"/><circle cx="130" cy="20" r="4" fill="red" class="port"/><text x="92" y="23" font-size="7" font-family="Arial">D0</text>
            <line x1="130" y1="31" x2="110" y2="31" stroke="black" stroke-width="2"/><circle cx="130" cy="31" r="4" fill="red" class="port"/><text x="92" y="34" font-size="7" font-family="Arial">D1</text>
            <line x1="130" y1="42" x2="110" y2="42" stroke="black" stroke-width="2"/><circle cx="130" cy="42" r="4" fill="red" class="port"/><text x="92" y="45" font-size="7" font-family="Arial">D2</text>
            <line x1="130" y1="53" x2="110" y2="53" stroke="black" stroke-width="2"/><circle cx="130" cy="53" r="4" fill="red" class="port"/><text x="92" y="56" font-size="7" font-family="Arial">D3</text>
            <line x1="130" y1="64" x2="110" y2="64" stroke="black" stroke-width="2"/><circle cx="130" cy="64" r="4" fill="red" class="port"/><text x="92" y="67" font-size="7" font-family="Arial">D4</text>
            <line x1="130" y1="75" x2="110" y2="75" stroke="black" stroke-width="2"/><circle cx="130" cy="75" r="4" fill="red" class="port"/><text x="92" y="78" font-size="7" font-family="Arial">D5</text>
            <line x1="130" y1="86" x2="110" y2="86" stroke="black" stroke-width="2"/><circle cx="130" cy="86" r="4" fill="red" class="port"/><text x="92" y="89" font-size="7" font-family="Arial">D6</text>
            <line x1="130" y1="97" x2="110" y2="97" stroke="black" stroke-width="2"/><circle cx="130" cy="97" r="4" fill="red" class="port"/><text x="92" y="100" font-size="7" font-family="Arial">D7</text>
            <line x1="130" y1="108" x2="110" y2="108" stroke="black" stroke-width="2"/><circle cx="130" cy="108" r="4" fill="red" class="port"/><text x="92" y="111" font-size="7" font-family="Arial">D8</text>
            <line x1="130" y1="119" x2="110" y2="119" stroke="black" stroke-width="2"/><circle cx="130" cy="119" r="4" fill="red" class="port"/><text x="92" y="122" font-size="7" font-family="Arial">D9</text>
            <line x1="130" y1="130" x2="110" y2="130" stroke="black" stroke-width="2"/><circle cx="130" cy="130" r="4" fill="red" class="port"/><text x="86" y="133" font-size="7" font-family="Arial">D10</text>
            <line x1="130" y1="141" x2="110" y2="141" stroke="black" stroke-width="2"/><circle cx="130" cy="141" r="4" fill="red" class="port"/><text x="86" y="144" font-size="7" font-family="Arial">D11</text>
            <line x1="130" y1="152" x2="110" y2="152" stroke="black" stroke-width="2"/><circle cx="130" cy="152" r="4" fill="red" class="port"/><text x="86" y="155" font-size="7" font-family="Arial">D12</text>
            <line x1="130" y1="163" x2="110" y2="163" stroke="black" stroke-width="2"/><circle cx="130" cy="163" r="4" fill="red" class="port"/><text x="86" y="166" font-size="7" font-family="Arial">D13</text>
        </svg>
    `
});





// =====================================================================
// MODULE & STROMVERSORGUNG
// =====================================================================

window.ComponentRegistry.register('netzteil_ac_dc', {
    folder: 'elektronik', title: 'Netzteil AC/DC', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="30" y="40" width="60" height="80" fill="none" stroke="black" stroke-width="2"/>
            <!-- Diagonale Trennlinie -->
            <line x1="30" y1="120" x2="90" y2="40" stroke="black" stroke-width="1.5"/>
            <!-- Symbole -->
            <text x="45" y="65" font-size="14" font-family="Arial">~</text>
            <text x="75" y="105" font-size="14" font-family="Arial">=</text>
            
            <!-- AC Eingang -->
            <line x1="10" y1="60" x2="30" y2="60" stroke="black" stroke-width="2"/><circle cx="10" cy="60" r="4" fill="red" class="port"/><text x="15" y="55" font-size="9" font-family="Arial">L</text>
            <line x1="10" y1="100" x2="30" y2="100" stroke="black" stroke-width="2"/><circle cx="10" cy="100" r="4" fill="red" class="port"/><text x="15" y="95" font-size="9" font-family="Arial">N</text>
            
            <!-- DC Ausgang -->
            <line x1="110" y1="60" x2="90" y2="60" stroke="black" stroke-width="2"/><circle cx="110" cy="60" r="4" fill="red" class="port"/><text x="100" y="55" font-size="11" font-weight="bold" font-family="Arial">+</text>
            <line x1="110" y1="100" x2="90" y2="100" stroke="black" stroke-width="2"/><circle cx="110" cy="100" r="4" fill="red" class="port"/><text x="102" y="95" font-size="14" font-weight="bold" font-family="Arial">-</text>
        </svg>
    `
});

window.ComponentRegistry.register('relais_modul', {
    folder: 'elektronik', title: 'Relais Modul (PCB)', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="25" y="30" width="70" height="100" fill="none" stroke="black" stroke-width="2"/>
            <rect x="35" y="50" width="50" height="60" fill="none" stroke="black" stroke-width="1.5" stroke-dasharray="2,2"/>
            <text x="60" y="85" font-size="11" font-family="Arial" text-anchor="middle">RELAIS</text>
            
            <!-- Steuerung -->
            <line x1="5" y1="50" x2="25" y2="50" stroke="black" stroke-width="2"/><circle cx="5" cy="50" r="4" fill="red" class="port"/><text x="28" y="53" font-size="7" font-family="Arial">VCC</text>
            <line x1="5" y1="80" x2="25" y2="80" stroke="black" stroke-width="2"/><circle cx="5" cy="80" r="4" fill="red" class="port"/><text x="28" y="83" font-size="7" font-family="Arial">GND</text>
            <line x1="5" y1="110" x2="25" y2="110" stroke="black" stroke-width="2"/><circle cx="5" cy="110" r="4" fill="red" class="port"/><text x="28" y="113" font-size="7" font-family="Arial">IN</text>
            
            <!-- Last-Kontakte -->
            <line x1="115" y1="50" x2="95" y2="50" stroke="black" stroke-width="2"/><circle cx="115" cy="50" r="4" fill="red" class="port"/><text x="78" y="53" font-size="7" font-family="Arial">NC</text>
            <line x1="115" y1="80" x2="95" y2="80" stroke="black" stroke-width="2"/><circle cx="115" cy="80" r="4" fill="red" class="port"/><text x="73" y="83" font-size="7" font-family="Arial">COM</text>
            <line x1="115" y1="110" x2="95" y2="110" stroke="black" stroke-width="2"/><circle cx="115" cy="110" r="4" fill="red" class="port"/><text x="78" y="113" font-size="7" font-family="Arial">NO</text>
        </svg>
    `
});

window.ComponentRegistry.register('summer', {
    folder: 'elektronik', title: 'Summer (Buzzer)', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="40" y="70" width="40" height="20" fill="none" stroke="black" stroke-width="2"/>
            <path d="M 40 70 C 40 40 80 40 80 70" fill="none" stroke="black" stroke-width="2"/>
            <line x1="45" y1="90" x2="45" y2="130" stroke="black" stroke-width="2"/>
            <line x1="75" y1="90" x2="75" y2="130" stroke="black" stroke-width="2"/>
            <circle cx="45" cy="130" r="4" fill="red" class="port"/><text x="35" y="125" font-size="11" font-weight="bold" font-family="Arial">+</text>
            <circle cx="75" cy="130" r="4" fill="red" class="port"/><text x="82" y="125" font-size="14" font-weight="bold" font-family="Arial">-</text>
        </svg>
    `
});

window.ComponentRegistry.register('printklemme_2', {
    folder: 'elektronik', title: 'Printklemme 2-pol', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <rect x="30" y="40" width="60" height="40" fill="none" stroke="black" stroke-width="2"/>
            <circle cx="45" cy="60" r="6" fill="none" stroke="black" stroke-width="1.5"/><line x1="41" y1="56" x2="49" y2="64" stroke="black" stroke-width="1"/>
            <circle cx="75" cy="60" r="6" fill="none" stroke="black" stroke-width="1.5"/><line x1="71" y1="56" x2="79" y2="64" stroke="black" stroke-width="1"/>
            <line x1="45" y1="80" x2="45" y2="120" stroke="black" stroke-width="2"/><circle cx="45" cy="120" r="4" fill="red" class="port"/>
            <line x1="75" y1="80" x2="75" y2="120" stroke="black" stroke-width="2"/><circle cx="75" cy="120" r="4" fill="red" class="port"/>
        </svg>
    `
});


window.ComponentRegistry.register('batterie_zelle', {
    folder: 'elektronik', title: 'Batterie / Zelle', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <!-- + Anschluss oben (lange, dünne Linie) -->
            <line x1="60" y1="20" x2="60" y2="70" stroke="black" stroke-width="2"/>
            <line x1="40" y1="70" x2="80" y2="70" stroke="black" stroke-width="2"/>
            <text x="75" y="65" font-size="14" font-family="Arial" font-weight="bold">+</text>

            <!-- - Anschluss unten (kurze, dicke Linie) -->
            <line x1="60" y1="90" x2="60" y2="140" stroke="black" stroke-width="2"/>
            <line x1="48" y1="90" x2="72" y2="90" stroke="black" stroke-width="4"/>
            <text x="78" y="105" font-size="14" font-family="Arial" font-weight="bold">-</text>

            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
        </svg>
    `
});

window.ComponentRegistry.register('batterie_gefuellt', {
    folder: 'elektronik', title: 'Batterie (gefüllt)', defaultData: {},
    svg: `
        <svg viewBox="0 0 120 160" class="symbol">
            <!-- + Anschluss oben (lange, dünne Linie) -->
            <line x1="60" y1="20" x2="60" y2="70" stroke="black" stroke-width="2"/>
            <line x1="40" y1="70" x2="80" y2="70" stroke="black" stroke-width="2"/>
            <text x="75" y="65" font-size="14" font-family="Arial" font-weight="bold">+</text>

            <!-- - Anschluss unten (gefüllter Block) -->
            <line x1="60" y1="90" x2="60" y2="140" stroke="black" stroke-width="2"/>
            <rect x="45" y="86" width="30" height="8" fill="black" stroke="black" stroke-width="2"/>
            <text x="78" y="105" font-size="14" font-family="Arial" font-weight="bold">-</text>

            <circle cx="60" cy="20" r="4" fill="red" class="port"/>
            <circle cx="60" cy="140" r="4" fill="red" class="port"/>
        </svg>
    `
});