@ssgc/alert-console 2.4.3 → 2.4.6
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +1705 -1689
- package/dist/index.es.js.map +1 -1
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),y=require("react"),h=require("antd"),ot=require("@ant-design/icons"),Ne=require("react-toastify");function Gi(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const Se=Gi(y),Qi="#FF3B30",Ji="#FF9500",Ki="#FFCC00",Xi="#34C759",$t={critical:Qi,high:Ji,medium:Ki,low:Xi},vn={Critical:$t.critical,High:$t.high,Medium:$t.medium,Low:$t.low};function ea(t){return vn[t]||vn.Low}function Sn(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,i=Number.parseInt(s,10),a=Number.parseInt(n,10),o=Number.parseFloat(r||"0"),u=Number.isFinite(i)?i:0,c=Number.isFinite(a)?a:0,d=Number.isFinite(o)?o:0;return u*3600+c*60+d}function xn(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(a=>parseInt(String(a).trim(),10)).filter(a=>Number.isFinite(a)),r=new Set,i=[];return n.forEach(a=>{r.has(a)||(r.add(a),i.push(a))}),i}const gr="",ta=gr,sa="",na="",wn={snl:{alerts:gr,rules:ta},schools:{alerts:sa,rules:na}};function Ee(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function ra(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function Wt(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 Me(t,e){const s={...e.headers,...ra()},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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const a=i?.errorMessage||i?.message||`HTTP ${n.status}`;throw new Error(a)}return i}function ia(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ee(t.baseUrl,"/api/Alert"),n=await Me(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ee(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Me(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=Ee(t.baseUrl,"/Alerts/GetAlertsReport"),r=Wt(n,s),i=await Me(r,{method:"GET",headers:e});return Array.isArray(i)?i:[]},async updateAlertStatus(s){const n=Ee(t.baseUrl,"/api/Alert/status");return Me(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ee(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Me(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=Ee(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Me(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ee(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Me(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=Ee(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Me(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),i=r?.responseStatus??!0,a=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:i,errorMessage:i?"":r?.errorMessage??r?.message??"",statusCode:200,data:a}},async getAlertNotifications(s){const n=Ee(t.baseUrl,"/api/Alert/GetNotifications"),r=Wt(n,{alertId:s}),i=await Me(r,{method:"GET",headers:e});return Array.isArray(i)?i:i&&typeof i=="object"&&Array.isArray(i.data)?i.data:[]},async notifyFamilyMembers(s){const n=Ee(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Wt(n,{alertId:s});return Me(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const i=Ee(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),a=Wt(i,{alertId:s,isEmail:n,isSMS:r});return Me(a,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ee(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Me(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ee(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Me(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 bn(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{}}}async function Vt(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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const a=i?.errorMessage||i?.message||`HTTP ${n.status}`;throw new Error(a)}return i}function oa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=bn(t.baseUrl,"/api/Rules"),n=bn(t.baseUrl,"/api/Rules/lookups");return{async getRules(){const r=await Vt(s,{method:"GET",headers:e});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Vt(s,{method:"POST",headers:e,body:JSON.stringify(r??{})})},async getLookups(){return Vt(n,{method:"GET",headers:e})},async updateRule(r,i){const a=`${s}/${r}`;return Vt(a,{method:"PUT",headers:e,body:JSON.stringify(i??{})})}}}function la(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Qt={exports:{}},ua=Qt.exports,Tn;function ca(){return Tn||(Tn=1,(function(t,e){(function(s,n){t.exports=n()})(ua,(function(){var s=1e3,n=6e4,r=36e5,i="millisecond",a="second",o="minute",u="hour",c="day",d="week",f="month",m="quarter",p="year",v="date",g="Invalid Date",S=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,L=/\[([^\]]+)]|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,j={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(M){var A=["th","st","nd","rd"],x=M%100;return"["+M+(A[(x-20)%10]||A[x]||A[0])+"]"}},q=function(M,A,x){var O=String(M);return!O||O.length>=A?M:""+Array(A+1-O.length).join(x)+M},F={s:q,z:function(M){var A=-M.utcOffset(),x=Math.abs(A),O=Math.floor(x/60),w=x%60;return(A<=0?"+":"-")+q(O,2,"0")+":"+q(w,2,"0")},m:function M(A,x){if(A.date()<x.date())return-M(x,A);var O=12*(x.year()-A.year())+(x.month()-A.month()),w=A.clone().add(O,f),b=x-w<0,T=A.clone().add(O+(b?-1:1),f);return+(-(O+(x-w)/(b?w-T:T-w))||0)},a:function(M){return M<0?Math.ceil(M)||0:Math.floor(M)},p:function(M){return{M:f,y:p,w:d,d:c,D:v,h:u,m:o,s:a,ms:i,Q:m}[M]||String(M||"").toLowerCase().replace(/s$/,"")},u:function(M){return M===void 0}},H="en",G={};G[H]=j;var Q="$isDayjsObject",J=function(M){return M instanceof ne||!(!M||!M[Q])},I=function M(A,x,O){var w;if(!A)return H;if(typeof A=="string"){var b=A.toLowerCase();G[b]&&(w=b),x&&(G[b]=x,w=b);var T=A.split("-");if(!w&&T.length>1)return M(T[0])}else{var D=A.name;G[D]=A,w=D}return!O&&w&&(H=w),w||!O&&H},N=function(M,A){if(J(M))return M.clone();var x=typeof A=="object"?A:{};return x.date=M,x.args=arguments,new ne(x)},E=F;E.l=I,E.i=J,E.w=function(M,A){return N(M,{locale:A.$L,utc:A.$u,x:A.$x,$offset:A.$offset})};var ne=(function(){function M(x){this.$L=I(x.locale,null,!0),this.parse(x),this.$x=this.$x||x.x||{},this[Q]=!0}var A=M.prototype;return A.parse=function(x){this.$d=(function(O){var w=O.date,b=O.utc;if(w===null)return new Date(NaN);if(E.u(w))return new Date;if(w instanceof Date)return new Date(w);if(typeof w=="string"&&!/Z$/i.test(w)){var T=w.match(S);if(T){var D=T[2]-1||0,V=(T[7]||"0").substring(0,3);return b?new Date(Date.UTC(T[1],D,T[3]||1,T[4]||0,T[5]||0,T[6]||0,V)):new Date(T[1],D,T[3]||1,T[4]||0,T[5]||0,T[6]||0,V)}}return new Date(w)})(x),this.init()},A.init=function(){var x=this.$d;this.$y=x.getFullYear(),this.$M=x.getMonth(),this.$D=x.getDate(),this.$W=x.getDay(),this.$H=x.getHours(),this.$m=x.getMinutes(),this.$s=x.getSeconds(),this.$ms=x.getMilliseconds()},A.$utils=function(){return E},A.isValid=function(){return this.$d.toString()!==g},A.isSame=function(x,O){var w=N(x);return this.startOf(O)<=w&&w<=this.endOf(O)},A.isAfter=function(x,O){return N(x)<this.startOf(O)},A.isBefore=function(x,O){return this.endOf(O)<N(x)},A.$g=function(x,O,w){return E.u(x)?this[O]:this.set(w,x)},A.unix=function(){return Math.floor(this.valueOf()/1e3)},A.valueOf=function(){return this.$d.getTime()},A.startOf=function(x,O){var w=this,b=!!E.u(O)||O,T=E.p(x),D=function(xe,ae){var pe=E.w(w.$u?Date.UTC(w.$y,ae,xe):new Date(w.$y,ae,xe),w);return b?pe:pe.endOf(c)},V=function(xe,ae){return E.w(w.toDate()[xe].apply(w.toDate("s"),(b?[0,0,0,0]:[23,59,59,999]).slice(ae)),w)},U=this.$W,B=this.$M,Z=this.$D,le="set"+(this.$u?"UTC":"");switch(T){case p:return b?D(1,0):D(31,11);case f:return b?D(1,B):D(0,B+1);case d:var he=this.$locale().weekStart||0,fe=(U<he?U+7:U)-he;return D(b?Z-fe:Z+(6-fe),B);case c:case v:return V(le+"Hours",0);case u:return V(le+"Minutes",1);case o:return V(le+"Seconds",2);case a:return V(le+"Milliseconds",3);default:return this.clone()}},A.endOf=function(x){return this.startOf(x,!1)},A.$set=function(x,O){var w,b=E.p(x),T="set"+(this.$u?"UTC":""),D=(w={},w[c]=T+"Date",w[v]=T+"Date",w[f]=T+"Month",w[p]=T+"FullYear",w[u]=T+"Hours",w[o]=T+"Minutes",w[a]=T+"Seconds",w[i]=T+"Milliseconds",w)[b],V=b===c?this.$D+(O-this.$W):O;if(b===f||b===p){var U=this.clone().set(v,1);U.$d[D](V),U.init(),this.$d=U.set(v,Math.min(this.$D,U.daysInMonth())).$d}else D&&this.$d[D](V);return this.init(),this},A.set=function(x,O){return this.clone().$set(x,O)},A.get=function(x){return this[E.p(x)]()},A.add=function(x,O){var w,b=this;x=Number(x);var T=E.p(O),D=function(B){var Z=N(b);return E.w(Z.date(Z.date()+Math.round(B*x)),b)};if(T===f)return this.set(f,this.$M+x);if(T===p)return this.set(p,this.$y+x);if(T===c)return D(1);if(T===d)return D(7);var V=(w={},w[o]=n,w[u]=r,w[a]=s,w)[T]||1,U=this.$d.getTime()+x*V;return E.w(U,this)},A.subtract=function(x,O){return this.add(-1*x,O)},A.format=function(x){var O=this,w=this.$locale();if(!this.isValid())return w.invalidDate||g;var b=x||"YYYY-MM-DDTHH:mm:ssZ",T=E.z(this),D=this.$H,V=this.$m,U=this.$M,B=w.weekdays,Z=w.months,le=w.meridiem,he=function(ae,pe,Ie,Oe){return ae&&(ae[pe]||ae(O,b))||Ie[pe].slice(0,Oe)},fe=function(ae){return E.s(D%12||12,ae,"0")},xe=le||function(ae,pe,Ie){var Oe=ae<12?"AM":"PM";return Ie?Oe.toLowerCase():Oe};return b.replace(L,(function(ae,pe){return pe||(function(Ie){switch(Ie){case"YY":return String(O.$y).slice(-2);case"YYYY":return E.s(O.$y,4,"0");case"M":return U+1;case"MM":return E.s(U+1,2,"0");case"MMM":return he(w.monthsShort,U,Z,3);case"MMMM":return he(Z,U);case"D":return O.$D;case"DD":return E.s(O.$D,2,"0");case"d":return String(O.$W);case"dd":return he(w.weekdaysMin,O.$W,B,2);case"ddd":return he(w.weekdaysShort,O.$W,B,3);case"dddd":return B[O.$W];case"H":return String(D);case"HH":return E.s(D,2,"0");case"h":return fe(1);case"hh":return fe(2);case"a":return xe(D,V,!0);case"A":return xe(D,V,!1);case"m":return String(V);case"mm":return E.s(V,2,"0");case"s":return String(O.$s);case"ss":return E.s(O.$s,2,"0");case"SSS":return E.s(O.$ms,3,"0");case"Z":return T}return null})(ae)||T.replace(":","")}))},A.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},A.diff=function(x,O,w){var b,T=this,D=E.p(O),V=N(x),U=(V.utcOffset()-this.utcOffset())*n,B=this-V,Z=function(){return E.m(T,V)};switch(D){case p:b=Z()/12;break;case f:b=Z();break;case m:b=Z()/3;break;case d:b=(B-U)/6048e5;break;case c:b=(B-U)/864e5;break;case u:b=B/r;break;case o:b=B/n;break;case a:b=B/s;break;default:b=B}return w?b:E.a(b)},A.daysInMonth=function(){return this.endOf(f).$D},A.$locale=function(){return G[this.$L]},A.locale=function(x,O){if(!x)return this.$L;var w=this.clone(),b=I(x,O,!0);return b&&(w.$L=b),w},A.clone=function(){return E.w(this.$d,this)},A.toDate=function(){return new Date(this.valueOf())},A.toJSON=function(){return this.isValid()?this.toISOString():null},A.toISOString=function(){return this.$d.toISOString()},A.toString=function(){return this.$d.toUTCString()},M})(),te=ne.prototype;return N.prototype=te,[["$ms",i],["$s",a],["$m",o],["$H",u],["$W",c],["$M",f],["$y",p],["$D",v]].forEach((function(M){te[M[1]]=function(A){return this.$g(A,M[0],M[1])}})),N.extend=function(M,A){return M.$i||(M(A,ne,N),M.$i=!0),N},N.locale=I,N.isDayjs=J,N.unix=function(M){return N(1e3*M)},N.en=G[H],N.Ls=G,N.p={},N}))})(Qt)),Qt.exports}var da=ca();const ha=la(da);function vr(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 Sr(t){if(!t||typeof t!="string")return{hours:0,minutes:0,seconds:0};const e=t.split(":").map(i=>parseInt(i,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 An(t){const{hours:e,minutes:s,seconds:n}=Sr(t);return ha().hour(e).minute(s).second(n).millisecond(0)}function ze(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function fa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function kn(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 _e(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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const a=i?.Message||`HTTP ${n.status}`;throw new Error(a)}return i}const de=(...t)=>t.find(e=>e!=null);function ma(t){return{id:String(de(t?.AlertId,t?.alertId)??""),priority:de(t?.Priority,t?.priority,"Low"),timestamp:de(t?.Timestamp,t?.timestamp,""),statusType:de(t?.Status,t?.statusType,""),description:de(t?.Description,t?.description,""),eventName:de(t?.EventName,t?.eventName),ruleName:de(t?.RuleName,t?.ruleName),spaceName:de(t?.SpaceName,t?.spaceName),assignTeam:de(t?.AssignTeam,t?.assignTeam),cameraName:de(t?.CameraName,t?.cameraName),type:de(t?.Type,t?.type),mediaDetails:de(t?.MediaDetails,t?.mediaDetails),additionalMedia:de(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:de(t?.TimeElapsed,t?.timeElapsed),timeRemaining:de(t?.TimeRemaining,t?.timeRemaining),anomalyName:de(t?.AnomalyName,t?.anomalyName),alertDetails:de(t?.AlertDetails,t?.alertDetails),statusHistory:de(t?.StatusHistory,t?.statusHistory),isEmailSent:de(t?.IsEmailSent,t?.isEmailSent),isSMSSent:de(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:de(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function ya(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=ze(t.baseUrl,"/api/detectionpolicy/alerts?customerId=99e5c8b5-b9d4-4d35-8885-7f121c532664"),n=await _e(s,{method:"GET",headers:e});return Array.isArray(n?.Items)?(n?.Items).map(ma):[]},async getAlertStatusList(){const s=ze(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await _e(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertsReport(s){const n=ze(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=kn(n,s),i=await _e(r,{method:"GET",headers:e});return Array.isArray(i)?i:[]},async updateAlertStatus(s){const n=ze(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 _e(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=ze(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await _e(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=ze(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??""};return _e(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=ze(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await _e(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=ze(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=c=>{const{hours:d,minutes:f,seconds:m}=Sr(c);return(d*3600+f*60+m)*1e7},i={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(c=>String(c)):[],DoNotDisturbStart:{Ticks:r(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:r(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},a=await _e(n,{method:"POST",headers:e,body:JSON.stringify(i)}),o=a?.responseStatus??!0,u=a?.data??a?.message??"Preferences updated successfully.";return{responseStatus:o,errorMessage:o?"":a?.errorMessage??a?.Message??a?.message??"",statusCode:200,data:u}},async getAlertNotifications(s){const n=ze(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=kn(n,{alertId:s}),i=await _e(r,{method:"GET",headers:e});return Array.isArray(i)?i:i&&typeof i=="object"&&Array.isArray(i.data)?i.data:[]}}}function pa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Je(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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const a=i?.errorMessage||i?.message||`HTTP ${n.status}`;throw new Error(a)}return i}function ga(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)?n:[]},async setEscalationSettings(n){return Je(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=F=>new URL(F,t.baseUrl).toString(),r=[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})],[i,a,o,u,c]=await Promise.allSettled(r),d=F=>F.status==="fulfilled"&&Array.isArray(F.value)?F.value:[],f=d(i),m=d(a),p=d(o),v=d(u),g=d(c),S=f.map(F=>({actionTypeId:Number(F?.ActionTypeId),name:F?.DisplayName??F?.Name??""})),L=m.map(F=>({recordId:F?.AnomalyId,anomalyName:F?.DisplayName??F?.Name??""})),j=p.map(F=>({thirdPartyId:Number(F?.ThirdPartyId),thirdPartyName:F?.ThirdPartyName??F?.Name??""})),q={actionTypes:S,anomalies:L,thirdParties:j};return v.length&&(q.severities=v),g.length&&(q.scheduleTypes=g),q},async updateRule(n,r){const i=`${s}/${n}`;return Je(i,{method:"PUT",headers:e,body:JSON.stringify(r??{})})}}}const xr=y.createContext(null);function wr({tenant:t="snl",override:e,children:s}){const n=y.useMemo(()=>{const i=e?.alertsBaseUrl?.trim()||wn[t]?.alerts||"";let a=e?.rulesBaseUrl?.trim()||wn[t]?.rules||"";t==="snl"&&(a=i);const o=e?.headers;return{tenant:t,alertsBaseUrl:i,rulesBaseUrl:a,headers:o}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{})]),r=y.useMemo(()=>{const i=n.tenant==="schools"?ya({baseUrl:n.alertsBaseUrl,headers:n.headers}):ia({baseUrl:n.alertsBaseUrl,headers:n.headers}),a=n.tenant==="schools"?ga({baseUrl:n.rulesBaseUrl,headers:n.headers}):oa({baseUrl:n.alertsBaseUrl,headers:n.headers});return{config:n,alerts:i,rules:a}},[n]);return l.jsx(xr.Provider,{value:r,children:s})}function je(){const t=y.useContext(xr);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const va={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Sa={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Gs=6,Qs=7;function Nn(t,e,s){const n=t===Gs,r=t===Qs,i=e.isEmailSent??!1,a=e.isSMSSent??!1,o=n&&i||r&&a,u=n?"Send Email":r?"Send SMS":s,c=n&&i?"Email sent":r&&a?"SMS sent":u,d=n&&i?"Email sent":r&&a?"SMS sent":`Click to ${u}`;return{isDisabled:o,buttonText:c,tooltipTitle:d}}function xa(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 wa(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 qt(t){return t===Gs||t===Qs}function ls({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return l.jsx(h.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const ba=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Ta({value:t,onChange:e,options:s}){return l.jsx(ls,{className:"w-[140px]",value:t,onChange:e,options:s||ba})}const Aa=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function ka({value:t,onChange:e,options:s}){return l.jsx(ls,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||Aa})}function Na({value:t,onChange:e,options:s}){return l.jsx(ls,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const Ia=[{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 Oa({value:t,onChange:e,options:s}){return l.jsx(ls,{className:"w-[130px]",value:t,onChange:e,options:s||Ia})}function br({columns:t,data:e,loading:s=!1,pageSize:n=10,rowKey:r="id",toolbar:i,tableProps:a}){return l.jsxs("div",{children:[i,l.jsx(h.Table,{rowKey:r,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,showSizeChanger:!0,showTotal:o=>`Total: ${o}`},bordered:!0,...a})]})}function Js({data:t,loading:e=!1,pageSize:s=10,columns:n,severityOptions:r,spaceOptions:i,renderActions:a,onAlertIdClick:o,onRefetch:u,excludeCompleted:c=!0}){const[d,f]=y.useState("All"),[m,p]=y.useState("All"),[v,g]=y.useState("All"),[S,L]=y.useState("All"),[j,q]=y.useState(""),[F,H]=y.useState([{label:"All",value:"All"}]),[G,Q]=y.useState(new Set),{rules:J,alerts:I}=je(),N={6:{title:"Email",kind:"icon",icon:l.jsx(ot.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:l.jsx(ot.MessageOutlined,{})}},E=y.useMemo(()=>xa(t),[t]),ne=y.useMemo(()=>wa(t),[t]);y.useEffect(()=>{let b=!0;return(async()=>{try{const T=await J.getLookups(),V=(Array.isArray(T.thirdParties)?T.thirdParties:[]).map(U=>({label:U.thirdPartyName,value:String(U.thirdPartyId)}));b&&H([{label:"All",value:"All"},...V])}catch(T){console.error("Error loading third party options",T)}})(),()=>{b=!1}},[J]);const te=y.useMemo(()=>(t||[]).some(b=>xn(b).length>0),[t]),M=y.useMemo(()=>(t||[]).filter(b=>{const T=d==="All"||b.priority===d,D=`${b.id} ${b.description} ${b.statusType}`.toLowerCase(),V=!j||D.includes(j.toLowerCase()),U=m==="All"||(b.anomalyName||"").toLowerCase()===m.toLowerCase(),B=v==="All"||(b.spaceName||"").toLowerCase()===v.toLowerCase(),Z=!te||S==="All"||xn(b).includes(Number(S)),le=!c||!["completed","false positive"].includes(String(b.statusType||"").toLowerCase());return T&&V&&U&&B&&Z&&le}),[t,d,j,m,v,S,te,c]),A=E,x=i&&i.length?i:ne,O=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:b=>l.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Sa[b]}`,backgroundColor:va[b]},children:b})},{title:"Tracker",key:"tracker",width:140,render:(b,T)=>l.jsx("a",{onClick:D=>{D.preventDefault(),o?.(T,{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:(b,T)=>{if(a)return l.jsx(l.Fragment,{children:a(T)});const D=async(Ie,Oe)=>{const dt=xs(T.id,Ie);Q(ve=>new Set(ve).add(dt));try{const ve=await I.sendSMSorEmailNotifications?.(T.id,Ie,Oe);ve?.responseStatus?(Ne.toast.success(ve.data||(Ie?"Email sent successfully":"SMS sent successfully")),u?.()):Ne.toast.error(ve?.data||ve?.errorMessage||"Failed to send notification")}catch(ve){Ne.toast.error(ve?.message||"Failed to send notification")}finally{Q(ve=>{const ht=new Set(ve);return ht.delete(dt),ht})}},V=Gs,U=Qs,B=N[V],Z=N[U],le=Nn(V,T,B?.title),he=Nn(U,T,Z?.title),fe=xs(T.id,!0),xe=xs(T.id,!1),ae=qt(V)&&G.has(fe),pe=qt(U)&&G.has(xe);return l.jsxs(h.Space,{size:"middle",children:[l.jsx(h.Tooltip,{title:le.tooltipTitle,children:l.jsx(h.Button,{size:"small",disabled:le.isDisabled,loading:ae,onClick:qt(V)?()=>D(!0,!1):void 0,icon:!ae&&B?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:le.buttonText})},String(V)),l.jsx(h.Tooltip,{title:he.tooltipTitle,children:l.jsx(h.Button,{size:"small",disabled:he.isDisabled,loading:pe,onClick:qt(U)?()=>D(!1,!0):void 0,icon:!pe&&Z?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:he.buttonText})},String(U))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(b,T)=>{const D=T?.timeElapsed,V=T?.timeRemaining,U=D?Sn(D):0,B=V?Sn(V):0,Z=Math.round(U/(U+B)*100);return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),l.jsx("span",{className:"font-medium",children:D??"-"})]}),l.jsx(h.Progress,{percent:Z,showInfo:!1,size:"small",strokeColor:ea(T.priority)}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-[70px]",children:"Remaining"}),l.jsx("span",{className:"font-medium",children:V??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(b,T)=>l.jsxs("div",{children:[l.jsx("a",{onClick:D=>{D.preventDefault(),o?.(T,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:T.alertNumber}),l.jsx("div",{className:"text-black/65",children:b})]})}],w=n&&n.length?n:O;return l.jsx("div",{children:l.jsx(br,{rowKey:"id",data:M,columns:w,loading:e,pageSize:s,toolbar:l.jsxs(h.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[l.jsx(h.Col,{flex:"none",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{children:"Severity"}),l.jsx(Ta,{value:d,onChange:f,options:r})]})}),l.jsx(h.Col,{flex:"none",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{children:"Anomaly type"}),l.jsx(ka,{value:m,onChange:p,options:A})]})}),l.jsx(h.Col,{flex:"none",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{children:"Space"}),l.jsx(Na,{value:v,onChange:g,options:x})]})}),l.jsx(h.Col,{flex:"none",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{children:"Action Taken"}),l.jsx(Oa,{value:S,onChange:L,options:F})]})}),l.jsx(h.Col,{flex:"auto"}),l.jsx(h.Col,{flex:"none",children:l.jsx(h.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:q,onChange:b=>q(b.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}var wt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ca={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ea=class{#e=Ca;#t=!1;setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&this.#t&&t!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:t}),this.#e=t,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},it=new Ea;function Ma(t){setTimeout(t,0)}var lt=typeof window>"u"||"Deno"in globalThis;function Ae(){}function Da(t,e){return typeof t=="function"?t(e):t}function Ms(t){return typeof t=="number"&&t>=0&&t!==1/0}function Tr(t,e){return Math.max(t+(e||0)-Date.now(),0)}function tt(t,e){return typeof t=="function"?t(e):t}function Pe(t,e){return typeof t=="function"?t(e):t}function In(t,e){const{type:s="all",exact:n,fetchStatus:r,predicate:i,queryKey:a,stale:o}=t;if(a){if(n){if(e.queryHash!==Ks(a,e.options))return!1}else if(!Dt(e.queryKey,a))return!1}if(s!=="all"){const u=e.isActive();if(s==="active"&&!u||s==="inactive"&&u)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||r&&r!==e.state.fetchStatus||i&&!i(e))}function On(t,e){const{exact:s,status:n,predicate:r,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(s){if(ut(e.options.mutationKey)!==ut(i))return!1}else if(!Dt(e.options.mutationKey,i))return!1}return!(n&&e.state.status!==n||r&&!r(e))}function Ks(t,e){return(e?.queryKeyHashFn||ut)(t)}function ut(t){return JSON.stringify(t,(e,s)=>js(s)?Object.keys(s).sort().reduce((n,r)=>(n[r]=s[r],n),{}):s)}function Dt(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(s=>Dt(t[s],e[s])):!1}var ja=Object.prototype.hasOwnProperty;function Ds(t,e,s=0){if(t===e)return t;if(s>500)return e;const n=Cn(t)&&Cn(e);if(!n&&!(js(t)&&js(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),o=a.length,u=n?new Array(o):{};let c=0;for(let d=0;d<o;d++){const f=n?d:a[d],m=t[f],p=e[f];if(m===p){u[f]=m,(n?d<i:ja.call(t,f))&&c++;continue}if(m===null||p===null||typeof m!="object"||typeof p!="object"){u[f]=p;continue}const v=Ds(m,p,s+1);u[f]=v,v===m&&c++}return i===o&&c===i?t:u}function es(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function Cn(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function js(t){if(!En(t))return!1;const e=t.constructor;if(e===void 0)return!0;const s=e.prototype;return!(!En(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function En(t){return Object.prototype.toString.call(t)==="[object Object]"}function Ra(t){return new Promise(e=>{it.setTimeout(e,t)})}function Rs(t,e,s){if(typeof s.structuralSharing=="function")return s.structuralSharing(t,e);if(s.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Ds(t,e)}catch(n){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${n}`),n}return Ds(t,e)}return e}function Fa(t,e,s=0){const n=[...t,e];return s&&n.length>s?n.slice(1):n}function Pa(t,e,s=0){const n=[e,...t];return s&&n.length>s?n.slice(0,-1):n}var ts=Symbol();function Ar(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===ts&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===ts?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Xs(t,e){return typeof t=="function"?t(...e):!!t}function La(t,e,s){let n=!1,r;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(r??=e(),n||(n=!0,r.aborted?s():r.addEventListener("abort",s,{once:!0})),r)}),t}var Ua=class extends wt{#e;#t;#s;constructor(){super(),this.#s=t=>{if(!lt&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#s=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},en=new Ua;function Fs(){let t,e;const s=new Promise((r,i)=>{t=r,e=i});s.status="pending",s.catch(()=>{});function n(r){Object.assign(s,r),delete s.resolve,delete s.reject}return s.resolve=r=>{n({status:"fulfilled",value:r}),t(r)},s.reject=r=>{n({status:"rejected",reason:r}),e(r)},s}var $a=Ma;function Wa(){let t=[],e=0,s=o=>{o()},n=o=>{o()},r=$a;const i=o=>{e?t.push(o):r(()=>{s(o)})},a=()=>{const o=t;t=[],o.length&&r(()=>{n(()=>{o.forEach(u=>{s(u)})})})};return{batch:o=>{let u;e++;try{u=o()}finally{e--,e||a()}return u},batchCalls:o=>(...u)=>{i(()=>{o(...u)})},schedule:i,setNotifyFunction:o=>{s=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{r=o}}}var ge=Wa(),Va=class extends wt{#e=!0;#t;#s;constructor(){super(),this.#s=t=>{if(!lt&&window.addEventListener){const e=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#s=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(s=>{s(t)}))}isOnline(){return this.#e}},ss=new Va;function qa(t){return Math.min(1e3*2**t,3e4)}function kr(t){return(t??"online")==="online"?ss.isOnline():!0}var Ps=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Nr(t){let e=!1,s=0,n;const r=Fs(),i=()=>r.status!=="pending",a=g=>{if(!i()){const S=new Ps(g);m(S),t.onCancel?.(S)}},o=()=>{e=!0},u=()=>{e=!1},c=()=>en.isFocused()&&(t.networkMode==="always"||ss.isOnline())&&t.canRun(),d=()=>kr(t.networkMode)&&t.canRun(),f=g=>{i()||(n?.(),r.resolve(g))},m=g=>{i()||(n?.(),r.reject(g))},p=()=>new Promise(g=>{n=S=>{(i()||c())&&g(S)},t.onPause?.()}).then(()=>{n=void 0,i()||t.onContinue?.()}),v=()=>{if(i())return;let g;const S=s===0?t.initialPromise:void 0;try{g=S??t.fn()}catch(L){g=Promise.reject(L)}Promise.resolve(g).then(f).catch(L=>{if(i())return;const j=t.retry??(lt?0:3),q=t.retryDelay??qa,F=typeof q=="function"?q(s,L):q,H=j===!0||typeof j=="number"&&s<j||typeof j=="function"&&j(s,L);if(e||!H){m(L);return}s++,t.onFail?.(s,L),Ra(F).then(()=>c()?void 0:p()).then(()=>{e?m(L):v()})})};return{promise:r,status:()=>r.status,cancel:a,continue:()=>(n?.(),r),cancelRetry:o,continueRetry:u,canStart:d,start:()=>(d()?v():p().then(v),r)}}var Ir=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ms(this.gcTime)&&(this.#e=it.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(lt?1/0:300*1e3))}clearGcTimeout(){this.#e&&(it.clearTimeout(this.#e),this.#e=void 0)}},Ba=class extends Ir{#e;#t;#s;#r;#n;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#r=t.client,this.#s=this.#r.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=Dn(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(t){if(this.options={...this.#a,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Dn(this.options);e.data!==void 0&&(this.setState(Mn(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){const s=Rs(this.state.data,t,this.options);return this.#i({data:s,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),s}setState(t,e){this.#i({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#n?.promise;return this.#n?.cancel(t),e?e.then(Ae).catch(Ae):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Pe(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ts||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>tt(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Tr(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#n&&(this.#o?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(u=>u.options.queryFn);o&&this.setOptions(o.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const s=new AbortController,n=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,s.signal)})},r=()=>{const o=Ar(this.options,e),c=(()=>{const d={client:this.#r,queryKey:this.queryKey,meta:this.meta};return n(d),d})();return this.#o=!1,this.options.persister?this.options.persister(o,c,this):o(c)},a=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:r};return n(o),o})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#i({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=Nr({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o=>{o instanceof Ps&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),s.abort()},onFail:(o,u)=>{this.#i({type:"failed",failureCount:o,error:u})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const o=await this.#n.start();if(o===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#s.config.onSuccess?.(o,this),this.#s.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof Ps){if(o.silent)return this.#n.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#i({type:"error",error:o}),this.#s.config.onError?.(o,this),this.#s.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#i(t){const e=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...Or(s.data,this.options),fetchMeta:t.meta??null};case"success":const n={...s,...Mn(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?n:void 0,n;case"error":const r=t.error;return{...s,error:r,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=e(this.state),ge.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function Or(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:kr(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Mn(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Dn(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,s=e!==void 0,n=s?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:s?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var Za=class extends wt{constructor(t,e){super(),this.options=e,this.#e=t,this.#i=null,this.#o=Fs(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#s=void 0;#r=void 0;#n;#a;#o;#i;#y;#h;#f;#u;#c;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),jn(this.#t,this.options)?this.#d():this.updateResult(),this.#S())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ls(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ls(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#x(),this.#w(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Pe(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#b(),this.#t.setOptions(this.options),e._defaulted&&!es(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const n=this.hasListeners();n&&Rn(this.#t,s,this.options,e)&&this.#d(),this.updateResult(),n&&(this.#t!==s||Pe(this.options.enabled,this.#t)!==Pe(e.enabled,this.#t)||tt(this.options.staleTime,this.#t)!==tt(e.staleTime,this.#t))&&this.#p();const r=this.#g();n&&(this.#t!==s||Pe(this.options.enabled,this.#t)!==Pe(e.enabled,this.#t)||r!==this.#l)&&this.#v(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return za(this,s)&&(this.#r=s,this.#a=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#r}trackResult(t,e){return new Proxy(t,{get:(s,n)=>(this.trackProp(n),e?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,n))})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);return s.fetch().then(()=>this.createResult(s,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#d(t){this.#b();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Ae)),e}#p(){this.#x();const t=tt(this.options.staleTime,this.#t);if(lt||this.#r.isStale||!Ms(t))return;const s=Tr(this.#r.dataUpdatedAt,t)+1;this.#u=it.setTimeout(()=>{this.#r.isStale||this.updateResult()},s)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#w(),this.#l=t,!(lt||Pe(this.options.enabled,this.#t)===!1||!Ms(this.#l)||this.#l===0)&&(this.#c=it.setInterval(()=>{(this.options.refetchIntervalInBackground||en.isFocused())&&this.#d()},this.#l))}#S(){this.#p(),this.#v(this.#g())}#x(){this.#u&&(it.clearTimeout(this.#u),this.#u=void 0)}#w(){this.#c&&(it.clearInterval(this.#c),this.#c=void 0)}createResult(t,e){const s=this.#t,n=this.options,r=this.#r,i=this.#n,a=this.#a,u=t!==s?t.state:this.#s,{state:c}=t;let d={...c},f=!1,m;if(e._optimisticResults){const J=this.hasListeners(),I=!J&&jn(t,e),N=J&&Rn(t,s,e,n);(I||N)&&(d={...d,...Or(c.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:v,status:g}=d;m=d.data;let S=!1;if(e.placeholderData!==void 0&&m===void 0&&g==="pending"){let J;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(J=r.data,S=!0):J=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,J!==void 0&&(g="success",m=Rs(r?.data,J,e),f=!0)}if(e.select&&m!==void 0&&!S)if(r&&m===i?.data&&e.select===this.#y)m=this.#h;else try{this.#y=e.select,m=e.select(m),m=Rs(r?.data,m,e),this.#h=m,this.#i=null}catch(J){this.#i=J}this.#i&&(p=this.#i,m=this.#h,v=Date.now(),g="error");const L=d.fetchStatus==="fetching",j=g==="pending",q=g==="error",F=j&&L,H=m!==void 0,Q={status:g,fetchStatus:d.fetchStatus,isPending:j,isSuccess:g==="success",isError:q,isInitialLoading:F,isLoading:F,data:m,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:v,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:L,isRefetching:L&&!j,isLoadingError:q&&!H,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:q&&H,isStale:tn(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Pe(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const J=Q.data!==void 0,I=Q.status==="error"&&!J,N=te=>{I?te.reject(Q.error):J&&te.resolve(Q.data)},E=()=>{const te=this.#o=Q.promise=Fs();N(te)},ne=this.#o;switch(ne.status){case"pending":t.queryHash===s.queryHash&&N(ne);break;case"fulfilled":(I||Q.data!==ne.value)&&E();break;case"rejected":(!I||Q.error!==ne.reason)&&E();break}}return Q}updateResult(){const t=this.#r,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#a=this.options,this.#n.data!==void 0&&(this.#f=this.#t),es(e,t))return;this.#r=e;const s=()=>{if(!t)return!0;const{notifyOnChangeProps:n}=this.options,r=typeof n=="function"?n():n;if(r==="all"||!r&&!this.#m.size)return!0;const i=new Set(r??this.#m);return this.options.throwOnError&&i.add("error"),Object.keys(this.#r).some(a=>{const o=a;return this.#r[o]!==t[o]&&i.has(o)})};this.#T({listeners:s()})}#b(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#s=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#S()}#T(t){ge.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Ha(t,e){return Pe(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function jn(t,e){return Ha(t,e)||t.state.data!==void 0&&Ls(t,e,e.refetchOnMount)}function Ls(t,e,s){if(Pe(e.enabled,t)!==!1&&tt(e.staleTime,t)!=="static"){const n=typeof s=="function"?s(t):s;return n==="always"||n!==!1&&tn(t,e)}return!1}function Rn(t,e,s,n){return(t!==e||Pe(n.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&tn(t,s)}function tn(t,e){return Pe(e.enabled,t)!==!1&&t.isStaleByTime(tt(e.staleTime,t))}function za(t,e){return!es(t.getCurrentResult(),e)}function Fn(t){return{onFetch:(e,s)=>{const n=e.options,r=e.fetchOptions?.meta?.fetchMore?.direction,i=e.state.data?.pages||[],a=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},u=0;const c=async()=>{let d=!1;const f=v=>{La(v,()=>e.signal,()=>d=!0)},m=Ar(e.options,e.fetchOptions),p=async(v,g,S)=>{if(d)return Promise.reject();if(g==null&&v.pages.length)return Promise.resolve(v);const j=(()=>{const G={client:e.client,queryKey:e.queryKey,pageParam:g,direction:S?"backward":"forward",meta:e.options.meta};return f(G),G})(),q=await m(j),{maxPages:F}=e.options,H=S?Pa:Fa;return{pages:H(v.pages,q,F),pageParams:H(v.pageParams,g,F)}};if(r&&i.length){const v=r==="backward",g=v?_a:Pn,S={pages:i,pageParams:a},L=g(n,S);o=await p(S,L,v)}else{const v=t??i.length;do{const g=u===0?a[0]??n.initialPageParam:Pn(n,o);if(u>0&&g==null)break;o=await p(o,g),u++}while(u<v)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s):e.fetchFn=c}}}function Pn(t,{pages:e,pageParams:s}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,s[n],s):void 0}function _a(t,{pages:e,pageParams:s}){return e.length>0?t.getPreviousPageParam?.(e[0],e,s[0],s):void 0}var Ya=class extends Ir{#e;#t;#s;#r;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#s=t.mutationCache,this.#t=[],this.state=t.state||Cr(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#s.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#n({type:"continue"})},s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Nr({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(i,a)=>{this.#n({type:"failed",failureCount:i,error:a})},onPause:()=>{this.#n({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const n=this.state.status==="pending",r=!this.#r.canStart();try{if(n)e();else{this.#n({type:"pending",variables:t,isPaused:r}),this.#s.config.onMutate&&await this.#s.config.onMutate(t,this,s);const a=await this.options.onMutate?.(t,s);a!==this.state.context&&this.#n({type:"pending",context:a,variables:t,isPaused:r})}const i=await this.#r.start();return await this.#s.config.onSuccess?.(i,t,this.state.context,this,s),await this.options.onSuccess?.(i,t,this.state.context,s),await this.#s.config.onSettled?.(i,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(i,null,t,this.state.context,s),this.#n({type:"success",data:i}),i}catch(i){try{await this.#s.config.onError?.(i,t,this.state.context,this,s)}catch(a){Promise.reject(a)}try{await this.options.onError?.(i,t,this.state.context,s)}catch(a){Promise.reject(a)}try{await this.#s.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,s)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,i,t,this.state.context,s)}catch(a){Promise.reject(a)}throw this.#n({type:"error",error:i}),i}finally{this.#s.runNext(this)}}#n(t){const e=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),ge.batch(()=>{this.#t.forEach(s=>{s.onMutationUpdate(t)}),this.#s.notify({mutation:this,type:"updated",action:t})})}};function Cr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ga=class extends wt{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#s=0}#e;#t;#s;build(t,e,s){const n=new Ya({client:t,mutationCache:this,mutationId:++this.#s,options:t.defaultMutationOptions(e),state:s});return this.add(n),n}add(t){this.#e.add(t);const e=Bt(t);if(typeof e=="string"){const s=this.#t.get(e);s?s.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=Bt(t);if(typeof e=="string"){const s=this.#t.get(e);if(s)if(s.length>1){const n=s.indexOf(t);n!==-1&&s.splice(n,1)}else s[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=Bt(t);if(typeof e=="string"){const n=this.#t.get(e)?.find(r=>r.state.status==="pending");return!n||n===t}else return!0}runNext(t){const e=Bt(t);return typeof e=="string"?this.#t.get(e)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ge.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(s=>On(e,s))}findAll(t={}){return this.getAll().filter(e=>On(t,e))}notify(t){ge.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return ge.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ae))))}};function Bt(t){return t.options.scope?.id}var Qa=class extends wt{#e;#t=void 0;#s;#r;constructor(t,e){super(),this.#e=t,this.setOptions(e),this.bindMethods(),this.#n()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.#e.defaultMutationOptions(t),es(this.options,e)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),e?.mutationKey&&this.options.mutationKey&&ut(e.mutationKey)!==ut(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(t){this.#n(),this.#a(t)}getCurrentResult(){return this.#t}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#n(),this.#a()}mutate(t,e){return this.#r=e,this.#s?.removeObserver(this),this.#s=this.#e.getMutationCache().build(this.#e,this.options),this.#s.addObserver(this),this.#s.execute(t)}#n(){const t=this.#s?.state??Cr();this.#t={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){ge.batch(()=>{if(this.#r&&this.hasListeners()){const e=this.#t.variables,s=this.#t.context,n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#r.onSuccess?.(t.data,e,s,n)}catch(r){Promise.reject(r)}try{this.#r.onSettled?.(t.data,null,e,s,n)}catch(r){Promise.reject(r)}}else if(t?.type==="error"){try{this.#r.onError?.(t.error,e,s,n)}catch(r){Promise.reject(r)}try{this.#r.onSettled?.(void 0,t.error,e,s,n)}catch(r){Promise.reject(r)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Ja=class extends wt{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,s){const n=e.queryKey,r=e.queryHash??Ks(n,e);let i=this.get(r);return i||(i=new Ba({client:t,queryKey:n,queryHash:r,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ge.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(s=>In(e,s))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(s=>In(t,s)):e}notify(t){ge.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){ge.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ge.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ka=class{#e;#t;#s;#r;#n;#a;#o;#i;constructor(t={}){this.#e=t.queryCache||new Ja,this.#t=t.mutationCache||new Ga,this.#s=t.defaultOptions||{},this.#r=new Map,this.#n=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=en.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=ss.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#i?.(),this.#i=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),s=this.#e.build(this,e),n=s.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(tt(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:s})=>{const n=s.data;return[e,n]})}setQueryData(t,e,s){const n=this.defaultQueryOptions({queryKey:t}),i=this.#e.get(n.queryHash)?.state.data,a=Da(e,i);if(a!==void 0)return this.#e.build(this,n).setData(a,{...s,manual:!0})}setQueriesData(t,e,s){return ge.batch(()=>this.#e.findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,s)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;ge.batch(()=>{e.findAll(t).forEach(s=>{e.remove(s)})})}resetQueries(t,e){const s=this.#e;return ge.batch(()=>(s.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const s={revert:!0,...e},n=ge.batch(()=>this.#e.findAll(t).map(r=>r.cancel(s)));return Promise.all(n).then(Ae).catch(Ae)}invalidateQueries(t,e={}){return ge.batch(()=>(this.#e.findAll(t).forEach(s=>{s.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const s={...e,cancelRefetch:e.cancelRefetch??!0},n=ge.batch(()=>this.#e.findAll(t).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,s);return s.throwOnError||(i=i.catch(Ae)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(Ae)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const s=this.#e.build(this,e);return s.isStaleByTime(tt(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ae).catch(Ae)}fetchInfiniteQuery(t){return t.behavior=Fn(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ae).catch(Ae)}ensureInfiniteQueryData(t){return t.behavior=Fn(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return ss.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#s}setDefaultOptions(t){this.#s=t}setQueryDefaults(t,e){this.#r.set(ut(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#r.values()],s={};return e.forEach(n=>{Dt(t,n.queryKey)&&Object.assign(s,n.defaultOptions)}),s}setMutationDefaults(t,e){this.#n.set(ut(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#n.values()],s={};return e.forEach(n=>{Dt(t,n.mutationKey)&&Object.assign(s,n.defaultOptions)}),s}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#s.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Ks(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===ts&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#s.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Er=Se.createContext(void 0),sn=t=>{const e=Se.useContext(Er);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Xa=({client:t,children:e})=>(Se.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),l.jsx(Er.Provider,{value:t,children:e})),Mr=Se.createContext(!1),eo=()=>Se.useContext(Mr);Mr.Provider;function to(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var so=Se.createContext(to()),no=()=>Se.useContext(so),ro=(t,e,s)=>{const n=s?.state.error&&typeof t.throwOnError=="function"?Xs(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||n)&&(e.isReset()||(t.retryOnMount=!1))},io=t=>{Se.useEffect(()=>{t.clearReset()},[t])},ao=({result:t,errorResetBoundary:e,throwOnError:s,query:n,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(r&&t.data===void 0||Xs(s,[t.error,n])),oo=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),n=t.staleTime;t.staleTime=typeof n=="function"?(...r)=>s(n(...r)):s(n),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},lo=(t,e)=>t.isLoading&&t.isFetching&&!e,uo=(t,e)=>t?.suspense&&e.isPending,Ln=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function co(t,e,s){if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=eo(),r=no(),i=sn(),a=i.defaultQueryOptions(t);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a);const o=i.getQueryCache().get(a.queryHash);process.env.NODE_ENV!=="production"&&(a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),a._optimisticResults=n?"isRestoring":"optimistic",oo(a),ro(a,r,o),io(r);const u=!i.getQueryCache().get(a.queryHash),[c]=Se.useState(()=>new e(i,a)),d=c.getOptimisticResult(a),f=!n&&t.subscribed!==!1;if(Se.useSyncExternalStore(Se.useCallback(m=>{const p=f?c.subscribe(ge.batchCalls(m)):Ae;return c.updateResult(),p},[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Se.useEffect(()=>{c.setOptions(a)},[a,c]),uo(a,d))throw Ln(a,c,r);if(ao({result:d,errorResetBoundary:r,throwOnError:a.throwOnError,query:o,suspense:a.suspense}))throw d.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,d),a.experimental_prefetchInRender&&!lt&&lo(d,n)&&(u?Ln(a,c,r):o?.promise)?.catch(Ae).finally(()=>{c.updateResult()}),a.notifyOnChangeProps?d:c.trackResult(d)}function us(t,e){return co(t,Za)}function ho(t,e){const s=sn(),[n]=Se.useState(()=>new Qa(s,t));Se.useEffect(()=>{n.setOptions(t)},[n,t]);const r=Se.useSyncExternalStore(Se.useCallback(a=>n.subscribe(ge.batchCalls(a)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=Se.useCallback((a,o)=>{n.mutate(a,o).catch(Ae)},[n]);if(r.error&&Xs(n.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:i,mutateAsync:r.mutate}}function nn(){const{alerts:t}=je(),e=sn();return ho({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class ct extends Error{}class fo extends ct{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class mo extends ct{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class yo extends ct{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class gt extends ct{}class Dr extends ct{constructor(e){super(`Invalid unit ${e}`)}}class we extends ct{}class Ke extends ct{constructor(){super("Zone is an abstract class")}}const k="numeric",qe="short",De="long",ns={year:k,month:k,day:k},jr={year:k,month:qe,day:k},po={year:k,month:qe,day:k,weekday:qe},Rr={year:k,month:De,day:k},Fr={year:k,month:De,day:k,weekday:De},Pr={hour:k,minute:k},Lr={hour:k,minute:k,second:k},Ur={hour:k,minute:k,second:k,timeZoneName:qe},$r={hour:k,minute:k,second:k,timeZoneName:De},Wr={hour:k,minute:k,hourCycle:"h23"},Vr={hour:k,minute:k,second:k,hourCycle:"h23"},qr={hour:k,minute:k,second:k,hourCycle:"h23",timeZoneName:qe},Br={hour:k,minute:k,second:k,hourCycle:"h23",timeZoneName:De},Zr={year:k,month:k,day:k,hour:k,minute:k},Hr={year:k,month:k,day:k,hour:k,minute:k,second:k},zr={year:k,month:qe,day:k,hour:k,minute:k},_r={year:k,month:qe,day:k,hour:k,minute:k,second:k},go={year:k,month:qe,day:k,weekday:qe,hour:k,minute:k},Yr={year:k,month:De,day:k,hour:k,minute:k,timeZoneName:qe},Gr={year:k,month:De,day:k,hour:k,minute:k,second:k,timeZoneName:qe},Qr={year:k,month:De,day:k,weekday:De,hour:k,minute:k,timeZoneName:De},Jr={year:k,month:De,day:k,weekday:De,hour:k,minute:k,second:k,timeZoneName:De};class Rt{get type(){throw new Ke}get name(){throw new Ke}get ianaName(){return this.name}get isUniversal(){throw new Ke}offsetName(e,s){throw new Ke}formatOffset(e,s){throw new Ke}offset(e){throw new Ke}equals(e){throw new Ke}get isValid(){throw new Ke}}let ws=null;class cs extends Rt{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 li(e,s,n)}formatOffset(e,s){return Mt(this.offset(e),s)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const Us=new Map;function vo(t){let e=Us.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"}),Us.set(t,e)),e}const So={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function xo(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,i,a,o,u,c,d]=n;return[a,r,i,o,u,c,d]}function wo(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:i,value:a}=s[r],o=So[i];i==="era"?n[o]=a:W(o)||(n[o]=parseInt(a,10))}return n}const bs=new Map;class Qe extends Rt{static create(e){let s=bs.get(e);return s===void 0&&bs.set(e,s=new Qe(e)),s}static resetCache(){bs.clear(),Us.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=Qe.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return li(e,s,n,this.name)}formatOffset(e,s){return Mt(this.offset(e),s)}offset(e){if(!this.valid)return NaN;const s=new Date(e);if(isNaN(s))return NaN;const n=vo(this.name);let[r,i,a,o,u,c,d]=n.formatToParts?wo(n,s):xo(n,s);o==="BC"&&(r=-Math.abs(r)+1);const m=hs({year:r,month:i,day:a,hour:u===24?0:u,minute:c,second:d,millisecond:0});let p=+s;const v=p%1e3;return p-=v>=0?v:1e3+v,(m-p)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let Un={};function bo(t,e={}){const s=JSON.stringify([t,e]);let n=Un[s];return n||(n=new Intl.ListFormat(t,e),Un[s]=n),n}const $s=new Map;function Ws(t,e={}){const s=JSON.stringify([t,e]);let n=$s.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),$s.set(s,n)),n}const Vs=new Map;function To(t,e={}){const s=JSON.stringify([t,e]);let n=Vs.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),Vs.set(s,n)),n}const qs=new Map;function Ao(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let i=qs.get(r);return i===void 0&&(i=new Intl.RelativeTimeFormat(t,e),qs.set(r,i)),i}let Ot=null;function ko(){return Ot||(Ot=new Intl.DateTimeFormat().resolvedOptions().locale,Ot)}const Bs=new Map;function Kr(t){let e=Bs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Bs.set(t,e)),e}const Zs=new Map;function No(t){let e=Zs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...Xr,...e}),Zs.set(t,e)}return e}function Io(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=Ws(t).resolvedOptions(),r=t}catch{const u=t.substring(0,s);n=Ws(u).resolvedOptions(),r=u}const{numberingSystem:i,calendar:a}=n;return[r,i,a]}}function Oo(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function Co(t){const e=[];for(let s=1;s<=12;s++){const n=$.utc(2009,s,1);e.push(t(n))}return e}function Eo(t){const e=[];for(let s=1;s<=7;s++){const n=$.utc(2016,11,13+s);e.push(t(n))}return e}function Zt(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function Mo(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Kr(t.locale).numberingSystem==="latn"}class Do{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:i,...a}=n;if(!s||Object.keys(a).length>0){const o={useGrouping:!1,...n};n.padTo>0&&(o.minimumIntegerDigits=n.padTo),this.inf=To(e,o)}}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):un(e,3);return ye(s,this.padTo)}}}class jo{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 a=-1*(e.offset/60),o=a>=0?`Etc/GMT+${a}`:`Etc/GMT${a}`;e.offset!==0&&Qe.create(o).valid?(r=o,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 i={...this.opts};i.timeZone=i.timeZone||r,this.dtf=Ws(s,i)}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 Ro{constructor(e,s,n){this.opts={style:"long",...n},!s&&ai()&&(this.rtf=Ao(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):sl(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const Xr={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,i=!1){const a=e||ce.defaultLocale,o=a||(i?"en-US":ko()),u=s||ce.defaultNumberingSystem,c=n||ce.defaultOutputCalendar,d=zs(r)||ce.defaultWeekSettings;return new se(o,u,c,d,a)}static resetCache(){Ot=null,$s.clear(),Vs.clear(),qs.clear(),Bs.clear(),Zs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return se.create(e,s,n,r)}constructor(e,s,n,r,i){const[a,o,u]=Io(e);this.locale=a,this.numberingSystem=s||o||null,this.outputCalendar=n||u||null,this.weekSettings=r,this.intl=Oo(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=Mo(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,zs(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 Zt(this,e,di,()=>{const n=this.intl==="ja"||this.intl.startsWith("ja-");s&=!n;const r=s?{month:e,day:"numeric"}:{month:e},i=s?"format":"standalone";if(!this.monthsCache[i][e]){const a=n?o=>this.dtFormatter(o,r).format():o=>this.extract(o,r,"month");this.monthsCache[i][e]=Co(a)}return this.monthsCache[i][e]})}weekdays(e,s=!1){return Zt(this,e,mi,()=>{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]=Eo(i=>this.extract(i,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return Zt(this,void 0,()=>yi,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[$.utc(2016,11,13,9),$.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Zt(this,e,pi,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[$.utc(-40,1,1),$.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),i=r.formatToParts(),a=i.find(o=>o.type.toLowerCase()===n);return a?a.value:null}numberFormatter(e={}){return new Do(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new jo(e,this.intl,s)}relFormatter(e={}){return new Ro(this.intl,this.isEnglish(),e)}listFormatter(e={}){return bo(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Kr(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:oi()?No(this.locale):Xr}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 ke extends Rt{static get utcInstance(){return Ts===null&&(Ts=new ke(0)),Ts}static instance(e){return e===0?ke.utcInstance:new ke(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new ke(fs(s[1],s[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Mt(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Mt(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,s){return Mt(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 Fo extends Rt{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 et(t,e){if(W(t)||t===null)return e;if(t instanceof Rt)return t;if(Vo(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?cs.instance:s==="utc"||s==="gmt"?ke.utcInstance:ke.parseSpecifier(s)||Qe.create(t)}else return st(t)?ke.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Fo(t)}const rn={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},$n={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]},Po=rn.hanidec.replace(/[\[|\]]/g,"").split("");function Lo(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(rn.hanidec)!==-1)e+=Po.indexOf(t[s]);else for(const r in $n){const[i,a]=$n[r];n>=i&&n<=a&&(e+=n-i)}}return parseInt(e,10)}else return e}const Hs=new Map;function Uo(){Hs.clear()}function $e({numberingSystem:t},e=""){const s=t||"latn";let n=Hs.get(s);n===void 0&&(n=new Map,Hs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${rn[s]}${e}`),n.set(e,r)),r}let Wn=()=>Date.now(),Vn="system",qn=null,Bn=null,Zn=null,Hn=60,zn,_n=null;class ce{static get now(){return Wn}static set now(e){Wn=e}static set defaultZone(e){Vn=e}static get defaultZone(){return et(Vn,cs.instance)}static get defaultLocale(){return qn}static set defaultLocale(e){qn=e}static get defaultNumberingSystem(){return Bn}static set defaultNumberingSystem(e){Bn=e}static get defaultOutputCalendar(){return Zn}static set defaultOutputCalendar(e){Zn=e}static get defaultWeekSettings(){return _n}static set defaultWeekSettings(e){_n=zs(e)}static get twoDigitCutoffYear(){return Hn}static set twoDigitCutoffYear(e){Hn=e%100}static get throwOnInvalid(){return zn}static set throwOnInvalid(e){zn=e}static resetCaches(){se.resetCache(),Qe.resetCache(),$.resetCache(),Uo()}}class Ve{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const ei=[0,31,59,90,120,151,181,212,243,273,304,334],ti=[0,31,60,91,121,152,182,213,244,274,305,335];function Le(t,e){return new Ve("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function an(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 si(t,e,s){return s+(Ft(t)?ti:ei)[e-1]}function ni(t,e){const s=Ft(t)?ti:ei,n=s.findIndex(i=>i<e),r=e-s[n];return{month:n+1,day:r}}function on(t,e){return(t-e+7)%7+1}function rs(t,e=4,s=1){const{year:n,month:r,day:i}=t,a=si(n,r,i),o=on(an(n,r,i),s);let u=Math.floor((a-o+14-e)/7),c;return u<1?(c=n-1,u=jt(c,e,s)):u>jt(n,e,s)?(c=n+1,u=1):c=n,{weekYear:c,weekNumber:u,weekday:o,...ms(t)}}function Yn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:i}=t,a=on(an(n,1,e),s),o=vt(n);let u=r*7+i-a-7+e,c;u<1?(c=n-1,u+=vt(c)):u>o?(c=n+1,u-=vt(n)):c=n;const{month:d,day:f}=ni(c,u);return{year:c,month:d,day:f,...ms(t)}}function As(t){const{year:e,month:s,day:n}=t,r=si(e,s,n);return{year:e,ordinal:r,...ms(t)}}function Gn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=ni(e,s);return{year:e,month:n,day:r,...ms(t)}}function Qn(t,e){if(!W(t.localWeekday)||!W(t.localWeekNumber)||!W(t.localWeekYear)){if(!W(t.weekday)||!W(t.weekNumber)||!W(t.weekYear))throw new gt("Cannot mix locale-based week fields with ISO-based week fields");return W(t.localWeekday)||(t.weekday=t.localWeekday),W(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),W(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 $o(t,e=4,s=1){const n=ds(t.weekYear),r=Ue(t.weekNumber,1,jt(t.weekYear,e,s)),i=Ue(t.weekday,1,7);return n?r?i?!1:Le("weekday",t.weekday):Le("week",t.weekNumber):Le("weekYear",t.weekYear)}function Wo(t){const e=ds(t.year),s=Ue(t.ordinal,1,vt(t.year));return e?s?!1:Le("ordinal",t.ordinal):Le("year",t.year)}function ri(t){const e=ds(t.year),s=Ue(t.month,1,12),n=Ue(t.day,1,is(t.year,t.month));return e?s?n?!1:Le("day",t.day):Le("month",t.month):Le("year",t.year)}function ii(t){const{hour:e,minute:s,second:n,millisecond:r}=t,i=Ue(e,0,23)||e===24&&s===0&&n===0&&r===0,a=Ue(s,0,59),o=Ue(n,0,59),u=Ue(r,0,999);return i?a?o?u?!1:Le("millisecond",r):Le("second",n):Le("minute",s):Le("hour",e)}function W(t){return typeof t>"u"}function st(t){return typeof t=="number"}function ds(t){return typeof t=="number"&&t%1===0}function Vo(t){return typeof t=="string"}function qo(t){return Object.prototype.toString.call(t)==="[object Date]"}function ai(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function oi(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Bo(t){return Array.isArray(t)?t:[t]}function Jn(t,e,s){if(t.length!==0)return t.reduce((n,r)=>{const i=[e(r),r];return n&&s(n[0],i[0])===n[0]?n:i},null)[1]}function Zo(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function xt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function zs(t){if(t==null)return null;if(typeof t!="object")throw new we("Week settings must be an object");if(!Ue(t.firstDay,1,7)||!Ue(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!Ue(e,1,7)))throw new we("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function Ue(t,e,s){return ds(t)&&t>=e&&t<=s}function Ho(t,e){return t-e*Math.floor(t/e)}function ye(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function Xe(t){if(!(W(t)||t===null||t===""))return parseInt(t,10)}function nt(t){if(!(W(t)||t===null||t===""))return parseFloat(t)}function ln(t){if(!(W(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function un(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 vt(t){return Ft(t)?366:365}function is(t,e){const s=Ho(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 hs(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 Kn(t,e,s){return-on(an(t,1,e),s)+e-1}function jt(t,e=4,s=1){const n=Kn(t,e,s),r=Kn(t+1,e,s);return(vt(t)-n+r)/7}function _s(t){return t>99?t:t>ce.twoDigitCutoffYear?1900+t:2e3+t}function li(t,e,s,n=null){const r=new Date(t),i={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};n&&(i.timeZone=n);const a={timeZoneName:e,...i},o=new Intl.DateTimeFormat(s,a).formatToParts(r).find(u=>u.type.toLowerCase()==="timezonename");return o?o.value:null}function fs(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 ui(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new we(`Invalid unit value ${t}`);return e}function as(t,e){const s={};for(const n in t)if(xt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=ui(r)}return s}function Mt(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}${ye(s,2)}:${ye(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${ye(s,2)}${ye(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function ms(t){return Zo(t,["hour","minute","second","millisecond"])}const zo=["January","February","March","April","May","June","July","August","September","October","November","December"],ci=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],_o=["J","F","M","A","M","J","J","A","S","O","N","D"];function di(t){switch(t){case"narrow":return[..._o];case"short":return[...ci];case"long":return[...zo];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 hi=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],fi=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Yo=["M","T","W","T","F","S","S"];function mi(t){switch(t){case"narrow":return[...Yo];case"short":return[...fi];case"long":return[...hi];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const yi=["AM","PM"],Go=["Before Christ","Anno Domini"],Qo=["BC","AD"],Jo=["B","A"];function pi(t){switch(t){case"narrow":return[...Jo];case"short":return[...Qo];case"long":return[...Go];default:return null}}function Ko(t){return yi[t.hour<12?0:1]}function Xo(t,e){return mi(e)[t.weekday-1]}function el(t,e){return di(e)[t.month-1]}function tl(t,e){return pi(e)[t.year<0?0:1]}function sl(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."]},i=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&i){const f=t==="days";switch(e){case 1:return f?"tomorrow":`next ${r[t][0]}`;case-1:return f?"yesterday":`last ${r[t][0]}`;case 0:return f?"today":`this ${r[t][0]}`}}const a=Object.is(e,-0)||e<0,o=Math.abs(e),u=o===1,c=r[t],d=n?u?c[1]:c[2]||c[1]:u?r[t][0]:t;return a?`${o} ${d} ago`:`in ${o} ${d}`}function Xn(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const nl={D:ns,DD:jr,DDD:Rr,DDDD:Fr,t:Pr,tt:Lr,ttt:Ur,tttt:$r,T:Wr,TT:Vr,TTT:qr,TTTT:Br,f:Zr,ff:zr,fff:Yr,ffff:Qr,F:Hr,FF:_r,FFF:Gr,FFFF:Jr};class be{static create(e,s={}){return new be(e,s)}static parseFormat(e){let s=null,n="",r=!1;const i=[];for(let a=0;a<e.length;a++){const o=e.charAt(a);o==="'"?((n.length>0||r)&&i.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||o===s?n+=o:(n.length>0&&i.push({literal:/^\s+$/.test(n),val:n}),n=o,s=o)}return n.length>0&&i.push({literal:r||/^\s+$/.test(n),val:n}),i}static macroTokenToFormatOpts(e){return nl[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 ye(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",i=(p,v)=>this.loc.extract(e,p,v),a=p=>e.isOffsetFixed&&e.offset===0&&p.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,p.format):"",o=()=>n?Ko(e):i({hour:"numeric",hourCycle:"h12"},"dayperiod"),u=(p,v)=>n?el(e,p):i(v?{month:p}:{month:p,day:"numeric"},"month"),c=(p,v)=>n?Xo(e,p):i(v?{weekday:p}:{weekday:p,month:"long",day:"numeric"},"weekday"),d=p=>{const v=be.macroTokenToFormatOpts(p);return v?this.formatWithSystemDefault(e,v):p},f=p=>n?tl(e,p):i({era:p},"era"),m=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 a({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return a({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return a({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 o();case"d":return r?i({day:"numeric"},"day"):this.num(e.day);case"dd":return r?i({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return c("short",!0);case"cccc":return c("long",!0);case"ccccc":return c("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return c("short",!1);case"EEEE":return c("long",!1);case"EEEEE":return c("narrow",!1);case"L":return r?i({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?i({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return u("short",!0);case"LLLL":return u("long",!0);case"LLLLL":return u("narrow",!0);case"M":return r?i({month:"numeric"},"month"):this.num(e.month);case"MM":return r?i({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return u("short",!1);case"MMMM":return u("long",!1);case"MMMMM":return u("narrow",!1);case"y":return r?i({year:"numeric"},"year"):this.num(e.year);case"yy":return r?i({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?i({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?i({year:"numeric"},"year"):this.num(e.year,6);case"G":return f("short");case"GG":return f("long");case"GGGGG":return f("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 d(p)}};return Xn(be.parseFormat(s),m)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=d=>{switch(d[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}},i=(d,f)=>m=>{const p=r(m);if(p){const v=f.isNegativeDuration&&p!==f.largestUnit?n:1;let g;return this.opts.signMode==="negativeLargestOnly"&&p!==f.largestUnit?g="never":this.opts.signMode==="all"?g="always":g="auto",this.num(d.get(p)*v,m.length,g)}else return m},a=be.parseFormat(s),o=a.reduce((d,{literal:f,val:m})=>f?d:d.concat(m),[]),u=e.shiftTo(...o.map(r).filter(d=>d)),c={isNegativeDuration:u<0,largestUnit:Object.keys(u.values)[0]};return Xn(a,i(u,c))}}const gi=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function bt(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function Tt(...t){return e=>t.reduce(([s,n,r],i)=>{const[a,o,u]=i(e,r);return[{...s,...a},o||n,u]},[{},null,1]).slice(0,2)}function At(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 vi(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=Xe(e[s+r]);return[n,null,s+r]}}const Si=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,rl=`(?:${Si.source}?(?:\\[(${gi.source})\\])?)?`,cn=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,xi=RegExp(`${cn.source}${rl}`),dn=RegExp(`(?:[Tt]${xi.source})?`),il=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,al=/(\d{4})-?W(\d\d)(?:-?(\d))?/,ol=/(\d{4})-?(\d{3})/,ll=vi("weekYear","weekNumber","weekDay"),ul=vi("year","ordinal"),cl=/(\d{4})-(\d\d)-(\d\d)/,wi=RegExp(`${cn.source} ?(?:${Si.source}|(${gi.source}))?`),dl=RegExp(`(?: ${wi.source})?`);function St(t,e,s){const n=t[e];return W(n)?s:Xe(n)}function hl(t,e){return[{year:St(t,e),month:St(t,e+1,1),day:St(t,e+2,1)},null,e+3]}function kt(t,e){return[{hours:St(t,e,0),minutes:St(t,e+1,0),seconds:St(t,e+2,0),milliseconds:ln(t[e+3])},null,e+4]}function Pt(t,e){const s=!t[e]&&!t[e+1],n=fs(t[e+1],t[e+2]),r=s?null:ke.instance(n);return[{},r,e+3]}function Lt(t,e){const s=t[e]?Qe.create(t[e]):null;return[{},s,e+1]}const fl=RegExp(`^T?${cn.source}$`),ml=/^-?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 yl(t){const[e,s,n,r,i,a,o,u,c]=t,d=e[0]==="-",f=u&&u[0]==="-",m=(p,v=!1)=>p!==void 0&&(v||p&&d)?-p:p;return[{years:m(nt(s)),months:m(nt(n)),weeks:m(nt(r)),days:m(nt(i)),hours:m(nt(a)),minutes:m(nt(o)),seconds:m(nt(u),u==="-0"),milliseconds:m(ln(c),f)}]}const pl={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function hn(t,e,s,n,r,i,a){const o={year:e.length===2?_s(Xe(e)):Xe(e),month:ci.indexOf(s)+1,day:Xe(n),hour:Xe(r),minute:Xe(i)};return a&&(o.second=Xe(a)),t&&(o.weekday=t.length>3?hi.indexOf(t)+1:fi.indexOf(t)+1),o}const gl=/^(?:(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 vl(t){const[,e,s,n,r,i,a,o,u,c,d,f]=t,m=hn(e,r,n,s,i,a,o);let p;return u?p=pl[u]:c?p=0:p=fs(d,f),[m,new ke(p)]}function Sl(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const xl=/^(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$/,wl=/^(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$/,bl=/^(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 er(t){const[,e,s,n,r,i,a,o]=t;return[hn(e,r,n,s,i,a,o),ke.utcInstance]}function Tl(t){const[,e,s,n,r,i,a,o]=t;return[hn(e,o,s,n,r,i,a),ke.utcInstance]}const Al=bt(il,dn),kl=bt(al,dn),Nl=bt(ol,dn),Il=bt(xi),bi=Tt(hl,kt,Pt,Lt),Ol=Tt(ll,kt,Pt,Lt),Cl=Tt(ul,kt,Pt,Lt),El=Tt(kt,Pt,Lt);function Ml(t){return At(t,[Al,bi],[kl,Ol],[Nl,Cl],[Il,El])}function Dl(t){return At(Sl(t),[gl,vl])}function jl(t){return At(t,[xl,er],[wl,er],[bl,Tl])}function Rl(t){return At(t,[ml,yl])}const Fl=Tt(kt);function Pl(t){return At(t,[fl,Fl])}const Ll=bt(cl,dl),Ul=bt(wi),$l=Tt(kt,Pt,Lt);function Wl(t){return At(t,[Ll,bi],[Ul,$l])}const tr="Invalid Duration",Ti={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}},Vl={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},...Ti},Fe=146097/400,ft=146097/4800,ql={years:{quarters:4,months:12,weeks:Fe/7,days:Fe,hours:Fe*24,minutes:Fe*24*60,seconds:Fe*24*60*60,milliseconds:Fe*24*60*60*1e3},quarters:{months:3,weeks:Fe/28,days:Fe/4,hours:Fe*24/4,minutes:Fe*24*60/4,seconds:Fe*24*60*60/4,milliseconds:Fe*24*60*60*1e3/4},months:{weeks:ft/7,days:ft,hours:ft*24,minutes:ft*24*60,seconds:ft*24*60*60,milliseconds:ft*24*60*60*1e3},...Ti},at=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Bl=at.slice(0).reverse();function Ye(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 K(n)}function Ai(t,e){let s=e.milliseconds??0;for(const n of Bl.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function sr(t,e){const s=Ai(t,e)<0?-1:1;at.reduceRight((n,r)=>{if(W(e[r]))return n;if(n){const i=e[n]*s,a=t[r][n],o=Math.floor(i/a);e[r]+=o*s,e[n]-=o*a*s}return r},null),at.reduce((n,r)=>{if(W(e[r]))return n;if(n){const i=e[n]%1;e[n]-=i,e[r]+=i*t[n][r]}return r},null)}function nr(t){const e={};for(const[s,n]of Object.entries(t))n!==0&&(e[s]=n);return e}class K{constructor(e){const s=e.conversionAccuracy==="longterm"||!1;let n=s?ql:Vl;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 K.fromObject({milliseconds:e},s)}static fromObject(e,s={}){if(e==null||typeof e!="object")throw new we(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new K({values:as(e,K.normalizeUnit),loc:se.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(st(e))return K.fromMillis(e);if(K.isDuration(e))return e;if(typeof e=="object")return K.fromObject(e);throw new we(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,s){const[n]=Rl(e);return n?K.fromObject(n,s):K.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,s){const[n]=Pl(e);return n?K.fromObject(n,s):K.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,s=null){if(!e)throw new we("need to specify a reason the Duration is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(ce.throwOnInvalid)throw new yo(n);return new K({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 Dr(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?be.create(this.loc,n).formatDurationFromString(this,e):tr}toHuman(e={}){if(!this.isValid)return tr;const s=e.showZeros!==!1,n=at.map(r=>{const i=this.values[r];return W(i)||i===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(i)}).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+=un(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},$.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?Ai(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e),n={};for(const r of at)(xt(s.values,r)||xt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Ye(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const s=K.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]=ui(e(this.values[n],n));return Ye(this,{values:s},!0)}get(e){return this[K.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...as(e,K.normalizeUnit)};return Ye(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const a={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return Ye(this,a)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return sr(this.matrix,e),Ye(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=nr(this.normalize().shiftToAll().toObject());return Ye(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(a=>K.normalizeUnit(a));const s={},n={},r=this.toObject();let i;for(const a of at)if(e.indexOf(a)>=0){i=a;let o=0;for(const c in n)o+=this.matrix[c][a]*n[c],n[c]=0;st(r[a])&&(o+=r[a]);const u=Math.trunc(o);s[a]=u,n[a]=(o*1e3-u*1e3)/1e3}else st(r[a])&&(n[a]=r[a]);for(const a in n)n[a]!==0&&(s[i]+=a===i?n[a]:n[a]/this.matrix[i][a]);return sr(this.matrix,s),Ye(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 Ye(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=nr(this.values);return Ye(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 at)if(!s(this.values[n],e.values[n]))return!1;return!0}}const mt="Invalid Interval";function Zl(t,e){return!t||!t.isValid?ue.invalid("missing or invalid start"):!e||!e.isValid?ue.invalid("missing or invalid end"):e<t?ue.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 ue{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 we("need to specify a reason the Interval is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(ce.throwOnInvalid)throw new mo(n);return new ue({invalid:n})}static fromDateTimes(e,s){const n=It(e),r=It(s),i=Zl(n,r);return i??new ue({start:n,end:r})}static after(e,s){const n=K.fromDurationLike(s),r=It(e);return ue.fromDateTimes(r,r.plus(n))}static before(e,s){const n=K.fromDurationLike(s),r=It(e);return ue.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let i,a;try{i=$.fromISO(n,s),a=i.isValid}catch{a=!1}let o,u;try{o=$.fromISO(r,s),u=o.isValid}catch{u=!1}if(a&&u)return ue.fromDateTimes(i,o);if(a){const c=K.fromISO(r,s);if(c.isValid)return ue.after(i,c)}else if(u){const c=K.fromISO(n,s);if(c.isValid)return ue.before(o,c)}}return ue.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?ue.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(It).filter(a=>this.contains(a)).sort((a,o)=>a.toMillis()-o.toMillis()),n=[];let{s:r}=this,i=0;for(;r<this.e;){const a=s[i]||this.e,o=+a>+this.e?this.e:a;n.push(ue.fromDateTimes(r,o)),r=o,i+=1}return n}splitBy(e){const s=K.fromDurationLike(e);if(!this.isValid||!s.isValid||s.as("milliseconds")===0)return[];let{s:n}=this,r=1,i;const a=[];for(;n<this.e;){const o=this.start.plus(s.mapUnits(u=>u*r));i=+o>+this.e?this.e:o,a.push(ue.fromDateTimes(n,i)),n=i,r+=1}return a}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:ue.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 ue.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,i)=>r.s-i.s).reduce(([r,i],a)=>i?i.overlaps(a)||i.abutsStart(a)?[r,i.union(a)]:[r.concat([i]),a]:[r,a],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],i=e.map(u=>[{time:u.s,type:"s"},{time:u.e,type:"e"}]),a=Array.prototype.concat(...i),o=a.sort((u,c)=>u.time-c.time);for(const u of o)n+=u.type==="s"?1:-1,n===1?s=u.time:(s&&+s!=+u.time&&r.push(ue.fromDateTimes(s,u.time)),s=null);return ue.merge(r)}difference(...e){return ue.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:mt}[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?be.create(this.s.loc.clone(s),e).formatInterval(this):mt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:mt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:mt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:mt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:mt}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):K.invalid(this.invalidReason)}mapEndpoints(e){return ue.fromDateTimes(e(this.s),e(this.e))}}class Ht{static hasDST(e=ce.defaultZone){const s=$.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return Qe.isValidZone(e)}static normalizeZone(e){return et(e,ce.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:i="gregory"}={}){return(r||se.create(s,n,i)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||se.create(s,n,i)).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:ai(),localeWeek:oi()}}}function rr(t,e){const s=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=s(e)-s(t);return Math.floor(K.fromMillis(n).as("days"))}function Hl(t,e,s){const n=[["years",(u,c)=>c.year-u.year],["quarters",(u,c)=>c.quarter-u.quarter+(c.year-u.year)*4],["months",(u,c)=>c.month-u.month+(c.year-u.year)*12],["weeks",(u,c)=>{const d=rr(u,c);return(d-d%7)/7}],["days",rr]],r={},i=t;let a,o;for(const[u,c]of n)s.indexOf(u)>=0&&(a=u,r[u]=c(t,e),o=i.plus(r),o>e?(r[u]--,t=i.plus(r),t>e&&(o=t,r[u]--,t=i.plus(r))):t=o);return[t,r,o,a]}function zl(t,e,s,n){let[r,i,a,o]=Hl(t,e,s);const u=e-r,c=s.filter(f=>["hours","minutes","seconds","milliseconds"].indexOf(f)>=0);c.length===0&&(a<e&&(a=r.plus({[o]:1})),a!==r&&(i[o]=(i[o]||0)+u/(a-r)));const d=K.fromObject(i,n);return c.length>0?K.fromMillis(u,n).shiftTo(...c).plus(d):d}const _l="missing Intl.DateTimeFormat.formatToParts support";function ee(t,e=s=>s){return{regex:t,deser:([s])=>e(Lo(s))}}const Yl=" ",ki=`[ ${Yl}]`,Ni=new RegExp(ki,"g");function Gl(t){return t.replace(/\./g,"\\.?").replace(Ni,ki)}function ir(t){return t.replace(/\./g,"").replace(Ni," ").toLowerCase()}function We(t,e){return t===null?null:{regex:RegExp(t.map(Gl).join("|")),deser:([s])=>t.findIndex(n=>ir(s)===ir(n))+e}}function ar(t,e){return{regex:t,deser:([,s,n])=>fs(s,n),groups:e}}function zt(t){return{regex:t,deser:([e])=>e}}function Ql(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Jl(t,e){const s=$e(e),n=$e(e,"{2}"),r=$e(e,"{3}"),i=$e(e,"{4}"),a=$e(e,"{6}"),o=$e(e,"{1,2}"),u=$e(e,"{1,3}"),c=$e(e,"{1,6}"),d=$e(e,"{1,9}"),f=$e(e,"{2,4}"),m=$e(e,"{4,6}"),p=S=>({regex:RegExp(Ql(S.val)),deser:([L])=>L,literal:!0}),g=(S=>{if(t.literal)return p(S);switch(S.val){case"G":return We(e.eras("short"),0);case"GG":return We(e.eras("long"),0);case"y":return ee(c);case"yy":return ee(f,_s);case"yyyy":return ee(i);case"yyyyy":return ee(m);case"yyyyyy":return ee(a);case"M":return ee(o);case"MM":return ee(n);case"MMM":return We(e.months("short",!0),1);case"MMMM":return We(e.months("long",!0),1);case"L":return ee(o);case"LL":return ee(n);case"LLL":return We(e.months("short",!1),1);case"LLLL":return We(e.months("long",!1),1);case"d":return ee(o);case"dd":return ee(n);case"o":return ee(u);case"ooo":return ee(r);case"HH":return ee(n);case"H":return ee(o);case"hh":return ee(n);case"h":return ee(o);case"mm":return ee(n);case"m":return ee(o);case"q":return ee(o);case"qq":return ee(n);case"s":return ee(o);case"ss":return ee(n);case"S":return ee(u);case"SSS":return ee(r);case"u":return zt(d);case"uu":return zt(o);case"uuu":return ee(s);case"a":return We(e.meridiems(),0);case"kkkk":return ee(i);case"kk":return ee(f,_s);case"W":return ee(o);case"WW":return ee(n);case"E":case"c":return ee(s);case"EEE":return We(e.weekdays("short",!1),1);case"EEEE":return We(e.weekdays("long",!1),1);case"ccc":return We(e.weekdays("short",!0),1);case"cccc":return We(e.weekdays("long",!0),1);case"Z":case"ZZ":return ar(new RegExp(`([+-]${o.source})(?::(${n.source}))?`),2);case"ZZZ":return ar(new RegExp(`([+-]${o.source})(${n.source})?`),2);case"z":return zt(/[a-z_+-/]{1,256}?/i);case" ":return zt(/[^\S\n\r]/);default:return p(S)}})(t)||{invalidReason:_l};return g.token=t,g}const Kl={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 Xl(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const u=/^\s+$/.test(r);return{literal:!u,val:u?" ":r}}const i=e[n];let a=n;n==="hour"&&(e.hour12!=null?a=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?a="hour12":a="hour24":a=s.hour12?"hour12":"hour24");let o=Kl[a];if(typeof o=="object"&&(o=o[i]),o)return{literal:!1,val:o}}function eu(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function tu(t,e,s){const n=t.match(e);if(n){const r={};let i=1;for(const a in s)if(xt(s,a)){const o=s[a],u=o.groups?o.groups+1:1;!o.literal&&o.token&&(r[o.token.val[0]]=o.deser(n.slice(i,i+u))),i+=u}return[n,r]}else return[n,{}]}function su(t){const e=i=>{switch(i){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 W(t.z)||(s=Qe.create(t.z)),W(t.Z)||(s||(s=new ke(t.Z)),n=t.Z),W(t.q)||(t.M=(t.q-1)*3+1),W(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),W(t.u)||(t.S=ln(t.u)),[Object.keys(t).reduce((i,a)=>{const o=e(a);return o&&(i[o]=t[a]),i},{}),s,n]}let ks=null;function nu(){return ks||(ks=$.fromMillis(1555555555555)),ks}function ru(t,e){if(t.literal)return t;const s=be.macroTokenToFormatOpts(t.val),n=Ei(s,e);return n==null||n.includes(void 0)?t:n}function Ii(t,e){return Array.prototype.concat(...t.map(s=>ru(s,e)))}class Oi{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=Ii(be.parseFormat(s),e),this.units=this.tokens.map(n=>Jl(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=eu(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=tu(e,this.regex,this.handlers),[r,i,a]=n?su(n):[null,null,void 0];if(xt(n,"a")&&xt(n,"H"))throw new gt("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:i,specificOffset:a}}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 Ci(t,e,s){return new Oi(t,s).explainFromTokens(e)}function iu(t,e,s){const{result:n,zone:r,specificOffset:i,invalidReason:a}=Ci(t,e,s);return[n,r,i,a]}function Ei(t,e){if(!t)return null;const n=be.create(e,t).dtFormatter(nu()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(a=>Xl(a,t,i))}const Ns="Invalid DateTime",or=864e13;function Ct(t){return new Ve("unsupported zone",`the zone "${t.name}" is not supported`)}function Is(t){return t.weekData===null&&(t.weekData=rs(t.c)),t.weekData}function Os(t){return t.localWeekData===null&&(t.localWeekData=rs(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function rt(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new $({...s,...e,old:s})}function Mi(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 i=s.offset(n);return r===i?[n,r]:[t-Math.min(r,i)*60*1e3,Math.max(r,i)]}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 Jt(t,e,s){return Mi(hs(t),e,s)}function lr(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,i={...t.c,year:n,month:r,day:Math.min(t.c.day,is(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},a=K.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"),o=hs(i);let[u,c]=Mi(o,s,t.zone);return a!==0&&(u+=a,c=t.zone.offset(u)),{ts:u,o:c}}function yt(t,e,s,n,r,i){const{setZone:a,zone:o}=s;if(t&&Object.keys(t).length!==0||e){const u=e||o,c=$.fromObject(t,{...s,zone:u,specificOffset:i});return a?c:c.setZone(o)}else return $.invalid(new Ve("unparsable",`the input "${r}" can't be parsed as ${n}`))}function Yt(t,e,s=!0){return t.isValid?be.create(se.create("en-US"),{allowZ:s,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Cs(t,e,s){const n=t.c.year>9999||t.c.year<0;let r="";if(n&&t.c.year>=0&&(r+="+"),r+=ye(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=ye(t.c.month),s==="month")return r;r+="-"}else if(r+=ye(t.c.month),s==="month")return r;return r+=ye(t.c.day),r}function ur(t,e,s,n,r,i,a){let o=!s||t.c.millisecond!==0||t.c.second!==0,u="";switch(a){case"day":case"month":case"year":break;default:if(u+=ye(t.c.hour),a==="hour")break;if(e){if(u+=":",u+=ye(t.c.minute),a==="minute")break;o&&(u+=":",u+=ye(t.c.second))}else{if(u+=ye(t.c.minute),a==="minute")break;o&&(u+=ye(t.c.second))}if(a==="second")break;o&&(!n||t.c.millisecond!==0)&&(u+=".",u+=ye(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!i?u+="Z":t.o<0?(u+="-",u+=ye(Math.trunc(-t.o/60)),u+=":",u+=ye(Math.trunc(-t.o%60))):(u+="+",u+=ye(Math.trunc(t.o/60)),u+=":",u+=ye(Math.trunc(t.o%60)))),i&&(u+="["+t.zone.ianaName+"]"),u}const Di={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},au={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},ou={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Kt=["year","month","day","hour","minute","second","millisecond"],lu=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],uu=["year","ordinal","hour","minute","second","millisecond"];function Xt(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 Dr(t);return e}function cr(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return Xt(t)}}function cu(t){if(Et===void 0&&(Et=ce.now()),t.type!=="iana")return t.offset(Et);const e=t.name;let s=Ys.get(e);return s===void 0&&(s=t.offset(Et),Ys.set(e,s)),s}function dr(t,e){const s=et(e.zone,ce.defaultZone);if(!s.isValid)return $.invalid(Ct(s));const n=se.fromObject(e);let r,i;if(W(t.year))r=ce.now();else{for(const u of Kt)W(t[u])&&(t[u]=Di[u]);const a=ri(t)||ii(t);if(a)return $.invalid(a);const o=cu(s);[r,i]=Jt(t,o,s)}return new $({ts:r,zone:s,loc:n,o:i})}function hr(t,e,s){const n=W(s.round)?!0:s.round,r=W(s.rounding)?"trunc":s.rounding,i=(o,u)=>(o=un(o,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(o,u)),a=o=>s.calendary?e.hasSame(t,o)?0:e.startOf(o).diff(t.startOf(o),o).get(o):e.diff(t,o).get(o);if(s.unit)return i(a(s.unit),s.unit);for(const o of s.units){const u=a(o);if(Math.abs(u)>=1)return i(u,o)}return i(t>e?-0:0,s.units[s.units.length-1])}function fr(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 Et;const Ys=new Map;class ${constructor(e){const s=e.zone||ce.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ve("invalid input"):null)||(s.isValid?null:Ct(s));this.ts=W(e.ts)?ce.now():e.ts;let r=null,i=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,i]=[e.old.c,e.old.o];else{const o=st(e.o)&&!e.old?e.o:s.offset(this.ts);r=_t(this.ts,o),n=Number.isNaN(r.year)?new Ve("invalid input"):null,r=n?null:r,i=n?null:o}this._zone=s,this.loc=e.loc||se.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}static now(){return new $({})}static local(){const[e,s]=fr(arguments),[n,r,i,a,o,u,c]=s;return dr({year:n,month:r,day:i,hour:a,minute:o,second:u,millisecond:c},e)}static utc(){const[e,s]=fr(arguments),[n,r,i,a,o,u,c]=s;return e.zone=ke.utcInstance,dr({year:n,month:r,day:i,hour:a,minute:o,second:u,millisecond:c},e)}static fromJSDate(e,s={}){const n=qo(e)?e.valueOf():NaN;if(Number.isNaN(n))return $.invalid("invalid input");const r=et(s.zone,ce.defaultZone);return r.isValid?new $({ts:n,zone:r,loc:se.fromObject(s)}):$.invalid(Ct(r))}static fromMillis(e,s={}){if(st(e))return e<-or||e>or?$.invalid("Timestamp out of range"):new $({ts:e,zone:et(s.zone,ce.defaultZone),loc:se.fromObject(s)});throw new we(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,s={}){if(st(e))return new $({ts:e*1e3,zone:et(s.zone,ce.defaultZone),loc:se.fromObject(s)});throw new we("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=et(s.zone,ce.defaultZone);if(!n.isValid)return $.invalid(Ct(n));const r=se.fromObject(s),i=as(e,cr),{minDaysInFirstWeek:a,startOfWeek:o}=Qn(i,r),u=ce.now(),c=W(s.specificOffset)?n.offset(u):s.specificOffset,d=!W(i.ordinal),f=!W(i.year),m=!W(i.month)||!W(i.day),p=f||m,v=i.weekYear||i.weekNumber;if((p||d)&&v)throw new gt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(m&&d)throw new gt("Can't mix ordinal dates with month/day");const g=v||i.weekday&&!p;let S,L,j=_t(u,c);g?(S=lu,L=au,j=rs(j,a,o)):d?(S=uu,L=ou,j=As(j)):(S=Kt,L=Di);let q=!1;for(const N of S){const E=i[N];W(E)?q?i[N]=L[N]:i[N]=j[N]:q=!0}const F=g?$o(i,a,o):d?Wo(i):ri(i),H=F||ii(i);if(H)return $.invalid(H);const G=g?Yn(i,a,o):d?Gn(i):i,[Q,J]=Jt(G,c,n),I=new $({ts:Q,zone:n,o:J,loc:r});return i.weekday&&p&&e.weekday!==I.weekday?$.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${I.toISO()}`):I.isValid?I:$.invalid(I.invalid)}static fromISO(e,s={}){const[n,r]=Ml(e);return yt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=Dl(e);return yt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=jl(e);return yt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if(W(e)||W(s))throw new we("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:i=null}=n,a=se.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),[o,u,c,d]=iu(a,e,s);return d?$.invalid(d):yt(o,u,n,`format ${s}`,e,c)}static fromString(e,s,n={}){return $.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=Wl(e);return yt(n,r,s,"SQL",e)}static invalid(e,s=null){if(!e)throw new we("need to specify a reason the DateTime is invalid");const n=e instanceof Ve?e:new Ve(e,s);if(ce.throwOnInvalid)throw new fo(n);return new $({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=Ei(e,se.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return Ii(be.parseFormat(e),se.fromObject(s)).map(r=>r.val).join("")}static resetCache(){Et=void 0,Ys.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?Os(this).weekday:NaN}get localWeekNumber(){return this.isValid?Os(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Os(this).weekYear:NaN}get ordinal(){return this.isValid?As(this.c).ordinal:NaN}get monthShort(){return this.isValid?Ht.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Ht.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Ht.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Ht.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=hs(this.c),r=this.zone.offset(n-e),i=this.zone.offset(n+e),a=this.zone.offset(n-r*s),o=this.zone.offset(n-i*s);if(a===o)return[this];const u=n-a*s,c=n-o*s,d=_t(u,a),f=_t(c,o);return d.hour===f.hour&&d.minute===f.minute&&d.second===f.second&&d.millisecond===f.millisecond?[rt(this,{ts:u}),rt(this,{ts:c})]:[this]}get isInLeapYear(){return Ft(this.year)}get daysInMonth(){return is(this.year,this.month)}get daysInYear(){return this.isValid?vt(this.year):NaN}get weeksInWeekYear(){return this.isValid?jt(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?jt(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=be.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(ke.instance(e),s)}toLocal(){return this.setZone(ce.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=et(e,ce.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const i=e.offset(this.ts),a=this.toObject();[r]=Jt(a,i,e)}return rt(this,{ts:r,zone:e})}else return $.invalid(Ct(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return rt(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=as(e,cr),{minDaysInFirstWeek:n,startOfWeek:r}=Qn(s,this.loc),i=!W(s.weekYear)||!W(s.weekNumber)||!W(s.weekday),a=!W(s.ordinal),o=!W(s.year),u=!W(s.month)||!W(s.day),c=o||u,d=s.weekYear||s.weekNumber;if((c||a)&&d)throw new gt("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(u&&a)throw new gt("Can't mix ordinal dates with month/day");let f;i?f=Yn({...rs(this.c,n,r),...s},n,r):W(s.ordinal)?(f={...this.toObject(),...s},W(s.day)&&(f.day=Math.min(is(f.year,f.month),f.day))):f=Gn({...As(this.c),...s});const[m,p]=Jt(f,this.o,this.zone);return rt(this,{ts:m,o:p})}plus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e);return rt(this,lr(this,s))}minus(e){if(!this.isValid)return this;const s=K.fromDurationLike(e).negate();return rt(this,lr(this,s))}startOf(e,{useLocaleWeeks:s=!1}={}){if(!this.isValid)return this;const n={},r=K.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 i=this.loc.getStartOfWeek(),{weekday:a}=this;a<i&&(n.weekNumber=this.weekNumber-1),n.weekday=i}else n.weekday=1;if(r==="quarters"){const i=Math.ceil(this.month/3);n.month=(i-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?be.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Ns}toLocaleString(e=ns,s={}){return this.isValid?be.create(this.loc.clone(s),e).formatDateTime(this):Ns}toLocaleParts(e={}){return this.isValid?be.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:s=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:i=!1,precision:a="milliseconds"}={}){if(!this.isValid)return null;a=Xt(a);const o=e==="extended";let u=Cs(this,o,a);return Kt.indexOf(a)>=3&&(u+="T"),u+=ur(this,o,s,n,r,i,a),u}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Cs(this,e==="extended",Xt(s)):null}toISOWeekDate(){return Yt(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:i=!1,format:a="extended",precision:o="milliseconds"}={}){return this.isValid?(o=Xt(o),(r&&Kt.indexOf(o)>=3?"T":"")+ur(this,a==="extended",s,e,n,i,o)):null}toRFC2822(){return Yt(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Yt(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Cs(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")),Yt(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Ns}[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 K.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=Bo(s).map(K.normalizeUnit),a=e.valueOf()>this.valueOf(),o=a?this:e,u=a?e:this,c=zl(o,u,i,r);return a?c.negate():c}diffNow(e="milliseconds",s={}){return this.diff($.now(),e,s)}until(e){return this.isValid?ue.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(s,n)<=r&&r<=i.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||$.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],i=e.unit;return Array.isArray(e.unit)&&(r=e.unit,i=void 0),hr(s,this.plus(n),{...e,numeric:"always",units:r,unit:i})}toRelativeCalendar(e={}){return this.isValid?hr(e.base||$.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every($.isDateTime))throw new we("min requires all arguments be DateTimes");return Jn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every($.isDateTime))throw new we("max requires all arguments be DateTimes");return Jn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:i=null}=n,a=se.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0});return Ci(a,e,s)}static fromStringExplain(e,s,n={}){return $.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,i=se.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new Oi(i,e)}static fromFormatParser(e,s,n={}){if(W(e)||W(s))throw new we("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:i=null}=n,a=se.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0});if(!a.equals(s.locale))throw new we(`fromFormatParser called with a locale of ${a}, but the format parser was created for ${s.locale}`);const{result:o,zone:u,specificOffset:c,invalidReason:d}=s.explainFromTokens(e);return d?$.invalid(d):yt(o,u,n,`format ${s.format}`,e,c)}static get DATE_SHORT(){return ns}static get DATE_MED(){return jr}static get DATE_MED_WITH_WEEKDAY(){return po}static get DATE_FULL(){return Rr}static get DATE_HUGE(){return Fr}static get TIME_SIMPLE(){return Pr}static get TIME_WITH_SECONDS(){return Lr}static get TIME_WITH_SHORT_OFFSET(){return Ur}static get TIME_WITH_LONG_OFFSET(){return $r}static get TIME_24_SIMPLE(){return Wr}static get TIME_24_WITH_SECONDS(){return Vr}static get TIME_24_WITH_SHORT_OFFSET(){return qr}static get TIME_24_WITH_LONG_OFFSET(){return Br}static get DATETIME_SHORT(){return Zr}static get DATETIME_SHORT_WITH_SECONDS(){return Hr}static get DATETIME_MED(){return zr}static get DATETIME_MED_WITH_SECONDS(){return _r}static get DATETIME_MED_WITH_WEEKDAY(){return go}static get DATETIME_FULL(){return Yr}static get DATETIME_FULL_WITH_SECONDS(){return Gr}static get DATETIME_HUGE(){return Qr}static get DATETIME_HUGE_WITH_SECONDS(){return Jr}}function It(t){if($.isDateTime(t))return t;if(t&&t.valueOf&&st(t.valueOf()))return $.fromJSDate(t);if(t&&typeof t=="object")return $.fromObject(t);throw new we(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function du(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function hu(t,e){try{const s=$.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 fu(t){if(!t)return"-";try{const e=new Date(t),s=c=>String(c).padStart(2,"0"),n=s(e.getMonth()+1),r=s(e.getDate()),i=e.getFullYear(),a=s(e.getHours()),o=s(e.getMinutes()),u=s(e.getSeconds());return`${n}/${r}/${i} ${a}:${o}:${u}`}catch{return"-"}}function os(t,e="UTC"){if(!t)return"-";const s=new Date(t),n=$.fromJSDate(s,{zone:"utc"}).setZone(e),r=n.toFormat("MM/dd/yyyy, hh:mm:ss a"),i=n.toJSDate().toLocaleString("en-US",{timeZone:e,timeZoneName:"short"}).split(" ").pop()||"";return`${r} (${i})`}const mu={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},yu={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function ji({alerts:t,loading:e=!1,pageSize:s=10,severityOptions:n,anomalyOptions:r,spaceOptions:i,onAlertIdClick:a}){const o=nn(),u=["completed","false positive"],c=async m=>{try{const p=await o.mutateAsync({alertUniqueId:m.alertId??m.id,alertId:m.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(p?.responseStatus){const v=p?.data||"Alert reopened successfully.";Ne.toast.success(v)}else{const v=p?.errorMessage||"Failed to reopen alert";Ne.toast.error(v)}}catch{Ne.toast.error("Failed to reopen alert. Please try again.")}},d=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:m=>l.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${mu[m]}`,backgroundColor:yu[String(m)]},children:m})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:m=>fu(m)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(m,p)=>l.jsxs("div",{children:[l.jsx("a",{onClick:v=>{v.preventDefault(),a?.(p,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:p.alertNumber}),l.jsx("div",{className:"text-black/65",children:m})]})},{title:"",key:"menu",width:60,align:"right",render:(m,p)=>l.jsx(h.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:v})=>{v==="reopen"&&c(p)}},children:l.jsx(h.Button,{type:"text",icon:l.jsx(ot.MoreOutlined,{})})})}],f=(t||[]).filter(m=>u.includes((m.statusType||"").toLowerCase()));return l.jsx(Js,{data:f,loading:e,pageSize:s,columns:d,severityOptions:n,anomalyOptions:r,spaceOptions:i,renderActions:void 0,onAlertIdClick:a,excludeCompleted:!1})}function pu({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:i}=y.useMemo(()=>{const f=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(f.find(m=>m.type==="hour")?.value||"0",10),minutes:parseInt(f.find(m=>m.type==="minute")?.value||"0",10),seconds:parseInt(f.find(m=>m.type==="second")?.value||"0",10)}},[e,s]),a=i*6,o=r*6+i*.1,u=n%12*30+r*.5,c=t/2;return l.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((d,f)=>{const m=f*30,p=6,v=c-4,g=v-p,S=(m-90)*(Math.PI/180),L=c+g*Math.cos(S),j=c+g*Math.sin(S),q=c+v*Math.cos(S),F=c+v*Math.sin(S);return l.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:l.jsx("line",{x1:L,y1:j,x2:q,y2:F,stroke:"#9CA3AF",strokeWidth:f%3===0?2:1,strokeLinecap:"round"})},f)}),l.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${u}deg)`},children:l.jsx("line",{x1:c,y1:c,x2:c,y2:c-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),l.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:l.jsx("line",{x1:c,y1:c,x2:c,y2:c-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),l.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${a}deg)`},children:l.jsx("line",{x1:c,y1:c+t*.08,x2:c,y2:c-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),l.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:c-4,top:c-4}})]})}function Ri({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,i]=y.useState(new Date);y.useEffect(()=>{const c=setInterval(()=>i(new Date),s);return()=>clearInterval(c)},[s]);const a=y.useMemo(()=>du(r,e),[r,e]),{abbr:o,offset:u}=y.useMemo(()=>hu(r,e),[r,e]);return l.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[l.jsx(pu,{time:r,timeZone:e,size:80}),l.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[l.jsx("span",{className:"uppercase",children:t}),o&&l.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[o," ",u]})]}),l.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:a})]})]})}const gu=[{SeverityId:1,Code:"LOW",DisplayName:"Low",SortOrder:10,IsActive:!0},{SeverityId:2,Code:"MEDIUM",DisplayName:"Medium",SortOrder:20,IsActive:!0},{SeverityId:3,Code:"HIGH",DisplayName:"High",SortOrder:30,IsActive:!0},{SeverityId:4,Code:"CRITICAL",DisplayName:"Critical",SortOrder:40,IsActive:!0}],vu=[{RuleId:"0938aa00-dfa7-4258-805a-67396366c776",RuleVersionId:"36d2d581-57c3-45c3-8705-8235935fdf96",Name:"License Plate Recognition",Description:"License Plate Recognition",VersionCount:1,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:3,AnomalyId:"915976ef-4eb6-4f7b-bbe6-e53862517fc9",Level:"global"},{RuleId:"2437286a-db6a-4d35-814e-9ac49f158dde",RuleVersionId:"00000000-0000-0000-0000-000000000000",Name:"Monitor And Track Onsite Vehicle timelog",Description:"Monitor And Track Onsite Vehicle timelog",VersionCount:0,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:3,AnomalyId:"9fd651ab-4312-4826-84b6-94d735894477",Level:"global"},{RuleId:"b99120ba-7a83-4ade-b5d9-a420550fe351",RuleVersionId:"d7b14dae-a7b1-474e-a357-199182c02ac3",Name:"Watchlist person detected",Description:"Watchlist person detected",VersionCount:1,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:4,AnomalyId:"bb3a3d3a-73a3-4f5a-8804-1baadbd0d412",Level:"global"},{RuleId:"ffc2c24f-adb7-4aba-ace7-f19c54e21530",RuleVersionId:"6ab3178f-bf77-4a1e-898d-1d5dbef749c5",Name:"Weapon Detection",Description:"Weapon Detection",VersionCount:1,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:4,AnomalyId:"ac82c3a2-72e6-4f9c-88fb-851a3ca3c4de",Level:"global"}],Su=[{userRoleId:1,userRoleName:"Super Admin"},{userRoleId:2,userRoleName:"Security Officer"},{userRoleId:3,userRoleName:"Security Admin"},{userRoleId:4,userRoleName:"Regulatory Officer/First Responder"},{userRoleId:5,userRoleName:"User"}],pt={severities:gu,rules:vu,userRoles:Su},{Text:xu}=h.Typography;function wu({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:i}){return l.jsxs(h.Row,{gutter:[16,16],align:"middle",children:[l.jsx(h.Col,{xs:24,md:8,lg:5,children:l.jsxs(h.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[l.jsx(xu,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),l.jsx(h.Select,{placeholder:"By Severity",value:t,onChange:a=>e({sortBy:a}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),l.jsx(h.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?l.jsxs(h.Space,{className:"w-full",direction:"horizontal",size:8,children:[l.jsx(h.Button,{onClick:r,disabled:i,children:"Clear"}),l.jsx(h.Button,{type:"primary",onClick:n,loading:i,children:"Save"})]}):null})]})}const{Text:Ge}=h.Typography;function bu(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:i,l1mins:a,setL1mins:o,l1role:u,setL1role:c,l2mins:d,setL2mins:f,l2role:m,setL2role:p,l3mins:v,setL3mins:g,l3role:S,setL3role:L,actions:j,setActions:q,thirdPartyIds:F,setThirdPartyIds:H,humanLoop:G,setHumanLoop:Q,isAutoExpire:J,setAutoExpire:I,onClear:N,onSave:E,saving:ne,onActionTypesLoaded:te}=t,{rules:M}=je(),[A,x]=y.useState([]),[O,w]=y.useState([]),[b,T]=y.useState(!1);y.useEffect(()=>{let B=!1;return(async()=>{try{T(!0);const Z=await M.getLookups();if(B||!Z||!Array.isArray(Z.actionTypes))return;const le=Z.actionTypes.map(fe=>({label:fe.name,value:String(fe.actionTypeId)}));x(le),te&&te(Z.actionTypes);const he=Array.isArray(Z.thirdParties)?Z.thirdParties.map(fe=>({label:fe.thirdPartyName,value:fe.thirdPartyId})):[];w(he)}catch(Z){console.error("Error loading lookups",Z)}finally{B||T(!1)}})(),()=>{B=!0}},[]);const D=B=>l.jsxs(h.Tag,{children:[l.jsx(ot.PlusOutlined,{})," ",B.length," more"]}),V=typeof a=="number"||typeof u=="number"||typeof d=="number"||typeof m=="number"||typeof v=="number"||typeof S=="number"||Array.isArray(j)&&j.length>0||Array.isArray(F)&&F.length>0||!!G||!!J,U=!!e&&V&&!ne;return l.jsxs(h.Spin,{spinning:!!ne||b,children:[l.jsxs(h.Row,{gutter:[16,16],align:"bottom",children:[l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),l.jsx(h.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),l.jsx(h.Col,{span:14,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:a,onChange:o,options:r})}),l.jsx(h.Col,{span:14,children:l.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:u,onChange:c,options:i})})]})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),l.jsx(h.Col,{span:14,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:d,onChange:f,options:r})}),l.jsx(h.Col,{span:14,children:l.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:m,onChange:p,options:i})})]})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),l.jsx(h.Col,{span:14,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:v,onChange:g,options:r})}),l.jsx(h.Col,{span:14,children:l.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:S,onChange:L,options:i})})]})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),l.jsx(h.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:j,onChange:q,options:A,maxTagCount:1,maxTagPlaceholder:D})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Third Party App"}),l.jsx(h.Select,{mode:"multiple",placeholder:"Third Party app",className:"w-full",value:F,onChange:H,options:O})]})})]}),l.jsxs(h.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[l.jsx(h.Col,{xs:24,sm:12,md:8,lg:7,children:l.jsxs("div",{className:"flex items-center h-full gap-8",children:[l.jsx(h.Checkbox,{checked:G,onChange:B=>Q(B.target.checked),className:"w-full",children:"Human-In-The-Loop"}),l.jsx(h.Checkbox,{checked:J,onChange:B=>I(B.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(h.Button,{onClick:N,children:"Clear"}),l.jsx(h.Button,{type:"primary",onClick:E,loading:!!ne,disabled:!U,children:"Save"})]})})]})]})}function Tu({entries:t,userRoles:e,onEdit:s,loading:n}){const r=new Map(e.map(a=>[a.userRoleId,a.userRoleName])),i=a=>a.map(o=>r.get(o)||String(o)).join(", ");return l.jsx(h.Table,{rowKey:"id",dataSource:t,pagination:!1,loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(a,o)=>l.jsxs("span",{children:[o.l1.minutes?`Action taken in (${o.l1.minutes} Mins)`:"No Action taken in 0 Min",o.l1.roles?.length?`, Escalate to (${i(o.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(a,o)=>l.jsxs("span",{children:[o.l2.minutes?`Action taken in (${o.l2.minutes} Mins)`:"No Action taken in 0 Min",o.l2.roles?.length?`, Escalate to (${i(o.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(a,o)=>l.jsxs("span",{children:[o.l3.minutes?`Action taken in (${o.l3.minutes} Mins)`:"No Action taken in 0 Min",o.l3.roles?.length?`, Escalate to (${i(o.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(a,o)=>o.actions?.length?o.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(a,o)=>o.notify?.length?o.notify.join(", "):"-"},{title:"Human-In-The-Loop",key:"humanLoop",render:(a,o)=>o.humanLoop?"Yes":"No"},{title:"Auto Expire",key:"isAutoExpire",render:(a,o)=>o.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(a,o)=>l.jsx(h.Button,{type:"text",onClick:()=>s(o.id),children:l.jsx(ot.EditOutlined,{})})}]})}const{Title:Au}=h.Typography;function Fi({userRoles:t,rules:e,rawRules:s}){const{rules:n}=je(),[r,i]=y.useState(!1),[a,o]=y.useState(s),[u,c]=y.useState({}),d=y.useMemo(()=>t.map(g=>({label:g.userRoleName,value:g.userRoleId})),[t]),f=y.useMemo(()=>(e||[]).map((g,S)=>({key:g.RuleId||g.Name||String(S),ruleName:g.Name||"-",ruleDesc:g.Description||""})),[e]);y.useEffect(()=>{let g=!1;return(async()=>{try{i(!0);const S=await n.getRules();g||(o(Array.isArray(S)?S:[]),c({}))}catch{!g&&Array.isArray(s)&&o(s)}finally{g||i(!1)}})(),()=>{g=!0}},[]),y.useEffect(()=>{!a&&Array.isArray(s)&&o(s)},[s]);const m=y.useMemo(()=>{if(!Array.isArray(a)||!a.length)return{};const g={};for(const S of f){const L=a.find(q=>q?.ruleId===S.key||q?.ruleName===S.key||q?.RuleId===S.key||q?.ruleName===S.ruleName||q?.Name===S.ruleName),j=Array.isArray(L?.userRoleIds)?L.userRoleIds:[];j.length&&(g[S.key]=j)}return g},[a,f]),p=()=>{c({})},v=async()=>{try{if(!a||!Array.isArray(a)||Object.keys(u).length===0){Ne.toast.info("No changes to save");return}i(!0);const g=Object.entries(u).map(async([S,L])=>{const j=a.find(Q=>Q?.ruleId===S||Q?.ruleName===S||Q?.RuleId===S),q=typeof j?.recordId=="number"?j.recordId:void 0;if(!j||typeof q!="number")throw new Error(`Unable to find recordId for rule ${S}`);const F=Array.isArray(L)?L:[],H=F.map(Q=>{const J=t.find(I=>I.userRoleId===Q);return{id:Q,name:J?.userRoleName??String(Q)}}),G={...j,ruleId:S,userRoleIds:F,userRoles:H,actions:[{actionTypeId:4,actionTypeUniqueId:"bc0973d4-9be0-4efb-8545-c9112ba06c1f",name:"Audible Warning",notificationType:"Alarm",category:"Hardware",description:"Test",isSystemDefined:!0,isActive:!0,displayOrder:0}]};return n.updateRule(q,G)});await Promise.all(g),Ne.toast.success("Alert assignment saved");try{const S=await n.getRules();o(Array.isArray(S)?S:[]),c({})}catch(S){console.error("Failed to refresh rules after save",S)}}catch(g){console.error("Failed to save alert assignment",g)}finally{i(!1)}};return l.jsxs("div",{className:"w-full",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsx(Au,{level:4,className:"!mb-4",children:"Alert Assignment"})}),l.jsx(h.Table,{rowKey:"key",dataSource:f,loading:r,pagination:!1,columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(g,S)=>l.jsx(h.Select,{mode:"multiple",placeholder:"Dropdown with Multi select",className:"w-full",value:u[S.key]??m[S.key]??[],onChange:L=>c(j=>({...j,[S.key]:L})),options:d})}]}),l.jsxs(h.Space,{className:"mt-4",children:[l.jsx(h.Button,{onClick:p,disabled:r,children:"Clear"}),l.jsx(h.Button,{type:"primary",onClick:v,loading:r,disabled:r||Object.keys(u).length===0,children:"Save"})]})]})}const{Title:mr}=h.Typography;function Pi({severities:t,rules:e,userRoles:s,rawRules:n,onSave:r}){const{rules:i,alerts:a}=je(),[o,u]=y.useState("By Severity"),[c,d]=y.useState("By severity"),[f,m]=y.useState("By Severity"),[p,v]=y.useState(!1),[g,S]=y.useState(!1),[L,j]=y.useState(!1),[q,F]=y.useState(null),[H,G]=y.useState("rules"),[Q,J]=y.useState(),[I,N]=y.useState(),[E,ne]=y.useState(),[te,M]=y.useState(),[A,x]=y.useState(),[O,w]=y.useState(),[b,T]=y.useState(),[D,V]=y.useState(),[U,B]=y.useState([]),[Z,le]=y.useState([]),[he,fe]=y.useState(!1),[xe,ae]=y.useState(!1),[pe,Ie]=y.useState({}),[Oe,dt]=y.useState({}),[ve,ht]=y.useState(s||[]),[Ze,Nt]=y.useState([]),[C,z]=y.useState(!1),[me,Be]=y.useState(!1),[X,Re]=y.useState(n||[]);y.useEffect(()=>{n&&n.length&&Re(n)},[n]),y.useEffect(()=>{if(!X||!X.length)return;const R=Object.keys(pe).length>0||Object.keys(Oe).length>0;if(Ze.length&&!R)return;const ie=X.map((_,P)=>{const re=e.find(Te=>Te.RuleId===(_.ruleId||_.ruleName))?.Name||_.ruleName||_.Name||"-",Y=_.escalationSettings||{},oe=typeof Y.level1UserRoleId=="number"&&Y.level1UserRoleId>0?[Y.level1UserRoleId]:[],He=typeof Y.level2UserRoleId=="number"&&Y.level2UserRoleId>0?[Y.level2UserRoleId]:[],gs=typeof Y.level3UserRoleId=="number"&&Y.level3UserRoleId>0?[Y.level3UserRoleId]:[],yn=(Array.isArray(Y.escalationSettingsActionTypeIds)?Y.escalationSettingsActionTypeIds:[]).map(Te=>pe[Te]||String(Te)),gn=(Array.isArray(Y.thirdPartyId)?Y.thirdPartyId:[]).map(Te=>Oe[Te]||String(Te)),vs=typeof Y.humanLoop=="boolean"?Y.humanLoop:null,Ss=typeof Y.isAutoExpire=="boolean"?Y.isAutoExpire:null;return{id:String(_.ruleId||_.ruleName||P),ruleOrSeverityLabel:re,l1:{minutes:Y.level1PostAssistTime??void 0,roles:oe},l2:{minutes:Y.level2PostAssistTime??void 0,roles:He},l3:{minutes:Y.level3PostAssistTime??void 0,roles:gs},actions:yn,notify:gn,humanLoop:vs,isAutoExpire:Ss}});Nt(ie)},[X,e,pe,Oe]);const Ut=y.useMemo(()=>t.map(R=>({label:R.DisplayName,value:R.SeverityId})),[t]),Ce=y.useMemo(()=>e.map(R=>({label:R.Name,value:R.RuleId})),[e]),ps=y.useMemo(()=>ve.map(R=>({label:R.userRoleName,value:R.userRoleId})),[ve]),Bi=y.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(R=>({label:`${R}`,value:R})),[]);y.useEffect(()=>{let R=!1;async function ie(){try{j(!0),F(null);const _=await a.getAdminSettings();if(!R&&_){const P=vr(_.sortBy);u(P),m(P),v(!1)}}catch(_){if(!R){const P=_ instanceof Error?_.message:"Failed to load admin settings";F(P)}}finally{R||j(!1)}}return ie(),()=>{R=!0}},[]),y.useEffect(()=>{if(!I)return;const R=re=>{const Y=Number(re);return!isNaN(Y)&&Y>0?Y:void 0},ie=re=>{const Y=Number(re);return!isNaN(Y)&&Y>0?Y:void 0},P=(X||[]).find(re=>re?.ruleId===I||re?.ruleName===I||re?.RuleId===I)?.escalationSettings;if(P&&typeof P=="object"){ne(ie(P.level1PostAssistTime)),M(R(P.level1UserRoleId)),x(ie(P.level2PostAssistTime)),w(R(P.level2UserRoleId)),T(ie(P.level3PostAssistTime)),V(R(P.level3UserRoleId));const re=Array.isArray(P.escalationSettingsActionTypeIds)?P.escalationSettingsActionTypeIds:[];B(re.map(Y=>String(Y))),le(Array.isArray(P.thirdPartyId)?P.thirdPartyId:[]),fe(!!P.humanLoop),ae(!!P.isAutoExpire)}},[H,I,X]);const Zi=async()=>{try{Be(!0);const R=await i.getRules(),ie=Array.isArray(R)?R:Array.isArray(R?.data)?R.data:[];Re(ie);const _=ie.map((P,re)=>{const Y=e.find(Te=>Te.RuleId===(P.ruleId||P.ruleName))?.Name||P.ruleName||P.Name||"-",oe=P.escalationSettings||{},He=typeof oe.level1UserRoleId=="number"&&oe.level1UserRoleId>0?[oe.level1UserRoleId]:[],gs=typeof oe.level2UserRoleId=="number"&&oe.level2UserRoleId>0?[oe.level2UserRoleId]:[],mn=typeof oe.level3UserRoleId=="number"&&oe.level3UserRoleId>0?[oe.level3UserRoleId]:[],pn=(Array.isArray(oe.escalationSettingsActionTypeIds)?oe.escalationSettingsActionTypeIds:[]).map(Te=>pe[Te]||String(Te)),vs=(Array.isArray(oe.thirdPartyId)?oe.thirdPartyId:[]).map(Te=>Oe[Te]||String(Te)),Ss=typeof oe.humanLoop=="boolean"?oe.humanLoop:null;return{id:String(P.ruleId||P.ruleName||re),ruleOrSeverityLabel:Y,l1:{minutes:oe.level1PostAssistTime??void 0,roles:He},l2:{minutes:oe.level2PostAssistTime??void 0,roles:gs},l3:{minutes:oe.level3PostAssistTime??void 0,roles:mn},actions:pn,notify:vs,humanLoop:Ss}});Nt(_)}catch(R){console.error("Failed to refetch entries",R)}finally{Be(!1)}};y.useEffect(()=>{let R=!1;return(async()=>{try{const ie=await i.getLookups();if(R||!ie)return;const _={};if(Array.isArray(ie.thirdParties))for(const re of ie.thirdParties)typeof re.thirdPartyId=="number"&&(_[re.thirdPartyId]=re.thirdPartyName);dt(_);const P=Array.isArray(ie.userRoles)?ie.userRoles.map(re=>({userRoleId:re.userRoleId??re.id,userRoleName:re.userRoleName??re.name})):[];R||ht(P.length?P:s||[])}catch(ie){console.error("Error loading lookups",ie)}})(),()=>{R=!0}},[]);const Hi=async()=>{S(!0);try{const R=await a.setAdminSettings({sortBy:o,groupBy:"string"});R?.responseStatus&&R?.data&&Ne.toast.success(R.data),m(o),v(!1)}catch(R){console.error("Error saving admin settings",R)}finally{S(!1)}},zi=()=>{u(f),v(!1)},_i=async()=>{z(!0),r?.({ruleId:I,levels:[{minutes:E,role:te},{minutes:A,role:O},{minutes:b,role:D}],actions:U,thirdPartyIds:Z,humanLoop:he,isAutoExpire:xe});try{if(I){const _=Array.isArray(U)?U.map(He=>Number(He)):[],P=(X||[]).find(He=>He?.ruleId===I||He?.ruleName===I||He?.RuleId===I),re=typeof P?.recordId=="number"?P.recordId:void 0;if(!P||typeof re!="number"){Ne.toast.error("Unable to find rule recordId for update");return}const Y={...P,actions:[{actionTypeId:4,actionTypeUniqueId:"bc0973d4-9be0-4efb-8545-c9112ba06c1f",name:"Audible Warning",notificationType:"Alarm",category:"Hardware",description:"Test",isSystemDefined:!0,isActive:!0,displayOrder:0}],escalationSettings:{level1UserRoleId:te??0,level1PostAssistTime:E??0,level2UserRoleId:O??0,level2PostAssistTime:A??0,level3UserRoleId:D??0,level3PostAssistTime:b??0,escalationSettingsActionTypeIds:_,thirdPartyId:Array.isArray(Z)?Z:[],humanLoop:he,isAutoExpire:xe}},oe=await i.updateRule(re,Y);if(oe?.responseStatus||oe?.ok||oe){Ne.toast.success("Escalation settings saved"),await Zi(),N(void 0),ne(void 0),M(void 0),x(void 0),w(void 0),T(void 0),V(void 0),B([]),le([]),fe(!1),ae(!1);return}}}catch(_){console.error("Error saving escalation settings",_)}finally{z(!1)}const ie=e.find(_=>_.RuleId===I)?.Name||"-";Nt(_=>[..._,{id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ruleOrSeverityLabel:ie,l1:{minutes:E,roles:te?[te]:[]},l2:{minutes:A,roles:O?[O]:[]},l3:{minutes:b,roles:D?[D]:[]},actions:(Array.isArray(U)?U:[]).map(P=>{const re=Number(P);return pe[re]||String(P)}),notify:(Array.isArray(Z)?Z:[]).map(P=>Oe[P]||String(P)),humanLoop:!!he,isAutoExpire:!!xe}])},Yi=()=>{u("By Severity"),d("By severity"),G("rules"),J(void 0),N(void 0),ne(void 0),M(void 0),x(void 0),w(void 0),T(void 0),V(void 0),B([]),le([]),fe(!1),ae(!1)};return l.jsxs("div",{className:"w-full",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx(mr,{level:4,className:"!mb-2",children:"Admin Settings"}),l.jsxs(h.Spin,{spinning:L,children:[q?l.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",q]}):null,l.jsx(wu,{sortBy:o,groupBy:c,onChange:R=>{R.sortBy&&(u(R.sortBy),v(!0)),R.groupBy&&(d(R.groupBy),v(!0))},showActions:p,onSave:Hi,onClear:zi,saving:g})]})]}),l.jsx(h.Divider,{className:"my-6"}),l.jsxs("div",{children:[l.jsx(mr,{level:4,className:"!mb-4",children:"Escalation Settings"}),l.jsx(bu,{escBasis:H,setEscBasis:G,selectedSeverity:Q,setSelectedSeverity:J,selectedRule:I,setSelectedRule:N,severityOptions:Ut,ruleOptions:Ce,minsOptions:Bi,roleOptions:ps,l1mins:E,setL1mins:ne,l1role:te,setL1role:M,l2mins:A,setL2mins:x,l2role:O,setL2role:w,l3mins:b,setL3mins:T,l3role:D,setL3role:V,actions:U,setActions:B,thirdPartyIds:Z,setThirdPartyIds:le,humanLoop:he,setHumanLoop:fe,onClear:Yi,onSave:_i,saving:C,onActionTypesLoaded:R=>{const ie={};for(const _ of R)typeof _.actionTypeId=="number"&&(ie[_.actionTypeId]=_.name);Ie(ie)},isAutoExpire:xe,setAutoExpire:ae})]}),l.jsx(h.Divider,{className:"my-6"}),l.jsx(Tu,{entries:Ze,userRoles:ve,loading:me,onEdit:R=>{G("rules");const ie=Ze.find(P=>P.id===R),_=e.find(P=>P.RuleId===R)||(ie?e.find(P=>P.Name===ie.ruleOrSeverityLabel):void 0);N(_?_.RuleId:R)}}),l.jsx(h.Divider,{className:"my-6"}),l.jsx(Fi,{userRoles:ve,rules:e,rawRules:n}),l.jsx(h.Divider,{})]})}const{Title:yr,Text:Gt}=h.Typography;function ku({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:i}=je(),a=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[o,u]=y.useState("By Severity"),[c,d]=y.useState(new Set),[f,m]=y.useState(null),[p,v]=y.useState(null),[g,S]=y.useState({inApp:!1,sms:!1,email:!1}),[L,j]=y.useState([]),[q,F]=y.useState(!0),[H,G]=y.useState(!1);y.useEffect(()=>{let I=!1;return(async()=>{try{const N=await i.getPreferenceSettings();if(I||!N)return;S({inApp:!!N.inApp,sms:!!N.sms,email:!!N.email});const E=vr(N.sortBy);u(E==="By Created Date"?"By Created Date":"By Severity"),m(An(N.doNotDisturbStart)),v(An(N.doNotDisturbEnd)),Array.isArray(N.anomalyIds)&&d(new Set(N.anomalyIds.map(ne=>String(ne))))}catch(N){console.error("Error in loading my preferences: ",N)}})(),()=>{I=!0}},[]),y.useEffect(()=>{let I=!1;return(async()=>{try{F(!0);const N=await r.getLookups();if(I||!N)return;const E=Array.isArray(N.anomalies)?N.anomalies:[];j(E)}catch(N){console.error("Failed to load anomalies lookups",N)}finally{I||F(!1)}})(),()=>{I=!0}},[]);const Q=I=>{d(N=>{const E=new Set(N);return E.has(I)?E.delete(I):E.add(I),E})},J=async()=>{s?.({sortBy:o,subscribedRuleIds:Array.from(c),dnd:{from:f,to:p},channels:g});try{G(!0);const I=f?f.format?.("HH:mm:ss")??"00:00:00":"00:00:00",N=p?p.format?.("HH:mm:ss")??"00:00:00":"00:00:00",E=Array.from(c).map(te=>Number(te)).filter(te=>Number.isFinite(te)),ne=await i.setPreferenceSettings({anomalyIds:E,doNotDisturbStart:I,doNotDisturbEnd:N,inApp:!!g.inApp,sms:!!g.sms,email:!!g.email,sortBy:o});ne?.responseStatus&&Ne.toast.success(ne?.data||"Preferences updated successfully.")}catch(I){console.error("Error in saving my preferences: ",I)}finally{G(!1)}};return l.jsxs("div",{className:"w-full",children:[l.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:l.jsx(h.Col,{xs:24,md:8,children:l.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[l.jsx(Gt,{className:"text-gray-600",children:"Sort By:"}),l.jsx(h.Select,{className:"w-[240px]",value:o,options:a,onChange:u})]})})}),l.jsxs("div",{className:"mb-4",children:[l.jsx(yr,{level:5,className:"!mb-2",children:"Anomalies"}),q?l.jsx("div",{className:"py-4",children:l.jsx(h.Spin,{})}):l.jsx(h.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(L)?L:[]).map(I=>{const N=String(I.recordId),E=I.anomalyName;return l.jsx(h.Checkbox,{checked:c.has(N),onChange:()=>Q(N),children:E},N)})})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx(yr,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),l.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:l.jsx(h.Col,{xs:24,md:12,children:l.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[l.jsx(Gt,{children:"Do Not Disturb mode:"}),l.jsxs(h.Space,{size:12,className:"w-full",children:[l.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[l.jsx(Gt,{children:"From"}),l.jsx(h.TimePicker,{value:f,onChange:I=>m(I),format:"HH:mm"})]}),l.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[l.jsx(Gt,{children:"To"}),l.jsx(h.TimePicker,{value:p,onChange:I=>v(I),format:"HH:mm"})]})]})]})})}),l.jsxs(h.Row,{gutter:[24,12],children:[l.jsx(h.Col,{children:l.jsx(h.Checkbox,{checked:g.inApp,onChange:I=>S({...g,inApp:I.target.checked}),children:"In-app"})}),l.jsx(h.Col,{children:l.jsx(h.Checkbox,{checked:g.sms,onChange:I=>S({...g,sms:I.target.checked}),children:"SMS"})}),l.jsx(h.Col,{children:l.jsx(h.Checkbox,{checked:g.email,onChange:I=>S({...g,email:I.target.checked}),children:"Email"})})]})]}),l.jsx(h.Divider,{}),l.jsxs(h.Space,{className:"gap-3",children:[l.jsx(h.Button,{onClick:n,disabled:H,children:"Cancel"}),l.jsx(h.Button,{type:"primary",onClick:J,loading:H,children:"Save"})]})]})}function Li({severities:t,rules:e,userRoles:s,rawRules:n}){return l.jsx("div",{className:"w-full",children:l.jsx(Pi,{severities:t,rules:e,userRoles:s,rawRules:n})})}const Nu="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=",Iu="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 ys(){const{alerts:t}=je(),{data:e,isLoading:s}=us({queryKey:["userTimeZone"],queryFn:async()=>{const[n,r]=await Promise.all([t.getMyAppPreferences?.()??Promise.resolve(null),t.getTimeZoneMasters?.()??Promise.resolve([])]),i=Intl.DateTimeFormat().resolvedOptions().timeZone,a={timeZoneUniqueId:"",ianaTimeZoneId:i,timeZoneName:i,offset:""};if(!n?.timeZoneUniqueId||!r.length)return a;const o=r.find(u=>u.timeZoneUniqueId===n.timeZoneUniqueId);return o?.ianaTimeZoneId?{timeZoneUniqueId:o.timeZoneUniqueId,ianaTimeZoneId:o.ianaTimeZoneId,timeZoneName:o.timeZoneName,offset:o.offset}:a},staleTime:5*6e4});return{timeZoneDetails:e,loading:s}}function Ou(t){const e=(t.status||"").toLowerCase()==="completed"?l.jsx("img",{src:Nu,alt:"completed",style:{width:20,height:20}}):l.jsx("img",{src:Iu,alt:"pending",style:{width:20,height:20}});return{title:l.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:l.jsx("b",{children:t.title})}),t.description?l.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?l.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function Cu({data:t}){const{timeZoneDetails:e}=ys();return l.jsx("div",{className:"w-full",children:l.jsx(h.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:l.jsxs("div",{className:"w-full",children:[l.jsx(h.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:l.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsx("span",{className:"text-gray-500",children:"Alert ID"}),l.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsx("span",{className:"text-gray-500",children:"Severity"}),l.jsx("span",{className:"text-black",children:t.summary.severity})]}),l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsx("span",{className:"text-gray-500",children:"Location"}),l.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),l.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),l.jsx("div",{className:"mt-2",children:l.jsx(h.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(Ou)})})]})]})},{key:"notification",label:"Notification Sent",children:l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(t.notifications||[]).map((s,n)=>l.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{className:"flex flex-col",children:[l.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),l.jsx("span",{className:"text-xs text-gray-500 mt-1",children:os(s.sentAt,e?.ianaTimeZoneId)})]}),l.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"]})]}),l.jsxs("div",{className:"mt-4 text-xs",children:[l.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?l.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),l.jsxs("div",{className:"mt-4",children:[l.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),l.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,i)=>{const a=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex flex-col",children:[l.jsxs("span",{className:"text-black",children:[r.name," - ",l.jsx("span",{style:{color:a?"#FF3B30":"#FFB86A"},children:a?"Escalation Notification":"Alert Notification"})]}),l.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),l.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})]},i)})})]})]},n)),t?.notifications?.length?null:l.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const Eu=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:i,notifGroups:a})=>{const o={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:u}=ys(),c=i?.length?i.map(f=>{const m=(f?.status||f?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",p=f?.createdDate?os(f.createdDate,u?.ianaTimeZoneId):f?.timestamp?os(f.timestamp,u?.ianaTimeZoneId):"";return{status:m,title:f?.status||f?.eventStatus||"Status Update",description:f?.description||f?.actionNotes||"",timestamp:p}}):[],d={summary:o,timeline:c,notifications:a??[]};return l.jsx(Cu,{data:d})};const Mu=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Du=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),pr=t=>{const e=Du(t);return e.charAt(0).toUpperCase()+e.slice(1)},Ui=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),ju=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Ru={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 Fu=y.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:i,iconNode:a,...o},u)=>y.createElement("svg",{ref:u,...Ru,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:Ui("lucide",r),...!i&&!ju(o)&&{"aria-hidden":"true"},...o},[...a.map(([c,d])=>y.createElement(c,d)),...Array.isArray(i)?i:[i]]));const $i=(t,e)=>{const s=y.forwardRef(({className:n,...r},i)=>y.createElement(Fu,{ref:i,iconNode:e,className:Ui(`lucide-${Mu(pr(t))}`,`lucide-${t}`,n),...r}));return s.displayName=pr(t),s};const Pu=[["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"}]],Wi=$i("maximize-2",Pu);const Lu=[["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"}]],Uu=$i("minimize-2",Lu),$u=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,i]=y.useState(!1),[a,o]=y.useState(!1);return y.useEffect(()=>{t&&o(!1)},[t,s]),y.useEffect(()=>{t&&(!s||a)&&e()},[t,s,a,e]),t?l.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:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),e())},onTouchStart:e,children:l.jsxs("div",{className:`relative ${r?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:u=>u.stopPropagation(),children:[n==="image"?l.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:()=>o(!0)}):l.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:()=>o(!0)}),l.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),l.jsx("button",{onClick:()=>i(!r),className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:r?l.jsx(Uu,{size:20}):l.jsx(Wi,{size:20})})]})}):null};function Wu(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 Es(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:Wu(t?.mediaUrl||t)}function Vu(t){const e=t;return e?Array.isArray(e)?e:[e]:[]}const qu={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Bu={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Zu=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:i=!1,initialTab:a="details",sourceTab:o})=>{const[u,c]=y.useState(),[d,f]=y.useState(""),[m,p]=y.useState(!1),v=y.useRef(null),[g,S]=y.useState("details"),[L,j]=y.useState(void 0),q=nn(),{alerts:F}=je(),{timeZoneDetails:H}=ys(),[G,Q]=y.useState(!1),[J,I]=y.useState(void 0),[N,E]=y.useState(void 0),[ne,te]=y.useState({}),M=s?.originalData||{},{eventName:A,alertId:x,timestamp:O,description:w,spaceName:b,assignTeam:T,priority:D,statusType:V,id:U,alertDetails:B,statusHistory:Z,mediaDetails:le,alertNumber:he}=M,fe=C=>{const z=String(C||"").toLowerCase();return z==="delivered"||z==="sent"?"Delivered":z==="failed"?"Failed":"Queued"},xe=C=>({name:C?.receipientName||C?.recipientName||"-",role:C?.receipientRoleName||"",phone:C?.receipentPhoneNumber||C?.recipientPhoneNumber||C?.receipientEmail||C?.recipientEmail||"",status:fe(C?.messageStatus),notificationReceipientType:C?.notificationReceipientType||""}),ae=(C,z)=>{const me=z.map(xe),Be=me.filter(Ce=>Ce.status==="Delivered").length,X=z.map(Ce=>Ce?.sentAt).filter(Boolean).sort((Ce,ps)=>new Date(ps).getTime()-new Date(Ce).getTime())[0],Re=z[0]||{},Ut=[Re?.severityName,Re?.anomalyName].filter(Boolean).join(" - ")||`${C} Notification`;return{channelLabel:`${C} Notification`,sentAt:X||"",messageTitle:Ut,messageBody:"",total:me.length,delivered:Be,recipients:me}},pe=C=>{const z=new Map;return(C||[]).forEach(me=>{const Be=String(me?.notificationType||"Unknown"),X=z.get(Be)||[];X.push(me),z.set(Be,X)}),Array.from(z.entries()).map(([me,Be])=>ae(me,Be))},Ie=async C=>{try{const z=await F.getAlertNotifications(C),me=pe(z);j(me)}catch{j(void 0)}};y.useEffect(()=>{if(g!=="track"||!U)return;let C=!1;return Ie(U).then(()=>{C&&j(void 0)}),()=>{C=!0}},[g,U]),y.useEffect(()=>{t&&S(a)},[t,a]);const dt=o==="archived"||["completed","false positive"].includes(String(V||"").toLowerCase()),ve=C=>{const z=String(C?.value||"").toLowerCase(),me=String(C?.statusName||"").toLowerCase();return z.includes("reopen")||me.includes("reopen")},ht=(r||[]).filter(C=>{const z=ve(C);return typeof o<"u"?o==="archived"?z:!z:dt?z:!z}).map(C=>({value:C.value,label:C.statusName})),Ze=y.useMemo(()=>Vu(le),[le]);y.useEffect(()=>{let C=!1;const z=new AbortController,me=async X=>{if(X){C||te(Re=>({...Re,[X]:!1}));try{const Re=await fetch(X,{method:"HEAD",signal:z.signal});if(Re.ok){C||te(Ce=>({...Ce,[X]:!0}));return}if(Re.status===404){C||te(Ce=>({...Ce,[X]:!1}));return}if(!(await fetch(X,{method:"GET",signal:z.signal})).ok)throw new Error("Media not available");C||te(Ce=>({...Ce,[X]:!0}))}catch{C||te(Re=>({...Re,[X]:!1}))}}};return te({}),Ze.filter(X=>!Es(X)).map(X=>X?.mediaUrl||X).filter(X=>typeof X=="string"&&X.length>0).forEach(X=>me(X)),()=>{C=!0,z.abort()}},[Ze]);const Nt=async()=>{try{p(!0);const C={alertUniqueId:x,alertId:U,status:u?String(u):void 0,notes:d.trim(),modifiedBy:0},z=await q.mutateAsync(C);if(z?.responseStatus){const me=z?.data||"Alert updated successfully.";Ne.toast.success(me,{autoClose:1500,onClose:()=>{n(),e()}}),c(void 0),f("")}else{const me=z?.errorMessage||"Failed to update alert status";Ne.toast.error(me)}}catch(C){console.error("Error updating alert status:",C),Ne.toast.error("Failed to update alert status. Please try again.")}finally{p(!1)}};return l.jsx(h.Modal,{open:t,onCancel:e,width:1e3,styles:{body:{maxHeight:"70vh",overflowY:"auto"}},footer:g==="details"?l.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[l.jsx(h.Button,{onClick:e,className:"bg-[#6C757D] text-white",children:"Cancel"}),l.jsx(h.Button,{type:"primary",onClick:Nt,loading:m,children:m?"Saving...":"Save Changes"})]}):null,children:s&&l.jsx(h.Tabs,{activeKey:g,onChange:C=>S(C),items:[{key:"details",label:"Alert Detail",children:l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("div",{className:"text-sm font-bold",children:A||"Alert Event"}),B?.firstName?l.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",B?.firstName," ",B?.lastName||""," ",B?.residentId||""]}):null,l.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",os(O,H?.ianaTimeZoneId)]}),l.jsxs("div",{className:"font-sm text-gray-500",children:[l.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",w||"No description available"]}),b&&l.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",b]}),T&&l.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",T]}),l.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[l.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${qu[String(D)]||"#DFE4EA"}`,backgroundColor:Bu[String(D)]},children:["Severity: ",D||"N/A"]}),l.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(V||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",V||"N/A"]})]}),l.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:l.jsxs("div",{className:"w-full mt-4",children:[l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(h.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:C=>c(C),value:u,options:ht,loading:i})}),l.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[l.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),l.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:d,onChange:C=>f(C.target.value)})]})]})})]}),l.jsx("div",{className:"flex flex-col gap-4",children:l.jsxs("div",{className:"w-full mt-1",children:[l.jsxs("div",{className:"w-full flex items-center justify-between",children:[l.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),Ze.length>1?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:()=>v.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:l.jsx(ot.LeftOutlined,{style:{fontSize:12}})}),l.jsx("button",{type:"button",onClick:()=>v.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:l.jsx(ot.RightOutlined,{style:{fontSize:12}})})]}):null]}),Ze.length?l.jsx("div",{className:"w-full",children:l.jsx(h.Carousel,{ref:v,dots:!0,className:"w-full",children:Ze.map((C,z)=>l.jsxs("div",{className:"flex justify-center items-center",children:[Es(C)?l.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[l.jsx("source",{src:C.mediaUrl||C}),"Your browser does not support the video tag."]}):l.jsx("img",{src:C.mediaUrl||C,alt:C.caption||`media-${z}`,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg"}),C.caption&&l.jsx("p",{className:"text-xs text-gray-500 mt-1",children:C.caption}),!Es(C)&&ne[String(C.mediaUrl||C)]?l.jsx("button",{onClick:()=>{Q(!0),I(C.mediaUrl||C),E(C.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:l.jsx(Wi,{size:20})}):null]},z))})}):null]})}),l.jsx($u,{isOpen:G,onClose:()=>Q(!1),src:J||"",type:N||"image"})]})},{key:"track",label:"Track Incident",children:l.jsx(Eu,{alertId:x,id:U,priority:D,spaceName:b,alertNumber:he,statusHistory:Z,notifGroups:L})}]})})};function Vi(){const{alerts:t}=je(),e=us({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function fn({alerts:t,loading:e=!1,columns:s,onRefetch:n}){const[r,i]=y.useState(!1),[a,o]=y.useState(null),[u,c]=y.useState("details"),{list:d,loading:f}=Vi(),{timeZoneDetails:m,loading:p}=ys(),v=m?.timeZoneName??"UTC",g=m?.ianaTimeZoneId??"UTC";function S(H,G){o(H),c(G?.tab??"details"),q(G?.sourceTab??"active"),i(!0)}function L(){i(!1)}const[j,q]=y.useState("active"),F=a?{originalData:{...a,alertId:a.alertId??a.id,mediaDetails:a.mediaDetails}}:null;return l.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[l.jsxs("div",{className:"w-1/2 flex items-center justify-between mb-4",children:[l.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),p?l.jsx(h.Spin,{size:"small"}):l.jsx(Ri,{label:v,timeZone:g})]}),l.jsx(h.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:H=>{H==="active"&&n?.()},items:[{key:"active",label:"Active",children:l.jsx(Js,{data:t,loading:e,pageSize:10,columns:s||[],onAlertIdClick:S,onRefetch:n})},{key:"archived",label:"Archived",children:l.jsx(ji,{alerts:t,loading:e,columns:s||[],onAlertIdClick:S})},{key:"settings",label:"Settings",children:l.jsx(Hu,{})}]}),l.jsx(Zu,{isModalOpen:r,handleModalClose:L,selectedRow:F,fetchAlertLogs:()=>{},alertStatusList:d,alertStatusLoading:f,initialTab:u,sourceTab:j})]})}function Hu(){const[t,e]=y.useState([]),[s,n]=y.useState([]),[r,i]=y.useState([]),{rules:a}=je();return y.useEffect(()=>{let o=!0;return(async()=>{try{const u=await a.getRules();if(!o)return;i(Array.isArray(u)?u:[]);const c=(u||[]).map((d,f)=>({RuleId:d.ruleId||d.ruleName||String(f),Name:d.ruleName||d.Name||"-",Description:d.ruleDesc||d.Description||"",SeverityId:0}));e(c.length?c:pt.rules);try{const d=await a.getLookups(),f=Array.isArray(d?.userRoles)?d.userRoles.map(m=>({userRoleId:m.userRoleId??m.id,userRoleName:m.userRoleName??m.name})):[];n(f.length?f:pt.userRoles)}catch{n(pt.userRoles)}}catch{e(pt.rules),n(pt.userRoles)}})(),()=>{o=!1}},[]),l.jsx(Li,{severities:pt.severities,rules:t,userRoles:s,rawRules:r})}function qi(){const{alerts:t}=je(),e=us({queryKey:["alerts","list"],queryFn:()=>t.listAlerts(),staleTime:3e4});return{alerts:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function zu(t){const{alerts:e,loading:s,refetch:n}=qi();return l.jsx(fn,{alerts:e,loading:s,columns:t.columns,onRefetch:n})}function _u({tenant:t,apiDomain:e,rulesDomain:s,headers:n,alerts:r,loading:i,columns:a}){const[o]=y.useState(()=>new Ka),u=y.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return l.jsx(Xa,{client:o,children:l.jsx(wr,{tenant:t,override:u,children:Array.isArray(r)?l.jsx(fn,{alerts:r,loading:!!i,columns:a}):l.jsx(zu,{columns:a})})})}function Yu(t){const{alerts:e}=je(),s=us({queryKey:["alerts","report",t],queryFn:()=>e.getAlertsReport(t),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const Gu=[{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=Fi;exports.AlertConsole=fn;exports.AlertConsoleWidget=_u;exports.AlertsTable=Js;exports.ApiProvider=wr;exports.ArchivedTable=ji;exports.Clock=Ri;exports.DataTable=br;exports.MyPreferencesPanel=ku;exports.SettingsPanel=Pi;exports.SettingsTabs=Li;exports.exampleAlertColumns=Gu;exports.useAlertStatusList=Vi;exports.useAlerts=qi;exports.useAlertsReport=Yu;exports.useApi=je;exports.useUpdateAlertStatus=nn;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),y=require("react"),h=require("antd"),ut=require("@ant-design/icons"),Ie=require("react-toastify");function Gi(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const ve=Gi(y),Qi="#FF3B30",Ji="#FF9500",Ki="#FFCC00",Xi="#34C759",qt={critical:Qi,high:Ji,medium:Ki,low:Xi},xn={Critical:qt.critical,High:qt.high,Medium:qt.medium,Low:qt.low};function ea(t){return xn[t]||xn.Low}function wn(t){if(!t||typeof t!="string")return 0;const e=t.trim().split(":");if(e.length!==3)return 0;const[s,n,r]=e,i=Number.parseInt(s,10),a=Number.parseInt(n,10),o=Number.parseFloat(r||"0"),u=Number.isFinite(i)?i:0,c=Number.isFinite(a)?a:0,d=Number.isFinite(o)?o:0;return u*3600+c*60+d}function bn(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(a=>parseInt(String(a).trim(),10)).filter(a=>Number.isFinite(a)),r=new Set,i=[];return n.forEach(a=>{r.has(a)||(r.add(a),i.push(a))}),i}const xr="",ta=xr,sa="",na="",Tn={snl:{alerts:xr,rules:ta},schools:{alerts:sa,rules:na}};function Ee(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function ra(){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 Me(t,e){const s={...e.headers,...ra()},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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const a=i?.errorMessage||i?.message||`HTTP ${n.status}`;throw new Error(a)}return i}function ia(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=Ee(t.baseUrl,"/api/Alert"),n=await Me(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertStatusList(){const s=Ee(t.baseUrl,"/api/Alert/AlertStatusList"),n=await Me(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=Ee(t.baseUrl,"/Alerts/GetAlertsReport"),r=Zt(n,s),i=await Me(r,{method:"GET",headers:e});return Array.isArray(i)?i:[]},async updateAlertStatus(s){const n=Ee(t.baseUrl,"/api/Alert/status");return Me(n,{method:"PUT",headers:e,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=Ee(t.baseUrl,"/api/Alert/GetAdminSettings"),n=await Me(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=Ee(t.baseUrl,"/api/Alert/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return Me(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=Ee(t.baseUrl,"/api/Alert/GetPreferenceSettings"),n=await Me(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=Ee(t.baseUrl,"/api/Alert/SetPreferenceSettings"),r=await Me(n,{method:"POST",headers:e,body:JSON.stringify(s??{})}),i=r?.responseStatus??!0,a=r?.data??r?.message??"Preferences updated successfully.";return{responseStatus:i,errorMessage:i?"":r?.errorMessage??r?.message??"",statusCode:200,data:a}},async getAlertNotifications(s){const n=Ee(t.baseUrl,"/api/Alert/GetNotifications"),r=Zt(n,{alertId:s}),i=await Me(r,{method:"GET",headers:e});return Array.isArray(i)?i:i&&typeof i=="object"&&Array.isArray(i.data)?i.data:[]},async notifyFamilyMembers(s){const n=Ee(t.baseUrl,"/api/Alert/NotificationToFamilyMembers"),r=Zt(n,{alertId:s});return Me(r,{method:"POST",headers:e})},async sendSMSorEmailNotifications(s,n,r){const i=Ee(t.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),a=Zt(i,{alertId:s,isEmail:n,isSMS:r});return Me(a,{method:"POST",headers:e})},async getTimeZoneMasters(){const s=Ee(t.baseUrl,"/api/UserPreference/GetTimeZoneMasters"),n=await Me(s,{method:"GET",headers:e});return Array.isArray(n)?n:n&&typeof n=="object"&&Array.isArray(n.data)?n.data:[]},async getMyAppPreferences(){const s=Ee(t.baseUrl,"/api/UserPreference/GetMyAppPreferences"),n=await Me(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 An(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{}}}async function Bt(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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const a=i?.errorMessage||i?.message||`HTTP ${n.status}`;throw new Error(a)}return i}function oa(t){const e={"Content-Type":"application/json",...t.headers||{}},s=An(t.baseUrl,"/api/Rules"),n=An(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,i){const a=`${s}/${r}`;return Bt(a,{method:"PUT",headers:e,body:JSON.stringify(i??{})})}}}function la(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xt={exports:{}},ua=Xt.exports,kn;function ca(){return kn||(kn=1,(function(t,e){(function(s,n){t.exports=n()})(ua,(function(){var s=1e3,n=6e4,r=36e5,i="millisecond",a="second",o="minute",u="hour",c="day",d="week",f="month",m="quarter",p="year",v="date",g="Invalid Date",S=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,P=/\[([^\]]+)]|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,D={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(M){var b=["th","st","nd","rd"],x=M%100;return"["+M+(b[(x-20)%10]||b[x]||b[0])+"]"}},V=function(M,b,x){var O=String(M);return!O||O.length>=b?M:""+Array(b+1-O.length).join(x)+M},F={s:V,z:function(M){var b=-M.utcOffset(),x=Math.abs(b),O=Math.floor(x/60),w=x%60;return(b<=0?"+":"-")+V(O,2,"0")+":"+V(w,2,"0")},m:function M(b,x){if(b.date()<x.date())return-M(x,b);var O=12*(x.year()-b.year())+(x.month()-b.month()),w=b.clone().add(O,f),T=x-w<0,A=b.clone().add(O+(T?-1:1),f);return+(-(O+(x-w)/(T?w-A:A-w))||0)},a:function(M){return M<0?Math.ceil(M)||0:Math.floor(M)},p:function(M){return{M:f,y:p,w:d,d:c,D:v,h:u,m:o,s:a,ms:i,Q:m}[M]||String(M||"").toLowerCase().replace(/s$/,"")},u:function(M){return M===void 0}},z="en",Q={};Q[z]=D;var J="$isDayjsObject",K=function(M){return M instanceof re||!(!M||!M[J])},I=function M(b,x,O){var w;if(!b)return z;if(typeof b=="string"){var T=b.toLowerCase();Q[T]&&(w=T),x&&(Q[T]=x,w=T);var A=b.split("-");if(!w&&A.length>1)return M(A[0])}else{var j=b.name;Q[j]=b,w=j}return!O&&w&&(z=w),w||!O&&z},N=function(M,b){if(K(M))return M.clone();var x=typeof b=="object"?b:{};return x.date=M,x.args=arguments,new re(x)},C=F;C.l=I,C.i=K,C.w=function(M,b){return N(M,{locale:b.$L,utc:b.$u,x:b.$x,$offset:b.$offset})};var re=(function(){function M(x){this.$L=I(x.locale,null,!0),this.parse(x),this.$x=this.$x||x.x||{},this[J]=!0}var b=M.prototype;return b.parse=function(x){this.$d=(function(O){var w=O.date,T=O.utc;if(w===null)return new Date(NaN);if(C.u(w))return new Date;if(w instanceof Date)return new Date(w);if(typeof w=="string"&&!/Z$/i.test(w)){var A=w.match(S);if(A){var j=A[2]-1||0,q=(A[7]||"0").substring(0,3);return T?new Date(Date.UTC(A[1],j,A[3]||1,A[4]||0,A[5]||0,A[6]||0,q)):new Date(A[1],j,A[3]||1,A[4]||0,A[5]||0,A[6]||0,q)}}return new Date(w)})(x),this.init()},b.init=function(){var x=this.$d;this.$y=x.getFullYear(),this.$M=x.getMonth(),this.$D=x.getDate(),this.$W=x.getDay(),this.$H=x.getHours(),this.$m=x.getMinutes(),this.$s=x.getSeconds(),this.$ms=x.getMilliseconds()},b.$utils=function(){return C},b.isValid=function(){return this.$d.toString()!==g},b.isSame=function(x,O){var w=N(x);return this.startOf(O)<=w&&w<=this.endOf(O)},b.isAfter=function(x,O){return N(x)<this.startOf(O)},b.isBefore=function(x,O){return this.endOf(O)<N(x)},b.$g=function(x,O,w){return C.u(x)?this[O]:this.set(w,x)},b.unix=function(){return Math.floor(this.valueOf()/1e3)},b.valueOf=function(){return this.$d.getTime()},b.startOf=function(x,O){var w=this,T=!!C.u(O)||O,A=C.p(x),j=function(Se,le){var pe=C.w(w.$u?Date.UTC(w.$y,le,Se):new Date(w.$y,le,Se),w);return T?pe:pe.endOf(c)},q=function(Se,le){return C.w(w.toDate()[Se].apply(w.toDate("s"),(T?[0,0,0,0]:[23,59,59,999]).slice(le)),w)},W=this.$W,Z=this.$M,B=this.$D,oe="set"+(this.$u?"UTC":"");switch(A){case p:return T?j(1,0):j(31,11);case f:return T?j(1,Z):j(0,Z+1);case d:var me=this.$locale().weekStart||0,he=(W<me?W+7:W)-me;return j(T?B-he:B+(6-he),Z);case c:case v:return q(oe+"Hours",0);case u:return q(oe+"Minutes",1);case o:return q(oe+"Seconds",2);case a:return q(oe+"Milliseconds",3);default:return this.clone()}},b.endOf=function(x){return this.startOf(x,!1)},b.$set=function(x,O){var w,T=C.p(x),A="set"+(this.$u?"UTC":""),j=(w={},w[c]=A+"Date",w[v]=A+"Date",w[f]=A+"Month",w[p]=A+"FullYear",w[u]=A+"Hours",w[o]=A+"Minutes",w[a]=A+"Seconds",w[i]=A+"Milliseconds",w)[T],q=T===c?this.$D+(O-this.$W):O;if(T===f||T===p){var W=this.clone().set(v,1);W.$d[j](q),W.init(),this.$d=W.set(v,Math.min(this.$D,W.daysInMonth())).$d}else j&&this.$d[j](q);return this.init(),this},b.set=function(x,O){return this.clone().$set(x,O)},b.get=function(x){return this[C.p(x)]()},b.add=function(x,O){var w,T=this;x=Number(x);var A=C.p(O),j=function(Z){var B=N(T);return C.w(B.date(B.date()+Math.round(Z*x)),T)};if(A===f)return this.set(f,this.$M+x);if(A===p)return this.set(p,this.$y+x);if(A===c)return j(1);if(A===d)return j(7);var q=(w={},w[o]=n,w[u]=r,w[a]=s,w)[A]||1,W=this.$d.getTime()+x*q;return C.w(W,this)},b.subtract=function(x,O){return this.add(-1*x,O)},b.format=function(x){var O=this,w=this.$locale();if(!this.isValid())return w.invalidDate||g;var T=x||"YYYY-MM-DDTHH:mm:ssZ",A=C.z(this),j=this.$H,q=this.$m,W=this.$M,Z=w.weekdays,B=w.months,oe=w.meridiem,me=function(le,pe,Ce,Oe){return le&&(le[pe]||le(O,T))||Ce[pe].slice(0,Oe)},he=function(le){return C.s(j%12||12,le,"0")},Se=oe||function(le,pe,Ce){var Oe=le<12?"AM":"PM";return Ce?Oe.toLowerCase():Oe};return T.replace(P,(function(le,pe){return pe||(function(Ce){switch(Ce){case"YY":return String(O.$y).slice(-2);case"YYYY":return C.s(O.$y,4,"0");case"M":return W+1;case"MM":return C.s(W+1,2,"0");case"MMM":return me(w.monthsShort,W,B,3);case"MMMM":return me(B,W);case"D":return O.$D;case"DD":return C.s(O.$D,2,"0");case"d":return String(O.$W);case"dd":return me(w.weekdaysMin,O.$W,Z,2);case"ddd":return me(w.weekdaysShort,O.$W,Z,3);case"dddd":return Z[O.$W];case"H":return String(j);case"HH":return C.s(j,2,"0");case"h":return he(1);case"hh":return he(2);case"a":return Se(j,q,!0);case"A":return Se(j,q,!1);case"m":return String(q);case"mm":return C.s(q,2,"0");case"s":return String(O.$s);case"ss":return C.s(O.$s,2,"0");case"SSS":return C.s(O.$ms,3,"0");case"Z":return A}return null})(le)||A.replace(":","")}))},b.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},b.diff=function(x,O,w){var T,A=this,j=C.p(O),q=N(x),W=(q.utcOffset()-this.utcOffset())*n,Z=this-q,B=function(){return C.m(A,q)};switch(j){case p:T=B()/12;break;case f:T=B();break;case m:T=B()/3;break;case d:T=(Z-W)/6048e5;break;case c:T=(Z-W)/864e5;break;case u:T=Z/r;break;case o:T=Z/n;break;case a:T=Z/s;break;default:T=Z}return w?T:C.a(T)},b.daysInMonth=function(){return this.endOf(f).$D},b.$locale=function(){return Q[this.$L]},b.locale=function(x,O){if(!x)return this.$L;var w=this.clone(),T=I(x,O,!0);return T&&(w.$L=T),w},b.clone=function(){return C.w(this.$d,this)},b.toDate=function(){return new Date(this.valueOf())},b.toJSON=function(){return this.isValid()?this.toISOString():null},b.toISOString=function(){return this.$d.toISOString()},b.toString=function(){return this.$d.toUTCString()},M})(),te=re.prototype;return N.prototype=te,[["$ms",i],["$s",a],["$m",o],["$H",u],["$W",c],["$M",f],["$y",p],["$D",v]].forEach((function(M){te[M[1]]=function(b){return this.$g(b,M[0],M[1])}})),N.extend=function(M,b){return M.$i||(M(b,re,N),M.$i=!0),N},N.locale=I,N.isDayjs=K,N.unix=function(M){return N(1e3*M)},N.en=Q[z],N.Ls=Q,N.p={},N}))})(Xt)),Xt.exports}var da=ca();const ha=la(da);function wr(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 br(t){if(!t||typeof t!="string")return{hours:0,minutes:0,seconds:0};const e=t.split(":").map(i=>parseInt(i,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 Nn(t){const{hours:e,minutes:s,seconds:n}=br(t);return ha().hour(e).minute(s).second(n).millisecond(0)}function ze(t,e){const s=(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return`${s}${n}`}function fa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}function In(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 _e(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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const a=i?.Message||`HTTP ${n.status}`;throw new Error(a)}return i}const fe=(...t)=>t.find(e=>e!=null);function ma(t){return{id:String(fe(t?.AlertId,t?.alertId)??""),priority:fe(t?.Priority,t?.priority,"Low"),timestamp:fe(t?.Timestamp,t?.timestamp,""),statusType:fe(t?.Status,t?.statusType,""),description:fe(t?.Description,t?.description,""),eventName:fe(t?.EventName,t?.eventName),ruleName:fe(t?.RuleName,t?.ruleName),spaceName:fe(t?.SpaceName,t?.spaceName),assignTeam:fe(t?.AssignTeam,t?.assignTeam),cameraName:fe(t?.CameraName,t?.cameraName),type:fe(t?.Type,t?.type),mediaDetails:fe(t?.MediaDetails,t?.mediaDetails),additionalMedia:fe(t?.AdditionalMedia,t?.additionalMedia),timeElapsed:fe(t?.TimeElapsed,t?.timeElapsed),timeRemaining:fe(t?.TimeRemaining,t?.timeRemaining),anomalyName:fe(t?.AnomalyName,t?.anomalyName),alertDetails:fe(t?.AlertDetails,t?.alertDetails),statusHistory:fe(t?.StatusHistory,t?.statusHistory),isEmailSent:fe(t?.IsEmailSent,t?.isEmailSent),isSMSSent:fe(t?.IsSMSSent,t?.isSMSSent),timeZoneUniqueId:fe(t?.TimeZoneUniqueId,t?.timeZoneUniqueId)}}function ya(t){const e={"Content-Type":"application/json",...t.headers||{}};return{async listAlerts(){const s=ze(t.baseUrl,"/api/detectionpolicy/alerts?customerId=99e5c8b5-b9d4-4d35-8885-7f121c532664"),n=await _e(s,{method:"GET",headers:e});return Array.isArray(n?.Items)?(n?.Items).map(ma):[]},async getAlertStatusList(){const s=ze(t.baseUrl,"/api/detectionpolicy/alerts/StatusList"),n=await _e(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async getAlertsReport(s){const n=ze(t.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),r=In(n,s),i=await _e(r,{method:"GET",headers:e});return Array.isArray(i)?i:[]},async updateAlertStatus(s){const n=ze(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 _e(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getAdminSettings(){const s=ze(t.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),n=await _e(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=ze(t.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),r={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??""};return _e(n,{method:"POST",headers:e,body:JSON.stringify(r)})},async getPreferenceSettings(){const s=ze(t.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),n=await _e(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=ze(t.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),r=c=>{const{hours:d,minutes:f,seconds:m}=br(c);return(d*3600+f*60+m)*1e7},i={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(c=>String(c)):[],DoNotDisturbStart:{Ticks:r(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:r(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},a=await _e(n,{method:"POST",headers:e,body:JSON.stringify(i)}),o=a?.responseStatus??!0,u=a?.data??a?.message??"Preferences updated successfully.";return{responseStatus:o,errorMessage:o?"":a?.errorMessage??a?.Message??a?.message??"",statusCode:200,data:u}},async getAlertNotifications(s){const n=ze(t.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),r=In(n,{alertId:s}),i=await _e(r,{method:"GET",headers:e});return Array.isArray(i)?i:i&&typeof i=="object"&&Array.isArray(i.data)?i.data:[]}}}function pa(){try{const t=localStorage.getItem("authToken");return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}async function Ke(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 i={};if(r)try{i=JSON.parse(r)}catch{i={ok:n.ok,status:n.status,raw:r}}if(!n.ok){const a=i?.errorMessage||i?.message||`HTTP ${n.status}`;throw new Error(a)}return i}function ga(t){const e={"Content-Type":"application/json",...t.headers||{}},s=new URL("/api/detectionpolicy/rules",t.baseUrl).toString();return{async getRules(){const n=await Ke(s,{method:"GET",headers:e});return Array.isArray(n)?n:[]},async setEscalationSettings(n){return Ke(s,{method:"POST",headers:e,body:JSON.stringify(n??{})})},async getLookups(){const n=F=>new URL(F,t.baseUrl).toString(),r=[Ke(n("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:e}),Ke(n("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:e})],[i,a,o,u,c]=await Promise.allSettled(r),d=F=>F.status==="fulfilled"&&Array.isArray(F.value)?F.value:[],f=d(i),m=d(a),p=d(o),v=d(u),g=d(c),S=f.map(F=>({actionTypeId:Number(F?.ActionTypeId),name:F?.DisplayName??F?.Name??""})),P=m.map(F=>({recordId:F?.AnomalyId,anomalyName:F?.DisplayName??F?.Name??""})),D=p.map(F=>({thirdPartyId:Number(F?.ThirdPartyId),thirdPartyName:F?.ThirdPartyName??F?.Name??""})),V={actionTypes:S,anomalies:P,thirdParties:D};return v.length&&(V.severities=v),g.length&&(V.scheduleTypes=g),V},async updateRule(n,r){const i=`${s}/${n}`;return Ke(i,{method:"PUT",headers:e,body:JSON.stringify(r??{})})}}}const Tr=y.createContext(null);function Ar({tenant:t="snl",override:e,children:s}){const n=y.useMemo(()=>{const i=e?.alertsBaseUrl?.trim()||Tn[t]?.alerts||"";let a=e?.rulesBaseUrl?.trim()||Tn[t]?.rules||"";t==="snl"&&(a=i);const o=e?.headers;return{tenant:t,alertsBaseUrl:i,rulesBaseUrl:a,headers:o}},[t,e?.alertsBaseUrl,e?.rulesBaseUrl,JSON.stringify(e?.headers||{})]),r=y.useMemo(()=>{const i=n.tenant==="schools"?ya({baseUrl:n.alertsBaseUrl,headers:n.headers}):ia({baseUrl:n.alertsBaseUrl,headers:n.headers}),a=n.tenant==="schools"?ga({baseUrl:n.rulesBaseUrl,headers:n.headers}):oa({baseUrl:n.alertsBaseUrl,headers:n.headers});return{config:n,alerts:i,rules:a}},[n]);return l.jsx(Tr.Provider,{value:r,children:s})}function je(){const t=y.useContext(Tr);if(!t)throw new Error("useApi must be used inside ApiProvider");return t}const va={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Sa={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Qs=6,Js=7;function On(t,e,s){const n=t===Qs,r=t===Js,i=e.isEmailSent??!1,a=e.isSMSSent??!1,o=n&&i||r&&a,u=n?"Send Email":r?"Send SMS":s,c=n&&i?"Email sent":r&&a?"SMS sent":u,d=n&&i?"Email sent":r&&a?"SMS sent":`Click to ${u}`;return{isDisabled:o,buttonText:c,tooltipTitle:d}}function xa(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 wa(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 bs(t,e){return`${t}-${e?"email":"sms"}`}function Ht(t){return t===Qs||t===Js}function ds({value:t,onChange:e,options:s,className:n,dropdownWidth:r}){return l.jsx(h.Select,{className:n,options:s,value:t,onChange:e,dropdownMatchSelectWidth:r??260})}const ba=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Ta({value:t,onChange:e,options:s}){return l.jsx(ds,{className:"w-[140px]",value:t,onChange:e,options:s||ba})}const Aa=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function ka({value:t,onChange:e,options:s}){return l.jsx(ds,{className:"w-[220px]",dropdownWidth:280,value:t,onChange:e,options:s||Aa})}function Na({value:t,onChange:e,options:s}){return l.jsx(ds,{className:"w-[100px]",value:t,onChange:e,options:s||[]})}const Ia=[{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 Oa({value:t,onChange:e,options:s}){return l.jsx(ds,{className:"w-[130px]",value:t,onChange:e,options:s||Ia})}function kr({columns:t,data:e,loading:s=!1,pageSize:n=10,rowKey:r="id",toolbar:i,tableProps:a}){return l.jsxs("div",{children:[i,l.jsx(h.Table,{rowKey:r,dataSource:e,columns:t,loading:s,pagination:{pageSize:n,showSizeChanger:!0,showTotal:o=>`Total: ${o}`},bordered:!0,...a})]})}function Ks({data:t,loading:e=!1,pageSize:s=10,columns:n,severityOptions:r,spaceOptions:i,renderActions:a,onAlertIdClick:o,onRefetch:u,excludeCompleted:c=!0}){const[d,f]=y.useState("All"),[m,p]=y.useState("All"),[v,g]=y.useState("All"),[S,P]=y.useState("All"),[D,V]=y.useState(""),[F,z]=y.useState([{label:"All",value:"All"}]),[Q,J]=y.useState(new Set),{rules:K,alerts:I}=je(),N={6:{title:"Email",kind:"icon",icon:l.jsx(ut.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:l.jsx(ut.MessageOutlined,{})}},C=y.useMemo(()=>xa(t),[t]),re=y.useMemo(()=>wa(t),[t]);y.useEffect(()=>{let T=!0;return(async()=>{try{const A=await K.getLookups(),q=(Array.isArray(A.thirdParties)?A.thirdParties:[]).map(W=>({label:W.thirdPartyName,value:String(W.thirdPartyId)}));T&&z([{label:"All",value:"All"},...q])}catch(A){console.error("Error loading third party options",A)}})(),()=>{T=!1}},[K]);const te=y.useMemo(()=>(t||[]).some(T=>bn(T).length>0),[t]),M=y.useMemo(()=>(t||[]).filter(T=>{const A=d==="All"||T.priority===d,j=`${T.id} ${T.description} ${T.statusType}`.toLowerCase(),q=!D||j.includes(D.toLowerCase()),W=m==="All"||(T.anomalyName||"").toLowerCase()===m.toLowerCase(),Z=v==="All"||(T.spaceName||"").toLowerCase()===v.toLowerCase(),B=!te||S==="All"||bn(T).includes(Number(S)),oe=!c||!["completed","false positive"].includes(String(T.statusType||"").toLowerCase());return A&&q&&W&&Z&&B&&oe}),[t,d,D,m,v,S,te,c]),b=C,x=i&&i.length?i:re,O=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:T=>l.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Sa[T]}`,backgroundColor:va[T]},children:T})},{title:"Tracker",key:"tracker",width:140,render:(T,A)=>l.jsx("a",{onClick:j=>{j.preventDefault(),o?.(A,{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:(T,A)=>{if(a)return l.jsx(l.Fragment,{children:a(A)});const j=async(Ce,Oe)=>{const ft=bs(A.id,Ce);J(xe=>new Set(xe).add(ft));try{const xe=await I.sendSMSorEmailNotifications?.(A.id,Ce,Oe);xe?.responseStatus?(Ie.toast.success(xe.data||(Ce?"Email sent successfully":"SMS sent successfully")),u?.()):Ie.toast.error(xe?.data||xe?.errorMessage||"Failed to send notification")}catch(xe){Ie.toast.error(xe?.message||"Failed to send notification")}finally{J(xe=>{const mt=new Set(xe);return mt.delete(ft),mt})}},q=Qs,W=Js,Z=N[q],B=N[W],oe=On(q,A,Z?.title),me=On(W,A,B?.title),he=bs(A.id,!0),Se=bs(A.id,!1),le=Ht(q)&&Q.has(he),pe=Ht(W)&&Q.has(Se);return l.jsxs(h.Space,{size:"middle",children:[l.jsx(h.Tooltip,{title:oe.tooltipTitle,children:l.jsx(h.Button,{size:"small",disabled:oe.isDisabled,loading:le,onClick:Ht(q)?()=>j(!0,!1):void 0,icon:!le&&Z?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:oe.buttonText})},String(q)),l.jsx(h.Tooltip,{title:me.tooltipTitle,children:l.jsx(h.Button,{size:"small",disabled:me.isDisabled,loading:pe,onClick:Ht(W)?()=>j(!1,!0):void 0,icon:!pe&&B?.icon,className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:me.buttonText})},String(W))]})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(T,A)=>{const j=A?.timeElapsed,q=A?.timeRemaining,W=j?wn(j):0,Z=q?wn(q):0,B=Math.round(W/(W+Z)*100);return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),l.jsx("span",{className:"font-medium",children:j??"-"})]}),l.jsx(h.Progress,{percent:B,showInfo:!1,size:"small",strokeColor:ea(A.priority)}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-[70px]",children:"Remaining"}),l.jsx("span",{className:"font-medium",children:q??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(T,A)=>l.jsxs("div",{children:[l.jsx("a",{onClick:j=>{j.preventDefault(),o?.(A,{sourceTab:"active"})},className:"inline-block mb-1 text-blue-600",children:A.alertNumber}),l.jsx("div",{className:"text-black/65",children:T})]})}],w=n&&n.length?n:O;return l.jsx("div",{children:l.jsx(kr,{rowKey:"id",data:M,columns:w,loading:e,pageSize:s,toolbar:l.jsxs(h.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[l.jsx(h.Col,{flex:"none",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{children:"Severity"}),l.jsx(Ta,{value:d,onChange:f,options:r})]})}),l.jsx(h.Col,{flex:"none",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{children:"Anomaly type"}),l.jsx(ka,{value:m,onChange:p,options:b})]})}),l.jsx(h.Col,{flex:"none",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{children:"Space"}),l.jsx(Na,{value:v,onChange:g,options:x})]})}),l.jsx(h.Col,{flex:"none",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{children:"Action Taken"}),l.jsx(Oa,{value:S,onChange:P,options:F})]})}),l.jsx(h.Col,{flex:"auto"}),l.jsx(h.Col,{flex:"none",children:l.jsx(h.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:V,onChange:T=>V(T.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}var Tt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ca={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ea=class{#e=Ca;#t=!1;setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&this.#t&&t!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:t}),this.#e=t,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},ot=new Ea;function Ma(t){setTimeout(t,0)}var ct=typeof window>"u"||"Deno"in globalThis;function ke(){}function Da(t,e){return typeof t=="function"?t(e):t}function Ds(t){return typeof t=="number"&&t>=0&&t!==1/0}function Nr(t,e){return Math.max(t+(e||0)-Date.now(),0)}function st(t,e){return typeof t=="function"?t(e):t}function Le(t,e){return typeof t=="function"?t(e):t}function Cn(t,e){const{type:s="all",exact:n,fetchStatus:r,predicate:i,queryKey:a,stale:o}=t;if(a){if(n){if(e.queryHash!==Xs(a,e.options))return!1}else if(!Ft(e.queryKey,a))return!1}if(s!=="all"){const u=e.isActive();if(s==="active"&&!u||s==="inactive"&&u)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||r&&r!==e.state.fetchStatus||i&&!i(e))}function En(t,e){const{exact:s,status:n,predicate:r,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(s){if(dt(e.options.mutationKey)!==dt(i))return!1}else if(!Ft(e.options.mutationKey,i))return!1}return!(n&&e.state.status!==n||r&&!r(e))}function Xs(t,e){return(e?.queryKeyHashFn||dt)(t)}function dt(t){return JSON.stringify(t,(e,s)=>Rs(s)?Object.keys(s).sort().reduce((n,r)=>(n[r]=s[r],n),{}):s)}function Ft(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(s=>Ft(t[s],e[s])):!1}var ja=Object.prototype.hasOwnProperty;function js(t,e,s=0){if(t===e)return t;if(s>500)return e;const n=Mn(t)&&Mn(e);if(!n&&!(Rs(t)&&Rs(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),o=a.length,u=n?new Array(o):{};let c=0;for(let d=0;d<o;d++){const f=n?d:a[d],m=t[f],p=e[f];if(m===p){u[f]=m,(n?d<i:ja.call(t,f))&&c++;continue}if(m===null||p===null||typeof m!="object"||typeof p!="object"){u[f]=p;continue}const v=js(m,p,s+1);u[f]=v,v===m&&c++}return i===o&&c===i?t:u}function ns(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function Mn(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Rs(t){if(!Dn(t))return!1;const e=t.constructor;if(e===void 0)return!0;const s=e.prototype;return!(!Dn(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Dn(t){return Object.prototype.toString.call(t)==="[object Object]"}function Ra(t){return new Promise(e=>{ot.setTimeout(e,t)})}function Fs(t,e,s){if(typeof s.structuralSharing=="function")return s.structuralSharing(t,e);if(s.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return js(t,e)}catch(n){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${n}`),n}return js(t,e)}return e}function Fa(t,e,s=0){const n=[...t,e];return s&&n.length>s?n.slice(1):n}function La(t,e,s=0){const n=[e,...t];return s&&n.length>s?n.slice(0,-1):n}var rs=Symbol();function Ir(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===rs&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===rs?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function en(t,e){return typeof t=="function"?t(...e):!!t}function Pa(t,e,s){let n=!1,r;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(r??=e(),n||(n=!0,r.aborted?s():r.addEventListener("abort",s,{once:!0})),r)}),t}var Ua=class extends Tt{#e;#t;#s;constructor(){super(),this.#s=t=>{if(!ct&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#s=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},tn=new Ua;function Ls(){let t,e;const s=new Promise((r,i)=>{t=r,e=i});s.status="pending",s.catch(()=>{});function n(r){Object.assign(s,r),delete s.resolve,delete s.reject}return s.resolve=r=>{n({status:"fulfilled",value:r}),t(r)},s.reject=r=>{n({status:"rejected",reason:r}),e(r)},s}var $a=Ma;function Wa(){let t=[],e=0,s=o=>{o()},n=o=>{o()},r=$a;const i=o=>{e?t.push(o):r(()=>{s(o)})},a=()=>{const o=t;t=[],o.length&&r(()=>{n(()=>{o.forEach(u=>{s(u)})})})};return{batch:o=>{let u;e++;try{u=o()}finally{e--,e||a()}return u},batchCalls:o=>(...u)=>{i(()=>{o(...u)})},schedule:i,setNotifyFunction:o=>{s=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{r=o}}}var ge=Wa(),Va=class extends Tt{#e=!0;#t;#s;constructor(){super(),this.#s=t=>{if(!ct&&window.addEventListener){const e=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#s=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(s=>{s(t)}))}isOnline(){return this.#e}},is=new Va;function qa(t){return Math.min(1e3*2**t,3e4)}function Or(t){return(t??"online")==="online"?is.isOnline():!0}var Ps=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Cr(t){let e=!1,s=0,n;const r=Ls(),i=()=>r.status!=="pending",a=g=>{if(!i()){const S=new Ps(g);m(S),t.onCancel?.(S)}},o=()=>{e=!0},u=()=>{e=!1},c=()=>tn.isFocused()&&(t.networkMode==="always"||is.isOnline())&&t.canRun(),d=()=>Or(t.networkMode)&&t.canRun(),f=g=>{i()||(n?.(),r.resolve(g))},m=g=>{i()||(n?.(),r.reject(g))},p=()=>new Promise(g=>{n=S=>{(i()||c())&&g(S)},t.onPause?.()}).then(()=>{n=void 0,i()||t.onContinue?.()}),v=()=>{if(i())return;let g;const S=s===0?t.initialPromise:void 0;try{g=S??t.fn()}catch(P){g=Promise.reject(P)}Promise.resolve(g).then(f).catch(P=>{if(i())return;const D=t.retry??(ct?0:3),V=t.retryDelay??qa,F=typeof V=="function"?V(s,P):V,z=D===!0||typeof D=="number"&&s<D||typeof D=="function"&&D(s,P);if(e||!z){m(P);return}s++,t.onFail?.(s,P),Ra(F).then(()=>c()?void 0:p()).then(()=>{e?m(P):v()})})};return{promise:r,status:()=>r.status,cancel:a,continue:()=>(n?.(),r),cancelRetry:o,continueRetry:u,canStart:d,start:()=>(d()?v():p().then(v),r)}}var Er=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ds(this.gcTime)&&(this.#e=ot.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(ct?1/0:300*1e3))}clearGcTimeout(){this.#e&&(ot.clearTimeout(this.#e),this.#e=void 0)}},Za=class extends Er{#e;#t;#s;#r;#n;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#r=t.client,this.#s=this.#r.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=Rn(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(t){if(this.options={...this.#a,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Rn(this.options);e.data!==void 0&&(this.setState(jn(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){const s=Fs(this.state.data,t,this.options);return this.#i({data:s,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),s}setState(t,e){this.#i({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#n?.promise;return this.#n?.cancel(t),e?e.then(ke).catch(ke):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Le(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===rs||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>st(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Nr(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#n&&(this.#o?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(u=>u.options.queryFn);o&&this.setOptions(o.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const s=new AbortController,n=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,s.signal)})},r=()=>{const o=Ir(this.options,e),c=(()=>{const d={client:this.#r,queryKey:this.queryKey,meta:this.meta};return n(d),d})();return this.#o=!1,this.options.persister?this.options.persister(o,c,this):o(c)},a=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:r};return n(o),o})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#i({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=Cr({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o=>{o instanceof Ps&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),s.abort()},onFail:(o,u)=>{this.#i({type:"failed",failureCount:o,error:u})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const o=await this.#n.start();if(o===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#s.config.onSuccess?.(o,this),this.#s.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof Ps){if(o.silent)return this.#n.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#i({type:"error",error:o}),this.#s.config.onError?.(o,this),this.#s.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#i(t){const e=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...Mr(s.data,this.options),fetchMeta:t.meta??null};case"success":const n={...s,...jn(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?n:void 0,n;case"error":const r=t.error;return{...s,error:r,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=e(this.state),ge.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function Mr(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Or(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function jn(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Rn(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,s=e!==void 0,n=s?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:s?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var Ba=class extends Tt{constructor(t,e){super(),this.options=e,this.#e=t,this.#i=null,this.#o=Ls(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#s=void 0;#r=void 0;#n;#a;#o;#i;#y;#h;#f;#u;#c;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Fn(this.#t,this.options)?this.#d():this.updateResult(),this.#S())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Us(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Us(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#x(),this.#w(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Le(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#b(),this.#t.setOptions(this.options),e._defaulted&&!ns(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const n=this.hasListeners();n&&Ln(this.#t,s,this.options,e)&&this.#d(),this.updateResult(),n&&(this.#t!==s||Le(this.options.enabled,this.#t)!==Le(e.enabled,this.#t)||st(this.options.staleTime,this.#t)!==st(e.staleTime,this.#t))&&this.#p();const r=this.#g();n&&(this.#t!==s||Le(this.options.enabled,this.#t)!==Le(e.enabled,this.#t)||r!==this.#l)&&this.#v(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return za(this,s)&&(this.#r=s,this.#a=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#r}trackResult(t,e){return new Proxy(t,{get:(s,n)=>(this.trackProp(n),e?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,n))})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);return s.fetch().then(()=>this.createResult(s,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#d(t){this.#b();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(ke)),e}#p(){this.#x();const t=st(this.options.staleTime,this.#t);if(ct||this.#r.isStale||!Ds(t))return;const s=Nr(this.#r.dataUpdatedAt,t)+1;this.#u=ot.setTimeout(()=>{this.#r.isStale||this.updateResult()},s)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#w(),this.#l=t,!(ct||Le(this.options.enabled,this.#t)===!1||!Ds(this.#l)||this.#l===0)&&(this.#c=ot.setInterval(()=>{(this.options.refetchIntervalInBackground||tn.isFocused())&&this.#d()},this.#l))}#S(){this.#p(),this.#v(this.#g())}#x(){this.#u&&(ot.clearTimeout(this.#u),this.#u=void 0)}#w(){this.#c&&(ot.clearInterval(this.#c),this.#c=void 0)}createResult(t,e){const s=this.#t,n=this.options,r=this.#r,i=this.#n,a=this.#a,u=t!==s?t.state:this.#s,{state:c}=t;let d={...c},f=!1,m;if(e._optimisticResults){const K=this.hasListeners(),I=!K&&Fn(t,e),N=K&&Ln(t,s,e,n);(I||N)&&(d={...d,...Mr(c.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:v,status:g}=d;m=d.data;let S=!1;if(e.placeholderData!==void 0&&m===void 0&&g==="pending"){let K;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(K=r.data,S=!0):K=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,K!==void 0&&(g="success",m=Fs(r?.data,K,e),f=!0)}if(e.select&&m!==void 0&&!S)if(r&&m===i?.data&&e.select===this.#y)m=this.#h;else try{this.#y=e.select,m=e.select(m),m=Fs(r?.data,m,e),this.#h=m,this.#i=null}catch(K){this.#i=K}this.#i&&(p=this.#i,m=this.#h,v=Date.now(),g="error");const P=d.fetchStatus==="fetching",D=g==="pending",V=g==="error",F=D&&P,z=m!==void 0,J={status:g,fetchStatus:d.fetchStatus,isPending:D,isSuccess:g==="success",isError:V,isInitialLoading:F,isLoading:F,data:m,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:v,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:P,isRefetching:P&&!D,isLoadingError:V&&!z,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:V&&z,isStale:sn(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Le(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const K=J.data!==void 0,I=J.status==="error"&&!K,N=te=>{I?te.reject(J.error):K&&te.resolve(J.data)},C=()=>{const te=this.#o=J.promise=Ls();N(te)},re=this.#o;switch(re.status){case"pending":t.queryHash===s.queryHash&&N(re);break;case"fulfilled":(I||J.data!==re.value)&&C();break;case"rejected":(!I||J.error!==re.reason)&&C();break}}return J}updateResult(){const t=this.#r,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#a=this.options,this.#n.data!==void 0&&(this.#f=this.#t),ns(e,t))return;this.#r=e;const s=()=>{if(!t)return!0;const{notifyOnChangeProps:n}=this.options,r=typeof n=="function"?n():n;if(r==="all"||!r&&!this.#m.size)return!0;const i=new Set(r??this.#m);return this.options.throwOnError&&i.add("error"),Object.keys(this.#r).some(a=>{const o=a;return this.#r[o]!==t[o]&&i.has(o)})};this.#T({listeners:s()})}#b(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#s=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#S()}#T(t){ge.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Ha(t,e){return Le(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Fn(t,e){return Ha(t,e)||t.state.data!==void 0&&Us(t,e,e.refetchOnMount)}function Us(t,e,s){if(Le(e.enabled,t)!==!1&&st(e.staleTime,t)!=="static"){const n=typeof s=="function"?s(t):s;return n==="always"||n!==!1&&sn(t,e)}return!1}function Ln(t,e,s,n){return(t!==e||Le(n.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&sn(t,s)}function sn(t,e){return Le(e.enabled,t)!==!1&&t.isStaleByTime(st(e.staleTime,t))}function za(t,e){return!ns(t.getCurrentResult(),e)}function Pn(t){return{onFetch:(e,s)=>{const n=e.options,r=e.fetchOptions?.meta?.fetchMore?.direction,i=e.state.data?.pages||[],a=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},u=0;const c=async()=>{let d=!1;const f=v=>{Pa(v,()=>e.signal,()=>d=!0)},m=Ir(e.options,e.fetchOptions),p=async(v,g,S)=>{if(d)return Promise.reject();if(g==null&&v.pages.length)return Promise.resolve(v);const D=(()=>{const Q={client:e.client,queryKey:e.queryKey,pageParam:g,direction:S?"backward":"forward",meta:e.options.meta};return f(Q),Q})(),V=await m(D),{maxPages:F}=e.options,z=S?La:Fa;return{pages:z(v.pages,V,F),pageParams:z(v.pageParams,g,F)}};if(r&&i.length){const v=r==="backward",g=v?_a:Un,S={pages:i,pageParams:a},P=g(n,S);o=await p(S,P,v)}else{const v=t??i.length;do{const g=u===0?a[0]??n.initialPageParam:Un(n,o);if(u>0&&g==null)break;o=await p(o,g),u++}while(u<v)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s):e.fetchFn=c}}}function Un(t,{pages:e,pageParams:s}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,s[n],s):void 0}function _a(t,{pages:e,pageParams:s}){return e.length>0?t.getPreviousPageParam?.(e[0],e,s[0],s):void 0}var Ya=class extends Er{#e;#t;#s;#r;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#s=t.mutationCache,this.#t=[],this.state=t.state||Dr(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#s.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#n({type:"continue"})},s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Cr({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(i,a)=>{this.#n({type:"failed",failureCount:i,error:a})},onPause:()=>{this.#n({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const n=this.state.status==="pending",r=!this.#r.canStart();try{if(n)e();else{this.#n({type:"pending",variables:t,isPaused:r}),this.#s.config.onMutate&&await this.#s.config.onMutate(t,this,s);const a=await this.options.onMutate?.(t,s);a!==this.state.context&&this.#n({type:"pending",context:a,variables:t,isPaused:r})}const i=await this.#r.start();return await this.#s.config.onSuccess?.(i,t,this.state.context,this,s),await this.options.onSuccess?.(i,t,this.state.context,s),await this.#s.config.onSettled?.(i,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(i,null,t,this.state.context,s),this.#n({type:"success",data:i}),i}catch(i){try{await this.#s.config.onError?.(i,t,this.state.context,this,s)}catch(a){Promise.reject(a)}try{await this.options.onError?.(i,t,this.state.context,s)}catch(a){Promise.reject(a)}try{await this.#s.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,s)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,i,t,this.state.context,s)}catch(a){Promise.reject(a)}throw this.#n({type:"error",error:i}),i}finally{this.#s.runNext(this)}}#n(t){const e=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),ge.batch(()=>{this.#t.forEach(s=>{s.onMutationUpdate(t)}),this.#s.notify({mutation:this,type:"updated",action:t})})}};function Dr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ga=class extends Tt{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#s=0}#e;#t;#s;build(t,e,s){const n=new Ya({client:t,mutationCache:this,mutationId:++this.#s,options:t.defaultMutationOptions(e),state:s});return this.add(n),n}add(t){this.#e.add(t);const e=zt(t);if(typeof e=="string"){const s=this.#t.get(e);s?s.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=zt(t);if(typeof e=="string"){const s=this.#t.get(e);if(s)if(s.length>1){const n=s.indexOf(t);n!==-1&&s.splice(n,1)}else s[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=zt(t);if(typeof e=="string"){const n=this.#t.get(e)?.find(r=>r.state.status==="pending");return!n||n===t}else return!0}runNext(t){const e=zt(t);return typeof e=="string"?this.#t.get(e)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ge.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(s=>En(e,s))}findAll(t={}){return this.getAll().filter(e=>En(t,e))}notify(t){ge.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return ge.batch(()=>Promise.all(t.map(e=>e.continue().catch(ke))))}};function zt(t){return t.options.scope?.id}var Qa=class extends Tt{#e;#t=void 0;#s;#r;constructor(t,e){super(),this.#e=t,this.setOptions(e),this.bindMethods(),this.#n()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.#e.defaultMutationOptions(t),ns(this.options,e)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),e?.mutationKey&&this.options.mutationKey&&dt(e.mutationKey)!==dt(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(t){this.#n(),this.#a(t)}getCurrentResult(){return this.#t}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#n(),this.#a()}mutate(t,e){return this.#r=e,this.#s?.removeObserver(this),this.#s=this.#e.getMutationCache().build(this.#e,this.options),this.#s.addObserver(this),this.#s.execute(t)}#n(){const t=this.#s?.state??Dr();this.#t={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){ge.batch(()=>{if(this.#r&&this.hasListeners()){const e=this.#t.variables,s=this.#t.context,n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#r.onSuccess?.(t.data,e,s,n)}catch(r){Promise.reject(r)}try{this.#r.onSettled?.(t.data,null,e,s,n)}catch(r){Promise.reject(r)}}else if(t?.type==="error"){try{this.#r.onError?.(t.error,e,s,n)}catch(r){Promise.reject(r)}try{this.#r.onSettled?.(void 0,t.error,e,s,n)}catch(r){Promise.reject(r)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Ja=class extends Tt{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,s){const n=e.queryKey,r=e.queryHash??Xs(n,e);let i=this.get(r);return i||(i=new Za({client:t,queryKey:n,queryHash:r,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ge.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(s=>Cn(e,s))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(s=>Cn(t,s)):e}notify(t){ge.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){ge.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ge.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ka=class{#e;#t;#s;#r;#n;#a;#o;#i;constructor(t={}){this.#e=t.queryCache||new Ja,this.#t=t.mutationCache||new Ga,this.#s=t.defaultOptions||{},this.#r=new Map,this.#n=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=tn.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=is.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#i?.(),this.#i=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),s=this.#e.build(this,e),n=s.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(st(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:s})=>{const n=s.data;return[e,n]})}setQueryData(t,e,s){const n=this.defaultQueryOptions({queryKey:t}),i=this.#e.get(n.queryHash)?.state.data,a=Da(e,i);if(a!==void 0)return this.#e.build(this,n).setData(a,{...s,manual:!0})}setQueriesData(t,e,s){return ge.batch(()=>this.#e.findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,s)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;ge.batch(()=>{e.findAll(t).forEach(s=>{e.remove(s)})})}resetQueries(t,e){const s=this.#e;return ge.batch(()=>(s.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const s={revert:!0,...e},n=ge.batch(()=>this.#e.findAll(t).map(r=>r.cancel(s)));return Promise.all(n).then(ke).catch(ke)}invalidateQueries(t,e={}){return ge.batch(()=>(this.#e.findAll(t).forEach(s=>{s.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const s={...e,cancelRefetch:e.cancelRefetch??!0},n=ge.batch(()=>this.#e.findAll(t).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,s);return s.throwOnError||(i=i.catch(ke)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(ke)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const s=this.#e.build(this,e);return s.isStaleByTime(st(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ke).catch(ke)}fetchInfiniteQuery(t){return t.behavior=Pn(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ke).catch(ke)}ensureInfiniteQueryData(t){return t.behavior=Pn(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return is.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#s}setDefaultOptions(t){this.#s=t}setQueryDefaults(t,e){this.#r.set(dt(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#r.values()],s={};return e.forEach(n=>{Ft(t,n.queryKey)&&Object.assign(s,n.defaultOptions)}),s}setMutationDefaults(t,e){this.#n.set(dt(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#n.values()],s={};return e.forEach(n=>{Ft(t,n.mutationKey)&&Object.assign(s,n.defaultOptions)}),s}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#s.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Xs(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===rs&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#s.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},jr=ve.createContext(void 0),nn=t=>{const e=ve.useContext(jr);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Xa=({client:t,children:e})=>(ve.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),l.jsx(jr.Provider,{value:t,children:e})),Rr=ve.createContext(!1),eo=()=>ve.useContext(Rr);Rr.Provider;function to(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var so=ve.createContext(to()),no=()=>ve.useContext(so),ro=(t,e,s)=>{const n=s?.state.error&&typeof t.throwOnError=="function"?en(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||n)&&(e.isReset()||(t.retryOnMount=!1))},io=t=>{ve.useEffect(()=>{t.clearReset()},[t])},ao=({result:t,errorResetBoundary:e,throwOnError:s,query:n,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(r&&t.data===void 0||en(s,[t.error,n])),oo=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),n=t.staleTime;t.staleTime=typeof n=="function"?(...r)=>s(n(...r)):s(n),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},lo=(t,e)=>t.isLoading&&t.isFetching&&!e,uo=(t,e)=>t?.suspense&&e.isPending,$n=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function co(t,e,s){if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=eo(),r=no(),i=nn(),a=i.defaultQueryOptions(t);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a);const o=i.getQueryCache().get(a.queryHash);process.env.NODE_ENV!=="production"&&(a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),a._optimisticResults=n?"isRestoring":"optimistic",oo(a),ro(a,r,o),io(r);const u=!i.getQueryCache().get(a.queryHash),[c]=ve.useState(()=>new e(i,a)),d=c.getOptimisticResult(a),f=!n&&t.subscribed!==!1;if(ve.useSyncExternalStore(ve.useCallback(m=>{const p=f?c.subscribe(ge.batchCalls(m)):ke;return c.updateResult(),p},[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),ve.useEffect(()=>{c.setOptions(a)},[a,c]),uo(a,d))throw $n(a,c,r);if(ao({result:d,errorResetBoundary:r,throwOnError:a.throwOnError,query:o,suspense:a.suspense}))throw d.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,d),a.experimental_prefetchInRender&&!ct&&lo(d,n)&&(u?$n(a,c,r):o?.promise)?.catch(ke).finally(()=>{c.updateResult()}),a.notifyOnChangeProps?d:c.trackResult(d)}function hs(t,e){return co(t,Ba)}function ho(t,e){const s=nn(),[n]=ve.useState(()=>new Qa(s,t));ve.useEffect(()=>{n.setOptions(t)},[n,t]);const r=ve.useSyncExternalStore(ve.useCallback(a=>n.subscribe(ge.batchCalls(a)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=ve.useCallback((a,o)=>{n.mutate(a,o).catch(ke)},[n]);if(r.error&&en(n.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:i,mutateAsync:r.mutate}}function rn(){const{alerts:t}=je(),e=nn();return ho({mutationFn:s=>t.updateAlertStatus(s),onSuccess:()=>{e.invalidateQueries({queryKey:["alerts","list"]}),e.invalidateQueries({queryKey:["alerts","report"]})}})}class ht extends Error{}class fo extends ht{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class mo extends ht{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class yo extends ht{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class St extends ht{}class Fr extends ht{constructor(e){super(`Invalid unit ${e}`)}}class be extends ht{}class Xe extends ht{constructor(){super("Zone is an abstract class")}}const k="numeric",qe="short",De="long",as={year:k,month:k,day:k},Lr={year:k,month:qe,day:k},po={year:k,month:qe,day:k,weekday:qe},Pr={year:k,month:De,day:k},Ur={year:k,month:De,day:k,weekday:De},$r={hour:k,minute:k},Wr={hour:k,minute:k,second:k},Vr={hour:k,minute:k,second:k,timeZoneName:qe},qr={hour:k,minute:k,second:k,timeZoneName:De},Zr={hour:k,minute:k,hourCycle:"h23"},Br={hour:k,minute:k,second:k,hourCycle:"h23"},Hr={hour:k,minute:k,second:k,hourCycle:"h23",timeZoneName:qe},zr={hour:k,minute:k,second:k,hourCycle:"h23",timeZoneName:De},_r={year:k,month:k,day:k,hour:k,minute:k},Yr={year:k,month:k,day:k,hour:k,minute:k,second:k},Gr={year:k,month:qe,day:k,hour:k,minute:k},Qr={year:k,month:qe,day:k,hour:k,minute:k,second:k},go={year:k,month:qe,day:k,weekday:qe,hour:k,minute:k},Jr={year:k,month:De,day:k,hour:k,minute:k,timeZoneName:qe},Kr={year:k,month:De,day:k,hour:k,minute:k,second:k,timeZoneName:qe},Xr={year:k,month:De,day:k,weekday:De,hour:k,minute:k,timeZoneName:De},ei={year:k,month:De,day:k,weekday:De,hour:k,minute:k,second:k,timeZoneName:De};class Pt{get type(){throw new Xe}get name(){throw new Xe}get ianaName(){return this.name}get isUniversal(){throw new Xe}offsetName(e,s){throw new Xe}formatOffset(e,s){throw new Xe}offset(e){throw new Xe}equals(e){throw new Xe}get isValid(){throw new Xe}}let Ts=null;class fs extends Pt{static get instance(){return Ts===null&&(Ts=new fs),Ts}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return di(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 $s=new Map;function vo(t){let e=$s.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"}),$s.set(t,e)),e}const So={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function xo(t,e){const s=t.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(s),[,r,i,a,o,u,c,d]=n;return[a,r,i,o,u,c,d]}function wo(t,e){const s=t.formatToParts(e),n=[];for(let r=0;r<s.length;r++){const{type:i,value:a}=s[r],o=So[i];i==="era"?n[o]=a:$(o)||(n[o]=parseInt(a,10))}return n}const As=new Map;class Qe extends Pt{static create(e){let s=As.get(e);return s===void 0&&As.set(e,s=new Qe(e)),s}static resetCache(){As.clear(),$s.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=Qe.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:s,locale:n}){return di(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=vo(this.name);let[r,i,a,o,u,c,d]=n.formatToParts?wo(n,s):xo(n,s);o==="BC"&&(r=-Math.abs(r)+1);const m=ys({year:r,month:i,day:a,hour:u===24?0:u,minute:c,second:d,millisecond:0});let p=+s;const v=p%1e3;return p-=v>=0?v:1e3+v,(m-p)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let Wn={};function bo(t,e={}){const s=JSON.stringify([t,e]);let n=Wn[s];return n||(n=new Intl.ListFormat(t,e),Wn[s]=n),n}const Ws=new Map;function Vs(t,e={}){const s=JSON.stringify([t,e]);let n=Ws.get(s);return n===void 0&&(n=new Intl.DateTimeFormat(t,e),Ws.set(s,n)),n}const qs=new Map;function To(t,e={}){const s=JSON.stringify([t,e]);let n=qs.get(s);return n===void 0&&(n=new Intl.NumberFormat(t,e),qs.set(s,n)),n}const Zs=new Map;function Ao(t,e={}){const{base:s,...n}=e,r=JSON.stringify([t,n]);let i=Zs.get(r);return i===void 0&&(i=new Intl.RelativeTimeFormat(t,e),Zs.set(r,i)),i}let Mt=null;function ko(){return Mt||(Mt=new Intl.DateTimeFormat().resolvedOptions().locale,Mt)}const Bs=new Map;function ti(t){let e=Bs.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Bs.set(t,e)),e}const Hs=new Map;function No(t){let e=Hs.get(t);if(!e){const s=new Intl.Locale(t);e="getWeekInfo"in s?s.getWeekInfo():s.weekInfo,"minimalDays"in e||(e={...si,...e}),Hs.set(t,e)}return e}function Io(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=Vs(t).resolvedOptions(),r=t}catch{const u=t.substring(0,s);n=Vs(u).resolvedOptions(),r=u}const{numberingSystem:i,calendar:a}=n;return[r,i,a]}}function Oo(t,e,s){return(s||e)&&(t.includes("-u-")||(t+="-u"),s&&(t+=`-ca-${s}`),e&&(t+=`-nu-${e}`)),t}function Co(t){const e=[];for(let s=1;s<=12;s++){const n=U.utc(2009,s,1);e.push(t(n))}return e}function Eo(t){const e=[];for(let s=1;s<=7;s++){const n=U.utc(2016,11,13+s);e.push(t(n))}return e}function _t(t,e,s,n){const r=t.listingMode();return r==="error"?null:r==="en"?s(e):n(e)}function Mo(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||ti(t.locale).numberingSystem==="latn"}class Do{constructor(e,s,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:i,...a}=n;if(!s||Object.keys(a).length>0){const o={useGrouping:!1,...n};n.padTo>0&&(o.minimumIntegerDigits=n.padTo),this.inf=To(e,o)}}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):cn(e,3);return ye(s,this.padTo)}}}class jo{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 a=-1*(e.offset/60),o=a>=0?`Etc/GMT+${a}`:`Etc/GMT${a}`;e.offset!==0&&Qe.create(o).valid?(r=o,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 i={...this.opts};i.timeZone=i.timeZone||r,this.dtf=Vs(s,i)}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 Ro{constructor(e,s,n){this.opts={style:"long",...n},!s&&ui()&&(this.rtf=Ao(e,n))}format(e,s){return this.rtf?this.rtf.format(e,s):sl(s,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,s){return this.rtf?this.rtf.formatToParts(e,s):[]}}const si={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,i=!1){const a=e||de.defaultLocale,o=a||(i?"en-US":ko()),u=s||de.defaultNumberingSystem,c=n||de.defaultOutputCalendar,d=_s(r)||de.defaultWeekSettings;return new se(o,u,c,d,a)}static resetCache(){Mt=null,Ws.clear(),qs.clear(),Zs.clear(),Bs.clear(),Hs.clear()}static fromObject({locale:e,numberingSystem:s,outputCalendar:n,weekSettings:r}={}){return se.create(e,s,n,r)}constructor(e,s,n,r,i){const[a,o,u]=Io(e);this.locale=a,this.numberingSystem=s||o||null,this.outputCalendar=n||u||null,this.weekSettings=r,this.intl=Oo(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=Mo(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,_s(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 _t(this,e,mi,()=>{const n=this.intl==="ja"||this.intl.startsWith("ja-");s&=!n;const r=s?{month:e,day:"numeric"}:{month:e},i=s?"format":"standalone";if(!this.monthsCache[i][e]){const a=n?o=>this.dtFormatter(o,r).format():o=>this.extract(o,r,"month");this.monthsCache[i][e]=Co(a)}return this.monthsCache[i][e]})}weekdays(e,s=!1){return _t(this,e,gi,()=>{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]=Eo(i=>this.extract(i,n,"weekday"))),this.weekdaysCache[r][e]})}meridiems(){return _t(this,void 0,()=>vi,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[U.utc(2016,11,13,9),U.utc(2016,11,13,19)].map(s=>this.extract(s,e,"dayperiod"))}return this.meridiemCache})}eras(e){return _t(this,e,Si,()=>{const s={era:e};return this.eraCache[e]||(this.eraCache[e]=[U.utc(-40,1,1),U.utc(2017,1,1)].map(n=>this.extract(n,s,"era"))),this.eraCache[e]})}extract(e,s,n){const r=this.dtFormatter(e,s),i=r.formatToParts(),a=i.find(o=>o.type.toLowerCase()===n);return a?a.value:null}numberFormatter(e={}){return new Do(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,s={}){return new jo(e,this.intl,s)}relFormatter(e={}){return new Ro(this.intl,this.isEnglish(),e)}listFormatter(e={}){return bo(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||ti(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:ci()?No(this.locale):si}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 ks=null;class Ne extends Pt{static get utcInstance(){return ks===null&&(ks=new Ne(0)),ks}static instance(e){return e===0?Ne.utcInstance:new Ne(e)}static parseSpecifier(e){if(e){const s=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(s)return new Ne(ps(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 Fo extends Pt{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 tt(t,e){if($(t)||t===null)return e;if(t instanceof Pt)return t;if(Vo(t)){const s=t.toLowerCase();return s==="default"?e:s==="local"||s==="system"?fs.instance:s==="utc"||s==="gmt"?Ne.utcInstance:Ne.parseSpecifier(s)||Qe.create(t)}else return nt(t)?Ne.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Fo(t)}const an={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},Vn={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]},Lo=an.hanidec.replace(/[\[|\]]/g,"").split("");function Po(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(an.hanidec)!==-1)e+=Lo.indexOf(t[s]);else for(const r in Vn){const[i,a]=Vn[r];n>=i&&n<=a&&(e+=n-i)}}return parseInt(e,10)}else return e}const zs=new Map;function Uo(){zs.clear()}function $e({numberingSystem:t},e=""){const s=t||"latn";let n=zs.get(s);n===void 0&&(n=new Map,zs.set(s,n));let r=n.get(e);return r===void 0&&(r=new RegExp(`${an[s]}${e}`),n.set(e,r)),r}let qn=()=>Date.now(),Zn="system",Bn=null,Hn=null,zn=null,_n=60,Yn,Gn=null;class de{static get now(){return qn}static set now(e){qn=e}static set defaultZone(e){Zn=e}static get defaultZone(){return tt(Zn,fs.instance)}static get defaultLocale(){return Bn}static set defaultLocale(e){Bn=e}static get defaultNumberingSystem(){return Hn}static set defaultNumberingSystem(e){Hn=e}static get defaultOutputCalendar(){return zn}static set defaultOutputCalendar(e){zn=e}static get defaultWeekSettings(){return Gn}static set defaultWeekSettings(e){Gn=_s(e)}static get twoDigitCutoffYear(){return _n}static set twoDigitCutoffYear(e){_n=e%100}static get throwOnInvalid(){return Yn}static set throwOnInvalid(e){Yn=e}static resetCaches(){se.resetCache(),Qe.resetCache(),U.resetCache(),Uo()}}class Ve{constructor(e,s){this.reason=e,this.explanation=s}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const ni=[0,31,59,90,120,151,181,212,243,273,304,334],ri=[0,31,60,91,121,152,182,213,244,274,305,335];function Pe(t,e){return new Ve("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function on(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 ii(t,e,s){return s+(Ut(t)?ri:ni)[e-1]}function ai(t,e){const s=Ut(t)?ri:ni,n=s.findIndex(i=>i<e),r=e-s[n];return{month:n+1,day:r}}function ln(t,e){return(t-e+7)%7+1}function os(t,e=4,s=1){const{year:n,month:r,day:i}=t,a=ii(n,r,i),o=ln(on(n,r,i),s);let u=Math.floor((a-o+14-e)/7),c;return u<1?(c=n-1,u=Lt(c,e,s)):u>Lt(n,e,s)?(c=n+1,u=1):c=n,{weekYear:c,weekNumber:u,weekday:o,...gs(t)}}function Qn(t,e=4,s=1){const{weekYear:n,weekNumber:r,weekday:i}=t,a=ln(on(n,1,e),s),o=xt(n);let u=r*7+i-a-7+e,c;u<1?(c=n-1,u+=xt(c)):u>o?(c=n+1,u-=xt(n)):c=n;const{month:d,day:f}=ai(c,u);return{year:c,month:d,day:f,...gs(t)}}function Ns(t){const{year:e,month:s,day:n}=t,r=ii(e,s,n);return{year:e,ordinal:r,...gs(t)}}function Jn(t){const{year:e,ordinal:s}=t,{month:n,day:r}=ai(e,s);return{year:e,month:n,day:r,...gs(t)}}function Kn(t,e){if(!$(t.localWeekday)||!$(t.localWeekNumber)||!$(t.localWeekYear)){if(!$(t.weekday)||!$(t.weekNumber)||!$(t.weekYear))throw new St("Cannot mix locale-based week fields with ISO-based week fields");return $(t.localWeekday)||(t.weekday=t.localWeekday),$(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),$(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 $o(t,e=4,s=1){const n=ms(t.weekYear),r=Ue(t.weekNumber,1,Lt(t.weekYear,e,s)),i=Ue(t.weekday,1,7);return n?r?i?!1:Pe("weekday",t.weekday):Pe("week",t.weekNumber):Pe("weekYear",t.weekYear)}function Wo(t){const e=ms(t.year),s=Ue(t.ordinal,1,xt(t.year));return e?s?!1:Pe("ordinal",t.ordinal):Pe("year",t.year)}function oi(t){const e=ms(t.year),s=Ue(t.month,1,12),n=Ue(t.day,1,ls(t.year,t.month));return e?s?n?!1:Pe("day",t.day):Pe("month",t.month):Pe("year",t.year)}function li(t){const{hour:e,minute:s,second:n,millisecond:r}=t,i=Ue(e,0,23)||e===24&&s===0&&n===0&&r===0,a=Ue(s,0,59),o=Ue(n,0,59),u=Ue(r,0,999);return i?a?o?u?!1:Pe("millisecond",r):Pe("second",n):Pe("minute",s):Pe("hour",e)}function $(t){return typeof t>"u"}function nt(t){return typeof t=="number"}function ms(t){return typeof t=="number"&&t%1===0}function Vo(t){return typeof t=="string"}function qo(t){return Object.prototype.toString.call(t)==="[object Date]"}function ui(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function ci(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Zo(t){return Array.isArray(t)?t:[t]}function Xn(t,e,s){if(t.length!==0)return t.reduce((n,r)=>{const i=[e(r),r];return n&&s(n[0],i[0])===n[0]?n:i},null)[1]}function Bo(t,e){return e.reduce((s,n)=>(s[n]=t[n],s),{})}function bt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function _s(t){if(t==null)return null;if(typeof t!="object")throw new be("Week settings must be an object");if(!Ue(t.firstDay,1,7)||!Ue(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!Ue(e,1,7)))throw new be("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function Ue(t,e,s){return ms(t)&&t>=e&&t<=s}function Ho(t,e){return t-e*Math.floor(t/e)}function ye(t,e=2){const s=t<0;let n;return s?n="-"+(""+-t).padStart(e,"0"):n=(""+t).padStart(e,"0"),n}function et(t){if(!($(t)||t===null||t===""))return parseInt(t,10)}function it(t){if(!($(t)||t===null||t===""))return parseFloat(t)}function un(t){if(!($(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function cn(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 Ut(t){return t%4===0&&(t%100!==0||t%400===0)}function xt(t){return Ut(t)?366:365}function ls(t,e){const s=Ho(e-1,12)+1,n=t+(e-s)/12;return s===2?Ut(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][s-1]}function ys(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 er(t,e,s){return-ln(on(t,1,e),s)+e-1}function Lt(t,e=4,s=1){const n=er(t,e,s),r=er(t+1,e,s);return(xt(t)-n+r)/7}function Ys(t){return t>99?t:t>de.twoDigitCutoffYear?1900+t:2e3+t}function di(t,e,s,n=null){const r=new Date(t),i={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};n&&(i.timeZone=n);const a={timeZoneName:e,...i},o=new Intl.DateTimeFormat(s,a).formatToParts(r).find(u=>u.type.toLowerCase()==="timezonename");return o?o.value:null}function ps(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 hi(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new be(`Invalid unit value ${t}`);return e}function us(t,e){const s={};for(const n in t)if(bt(t,n)){const r=t[n];if(r==null)continue;s[e(n)]=hi(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}${ye(s,2)}:${ye(n,2)}`;case"narrow":return`${r}${s}${n>0?`:${n}`:""}`;case"techie":return`${r}${ye(s,2)}${ye(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function gs(t){return Bo(t,["hour","minute","second","millisecond"])}const zo=["January","February","March","April","May","June","July","August","September","October","November","December"],fi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],_o=["J","F","M","A","M","J","J","A","S","O","N","D"];function mi(t){switch(t){case"narrow":return[..._o];case"short":return[...fi];case"long":return[...zo];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 yi=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],pi=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Yo=["M","T","W","T","F","S","S"];function gi(t){switch(t){case"narrow":return[...Yo];case"short":return[...pi];case"long":return[...yi];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const vi=["AM","PM"],Go=["Before Christ","Anno Domini"],Qo=["BC","AD"],Jo=["B","A"];function Si(t){switch(t){case"narrow":return[...Jo];case"short":return[...Qo];case"long":return[...Go];default:return null}}function Ko(t){return vi[t.hour<12?0:1]}function Xo(t,e){return gi(e)[t.weekday-1]}function el(t,e){return mi(e)[t.month-1]}function tl(t,e){return Si(e)[t.year<0?0:1]}function sl(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."]},i=["hours","minutes","seconds"].indexOf(t)===-1;if(s==="auto"&&i){const f=t==="days";switch(e){case 1:return f?"tomorrow":`next ${r[t][0]}`;case-1:return f?"yesterday":`last ${r[t][0]}`;case 0:return f?"today":`this ${r[t][0]}`}}const a=Object.is(e,-0)||e<0,o=Math.abs(e),u=o===1,c=r[t],d=n?u?c[1]:c[2]||c[1]:u?r[t][0]:t;return a?`${o} ${d} ago`:`in ${o} ${d}`}function tr(t,e){let s="";for(const n of t)n.literal?s+=n.val:s+=e(n.val);return s}const nl={D:as,DD:Lr,DDD:Pr,DDDD:Ur,t:$r,tt:Wr,ttt:Vr,tttt:qr,T:Zr,TT:Br,TTT:Hr,TTTT:zr,f:_r,ff:Gr,fff:Jr,ffff:Xr,F:Yr,FF:Qr,FFF:Kr,FFFF:ei};class Te{static create(e,s={}){return new Te(e,s)}static parseFormat(e){let s=null,n="",r=!1;const i=[];for(let a=0;a<e.length;a++){const o=e.charAt(a);o==="'"?((n.length>0||r)&&i.push({literal:r||/^\s+$/.test(n),val:n===""?"'":n}),s=null,n="",r=!r):r||o===s?n+=o:(n.length>0&&i.push({literal:/^\s+$/.test(n),val:n}),n=o,s=o)}return n.length>0&&i.push({literal:r||/^\s+$/.test(n),val:n}),i}static macroTokenToFormatOpts(e){return nl[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 ye(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",i=(p,v)=>this.loc.extract(e,p,v),a=p=>e.isOffsetFixed&&e.offset===0&&p.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,p.format):"",o=()=>n?Ko(e):i({hour:"numeric",hourCycle:"h12"},"dayperiod"),u=(p,v)=>n?el(e,p):i(v?{month:p}:{month:p,day:"numeric"},"month"),c=(p,v)=>n?Xo(e,p):i(v?{weekday:p}:{weekday:p,month:"long",day:"numeric"},"weekday"),d=p=>{const v=Te.macroTokenToFormatOpts(p);return v?this.formatWithSystemDefault(e,v):p},f=p=>n?tl(e,p):i({era:p},"era"),m=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 a({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return a({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return a({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 o();case"d":return r?i({day:"numeric"},"day"):this.num(e.day);case"dd":return r?i({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return c("short",!0);case"cccc":return c("long",!0);case"ccccc":return c("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return c("short",!1);case"EEEE":return c("long",!1);case"EEEEE":return c("narrow",!1);case"L":return r?i({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?i({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return u("short",!0);case"LLLL":return u("long",!0);case"LLLLL":return u("narrow",!0);case"M":return r?i({month:"numeric"},"month"):this.num(e.month);case"MM":return r?i({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return u("short",!1);case"MMMM":return u("long",!1);case"MMMMM":return u("narrow",!1);case"y":return r?i({year:"numeric"},"year"):this.num(e.year);case"yy":return r?i({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?i({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?i({year:"numeric"},"year"):this.num(e.year,6);case"G":return f("short");case"GG":return f("long");case"GGGGG":return f("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 d(p)}};return tr(Te.parseFormat(s),m)}formatDurationFromString(e,s){const n=this.opts.signMode==="negativeLargestOnly"?-1:1,r=d=>{switch(d[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}},i=(d,f)=>m=>{const p=r(m);if(p){const v=f.isNegativeDuration&&p!==f.largestUnit?n:1;let g;return this.opts.signMode==="negativeLargestOnly"&&p!==f.largestUnit?g="never":this.opts.signMode==="all"?g="always":g="auto",this.num(d.get(p)*v,m.length,g)}else return m},a=Te.parseFormat(s),o=a.reduce((d,{literal:f,val:m})=>f?d:d.concat(m),[]),u=e.shiftTo(...o.map(r).filter(d=>d)),c={isNegativeDuration:u<0,largestUnit:Object.keys(u.values)[0]};return tr(a,i(u,c))}}const xi=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function At(...t){const e=t.reduce((s,n)=>s+n.source,"");return RegExp(`^${e}$`)}function kt(...t){return e=>t.reduce(([s,n,r],i)=>{const[a,o,u]=i(e,r);return[{...s,...a},o||n,u]},[{},null,1]).slice(0,2)}function Nt(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 wi(...t){return(e,s)=>{const n={};let r;for(r=0;r<t.length;r++)n[t[r]]=et(e[s+r]);return[n,null,s+r]}}const bi=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,rl=`(?:${bi.source}?(?:\\[(${xi.source})\\])?)?`,dn=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Ti=RegExp(`${dn.source}${rl}`),hn=RegExp(`(?:[Tt]${Ti.source})?`),il=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,al=/(\d{4})-?W(\d\d)(?:-?(\d))?/,ol=/(\d{4})-?(\d{3})/,ll=wi("weekYear","weekNumber","weekDay"),ul=wi("year","ordinal"),cl=/(\d{4})-(\d\d)-(\d\d)/,Ai=RegExp(`${dn.source} ?(?:${bi.source}|(${xi.source}))?`),dl=RegExp(`(?: ${Ai.source})?`);function wt(t,e,s){const n=t[e];return $(n)?s:et(n)}function hl(t,e){return[{year:wt(t,e),month:wt(t,e+1,1),day:wt(t,e+2,1)},null,e+3]}function It(t,e){return[{hours:wt(t,e,0),minutes:wt(t,e+1,0),seconds:wt(t,e+2,0),milliseconds:un(t[e+3])},null,e+4]}function $t(t,e){const s=!t[e]&&!t[e+1],n=ps(t[e+1],t[e+2]),r=s?null:Ne.instance(n);return[{},r,e+3]}function Wt(t,e){const s=t[e]?Qe.create(t[e]):null;return[{},s,e+1]}const fl=RegExp(`^T?${dn.source}$`),ml=/^-?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 yl(t){const[e,s,n,r,i,a,o,u,c]=t,d=e[0]==="-",f=u&&u[0]==="-",m=(p,v=!1)=>p!==void 0&&(v||p&&d)?-p:p;return[{years:m(it(s)),months:m(it(n)),weeks:m(it(r)),days:m(it(i)),hours:m(it(a)),minutes:m(it(o)),seconds:m(it(u),u==="-0"),milliseconds:m(un(c),f)}]}const pl={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function fn(t,e,s,n,r,i,a){const o={year:e.length===2?Ys(et(e)):et(e),month:fi.indexOf(s)+1,day:et(n),hour:et(r),minute:et(i)};return a&&(o.second=et(a)),t&&(o.weekday=t.length>3?yi.indexOf(t)+1:pi.indexOf(t)+1),o}const gl=/^(?:(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 vl(t){const[,e,s,n,r,i,a,o,u,c,d,f]=t,m=fn(e,r,n,s,i,a,o);let p;return u?p=pl[u]:c?p=0:p=ps(d,f),[m,new Ne(p)]}function Sl(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const xl=/^(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$/,wl=/^(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$/,bl=/^(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 sr(t){const[,e,s,n,r,i,a,o]=t;return[fn(e,r,n,s,i,a,o),Ne.utcInstance]}function Tl(t){const[,e,s,n,r,i,a,o]=t;return[fn(e,o,s,n,r,i,a),Ne.utcInstance]}const Al=At(il,hn),kl=At(al,hn),Nl=At(ol,hn),Il=At(Ti),ki=kt(hl,It,$t,Wt),Ol=kt(ll,It,$t,Wt),Cl=kt(ul,It,$t,Wt),El=kt(It,$t,Wt);function Ml(t){return Nt(t,[Al,ki],[kl,Ol],[Nl,Cl],[Il,El])}function Dl(t){return Nt(Sl(t),[gl,vl])}function jl(t){return Nt(t,[xl,sr],[wl,sr],[bl,Tl])}function Rl(t){return Nt(t,[ml,yl])}const Fl=kt(It);function Ll(t){return Nt(t,[fl,Fl])}const Pl=At(cl,dl),Ul=At(Ai),$l=kt(It,$t,Wt);function Wl(t){return Nt(t,[Pl,ki],[Ul,$l])}const nr="Invalid Duration",Ni={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}},Vl={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},...Ni},Fe=146097/400,yt=146097/4800,ql={years:{quarters:4,months:12,weeks:Fe/7,days:Fe,hours:Fe*24,minutes:Fe*24*60,seconds:Fe*24*60*60,milliseconds:Fe*24*60*60*1e3},quarters:{months:3,weeks:Fe/28,days:Fe/4,hours:Fe*24/4,minutes:Fe*24*60/4,seconds:Fe*24*60*60/4,milliseconds:Fe*24*60*60*1e3/4},months:{weeks:yt/7,days:yt,hours:yt*24,minutes:yt*24*60,seconds:yt*24*60*60,milliseconds:yt*24*60*60*1e3},...Ni},lt=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Zl=lt.slice(0).reverse();function Ye(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 Ii(t,e){let s=e.milliseconds??0;for(const n of Zl.slice(1))e[n]&&(s+=e[n]*t[n].milliseconds);return s}function rr(t,e){const s=Ii(t,e)<0?-1:1;lt.reduceRight((n,r)=>{if($(e[r]))return n;if(n){const i=e[n]*s,a=t[r][n],o=Math.floor(i/a);e[r]+=o*s,e[n]-=o*a*s}return r},null),lt.reduce((n,r)=>{if($(e[r]))return n;if(n){const i=e[n]%1;e[n]-=i,e[r]+=i*t[n][r]}return r},null)}function ir(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?ql:Vl;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:us(e,X.normalizeUnit),loc:se.fromObject(s),conversionAccuracy:s.conversionAccuracy,matrix:s.matrix})}static fromDurationLike(e){if(nt(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]=Rl(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]=Ll(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 Ve?e:new Ve(e,s);if(de.throwOnInvalid)throw new yo(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 Fr(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?Te.create(this.loc,n).formatDurationFromString(this,e):nr}toHuman(e={}){if(!this.isValid)return nr;const s=e.showZeros!==!1,n=lt.map(r=>{const i=this.values[r];return $(i)||i===0&&!s?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(i)}).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+=cn(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},U.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?Ii(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)(bt(s.values,r)||bt(this.values,r))&&(n[r]=s.get(r)+this.get(r));return Ye(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]=hi(e(this.values[n],n));return Ye(this,{values:s},!0)}get(e){return this[X.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const s={...this.values,...us(e,X.normalizeUnit)};return Ye(this,{values:s})}reconfigure({locale:e,numberingSystem:s,conversionAccuracy:n,matrix:r}={}){const a={loc:this.loc.clone({locale:e,numberingSystem:s}),matrix:r,conversionAccuracy:n};return Ye(this,a)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return rr(this.matrix,e),Ye(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=ir(this.normalize().shiftToAll().toObject());return Ye(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(a=>X.normalizeUnit(a));const s={},n={},r=this.toObject();let i;for(const a of lt)if(e.indexOf(a)>=0){i=a;let o=0;for(const c in n)o+=this.matrix[c][a]*n[c],n[c]=0;nt(r[a])&&(o+=r[a]);const u=Math.trunc(o);s[a]=u,n[a]=(o*1e3-u*1e3)/1e3}else nt(r[a])&&(n[a]=r[a]);for(const a in n)n[a]!==0&&(s[i]+=a===i?n[a]:n[a]/this.matrix[i][a]);return rr(this.matrix,s),Ye(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 Ye(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=ir(this.values);return Ye(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 pt="Invalid Interval";function Bl(t,e){return!t||!t.isValid?ce.invalid("missing or invalid start"):!e||!e.isValid?ce.invalid("missing or invalid end"):e<t?ce.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 ce{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 Ve?e:new Ve(e,s);if(de.throwOnInvalid)throw new mo(n);return new ce({invalid:n})}static fromDateTimes(e,s){const n=Et(e),r=Et(s),i=Bl(n,r);return i??new ce({start:n,end:r})}static after(e,s){const n=X.fromDurationLike(s),r=Et(e);return ce.fromDateTimes(r,r.plus(n))}static before(e,s){const n=X.fromDurationLike(s),r=Et(e);return ce.fromDateTimes(r.minus(n),r)}static fromISO(e,s){const[n,r]=(e||"").split("/",2);if(n&&r){let i,a;try{i=U.fromISO(n,s),a=i.isValid}catch{a=!1}let o,u;try{o=U.fromISO(r,s),u=o.isValid}catch{u=!1}if(a&&u)return ce.fromDateTimes(i,o);if(a){const c=X.fromISO(r,s);if(c.isValid)return ce.after(i,c)}else if(u){const c=X.fromISO(n,s);if(c.isValid)return ce.before(o,c)}}return ce.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?ce.fromDateTimes(e||this.s,s||this.e):this}splitAt(...e){if(!this.isValid)return[];const s=e.map(Et).filter(a=>this.contains(a)).sort((a,o)=>a.toMillis()-o.toMillis()),n=[];let{s:r}=this,i=0;for(;r<this.e;){const a=s[i]||this.e,o=+a>+this.e?this.e:a;n.push(ce.fromDateTimes(r,o)),r=o,i+=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,i;const a=[];for(;n<this.e;){const o=this.start.plus(s.mapUnits(u=>u*r));i=+o>+this.e?this.e:o,a.push(ce.fromDateTimes(n,i)),n=i,r+=1}return a}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:ce.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 ce.fromDateTimes(s,n)}static merge(e){const[s,n]=e.sort((r,i)=>r.s-i.s).reduce(([r,i],a)=>i?i.overlaps(a)||i.abutsStart(a)?[r,i.union(a)]:[r.concat([i]),a]:[r,a],[[],null]);return n&&s.push(n),s}static xor(e){let s=null,n=0;const r=[],i=e.map(u=>[{time:u.s,type:"s"},{time:u.e,type:"e"}]),a=Array.prototype.concat(...i),o=a.sort((u,c)=>u.time-c.time);for(const u of o)n+=u.type==="s"?1:-1,n===1?s=u.time:(s&&+s!=+u.time&&r.push(ce.fromDateTimes(s,u.time)),s=null);return ce.merge(r)}difference(...e){return ce.xor([this].concat(e)).map(s=>this.intersection(s)).filter(s=>s&&!s.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:pt}[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=as,s={}){return this.isValid?Te.create(this.s.loc.clone(s),e).formatInterval(this):pt}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:pt}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:pt}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:pt}toFormat(e,{separator:s=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${s}${this.e.toFormat(e)}`:pt}toDuration(e,s){return this.isValid?this.e.diff(this.s,e,s):X.invalid(this.invalidReason)}mapEndpoints(e){return ce.fromDateTimes(e(this.s),e(this.e))}}class Yt{static hasDST(e=de.defaultZone){const s=U.now().setZone(e).set({month:12});return!e.isUniversal&&s.offset!==s.set({month:6}).offset}static isValidIANAZone(e){return Qe.isValidZone(e)}static normalizeZone(e){return tt(e,de.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:i="gregory"}={}){return(r||se.create(s,n,i)).months(e)}static monthsFormat(e="long",{locale:s=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||se.create(s,n,i)).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:ui(),localeWeek:ci()}}}function ar(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 Hl(t,e,s){const n=[["years",(u,c)=>c.year-u.year],["quarters",(u,c)=>c.quarter-u.quarter+(c.year-u.year)*4],["months",(u,c)=>c.month-u.month+(c.year-u.year)*12],["weeks",(u,c)=>{const d=ar(u,c);return(d-d%7)/7}],["days",ar]],r={},i=t;let a,o;for(const[u,c]of n)s.indexOf(u)>=0&&(a=u,r[u]=c(t,e),o=i.plus(r),o>e?(r[u]--,t=i.plus(r),t>e&&(o=t,r[u]--,t=i.plus(r))):t=o);return[t,r,o,a]}function zl(t,e,s,n){let[r,i,a,o]=Hl(t,e,s);const u=e-r,c=s.filter(f=>["hours","minutes","seconds","milliseconds"].indexOf(f)>=0);c.length===0&&(a<e&&(a=r.plus({[o]:1})),a!==r&&(i[o]=(i[o]||0)+u/(a-r)));const d=X.fromObject(i,n);return c.length>0?X.fromMillis(u,n).shiftTo(...c).plus(d):d}const _l="missing Intl.DateTimeFormat.formatToParts support";function ee(t,e=s=>s){return{regex:t,deser:([s])=>e(Po(s))}}const Yl=" ",Oi=`[ ${Yl}]`,Ci=new RegExp(Oi,"g");function Gl(t){return t.replace(/\./g,"\\.?").replace(Ci,Oi)}function or(t){return t.replace(/\./g,"").replace(Ci," ").toLowerCase()}function We(t,e){return t===null?null:{regex:RegExp(t.map(Gl).join("|")),deser:([s])=>t.findIndex(n=>or(s)===or(n))+e}}function lr(t,e){return{regex:t,deser:([,s,n])=>ps(s,n),groups:e}}function Gt(t){return{regex:t,deser:([e])=>e}}function Ql(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Jl(t,e){const s=$e(e),n=$e(e,"{2}"),r=$e(e,"{3}"),i=$e(e,"{4}"),a=$e(e,"{6}"),o=$e(e,"{1,2}"),u=$e(e,"{1,3}"),c=$e(e,"{1,6}"),d=$e(e,"{1,9}"),f=$e(e,"{2,4}"),m=$e(e,"{4,6}"),p=S=>({regex:RegExp(Ql(S.val)),deser:([P])=>P,literal:!0}),g=(S=>{if(t.literal)return p(S);switch(S.val){case"G":return We(e.eras("short"),0);case"GG":return We(e.eras("long"),0);case"y":return ee(c);case"yy":return ee(f,Ys);case"yyyy":return ee(i);case"yyyyy":return ee(m);case"yyyyyy":return ee(a);case"M":return ee(o);case"MM":return ee(n);case"MMM":return We(e.months("short",!0),1);case"MMMM":return We(e.months("long",!0),1);case"L":return ee(o);case"LL":return ee(n);case"LLL":return We(e.months("short",!1),1);case"LLLL":return We(e.months("long",!1),1);case"d":return ee(o);case"dd":return ee(n);case"o":return ee(u);case"ooo":return ee(r);case"HH":return ee(n);case"H":return ee(o);case"hh":return ee(n);case"h":return ee(o);case"mm":return ee(n);case"m":return ee(o);case"q":return ee(o);case"qq":return ee(n);case"s":return ee(o);case"ss":return ee(n);case"S":return ee(u);case"SSS":return ee(r);case"u":return Gt(d);case"uu":return Gt(o);case"uuu":return ee(s);case"a":return We(e.meridiems(),0);case"kkkk":return ee(i);case"kk":return ee(f,Ys);case"W":return ee(o);case"WW":return ee(n);case"E":case"c":return ee(s);case"EEE":return We(e.weekdays("short",!1),1);case"EEEE":return We(e.weekdays("long",!1),1);case"ccc":return We(e.weekdays("short",!0),1);case"cccc":return We(e.weekdays("long",!0),1);case"Z":case"ZZ":return lr(new RegExp(`([+-]${o.source})(?::(${n.source}))?`),2);case"ZZZ":return lr(new RegExp(`([+-]${o.source})(${n.source})?`),2);case"z":return Gt(/[a-z_+-/]{1,256}?/i);case" ":return Gt(/[^\S\n\r]/);default:return p(S)}})(t)||{invalidReason:_l};return g.token=t,g}const Kl={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 Xl(t,e,s){const{type:n,value:r}=t;if(n==="literal"){const u=/^\s+$/.test(r);return{literal:!u,val:u?" ":r}}const i=e[n];let a=n;n==="hour"&&(e.hour12!=null?a=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?a="hour12":a="hour24":a=s.hour12?"hour12":"hour24");let o=Kl[a];if(typeof o=="object"&&(o=o[i]),o)return{literal:!1,val:o}}function eu(t){return[`^${t.map(s=>s.regex).reduce((s,n)=>`${s}(${n.source})`,"")}$`,t]}function tu(t,e,s){const n=t.match(e);if(n){const r={};let i=1;for(const a in s)if(bt(s,a)){const o=s[a],u=o.groups?o.groups+1:1;!o.literal&&o.token&&(r[o.token.val[0]]=o.deser(n.slice(i,i+u))),i+=u}return[n,r]}else return[n,{}]}function su(t){const e=i=>{switch(i){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 $(t.z)||(s=Qe.create(t.z)),$(t.Z)||(s||(s=new Ne(t.Z)),n=t.Z),$(t.q)||(t.M=(t.q-1)*3+1),$(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),$(t.u)||(t.S=un(t.u)),[Object.keys(t).reduce((i,a)=>{const o=e(a);return o&&(i[o]=t[a]),i},{}),s,n]}let Is=null;function nu(){return Is||(Is=U.fromMillis(1555555555555)),Is}function ru(t,e){if(t.literal)return t;const s=Te.macroTokenToFormatOpts(t.val),n=ji(s,e);return n==null||n.includes(void 0)?t:n}function Ei(t,e){return Array.prototype.concat(...t.map(s=>ru(s,e)))}class Mi{constructor(e,s){if(this.locale=e,this.format=s,this.tokens=Ei(Te.parseFormat(s),e),this.units=this.tokens.map(n=>Jl(n,e)),this.disqualifyingUnit=this.units.find(n=>n.invalidReason),!this.disqualifyingUnit){const[n,r]=eu(this.units);this.regex=RegExp(n,"i"),this.handlers=r}}explainFromTokens(e){if(this.isValid){const[s,n]=tu(e,this.regex,this.handlers),[r,i,a]=n?su(n):[null,null,void 0];if(bt(n,"a")&&bt(n,"H"))throw new St("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:i,specificOffset:a}}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 Di(t,e,s){return new Mi(t,s).explainFromTokens(e)}function iu(t,e,s){const{result:n,zone:r,specificOffset:i,invalidReason:a}=Di(t,e,s);return[n,r,i,a]}function ji(t,e){if(!t)return null;const n=Te.create(e,t).dtFormatter(nu()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(a=>Xl(a,t,i))}const Os="Invalid DateTime",ur=864e13;function Dt(t){return new Ve("unsupported zone",`the zone "${t.name}" is not supported`)}function Cs(t){return t.weekData===null&&(t.weekData=os(t.c)),t.weekData}function Es(t){return t.localWeekData===null&&(t.localWeekData=os(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function at(t,e){const s={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new U({...s,...e,old:s})}function Ri(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 i=s.offset(n);return r===i?[n,r]:[t-Math.min(r,i)*60*1e3,Math.max(r,i)]}function Qt(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 es(t,e,s){return Ri(ys(t),e,s)}function cr(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,i={...t.c,year:n,month:r,day:Math.min(t.c.day,ls(n,r))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},a=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"),o=ys(i);let[u,c]=Ri(o,s,t.zone);return a!==0&&(u+=a,c=t.zone.offset(u)),{ts:u,o:c}}function gt(t,e,s,n,r,i){const{setZone:a,zone:o}=s;if(t&&Object.keys(t).length!==0||e){const u=e||o,c=U.fromObject(t,{...s,zone:u,specificOffset:i});return a?c:c.setZone(o)}else return U.invalid(new Ve("unparsable",`the input "${r}" can't be parsed as ${n}`))}function Jt(t,e,s=!0){return t.isValid?Te.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+=ye(t.c.year,n?6:4),s==="year")return r;if(e){if(r+="-",r+=ye(t.c.month),s==="month")return r;r+="-"}else if(r+=ye(t.c.month),s==="month")return r;return r+=ye(t.c.day),r}function dr(t,e,s,n,r,i,a){let o=!s||t.c.millisecond!==0||t.c.second!==0,u="";switch(a){case"day":case"month":case"year":break;default:if(u+=ye(t.c.hour),a==="hour")break;if(e){if(u+=":",u+=ye(t.c.minute),a==="minute")break;o&&(u+=":",u+=ye(t.c.second))}else{if(u+=ye(t.c.minute),a==="minute")break;o&&(u+=ye(t.c.second))}if(a==="second")break;o&&(!n||t.c.millisecond!==0)&&(u+=".",u+=ye(t.c.millisecond,3))}return r&&(t.isOffsetFixed&&t.offset===0&&!i?u+="Z":t.o<0?(u+="-",u+=ye(Math.trunc(-t.o/60)),u+=":",u+=ye(Math.trunc(-t.o%60))):(u+="+",u+=ye(Math.trunc(t.o/60)),u+=":",u+=ye(Math.trunc(t.o%60)))),i&&(u+="["+t.zone.ianaName+"]"),u}const Fi={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},au={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},ou={ordinal:1,hour:0,minute:0,second:0,millisecond:0},ts=["year","month","day","hour","minute","second","millisecond"],lu=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],uu=["year","ordinal","hour","minute","second","millisecond"];function ss(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 Fr(t);return e}function hr(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return ss(t)}}function cu(t){if(jt===void 0&&(jt=de.now()),t.type!=="iana")return t.offset(jt);const e=t.name;let s=Gs.get(e);return s===void 0&&(s=t.offset(jt),Gs.set(e,s)),s}function fr(t,e){const s=tt(e.zone,de.defaultZone);if(!s.isValid)return U.invalid(Dt(s));const n=se.fromObject(e);let r,i;if($(t.year))r=de.now();else{for(const u of ts)$(t[u])&&(t[u]=Fi[u]);const a=oi(t)||li(t);if(a)return U.invalid(a);const o=cu(s);[r,i]=es(t,o,s)}return new U({ts:r,zone:s,loc:n,o:i})}function mr(t,e,s){const n=$(s.round)?!0:s.round,r=$(s.rounding)?"trunc":s.rounding,i=(o,u)=>(o=cn(o,n||s.calendary?0:2,s.calendary?"round":r),e.loc.clone(s).relFormatter(s).format(o,u)),a=o=>s.calendary?e.hasSame(t,o)?0:e.startOf(o).diff(t.startOf(o),o).get(o):e.diff(t,o).get(o);if(s.unit)return i(a(s.unit),s.unit);for(const o of s.units){const u=a(o);if(Math.abs(u)>=1)return i(u,o)}return i(t>e?-0:0,s.units[s.units.length-1])}function yr(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 jt;const Gs=new Map;class U{constructor(e){const s=e.zone||de.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Ve("invalid input"):null)||(s.isValid?null:Dt(s));this.ts=$(e.ts)?de.now():e.ts;let r=null,i=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(s))[r,i]=[e.old.c,e.old.o];else{const o=nt(e.o)&&!e.old?e.o:s.offset(this.ts);r=Qt(this.ts,o),n=Number.isNaN(r.year)?new Ve("invalid input"):null,r=n?null:r,i=n?null:o}this._zone=s,this.loc=e.loc||se.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}static now(){return new U({})}static local(){const[e,s]=yr(arguments),[n,r,i,a,o,u,c]=s;return fr({year:n,month:r,day:i,hour:a,minute:o,second:u,millisecond:c},e)}static utc(){const[e,s]=yr(arguments),[n,r,i,a,o,u,c]=s;return e.zone=Ne.utcInstance,fr({year:n,month:r,day:i,hour:a,minute:o,second:u,millisecond:c},e)}static fromJSDate(e,s={}){const n=qo(e)?e.valueOf():NaN;if(Number.isNaN(n))return U.invalid("invalid input");const r=tt(s.zone,de.defaultZone);return r.isValid?new U({ts:n,zone:r,loc:se.fromObject(s)}):U.invalid(Dt(r))}static fromMillis(e,s={}){if(nt(e))return e<-ur||e>ur?U.invalid("Timestamp out of range"):new U({ts:e,zone:tt(s.zone,de.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(nt(e))return new U({ts:e*1e3,zone:tt(s.zone,de.defaultZone),loc:se.fromObject(s)});throw new be("fromSeconds requires a numerical input")}static fromObject(e,s={}){e=e||{};const n=tt(s.zone,de.defaultZone);if(!n.isValid)return U.invalid(Dt(n));const r=se.fromObject(s),i=us(e,hr),{minDaysInFirstWeek:a,startOfWeek:o}=Kn(i,r),u=de.now(),c=$(s.specificOffset)?n.offset(u):s.specificOffset,d=!$(i.ordinal),f=!$(i.year),m=!$(i.month)||!$(i.day),p=f||m,v=i.weekYear||i.weekNumber;if((p||d)&&v)throw new St("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(m&&d)throw new St("Can't mix ordinal dates with month/day");const g=v||i.weekday&&!p;let S,P,D=Qt(u,c);g?(S=lu,P=au,D=os(D,a,o)):d?(S=uu,P=ou,D=Ns(D)):(S=ts,P=Fi);let V=!1;for(const N of S){const C=i[N];$(C)?V?i[N]=P[N]:i[N]=D[N]:V=!0}const F=g?$o(i,a,o):d?Wo(i):oi(i),z=F||li(i);if(z)return U.invalid(z);const Q=g?Qn(i,a,o):d?Jn(i):i,[J,K]=es(Q,c,n),I=new U({ts:J,zone:n,o:K,loc:r});return i.weekday&&p&&e.weekday!==I.weekday?U.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${I.toISO()}`):I.isValid?I:U.invalid(I.invalid)}static fromISO(e,s={}){const[n,r]=Ml(e);return gt(n,r,s,"ISO 8601",e)}static fromRFC2822(e,s={}){const[n,r]=Dl(e);return gt(n,r,s,"RFC 2822",e)}static fromHTTP(e,s={}){const[n,r]=jl(e);return gt(n,r,s,"HTTP",s)}static fromFormat(e,s,n={}){if($(e)||$(s))throw new be("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:i=null}=n,a=se.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),[o,u,c,d]=iu(a,e,s);return d?U.invalid(d):gt(o,u,n,`format ${s}`,e,c)}static fromString(e,s,n={}){return U.fromFormat(e,s,n)}static fromSQL(e,s={}){const[n,r]=Wl(e);return gt(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 Ve?e:new Ve(e,s);if(de.throwOnInvalid)throw new fo(n);return new U({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,s={}){const n=ji(e,se.fromObject(s));return n?n.map(r=>r?r.val:null).join(""):null}static expandFormat(e,s={}){return Ei(Te.parseFormat(e),se.fromObject(s)).map(r=>r.val).join("")}static resetCache(){jt=void 0,Gs.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?Cs(this).weekYear:NaN}get weekNumber(){return this.isValid?Cs(this).weekNumber:NaN}get weekday(){return this.isValid?Cs(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?Yt.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Yt.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Yt.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Yt.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=ys(this.c),r=this.zone.offset(n-e),i=this.zone.offset(n+e),a=this.zone.offset(n-r*s),o=this.zone.offset(n-i*s);if(a===o)return[this];const u=n-a*s,c=n-o*s,d=Qt(u,a),f=Qt(c,o);return d.hour===f.hour&&d.minute===f.minute&&d.second===f.second&&d.millisecond===f.millisecond?[at(this,{ts:u}),at(this,{ts:c})]:[this]}get isInLeapYear(){return Ut(this.year)}get daysInMonth(){return ls(this.year,this.month)}get daysInYear(){return this.isValid?xt(this.year):NaN}get weeksInWeekYear(){return this.isValid?Lt(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Lt(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:s,numberingSystem:n,calendar:r}=Te.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:s,numberingSystem:n,outputCalendar:r}}toUTC(e=0,s={}){return this.setZone(Ne.instance(e),s)}toLocal(){return this.setZone(de.defaultZone)}setZone(e,{keepLocalTime:s=!1,keepCalendarTime:n=!1}={}){if(e=tt(e,de.defaultZone),e.equals(this.zone))return this;if(e.isValid){let r=this.ts;if(s||n){const i=e.offset(this.ts),a=this.toObject();[r]=es(a,i,e)}return at(this,{ts:r,zone:e})}else return U.invalid(Dt(e))}reconfigure({locale:e,numberingSystem:s,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:s,outputCalendar:n});return at(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const s=us(e,hr),{minDaysInFirstWeek:n,startOfWeek:r}=Kn(s,this.loc),i=!$(s.weekYear)||!$(s.weekNumber)||!$(s.weekday),a=!$(s.ordinal),o=!$(s.year),u=!$(s.month)||!$(s.day),c=o||u,d=s.weekYear||s.weekNumber;if((c||a)&&d)throw new St("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(u&&a)throw new St("Can't mix ordinal dates with month/day");let f;i?f=Qn({...os(this.c,n,r),...s},n,r):$(s.ordinal)?(f={...this.toObject(),...s},$(s.day)&&(f.day=Math.min(ls(f.year,f.month),f.day))):f=Jn({...Ns(this.c),...s});const[m,p]=es(f,this.o,this.zone);return at(this,{ts:m,o:p})}plus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e);return at(this,cr(this,s))}minus(e){if(!this.isValid)return this;const s=X.fromDurationLike(e).negate();return at(this,cr(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 i=this.loc.getStartOfWeek(),{weekday:a}=this;a<i&&(n.weekNumber=this.weekNumber-1),n.weekday=i}else n.weekday=1;if(r==="quarters"){const i=Math.ceil(this.month/3);n.month=(i-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?Te.create(this.loc.redefaultToEN(s)).formatDateTimeFromString(this,e):Os}toLocaleString(e=as,s={}){return this.isValid?Te.create(this.loc.clone(s),e).formatDateTime(this):Os}toLocaleParts(e={}){return this.isValid?Te.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:s=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:i=!1,precision:a="milliseconds"}={}){if(!this.isValid)return null;a=ss(a);const o=e==="extended";let u=Ms(this,o,a);return ts.indexOf(a)>=3&&(u+="T"),u+=dr(this,o,s,n,r,i,a),u}toISODate({format:e="extended",precision:s="day"}={}){return this.isValid?Ms(this,e==="extended",ss(s)):null}toISOWeekDate(){return Jt(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:s=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:i=!1,format:a="extended",precision:o="milliseconds"}={}){return this.isValid?(o=ss(o),(r&&ts.indexOf(o)>=3?"T":"")+dr(this,a==="extended",s,e,n,i,o)):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():Os}[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},i=Zo(s).map(X.normalizeUnit),a=e.valueOf()>this.valueOf(),o=a?this:e,u=a?e:this,c=zl(o,u,i,r);return a?c.negate():c}diffNow(e="milliseconds",s={}){return this.diff(U.now(),e,s)}until(e){return this.isValid?ce.fromDateTimes(this,e):this}hasSame(e,s,n){if(!this.isValid)return!1;const r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(s,n)<=r&&r<=i.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||U.fromObject({},{zone:this.zone}),n=e.padding?this<s?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],i=e.unit;return Array.isArray(e.unit)&&(r=e.unit,i=void 0),mr(s,this.plus(n),{...e,numeric:"always",units:r,unit:i})}toRelativeCalendar(e={}){return this.isValid?mr(e.base||U.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(U.isDateTime))throw new be("min requires all arguments be DateTimes");return Xn(e,s=>s.valueOf(),Math.min)}static max(...e){if(!e.every(U.isDateTime))throw new be("max requires all arguments be DateTimes");return Xn(e,s=>s.valueOf(),Math.max)}static fromFormatExplain(e,s,n={}){const{locale:r=null,numberingSystem:i=null}=n,a=se.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0});return Di(a,e,s)}static fromStringExplain(e,s,n={}){return U.fromFormatExplain(e,s,n)}static buildFormatParser(e,s={}){const{locale:n=null,numberingSystem:r=null}=s,i=se.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new Mi(i,e)}static fromFormatParser(e,s,n={}){if($(e)||$(s))throw new be("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:i=null}=n,a=se.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0});if(!a.equals(s.locale))throw new be(`fromFormatParser called with a locale of ${a}, but the format parser was created for ${s.locale}`);const{result:o,zone:u,specificOffset:c,invalidReason:d}=s.explainFromTokens(e);return d?U.invalid(d):gt(o,u,n,`format ${s.format}`,e,c)}static get DATE_SHORT(){return as}static get DATE_MED(){return Lr}static get DATE_MED_WITH_WEEKDAY(){return po}static get DATE_FULL(){return Pr}static get DATE_HUGE(){return Ur}static get TIME_SIMPLE(){return $r}static get TIME_WITH_SECONDS(){return Wr}static get TIME_WITH_SHORT_OFFSET(){return Vr}static get TIME_WITH_LONG_OFFSET(){return qr}static get TIME_24_SIMPLE(){return Zr}static get TIME_24_WITH_SECONDS(){return Br}static get TIME_24_WITH_SHORT_OFFSET(){return Hr}static get TIME_24_WITH_LONG_OFFSET(){return zr}static get DATETIME_SHORT(){return _r}static get DATETIME_SHORT_WITH_SECONDS(){return Yr}static get DATETIME_MED(){return Gr}static get DATETIME_MED_WITH_SECONDS(){return Qr}static get DATETIME_MED_WITH_WEEKDAY(){return go}static get DATETIME_FULL(){return Jr}static get DATETIME_FULL_WITH_SECONDS(){return Kr}static get DATETIME_HUGE(){return Xr}static get DATETIME_HUGE_WITH_SECONDS(){return ei}}function Et(t){if(U.isDateTime(t))return t;if(t&&t.valueOf&&nt(t.valueOf()))return U.fromJSDate(t);if(t&&typeof t=="object")return U.fromObject(t);throw new be(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function du(t,e){return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:e})}function hu(t,e){try{const s=U.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 fu(t){if(!t)return"-";try{const e=new Date(t),s=c=>String(c).padStart(2,"0"),n=s(e.getMonth()+1),r=s(e.getDate()),i=e.getFullYear(),a=s(e.getHours()),o=s(e.getMinutes()),u=s(e.getSeconds());return`${n}/${r}/${i} ${a}:${o}:${u}`}catch{return"-"}}function cs(t,e="UTC"){if(!t)return"-";const s=U.fromISO(t,{zone:"utc"}).setZone(e);if(!s.isValid)return"-";const n=s.offsetNameShort,r=s.toFormat("ZZZZ"),i=n.startsWith("GMT")||n===r?r:`${n}/${r}`;return`${s.toFormat("MM/dd/yyyy, hh:mm:ss a")} (${i})`}const mu={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},yu={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function Li({alerts:t,loading:e=!1,pageSize:s=10,severityOptions:n,anomalyOptions:r,spaceOptions:i,onAlertIdClick:a}){const o=rn(),u=["completed","false positive"],c=async m=>{try{const p=await o.mutateAsync({alertUniqueId:m.alertId??m.id,alertId:m.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(p?.responseStatus){const v=p?.data||"Alert reopened successfully.";Ie.toast.success(v)}else{const v=p?.errorMessage||"Failed to reopen alert";Ie.toast.error(v)}}catch{Ie.toast.error("Failed to reopen alert. Please try again.")}},d=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:m=>l.jsx(h.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${mu[m]}`,backgroundColor:yu[String(m)]},children:m})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:m=>fu(m)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(m,p)=>l.jsxs("div",{children:[l.jsx("a",{onClick:v=>{v.preventDefault(),a?.(p,{sourceTab:"archived"})},className:"inline-block mb-1 text-blue-600",children:p.alertNumber}),l.jsx("div",{className:"text-black/65",children:m})]})},{title:"",key:"menu",width:60,align:"right",render:(m,p)=>l.jsx(h.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:v})=>{v==="reopen"&&c(p)}},children:l.jsx(h.Button,{type:"text",icon:l.jsx(ut.MoreOutlined,{})})})}],f=(t||[]).filter(m=>u.includes((m.statusType||"").toLowerCase()));return l.jsx(Ks,{data:f,loading:e,pageSize:s,columns:d,severityOptions:n,anomalyOptions:r,spaceOptions:i,renderActions:void 0,onAlertIdClick:a,excludeCompleted:!1})}function pu({size:t=120,time:e,timeZone:s="America/New_York"}){const{hours:n,minutes:r,seconds:i}=y.useMemo(()=>{const f=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(e);return{hours:parseInt(f.find(m=>m.type==="hour")?.value||"0",10),minutes:parseInt(f.find(m=>m.type==="minute")?.value||"0",10),seconds:parseInt(f.find(m=>m.type==="second")?.value||"0",10)}},[e,s]),a=i*6,o=r*6+i*.1,u=n%12*30+r*.5,c=t/2;return l.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((d,f)=>{const m=f*30,p=6,v=c-4,g=v-p,S=(m-90)*(Math.PI/180),P=c+g*Math.cos(S),D=c+g*Math.sin(S),V=c+v*Math.cos(S),F=c+v*Math.sin(S);return l.jsx("svg",{className:"absolute inset-0",width:t,height:t,children:l.jsx("line",{x1:P,y1:D,x2:V,y2:F,stroke:"#9CA3AF",strokeWidth:f%3===0?2:1,strokeLinecap:"round"})},f)}),l.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${u}deg)`},children:l.jsx("line",{x1:c,y1:c,x2:c,y2:c-t*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),l.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${o}deg)`},children:l.jsx("line",{x1:c,y1:c,x2:c,y2:c-t*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),l.jsx("svg",{className:"absolute inset-0",width:t,height:t,style:{transform:`rotate(${a}deg)`},children:l.jsx("line",{x1:c,y1:c+t*.08,x2:c,y2:c-t*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),l.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:c-4,top:c-4}})]})}function Pi({label:t="USA",timeZone:e="America/New_York",updateIntervalMs:s=1e3,className:n}){const[r,i]=y.useState(new Date);y.useEffect(()=>{const c=setInterval(()=>i(new Date),s);return()=>clearInterval(c)},[s]);const a=y.useMemo(()=>du(r,e),[r,e]),{abbr:o,offset:u}=y.useMemo(()=>hu(r,e),[r,e]);return l.jsxs("div",{className:`flex items-center gap-3 ${n||""}`,children:[l.jsx(pu,{time:r,timeZone:e,size:80}),l.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[l.jsx("span",{className:"uppercase",children:t}),o&&l.jsxs("span",{className:"p-2 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:[o," ",u]})]}),l.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:a})]})]})}const gu=[{SeverityId:1,Code:"LOW",DisplayName:"Low",SortOrder:10,IsActive:!0},{SeverityId:2,Code:"MEDIUM",DisplayName:"Medium",SortOrder:20,IsActive:!0},{SeverityId:3,Code:"HIGH",DisplayName:"High",SortOrder:30,IsActive:!0},{SeverityId:4,Code:"CRITICAL",DisplayName:"Critical",SortOrder:40,IsActive:!0}],vu=[{RuleId:"0938aa00-dfa7-4258-805a-67396366c776",RuleVersionId:"36d2d581-57c3-45c3-8705-8235935fdf96",Name:"License Plate Recognition",Description:"License Plate Recognition",VersionCount:1,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:3,AnomalyId:"915976ef-4eb6-4f7b-bbe6-e53862517fc9",Level:"global"},{RuleId:"2437286a-db6a-4d35-814e-9ac49f158dde",RuleVersionId:"00000000-0000-0000-0000-000000000000",Name:"Monitor And Track Onsite Vehicle timelog",Description:"Monitor And Track Onsite Vehicle timelog",VersionCount:0,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:3,AnomalyId:"9fd651ab-4312-4826-84b6-94d735894477",Level:"global"},{RuleId:"b99120ba-7a83-4ade-b5d9-a420550fe351",RuleVersionId:"d7b14dae-a7b1-474e-a357-199182c02ac3",Name:"Watchlist person detected",Description:"Watchlist person detected",VersionCount:1,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:4,AnomalyId:"bb3a3d3a-73a3-4f5a-8804-1baadbd0d412",Level:"global"},{RuleId:"ffc2c24f-adb7-4aba-ace7-f19c54e21530",RuleVersionId:"6ab3178f-bf77-4a1e-898d-1d5dbef749c5",Name:"Weapon Detection",Description:"Weapon Detection",VersionCount:1,ActionCount:0,ApplicabilityPeriodCount:0,SuppressionCount:0,AssignmentCount:0,ExclusionCount:0,IsDeleted:!1,SeverityId:4,AnomalyId:"ac82c3a2-72e6-4f9c-88fb-851a3ca3c4de",Level:"global"}],Su=[{userRoleId:1,userRoleName:"Super Admin"},{userRoleId:2,userRoleName:"Security Officer"},{userRoleId:3,userRoleName:"Security Admin"},{userRoleId:4,userRoleName:"Regulatory Officer/First Responder"},{userRoleId:5,userRoleName:"User"}],vt={severities:gu,rules:vu,userRoles:Su},{Text:xu}=h.Typography;function wu({sortBy:t,onChange:e,showActions:s,onSave:n,onClear:r,saving:i}){return l.jsxs(h.Row,{gutter:[16,16],align:"middle",children:[l.jsx(h.Col,{xs:24,md:8,lg:5,children:l.jsxs(h.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[l.jsx(xu,{className:"text-gray-600 whitespace-nowrap",children:"Sort By:"}),l.jsx(h.Select,{placeholder:"By Severity",value:t,onChange:a=>e({sortBy:a}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),l.jsx(h.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?l.jsxs(h.Space,{className:"w-full",direction:"horizontal",size:8,children:[l.jsx(h.Button,{onClick:r,disabled:i,children:"Clear"}),l.jsx(h.Button,{type:"primary",onClick:n,loading:i,children:"Save"})]}):null})]})}const{Text:Ge}=h.Typography;function bu(t){const{selectedRule:e,setSelectedRule:s,ruleOptions:n,minsOptions:r,roleOptions:i,l1mins:a,setL1mins:o,l1role:u,setL1role:c,l2mins:d,setL2mins:f,l2role:m,setL2role:p,l3mins:v,setL3mins:g,l3role:S,setL3role:P,actions:D,setActions:V,thirdPartyIds:F,setThirdPartyIds:z,humanLoop:Q,setHumanLoop:J,isAutoExpire:K,setAutoExpire:I,onClear:N,onSave:C,saving:re,onActionTypesLoaded:te}=t,{rules:M}=je(),[b,x]=y.useState([]),[O,w]=y.useState([]),[T,A]=y.useState(!1);y.useEffect(()=>{let Z=!1;return(async()=>{try{A(!0);const B=await M.getLookups();if(Z||!B||!Array.isArray(B.actionTypes))return;const oe=B.actionTypes.map(he=>({label:he.name,value:String(he.actionTypeId)}));x(oe),te&&te(B.actionTypes);const me=Array.isArray(B.thirdParties)?B.thirdParties.map(he=>({label:he.thirdPartyName,value:he.thirdPartyId})):[];w(me)}catch(B){console.error("Error loading lookups",B)}finally{Z||A(!1)}})(),()=>{Z=!0}},[]);const j=Z=>l.jsxs(h.Tag,{children:[l.jsx(ut.PlusOutlined,{})," ",Z.length," more"]}),q=typeof a=="number"||typeof u=="number"||typeof d=="number"||typeof m=="number"||typeof v=="number"||typeof S=="number"||Array.isArray(D)&&D.length>0||Array.isArray(F)&&F.length>0||!!Q||!!K,W=!!e&&q&&!re;return l.jsxs(h.Spin,{spinning:!!re||T,children:[l.jsxs(h.Row,{gutter:[16,16],align:"bottom",children:[l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),l.jsx(h.Select,{placeholder:"Rules",value:e,onChange:s,options:n,className:"w-full"})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),l.jsx(h.Col,{span:14,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:a,onChange:o,options:r})}),l.jsx(h.Col,{span:14,children:l.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:u,onChange:c,options:i})})]})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),l.jsx(h.Col,{span:14,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:d,onChange:f,options:r})}),l.jsx(h.Col,{span:14,children:l.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:m,onChange:p,options:i})})]})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),l.jsx(h.Col,{span:14,children:l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),l.jsxs(h.Row,{gutter:8,children:[l.jsx(h.Col,{span:10,children:l.jsx(h.Select,{className:"w-full",placeholder:"Mins",value:v,onChange:g,options:r})}),l.jsx(h.Col,{span:14,children:l.jsx(h.Select,{placeholder:"Escalate to",className:"w-full",value:S,onChange:P,options:i})})]})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),l.jsx(h.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:D,onChange:V,options:b,maxTagCount:1,maxTagPlaceholder:j})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,lg:4,children:l.jsxs("div",{children:[l.jsx(Ge,{className:"text-gray-700 font-medium block mb-1",children:"Third Party App"}),l.jsx(h.Select,{mode:"multiple",placeholder:"Third Party app",className:"w-full",value:F,onChange:z,options:O})]})})]}),l.jsxs(h.Row,{gutter:[16,16],align:"bottom",className:"mt-4 items-center",children:[l.jsx(h.Col,{xs:24,sm:12,md:8,lg:7,children:l.jsxs("div",{className:"flex items-center h-full gap-8",children:[l.jsx(h.Checkbox,{checked:Q,onChange:Z=>J(Z.target.checked),className:"w-full",children:"Human-In-The-Loop"}),l.jsx(h.Checkbox,{checked:K,onChange:Z=>I(Z.target.checked),className:"w-full",children:"Auto-expire in 5 minutes"})]})}),l.jsx(h.Col,{xs:24,sm:12,md:8,children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(h.Button,{onClick:N,children:"Clear"}),l.jsx(h.Button,{type:"primary",onClick:C,loading:!!re,disabled:!W,children:"Save"})]})})]})]})}function Tu({entries:t,userRoles:e,onEdit:s,loading:n}){const r=new Map(e.map(a=>[a.userRoleId,a.userRoleName])),i=a=>a.map(o=>r.get(o)||String(o)).join(", ");return l.jsx(h.Table,{rowKey:"id",dataSource:t,pagination:!1,loading:n,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(a,o)=>l.jsxs("span",{children:[o.l1.minutes?`Action taken in (${o.l1.minutes} Mins)`:"No Action taken in 0 Min",o.l1.roles?.length?`, Escalate to (${i(o.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(a,o)=>l.jsxs("span",{children:[o.l2.minutes?`Action taken in (${o.l2.minutes} Mins)`:"No Action taken in 0 Min",o.l2.roles?.length?`, Escalate to (${i(o.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(a,o)=>l.jsxs("span",{children:[o.l3.minutes?`Action taken in (${o.l3.minutes} Mins)`:"No Action taken in 0 Min",o.l3.roles?.length?`, Escalate to (${i(o.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(a,o)=>o.actions?.length?o.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(a,o)=>o.notify?.length?o.notify.join(", "):"-"},{title:"Human-In-The-Loop",key:"humanLoop",render:(a,o)=>o.humanLoop?"Yes":"No"},{title:"Auto Expire",key:"isAutoExpire",render:(a,o)=>o.isAutoExpire?"Yes":"No"},{title:"Actions",key:"ops",render:(a,o)=>l.jsx(h.Button,{type:"text",onClick:()=>s(o.id),children:l.jsx(ut.EditOutlined,{})})}]})}const{Title:Au}=h.Typography;function Ui({userRoles:t,rules:e,rawRules:s}){const{rules:n}=je(),[r,i]=y.useState(!1),[a,o]=y.useState(s),[u,c]=y.useState({}),d=y.useMemo(()=>t.map(g=>({label:g.userRoleName,value:g.userRoleId})),[t]),f=y.useMemo(()=>(e||[]).map((g,S)=>({key:g.RuleId||g.Name||String(S),ruleName:g.Name||"-",ruleDesc:g.Description||""})),[e]);y.useEffect(()=>{let g=!1;return(async()=>{try{i(!0);const S=await n.getRules();g||(o(Array.isArray(S)?S:[]),c({}))}catch{!g&&Array.isArray(s)&&o(s)}finally{g||i(!1)}})(),()=>{g=!0}},[]),y.useEffect(()=>{!a&&Array.isArray(s)&&o(s)},[s]);const m=y.useMemo(()=>{if(!Array.isArray(a)||!a.length)return{};const g={};for(const S of f){const P=a.find(V=>V?.ruleId===S.key||V?.ruleName===S.key||V?.RuleId===S.key||V?.ruleName===S.ruleName||V?.Name===S.ruleName),D=Array.isArray(P?.userRoleIds)?P.userRoleIds:[];D.length&&(g[S.key]=D)}return g},[a,f]),p=()=>{c({})},v=async()=>{try{if(!a||!Array.isArray(a)||Object.keys(u).length===0){Ie.toast.info("No changes to save");return}i(!0);const g=Object.entries(u).map(async([S,P])=>{const D=a.find(J=>J?.ruleId===S||J?.ruleName===S||J?.RuleId===S),V=typeof D?.recordId=="number"?D.recordId:void 0;if(!D||typeof V!="number")throw new Error(`Unable to find recordId for rule ${S}`);const F=Array.isArray(P)?P:[],z=F.map(J=>{const K=t.find(I=>I.userRoleId===J);return{id:J,name:K?.userRoleName??String(J)}}),Q={...D,ruleId:S,userRoleIds:F,userRoles:z,actions:[{actionTypeId:4,actionTypeUniqueId:"bc0973d4-9be0-4efb-8545-c9112ba06c1f",name:"Audible Warning",notificationType:"Alarm",category:"Hardware",description:"Test",isSystemDefined:!0,isActive:!0,displayOrder:0}]};return n.updateRule(V,Q)});await Promise.all(g),Ie.toast.success("Alert assignment saved");try{const S=await n.getRules();o(Array.isArray(S)?S:[]),c({})}catch(S){console.error("Failed to refresh rules after save",S)}}catch(g){console.error("Failed to save alert assignment",g)}finally{i(!1)}};return l.jsxs("div",{className:"w-full",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsx(Au,{level:4,className:"!mb-4",children:"Alert Assignment"})}),l.jsx(h.Table,{rowKey:"key",dataSource:f,loading:r,pagination:!1,columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(g,S)=>l.jsx(h.Select,{mode:"multiple",placeholder:"Dropdown with Multi select",className:"w-full",value:u[S.key]??m[S.key]??[],onChange:P=>c(D=>({...D,[S.key]:P})),options:d})}]}),l.jsxs(h.Space,{className:"mt-4",children:[l.jsx(h.Button,{onClick:p,disabled:r,children:"Clear"}),l.jsx(h.Button,{type:"primary",onClick:v,loading:r,disabled:r||Object.keys(u).length===0,children:"Save"})]})]})}const{Title:pr}=h.Typography;function $i({severities:t,rules:e,userRoles:s,rawRules:n,onSave:r}){const{rules:i,alerts:a}=je(),[o,u]=y.useState("By Severity"),[c,d]=y.useState("By severity"),[f,m]=y.useState("By Severity"),[p,v]=y.useState(!1),[g,S]=y.useState(!1),[P,D]=y.useState(!1),[V,F]=y.useState(null),[z,Q]=y.useState("rules"),[J,K]=y.useState(),[I,N]=y.useState(),[C,re]=y.useState(),[te,M]=y.useState(),[b,x]=y.useState(),[O,w]=y.useState(),[T,A]=y.useState(),[j,q]=y.useState(),[W,Z]=y.useState([]),[B,oe]=y.useState([]),[me,he]=y.useState(!1),[Se,le]=y.useState(!1),[pe,Ce]=y.useState({}),[Oe,ft]=y.useState({}),[xe,mt]=y.useState(s||[]),[Ot,Ct]=y.useState([]),[rt,Vt]=y.useState(!1),[E,_]=y.useState(!1),[H,we]=y.useState(n||[]);y.useEffect(()=>{n&&n.length&&we(n)},[n]),y.useEffect(()=>{if(!H||!H.length)return;const R=Object.keys(pe).length>0||Object.keys(Oe).length>0;if(Ot.length&&!R)return;const ae=H.map((Y,L)=>{const ie=e.find(Ae=>Ae.RuleId===(Y.ruleId||Y.ruleName))?.Name||Y.ruleName||Y.Name||"-",G=Y.escalationSettings||{},ue=typeof G.level1UserRoleId=="number"&&G.level1UserRoleId>0?[G.level1UserRoleId]:[],He=typeof G.level2UserRoleId=="number"&&G.level2UserRoleId>0?[G.level2UserRoleId]:[],Ss=typeof G.level3UserRoleId=="number"&&G.level3UserRoleId>0?[G.level3UserRoleId]:[],gn=(Array.isArray(G.escalationSettingsActionTypeIds)?G.escalationSettingsActionTypeIds:[]).map(Ae=>pe[Ae]||String(Ae)),Sn=(Array.isArray(G.thirdPartyId)?G.thirdPartyId:[]).map(Ae=>Oe[Ae]||String(Ae)),xs=typeof G.humanLoop=="boolean"?G.humanLoop:null,ws=typeof G.isAutoExpire=="boolean"?G.isAutoExpire:null;return{id:String(Y.ruleId||Y.ruleName||L),ruleOrSeverityLabel:ie,l1:{minutes:G.level1PostAssistTime??void 0,roles:ue},l2:{minutes:G.level2PostAssistTime??void 0,roles:He},l3:{minutes:G.level3PostAssistTime??void 0,roles:Ss},actions:gn,notify:Sn,humanLoop:xs,isAutoExpire:ws}});Ct(ae)},[H,e,pe,Oe]);const Re=y.useMemo(()=>t.map(R=>({label:R.DisplayName,value:R.SeverityId})),[t]),ne=y.useMemo(()=>e.map(R=>({label:R.Name,value:R.RuleId})),[e]),Ze=y.useMemo(()=>xe.map(R=>({label:R.userRoleName,value:R.userRoleId})),[xe]),Je=y.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(R=>({label:`${R}`,value:R})),[]);y.useEffect(()=>{let R=!1;async function ae(){try{D(!0),F(null);const Y=await a.getAdminSettings();if(!R&&Y){const L=wr(Y.sortBy);u(L),m(L),v(!1)}}catch(Y){if(!R){const L=Y instanceof Error?Y.message:"Failed to load admin settings";F(L)}}finally{R||D(!1)}}return ae(),()=>{R=!0}},[]),y.useEffect(()=>{if(!I)return;const R=ie=>{const G=Number(ie);return!isNaN(G)&&G>0?G:void 0},ae=ie=>{const G=Number(ie);return!isNaN(G)&&G>0?G:void 0},L=(H||[]).find(ie=>ie?.ruleId===I||ie?.ruleName===I||ie?.RuleId===I)?.escalationSettings;if(L&&typeof L=="object"){re(ae(L.level1PostAssistTime)),M(R(L.level1UserRoleId)),x(ae(L.level2PostAssistTime)),w(R(L.level2UserRoleId)),A(ae(L.level3PostAssistTime)),q(R(L.level3UserRoleId));const ie=Array.isArray(L.escalationSettingsActionTypeIds)?L.escalationSettingsActionTypeIds:[];Z(ie.map(G=>String(G))),oe(Array.isArray(L.thirdPartyId)?L.thirdPartyId:[]),he(!!L.humanLoop),le(!!L.isAutoExpire)}},[z,I,H]);const Be=async()=>{try{_(!0);const R=await i.getRules(),ae=Array.isArray(R)?R:Array.isArray(R?.data)?R.data:[];we(ae);const Y=ae.map((L,ie)=>{const G=e.find(Ae=>Ae.RuleId===(L.ruleId||L.ruleName))?.Name||L.ruleName||L.Name||"-",ue=L.escalationSettings||{},He=typeof ue.level1UserRoleId=="number"&&ue.level1UserRoleId>0?[ue.level1UserRoleId]:[],Ss=typeof ue.level2UserRoleId=="number"&&ue.level2UserRoleId>0?[ue.level2UserRoleId]:[],pn=typeof ue.level3UserRoleId=="number"&&ue.level3UserRoleId>0?[ue.level3UserRoleId]:[],vn=(Array.isArray(ue.escalationSettingsActionTypeIds)?ue.escalationSettingsActionTypeIds:[]).map(Ae=>pe[Ae]||String(Ae)),xs=(Array.isArray(ue.thirdPartyId)?ue.thirdPartyId:[]).map(Ae=>Oe[Ae]||String(Ae)),ws=typeof ue.humanLoop=="boolean"?ue.humanLoop:null;return{id:String(L.ruleId||L.ruleName||ie),ruleOrSeverityLabel:G,l1:{minutes:ue.level1PostAssistTime??void 0,roles:He},l2:{minutes:ue.level2PostAssistTime??void 0,roles:Ss},l3:{minutes:ue.level3PostAssistTime??void 0,roles:pn},actions:vn,notify:xs,humanLoop:ws}});Ct(Y)}catch(R){console.error("Failed to refetch entries",R)}finally{_(!1)}};y.useEffect(()=>{let R=!1;return(async()=>{try{const ae=await i.getLookups();if(R||!ae)return;const Y={};if(Array.isArray(ae.thirdParties))for(const ie of ae.thirdParties)typeof ie.thirdPartyId=="number"&&(Y[ie.thirdPartyId]=ie.thirdPartyName);ft(Y);const L=Array.isArray(ae.userRoles)?ae.userRoles.map(ie=>({userRoleId:ie.userRoleId??ie.id,userRoleName:ie.userRoleName??ie.name})):[];R||mt(L.length?L:s||[])}catch(ae){console.error("Error loading lookups",ae)}})(),()=>{R=!0}},[]);const Hi=async()=>{S(!0);try{const R=await a.setAdminSettings({sortBy:o,groupBy:"string"});R?.responseStatus&&R?.data&&Ie.toast.success(R.data),m(o),v(!1)}catch(R){console.error("Error saving admin settings",R)}finally{S(!1)}},zi=()=>{u(f),v(!1)},_i=async()=>{Vt(!0),r?.({ruleId:I,levels:[{minutes:C,role:te},{minutes:b,role:O},{minutes:T,role:j}],actions:W,thirdPartyIds:B,humanLoop:me,isAutoExpire:Se});try{if(I){const Y=Array.isArray(W)?W.map(He=>Number(He)):[],L=(H||[]).find(He=>He?.ruleId===I||He?.ruleName===I||He?.RuleId===I),ie=typeof L?.recordId=="number"?L.recordId:void 0;if(!L||typeof ie!="number"){Ie.toast.error("Unable to find rule recordId for update");return}const G={...L,actions:[{actionTypeId:4,actionTypeUniqueId:"bc0973d4-9be0-4efb-8545-c9112ba06c1f",name:"Audible Warning",notificationType:"Alarm",category:"Hardware",description:"Test",isSystemDefined:!0,isActive:!0,displayOrder:0}],escalationSettings:{level1UserRoleId:te??0,level1PostAssistTime:C??0,level2UserRoleId:O??0,level2PostAssistTime:b??0,level3UserRoleId:j??0,level3PostAssistTime:T??0,escalationSettingsActionTypeIds:Y,thirdPartyId:Array.isArray(B)?B:[],humanLoop:me,isAutoExpire:Se}},ue=await i.updateRule(ie,G);if(ue?.responseStatus||ue?.ok||ue){Ie.toast.success("Escalation settings saved"),await Be(),N(void 0),re(void 0),M(void 0),x(void 0),w(void 0),A(void 0),q(void 0),Z([]),oe([]),he(!1),le(!1);return}}}catch(Y){console.error("Error saving escalation settings",Y)}finally{Vt(!1)}const ae=e.find(Y=>Y.RuleId===I)?.Name||"-";Ct(Y=>[...Y,{id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ruleOrSeverityLabel:ae,l1:{minutes:C,roles:te?[te]:[]},l2:{minutes:b,roles:O?[O]:[]},l3:{minutes:T,roles:j?[j]:[]},actions:(Array.isArray(W)?W:[]).map(L=>{const ie=Number(L);return pe[ie]||String(L)}),notify:(Array.isArray(B)?B:[]).map(L=>Oe[L]||String(L)),humanLoop:!!me,isAutoExpire:!!Se}])},Yi=()=>{u("By Severity"),d("By severity"),Q("rules"),K(void 0),N(void 0),re(void 0),M(void 0),x(void 0),w(void 0),A(void 0),q(void 0),Z([]),oe([]),he(!1),le(!1)};return l.jsxs("div",{className:"w-full",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx(pr,{level:4,className:"!mb-2",children:"Admin Settings"}),l.jsxs(h.Spin,{spinning:P,children:[V?l.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",V]}):null,l.jsx(wu,{sortBy:o,groupBy:c,onChange:R=>{R.sortBy&&(u(R.sortBy),v(!0)),R.groupBy&&(d(R.groupBy),v(!0))},showActions:p,onSave:Hi,onClear:zi,saving:g})]})]}),l.jsx(h.Divider,{className:"my-6"}),l.jsxs("div",{children:[l.jsx(pr,{level:4,className:"!mb-4",children:"Escalation Settings"}),l.jsx(bu,{escBasis:z,setEscBasis:Q,selectedSeverity:J,setSelectedSeverity:K,selectedRule:I,setSelectedRule:N,severityOptions:Re,ruleOptions:ne,minsOptions:Je,roleOptions:Ze,l1mins:C,setL1mins:re,l1role:te,setL1role:M,l2mins:b,setL2mins:x,l2role:O,setL2role:w,l3mins:T,setL3mins:A,l3role:j,setL3role:q,actions:W,setActions:Z,thirdPartyIds:B,setThirdPartyIds:oe,humanLoop:me,setHumanLoop:he,onClear:Yi,onSave:_i,saving:rt,onActionTypesLoaded:R=>{const ae={};for(const Y of R)typeof Y.actionTypeId=="number"&&(ae[Y.actionTypeId]=Y.name);Ce(ae)},isAutoExpire:Se,setAutoExpire:le})]}),l.jsx(h.Divider,{className:"my-6"}),l.jsx(Tu,{entries:Ot,userRoles:xe,loading:E,onEdit:R=>{Q("rules");const ae=Ot.find(L=>L.id===R),Y=e.find(L=>L.RuleId===R)||(ae?e.find(L=>L.Name===ae.ruleOrSeverityLabel):void 0);N(Y?Y.RuleId:R)}}),l.jsx(h.Divider,{className:"my-6"}),l.jsx(Ui,{userRoles:xe,rules:e,rawRules:n}),l.jsx(h.Divider,{})]})}const{Title:gr,Text:Kt}=h.Typography;function ku({severities:t,rules:e,onSave:s,onCancel:n}){const{rules:r,alerts:i}=je(),a=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[o,u]=y.useState("By Severity"),[c,d]=y.useState(new Set),[f,m]=y.useState(null),[p,v]=y.useState(null),[g,S]=y.useState({inApp:!1,sms:!1,email:!1}),[P,D]=y.useState([]),[V,F]=y.useState(!0),[z,Q]=y.useState(!1);y.useEffect(()=>{let I=!1;return(async()=>{try{const N=await i.getPreferenceSettings();if(I||!N)return;S({inApp:!!N.inApp,sms:!!N.sms,email:!!N.email});const C=wr(N.sortBy);u(C==="By Created Date"?"By Created Date":"By Severity"),m(Nn(N.doNotDisturbStart)),v(Nn(N.doNotDisturbEnd)),Array.isArray(N.anomalyIds)&&d(new Set(N.anomalyIds.map(re=>String(re))))}catch(N){console.error("Error in loading my preferences: ",N)}})(),()=>{I=!0}},[]),y.useEffect(()=>{let I=!1;return(async()=>{try{F(!0);const N=await r.getLookups();if(I||!N)return;const C=Array.isArray(N.anomalies)?N.anomalies:[];D(C)}catch(N){console.error("Failed to load anomalies lookups",N)}finally{I||F(!1)}})(),()=>{I=!0}},[]);const J=I=>{d(N=>{const C=new Set(N);return C.has(I)?C.delete(I):C.add(I),C})},K=async()=>{s?.({sortBy:o,subscribedRuleIds:Array.from(c),dnd:{from:f,to:p},channels:g});try{Q(!0);const I=f?f.format?.("HH:mm:ss")??"00:00:00":"00:00:00",N=p?p.format?.("HH:mm:ss")??"00:00:00":"00:00:00",C=Array.from(c).map(te=>Number(te)).filter(te=>Number.isFinite(te)),re=await i.setPreferenceSettings({anomalyIds:C,doNotDisturbStart:I,doNotDisturbEnd:N,inApp:!!g.inApp,sms:!!g.sms,email:!!g.email,sortBy:o});re?.responseStatus&&Ie.toast.success(re?.data||"Preferences updated successfully.")}catch(I){console.error("Error in saving my preferences: ",I)}finally{Q(!1)}};return l.jsxs("div",{className:"w-full",children:[l.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:l.jsx(h.Col,{xs:24,md:8,children:l.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[l.jsx(Kt,{className:"text-gray-600",children:"Sort By:"}),l.jsx(h.Select,{className:"w-[240px]",value:o,options:a,onChange:u})]})})}),l.jsxs("div",{className:"mb-4",children:[l.jsx(gr,{level:5,className:"!mb-2",children:"Anomalies"}),V?l.jsx("div",{className:"py-4",children:l.jsx(h.Spin,{})}):l.jsx(h.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(P)?P:[]).map(I=>{const N=String(I.recordId),C=I.anomalyName;return l.jsx(h.Checkbox,{checked:c.has(N),onChange:()=>J(N),children:C},N)})})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx(gr,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),l.jsx(h.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:l.jsx(h.Col,{xs:24,md:12,children:l.jsxs(h.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[l.jsx(Kt,{children:"Do Not Disturb mode:"}),l.jsxs(h.Space,{size:12,className:"w-full",children:[l.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[l.jsx(Kt,{children:"From"}),l.jsx(h.TimePicker,{value:f,onChange:I=>m(I),format:"HH:mm"})]}),l.jsxs(h.Space,{direction:"horizontal",size:8,className:"items-center",children:[l.jsx(Kt,{children:"To"}),l.jsx(h.TimePicker,{value:p,onChange:I=>v(I),format:"HH:mm"})]})]})]})})}),l.jsxs(h.Row,{gutter:[24,12],children:[l.jsx(h.Col,{children:l.jsx(h.Checkbox,{checked:g.inApp,onChange:I=>S({...g,inApp:I.target.checked}),children:"In-app"})}),l.jsx(h.Col,{children:l.jsx(h.Checkbox,{checked:g.sms,onChange:I=>S({...g,sms:I.target.checked}),children:"SMS"})}),l.jsx(h.Col,{children:l.jsx(h.Checkbox,{checked:g.email,onChange:I=>S({...g,email:I.target.checked}),children:"Email"})})]})]}),l.jsx(h.Divider,{}),l.jsxs(h.Space,{className:"gap-3",children:[l.jsx(h.Button,{onClick:n,disabled:z,children:"Cancel"}),l.jsx(h.Button,{type:"primary",onClick:K,loading:z,children:"Save"})]})]})}function Wi({severities:t,rules:e,userRoles:s,rawRules:n}){return l.jsx("div",{className:"w-full",children:l.jsx($i,{severities:t,rules:e,userRoles:s,rawRules:n})})}const Nu="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=",Iu="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 vs(){const{alerts:t}=je(),{data:e,isLoading:s}=hs({queryKey:["userTimeZone"],queryFn:async()=>{const[n,r]=await Promise.all([t.getMyAppPreferences?.()??Promise.resolve(null),t.getTimeZoneMasters?.()??Promise.resolve([])]),i=Intl.DateTimeFormat().resolvedOptions().timeZone,a={timeZoneUniqueId:"",ianaTimeZoneId:i,timeZoneName:i,offset:""};if(!n?.timeZoneUniqueId||!r.length)return a;const o=r.find(u=>u.timeZoneUniqueId===n.timeZoneUniqueId);return o?.ianaTimeZoneId?{timeZoneUniqueId:o.timeZoneUniqueId,ianaTimeZoneId:o.ianaTimeZoneId,timeZoneName:o.timeZoneName,offset:o.offset}:a},staleTime:5*6e4});return{timeZoneDetails:e,loading:s}}function Ou(t){const e=(t.status||"").toLowerCase()==="completed"?l.jsx("img",{src:Nu,alt:"completed",style:{width:20,height:20}}):l.jsx("img",{src:Iu,alt:"pending",style:{width:20,height:20}});return{title:l.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:l.jsx("b",{children:t.title})}),t.description?l.jsx("span",{className:"text-gray-500 text-xs",children:t.description}):null]}),t.timestamp?l.jsx("span",{className:"text-gray-500 text-xs",children:t.timestamp}):null]}),icon:e,description:null}}function Cu({data:t}){const{timeZoneDetails:e}=vs();return l.jsx("div",{className:"w-full",children:l.jsx(h.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:l.jsxs("div",{className:"w-full",children:[l.jsx(h.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:l.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsx("span",{className:"text-gray-500",children:"Alert ID"}),l.jsx("span",{className:"text-black",children:t.summary.alertNumber})]}),l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsx("span",{className:"text-gray-500",children:"Severity"}),l.jsx("span",{className:"text-black",children:t.summary.severity})]}),l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsx("span",{className:"text-gray-500",children:"Location"}),l.jsx("span",{className:"text-black",children:t.summary.location})]})]})}),l.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),l.jsx("div",{className:"mt-2",children:l.jsx(h.Steps,{direction:"vertical",size:"small",current:1,items:(t.timeline||[]).map(Ou)})})]})]})},{key:"notification",label:"Notification Sent",children:l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(t.notifications||[]).map((s,n)=>l.jsxs(h.Card,{className:"rounded-md p-4",bordered:!0,children:[l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{className:"flex flex-col",children:[l.jsx("h4",{className:"text-sm text-black font-medium",children:s.channelLabel}),l.jsx("span",{className:"text-xs text-gray-500 mt-1",children:cs(s.sentAt,e?.ianaTimeZoneId)})]}),l.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"]})]}),l.jsxs("div",{className:"mt-4 text-xs",children:[l.jsxs("div",{className:"text-black",children:[" ",s.messageTitle]}),s.messageBody?l.jsx("div",{className:"text-gray-600",children:s.messageBody}):null]}),l.jsxs("div",{className:"mt-4",children:[l.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",s.total,")"]}),l.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(s.recipients||[]).map((r,i)=>{const a=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex flex-col",children:[l.jsxs("span",{className:"text-black",children:[r.name," - ",l.jsx("span",{style:{color:a?"#FF3B30":"#FFB86A"},children:a?"Escalation Notification":"Alert Notification"})]}),l.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),l.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})]},i)})})]})]},n)),t?.notifications?.length?null:l.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const Eu=({alertId:t,id:e,priority:s,spaceName:n,alertNumber:r,statusHistory:i,notifGroups:a})=>{const o={alertId:t??String(e??""),incidentId:"-",severity:s||"",location:n||"",alertNumber:r??""},{timeZoneDetails:u}=vs(),c=i?.length?i.map(f=>{const m=(f?.status||f?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",p=f?.createdDate?cs(f.createdDate,u?.ianaTimeZoneId):f?.timestamp?cs(f.timestamp,u?.ianaTimeZoneId):"";return{status:m,title:f?.status||f?.eventStatus||"Status Update",description:f?.description||f?.actionNotes||"",timestamp:p}}):[],d={summary:o,timeline:c,notifications:a??[]};return l.jsx(Cu,{data:d})};const Mu=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Du=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,n)=>n?n.toUpperCase():s.toLowerCase()),vr=t=>{const e=Du(t);return e.charAt(0).toUpperCase()+e.slice(1)},Vi=(...t)=>t.filter((e,s,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===s).join(" ").trim(),ju=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Ru={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 Fu=y.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:i,iconNode:a,...o},u)=>y.createElement("svg",{ref:u,...Ru,width:e,height:e,stroke:t,strokeWidth:n?Number(s)*24/Number(e):s,className:Vi("lucide",r),...!i&&!ju(o)&&{"aria-hidden":"true"},...o},[...a.map(([c,d])=>y.createElement(c,d)),...Array.isArray(i)?i:[i]]));const mn=(t,e)=>{const s=y.forwardRef(({className:n,...r},i)=>y.createElement(Fu,{ref:i,iconNode:e,className:Vi(`lucide-${Mu(vr(t))}`,`lucide-${t}`,n),...r}));return s.displayName=vr(t),s};const Lu=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Pu=mn("loader-circle",Lu);const Uu=[["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"}]],qi=mn("maximize-2",Uu);const $u=[["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"}]],Wu=mn("minimize-2",$u),Vu=({isOpen:t,onClose:e,src:s,type:n="image"})=>{const[r,i]=y.useState(!1),[a,o]=y.useState(!1);return y.useEffect(()=>{t&&o(!1)},[t,s]),y.useEffect(()=>{t&&(!s||a)&&e()},[t,s,a,e]),t?l.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:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),e())},onTouchStart:e,children:l.jsxs("div",{className:`relative ${r?"w-full h-full":"max-w-5xl max-h-[90vh] w-full"} flex items-center justify-center`,onClick:u=>u.stopPropagation(),children:[n==="image"?l.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:()=>o(!0)}):l.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:()=>o(!0)}),l.jsx("button",{onClick:e,className:"absolute top-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:"✕"}),l.jsx("button",{onClick:()=>i(!r),className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:r?l.jsx(Wu,{size:20}):l.jsx(qi,{size:20})})]})}):null};function qu(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 Sr(t){const e=(t?.mediaType||t?.type||"").toString().toLowerCase();return e==="video"||e==="mp4"?!0:qu(t?.mediaUrl||t)}function Zu(t){const e=t;return e?Array.isArray(e)?e:[e]:[]}const Bu={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Hu={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},zu=({isModalOpen:t,handleModalClose:e,selectedRow:s,fetchAlertLogs:n,alertStatusList:r=[],alertStatusLoading:i=!1,initialTab:a="details",sourceTab:o})=>{const[u,c]=y.useState(),[d,f]=y.useState(""),[m,p]=y.useState(!1),v=y.useRef(null),[g,S]=y.useState("details"),[P,D]=y.useState(void 0),V=rn(),{alerts:F}=je(),{timeZoneDetails:z}=vs(),[Q,J]=y.useState(!1),[K,I]=y.useState(void 0),[N,C]=y.useState(void 0),[re,te]=y.useState({}),[M,b]=y.useState({}),x=s?.originalData||{},{eventName:O,alertId:w,timestamp:T,description:A,spaceName:j,assignTeam:q,priority:W,statusType:Z,id:B,alertDetails:oe,statusHistory:me,mediaDetails:he,alertNumber:Se}=x,le=E=>{const _=String(E||"").toLowerCase();return _==="delivered"||_==="sent"?"Delivered":_==="failed"?"Failed":"Queued"},pe=E=>({name:E?.receipientName||E?.recipientName||"-",role:E?.receipientRoleName||"",phone:E?.receipentPhoneNumber||E?.recipientPhoneNumber||E?.receipientEmail||E?.recipientEmail||"",status:le(E?.messageStatus),notificationReceipientType:E?.notificationReceipientType||""}),Ce=(E,_)=>{const H=_.map(pe),we=H.filter(Je=>Je.status==="Delivered").length,Re=_.map(Je=>Je?.sentAt).filter(Boolean).sort((Je,Be)=>new Date(Be).getTime()-new Date(Je).getTime())[0],ne=_[0]||{},Ze=[ne?.severityName,ne?.anomalyName].filter(Boolean).join(" - ")||`${E} Notification`;return{channelLabel:`${E} Notification`,sentAt:Re||"",messageTitle:Ze,messageBody:"",total:H.length,delivered:we,recipients:H}},Oe=E=>{const _=new Map;return(E||[]).forEach(H=>{const we=String(H?.notificationType||"Unknown"),Re=_.get(we)||[];Re.push(H),_.set(we,Re)}),Array.from(_.entries()).map(([H,we])=>Ce(H,we))},ft=async E=>{try{const _=await F.getAlertNotifications(E),H=Oe(_);D(H)}catch{D(void 0)}};y.useEffect(()=>{if(g!=="track"||!B)return;let E=!1;return ft(B).then(()=>{E&&D(void 0)}),()=>{E=!0}},[g,B]),y.useEffect(()=>{t&&S(a)},[t,a]);const mt=o==="archived"||["completed","false positive"].includes(String(Z||"").toLowerCase()),Ot=E=>{const _=String(E?.value||"").toLowerCase(),H=String(E?.statusName||"").toLowerCase();return _.includes("reopen")||H.includes("reopen")},Ct=(r||[]).filter(E=>{const _=Ot(E);return typeof o<"u"?o==="archived"?_:!_:mt?_:!_}).map(E=>({value:E.value,label:E.statusName})),rt=y.useMemo(()=>Zu(he),[he]);y.useEffect(()=>{let E=!1;const _=new AbortController,H=async ne=>{if(ne){E||te(Ze=>({...Ze,[ne]:!1}));try{const Ze=await fetch(ne,{method:"HEAD",signal:_.signal});if(Ze.ok){E||te(Be=>({...Be,[ne]:!0}));return}if(Ze.status===404){E||te(Be=>({...Be,[ne]:!1}));return}if(!(await fetch(ne,{method:"GET",signal:_.signal})).ok)throw new Error("Media not available");E||te(Be=>({...Be,[ne]:!0}))}catch{E||te(Ze=>({...Ze,[ne]:!1}))}}};te({});const we=rt.filter(ne=>!Sr(ne)).map(ne=>ne?.mediaUrl||ne).filter(ne=>typeof ne=="string"&&ne.length>0),Re={};return we.forEach(ne=>{Re[ne]=!0}),b(Re),we.forEach(ne=>H(ne)),()=>{E=!0,_.abort()}},[rt]);const Vt=async()=>{try{p(!0);const E={alertUniqueId:w,alertId:B,status:u?String(u):void 0,notes:d.trim(),modifiedBy:0},_=await V.mutateAsync(E);if(_?.responseStatus){const H=_?.data||"Alert updated successfully.";Ie.toast.success(H,{autoClose:1500,onClose:()=>{n(),e()}}),c(void 0),f("")}else{const H=_?.errorMessage||"Failed to update alert status";Ie.toast.error(H)}}catch(E){console.error("Error updating alert status:",E),Ie.toast.error("Failed to update alert status. Please try again.")}finally{p(!1)}};return l.jsx(h.Modal,{open:t,onCancel:e,width:1e3,styles:{body:{maxHeight:"70vh",overflowY:"auto"}},footer:g==="details"?l.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[l.jsx(h.Button,{onClick:e,className:"bg-[#6C757D] text-white",children:"Cancel"}),l.jsx(h.Button,{type:"primary",onClick:Vt,loading:m,children:m?"Saving...":"Save Changes"})]}):null,children:s&&l.jsx(h.Tabs,{activeKey:g,onChange:E=>S(E),items:[{key:"details",label:"Alert Detail",children:l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("div",{className:"text-sm font-bold",children:O||"Alert Event"}),oe?.firstName?l.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",oe?.firstName," ",oe?.lastName||""," ",oe?.residentId||""]}):null,l.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",cs(T,z?.ianaTimeZoneId)]}),l.jsxs("div",{className:"font-sm text-gray-500",children:[l.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",A||"No description available"]}),j&&l.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",j]}),q&&l.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",q]}),l.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[l.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${Bu[String(W)]||"#DFE4EA"}`,backgroundColor:Hu[String(W)]},children:["Severity: ",W||"N/A"]}),l.jsxs(h.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(Z||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",Z||"N/A"]})]}),l.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:l.jsxs("div",{className:"w-full mt-4",children:[l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(h.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:E=>c(E),value:u,options:Ct,loading:i})}),l.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[l.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),l.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:d,onChange:E=>f(E.target.value)})]})]})})]}),l.jsx("div",{className:"flex flex-col gap-4",children:l.jsxs("div",{className:"w-full mt-1",children:[l.jsxs("div",{className:"w-full flex items-center justify-between",children:[l.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),rt.length>1?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:()=>v.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:l.jsx(ut.LeftOutlined,{style:{fontSize:12}})}),l.jsx("button",{type:"button",onClick:()=>v.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:l.jsx(ut.RightOutlined,{style:{fontSize:12}})})]}):null]}),rt.length?l.jsx("div",{className:"w-full",children:l.jsx(h.Carousel,{ref:v,dots:!0,className:"w-full",children:rt.map((E,_)=>{const H=E.mediaUrl||E,we=Sr(E),Re=!we&&M[String(H)];return l.jsxs("div",{className:"flex justify-center items-center relative",children:[we?l.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[l.jsx("source",{src:H}),"Your browser does not support the video tag."]}):l.jsxs("div",{className:"relative w-full flex justify-center items-center min-h-[200px]",children:[Re&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg z-10",children:l.jsx(Pu,{size:32,className:"animate-spin text-gray-400"})}),l.jsx("img",{src:H,alt:E.caption||`media-${_}`,className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg transition-opacity duration-200 ${Re?"opacity-0":"opacity-100"}`,onLoad:()=>b(ne=>({...ne,[String(H)]:!1})),onError:()=>b(ne=>({...ne,[String(H)]:!1}))},String(H))]}),E.caption&&l.jsx("p",{className:"text-xs text-gray-500 mt-1",children:E.caption}),!we&&re[String(H)]?l.jsx("button",{onClick:()=>{J(!0),I(H),C(E.type||"image")},className:"absolute bottom-3 right-3 text-white bg-black/50 rounded-full p-2 hover:bg-black/70",children:l.jsx(qi,{size:20})}):null]},String(H)||_)})})}):null]})}),l.jsx(Vu,{isOpen:Q,onClose:()=>J(!1),src:K||"",type:N||"image"})]})},{key:"track",label:"Track Incident",children:l.jsx(Eu,{alertId:w,id:B,priority:W,spaceName:j,alertNumber:Se,statusHistory:me,notifGroups:P})}]})})};function Zi(){const{alerts:t}=je(),e=hs({queryKey:["alerts","statusList"],queryFn:()=>t.getAlertStatusList(),staleTime:5*6e4});return{list:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function yn({alerts:t,loading:e=!1,columns:s,onRefetch:n}){const[r,i]=y.useState(!1),[a,o]=y.useState(null),[u,c]=y.useState("details"),{list:d,loading:f}=Zi(),{timeZoneDetails:m,loading:p}=vs(),v=m?.timeZoneName??"UTC",g=m?.ianaTimeZoneId??"UTC";function S(z,Q){o(z),c(Q?.tab??"details"),V(Q?.sourceTab??"active"),i(!0)}function P(){i(!1)}const[D,V]=y.useState("active"),F=a?{originalData:{...a,alertId:a.alertId??a.id,mediaDetails:a.mediaDetails}}:null;return l.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[l.jsxs("div",{className:"w-1/2 flex items-center justify-between mb-4",children:[l.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),p?l.jsx(h.Spin,{size:"small"}):l.jsx(Pi,{label:v,timeZone:g})]}),l.jsx(h.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:z=>{z==="active"&&n?.()},items:[{key:"active",label:"Active",children:l.jsx(Ks,{data:t,loading:e,pageSize:10,columns:s||[],onAlertIdClick:S,onRefetch:n})},{key:"archived",label:"Archived",children:l.jsx(Li,{alerts:t,loading:e,columns:s||[],onAlertIdClick:S})},{key:"settings",label:"Settings",children:l.jsx(_u,{})}]}),l.jsx(zu,{isModalOpen:r,handleModalClose:P,selectedRow:F,fetchAlertLogs:()=>{},alertStatusList:d,alertStatusLoading:f,initialTab:u,sourceTab:D})]})}function _u(){const[t,e]=y.useState([]),[s,n]=y.useState([]),[r,i]=y.useState([]),{rules:a}=je();return y.useEffect(()=>{let o=!0;return(async()=>{try{const u=await a.getRules();if(!o)return;i(Array.isArray(u)?u:[]);const c=(u||[]).map((d,f)=>({RuleId:d.ruleId||d.ruleName||String(f),Name:d.ruleName||d.Name||"-",Description:d.ruleDesc||d.Description||"",SeverityId:0}));e(c.length?c:vt.rules);try{const d=await a.getLookups(),f=Array.isArray(d?.userRoles)?d.userRoles.map(m=>({userRoleId:m.userRoleId??m.id,userRoleName:m.userRoleName??m.name})):[];n(f.length?f:vt.userRoles)}catch{n(vt.userRoles)}}catch{e(vt.rules),n(vt.userRoles)}})(),()=>{o=!1}},[]),l.jsx(Wi,{severities:vt.severities,rules:t,userRoles:s,rawRules:r})}function Bi(){const{alerts:t}=je(),e=hs({queryKey:["alerts","list"],queryFn:()=>t.listAlerts(),staleTime:3e4});return{alerts:e.data??[],loading:e.isLoading,error:e.error,refetch:e.refetch}}function Yu(t){const{alerts:e,loading:s,refetch:n}=Bi();return l.jsx(yn,{alerts:e,loading:s,columns:t.columns,onRefetch:n})}function Gu({tenant:t,apiDomain:e,rulesDomain:s,headers:n,alerts:r,loading:i,columns:a}){const[o]=y.useState(()=>new Ka),u=y.useMemo(()=>({alertsBaseUrl:e,rulesBaseUrl:s||e,headers:n||void 0}),[e,s,n]);return l.jsx(Xa,{client:o,children:l.jsx(Ar,{tenant:t,override:u,children:Array.isArray(r)?l.jsx(yn,{alerts:r,loading:!!i,columns:a}):l.jsx(Yu,{columns:a})})})}function Qu(t){const{alerts:e}=je(),s=hs({queryKey:["alerts","report",t],queryFn:()=>e.getAlertsReport(t),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const Ju=[{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=Ui;exports.AlertConsole=yn;exports.AlertConsoleWidget=Gu;exports.AlertsTable=Ks;exports.ApiProvider=Ar;exports.ArchivedTable=Li;exports.Clock=Pi;exports.DataTable=kr;exports.MyPreferencesPanel=ku;exports.SettingsPanel=$i;exports.SettingsTabs=Wi;exports.exampleAlertColumns=Ju;exports.useAlertStatusList=Zi;exports.useAlerts=Bi;exports.useAlertsReport=Qu;exports.useApi=je;exports.useUpdateAlertStatus=rn;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|