<!--

    Copyright © 2016-2026 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 class="tb-title" translate>widgets.getting-started.get-started</div>
<div class="tb-get-started-container">
  <mat-stepper #matStepper class="tb-get-started" orientation="vertical" [linear]="false"
               (selectionChange)="updateSelectedIndex($event)">
    <ng-template matStepperIcon="edit" let-index="index">
      {{ index + 1 }}
    </ng-template>
    @switch (authUser.authority) {
      @case (authority.SYS_ADMIN) {
        <mat-step [completed]="gettingStarted.maxSelectedIndex > -1">
          <ng-template matStepLabel>
            <div class="flex items-center justify-between">
              <div translate>widgets.getting-started.sys-admin.step1.title</div>
              @if (matStepper.selectedIndex === 0) {
                <a mat-button color="primary" routerLink="/tenants">{{ 'tenant.tenants' | translate }}</a>
              }
            </div>
          </ng-template>
          <div [innerHTML]="'widgets.getting-started.sys-admin.step1.content' | translate | safe: 'html'"></div>
          <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/user-guide/ui/tenants/" target="_blank">
            <mat-icon>description</mat-icon>{{ 'widgets.getting-started.sys-admin.step1.how-to-create-tenant' | translate }}</a>
          </mat-step>
          <mat-step [completed]="gettingStarted.maxSelectedIndex > 0">
            <ng-template matStepLabel>
              <div class="flex items-center justify-between">
                <div translate>widgets.getting-started.sys-admin.step2.title</div>
                @if (matStepper.selectedIndex === 1) {
                  <a mat-button color="primary" routerLink="/settings/outgoing-mail">{{ 'admin.settings' | translate }}</a>
                }
              </div>
            </ng-template>
            <div [innerHTML]="'widgets.getting-started.sys-admin.step2.content' | translate | safe: 'html'"></div>
            <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/user-guide/ui/mail-settings/" target="_blank">
              <mat-icon>description</mat-icon>{{ 'widgets.getting-started.sys-admin.step2.how-to-configure-mail-server' | translate }}</a>
            </mat-step>
            <mat-step [completed]="gettingStarted.maxSelectedIndex > 1">
              <ng-template matStepLabel>
                <div class="flex items-center justify-between">
                  <div translate>widgets.getting-started.sys-admin.step3.title</div>
                  @if (matStepper.selectedIndex === 2) {
                    <a mat-button color="primary" routerLink="/settings/notifications">{{ 'admin.settings' | translate }}</a>
                  }
                </div>
              </ng-template>
              <div [innerHTML]="'widgets.getting-started.sys-admin.step3.content' | translate | safe: 'html'"></div>
              <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/user-guide/ui/sms-provider-settings/" target="_blank">
                <mat-icon>description</mat-icon>{{ 'widgets.getting-started.sys-admin.step3.how-to-configure-sms-provider' | translate }}</a>
              </mat-step>
              <mat-step [completed]="gettingStarted.maxSelectedIndex > 2">
                <ng-template matStepLabel>
                  <div class="flex items-center justify-between">
                    <div translate>widgets.getting-started.sys-admin.step4.title</div>
                    @if (matStepper.selectedIndex === 3) {
                      <a mat-button color="primary" routerLink="/security-settings/2fa">{{ 'admin.settings' | translate }}</a>
                    }
                  </div>
                </ng-template>
                <div [innerHTML]="'widgets.getting-started.sys-admin.step4.content' | translate | safe: 'html'"></div>
                <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/user-guide/two-factor-authentication/" target="_blank">
                  <mat-icon>description</mat-icon>{{ 'widgets.getting-started.sys-admin.step4.how-to-configure-2fa' | translate }}</a>
                </mat-step>
                <mat-step [completed]="gettingStarted.maxSelectedIndex > 3">
                  <ng-template matStepLabel>
                    <div class="flex items-center justify-between">
                      <div translate>widgets.getting-started.sys-admin.step5.title</div>
                      @if (matStepper.selectedIndex === 4) {
                        <a mat-button color="primary" routerLink="/security-settings/oauth2">{{ 'admin.settings' | translate }}</a>
                      }
                    </div>
                  </ng-template>
                  <div [innerHTML]="'widgets.getting-started.sys-admin.step5.content' | translate | safe: 'html'"></div>
                  <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/user-guide/oauth-2-support/" target="_blank">
                    <mat-icon>description</mat-icon>{{ 'widgets.getting-started.sys-admin.step5.how-to-configure-oauth2' | translate }}</a>
                  </mat-step>
                  <mat-step [completed]="gettingStarted.maxSelectedIndex > 4">
                    <ng-template matStepLabel>
                      <div class="flex items-center justify-between">
                        <div translate>widgets.getting-started.sys-admin.step6.title</div>
                        @if (matStepper.selectedIndex === 5) {
                          <a mat-button color="primary" routerLink="/settings/notifications">{{ 'admin.settings' | translate }}</a>
                        }
                      </div>
                    </ng-template>
                    <div [innerHTML]="'widgets.getting-started.sys-admin.step6.content' | translate | safe: 'html'"></div>
                    <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/user-guide/ui/slack-settings/" target="_blank">
                      <mat-icon>description</mat-icon>{{ 'widgets.getting-started.sys-admin.step6.how-to-configure-notifications' | translate }}</a>
                    </mat-step>
                  }
                  @case (authority.TENANT_ADMIN) {
                    <mat-step [completed]="gettingStarted.maxSelectedIndex > -1">
                      <ng-template matStepLabel>
                        <div class="flex items-center justify-between">
                          <div translate>widgets.getting-started.tenant-admin.step1.title</div>
                          @if (matStepper.selectedIndex === 0) {
                            <a mat-button color="primary" routerLink="/entities/devices">{{ 'device.devices' | translate }}</a>
                          }
                        </div>
                      </ng-template>
                      <div [innerHTML]="'widgets.getting-started.tenant-admin.step1.content' | translate | safe: 'html'"></div>
                      <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/getting-started-guides/helloworld/#step-1-provision-device" target="_blank">
                        <mat-icon>description</mat-icon>{{ 'widgets.getting-started.tenant-admin.step1.how-to-create-device' | translate }}</a>
                      </mat-step>
                      <mat-step [completed]="gettingStarted.maxSelectedIndex > 0">
                        <ng-template matStepLabel>
                          <div class="flex items-center justify-between">
                            <div translate>widgets.getting-started.tenant-admin.step2.title</div>
                          </div>
                        </ng-template>
                        <div [innerHTML]="'widgets.getting-started.tenant-admin.step2.content-before' | translate | safe: 'html'"></div>
                        <div class="tb-bordered-content">
                          <tb-toggle-header #publishCommandSteps value="ubuntu" name="publishCommandSteps" useSelectOnMdLg="false">
                            <tb-toggle-option value="ubuntu">Ubuntu</tb-toggle-option>
                            <tb-toggle-option value="macos">MacOS</tb-toggle-option>
                            <tb-toggle-option value="windows">Windows</tb-toggle-option>
                          </tb-toggle-header>
                          @switch (publishCommandSteps.value) {
                            @case ('ubuntu') {
                              <p [innerHTML]="'widgets.getting-started.tenant-admin.step2.ubuntu.install-curl' | translate | safe: 'html'"></p>
                <tb-markdown usePlainMarkdown containerClass="tb-getting-started-code" data="
                    ```bash
                    sudo apt-get install curl
                    {:copy-code}
                    ```
                "></tb-markdown>
                            }
                            @case ('macos') {
                              <p [innerHTML]="'widgets.getting-started.tenant-admin.step2.macos.install-curl' | translate | safe: 'html'"></p>
                <tb-markdown usePlainMarkdown containerClass="tb-getting-started-code" data="
                    ```bash
                    brew install curl
                    {:copy-code}
                    ```
                "></tb-markdown>
                            }
                            @case ('windows') {
                              <p [innerHTML]="'widgets.getting-started.tenant-admin.step2.windows.install-curl' | translate | safe: 'html'"></p>
                            }
                          }
                          <p [innerHTML]="'widgets.getting-started.tenant-admin.step2.replace-access-token' | translate | safe: 'html'"></p>
            <tb-markdown usePlainMarkdown containerClass="tb-getting-started-code" data="
                    ```bash
                    curl -v -X POST -d &quot;{\&quot;temperature\&quot;: 25}&quot; {{baseUrl}}/api/v1/$ACCESS_TOKEN/telemetry --header &quot;Content-Type:application/json&quot;
                    {:copy-code}
                    ```
                "></tb-markdown>
                        </div>
                        <div [innerHTML]="'widgets.getting-started.tenant-admin.step2.content-after' | translate | safe: 'html'"></div>
                        <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/getting-started-guides/helloworld/#step-2-connect-device" target="_blank">
                          <mat-icon>description</mat-icon>{{ 'widgets.getting-started.tenant-admin.step2.how-to-connect-device' | translate }}</a>
                        </mat-step>
                        <mat-step [completed]="gettingStarted.maxSelectedIndex > 1">
                          <ng-template matStepLabel>
                            <div class="flex items-center justify-between">
                              <div translate>widgets.getting-started.tenant-admin.step3.title</div>
                              @if (matStepper.selectedIndex === 2) {
                                <a mat-button color="primary" routerLink="/dashboards">{{ 'dashboard.dashboards' | translate }}</a>
                              }
                            </div>
                          </ng-template>
                          <div [innerHTML]="'widgets.getting-started.tenant-admin.step3.content' | translate | safe: 'html'"></div>
                          <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/getting-started-guides/helloworld/#step-3-create-dashboard" target="_blank">
                            <mat-icon>description</mat-icon>{{ 'widgets.getting-started.tenant-admin.step3.how-to-create-dashboard' | translate }}</a>
                          </mat-step>
                          <mat-step [completed]="gettingStarted.maxSelectedIndex > 2">
                            <ng-template matStepLabel>
                              <div class="flex items-center justify-between">
                                <div translate>widgets.getting-started.tenant-admin.step4.title</div>
                                @if (matStepper.selectedIndex === 3) {
                                  <a mat-button color="primary" routerLink="/alarms/alarm-rules">{{ 'widgets.getting-started.tenant-admin.step4.alarm-rules' | translate }}</a>
                                }
                              </div>
                            </ng-template>
                            <div [innerHTML]="'widgets.getting-started.tenant-admin.step4.content' | translate | safe: 'html'"></div>
                            <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/user-guide/alarm-rules/" target="_blank">
                              <mat-icon>description</mat-icon>{{ 'widgets.getting-started.tenant-admin.step4.how-to-configure-alarm-rules' | translate }}</a>
                            </mat-step>
                            <mat-step [completed]="gettingStarted.maxSelectedIndex > 3">
                              <ng-template matStepLabel>
                                <div class="flex items-center justify-between">
                                  <div translate>widgets.getting-started.tenant-admin.step5.title</div>
                                </div>
                              </ng-template>
                              <div [innerHTML]="'widgets.getting-started.tenant-admin.step5.content-before' | translate | safe: 'html'"></div>
                              <p [innerHTML]="'widgets.getting-started.tenant-admin.step5.replace-access-token' | translate | safe: 'html'"></p>
          <tb-markdown usePlainMarkdown containerClass="tb-getting-started-code" data="
                    ```bash
                    curl -v -X POST -d &quot;{\&quot;temperature\&quot;: 26}&quot; {{baseUrl}}/api/v1/$ACCESS_TOKEN/telemetry --header &quot;Content-Type:application/json&quot;
                    {:copy-code}
                    ```
                "></tb-markdown>
                              <div [innerHTML]="'widgets.getting-started.tenant-admin.step5.content-after' | translate | safe: 'html'"></div>
                              <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/getting-started-guides/helloworld/#step-5-create-alarm" target="_blank">
                                <mat-icon>description</mat-icon>{{ 'widgets.getting-started.tenant-admin.step5.how-to-create-alarm' | translate }}</a>
                              </mat-step>
                              <mat-step [completed]="gettingStarted.maxSelectedIndex > 4">
                                <ng-template matStepLabel>
                                  <div class="flex items-center justify-between">
                                    <div translate>widgets.getting-started.tenant-admin.step6.title</div>
                                    @if (matStepper.selectedIndex === 5) {
                                      <a mat-button color="primary" routerLink="/customers">{{ 'customer.customers' | translate }}</a>
                                    }
                                  </div>
                                </ng-template>
                                <div [innerHTML]="'widgets.getting-started.tenant-admin.step6.content' | translate | safe: 'html'"></div>
                                <a mat-stroked-button color="primary" href="https://thingsboard.io/docs/getting-started-guides/helloworld/#step-7-assign-device-and-dashboard-to-customer" target="_blank">
                                  <mat-icon>description</mat-icon>{{ 'widgets.getting-started.tenant-admin.step6.how-to-create-customer-and-assign-dashboard' | translate }}</a>
                                </mat-step>
                              }
                            }
                          </mat-stepper>
                          @if (allCompleted) {
                            <div class="flex justify-center pt-6">
                              <button (click)="gettingStartedCompleted()" mat-flat-button color="primary">
                                <mat-icon>rocket_launch</mat-icon>{{ 'widgets.getting-started.finish' | translate }}</button>
                              </div>
                            }
                          </div>
