import{a as k,b as T}from"./chunk-MXSLISEG.js";import{a as N}from"./chunk-7GYHTWED.js";import{Rb as y,wb as M}from"./chunk-YSQLW2JA.js";import{O as v,P as u,S as x,Sa as E,xa as O}from"./chunk-NVJ2ZZFT.js";import{Aa as r,Mc as _,Nc as b,Qf as I,Rd as g,Sd as p,Te as h,Zf as R,af as A,bb as d,dd as m,ea as S,mg as f,ya as a}from"./chunk-SKPDQO4E.js";var D=`<div class="modal-header">
	<div class="d-flex flex-column">
		<span class="text-lg">{{accessControlPointDetailed.name}}</span>
	</div>
</div>

<div class="modal-body">
	<div class="row">
		<div class="col-12 mb-3">
			<span>{{'IDENTITY.ACP_DAFAULT_PERMISSIONS_UPDATE_INFO'|translate:accessControlPointDetailed}}</span>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<armon-identity-access-right #identityAccessRight *ngIf="accessRight" [accessRight]="accessRight"
				[editMode]="true" [visibleFooter]="false"></armon-identity-access-right>
		</div>
	</div>
	<div class="row my-3">
		<div class="col-12">
			<div class="form-group">
				<label class="text-sm fw-medium mb-2">{{'ACCESSCONTROLPOINT.APPLY_USERS_METHOD' |
					translate:languageService.userTranslate}}</label>
				<div class="form-check">
					<input class="form-check-input" id="expand-current" type="radio" name="expand-current"
						[(ngModel)]="selectedScope" [value]="1">
					<label class="form-check-label" for="expand-current">
						{{'ACCESSCONTROLPOINT.APPLY_USERS_METHOD_EXPAND_CURRENT'|translate}}
					</label>
				</div>
				<div class="form-check">
					<input class="form-check-input" id="ignore-current" type="radio" name="ignore-current"
						[(ngModel)]="selectedScope" [value]="2">
					<label class="form-check-label" for="ignore-current">
						{{'ACCESSCONTROLPOINT.APPLY_USERS_METHOD_IGNORE_CURRENT'|translate}}
					</label>
				</div>
				<div class="form-check">
					<input class="form-check-input" id="override-current" type="radio" name="override-current"
						[(ngModel)]="selectedScope" [value]="3">
					<label class="form-check-label" for="override-current">
						{{'ACCESSCONTROLPOINT.APPLY_USERS_METHOD_OVERRIDE_CURRENT'|translate}}
					</label>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="modal-footer">
	<button type="button" class="btn btn-primary" [disabled]="!accessRight.isValid"
		(click)="onSaveClicked($event)">{{'BUTTON.SAVE' | translate}}</button>
</div>`;var U=`.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 V=function(c,e,t,i){var o=arguments.length,s=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(n=c[l])&&(s=(o<3?n(s):o>3?n(e,t,s):n(e,t))||s);return o>3&&s&&Object.defineProperty(e,t,s),s},C=class extends p{languageService;accessControlPointDetailed;accessRight;selectedScope=R.InsertNewExpandCurrent;constructor(e){super(),this.languageService=e}onModalInitialized(){super.onModalInitialized();let e=E.getEmptyModel();e.access=this.accessControlPointDetailed.defaultPrivileges.access,e.remoteAccess=this.accessControlPointDetailed.defaultPrivileges.remoteAccess,e.read=this.accessControlPointDetailed.defaultPrivileges.read,e.config=this.accessControlPointDetailed.defaultPrivileges.config,e.grant=this.accessControlPointDetailed.defaultPrivileges.grant,e.snapshot=this.accessControlPointDetailed.defaultPrivileges.snapshot,e.accessControlPointRemoteAvailable=this.accessControlPointDetailed.remoteAvailable,e.accessControlPointId=this.accessControlPointDetailed.id,e.accessControlPointName=this.accessControlPointDetailed.name,e.userRights=this.accessControlPointDetailed.userRights,this.accessRight=e}onSaveClicked(e){let t=x.getDummyModel();t.access=this.accessRight.access,t.remoteAccess=this.accessRight.remoteAccess,t.read=this.accessRight.read,t.config=this.accessRight.config,t.grant=this.accessRight.grant,t.snapshot=this.accessRight.snapshot,this.closeModal({accessRights:t,scope:this.selectedScope})}static ctorParameters=()=>[{type:A}];static propDecorators={accessControlPointDetailed:[{type:r}]}};C=V([a({selector:"armon-access-control-point-permissions-modal",template:D,standalone:!0,imports:[d,N,h,f,m],styles:[U]})],C);var L=`<div class="modal-header">
	<div class="d-flex flex-column">
		<span class="text-lg">{{'REGION.TITLE_ACCESS_CONTROL_POINTS'|translate}}</span>
	</div>
</div>

<div class="modal-body">
	<div class="row mb-4" *ngIf="direction">
		<div class="col-12">
			<span class="text-sm text-italic">
				{{data.direction|translate}}
			</span>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<armon-select-search query="point" [allowMulti]="false" [(ngModel)]="selectedAccessControlPointId"
				[searchFilters]="searchFilters" searchTake="100" [disabledValues]="disabledValues">
			</armon-select-search>
		</div>
	</div>
</div>
<div class="modal-footer">
	<button type="button" class="btn btn-outline-primary me-2" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' |
		translate}}</button>
	<button type="button" class="btn btn-primary" [disabled]="!selectedAccessControlPointId"
		(click)="onSaveClicked($event)">{{'BUTTON.OK' |
		translate}}</button>
</div>`;var w=`.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 H=function(c,e,t,i){var o=arguments.length,s=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(n=c[l])&&(s=(o<3?n(s):o>3?n(e,t,s):n(e,t))||s);return o>3&&s&&Object.defineProperty(e,t,s),s},P=class extends p{direction;searchFilters;selectedAccessControlPointId;disabledValues=[u];constructor(){super()}onSaveClicked(e){this.closeModal(this.selectedAccessControlPointId)}static ctorParameters=()=>[];static propDecorators={direction:[{type:r}],searchFilters:[{type:r}]}};P=H([a({selector:"armon-access-control-point-selection-modal",template:L,standalone:!0,imports:[d,M,h,f,m],styles:[w]})],P);var W=function(c,e,t,i){var o=arguments.length,s=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(n=c[l])&&(s=(o<3?n(s):o>3?n(e,t,s):n(e,t))||s);return o>3&&s&&Object.defineProperty(e,t,s),s},j=class{identitySelectionService;accessControlPointService;interactionService;modalService;accessControlPointDetailed=null;lastWorkplanId=null;constructor(e,t,i,o){this.identitySelectionService=e,this.accessControlPointService=t,this.interactionService=i,this.modalService=o}showUserSelection(e,t=null,i=!1){this.accessControlPointService.getDetailsofAccessControlPoint(e).subscribe(o=>{this.accessControlPointDetailed=o,this.showUserSelectionModal(t,i)})}checkUserSelectionVirtualMobileCheckin(e,t=!1){let i=new O;i.take=10,i.skip=0,i.accessControlPointType=v.VirtualMobileCheckin,this.accessControlPointService.searchAccessControlPoints(i).subscribe(o=>{o.items&&o.items.length==1?t==!1&&setTimeout(()=>{this.interactionService.showDialog("PACS.WORKPLAN_MOBILE_CHECK_IN","PACS.WORKPLAN_MOBILE_CHECK_ACP_ONLY_BUILTIN",null,null,!1,"BUTTON.OK","",!1,()=>{})},600):o.items&&o.items.length==2?this.confirmUserSelectionVirtualMobileCheckin(e,t,o.items[0].id==u?o.items[1].id:o.items[0].id):o.items&&o.items.length>2?this.confirmUserSelectionVirtualMobileCheckin(e,t):this.interactionService.showMessage("PACS.WORKPLAN_MOBILE_CHECK_NO_ACP","PACS.WORKPLAN_MOBILE_CHECK_IN",b.Error)})}confirmUserSelectionVirtualMobileCheckin(e,t=!1,i){t?this.interactionService.showDialog("PACS.WORKPLAN_MOBILE_CHECK_IN","PACS.WORKPLAN_MOBILE_CHECK_ACP_USERS_ASK",null,null,!0,"BUTTON.USERS","",!1,()=>{this.getVirtualMobileCheckInPoint(e,i)}):this.getVirtualMobileCheckInPoint(e,i)}_virtualMobileCheckInPointId;_multiVirtualMobileCheckInPoint=!1;getVirtualMobileCheckInPoint(e,t){t?(this._virtualMobileCheckInPointId=t,this.showUserSelection(this._virtualMobileCheckInPointId,e,!0),this._multiVirtualMobileCheckInPoint=!1):setTimeout(()=>{this.modalService.open(P,{settings:{size:"md",centered:!0},props:{direction:"PACS.WORKPLAN_MOBILE_CHECK_MULTI_ACP",searchFilters:{accessControlPointType:v.VirtualMobileCheckin}}}).result.then(i=>{this._virtualMobileCheckInPointId=i,this.showUserSelection(this._virtualMobileCheckInPointId,e,!0)}).catch(i=>{}),this._multiVirtualMobileCheckInPoint=!0},600)}showUserSelectionModal(e=null,t=!1){this.lastWorkplanId=e;let i={editable:!0,sessionFunction:this.getSessionIdForAccessControlPoint.bind(this),useCustomApply:!0,ignoreListUpdate:!0};t&&(i.directionTitle=this.accessControlPointDetailed.name,i.directionContent="PACS.WORKPLAN_MOBILE_CHECK_ACP_USERS_DIRECTION"),e&&(i.workplanIds=[e]),this.modalService.open(T,{settings:{size:"xl"},props:i}).result.then(o=>{o&&this.modalService.open(C,{settings:{size:"lg"},props:{accessControlPointDetailed:this.accessControlPointDetailed}}).result.then(s=>{this.applyUserSelection(o.sessionId,s.accessRights,s.scope,e,t)}).catch(s=>{})}).catch(o=>{})}getSessionIdForAccessControlPoint(e){return this.accessControlPointService.getSessionForAccessControlPoint(this.accessControlPointDetailed.id,e)}applyUserSelection(e,t,i,o=null,s=!1){this.identitySelectionService.applySessionDataWithAcpPrivileges(e,t,i).subscribe(()=>{s&&this._multiVirtualMobileCheckInPoint&&o&&this.interactionService.showDialog("PACS.WORKPLAN_MOBILE_CHECK_ACP_USERS","PACS.WORKPLAN_MOBILE_CHECK_MULTI_ACP_INFO",null,null,!1,"BUTTON.OK",null,!1)},n=>{n&&n.status&&n.status===_.AccessControlPointInvalidRightsApply&&this.interactionService.showDialog("AUTHENTICATION.MISSING_PERMISSION",n.error.message,null,null,!0,"BUTTON.EDIT","BUTTON.CANCEL",!1,()=>{this.showUserSelection(this.accessControlPointDetailed.id,this.lastWorkplanId)},()=>{})})}static ctorParameters=()=>[{type:k},{type:y},{type:I},{type:g}]};j=W([S({providedIn:"root"})],j);export{j as a};
