<div
  style="
    display: flex;
    flex-direction: column;
    position: relative;
    width: stretch;
    height: 100%;
  "
>
  <div>
    <div style="display: flex">
      <div>
        @if(!icon.svgIcon) {
        <mat-icon [class]="icon.class">{{icon.name}}</mat-icon>
        } @else {
        <mat-icon [svgIcon]="icon.svgIcon"></mat-icon>
        }
      </div>
      <div>
        &nbsp; @if(_region().feature.properties?.skIcon === 'hazard') {
        {{'Hazardous '}} } Region
      </div>
    </div>

    <mat-divider></mat-divider>

    <div style="display: flex">
      <div>
        <button
          mat-button
          [disabled]="_region()?.feature?.properties?.readOnly || interacting()"
          (click)="onEdit()"
          matTooltip="Edit Region"
        >
          <mat-icon>edit</mat-icon>
          EDIT
        </button>
        &nbsp;
        <button
          mat-button
          [disabled]="interacting()"
          (click)="onPanTo()"
          matTooltip="Center Region"
        >
          <mat-icon>center_focus_strong</mat-icon>
          CENTER
        </button>
        &nbsp;
        <button
          mat-button
          [disabled]="_region()?.feature?.properties?.readOnly || interacting()"
          (click)="onDelete()"
          matTooltip="Delete Region"
        >
          <mat-icon>delete</mat-icon>
          DELETE
        </button>
      </div>
    </div>

    <mat-divider></mat-divider>

    <div
      style="
        display: flex;
        flex-direction: column;
        padding-left: 5px;
        padding-top: 15px;
      "
    >
      <div style="font-weight: bold; font-size: larger; padding-bottom: 5px">
        {{_region()?.name}}
      </div>
    </div>
  </div>

  <remark
    [processor]="mdProcessor"
    [markdown]="_region().description"
    style="flex: 2 1 auto; overflow-y: auto; padding-left: 5px"
  >
    <ng-template remarkTemplate="heading" let-node>
      @if(node.depth === 1) {
      <h1 [remarkNode]="node" style="font-size: 14pt"></h1>
      } @if(node.depth === 2) {
      <h2 [remarkNode]="node" style="font-size: 12pt"></h2>
      } @if(node.depth === 3) {
      <h3 [remarkNode]="node" style="font-size: 10pt"></h3>
      } @if(node.depth === 4) {
      <h4 [remarkNode]="node" style="font-size: 8pt"></h4>
      }
    </ng-template>
  </remark>

  <mat-divider></mat-divider>
  <mat-accordion>
    <mat-expansion-panel>
      <mat-expansion-panel-header>
        <mat-panel-title>
          <mat-icon>local_offer</mat-icon>
          &nbsp;Notes:
        </mat-panel-title>
        <mat-panel-description>
          ({{this.notes().length}})
          <button
            matIconButton
            matTooltip="Add Note"
            [disabled]="interacting()"
            (click)="addNote()"
          >
            <mat-icon>add</mat-icon>
          </button>
        </mat-panel-description>
      </mat-expansion-panel-header>
      @if(this.notes().length){
      <mat-nav-list
        style="min-height: 50px; max-height: 200px; overflow-y: auto"
      >
        @for( note of notes(); track note[0]) {
        <a mat-list-item (click)="showNote(note[0])">
          <span matListItemTitle> {{note[1].name}}</span>
        </a>
        }
      </mat-nav-list>
      }
    </mat-expansion-panel>
    <mat-expansion-panel>
      <mat-expansion-panel-header>
        <mat-panel-title>
          <mat-icon>category</mat-icon>
          &nbsp;Groups:
        </mat-panel-title>
        <mat-panel-description>
          ({{this.groups().length}}) @if(app.featureFlags().resourceGroups) {
          <button
            matIconButton
            matTooltip="Add to Group"
            [disabled]="interacting()"
            (click)="addToGroup()"
          >
            <mat-icon>add</mat-icon>
          </button>
          }
        </mat-panel-description>
      </mat-expansion-panel-header>
      @if(this.groups().length){
      <mat-nav-list
        style="min-height: 50px; max-height: 200px; overflow-y: auto"
      >
        @for( group of groups(); track group[0]) {
        <a mat-list-item (click)="skgroups.editGroupInfo(group[0])">
          <span matListItemTitle> {{group[1].name}}</span>
        </a>
        }
      </mat-nav-list>
      }
    </mat-expansion-panel>
  </mat-accordion>
</div>
