import{m as e,p as t}from"./lit-runtime-BImxIzGR.js";import{o as n,t as r}from"./string-coerce-CWuDdnrG.js";var i=[`trace`,`debug`,`info`,`warn`,`error`,`fatal`];function a(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function o(e,t){return t?r([e.message,e.subsystem,e.raw].filter(Boolean).join(` `)).includes(t):!0}function s(s){let c=r(s.filterText),l=i.some(e=>!s.levelFilters[e]),u=s.entries.filter(e=>e.level&&!s.levelFilters[e.level]?!1:o(e,c)),d=c||l?`filtered`:`visible`;return e`
    <section class="card card--fill-height">
      <div class="row" style="justify-content: space-between;">
        <div>
          <div class="card-title">日志</div>
          <div class="card-sub">网关文件日志 (JSONL)。</div>
        </div>
        <div class="row" style="gap: 8px;">
          <button class="btn" ?disabled=${s.loading} @click=${s.onRefresh}>
            ${s.loading?n(`common.loading`):n(`common.refresh`)}
          </button>
          <button
            class="btn"
            ?disabled=${u.length===0}
            @click=${()=>s.onExport(u.map(e=>e.raw),d)}
          >
            导出 ${d}
          </button>
        </div>
      </div>

      <div class="filters" style="margin-top: 14px;">
        <label class="field" style="min-width: 220px;">
          <span>筛选</span>
          <input
            .value=${s.filterText}
            @input=${e=>s.onFilterTextChange(e.target.value)}
            placeholder="搜索日志"
          />
        </label>
        <label class="field checkbox">
          <span>自动跟踪</span>
          <input
            type="checkbox"
            .checked=${s.autoFollow}
            @change=${e=>s.onToggleAutoFollow(e.target.checked)}
          />
        </label>
      </div>

      <div class="chip-row" style="margin-top: 12px;">
        ${i.map(t=>e`
            <label class="chip log-chip ${t}">
              <input
                type="checkbox"
                .checked=${s.levelFilters[t]}
                @change=${e=>s.onLevelToggle(t,e.target.checked)}
              />
              <span>${t}</span>
            </label>
          `)}
      </div>

      ${s.file?e`<div class="muted" style="margin-top: 10px;">File: ${s.file}</div>`:t}
      ${s.truncated?e`
            <div class="callout" style="margin-top: 10px">
              日志输出已截断；显示最新部分。
            </div>
          `:t}
      ${s.error?e`<div class="callout danger" style="margin-top: 10px;">${s.error}</div>`:t}

      <div class="log-stream" style="margin-top: 12px;" @scroll=${s.onScroll}>
        ${u.length===0?e` <div class="muted" style="padding: 12px">暂无日志条目。</div> `:u.map(t=>e`
                <div class="log-row">
                  <div class="log-time mono">${a(t.time)}</div>
                  <div class="log-level ${t.level??``}">${t.level??``}</div>
                  <div class="log-subsystem mono">${t.subsystem??``}</div>
                  <div class="log-message mono">${t.message??t.raw}</div>
                </div>
              `)}
      </div>
    </section>
  `}export{s as renderLogs};
//# sourceMappingURL=logs-hkZQ5Nnv.js.map