import{a as Z,b as ee}from"./chunk-S4UARQQV.js";import{a as J}from"./chunk-I5K7GPAI.js";import{a as W}from"./chunk-D4RZOGGF.js";import{b as H,c as Q,d as X}from"./chunk-YOJ4KGSB.js";import"./chunk-CO3X7TQN.js";import{a as Y}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{Mb as $,Ob as b,Xa as G,Ya as K,s as P,tb as d,v as j,wb as T,y as q}from"./chunk-YSQLW2JA.js";import"./chunk-NVJ2ZZFT.js";import{Aa as g,Ba as C,Fb as w,He as u,Mc as R,Mg as V,Nc as z,Ng as F,Qf as y,Rd as h,Sd as N,Se as D,Te as v,Ue as M,Wb as A,_a as I,ab as k,af as L,bb as l,dc as O,dd as p,gb as E,ha as S,hd as m,kb as _,kg as U,ng as B,ya as c}from"./chunk-SKPDQO4E.js";var te=`<div class="h-100">
    <side-navigation>
        <ng-template side-navigation-nav>
            <!-- Filtering area -->
            <div class="row">
                <div class="col-xl-12">
                    <label class="report-form-label">{{'REPORT.REGION' | translate}}</label>
                    <armon-select-search query="region" [allowMulti]="true" [(ngModel)]="filter.regionIds"
                        (ngModelChange)="onRegionChanged($event)">
                    </armon-select-search>
                </div>
            </div>
        </ng-template>
        <ng-template side-navigation-content>
            <!-- Listing area -->
            <div class="row my-3">
                <div class="col-12">
                    <!-- Add new ticket type button -->
                    <button class="btn btn-sm btn-primary" (click)="onAddTicketTypeClicked()"
                        *ngIf="permissionAddTicketType">{{'SOCA.TICKET_TYPE_ADD'
                        | translate}}</button>
                </div>
            </div>
            <div class="row" [@listAnimation]="ticketTypes.length">
                <!-- List of ticket types -->
                <div class="col-xl-6 col-lg-6 col-md-12" *ngFor="let ticketType of ticketTypes">
                    <armon-soca-ticket-type-card [ticketType]="ticketType"
                        (ticketTypeDeleted)="onTicketTypeDeleted($event)"></armon-soca-ticket-type-card>
                </div>
            </div>
            <div class="col-xl-12 my-3">
                <armon-pagination [paginationResponse]="paginationResponse" (pageChanged)="pageChanged($event)">
                </armon-pagination>
            </div>
        </ng-template>
    </side-navigation>
</div>`;var ie=`.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 oe=`<ng-container *ngIf="visibleComponent">
  <div class="modal-header">
    <span class="text-lg">{{(isEditMode ? 'SOCA.TICKET_TYPE_EDIT' : 'SOCA.TICKET_TYPE_ADD' ) | translate}}</span>
  </div>
  <div class="modal-body">
    <form [formGroup]="form">
      <div class="row">
        <div class="col-12">
          <div class="form-group">
            <label for="requiredUnitsInput">{{'SOCA.TICKET_TYPE_REQUIRED_UNITS' | translate}}</label>
            <input type="text" required class="form-control form-control-lg w-50"
              [ngClass]="{'is-invalid': form.get('requiredUnits').touched && form.get('requiredUnits').invalid}"
              [formControl]="form.get('requiredUnits')" id="requiredUnitsInput">
            <ng-template
              *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('requiredUnits')}">
            </ng-template>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-12">
          <div class="form-group">
            <label for="nameInput">{{'SOCA.TICKET_TYPE_NAME' | translate}}</label>
            <input type="text" id="nameInput"
              [ngClass]="{'is-invalid': form.get('name').touched && form.get('name').invalid}"
              [formControl]="form.get('name')" class="form-control form-control-sm">
            <ng-template
              *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('name')}">
            </ng-template>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-12">
          <div class="form-group">
            <label for="requiredUnitsInput">{{'SOCA.TICKET_TYPE_REGION' | translate}}</label>
            <armon-select-search query="region" [allowMulti]="false"
              [invalid]="form.get('regionId').touched && form.get('regionId').invalid"
              [formControl]="form.get('regionId')">
            </armon-select-search>
            <ng-template
              *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('regionId')}">
            </ng-template>
          </div>
        </div>
      </div>
    </form>
  </div>
  <div class="modal-footer">
    <button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CLOSE' | translate}}</button>
    <button class="btn btn-primary me-0" (click)="onSaveClicked($event)" [disabled]="form.invalid">
      {{'BUTTON.SAVE' | 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.pattern">{{'VALIDATION.TWO_DIGIT_DECIMAL'|translate}}</span>
      <span *ngIf="control.errors.validateMax">{{'VALIDATION.MAX_VALUE'|translate:control.errors.validateMax}}</span>
      <span *ngIf="control.errors.validateMin">{{'VALIDATION.MIN_VALUE'|translate:control.errors.validateMin}}</span>
    </div>
  </ng-container>
</ng-template>`;var ne="";var de=function(r,e,t,o){var n=arguments.length,i=n<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(a=r[s])&&(i=(n<3?a(i):n>3?a(e,t,i):a(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i},f=class extends N{formBuilder;interactionService;socialAreaService;languageService;ticketType;visibleComponent=!1;isEditMode;form;constructor(e,t,o,n){super(),this.formBuilder=e,this.interactionService=t,this.socialAreaService=o,this.languageService=n}onModalInitialized(){super.onModalInitialized(),A(this.ticketType)?(this.ticketType=G.getEmptyModel(),this.isEditMode=!1):(this.ticketType=O(this.ticketType),this.isEditMode=!0),this.visibleComponent=!0,this.createForm()}createForm(){this.form=this.formBuilder.group({name:[this.ticketType.name?this.ticketType.name:null,u.required],regionId:[this.ticketType.regionId?this.ticketType.regionId:null,u.required],requiredUnits:[this.ticketType.requiredUnits?this.ticketType.requiredUnits.toString().replace(".",","):null,[u.required,B.numeric({acceptValue:U.PositiveNumber,allowDecimal:!0}),u.pattern(this.languageService.getSeparator("decimal")==","?/^(\d+(\,\d{0,2})?|\,?\d{1,2})$/:/^(\d+(\.\d{0,2})?|\.?\d{1,2})$/),Z(999.99),ee(.01)]]})}onSaveClicked(e){Object.assign(this.ticketType,this.form.value),this.ticketType.requiredUnits=Number(this.form.value.requiredUnits.replace(",",".")),this.socialAreaService.upsertTicketType(this.ticketType).subscribe({next:t=>{this.interactionService.showMessage("SOCA.TICKET_TYPE_UPSERT_SUCCEED",null,z.Success),this.closeModal(this.ticketType.id)},error:t=>{t&&t.status&&t.status===R.Conflict&&this.interactionService.showDialog(this.isEditMode?"SOCA.TICKET_TYPE_EDIT":"SOCA.TICKET_TYPE_ADD","SOCA.TICKET_INFO_REGION_CONFLICT",null,null,!1,"BUTTON.OK","",!1,()=>{})}})}static ctorParameters=()=>[{type:D},{type:y},{type:d},{type:L}];static propDecorators={ticketType:[{type:g}]}};f=de([c({selector:"armon-soca-ticket-type-upsert",template:oe,standalone:!0,imports:[l,v,M,I,E,T,p],styles:[ne]})],f);var re=`<div class="card mb-3">

  <div class="card-body">
    <div class="ticket-type-container">
      <div class="ticket-type-icon">
        <cds-icon shape="tickets" size="lg"></cds-icon>
      </div>
      <div class="ticket-type-title">
        <span class="name">{{ticketType.name}}</span>
        <span class="units mb-2">{{ticketType.requiredUnits|number}}&nbsp;{{'SOCA.BALANCE_UNIT' | translate}}</span>
        <span class="region">{{ticketType.regionName}}&nbsp;{{'SOCA.REGION_LABEL' | translate}}</span>
      </div>
    </div>
  </div>

  <div class="card-footer" *ngIf="visibleButtons.length > 0">

    <button class="btn btn-sm btn-link" *ngFor="let button of visibleButtons"
      (click)="onFooterButtonClicked($event, button.event)">{{button.text
      | translate}}</button>

    <button nz-dropdown [nzDropdownMenu]="menuSub" class="btn btn-link btn-sm me-2" *ngIf="hiddenButtons.length > 0"
      [nzClickHide]="true">
      <cds-icon shape="ellipsis-horizontal"></cds-icon>
    </button>
    <nz-dropdown-menu #menuSub="nzDropdownMenu">
      <ul nz-menu>
        <li nz-menu-item *ngFor="let button of hiddenButtons" (click)="onFooterButtonClicked($event, button.event)">
          {{button.text | translate}}</li>
      </ul>
    </nz-dropdown-menu>

  </div>

</div>`;var ae=`.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}:host .ticket-type-container{display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:horizontal;-moz-box-orient:horizontal;-webkit-flex-direction:row;-moz-flex-direction:row;-ms-flex-direction:row;flex-direction:row}:host .ticket-type-container .ticket-type-icon{margin:6px 12px 6px 0;width:42px;min-width:42px;height:42px;min-height:42px;display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-direction:column;-moz-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-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;-webkit-box-align:center;-ms-flex-align:center;-webkit-align-items:center;-moz-align-items:center;align-items:center;-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem;color:#fff;background-color:#472650}:host .ticket-type-container .ticket-type-title{display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-direction:column;-moz-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-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}:host .ticket-type-container .ticket-type-title .name{font-size:.756rem}:host .ticket-type-container .ticket-type-title .units{font-size:.924rem;font-weight:lighter}:host .ticket-type-container .ticket-type-title .region{font-size:.588rem}
`;var ge=function(r,e,t,o){var n=arguments.length,i=n<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(a=r[s])&&(i=(n<3?a(i):n>3?a(e,t,i):a(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i},x=class extends J{interactionService;socialAreaService;modalService;routingService;authService;ticketType;ticketTypeDeleted=new S;constructor(e,t,o,n,i){super(i),this.interactionService=e,this.socialAreaService=t,this.modalService=o,this.routingService=n,this.authService=i}ngOnInit(){this.initializeButtons()}initializeButtons(){this.addButton("PAGES.SOCA_REPORT_USAGES",this.onReportButtonClicked,m.SOCIALAREA.getWrite()),this.addButton("BUTTON.EDIT",this.onEditButtonClicked,m.SOCIALAREA.getWrite()),this.addButton("BUTTON.DELETE",this.onDeleteButtonClicked,m.SOCIALAREA.getWrite())}onEditButtonClicked(){this.modalService.open(f,{settings:{size:"md"},props:{ticketType:this.ticketType}}).result.then(e=>{this.socialAreaService.getTicketTypeDetail(e).subscribe(t=>{this.ticketType=t})}).catch(e=>{})}onDeleteButtonClicked(){this.interactionService.showDialog(this.ticketType.name,"SOCA.TICKET_TYPE_APPROVE_FOR_DELETE",null,null,!0,"BUTTON.DELETE","",!0,()=>{this.socialAreaService.deleteTicketType(this.ticketType.id).subscribe(()=>{this.ticketTypeDeleted.emit(this.ticketType.id)})})}onReportButtonClicked(){this.routingService.gotoSocaTicketUsageReport(this.ticketType.id)}static ctorParameters=()=>[{type:y},{type:d},{type:h},{type:$},{type:b}];static propDecorators={ticketType:[{type:g}],ticketTypeDeleted:[{type:C}]}};x=ge([c({selector:"armon-soca-ticket-type-card",template:re,standalone:!0,imports:[l,k,q,j,P,_,p],styles:[ae]})],x);var ke=function(r,e,t,o){var n=arguments.length,i=n<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(a=r[s])&&(i=(n<3?a(i):n>3?a(e,t,i):a(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i},se=class{route;authService;socialAreaService;modalService;filter;ticketTypes=[];paginationResponse=new F;paginationRequest=new V;permissionAddTicketType;constructor(e,t,o,n){this.route=e,this.authService=t,this.socialAreaService=o,this.modalService=n,this.permissionAddTicketType=this.authService.checkPermission(m.SOCIALAREA.getWrite())}ngOnInit(){this.filter=K.getEmptyModel(),this.getList()}ngOnDestroy(){}getList(){this.socialAreaService.getTicketTypes(this.filter).subscribe(e=>{this.ticketTypes=e.items,this.paginationResponse=e.pagination})}refreshList(e=!0){e&&(this.filter.pagination.skip=0),this.getList()}onRegionChanged(e){this.refreshList()}onTicketTypeDeleted(e){this.refreshList()}onAddTicketTypeClicked(e){this.modalService.open(f,{settings:{size:"md"}}).result.then(t=>{this.refreshList()}).catch(t=>{})}pageChanged(e){this.filter.pagination.skip=e.skip,this.filter.pagination.take=e.take,this.refreshList(!1)}static ctorParameters=()=>[{type:w},{type:b},{type:d},{type:h}]};se=ke([c({selector:"armon-soca-ticket-type-management",template:te,animations:W,standalone:!0,imports:[X,H,T,v,Q,l,k,x,Y,p],styles:[ie]})],se);export{se as SocaTicketTypeManagementComponent};
