import{a as Ee,b as Je}from"./chunk-MXSLISEG.js";import{a as Oe}from"./chunk-AYO4TCFG.js";import{a as be,b as he}from"./chunk-5DQKN4SL.js";import"./chunk-7QEXVS2A.js";import{a as Se,b as xe}from"./chunk-FSCI3FDB.js";import{a as Ie}from"./chunk-D4RZOGGF.js";import"./chunk-HXEFMD5A.js";import"./chunk-KCLQIV7M.js";import"./chunk-5KCUTXXV.js";import"./chunk-JUDWAYYT.js";import{a as Te}from"./chunk-WFZJP5WR.js";import"./chunk-F6KLNSUK.js";import{b as Ne,c as Ce,d as ye}from"./chunk-YOJ4KGSB.js";import"./chunk-CO3X7TQN.js";import{a as z}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{Eb as ue,Gb as D,Ib as ge,Mb as k,O as ne,Ob as ve,P as oe,R as ae,T as se,V as re,W as le,X as S,bb as de,c as E,cb as pe,l as Z,o as K,rb as _,s as ee,v as te,wb as fe,y as ie}from"./chunk-YSQLW2JA.js";import{Jc as me,ma as F}from"./chunk-NVJ2ZZFT.js";import{Aa as T,Ba as U,Fb as V,He as d,Nc as u,Ng as A,Qf as h,Rd as O,Sd as N,Se as C,Te as b,Ue as y,Vc as H,W as P,Yg as ce,_a as g,_b as B,ab as f,af as p,bb as c,cd as G,dd as m,eh as w,gb as v,gg as J,ha as j,hd as I,hg as Y,jg as W,mg as Q,ng as X,wc as q,ya as l,zc as $}from"./chunk-SKPDQO4E.js";var Ae=`<div class="h-100" *ngIf="visibleComponent">
  <side-navigation>
    <ng-template side-navigation-nav>
      <div class="row">
        <div class="col-12">
          <label class="report-form-label">{{'NOTIFICATIONJOBS.TYPES'|translate}}</label>
          <nz-select class="w-100" nzSize="small" nzPlaceHolder="{{'COMMON.ALL'|translate}}"
            [(ngModel)]="request.filter.types" nzMode="'multiple'">
            <nz-option *ngFor="let notificationJobsType of notificationJobTypes" [nzValue]="notificationJobsType.type"
              [nzLabel]="(notificationJobsType.title | translate)"></nz-option>
          </nz-select>
        </div>
        <div class="col-12">
          <label class="report-form-label">{{'SCHEDULEDJOBS.JOB_CREATED_BY'|translate}}</label>
          <nz-select class="w-100" nzSize="small" nzPlaceHolder="{{'COMMON.ALL'|translate}}" [nzAllowClear]="true"
            [(ngModel)]="request.filter.createdBySystem" (ngModelChange)="onCreatedBySystemChanged($event)">
            <nz-option *ngFor="let creationState of creationStates" [nzValue]="creationState.value"
              [nzLabel]="(creationState.title | translate:languageService.userTranslate)"></nz-option>
          </nz-select>
        </div>
        <div class="col-12" *ngIf="permissionSearchIdentity && request.filter.createdBySystem!=true">
          <label class="report-form-label">{{'SCHEDULEDJOBS.JOB_CREATED_USER_BY' | translate :
            languageService.userTranslate}}</label>
          <armon-select-search query="identity" [allowMulti]="false" [allowClear]="true"
            [(ngModel)]="request.filter.createdByUserId">
          </armon-select-search>
        </div>
        <div class="col-12">
          <label class="report-form-label">{{'NOTIFICATIONJOBS.MEDIUMS'|translate}}</label>
          <armon-notification-medium-input [(ngModel)]="request.filter.mediums" [narrow]="true">
          </armon-notification-medium-input>
        </div>
        <div class="col-12">
          <label class="report-form-label">{{'NOTIFICATIONJOBS.WHEN'|translate}}</label>
          <nz-select class="w-100" nzSize="small" nzPlaceHolder="{{'COMMON.ALL'|translate}}"
            [(ngModel)]="request.filter.when" [nzAllowClear]="true">
            <nz-option *ngFor="let notificationJobsWhen of notificationJobService.notificationJobsWhens"
              [nzValue]="notificationJobsWhen.trigger" [nzLabel]="(notificationJobsWhen.title | translate)"></nz-option>
          </nz-select>
        </div>
        <div class="col-12 mt-2">
          <label class="report-checkbox-label" nz-checkbox
            [(ngModel)]="request.filter.archived">{{'NOTIFICATIONJOBS.ONLY_ARCHIVED' |
            translate}}</label>
        </div>
        <div class="col-12 mt-4 d-flex justify-content-center">
          <button class="btn btn-primary btn-sm" (click)="onListClicked($event)">{{'COMMON.FILTER' |translate}}</button>
        </div>
      </div>
    </ng-template>
    <ng-template side-navigation-content>
      <div class="report-data-container">
        <div class="row report-filter-container">
          <div class="col-12 d-flex mb-2">
            <button nz-dropdown [nzDropdownMenu]="menuAdd" class="btn btn-primary btn-sm me-2" nzTrigger="click"
              *ngIf="addableNotificationJobTypes.length>0 || permissionSendAnnouncement">
              {{'NOTIFICATIONJOBS.ADD'|translate}}
              <cds-icon shape="angle" direction="down"></cds-icon>
            </button>
            <nz-dropdown-menu #menuAdd="nzDropdownMenu">
              <ul nz-menu>
                <ng-container *ngFor="let notificationJobType of addableNotificationJobTypes">
                  <li nz-menu-item (click)="onAddNotificationClicked($event, notificationJobType)"
                    *ngIf="notificationJobType.addable">
                    <div class="d-flex">
                      <div class="me-2">
                        <cds-icon [attr.shape]="notificationJobType.addAsScheduledJob?'scheduled_job':'bell'"
                          style="width: 20px; height: 20px;" class="opacity-50"></cds-icon>
                      </div>
                      <div class="d-flex flex-column justify-content-center flex-grow-1 py-1">
                        <span class="text-sm line-height-sm text-primary">{{notificationJobType.title|translate}}</span>
                        <span class="text-xs line-height-xs text-italic text-black-50"
                          *ngIf="notificationJobType.addAsScheduledJob">{{'SCHEDULEDJOBS.AS_JOB'|translate}}</span>
                      </div>
                    </div>
                  </li>
                </ng-container>
                <ng-container *ngIf="permissionSendAnnouncement">
                  <li nz-menu-divider *ngIf="addableNotificationJobTypes.length>0"></li>
                  <li nz-menu-item (click)="onSendAnnouncementClicked($event)">
                    <div class="d-flex">
                      <div class="me-2">
                        <cds-icon shape="megaphone" style="width: 20px; height: 20px;" class="opacity-50"></cds-icon>
                      </div>
                      <div class="d-flex flex-column justify-content-center flex-grow-1 py-1">
                        <span
                          class="text-sm line-height-sm text-primary">{{'NOTIFICATIONS.SEND_NOTIFICATION'|translate}}</span>
                      </div>
                    </div>
                  </li>
                </ng-container>
              </ul>
            </nz-dropdown-menu>
            <button class="btn btn-sm btn-outline-primary ms-auto" (click)="onNotificationPreferencesClicked($event)"
              title="{{'NOTIFICATIONJOBS.ORGANIZATION_PREFERENCES'|translate}}">{{'NOTIFICATIONJOBS.PREFERENCES' |
              translate}}</button>
          </div>
          <div class="col-12"
            *ngIf="request.filter && request.filter.notificationIds && request.filter.notificationIds.length>0">
            <div class="alert alert-warning alert-sm passive-alert">
              <div class="alert-items">
                <div class="alert-item static">
                  <div class="alert-text">
                    {{"NOTIFICATIONJOBS.HISTORY_LIMITED"|translate}}<button class="ms-3 btn btn-sm btn-link"
                      (click)="onExitLimitedModeClicked($event)">{{'BUTTON.SHOW_ALL'|translate}}</button>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="row report-data-table-container" id="report-data-table-container">
          <div class="col-12">
            <ng-container *ngIf="items && items.length>0">
              <div class="row my-2" [@listAnimation]="items.length">
                <div class="col-12" *ngFor="let item of items">
                  <div class="card mb-3">
                    <div class="card-body p-4">
                      <div class="d-flex flex-grow-1">
                        <div class="flex-column align-items-center pe-3 py-3 b-r-1 d-none d-sm-flex">
                          <cds-icon shape="bell" size="lg" class="text-primary opacity-25 mb-3"
                            [ngClass]="{'text-danger': item.archived}"></cds-icon>
                          <span *ngIf="item.archived"
                            class="text-xs fw-medium text-danger">{{'COMMON.DELETED'|translate}}</span>
                        </div>
                        <div class="row flex-grow-1">
                          <div class="col-12 mb-4">
                            <div class="d-flex flex-grow-1 px-3 align-items-center">
                              <span
                                class="text-md fw-medium text-primary mb-1">{{item.notificationJobType.title|translate}}</span>
                              <div class="d-flex align-items-center ms-auto">
                                <ng-container *ngFor="let notificationMedium of item.notificationMediums">
                                  <cds-icon [attr.shape]="notificationMedium.icon" style="width: 20px; height: 20px;"
                                    class="ms-2 text-primary opacity-50" nz-tooltip
                                    nzTooltipTitle="{{notificationMedium.title | translate}}"></cds-icon>
                                </ng-container>
                              </div>
                            </div>
                          </div>
                          <div class="col-md-6 col-12">
                            <div class="d-flex flex-column flex-grow-1 px-3">
                              <ng-container *ngIf="item.settings">
                                <ng-container *ngIf="item.settings.reportTypeDefinition">
                                  <div>
                                    <span nz-tooltip nzTooltipTitle="{{'REPORT.TEMPLATE_GOTO_REPORT' | translate}}"
                                      class="text-sm cursor-pointer"
                                      (click)="onReportTemplateClicked($event, item)">{{item.settings.reportTypeDefinition.description|translate:languageService.userTranslate}}
                                      -
                                      {{(item.settings.reportName)?item.settings.reportName:item.settings.templateName}}</span>
                                  </div>
                                </ng-container>
                                <div class="d-flex flex-column mb-2" *ngIf="item.settings.targetUser">
                                  <span
                                    class="text-xs color-gray">{{'IDENTITY.TITLE'|translate:languageService.userTranslate}}</span>
                                  <armon-captionlines [showBorder]="false"
                                    [captionlines]="item.settings.targetUser.caption">
                                  </armon-captionlines>
                                </div>
                                <!-- Identity Access all users -->
                                <div class="d-flex flex-column mb-2"
                                  *ngIf="item.notificationJobType.type==1 && item.settings?.targetUser==null">
                                  <span class="text-sm">{{'COMMON.ALL_USERS' | translate :
                                    languageService.userTranslate}}</span>
                                </div>
                                <div class="d-flex flex-column mb-2" *ngIf="item.settings.message">
                                  <span class="text-sm">{{item.settings.message}}</span>
                                </div>
                              </ng-container>
                              <ng-container *ngIf="item.receiverFilter">
                                <span class="text-xs color-gray mt-2">{{'NOTIFICATIONJOBS.USER_RECIPIENTS' |
                                  translate}}</span>
                                <armon-user-filter-control [ngModel]="item.receiverFilter" [listView]="true">
                                </armon-user-filter-control>
                              </ng-container>
                            </div>
                          </div>
                          <div class="col-md-6 col-12" *ngIf="item.createdBy">
                            <div class="d-flex flex-column flex-grow-1 px-3">
                              <ng-container>
                                <span class="text-xs color-gray">{{'SCHEDULEDJOBS.JOB_CREATED_BY'|translate}}</span>
                                <armon-captionlines [showBorder]="false" [captionlines]="item.createdBy.caption">
                                </armon-captionlines>
                              </ng-container>
                            </div>
                          </div>
                          <div class="col-12" *ngIf="item.lastEvent">
                            <div class="d-flex flex-column px-3 mt-3 pt-2 b-t-1">
                              <span class="text-xs color-gray mb-2">{{'NOTIFICATIONJOBS.LAST_EVENT' | translate}}</span>
                              <armon-notificationjobs-event [notificationJobEvent]="item.lastEvent" [cardView]="false">
                              </armon-notificationjobs-event>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="card-footer">
                      <button class="btn btn-sm btn-link me-2"
                        (click)="onShowEventsClicked($event, item)">{{'NOTIFICATIONJOBS.EVENTS'|translate}}</button>
                      <button class="btn btn-sm btn-link me-2"
                        *ngIf="!item.archived && item.notificationJobType.editable"
                        (click)="onEditNotificationClicked($event, item)">{{'BUTTON.EDIT'|translate}}</button>
                      <button class="btn btn-sm btn-link me-2"
                        *ngIf="!item.archived && item.notificationJobType.addable"
                        (click)="onDeleteNotificationClicked($event, item)">{{'BUTTON.DELETE'|translate}}</button>
                    </div>
                  </div>
                </div>
              </div>
            </ng-container>
          </div>
          <div class="col-12 my-2">
            <armon-pagination [paginationResponse]="paginationResponse" (pageChanged)="pageChanged($event)"
              [scrollDomId]="'report-data-table-container'">
            </armon-pagination>
          </div>
        </div>
      </div>
    </ng-template>
  </side-navigation>
</div>`;var we=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var _e=`<ng-container *ngIf="visible">
    <div class="row mb-4">
        <div class="col-12">
            <span class="text-lg">{{'NOTIFICATIONJOBS.ORGANIZATION_PREFERENCES'|translate}}</span>
        </div>
    </div>
    <div class="row my-3" *ngIf="notificationPreferences.smsBalance">
        <div class="col-12">
            <span
                class="text-sm fw-medium">{{'NOTIFICATIONJOBS.SMS_BALANCE'|translate:notificationPreferences}}</span>
        </div>
    </div>
    <form [formGroup]="form">
        <div class="row">
            <div class="col-12 my-3 pb-2 b-b-1">
                <span class="text-md">{{'NOTIFICATIONJOBS.TYPES'|translate}}</span>
            </div>
            <div class="col-12 mb-3">
                <label class="report-form-label">{{'NOTIFICATIONJOBS.ACTIVE_TYPES'|translate}}</label>
                <nz-select class="w-100" nzSize="small" [formControl]="form.get('enabledTypes')" [nzMaxTagCount]="10"
                    [nzMaxTagPlaceholder]="tagPlaceHolder" [ngClass]="{'nz-invalid': form.get('enabledTypes').invalid}"
                    nzMode="'multiple'">
                    <nz-option *ngFor="let notificationJobsType of notificationPreferences.availableTypeDefs"
                        [nzValue]="notificationJobsType.type" [nzLabel]="(notificationJobsType.title | translate)">
                    </nz-option>
                </nz-select>
                <ng-template #tagPlaceHolder let-selectedList> <span class="ant-select-selection-item-count">(+ {{
                        selectedList.length
                        }})</span>
                </ng-template>
                <ng-template
                    *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('enabledTypes'), isArray:true}">
                </ng-template>
            </div>
        </div>
        <div class="row">
            <div class="col-12 my-3 pb-2 b-b-1">
                <span class="text-md">{{'NOTIFICATIONJOBS.ALL_TYPES_MEDIUM'|translate}}</span>
            </div>
            <div class="col-12 mb-3">
                <label class="report-form-label">{{'NOTIFICATIONJOBS.MEDIUMS'|translate}}</label>
                <armon-notification-medium-input [formControl]="form.get('mediumSettings').get('general')"
                    [invalid]="form.get('mediumSettings').get('general').invalid"></armon-notification-medium-input>
                <ng-template
                    *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form.get('mediumSettings'), control:form.get('mediumSettings').get('general'), isArray:true}">
                </ng-template>
            </div>
        </div>
        <div class="row px-2">
            <div class="col-12 d-flex align-items-center my-3 pb-2 b-b-1">
                <span class="text-md">{{'NOTIFICATIONJOBS.SPECIFIC_TYPE_MEDIUMS'|translate}}</span>
                <button class="btn btn-sm btn-primary ms-auto" (click)="onAddCustomClicked($event)">
                    <cds-icon shape="plus-circle" solid class="me-1"></cds-icon>{{'BUTTON.ADD'|translate}}
                </button>
            </div>
            <div class="col-12 mb-3">
                <div formArray="memberFilterFormUnits" [hidden]="formCustom.controls.length==0">
                    <ng-container
                        *ngFor="let formCustomControl of formCustom.controls; let index = index; let last = last;">
                        <div class="row mb-3" [formGroup]="formCustomControl">
                            <div class="col-11 mb-2">
                                <label class="report-form-label">{{'NOTIFICATIONJOBS.TYPE'|translate}}</label>
                                <nz-select class="w-100" nzSize="small"
                                    nzPlaceHolder="{{'COMMON.SELECT_ONE'|translate}}"
                                    [formControl]="formCustomControl.get('type')"
                                    [ngClass]="{'nz-invalid': formCustomControl.get('type').invalid}">
                                    <nz-option
                                        *ngFor="let notificationJobsType of notificationPreferences.availableTypeDefs"
                                        [nzValue]="notificationJobsType.type"
                                        [nzLabel]="(notificationJobsType.title | translate)"></nz-option>
                                </nz-select>
                                <ng-template
                                    *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: formCustomControl, control:formCustomControl.get('type')}">
                                </ng-template>
                            </div>
                            <div class="col-1 d-flex align-items-center">
                                <cds-icon solid class="ms-auto text-danger cursor-pointer" shape="times-circle"
                                    style="width: 20px; height: 20px;" (click)="onRemoveCustomClicked($event, index)"></cds-icon>
                            </div>
                            <div class="col-12 mb-2">
                                <label class="report-form-label">{{'NOTIFICATIONJOBS.MEDIUMS'|translate}}</label>
                                <armon-notification-medium-input [formControl]="formCustomControl.get('mediums')"
                                    [invalid]="formCustomControl.get('mediums').invalid">
                                </armon-notification-medium-input>
                                <ng-template
                                    *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: formCustomControl, control:formCustomControl.get('mediums'), isArray:true}">
                                </ng-template>
                            </div>
                        </div>
                    </ng-container>
                </div>
            </div>
        </div>
    </form>
    <div class="row mt-3">
        <div class="col-12 d-flex justify-content-end">
            <button class="btn btn-sm btn-outline-primary me-2" *ngIf="drawerRef"
                (click)="onCancelClicked($event)">{{'BUTTON.CANCEL'|translate}}</button>
            <button class="btn btn-sm btn-success" [disabled]="form.invalid"
                (click)="onSaveClicked($event)">{{'BUTTON.SAVE'|translate}}</button>
        </div>
    </div>
</ng-container>

<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control" let-isArray="isArray">
    <ng-container *ngIf="control.errors">
        <div class="invalid-feedback" style="display: initial;">
            <span
                *ngIf="control.errors.required">{{(isArray?'VALIDATION.MIN_ONE_SELECTED':'VALIDATION.REQUIRED')|translate}}</span>
            <span *ngIf="control.errors.ip">{{'VALIDATION.IP_V4_OR_V6'|translate}}</span>
            <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
            <span *ngIf="control.errors.max">{{'VALIDATION.MAX_VALUE'|translate:control.errors.max}}</span>
            <span *ngIf="control.errors.unique">{{'VALIDATION.UNIQUE'|translate}}</span>
        </div>
    </ng-container>
</ng-template>`;var De=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var Ye=function(s,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,n);else for(var r=s.length-1;r>=0;r--)(a=s[r])&&(i=(o<3?a(i):o>3?a(e,t,i):a(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i},L=class{notificationJobService;interactionService;languageService;settingsService;drawerRef;formBuilder;visible=!1;form;notificationPreferences;constructor(e,t,n,o,i,a){this.notificationJobService=e,this.interactionService=t,this.languageService=n,this.settingsService=o,this.drawerRef=i,this.formBuilder=a}ngOnInit(){this.getSettings()}ngOnDestroy(){}getSettings(){this.settingsService.getOrganizationSettings().subscribe(e=>{this.notificationPreferences=e.notification,console.log(this.notificationPreferences),this.createForm()})}updateSettings(){let e=de.getEmptyModel(),t=pe.getEmptyModel();Object.assign(t,this.form.value),e.notification=t,this.settingsService.updateOrganizationSettings(e).subscribe(n=>{this.interactionService.showMessage("NOTIFICATIONJOBS.SETTINGS_ORGANIZATION_UPDATED",null,u.Success),this.drawerRef&&this.drawerRef.close()})}createForm(){if(this.form=this.formBuilder.group({enabledTypes:[this.notificationPreferences.enabledTypes?this.notificationPreferences.enabledTypes:null,d.required],mediumSettings:this.formBuilder.group({general:[this.notificationPreferences.mediumSettings.general?this.notificationPreferences.mediumSettings.general:null,d.required],custom:this.formBuilder.array([])})}),this.notificationPreferences.mediumSettings.custom&&this.notificationPreferences.mediumSettings.custom.length>0){let e=this.form.get("mediumSettings").get("custom");this.notificationPreferences.mediumSettings.custom.map(t=>{e.push(this.createCustomUnitForm(t))})}this.visible=!0}get formCustom(){return this.form.get("mediumSettings").get("custom")}createCustomUnitForm(e=null){return e||(e={}),this.formBuilder.group({type:[e.type?e.type:null,[d.required,X.unique()]],mediums:[e.mediums?e.mediums:null,d.required]})}onAddCustomClicked(e){this.formCustom.push(this.createCustomUnitForm()),this.form.updateValueAndValidity()}onRemoveCustomClicked(e,t){this.formCustom.removeAt(t),this.form.updateValueAndValidity()}onCancelClicked(e){this.drawerRef&&this.drawerRef.close()}onSaveClicked(e){this.updateSettings()}static ctorParameters=()=>[{type:S},{type:h},{type:p},{type:_},{type:be,decorators:[{type:P}]},{type:C}]};L=Ye([l({selector:"armon-notificationjobs-preferences",template:_e,standalone:!0,imports:[c,b,y,Q,w,g,f,v,D,m],styles:[De]})],L);var ke=`<ng-container *ngIf="visible">
    <div class="modal-header align-items-center">
        <div class="d-flex me-2 align-items-center">
            <cds-icon shape="event" size="lg" class="text-primary opacity-25"></cds-icon>
        </div>
        <div class="d-flex flex-column flex-grow-1">
            <span class="text-lg">{{'NOTIFICATIONJOBS.EVENTS' | translate}}</span>
            <span class="text-sm fw-medium"
                *ngIf="notificationJob.notificationJobType">{{notificationJob.notificationJobType.title|translate}}</span>
        </div>
    </div>
    <div class="modal-body">
        <div class="row">
            <div class="col-12">
                <armon-date-picker [options]="datePickerOptions" (selectionChanged)="onDateSelectionChanged($event)">
                </armon-date-picker>
            </div>
        </div>
        <div class="row my-2 align-content-start mh-vh-60 mxh-vh-60 overflow-y-auto">
            <div class="col-12">
                <ng-container *ngFor="let item of items">
                    <armon-notificationjobs-event [notificationJobEvent]="item"
                        (routingStarted)="onRoutingStarted($event)"></armon-notificationjobs-event>
                </ng-container>
            </div>
        </div>
        <div class="row">
            <div class="col-12">
                <armon-pagination [paginationResponse]="paginationResponse" (pageChanged)="pageChanged($event)">
                </armon-pagination>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CLOSE' |
            translate}}</button>
    </div>
</ng-container>`;var ze=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var Le=`<ng-container *ngIf="cardView">
    <div class="card mb-3">
        <div class="card-body p-4">
            <ng-template *ngTemplateOutlet="eventTemplate;context: {$implicit:notificationJobEvent}">
            </ng-template>
        </div>
        <div class="card-footer">
            <button class="btn btn-sm btn-link me-2"
                (click)="notificationJobEvent.showDetail = !notificationJobEvent.showDetail;">{{(notificationJobEvent.showDetail?'BUTTON.HIDE_DETAIL':"BUTTON.SHOW_DETAIL")|translate}}</button>
            <button class="btn btn-sm btn-link me-2"
                (click)="onNotificationsClicked($event)">{{"PAGES.REPORT_NOTIFICATION_JOBS_INSTANCES"|translate}}</button>
        </div>
    </div>
</ng-container>
<ng-container *ngIf="!cardView">
    <ng-template *ngTemplateOutlet="eventTemplate;context: {$implicit:notificationJobEvent}">
    </ng-template>
</ng-container>

<ng-template #eventTemplate let-notificationJobEvent>
    <div class="row">
        <div class="col-md-3 col-6 d-flex flex-column">
            <span class="text-lg">{{notificationJobEvent.createdTHourText}}</span>
            <span class="text-sm text-italic">{{notificationJobEvent.createdTDateText}}</span>
            <span *ngIf="notificationJobEvent.archived" class="text-danger">
                <cds-icon shape="exclamation-triangle" class="me-1" size="sm"></cds-icon><span class="text-xs fw-medium">{{'COMMON.DELETED'|translate}}</span>
            </span>
        </div>
        <div class="col-md-2 col-6 d-flex flex-column">
            <span class="text-xs color-gray">{{'NOTIFICATIONJOBS.USER_RECIPIENTS'|translate}}</span>
            <span class="text-xl line-height-xl">{{notificationJobEvent.receiverCount}}</span>
        </div>
        <div class="col-md-3 col-12 d-flex flex-column">
            <span class="text-xs color-gray mb-1">{{'NOTIFICATIONJOBS.STATES'|translate}}</span>
            <ng-container *ngFor="let stateCount of notificationJobEvent.stateCounts">
                <span class="text-xs">{{stateCount.notificationState.title|translate}}
                    <strong>({{stateCount.count}})</strong></span>
            </ng-container>
        </div>
        <div class="col-md-4 col-12 d-flex flex-column">
            <span class="text-sm" *ngIf="notificationJobEvent.content">{{notificationJobEvent.content.title}}</span>
            <span class="text-xs" *ngIf="notificationJobEvent.content">{{notificationJobEvent.content.body}}</span>
        </div>
    </div>
    <div class="row mt-2 b-t-1 pt-2" *ngIf="notificationJobEvent.showDetail">
        <ng-container *ngFor="let mediumCount of notificationJobEvent.mediumCounts">
            <div class="col-12">
                <span class="text-sm">
                    <cds-icon [attr.shape]="mediumCount.notificationMedium.icon" size="sm"
                        class="me-1 text-primary opacity-50"></cds-icon>
                    <span>{{mediumCount.notificationMedium.title | translate}} : </span>
                    <ng-container *ngFor="let stateCount of mediumCount.stateCounts">
                        <span class="comma">{{stateCount.notificationState.title|translate}}
                            <strong>({{stateCount.count}})</strong></span>
                    </ng-container>
                </span>
            </div>
        </ng-container>
    </div>
</ng-template>`;var Me=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var Ke=function(s,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,n);else for(var r=s.length-1;r>=0;r--)(a=s[r])&&(i=(o<3?a(i):o>3?a(e,t,i):a(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i},x=class{languageService;routingService;notificationJobEvent;cardView=!0;routingStarted=new j;constructor(e,t){this.languageService=e,this.routingService=t}ngOnInit(){}ngOnDestroy(){}onNotificationsClicked(e){this.routingService.gotoNotificationJobsInstances(null,this.notificationJobEvent.id,this.notificationJobEvent.archived),this.routingStarted.emit()}static ctorParameters=()=>[{type:p},{type:k}];static propDecorators={notificationJobEvent:[{type:T}],cardView:[{type:T}],routingStarted:[{type:U}]}};x=Ke([l({selector:"armon-notificationjobs-event",template:Le,standalone:!0,imports:[c,v,f,m],styles:[Me]})],x);var et=function(s,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,n);else for(var r=s.length-1;r>=0;r--)(a=s[r])&&(i=(o<3?a(i):o>3?a(e,t,i):a(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i},M=class extends N{languageService;notificationJobService;notificationJob;visible=!1;request;items;datePickerOptions=new Y;paginationResponse=new A;constructor(e,t){super(),this.languageService=e,this.notificationJobService=t}ngOnInit(){this.request=ae.getEmptyModel(),this.request.filter.notificationIds=[this.notificationJob.id],this.request.sorting.field="createdT",this.request.sorting.order=H.DESC,this.request.filter.archived=this.notificationJob.archived,this.datePickerOptions.items=[{type:J.LastWeek,selected:!0},{type:J.LastMonth},{type:J.CustomWithTimer}];let e=W.getDateSelection(this.datePickerOptions.items[0]);this.setDateSelection(e),this.getData(),this.visible=!0}ngOnDestroy(){}getData(){this.notificationJobService.listNotificationJobEvents(this.request).subscribe(e=>{this.items=e.items,this.paginationResponse=e.pagination})}setDateSelection(e){this.request.filter.eventTime.start=e.startDate,this.request.filter.eventTime.end=e.endDate,this.request.pagination.skip=0}onDateSelectionChanged(e){this.setDateSelection(e),this.getData()}pageChanged(e){this.request.pagination=e,this.getData()}onRoutingStarted(e){this.cancelModal()}static ctorParameters=()=>[{type:p},{type:S}];static propDecorators={notificationJob:[{type:T}]}};M=et([l({selector:"armon-notificationjobs-events-modal",template:ke,standalone:!0,imports:[c,Z,f,x,z,m],styles:[ze]})],M);var Re=`<ng-container *ngIf="visibleComponent">
    <div class="modal-header">
        <span class="text-lg"><cds-icon shape="megaphone" style="width: 28px; height: 28px;"
                class="opacity-50 me-2"></cds-icon>{{'NOTIFICATIONS.SEND_NOTIFICATION'| translate}}</span>
    </div>
    <div class="modal-body">
        <div class="row">
            <div class="col-12">
                <form [formGroup]="form">
                    <div class="form-group">
                        <label for="subject-input">{{'NOTIFICATIONS.SEND_SUBJECT' | translate}}</label>
                        <input type="text" id="subject-input" maxlength="256" [formControl]="form.get('subject')"
                            [ngClass]="{'is-invalid': form.get('subject').touched && form.get('subject').invalid}"
                            class="form-control form-control-sm">
                        <ng-template
                            *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('subject')}">
                        </ng-template>
                    </div>
                    <div class="form-group">
                        <label for="body-textarea">{{'NOTIFICATIONS.SEND_CONTENT' | translate}}</label>
                        <textarea name="message" id="body-textarea" rows="6" cols="20" maxlength="1024"
                            class="form-control form-control-sm" [formControl]="form.get('body')"
                            [ngClass]="{'is-invalid': form.get('body').touched && form.get('body').invalid}"
                            style="resize:none"></textarea>
                        <ng-template
                            *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('body')}">
                        </ng-template>
                    </div>
                    <div>
                        <div class="form-group">
                            <label>{{'NOTIFICATIONS.SEND_CONTENT' | translate}}</label>
                            <!-- NOTIFICATION UPLOAD, feature=2 -->
                            <armon-pacs-attachment-list uploadEnabled="true" [feature]="2"
                                [(attachmentList)]="attachmentList" class="custom-item">
                            </armon-pacs-attachment-list>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-outline-primary me-2" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' |
            translate}}</button>
        <button class="btn btn-primary" (click)="onSendClicked($event)" [disabled]="form.invalid">{{'BUTTON.SEND'
            | translate}}</button>
    </div>
</ng-container>

<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control">
    <ng-container *ngIf="control.errors">
        <div class="invalid-feedback d-flex flex-column" style="display: initial;">
            <span *ngIf="control.errors.required">{{'VALIDATION.REQUIRED'|translate}}</span>
            <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
            <span *ngIf="control.errors.max">{{'VALIDATION.MAX_VALUE'|translate:control.errors.max}}</span>
            <span *ngIf="control.errors.maxlength">{{'VALIDATION.MAX_LENGTH'|translate: {
                max:control.errors.maxlength.requiredLength} }}</span>
            <span *ngIf="control.errors.min">{{'VALIDATION.MIN_VALUE'|translate:control.errors.min}}</span>
            <span *ngIf="control.errors.minlength">{{'VALIDATION.MIN_LENGTH'|translate: {
                min:control.errors.minlength.requiredLength} }}</span>
        </div>
    </ng-container>
</ng-template>`;var Be=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var nt=function(s,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,n);else for(var r=s.length-1;r>=0;r--)(a=s[r])&&(i=(o<3?a(i):o>3?a(e,t,i):a(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i},R=class extends N{formBuilder;notificationService;interactionService;languageService;identitySelectionService;modalService;visibleComponent=!1;attachmentList=[];form;constructor(e,t,n,o,i,a){super(),this.formBuilder=e,this.notificationService=t,this.interactionService=n,this.languageService=o,this.identitySelectionService=i,this.modalService=a}onModalInitialized(){super.onModalInitialized(),this.attachmentList=[],this.initializeForms(),this.visibleComponent=!0}initializeForms(){this.form=this.formBuilder.group({subject:[null,[d.required,d.maxLength(256)]],body:[null,[d.required,d.maxLength(1024)]]})}getSessionForNotification(e){return this.identitySelectionService.getSessionForNotification(e)}onSendClicked(e){this.modalService.open(Je,{settings:{size:"xl"},props:{editable:!0,sessionFunction:this.getSessionForNotification.bind(this),useCustomApply:!0}}).result.then(t=>{t&&this.sendNotification(t.sessionId)}).catch(t=>{this.interactionService.showMessage("VALIDATION.MIN_ONE_USER_SELECTED",null,u.Warning,this.languageService.userTranslate)})}sendNotification(e){let t=me.getEmptyModel();Object.assign(t,this.form.value),this.attachmentList&&this.attachmentList.length>0?t.attachmentIds=this.attachmentList.map(n=>n.id):t.attachmentIds=null,this.notificationService.sendNotification(e,t).subscribe(n=>{this.interactionService.showMessage("NOTIFICATIONS.SEND_COMPLETED",null,u.Success),this.closeModal()})}static ctorParameters=()=>[{type:C},{type:Se},{type:h},{type:p},{type:Ee},{type:O}]};R=nt([l({selector:"armon-notification-send",template:Re,standalone:!0,imports:[b,c,g,y,v,xe,m],styles:[Be]})],R);var ot=function(s,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,n);else for(var r=s.length-1;r>=0;r--)(a=s[r])&&(i=(o<3?a(i):o>3?a(e,t,i):a(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i},Fe=class{notificationJobService;scheduledJobService;languageService;authService;translateService;interactionService;routingService;modalService;settingsService;route;drawerService;visibleComponent=!1;items;request;filterDateRange;notificationJobTypes;addableNotificationJobTypes;paginationResponse=new A;permissionSendAnnouncement=!1;enabledStates=[{value:!0,title:"SCHEDULEDJOBS.JOB_ONLY_ACTIVE"},{value:!1,title:"SCHEDULEDJOBS.JOB_ONLY_PASSIVE"}];editableStates=[{value:!0,title:"SCHEDULEDJOBS.JOB_ONLY_EDITABLE"},{value:!1,title:"SCHEDULEDJOBS.JOB_ONLY_NOT_EDITABLE"}];creationStates=[{value:!0,title:"SCHEDULEDJOBS.JOB_ONLY_SYSTEM"},{value:!1,title:"SCHEDULEDJOBS.JOB_ONLY_USER"}];permissionReportDetailed;permissionSearchIdentity;constructor(e,t,n,o,i,a,r,Pe,je,Ue,Ve){this.notificationJobService=e,this.scheduledJobService=t,this.languageService=n,this.authService=o,this.translateService=i,this.interactionService=a,this.routingService=r,this.modalService=Pe,this.settingsService=je,this.route=Ue,this.drawerService=Ve}ngOnInit(){this.permissionReportDetailed=this.authService.checkPermission(I.ACCESSLOG.getReportDetailed()),this.permissionSearchIdentity=this.authService.checkPermission(I.IDENTITY.getReadBasic()),this.resetFilter(),this.route.queryParams.subscribe(e=>{e&&e[E.NotificationId]&&e[E.NotificationId]!==""&&(this.request.filter.notificationIds=[e[E.NotificationId]]),setTimeout(()=>{this.getOrganizationSettings()},300)})}resetFilter(){this.request=ne.getEmptyModel(),this.request.pagination.take=$.REQUEST_ITEM_LIMIT}getOrganizationSettings(e=!1){this.settingsService.getOrganizationSettings(e).subscribe(t=>{this.notificationJobTypes=B(t.notification.enabledTypeDefs.filter(n=>n.filterable==!0),["addAsScheduledJob"],["desc"]),this.addableNotificationJobTypes=B(t.notification.enabledTypeDefs.filter(n=>n.addable==!0),["addAsScheduledJob"],["desc"]),this.permissionSendAnnouncement=this.authService.checkPermission(I.SYSTEM.getRead())&&t.notification.enabledTypeDefs.findIndex(n=>n.type==F.Announcement)>-1,this.getData(),this.visibleComponent=!0})}getData(){this.notificationJobService.listNotificationJobs(this.request).subscribe(e=>{e.items.forEach(t=>{t.receiverFilter&&(t.receiverFilterTexts=t.receiverFilter.getSummary(this.translateService,this.languageService))}),this.items=e.items,this.paginationResponse=e.pagination})}pageChanged(e){this.request.pagination=e,this.getData()}updateFilter(){this.request.pagination.skip=0}onListClicked(e){this.updateFilter(),this.getData()}onCreatedBySystemChanged(e){this.request.filter.createdBySystem==!0&&(this.request.filter.createdByUserId=null)}showNotificationJobModal(e){setTimeout(()=>{this.modalService.open(Oe,{settings:{size:"lg",scrollable:!0},props:{notificationJob:e}}).result.then(t=>{this.getData()}).catch(t=>{})},300)}showScheduledJobModal(e){setTimeout(()=>{this.modalService.open(ge,{settings:{size:"lg",scrollable:!0},props:{scheduledJob:e}}).result.then(t=>{this.getData()}).catch(t=>{})},300)}onAddNotificationClicked(e,t){if(t.addAsScheduledJob){let n=se.find(i=>i.type==+t.type),o=re.getEmptyModel(n.type);this.showScheduledJobModal(o)}else{let n=oe.getEmptyModel(t.type);this.showNotificationJobModal(n)}}onEditNotificationClicked(e,t,n=!1){t.notificationJobType.addAsScheduledJob?this.scheduledJobService.getScheduledJob(t.scheduledJobId).subscribe(o=>{this.showScheduledJobModal(o)}):this.showNotificationJobModal(t.getUpsertModel())}onDeleteNotificationClicked(e,t){t.notificationJobType.addAsScheduledJob?this.interactionService.showDialog("NOTIFICATIONJOBS.DELETE","NOTIFICATIONJOBS.DELETE_CONFIRMATION_WITH_SCHEDULED_JOB",null,{},!0,"BUTTON.DELETE","",!0,()=>{this.scheduledJobService.deleteScheduledJob(t.scheduledJobId).subscribe(()=>{this.interactionService.showMessage("NOTIFICATIONJOBS.DELETE_COMPLETED",null,u.Success),this.getData()})}):this.interactionService.showDialog("NOTIFICATIONJOBS.DELETE","NOTIFICATIONJOBS.DELETE_CONFIRMATION",null,{},!0,"BUTTON.DELETE","",!0,()=>{this.notificationJobService.deleteNotificationJob(t.id).subscribe(n=>{this.interactionService.showMessage("NOTIFICATIONJOBS.DELETE_COMPLETED",null,u.Success),this.getData()})})}onShowEventsClicked(e,t){this.modalService.open(M,{settings:{size:"xl"},props:{notificationJob:t}}).result.then(n=>{}).catch(n=>{})}onExitLimitedModeClicked(){this.request.filter.notificationIds=null,this.getData()}onNotificationPreferencesClicked(){this.drawerService.create({nzContent:L,nzClosable:!1,nzWidth:q(!1),nzContentParams:{}}).afterClose.subscribe(t=>{this.getOrganizationSettings(!0)})}onReportTemplateClicked(e,t){this.routingService.gotoReportTemplate(t.settings.reportTypeDefinition.type,t.settings.templateId,t.settings.customReportId)}onSendAnnouncementClicked(e){setTimeout(()=>{this.modalService.open(R,{settings:{size:"lg",scrollable:!0}}).result.then(t=>{this.resetFilter(),this.request.filter.types=[F.Announcement],this.getData()}).catch(t=>{})},600)}static ctorParameters=()=>[{type:S},{type:le},{type:p},{type:ve},{type:G},{type:h},{type:k},{type:O},{type:_},{type:V},{type:he}]};Fe=ot([l({selector:"armon-notificationjobs",template:Ae,animations:Ie,standalone:!0,imports:[c,ye,Ne,w,b,f,fe,D,K,Ce,ie,te,ee,g,ce,Te,ue,x,z,m],styles:[we]})],Fe);export{Fe as NotificationJobsComponent};
