@ssgc/alert-console 2.7.3 → 2.7.4

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.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),m=require("react"),d=require("antd"),ct=require("@ant-design/icons"),Ae=require("react-toastify"),ut=require("@tanstack/react-query"),ma="#FF3B30",fa="#FF9500",ha="#FFCC00",ya="#34C759",Wt={critical:ma,high:fa,medium:ha,low:ya},on={Critical:Wt.critical,High:Wt.high,Medium:Wt.medium,Low:Wt.low};function pa(t){return on[t]||on.Low}function ln(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,a=Number.parseInt(s,10),o=Number.parseInt(n,10),c=Number.parseFloat(r||"0"),l=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o:0,f=Number.isFinite(c)?c:0;return l*3600+u*60+f}function cn(t){const e=t.thirdPartyIds??t.ThirdPartyIds??t.thirdPartyId??t.ThirdPartyId??"",s=Array.isArray(e)?e.join(","):String(e??"");if(!s||!s.trim())return[];const n=s.split(",").map(o=>parseInt(String(o).trim(),10)).filter(o=>Number.isFinite(o)),r=new Set,a=[];return n.forEach(o=>{r.has(o)||(r.add(o),a.push(o))}),a}const _n="",ga=_n,Sa="",xa="",va="",wa="",un={snl:{alerts:_n,rules:ga},schools:{alerts:Sa,rules:xa},transit:{alerts:va,rules:wa}};function Ue(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Aa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Vt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Le(t,e){const s={...e.headers,...Aa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Ta(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ue(t.baseUrl,"/api/Alert"),n=await Le(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ue(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Le(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Ue(t.baseUrl,"/Alerts/GetAlertsReport"),r=Vt(n,s),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ue(t.baseUrl,"/api/Alert/status");return Le(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ue(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Le(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Ue(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Le(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ue(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Le(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Ue(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Le(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=Ue(t.baseUrl,"/api/Alert/GetNotifications"),r=Vt(n,{alertId:s}),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async notifyFamilyMembers(s){const n=Ue(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Vt(n,{alertId:s});return Le(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ue(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Vt(a,{alertId:s,isEmail:n,isSMS:r});return Le(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ue(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Le(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ue(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Le(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}function dn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Na(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Bt(t,e){const s={...e.headers,...Na()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function ba(t){const e={"Content-Type":"application/json",...t.headers||{}},s=dn(t.baseUrl,"/api/Rules"),n=dn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Bt(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Bt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Bt(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return Bt(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function ka(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Qt={exports:{}},Ia=Qt.exports,mn;function Ea(){return mn||(mn=1,(function(t,e){(function(s,n){t.exports=n()})(Ia,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",c="minute",l="hour",u="day",f="week",h="month",x="quarter",p="year",k="date",j="Invalid Date",M=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,G=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,L={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(U){var v=["th","st","nd","rd"],S=U%100;return"["+U+(v[(S-20)%10]||v[S]||v[0])+"]"}},$=function(U,v,S){var I=String(U);return!I||I.length>=v?U:""+Array(v+1-I.length).join(S)+U},T={s:$,z:function(U){var v=-U.utcOffset(),S=Math.abs(v),I=Math.floor(S/60),A=S%60;return(v<=0?"+":"-")+$(I,2,"0")+":"+$(A,2,"0")},m:function U(v,S){if(v.date()<S.date())return-U(S,v);var I=12*(S.year()-v.year())+(S.month()-v.month()),A=v.clone().add(I,h),R=S-A<0,F=v.clone().add(I+(R?-1:1),h);return+(-(I+(S-A)/(R?A-F:F-A))||0)},a:function(U){return U<0?Math.ceil(U)||0:Math.floor(U)},p:function(U){return{M:h,y:p,w:f,d:u,D:k,h:l,m:c,s:o,ms:a,Q:x}[U]||String(U||"").toLowerCase().replace(/s$/,"")},u:function(U){return U===void 0}},D="en",B={};B[D]=L;var C="$isDayjsObject",q=function(U){return U instanceof oe||!(!U||!U[C])},y=function U(v,S,I){var A;if(!v)return D;if(typeof v=="string"){var R=v.toLowerCase();B[R]&&(A=R),S&&(B[R]=S,A=R);var F=v.split("-");if(!A&&F.length>1)return U(F[0])}else{var Y=v.name;B[Y]=v,A=Y}return!I&&A&&(D=A),A||!I&&D},g=function(U,v){if(q(U))return U.clone();var S=typeof v=="object"?v:{};return S.date=U,S.args=arguments,new oe(S)},O=T;O.l=y,O.i=q,O.w=function(U,v){return g(U,{locale:v.$L,utc:v.$u,x:v.$x,$offset:v.$offset})};var oe=(function(){function U(S){this.$L=y(S.locale,null,!0),this.parse(S),this.$x=this.$x||S.x||{},this[C]=!0}var v=U.prototype;return v.parse=function(S){this.$d=(function(I){var A=I.date,R=I.utc;if(A===null)return new Date(NaN);if(O.u(A))return new Date;if(A instanceof Date)return new Date(A);if(typeof A=="string"&&!/Z$/i.test(A)){var F=A.match(M);if(F){var Y=F[2]-1||0,K=(F[7]||"0").substring(0,3);return R?new Date(Date.UTC(F[1],Y,F[3]||1,F[4]||0,F[5]||0,F[6]||0,K)):new Date(F[1],Y,F[3]||1,F[4]||0,F[5]||0,F[6]||0,K)}}return new Date(A)})(S),this.init()},v.init=function(){var S=this.$d;this.$y=S.getFullYear(),this.$M=S.getMonth(),this.$D=S.getDate(),this.$W=S.getDay(),this.$H=S.getHours(),this.$m=S.getMinutes(),this.$s=S.getSeconds(),this.$ms=S.getMilliseconds()},v.$utils=function(){return O},v.isValid=function(){return this.$d.toString()!==j},v.isSame=function(S,I){var A=g(S);return this.startOf(I)<=A&&A<=this.endOf(I)},v.isAfter=function(S,I){return g(S)<this.startOf(I)},v.isBefore=function(S,I){return this.endOf(I)<g(S)},v.$g=function(S,I,A){return O.u(S)?this[I]:this.set(A,S)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(S,I){var A=this,R=!!O.u(I)||I,F=O.p(S),Y=function(ge,le){var ie=O.w(A.$u?Date.UTC(A.$y,le,ge):new Date(A.$y,le,ge),A);return R?ie:ie.endOf(u)},K=function(ge,le){return O.w(A.toDate()[ge].apply(A.toDate("s"),(R?[0,0,0,0]:[23,59,59,999]).slice(le)),A)},te=this.$W,ae=this.$M,ue=this.$D,xe="set"+(this.$u?"UTC":"");switch(F){case p:return R?Y(1,0):Y(31,11);case h:return R?Y(1,ae):Y(0,ae+1);case f:var de=this.$locale().weekStart||0,me=(te<de?te+7:te)-de;return Y(R?ue-me:ue+(6-me),ae);case u:case k:return K(xe+"Hours",0);case l:return K(xe+"Minutes",1);case c:return K(xe+"Seconds",2);case o:return K(xe+"Milliseconds",3);default:return this.clone()}},v.endOf=function(S){return this.startOf(S,!1)},v.$set=function(S,I){var A,R=O.p(S),F="set"+(this.$u?"UTC":""),Y=(A={},A[u]=F+"Date",A[k]=F+"Date",A[h]=F+"Month",A[p]=F+"FullYear",A[l]=F+"Hours",A[c]=F+"Minutes",A[o]=F+"Seconds",A[a]=F+"Milliseconds",A)[R],K=R===u?this.$D+(I-this.$W):I;if(R===h||R===p){var te=this.clone().set(k,1);te.$d[Y](K),te.init(),this.$d=te.set(k,Math.min(this.$D,te.daysInMonth())).$d}else Y&&this.$d[Y](K);return this.init(),this},v.set=function(S,I){return this.clone().$set(S,I)},v.get=function(S){return this[O.p(S)]()},v.add=function(S,I){var A,R=this;S=Number(S);var F=O.p(I),Y=function(ae){var ue=g(R);return O.w(ue.date(ue.date()+Math.round(ae*S)),R)};if(F===h)return this.set(h,this.$M+S);if(F===p)return this.set(p,this.$y+S);if(F===u)return Y(1);if(F===f)return Y(7);var K=(A={},A[c]=n,A[l]=r,A[o]=s,A)[F]||1,te=this.$d.getTime()+S*K;return O.w(te,this)},v.subtract=function(S,I){return this.add(-1*S,I)},v.format=function(S){var I=this,A=this.$locale();if(!this.isValid())return A.invalidDate||j;var R=S||"YYYY-MM-DDTHH:mm:ssZ",F=O.z(this),Y=this.$H,K=this.$m,te=this.$M,ae=A.weekdays,ue=A.months,xe=A.meridiem,de=function(le,ie,Te,Oe){return le&&(le[ie]||le(I,R))||Te[ie].slice(0,Oe)},me=function(le){return O.s(Y%12||12,le,"0")},ge=xe||function(le,ie,Te){var Oe=le<12?"AM":"PM";return Te?Oe.toLowerCase():Oe};return R.replace(G,(function(le,ie){return ie||(function(Te){switch(Te){case"YY":return String(I.$y).slice(-2);case"YYYY":return O.s(I.$y,4,"0");case"M":return te+1;case"MM":return O.s(te+1,2,"0");case"MMM":return de(A.monthsShort,te,ue,3);case"MMMM":return de(ue,te);case"D":return I.$D;case"DD":return O.s(I.$D,2,"0");case"d":return String(I.$W);case"dd":return de(A.weekdaysMin,I.$W,ae,2);case"ddd":return de(A.weekdaysShort,I.$W,ae,3);case"dddd":return ae[I.$W];case"H":return String(Y);case"HH":return O.s(Y,2,"0");case"h":return me(1);case"hh":return me(2);case"a":return ge(Y,K,!0);case"A":return ge(Y,K,!1);case"m":return String(K);case"mm":return O.s(K,2,"0");case"s":return String(I.$s);case"ss":return O.s(I.$s,2,"0");case"SSS":return O.s(I.$ms,3,"0");case"Z":return F}return null})(le)||F.replace(":","")}))},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(S,I,A){var R,F=this,Y=O.p(I),K=g(S),te=(K.utcOffset()-this.utcOffset())*n,ae=this-K,ue=function(){return O.m(F,K)};switch(Y){case p:R=ue()/12;break;case h:R=ue();break;case x:R=ue()/3;break;case f:R=(ae-te)/6048e5;break;case u:R=(ae-te)/864e5;break;case l:R=ae/r;break;case c:R=ae/n;break;case o:R=ae/s;break;default:R=ae}return A?R:O.a(R)},v.daysInMonth=function(){return this.endOf(h).$D},v.$locale=function(){return B[this.$L]},v.locale=function(S,I){if(!S)return this.$L;var A=this.clone(),R=y(S,I,!0);return R&&(A.$L=R),A},v.clone=function(){return O.w(this.$d,this)},v.toDate=function(){return new Date(this.valueOf())},v.toJSON=function(){return this.isValid()?this.toISOString():null},v.toISOString=function(){return this.$d.toISOString()},v.toString=function(){return this.$d.toUTCString()},U})(),re=oe.prototype;return g.prototype=re,[["$ms",a],["$s",o],["$m",c],["$H",l],["$W",u],["$M",h],["$y",p],["$D",k]].forEach((function(U){re[U[1]]=function(v){return this.$g(v,U[0],U[1])}})),g.extend=function(U,v){return U.$i||(U(v,oe,g),U.$i=!0),g},g.locale=y,g.isDayjs=q,g.unix=function(U){return g(1e3*U)},g.en=B[D],g.Ls=B,g.p={},g}))})(Qt)),Qt.exports}var Ma=Ea();const Oa=ka(Ma);function Jn(t){if(!t)return"By Severity";const e=t.trim().toLowerCase();return e.includes("created")?"By Created Date":e.includes("updated")||e.includes("modified")?"By Updated Date":"By Severity"}function Kn(t){if(!t||typeof t!="string")return{hours:0,minutes:0,seconds:0};const e=t.split(":").map(a=>parseInt(a,10)),s=Number.isFinite(e[0])?e[0]:0,n=Number.isFinite(e[1])?e[1]:0,r=Number.isFinite(e[2])?e[2]:0;return{hours:s,minutes:n,seconds:r}}function fn(t){const{hours:e,minutes:s,seconds:n}=Kn(t);return Oa().hour(e).minute(s).second(n).millisecond(0)}function je(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function ja(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Zt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ce(t,e){const s={...e.headers,...ja()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const ce=(...t)=>t.find(e=>e!=null);function Ot(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function Ca(t){return Array.isArray(t)?t.map(e=>Ot(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Da(t){return{id:String(ce(t?.AlertId,t?.alertId)??""),alertNumber:ce(t?.AlertNumber,t?.alertNumber),priority:ce(t?.Priority,t?.priority,"Low"),timestamp:ce(t?.UpdatedUtc,t?.timestamp,""),statusType:ce(t?.Status,t?.statusType,""),description:ce(t?.Description,t?.description,""),eventName:ce(t?.EventName,t?.eventName),ruleName:ce(t?.RuleName,t?.ruleName),spaceId:ce(t?.SpaceId,t?.spaceId),spaceName:ce(t?.SpaceName,t?.spaceName),anomalyId:ce(t?.AnomalyId,t?.anomalyId),severityId:ce(t?.SeverityId,t?.severityId),assignTeam:ce(t?.AssignTeam,t?.assignTeam),cameraName:ce(t?.CameraName,t?.cameraName),type:ce(t?.Type,t?.type),mediaDetails:ce(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:ce(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:ce(t?.TimeElapsed,t?.timeElapsed),timeRemaining:ce(t?.TimeRemaining,t?.timeRemaining),anomalyName:ce(t?.AnomalyName,t?.anomalyName),alertDetails:ce(t?.AlertDetails,t?.alertDetails),statusHistory:Ca(ce(t?.StatusHistory,t?.statusHistory)),isEmailSent:ce(t?.IsEmailSent,t?.isEmailSent),isSMSSent:ce(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:ce(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Ra(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts"),r=Zt(n,{customerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",pageSize:s?.pageSize??10,page:s?.pageNumber??1,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{ThirdPartyIds:s.thirdPartyIds.join(",")},isArchived:s?.isArchived??!1}),a=await Ce(r,{method:"GET",headers:e});return{items:Array.isArray(a?.Items)?a.Items.map(Da):[],total:a?.Total}},async getAlertStatusList(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Ot(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=Zt(n,s),a=await Ce(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/Log"),r={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Ot(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:f,minutes:h,seconds:x}=Kn(u);return(f*3600+h*60+x)*1e7},a={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(u=>String(u)):[],DoNotDisturbStart:{Ticks:r(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:r(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},o=await Ce(n,{method:"POST",headers:e,body:JSON.stringify(a)}),c=o?.responseStatus??!0,l=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:c,errorMessage:c?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:l}},async sendSMSorEmailNotifications(s,n,r){const a=je(t.baseUrl,"/api/detectionpolicy/alerts/SendSMSorEmailNotifications"),o=Zt(a,{alertId:s,isEmail:n,isSMS:r});return Ce(o,{method:"POST",headers:e})},async getAlertNotifications(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=Zt(n,{alertId:s}),a=await Ce(r,{method:"GET",headers:e});let o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(c=>Ot(c,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=je(t.baseUrl,"/api/TimeZoneMaster"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Ot(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getAllSpaces(){const s=t.spacesBaseUrl||t.baseUrl,n=je(s,"/api/AllSpaces"),r=await Ce(n,{method:"GET",headers:e});return(Array.isArray(r?.Data)?r.Data:[]).map(o=>({spaceId:o?.SpaceId??o?.spaceId,spaceName:o?.SpaceName??o?.spaceName??""}))},async getMyAppPreferences(){const s=je(t.baseUrl,"/MyProfile"),n=await Ce(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=je(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await Ce(a,{method:"GET",headers:e});if(o&&typeof o=="object"){const c=o.data??o.Data??o,l=c?.timeZoneUniqueId??c?.TimeZoneUniqueId;if(l)return{timeZoneUniqueId:l}}return null}}}function Ua(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Je(t,e){const s={...e.headers,...Ua()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function La(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await Je(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n?.Data:[]).map(a=>({...a,ruleId:a.ruleId??a.RuleId,ruleName:a.ruleName??a.RuleName??a.Name,escalationSettings:a.escalationSettings??a.EscalationSettings}))},async setEscalationSettings(n){return Je(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=y=>new URL(y,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Je(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),Je(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,c,l,u,f,h]=await Promise.allSettled(a),x=y=>{if(y.status!=="fulfilled")return[];const g=y.value;return Array.isArray(g)?g:Array.isArray(g?.Data)?g.Data:Array.isArray(g?.data)?g.data:[]},p=x(o),k=x(c),j=x(l),M=x(u),G=x(f),L=h.status==="fulfilled"?h.value:null;let $=[];Array.isArray(L)?$=L:Array.isArray(L?.Data)?$=L.Data:Array.isArray(L?.data)&&($=L.data);const T=p.map(y=>({actionTypeId:Number(y?.ActionTypeId),name:y?.DisplayName??y?.Name??""})),D=k.map(y=>({recordId:y?.AnomalyId,anomalyName:y?.DisplayName??y?.Name??""})),B=j.map(y=>({thirdPartyId:Number(y?.ThirdPartyId),thirdPartyName:y?.ThirdPartyName??y?.Name??""})),C=$.map(y=>({userRoleId:y.UserRoleId??y.userRoleId??y.Id??y.id??0,userRoleName:y.UserRoleName??y.userRoleName??y.Name??y.name??""})),q={actionTypes:T,anomalies:D,thirdParties:B};return M.length&&(q.severities=M.map(y=>({severityId:y?.SeverityId??y?.severityId,severityName:y?.DisplayName??y?.SeverityName??y?.Name??y?.name??""}))),G.length&&(q.scheduleTypes=G),C.length&&(q.userRoles=C),q},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,Anomaly:c,Severity:l,...u}=r??{};return Je(a,{method:"PUT",headers:e,body:JSON.stringify({...u,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},AnomalyId:c?.AnomalyId,SeverityId:l?.SeverityId,EscalationSettings:o?{...o,ThirdPartyIds:o.thirdPartyId??[]}:{}})})}}}function Fa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function tt(t,e){const s={...e.headers,...Fa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function $a(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await tt(s,{method:"POST",headers:e,body:JSON.stringify({command:"get-all"})});return(Array.isArray(n?.data)?n.data:[]).map(a=>({...a,ruleId:a.RuleId??a.ruleId,ruleName:a.RuleName??a.ruleName,ruleDesc:a.RuleDesc??a.ruleDesc??null}))},async setEscalationSettings(n){return tt(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=C=>new URL(C,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[tt(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),tt(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),tt(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),tt(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),tt(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,c,l,u,f]=await Promise.allSettled(a),h=C=>{if(C.status!=="fulfilled")return[];const q=C.value;return Array.isArray(q)?q:Array.isArray(q?.data)?q.data:[]},x=h(o),p=h(c),k=h(l),j=h(u),M=f.status==="fulfilled"?f.value:null,G=x.map(C=>({actionTypeId:C?.ActionTypeUniqueId,name:C?.Name??""})),L=p.map(C=>({recordId:C?.AnomalyId,anomalyName:C?.DisplayName??C?.Name??""})),$=k.map(C=>({thirdPartyId:Number(C?.ThirdPartyId),thirdPartyName:C?.ThirdPartyName??C?.Name??""}));let T=[];Array.isArray(M)?T=M:Array.isArray(M?.Data)?T=M.Data:Array.isArray(M?.data)&&(T=M.data);const D=T.map(C=>({userRoleId:C.userRoleId??0,userRoleName:C.userRoleName??""})),B={actionTypes:G,anomalies:L,thirdParties:$};return j.length&&(B.severities=j.map(C=>({SeverityId:C.SeverityId,DisplayName:C.SeverityName??C.DisplayName??""}))),D.length&&(B.userRoles=D),B},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:c,ruleName:l,ruleDesc:u,...f}=r??{},h=o??{},x=(h.escalationSettingsActionTypeIds??[]).filter(k=>k!=null&&!Number.isNaN(k)),p={Level1UserRoleId:h.level1UserRoleId??0,Level1PostAssistTime:h.level1PostAssistTime??0,Level2UserRoleId:h.level2UserRoleId??0,Level2PostAssistTime:h.level2PostAssistTime??0,Level3UserRoleId:h.level3UserRoleId??0,Level3PostAssistTime:h.level3PostAssistTime??0,EscalationSettingsActionTypeIds:x,ThirdPartyIds:h.thirdPartyId??[],HumanLoop:h.humanLoop??!1};return tt(a,{method:"POST",headers:e,body:JSON.stringify({...f,RuleId:c??f.RuleId??n,RuleName:l??f.RuleName,RuleDesc:u??f.RuleDesc??null,ActionTypeUniqueIdList:x,EscalationSettings:p})})}}}function We(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Pa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function zt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ve(t,e){const s={...e.headers,...Pa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Wa(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=We(t.baseUrl,"/api/Alerts"),r=zt(n,{pageSize:s?.pageSize??10,pageNumber:s?.pageNumber??1}),a=await Ve(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async getAlertStatusList(){const s=We(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await Ve(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=We(t.baseUrl,"/Alerts/GetAlertsReport"),r=zt(n,s),a=await Ve(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=We(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return Ve(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=We(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await Ve(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=We(t.baseUrl,"/api/Alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Ve(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=We(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await Ve(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=We(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await Ve(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=We(t.baseUrl,"/api/Alerts/GetNotifications"),r=zt(n,{alertId:s}),a=await Ve(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async sendSMSorEmailNotifications(s,n,r){const a=We(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),o=zt(a,{alertId:s,isEmail:n,isSMS:r});return Ve(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=We(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Ve(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=We(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Ve(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}const Qn=m.createContext(null);function Xn({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,spacesBaseUrl:r,children:a}){const o=m.useMemo(()=>{const l=e?.alertsBaseUrl?.trim()||un[t]?.alerts||"";let u=e?.rulesBaseUrl?.trim()||un[t]?.rules||"";t==="snl"&&(u=l);const f=e?.headers;return{tenant:t,alertsBaseUrl:l,rulesBaseUrl:u,headers:f,timeZone:s,userManagementDomain:n,spacesBaseUrl:r}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n,r]),c=m.useMemo(()=>{const l={baseUrl:o.alertsBaseUrl,headers:o.headers},u={baseUrl:o.rulesBaseUrl,headers:o.headers},f={schools:()=>Ra({...l,spacesBaseUrl:o.spacesBaseUrl}),transit:()=>Wa(l),snl:()=>Ta(l)},h={schools:()=>La({...u,userManagementBaseUrl:o.userManagementDomain}),transit:()=>$a({...u,userManagementBaseUrl:o.userManagementDomain}),snl:()=>ba({baseUrl:o.alertsBaseUrl,headers:o.headers})};return{config:o,alerts:f[o.tenant](),rules:h[o.tenant]()}},[o]);return i.jsx(Qn.Provider,{value:c,children:a})}function Me(){const t=m.useContext(Qn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Va={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Ba={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Zs=6,zs=7;function hn(t,e,s){const n=t===Zs,r=t===zs,a=e.isEmailSent??!1,o=e.isSMSSent??!1,c=n&&a||r&&o,l=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&o?"SMS sent":l,f=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${l}`;return{isDisabled:c,buttonText:u,tooltipTitle:f}}function Za(t){const e=new Set;(t||[]).forEach(n=>{const r=n.anomalyName;typeof r=="string"&&r.trim().length>0&&e.add(r.trim())});const s=Array.from(e).map(n=>({label:n,value:n}));return[{label:"All Types",value:"All"},...s]}function za(t){const e=new Set;(t||[]).forEach(n=>{const r=n.spaceName;typeof r=="string"&&r.trim().length>0&&e.add(r.trim())});const s=Array.from(e).map(n=>({label:n,value:n}));return[{label:"All",value:"All"},...s]}function xs(t,e){return`${t}-${e?"email":"sms"}`}function Ht(t){return t===Zs||t===zs}function os({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(d.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const Ha=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function qa({value:t,onChange:e,options:s}){return i.jsx(os,{className:"w-[140px]",value:t,onChange:e,options:s||Ha})}const Ga=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function Ya({value:t,onChange:e,options:s}){return i.jsx(os,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||Ga})}function _a({value:t,onChange:e,options:s}){return i.jsx(os,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const Ja=[{label:"All",value:"All"},{label:"SOS",value:"SOS"},{label:"911",value:"911"},{label:"Aegix",value:"Aegix"},{label:"Eli",value:"Eli"},{label:"Skydio",value:"Skydio"}];function Ka({value:t,onChange:e,options:s}){return i.jsx(os,{className:"w-[130px]",value:t,onChange:e,options:s||Ja})}function er({columns:t,data:e,loading:s=!1,pageSize:n=10,total:r,currentPage:a,rowKey:o="id",toolbar:c,tableProps:l,onPageChange:u}){const f=r!==void 0;return i.jsxs("div",{children:[c,i.jsx(d.Table,{rowKey:o,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,...f?{total:r,current:a}:{},showSizeChanger:!1,showTotal:h=>`Total: ${h}`,onChange:u},bordered:!0,...l})]})}const tr=["completed","false positive","face doesn't match name","safe","supervised exit","elopement confirmed"];function Hs({data:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,columns:a,severityOptions:o,anomalyOptions:c,spaceOptions:l,renderActions:u,onAlertIdClick:f,onRefetch:h,onPageChange:x,onFilterChange:p,excludeCompleted:k=!0,resetKey:j,serverSideFilters:M=!1}){const[G,L]=m.useState("All"),[$,T]=m.useState("All"),[D,B]=m.useState("All"),[C,q]=m.useState("All"),[y,g]=m.useState("");m.useEffect(()=>{j!==void 0&&(L("All"),T("All"),B("All"),q("All"),g(""))},[j]);const[O,oe]=m.useState([{label:"All",value:"All"}]),[re,U]=m.useState([]),[v,S]=m.useState([]),[I,A]=m.useState([]),[R,F]=m.useState(new Set),{rules:Y,alerts:K}=Me(),te={6:{title:"Email",kind:"icon",icon:i.jsx(ct.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(ct.MessageOutlined,{})}},ae=m.useMemo(()=>Za(t),[t]),ue=m.useMemo(()=>za(t),[t]);m.useEffect(()=>{if(!K.getAllSpaces)return;let ne=!0;return(async()=>{try{const Z=await K.getAllSpaces();if(ne){const ve=Z.map(fe=>({label:fe.spaceName,value:String(fe.spaceId)}));U([{label:"All",value:"All"},...ve])}}catch(Z){console.error("Error loading space options",Z)}})(),()=>{ne=!1}},[K]),m.useEffect(()=>{let ne=!0;return(async()=>{try{const Z=await Y.getLookups(),fe=(Array.isArray(Z.thirdParties)?Z.thirdParties:[]).map(we=>({label:we.thirdPartyName,value:String(we.thirdPartyId)})),De=(Array.isArray(Z.anomalies)?Z.anomalies:[]).map(we=>({label:we.anomalyName,value:String(we.recordId)})),Pe=(Array.isArray(Z.severities)?Z.severities:[]).map(we=>({label:we.severityName,value:String(we.severityId)}));ne&&(oe([{label:"All",value:"All"},...fe]),De.length&&S([{label:"All Types",value:"All"},...De]),Pe.length&&A([{label:"All levels",value:"All"},...Pe]))}catch(Z){console.error("Error loading filter options",Z)}})(),()=>{ne=!1}},[Y]);const xe=m.useMemo(()=>(t||[]).some(ne=>cn(ne).length>0),[t]);m.useEffect(()=>{if(M&&p){const ne={anomalyId:v.length>1&&$!=="All"?$:void 0,spaceId:re.length>1&&D!=="All"?Number(D):void 0,severityId:I.length>1&&G!=="All"?Number(G):void 0,thirdPartyIds:C==="All"?void 0:[Number(C)]};p(ne)}x?.(1)},[$,D,G,C,v.length,re.length,I.length]);const de=m.useMemo(()=>{const ne=M;return(t||[]).filter(Z=>{const ve=ne||G==="All"||Z.priority===G,fe=`${Z.id} ${Z.description} ${Z.statusType}`.toLowerCase(),Ne=!y||fe.includes(y.toLowerCase()),De=ne||$==="All"||(Z.anomalyName||"").toLowerCase()===$.toLowerCase(),$e=ne||D==="All"||(Z.spaceName||"").toLowerCase()===D.toLowerCase(),Pe=ne||!xe||C==="All"||cn(Z).includes(Number(C)),we=String(Z.statusType||"").toLowerCase(),Re=!k||!tr.some(et=>we.includes(et));return ve&&Ne&&De&&$e&&Pe&&Re})},[t,G,y,$,D,C,xe,k,M]),me=c?.length?c:ae,ge=M&&v.length>1?v:me,le=l?.length?l:ue,ie=M&&re.length>1?re:le,Te=M&&I.length>1?I:o,Oe=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:ne=>i.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ba[ne]}`,backgroundColor:Va[ne]},children:ne})},{title:"Tracker",key:"tracker",width:140,render:(ne,Z)=>i.jsx("a",{onClick:ve=>{ve.preventDefault(),f?.(Z,{tab:"track",sourceTab:"active"})},className:"text-blue-600 hover:underline",children:"Tracker"})},{title:"Call to action/Human in the loop",key:"actions",width:320,render:(ne,Z)=>{if(u)return i.jsx(i.Fragment,{children:u(Z)});const ve=async(ht,Et)=>{const yt=xs(Z.id,ht);F(he=>new Set(he).add(yt));try{const he=await K.sendSMSorEmailNotifications?.(Z.id,ht,Et);he?.responseStatus||he?.Success||he?.success?(Ae.toast.success(he?.message||he.data||(ht?"Email sent successfully":"SMS sent successfully")),h?.()):Ae.toast.error(he?.message||he?.data||he?.errorMessage||"Failed to send notification")}catch(he){Ae.toast.error(he?.message||"Failed to send notification")}finally{F(he=>{const pt=new Set(he);return pt.delete(yt),pt})}},fe=Zs,Ne=zs,De=te[fe],$e=te[Ne],Pe=hn(fe,Z,De?.title),we=hn(Ne,Z,$e?.title),Re=xs(Z.id,!0),et=xs(Z.id,!1),mt=Ht(fe)&&R.has(Re),ft=Ht(Ne)&&R.has(et);return i.jsxs(d.Space,{size:"middle",children:[i.jsx(d.Tooltip,{title:Pe.tooltipTitle,children:i.jsx(d.Button,{size:"small",disabled:Pe.isDisabled,loading:mt,onClick:Ht(fe)?()=>ve(!0,!1):void 0,icon:!mt&&De?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Pe.buttonText})},String(fe)),i.jsx(d.Tooltip,{title:we.tooltipTitle,children:i.jsx(d.Button,{size:"small",disabled:we.isDisabled,loading:ft,onClick:Ht(Ne)?()=>ve(!1,!0):void 0,icon:!ft&&$e?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:we.buttonText})},String(Ne))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(ne,Z)=>{const ve=Z?.timeElapsed,fe=Z?.timeRemaining,Ne=ve?ln(ve):0,De=fe?ln(fe):0,$e=Math.round(Ne/(Ne+De)*100);return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),i.jsx("span",{className:"font-medium",children:ve??"-"})]}),i.jsx(d.Progress,{percent:$e,showInfo:!1,size:"small",strokeColor:pa(Z.priority)}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Remaining"}),i.jsx("span",{className:"font-medium",children:fe??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(ne,Z)=>i.jsxs("div",{children:[i.jsx("a",{onClick:ve=>{ve.preventDefault(),f?.(Z,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:Z.alertNumber}),i.jsx("div",{className:"text-black/65",children:ne})]})}],He=a&&a.length?a:Oe;return i.jsx("div",{children:i.jsx(er,{rowKey:"id",data:de,columns:He,loading:e,pageSize:s,total:n,currentPage:r,onPageChange:x,toolbar:i.jsxs(d.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(qa,{value:G,onChange:L,options:Te})]})}),i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(Ya,{value:$,onChange:T,options:ge})]})}),i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Space"}),i.jsx(_a,{value:D,onChange:B,options:ie})]})}),i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(Ka,{value:C,onChange:q,options:O})]})}),i.jsx(d.Col,{flex:"auto"}),i.jsx(d.Col,{flex:"none",children:i.jsx(d.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:g,onChange:ne=>g(ne.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function qs(){const{alerts:t}=Me(),e=ut.useQueryClient();return ut.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class dt extends Error{}class Qa extends dt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class Xa extends dt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class ei extends dt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class vt extends dt{}class sr extends dt{constructor(e){super(`Invalid unit ${e}`)}}class be extends dt{}class st extends dt{constructor(){super("Zone is an abstract class")}}const N="numeric",_e="short",Fe="long",ss={year:N,month:N,day:N},nr={year:N,month:_e,day:N},ti={year:N,month:_e,day:N,weekday:_e},rr={year:N,month:Fe,day:N},ar={year:N,month:Fe,day:N,weekday:Fe},ir={hour:N,minute:N},or={hour:N,minute:N,second:N},lr={hour:N,minute:N,second:N,timeZoneName:_e},cr={hour:N,minute:N,second:N,timeZoneName:Fe},ur={hour:N,minute:N,hourCycle:"h23"},dr={hour:N,minute:N,second:N,hourCycle:"h23"},mr={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:_e},fr={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:Fe},hr={year:N,month:N,day:N,hour:N,minute:N},yr={year:N,month:N,day:N,hour:N,minute:N,second:N},pr={year:N,month:_e,day:N,hour:N,minute:N},gr={year:N,month:_e,day:N,hour:N,minute:N,second:N},si={year:N,month:_e,day:N,weekday:_e,hour:N,minute:N},Sr={year:N,month:Fe,day:N,hour:N,minute:N,timeZoneName:_e},xr={year:N,month:Fe,day:N,hour:N,minute:N,second:N,timeZoneName:_e},vr={year:N,month:Fe,day:N,weekday:Fe,hour:N,minute:N,timeZoneName:Fe},wr={year:N,month:Fe,day:N,weekday:Fe,hour:N,minute:N,second:N,timeZoneName:Fe};class Lt{get type(){throw new st}get name(){throw new st}get ianaName(){return this.name}get isUniversal(){throw new st}offsetName(e,s){throw new st}formatOffset(e,s){throw new st}offset(e){throw new st}equals(e){throw new st}get isValid(){throw new st}}let vs=null;class ls extends Lt{static get instance(){return vs===null&&(vs=new ls),vs}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Cr(e,s,n)}formatOffset(e,s){return Rt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const js=new Map;function ni(t){let e=js.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),js.set(t,e)),e}const ri={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ai(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,c,l,u,f]=n;return[o,r,a,c,l,u,f]}function ii(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],c=ri[a];a==="era"?n[c]=o:V(c)||(n[c]=parseInt(o,10))}return n}const ws=new Map;class Xe extends Lt{static create(e){let s=ws.get(e);return s===void 0&&ws.set(e,s=new Xe(e)),s}static resetCache(){ws.clear(),js.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=Xe.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Cr(e,s,n,this.name)}formatOffset(e,s){return Rt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=ni(this.name);let[r,a,o,c,l,u,f]=n.formatToParts?ii(n,s):ai(n,s);c==="BC"&&(r=-Math.abs(r)+1);const x=us({year:r,month:a,day:o,hour:l===24?0:l,minute:u,second:f,millisecond:0});let p=+s;const k=p%1e3;return p-=k>=0?k:1e3+k,(x-p)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let yn={};function oi(t,e={}){const s=JSON.stringify([t,e]);let n=yn[s];return n||(n=new Intl.ListFormat(t,e),yn[s]=n),n}const Cs=new Map;function Ds(t,e={}){const s=JSON.stringify([t,e]);let n=Cs.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Cs.set(s,n)),n}const Rs=new Map;function li(t,e={}){const s=JSON.stringify([t,e]);let n=Rs.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Rs.set(s,n)),n}const Us=new Map;function ci(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Us.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Us.set(r,a)),a}let jt=null;function ui(){return jt||(jt=new Intl.DateTimeFormat().resolvedOptions().locale,jt)}const Ls=new Map;function Ar(t){let e=Ls.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Ls.set(t,e)),e}const Fs=new Map;function di(t){let e=Fs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...Tr,...e}),Fs.set(t,e)}return e}function mi(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=Ds(t).resolvedOptions(),r=t}catch{const l=t.substring(0,s);n=Ds(l).resolvedOptions(),r=l}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function fi(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function hi(t){const e=[];for(let s=1;s<=12;s++){const n=W.utc(2009,s,1);e.push(t(n))}return e}function yi(t){const e=[];for(let s=1;s<=7;s++){const n=W.utc(2016,11,13+s);e.push(t(n))}return e}function qt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function pi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Ar(t.locale).numberingSystem==="latn"}class gi{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:a,...o}=n;if(!s||Object.keys(o).length>0){const c={useGrouping:!1,...n};n.padTo>0&&(c.minimumIntegerDigits=n.padTo),this.inf=li(e,c)}}format(e){if(this.inf){const s=this.floor?Math.floor(e):e;return this.inf.format(s)}else{const s=this.floor?Math.floor(e):Ks(e,3);return Se(s,this.padTo)}}}class Si{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),c=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&Xe.create(c).valid?(r=c,this.dt=e):(r="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=Ds(s,a)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(s=>{if(s.type==="timeZoneName"){const n=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...s,value:n}}else return s}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class xi{constructor(e,s,n){this.opts={style:"long",...n},!s&&Or()&&(this.rtf=ci(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):Vi(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const Tr={firstDay:1,minimalDays:4,weekend:[6,7]};class se{static fromOpts(e){return se.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||pe.defaultLocale,c=o||(a?"en-US":ui()),l=s||pe.defaultNumberingSystem,u=n||pe.defaultOutputCalendar,f=Ps(r)||pe.defaultWeekSettings;return new se(c,l,u,f,o)}static resetCache(){jt=null,Cs.clear(),Rs.clear(),Us.clear(),Ls.clear(),Fs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return se.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,c,l]=mi(e);this.locale=o,this.numberingSystem=s||c||null,this.outputCalendar=n||l||null,this.weekSettings=r,this.intl=fi(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=a,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=pi(this)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),s=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&s?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:se.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Ps(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,s=!1){return qt(this,e,Ur,()=>{const n=this.intl==="ja"||this.intl.startsWith("ja-");s&=!n;const r=s?{month:e,day:"numeric"}:{month:e},a=s?"format":"standalone";if(!this.monthsCache[a][e]){const o=n?c=>this.dtFormatter(c,r).format():c=>this.extract(c,r,"month");this.monthsCache[a][e]=hi(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return qt(this,e,$r,()=>{const n=s?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=s?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=yi(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return qt(this,void 0,()=>Pr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[W.utc(2016,11,13,9),W.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return qt(this,e,Wr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[W.utc(-40,1,1),W.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),a=r.formatToParts(),o=a.find(c=>c.type.toLowerCase()===n);return o?o.value:null}numberFormatter(e={}){return new gi(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new Si(e,this.intl,s)}relFormatter(e={}){return new xi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return oi(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Ar(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:jr()?di(this.locale):Tr}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let As=null;class Ee extends Lt{static get utcInstance(){return As===null&&(As=new Ee(0)),As}static instance(e){return e===0?Ee.utcInstance:new Ee(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Ee(ds(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Rt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Rt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Rt(this.fixed,s)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}}class vi extends Lt{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function rt(t,e){if(V(t)||t===null)return e;if(t instanceof Lt)return t;if(ki(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?ls.instance:s==="utc"||s==="gmt"?Ee.utcInstance:Ee.parseSpecifier(s)||Xe.create(t)}else return at(t)?Ee.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new vi(t)}const Gs={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},pn={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},wi=Gs.hanidec.replace(/[\[|\]]/g,"").split("");function Ai(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let s=0;s<t.length;s++){const n=t.charCodeAt(s);if(t[s].search(Gs.hanidec)!==-1)e+=wi.indexOf(t[s]);else for(const r in pn){const[a,o]=pn[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const $s=new Map;function Ti(){$s.clear()}function qe({numberingSystem:t},e=""){const s=t||"latn";let n=$s.get(s);n===void 0&&(n=new Map,$s.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Gs[s]}${e}`),n.set(e,r)),r}let gn=()=>Date.now(),Sn="system",xn=null,vn=null,wn=null,An=60,Tn,Nn=null;class pe{static get now(){return gn}static set now(e){gn=e}static set defaultZone(e){Sn=e}static get defaultZone(){return rt(Sn,ls.instance)}static get defaultLocale(){return xn}static set defaultLocale(e){xn=e}static get defaultNumberingSystem(){return vn}static set defaultNumberingSystem(e){vn=e}static get defaultOutputCalendar(){return wn}static set defaultOutputCalendar(e){wn=e}static get defaultWeekSettings(){return Nn}static set defaultWeekSettings(e){Nn=Ps(e)}static get twoDigitCutoffYear(){return An}static set twoDigitCutoffYear(e){An=e%100}static get throwOnInvalid(){return Tn}static set throwOnInvalid(e){Tn=e}static resetCaches(){se.resetCache(),Xe.resetCache(),W.resetCache(),Ti()}}class Ye{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Nr=[0,31,59,90,120,151,181,212,243,273,304,334],br=[0,31,60,91,121,152,182,213,244,274,305,335];function Ze(t,e){return new Ye("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Ys(t,e,s){const n=new Date(Date.UTC(t,e-1,s));t<100&&t>=0&&n.setUTCFullYear(n.getUTCFullYear()-1900);const r=n.getUTCDay();return r===0?7:r}function kr(t,e,s){return s+(Ft(t)?br:Nr)[e-1]}function Ir(t,e){const s=Ft(t)?br:Nr,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function _s(t,e){return(t-e+7)%7+1}function ns(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=kr(n,r,a),c=_s(Ys(n,r,a),s);let l=Math.floor((o-c+14-e)/7),u;return l<1?(u=n-1,l=Ut(u,e,s)):l>Ut(n,e,s)?(u=n+1,l=1):u=n,{weekYear:u,weekNumber:l,weekday:c,...ms(t)}}function bn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=_s(Ys(n,1,e),s),c=wt(n);let l=r*7+a-o-7+e,u;l<1?(u=n-1,l+=wt(u)):l>c?(u=n+1,l-=wt(n)):u=n;const{month:f,day:h}=Ir(u,l);return{year:u,month:f,day:h,...ms(t)}}function Ts(t){const{year:e,month:s,day:n}=t,r=kr(e,s,n);return{year:e,ordinal:r,...ms(t)}}function kn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=Ir(e,s);return{year:e,month:n,day:r,...ms(t)}}function In(t,e){if(!V(t.localWeekday)||!V(t.localWeekNumber)||!V(t.localWeekYear)){if(!V(t.weekday)||!V(t.weekNumber)||!V(t.weekYear))throw new vt("Cannot mix locale-based week fields with ISO-based week fields");return V(t.localWeekday)||(t.weekday=t.localWeekday),V(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),V(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function Ni(t,e=4,s=1){const n=cs(t.weekYear),r=ze(t.weekNumber,1,Ut(t.weekYear,e,s)),a=ze(t.weekday,1,7);return n?r?a?!1:Ze("weekday",t.weekday):Ze("week",t.weekNumber):Ze("weekYear",t.weekYear)}function bi(t){const e=cs(t.year),s=ze(t.ordinal,1,wt(t.year));return e?s?!1:Ze("ordinal",t.ordinal):Ze("year",t.year)}function Er(t){const e=cs(t.year),s=ze(t.month,1,12),n=ze(t.day,1,rs(t.year,t.month));return e?s?n?!1:Ze("day",t.day):Ze("month",t.month):Ze("year",t.year)}function Mr(t){const{hour:e,minute:s,second:n,millisecond:r}=t,a=ze(e,0,23)||e===24&&s===0&&n===0&&r===0,o=ze(s,0,59),c=ze(n,0,59),l=ze(r,0,999);return a?o?c?l?!1:Ze("millisecond",r):Ze("second",n):Ze("minute",s):Ze("hour",e)}function V(t){return typeof t>"u"}function at(t){return typeof t=="number"}function cs(t){return typeof t=="number"&&t%1===0}function ki(t){return typeof t=="string"}function Ii(t){return Object.prototype.toString.call(t)==="[object Date]"}function Or(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function jr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Ei(t){return Array.isArray(t)?t:[t]}function En(t,e,s){if(t.length!==0)return t.reduce((n,r)=>{const a=[e(r),r];return n&&s(n[0],a[0])===n[0]?n:a},null)[1]}function Mi(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function Tt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Ps(t){if(t==null)return null;if(typeof t!="object")throw new be("Week settings must be an object");if(!ze(t.firstDay,1,7)||!ze(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!ze(e,1,7)))throw new be("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function ze(t,e,s){return cs(t)&&t>=e&&t<=s}function Oi(t,e){return t-e*Math.floor(t/e)}function Se(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function nt(t){if(!(V(t)||t===null||t===""))return parseInt(t,10)}function it(t){if(!(V(t)||t===null||t===""))return parseFloat(t)}function Js(t){if(!(V(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function Ks(t,e,s="round"){const n=10**e;switch(s){case"expand":return t>0?Math.ceil(t*n)/n:Math.floor(t*n)/n;case"trunc":return Math.trunc(t*n)/n;case"round":return Math.round(t*n)/n;case"floor":return Math.floor(t*n)/n;case"ceil":return Math.ceil(t*n)/n;default:throw new RangeError(`Value rounding ${s} is out of range`)}}function Ft(t){return t%4===0&&(t%100!==0||t%400===0)}function wt(t){return Ft(t)?366:365}function rs(t,e){const s=Oi(e-1,12)+1,n=t+(e-s)/12;return s===2?Ft(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function us(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function Mn(t,e,s){return-_s(Ys(t,1,e),s)+e-1}function Ut(t,e=4,s=1){const n=Mn(t,e,s),r=Mn(t+1,e,s);return(wt(t)-n+r)/7}function Ws(t){return t>99?t:t>pe.twoDigitCutoffYear?1900+t:2e3+t}function Cr(t,e,s,n=null){const r=new Date(t),a={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};n&&(a.timeZone=n);const o={timeZoneName:e,...a},c=new Intl.DateTimeFormat(s,o).formatToParts(r).find(l=>l.type.toLowerCase()==="timezonename");return c?c.value:null}function ds(t,e){let s=parseInt(t,10);Number.isNaN(s)&&(s=0);const n=parseInt(e,10)||0,r=s<0||Object.is(s,-0)?-n:n;return s*60+r}function Dr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new be(`Invalid unit value ${t}`);return e}function as(t,e){const s={};for(const n in t)if(Tt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=Dr(r)}return s}function Rt(t,e){const s=Math.trunc(Math.abs(t/60)),n=Math.trunc(Math.abs(t%60)),r=t>=0?"+":"-";switch(e){case"short":return`${r}${Se(s,2)}:${Se(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${Se(s,2)}${Se(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function ms(t){return Mi(t,["hour","minute","second","millisecond"])}const ji=["January","February","March","April","May","June","July","August","September","October","November","December"],Rr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ci=["J","F","M","A","M","J","J","A","S","O","N","D"];function Ur(t){switch(t){case"narrow":return[...Ci];case"short":return[...Rr];case"long":return[...ji];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const Lr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Fr=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Di=["M","T","W","T","F","S","S"];function $r(t){switch(t){case"narrow":return[...Di];case"short":return[...Fr];case"long":return[...Lr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Pr=["AM","PM"],Ri=["Before Christ","Anno Domini"],Ui=["BC","AD"],Li=["B","A"];function Wr(t){switch(t){case"narrow":return[...Li];case"short":return[...Ui];case"long":return[...Ri];default:return null}}function Fi(t){return Pr[t.hour<12?0:1]}function $i(t,e){return $r(e)[t.weekday-1]}function Pi(t,e){return Ur(e)[t.month-1]}function Wi(t,e){return Wr(e)[t.year<0?0:1]}function Vi(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const h=t==="days";switch(e){case 1:return h?"tomorrow":`next ${r[t][0]}`;case-1:return h?"yesterday":`last ${r[t][0]}`;case 0:return h?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,c=Math.abs(e),l=c===1,u=r[t],f=n?l?u[1]:u[2]||u[1]:l?r[t][0]:t;return o?`${c} ${f} ago`:`in ${c} ${f}`}function On(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const Bi={D:ss,DD:nr,DDD:rr,DDDD:ar,t:ir,tt:or,ttt:lr,tttt:cr,T:ur,TT:dr,TTT:mr,TTTT:fr,f:hr,ff:pr,fff:Sr,ffff:vr,F:yr,FF:gr,FFF:xr,FFFF:wr};class ke{static create(e,s={}){return new ke(e,s)}static parseFormat(e){let s=null,n="",r=!1;const a=[];for(let o=0;o<e.length;o++){const c=e.charAt(o);c==="'"?((n.length>0||r)&&a.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||c===s?n+=c:(n.length>0&&a.push({literal:/^\s+$/.test(n),val:n}),n=c,s=c)}return n.length>0&&a.push({literal:r||/^\s+$/.test(n),val:n}),a}static macroTokenToFormatOpts(e){return Bi[e]}constructor(e,s){this.opts=s,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,s){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...s}).format()}dtFormatter(e,s={}){return this.loc.dtFormatter(e,{...this.opts,...s})}formatDateTime(e,s){return this.dtFormatter(e,s).format()}formatDateTimeParts(e,s){return this.dtFormatter(e,s).formatToParts()}formatInterval(e,s){return this.dtFormatter(e.start,s).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,s){return this.dtFormatter(e,s).resolvedOptions()}num(e,s=0,n=void 0){if(this.opts.forceSimple)return Se(e,s);const r={...this.opts};return s>0&&(r.padTo=s),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,s){const n=this.loc.listingMode()==="en",r=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",a=(p,k)=>this.loc.extract(e,p,k),o=p=>e.isOffsetFixed&&e.offset===0&&p.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,p.format):"",c=()=>n?Fi(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(p,k)=>n?Pi(e,p):a(k?{month:p}:{month:p,day:"numeric"},"month"),u=(p,k)=>n?$i(e,p):a(k?{weekday:p}:{weekday:p,month:"long",day:"numeric"},"weekday"),f=p=>{const k=ke.macroTokenToFormatOpts(p);return k?this.formatWithSystemDefault(e,k):p},h=p=>n?Wi(e,p):a({era:p},"era"),x=p=>{switch(p){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return c();case"d":return r?a({day:"numeric"},"day"):this.num(e.day);case"dd":return r?a({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return r?a({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?a({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("narrow",!0);case"M":return r?a({month:"numeric"},"month"):this.num(e.month);case"MM":return r?a({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("narrow",!1);case"y":return r?a({year:"numeric"},"year"):this.num(e.year);case"yy":return r?a({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?a({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?a({year:"numeric"},"year"):this.num(e.year,6);case"G":return h("short");case"GG":return h("long");case"GGGGG":return h("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return f(p)}};return On(ke.parseFormat(s),x)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=f=>{switch(f[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},a=(f,h)=>x=>{const p=r(x);if(p){const k=h.isNegativeDuration&&p!==h.largestUnit?n:1;let j;return this.opts.signMode==="negativeLargestOnly"&&p!==h.largestUnit?j="never":this.opts.signMode==="all"?j="always":j="auto",this.num(f.get(p)*k,x.length,j)}else return x},o=ke.parseFormat(s),c=o.reduce((f,{literal:h,val:x})=>h?f:f.concat(x),[]),l=e.shiftTo(...c.map(r).filter(f=>f)),u={isNegativeDuration:l<0,largestUnit:Object.keys(l.values)[0]};return On(o,a(l,u))}}const Vr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Nt(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function bt(...t){return e=>t.reduce(([s,n,r],a)=>{const[o,c,l]=a(e,r);return[{...s,...o},c||n,l]},[{},null,1]).slice(0,2)}function kt(t,...e){if(t==null)return[null,null];for(const[s,n]of e){const r=s.exec(t);if(r)return n(r)}return[null,null]}function Br(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=nt(e[s+r]);return[n,null,s+r]}}const Zr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Zi=`(?:${Zr.source}?(?:\\[(${Vr.source})\\])?)?`,Qs=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,zr=RegExp(`${Qs.source}${Zi}`),Xs=RegExp(`(?:[Tt]${zr.source})?`),zi=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Hi=/(\d{4})-?W(\d\d)(?:-?(\d))?/,qi=/(\d{4})-?(\d{3})/,Gi=Br("weekYear","weekNumber","weekDay"),Yi=Br("year","ordinal"),_i=/(\d{4})-(\d\d)-(\d\d)/,Hr=RegExp(`${Qs.source} ?(?:${Zr.source}|(${Vr.source}))?`),Ji=RegExp(`(?: ${Hr.source})?`);function At(t,e,s){const n=t[e];return V(n)?s:nt(n)}function Ki(t,e){return[{year:At(t,e),month:At(t,e+1,1),day:At(t,e+2,1)},null,e+3]}function It(t,e){return[{hours:At(t,e,0),minutes:At(t,e+1,0),seconds:At(t,e+2,0),milliseconds:Js(t[e+3])},null,e+4]}function $t(t,e){const s=!t[e]&&!t[e+1],n=ds(t[e+1],t[e+2]),r=s?null:Ee.instance(n);return[{},r,e+3]}function Pt(t,e){const s=t[e]?Xe.create(t[e]):null;return[{},s,e+1]}const Qi=RegExp(`^T?${Qs.source}$`),Xi=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function eo(t){const[e,s,n,r,a,o,c,l,u]=t,f=e[0]==="-",h=l&&l[0]==="-",x=(p,k=!1)=>p!==void 0&&(k||p&&f)?-p:p;return[{years:x(it(s)),months:x(it(n)),weeks:x(it(r)),days:x(it(a)),hours:x(it(o)),minutes:x(it(c)),seconds:x(it(l),l==="-0"),milliseconds:x(Js(u),h)}]}const to={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function en(t,e,s,n,r,a,o){const c={year:e.length===2?Ws(nt(e)):nt(e),month:Rr.indexOf(s)+1,day:nt(n),hour:nt(r),minute:nt(a)};return o&&(c.second=nt(o)),t&&(c.weekday=t.length>3?Lr.indexOf(t)+1:Fr.indexOf(t)+1),c}const so=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function no(t){const[,e,s,n,r,a,o,c,l,u,f,h]=t,x=en(e,r,n,s,a,o,c);let p;return l?p=to[l]:u?p=0:p=ds(f,h),[x,new Ee(p)]}function ro(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const ao=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,io=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,oo=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function jn(t){const[,e,s,n,r,a,o,c]=t;return[en(e,r,n,s,a,o,c),Ee.utcInstance]}function lo(t){const[,e,s,n,r,a,o,c]=t;return[en(e,c,s,n,r,a,o),Ee.utcInstance]}const co=Nt(zi,Xs),uo=Nt(Hi,Xs),mo=Nt(qi,Xs),fo=Nt(zr),qr=bt(Ki,It,$t,Pt),ho=bt(Gi,It,$t,Pt),yo=bt(Yi,It,$t,Pt),po=bt(It,$t,Pt);function go(t){return kt(t,[co,qr],[uo,ho],[mo,yo],[fo,po])}function So(t){return kt(ro(t),[so,no])}function xo(t){return kt(t,[ao,jn],[io,jn],[oo,lo])}function vo(t){return kt(t,[Xi,eo])}const wo=bt(It);function Ao(t){return kt(t,[Qi,wo])}const To=Nt(_i,Ji),No=Nt(Hr),bo=bt(It,$t,Pt);function ko(t){return kt(t,[To,qr],[No,bo])}const Cn="Invalid Duration",Gr={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Io={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...Gr},Be=146097/400,gt=146097/4800,Eo={years:{quarters:4,months:12,weeks:Be/7,days:Be,hours:Be*24,minutes:Be*24*60,seconds:Be*24*60*60,milliseconds:Be*24*60*60*1e3},quarters:{months:3,weeks:Be/28,days:Be/4,hours:Be*24/4,minutes:Be*24*60/4,seconds:Be*24*60*60/4,milliseconds:Be*24*60*60*1e3/4},months:{weeks:gt/7,days:gt,hours:gt*24,minutes:gt*24*60,seconds:gt*24*60*60,milliseconds:gt*24*60*60*1e3},...Gr},lt=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Mo=lt.slice(0).reverse();function Ke(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new X(n)}function Yr(t,e){let s=e.milliseconds??0;for(const n of Mo.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Dn(t,e){const s=Yr(t,e)<0?-1:1;lt.reduceRight((n,r)=>{if(V(e[r]))return n;if(n){const a=e[n]*s,o=t[r][n],c=Math.floor(a/o);e[r]+=c*s,e[n]-=c*o*s}return r},null),lt.reduce((n,r)=>{if(V(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function Rn(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class X{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?Eo:Io;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||se.create(),this.conversionAccuracy=s?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,s){return X.fromObject({milliseconds:e},s)}static fromObject(e,s={}){if(e==null||typeof e!="object")throw new be(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new X({values:as(e,X.normalizeUnit),loc:se.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(at(e))return X.fromMillis(e);if(X.isDuration(e))return e;if(typeof e=="object")return X.fromObject(e);throw new be(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=vo(e);return n?X.fromObject(n,s):X.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=Ao(e);return n?X.fromObject(n,s):X.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new be("need to specify a reason the Duration is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(pe.throwOnInvalid)throw new ei(n);return new X({invalid:n})}static normalizeUnit(e){const s={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!s)throw new sr(e);return s}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,s={}){const n={...s,floor:s.round!==!1&&s.floor!==!1};return this.isValid?ke.create(this.loc,n).formatDurationFromString(this,e):Cn}toHuman(e={}){if(!this.isValid)return Cn;const s=e.showZeros!==!1,n=lt.map(r=>{const a=this.values[r];return V(a)||a===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(a)}).filter(r=>r);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=Ks(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const s=this.toMillis();return s<0||s>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},W.fromMillis(s,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?Yr(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e),n={};for(const r of lt)(Tt(s.values,r)||Tt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Ke(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e);return this.plus(s.negate())}mapUnits(e){if(!this.isValid)return this;const s={};for(const n of Object.keys(this.values))s[n]=Dr(e(this.values[n],n));return Ke(this,{values:s},!0)}get(e){return this[X.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...as(e,X.normalizeUnit)};return Ke(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const o={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return Ke(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Dn(this.matrix,e),Ke(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=Rn(this.normalize().shiftToAll().toObject());return Ke(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>X.normalizeUnit(o));const s={},n={},r=this.toObject();let a;for(const o of lt)if(e.indexOf(o)>=0){a=o;let c=0;for(const u in n)c+=this.matrix[u][o]*n[u],n[u]=0;at(r[o])&&(c+=r[o]);const l=Math.trunc(c);s[o]=l,n[o]=(c*1e3-l*1e3)/1e3}else at(r[o])&&(n[o]=r[o]);for(const o in n)n[o]!==0&&(s[a]+=o===a?n[o]:n[o]/this.matrix[a][o]);return Dn(this.matrix,s),Ke(this,{values:s},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const s of Object.keys(this.values))e[s]=this.values[s]===0?0:-this.values[s];return Ke(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=Rn(this.values);return Ke(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function s(n,r){return n===void 0||n===0?r===void 0||r===0:n===r}for(const n of lt)if(!s(this.values[n],e.values[n]))return!1;return!0}}const St="Invalid Interval";function Oo(t,e){return!t||!t.isValid?ye.invalid("missing or invalid start"):!e||!e.isValid?ye.invalid("missing or invalid end"):e<t?ye.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}class ye{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,s=null){if(!e)throw new be("need to specify a reason the Interval is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(pe.throwOnInvalid)throw new Xa(n);return new ye({invalid:n})}static fromDateTimes(e,s){const n=Mt(e),r=Mt(s),a=Oo(n,r);return a??new ye({start:n,end:r})}static after(e,s){const n=X.fromDurationLike(s),r=Mt(e);return ye.fromDateTimes(r,r.plus(n))}static before(e,s){const n=X.fromDurationLike(s),r=Mt(e);return ye.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=W.fromISO(n,s),o=a.isValid}catch{o=!1}let c,l;try{c=W.fromISO(r,s),l=c.isValid}catch{l=!1}if(o&&l)return ye.fromDateTimes(a,c);if(o){const u=X.fromISO(r,s);if(u.isValid)return ye.after(a,u)}else if(l){const u=X.fromISO(n,s);if(u.isValid)return ye.before(c,u)}}return ye.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",s){if(!this.isValid)return NaN;const n=this.start.startOf(e,s);let r;return s?.useLocaleWeeks?r=this.end.reconfigure({locale:n.locale}):r=this.end,r=r.startOf(e,s),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:s}={}){return this.isValid?ye.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Mt).filter(o=>this.contains(o)).sort((o,c)=>o.toMillis()-c.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const o=s[a]||this.e,c=+o>+this.e?this.e:o;n.push(ye.fromDateTimes(r,c)),r=c,a+=1}return n}splitBy(e){const s=X.fromDurationLike(e);if(!this.isValid||!s.isValid||s.as("milliseconds")===0)return[];let{s:n}=this,r=1,a;const o=[];for(;n<this.e;){const c=this.start.plus(s.mapUnits(l=>l*r));a=+c>+this.e?this.e:c,o.push(ye.fromDateTimes(n,a)),n=a,r+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const s=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return s>=n?null:ye.fromDateTimes(s,n)}union(e){if(!this.isValid)return this;const s=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return ye.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,a)=>r.s-a.s).reduce(([r,a],o)=>a?a.overlaps(o)||a.abutsStart(o)?[r,a.union(o)]:[r.concat([a]),o]:[r,o],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],a=e.map(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),o=Array.prototype.concat(...a),c=o.sort((l,u)=>l.time-u.time);for(const l of c)n+=l.type==="s"?1:-1,n===1?s=l.time:(s&&+s!=+l.time&&r.push(ye.fromDateTimes(s,l.time)),s=null);return ye.merge(r)}difference(...e){return ye.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:St}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=ss,s={}){return this.isValid?ke.create(this.s.loc.clone(s),e).formatInterval(this):St}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:St}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:St}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:St}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:St}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):X.invalid(this.invalidReason)}mapEndpoints(e){return ye.fromDateTimes(e(this.s),e(this.e))}}class Gt{static hasDST(e=pe.defaultZone){const s=W.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return Xe.isValidZone(e)}static normalizeZone(e){return rt(e,pe.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||se.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||se.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||se.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||se.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return se.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return se.create(s,null,"gregory").eras(e)}static features(){return{relative:Or(),localeWeek:jr()}}}function Un(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(X.fromMillis(n).as("days"))}function jo(t,e,s){const n=[["years",(l,u)=>u.year-l.year],["quarters",(l,u)=>u.quarter-l.quarter+(u.year-l.year)*4],["months",(l,u)=>u.month-l.month+(u.year-l.year)*12],["weeks",(l,u)=>{const f=Un(l,u);return(f-f%7)/7}],["days",Un]],r={},a=t;let o,c;for(const[l,u]of n)s.indexOf(l)>=0&&(o=l,r[l]=u(t,e),c=a.plus(r),c>e?(r[l]--,t=a.plus(r),t>e&&(c=t,r[l]--,t=a.plus(r))):t=c);return[t,r,c,o]}function Co(t,e,s,n){let[r,a,o,c]=jo(t,e,s);const l=e-r,u=s.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<e&&(o=r.plus({[c]:1})),o!==r&&(a[c]=(a[c]||0)+l/(o-r)));const f=X.fromObject(a,n);return u.length>0?X.fromMillis(l,n).shiftTo(...u).plus(f):f}const Do="missing Intl.DateTimeFormat.formatToParts support";function ee(t,e=s=>s){return{regex:t,deser:([s])=>e(Ai(s))}}const Ro=" ",_r=`[ ${Ro}]`,Jr=new RegExp(_r,"g");function Uo(t){return t.replace(/\./g,"\\.?").replace(Jr,_r)}function Ln(t){return t.replace(/\./g,"").replace(Jr," ").toLowerCase()}function Ge(t,e){return t===null?null:{regex:RegExp(t.map(Uo).join("|")),deser:([s])=>t.findIndex(n=>Ln(s)===Ln(n))+e}}function Fn(t,e){return{regex:t,deser:([,s,n])=>ds(s,n),groups:e}}function Yt(t){return{regex:t,deser:([e])=>e}}function Lo(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Fo(t,e){const s=qe(e),n=qe(e,"{2}"),r=qe(e,"{3}"),a=qe(e,"{4}"),o=qe(e,"{6}"),c=qe(e,"{1,2}"),l=qe(e,"{1,3}"),u=qe(e,"{1,6}"),f=qe(e,"{1,9}"),h=qe(e,"{2,4}"),x=qe(e,"{4,6}"),p=M=>({regex:RegExp(Lo(M.val)),deser:([G])=>G,literal:!0}),j=(M=>{if(t.literal)return p(M);switch(M.val){case"G":return Ge(e.eras("short"),0);case"GG":return Ge(e.eras("long"),0);case"y":return ee(u);case"yy":return ee(h,Ws);case"yyyy":return ee(a);case"yyyyy":return ee(x);case"yyyyyy":return ee(o);case"M":return ee(c);case"MM":return ee(n);case"MMM":return Ge(e.months("short",!0),1);case"MMMM":return Ge(e.months("long",!0),1);case"L":return ee(c);case"LL":return ee(n);case"LLL":return Ge(e.months("short",!1),1);case"LLLL":return Ge(e.months("long",!1),1);case"d":return ee(c);case"dd":return ee(n);case"o":return ee(l);case"ooo":return ee(r);case"HH":return ee(n);case"H":return ee(c);case"hh":return ee(n);case"h":return ee(c);case"mm":return ee(n);case"m":return ee(c);case"q":return ee(c);case"qq":return ee(n);case"s":return ee(c);case"ss":return ee(n);case"S":return ee(l);case"SSS":return ee(r);case"u":return Yt(f);case"uu":return Yt(c);case"uuu":return ee(s);case"a":return Ge(e.meridiems(),0);case"kkkk":return ee(a);case"kk":return ee(h,Ws);case"W":return ee(c);case"WW":return ee(n);case"E":case"c":return ee(s);case"EEE":return Ge(e.weekdays("short",!1),1);case"EEEE":return Ge(e.weekdays("long",!1),1);case"ccc":return Ge(e.weekdays("short",!0),1);case"cccc":return Ge(e.weekdays("long",!0),1);case"Z":case"ZZ":return Fn(new RegExp(`([+-]${c.source})(?::(${n.source}))?`),2);case"ZZZ":return Fn(new RegExp(`([+-]${c.source})(${n.source})?`),2);case"z":return Yt(/[a-z_+-/]{1,256}?/i);case" ":return Yt(/[^\S\n\r]/);default:return p(M)}})(t)||{invalidReason:Do};return j.token=t,j}const $o={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function Po(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const l=/^\s+$/.test(r);return{literal:!l,val:l?" ":r}}const a=e[n];let o=n;n==="hour"&&(e.hour12!=null?o=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?o="hour12":o="hour24":o=s.hour12?"hour12":"hour24");let c=$o[o];if(typeof c=="object"&&(c=c[a]),c)return{literal:!1,val:c}}function Wo(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function Vo(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(Tt(s,o)){const c=s[o],l=c.groups?c.groups+1:1;!c.literal&&c.token&&(r[c.token.val[0]]=c.deser(n.slice(a,a+l))),a+=l}return[n,r]}else return[n,{}]}function Bo(t){const e=a=>{switch(a){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let s=null,n;return V(t.z)||(s=Xe.create(t.z)),V(t.Z)||(s||(s=new Ee(t.Z)),n=t.Z),V(t.q)||(t.M=(t.q-1)*3+1),V(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),V(t.u)||(t.S=Js(t.u)),[Object.keys(t).reduce((a,o)=>{const c=e(o);return c&&(a[c]=t[o]),a},{}),s,n]}let Ns=null;function Zo(){return Ns||(Ns=W.fromMillis(1555555555555)),Ns}function zo(t,e){if(t.literal)return t;const s=ke.macroTokenToFormatOpts(t.val),n=ea(s,e);return n==null||n.includes(void 0)?t:n}function Kr(t,e){return Array.prototype.concat(...t.map(s=>zo(s,e)))}class Qr{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=Kr(ke.parseFormat(s),e),this.units=this.tokens.map(n=>Fo(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=Wo(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=Vo(e,this.regex,this.handlers),[r,a,o]=n?Bo(n):[null,null,void 0];if(Tt(n,"a")&&Tt(n,"H"))throw new vt("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:s,matches:n,result:r,zone:a,specificOffset:o}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function Xr(t,e,s){return new Qr(t,s).explainFromTokens(e)}function Ho(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=Xr(t,e,s);return[n,r,a,o]}function ea(t,e){if(!t)return null;const n=ke.create(e,t).dtFormatter(Zo()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>Po(o,t,a))}const bs="Invalid DateTime",$n=864e13;function Ct(t){return new Ye("unsupported zone",`the zone "${t.name}" is not supported`)}function ks(t){return t.weekData===null&&(t.weekData=ns(t.c)),t.weekData}function Is(t){return t.localWeekData===null&&(t.localWeekData=ns(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function ot(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new W({...s,...e,old:s})}function ta(t,e,s){let n=t-e*60*1e3;const r=s.offset(n);if(e===r)return[n,e];n-=(r-e)*60*1e3;const a=s.offset(n);return r===a?[n,r]:[t-Math.min(r,a)*60*1e3,Math.max(r,a)]}function _t(t,e){t+=e*60*1e3;const s=new Date(t);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),hour:s.getUTCHours(),minute:s.getUTCMinutes(),second:s.getUTCSeconds(),millisecond:s.getUTCMilliseconds()}}function Xt(t,e,s){return ta(us(t),e,s)}function Pn(t,e){const s=t.o,n=t.c.year+Math.trunc(e.years),r=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,a={...t.c,year:n,month:r,day:Math.min(t.c.day,rs(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=X.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),c=us(a);let[l,u]=ta(c,s,t.zone);return o!==0&&(l+=o,u=t.zone.offset(l)),{ts:l,o:u}}function xt(t,e,s,n,r,a){const{setZone:o,zone:c}=s;if(t&&Object.keys(t).length!==0||e){const l=e||c,u=W.fromObject(t,{...s,zone:l,specificOffset:a});return o?u:u.setZone(c)}else return W.invalid(new Ye("unparsable",`the input "${r}" can't be parsed as ${n}`))}function Jt(t,e,s=!0){return t.isValid?ke.create(se.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Es(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=Se(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=Se(t.c.month),s==="month")return r;r+="-"}else if(r+=Se(t.c.month),s==="month")return r;return r+=Se(t.c.day),r}function Wn(t,e,s,n,r,a,o){let c=!s||t.c.millisecond!==0||t.c.second!==0,l="";switch(o){case"day":case"month":case"year":break;default:if(l+=Se(t.c.hour),o==="hour")break;if(e){if(l+=":",l+=Se(t.c.minute),o==="minute")break;c&&(l+=":",l+=Se(t.c.second))}else{if(l+=Se(t.c.minute),o==="minute")break;c&&(l+=Se(t.c.second))}if(o==="second")break;c&&(!n||t.c.millisecond!==0)&&(l+=".",l+=Se(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?l+="Z":t.o<0?(l+="-",l+=Se(Math.trunc(-t.o/60)),l+=":",l+=Se(Math.trunc(-t.o%60))):(l+="+",l+=Se(Math.trunc(t.o/60)),l+=":",l+=Se(Math.trunc(t.o%60)))),a&&(l+="["+t.zone.ianaName+"]"),l}const sa={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},qo={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Go={ordinal:1,hour:0,minute:0,second:0,millisecond:0},es=["year","month","day","hour","minute","second","millisecond"],Yo=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],_o=["year","ordinal","hour","minute","second","millisecond"];function ts(t){const e={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[t.toLowerCase()];if(!e)throw new sr(t);return e}function Vn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return ts(t)}}function Jo(t){if(Dt===void 0&&(Dt=pe.now()),t.type!=="iana")return t.offset(Dt);const e=t.name;let s=Vs.get(e);return s===void 0&&(s=t.offset(Dt),Vs.set(e,s)),s}function Bn(t,e){const s=rt(e.zone,pe.defaultZone);if(!s.isValid)return W.invalid(Ct(s));const n=se.fromObject(e);let r,a;if(V(t.year))r=pe.now();else{for(const l of es)V(t[l])&&(t[l]=sa[l]);const o=Er(t)||Mr(t);if(o)return W.invalid(o);const c=Jo(s);[r,a]=Xt(t,c,s)}return new W({ts:r,zone:s,loc:n,o:a})}function Zn(t,e,s){const n=V(s.round)?!0:s.round,r=V(s.rounding)?"trunc":s.rounding,a=(c,l)=>(c=Ks(c,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(c,l)),o=c=>s.calendary?e.hasSame(t,c)?0:e.startOf(c).diff(t.startOf(c),c).get(c):e.diff(t,c).get(c);if(s.unit)return a(o(s.unit),s.unit);for(const c of s.units){const l=o(c);if(Math.abs(l)>=1)return a(l,c)}return a(t>e?-0:0,s.units[s.units.length-1])}function zn(t){let e={},s;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],s=Array.from(t).slice(0,t.length-1)):s=Array.from(t),[e,s]}let Dt;const Vs=new Map;class W{constructor(e){const s=e.zone||pe.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ye("invalid input"):null)||(s.isValid?null:Ct(s));this.ts=V(e.ts)?pe.now():e.ts;let r=null,a=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,a]=[e.old.c,e.old.o];else{const c=at(e.o)&&!e.old?e.o:s.offset(this.ts);r=_t(this.ts,c),n=Number.isNaN(r.year)?new Ye("invalid input"):null,r=n?null:r,a=n?null:c}this._zone=s,this.loc=e.loc||se.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new W({})}static local(){const[e,s]=zn(arguments),[n,r,a,o,c,l,u]=s;return Bn({year:n,month:r,day:a,hour:o,minute:c,second:l,millisecond:u},e)}static utc(){const[e,s]=zn(arguments),[n,r,a,o,c,l,u]=s;return e.zone=Ee.utcInstance,Bn({year:n,month:r,day:a,hour:o,minute:c,second:l,millisecond:u},e)}static fromJSDate(e,s={}){const n=Ii(e)?e.valueOf():NaN;if(Number.isNaN(n))return W.invalid("invalid input");const r=rt(s.zone,pe.defaultZone);return r.isValid?new W({ts:n,zone:r,loc:se.fromObject(s)}):W.invalid(Ct(r))}static fromMillis(e,s={}){if(at(e))return e<-$n||e>$n?W.invalid("Timestamp out of range"):new W({ts:e,zone:rt(s.zone,pe.defaultZone),loc:se.fromObject(s)});throw new be(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(at(e))return new W({ts:e*1e3,zone:rt(s.zone,pe.defaultZone),loc:se.fromObject(s)});throw new be("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=rt(s.zone,pe.defaultZone);if(!n.isValid)return W.invalid(Ct(n));const r=se.fromObject(s),a=as(e,Vn),{minDaysInFirstWeek:o,startOfWeek:c}=In(a,r),l=pe.now(),u=V(s.specificOffset)?n.offset(l):s.specificOffset,f=!V(a.ordinal),h=!V(a.year),x=!V(a.month)||!V(a.day),p=h||x,k=a.weekYear||a.weekNumber;if((p||f)&&k)throw new vt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(x&&f)throw new vt("Can't mix ordinal dates with month/day");const j=k||a.weekday&&!p;let M,G,L=_t(l,u);j?(M=Yo,G=qo,L=ns(L,o,c)):f?(M=_o,G=Go,L=Ts(L)):(M=es,G=sa);let $=!1;for(const g of M){const O=a[g];V(O)?$?a[g]=G[g]:a[g]=L[g]:$=!0}const T=j?Ni(a,o,c):f?bi(a):Er(a),D=T||Mr(a);if(D)return W.invalid(D);const B=j?bn(a,o,c):f?kn(a):a,[C,q]=Xt(B,u,n),y=new W({ts:C,zone:n,o:q,loc:r});return a.weekday&&p&&e.weekday!==y.weekday?W.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${y.toISO()}`):y.isValid?y:W.invalid(y.invalid)}static fromISO(e,s={}){const[n,r]=go(e);return xt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=So(e);return xt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=xo(e);return xt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(V(e)||V(s))throw new be("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[c,l,u,f]=Ho(o,e,s);return f?W.invalid(f):xt(c,l,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return W.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=ko(e);return xt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new be("need to specify a reason the DateTime is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(pe.throwOnInvalid)throw new Qa(n);return new W({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=ea(e,se.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return Kr(ke.parseFormat(e),se.fromObject(s)).map(r=>r.val).join("")}static resetCache(){Dt=void 0,Vs.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?ks(this).weekYear:NaN}get weekNumber(){return this.isValid?ks(this).weekNumber:NaN}get weekday(){return this.isValid?ks(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Is(this).weekday:NaN}get localWeekNumber(){return this.isValid?Is(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Is(this).weekYear:NaN}get ordinal(){return this.isValid?Ts(this.c).ordinal:NaN}get monthShort(){return this.isValid?Gt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Gt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Gt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Gt.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,s=6e4,n=us(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),o=this.zone.offset(n-r*s),c=this.zone.offset(n-a*s);if(o===c)return[this];const l=n-o*s,u=n-c*s,f=_t(l,o),h=_t(u,c);return f.hour===h.hour&&f.minute===h.minute&&f.second===h.second&&f.millisecond===h.millisecond?[ot(this,{ts:l}),ot(this,{ts:u})]:[this]}get isInLeapYear(){return Ft(this.year)}get daysInMonth(){return rs(this.year,this.month)}get daysInYear(){return this.isValid?wt(this.year):NaN}get weeksInWeekYear(){return this.isValid?Ut(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Ut(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=ke.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(Ee.instance(e),s)}toLocal(){return this.setZone(pe.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=rt(e,pe.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const a=e.offset(this.ts),o=this.toObject();[r]=Xt(o,a,e)}return ot(this,{ts:r,zone:e})}else return W.invalid(Ct(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return ot(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=as(e,Vn),{minDaysInFirstWeek:n,startOfWeek:r}=In(s,this.loc),a=!V(s.weekYear)||!V(s.weekNumber)||!V(s.weekday),o=!V(s.ordinal),c=!V(s.year),l=!V(s.month)||!V(s.day),u=c||l,f=s.weekYear||s.weekNumber;if((u||o)&&f)throw new vt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&o)throw new vt("Can't mix ordinal dates with month/day");let h;a?h=bn({...ns(this.c,n,r),...s},n,r):V(s.ordinal)?(h={...this.toObject(),...s},V(s.day)&&(h.day=Math.min(rs(h.year,h.month),h.day))):h=kn({...Ts(this.c),...s});const[x,p]=Xt(h,this.o,this.zone);return ot(this,{ts:x,o:p})}plus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e);return ot(this,Pn(this,s))}minus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e).negate();return ot(this,Pn(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=X.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0;break}if(r==="weeks")if(s){const a=this.loc.getStartOfWeek(),{weekday:o}=this;o<a&&(n.weekNumber=this.weekNumber-1),n.weekday=a}else n.weekday=1;if(r==="quarters"){const a=Math.ceil(this.month/3);n.month=(a-1)*3+1}return this.set(n)}endOf(e,s){return this.isValid?this.plus({[e]:1}).startOf(e,s).minus(1):this}toFormat(e,s={}){return this.isValid?ke.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):bs}toLocaleString(e=ss,s={}){return this.isValid?ke.create(this.loc.clone(s),e).formatDateTime(this):bs}toLocaleParts(e={}){return this.isValid?ke.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:s=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:a=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=ts(o);const c=e==="extended";let l=Es(this,c,o);return es.indexOf(o)>=3&&(l+="T"),l+=Wn(this,c,s,n,r,a,o),l}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Es(this,e==="extended",ts(s)):null}toISOWeekDate(){return Jt(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:a=!1,format:o="extended",precision:c="milliseconds"}={}){return this.isValid?(c=ts(c),(r&&es.indexOf(c)>=3?"T":"")+Wn(this,o==="extended",s,e,n,a,c)):null}toRFC2822(){return Jt(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Jt(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Es(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:s=!1,includeOffsetSpace:n=!0}={}){let r="HH:mm:ss.SSS";return(s||e)&&(n&&(r+=" "),s?r+="z":e&&(r+="ZZ")),Jt(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():bs}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const s={...this.c};return e.includeConfig&&(s.outputCalendar=this.outputCalendar,s.numberingSystem=this.loc.numberingSystem,s.locale=this.loc.locale),s}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,s="milliseconds",n={}){if(!this.isValid||!e.isValid)return X.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=Ei(s).map(X.normalizeUnit),o=e.valueOf()>this.valueOf(),c=o?this:e,l=o?e:this,u=Co(c,l,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(W.now(),e,s)}until(e){return this.isValid?ye.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),a=this.setZone(e.zone,{keepLocalTime:!0});return a.startOf(s,n)<=r&&r<=a.endOf(s,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const s=e.base||W.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],a=e.unit;return Array.isArray(e.unit)&&(r=e.unit,a=void 0),Zn(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?Zn(e.base||W.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(W.isDateTime))throw new be("min requires all arguments be DateTimes");return En(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(W.isDateTime))throw new be("max requires all arguments be DateTimes");return En(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return Xr(o,e,s)}static fromStringExplain(e,s,n={}){return W.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=se.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new Qr(a,e)}static fromFormatParser(e,s,n={}){if(V(e)||V(s))throw new be("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!o.equals(s.locale))throw new be(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:c,zone:l,specificOffset:u,invalidReason:f}=s.explainFromTokens(e);return f?W.invalid(f):xt(c,l,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return ss}static get DATE_MED(){return nr}static get DATE_MED_WITH_WEEKDAY(){return ti}static get DATE_FULL(){return rr}static get DATE_HUGE(){return ar}static get TIME_SIMPLE(){return ir}static get TIME_WITH_SECONDS(){return or}static get TIME_WITH_SHORT_OFFSET(){return lr}static get TIME_WITH_LONG_OFFSET(){return cr}static get TIME_24_SIMPLE(){return ur}static get TIME_24_WITH_SECONDS(){return dr}static get TIME_24_WITH_SHORT_OFFSET(){return mr}static get TIME_24_WITH_LONG_OFFSET(){return fr}static get DATETIME_SHORT(){return hr}static get DATETIME_SHORT_WITH_SECONDS(){return yr}static get DATETIME_MED(){return pr}static get DATETIME_MED_WITH_SECONDS(){return gr}static get DATETIME_MED_WITH_WEEKDAY(){return si}static get DATETIME_FULL(){return Sr}static get DATETIME_FULL_WITH_SECONDS(){return xr}static get DATETIME_HUGE(){return vr}static get DATETIME_HUGE_WITH_SECONDS(){return wr}}function Mt(t){if(W.isDateTime(t))return t;if(t&&t.valueOf&&at(t.valueOf()))return W.fromJSDate(t);if(t&&typeof t=="object")return W.fromObject(t);throw new be(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Ko(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Qo(t,e){try{const s=W.fromJSDate(t,{zone:"utc"}).setZone(e),n=s.toJSDate().toLocaleString("en-US",{timeZone:e,timeZoneName:"short"}).split(" ").pop()||void 0,r=s.toFormat("ZZ")||void 0;return{abbr:n,offset:r}}catch{return{}}}function Xo(t){if(!t)return"-";try{const e=new Date(t),s=u=>String(u).padStart(2,"0"),n=s(e.getMonth()+1),r=s(e.getDate()),a=e.getFullYear(),o=s(e.getHours()),c=s(e.getMinutes()),l=s(e.getSeconds());return`${n}/${r}/${a} ${o}:${c}:${l}`}catch{return"-"}}function is(t,e="UTC"){if(!t)return"-";const s=W.fromISO(t,{zone:"utc"}).setZone(e);if(!s.isValid)return"-";const n=s.offsetNameShort,r=s.toFormat("ZZZZ"),a=n.startsWith("GMT")||n===r?r:`${n}/${r}`;return`${s.toFormat("MM/dd/yyyy, hh:mm:ss a")} (${a})`}const el={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},tl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function na({alerts:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,severityOptions:a,anomalyOptions:o,spaceOptions:c,onAlertIdClick:l,onFilterChange:u,onPageChange:f,onRefetch:h,resetKey:x,serverSideFilters:p}){const k=qs(),j=async L=>{try{const $=await k.mutateAsync({alertUniqueId:L.alertId??L.id,alertId:L.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if($?.responseStatus||$?.Success){const T=$?.Message||$?.data||"Alert reopened successfully.";Ae.toast.success(T)}else{const T=$?.errorMessage||$?.Message||"Failed to reopen alert";Ae.toast.error(T)}}catch{Ae.toast.error("Failed to reopen alert. Please try again.")}},M=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:L=>i.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${el[L]}`,backgroundColor:tl[String(L)]},children:L})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:L=>Xo(L)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(L,$)=>i.jsxs("div",{children:[i.jsx("a",{onClick:T=>{T.preventDefault(),l?.($,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:$.alertNumber}),i.jsx("div",{className:"text-black/65",children:L})]})},{title:"",key:"menu",width:60,align:"right",render:(L,$)=>i.jsx(d.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:T})=>{T==="reopen"&&j($)}},children:i.jsx(d.Button,{type:"text",icon:i.jsx(ct.MoreOutlined,{})})})}],G=u&&p?t:(t||[]).filter(L=>{const $=(L.statusType||"").toLowerCase();return tr.some(T=>$.includes(T))});return i.jsx(Hs,{data:G,loading:e,pageSize:s,total:n,currentPage:r,columns:M,severityOptions:a,anomalyOptions:o,spaceOptions:c,renderActions:void 0,onAlertIdClick:l,onFilterChange:u,onPageChange:f,onRefetch:h,resetKey:x,serverSideFilters:p,excludeCompleted:!1})}function sl({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=m.useMemo(()=>{const h=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(h.find(x=>x.type==="hour")?.value||"0",10),minutes:parseInt(h.find(x=>x.type==="minute")?.value||"0",10),seconds:parseInt(h.find(x=>x.type==="second")?.value||"0",10)}},[e,s]),o=a*6,c=r*6+a*.1,l=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((f,h)=>{const x=h*30,p=6,k=u-4,j=k-p,M=(x-90)*(Math.PI/180),G=u+j*Math.cos(M),L=u+j*Math.sin(M),$=u+k*Math.cos(M),T=u+k*Math.sin(M);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:G,y1:L,x2:$,y2:T,stroke:"#9CA3AF",strokeWidth:h%3===0?2:1,strokeLinecap:"round"})},h)}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:i.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),i.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function ra({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,a]=m.useState(new Date);m.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const o=m.useMemo(()=>Ko(r,e),[r,e]),{abbr:c,offset:l}=m.useMemo(()=>Qo(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(sl,{time:r,timeZone:e,size:80}),i.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[i.jsx("span",{className:"uppercase",children:t}),c&&i.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[c," ",l]})]}),i.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const{Text:nl}=d.Typography;function rl({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(d.Row,{gutter:[16,16],align:"middle",children:[i.jsx(d.Col,{xs:24,md:8,lg:5,children:i.jsxs(d.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(nl,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(d.Select,{placeholder:"By Severity",value:t,onChange:o=>e({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),i.jsx(d.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(d.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(d.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(d.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const Bs=t=>i.jsxs(d.Tag,{children:[i.jsx(ct.PlusOutlined,{})," ",t.length," more"]}),{Text:Qe}=d.Typography;function al(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:c,l1role:l,setL1role:u,l2mins:f,setL2mins:h,l2role:x,setL2role:p,l3mins:k,setL3mins:j,l3role:M,setL3role:G,actions:L,setActions:$,thirdPartyIds:T,setThirdPartyIds:D,humanLoop:B,setHumanLoop:C,isAutoExpire:q,setAutoExpire:y,onClear:g,onSave:O,saving:oe,onActionTypesLoaded:re}=t,{rules:U,config:v}=Me(),S=v.tenant==="schools",[I,A]=m.useState([]),[R,F]=m.useState([]),[Y,K]=m.useState(!1);m.useEffect(()=>{let de=!1;return(async()=>{try{K(!0);const me=await U.getLookups();if(de||!me||!Array.isArray(me.actionTypes))return;const ge=me.actionTypes.map(ie=>({label:ie.name,value:String(ie.actionTypeId)}));A(ge),re&&re(me.actionTypes);const le=Array.isArray(me.thirdParties)?me.thirdParties.map(ie=>({label:ie.thirdPartyName,value:ie.thirdPartyIds??ie.thirdPartyId})):[];F(le)}catch(me){console.error("Error loading lookups",me)}finally{de||K(!1)}})(),()=>{de=!0}},[]);const te=typeof o=="number"||typeof l=="number",ae=typeof f=="number"||typeof x=="number",ue=typeof o=="number"||typeof l=="number"||typeof f=="number"||typeof x=="number"||typeof k=="number"||typeof M=="number"||Array.isArray(L)&&L.length>0||Array.isArray(T)&&T.length>0||!!B||!!q,xe=!!e&&ue&&!oe;return i.jsxs(d.Spin,{spinning:!!oe||Y,children:[i.jsxs(d.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(d.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:c,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:l,onChange:u,options:a})})]})]})}),te&&i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:f,onChange:h,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:x,onChange:p,options:a})})]})]})}),ae&&i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:k,onChange:j,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:M,onChange:G,options:a})})]})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:L,onChange:$,options:I,maxTagCount:1,maxTagPlaceholder:Bs})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:T,onChange:D,options:R,maxCount:2,maxTagPlaceholder:Bs})]})})]}),i.jsxs(d.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(d.Col,{xs:24,sm:12,md:8,lg:7,children:i.jsxs("div",{className:"flex items-center h-full gap-8",children:[!S&&i.jsx(d.Checkbox,{checked:B,onChange:de=>C(de.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(d.Checkbox,{checked:q,onChange:de=>y(de.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Button,{onClick:g,children:"Clear"}),i.jsx(d.Button,{type:"primary",onClick:O,loading:!!oe,disabled:!xe,children:"Save"})]})})]})]})}function il({entries:t,userRoles:e,onEdit:s,loading:n}){const{config:r}=Me(),a=r.tenant==="schools",o=new Map(e.map(l=>[l.userRoleId,l.userRoleName])),c=l=>l.map(u=>o.get(u)||String(u)).join(", ");return i.jsx(d.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(l,u)=>`${u[0]}-${u[1]} of ${l} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(l,u)=>i.jsxs("span",{children:[u.l1.minutes?`Action taken in (${u.l1.minutes} Mins)`:"No Action taken in 0 Min",u.l1.roles?.length?`, Escalate to (${c(u.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(l,u)=>i.jsxs("span",{children:[u.l2.minutes?`Action taken in (${u.l2.minutes} Mins)`:"No Action taken in 0 Min",u.l2.roles?.length?`, Escalate to (${c(u.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(l,u)=>i.jsxs("span",{children:[u.l3.minutes?`Action taken in (${u.l3.minutes} Mins)`:"No Action taken in 0 Min",u.l3.roles?.length?`, Escalate to (${c(u.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(l,u)=>u.actions?.length?u.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(l,u)=>u.notify?.length?u.notify.join(", "):"-"},...a?[]:[{title:"Human-In-The-Loop",key:"humanLoop",render:(l,u)=>u.humanLoop?"Yes":"No"}],{title:"Auto Expire",key:"isAutoExpire",render:(l,u)=>u.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(l,u)=>i.jsx(d.Button,{type:"text",onClick:()=>s(u.id),children:i.jsx(ct.EditOutlined,{})})}]})}const{Title:ol,Text:Ms}=d.Typography;function aa({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Me(),[r,a]=m.useState(!1),[o,c]=m.useState(!1),[l,u]=m.useState(s),[f,h]=m.useState(),[x,p]=m.useState([]),k=m.useMemo(()=>t.map(T=>({label:T.userRoleName,value:T.userRoleId})),[t]),j=m.useMemo(()=>(e||[]).map(T=>({label:T.Name||"-",value:T.RuleId||T.Name||""})),[e]),M=m.useMemo(()=>(e||[]).map((T,D)=>({key:T.RuleId||T.Name||String(D),ruleName:T.Name||"-",ruleDesc:T.Description||""})),[e]);m.useEffect(()=>{let T=!1;return(async()=>{try{a(!0);const D=await n.getRules();T||u(Array.isArray(D)?D:[])}catch{!T&&Array.isArray(s)&&u(s)}finally{T||a(!1)}})(),()=>{T=!0}},[]),m.useEffect(()=>{!l&&Array.isArray(s)&&u(s)},[s]),m.useEffect(()=>{if(!f||!Array.isArray(l)){p([]);return}const T=l.find(B=>B?.ruleId===f||B?.RuleId===f||B?.ruleName===f),D=T?.userRoleIds??T?.UserRoleIds;p(Array.isArray(D)?D:[])},[f,l]);const G=m.useMemo(()=>{if(!Array.isArray(l)||!l.length)return{};const T={};for(const D of M){const B=l.find(y=>y?.ruleId===D.key||y?.ruleName===D.key||y?.RuleId===D.key||y?.ruleName===D.ruleName||y?.Name===D.ruleName),C=B?.userRoleIds??B?.UserRoleIds,q=Array.isArray(C)?C:[];q.length&&(T[D.key]=q)}return T},[l,M]),L=()=>{h(void 0),p([])},$=async()=>{if(!f){Ae.toast.info("Please select a rule");return}try{c(!0);const T=Array.isArray(l)?l.find(y=>y?.ruleId===f||y?.RuleId===f||y?.ruleName===f):void 0,D=typeof T?.recordId=="number"?T.recordId:T?.ruleId||T?.RuleId||void 0;if(!T||!D)throw new Error(`Unable to find rule identifier for rule ${f}`);const B=x.map(y=>{const g=t.find(O=>O.userRoleId===y);return{id:y,name:g?.userRoleName??String(y)}}),C={...T,ruleId:f,userRoleIds:x,userRoles:B},q=await n.updateRule(D,C);if(!q?.responseStatus&&!q?.Success&&!q?.success)Ae.toast.error(q?.errorMessage||q?.Message||"Error saving Alert Assignment");else{Ae.toast.success("Alert assignment saved"),h(void 0),p([]);try{const y=await n.getRules();u(Array.isArray(y)?y:[])}catch(y){console.error("Failed to refresh rules after save",y)}}}catch(T){console.error("Failed to save alert assignment",T),Ae.toast.error(T instanceof Error?T.message:"Error saving Alert Assignment")}finally{c(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(ol,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(d.Spin,{spinning:o||r,children:i.jsxs(d.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(d.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Ms,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(d.Select,{placeholder:"Rules",value:f,onChange:h,options:j,className:"w-full"})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Ms,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:x,onChange:p,options:k,maxTagCount:1,maxTagPlaceholder:Bs})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Button,{onClick:L,disabled:o,children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:$,loading:o,disabled:o||!f,children:"Save"})]})})]})}),i.jsx(d.Table,{rowKey:"key",dataSource:M,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(T,D)=>`${D[0]}-${D[1]} of ${T} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(T,D)=>{const B=G[D.key]??[];return B.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:B.map(C=>{const q=t.find(y=>y.userRoleId===C);return i.jsx(d.Tag,{children:q?.userRoleName??String(C)},C)})}):i.jsx(Ms,{type:"secondary",children:"—"})}}]})]})}const{Title:Hn}=d.Typography;function Os(t){return!t||typeof t!="object"?{}:{level1UserRoleId:t.level1UserRoleId??t.Level1UserRoleId,level1PostAssistTime:t.level1PostAssistTime??t.Level1PostAssistTime,level2UserRoleId:t.level2UserRoleId??t.Level2UserRoleId,level2PostAssistTime:t.level2PostAssistTime??t.Level2PostAssistTime,level3UserRoleId:t.level3UserRoleId??t.Level3UserRoleId,level3PostAssistTime:t.level3PostAssistTime??t.Level3PostAssistTime,escalationSettingsActionTypeIds:t.escalationSettingsActionTypeIds??t.EscalationSettingsActionTypeIds,thirdPartyId:t.thirdPartyId??t.ThirdPartyId??t.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function ia({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:c}=Me(),[l,u]=m.useState("By Severity"),[f,h]=m.useState("By severity"),[x,p]=m.useState("By Severity"),[k,j]=m.useState(!1),[M,G]=m.useState(!1),[L,$]=m.useState(!1),[T,D]=m.useState(null),[B,C]=m.useState("rules"),[q,y]=m.useState(),[g,O]=m.useState(),[oe,re]=m.useState(),[U,v]=m.useState(),[S,I]=m.useState(),[A,R]=m.useState(),[F,Y]=m.useState(),[K,te]=m.useState(),[ae,ue]=m.useState([]),[xe,de]=m.useState([]),[me,ge]=m.useState(!1),[le,ie]=m.useState(!1),[Te,Oe]=m.useState({}),[He,ne]=m.useState({}),[Z,ve]=m.useState(s||[]),[fe,Ne]=m.useState([]),[De,$e]=m.useState(!1),[Pe,we]=m.useState(!1),[Re,et]=m.useState(n||[]);m.useEffect(()=>{n&&n.length&&et(n)},[n]),m.useEffect(()=>{if(!Re||!Re.length)return;const w=Object.keys(Te).length>0||Object.keys(He).length>0;if(fe.length&&!w)return;const H=Re.map((z,E)=>{const Q=e.find(Ie=>Ie.RuleId===(z.ruleId||z.ruleName))?.Name||z.ruleName||z.Name||"-",P=Os(z.escalationSettings),J=typeof P.level1UserRoleId=="number"&&P.level1UserRoleId>0?[P.level1UserRoleId]:[],ys=typeof P.level2UserRoleId=="number"&&P.level2UserRoleId>0?[P.level2UserRoleId]:[],ps=typeof P.level3UserRoleId=="number"&&P.level3UserRoleId>0?[P.level3UserRoleId]:[],nn=(Array.isArray(P.escalationSettingsActionTypeIds)?P.escalationSettingsActionTypeIds:[]).map(Ie=>Te[Ie]||String(Ie)),an=(Array.isArray(P.thirdPartyId)?P.thirdPartyId:[]).map(Ie=>He[Ie]||String(Ie)),gs=typeof P.humanLoop=="boolean"?P.humanLoop:null,Ss=typeof P.isAutoExpire=="boolean"?P.isAutoExpire:null;return{id:String(z.ruleId||z.ruleName||E),ruleOrSeverityLabel:Q,l1:{minutes:P.level1PostAssistTime??void 0,roles:J},l2:{minutes:P.level2PostAssistTime??void 0,roles:ys},l3:{minutes:P.level3PostAssistTime??void 0,roles:ps},actions:nn,notify:an,humanLoop:gs,isAutoExpire:Ss}});Ne(H)},[Re,e,Te,He]);const mt=m.useMemo(()=>t.map(w=>({label:w.DisplayName,value:w.SeverityId})),[t]),ft=m.useMemo(()=>e.map(w=>({label:w.Name,value:w.RuleId})),[e]),ht=m.useMemo(()=>Z.map(w=>({label:w.userRoleName,value:w.userRoleId})),[Z]),Et=m.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(w=>({label:`${w}`,value:w})),[]);m.useEffect(()=>{let w=!1;async function H(){try{$(!0),D(null);const z=await c.getAdminSettings();if(!w&&z){const E=Jn(z.sortBy);u(E),p(E),j(!1)}}catch(z){if(!w){const E=z instanceof Error?z.message:"Failed to load admin settings";D(E)}}finally{w||$(!1)}}return H(),()=>{w=!0}},[]),m.useEffect(()=>{if(!g)return;const w=Q=>{const P=Number(Q);return!isNaN(P)&&P>0?P:void 0},H=Q=>{const P=Number(Q);return!isNaN(P)&&P>0?P:void 0},z=(Re||[]).find(Q=>Q?.ruleId===g||Q?.ruleName===g||Q?.RuleId===g),E=Os(z?.escalationSettings);if(E&&typeof E=="object"){re(H(E.level1PostAssistTime)),v(w(E.level1UserRoleId)),I(H(E.level2PostAssistTime)),R(w(E.level2UserRoleId)),Y(H(E.level3PostAssistTime)),te(w(E.level3UserRoleId));const Q=Array.isArray(E.escalationSettingsActionTypeIds)?E.escalationSettingsActionTypeIds:[];ue(Q.map(P=>String(P))),de(Array.isArray(E.thirdPartyId)?E.thirdPartyId:[]),ge(!!E.humanLoop),ie(!!E.isAutoExpire)}},[B,g,Re]);const yt=async()=>{try{we(!0);const w=await o.getRules(),H=Array.isArray(w)?w:Array.isArray(w?.data)?w.data:[];et(H);const z=H.map((E,Q)=>{const P=e.find(Ie=>Ie.RuleId===(E.ruleId||E.ruleName))?.Name||E.ruleName||E.Name||"-",J=Os(E.escalationSettings??E.EscalationSettings),ys=typeof J.level1UserRoleId=="number"&&J.level1UserRoleId>0?[J.level1UserRoleId]:[],ps=typeof J.level2UserRoleId=="number"&&J.level2UserRoleId>0?[J.level2UserRoleId]:[],sn=typeof J.level3UserRoleId=="number"&&J.level3UserRoleId>0?[J.level3UserRoleId]:[],rn=(Array.isArray(J.escalationSettingsActionTypeIds)?J.escalationSettingsActionTypeIds:[]).map(Ie=>Te[Ie]||String(Ie)),gs=(Array.isArray(J.thirdPartyId)?J.thirdPartyId:[]).map(Ie=>He[Ie]||String(Ie)),Ss=typeof J.humanLoop=="boolean"?J.humanLoop:null;return{id:String(E.ruleId||E.ruleName||Q),ruleOrSeverityLabel:P,l1:{minutes:J.level1PostAssistTime??void 0,roles:ys},l2:{minutes:J.level2PostAssistTime??void 0,roles:ps},l3:{minutes:J.level3PostAssistTime??void 0,roles:sn},actions:rn,notify:gs,humanLoop:Ss}});Ne(z)}catch(w){console.error("Failed to refetch entries",w)}finally{we(!1)}};m.useEffect(()=>{let w=!1;return(async()=>{try{const H=await o.getLookups();if(w||!H)return;const z={};if(Array.isArray(H.thirdParties))for(const Q of H.thirdParties){const P=Q.thirdPartyIds??Q.thirdPartyId;typeof P=="number"&&(z[P]=Q.thirdPartyName)}ne(z);const E=Array.isArray(H.userRoles)?H.userRoles.map(Q=>({userRoleId:Q.userRoleId??Q.id,userRoleName:Q.userRoleName??Q.name})):[];w||ve(E.length?E:s||[])}catch(H){console.error("Error loading lookups",H)}})(),()=>{w=!0}},[]);const he=async()=>{G(!0);try{const w=await c.setAdminSettings({sortBy:l,groupBy:"string"});w?.responseStatus&&w?.data&&Ae.toast.success(w.data),p(l),j(!1)}catch(w){console.error("Error saving admin settings",w)}finally{G(!1)}},pt=()=>{u(x),j(!1)},b=async()=>{$e(!0),a?.({ruleId:g,levels:[{minutes:oe,role:U},{minutes:S,role:A},{minutes:F,role:K}],actions:ae,thirdPartyIds:xe,humanLoop:me,isAutoExpire:le});try{if(g){const H=Array.isArray(ae)?ae.map(J=>Number.isNaN(Number(J))?J:Number(J)):[],z=(Re||[]).find(J=>J?.ruleId===g||J?.ruleName===g||J?.RuleId===g),E=typeof z?.recordId=="number"?z.recordId:z?.ruleId||z?.RuleId||void 0;if(!z||!E){Ae.toast.error("Unable to find rule identifier for update");return}const Q={...z,escalationSettings:{level1UserRoleId:U??0,level1PostAssistTime:oe??0,level2UserRoleId:A??0,level2PostAssistTime:S??0,level3UserRoleId:K??0,level3PostAssistTime:F??0,escalationSettingsActionTypeIds:H,thirdPartyId:Array.isArray(xe)?xe:[],humanLoop:me,isAutoExpire:le}},P=await o.updateRule(E,Q);P?.responseStatus||P?.Success||P?.success?(Ae.toast.success("Escalation settings saved"),await yt(),O(void 0),re(void 0),v(void 0),I(void 0),R(void 0),Y(void 0),te(void 0),ue([]),de([]),ge(!1),ie(!1)):Ae.toast.error(P?.errorMessage||P?.Message||"Error saving Escalation Settings")}}catch(H){console.error("Error saving escalation settings",H)}finally{$e(!1)}},_=()=>{u("By Severity"),h("By severity"),C("rules"),y(void 0),O(void 0),re(void 0),v(void 0),I(void 0),R(void 0),Y(void 0),te(void 0),ue([]),de([]),ge(!1),ie(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Hn,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(d.Spin,{spinning:L,children:[T?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",T]}):null,i.jsx(rl,{sortBy:l,groupBy:f,onChange:w=>{w.sortBy&&(u(w.sortBy),j(!0)),w.groupBy&&(h(w.groupBy),j(!0))},showActions:k,onSave:he,onClear:pt,saving:M})]})]}),i.jsx(d.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(Hn,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(al,{escBasis:B,setEscBasis:C,selectedSeverity:q,setSelectedSeverity:y,selectedRule:g,setSelectedRule:O,severityOptions:mt,ruleOptions:ft,minsOptions:Et,roleOptions:ht,l1mins:oe,setL1mins:re,l1role:U,setL1role:v,l2mins:S,setL2mins:I,l2role:A,setL2role:R,l3mins:F,setL3mins:Y,l3role:K,setL3role:te,actions:ae,setActions:ue,thirdPartyIds:xe,setThirdPartyIds:de,humanLoop:me,setHumanLoop:ge,onClear:_,onSave:b,saving:De,onActionTypesLoaded:w=>{const H={};for(const z of w)typeof z.actionTypeId=="number"&&(H[z.actionTypeId]=z.name);Oe(H)},isAutoExpire:le,setAutoExpire:ie})]}),i.jsx(d.Divider,{className:"my-6"}),i.jsx(il,{entries:fe,userRoles:Z,loading:Pe||r,onEdit:w=>{C("rules");const H=fe.find(E=>E.id===w),z=e.find(E=>E.RuleId===w)||(H?e.find(E=>E.Name===H.ruleOrSeverityLabel):void 0);O(z?z.RuleId:w)}}),i.jsx(d.Divider,{className:"my-6"}),i.jsx(aa,{userRoles:Z,rules:e,rawRules:n}),i.jsx(d.Divider,{})]})}const{Title:qn,Text:Kt}=d.Typography;function ll({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Me(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[c,l]=m.useState("By Severity"),[u,f]=m.useState(new Set),[h,x]=m.useState(null),[p,k]=m.useState(null),[j,M]=m.useState({inApp:!1,sms:!1,email:!1}),[G,L]=m.useState([]),[$,T]=m.useState(!0),[D,B]=m.useState(!1);m.useEffect(()=>{let y=!1;return(async()=>{try{const g=await a.getPreferenceSettings();if(y||!g)return;M({inApp:!!g.inApp,sms:!!g.sms,email:!!g.email});const O=Jn(g.sortBy);l(O==="By Created Date"?"By Created Date":"By Severity"),x(fn(g.doNotDisturbStart)),k(fn(g.doNotDisturbEnd)),Array.isArray(g.anomalyIds)&&f(new Set(g.anomalyIds.map(oe=>String(oe))))}catch(g){console.error("Error in loading my preferences: ",g)}})(),()=>{y=!0}},[]),m.useEffect(()=>{let y=!1;return(async()=>{try{T(!0);const g=await r.getLookups();if(y||!g)return;const O=Array.isArray(g.anomalies)?g.anomalies:[];L(O)}catch(g){console.error("Failed to load anomalies lookups",g)}finally{y||T(!1)}})(),()=>{y=!0}},[]);const C=y=>{f(g=>{const O=new Set(g);return O.has(y)?O.delete(y):O.add(y),O})},q=async()=>{s?.({sortBy:c,subscribedRuleIds:Array.from(u),dnd:{from:h,to:p},channels:j});try{B(!0);const y=h?h.format?.("HH:mm:ss")??"00:00:00":"00:00:00",g=p?p.format?.("HH:mm:ss")??"00:00:00":"00:00:00",O=Array.from(u).map(re=>Number(re)).filter(re=>Number.isFinite(re)),oe=await a.setPreferenceSettings({anomalyIds:O,doNotDisturbStart:y,doNotDisturbEnd:g,inApp:!!j.inApp,sms:!!j.sms,email:!!j.email,sortBy:c});oe?.responseStatus&&Ae.toast.success(oe?.data||"Preferences updated successfully.")}catch(y){console.error("Error in saving my preferences: ",y)}finally{B(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(d.Col,{xs:24,md:8,children:i.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(Kt,{className:"text-gray-600",children:"Sort By:"}),i.jsx(d.Select,{className:"w-[240px]",value:c,options:o,onChange:l})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(qn,{level:5,className:"!mb-2",children:"Anomalies"}),$?i.jsx("div",{className:"py-4",children:i.jsx(d.Spin,{})}):i.jsx(d.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(G)?G:[]).map(y=>{const g=String(y.recordId),O=y.anomalyName;return i.jsx(d.Checkbox,{checked:u.has(g),onChange:()=>C(g),children:O},g)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(qn,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(d.Col,{xs:24,md:12,children:i.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(Kt,{children:"Do Not Disturb mode:"}),i.jsxs(d.Space,{size:12,className:"w-full",children:[i.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(Kt,{children:"From"}),i.jsx(d.TimePicker,{value:h,onChange:y=>x(y),format:"HH:mm"})]}),i.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(Kt,{children:"To"}),i.jsx(d.TimePicker,{value:p,onChange:y=>k(y),format:"HH:mm"})]})]})]})})}),i.jsxs(d.Row,{gutter:[24,12],children:[i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:j.inApp,onChange:y=>M({...j,inApp:y.target.checked}),children:"In-app"})}),i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:j.sms,onChange:y=>M({...j,sms:y.target.checked}),children:"SMS"})}),i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:j.email,onChange:y=>M({...j,email:y.target.checked}),children:"Email"})})]})]}),i.jsx(d.Divider,{}),i.jsxs(d.Space,{className:"gap-3",children:[i.jsx(d.Button,{onClick:n,disabled:D,children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:q,loading:D,children:"Save"})]})]})}function oa({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(ia,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const cl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIZSURBVHgBnZW/b9NAFMe/z3H6i1ZNJUBFQsL/QQkLCFBtRhhKF1ibhBmpXbtgFlYqsTG0gRGWwgAjMb8EYmjYGN0pCCrVVaX+SBxf37PiqHWcOu5Xsux79+6j77vz3RH66IbdsDTQPCFngmBwqMCPBwVXoe204Fd/2ZfrSWMpHrDshtGCvsY9FlKkFNYD+Es/7EtuX+itp1sLnLrScTWoPMYsfnty/lUPtAOs4syiUgQOoWHJpG9kdBiX11Z+UaZCk1YT+vOzACuzYxgf7hZbyBGvhTi9af+7SkQbyKi7M8N4ZJ5D+eU2dg9UN07KvyNOS8io6UkNFXMMj1/vnACKAuTmNXZpIqME+LF+iIbX7ukjkClODWTQw+ujuGYMYfXzXnICbxSBDrxAUvYDhkrZp6ggUC8+sDI7mpj9YmESb3/uJ5Z9TJ5A3eORvzsBpgs6lufGT2TKPNY3fbxh6Knis0FTSjnx+LP3u5DJicDi/t7MCFadPaRJQTl02/5vKcKnpITluYkwrWjksebs48Pvg3SoUkXtq32hxt+1pITI8Zc/zcGACN59ty/WdWnklV5ukZ+49wU8MUJIF3mBGlqUr3Dv1+wpl20v9UuP75pElyrgc3XK7UJFbLvK4DJiv9ggDmWcjO9G4imWvW00yV/hjvtpOFnpQOVLkcO+0EhyevGrROG1ol1hREFc8ZGxyddIje+v9c4i9+gI5z7MozLxclgAAAAASUVORK5CYII=",ul="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgBjVVdbtpAEJ5ZmygPfTBSaVWpUt0bwFuURgJOUG5QeoLACbw+QeAEwA3SGxgJokh9CDeI+xSpTRU/Imw8nbFZx6QQGAl5d2fm229+dkDYI2f6oaUAOwhWExBcPnL4FwFBSLCexpCMf+qPi12++PKgpR/cGOwRa1pwQIjgOoWkf6s/hOVzVd588R+/xWjf5YAY8Y0+ErQrZFfnXg3lK3uGm7A+RISOxfbit5NprqBxxgBoeEIVHehqtI9lSz+5McaaITaA2J17bycFaBayMOS8IaT+zHuv4Ui58P9oAvB4Ga0paUgqbFGswL5idIcIx3P9DCiXrQB7iJawcTiCkMMIUlj7Jo8zr6Yv/EfRXXIqRnzUxnP9u46Id8Q5Sslq3+pqWErHAPKqvxROC/ZMuJwKJ8bkPouUkrYUqgt5IgMDKAxfAYT8nAZnmR2A5J47YSjrFKyOYpZN2SiIJ8YjRqVfASyAFVg9s2F2gXwRsClMXdnYcFpq5PyiQ8KEilaywc79+aEow2i7fdCF46SIpuTvCGi2kWSXjCM4QqS4Zl3yjwQ0UySwrBfGRJNjQKW4ZrmEpL45CxUDTGWdgmoZgxOoDA6zxYgr7ZudhWk3x6Sp4kl0nZmgujQhcH5Cvqy/Hxi5hdL+dgsWxR2rma4FkLeDw+PMM243+t2YB0jDDI9nMBquyWqI3tjmLYguQfqDzxebty/DIcnePr9jfePVfDhSzv2/Hs8LAY3kMmFfTCl+rl3uu1GWF6Jx+X3vkpa+58jeeNyXvY3Pd8N+a0hvgK9ge3hMTmG5CPTnSICWcFpXaDfZUcAck99yOnZM/id3hcmAFV/hgEilU6p0TcH2gpZYS98xc/kXUJ8YImPFzfeLh0cgXbMp8n/yD3ySPZSK0MWKAAAAAElFTkSuQmCC";function fs(){const{config:t}=Me();return{timeZoneDetails:m.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function dl(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:cl,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:ul,alt:"pending",style:{width:20,height:20}});return{title:i.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:i.jsx("b",{children:t.title})}),t.description?i.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?i.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function ml({data:t}){const{timeZoneDetails:e}=fs();return console.log("summary",t),i.jsx("div",{className:"w-full",children:i.jsx(d.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(d.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:i.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Alert ID"}),i.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Severity"}),i.jsx("span",{className:"text-black",children:t.summary.severity})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Location"}),i.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),i.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),i.jsx("div",{className:"mt-2",children:i.jsx(d.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(dl)})})]})]})},{key:"notification",label:"Notification Sent",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>i.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),i.jsx("span",{className:"text-xs text-gray-500 mt-1",children:is(s.sentAt,e?.ianaTimeZoneId)})]}),i.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-green-50 text-green-700 border border-green-200",children:[s.delivered,"/",s.total," Delivered"]})]}),i.jsxs("div",{className:"mt-4 text-xs",children:[i.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?i.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),i.jsxs("div",{className:"mt-4",children:[i.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),i.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,a)=>{const o=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("span",{className:"text-black",children:[r.name," - ",i.jsx("span",{style:{color:o?"#FF3B30":"#FFB86A"},children:o?"Escalation Notification":"Alert Notification"})]}),i.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),i.jsx("span",{className:`text-[11px] px-3 py-[2px] rounded ${r.status==="Delivered"?"bg-green-50 text-green-700 border border-green-200":"bg-red-50 text-red-700 border border-red-200"}`,children:r.status})]},a)})})]})]},n)),t?.notifications?.length?null:i.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const fl=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:a,notifGroups:o})=>{const c={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:l}=fs(),u=a?.length?a.map(h=>{const x=(h?.status||h?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",p=h?.createdDate?is(h.createdDate,l?.ianaTimeZoneId):h?.timestamp?is(h.timestamp,l?.ianaTimeZoneId):"";return{status:x,title:h?.status||h?.eventStatus||"Status Update",description:h?.description||h?.actionNotes||"",timestamp:p}}):[],f={summary:c,timeline:u,notifications:o??[]};return i.jsx(ml,{data:f})};const hl=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),yl=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Gn=t=>{const e=yl(t);return e.charAt(0).toUpperCase()+e.slice(1)},la=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),pl=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var gl={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Sl=m.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:o,...c},l)=>m.createElement("svg",{ref:l,...gl,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:la("lucide",r),...!a&&!pl(c)&&{"aria-hidden":"true"},...c},[...o.map(([u,f])=>m.createElement(u,f)),...Array.isArray(a)?a:[a]]));const hs=(t,e)=>{const s=m.forwardRef(({className:n,...r},a)=>m.createElement(Sl,{ref:a,iconNode:e,className:la(`lucide-${hl(Gn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Gn(t),s};const xl=[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]],vl=hs("image-off",xl);const wl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Al=hs("loader-circle",wl);const Tl=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ca=hs("maximize-2",Tl);const Nl=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],bl=hs("minimize-2",Nl),kl=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,a]=m.useState(!1),[o,c]=m.useState(!1);return m.useEffect(()=>{t&&c(!1)},[t,s]),m.useEffect(()=>{t&&(!s||o)&&e()},[t,s,o,e]),t?i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70",role:"button",tabIndex:0,"aria-label":"Close media preview",onClick:e,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),e())},onTouchStart:e,children:i.jsxs("div",{className:`relative ${r?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:l=>l.stopPropagation(),children:[n==="image"?i.jsx("img",{src:s,alt:"preview",className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>c(!0)}):i.jsx("video",{src:s,controls:!0,className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>c(!0)}),i.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),i.jsx("button",{onClick:()=>a(!r),className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:r?i.jsx(bl,{size:20}):i.jsx(ca,{size:20})})]})}):null};function Il(t){if(!t||typeof t!="string")return!1;const e=t.split("?")[0].toLowerCase();return e.endsWith(".mp4")||e.endsWith(".webm")||e.endsWith(".ogg")||e.endsWith(".m3u8")}function Yn(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:Il(t?.mediaUrl||t)}function El(t){const e=t?.mediaUrl;let s=null;if(Array.isArray(e))s=e;else if(typeof e=="string")try{const n=JSON.parse(e);Array.isArray(n)&&(s=n)}catch{}return s&&s.length>0?s.map(n=>({...t,mediaUrl:n})):[t]}function Ml(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(El):[]}const Ol={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},jl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Cl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:c})=>{const[l,u]=m.useState(),[f,h]=m.useState(""),[x,p]=m.useState(!1),k=m.useRef(null),[j,M]=m.useState("details"),[G,L]=m.useState(void 0),$=qs(),{alerts:T,rules:D,config:B}=Me(),{timeZoneDetails:C}=fs(),[q,y]=m.useState(null),[g,O]=m.useState(!1),[oe,re]=m.useState(!1),[U,v]=m.useState(void 0),[S,I]=m.useState(void 0),[A,R]=m.useState({}),[F,Y]=m.useState({}),K=(b,_,w)=>{const H=F[b];return A[b]===!1&&!H?i.jsxs("div",{className:"w-full flex flex-col items-center justify-center min-h-[200px] bg-gray-100 rounded-lg gap-2 text-gray-400",children:[i.jsx(vl,{size:40}),i.jsx("span",{className:"text-sm",children:"Media not available"})]}):i.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[H&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(Al,{size:32,className:"animate-spin text-gray-400"})}),i.jsx("img",{src:b,alt:_.caption||`media-${w}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${H?"opacity-0":"opacity-100"}`,onLoad:()=>Y(z=>({...z,[b]:!1})),onError:()=>Y(z=>({...z,[b]:!1}))},b)]})},te=s?.originalData||{},{eventName:ae,anomalyName:ue,alertId:xe,timestamp:de,description:me,spaceName:ge,assignTeam:le,priority:ie,statusType:Te,id:Oe,alertDetails:He,statusHistory:ne,mediaDetails:Z,alertNumber:ve}=te,fe=b=>{const _=String(b||"").toLowerCase();return _==="delivered"||_==="sent"?"Delivered":_==="failed"?"Failed":"Queued"},Ne=b=>({name:b?.receipientName||b?.recipientName||"-",role:b?.receipientRoleName||"",phone:b?.receipentPhoneNumber||b?.recipientPhoneNumber||b?.receipientEmail||b?.recipientEmail||"",status:fe(b?.messageStatus),notificationReceipientType:b?.notificationReceipientType||""}),De=(b,_)=>{const w=_.map(Ne),H=w.filter(P=>P.status==="Delivered").length,z=_.map(P=>P?.sentAt).filter(Boolean).sort((P,J)=>new Date(J).getTime()-new Date(P).getTime())[0],E=_[0]||{},Q=[E?.severityName,E?.anomalyName].filter(Boolean).join(" - ")||`${b} Notification`;return{channelLabel:`${b} Notification`,sentAt:z||"",messageTitle:Q,messageBody:"",total:w.length,delivered:H,recipients:w}},$e=b=>{const _=new Map;return(b||[]).forEach(w=>{const H=String(w?.notificationType||"Unknown"),z=_.get(H)||[];z.push(w),_.set(H,z)}),Array.from(_.entries()).map(([w,H])=>De(w,H))},Pe=async b=>{try{const _=await T.getAlertNotifications(b),w=$e(_);L(w)}catch{L(void 0)}};m.useEffect(()=>{if(j!=="track"||!Oe)return;let b=!1;return Pe(Oe).then(()=>{b&&L(void 0)}),()=>{b=!0}},[j,Oe]),m.useEffect(()=>{t?M(o):(u(void 0),h(""))},[t,o]),m.useEffect(()=>{if(!t||B.tenant!=="snl")return;let b=!1;return O(!0),D.getLookups().then(_=>{b||(y(_.alertStatusTypes??[]),O(!1))}).catch(()=>{b||(y([]),O(!1))}),()=>{b=!0}},[t,B.tenant]);const Re=c==="archived"||["completed","false positive"].includes(String(Te||"").toLowerCase()),et=b=>{const _=String(b?.value||"").toLowerCase(),w=String(b?.statusName||"").toLowerCase();return _.includes("reopen")||w.includes("reopen")},mt=ue==="Elopement Attempt"||ue==="Elopement Completed",ft=r.filter(b=>{const _=et(b);return typeof c<"u"?c==="archived"?_:!_:Re?_:!_}).map(b=>({value:b.value,label:b.statusName})),Et=(q??[]).filter(b=>b.isElopementStatus===mt).map(b=>({value:b.alertStatusTypeName,label:b.alertStatusTypeName})),yt=B.tenant==="snl"&&q!==null?Et:ft,he=m.useMemo(()=>Ml(Z),[Z]);m.useEffect(()=>{let b=!1;const _=new AbortController,w=async E=>{if(E){b||R(Q=>({...Q,[E]:!1}));try{const Q=await fetch(E,{method:"HEAD",signal:_.signal});if(Q.ok){b||R(J=>({...J,[E]:!0}));return}if(Q.status===404){b||R(J=>({...J,[E]:!1}));return}if(!(await fetch(E,{method:"GET",signal:_.signal})).ok)throw new Error("Media not available");b||R(J=>({...J,[E]:!0}))}catch{b||R(Q=>({...Q,[E]:!1}))}}};R({});const H=he.filter(E=>!Yn(E)).map(E=>E?.mediaUrl||E).filter(E=>typeof E=="string"&&E.length>0),z={};return H.forEach(E=>{z[E]=!0}),Y(z),H.forEach(E=>w(E)),()=>{b=!0,_.abort()}},[he]);const pt=async()=>{try{p(!0);const b={alertUniqueId:xe,alertId:Oe,status:l?String(l):void 0,notes:f.trim(),modifiedBy:0},_=await $.mutateAsync(b);if(_?.responseStatus||_?.Success){const w=_?.Message||_?.data||"Alert updated successfully.";Ae.toast.success(w,{autoClose:1500,onClose:()=>{n(),e()}}),u(void 0),h("")}else{const w=_?.errorMessage||_?.Message||"Failed to update alert status";Ae.toast.error(w)}}catch(b){console.error("Error updating alert status:",b),Ae.toast.error("Failed to update alert status. Please try again.")}finally{p(!1)}};return i.jsx(d.Modal,{open:t,onCancel:e,width:1e3,footer:j==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(d.Button,{onClick:e,className:"bg-[#6C757D] text-white",children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:pt,loading:x,children:x?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(d.Tabs,{activeKey:j,onChange:b=>M(b),items:[{key:"details",label:"Alert Detail",children:i.jsxs("div",{className:"grid grid-cols-2 gap-2",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("div",{className:"text-sm font-bold",children:ae||"Alert Event"}),He?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",He?.firstName," ",He?.lastName||"","   ",He?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",is(de,C?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",me||"No description available"]}),ge&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",ge]}),le&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",le]}),i.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[i.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Ol[String(ie)]||"#DFE4EA"}`,backgroundColor:jl[String(ie)]},children:["Severity: ",ie||"N/A"]}),i.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Te||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Te||"N/A"]})]}),i.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:i.jsxs("div",{className:"w-full mt-4",children:[i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx(d.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:b=>u(b),value:l,options:yt,loading:B.tenant==="snl"?g:a})}),i.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[i.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),i.jsx("textarea",{id:"action-details-input",placeholder:"Enter details...",className:"w-full text-gray-500 h-20 border border-grey-500 rounded-md p-2",value:f,onChange:b=>h(b.target.value)})]})]})})]}),i.jsx("div",{className:"flex flex-col gap-4",children:i.jsxs("div",{className:"w-full mt-1",children:[i.jsxs("div",{className:"w-full flex items-center justify-between",children:[i.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),he.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>k.current?.prev?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Previous media",children:i.jsx(ct.LeftOutlined,{style:{fontSize:12}})}),i.jsx("button",{type:"button",onClick:()=>k.current?.next?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Next media",children:i.jsx(ct.RightOutlined,{style:{fontSize:12}})})]}):null]}),he.length?i.jsx("div",{className:"w-full",children:i.jsx(d.Carousel,{ref:k,dots:!0,className:"w-full",children:he.map((b,_)=>{const w=b.mediaUrl||b,H=Yn(b);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[H?i.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[i.jsx("source",{src:w}),"Your browser does not support the video tag."]}):K(String(w),b,_),b.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:b.caption}),!H&&A[String(w)]?i.jsx("button",{onClick:()=>{re(!0),v(w),I(b.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(ca,{size:20})}):null]},String(w)||_)})})}):null]})}),i.jsx(kl,{isOpen:oe,onClose:()=>re(!1),src:U||"",type:S||"image"})]})},{key:"track",label:"Track Incident",children:i.jsx(fl,{alertId:xe,id:Oe,priority:ie,spaceName:ge,alertNumber:ve,statusHistory:ne,notifGroups:G})}]})})};function ua(){const{alerts:t}=Me(),e=ut.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function tn({alerts:t,loading:e=!1,columns:s,total:n,currentPage:r,onRefetch:a,onPageChange:o,onFilterChange:c}){const[l,u]=m.useState(!1),[f,h]=m.useState(null),[x,p]=m.useState("details"),{list:k,loading:j}=ua(),{config:M}=Me(),G=M.tenant==="schools",{timeZoneDetails:L}=fs(),$=L?.timeZoneName??"UTC",T=L?.ianaTimeZoneId??"UTC";function D(oe,re){h(oe),p(re?.tab??"details"),q(re?.sourceTab??"active"),u(!0)}function B(){u(!1)}const[C,q]=m.useState("active"),[y,g]=m.useState(0),O=f?{originalData:{...f,alertId:f.alertId??f.id,mediaDetails:f.mediaDetails}}:null;return i.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[i.jsxs("div",{className:"w-full grid grid-cols-3 sm:grid-cols-1 items-center mb-4",children:[i.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),i.jsx("div",{className:"flex items-center justify-start sm:justify-center",children:i.jsx(ra,{label:$,timeZone:T})})]}),i.jsx(d.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:oe=>{const re=oe==="archived";g(U=>U+1),o?.(1),c?.({isArchived:re})},items:[{key:"active",label:"Active",children:i.jsx(Hs,{data:t,loading:e,pageSize:10,total:n,currentPage:r,columns:s||[],onAlertIdClick:D,onRefetch:a,onPageChange:o,onFilterChange:c,resetKey:y,serverSideFilters:G})},{key:"archived",label:"Archived",children:i.jsx(na,{alerts:t,loading:e,columns:s||[],total:n,currentPage:r,onAlertIdClick:D,onFilterChange:c,onPageChange:o,onRefetch:a,resetKey:y,serverSideFilters:G})},{key:"settings",label:"Settings",children:i.jsx(Dl,{})}]}),i.jsx(Cl,{isModalOpen:l,handleModalClose:B,selectedRow:O,fetchAlertLogs:()=>{},alertStatusList:k,alertStatusLoading:j,initialTab:x,sourceTab:C})]})}function Dl(){const[t,e]=m.useState([]),[s,n]=m.useState([]),[r,a]=m.useState([]),[o,c]=m.useState([]),[l,u]=m.useState(!0),{rules:f}=Me();return m.useEffect(()=>{let h=!0;return(async()=>{try{const x=await f.getRules();if(!h)return;c(Array.isArray(x)?x:[]);const p=(x||[]).map((k,j)=>({RuleId:k.ruleId||k.ruleName||String(j),Name:k.ruleName||k.Name||"-",Description:k.ruleDesc||k.Description||"",SeverityId:0}));e(p);try{const k=await f.getLookups(),j=Array.isArray(k?.userRoles)?k.userRoles.map(M=>({userRoleId:M.userRoleId??M.id,userRoleName:M.userRoleName??M.name})):[];n(j),a(Array.isArray(k?.severities)?k.severities:[])}catch{}}catch{}finally{h&&u(!1)}})(),()=>{h=!1}},[]),i.jsx(oa,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:l})}function Rl(t){return Array.isArray(t)?{items:t}:t}function da(t=1,e){const{alerts:s}=Me(),n=ut.useQuery({queryKey:["alerts","list",t,e],queryFn:()=>s.listAlerts({pageNumber:t,pageSize:10,...e}).then(Rl),staleTime:3e4});return{alerts:n.data?.items??[],total:n.data?.total,loading:n.isLoading,error:n.error,refetch:n.refetch}}function Ul(t){const[e,s]=m.useState(1),[n,r]=m.useState({}),{alerts:a,total:o,loading:c,refetch:l}=da(e,n),u=f=>{"isArchived"in f?r({isArchived:f.isArchived}):r(h=>({...h,...f}))};return i.jsx(tn,{alerts:a,loading:c,columns:t.columns,total:o,currentPage:e,onRefetch:l,onPageChange:s,onFilterChange:u})}function Ll({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,alerts:c,loading:l,columns:u}){const[f]=m.useState(()=>new ut.QueryClient),h=m.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(ut.QueryClientProvider,{client:f,children:i.jsx(Xn,{tenant:t,override:h,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,children:Array.isArray(c)?i.jsx(tn,{alerts:c,loading:!!l,columns:u}):i.jsx(Ul,{columns:u})})})}function Fl(t){const{alerts:e}=Me(),s=ut.useQuery({queryKey:["alerts","report",t],queryFn:()=>e.getAlertsReport(t),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const $l=[{title:"ID",dataIndex:"id",key:"id",width:120},{title:"Priority",dataIndex:"priority",key:"priority",width:120},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:220},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description"}];exports.AlertAssignment=aa;exports.AlertConsole=tn;exports.AlertConsoleWidget=Ll;exports.AlertsTable=Hs;exports.ApiProvider=Xn;exports.ArchivedTable=na;exports.Clock=ra;exports.DataTable=er;exports.MyPreferencesPanel=ll;exports.SettingsPanel=ia;exports.SettingsTabs=oa;exports.exampleAlertColumns=$l;exports.useAlertStatusList=ua;exports.useAlerts=da;exports.useAlertsReport=Fl;exports.useApi=Me;exports.useUpdateAlertStatus=qs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),m=require("react"),d=require("antd"),ct=require("@ant-design/icons"),Ae=require("react-toastify"),ut=require("@tanstack/react-query"),fa="#FF3B30",ha="#FF9500",ya="#FFCC00",pa="#34C759",Wt={critical:fa,high:ha,medium:ya,low:pa},ln={Critical:Wt.critical,High:Wt.high,Medium:Wt.medium,Low:Wt.low};function ga(t){return ln[t]||ln.Low}function cn(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,a=Number.parseInt(s,10),o=Number.parseInt(n,10),c=Number.parseFloat(r||"0"),l=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o:0,f=Number.isFinite(c)?c:0;return l*3600+u*60+f}function un(t){const e=t.thirdPartyIds??t.ThirdPartyIds??t.thirdPartyId??t.ThirdPartyId??"",s=Array.isArray(e)?e.join(","):String(e??"");if(!s||!s.trim())return[];const n=s.split(",").map(o=>parseInt(String(o).trim(),10)).filter(o=>Number.isFinite(o)),r=new Set,a=[];return n.forEach(o=>{r.has(o)||(r.add(o),a.push(o))}),a}function ss(t){return t.toLowerCase().replaceAll("'","").replaceAll("‘","").replaceAll("’","")}const Jn="",Sa=Jn,xa="",va="",wa="",Aa="",dn={snl:{alerts:Jn,rules:Sa},schools:{alerts:xa,rules:va},transit:{alerts:wa,rules:Aa}};function Ue(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ta(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Vt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Le(t,e){const s={...e.headers,...Ta()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Na(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ue(t.baseUrl,"/api/Alert"),n=await Le(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ue(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Le(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=Ue(t.baseUrl,"/Alerts/GetAlertsReport"),r=Vt(n,s),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=Ue(t.baseUrl,"/api/Alert/status");return Le(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ue(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Le(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=Ue(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Le(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ue(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Le(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=Ue(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Le(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=Ue(t.baseUrl,"/api/Alert/GetNotifications"),r=Vt(n,{alertId:s}),a=await Le(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async notifyFamilyMembers(s){const n=Ue(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Vt(n,{alertId:s});return Le(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const a=Ue(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Vt(a,{alertId:s,isEmail:n,isSMS:r});return Le(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ue(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Le(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ue(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Le(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}function mn(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function ba(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Bt(t,e){const s={...e.headers,...ba()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function ka(t){const e={"Content-Type":"application/json",...t.headers||{}},s=mn(t.baseUrl,"/api/Rules"),n=mn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Bt(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Bt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Bt(n,{method:"GET",headers:e})},async updateRule(r,a){const o=`${s}/${r}`;return Bt(o,{method:"PUT",headers:e,body:JSON.stringify(a??{})})}}}function Ia(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Qt={exports:{}},Ea=Qt.exports,fn;function Ma(){return fn||(fn=1,(function(t,e){(function(s,n){t.exports=n()})(Ea,(function(){var s=1e3,n=6e4,r=36e5,a="millisecond",o="second",c="minute",l="hour",u="day",f="week",h="month",x="quarter",p="year",k="date",j="Invalid Date",M=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,G=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,L={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(U){var v=["th","st","nd","rd"],S=U%100;return"["+U+(v[(S-20)%10]||v[S]||v[0])+"]"}},$=function(U,v,S){var I=String(U);return!I||I.length>=v?U:""+Array(v+1-I.length).join(S)+U},T={s:$,z:function(U){var v=-U.utcOffset(),S=Math.abs(v),I=Math.floor(S/60),A=S%60;return(v<=0?"+":"-")+$(I,2,"0")+":"+$(A,2,"0")},m:function U(v,S){if(v.date()<S.date())return-U(S,v);var I=12*(S.year()-v.year())+(S.month()-v.month()),A=v.clone().add(I,h),R=S-A<0,F=v.clone().add(I+(R?-1:1),h);return+(-(I+(S-A)/(R?A-F:F-A))||0)},a:function(U){return U<0?Math.ceil(U)||0:Math.floor(U)},p:function(U){return{M:h,y:p,w:f,d:u,D:k,h:l,m:c,s:o,ms:a,Q:x}[U]||String(U||"").toLowerCase().replace(/s$/,"")},u:function(U){return U===void 0}},D="en",B={};B[D]=L;var C="$isDayjsObject",q=function(U){return U instanceof oe||!(!U||!U[C])},y=function U(v,S,I){var A;if(!v)return D;if(typeof v=="string"){var R=v.toLowerCase();B[R]&&(A=R),S&&(B[R]=S,A=R);var F=v.split("-");if(!A&&F.length>1)return U(F[0])}else{var Y=v.name;B[Y]=v,A=Y}return!I&&A&&(D=A),A||!I&&D},g=function(U,v){if(q(U))return U.clone();var S=typeof v=="object"?v:{};return S.date=U,S.args=arguments,new oe(S)},O=T;O.l=y,O.i=q,O.w=function(U,v){return g(U,{locale:v.$L,utc:v.$u,x:v.$x,$offset:v.$offset})};var oe=(function(){function U(S){this.$L=y(S.locale,null,!0),this.parse(S),this.$x=this.$x||S.x||{},this[C]=!0}var v=U.prototype;return v.parse=function(S){this.$d=(function(I){var A=I.date,R=I.utc;if(A===null)return new Date(NaN);if(O.u(A))return new Date;if(A instanceof Date)return new Date(A);if(typeof A=="string"&&!/Z$/i.test(A)){var F=A.match(M);if(F){var Y=F[2]-1||0,K=(F[7]||"0").substring(0,3);return R?new Date(Date.UTC(F[1],Y,F[3]||1,F[4]||0,F[5]||0,F[6]||0,K)):new Date(F[1],Y,F[3]||1,F[4]||0,F[5]||0,F[6]||0,K)}}return new Date(A)})(S),this.init()},v.init=function(){var S=this.$d;this.$y=S.getFullYear(),this.$M=S.getMonth(),this.$D=S.getDate(),this.$W=S.getDay(),this.$H=S.getHours(),this.$m=S.getMinutes(),this.$s=S.getSeconds(),this.$ms=S.getMilliseconds()},v.$utils=function(){return O},v.isValid=function(){return this.$d.toString()!==j},v.isSame=function(S,I){var A=g(S);return this.startOf(I)<=A&&A<=this.endOf(I)},v.isAfter=function(S,I){return g(S)<this.startOf(I)},v.isBefore=function(S,I){return this.endOf(I)<g(S)},v.$g=function(S,I,A){return O.u(S)?this[I]:this.set(A,S)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(S,I){var A=this,R=!!O.u(I)||I,F=O.p(S),Y=function(ge,le){var ie=O.w(A.$u?Date.UTC(A.$y,le,ge):new Date(A.$y,le,ge),A);return R?ie:ie.endOf(u)},K=function(ge,le){return O.w(A.toDate()[ge].apply(A.toDate("s"),(R?[0,0,0,0]:[23,59,59,999]).slice(le)),A)},te=this.$W,ae=this.$M,ue=this.$D,xe="set"+(this.$u?"UTC":"");switch(F){case p:return R?Y(1,0):Y(31,11);case h:return R?Y(1,ae):Y(0,ae+1);case f:var de=this.$locale().weekStart||0,me=(te<de?te+7:te)-de;return Y(R?ue-me:ue+(6-me),ae);case u:case k:return K(xe+"Hours",0);case l:return K(xe+"Minutes",1);case c:return K(xe+"Seconds",2);case o:return K(xe+"Milliseconds",3);default:return this.clone()}},v.endOf=function(S){return this.startOf(S,!1)},v.$set=function(S,I){var A,R=O.p(S),F="set"+(this.$u?"UTC":""),Y=(A={},A[u]=F+"Date",A[k]=F+"Date",A[h]=F+"Month",A[p]=F+"FullYear",A[l]=F+"Hours",A[c]=F+"Minutes",A[o]=F+"Seconds",A[a]=F+"Milliseconds",A)[R],K=R===u?this.$D+(I-this.$W):I;if(R===h||R===p){var te=this.clone().set(k,1);te.$d[Y](K),te.init(),this.$d=te.set(k,Math.min(this.$D,te.daysInMonth())).$d}else Y&&this.$d[Y](K);return this.init(),this},v.set=function(S,I){return this.clone().$set(S,I)},v.get=function(S){return this[O.p(S)]()},v.add=function(S,I){var A,R=this;S=Number(S);var F=O.p(I),Y=function(ae){var ue=g(R);return O.w(ue.date(ue.date()+Math.round(ae*S)),R)};if(F===h)return this.set(h,this.$M+S);if(F===p)return this.set(p,this.$y+S);if(F===u)return Y(1);if(F===f)return Y(7);var K=(A={},A[c]=n,A[l]=r,A[o]=s,A)[F]||1,te=this.$d.getTime()+S*K;return O.w(te,this)},v.subtract=function(S,I){return this.add(-1*S,I)},v.format=function(S){var I=this,A=this.$locale();if(!this.isValid())return A.invalidDate||j;var R=S||"YYYY-MM-DDTHH:mm:ssZ",F=O.z(this),Y=this.$H,K=this.$m,te=this.$M,ae=A.weekdays,ue=A.months,xe=A.meridiem,de=function(le,ie,Te,Oe){return le&&(le[ie]||le(I,R))||Te[ie].slice(0,Oe)},me=function(le){return O.s(Y%12||12,le,"0")},ge=xe||function(le,ie,Te){var Oe=le<12?"AM":"PM";return Te?Oe.toLowerCase():Oe};return R.replace(G,(function(le,ie){return ie||(function(Te){switch(Te){case"YY":return String(I.$y).slice(-2);case"YYYY":return O.s(I.$y,4,"0");case"M":return te+1;case"MM":return O.s(te+1,2,"0");case"MMM":return de(A.monthsShort,te,ue,3);case"MMMM":return de(ue,te);case"D":return I.$D;case"DD":return O.s(I.$D,2,"0");case"d":return String(I.$W);case"dd":return de(A.weekdaysMin,I.$W,ae,2);case"ddd":return de(A.weekdaysShort,I.$W,ae,3);case"dddd":return ae[I.$W];case"H":return String(Y);case"HH":return O.s(Y,2,"0");case"h":return me(1);case"hh":return me(2);case"a":return ge(Y,K,!0);case"A":return ge(Y,K,!1);case"m":return String(K);case"mm":return O.s(K,2,"0");case"s":return String(I.$s);case"ss":return O.s(I.$s,2,"0");case"SSS":return O.s(I.$ms,3,"0");case"Z":return F}return null})(le)||F.replace(":","")}))},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(S,I,A){var R,F=this,Y=O.p(I),K=g(S),te=(K.utcOffset()-this.utcOffset())*n,ae=this-K,ue=function(){return O.m(F,K)};switch(Y){case p:R=ue()/12;break;case h:R=ue();break;case x:R=ue()/3;break;case f:R=(ae-te)/6048e5;break;case u:R=(ae-te)/864e5;break;case l:R=ae/r;break;case c:R=ae/n;break;case o:R=ae/s;break;default:R=ae}return A?R:O.a(R)},v.daysInMonth=function(){return this.endOf(h).$D},v.$locale=function(){return B[this.$L]},v.locale=function(S,I){if(!S)return this.$L;var A=this.clone(),R=y(S,I,!0);return R&&(A.$L=R),A},v.clone=function(){return O.w(this.$d,this)},v.toDate=function(){return new Date(this.valueOf())},v.toJSON=function(){return this.isValid()?this.toISOString():null},v.toISOString=function(){return this.$d.toISOString()},v.toString=function(){return this.$d.toUTCString()},U})(),re=oe.prototype;return g.prototype=re,[["$ms",a],["$s",o],["$m",c],["$H",l],["$W",u],["$M",h],["$y",p],["$D",k]].forEach((function(U){re[U[1]]=function(v){return this.$g(v,U[0],U[1])}})),g.extend=function(U,v){return U.$i||(U(v,oe,g),U.$i=!0),g},g.locale=y,g.isDayjs=q,g.unix=function(U){return g(1e3*U)},g.en=B[D],g.Ls=B,g.p={},g}))})(Qt)),Qt.exports}var Oa=Ma();const ja=Ia(Oa);function Kn(t){if(!t)return"By Severity";const e=t.trim().toLowerCase();return e.includes("created")?"By Created Date":e.includes("updated")||e.includes("modified")?"By Updated Date":"By Severity"}function Qn(t){if(!t||typeof t!="string")return{hours:0,minutes:0,seconds:0};const e=t.split(":").map(a=>parseInt(a,10)),s=Number.isFinite(e[0])?e[0]:0,n=Number.isFinite(e[1])?e[1]:0,r=Number.isFinite(e[2])?e[2]:0;return{hours:s,minutes:n,seconds:r}}function hn(t){const{hours:e,minutes:s,seconds:n}=Qn(t);return ja().hour(e).minute(s).second(n).millisecond(0)}function je(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Ca(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Zt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ce(t,e){const s={...e.headers,...Ca()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.Message||`HTTP ${n.status}`;throw new Error(o)}return a}const ce=(...t)=>t.find(e=>e!=null);function Ot(t,e,s={}){const n={};for(const r of e){const a=s[r]??r.charAt(0).toUpperCase()+r.slice(1);n[r]=t?.[a]??t?.[r]}return n}function Da(t){return Array.isArray(t)?t.map(e=>Ot(e,["alertLogId","alertId","status","description","actionNotes","createdDate","createdBy","modifiedDate","modifiedBy"])):t}function Ra(t){return{id:String(ce(t?.AlertId,t?.alertId)??""),alertNumber:ce(t?.AlertNumber,t?.alertNumber),priority:ce(t?.Priority,t?.priority,"Low"),timestamp:ce(t?.UpdatedUtc,t?.timestamp,""),statusType:ce(t?.Status,t?.statusType,""),description:ce(t?.Description,t?.description,""),eventName:ce(t?.EventName,t?.eventName),ruleName:ce(t?.RuleName,t?.ruleName),spaceId:ce(t?.SpaceId,t?.spaceId),spaceName:ce(t?.SpaceName,t?.spaceName),anomalyId:ce(t?.AnomalyId,t?.anomalyId),severityId:ce(t?.SeverityId,t?.severityId),assignTeam:ce(t?.AssignTeam,t?.assignTeam),cameraName:ce(t?.CameraName,t?.cameraName),type:ce(t?.Type,t?.type),mediaDetails:ce(t?.MediaDetails,t?.mediaDetails,t?.MediaUrls,t?.mediaUrls),additionalMedia:ce(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:ce(t?.TimeElapsed,t?.timeElapsed),timeRemaining:ce(t?.TimeRemaining,t?.timeRemaining),anomalyName:ce(t?.AnomalyName,t?.anomalyName),alertDetails:ce(t?.AlertDetails,t?.alertDetails),statusHistory:Da(ce(t?.StatusHistory,t?.statusHistory)),isEmailSent:ce(t?.IsEmailSent,t?.isEmailSent),isSMSSent:ce(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:ce(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function Ua(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts"),r=Zt(n,{customerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",pageSize:s?.pageSize??10,page:s?.pageNumber??1,...s?.anomalyId!==void 0&&{anomalyId:s.anomalyId},...s?.spaceId!==void 0&&{spaceId:s.spaceId},...s?.severityId!==void 0&&{severityId:s.severityId},...s?.thirdPartyIds?.length&&{ThirdPartyIds:s.thirdPartyIds.join(",")},isArchived:s?.isArchived??!1}),a=await Ce(r,{method:"GET",headers:e});return{items:Array.isArray(a?.Items)?a.Items.map(Ra):[],total:a?.Total}},async getAlertStatusList(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n)?n:[]).map(a=>Ot(a,["alertStatusId","value","statusName"]))},async getAlertsReport(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=Zt(n,s),a=await Ce(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/Log"),r={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n.Data??n;if(r&&typeof r=="object")return Ot(r,["userId","isAdminSetting","sortBy"],{sortBy:"SortOption"})}return null},async setAdminSettings(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={Settings:{UserId:0,IsAdminSetting:!0,SortOption:s?.sortBy??"",GroupBy:s?.groupBy??null}};return Ce(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=je(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await Ce(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=u=>{const{hours:f,minutes:h,seconds:x}=Qn(u);return(f*3600+h*60+x)*1e7},a={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(u=>String(u)):[],DoNotDisturbStart:{Ticks:r(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:r(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},o=await Ce(n,{method:"POST",headers:e,body:JSON.stringify(a)}),c=o?.responseStatus??!0,l=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:c,errorMessage:c?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:l}},async sendSMSorEmailNotifications(s,n,r){const a=je(t.baseUrl,"/api/detectionpolicy/alerts/SendSMSorEmailNotifications"),o=Zt(a,{alertId:s,isEmail:n,isSMS:r});return Ce(o,{method:"POST",headers:e})},async getAlertNotifications(s){const n=je(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=Zt(n,{alertId:s}),a=await Ce(r,{method:"GET",headers:e});let o=[];return Array.isArray(a)?o=a:Array.isArray(a?.data)&&(o=a.data),o.map(c=>Ot(c,["alertNotificationSentId","alertId","notificationType","receipientName","receipentPhoneNumber","messageSID","messageStatus","receipientEmail","notificationReceipientType","sentAt"]))},async getTimeZoneMasters(){const s=je(t.baseUrl,"/api/TimeZoneMaster"),n=await Ce(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n.Data:[]).map(a=>Ot(a,["timeZoneUniqueId","ianaTimeZoneId","timeZoneName","offset"]))},async getAllSpaces(){const s=t.spacesBaseUrl||t.baseUrl,n=je(s,"/api/AllSpaces"),r=await Ce(n,{method:"GET",headers:e});return(Array.isArray(r?.Data)?r.Data:[]).map(o=>({spaceId:o?.SpaceId??o?.spaceId,spaceName:o?.SpaceName??o?.spaceName??""}))},async getMyAppPreferences(){const s=je(t.baseUrl,"/MyProfile"),n=await Ce(s,{method:"GET",headers:e}),r=n?.data?.userGuid??n?.Data?.userGuid??n?.userGuid;if(!r)return null;const a=je(t.baseUrl,`/api/GetMyAppPreferences/${r}`),o=await Ce(a,{method:"GET",headers:e});if(o&&typeof o=="object"){const c=o.data??o.Data??o,l=c?.timeZoneUniqueId??c?.TimeZoneUniqueId;if(l)return{timeZoneUniqueId:l}}return null}}}function La(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Je(t,e){const s={...e.headers,...La()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Fa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await Je(s,{method:"GET",headers:e});return(Array.isArray(n?.Data)?n?.Data:[]).map(a=>({...a,ruleId:a.ruleId??a.RuleId,ruleName:a.ruleName??a.RuleName??a.Name,escalationSettings:a.escalationSettings??a.EscalationSettings}))},async setEscalationSettings(n){return Je(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=y=>new URL(y,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[Je(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),Je(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e}),Je(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,c,l,u,f,h]=await Promise.allSettled(a),x=y=>{if(y.status!=="fulfilled")return[];const g=y.value;return Array.isArray(g)?g:Array.isArray(g?.Data)?g.Data:Array.isArray(g?.data)?g.data:[]},p=x(o),k=x(c),j=x(l),M=x(u),G=x(f),L=h.status==="fulfilled"?h.value:null;let $=[];Array.isArray(L)?$=L:Array.isArray(L?.Data)?$=L.Data:Array.isArray(L?.data)&&($=L.data);const T=p.map(y=>({actionTypeId:Number(y?.ActionTypeId),name:y?.DisplayName??y?.Name??""})),D=k.map(y=>({recordId:y?.AnomalyId,anomalyName:y?.DisplayName??y?.Name??""})),B=j.map(y=>({thirdPartyId:Number(y?.ThirdPartyId),thirdPartyName:y?.ThirdPartyName??y?.Name??""})),C=$.map(y=>({userRoleId:y.UserRoleId??y.userRoleId??y.Id??y.id??0,userRoleName:y.UserRoleName??y.userRoleName??y.Name??y.name??""})),q={actionTypes:T,anomalies:D,thirdParties:B};return M.length&&(q.severities=M.map(y=>({severityId:y?.SeverityId??y?.severityId,severityName:y?.DisplayName??y?.SeverityName??y?.Name??y?.name??""}))),G.length&&(q.scheduleTypes=G),C.length&&(q.userRoles=C),q},async updateRule(n,r){const a=`${s}/${n}`,{escalationSettings:o,Anomaly:c,Severity:l,...u}=r??{};return Je(a,{method:"PUT",headers:e,body:JSON.stringify({...u,CustomerId:"99e5c8b5-b9d4-4d35-8885-7f121c532664",Version:{DeDupWindowSeconds:0,IncludeSubjectInHash:!0},AnomalyId:c?.AnomalyId,SeverityId:l?.SeverityId,EscalationSettings:o?{...o,ThirdPartyIds:o.thirdPartyId??[]}:{}})})}}}function $a(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function tt(t,e){const s={...e.headers,...$a()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Pa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/list-rule",t.baseUrl).toString();return{async getRules(){const n=await tt(s,{method:"POST",headers:e,body:JSON.stringify({command:"get-all"})});return(Array.isArray(n?.data)?n.data:[]).map(a=>({...a,ruleId:a.RuleId??a.ruleId,ruleName:a.RuleName??a.ruleName,ruleDesc:a.RuleDesc??a.ruleDesc??null}))},async setEscalationSettings(n){return tt(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=C=>new URL(C,t.baseUrl).toString(),r=t.userManagementBaseUrl||t.baseUrl,a=[tt(n("/api/ActionTypeMaster/GetAll"),{method:"GET",headers:e}),tt(n("/api/anomaly/anomaly-list"),{method:"POST",headers:e,body:JSON.stringify({RuleLevel:1})}),tt(n("/api/Lookup/ThirdParties"),{method:"GET",headers:e}),tt(n("/api/anomaly/severity-list"),{method:"GET",headers:e}),tt(new URL("/user/user-roles",r).toString(),{method:"GET",headers:e})],[o,c,l,u,f]=await Promise.allSettled(a),h=C=>{if(C.status!=="fulfilled")return[];const q=C.value;return Array.isArray(q)?q:Array.isArray(q?.data)?q.data:[]},x=h(o),p=h(c),k=h(l),j=h(u),M=f.status==="fulfilled"?f.value:null,G=x.map(C=>({actionTypeId:C?.ActionTypeUniqueId,name:C?.Name??""})),L=p.map(C=>({recordId:C?.AnomalyId,anomalyName:C?.DisplayName??C?.Name??""})),$=k.map(C=>({thirdPartyId:Number(C?.ThirdPartyId),thirdPartyName:C?.ThirdPartyName??C?.Name??""}));let T=[];Array.isArray(M)?T=M:Array.isArray(M?.Data)?T=M.Data:Array.isArray(M?.data)&&(T=M.data);const D=T.map(C=>({userRoleId:C.userRoleId??0,userRoleName:C.userRoleName??""})),B={actionTypes:G,anomalies:L,thirdParties:$};return j.length&&(B.severities=j.map(C=>({SeverityId:C.SeverityId,DisplayName:C.SeverityName??C.DisplayName??""}))),D.length&&(B.userRoles=D),B},async updateRule(n,r){const a=new URL("/update-rule",t.baseUrl).toString(),{escalationSettings:o,ruleId:c,ruleName:l,ruleDesc:u,...f}=r??{},h=o??{},x=(h.escalationSettingsActionTypeIds??[]).filter(k=>k!=null&&!Number.isNaN(k)),p={Level1UserRoleId:h.level1UserRoleId??0,Level1PostAssistTime:h.level1PostAssistTime??0,Level2UserRoleId:h.level2UserRoleId??0,Level2PostAssistTime:h.level2PostAssistTime??0,Level3UserRoleId:h.level3UserRoleId??0,Level3PostAssistTime:h.level3PostAssistTime??0,EscalationSettingsActionTypeIds:x,ThirdPartyIds:h.thirdPartyId??[],HumanLoop:h.humanLoop??!1};return tt(a,{method:"POST",headers:e,body:JSON.stringify({...f,RuleId:c??f.RuleId??n,RuleName:l??f.RuleName,RuleDesc:u??f.RuleDesc??null,ActionTypeUniqueIdList:x,EscalationSettings:p})})}}}function We(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function Wa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function zt(t,e){if(!e)return t;const s=new URL(t);return Object.entries(e).forEach(([n,r])=>{r!=null&&String(r).length>0&&s.searchParams.set(n,String(r))}),s.toString()}async function Ve(t,e){const s={...e.headers,...Wa()},n=await fetch(t,{...e,headers:s});if(n.status===401)throw window.location.href="/login",new Error("Unauthorized");if(n.status===204)return{};const r=await n.text();let a={};if(r)try{a=JSON.parse(r)}catch{a={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const o=a?.errorMessage||a?.message||`HTTP ${n.status}`;throw new Error(o)}return a}function Va(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(s){const n=We(t.baseUrl,"/api/Alerts"),r=zt(n,{pageSize:s?.pageSize??10,pageNumber:s?.pageNumber??1}),a=await Ve(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async getAlertStatusList(){const s=We(t.baseUrl,"/api/Alerts/GetAlertStatus"),n=await Ve(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getAlertsReport(s){const n=We(t.baseUrl,"/Alerts/GetAlertsReport"),r=zt(n,s),a=await Ve(r,{method:"GET",headers:e});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const n=We(t.baseUrl,"/api/Alerts/UpdateAlertLog"),r={alertId:s.alertId,action:s.status,notes:s.notes};return Ve(n,{method:"PUT",headers:e,body:JSON.stringify(r??{})})},async getAdminSettings(){const s=We(t.baseUrl,"/api/Alerts/GetAdminSettings"),n=await Ve(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("userId"in n)return n}return null},async setAdminSettings(s){const n=We(t.baseUrl,"/api/Alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Ve(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=We(t.baseUrl,"/api/Alerts/GetPreferenceSettings"),n=await Ve(s,{method:"GET",headers:e});if(n&&typeof n=="object"){if("data"in n)return n.data;if("anomalyIds"in n)return n}return null},async setPreferenceSettings(s){const n=We(t.baseUrl,"/api/Alerts/SetPreferenceSettings"),r=await Ve(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),a=r?.responseStatus??!0,o=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":r?.errorMessage??r?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const n=We(t.baseUrl,"/api/Alerts/GetNotifications"),r=zt(n,{alertId:s}),a=await Ve(r,{method:"GET",headers:e});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async sendSMSorEmailNotifications(s,n,r){const a=We(t.baseUrl,"/api/Alerts/SendSMSorEmailNotifications"),o=zt(a,{alertId:s,isEmail:n,isSMS:r});return Ve(o,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=We(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Ve(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=We(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Ve(s,{method:"GET",headers:e});if(n&&typeof n=="object"){const r=n.data??n;if(r?.timeZoneUniqueId)return{timeZoneUniqueId:r.timeZoneUniqueId}}return null}}}const Xn=m.createContext(null);function er({tenant:t="snl",override:e,timeZone:s,userManagementDomain:n,spacesBaseUrl:r,children:a}){const o=m.useMemo(()=>{const l=e?.alertsBaseUrl?.trim()||dn[t]?.alerts||"";let u=e?.rulesBaseUrl?.trim()||dn[t]?.rules||"";t==="snl"&&(u=l);const f=e?.headers;return{tenant:t,alertsBaseUrl:l,rulesBaseUrl:u,headers:f,timeZone:s,userManagementDomain:n,spacesBaseUrl:r}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{}),s,n,r]),c=m.useMemo(()=>{const l={baseUrl:o.alertsBaseUrl,headers:o.headers},u={baseUrl:o.rulesBaseUrl,headers:o.headers},f={schools:()=>Ua({...l,spacesBaseUrl:o.spacesBaseUrl}),transit:()=>Va(l),snl:()=>Na(l)},h={schools:()=>Fa({...u,userManagementBaseUrl:o.userManagementDomain}),transit:()=>Pa({...u,userManagementBaseUrl:o.userManagementDomain}),snl:()=>ka({baseUrl:o.alertsBaseUrl,headers:o.headers})};return{config:o,alerts:f[o.tenant](),rules:h[o.tenant]()}},[o]);return i.jsx(Xn.Provider,{value:c,children:a})}function Me(){const t=m.useContext(Xn);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const Ba={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Za={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},zs=6,Hs=7;function yn(t,e,s){const n=t===zs,r=t===Hs,a=e.isEmailSent??!1,o=e.isSMSSent??!1,c=n&&a||r&&o,l=n?"Send Email":r?"Send SMS":s,u=n&&a?"Email sent":r&&o?"SMS sent":l,f=n&&a?"Email sent":r&&o?"SMS sent":`Click to ${l}`;return{isDisabled:c,buttonText:u,tooltipTitle:f}}function za(t){const e=new Set;(t||[]).forEach(n=>{const r=n.anomalyName;typeof r=="string"&&r.trim().length>0&&e.add(r.trim())});const s=Array.from(e).map(n=>({label:n,value:n}));return[{label:"All Types",value:"All"},...s]}function Ha(t){const e=new Set;(t||[]).forEach(n=>{const r=n.spaceName;typeof r=="string"&&r.trim().length>0&&e.add(r.trim())});const s=Array.from(e).map(n=>({label:n,value:n}));return[{label:"All",value:"All"},...s]}function vs(t,e){return`${t}-${e?"email":"sms"}`}function Ht(t){return t===zs||t===Hs}function ls({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return i.jsx(d.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const qa=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Ga({value:t,onChange:e,options:s}){return i.jsx(ls,{className:"w-[140px]",value:t,onChange:e,options:s||qa})}const Ya=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function _a({value:t,onChange:e,options:s}){return i.jsx(ls,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||Ya})}function Ja({value:t,onChange:e,options:s}){return i.jsx(ls,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const Ka=[{label:"All",value:"All"},{label:"SOS",value:"SOS"},{label:"911",value:"911"},{label:"Aegix",value:"Aegix"},{label:"Eli",value:"Eli"},{label:"Skydio",value:"Skydio"}];function Qa({value:t,onChange:e,options:s}){return i.jsx(ls,{className:"w-[130px]",value:t,onChange:e,options:s||Ka})}function tr({columns:t,data:e,loading:s=!1,pageSize:n=10,total:r,currentPage:a,rowKey:o="id",toolbar:c,tableProps:l,onPageChange:u}){const f=r!==void 0;return i.jsxs("div",{children:[c,i.jsx(d.Table,{rowKey:o,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,...f?{total:r,current:a}:{},showSizeChanger:!1,showTotal:h=>`Total: ${h}`,onChange:u},bordered:!0,...l})]})}const sr=["completed","false positive","face doesn't match name","safe","supervised exit","elopement confirmed"];function qs({data:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,columns:a,severityOptions:o,anomalyOptions:c,spaceOptions:l,renderActions:u,onAlertIdClick:f,onRefetch:h,onPageChange:x,onFilterChange:p,excludeCompleted:k=!0,resetKey:j,serverSideFilters:M=!1}){const[G,L]=m.useState("All"),[$,T]=m.useState("All"),[D,B]=m.useState("All"),[C,q]=m.useState("All"),[y,g]=m.useState("");m.useEffect(()=>{j!==void 0&&(L("All"),T("All"),B("All"),q("All"),g(""))},[j]);const[O,oe]=m.useState([{label:"All",value:"All"}]),[re,U]=m.useState([]),[v,S]=m.useState([]),[I,A]=m.useState([]),[R,F]=m.useState(new Set),{rules:Y,alerts:K}=Me(),te={6:{title:"Email",kind:"icon",icon:i.jsx(ct.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:i.jsx(ct.MessageOutlined,{})}},ae=m.useMemo(()=>za(t),[t]),ue=m.useMemo(()=>Ha(t),[t]);m.useEffect(()=>{if(!K.getAllSpaces)return;let ne=!0;return(async()=>{try{const Z=await K.getAllSpaces();if(ne){const ve=Z.map(fe=>({label:fe.spaceName,value:String(fe.spaceId)}));U([{label:"All",value:"All"},...ve])}}catch(Z){console.error("Error loading space options",Z)}})(),()=>{ne=!1}},[K]),m.useEffect(()=>{let ne=!0;return(async()=>{try{const Z=await Y.getLookups(),fe=(Array.isArray(Z.thirdParties)?Z.thirdParties:[]).map(we=>({label:we.thirdPartyName,value:String(we.thirdPartyId)})),De=(Array.isArray(Z.anomalies)?Z.anomalies:[]).map(we=>({label:we.anomalyName,value:String(we.recordId)})),Pe=(Array.isArray(Z.severities)?Z.severities:[]).map(we=>({label:we.severityName,value:String(we.severityId)}));ne&&(oe([{label:"All",value:"All"},...fe]),De.length&&S([{label:"All Types",value:"All"},...De]),Pe.length&&A([{label:"All levels",value:"All"},...Pe]))}catch(Z){console.error("Error loading filter options",Z)}})(),()=>{ne=!1}},[Y]);const xe=m.useMemo(()=>(t||[]).some(ne=>un(ne).length>0),[t]);m.useEffect(()=>{if(M&&p){const ne={anomalyId:v.length>1&&$!=="All"?$:void 0,spaceId:re.length>1&&D!=="All"?Number(D):void 0,severityId:I.length>1&&G!=="All"?Number(G):void 0,thirdPartyIds:C==="All"?void 0:[Number(C)]};p(ne)}x?.(1)},[$,D,G,C,v.length,re.length,I.length]);const de=m.useMemo(()=>{const ne=M;return(t||[]).filter(Z=>{const ve=ne||G==="All"||Z.priority===G,fe=`${Z.id} ${Z.description} ${Z.statusType}`.toLowerCase(),Ne=!y||fe.includes(y.toLowerCase()),De=ne||$==="All"||(Z.anomalyName||"").toLowerCase()===$.toLowerCase(),$e=ne||D==="All"||(Z.spaceName||"").toLowerCase()===D.toLowerCase(),Pe=ne||!xe||C==="All"||un(Z).includes(Number(C)),we=ss(String(Z.statusType||"")),Re=!k||!sr.some(et=>we.includes(ss(et)));return ve&&Ne&&De&&$e&&Pe&&Re})},[t,G,y,$,D,C,xe,k,M]),me=c?.length?c:ae,ge=M&&v.length>1?v:me,le=l?.length?l:ue,ie=M&&re.length>1?re:le,Te=M&&I.length>1?I:o,Oe=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:ne=>i.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Za[ne]}`,backgroundColor:Ba[ne]},children:ne})},{title:"Tracker",key:"tracker",width:140,render:(ne,Z)=>i.jsx("a",{onClick:ve=>{ve.preventDefault(),f?.(Z,{tab:"track",sourceTab:"active"})},className:"text-blue-600 hover:underline",children:"Tracker"})},{title:"Call to action/Human in the loop",key:"actions",width:320,render:(ne,Z)=>{if(u)return i.jsx(i.Fragment,{children:u(Z)});const ve=async(ht,Et)=>{const yt=vs(Z.id,ht);F(he=>new Set(he).add(yt));try{const he=await K.sendSMSorEmailNotifications?.(Z.id,ht,Et);he?.responseStatus||he?.Success||he?.success?(Ae.toast.success(he?.message||he.data||(ht?"Email sent successfully":"SMS sent successfully")),h?.()):Ae.toast.error(he?.message||he?.data||he?.errorMessage||"Failed to send notification")}catch(he){Ae.toast.error(he?.message||"Failed to send notification")}finally{F(he=>{const pt=new Set(he);return pt.delete(yt),pt})}},fe=zs,Ne=Hs,De=te[fe],$e=te[Ne],Pe=yn(fe,Z,De?.title),we=yn(Ne,Z,$e?.title),Re=vs(Z.id,!0),et=vs(Z.id,!1),mt=Ht(fe)&&R.has(Re),ft=Ht(Ne)&&R.has(et);return i.jsxs(d.Space,{size:"middle",children:[i.jsx(d.Tooltip,{title:Pe.tooltipTitle,children:i.jsx(d.Button,{size:"small",disabled:Pe.isDisabled,loading:mt,onClick:Ht(fe)?()=>ve(!0,!1):void 0,icon:!mt&&De?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:Pe.buttonText})},String(fe)),i.jsx(d.Tooltip,{title:we.tooltipTitle,children:i.jsx(d.Button,{size:"small",disabled:we.isDisabled,loading:ft,onClick:Ht(Ne)?()=>ve(!1,!0):void 0,icon:!ft&&$e?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:we.buttonText})},String(Ne))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(ne,Z)=>{const ve=Z?.timeElapsed,fe=Z?.timeRemaining,Ne=ve?cn(ve):0,De=fe?cn(fe):0,$e=Math.round(Ne/(Ne+De)*100);return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),i.jsx("span",{className:"font-medium",children:ve??"-"})]}),i.jsx(d.Progress,{percent:$e,showInfo:!1,size:"small",strokeColor:ga(Z.priority)}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-[70px]",children:"Remaining"}),i.jsx("span",{className:"font-medium",children:fe??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(ne,Z)=>i.jsxs("div",{children:[i.jsx("a",{onClick:ve=>{ve.preventDefault(),f?.(Z,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:Z.alertNumber}),i.jsx("div",{className:"text-black/65",children:ne})]})}],He=a&&a.length?a:Oe;return i.jsx("div",{children:i.jsx(tr,{rowKey:"id",data:de,columns:He,loading:e,pageSize:s,total:n,currentPage:r,onPageChange:x,toolbar:i.jsxs(d.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Severity"}),i.jsx(Ga,{value:G,onChange:L,options:Te})]})}),i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Anomaly type"}),i.jsx(_a,{value:$,onChange:T,options:ge})]})}),i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Space"}),i.jsx(Ja,{value:D,onChange:B,options:ie})]})}),i.jsx(d.Col,{flex:"none",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:"Action Taken"}),i.jsx(Qa,{value:C,onChange:q,options:O})]})}),i.jsx(d.Col,{flex:"auto"}),i.jsx(d.Col,{flex:"none",children:i.jsx(d.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:g,onChange:ne=>g(ne.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}function Gs(){const{alerts:t}=Me(),e=ut.useQueryClient();return ut.useMutation({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class dt extends Error{}class Xa extends dt{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class ei extends dt{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class ti extends dt{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class vt extends dt{}class nr extends dt{constructor(e){super(`Invalid unit ${e}`)}}class be extends dt{}class st extends dt{constructor(){super("Zone is an abstract class")}}const N="numeric",_e="short",Fe="long",ns={year:N,month:N,day:N},rr={year:N,month:_e,day:N},si={year:N,month:_e,day:N,weekday:_e},ar={year:N,month:Fe,day:N},ir={year:N,month:Fe,day:N,weekday:Fe},or={hour:N,minute:N},lr={hour:N,minute:N,second:N},cr={hour:N,minute:N,second:N,timeZoneName:_e},ur={hour:N,minute:N,second:N,timeZoneName:Fe},dr={hour:N,minute:N,hourCycle:"h23"},mr={hour:N,minute:N,second:N,hourCycle:"h23"},fr={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:_e},hr={hour:N,minute:N,second:N,hourCycle:"h23",timeZoneName:Fe},yr={year:N,month:N,day:N,hour:N,minute:N},pr={year:N,month:N,day:N,hour:N,minute:N,second:N},gr={year:N,month:_e,day:N,hour:N,minute:N},Sr={year:N,month:_e,day:N,hour:N,minute:N,second:N},ni={year:N,month:_e,day:N,weekday:_e,hour:N,minute:N},xr={year:N,month:Fe,day:N,hour:N,minute:N,timeZoneName:_e},vr={year:N,month:Fe,day:N,hour:N,minute:N,second:N,timeZoneName:_e},wr={year:N,month:Fe,day:N,weekday:Fe,hour:N,minute:N,timeZoneName:Fe},Ar={year:N,month:Fe,day:N,weekday:Fe,hour:N,minute:N,second:N,timeZoneName:Fe};class Lt{get type(){throw new st}get name(){throw new st}get ianaName(){return this.name}get isUniversal(){throw new st}offsetName(e,s){throw new st}formatOffset(e,s){throw new st}offset(e){throw new st}equals(e){throw new st}get isValid(){throw new st}}let ws=null;class cs extends Lt{static get instance(){return ws===null&&(ws=new cs),ws}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Dr(e,s,n)}formatOffset(e,s){return Rt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const Cs=new Map;function ri(t){let e=Cs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),Cs.set(t,e)),e}const ai={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ii(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,a,o,c,l,u,f]=n;return[o,r,a,c,l,u,f]}function oi(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:a,value:o}=s[r],c=ai[a];a==="era"?n[c]=o:V(c)||(n[c]=parseInt(o,10))}return n}const As=new Map;class Xe extends Lt{static create(e){let s=As.get(e);return s===void 0&&As.set(e,s=new Xe(e)),s}static resetCache(){As.clear(),Cs.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=Xe.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return Dr(e,s,n,this.name)}formatOffset(e,s){return Rt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=ri(this.name);let[r,a,o,c,l,u,f]=n.formatToParts?oi(n,s):ii(n,s);c==="BC"&&(r=-Math.abs(r)+1);const x=ds({year:r,month:a,day:o,hour:l===24?0:l,minute:u,second:f,millisecond:0});let p=+s;const k=p%1e3;return p-=k>=0?k:1e3+k,(x-p)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let pn={};function li(t,e={}){const s=JSON.stringify([t,e]);let n=pn[s];return n||(n=new Intl.ListFormat(t,e),pn[s]=n),n}const Ds=new Map;function Rs(t,e={}){const s=JSON.stringify([t,e]);let n=Ds.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Ds.set(s,n)),n}const Us=new Map;function ci(t,e={}){const s=JSON.stringify([t,e]);let n=Us.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Us.set(s,n)),n}const Ls=new Map;function ui(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let a=Ls.get(r);return a===void 0&&(a=new Intl.RelativeTimeFormat(t,e),Ls.set(r,a)),a}let jt=null;function di(){return jt||(jt=new Intl.DateTimeFormat().resolvedOptions().locale,jt)}const Fs=new Map;function Tr(t){let e=Fs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Fs.set(t,e)),e}const $s=new Map;function mi(t){let e=$s.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...Nr,...e}),$s.set(t,e)}return e}function fi(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const s=t.indexOf("-u-");if(s===-1)return[t];{let n,r;try{n=Rs(t).resolvedOptions(),r=t}catch{const l=t.substring(0,s);n=Rs(l).resolvedOptions(),r=l}const{numberingSystem:a,calendar:o}=n;return[r,a,o]}}function hi(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function yi(t){const e=[];for(let s=1;s<=12;s++){const n=W.utc(2009,s,1);e.push(t(n))}return e}function pi(t){const e=[];for(let s=1;s<=7;s++){const n=W.utc(2016,11,13+s);e.push(t(n))}return e}function qt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function gi(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Tr(t.locale).numberingSystem==="latn"}class Si{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:a,...o}=n;if(!s||Object.keys(o).length>0){const c={useGrouping:!1,...n};n.padTo>0&&(c.minimumIntegerDigits=n.padTo),this.inf=ci(e,c)}}format(e){if(this.inf){const s=this.floor?Math.floor(e):e;return this.inf.format(s)}else{const s=this.floor?Math.floor(e):Qs(e,3);return Se(s,this.padTo)}}}class xi{constructor(e,s,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const o=-1*(e.offset/60),c=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&Xe.create(c).valid?(r=c,this.dt=e):(r="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const a={...this.opts};a.timeZone=a.timeZone||r,this.dtf=Rs(s,a)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(s=>{if(s.type==="timeZoneName"){const n=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...s,value:n}}else return s}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class vi{constructor(e,s,n){this.opts={style:"long",...n},!s&&jr()&&(this.rtf=ui(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):Bi(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const Nr={firstDay:1,minimalDays:4,weekend:[6,7]};class se{static fromOpts(e){return se.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,s,n,r,a=!1){const o=e||pe.defaultLocale,c=o||(a?"en-US":di()),l=s||pe.defaultNumberingSystem,u=n||pe.defaultOutputCalendar,f=Ws(r)||pe.defaultWeekSettings;return new se(c,l,u,f,o)}static resetCache(){jt=null,Ds.clear(),Us.clear(),Ls.clear(),Fs.clear(),$s.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return se.create(e,s,n,r)}constructor(e,s,n,r,a){const[o,c,l]=fi(e);this.locale=o,this.numberingSystem=s||c||null,this.outputCalendar=n||l||null,this.weekSettings=r,this.intl=hi(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=a,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=gi(this)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),s=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&s?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:se.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Ws(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,s=!1){return qt(this,e,Lr,()=>{const n=this.intl==="ja"||this.intl.startsWith("ja-");s&=!n;const r=s?{month:e,day:"numeric"}:{month:e},a=s?"format":"standalone";if(!this.monthsCache[a][e]){const o=n?c=>this.dtFormatter(c,r).format():c=>this.extract(c,r,"month");this.monthsCache[a][e]=yi(o)}return this.monthsCache[a][e]})}weekdays(e,s=!1){return qt(this,e,Pr,()=>{const n=s?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=s?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=pi(a=>this.extract(a,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return qt(this,void 0,()=>Wr,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[W.utc(2016,11,13,9),W.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return qt(this,e,Vr,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[W.utc(-40,1,1),W.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),a=r.formatToParts(),o=a.find(c=>c.type.toLowerCase()===n);return o?o.value:null}numberFormatter(e={}){return new Si(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new xi(e,this.intl,s)}relFormatter(e={}){return new vi(this.intl,this.isEnglish(),e)}listFormatter(e={}){return li(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Tr(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Cr()?mi(this.locale):Nr}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Ts=null;class Ee extends Lt{static get utcInstance(){return Ts===null&&(Ts=new Ee(0)),Ts}static instance(e){return e===0?Ee.utcInstance:new Ee(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Ee(ms(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Rt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Rt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Rt(this.fixed,s)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}}class wi extends Lt{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function rt(t,e){if(V(t)||t===null)return e;if(t instanceof Lt)return t;if(Ii(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?cs.instance:s==="utc"||s==="gmt"?Ee.utcInstance:Ee.parseSpecifier(s)||Xe.create(t)}else return at(t)?Ee.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new wi(t)}const Ys={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},gn={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},Ai=Ys.hanidec.replace(/[\[|\]]/g,"").split("");function Ti(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let s=0;s<t.length;s++){const n=t.charCodeAt(s);if(t[s].search(Ys.hanidec)!==-1)e+=Ai.indexOf(t[s]);else for(const r in gn){const[a,o]=gn[r];n>=a&&n<=o&&(e+=n-a)}}return parseInt(e,10)}else return e}const Ps=new Map;function Ni(){Ps.clear()}function qe({numberingSystem:t},e=""){const s=t||"latn";let n=Ps.get(s);n===void 0&&(n=new Map,Ps.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${Ys[s]}${e}`),n.set(e,r)),r}let Sn=()=>Date.now(),xn="system",vn=null,wn=null,An=null,Tn=60,Nn,bn=null;class pe{static get now(){return Sn}static set now(e){Sn=e}static set defaultZone(e){xn=e}static get defaultZone(){return rt(xn,cs.instance)}static get defaultLocale(){return vn}static set defaultLocale(e){vn=e}static get defaultNumberingSystem(){return wn}static set defaultNumberingSystem(e){wn=e}static get defaultOutputCalendar(){return An}static set defaultOutputCalendar(e){An=e}static get defaultWeekSettings(){return bn}static set defaultWeekSettings(e){bn=Ws(e)}static get twoDigitCutoffYear(){return Tn}static set twoDigitCutoffYear(e){Tn=e%100}static get throwOnInvalid(){return Nn}static set throwOnInvalid(e){Nn=e}static resetCaches(){se.resetCache(),Xe.resetCache(),W.resetCache(),Ni()}}class Ye{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const br=[0,31,59,90,120,151,181,212,243,273,304,334],kr=[0,31,60,91,121,152,182,213,244,274,305,335];function Ze(t,e){return new Ye("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function _s(t,e,s){const n=new Date(Date.UTC(t,e-1,s));t<100&&t>=0&&n.setUTCFullYear(n.getUTCFullYear()-1900);const r=n.getUTCDay();return r===0?7:r}function Ir(t,e,s){return s+(Ft(t)?kr:br)[e-1]}function Er(t,e){const s=Ft(t)?kr:br,n=s.findIndex(a=>a<e),r=e-s[n];return{month:n+1,day:r}}function Js(t,e){return(t-e+7)%7+1}function rs(t,e=4,s=1){const{year:n,month:r,day:a}=t,o=Ir(n,r,a),c=Js(_s(n,r,a),s);let l=Math.floor((o-c+14-e)/7),u;return l<1?(u=n-1,l=Ut(u,e,s)):l>Ut(n,e,s)?(u=n+1,l=1):u=n,{weekYear:u,weekNumber:l,weekday:c,...fs(t)}}function kn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:a}=t,o=Js(_s(n,1,e),s),c=wt(n);let l=r*7+a-o-7+e,u;l<1?(u=n-1,l+=wt(u)):l>c?(u=n+1,l-=wt(n)):u=n;const{month:f,day:h}=Er(u,l);return{year:u,month:f,day:h,...fs(t)}}function Ns(t){const{year:e,month:s,day:n}=t,r=Ir(e,s,n);return{year:e,ordinal:r,...fs(t)}}function In(t){const{year:e,ordinal:s}=t,{month:n,day:r}=Er(e,s);return{year:e,month:n,day:r,...fs(t)}}function En(t,e){if(!V(t.localWeekday)||!V(t.localWeekNumber)||!V(t.localWeekYear)){if(!V(t.weekday)||!V(t.weekNumber)||!V(t.weekYear))throw new vt("Cannot mix locale-based week fields with ISO-based week fields");return V(t.localWeekday)||(t.weekday=t.localWeekday),V(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),V(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function bi(t,e=4,s=1){const n=us(t.weekYear),r=ze(t.weekNumber,1,Ut(t.weekYear,e,s)),a=ze(t.weekday,1,7);return n?r?a?!1:Ze("weekday",t.weekday):Ze("week",t.weekNumber):Ze("weekYear",t.weekYear)}function ki(t){const e=us(t.year),s=ze(t.ordinal,1,wt(t.year));return e?s?!1:Ze("ordinal",t.ordinal):Ze("year",t.year)}function Mr(t){const e=us(t.year),s=ze(t.month,1,12),n=ze(t.day,1,as(t.year,t.month));return e?s?n?!1:Ze("day",t.day):Ze("month",t.month):Ze("year",t.year)}function Or(t){const{hour:e,minute:s,second:n,millisecond:r}=t,a=ze(e,0,23)||e===24&&s===0&&n===0&&r===0,o=ze(s,0,59),c=ze(n,0,59),l=ze(r,0,999);return a?o?c?l?!1:Ze("millisecond",r):Ze("second",n):Ze("minute",s):Ze("hour",e)}function V(t){return typeof t>"u"}function at(t){return typeof t=="number"}function us(t){return typeof t=="number"&&t%1===0}function Ii(t){return typeof t=="string"}function Ei(t){return Object.prototype.toString.call(t)==="[object Date]"}function jr(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Cr(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Mi(t){return Array.isArray(t)?t:[t]}function Mn(t,e,s){if(t.length!==0)return t.reduce((n,r)=>{const a=[e(r),r];return n&&s(n[0],a[0])===n[0]?n:a},null)[1]}function Oi(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function Tt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Ws(t){if(t==null)return null;if(typeof t!="object")throw new be("Week settings must be an object");if(!ze(t.firstDay,1,7)||!ze(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!ze(e,1,7)))throw new be("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function ze(t,e,s){return us(t)&&t>=e&&t<=s}function ji(t,e){return t-e*Math.floor(t/e)}function Se(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function nt(t){if(!(V(t)||t===null||t===""))return parseInt(t,10)}function it(t){if(!(V(t)||t===null||t===""))return parseFloat(t)}function Ks(t){if(!(V(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function Qs(t,e,s="round"){const n=10**e;switch(s){case"expand":return t>0?Math.ceil(t*n)/n:Math.floor(t*n)/n;case"trunc":return Math.trunc(t*n)/n;case"round":return Math.round(t*n)/n;case"floor":return Math.floor(t*n)/n;case"ceil":return Math.ceil(t*n)/n;default:throw new RangeError(`Value rounding ${s} is out of range`)}}function Ft(t){return t%4===0&&(t%100!==0||t%400===0)}function wt(t){return Ft(t)?366:365}function as(t,e){const s=ji(e-1,12)+1,n=t+(e-s)/12;return s===2?Ft(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function ds(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function On(t,e,s){return-Js(_s(t,1,e),s)+e-1}function Ut(t,e=4,s=1){const n=On(t,e,s),r=On(t+1,e,s);return(wt(t)-n+r)/7}function Vs(t){return t>99?t:t>pe.twoDigitCutoffYear?1900+t:2e3+t}function Dr(t,e,s,n=null){const r=new Date(t),a={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};n&&(a.timeZone=n);const o={timeZoneName:e,...a},c=new Intl.DateTimeFormat(s,o).formatToParts(r).find(l=>l.type.toLowerCase()==="timezonename");return c?c.value:null}function ms(t,e){let s=parseInt(t,10);Number.isNaN(s)&&(s=0);const n=parseInt(e,10)||0,r=s<0||Object.is(s,-0)?-n:n;return s*60+r}function Rr(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new be(`Invalid unit value ${t}`);return e}function is(t,e){const s={};for(const n in t)if(Tt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=Rr(r)}return s}function Rt(t,e){const s=Math.trunc(Math.abs(t/60)),n=Math.trunc(Math.abs(t%60)),r=t>=0?"+":"-";switch(e){case"short":return`${r}${Se(s,2)}:${Se(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${Se(s,2)}${Se(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function fs(t){return Oi(t,["hour","minute","second","millisecond"])}const Ci=["January","February","March","April","May","June","July","August","September","October","November","December"],Ur=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Di=["J","F","M","A","M","J","J","A","S","O","N","D"];function Lr(t){switch(t){case"narrow":return[...Di];case"short":return[...Ur];case"long":return[...Ci];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const Fr=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],$r=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Ri=["M","T","W","T","F","S","S"];function Pr(t){switch(t){case"narrow":return[...Ri];case"short":return[...$r];case"long":return[...Fr];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Wr=["AM","PM"],Ui=["Before Christ","Anno Domini"],Li=["BC","AD"],Fi=["B","A"];function Vr(t){switch(t){case"narrow":return[...Fi];case"short":return[...Li];case"long":return[...Ui];default:return null}}function $i(t){return Wr[t.hour<12?0:1]}function Pi(t,e){return Pr(e)[t.weekday-1]}function Wi(t,e){return Lr(e)[t.month-1]}function Vi(t,e){return Vr(e)[t.year<0?0:1]}function Bi(t,e,s="always",n=!1){const r={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&a){const h=t==="days";switch(e){case 1:return h?"tomorrow":`next ${r[t][0]}`;case-1:return h?"yesterday":`last ${r[t][0]}`;case 0:return h?"today":`this ${r[t][0]}`}}const o=Object.is(e,-0)||e<0,c=Math.abs(e),l=c===1,u=r[t],f=n?l?u[1]:u[2]||u[1]:l?r[t][0]:t;return o?`${c} ${f} ago`:`in ${c} ${f}`}function jn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const Zi={D:ns,DD:rr,DDD:ar,DDDD:ir,t:or,tt:lr,ttt:cr,tttt:ur,T:dr,TT:mr,TTT:fr,TTTT:hr,f:yr,ff:gr,fff:xr,ffff:wr,F:pr,FF:Sr,FFF:vr,FFFF:Ar};class ke{static create(e,s={}){return new ke(e,s)}static parseFormat(e){let s=null,n="",r=!1;const a=[];for(let o=0;o<e.length;o++){const c=e.charAt(o);c==="'"?((n.length>0||r)&&a.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||c===s?n+=c:(n.length>0&&a.push({literal:/^\s+$/.test(n),val:n}),n=c,s=c)}return n.length>0&&a.push({literal:r||/^\s+$/.test(n),val:n}),a}static macroTokenToFormatOpts(e){return Zi[e]}constructor(e,s){this.opts=s,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,s){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...s}).format()}dtFormatter(e,s={}){return this.loc.dtFormatter(e,{...this.opts,...s})}formatDateTime(e,s){return this.dtFormatter(e,s).format()}formatDateTimeParts(e,s){return this.dtFormatter(e,s).formatToParts()}formatInterval(e,s){return this.dtFormatter(e.start,s).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,s){return this.dtFormatter(e,s).resolvedOptions()}num(e,s=0,n=void 0){if(this.opts.forceSimple)return Se(e,s);const r={...this.opts};return s>0&&(r.padTo=s),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,s){const n=this.loc.listingMode()==="en",r=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",a=(p,k)=>this.loc.extract(e,p,k),o=p=>e.isOffsetFixed&&e.offset===0&&p.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,p.format):"",c=()=>n?$i(e):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(p,k)=>n?Wi(e,p):a(k?{month:p}:{month:p,day:"numeric"},"month"),u=(p,k)=>n?Pi(e,p):a(k?{weekday:p}:{weekday:p,month:"long",day:"numeric"},"weekday"),f=p=>{const k=ke.macroTokenToFormatOpts(p);return k?this.formatWithSystemDefault(e,k):p},h=p=>n?Vi(e,p):a({era:p},"era"),x=p=>{switch(p){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return c();case"d":return r?a({day:"numeric"},"day"):this.num(e.day);case"dd":return r?a({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return r?a({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?a({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("narrow",!0);case"M":return r?a({month:"numeric"},"month"):this.num(e.month);case"MM":return r?a({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("narrow",!1);case"y":return r?a({year:"numeric"},"year"):this.num(e.year);case"yy":return r?a({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?a({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?a({year:"numeric"},"year"):this.num(e.year,6);case"G":return h("short");case"GG":return h("long");case"GGGGG":return h("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return f(p)}};return jn(ke.parseFormat(s),x)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=f=>{switch(f[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},a=(f,h)=>x=>{const p=r(x);if(p){const k=h.isNegativeDuration&&p!==h.largestUnit?n:1;let j;return this.opts.signMode==="negativeLargestOnly"&&p!==h.largestUnit?j="never":this.opts.signMode==="all"?j="always":j="auto",this.num(f.get(p)*k,x.length,j)}else return x},o=ke.parseFormat(s),c=o.reduce((f,{literal:h,val:x})=>h?f:f.concat(x),[]),l=e.shiftTo(...c.map(r).filter(f=>f)),u={isNegativeDuration:l<0,largestUnit:Object.keys(l.values)[0]};return jn(o,a(l,u))}}const Br=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Nt(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function bt(...t){return e=>t.reduce(([s,n,r],a)=>{const[o,c,l]=a(e,r);return[{...s,...o},c||n,l]},[{},null,1]).slice(0,2)}function kt(t,...e){if(t==null)return[null,null];for(const[s,n]of e){const r=s.exec(t);if(r)return n(r)}return[null,null]}function Zr(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=nt(e[s+r]);return[n,null,s+r]}}const zr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,zi=`(?:${zr.source}?(?:\\[(${Br.source})\\])?)?`,Xs=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Hr=RegExp(`${Xs.source}${zi}`),en=RegExp(`(?:[Tt]${Hr.source})?`),Hi=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,qi=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Gi=/(\d{4})-?(\d{3})/,Yi=Zr("weekYear","weekNumber","weekDay"),_i=Zr("year","ordinal"),Ji=/(\d{4})-(\d\d)-(\d\d)/,qr=RegExp(`${Xs.source} ?(?:${zr.source}|(${Br.source}))?`),Ki=RegExp(`(?: ${qr.source})?`);function At(t,e,s){const n=t[e];return V(n)?s:nt(n)}function Qi(t,e){return[{year:At(t,e),month:At(t,e+1,1),day:At(t,e+2,1)},null,e+3]}function It(t,e){return[{hours:At(t,e,0),minutes:At(t,e+1,0),seconds:At(t,e+2,0),milliseconds:Ks(t[e+3])},null,e+4]}function $t(t,e){const s=!t[e]&&!t[e+1],n=ms(t[e+1],t[e+2]),r=s?null:Ee.instance(n);return[{},r,e+3]}function Pt(t,e){const s=t[e]?Xe.create(t[e]):null;return[{},s,e+1]}const Xi=RegExp(`^T?${Xs.source}$`),eo=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function to(t){const[e,s,n,r,a,o,c,l,u]=t,f=e[0]==="-",h=l&&l[0]==="-",x=(p,k=!1)=>p!==void 0&&(k||p&&f)?-p:p;return[{years:x(it(s)),months:x(it(n)),weeks:x(it(r)),days:x(it(a)),hours:x(it(o)),minutes:x(it(c)),seconds:x(it(l),l==="-0"),milliseconds:x(Ks(u),h)}]}const so={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function tn(t,e,s,n,r,a,o){const c={year:e.length===2?Vs(nt(e)):nt(e),month:Ur.indexOf(s)+1,day:nt(n),hour:nt(r),minute:nt(a)};return o&&(c.second=nt(o)),t&&(c.weekday=t.length>3?Fr.indexOf(t)+1:$r.indexOf(t)+1),c}const no=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function ro(t){const[,e,s,n,r,a,o,c,l,u,f,h]=t,x=tn(e,r,n,s,a,o,c);let p;return l?p=so[l]:u?p=0:p=ms(f,h),[x,new Ee(p)]}function ao(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const io=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,oo=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,lo=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Cn(t){const[,e,s,n,r,a,o,c]=t;return[tn(e,r,n,s,a,o,c),Ee.utcInstance]}function co(t){const[,e,s,n,r,a,o,c]=t;return[tn(e,c,s,n,r,a,o),Ee.utcInstance]}const uo=Nt(Hi,en),mo=Nt(qi,en),fo=Nt(Gi,en),ho=Nt(Hr),Gr=bt(Qi,It,$t,Pt),yo=bt(Yi,It,$t,Pt),po=bt(_i,It,$t,Pt),go=bt(It,$t,Pt);function So(t){return kt(t,[uo,Gr],[mo,yo],[fo,po],[ho,go])}function xo(t){return kt(ao(t),[no,ro])}function vo(t){return kt(t,[io,Cn],[oo,Cn],[lo,co])}function wo(t){return kt(t,[eo,to])}const Ao=bt(It);function To(t){return kt(t,[Xi,Ao])}const No=Nt(Ji,Ki),bo=Nt(qr),ko=bt(It,$t,Pt);function Io(t){return kt(t,[No,Gr],[bo,ko])}const Dn="Invalid Duration",Yr={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Eo={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...Yr},Be=146097/400,gt=146097/4800,Mo={years:{quarters:4,months:12,weeks:Be/7,days:Be,hours:Be*24,minutes:Be*24*60,seconds:Be*24*60*60,milliseconds:Be*24*60*60*1e3},quarters:{months:3,weeks:Be/28,days:Be/4,hours:Be*24/4,minutes:Be*24*60/4,seconds:Be*24*60*60/4,milliseconds:Be*24*60*60*1e3/4},months:{weeks:gt/7,days:gt,hours:gt*24,minutes:gt*24*60,seconds:gt*24*60*60,milliseconds:gt*24*60*60*1e3},...Yr},lt=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Oo=lt.slice(0).reverse();function Ke(t,e,s=!1){const n={values:s?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new X(n)}function _r(t,e){let s=e.milliseconds??0;for(const n of Oo.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function Rn(t,e){const s=_r(t,e)<0?-1:1;lt.reduceRight((n,r)=>{if(V(e[r]))return n;if(n){const a=e[n]*s,o=t[r][n],c=Math.floor(a/o);e[r]+=c*s,e[n]-=c*o*s}return r},null),lt.reduce((n,r)=>{if(V(e[r]))return n;if(n){const a=e[n]%1;e[n]-=a,e[r]+=a*t[n][r]}return r},null)}function Un(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class X{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?Mo:Eo;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||se.create(),this.conversionAccuracy=s?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,s){return X.fromObject({milliseconds:e},s)}static fromObject(e,s={}){if(e==null||typeof e!="object")throw new be(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new X({values:is(e,X.normalizeUnit),loc:se.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(at(e))return X.fromMillis(e);if(X.isDuration(e))return e;if(typeof e=="object")return X.fromObject(e);throw new be(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=wo(e);return n?X.fromObject(n,s):X.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=To(e);return n?X.fromObject(n,s):X.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new be("need to specify a reason the Duration is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(pe.throwOnInvalid)throw new ti(n);return new X({invalid:n})}static normalizeUnit(e){const s={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!s)throw new nr(e);return s}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,s={}){const n={...s,floor:s.round!==!1&&s.floor!==!1};return this.isValid?ke.create(this.loc,n).formatDurationFromString(this,e):Dn}toHuman(e={}){if(!this.isValid)return Dn;const s=e.showZeros!==!1,n=lt.map(r=>{const a=this.values[r];return V(a)||a===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(a)}).filter(r=>r);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=Qs(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const s=this.toMillis();return s<0||s>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},W.fromMillis(s,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?_r(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e),n={};for(const r of lt)(Tt(s.values,r)||Tt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Ke(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e);return this.plus(s.negate())}mapUnits(e){if(!this.isValid)return this;const s={};for(const n of Object.keys(this.values))s[n]=Rr(e(this.values[n],n));return Ke(this,{values:s},!0)}get(e){return this[X.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...is(e,X.normalizeUnit)};return Ke(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const o={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return Ke(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Rn(this.matrix,e),Ke(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=Un(this.normalize().shiftToAll().toObject());return Ke(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>X.normalizeUnit(o));const s={},n={},r=this.toObject();let a;for(const o of lt)if(e.indexOf(o)>=0){a=o;let c=0;for(const u in n)c+=this.matrix[u][o]*n[u],n[u]=0;at(r[o])&&(c+=r[o]);const l=Math.trunc(c);s[o]=l,n[o]=(c*1e3-l*1e3)/1e3}else at(r[o])&&(n[o]=r[o]);for(const o in n)n[o]!==0&&(s[a]+=o===a?n[o]:n[o]/this.matrix[a][o]);return Rn(this.matrix,s),Ke(this,{values:s},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const s of Object.keys(this.values))e[s]=this.values[s]===0?0:-this.values[s];return Ke(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=Un(this.values);return Ke(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function s(n,r){return n===void 0||n===0?r===void 0||r===0:n===r}for(const n of lt)if(!s(this.values[n],e.values[n]))return!1;return!0}}const St="Invalid Interval";function jo(t,e){return!t||!t.isValid?ye.invalid("missing or invalid start"):!e||!e.isValid?ye.invalid("missing or invalid end"):e<t?ye.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}class ye{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,s=null){if(!e)throw new be("need to specify a reason the Interval is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(pe.throwOnInvalid)throw new ei(n);return new ye({invalid:n})}static fromDateTimes(e,s){const n=Mt(e),r=Mt(s),a=jo(n,r);return a??new ye({start:n,end:r})}static after(e,s){const n=X.fromDurationLike(s),r=Mt(e);return ye.fromDateTimes(r,r.plus(n))}static before(e,s){const n=X.fromDurationLike(s),r=Mt(e);return ye.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let a,o;try{a=W.fromISO(n,s),o=a.isValid}catch{o=!1}let c,l;try{c=W.fromISO(r,s),l=c.isValid}catch{l=!1}if(o&&l)return ye.fromDateTimes(a,c);if(o){const u=X.fromISO(r,s);if(u.isValid)return ye.after(a,u)}else if(l){const u=X.fromISO(n,s);if(u.isValid)return ye.before(c,u)}}return ye.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",s){if(!this.isValid)return NaN;const n=this.start.startOf(e,s);let r;return s?.useLocaleWeeks?r=this.end.reconfigure({locale:n.locale}):r=this.end,r=r.startOf(e,s),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:s}={}){return this.isValid?ye.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Mt).filter(o=>this.contains(o)).sort((o,c)=>o.toMillis()-c.toMillis()),n=[];let{s:r}=this,a=0;for(;r<this.e;){const o=s[a]||this.e,c=+o>+this.e?this.e:o;n.push(ye.fromDateTimes(r,c)),r=c,a+=1}return n}splitBy(e){const s=X.fromDurationLike(e);if(!this.isValid||!s.isValid||s.as("milliseconds")===0)return[];let{s:n}=this,r=1,a;const o=[];for(;n<this.e;){const c=this.start.plus(s.mapUnits(l=>l*r));a=+c>+this.e?this.e:c,o.push(ye.fromDateTimes(n,a)),n=a,r+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const s=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return s>=n?null:ye.fromDateTimes(s,n)}union(e){if(!this.isValid)return this;const s=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return ye.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,a)=>r.s-a.s).reduce(([r,a],o)=>a?a.overlaps(o)||a.abutsStart(o)?[r,a.union(o)]:[r.concat([a]),o]:[r,o],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],a=e.map(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),o=Array.prototype.concat(...a),c=o.sort((l,u)=>l.time-u.time);for(const l of c)n+=l.type==="s"?1:-1,n===1?s=l.time:(s&&+s!=+l.time&&r.push(ye.fromDateTimes(s,l.time)),s=null);return ye.merge(r)}difference(...e){return ye.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:St}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=ns,s={}){return this.isValid?ke.create(this.s.loc.clone(s),e).formatInterval(this):St}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:St}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:St}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:St}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:St}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):X.invalid(this.invalidReason)}mapEndpoints(e){return ye.fromDateTimes(e(this.s),e(this.e))}}class Gt{static hasDST(e=pe.defaultZone){const s=W.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return Xe.isValidZone(e)}static normalizeZone(e){return rt(e,pe.defaultZone)}static getStartOfWeek({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:s=null}={}){return(s||se.create(e)).getWeekendDays().slice()}static months(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||se.create(s,n,a)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:a="gregory"}={}){return(r||se.create(s,n,a)).months(e,!0)}static weekdays(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||se.create(s,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null}={}){return(r||se.create(s,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return se.create(e).meridiems()}static eras(e="short",{locale:s=null}={}){return se.create(s,null,"gregory").eras(e)}static features(){return{relative:jr(),localeWeek:Cr()}}}function Ln(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(X.fromMillis(n).as("days"))}function Co(t,e,s){const n=[["years",(l,u)=>u.year-l.year],["quarters",(l,u)=>u.quarter-l.quarter+(u.year-l.year)*4],["months",(l,u)=>u.month-l.month+(u.year-l.year)*12],["weeks",(l,u)=>{const f=Ln(l,u);return(f-f%7)/7}],["days",Ln]],r={},a=t;let o,c;for(const[l,u]of n)s.indexOf(l)>=0&&(o=l,r[l]=u(t,e),c=a.plus(r),c>e?(r[l]--,t=a.plus(r),t>e&&(c=t,r[l]--,t=a.plus(r))):t=c);return[t,r,c,o]}function Do(t,e,s,n){let[r,a,o,c]=Co(t,e,s);const l=e-r,u=s.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<e&&(o=r.plus({[c]:1})),o!==r&&(a[c]=(a[c]||0)+l/(o-r)));const f=X.fromObject(a,n);return u.length>0?X.fromMillis(l,n).shiftTo(...u).plus(f):f}const Ro="missing Intl.DateTimeFormat.formatToParts support";function ee(t,e=s=>s){return{regex:t,deser:([s])=>e(Ti(s))}}const Uo=" ",Jr=`[ ${Uo}]`,Kr=new RegExp(Jr,"g");function Lo(t){return t.replace(/\./g,"\\.?").replace(Kr,Jr)}function Fn(t){return t.replace(/\./g,"").replace(Kr," ").toLowerCase()}function Ge(t,e){return t===null?null:{regex:RegExp(t.map(Lo).join("|")),deser:([s])=>t.findIndex(n=>Fn(s)===Fn(n))+e}}function $n(t,e){return{regex:t,deser:([,s,n])=>ms(s,n),groups:e}}function Yt(t){return{regex:t,deser:([e])=>e}}function Fo(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function $o(t,e){const s=qe(e),n=qe(e,"{2}"),r=qe(e,"{3}"),a=qe(e,"{4}"),o=qe(e,"{6}"),c=qe(e,"{1,2}"),l=qe(e,"{1,3}"),u=qe(e,"{1,6}"),f=qe(e,"{1,9}"),h=qe(e,"{2,4}"),x=qe(e,"{4,6}"),p=M=>({regex:RegExp(Fo(M.val)),deser:([G])=>G,literal:!0}),j=(M=>{if(t.literal)return p(M);switch(M.val){case"G":return Ge(e.eras("short"),0);case"GG":return Ge(e.eras("long"),0);case"y":return ee(u);case"yy":return ee(h,Vs);case"yyyy":return ee(a);case"yyyyy":return ee(x);case"yyyyyy":return ee(o);case"M":return ee(c);case"MM":return ee(n);case"MMM":return Ge(e.months("short",!0),1);case"MMMM":return Ge(e.months("long",!0),1);case"L":return ee(c);case"LL":return ee(n);case"LLL":return Ge(e.months("short",!1),1);case"LLLL":return Ge(e.months("long",!1),1);case"d":return ee(c);case"dd":return ee(n);case"o":return ee(l);case"ooo":return ee(r);case"HH":return ee(n);case"H":return ee(c);case"hh":return ee(n);case"h":return ee(c);case"mm":return ee(n);case"m":return ee(c);case"q":return ee(c);case"qq":return ee(n);case"s":return ee(c);case"ss":return ee(n);case"S":return ee(l);case"SSS":return ee(r);case"u":return Yt(f);case"uu":return Yt(c);case"uuu":return ee(s);case"a":return Ge(e.meridiems(),0);case"kkkk":return ee(a);case"kk":return ee(h,Vs);case"W":return ee(c);case"WW":return ee(n);case"E":case"c":return ee(s);case"EEE":return Ge(e.weekdays("short",!1),1);case"EEEE":return Ge(e.weekdays("long",!1),1);case"ccc":return Ge(e.weekdays("short",!0),1);case"cccc":return Ge(e.weekdays("long",!0),1);case"Z":case"ZZ":return $n(new RegExp(`([+-]${c.source})(?::(${n.source}))?`),2);case"ZZZ":return $n(new RegExp(`([+-]${c.source})(${n.source})?`),2);case"z":return Yt(/[a-z_+-/]{1,256}?/i);case" ":return Yt(/[^\S\n\r]/);default:return p(M)}})(t)||{invalidReason:Ro};return j.token=t,j}const Po={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function Wo(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const l=/^\s+$/.test(r);return{literal:!l,val:l?" ":r}}const a=e[n];let o=n;n==="hour"&&(e.hour12!=null?o=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?o="hour12":o="hour24":o=s.hour12?"hour12":"hour24");let c=Po[o];if(typeof c=="object"&&(c=c[a]),c)return{literal:!1,val:c}}function Vo(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function Bo(t,e,s){const n=t.match(e);if(n){const r={};let a=1;for(const o in s)if(Tt(s,o)){const c=s[o],l=c.groups?c.groups+1:1;!c.literal&&c.token&&(r[c.token.val[0]]=c.deser(n.slice(a,a+l))),a+=l}return[n,r]}else return[n,{}]}function Zo(t){const e=a=>{switch(a){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let s=null,n;return V(t.z)||(s=Xe.create(t.z)),V(t.Z)||(s||(s=new Ee(t.Z)),n=t.Z),V(t.q)||(t.M=(t.q-1)*3+1),V(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),V(t.u)||(t.S=Ks(t.u)),[Object.keys(t).reduce((a,o)=>{const c=e(o);return c&&(a[c]=t[o]),a},{}),s,n]}let bs=null;function zo(){return bs||(bs=W.fromMillis(1555555555555)),bs}function Ho(t,e){if(t.literal)return t;const s=ke.macroTokenToFormatOpts(t.val),n=ta(s,e);return n==null||n.includes(void 0)?t:n}function Qr(t,e){return Array.prototype.concat(...t.map(s=>Ho(s,e)))}class Xr{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=Qr(ke.parseFormat(s),e),this.units=this.tokens.map(n=>$o(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=Vo(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=Bo(e,this.regex,this.handlers),[r,a,o]=n?Zo(n):[null,null,void 0];if(Tt(n,"a")&&Tt(n,"H"))throw new vt("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:s,matches:n,result:r,zone:a,specificOffset:o}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function ea(t,e,s){return new Xr(t,s).explainFromTokens(e)}function qo(t,e,s){const{result:n,zone:r,specificOffset:a,invalidReason:o}=ea(t,e,s);return[n,r,a,o]}function ta(t,e){if(!t)return null;const n=ke.create(e,t).dtFormatter(zo()),r=n.formatToParts(),a=n.resolvedOptions();return r.map(o=>Wo(o,t,a))}const ks="Invalid DateTime",Pn=864e13;function Ct(t){return new Ye("unsupported zone",`the zone "${t.name}" is not supported`)}function Is(t){return t.weekData===null&&(t.weekData=rs(t.c)),t.weekData}function Es(t){return t.localWeekData===null&&(t.localWeekData=rs(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function ot(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new W({...s,...e,old:s})}function sa(t,e,s){let n=t-e*60*1e3;const r=s.offset(n);if(e===r)return[n,e];n-=(r-e)*60*1e3;const a=s.offset(n);return r===a?[n,r]:[t-Math.min(r,a)*60*1e3,Math.max(r,a)]}function _t(t,e){t+=e*60*1e3;const s=new Date(t);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),hour:s.getUTCHours(),minute:s.getUTCMinutes(),second:s.getUTCSeconds(),millisecond:s.getUTCMilliseconds()}}function Xt(t,e,s){return sa(ds(t),e,s)}function Wn(t,e){const s=t.o,n=t.c.year+Math.trunc(e.years),r=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,a={...t.c,year:n,month:r,day:Math.min(t.c.day,as(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=X.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),c=ds(a);let[l,u]=sa(c,s,t.zone);return o!==0&&(l+=o,u=t.zone.offset(l)),{ts:l,o:u}}function xt(t,e,s,n,r,a){const{setZone:o,zone:c}=s;if(t&&Object.keys(t).length!==0||e){const l=e||c,u=W.fromObject(t,{...s,zone:l,specificOffset:a});return o?u:u.setZone(c)}else return W.invalid(new Ye("unparsable",`the input "${r}" can't be parsed as ${n}`))}function Jt(t,e,s=!0){return t.isValid?ke.create(se.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Ms(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=Se(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=Se(t.c.month),s==="month")return r;r+="-"}else if(r+=Se(t.c.month),s==="month")return r;return r+=Se(t.c.day),r}function Vn(t,e,s,n,r,a,o){let c=!s||t.c.millisecond!==0||t.c.second!==0,l="";switch(o){case"day":case"month":case"year":break;default:if(l+=Se(t.c.hour),o==="hour")break;if(e){if(l+=":",l+=Se(t.c.minute),o==="minute")break;c&&(l+=":",l+=Se(t.c.second))}else{if(l+=Se(t.c.minute),o==="minute")break;c&&(l+=Se(t.c.second))}if(o==="second")break;c&&(!n||t.c.millisecond!==0)&&(l+=".",l+=Se(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!a?l+="Z":t.o<0?(l+="-",l+=Se(Math.trunc(-t.o/60)),l+=":",l+=Se(Math.trunc(-t.o%60))):(l+="+",l+=Se(Math.trunc(t.o/60)),l+=":",l+=Se(Math.trunc(t.o%60)))),a&&(l+="["+t.zone.ianaName+"]"),l}const na={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Go={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Yo={ordinal:1,hour:0,minute:0,second:0,millisecond:0},es=["year","month","day","hour","minute","second","millisecond"],_o=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Jo=["year","ordinal","hour","minute","second","millisecond"];function ts(t){const e={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[t.toLowerCase()];if(!e)throw new nr(t);return e}function Bn(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return ts(t)}}function Ko(t){if(Dt===void 0&&(Dt=pe.now()),t.type!=="iana")return t.offset(Dt);const e=t.name;let s=Bs.get(e);return s===void 0&&(s=t.offset(Dt),Bs.set(e,s)),s}function Zn(t,e){const s=rt(e.zone,pe.defaultZone);if(!s.isValid)return W.invalid(Ct(s));const n=se.fromObject(e);let r,a;if(V(t.year))r=pe.now();else{for(const l of es)V(t[l])&&(t[l]=na[l]);const o=Mr(t)||Or(t);if(o)return W.invalid(o);const c=Ko(s);[r,a]=Xt(t,c,s)}return new W({ts:r,zone:s,loc:n,o:a})}function zn(t,e,s){const n=V(s.round)?!0:s.round,r=V(s.rounding)?"trunc":s.rounding,a=(c,l)=>(c=Qs(c,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(c,l)),o=c=>s.calendary?e.hasSame(t,c)?0:e.startOf(c).diff(t.startOf(c),c).get(c):e.diff(t,c).get(c);if(s.unit)return a(o(s.unit),s.unit);for(const c of s.units){const l=o(c);if(Math.abs(l)>=1)return a(l,c)}return a(t>e?-0:0,s.units[s.units.length-1])}function Hn(t){let e={},s;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],s=Array.from(t).slice(0,t.length-1)):s=Array.from(t),[e,s]}let Dt;const Bs=new Map;class W{constructor(e){const s=e.zone||pe.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ye("invalid input"):null)||(s.isValid?null:Ct(s));this.ts=V(e.ts)?pe.now():e.ts;let r=null,a=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,a]=[e.old.c,e.old.o];else{const c=at(e.o)&&!e.old?e.o:s.offset(this.ts);r=_t(this.ts,c),n=Number.isNaN(r.year)?new Ye("invalid input"):null,r=n?null:r,a=n?null:c}this._zone=s,this.loc=e.loc||se.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=a,this.isLuxonDateTime=!0}static now(){return new W({})}static local(){const[e,s]=Hn(arguments),[n,r,a,o,c,l,u]=s;return Zn({year:n,month:r,day:a,hour:o,minute:c,second:l,millisecond:u},e)}static utc(){const[e,s]=Hn(arguments),[n,r,a,o,c,l,u]=s;return e.zone=Ee.utcInstance,Zn({year:n,month:r,day:a,hour:o,minute:c,second:l,millisecond:u},e)}static fromJSDate(e,s={}){const n=Ei(e)?e.valueOf():NaN;if(Number.isNaN(n))return W.invalid("invalid input");const r=rt(s.zone,pe.defaultZone);return r.isValid?new W({ts:n,zone:r,loc:se.fromObject(s)}):W.invalid(Ct(r))}static fromMillis(e,s={}){if(at(e))return e<-Pn||e>Pn?W.invalid("Timestamp out of range"):new W({ts:e,zone:rt(s.zone,pe.defaultZone),loc:se.fromObject(s)});throw new be(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(at(e))return new W({ts:e*1e3,zone:rt(s.zone,pe.defaultZone),loc:se.fromObject(s)});throw new be("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=rt(s.zone,pe.defaultZone);if(!n.isValid)return W.invalid(Ct(n));const r=se.fromObject(s),a=is(e,Bn),{minDaysInFirstWeek:o,startOfWeek:c}=En(a,r),l=pe.now(),u=V(s.specificOffset)?n.offset(l):s.specificOffset,f=!V(a.ordinal),h=!V(a.year),x=!V(a.month)||!V(a.day),p=h||x,k=a.weekYear||a.weekNumber;if((p||f)&&k)throw new vt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(x&&f)throw new vt("Can't mix ordinal dates with month/day");const j=k||a.weekday&&!p;let M,G,L=_t(l,u);j?(M=_o,G=Go,L=rs(L,o,c)):f?(M=Jo,G=Yo,L=Ns(L)):(M=es,G=na);let $=!1;for(const g of M){const O=a[g];V(O)?$?a[g]=G[g]:a[g]=L[g]:$=!0}const T=j?bi(a,o,c):f?ki(a):Mr(a),D=T||Or(a);if(D)return W.invalid(D);const B=j?kn(a,o,c):f?In(a):a,[C,q]=Xt(B,u,n),y=new W({ts:C,zone:n,o:q,loc:r});return a.weekday&&p&&e.weekday!==y.weekday?W.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${y.toISO()}`):y.isValid?y:W.invalid(y.invalid)}static fromISO(e,s={}){const[n,r]=So(e);return xt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=xo(e);return xt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=vo(e);return xt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(V(e)||V(s))throw new be("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0}),[c,l,u,f]=qo(o,e,s);return f?W.invalid(f):xt(c,l,n,`format ${s}`,e,u)}static fromString(e,s,n={}){return W.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=Io(e);return xt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new be("need to specify a reason the DateTime is invalid");const n=e instanceof Ye?e:new Ye(e,s);if(pe.throwOnInvalid)throw new Xa(n);return new W({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=ta(e,se.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return Qr(ke.parseFormat(e),se.fromObject(s)).map(r=>r.val).join("")}static resetCache(){Dt=void 0,Bs.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Is(this).weekYear:NaN}get weekNumber(){return this.isValid?Is(this).weekNumber:NaN}get weekday(){return this.isValid?Is(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Es(this).weekday:NaN}get localWeekNumber(){return this.isValid?Es(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Es(this).weekYear:NaN}get ordinal(){return this.isValid?Ns(this.c).ordinal:NaN}get monthShort(){return this.isValid?Gt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Gt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Gt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Gt.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,s=6e4,n=ds(this.c),r=this.zone.offset(n-e),a=this.zone.offset(n+e),o=this.zone.offset(n-r*s),c=this.zone.offset(n-a*s);if(o===c)return[this];const l=n-o*s,u=n-c*s,f=_t(l,o),h=_t(u,c);return f.hour===h.hour&&f.minute===h.minute&&f.second===h.second&&f.millisecond===h.millisecond?[ot(this,{ts:l}),ot(this,{ts:u})]:[this]}get isInLeapYear(){return Ft(this.year)}get daysInMonth(){return as(this.year,this.month)}get daysInYear(){return this.isValid?wt(this.year):NaN}get weeksInWeekYear(){return this.isValid?Ut(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Ut(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=ke.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(Ee.instance(e),s)}toLocal(){return this.setZone(pe.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=rt(e,pe.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const a=e.offset(this.ts),o=this.toObject();[r]=Xt(o,a,e)}return ot(this,{ts:r,zone:e})}else return W.invalid(Ct(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return ot(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=is(e,Bn),{minDaysInFirstWeek:n,startOfWeek:r}=En(s,this.loc),a=!V(s.weekYear)||!V(s.weekNumber)||!V(s.weekday),o=!V(s.ordinal),c=!V(s.year),l=!V(s.month)||!V(s.day),u=c||l,f=s.weekYear||s.weekNumber;if((u||o)&&f)throw new vt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&o)throw new vt("Can't mix ordinal dates with month/day");let h;a?h=kn({...rs(this.c,n,r),...s},n,r):V(s.ordinal)?(h={...this.toObject(),...s},V(s.day)&&(h.day=Math.min(as(h.year,h.month),h.day))):h=In({...Ns(this.c),...s});const[x,p]=Xt(h,this.o,this.zone);return ot(this,{ts:x,o:p})}plus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e);return ot(this,Wn(this,s))}minus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e).negate();return ot(this,Wn(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=X.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0;break}if(r==="weeks")if(s){const a=this.loc.getStartOfWeek(),{weekday:o}=this;o<a&&(n.weekNumber=this.weekNumber-1),n.weekday=a}else n.weekday=1;if(r==="quarters"){const a=Math.ceil(this.month/3);n.month=(a-1)*3+1}return this.set(n)}endOf(e,s){return this.isValid?this.plus({[e]:1}).startOf(e,s).minus(1):this}toFormat(e,s={}){return this.isValid?ke.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):ks}toLocaleString(e=ns,s={}){return this.isValid?ke.create(this.loc.clone(s),e).formatDateTime(this):ks}toLocaleParts(e={}){return this.isValid?ke.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:s=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:a=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=ts(o);const c=e==="extended";let l=Ms(this,c,o);return es.indexOf(o)>=3&&(l+="T"),l+=Vn(this,c,s,n,r,a,o),l}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Ms(this,e==="extended",ts(s)):null}toISOWeekDate(){return Jt(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:a=!1,format:o="extended",precision:c="milliseconds"}={}){return this.isValid?(c=ts(c),(r&&es.indexOf(c)>=3?"T":"")+Vn(this,o==="extended",s,e,n,a,c)):null}toRFC2822(){return Jt(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Jt(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Ms(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:s=!1,includeOffsetSpace:n=!0}={}){let r="HH:mm:ss.SSS";return(s||e)&&(n&&(r+=" "),s?r+="z":e&&(r+="ZZ")),Jt(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():ks}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const s={...this.c};return e.includeConfig&&(s.outputCalendar=this.outputCalendar,s.numberingSystem=this.loc.numberingSystem,s.locale=this.loc.locale),s}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,s="milliseconds",n={}){if(!this.isValid||!e.isValid)return X.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},a=Mi(s).map(X.normalizeUnit),o=e.valueOf()>this.valueOf(),c=o?this:e,l=o?e:this,u=Do(c,l,a,r);return o?u.negate():u}diffNow(e="milliseconds",s={}){return this.diff(W.now(),e,s)}until(e){return this.isValid?ye.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),a=this.setZone(e.zone,{keepLocalTime:!0});return a.startOf(s,n)<=r&&r<=a.endOf(s,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const s=e.base||W.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],a=e.unit;return Array.isArray(e.unit)&&(r=e.unit,a=void 0),zn(s,this.plus(n),{...e,numeric:"always",units:r,unit:a})}toRelativeCalendar(e={}){return this.isValid?zn(e.base||W.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(W.isDateTime))throw new be("min requires all arguments be DateTimes");return Mn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(W.isDateTime))throw new be("max requires all arguments be DateTimes");return Mn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});return ea(o,e,s)}static fromStringExplain(e,s,n={}){return W.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,a=se.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new Xr(a,e)}static fromFormatParser(e,s,n={}){if(V(e)||V(s))throw new be("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:a=null}=n,o=se.fromOpts({locale:r,numberingSystem:a,defaultToEN:!0});if(!o.equals(s.locale))throw new be(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${s.locale}`);const{result:c,zone:l,specificOffset:u,invalidReason:f}=s.explainFromTokens(e);return f?W.invalid(f):xt(c,l,n,`format ${s.format}`,e,u)}static get DATE_SHORT(){return ns}static get DATE_MED(){return rr}static get DATE_MED_WITH_WEEKDAY(){return si}static get DATE_FULL(){return ar}static get DATE_HUGE(){return ir}static get TIME_SIMPLE(){return or}static get TIME_WITH_SECONDS(){return lr}static get TIME_WITH_SHORT_OFFSET(){return cr}static get TIME_WITH_LONG_OFFSET(){return ur}static get TIME_24_SIMPLE(){return dr}static get TIME_24_WITH_SECONDS(){return mr}static get TIME_24_WITH_SHORT_OFFSET(){return fr}static get TIME_24_WITH_LONG_OFFSET(){return hr}static get DATETIME_SHORT(){return yr}static get DATETIME_SHORT_WITH_SECONDS(){return pr}static get DATETIME_MED(){return gr}static get DATETIME_MED_WITH_SECONDS(){return Sr}static get DATETIME_MED_WITH_WEEKDAY(){return ni}static get DATETIME_FULL(){return xr}static get DATETIME_FULL_WITH_SECONDS(){return vr}static get DATETIME_HUGE(){return wr}static get DATETIME_HUGE_WITH_SECONDS(){return Ar}}function Mt(t){if(W.isDateTime(t))return t;if(t&&t.valueOf&&at(t.valueOf()))return W.fromJSDate(t);if(t&&typeof t=="object")return W.fromObject(t);throw new be(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function Qo(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function Xo(t,e){try{const s=W.fromJSDate(t,{zone:"utc"}).setZone(e),n=s.toJSDate().toLocaleString("en-US",{timeZone:e,timeZoneName:"short"}).split(" ").pop()||void 0,r=s.toFormat("ZZ")||void 0;return{abbr:n,offset:r}}catch{return{}}}function el(t){if(!t)return"-";try{const e=new Date(t),s=u=>String(u).padStart(2,"0"),n=s(e.getMonth()+1),r=s(e.getDate()),a=e.getFullYear(),o=s(e.getHours()),c=s(e.getMinutes()),l=s(e.getSeconds());return`${n}/${r}/${a} ${o}:${c}:${l}`}catch{return"-"}}function os(t,e="UTC"){if(!t)return"-";const s=W.fromISO(t,{zone:"utc"}).setZone(e);if(!s.isValid)return"-";const n=s.offsetNameShort,r=s.toFormat("ZZZZ"),a=n.startsWith("GMT")||n===r?r:`${n}/${r}`;return`${s.toFormat("MM/dd/yyyy, hh:mm:ss a")} (${a})`}const tl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},sl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function ra({alerts:t,loading:e=!1,pageSize:s=10,total:n,currentPage:r,severityOptions:a,anomalyOptions:o,spaceOptions:c,onAlertIdClick:l,onFilterChange:u,onPageChange:f,onRefetch:h,resetKey:x,serverSideFilters:p}){const k=Gs(),j=async L=>{try{const $=await k.mutateAsync({alertUniqueId:L.alertId??L.id,alertId:L.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if($?.responseStatus||$?.Success){const T=$?.Message||$?.data||"Alert reopened successfully.";Ae.toast.success(T)}else{const T=$?.errorMessage||$?.Message||"Failed to reopen alert";Ae.toast.error(T)}}catch{Ae.toast.error("Failed to reopen alert. Please try again.")}},M=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:L=>i.jsx(d.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${tl[L]}`,backgroundColor:sl[String(L)]},children:L})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:L=>el(L)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(L,$)=>i.jsxs("div",{children:[i.jsx("a",{onClick:T=>{T.preventDefault(),l?.($,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:$.alertNumber}),i.jsx("div",{className:"text-black/65",children:L})]})},{title:"",key:"menu",width:60,align:"right",render:(L,$)=>i.jsx(d.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:T})=>{T==="reopen"&&j($)}},children:i.jsx(d.Button,{type:"text",icon:i.jsx(ct.MoreOutlined,{})})})}],G=u&&p?t:(t||[]).filter(L=>{const $=ss(L.statusType||"");return sr.some(T=>$.includes(ss(T)))});return i.jsx(qs,{data:G,loading:e,pageSize:s,total:n,currentPage:r,columns:M,severityOptions:a,anomalyOptions:o,spaceOptions:c,renderActions:void 0,onAlertIdClick:l,onFilterChange:u,onPageChange:f,onRefetch:h,resetKey:x,serverSideFilters:p,excludeCompleted:!1})}function nl({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:a}=m.useMemo(()=>{const h=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(h.find(x=>x.type==="hour")?.value||"0",10),minutes:parseInt(h.find(x=>x.type==="minute")?.value||"0",10),seconds:parseInt(h.find(x=>x.type==="second")?.value||"0",10)}},[e,s]),o=a*6,c=r*6+a*.1,l=n%12*30+r*.5,u=t/2;return i.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:t,height:t},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((f,h)=>{const x=h*30,p=6,k=u-4,j=k-p,M=(x-90)*(Math.PI/180),G=u+j*Math.cos(M),L=u+j*Math.sin(M),$=u+k*Math.cos(M),T=u+k*Math.sin(M);return i.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:i.jsx("line",{x1:G,y1:L,x2:$,y2:T,stroke:"#9CA3AF",strokeWidth:h%3===0?2:1,strokeLinecap:"round"})},h)}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${l}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${c}deg)`},children:i.jsx("line",{x1:u,y1:u,x2:u,y2:u-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),i.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:i.jsx("line",{x1:u,y1:u+t*.08,x2:u,y2:u-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),i.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function aa({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,a]=m.useState(new Date);m.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const o=m.useMemo(()=>Qo(r,e),[r,e]),{abbr:c,offset:l}=m.useMemo(()=>Xo(r,e),[r,e]);return i.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[i.jsx(nl,{time:r,timeZone:e,size:80}),i.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[i.jsx("span",{className:"uppercase",children:t}),c&&i.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[c," ",l]})]}),i.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const{Text:rl}=d.Typography;function al({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:a}){return i.jsxs(d.Row,{gutter:[16,16],align:"middle",children:[i.jsx(d.Col,{xs:24,md:8,lg:5,children:i.jsxs(d.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[i.jsx(rl,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),i.jsx(d.Select,{placeholder:"By Severity",value:t,onChange:o=>e({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),i.jsx(d.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?i.jsxs(d.Space,{className:"w-full",direction:"horizontal",size:8,children:[i.jsx(d.Button,{onClick:r,disabled:a,children:"Clear"}),i.jsx(d.Button,{type:"primary",onClick:n,loading:a,children:"Save"})]}):null})]})}const Zs=t=>i.jsxs(d.Tag,{children:[i.jsx(ct.PlusOutlined,{})," ",t.length," more"]}),{Text:Qe}=d.Typography;function il(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:a,l1mins:o,setL1mins:c,l1role:l,setL1role:u,l2mins:f,setL2mins:h,l2role:x,setL2role:p,l3mins:k,setL3mins:j,l3role:M,setL3role:G,actions:L,setActions:$,thirdPartyIds:T,setThirdPartyIds:D,humanLoop:B,setHumanLoop:C,isAutoExpire:q,setAutoExpire:y,onClear:g,onSave:O,saving:oe,onActionTypesLoaded:re}=t,{rules:U,config:v}=Me(),S=v.tenant==="schools",[I,A]=m.useState([]),[R,F]=m.useState([]),[Y,K]=m.useState(!1);m.useEffect(()=>{let de=!1;return(async()=>{try{K(!0);const me=await U.getLookups();if(de||!me||!Array.isArray(me.actionTypes))return;const ge=me.actionTypes.map(ie=>({label:ie.name,value:String(ie.actionTypeId)}));A(ge),re&&re(me.actionTypes);const le=Array.isArray(me.thirdParties)?me.thirdParties.map(ie=>({label:ie.thirdPartyName,value:ie.thirdPartyIds??ie.thirdPartyId})):[];F(le)}catch(me){console.error("Error loading lookups",me)}finally{de||K(!1)}})(),()=>{de=!0}},[]);const te=typeof o=="number"||typeof l=="number",ae=typeof f=="number"||typeof x=="number",ue=typeof o=="number"||typeof l=="number"||typeof f=="number"||typeof x=="number"||typeof k=="number"||typeof M=="number"||Array.isArray(L)&&L.length>0||Array.isArray(T)&&T.length>0||!!B||!!q,xe=!!e&&ue&&!oe;return i.jsxs(d.Spin,{spinning:!!oe||Y,children:[i.jsxs(d.Row,{gutter:[16,16],align:"bottom",children:[i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(d.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:c,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:l,onChange:u,options:a})})]})]})}),te&&i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:f,onChange:h,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:x,onChange:p,options:a})})]})]})}),ae&&i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),i.jsx(d.Col,{span:14,children:i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),i.jsxs(d.Row,{gutter:8,children:[i.jsx(d.Col,{span:10,children:i.jsx(d.Select,{className:"w-full",placeholder:"Mins",value:k,onChange:j,options:r})}),i.jsx(d.Col,{span:14,children:i.jsx(d.Select,{placeholder:"Escalate to",className:"w-full",value:M,onChange:G,options:a})})]})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:L,onChange:$,options:I,maxTagCount:1,maxTagPlaceholder:Zs})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{children:[i.jsx(Qe,{className:"text-gray-700 font-medium block mb-1",children:"Notify"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Notify",className:"w-full",value:T,onChange:D,options:R,maxCount:2,maxTagPlaceholder:Zs})]})})]}),i.jsxs(d.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[i.jsx(d.Col,{xs:24,sm:12,md:8,lg:7,children:i.jsxs("div",{className:"flex items-center h-full gap-8",children:[!S&&i.jsx(d.Checkbox,{checked:B,onChange:de=>C(de.target.checked),className:"w-full",children:"Human-In-The-Loop"}),i.jsx(d.Checkbox,{checked:q,onChange:de=>y(de.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Button,{onClick:g,children:"Clear"}),i.jsx(d.Button,{type:"primary",onClick:O,loading:!!oe,disabled:!xe,children:"Save"})]})})]})]})}function ol({entries:t,userRoles:e,onEdit:s,loading:n}){const{config:r}=Me(),a=r.tenant==="schools",o=new Map(e.map(l=>[l.userRoleId,l.userRoleName])),c=l=>l.map(u=>o.get(u)||String(u)).join(", ");return i.jsx(d.Table,{rowKey:"id",dataSource:t,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(l,u)=>`${u[0]}-${u[1]} of ${l} items`},loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(l,u)=>i.jsxs("span",{children:[u.l1.minutes?`Action taken in (${u.l1.minutes} Mins)`:"No Action taken in 0 Min",u.l1.roles?.length?`, Escalate to (${c(u.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(l,u)=>i.jsxs("span",{children:[u.l2.minutes?`Action taken in (${u.l2.minutes} Mins)`:"No Action taken in 0 Min",u.l2.roles?.length?`, Escalate to (${c(u.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(l,u)=>i.jsxs("span",{children:[u.l3.minutes?`Action taken in (${u.l3.minutes} Mins)`:"No Action taken in 0 Min",u.l3.roles?.length?`, Escalate to (${c(u.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(l,u)=>u.actions?.length?u.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(l,u)=>u.notify?.length?u.notify.join(", "):"-"},...a?[]:[{title:"Human-In-The-Loop",key:"humanLoop",render:(l,u)=>u.humanLoop?"Yes":"No"}],{title:"Auto Expire",key:"isAutoExpire",render:(l,u)=>u.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(l,u)=>i.jsx(d.Button,{type:"text",onClick:()=>s(u.id),children:i.jsx(ct.EditOutlined,{})})}]})}const{Title:ll,Text:Os}=d.Typography;function ia({userRoles:t,rules:e,rawRules:s}){const{rules:n}=Me(),[r,a]=m.useState(!1),[o,c]=m.useState(!1),[l,u]=m.useState(s),[f,h]=m.useState(),[x,p]=m.useState([]),k=m.useMemo(()=>t.map(T=>({label:T.userRoleName,value:T.userRoleId})),[t]),j=m.useMemo(()=>(e||[]).map(T=>({label:T.Name||"-",value:T.RuleId||T.Name||""})),[e]),M=m.useMemo(()=>(e||[]).map((T,D)=>({key:T.RuleId||T.Name||String(D),ruleName:T.Name||"-",ruleDesc:T.Description||""})),[e]);m.useEffect(()=>{let T=!1;return(async()=>{try{a(!0);const D=await n.getRules();T||u(Array.isArray(D)?D:[])}catch{!T&&Array.isArray(s)&&u(s)}finally{T||a(!1)}})(),()=>{T=!0}},[]),m.useEffect(()=>{!l&&Array.isArray(s)&&u(s)},[s]),m.useEffect(()=>{if(!f||!Array.isArray(l)){p([]);return}const T=l.find(B=>B?.ruleId===f||B?.RuleId===f||B?.ruleName===f),D=T?.userRoleIds??T?.UserRoleIds;p(Array.isArray(D)?D:[])},[f,l]);const G=m.useMemo(()=>{if(!Array.isArray(l)||!l.length)return{};const T={};for(const D of M){const B=l.find(y=>y?.ruleId===D.key||y?.ruleName===D.key||y?.RuleId===D.key||y?.ruleName===D.ruleName||y?.Name===D.ruleName),C=B?.userRoleIds??B?.UserRoleIds,q=Array.isArray(C)?C:[];q.length&&(T[D.key]=q)}return T},[l,M]),L=()=>{h(void 0),p([])},$=async()=>{if(!f){Ae.toast.info("Please select a rule");return}try{c(!0);const T=Array.isArray(l)?l.find(y=>y?.ruleId===f||y?.RuleId===f||y?.ruleName===f):void 0,D=typeof T?.recordId=="number"?T.recordId:T?.ruleId||T?.RuleId||void 0;if(!T||!D)throw new Error(`Unable to find rule identifier for rule ${f}`);const B=x.map(y=>{const g=t.find(O=>O.userRoleId===y);return{id:y,name:g?.userRoleName??String(y)}}),C={...T,ruleId:f,userRoleIds:x,userRoles:B},q=await n.updateRule(D,C);if(!q?.responseStatus&&!q?.Success&&!q?.success)Ae.toast.error(q?.errorMessage||q?.Message||"Error saving Alert Assignment");else{Ae.toast.success("Alert assignment saved"),h(void 0),p([]);try{const y=await n.getRules();u(Array.isArray(y)?y:[])}catch(y){console.error("Failed to refresh rules after save",y)}}}catch(T){console.error("Failed to save alert assignment",T),Ae.toast.error(T instanceof Error?T.message:"Error saving Alert Assignment")}finally{c(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(ll,{level:4,className:"!mb-4",children:"Alert Assignment"}),i.jsx(d.Spin,{spinning:o||r,children:i.jsxs(d.Row,{gutter:[16,16],align:"bottom",className:"mb-6",children:[i.jsx(d.Col,{xs:24,sm:12,md:8,lg:6,children:i.jsxs("div",{children:[i.jsx(Os,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),i.jsx(d.Select,{placeholder:"Rules",value:f,onChange:h,options:j,className:"w-full"})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:8,children:i.jsxs("div",{children:[i.jsx(Os,{className:"text-gray-700 font-medium block mb-1",children:"Alert Notification To"}),i.jsx(d.Select,{mode:"multiple",placeholder:"Select roles",className:"w-full",value:x,onChange:p,options:k,maxTagCount:1,maxTagPlaceholder:Zs})]})}),i.jsx(d.Col,{xs:24,sm:12,md:8,lg:4,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Button,{onClick:L,disabled:o,children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:$,loading:o,disabled:o||!f,children:"Save"})]})})]})}),i.jsx(d.Table,{rowKey:"key",dataSource:M,loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:(T,D)=>`${D[0]}-${D[1]} of ${T} items`},columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(T,D)=>{const B=G[D.key]??[];return B.length?i.jsx("div",{className:"flex flex-wrap gap-1",children:B.map(C=>{const q=t.find(y=>y.userRoleId===C);return i.jsx(d.Tag,{children:q?.userRoleName??String(C)},C)})}):i.jsx(Os,{type:"secondary",children:"—"})}}]})]})}const{Title:qn}=d.Typography;function js(t){return!t||typeof t!="object"?{}:{level1UserRoleId:t.level1UserRoleId??t.Level1UserRoleId,level1PostAssistTime:t.level1PostAssistTime??t.Level1PostAssistTime,level2UserRoleId:t.level2UserRoleId??t.Level2UserRoleId,level2PostAssistTime:t.level2PostAssistTime??t.Level2PostAssistTime,level3UserRoleId:t.level3UserRoleId??t.Level3UserRoleId,level3PostAssistTime:t.level3PostAssistTime??t.Level3PostAssistTime,escalationSettingsActionTypeIds:t.escalationSettingsActionTypeIds??t.EscalationSettingsActionTypeIds,thirdPartyId:t.thirdPartyId??t.ThirdPartyId??t.ThirdPartyIds,humanLoop:t.humanLoop??t.HumanLoop,isAutoExpire:t.isAutoExpire??t.IsAutoExpire}}function oa({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r,onSave:a}){const{rules:o,alerts:c}=Me(),[l,u]=m.useState("By Severity"),[f,h]=m.useState("By severity"),[x,p]=m.useState("By Severity"),[k,j]=m.useState(!1),[M,G]=m.useState(!1),[L,$]=m.useState(!1),[T,D]=m.useState(null),[B,C]=m.useState("rules"),[q,y]=m.useState(),[g,O]=m.useState(),[oe,re]=m.useState(),[U,v]=m.useState(),[S,I]=m.useState(),[A,R]=m.useState(),[F,Y]=m.useState(),[K,te]=m.useState(),[ae,ue]=m.useState([]),[xe,de]=m.useState([]),[me,ge]=m.useState(!1),[le,ie]=m.useState(!1),[Te,Oe]=m.useState({}),[He,ne]=m.useState({}),[Z,ve]=m.useState(s||[]),[fe,Ne]=m.useState([]),[De,$e]=m.useState(!1),[Pe,we]=m.useState(!1),[Re,et]=m.useState(n||[]);m.useEffect(()=>{n&&n.length&&et(n)},[n]),m.useEffect(()=>{if(!Re||!Re.length)return;const w=Object.keys(Te).length>0||Object.keys(He).length>0;if(fe.length&&!w)return;const H=Re.map((z,E)=>{const Q=e.find(Ie=>Ie.RuleId===(z.ruleId||z.ruleName))?.Name||z.ruleName||z.Name||"-",P=js(z.escalationSettings),J=typeof P.level1UserRoleId=="number"&&P.level1UserRoleId>0?[P.level1UserRoleId]:[],ps=typeof P.level2UserRoleId=="number"&&P.level2UserRoleId>0?[P.level2UserRoleId]:[],gs=typeof P.level3UserRoleId=="number"&&P.level3UserRoleId>0?[P.level3UserRoleId]:[],rn=(Array.isArray(P.escalationSettingsActionTypeIds)?P.escalationSettingsActionTypeIds:[]).map(Ie=>Te[Ie]||String(Ie)),on=(Array.isArray(P.thirdPartyId)?P.thirdPartyId:[]).map(Ie=>He[Ie]||String(Ie)),Ss=typeof P.humanLoop=="boolean"?P.humanLoop:null,xs=typeof P.isAutoExpire=="boolean"?P.isAutoExpire:null;return{id:String(z.ruleId||z.ruleName||E),ruleOrSeverityLabel:Q,l1:{minutes:P.level1PostAssistTime??void 0,roles:J},l2:{minutes:P.level2PostAssistTime??void 0,roles:ps},l3:{minutes:P.level3PostAssistTime??void 0,roles:gs},actions:rn,notify:on,humanLoop:Ss,isAutoExpire:xs}});Ne(H)},[Re,e,Te,He]);const mt=m.useMemo(()=>t.map(w=>({label:w.DisplayName,value:w.SeverityId})),[t]),ft=m.useMemo(()=>e.map(w=>({label:w.Name,value:w.RuleId})),[e]),ht=m.useMemo(()=>Z.map(w=>({label:w.userRoleName,value:w.userRoleId})),[Z]),Et=m.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(w=>({label:`${w}`,value:w})),[]);m.useEffect(()=>{let w=!1;async function H(){try{$(!0),D(null);const z=await c.getAdminSettings();if(!w&&z){const E=Kn(z.sortBy);u(E),p(E),j(!1)}}catch(z){if(!w){const E=z instanceof Error?z.message:"Failed to load admin settings";D(E)}}finally{w||$(!1)}}return H(),()=>{w=!0}},[]),m.useEffect(()=>{if(!g)return;const w=Q=>{const P=Number(Q);return!isNaN(P)&&P>0?P:void 0},H=Q=>{const P=Number(Q);return!isNaN(P)&&P>0?P:void 0},z=(Re||[]).find(Q=>Q?.ruleId===g||Q?.ruleName===g||Q?.RuleId===g),E=js(z?.escalationSettings);if(E&&typeof E=="object"){re(H(E.level1PostAssistTime)),v(w(E.level1UserRoleId)),I(H(E.level2PostAssistTime)),R(w(E.level2UserRoleId)),Y(H(E.level3PostAssistTime)),te(w(E.level3UserRoleId));const Q=Array.isArray(E.escalationSettingsActionTypeIds)?E.escalationSettingsActionTypeIds:[];ue(Q.map(P=>String(P))),de(Array.isArray(E.thirdPartyId)?E.thirdPartyId:[]),ge(!!E.humanLoop),ie(!!E.isAutoExpire)}},[B,g,Re]);const yt=async()=>{try{we(!0);const w=await o.getRules(),H=Array.isArray(w)?w:Array.isArray(w?.data)?w.data:[];et(H);const z=H.map((E,Q)=>{const P=e.find(Ie=>Ie.RuleId===(E.ruleId||E.ruleName))?.Name||E.ruleName||E.Name||"-",J=js(E.escalationSettings??E.EscalationSettings),ps=typeof J.level1UserRoleId=="number"&&J.level1UserRoleId>0?[J.level1UserRoleId]:[],gs=typeof J.level2UserRoleId=="number"&&J.level2UserRoleId>0?[J.level2UserRoleId]:[],nn=typeof J.level3UserRoleId=="number"&&J.level3UserRoleId>0?[J.level3UserRoleId]:[],an=(Array.isArray(J.escalationSettingsActionTypeIds)?J.escalationSettingsActionTypeIds:[]).map(Ie=>Te[Ie]||String(Ie)),Ss=(Array.isArray(J.thirdPartyId)?J.thirdPartyId:[]).map(Ie=>He[Ie]||String(Ie)),xs=typeof J.humanLoop=="boolean"?J.humanLoop:null;return{id:String(E.ruleId||E.ruleName||Q),ruleOrSeverityLabel:P,l1:{minutes:J.level1PostAssistTime??void 0,roles:ps},l2:{minutes:J.level2PostAssistTime??void 0,roles:gs},l3:{minutes:J.level3PostAssistTime??void 0,roles:nn},actions:an,notify:Ss,humanLoop:xs}});Ne(z)}catch(w){console.error("Failed to refetch entries",w)}finally{we(!1)}};m.useEffect(()=>{let w=!1;return(async()=>{try{const H=await o.getLookups();if(w||!H)return;const z={};if(Array.isArray(H.thirdParties))for(const Q of H.thirdParties){const P=Q.thirdPartyIds??Q.thirdPartyId;typeof P=="number"&&(z[P]=Q.thirdPartyName)}ne(z);const E=Array.isArray(H.userRoles)?H.userRoles.map(Q=>({userRoleId:Q.userRoleId??Q.id,userRoleName:Q.userRoleName??Q.name})):[];w||ve(E.length?E:s||[])}catch(H){console.error("Error loading lookups",H)}})(),()=>{w=!0}},[]);const he=async()=>{G(!0);try{const w=await c.setAdminSettings({sortBy:l,groupBy:"string"});w?.responseStatus&&w?.data&&Ae.toast.success(w.data),p(l),j(!1)}catch(w){console.error("Error saving admin settings",w)}finally{G(!1)}},pt=()=>{u(x),j(!1)},b=async()=>{$e(!0),a?.({ruleId:g,levels:[{minutes:oe,role:U},{minutes:S,role:A},{minutes:F,role:K}],actions:ae,thirdPartyIds:xe,humanLoop:me,isAutoExpire:le});try{if(g){const H=Array.isArray(ae)?ae.map(J=>Number.isNaN(Number(J))?J:Number(J)):[],z=(Re||[]).find(J=>J?.ruleId===g||J?.ruleName===g||J?.RuleId===g),E=typeof z?.recordId=="number"?z.recordId:z?.ruleId||z?.RuleId||void 0;if(!z||!E){Ae.toast.error("Unable to find rule identifier for update");return}const Q={...z,escalationSettings:{level1UserRoleId:U??0,level1PostAssistTime:oe??0,level2UserRoleId:A??0,level2PostAssistTime:S??0,level3UserRoleId:K??0,level3PostAssistTime:F??0,escalationSettingsActionTypeIds:H,thirdPartyId:Array.isArray(xe)?xe:[],humanLoop:me,isAutoExpire:le}},P=await o.updateRule(E,Q);P?.responseStatus||P?.Success||P?.success?(Ae.toast.success("Escalation settings saved"),await yt(),O(void 0),re(void 0),v(void 0),I(void 0),R(void 0),Y(void 0),te(void 0),ue([]),de([]),ge(!1),ie(!1)):Ae.toast.error(P?.errorMessage||P?.Message||"Error saving Escalation Settings")}}catch(H){console.error("Error saving escalation settings",H)}finally{$e(!1)}},_=()=>{u("By Severity"),h("By severity"),C("rules"),y(void 0),O(void 0),re(void 0),v(void 0),I(void 0),R(void 0),Y(void 0),te(void 0),ue([]),de([]),ge(!1),ie(!1)};return i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(qn,{level:4,className:"!mb-2",children:"Admin Settings"}),i.jsxs(d.Spin,{spinning:L,children:[T?i.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",T]}):null,i.jsx(al,{sortBy:l,groupBy:f,onChange:w=>{w.sortBy&&(u(w.sortBy),j(!0)),w.groupBy&&(h(w.groupBy),j(!0))},showActions:k,onSave:he,onClear:pt,saving:M})]})]}),i.jsx(d.Divider,{className:"my-6"}),i.jsxs("div",{children:[i.jsx(qn,{level:4,className:"!mb-4",children:"Escalation Settings"}),i.jsx(il,{escBasis:B,setEscBasis:C,selectedSeverity:q,setSelectedSeverity:y,selectedRule:g,setSelectedRule:O,severityOptions:mt,ruleOptions:ft,minsOptions:Et,roleOptions:ht,l1mins:oe,setL1mins:re,l1role:U,setL1role:v,l2mins:S,setL2mins:I,l2role:A,setL2role:R,l3mins:F,setL3mins:Y,l3role:K,setL3role:te,actions:ae,setActions:ue,thirdPartyIds:xe,setThirdPartyIds:de,humanLoop:me,setHumanLoop:ge,onClear:_,onSave:b,saving:De,onActionTypesLoaded:w=>{const H={};for(const z of w)typeof z.actionTypeId=="number"&&(H[z.actionTypeId]=z.name);Oe(H)},isAutoExpire:le,setAutoExpire:ie})]}),i.jsx(d.Divider,{className:"my-6"}),i.jsx(ol,{entries:fe,userRoles:Z,loading:Pe||r,onEdit:w=>{C("rules");const H=fe.find(E=>E.id===w),z=e.find(E=>E.RuleId===w)||(H?e.find(E=>E.Name===H.ruleOrSeverityLabel):void 0);O(z?z.RuleId:w)}}),i.jsx(d.Divider,{className:"my-6"}),i.jsx(ia,{userRoles:Z,rules:e,rawRules:n}),i.jsx(d.Divider,{})]})}const{Title:Gn,Text:Kt}=d.Typography;function cl({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:a}=Me(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[c,l]=m.useState("By Severity"),[u,f]=m.useState(new Set),[h,x]=m.useState(null),[p,k]=m.useState(null),[j,M]=m.useState({inApp:!1,sms:!1,email:!1}),[G,L]=m.useState([]),[$,T]=m.useState(!0),[D,B]=m.useState(!1);m.useEffect(()=>{let y=!1;return(async()=>{try{const g=await a.getPreferenceSettings();if(y||!g)return;M({inApp:!!g.inApp,sms:!!g.sms,email:!!g.email});const O=Kn(g.sortBy);l(O==="By Created Date"?"By Created Date":"By Severity"),x(hn(g.doNotDisturbStart)),k(hn(g.doNotDisturbEnd)),Array.isArray(g.anomalyIds)&&f(new Set(g.anomalyIds.map(oe=>String(oe))))}catch(g){console.error("Error in loading my preferences: ",g)}})(),()=>{y=!0}},[]),m.useEffect(()=>{let y=!1;return(async()=>{try{T(!0);const g=await r.getLookups();if(y||!g)return;const O=Array.isArray(g.anomalies)?g.anomalies:[];L(O)}catch(g){console.error("Failed to load anomalies lookups",g)}finally{y||T(!1)}})(),()=>{y=!0}},[]);const C=y=>{f(g=>{const O=new Set(g);return O.has(y)?O.delete(y):O.add(y),O})},q=async()=>{s?.({sortBy:c,subscribedRuleIds:Array.from(u),dnd:{from:h,to:p},channels:j});try{B(!0);const y=h?h.format?.("HH:mm:ss")??"00:00:00":"00:00:00",g=p?p.format?.("HH:mm:ss")??"00:00:00":"00:00:00",O=Array.from(u).map(re=>Number(re)).filter(re=>Number.isFinite(re)),oe=await a.setPreferenceSettings({anomalyIds:O,doNotDisturbStart:y,doNotDisturbEnd:g,inApp:!!j.inApp,sms:!!j.sms,email:!!j.email,sortBy:c});oe?.responseStatus&&Ae.toast.success(oe?.data||"Preferences updated successfully.")}catch(y){console.error("Error in saving my preferences: ",y)}finally{B(!1)}};return i.jsxs("div",{className:"w-full",children:[i.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:i.jsx(d.Col,{xs:24,md:8,children:i.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(Kt,{className:"text-gray-600",children:"Sort By:"}),i.jsx(d.Select,{className:"w-[240px]",value:c,options:o,onChange:l})]})})}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Gn,{level:5,className:"!mb-2",children:"Anomalies"}),$?i.jsx("div",{className:"py-4",children:i.jsx(d.Spin,{})}):i.jsx(d.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(G)?G:[]).map(y=>{const g=String(y.recordId),O=y.anomalyName;return i.jsx(d.Checkbox,{checked:u.has(g),onChange:()=>C(g),children:O},g)})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(Gn,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),i.jsx(d.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:i.jsx(d.Col,{xs:24,md:12,children:i.jsxs(d.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[i.jsx(Kt,{children:"Do Not Disturb mode:"}),i.jsxs(d.Space,{size:12,className:"w-full",children:[i.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(Kt,{children:"From"}),i.jsx(d.TimePicker,{value:h,onChange:y=>x(y),format:"HH:mm"})]}),i.jsxs(d.Space,{direction:"horizontal",size:8,className:"items-center",children:[i.jsx(Kt,{children:"To"}),i.jsx(d.TimePicker,{value:p,onChange:y=>k(y),format:"HH:mm"})]})]})]})})}),i.jsxs(d.Row,{gutter:[24,12],children:[i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:j.inApp,onChange:y=>M({...j,inApp:y.target.checked}),children:"In-app"})}),i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:j.sms,onChange:y=>M({...j,sms:y.target.checked}),children:"SMS"})}),i.jsx(d.Col,{children:i.jsx(d.Checkbox,{checked:j.email,onChange:y=>M({...j,email:y.target.checked}),children:"Email"})})]})]}),i.jsx(d.Divider,{}),i.jsxs(d.Space,{className:"gap-3",children:[i.jsx(d.Button,{onClick:n,disabled:D,children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:q,loading:D,children:"Save"})]})]})}function la({severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r}){return i.jsx("div",{className:"w-full",children:i.jsx(oa,{severities:t,rules:e,userRoles:s,rawRules:n,loadingRules:r})})}const ul="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIZSURBVHgBnZW/b9NAFMe/z3H6i1ZNJUBFQsL/QQkLCFBtRhhKF1ibhBmpXbtgFlYqsTG0gRGWwgAjMb8EYmjYGN0pCCrVVaX+SBxf37PiqHWcOu5Xsux79+6j77vz3RH66IbdsDTQPCFngmBwqMCPBwVXoe204Fd/2ZfrSWMpHrDshtGCvsY9FlKkFNYD+Es/7EtuX+itp1sLnLrScTWoPMYsfnty/lUPtAOs4syiUgQOoWHJpG9kdBiX11Z+UaZCk1YT+vOzACuzYxgf7hZbyBGvhTi9af+7SkQbyKi7M8N4ZJ5D+eU2dg9UN07KvyNOS8io6UkNFXMMj1/vnACKAuTmNXZpIqME+LF+iIbX7ukjkClODWTQw+ujuGYMYfXzXnICbxSBDrxAUvYDhkrZp6ggUC8+sDI7mpj9YmESb3/uJ5Z9TJ5A3eORvzsBpgs6lufGT2TKPNY3fbxh6Knis0FTSjnx+LP3u5DJicDi/t7MCFadPaRJQTl02/5vKcKnpITluYkwrWjksebs48Pvg3SoUkXtq32hxt+1pITI8Zc/zcGACN59ty/WdWnklV5ukZ+49wU8MUJIF3mBGlqUr3Dv1+wpl20v9UuP75pElyrgc3XK7UJFbLvK4DJiv9ggDmWcjO9G4imWvW00yV/hjvtpOFnpQOVLkcO+0EhyevGrROG1ol1hREFc8ZGxyddIje+v9c4i9+gI5z7MozLxclgAAAAASUVORK5CYII=",dl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgBjVVdbtpAEJ5ZmygPfTBSaVWpUt0bwFuURgJOUG5QeoLACbw+QeAEwA3SGxgJokh9CDeI+xSpTRU/Imw8nbFZx6QQGAl5d2fm229+dkDYI2f6oaUAOwhWExBcPnL4FwFBSLCexpCMf+qPi12++PKgpR/cGOwRa1pwQIjgOoWkf6s/hOVzVd588R+/xWjf5YAY8Y0+ErQrZFfnXg3lK3uGm7A+RISOxfbit5NprqBxxgBoeEIVHehqtI9lSz+5McaaITaA2J17bycFaBayMOS8IaT+zHuv4Ui58P9oAvB4Ga0paUgqbFGswL5idIcIx3P9DCiXrQB7iJawcTiCkMMIUlj7Jo8zr6Yv/EfRXXIqRnzUxnP9u46Id8Q5Sslq3+pqWErHAPKqvxROC/ZMuJwKJ8bkPouUkrYUqgt5IgMDKAxfAYT8nAZnmR2A5J47YSjrFKyOYpZN2SiIJ8YjRqVfASyAFVg9s2F2gXwRsClMXdnYcFpq5PyiQ8KEilaywc79+aEow2i7fdCF46SIpuTvCGi2kWSXjCM4QqS4Zl3yjwQ0UySwrBfGRJNjQKW4ZrmEpL45CxUDTGWdgmoZgxOoDA6zxYgr7ZudhWk3x6Sp4kl0nZmgujQhcH5Cvqy/Hxi5hdL+dgsWxR2rma4FkLeDw+PMM243+t2YB0jDDI9nMBquyWqI3tjmLYguQfqDzxebty/DIcnePr9jfePVfDhSzv2/Hs8LAY3kMmFfTCl+rl3uu1GWF6Jx+X3vkpa+58jeeNyXvY3Pd8N+a0hvgK9ge3hMTmG5CPTnSICWcFpXaDfZUcAck99yOnZM/id3hcmAFV/hgEilU6p0TcH2gpZYS98xc/kXUJ8YImPFzfeLh0cgXbMp8n/yD3ySPZSK0MWKAAAAAElFTkSuQmCC";function hs(){const{config:t}=Me();return{timeZoneDetails:m.useMemo(()=>{const s=t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone;return{timeZoneUniqueId:"",ianaTimeZoneId:s,timeZoneName:s,offset:""}},[t.timeZone]),loading:!1}}function ml(t){const e=(t.status||"").toLowerCase()==="completed"?i.jsx("img",{src:ul,alt:"completed",style:{width:20,height:20}}):i.jsx("img",{src:dl,alt:"pending",style:{width:20,height:20}});return{title:i.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:i.jsx("b",{children:t.title})}),t.description?i.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?i.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function fl({data:t}){const{timeZoneDetails:e}=hs();return console.log("summary",t),i.jsx("div",{className:"w-full",children:i.jsx(d.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:i.jsxs("div",{className:"w-full",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsx(d.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:i.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Alert ID"}),i.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Severity"}),i.jsx("span",{className:"text-black",children:t.summary.severity})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-gray-500",children:"Location"}),i.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),i.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),i.jsx("div",{className:"mt-2",children:i.jsx(d.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(ml)})})]})]})},{key:"notification",label:"Notification Sent",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",style:{maxHeight:"50vh",overflowY:"auto"},children:[(t.notifications||[]).map((s,n)=>i.jsxs(d.Card,{className:"rounded-md p-4",bordered:!0,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),i.jsx("span",{className:"text-xs text-gray-500 mt-1",children:os(s.sentAt,e?.ianaTimeZoneId)})]}),i.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-green-50 text-green-700 border border-green-200",children:[s.delivered,"/",s.total," Delivered"]})]}),i.jsxs("div",{className:"mt-4 text-xs",children:[i.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?i.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),i.jsxs("div",{className:"mt-4",children:[i.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),i.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,a)=>{const o=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("span",{className:"text-black",children:[r.name," - ",i.jsx("span",{style:{color:o?"#FF3B30":"#FFB86A"},children:o?"Escalation Notification":"Alert Notification"})]}),i.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),i.jsx("span",{className:`text-[11px] px-3 py-[2px] rounded ${r.status==="Delivered"?"bg-green-50 text-green-700 border border-green-200":"bg-red-50 text-red-700 border border-red-200"}`,children:r.status})]},a)})})]})]},n)),t?.notifications?.length?null:i.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const hl=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:a,notifGroups:o})=>{const c={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:l}=hs(),u=a?.length?a.map(h=>{const x=(h?.status||h?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",p=h?.createdDate?os(h.createdDate,l?.ianaTimeZoneId):h?.timestamp?os(h.timestamp,l?.ianaTimeZoneId):"";return{status:x,title:h?.status||h?.eventStatus||"Status Update",description:h?.description||h?.actionNotes||"",timestamp:p}}):[],f={summary:c,timeline:u,notifications:o??[]};return i.jsx(fl,{data:f})};const yl=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),pl=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),Yn=t=>{const e=pl(t);return e.charAt(0).toUpperCase()+e.slice(1)},ca=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),gl=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Sl={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const xl=m.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:a,iconNode:o,...c},l)=>m.createElement("svg",{ref:l,...Sl,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:ca("lucide",r),...!a&&!gl(c)&&{"aria-hidden":"true"},...c},[...o.map(([u,f])=>m.createElement(u,f)),...Array.isArray(a)?a:[a]]));const ys=(t,e)=>{const s=m.forwardRef(({className:n,...r},a)=>m.createElement(xl,{ref:a,iconNode:e,className:ca(`lucide-${yl(Yn(t))}`,`lucide-${t}`,n),...r}));return s.displayName=Yn(t),s};const vl=[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]],wl=ys("image-off",vl);const Al=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Tl=ys("loader-circle",Al);const Nl=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ua=ys("maximize-2",Nl);const bl=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],kl=ys("minimize-2",bl),Il=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,a]=m.useState(!1),[o,c]=m.useState(!1);return m.useEffect(()=>{t&&c(!1)},[t,s]),m.useEffect(()=>{t&&(!s||o)&&e()},[t,s,o,e]),t?i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70",role:"button",tabIndex:0,"aria-label":"Close media preview",onClick:e,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),e())},onTouchStart:e,children:i.jsxs("div",{className:`relative ${r?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:l=>l.stopPropagation(),children:[n==="image"?i.jsx("img",{src:s,alt:"preview",className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>c(!0)}):i.jsx("video",{src:s,controls:!0,className:`object-contain rounded-lg shadow-lg ${r?"w-full h-full":"max-w-full max-h-[90vh]"}`,onError:()=>c(!0)}),i.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),i.jsx("button",{onClick:()=>a(!r),className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:r?i.jsx(kl,{size:20}):i.jsx(ua,{size:20})})]})}):null};function El(t){if(!t||typeof t!="string")return!1;const e=t.split("?")[0].toLowerCase();return e.endsWith(".mp4")||e.endsWith(".webm")||e.endsWith(".ogg")||e.endsWith(".m3u8")}function _n(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:El(t?.mediaUrl||t)}function Ml(t){const e=t?.mediaUrl;let s=null;if(Array.isArray(e))s=e;else if(typeof e=="string")try{const n=JSON.parse(e);Array.isArray(n)&&(s=n)}catch{}return s&&s.length>0?s.map(n=>({...t,mediaUrl:n})):[t]}function Ol(t){const e=t;return e?(Array.isArray(e)?e:[e]).flatMap(Ml):[]}const jl={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Cl={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Dl=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:a=!1,initialTab:o="details",sourceTab:c})=>{const[l,u]=m.useState(),[f,h]=m.useState(""),[x,p]=m.useState(!1),k=m.useRef(null),[j,M]=m.useState("details"),[G,L]=m.useState(void 0),$=Gs(),{alerts:T,rules:D,config:B}=Me(),{timeZoneDetails:C}=hs(),[q,y]=m.useState(null),[g,O]=m.useState(!1),[oe,re]=m.useState(!1),[U,v]=m.useState(void 0),[S,I]=m.useState(void 0),[A,R]=m.useState({}),[F,Y]=m.useState({}),K=(b,_,w)=>{const H=F[b];return A[b]===!1&&!H?i.jsxs("div",{className:"w-full flex flex-col items-center justify-center min-h-[200px] bg-gray-100 rounded-lg gap-2 text-gray-400",children:[i.jsx(wl,{size:40}),i.jsx("span",{className:"text-sm",children:"Media not available"})]}):i.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[H&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:i.jsx(Tl,{size:32,className:"animate-spin text-gray-400"})}),i.jsx("img",{src:b,alt:_.caption||`media-${w}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${H?"opacity-0":"opacity-100"}`,onLoad:()=>Y(z=>({...z,[b]:!1})),onError:()=>Y(z=>({...z,[b]:!1}))},b)]})},te=s?.originalData||{},{eventName:ae,anomalyName:ue,alertId:xe,timestamp:de,description:me,spaceName:ge,assignTeam:le,priority:ie,statusType:Te,id:Oe,alertDetails:He,statusHistory:ne,mediaDetails:Z,alertNumber:ve}=te,fe=b=>{const _=String(b||"").toLowerCase();return _==="delivered"||_==="sent"?"Delivered":_==="failed"?"Failed":"Queued"},Ne=b=>({name:b?.receipientName||b?.recipientName||"-",role:b?.receipientRoleName||"",phone:b?.receipentPhoneNumber||b?.recipientPhoneNumber||b?.receipientEmail||b?.recipientEmail||"",status:fe(b?.messageStatus),notificationReceipientType:b?.notificationReceipientType||""}),De=(b,_)=>{const w=_.map(Ne),H=w.filter(P=>P.status==="Delivered").length,z=_.map(P=>P?.sentAt).filter(Boolean).sort((P,J)=>new Date(J).getTime()-new Date(P).getTime())[0],E=_[0]||{},Q=[E?.severityName,E?.anomalyName].filter(Boolean).join(" - ")||`${b} Notification`;return{channelLabel:`${b} Notification`,sentAt:z||"",messageTitle:Q,messageBody:"",total:w.length,delivered:H,recipients:w}},$e=b=>{const _=new Map;return(b||[]).forEach(w=>{const H=String(w?.notificationType||"Unknown"),z=_.get(H)||[];z.push(w),_.set(H,z)}),Array.from(_.entries()).map(([w,H])=>De(w,H))},Pe=async b=>{try{const _=await T.getAlertNotifications(b),w=$e(_);L(w)}catch{L(void 0)}};m.useEffect(()=>{if(j!=="track"||!Oe)return;let b=!1;return Pe(Oe).then(()=>{b&&L(void 0)}),()=>{b=!0}},[j,Oe]),m.useEffect(()=>{t?M(o):(u(void 0),h(""))},[t,o]),m.useEffect(()=>{if(!t||B.tenant!=="snl")return;let b=!1;return O(!0),D.getLookups().then(_=>{b||(y(_.alertStatusTypes??[]),O(!1))}).catch(()=>{b||(y([]),O(!1))}),()=>{b=!0}},[t,B.tenant]);const Re=c==="archived"||["completed","false positive"].includes(String(Te||"").toLowerCase()),et=b=>{const _=String(b?.value||"").toLowerCase(),w=String(b?.statusName||"").toLowerCase();return _.includes("reopen")||w.includes("reopen")},mt=ue==="Elopement Attempt"||ue==="Elopement Completed",ft=r.filter(b=>{const _=et(b);return typeof c<"u"?c==="archived"?_:!_:Re?_:!_}).map(b=>({value:b.value,label:b.statusName})),Et=(q??[]).filter(b=>b.isElopementStatus===mt).map(b=>({value:b.alertStatusTypeName,label:b.alertStatusTypeName})),yt=B.tenant==="snl"&&q!==null?Et:ft,he=m.useMemo(()=>Ol(Z),[Z]);m.useEffect(()=>{let b=!1;const _=new AbortController,w=async E=>{if(E){b||R(Q=>({...Q,[E]:!1}));try{const Q=await fetch(E,{method:"HEAD",signal:_.signal});if(Q.ok){b||R(J=>({...J,[E]:!0}));return}if(Q.status===404){b||R(J=>({...J,[E]:!1}));return}if(!(await fetch(E,{method:"GET",signal:_.signal})).ok)throw new Error("Media not available");b||R(J=>({...J,[E]:!0}))}catch{b||R(Q=>({...Q,[E]:!1}))}}};R({});const H=he.filter(E=>!_n(E)).map(E=>E?.mediaUrl||E).filter(E=>typeof E=="string"&&E.length>0),z={};return H.forEach(E=>{z[E]=!0}),Y(z),H.forEach(E=>w(E)),()=>{b=!0,_.abort()}},[he]);const pt=async()=>{try{p(!0);const b={alertUniqueId:xe,alertId:Oe,status:l?String(l):void 0,notes:f.trim(),modifiedBy:0},_=await $.mutateAsync(b);if(_?.responseStatus||_?.Success){const w=_?.Message||_?.data||"Alert updated successfully.";Ae.toast.success(w,{autoClose:1500,onClose:()=>{n(),e()}}),u(void 0),h("")}else{const w=_?.errorMessage||_?.Message||"Failed to update alert status";Ae.toast.error(w)}}catch(b){console.error("Error updating alert status:",b),Ae.toast.error("Failed to update alert status. Please try again.")}finally{p(!1)}};return i.jsx(d.Modal,{open:t,onCancel:e,width:1e3,footer:j==="details"?i.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[i.jsx(d.Button,{onClick:e,className:"bg-[#6C757D] text-white",children:"Cancel"}),i.jsx(d.Button,{type:"primary",onClick:pt,loading:x,children:x?"Saving...":"Save Changes"})]}):null,children:s&&i.jsx(d.Tabs,{activeKey:j,onChange:b=>M(b),items:[{key:"details",label:"Alert Detail",children:i.jsxs("div",{className:"grid grid-cols-2 gap-2",style:{maxHeight:"50vh",overflowY:"auto"},children:[i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("div",{className:"text-sm font-bold",children:ae||"Alert Event"}),He?.firstName?i.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",He?.firstName," ",He?.lastName||"","   ",He?.residentId||""]}):null,i.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",os(de,C?.ianaTimeZoneId)]}),i.jsxs("div",{className:"font-sm text-gray-500",children:[i.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",me||"No description available"]}),ge&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",ge]}),le&&i.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",le]}),i.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[i.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${jl[String(ie)]||"#DFE4EA"}`,backgroundColor:Cl[String(ie)]},children:["Severity: ",ie||"N/A"]}),i.jsxs(d.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Te||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Te||"N/A"]})]}),i.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:i.jsxs("div",{className:"w-full mt-4",children:[i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx(d.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:b=>u(b),value:l,options:yt,loading:B.tenant==="snl"?g:a})}),i.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[i.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),i.jsx("textarea",{id:"action-details-input",placeholder:"Enter details...",className:"w-full text-gray-500 h-20 border border-grey-500 rounded-md p-2",value:f,onChange:b=>h(b.target.value)})]})]})})]}),i.jsx("div",{className:"flex flex-col gap-4",children:i.jsxs("div",{className:"w-full mt-1",children:[i.jsxs("div",{className:"w-full flex items-center justify-between",children:[i.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),he.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>k.current?.prev?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Previous media",children:i.jsx(ct.LeftOutlined,{style:{fontSize:12}})}),i.jsx("button",{type:"button",onClick:()=>k.current?.next?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Next media",children:i.jsx(ct.RightOutlined,{style:{fontSize:12}})})]}):null]}),he.length?i.jsx("div",{className:"w-full",children:i.jsx(d.Carousel,{ref:k,dots:!0,className:"w-full",children:he.map((b,_)=>{const w=b.mediaUrl||b,H=_n(b);return i.jsxs("div",{className:"flex justify-center items-center relative",children:[H?i.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[i.jsx("source",{src:w}),"Your browser does not support the video tag."]}):K(String(w),b,_),b.caption&&i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:b.caption}),!H&&A[String(w)]?i.jsx("button",{onClick:()=>{re(!0),v(w),I(b.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:i.jsx(ua,{size:20})}):null]},String(w)||_)})})}):null]})}),i.jsx(Il,{isOpen:oe,onClose:()=>re(!1),src:U||"",type:S||"image"})]})},{key:"track",label:"Track Incident",children:i.jsx(hl,{alertId:xe,id:Oe,priority:ie,spaceName:ge,alertNumber:ve,statusHistory:ne,notifGroups:G})}]})})};function da(){const{alerts:t}=Me(),e=ut.useQuery({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function sn({alerts:t,loading:e=!1,columns:s,total:n,currentPage:r,onRefetch:a,onPageChange:o,onFilterChange:c}){const[l,u]=m.useState(!1),[f,h]=m.useState(null),[x,p]=m.useState("details"),{list:k,loading:j}=da(),{config:M}=Me(),G=M.tenant==="schools",{timeZoneDetails:L}=hs(),$=L?.timeZoneName??"UTC",T=L?.ianaTimeZoneId??"UTC";function D(oe,re){h(oe),p(re?.tab??"details"),q(re?.sourceTab??"active"),u(!0)}function B(){u(!1)}const[C,q]=m.useState("active"),[y,g]=m.useState(0),O=f?{originalData:{...f,alertId:f.alertId??f.id,mediaDetails:f.mediaDetails}}:null;return i.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[i.jsxs("div",{className:"w-full grid grid-cols-3 sm:grid-cols-1 items-center mb-4",children:[i.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),i.jsx("div",{className:"flex items-center justify-start sm:justify-center",children:i.jsx(aa,{label:$,timeZone:T})})]}),i.jsx(d.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:oe=>{const re=oe==="archived";g(U=>U+1),o?.(1),c?.({isArchived:re})},items:[{key:"active",label:"Active",children:i.jsx(qs,{data:t,loading:e,pageSize:10,total:n,currentPage:r,columns:s||[],onAlertIdClick:D,onRefetch:a,onPageChange:o,onFilterChange:c,resetKey:y,serverSideFilters:G})},{key:"archived",label:"Archived",children:i.jsx(ra,{alerts:t,loading:e,columns:s||[],total:n,currentPage:r,onAlertIdClick:D,onFilterChange:c,onPageChange:o,onRefetch:a,resetKey:y,serverSideFilters:G})},{key:"settings",label:"Settings",children:i.jsx(Rl,{})}]}),i.jsx(Dl,{isModalOpen:l,handleModalClose:B,selectedRow:O,fetchAlertLogs:()=>{},alertStatusList:k,alertStatusLoading:j,initialTab:x,sourceTab:C})]})}function Rl(){const[t,e]=m.useState([]),[s,n]=m.useState([]),[r,a]=m.useState([]),[o,c]=m.useState([]),[l,u]=m.useState(!0),{rules:f}=Me();return m.useEffect(()=>{let h=!0;return(async()=>{try{const x=await f.getRules();if(!h)return;c(Array.isArray(x)?x:[]);const p=(x||[]).map((k,j)=>({RuleId:k.ruleId||k.ruleName||String(j),Name:k.ruleName||k.Name||"-",Description:k.ruleDesc||k.Description||"",SeverityId:0}));e(p);try{const k=await f.getLookups(),j=Array.isArray(k?.userRoles)?k.userRoles.map(M=>({userRoleId:M.userRoleId??M.id,userRoleName:M.userRoleName??M.name})):[];n(j),a(Array.isArray(k?.severities)?k.severities:[])}catch{}}catch{}finally{h&&u(!1)}})(),()=>{h=!1}},[]),i.jsx(la,{severities:r,rules:t,userRoles:s,rawRules:o,loadingRules:l})}function Ul(t){return Array.isArray(t)?{items:t}:t}function ma(t=1,e){const{alerts:s}=Me(),n=ut.useQuery({queryKey:["alerts","list",t,e],queryFn:()=>s.listAlerts({pageNumber:t,pageSize:10,...e}).then(Ul),staleTime:3e4});return{alerts:n.data?.items??[],total:n.data?.total,loading:n.isLoading,error:n.error,refetch:n.refetch}}function Ll(t){const[e,s]=m.useState(1),[n,r]=m.useState({}),{alerts:a,total:o,loading:c,refetch:l}=ma(e,n),u=f=>{"isArchived"in f?r({isArchived:f.isArchived}):r(h=>({...h,...f}))};return i.jsx(sn,{alerts:a,loading:c,columns:t.columns,total:o,currentPage:e,onRefetch:l,onPageChange:s,onFilterChange:u})}function Fl({tenant:t,apiDomain:e,rulesDomain:s,headers:n,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,alerts:c,loading:l,columns:u}){const[f]=m.useState(()=>new ut.QueryClient),h=m.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return i.jsx(ut.QueryClientProvider,{client:f,children:i.jsx(er,{tenant:t,override:h,timeZone:r,userManagementDomain:a,spacesBaseUrl:o,children:Array.isArray(c)?i.jsx(sn,{alerts:c,loading:!!l,columns:u}):i.jsx(Ll,{columns:u})})})}function $l(t){const{alerts:e}=Me(),s=ut.useQuery({queryKey:["alerts","report",t],queryFn:()=>e.getAlertsReport(t),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const Pl=[{title:"ID",dataIndex:"id",key:"id",width:120},{title:"Priority",dataIndex:"priority",key:"priority",width:120},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:220},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description"}];exports.AlertAssignment=ia;exports.AlertConsole=sn;exports.AlertConsoleWidget=Fl;exports.AlertsTable=qs;exports.ApiProvider=er;exports.ArchivedTable=ra;exports.Clock=aa;exports.DataTable=tr;exports.MyPreferencesPanel=cl;exports.SettingsPanel=oa;exports.SettingsTabs=la;exports.exampleAlertColumns=Pl;exports.useAlertStatusList=da;exports.useAlerts=ma;exports.useAlertsReport=$l;exports.useApi=Me;exports.useUpdateAlertStatus=Gs;
2
2
  //# sourceMappingURL=index.cjs.map