import{a as T,b as B}from"./chunk-YKYLT6FT.js";import"./chunk-I5K7GPAI.js";import"./chunk-VQU52MNH.js";import"./chunk-MXSLISEG.js";import"./chunk-7GYHTWED.js";import"./chunk-3GSDFESG.js";import"./chunk-7QEXVS2A.js";import{a as N}from"./chunk-D4RZOGGF.js";import"./chunk-HXEFMD5A.js";import"./chunk-KCLQIV7M.js";import"./chunk-5KCUTXXV.js";import"./chunk-JUDWAYYT.js";import"./chunk-LAJI7RPC.js";import"./chunk-WFZJP5WR.js";import"./chunk-F6KLNSUK.js";import{b as y,c as E,d as A}from"./chunk-YOJ4KGSB.js";import"./chunk-CO3X7TQN.js";import{a as _}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{Ob as w,wb as x}from"./chunk-YSQLW2JA.js";import{ee as S}from"./chunk-NVJ2ZZFT.js";import{Aa as d,Ba as b,Mg as L,Ng as p,Pd as C,Rd as I,Te as P,ab as g,bb as z,bh as R,dd as U,ha as u,hd as v,lc as O,mc as m,wa as f,ya as c}from"./chunk-SKPDQO4E.js";var D=`<div class="h-100">
  <side-navigation>
    <ng-template side-navigation-nav>
      <!-- Filtering area -->
      <label class="report-form-label">{{'ORGANIZATIONUNIT.SEARCH' | translate}}</label>
      <armon-select-search query="unit" [allowMulti]="false" [enabledAutoClearSearchValue]="false"
        [(ngModel)]="filterOrganizationUnitId" (ngModelChange)="onFilterChanged($event)">
      </armon-select-search>
    </ng-template>
    <ng-template side-navigation-content>
      <!-- Breadcrumb of organization unit hierarchy path -->
      <armon-breadcrumb [items]="currentOrganizationUnitPath" [showRoot]="true"
        [rootName]="sessionService.currentOrganizationName"
        (selectionChanged)="organizationUnitSelectionChanged($event)">
      </armon-breadcrumb>
      <!-- Listing area -->
      <div class="row mb-3">
        <div class="col-xl-12 col-lg-6 col-md-12">
          <!-- Add new organization unit button -->
          <button class="btn btn-sm btn-primary" (click)="onAddOrganizationUnitButtonClicked()"
            *ngIf="permissionAddOrganizationUnit">{{'ORGANIZATIONUNIT.ADD' | translate}}</button>
        </div>
      </div>
      <ng-container *ngIf="paginationOrganizationUnitList">
        <div class="row" [@listAnimation]="paginationOrganizationUnitList.length">
          <!-- List of user groups -->
          <div class="col-xxxl-4 col-xl-6 col-lg-6 col-md-12"
            *ngFor="let organizationUnit of paginationOrganizationUnitList">
            <armon-organization-unit-basic [organizationUnit]="organizationUnit"
              (showChildrenRequested)="onShowChildrenRequested($event)"
              (organizationUnitUpdated)="onOrganizationUnitUpserted($event)"
              (organizationUsersUpdated)="onOrganizationUnitUpserted($event)"
              (organizationUnitDeleted)="onOrganizationUnitDeleted($event)"></armon-organization-unit-basic>
          </div>
          <div class="col-12 my-3">
            <armon-pagination [paginationResponse]="paginationResponse" [scrollDomId]="'side-nav-content'"
              (pageChanged)="pageChanged($event)"></armon-pagination>
          </div>
        </div>
      </ng-container>
      <div class="row pt-3" *ngIf="paginationOrganizationUnitList && paginationOrganizationUnitList.length === 0">
        <div class="col-12">
          <nz-empty [nzNotFoundContent]="contentTpl" [nzNotFoundImage]="'./assets/images/empty/empty_list.png'">
            <ng-template #contentTpl>
              <span>{{'ORGANIZATIONUNIT.INFO_EMPTY_CHILDREN_LIST'|translate}}</span>
            </ng-template>
          </nz-empty>
        </div>
      </div>
    </ng-template>
  </side-navigation>
</div>`;var M=`.emptyInfo{text-align:center;color:#c82602}
`;var l=class{constructor(t,i){this.id=t,this.name=i}id;name};var F=`<span class="breadcrumpContainer d-flex">
  <ul class="breadcrumpList d-flex" #list>
    <li *ngFor="let item of breadcrumbItems" (click)="changeSelection(item.id)">
      <!-- <cds-icon shape="home"></cds-icon> -->
      <span>{{item.name}}</span>
    </li>
  </ul>
</span>`;var G=`.breadcrumpContainer{white-space:nowrap}.breadcrumpList{margin:8px 0;padding:4px 0;width:100%;overflow-x:auto;overflow-y:hidden}.breadcrumpList li{display:flex;font-size:12px;color:#0a2a5a;cursor:pointer;float:left;margin-left:0;width:auto;height:20px;padding:5px 5px 5px 20px;list-style-type:none;border-right:3px solid white;position:relative}.breadcrumpList i{font-size:18px;padding-right:6px}.breadcrumpList span{align-items:center;display:flex}.breadcrumpList li:first-child{padding-left:5px;background-color:#0369a1;color:#fff}.breadcrumpList li:first-child:after{border-left-color:#0369a1}.breadcrumpList li:last-child{color:#fff;background-color:#0a2a5a}.breadcrumpList li:last-child:after{border-left-color:#0a2a5a}.breadcrumpList li:nth-child(n+2):before{position:absolute;top:0;left:0;display:block;border-left:10px solid #f3f4f6;border-top:10px solid transparent;border-bottom:10px solid transparent;width:0;height:0;content:" "}.breadcrumpList li:after{z-index:1;position:absolute;top:0;right:-10px;display:block;border-left:10px solid #e1f1f6;border-top:10px solid transparent;border-bottom:10px solid transparent;width:0;height:0;content:" "}.breadcrumpList li{background-color:#e1f1f6}.breadcrumpList li:after{border-left-color:#e1f1f6}.breadcrumpList li:hover{background-color:#eb8d00;color:#000}.breadcrumpList li:hover:after{border-left-color:#eb8d00;color:#000}
`;var V=function(a,t,i,n){var e=arguments.length,r=e<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,i):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(a,t,i,n);else for(var s=a.length-1;s>=0;s--)(o=a[s])&&(r=(e<3?o(r):e>3?o(t,i,r):o(t,i))||r);return e>3&&r&&Object.defineProperty(t,i,r),r},h=class{items=[];showRoot=!0;rootName;selectionChanged=new u;itemListElement;breadcrumbItems=[];elementObserver;constructor(){}ngOnInit(){this.updateBreadcrumbItems(this.items)}ngOnDestroy(){this.elementObserver&&this.elementObserver.disconnect()}ngOnChanges(t){this.updateBreadcrumbItems(t.items.currentValue)}ngAfterViewInit(){this.initializeObservers()}changeSelection(t){this.selectionChanged.emit(t)}initializeObservers(){this.elementObserver=new MutationObserver(i=>{i.forEach(function(n){try{n.target instanceof Element&&(n.target.scrollLeft=n.target.scrollWidth)}catch{}})});let t={attributes:!0,childList:!0,characterData:!0};this.itemListElement&&this.itemListElement.nativeElement&&this.elementObserver.observe(this.itemListElement.nativeElement,t)}updateBreadcrumbItems(t){if(this.breadcrumbItems=[],this.showRoot){let i=new l(null,this.rootName);this.breadcrumbItems.push(i)}t&&t.forEach(i=>this.breadcrumbItems.push(i))}static ctorParameters=()=>[];static propDecorators={items:[{type:d}],showRoot:[{type:d}],rootName:[{type:d}],selectionChanged:[{type:b}],itemListElement:[{type:f,args:["list",{static:!0}]}]}};h=V([c({selector:"armon-breadcrumb",template:F,standalone:!0,imports:[g],styles:[G]})],h);var Z=function(a,t,i,n){var e=arguments.length,r=e<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,i):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(a,t,i,n);else for(var s=a.length-1;s>=0;s--)(o=a[s])&&(r=(e<3?o(r):e>3?o(t,i,r):o(t,i))||r);return e>3&&r&&Object.defineProperty(t,i,r),r},k=class{sessionService;organizationUnitService;authService;modalService;permissionAddOrganizationUnit;organizationUnitPath=[];organizationUnitList=[];paginationOrganizationUnitList=null;paginationResponse=new p;paginationRequest=new L;filterOrganizationUnitId=null;constructor(t,i,n,e){this.sessionService=t,this.organizationUnitService=i,this.authService=n,this.modalService=e}get currentOrganizationUnitPath(){return this.organizationUnitPath}set currentOrganizationUnitPath(t){this.organizationUnitPath=t,this.checkPermissions()}ngOnInit(){this.checkPermissions(),this.getChildren()}onAddOrganizationUnitButtonClicked(){let t=this.currentOrganizationUnitPath&&this.currentOrganizationUnitPath.length>0?this.currentOrganizationUnitPath[this.currentOrganizationUnitPath.length-1]:null;this.modalService.open(T,{settings:{size:"lg",scrollable:!0},props:{parentOrganizationUnit:t}}).result.then(i=>{this.onOrganizationUnitUpserted()}).catch(i=>{})}onFilterChanged(t){t&&this.organizationUnitService.getOrganizationUnitBasic(this.filterOrganizationUnitId).subscribe(i=>{this.getSiblings(i)})}onShowChildrenRequested(t){t&&this.showChildrenOfOrganizationUnit(t)}onOrganizationUnitDeleted(t){let i=this.currentOrganizationUnitPath.length>0?this.currentOrganizationUnitPath[this.currentOrganizationUnitPath.length-1].id:null;this.getChildren(i)}onOrganizationUnitUpserted(){let t=this.currentOrganizationUnitPath.length>0?this.currentOrganizationUnitPath[this.currentOrganizationUnitPath.length-1].id:null;this.getChildren(t)}organizationUnitSelectionChanged(t){if(t){let i=this.currentOrganizationUnitPath.findIndex(n=>n.id===t);this.currentOrganizationUnitPath=i>-1?this.currentOrganizationUnitPath.slice(0,i+1):[]}else this.currentOrganizationUnitPath=[];this.getChildren(t)}checkPermissions(){let t=this.currentOrganizationUnitPath.map(i=>i.id);this.permissionAddOrganizationUnit=this.authService.checkPermission(v.ORGANIZATIONUNIT.getWrite(),t)}setPaginatedResult(t,i,n){this.paginationOrganizationUnitList=this.organizationUnitList.slice(t,t+i);let e=new p;e.skip=t,e.take=i,e.total=n,this.paginationResponse=e}getChildren(t){this.organizationUnitService.getChildrenOfOrganizationUnit(t).subscribe({next:i=>{m(i,"name"),this.organizationUnitList=i,this.setPaginatedResult(0,20,i.length)},error:i=>{this.organizationUnitList=[],this.paginationOrganizationUnitList=null}})}getSiblings(t){this.organizationUnitService.getSiblingsOfOrganizationUnit(t.id).subscribe({next:i=>{let n=[];n.push(...i.siblings||[]),m(n,"name"),i.self.selected=!0,n.unshift(i.self),this.organizationUnitList=n,this.setPaginatedResult(0,20,n.length);let e=[];i.ancestors.forEach(r=>{e.push(new l(r.id,r.name))}),this.currentOrganizationUnitPath=e},error:i=>{this.organizationUnitList=[],this.paginationOrganizationUnitList=null}})}showChildrenOfOrganizationUnit(t){this.currentOrganizationUnitPath=O(this.currentOrganizationUnitPath,new l(t.id,t.name)),this.getChildren(t.id)}pageChanged(t){this.setPaginatedResult(t.skip,t.take,this.paginationResponse.total)}static ctorParameters=()=>[{type:C},{type:S},{type:w},{type:I}]};k=Z([c({selector:"armon-manage-organization-units-wide",template:D,animations:N,standalone:!0,imports:[A,y,x,P,E,h,z,g,B,_,R,U],styles:[M]})],k);export{k as ManageOrganizationUnitsWideComponent};
