import{b as M,c as $t,e as x,f as jt}from"./chunk-PLS4K4KY.js";import{a as Kt}from"./chunk-7GYHTWED.js";import{a as qt}from"./chunk-XOY5UTVP.js";import{a as H}from"./chunk-7QEXVS2A.js";import{b as Zt}from"./chunk-LAJI7RPC.js";import{B as q,Db as kt,H as z,I as bt,Ob as Wt,Rb as Qt,nb as Yt,s as St,v as Ft,wb as Vt,y as Pt}from"./chunk-YSQLW2JA.js";import{Ea as X,La as J,Ma as tt,Na as G,Oa as et,Pa as Lt,Qa as Mt,Ra as xt,S as wt,Sa as U,Ta as L,ee as Bt,gb as Ht}from"./chunk-NVJ2ZZFT.js";import{Aa as d,Ba as I,Ea as ut,He as p,Ig as zt,Jg as K,Kg as w,Ma as It,Me as Nt,Na as _,Nc as j,Ne as F,Pa as D,Pd as Rt,Qa as ht,Qf as Dt,Ra as gt,Sa as yt,Sd as Ct,T as ot,Tb as Et,Te as P,Ue as Ot,V,Va as c,W as at,Wa as W,Yg as Gt,_a as ft,ab as S,af as _t,bb as At,bc as vt,ca as O,dc as h,dd as v,ea as dt,fc as Q,gc as $,ha as u,hd as l,ic as g,jc as Z,kc as y,ma as ct,mc as m,md as Tt,mg as b,qa as k,va as lt,wa as mt,xa as pt,ya as E,yc as Ut,zc as f}from"./chunk-SKPDQO4E.js";var Xt=`<div class="modal-header">
  <span class="text-lg" *ngIf="visibleComponent">{{(currentIdentityDetailed ?
    currentIdentityDetailed.organizationProfile.fullName :
    'IDENTITY.TITLE_NEW_IDENTITY' ) | translate:languageService.userTranslate}}</span>
  <div class="d-flex column-gap-2" *ngIf="!visibleComponent"><span
      class="spinner-grow spinner-grow-sm text-secondary"></span><span
      class="text-base">{{'IDENTITY.TITLE_LOADING_IDENTITY'|
      translate:languageService.userTranslate}}</span></div>
</div>
<div class="modal-body" *ngIf="!visibleComponent">
  <div class="row modal-scroll-area-60">
    <span></span>
  </div>
</div>
<div class="modal-body" [hidden]="!visibleComponent">
  <nz-tabset [(nzSelectedIndex)]="selectedTabIndex" [nzAnimated]="false">
    <!-- PERSONAL -->
    <nz-tab [nzTitle]="titleTemplatePersonal">
      <ng-template #titleTemplatePersonal>
        <span [ngClass]="{'text-danger': identityFormInfo?.formGroup.invalid}">
          <cds-icon shape="user" class="me-2" size="md"></cds-icon>
          <span>{{'IDENTITY.TITLE_PERSONAL_INFORMATION' | translate}}</span>
        </span>
      </ng-template>
      <!-- CONTENT PERSONAL -->
      <div class="row mb-3 pb-3 b-b-1" *ngIf="currentIdentityDetailed && currentIdentityDetailed.username">
        <div class="col-12">
          <div class="d-flex ms-2">
            <span>{{'USER.USERNAME'|translate}} :</span><span class="fw-medium ms-2 cursor-pointer"
              [cdkCopyToClipboard]="currentIdentityDetailed.username" nz-tooltip
              nzTooltipTitle="{{'BUTTON.COPY' | translate}}">{{currentIdentityDetailed.username}}</span>
          </div>
        </div>
      </div>
      <div class="row modal-scroll-area-60" *ngIf="identityFormInfo">
        <!-- <div class="row" *ngIf="identityFormData"> -->
        <div class="col-12">
          <dynamic-form [formGroup]="identityFormInfo.formGroup" [formFields]="identityFormInfo.formFields"
            [fieldEndpoint]="identityFormInfo.endpointField" [isEnabledForm]="true"
            (fieldOnFocus)="onIdentityOrganizationProfileFieldFocus($event)"
            (fieldOnBlur)="onIdentityOrganizationProfileFieldBlur($event)"></dynamic-form>
          <!-- <df-form [formData]="identityFormData" #identityDfForm (formInitialized)="onDynamicFormInitialized($event)"></df-form> -->
        </div>
      </div>
      <!-- CONTENT PERSONAL -->
    </nz-tab>
    <!-- ACCOUNT -->
    <nz-tab [nzTitle]="titleTemplateAccount" *ngIf="isUserAccountFormAvailable">
      <ng-template #titleTemplateAccount>
        <span
          [ngClass]="{'text-danger': isUserAccountFormHasValue && (identityUserAccountForm.invalid || isUserAccountPasswordNotMatched)}">
          <cds-icon shape="key" class="me-2" size="md"></cds-icon><span>{{'IDENTITY.TITLE_USER_ACCOUNT' |
            translate}}</span>
        </span>
      </ng-template>
      <!-- CONTENT ACCOUNT -->
      <div class="d-flex flex-column my-3">
        <span class="text-sm text-bold text-center">{{'IDENTITY.USER_ACCOUNT_INFO_REQUIRED' | translate}}</span>
        <span class="text-sm text-center mt-3">{{'IDENTITY.USER_ACCOUNT_INFO_SKIP_PAGE' | translate}}</span>
      </div>
      <div class="d-flex flex-column modal-scroll-area-60">
        <form class="form" [formGroup]="identityUserAccountForm">
          <div class="row mx-1">
            <div class="col-6">
              <div class="form-group">
                <label for="identityAccountUsername" class="required">{{'IDENTITY.USERNAME' | translate}}</label>
                <input id="identityAccountUsername" type="text" formControlName="username"
                  [ngClass]="{'is-invalid': isUserAccountFormFieldInvalid('username')}"
                  (focus)="onIdentityUsernameFieldFocus($event)" (blur)="onIdentityUsernameFieldBlur($event)"
                  class="form-control form-control-sm" autocomplete="new-password">
                <div class="invalid-feedback"
                  *ngIf="identityUserAccountForm.get('username').errors && identityUserAccountForm.get('username').errors.required">
                  {{'VALIDATION.REQUIRED' | translate}}
                </div>
                <div class="invalid-feedback"
                  *ngIf="identityUserAccountForm.get('username').errors && identityUserAccountForm.get('username').errors.minlength">
                  <span [translate]="'VALIDATION.MIN_LENGTH'" [translateParams]="{min: 3}"></span>
                </div>
                <div class="invalid-feedback"
                  *ngIf="identityUserAccountForm.get('username').errors && identityUserAccountForm.get('username').errors.maxlength">
                  <span [translate]="'VALIDATION.MAX_LENGTH'" [translateParams]="{max: 127}"></span>
                </div>
              </div>
            </div>
          </div>
          <div class="row mx-1">
            <div class="col-6">
              <div class="form-group">
                <label for="identityAccountNewPassword" class="required">{{'IDENTITY.PASSWORD' | translate}}</label>
                <input id="identityAccountNewPassword" type="password" formControlName="newPassword"
                  class="form-control form-control-sm" autocomplete="new-password"
                  [ngClass]="{'is-invalid': isUserAccountFormFieldInvalid('newPassword')}">
                <div class="invalid-feedback"
                  *ngIf="identityUserAccountForm.get('newPassword').errors && identityUserAccountForm.get('newPassword').errors.required">
                  {{'VALIDATION.REQUIRED' | translate}}
                </div>
                <div class="invalid-feedback"
                  *ngIf="identityUserAccountForm.get('newPassword').errors && identityUserAccountForm.get('newPassword').errors.minlength">
                  <span [translate]="'VALIDATION.MIN_LENGTH'"
                    [translateParams]="{min: identityUserAccountForm.get('newPassword').errors.minlength.requiredLength}"></span>
                </div>
                <div class="invalid-feedback"
                  *ngIf="identityUserAccountForm.get('newPassword').errors && identityUserAccountForm.get('newPassword').errors.maxlength">
                  <span [translate]="'VALIDATION.MAX_LENGTH'"
                    [translateParams]="{max: identityUserAccountForm.get('newPassword').errors.maxlength.requiredLength}"></span>
                </div>
              </div>
            </div>
            <div class="col-6">
              <div class="form-group">
                <label for="identityAccountConfirmPassword" class="required">{{'IDENTITY.CONFIRM_PASSWORD' |
                  translate}}</label>
                <input id="identityAccountConfirmPassword" type="password" formControlName="confirmPassword"
                  autocomplete="new-password" class="form-control form-control-sm"
                  [ngClass]="{'is-invalid': isUserAccountFormFieldInvalid('confirmPassword') || isUserAccountPasswordNotMatched}">
                <div class="invalid-feedback"
                  *ngIf="identityUserAccountForm.get('confirmPassword').errors && identityUserAccountForm.get('confirmPassword').errors.required">
                  {{'VALIDATION.REQUIRED' | translate}}
                </div>
                <div class="invalid-feedback"
                  *ngIf="identityUserAccountForm.get('confirmPassword').errors && identityUserAccountForm.get('confirmPassword').errors.minlength">
                  <span [translate]="'VALIDATION.MIN_LENGTH'"
                    [translateParams]="{min: identityUserAccountForm.get('confirmPassword').errors.minlength.requiredLength}"></span>
                </div>
                <div class="invalid-feedback"
                  *ngIf="identityUserAccountForm.get('confirmPassword').errors && identityUserAccountForm.get('confirmPassword').errors.maxlength">
                  <span [translate]="'VALIDATION.MAX_LENGTH'"
                    [translateParams]="{max: identityUserAccountForm.get('confirmPassword').errors.maxlength.requiredLength}"></span>
                </div>
                <div class="invalid-feedback" *ngIf="isUserAccountPasswordNotMatched">
                  {{'VALIDATION.PASSWORD_NOT_MATCH' | translate}}
                </div>
              </div>
            </div>
          </div>
        </form>
      </div>
      <!-- CONTENT ACCOUNT -->
    </nz-tab>
    <!-- ORGANIZATION -->
    <nz-tab [nzTitle]="titleTemplateOrganization">
      <ng-template #titleTemplateOrganization>
        <cds-icon shape="organization" class="me-2" size="md"></cds-icon><span>{{'IDENTITY.TITLE_ORGANIZATION_UNITS' |
          translate}}</span>
      </ng-template>
      <!-- CONTENT ORGANIZATION -->
      <div class="row mb-3 pb-3 b-b-1">
        <div class="col-12 d-flex align-items-stretch">
          <div class="px-3 me-3 b-r-1 d-flex align-items-center">
            <cds-icon shape="organization" class="color-gray" size="lg"></cds-icon>
          </div>
          <div class="d-flex flex-column flex-grow-1">
            <label>{{'LICENSE.ORGANIZATION_TITLE'|translate}}</label>
            <armon-select-search query="unit" [allowMulti]="true" [(ngModel)]="controlOrganizationUnitIds"
              [closeAfterChange]="true" [enabledAllSelection]="false" (onOptionSelected)="onUnitSelected($event)"
              (onOptionUnselected)="onUnitUnselected($event)" class="w-100">
            </armon-select-search>
          </div>
        </div>
      </div>
      <div class="row align-content-start modal-scroll-area-60 overflow-y-auto">
        <div class="col-xl-6 col-lg-6 col-sm-12" *ngFor="let organizationUnit of currentIdentityOrganizationUnits">
          <armon-identity-organization-unit [organizationUnit]="organizationUnit"
            [isNewAdded]="isNewOrganizationUnit(organizationUnit)"
            [isUpdated]="isUpdatedOrganizationUnit(organizationUnit)"
            (organizationUnitRemoved)="onOrganizationUnitRemoved($event)"
            (organizationUnitUpdated)="onOrganizationUnitUpdated($event)"></armon-identity-organization-unit>
        </div>
      </div>
      <!-- CONTENT ORGANIZATION -->
    </nz-tab>
    <!-- GROUP -->
    <nz-tab [nzTitle]="titleTemplateGroup">
      <ng-template #titleTemplateGroup>
        <cds-icon shape="users" class="me-2" size="md"></cds-icon><span>{{'IDENTITY.TITLE_USER_GROUP' |
          translate}}</span>
      </ng-template>
      <!-- CONTENT GROUP -->

      <div class="row mb-3 pb-3 b-b-1">
        <div class="col-12 d-flex align-items-stretch">
          <div class="px-3 me-3 b-r-1 d-flex align-items-center">
            <cds-icon shape="users" class="color-gray" size="lg"></cds-icon>
          </div>
          <div class="d-flex flex-column flex-grow-1">
            <label>{{'IDENTITY.FILTER_TITLE_USER_GROUPS'|translate:languageService.userTranslate}}</label>
            <armon-select-search query="group" [allowMulti]="true" [(ngModel)]="controlGroupIds"
              [enabledAllSelection]="false" (onOptionSelected)="onGroupSelected($event)"
              (onOptionUnselected)="onGroupUnselected($event)">
            </armon-select-search>
          </div>
        </div>
      </div>

      <div class="row align-content-start modal-scroll-area-60 overflow-y-auto">
        <div class="col-xl-6 col-lg-6 col-sm-12" *ngFor="let userGroup of currentIdentityUserGroups">
          <armon-identity-user-group [userGroup]="userGroup" [isNewAdded]="isNewUserGroup(userGroup)"
            (userGroupRemoved)="onUserGroupRemoved($event)"></armon-identity-user-group>
        </div>
      </div>
      <!-- CONTENT GROUP -->
    </nz-tab>
    <!-- ACCESS RIGHT -->
    <nz-tab [nzTitle]="titleTemplateAccessRight">
      <ng-template #titleTemplateAccessRight>
        <cds-icon shape="login" class="me-2" size="md"></cds-icon><span>{{'IDENTITY.TITLE_ACCESS_RIGHTS' |
          translate}}</span>
      </ng-template>
      <!-- CONTENT ACCESS RIGHT -->

      <div class="row mb-3 pb-3 b-b-1">
        <div class="col-12 d-flex align-items-stretch">
          <div class="px-3 me-3 b-r-1 d-flex align-items-center">
            <cds-icon shape="login" class="color-gray" size="lg"></cds-icon>
          </div>
          <div class="d-flex flex-column flex-grow-1">
            <label>{{'REPORT.ACCESS_CONTROL_POINT'|translate}}</label>
            <armon-select-search query="point" [allowMulti]="true" [(ngModel)]="controlAccessControlPointIds"
              [enabledAllSelection]="true" (onOptionSelected)="onPointSelected($event)"
              (onOptionUnselected)="onPointUnselected($event)">
            </armon-select-search>
          </div>
        </div>
      </div>

      <div class="row modal-scroll-area-60 overflow-y-auto align-content-start">
        <div class="col-12" *ngIf="currentIdentityAccessRights && currentIdentityAccessRights.length>0">
          <span class="me-2">{{'REPORT.ACCESS_CONTROL_POINTS'|translate}}</span>
          <cds-icon shape="help" nz-popover [nzPopoverTitle]="titleTemplate" [nzPopoverContent]="contentTemplate">
          </cds-icon>
          <ng-template #titleTemplate>{{'IDENTITY.ACP_DAFAULT_PERMISSIONS'|translate}}</ng-template>
          <ng-template #contentTemplate>
            <span
              class="text-sm"><strong>{{'IDENTITY.ACCESS'|translate}}</strong>&nbsp;({{'IDENTITY.ACCESS_INFO'|translate}})</span><br>
            <span
              class="text-sm"><strong>{{'IDENTITY.REMOTE_ACCESS'|translate}}</strong>&nbsp;({{'IDENTITY.REMOTE_ACCESS_INFO'|translate}})</span><br>
            <span
              class="text-sm"><strong>{{'IDENTITY.READ'|translate}}</strong>&nbsp;({{'IDENTITY.READ_INFO'|translate}})</span><br>
            <span
              class="text-sm"><strong>{{'IDENTITY.CONFIG'|translate}}</strong>&nbsp;({{'IDENTITY.CONFIG_INFO'|translate}})</span><br>
            <span
              class="text-sm"><strong>{{'IDENTITY.GRANT'|translate}}</strong>&nbsp;({{'IDENTITY.GRANT_INFO'|translate}})</span><br>
          </ng-template>
        </div>
        <div class="col-12" *ngFor="let accessRight of currentIdentityAccessRights">
          <armon-identity-access-right [initSummaryView]="true" [accessRight]="accessRight"
            [isNewAdded]="isNewAccessRight(accessRight)" [isUpdated]="isUpdatedAccessRight(accessRight)"
            (accessRightRemoved)="onAccessRightRemoved($event)" (accessRightUpdated)="onAccessRightUpdated($event)">
          </armon-identity-access-right>
        </div>
      </div>
      <!-- CONTENT ACCESS RIGHT -->
    </nz-tab>
    <!-- CREDENTIAL -->
    <nz-tab [nzTitle]="titleTemplateCredential">
      <ng-template #titleTemplateCredential>
        <cds-icon shape="credit-card" class="me-2" size="md"></cds-icon>
        <span>{{'IDENTITY.TITLE_CREDENTIALS' | translate}}</span>
      </ng-template>
      <!-- CONTENT CREDENTIAL -->
      <div class="row mb-3 mx-1">
        <div class="col-md-6 col-sm-3 col-4">
          <button nz-dropdown [nzDropdownMenu]="menuAdd" class="btn btn-sm btn-primary">
            {{'BUTTON.ADD' | translate}}
            <cds-icon shape="angle" direction="down"></cds-icon>
          </button>
          <nz-dropdown-menu #menuAdd="nzDropdownMenu">
            <ul nz-menu>
              <li nz-menu-item *ngFor="let type of addableCredentialTypes"
                (click)="onAddCredentialClicked($event, type.type)">
                <cds-icon [attr.shape]="type.icon"
                  class="me-3 cds-icon-30 color-gray-darkest"></cds-icon>{{type.description|translate}}
              </li>
            </ul>
          </nz-dropdown-menu>
        </div>
        <div class="col-md-6 col-sm-9 col-8">
          <armon-filter-input #credentialDataInput class="responsiveContent" [minLength]=3
            placeholder="CREDENTIAL.TITLE_DATA" (entryCompleted)="onCredentialDataEntered($event)">
          </armon-filter-input>
        </div>
      </div>

      <div class="row mx-1 align-content-start modal-scroll-area-60 overflow-y-auto py-2">
        <div class="col-md-6 col-sm-12" *ngFor="let credentialData of currentIdentityCredentials">
          <armon-credential #credential [credential]="credentialData" (credentialRemoved)="onCredentialRemoved($event)"
            (credentialEdit)="onCredentialEdit($event)" [editEnabled]="true"></armon-credential>
        </div>
      </div>
      <!-- CONTENT CREDENTIAL -->
    </nz-tab>
  </nz-tabset>
</div>
<div class="modal-footer">
  <button class="btn btn-outline-primary me-2" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' |
    translate}}</button>
  <button class="btn btn-success" (click)="onCompleteForm($event)" [disabled]="!validForm">
    {{'BUTTON.SAVE' | translate}}
  </button>
</div>`;var Jt="";var te=`<div class="card mb-3">

  <div class="card-body p-3">
    <div class="d-flex mb-3">
      <div class="text-md">{{userGroup.name}}</div>
      <armon-card-badge [added]="isNewAdded"></armon-card-badge>
    </div>
  </div>

  <div class="card-footer">
    <button class="btn btn-sm btn-link" (click)="onRemoveClicked($event)">{{'BUTTON.REMOVE' | translate}}</button>
  </div>
</div>`;var ee=`.userGroupName{margin-top:2px;word-wrap:break-word}
`;var me=function(r,t,i,e){var n=arguments.length,s=n<3?t:e===null?e=Object.getOwnPropertyDescriptor(t,i):e,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,t,i,e);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(s=(n<3?o(s):n>3?o(t,i,s):o(t,i))||s);return n>3&&s&&Object.defineProperty(t,i,s),s},Y=class{userGroup;isNewAdded;userGroupRemoved=new u;constructor(){}ngOnInit(){}onRemoveClicked(t){this.userGroupRemoved.emit(this.userGroup.id)}static ctorParameters=()=>[];static propDecorators={userGroup:[{type:d}],isNewAdded:[{type:d}],userGroupRemoved:[{type:I}]}};Y=me([E({selector:"armon-identity-user-group",template:te,standalone:!0,imports:[H,v],styles:[ee]})],Y);var ie=`<div class="card mb-3">\r
  <div class="card-body p-3">\r
    <div class="d-flex mb-3">\r
      <div class="text-md">{{organizationUnit.name}}</div>\r
      <armon-card-badge [added]="isNewAdded" [updated]="isUpdated"></armon-card-badge>\r
    </div>\r
\r
    <div class="d-flex flex-column">\r
      <label [attr.for]="organizationUnit.organizationUnitId">{{'IDENTITY.ROLE' | translate}}</label>\r
      <select [id]="organizationUnit.organizationUnitId" [(ngModel)]="organizationUnit.roleId"\r
        (change)="onRoleChanged($event)" class="form-select form-select-sm">\r
        <option *ngFor="let option of roles" [ngValue]="option.id">{{option.name | translate}}</option>\r
      </select>\r
    </div>\r
  </div>\r
\r
  <div class="card-footer">\r
    <button class="btn btn-sm btn-link" (click)="onRemoveClicked($event)">{{'BUTTON.REMOVE' | translate}}</button>\r
  </div>\r
</div>`;var ne="";var Ie=function(r,t,i,e){var n=arguments.length,s=n<3?t:e===null?e=Object.getOwnPropertyDescriptor(t,i):e,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,t,i,e);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(s=(n<3?o(s):n>3?o(t,i,s):o(t,i))||s);return n>3&&s&&Object.defineProperty(t,i,s),s},B=class{roleService;organizationUnit;isNewAdded;isUpdated;organizationUnitRemoved=new u;organizationUnitUpdated=new u;constructor(t){this.roleService=t}get roles(){return this.roleService.allRoles.filter(t=>!t.isOrganizationWide)}ngOnInit(){}onRemoveClicked(t){this.organizationUnitRemoved.emit(this.organizationUnit.organizationUnitId)}onRoleChanged(t){this.organizationUnitUpdated.emit(this.organizationUnit)}static ctorParameters=()=>[{type:z}];static propDecorators={organizationUnit:[{type:d}],isNewAdded:[{type:d}],isUpdated:[{type:d}],organizationUnitRemoved:[{type:I}],organizationUnitUpdated:[{type:I}]}};B=Ie([E({selector:"armon-identity-organization-unit",template:ie,standalone:!0,imports:[H,P,b,S,v],styles:[ne]})],B);var it=class{constructor(t,i){this._document=i;let e=this._textarea=this._document.createElement("textarea"),n=e.style;n.position="fixed",n.top=n.opacity="0",n.left="-999em",e.setAttribute("aria-hidden","true"),e.value=t,e.readOnly=!0,(this._document.fullscreenElement||this._document.body).appendChild(e)}copy(){let t=this._textarea,i=!1;try{if(t){let e=this._document.activeElement;t.select(),t.setSelectionRange(0,t.value.length),i=this._document.execCommand("copy"),e&&e.focus()}}catch{}return i}destroy(){let t=this._textarea;t&&(t.remove(),this._textarea=void 0)}},R=class r{constructor(t){this._document=t}copy(t){let i=this.beginCopy(t),e=i.copy();return i.destroy(),e}beginCopy(t){return new it(t,this._document)}static{this.\u0275fac=D({minVersion:"12.0.0",version:"17.2.0",ngImport:c,type:r,deps:[{token:W}],target:O.Injectable})}static{this.\u0275prov=ht({minVersion:"12.0.0",version:"17.2.0",ngImport:c,type:r,providedIn:"root"})}};_({minVersion:"12.0.0",version:"17.2.0",ngImport:c,type:R,decorators:[{type:dt,args:[{providedIn:"root"}]}],ctorParameters:()=>[{type:void 0,decorators:[{type:V,args:[W]}]}]});var se=new ot("CDK_COPY_TO_CLIPBOARD_CONFIG"),A=class r{constructor(t,i,e){this._clipboard=t,this._ngZone=i,this.text="",this.attempts=1,this.copied=new u,this._pending=new Set,e&&e.attempts!=null&&(this.attempts=e.attempts)}copy(t=this.attempts){if(t>1){let i=t,e=this._clipboard.beginCopy(this.text);this._pending.add(e);let n=()=>{let s=e.copy();!s&&--i&&!this._destroyed?this._currentTimeout=this._ngZone.runOutsideAngular(()=>setTimeout(n,1)):(this._currentTimeout=null,this._pending.delete(e),e.destroy(),this.copied.emit(s))};n()}else this.copied.emit(this._clipboard.copy(this.text))}ngOnDestroy(){this._currentTimeout&&clearTimeout(this._currentTimeout),this._pending.forEach(t=>t.destroy()),this._pending.clear(),this._destroyed=!0}static{this.\u0275fac=D({minVersion:"12.0.0",version:"17.2.0",ngImport:c,type:r,deps:[{token:R},{token:k},{token:se,optional:!0}],target:O.Directive})}static{this.\u0275dir=It({minVersion:"14.0.0",version:"17.2.0",type:r,isStandalone:!0,selector:"[cdkCopyToClipboard]",inputs:{text:["cdkCopyToClipboard","text"],attempts:["cdkCopyToClipboardAttempts","attempts"]},outputs:{copied:"cdkCopyToClipboardCopied"},host:{listeners:{click:"copy()"}},ngImport:c})}};_({minVersion:"12.0.0",version:"17.2.0",ngImport:c,type:A,decorators:[{type:pt,args:[{selector:"[cdkCopyToClipboard]",host:{"(click)":"copy()"},standalone:!0}]}],ctorParameters:()=>[{type:R},{type:k},{type:void 0,decorators:[{type:at},{type:V,args:[se]}]}],propDecorators:{text:[{type:d,args:["cdkCopyToClipboard"]}],attempts:[{type:d,args:["cdkCopyToClipboardAttempts"]}],copied:[{type:I,args:["cdkCopyToClipboardCopied"]}]}});var C=class r{static{this.\u0275fac=D({minVersion:"12.0.0",version:"17.2.0",ngImport:c,type:r,deps:[],target:O.NgModule})}static{this.\u0275mod=yt({minVersion:"14.0.0",version:"17.2.0",ngImport:c,type:r,imports:[A],exports:[A]})}static{this.\u0275inj=gt({minVersion:"12.0.0",version:"17.2.0",ngImport:c,type:r})}};_({minVersion:"12.0.0",version:"17.2.0",ngImport:c,type:C,decorators:[{type:ut,args:[{imports:[A],exports:[A]}]}]});var he=function(r,t,i,e){var n=arguments.length,s=n<3?t:e===null?e=Object.getOwnPropertyDescriptor(t,i):e,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,t,i,e);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(s=(n<3?o(s):n>3?o(t,i,s):o(t,i))||s);return n>3&&s&&Object.defineProperty(t,i,s),s},re=class extends Ct{identityService;roleService;organizationUnitService;accessControlPointService;dynamicFormService;authService;interactionService;languageService;sessionService;page;identity;identityId;credentialDataInput;credentials;currentIdentityDetailed;currentIdentityBasic;currentIdentityCredentials=[];currentIdentityAccessRights=[];currentIdentityUserGroups=[];currentIdentityOrganizationUnits=[];isUserAccountFormAvailable=!1;permissionEditIdentity;permissionEditHierarhcy;permissionEditAccessRights;permissionEditUserGroup;permissionEditUserAccount;permissionGrantRemoteAccess;permissionCredentialWrite;identityFormInfo;identityUserAccountForm=new Nt({username:new F("",[p.required,p.minLength(f.USERNAME_MIN_LENGTH),p.maxLength(f.USERNAME_MAX_LENGTH)]),newPassword:new F("",[p.required,p.minLength(f.PASSWORD_MIN_LENGTH),p.maxLength(f.PASSWORD_MAX_LENGTH)]),confirmPassword:new F("",[p.required,p.minLength(f.PASSWORD_MIN_LENGTH),p.maxLength(f.PASSWORD_MAX_LENGTH)])});removedIdentityCredentials=[];removedIdentityOrganizationUnits=[];removedIdentityAccessRights=[];removedIdentityUserGroups=[];updatedIdentityOrganizationUnits=[];updatedIdentityAccessRights=[];addedIdentityOrganizationUnits=[];addedIdentityAccessRights=[];addedIdentityUserGroups=[];identityOrganizationProfileFormInit;subscriptionRoleListChanged;FIELD_NAME_CREDENTIAL_UNIQUE="id";FIELD_NAME_ORGANIZATIONUNIT_UNIQUE="organizationUnitId";FIELD_NAME_ORGANIZATIONUNIT_CHECK="roleId";FIELD_NAME_ORGANIZATIONUNIT_SORT="name";FIELD_NAME_ACCESSRIGHT_UNIQUE="accessControlPointId";FIELD_NAME_ACCESSRIGHT_CHECK="remoteAccess";FIELD_NAME_ACCESSRIGHT_SORT="accessControlPointName";FIELD_NAME_USER_GROUP_UNIQUE="id";FIELD_NAME_USER_GROUP_SORT="name";FIELD_NAME_CREDENTIAL_SORT="-groupNumber";FORM_FIELD_UNIQUEID="uniqueId";FORM_FIELD_USERNAME="username";FORM_FIELD_NEWPASSWORD="newPassword";FORM_FIELD_CONFIRMPASSWORD="confirmPassword";addableCredentialTypes;validForm=!1;visibleComponent=!1;selectedTabIndex=0;controlOrganizationUnitIds;controlAccessControlPointIds;controlGroupIds;constructor(t,i,e,n,s,o,a,T,N){super(),this.identityService=t,this.roleService=i,this.organizationUnitService=e,this.accessControlPointService=n,this.dynamicFormService=s,this.authService=o,this.interactionService=a,this.languageService=T,this.sessionService=N}get isUserAccountPasswordNotMatched(){return this.identityUserAccountForm&&this.identityUserAccountForm.get(this.FORM_FIELD_NEWPASSWORD)&&this.identityUserAccountForm.get(this.FORM_FIELD_NEWPASSWORD).value&&this.identityUserAccountForm.get(this.FORM_FIELD_CONFIRMPASSWORD)&&this.identityUserAccountForm.get(this.FORM_FIELD_CONFIRMPASSWORD).value&&this.identityUserAccountForm.get(this.FORM_FIELD_NEWPASSWORD).value!==this.identityUserAccountForm.get(this.FORM_FIELD_CONFIRMPASSWORD).value}get isUserAccountFormHasValue(){let t=!1;return Object.keys(this.identityUserAccountForm.controls).forEach(e=>{this.identityUserAccountForm.controls[e].value&&(t=!0)}),t}onModalInitialized(){super.onModalInitialized()}onModalViewInitialized(){super.onModalViewInitialized(),this.setSubscriptions(),this.processModalData()}onModalDestroyed(){super.onModalDestroyed(),this.subscriptionRoleListChanged&&this.subscriptionRoleListChanged.unsubscribe()}processModalData(){let t=[];this.sessionService.currentOrganizationCredentialTypes.forEach(i=>{if(K.getIsAddable(i)){let e=zt.find(n=>n.type==i);e&&t.push(e)}}),this.addableCredentialTypes=t,this.page&&(this.page=="credentials"?this.selectedTabIndex=4:this.page=="accessrights"?this.selectedTabIndex=3:this.page=="organizationunits"?this.selectedTabIndex=1:this.page=="usergroups"&&(this.selectedTabIndex=2)),this.setIdentityData()}onIdentityOrganizationProfileFieldFocus(t){}onIdentityOrganizationProfileFieldBlur(t){if(t===this.FORM_FIELD_UNIQUEID){let i=this.identityFormInfo.formGroup?this.identityFormInfo.formGroup.get(t).value:""}}onIdentityUsernameFieldFocus(t){}onIdentityUsernameFieldBlur(t){let i=this.identityUserAccountForm.get(this.FORM_FIELD_USERNAME).valid?this.identityUserAccountForm.get(this.FORM_FIELD_USERNAME).value:""}isUserAccountFormFieldInvalid(t){return vt(this.identityUserAccountForm,t)}onCredentialDataEntered(t){this.credentialDataInput.resetText();let i=this.currentIdentityCredentials.find(e=>e.data===this.sessionService.getConvertedCredentialData(t));if(i)this.interactionService.showDialog("IDENTITY.TITLE_CREDENTIALS","CREDENTIAL.INFO_REMOVE",null,null,!0,"BUTTON.REMOVE","",!0,()=>{this.onCredentialRemoved(i.id)});else{let e=new K;e.data=t,this.modalService.open(x,{settings:{size:"md"},props:{credential:e}}).result.then(n=>{n&&this.currentIdentityCredentials.push(n),m(this.currentIdentityCredentials,this.FIELD_NAME_CREDENTIAL_SORT)}).catch(n=>{})}}onAddCredentialClicked(t,i){this.modalService.open(x,{settings:{size:"md",centered:!0,scrollable:!0},props:{credential:null,type:i}}).result.then(e=>{e&&this.currentIdentityCredentials.push(e),m(this.currentIdentityCredentials,this.FIELD_NAME_CREDENTIAL_SORT)}).catch(e=>{})}onCredentialRemoved(t){g(this.currentIdentityCredentials,this.FIELD_NAME_CREDENTIAL_UNIQUE,t),m(this.currentIdentityCredentials,this.FIELD_NAME_CREDENTIAL_SORT),t.startsWith(M.NEW_CREDENTIAL)||this.removedIdentityCredentials.push(t)}onCredentialEdit(t){let i=this.currentIdentityCredentials.find(e=>e.id==t);this.modalService.open(x,{settings:{size:"md",centered:!0,scrollable:!0},props:{credential:i,type:i.type,editMode:!0}}).result.then(e=>{e&&(Ut(this.currentIdentityCredentials,{id:e.id},e),this.credentials.forEach(n=>{n.render()}),m(this.currentIdentityCredentials,this.FIELD_NAME_CREDENTIAL_SORT))}).catch(e=>{})}onOrganizationUnitRemoved(t){let i=this.removeOperationOnList(this.FIELD_NAME_ORGANIZATIONUNIT_UNIQUE,t,this.currentIdentityOrganizationUnits,this.addedIdentityOrganizationUnits,this.updatedIdentityOrganizationUnits,this.removedIdentityOrganizationUnits);this.controlOrganizationUnitIds.findIndex(e=>e==t)>-1&&(this.controlOrganizationUnitIds.splice(this.controlOrganizationUnitIds.findIndex(e=>e==t),1),this.controlOrganizationUnitIds=h(this.controlOrganizationUnitIds)),this.permissionEditAccessRights&&this.removeDefaultAccessControlPoints(i)}onOrganizationUnitUpdated(t){this.updateOperationOnList(this.FIELD_NAME_ORGANIZATIONUNIT_UNIQUE,this.FIELD_NAME_ORGANIZATIONUNIT_CHECK,t,this.currentIdentityDetailed?this.currentIdentityDetailed.organizationUnits||[]:[],this.addedIdentityOrganizationUnits,this.updatedIdentityOrganizationUnits)}onUnitSelected(t){this.organizationUnitService.getOrganizationUnitDetails(t.data.id).subscribe(i=>{let e=new L;e.ancestorIds=i.ancestorIds,e.defaultAccessControlPointIds=i.defaultAccessControlPoints.map(n=>n.id),e.extraPermissions=[],e.roleId=this.roleService.getRoleIdWithType(q.STANDARD_USER),e.name=i.name,e.organizationUnitId=i.id,e.typeId=i.typeId,this.addOperationOnList(this.FIELD_NAME_ORGANIZATIONUNIT_UNIQUE,this.FIELD_NAME_ORGANIZATIONUNIT_SORT,this.FIELD_NAME_ORGANIZATIONUNIT_CHECK,i.id,e,this.currentIdentityDetailed?this.currentIdentityDetailed.organizationUnits||[]:[],this.currentIdentityOrganizationUnits,this.addedIdentityOrganizationUnits,this.updatedIdentityOrganizationUnits,this.removedIdentityOrganizationUnits),this.permissionEditAccessRights&&this.addDefaultAccessControlPoints(i)})}onUnitUnselected(t){this.onOrganizationUnitRemoved(t.data.id)}onUserGroupRemoved(t){let i=this.removeOperationOnList(this.FIELD_NAME_USER_GROUP_UNIQUE,t,this.currentIdentityUserGroups,this.addedIdentityUserGroups,[],this.removedIdentityUserGroups);this.controlGroupIds.findIndex(e=>e==t)>-1&&(this.controlGroupIds.splice(this.controlGroupIds.findIndex(e=>e==t),1),this.controlGroupIds=h(this.controlGroupIds))}onGroupSelected(t){this.addOperationOnList(this.FIELD_NAME_USER_GROUP_UNIQUE,this.FIELD_NAME_USER_GROUP_SORT,"",t.data.id,t.data,this.currentIdentityDetailed?this.currentIdentityDetailed.userGroups||[]:[],this.currentIdentityUserGroups,this.addedIdentityUserGroups,[],this.removedIdentityUserGroups)}onGroupUnselected(t){this.onUserGroupRemoved(t.data.id)}onAccessRightRemoved(t){this.controlAccessControlPointIds&&this.controlAccessControlPointIds.findIndex(i=>i==t)>-1&&(this.controlAccessControlPointIds.splice(this.controlAccessControlPointIds.findIndex(i=>i==t),1),this.controlAccessControlPointIds=h(this.controlAccessControlPointIds)),this.removeOperationOnList(this.FIELD_NAME_ACCESSRIGHT_UNIQUE,t,this.currentIdentityAccessRights,this.addedIdentityAccessRights,this.updatedIdentityAccessRights,this.removedIdentityAccessRights)}onAccessRightUpdated(t){this.updateOperationOnList(this.FIELD_NAME_ACCESSRIGHT_UNIQUE,t.field,t.accessRight,this.currentIdentityDetailed?this.currentIdentityDetailed.accessRights||[]:[],this.addedIdentityAccessRights,this.updatedIdentityAccessRights)}onPointSelected(t){t&&t.length>0&&this.accessControlPointService.getAccessControlPointBasicList({accessControlPointIds:t.map(i=>i.data.id)}).subscribe(i=>{i&&i.items?.length>0&&i.items.forEach(e=>{this.addAccessControlPoint(e,!1)})})}onPointUnselected(t){t&&t.length>0&&t.forEach(i=>{this.onAccessRightRemoved(i.data.id)})}onCompleteForm(t){this.currentIdentityBasic&&this.currentIdentityBasic.id&&this.currentIdentityBasic.id!=null?this.updateIdentity():this.insertIdentity()}isNewAccessRight(t){return y(this.addedIdentityAccessRights,this.FIELD_NAME_ACCESSRIGHT_UNIQUE,t.accessControlPointId)>=0}isUpdatedAccessRight(t){return y(this.updatedIdentityAccessRights,this.FIELD_NAME_ACCESSRIGHT_UNIQUE,t.accessControlPointId)>=0}isNewOrganizationUnit(t){return y(this.addedIdentityOrganizationUnits,this.FIELD_NAME_ORGANIZATIONUNIT_UNIQUE,t.organizationUnitId)>=0}isUpdatedOrganizationUnit(t){return y(this.updatedIdentityOrganizationUnits,this.FIELD_NAME_ORGANIZATIONUNIT_UNIQUE,t.organizationUnitId)>=0}isNewUserGroup(t){return y(this.addedIdentityUserGroups,this.FIELD_NAME_USER_GROUP_UNIQUE,t.id)>=0}setSubscriptions(){this.identityFormInfo=this.dynamicFormService.getFormInfo(Tt.UserOrganizationProfile),this.identityFormInfo.formGroup.statusChanges.subscribe(()=>{this.checkPageCompletedStates()}),this.identityUserAccountForm.statusChanges.subscribe(()=>{this.checkPageCompletedStates()}),this.identityOrganizationProfileFormInit=!0}checkPermissions(){let t=this.getOrganizationUnitIds();this.permissionEditIdentity=this.authService.checkPermission(l.IDENTITY.getEdit(),t),this.permissionEditHierarhcy=this.authService.checkPermission([l.ORGANIZATIONUNIT.getReadBasic(),l.IDENTITY.getHierarchy()],t),this.permissionEditAccessRights=this.authService.checkPermission([l.IDENTITY.getAccessRight()],t),this.permissionEditUserGroup=this.authService.checkPermission(l.USERGROUP.getRead(),t),this.permissionEditUserAccount=this.authService.checkPermission(l.IDENTITY.getUserAccount(),t),this.permissionGrantRemoteAccess=this.authService.checkPermission([l.IDENTITY.getAccessRight(),l.IDENTITY.getGrantRemoteAccess()],t),this.permissionCredentialWrite=this.authService.checkPermission([l.IDENTITY.getReadDetailed(),l.IDENTITY.getCredentialWrite()],t)}getOrganizationUnitIds(){let t=[];return this.currentIdentityBasic&&this.currentIdentityBasic.organizationUnits&&this.currentIdentityBasic.organizationUnits.forEach(i=>{~t.indexOf(i.id)||t.push(i.id),i.ancestorIds.forEach(e=>{~t.indexOf(e)||t.push(e)})}),t}setIdentityData(){this.currentIdentityBasic=this.identity,this.checkPermissions(),this.isUserAccountFormAvailable=(!this.currentIdentityBasic||this.currentIdentityBasic.hasUserAccount!=null&&!this.currentIdentityBasic.hasUserAccount)&&this.permissionEditUserAccount,this.identity&&this.identity.id?this.getIdentityDetails(this.identity.id):this.identityId?this.getIdentityDetails(this.identityId):(this.visibleComponent=!0,this.currentIdentityBasic.hasUserAccount=!1,Q(this.identityFormInfo,{roleId:this.roleService.getRoleIdWithType(q.STANDARD_USER_ORGANIZATION),isActive:!0}))}getIdentityDetails(t){this.identityService.getIdentityDetailedById(t).subscribe({next:i=>{this.currentIdentityBasic=new Ht,this.currentIdentityBasic.id=i.id,this.currentIdentityDetailed=i,this.setFields(),this.visibleComponent=!0},error:i=>{setTimeout(()=>{this.cancelModal()},1e3)}})}setFields(){Q(this.identityFormInfo,this.currentIdentityDetailed.organizationProfile),this.currentIdentityDetailed.credentials.forEach(t=>this.currentIdentityCredentials.push(t)),this.currentIdentityAccessRights=new U().createInstanceArray(this.currentIdentityDetailed.accessRights,U),this.currentIdentityOrganizationUnits=new L().createInstanceArray(this.currentIdentityDetailed.organizationUnits,L),this.currentIdentityUserGroups=new X().createInstanceArray(this.currentIdentityDetailed.userGroups,X),m(this.currentIdentityAccessRights,this.FIELD_NAME_ACCESSRIGHT_SORT),m(this.currentIdentityOrganizationUnits,this.FIELD_NAME_ORGANIZATIONUNIT_SORT),m(this.currentIdentityUserGroups,this.FIELD_NAME_USER_GROUP_SORT),m(this.currentIdentityCredentials,this.FIELD_NAME_CREDENTIAL_SORT),this.permissionEditHierarhcy&&(this.controlOrganizationUnitIds=this.currentIdentityOrganizationUnits&&this.currentIdentityOrganizationUnits.length>0?this.currentIdentityOrganizationUnits.map(t=>t.organizationUnitId):[]),this.permissionEditAccessRights&&(this.controlAccessControlPointIds=this.currentIdentityAccessRights&&this.currentIdentityAccessRights.length>0?this.currentIdentityAccessRights.map(t=>t.accessControlPointId):[]),this.permissionEditUserGroup&&(this.controlGroupIds=this.currentIdentityUserGroups&&this.currentIdentityUserGroups.length>0?this.currentIdentityUserGroups.map(t=>t.id):[]),!this.permissionEditIdentity&&this.permissionCredentialWrite?this.identityFormInfo.formGroup.disable():this.identityFormInfo.formGroup.enable()}checkPageCompletedStates(){this.validForm=this.identityFormInfo.formGroup.valid&&this.identityFormInfo.formGroup.valid&&(!this.isUserAccountFormHasValue||this.identityUserAccountForm.valid)}onValidationForConfirm(){return new Promise(t=>this.identityUserAccountForm&&this.identityUserAccountForm.get("newPassword")&&this.identityUserAccountForm.get("newPassword").value&&this.identityUserAccountForm.get("confirmPassword")&&this.identityUserAccountForm.get("confirmPassword").value&&this.identityUserAccountForm.get("newPassword").value!==this.identityUserAccountForm.get("confirmPassword").value?(this.identityUserAccountForm.get("confirmPassword").setErrors({notMatched:!0}),!1):(this.identityUserAccountForm.get("confirmPassword").setErrors(null),!0))}insertIdentity(){let t=new Lt;t.organizationProfile=new J,$(this.identityFormInfo.formGroup,this.identityFormInfo.formFields,t.organizationProfile),t.organizationProfile.isDisabled=!t.organizationProfile.isActive,t.organizationProfile.pacsEnabledRemainedAnnualPPermission=+t.organizationProfile.pacsEnabledRemainedAnnualPPermission,t.organizationProfile.previousServiceDuration=+t.organizationProfile.previousServiceDuration,this.isUserAccountFormHasValue&&(t.userAccount=new et,t.userAccount.username=this.identityUserAccountForm.get(this.FORM_FIELD_USERNAME).value.trim(),t.userAccount.password=this.identityUserAccountForm.get(this.FORM_FIELD_NEWPASSWORD).value),t.credentials=[],this.currentIdentityCredentials.forEach(i=>{let e=new w;e.copyFrom(this.sessionService,i),t.credentials.push(e)}),t.accessRights=[],this.currentIdentityAccessRights.forEach(i=>{if(i.isValid){let e=new G;e.copyFrom(i),t.accessRights.push(e)}}),t.organizationUnits=[],this.currentIdentityOrganizationUnits.forEach(i=>{let e=new tt;e.copyFrom(i),t.organizationUnits.push(e)}),t.userGroupIds=[],this.currentIdentityUserGroups.forEach(i=>{t.userGroupIds.push(i.id)}),this.identityService.addIdentity(t).subscribe(i=>{this.interactionService.showMessage("IDENTITY.INSERT_SUCCEED",null,j.Success);let e=i.getBasicCopy(this.isUserAccountFormHasValue);this.closeModal(e)})}updateIdentity(){let t=new xt;t.id=this.currentIdentityDetailed.id,t.organizationProfile=new J,$(this.identityFormInfo.formGroup,this.identityFormInfo.formFields,t.organizationProfile),t.organizationProfile.isDisabled=!t.organizationProfile.isActive,t.organizationProfile.pacsEnabledRemainedAnnualPPermission=+t.organizationProfile.pacsEnabledRemainedAnnualPPermission,t.organizationProfile.previousServiceDuration=+t.organizationProfile.previousServiceDuration,this.isUserAccountFormHasValue&&(t.userAccount=new et,t.userAccount.username=this.identityUserAccountForm.get(this.FORM_FIELD_USERNAME).value.trim(),t.userAccount.password=this.identityUserAccountForm.get(this.FORM_FIELD_NEWPASSWORD).value),t.addedCredentials=[],this.currentIdentityCredentials.filter(n=>n.id.startsWith(M.NEW_CREDENTIAL)).forEach(n=>{let s=new w;s.copyFrom(this.sessionService,n),t.addedCredentials.push(s)}),t.updatedCredentials=[],this.currentIdentityCredentials.filter(n=>!n.id.startsWith(M.NEW_CREDENTIAL)&&n.edited).forEach(n=>{let s=new w;s.copyFrom(this.sessionService,n),t.updatedCredentials.push(s)}),t.removedCredentialIds=[],this.removedIdentityCredentials.forEach(n=>{t.removedCredentialIds.push(n)}),t.addedAccessRights=[],this.addedIdentityAccessRights.forEach(n=>{if(n.isValid){let s=new G;s.copyFrom(n),t.addedAccessRights.push(s)}}),t.updatedAccessRights=[],this.updatedIdentityAccessRights.forEach(n=>{if(n.isValid){let s=new G;s.copyFrom(n),t.updatedAccessRights.push(s)}}),t.removedAccessControlPointIds=[],this.removedIdentityAccessRights.forEach(n=>{t.removedAccessControlPointIds.push(n)}),t.addedOrganizationUnits=[],this.addedIdentityOrganizationUnits.forEach(n=>{let s=new tt;s.copyFrom(n),t.addedOrganizationUnits.push(s)}),t.updatedOrganizationUnits=[],this.updatedIdentityOrganizationUnits.forEach(n=>{let s=new Mt;s.copyFrom(n),t.updatedOrganizationUnits.push(s)}),t.removedOrganizationUnitIds=[],this.removedIdentityOrganizationUnits.forEach(n=>{t.removedOrganizationUnitIds.push(n)}),t.addedUserGroupIds=[],this.addedIdentityUserGroups.forEach(n=>{t.addedUserGroupIds.push(n.id)}),t.removedUserGroupIds=[],this.removedIdentityUserGroups.forEach(n=>{t.removedUserGroupIds.push(n)}),this.identityService.updateIdentity(t).subscribe(n=>{this.interactionService.showMessage("IDENTITY.UPDATE_SUCCEED",null,j.Success);let s=n.getBasicCopy(this.currentIdentityBasic.hasUserAccount||this.isUserAccountFormHasValue);this.closeModal(s)})}removeOperationOnList(t,i,e,n,s,o){let a=g(e,t,i);return Z(n,t,i)?g(n,t,i):(g(s,t,i),o.push(i)),a}addOperationOnList(t,i,e,n,s,o,a,T,N,nt){a.push(s),m(a,i);let st=nt.indexOf(n);st>=0&&nt.splice(st,1);let rt=o.find(oe=>oe[t]===n);rt?e?rt[e]!==s[e]&&N.push(s):N.push(s):T.push(s)}updateOperationOnList(t,i,e,n,s,o){let a=n.find(T=>T[t]===e[t]);a?(g(o,t,e[t]),a[i]!==e[i]&&o.push(e)):(g(s,t,e[t]),s.push(e))}addAccessControlPoint(t,i=!0){let e;if(this.currentIdentityDetailed?.accessRights&&!Et(this.currentIdentityDetailed?.accessRights)&&this.currentIdentityDetailed.accessRights.findIndex(n=>n.accessControlPointId===t.id)>=0)e=U.getEmptyModel(),e.createInstance(h(this.currentIdentityDetailed.accessRights.find(n=>n.accessControlPointId===t.id)),U,e);else{e=new U,e.accessControlPointId=t.id,e.accessControlPointIsRemoteDefault=t.isRemoteDefault||!1,e.accessControlPointName=t.name,e.accessControlPointRemoteAvailable=t.remoteAvailable||!1,e.managable=!0;let n=wt.getEmptyModel(t,this.permissionGrantRemoteAccess,t.userRights);e.access=n.access,e.config=n.config,e.read=n.read,e.grant=n.grant,e.remoteAccess=n.remoteAccess,e.snapshot=n.snapshot,e.userRights=t.userRights}i&&(this.controlAccessControlPointIds||(this.controlAccessControlPointIds=[]),this.controlAccessControlPointIds.findIndex(n=>n==t.id)==-1&&this.controlAccessControlPointIds.push(t.id),this.controlAccessControlPointIds=h(this.controlAccessControlPointIds)),this.addOperationOnList(this.FIELD_NAME_ACCESSRIGHT_UNIQUE,this.FIELD_NAME_ACCESSRIGHT_SORT,void 0,t.id,e,this.currentIdentityDetailed?this.currentIdentityDetailed.accessRights||[]:[],this.currentIdentityAccessRights,this.addedIdentityAccessRights,this.updatedIdentityAccessRights,this.removedIdentityAccessRights)}addDefaultAccessControlPoints(t){if(t){let i=t.defaultAccessControlPoints.filter(e=>!Z(this.currentIdentityAccessRights,this.FIELD_NAME_ACCESSRIGHT_UNIQUE,e.id)&&e.managable);i.length>0&&this.interactionService.showDialog("IDENTITY.TITLE_ACCESS_RIGHTS","IDENTITY.DEFAULT_ACCESS_RIGHTS_ADD",null,t,null,"BUTTON.YES","BUTTON.NO",!1,()=>{i.forEach(e=>this.addAccessControlPoint(e))})}}removeDefaultAccessControlPoints(t){if(t){let i=[];t.defaultAccessControlPointIds.forEach(e=>{let n=y(this.currentIdentityAccessRights,this.FIELD_NAME_ACCESSRIGHT_UNIQUE,e);n>=0&&this.currentIdentityAccessRights[n].managable&&i.push(this.currentIdentityAccessRights[n])}),i.length>0&&this.interactionService.showDialog("IDENTITY.TITLE_ACCESS_RIGHTS","IDENTITY.DEFAULT_ACCESS_RIGHTS_REMOVE",null,t,null,"BUTTON.YES","BUTTON.NO",!1,()=>{if(this.controlAccessControlPointIds){let e=h(this.controlAccessControlPointIds);i.forEach(n=>{e.findIndex(s=>s==n.accessControlPointId)>-1&&e.splice(e.findIndex(s=>s==n.accessControlPointId),1)}),this.controlAccessControlPointIds=e}i.forEach(e=>this.onAccessRightRemoved(e.accessControlPointId))})}}static ctorParameters=()=>[{type:Yt},{type:z},{type:Bt},{type:Qt},{type:bt},{type:Wt},{type:Dt},{type:_t},{type:Rt}];static propDecorators={page:[{type:d}],identity:[{type:d}],identityId:[{type:d}],credentialDataInput:[{type:mt,args:["credentialDataInput"]}],credentials:[{type:lt,args:["credential"]}]}};re=he([E({selector:"armon-identity-modal",template:Xt,schemas:[ct],standalone:!0,imports:[kt,ft,At,Gt,C,$t,P,Ot,b,v,Vt,S,B,Y,Zt,Kt,Pt,Ft,St,qt,jt],styles:[Jt]})],re);export{C as a,re as b};
