// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import type {CharacterSetInsightModel} from '../../../../models/trace/insights/CharacterSet.js';
import type * as Trace from '../../../../models/trace/trace.js';
import * as UI from '../../../../ui/legacy/legacy.js';
import * as Lit from '../../../../ui/lit/lit.js';

import {BaseInsightComponent} from './BaseInsightComponent.js';
import {Checklist} from './Checklist.js';

const {html} = Lit;
const {widget} = UI.Widget;

export class CharacterSet extends BaseInsightComponent<CharacterSetInsightModel> {
  override internalName = 'character-set';

  protected override hasAskAiSupport(): boolean {
    return true;
  }

  override getEstimatedSavingsTime(): Trace.Types.Timing.Milli|null {
    return this.model?.metricSavings?.FCP ?? null;
  }

  override renderContent(): Lit.LitTemplate {
    if (!this.model?.data) {
      return Lit.nothing;
    }

    return html`${widget(Checklist, {checklist: this.model.data.checklist})}`;
  }
}
