import{v as me,w as W,i as Z,A as d,b as n,x as be,y as ye,z as fe,D as we,E as $e,F as ke}from"./app-wpJSg6bV.js";import"./index-BScPU8W0.js";const Y={all:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="3" y="3" width="7" height="7"></rect>
      <rect x="14" y="3" width="7" height="7"></rect>
      <rect x="14" y="14" width="7" height="7"></rect>
      <rect x="3" y="14" width="7" height="7"></rect>
    </svg>
  `,env:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="3"></circle>
      <path
        d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"
      ></path>
    </svg>
  `,update:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
      <polyline points="7 10 12 15 17 10"></polyline>
      <line x1="12" y1="15" x2="12" y2="3"></line>
    </svg>
  `,agents:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path
        d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"
      ></path>
      <circle cx="8" cy="14" r="1"></circle>
      <circle cx="16" cy="14" r="1"></circle>
    </svg>
  `,auth:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
      <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
    </svg>
  `,channels:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
    </svg>
  `,messages:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path>
      <polyline points="22,6 12,13 2,6"></polyline>
    </svg>
  `,commands:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <polyline points="4 17 10 11 4 5"></polyline>
      <line x1="12" y1="19" x2="20" y2="19"></line>
    </svg>
  `,hooks:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
      <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
    </svg>
  `,skills:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <polygon
        points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"
      ></polygon>
    </svg>
  `,tools:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path
        d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"
      ></path>
    </svg>
  `,gateway:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="10"></circle>
      <line x1="2" y1="12" x2="22" y2="12"></line>
      <path
        d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"
      ></path>
    </svg>
  `,wizard:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M15 4V2"></path>
      <path d="M15 16v-2"></path>
      <path d="M8 9h2"></path>
      <path d="M20 9h2"></path>
      <path d="M17.8 11.8 19 13"></path>
      <path d="M15 9h0"></path>
      <path d="M17.8 6.2 19 5"></path>
      <path d="m3 21 9-9"></path>
      <path d="M12.2 6.2 11 5"></path>
    </svg>
  `,meta:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M12 20h9"></path>
      <path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path>
    </svg>
  `,logging:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
      <polyline points="14 2 14 8 20 8"></polyline>
      <line x1="16" y1="13" x2="8" y2="13"></line>
      <line x1="16" y1="17" x2="8" y2="17"></line>
      <polyline points="10 9 9 9 8 9"></polyline>
    </svg>
  `,browser:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="10"></circle>
      <circle cx="12" cy="12" r="4"></circle>
      <line x1="21.17" y1="8" x2="12" y2="8"></line>
      <line x1="3.95" y1="6.06" x2="8.54" y2="14"></line>
      <line x1="10.88" y1="21.94" x2="15.46" y2="14"></line>
    </svg>
  `,ui:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
      <line x1="3" y1="9" x2="21" y2="9"></line>
      <line x1="9" y1="21" x2="9" y2="9"></line>
    </svg>
  `,models:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path
        d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"
      ></path>
      <polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
      <line x1="12" y1="22.08" x2="12" y2="12"></line>
    </svg>
  `,bindings:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect>
      <rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect>
      <line x1="6" y1="6" x2="6.01" y2="6"></line>
      <line x1="6" y1="18" x2="6.01" y2="18"></line>
    </svg>
  `,broadcast:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path>
      <path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path>
      <circle cx="12" cy="12" r="2"></circle>
      <path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path>
      <path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path>
    </svg>
  `,session:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
      <circle cx="9" cy="7" r="4"></circle>
      <path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
      <path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
    </svg>
  `,cron:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="10"></circle>
      <polyline points="12 6 12 12 16 14"></polyline>
    </svg>
  `,web:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="10"></circle>
      <line x1="2" y1="12" x2="22" y2="12"></line>
      <path
        d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"
      ></path>
    </svg>
  `,discovery:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="11" cy="11" r="8"></circle>
      <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
    </svg>
  `,canvasHost:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
      <circle cx="8.5" cy="8.5" r="1.5"></circle>
      <polyline points="21 15 16 10 5 21"></polyline>
    </svg>
  `,talk:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path>
      <path d="M19 10v2a7 7 0 0 1-14 0v-2"></path>
      <line x1="12" y1="19" x2="12" y2="23"></line>
      <line x1="8" y1="23" x2="16" y2="23"></line>
    </svg>
  `,plugins:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M12 2v6"></path>
      <path d="m4.93 10.93 4.24 4.24"></path>
      <path d="M2 12h6"></path>
      <path d="m4.93 13.07 4.24-4.24"></path>
      <path d="M12 22v-6"></path>
      <path d="m19.07 13.07-4.24-4.24"></path>
      <path d="M22 12h-6"></path>
      <path d="m19.07 10.93-4.24 4.24"></path>
    </svg>
  `,default:n`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
      <polyline points="14 2 14 8 20 8"></polyline>
    </svg>
  `},ee=[{key:"env",label:"Environment"},{key:"update",label:"Updates"},{key:"agents",label:"Agents"},{key:"acp",label:"ACP Runtime"},{key:"auth",label:"Authentication"},{key:"channels",label:"Channels"},{key:"bindings",label:"Bindings"},{key:"broadcast",label:"Broadcast"},{key:"messages",label:"Messages"},{key:"commands",label:"Commands"},{key:"hooks",label:"Hooks"},{key:"skills",label:"Skills"},{key:"tools",label:"Tools"},{key:"gateway",label:"Gateway"},{key:"nodeHost",label:"Node Host"},{key:"wizard",label:"Setup Wizard"}],V=new Set(["agents","approvals","auth","audio","canvasHost","channels","commands","cron","discovery","env","federation","browser","diagnostics","hooks","logging","media","memory","meta","messages","mcp","models","plugins","session","skills","talk","tools","update","ui","wallet","web","wizard"]),xe=["api-key","oauth","token"],G=["api_key","oauth","token"],te="__all__";function P(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Ae(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t.trim():"").filter(Boolean):[]}function ge(e){return Y[e]??Y.default}function Ce(e){switch(e){case"auth":case"models":return[{label:"Providers",tab:"providers",detail:"Add model APIs, auth profiles, and default model choices."}];case"agents":return[{label:"Agents",tab:"agents",detail:"Create Agents and attach models, skills, services, channels, memory, and cron."}];case"acp":return[{label:"Debug",tab:"debug",detail:"Inspect ACPX bridge state, guarded wrappers, sessions, and runtime diagnostics."},{label:"Extensions",tab:"plugins",detail:"Install, enable, and inspect ACP backend plugins such as acpx."},{label:"Agents",tab:"agents",detail:"Normal Agent coordination, models, memory, tools, and tasks live on the Agent page."},{label:"Channels",tab:"channels",detail:"Thread routing and channel-specific ACP spawn behavior live with channel routes."}];case"skills":return[{label:"Skills",tab:"skills",detail:"Install, enable, configure API keys, and review skill readiness."}];case"commands":case"messages":case"channels":return[{label:"Channels",tab:"channels",detail:"Connect apps, route accounts to Agents, and review command parity."}];case"bindings":return[{label:"Channels",tab:"channels",detail:"Manage normal channel account routing and default Agent routes."},{label:"Agents",tab:"agents",detail:"Review which inbound channel routes and task bindings belong to each Agent."}];case"broadcast":return[{label:"Channels",tab:"channels",detail:"Manage normal channel access, account routing, and group safety first."},{label:"Agents",tab:"agents",detail:"Review and configure the Agents that can participate in multi-Agent replies."}];case"hooks":return[{label:"Tasks",tab:"cron",detail:"Use task policies and schedules for normal Agent automations."},{label:"Agents",tab:"agents",detail:"Enable Agent-owned memory behavior and coordination settings."},{label:"Extensions",tab:"plugins",detail:"Developer hook packs and lifecycle integrations belong with Extensions."}];case"session":return[{label:"Agents",tab:"agents",detail:"Enable memory hooks and review Agent setup."},{label:"Memory",tab:"memory",detail:"Read-only memory diagnostics and archive health."}];case"memory":return[{label:"Memory",tab:"memory",detail:"Read-only memory diagnostics and archive health."},{label:"Agents",tab:"agents",detail:"Enable or disable session-memory for an Agent."}];case"plugins":return[{label:"Extensions",tab:"plugins",detail:"Runtime plugin lifecycle, trust, dependency, and scanner diagnostics."}];case"cron":return[{label:"Tasks",tab:"cron",detail:"Create scheduled tasks, filters, runs, and delivery state."}];case"gateway":return[{label:"Overview",tab:"overview",detail:"Gateway endpoint, auth status, connection health, uptime, and high-level cards."},{label:"Debug",tab:"debug",detail:"Startup timings, event logs, admin RPC, command catalog, and runtime diagnostics."}];case"wizard":return[{label:"Overview",tab:"overview",detail:"Post-onboarding status, gateway health, and next setup actions."},{label:"Agents",tab:"agents",detail:"Continue normal setup after onboarding: models, channels, memory, skills, services, and tasks."},{label:"Debug",tab:"debug",detail:"Gateway startup, wizard/runtime diagnostics, and repair surfaces."}];case"diagnostics":return[{label:"Debug",tab:"debug",detail:"Read diagnostics stability, startup, event logs, admin RPC, and runtime state."},{label:"Overview",tab:"overview",detail:"Use normal health cards before enabling verbose diagnostics."}];case"logging":return[{label:"Logs",tab:"logs",detail:"Read, filter, follow, and export gateway file logs."},{label:"Debug",tab:"debug",detail:"Inspect runtime health, event logs, startup diagnostics, and admin surfaces."}];case"wallet":return[{label:"Wallet",tab:"wallet",detail:"Review balances, approvals, policy, passkeys, custody, and wallet health."},{label:"Mining",tab:"mining",detail:"Review the singleton SAT mining wallet and mining operations."},{label:"Network",tab:"federation",detail:"Review Fased Network and bond wallet status."}];case"federation":return[{label:"Network",tab:"federation",detail:"Review Fased Network, marketplace, receipts, and bonded operations."},{label:"Wallet",tab:"wallet",detail:"Review wallet policy and approvals used by network operations."}];case"browser":return[{label:"Services",tab:"services",detail:"Enable the browser/media runtime."},{label:"Agents",tab:"agents",detail:"Grant browser tools to an Agent."},{label:"Debug",tab:"debug",detail:"Inspect browser runtime failures, gateway events, and service health."}];case"nodeHost":return[{label:"Nodes",tab:"nodes",detail:"Pair devices, inspect live node status, command catalogs, and exec approvals."},{label:"Services",tab:"services",detail:"Enable browser/media services before exposing them through a node host."},{label:"Debug",tab:"debug",detail:"Inspect node-host, browser proxy, and gateway runtime failures."}];case"tools":case"canvasHost":return[{label:"Services",tab:"services",detail:"Connect service APIs, web/search, browser/media, and custom integrations."},{label:"Agents",tab:"agents",detail:"Grant service tools to an Agent."}];case"web":return[{label:"Channels",tab:"channels",detail:"Web-client login, heartbeat, and reconnect policy for QR/web channels."},{label:"Debug",tab:"debug",detail:"Run operator-approved web login diagnostics."}];default:return[]}}function Pe(e,t,i){const s=$e(e.tab,t.basePath??"");return n`
    <a
      class=${i}
      href=${s}
      title=${e.detail??e.label}
      @click=${o=>{!t.onNavigate||o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||(o.preventDefault(),t.onNavigate(e.tab))}}
    >
      ${e.label}
    </a>
  `}function Me(e,t){const i=Ce(e);return i.length===0?d:n`
    <div class="config-section-shortcuts" aria-label="Friendly page for this config section">
      <span class="config-section-shortcuts__label">Friendly page</span>
      ${i.map(s=>Pe(s,t,"config-section-shortcut"))}
    </div>
  `}function Se(e){return e==="gateway"?n`
      <div class="callout warn">
        Gateway config is low-level runtime plumbing. Use Overview for endpoint, token, connection,
        uptime, and high-level health. Use Debug for startup timings, event logs, command/runtime
        catalogs, admin RPC, and diagnostics. Edit this section only for bind, port, auth, CORS, allowed
        origins, and other listener/security fields.
      </div>
    `:e==="wallet"?n`
      <div class="callout warn">
        Wallet config is advanced plumbing. Use Wallet for balances, approvals, policy, passkeys, and
        custody; use Mining for the singleton <span class="mono">@wallet:mining</span> lifecycle; use
        Network for bond wallet and Fased Network state. Private-key import/export, signer cleanup, and
        mining-wallet deletion stay in onboarding or CLI.
      </div>
    `:e==="wizard"?n`
      <div class="callout info">
        Setup Wizard config is last-run metadata only: timestamp, version, commit, command, and local or
        remote mode. Do not edit it to rerun onboarding. Use <span class="mono">fased setup</span> or the
        app onboarding flow to run setup again; continue normal setup in Agents, Providers, Channels,
        Services, Wallet, and Tasks.
      </div>
    `:e==="diagnostics"?n`
      <div class="callout warn">
        Diagnostics config is advanced observability. Use Debug to inspect current runtime diagnostics
        before changing these toggles. Enable flags, OpenTelemetry, or cache trace only temporarily and
        only when you control the output destination. Cache trace options can record prompts, messages,
        and system context into local logs.
      </div>
    `:e==="logging"?n`
      <div class="callout warn">
        Logging config controls file and console verbosity, log path, format, and redaction. Use Logs to
        read and export gateway logs; use Debug for runtime health and event diagnostics. Only raise
        levels to debug or trace temporarily, and do not disable redaction unless you control the output
        destination because logs may contain tool arguments, prompts, identifiers, and operational
        context.
      </div>
    `:e==="browser"?n`
      <div class="callout warn">
        Browser config is advanced runtime plumbing. Use Services to enable the browser/media runtime and
        Agent Tools to decide which Agents may use browser tools. Edit this section only for CDP URLs,
        profile ports, executable path, headless/no-sandbox launch behavior, attach-only mode, snapshot
        defaults, or evaluate/remote-browser troubleshooting. These settings can expose a real local
        browser or remote CDP endpoint, so keep them scoped and intentional.
      </div>
    `:e==="acp"?n`
      <div class="callout warn">
        ACP config is advanced external harness plumbing for Codex, Claude Code, Gemini CLI, OpenCode, and
        other Agent Client Protocol runtimes. Use Debug for ACPX bridge/runtime inspection, Extensions for
        backend plugin lifecycle, Agents for normal coordination policy, and Channels for thread binding.
        Edit this section only for the global ACP gate, dispatch, backend id, harness allowlist, session
        concurrency, stream coalescing, or runtime TTL.
      </div>
    `:e==="nodeHost"?n`
      <div class="callout warn">
        Node Host config is advanced companion-process plumbing for machines running as Fased nodes. Use
        Nodes for pairing, live device status, command exposure, exec approvals, and Agent execution-node
        bindings. Use Services for browser/media setup and Debug for runtime failures. Edit this section
        only when a node host should expose its local browser proxy or restrict which browser profiles the
        gateway may reach through that node.
      </div>
    `:e==="bindings"?n`
      <div class="callout warn">
        Bindings are advanced channel-to-Agent route rules. Use Channels for normal account routing and
        default Agent selection; use Agents to inspect which routes belong to an Agent. Edit this section
        only for precise peer, topic, guild, team, role, or multi-account routing that the focused
        Channels UI does not expose yet. Bindings are deterministic and the most-specific match wins.
      </div>
    `:e==="broadcast"?n`
      <div class="callout warn">
        Broadcast config is experimental multi-Agent channel fanout. It currently applies to eligible
        WhatsApp peers after normal pairing, allowlist, group policy, and mention gates pass. Use Channels
        for normal routing and safety policy, and Agents for the Agent identities, models, tools, and
        memory that will run. Edit this section only to map a source peer ID to multiple Agent IDs or to
        switch between parallel and sequential fanout.
      </div>
    `:d}function _e(e){const{sections:t,schemaProps:i,props:s}=e;return n`
    <section class="config-section-index" aria-label="Config sections">
      <div class="config-section-index__header">
        <div class="config-section-index__eyebrow">Advanced Config</div>
        <h2 class="config-section-index__title">Choose a section</h2>
        <p class="config-section-index__desc">
          Edit one config area at a time. Search on the left, or pick a section below.
        </p>
      </div>
      <div class="config-section-index__grid">
        ${t.map(o=>{const r=q(o.key,i[o.key]);return n`
            <button
              type="button"
              class="config-section-index__card"
              @click=${()=>s.onSectionChange(o.key)}
            >
              <span class="config-section-index__icon">${ge(o.key)}</span>
              <span class="config-section-index__copy">
                <span class="config-section-index__label">${o.label}</span>
                ${r.description?n`<span class="config-section-index__summary">${r.description}</span>`:d}
              </span>
            </button>
          `})}
      </div>
    </section>
  `}function q(e,t){const i=ye[e];return i||{label:t?.title??fe(e),description:t?.description??""}}function Re(e){const{key:t,schema:i,uiHints:s}=e;if(!i||W(i)!=="object"||!i.properties)return[];const o=Object.entries(i.properties).map(([r,l])=>{const u=we([t,r],s),g=u?.label??l.title??fe(r),v=u?.help??l.description??"",m=u?.order??50;return{key:r,label:g,description:v,order:m}});return o.sort((r,l)=>r.order!==l.order?r.order-l.order:r.key.localeCompare(l.key)),o}function Ie(e,t){if(!e||!t)return[];const i=[];function s(o,r,l){if(o===r)return;if(typeof o!=typeof r){i.push({path:l,from:o,to:r});return}if(typeof o!="object"||o===null||r===null){o!==r&&i.push({path:l,from:o,to:r});return}if(Array.isArray(o)&&Array.isArray(r)){JSON.stringify(o)!==JSON.stringify(r)&&i.push({path:l,from:o,to:r});return}const u=o,g=r,v=new Set([...Object.keys(u),...Object.keys(g)]);for(const m of v)s(u[m],g[m],l?`${l}.${m}`:m)}return s(e,t,""),i}function ne(e,t=40){let i;try{i=JSON.stringify(e)??String(e)}catch{i=String(e)}return i.length<=t?i:i.slice(0,t-3)+"..."}function Oe(e){const t=P(e)??{},i=P(t.auth)??{},s=P(i.profiles)??{},o=P(i.order)??{},r=P(t.models)??{},l=P(r.providers)??{},u=P(t.gateway)??{},g=P(u.auth),v=g&&typeof g.mode=="string"?g.mode:null,m=new Set([...Object.keys(l),...Object.keys(o),...Object.values(s).map($=>{const y=P($);return y&&typeof y.provider=="string"?y.provider.trim():""}).filter(Boolean)]),b=Array.from(m).toSorted(($,y)=>$.localeCompare(y)).map($=>{const y=P(l[$]),M=[];for(const[B,I]of Object.entries(s)){const x=P(I);if((x&&typeof x.provider=="string"?x.provider.trim():"")!==$)continue;const S=x&&typeof x.mode=="string"?x.mode:"unknown",F=S==="api_key"||S==="oauth"||S==="token"?S:"unknown";M.push({id:B,mode:F,email:x&&typeof x.email=="string"&&x.email.trim()||void 0})}return{id:$,modelCount:Array.isArray(y?.models)?y.models.length:0,authMode:y&&typeof y.auth=="string"?y.auth:null,hasApiKey:!!(y&&"apiKey"in y),profiles:M,orderedProfileIds:Ae(o[$])}}),O={api_key:0,oauth:0,token:0,unknown:0};for(const $ of b)for(const y of $.profiles)O[y.mode]+=1;return{gatewayAuthMode:v,totalProfiles:Object.keys(s).length,totalProviders:b.length,profileModeCounts:O,providers:b}}function Be(e){switch(e){case"api_key":return"api-key";case"oauth":return"oauth";case"token":return"token";default:return null}}function H(e){return e==="oauth"||e==="token"?e:"api_key"}function Ee(e){const t=e.trim();return t||void 0}function Te(e){return/^[^\s@]+@[^\s@]+$/.test(e)}function E(e,t){const i=e.get(t);return typeof i=="string"?i.trim():""}function Fe(e,t){const i=e.indexOf(":");return i<0?!0:e.slice(0,i)===t}function ie(e){return Object.values(e).some(Boolean)}function De(e,t){const i=e.elements.namedItem(t);return i instanceof HTMLInputElement||i instanceof HTMLSelectElement?i:null}function T(e){(e instanceof HTMLInputElement||e instanceof HTMLSelectElement)&&e.setCustomValidity("")}function ae(e,t){let i=null;for(const s of["id","provider","mode","email"]){const o=De(e,s);if(!o)continue;const r=t[s]??"";o.setCustomValidity(r),!i&&r&&(i=o)}i?.reportValidity()}function se(e){const t=new Set;(e.authMode==="api-key"||e.authMode==="oauth"||e.authMode==="token")&&t.add(e.authMode),e.hasApiKey&&t.add("api-key");for(const i of e.profiles){const s=Be(i.mode);s&&t.add(s)}return xe.filter(i=>t.has(i))}function oe(e,t){const i=new Set(e.profiles.map(r=>r.id)),s=e.orderedProfileIds.filter(r=>i.has(r)),o=e.profiles.map(r=>r.id).filter(r=>r!==t&&!s.includes(r));return i.has(t)?[t,...s.filter(r=>r!==t),...o]:[...s,...o]}function Ue(e){const t=new Map(e.profiles.map(o=>[o.id,o])),i=e.orderedProfileIds.map(o=>t.get(o)??null).filter(o=>!!o),s=e.profiles.filter(o=>!e.orderedProfileIds.includes(o.id));return[...i,...s]}function je(e){const t={},i={};for(const s of e.providers){const o=s.profiles.map(u=>u.id),r=s.orderedProfileIds.filter(u=>o.includes(u)),l=o.filter(u=>!r.includes(u));(r.length>0||l.length>0)&&(i[s.id]=[...r,...l]);for(const u of s.profiles)t[u.id]={provider:s.id,mode:H(u.mode),email:u.email}}return{profiles:t,order:i}}function re(e,t){const i=t.id.trim(),s=t.provider.trim();if(!i||!s)return e;const o=e.profiles[i],r={...e.profiles};r[i]={provider:s,mode:H(t.mode),email:Ee(t.email??"")};const l=Object.fromEntries(Object.entries(e.order).map(([m,b])=>[m,[...b]])),u=l[s]??[],g=o&&o.provider===s?u.indexOf(i):-1;for(const[m,b]of Object.entries(l))l[m]=b.filter(O=>O!==i);const v=l[s]??[];g>=0?v.splice(Math.min(g,v.length),0,i):v.push(i),l[s]=v;for(const[m,b]of Object.entries(l))b.length===0&&delete l[m];return{profiles:r,order:l}}function He(e,t){if(!e.profiles[t])return e;const i={...e.profiles};delete i[t];const s={};for(const[o,r]of Object.entries(e.order)){const l=r.filter(u=>u!==t);l.length>0&&(s[o]=l)}return{profiles:i,order:s}}function le(e,t,i,s){if(!e.profiles[i]||e.profiles[i]?.provider!==t)return e;const o=Object.entries(e.profiles).filter(([,v])=>v.provider===t).map(([v])=>v),r=[...(e.order[t]??[]).filter(v=>o.includes(v)),...o.filter(v=>!(e.order[t]??[]).includes(v))],l=r.indexOf(i);if(l<0)return e;const u=s==="up"?l-1:l+1;if(u<0||u>=r.length)return e;const g=[...r];return[g[l],g[u]]=[g[u],g[l]],{profiles:{...e.profiles},order:{...e.order,[t]:g}}}function ce(e,t,i){const s=t.id.trim(),o=t.provider.trim(),r=t.mode.trim(),l=t.email?.trim()??"",u={};return s?/\s/.test(s)?u.id="Profile id cannot contain spaces.":s!==i&&e.profiles[s]&&(u.id="Profile id already exists."):u.id="Profile id is required.",o?/\s/.test(o)&&(u.provider="Provider id cannot contain spaces."):u.provider="Provider is required.",G.includes(r)||(u.mode="Select a supported auth mode."),l&&!Te(l)&&(u.email="Enter a valid email address."),s&&o&&!u.id&&!u.provider&&!Fe(s,o)&&(u.provider=`Provider should match the profile id prefix "${s.split(":",1)[0]}".`),u}function L(e){switch(e){case"ok":case"static":return"chip chip-ok";case"expiring":return"chip chip-warn";case"expired":case"missing":return"chip chip-danger";default:return"chip"}}function z(e){if(typeof e!="number"||!Number.isFinite(e))return null;if(e<=0)return"now";const t=Math.ceil(e/6e4);if(t<60)return`${t}m`;const i=Math.ceil(t/60);return i<48?`${i}h`:`${Math.ceil(i/24)}d`}function de(e){if(e.unusableKind==="disabled")return e.unusableReason?`disabled: ${e.unusableReason}`:"disabled";if(e.unusableKind==="cooldown"){const t=z(e.remainingMs);return t?`cooldown · ${t}`:"cooldown"}switch(e.status){case"ok":{const t=z(e.remainingMs);return t?`ok · ${t}`:"ok"}case"expiring":{const t=z(e.remainingMs);return t?`expiring · ${t}`:"expiring"}case"expired":return"expired";case"missing":return"missing";case"static":return"static";default:return"unknown"}}function Ne(e){const t=e.provider.trim(),i=e.profileId.trim();return t?e.mode==="token"?`pnpm fased models auth paste-token --provider ${t} --profile-id ${i||`${t}:manual`}`:`pnpm fased models auth login --provider ${t}`:"pnpm fased models auth login"}function Ve(e){return e==="api_key"||e==="token"}function Le(e){return e==="token"?"Save token":"Save API key"}function ze(e){return e==="oauth"}function ue(e){switch(e){case"success":return"callout info";case"warn":return"callout warn";case"danger":return"callout danger";default:return"callout info"}}function Ke(e,t){if(!e)return"Run sign-in";switch(t?.stepType){case"note":case"action":return t.hasUrl?"Open browser…":"Reading step…";case"confirm":return"Awaiting confirm…";case"text":return"Awaiting text…";case"select":case"multiselect":return"Awaiting choice…";default:return"Signing in…"}}function j(e){switch(e?.stepType){case"note":case"action":return e.hasUrl?"browser step":"instruction step";case"confirm":return"confirmation";case"text":return"text input";case"select":return"single choice";case"multiselect":return"multiple choice";default:return null}}function K(e){return!!(e?.actionKind==="interactive"&&!e.active&&e.retryable)}function We(e){return!!(e?.actionKind==="interactive"&&e.url)}function pe(e){if(!e)return null;const t=[e.provider,e.profileId].filter(Boolean).join(" · ")||"provider auth";switch(e.actionKind){case"interactive":return e.active?`${t} sign-in is in progress.`:e.tone==="success"?`${t} sign-in completed.`:e.tone==="warn"?`${t} sign-in stopped before completion.`:e.tone==="danger"?`${t} sign-in needs attention.`:`${t} sign-in updated.`;case"store":return e.active?`${t} credential update is running.`:e.tone==="success"?`${t} credential was updated.`:e.tone==="danger"?`${t} credential update failed.`:`${t} credential update changed state.`;case"clear":return e.active?`${t} credential clear is running.`:e.tone==="success"?`${t} credential was cleared.`:e.tone==="warn"?`${t} had no stored credential to clear.`:e.tone==="danger"?`${t} credential clear failed.`:`${t} credential clear changed state.`;default:return t}}function he(e){if(!e)return[];if(e.actionKind==="interactive"){if(e.active)switch(e.stepType){case"note":case"action":return e.hasUrl?["Finish the provider page in your browser, then return here for the next prompt.","Keep this Config card open so the next step stays visible."]:["Read the instruction fully, then return here to continue.","Keep this Config card open so the next step stays visible."];case"confirm":return["Approve the confirmation prompt to keep the sign-in flow moving.",e.hasUrl?"If needed, reopen the sign-in page from this card before confirming.":"Return here after confirming to continue."];case"text":return["Paste the requested code or value exactly into the prompt dialog.","Submit the prompt, then return here for the next step."];case"select":case"multiselect":return["Choose the option that matches the provider account or workspace you want.","If the choices look wrong, cancel and restart before storing the wrong profile."];default:return["Follow the current prompt, then return here for the next step."]}if(e.tone==="success")return["Check the refreshed runtime status below to confirm the provider is now usable.","If you need a different account, rerun sign-in from this same profile."];if(e.tone==="warn")return["Use Retry sign-in to continue from this profile.",e.url?"Use Open sign-in page again if the provider browser page was already opened.":"Restart the sign-in flow from this profile when you are ready."];if(e.tone==="danger")return["Review the error detail, then retry sign-in from this profile.","If the browser flow keeps failing, use the terminal command fallback below."]}return e.actionKind==="store"?e.tone==="danger"?["Paste the credential again and verify the selected provider/profile.","If needed, clear the credential first to start from a clean state."]:["Check the refreshed runtime status below to confirm the stored credential is now active."]:e.actionKind==="clear"?e.tone==="danger"?["Retry the clear action if you still need to remove the stored credential.","If the profile looks wrong, update it in the config form first."]:["Check the refreshed runtime status below to confirm the profile no longer has a stored credential."]:[]}function ve(e,t){return e?.providers.find(i=>i.provider===t)??null}function Ge(e,t,i){return ve(e,t)?.profiles.find(s=>s.profileId===i)??null}function qe(e,t,i,s){const o=a=>{s.onSectionChange(a),s.onSubsectionChange(null)},r=e.providers.length>0,l=s.authAction,u=pe(l),g=he(l),v=s.activeSection==="auth",m=s.activeSection==="models",b=je(e),$=(i?Object.entries(i.sourceCounts).toSorted((a,h)=>a[0].localeCompare(h[0])):[]).slice(0,4),y=i?.providers.filter(a=>!a.configured).slice(0,6).map(a=>a.provider).join(", ")??"",M=a=>{s.onFormPatch(["auth","profiles"],a.profiles),s.onFormPatch(["auth","order"],a.order)},B=(a,h)=>{a.preventDefault();const f=a.currentTarget,c=new FormData(f),k={id:h,provider:E(c,"provider"),mode:E(c,"mode"),email:E(c,"email")},p=ce(b,k,h);if(ie(p)){ae(f,p);return}M(re(b,k))},I=a=>{a.preventDefault();const h=a.currentTarget,f=new FormData(h),c={id:E(f,"id"),provider:E(f,"provider"),mode:E(f,"mode"),email:E(f,"email")},k=ce(b,c);if(ie(k)){ae(h,k);return}M(re(b,c)),h.reset()},x=(a,h,f,c)=>{if(typeof window>"u")return;const k=f==="token"?"token":"API key",p=window.prompt(`Paste ${a} ${k} for ${h}`,"")?.trim();p&&s.onStoreProfileCredential({profileId:h,provider:a,mode:f,secret:p,...c?{email:c}:{}})},_=a=>{typeof window<"u"&&!window.confirm(`Clear the stored credential for "${a}"?`)||s.onClearProfileCredential(a)},S=(a,h)=>{s.onRunInteractiveProfileAuth({profileId:h,provider:a})},F=a=>{!a?.url||typeof window>"u"||ke(a.url)};return n`
    <section class="card" style="margin-bottom: 16px;">
      <div class="row" style="justify-content: space-between; gap: 12px; align-items: flex-start;">
        <div>
          <div class="card-title">Provider Auth</div>
          <div class="card-sub">
            Review configured provider credentials, auth profiles, and model coverage before editing the raw config.
          </div>
        </div>
        <div class="row" style="gap: 8px; flex-wrap: wrap;">
          <button
            class="btn btn--sm ${v?"primary":""}"
            @click=${()=>o("auth")}
          >
            Open Authentication
          </button>
          <button
            class="btn btn--sm ${m?"primary":""}"
            @click=${()=>o("models")}
          >
            Open Models
          </button>
        </div>
      </div>

      <div class="chip-row" style="margin-top: 12px;">
        <span class="chip">${e.totalProviders} providers</span>
        <span class="chip">${e.totalProfiles} auth profiles</span>
        ${e.gatewayAuthMode?n`<span class="chip">gateway ${e.gatewayAuthMode}</span>`:d}
        ${e.profileModeCounts.api_key>0?n`<span class="chip">${e.profileModeCounts.api_key} api_key</span>`:d}
        ${e.profileModeCounts.oauth>0?n`<span class="chip">${e.profileModeCounts.oauth} oauth</span>`:d}
        ${e.profileModeCounts.token>0?n`<span class="chip">${e.profileModeCounts.token} token</span>`:d}
        ${t?.storePath?n`<span class="chip">store ${t.storePath}</span>`:d}
        ${i?n`
                <span class="chip">${i.totalProviders} catalog providers</span>
                <span class="chip">${i.totalModels} catalog models</span>
                <span class="chip">${i.configuredProviders} configured</span>
                <span class="chip">${i.availableProviders} available</span>
                ${i.reasoningModels>0?n`<span class="chip">${i.reasoningModels} reasoning</span>`:d}
                ${i.visionModels>0?n`<span class="chip">${i.visionModels} vision</span>`:d}
                ${$.map(([a,h])=>n`<span class="chip">${a} ${h}</span>`)}
              `:n`
                <span class="chip chip-warn">catalog unavailable</span>
              `}
      </div>

      ${m&&y?n`
              <div class="list-sub" style="margin-top: 10px">
                Available providers not configured: ${y}
              </div>
            `:d}

      ${t?n`
              <div class="list-sub" style="margin-top: 10px">
                Live credential status reflects the currently applied runtime. Unsaved config edits will not show
                here until you save or apply.
              </div>
            `:n`
              <div class="list-sub" style="margin-top: 10px">
                Live credential status is unavailable right now. Profile edits still update config immediately.
              </div>
            `}

      ${l?n`
              <div
                class=${ue(l.tone)}
                style="margin-top: 12px"
              >
                <strong>${l.title}</strong>
                <div style="margin-top: 4px">${l.message}</div>
                ${u?n`
                        <div class="list-sub" style="margin-top: 6px;">
                          Summary: ${u}
                        </div>
                      `:d}
                <div class="chip-row" style="margin-top: 8px;">
                  ${l.active?n`
                          <span class="chip chip-ok">in progress</span>
                        `:d}
                  ${j(l)?n`
                          <span class="chip">${j(l)}</span>
                        `:d}
                  ${l.hasUrl?n`
                          <span class="chip">browser link</span>
                        `:d}
                  ${K(l)?n`
                          <span class="chip chip-warn">retry available</span>
                        `:d}
                </div>
                ${l.detail?n`
                        <div class="list-sub" style="margin-top: 6px;">${l.detail}</div>
                      `:d}
                ${g.length>0?n`
                        <div class="list-sub" style="margin-top: 8px;">What happens next</div>
                        <ul style="margin: 6px 0 0 18px; padding: 0;">
                          ${g.map(a=>n`
                              <li class="list-sub" style="margin-top: 4px;">${a}</li>
                            `)}
                        </ul>
                      `:d}
              </div>
            `:d}

      ${r?n`
              <div class="list" style="margin-top: 12px;">
                ${e.providers.map(a=>{const h=Ue(a),f=ve(t,a.id);return n`
                      <div class="list-item">
                        <div class="list-main">
                        <div class="list-title">${a.id}</div>
                        <div class="list-sub">
                          ${a.modelCount} model${a.modelCount===1?"":"s"}
                          ${a.authMode?n` · auth ${a.authMode}`:d}
                          ${a.hasApiKey?n`
                                  · apiKey set
                                `:d}
                        </div>
                        <div class="chip-row" style="margin-top: 8px;">
                        ${f?n`
                                <span class=${L(f.status)}>
                                  ${f.status}
                                </span>
                                <span class="chip">
                                  ${f.effective.kind} · ${f.effective.detail}
                                </span>
                              `:d}
                        ${h.length>0?h.map(c=>n`
                                    <span class="chip">
                                      ${c.id} · ${c.mode}${c.email?` · ${c.email}`:""}
                                    </span>
                                  `):n`
                                <span class="chip">no auth profiles</span>
                              `}
                          ${a.orderedProfileIds.map(c=>n`
                                <span class="chip chip-ok">order ${c}</span>
                              `)}
                        </div>
                        ${se(a).length>0?n`
                                <div class="row" style="gap: 8px; margin-top: 10px; flex-wrap: wrap;">
                                  ${se(a).map(c=>n`
                                      <button
                                        class="btn btn--sm ${a.authMode===c?"primary":""}"
                                        @click=${()=>s.onFormPatch(["models","providers",a.id,"auth"],c)}
                                      >
                                        ${a.authMode===c?`Auth: ${c}`:`Use ${c}`}
                                      </button>
                                    `)}
                                </div>
                              `:d}
                        ${a.profiles.length>0?n`
                                <div class="row" style="gap: 8px; margin-top: 8px; flex-wrap: wrap;">
                                  ${h.map(c=>n`
                                      <button
                                        class="btn btn--sm ${a.orderedProfileIds[0]===c.id?"primary":""}"
                                        @click=${()=>s.onFormPatch(["auth","order",a.id],oe(a,c.id))}
                                      >
                                        ${a.orderedProfileIds[0]===c.id?`Preferred ${c.id}`:`Prefer ${c.id}`}
                                      </button>
                                    `)}
                                </div>
                              `:d}
                        ${a.profiles.length>0?n`
                                <div style="display: grid; gap: 10px; margin-top: 12px;">
                                  ${h.map((c,k)=>{const p=a.orderedProfileIds[0]===c.id,C=Ge(t,a.id,c.id),D=H(c.mode),Q=Ne({provider:a.id,profileId:c.id,mode:D}),U=Ve(D)?D:null,N=ze(D),R=s.authActionBusyProfileId===c.id,w=s.authAction?.profileId===c.id?s.authAction:null,J=pe(w),X=he(w);return n`
                                      <details class="card" style="padding: 12px;">
                                        <summary style="cursor: pointer; list-style: none;">
                                          <div
                                            class="row"
                                            style="justify-content: space-between; gap: 10px; align-items: center;"
                                          >
                                            <div>
                                              <div class="list-title">${c.id}</div>
                                              <div class="list-sub">
                                                ${c.mode}${c.email?` · ${c.email}`:""}
                                              </div>
                                              ${C?n`
                                                      <div class="list-sub" style="margin-top: 4px;">
                                                        ${C.label}
                                                      </div>
                                                    `:d}
                                            </div>
                                            <div class="chip-row">
                                              ${C?n`
                                                      <span
                                                        class=${L(C.status)}
                                                      >
                                                        ${de(C)}
                                                      </span>
                                                    `:n`
                                                      <span class="chip chip-warn">runtime unknown</span>
                                                    `}
                                              <span class="chip">order ${k+1}/${h.length}</span>
                                              ${p?n`
                                                      <span class="chip chip-ok">preferred</span>
                                                    `:d}
                                            </div>
                                          </div>
                                        </summary>
                                        <div style="display: grid; gap: 10px; margin-top: 12px;">
                                          <div class="list-sub">
                                            Expand to manage this profile directly from Config.
                                          </div>
                                          ${w?n`
                                                  <div
                                                    class=${ue(w.tone)}
                                                  >
                                                    <strong>${w.title}</strong>
                                                    <div style="margin-top: 4px">
                                                      ${w.message}
                                                    </div>
                                                    ${J?n`
                                                            <div
                                                              class="list-sub"
                                                              style="margin-top: 6px;"
                                                            >
                                                              Summary: ${J}
                                                            </div>
                                                          `:d}
                                                    <div class="chip-row" style="margin-top: 8px;">
                                                      ${w.active?n`
                                                              <span class="chip chip-ok">in progress</span>
                                                            `:d}
                                                      ${j(w)?n`
                                                              <span class="chip">
                                                                ${j(w)}
                                                              </span>
                                                            `:d}
                                                      ${w.hasUrl?n`
                                                              <span class="chip">browser link</span>
                                                            `:d}
                                                      ${K(w)?n`
                                                              <span class="chip chip-warn"> retry available </span>
                                                            `:d}
                                                    </div>
                                                    ${w.detail?n`
                                                            <div
                                                              class="list-sub"
                                                              style="margin-top: 6px;"
                                                            >
                                                              ${w.detail}
                                                            </div>
                                                          `:d}
                                                    ${X.length>0?n`
                                                            <div
                                                              class="list-sub"
                                                              style="margin-top: 8px;"
                                                            >
                                                              What happens next
                                                            </div>
                                                            <ul
                                                              style="margin: 6px 0 0 18px; padding: 0;"
                                                            >
                                                              ${X.map(A=>n`
                                                                  <li
                                                                    class="list-sub"
                                                                    style="margin-top: 4px;"
                                                                  >
                                                                    ${A}
                                                                  </li>
                                                                `)}
                                                            </ul>
                                                          `:d}
                                                    <div
                                                      class="row"
                                                      style="gap: 8px; margin-top: 10px; flex-wrap: wrap;"
                                                    >
                                                      ${We(w)?n`
                                                              <button
                                                                type="button"
                                                                class="btn btn--sm"
                                                                @click=${()=>F(w)}
                                                              >
                                                                Open sign-in page again
                                                              </button>
                                                            `:d}
                                                      ${N&&K(w)?n`
                                                              <button
                                                                type="button"
                                                                class="btn btn--sm primary"
                                                                ?disabled=${R}
                                                                @click=${()=>S(a.id,c.id)}
                                                              >
                                                                Retry sign-in
                                                              </button>
                                                            `:d}
                                                    </div>
                                                  </div>
                                                `:d}
                                          <div class="card" style="padding: 12px;">
                                            <div class="list-title">Credential status</div>
                                            <div class="chip-row" style="margin-top: 8px;">
                                              ${C?n`
                                                      <span
                                                        class=${L(C.status)}
                                                      >
                                                        ${de(C)}
                                                      </span>
                                                      <span class="chip">${C.type}</span>
                                                      <span class="chip">${C.source}</span>
                                                      ${f?n`
                                                              <span class="chip">
                                                                ${f.effective.kind}
                                                              </span>
                                                            `:d}
                                                    `:n`
                                                      <span class="chip chip-warn">No live credential data</span>
                                                    `}
                                            </div>
                                            ${C?.unusableReason?n`
                                                    <div class="list-sub" style="margin-top: 8px;">
                                                      Last reason: ${C.unusableReason}
                                                    </div>
                                                  `:d}
                                            ${f?n`
                                                    <div class="list-sub" style="margin-top: 8px;">
                                                      Effective source: ${f.effective.detail}
                                                    </div>
                                                  `:d}
                                            <div
                                              class="row"
                                              style="gap: 8px; margin-top: 10px; flex-wrap: wrap;"
                                            >
                                              ${U?n`
                                                      <button
                                                        type="button"
                                                        class="btn btn--sm primary"
                                                        ?disabled=${R}
                                                        @click=${()=>x(a.id,c.id,U,c.email)}
                                                      >
                                                        ${R?"Saving…":Le(U)}
                                                      </button>
                                                      <button
                                                        type="button"
                                                        class="btn btn--sm"
                                                        ?disabled=${R}
                                                        @click=${()=>_(c.id)}
                                                      >
                                                        ${R?"Working…":"Clear stored credential"}
                                                      </button>
                                                    `:d}
                                              ${!U&&N?n`
                                                      <button
                                                        type="button"
                                                        class="btn btn--sm primary"
                                                        ?disabled=${R}
                                                        @click=${()=>S(a.id,c.id)}
                                                      >
                                                        ${Ke(R,w)}
                                                      </button>
                                                    `:d}
                                              ${N?n`
                                                      <button
                                                        type="button"
                                                        class="btn btn--sm"
                                                        ?disabled=${R}
                                                        @click=${()=>_(c.id)}
                                                      >
                                                        ${R?"Working…":"Clear stored credential"}
                                                      </button>
                                                    `:d}
                                              <button
                                                type="button"
                                                class="btn btn--sm"
                                                @click=${()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(Q).catch(()=>{})}}
                                              >
                                                Copy terminal command
                                              </button>
                                              <code style="word-break: break-all;">${Q}</code>
                                            </div>
                                          </div>
                                          <div class="row" style="gap: 8px; flex-wrap: wrap;">
                                            <button
                                              type="button"
                                              class="btn btn--sm"
                                              ?disabled=${k===0}
                                              @click=${()=>M(le(b,a.id,c.id,"up"))}
                                            >
                                              Move up
                                            </button>
                                            <button
                                              type="button"
                                              class="btn btn--sm"
                                              ?disabled=${k===h.length-1}
                                              @click=${()=>M(le(b,a.id,c.id,"down"))}
                                            >
                                              Move down
                                            </button>
                                            <button
                                              type="button"
                                              class="btn btn--sm ${p?"primary":""}"
                                              @click=${()=>s.onFormPatch(["auth","order",a.id],oe(a,c.id))}
                                            >
                                              ${p?"Preferred profile":"Make preferred"}
                                            </button>
                                            <button
                                              type="button"
                                              class="btn btn--sm"
                                              @click=${()=>M(He(b,c.id))}
                                            >
                                              Remove
                                            </button>
                                          </div>
                                          <form
                                            style="display: grid; gap: 10px;"
                                            @submit=${A=>B(A,c.id)}
                                          >
                                            <div
                                              style="display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));"
                                            >
                                              <label style="display: grid; gap: 6px;">
                                                <span class="list-sub">Provider</span>
                                                <input
                                                  class="input"
                                                  name="provider"
                                                  .value=${a.id}
                                                  required
                                                  @input=${A=>T(A.currentTarget)}
                                                />
                                              </label>
                                              <label style="display: grid; gap: 6px;">
                                                <span class="list-sub">Mode</span>
                                                <select
                                                  class="input"
                                                  name="mode"
                                                  @change=${A=>T(A.currentTarget)}
                                                >
                                                  ${G.map(A=>n`
                                                      <option
                                                        value=${A}
                                                        ?selected=${H(c.mode)===A}
                                                      >
                                                        ${A}
                                                      </option>
                                                    `)}
                                                </select>
                                              </label>
                                              <label style="display: grid; gap: 6px;">
                                                <span class="list-sub">Email</span>
                                                <input
                                                  class="input"
                                                  name="email"
                                                  type="email"
                                                  .value=${c.email??""}
                                                  placeholder="optional"
                                                  @input=${A=>T(A.currentTarget)}
                                                />
                                              </label>
                                            </div>
                                            <div class="row" style="gap: 8px; justify-content: flex-end;">
                                              <button type="submit" class="btn btn--sm primary">
                                                Save profile
                                              </button>
                                            </div>
                                          </form>
                                        </div>
                                      </details>
                                    `})}
                                </div>
                              `:d}
                      </div>
                    </div>
                    `})}
              </div>
            `:n`
              <div class="callout info" style="margin-top: 12px">
                No provider auth is configured yet. Start in <strong>Authentication</strong> to add profiles, then
                use <strong>Models</strong> to choose Agent model refs.
              </div>
            `}

      <form
        class="card"
        style="margin-top: 12px; padding: 12px; display: grid; gap: 10px;"
        @submit=${I}
      >
        <div>
          <div class="list-title">Add auth profile</div>
          <div class="list-sub">
            Create a provider auth profile without leaving the Config tab.
          </div>
        </div>
        <div
          style="display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));"
        >
          <label style="display: grid; gap: 6px;">
            <span class="list-sub">Profile id</span>
            <input
              class="input"
              name="id"
              placeholder="provider:profile"
              required
              @input=${a=>T(a.currentTarget)}
            />
          </label>
          <label style="display: grid; gap: 6px;">
            <span class="list-sub">Provider</span>
            <input
              class="input"
              name="provider"
              placeholder="openai"
              required
              @input=${a=>T(a.currentTarget)}
            />
          </label>
          <label style="display: grid; gap: 6px;">
            <span class="list-sub">Mode</span>
            <select
              class="input"
              name="mode"
              @change=${a=>T(a.currentTarget)}
            >
              ${G.map(a=>n`
                  <option value=${a} ?selected=${a==="api_key"}>${a}</option>
                `)}
            </select>
          </label>
          <label style="display: grid; gap: 6px;">
            <span class="list-sub">Email</span>
            <input
              class="input"
              name="email"
              type="email"
              placeholder="optional"
              @input=${a=>T(a.currentTarget)}
            />
          </label>
        </div>
        <div class="list-sub">
          Profile ids must be unique, whitespace-free, and should follow the provider prefix pattern
          (for example <code>openai:manual</code>).
        </div>
        <div class="row" style="gap: 8px; justify-content: flex-end;">
          <button type="submit" class="btn btn--sm primary">Add profile</button>
        </div>
      </form>
    </section>
  `}function Xe(e){const t=e.valid==null?"unknown":e.valid?"valid":"invalid",i=me(e.schema),s=i.schema?i.unsupportedPaths.length>0:!1,o=i.schema&&W(i.schema)==="object"&&i.schema.properties?{...i.schema,properties:Object.fromEntries(Object.entries(i.schema.properties).filter(([p])=>!V.has(p)))}:i.schema,r=e.activeSection&&!V.has(e.activeSection)?e.activeSection:null,l=o?.properties??{},u=ee.filter(p=>!V.has(p.key)&&p.key in l),g=new Set(ee.map(p=>p.key)),v=Object.keys(l).filter(p=>!g.has(p)).map(p=>({key:p,label:q(p,l[p]).label})),m=[...u,...v],b=r&&o&&W(o)==="object"?o.properties?.[r]:void 0,O=r?q(r,b):null,$=r?Re({key:r,schema:b,uiHints:e.uiHints}):[],y=e.formMode==="form"&&!!r&&$.length>0,M=e.activeSubsection===te,B=e.searchQuery||M?null:e.activeSubsection??$[0]?.key??null,I=e.formMode==="form"?Ie(e.originalValue,e.formValue):[],x=e.formMode==="raw"&&e.raw!==e.originalRaw,_=e.formMode==="form"?I.length>0:x,S=!!e.formValue&&!e.loading&&!!i.schema,F=e.connected&&!e.saving&&_&&(e.formMode==="raw"?!0:S),a=e.connected&&!e.applying&&!e.updating&&_&&(e.formMode==="raw"?!0:S),h=e.formMode==="form"?Oe(e.formValue??e.originalValue):null,f=h&&(r==="auth"||r==="models")?h:null,c=_?"dirty":t==="valid"?"valid":t==="invalid"?"invalid":"unknown",k=_?"Unsaved changes":t==="valid"?"Config valid":t==="invalid"?"Config invalid":"Config status unknown";return n`
    <div class="config-layout">
      <!-- Sidebar -->
      <aside class="config-sidebar">
        <div class="config-sidebar__header">
          <div class="config-sidebar__title">Sections</div>
          <div class="config-sidebar__header-tools">
            <span
              class="config-status-dot config-status-dot--${c}"
              title=${k}
              aria-label=${k}
            ></span>
            <div class="config-mode-toggle" aria-label="Config editor mode">
              <button
                class="config-mode-toggle__btn ${e.formMode==="form"?"active":""}"
                type="button"
                title="Form"
                aria-label="Form"
                ?disabled=${e.schemaLoading||!e.schema}
                @click=${()=>e.onFormModeChange("form")}
              >
                ${Z.fileText}
              </button>
              <button
                class="config-mode-toggle__btn ${e.formMode==="raw"?"active":""}"
                type="button"
                title="Raw"
                aria-label="Raw"
                @click=${()=>e.onFormModeChange("raw")}
              >
                ${Z.fileCode}
              </button>
            </div>
          </div>
        </div>

        <!-- Search -->
        <div class="config-search">
          <div class="config-search__input-row">
            <svg
              class="config-search__icon"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
            >
              <circle cx="11" cy="11" r="8"></circle>
              <path d="M21 21l-4.35-4.35"></path>
            </svg>
            <input
              type="text"
              class="config-search__input"
              placeholder="Search settings..."
              .value=${e.searchQuery}
              @input=${p=>e.onSearchChange(p.target.value)}
            />
            ${e.searchQuery?n`
                  <button
                    class="config-search__clear"
                    @click=${()=>e.onSearchChange("")}
                  >
                    ×
                  </button>
                `:d}
          </div>
        </div>

        <!-- Section nav -->
        <nav class="config-nav">
          ${m.map(p=>n`
              <button
                class="config-nav__item ${r===p.key?"active":""}"
                @click=${()=>e.onSectionChange(p.key)}
              >
                <span class="config-nav__icon"
                  >${ge(p.key)}</span
                >
                <span class="config-nav__label">${p.label}</span>
              </button>
            `)}
        </nav>

        <!-- Mode toggle at bottom -->
        <div class="config-sidebar__footer">
          <div class="config-sidebar__actions">
            <button
              class="btn btn--sm"
              ?disabled=${e.loading}
              @click=${e.onReload}
            >
              ${e.loading?"Loading…":"Reload"}
            </button>
            <button
              class="btn btn--sm primary"
              ?disabled=${!F}
              @click=${e.onSave}
            >
              ${e.saving?"Saving…":"Save"}
            </button>
            <button
              class="btn btn--sm"
              ?disabled=${!a}
              @click=${e.onApply}
            >
              ${e.applying?"Applying…":"Apply"}
            </button>
          </div>
        </div>
      </aside>

      <!-- Main content -->
      <main class="config-main">
        ${e.error?n`
                <div class="callout danger" style="margin-top: 12px;">
                  ${e.error}
                </div>
              `:d}
        ${e.loading&&!e.formValue?n`
                <div class="callout info" style="margin-top: 12px">Loading config…</div>
              `:d}

        <!-- Diff panel (form mode only - raw mode doesn't have granular diff) -->
        ${_&&e.formMode==="form"?n`
              <details class="config-diff">
                <summary class="config-diff__summary">
                  <span
                    >View ${I.length} pending
                    change${I.length!==1?"s":""}</span
                  >
                  <svg
                    class="config-diff__chevron"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                  >
                    <polyline points="6 9 12 15 18 9"></polyline>
                  </svg>
                </summary>
                <div class="config-diff__content">
                  ${I.map(p=>n`
                      <div class="config-diff__item">
                        <div class="config-diff__path">${p.path}</div>
                        <div class="config-diff__values">
                          <span class="config-diff__from"
                            >${ne(p.from)}</span
                          >
                          <span class="config-diff__arrow">→</span>
                          <span class="config-diff__to"
                            >${ne(p.to)}</span
                          >
                        </div>
                      </div>
                    `)}
                </div>
              </details>
            `:d}
        ${O&&e.formMode==="form"?n`
              ${Me(r,e)}
              ${Se(r)}
            `:d}
        ${y?n`
              <div class="config-subnav">
                <button
                  class="config-subnav__item ${B===null?"active":""}"
                  @click=${()=>e.onSubsectionChange(te)}
                >
                  All
                </button>
                ${$.map(p=>n`
                    <button
                      class="config-subnav__item ${B===p.key?"active":""}"
                      title=${p.description||p.label}
                      @click=${()=>e.onSubsectionChange(p.key)}
                    >
                      ${p.label}
                    </button>
                  `)}
              </div>
            `:d}

        <!-- Form content -->
        <div class="config-content">
          ${f?qe(f,e.authStatus,e.modelCatalogStatus,{activeSection:r,authActionBusyProfileId:e.authActionBusyProfileId,authAction:e.authAction,onClearProfileCredential:e.onClearProfileCredential,onFormPatch:e.onFormPatch,onRunInteractiveProfileAuth:e.onRunInteractiveProfileAuth,onSectionChange:e.onSectionChange,onStoreProfileCredential:e.onStoreProfileCredential,onSubsectionChange:e.onSubsectionChange}):d}
          ${e.formMode==="form"?n`
                ${e.schemaLoading?n`
                        <div class="config-loading">
                          <div class="config-loading__spinner"></div>
                          <span>Loading schema…</span>
                        </div>
                      `:r===null?_e({sections:m,schemaProps:l,props:e}):be({schema:o,uiHints:e.uiHints,value:e.formValue,disabled:e.loading||!e.formValue,unsupportedPaths:i.unsupportedPaths,onPatch:e.onFormPatch,searchQuery:e.searchQuery,activeSection:r,activeSubsection:B})}
                ${s&&r!==null?n`
                        <div class="callout danger" style="margin-top: 12px">
                          Form view can't safely edit some fields. Use Raw to avoid losing config entries.
                        </div>
                      `:d}
              `:n`
                <label class="field config-raw-field">
                  <span>Raw JSON5</span>
                  <textarea
                    .value=${e.raw}
                    @input=${p=>e.onRawChange(p.target.value)}
                  ></textarea>
                </label>
              `}
        </div>

        ${e.issues.length>0?n`<div class="callout danger" style="margin-top: 12px;">
              <pre class="code-block">
${JSON.stringify(e.issues,null,2)}</pre
              >
            </div>`:d}
      </main>
    </div>
  `}export{Ue as buildOrderedProviderProfiles,oe as buildPreferredProviderOrder,Ne as buildProviderAuthActionCommand,he as buildProviderAuthActionGuidance,pe as buildProviderAuthActionSummary,je as buildProviderAuthState,Oe as buildProviderAuthSummary,ue as calloutClassForProviderAuthActionTone,We as canReopenProviderAuthActionUrl,K as canRetryProviderAuthAction,de as formatProviderAuthRuntimeStatus,Ke as labelForInteractiveProviderAuthAction,j as labelForProviderAuthActionStep,le as moveProviderAuthProfile,He as removeProviderAuthProfile,Xe as renderConfig,se as resolveEditableProviderAuthModes,Ge as resolveProviderAuthLiveProfileStatus,re as upsertProviderAuthProfile,ce as validateProviderAuthProfileDraft};
//# sourceMappingURL=config-D5fCHJGy.js.map
