<!--

    Copyright © 2016-2022 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div
   (dblclick)="userNodeCallbacks.doubleClick($event, node)"
   (mousedown)="userNodeCallbacks.mouseDown($event, node)"
   (mouseenter)="userNodeCallbacks.mouseEnter($event, node)"
   (mouseleave)="userNodeCallbacks.mouseLeave($event, node)">
  <div class="fc-node-overlay"></div>
  <div class="tb-rule-node {{node.nodeClass}}"
       [ngClass]="{'tb-rule-node-highlighted' : node.highlighted,
                   'tb-rule-node-invalid': node.error }">
    <mat-icon *ngIf="!iconUrl" fxFlex="15">{{node.icon}}</mat-icon>
    <img *ngIf="iconUrl" fxFlex="15" [src]="iconUrl"/>
    <div fxLayout="column" fxFlex="85" fxLayoutAlign="center">
      <span class="tb-node-type">{{ node.component.name }}</span>
      <span class="tb-node-title" *ngIf="node.name">{{ node.name }}</span>
    </div>
    <div class="{{flowchartConstants.leftConnectorClass}}">
      <div fc-magnet [connector]="connector" [callbacks]="callbacks"
           *ngFor="let connector of modelservice.nodes.getConnectorsByType(node, flowchartConstants.leftConnectorType)">
        <div fc-connector [connector]="connector"
             [nodeRectInfo]="nodeRectInfo"
             [mouseOverConnector]="mouseOverConnector"
             [callbacks]="callbacks"
             [modelservice]="modelservice"></div>
      </div>
    </div>
    <div class="{{flowchartConstants.rightConnectorClass}}">
      <div fc-magnet [connector]="connector" [callbacks]="callbacks"
           *ngFor="let connector of modelservice.nodes.getConnectorsByType(node, flowchartConstants.rightConnectorType)">
        <div fc-connector [connector]="connector"
             [nodeRectInfo]="nodeRectInfo"
             [mouseOverConnector]="mouseOverConnector"
             [callbacks]="callbacks"
             [modelservice]="modelservice"></div>
      </div>
    </div>
  </div>
  <section *ngIf="modelservice.isEditable() && !node.readonly">
    <div class="fc-nodeedit" (click)="userNodeCallbacks.nodeEdit($event, node)">
      <i class="fa fa-pencil" aria-hidden="true"></i>
    </div>
    <div class="fc-nodedelete" (click)="modelservice.nodes.delete(node)">
      &times;
    </div>
  </section>
  <section *ngIf="node.component?.configurationDescriptor?.nodeDefinition?.ruleChainNode && modelservice.isEditable()">
    <div class="fc-nodeopen" (click)="openRuleChain($event, node)" (mouseenter)="displayOpenRuleChainTooltip($event, node)">
      <mat-icon class="material-icons" svgIcon="mdi:login"></mat-icon>
    </div>
  </section>
</div>
