@digital-realty/ui-service-management 12.0.13 → 12.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{__decorate as E}from"tslib";import{css as bt,html as g,LitElement as Rt,nothing as N,svg as Ot}from"lit";import{property as we,customElement as X,state as Mi}from"lit/decorators.js";import G from"moment";import{baseTheme as on}from"@digital-realty/theme";import he from"moment-timezone";import"date-fns/format.js";import{makeAutoObservable as se}from"mobx";import{makePersistable as Je}from"mobx-persist-store";import{authedUser as rt}from"@digital-realty/ix-account-switcher";import{Router as ct}from"@vaadin/router";import{User as rn,UserManager as cn}from"oidc-client-ts";import{MobxLitElement as Ae}from"@adobe/lit-mobx";import{ifDefined as dn}from"lit/directives/if-defined.js";import"@digital-realty/ix-select/ix-select.js";import"@digital-realty/ix-select/ix-select-option.js";import"@digital-realty/ix-icon-button/ix-icon-button.js";import{until as fe}from"lit-html/directives/until.js";import{isPossiblePhoneNumber as un}from"libphonenumber-js";var vi;(function(e){e.CustomerSupport="customer-support",e.FacilityAccess="facility-access",e.RemoteHands="remote-hands",e.DeliveriesAndRemovals="deliveries-removals",e.TroubleTicket="trouble-ticket"})(vi||(vi={}));var y;(function(e){e.CustomerSupport="customer-support",e.FacilityAccess="facility-access",e.VisitorAccess="visitor-access",e.PermanentBadge="permanent-badge",e.OSPAccess="osp-access",e.POPPOEAccess="pop-poe-access",e.RemoteHands="remote-hands",e.Deliveries="deliveries",e.Removals="removals",e.DeliveriesAndRemovals="deliveries-removals",e.TroubleTickets="trouble-tickets"})(y||(y={}));const ln="ticketViewType";var gi;(function(e){e.PlannedWork="Planned Work",e.UrgentWork="Urgent Work"})(gi||(gi={}));var H;(function(e){e.TelxSFDC="TelxSFDC",e.Insite="InSite",e.ServiceNow="ServiceNow"})(H||(H={}));const dt="YYYY-MM-DD",mn="HH:mm:ss",$t="HH:mm",pn="YYYY-MM-DD HH:mm";var w;(function(e){e.Default="default",e.Submitting="submitting",e.Submitted="submitted",e.Error="error"})(w||(w={}));var Q;(function(e){e.Deliveries="deliveries-tickets",e.FacilityAccess="osp-access-tickets",e.TroubleTickets="trouble-tickets",e.RemoteHands="remote-hands-tickets"})(Q||(Q={}));const Ji=[{label:"CSV",extensions:["csv"]},{label:"DOC/X",extensions:["doc","docx"]},{label:"GIF",extensions:["gif"]},{label:"JPG (JPEG)",extensions:["jpg","jpeg"]},{label:"PDF",extensions:["pdf"]},{label:"PNG",extensions:["png"]},{label:"XLS/X",extensions:["xls","xlsx"]}],hn=[{label:"JPG (JPEG)",extensions:["image/jpg","image/jpeg"]},{label:"PDF",extensions:["application/pdf"]},{label:"PNG",extensions:["image/png"]},{label:"GIF",extensions:["image/gif"]}],vn=Ji.flatMap(e=>e.extensions),gn=hn.flatMap(e=>e.extensions),wn=e=>{var t;return Number((t=e.split("cursor=").pop())===null||t===void 0?void 0:t.split("&")[0])},Wi=async(e,t)=>{const i=await t({...e,cursor:"1"});if(!i)return[];const s=[...i.items];if(i.last&&i.self!==i.last){const a=[];let o=1;o=wn(i.last);for(let n=2;n<=o;n+=1)a.push(t({...e,cursor:n.toString()}));await Promise.all(a).then(n=>{n.forEach(r=>{r&&s.push(...r.items)})})}return s},fn=e=>{var t,i;return e?"name"in e?((t=e.name)===null||t===void 0?void 0:t.trim())||e.id||"":((i=e.comment)===null||i===void 0?void 0:i.trim())||e.id||"":""},kn="https://api.digitalrealty.com/service-management/v1".replace(/\/+$/,"");class Gi{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:kn}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Zi}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const yn=new Gi;class ai{constructor(t=yn){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new An(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ai.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new Rn(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;bn(r.body)||r.body instanceof URLSearchParams||Tn(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ai.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Tn(e){return typeof Blob<"u"&&e instanceof Blob}function bn(e){return typeof FormData<"u"&&e instanceof FormData}class Rn extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class An extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class ae extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function S(e,t){return e[t]!=null}function Zi(e,t=""){return Object.keys(e).map(i=>Ki(i,e[i],t)).filter(i=>i.length>0).join("&")}function Ki(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return Ki(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Zi(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ce{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class _n{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}const In="https://api.digitalrealty.com".replace(/\/+$/,"");class Et{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:In}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Xi}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Sn=new Et;class kt{constructor(t=Sn){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new Nn(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?kt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new Yi(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;Pn(r.body)||r.body instanceof URLSearchParams||Cn(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}kt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Cn(e){return typeof Blob<"u"&&e instanceof Blob}function Pn(e){return typeof FormData<"u"&&e instanceof FormData}class Yi extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Nn extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class $ extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function h(e,t){return e[t]!=null}function Xi(e,t=""){return Object.keys(e).map(i=>Qi(i,e[i],t)).filter(i=>i.length>0).join("&")}function Qi(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return Qi(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Xi(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class j{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class es{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}class qn extends kt{async getCourierBySiteRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getCourierBySite.");if(t.site===null||t.site===void 0)throw new $("site","Required parameter requestParameters.site was null or undefined when calling getCourierBySite.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/deliveries-removals/courier-companies",method:"GET",headers:a,query:s},i);return new j(o)}async getCourierBySite(t,i){return await(await this.getCourierBySiteRaw(t,i)).value()}}function ts(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function is(e){return Dn(e)}function Dn(e,t){return e==null?e:{message:h(e,"message")?e.message:void 0}}function wi(e){return Bn(e)}function Bn(e,t){return e==null?e:{createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,comment:h(e,"comment")?e.comment:void 0}}function ss(e){return On(e)}function On(e,t){return e==null?e:{comments:h(e,"comments")?e.comments.map(wi):void 0}}function $n(e){return En(e)}function En(e,t){return e==null?e:{deliveryBlocked:h(e,"delivery_blocked")?e.delivery_blocked:void 0}}function as(e){return xn(e)}function xn(e,t){return e==null?e:{accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,id:h(e,"id")?e.id:void 0,status:h(e,"status")?e.status:void 0,site:h(e,"site")?e.site:void 0,subject:h(e,"subject")?e.subject:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0}}function Fn(e){return Ln(e)}function Ln(e,t){return e==null?e:{deliveryTickets:h(e,"delivery_tickets")?e.delivery_tickets.map(as):void 0,totalCount:h(e,"total_count")?e.total_count:void 0,pageNumber:h(e,"page_number")?e.page_number:void 0,pageSize:h(e,"page_size")?e.page_size:void 0}}function Vn(e){if(e!==void 0)return e===null?null:{tracking_number:e.trackingNumber,size_when_oversized:e.sizeWhenOversized,weight_when_overweight:e.weightWhenOverweight,courier_company:e.courierCompany}}function Un(e){if(e!==void 0)return e===null?null:{id:e.id,tracking_number:e.trackingNumber,number_of_packages:e.numberOfPackages,size_when_oversized:e.sizeWhenOversized,weight_when_overweight:e.weightWhenOverweight,courier_company:e.courierCompany}}function Hn(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,description:e.description,eta_from:e.etaFrom===null?null:e.etaFrom.toISOString().substring(0,10),eta_to:e.etaTo===null?null:e.etaTo.toISOString(),loading_bay_required:e.loadingBayRequired,remote_hands_required:e.remoteHandsRequired,customer_reference:e.customerReference,site:e.site,other_notification_recipients:e.otherNotificationRecipients,packages:e.packages===void 0?void 0:e.packages.map(Un)}}function zn(e){return jn(e)}function jn(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,trackingNumber:h(e,"tracking_number")?e.tracking_number:void 0,numberOfPackages:h(e,"number_of_packages")?e.number_of_packages:void 0,sizeWhenOversized:h(e,"size_when_oversized")?e.size_when_oversized:void 0,weightWhenOverweight:h(e,"weight_when_overweight")?e.weight_when_overweight:void 0,courierCompany:h(e,"courier_company")?e.courier_company:void 0}}function xt(e){return Mn(e)}function Mn(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,status:h(e,"status")?e.status:void 0,subject:h(e,"subject")?e.subject:void 0,description:h(e,"description")?e.description:void 0,cancellationReason:h(e,"cancellation_reason")?e.cancellation_reason:void 0,etaFrom:h(e,"eta_from")?e.eta_from===null?null:new Date(e.eta_from):void 0,etaTo:h(e,"eta_to")?e.eta_to===null?null:new Date(e.eta_to):void 0,customerReference:h(e,"customer_reference")?e.customer_reference:void 0,site:h(e,"site")?e.site:void 0,otherNotificationRecipients:h(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0,loadingBayRequired:h(e,"loading_bay_required")?e.loading_bay_required:void 0,remoteHandsRequired:h(e,"remote_hands_required")?e.remote_hands_required:void 0,packages:h(e,"packages")?e.packages.map(zn):void 0,comments:h(e,"comments")?e.comments.map(wi):void 0}}function Jn(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,eta_from:e.etaFrom===void 0?void 0:e.etaFrom===null?null:e.etaFrom.toISOString(),eta_to:e.etaTo===void 0?void 0:e.etaTo===null?null:e.etaTo.toISOString(),loading_bay_required:e.loadingBayRequired,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Wn(e){return Gn(e)}function Gn(e,t){return e==null?e:{removalTickets:h(e,"removal_tickets")?e.removal_tickets.map(as):void 0,totalCount:h(e,"total_count")?e.total_count:void 0,pageNumber:h(e,"page_number")?e.page_number:void 0,pageSize:h(e,"page_size")?e.page_size:void 0}}function Zn(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,description:e.description,customer_reference:e.customerReference,removal_party:e.removalParty,courier_company:e.courierCompany,tracking_number:e.trackingNumber,pickup_date:e.pickupDate.toISOString(),site:e.site,other_notification_recipients:e.otherNotificationRecipients}}function fi(e){return Kn(e)}function Kn(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,status:h(e,"status")?e.status:void 0,cancellationReason:h(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:h(e,"subject")?e.subject:void 0,description:h(e,"description")?e.description:void 0,customerReference:h(e,"customer_reference")?e.customer_reference:void 0,removalParty:h(e,"removal_party")?e.removal_party:void 0,courierCompany:h(e,"courier_company")?e.courier_company:void 0,trackingNumber:h(e,"tracking_number")?e.tracking_number:void 0,pickupDate:h(e,"pickup_date")?e.pickup_date:void 0,site:h(e,"site")?e.site:void 0,otherNotificationRecipients:h(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0,comments:h(e,"comments")?e.comments.map(wi):void 0}}function Yn(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,customer_reference:e.customerReference,courier_company:e.courierCompany,tracking_number:e.trackingNumber,pickup_date:e.pickupDate===void 0?void 0:e.pickupDate===null?null:e.pickupDate.toISOString(),other_notification_recipients:e.otherNotificationRecipients}}function ki(e){return Xn(e)}function Xn(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,fileName:h(e,"file_name")?e.file_name:void 0,fileSize:h(e,"file_size")?e.file_size:void 0,contentType:h(e,"content_type")?e.content_type:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0}}function ns(e){return Qn(e)}function Qn(e,t){return e==null?e:{attachments:h(e,"attachments")?e.attachments.map(ki):void 0}}function os(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class eo extends kt{async cancellationDeliveryRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationDeliveryRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new $("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationDeliveryRequest.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:a,query:s,body:ts(t.cancellationTicketsRequest)},i);return new j(o,n=>is(n))}async cancellationDeliveryRequest(t,i){return await(await this.cancellationDeliveryRequestRaw(t,i)).value()}async createAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createAttachment.");if(t.fileName===null||t.fileName===void 0)throw new $("fileName","Required parameter requestParameters.fileName was null or undefined when calling createAttachment.");if(t.body===null||t.body===void 0)throw new $("body","Required parameter requestParameters.body was null or undefined when calling createAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const a={};if(a["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:t.body},i);return new j(o,n=>ki(n))}async createAttachment(t,i){return await(await this.createAttachmentRaw(t,i)).value()}async createDeliveriesCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createDeliveriesComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new $("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createDeliveriesComment.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:os(t.ticketCommentsRequest)},i);return new j(o,n=>ss(n))}async createDeliveriesComment(t,i){return await(await this.createDeliveriesCommentRaw(t,i)).value()}async createDeliveryRaw(t,i){if(t.deliveryTicketsRequest===null||t.deliveryTicketsRequest===void 0)throw new $("deliveryTicketsRequest","Required parameter requestParameters.deliveryTicketsRequest was null or undefined when calling createDelivery.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets",method:"POST",headers:a,query:s,body:Hn(t.deliveryTicketsRequest)},i);return new j(o,n=>xt(n))}async createDelivery(t,i){return await(await this.createDeliveryRaw(t,i)).value()}async getDeliveriesRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getDeliveries.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets",method:"GET",headers:a,query:s},i);return new j(o,n=>Fn(n))}async getDeliveries(t,i){return await(await this.getDeliveriesRaw(t,i)).value()}async getDeliveryAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new $("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getDeliveryAttachmentsById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new es(o)}async getDeliveryAttachmentsById(t,i){return await(await this.getDeliveryAttachmentsByIdRaw(t,i)).value()}async getDeliveryAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryAttachmentsList.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new j(o,n=>ns(n))}async getDeliveryAttachmentsList(t,i){return await(await this.getDeliveryAttachmentsListRaw(t,i)).value()}async getDeliveryByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new j(o,n=>xt(n))}async getDeliveryById(t,i){return await(await this.getDeliveryByIdRaw(t,i)).value()}async getDeliveryDiscoveryRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getDeliveryDiscovery.");if(t.site===null||t.site===void 0)throw new $("site","Required parameter requestParameters.site was null or undefined when calling getDeliveryDiscovery.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-discovery",method:"GET",headers:a,query:s},i);return new j(o,n=>$n(n))}async getDeliveryDiscovery(t,i){return await(await this.getDeliveryDiscoveryRaw(t,i)).value()}async updateDeliveriesTicketsRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateDeliveriesTickets.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:Jn(t.deliveryTicketsUpdateRequest)},i);return new j(o,n=>xt(n))}async updateDeliveriesTickets(t,i){return await(await this.updateDeliveriesTicketsRaw(t,i)).value()}async updateDeliveriesTicketsPackagesRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateDeliveriesTicketsPackages.");if(t.packageId===null||t.packageId===void 0)throw new $("packageId","Required parameter requestParameters.packageId was null or undefined when calling updateDeliveriesTicketsPackages.");if(t.deliveryTicketUpdatePackagesRequest===null||t.deliveryTicketUpdatePackagesRequest===void 0)throw new $("deliveryTicketUpdatePackagesRequest","Required parameter requestParameters.deliveryTicketUpdatePackagesRequest was null or undefined when calling updateDeliveriesTicketsPackages.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/packages/{package_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{package_id}",encodeURIComponent(String(t.packageId))),method:"PATCH",headers:a,query:s,body:Vn(t.deliveryTicketUpdatePackagesRequest)},i);return new j(o,n=>xt(n))}async updateDeliveriesTicketsPackages(t,i){return await(await this.updateDeliveriesTicketsPackagesRaw(t,i)).value()}}class to extends kt{async cancellationRemovalRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationRemovalRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new $("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationRemovalRequest.");const s={},a={};a["Content-Type"]="application/json";const o=await this.request({path:"/removals-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:a,query:s,body:ts(t.cancellationTicketsRequest)},i);return new j(o,n=>is(n))}async cancellationRemovalRequest(t,i){return await(await this.cancellationRemovalRequestRaw(t,i)).value()}async createCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new $("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createComment.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:os(t.ticketCommentsRequest)},i);return new j(o,n=>ss(n))}async createComment(t,i){return await(await this.createCommentRaw(t,i)).value()}async createRemovalRaw(t,i){if(t.removalTicketsRequest===null||t.removalTicketsRequest===void 0)throw new $("removalTicketsRequest","Required parameter requestParameters.removalTicketsRequest was null or undefined when calling createRemoval.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets",method:"POST",headers:a,query:s,body:Zn(t.removalTicketsRequest)},i);return new j(o,n=>fi(n))}async createRemoval(t,i){return await(await this.createRemovalRaw(t,i)).value()}async createRemovalsAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemovalsAttachment.");if(t.fileName===null||t.fileName===void 0)throw new $("fileName","Required parameter requestParameters.fileName was null or undefined when calling createRemovalsAttachment.");if(t.body===null||t.body===void 0)throw new $("body","Required parameter requestParameters.body was null or undefined when calling createRemovalsAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const a={};if(a["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:t.body},i);return new j(o,n=>ki(n))}async createRemovalsAttachment(t,i){return await(await this.createRemovalsAttachmentRaw(t,i)).value()}async getRemovalByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new j(o,n=>fi(n))}async getRemovalById(t,i){return await(await this.getRemovalByIdRaw(t,i)).value()}async getRemovalPartiesRaw(t){const i={},s={};if(this.configuration&&this.configuration.accessToken){const o=this.configuration.accessToken,n=await o("BearerAuth",[]);n&&(s.Authorization=`Bearer ${n}`)}const a=await this.request({path:"/removal-parties",method:"GET",headers:s,query:i},t);return new j(a)}async getRemovalParties(t){return await(await this.getRemovalPartiesRaw(t)).value()}async getRemovalsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets",method:"GET",headers:a,query:s},i);return new j(o,n=>Wn(n))}async getRemovals(t={},i){return await(await this.getRemovalsRaw(t,i)).value()}async getRemovalsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new $("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getRemovalsAttachmentsById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new es(o)}async getRemovalsAttachmentsById(t,i){return await(await this.getRemovalsAttachmentsByIdRaw(t,i)).value()}async getRemovalsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalsAttachmentsList.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new j(o,n=>ns(n))}async getRemovalsAttachmentsList(t,i){return await(await this.getRemovalsAttachmentsListRaw(t,i)).value()}async updateRemovalByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateRemovalById.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:Yn(t.removalsTicketsUpdateRequest)},i);return new j(o,n=>fi(n))}async updateRemovalById(t,i){return await(await this.updateRemovalByIdRaw(t,i)).value()}}const io="https://api.digitalrealty.com/service-management/v1/facility-access".replace(/\/+$/,"");class ht{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:io}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||rs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const so=new ht;class Qe{constructor(t=so){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new ro(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?Qe.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new oo(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;no(r.body)||r.body instanceof URLSearchParams||ao(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}Qe.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function ao(e){return typeof Blob<"u"&&e instanceof Blob}function no(e){return typeof FormData<"u"&&e instanceof FormData}class oo extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class ro extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class v extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function c(e,t){return e[t]!=null}function rs(e,t=""){return Object.keys(e).map(i=>cs(i,e[i],t)).filter(i=>i.length>0).join("&")}function cs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return cs(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?rs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class q{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Ft{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function co(e){return uo(e)}function uo(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,accountNumber:c(e,"account_number")?e.account_number:void 0,firstName:c(e,"first_name")?e.first_name:void 0,lastName:c(e,"last_name")?e.last_name:void 0,email:c(e,"email")?e.email:void 0,phone:c(e,"phone")?e.phone:void 0,representingCompany:c(e,"representing_company")?e.representing_company:void 0,badgeStartDate:c(e,"badge_start_date")?new Date(e.badge_start_date):void 0,activeBadge:c(e,"active_badge")?e.active_badge:void 0,terminationRequested:c(e,"termination_requested")?e.termination_requested:void 0}}function lo(e){return mo(e)}function mo(e,t){return e==null?e:{items:c(e,"items")?e.items.map(co):void 0,totalCount:c(e,"total_count")?e.total_count:void 0}}function Lt(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function Vt(e){return po(e)}function po(e,t){return e==null?e:{message:c(e,"message")?e.message:void 0}}function At(e){return ho(e)}function ho(e,t){return e==null?e:{createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,comment:c(e,"comment")?e.comment:void 0}}function Ut(e){return vo(e)}function vo(e,t){return e==null?e:{comments:c(e,"comments")?e.comments.map(At):void 0}}const ds={Approved:"Approved",Denied:"Denied"};function Ht(e){if(e!==void 0)return e===null?null:{id:e.id,approval_status:e.approvalStatus}}function go(e){return wo(e)}function wo(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0}}function zt(e){return fo(e)}function fo(e,t){return e==null?e:{items:c(e,"items")?e.items.map(go):void 0}}function ko(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime===void 0?void 0:e.startDateTime.toISOString(),end_date_time:e.endDateTime===void 0?void 0:e.endDateTime.toISOString()}}function yo(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,company:e.company,phone:e.phone,visitor_type:e.visitorType}}function To(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors.map(yo),locations:e.locations.map(ko),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,work_description:e.workDescription,notification_recipients:e.notificationRecipients}}function bo(e){return Ro(e)}function Ro(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?e.start_date_time:void 0,endDateTime:c(e,"end_date_time")?e.end_date_time:void 0}}function us(e){return Ao(e)}function Ao(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorCompany:c(e,"visitor_company")?e.visitor_company:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitorType:c(e,"visitor_type")?e.visitor_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(bo):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,customerExternalReference:c(e,"customer_external_reference")?e.customer_external_reference:void 0,serviceImpactedDescription:c(e,"service_impacted_description")?e.service_impacted_description:void 0,workDescription:c(e,"work_description")?e.work_description:void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at:void 0,updatedAt:c(e,"updated_at")?e.updated_at:void 0,closedAt:c(e,"closed_at")?e.closed_at:void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function _o(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime===void 0?void 0:e.startDateTime.toISOString(),end_date_time:e.endDateTime===void 0?void 0:e.endDateTime.toISOString()}}function Io(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,visitor_company:e.visitorCompany,escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,locations:e.locations===void 0?void 0:e.locations.map(_o),visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,work_description:e.workDescription,other_notification_recipients:e.otherNotificationRecipients}}function So(e){return Co(e)}function Co(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?new Date(e.start_date_time):void 0,endDateTime:c(e,"end_date_time")?new Date(e.end_date_time):void 0}}function Po(e){return No(e)}function No(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(So):void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function qo(e){return Do(e)}function Do(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Po):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function Bo(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime.toISOString(),end_date_time:e.endDateTime.toISOString()}}function Oo(e){if(e!==void 0)return e===null?null:{ppop_space_from:e.ppopSpaceFrom,ppop_space_to:e.ppopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function ls(e){return $o(e)}function $o(e,t){return e==null?e:{rack:c(e,"rack")?e.rack:void 0,cabinet:c(e,"cabinet")?e.cabinet:void 0}}function ms(e){if(e!==void 0)return e===null?null:{rack:e.rack,cabinet:e.cabinet}}function Eo(e){if(e!==void 0)return e===null?null:{side_a_name:e.sideAName,side_a_room_number:e.sideARoomNumber,side_a_rack_number:e.sideARackNumber,side_a_panel_number:e.sideAPanelNumber,side_a_port_1:e.sideAPort1,side_a_carrier_circuit_id:e.sideACarrierCircuitId,side_b_name:e.sideBName,side_b_room_number:e.sideBRoomNumber,side_b_rack_number:e.sideBRackNumber,side_b_panel_number:e.sideBPanelNumber,side_b_port_1:e.sideBPort1,side_b_carrier_circuit_id:e.sideBCarrierCircuitId}}function xo(e){if(e!==void 0)return e===null?null:{service_type:e.serviceType,scope:e.scope,circuits:e.circuits===void 0?void 0:e.circuits.map(Eo),work_description:e.workDescription}}function Fo(e){if(e!==void 0)return e===null?null:{spop_space_from:e.spopSpaceFrom,spop_space_to:e.spopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function Lo(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,company:e.company,phone:e.phone,visitor_type:e.visitorType}}function Vo(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors.map(Lo),locations:e.locations.map(Bo),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,service_details:xo(e.serviceDetails),ppop_space:e.ppopSpace===void 0?void 0:e.ppopSpace.map(ms),spop_space:e.spopSpace===void 0?void 0:e.spopSpace.map(ms),ppop_room_work:Oo(e.ppopRoomWork),spop_room_work:Fo(e.spopRoomWork),notification_recipients:e.notificationRecipients}}function Uo(e){return Ho(e)}function Ho(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?e.start_date_time:void 0,endDateTime:c(e,"end_date_time")?e.end_date_time:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function zo(e){return jo(e)}function jo(e,t){return e==null?e:{ppopSpaceFrom:c(e,"ppop_space_from")?e.ppop_space_from:void 0,ppopSpaceTo:c(e,"ppop_space_to")?e.ppop_space_to:void 0,cableType:c(e,"cable_type")?e.cable_type:void 0,onLadderRack:c(e,"on_ladder_rack")?e.on_ladder_rack:void 0,inInnerDuct:c(e,"in_inner_duct")?e.in_inner_duct:void 0,inFiberGuide:c(e,"in_fiber_guide")?e.in_fiber_guide:void 0}}function Mo(e){return Jo(e)}function Jo(e,t){return e==null?e:{sideAName:c(e,"side_a_name")?e.side_a_name:void 0,sideARoomNumber:c(e,"side_a_room_number")?e.side_a_room_number:void 0,sideARackNumber:c(e,"side_a_rack_number")?e.side_a_rack_number:void 0,sideAPanelNumber:c(e,"side_a_panel_number")?e.side_a_panel_number:void 0,sideAPort1:c(e,"side_a_port_1")?e.side_a_port_1:void 0,sideACarrierCircuitId:c(e,"side_a_carrier_circuit_id")?e.side_a_carrier_circuit_id:void 0,sideBName:c(e,"side_b_name")?e.side_b_name:void 0,sideBRoomNumber:c(e,"side_b_room_number")?e.side_b_room_number:void 0,sideBRackNumber:c(e,"side_b_rack_number")?e.side_b_rack_number:void 0,sideBPanelNumber:c(e,"side_b_panel_number")?e.side_b_panel_number:void 0,sideBPort1:c(e,"side_b_port_1")?e.side_b_port_1:void 0,sideBCarrierCircuitId:c(e,"side_b_carrier_circuit_id")?e.side_b_carrier_circuit_id:void 0}}const We={SiteSurvey:"Site Survey",Testing:"Testing",InstallationDeInstallationWork:"Installation/De-installation Work"};function Wo(e){return Go(e)}function Go(e,t){return e==null?e:{serviceType:c(e,"service_type")?e.service_type:void 0,scope:c(e,"scope")?e.scope:void 0,circuits:c(e,"circuits")?e.circuits.map(Mo):void 0,workDescription:c(e,"work_description")?e.work_description:void 0}}function Zo(e){return Ko(e)}function Ko(e,t){return e==null?e:{spopSpaceFrom:c(e,"spop_space_from")?e.spop_space_from:void 0,spopSpaceTo:c(e,"spop_space_to")?e.spop_space_to:void 0,cableType:c(e,"cable_type")?e.cable_type:void 0,onLadderRack:c(e,"on_ladder_rack")?e.on_ladder_rack:void 0,inInnerDuct:c(e,"in_inner_duct")?e.in_inner_duct:void 0,inFiberGuide:c(e,"in_fiber_guide")?e.in_fiber_guide:void 0}}function ps(e){return Yo(e)}function Yo(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorCompany:c(e,"visitor_company")?e.visitor_company:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitorType:c(e,"visitor_type")?e.visitor_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(Uo):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,visitorHostCompany:c(e,"visitor_host_company")?e.visitor_host_company:void 0,customerExternalReference:c(e,"customer_external_reference")?e.customer_external_reference:void 0,serviceImpactedDescription:c(e,"service_impacted_description")?e.service_impacted_description:void 0,serviceDetails:c(e,"service_details")?Wo(e.service_details):void 0,ppopSpace:c(e,"ppop_space")?e.ppop_space.map(ls):void 0,spopSpace:c(e,"spop_space")?e.spop_space.map(ls):void 0,ppopRoomWork:c(e,"ppop_room_work")?zo(e.ppop_room_work):void 0,spopRoomWork:c(e,"spop_room_work")?Zo(e.spop_room_work):void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at:void 0,updatedAt:c(e,"updated_at")?e.updated_at:void 0,closedAt:c(e,"closed_at")?e.closed_at:void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function Xo(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime.toISOString(),end_date_time:e.endDateTime.toISOString()}}function Qo(e){if(e!==void 0)return e===null?null:{ppop_space_from:e.ppopSpaceFrom,ppop_space_to:e.ppopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function hs(e){if(e!==void 0)return e===null?null:{id:e.id,rack:e.rack,cabinet:e.cabinet}}function er(e){if(e!==void 0)return e===null?null:{id:e.id,side_a_name:e.sideAName,side_a_room_number:e.sideARoomNumber,side_a_rack_number:e.sideARackNumber,side_a_panel_number:e.sideAPanelNumber,side_a_port_1:e.sideAPort1,side_a_carrier_circuit_id:e.sideACarrierCircuitId,side_b_name:e.sideBName,side_b_room_number:e.sideBRoomNumber,side_b_rack_number:e.sideBRackNumber,side_b_panel_number:e.sideBPanelNumber,side_b_port_1:e.sideBPort1,side_b_carrier_circuit_id:e.sideBCarrierCircuitId}}function tr(e){if(e!==void 0)return e===null?null:{service_type:e.serviceType,scope:e.scope,circuits:e.circuits===void 0?void 0:e.circuits.map(er),work_description:e.workDescription}}function ir(e){if(e!==void 0)return e===null?null:{spop_space_from:e.spopSpaceFrom,spop_space_to:e.spopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function sr(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,visitor_company:e.visitorCompany,service_impacted_description:e.serviceImpactedDescription,locations:e.locations===void 0?void 0:e.locations.map(Xo),service_details:tr(e.serviceDetails),ppop_space:e.ppopSpace===void 0?void 0:e.ppopSpace.map(hs),spop_space:e.spopSpace===void 0?void 0:e.spopSpace.map(hs),ppop_room_work:Qo(e.ppopRoomWork),spop_room_work:ir(e.spopRoomWork),customer_external_reference:e.customerExternalReference,notification_recipients:e.notificationRecipients}}function ar(e){return nr(e)}function nr(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?new Date(e.start_date_time):void 0,endDateTime:c(e,"end_date_time")?new Date(e.end_date_time):void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function or(e){return rr(e)}function rr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(ar):void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function cr(e){return dr(e)}function dr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(or):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function ur(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10),operation:e.operation}}function lr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_id:e.badgeholderId,badge_start_date:e.badgeStartDate.toISOString().substring(0,10),badge_end_date:e.badgeEndDate===void 0?void 0:e.badgeEndDate.toISOString().substring(0,10),locations:e.locations===void 0?void 0:e.locations.map(ur),notification_recipients:e.notificationRecipients}}function mr(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10)}}function pr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_first_name:e.badgeholderFirstName,badgeholder_last_name:e.badgeholderLastName,badgeholder_email:e.badgeholderEmail,badgeholder_company:e.badgeholderCompany,badgeholder_phone:e.badgeholderPhone,badge_start_date:e.badgeStartDate.toISOString().substring(0,10),badge_end_date:e.badgeEndDate===void 0?void 0:e.badgeEndDate.toISOString().substring(0,10),locations:e.locations===void 0?void 0:e.locations.map(mr),notification_recipients:e.notificationRecipients}}function hr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_id:e.badgeholderId,badge_end_date:e.badgeEndDate.toISOString().substring(0,10),notification_recipients:e.notificationRecipients}}function vs(e){return vr(e)}function vr(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,site:c(e,"site")?e.site:void 0,siteAddress:c(e,"site_address")?e.site_address:void 0,startDate:c(e,"start_date")?e.start_date:void 0,endDate:c(e,"end_date")?e.end_date:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function gs(e){return gr(e)}function gr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,badgeholderFirstName:c(e,"badgeholder_first_name")?e.badgeholder_first_name:void 0,badgeholderLastName:c(e,"badgeholder_last_name")?e.badgeholder_last_name:void 0,badgeholderEmail:c(e,"badgeholder_email")?e.badgeholder_email:void 0,badgeholderPhone:c(e,"badgeholder_phone")?e.badgeholder_phone:void 0,badgeholderCompany:c(e,"badgeholder_company")?e.badgeholder_company:void 0,requestType:c(e,"request_type")?e.request_type:void 0,badgeStartDate:c(e,"badge_start_date")?e.badge_start_date:void 0,badgeEndDate:c(e,"badge_end_date")?e.badge_end_date:void 0,locations:c(e,"locations")?e.locations.map(vs):void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function wr(e){if(e!==void 0)return e===null?null:{other_notification_recipients:e.otherNotificationRecipients}}function fr(e){return kr(e)}function kr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,badgeholderEmail:c(e,"badgeholder_email")?e.badgeholder_email:void 0,requestType:c(e,"request_type")?e.request_type:void 0,locations:c(e,"locations")?e.locations.map(vs):void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function yr(e){return Tr(e)}function Tr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(fr):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function _t(e){return br(e)}function br(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,fileName:c(e,"file_name")?e.file_name:void 0,fileSize:c(e,"file_size")?e.file_size:void 0,contentType:c(e,"content_type")?e.content_type:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at===null?null:new Date(e.created_at):void 0}}function jt(e){return Rr(e)}function Rr(e,t){return e==null?e:{attachments:c(e,"attachments")?e.attachments.map(_t):void 0}}function Mt(e){if(e!==void 0)return e===null?null:{comment:e.comment}}function vt(e){return Ar(e)}function Ar(e,t){return e==null?e:{ticketNumbers:c(e,"ticket_numbers")?e.ticket_numbers:void 0}}function _r(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10)}}function Ir(e){if(e!==void 0)return e===null?null:{site_code:e.siteCode,visitor_host_id:e.visitorHostId,locations:e.locations===void 0?void 0:e.locations.map(_r)}}function Sr(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone}}const Jt={Escorted:"Escorted",Standard:"Standard",Extended:"Extended"};function Cr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors===void 0?void 0:e.visitors.map(Sr),visit_start_date:e.visitStartDate.toISOString().substring(0,10),visit_end_date:e.visitEndDate.toISOString().substring(0,10),visit_type:e.visitType,sites:e.sites===void 0?void 0:e.sites.map(Ir),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,representing_company:e.representingCompany,description:e.description,notification_recipients:e.notificationRecipients}}function ws(e){return Pr(e)}function Pr(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDate:c(e,"start_date")?e.start_date:void 0,endDate:c(e,"end_date")?e.end_date:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function fs(e){return Nr(e)}function Nr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitStartDate:c(e,"visit_start_date")?e.visit_start_date:void 0,visitEndDate:c(e,"visit_end_date")?e.visit_end_date:void 0,visitType:c(e,"visit_type")?e.visit_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(ws):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,representingCompany:c(e,"representing_company")?e.representing_company:void 0,description:c(e,"description")?e.description:void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function qr(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,other_notification_recipients:e.otherNotificationRecipients}}function Dr(e){return Br(e)}function Br(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(ws):void 0,visitType:c(e,"visit_type")?e.visit_type:void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Or(e){return $r(e)}function $r(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Dr):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function Er(e){return xr(e)}function xr(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,firstName:c(e,"first_name")?e.first_name:void 0,lastName:c(e,"last_name")?e.last_name:void 0}}function Fr(e){return Lr(e)}function Lr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Er):void 0,totalCount:c(e,"total_count")?e.total_count:void 0}}class Vr extends Qe{async cancellationOspAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationOspAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationOspAccessRequest.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:a,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,n=>Vt(n))}async cancellationOspAccessRequest(t,i){return await(await this.cancellationOspAccessRequestRaw(t,i)).value()}async createOspAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createOspAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createOspAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createOspAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const a={};if(a["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:t.body},i);return new q(o,n=>_t(n))}async createOspAccessAttachment(t,i){return await(await this.createOspAccessAttachmentRaw(t,i)).value()}async createOspAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createOspAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createOspAccessComment.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,n=>Ut(n))}async createOspAccessComment(t,i){return await(await this.createOspAccessCommentRaw(t,i)).value()}async createOspAccessTicketRaw(t,i){if(t.oSPAccessTicketRequest===null||t.oSPAccessTicketRequest===void 0)throw new v("oSPAccessTicketRequest","Required parameter requestParameters.oSPAccessTicketRequest was null or undefined when calling createOspAccessTicket.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets",method:"POST",headers:a,query:s,body:To(t.oSPAccessTicketRequest)},i);return new q(o,n=>vt(n))}async createOspAccessTicket(t,i){return await(await this.createOspAccessTicketRaw(t,i)).value()}async getOspAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getOspAccessAttachmentsById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new Ft(o)}async getOspAccessAttachmentsById(t,i){return await(await this.getOspAccessAttachmentsByIdRaw(t,i)).value()}async getOspAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessAttachmentsList.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new q(o,n=>jt(n))}async getOspAccessAttachmentsList(t,i){return await(await this.getOspAccessAttachmentsListRaw(t,i)).value()}async getOspAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessTicketById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new q(o,n=>us(n))}async getOspAccessTicketById(t,i){return await(await this.getOspAccessTicketByIdRaw(t,i)).value()}async getOspAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const a={},o=await this.request({path:"/osp-access-tickets",method:"GET",headers:a,query:s},i);return new q(o,n=>qo(n))}async getOspAccessTickets(t={},i){return await(await this.getOspAccessTicketsRaw(t,i)).value()}async updateOspAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateOspAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updateOspAccessLocationsTicket.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,n=>zt(n))}async updateOspAccessLocationsTicket(t,i){return await(await this.updateOspAccessLocationsTicketRaw(t,i)).value()}async updateOspAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateOspAccessTicket.");if(t.oSPAccessTicketUpdateRequest===null||t.oSPAccessTicketUpdateRequest===void 0)throw new v("oSPAccessTicketUpdateRequest","Required parameter requestParameters.oSPAccessTicketUpdateRequest was null or undefined when calling updateOspAccessTicket.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:Io(t.oSPAccessTicketUpdateRequest)},i);return new q(o,n=>us(n))}async updateOspAccessTicket(t,i){return await(await this.updateOspAccessTicketRaw(t,i)).value()}}class Ur extends Qe{async cancellationPopAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationPopAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationPopAccessRequest.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:a,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,n=>Vt(n))}async cancellationPopAccessRequest(t,i){return await(await this.cancellationPopAccessRequestRaw(t,i)).value()}async createPopAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPopAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createPopAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createPopAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const a={};if(a["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:t.body},i);return new q(o,n=>_t(n))}async createPopAccessAttachment(t,i){return await(await this.createPopAccessAttachmentRaw(t,i)).value()}async createPopAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPopAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createPopAccessComment.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,n=>Ut(n))}async createPopAccessComment(t,i){return await(await this.createPopAccessCommentRaw(t,i)).value()}async createPopAccessTicketRaw(t,i){if(t.pOPAccessTicketRequest===null||t.pOPAccessTicketRequest===void 0)throw new v("pOPAccessTicketRequest","Required parameter requestParameters.pOPAccessTicketRequest was null or undefined when calling createPopAccessTicket.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets",method:"POST",headers:a,query:s,body:Vo(t.pOPAccessTicketRequest)},i);return new q(o,n=>vt(n))}async createPopAccessTicket(t,i){return await(await this.createPopAccessTicketRaw(t,i)).value()}async getPopAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPopAccessAttachmentsById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new Ft(o)}async getPopAccessAttachmentsById(t,i){return await(await this.getPopAccessAttachmentsByIdRaw(t,i)).value()}async getPopAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessAttachmentsList.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new q(o,n=>jt(n))}async getPopAccessAttachmentsList(t,i){return await(await this.getPopAccessAttachmentsListRaw(t,i)).value()}async getPopAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessTicketById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new q(o,n=>ps(n))}async getPopAccessTicketById(t,i){return await(await this.getPopAccessTicketByIdRaw(t,i)).value()}async getPopAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const a={},o=await this.request({path:"/pop-access-tickets",method:"GET",headers:a,query:s},i);return new q(o,n=>cr(n))}async getPopAccessTickets(t={},i){return await(await this.getPopAccessTicketsRaw(t,i)).value()}async updatePopAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePopAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updatePopAccessLocationsTicket.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,n=>zt(n))}async updatePopAccessLocationsTicket(t,i){return await(await this.updatePopAccessLocationsTicketRaw(t,i)).value()}async updatePopAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePopAccessTicket.");if(t.pOPAccessTicketUpdateRequest===null||t.pOPAccessTicketUpdateRequest===void 0)throw new v("pOPAccessTicketUpdateRequest","Required parameter requestParameters.pOPAccessTicketUpdateRequest was null or undefined when calling updatePopAccessTicket.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:sr(t.pOPAccessTicketUpdateRequest)},i);return new q(o,n=>ps(n))}async updatePopAccessTicket(t,i){return await(await this.updatePopAccessTicketRaw(t,i)).value()}}class Hr extends Qe{async cancellationPermanentBadgeRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationPermanentBadgeRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationPermanentBadgeRequest.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:a,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,n=>Vt(n))}async cancellationPermanentBadgeRequest(t,i){return await(await this.cancellationPermanentBadgeRequestRaw(t,i)).value()}async createPermanentBadegeAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPermanentBadegeAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createPermanentBadegeAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createPermanentBadegeAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const a={};if(a["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:t.body},i);return new q(o,n=>_t(n))}async createPermanentBadegeAttachment(t,i){return await(await this.createPermanentBadegeAttachmentRaw(t,i)).value()}async createPermanentBadgeCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPermanentBadgeComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createPermanentBadgeComment.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,n=>Ut(n))}async createPermanentBadgeComment(t,i){return await(await this.createPermanentBadgeCommentRaw(t,i)).value()}async createPermanentBadgeModifyTicketRaw(t,i){if(t.permanentBadgeAccessModifyTicketRequest===null||t.permanentBadgeAccessModifyTicketRequest===void 0)throw new v("permanentBadgeAccessModifyTicketRequest","Required parameter requestParameters.permanentBadgeAccessModifyTicketRequest was null or undefined when calling createPermanentBadgeModifyTicket.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-modify-tickets",method:"POST",headers:a,query:s,body:lr(t.permanentBadgeAccessModifyTicketRequest)},i);return new q(o,n=>vt(n))}async createPermanentBadgeModifyTicket(t,i){return await(await this.createPermanentBadgeModifyTicketRaw(t,i)).value()}async createPermanentBadgeNewTicketRaw(t,i){if(t.permanentBadgeAccessNewTicketRequest===null||t.permanentBadgeAccessNewTicketRequest===void 0)throw new v("permanentBadgeAccessNewTicketRequest","Required parameter requestParameters.permanentBadgeAccessNewTicketRequest was null or undefined when calling createPermanentBadgeNewTicket.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-new-tickets",method:"POST",headers:a,query:s,body:pr(t.permanentBadgeAccessNewTicketRequest)},i);return new q(o,n=>vt(n))}async createPermanentBadgeNewTicket(t,i){return await(await this.createPermanentBadgeNewTicketRaw(t,i)).value()}async createPermanentBadgeTerminateTicketRaw(t,i){if(t.permanentBadgeAccessTerminateTicketRequest===null||t.permanentBadgeAccessTerminateTicketRequest===void 0)throw new v("permanentBadgeAccessTerminateTicketRequest","Required parameter requestParameters.permanentBadgeAccessTerminateTicketRequest was null or undefined when calling createPermanentBadgeTerminateTicket.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-terminate-tickets",method:"POST",headers:a,query:s,body:hr(t.permanentBadgeAccessTerminateTicketRequest)},i);return new q(o,n=>vt(n))}async createPermanentBadgeTerminateTicket(t,i){return await(await this.createPermanentBadgeTerminateTicketRaw(t,i)).value()}async getPermanentBadgeAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPermanentBadgeAttachmentsById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new Ft(o)}async getPermanentBadgeAttachmentsById(t,i){return await(await this.getPermanentBadgeAttachmentsByIdRaw(t,i)).value()}async getPermanentBadgeAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeAttachmentsList.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new q(o,n=>jt(n))}async getPermanentBadgeAttachmentsList(t,i){return await(await this.getPermanentBadgeAttachmentsListRaw(t,i)).value()}async getPermanentBadgeHoldersListRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new v("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getPermanentBadgeHoldersList.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.activeBadge!==void 0&&(s.active_badge=t.activeBadge),t.nameOrEmailContains!==void 0&&(s.name_or_email_contains=t.nameOrEmailContains),t.page!==void 0&&(s.page=t.page),t.size!==void 0&&(s.size=t.size);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/badge-holders",method:"GET",headers:a,query:s},i);return new q(o,n=>lo(n))}async getPermanentBadgeHoldersList(t,i){return await(await this.getPermanentBadgeHoldersListRaw(t,i)).value()}async getPermanentBadgeTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeTicketById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new q(o,n=>gs(n))}async getPermanentBadgeTicketById(t,i){return await(await this.getPermanentBadgeTicketByIdRaw(t,i)).value()}async getPermanentBadgeTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const a={},o=await this.request({path:"/permanent-badge-access-tickets",method:"GET",headers:a,query:s},i);return new q(o,n=>yr(n))}async getPermanentBadgeTickets(t={},i){return await(await this.getPermanentBadgeTicketsRaw(t,i)).value()}async updatePermanentBadgeLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePermanentBadgeLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updatePermanentBadgeLocationsTicket.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,n=>zt(n))}async updatePermanentBadgeLocationsTicket(t,i){return await(await this.updatePermanentBadgeLocationsTicketRaw(t,i)).value()}async updatePermanentBadgeTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePermanentBadgeTicket.");if(t.permanentBadgeAccessTicketUpdateRequest===null||t.permanentBadgeAccessTicketUpdateRequest===void 0)throw new v("permanentBadgeAccessTicketUpdateRequest","Required parameter requestParameters.permanentBadgeAccessTicketUpdateRequest was null or undefined when calling updatePermanentBadgeTicket.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:wr(t.permanentBadgeAccessTicketUpdateRequest)},i);return new q(o,n=>gs(n))}async updatePermanentBadgeTicket(t,i){return await(await this.updatePermanentBadgeTicketRaw(t,i)).value()}}class zr extends Qe{async cancellationVisitorAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationVisitorAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationVisitorAccessRequest.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:a,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,n=>Vt(n))}async cancellationVisitorAccessRequest(t,i){return await(await this.cancellationVisitorAccessRequestRaw(t,i)).value()}async createVisitorAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createVisitorAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createVisitorAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createVisitorAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const a={};if(a["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:t.body},i);return new q(o,n=>_t(n))}async createVisitorAccessAttachment(t,i){return await(await this.createVisitorAccessAttachmentRaw(t,i)).value()}async createVisitorAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createVisitorAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createVisitorAccessComment.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,n=>Ut(n))}async createVisitorAccessComment(t,i){return await(await this.createVisitorAccessCommentRaw(t,i)).value()}async createVisitorAccessTicketRaw(t,i){if(t.visitorAccessTicketRequest===null||t.visitorAccessTicketRequest===void 0)throw new v("visitorAccessTicketRequest","Required parameter requestParameters.visitorAccessTicketRequest was null or undefined when calling createVisitorAccessTicket.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets",method:"POST",headers:a,query:s,body:Cr(t.visitorAccessTicketRequest)},i);return new q(o,n=>vt(n))}async createVisitorAccessTicket(t,i){return await(await this.createVisitorAccessTicketRaw(t,i)).value()}async getVisitorAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getVisitorAccessAttachmentsById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new Ft(o)}async getVisitorAccessAttachmentsById(t,i){return await(await this.getVisitorAccessAttachmentsByIdRaw(t,i)).value()}async getVisitorAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessAttachmentsList.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new q(o,n=>jt(n))}async getVisitorAccessAttachmentsList(t,i){return await(await this.getVisitorAccessAttachmentsListRaw(t,i)).value()}async getVisitorAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessTicketById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new q(o,n=>fs(n))}async getVisitorAccessTicketById(t,i){return await(await this.getVisitorAccessTicketByIdRaw(t,i)).value()}async getVisitorAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const a={},o=await this.request({path:"/visitor-access-tickets",method:"GET",headers:a,query:s},i);return new q(o,n=>Or(n))}async getVisitorAccessTickets(t={},i){return await(await this.getVisitorAccessTicketsRaw(t,i)).value()}async updateVisitorAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateVisitorAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updateVisitorAccessLocationsTicket.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,n=>zt(n))}async updateVisitorAccessLocationsTicket(t,i){return await(await this.updateVisitorAccessLocationsTicketRaw(t,i)).value()}async updateVisitorAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateVisitorAccessTicket.");if(t.visitorAccessTicketUpdateRequest===null||t.visitorAccessTicketUpdateRequest===void 0)throw new v("visitorAccessTicketUpdateRequest","Required parameter requestParameters.visitorAccessTicketUpdateRequest was null or undefined when calling updateVisitorAccessTicket.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:qr(t.visitorAccessTicketUpdateRequest)},i);return new q(o,n=>fs(n))}async updateVisitorAccessTicket(t,i){return await(await this.updateVisitorAccessTicketRaw(t,i)).value()}}class jr extends Qe{async getVisitorHostsListRaw(t,i){if(t.site===null||t.site===void 0)throw new v("site","Required parameter requestParameters.site was null or undefined when calling getVisitorHostsList.");const s={};t.site!==void 0&&(s.site=t.site),t.nameOrEmailContains!==void 0&&(s.name_or_email_contains=t.nameOrEmailContains),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-hosts",method:"GET",headers:a,query:s},i);return new q(o,n=>Fr(n))}async getVisitorHostsList(t,i){return await(await this.getVisitorHostsListRaw(t,i)).value()}}const Mr="http://localhost".replace(/\/+$/,"");class Wt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Mr}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||ks}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Jr=new Wt;class Bt{constructor(t=Jr){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new Kr(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?Bt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new Zr(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;Gr(r.body)||r.body instanceof URLSearchParams||Wr(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}Bt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Wr(e){return typeof Blob<"u"&&e instanceof Blob}function Gr(e){return typeof FormData<"u"&&e instanceof FormData}class Zr extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Kr extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class yi extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function f(e,t){return e[t]!=null}function ks(e,t=""){return Object.keys(e).map(i=>ys(i,e[i],t)).filter(i=>i.length>0).join("&")}function ys(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return ys(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?ks(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class It{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}const Yr="https://service-management.digitalrealty.com".replace(/\/+$/,"");class Gt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Yr}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ts}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Xr=new Gt;class yt{constructor(t=Xr){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new ic(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?yt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new tc(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;ec(r.body)||r.body instanceof URLSearchParams||Qr(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}yt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Qr(e){return typeof Blob<"u"&&e instanceof Blob}function ec(e){return typeof FormData<"u"&&e instanceof FormData}class tc extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class ic extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class ut extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function Ge(e,t){return e[t]!=null}function Ts(e,t=""){return Object.keys(e).map(i=>bs(i,e[i],t)).filter(i=>i.length>0).join("&")}function bs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return bs(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ts(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ti{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class sc{constructor(t){this.raw=t}async value(){return await this.raw.text()}}const ac="https://service-management.digitalrealty.com".replace(/\/+$/,"");class Rs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:ac}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||As}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const nc=new Rs;class ni{constructor(t=nc){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new dc(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ni.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new cc(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;rc(r.body)||r.body instanceof URLSearchParams||oc(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ni.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function oc(e){return typeof Blob<"u"&&e instanceof Blob}function rc(e){return typeof FormData<"u"&&e instanceof FormData}class cc extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class dc extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class ee extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function I(e,t){return e[t]!=null}function As(e,t=""){return Object.keys(e).map(i=>_s(i,e[i],t)).filter(i=>i.length>0).join("&")}function _s(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return _s(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?As(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Pe{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class uc{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function lc(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function mc(e){return pc(e)}function pc(e,t){return e==null?e:{message:I(e,"message")?e.message:void 0}}function hc(e){return vc(e)}function vc(e,t){return e==null?e:{requestType:I(e,"request_type")?e.request_type:void 0,categories:I(e,"categories")?e.categories:void 0}}function gc(e){return wc(e)}function wc(e,t){return e==null?e:{items:I(e,"items")?e.items.map(hc):void 0}}function Is(e){return fc(e)}function fc(e,t){return e==null?e:{createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,comment:I(e,"comment")?e.comment:void 0}}function kc(e){return yc(e)}function yc(e,t){return e==null?e:{comments:I(e,"comments")?e.comments.map(Is):void 0}}function Tc(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,request_type:e.requestType,category:e.category,subject:e.subject,description:e.description,expected_start:e.expectedStart===void 0?void 0:e.expectedStart===null?null:e.expectedStart.toISOString(),customer_reference:e.customerReference,locations:e.locations,reference_ticket:e.referenceTicket,other_notification_recipients:e.otherNotificationRecipients}}function bi(e){return bc(e)}function bc(e,t){return e==null?e:{ticketId:I(e,"ticket_id")?e.ticket_id:void 0,accountNumber:I(e,"account_number")?e.account_number:void 0,accountName:I(e,"account_name")?e.account_name:void 0,status:I(e,"status")?e.status:void 0,cancellationReason:I(e,"cancellation_reason")?e.cancellation_reason:void 0,site:I(e,"site")?e.site:void 0,locations:I(e,"locations")?e.locations:void 0,requestType:I(e,"request_type")?e.request_type:void 0,category:I(e,"category")?e.category:void 0,subject:I(e,"subject")?e.subject:void 0,description:I(e,"description")?e.description:void 0,expectedStart:I(e,"expected_start")?e.expected_start===null?null:new Date(e.expected_start):void 0,referenceTicket:I(e,"reference_ticket")?e.reference_ticket:void 0,customerReference:I(e,"customer_reference")?e.customer_reference:void 0,otherNotificationRecipients:I(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,updatedAt:I(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:I(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:I(e,"comments")?e.comments.map(Is):void 0}}function Rc(e){return Ac(e)}function Ac(e,t){return e==null?e:{accountNumber:I(e,"account_number")?e.account_number:void 0,accountName:I(e,"account_name")?e.account_name:void 0,id:I(e,"id")?e.id:void 0,status:I(e,"status")?e.status:void 0,site:I(e,"site")?e.site:void 0,locations:I(e,"locations")?e.locations:void 0,description:I(e,"description")?e.description:void 0,subject:I(e,"subject")?e.subject:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,updatedAt:I(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:I(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function _c(e){return Ic(e)}function Ic(e,t){return e==null?e:{remoteHandsTickets:I(e,"remote_hands_tickets")?e.remote_hands_tickets.map(Rc):void 0,totalCount:I(e,"total_count")?e.total_count:void 0,pageNumber:I(e,"page_number")?e.page_number:void 0,pageSize:I(e,"page_size")?e.page_size:void 0}}function Sc(e){if(e!==void 0)return e===null?null:{customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Ss(e){return Cc(e)}function Cc(e,t){return e==null?e:{id:I(e,"id")?e.id:void 0,fileName:I(e,"file_name")?e.file_name:void 0,fileSize:I(e,"file_size")?e.file_size:void 0,contentType:I(e,"content_type")?e.content_type:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?e.created_at===null?null:new Date(e.created_at):void 0}}function Pc(e){return Nc(e)}function Nc(e,t){return e==null?e:{attachments:I(e,"attachments")?e.attachments.map(Ss):void 0}}function qc(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class Dc extends ni{async cancellationRemoteHandsRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationRemoteHandsRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new ee("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationRemoteHandsRequest.");const s={},a={};a["Content-Type"]="application/json";const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:a,query:s,body:lc(t.cancellationTicketsRequest)},i);return new Pe(o,n=>mc(n))}async cancellationRemoteHandsRequest(t,i){return await(await this.cancellationRemoteHandsRequestRaw(t,i)).value()}async createRemoteHandsAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemoteHandsAttachment.");if(t.fileName===null||t.fileName===void 0)throw new ee("fileName","Required parameter requestParameters.fileName was null or undefined when calling createRemoteHandsAttachment.");if(t.body===null||t.body===void 0)throw new ee("body","Required parameter requestParameters.body was null or undefined when calling createRemoteHandsAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const a={};if(a["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:t.body},i);return new Pe(o,n=>Ss(n))}async createRemoteHandsAttachment(t,i){return await(await this.createRemoteHandsAttachmentRaw(t,i)).value()}async createRemoteHandsCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemoteHandsComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new ee("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createRemoteHandsComment.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:qc(t.ticketCommentsRequest)},i);return new Pe(o,n=>kc(n))}async createRemoteHandsComment(t,i){return await(await this.createRemoteHandsCommentRaw(t,i)).value()}async createRemoteHandsTicketRaw(t,i){if(t.remoteHandsRequest===null||t.remoteHandsRequest===void 0)throw new ee("remoteHandsRequest","Required parameter requestParameters.remoteHandsRequest was null or undefined when calling createRemoteHandsTicket.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets",method:"POST",headers:a,query:s,body:Tc(t.remoteHandsRequest)},i);return new Pe(o,n=>bi(n))}async createRemoteHandsTicket(t,i){return await(await this.createRemoteHandsTicketRaw(t,i)).value()}async getRemoteHandsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new ee("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getRemoteHandsAttachmentsById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new uc(o)}async getRemoteHandsAttachmentsById(t,i){return await(await this.getRemoteHandsAttachmentsByIdRaw(t,i)).value()}async getRemoteHandsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsAttachmentsList.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new Pe(o,n=>Pc(n))}async getRemoteHandsAttachmentsList(t,i){return await(await this.getRemoteHandsAttachmentsListRaw(t,i)).value()}async getRemoteHandsCategoriesListRaw(t,i){if(t.site===null||t.site===void 0)throw new ee("site","Required parameter requestParameters.site was null or undefined when calling getRemoteHandsCategoriesList.");const s={};t.site!==void 0&&(s.site=t.site);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/categories",method:"GET",headers:a,query:s},i);return new Pe(o,n=>gc(n))}async getRemoteHandsCategoriesList(t,i){return await(await this.getRemoteHandsCategoriesListRaw(t,i)).value()}async getRemoteHandsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsTicketById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new Pe(o,n=>bi(n))}async getRemoteHandsTicketById(t,i){return await(await this.getRemoteHandsTicketByIdRaw(t,i)).value()}async getRemoteHandsTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const a={},o=await this.request({path:"/remote-hands-tickets",method:"GET",headers:a,query:s},i);return new Pe(o,n=>_c(n))}async getRemoteHandsTickets(t={},i){return await(await this.getRemoteHandsTicketsRaw(t,i)).value()}async updateRemoteHandsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateRemoteHandsTicketById.");if(t.remoteHandsUpdateRequest===null||t.remoteHandsUpdateRequest===void 0)throw new ee("remoteHandsUpdateRequest","Required parameter requestParameters.remoteHandsUpdateRequest was null or undefined when calling updateRemoteHandsTicketById.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:Sc(t.remoteHandsUpdateRequest)},i);return new Pe(o,n=>bi(n))}async updateRemoteHandsTicketById(t,i){return await(await this.updateRemoteHandsTicketByIdRaw(t,i)).value()}}function Bc(e){return Oc(e)}function Oc(e,t){return e==null?e:{serviceManagement:f(e,"service_management")?e.service_management:void 0,remoteHands:f(e,"remote_hands")?e.remote_hands:void 0,deliveries:f(e,"deliveries")?e.deliveries:void 0,removals:f(e,"removals")?e.removals:void 0,facilitiesAccess:f(e,"facilities_access")?e.facilities_access:void 0,temporaryAccess:f(e,"temporary_access")?e.temporary_access:void 0,inventory:f(e,"inventory")?e.inventory:void 0,orderHistory:f(e,"order_history")?e.order_history:void 0,precabling:f(e,"precabling")?e.precabling:void 0,crossConnect:f(e,"cross_connect")?e.cross_connect:void 0,customerEquipmentConnection:f(e,"customer_equipment_connection")?e.customer_equipment_connection:void 0,virtualConnectivity:f(e,"virtual_connectivity")?e.virtual_connectivity:void 0,customerCare:f(e,"customer_care")?e.customer_care:void 0,troubleTickets:f(e,"trouble_tickets")?e.trouble_tickets:void 0}}function $c(e){return Ec(e)}function Ec(e,t){return e==null?e:{name:f(e,"name")?e.name:void 0,privilegeLevel:f(e,"privilege_level")?e.privilege_level:void 0}}function xc(e){return Fc(e)}function Fc(e,t){return e==null?e:{id:e.id,accountNumber:e.account_number,siteId:e.site_id,floor:f(e,"floor")?e.floor:void 0,room:f(e,"room")?e.room:void 0,cage:f(e,"cage")?e.cage:void 0,rack:f(e,"rack")?e.rack:void 0,row:f(e,"row")?e.row:void 0,locationType:e.location_type,csrDemarcation:e.csr_demarcation,comment:f(e,"comment")?e.comment:void 0,dcimEnabled:f(e,"dcim_enabled")?e.dcim_enabled:void 0,permissions:f(e,"permissions")?e.permissions.map($c):void 0,assignableProcesses:f(e,"assignable_processes")?Bc(e.assignable_processes):void 0}}function Lc(e){return Vc(e)}function Vc(e,t){return e==null?e:{self:f(e,"self")?e.self:void 0,first:f(e,"first")?e.first:void 0,prev:f(e,"prev")?e.prev:void 0,next:f(e,"next")?e.next:void 0,last:f(e,"last")?e.last:void 0,items:e.items.map(xc)}}function Uc(e){return Hc(e)}function Hc(e,t){return e==null?e:{count:e.count}}function Cs(e){return zc(e)}function zc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,locationId:f(e,"location_id")?e.location_id:void 0,name:f(e,"name")?e.name:void 0,campus:f(e,"campus")?e.campus:void 0,metroArea:f(e,"metro_area")?e.metro_area:void 0,region:f(e,"region")?e.region:void 0,regionName:f(e,"region_name")?e.region_name:void 0,country:f(e,"country")?e.country:void 0,addressCountry:f(e,"address_country")?e.address_country:void 0,addressLocality:f(e,"address_locality")?e.address_locality:void 0,addressRegion:f(e,"address_region")?e.address_region:void 0,postalCode:f(e,"postal_code")?e.postal_code:void 0,streetAddress:f(e,"street_address")?e.street_address:void 0,peeringdbFacilityId:f(e,"peeringdb_facility_id")?e.peeringdb_facility_id:void 0,organisationName:f(e,"organisation_name")?e.organisation_name:void 0,timeZone:f(e,"time_zone")?e.time_zone:void 0,latitude:f(e,"latitude")?e.latitude:void 0,longitude:f(e,"longitude")?e.longitude:void 0,locations:f(e,"locations")?Uc(e.locations):void 0}}function jc(e){return Mc(e)}function Mc(e,t){return e==null?e:{self:f(e,"self")?e.self:void 0,first:f(e,"first")?e.first:void 0,prev:f(e,"prev")?e.prev:void 0,next:f(e,"next")?e.next:void 0,last:f(e,"last")?e.last:void 0,items:e.items.map(Cs)}}function Jc(e){return Wc(e)}function Wc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,name:f(e,"name")?e.name:void 0,description:f(e,"description")?e.description:void 0}}function Gc(e){return Zc(e)}function Zc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,name:f(e,"name")?e.name:void 0,description:f(e,"description")?e.description:void 0}}class Kc extends Bt{async getLocationsRaw(t,i){const s={};t.sort!==void 0&&(s.sort=t.sort),t.cursor!==void 0&&(s.cursor=t.cursor),t.pageSize!==void 0&&(s.page_size=t.pageSize),t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.id!==void 0&&(s.id=t.id),t.siteId!==void 0&&(s.site_id=t.siteId),t.floor!==void 0&&(s.floor=t.floor),t.room!==void 0&&(s.room=t.room),t.cage!==void 0&&(s.cage=t.cage),t.rack!==void 0&&(s.rack=t.rack),t.row!==void 0&&(s.row=t.row),t.demarcation!==void 0&&(s.demarcation=t.demarcation),t.locationType!==void 0&&(s.location_type=t.locationType),t.embed!==void 0&&(s.embed=t.embed),t.permissionType!==void 0&&(s.permission_type=t.permissionType),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege),t.dcimEnabled!==void 0&&(s.dcim_enabled=t.dcimEnabled),t.assignableProcess!==void 0&&(s.assignable_process=t.assignableProcess);const a={};this.configuration&&this.configuration.apiKey&&(a.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/locations",method:"GET",headers:a,query:s},i);return new It(o,n=>Lc(n))}async getLocations(t={},i){return await(await this.getLocationsRaw(t,i)).value()}}class Ps extends Bt{async getOspsBySiteIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new yi("siteId","Required parameter requestParameters.siteId was null or undefined when calling getOspsBySiteId.");const s={},a={};this.configuration&&this.configuration.apiKey&&(a.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}/osps".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:a,query:s},i);return new It(o,n=>n.map(Jc))}async getOspsBySiteId(t,i){return await(await this.getOspsBySiteIdRaw(t,i)).value()}async getPopsBySiteIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new yi("siteId","Required parameter requestParameters.siteId was null or undefined when calling getPopsBySiteId.");const s={},a={};this.configuration&&this.configuration.apiKey&&(a.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}/pops".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:a,query:s},i);return new It(o,n=>n.map(Gc))}async getPopsBySiteId(t,i){return await(await this.getPopsBySiteIdRaw(t,i)).value()}async getSiteByIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new yi("siteId","Required parameter requestParameters.siteId was null or undefined when calling getSiteById.");const s={},a={};this.configuration&&this.configuration.apiKey&&(a.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:a,query:s},i);return new It(o,n=>Cs(n))}async getSiteById(t,i){return await(await this.getSiteByIdRaw(t,i)).value()}async getSitesRaw(t,i){const s={};t.name!==void 0&&(s.name=t.name),t.sort!==void 0&&(s.sort=t.sort),t.cursor!==void 0&&(s.cursor=t.cursor),t.pageSize!==void 0&&(s.page_size=t.pageSize),t.showMySites!==void 0&&(s.show_my_sites=t.showMySites),t.embed!==void 0&&(s.embed=t.embed);const a={};this.configuration&&this.configuration.apiKey&&(a.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites",method:"GET",headers:a,query:s},i);return new It(o,n=>jc(n))}async getSites(t={},i){return await(await this.getSitesRaw(t,i)).value()}}const Yc="https://api.digitalrealty.com".replace(/\/+$/,"");class Ns{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Yc}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||qs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Xc=new Ns;class oi{constructor(t=Xc){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new id(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?oi.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new td(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;ed(r.body)||r.body instanceof URLSearchParams||Qc(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}oi.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Qc(e){return typeof Blob<"u"&&e instanceof Blob}function ed(e){return typeof FormData<"u"&&e instanceof FormData}class td extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class id extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class Zt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function T(e,t){return e[t]!=null}function qs(e,t=""){return Object.keys(e).map(i=>Ds(i,e[i],t)).filter(i=>i.length>0).join("&")}function Ds(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return Ds(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?qs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ri{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Bs{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}const sd="https://api.digitalrealty.com/service-management/v1".replace(/\/+$/,"");class Os{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:sd}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||$s}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ad=new Os;class ri{constructor(t=ad){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new cd(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ri.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new rd(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;od(r.body)||r.body instanceof URLSearchParams||nd(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ri.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function nd(e){return typeof Blob<"u"&&e instanceof Blob}function od(e){return typeof FormData<"u"&&e instanceof FormData}class rd extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class cd extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class gt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function D(e,t){return e[t]!=null}function $s(e,t=""){return Object.keys(e).map(i=>Es(i,e[i],t)).filter(i=>i.length>0).join("&")}function Es(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return Es(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?$s(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Kt{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class xs{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function Fs(e){return dd(e)}function dd(e,t){return e==null?e:{createdBy:D(e,"created_by")?e.created_by:void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,comment:D(e,"comment")?e.comment:void 0}}function ud(e){return ld(e)}function ld(e,t){return e==null?e:{comments:D(e,"comments")?e.comments.map(Fs):void 0}}function Ls(e){return md(e)}function md(e,t){return e==null?e:{id:D(e,"id")?e.id:void 0,fileName:D(e,"file_name")?e.file_name:void 0}}function pd(e){return hd(e)}function hd(e,t){return e==null?e:{accountNumber:D(e,"account_number")?e.account_number:void 0,accountName:D(e,"account_name")?e.account_name:void 0,id:D(e,"id")?e.id:void 0,status:D(e,"status")?e.status:void 0,subject:D(e,"subject")?e.subject:void 0,site:D(e,"site")?e.site:void 0,priority:D(e,"priority")?e.priority:void 0,comments:D(e,"comments")?e.comments.map(Fs):void 0,attachments:D(e,"attachments")?e.attachments.map(Ls):void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,updatedAt:D(e,"updated_at")?new Date(e.updated_at):void 0}}function vd(e){return gd(e)}function gd(e,t){return e==null?e:{accountNumber:D(e,"account_number")?e.account_number:void 0,accountName:D(e,"account_name")?e.account_name:void 0,id:D(e,"id")?e.id:void 0,status:D(e,"status")?e.status:void 0,subject:D(e,"subject")?e.subject:void 0,site:D(e,"site")?e.site:void 0,priority:D(e,"priority")?e.priority:void 0,attachments:D(e,"attachments")?e.attachments.map(Ls):void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,updatedAt:D(e,"updated_at")?new Date(e.updated_at):void 0}}function wd(e){return fd(e)}function fd(e,t){return e==null?e:{items:D(e,"items")?e.items.map(vd):void 0,totalCount:D(e,"total_count")?e.total_count:void 0,pageNumber:D(e,"page_number")?e.page_number:void 0,pageSize:D(e,"page_size")?e.page_size:void 0}}function kd(e){return yd(e)}function yd(e,t){return e==null?e:{id:D(e,"id")?e.id:void 0,fileName:D(e,"file_name")?e.file_name:void 0,fileSize:D(e,"file_size")?e.file_size:void 0,contentType:D(e,"content_type")?e.content_type:void 0,createdBy:D(e,"created_by")?e.created_by:void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0}}function Td(e){return bd(e)}function bd(e,t){return e==null?e:{attachments:D(e,"attachments")?e.attachments.map(kd):void 0}}function Rd(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class Ad extends ri{async createIncidentCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new gt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createIncidentComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new gt("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createIncidentComment.");const s={},a={};a["Content-Type"]="application/json";const o=await this.request({path:"/incident-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:Rd(t.ticketCommentsRequest)},i);return new Kt(o,n=>ud(n))}async createIncidentComment(t,i){return await(await this.createIncidentCommentRaw(t,i)).value()}async downloadIncidentTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const a={},o=await this.request({path:"/incident-tickets/file",method:"GET",headers:a,query:s},i);return new xs(o)}async downloadIncidentTickets(t={},i){return await(await this.downloadIncidentTicketsRaw(t,i)).value()}async getIncidentsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new gt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new gt("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getIncidentsAttachmentsById.");const s={},a={},o=await this.request({path:"/incident-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new xs(o)}async getIncidentsAttachmentsById(t,i){return await(await this.getIncidentsAttachmentsByIdRaw(t,i)).value()}async getIncidentsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new gt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsAttachmentsList.");const s={},a={},o=await this.request({path:"/incident-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new Kt(o,n=>Td(n))}async getIncidentsAttachmentsList(t,i){return await(await this.getIncidentsAttachmentsListRaw(t,i)).value()}async getIncidentsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new gt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsTicketById.");const s={},a={},o=await this.request({path:"/incident-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new Kt(o,n=>pd(n))}async getIncidentsTicketById(t,i){return await(await this.getIncidentsTicketByIdRaw(t,i)).value()}async getIncidentsTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const a={},o=await this.request({path:"/incident-tickets",method:"GET",headers:a,query:s},i);return new Kt(o,n=>wd(n))}async getIncidentsTickets(t={},i){return await(await this.getIncidentsTicketsRaw(t,i)).value()}}const _d="http://localhost".replace(/\/+$/,"");class Vs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:_d}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Hs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Id=new Vs;class ci{constructor(t=Id){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new Nd(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ci.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new Pd(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;Cd(r.body)||r.body instanceof URLSearchParams||Sd(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ci.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Sd(e){return typeof Blob<"u"&&e instanceof Blob}function Cd(e){return typeof FormData<"u"&&e instanceof FormData}class Pd extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Nd extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class Us extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function Ne(e,t){return e[t]!=null}function Hs(e,t=""){return Object.keys(e).map(i=>zs(i,e[i],t)).filter(i=>i.length>0).join("&")}function zs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return zs(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Hs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class qd{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}const Dd="http://localhost".replace(/\/+$/,"");class js{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Dd}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Js}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Bd=new js;class di{constructor(t=Bd){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new xd(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?di.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new Ed(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;$d(r.body)||r.body instanceof URLSearchParams||Od(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}di.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Od(e){return typeof Blob<"u"&&e instanceof Blob}function $d(e){return typeof FormData<"u"&&e instanceof FormData}class Ed extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class xd extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}function Ms(e,t){return e[t]!=null}function Js(e,t=""){return Object.keys(e).map(i=>Ws(i,e[i],t)).filter(i=>i.length>0).join("&")}function Ws(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return Ws(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Js(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Gs{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}function Fd(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function Ld(e){return Vd(e)}function Vd(e,t){return e==null?e:{message:S(e,"message")?e.message:void 0}}function Ud(e){return Hd(e)}function Hd(e,t){return e==null?e:{requestType:S(e,"request_type")?e.request_type:void 0,categories:S(e,"categories")?e.categories:void 0}}function zd(e){return jd(e)}function jd(e,t){return e==null?e:{items:S(e,"items")?e.items.map(Ud):void 0}}function Zs(e){return Md(e)}function Md(e,t){return e==null?e:{createdBy:S(e,"created_by")?e.created_by:void 0,createdAt:S(e,"created_at")?new Date(e.created_at):void 0,comment:S(e,"comment")?e.comment:void 0}}function Jd(e){return Wd(e)}function Wd(e,t){return e==null?e:{comments:S(e,"comments")?e.comments.map(Zs):void 0}}function Gd(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,request_type:e.requestType,category:e.category,locations:e.locations,customer_reference:e.customerReference,description:e.description,notification_recipients:e.notificationRecipients}}function Ai(e){return Zd(e)}function Zd(e,t){return e==null?e:{accountNumber:S(e,"account_number")?e.account_number:void 0,accountName:S(e,"account_name")?e.account_name:void 0,id:S(e,"id")?e.id:void 0,status:S(e,"status")?e.status:void 0,cancellationReason:S(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:S(e,"subject")?e.subject:void 0,requestType:S(e,"request_type")?e.request_type:void 0,category:S(e,"category")?e.category:void 0,site:S(e,"site")?e.site:void 0,locations:S(e,"locations")?e.locations:void 0,customerReference:S(e,"customer_reference")?e.customer_reference:void 0,description:S(e,"description")?e.description:void 0,notificationRecipients:S(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:S(e,"created_by")?e.created_by:void 0,createdAt:S(e,"created_at")?new Date(e.created_at):void 0,updatedAt:S(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:S(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:S(e,"comments")?e.comments.map(Zs):void 0}}function Kd(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Yd(e){return Xd(e)}function Xd(e,t){return e==null?e:{accountNumber:S(e,"account_number")?e.account_number:void 0,accountName:S(e,"account_name")?e.account_name:void 0,id:S(e,"id")?e.id:void 0,status:S(e,"status")?e.status:void 0,subject:S(e,"subject")?e.subject:void 0,site:S(e,"site")?e.site:void 0,locations:S(e,"locations")?e.locations:void 0,description:S(e,"description")?e.description:void 0,createdBy:S(e,"created_by")?e.created_by:void 0,createdAt:S(e,"created_at")?new Date(e.created_at):void 0,updatedAt:S(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:S(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Qd(e){return eu(e)}function eu(e,t){return e==null?e:{items:S(e,"items")?e.items.map(Yd):void 0,totalCount:S(e,"total_count")?e.total_count:void 0,pageNumber:S(e,"page_number")?e.page_number:void 0,pageSize:S(e,"page_size")?e.page_size:void 0}}function Ks(e){return tu(e)}function tu(e,t){return e==null?e:{id:S(e,"id")?e.id:void 0,fileName:S(e,"file_name")?e.file_name:void 0,fileSize:S(e,"file_size")?e.file_size:void 0,contentType:S(e,"content_type")?e.content_type:void 0,createdBy:S(e,"created_by")?e.created_by:void 0,createdAt:S(e,"created_at")?new Date(e.created_at):void 0}}function iu(e){return su(e)}function su(e,t){return e==null?e:{attachments:S(e,"attachments")?e.attachments.map(Ks):void 0}}function au(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class nu extends ai{async cancellationCustomerCareRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ae("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationCustomerCareRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new ae("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationCustomerCareRequest.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:a,query:s,body:Fd(t.cancellationTicketsRequest)},i);return new Ce(o,n=>Ld(n))}async cancellationCustomerCareRequest(t,i){return await(await this.cancellationCustomerCareRequestRaw(t,i)).value()}async createCustomerCareCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ae("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createCustomerCareComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new ae("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createCustomerCareComment.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:au(t.ticketCommentsRequest)},i);return new Ce(o,n=>Jd(n))}async createCustomerCareComment(t,i){return await(await this.createCustomerCareCommentRaw(t,i)).value()}async createCustomerCareTicketRaw(t,i){if(t.customerCareTicketRequest===null||t.customerCareTicketRequest===void 0)throw new ae("customerCareTicketRequest","Required parameter requestParameters.customerCareTicketRequest was null or undefined when calling createCustomerCareTicket.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets",method:"POST",headers:a,query:s,body:Gd(t.customerCareTicketRequest)},i);return new Ce(o,n=>Ai(n))}async createCustomerCareTicket(t,i){return await(await this.createCustomerCareTicketRaw(t,i)).value()}async createCustomerCareTicketAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ae("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createCustomerCareTicketAttachment.");if(t.fileName===null||t.fileName===void 0)throw new ae("fileName","Required parameter requestParameters.fileName was null or undefined when calling createCustomerCareTicketAttachment.");if(t.body===null||t.body===void 0)throw new ae("body","Required parameter requestParameters.body was null or undefined when calling createCustomerCareTicketAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const a={};if(a["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:t.body},i);return new Ce(o,n=>Ks(n))}async createCustomerCareTicketAttachment(t,i){return await(await this.createCustomerCareTicketAttachmentRaw(t,i)).value()}async getCustomerCareCategoriesListRaw(t,i){const s={};t.site!==void 0&&(s.site=t.site),t.accountNumber!==void 0&&(s.account_number=t.accountNumber);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/categories",method:"GET",headers:a,query:s},i);return new Ce(o,n=>zd(n))}async getCustomerCareCategoriesList(t={},i){return await(await this.getCustomerCareCategoriesListRaw(t,i)).value()}async getCustomerCareTicketAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ae("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new ae("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getCustomerCareTicketAttachmentsById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new _n(o)}async getCustomerCareTicketAttachmentsById(t,i){return await(await this.getCustomerCareTicketAttachmentsByIdRaw(t,i)).value()}async getCustomerCareTicketAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ae("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketAttachmentsList.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new Ce(o,n=>iu(n))}async getCustomerCareTicketAttachmentsList(t,i){return await(await this.getCustomerCareTicketAttachmentsListRaw(t,i)).value()}async getCustomerCareTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ae("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new Ce(o,n=>Ai(n))}async getCustomerCareTicketById(t,i){return await(await this.getCustomerCareTicketByIdRaw(t,i)).value()}async getCustomerCareTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const a={},o=await this.request({path:"/customer-care-tickets",method:"GET",headers:a,query:s},i);return new Ce(o,n=>Qd(n))}async getCustomerCareTickets(t={},i){return await(await this.getCustomerCareTicketsRaw(t,i)).value()}async updateCustomerCareTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ae("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateCustomerCareTicket.");if(t.customerCareTicketUpdateRequest===null||t.customerCareTicketUpdateRequest===void 0)throw new ae("customerCareTicketUpdateRequest","Required parameter requestParameters.customerCareTicketUpdateRequest was null or undefined when calling updateCustomerCareTicket.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:Kd(t.customerCareTicketUpdateRequest)},i);return new Ce(o,n=>Ai(n))}async updateCustomerCareTicket(t,i){return await(await this.updateCustomerCareTicketRaw(t,i)).value()}}function ou(e){return ru(e)}function ru(e,t){return e==null?e:{requestType:Ge(e,"request_type")?e.request_type:void 0,categories:Ge(e,"categories")?e.categories:void 0}}function cu(e){return du(e)}function du(e,t){return e==null?e:{mappedRequestType:Ge(e,"mapped_request_type")?e.mapped_request_type:void 0,canonicalValue:Ge(e,"canonical_value")?e.canonical_value:void 0,mappedValue:Ge(e,"mapped_value")?e.mapped_value:void 0,isActive:Ge(e,"is_active")?e.is_active:void 0}}function uu(e){return lu(e)}function lu(e,t){return e==null?e:{requestType:Ge(e,"request_type")?e.request_type:void 0,categories:Ge(e,"categories")?e.categories.map(cu):void 0}}class mu extends yt{async getRequestTypesAndCategoriesRaw(t,i){if(t.serviceTicketType===null||t.serviceTicketType===void 0)throw new ut("serviceTicketType","Required parameter requestParameters.serviceTicketType was null or undefined when calling getRequestTypesAndCategories.");if(t.accountNumber===null||t.accountNumber===void 0)throw new ut("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getRequestTypesAndCategories.");if(t.site===null||t.site===void 0)throw new ut("site","Required parameter requestParameters.site was null or undefined when calling getRequestTypesAndCategories.");if(t.requestType===null||t.requestType===void 0)throw new ut("requestType","Required parameter requestParameters.requestType was null or undefined when calling getRequestTypesAndCategories.");const s={};t.serviceTicketType!==void 0&&(s.service_ticket_type=t.serviceTicketType),t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.requestType!==void 0&&(s.request_type=t.requestType);const a={},o=await this.request({path:"/categories",method:"GET",headers:a,query:s},i);return new Ti(o,n=>n.map(ou))}async getRequestTypesAndCategories(t,i){return await(await this.getRequestTypesAndCategoriesRaw(t,i)).value()}}class pu extends yt{async getRequestTypeCategoryMappingsRaw(t,i){if(t.serviceTicketType===null||t.serviceTicketType===void 0)throw new ut("serviceTicketType","Required parameter requestParameters.serviceTicketType was null or undefined when calling getRequestTypeCategoryMappings.");if(t.serviceManagementSystem===null||t.serviceManagementSystem===void 0)throw new ut("serviceManagementSystem","Required parameter requestParameters.serviceManagementSystem was null or undefined when calling getRequestTypeCategoryMappings.");const s={};t.serviceTicketType!==void 0&&(s.service_ticket_type=t.serviceTicketType),t.serviceManagementSystem!==void 0&&(s.service_management_system=t.serviceManagementSystem),t.siteCode!==void 0&&(s.site_code=t.siteCode);const a={},o=await this.request({path:"/requestTypeCategoryMappings",method:"GET",headers:a,query:s},i);return new Ti(o,n=>n.map(uu))}async getRequestTypeCategoryMappings(t,i){return await(await this.getRequestTypeCategoryMappingsRaw(t,i)).value()}}const hu={CustomerEnquiries:"customer_enquiries",RemoteHands:"remote_hands",CustomerCare:"customer_care",TroubleTickets:"trouble_tickets"};class vu extends yt{async getTermsRaw(t,i){if(t.service===null||t.service===void 0)throw new ut("service","Required parameter requestParameters.service was null or undefined when calling getTerms.");const s={},a={},o=await this.request({path:"/{service}/terms".replace("{service}",encodeURIComponent(String(t.service))),method:"GET",headers:a,query:s},i);return this.isJsonMime(o.headers.get("content-type"))?new Ti(o):new sc(o)}async getTerms(t,i){return await(await this.getTermsRaw(t,i)).value()}}const gu="https://api.digitalrealty.com".replace(/\/+$/,"");class Ys{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:gu}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Xs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const wu=new Ys;class ui{constructor(t=wu){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new Tu(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ui.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new yu(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;ku(r.body)||r.body instanceof URLSearchParams||fu(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ui.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function fu(e){return typeof Blob<"u"&&e instanceof Blob}function ku(e){return typeof FormData<"u"&&e instanceof FormData}class yu extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Tu extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}function U(e,t){return e[t]!=null}function Xs(e,t=""){return Object.keys(e).map(i=>Qs(i,e[i],t)).filter(i=>i.length>0).join("&")}function Qs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return Qs(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Xs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class bu{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Ru{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function Au(e){return _u(e)}function _u(e,t){return e==null?e:{id:U(e,"id")?e.id:void 0,name:U(e,"name")?e.name:void 0}}function Iu(e){return Su(e)}function Su(e,t){return e==null?e:{accountNumber:U(e,"account_number")?e.account_number:void 0,accountName:U(e,"account_name")?e.account_name:void 0,ticketId:U(e,"ticket_id")?e.ticket_id:void 0,ticketType:U(e,"ticket_type")?e.ticket_type:void 0,requestType:U(e,"request_type")?e.request_type:void 0,category:U(e,"category")?e.category:void 0,subject:U(e,"subject")?e.subject:void 0,sites:U(e,"sites")?e.sites.map(Au):void 0,locations:U(e,"locations")?e.locations:void 0,accessRequestedFor:U(e,"access_requested_for")?e.access_requested_for:void 0,status:U(e,"status")?e.status:void 0,cancellationReason:U(e,"cancellation_reason")?e.cancellation_reason:void 0,createdBy:U(e,"created_by")?e.created_by:void 0,createdAt:U(e,"created_at")?new Date(e.created_at):void 0,updatedAt:U(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:U(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Cu(e){return Pu(e)}function Pu(e,t){return e==null?e:{items:U(e,"items")?e.items.map(Iu):void 0,totalCount:U(e,"total_count")?e.total_count:void 0,pageNumber:U(e,"page_number")?e.page_number:void 0,pageSize:U(e,"page_size")?e.page_size:void 0}}class Nu extends ui{async downloadServiceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/service-tickets/file",method:"GET",headers:a,query:s},i);return new Ru(o)}async downloadServiceTickets(t={},i){return await(await this.downloadServiceTicketsRaw(t,i)).value()}async getServiceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/service-tickets",method:"GET",headers:a,query:s},i);return new bu(o,n=>Cu(n))}async getServiceTickets(t={},i){return await(await this.getServiceTicketsRaw(t,i)).value()}}function qu(e){return Du(e)}function Du(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0}}function Bu(e){return Ou(e)}function Ou(e,t){return e==null?e:{accountNumber:T(e,"account_number")?e.account_number:void 0,accountName:T(e,"account_name")?e.account_name:void 0,id:T(e,"id")?e.id:void 0,status:T(e,"status")?e.status:void 0,cancellationReason:T(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:T(e,"subject")?e.subject:void 0,startDate:T(e,"start_date")?new Date(e.start_date):void 0,endDate:T(e,"end_date")?new Date(e.end_date):void 0,approvalStatus:T(e,"approval_status")?e.approval_status:void 0,category:T(e,"category")?e.category:void 0,activityType:T(e,"activity_type")?e.activity_type:void 0,activitySubtype:T(e,"activity_subtype")?e.activity_subtype:void 0,activityCategory:T(e,"activity_category")?e.activity_category:void 0,site:T(e,"site")?e.site:void 0,locations:T(e,"locations")?e.locations:void 0,highLevelSummary:T(e,"high_level_summary")?e.high_level_summary:void 0,serviceType:T(e,"service_type")?e.service_type:void 0,riskLevel:T(e,"risk_level")?e.risk_level:void 0,attachments:T(e,"attachments")?e.attachments.map(qu):void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0,updatedAt:T(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:T(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function $u(e){return Eu(e)}function Eu(e,t){return e==null?e:{items:T(e,"items")?e.items.map(Bu):void 0}}function xu(e){return Fu(e)}function Fu(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0}}function Lu(e){return Vu(e)}function Vu(e,t){return e==null?e:{accountNumber:T(e,"account_number")?e.account_number:void 0,accountName:T(e,"account_name")?e.account_name:void 0,id:T(e,"id")?e.id:void 0,status:T(e,"status")?e.status:void 0,subject:T(e,"subject")?e.subject:void 0,startDate:T(e,"start_date")?new Date(e.start_date):void 0,endDate:T(e,"end_date")?new Date(e.end_date):void 0,activityType:T(e,"activity_type")?e.activity_type:void 0,site:T(e,"site")?e.site:void 0,locations:T(e,"locations")?e.locations:void 0,notificationType:T(e,"notification_type")?e.notification_type:void 0,riskLevel:T(e,"risk_level")?e.risk_level:void 0,attachments:T(e,"attachments")?e.attachments.map(xu):void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0,updatedAt:T(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:T(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Uu(e){return Hu(e)}function Hu(e,t){return e==null?e:{items:T(e,"items")?e.items.map(Lu):void 0,totalCount:T(e,"total_count")?e.total_count:void 0,pageNumber:T(e,"page_number")?e.page_number:void 0,pageSize:T(e,"page_size")?e.page_size:void 0}}function zu(e){return ju(e)}function ju(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0,fileSize:T(e,"file_size")?e.file_size:void 0,contentType:T(e,"content_type")?e.content_type:void 0,createdBy:T(e,"created_by")?e.created_by:void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0}}function Mu(e){return Ju(e)}function Ju(e,t){return e==null?e:{attachments:T(e,"attachments")?e.attachments.map(zu):void 0}}class Wu extends oi{async downloadPlannedMaintenanceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/file",method:"GET",headers:a,query:s},i);return new Bs(o)}async downloadPlannedMaintenanceTickets(t={},i){return await(await this.downloadPlannedMaintenanceTicketsRaw(t,i)).value()}async getPlannedMaintenanceAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new Zt("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPlannedMaintenanceAttachmentsById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new Bs(o)}async getPlannedMaintenanceAttachmentsById(t,i){return await(await this.getPlannedMaintenanceAttachmentsByIdRaw(t,i)).value()}async getPlannedMaintenanceAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceAttachmentsList.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new Ri(o,n=>Mu(n))}async getPlannedMaintenanceAttachmentsList(t,i){return await(await this.getPlannedMaintenanceAttachmentsListRaw(t,i)).value()}async getPlannedMaintenanceTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceTicketById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new Ri(o,n=>$u(n))}async getPlannedMaintenanceTicketById(t,i){return await(await this.getPlannedMaintenanceTicketByIdRaw(t,i)).value()}async getPlannedMaintenanceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const a={},o=await this.request({path:"/planned-maintenances",method:"GET",headers:a,query:s},i);return new Ri(o,n=>Uu(n))}async getPlannedMaintenanceTickets(t={},i){return await(await this.getPlannedMaintenanceTicketsRaw(t,i)).value()}}function Gu(e){return Zu(e)}function Zu(e,t){return e==null?e:{en:Ne(e,"en")?e.en:void 0,fr:Ne(e,"fr")?e.fr:void 0,de:Ne(e,"de")?e.de:void 0,es:Ne(e,"es")?e.es:void 0}}function Ku(e){return Yu(e)}function Yu(e,t){return e}function Xu(e){return Qu(e)}function Qu(e,t){return e}const _i={ServiceNow:"ServiceNow",InSite:"InSite",TelxSfdc:"TelxSFDC"};function el(e){return tl(e)}function tl(e,t){return e}function il(e){return sl(e)}function sl(e,t){return e==null?e:{process:Ne(e,"process")?Xu(e.process):void 0,site:Ne(e,"site")?e.site:void 0,serviceManagementSystem:Ne(e,"serviceManagementSystem")?el(e.serviceManagementSystem):void 0,destinationUrls:Ne(e,"destinationUrls")?Gu(e.destinationUrls):void 0,portal:Ne(e,"portal")?Ku(e.portal):void 0}}class al extends ci{async getSiteNavigationRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new Us("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getSiteNavigation.");if(t.site===null||t.site===void 0)throw new Us("site","Required parameter requestParameters.site was null or undefined when calling getSiteNavigation.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.process!==void 0&&(s.process=t.process);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("bearerToken",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/site-configurations",method:"GET",headers:a,query:s},i);return new qd(o,n=>n.map(il))}async getSiteNavigation(t,i){return await(await this.getSiteNavigationRaw(t,i)).value()}}const nl="http://localhost".replace(/\/+$/,"");class ea{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:nl}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||ta}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ol=new ea;class li{constructor(t=ol){this.configuration=t,this.fetchApi=async(i,s)=>{let a={url:i,init:s};for(const n of this.middleware)n.pre&&(a=await n.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(n){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:n,response:o?o.clone():void 0})||o);if(o===void 0)throw n instanceof Error?new ul(n,"The request failed and the interceptors did not return an alternative response"):n}for(const n of this.middleware)n.post&&(o=await n.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?li.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:a}=await this.createFetchParams(t,i),o=await this.fetchApi(s,a);if(o&&o.status>=200&&o.status<300)return o;throw new dl(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(p=>a[p]===void 0?delete a[p]:{});const o=typeof i=="function"?i:async()=>i,n={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},r={...n,...await o({init:n,context:t})};let d;cl(r.body)||r.body instanceof URLSearchParams||rl(r.body)?d=r.body:this.isJsonMime(a["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}li.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function rl(e){return typeof Blob<"u"&&e instanceof Blob}function cl(e){return typeof FormData<"u"&&e instanceof FormData}class dl extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class ul extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class te extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function R(e,t){return e[t]!=null}function ta(e,t=""){return Object.keys(e).map(i=>ia(i,e[i],t)).filter(i=>i.length>0).join("&")}function ia(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${a}`}if(t instanceof Set){const a=Array.from(t);return ia(e,a,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?ta(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class qe{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class ll{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function ml(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function pl(e){return hl(e)}function hl(e,t){return e==null?e:{message:R(e,"message")?e.message:void 0}}function vl(e){return gl(e)}function gl(e,t){return e==null?e:{requestType:R(e,"request_type")?e.request_type:void 0,categories:R(e,"categories")?e.categories:void 0}}function wl(e){return fl(e)}function fl(e,t){return e==null?e:{items:R(e,"items")?e.items.map(vl):void 0}}function sa(e){return kl(e)}function kl(e,t){return e==null?e:{createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,comment:R(e,"comment")?e.comment:void 0}}function yl(e){return Tl(e)}function Tl(e,t){return e==null?e:{comments:R(e,"comments")?e.comments.map(sa):void 0}}function aa(e){return bl(e)}function bl(e,t){return e==null?e:{id:R(e,"id")?e.id:void 0,fileName:R(e,"file_name")?e.file_name:void 0,fileSize:R(e,"file_size")?e.file_size:void 0,contentType:R(e,"content_type")?e.content_type:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0}}function Rl(e){return Al(e)}function Al(e,t){return e==null?e:{attachments:R(e,"attachments")?e.attachments.map(aa):void 0}}function _l(e){if(e!==void 0)return e===null?null:{comment:e.comment}}function Il(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,request_type:e.requestType,category:e.category,locations:e.locations,circuit_id:e.circuitId,customer_reference:e.customerReference,description:e.description,notification_recipients:e.notificationRecipients}}function Ii(e){return Sl(e)}function Sl(e,t){return e==null?e:{ticketNumber:R(e,"ticket_number")?e.ticket_number:void 0,accountNumber:R(e,"account_number")?e.account_number:void 0,accountName:R(e,"account_name")?e.account_name:void 0,id:R(e,"id")?e.id:void 0,status:R(e,"status")?e.status:void 0,cancellationReason:R(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:R(e,"subject")?e.subject:void 0,requestType:R(e,"request_type")?e.request_type:void 0,category:R(e,"category")?e.category:void 0,site:R(e,"site")?e.site:void 0,locations:R(e,"locations")?e.locations:void 0,circuitId:R(e,"circuit_id")?e.circuit_id:void 0,customerReference:R(e,"customer_reference")?e.customer_reference:void 0,description:R(e,"description")?e.description:void 0,notificationRecipients:R(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,updatedAt:R(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:R(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:R(e,"comments")?e.comments.map(sa):void 0}}function Cl(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,circuit_id:e.circuitId,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Pl(e){return Nl(e)}function Nl(e,t){return e==null?e:{accountNumber:R(e,"account_number")?e.account_number:void 0,accountName:R(e,"account_name")?e.account_name:void 0,id:R(e,"id")?e.id:void 0,status:R(e,"status")?e.status:void 0,subject:R(e,"subject")?e.subject:void 0,site:R(e,"site")?e.site:void 0,locations:R(e,"locations")?e.locations:void 0,description:R(e,"description")?e.description:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,updatedAt:R(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:R(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function ql(e){return Dl(e)}function Dl(e,t){return e==null?e:{items:R(e,"items")?e.items.map(Pl):void 0,totalCount:R(e,"total_count")?e.total_count:void 0,pageNumber:R(e,"page_number")?e.page_number:void 0,pageSize:R(e,"page_size")?e.page_size:void 0}}class Bl extends li{async cancellationTroubleTicketRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationTroubleTicketRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new te("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationTroubleTicketRequest.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:a,query:s,body:ml(t.cancellationTicketsRequest)},i);return new qe(o,n=>pl(n))}async cancellationTroubleTicketRequest(t,i){return await(await this.cancellationTroubleTicketRequestRaw(t,i)).value()}async createTroubleTicketAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createTroubleTicketAttachment.");if(t.fileName===null||t.fileName===void 0)throw new te("fileName","Required parameter requestParameters.fileName was null or undefined when calling createTroubleTicketAttachment.");if(t.body===null||t.body===void 0)throw new te("body","Required parameter requestParameters.body was null or undefined when calling createTroubleTicketAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const a={};if(a["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:t.body},i);return new qe(o,n=>aa(n))}async createTroubleTicketAttachment(t,i){return await(await this.createTroubleTicketAttachmentRaw(t,i)).value()}async createTroubleTicketCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createTroubleTicketComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new te("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createTroubleTicketComment.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:a,query:s,body:_l(t.ticketCommentsRequest)},i);return new qe(o,n=>yl(n))}async createTroubleTicketComment(t,i){return await(await this.createTroubleTicketCommentRaw(t,i)).value()}async createTroubleTicketTicketRaw(t,i){if(t.troubleTicketRequest===null||t.troubleTicketRequest===void 0)throw new te("troubleTicketRequest","Required parameter requestParameters.troubleTicketRequest was null or undefined when calling createTroubleTicketTicket.");const s={},a={};if(a["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets",method:"POST",headers:a,query:s,body:Il(t.troubleTicketRequest)},i);return new qe(o,n=>Ii(n))}async createTroubleTicketTicket(t,i){return await(await this.createTroubleTicketTicketRaw(t,i)).value()}async getTroubleTicketAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new te("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getTroubleTicketAttachmentsById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:a,query:s},i);return new ll(o)}async getTroubleTicketAttachmentsById(t,i){return await(await this.getTroubleTicketAttachmentsByIdRaw(t,i)).value()}async getTroubleTicketAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketAttachmentsList.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new qe(o,n=>Rl(n))}async getTroubleTicketAttachmentsList(t,i){return await(await this.getTroubleTicketAttachmentsListRaw(t,i)).value()}async getTroubleTicketTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketTicketById.");const s={},a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:a,query:s},i);return new qe(o,n=>Ii(n))}async getTroubleTicketTicketById(t,i){return await(await this.getTroubleTicketTicketByIdRaw(t,i)).value()}async getTroubleTicketTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const a={},o=await this.request({path:"/trouble-tickets",method:"GET",headers:a,query:s},i);return new qe(o,n=>ql(n))}async getTroubleTicketTickets(t={},i){return await(await this.getTroubleTicketTicketsRaw(t,i)).value()}async getTroubleTicketsCategoriesListRaw(t,i){if(t.site===null||t.site===void 0)throw new te("site","Required parameter requestParameters.site was null or undefined when calling getTroubleTicketsCategoriesList.");const s={};t.site!==void 0&&(s.site=t.site);const a={};if(this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/categories",method:"GET",headers:a,query:s},i);return new qe(o,n=>wl(n))}async getTroubleTicketsCategoriesList(t,i){return await(await this.getTroubleTicketsCategoriesListRaw(t,i)).value()}async updateTroubleTicketTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateTroubleTicketTicket.");if(t.troubleTicketUpdateRequest===null||t.troubleTicketUpdateRequest===void 0)throw new te("troubleTicketUpdateRequest","Required parameter requestParameters.troubleTicketUpdateRequest was null or undefined when calling updateTroubleTicketTicket.");const s={},a={};if(a["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const n=this.configuration.accessToken,r=await n("BearerAuth",[]);r&&(a.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:a,query:s,body:Cl(t.troubleTicketUpdateRequest)},i);return new qe(o,n=>Ii(n))}async updateTroubleTicketTicket(t,i){return await(await this.updateTroubleTicketTicketRaw(t,i)).value()}}function Ol(e){return $l(e)}function $l(e,t){return e==null?e:{id:e.id,name:e.name,isNonLocation:e.is_non_location,category:Ms(e,"category")?e.category:void 0,privileges:e.privileges,isInternal:e.is_internal}}function El(e){return xl(e)}function xl(e,t){return e==null?e:{accountNumber:e.account_number,permissionName:e.permission_name,privilege:e.privilege,isNonLocation:Ms(e,"is_non_location")?e.is_non_location:void 0,permissionIsInternal:e.permission_is_internal}}class Fl extends di{async getPermissionsRaw(t){const i={},s={};this.configuration&&this.configuration.accessToken&&(s.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/permissions",method:"GET",headers:s,query:i},t);return new Gs(a,o=>o.map(Ol))}async getPermissions(t){return await(await this.getPermissionsRaw(t)).value()}async getUserPermissionsRaw(t,i){const s={};t.excludeSiblings!==void 0&&(s.exclude_siblings=t.excludeSiblings),t.excludeParents!==void 0&&(s.exclude_parents=t.excludeParents);const a={};this.configuration&&this.configuration.accessToken&&(a.Authorization=await this.configuration.accessToken("oAuth2",[]));const o=await this.request({path:"/my-permissions",method:"GET",headers:a,query:s},i);return new Gs(o,n=>n.map(El))}async getUserPermissions(t={},i){return await(await this.getUserPermissionsRaw(t,i)).value()}}const z={CustomerCare:"sm-customer-care",DeliveriesRemovals:"sm-deliveries",References:"sm-references",RemoteHands:"sm-remote-hands",TroubleTickets:"sm-trouble-tickets",FacilityAccess:"sm-facility-access",ServiceTickets:"sm-service-tickets",SiteMaintenance:"sm-site-maintenance",Incidents:"sm-incidents",Inventory:"inventory",SiteNavigation:"site-navigations",UserManagement:"usermanagement"},F={Site:"Site",Floor:"Floor",Room:"Room",Cabinet:"Cabinet",Cage:"Cage"},L={Read:"Read",Update:"Update",Delete:"Delete",Create:"Create",Approve:"Approve"},Ll={READ:1,UPDATE:2,DELETE:4,CREATE:8,APPROVE:16};var Si;(function(e){e.Security="Security",e.DCIM="DCIM",e.PlannedSiteMaintenance="Planned Site Maintenance"})(Si||(Si={}));const A={RemoteHands:"Remote Hands",TroubleTickets:"Trouble Ticket",DeliveriesRemovals:"Shipping & Receiving",VisitorAccess:"Visitor Access",CustomerCare:"Customer Support",PermanentBadge:"Permanent Badge",OSPAccess:"OSP Access",POPPOEAccess:"POP/POE Room Access",PlannedMaintenance:"Planned Site Maintenance"},Vl={Duplicate:"Duplicate request",Error:"Request entered in error",NotNeeded:"Request no longer needed"},Ul={Delivery:"Delivery",Removal:"Removal",TroubleTicket:"Trouble Ticket",FacilityAccess:"Facility Access",RemoteHands:"Remote Hands",VisitorAccess:"Visitor Access",PermanentBadge:"Permanent Badge"},lt={GreaterThan:"gt:",GreaterOrEqual:"ge:",LessThan:"lt:",LessThanOrEqual:"le:"},Hl=10,zl="permission_privilege";class jl{constructor(t){this.configuration=t}get customerCareApi(){return new nu(new Gi({basePath:`${this.configuration.SMApiUrl}/${z.CustomerCare}`,headers:{Authorization:this.getAuthorization()}}))}get courierCompaniesApi(){return new qn(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get deliveriesApi(){return new eo(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get removalsApi(){return new to(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get remoteHandsApi(){return new Dc(new Rs({basePath:`${this.configuration.SMApiUrl}/${z.RemoteHands}`,headers:{Authorization:this.getAuthorization()}}))}get troubleTicketsApi(){return new Bl(new ea({basePath:`${this.configuration.SMApiUrl}/${z.TroubleTickets}`,headers:{Authorization:this.getAuthorization()}}))}get facilityAccessApi(){return{visitorAccess:new zr(new ht({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),visitorHost:new jr(new ht({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),permanentBadgeAccess:new Hr(new ht({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),ospAccess:new Vr(new ht({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),popAccess:new Ur(new ht({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}}))}}get serviceTicketApi(){return new Nu(new Ys({basePath:`${this.configuration.SMApiUrl}/${z.ServiceTickets}`,headers:{Authorization:this.getAuthorization()}}))}get inventoryApi(){return{locations:new Kc(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}})),sites:new Ps(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}}))}}get sitesApi(){return new Ps(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}}))}get siteNavigationApi(){return new al(new Vs({basePath:`${this.configuration.SMApiUrl}/${z.SiteNavigation}`,headers:{Authorization:this.getAuthorization()}}))}get plannedMaintenanceApi(){return new Wu(new Ns({basePath:`${this.configuration.SMApiUrl}/${z.SiteMaintenance}`,headers:{Authorization:this.getAuthorization()}}))}get incidentsApi(){return new Ad(new Os({basePath:`${this.configuration.SMApiUrl}/${z.Incidents}`,headers:{Authorization:this.getAuthorization()}}))}get userPermissionsApi(){return new Fl(new js({basePath:`${this.configuration.SMApiUrl}/${z.UserManagement}`,headers:{Authorization:this.getAuthorization()}}))}getAuthorizationToken(){return this.getAuthorization()}get referencesApi(){return{categories:new mu(new Gt({basePath:`${this.configuration.SMApiUrl}/${z.References}`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}})),requestTypeCategoryMappings:new pu(new Gt({basePath:`${this.configuration.SMApiUrl}/${z.References}`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}})),terms:new vu(new Gt({basePath:`${this.configuration.SMApiUrl}/sm-references`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}}))}}getAuthorization(){return this.configuration.getAuthorizationFn?this.configuration.getAuthorizationFn():""}}class Ml extends rn{constructor(t,i){super({...t}),this.hashed_identifier=i}}class Jl{constructor(t,i){this.name=t,this.accountNumber=i}}class et{constructor({loginAuthority:t,clientId:i,scope:s,postLogoutRedirectUri:a,userStorageKey:o="user-authentication",redirectUrlKey:n="redirect-url",authPaths:r={authenticate:"authenticate",authCallback:"auth-callback",logout:"logout"}}){this.getHashedRootAccountNumberAndUserEmail=async()=>{const _=rt.getAccountHierarchy(),P=await et.hashValue(rt===null||rt===void 0?void 0:rt.email);let b=await et.hashValue(rt===null||rt===void 0?void 0:rt.account_number);return _&&(b=await et.hashValue(_==null?void 0:_.accountNumber)),`${b}-${P}`},this.configuration={loginAuthority:t,clientId:i,scope:s,postLogoutRedirectUri:a,userStorageKey:o,redirectUrlKey:n,authPaths:r};const{location:d}=window,u=`${d.protocol}//${d.hostname}${d.port?`:${d.port}`:""}`,p={authority:this.configuration.loginAuthority,client_id:this.configuration.clientId,redirect_uri:`${u}/${this.configuration.authPaths.authCallback}`,response_type:"code",scope:this.configuration.scope,post_logout_redirect_uri:this.configuration.postLogoutRedirectUri,loadUserInfo:!0};this.userManager=new cn(p)}isLoggedIn(){const t=this.getUser();if(t===null)return!1;if(!t.expires_at)return!0;const i=new Date,s=new Date(t.expires_at*1e3);return i<s}redirectToAuth(t=!1){const i=this.isAuthenticating();(t||!i)&&(i||localStorage.setItem(this.configuration.redirectUrlKey,window.location.href),ct.go(`/${this.configuration.authPaths.authenticate}`))}isAuthenticating(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authenticate?(this.userManager.signinRedirect(),!0):!1}isHandlingAuthCallback(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authCallback?(this.userManager.signinRedirectCallback().then(et.ensureValidUser).then(et.addHashedIdToUserProfile).then(i=>this.saveUser(i)).then(()=>this.authSuccessRedirect()).catch(()=>this.redirectToAuth()),!0):!1}authSuccessRedirect(){let t="/";const i=localStorage.getItem(this.configuration.redirectUrlKey);i&&(localStorage.removeItem(this.configuration.redirectUrlKey),t=i),ct.go(t)}redirectToLogout(){this.isHandlingLogout()||ct.go(`/${this.configuration.authPaths.logout}`)}isHandlingLogout(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.logout?(this.clearUser(),window.localStorage.clear(),this.userManager.signoutRedirect({id_token_hint:this.getIdToken()}),!0):!1}isProcessing(){return this.isAuthenticating()||this.isHandlingAuthCallback()||this.isHandlingLogout()}saveUser(t){localStorage.setItem(this.configuration.userStorageKey,JSON.stringify(t))}clearUser(){localStorage.removeItem(this.configuration.userStorageKey)}getUser(){const t=localStorage.getItem(this.configuration.userStorageKey);return t?JSON.parse(t):null}getUserProfileSub(){var t;const i=this.getUser();return(t=i==null?void 0:i.profile)===null||t===void 0?void 0:t.sub}getUserLocale(){var t;const i=this.getUser();return(t=i==null?void 0:i.profile)===null||t===void 0?void 0:t.locale}getHashedIdentifer(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.hashed_identifier}getIdToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.id_token}getAccessToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.access_token}getAuthorization(){var t,i;return`${(t=this.getUser())===null||t===void 0?void 0:t.token_type} ${(i=this.getUser())===null||i===void 0?void 0:i.access_token}`}getUserAccount(){var t,i,s,a;return new Jl((i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.account_name,(a=(s=this.getUser())===null||s===void 0?void 0:s.profile)===null||a===void 0?void 0:a.account_number)}getUserEmail(){var t,i;return(i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.email}getAccountNumber(){var t,i;return(i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.account_number}static async hashValue(t){const i=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(s)).map(a=>a.toString(16).padStart(2,"0")).join("")}static async addHashedIdToUserProfile(t){const i=`${t.profile.sub}-${t.profile.customer_id}`,s=await et.hashValue(i);return new Ml(t,s)}static ensureValidUser(t){if(!t.id_token)throw new Error("Missing property:id_token");return t}}function De(){var e;const t=(e=window.gpConfig)===null||e===void 0?void 0:e["ui-service-management"];if(!t)throw new Error("ui-service-management config not loaded. Ensure config.json is fetched before app bootstrap.");return t}const Yt=De(),ne=new et({loginAuthority:Yt.LoginAuthority,clientId:Yt.ServiceManagementUIClientId,scope:Yt.ServiceManagementUIScopes}),m=new jl({SMApiUrl:Yt.SMApiUrl,getAuthorizationFn:()=>`Bearer ${ne.getAccessToken()}`}),na="no instructions provided",Ci=" [Special Instructions] ",wt="Other",oa="Digital Realty",Wl="Interxion",ra=5;class Gl{constructor(){this.couriers={},this.sites=[],this.removalParties=[],this.requestTypeCategoriesDict={},this.termsLookup={[Q.Deliveries]:"",[Q.FacilityAccess]:"",[Q.TroubleTickets]:"",[Q.RemoteHands]:""},se(this),Je(this,{name:"lookups",properties:["couriers","sites","removalParties","requestTypeCategoriesDict","termsLookup"],storage:window.sessionStorage})}getCouriers(t,i){var s;const a=(s=this.couriers[t])!==null&&s!==void 0?s:[];return i?[...a,wt]:a}async fillCouriers(t,i,s){!t||!i||!s||this.couriers[s]||(this.couriers[s]=await m.courierCompaniesApi.getCourierBySite({accountNumber:i,site:t}))}async fillSites(){const t={pageSize:1e3};this.sites=await Wi(t,i=>m.inventoryApi.sites.getSites(i))}async getRequestCategories(t,i,s){const a=`${t}-${i}`;if(this.requestTypeCategoriesDict[a]&&!s)return this.requestTypeCategoriesDict[a];const o=(await m.referencesApi.requestTypeCategoryMappings.getRequestTypeCategoryMappings({serviceTicketType:i,serviceManagementSystem:t,siteCode:s})).filter(n=>{var r;return(r=n.categories)===null||r===void 0?void 0:r.some(d=>d.isActive)});return this.requestTypeCategoriesDict[a]=Object.fromEntries(o.map(n=>{var r;return[n.requestType,(r=n.categories)===null||r===void 0?void 0:r.filter(d=>d.isActive).map(d=>d.canonicalValue)]})),this.requestTypeCategoriesDict[a]}async fillRemovalParties(){this.removalParties=await m.removalsApi.getRemovalParties()}async fillLookups(){await Promise.all([this.fillRemovalParties(),this.fillTerms(),this.fillSites()])}async fillTerms(){const t=async i=>{await m.referencesApi.terms.getTerms({service:i}).then(s=>{this.termsLookup[i]=s})};await Promise.all([t(Q.Deliveries),t(Q.TroubleTickets),t(Q.RemoteHands),t(Q.FacilityAccess)])}clear(){this.couriers={},this.sites=[],this.removalParties=[],this.requestTypeCategoriesDict={},this.termsLookup={[Q.Deliveries]:"",[Q.FacilityAccess]:"",[Q.TroubleTickets]:"",[Q.RemoteHands]:""}}}const J=new Gl;function St(e){return new Date(e).toISOString().split("T")[0]}const ca=()=>{var e;const t=localStorage.getItem("date-format");return t&&((e=JSON.parse(t))===null||e===void 0?void 0:e.preferredTimezone)||he.tz.guess()},Be=(e,t,i)=>{var s,a;if(!e||!t)return;const o=`${e} ${t}`,n=(a=(s=J.sites)===null||s===void 0?void 0:s.find(r=>r.id===i))===null||a===void 0?void 0:a.timeZone;return(n?he.tz(o,n):he.utc(o)).utc().toDate()};function Zl(e,t=ca()){const i=he.tz(e,t).startOf("day").toDate(),s=he.tz(e,t).endOf("day").toDate();return{startOfDayLocal:i,endOfDayLocal:s}}const Kl=()=>he.utc().tz(ca()).startOf("day").format("YYYY-MM-DD"),Yl=(e,t)=>(t?he.tz(t):he.utc()).add(e,"days").format("YYYY-MM-DD"),Z=e=>{if(e)return new Date(e)},Xl=()=>{var e;const t=localStorage.getItem("date-format");return t&&((e=JSON.parse(t))===null||e===void 0?void 0:e.preferredDateFormat)||"yyyy-MM-dd"};St(new Date);const Ql=bt`.header-container{display:flex;align-items:center;gap:20px}.header__title{margin:0;font-family:var(--root-secondary-font);font-style:normal;font-weight:700;font-size:34px;line-height:40px;letter-spacing:.35px;color:#092241;flex-grow:1}.header__profile{background-color:#092241;height:35px;border-radius:10px;color:#fff;padding-left:20px;padding-right:20px;display:flex;align-items:center;font-size:14px}.header__logout{height:35px;border-radius:10px;border:none;background-color:#1456e0;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding-left:15px;padding-right:15px}.header__logout svg{width:1em;height:1em;font-size:20px;margin-right:5px}.header__accounts{width:200px;--md-outlined-field-top-space:5px;--md-outlined-field-bottom-space:5px}@media only screen and (min-width:5px) and (max-width:500px){.header-container{flex-direction:column}}@media only screen and (min-width:500px) and (max-width:1250px){.header-container{flex-direction:row}}`,V={ErrorRaised:"sm:error-raised",DrawerClose:"drawer-close",CreateTicket:"create-ticket",CancelTicket:"cancel-ticket",EditTicket:"edit-ticket",ApproveDenyTicket:"approve-deny-ticket"};class Oe{constructor(t,i,s){var a,o;this.id=t,this.siteId=i,this.accountNumber=s;const n=J.sites.find(r=>r.id===this.siteId);n?this.displayName=`${n==null?void 0:n.name} - ${n==null?void 0:n.streetAddress}`:this.displayName=(o=(a=this.id)!==null&&a!==void 0?a:this.siteId)!==null&&o!==void 0?o:""}}async function em(e){if(!e)return"";const t=J.sites.find(i=>i.locationId===e);return t?`${t.name} - ${t.streetAddress}`:e}async function tm(e){if(!e)return"";const t=J.sites.find(i=>i.id===e);return t?`${t.name} - ${t.streetAddress}`:e}async function im(e){const t=J.sites.find(i=>i.id===e);return t==null?void 0:t.locationId}const da=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))},sm=e=>da(document,V.ErrorRaised,e),l=async(e,t=!0)=>{let i="An error occurred";if(e instanceof Yi&&e.response.status===400)try{const{detail:s}=await e.response.json();i=s}catch(s){console.error(e)}else console.error(e);t&&sm(i)},am=e=>{window.dispatchEvent(new CustomEvent("add-toast",{detail:{id:"error-toast",content:g`<ix-message-toast forceClose="false" toastId="error-toast" type="error">${e} </ix-message-toast>`,vertical:"bottom",horizontal:"center",animated:!0,above:!1}}))};class nm{constructor(){se(this),Je(this,{name:"locations",properties:[],storage:window.localStorage})}async getLocations(t,i){var s;let a=[],o={...t,sort:t.sort||"+id"};const n=r=>m.inventoryApi.locations.getLocations(r).catch(d=>{l(d,!1)});if(i!=null&&i.onlyLoadFirstPage){const r=await n(o);a=(s=r==null?void 0:r.items)!==null&&s!==void 0?s:[]}else a=await Wi(o,n);return a.sort((r,d)=>r.id.localeCompare(d.id))}async getOspsBySiteId(t){try{const i=await m.inventoryApi.sites.getOspsBySiteId({siteId:t});return i!=null?i:[]}catch(i){return[]}}async getPopsBySiteId(t){try{const i=await m.inventoryApi.sites.getPopsBySiteId({siteId:t});return i!=null?i:[]}catch(i){return[]}}}const oe=new nm;class om{constructor(){this.isHideLocationDatesEnabled=()=>{const t=De()["SM:HideLocationDates"];return typeof t=="boolean"?t:!1},this.showNewDatePickerComponent=()=>{const t=De()["SM:UseNewDatePicker"];return typeof t=="boolean"?t:!1},this.isOspEnabled=()=>{const t=De()["SM:ShowOspAccess"];return typeof t=="boolean"?t:!1},this.isPopPoeEnabled=()=>{const t=De()["SM:ShowPopPoeAccess"];return typeof t=="boolean"?t:!1},this.isIncidentsEnabled=()=>{const t=De()["SM:IncidentsEnabled"];return typeof t=="boolean"?t:!1}}}const Ze=new om,Ct=`${F.Floor},${F.Room},${F.Cabinet},${F.Cage}`;function ua(e){return e===A.VisitorAccess||e===A.PermanentBadge}function rm(e){return e===A.RemoteHands||e===A.TroubleTickets||e===A.VisitorAccess||e===A.PermanentBadge||e===A.CustomerCare||e===A.OSPAccess||e===A.POPPOEAccess}async function Ke(e){var t;const i=await oe.getLocations({...e,pageSize:100});return(t=[...new Map(i.map(s=>[s.siteId,s])).values()].map(s=>new Oe(void 0,s.siteId,s.accountNumber)))!==null&&t!==void 0?t:[]}async function cm(e,t,i,s){let a=[];const o=rm(t);let n=lt.GreaterThan+F.Site;o?ua(t)&&(n=Ct):n=F.Site;let r=await oe.getLocations({locationType:n,permissionType:t,permissionPrivilege:e,pageSize:100,accountNumber:s,assignableProcess:i});return o?(r=[...new Map(r.map(d=>[d.siteId,d])).values()],a=r.map(d=>new Oe(d.siteId,d.siteId,d.accountNumber))):a=r.map(d=>new Oe(d.id,d.siteId,d.accountNumber)),a!=null?a:[]}async function dm(e,t){const i=await oe.getLocations({locationType:F.Site,permissionType:t,permissionPrivilege:e,pageSize:100}),s=[...new Set(i.map(a=>a.accountNumber))];return s!=null?s:[]}async function um(e,t,i,s,a){let o=lt.GreaterThan+F.Site;return ua(t)&&(o=Ct),await oe.getLocations({permissionType:t,locationType:o,permissionPrivilege:e,siteId:s,pageSize:100,accountNumber:a,assignableProcess:i})}async function Pt(e,t,i,s){const a=await oe.getLocations({permissionType:t,permissionPrivilege:e,id:i,accountNumber:s,pageSize:1},{onlyLoadFirstPage:!0});return(a==null?void 0:a.length)>0}async function $e(e,t,i,s){return(await oe.getLocations({permissionPrivilege:t,pageSize:1,permissionType:e,assignableProcess:i,locationType:s},{onlyLoadFirstPage:!0})).length>0}async function Ye(e,t,i){return(await oe.getLocations({permissionPrivilege:i,pageSize:100,permissionType:t})).some(s=>e.includes(s.id))}async function la(e){var t;if(!e)return;const i=await oe.getLocations({id:e,pageSize:1},{onlyLoadFirstPage:!0});return(t=i==null?void 0:i[0])===null||t===void 0?void 0:t.siteId}async function lm(e){var t;if(!e)return;const i=await oe.getLocations({siteId:e,locationType:F.Site,pageSize:1},{onlyLoadFirstPage:!0});return(t=i==null?void 0:i[0])===null||t===void 0?void 0:t.id}async function mm(){return $e(A.CustomerCare,L.Create,void 0,F.Site)}async function ma(){return $e(A.VisitorAccess,L.Create,void 0,F.Site)}async function pa(){return $e(A.PermanentBadge,L.Create,void 0,F.Site)}async function ha(){return Ze.isOspEnabled()?$e(A.OSPAccess,L.Create,void 0,F.Site):!1}async function va(){return Ze.isPopPoeEnabled()?$e(A.POPPOEAccess,L.Create,void 0,F.Site):!1}async function pm(){return $e(A.DeliveriesRemovals,L.Create)}async function hm(){return(await Promise.all([ma(),pa(),ha(),va()])).some(e=>e)}async function vm(){return $e(A.RemoteHands,L.Create,void 0,F.Site)}async function ga(){return pm()}function gm(){return $e(A.TroubleTickets,L.Create,void 0,F.Site)}async function wm(){return(await Promise.all([mm(),hm(),vm(),ga(),gm()])).some(e=>e)}async function fm(){const e=await oe.getLocations({pageSize:1e3,permissionPrivilege:L.Create,locationType:F.Site,embed:"permissions"}),t={hasCustomerCareCreatePermission:!1,hasFacilityAccessCreatePermission:!1,hasRemoteHandsCreatePermission:!1,hasDeliveriesAndRemovalsCreatePermission:!1,hasTroubleTicketsCreatePermission:!1,hasVisitorAccessCreatePermission:!1,hasPermanentBadgeCreatePermission:!1,hasOspAccessCreatePermission:!1,hasPopPoeAccessCreatePermission:!1};for(const i of e)if(i.permissions&&Array.isArray(i.permissions)){for(const s of i.permissions)if(s.privilegeLevel===L.Create||s.privilegeLevel===L.Approve)switch(s.name){case A.CustomerCare:t.hasCustomerCareCreatePermission=!0;break;case A.RemoteHands:t.hasRemoteHandsCreatePermission=!0;break;case A.DeliveriesRemovals:t.hasDeliveriesAndRemovalsCreatePermission=!0;break;case A.TroubleTickets:t.hasTroubleTicketsCreatePermission=!0;break;case A.VisitorAccess:t.hasVisitorAccessCreatePermission=!0;break;case A.PermanentBadge:t.hasPermanentBadgeCreatePermission=!0;break;case A.OSPAccess:t.hasOspAccessCreatePermission=Ze.isOspEnabled();break;case A.POPPOEAccess:t.hasPopPoeAccessCreatePermission=Ze.isPopPoeEnabled();break}}return t.hasFacilityAccessCreatePermission=t.hasVisitorAccessCreatePermission||t.hasPermanentBadgeCreatePermission||t.hasOspAccessCreatePermission||t.hasPopPoeAccessCreatePermission,t}function km(e){switch(e){case"Visitor Access":return A.VisitorAccess;case"Permanent Badge":return A.PermanentBadge;case"OSP Access":return A.OSPAccess;case"PoP/POE Access":return A.POPPOEAccess;default:return}}async function wa(e){if(e===void 0)return!1;const t=await la(e);return t?(await oe.getLocations({siteId:t,permissionType:A.OSPAccess,locationType:lt.GreaterOrEqual+F.Site,permissionPrivilege:L.Update,pageSize:100,assignableProcess:"OSP_access"})).some(i=>i.siteId===t):!1}async function fa(e){if(e===void 0)return!1;const t=await la(e);return t?(await oe.getLocations({siteId:t,permissionType:A.POPPOEAccess,locationType:lt.GreaterOrEqual+F.Site,permissionPrivilege:L.Update,pageSize:100,assignableProcess:"POP_access"})).some(i=>i.siteId===t):!1}async function ka(e){return oe.getOspsBySiteId(e)}async function ya(e){return oe.getPopsBySiteId(e)}let Pi=class extends Rt{constructor(){super(...arguments),this.hasCreatePermission=!1}dispatchCreateTicketEvent(){const e=new CustomEvent(V.CreateTicket,{bubbles:!0,composed:!0});this.dispatchEvent(e)}async firstUpdated(){this.hasCreatePermission=await wm()}render(){return this.hasCreatePermission?g` <ix-button @click="${this.dispatchCreateTicketEvent}" has-icon> <md-icon slot="icon">add</md-icon> <span class="uppercase font-bold tracking-wider">Create Ticket</span> </ix-button>`:N}};E([we()],Pi.prototype,"hasCreatePermission",void 0),Pi=E([X("sm-create-service-ticket-button")],Pi);let _e=null;function Ta(){const{pathname:e,search:t,hash:i}=window.location;ct.go({pathname:e,search:t,hash:i})}function ym(e,t,i){const s=i.map(a=>({...a,path:`${t}${a.path}`,redirect:a.redirect?`${t}${a.redirect}`:null}));s.push({name:W.ServiceTickets,path:t||"/",component:"service-tickets-view",headerRight:g`<sm-create-service-ticket-button></sm-create-service-ticket-button>`,action:()=>{import("./ui-service-management2.js")}}),s.push({path:"(.*)",component:"service-tickets-view",action:()=>{import("./ui-service-management2.js")}}),_e=new ct(e),_e.setRoutes(s),window.addEventListener("shell-after-navigate",Ta)}function Tm(){return _e}function bm(){_e==null||_e.unsubscribe(),_e==null||_e.removeRoutes(),_e=null,window.removeEventListener("shell-after-navigate",Ta)}function Xt(e,t){return _e&&_e.urlForName(e,t)}function Rm(e,t){const i=Xt(e);i&&ct.go({pathname:i,hash:t})}let Ni=class extends Rt{constructor(){super(...arguments),this.routeName=null}return(){this.routeName&&Rm(this.routeName),window.history.back()}render(){return g` <ix-button appearance="text" has-icon @click="${this.return}"> <md-icon slot="icon">arrow_back</md-icon> <span class="uppercase font-bold tracking-wider">Back</span> </ix-button>`}};E([we({type:String})],Ni.prototype,"routeName",void 0),Ni=E([X("sm-back-button")],Ni);const Am="Other parties to notify",_m="Result",Xe="CANCEL TICKET",Im="REQUEST CANCELLATION",Ee="EDIT TICKET",Sm="Sites & Locations",Cm="Sites, Locations & Hosts",Pm="Trouble Ticket is not supported for this site.",Nm="We are unable to process your request. Please, try again or reach out to us for further assistance. We apologize for the inconvenience. Your Digital Realty Team.",qm="Please be advised that your company has been restricted from submitting a new Delivery request for this location until all existing packages have been retrieved.",Dm="We're unable to process your request at the moment. Please reach out to Customer Care for assistance.",Bm="Unable to process request. Contact Customer Care.";var O;(function(e){e.Announced="Announced",e.Cancelled="Cancelled",e.Completed="Completed",e.Draft="Draft",e.InProgress="In Progress",e.New="New",e.Expired="Expired"})(O||(O={}));var Qt;(function(e){e.CancellationRequested="Cancellation requested"})(Qt||(Qt={}));var ft;(function(e){e.Approved="Approved",e.PendingPickup="Pending Pick-up",e.Rejected="Rejected"})(ft||(ft={}));var re;(function(e){e.Approved="Approved",e.PendingApproval="Pending Approval",e.ApprovalDenied="Approval Denied"})(re||(re={}));const Om=[O.Cancelled,O.Completed,O.Expired,ft.Rejected,re.ApprovalDenied],$m=[O.New,O.InProgress,O.Announced,ft.PendingPickup,ft.Approved,Qt.CancellationRequested,re.PendingApproval];var qi;(function(e){e.Resolved="Resolved",e.InProgress="In Progress",e.New="New",e.Closed="Closed",e.Cancelled="Cancelled"})(qi||(qi={}));class Em{constructor(){se(this)}async getServiceBackend(t,i,s){var a;i=i==null?void 0:i.split(".").pop();let o={accountNumber:t,site:i};const n=await m.siteNavigationApi.getSiteNavigation(o).catch(r=>{l(r,!1)});switch((a=n==null?void 0:n.find(r=>r.process===s))===null||a===void 0?void 0:a.serviceManagementSystem){case _i.InSite:return H.Insite;case _i.ServiceNow:return H.ServiceNow;case _i.TelxSfdc:return s==="Facilities_access"?H.Insite:H.TelxSFDC;default:return}}}const K=new Em;var mt;(function(e){e.Kilograms="kilograms",e.Pounds="pounds"})(mt||(mt={}));function ba(e){return typeof e=="string"&&e.trim().length>0}const Ra=e=>/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e);function xm(e){return/^[a-zA-Z0-9]+$/.test(e)}function Fm(e){return/^[a-zA-Z0-9 ]+$/.test(e)}function Lm(e){return/^[a-zA-Z0-9.' ]+$/.test(e)}function Vm(e){const t=he(e,"YYYY-MM-DD"),i=he().add(24,"hours").startOf("day");return t.isSameOrAfter(i)}function Um(e,t){const i=t?he.tz(t):he.utc(),[s,a]=e.split(":").map(o=>parseInt(o,10));return s>i.hours()||s===i.hours()&&a>i.minutes()}function Aa(e){return ba(e)?/^(0|[1-9]\d*)$/.test(e):!1}const _a=(e,t)=>{let i;return t===H.ServiceNow&&(i=e.weight,e.overweight&&(e.isHistorical||(i=`${e.weight} ${e.weightUnit}`))),{trackingNumber:e.trackingNumber,numberOfPackages:e.numberOfPackages,sizeWhenOversized:e.dimensions,weightWhenOverweight:i,courierCompany:e.courier===wt?e.otherCompany:e.courier}},Ia=(e,t=!1)=>{var i,s,a,o,n;const r=e.serviceBackend!==H.ServiceNow?e.shortDescription+Ci+(e.instructions||na):e.shortDescription,d={accountNumber:(i=e.site)===null||i===void 0?void 0:i.accountNumber,subject:(s=e.subject)!==null&&s!==void 0?s:"",description:r,etaFrom:Z(e.estimatedDate)||null,etaTo:Z(e.latestDate)||null,customerReference:e.referenceNumber,site:(o=(a=e.site)===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:"",otherNotificationRecipients:e.contacts,remoteHandsRequired:e.needRemoteHands};return(e==null?void 0:e.serviceBackend)!==H.TelxSFDC&&(d.loadingBayRequired=e.isLoadingBayRequired),t||(d.packages=(n=e.packages)===null||n===void 0?void 0:n.map(u=>_a(u,e.serviceBackend))),d};function Hm(e,t){const i=new Date;return t&&i.setDate(i.getDate()+e),St(i)}function zm(e){const t=new Date;return t.setDate(t.getDate()+e),St(t)}const Sa=async(e,t,i)=>{if(!e||!t||!i)return[e];if(await K.getServiceBackend(t,i,"Deliveries")!==H.ServiceNow){const s=e.lastIndexOf(Ci);return s===-1?[e]:e.endsWith(na)?[e.substring(0,s)]:[e.substring(0,s),e.substring(s+Ci.length)]}return[e]},jm=e=>{if(!e)return[void 0,void 0];const t=e.split(" ");if(t.length!==2)return[e,void 0];const[i,s]=t;let a;if(s.toLowerCase()===mt.Kilograms)a=mt.Kilograms;else if(s.toLowerCase()===mt.Pounds)a=mt.Pounds;else return[e,void 0];return Aa(i)?[i,a]:[e,void 0]},Ca=async(e,t,i,s)=>{if(!e)return[];await J.fillCouriers(t,i,s);const a=J.getCouriers(s);return e.map(o=>{const n=a==null?void 0:a.find(P=>{var b;return P.toLowerCase()===((b=o.courierCompany)===null||b===void 0?void 0:b.toLowerCase())}),r=!!n,d=!!o.weightWhenOverweight;let u="",p;if(d){const[P,b]=jm(o.weightWhenOverweight);u=P!=null?P:"",p=b}let _=!1;return d&&(_=!p||u.length>ra),{id:o.id||"",trackingNumber:o.trackingNumber,numberOfPackages:o.numberOfPackages||0,dimensions:o.sizeWhenOversized,overweight:d,oversized:!!o.sizeWhenOversized,weight:_?o.weightWhenOverweight:u,weightUnit:_?void 0:p,courier:r?n:wt,otherCompany:r?"":o.courierCompany,isHistorical:_}})},Pa=async e=>{var t,i,s,a,o,n;if(!e)return;const[r,d]=await Sa(e.description,e.accountNumber,e.site),u=await K.getServiceBackend(e.accountNumber,e.site,"Deliveries"),p=await Ca(e.packages,e.site,e.accountNumber,u);return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,subject:e.subject,shortDescription:r,instructions:d,estimatedDate:(t=e.etaFrom)===null||t===void 0?void 0:t.toISOString().split("T")[0],latestDate:(i=e.etaTo)===null||i===void 0?void 0:i.toISOString().split("T")[0],referenceNumber:e.customerReference,site:e.site,cancellationReason:e.cancellationReason,contacts:e.otherNotificationRecipients,state:e.status,requester:e.createdBy,createdOn:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedOn:(a=e.updatedAt)===null||a===void 0?void 0:a.toISOString(),isLoadingBayRequired:e.loadingBayRequired,needRemoteHands:(o=e.remoteHandsRequired)!==null&&o!==void 0?o:!1,packages:p,comments:(n=e.comments)===null||n===void 0?void 0:n.map(_=>M(_)),serviceBackend:u}},Mm=async e=>{var t,i,s;if(!e)return;const[a,o]=await Sa(e.description,e.accountNumber,e.site),n=await K.getServiceBackend(e.accountNumber,e.site,"Deliveries"),r=await Ca(e.packages,e.site,e.accountNumber,n),d=J.sites.find(u=>u.id===e.site).locationId;return{id:e.id||"",accountNumber:e.accountNumber||"",subject:e.subject,shortDescription:a,instructions:o,estimatedDate:(t=e.etaFrom)===null||t===void 0?void 0:t.toISOString(),latestDate:(i=e.etaTo)===null||i===void 0?void 0:i.toISOString(),referenceNumber:e.customerReference,site:new Oe(d,e.site,e.accountNumber),contacts:e.otherNotificationRecipients,isLoadingBayRequired:e.loadingBayRequired,serviceBackend:n,isValid:!0,needRemoteHands:(s=e.remoteHandsRequired)!==null&&s!==void 0?s:!1,packages:r}},Jm=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Na=e=>e.requestType===gi.PlannedWork&&e.serviceBackend===H.ServiceNow,Wm=e=>{var t,i;return Na(e)&&(i=Be(e.startDate,e.startTime,(t=e.site)===null||t===void 0?void 0:t.siteId))!==null&&i!==void 0?i:null},qa=async e=>{var t,i;if(!e.expectedStart)return{startDate:"",startTime:"",startDateTime:""};const s=(i=(t=J.sites)===null||t===void 0?void 0:t.find(o=>o.locationId===e.site))===null||i===void 0?void 0:i.timeZone,a=s?G(e.expectedStart).tz(s):G(e.expectedStart);return{startDate:a.format("YYYY-MM-DD"),startTime:a.format("HH:mm"),startDateTime:a.format("YYYY-MM-DDTHH:mm")}},Gm=e=>{var t,i,s,a,o;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",requestType:(i=e.requestType)!==null&&i!==void 0?i:"",category:(s=e.category)!==null&&s!==void 0?s:"",subject:(a=e.subject)!==null&&a!==void 0?a:"",description:e.description,expectedStart:Wm(e),customerReference:e.referenceNumber,locations:!((o=e.location)===null||o===void 0)&&o.id?[e.location.id]:[],referenceTicket:e.referenceTicketNumber,otherNotificationRecipients:e.contacts}},Zm=e=>({customerReference:e.referenceNumber,otherNotificationRecipients:e.contacts}),Da=async e=>{var t,i,s,a,o;if(!e)return;const{startDate:n,startTime:r}=await qa(e);return{id:e.ticketId,accountName:e.accountName,accountNumber:e.accountNumber,category:e.category,subject:e.subject,shortDescription:e.description,startDate:n,startTime:r,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,state:e.status,site:e.site,locations:(i=(t=e.locations)===null||t===void 0?void 0:t.join(", "))!==null&&i!==void 0?i:"",requester:e.createdBy,requestType:e.requestType,referenceTicketNumber:e.referenceTicket,createdAt:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedAt:(a=e.updatedAt)===null||a===void 0?void 0:a.toISOString(),cancellationReason:e.cancellationReason,comments:(o=e.comments)===null||o===void 0?void 0:o.map(d=>M(d)),serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Remote_hands"),ticketStatus:e.status||""}},Km=async e=>{var t,i,s,a;if(!e)return;const{startDate:o,startTime:n,startDateTime:r}=await qa(e);return{id:e.ticketId||"",accountName:e.accountName,accountNumber:e.accountNumber||"",category:e.category,subject:e.subject,description:e.description,shortDescription:(i=(t=e.description)===null||t===void 0?void 0:t.split("-")[0])===null||i===void 0?void 0:i.trim(),startDate:o,startTime:n,startDateTime:r,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,state:e.status,site:{id:e.site},location:{id:e.locations[0],accountNumber:e.accountNumber},requester:e.createdBy,requestType:e.requestType,referenceTicketNumber:e.referenceTicket,createdOn:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedOn:(a=e.updatedAt)===null||a===void 0?void 0:a.toISOString(),ticketStatus:e.status||"",serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Remote_hands")}},Ym=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Di=(e,t)=>{if(e===wt)return!0;const i=J.getCouriers(t).map(s=>s.toLowerCase());return!!e&&!(i!=null&&i.includes(e.toLowerCase()))},Ba=e=>e===oa,Xm=e=>G().add({days:e}).format(dt),Qm=(e,t)=>G(t).add({days:e}).format(dt),ep=e=>!!e&&G(e).isBefore(G().add({days:1}),"day"),tp=e=>!!e&&G(e).isBefore(G(),"day"),ip=e=>{var t,i,s,a,o,n;const r=(t=Di(e.courier,e.serviceBackend)?e.otherCompany:e.courier)!==null&&t!==void 0?t:"";return{accountNumber:(i=e.site)===null||i===void 0?void 0:i.accountNumber,subject:(s=e.subject)!==null&&s!==void 0?s:"",description:e.shortDescription,customerReference:e.referenceNumber,removalParty:(a=e.removalParty)!==null&&a!==void 0?a:"",courierCompany:r,trackingNumber:e.trackingNumber,pickupDate:Z(e.pickupDate),site:(n=(o=e.site)===null||o===void 0?void 0:o.id)!==null&&n!==void 0?n:"",otherNotificationRecipients:e.contacts}},sp=e=>{var t;const i=(t=Di(e.courier,e.serviceBackend)?e.otherCompany:e.courier)!==null&&t!==void 0?t:"";return{subject:e.subject,description:e.shortDescription,customerReference:e.referenceNumber,courierCompany:i,trackingNumber:e.trackingNumber,pickupDate:Z(e.pickupDate),otherNotificationRecipients:e.contacts}},Oa=async(e,t,i,s)=>{await J.fillCouriers(t,i,s);const a=J.getCouriers(s).find(n=>n.toLowerCase()===(e==null?void 0:e.toLowerCase())),o=!!a;return{courier:o?a:wt,otherCompany:o?"":e}},$a=e=>e===Wl?oa:e;async function ap(e){if(!e)return;const t=await K.getServiceBackend(e.accountNumber,e.site,"Removals"),{courier:i,otherCompany:s}=await Oa(e.courierCompany,e.site,e.accountNumber,t),a=$a(e.removalParty),o=J.sites.find(n=>n.id===e.site).locationId;return{id:e.id,accountNumber:e.accountNumber,site:new Oe(o,e.site,e.accountNumber),subject:e.subject,shortDescription:e.description,courier:i,otherCompany:s,removalParty:a,trackingNumber:e.trackingNumber,pickupDate:e.pickupDate,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,status:e.status,isValid:!0,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Removals")}}const np=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Ea=async e=>{var t,i,s;if(!e)return;const a=await K.getServiceBackend(e.accountNumber,e.site,"Removals"),{courier:o,otherCompany:n}=await Oa(e.courierCompany,e.site,e.accountNumber,a),r=$a(e.removalParty);return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,status:e.status,subject:e.subject,shortDescription:e.description,referenceNumber:e.customerReference,removalParty:r,needRemoteHands:Ba(r),courier:o,otherCompany:n,trackingNumber:e.trackingNumber,pickupDate:e.pickupDate,site:e.site,serviceBackend:a,contacts:e.otherNotificationRecipients,requester:e.createdBy,createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),cancellationReason:e.cancellationReason,comments:(s=e.comments)===null||s===void 0?void 0:s.map(d=>M(d))}},op=e=>{var t,i,s,a,o,n,r,d;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",requestType:(i=e.requestType)!==null&&i!==void 0?i:"",category:(s=e.category)!==null&&s!==void 0?s:"",subject:(a=e.subject)!==null&&a!==void 0?a:"",description:(o=e.description)!==null&&o!==void 0?o:"",locations:e.locations,customerReference:(n=e.referenceNumber)!==null&&n!==void 0?n:"",circuitId:(r=e.circuitId)!==null&&r!==void 0?r:"",notificationRecipients:(d=e.contacts)!==null&&d!==void 0?d:""}},rp=e=>{const t={};return e.subject&&(t.subject=e.subject),e.description&&(t.description=e.description),e.circuitId&&(t.circuitId=e.circuitId),e.referenceNumber&&(t.customerReference=e.referenceNumber),e.contacts&&(t.otherNotificationRecipients=e.contacts),t},Bi=async e=>{var t,i,s,a;if(e)return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,category:e.category,subject:e.subject,description:e.description,referenceNumber:e.customerReference,contacts:e.notificationRecipients,state:e.status,site:{id:e.site,accountNumber:e.accountNumber},locations:e.locations,requester:e.createdBy,requestType:e.requestType,circuitId:e.circuitId,createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),closedOn:(s=e.closedAt)===null||s===void 0?void 0:s.toISOString(),comments:(a=e.comments)===null||a===void 0?void 0:a.map(o=>M(o)),cancellationReason:e.cancellationReason,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Trouble_tickets")}},cp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}});async function Nt(e,t,i,s,a,o){var n;let r;switch(e){case y.CustomerSupport:{r=await m.customerCareApi.createCustomerCareTicketAttachment({ticketId:a,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.RemoteHands:{r=await m.remoteHandsApi.createRemoteHandsAttachment({ticketId:a,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.Deliveries:{r=await m.deliveriesApi.createAttachment({ticketId:a,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.Removals:{r=await m.removalsApi.createRemovalsAttachment({ticketId:a,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.FacilityAccess:{switch(o){case"Visitor Access":r=await m.facilityAccessApi.visitorAccess.createVisitorAccessAttachment({ticketId:a,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break;case"Permanent Badge":r=await((n=m.facilityAccessApi.permanentBadgeAccess)===null||n===void 0?void 0:n.createPermanentBadegeAttachment({ticketId:a,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d}));break;case"OSP Access":r=await m.facilityAccessApi.ospAccess.createOspAccessAttachment({ticketId:a,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break;case"PoP/POE Access":r=await m.facilityAccessApi.popAccess.createPopAccessAttachment({ticketId:a,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}break}case y.TroubleTickets:{r=await m.troubleTicketsApi.createTroubleTicketAttachment({ticketId:a,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}default:return}return r}const xe=e=>{const t=URL.createObjectURL(e);window.open(t),setTimeout(()=>URL.revokeObjectURL(t),1e3*60*5)};async function dp(e,t,i,s){var a;let o;try{switch(e){case y.CustomerSupport:{o=await m.customerCareApi.getCustomerCareTicketAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.RemoteHands:{o=await m.remoteHandsApi.getRemoteHandsAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.Deliveries:{o=await m.deliveriesApi.getDeliveryAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.Removals:{o=await m.removalsApi.getRemovalsAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.TroubleTickets:{o=await m.troubleTicketsApi.getTroubleTicketAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.FacilityAccess:{switch(s){case"Visitor Access":o=await m.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;case"Permanent Badge":o=await((a=m.facilityAccessApi.permanentBadgeAccess)===null||a===void 0?void 0:a.getPermanentBadgeAttachmentsById({ticketId:i,attachmentId:t})),xe(o);break;case"OSP Access":o=await m.facilityAccessApi.ospAccess.getOspAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;case"PoP/POE Access":o=await m.facilityAccessApi.popAccess.getPopAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;default:break}break}default:return}}catch(n){console.error("error",n),l(n,!1)}return o}const Fe=(e,t)=>{const i=URL.createObjectURL(e),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),URL.revokeObjectURL(i)};async function up(e,t,i,s,a){var o;let n;try{switch(e){case y.CustomerSupport:{n=await m.customerCareApi.getCustomerCareTicketAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(n,i);break}case y.RemoteHands:{n=await m.remoteHandsApi.getRemoteHandsAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(n,i);break}case y.Deliveries:{n=await m.deliveriesApi.getDeliveryAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(n,i);break}case y.Removals:{n=await m.removalsApi.getRemovalsAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(n,i);break}case y.TroubleTickets:{n=await m.troubleTicketsApi.getTroubleTicketAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(n,i);break}case y.FacilityAccess:{switch(a){case"Visitor Access":n=await m.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(n,i);break;case"Permanent Badge":n=await((o=m.facilityAccessApi.permanentBadgeAccess)===null||o===void 0?void 0:o.getPermanentBadgeAttachmentsById({ticketId:s,attachmentId:t})),Fe(n,i);break;case"OSP Access":n=await m.facilityAccessApi.ospAccess.getOspAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(n,i);break;case"PoP/POE Access":n=await m.facilityAccessApi.popAccess.getPopAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(n,i);break;default:break}break}default:return}}catch(r){console.error("error",r),l(r,!1)}return n}async function xa(e,t,i){var s,a;try{let o;switch(e){case y.CustomerSupport:{o=await m.customerCareApi.getCustomerCareTicketAttachmentsList({ticketId:t});break}case y.RemoteHands:{o=await m.remoteHandsApi.getRemoteHandsAttachmentsList({ticketId:t});break}case y.Deliveries:{o=await m.deliveriesApi.getDeliveryAttachmentsList({ticketId:t});break}case y.Removals:{o=await m.removalsApi.getRemovalsAttachmentsList({ticketId:t});break}case y.TroubleTickets:{o=await m.troubleTicketsApi.getTroubleTicketAttachmentsList({ticketId:t});break}case y.FacilityAccess:{switch(i){case"Visitor Access":o=await m.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsList({ticketId:t});break;case"Permanent Badge":o=await((s=m.facilityAccessApi.permanentBadgeAccess)===null||s===void 0?void 0:s.getPermanentBadgeAttachmentsList({ticketId:t}));break;case"OSP Access":o=await m.facilityAccessApi.ospAccess.getOspAccessAttachmentsList({ticketId:t});break;case"PoP/POE Access":o=await m.facilityAccessApi.popAccess.getPopAccessAttachmentsList({ticketId:t});break;default:break}break}default:return}return k.attachments=(a=o==null?void 0:o.attachments)!==null&&a!==void 0?a:[],k.attachments}catch(o){console.error("error",o),await l(o,!1);return}}const qt=async(e,t,i="text/csv")=>{const s=new Blob([await e.arrayBuffer()],{type:i}),a=URL.createObjectURL(s),o=document.createElement("a");o.href=a,o.download=t,document.body.appendChild(o),o.click(),URL.revokeObjectURL(a)};async function lp(e,t){try{const i=await m.serviceTicketApi.downloadServiceTickets({$filter:e,permissionPrivilege:t});await qt(i,"service-tickets.csv")}catch(i){l(i,!1)}}async function mp(e,t,i,s){try{const a=await m.plannedMaintenanceApi.downloadPlannedMaintenanceTickets({$filter:e,$orderby:t,$skip:i,$top:s});await qt(a,"planned-maintenance-tickets.csv")}catch(a){l(a,!1)}}async function pp(e,t,i){try{const s=await m.plannedMaintenanceApi.getPlannedMaintenanceAttachmentsByIdRaw({ticketId:e,attachmentId:t}),a=s.raw.headers.get("content-type")||void 0,o=await s.value();await qt(o,i,a)}catch(s){l(s,!1)}}async function hp(e,t,i,s){try{const a=await m.incidentsApi.downloadIncidentTickets({$filter:e,$orderby:t,$skip:i,$top:s});await qt(a,"incident-tickets.csv")}catch(a){l(a,!1)}}async function vp(e,t,i){try{const s=await m.incidentsApi.getIncidentsAttachmentsByIdRaw({ticketId:e,attachmentId:t}),a=s.raw.headers.get("content-type")||void 0,o=await s.value();await qt(o,i,a)}catch(s){l(s,!1)}}const Le={ticketType:void 0,ticketStep:void 0,serviceTickets:void 0,permissions:{hasCustomerCareCreatePermission:!1,hasFacilityAccessCreatePermission:!1,hasRemoteHandsCreatePermission:!1,hasDeliveriesAndRemovalsCreatePermission:!1,hasTroubleTicketsCreatePermission:!1},loadings:{ticketCreatePermissionChecks:!0,serviceTicketList:!0,attachments:!0,downloadServiceTicketList:!1,serviceTicket:!1,isTicketCancelling:!1},attachments:[],failedAttachments:[],error:{uploadingAttachments:!1,serviceTicketsGrid:!1,fetchingTicket:!1,cancellingTicket:!1},hasPendingApprovalDialogBeenShown:!1};class gp{constructor(){this.ticketType=void 0,this.ticketStep=void 0,this.serviceTickets=void 0,this.permissions=Le.permissions,this.loadings=Le.loadings,this.attachments=Le.attachments,this.failedAttachments=Le.failedAttachments,this.error=Le.error,this.hasPendingApprovalDialogBeenShown=Le.hasPendingApprovalDialogBeenShown,se(this)}updateTicketType(t=void 0){this.ticketType=t}clear(){this.ticketType=void 0,this.ticketStep=void 0,this.error=Le.error,this.loadings=Le.loadings,this.failedAttachments=Le.failedAttachments}setPendingApprovalDialogShown(t){this.hasPendingApprovalDialogBeenShown=t}async checkPermissions(){this.loadings.ticketCreatePermissionChecks=!0;const t=await fm();this.permissions.hasCustomerCareCreatePermission=t.hasCustomerCareCreatePermission,this.permissions.hasFacilityAccessCreatePermission=t.hasFacilityAccessCreatePermission,this.permissions.hasRemoteHandsCreatePermission=t.hasRemoteHandsCreatePermission,this.permissions.hasDeliveriesAndRemovalsCreatePermission=t.hasDeliveriesAndRemovalsCreatePermission,this.permissions.hasTroubleTicketsCreatePermission=t.hasTroubleTicketsCreatePermission,this.loadings.ticketCreatePermissionChecks=!1}async postAttachments(t,i,s,a,o){i&&i.length>0&&(this.error.uploadingAttachments=!1,this.failedAttachments=i.map(n=>n.fileName),await Promise.all(i.map(async n=>{try{const r=await Nt(t,n.file,n.fileName,n.fileType,s,o);a&&r!=null&&r.id&&(this.attachments.push(r),this.failedAttachments=this.failedAttachments.filter(d=>d!==n.fileName))}catch(r){await l(r,!1),this.error.uploadingAttachments=!0}})))}async GetServiceTicketList(t,i,s,a,o,n){var r,d;this.loadings.serviceTicketList=!0,this.error.serviceTicketsGrid=!1;try{this.serviceTickets=await m.serviceTicketApi.getServiceTickets({$filter:t,$orderby:i,$skip:s,$top:a,permissionPrivilege:o},n)}catch(u){if(!((r=n==null?void 0:n.signal)===null||r===void 0)&&r.aborted)return;l(u,!1),this.serviceTickets=void 0,this.error.serviceTicketsGrid=!0}finally{!((d=n==null?void 0:n.signal)===null||d===void 0)&&d.aborted||(this.loadings.serviceTicketList=!1)}}async downloadServiceTickets(t,i){this.loadings.downloadServiceTicketList=!0,await lp(t,i),this.loadings.downloadServiceTicketList=!1}get ticketAttachments(){return this.attachments.filter(t=>!t.isError).map(t=>({name:t.fileName}))}}const k=new gp,ke={newTicket:{isValid:!1,accountNumber:"",attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1,ticketDetailsPermissionCheck:!1}};class wp{constructor(){this.newTicket=ke.newTicket,this.submissionResult=ke.submissionResult,this.selectedTicket=ke.selectedTicket,this.loadings=ke.loadings,se(this),Je(this,{name:"removals",properties:[],storage:window.localStorage})}createTicket(){var t,i,s;this.newTicket={...ke.newTicket,site:(t=this.newTicket.site)!==null&&t!==void 0?t:void 0,serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0,accountNumber:(s=this.newTicket.accountNumber)!==null&&s!==void 0?s:"NOT FOUND"},this.submissionResult=ke.submissionResult}updateIsFormValid(t){this.newTicket.isValid=t}updateSite(t){this.newTicket.site=t}updateSubject(t){this.newTicket.subject=t}updateShortDesc(t){this.newTicket.shortDescription=t}updateCourier(t){this.newTicket.courier=t}updateOtherCompany(t){this.newTicket.otherCompany=t}updateTrackingNumber(t){this.newTicket.trackingNumber=t}updatePickupDate(t){this.newTicket.pickupDate=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateRemovalParty(t){this.newTicket.removalParty=t}updateContacts(t){this.newTicket.contacts=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.result=void 0;try{this.submissionResult.result=await m.removalsApi.createRemoval({removalTicketsRequest:ip(this.newTicket)})}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&(await k.postAttachments(y.Removals,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0)}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async hasTicketPermissionAtLocation(t,i,s,a){try{return this.loadings.ticketDetailsPermissionCheck=!0,await Pt(t,i,s,a)}finally{this.loadings.ticketDetailsPermissionCheck=!1}}async setNewTicket(){try{this.newTicket=await ap(this.submissionResult.result)||ke.newTicket}catch(t){throw await l(t,!1),t}}async getRemovalsServiceTicket(t){if(t)try{const i=await m.removalsApi.getRemovalById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await Ea(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async editTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{t=await m.removalsApi.updateRemovalById({ticketId:this.newTicket.id||"",removalsTicketsUpdateRequest:sp(this.newTicket)}),this.submissionResult.result=t,this.submissionResult.state=w.Submitted}catch(i){this.submissionResult.state=w.Error,await l(i,!1)}try{await k.postAttachments(y.Removals,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await Ea(t),await this.setNewTicket())}catch(i){throw await l(i,!1),i}}finally{this.loadings.isSubmitting=!1}}async cancelTicket(t){var i,s;try{if(k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id){const a=(s=this.selectedTicket)===null||s===void 0?void 0:s.id;await m.removalsApi.cancellationRemovalRequest({ticketId:a,cancellationTicketsRequest:{cancellationReason:t}}),await this.getRemovalsServiceTicket(a)}}catch(a){throw await l(a,!1),a}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=ke.newTicket,this.selectedTicket=ke.selectedTicket,this.submissionResult=ke.submissionResult,this.loadings=ke.loadings}}const Ve=new wp,ye={newTicket:{isValid:!1,isLoadingBayRequired:!1,needRemoteHands:!1,accountNumber:"",contacts:"",attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default,result:void 0},loadings:{isSubmitting:!1,isDeliveryBlocked:!1,ticketDetailsPermissionCheck:!1}};class fp{constructor(){this.newTicket=ye.newTicket,this.submissionResult=ye.submissionResult,this.selectedTicket=ye.selectedTicket,this.loadings=ye.loadings,se(this),Je(this,{name:"deliveries",properties:[],storage:window.localStorage})}createTicket(){var t,i,s;this.newTicket={...ye.newTicket,site:(t=this.newTicket.site)!==null&&t!==void 0?t:void 0,serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0,accountNumber:(s=this.newTicket.accountNumber)!==null&&s!==void 0?s:"NOT FOUND"},this.submissionResult=ye.submissionResult}addPackage(t,i){var s;if(!t)return;const a=(s=this.newTicket.packages)!==null&&s!==void 0?s:[];i?this.newTicket.packages=a.map(o=>o.id===t.id?t:o):this.newTicket.packages=[...a,t]}removePackage(t){var i;if(t){const s=((i=this.newTicket.packages)!==null&&i!==void 0?i:[]).filter(a=>a.id!==t.id);this.newTicket.packages=[...s]}}updateSite(t){this.newTicket.site=t,this.newTicket.packages=[]}updateSubject(t){this.newTicket.subject=t}updateShortDesc(t){this.newTicket.shortDescription=t}updateEstimatedDate(t){this.newTicket.estimatedDate=t}updateLatestDate(t){this.newTicket.latestDate=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateLoadingBay(t){this.newTicket.isLoadingBayRequired=t}updateNeedRemoteHands(t){this.newTicket.needRemoteHands=t}updateInstructions(t){this.newTicket.instructions=t}updateContacts(t){this.newTicket.contacts=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateIsValid(t){this.newTicket.isValid=t}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await m.deliveriesApi.createDelivery({deliveryTicketsRequest:Ia(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&await k.postAttachments(y.Deliveries,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Mm(this.submissionResult.result)||ye.newTicket}catch(t){throw await l(t,!1),t}}async updateTicketRequest(){var t,i;let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await m.deliveriesApi.updateDeliveriesTickets({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",deliveryTicketsUpdateRequest:Ia(this.newTicket,!0)});const a=((i=this.newTicket)===null||i===void 0?void 0:i.packages)||[],o=(await Promise.all(a.map(async n=>{var r;return m.deliveriesApi.updateDeliveriesTicketsPackages({ticketId:((r=this.selectedTicket)===null||r===void 0?void 0:r.id)||"",packageId:(n==null?void 0:n.id)||"",deliveryTicketUpdatePackagesRequest:_a(n,this.newTicket.serviceBackend)}).then(d=>{var u,p;return(p=(u=d.packages)===null||u===void 0?void 0:u.find(_=>_.id===n.id))!==null&&p!==void 0?p:null}).catch(d=>(l(d,!1),null))}))).filter(n=>n!==null);s&&(s.packages=s.packages.map(n=>{const r=o.find(d=>n.id===d.id);return r!=null?r:n})),this.submissionResult.result=s,this.submissionResult.state=w.Submitted}catch(a){throw this.submissionResult.state=w.Error,await l(a,!1),a}try{await k.postAttachments(y.Deliveries,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(a){await l(a,!1)}try{this.selectedTicket=await Pa(s),await this.setNewTicket()}catch(a){await l(a,!1)}}finally{this.loadings.isSubmitting=!1}}async hasTicketPermissionAtLocation(t,i,s,a){this.loadings.ticketDetailsPermissionCheck=!0;const o=await Pt(t,i,s,a);return this.loadings.ticketDetailsPermissionCheck=!1,o}async getDeliveriesServiceTicket(t){if(t)try{const i=await m.deliveriesApi.getDeliveryById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await Pa(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelDelivery(t,i){try{k.loadings.isTicketCancelling=!0,t&&(await m.deliveriesApi.cancellationDeliveryRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}),await this.getDeliveriesServiceTicket(t))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async isDeliveryBlocked(t,i){var s;let a;return this.loadings.isDeliveryBlocked=!0,t&&i&&(a=await m.deliveriesApi.getDeliveryDiscovery({site:t,accountNumber:i}).catch(o=>{l(o,!1)})),this.loadings.isDeliveryBlocked=!1,(s=a==null?void 0:a.deliveryBlocked)!==null&&s!==void 0?s:!0}clear(){this.newTicket=ye.newTicket,this.selectedTicket=ye.selectedTicket,this.submissionResult=ye.submissionResult,this.loadings=ye.loadings}}const Te=new fp,be={newTicket:{isValid:!1,accountNumber:"",disableReferenceTicketNumber:!1,attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1,ticketDetailsPermissionCheck:!1,requestType:!1}};class kp{constructor(){this.newTicket=be.newTicket,this.submissionResult=be.submissionResult,this.selectedTicket=be.selectedTicket,this.loadings=be.loadings,se(this),Je(this,{name:"remote-hands",properties:[],storage:window.localStorage})}createTicket(t){var i,s,a,o;const n=(i=this.newTicket.accountNumber)!==null&&i!==void 0?i:ne.getUserAccount().accountNumber;this.newTicket={...be.newTicket,site:(s=this.newTicket.site)!==null&&s!==void 0?s:void 0,accountNumber:n!=null?n:"NOT FOUND",serviceBackend:t,referenceTicketNumber:(a=this.newTicket.referenceTicketNumber)!==null&&a!==void 0?a:void 0,disableReferenceTicketNumber:(o=this.newTicket.disableReferenceTicketNumber)!==null&&o!==void 0?o:void 0},this.submissionResult=be.submissionResult}updateSite(t,i=!1){this.newTicket.site=t,this.newTicket.isValid=i}updateLocation(t){this.newTicket.location=t}updateSubject(t){this.newTicket.subject=t}updateDescription(t){this.newTicket.description=t}updateRequestType(t){this.newTicket.requestType=t,this.newTicket.category=void 0}updateCategory(t){this.newTicket.category=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateReferenceTicketNumber(t){this.newTicket.referenceTicketNumber=t}updateReferenceNumberDisable(t){this.newTicket.referenceTicketNumber=t,this.newTicket.disableReferenceTicketNumber=!0}updateStartDate(t){this.newTicket.startDate=t}updateStartTime(t){this.newTicket.startTime=t}updateContacts(t){this.newTicket.contacts=t}updateAccountNumber(t){this.newTicket.accountNumber=t}updateFormValidation(t){this.newTicket.isValid=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}updateTermsAgreed(t){this.newTicket.termsAgreed=t}async setNewTicket(){try{this.newTicket=await Km(this.submissionResult.result)||be.newTicket}catch(t){throw await l(t,!1),t}}async updateTicketRequest(){var t;let i;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{i=await m.remoteHandsApi.updateRemoteHandsTicketById({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",remoteHandsUpdateRequest:Zm(this.newTicket)}),this.submissionResult.result=i,this.submissionResult.state=w.Submitted}catch(s){this.submissionResult.state=w.Error,await l(s,!1)}try{await k.postAttachments(y.RemoteHands,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(s){await l(s,!1)}try{i&&(this.selectedTicket=await Da(i))}catch(s){await l(s,!1)}}catch(s){throw await l(s,!1),s}finally{this.loadings.isSubmitting=!1}}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await m.remoteHandsApi.createRemoteHandsTicket({remoteHandsRequest:Gm(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.ticketId&&(await k.postAttachments(y.RemoteHands,this.newTicket.attachments,this.submissionResult.result.ticketId),this.newTicket.attachments=void 0)}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async getRemoteHandsServiceTicket(t){if(t)try{const i=await m.remoteHandsApi.getRemoteHandsTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await Da(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.remoteHandsApi.cancellationRemoteHandsRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getRemoteHandsServiceTicket(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=be.newTicket,this.selectedTicket=be.selectedTicket,this.submissionResult=be.submissionResult,this.loadings=be.loadings}}const ce=new kp,yp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Re={newTicket:{isValid:!1,accountNumber:"",attachments:[],locations:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1}};class Tp{constructor(){this.newTicket=Re.newTicket,this.submissionResult=Re.submissionResult,this.selectedTicket=Re.selectedTicket,this.loadings=Re.loadings,se(this),Je(this,{name:"trouble-tickets",properties:[],storage:window.localStorage})}getIsInProgress(){var t;return((t=this.selectedTicket)===null||t===void 0?void 0:t.state)===O.InProgress}createTicket(t){var i,s;const{accountNumber:a}=ne.getUserAccount();this.newTicket={...Re.newTicket,site:(i=this.newTicket.site)!==null&&i!==void 0?i:void 0,accountNumber:a!=null?a:"NOT FOUND",referenceTicketNumber:t,serviceBackend:(s=this.newTicket.serviceBackend)!==null&&s!==void 0?s:void 0},this.submissionResult=Re.submissionResult}updateSite(t,i=!1){this.newTicket.site=t,this.newTicket.isValid=i}updateLocations(t,i){var s,a,o;if(i)(o=this.newTicket.locations)===null||o===void 0||o.push(t);else{const n=(s=this.newTicket.locations)===null||s===void 0?void 0:s.indexOf(t);n!==void 0&&n!==-1&&((a=this.newTicket.locations)===null||a===void 0||a.splice(n,1))}}clearLocations(){this.newTicket.locations=[]}updateSubject(t){this.newTicket.subject=t}updateDescription(t){this.newTicket.description=t}updateRequestType(t){this.newTicket.requestType=t,this.newTicket.category=void 0}updateCategory(t){this.newTicket.category=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateReferenceTicketNumber(t){this.newTicket.referenceTicketNumber=t}updateReferenceNumberDisable(t){this.newTicket.referenceTicketNumber=t}updateCircuitId(t){this.newTicket.circuitId=t}updateContacts(t){this.newTicket.contacts=t}updateAccountNumber(t){this.newTicket.accountNumber=t}updateFormValidation(t){this.newTicket.isValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}async submitNewTicketRequest(){var t,i;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.result=void 0;try{this.submissionResult.result=await m.troubleTicketsApi.createTroubleTicketTicket({troubleTicketRequest:op(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(s){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(s,!1),s}try{!((i=(t=this.submissionResult)===null||t===void 0?void 0:t.result)===null||i===void 0)&&i.id&&(await k.postAttachments(y.TroubleTickets,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0)}catch(s){throw await l(s,!1),s}finally{this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Bi(this.submissionResult.result)||Re.newTicket}catch(t){throw await l(t,!1),t}}async submitUpdateTicketRequest(){var t,i;if(this.newTicket&&this.selectedTicket&&this.selectedTicket.id){let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await m.troubleTicketsApi.updateTroubleTicketTicket({ticketId:(t=this.selectedTicket.id)!==null&&t!==void 0?t:"",troubleTicketUpdateRequest:rp(this.newTicket)}),this.submissionResult.result=s}catch(a){this.submissionResult.state=w.Error,await l(a,!1)}try{await k.postAttachments(y.TroubleTickets,this.newTicket.attachments,(i=this.selectedTicket)===null||i===void 0?void 0:i.id,!0),this.newTicket.attachments=void 0}catch(a){await l(a,!1)}try{s&&(this.submissionResult.state=w.Submitted,this.submissionResult.result=s,this.selectedTicket=await Bi(this.submissionResult.result),await this.setNewTicket())}catch(a){await l(a,!1)}}finally{this.loadings.isSubmitting=!1}}}async getTroubleTicketById(t){if(t)try{const i=await m.troubleTicketsApi.getTroubleTicketTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await Bi(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.troubleTicketsApi.cancellationTroubleTicketRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getTroubleTicketById(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=Re.newTicket,this.selectedTicket=Re.selectedTicket,this.submissionResult=Re.submissionResult,this.loadings=Re.loadings}}const Ue=new Tp,bp={"Visitor First Name":"visitorFirstName","Visitor Last Name":"visitorLastName","Visitor Email Address":"visitorEmailAddress","Visitor Phone Number":"visitorPhoneNumber"},Fa=40,Oi="bulk_";function pt(e){return e.startsWith("WO")}function Rp(e){return e.startsWith("CS")||e.startsWith("DEL")}function Ap(e,t){return e?Jt.Escorted:t==="Standard"?Jt.Standard:Jt.Extended}function _p(e){return e?e==="Escorted"?{isEscortedVisitor:!0,visitorBadge:void 0}:{isEscortedVisitor:!1,visitorBadge:e==="Standard"?"Standard":"Extended"}:{isEscortedVisitor:void 0,visitorBadge:void 0}}function Ip(e){return e.map(t=>{var i;return{siteCode:t.site.siteId,visitorHostId:(i=t.visitorHost)===null||i===void 0?void 0:i.id,locations:t.locations.map(s=>({id:s.id,startDate:Z(s.startDate),endDate:Z(s.endDate)}))}})}const Sp=e=>({otherNotificationRecipients:e.contacts,visitorPhone:e.visitors[0].phone});async function La(e,t,i,s,a,o){var n,r;const d=(n=J.sites.find(u=>u.locationId===e))===null||n===void 0?void 0:n.id;return[{site:new Oe(e,d,t),locations:(r=i==null?void 0:i.map(u=>({id:u.id||"-",site:d,startDate:u.startDate||"",endDate:u.endDate||"",status:u.approvalStatus||"-",modifiedBy:u.modifiedBy||"-"})))!==null&&r!==void 0?r:[],isVisitorHostDetailsValid:s,visitorHost:a,serviceBackend:o}]}const Cp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Pp=e=>{var t,i,s,a;return{accountNumber:e.accountNumber,visitors:e.visitors.map(o=>({firstName:o.firstName,lastName:o.lastName,email:o.email,phone:o.phone})),visitStartDate:Z(e.startDate),visitEndDate:Z(e.endDate),visitType:Ap((t=e.isEscortedVisitor)!==null&&t!==void 0?t:!1,e.visitorBadge),sites:Ip(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:(i=e.hostFirstName)!==null&&i!==void 0?i:"",visitorHostLastName:(s=e.hostLastName)!==null&&s!==void 0?s:"",representingCompany:(a=e.representingCompany)!==null&&a!==void 0?a:"",description:e.notes,notificationRecipients:e.contacts}},Va=async e=>{var t,i,s,a;if(!e)return;const o=pt(e.id)?H.Insite:H.ServiceNow;return{id:e.id,accountNumber:e.accountNumber||"-",accountName:e.accountName||"-",contacts:e.notificationRecipients||"",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt.toISOString(),updatedOn:e.updatedAt.toISOString(),requestType:"Visitor Access",category:"New Visitor Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",id:""}],visitorType:e.visitType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",startDate:e.visitStartDate,endDate:e.visitEndDate,representingCompany:e.representingCompany||"-",notes:e.description||"-",site:e.site,cancellationReason:e.cancellationReason,sitesDetails:await La((t=e.site)!==null&&t!==void 0?t:"-",(i=e.accountNumber)!==null&&i!==void 0?i:"-",(s=e.locations)!==null&&s!==void 0?s:[],!0,{firstName:e.visitorHostFirstName,lastName:e.visitorHostLastName},o),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,comments:(a=e.comments)===null||a===void 0?void 0:a.map(n=>M(n))}},Np=async e=>{var t,i,s;if(!e)return;const{isEscortedVisitor:a,visitorBadge:o}=_p(e.visitType),n=pt(e.id)?H.Insite:H.ServiceNow;return{id:e==null?void 0:e.id,accountNumber:e.accountNumber||"",contacts:e.notificationRecipients||"",requestType:"Visitor Access",category:"New Visitor Access",visitors:[{firstName:e.visitorFirstName||"",lastName:e.visitorLastName||"",email:e.visitorEmail||"",phone:e.visitorPhone||""}],escortFirstName:e.escortFirstName||"",escortLastName:e.escortLastName||"",startDate:e.visitStartDate,endDate:e.visitEndDate,representingCompany:e.representingCompany||"-",notes:e.description||"-",sitesDetails:await La((t=e.site)!==null&&t!==void 0?t:"-",(i=e.accountNumber)!==null&&i!==void 0?i:"-",(s=e.locations)!==null&&s!==void 0?s:[],!0,{firstName:e.visitorHostFirstName,lastName:e.visitorHostLastName},n),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,cancellationReason:e.cancellationReason,visitorBadge:o,isEscortedVisitor:a,isFileAttachedForVisitors:!1,isNotificationsAttachmentsValid:!0,isRequestedAccessDetailsValid:!0,isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0}},Ua=e=>{const{visitorFirstName:t,visitorLastName:i,visitorEmailAddress:s,visitorPhoneNumber:a}=e;if(!t||!i||!s)return"Error: First name, last name and email are required.";const o=!Ra(s),n=a&&a.length>0&&!un(a);if(o&&n)return"Error: Invalid visitor email address and phone number";if(o)return"Error: Invalid visitor email address";if(n)return"Error: Invalid visitor phone number"};async function qp(e){const[t,i]=await Promise.all([Ke({locationType:F.Site,permissionType:A.VisitorAccess,permissionPrivilege:e}),Ke({locationType:Ct,permissionType:A.VisitorAccess,permissionPrivilege:e,assignableProcess:"Facilities_access"})]),s=new Set(i.map(a=>a.siteId));return t.sort((a,o)=>a.siteId>o.siteId?1:-1).map(a=>({...a,hasSpaces:s.has(a.siteId)}))}const de={newTicket:{isRequestedAccessDetailsValid:!1,isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isNotificationsAttachmentsValid:!1,isRepresentingCompanyValid:!1,accountNumber:void 0,visitors:[],contacts:"",attachments:[],isEscortedVisitor:!1,startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard"},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Dp{constructor(){this.DuplicateEmailErrorMessage="Each visitor must have a unique email address.",this.newTicket=de.newTicket,this.submissionResult=de.submissionResult,this.selectedTicket=de.selectedTicket,this.loadings=de.loadings,this.isEditAttachmentAdded=de.isEditAttachmentAdded,se(this)}createTicket(){var t,i;const s=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ne.getUserAccount().accountNumber;this.newTicket={...de.newTicket,accountNumber:s,requestType:"Visitor Access",category:"New Visitor Access",serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0},this.submissionResult=de.submissionResult}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}get isVisitorHostDetailsValid(){var t;return((t=this.newTicket.sitesDetails)===null||t===void 0?void 0:t.some(i=>i.isVisitorHostDetailsValid===!1))===!1}isVisitorHostDetailsValidBySite(t,i){var s;const a=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);a&&(a.isVisitorHostDetailsValid=i)}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}isRepresentingCompanyValid(t){this.newTicket.isRepresentingCompanyValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}removeBulkAttachment(){var t;this.newTicket.attachments=(t=this.newTicket.attachments)===null||t===void 0?void 0:t.filter(i=>{var s;return!(!((s=i.fileName)===null||s===void 0)&&s.startsWith(Oi))})}get isNewTicketValid(){return this.newTicket.isVisitorContactsDetailsValid&&this.newTicket.isVisitorEscortedDetailsValid&&this.isVisitorHostDetailsValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isRepresentingCompanyValid&&this.newTicket.isNotificationsAttachmentsValid}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const a=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);a&&(a.visitorHost=i,a.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}updateIsFileAttachedForVisitors(t){this.newTicket.isFileAttachedForVisitors=t}validateNoDuplicateEmails(t){const i=[...t];i.forEach((a,o)=>{a.validationError===this.DuplicateEmailErrorMessage&&(i[o]={...a,validationError:void 0,isValid:!0})});const s=i.filter(a=>!a.validationError);return i.forEach((a,o)=>{a.validationError||s.filter(n=>n.email.toLowerCase()===a.email.toLowerCase()).length>1&&(i[o]={...a,validationError:this.DuplicateEmailErrorMessage,isValid:!1})}),i}addOrUpdateVisitor(t){var i;if(!t)return;const s=(i=this.newTicket.visitors)!==null&&i!==void 0?i:[],a=s.findIndex(n=>n.id===t.id),o=a!==-1;if(!(!o&&s.length>=Fa))if(this.newTicket.id)this.newTicket.visitors=[t];else{let n;t.isUploadedFromFile&&(n=Ua({visitorFirstName:t.firstName,visitorLastName:t.lastName,visitorEmailAddress:t.email,visitorPhoneNumber:t.phone}));const r={...t,validationError:n,isValid:!n},d=[...s];o?d[a]=r:d.push(r),this.newTicket.visitors=this.validateNoDuplicateEmails(d)}}addBulkVisitors(t){t.forEach(i=>{const s=Ua(i),a={id:crypto.randomUUID(),firstName:i.visitorFirstName,lastName:i.visitorLastName,email:i.visitorEmailAddress,phone:i.visitorPhoneNumber,isUploadedFromFile:!0,validationError:s,isValid:!s};this.addOrUpdateVisitor(a)})}removeBulkVisitors(){var t;const i=((t=this.newTicket.visitors)!==null&&t!==void 0?t:[]).filter(s=>s.isUploadedFromFile!==!0);this.newTicket.visitors=[...i]}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(a=>a.id!==t.id);this.newTicket.visitors=this.validateNoDuplicateEmails(s)}}removeAllVisitors(){this.newTicket.visitors=[]}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(a=>{a.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(a=>{a.endDate=t})})}updateRepresentingCompany(t){this.newTicket.representingCompany=t}updateNotes(t){this.newTicket.notes=t}async addSiteLocations(t){var i;if(t){const s=await K.getServiceBackend(t.site.accountNumber,t.site.siteId,"Facilities_access"),a=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId),o={...t,serviceBackend:s};this.newTicket.sitesDetails=[...a,o]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i,s,a;let o;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{o=await m.facilityAccessApi.visitorAccess.createVisitorAccessTicket({visitorAccessTicketRequest:Pp(this.newTicket)}),this.submissionResult.ticketNumbers=o==null?void 0:o.ticketNumbers}catch(n){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(n,!1),n}try{if(o){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(u=>u.fileName);const{ticketNumbers:n}=o,r=(i=n==null?void 0:n.filter(u=>Rp(u)))!==null&&i!==void 0?i:[],d=(s=n==null?void 0:n.filter(u=>pt(u)))!==null&&s!==void 0?s:[];n!=null&&n.length&&!((a=this.newTicket.attachments)===null||a===void 0)&&a.length&&await Promise.all(this.newTicket.attachments.map(async u=>{const p=[];let _=[];u.fileName.startsWith(Oi)?(r.length>0&&_.push(r[0]),d.length>0&&_.push(...d)):_=n,p.push(..._.map(async P=>Nt(y.FacilityAccess,u.file,u.fileName,u.fileType,P,this.newTicket.requestType))),await Promise.all(p).then(()=>{var P;k.failedAttachments=((P=this.newTicket.attachments)!==null&&P!==void 0?P:[]).filter(b=>b.fileName!==u.fileName).map(b=>b.fileName)})})),this.newTicket.attachments=void 0}}catch(n){throw k.error.uploadingAttachments=!0,await l(n,!1),n}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Np(this.submissionResult.ticketResponse)||de.newTicket}catch(t){throw await l(t,!1),t}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await m.facilityAccessApi.visitorAccess.updateVisitorAccessTicket({visitorAccessTicketUpdateRequest:Sp(this.newTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t.id]}catch(i){this.submissionResult.state=w.Error,await l(i,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"Visitor Access"),this.newTicket.attachments=void 0}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await Va(t),await this.setNewTicket())}catch(i){await l(i,!1)}}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async getVisitorAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.visitorAccess.getVisitorAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Va(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t,i){try{k.loadings.isTicketCancelling=!0,k.error.cancellingTicket=!1,t&&(await m.facilityAccessApi.visitorAccess.cancellationVisitorAccessRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}).catch(s=>{throw l(s,!1),s}),await this.getVisitorAccessServiceTicket(t))}catch(s){throw k.error.cancellingTicket=!0,await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async hasUpdatePermissions(){try{return!!await Ye(this.selectedTicket.sitesDetails[0].locations.map(t=>t.id),A.VisitorAccess,L.Update)}catch(t){return!1}}clearNewTicket(){this.newTicket=de.newTicket}async patchLocationsApprovalStatus(t){var i,s;const a=t.map(o=>({id:o.id,approvalStatus:ds[o.status]}));await m.facilityAccessApi.visitorAccess.updateVisitorAccessLocationsTicket({ticketId:((i=this.selectedTicket)===null||i===void 0?void 0:i.id)||"",locationsPatchRequestInner:a}),await this.getVisitorAccessServiceTicket((s=this.selectedTicket)===null||s===void 0?void 0:s.id)}async getVisitorHosts(t,i,s,a=1,o=10){return await m.facilityAccessApi.visitorHost.getVisitorHostsList({site:t,nameOrEmailContains:i,pageNumber:a,pageSize:o},s).catch(r=>{var d;!((d=s==null?void 0:s.signal)===null||d===void 0)&&d.aborted||l(r,!1)})||{items:[],totalCount:0}}clear(){this.newTicket=de.newTicket,this.selectedTicket=de.selectedTicket,this.submissionResult=de.submissionResult,this.loadings=de.loadings,this.isEditAttachmentAdded=de.isEditAttachmentAdded}}const ie=new Dp;function Bp(e){return e.flatMap(t=>t.locations).map(t=>({id:t.id,startDate:Z(t.startDate),endDate:Z(t.endDate)}))}function Op(e){return e.flatMap(t=>t.locations).map(t=>({id:t.id,startDate:Z(t.startDate),endDate:Z(t.endDate),operation:"add"}))}const $p=e=>{var t;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",badgeholderFirstName:e.badgeHolder.firstName,badgeholderLastName:e.badgeHolder.lastName,badgeholderEmail:e.badgeHolder.email,badgeholderCompany:e.badgeHolder.company,badgeholderPhone:e.badgeHolder.phone,badgeStartDate:Z(e.startDate),badgeEndDate:Z(e.endDate),locations:Bp(e.sitesDetails||[]),notificationRecipients:e.contacts}},Ep=e=>({otherNotificationRecipients:e.contacts}),xp=e=>({otherNotificationRecipients:e.contacts}),Fp=()=>({}),Lp=e=>{var t;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",badgeholderId:e.badgeHolder.id,badgeStartDate:Z(e.startDate),badgeEndDate:Z(e.endDate),locations:Op(e.sitesDetails||[]),notificationRecipients:e.contacts}},Vp=e=>({badgeholderId:e.badgeHolder.id,accountNumber:e.badgeHolder.accountNumber,badgeEndDate:Z(e.endDate)});async function Ha(e,t=""){if(!e)return[];const i=e.map(n=>({id:n.id||"-",site:n.site||"",siteAddress:n.siteAddress,startDate:n.startDate||"",endDate:n.endDate||"",status:n.approvalStatus||"-",modifiedBy:n.modifiedBy||"-"})),s=[...new Set(i.map(n=>n.site))],a={};await Promise.all(s.map(async n=>{var r;a[n]=(r=await lm(n))!==null&&r!==void 0?r:n}));const o=[];return i.forEach(n=>{const{site:r}=n,d=o.find(u=>u.site.siteId===r);d?d.locations.push(n):o.push({site:new Oe(a[r],r,t),locations:[n]})}),o}const za=async e=>{var t,i,s;if(e)return{id:e==null?void 0:e.id,accountNumber:e.accountNumber||"-",accountName:e.accountName||"-",contacts:e.notificationRecipients||"",state:e.status||"-",requester:e.createdBy||"-",createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),requestType:"Permanent Badge",category:e.requestType,visitors:[{firstName:e.badgeholderFirstName||"-",lastName:e.badgeholderLastName||"-",email:e.badgeholderEmail||"-",phone:e.badgeholderPhone,company:e.badgeholderCompany||"-"}],startDate:e.badgeStartDate,endDate:e.badgeEndDate,sitesDetails:await Ha(e.locations,e.accountNumber),cancellationReason:e.cancellationReason,comments:(s=e.comments)===null||s===void 0?void 0:s.map(a=>M(a))}},Up=async e=>{if(e)return{id:e==null?void 0:e.id,contacts:e.notificationRecipients,requestType:"Permanent Badge",category:e.requestType,visitors:[{firstName:e.badgeholderFirstName||"",lastName:e.badgeholderLastName||"",email:e.badgeholderEmail||"",phone:e.badgeholderPhone||"",company:e.badgeholderCompany||""}],badgeHolder:{firstName:e.badgeholderFirstName||"",lastName:e.badgeholderLastName||"",email:e.badgeholderEmail||"",phone:e.badgeholderPhone||"",company:e.badgeholderCompany||""},startDate:e.badgeStartDate,endDate:e.badgeEndDate,sitesDetails:await Ha(e.locations,e.accountNumber),isNotificationsAttachmentsValid:!0,isRequestedAccessDetailsValid:!0,isVisitorContactsDetailsValid:!0,isEndDateValid:!0,isBadgeholderValid:!0}},Hp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),ja=e=>e.map(t=>({id:t.id,accountNumber:t.accountNumber,firstName:t.firstName,lastName:t.lastName,email:t.email,phone:t.phone,company:t.representingCompany,startDate:t.badgeStartDate?St(t.badgeStartDate):void 0})),zp=(e,t)=>[...e,...ja(t)];async function jp(e){const[t,i]=await Promise.all([Ke({locationType:F.Site,permissionType:A.PermanentBadge,permissionPrivilege:e}),Ke({locationType:Ct,permissionType:A.PermanentBadge,permissionPrivilege:e,assignableProcess:"Facilities_access"})]),s=new Set(i.map(a=>a.siteId));return t.sort((a,o)=>a.siteId>o.siteId?1:-1).map(a=>({...a,hasSpaces:s.has(a.siteId)}))}const ue={newTicket:{isRequestedAccessDetailsValid:!1,isNotificationsAttachmentsValid:!1,isBadgeholderValid:!1,isStartDateSetViaBadgeHolder:!1,isEndDateValid:!1,accountNumber:void 0,contacts:"",badgeHolder:{},attachments:[],isVisitorContactsDetailsValid:!1,visitors:[]},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Mp{constructor(){this.newTicket=ue.newTicket,this.submissionResult=ue.submissionResult,this.selectedTicket=ue.selectedTicket,this.loadings=ue.loadings,this.isEditAttachmentAdded=ue.isEditAttachmentAdded,se(this)}createTicket(){var t,i,s,a;const o=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ne.getUserAccount().accountNumber;this.newTicket={...ue.newTicket,accountNumber:o,requestType:(i=this.newTicket.requestType)!==null&&i!==void 0?i:void 0,category:(s=this.newTicket.category)!==null&&s!==void 0?s:void 0,serviceBackend:(a=this.newTicket.serviceBackend)!==null&&a!==void 0?a:void 0},this.submissionResult=ue.submissionResult}updateStartDateSetViaBadgeholder(t){this.newTicket.isStartDateSetViaBadgeHolder=t}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}isBadgeholderValid(t){this.newTicket.isBadgeholderValid=t}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}isEndDateValid(t){this.newTicket.isEndDateValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}removeBulkAttachment(){throw new Error("Method not implemented.")}get isNewTicketValid(){switch(this.newTicket.category){case"New":return this.newTicket.isVisitorContactsDetailsValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isNotificationsAttachmentsValid;case"Modify":return this.newTicket.isBadgeholderValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isNotificationsAttachmentsValid;case"Terminate":return this.newTicket.isBadgeholderValid&&this.newTicket.isEndDateValid;default:return!1}}setBadgeHolder(t){this.newTicket.badgeHolder=t,t===void 0?this.newTicket.visitors=[]:this.newTicket.visitors=[{id:t.id,firstName:t.firstName,lastName:t.lastName,email:t.email,phone:t.phone,company:t.company}]}addOrUpdateVisitor(t){t&&this.setBadgeHolder(t)}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeVisitor(t){this.setBadgeHolder(void 0)}removeAllVisitors(){this.newTicket.visitors=[]}clearStartDate(){this.newTicket.startDate=void 0}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(a=>{a.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(a=>{a.endDate=t})})}async addSiteLocations(t){var i;if(t){const s=await K.getServiceBackend(t.site.accountNumber,t.site.siteId,"Facilities_access"),a=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId),o={...t,serviceBackend:s};this.newTicket.sitesDetails=[...a,o]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i;let s;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{switch(this.newTicket.category){case"New":s=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeNewTicket({permanentBadgeAccessNewTicketRequest:$p(this.newTicket)});break;case"Modify":s=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeModifyTicket({permanentBadgeAccessModifyTicketRequest:Lp(this.newTicket)});break;case"Terminate":s=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeTerminateTicket({permanentBadgeAccessTerminateTicketRequest:Vp(this.newTicket)});break;default:throw new Error("Invalid category")}this.submissionResult.ticketNumbers=s==null?void 0:s.ticketNumbers}catch(a){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(a,!1),a}try{if(s){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(o=>o.fileName);const{ticketNumbers:a}=s;a!=null&&a.length&&!((i=this.newTicket.attachments)===null||i===void 0)&&i.length&&await Promise.all(this.newTicket.attachments.map(async o=>Promise.all(a.map(async n=>Nt(y.FacilityAccess,o.file,o.fileName,o.fileType,n,this.newTicket.requestType))).then(()=>{var n;k.failedAttachments=((n=this.newTicket.attachments)!==null&&n!==void 0?n:[]).filter(r=>r.fileName!==o.fileName).map(r=>r.fileName)}))),this.newTicket.attachments=void 0}}catch(a){throw k.error.uploadingAttachments=!0,await l(a,!1),a}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}mapPermanentBadgeTicketToUpdateRequest(){switch(this.newTicket.category){case"Modify":return xp(this.newTicket);case"New":return Ep(this.newTicket);case"Terminate":return Fp();default:throw new Error("Invalid category")}}async setNewTicket(){try{this.newTicket=await Up(this.submissionResult.ticketResponse)||ue.newTicket}catch(t){throw await l(t,!1),t}}async submitUpdateTicketRequest(){var t;let i;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{i=await((t=m.facilityAccessApi.permanentBadgeAccess)===null||t===void 0?void 0:t.updatePermanentBadgeTicket({permanentBadgeAccessTicketUpdateRequest:this.mapPermanentBadgeTicketToUpdateRequest(),ticketId:this.newTicket.id})),this.submissionResult.ticketResponse=i,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[i.id]}catch(s){await l(s,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"Permanent Badge"),this.newTicket.attachments=void 0}catch(s){await l(s,!1)}try{i&&(this.selectedTicket=await za(i),await this.setNewTicket())}catch(s){await l(s,!1)}}catch(s){throw await l(s,!1),this.submissionResult.state=w.Error,s}finally{this.loadings.isSubmitting=!1}}async getPermanentBadgeAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.permanentBadgeAccess.getPermanentBadgeTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await za(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t,i){try{k.loadings.isTicketCancelling=!0,k.error.cancellingTicket=!1,t&&(await m.facilityAccessApi.permanentBadgeAccess.cancellationPermanentBadgeRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}).catch(s=>{throw l(s,!1),s}),await this.getPermanentBadgeAccessServiceTicket(t))}catch(s){throw k.error.cancellingTicket=!0,await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async hasUpdatePermissions(){try{return!!await Ye(this.selectedTicket.sitesDetails[0].locations.map(t=>t.id),A.PermanentBadge,L.Update)}catch(t){return!1}}async getAttachments(t,i){return xa(y.FacilityAccess,t,i)}async getPermanentBadgeHolders(t,i,s=1,a=10){return await m.facilityAccessApi.permanentBadgeAccess.getPermanentBadgeHoldersList({accountNumber:this.newTicket.accountNumber,activeBadge:!0,nameOrEmailContains:t,page:s,size:a},i).catch(n=>{var r;!((r=i==null?void 0:i.signal)===null||r===void 0)&&r.aborted||l(n,!0)})||{items:[],totalCount:0}}clearNewTicket(){this.newTicket=ue.newTicket}async patchLocationsApprovalStatus(t){var i,s,a;const o=t.map(n=>({id:n.id,approvalStatus:ds[n.status]}));await((i=m.facilityAccessApi.permanentBadgeAccess)===null||i===void 0?void 0:i.updatePermanentBadgeLocationsTicket({ticketId:((s=this.selectedTicket)===null||s===void 0?void 0:s.id)||"",locationsPatchRequestInner:o}).catch(n=>{l(n,!1)})),await this.getPermanentBadgeAccessServiceTicket((a=this.selectedTicket)===null||a===void 0?void 0:a.id).catch(n=>{l(n,!1)})}clear(){this.newTicket=ue.newTicket,this.selectedTicket=ue.selectedTicket,this.submissionResult=ue.submissionResult,this.loadings=ue.loadings,this.isEditAttachmentAdded=ue.isEditAttachmentAdded}}const Y=new Mp;function Jp(e){return e.flatMap(t=>t.locations.map(i=>({id:i.id,startDateTime:Be(i.startDate,i.startTime,t.site.siteId),endDateTime:Be(i.endDate,i.endTime,t.site.siteId)})))}async function Ma(e){var t,i,s;const{timeZone:a,id:o}=((t=J.sites)===null||t===void 0?void 0:t.find(d=>d.locationId===e.site))||{},n=o?await ka(o):[],r=new Map(n.map(d=>{var u;return[d.id,(u=d.name)!==null&&u!==void 0?u:d.id]}));return[{site:new Oe(e.site,o,e.accountNumber),locations:(s=(i=e.locations)===null||i===void 0?void 0:i.map(d=>{var u,p,_,P;return{id:d.id,name:r.get(d.id)||d.id,site:o,startDate:d.startDateTime&&a?(u=G(d.startDateTime).tz(a))===null||u===void 0?void 0:u.format(dt):"-",startTime:d.startDateTime&&a?(p=G(d.startDateTime).tz(a))===null||p===void 0?void 0:p.format($t):"-",endDate:d.endDateTime&&a?(_=G(d.endDateTime).tz(a))===null||_===void 0?void 0:_.format(dt):"-",endTime:d.endDateTime&&a?(P=G(d.endDateTime).tz(a))===null||P===void 0?void 0:P.format($t):"-"}}))!==null&&s!==void 0?s:[]}]}async function Wp(e){const[t,i]=await Promise.all([Ke({locationType:F.Site,permissionType:A.OSPAccess,permissionPrivilege:e}),Ke({locationType:lt.GreaterThan+F.Site,permissionType:A.OSPAccess,permissionPrivilege:e,assignableProcess:"OSP_access"})]),s=new Set(i.map(a=>a.siteId));return t.sort((a,o)=>a.siteId>o.siteId?1:-1).map(a=>({...a,hasSpaces:s.has(a.siteId),accountNumber:a.accountNumber}))}const Gp=e=>({accountNumber:e.accountNumber,visitors:e.visitors.map(t=>({firstName:t.firstName,lastName:t.lastName,email:t.email,company:t.company,phone:t.phone,visitorType:t.visitorType})),locations:Jp(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:e.hostFirstName,visitorHostLastName:e.hostLastName,customerExternalReference:e.customerExternalReference,serviceImpactedDescription:e.serviceImpactDescription,workDescription:e.workDescription,notificationRecipients:e.contacts}),le=(e,t)=>e===t||!e&&!t||!e&&t==="-",Zp=(e,t)=>{var i,s;const a={};le(e.visitors[0].phone,t.visitors[0].phone)||(a.visitorPhone=e.visitors[0].phone),le(e.visitors[0].company,t.visitors[0].company)||(a.visitorCompany=e.visitors[0].company),(!le(e.escortFirstName,t.escortFirstName)||!le(e.escortLastName,t.escortLastName))&&(a.escortFirstName=e.escortFirstName,a.escortLastName=e.escortLastName),(!le(e.hostFirstName,t.visitorHostFirstName)||!le(e.hostLastName,t.visitorHostLastName))&&(a.visitorHostFirstName=e.hostFirstName,a.visitorHostLastName=e.hostLastName),le(e.customerExternalReference,t.customerExternalReference)||(a.customerExternalReference=e.customerExternalReference),le(e.serviceImpactDescription,t.serviceImpactDescription)||(a.serviceImpactedDescription=e.serviceImpactDescription),le(e.workDescription,t.workDescription)||(a.workDescription=e.workDescription),le(e.contacts,t.notificationRecipients)||(a.otherNotificationRecipients=e.contacts);const o=((i=e.sitesDetails)===null||i===void 0?void 0:i.flatMap(d=>d.locations))||[],n=((s=t.sitesDetails)===null||s===void 0?void 0:s.flatMap(d=>d.locations))||[],r=o.map(d=>{var u,p;const _=n.find(b=>b.id===d.id),P={id:d.id};return(!_||!le(d.startDate,_.startDate)||!le(d.startTime,_.startTime))&&(P.startDateTime=Be(d.startDate,d.startTime,(u=e.sitesDetails)===null||u===void 0?void 0:u[0].site.siteId)),(!_||!le(d.endDate,_.endDate)||!le(d.endTime,_.endTime))&&(P.endDateTime=Be(d.endDate,d.endTime,(p=e.sitesDetails)===null||p===void 0?void 0:p[0].site.siteId)),P}).filter(d=>d.startDateTime||d.endDateTime);return r.length&&(a.locations=r),Object.keys(a).length===0&&(a.visitorCompany=e.visitors[0].company),a},Ja=async e=>{var t;return{id:e.id||"-",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt||"-",updatedOn:e.updatedAt||"-",requestType:"OSP Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",company:e.visitorCompany||"-",visitorType:e.visitorType}],visitorType:e.visitorType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",visitorHostFirstName:e.visitorHostFirstName||"-",visitorHostLastName:e.visitorHostLastName||"-",site:e.site||"-",sitesDetails:await Ma(e),customerExternalReference:e.customerExternalReference||"-",serviceImpacted:e.serviceImpactedDescription?"Yes":"No",serviceImpactDescription:e.serviceImpactedDescription||"-",workDescription:e.workDescription||"-",notificationRecipients:e.notificationRecipients||"",cancellationReason:e.cancellationReason||"-",comments:(t=e.comments)===null||t===void 0?void 0:t.map(i=>M(i))}},Kp=async e=>{var t,i,s,a,o;if(e)return{isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0,isVisitorHostValid:!0,isRequestedAccessDetailsValid:!0,isServiceImpactedSectionValid:!0,isNotificationsAttachmentsValid:!0,accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",status:e.status,requestType:"OSP Access",category:"",visitors:[{firstName:(i=e.visitorFirstName)!==null&&i!==void 0?i:"",lastName:(s=e.visitorLastName)!==null&&s!==void 0?s:"",email:(a=e.visitorEmail)!==null&&a!==void 0?a:"",company:e.visitorCompany,phone:(o=e.visitorPhone)!==null&&o!==void 0?o:"",visitorType:e.visitorType}],isEscortedVisitor:!0,escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,visitorBadge:"Standard",sitesDetails:await Ma(e),contacts:e.notificationRecipients,customerExternalReference:e.customerExternalReference,isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription,workDescription:e.workDescription,termsAgreed:!0,id:e.id,attachments:[]}},Yp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),me={newTicket:{isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isVisitorHostValid:!1,isRequestedAccessDetailsValid:!1,isServiceImpactedSectionValid:!1,isNotificationsAttachmentsValid:!1,accountNumber:"",visitors:[],contacts:"",attachments:[],startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard",serviceType:void 0,isEscortedVisitor:!0,escortFirstName:void 0,escortLastName:void 0,hostCompany:void 0,hostFirstName:void 0,hostLastName:void 0},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Wa{constructor(){this.newTicket=me.newTicket,this.submissionResult=me.submissionResult,this.selectedTicket=me.selectedTicket,this.loadings=me.loadings,this.isEditAttachmentAdded=me.isEditAttachmentAdded,se(this)}async setNewTicket(){var t;try{this.newTicket=(t=await Kp(this.submissionResult.ticketResponse))!==null&&t!==void 0?t:me.newTicket}catch(i){throw await l(i,!1),i}}async getOSPAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.ospAccess.getOspAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Ja(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}createTicket(){var t;const i=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ne.getUserAccount().accountNumber;this.newTicket={...me.newTicket,accountNumber:i,requestType:"OSP Access",category:""},this.submissionResult=me.submissionResult}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const a=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);a&&(a.visitorHost=i,a.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}addOrUpdateVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(a=>a.id!==t.id);this.newTicket.visitors=[...s,t]}}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(a=>a.id!==t.id);this.newTicket.visitors=[...s]}}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}async addSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s,t]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i;let s;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{s=await m.facilityAccessApi.ospAccess.createOspAccessTicket({oSPAccessTicketRequest:Gp(this.newTicket)}),this.submissionResult.ticketNumbers=s==null?void 0:s.ticketNumbers}catch(a){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(a,!1),a}try{if(s){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(o=>o.fileName);const{ticketNumbers:a}=s;a!=null&&a.length&&!((i=this.newTicket.attachments)===null||i===void 0)&&i.length&&await Promise.all(this.newTicket.attachments.map(async o=>Promise.all(a.map(async n=>Nt(y.FacilityAccess,o.file,o.fileName,o.fileType,n,this.newTicket.requestType))).then(()=>{var n;k.failedAttachments=((n=this.newTicket.attachments)!==null&&n!==void 0?n:[]).filter(r=>r.fileName!==o.fileName).map(r=>r.fileName)}))),this.newTicket.attachments=void 0}}catch(a){throw k.error.uploadingAttachments=!0,await l(a,!1),a}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await m.facilityAccessApi.ospAccess.updateOspAccessTicket({oSPAccessTicketUpdateRequest:Zp(this.newTicket,this.selectedTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t==null?void 0:t.id]}catch(i){this.submissionResult.state=w.Error,await l(i,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"OSP Access"),this.newTicket.attachments=void 0}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await Ja(t))}catch(i){await l(i,!1)}}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}updateFieldValue(t,i){this.newTicket[t]=i}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeBulkAttachment(){throw new Error("Method not implemented.")}removeAllVisitors(){this.newTicket.visitors=[]}async hasUpdatePermissions(){var t;try{return await wa((t=this.selectedTicket)===null||t===void 0?void 0:t.site)}catch(i){return!1}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.facilityAccessApi.ospAccess.cancellationOspAccessRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getOSPAccessServiceTicket(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}get isNewTicketValid(){const t=this.newTicket.isVisitorContactsDetailsValid,i=this.newTicket.isVisitorEscortedDetailsValid,s=this.newTicket.isVisitorHostValid,a=this.newTicket.isRequestedAccessDetailsValid,o=this.newTicket.isServiceImpactedSectionValid,n=this.newTicket.isNotificationsAttachmentsValid;return t&&i&&s&&a&&o&&n}clear(){this.newTicket=me.newTicket,this.selectedTicket=me.selectedTicket,this.submissionResult=me.submissionResult,this.loadings=me.loadings,this.isEditAttachmentAdded=me.isEditAttachmentAdded}}const Ie=new Wa;function Xp(e){return e.flatMap(t=>t.locations.map(i=>({id:i.id,startDateTime:Be(i.startDate,i.startTime,t.site.siteId),endDateTime:Be(i.endDate,i.endTime,t.site.siteId)})))}async function Ga(e){var t,i,s,a;const{timeZone:o,id:n}=(i=(t=J.sites)===null||t===void 0?void 0:t.find(u=>u.locationId===e.site))!==null&&i!==void 0?i:{},r=n?await ya(n):[],d=new Map(r.map(u=>{var p;return[u.id,(p=u.name)!==null&&p!==void 0?p:u.id]}));return[{site:new Oe(e.site,n,e.accountNumber),locations:(a=(s=e.locations)===null||s===void 0?void 0:s.map(u=>{var p,_,P,b;return{id:u.id,name:d.get(u.id)||u.id,site:n,startDate:u.startDateTime&&o?(p=G(u.startDateTime).tz(o))===null||p===void 0?void 0:p.format(dt):"-",startTime:u.startDateTime&&o?(_=G(u.startDateTime).tz(o))===null||_===void 0?void 0:_.format($t):"-",endDate:u.endDateTime&&o?(P=G(u.endDateTime).tz(o))===null||P===void 0?void 0:P.format(dt):"-",endTime:u.endDateTime&&o?(b=G(u.endDateTime).tz(o))===null||b===void 0?void 0:b.format($t):"-"}}))!==null&&a!==void 0?a:[]}]}async function Qp(e){const[t,i]=await Promise.all([Ke({locationType:F.Site,permissionType:A.POPPOEAccess,permissionPrivilege:e}),Ke({locationType:lt.GreaterThan+F.Site,permissionType:A.POPPOEAccess,permissionPrivilege:e,assignableProcess:"POP_access"})]),s=new Set(i.map(a=>a.siteId));return t.sort((a,o)=>a.siteId>o.siteId?1:-1).map(a=>({...a,hasSpaces:s.has(a.siteId),accountNumber:a.accountNumber}))}const $i=e=>{var t;return(t=e==null?void 0:e.map(i=>{var s,a,o,n,r,d,u,p,_,P,b,C;return{sideAName:(s=i.sideAName)!==null&&s!==void 0?s:"",sideARoomNumber:(a=i.sideARoomNumber)!==null&&a!==void 0?a:"",sideARackNumber:(o=i.sideARackNumber)!==null&&o!==void 0?o:"",sideAPanelNumber:(n=i.sideAPanelNumber)!==null&&n!==void 0?n:"",sideAPort1:(r=i.sideAPort)!==null&&r!==void 0?r:"",sideACarrierCircuitId:(d=i.sideACarrierCircuitID)!==null&&d!==void 0?d:"",sideBName:(u=i.sideZName)!==null&&u!==void 0?u:"",sideBRoomNumber:(p=i.sideZRoomNumber)!==null&&p!==void 0?p:"",sideBRackNumber:(_=i.sideZRackNumber)!==null&&_!==void 0?_:"",sideBPanelNumber:(P=i.sideZPanelNumber)!==null&&P!==void 0?P:"",sideBPort1:(b=i.sideZPort)!==null&&b!==void 0?b:"",sideBCarrierCircuitId:(C=i.sideZCarrierCircuitID)!==null&&C!==void 0?C:""}}))!==null&&t!==void 0?t:[]},Za=e=>!e||e.length===1&&!e[0].rack&&!e[0].cabinet?[]:e.map(t=>{var i,s;return{rack:(i=t.rack)!==null&&i!==void 0?i:"",cabinet:(s=t.cabinet)!==null&&s!==void 0?s:""}}),eh=e=>({accountNumber:e.accountNumber,visitors:e.visitors.map(t=>({firstName:t.firstName,lastName:t.lastName,email:t.email,company:t.company,phone:t.phone,visitorType:t.visitorType})),locations:Xp(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:e.hostFirstName,visitorHostLastName:e.hostLastName,customerExternalReference:e.customerExternalReference,serviceImpactedDescription:e.serviceImpactDescription,serviceDetails:{serviceType:e.serviceType,scope:e.scope,circuits:$i(e.circuits),workDescription:e.descriptionOfWork},ppopSpace:Za(e.ppopSpaces),spopSpace:Za(e.spopSpaces),ppopRoomWork:e.isPpopCableRunOutside?{ppopSpaceFrom:e.ppopFromRackPanel,ppopSpaceTo:e.ppopToRackPanel,cableType:e.ppopCableType,onLadderRack:e.ppopLadderRack,inInnerDuct:e.ppopInnerDuct,inFiberGuide:e.ppopFiberGuide}:void 0,spopRoomWork:e.isSpopCableRunOutside?{spopSpaceFrom:e.spopFromRackPanel,spopSpaceTo:e.spopToRackPanel,cableType:e.spopCableType,onLadderRack:e.spopLadderRack,inInnerDuct:e.spopInnerDuct,inFiberGuide:e.spopFiberGuide}:void 0,notificationRecipients:e.contacts}),Ka=e=>(e==null?void 0:e.map(t=>({sideAName:t.sideAName||"-",sideARoomNumber:t.sideARoomNumber||"-",sideARackNumber:t.sideARackNumber||"-",sideAPanelNumber:t.sideAPanelNumber||"-",sideAPort:t.sideAPort1||"-",sideACarrierCircuitID:t.sideACarrierCircuitId||"-",sideZName:t.sideBName||"-",sideZRoomNumber:t.sideBRoomNumber||"-",sideZRackNumber:t.sideBRackNumber||"-",sideZPanelNumber:t.sideBPanelNumber||"-",sideZPort:t.sideBPort1||"-",sideZCarrierCircuitID:t.sideBCarrierCircuitId||"-"})))||[],Ya=async e=>{var t,i,s,a,o,n,r,d,u,p,_,P,b,C,x,tt,it,st,at,nt,ot;return{id:e.id||"-",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt||"-",updatedOn:e.updatedAt||"-",requestType:"PoP/POE Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",company:e.visitorCompany||"-",visitorType:e.visitorType}],visitorType:e.visitorType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",visitorHostFirstName:e.visitorHostFirstName||"-",visitorHostLastName:e.visitorHostLastName||"-",visitorHostCompany:e.visitorHostCompany||"-",site:e.site||"-",sitesDetails:await Ga(e),customerExternalReference:e.customerExternalReference||"-",isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription||"-",serviceType:((t=e.serviceDetails)===null||t===void 0?void 0:t.serviceType)||"-",scope:((i=e.serviceDetails)===null||i===void 0?void 0:i.scope)||"-",isCrossConnectPatchCableInstallationOrRemoval:!!(!((a=(s=e.serviceDetails)===null||s===void 0?void 0:s.circuits)===null||a===void 0)&&a.length),workDescription:((o=e.serviceDetails)===null||o===void 0?void 0:o.workDescription)||"-",circuits:Ka((n=e.serviceDetails)===null||n===void 0?void 0:n.circuits),ppopSpaces:((r=e.ppopSpace)===null||r===void 0?void 0:r.map(ge=>({rack:ge.rack||"",cabinet:ge.cabinet||""})))||[],spopSpaces:((d=e.spopSpace)===null||d===void 0?void 0:d.map(ge=>({rack:ge.rack||"",cabinet:ge.cabinet||""})))||[],isPpopCableRunOutside:!!e.ppopRoomWork&&Object.keys(e.ppopRoomWork).length>0,ppopFromRackPanel:((u=e.ppopRoomWork)===null||u===void 0?void 0:u.ppopSpaceFrom)||"-",ppopToRackPanel:((p=e.ppopRoomWork)===null||p===void 0?void 0:p.ppopSpaceTo)||"-",ppopCableType:((_=e.ppopRoomWork)===null||_===void 0?void 0:_.cableType)||"-",ppopLadderRack:(P=e.ppopRoomWork)===null||P===void 0?void 0:P.onLadderRack,ppopInnerDuct:(b=e.ppopRoomWork)===null||b===void 0?void 0:b.inInnerDuct,ppopFiberGuide:(C=e.ppopRoomWork)===null||C===void 0?void 0:C.inFiberGuide,isSpopCableRunOutside:!!(e.spopRoomWork&&Object.keys(e.spopRoomWork).length>0),spopFromRackPanel:((x=e.spopRoomWork)===null||x===void 0?void 0:x.spopSpaceFrom)||"-",spopToRackPanel:((tt=e.spopRoomWork)===null||tt===void 0?void 0:tt.spopSpaceTo)||"-",spopCableType:((it=e.spopRoomWork)===null||it===void 0?void 0:it.cableType)||"-",spopLadderRack:(st=e.spopRoomWork)===null||st===void 0?void 0:st.onLadderRack,spopInnerDuct:(at=e.spopRoomWork)===null||at===void 0?void 0:at.inInnerDuct,spopFiberGuide:(nt=e.spopRoomWork)===null||nt===void 0?void 0:nt.inFiberGuide,notificationRecipients:e.notificationRecipients||"",cancellationReason:e.cancellationReason||"-",comments:(ot=e.comments)===null||ot===void 0?void 0:ot.map(ge=>M(ge))}},th=async e=>{var t,i,s,a,o,n,r,d,u,p,_,P,b,C,x,tt,it,st,at,nt,ot,ge,mi,pi,hi;if(e)return{isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0,isVisitorHostValid:!0,isRequestedAccessDetailsValid:!0,isNotificationsAttachmentsValid:!0,isPopRequestedAccessValid:!0,accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",status:e.status,requestType:"PoP/POE Access",category:"",id:e.id,visitors:[{firstName:(i=e.visitorFirstName)!==null&&i!==void 0?i:"",lastName:(s=e.visitorLastName)!==null&&s!==void 0?s:"",email:(a=e.visitorEmail)!==null&&a!==void 0?a:"",company:e.visitorCompany,phone:(o=e.visitorPhone)!==null&&o!==void 0?o:"",visitorType:e.visitorType}],isEscortedVisitor:!0,escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,sitesDetails:await Ga(e),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,customerExternalReference:e.customerExternalReference,isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription,termsAgreed:!0,serviceType:(n=e.serviceDetails)===null||n===void 0?void 0:n.serviceType,scope:(r=e.serviceDetails)===null||r===void 0?void 0:r.scope,isCrossConnectInstallation:!!(!((u=(d=e.serviceDetails)===null||d===void 0?void 0:d.circuits)===null||u===void 0)&&u.length),descriptionOfWork:(p=e.serviceDetails)===null||p===void 0?void 0:p.workDescription,circuits:Ka((_=e.serviceDetails)===null||_===void 0?void 0:_.circuits),ppopSpaces:((P=e.ppopSpace)===null||P===void 0?void 0:P.map(Tt=>({rack:Tt.rack||"",cabinet:Tt.cabinet||""})))||[],spopSpaces:((b=e.spopSpace)===null||b===void 0?void 0:b.map(Tt=>({rack:Tt.rack||"",cabinet:Tt.cabinet||""})))||[],isPpopCableRunOutside:!!e.ppopRoomWork&&Object.keys(e.ppopRoomWork).length>0,ppopFromRackPanel:(C=e.ppopRoomWork)===null||C===void 0?void 0:C.ppopSpaceFrom,ppopToRackPanel:(x=e.ppopRoomWork)===null||x===void 0?void 0:x.ppopSpaceTo,ppopCableType:(tt=e.ppopRoomWork)===null||tt===void 0?void 0:tt.cableType,ppopLadderRack:(it=e.ppopRoomWork)===null||it===void 0?void 0:it.onLadderRack,ppopInnerDuct:(st=e.ppopRoomWork)===null||st===void 0?void 0:st.inInnerDuct,ppopFiberGuide:(at=e.ppopRoomWork)===null||at===void 0?void 0:at.inFiberGuide,isSpopCableRunOutside:!!(e.spopRoomWork&&Object.keys(e.spopRoomWork).length>0),spopFromRackPanel:(nt=e.spopRoomWork)===null||nt===void 0?void 0:nt.spopSpaceFrom,spopToRackPanel:(ot=e.spopRoomWork)===null||ot===void 0?void 0:ot.spopSpaceTo,spopCableType:(ge=e.spopRoomWork)===null||ge===void 0?void 0:ge.cableType,spopLadderRack:(mi=e.spopRoomWork)===null||mi===void 0?void 0:mi.onLadderRack,spopInnerDuct:(pi=e.spopRoomWork)===null||pi===void 0?void 0:pi.inInnerDuct,spopFiberGuide:(hi=e.spopRoomWork)===null||hi===void 0?void 0:hi.inFiberGuide,contacts:e.notificationRecipients,attachments:[]}},ih=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),He=(e,t)=>(e!=null?e:!1)!==(t!=null?t:!1),B=(e,t)=>!(e===t||!e&&!t||!e&&t==="-"),sh=(e,t)=>B(e.sideAName,t.sideAName)||B(e.sideARoomNumber,t.sideARoomNumber)||B(e.sideARackNumber,t.sideARackNumber)||B(e.sideAPanelNumber,t.sideAPanelNumber)||B(e.sideAPort,t.sideAPort)||B(e.sideACarrierCircuitID,t.sideACarrierCircuitID)||B(e.sideZName,t.sideZName)||B(e.sideZRoomNumber,t.sideZRoomNumber)||B(e.sideZRackNumber,t.sideZRackNumber)||B(e.sideZPanelNumber,t.sideZPanelNumber)||B(e.sideZPort,t.sideZPort)||B(e.sideZCarrierCircuitID,t.sideZCarrierCircuitID),ah=(e,t)=>{if(e===void 0)return t.length!==0;if(e.length!==t.length)return!0;for(let i=0;i<e.length;i++)if(sh(e[i],t[i]))return!0;return!1},Xa=(e,t)=>{if(e===void 0&&!(t!=null&&t.length))return!1;if(!e||!t||e.length!==t.length)return!0;for(let i=0;i<e.length;i++)if(B(e[i].rack,t[i].rack)||B(e[i].cabinet,t[i].cabinet))return!0;return!1},nh=(e,t)=>{var i,s;const a={};B(e.visitors[0].company,t.visitors[0].company)&&(a.visitorCompany=e.visitors[0].company),(B(e.escortFirstName,t.escortFirstName)||B(e.escortLastName,t.escortLastName))&&(a.escortFirstName=e.escortFirstName,a.escortLastName=e.escortLastName);const o=((i=e.sitesDetails)===null||i===void 0?void 0:i.flatMap(d=>d.locations.map(u=>({id:u.id,startDate:u.startDate,startTime:u.startTime,endDate:u.endDate,endTime:u.endTime,siteId:d.site.siteId}))))||[],n=((s=t.sitesDetails)===null||s===void 0?void 0:s.flatMap(d=>d.locations))||[],r=o.map(d=>{const u=n.find(_=>_.id===d.id),p={id:d.id};return(!u||B(d.startDate,u.startDate)||B(d.startTime,u.startTime)||B(d.endDate,u.endDate)||B(d.endTime,u.endTime))&&(p.startDateTime=Be(d.startDate,d.startTime,d.siteId),p.endDateTime=Be(d.endDate,d.endTime,d.siteId)),p}).filter(d=>d.startDateTime&&d.endDateTime);if(r.length&&(a.locations=r),(B(e.hostFirstName,t.visitorHostFirstName)||B(e.hostLastName,t.visitorHostLastName))&&(a.visitorHostFirstName=e.hostFirstName,a.visitorHostLastName=e.hostLastName),He(e.isServiceImpacted,t.isServiceImpacted)&&e.isServiceImpacted===!1&&(a.serviceImpactedDescription=""),B(e.serviceImpactDescription,t.serviceImpactDescription)&&(a.serviceImpactedDescription=e.serviceImpactDescription),a.serviceDetails={},B(e.serviceType,t.serviceType))switch(a.serviceDetails.serviceType=e.serviceType,e.serviceType){case We.SiteSurvey:case We.Testing:a.serviceDetails.scope=e.scope,a.serviceDetails.workDescription="",a.serviceDetails.circuits=[];break;case We.InstallationDeInstallationWork:a.serviceDetails.scope="",a.serviceDetails.workDescription=e.descriptionOfWork,a.serviceDetails.circuits=$i(e.circuits);break;default:throw new Error("Unsupported service type for update")}else switch(e.serviceType){case We.SiteSurvey:case We.Testing:B(e.scope,t.scope)&&(a.serviceDetails.scope=e.scope);break;case We.InstallationDeInstallationWork:B(e.descriptionOfWork,t.workDescription)&&(a.serviceDetails.workDescription=e.descriptionOfWork),ah(e.circuits,t.circuits)&&(a.serviceDetails.circuits=$i(e.circuits));break;default:throw new Error("Unsupported service type for update")}return Object.keys(a.serviceDetails).length===0&&delete a.serviceDetails,Xa(e.ppopSpaces,t.ppopSpaces)&&(a.ppopSpace=e.ppopSpaces),Xa(e.spopSpaces,t.spopSpaces)&&(a.spopSpace=e.spopSpaces),e.isPpopCableRunOutside?(a.ppopRoomWork={},B(e.ppopFromRackPanel,t.ppopFromRackPanel)&&(a.ppopRoomWork.ppopSpaceFrom=e.ppopFromRackPanel),B(e.ppopToRackPanel,t.ppopToRackPanel)&&(a.ppopRoomWork.ppopSpaceTo=e.ppopToRackPanel),B(e.ppopCableType,t.ppopCableType)&&(a.ppopRoomWork.cableType=e.ppopCableType),He(e.ppopLadderRack,t.ppopLadderRack)&&(a.ppopRoomWork.onLadderRack=e.ppopLadderRack),He(e.ppopInnerDuct,t.ppopInnerDuct)&&(a.ppopRoomWork.inInnerDuct=e.ppopInnerDuct),He(e.ppopFiberGuide,t.ppopFiberGuide)&&(a.ppopRoomWork.inFiberGuide=e.ppopFiberGuide),Object.keys(a.ppopRoomWork).length===0&&delete a.ppopRoomWork):He(e.isPpopCableRunOutside,t.isPpopCableRunOutside)&&(a.ppopRoomWork=null),e.isSpopCableRunOutside?(a.spopRoomWork={},B(e.spopFromRackPanel,t.spopFromRackPanel)&&(a.spopRoomWork.spopSpaceFrom=e.spopFromRackPanel),B(e.spopToRackPanel,t.spopToRackPanel)&&(a.spopRoomWork.spopSpaceTo=e.spopToRackPanel),B(e.spopCableType,t.spopCableType)&&(a.spopRoomWork.cableType=e.spopCableType),He(e.spopLadderRack,t.spopLadderRack)&&(a.spopRoomWork.onLadderRack=e.spopLadderRack),He(e.spopInnerDuct,t.spopInnerDuct)&&(a.spopRoomWork.inInnerDuct=e.spopInnerDuct),He(e.spopFiberGuide,t.spopFiberGuide)&&(a.spopRoomWork.inFiberGuide=e.spopFiberGuide),Object.keys(a.spopRoomWork).length===0&&delete a.spopRoomWork):He(e.isSpopCableRunOutside,t.isSpopCableRunOutside)&&(a.spopRoomWork=null),B(e.visitors[0].phone,t.visitors[0].phone)&&(a.visitorPhone=e.visitors[0].phone),B(e.customerExternalReference,t.customerExternalReference)&&(a.customerExternalReference=e.customerExternalReference),B(e.contacts,t.notificationRecipients)&&(a.notificationRecipients=e.contacts),Object.keys(a).length===0&&(a.visitorCompany=e.visitors[0].company),a},pe={newTicket:{isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isVisitorHostValid:!1,isRequestedAccessDetailsValid:!1,isPopRequestedAccessValid:!1,isPPopRoomWorkValid:!1,isSPopRoomWorkValid:!1,isNotificationsAttachmentsValid:!1,accountNumber:"",visitors:[],contacts:"",attachments:[],startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard",serviceType:void 0,isEscortedVisitor:!0,escortFirstName:void 0,escortLastName:void 0,hostCompany:void 0,hostFirstName:void 0,hostLastName:void 0,ppopSpaces:[{}],spopSpaces:[{}]},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],popAccessResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Qa{constructor(){this.newTicket=pe.newTicket,this.submissionResult=pe.submissionResult,this.selectedTicket=pe.selectedTicket,this.loadings=pe.loadings,this.isEditAttachmentAdded=pe.isEditAttachmentAdded,se(this)}createTicket(){var t,i;const s=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ne.getUserAccount().accountNumber;this.newTicket={...pe.newTicket,accountNumber:s,requestType:"PoP/POE Access",category:"",serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0},this.submissionResult=pe.submissionResult}async setNewTicket(){try{this.newTicket=await th(this.submissionResult.ticketResponse),this.newTicket||(this.newTicket=pe.newTicket)}catch(t){throw await l(t,!1),t}}async getPOPAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.popAccess.getPopAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Ya(i)}catch(i){throw await l(i,!1),i}}async hasUpdatePermissions(){var t;try{return await fa((t=this.selectedTicket)===null||t===void 0?void 0:t.site)}catch(i){return!1}}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const a=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);a&&(a.visitorHost=i,a.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}addVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(a=>a.id!==t.id);this.newTicket.visitors=[...s,t]}}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(a=>a.id!==t.id);this.newTicket.visitors=[...s]}}addOrUpdateVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(a=>a.id!==t.id);this.newTicket.visitors=[...s,t]}}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(a=>{a.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(a=>{a.endDate=t})})}async addSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s,t]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t;this.resetSubmission();try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;const i=await m.facilityAccessApi.popAccess.createPopAccessTicket({pOPAccessTicketRequest:eh(this.newTicket)}).catch(s=>{throw l(s,!1),this.submissionResult.state=w.Error,s});if(i){const{ticketNumbers:s}=i;s!=null&&s.length&&!((t=this.newTicket.attachments)===null||t===void 0)&&t.length&&await Promise.all(s.map(async a=>{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,a,!1,"PoP/POE Access")})),this.newTicket.attachments=void 0,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=i==null?void 0:i.ticketNumbers}}catch(i){throw await l(i,!1),this.submissionResult.state=w.Error,i}finally{this.loadings.isSubmitting=!1}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.facilityAccessApi.popAccess.cancellationPopAccessRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getPOPAccessServiceTicket(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await m.facilityAccessApi.popAccess.updatePopAccessTicket({pOPAccessTicketUpdateRequest:nh(this.newTicket,this.selectedTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t==null?void 0:t.id]}catch(i){throw this.submissionResult.state=w.Error,await l(i,!1),i}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"PoP/POE Access"),this.newTicket.attachments=[]}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await Ya(t))}catch(i){throw await l(i,!1),i}}finally{this.loadings.isSubmitting=!1}}resetSubmission(){this.submissionResult=pe.submissionResult}clearNewTicket(){this.newTicket=pe.newTicket}clear(){this.newTicket=pe.newTicket,this.selectedTicket=pe.selectedTicket,this.submissionResult=pe.submissionResult}updateFieldValue(t,i){this.newTicket[t]=i}updateIsServiceImpacted(t){this.newTicket.isServiceImpacted=t}updateCustomerExternalReference(t){this.newTicket.customerExternalReference=t}updateServiceImpactDescription(t){this.newTicket.serviceImpactDescription=t}updateServiceType(t){this.newTicket.serviceType=t,t===We.InstallationDeInstallationWork&&this.updateScope(""),this.updateIsCrossConnectInstallation(!1)}updateScope(t){this.newTicket.scope=t}updateDescriptionOfWork(t){this.newTicket.descriptionOfWork=t}updateIsCrossConnectInstallation(t){this.newTicket.isCrossConnectInstallation=t,t?this.newTicket.circuits=[{}]:(this.updateDescriptionOfWork(""),this.newTicket.circuits=void 0)}updateIsPPopCableRunOutside(t){this.newTicket.isPpopCableRunOutside=t,t||(this.newTicket.ppopFromRackPanel=void 0,this.newTicket.ppopToRackPanel=void 0,this.newTicket.ppopCableType=void 0,this.newTicket.ppopLadderRack=void 0,this.newTicket.ppopInnerDuct=void 0,this.newTicket.ppopFiberGuide=void 0)}updateIsSPopCableRunOutside(t){this.newTicket.isSpopCableRunOutside=t,t||(this.newTicket.spopFromRackPanel=void 0,this.newTicket.spopToRackPanel=void 0,this.newTicket.spopCableType=void 0,this.newTicket.spopLadderRack=void 0,this.newTicket.spopInnerDuct=void 0,this.newTicket.spopFiberGuide=void 0)}updateCircuitField(t,i,s){var a;(!this.newTicket.circuits||((a=this.newTicket.circuits)===null||a===void 0?void 0:a.length)===0)&&(this.newTicket.circuits=[{}]);const o=[...this.newTicket.circuits];o[s][i]=t,this.newTicket.circuits=o}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeBulkAttachment(){throw new Error("Method not implemented.")}removeAllVisitors(){this.newTicket.visitors=[]}get isNewTicketValid(){const t=this.newTicket.isVisitorContactsDetailsValid,i=this.newTicket.isVisitorEscortedDetailsValid,s=this.newTicket.isVisitorHostValid,a=this.newTicket.isRequestedAccessDetailsValid,o=this.newTicket.isPopRequestedAccessValid;return t&&i&&s&&a&&o}get isAdditionalComponentValid(){return this.newTicket.isPPopRoomWorkValid&&this.newTicket.isSPopRoomWorkValid&&this.newTicket.isNotificationsAttachmentsValid}}const Se=new Qa;var ei;(function(e){e.PLANNED_MAINTENANCE="Planned Maintenance",e.INCIDENTS="Incidents",e.DCIM_ALERTS="DCIM Alerts",e.SERVICE_TICKETS="Service Tickets"})(ei||(ei={}));const oh=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),M=e=>({comment:e.comment,commentedBy:e.createdBy,commentedOn:e.createdAt});async function rh(e,t,i){var s,a,o,n,r,d,u,p,_,P;let b;switch(e){case y.Deliveries:{const C=await m.deliveriesApi.createDeliveriesComment(Jm(t,i)).catch(x=>{l(x,!1)});b=(s=C==null?void 0:C.comments)===null||s===void 0?void 0:s.map(M),Te.selectedTicket&&(Te.selectedTicket.comments=b);break}case y.Removals:{const C=await m.removalsApi.createComment(np(t,i)).catch(x=>{l(x,!1)});b=(a=C==null?void 0:C.comments)===null||a===void 0?void 0:a.map(M),Ve.selectedTicket&&(Ve.selectedTicket.comments=b);break}case y.RemoteHands:{const C=await m.remoteHandsApi.createRemoteHandsComment(Ym(t,i)).catch(x=>{l(x,!1)});b=(o=C==null?void 0:C.comments)===null||o===void 0?void 0:o.map(M),ce.selectedTicket&&(ce.selectedTicket.comments=b);break}case y.VisitorAccess:{const C=await m.facilityAccessApi.visitorAccess.createVisitorAccessComment(Cp(t,i)).catch(x=>{l(x,!1)});b=(n=C==null?void 0:C.comments)===null||n===void 0?void 0:n.map(M),ie.selectedTicket&&(ie.selectedTicket.comments=b);break}case y.PermanentBadge:{const C=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeComment(Hp(t,i)).catch(x=>{l(x,!1)});b=(r=C==null?void 0:C.comments)===null||r===void 0?void 0:r.map(M),Y.selectedTicket&&(Y.selectedTicket.comments=b);break}case y.CustomerSupport:{const C=await m.customerCareApi.createCustomerCareComment(yp(t,i)).catch(x=>{l(x,!1)});b=(d=C==null?void 0:C.comments)===null||d===void 0?void 0:d.map(M),je.selectedTicket&&(je.selectedTicket.comments=b);break}case y.TroubleTickets:{const C=await m.troubleTicketsApi.createTroubleTicketComment(cp(t,i)).catch(x=>{l(x,!1)});b=(u=C==null?void 0:C.comments)===null||u===void 0?void 0:u.map(M),Ue.selectedTicket&&(Ue.selectedTicket.comments=b);break}case y.OSPAccess:{const C=await m.facilityAccessApi.ospAccess.createOspAccessComment(Yp(t,i)).catch(x=>{l(x,!1)});b=(p=C==null?void 0:C.comments)===null||p===void 0?void 0:p.map(M),Ie.selectedTicket&&(Ie.selectedTicket.comments=b);break}case y.POPPOEAccess:{const C=await m.facilityAccessApi.popAccess.createPopAccessComment(ih(t,i)).catch(x=>{l(x,!1)});b=(_=C==null?void 0:C.comments)===null||_===void 0?void 0:_.map(M),Se.selectedTicket&&(Se.selectedTicket.comments=b);break}case ei.INCIDENTS:{const C=await m.incidentsApi.createIncidentComment(oh(t,i)).catch(x=>{l(x,!1)});b=(P=C==null?void 0:C.comments)===null||P===void 0?void 0:P.map(M);break}default:return}return b}const ch=e=>({subject:e.subject,customerReference:e.customerReferenceNumber,description:e.description,otherNotificationRecipients:e.contacts}),dh=e=>{var t;return{accountNumber:e.accountNumber,subject:e.subject,requestType:e.requestType,category:e.category,locations:!((t=e.location)===null||t===void 0)&&t.id?[e.location.id]:[],customerReference:e.customerReferenceNumber,description:e.description,notificationRecipients:e.contacts}},uh=async e=>{if(e)return{accountNumber:e.accountNumber,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Customer_care"),subject:e.subject,requestType:e.requestType,category:e.category,site:{id:e.site,accountNumber:e.accountNumber},location:{id:e.locations[0],accountNumber:e.accountNumber},customerReferenceNumber:e.customerReference,description:e.description,contacts:e.notificationRecipients}},en=async e=>{var t,i,s,a,o;if(e)return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Customer_care"),subject:e.subject,description:e.description,customerReference:e.customerReference,site:e.site,location:!((t=e.locations)===null||t===void 0)&&t.length?e.locations[0]:"",notificationRecipients:e.notificationRecipients,status:e.status,createdBy:e.createdBy,createdAt:(i=e.createdAt)===null||i===void 0?void 0:i.toISOString(),updatedAt:(s=e.updatedAt)===null||s===void 0?void 0:s.toISOString(),closedAt:(a=e.closedAt)===null||a===void 0?void 0:a.toISOString(),cancellationReason:e.cancellationReason,requestType:e.requestType,category:e.category,comments:(o=e.comments)===null||o===void 0?void 0:o.map(n=>M(n))}},ze={selectedTicket:void 0,ticket:{isValid:!1,subject:"",description:"",site:void 0,requestType:"",category:"",customerReferenceNumber:"",contacts:"",attachments:[],accountNumber:""},submissionResult:{state:w.Default,result:void 0},loadings:{isSubmitting:!1}};class lh{constructor(){this.selectedTicket=ze.selectedTicket,this.ticket=ze.ticket,this.submissionResult=ze.submissionResult,this.loadings=ze.loadings,se(this),Je(this,{name:"customerCare",properties:[],storage:window.localStorage})}async setTicket(){try{this.ticket=await uh(this.submissionResult.result)||ze.ticket}catch(t){throw await l(t,!1),t}}async getSelectedTicket(t){if(t)try{const i=await m.customerCareApi.getCustomerCareTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await en(i),await this.setTicket()}catch(i){throw await l(i,!1),i}}async getCategories(t,i){if(!(!t||!i))try{return await m.customerCareApi.getCustomerCareCategoriesList({site:t,accountNumber:i})}catch(s){throw await l(s,!1),s}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.customerCareApi.cancellationCustomerCareRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}).catch(s=>{throw l(s,!1),s}),await this.getSelectedTicket(this.selectedTicket.id))}finally{k.loadings.isTicketCancelling=!1}}async updateSite(t){this.ticket.site=t,this.ticket.accountNumber=t.accountNumber}async createTicket(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await m.customerCareApi.createCustomerCareTicket({customerCareTicketRequest:dh(this.ticket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&await k.postAttachments(y.CustomerSupport,this.ticket.attachments,this.submissionResult.result.id),this.ticket.attachments=void 0}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async updateTicket(){var t,i;let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await m.customerCareApi.updateCustomerCareTicket({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",customerCareTicketUpdateRequest:ch(this.ticket)}),this.submissionResult.result=s,this.submissionResult.state=w.Submitted}catch(a){throw this.submissionResult.state=w.Error,await l(a,!1),a}try{await k.postAttachments(y.CustomerSupport,this.ticket.attachments,(i=this.selectedTicket)===null||i===void 0?void 0:i.id,!0),this.ticket.attachments=void 0}catch(a){throw await l(a,!1),a}try{s&&(this.selectedTicket=await en(s),await this.setTicket())}catch(a){throw await l(a,!1),a}}finally{this.loadings.isSubmitting=!1}}updateLocation(t){this.ticket.location=t}clear(){this.ticket=ze.ticket,this.selectedTicket=ze.selectedTicket,this.submissionResult=ze.submissionResult,this.loadings=ze.loadings}}const je=new lh,ve=bt` *, ::before, ::after {
1
+ import{__decorate as E}from"tslib";import{css as bt,html as g,LitElement as Rt,nothing as P,svg as Ot}from"lit";import{property as we,customElement as X,state as Ji}from"lit/decorators.js";import G from"moment";import{baseTheme as ua}from"@digital-realty/theme";import he from"moment-timezone";import"date-fns/format.js";import{makeAutoObservable as se}from"mobx";import{makePersistable as Je}from"mobx-persist-store";import{authedUser as ot}from"@digital-realty/ix-account-switcher";import{Router as rt}from"@vaadin/router";import{User as la,UserManager as ma}from"oidc-client-ts";import{MobxLitElement as Ae}from"@adobe/lit-mobx";import{ifDefined as pa}from"lit/directives/if-defined.js";import"@digital-realty/ix-select/ix-select.js";import"@digital-realty/ix-select/ix-select-option.js";import"@digital-realty/ix-icon-button/ix-icon-button.js";import{until as fe}from"lit-html/directives/until.js";import{isPossiblePhoneNumber as ha}from"libphonenumber-js";var vi;(function(e){e.CustomerSupport="customer-support",e.FacilityAccess="facility-access",e.RemoteHands="remote-hands",e.DeliveriesAndRemovals="deliveries-removals",e.TroubleTicket="trouble-ticket"})(vi||(vi={}));var y;(function(e){e.CustomerSupport="customer-support",e.FacilityAccess="facility-access",e.VisitorAccess="visitor-access",e.PermanentBadge="permanent-badge",e.OSPAccess="osp-access",e.POPPOEAccess="pop-poe-access",e.RemoteHands="remote-hands",e.Deliveries="deliveries",e.Removals="removals",e.DeliveriesAndRemovals="deliveries-removals",e.TroubleTickets="trouble-tickets"})(y||(y={}));const va="ticketViewType";var gi;(function(e){e.PlannedWork="Planned Work",e.UrgentWork="Urgent Work"})(gi||(gi={}));var H;(function(e){e.TelxSFDC="TelxSFDC",e.Insite="InSite",e.ServiceNow="ServiceNow"})(H||(H={}));const ct="YYYY-MM-DD",ga="HH:mm:ss",$t="HH:mm",wa="YYYY-MM-DD HH:mm";var w;(function(e){e.Default="default",e.Submitting="submitting",e.Submitted="submitted",e.Error="error"})(w||(w={}));var Q;(function(e){e.Deliveries="deliveries-tickets",e.FacilityAccess="osp-access-tickets",e.TroubleTickets="trouble-tickets",e.RemoteHands="remote-hands-tickets"})(Q||(Q={}));const Wi=[{label:"CSV",extensions:["csv"]},{label:"DOC/X",extensions:["doc","docx"]},{label:"GIF",extensions:["gif"]},{label:"JPG (JPEG)",extensions:["jpg","jpeg"]},{label:"PDF",extensions:["pdf"]},{label:"PNG",extensions:["png"]},{label:"XLS/X",extensions:["xls","xlsx"]}],fa=[{label:"JPG (JPEG)",extensions:["image/jpg","image/jpeg"]},{label:"PDF",extensions:["application/pdf"]},{label:"PNG",extensions:["image/png"]},{label:"GIF",extensions:["image/gif"]}],ka=Wi.flatMap(e=>e.extensions),ya=fa.flatMap(e=>e.extensions),Ta=e=>{var t;return Number((t=e.split("cursor=").pop())===null||t===void 0?void 0:t.split("&")[0])},Gi=async(e,t)=>{const i=await t({...e,cursor:"1"});if(!i)return[];const s=[...i.items];if(i.last&&i.self!==i.last){const n=[];let o=1;o=Ta(i.last);for(let a=2;a<=o;a+=1)n.push(t({...e,cursor:a.toString()}));await Promise.all(n).then(a=>{a.forEach(r=>{r&&s.push(...r.items)})})}return s},ba=e=>{var t,i;return e?"name"in e?((t=e.name)===null||t===void 0?void 0:t.trim())||e.id||"":((i=e.comment)===null||i===void 0?void 0:i.trim())||e.id||"":""},Ra="https://api.digitalrealty.com/service-management/v1".replace(/\/+$/,"");class Zi{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Ra}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ki}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Aa=new Zi;class ni{constructor(t=Aa){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Na(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ni.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Sa(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ia(r.body)||r.body instanceof URLSearchParams||_a(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ni.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function _a(e){return typeof Blob<"u"&&e instanceof Blob}function Ia(e){return typeof FormData<"u"&&e instanceof FormData}class Sa extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Na extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class ne extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function I(e,t){return e[t]!=null}function Ki(e,t=""){return Object.keys(e).map(i=>Yi(i,e[i],t)).filter(i=>i.length>0).join("&")}function Yi(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Yi(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ki(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ne{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Ca{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}const Pa="https://api.digitalrealty.com".replace(/\/+$/,"");class Et{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Pa}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Qi}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const qa=new Et;class kt{constructor(t=qa){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Oa(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?kt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Xi(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ba(r.body)||r.body instanceof URLSearchParams||Da(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}kt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Da(e){return typeof Blob<"u"&&e instanceof Blob}function Ba(e){return typeof FormData<"u"&&e instanceof FormData}class Xi extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Oa extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class $ extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function h(e,t){return e[t]!=null}function Qi(e,t=""){return Object.keys(e).map(i=>es(i,e[i],t)).filter(i=>i.length>0).join("&")}function es(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return es(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Qi(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class j{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class ts{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}class $a extends kt{async getCourierBySiteRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getCourierBySite.");if(t.site===null||t.site===void 0)throw new $("site","Required parameter requestParameters.site was null or undefined when calling getCourierBySite.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/deliveries-removals/courier-companies",method:"GET",headers:n,query:s},i);return new j(o)}async getCourierBySite(t,i){return await(await this.getCourierBySiteRaw(t,i)).value()}}function is(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function ss(e){return Ea(e)}function Ea(e,t){return e==null?e:{message:h(e,"message")?e.message:void 0}}function wi(e){return xa(e)}function xa(e,t){return e==null?e:{createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,comment:h(e,"comment")?e.comment:void 0}}function ns(e){return Fa(e)}function Fa(e,t){return e==null?e:{comments:h(e,"comments")?e.comments.map(wi):void 0}}function La(e){return Va(e)}function Va(e,t){return e==null?e:{deliveryBlocked:h(e,"delivery_blocked")?e.delivery_blocked:void 0}}function as(e){return Ua(e)}function Ua(e,t){return e==null?e:{accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,id:h(e,"id")?e.id:void 0,status:h(e,"status")?e.status:void 0,site:h(e,"site")?e.site:void 0,subject:h(e,"subject")?e.subject:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0}}function Ha(e){return za(e)}function za(e,t){return e==null?e:{deliveryTickets:h(e,"delivery_tickets")?e.delivery_tickets.map(as):void 0,totalCount:h(e,"total_count")?e.total_count:void 0,pageNumber:h(e,"page_number")?e.page_number:void 0,pageSize:h(e,"page_size")?e.page_size:void 0}}function ja(e){if(e!==void 0)return e===null?null:{tracking_number:e.trackingNumber,size_when_oversized:e.sizeWhenOversized,weight_when_overweight:e.weightWhenOverweight,courier_company:e.courierCompany}}function Ma(e){if(e!==void 0)return e===null?null:{id:e.id,tracking_number:e.trackingNumber,number_of_packages:e.numberOfPackages,size_when_oversized:e.sizeWhenOversized,weight_when_overweight:e.weightWhenOverweight,courier_company:e.courierCompany}}function Ja(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,description:e.description,eta_from:e.etaFrom===null?null:e.etaFrom.toISOString().substring(0,10),eta_to:e.etaTo===null?null:e.etaTo.toISOString(),loading_bay_required:e.loadingBayRequired,remote_hands_required:e.remoteHandsRequired,customer_reference:e.customerReference,site:e.site,other_notification_recipients:e.otherNotificationRecipients,packages:e.packages===void 0?void 0:e.packages.map(Ma)}}function Wa(e){return Ga(e)}function Ga(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,trackingNumber:h(e,"tracking_number")?e.tracking_number:void 0,numberOfPackages:h(e,"number_of_packages")?e.number_of_packages:void 0,sizeWhenOversized:h(e,"size_when_oversized")?e.size_when_oversized:void 0,weightWhenOverweight:h(e,"weight_when_overweight")?e.weight_when_overweight:void 0,courierCompany:h(e,"courier_company")?e.courier_company:void 0}}function xt(e){return Za(e)}function Za(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,status:h(e,"status")?e.status:void 0,subject:h(e,"subject")?e.subject:void 0,description:h(e,"description")?e.description:void 0,cancellationReason:h(e,"cancellation_reason")?e.cancellation_reason:void 0,etaFrom:h(e,"eta_from")?e.eta_from===null?null:new Date(e.eta_from):void 0,etaTo:h(e,"eta_to")?e.eta_to===null?null:new Date(e.eta_to):void 0,customerReference:h(e,"customer_reference")?e.customer_reference:void 0,site:h(e,"site")?e.site:void 0,otherNotificationRecipients:h(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0,loadingBayRequired:h(e,"loading_bay_required")?e.loading_bay_required:void 0,remoteHandsRequired:h(e,"remote_hands_required")?e.remote_hands_required:void 0,packages:h(e,"packages")?e.packages.map(Wa):void 0,comments:h(e,"comments")?e.comments.map(wi):void 0}}function Ka(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,eta_from:e.etaFrom===void 0?void 0:e.etaFrom===null?null:e.etaFrom.toISOString(),eta_to:e.etaTo===void 0?void 0:e.etaTo===null?null:e.etaTo.toISOString(),loading_bay_required:e.loadingBayRequired,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Ya(e){return Xa(e)}function Xa(e,t){return e==null?e:{removalTickets:h(e,"removal_tickets")?e.removal_tickets.map(as):void 0,totalCount:h(e,"total_count")?e.total_count:void 0,pageNumber:h(e,"page_number")?e.page_number:void 0,pageSize:h(e,"page_size")?e.page_size:void 0}}function Qa(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,description:e.description,customer_reference:e.customerReference,removal_party:e.removalParty,courier_company:e.courierCompany,tracking_number:e.trackingNumber,pickup_date:e.pickupDate.toISOString(),site:e.site,other_notification_recipients:e.otherNotificationRecipients}}function fi(e){return eo(e)}function eo(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,status:h(e,"status")?e.status:void 0,cancellationReason:h(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:h(e,"subject")?e.subject:void 0,description:h(e,"description")?e.description:void 0,customerReference:h(e,"customer_reference")?e.customer_reference:void 0,removalParty:h(e,"removal_party")?e.removal_party:void 0,courierCompany:h(e,"courier_company")?e.courier_company:void 0,trackingNumber:h(e,"tracking_number")?e.tracking_number:void 0,pickupDate:h(e,"pickup_date")?e.pickup_date:void 0,site:h(e,"site")?e.site:void 0,otherNotificationRecipients:h(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0,comments:h(e,"comments")?e.comments.map(wi):void 0}}function to(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,customer_reference:e.customerReference,courier_company:e.courierCompany,tracking_number:e.trackingNumber,pickup_date:e.pickupDate===void 0?void 0:e.pickupDate===null?null:e.pickupDate.toISOString(),other_notification_recipients:e.otherNotificationRecipients}}function ki(e){return io(e)}function io(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,fileName:h(e,"file_name")?e.file_name:void 0,fileSize:h(e,"file_size")?e.file_size:void 0,contentType:h(e,"content_type")?e.content_type:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0}}function os(e){return so(e)}function so(e,t){return e==null?e:{attachments:h(e,"attachments")?e.attachments.map(ki):void 0}}function rs(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class no extends kt{async cancellationDeliveryRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationDeliveryRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new $("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationDeliveryRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:is(t.cancellationTicketsRequest)},i);return new j(o,a=>ss(a))}async cancellationDeliveryRequest(t,i){return await(await this.cancellationDeliveryRequestRaw(t,i)).value()}async createAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createAttachment.");if(t.fileName===null||t.fileName===void 0)throw new $("fileName","Required parameter requestParameters.fileName was null or undefined when calling createAttachment.");if(t.body===null||t.body===void 0)throw new $("body","Required parameter requestParameters.body was null or undefined when calling createAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new j(o,a=>ki(a))}async createAttachment(t,i){return await(await this.createAttachmentRaw(t,i)).value()}async createDeliveriesCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createDeliveriesComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new $("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createDeliveriesComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:rs(t.ticketCommentsRequest)},i);return new j(o,a=>ns(a))}async createDeliveriesComment(t,i){return await(await this.createDeliveriesCommentRaw(t,i)).value()}async createDeliveryRaw(t,i){if(t.deliveryTicketsRequest===null||t.deliveryTicketsRequest===void 0)throw new $("deliveryTicketsRequest","Required parameter requestParameters.deliveryTicketsRequest was null or undefined when calling createDelivery.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets",method:"POST",headers:n,query:s,body:Ja(t.deliveryTicketsRequest)},i);return new j(o,a=>xt(a))}async createDelivery(t,i){return await(await this.createDeliveryRaw(t,i)).value()}async getDeliveriesRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getDeliveries.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets",method:"GET",headers:n,query:s},i);return new j(o,a=>Ha(a))}async getDeliveries(t,i){return await(await this.getDeliveriesRaw(t,i)).value()}async getDeliveryAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new $("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getDeliveryAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new ts(o)}async getDeliveryAttachmentsById(t,i){return await(await this.getDeliveryAttachmentsByIdRaw(t,i)).value()}async getDeliveryAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>os(a))}async getDeliveryAttachmentsList(t,i){return await(await this.getDeliveryAttachmentsListRaw(t,i)).value()}async getDeliveryByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>xt(a))}async getDeliveryById(t,i){return await(await this.getDeliveryByIdRaw(t,i)).value()}async getDeliveryDiscoveryRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getDeliveryDiscovery.");if(t.site===null||t.site===void 0)throw new $("site","Required parameter requestParameters.site was null or undefined when calling getDeliveryDiscovery.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-discovery",method:"GET",headers:n,query:s},i);return new j(o,a=>La(a))}async getDeliveryDiscovery(t,i){return await(await this.getDeliveryDiscoveryRaw(t,i)).value()}async updateDeliveriesTicketsRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateDeliveriesTickets.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Ka(t.deliveryTicketsUpdateRequest)},i);return new j(o,a=>xt(a))}async updateDeliveriesTickets(t,i){return await(await this.updateDeliveriesTicketsRaw(t,i)).value()}async updateDeliveriesTicketsPackagesRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateDeliveriesTicketsPackages.");if(t.packageId===null||t.packageId===void 0)throw new $("packageId","Required parameter requestParameters.packageId was null or undefined when calling updateDeliveriesTicketsPackages.");if(t.deliveryTicketUpdatePackagesRequest===null||t.deliveryTicketUpdatePackagesRequest===void 0)throw new $("deliveryTicketUpdatePackagesRequest","Required parameter requestParameters.deliveryTicketUpdatePackagesRequest was null or undefined when calling updateDeliveriesTicketsPackages.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/packages/{package_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{package_id}",encodeURIComponent(String(t.packageId))),method:"PATCH",headers:n,query:s,body:ja(t.deliveryTicketUpdatePackagesRequest)},i);return new j(o,a=>xt(a))}async updateDeliveriesTicketsPackages(t,i){return await(await this.updateDeliveriesTicketsPackagesRaw(t,i)).value()}}class ao extends kt{async cancellationRemovalRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationRemovalRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new $("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationRemovalRequest.");const s={},n={};n["Content-Type"]="application/json";const o=await this.request({path:"/removals-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:is(t.cancellationTicketsRequest)},i);return new j(o,a=>ss(a))}async cancellationRemovalRequest(t,i){return await(await this.cancellationRemovalRequestRaw(t,i)).value()}async createCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new $("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:rs(t.ticketCommentsRequest)},i);return new j(o,a=>ns(a))}async createComment(t,i){return await(await this.createCommentRaw(t,i)).value()}async createRemovalRaw(t,i){if(t.removalTicketsRequest===null||t.removalTicketsRequest===void 0)throw new $("removalTicketsRequest","Required parameter requestParameters.removalTicketsRequest was null or undefined when calling createRemoval.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets",method:"POST",headers:n,query:s,body:Qa(t.removalTicketsRequest)},i);return new j(o,a=>fi(a))}async createRemoval(t,i){return await(await this.createRemovalRaw(t,i)).value()}async createRemovalsAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemovalsAttachment.");if(t.fileName===null||t.fileName===void 0)throw new $("fileName","Required parameter requestParameters.fileName was null or undefined when calling createRemovalsAttachment.");if(t.body===null||t.body===void 0)throw new $("body","Required parameter requestParameters.body was null or undefined when calling createRemovalsAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new j(o,a=>ki(a))}async createRemovalsAttachment(t,i){return await(await this.createRemovalsAttachmentRaw(t,i)).value()}async getRemovalByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>fi(a))}async getRemovalById(t,i){return await(await this.getRemovalByIdRaw(t,i)).value()}async getRemovalPartiesRaw(t){const i={},s={};if(this.configuration&&this.configuration.accessToken){const o=this.configuration.accessToken,a=await o("BearerAuth",[]);a&&(s.Authorization=`Bearer ${a}`)}const n=await this.request({path:"/removal-parties",method:"GET",headers:s,query:i},t);return new j(n)}async getRemovalParties(t){return await(await this.getRemovalPartiesRaw(t)).value()}async getRemovalsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets",method:"GET",headers:n,query:s},i);return new j(o,a=>Ya(a))}async getRemovals(t={},i){return await(await this.getRemovalsRaw(t,i)).value()}async getRemovalsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new $("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getRemovalsAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new ts(o)}async getRemovalsAttachmentsById(t,i){return await(await this.getRemovalsAttachmentsByIdRaw(t,i)).value()}async getRemovalsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalsAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>os(a))}async getRemovalsAttachmentsList(t,i){return await(await this.getRemovalsAttachmentsListRaw(t,i)).value()}async updateRemovalByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateRemovalById.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:to(t.removalsTicketsUpdateRequest)},i);return new j(o,a=>fi(a))}async updateRemovalById(t,i){return await(await this.updateRemovalByIdRaw(t,i)).value()}}const oo="https://api.digitalrealty.com/service-management/v1/facility-access".replace(/\/+$/,"");class pt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:oo}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||cs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ro=new pt;class Xe{constructor(t=ro){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new mo(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?Xe.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new lo(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;uo(r.body)||r.body instanceof URLSearchParams||co(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}Xe.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function co(e){return typeof Blob<"u"&&e instanceof Blob}function uo(e){return typeof FormData<"u"&&e instanceof FormData}class lo extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class mo extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class v extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function c(e,t){return e[t]!=null}function cs(e,t=""){return Object.keys(e).map(i=>ds(i,e[i],t)).filter(i=>i.length>0).join("&")}function ds(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return ds(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?cs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class q{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Ft{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function po(e){return ho(e)}function ho(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,accountNumber:c(e,"account_number")?e.account_number:void 0,firstName:c(e,"first_name")?e.first_name:void 0,lastName:c(e,"last_name")?e.last_name:void 0,email:c(e,"email")?e.email:void 0,phone:c(e,"phone")?e.phone:void 0,representingCompany:c(e,"representing_company")?e.representing_company:void 0,badgeStartDate:c(e,"badge_start_date")?new Date(e.badge_start_date):void 0,activeBadge:c(e,"active_badge")?e.active_badge:void 0,terminationRequested:c(e,"termination_requested")?e.termination_requested:void 0}}function vo(e){return go(e)}function go(e,t){return e==null?e:{items:c(e,"items")?e.items.map(po):void 0,totalCount:c(e,"total_count")?e.total_count:void 0}}function Lt(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function Vt(e){return wo(e)}function wo(e,t){return e==null?e:{message:c(e,"message")?e.message:void 0}}function At(e){return fo(e)}function fo(e,t){return e==null?e:{createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,comment:c(e,"comment")?e.comment:void 0}}function Ut(e){return ko(e)}function ko(e,t){return e==null?e:{comments:c(e,"comments")?e.comments.map(At):void 0}}const us={Approved:"Approved",Denied:"Denied"};function Ht(e){if(e!==void 0)return e===null?null:{id:e.id,approval_status:e.approvalStatus}}function yo(e){return To(e)}function To(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0}}function zt(e){return bo(e)}function bo(e,t){return e==null?e:{items:c(e,"items")?e.items.map(yo):void 0}}function Ro(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime===void 0?void 0:e.startDateTime.toISOString(),end_date_time:e.endDateTime===void 0?void 0:e.endDateTime.toISOString()}}function Ao(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,company:e.company,phone:e.phone,visitor_type:e.visitorType}}function _o(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors.map(Ao),locations:e.locations.map(Ro),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,work_description:e.workDescription,notification_recipients:e.notificationRecipients}}function Io(e){return So(e)}function So(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?e.start_date_time:void 0,endDateTime:c(e,"end_date_time")?e.end_date_time:void 0}}function ls(e){return No(e)}function No(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorCompany:c(e,"visitor_company")?e.visitor_company:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitorType:c(e,"visitor_type")?e.visitor_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(Io):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,customerExternalReference:c(e,"customer_external_reference")?e.customer_external_reference:void 0,serviceImpactedDescription:c(e,"service_impacted_description")?e.service_impacted_description:void 0,workDescription:c(e,"work_description")?e.work_description:void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at:void 0,updatedAt:c(e,"updated_at")?e.updated_at:void 0,closedAt:c(e,"closed_at")?e.closed_at:void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function Co(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime===void 0?void 0:e.startDateTime.toISOString(),end_date_time:e.endDateTime===void 0?void 0:e.endDateTime.toISOString()}}function Po(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,visitor_company:e.visitorCompany,escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,locations:e.locations===void 0?void 0:e.locations.map(Co),visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,work_description:e.workDescription,other_notification_recipients:e.otherNotificationRecipients}}function qo(e){return Do(e)}function Do(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?new Date(e.start_date_time):void 0,endDateTime:c(e,"end_date_time")?new Date(e.end_date_time):void 0}}function Bo(e){return Oo(e)}function Oo(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(qo):void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function $o(e){return Eo(e)}function Eo(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Bo):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function xo(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime.toISOString(),end_date_time:e.endDateTime.toISOString()}}function Fo(e){if(e!==void 0)return e===null?null:{ppop_space_from:e.ppopSpaceFrom,ppop_space_to:e.ppopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function ms(e){return Lo(e)}function Lo(e,t){return e==null?e:{rack:c(e,"rack")?e.rack:void 0,cabinet:c(e,"cabinet")?e.cabinet:void 0}}function ps(e){if(e!==void 0)return e===null?null:{rack:e.rack,cabinet:e.cabinet}}function Vo(e){if(e!==void 0)return e===null?null:{side_a_name:e.sideAName,side_a_room_number:e.sideARoomNumber,side_a_rack_number:e.sideARackNumber,side_a_panel_number:e.sideAPanelNumber,side_a_port_1:e.sideAPort1,side_a_carrier_circuit_id:e.sideACarrierCircuitId,side_b_name:e.sideBName,side_b_room_number:e.sideBRoomNumber,side_b_rack_number:e.sideBRackNumber,side_b_panel_number:e.sideBPanelNumber,side_b_port_1:e.sideBPort1,side_b_carrier_circuit_id:e.sideBCarrierCircuitId}}function Uo(e){if(e!==void 0)return e===null?null:{service_type:e.serviceType,scope:e.scope,circuits:e.circuits===void 0?void 0:e.circuits.map(Vo),work_description:e.workDescription}}function Ho(e){if(e!==void 0)return e===null?null:{spop_space_from:e.spopSpaceFrom,spop_space_to:e.spopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function zo(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,company:e.company,phone:e.phone,visitor_type:e.visitorType}}function jo(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors.map(zo),locations:e.locations.map(xo),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,service_details:Uo(e.serviceDetails),ppop_space:e.ppopSpace===void 0?void 0:e.ppopSpace.map(ps),spop_space:e.spopSpace===void 0?void 0:e.spopSpace.map(ps),ppop_room_work:Fo(e.ppopRoomWork),spop_room_work:Ho(e.spopRoomWork),notification_recipients:e.notificationRecipients}}function Mo(e){return Jo(e)}function Jo(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?e.start_date_time:void 0,endDateTime:c(e,"end_date_time")?e.end_date_time:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function Wo(e){return Go(e)}function Go(e,t){return e==null?e:{ppopSpaceFrom:c(e,"ppop_space_from")?e.ppop_space_from:void 0,ppopSpaceTo:c(e,"ppop_space_to")?e.ppop_space_to:void 0,cableType:c(e,"cable_type")?e.cable_type:void 0,onLadderRack:c(e,"on_ladder_rack")?e.on_ladder_rack:void 0,inInnerDuct:c(e,"in_inner_duct")?e.in_inner_duct:void 0,inFiberGuide:c(e,"in_fiber_guide")?e.in_fiber_guide:void 0}}function Zo(e){return Ko(e)}function Ko(e,t){return e==null?e:{sideAName:c(e,"side_a_name")?e.side_a_name:void 0,sideARoomNumber:c(e,"side_a_room_number")?e.side_a_room_number:void 0,sideARackNumber:c(e,"side_a_rack_number")?e.side_a_rack_number:void 0,sideAPanelNumber:c(e,"side_a_panel_number")?e.side_a_panel_number:void 0,sideAPort1:c(e,"side_a_port_1")?e.side_a_port_1:void 0,sideACarrierCircuitId:c(e,"side_a_carrier_circuit_id")?e.side_a_carrier_circuit_id:void 0,sideBName:c(e,"side_b_name")?e.side_b_name:void 0,sideBRoomNumber:c(e,"side_b_room_number")?e.side_b_room_number:void 0,sideBRackNumber:c(e,"side_b_rack_number")?e.side_b_rack_number:void 0,sideBPanelNumber:c(e,"side_b_panel_number")?e.side_b_panel_number:void 0,sideBPort1:c(e,"side_b_port_1")?e.side_b_port_1:void 0,sideBCarrierCircuitId:c(e,"side_b_carrier_circuit_id")?e.side_b_carrier_circuit_id:void 0}}const We={SiteSurvey:"Site Survey",Testing:"Testing",InstallationDeInstallationWork:"Installation/De-installation Work"};function Yo(e){return Xo(e)}function Xo(e,t){return e==null?e:{serviceType:c(e,"service_type")?e.service_type:void 0,scope:c(e,"scope")?e.scope:void 0,circuits:c(e,"circuits")?e.circuits.map(Zo):void 0,workDescription:c(e,"work_description")?e.work_description:void 0}}function Qo(e){return er(e)}function er(e,t){return e==null?e:{spopSpaceFrom:c(e,"spop_space_from")?e.spop_space_from:void 0,spopSpaceTo:c(e,"spop_space_to")?e.spop_space_to:void 0,cableType:c(e,"cable_type")?e.cable_type:void 0,onLadderRack:c(e,"on_ladder_rack")?e.on_ladder_rack:void 0,inInnerDuct:c(e,"in_inner_duct")?e.in_inner_duct:void 0,inFiberGuide:c(e,"in_fiber_guide")?e.in_fiber_guide:void 0}}function hs(e){return tr(e)}function tr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorCompany:c(e,"visitor_company")?e.visitor_company:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitorType:c(e,"visitor_type")?e.visitor_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(Mo):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,visitorHostCompany:c(e,"visitor_host_company")?e.visitor_host_company:void 0,customerExternalReference:c(e,"customer_external_reference")?e.customer_external_reference:void 0,serviceImpactedDescription:c(e,"service_impacted_description")?e.service_impacted_description:void 0,serviceDetails:c(e,"service_details")?Yo(e.service_details):void 0,ppopSpace:c(e,"ppop_space")?e.ppop_space.map(ms):void 0,spopSpace:c(e,"spop_space")?e.spop_space.map(ms):void 0,ppopRoomWork:c(e,"ppop_room_work")?Wo(e.ppop_room_work):void 0,spopRoomWork:c(e,"spop_room_work")?Qo(e.spop_room_work):void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at:void 0,updatedAt:c(e,"updated_at")?e.updated_at:void 0,closedAt:c(e,"closed_at")?e.closed_at:void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function ir(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime.toISOString(),end_date_time:e.endDateTime.toISOString()}}function sr(e){if(e!==void 0)return e===null?null:{ppop_space_from:e.ppopSpaceFrom,ppop_space_to:e.ppopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function vs(e){if(e!==void 0)return e===null?null:{id:e.id,rack:e.rack,cabinet:e.cabinet}}function nr(e){if(e!==void 0)return e===null?null:{id:e.id,side_a_name:e.sideAName,side_a_room_number:e.sideARoomNumber,side_a_rack_number:e.sideARackNumber,side_a_panel_number:e.sideAPanelNumber,side_a_port_1:e.sideAPort1,side_a_carrier_circuit_id:e.sideACarrierCircuitId,side_b_name:e.sideBName,side_b_room_number:e.sideBRoomNumber,side_b_rack_number:e.sideBRackNumber,side_b_panel_number:e.sideBPanelNumber,side_b_port_1:e.sideBPort1,side_b_carrier_circuit_id:e.sideBCarrierCircuitId}}function ar(e){if(e!==void 0)return e===null?null:{service_type:e.serviceType,scope:e.scope,circuits:e.circuits===void 0?void 0:e.circuits.map(nr),work_description:e.workDescription}}function or(e){if(e!==void 0)return e===null?null:{spop_space_from:e.spopSpaceFrom,spop_space_to:e.spopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function rr(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,visitor_company:e.visitorCompany,service_impacted_description:e.serviceImpactedDescription,locations:e.locations===void 0?void 0:e.locations.map(ir),service_details:ar(e.serviceDetails),ppop_space:e.ppopSpace===void 0?void 0:e.ppopSpace.map(vs),spop_space:e.spopSpace===void 0?void 0:e.spopSpace.map(vs),ppop_room_work:sr(e.ppopRoomWork),spop_room_work:or(e.spopRoomWork),customer_external_reference:e.customerExternalReference,notification_recipients:e.notificationRecipients}}function cr(e){return dr(e)}function dr(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?new Date(e.start_date_time):void 0,endDateTime:c(e,"end_date_time")?new Date(e.end_date_time):void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function ur(e){return lr(e)}function lr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(cr):void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function mr(e){return pr(e)}function pr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(ur):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function hr(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10),operation:e.operation}}function vr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_id:e.badgeholderId,badge_start_date:e.badgeStartDate.toISOString().substring(0,10),badge_end_date:e.badgeEndDate===void 0?void 0:e.badgeEndDate.toISOString().substring(0,10),locations:e.locations===void 0?void 0:e.locations.map(hr),notification_recipients:e.notificationRecipients}}function gr(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10)}}function wr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_first_name:e.badgeholderFirstName,badgeholder_last_name:e.badgeholderLastName,badgeholder_email:e.badgeholderEmail,badgeholder_company:e.badgeholderCompany,badgeholder_phone:e.badgeholderPhone,badge_start_date:e.badgeStartDate.toISOString().substring(0,10),badge_end_date:e.badgeEndDate===void 0?void 0:e.badgeEndDate.toISOString().substring(0,10),locations:e.locations===void 0?void 0:e.locations.map(gr),notification_recipients:e.notificationRecipients}}function fr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_id:e.badgeholderId,badge_end_date:e.badgeEndDate.toISOString().substring(0,10),notification_recipients:e.notificationRecipients}}function gs(e){return kr(e)}function kr(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,site:c(e,"site")?e.site:void 0,siteAddress:c(e,"site_address")?e.site_address:void 0,startDate:c(e,"start_date")?e.start_date:void 0,endDate:c(e,"end_date")?e.end_date:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function ws(e){return yr(e)}function yr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,badgeholderFirstName:c(e,"badgeholder_first_name")?e.badgeholder_first_name:void 0,badgeholderLastName:c(e,"badgeholder_last_name")?e.badgeholder_last_name:void 0,badgeholderEmail:c(e,"badgeholder_email")?e.badgeholder_email:void 0,badgeholderPhone:c(e,"badgeholder_phone")?e.badgeholder_phone:void 0,badgeholderCompany:c(e,"badgeholder_company")?e.badgeholder_company:void 0,requestType:c(e,"request_type")?e.request_type:void 0,badgeStartDate:c(e,"badge_start_date")?e.badge_start_date:void 0,badgeEndDate:c(e,"badge_end_date")?e.badge_end_date:void 0,locations:c(e,"locations")?e.locations.map(gs):void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function Tr(e){if(e!==void 0)return e===null?null:{other_notification_recipients:e.otherNotificationRecipients}}function br(e){return Rr(e)}function Rr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,badgeholderEmail:c(e,"badgeholder_email")?e.badgeholder_email:void 0,requestType:c(e,"request_type")?e.request_type:void 0,locations:c(e,"locations")?e.locations.map(gs):void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function Ar(e){return _r(e)}function _r(e,t){return e==null?e:{items:c(e,"items")?e.items.map(br):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function _t(e){return Ir(e)}function Ir(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,fileName:c(e,"file_name")?e.file_name:void 0,fileSize:c(e,"file_size")?e.file_size:void 0,contentType:c(e,"content_type")?e.content_type:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at===null?null:new Date(e.created_at):void 0}}function jt(e){return Sr(e)}function Sr(e,t){return e==null?e:{attachments:c(e,"attachments")?e.attachments.map(_t):void 0}}function Mt(e){if(e!==void 0)return e===null?null:{comment:e.comment}}function ht(e){return Nr(e)}function Nr(e,t){return e==null?e:{ticketNumbers:c(e,"ticket_numbers")?e.ticket_numbers:void 0}}function Cr(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10)}}function Pr(e){if(e!==void 0)return e===null?null:{site_code:e.siteCode,visitor_host_id:e.visitorHostId,locations:e.locations===void 0?void 0:e.locations.map(Cr)}}function qr(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone}}const Jt={Escorted:"Escorted",Standard:"Standard",Extended:"Extended"};function Dr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors===void 0?void 0:e.visitors.map(qr),visit_start_date:e.visitStartDate.toISOString().substring(0,10),visit_end_date:e.visitEndDate.toISOString().substring(0,10),visit_type:e.visitType,sites:e.sites===void 0?void 0:e.sites.map(Pr),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,representing_company:e.representingCompany,description:e.description,notification_recipients:e.notificationRecipients}}function fs(e){return Br(e)}function Br(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDate:c(e,"start_date")?e.start_date:void 0,endDate:c(e,"end_date")?e.end_date:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function ks(e){return Or(e)}function Or(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitStartDate:c(e,"visit_start_date")?e.visit_start_date:void 0,visitEndDate:c(e,"visit_end_date")?e.visit_end_date:void 0,visitType:c(e,"visit_type")?e.visit_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(fs):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,representingCompany:c(e,"representing_company")?e.representing_company:void 0,description:c(e,"description")?e.description:void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function $r(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,other_notification_recipients:e.otherNotificationRecipients}}function Er(e){return xr(e)}function xr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(fs):void 0,visitType:c(e,"visit_type")?e.visit_type:void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Fr(e){return Lr(e)}function Lr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Er):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function Vr(e){return Ur(e)}function Ur(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,firstName:c(e,"first_name")?e.first_name:void 0,lastName:c(e,"last_name")?e.last_name:void 0}}function Hr(e){return zr(e)}function zr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Vr):void 0,totalCount:c(e,"total_count")?e.total_count:void 0}}class jr extends Xe{async cancellationOspAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationOspAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationOspAccessRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationOspAccessRequest(t,i){return await(await this.cancellationOspAccessRequestRaw(t,i)).value()}async createOspAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createOspAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createOspAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createOspAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createOspAccessAttachment(t,i){return await(await this.createOspAccessAttachmentRaw(t,i)).value()}async createOspAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createOspAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createOspAccessComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createOspAccessComment(t,i){return await(await this.createOspAccessCommentRaw(t,i)).value()}async createOspAccessTicketRaw(t,i){if(t.oSPAccessTicketRequest===null||t.oSPAccessTicketRequest===void 0)throw new v("oSPAccessTicketRequest","Required parameter requestParameters.oSPAccessTicketRequest was null or undefined when calling createOspAccessTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets",method:"POST",headers:n,query:s,body:_o(t.oSPAccessTicketRequest)},i);return new q(o,a=>ht(a))}async createOspAccessTicket(t,i){return await(await this.createOspAccessTicketRaw(t,i)).value()}async getOspAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getOspAccessAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getOspAccessAttachmentsById(t,i){return await(await this.getOspAccessAttachmentsByIdRaw(t,i)).value()}async getOspAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getOspAccessAttachmentsList(t,i){return await(await this.getOspAccessAttachmentsListRaw(t,i)).value()}async getOspAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>ls(a))}async getOspAccessTicketById(t,i){return await(await this.getOspAccessTicketByIdRaw(t,i)).value()}async getOspAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/osp-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>$o(a))}async getOspAccessTickets(t={},i){return await(await this.getOspAccessTicketsRaw(t,i)).value()}async updateOspAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateOspAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updateOspAccessLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updateOspAccessLocationsTicket(t,i){return await(await this.updateOspAccessLocationsTicketRaw(t,i)).value()}async updateOspAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateOspAccessTicket.");if(t.oSPAccessTicketUpdateRequest===null||t.oSPAccessTicketUpdateRequest===void 0)throw new v("oSPAccessTicketUpdateRequest","Required parameter requestParameters.oSPAccessTicketUpdateRequest was null or undefined when calling updateOspAccessTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Po(t.oSPAccessTicketUpdateRequest)},i);return new q(o,a=>ls(a))}async updateOspAccessTicket(t,i){return await(await this.updateOspAccessTicketRaw(t,i)).value()}}class Mr extends Xe{async cancellationPopAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationPopAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationPopAccessRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationPopAccessRequest(t,i){return await(await this.cancellationPopAccessRequestRaw(t,i)).value()}async createPopAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPopAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createPopAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createPopAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createPopAccessAttachment(t,i){return await(await this.createPopAccessAttachmentRaw(t,i)).value()}async createPopAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPopAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createPopAccessComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createPopAccessComment(t,i){return await(await this.createPopAccessCommentRaw(t,i)).value()}async createPopAccessTicketRaw(t,i){if(t.pOPAccessTicketRequest===null||t.pOPAccessTicketRequest===void 0)throw new v("pOPAccessTicketRequest","Required parameter requestParameters.pOPAccessTicketRequest was null or undefined when calling createPopAccessTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets",method:"POST",headers:n,query:s,body:jo(t.pOPAccessTicketRequest)},i);return new q(o,a=>ht(a))}async createPopAccessTicket(t,i){return await(await this.createPopAccessTicketRaw(t,i)).value()}async getPopAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPopAccessAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getPopAccessAttachmentsById(t,i){return await(await this.getPopAccessAttachmentsByIdRaw(t,i)).value()}async getPopAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getPopAccessAttachmentsList(t,i){return await(await this.getPopAccessAttachmentsListRaw(t,i)).value()}async getPopAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>hs(a))}async getPopAccessTicketById(t,i){return await(await this.getPopAccessTicketByIdRaw(t,i)).value()}async getPopAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/pop-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>mr(a))}async getPopAccessTickets(t={},i){return await(await this.getPopAccessTicketsRaw(t,i)).value()}async updatePopAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePopAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updatePopAccessLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updatePopAccessLocationsTicket(t,i){return await(await this.updatePopAccessLocationsTicketRaw(t,i)).value()}async updatePopAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePopAccessTicket.");if(t.pOPAccessTicketUpdateRequest===null||t.pOPAccessTicketUpdateRequest===void 0)throw new v("pOPAccessTicketUpdateRequest","Required parameter requestParameters.pOPAccessTicketUpdateRequest was null or undefined when calling updatePopAccessTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:rr(t.pOPAccessTicketUpdateRequest)},i);return new q(o,a=>hs(a))}async updatePopAccessTicket(t,i){return await(await this.updatePopAccessTicketRaw(t,i)).value()}}class Jr extends Xe{async cancellationPermanentBadgeRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationPermanentBadgeRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationPermanentBadgeRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationPermanentBadgeRequest(t,i){return await(await this.cancellationPermanentBadgeRequestRaw(t,i)).value()}async createPermanentBadegeAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPermanentBadegeAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createPermanentBadegeAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createPermanentBadegeAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createPermanentBadegeAttachment(t,i){return await(await this.createPermanentBadegeAttachmentRaw(t,i)).value()}async createPermanentBadgeCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPermanentBadgeComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createPermanentBadgeComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createPermanentBadgeComment(t,i){return await(await this.createPermanentBadgeCommentRaw(t,i)).value()}async createPermanentBadgeModifyTicketRaw(t,i){if(t.permanentBadgeAccessModifyTicketRequest===null||t.permanentBadgeAccessModifyTicketRequest===void 0)throw new v("permanentBadgeAccessModifyTicketRequest","Required parameter requestParameters.permanentBadgeAccessModifyTicketRequest was null or undefined when calling createPermanentBadgeModifyTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-modify-tickets",method:"POST",headers:n,query:s,body:vr(t.permanentBadgeAccessModifyTicketRequest)},i);return new q(o,a=>ht(a))}async createPermanentBadgeModifyTicket(t,i){return await(await this.createPermanentBadgeModifyTicketRaw(t,i)).value()}async createPermanentBadgeNewTicketRaw(t,i){if(t.permanentBadgeAccessNewTicketRequest===null||t.permanentBadgeAccessNewTicketRequest===void 0)throw new v("permanentBadgeAccessNewTicketRequest","Required parameter requestParameters.permanentBadgeAccessNewTicketRequest was null or undefined when calling createPermanentBadgeNewTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-new-tickets",method:"POST",headers:n,query:s,body:wr(t.permanentBadgeAccessNewTicketRequest)},i);return new q(o,a=>ht(a))}async createPermanentBadgeNewTicket(t,i){return await(await this.createPermanentBadgeNewTicketRaw(t,i)).value()}async createPermanentBadgeTerminateTicketRaw(t,i){if(t.permanentBadgeAccessTerminateTicketRequest===null||t.permanentBadgeAccessTerminateTicketRequest===void 0)throw new v("permanentBadgeAccessTerminateTicketRequest","Required parameter requestParameters.permanentBadgeAccessTerminateTicketRequest was null or undefined when calling createPermanentBadgeTerminateTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-terminate-tickets",method:"POST",headers:n,query:s,body:fr(t.permanentBadgeAccessTerminateTicketRequest)},i);return new q(o,a=>ht(a))}async createPermanentBadgeTerminateTicket(t,i){return await(await this.createPermanentBadgeTerminateTicketRaw(t,i)).value()}async getPermanentBadgeAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPermanentBadgeAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getPermanentBadgeAttachmentsById(t,i){return await(await this.getPermanentBadgeAttachmentsByIdRaw(t,i)).value()}async getPermanentBadgeAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getPermanentBadgeAttachmentsList(t,i){return await(await this.getPermanentBadgeAttachmentsListRaw(t,i)).value()}async getPermanentBadgeHoldersListRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new v("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getPermanentBadgeHoldersList.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.activeBadge!==void 0&&(s.active_badge=t.activeBadge),t.nameOrEmailContains!==void 0&&(s.name_or_email_contains=t.nameOrEmailContains),t.page!==void 0&&(s.page=t.page),t.size!==void 0&&(s.size=t.size);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/badge-holders",method:"GET",headers:n,query:s},i);return new q(o,a=>vo(a))}async getPermanentBadgeHoldersList(t,i){return await(await this.getPermanentBadgeHoldersListRaw(t,i)).value()}async getPermanentBadgeTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>ws(a))}async getPermanentBadgeTicketById(t,i){return await(await this.getPermanentBadgeTicketByIdRaw(t,i)).value()}async getPermanentBadgeTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/permanent-badge-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>Ar(a))}async getPermanentBadgeTickets(t={},i){return await(await this.getPermanentBadgeTicketsRaw(t,i)).value()}async updatePermanentBadgeLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePermanentBadgeLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updatePermanentBadgeLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updatePermanentBadgeLocationsTicket(t,i){return await(await this.updatePermanentBadgeLocationsTicketRaw(t,i)).value()}async updatePermanentBadgeTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePermanentBadgeTicket.");if(t.permanentBadgeAccessTicketUpdateRequest===null||t.permanentBadgeAccessTicketUpdateRequest===void 0)throw new v("permanentBadgeAccessTicketUpdateRequest","Required parameter requestParameters.permanentBadgeAccessTicketUpdateRequest was null or undefined when calling updatePermanentBadgeTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Tr(t.permanentBadgeAccessTicketUpdateRequest)},i);return new q(o,a=>ws(a))}async updatePermanentBadgeTicket(t,i){return await(await this.updatePermanentBadgeTicketRaw(t,i)).value()}}class Wr extends Xe{async cancellationVisitorAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationVisitorAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationVisitorAccessRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationVisitorAccessRequest(t,i){return await(await this.cancellationVisitorAccessRequestRaw(t,i)).value()}async createVisitorAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createVisitorAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createVisitorAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createVisitorAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createVisitorAccessAttachment(t,i){return await(await this.createVisitorAccessAttachmentRaw(t,i)).value()}async createVisitorAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createVisitorAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createVisitorAccessComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createVisitorAccessComment(t,i){return await(await this.createVisitorAccessCommentRaw(t,i)).value()}async createVisitorAccessTicketRaw(t,i){if(t.visitorAccessTicketRequest===null||t.visitorAccessTicketRequest===void 0)throw new v("visitorAccessTicketRequest","Required parameter requestParameters.visitorAccessTicketRequest was null or undefined when calling createVisitorAccessTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets",method:"POST",headers:n,query:s,body:Dr(t.visitorAccessTicketRequest)},i);return new q(o,a=>ht(a))}async createVisitorAccessTicket(t,i){return await(await this.createVisitorAccessTicketRaw(t,i)).value()}async getVisitorAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getVisitorAccessAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getVisitorAccessAttachmentsById(t,i){return await(await this.getVisitorAccessAttachmentsByIdRaw(t,i)).value()}async getVisitorAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getVisitorAccessAttachmentsList(t,i){return await(await this.getVisitorAccessAttachmentsListRaw(t,i)).value()}async getVisitorAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>ks(a))}async getVisitorAccessTicketById(t,i){return await(await this.getVisitorAccessTicketByIdRaw(t,i)).value()}async getVisitorAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/visitor-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>Fr(a))}async getVisitorAccessTickets(t={},i){return await(await this.getVisitorAccessTicketsRaw(t,i)).value()}async updateVisitorAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateVisitorAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updateVisitorAccessLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updateVisitorAccessLocationsTicket(t,i){return await(await this.updateVisitorAccessLocationsTicketRaw(t,i)).value()}async updateVisitorAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateVisitorAccessTicket.");if(t.visitorAccessTicketUpdateRequest===null||t.visitorAccessTicketUpdateRequest===void 0)throw new v("visitorAccessTicketUpdateRequest","Required parameter requestParameters.visitorAccessTicketUpdateRequest was null or undefined when calling updateVisitorAccessTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:$r(t.visitorAccessTicketUpdateRequest)},i);return new q(o,a=>ks(a))}async updateVisitorAccessTicket(t,i){return await(await this.updateVisitorAccessTicketRaw(t,i)).value()}}class Gr extends Xe{async getVisitorHostsListRaw(t,i){if(t.site===null||t.site===void 0)throw new v("site","Required parameter requestParameters.site was null or undefined when calling getVisitorHostsList.");const s={};t.site!==void 0&&(s.site=t.site),t.nameOrEmailContains!==void 0&&(s.name_or_email_contains=t.nameOrEmailContains),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-hosts",method:"GET",headers:n,query:s},i);return new q(o,a=>Hr(a))}async getVisitorHostsList(t,i){return await(await this.getVisitorHostsListRaw(t,i)).value()}}const Zr="http://localhost".replace(/\/+$/,"");class Wt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Zr}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||ys}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Kr=new Wt;class Bt{constructor(t=Kr){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new ec(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?Bt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Qr(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Xr(r.body)||r.body instanceof URLSearchParams||Yr(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}Bt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Yr(e){return typeof Blob<"u"&&e instanceof Blob}function Xr(e){return typeof FormData<"u"&&e instanceof FormData}class Qr extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class ec extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class yi extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function f(e,t){return e[t]!=null}function ys(e,t=""){return Object.keys(e).map(i=>Ts(i,e[i],t)).filter(i=>i.length>0).join("&")}function Ts(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Ts(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?ys(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class It{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}const tc="https://service-management.digitalrealty.com".replace(/\/+$/,"");class Gt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:tc}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||bs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ic=new Gt;class yt{constructor(t=ic){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new oc(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?yt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new ac(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;nc(r.body)||r.body instanceof URLSearchParams||sc(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}yt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function sc(e){return typeof Blob<"u"&&e instanceof Blob}function nc(e){return typeof FormData<"u"&&e instanceof FormData}class ac extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class oc extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class dt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function Ge(e,t){return e[t]!=null}function bs(e,t=""){return Object.keys(e).map(i=>Rs(i,e[i],t)).filter(i=>i.length>0).join("&")}function Rs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Rs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?bs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ti{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class rc{constructor(t){this.raw=t}async value(){return await this.raw.text()}}const cc="https://service-management.digitalrealty.com".replace(/\/+$/,"");class As{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:cc}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||_s}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const dc=new As;class ai{constructor(t=dc){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new pc(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ai.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new mc(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;lc(r.body)||r.body instanceof URLSearchParams||uc(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ai.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function uc(e){return typeof Blob<"u"&&e instanceof Blob}function lc(e){return typeof FormData<"u"&&e instanceof FormData}class mc extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class pc extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class ee extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function _(e,t){return e[t]!=null}function _s(e,t=""){return Object.keys(e).map(i=>Is(i,e[i],t)).filter(i=>i.length>0).join("&")}function Is(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Is(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?_s(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ce{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class hc{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function vc(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function gc(e){return wc(e)}function wc(e,t){return e==null?e:{message:_(e,"message")?e.message:void 0}}function fc(e){return kc(e)}function kc(e,t){return e==null?e:{requestType:_(e,"request_type")?e.request_type:void 0,categories:_(e,"categories")?e.categories:void 0}}function yc(e){return Tc(e)}function Tc(e,t){return e==null?e:{items:_(e,"items")?e.items.map(fc):void 0}}function Ss(e){return bc(e)}function bc(e,t){return e==null?e:{createdBy:_(e,"created_by")?e.created_by:void 0,createdAt:_(e,"created_at")?new Date(e.created_at):void 0,comment:_(e,"comment")?e.comment:void 0}}function Rc(e){return Ac(e)}function Ac(e,t){return e==null?e:{comments:_(e,"comments")?e.comments.map(Ss):void 0}}function _c(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,request_type:e.requestType,category:e.category,subject:e.subject,description:e.description,expected_start:e.expectedStart===void 0?void 0:e.expectedStart===null?null:e.expectedStart.toISOString(),customer_reference:e.customerReference,locations:e.locations,reference_ticket:e.referenceTicket,other_notification_recipients:e.otherNotificationRecipients}}function bi(e){return Ic(e)}function Ic(e,t){return e==null?e:{ticketId:_(e,"ticket_id")?e.ticket_id:void 0,accountNumber:_(e,"account_number")?e.account_number:void 0,accountName:_(e,"account_name")?e.account_name:void 0,status:_(e,"status")?e.status:void 0,cancellationReason:_(e,"cancellation_reason")?e.cancellation_reason:void 0,site:_(e,"site")?e.site:void 0,locations:_(e,"locations")?e.locations:void 0,requestType:_(e,"request_type")?e.request_type:void 0,category:_(e,"category")?e.category:void 0,subject:_(e,"subject")?e.subject:void 0,description:_(e,"description")?e.description:void 0,expectedStart:_(e,"expected_start")?e.expected_start===null?null:new Date(e.expected_start):void 0,referenceTicket:_(e,"reference_ticket")?e.reference_ticket:void 0,customerReference:_(e,"customer_reference")?e.customer_reference:void 0,otherNotificationRecipients:_(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:_(e,"created_by")?e.created_by:void 0,createdAt:_(e,"created_at")?new Date(e.created_at):void 0,updatedAt:_(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:_(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:_(e,"comments")?e.comments.map(Ss):void 0}}function Sc(e){return Nc(e)}function Nc(e,t){return e==null?e:{accountNumber:_(e,"account_number")?e.account_number:void 0,accountName:_(e,"account_name")?e.account_name:void 0,id:_(e,"id")?e.id:void 0,status:_(e,"status")?e.status:void 0,site:_(e,"site")?e.site:void 0,locations:_(e,"locations")?e.locations:void 0,description:_(e,"description")?e.description:void 0,subject:_(e,"subject")?e.subject:void 0,createdBy:_(e,"created_by")?e.created_by:void 0,updatedAt:_(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:_(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Cc(e){return Pc(e)}function Pc(e,t){return e==null?e:{remoteHandsTickets:_(e,"remote_hands_tickets")?e.remote_hands_tickets.map(Sc):void 0,totalCount:_(e,"total_count")?e.total_count:void 0,pageNumber:_(e,"page_number")?e.page_number:void 0,pageSize:_(e,"page_size")?e.page_size:void 0}}function qc(e){if(e!==void 0)return e===null?null:{customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Ns(e){return Dc(e)}function Dc(e,t){return e==null?e:{id:_(e,"id")?e.id:void 0,fileName:_(e,"file_name")?e.file_name:void 0,fileSize:_(e,"file_size")?e.file_size:void 0,contentType:_(e,"content_type")?e.content_type:void 0,createdBy:_(e,"created_by")?e.created_by:void 0,createdAt:_(e,"created_at")?e.created_at===null?null:new Date(e.created_at):void 0}}function Bc(e){return Oc(e)}function Oc(e,t){return e==null?e:{attachments:_(e,"attachments")?e.attachments.map(Ns):void 0}}function $c(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class Ec extends ai{async cancellationRemoteHandsRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationRemoteHandsRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new ee("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationRemoteHandsRequest.");const s={},n={};n["Content-Type"]="application/json";const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:vc(t.cancellationTicketsRequest)},i);return new Ce(o,a=>gc(a))}async cancellationRemoteHandsRequest(t,i){return await(await this.cancellationRemoteHandsRequestRaw(t,i)).value()}async createRemoteHandsAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemoteHandsAttachment.");if(t.fileName===null||t.fileName===void 0)throw new ee("fileName","Required parameter requestParameters.fileName was null or undefined when calling createRemoteHandsAttachment.");if(t.body===null||t.body===void 0)throw new ee("body","Required parameter requestParameters.body was null or undefined when calling createRemoteHandsAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new Ce(o,a=>Ns(a))}async createRemoteHandsAttachment(t,i){return await(await this.createRemoteHandsAttachmentRaw(t,i)).value()}async createRemoteHandsCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemoteHandsComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new ee("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createRemoteHandsComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:$c(t.ticketCommentsRequest)},i);return new Ce(o,a=>Rc(a))}async createRemoteHandsComment(t,i){return await(await this.createRemoteHandsCommentRaw(t,i)).value()}async createRemoteHandsTicketRaw(t,i){if(t.remoteHandsRequest===null||t.remoteHandsRequest===void 0)throw new ee("remoteHandsRequest","Required parameter requestParameters.remoteHandsRequest was null or undefined when calling createRemoteHandsTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets",method:"POST",headers:n,query:s,body:_c(t.remoteHandsRequest)},i);return new Ce(o,a=>bi(a))}async createRemoteHandsTicket(t,i){return await(await this.createRemoteHandsTicketRaw(t,i)).value()}async getRemoteHandsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new ee("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getRemoteHandsAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new hc(o)}async getRemoteHandsAttachmentsById(t,i){return await(await this.getRemoteHandsAttachmentsByIdRaw(t,i)).value()}async getRemoteHandsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ce(o,a=>Bc(a))}async getRemoteHandsAttachmentsList(t,i){return await(await this.getRemoteHandsAttachmentsListRaw(t,i)).value()}async getRemoteHandsCategoriesListRaw(t,i){if(t.site===null||t.site===void 0)throw new ee("site","Required parameter requestParameters.site was null or undefined when calling getRemoteHandsCategoriesList.");const s={};t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/categories",method:"GET",headers:n,query:s},i);return new Ce(o,a=>yc(a))}async getRemoteHandsCategoriesList(t,i){return await(await this.getRemoteHandsCategoriesListRaw(t,i)).value()}async getRemoteHandsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ce(o,a=>bi(a))}async getRemoteHandsTicketById(t,i){return await(await this.getRemoteHandsTicketByIdRaw(t,i)).value()}async getRemoteHandsTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/remote-hands-tickets",method:"GET",headers:n,query:s},i);return new Ce(o,a=>Cc(a))}async getRemoteHandsTickets(t={},i){return await(await this.getRemoteHandsTicketsRaw(t,i)).value()}async updateRemoteHandsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateRemoteHandsTicketById.");if(t.remoteHandsUpdateRequest===null||t.remoteHandsUpdateRequest===void 0)throw new ee("remoteHandsUpdateRequest","Required parameter requestParameters.remoteHandsUpdateRequest was null or undefined when calling updateRemoteHandsTicketById.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:qc(t.remoteHandsUpdateRequest)},i);return new Ce(o,a=>bi(a))}async updateRemoteHandsTicketById(t,i){return await(await this.updateRemoteHandsTicketByIdRaw(t,i)).value()}}function xc(e){return Fc(e)}function Fc(e,t){return e==null?e:{serviceManagement:f(e,"service_management")?e.service_management:void 0,remoteHands:f(e,"remote_hands")?e.remote_hands:void 0,deliveries:f(e,"deliveries")?e.deliveries:void 0,removals:f(e,"removals")?e.removals:void 0,facilitiesAccess:f(e,"facilities_access")?e.facilities_access:void 0,temporaryAccess:f(e,"temporary_access")?e.temporary_access:void 0,inventory:f(e,"inventory")?e.inventory:void 0,orderHistory:f(e,"order_history")?e.order_history:void 0,precabling:f(e,"precabling")?e.precabling:void 0,crossConnect:f(e,"cross_connect")?e.cross_connect:void 0,customerEquipmentConnection:f(e,"customer_equipment_connection")?e.customer_equipment_connection:void 0,virtualConnectivity:f(e,"virtual_connectivity")?e.virtual_connectivity:void 0,customerCare:f(e,"customer_care")?e.customer_care:void 0,troubleTickets:f(e,"trouble_tickets")?e.trouble_tickets:void 0}}function Lc(e){return Vc(e)}function Vc(e,t){return e==null?e:{name:f(e,"name")?e.name:void 0,privilegeLevel:f(e,"privilege_level")?e.privilege_level:void 0}}function Uc(e){return Hc(e)}function Hc(e,t){return e==null?e:{id:e.id,accountNumber:e.account_number,siteId:e.site_id,floor:f(e,"floor")?e.floor:void 0,room:f(e,"room")?e.room:void 0,cage:f(e,"cage")?e.cage:void 0,rack:f(e,"rack")?e.rack:void 0,row:f(e,"row")?e.row:void 0,locationType:e.location_type,csrDemarcation:e.csr_demarcation,comment:f(e,"comment")?e.comment:void 0,dcimEnabled:f(e,"dcim_enabled")?e.dcim_enabled:void 0,permissions:f(e,"permissions")?e.permissions.map(Lc):void 0,assignableProcesses:f(e,"assignable_processes")?xc(e.assignable_processes):void 0}}function zc(e){return jc(e)}function jc(e,t){return e==null?e:{self:f(e,"self")?e.self:void 0,first:f(e,"first")?e.first:void 0,prev:f(e,"prev")?e.prev:void 0,next:f(e,"next")?e.next:void 0,last:f(e,"last")?e.last:void 0,items:e.items.map(Uc)}}function Mc(e){return Jc(e)}function Jc(e,t){return e==null?e:{count:e.count}}function Cs(e){return Wc(e)}function Wc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,locationId:f(e,"location_id")?e.location_id:void 0,name:f(e,"name")?e.name:void 0,campus:f(e,"campus")?e.campus:void 0,metroArea:f(e,"metro_area")?e.metro_area:void 0,region:f(e,"region")?e.region:void 0,regionName:f(e,"region_name")?e.region_name:void 0,country:f(e,"country")?e.country:void 0,addressCountry:f(e,"address_country")?e.address_country:void 0,addressLocality:f(e,"address_locality")?e.address_locality:void 0,addressRegion:f(e,"address_region")?e.address_region:void 0,postalCode:f(e,"postal_code")?e.postal_code:void 0,streetAddress:f(e,"street_address")?e.street_address:void 0,peeringdbFacilityId:f(e,"peeringdb_facility_id")?e.peeringdb_facility_id:void 0,organisationName:f(e,"organisation_name")?e.organisation_name:void 0,timeZone:f(e,"time_zone")?e.time_zone:void 0,latitude:f(e,"latitude")?e.latitude:void 0,longitude:f(e,"longitude")?e.longitude:void 0,locations:f(e,"locations")?Mc(e.locations):void 0}}function Gc(e){return Zc(e)}function Zc(e,t){return e==null?e:{self:f(e,"self")?e.self:void 0,first:f(e,"first")?e.first:void 0,prev:f(e,"prev")?e.prev:void 0,next:f(e,"next")?e.next:void 0,last:f(e,"last")?e.last:void 0,items:e.items.map(Cs)}}function Kc(e){return Yc(e)}function Yc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,name:f(e,"name")?e.name:void 0,description:f(e,"description")?e.description:void 0}}function Xc(e){return Qc(e)}function Qc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,name:f(e,"name")?e.name:void 0,description:f(e,"description")?e.description:void 0}}class ed extends Bt{async getLocationsRaw(t,i){const s={};t.sort!==void 0&&(s.sort=t.sort),t.cursor!==void 0&&(s.cursor=t.cursor),t.pageSize!==void 0&&(s.page_size=t.pageSize),t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.id!==void 0&&(s.id=t.id),t.siteId!==void 0&&(s.site_id=t.siteId),t.floor!==void 0&&(s.floor=t.floor),t.room!==void 0&&(s.room=t.room),t.cage!==void 0&&(s.cage=t.cage),t.rack!==void 0&&(s.rack=t.rack),t.row!==void 0&&(s.row=t.row),t.demarcation!==void 0&&(s.demarcation=t.demarcation),t.locationType!==void 0&&(s.location_type=t.locationType),t.embed!==void 0&&(s.embed=t.embed),t.permissionType!==void 0&&(s.permission_type=t.permissionType),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege),t.dcimEnabled!==void 0&&(s.dcim_enabled=t.dcimEnabled),t.assignableProcess!==void 0&&(s.assignable_process=t.assignableProcess);const n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/locations",method:"GET",headers:n,query:s},i);return new It(o,a=>zc(a))}async getLocations(t={},i){return await(await this.getLocationsRaw(t,i)).value()}}class Ps extends Bt{async getOspsBySiteIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new yi("siteId","Required parameter requestParameters.siteId was null or undefined when calling getOspsBySiteId.");const s={},n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}/osps".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:n,query:s},i);return new It(o,a=>a.map(Kc))}async getOspsBySiteId(t,i){return await(await this.getOspsBySiteIdRaw(t,i)).value()}async getPopsBySiteIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new yi("siteId","Required parameter requestParameters.siteId was null or undefined when calling getPopsBySiteId.");const s={},n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}/pops".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:n,query:s},i);return new It(o,a=>a.map(Xc))}async getPopsBySiteId(t,i){return await(await this.getPopsBySiteIdRaw(t,i)).value()}async getSiteByIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new yi("siteId","Required parameter requestParameters.siteId was null or undefined when calling getSiteById.");const s={},n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:n,query:s},i);return new It(o,a=>Cs(a))}async getSiteById(t,i){return await(await this.getSiteByIdRaw(t,i)).value()}async getSitesRaw(t,i){const s={};t.name!==void 0&&(s.name=t.name),t.sort!==void 0&&(s.sort=t.sort),t.cursor!==void 0&&(s.cursor=t.cursor),t.pageSize!==void 0&&(s.page_size=t.pageSize),t.showMySites!==void 0&&(s.show_my_sites=t.showMySites),t.embed!==void 0&&(s.embed=t.embed);const n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites",method:"GET",headers:n,query:s},i);return new It(o,a=>Gc(a))}async getSites(t={},i){return await(await this.getSitesRaw(t,i)).value()}}const td="https://api.digitalrealty.com".replace(/\/+$/,"");class qs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:td}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ds}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const id=new qs;class oi{constructor(t=id){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new od(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?oi.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new ad(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;nd(r.body)||r.body instanceof URLSearchParams||sd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}oi.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function sd(e){return typeof Blob<"u"&&e instanceof Blob}function nd(e){return typeof FormData<"u"&&e instanceof FormData}class ad extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class od extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class Zt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function T(e,t){return e[t]!=null}function Ds(e,t=""){return Object.keys(e).map(i=>Bs(i,e[i],t)).filter(i=>i.length>0).join("&")}function Bs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Bs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ds(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ri{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Os{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}const rd="https://api.digitalrealty.com/service-management/v1".replace(/\/+$/,"");class $s{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:rd}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Es}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const cd=new $s;class ri{constructor(t=cd){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new md(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ri.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new ld(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;ud(r.body)||r.body instanceof URLSearchParams||dd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ri.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function dd(e){return typeof Blob<"u"&&e instanceof Blob}function ud(e){return typeof FormData<"u"&&e instanceof FormData}class ld extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class md extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class vt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function D(e,t){return e[t]!=null}function Es(e,t=""){return Object.keys(e).map(i=>xs(i,e[i],t)).filter(i=>i.length>0).join("&")}function xs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return xs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Es(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Kt{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Fs{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function Ls(e){return pd(e)}function pd(e,t){return e==null?e:{createdBy:D(e,"created_by")?e.created_by:void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,comment:D(e,"comment")?e.comment:void 0}}function hd(e){return vd(e)}function vd(e,t){return e==null?e:{comments:D(e,"comments")?e.comments.map(Ls):void 0}}function Vs(e){return gd(e)}function gd(e,t){return e==null?e:{id:D(e,"id")?e.id:void 0,fileName:D(e,"file_name")?e.file_name:void 0}}function wd(e){return fd(e)}function fd(e,t){return e==null?e:{accountNumber:D(e,"account_number")?e.account_number:void 0,accountName:D(e,"account_name")?e.account_name:void 0,id:D(e,"id")?e.id:void 0,status:D(e,"status")?e.status:void 0,subject:D(e,"subject")?e.subject:void 0,site:D(e,"site")?e.site:void 0,priority:D(e,"priority")?e.priority:void 0,comments:D(e,"comments")?e.comments.map(Ls):void 0,attachments:D(e,"attachments")?e.attachments.map(Vs):void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,updatedAt:D(e,"updated_at")?new Date(e.updated_at):void 0}}function kd(e){return yd(e)}function yd(e,t){return e==null?e:{accountNumber:D(e,"account_number")?e.account_number:void 0,accountName:D(e,"account_name")?e.account_name:void 0,id:D(e,"id")?e.id:void 0,status:D(e,"status")?e.status:void 0,subject:D(e,"subject")?e.subject:void 0,site:D(e,"site")?e.site:void 0,priority:D(e,"priority")?e.priority:void 0,attachments:D(e,"attachments")?e.attachments.map(Vs):void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,updatedAt:D(e,"updated_at")?new Date(e.updated_at):void 0}}function Td(e){return bd(e)}function bd(e,t){return e==null?e:{items:D(e,"items")?e.items.map(kd):void 0,totalCount:D(e,"total_count")?e.total_count:void 0,pageNumber:D(e,"page_number")?e.page_number:void 0,pageSize:D(e,"page_size")?e.page_size:void 0}}function Rd(e){return Ad(e)}function Ad(e,t){return e==null?e:{id:D(e,"id")?e.id:void 0,fileName:D(e,"file_name")?e.file_name:void 0,fileSize:D(e,"file_size")?e.file_size:void 0,contentType:D(e,"content_type")?e.content_type:void 0,createdBy:D(e,"created_by")?e.created_by:void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0}}function _d(e){return Id(e)}function Id(e,t){return e==null?e:{attachments:D(e,"attachments")?e.attachments.map(Rd):void 0}}function Sd(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class Nd extends ri{async createIncidentCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createIncidentComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new vt("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createIncidentComment.");const s={},n={};n["Content-Type"]="application/json";const o=await this.request({path:"/incident-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Sd(t.ticketCommentsRequest)},i);return new Kt(o,a=>hd(a))}async createIncidentComment(t,i){return await(await this.createIncidentCommentRaw(t,i)).value()}async downloadIncidentTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={},o=await this.request({path:"/incident-tickets/file",method:"GET",headers:n,query:s},i);return new Fs(o)}async downloadIncidentTickets(t={},i){return await(await this.downloadIncidentTicketsRaw(t,i)).value()}async getIncidentsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new vt("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getIncidentsAttachmentsById.");const s={},n={},o=await this.request({path:"/incident-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Fs(o)}async getIncidentsAttachmentsById(t,i){return await(await this.getIncidentsAttachmentsByIdRaw(t,i)).value()}async getIncidentsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsAttachmentsList.");const s={},n={},o=await this.request({path:"/incident-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Kt(o,a=>_d(a))}async getIncidentsAttachmentsList(t,i){return await(await this.getIncidentsAttachmentsListRaw(t,i)).value()}async getIncidentsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsTicketById.");const s={},n={},o=await this.request({path:"/incident-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Kt(o,a=>wd(a))}async getIncidentsTicketById(t,i){return await(await this.getIncidentsTicketByIdRaw(t,i)).value()}async getIncidentsTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={},o=await this.request({path:"/incident-tickets",method:"GET",headers:n,query:s},i);return new Kt(o,a=>Td(a))}async getIncidentsTickets(t={},i){return await(await this.getIncidentsTicketsRaw(t,i)).value()}}const Cd="http://localhost".replace(/\/+$/,"");class Us{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Cd}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||zs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Pd=new Us;class ci{constructor(t=Pd){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Od(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ci.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Bd(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Dd(r.body)||r.body instanceof URLSearchParams||qd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ci.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function qd(e){return typeof Blob<"u"&&e instanceof Blob}function Dd(e){return typeof FormData<"u"&&e instanceof FormData}class Bd extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Od extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class Hs extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function Pe(e,t){return e[t]!=null}function zs(e,t=""){return Object.keys(e).map(i=>js(i,e[i],t)).filter(i=>i.length>0).join("&")}function js(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return js(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?zs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class $d{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}const Ed="http://localhost".replace(/\/+$/,"");class Ms{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Ed}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ws}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const xd=new Ms;class di{constructor(t=xd){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Ud(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?di.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Vd(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ld(r.body)||r.body instanceof URLSearchParams||Fd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}di.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Fd(e){return typeof Blob<"u"&&e instanceof Blob}function Ld(e){return typeof FormData<"u"&&e instanceof FormData}class Vd extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Ud extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}function Js(e,t){return e[t]!=null}function Ws(e,t=""){return Object.keys(e).map(i=>Gs(i,e[i],t)).filter(i=>i.length>0).join("&")}function Gs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Gs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ws(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Zs{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}function Hd(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function zd(e){return jd(e)}function jd(e,t){return e==null?e:{message:I(e,"message")?e.message:void 0}}function Md(e){return Jd(e)}function Jd(e,t){return e==null?e:{requestType:I(e,"request_type")?e.request_type:void 0,categories:I(e,"categories")?e.categories:void 0}}function Wd(e){return Gd(e)}function Gd(e,t){return e==null?e:{items:I(e,"items")?e.items.map(Md):void 0}}function Ks(e){return Zd(e)}function Zd(e,t){return e==null?e:{createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,comment:I(e,"comment")?e.comment:void 0}}function Kd(e){return Yd(e)}function Yd(e,t){return e==null?e:{comments:I(e,"comments")?e.comments.map(Ks):void 0}}function Xd(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,request_type:e.requestType,category:e.category,locations:e.locations,customer_reference:e.customerReference,description:e.description,notification_recipients:e.notificationRecipients}}function Ai(e){return Qd(e)}function Qd(e,t){return e==null?e:{accountNumber:I(e,"account_number")?e.account_number:void 0,accountName:I(e,"account_name")?e.account_name:void 0,id:I(e,"id")?e.id:void 0,status:I(e,"status")?e.status:void 0,cancellationReason:I(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:I(e,"subject")?e.subject:void 0,requestType:I(e,"request_type")?e.request_type:void 0,category:I(e,"category")?e.category:void 0,site:I(e,"site")?e.site:void 0,locations:I(e,"locations")?e.locations:void 0,customerReference:I(e,"customer_reference")?e.customer_reference:void 0,description:I(e,"description")?e.description:void 0,notificationRecipients:I(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,updatedAt:I(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:I(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:I(e,"comments")?e.comments.map(Ks):void 0}}function eu(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function tu(e){return iu(e)}function iu(e,t){return e==null?e:{accountNumber:I(e,"account_number")?e.account_number:void 0,accountName:I(e,"account_name")?e.account_name:void 0,id:I(e,"id")?e.id:void 0,status:I(e,"status")?e.status:void 0,subject:I(e,"subject")?e.subject:void 0,site:I(e,"site")?e.site:void 0,locations:I(e,"locations")?e.locations:void 0,description:I(e,"description")?e.description:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,updatedAt:I(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:I(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function su(e){return nu(e)}function nu(e,t){return e==null?e:{items:I(e,"items")?e.items.map(tu):void 0,totalCount:I(e,"total_count")?e.total_count:void 0,pageNumber:I(e,"page_number")?e.page_number:void 0,pageSize:I(e,"page_size")?e.page_size:void 0}}function Ys(e){return au(e)}function au(e,t){return e==null?e:{id:I(e,"id")?e.id:void 0,fileName:I(e,"file_name")?e.file_name:void 0,fileSize:I(e,"file_size")?e.file_size:void 0,contentType:I(e,"content_type")?e.content_type:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0}}function ou(e){return ru(e)}function ru(e,t){return e==null?e:{attachments:I(e,"attachments")?e.attachments.map(Ys):void 0}}function cu(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class du extends ni{async cancellationCustomerCareRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationCustomerCareRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new ne("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationCustomerCareRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Hd(t.cancellationTicketsRequest)},i);return new Ne(o,a=>zd(a))}async cancellationCustomerCareRequest(t,i){return await(await this.cancellationCustomerCareRequestRaw(t,i)).value()}async createCustomerCareCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createCustomerCareComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new ne("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createCustomerCareComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:cu(t.ticketCommentsRequest)},i);return new Ne(o,a=>Kd(a))}async createCustomerCareComment(t,i){return await(await this.createCustomerCareCommentRaw(t,i)).value()}async createCustomerCareTicketRaw(t,i){if(t.customerCareTicketRequest===null||t.customerCareTicketRequest===void 0)throw new ne("customerCareTicketRequest","Required parameter requestParameters.customerCareTicketRequest was null or undefined when calling createCustomerCareTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets",method:"POST",headers:n,query:s,body:Xd(t.customerCareTicketRequest)},i);return new Ne(o,a=>Ai(a))}async createCustomerCareTicket(t,i){return await(await this.createCustomerCareTicketRaw(t,i)).value()}async createCustomerCareTicketAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createCustomerCareTicketAttachment.");if(t.fileName===null||t.fileName===void 0)throw new ne("fileName","Required parameter requestParameters.fileName was null or undefined when calling createCustomerCareTicketAttachment.");if(t.body===null||t.body===void 0)throw new ne("body","Required parameter requestParameters.body was null or undefined when calling createCustomerCareTicketAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new Ne(o,a=>Ys(a))}async createCustomerCareTicketAttachment(t,i){return await(await this.createCustomerCareTicketAttachmentRaw(t,i)).value()}async getCustomerCareCategoriesListRaw(t,i){const s={};t.site!==void 0&&(s.site=t.site),t.accountNumber!==void 0&&(s.account_number=t.accountNumber);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/categories",method:"GET",headers:n,query:s},i);return new Ne(o,a=>Wd(a))}async getCustomerCareCategoriesList(t={},i){return await(await this.getCustomerCareCategoriesListRaw(t,i)).value()}async getCustomerCareTicketAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new ne("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getCustomerCareTicketAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ca(o)}async getCustomerCareTicketAttachmentsById(t,i){return await(await this.getCustomerCareTicketAttachmentsByIdRaw(t,i)).value()}async getCustomerCareTicketAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ne(o,a=>ou(a))}async getCustomerCareTicketAttachmentsList(t,i){return await(await this.getCustomerCareTicketAttachmentsListRaw(t,i)).value()}async getCustomerCareTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ne(o,a=>Ai(a))}async getCustomerCareTicketById(t,i){return await(await this.getCustomerCareTicketByIdRaw(t,i)).value()}async getCustomerCareTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/customer-care-tickets",method:"GET",headers:n,query:s},i);return new Ne(o,a=>su(a))}async getCustomerCareTickets(t={},i){return await(await this.getCustomerCareTicketsRaw(t,i)).value()}async updateCustomerCareTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateCustomerCareTicket.");if(t.customerCareTicketUpdateRequest===null||t.customerCareTicketUpdateRequest===void 0)throw new ne("customerCareTicketUpdateRequest","Required parameter requestParameters.customerCareTicketUpdateRequest was null or undefined when calling updateCustomerCareTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:eu(t.customerCareTicketUpdateRequest)},i);return new Ne(o,a=>Ai(a))}async updateCustomerCareTicket(t,i){return await(await this.updateCustomerCareTicketRaw(t,i)).value()}}function uu(e){return lu(e)}function lu(e,t){return e==null?e:{requestType:Ge(e,"request_type")?e.request_type:void 0,categories:Ge(e,"categories")?e.categories:void 0}}function mu(e){return pu(e)}function pu(e,t){return e==null?e:{mappedRequestType:Ge(e,"mapped_request_type")?e.mapped_request_type:void 0,canonicalValue:Ge(e,"canonical_value")?e.canonical_value:void 0,mappedValue:Ge(e,"mapped_value")?e.mapped_value:void 0,isActive:Ge(e,"is_active")?e.is_active:void 0}}function hu(e){return vu(e)}function vu(e,t){return e==null?e:{requestType:Ge(e,"request_type")?e.request_type:void 0,categories:Ge(e,"categories")?e.categories.map(mu):void 0}}class gu extends yt{async getRequestTypesAndCategoriesRaw(t,i){if(t.serviceTicketType===null||t.serviceTicketType===void 0)throw new dt("serviceTicketType","Required parameter requestParameters.serviceTicketType was null or undefined when calling getRequestTypesAndCategories.");if(t.accountNumber===null||t.accountNumber===void 0)throw new dt("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getRequestTypesAndCategories.");if(t.site===null||t.site===void 0)throw new dt("site","Required parameter requestParameters.site was null or undefined when calling getRequestTypesAndCategories.");if(t.requestType===null||t.requestType===void 0)throw new dt("requestType","Required parameter requestParameters.requestType was null or undefined when calling getRequestTypesAndCategories.");const s={};t.serviceTicketType!==void 0&&(s.service_ticket_type=t.serviceTicketType),t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.requestType!==void 0&&(s.request_type=t.requestType);const n={},o=await this.request({path:"/categories",method:"GET",headers:n,query:s},i);return new Ti(o,a=>a.map(uu))}async getRequestTypesAndCategories(t,i){return await(await this.getRequestTypesAndCategoriesRaw(t,i)).value()}}class wu extends yt{async getRequestTypeCategoryMappingsRaw(t,i){if(t.serviceTicketType===null||t.serviceTicketType===void 0)throw new dt("serviceTicketType","Required parameter requestParameters.serviceTicketType was null or undefined when calling getRequestTypeCategoryMappings.");if(t.serviceManagementSystem===null||t.serviceManagementSystem===void 0)throw new dt("serviceManagementSystem","Required parameter requestParameters.serviceManagementSystem was null or undefined when calling getRequestTypeCategoryMappings.");const s={};t.serviceTicketType!==void 0&&(s.service_ticket_type=t.serviceTicketType),t.serviceManagementSystem!==void 0&&(s.service_management_system=t.serviceManagementSystem),t.siteCode!==void 0&&(s.site_code=t.siteCode);const n={},o=await this.request({path:"/requestTypeCategoryMappings",method:"GET",headers:n,query:s},i);return new Ti(o,a=>a.map(hu))}async getRequestTypeCategoryMappings(t,i){return await(await this.getRequestTypeCategoryMappingsRaw(t,i)).value()}}const fu={CustomerEnquiries:"customer_enquiries",RemoteHands:"remote_hands",CustomerCare:"customer_care",TroubleTickets:"trouble_tickets"};class ku extends yt{async getTermsRaw(t,i){if(t.service===null||t.service===void 0)throw new dt("service","Required parameter requestParameters.service was null or undefined when calling getTerms.");const s={},n={},o=await this.request({path:"/{service}/terms".replace("{service}",encodeURIComponent(String(t.service))),method:"GET",headers:n,query:s},i);return this.isJsonMime(o.headers.get("content-type"))?new Ti(o):new rc(o)}async getTerms(t,i){return await(await this.getTermsRaw(t,i)).value()}}const yu="https://api.digitalrealty.com".replace(/\/+$/,"");class Xs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:yu}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Qs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Tu=new Xs;class ui{constructor(t=Tu){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new _u(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ui.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Au(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ru(r.body)||r.body instanceof URLSearchParams||bu(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ui.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function bu(e){return typeof Blob<"u"&&e instanceof Blob}function Ru(e){return typeof FormData<"u"&&e instanceof FormData}class Au extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class _u extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}function V(e,t){return e[t]!=null}function Qs(e,t=""){return Object.keys(e).map(i=>en(i,e[i],t)).filter(i=>i.length>0).join("&")}function en(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return en(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Qs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Iu{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Su{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function Nu(e){return Cu(e)}function Cu(e,t){return e==null?e:{id:V(e,"id")?e.id:void 0,name:V(e,"name")?e.name:void 0}}function Pu(e){return qu(e)}function qu(e,t){return e==null?e:{accountNumber:V(e,"account_number")?e.account_number:void 0,accountName:V(e,"account_name")?e.account_name:void 0,ticketId:V(e,"ticket_id")?e.ticket_id:void 0,ticketType:V(e,"ticket_type")?e.ticket_type:void 0,requestType:V(e,"request_type")?e.request_type:void 0,category:V(e,"category")?e.category:void 0,subject:V(e,"subject")?e.subject:void 0,sites:V(e,"sites")?e.sites.map(Nu):void 0,locations:V(e,"locations")?e.locations:void 0,accessRequestedFor:V(e,"access_requested_for")?e.access_requested_for:void 0,status:V(e,"status")?e.status:void 0,cancellationReason:V(e,"cancellation_reason")?e.cancellation_reason:void 0,createdBy:V(e,"created_by")?e.created_by:void 0,createdAt:V(e,"created_at")?new Date(e.created_at):void 0,updatedAt:V(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:V(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Du(e){return Bu(e)}function Bu(e,t){return e==null?e:{items:V(e,"items")?e.items.map(Pu):void 0,totalCount:V(e,"total_count")?e.total_count:void 0,pageNumber:V(e,"page_number")?e.page_number:void 0,pageSize:V(e,"page_size")?e.page_size:void 0}}class Ou extends ui{async downloadServiceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/service-tickets/file",method:"GET",headers:n,query:s},i);return new Su(o)}async downloadServiceTickets(t={},i){return await(await this.downloadServiceTicketsRaw(t,i)).value()}async getServiceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/service-tickets",method:"GET",headers:n,query:s},i);return new Iu(o,a=>Du(a))}async getServiceTickets(t={},i){return await(await this.getServiceTicketsRaw(t,i)).value()}}function $u(e){return Eu(e)}function Eu(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0}}function xu(e){return Fu(e)}function Fu(e,t){return e==null?e:{accountNumber:T(e,"account_number")?e.account_number:void 0,accountName:T(e,"account_name")?e.account_name:void 0,id:T(e,"id")?e.id:void 0,status:T(e,"status")?e.status:void 0,cancellationReason:T(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:T(e,"subject")?e.subject:void 0,startDate:T(e,"start_date")?new Date(e.start_date):void 0,endDate:T(e,"end_date")?new Date(e.end_date):void 0,approvalStatus:T(e,"approval_status")?e.approval_status:void 0,category:T(e,"category")?e.category:void 0,activityType:T(e,"activity_type")?e.activity_type:void 0,activitySubtype:T(e,"activity_subtype")?e.activity_subtype:void 0,activityCategory:T(e,"activity_category")?e.activity_category:void 0,site:T(e,"site")?e.site:void 0,locations:T(e,"locations")?e.locations:void 0,highLevelSummary:T(e,"high_level_summary")?e.high_level_summary:void 0,serviceType:T(e,"service_type")?e.service_type:void 0,riskLevel:T(e,"risk_level")?e.risk_level:void 0,attachments:T(e,"attachments")?e.attachments.map($u):void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0,updatedAt:T(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:T(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Lu(e){return Vu(e)}function Vu(e,t){return e==null?e:{items:T(e,"items")?e.items.map(xu):void 0}}function Uu(e){return Hu(e)}function Hu(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0}}function zu(e){return ju(e)}function ju(e,t){return e==null?e:{accountNumber:T(e,"account_number")?e.account_number:void 0,accountName:T(e,"account_name")?e.account_name:void 0,id:T(e,"id")?e.id:void 0,status:T(e,"status")?e.status:void 0,subject:T(e,"subject")?e.subject:void 0,startDate:T(e,"start_date")?new Date(e.start_date):void 0,endDate:T(e,"end_date")?new Date(e.end_date):void 0,activityType:T(e,"activity_type")?e.activity_type:void 0,site:T(e,"site")?e.site:void 0,locations:T(e,"locations")?e.locations:void 0,notificationType:T(e,"notification_type")?e.notification_type:void 0,riskLevel:T(e,"risk_level")?e.risk_level:void 0,attachments:T(e,"attachments")?e.attachments.map(Uu):void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0,updatedAt:T(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:T(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Mu(e){return Ju(e)}function Ju(e,t){return e==null?e:{items:T(e,"items")?e.items.map(zu):void 0,totalCount:T(e,"total_count")?e.total_count:void 0,pageNumber:T(e,"page_number")?e.page_number:void 0,pageSize:T(e,"page_size")?e.page_size:void 0}}function Wu(e){return Gu(e)}function Gu(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0,fileSize:T(e,"file_size")?e.file_size:void 0,contentType:T(e,"content_type")?e.content_type:void 0,createdBy:T(e,"created_by")?e.created_by:void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0}}function Zu(e){return Ku(e)}function Ku(e,t){return e==null?e:{attachments:T(e,"attachments")?e.attachments.map(Wu):void 0}}class Yu extends oi{async downloadPlannedMaintenanceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/file",method:"GET",headers:n,query:s},i);return new Os(o)}async downloadPlannedMaintenanceTickets(t={},i){return await(await this.downloadPlannedMaintenanceTicketsRaw(t,i)).value()}async getPlannedMaintenanceAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new Zt("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPlannedMaintenanceAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Os(o)}async getPlannedMaintenanceAttachmentsById(t,i){return await(await this.getPlannedMaintenanceAttachmentsByIdRaw(t,i)).value()}async getPlannedMaintenanceAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ri(o,a=>Zu(a))}async getPlannedMaintenanceAttachmentsList(t,i){return await(await this.getPlannedMaintenanceAttachmentsListRaw(t,i)).value()}async getPlannedMaintenanceTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ri(o,a=>Lu(a))}async getPlannedMaintenanceTicketById(t,i){return await(await this.getPlannedMaintenanceTicketByIdRaw(t,i)).value()}async getPlannedMaintenanceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={},o=await this.request({path:"/planned-maintenances",method:"GET",headers:n,query:s},i);return new Ri(o,a=>Mu(a))}async getPlannedMaintenanceTickets(t={},i){return await(await this.getPlannedMaintenanceTicketsRaw(t,i)).value()}}function Xu(e){return Qu(e)}function Qu(e,t){return e==null?e:{en:Pe(e,"en")?e.en:void 0,fr:Pe(e,"fr")?e.fr:void 0,de:Pe(e,"de")?e.de:void 0,es:Pe(e,"es")?e.es:void 0}}function el(e){return tl(e)}function tl(e,t){return e}function il(e){return sl(e)}function sl(e,t){return e}const _i={ServiceNow:"ServiceNow",InSite:"InSite",TelxSfdc:"TelxSFDC"};function nl(e){return al(e)}function al(e,t){return e}function ol(e){return rl(e)}function rl(e,t){return e==null?e:{process:Pe(e,"process")?il(e.process):void 0,site:Pe(e,"site")?e.site:void 0,serviceManagementSystem:Pe(e,"serviceManagementSystem")?nl(e.serviceManagementSystem):void 0,destinationUrls:Pe(e,"destinationUrls")?Xu(e.destinationUrls):void 0,portal:Pe(e,"portal")?el(e.portal):void 0}}class cl extends ci{async getSiteNavigationRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new Hs("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getSiteNavigation.");if(t.site===null||t.site===void 0)throw new Hs("site","Required parameter requestParameters.site was null or undefined when calling getSiteNavigation.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.process!==void 0&&(s.process=t.process);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("bearerToken",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/site-configurations",method:"GET",headers:n,query:s},i);return new $d(o,a=>a.map(ol))}async getSiteNavigation(t,i){return await(await this.getSiteNavigationRaw(t,i)).value()}}const dl="http://localhost".replace(/\/+$/,"");class tn{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:dl}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||sn}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ul=new tn;class li{constructor(t=ul){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new hl(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?li.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new pl(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;ml(r.body)||r.body instanceof URLSearchParams||ll(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}li.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function ll(e){return typeof Blob<"u"&&e instanceof Blob}function ml(e){return typeof FormData<"u"&&e instanceof FormData}class pl extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class hl extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class te extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function R(e,t){return e[t]!=null}function sn(e,t=""){return Object.keys(e).map(i=>nn(i,e[i],t)).filter(i=>i.length>0).join("&")}function nn(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return nn(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?sn(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class qe{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class vl{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function gl(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function wl(e){return fl(e)}function fl(e,t){return e==null?e:{message:R(e,"message")?e.message:void 0}}function kl(e){return yl(e)}function yl(e,t){return e==null?e:{requestType:R(e,"request_type")?e.request_type:void 0,categories:R(e,"categories")?e.categories:void 0}}function Tl(e){return bl(e)}function bl(e,t){return e==null?e:{items:R(e,"items")?e.items.map(kl):void 0}}function an(e){return Rl(e)}function Rl(e,t){return e==null?e:{createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,comment:R(e,"comment")?e.comment:void 0}}function Al(e){return _l(e)}function _l(e,t){return e==null?e:{comments:R(e,"comments")?e.comments.map(an):void 0}}function on(e){return Il(e)}function Il(e,t){return e==null?e:{id:R(e,"id")?e.id:void 0,fileName:R(e,"file_name")?e.file_name:void 0,fileSize:R(e,"file_size")?e.file_size:void 0,contentType:R(e,"content_type")?e.content_type:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0}}function Sl(e){return Nl(e)}function Nl(e,t){return e==null?e:{attachments:R(e,"attachments")?e.attachments.map(on):void 0}}function Cl(e){if(e!==void 0)return e===null?null:{comment:e.comment}}function Pl(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,request_type:e.requestType,category:e.category,locations:e.locations,circuit_id:e.circuitId,customer_reference:e.customerReference,description:e.description,notification_recipients:e.notificationRecipients}}function Ii(e){return ql(e)}function ql(e,t){return e==null?e:{ticketNumber:R(e,"ticket_number")?e.ticket_number:void 0,accountNumber:R(e,"account_number")?e.account_number:void 0,accountName:R(e,"account_name")?e.account_name:void 0,id:R(e,"id")?e.id:void 0,status:R(e,"status")?e.status:void 0,cancellationReason:R(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:R(e,"subject")?e.subject:void 0,requestType:R(e,"request_type")?e.request_type:void 0,category:R(e,"category")?e.category:void 0,site:R(e,"site")?e.site:void 0,locations:R(e,"locations")?e.locations:void 0,circuitId:R(e,"circuit_id")?e.circuit_id:void 0,customerReference:R(e,"customer_reference")?e.customer_reference:void 0,description:R(e,"description")?e.description:void 0,notificationRecipients:R(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,updatedAt:R(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:R(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:R(e,"comments")?e.comments.map(an):void 0}}function Dl(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,circuit_id:e.circuitId,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Bl(e){return Ol(e)}function Ol(e,t){return e==null?e:{accountNumber:R(e,"account_number")?e.account_number:void 0,accountName:R(e,"account_name")?e.account_name:void 0,id:R(e,"id")?e.id:void 0,status:R(e,"status")?e.status:void 0,subject:R(e,"subject")?e.subject:void 0,site:R(e,"site")?e.site:void 0,locations:R(e,"locations")?e.locations:void 0,description:R(e,"description")?e.description:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,updatedAt:R(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:R(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function $l(e){return El(e)}function El(e,t){return e==null?e:{items:R(e,"items")?e.items.map(Bl):void 0,totalCount:R(e,"total_count")?e.total_count:void 0,pageNumber:R(e,"page_number")?e.page_number:void 0,pageSize:R(e,"page_size")?e.page_size:void 0}}class xl extends li{async cancellationTroubleTicketRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationTroubleTicketRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new te("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationTroubleTicketRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:gl(t.cancellationTicketsRequest)},i);return new qe(o,a=>wl(a))}async cancellationTroubleTicketRequest(t,i){return await(await this.cancellationTroubleTicketRequestRaw(t,i)).value()}async createTroubleTicketAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createTroubleTicketAttachment.");if(t.fileName===null||t.fileName===void 0)throw new te("fileName","Required parameter requestParameters.fileName was null or undefined when calling createTroubleTicketAttachment.");if(t.body===null||t.body===void 0)throw new te("body","Required parameter requestParameters.body was null or undefined when calling createTroubleTicketAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new qe(o,a=>on(a))}async createTroubleTicketAttachment(t,i){return await(await this.createTroubleTicketAttachmentRaw(t,i)).value()}async createTroubleTicketCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createTroubleTicketComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new te("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createTroubleTicketComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Cl(t.ticketCommentsRequest)},i);return new qe(o,a=>Al(a))}async createTroubleTicketComment(t,i){return await(await this.createTroubleTicketCommentRaw(t,i)).value()}async createTroubleTicketTicketRaw(t,i){if(t.troubleTicketRequest===null||t.troubleTicketRequest===void 0)throw new te("troubleTicketRequest","Required parameter requestParameters.troubleTicketRequest was null or undefined when calling createTroubleTicketTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets",method:"POST",headers:n,query:s,body:Pl(t.troubleTicketRequest)},i);return new qe(o,a=>Ii(a))}async createTroubleTicketTicket(t,i){return await(await this.createTroubleTicketTicketRaw(t,i)).value()}async getTroubleTicketAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new te("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getTroubleTicketAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new vl(o)}async getTroubleTicketAttachmentsById(t,i){return await(await this.getTroubleTicketAttachmentsByIdRaw(t,i)).value()}async getTroubleTicketAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new qe(o,a=>Sl(a))}async getTroubleTicketAttachmentsList(t,i){return await(await this.getTroubleTicketAttachmentsListRaw(t,i)).value()}async getTroubleTicketTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new qe(o,a=>Ii(a))}async getTroubleTicketTicketById(t,i){return await(await this.getTroubleTicketTicketByIdRaw(t,i)).value()}async getTroubleTicketTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/trouble-tickets",method:"GET",headers:n,query:s},i);return new qe(o,a=>$l(a))}async getTroubleTicketTickets(t={},i){return await(await this.getTroubleTicketTicketsRaw(t,i)).value()}async getTroubleTicketsCategoriesListRaw(t,i){if(t.site===null||t.site===void 0)throw new te("site","Required parameter requestParameters.site was null or undefined when calling getTroubleTicketsCategoriesList.");const s={};t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/categories",method:"GET",headers:n,query:s},i);return new qe(o,a=>Tl(a))}async getTroubleTicketsCategoriesList(t,i){return await(await this.getTroubleTicketsCategoriesListRaw(t,i)).value()}async updateTroubleTicketTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateTroubleTicketTicket.");if(t.troubleTicketUpdateRequest===null||t.troubleTicketUpdateRequest===void 0)throw new te("troubleTicketUpdateRequest","Required parameter requestParameters.troubleTicketUpdateRequest was null or undefined when calling updateTroubleTicketTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Dl(t.troubleTicketUpdateRequest)},i);return new qe(o,a=>Ii(a))}async updateTroubleTicketTicket(t,i){return await(await this.updateTroubleTicketTicketRaw(t,i)).value()}}function Fl(e){return Ll(e)}function Ll(e,t){return e==null?e:{id:e.id,name:e.name,isNonLocation:e.is_non_location,category:Js(e,"category")?e.category:void 0,privileges:e.privileges,isInternal:e.is_internal}}function Vl(e){return Ul(e)}function Ul(e,t){return e==null?e:{accountNumber:e.account_number,permissionName:e.permission_name,privilege:e.privilege,isNonLocation:Js(e,"is_non_location")?e.is_non_location:void 0,permissionIsInternal:e.permission_is_internal}}class Hl extends di{async getPermissionsRaw(t){const i={},s={};this.configuration&&this.configuration.accessToken&&(s.Authorization=await this.configuration.accessToken("oAuth2",[]));const n=await this.request({path:"/permissions",method:"GET",headers:s,query:i},t);return new Zs(n,o=>o.map(Fl))}async getPermissions(t){return await(await this.getPermissionsRaw(t)).value()}async getUserPermissionsRaw(t,i){const s={};t.excludeSiblings!==void 0&&(s.exclude_siblings=t.excludeSiblings),t.excludeParents!==void 0&&(s.exclude_parents=t.excludeParents);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const o=await this.request({path:"/my-permissions",method:"GET",headers:n,query:s},i);return new Zs(o,a=>a.map(Vl))}async getUserPermissions(t={},i){return await(await this.getUserPermissionsRaw(t,i)).value()}}const z={CustomerCare:"sm-customer-care",DeliveriesRemovals:"sm-deliveries",References:"sm-references",RemoteHands:"sm-remote-hands",TroubleTickets:"sm-trouble-tickets",FacilityAccess:"sm-facility-access",ServiceTickets:"sm-service-tickets",SiteMaintenance:"sm-site-maintenance",Incidents:"sm-incidents",Inventory:"inventory",SiteNavigation:"site-navigations",UserManagement:"usermanagement"},F={Site:"Site",Floor:"Floor",Room:"Room",Cabinet:"Cabinet",Cage:"Cage"},U={Read:"Read",Update:"Update",Delete:"Delete",Create:"Create",Approve:"Approve"},zl={READ:1,UPDATE:2,DELETE:4,CREATE:8,APPROVE:16};var Si;(function(e){e.Security="Security",e.DCIM="DCIM",e.PlannedSiteMaintenance="Planned Site Maintenance"})(Si||(Si={}));const S={RemoteHands:"Remote Hands",TroubleTickets:"Trouble Ticket",DeliveriesRemovals:"Shipping & Receiving",VisitorAccess:"Visitor Access",CustomerCare:"Customer Support",PermanentBadge:"Permanent Badge",OSPAccess:"OSP Access",POPPOEAccess:"POP/POE Room Access",PlannedMaintenance:"Planned Site Maintenance"},jl={Duplicate:"Duplicate request",Error:"Request entered in error",NotNeeded:"Request no longer needed"},Ml={Delivery:"Delivery",Removal:"Removal",TroubleTicket:"Trouble Ticket",FacilityAccess:"Facility Access",RemoteHands:"Remote Hands",VisitorAccess:"Visitor Access",PermanentBadge:"Permanent Badge"},ut={GreaterThan:"gt:",GreaterOrEqual:"ge:",LessThan:"lt:",LessThanOrEqual:"le:"},Jl=10,Wl="permission_privilege";class Gl{constructor(t){this.configuration=t}get customerCareApi(){return new du(new Zi({basePath:`${this.configuration.SMApiUrl}/${z.CustomerCare}`,headers:{Authorization:this.getAuthorization()}}))}get courierCompaniesApi(){return new $a(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get deliveriesApi(){return new no(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get removalsApi(){return new ao(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get remoteHandsApi(){return new Ec(new As({basePath:`${this.configuration.SMApiUrl}/${z.RemoteHands}`,headers:{Authorization:this.getAuthorization()}}))}get troubleTicketsApi(){return new xl(new tn({basePath:`${this.configuration.SMApiUrl}/${z.TroubleTickets}`,headers:{Authorization:this.getAuthorization()}}))}get facilityAccessApi(){return{visitorAccess:new Wr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),visitorHost:new Gr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),permanentBadgeAccess:new Jr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),ospAccess:new jr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),popAccess:new Mr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}}))}}get serviceTicketApi(){return new Ou(new Xs({basePath:`${this.configuration.SMApiUrl}/${z.ServiceTickets}`,headers:{Authorization:this.getAuthorization()}}))}get inventoryApi(){return{locations:new ed(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}})),sites:new Ps(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}}))}}get sitesApi(){return new Ps(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}}))}get siteNavigationApi(){return new cl(new Us({basePath:`${this.configuration.SMApiUrl}/${z.SiteNavigation}`,headers:{Authorization:this.getAuthorization()}}))}get plannedMaintenanceApi(){return new Yu(new qs({basePath:`${this.configuration.SMApiUrl}/${z.SiteMaintenance}`,headers:{Authorization:this.getAuthorization()}}))}get incidentsApi(){return new Nd(new $s({basePath:`${this.configuration.SMApiUrl}/${z.Incidents}`,headers:{Authorization:this.getAuthorization()}}))}get userPermissionsApi(){return new Hl(new Ms({basePath:`${this.configuration.SMApiUrl}/${z.UserManagement}`,headers:{Authorization:this.getAuthorization()}}))}getAuthorizationToken(){return this.getAuthorization()}get referencesApi(){return{categories:new gu(new Gt({basePath:`${this.configuration.SMApiUrl}/${z.References}`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}})),requestTypeCategoryMappings:new wu(new Gt({basePath:`${this.configuration.SMApiUrl}/${z.References}`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}})),terms:new ku(new Gt({basePath:`${this.configuration.SMApiUrl}/sm-references`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}}))}}getAuthorization(){return this.configuration.getAuthorizationFn?this.configuration.getAuthorizationFn():""}}class Zl extends la{constructor(t,i){super({...t}),this.hashed_identifier=i}}class Kl{constructor(t,i){this.name=t,this.accountNumber=i}}class Qe{constructor({loginAuthority:t,clientId:i,scope:s,postLogoutRedirectUri:n,userStorageKey:o="user-authentication",redirectUrlKey:a="redirect-url",authPaths:r={authenticate:"authenticate",authCallback:"auth-callback",logout:"logout"}}){this.getHashedRootAccountNumberAndUserEmail=async()=>{const A=ot.getAccountHierarchy(),C=await Qe.hashValue(ot===null||ot===void 0?void 0:ot.email);let b=await Qe.hashValue(ot===null||ot===void 0?void 0:ot.account_number);return A&&(b=await Qe.hashValue(A==null?void 0:A.accountNumber)),`${b}-${C}`},this.configuration={loginAuthority:t,clientId:i,scope:s,postLogoutRedirectUri:n,userStorageKey:o,redirectUrlKey:a,authPaths:r};const{location:d}=window,u=`${d.protocol}//${d.hostname}${d.port?`:${d.port}`:""}`,p={authority:this.configuration.loginAuthority,client_id:this.configuration.clientId,redirect_uri:`${u}/${this.configuration.authPaths.authCallback}`,response_type:"code",scope:this.configuration.scope,post_logout_redirect_uri:this.configuration.postLogoutRedirectUri,loadUserInfo:!0};this.userManager=new ma(p)}isLoggedIn(){const t=this.getUser();if(t===null)return!1;if(!t.expires_at)return!0;const i=new Date,s=new Date(t.expires_at*1e3);return i<s}redirectToAuth(t=!1){const i=this.isAuthenticating();(t||!i)&&(i||localStorage.setItem(this.configuration.redirectUrlKey,window.location.href),rt.go(`/${this.configuration.authPaths.authenticate}`))}isAuthenticating(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authenticate?(this.userManager.signinRedirect(),!0):!1}isHandlingAuthCallback(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authCallback?(this.userManager.signinRedirectCallback().then(Qe.ensureValidUser).then(Qe.addHashedIdToUserProfile).then(i=>this.saveUser(i)).then(()=>this.authSuccessRedirect()).catch(()=>this.redirectToAuth()),!0):!1}authSuccessRedirect(){let t="/";const i=localStorage.getItem(this.configuration.redirectUrlKey);i&&(localStorage.removeItem(this.configuration.redirectUrlKey),t=i),rt.go(t)}redirectToLogout(){this.isHandlingLogout()||rt.go(`/${this.configuration.authPaths.logout}`)}isHandlingLogout(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.logout?(this.clearUser(),window.localStorage.clear(),this.userManager.signoutRedirect({id_token_hint:this.getIdToken()}),!0):!1}isProcessing(){return this.isAuthenticating()||this.isHandlingAuthCallback()||this.isHandlingLogout()}saveUser(t){localStorage.setItem(this.configuration.userStorageKey,JSON.stringify(t))}clearUser(){localStorage.removeItem(this.configuration.userStorageKey)}getUser(){const t=localStorage.getItem(this.configuration.userStorageKey);return t?JSON.parse(t):null}getUserProfileSub(){var t;const i=this.getUser();return(t=i==null?void 0:i.profile)===null||t===void 0?void 0:t.sub}getUserLocale(){var t;const i=this.getUser();return(t=i==null?void 0:i.profile)===null||t===void 0?void 0:t.locale}getHashedIdentifer(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.hashed_identifier}getIdToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.id_token}getAccessToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.access_token}getAuthorization(){var t,i;return`${(t=this.getUser())===null||t===void 0?void 0:t.token_type} ${(i=this.getUser())===null||i===void 0?void 0:i.access_token}`}getUserAccount(){var t,i,s,n;return new Kl((i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.account_name,(n=(s=this.getUser())===null||s===void 0?void 0:s.profile)===null||n===void 0?void 0:n.account_number)}getUserEmail(){var t,i;return(i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.email}getAccountNumber(){var t,i;return(i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.account_number}static async hashValue(t){const i=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")}static async addHashedIdToUserProfile(t){const i=`${t.profile.sub}-${t.profile.customer_id}`,s=await Qe.hashValue(i);return new Zl(t,s)}static ensureValidUser(t){if(!t.id_token)throw new Error("Missing property:id_token");return t}}function De(){var e;const t=(e=window.gpConfig)===null||e===void 0?void 0:e["ui-service-management"];if(!t)throw new Error("ui-service-management config not loaded. Ensure config.json is fetched before app bootstrap.");return t}const Yt=De(),ae=new Qe({loginAuthority:Yt.LoginAuthority,clientId:Yt.ServiceManagementUIClientId,scope:Yt.ServiceManagementUIScopes}),m=new Gl({SMApiUrl:Yt.SMApiUrl,getAuthorizationFn:()=>`Bearer ${ae.getAccessToken()}`}),rn="no instructions provided",Ni=" [Special Instructions] ",gt="Other",cn="Digital Realty",Yl="Interxion",dn=5;class Xl{constructor(){this.couriers={},this.sites=[],this.removalParties=[],this.requestTypeCategoriesDict={},this.termsLookup={[Q.Deliveries]:"",[Q.FacilityAccess]:"",[Q.TroubleTickets]:"",[Q.RemoteHands]:""},se(this),Je(this,{name:"lookups",properties:["couriers","sites","removalParties","requestTypeCategoriesDict","termsLookup"],storage:window.sessionStorage})}getCouriers(t,i){var s;const n=(s=this.couriers[t])!==null&&s!==void 0?s:[];return i?[...n,gt]:n}async fillCouriers(t,i,s){!t||!i||!s||this.couriers[s]||(this.couriers[s]=await m.courierCompaniesApi.getCourierBySite({accountNumber:i,site:t}))}async fillSites(){const t={pageSize:1e3};this.sites=await Gi(t,i=>m.inventoryApi.sites.getSites(i))}async getRequestCategories(t,i,s){const n=`${t}-${i}`;if(this.requestTypeCategoriesDict[n]&&!s)return this.requestTypeCategoriesDict[n];const o=(await m.referencesApi.requestTypeCategoryMappings.getRequestTypeCategoryMappings({serviceTicketType:i,serviceManagementSystem:t,siteCode:s})).filter(a=>{var r;return(r=a.categories)===null||r===void 0?void 0:r.some(d=>d.isActive)});return this.requestTypeCategoriesDict[n]=Object.fromEntries(o.map(a=>{var r;return[a.requestType,(r=a.categories)===null||r===void 0?void 0:r.filter(d=>d.isActive).map(d=>d.canonicalValue)]})),this.requestTypeCategoriesDict[n]}async fillRemovalParties(){this.removalParties=await m.removalsApi.getRemovalParties()}async fillLookups(){await Promise.all([this.fillRemovalParties(),this.fillTerms(),this.fillSites()])}async fillTerms(){const t=async i=>{await m.referencesApi.terms.getTerms({service:i}).then(s=>{this.termsLookup[i]=s})};await Promise.all([t(Q.Deliveries),t(Q.TroubleTickets),t(Q.RemoteHands),t(Q.FacilityAccess)])}clear(){this.couriers={},this.sites=[],this.removalParties=[],this.requestTypeCategoriesDict={},this.termsLookup={[Q.Deliveries]:"",[Q.FacilityAccess]:"",[Q.TroubleTickets]:"",[Q.RemoteHands]:""}}}const J=new Xl;function St(e){return new Date(e).toISOString().split("T")[0]}const un=()=>{var e;const t=localStorage.getItem("date-format");return t&&((e=JSON.parse(t))===null||e===void 0?void 0:e.preferredTimezone)||he.tz.guess()},Be=(e,t,i)=>{var s,n;if(!e||!t)return;const o=`${e} ${t}`,a=(n=(s=J.sites)===null||s===void 0?void 0:s.find(r=>r.id===i))===null||n===void 0?void 0:n.timeZone;return(a?he.tz(o,a):he.utc(o)).utc().toDate()};function Ql(e,t=un()){const i=he.tz(e,t).startOf("day").toDate(),s=he.tz(e,t).endOf("day").toDate();return{startOfDayLocal:i,endOfDayLocal:s}}const em=()=>he.utc().tz(un()).startOf("day").format("YYYY-MM-DD"),tm=(e,t)=>(t?he.tz(t):he.utc()).add(e,"days").format("YYYY-MM-DD"),Z=e=>{if(e)return new Date(e)},im=()=>{var e;const t=localStorage.getItem("date-format");return t&&((e=JSON.parse(t))===null||e===void 0?void 0:e.preferredDateFormat)||"yyyy-MM-dd"};St(new Date);const sm=bt`.header-container{display:flex;align-items:center;gap:20px}.header__title{margin:0;font-family:var(--root-secondary-font);font-style:normal;font-weight:700;font-size:34px;line-height:40px;letter-spacing:.35px;color:#092241;flex-grow:1}.header__profile{background-color:#092241;height:35px;border-radius:10px;color:#fff;padding-left:20px;padding-right:20px;display:flex;align-items:center;font-size:14px}.header__logout{height:35px;border-radius:10px;border:none;background-color:#1456e0;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding-left:15px;padding-right:15px}.header__logout svg{width:1em;height:1em;font-size:20px;margin-right:5px}.header__accounts{width:200px;--md-outlined-field-top-space:5px;--md-outlined-field-bottom-space:5px}@media only screen and (min-width:5px) and (max-width:500px){.header-container{flex-direction:column}}@media only screen and (min-width:500px) and (max-width:1250px){.header-container{flex-direction:row}}`,L={ErrorRaised:"sm:error-raised",DrawerClose:"drawer-close",CreateTicket:"create-ticket",CancelTicket:"cancel-ticket",EditTicket:"edit-ticket",ApproveDenyTicket:"approve-deny-ticket"};class Oe{constructor(t,i,s){var n,o;this.id=t,this.siteId=i,this.accountNumber=s;const a=J.sites.find(r=>r.id===this.siteId);a?this.displayName=`${a==null?void 0:a.name} - ${a==null?void 0:a.streetAddress}`:this.displayName=(o=(n=this.id)!==null&&n!==void 0?n:this.siteId)!==null&&o!==void 0?o:""}}async function nm(e){if(!e)return"";const t=J.sites.find(i=>i.locationId===e);return t?`${t.name} - ${t.streetAddress}`:e}async function am(e){if(!e)return"";const t=J.sites.find(i=>i.id===e);return t?`${t.name} - ${t.streetAddress}`:e}async function om(e){const t=J.sites.find(i=>i.id===e);return t==null?void 0:t.locationId}const ln=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))},rm=e=>ln(document,L.ErrorRaised,e),l=async(e,t=!0)=>{let i="An error occurred";if(e instanceof Xi&&e.response.status===400)try{const{detail:s}=await e.response.json();i=s}catch(s){console.error(e)}else console.error(e);t&&rm(i)},cm=e=>{window.dispatchEvent(new CustomEvent("add-toast",{detail:{id:"error-toast",content:g`<ix-message-toast forceClose="false" toastId="error-toast" type="error">${e} </ix-message-toast>`,vertical:"bottom",horizontal:"center",animated:!0,above:!1}}))};class dm{constructor(){se(this),Je(this,{name:"locations",properties:[],storage:window.localStorage})}async getLocations(t,i){var s;let n=[],o={...t,sort:t.sort||"+id"};const a=r=>m.inventoryApi.locations.getLocations(r).catch(d=>{l(d,!1)});if(i!=null&&i.onlyLoadFirstPage){const r=await a(o);n=(s=r==null?void 0:r.items)!==null&&s!==void 0?s:[]}else n=await Gi(o,a);return n.sort((r,d)=>r.id.localeCompare(d.id))}async getOspsBySiteId(t){try{const i=await m.inventoryApi.sites.getOspsBySiteId({siteId:t});return i!=null?i:[]}catch(i){return[]}}async getPopsBySiteId(t){try{const i=await m.inventoryApi.sites.getPopsBySiteId({siteId:t});return i!=null?i:[]}catch(i){return[]}}}const le=new dm;class um{constructor(){this.isHideLocationDatesEnabled=()=>{const t=De()["SM:HideLocationDates"];return typeof t=="boolean"?t:!1},this.showNewDatePickerComponent=()=>{const t=De()["SM:UseNewDatePicker"];return typeof t=="boolean"?t:!1},this.isOspEnabled=()=>{const t=De()["SM:ShowOspAccess"];return typeof t=="boolean"?t:!1},this.isPopPoeEnabled=()=>{const t=De()["SM:ShowPopPoeAccess"];return typeof t=="boolean"?t:!1},this.isIncidentsEnabled=()=>{const t=De()["SM:IncidentsEnabled"];return typeof t=="boolean"?t:!1}}}const wt=new um,Nt=`${F.Floor},${F.Room},${F.Cabinet},${F.Cage}`;function mn(e){return e===S.VisitorAccess||e===S.PermanentBadge}function lm(e){return e===S.RemoteHands||e===S.TroubleTickets||e===S.VisitorAccess||e===S.PermanentBadge||e===S.CustomerCare||e===S.OSPAccess||e===S.POPPOEAccess}async function Ze(e){var t;const i=await le.getLocations({...e,pageSize:100});return(t=[...new Map(i.map(s=>[s.siteId,s])).values()].map(s=>new Oe(void 0,s.siteId,s.accountNumber)))!==null&&t!==void 0?t:[]}async function mm(e,t,i,s){let n=[];const o=lm(t);let a=ut.GreaterThan+F.Site;o?mn(t)&&(a=Nt):a=F.Site;let r=await le.getLocations({locationType:a,permissionType:t,permissionPrivilege:e,pageSize:100,accountNumber:s,assignableProcess:i});return o?(r=[...new Map(r.map(d=>[d.siteId,d])).values()],n=r.map(d=>new Oe(d.siteId,d.siteId,d.accountNumber))):n=r.map(d=>new Oe(d.id,d.siteId,d.accountNumber)),n!=null?n:[]}async function pm(e,t){const i=await le.getLocations({locationType:F.Site,permissionType:t,permissionPrivilege:e,pageSize:100}),s=[...new Set(i.map(n=>n.accountNumber))];return s!=null?s:[]}async function hm(e,t,i,s,n){let o=ut.GreaterThan+F.Site;return mn(t)&&(o=Nt),await le.getLocations({permissionType:t,locationType:o,permissionPrivilege:e,siteId:s,pageSize:100,accountNumber:n,assignableProcess:i})}async function Ct(e,t,i,s){const n=await le.getLocations({permissionType:t,permissionPrivilege:e,id:i,accountNumber:s,pageSize:1},{onlyLoadFirstPage:!0});return(n==null?void 0:n.length)>0}async function $e(e,t,i,s){return(await le.getLocations({permissionPrivilege:t,pageSize:1,permissionType:e,assignableProcess:i,locationType:s},{onlyLoadFirstPage:!0})).length>0}async function Ke(e,t,i){return(await le.getLocations({permissionPrivilege:i,pageSize:100,permissionType:t})).some(s=>e.includes(s.id))}async function pn(e){var t;if(!e)return;const i=await le.getLocations({id:e,pageSize:1},{onlyLoadFirstPage:!0});return(t=i==null?void 0:i[0])===null||t===void 0?void 0:t.siteId}async function vm(e){var t;if(!e)return;const i=await le.getLocations({siteId:e,locationType:F.Site,pageSize:1},{onlyLoadFirstPage:!0});return(t=i==null?void 0:i[0])===null||t===void 0?void 0:t.id}async function hn(){return $e(S.CustomerCare,U.Create,void 0,F.Site)}async function vn(){return $e(S.VisitorAccess,U.Create,void 0,F.Site)}async function gn(){return $e(S.PermanentBadge,U.Create,void 0,F.Site)}async function wn(){return wt.isOspEnabled()?$e(S.OSPAccess,U.Create,void 0,F.Site):!1}async function fn(){return wt.isPopPoeEnabled()?$e(S.POPPOEAccess,U.Create,void 0,F.Site):!1}async function gm(){return $e(S.DeliveriesRemovals,U.Create)}async function kn(){return(await Promise.all([vn(),gn(),wn(),fn()])).some(e=>e)}async function yn(){return $e(S.RemoteHands,U.Create,void 0,F.Site)}async function Ci(){return gm()}function Tn(){return $e(S.TroubleTickets,U.Create,void 0,F.Site)}async function wm(){return(await Promise.all([hn(),kn(),yn(),Ci(),Tn()])).some(e=>e)}function fm(e){switch(e){case"Visitor Access":return S.VisitorAccess;case"Permanent Badge":return S.PermanentBadge;case"OSP Access":return S.OSPAccess;case"PoP/POE Access":return S.POPPOEAccess;default:return}}async function bn(e){if(e===void 0)return!1;const t=await pn(e);return t?(await le.getLocations({siteId:t,permissionType:S.OSPAccess,locationType:ut.GreaterOrEqual+F.Site,permissionPrivilege:U.Update,pageSize:100,assignableProcess:"OSP_access"})).some(i=>i.siteId===t):!1}async function Rn(e){if(e===void 0)return!1;const t=await pn(e);return t?(await le.getLocations({siteId:t,permissionType:S.POPPOEAccess,locationType:ut.GreaterOrEqual+F.Site,permissionPrivilege:U.Update,pageSize:100,assignableProcess:"POP_access"})).some(i=>i.siteId===t):!1}async function An(e){return le.getOspsBySiteId(e)}async function _n(e){return le.getPopsBySiteId(e)}let Pi=class extends Rt{constructor(){super(...arguments),this.hasCreatePermission=!1}dispatchCreateTicketEvent(){const e=new CustomEvent(L.CreateTicket,{bubbles:!0,composed:!0});this.dispatchEvent(e)}async firstUpdated(){this.hasCreatePermission=await wm()}render(){return this.hasCreatePermission?g` <ix-button @click="${this.dispatchCreateTicketEvent}" has-icon> <md-icon slot="icon">add</md-icon> <span class="uppercase font-bold tracking-wider">Create Ticket</span> </ix-button>`:P}};E([we()],Pi.prototype,"hasCreatePermission",void 0),Pi=E([X("sm-create-service-ticket-button")],Pi);let _e=null;function In(){const{pathname:e,search:t,hash:i}=window.location;rt.go({pathname:e,search:t,hash:i})}function km(e,t,i){const s=i.map(n=>({...n,path:`${t}${n.path}`,redirect:n.redirect?`${t}${n.redirect}`:null}));s.push({name:W.ServiceTickets,path:t||"/",component:"service-tickets-view",headerRight:g`<sm-create-service-ticket-button></sm-create-service-ticket-button>`,action:()=>{import("./ui-service-management2.js")}}),s.push({path:"(.*)",component:"service-tickets-view",action:()=>{import("./ui-service-management2.js")}}),_e=new rt(e),_e.setRoutes(s),window.addEventListener("shell-after-navigate",In)}function ym(){return _e}function Tm(){_e==null||_e.unsubscribe(),_e==null||_e.removeRoutes(),_e=null,window.removeEventListener("shell-after-navigate",In)}function Xt(e,t){return _e&&_e.urlForName(e,t)}function bm(e,t){const i=Xt(e);i&&rt.go({pathname:i,hash:t})}let qi=class extends Rt{constructor(){super(...arguments),this.routeName=null}return(){this.routeName&&bm(this.routeName),window.history.back()}render(){return g` <ix-button appearance="text" has-icon @click="${this.return}"> <md-icon slot="icon">arrow_back</md-icon> <span class="uppercase font-bold tracking-wider">Back</span> </ix-button>`}};E([we({type:String})],qi.prototype,"routeName",void 0),qi=E([X("sm-back-button")],qi);const Rm="Other parties to notify",Am="Result",Ye="CANCEL TICKET",_m="REQUEST CANCELLATION",Ee="EDIT TICKET",Im="Sites & Locations",Sm="Sites, Locations & Hosts",Nm="Trouble Ticket is not supported for this site.",Cm="We are unable to process your request. Please, try again or reach out to us for further assistance. We apologize for the inconvenience. Your Digital Realty Team.",Pm="Please be advised that your company has been restricted from submitting a new Delivery request for this location until all existing packages have been retrieved.",qm="We're unable to process your request at the moment. Please reach out to Customer Care for assistance.",Dm="Unable to process request. Contact Customer Care.";var O;(function(e){e.Announced="Announced",e.Cancelled="Cancelled",e.Completed="Completed",e.Draft="Draft",e.InProgress="In Progress",e.New="New",e.Expired="Expired"})(O||(O={}));var Qt;(function(e){e.CancellationRequested="Cancellation requested"})(Qt||(Qt={}));var ft;(function(e){e.Approved="Approved",e.PendingPickup="Pending Pick-up",e.Rejected="Rejected"})(ft||(ft={}));var oe;(function(e){e.Approved="Approved",e.PendingApproval="Pending Approval",e.ApprovalDenied="Approval Denied"})(oe||(oe={}));const Bm=[O.Cancelled,O.Completed,O.Expired,ft.Rejected,oe.ApprovalDenied],Om=[O.New,O.InProgress,O.Announced,ft.PendingPickup,ft.Approved,Qt.CancellationRequested,oe.PendingApproval];var Di;(function(e){e.Resolved="Resolved",e.InProgress="In Progress",e.New="New",e.Closed="Closed",e.Cancelled="Cancelled"})(Di||(Di={}));class $m{constructor(){se(this)}async getServiceBackend(t,i,s){var n;i=i==null?void 0:i.split(".").pop();let o={accountNumber:t,site:i};const a=await m.siteNavigationApi.getSiteNavigation(o).catch(r=>{l(r,!1)});switch((n=a==null?void 0:a.find(r=>r.process===s))===null||n===void 0?void 0:n.serviceManagementSystem){case _i.InSite:return H.Insite;case _i.ServiceNow:return H.ServiceNow;case _i.TelxSfdc:return s==="Facilities_access"?H.Insite:H.TelxSFDC;default:return}}}const K=new $m;var lt;(function(e){e.Kilograms="kilograms",e.Pounds="pounds"})(lt||(lt={}));function Sn(e){return typeof e=="string"&&e.trim().length>0}const Nn=e=>/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e);function Em(e){return/^[a-zA-Z0-9]+$/.test(e)}function xm(e){return/^[a-zA-Z0-9 ]+$/.test(e)}function Fm(e){return/^[a-zA-Z0-9.' ]+$/.test(e)}function Lm(e){const t=he(e,"YYYY-MM-DD"),i=he().add(24,"hours").startOf("day");return t.isSameOrAfter(i)}function Vm(e,t){const i=t?he.tz(t):he.utc(),[s,n]=e.split(":").map(o=>parseInt(o,10));return s>i.hours()||s===i.hours()&&n>i.minutes()}function Cn(e){return Sn(e)?/^(0|[1-9]\d*)$/.test(e):!1}const Pn=(e,t)=>{let i;return t===H.ServiceNow&&(i=e.weight,e.overweight&&(e.isHistorical||(i=`${e.weight} ${e.weightUnit}`))),{trackingNumber:e.trackingNumber,numberOfPackages:e.numberOfPackages,sizeWhenOversized:e.dimensions,weightWhenOverweight:i,courierCompany:e.courier===gt?e.otherCompany:e.courier}},qn=(e,t=!1)=>{var i,s,n,o,a;const r=e.serviceBackend!==H.ServiceNow?e.shortDescription+Ni+(e.instructions||rn):e.shortDescription,d={accountNumber:(i=e.site)===null||i===void 0?void 0:i.accountNumber,subject:(s=e.subject)!==null&&s!==void 0?s:"",description:r,etaFrom:Z(e.estimatedDate)||null,etaTo:Z(e.latestDate)||null,customerReference:e.referenceNumber,site:(o=(n=e.site)===null||n===void 0?void 0:n.id)!==null&&o!==void 0?o:"",otherNotificationRecipients:e.contacts,remoteHandsRequired:e.needRemoteHands};return(e==null?void 0:e.serviceBackend)!==H.TelxSFDC&&(d.loadingBayRequired=e.isLoadingBayRequired),t||(d.packages=(a=e.packages)===null||a===void 0?void 0:a.map(u=>Pn(u,e.serviceBackend))),d};function Um(e,t){const i=new Date;return t&&i.setDate(i.getDate()+e),St(i)}function Hm(e){const t=new Date;return t.setDate(t.getDate()+e),St(t)}const Dn=async(e,t,i)=>{if(!e||!t||!i)return[e];if(await K.getServiceBackend(t,i,"Deliveries")!==H.ServiceNow){const s=e.lastIndexOf(Ni);return s===-1?[e]:e.endsWith(rn)?[e.substring(0,s)]:[e.substring(0,s),e.substring(s+Ni.length)]}return[e]},zm=e=>{if(!e)return[void 0,void 0];const t=e.split(" ");if(t.length!==2)return[e,void 0];const[i,s]=t;let n;if(s.toLowerCase()===lt.Kilograms)n=lt.Kilograms;else if(s.toLowerCase()===lt.Pounds)n=lt.Pounds;else return[e,void 0];return Cn(i)?[i,n]:[e,void 0]},Bn=async(e,t,i,s)=>{if(!e)return[];await J.fillCouriers(t,i,s);const n=J.getCouriers(s);return e.map(o=>{const a=n==null?void 0:n.find(C=>{var b;return C.toLowerCase()===((b=o.courierCompany)===null||b===void 0?void 0:b.toLowerCase())}),r=!!a,d=!!o.weightWhenOverweight;let u="",p;if(d){const[C,b]=zm(o.weightWhenOverweight);u=C!=null?C:"",p=b}let A=!1;return d&&(A=!p||u.length>dn),{id:o.id||"",trackingNumber:o.trackingNumber,numberOfPackages:o.numberOfPackages||0,dimensions:o.sizeWhenOversized,overweight:d,oversized:!!o.sizeWhenOversized,weight:A?o.weightWhenOverweight:u,weightUnit:A?void 0:p,courier:r?a:gt,otherCompany:r?"":o.courierCompany,isHistorical:A}})},On=async e=>{var t,i,s,n,o,a;if(!e)return;const[r,d]=await Dn(e.description,e.accountNumber,e.site),u=await K.getServiceBackend(e.accountNumber,e.site,"Deliveries"),p=await Bn(e.packages,e.site,e.accountNumber,u);return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,subject:e.subject,shortDescription:r,instructions:d,estimatedDate:(t=e.etaFrom)===null||t===void 0?void 0:t.toISOString().split("T")[0],latestDate:(i=e.etaTo)===null||i===void 0?void 0:i.toISOString().split("T")[0],referenceNumber:e.customerReference,site:e.site,cancellationReason:e.cancellationReason,contacts:e.otherNotificationRecipients,state:e.status,requester:e.createdBy,createdOn:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedOn:(n=e.updatedAt)===null||n===void 0?void 0:n.toISOString(),isLoadingBayRequired:e.loadingBayRequired,needRemoteHands:(o=e.remoteHandsRequired)!==null&&o!==void 0?o:!1,packages:p,comments:(a=e.comments)===null||a===void 0?void 0:a.map(A=>M(A)),serviceBackend:u}},jm=async e=>{var t,i,s;if(!e)return;const[n,o]=await Dn(e.description,e.accountNumber,e.site),a=await K.getServiceBackend(e.accountNumber,e.site,"Deliveries"),r=await Bn(e.packages,e.site,e.accountNumber,a),d=J.sites.find(u=>u.id===e.site).locationId;return{id:e.id||"",accountNumber:e.accountNumber||"",subject:e.subject,shortDescription:n,instructions:o,estimatedDate:(t=e.etaFrom)===null||t===void 0?void 0:t.toISOString(),latestDate:(i=e.etaTo)===null||i===void 0?void 0:i.toISOString(),referenceNumber:e.customerReference,site:new Oe(d,e.site,e.accountNumber),contacts:e.otherNotificationRecipients,isLoadingBayRequired:e.loadingBayRequired,serviceBackend:a,isValid:!0,needRemoteHands:(s=e.remoteHandsRequired)!==null&&s!==void 0?s:!1,packages:r}},Mm=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),$n=e=>e.requestType===gi.PlannedWork&&e.serviceBackend===H.ServiceNow,Jm=e=>{var t,i;return $n(e)&&(i=Be(e.startDate,e.startTime,(t=e.site)===null||t===void 0?void 0:t.siteId))!==null&&i!==void 0?i:null},En=async e=>{var t,i;if(!e.expectedStart)return{startDate:"",startTime:"",startDateTime:""};const s=(i=(t=J.sites)===null||t===void 0?void 0:t.find(o=>o.locationId===e.site))===null||i===void 0?void 0:i.timeZone,n=s?G(e.expectedStart).tz(s):G(e.expectedStart);return{startDate:n.format("YYYY-MM-DD"),startTime:n.format("HH:mm"),startDateTime:n.format("YYYY-MM-DDTHH:mm")}},Wm=e=>{var t,i,s,n,o;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",requestType:(i=e.requestType)!==null&&i!==void 0?i:"",category:(s=e.category)!==null&&s!==void 0?s:"",subject:(n=e.subject)!==null&&n!==void 0?n:"",description:e.description,expectedStart:Jm(e),customerReference:e.referenceNumber,locations:!((o=e.location)===null||o===void 0)&&o.id?[e.location.id]:[],referenceTicket:e.referenceTicketNumber,otherNotificationRecipients:e.contacts}},Gm=e=>({customerReference:e.referenceNumber,otherNotificationRecipients:e.contacts}),xn=async e=>{var t,i,s,n,o;if(!e)return;const{startDate:a,startTime:r}=await En(e);return{id:e.ticketId,accountName:e.accountName,accountNumber:e.accountNumber,category:e.category,subject:e.subject,shortDescription:e.description,startDate:a,startTime:r,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,state:e.status,site:e.site,locations:(i=(t=e.locations)===null||t===void 0?void 0:t.join(", "))!==null&&i!==void 0?i:"",requester:e.createdBy,requestType:e.requestType,referenceTicketNumber:e.referenceTicket,createdAt:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedAt:(n=e.updatedAt)===null||n===void 0?void 0:n.toISOString(),cancellationReason:e.cancellationReason,comments:(o=e.comments)===null||o===void 0?void 0:o.map(d=>M(d)),serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Remote_hands"),ticketStatus:e.status||""}},Zm=async e=>{var t,i,s,n;if(!e)return;const{startDate:o,startTime:a,startDateTime:r}=await En(e);return{id:e.ticketId||"",accountName:e.accountName,accountNumber:e.accountNumber||"",category:e.category,subject:e.subject,description:e.description,shortDescription:(i=(t=e.description)===null||t===void 0?void 0:t.split("-")[0])===null||i===void 0?void 0:i.trim(),startDate:o,startTime:a,startDateTime:r,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,state:e.status,site:{id:e.site},location:{id:e.locations[0],accountNumber:e.accountNumber},requester:e.createdBy,requestType:e.requestType,referenceTicketNumber:e.referenceTicket,createdOn:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedOn:(n=e.updatedAt)===null||n===void 0?void 0:n.toISOString(),ticketStatus:e.status||"",serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Remote_hands")}},Km=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Bi=(e,t)=>{if(e===gt)return!0;const i=J.getCouriers(t).map(s=>s.toLowerCase());return!!e&&!(i!=null&&i.includes(e.toLowerCase()))},Fn=e=>e===cn,Ym=e=>G().add({days:e}).format(ct),Xm=(e,t)=>G(t).add({days:e}).format(ct),Qm=e=>!!e&&G(e).isBefore(G().add({days:1}),"day"),ep=e=>!!e&&G(e).isBefore(G(),"day"),tp=e=>{var t,i,s,n,o,a;const r=(t=Bi(e.courier,e.serviceBackend)?e.otherCompany:e.courier)!==null&&t!==void 0?t:"";return{accountNumber:(i=e.site)===null||i===void 0?void 0:i.accountNumber,subject:(s=e.subject)!==null&&s!==void 0?s:"",description:e.shortDescription,customerReference:e.referenceNumber,removalParty:(n=e.removalParty)!==null&&n!==void 0?n:"",courierCompany:r,trackingNumber:e.trackingNumber,pickupDate:Z(e.pickupDate),site:(a=(o=e.site)===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:"",otherNotificationRecipients:e.contacts}},ip=e=>{var t;const i=(t=Bi(e.courier,e.serviceBackend)?e.otherCompany:e.courier)!==null&&t!==void 0?t:"";return{subject:e.subject,description:e.shortDescription,customerReference:e.referenceNumber,courierCompany:i,trackingNumber:e.trackingNumber,pickupDate:Z(e.pickupDate),otherNotificationRecipients:e.contacts}},Ln=async(e,t,i,s)=>{await J.fillCouriers(t,i,s);const n=J.getCouriers(s).find(a=>a.toLowerCase()===(e==null?void 0:e.toLowerCase())),o=!!n;return{courier:o?n:gt,otherCompany:o?"":e}},Vn=e=>e===Yl?cn:e;async function sp(e){if(!e)return;const t=await K.getServiceBackend(e.accountNumber,e.site,"Removals"),{courier:i,otherCompany:s}=await Ln(e.courierCompany,e.site,e.accountNumber,t),n=Vn(e.removalParty),o=J.sites.find(a=>a.id===e.site).locationId;return{id:e.id,accountNumber:e.accountNumber,site:new Oe(o,e.site,e.accountNumber),subject:e.subject,shortDescription:e.description,courier:i,otherCompany:s,removalParty:n,trackingNumber:e.trackingNumber,pickupDate:e.pickupDate,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,status:e.status,isValid:!0,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Removals")}}const np=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Un=async e=>{var t,i,s;if(!e)return;const n=await K.getServiceBackend(e.accountNumber,e.site,"Removals"),{courier:o,otherCompany:a}=await Ln(e.courierCompany,e.site,e.accountNumber,n),r=Vn(e.removalParty);return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,status:e.status,subject:e.subject,shortDescription:e.description,referenceNumber:e.customerReference,removalParty:r,needRemoteHands:Fn(r),courier:o,otherCompany:a,trackingNumber:e.trackingNumber,pickupDate:e.pickupDate,site:e.site,serviceBackend:n,contacts:e.otherNotificationRecipients,requester:e.createdBy,createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),cancellationReason:e.cancellationReason,comments:(s=e.comments)===null||s===void 0?void 0:s.map(d=>M(d))}},ap=e=>{var t,i,s,n,o,a,r,d;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",requestType:(i=e.requestType)!==null&&i!==void 0?i:"",category:(s=e.category)!==null&&s!==void 0?s:"",subject:(n=e.subject)!==null&&n!==void 0?n:"",description:(o=e.description)!==null&&o!==void 0?o:"",locations:e.locations,customerReference:(a=e.referenceNumber)!==null&&a!==void 0?a:"",circuitId:(r=e.circuitId)!==null&&r!==void 0?r:"",notificationRecipients:(d=e.contacts)!==null&&d!==void 0?d:""}},op=e=>{const t={};return e.subject&&(t.subject=e.subject),e.description&&(t.description=e.description),e.circuitId&&(t.circuitId=e.circuitId),e.referenceNumber&&(t.customerReference=e.referenceNumber),e.contacts&&(t.otherNotificationRecipients=e.contacts),t},Oi=async e=>{var t,i,s,n;if(e)return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,category:e.category,subject:e.subject,description:e.description,referenceNumber:e.customerReference,contacts:e.notificationRecipients,state:e.status,site:{id:e.site,accountNumber:e.accountNumber},locations:e.locations,requester:e.createdBy,requestType:e.requestType,circuitId:e.circuitId,createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),closedOn:(s=e.closedAt)===null||s===void 0?void 0:s.toISOString(),comments:(n=e.comments)===null||n===void 0?void 0:n.map(o=>M(o)),cancellationReason:e.cancellationReason,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Trouble_tickets")}},rp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}});async function Pt(e,t,i,s,n,o){var a;let r;switch(e){case y.CustomerSupport:{r=await m.customerCareApi.createCustomerCareTicketAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.RemoteHands:{r=await m.remoteHandsApi.createRemoteHandsAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.Deliveries:{r=await m.deliveriesApi.createAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.Removals:{r=await m.removalsApi.createRemovalsAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.FacilityAccess:{switch(o){case"Visitor Access":r=await m.facilityAccessApi.visitorAccess.createVisitorAccessAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break;case"Permanent Badge":r=await((a=m.facilityAccessApi.permanentBadgeAccess)===null||a===void 0?void 0:a.createPermanentBadegeAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d}));break;case"OSP Access":r=await m.facilityAccessApi.ospAccess.createOspAccessAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break;case"PoP/POE Access":r=await m.facilityAccessApi.popAccess.createPopAccessAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}break}case y.TroubleTickets:{r=await m.troubleTicketsApi.createTroubleTicketAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}default:return}return r}const xe=e=>{const t=URL.createObjectURL(e);window.open(t),setTimeout(()=>URL.revokeObjectURL(t),1e3*60*5)};async function cp(e,t,i,s){var n;let o;try{switch(e){case y.CustomerSupport:{o=await m.customerCareApi.getCustomerCareTicketAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.RemoteHands:{o=await m.remoteHandsApi.getRemoteHandsAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.Deliveries:{o=await m.deliveriesApi.getDeliveryAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.Removals:{o=await m.removalsApi.getRemovalsAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.TroubleTickets:{o=await m.troubleTicketsApi.getTroubleTicketAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.FacilityAccess:{switch(s){case"Visitor Access":o=await m.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;case"Permanent Badge":o=await((n=m.facilityAccessApi.permanentBadgeAccess)===null||n===void 0?void 0:n.getPermanentBadgeAttachmentsById({ticketId:i,attachmentId:t})),xe(o);break;case"OSP Access":o=await m.facilityAccessApi.ospAccess.getOspAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;case"PoP/POE Access":o=await m.facilityAccessApi.popAccess.getPopAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;default:break}break}default:return}}catch(a){console.error("error",a),l(a,!1)}return o}const Fe=(e,t)=>{const i=URL.createObjectURL(e),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),URL.revokeObjectURL(i)};async function dp(e,t,i,s,n){var o;let a;try{switch(e){case y.CustomerSupport:{a=await m.customerCareApi.getCustomerCareTicketAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.RemoteHands:{a=await m.remoteHandsApi.getRemoteHandsAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.Deliveries:{a=await m.deliveriesApi.getDeliveryAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.Removals:{a=await m.removalsApi.getRemovalsAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.TroubleTickets:{a=await m.troubleTicketsApi.getTroubleTicketAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.FacilityAccess:{switch(n){case"Visitor Access":a=await m.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(a,i);break;case"Permanent Badge":a=await((o=m.facilityAccessApi.permanentBadgeAccess)===null||o===void 0?void 0:o.getPermanentBadgeAttachmentsById({ticketId:s,attachmentId:t})),Fe(a,i);break;case"OSP Access":a=await m.facilityAccessApi.ospAccess.getOspAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(a,i);break;case"PoP/POE Access":a=await m.facilityAccessApi.popAccess.getPopAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(a,i);break;default:break}break}default:return}}catch(r){console.error("error",r),l(r,!1)}return a}async function Hn(e,t,i){var s,n;try{let o;switch(e){case y.CustomerSupport:{o=await m.customerCareApi.getCustomerCareTicketAttachmentsList({ticketId:t});break}case y.RemoteHands:{o=await m.remoteHandsApi.getRemoteHandsAttachmentsList({ticketId:t});break}case y.Deliveries:{o=await m.deliveriesApi.getDeliveryAttachmentsList({ticketId:t});break}case y.Removals:{o=await m.removalsApi.getRemovalsAttachmentsList({ticketId:t});break}case y.TroubleTickets:{o=await m.troubleTicketsApi.getTroubleTicketAttachmentsList({ticketId:t});break}case y.FacilityAccess:{switch(i){case"Visitor Access":o=await m.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsList({ticketId:t});break;case"Permanent Badge":o=await((s=m.facilityAccessApi.permanentBadgeAccess)===null||s===void 0?void 0:s.getPermanentBadgeAttachmentsList({ticketId:t}));break;case"OSP Access":o=await m.facilityAccessApi.ospAccess.getOspAccessAttachmentsList({ticketId:t});break;case"PoP/POE Access":o=await m.facilityAccessApi.popAccess.getPopAccessAttachmentsList({ticketId:t});break;default:break}break}default:return}return k.attachments=(n=o==null?void 0:o.attachments)!==null&&n!==void 0?n:[],k.attachments}catch(o){console.error("error",o),await l(o,!1);return}}const qt=async(e,t,i="text/csv")=>{const s=new Blob([await e.arrayBuffer()],{type:i}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),URL.revokeObjectURL(n)};async function up(e,t){try{const i=await m.serviceTicketApi.downloadServiceTickets({$filter:e,permissionPrivilege:t});await qt(i,"service-tickets.csv")}catch(i){l(i,!1)}}async function lp(e,t,i,s){try{const n=await m.plannedMaintenanceApi.downloadPlannedMaintenanceTickets({$filter:e,$orderby:t,$skip:i,$top:s});await qt(n,"planned-maintenance-tickets.csv")}catch(n){l(n,!1)}}async function mp(e,t,i){try{const s=await m.plannedMaintenanceApi.getPlannedMaintenanceAttachmentsByIdRaw({ticketId:e,attachmentId:t}),n=s.raw.headers.get("content-type")||void 0,o=await s.value();await qt(o,i,n)}catch(s){l(s,!1)}}async function pp(e,t,i,s){try{const n=await m.incidentsApi.downloadIncidentTickets({$filter:e,$orderby:t,$skip:i,$top:s});await qt(n,"incident-tickets.csv")}catch(n){l(n,!1)}}async function hp(e,t,i){try{const s=await m.incidentsApi.getIncidentsAttachmentsByIdRaw({ticketId:e,attachmentId:t}),n=s.raw.headers.get("content-type")||void 0,o=await s.value();await qt(o,i,n)}catch(s){l(s,!1)}}const Le={ticketType:void 0,ticketStep:void 0,serviceTickets:void 0,permissions:{hasCustomerCareCreatePermission:!1,hasFacilityAccessCreatePermission:!1,hasRemoteHandsCreatePermission:!1,hasDeliveriesAndRemovalsCreatePermission:!1,hasTroubleTicketsCreatePermission:!1},loadings:{ticketCreatePermissionChecks:!0,serviceTicketList:!0,attachments:!0,downloadServiceTicketList:!1,serviceTicket:!1,isTicketCancelling:!1},attachments:[],failedAttachments:[],error:{uploadingAttachments:!1,serviceTicketsGrid:!1,fetchingTicket:!1,cancellingTicket:!1},hasPendingApprovalDialogBeenShown:!1};class vp{constructor(){this.ticketType=void 0,this.ticketStep=void 0,this.serviceTickets=void 0,this.permissions=Le.permissions,this.loadings=Le.loadings,this.attachments=Le.attachments,this.failedAttachments=Le.failedAttachments,this.error=Le.error,this.hasPendingApprovalDialogBeenShown=Le.hasPendingApprovalDialogBeenShown,se(this)}updateTicketType(t=void 0){this.ticketType=t}clear(){this.ticketType=void 0,this.ticketStep=void 0,this.error=Le.error,this.loadings=Le.loadings,this.failedAttachments=Le.failedAttachments}setPendingApprovalDialogShown(t){this.hasPendingApprovalDialogBeenShown=t}async checkPermissions(){this.loadings.ticketCreatePermissionChecks=!0,this.permissions.hasCustomerCareCreatePermission=await hn(),this.permissions.hasFacilityAccessCreatePermission=await kn(),this.permissions.hasRemoteHandsCreatePermission=await yn(),this.permissions.hasDeliveriesAndRemovalsCreatePermission=await Ci(),this.permissions.hasTroubleTicketsCreatePermission=await Tn(),this.loadings.ticketCreatePermissionChecks=!1}async postAttachments(t,i,s,n,o){i&&i.length>0&&(this.error.uploadingAttachments=!1,this.failedAttachments=i.map(a=>a.fileName),await Promise.all(i.map(async a=>{try{const r=await Pt(t,a.file,a.fileName,a.fileType,s,o);n&&r!=null&&r.id&&(this.attachments.push(r),this.failedAttachments=this.failedAttachments.filter(d=>d!==a.fileName))}catch(r){await l(r,!1),this.error.uploadingAttachments=!0}})))}async GetServiceTicketList(t,i,s,n,o,a){var r,d;this.loadings.serviceTicketList=!0,this.error.serviceTicketsGrid=!1;try{this.serviceTickets=await m.serviceTicketApi.getServiceTickets({$filter:t,$orderby:i,$skip:s,$top:n,permissionPrivilege:o},a)}catch(u){if(!((r=a==null?void 0:a.signal)===null||r===void 0)&&r.aborted)return;l(u,!1),this.serviceTickets=void 0,this.error.serviceTicketsGrid=!0}finally{!((d=a==null?void 0:a.signal)===null||d===void 0)&&d.aborted||(this.loadings.serviceTicketList=!1)}}async downloadServiceTickets(t,i){this.loadings.downloadServiceTicketList=!0,await up(t,i),this.loadings.downloadServiceTicketList=!1}get ticketAttachments(){return this.attachments.filter(t=>!t.isError).map(t=>({name:t.fileName}))}}const k=new vp,ke={newTicket:{isValid:!1,accountNumber:"",attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1,ticketDetailsPermissionCheck:!1}};class gp{constructor(){this.newTicket=ke.newTicket,this.submissionResult=ke.submissionResult,this.selectedTicket=ke.selectedTicket,this.loadings=ke.loadings,se(this),Je(this,{name:"removals",properties:[],storage:window.localStorage})}createTicket(){var t,i,s;this.newTicket={...ke.newTicket,site:(t=this.newTicket.site)!==null&&t!==void 0?t:void 0,serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0,accountNumber:(s=this.newTicket.accountNumber)!==null&&s!==void 0?s:"NOT FOUND"},this.submissionResult=ke.submissionResult}updateIsFormValid(t){this.newTicket.isValid=t}updateSite(t){this.newTicket.site=t}updateSubject(t){this.newTicket.subject=t}updateShortDesc(t){this.newTicket.shortDescription=t}updateCourier(t){this.newTicket.courier=t}updateOtherCompany(t){this.newTicket.otherCompany=t}updateTrackingNumber(t){this.newTicket.trackingNumber=t}updatePickupDate(t){this.newTicket.pickupDate=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateRemovalParty(t){this.newTicket.removalParty=t}updateContacts(t){this.newTicket.contacts=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.result=void 0;try{this.submissionResult.result=await m.removalsApi.createRemoval({removalTicketsRequest:tp(this.newTicket)})}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&(await k.postAttachments(y.Removals,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0)}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async hasTicketPermissionAtLocation(t,i,s,n){try{return this.loadings.ticketDetailsPermissionCheck=!0,await Ct(t,i,s,n)}finally{this.loadings.ticketDetailsPermissionCheck=!1}}async setNewTicket(){try{this.newTicket=await sp(this.submissionResult.result)||ke.newTicket}catch(t){throw await l(t,!1),t}}async getRemovalsServiceTicket(t){if(t)try{const i=await m.removalsApi.getRemovalById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await Un(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async editTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{t=await m.removalsApi.updateRemovalById({ticketId:this.newTicket.id||"",removalsTicketsUpdateRequest:ip(this.newTicket)}),this.submissionResult.result=t,this.submissionResult.state=w.Submitted}catch(i){this.submissionResult.state=w.Error,await l(i,!1)}try{await k.postAttachments(y.Removals,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await Un(t),await this.setNewTicket())}catch(i){throw await l(i,!1),i}}finally{this.loadings.isSubmitting=!1}}async cancelTicket(t){var i,s;try{if(k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id){const n=(s=this.selectedTicket)===null||s===void 0?void 0:s.id;await m.removalsApi.cancellationRemovalRequest({ticketId:n,cancellationTicketsRequest:{cancellationReason:t}}),await this.getRemovalsServiceTicket(n)}}catch(n){throw await l(n,!1),n}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=ke.newTicket,this.selectedTicket=ke.selectedTicket,this.submissionResult=ke.submissionResult,this.loadings=ke.loadings}}const Ve=new gp,ye={newTicket:{isValid:!1,isLoadingBayRequired:!1,needRemoteHands:!1,accountNumber:"",contacts:"",attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default,result:void 0},loadings:{isSubmitting:!1,isDeliveryBlocked:!1,ticketDetailsPermissionCheck:!1}};class wp{constructor(){this.newTicket=ye.newTicket,this.submissionResult=ye.submissionResult,this.selectedTicket=ye.selectedTicket,this.loadings=ye.loadings,se(this),Je(this,{name:"deliveries",properties:[],storage:window.localStorage})}createTicket(){var t,i,s;this.newTicket={...ye.newTicket,site:(t=this.newTicket.site)!==null&&t!==void 0?t:void 0,serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0,accountNumber:(s=this.newTicket.accountNumber)!==null&&s!==void 0?s:"NOT FOUND"},this.submissionResult=ye.submissionResult}addPackage(t,i){var s;if(!t)return;const n=(s=this.newTicket.packages)!==null&&s!==void 0?s:[];i?this.newTicket.packages=n.map(o=>o.id===t.id?t:o):this.newTicket.packages=[...n,t]}removePackage(t){var i;if(t){const s=((i=this.newTicket.packages)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.packages=[...s]}}updateSite(t){this.newTicket.site=t,this.newTicket.packages=[]}updateSubject(t){this.newTicket.subject=t}updateShortDesc(t){this.newTicket.shortDescription=t}updateEstimatedDate(t){this.newTicket.estimatedDate=t}updateLatestDate(t){this.newTicket.latestDate=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateLoadingBay(t){this.newTicket.isLoadingBayRequired=t}updateNeedRemoteHands(t){this.newTicket.needRemoteHands=t}updateInstructions(t){this.newTicket.instructions=t}updateContacts(t){this.newTicket.contacts=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateIsValid(t){this.newTicket.isValid=t}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await m.deliveriesApi.createDelivery({deliveryTicketsRequest:qn(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&await k.postAttachments(y.Deliveries,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await jm(this.submissionResult.result)||ye.newTicket}catch(t){throw await l(t,!1),t}}async updateTicketRequest(){var t,i;let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await m.deliveriesApi.updateDeliveriesTickets({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",deliveryTicketsUpdateRequest:qn(this.newTicket,!0)});const n=((i=this.newTicket)===null||i===void 0?void 0:i.packages)||[],o=(await Promise.all(n.map(async a=>{var r;return m.deliveriesApi.updateDeliveriesTicketsPackages({ticketId:((r=this.selectedTicket)===null||r===void 0?void 0:r.id)||"",packageId:(a==null?void 0:a.id)||"",deliveryTicketUpdatePackagesRequest:Pn(a,this.newTicket.serviceBackend)}).then(d=>{var u,p;return(p=(u=d.packages)===null||u===void 0?void 0:u.find(A=>A.id===a.id))!==null&&p!==void 0?p:null}).catch(d=>(l(d,!1),null))}))).filter(a=>a!==null);s&&(s.packages=s.packages.map(a=>{const r=o.find(d=>a.id===d.id);return r!=null?r:a})),this.submissionResult.result=s,this.submissionResult.state=w.Submitted}catch(n){throw this.submissionResult.state=w.Error,await l(n,!1),n}try{await k.postAttachments(y.Deliveries,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(n){await l(n,!1)}try{this.selectedTicket=await On(s),await this.setNewTicket()}catch(n){await l(n,!1)}}finally{this.loadings.isSubmitting=!1}}async hasTicketPermissionAtLocation(t,i,s,n){this.loadings.ticketDetailsPermissionCheck=!0;const o=await Ct(t,i,s,n);return this.loadings.ticketDetailsPermissionCheck=!1,o}async getDeliveriesServiceTicket(t){if(t)try{const i=await m.deliveriesApi.getDeliveryById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await On(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelDelivery(t,i){try{k.loadings.isTicketCancelling=!0,t&&(await m.deliveriesApi.cancellationDeliveryRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}),await this.getDeliveriesServiceTicket(t))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async isDeliveryBlocked(t,i){var s;let n;return this.loadings.isDeliveryBlocked=!0,t&&i&&(n=await m.deliveriesApi.getDeliveryDiscovery({site:t,accountNumber:i}).catch(o=>{l(o,!1)})),this.loadings.isDeliveryBlocked=!1,(s=n==null?void 0:n.deliveryBlocked)!==null&&s!==void 0?s:!0}clear(){this.newTicket=ye.newTicket,this.selectedTicket=ye.selectedTicket,this.submissionResult=ye.submissionResult,this.loadings=ye.loadings}}const Te=new wp,be={newTicket:{isValid:!1,accountNumber:"",disableReferenceTicketNumber:!1,attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1,ticketDetailsPermissionCheck:!1,requestType:!1}};class fp{constructor(){this.newTicket=be.newTicket,this.submissionResult=be.submissionResult,this.selectedTicket=be.selectedTicket,this.loadings=be.loadings,se(this),Je(this,{name:"remote-hands",properties:[],storage:window.localStorage})}createTicket(t){var i,s,n,o;const a=(i=this.newTicket.accountNumber)!==null&&i!==void 0?i:ae.getUserAccount().accountNumber;this.newTicket={...be.newTicket,site:(s=this.newTicket.site)!==null&&s!==void 0?s:void 0,accountNumber:a!=null?a:"NOT FOUND",serviceBackend:t,referenceTicketNumber:(n=this.newTicket.referenceTicketNumber)!==null&&n!==void 0?n:void 0,disableReferenceTicketNumber:(o=this.newTicket.disableReferenceTicketNumber)!==null&&o!==void 0?o:void 0},this.submissionResult=be.submissionResult}updateSite(t,i=!1){this.newTicket.site=t,this.newTicket.isValid=i}updateLocation(t){this.newTicket.location=t}updateSubject(t){this.newTicket.subject=t}updateDescription(t){this.newTicket.description=t}updateRequestType(t){this.newTicket.requestType=t,this.newTicket.category=void 0}updateCategory(t){this.newTicket.category=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateReferenceTicketNumber(t){this.newTicket.referenceTicketNumber=t}updateReferenceNumberDisable(t){this.newTicket.referenceTicketNumber=t,this.newTicket.disableReferenceTicketNumber=!0}updateStartDate(t){this.newTicket.startDate=t}updateStartTime(t){this.newTicket.startTime=t}updateContacts(t){this.newTicket.contacts=t}updateAccountNumber(t){this.newTicket.accountNumber=t}updateFormValidation(t){this.newTicket.isValid=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}updateTermsAgreed(t){this.newTicket.termsAgreed=t}async setNewTicket(){try{this.newTicket=await Zm(this.submissionResult.result)||be.newTicket}catch(t){throw await l(t,!1),t}}async updateTicketRequest(){var t;let i;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{i=await m.remoteHandsApi.updateRemoteHandsTicketById({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",remoteHandsUpdateRequest:Gm(this.newTicket)}),this.submissionResult.result=i,this.submissionResult.state=w.Submitted}catch(s){this.submissionResult.state=w.Error,await l(s,!1)}try{await k.postAttachments(y.RemoteHands,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(s){await l(s,!1)}try{i&&(this.selectedTicket=await xn(i))}catch(s){await l(s,!1)}}catch(s){throw await l(s,!1),s}finally{this.loadings.isSubmitting=!1}}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await m.remoteHandsApi.createRemoteHandsTicket({remoteHandsRequest:Wm(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.ticketId&&(await k.postAttachments(y.RemoteHands,this.newTicket.attachments,this.submissionResult.result.ticketId),this.newTicket.attachments=void 0)}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async getRemoteHandsServiceTicket(t){if(t)try{const i=await m.remoteHandsApi.getRemoteHandsTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await xn(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.remoteHandsApi.cancellationRemoteHandsRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getRemoteHandsServiceTicket(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=be.newTicket,this.selectedTicket=be.selectedTicket,this.submissionResult=be.submissionResult,this.loadings=be.loadings}}const re=new fp,kp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Re={newTicket:{isValid:!1,accountNumber:"",attachments:[],locations:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1}};class yp{constructor(){this.newTicket=Re.newTicket,this.submissionResult=Re.submissionResult,this.selectedTicket=Re.selectedTicket,this.loadings=Re.loadings,se(this),Je(this,{name:"trouble-tickets",properties:[],storage:window.localStorage})}getIsInProgress(){var t;return((t=this.selectedTicket)===null||t===void 0?void 0:t.state)===O.InProgress}createTicket(t){var i,s;const{accountNumber:n}=ae.getUserAccount();this.newTicket={...Re.newTicket,site:(i=this.newTicket.site)!==null&&i!==void 0?i:void 0,accountNumber:n!=null?n:"NOT FOUND",referenceTicketNumber:t,serviceBackend:(s=this.newTicket.serviceBackend)!==null&&s!==void 0?s:void 0},this.submissionResult=Re.submissionResult}updateSite(t,i=!1){this.newTicket.site=t,this.newTicket.isValid=i}updateLocations(t,i){var s,n,o;if(i)(o=this.newTicket.locations)===null||o===void 0||o.push(t);else{const a=(s=this.newTicket.locations)===null||s===void 0?void 0:s.indexOf(t);a!==void 0&&a!==-1&&((n=this.newTicket.locations)===null||n===void 0||n.splice(a,1))}}clearLocations(){this.newTicket.locations=[]}updateSubject(t){this.newTicket.subject=t}updateDescription(t){this.newTicket.description=t}updateRequestType(t){this.newTicket.requestType=t,this.newTicket.category=void 0}updateCategory(t){this.newTicket.category=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateReferenceTicketNumber(t){this.newTicket.referenceTicketNumber=t}updateReferenceNumberDisable(t){this.newTicket.referenceTicketNumber=t}updateCircuitId(t){this.newTicket.circuitId=t}updateContacts(t){this.newTicket.contacts=t}updateAccountNumber(t){this.newTicket.accountNumber=t}updateFormValidation(t){this.newTicket.isValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}async submitNewTicketRequest(){var t,i;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.result=void 0;try{this.submissionResult.result=await m.troubleTicketsApi.createTroubleTicketTicket({troubleTicketRequest:ap(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(s){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(s,!1),s}try{!((i=(t=this.submissionResult)===null||t===void 0?void 0:t.result)===null||i===void 0)&&i.id&&(await k.postAttachments(y.TroubleTickets,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0)}catch(s){throw await l(s,!1),s}finally{this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Oi(this.submissionResult.result)||Re.newTicket}catch(t){throw await l(t,!1),t}}async submitUpdateTicketRequest(){var t,i;if(this.newTicket&&this.selectedTicket&&this.selectedTicket.id){let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await m.troubleTicketsApi.updateTroubleTicketTicket({ticketId:(t=this.selectedTicket.id)!==null&&t!==void 0?t:"",troubleTicketUpdateRequest:op(this.newTicket)}),this.submissionResult.result=s}catch(n){this.submissionResult.state=w.Error,await l(n,!1)}try{await k.postAttachments(y.TroubleTickets,this.newTicket.attachments,(i=this.selectedTicket)===null||i===void 0?void 0:i.id,!0),this.newTicket.attachments=void 0}catch(n){await l(n,!1)}try{s&&(this.submissionResult.state=w.Submitted,this.submissionResult.result=s,this.selectedTicket=await Oi(this.submissionResult.result),await this.setNewTicket())}catch(n){await l(n,!1)}}finally{this.loadings.isSubmitting=!1}}}async getTroubleTicketById(t){if(t)try{const i=await m.troubleTicketsApi.getTroubleTicketTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await Oi(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.troubleTicketsApi.cancellationTroubleTicketRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getTroubleTicketById(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=Re.newTicket,this.selectedTicket=Re.selectedTicket,this.submissionResult=Re.submissionResult,this.loadings=Re.loadings}}const Ue=new yp,Tp={"Visitor First Name":"visitorFirstName","Visitor Last Name":"visitorLastName","Visitor Email Address":"visitorEmailAddress","Visitor Phone Number":"visitorPhoneNumber"},zn=40,$i="bulk_";function mt(e){return e.startsWith("WO")}function bp(e){return e.startsWith("CS")||e.startsWith("DEL")}function Rp(e,t){return e?Jt.Escorted:t==="Standard"?Jt.Standard:Jt.Extended}function Ap(e){return e?e==="Escorted"?{isEscortedVisitor:!0,visitorBadge:void 0}:{isEscortedVisitor:!1,visitorBadge:e==="Standard"?"Standard":"Extended"}:{isEscortedVisitor:void 0,visitorBadge:void 0}}function _p(e){return e.map(t=>{var i;return{siteCode:t.site.siteId,visitorHostId:(i=t.visitorHost)===null||i===void 0?void 0:i.id,locations:t.locations.map(s=>({id:s.id,startDate:Z(s.startDate),endDate:Z(s.endDate)}))}})}const Ip=e=>({otherNotificationRecipients:e.contacts,visitorPhone:e.visitors[0].phone});async function jn(e,t,i,s,n,o){var a,r;const d=(a=J.sites.find(u=>u.locationId===e))===null||a===void 0?void 0:a.id;return[{site:new Oe(e,d,t),locations:(r=i==null?void 0:i.map(u=>({id:u.id||"-",site:d,startDate:u.startDate||"",endDate:u.endDate||"",status:u.approvalStatus||"-",modifiedBy:u.modifiedBy||"-"})))!==null&&r!==void 0?r:[],isVisitorHostDetailsValid:s,visitorHost:n,serviceBackend:o}]}const Sp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Np=e=>{var t,i,s,n;return{accountNumber:e.accountNumber,visitors:e.visitors.map(o=>({firstName:o.firstName,lastName:o.lastName,email:o.email,phone:o.phone})),visitStartDate:Z(e.startDate),visitEndDate:Z(e.endDate),visitType:Rp((t=e.isEscortedVisitor)!==null&&t!==void 0?t:!1,e.visitorBadge),sites:_p(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:(i=e.hostFirstName)!==null&&i!==void 0?i:"",visitorHostLastName:(s=e.hostLastName)!==null&&s!==void 0?s:"",representingCompany:(n=e.representingCompany)!==null&&n!==void 0?n:"",description:e.notes,notificationRecipients:e.contacts}},Mn=async e=>{var t,i,s,n;if(!e)return;const o=mt(e.id)?H.Insite:H.ServiceNow;return{id:e.id,accountNumber:e.accountNumber||"-",accountName:e.accountName||"-",contacts:e.notificationRecipients||"",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt.toISOString(),updatedOn:e.updatedAt.toISOString(),requestType:"Visitor Access",category:"New Visitor Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",id:""}],visitorType:e.visitType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",startDate:e.visitStartDate,endDate:e.visitEndDate,representingCompany:e.representingCompany||"-",notes:e.description||"-",site:e.site,cancellationReason:e.cancellationReason,sitesDetails:await jn((t=e.site)!==null&&t!==void 0?t:"-",(i=e.accountNumber)!==null&&i!==void 0?i:"-",(s=e.locations)!==null&&s!==void 0?s:[],!0,{firstName:e.visitorHostFirstName,lastName:e.visitorHostLastName},o),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,comments:(n=e.comments)===null||n===void 0?void 0:n.map(a=>M(a))}},Cp=async e=>{var t,i,s;if(!e)return;const{isEscortedVisitor:n,visitorBadge:o}=Ap(e.visitType),a=mt(e.id)?H.Insite:H.ServiceNow;return{id:e==null?void 0:e.id,accountNumber:e.accountNumber||"",contacts:e.notificationRecipients||"",requestType:"Visitor Access",category:"New Visitor Access",visitors:[{firstName:e.visitorFirstName||"",lastName:e.visitorLastName||"",email:e.visitorEmail||"",phone:e.visitorPhone||""}],escortFirstName:e.escortFirstName||"",escortLastName:e.escortLastName||"",startDate:e.visitStartDate,endDate:e.visitEndDate,representingCompany:e.representingCompany||"-",notes:e.description||"-",sitesDetails:await jn((t=e.site)!==null&&t!==void 0?t:"-",(i=e.accountNumber)!==null&&i!==void 0?i:"-",(s=e.locations)!==null&&s!==void 0?s:[],!0,{firstName:e.visitorHostFirstName,lastName:e.visitorHostLastName},a),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,cancellationReason:e.cancellationReason,visitorBadge:o,isEscortedVisitor:n,isFileAttachedForVisitors:!1,isNotificationsAttachmentsValid:!0,isRequestedAccessDetailsValid:!0,isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0}},Jn=e=>{const{visitorFirstName:t,visitorLastName:i,visitorEmailAddress:s,visitorPhoneNumber:n}=e;if(!t||!i||!s)return"Error: First name, last name and email are required.";const o=!Nn(s),a=n&&n.length>0&&!ha(n);if(o&&a)return"Error: Invalid visitor email address and phone number";if(o)return"Error: Invalid visitor email address";if(a)return"Error: Invalid visitor phone number"};async function Pp(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.VisitorAccess,permissionPrivilege:e}),Ze({locationType:Nt,permissionType:S.VisitorAccess,permissionPrivilege:e,assignableProcess:"Facilities_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId)}))}const ce={newTicket:{isRequestedAccessDetailsValid:!1,isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isNotificationsAttachmentsValid:!1,isRepresentingCompanyValid:!1,accountNumber:void 0,visitors:[],contacts:"",attachments:[],isEscortedVisitor:!1,startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard"},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class qp{constructor(){this.DuplicateEmailErrorMessage="Each visitor must have a unique email address.",this.newTicket=ce.newTicket,this.submissionResult=ce.submissionResult,this.selectedTicket=ce.selectedTicket,this.loadings=ce.loadings,this.isEditAttachmentAdded=ce.isEditAttachmentAdded,se(this)}createTicket(){var t,i;const s=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...ce.newTicket,accountNumber:s,requestType:"Visitor Access",category:"New Visitor Access",serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0},this.submissionResult=ce.submissionResult}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}get isVisitorHostDetailsValid(){var t;return((t=this.newTicket.sitesDetails)===null||t===void 0?void 0:t.some(i=>i.isVisitorHostDetailsValid===!1))===!1}isVisitorHostDetailsValidBySite(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.isVisitorHostDetailsValid=i)}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}isRepresentingCompanyValid(t){this.newTicket.isRepresentingCompanyValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}removeBulkAttachment(){var t;this.newTicket.attachments=(t=this.newTicket.attachments)===null||t===void 0?void 0:t.filter(i=>{var s;return!(!((s=i.fileName)===null||s===void 0)&&s.startsWith($i))})}get isNewTicketValid(){return this.newTicket.isVisitorContactsDetailsValid&&this.newTicket.isVisitorEscortedDetailsValid&&this.isVisitorHostDetailsValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isRepresentingCompanyValid&&this.newTicket.isNotificationsAttachmentsValid}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.visitorHost=i,n.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}updateIsFileAttachedForVisitors(t){this.newTicket.isFileAttachedForVisitors=t}validateNoDuplicateEmails(t){const i=[...t];i.forEach((n,o)=>{n.validationError===this.DuplicateEmailErrorMessage&&(i[o]={...n,validationError:void 0,isValid:!0})});const s=i.filter(n=>!n.validationError);return i.forEach((n,o)=>{n.validationError||s.filter(a=>a.email.toLowerCase()===n.email.toLowerCase()).length>1&&(i[o]={...n,validationError:this.DuplicateEmailErrorMessage,isValid:!1})}),i}addOrUpdateVisitor(t){var i;if(!t)return;const s=(i=this.newTicket.visitors)!==null&&i!==void 0?i:[],n=s.findIndex(a=>a.id===t.id),o=n!==-1;if(!(!o&&s.length>=zn))if(this.newTicket.id)this.newTicket.visitors=[t];else{let a;t.isUploadedFromFile&&(a=Jn({visitorFirstName:t.firstName,visitorLastName:t.lastName,visitorEmailAddress:t.email,visitorPhoneNumber:t.phone}));const r={...t,validationError:a,isValid:!a},d=[...s];o?d[n]=r:d.push(r),this.newTicket.visitors=this.validateNoDuplicateEmails(d)}}addBulkVisitors(t){t.forEach(i=>{const s=Jn(i),n={id:crypto.randomUUID(),firstName:i.visitorFirstName,lastName:i.visitorLastName,email:i.visitorEmailAddress,phone:i.visitorPhoneNumber,isUploadedFromFile:!0,validationError:s,isValid:!s};this.addOrUpdateVisitor(n)})}removeBulkVisitors(){var t;const i=((t=this.newTicket.visitors)!==null&&t!==void 0?t:[]).filter(s=>s.isUploadedFromFile!==!0);this.newTicket.visitors=[...i]}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=this.validateNoDuplicateEmails(s)}}removeAllVisitors(){this.newTicket.visitors=[]}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.endDate=t})})}updateRepresentingCompany(t){this.newTicket.representingCompany=t}updateNotes(t){this.newTicket.notes=t}async addSiteLocations(t){var i;if(t){const s=await K.getServiceBackend(t.site.accountNumber,t.site.siteId,"Facilities_access"),n=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId),o={...t,serviceBackend:s};this.newTicket.sitesDetails=[...n,o]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i,s,n;let o;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{o=await m.facilityAccessApi.visitorAccess.createVisitorAccessTicket({visitorAccessTicketRequest:Np(this.newTicket)}),this.submissionResult.ticketNumbers=o==null?void 0:o.ticketNumbers}catch(a){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(a,!1),a}try{if(o){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(u=>u.fileName);const{ticketNumbers:a}=o,r=(i=a==null?void 0:a.filter(u=>bp(u)))!==null&&i!==void 0?i:[],d=(s=a==null?void 0:a.filter(u=>mt(u)))!==null&&s!==void 0?s:[];a!=null&&a.length&&!((n=this.newTicket.attachments)===null||n===void 0)&&n.length&&await Promise.all(this.newTicket.attachments.map(async u=>{const p=[];let A=[];u.fileName.startsWith($i)?(r.length>0&&A.push(r[0]),d.length>0&&A.push(...d)):A=a,p.push(...A.map(async C=>Pt(y.FacilityAccess,u.file,u.fileName,u.fileType,C,this.newTicket.requestType))),await Promise.all(p).then(()=>{var C;k.failedAttachments=((C=this.newTicket.attachments)!==null&&C!==void 0?C:[]).filter(b=>b.fileName!==u.fileName).map(b=>b.fileName)})})),this.newTicket.attachments=void 0}}catch(a){throw k.error.uploadingAttachments=!0,await l(a,!1),a}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Cp(this.submissionResult.ticketResponse)||ce.newTicket}catch(t){throw await l(t,!1),t}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await m.facilityAccessApi.visitorAccess.updateVisitorAccessTicket({visitorAccessTicketUpdateRequest:Ip(this.newTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t.id]}catch(i){this.submissionResult.state=w.Error,await l(i,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"Visitor Access"),this.newTicket.attachments=void 0}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await Mn(t),await this.setNewTicket())}catch(i){await l(i,!1)}}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async getVisitorAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.visitorAccess.getVisitorAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Mn(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t,i){try{k.loadings.isTicketCancelling=!0,k.error.cancellingTicket=!1,t&&(await m.facilityAccessApi.visitorAccess.cancellationVisitorAccessRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}).catch(s=>{throw l(s,!1),s}),await this.getVisitorAccessServiceTicket(t))}catch(s){throw k.error.cancellingTicket=!0,await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async hasUpdatePermissions(){try{return!!await Ke(this.selectedTicket.sitesDetails[0].locations.map(t=>t.id),S.VisitorAccess,U.Update)}catch(t){return!1}}clearNewTicket(){this.newTicket=ce.newTicket}async patchLocationsApprovalStatus(t){var i,s;const n=t.map(o=>({id:o.id,approvalStatus:us[o.status]}));await m.facilityAccessApi.visitorAccess.updateVisitorAccessLocationsTicket({ticketId:((i=this.selectedTicket)===null||i===void 0?void 0:i.id)||"",locationsPatchRequestInner:n}),await this.getVisitorAccessServiceTicket((s=this.selectedTicket)===null||s===void 0?void 0:s.id)}async getVisitorHosts(t,i,s,n=1,o=10){return await m.facilityAccessApi.visitorHost.getVisitorHostsList({site:t,nameOrEmailContains:i,pageNumber:n,pageSize:o},s).catch(r=>{var d;!((d=s==null?void 0:s.signal)===null||d===void 0)&&d.aborted||l(r,!1)})||{items:[],totalCount:0}}clear(){this.newTicket=ce.newTicket,this.selectedTicket=ce.selectedTicket,this.submissionResult=ce.submissionResult,this.loadings=ce.loadings,this.isEditAttachmentAdded=ce.isEditAttachmentAdded}}const ie=new qp;function Dp(e){return e.flatMap(t=>t.locations).map(t=>({id:t.id,startDate:Z(t.startDate),endDate:Z(t.endDate)}))}function Bp(e){return e.flatMap(t=>t.locations).map(t=>({id:t.id,startDate:Z(t.startDate),endDate:Z(t.endDate),operation:"add"}))}const Op=e=>{var t;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",badgeholderFirstName:e.badgeHolder.firstName,badgeholderLastName:e.badgeHolder.lastName,badgeholderEmail:e.badgeHolder.email,badgeholderCompany:e.badgeHolder.company,badgeholderPhone:e.badgeHolder.phone,badgeStartDate:Z(e.startDate),badgeEndDate:Z(e.endDate),locations:Dp(e.sitesDetails||[]),notificationRecipients:e.contacts}},$p=e=>({otherNotificationRecipients:e.contacts}),Ep=e=>({otherNotificationRecipients:e.contacts}),xp=()=>({}),Fp=e=>{var t;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",badgeholderId:e.badgeHolder.id,badgeStartDate:Z(e.startDate),badgeEndDate:Z(e.endDate),locations:Bp(e.sitesDetails||[]),notificationRecipients:e.contacts}},Lp=e=>({badgeholderId:e.badgeHolder.id,accountNumber:e.badgeHolder.accountNumber,badgeEndDate:Z(e.endDate)});async function Wn(e,t=""){if(!e)return[];const i=e.map(a=>({id:a.id||"-",site:a.site||"",siteAddress:a.siteAddress,startDate:a.startDate||"",endDate:a.endDate||"",status:a.approvalStatus||"-",modifiedBy:a.modifiedBy||"-"})),s=[...new Set(i.map(a=>a.site))],n={};await Promise.all(s.map(async a=>{var r;n[a]=(r=await vm(a))!==null&&r!==void 0?r:a}));const o=[];return i.forEach(a=>{const{site:r}=a,d=o.find(u=>u.site.siteId===r);d?d.locations.push(a):o.push({site:new Oe(n[r],r,t),locations:[a]})}),o}const Gn=async e=>{var t,i,s;if(e)return{id:e==null?void 0:e.id,accountNumber:e.accountNumber||"-",accountName:e.accountName||"-",contacts:e.notificationRecipients||"",state:e.status||"-",requester:e.createdBy||"-",createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),requestType:"Permanent Badge",category:e.requestType,visitors:[{firstName:e.badgeholderFirstName||"-",lastName:e.badgeholderLastName||"-",email:e.badgeholderEmail||"-",phone:e.badgeholderPhone,company:e.badgeholderCompany||"-"}],startDate:e.badgeStartDate,endDate:e.badgeEndDate,sitesDetails:await Wn(e.locations,e.accountNumber),cancellationReason:e.cancellationReason,comments:(s=e.comments)===null||s===void 0?void 0:s.map(n=>M(n))}},Vp=async e=>{if(e)return{id:e==null?void 0:e.id,contacts:e.notificationRecipients,requestType:"Permanent Badge",category:e.requestType,visitors:[{firstName:e.badgeholderFirstName||"",lastName:e.badgeholderLastName||"",email:e.badgeholderEmail||"",phone:e.badgeholderPhone||"",company:e.badgeholderCompany||""}],badgeHolder:{firstName:e.badgeholderFirstName||"",lastName:e.badgeholderLastName||"",email:e.badgeholderEmail||"",phone:e.badgeholderPhone||"",company:e.badgeholderCompany||""},startDate:e.badgeStartDate,endDate:e.badgeEndDate,sitesDetails:await Wn(e.locations,e.accountNumber),isNotificationsAttachmentsValid:!0,isRequestedAccessDetailsValid:!0,isVisitorContactsDetailsValid:!0,isEndDateValid:!0,isBadgeholderValid:!0}},Up=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Zn=e=>e.map(t=>({id:t.id,accountNumber:t.accountNumber,firstName:t.firstName,lastName:t.lastName,email:t.email,phone:t.phone,company:t.representingCompany,startDate:t.badgeStartDate?St(t.badgeStartDate):void 0})),Hp=(e,t)=>[...e,...Zn(t)];async function zp(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.PermanentBadge,permissionPrivilege:e}),Ze({locationType:Nt,permissionType:S.PermanentBadge,permissionPrivilege:e,assignableProcess:"Facilities_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId)}))}const de={newTicket:{isRequestedAccessDetailsValid:!1,isNotificationsAttachmentsValid:!1,isBadgeholderValid:!1,isStartDateSetViaBadgeHolder:!1,isEndDateValid:!1,accountNumber:void 0,contacts:"",badgeHolder:{},attachments:[],isVisitorContactsDetailsValid:!1,visitors:[]},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class jp{constructor(){this.newTicket=de.newTicket,this.submissionResult=de.submissionResult,this.selectedTicket=de.selectedTicket,this.loadings=de.loadings,this.isEditAttachmentAdded=de.isEditAttachmentAdded,se(this)}createTicket(){var t,i,s,n;const o=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...de.newTicket,accountNumber:o,requestType:(i=this.newTicket.requestType)!==null&&i!==void 0?i:void 0,category:(s=this.newTicket.category)!==null&&s!==void 0?s:void 0,serviceBackend:(n=this.newTicket.serviceBackend)!==null&&n!==void 0?n:void 0},this.submissionResult=de.submissionResult}updateStartDateSetViaBadgeholder(t){this.newTicket.isStartDateSetViaBadgeHolder=t}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}isBadgeholderValid(t){this.newTicket.isBadgeholderValid=t}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}isEndDateValid(t){this.newTicket.isEndDateValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}removeBulkAttachment(){throw new Error("Method not implemented.")}get isNewTicketValid(){switch(this.newTicket.category){case"New":return this.newTicket.isVisitorContactsDetailsValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isNotificationsAttachmentsValid;case"Modify":return this.newTicket.isBadgeholderValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isNotificationsAttachmentsValid;case"Terminate":return this.newTicket.isBadgeholderValid&&this.newTicket.isEndDateValid;default:return!1}}setBadgeHolder(t){this.newTicket.badgeHolder=t,t===void 0?this.newTicket.visitors=[]:this.newTicket.visitors=[{id:t.id,firstName:t.firstName,lastName:t.lastName,email:t.email,phone:t.phone,company:t.company}]}addOrUpdateVisitor(t){t&&this.setBadgeHolder(t)}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeVisitor(t){this.setBadgeHolder(void 0)}removeAllVisitors(){this.newTicket.visitors=[]}clearStartDate(){this.newTicket.startDate=void 0}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.endDate=t})})}async addSiteLocations(t){var i;if(t){const s=await K.getServiceBackend(t.site.accountNumber,t.site.siteId,"Facilities_access"),n=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId),o={...t,serviceBackend:s};this.newTicket.sitesDetails=[...n,o]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i;let s;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{switch(this.newTicket.category){case"New":s=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeNewTicket({permanentBadgeAccessNewTicketRequest:Op(this.newTicket)});break;case"Modify":s=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeModifyTicket({permanentBadgeAccessModifyTicketRequest:Fp(this.newTicket)});break;case"Terminate":s=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeTerminateTicket({permanentBadgeAccessTerminateTicketRequest:Lp(this.newTicket)});break;default:throw new Error("Invalid category")}this.submissionResult.ticketNumbers=s==null?void 0:s.ticketNumbers}catch(n){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(n,!1),n}try{if(s){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(o=>o.fileName);const{ticketNumbers:n}=s;n!=null&&n.length&&!((i=this.newTicket.attachments)===null||i===void 0)&&i.length&&await Promise.all(this.newTicket.attachments.map(async o=>Promise.all(n.map(async a=>Pt(y.FacilityAccess,o.file,o.fileName,o.fileType,a,this.newTicket.requestType))).then(()=>{var a;k.failedAttachments=((a=this.newTicket.attachments)!==null&&a!==void 0?a:[]).filter(r=>r.fileName!==o.fileName).map(r=>r.fileName)}))),this.newTicket.attachments=void 0}}catch(n){throw k.error.uploadingAttachments=!0,await l(n,!1),n}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}mapPermanentBadgeTicketToUpdateRequest(){switch(this.newTicket.category){case"Modify":return Ep(this.newTicket);case"New":return $p(this.newTicket);case"Terminate":return xp();default:throw new Error("Invalid category")}}async setNewTicket(){try{this.newTicket=await Vp(this.submissionResult.ticketResponse)||de.newTicket}catch(t){throw await l(t,!1),t}}async submitUpdateTicketRequest(){var t;let i;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{i=await((t=m.facilityAccessApi.permanentBadgeAccess)===null||t===void 0?void 0:t.updatePermanentBadgeTicket({permanentBadgeAccessTicketUpdateRequest:this.mapPermanentBadgeTicketToUpdateRequest(),ticketId:this.newTicket.id})),this.submissionResult.ticketResponse=i,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[i.id]}catch(s){await l(s,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"Permanent Badge"),this.newTicket.attachments=void 0}catch(s){await l(s,!1)}try{i&&(this.selectedTicket=await Gn(i),await this.setNewTicket())}catch(s){await l(s,!1)}}catch(s){throw await l(s,!1),this.submissionResult.state=w.Error,s}finally{this.loadings.isSubmitting=!1}}async getPermanentBadgeAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.permanentBadgeAccess.getPermanentBadgeTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Gn(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t,i){try{k.loadings.isTicketCancelling=!0,k.error.cancellingTicket=!1,t&&(await m.facilityAccessApi.permanentBadgeAccess.cancellationPermanentBadgeRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}).catch(s=>{throw l(s,!1),s}),await this.getPermanentBadgeAccessServiceTicket(t))}catch(s){throw k.error.cancellingTicket=!0,await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async hasUpdatePermissions(){try{return!!await Ke(this.selectedTicket.sitesDetails[0].locations.map(t=>t.id),S.PermanentBadge,U.Update)}catch(t){return!1}}async getAttachments(t,i){return Hn(y.FacilityAccess,t,i)}async getPermanentBadgeHolders(t,i,s=1,n=10){return await m.facilityAccessApi.permanentBadgeAccess.getPermanentBadgeHoldersList({accountNumber:this.newTicket.accountNumber,activeBadge:!0,nameOrEmailContains:t,page:s,size:n},i).catch(a=>{var r;!((r=i==null?void 0:i.signal)===null||r===void 0)&&r.aborted||l(a,!0)})||{items:[],totalCount:0}}clearNewTicket(){this.newTicket=de.newTicket}async patchLocationsApprovalStatus(t){var i,s,n;const o=t.map(a=>({id:a.id,approvalStatus:us[a.status]}));await((i=m.facilityAccessApi.permanentBadgeAccess)===null||i===void 0?void 0:i.updatePermanentBadgeLocationsTicket({ticketId:((s=this.selectedTicket)===null||s===void 0?void 0:s.id)||"",locationsPatchRequestInner:o}).catch(a=>{l(a,!1)})),await this.getPermanentBadgeAccessServiceTicket((n=this.selectedTicket)===null||n===void 0?void 0:n.id).catch(a=>{l(a,!1)})}clear(){this.newTicket=de.newTicket,this.selectedTicket=de.selectedTicket,this.submissionResult=de.submissionResult,this.loadings=de.loadings,this.isEditAttachmentAdded=de.isEditAttachmentAdded}}const Y=new jp;function Mp(e){return e.flatMap(t=>t.locations.map(i=>({id:i.id,startDateTime:Be(i.startDate,i.startTime,t.site.siteId),endDateTime:Be(i.endDate,i.endTime,t.site.siteId)})))}async function Kn(e){var t,i,s;const{timeZone:n,id:o}=((t=J.sites)===null||t===void 0?void 0:t.find(d=>d.locationId===e.site))||{},a=o?await An(o):[],r=new Map(a.map(d=>{var u;return[d.id,(u=d.name)!==null&&u!==void 0?u:d.id]}));return[{site:new Oe(e.site,o,e.accountNumber),locations:(s=(i=e.locations)===null||i===void 0?void 0:i.map(d=>{var u,p,A,C;return{id:d.id,name:r.get(d.id)||d.id,site:o,startDate:d.startDateTime&&n?(u=G(d.startDateTime).tz(n))===null||u===void 0?void 0:u.format(ct):"-",startTime:d.startDateTime&&n?(p=G(d.startDateTime).tz(n))===null||p===void 0?void 0:p.format($t):"-",endDate:d.endDateTime&&n?(A=G(d.endDateTime).tz(n))===null||A===void 0?void 0:A.format(ct):"-",endTime:d.endDateTime&&n?(C=G(d.endDateTime).tz(n))===null||C===void 0?void 0:C.format($t):"-"}}))!==null&&s!==void 0?s:[]}]}async function Jp(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.OSPAccess,permissionPrivilege:e}),Ze({locationType:ut.GreaterThan+F.Site,permissionType:S.OSPAccess,permissionPrivilege:e,assignableProcess:"OSP_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId),accountNumber:n.accountNumber}))}const Wp=e=>({accountNumber:e.accountNumber,visitors:e.visitors.map(t=>({firstName:t.firstName,lastName:t.lastName,email:t.email,company:t.company,phone:t.phone,visitorType:t.visitorType})),locations:Mp(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:e.hostFirstName,visitorHostLastName:e.hostLastName,customerExternalReference:e.customerExternalReference,serviceImpactedDescription:e.serviceImpactDescription,workDescription:e.workDescription,notificationRecipients:e.contacts}),ue=(e,t)=>e===t||!e&&!t||!e&&t==="-",Gp=(e,t)=>{var i,s;const n={};ue(e.visitors[0].phone,t.visitors[0].phone)||(n.visitorPhone=e.visitors[0].phone),ue(e.visitors[0].company,t.visitors[0].company)||(n.visitorCompany=e.visitors[0].company),(!ue(e.escortFirstName,t.escortFirstName)||!ue(e.escortLastName,t.escortLastName))&&(n.escortFirstName=e.escortFirstName,n.escortLastName=e.escortLastName),(!ue(e.hostFirstName,t.visitorHostFirstName)||!ue(e.hostLastName,t.visitorHostLastName))&&(n.visitorHostFirstName=e.hostFirstName,n.visitorHostLastName=e.hostLastName),ue(e.customerExternalReference,t.customerExternalReference)||(n.customerExternalReference=e.customerExternalReference),ue(e.serviceImpactDescription,t.serviceImpactDescription)||(n.serviceImpactedDescription=e.serviceImpactDescription),ue(e.workDescription,t.workDescription)||(n.workDescription=e.workDescription),ue(e.contacts,t.notificationRecipients)||(n.otherNotificationRecipients=e.contacts);const o=((i=e.sitesDetails)===null||i===void 0?void 0:i.flatMap(d=>d.locations))||[],a=((s=t.sitesDetails)===null||s===void 0?void 0:s.flatMap(d=>d.locations))||[],r=o.map(d=>{var u,p;const A=a.find(b=>b.id===d.id),C={id:d.id};return(!A||!ue(d.startDate,A.startDate)||!ue(d.startTime,A.startTime))&&(C.startDateTime=Be(d.startDate,d.startTime,(u=e.sitesDetails)===null||u===void 0?void 0:u[0].site.siteId)),(!A||!ue(d.endDate,A.endDate)||!ue(d.endTime,A.endTime))&&(C.endDateTime=Be(d.endDate,d.endTime,(p=e.sitesDetails)===null||p===void 0?void 0:p[0].site.siteId)),C}).filter(d=>d.startDateTime||d.endDateTime);return r.length&&(n.locations=r),Object.keys(n).length===0&&(n.visitorCompany=e.visitors[0].company),n},Yn=async e=>{var t;return{id:e.id||"-",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt||"-",updatedOn:e.updatedAt||"-",requestType:"OSP Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",company:e.visitorCompany||"-",visitorType:e.visitorType}],visitorType:e.visitorType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",visitorHostFirstName:e.visitorHostFirstName||"-",visitorHostLastName:e.visitorHostLastName||"-",site:e.site||"-",sitesDetails:await Kn(e),customerExternalReference:e.customerExternalReference||"-",serviceImpacted:e.serviceImpactedDescription?"Yes":"No",serviceImpactDescription:e.serviceImpactedDescription||"-",workDescription:e.workDescription||"-",notificationRecipients:e.notificationRecipients||"",cancellationReason:e.cancellationReason||"-",comments:(t=e.comments)===null||t===void 0?void 0:t.map(i=>M(i))}},Zp=async e=>{var t,i,s,n,o;if(e)return{isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0,isVisitorHostValid:!0,isRequestedAccessDetailsValid:!0,isServiceImpactedSectionValid:!0,isNotificationsAttachmentsValid:!0,accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",status:e.status,requestType:"OSP Access",category:"",visitors:[{firstName:(i=e.visitorFirstName)!==null&&i!==void 0?i:"",lastName:(s=e.visitorLastName)!==null&&s!==void 0?s:"",email:(n=e.visitorEmail)!==null&&n!==void 0?n:"",company:e.visitorCompany,phone:(o=e.visitorPhone)!==null&&o!==void 0?o:"",visitorType:e.visitorType}],isEscortedVisitor:!0,escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,visitorBadge:"Standard",sitesDetails:await Kn(e),contacts:e.notificationRecipients,customerExternalReference:e.customerExternalReference,isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription,workDescription:e.workDescription,termsAgreed:!0,id:e.id,attachments:[]}},Kp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),me={newTicket:{isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isVisitorHostValid:!1,isRequestedAccessDetailsValid:!1,isServiceImpactedSectionValid:!1,isNotificationsAttachmentsValid:!1,accountNumber:"",visitors:[],contacts:"",attachments:[],startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard",serviceType:void 0,isEscortedVisitor:!0,escortFirstName:void 0,escortLastName:void 0,hostCompany:void 0,hostFirstName:void 0,hostLastName:void 0},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Xn{constructor(){this.newTicket=me.newTicket,this.submissionResult=me.submissionResult,this.selectedTicket=me.selectedTicket,this.loadings=me.loadings,this.isEditAttachmentAdded=me.isEditAttachmentAdded,se(this)}async setNewTicket(){var t;try{this.newTicket=(t=await Zp(this.submissionResult.ticketResponse))!==null&&t!==void 0?t:me.newTicket}catch(i){throw await l(i,!1),i}}async getOSPAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.ospAccess.getOspAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Yn(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}createTicket(){var t;const i=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...me.newTicket,accountNumber:i,requestType:"OSP Access",category:""},this.submissionResult=me.submissionResult}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.visitorHost=i,n.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}addOrUpdateVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s,t]}}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s]}}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}async addSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s,t]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i;let s;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{s=await m.facilityAccessApi.ospAccess.createOspAccessTicket({oSPAccessTicketRequest:Wp(this.newTicket)}),this.submissionResult.ticketNumbers=s==null?void 0:s.ticketNumbers}catch(n){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(n,!1),n}try{if(s){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(o=>o.fileName);const{ticketNumbers:n}=s;n!=null&&n.length&&!((i=this.newTicket.attachments)===null||i===void 0)&&i.length&&await Promise.all(this.newTicket.attachments.map(async o=>Promise.all(n.map(async a=>Pt(y.FacilityAccess,o.file,o.fileName,o.fileType,a,this.newTicket.requestType))).then(()=>{var a;k.failedAttachments=((a=this.newTicket.attachments)!==null&&a!==void 0?a:[]).filter(r=>r.fileName!==o.fileName).map(r=>r.fileName)}))),this.newTicket.attachments=void 0}}catch(n){throw k.error.uploadingAttachments=!0,await l(n,!1),n}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await m.facilityAccessApi.ospAccess.updateOspAccessTicket({oSPAccessTicketUpdateRequest:Gp(this.newTicket,this.selectedTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t==null?void 0:t.id]}catch(i){this.submissionResult.state=w.Error,await l(i,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"OSP Access"),this.newTicket.attachments=void 0}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await Yn(t))}catch(i){await l(i,!1)}}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}updateFieldValue(t,i){this.newTicket[t]=i}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeBulkAttachment(){throw new Error("Method not implemented.")}removeAllVisitors(){this.newTicket.visitors=[]}async hasUpdatePermissions(){var t;try{return await bn((t=this.selectedTicket)===null||t===void 0?void 0:t.site)}catch(i){return!1}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.facilityAccessApi.ospAccess.cancellationOspAccessRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getOSPAccessServiceTicket(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}get isNewTicketValid(){const t=this.newTicket.isVisitorContactsDetailsValid,i=this.newTicket.isVisitorEscortedDetailsValid,s=this.newTicket.isVisitorHostValid,n=this.newTicket.isRequestedAccessDetailsValid,o=this.newTicket.isServiceImpactedSectionValid,a=this.newTicket.isNotificationsAttachmentsValid;return t&&i&&s&&n&&o&&a}clear(){this.newTicket=me.newTicket,this.selectedTicket=me.selectedTicket,this.submissionResult=me.submissionResult,this.loadings=me.loadings,this.isEditAttachmentAdded=me.isEditAttachmentAdded}}const Ie=new Xn;function Yp(e){return e.flatMap(t=>t.locations.map(i=>({id:i.id,startDateTime:Be(i.startDate,i.startTime,t.site.siteId),endDateTime:Be(i.endDate,i.endTime,t.site.siteId)})))}async function Qn(e){var t,i,s,n;const{timeZone:o,id:a}=(i=(t=J.sites)===null||t===void 0?void 0:t.find(u=>u.locationId===e.site))!==null&&i!==void 0?i:{},r=a?await _n(a):[],d=new Map(r.map(u=>{var p;return[u.id,(p=u.name)!==null&&p!==void 0?p:u.id]}));return[{site:new Oe(e.site,a,e.accountNumber),locations:(n=(s=e.locations)===null||s===void 0?void 0:s.map(u=>{var p,A,C,b;return{id:u.id,name:d.get(u.id)||u.id,site:a,startDate:u.startDateTime&&o?(p=G(u.startDateTime).tz(o))===null||p===void 0?void 0:p.format(ct):"-",startTime:u.startDateTime&&o?(A=G(u.startDateTime).tz(o))===null||A===void 0?void 0:A.format($t):"-",endDate:u.endDateTime&&o?(C=G(u.endDateTime).tz(o))===null||C===void 0?void 0:C.format(ct):"-",endTime:u.endDateTime&&o?(b=G(u.endDateTime).tz(o))===null||b===void 0?void 0:b.format($t):"-"}}))!==null&&n!==void 0?n:[]}]}async function Xp(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.POPPOEAccess,permissionPrivilege:e}),Ze({locationType:ut.GreaterThan+F.Site,permissionType:S.POPPOEAccess,permissionPrivilege:e,assignableProcess:"POP_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId),accountNumber:n.accountNumber}))}const Ei=e=>{var t;return(t=e==null?void 0:e.map(i=>{var s,n,o,a,r,d,u,p,A,C,b,N;return{sideAName:(s=i.sideAName)!==null&&s!==void 0?s:"",sideARoomNumber:(n=i.sideARoomNumber)!==null&&n!==void 0?n:"",sideARackNumber:(o=i.sideARackNumber)!==null&&o!==void 0?o:"",sideAPanelNumber:(a=i.sideAPanelNumber)!==null&&a!==void 0?a:"",sideAPort1:(r=i.sideAPort)!==null&&r!==void 0?r:"",sideACarrierCircuitId:(d=i.sideACarrierCircuitID)!==null&&d!==void 0?d:"",sideBName:(u=i.sideZName)!==null&&u!==void 0?u:"",sideBRoomNumber:(p=i.sideZRoomNumber)!==null&&p!==void 0?p:"",sideBRackNumber:(A=i.sideZRackNumber)!==null&&A!==void 0?A:"",sideBPanelNumber:(C=i.sideZPanelNumber)!==null&&C!==void 0?C:"",sideBPort1:(b=i.sideZPort)!==null&&b!==void 0?b:"",sideBCarrierCircuitId:(N=i.sideZCarrierCircuitID)!==null&&N!==void 0?N:""}}))!==null&&t!==void 0?t:[]},ea=e=>!e||e.length===1&&!e[0].rack&&!e[0].cabinet?[]:e.map(t=>{var i,s;return{rack:(i=t.rack)!==null&&i!==void 0?i:"",cabinet:(s=t.cabinet)!==null&&s!==void 0?s:""}}),Qp=e=>({accountNumber:e.accountNumber,visitors:e.visitors.map(t=>({firstName:t.firstName,lastName:t.lastName,email:t.email,company:t.company,phone:t.phone,visitorType:t.visitorType})),locations:Yp(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:e.hostFirstName,visitorHostLastName:e.hostLastName,customerExternalReference:e.customerExternalReference,serviceImpactedDescription:e.serviceImpactDescription,serviceDetails:{serviceType:e.serviceType,scope:e.scope,circuits:Ei(e.circuits),workDescription:e.descriptionOfWork},ppopSpace:ea(e.ppopSpaces),spopSpace:ea(e.spopSpaces),ppopRoomWork:e.isPpopCableRunOutside?{ppopSpaceFrom:e.ppopFromRackPanel,ppopSpaceTo:e.ppopToRackPanel,cableType:e.ppopCableType,onLadderRack:e.ppopLadderRack,inInnerDuct:e.ppopInnerDuct,inFiberGuide:e.ppopFiberGuide}:void 0,spopRoomWork:e.isSpopCableRunOutside?{spopSpaceFrom:e.spopFromRackPanel,spopSpaceTo:e.spopToRackPanel,cableType:e.spopCableType,onLadderRack:e.spopLadderRack,inInnerDuct:e.spopInnerDuct,inFiberGuide:e.spopFiberGuide}:void 0,notificationRecipients:e.contacts}),ta=e=>(e==null?void 0:e.map(t=>({sideAName:t.sideAName||"-",sideARoomNumber:t.sideARoomNumber||"-",sideARackNumber:t.sideARackNumber||"-",sideAPanelNumber:t.sideAPanelNumber||"-",sideAPort:t.sideAPort1||"-",sideACarrierCircuitID:t.sideACarrierCircuitId||"-",sideZName:t.sideBName||"-",sideZRoomNumber:t.sideBRoomNumber||"-",sideZRackNumber:t.sideBRackNumber||"-",sideZPanelNumber:t.sideBPanelNumber||"-",sideZPort:t.sideBPort1||"-",sideZCarrierCircuitID:t.sideBCarrierCircuitId||"-"})))||[],ia=async e=>{var t,i,s,n,o,a,r,d,u,p,A,C,b,N,x,et,tt,it,st,nt,at;return{id:e.id||"-",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt||"-",updatedOn:e.updatedAt||"-",requestType:"PoP/POE Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",company:e.visitorCompany||"-",visitorType:e.visitorType}],visitorType:e.visitorType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",visitorHostFirstName:e.visitorHostFirstName||"-",visitorHostLastName:e.visitorHostLastName||"-",visitorHostCompany:e.visitorHostCompany||"-",site:e.site||"-",sitesDetails:await Qn(e),customerExternalReference:e.customerExternalReference||"-",isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription||"-",serviceType:((t=e.serviceDetails)===null||t===void 0?void 0:t.serviceType)||"-",scope:((i=e.serviceDetails)===null||i===void 0?void 0:i.scope)||"-",isCrossConnectPatchCableInstallationOrRemoval:!!(!((n=(s=e.serviceDetails)===null||s===void 0?void 0:s.circuits)===null||n===void 0)&&n.length),workDescription:((o=e.serviceDetails)===null||o===void 0?void 0:o.workDescription)||"-",circuits:ta((a=e.serviceDetails)===null||a===void 0?void 0:a.circuits),ppopSpaces:((r=e.ppopSpace)===null||r===void 0?void 0:r.map(ge=>({rack:ge.rack||"",cabinet:ge.cabinet||""})))||[],spopSpaces:((d=e.spopSpace)===null||d===void 0?void 0:d.map(ge=>({rack:ge.rack||"",cabinet:ge.cabinet||""})))||[],isPpopCableRunOutside:!!e.ppopRoomWork&&Object.keys(e.ppopRoomWork).length>0,ppopFromRackPanel:((u=e.ppopRoomWork)===null||u===void 0?void 0:u.ppopSpaceFrom)||"-",ppopToRackPanel:((p=e.ppopRoomWork)===null||p===void 0?void 0:p.ppopSpaceTo)||"-",ppopCableType:((A=e.ppopRoomWork)===null||A===void 0?void 0:A.cableType)||"-",ppopLadderRack:(C=e.ppopRoomWork)===null||C===void 0?void 0:C.onLadderRack,ppopInnerDuct:(b=e.ppopRoomWork)===null||b===void 0?void 0:b.inInnerDuct,ppopFiberGuide:(N=e.ppopRoomWork)===null||N===void 0?void 0:N.inFiberGuide,isSpopCableRunOutside:!!(e.spopRoomWork&&Object.keys(e.spopRoomWork).length>0),spopFromRackPanel:((x=e.spopRoomWork)===null||x===void 0?void 0:x.spopSpaceFrom)||"-",spopToRackPanel:((et=e.spopRoomWork)===null||et===void 0?void 0:et.spopSpaceTo)||"-",spopCableType:((tt=e.spopRoomWork)===null||tt===void 0?void 0:tt.cableType)||"-",spopLadderRack:(it=e.spopRoomWork)===null||it===void 0?void 0:it.onLadderRack,spopInnerDuct:(st=e.spopRoomWork)===null||st===void 0?void 0:st.inInnerDuct,spopFiberGuide:(nt=e.spopRoomWork)===null||nt===void 0?void 0:nt.inFiberGuide,notificationRecipients:e.notificationRecipients||"",cancellationReason:e.cancellationReason||"-",comments:(at=e.comments)===null||at===void 0?void 0:at.map(ge=>M(ge))}},eh=async e=>{var t,i,s,n,o,a,r,d,u,p,A,C,b,N,x,et,tt,it,st,nt,at,ge,mi,pi,hi;if(e)return{isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0,isVisitorHostValid:!0,isRequestedAccessDetailsValid:!0,isNotificationsAttachmentsValid:!0,isPopRequestedAccessValid:!0,accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",status:e.status,requestType:"PoP/POE Access",category:"",id:e.id,visitors:[{firstName:(i=e.visitorFirstName)!==null&&i!==void 0?i:"",lastName:(s=e.visitorLastName)!==null&&s!==void 0?s:"",email:(n=e.visitorEmail)!==null&&n!==void 0?n:"",company:e.visitorCompany,phone:(o=e.visitorPhone)!==null&&o!==void 0?o:"",visitorType:e.visitorType}],isEscortedVisitor:!0,escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,sitesDetails:await Qn(e),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,customerExternalReference:e.customerExternalReference,isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription,termsAgreed:!0,serviceType:(a=e.serviceDetails)===null||a===void 0?void 0:a.serviceType,scope:(r=e.serviceDetails)===null||r===void 0?void 0:r.scope,isCrossConnectInstallation:!!(!((u=(d=e.serviceDetails)===null||d===void 0?void 0:d.circuits)===null||u===void 0)&&u.length),descriptionOfWork:(p=e.serviceDetails)===null||p===void 0?void 0:p.workDescription,circuits:ta((A=e.serviceDetails)===null||A===void 0?void 0:A.circuits),ppopSpaces:((C=e.ppopSpace)===null||C===void 0?void 0:C.map(Tt=>({rack:Tt.rack||"",cabinet:Tt.cabinet||""})))||[],spopSpaces:((b=e.spopSpace)===null||b===void 0?void 0:b.map(Tt=>({rack:Tt.rack||"",cabinet:Tt.cabinet||""})))||[],isPpopCableRunOutside:!!e.ppopRoomWork&&Object.keys(e.ppopRoomWork).length>0,ppopFromRackPanel:(N=e.ppopRoomWork)===null||N===void 0?void 0:N.ppopSpaceFrom,ppopToRackPanel:(x=e.ppopRoomWork)===null||x===void 0?void 0:x.ppopSpaceTo,ppopCableType:(et=e.ppopRoomWork)===null||et===void 0?void 0:et.cableType,ppopLadderRack:(tt=e.ppopRoomWork)===null||tt===void 0?void 0:tt.onLadderRack,ppopInnerDuct:(it=e.ppopRoomWork)===null||it===void 0?void 0:it.inInnerDuct,ppopFiberGuide:(st=e.ppopRoomWork)===null||st===void 0?void 0:st.inFiberGuide,isSpopCableRunOutside:!!(e.spopRoomWork&&Object.keys(e.spopRoomWork).length>0),spopFromRackPanel:(nt=e.spopRoomWork)===null||nt===void 0?void 0:nt.spopSpaceFrom,spopToRackPanel:(at=e.spopRoomWork)===null||at===void 0?void 0:at.spopSpaceTo,spopCableType:(ge=e.spopRoomWork)===null||ge===void 0?void 0:ge.cableType,spopLadderRack:(mi=e.spopRoomWork)===null||mi===void 0?void 0:mi.onLadderRack,spopInnerDuct:(pi=e.spopRoomWork)===null||pi===void 0?void 0:pi.inInnerDuct,spopFiberGuide:(hi=e.spopRoomWork)===null||hi===void 0?void 0:hi.inFiberGuide,contacts:e.notificationRecipients,attachments:[]}},th=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),He=(e,t)=>(e!=null?e:!1)!==(t!=null?t:!1),B=(e,t)=>!(e===t||!e&&!t||!e&&t==="-"),ih=(e,t)=>B(e.sideAName,t.sideAName)||B(e.sideARoomNumber,t.sideARoomNumber)||B(e.sideARackNumber,t.sideARackNumber)||B(e.sideAPanelNumber,t.sideAPanelNumber)||B(e.sideAPort,t.sideAPort)||B(e.sideACarrierCircuitID,t.sideACarrierCircuitID)||B(e.sideZName,t.sideZName)||B(e.sideZRoomNumber,t.sideZRoomNumber)||B(e.sideZRackNumber,t.sideZRackNumber)||B(e.sideZPanelNumber,t.sideZPanelNumber)||B(e.sideZPort,t.sideZPort)||B(e.sideZCarrierCircuitID,t.sideZCarrierCircuitID),sh=(e,t)=>{if(e===void 0)return t.length!==0;if(e.length!==t.length)return!0;for(let i=0;i<e.length;i++)if(ih(e[i],t[i]))return!0;return!1},sa=(e,t)=>{if(e===void 0&&!(t!=null&&t.length))return!1;if(!e||!t||e.length!==t.length)return!0;for(let i=0;i<e.length;i++)if(B(e[i].rack,t[i].rack)||B(e[i].cabinet,t[i].cabinet))return!0;return!1},nh=(e,t)=>{var i,s;const n={};B(e.visitors[0].company,t.visitors[0].company)&&(n.visitorCompany=e.visitors[0].company),(B(e.escortFirstName,t.escortFirstName)||B(e.escortLastName,t.escortLastName))&&(n.escortFirstName=e.escortFirstName,n.escortLastName=e.escortLastName);const o=((i=e.sitesDetails)===null||i===void 0?void 0:i.flatMap(d=>d.locations.map(u=>({id:u.id,startDate:u.startDate,startTime:u.startTime,endDate:u.endDate,endTime:u.endTime,siteId:d.site.siteId}))))||[],a=((s=t.sitesDetails)===null||s===void 0?void 0:s.flatMap(d=>d.locations))||[],r=o.map(d=>{const u=a.find(A=>A.id===d.id),p={id:d.id};return(!u||B(d.startDate,u.startDate)||B(d.startTime,u.startTime)||B(d.endDate,u.endDate)||B(d.endTime,u.endTime))&&(p.startDateTime=Be(d.startDate,d.startTime,d.siteId),p.endDateTime=Be(d.endDate,d.endTime,d.siteId)),p}).filter(d=>d.startDateTime&&d.endDateTime);if(r.length&&(n.locations=r),(B(e.hostFirstName,t.visitorHostFirstName)||B(e.hostLastName,t.visitorHostLastName))&&(n.visitorHostFirstName=e.hostFirstName,n.visitorHostLastName=e.hostLastName),He(e.isServiceImpacted,t.isServiceImpacted)&&e.isServiceImpacted===!1&&(n.serviceImpactedDescription=""),B(e.serviceImpactDescription,t.serviceImpactDescription)&&(n.serviceImpactedDescription=e.serviceImpactDescription),n.serviceDetails={},B(e.serviceType,t.serviceType))switch(n.serviceDetails.serviceType=e.serviceType,e.serviceType){case We.SiteSurvey:case We.Testing:n.serviceDetails.scope=e.scope,n.serviceDetails.workDescription="",n.serviceDetails.circuits=[];break;case We.InstallationDeInstallationWork:n.serviceDetails.scope="",n.serviceDetails.workDescription=e.descriptionOfWork,n.serviceDetails.circuits=Ei(e.circuits);break;default:throw new Error("Unsupported service type for update")}else switch(e.serviceType){case We.SiteSurvey:case We.Testing:B(e.scope,t.scope)&&(n.serviceDetails.scope=e.scope);break;case We.InstallationDeInstallationWork:B(e.descriptionOfWork,t.workDescription)&&(n.serviceDetails.workDescription=e.descriptionOfWork),sh(e.circuits,t.circuits)&&(n.serviceDetails.circuits=Ei(e.circuits));break;default:throw new Error("Unsupported service type for update")}return Object.keys(n.serviceDetails).length===0&&delete n.serviceDetails,sa(e.ppopSpaces,t.ppopSpaces)&&(n.ppopSpace=e.ppopSpaces),sa(e.spopSpaces,t.spopSpaces)&&(n.spopSpace=e.spopSpaces),e.isPpopCableRunOutside?(n.ppopRoomWork={},B(e.ppopFromRackPanel,t.ppopFromRackPanel)&&(n.ppopRoomWork.ppopSpaceFrom=e.ppopFromRackPanel),B(e.ppopToRackPanel,t.ppopToRackPanel)&&(n.ppopRoomWork.ppopSpaceTo=e.ppopToRackPanel),B(e.ppopCableType,t.ppopCableType)&&(n.ppopRoomWork.cableType=e.ppopCableType),He(e.ppopLadderRack,t.ppopLadderRack)&&(n.ppopRoomWork.onLadderRack=e.ppopLadderRack),He(e.ppopInnerDuct,t.ppopInnerDuct)&&(n.ppopRoomWork.inInnerDuct=e.ppopInnerDuct),He(e.ppopFiberGuide,t.ppopFiberGuide)&&(n.ppopRoomWork.inFiberGuide=e.ppopFiberGuide),Object.keys(n.ppopRoomWork).length===0&&delete n.ppopRoomWork):He(e.isPpopCableRunOutside,t.isPpopCableRunOutside)&&(n.ppopRoomWork=null),e.isSpopCableRunOutside?(n.spopRoomWork={},B(e.spopFromRackPanel,t.spopFromRackPanel)&&(n.spopRoomWork.spopSpaceFrom=e.spopFromRackPanel),B(e.spopToRackPanel,t.spopToRackPanel)&&(n.spopRoomWork.spopSpaceTo=e.spopToRackPanel),B(e.spopCableType,t.spopCableType)&&(n.spopRoomWork.cableType=e.spopCableType),He(e.spopLadderRack,t.spopLadderRack)&&(n.spopRoomWork.onLadderRack=e.spopLadderRack),He(e.spopInnerDuct,t.spopInnerDuct)&&(n.spopRoomWork.inInnerDuct=e.spopInnerDuct),He(e.spopFiberGuide,t.spopFiberGuide)&&(n.spopRoomWork.inFiberGuide=e.spopFiberGuide),Object.keys(n.spopRoomWork).length===0&&delete n.spopRoomWork):He(e.isSpopCableRunOutside,t.isSpopCableRunOutside)&&(n.spopRoomWork=null),B(e.visitors[0].phone,t.visitors[0].phone)&&(n.visitorPhone=e.visitors[0].phone),B(e.customerExternalReference,t.customerExternalReference)&&(n.customerExternalReference=e.customerExternalReference),B(e.contacts,t.notificationRecipients)&&(n.notificationRecipients=e.contacts),Object.keys(n).length===0&&(n.visitorCompany=e.visitors[0].company),n},pe={newTicket:{isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isVisitorHostValid:!1,isRequestedAccessDetailsValid:!1,isPopRequestedAccessValid:!1,isPPopRoomWorkValid:!1,isSPopRoomWorkValid:!1,isNotificationsAttachmentsValid:!1,accountNumber:"",visitors:[],contacts:"",attachments:[],startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard",serviceType:void 0,isEscortedVisitor:!0,escortFirstName:void 0,escortLastName:void 0,hostCompany:void 0,hostFirstName:void 0,hostLastName:void 0,ppopSpaces:[{}],spopSpaces:[{}]},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],popAccessResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class na{constructor(){this.newTicket=pe.newTicket,this.submissionResult=pe.submissionResult,this.selectedTicket=pe.selectedTicket,this.loadings=pe.loadings,this.isEditAttachmentAdded=pe.isEditAttachmentAdded,se(this)}createTicket(){var t,i;const s=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...pe.newTicket,accountNumber:s,requestType:"PoP/POE Access",category:"",serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0},this.submissionResult=pe.submissionResult}async setNewTicket(){try{this.newTicket=await eh(this.submissionResult.ticketResponse),this.newTicket||(this.newTicket=pe.newTicket)}catch(t){throw await l(t,!1),t}}async getPOPAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.popAccess.getPopAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await ia(i)}catch(i){throw await l(i,!1),i}}async hasUpdatePermissions(){var t;try{return await Rn((t=this.selectedTicket)===null||t===void 0?void 0:t.site)}catch(i){return!1}}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.visitorHost=i,n.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}addVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s,t]}}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s]}}addOrUpdateVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s,t]}}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.endDate=t})})}async addSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s,t]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t;this.resetSubmission();try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;const i=await m.facilityAccessApi.popAccess.createPopAccessTicket({pOPAccessTicketRequest:Qp(this.newTicket)}).catch(s=>{throw l(s,!1),this.submissionResult.state=w.Error,s});if(i){const{ticketNumbers:s}=i;s!=null&&s.length&&!((t=this.newTicket.attachments)===null||t===void 0)&&t.length&&await Promise.all(s.map(async n=>{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,n,!1,"PoP/POE Access")})),this.newTicket.attachments=void 0,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=i==null?void 0:i.ticketNumbers}}catch(i){throw await l(i,!1),this.submissionResult.state=w.Error,i}finally{this.loadings.isSubmitting=!1}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.facilityAccessApi.popAccess.cancellationPopAccessRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getPOPAccessServiceTicket(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await m.facilityAccessApi.popAccess.updatePopAccessTicket({pOPAccessTicketUpdateRequest:nh(this.newTicket,this.selectedTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t==null?void 0:t.id]}catch(i){throw this.submissionResult.state=w.Error,await l(i,!1),i}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"PoP/POE Access"),this.newTicket.attachments=[]}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await ia(t))}catch(i){throw await l(i,!1),i}}finally{this.loadings.isSubmitting=!1}}resetSubmission(){this.submissionResult=pe.submissionResult}clearNewTicket(){this.newTicket=pe.newTicket}clear(){this.newTicket=pe.newTicket,this.selectedTicket=pe.selectedTicket,this.submissionResult=pe.submissionResult}updateFieldValue(t,i){this.newTicket[t]=i}updateIsServiceImpacted(t){this.newTicket.isServiceImpacted=t}updateCustomerExternalReference(t){this.newTicket.customerExternalReference=t}updateServiceImpactDescription(t){this.newTicket.serviceImpactDescription=t}updateServiceType(t){this.newTicket.serviceType=t,t===We.InstallationDeInstallationWork&&this.updateScope(""),this.updateIsCrossConnectInstallation(!1)}updateScope(t){this.newTicket.scope=t}updateDescriptionOfWork(t){this.newTicket.descriptionOfWork=t}updateIsCrossConnectInstallation(t){this.newTicket.isCrossConnectInstallation=t,t?this.newTicket.circuits=[{}]:(this.updateDescriptionOfWork(""),this.newTicket.circuits=void 0)}updateIsPPopCableRunOutside(t){this.newTicket.isPpopCableRunOutside=t,t||(this.newTicket.ppopFromRackPanel=void 0,this.newTicket.ppopToRackPanel=void 0,this.newTicket.ppopCableType=void 0,this.newTicket.ppopLadderRack=void 0,this.newTicket.ppopInnerDuct=void 0,this.newTicket.ppopFiberGuide=void 0)}updateIsSPopCableRunOutside(t){this.newTicket.isSpopCableRunOutside=t,t||(this.newTicket.spopFromRackPanel=void 0,this.newTicket.spopToRackPanel=void 0,this.newTicket.spopCableType=void 0,this.newTicket.spopLadderRack=void 0,this.newTicket.spopInnerDuct=void 0,this.newTicket.spopFiberGuide=void 0)}updateCircuitField(t,i,s){var n;(!this.newTicket.circuits||((n=this.newTicket.circuits)===null||n===void 0?void 0:n.length)===0)&&(this.newTicket.circuits=[{}]);const o=[...this.newTicket.circuits];o[s][i]=t,this.newTicket.circuits=o}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeBulkAttachment(){throw new Error("Method not implemented.")}removeAllVisitors(){this.newTicket.visitors=[]}get isNewTicketValid(){const t=this.newTicket.isVisitorContactsDetailsValid,i=this.newTicket.isVisitorEscortedDetailsValid,s=this.newTicket.isVisitorHostValid,n=this.newTicket.isRequestedAccessDetailsValid,o=this.newTicket.isPopRequestedAccessValid;return t&&i&&s&&n&&o}get isAdditionalComponentValid(){return this.newTicket.isPPopRoomWorkValid&&this.newTicket.isSPopRoomWorkValid&&this.newTicket.isNotificationsAttachmentsValid}}const Se=new na;var ei;(function(e){e.PLANNED_MAINTENANCE="Planned Maintenance",e.INCIDENTS="Incidents",e.DCIM_ALERTS="DCIM Alerts",e.SERVICE_TICKETS="Service Tickets"})(ei||(ei={}));const ah=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),M=e=>({comment:e.comment,commentedBy:e.createdBy,commentedOn:e.createdAt});async function oh(e,t,i){var s,n,o,a,r,d,u,p,A,C;let b;switch(e){case y.Deliveries:{const N=await m.deliveriesApi.createDeliveriesComment(Mm(t,i)).catch(x=>{l(x,!1)});b=(s=N==null?void 0:N.comments)===null||s===void 0?void 0:s.map(M),Te.selectedTicket&&(Te.selectedTicket.comments=b);break}case y.Removals:{const N=await m.removalsApi.createComment(np(t,i)).catch(x=>{l(x,!1)});b=(n=N==null?void 0:N.comments)===null||n===void 0?void 0:n.map(M),Ve.selectedTicket&&(Ve.selectedTicket.comments=b);break}case y.RemoteHands:{const N=await m.remoteHandsApi.createRemoteHandsComment(Km(t,i)).catch(x=>{l(x,!1)});b=(o=N==null?void 0:N.comments)===null||o===void 0?void 0:o.map(M),re.selectedTicket&&(re.selectedTicket.comments=b);break}case y.VisitorAccess:{const N=await m.facilityAccessApi.visitorAccess.createVisitorAccessComment(Sp(t,i)).catch(x=>{l(x,!1)});b=(a=N==null?void 0:N.comments)===null||a===void 0?void 0:a.map(M),ie.selectedTicket&&(ie.selectedTicket.comments=b);break}case y.PermanentBadge:{const N=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeComment(Up(t,i)).catch(x=>{l(x,!1)});b=(r=N==null?void 0:N.comments)===null||r===void 0?void 0:r.map(M),Y.selectedTicket&&(Y.selectedTicket.comments=b);break}case y.CustomerSupport:{const N=await m.customerCareApi.createCustomerCareComment(kp(t,i)).catch(x=>{l(x,!1)});b=(d=N==null?void 0:N.comments)===null||d===void 0?void 0:d.map(M),je.selectedTicket&&(je.selectedTicket.comments=b);break}case y.TroubleTickets:{const N=await m.troubleTicketsApi.createTroubleTicketComment(rp(t,i)).catch(x=>{l(x,!1)});b=(u=N==null?void 0:N.comments)===null||u===void 0?void 0:u.map(M),Ue.selectedTicket&&(Ue.selectedTicket.comments=b);break}case y.OSPAccess:{const N=await m.facilityAccessApi.ospAccess.createOspAccessComment(Kp(t,i)).catch(x=>{l(x,!1)});b=(p=N==null?void 0:N.comments)===null||p===void 0?void 0:p.map(M),Ie.selectedTicket&&(Ie.selectedTicket.comments=b);break}case y.POPPOEAccess:{const N=await m.facilityAccessApi.popAccess.createPopAccessComment(th(t,i)).catch(x=>{l(x,!1)});b=(A=N==null?void 0:N.comments)===null||A===void 0?void 0:A.map(M),Se.selectedTicket&&(Se.selectedTicket.comments=b);break}case ei.INCIDENTS:{const N=await m.incidentsApi.createIncidentComment(ah(t,i)).catch(x=>{l(x,!1)});b=(C=N==null?void 0:N.comments)===null||C===void 0?void 0:C.map(M);break}default:return}return b}const rh=e=>({subject:e.subject,customerReference:e.customerReferenceNumber,description:e.description,otherNotificationRecipients:e.contacts}),ch=e=>{var t;return{accountNumber:e.accountNumber,subject:e.subject,requestType:e.requestType,category:e.category,locations:!((t=e.location)===null||t===void 0)&&t.id?[e.location.id]:[],customerReference:e.customerReferenceNumber,description:e.description,notificationRecipients:e.contacts}},dh=async e=>{if(e)return{accountNumber:e.accountNumber,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Customer_care"),subject:e.subject,requestType:e.requestType,category:e.category,site:{id:e.site,accountNumber:e.accountNumber},location:{id:e.locations[0],accountNumber:e.accountNumber},customerReferenceNumber:e.customerReference,description:e.description,contacts:e.notificationRecipients}},aa=async e=>{var t,i,s,n,o;if(e)return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Customer_care"),subject:e.subject,description:e.description,customerReference:e.customerReference,site:e.site,location:!((t=e.locations)===null||t===void 0)&&t.length?e.locations[0]:"",notificationRecipients:e.notificationRecipients,status:e.status,createdBy:e.createdBy,createdAt:(i=e.createdAt)===null||i===void 0?void 0:i.toISOString(),updatedAt:(s=e.updatedAt)===null||s===void 0?void 0:s.toISOString(),closedAt:(n=e.closedAt)===null||n===void 0?void 0:n.toISOString(),cancellationReason:e.cancellationReason,requestType:e.requestType,category:e.category,comments:(o=e.comments)===null||o===void 0?void 0:o.map(a=>M(a))}},ze={selectedTicket:void 0,ticket:{isValid:!1,subject:"",description:"",site:void 0,requestType:"",category:"",customerReferenceNumber:"",contacts:"",attachments:[],accountNumber:""},submissionResult:{state:w.Default,result:void 0},loadings:{isSubmitting:!1}};class uh{constructor(){this.selectedTicket=ze.selectedTicket,this.ticket=ze.ticket,this.submissionResult=ze.submissionResult,this.loadings=ze.loadings,se(this),Je(this,{name:"customerCare",properties:[],storage:window.localStorage})}async setTicket(){try{this.ticket=await dh(this.submissionResult.result)||ze.ticket}catch(t){throw await l(t,!1),t}}async getSelectedTicket(t){if(t)try{const i=await m.customerCareApi.getCustomerCareTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await aa(i),await this.setTicket()}catch(i){throw await l(i,!1),i}}async getCategories(t,i){if(!(!t||!i))try{return await m.customerCareApi.getCustomerCareCategoriesList({site:t,accountNumber:i})}catch(s){throw await l(s,!1),s}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.customerCareApi.cancellationCustomerCareRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}).catch(s=>{throw l(s,!1),s}),await this.getSelectedTicket(this.selectedTicket.id))}finally{k.loadings.isTicketCancelling=!1}}async updateSite(t){this.ticket.site=t,this.ticket.accountNumber=t.accountNumber}async createTicket(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await m.customerCareApi.createCustomerCareTicket({customerCareTicketRequest:ch(this.ticket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&await k.postAttachments(y.CustomerSupport,this.ticket.attachments,this.submissionResult.result.id),this.ticket.attachments=void 0}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async updateTicket(){var t,i;let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await m.customerCareApi.updateCustomerCareTicket({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",customerCareTicketUpdateRequest:rh(this.ticket)}),this.submissionResult.result=s,this.submissionResult.state=w.Submitted}catch(n){throw this.submissionResult.state=w.Error,await l(n,!1),n}try{await k.postAttachments(y.CustomerSupport,this.ticket.attachments,(i=this.selectedTicket)===null||i===void 0?void 0:i.id,!0),this.ticket.attachments=void 0}catch(n){throw await l(n,!1),n}try{s&&(this.selectedTicket=await aa(s),await this.setTicket())}catch(n){throw await l(n,!1),n}}finally{this.loadings.isSubmitting=!1}}updateLocation(t){this.ticket.location=t}clear(){this.ticket=ze.ticket,this.selectedTicket=ze.selectedTicket,this.submissionResult=ze.submissionResult,this.loadings=ze.loadings}}const je=new uh,ve=bt` *, ::before, ::after {
2
2
  --tw-border-spacing-x: 0;
3
3
  --tw-border-spacing-y: 0;
4
4
  --tw-translate-x: 0;
@@ -1057,7 +1057,7 @@ video {
1057
1057
  margin-left: 0px;
1058
1058
  margin-right: 0px;
1059
1059
  }
1060
- } `;let Ei=class extends Ae{constructor(){super(...arguments),this.hasPermission=void 0}async canPerformActions(){var e,t,i,s;return![O.InProgress,O.New].includes((e=je.selectedTicket)===null||e===void 0?void 0:e.status)||((t=je.selectedTicket)===null||t===void 0?void 0:t.serviceBackend)===H.TelxSFDC||!(!((i=je.selectedTicket)===null||i===void 0)&&i.location&&!((s=je.selectedTicket)===null||s===void 0)&&s.accountNumber)?!1:this.hasPermission!==void 0?this.hasPermission:(this.hasPermission=await Pt(L.Update,A.CustomerCare,je.selectedTicket.location,je.selectedTicket.accountNumber),this.hasPermission)}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return k.loadings.isTicketCancelling?N:g`<div class="w-fit flex gap-2"> ${fe(this.canPerformActions().then(e=>e?g`<ix-button name="cancel-button" class="cancel" appearance="outlined" @click="${()=>this.dispatchClickEvent(V.CancelTicket)}"> <span>${Xe}</span> </ix-button> <ix-button name="edit-button" @click="${()=>this.dispatchClickEvent(V.EditTicket)}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`:N),N)} </div>`}};Ei.styles=[ve],Ei=E([X("customer-care-button-group")],Ei);let ti=class extends Ae{constructor(){super(...arguments),this.hasPermission=void 0,this.backendService=void 0}async getServiceBackend(){var e,t;this.backendService||(this.backendService=await K.getServiceBackend((e=Te.newTicket.site)===null||e===void 0?void 0:e.accountNumber,(t=Te.newTicket.site)===null||t===void 0?void 0:t.id,"Deliveries"))}async canPerformActions(){var e,t,i,s,a,o,n,r,d,u;return((t=(e=Te.selectedTicket)===null||e===void 0?void 0:e.state)===null||t===void 0?void 0:t.toLowerCase())!==O.Announced.toLowerCase()||!(!((s=(i=Te.newTicket)===null||i===void 0?void 0:i.site)===null||s===void 0)&&s.id&&!((o=(a=Te.newTicket)===null||a===void 0?void 0:a.site)===null||o===void 0)&&o.accountNumber)||(await this.getServiceBackend(),this.backendService===H.TelxSFDC)?!1:this.hasPermission!==void 0?this.hasPermission:(this.hasPermission=await Te.hasTicketPermissionAtLocation(L.Update,A.DeliveriesRemovals,(r=(n=Te.newTicket)===null||n===void 0?void 0:n.site)===null||r===void 0?void 0:r.id,(u=(d=Te.newTicket)===null||d===void 0?void 0:d.site)===null||u===void 0?void 0:u.accountNumber),this.hasPermission)}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return k.loadings.isTicketCancelling?N:g`<div class="w-fit flex gap-2"> ${fe(this.canPerformActions().then(e=>e?g`<ix-button name="cancel-button" class="cancel" appearance="outlined" @click="${()=>this.dispatchClickEvent(V.CancelTicket)}"> <span>${Xe}</span> </ix-button> <ix-button name="edit-button" @click="${()=>this.dispatchClickEvent(V.EditTicket)}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`:N),N)} </div>`}};ti.styles=[ve],E([Mi()],ti.prototype,"backendService",void 0),ti=E([X("deliveries-button-group")],ti);let xi=class extends Ae{constructor(){super(...arguments),this.hasPermission=void 0}async canPerformActions(){var e,t,i,s,a,o,n,r,d,u;return((t=(e=Ve.selectedTicket)===null||e===void 0?void 0:e.status)===null||t===void 0?void 0:t.toLowerCase())!==O.Announced.toLowerCase()||!(!((s=(i=Ve.newTicket)===null||i===void 0?void 0:i.site)===null||s===void 0)&&s.id&&!((o=(a=Ve.newTicket)===null||a===void 0?void 0:a.site)===null||o===void 0)&&o.accountNumber)?!1:this.hasPermission!==void 0?this.hasPermission:(this.hasPermission=await Ve.hasTicketPermissionAtLocation(L.Update,A.DeliveriesRemovals,(r=(n=Ve.newTicket)===null||n===void 0?void 0:n.site)===null||r===void 0?void 0:r.id,(u=(d=Ve.newTicket)===null||d===void 0?void 0:d.site)===null||u===void 0?void 0:u.accountNumber),this.hasPermission)}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return k.loadings.isTicketCancelling?N:g`<div class="w-fit flex gap-2"> ${fe(this.canPerformActions().then(e=>e?g`<ix-button name="cancel-button" class="cancel" appearance="outlined" @click="${()=>this.dispatchClickEvent(V.CancelTicket)}"> <span>${Xe}</span> </ix-button> <ix-button name="edit-button" @click="${()=>this.dispatchClickEvent(V.EditTicket)}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`:N),N)} </div>`}};xi.styles=[ve],xi=E([X("removals-button-group")],xi);const tn=e=>e?e.some(t=>t.locations.some(i=>i.status==="Outstanding")):!1,mh=e=>{switch(e){case"New":return"New Badge";case"Modify":return"Modify Badge";case"Terminate":return"Terminate All Access";default:return e}};let Fi=class extends Ae{constructor(){super(...arguments),this.hasUpdatePermission=void 0,this.hasApprovePermission=void 0}async getUpdatePermissions(){var e,t,i,s;this.hasUpdatePermission!==void 0||!(!((s=(i=(t=(e=ie.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasUpdatePermission=await Ye(ie.selectedTicket.sitesDetails[0].locations.map(a=>a.id),A.VisitorAccess,L.Update))}async getApprovePermissions(){var e,t,i,s;this.hasApprovePermission!==void 0||!(!((s=(i=(t=(e=ie.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasApprovePermission=await Ye(ie.selectedTicket.sitesDetails[0].locations.map(a=>a.id),A.VisitorAccess,L.Approve))}get canApproveOrDeny(){var e;return!((e=ie.selectedTicket)===null||e===void 0)&&e.state?ie.selectedTicket.state!==O.Cancelled&&tn(ie.selectedTicket.sitesDetails):!1}get canCancel(){var e;return!pt(ie.selectedTicket.id)||!(!((e=ie.selectedTicket)===null||e===void 0)&&e.state)?!1:[O.InProgress.toLowerCase(),re.PendingApproval.toLowerCase(),re.Approved.toLowerCase()].includes(ie.selectedTicket.state.toLowerCase())}get canEdit(){var e;return!((e=ie.selectedTicket)===null||e===void 0)&&e.state?![O.Cancelled.toLowerCase(),O.Completed.toLowerCase(),re.ApprovalDenied.toLowerCase()].includes(ie.selectedTicket.state.toLowerCase()):!1}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}renderApproveDenyBtn(){return!this.hasApprovePermission||!this.canApproveOrDeny?N:g`<ix-button name="approveDenyBtn" has-icon @click="${()=>{this.dispatchClickEvent(V.ApproveDenyTicket)}}"> <md-icon slot="icon">playlist_add_check</md-icon> <span class="button-label">APPROVE/DENY</span> </ix-button>`}renderCancelBtn(){return!this.hasUpdatePermission||!this.canCancel?N:g`<ix-button class="cancel" appearance="outlined" name="cancelBtn" @click="${()=>{this.dispatchClickEvent(V.CancelTicket)}}"> <span class="button-label">${Xe}</span> </ix-button>`}renderEditBtn(){return!this.hasUpdatePermission||!this.canEdit?N:g`<ix-button name="edit-button" @click="${()=>{this.dispatchClickEvent(V.EditTicket)}}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`}render(){return k.loadings.isTicketCancelling?N:g`<div class="w-fit flex gap-2"> ${fe(this.getApprovePermissions().then(()=>g` ${this.renderApproveDenyBtn()}`),N)} ${fe(this.getUpdatePermissions().then(()=>g` ${this.renderCancelBtn()} ${this.renderEditBtn()}`),N)} </div>`}};Fi.styles=[ve],Fi=E([X("visitor-access-button-group")],Fi);let Li=class extends Ae{constructor(){super(...arguments),this.hasUpdatePermission=void 0,this.hasApprovePermission=void 0}async getUpdatePermissions(){var e,t,i,s;this.hasUpdatePermission!==void 0||!(!((s=(i=(t=(e=Y.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasUpdatePermission=await Ye(Y.selectedTicket.sitesDetails[0].locations.map(a=>a.id),A.PermanentBadge,L.Update))}async getApprovePermissions(){var e,t,i,s;this.hasApprovePermission!==void 0||!(!((s=(i=(t=(e=Y.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasApprovePermission=await Ye(Y.selectedTicket.sitesDetails.flatMap(a=>a.locations.map(o=>o.id)),A.PermanentBadge,L.Approve))}get canApproveOrDeny(){return Y.selectedTicket?Y.selectedTicket.category!=="Terminate"&&Y.selectedTicket.state!==O.Cancelled&&tn(Y.selectedTicket.sitesDetails):!1}get canCancel(){var e;return!pt(Y.selectedTicket.id)||!(!((e=Y.selectedTicket)===null||e===void 0)&&e.state)||!De()["SM:AllowPermanentBadgeCancellation"]?!1:[O.InProgress.toLowerCase(),re.PendingApproval.toLowerCase(),re.Approved.toLowerCase()].includes(Y.selectedTicket.state.toLowerCase())}get canEdit(){var e;return!((e=Y.selectedTicket)===null||e===void 0)&&e.state?![O.Cancelled.toLowerCase(),O.Completed.toLowerCase(),re.ApprovalDenied.toLowerCase()].includes(Y.selectedTicket.state.toLowerCase()):!1}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}renderApproveDenyBtn(){return!this.hasApprovePermission||!this.canApproveOrDeny?N:g`<ix-button name="approveDenyBtn" has-icon @click="${()=>{this.dispatchClickEvent(V.ApproveDenyTicket)}}"> <md-icon slot="icon">playlist_add_check</md-icon> <span class="button-label">APPROVE/DENY</span> </ix-button>`}renderCancelBtn(){return!this.hasUpdatePermission||!this.canCancel?N:g`<ix-button class="cancel" appearance="outlined" name="cancelBtn" @click="${()=>{this.dispatchClickEvent(V.CancelTicket)}}"> <span class="button-label">${Xe}</span> </ix-button>`}renderEditBtn(){return!this.hasUpdatePermission||!this.canEdit?N:g`<ix-button name="edit-button" @click="${()=>{this.dispatchClickEvent(V.EditTicket)}}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`}render(){return k.loadings.isTicketCancelling?N:g`<div class="w-fit flex gap-2"> ${fe(this.getApprovePermissions().then(()=>g` ${this.renderApproveDenyBtn()}`),N)} ${fe(this.getUpdatePermissions().then(()=>g` ${this.renderCancelBtn()} ${this.renderEditBtn()}`),N)} </div>`}};Li.styles=[ve],Li=E([X("permanent-badge-button-group")],Li);let Vi=class extends Ae{constructor(){super(...arguments),this.hasUpdatePermission=void 0}async getUpdatePermissions(){var e,t,i,s;this.hasUpdatePermission!==void 0||!(!((s=(i=(t=(e=Ie.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasUpdatePermission=await wa(Ie.selectedTicket.site))}get canCancel(){var e;return!pt(Ie.selectedTicket.id)||!(!((e=Ie.selectedTicket)===null||e===void 0)&&e.state)?!1:[O.InProgress.toLowerCase(),re.PendingApproval.toLowerCase(),re.Approved.toLowerCase()].includes(Ie.selectedTicket.state.toLowerCase())}get canEdit(){var e;return!((e=Ie.selectedTicket)===null||e===void 0)&&e.state?![O.Cancelled.toLowerCase(),O.Completed.toLowerCase()].includes(Ie.selectedTicket.state.toLowerCase()):!1}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}renderCancelBtn(){return!this.hasUpdatePermission||!this.canCancel?N:g`<ix-button class="cancel" appearance="outlined" name="cancelBtn" @click="${()=>{this.dispatchClickEvent(V.CancelTicket)}}"> <span class="button-label">${Xe}</span> </ix-button>`}renderEditBtn(){return!this.hasUpdatePermission||!this.canEdit?N:g`<ix-button name="edit-button" @click="${()=>{this.dispatchClickEvent(V.EditTicket)}}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`}render(){return k.loadings.isTicketCancelling?N:g`<div class="w-fit flex gap-2"> ${fe(this.getUpdatePermissions().then(()=>g` ${this.renderCancelBtn()} ${this.renderEditBtn()}`),N)} </div>`}};Vi.styles=[ve],Vi=E([X("osp-access-button-group")],Vi);let Ui=class extends Ae{constructor(){super(...arguments),this.hasUpdatePermission=void 0}async getUpdatePermissions(){var e,t,i,s;this.hasUpdatePermission!==void 0||!(!((s=(i=(t=(e=Se.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasUpdatePermission=await fa(Se.selectedTicket.site))}get canCancel(){var e;return!pt(Se.selectedTicket.id)||!(!((e=Se.selectedTicket)===null||e===void 0)&&e.state)?!1:[O.InProgress.toLowerCase(),re.Approved.toLowerCase()].includes(Se.selectedTicket.state.toLowerCase())}get canEdit(){var e;return!((e=Se.selectedTicket)===null||e===void 0)&&e.state?![O.Cancelled.toLowerCase(),O.Completed.toLowerCase()].includes(Se.selectedTicket.state.toLowerCase()):!1}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}renderCancelBtn(){return!this.hasUpdatePermission||!this.canCancel?N:g`<ix-button class="cancel" appearance="outlined" name="cancelBtn" @click="${()=>{this.dispatchClickEvent(V.CancelTicket)}}"> <span class="button-label">${Xe}</span> </ix-button>`}renderEditBtn(){return!this.hasUpdatePermission||!this.canEdit?N:g`<ix-button name="edit-button" @click="${()=>{this.dispatchClickEvent(V.EditTicket)}}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`}render(){return k.loadings.isTicketCancelling?N:g`<div class="w-fit flex gap-2"> ${fe(this.getUpdatePermissions().then(()=>g`${this.renderCancelBtn()}${this.renderEditBtn()}`),N)} </div>`}};Ui.styles=[ve],Ui=E([X("pop-access-button-group")],Ui);let ii=class extends Ae{constructor(){super(...arguments),this.hasPermission=void 0,this.backendService=void 0}async getServiceBackend(){var e;this.backendService||(this.backendService=await K.getServiceBackend(ce.newTicket.location.accountNumber,(e=ce.newTicket.site)===null||e===void 0?void 0:e.id,"Remote_hands"))}async getPermissions(){var e,t,i,s,a,o,n,r;return!(!((t=(e=ce.newTicket)===null||e===void 0?void 0:e.location)===null||t===void 0)&&t.id&&!((s=(i=ce.newTicket)===null||i===void 0?void 0:i.location)===null||s===void 0)&&s.accountNumber)||(await this.getServiceBackend(),this.backendService===H.TelxSFDC)?!1:this.hasPermission!==void 0?this.hasPermission:(ce.loadings.ticketDetailsPermissionCheck=!0,this.hasPermission=await Pt(L.Update,A.RemoteHands,(o=(a=ce.newTicket)===null||a===void 0?void 0:a.location)===null||o===void 0?void 0:o.id,(r=(n=ce.newTicket)===null||n===void 0?void 0:n.location)===null||r===void 0?void 0:r.accountNumber),ce.loadings.ticketDetailsPermissionCheck=!1,this.hasPermission)}get canCancel(){var e,t;return this.backendService===H.ServiceNow?!1:((t=(e=ce.selectedTicket)===null||e===void 0?void 0:e.state)===null||t===void 0?void 0:t.toLowerCase())===O.New.toLowerCase()}get canEdit(){var e,t,i;const s=new Set([O.New.toLowerCase(),O.InProgress.toLowerCase()]);return!((e=ce.selectedTicket)===null||e===void 0)&&e.state?s.has((i=(t=ce.selectedTicket)===null||t===void 0?void 0:t.state)===null||i===void 0?void 0:i.toLowerCase()):!1}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return k.loadings.isTicketCancelling?N:g`<div class="w-fit flex gap-2"> ${fe(this.getPermissions().then(e=>e?g` ${this.canCancel?g`<ix-button class="cancel" appearance="outlined" name="cancelRemovalsBtn" @click="${()=>{this.dispatchClickEvent(V.CancelTicket)}}"> <span class="button-label">${Im}</span> </ix-button>`:N} ${this.canEdit?g`<ix-button name="edit-button" @click="${()=>this.dispatchClickEvent(V.EditTicket)}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`:N}`:N),N)} </div>`}};ii.styles=[ve],E([Mi()],ii.prototype,"backendService",void 0),ii=E([X("remote-hands-button-group")],ii);let Hi=class extends Ae{constructor(){super(...arguments),this.hasPermission=void 0}async canPerformActions(){var e,t,i,s,a,o;return!(!((t=(e=Ue.selectedTicket)===null||e===void 0?void 0:e.id)===null||t===void 0)&&t.toLowerCase().startsWith("cs"))||![O.Announced,O.Draft,O.New,O.InProgress].includes((i=Ue.selectedTicket)===null||i===void 0?void 0:i.state)||!(!((s=Ue.selectedTicket)===null||s===void 0)&&s.locations)||((a=Ue.selectedTicket)===null||a===void 0?void 0:a.locations.length)===0||Ue.selectedTicket.serviceBackend===H.TelxSFDC?!1:this.hasPermission!==void 0?this.hasPermission:(this.hasPermission=await Ye((o=Ue.selectedTicket)===null||o===void 0?void 0:o.locations,A.TroubleTickets,L.Update),this.hasPermission)}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return k.loadings.isTicketCancelling?N:g`<div class="w-fit flex gap-2"> ${fe(this.canPerformActions().then(e=>e?g`<ix-button class="cancel" appearance="outlined" name="cancel-button" @click="${()=>{this.dispatchClickEvent(V.CancelTicket)}}"> <span class="button-label">${Xe}</span> </ix-button> <ix-button name="edit-button" @click="${()=>this.dispatchClickEvent(V.EditTicket)}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`:N),N)} </div>`}};Hi.styles=[ve],Hi=E([X("trouble-ticket-button-group")],Hi);const W={Home:"Home",ServiceTickets:"Service Tickets",Reports:"Reports, Maintenance & Incident Notifications",Incidents:"Incidents",DeliveriesTicketDetails:"Deliveries Ticket Details",RemovalsTicketDetails:"Removals Ticket Details",RemoteHandsTicketDetails:"Remote Hands Ticket Details",VisitorAccessTicketDetails:"Visitor Access Ticket Details",CustomerCareTicketDetails:"Customer Care Ticket Details",PermanentBadgeTicketDetails:"Permanent Badge Ticket Details",TroubleTicketDetails:"Trouble Ticket Details",OspAccessTicketDetails:"OSP Access Ticket Details",PopAccessTicketDetails:"POP Access Ticket Details"},Dt=[{name:W.CustomerCareTicketDetails,path:"/service-tickets/customer-care/:ticketId",component:"customer-care-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<customer-care-button-group></customer-care-button-group>`,action:()=>{import("./ui-service-management15.js")}},{name:W.DeliveriesTicketDetails,path:"/service-tickets/deliveries/:ticketId",component:"deliveries-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<deliveries-button-group></deliveries-button-group>`,action:()=>{import("./ui-service-management19.js")}},{name:W.RemovalsTicketDetails,path:"/service-tickets/removals/:ticketId",component:"removals-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<removals-button-group></removals-button-group>`,action:()=>{import("./ui-service-management20.js")}},{name:W.VisitorAccessTicketDetails,path:"/service-tickets/facility-access/visitor-access/:ticketId",component:"visitor-access-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<visitor-access-button-group></visitor-access-button-group>`,action:()=>{import("./ui-service-management21.js")}},{name:W.PermanentBadgeTicketDetails,path:"/service-tickets/facility-access/permanent-badge/:ticketId",component:"permanent-badge-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<permanent-badge-button-group></permanent-badge-button-group>`,action:()=>{import("./ui-service-management24.js")}},{name:W.RemoteHandsTicketDetails,path:"/service-tickets/remote-hands/:ticketId",component:"remote-hands-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<remote-hands-button-group></remote-hands-button-group>`,action:()=>{import("./ui-service-management25.js")}},{name:W.TroubleTicketDetails,path:"/service-tickets/trouble-tickets/:ticketId",component:"trouble-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<trouble-ticket-button-group></trouble-ticket-button-group>`,action:()=>{import("./ui-service-management26.js")}},{name:W.Reports,path:"/reports",component:"site-maintenance-list",action:()=>{import("./ui-service-management27.js")}}];Ze.isOspEnabled()&&Dt.push({name:W.OspAccessTicketDetails,path:"/service-tickets/facility-access/osp-access/:ticketId",component:"osp-access-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<osp-access-button-group></osp-access-button-group>`,action:()=>{import("./ui-service-management29.js")}}),Ze.isPopPoeEnabled()&&Dt.push({name:W.PopAccessTicketDetails,path:"/service-tickets/facility-access/pop-access/:ticketId",component:"pop-access-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<pop-access-button-group></pop-access-button-group>`,action:()=>{import("./ui-service-management30.js")}}),Ze.isIncidentsEnabled()&&Dt.push({name:W.Incidents,path:"/incidents",component:"incidents-list",action:()=>{import("./ui-service-management31.js")}});let zi=class extends Ae{constructor(){super(...arguments),this.pageTitle="Loading..."}static get styles(){return[Ql]}async firstUpdated(){window.addEventListener("vaadin-router-location-changed",e=>{var t;this.pageTitle=(t=e.detail.location.route)===null||t===void 0?void 0:t.name})}get currentAccount(){return ne.getUserAccount()}get headerRight(){var e;return this.pageTitle===W.ServiceTickets?null:(e=Dt.find(t=>t.name===this.pageTitle))===null||e===void 0?void 0:e.headerRight}render(){var e,t;return g` <div class="header-container"> <h1 class="header__title">${this.pageTitle}</h1> <sm-create-service-ticket-button></sm-create-service-ticket-button> ${this.headerRight} <div class="header__profile"> ${((t=(e=ne.getUser())===null||e===void 0?void 0:e.profile)===null||t===void 0?void 0:t.email)||"Unknown User"} </div> <button @click="${()=>ne.redirectToLogout()}" class="header__logout"> <svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="currentColor"> <path d="m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4V5z"></path> </svg> Logout </button> <ix-select class="header__accounts" label="Account" .wideMenu="${!0}"> <ix-select-option value="${dn(this.currentAccount.accountNumber)}" .selected="${!0}"> <div slot="headline">${this.currentAccount.name}</div> </ix-select-option> </ix-select> </div> `}};E([we({type:String})],zi.prototype,"pageTitle",void 0),zi=E([X("sm-app-header")],zi);const ph=bt`:host{--navbar-width:256px;--logo-padding-left:0px;--navbar-icon-min-width:56px}.container{width:var(--navbar-width);transition:width .3s ease;border-radius:12px;background:linear-gradient(#1456e0 20.5%,#0d2497 113.5%);min-height:calc(100vh - 54px);margin:15px;color:#fff;padding-bottom:24px;z-index:1000;box-shadow:rgba(3,28,82,.24) 0 8px 24px;text-align:center}.navigation-logo{user-select:none;display:inline-block;fill:currentcolor;flex-shrink:0;transition:fill .2s cubic-bezier(.4,0,.2,1) 0s;font-size:1.5rem;width:178px!important;height:27px!important;padding-top:24px;padding-bottom:18px;padding-left:var(--logo-padding-left)}ul{list-style:none;margin:0;position:relative;padding:8px 4px}ul li a{-webkit-tap-highlight-color:transparent;background-color:transparent;outline:0;border:0;margin:0;cursor:pointer;user-select:none;vertical-align:middle;appearance:none;color:inherit;display:flex;-webkit-box-flex:1;flex-grow:1;-webkit-box-align:center;align-items:center;position:relative;text-decoration:none;min-width:0;box-sizing:border-box;text-align:left;transition:background-color 150ms cubic-bezier(.4,0,.2,1) 0s;padding:12px 16px;border-radius:8px;opacity:.6;text-overflow:ellipsis;white-space:nowrap;-webkit-box-pack:unset;justify-content:unset}a.active,ul li a:hover{background:rgba(255,255,255,.16);opacity:1}.navigation-icon svg{user-select:none;width:1em;height:1em;display:inline-block;fill:currentcolor;transition:fill .2s cubic-bezier(.4,0,.2,1) 0s;font-size:1.5rem;flex-shrink:0;display:inline-flex;color:inherit;min-width:var(--navbar-icon-min-width)}h6{margin:0;font-weight:700;line-height:24px;letter-spacing:.1px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:inherit}.divider{border-color:#fff;opacity:.2;margin:0;flex-shrink:0;border-width:0 0 thin;border-style:solid}.container.compact{--navbar-width:80px}.container.compact .navigation-logo{--logo-padding-left:28px}.container.compact .navigation-icon svg{--navbar-icon-min-width:42px}@media only screen and (min-width:5px) and (max-width:500px){.container{--navbar-width:100%;min-height:auto;margin:0;border-radius:0;padding-bottom:0}.container.compact{--navbar-width:100%}}@media only screen and (min-width:500px) and (max-width:1250px){.container{--navbar-width:100%;min-height:auto;margin:0;border-radius:0;padding-bottom:0}.container.compact{--navbar-width:100%}}`,sn=bt`@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/materialicons/v145/flUhRq6tzZclQEJ-Vdg-IuiaDsNZ.ttf) format('truetype')}.material-icons{font-family:'Material Icons';font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr}@font-face{font-family:'Material Symbols Outlined';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/materialsymbolsoutlined/v352/kJF1BvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oDMzByHX9rA6RzaxHMPdY43zj-jCxv3fzvRNU22ZXGJpEpjC_1v-p_4MrImHCIJIZrDCvHOem.ttf) format('truetype')}.material-symbols-outlined{font-family:'Material Symbols Outlined';font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr}.title{font-style:normal;font-weight:700;font-size:20px;line-height:24px;letter-spacing:.15px}.temp-button{border:none;padding:10px;color:#fff;border-radius:100px;cursor:pointer;margin-right:10px;text-decoration:none;font-family:var(--root-secondary-font);font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px;text-transform:uppercase}.temp-button span{padding:20px}.temp-button:disabled{background-color:#ddd}.flex{display:flex}.flex-1{flex:1}.border-top-solid-gray{border-top:solid 1px #ddd}.red{background-color:#db0028}.blue{background-color:#1456e0}.white{background-color:#fff;color:#1456e0;border:solid 1px #1456e0}.right{float:right}.margin-top-20{margin-top:20px}.padding-2{padding:2px}.padding-20{padding:20px}.padding-right-10{padding:10px}.font-14{font-size:14px}.button-container{position:absolute;bottom:30px;margin-left:10px}.temp-button span{padding:5px;font-size:20px}@media only screen and (min-width:5px) and (max-width:500px){.button-container{right:10px;top:10px}}@media only screen and (min-width:500px) and (max-width:1250px){.button-container{right:10px;top:10px}}`;let an=class extends Rt{static get styles(){return[sn]}render(){return g` <div class="button-container"> <button @click="${()=>{localStorage.clear(),ct.go("/")}}" class="temp-button white"> <span class="material-icons"> <md-icon slot="icon">restart_alt</md-icon> </span> </button> </div> `}};an=E([X("dev-clear-storage-button-service")],an);const si={digitalRealtyLogo:Ot`
1060
+ } `;let xi=class extends Ae{constructor(){super(...arguments),this.hasPermission=void 0}async canPerformActions(){var e,t,i,s;return![O.InProgress,O.New].includes((e=je.selectedTicket)===null||e===void 0?void 0:e.status)||((t=je.selectedTicket)===null||t===void 0?void 0:t.serviceBackend)===H.TelxSFDC||!(!((i=je.selectedTicket)===null||i===void 0)&&i.location&&!((s=je.selectedTicket)===null||s===void 0)&&s.accountNumber)?!1:this.hasPermission!==void 0?this.hasPermission:(this.hasPermission=await Ct(U.Update,S.CustomerCare,je.selectedTicket.location,je.selectedTicket.accountNumber),this.hasPermission)}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return k.loadings.isTicketCancelling?P:g`<div class="w-fit flex gap-2"> ${fe(this.canPerformActions().then(e=>e?g`<ix-button name="cancel-button" class="cancel" appearance="outlined" @click="${()=>this.dispatchClickEvent(L.CancelTicket)}"> <span>${Ye}</span> </ix-button> <ix-button name="edit-button" @click="${()=>this.dispatchClickEvent(L.EditTicket)}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`:P),P)} </div>`}};xi.styles=[ve],xi=E([X("customer-care-button-group")],xi);let ti=class extends Ae{constructor(){super(...arguments),this.hasPermission=void 0,this.backendService=void 0}async getServiceBackend(){var e,t;this.backendService||(this.backendService=await K.getServiceBackend((e=Te.newTicket.site)===null||e===void 0?void 0:e.accountNumber,(t=Te.newTicket.site)===null||t===void 0?void 0:t.id,"Deliveries"))}async canPerformActions(){var e,t,i,s,n,o,a,r,d,u;return((t=(e=Te.selectedTicket)===null||e===void 0?void 0:e.state)===null||t===void 0?void 0:t.toLowerCase())!==O.Announced.toLowerCase()||!(!((s=(i=Te.newTicket)===null||i===void 0?void 0:i.site)===null||s===void 0)&&s.id&&!((o=(n=Te.newTicket)===null||n===void 0?void 0:n.site)===null||o===void 0)&&o.accountNumber)||(await this.getServiceBackend(),this.backendService===H.TelxSFDC)?!1:this.hasPermission!==void 0?this.hasPermission:(this.hasPermission=await Te.hasTicketPermissionAtLocation(U.Update,S.DeliveriesRemovals,(r=(a=Te.newTicket)===null||a===void 0?void 0:a.site)===null||r===void 0?void 0:r.id,(u=(d=Te.newTicket)===null||d===void 0?void 0:d.site)===null||u===void 0?void 0:u.accountNumber),this.hasPermission)}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return k.loadings.isTicketCancelling?P:g`<div class="w-fit flex gap-2"> ${fe(this.canPerformActions().then(e=>e?g`<ix-button name="cancel-button" class="cancel" appearance="outlined" @click="${()=>this.dispatchClickEvent(L.CancelTicket)}"> <span>${Ye}</span> </ix-button> <ix-button name="edit-button" @click="${()=>this.dispatchClickEvent(L.EditTicket)}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`:P),P)} </div>`}};ti.styles=[ve],E([Ji()],ti.prototype,"backendService",void 0),ti=E([X("deliveries-button-group")],ti);let Fi=class extends Ae{constructor(){super(...arguments),this.hasPermission=void 0}async canPerformActions(){var e,t,i,s,n,o,a,r,d,u;return((t=(e=Ve.selectedTicket)===null||e===void 0?void 0:e.status)===null||t===void 0?void 0:t.toLowerCase())!==O.Announced.toLowerCase()||!(!((s=(i=Ve.newTicket)===null||i===void 0?void 0:i.site)===null||s===void 0)&&s.id&&!((o=(n=Ve.newTicket)===null||n===void 0?void 0:n.site)===null||o===void 0)&&o.accountNumber)?!1:this.hasPermission!==void 0?this.hasPermission:(this.hasPermission=await Ve.hasTicketPermissionAtLocation(U.Update,S.DeliveriesRemovals,(r=(a=Ve.newTicket)===null||a===void 0?void 0:a.site)===null||r===void 0?void 0:r.id,(u=(d=Ve.newTicket)===null||d===void 0?void 0:d.site)===null||u===void 0?void 0:u.accountNumber),this.hasPermission)}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return k.loadings.isTicketCancelling?P:g`<div class="w-fit flex gap-2"> ${fe(this.canPerformActions().then(e=>e?g`<ix-button name="cancel-button" class="cancel" appearance="outlined" @click="${()=>this.dispatchClickEvent(L.CancelTicket)}"> <span>${Ye}</span> </ix-button> <ix-button name="edit-button" @click="${()=>this.dispatchClickEvent(L.EditTicket)}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`:P),P)} </div>`}};Fi.styles=[ve],Fi=E([X("removals-button-group")],Fi);const oa=e=>e?e.some(t=>t.locations.some(i=>i.status==="Outstanding")):!1,lh=e=>{switch(e){case"New":return"New Badge";case"Modify":return"Modify Badge";case"Terminate":return"Terminate All Access";default:return e}};let Li=class extends Ae{constructor(){super(...arguments),this.hasUpdatePermission=void 0,this.hasApprovePermission=void 0}async getUpdatePermissions(){var e,t,i,s;this.hasUpdatePermission!==void 0||!(!((s=(i=(t=(e=ie.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasUpdatePermission=await Ke(ie.selectedTicket.sitesDetails[0].locations.map(n=>n.id),S.VisitorAccess,U.Update))}async getApprovePermissions(){var e,t,i,s;this.hasApprovePermission!==void 0||!(!((s=(i=(t=(e=ie.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasApprovePermission=await Ke(ie.selectedTicket.sitesDetails[0].locations.map(n=>n.id),S.VisitorAccess,U.Approve))}get canApproveOrDeny(){var e;return!((e=ie.selectedTicket)===null||e===void 0)&&e.state?ie.selectedTicket.state!==O.Cancelled&&oa(ie.selectedTicket.sitesDetails):!1}get canCancel(){var e;return!mt(ie.selectedTicket.id)||!(!((e=ie.selectedTicket)===null||e===void 0)&&e.state)?!1:[O.InProgress.toLowerCase(),oe.PendingApproval.toLowerCase(),oe.Approved.toLowerCase()].includes(ie.selectedTicket.state.toLowerCase())}get canEdit(){var e;return!((e=ie.selectedTicket)===null||e===void 0)&&e.state?![O.Cancelled.toLowerCase(),O.Completed.toLowerCase(),oe.ApprovalDenied.toLowerCase()].includes(ie.selectedTicket.state.toLowerCase()):!1}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}renderApproveDenyBtn(){return!this.hasApprovePermission||!this.canApproveOrDeny?P:g`<ix-button name="approveDenyBtn" has-icon @click="${()=>{this.dispatchClickEvent(L.ApproveDenyTicket)}}"> <md-icon slot="icon">playlist_add_check</md-icon> <span class="button-label">APPROVE/DENY</span> </ix-button>`}renderCancelBtn(){return!this.hasUpdatePermission||!this.canCancel?P:g`<ix-button class="cancel" appearance="outlined" name="cancelBtn" @click="${()=>{this.dispatchClickEvent(L.CancelTicket)}}"> <span class="button-label">${Ye}</span> </ix-button>`}renderEditBtn(){return!this.hasUpdatePermission||!this.canEdit?P:g`<ix-button name="edit-button" @click="${()=>{this.dispatchClickEvent(L.EditTicket)}}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`}render(){return k.loadings.isTicketCancelling?P:g`<div class="w-fit flex gap-2"> ${fe(this.getApprovePermissions().then(()=>g` ${this.renderApproveDenyBtn()}`),P)} ${fe(this.getUpdatePermissions().then(()=>g` ${this.renderCancelBtn()} ${this.renderEditBtn()}`),P)} </div>`}};Li.styles=[ve],Li=E([X("visitor-access-button-group")],Li);let Vi=class extends Ae{constructor(){super(...arguments),this.hasUpdatePermission=void 0,this.hasApprovePermission=void 0}async getUpdatePermissions(){var e,t,i,s;this.hasUpdatePermission!==void 0||!(!((s=(i=(t=(e=Y.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasUpdatePermission=await Ke(Y.selectedTicket.sitesDetails[0].locations.map(n=>n.id),S.PermanentBadge,U.Update))}async getApprovePermissions(){var e,t,i,s;this.hasApprovePermission!==void 0||!(!((s=(i=(t=(e=Y.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasApprovePermission=await Ke(Y.selectedTicket.sitesDetails.flatMap(n=>n.locations.map(o=>o.id)),S.PermanentBadge,U.Approve))}get canApproveOrDeny(){return Y.selectedTicket?Y.selectedTicket.category!=="Terminate"&&Y.selectedTicket.state!==O.Cancelled&&oa(Y.selectedTicket.sitesDetails):!1}get canCancel(){var e;return!mt(Y.selectedTicket.id)||!(!((e=Y.selectedTicket)===null||e===void 0)&&e.state)||!De()["SM:AllowPermanentBadgeCancellation"]?!1:[O.InProgress.toLowerCase(),oe.PendingApproval.toLowerCase(),oe.Approved.toLowerCase()].includes(Y.selectedTicket.state.toLowerCase())}get canEdit(){var e;return!((e=Y.selectedTicket)===null||e===void 0)&&e.state?![O.Cancelled.toLowerCase(),O.Completed.toLowerCase(),oe.ApprovalDenied.toLowerCase()].includes(Y.selectedTicket.state.toLowerCase()):!1}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}renderApproveDenyBtn(){return!this.hasApprovePermission||!this.canApproveOrDeny?P:g`<ix-button name="approveDenyBtn" has-icon @click="${()=>{this.dispatchClickEvent(L.ApproveDenyTicket)}}"> <md-icon slot="icon">playlist_add_check</md-icon> <span class="button-label">APPROVE/DENY</span> </ix-button>`}renderCancelBtn(){return!this.hasUpdatePermission||!this.canCancel?P:g`<ix-button class="cancel" appearance="outlined" name="cancelBtn" @click="${()=>{this.dispatchClickEvent(L.CancelTicket)}}"> <span class="button-label">${Ye}</span> </ix-button>`}renderEditBtn(){return!this.hasUpdatePermission||!this.canEdit?P:g`<ix-button name="edit-button" @click="${()=>{this.dispatchClickEvent(L.EditTicket)}}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`}render(){return k.loadings.isTicketCancelling?P:g`<div class="w-fit flex gap-2"> ${fe(this.getApprovePermissions().then(()=>g` ${this.renderApproveDenyBtn()}`),P)} ${fe(this.getUpdatePermissions().then(()=>g` ${this.renderCancelBtn()} ${this.renderEditBtn()}`),P)} </div>`}};Vi.styles=[ve],Vi=E([X("permanent-badge-button-group")],Vi);let Ui=class extends Ae{constructor(){super(...arguments),this.hasUpdatePermission=void 0}async getUpdatePermissions(){var e,t,i,s;this.hasUpdatePermission!==void 0||!(!((s=(i=(t=(e=Ie.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasUpdatePermission=await bn(Ie.selectedTicket.site))}get canCancel(){var e;return!mt(Ie.selectedTicket.id)||!(!((e=Ie.selectedTicket)===null||e===void 0)&&e.state)?!1:[O.InProgress.toLowerCase(),oe.PendingApproval.toLowerCase(),oe.Approved.toLowerCase()].includes(Ie.selectedTicket.state.toLowerCase())}get canEdit(){var e;return!((e=Ie.selectedTicket)===null||e===void 0)&&e.state?![O.Cancelled.toLowerCase(),O.Completed.toLowerCase()].includes(Ie.selectedTicket.state.toLowerCase()):!1}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}renderCancelBtn(){return!this.hasUpdatePermission||!this.canCancel?P:g`<ix-button class="cancel" appearance="outlined" name="cancelBtn" @click="${()=>{this.dispatchClickEvent(L.CancelTicket)}}"> <span class="button-label">${Ye}</span> </ix-button>`}renderEditBtn(){return!this.hasUpdatePermission||!this.canEdit?P:g`<ix-button name="edit-button" @click="${()=>{this.dispatchClickEvent(L.EditTicket)}}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`}render(){return k.loadings.isTicketCancelling?P:g`<div class="w-fit flex gap-2"> ${fe(this.getUpdatePermissions().then(()=>g` ${this.renderCancelBtn()} ${this.renderEditBtn()}`),P)} </div>`}};Ui.styles=[ve],Ui=E([X("osp-access-button-group")],Ui);let Hi=class extends Ae{constructor(){super(...arguments),this.hasUpdatePermission=void 0}async getUpdatePermissions(){var e,t,i,s;this.hasUpdatePermission!==void 0||!(!((s=(i=(t=(e=Se.selectedTicket)===null||e===void 0?void 0:e.sitesDetails)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.locations)===null||s===void 0)&&s.length)||(this.hasUpdatePermission=await Rn(Se.selectedTicket.site))}get canCancel(){var e;return!mt(Se.selectedTicket.id)||!(!((e=Se.selectedTicket)===null||e===void 0)&&e.state)?!1:[O.InProgress.toLowerCase(),oe.Approved.toLowerCase()].includes(Se.selectedTicket.state.toLowerCase())}get canEdit(){var e;return!((e=Se.selectedTicket)===null||e===void 0)&&e.state?![O.Cancelled.toLowerCase(),O.Completed.toLowerCase()].includes(Se.selectedTicket.state.toLowerCase()):!1}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}renderCancelBtn(){return!this.hasUpdatePermission||!this.canCancel?P:g`<ix-button class="cancel" appearance="outlined" name="cancelBtn" @click="${()=>{this.dispatchClickEvent(L.CancelTicket)}}"> <span class="button-label">${Ye}</span> </ix-button>`}renderEditBtn(){return!this.hasUpdatePermission||!this.canEdit?P:g`<ix-button name="edit-button" @click="${()=>{this.dispatchClickEvent(L.EditTicket)}}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`}render(){return k.loadings.isTicketCancelling?P:g`<div class="w-fit flex gap-2"> ${fe(this.getUpdatePermissions().then(()=>g`${this.renderCancelBtn()}${this.renderEditBtn()}`),P)} </div>`}};Hi.styles=[ve],Hi=E([X("pop-access-button-group")],Hi);let ii=class extends Ae{constructor(){super(...arguments),this.hasPermission=void 0,this.backendService=void 0}async getServiceBackend(){var e;this.backendService||(this.backendService=await K.getServiceBackend(re.newTicket.location.accountNumber,(e=re.newTicket.site)===null||e===void 0?void 0:e.id,"Remote_hands"))}async getPermissions(){var e,t,i,s,n,o,a,r;return!(!((t=(e=re.newTicket)===null||e===void 0?void 0:e.location)===null||t===void 0)&&t.id&&!((s=(i=re.newTicket)===null||i===void 0?void 0:i.location)===null||s===void 0)&&s.accountNumber)||(await this.getServiceBackend(),this.backendService===H.TelxSFDC)?!1:this.hasPermission!==void 0?this.hasPermission:(re.loadings.ticketDetailsPermissionCheck=!0,this.hasPermission=await Ct(U.Update,S.RemoteHands,(o=(n=re.newTicket)===null||n===void 0?void 0:n.location)===null||o===void 0?void 0:o.id,(r=(a=re.newTicket)===null||a===void 0?void 0:a.location)===null||r===void 0?void 0:r.accountNumber),re.loadings.ticketDetailsPermissionCheck=!1,this.hasPermission)}get canCancel(){var e,t;return this.backendService===H.ServiceNow?!1:((t=(e=re.selectedTicket)===null||e===void 0?void 0:e.state)===null||t===void 0?void 0:t.toLowerCase())===O.New.toLowerCase()}get canEdit(){var e,t,i;const s=new Set([O.New.toLowerCase(),O.InProgress.toLowerCase()]);return!((e=re.selectedTicket)===null||e===void 0)&&e.state?s.has((i=(t=re.selectedTicket)===null||t===void 0?void 0:t.state)===null||i===void 0?void 0:i.toLowerCase()):!1}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return k.loadings.isTicketCancelling?P:g`<div class="w-fit flex gap-2"> ${fe(this.getPermissions().then(e=>e?g` ${this.canCancel?g`<ix-button class="cancel" appearance="outlined" name="cancelRemovalsBtn" @click="${()=>{this.dispatchClickEvent(L.CancelTicket)}}"> <span class="button-label">${_m}</span> </ix-button>`:P} ${this.canEdit?g`<ix-button name="edit-button" @click="${()=>this.dispatchClickEvent(L.EditTicket)}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`:P}`:P),P)} </div>`}};ii.styles=[ve],E([Ji()],ii.prototype,"backendService",void 0),ii=E([X("remote-hands-button-group")],ii);let zi=class extends Ae{constructor(){super(...arguments),this.hasPermission=void 0}async canPerformActions(){var e,t,i,s,n,o;return!(!((t=(e=Ue.selectedTicket)===null||e===void 0?void 0:e.id)===null||t===void 0)&&t.toLowerCase().startsWith("cs"))||![O.Announced,O.Draft,O.New,O.InProgress].includes((i=Ue.selectedTicket)===null||i===void 0?void 0:i.state)||!(!((s=Ue.selectedTicket)===null||s===void 0)&&s.locations)||((n=Ue.selectedTicket)===null||n===void 0?void 0:n.locations.length)===0||Ue.selectedTicket.serviceBackend===H.TelxSFDC?!1:this.hasPermission!==void 0?this.hasPermission:(this.hasPermission=await Ke((o=Ue.selectedTicket)===null||o===void 0?void 0:o.locations,S.TroubleTickets,U.Update),this.hasPermission)}dispatchClickEvent(e){const t=new CustomEvent(e,{bubbles:!0,composed:!0});this.dispatchEvent(t)}render(){return k.loadings.isTicketCancelling?P:g`<div class="w-fit flex gap-2"> ${fe(this.canPerformActions().then(e=>e?g`<ix-button class="cancel" appearance="outlined" name="cancel-button" @click="${()=>{this.dispatchClickEvent(L.CancelTicket)}}"> <span class="button-label">${Ye}</span> </ix-button> <ix-button name="edit-button" @click="${()=>this.dispatchClickEvent(L.EditTicket)}" has-icon> <md-icon slot="icon">edit</md-icon> <span>${Ee}</span> </ix-button>`:P),P)} </div>`}};zi.styles=[ve],zi=E([X("trouble-ticket-button-group")],zi);const W={Home:"Home",ServiceTickets:"Service Tickets",Reports:"Reports, Maintenance & Incident Notifications",Incidents:"Incidents",DeliveriesTicketDetails:"Deliveries Ticket Details",RemovalsTicketDetails:"Removals Ticket Details",RemoteHandsTicketDetails:"Remote Hands Ticket Details",VisitorAccessTicketDetails:"Visitor Access Ticket Details",CustomerCareTicketDetails:"Customer Care Ticket Details",PermanentBadgeTicketDetails:"Permanent Badge Ticket Details",TroubleTicketDetails:"Trouble Ticket Details",OspAccessTicketDetails:"OSP Access Ticket Details",PopAccessTicketDetails:"POP Access Ticket Details"},Dt=[{name:W.CustomerCareTicketDetails,path:"/service-tickets/customer-care/:ticketId",component:"customer-care-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<customer-care-button-group></customer-care-button-group>`,action:()=>{import("./ui-service-management15.js")}},{name:W.DeliveriesTicketDetails,path:"/service-tickets/deliveries/:ticketId",component:"deliveries-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<deliveries-button-group></deliveries-button-group>`,action:()=>{import("./ui-service-management19.js")}},{name:W.RemovalsTicketDetails,path:"/service-tickets/removals/:ticketId",component:"removals-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<removals-button-group></removals-button-group>`,action:()=>{import("./ui-service-management20.js")}},{name:W.VisitorAccessTicketDetails,path:"/service-tickets/facility-access/visitor-access/:ticketId",component:"visitor-access-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<visitor-access-button-group></visitor-access-button-group>`,action:()=>{import("./ui-service-management21.js")}},{name:W.PermanentBadgeTicketDetails,path:"/service-tickets/facility-access/permanent-badge/:ticketId",component:"permanent-badge-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<permanent-badge-button-group></permanent-badge-button-group>`,action:()=>{import("./ui-service-management24.js")}},{name:W.RemoteHandsTicketDetails,path:"/service-tickets/remote-hands/:ticketId",component:"remote-hands-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<remote-hands-button-group></remote-hands-button-group>`,action:()=>{import("./ui-service-management25.js")}},{name:W.TroubleTicketDetails,path:"/service-tickets/trouble-tickets/:ticketId",component:"trouble-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<trouble-ticket-button-group></trouble-ticket-button-group>`,action:()=>{import("./ui-service-management26.js")}},{name:W.Reports,path:"/reports",component:"site-maintenance-list",action:()=>{import("./ui-service-management27.js")}}];wt.isOspEnabled()&&Dt.push({name:W.OspAccessTicketDetails,path:"/service-tickets/facility-access/osp-access/:ticketId",component:"osp-access-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<osp-access-button-group></osp-access-button-group>`,action:()=>{import("./ui-service-management29.js")}}),wt.isPopPoeEnabled()&&Dt.push({name:W.PopAccessTicketDetails,path:"/service-tickets/facility-access/pop-access/:ticketId",component:"pop-access-ticket-details-view",hideAccountSwitcher:!0,headerLeft:g`<sm-back-button></sm-back-button>`,headerRight:g`<pop-access-button-group></pop-access-button-group>`,action:()=>{import("./ui-service-management30.js")}}),wt.isIncidentsEnabled()&&Dt.push({name:W.Incidents,path:"/incidents",component:"incidents-list",action:()=>{import("./ui-service-management31.js")}});let ji=class extends Ae{constructor(){super(...arguments),this.pageTitle="Loading..."}static get styles(){return[sm]}async firstUpdated(){window.addEventListener("vaadin-router-location-changed",e=>{var t;this.pageTitle=(t=e.detail.location.route)===null||t===void 0?void 0:t.name})}get currentAccount(){return ae.getUserAccount()}get headerRight(){var e;return this.pageTitle===W.ServiceTickets?null:(e=Dt.find(t=>t.name===this.pageTitle))===null||e===void 0?void 0:e.headerRight}render(){var e,t;return g` <div class="header-container"> <h1 class="header__title">${this.pageTitle}</h1> <sm-create-service-ticket-button></sm-create-service-ticket-button> ${this.headerRight} <div class="header__profile"> ${((t=(e=ae.getUser())===null||e===void 0?void 0:e.profile)===null||t===void 0?void 0:t.email)||"Unknown User"} </div> <button @click="${()=>ae.redirectToLogout()}" class="header__logout"> <svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="currentColor"> <path d="m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4V5z"></path> </svg> Logout </button> <ix-select class="header__accounts" label="Account" .wideMenu="${!0}"> <ix-select-option value="${pa(this.currentAccount.accountNumber)}" .selected="${!0}"> <div slot="headline">${this.currentAccount.name}</div> </ix-select-option> </ix-select> </div> `}};E([we({type:String})],ji.prototype,"pageTitle",void 0),ji=E([X("sm-app-header")],ji);const mh=bt`:host{--navbar-width:256px;--logo-padding-left:0px;--navbar-icon-min-width:56px}.container{width:var(--navbar-width);transition:width .3s ease;border-radius:12px;background:linear-gradient(#1456e0 20.5%,#0d2497 113.5%);min-height:calc(100vh - 54px);margin:15px;color:#fff;padding-bottom:24px;z-index:1000;box-shadow:rgba(3,28,82,.24) 0 8px 24px;text-align:center}.navigation-logo{user-select:none;display:inline-block;fill:currentcolor;flex-shrink:0;transition:fill .2s cubic-bezier(.4,0,.2,1) 0s;font-size:1.5rem;width:178px!important;height:27px!important;padding-top:24px;padding-bottom:18px;padding-left:var(--logo-padding-left)}ul{list-style:none;margin:0;position:relative;padding:8px 4px}ul li a{-webkit-tap-highlight-color:transparent;background-color:transparent;outline:0;border:0;margin:0;cursor:pointer;user-select:none;vertical-align:middle;appearance:none;color:inherit;display:flex;-webkit-box-flex:1;flex-grow:1;-webkit-box-align:center;align-items:center;position:relative;text-decoration:none;min-width:0;box-sizing:border-box;text-align:left;transition:background-color 150ms cubic-bezier(.4,0,.2,1) 0s;padding:12px 16px;border-radius:8px;opacity:.6;text-overflow:ellipsis;white-space:nowrap;-webkit-box-pack:unset;justify-content:unset}a.active,ul li a:hover{background:rgba(255,255,255,.16);opacity:1}.navigation-icon svg{user-select:none;width:1em;height:1em;display:inline-block;fill:currentcolor;transition:fill .2s cubic-bezier(.4,0,.2,1) 0s;font-size:1.5rem;flex-shrink:0;display:inline-flex;color:inherit;min-width:var(--navbar-icon-min-width)}h6{margin:0;font-weight:700;line-height:24px;letter-spacing:.1px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:inherit}.divider{border-color:#fff;opacity:.2;margin:0;flex-shrink:0;border-width:0 0 thin;border-style:solid}.container.compact{--navbar-width:80px}.container.compact .navigation-logo{--logo-padding-left:28px}.container.compact .navigation-icon svg{--navbar-icon-min-width:42px}@media only screen and (min-width:5px) and (max-width:500px){.container{--navbar-width:100%;min-height:auto;margin:0;border-radius:0;padding-bottom:0}.container.compact{--navbar-width:100%}}@media only screen and (min-width:500px) and (max-width:1250px){.container{--navbar-width:100%;min-height:auto;margin:0;border-radius:0;padding-bottom:0}.container.compact{--navbar-width:100%}}`,ra=bt`@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/materialicons/v145/flUhRq6tzZclQEJ-Vdg-IuiaDsNZ.ttf) format('truetype')}.material-icons{font-family:'Material Icons';font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr}@font-face{font-family:'Material Symbols Outlined';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/materialsymbolsoutlined/v354/kJF1BvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oDMzByHX9rA6RzaxHMPdY43zj-jCxv3fzvRNU22ZXGJpEpjC_1v-p_4MrImHCIJIZrDCvHOem.ttf) format('truetype')}.material-symbols-outlined{font-family:'Material Symbols Outlined';font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr}.title{font-style:normal;font-weight:700;font-size:20px;line-height:24px;letter-spacing:.15px}.temp-button{border:none;padding:10px;color:#fff;border-radius:100px;cursor:pointer;margin-right:10px;text-decoration:none;font-family:var(--root-secondary-font);font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px;text-transform:uppercase}.temp-button span{padding:20px}.temp-button:disabled{background-color:#ddd}.flex{display:flex}.flex-1{flex:1}.border-top-solid-gray{border-top:solid 1px #ddd}.red{background-color:#db0028}.blue{background-color:#1456e0}.white{background-color:#fff;color:#1456e0;border:solid 1px #1456e0}.right{float:right}.margin-top-20{margin-top:20px}.padding-2{padding:2px}.padding-20{padding:20px}.padding-right-10{padding:10px}.font-14{font-size:14px}.button-container{position:absolute;bottom:30px;margin-left:10px}.temp-button span{padding:5px;font-size:20px}@media only screen and (min-width:5px) and (max-width:500px){.button-container{right:10px;top:10px}}@media only screen and (min-width:500px) and (max-width:1250px){.button-container{right:10px;top:10px}}`;let ca=class extends Rt{static get styles(){return[ra]}render(){return g` <div class="button-container"> <button @click="${()=>{localStorage.clear(),rt.go("/")}}" class="temp-button white"> <span class="material-icons"> <md-icon slot="icon">restart_alt</md-icon> </span> </button> </div> `}};ca=E([X("dev-clear-storage-button-service")],ca);const si={digitalRealtyLogo:Ot`
1061
1061
  <path d="M17.6281 26.4421V23.1369C20.6656 23.1369 23.1369 20.6657 23.1369 17.6281H26.4421C26.4421 22.4881 22.4881 26.4421 17.6281 26.4421ZM17.6281 0V3.30527C20.6656 3.30527 23.1369 5.77647 23.1369 8.81404H26.4421C26.4421 3.95398 22.4881 0 17.6281 0ZM8.81404 23.1369H3.30527V17.6281H0V26.4421H8.81404V23.1369ZM3.30527 3.30527H8.81404V0H0V8.81404H3.30527V3.30527Z"></path>
1062
1062
  `,digitalRealtyLogoWithText:Ot`
1063
1063
  <path d="M174.823 18.1256V18.338H174.216V19.7581H173.986V18.338H173.379V18.1256H174.823ZM175.376 18.1256L176.025 19.4728L176.68 18.1256H177.002V19.7581H176.784V18.3865L176.116 19.7581H175.928L175.272 18.3865V19.7581H175.06V18.1256H175.376Z"></path>
@@ -1067,4 +1067,4 @@ video {
1067
1067
  <path d="M4 4C2.897 4 2 4.897 2 6V16C2 17.103 2.897 18 4 18H0V20H24V18H20C21.103 18 22 17.103 22 16V6C22 4.897 21.103 4 20 4H4ZM4 6H20L20.002 16H4V6ZM14.2852 8.00781L11 11.293L9.20703 9.5L7.79297 10.9141L11 14.1211L15.6992 9.42188L14.2852 8.00781Z"></path>
1068
1068
  `,reportsIcon:Ot`
1069
1069
  <path d="M6 2C4.90575 2 4 2.90575 4 4V20C4 21.0943 4.90575 22 6 22H11V20H6V4H13V9H18V13H20V8L14 2H6ZM12 11V14H15C15 12.343 13.641 11.031 12 11ZM11 12C9.343 12 8 13.343 8 15C8 16.657 9.343 18 11 18C12.657 18 13.969 16.641 14 15H11V12ZM16 15V21H13C13 22.654 14.346 24 16 24H21C22.645 24 24 22.645 24 21V15H16ZM18 17H22V21C22 21.565 21.565 22 21 22C20.449 22 20 21.552 20 21H18V17Z" fill="white"/>
1070
- `};let ji=class extends Rt{constructor(){super(...arguments),this.navigationItems=[],this.compact=!1}static get styles(){return[ve,ph]}firstUpdated(){window.addEventListener("vaadin-router-location-changed",()=>{this.requestUpdate(),this.navigationItems.length||(this.navigationItems=[{href:Xt(W.ServiceTickets),title:W.ServiceTickets,icon:g`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"> ${si.serviceTicketsIcon} </svg>`},{href:Xt(W.Reports),title:W.Reports,icon:g`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"> ${si.reportsIcon} </svg>`}])})}toggleCompact(){this.compact=!this.compact}renderItems(){return g` <ul> ${this.navigationItems.map(e=>g` <li> <a href="${e.href}" class="${e.href===window.location.pathname?"active":""}"> <div class="navigation-icon">${e.icon}</div> ${this.compact?"":g`<h6 class="dlr-text-small">${e.title}</h6>`} </a> </li> `)} </ul>`}render(){return g` <div class="${`container ${this.compact?"compact":""}`}"> <svg @click="${this.toggleCompact}" class="navigation-logo" focusable="false" aria-hidden="true" viewBox="0 0 178 27"> ${this.compact?si.digitalRealtyLogo:si.digitalRealtyLogoWithText} </svg> <hr class="divider"> ${this.renderItems()} <dev-clear-storage-button-service></dev-clear-storage-button-service> </div> `}};E([we({type:Boolean,attribute:!1})],ji.prototype,"compact",void 0),ji=E([X("sm-navigation-bar")],ji);const hh=bt`:host{display:block;font-size:calc(10px + 2vmin);color:#1a2b42;margin:0 auto;background-color:#f5f7ff;font-size:18px;--desktop-device-width:1920px;--tablet-device-width:1024px;--mobile-device-width:375px}.service-management__body{display:flex;flex-direction:column}.service-management__body.standalone{flex-direction:row}.center-container{flex-grow:1;padding:40px;padding-bottom:48px}main{flex-grow:1;max-width:100%}.create-service-ticket-btn{font-family:var(--root-secondary-font);font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px}@media only screen and (min-width:5px) and (max-width:500px){.service-management__body.standalone{flex-direction:column}}@media only screen and (min-width:500px) and (max-width:1250px){.service-management__body.standalone{flex-direction:column}}`;class vh{constructor(){this.isStandalone=!1,se(this),Je(this,{name:"app-state",properties:["isStandalone"],storage:window.sessionStorage})}}const nn=new vh;let Me=class extends Rt{constructor(){super(...arguments),this.routes=[],this.baseUrl="",this.sessionToken="",this.disableAuthentication=!1,this.isStandalone=!1,this.appIsVisible=!1,this.handleErrorRaised=e=>{this.errorMessage=e.detail}}static get styles(){return[on,ve,hh]}updated(e){e.has("routes")&&this.routes.length&&Tm().setRoutes(this.routes)}async firstUpdated(){nn.isStandalone=this.isStandalone,this.configureAuth(),this.init(),this.configureMomentCalendarDate(),await J.fillLookups()}configureAuth(){this.disableAuthentication||De().DisableServiceManagementUIAuth?this.appIsVisible=!0:ne.isProcessing()||(ne.isLoggedIn()?this.appIsVisible=!0:ne.redirectToAuth())}configureMomentCalendarDate(){const e=Xl().toUpperCase();G.updateLocale("en",{calendar:{sameDay:`[Today], ${e}`,lastDay:`[Yesterday], ${e}`,lastWeek:`${e}`,sameElse:`${e}`}})}init(){window.addEventListener(V.ErrorRaised,this.handleErrorRaised),setTimeout(()=>{var e;const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("main");t&&ym(t,this.baseUrl,Dt)})}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(V.ErrorRaised,this.handleErrorRaised),bm()}clearErrorMessage(){this.errorMessage=void 0}renderNavBar(){return this.isStandalone?g`<sm-navigation-bar></sm-navigation-bar>`:N}renderBody(){return this.isStandalone?g`<div class="center-container"> <sm-app-header></sm-app-header> <main></main> </div>`:g`<main></main>`}render(){return this.appIsVisible?g` <div class="md:mx-4 lg:mx-0 service-management__body ${this.isStandalone?"standalone":""}"> ${this.renderNavBar()} ${this.renderBody()} <ix-dialog ?open="${this.errorMessage}" @closed="${this.clearErrorMessage}"> <div slot="content" method="dialog">${this.errorMessage}</div> <div class="dialog-actions" slot="actions"> <ix-button id="dialogCloseBtn" ariaLabel="Close" appearance="text" text="Close" @click="${this.clearErrorMessage}"> <span>Close</span> </ix-button> </div> </ix-dialog> </div> `:N}};E([we({type:Array})],Me.prototype,"routes",void 0),E([we({type:String})],Me.prototype,"baseUrl",void 0),E([we({type:String})],Me.prototype,"sessionToken",void 0),E([we({type:Boolean,attribute:!0})],Me.prototype,"disableAuthentication",void 0),E([we({type:Boolean,attribute:!0})],Me.prototype,"isStandalone",void 0),E([we({type:Boolean,attribute:!1})],Me.prototype,"appIsVisible",void 0),E([we({type:String,attribute:!1})],Me.prototype,"errorMessage",void 0),Me=E([X("ui-service-management")],Me);export{ep as $,V as A,im as B,em as C,qm as D,O as E,vn as F,Dm as G,fn as H,w as I,ra as J,wt as K,L,Fm as M,Lm as N,Am as O,zl as P,Aa as Q,W as R,H as S,ve as T,xm as U,J as V,mt as W,tm as X,zm as Y,St as Z,Hm as _,y as a,sn as a$,Xm as a0,Qm as a1,Pt as a2,Q as a3,dm as a4,ma as a5,pa as a6,ha as a7,va as a8,$e as a9,ba as aA,We as aB,jp as aC,km as aD,ja as aE,zp as aF,Yl as aG,hu as aH,Na as aI,Vm as aJ,Um as aK,mn as aL,Di as aM,tp as aN,Ba as aO,Ue as aP,l as aQ,am as aR,Nm as aS,ft as aT,Qt as aU,gn as aV,xa as aW,Nt as aX,dp as aY,up as aZ,Vl as a_,mh as aa,lt as ab,F as ac,Ct as ad,Wa as ae,Qa as af,re as ag,Ra as ah,dt as ai,pn as aj,ie as ak,Cm as al,Sm as am,Y as an,Oi as ao,bp as ap,Fa as aq,Ji as ar,qp as as,Bm as at,Ie as au,ka as av,Wp as aw,Se as ax,ya as ay,Qp as az,da as b,rh as b0,ei as b1,Jt as b2,Ye as b3,m as b4,mp as b5,pp as b6,Hl as b7,Ll as b8,Si as b9,hp as ba,vp as bb,qi as bc,vi as c,Te as d,k as e,nn as f,ne as g,ln as h,Om as i,Zl as j,ga as k,Ul as l,Xt as m,Ze as n,$m as o,De as p,Kl as q,Ve as r,K as s,Pm as t,cm as u,A as v,ce as w,_m as x,je as y,um as z};
1070
+ `};let Mi=class extends Rt{constructor(){super(...arguments),this.navigationItems=[],this.compact=!1}static get styles(){return[ve,mh]}firstUpdated(){window.addEventListener("vaadin-router-location-changed",()=>{this.requestUpdate(),this.navigationItems.length||(this.navigationItems=[{href:Xt(W.ServiceTickets),title:W.ServiceTickets,icon:g`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"> ${si.serviceTicketsIcon} </svg>`},{href:Xt(W.Reports),title:W.Reports,icon:g`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"> ${si.reportsIcon} </svg>`}])})}toggleCompact(){this.compact=!this.compact}renderItems(){return g` <ul> ${this.navigationItems.map(e=>g` <li> <a href="${e.href}" class="${e.href===window.location.pathname?"active":""}"> <div class="navigation-icon">${e.icon}</div> ${this.compact?"":g`<h6 class="dlr-text-small">${e.title}</h6>`} </a> </li> `)} </ul>`}render(){return g` <div class="${`container ${this.compact?"compact":""}`}"> <svg @click="${this.toggleCompact}" class="navigation-logo" focusable="false" aria-hidden="true" viewBox="0 0 178 27"> ${this.compact?si.digitalRealtyLogo:si.digitalRealtyLogoWithText} </svg> <hr class="divider"> ${this.renderItems()} <dev-clear-storage-button-service></dev-clear-storage-button-service> </div> `}};E([we({type:Boolean,attribute:!1})],Mi.prototype,"compact",void 0),Mi=E([X("sm-navigation-bar")],Mi);const ph=bt`:host{display:block;font-size:calc(10px + 2vmin);color:#1a2b42;margin:0 auto;background-color:#f5f7ff;font-size:18px;--desktop-device-width:1920px;--tablet-device-width:1024px;--mobile-device-width:375px}.service-management__body{display:flex;flex-direction:column}.service-management__body.standalone{flex-direction:row}.center-container{flex-grow:1;padding:40px;padding-bottom:48px}main{flex-grow:1;max-width:100%}.create-service-ticket-btn{font-family:var(--root-secondary-font);font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px}@media only screen and (min-width:5px) and (max-width:500px){.service-management__body.standalone{flex-direction:column}}@media only screen and (min-width:500px) and (max-width:1250px){.service-management__body.standalone{flex-direction:column}}`;class hh{constructor(){this.isStandalone=!1,se(this),Je(this,{name:"app-state",properties:["isStandalone"],storage:window.sessionStorage})}}const da=new hh;let Me=class extends Rt{constructor(){super(...arguments),this.routes=[],this.baseUrl="",this.sessionToken="",this.disableAuthentication=!1,this.isStandalone=!1,this.appIsVisible=!1,this.handleErrorRaised=e=>{this.errorMessage=e.detail}}static get styles(){return[ua,ve,ph]}updated(e){e.has("routes")&&this.routes.length&&ym().setRoutes(this.routes)}async firstUpdated(){da.isStandalone=this.isStandalone,this.configureAuth(),this.init(),this.configureMomentCalendarDate(),await J.fillLookups()}configureAuth(){this.disableAuthentication||De().DisableServiceManagementUIAuth?this.appIsVisible=!0:ae.isProcessing()||(ae.isLoggedIn()?this.appIsVisible=!0:ae.redirectToAuth())}configureMomentCalendarDate(){const e=im().toUpperCase();G.updateLocale("en",{calendar:{sameDay:`[Today], ${e}`,lastDay:`[Yesterday], ${e}`,lastWeek:`${e}`,sameElse:`${e}`}})}init(){window.addEventListener(L.ErrorRaised,this.handleErrorRaised),setTimeout(()=>{var e;const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("main");t&&km(t,this.baseUrl,Dt)})}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(L.ErrorRaised,this.handleErrorRaised),Tm()}clearErrorMessage(){this.errorMessage=void 0}renderNavBar(){return this.isStandalone?g`<sm-navigation-bar></sm-navigation-bar>`:P}renderBody(){return this.isStandalone?g`<div class="center-container"> <sm-app-header></sm-app-header> <main></main> </div>`:g`<main></main>`}render(){return this.appIsVisible?g` <div class="md:mx-4 lg:mx-0 service-management__body ${this.isStandalone?"standalone":""}"> ${this.renderNavBar()} ${this.renderBody()} <ix-dialog ?open="${this.errorMessage}" @closed="${this.clearErrorMessage}"> <div slot="content" method="dialog">${this.errorMessage}</div> <div class="dialog-actions" slot="actions"> <ix-button id="dialogCloseBtn" ariaLabel="Close" appearance="text" text="Close" @click="${this.clearErrorMessage}"> <span>Close</span> </ix-button> </div> </ix-dialog> </div> `:P}};E([we({type:Array})],Me.prototype,"routes",void 0),E([we({type:String})],Me.prototype,"baseUrl",void 0),E([we({type:String})],Me.prototype,"sessionToken",void 0),E([we({type:Boolean,attribute:!0})],Me.prototype,"disableAuthentication",void 0),E([we({type:Boolean,attribute:!0})],Me.prototype,"isStandalone",void 0),E([we({type:Boolean,attribute:!1})],Me.prototype,"appIsVisible",void 0),E([we({type:String,attribute:!1})],Me.prototype,"errorMessage",void 0),Me=E([X("ui-service-management")],Me);export{Qm as $,L as A,om as B,nm as C,Pm as D,O as E,ka as F,qm as G,ba as H,w as I,dn as J,gt as K,U as L,xm as M,Fm as N,Rm as O,Wl as P,Cn as Q,W as R,H as S,ve as T,Em as U,J as V,lt as W,am as X,Hm as Y,St as Z,Um as _,y as a,ra as a$,Ym as a0,Xm as a1,Ct as a2,Q as a3,pm as a4,vn as a5,gn as a6,wn as a7,fn as a8,$e as a9,Sn as aA,We as aB,zp as aC,fm as aD,Zn as aE,Hp as aF,tm as aG,fu as aH,$n as aI,Lm as aJ,Vm as aK,ga as aL,Bi as aM,ep as aN,Fn as aO,Ue as aP,l as aQ,cm as aR,Cm as aS,ft as aT,Qt as aU,ya as aV,Hn as aW,Pt as aX,cp as aY,dp as aZ,jl as a_,lh as aa,ut as ab,F as ac,Nt as ad,Xn as ae,na as af,oe as ag,Nn as ah,ct as ai,wa as aj,ie as ak,Sm as al,Im as am,Y as an,$i as ao,Tp as ap,zn as aq,Wi as ar,Pp as as,Dm as at,Ie as au,An as av,Jp as aw,Se as ax,_n as ay,Xp as az,ln as b,oh as b0,ei as b1,Jt as b2,Ke as b3,m as b4,lp as b5,mp as b6,Jl as b7,zl as b8,Si as b9,pp as ba,hp as bb,Di as bc,vi as c,Te as d,k as e,da as f,ae as g,va as h,Bm as i,Ql as j,Ci as k,Ml as l,Xt as m,wt as n,Om as o,De as p,em as q,Ve as r,K as s,Nm as t,mm as u,S as v,re as w,Am as x,je as y,hm as z};