// KHPP Main App

const { useState, useMemo, useEffect, useRef } = React;

// === PALETTES ===
const PALETTES = {
  paper: {
    name: "Paper Topo",
    paper: "#f0e9d8",
    paperDeep: "#e6dcc4",
    ink: "#2b2820",
    inkSoft: "#4a4538",
    land: "#e6dcc4",
    contour: "#a8956a",
    contourDark: "#6b5a3a",
    water: "#a8b8c4",
    accent: "#a23b2a",
    accentSoft: "#c97a4a",
    summited: "#a23b2a",
    planned: "#6b5a3a",
  },
  forest: {
    name: "Forest & Stone",
    paper: "#ece4d2",
    paperDeep: "#dccfb4",
    ink: "#1f2a22",
    inkSoft: "#3d4a3f",
    land: "#d8cdb0",
    contour: "#7a8a6a",
    contourDark: "#3d4a3f",
    water: "#8aa0a8",
    accent: "#8b3a26",
    accentSoft: "#b76a44",
    summited: "#8b3a26",
    planned: "#3d4a3f",
  },
  glacier: {
    name: "Cool Alpine",
    paper: "#e8ecef",
    paperDeep: "#d2dae0",
    ink: "#1a2530",
    inkSoft: "#3a4a58",
    land: "#d2dae0",
    contour: "#7a8a98",
    contourDark: "#3a4a58",
    water: "#9ab4c4",
    accent: "#b04a32",
    accentSoft: "#d27a5a",
    summited: "#b04a32",
    planned: "#3a4a58",
  },
};

// === DEFAULTS ===
const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "palette": "paper",
  "mapStyle": "contours",
  "panelLayout": "side",
  "showCoordinates": true,
  "showGrid": true
}/*EDITMODE-END*/;

// === HEADER ===
function Header({ activeTab, onTab, summited, total }) {
  return (
    <header className="khpp-header">
      <div className="header-left">
        <div className="wordmark">
          <span className="wm-mono">KHPP</span>
          <span className="wm-divider">·</span>
          <span className="wm-name">Kantonale Hoheste Punkte Projekt</span>
        </div>
        <div className="counter-badge">
          <span className="counter-num">{summited}</span>
          <span className="counter-divider">/</span>
          <span className="counter-total">{total}</span>
          <span className="counter-label">cantons summited</span>
        </div>
      </div>
      <nav className="khpp-nav">
        {[
          { id: "map", label: "Map" },
          { id: "blog", label: "Field Notes" },
          { id: "about", label: "About" },
        ].map((t) => (
          <button
            key={t.id}
            className={`nav-btn ${activeTab === t.id ? "active" : ""}`}
            onClick={() => onTab(t.id)}
          >
            {t.label}
          </button>
        ))}
      </nav>
    </header>
  );
}

// === MAP VIEW ===
function MapView({ peaks, selected, onSelect, hovered, onHover, paletteObj, mapStyle, panelLayout, showGrid }) {
  return (
    <div className={`map-view layout-${panelLayout}`}>
      <div className="map-canvas-wrap">
        <div className="map-corners">
          <div className="corner tl">N 47°48'</div>
          <div className="corner tr">E 10°29'</div>
          <div className="corner bl">N 45°49'</div>
          <div className="corner br">E 5°57'</div>
        </div>
        <window.SwissMap
          peaks={peaks}
          selected={selected}
          hovered={hovered}
          onSelect={onSelect}
          onHover={onHover}
          paletteObj={paletteObj}
          mapStyle={mapStyle}
          showGrid={showGrid}
        />
        <div className="map-legend">
          <div className="legend-title">LEGEND</div>
          <div className="legend-row">
            <svg width="14" height="14" viewBox="-3 -3 6 6">
              <polygon points="0,-1.4 1.2,0.8 -1.2,0.8" fill={paletteObj.summited} stroke={paletteObj.summited} strokeWidth="0.15" />
              <circle r="0.3" cx="0" cy="0.1" fill={paletteObj.paper} />
            </svg>
            <span>Summited</span>
          </div>
          <div className="legend-row">
            <svg width="14" height="14" viewBox="-3 -3 6 6">
              <polygon points="0,-1.4 1.2,0.8 -1.2,0.8" fill={paletteObj.paper} stroke={paletteObj.planned} strokeWidth="0.3" />
            </svg>
            <span>Planned</span>
          </div>
        </div>
      </div>

      {/* Detail Panel */}
      <DetailPanel peak={selected} onClose={() => onSelect(null)} paletteObj={paletteObj} layout={panelLayout} />
    </div>
  );
}

// === DETAIL PANEL ===
function DetailPanel({ peak, onClose, paletteObj, layout }) {
  const [showBlog, setShowBlog] = useState(false);
  const [postContent, setPostContent] = useState(null);
  const [gpxData, setGpxData] = useState(null);
  const [images, setImages] = useState([]);

  useEffect(() => {
    setShowBlog(false);
    setPostContent(null);
    setGpxData(null);
    setImages([]);

    if (peak) {
      const code = peak.cantonCode.toLowerCase();
      // Fetch post
      fetch(`data/peaks/${code}/post.md`)
        .then(res => {
          if (res.ok) return res.text();
          throw new Error("No post");
        })
        .then(text => setPostContent(text))
        .catch(() => setPostContent(null));

      // Fetch GPX
      fetch(`data/peaks/${code}/route.gpx`)
        .then(res => {
          if (res.ok) return res.text();
          throw new Error("No GPX");
        })
        .then(xml => {
          if(window.parseGPX) {
            setGpxData(window.parseGPX(xml));
          }
        })
        .catch(() => setGpxData(null));

      // Fetch images
      fetch(`data/peaks/${code}/images.json`)
        .then(res => {
          if (res.ok) return res.json();
          throw new Error("No images manifest");
        })
        .then(data => setImages(data))
        .catch(() => setImages([]));
    }
  }, [peak?.id]);

  if (!peak) {
    return (
      <aside className={`detail-panel empty layout-${layout}`}>
        <div className="empty-card">
          <div className="empty-icon">
            <svg viewBox="0 0 40 40" width="36" height="36">
              <polygon points="20,8 30,28 10,28" fill="none" stroke={paletteObj.inkSoft} strokeWidth="1.2" />
              <polygon points="20,12 27,26 13,26" fill="none" stroke={paletteObj.inkSoft} strokeWidth="0.8" opacity="0.5" />
            </svg>
          </div>
          <h3 className="empty-title">Select a peak</h3>
          <p className="empty-body">
            Click any marker on the map to see route, stats, and field notes. Filled triangles are summited; outlined are still on the list.
          </p>
        </div>
      </aside>
    );
  }

  const isSummited = peak.status === "summited";
  const hasRoute = !!gpxData;
  const hasPost = !!postContent;

  return (
    <aside className={`detail-panel layout-${layout}`}>
      <button className="panel-close" onClick={onClose} aria-label="Close">×</button>

      <div className="panel-header">
        <div className="panel-canton-row">
          <div className="canton-code-large">{peak.cantonCode}</div>
          <div>
            <div className="panel-canton">{peak.canton}</div>
            <div className={`panel-status ${isSummited ? "summited" : "planned"}`}>
              {isSummited ? "● SUMMITED" : "○ PLANNED"}
            </div>
          </div>
        </div>
        <h2 className="panel-name">{peak.name}</h2>
        <div className="panel-range">{peak.range}</div>
      </div>

      {isSummited && hasPost && (
        <button className="blog-cta" onClick={() => setShowBlog(true)} style={{ margin: "0 24px 16px 24px" }}>
          <span>Read field notes {peak.date ? `from ${peak.date}` : ""}</span>
          <span className="cta-arrow">→</span>
        </button>
      )}

      <div className="panel-stats">
        <div className="stat">
          <div className="stat-label">Elevation</div>
          <div className="stat-value">{peak.elevation.toLocaleString()}<span className="stat-unit">m</span></div>
        </div>
        <div className="stat">
          <div className="stat-label">Prominence</div>
          <div className="stat-value">{peak.prominence.toLocaleString()}<span className="stat-unit">m</span></div>
        </div>
        <div className="stat">
          <div className="stat-label">Range</div>
          <div className="stat-value-text">{peak.range}</div>
        </div>
      </div>

      {isSummited && hasRoute && (
        <>
          <div className="panel-section">
            <div className="section-label">My Route</div>
            <div style={{ marginBottom: "10px" }}>
              <window.Peak3DMap gpxData={gpxData} paletteObj={paletteObj} />
            </div>
            
            <div className="route-stats">
              <div><span className="route-num">{gpxData.distance.toFixed(1)}</span><span className="route-unit">km</span></div>
              <div><span className="route-num">{Math.round(gpxData.elevationGain)}</span><span className="route-unit">m vert</span></div>
            </div>
            
            <div style={{ marginTop: "12px", display: "flex", gap: "8px" }}>
              <a href={`data/peaks/${peak.cantonCode.toLowerCase()}/route.gpx`} download className="blog-cta" style={{ flex: 1, padding: "8px", fontSize: "11px", textAlign: "center" }}>
                Download GPX
              </a>
              <a href="https://map.geo.admin.ch/?bgLayer=ch.swisstopo.pixelkarte-farbe" target="_blank" className="blog-cta" style={{ flex: 1, padding: "8px", fontSize: "11px", textAlign: "center" }}>
                Open Swisstopo ↗
              </a>
            </div>
            <div style={{ fontSize: "10px", color: paletteObj.inkSoft, marginTop: "4px", textAlign: "center" }}>
              (Drag & Drop GPX into Swisstopo)
            </div>
          </div>
        </>
      )}

      {!isSummited && (
        <div className="panel-section planned-note">
          <div className="section-label">Status</div>
          <p className="planned-text">
            Not yet summited. {peak.elevation < 1500 ? "A perfect early-comeback peak." : peak.elevation < 3000 ? "On the medium-term list." : "Saving this for later in the project."}
          </p>
        </div>
      )}

      {showBlog && hasPost && (
        <BlogModal content={postContent} peak={peak} gpxData={gpxData} images={images} onClose={() => setShowBlog(false)} paletteObj={paletteObj} />
      )}
    </aside>
  );
}

// === IMAGE GRID ===
function ImageGrid({ images, peakCode, onImageClick }) {
  if (!images || images.length === 0) return null;

  return (
    <div className="image-grid">
      {images.map((img, idx) => (
        <div key={img} className="grid-thumbnail" onClick={() => onImageClick(idx)}>
          <img src={`data/peaks/${peakCode}/images/${img}`} alt={`Thumbnail ${idx + 1}`} />
        </div>
      ))}
    </div>
  );
}

// === FULLSCREEN CAROUSEL ===
function FullscreenCarousel({ images, peakCode, initialIndex, onClose }) {
  const [currentIndex, setCurrentIndex] = useState(initialIndex || 0);

  const handleNext = (e) => {
    e.stopPropagation();
    setCurrentIndex((prev) => (prev + 1) % images.length);
  };

  const handlePrev = (e) => {
    e.stopPropagation();
    setCurrentIndex((prev) => (prev - 1 + images.length) % images.length);
  };

  useEffect(() => {
    const handleKeyDown = (e) => {
      if (e.key === 'Escape') onClose();
      if (e.key === 'ArrowRight') setCurrentIndex((p) => (p + 1) % images.length);
      if (e.key === 'ArrowLeft') setCurrentIndex((p) => (p - 1 + images.length) % images.length);
    };
    window.addEventListener('keydown', handleKeyDown);
    return () => window.removeEventListener('keydown', handleKeyDown);
  }, [images.length, onClose]);

  const currentImage = images[currentIndex];
  const src = `data/peaks/${peakCode}/images/${currentImage}`;

  return ReactDOM.createPortal(
    <div className="fullscreen-carousel-backdrop" onClick={onClose}>
      <button className="fc-close" onClick={onClose}>×</button>
      <div className="fc-content" onClick={(e) => e.stopPropagation()}>
        <img src={src} alt="Gallery full" className="fc-image" />
        {images.length > 1 && (
          <>
            <button className="fc-btn prev" onClick={handlePrev}>←</button>
            <button className="fc-btn next" onClick={handleNext}>→</button>
          </>
        )}
      </div>
      <div className="fc-meta">{currentIndex + 1} / {images.length}</div>
    </div>,
    document.body
  );
}

// === BLOG MODAL ===
function BlogModal({ content, peak, gpxData, images, onClose, paletteObj }) {
  const [selectedIndex, setSelectedIndex] = useState(null);

  const htmlContent = useMemo(() => {
    if (!content || !window.marked) return "";
    return window.marked.parse(content);
  }, [content]);

  return ReactDOM.createPortal(
    <>
      <div className="blog-modal-backdrop" onClick={onClose}>
        <article className="blog-modal" onClick={(e) => e.stopPropagation()}>
          <button className="modal-close" onClick={onClose}>× close</button>
          <div className="blog-meta-top">
            <span className="blog-canton">{peak.cantonCode} · {peak.canton}</span>
          </div>
          <div className="blog-stats-strip">
            <div><span className="bs-label">elev</span> <span className="bs-num">{peak.elevation}m</span></div>
            {gpxData && (
              <>
                <div><span className="bs-label">dist</span> <span className="bs-num">{gpxData.distance.toFixed(1)}km</span></div>
                <div><span className="bs-label">vert</span> <span className="bs-num">{Math.round(gpxData.elevationGain)}m</span></div>
              </>
            )}
          </div>
          
          <ImageGrid images={images} peakCode={peak.cantonCode.toLowerCase()} onImageClick={setSelectedIndex} />

          <div className="blog-body" dangerouslySetInnerHTML={{ __html: htmlContent }} />
        </article>
      </div>

      {selectedIndex !== null && (
        <FullscreenCarousel 
          images={images} 
          peakCode={peak.cantonCode.toLowerCase()} 
          initialIndex={selectedIndex} 
          onClose={() => setSelectedIndex(null)} 
        />
      )}
    </>,
    document.body
  );
}

// === MINI MAP (blog list) ===
function MiniMap({ peak, paletteObj }) {
  const W = 200, H = 130;
  if (!window.CH_GEO) return null;
  const proj = window.computeProjection(window.CH_GEO, W, H, 6);
  const countryD = window.geomToPath(window.CH_GEO.country.geometry, proj.project);
  const [px, py] = proj.project(peak.lon, peak.lat);
  return (
    <svg viewBox={`0 0 ${W} ${H}`} preserveAspectRatio="xMidYMid meet">
      <path d={countryD} fill={paletteObj.land} stroke={paletteObj.contourDark} strokeWidth="0.8" />
      {window.CH_GEO.cantons.features.map(f => (
        <path key={f.properties.id}
              d={window.geomToPath(f.geometry, proj.project)}
              fill="none"
              stroke={paletteObj.contourDark}
              strokeWidth="0.3"
              opacity="0.4" />
      ))}
      <g transform={`translate(${px}, ${py})`}>
        <circle r="6" fill={paletteObj.accent} opacity="0.22" />
        <polygon points="0,-4 3.2,2.4 -3.2,2.4" fill={paletteObj.accent} stroke={paletteObj.accent} strokeWidth="0.5" />
      </g>
    </svg>
  );
}

// === BLOG TAB (map-anchored) ===
function BlogView({ peaks, paletteObj, onJumpToMap }) {
  const summited = peaks.filter((p) => p.status === "summited");
  const [posts, setPosts] = useState({});

  useEffect(() => {
    summited.forEach(p => {
      const code = p.cantonCode.toLowerCase();
      fetch(`data/peaks/${code}/post.md`)
        .then(res => {
          if (res.ok) return res.text();
          return null;
        })
        .then(text => {
          if (text) {
            setPosts(prev => ({ ...prev, [p.id]: text }));
          }
        })
        .catch(() => {});
    });
  }, []);

  return (
    <div className="blog-view">
      <div className="blog-view-header">
        <h1>Field Notes</h1>
        <p className="blog-view-sub">
          Stories from each summit, anchored to where they happened. {summited.length} of {peaks.length} cantons logged.
        </p>
      </div>
      <div className="blog-anchored-list">
        {summited.map((p) => {
          const postText = posts[p.id];
          if (!postText) return null;
          
          // Get first paragraph as excerpt
          const excerpt = postText.split('\n\n').find(para => para.trim().length > 20) || "";

          return (
            <article key={p.id} className="anchored-entry">
              <div className="anchor-mini-map">
                <MiniMap peak={p} paletteObj={paletteObj} />
              </div>
              <div className="anchor-content">
                <div className="anchor-meta">
                  <span className="anchor-canton">{p.cantonCode} · {p.canton}</span>
                </div>
                <h2 className="anchor-title">{p.name} Field Notes</h2>
                <div className="anchor-stats">
                  <span>{p.elevation}m</span>
                </div>
                <div className="anchor-excerpt">
                  <p>{excerpt}</p>
                </div>
                <button className="anchor-cta" onClick={() => onJumpToMap(p)}>
                  Open on map →
                </button>
              </div>
            </article>
          );
        })}
        {summited.length === 0 && (
          <div className="empty-blog">No entries yet — check back soon.</div>
        )}
      </div>
    </div>
  );
}

// === ABOUT VIEW ===
function AboutView({ peaks, paletteObj }) {
  const [aboutContent, setAboutContent] = useState("");

  useEffect(() => {
    fetch("data/about.md")
      .then(res => {
        if (res.ok) return res.text();
        return "Could not load concept.";
      })
      .then(text => setAboutContent(text));
  }, []);

  const summited = peaks.filter((p) => p.status === "summited").length;
  const totalElev = peaks.reduce((s, p) => s + p.elevation, 0);
  const climbedElev = peaks.filter((p) => p.status === "summited").reduce((s, p) => s + p.elevation, 0);

  return (
    <div className="about-view">
      <div className="about-header">
        <div className="about-eyebrow">ABOUT THE PROJECT</div>
        <h1 className="about-title">The Concept</h1>
        <p className="about-deck">
          A list of 26 summits — one per canton — and a way back into the mountains after my son Oscar was born.
        </p>
      </div>

      <div className="about-grid">
        <div className="about-stats">
          <div className="about-stat">
            <div className="as-num">{summited}<span className="as-denom">/{peaks.length}</span></div>
            <div className="as-label">cantons summited</div>
          </div>
          <div className="about-stat">
            <div className="as-num">{climbedElev.toLocaleString()}</div>
            <div className="as-label">meters climbed</div>
          </div>
          <div className="about-stat">
            <div className="as-num">{(totalElev - climbedElev).toLocaleString()}</div>
            <div className="as-label">meters remaining</div>
          </div>
          <div className="about-stat">
            <div className="as-num">4,634</div>
            <div className="as-label">m — Dufourspitze (the goal)</div>
          </div>
        </div>

        <div className="about-prose">
          {aboutContent ? (
            <div dangerouslySetInnerHTML={{ __html: window.marked.parse(aboutContent) }} />
          ) : (
            <p>Loading...</p>
          )}
        </div>
      </div>

      <div className="about-elev-chart">
        <div className="elev-chart-label">ELEVATION PROFILE — 26 CANTONAL HIGH POINTS</div>
        <ElevationChart peaks={peaks} paletteObj={paletteObj} />
      </div>
    </div>
  );
}

// === ELEVATION CHART ===
function ElevationChart({ peaks, paletteObj }) {
  const sorted = [...peaks].sort((a, b) => a.elevation - b.elevation);
  const maxE = Math.max(...sorted.map((p) => p.elevation));
  const w = 1000;
  const h = 200;
  const padL = 40;
  const padR = 20;
  const padT = 20;
  const padB = 40;
  const innerW = w - padL - padR;
  const innerH = h - padT - padB;

  return (
    <svg viewBox={`0 0 ${w} ${h}`} className="elev-chart-svg">
      {/* y-axis grid */}
      {[0, 1000, 2000, 3000, 4000, 5000].map((tick) => {
        const y = padT + innerH - (tick / maxE) * innerH;
        return (
          <g key={tick}>
            <line x1={padL} y1={y} x2={w - padR} y2={y} stroke={paletteObj.contour} strokeWidth="0.5" opacity="0.3" />
            <text x={padL - 8} y={y + 4} fontSize="11" fill={paletteObj.inkSoft} textAnchor="end" fontFamily="JetBrains Mono, monospace">
              {tick}m
            </text>
          </g>
        );
      })}
      {/* bars */}
      {sorted.map((p, i) => {
        const x = padL + (i / (sorted.length - 1)) * innerW;
        const barH = (p.elevation / maxE) * innerH;
        const y = padT + innerH - barH;
        const isSummited = p.status === "summited";
        return (
          <g key={p.id}>
            <line x1={x} y1={padT + innerH} x2={x} y2={y} stroke={isSummited ? paletteObj.accent : paletteObj.contourDark} strokeWidth="2" />
            <polygon
              points={`${x},${y - 4} ${x + 3},${y + 1} ${x - 3},${y + 1}`}
              fill={isSummited ? paletteObj.accent : paletteObj.paper}
              stroke={isSummited ? paletteObj.accent : paletteObj.contourDark}
              strokeWidth="1.2"
            />
            <text x={x} y={padT + innerH + 14} fontSize="9" fill={paletteObj.inkSoft} textAnchor="middle" fontFamily="JetBrains Mono, monospace">
              {p.cantonCode}
            </text>
          </g>
        );
      })}
    </svg>
  );
}

// === MAIN APP ===
function App() {
  const [tweaks, setTweak] = window.useTweaks(TWEAK_DEFAULTS);
  const [activeTab, setActiveTab] = useState("map");
  const [selected, setSelected] = useState(null);
  const [hovered, setHovered] = useState(null);

  const peaks = window.KHPP_PEAKS;
  const paletteObj = PALETTES[tweaks.palette] || PALETTES.paper;
  const summited = peaks.filter((p) => p.status === "summited").length;

  // Apply palette to root
  useEffect(() => {
    const root = document.documentElement;
    root.style.setProperty("--paper", paletteObj.paper);
    root.style.setProperty("--paper-deep", paletteObj.paperDeep);
    root.style.setProperty("--ink", paletteObj.ink);
    root.style.setProperty("--ink-soft", paletteObj.inkSoft);
    root.style.setProperty("--contour", paletteObj.contour);
    root.style.setProperty("--contour-dark", paletteObj.contourDark);
    root.style.setProperty("--accent", paletteObj.accent);
    root.style.setProperty("--accent-soft", paletteObj.accentSoft);
    root.style.setProperty("--water", paletteObj.water);
  }, [paletteObj]);

  const jumpToMap = (peak) => {
    setActiveTab("map");
    setSelected(peak);
  };

  return (
    <div className="khpp-app">
      <Header activeTab={activeTab} onTab={setActiveTab} summited={summited} total={peaks.length} />

      <main className="khpp-main">
        {activeTab === "map" && (
          <MapView
            peaks={peaks}
            selected={selected}
            onSelect={setSelected}
            hovered={hovered}
            onHover={setHovered}
            palette={tweaks.palette}
            paletteObj={paletteObj}
            mapStyle={tweaks.mapStyle}
            panelLayout={tweaks.panelLayout}
            showCoordinates={tweaks.showCoordinates}
            showGrid={tweaks.showGrid}
          />
        )}
        {activeTab === "blog" && <BlogView peaks={peaks} paletteObj={paletteObj} onJumpToMap={jumpToMap} />}
        {activeTab === "about" && <AboutView peaks={peaks} paletteObj={paletteObj} />}
      </main>

      {/* Tweaks Panel */}
      <window.TweaksPanel title="Tweaks">
        <window.TweakSection title="Palette">
          <window.TweakSelect
            label="Color palette"
            value={tweaks.palette}
            onChange={(v) => setTweak("palette", v)}
            options={[
              { value: "paper", label: "Paper Topo" },
              { value: "forest", label: "Forest & Stone" },
              { value: "glacier", label: "Cool Alpine" },
            ]}
          />
        </window.TweakSection>
        <window.TweakSection title="Map style">
          <window.TweakRadio
            label="Terrain rendering"
            value={tweaks.mapStyle}
            onChange={(v) => setTweak("mapStyle", v)}
            options={[
              { value: "contours", label: "Contours" },
              { value: "hatched", label: "Hatched" },
              { value: "minimal", label: "Minimal" },
            ]}
          />
          <window.TweakToggle
            label="Coordinate grid"
            value={tweaks.showGrid}
            onChange={(v) => setTweak("showGrid", v)}
          />
          <window.TweakToggle
            label="Map corner coordinates"
            value={tweaks.showCoordinates}
            onChange={(v) => setTweak("showCoordinates", v)}
          />
        </window.TweakSection>
        <window.TweakSection title="Layout">
          <window.TweakRadio
            label="Detail panel"
            value={tweaks.panelLayout}
            onChange={(v) => setTweak("panelLayout", v)}
            options={[
              { value: "side", label: "Side" },
              { value: "bottom", label: "Bottom" },
              { value: "overlay", label: "Overlay" },
            ]}
          />
        </window.TweakSection>
      </window.TweaksPanel>
    </div>
  );
}

ReactDOM.createRoot(document.getElementById("root")).render(<App />);
