import*as i18n from"../../../core/i18n/i18n.js";import*as LitHtml from"../../lit-html/lit-html.js";import*as ComponentHelpers from"../helpers/helpers.js";import*as IconButton from"../icon_button/icon_button.js";import linearMemoryHighlightChipListStyles from"./linearMemoryHighlightChipList.css.js";const UIStrings={jumpToAddress:"Jump to this memory",deleteHighlight:"Stop highlighting this memory"},str_=i18n.i18n.registerUIStrings("ui/components/linear_memory_inspector/LinearMemoryHighlightChipList.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_),{render:render,html:html}=LitHtml;export class DeleteMemoryHighlightEvent extends Event{static eventName="deletememoryhighlight";data;constructor(t){super(DeleteMemoryHighlightEvent.eventName,{bubbles:!0,composed:!0}),this.data=t}}export class JumpToHighlightedMemoryEvent extends Event{static eventName="jumptohighlightedmemory";data;constructor(t){super(JumpToHighlightedMemoryEvent.eventName),this.data=t}}export class LinearMemoryHighlightChipList extends HTMLElement{static litTagName=LitHtml.literal`devtools-linear-memory-highlight-chip-list`;#t=this.attachShadow({mode:"open"});#i=[];#e;connectedCallback(){this.#t.adoptedStyleSheets=[linearMemoryHighlightChipListStyles]}set data(t){this.#i=t.highlightInfos,this.#e=t.focusedMemoryHighlight,this.#s()}#s(){const t=[];for(const i of this.#i)t.push(this.#h(i));const i=html`
            <div class="highlight-chip-list">
              ${t}
            </div>
        `;render(i,this.#t,{host:this})}#h(t){const i=t.name||"<anonymous>",e=t.type,s={focused:t===this.#e,"highlight-chip":!0};return html`
      <div class=${LitHtml.Directives.classMap(s)}>
        <button class="jump-to-highlight-button" title=${i18nString(UIStrings.jumpToAddress)}
            @click=${()=>this.#o(t.startAddress)}>
          <span class="source-code">
            <span class="value">${i}</span><span class="separator">: </span><span>${e}</span>
          </span>
        </button>
        <div class="delete-highlight-container">
          <button class="delete-highlight-button" title=${i18nString(UIStrings.deleteHighlight)} @click=${()=>this.#n(t)}>
            <${IconButton.Icon.Icon.litTagName} .data=${{iconName:"cross",color:"var(--icon-default-hover)",width:"16px"}}>
            </${IconButton.Icon.Icon.litTagName}>
          </button>
        </div>
      </div>
    `}#o(t){this.dispatchEvent(new JumpToHighlightedMemoryEvent(t))}#n(t){this.dispatchEvent(new DeleteMemoryHighlightEvent(t))}}ComponentHelpers.CustomElements.defineComponent("devtools-linear-memory-highlight-chip-list",LinearMemoryHighlightChipList);