@ssgc/alert-console 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),h=require("react"),c=require("antd"),Ee=require("@ant-design/icons"),re=require("react-toastify");function As(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const le=As(h),Ns="#FF3B30",ws="#FF9500",js="#FFCC00",Cs="#34C759",De={critical:Ns,high:ws,medium:js,low:Cs},At={Critical:De.critical,High:De.high,Medium:De.medium,Low:De.low};function Is(e){return At[e]||At.Low}function Nt(e){if(!e||typeof e!="string")return 0;const t=e.trim().split(":");if(t.length!==3)return 0;const[s,r,i]=t,a=Number.parseInt(s,10),o=Number.parseInt(r,10),l=Number.parseFloat(i||"0"),f=Number.isFinite(a)?a:0,u=Number.isFinite(o)?o:0,d=Number.isFinite(l)?l:0;return f*3600+u*60+d}function ze(e){const t=e.thirdPartyIds??e.ThirdPartyIds??e.thirdPartyId??e.ThirdPartyId??"",s=Array.isArray(t)?t.join(","):String(t??"");if(!s||!s.trim())return[];const r=s.split(",").map(o=>parseInt(String(o).trim(),10)).filter(o=>Number.isFinite(o)),i=new Set,a=[];return r.forEach(o=>{i.has(o)||(i.add(o),a.push(o))}),a}const Ht="",Ts=Ht,Rs="",ks="",wt={snl:{alerts:Ht,rules:Ts},schools:{alerts:Rs,rules:ks}};function fe(e,t){const s=(e||"").replace(/\/+$/,""),r=t.startsWith("/")?t:`/${t}`;return`${s}${r}`}function Os(){try{const e=localStorage.getItem("authToken");return e?{Authorization:`Bearer ${e}`}:{}}catch{return{}}}function Fe(e,t){if(!t)return e;const s=new URL(e);return Object.entries(t).forEach(([r,i])=>{i!=null&&String(i).length>0&&s.searchParams.set(r,String(i))}),s.toString()}async function me(e,t){const s={...t.headers,...Os()},r=await fetch(e,{...t,headers:s});if(r.status===401)throw window.location.href="/login",new Error("Unauthorized");if(r.status===204)return{};const i=await r.text();let a={};if(i)try{a=JSON.parse(i)}catch{a={ok:r.ok,status:r.status,raw:i}}if(!r.ok){const o=a?.errorMessage||a?.message||`HTTP ${r.status}`;throw new Error(o)}return a}function Es(e){const t={"Content-Type":"application/json",...e.headers||{}};return{async listAlerts(){const s=fe(e.baseUrl,"/api/Alert"),r=await me(s,{method:"GET",headers:t});return Array.isArray(r)?r:[]},async getAlertStatusList(){const s=fe(e.baseUrl,"/api/Alert/AlertStatusList"),r=await me(s,{method:"GET",headers:t});return Array.isArray(r)?r:r&&typeof r=="object"&&Array.isArray(r.data)?r.data:[]},async getAlertsReport(s){const r=fe(e.baseUrl,"/Alerts/GetAlertsReport"),i=Fe(r,s),a=await me(i,{method:"GET",headers:t});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const r=fe(e.baseUrl,"/api/Alert/status");return me(r,{method:"PUT",headers:t,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=fe(e.baseUrl,"/api/Alert/GetAdminSettings"),r=await me(s,{method:"GET",headers:t});if(r&&typeof r=="object"){if("data"in r)return r.data;if("userId"in r)return r}return null},async setAdminSettings(s){const r=fe(e.baseUrl,"/api/Alert/SetAdminSettings"),i={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return me(r,{method:"POST",headers:t,body:JSON.stringify(i)})},async getPreferenceSettings(){const s=fe(e.baseUrl,"/api/Alert/GetPreferenceSettings"),r=await me(s,{method:"GET",headers:t});if(r&&typeof r=="object"){if("data"in r)return r.data;if("anomalyIds"in r)return r}return null},async setPreferenceSettings(s){const r=fe(e.baseUrl,"/api/Alert/SetPreferenceSettings"),i=await me(r,{method:"POST",headers:t,body:JSON.stringify(s??{})}),a=i?.responseStatus??!0,o=i?.data??i?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":i?.errorMessage??i?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const r=fe(e.baseUrl,"/api/Alert/GetNotifications"),i=Fe(r,{alertId:s}),a=await me(i,{method:"GET",headers:t});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async notifyFamilyMembers(s){const r=fe(e.baseUrl,"/api/Alert/NotificationToFamilyMembers"),i=Fe(r,{alertId:s});return me(i,{method:"POST",headers:t})},async sendSMSorEmailNotifications(s,r,i){const a=fe(e.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Fe(a,{alertId:s,isEmail:r,isSMS:i});return me(o,{method:"POST",headers:t})}}}function jt(e,t){const s=(e||"").replace(/\/+$/,""),r=t.startsWith("/")?t:`/${t}`;return`${s}${r}`}function Ps(){try{const e=localStorage.getItem("authToken");return e?{Authorization:`Bearer ${e}`}:{}}catch{return{}}}async function Ue(e,t){const s={...t.headers,...Ps()},r=await fetch(e,{...t,headers:s});if(r.status===401)throw window.location.href="/login",new Error("Unauthorized");if(r.status===204)return{};const i=await r.text();let a={};if(i)try{a=JSON.parse(i)}catch{a={ok:r.ok,status:r.status,raw:i}}if(!r.ok){const o=a?.errorMessage||a?.message||`HTTP ${r.status}`;throw new Error(o)}return a}function Ms(e){const t={"Content-Type":"application/json",...e.headers||{}},s=jt(e.baseUrl,"/api/Rules"),r=jt(e.baseUrl,"/api/Rules/lookups");return{async getRules(){const i=await Ue(s,{method:"GET",headers:t});return Array.isArray(i)?i:[]},async setEscalationSettings(i){return Ue(s,{method:"POST",headers:t,body:JSON.stringify(i??{})})},async getLookups(){return Ue(r,{method:"GET",headers:t})},async updateRule(i,a){const o=`${s}/${i}`;return Ue(o,{method:"PUT",headers:t,body:JSON.stringify(a??{})})}}}function Ds(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Be={exports:{}},Fs=Be.exports,Ct;function Us(){return Ct||(Ct=1,(function(e,t){(function(s,r){e.exports=r()})(Fs,(function(){var s=1e3,r=6e4,i=36e5,a="millisecond",o="second",l="minute",f="hour",u="day",d="week",N="month",m="quarter",k="year",w="date",y="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,U={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(R){var v=["th","st","nd","rd"],p=R%100;return"["+R+(v[(p-20)%10]||v[p]||v[0])+"]"}},$=function(R,v,p){var A=String(R);return!A||A.length>=v?R:""+Array(v+1-A.length).join(p)+R},F={s:$,z:function(R){var v=-R.utcOffset(),p=Math.abs(v),A=Math.floor(p/60),g=p%60;return(v<=0?"+":"-")+$(A,2,"0")+":"+$(g,2,"0")},m:function R(v,p){if(v.date()<p.date())return-R(p,v);var A=12*(p.year()-v.year())+(p.month()-v.month()),g=v.clone().add(A,N),x=p-g<0,b=v.clone().add(A+(x?-1:1),N);return+(-(A+(p-g)/(x?g-b:b-g))||0)},a:function(R){return R<0?Math.ceil(R)||0:Math.floor(R)},p:function(R){return{M:N,y:k,w:d,d:u,D:w,h:f,m:l,s:o,ms:a,Q:m}[R]||String(R||"").toLowerCase().replace(/s$/,"")},u:function(R){return R===void 0}},K="en",V={};V[K]=U;var H="$isDayjsObject",G=function(R){return R instanceof te||!(!R||!R[H])},I=function R(v,p,A){var g;if(!v)return K;if(typeof v=="string"){var x=v.toLowerCase();V[x]&&(g=x),p&&(V[x]=p,g=x);var b=v.split("-");if(!g&&b.length>1)return R(b[0])}else{var O=v.name;V[O]=v,g=O}return!A&&g&&(K=g),g||!A&&K},j=function(R,v){if(G(R))return R.clone();var p=typeof v=="object"?v:{};return p.date=R,p.args=arguments,new te(p)},T=F;T.l=I,T.i=G,T.w=function(R,v){return j(R,{locale:v.$L,utc:v.$u,x:v.$x,$offset:v.$offset})};var te=(function(){function R(p){this.$L=I(p.locale,null,!0),this.parse(p),this.$x=this.$x||p.x||{},this[H]=!0}var v=R.prototype;return v.parse=function(p){this.$d=(function(A){var g=A.date,x=A.utc;if(g===null)return new Date(NaN);if(T.u(g))return new Date;if(g instanceof Date)return new Date(g);if(typeof g=="string"&&!/Z$/i.test(g)){var b=g.match(S);if(b){var O=b[2]-1||0,D=(b[7]||"0").substring(0,3);return x?new Date(Date.UTC(b[1],O,b[3]||1,b[4]||0,b[5]||0,b[6]||0,D)):new Date(b[1],O,b[3]||1,b[4]||0,b[5]||0,b[6]||0,D)}}return new Date(g)})(p),this.init()},v.init=function(){var p=this.$d;this.$y=p.getFullYear(),this.$M=p.getMonth(),this.$D=p.getDate(),this.$W=p.getDay(),this.$H=p.getHours(),this.$m=p.getMinutes(),this.$s=p.getSeconds(),this.$ms=p.getMilliseconds()},v.$utils=function(){return T},v.isValid=function(){return this.$d.toString()!==y},v.isSame=function(p,A){var g=j(p);return this.startOf(A)<=g&&g<=this.endOf(A)},v.isAfter=function(p,A){return j(p)<this.startOf(A)},v.isBefore=function(p,A){return this.endOf(A)<j(p)},v.$g=function(p,A,g){return T.u(p)?this[A]:this.set(g,p)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(p,A){var g=this,x=!!T.u(A)||A,b=T.p(p),O=function(oe,se){var C=T.w(g.$u?Date.UTC(g.$y,se,oe):new Date(g.$y,se,oe),g);return x?C:C.endOf(u)},D=function(oe,se){return T.w(g.toDate()[oe].apply(g.toDate("s"),(x?[0,0,0,0]:[23,59,59,999]).slice(se)),g)},P=this.$W,B=this.$M,q=this.$D,Y="set"+(this.$u?"UTC":"");switch(b){case k:return x?O(1,0):O(31,11);case N:return x?O(1,B):O(0,B+1);case d:var ne=this.$locale().weekStart||0,ue=(P<ne?P+7:P)-ne;return O(x?q-ue:q+(6-ue),B);case u:case w:return D(Y+"Hours",0);case f:return D(Y+"Minutes",1);case l:return D(Y+"Seconds",2);case o:return D(Y+"Milliseconds",3);default:return this.clone()}},v.endOf=function(p){return this.startOf(p,!1)},v.$set=function(p,A){var g,x=T.p(p),b="set"+(this.$u?"UTC":""),O=(g={},g[u]=b+"Date",g[w]=b+"Date",g[N]=b+"Month",g[k]=b+"FullYear",g[f]=b+"Hours",g[l]=b+"Minutes",g[o]=b+"Seconds",g[a]=b+"Milliseconds",g)[x],D=x===u?this.$D+(A-this.$W):A;if(x===N||x===k){var P=this.clone().set(w,1);P.$d[O](D),P.init(),this.$d=P.set(w,Math.min(this.$D,P.daysInMonth())).$d}else O&&this.$d[O](D);return this.init(),this},v.set=function(p,A){return this.clone().$set(p,A)},v.get=function(p){return this[T.p(p)]()},v.add=function(p,A){var g,x=this;p=Number(p);var b=T.p(A),O=function(B){var q=j(x);return T.w(q.date(q.date()+Math.round(B*p)),x)};if(b===N)return this.set(N,this.$M+p);if(b===k)return this.set(k,this.$y+p);if(b===u)return O(1);if(b===d)return O(7);var D=(g={},g[l]=r,g[f]=i,g[o]=s,g)[b]||1,P=this.$d.getTime()+p*D;return T.w(P,this)},v.subtract=function(p,A){return this.add(-1*p,A)},v.format=function(p){var A=this,g=this.$locale();if(!this.isValid())return g.invalidDate||y;var x=p||"YYYY-MM-DDTHH:mm:ssZ",b=T.z(this),O=this.$H,D=this.$m,P=this.$M,B=g.weekdays,q=g.months,Y=g.meridiem,ne=function(se,C,_,z){return se&&(se[C]||se(A,x))||_[C].slice(0,z)},ue=function(se){return T.s(O%12||12,se,"0")},oe=Y||function(se,C,_){var z=se<12?"AM":"PM";return _?z.toLowerCase():z};return x.replace(L,(function(se,C){return C||(function(_){switch(_){case"YY":return String(A.$y).slice(-2);case"YYYY":return T.s(A.$y,4,"0");case"M":return P+1;case"MM":return T.s(P+1,2,"0");case"MMM":return ne(g.monthsShort,P,q,3);case"MMMM":return ne(q,P);case"D":return A.$D;case"DD":return T.s(A.$D,2,"0");case"d":return String(A.$W);case"dd":return ne(g.weekdaysMin,A.$W,B,2);case"ddd":return ne(g.weekdaysShort,A.$W,B,3);case"dddd":return B[A.$W];case"H":return String(O);case"HH":return T.s(O,2,"0");case"h":return ue(1);case"hh":return ue(2);case"a":return oe(O,D,!0);case"A":return oe(O,D,!1);case"m":return String(D);case"mm":return T.s(D,2,"0");case"s":return String(A.$s);case"ss":return T.s(A.$s,2,"0");case"SSS":return T.s(A.$ms,3,"0");case"Z":return b}return null})(se)||b.replace(":","")}))},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(p,A,g){var x,b=this,O=T.p(A),D=j(p),P=(D.utcOffset()-this.utcOffset())*r,B=this-D,q=function(){return T.m(b,D)};switch(O){case k:x=q()/12;break;case N:x=q();break;case m:x=q()/3;break;case d:x=(B-P)/6048e5;break;case u:x=(B-P)/864e5;break;case f:x=B/i;break;case l:x=B/r;break;case o:x=B/s;break;default:x=B}return g?x:T.a(x)},v.daysInMonth=function(){return this.endOf(N).$D},v.$locale=function(){return V[this.$L]},v.locale=function(p,A){if(!p)return this.$L;var g=this.clone(),x=I(p,A,!0);return x&&(g.$L=x),g},v.clone=function(){return T.w(this.$d,this)},v.toDate=function(){return new Date(this.valueOf())},v.toJSON=function(){return this.isValid()?this.toISOString():null},v.toISOString=function(){return this.$d.toISOString()},v.toString=function(){return this.$d.toUTCString()},R})(),ee=te.prototype;return j.prototype=ee,[["$ms",a],["$s",o],["$m",l],["$H",f],["$W",u],["$M",N],["$y",k],["$D",w]].forEach((function(R){ee[R[1]]=function(v){return this.$g(v,R[0],R[1])}})),j.extend=function(R,v){return R.$i||(R(v,te,j),R.$i=!0),j},j.locale=I,j.isDayjs=G,j.unix=function(R){return j(1e3*R)},j.en=V[K],j.Ls=V,j.p={},j}))})(Be)),Be.exports}var Ls=Us();const $s=Ds(Ls);function Gt(e){if(!e)return"By Severity";const t=e.trim().toLowerCase();return t.includes("created")?"By Created Date":t.includes("updated")||t.includes("modified")?"By Updated Date":"By Severity"}function Wt(e){if(!e||typeof e!="string")return{hours:0,minutes:0,seconds:0};const t=e.split(":").map(a=>parseInt(a,10)),s=Number.isFinite(t[0])?t[0]:0,r=Number.isFinite(t[1])?t[1]:0,i=Number.isFinite(t[2])?t[2]:0;return{hours:s,minutes:r,seconds:i}}function It(e){const{hours:t,minutes:s,seconds:r}=Wt(e);return $s().hour(t).minute(s).second(r).millisecond(0)}function ge(e,t){const s=(e||"").replace(/\/+$/,""),r=t.startsWith("/")?t:`/${t}`;return`${s}${r}`}function Bs(){try{const e=localStorage.getItem("authToken");return e?{Authorization:`Bearer ${e}`}:{}}catch{return{}}}function Tt(e,t){if(!t)return e;const s=new URL(e);return Object.entries(t).forEach(([r,i])=>{i!=null&&String(i).length>0&&s.searchParams.set(r,String(i))}),s.toString()}async function ve(e,t){const s={...t.headers,...Bs()},r=await fetch(e,{...t,headers:s});if(r.status===401)throw window.location.href="/login",new Error("Unauthorized");if(r.status===204)return{};const i=await r.text();let a={};if(i)try{a=JSON.parse(i)}catch{a={ok:r.ok,status:r.status,raw:i}}if(!r.ok){const o=a?.Message||`HTTP ${r.status}`;throw new Error(o)}return a}const ae=(...e)=>e.find(t=>t!=null);function qs(e){return{id:String(ae(e?.AlertId,e?.alertId)??""),priority:ae(e?.Priority,e?.priority,"Low"),timestamp:ae(e?.Timestamp,e?.timestamp,""),statusType:ae(e?.Status,e?.statusType,""),description:ae(e?.Description,e?.description,""),eventName:ae(e?.EventName,e?.eventName),ruleName:ae(e?.RuleName,e?.ruleName),spaceName:ae(e?.SpaceName,e?.spaceName),assignTeam:ae(e?.AssignTeam,e?.assignTeam),cameraName:ae(e?.CameraName,e?.cameraName),type:ae(e?.Type,e?.type),mediaDetails:ae(e?.MediaDetails,e?.mediaDetails),additionalMedia:ae(e?.AdditionalMedia,e?.additionalMedia),timeElapsed:ae(e?.TimeElapsed,e?.timeElapsed),timeRemaining:ae(e?.TimeRemaining,e?.timeRemaining),anomalyName:ae(e?.AnomalyName,e?.anomalyName),alertDetails:ae(e?.AlertDetails,e?.alertDetails),statusHistory:ae(e?.StatusHistory,e?.statusHistory)}}function Qs(e){const t={"Content-Type":"application/json",...e.headers||{}};return{async listAlerts(){const s=ge(e.baseUrl,"/api/detectionpolicy/alerts?customerId=99e5c8b5-b9d4-4d35-8885-7f121c532664"),r=await ve(s,{method:"GET",headers:t});return Array.isArray(r?.Items)?(r?.Items).map(qs):[]},async getAlertStatusList(){const s=ge(e.baseUrl,"/api/detectionpolicy/alerts/StatusList"),r=await ve(s,{method:"GET",headers:t});return Array.isArray(r)?r:[]},async getAlertsReport(s){const r=ge(e.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),i=Tt(r,s),a=await ve(i,{method:"GET",headers:t});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const r=ge(e.baseUrl,"/api/detectionpolicy/alerts/Log"),i={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return ve(r,{method:"POST",headers:t,body:JSON.stringify(i)})},async getAdminSettings(){const s=ge(e.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),r=await ve(s,{method:"GET",headers:t});if(r&&typeof r=="object"){if("data"in r)return r.data;if("userId"in r)return r}return null},async setAdminSettings(s){const r=ge(e.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),i={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??""};return ve(r,{method:"POST",headers:t,body:JSON.stringify(i)})},async getPreferenceSettings(){const s=ge(e.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),r=await ve(s,{method:"GET",headers:t});if(r&&typeof r=="object"){if("data"in r)return r.data;if("anomalyIds"in r)return r}return null},async setPreferenceSettings(s){const r=ge(e.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),i=u=>{const{hours:d,minutes:N,seconds:m}=Wt(u);return(d*3600+N*60+m)*1e7},a={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(u=>String(u)):[],DoNotDisturbStart:{Ticks:i(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:i(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},o=await ve(r,{method:"POST",headers:t,body:JSON.stringify(a)}),l=o?.responseStatus??!0,f=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:l,errorMessage:l?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:f}},async getAlertNotifications(s){const r=ge(e.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),i=Tt(r,{alertId:s}),a=await ve(i,{method:"GET",headers:t});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]}}}function _s(){try{const e=localStorage.getItem("authToken");return e?{Authorization:`Bearer ${e}`}:{}}catch{return{}}}async function Ne(e,t){const s={...t.headers,..._s()},r=await fetch(e,{...t,headers:s});if(r.status===401)throw window.location.href="/login",new Error("Unauthorized");if(r.status===204)return{};const i=await r.text();let a={};if(i)try{a=JSON.parse(i)}catch{a={ok:r.ok,status:r.status,raw:i}}if(!r.ok){const o=a?.errorMessage||a?.message||`HTTP ${r.status}`;throw new Error(o)}return a}function Hs(e){const t={"Content-Type":"application/json",...e.headers||{}},s=new URL("/api/detectionpolicy/rules",e.baseUrl).toString();return{async getRules(){const r=await Ne(s,{method:"GET",headers:t});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Ne(s,{method:"POST",headers:t,body:JSON.stringify(r??{})})},async getLookups(){const r=F=>new URL(F,e.baseUrl).toString(),i=[Ne(r("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:t}),Ne(r("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:t}),Ne(r("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:t}),Ne(r("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:t}),Ne(r("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:t})],[a,o,l,f,u]=await Promise.allSettled(i),d=F=>F.status==="fulfilled"&&Array.isArray(F.value)?F.value:[],N=d(a),m=d(o),k=d(l),w=d(f),y=d(u),S=N.map(F=>({actionTypeId:Number(F?.ActionTypeId),name:F?.DisplayName??F?.Name??""})),L=m.map(F=>({recordId:F?.AnomalyId,anomalyName:F?.DisplayName??F?.Name??""})),U=k.map(F=>({thirdPartyId:Number(F?.ThirdPartyId),thirdPartyName:F?.ThirdPartyName??F?.Name??""})),$={actionTypes:S,anomalies:L,thirdParties:U};return w.length&&($.severities=w),y.length&&($.scheduleTypes=y),$},async updateRule(r,i){const a=`${s}/${r}`;return Ne(a,{method:"PUT",headers:t,body:JSON.stringify(i??{})})}}}const Kt=h.createContext(null);function Yt({tenant:e="snl",override:t,children:s}){const r=h.useMemo(()=>{const a=t?.alertsBaseUrl&&t.alertsBaseUrl.trim()||wt[e]?.alerts||"";let o=t?.rulesBaseUrl&&t.rulesBaseUrl.trim()||wt[e]?.rules||"";e==="snl"&&(o=a);const l=t?.headers;return{tenant:e,alertsBaseUrl:a,rulesBaseUrl:o,headers:l}},[e,t?.alertsBaseUrl,t?.rulesBaseUrl,JSON.stringify(t?.headers||{})]),i=h.useMemo(()=>{const a=r.tenant==="schools"?Qs({baseUrl:r.alertsBaseUrl,headers:r.headers}):Es({baseUrl:r.alertsBaseUrl,headers:r.headers}),o=r.tenant==="schools"?Hs({baseUrl:r.rulesBaseUrl,headers:r.headers}):Ms({baseUrl:r.alertsBaseUrl,headers:r.headers});return{config:r,alerts:a,rules:o}},[r]);return n.jsx(Kt.Provider,{value:i,children:s})}function he(){const e=h.useContext(Kt);if(!e)throw new Error("useApi must be used inside ApiProvider");return e}const Gs={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Ws={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},it=6,at=7;function Ks(e,t,s){const r=e===it,i=e===at,a=t.isEmailSent,o=t.isSMSSent,l=r&&a||i&&o,f=r?"Send Email":i?"Send SMS":s,u=r&&a?"Email already sent":i&&o?"SMS already sent":`Click to ${f.toLowerCase()}`;return{isDisabled:l,buttonText:f,tooltipTitle:u}}function Ys(e){const t=new Set;(e||[]).forEach(r=>{const i=r.anomalyName;typeof i=="string"&&i.trim().length>0&&t.add(i.trim())});const s=Array.from(t).map(r=>({label:r,value:r}));return[{label:"All Types",value:"All"},...s]}function zs(e){const t=new Set;(e||[]).forEach(r=>{const i=r.spaceName;typeof i=="string"&&i.trim().length>0&&t.add(i.trim())});const s=Array.from(t).map(r=>({label:r,value:r}));return[{label:"All",value:"All"},...s]}function Rt(e,t){return`${e}-${t?"email":"sms"}`}function kt(e){return e===it||e===at}function He({value:e,onChange:t,options:s,className:r,dropdownWidth:i}){return n.jsx(c.Select,{className:r,options:s,value:e,onChange:t,dropdownMatchSelectWidth:i??260})}const Vs=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Js({value:e,onChange:t,options:s}){return n.jsx(He,{className:"w-[140px]",value:e,onChange:t,options:s||Vs})}const Xs=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function Zs({value:e,onChange:t,options:s}){return n.jsx(He,{className:"w-[220px]",dropdownWidth:280,value:e,onChange:t,options:s||Xs})}function er({value:e,onChange:t,options:s}){return n.jsx(He,{className:"w-[100px]",value:e,onChange:t,options:s||[]})}const tr=[{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 sr({value:e,onChange:t,options:s}){return n.jsx(He,{className:"w-[130px]",value:e,onChange:t,options:s||tr})}function zt({columns:e,data:t,loading:s=!1,pageSize:r=10,rowKey:i="id",toolbar:a,tableProps:o}){return n.jsxs("div",{children:[a,n.jsx(c.Table,{rowKey:i,dataSource:t,columns:e,loading:s,pagination:{pageSize:r,showSizeChanger:!0,showTotal:l=>`Total: ${l}`},bordered:!0,...o})]})}function ot({data:e,loading:t=!1,pageSize:s=10,columns:r,severityOptions:i,spaceOptions:a,renderActions:o,onAlertIdClick:l,onRefetch:f,excludeCompleted:u=!0}){const[d,N]=h.useState("All"),[m,k]=h.useState("All"),[w,y]=h.useState("All"),[S,L]=h.useState("All"),[U,$]=h.useState(""),[F,K]=h.useState([{label:"All",value:"All"}]),[V,H]=h.useState(new Set),{rules:G,alerts:I}=he(),j={6:{title:"Email",kind:"icon",icon:n.jsx(Ee.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:n.jsx(Ee.MessageOutlined,{})}},T=h.useMemo(()=>Ys(e),[e]),te=h.useMemo(()=>zs(e),[e]);h.useEffect(()=>{let x=!0;return(async()=>{try{const b=await G.getLookups(),D=(Array.isArray(b.thirdParties)?b.thirdParties:[]).map(P=>({label:P.thirdPartyName,value:String(P.thirdPartyId)}));x&&K([{label:"All",value:"All"},...D])}catch(b){console.error("Error loading third party options",b)}})(),()=>{x=!1}},[G]);const ee=h.useMemo(()=>(e||[]).some(x=>ze(x).length>0),[e]),R=h.useMemo(()=>(e||[]).filter(x=>{const b=d==="All"||x.priority===d,O=`${x.id} ${x.description} ${x.statusType}`.toLowerCase(),D=!U||O.includes(U.toLowerCase()),P=m==="All"||(x.anomalyName||"").toLowerCase()===m.toLowerCase(),B=w==="All"||(x.spaceName||"").toLowerCase()===w.toLowerCase(),q=!ee||S==="All"||ze(x).includes(Number(S)),Y=!u||String(x.statusType||"").toLowerCase()!=="completed";return b&&D&&P&&B&&q&&Y}),[e,d,U,m,w,S,ee,u]),v=T,p=a&&a.length?a:te,A=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:x=>n.jsx(c.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ws[x]}`,backgroundColor:Gs[x]},children:x})},{title:"Tracker",key:"tracker",width:140,render:(x,b)=>n.jsx("a",{onClick:O=>{O.preventDefault(),l?.(b,{tab:"track"})},className:"text-blue-600 hover:underline",children:"Tracker"})},{title:"Call to action/Human in the loop",key:"actions",width:320,render:(x,b)=>{if(o)return n.jsx(n.Fragment,{children:o(b)});const O=ze(b);if(!O.length)return null;const D=async(P,B)=>{const q=Rt(b.id,P);H(Y=>new Set(Y).add(q));try{const Y=await I.sendSMSorEmailNotifications?.(b.id,P,B);Y?.responseStatus?(re.toast.success(Y.data||(P?"Email sent successfully":"SMS sent successfully")),f?.()):re.toast.error(Y?.data||Y?.errorMessage||"Failed to send notification")}catch(Y){re.toast.error(Y?.message||"Failed to send notification")}finally{H(Y=>{const ne=new Set(Y);return ne.delete(q),ne})}};return n.jsx(c.Space,{size:"middle",children:O.map(P=>{const B=j[P];if(!B)return null;const q=P===it,Y=P===at,{isDisabled:ne,buttonText:ue,tooltipTitle:oe}=Ks(P,b,B.title),se=Rt(b.id,q),C=kt(P)&&V.has(se),_=()=>{D(q,Y)};return n.jsx(c.Tooltip,{title:oe,children:n.jsx(c.Button,{size:"small",disabled:ne,loading:C,onClick:kt(P)?_:void 0,icon:!C&&(B.kind==="img"&&B.src?n.jsx("img",{src:B.src,alt:B.alt||B.title}):B.icon),className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:ue})},P)})})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(x,b)=>{const O=b?.timeElapsed,D=b?.timeRemaining,P=O?Nt(O):0,B=D?Nt(D):0,q=Math.round(P/(P+B)*100);return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),n.jsx("span",{className:"font-medium",children:O??"-"})]}),n.jsx(c.Progress,{percent:q,showInfo:!1,size:"small",strokeColor:Is(b.priority)}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"w-[70px]",children:"Remaining"}),n.jsx("span",{className:"font-medium",children:D??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(x,b)=>n.jsxs("div",{children:[n.jsx("a",{onClick:O=>{O.preventDefault(),l?.(b)},className:"inline-block mb-1 text-blue-600",children:b.alertNumber}),n.jsx("div",{className:"text-black/65",children:x})]})}],g=r&&r.length?r:A;return n.jsx("div",{children:n.jsx(zt,{rowKey:"id",data:R,columns:g,loading:t,pageSize:s,toolbar:n.jsxs(c.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[n.jsx(c.Col,{flex:"none",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{children:"Severity"}),n.jsx(Js,{value:d,onChange:N,options:i})]})}),n.jsx(c.Col,{flex:"none",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{children:"Anomaly type"}),n.jsx(Zs,{value:m,onChange:k,options:v})]})}),n.jsx(c.Col,{flex:"none",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{children:"Space"}),n.jsx(er,{value:w,onChange:y,options:p})]})}),n.jsx(c.Col,{flex:"none",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{children:"Action Taken"}),n.jsx(sr,{value:S,onChange:L,options:F})]})}),n.jsx(c.Col,{flex:"auto"}),n.jsx(c.Col,{flex:"none",children:n.jsx(c.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:$,onChange:x=>$(x.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}var Pe=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},rr={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nr=class{#e=rr;#t=!1;setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&this.#t&&e!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:e}),this.#e=e,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},Ie=new nr;function ir(e){setTimeout(e,0)}var Te=typeof window>"u"||"Deno"in globalThis;function ce(){}function ar(e,t){return typeof e=="function"?e(t):e}function Je(e){return typeof e=="number"&&e>=0&&e!==1/0}function Vt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function we(e,t){return typeof e=="function"?e(t):e}function de(e,t){return typeof e=="function"?e(t):e}function Ot(e,t){const{type:s="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=e;if(o){if(r){if(t.queryHash!==lt(o,t.options))return!1}else if(!Me(t.queryKey,o))return!1}if(s!=="all"){const f=t.isActive();if(s==="active"&&!f||s==="inactive"&&f)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||i&&i!==t.state.fetchStatus||a&&!a(t))}function Et(e,t){const{exact:s,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(s){if(Re(t.options.mutationKey)!==Re(a))return!1}else if(!Me(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function lt(e,t){return(t?.queryKeyHashFn||Re)(e)}function Re(e){return JSON.stringify(e,(t,s)=>Ze(s)?Object.keys(s).sort().reduce((r,i)=>(r[i]=s[i],r),{}):s)}function Me(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>Me(e[s],t[s])):!1}var or=Object.prototype.hasOwnProperty;function Xe(e,t){if(e===t)return e;const s=Pt(e)&&Pt(t);if(!s&&!(Ze(e)&&Ze(t)))return t;const i=(s?e:Object.keys(e)).length,a=s?t:Object.keys(t),o=a.length,l=s?new Array(o):{};let f=0;for(let u=0;u<o;u++){const d=s?u:a[u],N=e[d],m=t[d];if(N===m){l[d]=N,(s?u<i:or.call(e,d))&&f++;continue}if(N===null||m===null||typeof N!="object"||typeof m!="object"){l[d]=m;continue}const k=Xe(N,m);l[d]=k,k===N&&f++}return i===o&&f===i?e:l}function qe(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Pt(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ze(e){if(!Mt(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!Mt(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Mt(e){return Object.prototype.toString.call(e)==="[object Object]"}function lr(e){return new Promise(t=>{Ie.setTimeout(t,e)})}function et(e,t,s){if(typeof s.structuralSharing=="function")return s.structuralSharing(e,t);if(s.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Xe(e,t)}catch(r){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}]: ${r}`),r}return Xe(e,t)}return t}function cr(e,t,s=0){const r=[...e,t];return s&&r.length>s?r.slice(1):r}function ur(e,t,s=0){const r=[t,...e];return s&&r.length>s?r.slice(0,-1):r}var Qe=Symbol();function Jt(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Qe&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Qe?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ct(e,t){return typeof e=="function"?e(...t):!!e}function dr(e,t,s){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?s():i.addEventListener("abort",s,{once:!0})),i)}),e}var hr=class extends Pe{#e;#t;#s;constructor(){super(),this.#s=e=>{if(!Te&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#s=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},ut=new hr;function tt(){let e,t;const s=new Promise((i,a)=>{e=i,t=a});s.status="pending",s.catch(()=>{});function r(i){Object.assign(s,i),delete s.resolve,delete s.reject}return s.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},s.reject=i=>{r({status:"rejected",reason:i}),t(i)},s}var fr=ir;function mr(){let e=[],t=0,s=l=>{l()},r=l=>{l()},i=fr;const a=l=>{t?e.push(l):i(()=>{s(l)})},o=()=>{const l=e;e=[],l.length&&i(()=>{r(()=>{l.forEach(f=>{s(f)})})})};return{batch:l=>{let f;t++;try{f=l()}finally{t--,t||o()}return f},batchCalls:l=>(...f)=>{a(()=>{l(...f)})},schedule:a,setNotifyFunction:l=>{s=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var ie=mr(),pr=class extends Pe{#e=!0;#t;#s;constructor(){super(),this.#s=e=>{if(!Te&&window.addEventListener){const t=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#s=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(s=>{s(e)}))}isOnline(){return this.#e}},_e=new pr;function yr(e){return Math.min(1e3*2**e,3e4)}function Xt(e){return(e??"online")==="online"?_e.isOnline():!0}var st=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Zt(e){let t=!1,s=0,r;const i=tt(),a=()=>i.status!=="pending",o=y=>{if(!a()){const S=new st(y);m(S),e.onCancel?.(S)}},l=()=>{t=!0},f=()=>{t=!1},u=()=>ut.isFocused()&&(e.networkMode==="always"||_e.isOnline())&&e.canRun(),d=()=>Xt(e.networkMode)&&e.canRun(),N=y=>{a()||(r?.(),i.resolve(y))},m=y=>{a()||(r?.(),i.reject(y))},k=()=>new Promise(y=>{r=S=>{(a()||u())&&y(S)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),w=()=>{if(a())return;let y;const S=s===0?e.initialPromise:void 0;try{y=S??e.fn()}catch(L){y=Promise.reject(L)}Promise.resolve(y).then(N).catch(L=>{if(a())return;const U=e.retry??(Te?0:3),$=e.retryDelay??yr,F=typeof $=="function"?$(s,L):$,K=U===!0||typeof U=="number"&&s<U||typeof U=="function"&&U(s,L);if(t||!K){m(L);return}s++,e.onFail?.(s,L),lr(F).then(()=>u()?void 0:k()).then(()=>{t?m(L):w()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:f,canStart:d,start:()=>(d()?w():k().then(w),i)}}var es=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Je(this.gcTime)&&(this.#e=Ie.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Te?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Ie.clearTimeout(this.#e),this.#e=void 0)}},gr=class extends es{#e;#t;#s;#n;#r;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#n=e.client,this.#s=this.#n.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Ft(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=Ft(this.options);t.data!==void 0&&(this.setState(Dt(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(e,t){const s=et(this.state.data,e,this.options);return this.#i({data:s,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),s}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#r?.promise;return this.#r?.cancel(e),t?t.then(ce).catch(ce):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>de(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Qe||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>we(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Vt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(e&&this.setOptions(e),!this.options.queryFn){const l=this.observers.find(f=>f.options.queryFn);l&&this.setOptions(l.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,r=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#o=!0,s.signal)})},i=()=>{const l=Jt(this.options,t),u=(()=>{const d={client:this.#n,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(l,u,this):l(u)},o=(()=>{const l={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return r(l),l})();this.options.behavior?.onFetch(o,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#i({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=Zt({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof st&&l.revert&&this.setState({...this.#t,fetchStatus:"idle"}),s.abort()},onFail:(l,f)=>{this.#i({type:"failed",failureCount:l,error:f})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===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(l),this.#s.config.onSuccess?.(l,this),this.#s.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof st){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#i({type:"error",error:l}),this.#s.config.onError?.(l,this),this.#s.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#i(e){const t=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...ts(s.data,this.options),fetchMeta:e.meta??null};case"success":const r={...s,...Dt(e.data,e.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?r:void 0,r;case"error":const i=e.error;return{...s,error:i,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=t(this.state),ie.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:e})})}};function ts(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Xt(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Dt(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ft(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,r=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var vr=class extends Pe{constructor(e,t){super(),this.options=t,this.#e=e,this.#i=null,this.#o=tt(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#s=void 0;#n=void 0;#r;#a;#o;#i;#p;#h;#f;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ut(this.#t,this.options)?this.#d():this.updateResult(),this.#x())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rt(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rt(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#S(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof de(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#A(),this.#t.setOptions(this.options),t._defaulted&&!qe(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&Lt(this.#t,s,this.options,t)&&this.#d(),this.updateResult(),r&&(this.#t!==s||de(this.options.enabled,this.#t)!==de(t.enabled,this.#t)||we(this.options.staleTime,this.#t)!==we(t.staleTime,this.#t))&&this.#y();const i=this.#g();r&&(this.#t!==s||de(this.options.enabled,this.#t)!==de(t.enabled,this.#t)||i!==this.#l)&&this.#v(i)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),s=this.createResult(t,e);return br(this,s)&&(this.#n=s,this.#a=this.options,this.#r=this.#t.state),s}getCurrentResult(){return this.#n}trackResult(e,t){return new Proxy(e,{get:(s,r)=>(this.trackProp(r),t?.(r),r==="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,r))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),s=this.#e.getQueryCache().build(this.#e,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#n))}#d(e){this.#A();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(ce)),t}#y(){this.#b();const e=we(this.options.staleTime,this.#t);if(Te||this.#n.isStale||!Je(e))return;const s=Vt(this.#n.dataUpdatedAt,e)+1;this.#c=Ie.setTimeout(()=>{this.#n.isStale||this.updateResult()},s)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#S(),this.#l=e,!(Te||de(this.options.enabled,this.#t)===!1||!Je(this.#l)||this.#l===0)&&(this.#u=Ie.setInterval(()=>{(this.options.refetchIntervalInBackground||ut.isFocused())&&this.#d()},this.#l))}#x(){this.#y(),this.#v(this.#g())}#b(){this.#c&&(Ie.clearTimeout(this.#c),this.#c=void 0)}#S(){this.#u&&(Ie.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const s=this.#t,r=this.options,i=this.#n,a=this.#r,o=this.#a,f=e!==s?e.state:this.#s,{state:u}=e;let d={...u},N=!1,m;if(t._optimisticResults){const G=this.hasListeners(),I=!G&&Ut(e,t),j=G&&Lt(e,s,t,r);(I||j)&&(d={...d,...ts(u.data,e.options)}),t._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:k,errorUpdatedAt:w,status:y}=d;m=d.data;let S=!1;if(t.placeholderData!==void 0&&m===void 0&&y==="pending"){let G;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(G=i.data,S=!0):G=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,G!==void 0&&(y="success",m=et(i?.data,G,t),N=!0)}if(t.select&&m!==void 0&&!S)if(i&&m===a?.data&&t.select===this.#p)m=this.#h;else try{this.#p=t.select,m=t.select(m),m=et(i?.data,m,t),this.#h=m,this.#i=null}catch(G){this.#i=G}this.#i&&(k=this.#i,m=this.#h,w=Date.now(),y="error");const L=d.fetchStatus==="fetching",U=y==="pending",$=y==="error",F=U&&L,K=m!==void 0,H={status:y,fetchStatus:d.fetchStatus,isPending:U,isSuccess:y==="success",isError:$,isInitialLoading:F,isLoading:F,data:m,dataUpdatedAt:d.dataUpdatedAt,error:k,errorUpdatedAt:w,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>f.dataUpdateCount||d.errorUpdateCount>f.errorUpdateCount,isFetching:L,isRefetching:L&&!U,isLoadingError:$&&!K,isPaused:d.fetchStatus==="paused",isPlaceholderData:N,isRefetchError:$&&K,isStale:dt(e,t),refetch:this.refetch,promise:this.#o,isEnabled:de(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const G=T=>{H.status==="error"?T.reject(H.error):H.data!==void 0&&T.resolve(H.data)},I=()=>{const T=this.#o=H.promise=tt();G(T)},j=this.#o;switch(j.status){case"pending":e.queryHash===s.queryHash&&G(j);break;case"fulfilled":(H.status==="error"||H.data!==j.value)&&I();break;case"rejected":(H.status!=="error"||H.error!==j.reason)&&I();break}}return H}updateResult(){const e=this.#n,t=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#a=this.options,this.#r.data!==void 0&&(this.#f=this.#t),qe(t,e))return;this.#n=t;const s=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#m.size)return!0;const a=new Set(i??this.#m);return this.options.throwOnError&&a.add("error"),Object.keys(this.#n).some(o=>{const l=o;return this.#n[l]!==e[l]&&a.has(l)})};this.#N({listeners:s()})}#A(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#x()}#N(e){ie.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#n)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function xr(e,t){return de(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ut(e,t){return xr(e,t)||e.state.data!==void 0&&rt(e,t,t.refetchOnMount)}function rt(e,t,s){if(de(t.enabled,e)!==!1&&we(t.staleTime,e)!=="static"){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&dt(e,t)}return!1}function Lt(e,t,s,r){return(e!==t||de(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&dt(e,s)}function dt(e,t){return de(t.enabled,e)!==!1&&e.isStaleByTime(we(t.staleTime,e))}function br(e,t){return!qe(e.getCurrentResult(),t)}function $t(e){return{onFetch:(t,s)=>{const r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[];let l={pages:[],pageParams:[]},f=0;const u=async()=>{let d=!1;const N=w=>{dr(w,()=>t.signal,()=>d=!0)},m=Jt(t.options,t.fetchOptions),k=async(w,y,S)=>{if(d)return Promise.reject();if(y==null&&w.pages.length)return Promise.resolve(w);const U=(()=>{const V={client:t.client,queryKey:t.queryKey,pageParam:y,direction:S?"backward":"forward",meta:t.options.meta};return N(V),V})(),$=await m(U),{maxPages:F}=t.options,K=S?ur:cr;return{pages:K(w.pages,$,F),pageParams:K(w.pageParams,y,F)}};if(i&&a.length){const w=i==="backward",y=w?Sr:Bt,S={pages:a,pageParams:o},L=y(r,S);l=await k(S,L,w)}else{const w=e??a.length;do{const y=f===0?o[0]??r.initialPageParam:Bt(r,l);if(f>0&&y==null)break;l=await k(l,y),f++}while(f<w)}return l};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s):t.fetchFn=u}}}function Bt(e,{pages:t,pageParams:s}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,s[r],s):void 0}function Sr(e,{pages:t,pageParams:s}){return t.length>0?e.getPreviousPageParam?.(t[0],t,s[0],s):void 0}var Ar=class extends es{#e;#t;#s;#n;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#s=e.mutationCache,this.#t=[],this.state=e.state||ss(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#s.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#r({type:"continue"})},s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#n=Zt({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#r({type:"failed",failureCount:a,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const r=this.state.status==="pending",i=!this.#n.canStart();try{if(r)t();else{this.#r({type:"pending",variables:e,isPaused:i}),await this.#s.config.onMutate?.(e,this,s);const o=await this.options.onMutate?.(e,s);o!==this.state.context&&this.#r({type:"pending",context:o,variables:e,isPaused:i})}const a=await this.#n.start();return await this.#s.config.onSuccess?.(a,e,this.state.context,this,s),await this.options.onSuccess?.(a,e,this.state.context,s),await this.#s.config.onSettled?.(a,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(a,null,e,this.state.context,s),this.#r({type:"success",data:a}),a}catch(a){try{await this.#s.config.onError?.(a,e,this.state.context,this,s)}catch(o){Promise.reject(o)}try{await this.options.onError?.(a,e,this.state.context,s)}catch(o){Promise.reject(o)}try{await this.#s.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,s)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,a,e,this.state.context,s)}catch(o){Promise.reject(o)}throw this.#r({type:"error",error:a}),a}finally{this.#s.runNext(this)}}#r(e){const t=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ie.batch(()=>{this.#t.forEach(s=>{s.onMutationUpdate(e)}),this.#s.notify({mutation:this,type:"updated",action:e})})}};function ss(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Nr=class extends Pe{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#s=0}#e;#t;#s;build(e,t,s){const r=new Ar({client:e,mutationCache:this,mutationId:++this.#s,options:e.defaultMutationOptions(t),state:s});return this.add(r),r}add(e){this.#e.add(e);const t=Le(e);if(typeof t=="string"){const s=this.#t.get(t);s?s.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=Le(e);if(typeof t=="string"){const s=this.#t.get(t);if(s)if(s.length>1){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}else s[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Le(e);if(typeof t=="string"){const r=this.#t.get(t)?.find(i=>i.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=Le(e);return typeof t=="string"?this.#t.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ie.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(s=>Et(t,s))}findAll(e={}){return this.getAll().filter(t=>Et(e,t))}notify(e){ie.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ie.batch(()=>Promise.all(e.map(t=>t.continue().catch(ce))))}};function Le(e){return e.options.scope?.id}var wr=class extends Pe{#e;#t=void 0;#s;#n;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#e.defaultMutationOptions(e),qe(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),t?.mutationKey&&this.options.mutationKey&&Re(t.mutationKey)!==Re(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#r(),this.#a()}mutate(e,t){return this.#n=t,this.#s?.removeObserver(this),this.#s=this.#e.getMutationCache().build(this.#e,this.options),this.#s.addObserver(this),this.#s.execute(e)}#r(){const e=this.#s?.state??ss();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){ie.batch(()=>{if(this.#n&&this.hasListeners()){const t=this.#t.variables,s=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#n.onSuccess?.(e.data,t,s,r)}catch(i){Promise.reject(i)}try{this.#n.onSettled?.(e.data,null,t,s,r)}catch(i){Promise.reject(i)}}else if(e?.type==="error"){try{this.#n.onError?.(e.error,t,s,r)}catch(i){Promise.reject(i)}try{this.#n.onSettled?.(void 0,e.error,t,s,r)}catch(i){Promise.reject(i)}}}this.listeners.forEach(t=>{t(this.#t)})})}},jr=class extends Pe{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,s){const r=t.queryKey,i=t.queryHash??lt(r,t);let a=this.get(i);return a||(a=new gr({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ie.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(s=>Ot(t,s))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(s=>Ot(e,s)):t}notify(e){ie.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ie.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ie.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Cr=class{#e;#t;#s;#n;#r;#a;#o;#i;constructor(e={}){this.#e=e.queryCache||new jr,this.#t=e.mutationCache||new Nr,this.#s=e.defaultOptions||{},this.#n=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ut.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=_e.subscribe(async e=>{e&&(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(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=this.#e.build(this,t),r=s.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(we(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:s})=>{const r=s.data;return[t,r]})}setQueryData(e,t,s){const r=this.defaultQueryOptions({queryKey:e}),a=this.#e.get(r.queryHash)?.state.data,o=ar(t,a);if(o!==void 0)return this.#e.build(this,r).setData(o,{...s,manual:!0})}setQueriesData(e,t,s){return ie.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,s)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;ie.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=this.#e;return ie.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},r=ie.batch(()=>this.#e.findAll(e).map(i=>i.cancel(s)));return Promise.all(r).then(ce).catch(ce)}invalidateQueries(e,t={}){return ie.batch(()=>(this.#e.findAll(e).forEach(s=>{s.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},r=ie.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,s);return s.throwOnError||(a=a.catch(ce)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(ce)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=this.#e.build(this,t);return s.isStaleByTime(we(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ce).catch(ce)}fetchInfiniteQuery(e){return e.behavior=$t(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ce).catch(ce)}ensureInfiniteQueryData(e){return e.behavior=$t(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return _e.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#s}setDefaultOptions(e){this.#s=e}setQueryDefaults(e,t){this.#n.set(Re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#n.values()],s={};return t.forEach(r=>{Me(e,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(e,t){this.#r.set(Re(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#r.values()],s={};return t.forEach(r=>{Me(e,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#s.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=lt(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Qe&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#s.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},rs=le.createContext(void 0),ht=e=>{const t=le.useContext(rs);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Ir=({client:e,children:t})=>(le.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),n.jsx(rs.Provider,{value:e,children:t})),ns=le.createContext(!1),Tr=()=>le.useContext(ns);ns.Provider;function Rr(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kr=le.createContext(Rr()),Or=()=>le.useContext(kr),Er=(e,t,s)=>{const r=s?.state.error&&typeof e.throwOnError=="function"?ct(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Pr=e=>{le.useEffect(()=>{e.clearReset()},[e])},Mr=({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ct(s,[e.error,r])),Dr=e=>{if(e.suspense){const s=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>s(r(...i)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Fr=(e,t)=>e.isLoading&&e.isFetching&&!t,Ur=(e,t)=>e?.suspense&&t.isPending,qt=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Lr(e,t,s){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))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 r=Tr(),i=Or(),a=ht(),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=a.getQueryCache().get(o.queryHash);process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.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`)),o._optimisticResults=r?"isRestoring":"optimistic",Dr(o),Er(o,i,l),Pr(i);const f=!a.getQueryCache().get(o.queryHash),[u]=le.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),N=!r&&e.subscribed!==!1;if(le.useSyncExternalStore(le.useCallback(m=>{const k=N?u.subscribe(ie.batchCalls(m)):ce;return u.updateResult(),k},[u,N]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),le.useEffect(()=>{u.setOptions(o)},[o,u]),Ur(o,d))throw qt(o,u,i);if(Mr({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!Te&&Fr(d,r)&&(f?qt(o,u,i):l?.promise)?.catch(ce).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function ft(e,t){return Lr(e,vr)}function $r(e,t){const s=ht(),[r]=le.useState(()=>new wr(s,e));le.useEffect(()=>{r.setOptions(e)},[r,e]);const i=le.useSyncExternalStore(le.useCallback(o=>r.subscribe(ie.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=le.useCallback((o,l)=>{r.mutate(o,l).catch(ce)},[r]);if(i.error&&ct(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function mt(){const{alerts:e}=he(),t=ht();return $r({mutationFn:s=>e.updateAlertStatus(s),onSuccess:()=>{t.invalidateQueries({queryKey:["alerts","list"]}),t.invalidateQueries({queryKey:["alerts","report"]})}})}function Br(e,t){return e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:t})}function qr(e,t){try{const i=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"}).formatToParts(e).find(o=>o.type==="timeZoneName")?.value;let a;try{const l=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"shortOffset"}).formatToParts(e).find(f=>f.type==="timeZoneName");l?.value&&l.value.startsWith("GMT")&&(a=l.value.replace("GMT",""))}catch{}return{abbr:i,offset:a}}catch{return{}}}function Qr(e){if(!e)return"-";try{const t=new Date(e),s=u=>String(u).padStart(2,"0"),r=s(t.getMonth()+1),i=s(t.getDate()),a=t.getFullYear(),o=s(t.getHours()),l=s(t.getMinutes()),f=s(t.getSeconds());return`${r}/${i}/${a} ${o}:${l}:${f}`}catch{return"-"}}function nt(e){if(!e)return"-";try{return new Date(e).toLocaleString("en-US",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"-"}}const _r={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Hr={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function is({alerts:e,loading:t=!1,pageSize:s=10,completedStatus:r="Completed",severityOptions:i,anomalyOptions:a,spaceOptions:o,onAlertIdClick:l}){const f=mt(),u=async m=>{try{const k=await f.mutateAsync({alertUniqueId:m.alertId??m.id,alertId:m.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(k?.responseStatus){const w=k?.data||"Alert reopened successfully.";re.toast.success(w)}else{const w=k?.errorMessage||"Failed to reopen alert";re.toast.error(w)}}catch{re.toast.error("Failed to reopen alert. Please try again.")}},d=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:m=>n.jsx(c.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${_r[m]}`,backgroundColor:Hr[String(m)]},children:m})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:m=>Qr(m)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(m,k)=>n.jsxs("div",{children:[n.jsx("a",{onClick:w=>{w.preventDefault(),l?.(k)},className:"inline-block mb-1 text-blue-600",children:k.alertNumber}),n.jsx("div",{className:"text-black/65",children:m})]})},{title:"",key:"menu",width:60,align:"right",render:(m,k)=>n.jsx(c.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:w})=>{w==="reopen"&&u(k)}},children:n.jsx(c.Button,{type:"text",icon:n.jsx(Ee.MoreOutlined,{})})})}],N=(e||[]).filter(m=>(m.statusType||"").toLowerCase()===r.toLowerCase());return n.jsx(ot,{data:N,loading:t,pageSize:s,columns:d,severityOptions:i,anomalyOptions:a,spaceOptions:o,renderActions:void 0,onAlertIdClick:l,excludeCompleted:!1})}function Gr({size:e=120,time:t,timeZone:s="America/New_York"}){const{hours:r,minutes:i,seconds:a}=h.useMemo(()=>{const N=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(t);return{hours:parseInt(N.find(m=>m.type==="hour")?.value||"0",10),minutes:parseInt(N.find(m=>m.type==="minute")?.value||"0",10),seconds:parseInt(N.find(m=>m.type==="second")?.value||"0",10)}},[t,s]),o=a*6,l=i*6+a*.1,f=r%12*30+i*.5,u=e/2;return n.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:e,height:e},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((d,N)=>{const m=N*30,k=6,w=u-4,y=w-k,S=(m-90)*(Math.PI/180),L=u+y*Math.cos(S),U=u+y*Math.sin(S),$=u+w*Math.cos(S),F=u+w*Math.sin(S);return n.jsx("svg",{className:"absolute inset-0",width:e,height:e,children:n.jsx("line",{x1:L,y1:U,x2:$,y2:F,stroke:"#9CA3AF",strokeWidth:N%3===0?2:1,strokeLinecap:"round"})},N)}),n.jsx("svg",{className:"absolute inset-0",width:e,height:e,style:{transform:`rotate(${f}deg)`},children:n.jsx("line",{x1:u,y1:u,x2:u,y2:u-e*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),n.jsx("svg",{className:"absolute inset-0",width:e,height:e,style:{transform:`rotate(${l}deg)`},children:n.jsx("line",{x1:u,y1:u,x2:u,y2:u-e*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),n.jsx("svg",{className:"absolute inset-0",width:e,height:e,style:{transform:`rotate(${o}deg)`},children:n.jsx("line",{x1:u,y1:u+e*.08,x2:u,y2:u-e*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),n.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:u-4,top:u-4}})]})}function as({label:e="USA",timeZone:t="America/New_York",updateIntervalMs:s=1e3,className:r}){const[i,a]=h.useState(new Date);h.useEffect(()=>{const u=setInterval(()=>a(new Date),s);return()=>clearInterval(u)},[s]);const o=h.useMemo(()=>Br(i,t),[i,t]),{abbr:l,offset:f}=h.useMemo(()=>qr(i,t),[i,t]);return n.jsxs("div",{className:`flex items-center gap-3 ${r||""}`,children:[n.jsx(Gr,{time:i,timeZone:t,size:80}),n.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[n.jsx("span",{className:"uppercase",children:e}),l&&n.jsx("span",{className:"px-1.5 py-0.5 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:l}),f&&n.jsx("span",{className:"text-xs text-gray-500",children:f})]}),n.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const Wr=[{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}],Kr=[{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"}],Yr=[{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"}],Oe={severities:Wr,rules:Kr,userRoles:Yr},{Text:zr}=c.Typography;function Vr({sortBy:e,onChange:t,showActions:s,onSave:r,onClear:i,saving:a}){return n.jsxs(c.Row,{gutter:[16,16],align:"middle",children:[n.jsx(c.Col,{xs:24,md:8,lg:5,children:n.jsxs(c.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[n.jsx(zr,{className:"text-gray-600",children:"Sort by:"}),n.jsx(c.Select,{placeholder:"By Severity",value:e,onChange:o=>t({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),n.jsx(c.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?n.jsxs(c.Space,{className:"w-full",direction:"horizontal",size:8,children:[n.jsx(c.Button,{onClick:i,disabled:a,children:"Clear"}),n.jsx(c.Button,{type:"primary",onClick:r,loading:a,children:"Save"})]}):null})]})}const{Text:xe}=c.Typography;function Jr(e){const{selectedRule:t,setSelectedRule:s,ruleOptions:r,minsOptions:i,roleOptions:a,l1mins:o,setL1mins:l,l1role:f,setL1role:u,l2mins:d,setL2mins:N,l2role:m,setL2role:k,l3mins:w,setL3mins:y,l3role:S,setL3role:L,actions:U,setActions:$,thirdPartyIds:F,setThirdPartyIds:K,humanLoop:V,setHumanLoop:H,onClear:G,onSave:I,saving:j,onActionTypesLoaded:T}=e,{rules:te}=he(),[ee,R]=h.useState([]),[v,p]=h.useState([]),[A,g]=h.useState(!1);h.useEffect(()=>{let O=!1;return(async()=>{try{g(!0);const D=await te.getLookups();if(O||!D||!Array.isArray(D.actionTypes))return;const P=D.actionTypes.map(q=>({label:q.name,value:String(q.actionTypeId)}));R(P),T&&T(D.actionTypes);const B=Array.isArray(D.thirdParties)?D.thirdParties.map(q=>({label:q.thirdPartyName,value:q.thirdPartyId})):[];p(B)}catch(D){console.error("Error loading lookups",D)}finally{O||g(!1)}})(),()=>{O=!0}},[]);const x=typeof o=="number"||typeof f=="number"||typeof d=="number"||typeof m=="number"||typeof w=="number"||typeof S=="number"||Array.isArray(U)&&U.length>0||Array.isArray(F)&&F.length>0||!!V,b=!!t&&x&&!j;return n.jsxs(c.Spin,{spinning:!!j||A,children:[n.jsxs(c.Row,{gutter:[16,16],align:"bottom",children:[n.jsx(c.Col,{xs:24,sm:12,md:8,lg:4,children:n.jsxs("div",{children:[n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),n.jsx(c.Select,{placeholder:"Rules",value:t,onChange:s,options:r,className:"w-full"})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,lg:4,children:n.jsxs("div",{children:[n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),n.jsx(c.Col,{span:14,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(c.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:l,options:i})}),n.jsx(c.Col,{span:14,children:n.jsx(c.Select,{placeholder:"Escalate to",className:"w-full",value:f,onChange:u,options:a})})]})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,lg:4,children:n.jsxs("div",{children:[n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),n.jsx(c.Col,{span:14,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(c.Select,{className:"w-full",placeholder:"Mins",value:d,onChange:N,options:i})}),n.jsx(c.Col,{span:14,children:n.jsx(c.Select,{placeholder:"Escalate to",className:"w-full",value:m,onChange:k,options:a})})]})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,lg:4,children:n.jsxs("div",{children:[n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),n.jsx(c.Col,{span:14,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(c.Select,{className:"w-full",placeholder:"Mins",value:w,onChange:y,options:i})}),n.jsx(c.Col,{span:14,children:n.jsx(c.Select,{placeholder:"Escalate to",className:"w-full",value:S,onChange:L,options:a})})]})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,lg:5,children:n.jsxs("div",{children:[n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),n.jsx(c.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:U,onChange:$,options:ee})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,lg:3,children:n.jsx("div",{className:"flex items-end h-full",children:n.jsx(c.Checkbox,{checked:V,onChange:O=>H(O.target.checked),children:"Human-In-The-Loop"})})})]}),n.jsxs(c.Row,{gutter:[16,16],align:"bottom",className:"mt-4",children:[n.jsx(c.Col,{xs:24,sm:12,md:8,lg:5,children:n.jsxs("div",{children:[n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Third Party App"}),n.jsx(c.Select,{mode:"multiple",placeholder:"Third Party app",className:"w-full",value:F,onChange:K,options:v})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(c.Button,{onClick:G,children:"Clear"}),n.jsx(c.Button,{type:"primary",onClick:I,loading:!!j,disabled:!b,children:"Save"})]})})]})]})}function Xr({entries:e,userRoles:t,onEdit:s,loading:r}){const i=new Map(t.map(o=>[o.userRoleId,o.userRoleName])),a=o=>o.map(l=>i.get(l)||String(l)).join(", ");return n.jsx(c.Table,{rowKey:"id",dataSource:e,pagination:!1,loading:r,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(o,l)=>n.jsxs("span",{children:[l.l1.minutes?`Action taken in (${l.l1.minutes} Mins)`:"No Action taken in 0 Min",l.l1.roles?.length?`, Escalate to (${a(l.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(o,l)=>n.jsxs("span",{children:[l.l2.minutes?`Action taken in (${l.l2.minutes} Mins)`:"No Action taken in 0 Min",l.l2.roles?.length?`, Escalate to (${a(l.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(o,l)=>n.jsxs("span",{children:[l.l3.minutes?`Action taken in (${l.l3.minutes} Mins)`:"No Action taken in 0 Min",l.l3.roles?.length?`, Escalate to (${a(l.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(o,l)=>l.actions&&l.actions.length?l.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(o,l)=>l.notify&&l.notify.length?l.notify.join(", "):"-"},{title:"Human-In-The-Loop",key:"humanLoop",render:(o,l)=>l.humanLoop?"Yes":"No"},{title:"Actions",key:"ops",render:(o,l)=>n.jsx(c.Button,{type:"text",onClick:()=>s(l.id),children:n.jsx(Ee.EditOutlined,{})})}]})}const{Title:Zr}=c.Typography;function os({userRoles:e,rules:t,rawRules:s}){const{rules:r}=he(),[i,a]=h.useState(!1),[o,l]=h.useState(s),[f,u]=h.useState({}),d=h.useMemo(()=>e.map(y=>({label:y.userRoleName,value:y.userRoleId})),[e]),N=h.useMemo(()=>(t||[]).map((y,S)=>({key:y.RuleId||y.Name||String(S),ruleName:y.Name||"-",ruleDesc:y.Description||""})),[t]);h.useEffect(()=>{let y=!1;return(async()=>{try{a(!0);const S=await r.getRules();y||(l(Array.isArray(S)?S:[]),u({}))}catch{!y&&Array.isArray(s)&&l(s)}finally{y||a(!1)}})(),()=>{y=!0}},[]),h.useEffect(()=>{!o&&Array.isArray(s)&&l(s)},[s]);const m=h.useMemo(()=>{if(!Array.isArray(o)||!o.length)return{};const y={};for(const S of N){const L=o.find($=>$?.ruleId===S.key||$?.ruleName===S.key||$?.RuleId===S.key||$?.ruleName===S.ruleName||$?.Name===S.ruleName),U=Array.isArray(L?.userRoleIds)?L.userRoleIds:[];U.length&&(y[S.key]=U)}return y},[o,N]),k=()=>{u({})},w=async()=>{try{if(!o||!Array.isArray(o)||Object.keys(f).length===0){re.toast.info("No changes to save");return}a(!0);const y=Object.entries(f).map(async([S,L])=>{const U=o.find(H=>H?.ruleId===S||H?.ruleName===S||H?.RuleId===S),$=typeof U?.recordId=="number"?U.recordId:void 0;if(!U||typeof $!="number")throw new Error(`Unable to find recordId for rule ${S}`);const F=Array.isArray(L)?L:[],K=F.map(H=>{const G=e.find(I=>I.userRoleId===H);return{id:H,name:G?.userRoleName??String(H)}}),V={...U,ruleId:S,userRoleIds:F,userRoles:K,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 r.updateRule($,V)});await Promise.all(y),re.toast.success("Alert assignment saved");try{const S=await r.getRules();l(Array.isArray(S)?S:[]),u({})}catch(S){console.error("Failed to refresh rules after save",S)}}catch(y){console.error("Failed to save alert assignment",y)}finally{a(!1)}};return n.jsxs("div",{className:"w-full",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx(Zr,{level:4,className:"!mb-4",children:"Alert Assignment"})}),n.jsx(c.Table,{rowKey:"key",dataSource:N,loading:i,pagination:!1,columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(y,S)=>n.jsx(c.Select,{mode:"multiple",placeholder:"Dropdown with Multi select",className:"w-full",value:f[S.key]??m[S.key]??[],onChange:L=>u(U=>({...U,[S.key]:L})),options:d})}]}),n.jsxs(c.Space,{className:"mt-4",children:[n.jsx(c.Button,{onClick:k,disabled:i,children:"Clear"}),n.jsx(c.Button,{type:"primary",onClick:w,loading:i,disabled:i||Object.keys(f).length===0,children:"Save"})]})]})}const{Title:Qt}=c.Typography;function ls({severities:e,rules:t,userRoles:s,rawRules:r,onSave:i}){const{rules:a,alerts:o}=he(),[l,f]=h.useState("By Severity"),[u,d]=h.useState("By severity"),[N,m]=h.useState("By Severity"),[k,w]=h.useState(!1),[y,S]=h.useState(!1),[L,U]=h.useState(!1),[$,F]=h.useState(null),[K,V]=h.useState("rules"),[H,G]=h.useState(),[I,j]=h.useState(),[T,te]=h.useState(),[ee,R]=h.useState(),[v,p]=h.useState(),[A,g]=h.useState(),[x,b]=h.useState(),[O,D]=h.useState(),[P,B]=h.useState([]),[q,Y]=h.useState([]),[ne,ue]=h.useState(!1),[oe,se]=h.useState({}),[C,_]=h.useState({}),[z,be]=h.useState(s||[]),[Se,ke]=h.useState([]),[Ge,Ae]=h.useState(!1),[We,yt]=h.useState(!1),[je,gt]=h.useState(r||[]);h.useEffect(()=>{r&&r.length&&gt(r)},[r]),h.useEffect(()=>{if(!je||!je.length)return;const E=Object.keys(oe).length>0||Object.keys(C).length>0;if(Se.length&&!E)return;const X=je.map((Q,M)=>{const J=t.find(ye=>ye.RuleId===(Q.ruleId||Q.ruleName))?.Name||Q.ruleName||Q.Name||"-",W=Q.escalationSettings||{},Z=typeof W.level1UserRoleId=="number"&&W.level1UserRoleId>0?[W.level1UserRoleId]:[],pe=typeof W.level2UserRoleId=="number"&&W.level2UserRoleId>0?[W.level2UserRoleId]:[],Ke=typeof W.level3UserRoleId=="number"&&W.level3UserRoleId>0?[W.level3UserRoleId]:[],xt=(Array.isArray(W.escalationSettingsActionTypeIds)?W.escalationSettingsActionTypeIds:[]).map(ye=>oe[ye]||String(ye)),St=(Array.isArray(W.thirdPartyId)?W.thirdPartyId:[]).map(ye=>C[ye]||String(ye)),Ye=typeof W.humanLoop=="boolean"?W.humanLoop:null;return{id:String(Q.ruleId||Q.ruleName||M),ruleOrSeverityLabel:J,l1:{minutes:W.level1PostAssistTime??void 0,roles:Z},l2:{minutes:W.level2PostAssistTime??void 0,roles:pe},l3:{minutes:W.level3PostAssistTime??void 0,roles:Ke},actions:xt,notify:St,humanLoop:Ye}});ke(X)},[je,t,oe,C]);const fs=h.useMemo(()=>e.map(E=>({label:E.DisplayName,value:E.SeverityId})),[e]),ms=h.useMemo(()=>t.map(E=>({label:E.Name,value:E.RuleId})),[t]),ps=h.useMemo(()=>z.map(E=>({label:E.userRoleName,value:E.userRoleId})),[z]),ys=h.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(E=>({label:`${E}`,value:E})),[]);h.useEffect(()=>{let E=!1;async function X(){try{U(!0),F(null);const Q=await o.getAdminSettings();if(!E&&Q){const M=Gt(Q.sortBy);f(M),m(M),w(!1)}}catch(Q){if(!E){const M=Q instanceof Error?Q.message:"Failed to load admin settings";F(M)}}finally{E||U(!1)}}return X(),()=>{E=!0}},[]),h.useEffect(()=>{if(!I)return;const E=J=>{const W=Number(J);return!isNaN(W)&&W>0?W:void 0},X=J=>{const W=Number(J);return!isNaN(W)&&W>0?W:void 0},M=(je||[]).find(J=>J?.ruleId===I||J?.ruleName===I||J?.RuleId===I)?.escalationSettings;if(M&&typeof M=="object"){te(X(M.level1PostAssistTime)),R(E(M.level1UserRoleId)),p(X(M.level2PostAssistTime)),g(E(M.level2UserRoleId)),b(X(M.level3PostAssistTime)),D(E(M.level3UserRoleId));const J=Array.isArray(M.escalationSettingsActionTypeIds)?M.escalationSettingsActionTypeIds:[];B(J.map(W=>String(W))),Y(Array.isArray(M.thirdPartyId)?M.thirdPartyId:[]),ue(!!M.humanLoop)}},[K,I,je]);const gs=async()=>{try{yt(!0);const E=await a.getRules(),X=Array.isArray(E)?E:Array.isArray(E?.data)?E.data:[];gt(X);const Q=X.map((M,J)=>{const W=t.find(Ce=>Ce.RuleId===(M.ruleId||M.ruleName))?.Name||M.ruleName||M.Name||"-",Z=M.escalationSettings||{},pe=typeof Z.level1UserRoleId=="number"&&Z.level1UserRoleId>0?[Z.level1UserRoleId]:[],Ke=typeof Z.level2UserRoleId=="number"&&Z.level2UserRoleId>0?[Z.level2UserRoleId]:[],vt=typeof Z.level3UserRoleId=="number"&&Z.level3UserRoleId>0?[Z.level3UserRoleId]:[],bt=(Array.isArray(Z.escalationSettingsActionTypeIds)?Z.escalationSettingsActionTypeIds:[]).map(Ce=>oe[Ce]||String(Ce)),Ye=(Array.isArray(Z.thirdPartyId)?Z.thirdPartyId:[]).map(Ce=>C[Ce]||String(Ce)),ye=typeof Z.humanLoop=="boolean"?Z.humanLoop:null;return{id:String(M.ruleId||M.ruleName||J),ruleOrSeverityLabel:W,l1:{minutes:Z.level1PostAssistTime??void 0,roles:pe},l2:{minutes:Z.level2PostAssistTime??void 0,roles:Ke},l3:{minutes:Z.level3PostAssistTime??void 0,roles:vt},actions:bt,notify:Ye,humanLoop:ye}});ke(Q)}catch(E){console.error("Failed to refetch entries",E)}finally{yt(!1)}};h.useEffect(()=>{let E=!1;return(async()=>{try{const X=await a.getLookups();if(E||!X)return;const Q={};if(Array.isArray(X.thirdParties))for(const J of X.thirdParties)typeof J.thirdPartyId=="number"&&(Q[J.thirdPartyId]=J.thirdPartyName);_(Q);const M=Array.isArray(X.userRoles)?X.userRoles.map(J=>({userRoleId:J.userRoleId??J.id,userRoleName:J.userRoleName??J.name})):[];E||be(M.length?M:s||[])}catch(X){console.error("Error loading lookups",X)}})(),()=>{E=!0}},[]);const vs=async()=>{S(!0);try{const E=await o.setAdminSettings({sortBy:l,groupBy:"string"});E?.responseStatus&&E?.data&&re.toast.success(E.data),m(l),w(!1)}catch(E){console.error("Error saving admin settings",E)}finally{S(!1)}},xs=()=>{f(N),w(!1)},bs=async()=>{Ae(!0),i?.({ruleId:I,levels:[{minutes:T,role:ee},{minutes:v,role:A},{minutes:x,role:O}],actions:P,thirdPartyIds:q,humanLoop:ne});try{if(I){const Q=Array.isArray(P)?P.map(pe=>Number(pe)):[],M=(je||[]).find(pe=>pe?.ruleId===I||pe?.ruleName===I||pe?.RuleId===I),J=typeof M?.recordId=="number"?M.recordId:void 0;if(!M||typeof J!="number"){re.toast.error("Unable to find rule recordId for update");return}const W={...M,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:ee??0,level1PostAssistTime:T??0,level2UserRoleId:A??0,level2PostAssistTime:v??0,level3UserRoleId:O??0,level3PostAssistTime:x??0,escalationSettingsActionTypeIds:Q,thirdPartyId:Array.isArray(q)?q:[],humanLoop:ne}},Z=await a.updateRule(J,W);if(Z?.responseStatus||Z?.ok||Z){re.toast.success("Escalation settings saved"),await gs(),j(void 0),te(void 0),R(void 0),p(void 0),g(void 0),b(void 0),D(void 0),B([]),Y([]),ue(!1);return}}}catch(Q){console.error("Error saving escalation settings",Q)}finally{Ae(!1)}const X=t.find(Q=>Q.RuleId===I)?.Name||"-";ke(Q=>[...Q,{id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ruleOrSeverityLabel:X,l1:{minutes:T,roles:ee?[ee]:[]},l2:{minutes:v,roles:A?[A]:[]},l3:{minutes:x,roles:O?[O]:[]},actions:(Array.isArray(P)?P:[]).map(M=>{const J=Number(M);return oe[J]||String(M)}),notify:(Array.isArray(q)?q:[]).map(M=>C[M]||String(M)),humanLoop:!!ne}])},Ss=()=>{f("By Severity"),d("By severity"),V("rules"),G(void 0),j(void 0),te(void 0),R(void 0),p(void 0),g(void 0),b(void 0),D(void 0),B([]),Y([]),ue(!1)};return n.jsxs("div",{className:"w-full",children:[n.jsxs("div",{className:"mb-6",children:[n.jsx(Qt,{level:4,className:"!mb-2",children:"Admin Settings"}),n.jsxs(c.Spin,{spinning:L,children:[$?n.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",$]}):null,n.jsx(Vr,{sortBy:l,groupBy:u,onChange:E=>{E.sortBy&&(f(E.sortBy),w(!0)),E.groupBy&&(d(E.groupBy),w(!0))},showActions:k,onSave:vs,onClear:xs,saving:y})]})]}),n.jsx(c.Divider,{className:"my-6"}),n.jsxs("div",{children:[n.jsx(Qt,{level:4,className:"!mb-4",children:"Escalation Settings"}),n.jsx(Jr,{escBasis:K,setEscBasis:V,selectedSeverity:H,setSelectedSeverity:G,selectedRule:I,setSelectedRule:j,severityOptions:fs,ruleOptions:ms,minsOptions:ys,roleOptions:ps,l1mins:T,setL1mins:te,l1role:ee,setL1role:R,l2mins:v,setL2mins:p,l2role:A,setL2role:g,l3mins:x,setL3mins:b,l3role:O,setL3role:D,actions:P,setActions:B,thirdPartyIds:q,setThirdPartyIds:Y,humanLoop:ne,setHumanLoop:ue,onClear:Ss,onSave:bs,saving:Ge,onActionTypesLoaded:E=>{const X={};for(const Q of E)typeof Q.actionTypeId=="number"&&(X[Q.actionTypeId]=Q.name);se(X)}})]}),n.jsx(c.Divider,{className:"my-6"}),n.jsx(Xr,{entries:Se,userRoles:z,loading:We,onEdit:E=>{V("rules");const X=Se.find(M=>M.id===E),Q=t.find(M=>M.RuleId===E)||(X?t.find(M=>M.Name===X.ruleOrSeverityLabel):void 0);j(Q?Q.RuleId:E)}}),n.jsx(c.Divider,{className:"my-6"}),n.jsx(os,{userRoles:z,rules:t,rawRules:r}),n.jsx(c.Divider,{})]})}const{Title:_t,Text:$e}=c.Typography;function cs({severities:e,rules:t,onSave:s,onCancel:r}){const{rules:i,alerts:a}=he(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[l,f]=h.useState("By Severity"),[u,d]=h.useState(new Set),[N,m]=h.useState(null),[k,w]=h.useState(null),[y,S]=h.useState({inApp:!1,sms:!1,email:!1}),[L,U]=h.useState([]),[$,F]=h.useState(!0),[K,V]=h.useState(!1);h.useEffect(()=>{let I=!1;return(async()=>{try{const j=await a.getPreferenceSettings();if(I||!j)return;S({inApp:!!j.inApp,sms:!!j.sms,email:!!j.email});const T=Gt(j.sortBy);f(T==="By Created Date"?"By Created Date":"By Severity"),m(It(j.doNotDisturbStart)),w(It(j.doNotDisturbEnd)),Array.isArray(j.anomalyIds)&&d(new Set(j.anomalyIds.map(te=>String(te))))}catch(j){console.error("Error in loading my preferences: ",j)}})(),()=>{I=!0}},[]),h.useEffect(()=>{let I=!1;return(async()=>{try{F(!0);const j=await i.getLookups();if(I||!j)return;const T=Array.isArray(j.anomalies)?j.anomalies:[];U(T)}catch(j){console.error("Failed to load anomalies lookups",j)}finally{I||F(!1)}})(),()=>{I=!0}},[]);const H=I=>{d(j=>{const T=new Set(j);return T.has(I)?T.delete(I):T.add(I),T})},G=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(u),dnd:{from:N,to:k},channels:y});try{V(!0);const I=N?N.format?.("HH:mm:ss")??"00:00:00":"00:00:00",j=k?k.format?.("HH:mm:ss")??"00:00:00":"00:00:00",T=Array.from(u).map(ee=>Number(ee)).filter(ee=>Number.isFinite(ee)),te=await a.setPreferenceSettings({anomalyIds:T,doNotDisturbStart:I,doNotDisturbEnd:j,inApp:!!y.inApp,sms:!!y.sms,email:!!y.email,sortBy:l});te?.responseStatus&&re.toast.success(te?.data||"Preferences updated successfully.")}catch(I){console.error("Error in saving my preferences: ",I)}finally{V(!1)}};return n.jsxs("div",{className:"w-full",children:[n.jsx(c.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:n.jsx(c.Col,{xs:24,md:8,children:n.jsxs(c.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[n.jsx($e,{className:"text-gray-600",children:"Sort By:"}),n.jsx(c.Select,{className:"w-[240px]",value:l,options:o,onChange:f})]})})}),n.jsxs("div",{className:"mb-4",children:[n.jsx(_t,{level:5,className:"!mb-2",children:"Anomalies"}),$?n.jsx("div",{className:"py-4",children:n.jsx(c.Spin,{})}):n.jsx(c.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(L)?L:[]).map(I=>{const j=String(I.recordId),T=I.anomalyName;return n.jsx(c.Checkbox,{checked:u.has(j),onChange:()=>H(j),children:T},j)})})]}),n.jsxs("div",{className:"mb-4",children:[n.jsx(_t,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),n.jsx(c.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:n.jsx(c.Col,{xs:24,md:12,children:n.jsxs(c.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[n.jsx($e,{children:"Do Not Disturb mode:"}),n.jsxs(c.Space,{size:12,className:"w-full",children:[n.jsxs(c.Space,{direction:"horizontal",size:8,className:"items-center",children:[n.jsx($e,{children:"From"}),n.jsx(c.TimePicker,{value:N,onChange:I=>m(I),format:"HH:mm"})]}),n.jsxs(c.Space,{direction:"horizontal",size:8,className:"items-center",children:[n.jsx($e,{children:"To"}),n.jsx(c.TimePicker,{value:k,onChange:I=>w(I),format:"HH:mm"})]})]})]})})}),n.jsxs(c.Row,{gutter:[24,12],children:[n.jsx(c.Col,{children:n.jsx(c.Checkbox,{checked:y.inApp,onChange:I=>S({...y,inApp:I.target.checked}),children:"In-app"})}),n.jsx(c.Col,{children:n.jsx(c.Checkbox,{checked:y.sms,onChange:I=>S({...y,sms:I.target.checked}),children:"SMS"})}),n.jsx(c.Col,{children:n.jsx(c.Checkbox,{checked:y.email,onChange:I=>S({...y,email:I.target.checked}),children:"Email"})})]})]}),n.jsx(c.Divider,{}),n.jsxs(c.Space,{className:"gap-3",children:[n.jsx(c.Button,{onClick:r,disabled:K,children:"Cancel"}),n.jsx(c.Button,{type:"primary",onClick:G,loading:K,children:"Save"})]})]})}function us({severities:e,rules:t,userRoles:s,rawRules:r}){const[i,a]=h.useState("global");return n.jsxs("div",{className:"w-full",children:[n.jsxs("div",{className:"inline-flex rounded-xl overflow-hidden border border-gray-200 mb-4",children:[n.jsx("button",{onClick:()=>a("global"),className:`px-5 py-2 text-base font-medium outline-none ${i==="global"?" bg-black text-white":" bg-white text-black"}`,style:{border:"0"},children:"Global Settings"}),n.jsx("button",{onClick:()=>a("prefs"),className:`px-5 py-2 text-base font-medium outline-none ${i==="prefs"?"bg-black text-white":"bg-white"}`,children:"My Preferences"})]}),i==="global"?n.jsx(ls,{severities:e,rules:t,userRoles:s,rawRules:r}):n.jsx(cs,{severities:e,rules:t})]})}const en="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=",tn="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 sn(e){const t=(e.status||"").toLowerCase()==="completed"?n.jsx("img",{src:en,alt:"completed",style:{width:20,height:20}}):n.jsx("img",{src:tn,alt:"pending",style:{width:20,height:20}});return{title:n.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:n.jsx("b",{children:e.title})}),e.description?n.jsx("span",{className:"text-gray-500 text-xs",children:e.description}):null]}),e.timestamp?n.jsx("span",{className:"text-gray-500 text-xs",children:e.timestamp}):null]}),icon:t,description:null}}function rn({data:e}){return n.jsx("div",{className:"w-full",children:n.jsx(c.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:n.jsxs("div",{className:"w-full",children:[n.jsx(c.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:n.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-gray-500",children:"Alert ID"}),n.jsx("span",{className:"text-black",children:e.summary.alertNumber})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-gray-500",children:"Incident ID"}),n.jsx("span",{className:"text-black",children:e.summary.incidentId})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-gray-500",children:"Severity"}),n.jsx("span",{className:"text-black",children:e.summary.severity})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-gray-500",children:"Location"}),n.jsx("span",{className:"text-black",children:e.summary.location})]})]})}),n.jsxs(c.Card,{className:"rounded-md p-4",bordered:!0,children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),n.jsx("div",{className:"mt-2",children:n.jsx(c.Steps,{direction:"vertical",size:"small",current:1,items:(e.timeline||[]).map(sn)})})]})]})},{key:"notification",label:"Notification Sent",children:n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(e.notifications||[]).map((t,s)=>n.jsxs(c.Card,{className:"rounded-md p-4",bordered:!0,children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex flex-col",children:[n.jsx("h4",{className:"text-sm text-black font-medium",children:t.channelLabel}),n.jsx("span",{className:"text-xs text-gray-500 mt-1",children:t.sentAt})]}),n.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-green-50 text-green-700 border border-green-200",children:[t.delivered,"/",t.total," Delivered"]})]}),n.jsxs("div",{className:"mt-4 text-xs",children:[n.jsxs("div",{className:"text-black",children:[" ",t.messageTitle]}),t.messageBody?n.jsx("div",{className:"text-gray-600",children:t.messageBody}):null]}),n.jsxs("div",{className:"mt-4",children:[n.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",t.total,")"]}),n.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(t.recipients||[]).map((r,i)=>n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{className:"text-black",children:r.name}),n.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),n.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))})]})]},s)),e.notifications?.length?null:n.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const nn=({alertId:e,id:t,priority:s,spaceName:r,alertNumber:i,statusHistory:a,notifGroups:o})=>{const l={alertId:e??String(t??""),incidentId:"-",severity:s||"",location:r||"",alertNumber:i??""},f=a?.length?a.map(d=>{const N=(d?.status||d?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",m=d?.createdDate?nt(d.createdDate):d?.timestamp?nt(d.timestamp):"";return{status:N,title:d?.status||d?.eventStatus||"Status Update",description:d?.description||d?.actionNotes||"",timestamp:m}}):[],u={summary:l,timeline:f,notifications:o??[]};return n.jsx(rn,{data:u})};function an(e){if(!e||typeof e!="string")return!1;const t=e.split("?")[0].toLowerCase();return t.endsWith(".mp4")||t.endsWith(".webm")||t.endsWith(".ogg")||t.endsWith(".m3u8")}function on(e){const t=(e?.mediaType||e?.type||"").toString().toLowerCase();return t==="video"||t==="mp4"?!0:an(e?.mediaUrl||e)}function Ve(e){const t=e;return t?Array.isArray(t)?t:[t]:[]}const ln={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},cn={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},un=({isModalOpen:e,handleModalClose:t,selectedRow:s,fetchAlertLogs:r,alertStatusList:i=[],alertStatusLoading:a=!1,initialTab:o="details"})=>{const[l,f]=h.useState(),[u,d]=h.useState(""),[N,m]=h.useState(!1),k=h.useRef(null),[w,y]=h.useState("details"),[S,L]=h.useState(void 0),[U,$]=h.useState(!1),F=mt(),{alerts:K,config:V}=he(),H=V?.tenant==="schools",G=s?.originalData||{},{eventName:I,alertId:j,timestamp:T,description:te,spaceName:ee,assignTeam:R,priority:v,statusType:p,id:A,alertDetails:g,statusHistory:x,mediaDetails:b,alertNumber:O}=G,D=!H&&typeof G?.anomalyName=="string"&&String(G?.anomalyName||"").toLowerCase().includes("elopement"),P=C=>{const _=String(C||"").toLowerCase();return _==="delivered"?"Delivered":_==="failed"?"Failed":"Queued"},B=C=>({name:C?.receipientName||C?.recipientName||"-",role:C?.receipientRoleName||"",phone:C?.receipentPhoneNumber||C?.recipientPhoneNumber||C?.receipientEmail||C?.recipientEmail||"",status:P(C?.messageStatus)}),q=(C,_)=>{const z=_.map(B),be=z.filter(Ae=>Ae.status==="Delivered").length,Se=_.map(Ae=>Ae?.sentAt).filter(Boolean).sort((Ae,We)=>new Date(We).getTime()-new Date(Ae).getTime())[0],ke=_[0]||{},Ge=[ke?.severityName,ke?.anomalyName].filter(Boolean).join(" - ")||`${C} Notification`;return{channelLabel:`${C} Notification`,sentAt:Se||"",messageTitle:Ge,messageBody:"",total:z.length,delivered:be,recipients:z}},Y=C=>{const _=new Map;return(C||[]).forEach(z=>{const be=String(z?.notificationType||"Unknown"),Se=_.get(be)||[];Se.push(z),_.set(be,Se)}),Array.from(_.entries()).map(([z,be])=>q(z,be))},ne=async C=>{try{const _=await K.getAlertNotifications(C),z=Y(_);L(z)}catch{L(void 0)}};h.useEffect(()=>{if(w!=="track"||!A)return;let C=!1;return ne(A).then(()=>{C&&L(void 0)}),()=>{C=!0}},[w,A]),h.useEffect(()=>{e&&y(o)},[e,o]);const ue=(i||[]).map(C=>({value:C.value,label:C.statusName})),oe=async()=>{try{m(!0);const C={alertUniqueId:j,alertId:A,status:l?String(l):void 0,notes:u.trim(),modifiedBy:0},_=await F.mutateAsync(C);if(_?.responseStatus){const z=_?.data||"Alert updated successfully.";re.toast.success(z,{autoClose:1500,onClose:()=>{r(),t()}}),f(void 0),d("")}else{const z=_?.errorMessage||"Failed to update alert status";re.toast.error(z)}}catch(C){console.error("Error updating alert status:",C),re.toast.error("Failed to update alert status. Please try again.")}finally{m(!1)}},se=async()=>{try{if(!A){re.toast.error("Alert ID is missing.");return}$(!0);const C=A;if(!K.notifyFamilyMembers){re.toast.error("Notify Family is not supported.");return}const _=await K.notifyFamilyMembers(C);if(_?.responseStatus){const z=_?.data||"Alert Notifications sent to Family Members.";re.toast.success(z)}else{const z=_?.errorMessage||"Failed to send notifications.";re.toast.error(z)}}catch(C){console.error("Error notifying family members:",C),re.toast.error("Failed to send notifications. Please try again.")}finally{$(!1)}};return n.jsx(c.Modal,{open:e,onCancel:t,width:1e3,styles:{body:{maxHeight:"70vh",overflowY:"auto"}},footer:w==="details"?n.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[n.jsx(c.Button,{onClick:t,className:"bg-[#6C757D] text-white",children:"Cancel"}),n.jsx(c.Button,{type:"primary",onClick:oe,loading:N,children:N?"Saving...":"Save Changes"})]}):null,children:s&&n.jsx(c.Tabs,{activeKey:w,onChange:C=>y(C),items:[{key:"details",label:"Alert Detail",children:n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("div",{className:"text-sm font-bold",children:I||"Alert Event"}),g?.firstName?n.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",g?.firstName," ",g?.lastName||"","   ",g?.residentId||""]}):null,n.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",nt(T)]}),n.jsxs("div",{className:"font-sm text-gray-500",children:[n.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",te||"No description available"]}),ee&&n.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",ee]}),R&&n.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",R]}),n.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[n.jsxs(c.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${ln[String(v)]||"#DFE4EA"}`,backgroundColor:cn[String(v)]},children:["Severity: ",v||"N/A"]}),n.jsxs(c.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(p||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",p||"N/A"]})]}),n.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:n.jsxs("div",{className:"w-full mt-4",children:[n.jsx("div",{className:"flex flex-col gap-2",children:n.jsx(c.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:C=>f(C),value:l,options:ue,loading:a})}),n.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[n.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),n.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:u,onChange:C=>d(C.target.value)})]}),D&&n.jsxs("div",{className:"border border-[#DFE4EA] rounded-md px-4 py-2 flex flex-row justify-between items-center mt-4 mb-8",children:[n.jsx("label",{htmlFor:"notify-family-button",className:"text-xs font-medium",children:"Alert notification will be sent to all Family Members."}),n.jsx(c.Button,{loading:U,onClick:se,disabled:U,className:"bg-black text-white rounded-md px-4 py-2 text-xs disabled:opacity-60 disabled:cursor-not-allowed",children:"Notify Family"})]})]})})]}),n.jsx("div",{className:"flex flex-col gap-4",children:n.jsxs("div",{className:"w-full mt-1",children:[n.jsxs("div",{className:"w-full flex items-center justify-between",children:[n.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),Ve(b).length?n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:()=>k.current?.prev?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Previous media",children:n.jsx(Ee.LeftOutlined,{style:{fontSize:12}})}),n.jsx("button",{type:"button",onClick:()=>k.current?.next?.(),className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-600","aria-label":"Next media",children:n.jsx(Ee.RightOutlined,{style:{fontSize:12}})})]}):null]}),Ve(b).length?n.jsx("div",{className:"w-full",children:n.jsx(c.Carousel,{ref:k,dots:!0,className:"w-full",children:Ve(b).map((C,_)=>n.jsxs("div",{className:"flex justify-center items-center",children:[on(C)?n.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[n.jsx("source",{src:C.mediaUrl||C}),"Your browser does not support the video tag."]}):n.jsx("img",{src:C.mediaUrl||C,alt:C.caption||`media-${_}`,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg"}),C.caption&&n.jsx("p",{className:"text-xs text-gray-500 mt-1",children:C.caption})]},_))})}):null]})})]})},{key:"track",label:"Track Incident",children:n.jsx(nn,{alertId:j,id:A,priority:v,spaceName:ee,alertNumber:O,statusHistory:x,notifGroups:S})}]})})};function ds(){const{alerts:e}=he(),t=ft({queryKey:["alerts","statusList"],queryFn:()=>e.getAlertStatusList(),staleTime:5*6e4});return{list:t.data??[],loading:t.isLoading,error:t.error,refetch:t.refetch}}function pt({alerts:e,loading:t=!1,columns:s,onRefetch:r}){const[i,a]=h.useState(!1),[o,l]=h.useState(null),[f,u]=h.useState("details"),{list:d,loading:N}=ds();function m(y,S){l(y),u(S?.tab??"details"),a(!0)}function k(){a(!1)}const w=o?{originalData:{...o,alertId:o.alertId??o.id,mediaDetails:o.mediaDetails}}:null;return n.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[n.jsxs("div",{className:"w-1/2 flex items-center justify-between mb-4",children:[n.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),n.jsx(as,{label:"USA",timeZone:"America/New_York"})]}),n.jsx(c.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:y=>{y==="active"&&r?.()},items:[{key:"active",label:"Active",children:n.jsx(ot,{data:e,loading:t,pageSize:10,columns:s||[],onAlertIdClick:m,onRefetch:r})},{key:"archived",label:"Archived",children:n.jsx(is,{alerts:e,loading:t,columns:s||[],onAlertIdClick:m})},{key:"settings",label:"Settings",children:n.jsx(dn,{})}]}),n.jsx(un,{isModalOpen:i,handleModalClose:k,selectedRow:w,fetchAlertLogs:()=>{},alertStatusList:d,alertStatusLoading:N,initialTab:f})]})}function dn(){const[e,t]=h.useState([]),[s,r]=h.useState([]),[i,a]=h.useState([]),{rules:o}=he();return h.useEffect(()=>{let l=!0;return(async()=>{try{const f=await o.getRules();if(!l)return;a(Array.isArray(f)?f:[]);const u=(f||[]).map((d,N)=>({RuleId:d.ruleId||d.ruleName||String(N),Name:d.ruleName||d.Name||"-",Description:d.ruleDesc||d.Description||"",SeverityId:0}));t(u.length?u:Oe.rules);try{const d=await o.getLookups(),N=Array.isArray(d?.userRoles)?d.userRoles.map(m=>({userRoleId:m.userRoleId??m.id,userRoleName:m.userRoleName??m.name})):[];r(N.length?N:Oe.userRoles)}catch{r(Oe.userRoles)}}catch{t(Oe.rules),r(Oe.userRoles)}})(),()=>{l=!1}},[]),n.jsx(us,{severities:Oe.severities,rules:e,userRoles:s,rawRules:i})}function hs(){const{alerts:e}=he(),t=ft({queryKey:["alerts","list"],queryFn:()=>e.listAlerts(),staleTime:3e4});return{alerts:t.data??[],loading:t.isLoading,error:t.error,refetch:t.refetch}}function hn(e){const{alerts:t,loading:s,refetch:r}=hs();return n.jsx(pt,{alerts:t,loading:s,columns:e.columns,onRefetch:r})}function fn({tenant:e,apiDomain:t,rulesDomain:s,headers:r,alerts:i,loading:a,columns:o}){const[l]=h.useState(()=>new Cr),f=h.useMemo(()=>({alertsBaseUrl:t,rulesBaseUrl:s||t,headers:r||void 0}),[t,s,r]);return n.jsx(Ir,{client:l,children:n.jsx(Yt,{tenant:e,override:f,children:Array.isArray(i)?n.jsx(pt,{alerts:i,loading:!!a,columns:o}):n.jsx(hn,{columns:o})})})}function mn(e){const{alerts:t}=he(),s=ft({queryKey:["alerts","report",e],queryFn:()=>t.getAlertsReport(e),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const pn=[{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=os;exports.AlertConsole=pt;exports.AlertConsoleWidget=fn;exports.AlertsTable=ot;exports.ApiProvider=Yt;exports.ArchivedTable=is;exports.Clock=as;exports.DataTable=zt;exports.MyPreferencesPanel=cs;exports.SettingsPanel=ls;exports.SettingsTabs=us;exports.exampleAlertColumns=pn;exports.useAlertStatusList=ds;exports.useAlerts=hs;exports.useAlertsReport=mn;exports.useApi=he;exports.useUpdateAlertStatus=mt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),h=require("react"),c=require("antd"),Ee=require("@ant-design/icons"),re=require("react-toastify");function Ns(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const le=Ns(h),ws="#FF3B30",js="#FF9500",Cs="#FFCC00",Ts="#34C759",De={critical:ws,high:js,medium:Cs,low:Ts},At={Critical:De.critical,High:De.high,Medium:De.medium,Low:De.low};function Is(e){return At[e]||At.Low}function Nt(e){if(!e||typeof e!="string")return 0;const t=e.trim().split(":");if(t.length!==3)return 0;const[s,r,i]=t,a=Number.parseInt(s,10),o=Number.parseInt(r,10),l=Number.parseFloat(i||"0"),f=Number.isFinite(a)?a:0,d=Number.isFinite(o)?o:0,u=Number.isFinite(l)?l:0;return f*3600+d*60+u}function ze(e){const t=e.thirdPartyIds??e.ThirdPartyIds??e.thirdPartyId??e.ThirdPartyId??"",s=Array.isArray(t)?t.join(","):String(t??"");if(!s||!s.trim())return[];const r=s.split(",").map(o=>parseInt(String(o).trim(),10)).filter(o=>Number.isFinite(o)),i=new Set,a=[];return r.forEach(o=>{i.has(o)||(i.add(o),a.push(o))}),a}const Ht="",Rs=Ht,ks="",Os="",wt={snl:{alerts:Ht,rules:Rs},schools:{alerts:ks,rules:Os}};function fe(e,t){const s=(e||"").replace(/\/+$/,""),r=t.startsWith("/")?t:`/${t}`;return`${s}${r}`}function Es(){try{const e=localStorage.getItem("authToken");return e?{Authorization:`Bearer ${e}`}:{}}catch{return{}}}function Fe(e,t){if(!t)return e;const s=new URL(e);return Object.entries(t).forEach(([r,i])=>{i!=null&&String(i).length>0&&s.searchParams.set(r,String(i))}),s.toString()}async function me(e,t){const s={...t.headers,...Es()},r=await fetch(e,{...t,headers:s});if(r.status===401)throw window.location.href="/login",new Error("Unauthorized");if(r.status===204)return{};const i=await r.text();let a={};if(i)try{a=JSON.parse(i)}catch{a={ok:r.ok,status:r.status,raw:i}}if(!r.ok){const o=a?.errorMessage||a?.message||`HTTP ${r.status}`;throw new Error(o)}return a}function Ps(e){const t={"Content-Type":"application/json",...e.headers||{}};return{async listAlerts(){const s=fe(e.baseUrl,"/api/Alert"),r=await me(s,{method:"GET",headers:t});return Array.isArray(r)?r:[]},async getAlertStatusList(){const s=fe(e.baseUrl,"/api/Alert/AlertStatusList"),r=await me(s,{method:"GET",headers:t});return Array.isArray(r)?r:r&&typeof r=="object"&&Array.isArray(r.data)?r.data:[]},async getAlertsReport(s){const r=fe(e.baseUrl,"/Alerts/GetAlertsReport"),i=Fe(r,s),a=await me(i,{method:"GET",headers:t});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const r=fe(e.baseUrl,"/api/Alert/status");return me(r,{method:"PUT",headers:t,body:JSON.stringify(s??{})})},async getAdminSettings(){const s=fe(e.baseUrl,"/api/Alert/GetAdminSettings"),r=await me(s,{method:"GET",headers:t});if(r&&typeof r=="object"){if("data"in r)return r.data;if("userId"in r)return r}return null},async setAdminSettings(s){const r=fe(e.baseUrl,"/api/Alert/SetAdminSettings"),i={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??"",groupBy:s?.groupBy??null};return me(r,{method:"POST",headers:t,body:JSON.stringify(i)})},async getPreferenceSettings(){const s=fe(e.baseUrl,"/api/Alert/GetPreferenceSettings"),r=await me(s,{method:"GET",headers:t});if(r&&typeof r=="object"){if("data"in r)return r.data;if("anomalyIds"in r)return r}return null},async setPreferenceSettings(s){const r=fe(e.baseUrl,"/api/Alert/SetPreferenceSettings"),i=await me(r,{method:"POST",headers:t,body:JSON.stringify(s??{})}),a=i?.responseStatus??!0,o=i?.data??i?.message??"Preferences updated successfully.";return{responseStatus:a,errorMessage:a?"":i?.errorMessage??i?.message??"",statusCode:200,data:o}},async getAlertNotifications(s){const r=fe(e.baseUrl,"/api/Alert/GetNotifications"),i=Fe(r,{alertId:s}),a=await me(i,{method:"GET",headers:t});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]},async notifyFamilyMembers(s){const r=fe(e.baseUrl,"/api/Alert/NotificationToFamilyMembers"),i=Fe(r,{alertId:s});return me(i,{method:"POST",headers:t})},async sendSMSorEmailNotifications(s,r,i){const a=fe(e.baseUrl,"/api/Alert/SendSMSorEmailNotifications"),o=Fe(a,{alertId:s,isEmail:r,isSMS:i});return me(o,{method:"POST",headers:t})}}}function jt(e,t){const s=(e||"").replace(/\/+$/,""),r=t.startsWith("/")?t:`/${t}`;return`${s}${r}`}function Ms(){try{const e=localStorage.getItem("authToken");return e?{Authorization:`Bearer ${e}`}:{}}catch{return{}}}async function Ue(e,t){const s={...t.headers,...Ms()},r=await fetch(e,{...t,headers:s});if(r.status===401)throw window.location.href="/login",new Error("Unauthorized");if(r.status===204)return{};const i=await r.text();let a={};if(i)try{a=JSON.parse(i)}catch{a={ok:r.ok,status:r.status,raw:i}}if(!r.ok){const o=a?.errorMessage||a?.message||`HTTP ${r.status}`;throw new Error(o)}return a}function Ds(e){const t={"Content-Type":"application/json",...e.headers||{}},s=jt(e.baseUrl,"/api/Rules"),r=jt(e.baseUrl,"/api/Rules/lookups");return{async getRules(){const i=await Ue(s,{method:"GET",headers:t});return Array.isArray(i)?i:[]},async setEscalationSettings(i){return Ue(s,{method:"POST",headers:t,body:JSON.stringify(i??{})})},async getLookups(){return Ue(r,{method:"GET",headers:t})},async updateRule(i,a){const o=`${s}/${i}`;return Ue(o,{method:"PUT",headers:t,body:JSON.stringify(a??{})})}}}function Fs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Be={exports:{}},Us=Be.exports,Ct;function Ls(){return Ct||(Ct=1,(function(e,t){(function(s,r){e.exports=r()})(Us,(function(){var s=1e3,r=6e4,i=36e5,a="millisecond",o="second",l="minute",f="hour",d="day",u="week",N="month",m="quarter",I="year",w="date",y="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,U={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(k){var v=["th","st","nd","rd"],p=k%100;return"["+k+(v[(p-20)%10]||v[p]||v[0])+"]"}},$=function(k,v,p){var A=String(k);return!A||A.length>=v?k:""+Array(v+1-A.length).join(p)+k},F={s:$,z:function(k){var v=-k.utcOffset(),p=Math.abs(v),A=Math.floor(p/60),g=p%60;return(v<=0?"+":"-")+$(A,2,"0")+":"+$(g,2,"0")},m:function k(v,p){if(v.date()<p.date())return-k(p,v);var A=12*(p.year()-v.year())+(p.month()-v.month()),g=v.clone().add(A,N),x=p-g<0,b=v.clone().add(A+(x?-1:1),N);return+(-(A+(p-g)/(x?g-b:b-g))||0)},a:function(k){return k<0?Math.ceil(k)||0:Math.floor(k)},p:function(k){return{M:N,y:I,w:u,d,D:w,h:f,m:l,s:o,ms:a,Q:m}[k]||String(k||"").toLowerCase().replace(/s$/,"")},u:function(k){return k===void 0}},Y="en",V={};V[Y]=U;var W="$isDayjsObject",H=function(k){return k instanceof ee||!(!k||!k[W])},T=function k(v,p,A){var g;if(!v)return Y;if(typeof v=="string"){var x=v.toLowerCase();V[x]&&(g=x),p&&(V[x]=p,g=x);var b=v.split("-");if(!g&&b.length>1)return k(b[0])}else{var O=v.name;V[O]=v,g=O}return!A&&g&&(Y=g),g||!A&&Y},C=function(k,v){if(H(k))return k.clone();var p=typeof v=="object"?v:{};return p.date=k,p.args=arguments,new ee(p)},R=F;R.l=T,R.i=H,R.w=function(k,v){return C(k,{locale:v.$L,utc:v.$u,x:v.$x,$offset:v.$offset})};var ee=(function(){function k(p){this.$L=T(p.locale,null,!0),this.parse(p),this.$x=this.$x||p.x||{},this[W]=!0}var v=k.prototype;return v.parse=function(p){this.$d=(function(A){var g=A.date,x=A.utc;if(g===null)return new Date(NaN);if(R.u(g))return new Date;if(g instanceof Date)return new Date(g);if(typeof g=="string"&&!/Z$/i.test(g)){var b=g.match(S);if(b){var O=b[2]-1||0,D=(b[7]||"0").substring(0,3);return x?new Date(Date.UTC(b[1],O,b[3]||1,b[4]||0,b[5]||0,b[6]||0,D)):new Date(b[1],O,b[3]||1,b[4]||0,b[5]||0,b[6]||0,D)}}return new Date(g)})(p),this.init()},v.init=function(){var p=this.$d;this.$y=p.getFullYear(),this.$M=p.getMonth(),this.$D=p.getDate(),this.$W=p.getDay(),this.$H=p.getHours(),this.$m=p.getMinutes(),this.$s=p.getSeconds(),this.$ms=p.getMilliseconds()},v.$utils=function(){return R},v.isValid=function(){return this.$d.toString()!==y},v.isSame=function(p,A){var g=C(p);return this.startOf(A)<=g&&g<=this.endOf(A)},v.isAfter=function(p,A){return C(p)<this.startOf(A)},v.isBefore=function(p,A){return this.endOf(A)<C(p)},v.$g=function(p,A,g){return R.u(p)?this[A]:this.set(g,p)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(p,A){var g=this,x=!!R.u(A)||A,b=R.p(p),O=function(oe,se){var j=R.w(g.$u?Date.UTC(g.$y,se,oe):new Date(g.$y,se,oe),g);return x?j:j.endOf(d)},D=function(oe,se){return R.w(g.toDate()[oe].apply(g.toDate("s"),(x?[0,0,0,0]:[23,59,59,999]).slice(se)),g)},P=this.$W,B=this.$M,q=this.$D,K="set"+(this.$u?"UTC":"");switch(b){case I:return x?O(1,0):O(31,11);case N:return x?O(1,B):O(0,B+1);case u:var ne=this.$locale().weekStart||0,ue=(P<ne?P+7:P)-ne;return O(x?q-ue:q+(6-ue),B);case d:case w:return D(K+"Hours",0);case f:return D(K+"Minutes",1);case l:return D(K+"Seconds",2);case o:return D(K+"Milliseconds",3);default:return this.clone()}},v.endOf=function(p){return this.startOf(p,!1)},v.$set=function(p,A){var g,x=R.p(p),b="set"+(this.$u?"UTC":""),O=(g={},g[d]=b+"Date",g[w]=b+"Date",g[N]=b+"Month",g[I]=b+"FullYear",g[f]=b+"Hours",g[l]=b+"Minutes",g[o]=b+"Seconds",g[a]=b+"Milliseconds",g)[x],D=x===d?this.$D+(A-this.$W):A;if(x===N||x===I){var P=this.clone().set(w,1);P.$d[O](D),P.init(),this.$d=P.set(w,Math.min(this.$D,P.daysInMonth())).$d}else O&&this.$d[O](D);return this.init(),this},v.set=function(p,A){return this.clone().$set(p,A)},v.get=function(p){return this[R.p(p)]()},v.add=function(p,A){var g,x=this;p=Number(p);var b=R.p(A),O=function(B){var q=C(x);return R.w(q.date(q.date()+Math.round(B*p)),x)};if(b===N)return this.set(N,this.$M+p);if(b===I)return this.set(I,this.$y+p);if(b===d)return O(1);if(b===u)return O(7);var D=(g={},g[l]=r,g[f]=i,g[o]=s,g)[b]||1,P=this.$d.getTime()+p*D;return R.w(P,this)},v.subtract=function(p,A){return this.add(-1*p,A)},v.format=function(p){var A=this,g=this.$locale();if(!this.isValid())return g.invalidDate||y;var x=p||"YYYY-MM-DDTHH:mm:ssZ",b=R.z(this),O=this.$H,D=this.$m,P=this.$M,B=g.weekdays,q=g.months,K=g.meridiem,ne=function(se,j,_,z){return se&&(se[j]||se(A,x))||_[j].slice(0,z)},ue=function(se){return R.s(O%12||12,se,"0")},oe=K||function(se,j,_){var z=se<12?"AM":"PM";return _?z.toLowerCase():z};return x.replace(L,(function(se,j){return j||(function(_){switch(_){case"YY":return String(A.$y).slice(-2);case"YYYY":return R.s(A.$y,4,"0");case"M":return P+1;case"MM":return R.s(P+1,2,"0");case"MMM":return ne(g.monthsShort,P,q,3);case"MMMM":return ne(q,P);case"D":return A.$D;case"DD":return R.s(A.$D,2,"0");case"d":return String(A.$W);case"dd":return ne(g.weekdaysMin,A.$W,B,2);case"ddd":return ne(g.weekdaysShort,A.$W,B,3);case"dddd":return B[A.$W];case"H":return String(O);case"HH":return R.s(O,2,"0");case"h":return ue(1);case"hh":return ue(2);case"a":return oe(O,D,!0);case"A":return oe(O,D,!1);case"m":return String(D);case"mm":return R.s(D,2,"0");case"s":return String(A.$s);case"ss":return R.s(A.$s,2,"0");case"SSS":return R.s(A.$ms,3,"0");case"Z":return b}return null})(se)||b.replace(":","")}))},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(p,A,g){var x,b=this,O=R.p(A),D=C(p),P=(D.utcOffset()-this.utcOffset())*r,B=this-D,q=function(){return R.m(b,D)};switch(O){case I:x=q()/12;break;case N:x=q();break;case m:x=q()/3;break;case u:x=(B-P)/6048e5;break;case d:x=(B-P)/864e5;break;case f:x=B/i;break;case l:x=B/r;break;case o:x=B/s;break;default:x=B}return g?x:R.a(x)},v.daysInMonth=function(){return this.endOf(N).$D},v.$locale=function(){return V[this.$L]},v.locale=function(p,A){if(!p)return this.$L;var g=this.clone(),x=T(p,A,!0);return x&&(g.$L=x),g},v.clone=function(){return R.w(this.$d,this)},v.toDate=function(){return new Date(this.valueOf())},v.toJSON=function(){return this.isValid()?this.toISOString():null},v.toISOString=function(){return this.$d.toISOString()},v.toString=function(){return this.$d.toUTCString()},k})(),X=ee.prototype;return C.prototype=X,[["$ms",a],["$s",o],["$m",l],["$H",f],["$W",d],["$M",N],["$y",I],["$D",w]].forEach((function(k){X[k[1]]=function(v){return this.$g(v,k[0],k[1])}})),C.extend=function(k,v){return k.$i||(k(v,ee,C),k.$i=!0),C},C.locale=T,C.isDayjs=H,C.unix=function(k){return C(1e3*k)},C.en=V[Y],C.Ls=V,C.p={},C}))})(Be)),Be.exports}var $s=Ls();const Gt=Fs($s);function Wt(e){if(!e)return"By Severity";const t=e.trim().toLowerCase();return t.includes("created")?"By Created Date":t.includes("updated")||t.includes("modified")?"By Updated Date":"By Severity"}function Yt(e){if(!e||typeof e!="string")return{hours:0,minutes:0,seconds:0};const t=e.split(":").map(a=>parseInt(a,10)),s=Number.isFinite(t[0])?t[0]:0,r=Number.isFinite(t[1])?t[1]:0,i=Number.isFinite(t[2])?t[2]:0;return{hours:s,minutes:r,seconds:i}}function Tt(e){const{hours:t,minutes:s,seconds:r}=Yt(e);return Gt().hour(t).minute(s).second(r).millisecond(0)}function ge(e,t){const s=(e||"").replace(/\/+$/,""),r=t.startsWith("/")?t:`/${t}`;return`${s}${r}`}function Bs(){try{const e=localStorage.getItem("authToken");return e?{Authorization:`Bearer ${e}`}:{}}catch{return{}}}function It(e,t){if(!t)return e;const s=new URL(e);return Object.entries(t).forEach(([r,i])=>{i!=null&&String(i).length>0&&s.searchParams.set(r,String(i))}),s.toString()}async function ve(e,t){const s={...t.headers,...Bs()},r=await fetch(e,{...t,headers:s});if(r.status===401)throw window.location.href="/login",new Error("Unauthorized");if(r.status===204)return{};const i=await r.text();let a={};if(i)try{a=JSON.parse(i)}catch{a={ok:r.ok,status:r.status,raw:i}}if(!r.ok){const o=a?.Message||`HTTP ${r.status}`;throw new Error(o)}return a}const ae=(...e)=>e.find(t=>t!=null);function qs(e){return{id:String(ae(e?.AlertId,e?.alertId)??""),priority:ae(e?.Priority,e?.priority,"Low"),timestamp:ae(e?.Timestamp,e?.timestamp,""),statusType:ae(e?.Status,e?.statusType,""),description:ae(e?.Description,e?.description,""),eventName:ae(e?.EventName,e?.eventName),ruleName:ae(e?.RuleName,e?.ruleName),spaceName:ae(e?.SpaceName,e?.spaceName),assignTeam:ae(e?.AssignTeam,e?.assignTeam),cameraName:ae(e?.CameraName,e?.cameraName),type:ae(e?.Type,e?.type),mediaDetails:ae(e?.MediaDetails,e?.mediaDetails),additionalMedia:ae(e?.AdditionalMedia,e?.additionalMedia),timeElapsed:ae(e?.TimeElapsed,e?.timeElapsed),timeRemaining:ae(e?.TimeRemaining,e?.timeRemaining),anomalyName:ae(e?.AnomalyName,e?.anomalyName),alertDetails:ae(e?.AlertDetails,e?.alertDetails),statusHistory:ae(e?.StatusHistory,e?.statusHistory)}}function Qs(e){const t={"Content-Type":"application/json",...e.headers||{}};return{async listAlerts(){const s=ge(e.baseUrl,"/api/detectionpolicy/alerts?customerId=99e5c8b5-b9d4-4d35-8885-7f121c532664"),r=await ve(s,{method:"GET",headers:t});return Array.isArray(r?.Items)?(r?.Items).map(qs):[]},async getAlertStatusList(){const s=ge(e.baseUrl,"/api/detectionpolicy/alerts/StatusList"),r=await ve(s,{method:"GET",headers:t});return Array.isArray(r)?r:[]},async getAlertsReport(s){const r=ge(e.baseUrl,"/api/detectionpolicy/alerts/GetAlertsReport"),i=It(r,s),a=await ve(i,{method:"GET",headers:t});return Array.isArray(a)?a:[]},async updateAlertStatus(s){const r=ge(e.baseUrl,"/api/detectionpolicy/alerts/Log"),i={AlertId:s.alertId??s.alertUniqueId??s.AlertId,Status:s.status??s.Status??"",Notes:s.notes??s.Notes??""};return ve(r,{method:"POST",headers:t,body:JSON.stringify(i)})},async getAdminSettings(){const s=ge(e.baseUrl,"/api/detectionpolicy/alerts/GetAdminSettings"),r=await ve(s,{method:"GET",headers:t});if(r&&typeof r=="object"){if("data"in r)return r.data;if("userId"in r)return r}return null},async setAdminSettings(s){const r=ge(e.baseUrl,"/api/detectionpolicy/alerts/SetAdminSettings"),i={userId:0,isAdminSetting:!0,sortBy:s?.sortBy??""};return ve(r,{method:"POST",headers:t,body:JSON.stringify(i)})},async getPreferenceSettings(){const s=ge(e.baseUrl,"/api/detectionpolicy/alerts/GetPreferenceSettings"),r=await ve(s,{method:"GET",headers:t});if(r&&typeof r=="object"){if("data"in r)return r.data;if("anomalyIds"in r)return r}return null},async setPreferenceSettings(s){const r=ge(e.baseUrl,"/api/detectionpolicy/alerts/SetPreferenceSettings"),i=d=>{const{hours:u,minutes:N,seconds:m}=Yt(d);return(u*3600+N*60+m)*1e7},a={Settings:{UserId:0,AnomalyIds:Array.isArray(s?.anomalyIds)?s.anomalyIds.map(d=>String(d)):[],DoNotDisturbStart:{Ticks:i(s?.doNotDisturbStart)},DoNotDisturbEnd:{Ticks:i(s?.doNotDisturbEnd)},InApp:!!s?.inApp,SMS:!!s?.sms,Email:!!s?.email,SortBy:s?.sortBy??""}},o=await ve(r,{method:"POST",headers:t,body:JSON.stringify(a)}),l=o?.responseStatus??!0,f=o?.data??o?.message??"Preferences updated successfully.";return{responseStatus:l,errorMessage:l?"":o?.errorMessage??o?.Message??o?.message??"",statusCode:200,data:f}},async getAlertNotifications(s){const r=ge(e.baseUrl,"/api/detectionpolicy/alerts/GetNotifications"),i=It(r,{alertId:s}),a=await ve(i,{method:"GET",headers:t});return Array.isArray(a)?a:a&&typeof a=="object"&&Array.isArray(a.data)?a.data:[]}}}function _s(){try{const e=localStorage.getItem("authToken");return e?{Authorization:`Bearer ${e}`}:{}}catch{return{}}}async function Ne(e,t){const s={...t.headers,..._s()},r=await fetch(e,{...t,headers:s});if(r.status===401)throw window.location.href="/login",new Error("Unauthorized");if(r.status===204)return{};const i=await r.text();let a={};if(i)try{a=JSON.parse(i)}catch{a={ok:r.ok,status:r.status,raw:i}}if(!r.ok){const o=a?.errorMessage||a?.message||`HTTP ${r.status}`;throw new Error(o)}return a}function Hs(e){const t={"Content-Type":"application/json",...e.headers||{}},s=new URL("/api/detectionpolicy/rules",e.baseUrl).toString();return{async getRules(){const r=await Ne(s,{method:"GET",headers:t});return Array.isArray(r)?r:[]},async setEscalationSettings(r){return Ne(s,{method:"POST",headers:t,body:JSON.stringify(r??{})})},async getLookups(){const r=F=>new URL(F,e.baseUrl).toString(),i=[Ne(r("/api/detectionpolicy/lookups/actiontypes"),{method:"GET",headers:t}),Ne(r("/api/detectionpolicy/lookups/anomalies"),{method:"GET",headers:t}),Ne(r("/api/detectionpolicy/lookups/thirdparty"),{method:"GET",headers:t}),Ne(r("/api/detectionpolicy/lookups/severity"),{method:"GET",headers:t}),Ne(r("/api/detectionpolicy/lookups/scheduletypes"),{method:"GET",headers:t})],[a,o,l,f,d]=await Promise.allSettled(i),u=F=>F.status==="fulfilled"&&Array.isArray(F.value)?F.value:[],N=u(a),m=u(o),I=u(l),w=u(f),y=u(d),S=N.map(F=>({actionTypeId:Number(F?.ActionTypeId),name:F?.DisplayName??F?.Name??""})),L=m.map(F=>({recordId:F?.AnomalyId,anomalyName:F?.DisplayName??F?.Name??""})),U=I.map(F=>({thirdPartyId:Number(F?.ThirdPartyId),thirdPartyName:F?.ThirdPartyName??F?.Name??""})),$={actionTypes:S,anomalies:L,thirdParties:U};return w.length&&($.severities=w),y.length&&($.scheduleTypes=y),$},async updateRule(r,i){const a=`${s}/${r}`;return Ne(a,{method:"PUT",headers:t,body:JSON.stringify(i??{})})}}}const Kt=h.createContext(null);function zt({tenant:e="snl",override:t,children:s}){const r=h.useMemo(()=>{const a=t?.alertsBaseUrl&&t.alertsBaseUrl.trim()||wt[e]?.alerts||"";let o=t?.rulesBaseUrl&&t.rulesBaseUrl.trim()||wt[e]?.rules||"";e==="snl"&&(o=a);const l=t?.headers;return{tenant:e,alertsBaseUrl:a,rulesBaseUrl:o,headers:l}},[e,t?.alertsBaseUrl,t?.rulesBaseUrl,JSON.stringify(t?.headers||{})]),i=h.useMemo(()=>{const a=r.tenant==="schools"?Qs({baseUrl:r.alertsBaseUrl,headers:r.headers}):Ps({baseUrl:r.alertsBaseUrl,headers:r.headers}),o=r.tenant==="schools"?Hs({baseUrl:r.rulesBaseUrl,headers:r.headers}):Ds({baseUrl:r.alertsBaseUrl,headers:r.headers});return{config:r,alerts:a,rules:o}},[r]);return n.jsx(Kt.Provider,{value:i,children:s})}function he(){const e=h.useContext(Kt);if(!e)throw new Error("useApi must be used inside ApiProvider");return e}const Gs={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},Ws={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},it=6,at=7;function Ys(e,t,s){const r=e===it,i=e===at,a=t.isEmailSent,o=t.isSMSSent,l=r&&a||i&&o,f=r?"Send Email":i?"Send SMS":s,d=r&&a?"Email already sent":i&&o?"SMS already sent":`Click to ${f.toLowerCase()}`;return{isDisabled:l,buttonText:f,tooltipTitle:d}}function Ks(e){const t=new Set;(e||[]).forEach(r=>{const i=r.anomalyName;typeof i=="string"&&i.trim().length>0&&t.add(i.trim())});const s=Array.from(t).map(r=>({label:r,value:r}));return[{label:"All Types",value:"All"},...s]}function zs(e){const t=new Set;(e||[]).forEach(r=>{const i=r.spaceName;typeof i=="string"&&i.trim().length>0&&t.add(i.trim())});const s=Array.from(t).map(r=>({label:r,value:r}));return[{label:"All",value:"All"},...s]}function Rt(e,t){return`${e}-${t?"email":"sms"}`}function kt(e){return e===it||e===at}function He({value:e,onChange:t,options:s,className:r,dropdownWidth:i}){return n.jsx(c.Select,{className:r,options:s,value:e,onChange:t,dropdownMatchSelectWidth:i??260})}const Vs=[{label:"All levels",value:"All"},{label:"Critical",value:"Critical"},{label:"High",value:"High"},{label:"Medium",value:"Medium"},{label:"Low",value:"Low"}];function Js({value:e,onChange:t,options:s}){return n.jsx(He,{className:"w-[140px]",value:e,onChange:t,options:s||Vs})}const Xs=[{label:"All Types",value:"All"},{label:"Weapon Detection",value:"Weapon"},{label:"Unauthorized Access",value:"Unauthorized"},{label:"Aggressive Behavior",value:"Aggressive"}];function Zs({value:e,onChange:t,options:s}){return n.jsx(He,{className:"w-[220px]",dropdownWidth:280,value:e,onChange:t,options:s||Xs})}function er({value:e,onChange:t,options:s}){return n.jsx(He,{className:"w-[100px]",value:e,onChange:t,options:s||[]})}const tr=[{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 sr({value:e,onChange:t,options:s}){return n.jsx(He,{className:"w-[130px]",value:e,onChange:t,options:s||tr})}function Vt({columns:e,data:t,loading:s=!1,pageSize:r=10,rowKey:i="id",toolbar:a,tableProps:o}){return n.jsxs("div",{children:[a,n.jsx(c.Table,{rowKey:i,dataSource:t,columns:e,loading:s,pagination:{pageSize:r,showSizeChanger:!0,showTotal:l=>`Total: ${l}`},bordered:!0,...o})]})}function ot({data:e,loading:t=!1,pageSize:s=10,columns:r,severityOptions:i,spaceOptions:a,renderActions:o,onAlertIdClick:l,onRefetch:f,excludeCompleted:d=!0}){const[u,N]=h.useState("All"),[m,I]=h.useState("All"),[w,y]=h.useState("All"),[S,L]=h.useState("All"),[U,$]=h.useState(""),[F,Y]=h.useState([{label:"All",value:"All"}]),[V,W]=h.useState(new Set),{rules:H,alerts:T}=he(),C={6:{title:"Email",kind:"icon",icon:n.jsx(Ee.MailOutlined,{})},7:{title:"SMS",kind:"icon",icon:n.jsx(Ee.MessageOutlined,{})}},R=h.useMemo(()=>Ks(e),[e]),ee=h.useMemo(()=>zs(e),[e]);h.useEffect(()=>{let x=!0;return(async()=>{try{const b=await H.getLookups(),D=(Array.isArray(b.thirdParties)?b.thirdParties:[]).map(P=>({label:P.thirdPartyName,value:String(P.thirdPartyId)}));x&&Y([{label:"All",value:"All"},...D])}catch(b){console.error("Error loading third party options",b)}})(),()=>{x=!1}},[H]);const X=h.useMemo(()=>(e||[]).some(x=>ze(x).length>0),[e]),k=h.useMemo(()=>(e||[]).filter(x=>{const b=u==="All"||x.priority===u,O=`${x.id} ${x.description} ${x.statusType}`.toLowerCase(),D=!U||O.includes(U.toLowerCase()),P=m==="All"||(x.anomalyName||"").toLowerCase()===m.toLowerCase(),B=w==="All"||(x.spaceName||"").toLowerCase()===w.toLowerCase(),q=!X||S==="All"||ze(x).includes(Number(S)),K=!d||!["completed","false positive"].includes(String(x.statusType||"").toLowerCase());return b&&D&&P&&B&&q&&K}),[e,u,U,m,w,S,X,d]),v=R,p=a&&a.length?a:ee,A=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:x=>n.jsx(c.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${Ws[x]}`,backgroundColor:Gs[x]},children:x})},{title:"Tracker",key:"tracker",width:140,render:(x,b)=>n.jsx("a",{onClick:O=>{O.preventDefault(),l?.(b,{tab:"track"})},className:"text-blue-600 hover:underline",children:"Tracker"})},{title:"Call to action/Human in the loop",key:"actions",width:320,render:(x,b)=>{if(o)return n.jsx(n.Fragment,{children:o(b)});const O=ze(b);if(!O.length)return null;const D=async(P,B)=>{const q=Rt(b.id,P);W(K=>new Set(K).add(q));try{const K=await T.sendSMSorEmailNotifications?.(b.id,P,B);K?.responseStatus?(re.toast.success(K.data||(P?"Email sent successfully":"SMS sent successfully")),f?.()):re.toast.error(K?.data||K?.errorMessage||"Failed to send notification")}catch(K){re.toast.error(K?.message||"Failed to send notification")}finally{W(K=>{const ne=new Set(K);return ne.delete(q),ne})}};return n.jsx(c.Space,{size:"middle",children:O.map(P=>{const B=C[P];if(!B)return null;const q=P===it,K=P===at,{isDisabled:ne,buttonText:ue,tooltipTitle:oe}=Ys(P,b,B.title),se=Rt(b.id,q),j=kt(P)&&V.has(se),_=()=>{D(q,K)};return n.jsx(c.Tooltip,{title:oe,children:n.jsx(c.Button,{size:"small",disabled:ne,loading:j,onClick:kt(P)?_:void 0,icon:!j&&(B.kind==="img"&&B.src?n.jsx("img",{src:B.src,alt:B.alt||B.title}):B.icon),className:"flex flex-col items-center justify-center gap-1",style:{height:"fit-content"},children:ue})},P)})})}},{title:"Alert Timestamp",dataIndex:"timestamp",key:"timestamp",width:220,render:(x,b)=>{const O=b?.timeElapsed,D=b?.timeRemaining,P=O?Nt(O):0,B=D?Nt(D):0,q=Math.round(P/(P+B)*100);return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"w-[70px]",children:"Elapsed:"}),n.jsx("span",{className:"font-medium",children:O??"-"})]}),n.jsx(c.Progress,{percent:q,showInfo:!1,size:"small",strokeColor:Is(b.priority)}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"w-[70px]",children:"Remaining"}),n.jsx("span",{className:"font-medium",children:D??"-"})]})]})}},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(x,b)=>n.jsxs("div",{children:[n.jsx("a",{onClick:O=>{O.preventDefault(),l?.(b)},className:"inline-block mb-1 text-blue-600",children:b.alertNumber}),n.jsx("div",{className:"text-black/65",children:x})]})}],g=r&&r.length?r:A;return n.jsx("div",{children:n.jsx(Vt,{rowKey:"id",data:k,columns:g,loading:t,pageSize:s,toolbar:n.jsxs(c.Row,{gutter:[12,12],className:"mb-3",align:"middle",children:[n.jsx(c.Col,{flex:"none",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{children:"Severity"}),n.jsx(Js,{value:u,onChange:N,options:i})]})}),n.jsx(c.Col,{flex:"none",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{children:"Anomaly type"}),n.jsx(Zs,{value:m,onChange:I,options:v})]})}),n.jsx(c.Col,{flex:"none",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{children:"Space"}),n.jsx(er,{value:w,onChange:y,options:p})]})}),n.jsx(c.Col,{flex:"none",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{children:"Action Taken"}),n.jsx(sr,{value:S,onChange:L,options:F})]})}),n.jsx(c.Col,{flex:"auto"}),n.jsx(c.Col,{flex:"none",children:n.jsx(c.Input.Search,{allowClear:!0,placeholder:"Search",onSearch:$,onChange:x=>$(x.target.value),className:"w-[260px] ",enterButton:!0})})]})})})}var Pe=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},rr={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nr=class{#e=rr;#t=!1;setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&this.#t&&e!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:e}),this.#e=e,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},Te=new nr;function ir(e){setTimeout(e,0)}var Ie=typeof window>"u"||"Deno"in globalThis;function ce(){}function ar(e,t){return typeof e=="function"?e(t):e}function Je(e){return typeof e=="number"&&e>=0&&e!==1/0}function Jt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function we(e,t){return typeof e=="function"?e(t):e}function de(e,t){return typeof e=="function"?e(t):e}function Ot(e,t){const{type:s="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=e;if(o){if(r){if(t.queryHash!==lt(o,t.options))return!1}else if(!Me(t.queryKey,o))return!1}if(s!=="all"){const f=t.isActive();if(s==="active"&&!f||s==="inactive"&&f)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||i&&i!==t.state.fetchStatus||a&&!a(t))}function Et(e,t){const{exact:s,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(s){if(Re(t.options.mutationKey)!==Re(a))return!1}else if(!Me(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function lt(e,t){return(t?.queryKeyHashFn||Re)(e)}function Re(e){return JSON.stringify(e,(t,s)=>Ze(s)?Object.keys(s).sort().reduce((r,i)=>(r[i]=s[i],r),{}):s)}function Me(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>Me(e[s],t[s])):!1}var or=Object.prototype.hasOwnProperty;function Xe(e,t,s=0){if(e===t)return e;if(s>500)return t;const r=Pt(e)&&Pt(t);if(!r&&!(Ze(e)&&Ze(t)))return t;const a=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),l=o.length,f=r?new Array(l):{};let d=0;for(let u=0;u<l;u++){const N=r?u:o[u],m=e[N],I=t[N];if(m===I){f[N]=m,(r?u<a:or.call(e,N))&&d++;continue}if(m===null||I===null||typeof m!="object"||typeof I!="object"){f[N]=I;continue}const w=Xe(m,I,s+1);f[N]=w,w===m&&d++}return a===l&&d===a?e:f}function qe(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Pt(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ze(e){if(!Mt(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!Mt(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Mt(e){return Object.prototype.toString.call(e)==="[object Object]"}function lr(e){return new Promise(t=>{Te.setTimeout(t,e)})}function et(e,t,s){if(typeof s.structuralSharing=="function")return s.structuralSharing(e,t);if(s.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Xe(e,t)}catch(r){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}]: ${r}`),r}return Xe(e,t)}return t}function cr(e,t,s=0){const r=[...e,t];return s&&r.length>s?r.slice(1):r}function ur(e,t,s=0){const r=[t,...e];return s&&r.length>s?r.slice(0,-1):r}var Qe=Symbol();function Xt(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Qe&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Qe?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ct(e,t){return typeof e=="function"?e(...t):!!e}function dr(e,t,s){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?s():i.addEventListener("abort",s,{once:!0})),i)}),e}var hr=class extends Pe{#e;#t;#s;constructor(){super(),this.#s=e=>{if(!Ie&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#s=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},ut=new hr;function tt(){let e,t;const s=new Promise((i,a)=>{e=i,t=a});s.status="pending",s.catch(()=>{});function r(i){Object.assign(s,i),delete s.resolve,delete s.reject}return s.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},s.reject=i=>{r({status:"rejected",reason:i}),t(i)},s}var fr=ir;function mr(){let e=[],t=0,s=l=>{l()},r=l=>{l()},i=fr;const a=l=>{t?e.push(l):i(()=>{s(l)})},o=()=>{const l=e;e=[],l.length&&i(()=>{r(()=>{l.forEach(f=>{s(f)})})})};return{batch:l=>{let f;t++;try{f=l()}finally{t--,t||o()}return f},batchCalls:l=>(...f)=>{a(()=>{l(...f)})},schedule:a,setNotifyFunction:l=>{s=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var ie=mr(),pr=class extends Pe{#e=!0;#t;#s;constructor(){super(),this.#s=e=>{if(!Ie&&window.addEventListener){const t=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#s=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(s=>{s(e)}))}isOnline(){return this.#e}},_e=new pr;function yr(e){return Math.min(1e3*2**e,3e4)}function Zt(e){return(e??"online")==="online"?_e.isOnline():!0}var st=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function es(e){let t=!1,s=0,r;const i=tt(),a=()=>i.status!=="pending",o=y=>{if(!a()){const S=new st(y);m(S),e.onCancel?.(S)}},l=()=>{t=!0},f=()=>{t=!1},d=()=>ut.isFocused()&&(e.networkMode==="always"||_e.isOnline())&&e.canRun(),u=()=>Zt(e.networkMode)&&e.canRun(),N=y=>{a()||(r?.(),i.resolve(y))},m=y=>{a()||(r?.(),i.reject(y))},I=()=>new Promise(y=>{r=S=>{(a()||d())&&y(S)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),w=()=>{if(a())return;let y;const S=s===0?e.initialPromise:void 0;try{y=S??e.fn()}catch(L){y=Promise.reject(L)}Promise.resolve(y).then(N).catch(L=>{if(a())return;const U=e.retry??(Ie?0:3),$=e.retryDelay??yr,F=typeof $=="function"?$(s,L):$,Y=U===!0||typeof U=="number"&&s<U||typeof U=="function"&&U(s,L);if(t||!Y){m(L);return}s++,e.onFail?.(s,L),lr(F).then(()=>d()?void 0:I()).then(()=>{t?m(L):w()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:f,canStart:u,start:()=>(u()?w():I().then(w),i)}}var ts=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Je(this.gcTime)&&(this.#e=Te.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ie?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Te.clearTimeout(this.#e),this.#e=void 0)}},gr=class extends ts{#e;#t;#s;#n;#r;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#n=e.client,this.#s=this.#n.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Ft(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=Ft(this.options);t.data!==void 0&&(this.setState(Dt(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(e,t){const s=et(this.state.data,e,this.options);return this.#i({data:s,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),s}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#r?.promise;return this.#r?.cancel(e),t?t.then(ce).catch(ce):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>de(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Qe||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>we(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Jt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(e&&this.setOptions(e),!this.options.queryFn){const l=this.observers.find(f=>f.options.queryFn);l&&this.setOptions(l.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,r=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#o=!0,s.signal)})},i=()=>{const l=Xt(this.options,t),d=(()=>{const u={client:this.#n,queryKey:this.queryKey,meta:this.meta};return r(u),u})();return this.#o=!1,this.options.persister?this.options.persister(l,d,this):l(d)},o=(()=>{const l={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return r(l),l})();this.options.behavior?.onFetch(o,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#i({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=es({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof st&&l.revert&&this.setState({...this.#t,fetchStatus:"idle"}),s.abort()},onFail:(l,f)=>{this.#i({type:"failed",failureCount:l,error:f})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===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(l),this.#s.config.onSuccess?.(l,this),this.#s.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof st){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#i({type:"error",error:l}),this.#s.config.onError?.(l,this),this.#s.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#i(e){const t=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...ss(s.data,this.options),fetchMeta:e.meta??null};case"success":const r={...s,...Dt(e.data,e.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?r:void 0,r;case"error":const i=e.error;return{...s,error:i,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=t(this.state),ie.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:e})})}};function ss(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Zt(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Dt(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ft(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,r=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var vr=class extends Pe{constructor(e,t){super(),this.options=t,this.#e=e,this.#i=null,this.#o=tt(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#s=void 0;#n=void 0;#r;#a;#o;#i;#p;#h;#f;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ut(this.#t,this.options)?this.#d():this.updateResult(),this.#x())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rt(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rt(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#S(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof de(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#A(),this.#t.setOptions(this.options),t._defaulted&&!qe(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&Lt(this.#t,s,this.options,t)&&this.#d(),this.updateResult(),r&&(this.#t!==s||de(this.options.enabled,this.#t)!==de(t.enabled,this.#t)||we(this.options.staleTime,this.#t)!==we(t.staleTime,this.#t))&&this.#y();const i=this.#g();r&&(this.#t!==s||de(this.options.enabled,this.#t)!==de(t.enabled,this.#t)||i!==this.#l)&&this.#v(i)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),s=this.createResult(t,e);return br(this,s)&&(this.#n=s,this.#a=this.options,this.#r=this.#t.state),s}getCurrentResult(){return this.#n}trackResult(e,t){return new Proxy(e,{get:(s,r)=>(this.trackProp(r),t?.(r),r==="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,r))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),s=this.#e.getQueryCache().build(this.#e,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#n))}#d(e){this.#A();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(ce)),t}#y(){this.#b();const e=we(this.options.staleTime,this.#t);if(Ie||this.#n.isStale||!Je(e))return;const s=Jt(this.#n.dataUpdatedAt,e)+1;this.#c=Te.setTimeout(()=>{this.#n.isStale||this.updateResult()},s)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#S(),this.#l=e,!(Ie||de(this.options.enabled,this.#t)===!1||!Je(this.#l)||this.#l===0)&&(this.#u=Te.setInterval(()=>{(this.options.refetchIntervalInBackground||ut.isFocused())&&this.#d()},this.#l))}#x(){this.#y(),this.#v(this.#g())}#b(){this.#c&&(Te.clearTimeout(this.#c),this.#c=void 0)}#S(){this.#u&&(Te.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const s=this.#t,r=this.options,i=this.#n,a=this.#r,o=this.#a,f=e!==s?e.state:this.#s,{state:d}=e;let u={...d},N=!1,m;if(t._optimisticResults){const H=this.hasListeners(),T=!H&&Ut(e,t),C=H&&Lt(e,s,t,r);(T||C)&&(u={...u,...ss(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:I,errorUpdatedAt:w,status:y}=u;m=u.data;let S=!1;if(t.placeholderData!==void 0&&m===void 0&&y==="pending"){let H;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(H=i.data,S=!0):H=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,H!==void 0&&(y="success",m=et(i?.data,H,t),N=!0)}if(t.select&&m!==void 0&&!S)if(i&&m===a?.data&&t.select===this.#p)m=this.#h;else try{this.#p=t.select,m=t.select(m),m=et(i?.data,m,t),this.#h=m,this.#i=null}catch(H){this.#i=H}this.#i&&(I=this.#i,m=this.#h,w=Date.now(),y="error");const L=u.fetchStatus==="fetching",U=y==="pending",$=y==="error",F=U&&L,Y=m!==void 0,W={status:y,fetchStatus:u.fetchStatus,isPending:U,isSuccess:y==="success",isError:$,isInitialLoading:F,isLoading:F,data:m,dataUpdatedAt:u.dataUpdatedAt,error:I,errorUpdatedAt:w,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>f.dataUpdateCount||u.errorUpdateCount>f.errorUpdateCount,isFetching:L,isRefetching:L&&!U,isLoadingError:$&&!Y,isPaused:u.fetchStatus==="paused",isPlaceholderData:N,isRefetchError:$&&Y,isStale:dt(e,t),refetch:this.refetch,promise:this.#o,isEnabled:de(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const H=W.data!==void 0,T=W.status==="error"&&!H,C=X=>{T?X.reject(W.error):H&&X.resolve(W.data)},R=()=>{const X=this.#o=W.promise=tt();C(X)},ee=this.#o;switch(ee.status){case"pending":e.queryHash===s.queryHash&&C(ee);break;case"fulfilled":(T||W.data!==ee.value)&&R();break;case"rejected":(!T||W.error!==ee.reason)&&R();break}}return W}updateResult(){const e=this.#n,t=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#a=this.options,this.#r.data!==void 0&&(this.#f=this.#t),qe(t,e))return;this.#n=t;const s=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#m.size)return!0;const a=new Set(i??this.#m);return this.options.throwOnError&&a.add("error"),Object.keys(this.#n).some(o=>{const l=o;return this.#n[l]!==e[l]&&a.has(l)})};this.#N({listeners:s()})}#A(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#x()}#N(e){ie.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#n)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function xr(e,t){return de(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ut(e,t){return xr(e,t)||e.state.data!==void 0&&rt(e,t,t.refetchOnMount)}function rt(e,t,s){if(de(t.enabled,e)!==!1&&we(t.staleTime,e)!=="static"){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&dt(e,t)}return!1}function Lt(e,t,s,r){return(e!==t||de(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&dt(e,s)}function dt(e,t){return de(t.enabled,e)!==!1&&e.isStaleByTime(we(t.staleTime,e))}function br(e,t){return!qe(e.getCurrentResult(),t)}function $t(e){return{onFetch:(t,s)=>{const r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[];let l={pages:[],pageParams:[]},f=0;const d=async()=>{let u=!1;const N=w=>{dr(w,()=>t.signal,()=>u=!0)},m=Xt(t.options,t.fetchOptions),I=async(w,y,S)=>{if(u)return Promise.reject();if(y==null&&w.pages.length)return Promise.resolve(w);const U=(()=>{const V={client:t.client,queryKey:t.queryKey,pageParam:y,direction:S?"backward":"forward",meta:t.options.meta};return N(V),V})(),$=await m(U),{maxPages:F}=t.options,Y=S?ur:cr;return{pages:Y(w.pages,$,F),pageParams:Y(w.pageParams,y,F)}};if(i&&a.length){const w=i==="backward",y=w?Sr:Bt,S={pages:a,pageParams:o},L=y(r,S);l=await I(S,L,w)}else{const w=e??a.length;do{const y=f===0?o[0]??r.initialPageParam:Bt(r,l);if(f>0&&y==null)break;l=await I(l,y),f++}while(f<w)}return l};t.options.persister?t.fetchFn=()=>t.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s):t.fetchFn=d}}}function Bt(e,{pages:t,pageParams:s}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,s[r],s):void 0}function Sr(e,{pages:t,pageParams:s}){return t.length>0?e.getPreviousPageParam?.(t[0],t,s[0],s):void 0}var Ar=class extends ts{#e;#t;#s;#n;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#s=e.mutationCache,this.#t=[],this.state=e.state||rs(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#s.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#r({type:"continue"})},s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#n=es({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#r({type:"failed",failureCount:a,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const r=this.state.status==="pending",i=!this.#n.canStart();try{if(r)t();else{this.#r({type:"pending",variables:e,isPaused:i}),await this.#s.config.onMutate?.(e,this,s);const o=await this.options.onMutate?.(e,s);o!==this.state.context&&this.#r({type:"pending",context:o,variables:e,isPaused:i})}const a=await this.#n.start();return await this.#s.config.onSuccess?.(a,e,this.state.context,this,s),await this.options.onSuccess?.(a,e,this.state.context,s),await this.#s.config.onSettled?.(a,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(a,null,e,this.state.context,s),this.#r({type:"success",data:a}),a}catch(a){try{await this.#s.config.onError?.(a,e,this.state.context,this,s)}catch(o){Promise.reject(o)}try{await this.options.onError?.(a,e,this.state.context,s)}catch(o){Promise.reject(o)}try{await this.#s.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,s)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,a,e,this.state.context,s)}catch(o){Promise.reject(o)}throw this.#r({type:"error",error:a}),a}finally{this.#s.runNext(this)}}#r(e){const t=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ie.batch(()=>{this.#t.forEach(s=>{s.onMutationUpdate(e)}),this.#s.notify({mutation:this,type:"updated",action:e})})}};function rs(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Nr=class extends Pe{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#s=0}#e;#t;#s;build(e,t,s){const r=new Ar({client:e,mutationCache:this,mutationId:++this.#s,options:e.defaultMutationOptions(t),state:s});return this.add(r),r}add(e){this.#e.add(e);const t=Le(e);if(typeof t=="string"){const s=this.#t.get(t);s?s.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=Le(e);if(typeof t=="string"){const s=this.#t.get(t);if(s)if(s.length>1){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}else s[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Le(e);if(typeof t=="string"){const r=this.#t.get(t)?.find(i=>i.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=Le(e);return typeof t=="string"?this.#t.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ie.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(s=>Et(t,s))}findAll(e={}){return this.getAll().filter(t=>Et(e,t))}notify(e){ie.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ie.batch(()=>Promise.all(e.map(t=>t.continue().catch(ce))))}};function Le(e){return e.options.scope?.id}var wr=class extends Pe{#e;#t=void 0;#s;#n;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#e.defaultMutationOptions(e),qe(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),t?.mutationKey&&this.options.mutationKey&&Re(t.mutationKey)!==Re(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#r(),this.#a()}mutate(e,t){return this.#n=t,this.#s?.removeObserver(this),this.#s=this.#e.getMutationCache().build(this.#e,this.options),this.#s.addObserver(this),this.#s.execute(e)}#r(){const e=this.#s?.state??rs();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){ie.batch(()=>{if(this.#n&&this.hasListeners()){const t=this.#t.variables,s=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#n.onSuccess?.(e.data,t,s,r)}catch(i){Promise.reject(i)}try{this.#n.onSettled?.(e.data,null,t,s,r)}catch(i){Promise.reject(i)}}else if(e?.type==="error"){try{this.#n.onError?.(e.error,t,s,r)}catch(i){Promise.reject(i)}try{this.#n.onSettled?.(void 0,e.error,t,s,r)}catch(i){Promise.reject(i)}}}this.listeners.forEach(t=>{t(this.#t)})})}},jr=class extends Pe{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,s){const r=t.queryKey,i=t.queryHash??lt(r,t);let a=this.get(i);return a||(a=new gr({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ie.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(s=>Ot(t,s))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(s=>Ot(e,s)):t}notify(e){ie.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ie.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ie.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Cr=class{#e;#t;#s;#n;#r;#a;#o;#i;constructor(e={}){this.#e=e.queryCache||new jr,this.#t=e.mutationCache||new Nr,this.#s=e.defaultOptions||{},this.#n=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ut.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=_e.subscribe(async e=>{e&&(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(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=this.#e.build(this,t),r=s.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(we(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:s})=>{const r=s.data;return[t,r]})}setQueryData(e,t,s){const r=this.defaultQueryOptions({queryKey:e}),a=this.#e.get(r.queryHash)?.state.data,o=ar(t,a);if(o!==void 0)return this.#e.build(this,r).setData(o,{...s,manual:!0})}setQueriesData(e,t,s){return ie.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,s)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;ie.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=this.#e;return ie.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},r=ie.batch(()=>this.#e.findAll(e).map(i=>i.cancel(s)));return Promise.all(r).then(ce).catch(ce)}invalidateQueries(e,t={}){return ie.batch(()=>(this.#e.findAll(e).forEach(s=>{s.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},r=ie.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,s);return s.throwOnError||(a=a.catch(ce)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(ce)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=this.#e.build(this,t);return s.isStaleByTime(we(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ce).catch(ce)}fetchInfiniteQuery(e){return e.behavior=$t(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ce).catch(ce)}ensureInfiniteQueryData(e){return e.behavior=$t(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return _e.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#s}setDefaultOptions(e){this.#s=e}setQueryDefaults(e,t){this.#n.set(Re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#n.values()],s={};return t.forEach(r=>{Me(e,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(e,t){this.#r.set(Re(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#r.values()],s={};return t.forEach(r=>{Me(e,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#s.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=lt(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Qe&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#s.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},ns=le.createContext(void 0),ht=e=>{const t=le.useContext(ns);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Tr=({client:e,children:t})=>(le.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),n.jsx(ns.Provider,{value:e,children:t})),is=le.createContext(!1),Ir=()=>le.useContext(is);is.Provider;function Rr(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kr=le.createContext(Rr()),Or=()=>le.useContext(kr),Er=(e,t,s)=>{const r=s?.state.error&&typeof e.throwOnError=="function"?ct(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Pr=e=>{le.useEffect(()=>{e.clearReset()},[e])},Mr=({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ct(s,[e.error,r])),Dr=e=>{if(e.suspense){const s=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>s(r(...i)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Fr=(e,t)=>e.isLoading&&e.isFetching&&!t,Ur=(e,t)=>e?.suspense&&t.isPending,qt=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Lr(e,t,s){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))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 r=Ir(),i=Or(),a=ht(),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=a.getQueryCache().get(o.queryHash);process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.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`)),o._optimisticResults=r?"isRestoring":"optimistic",Dr(o),Er(o,i,l),Pr(i);const f=!a.getQueryCache().get(o.queryHash),[d]=le.useState(()=>new t(a,o)),u=d.getOptimisticResult(o),N=!r&&e.subscribed!==!1;if(le.useSyncExternalStore(le.useCallback(m=>{const I=N?d.subscribe(ie.batchCalls(m)):ce;return d.updateResult(),I},[d,N]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),le.useEffect(()=>{d.setOptions(o)},[o,d]),Ur(o,u))throw qt(o,d,i);if(Mr({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!Ie&&Fr(u,r)&&(f?qt(o,d,i):l?.promise)?.catch(ce).finally(()=>{d.updateResult()}),o.notifyOnChangeProps?u:d.trackResult(u)}function ft(e,t){return Lr(e,vr)}function $r(e,t){const s=ht(),[r]=le.useState(()=>new wr(s,e));le.useEffect(()=>{r.setOptions(e)},[r,e]);const i=le.useSyncExternalStore(le.useCallback(o=>r.subscribe(ie.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=le.useCallback((o,l)=>{r.mutate(o,l).catch(ce)},[r]);if(i.error&&ct(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function mt(){const{alerts:e}=he(),t=ht();return $r({mutationFn:s=>e.updateAlertStatus(s),onSuccess:()=>{t.invalidateQueries({queryKey:["alerts","list"]}),t.invalidateQueries({queryKey:["alerts","report"]})}})}function Br(e,t){return e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZone:t})}function qr(e,t){try{const i=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"}).formatToParts(e).find(o=>o.type==="timeZoneName")?.value;let a;try{const l=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"shortOffset"}).formatToParts(e).find(f=>f.type==="timeZoneName");l?.value&&l.value.startsWith("GMT")&&(a=l.value.replace("GMT",""))}catch{}return{abbr:i,offset:a}}catch{return{}}}function Qr(e){if(!e)return"-";try{const t=new Date(e),s=d=>String(d).padStart(2,"0"),r=s(t.getMonth()+1),i=s(t.getDate()),a=t.getFullYear(),o=s(t.getHours()),l=s(t.getMinutes()),f=s(t.getSeconds());return`${r}/${i}/${a} ${o}:${l}:${f}`}catch{return"-"}}function nt(e){if(!e)return"-";try{return new Date(e).toLocaleString("en-US",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"-"}}const _r={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},Hr={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"};function as({alerts:e,loading:t=!1,pageSize:s=10,severityOptions:r,anomalyOptions:i,spaceOptions:a,onAlertIdClick:o}){const l=mt(),f=["completed","false positive"],d=async m=>{try{const I=await l.mutateAsync({alertUniqueId:m.alertId??m.id,alertId:m.id,status:"Reopen",notes:"Reopened",modifiedBy:0});if(I?.responseStatus){const w=I?.data||"Alert reopened successfully.";re.toast.success(w)}else{const w=I?.errorMessage||"Failed to reopen alert";re.toast.error(w)}}catch{re.toast.error("Failed to reopen alert. Please try again.")}},u=[{title:"Severity",dataIndex:"priority",key:"priority",width:120,render:m=>n.jsx(c.Tag,{className:"px-[10px] py-[2px]",style:{border:`2px solid ${_r[m]}`,backgroundColor:Hr[String(m)]},children:m})},{title:"Timestamp",dataIndex:"timestamp",key:"timestamp",width:200,render:m=>Qr(m)},{title:"Status",dataIndex:"statusType",key:"statusType",width:140},{title:"Description",dataIndex:"description",key:"description",render:(m,I)=>n.jsxs("div",{children:[n.jsx("a",{onClick:w=>{w.preventDefault(),o?.(I)},className:"inline-block mb-1 text-blue-600",children:I.alertNumber}),n.jsx("div",{className:"text-black/65",children:m})]})},{title:"",key:"menu",width:60,align:"right",render:(m,I)=>n.jsx(c.Dropdown,{trigger:["click"],menu:{items:[{key:"reopen",label:"Reopen"}],onClick:({key:w})=>{w==="reopen"&&d(I)}},children:n.jsx(c.Button,{type:"text",icon:n.jsx(Ee.MoreOutlined,{})})})}],N=(e||[]).filter(m=>f.includes((m.statusType||"").toLowerCase()));return n.jsx(ot,{data:N,loading:t,pageSize:s,columns:u,severityOptions:r,anomalyOptions:i,spaceOptions:a,renderActions:void 0,onAlertIdClick:o,excludeCompleted:!1})}function Gr({size:e=120,time:t,timeZone:s="America/New_York"}){const{hours:r,minutes:i,seconds:a}=h.useMemo(()=>{const N=new Intl.DateTimeFormat("en-US",{timeZone:s,hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(t);return{hours:parseInt(N.find(m=>m.type==="hour")?.value||"0",10),minutes:parseInt(N.find(m=>m.type==="minute")?.value||"0",10),seconds:parseInt(N.find(m=>m.type==="second")?.value||"0",10)}},[t,s]),o=a*6,l=i*6+a*.1,f=r%12*30+i*.5,d=e/2;return n.jsxs("div",{className:"relative rounded-full border border-gray-300 bg-white",style:{width:e,height:e},role:"img","aria-label":"Analog Clock",children:[[...Array(12)].map((u,N)=>{const m=N*30,I=6,w=d-4,y=w-I,S=(m-90)*(Math.PI/180),L=d+y*Math.cos(S),U=d+y*Math.sin(S),$=d+w*Math.cos(S),F=d+w*Math.sin(S);return n.jsx("svg",{className:"absolute inset-0",width:e,height:e,children:n.jsx("line",{x1:L,y1:U,x2:$,y2:F,stroke:"#9CA3AF",strokeWidth:N%3===0?2:1,strokeLinecap:"round"})},N)}),n.jsx("svg",{className:"absolute inset-0",width:e,height:e,style:{transform:`rotate(${f}deg)`},children:n.jsx("line",{x1:d,y1:d,x2:d,y2:d-e*.25,stroke:"#1F2937",strokeWidth:4,strokeLinecap:"round"})}),n.jsx("svg",{className:"absolute inset-0",width:e,height:e,style:{transform:`rotate(${l}deg)`},children:n.jsx("line",{x1:d,y1:d,x2:d,y2:d-e*.35,stroke:"#374151",strokeWidth:3,strokeLinecap:"round"})}),n.jsx("svg",{className:"absolute inset-0",width:e,height:e,style:{transform:`rotate(${o}deg)`},children:n.jsx("line",{x1:d,y1:d+e*.08,x2:d,y2:d-e*.38,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"})}),n.jsx("div",{className:"absolute bg-gray-900 rounded-full",style:{width:8,height:8,left:d-4,top:d-4}})]})}function os({label:e="USA",timeZone:t="America/New_York",updateIntervalMs:s=1e3,className:r}){const[i,a]=h.useState(new Date);h.useEffect(()=>{const d=setInterval(()=>a(new Date),s);return()=>clearInterval(d)},[s]);const o=h.useMemo(()=>Br(i,t),[i,t]),{abbr:l,offset:f}=h.useMemo(()=>qr(i,t),[i,t]);return n.jsxs("div",{className:`flex items-center gap-3 ${r||""}`,children:[n.jsx(Gr,{time:i,timeZone:t,size:80}),n.jsxs("div",{className:"flex flex-col items-baseline gap-1",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[n.jsx("span",{className:"uppercase",children:e}),l&&n.jsx("span",{className:"px-1.5 py-0.5 rounded-md border text-[10px] leading-none text-gray-600 bg-gray-50",children:l}),f&&n.jsx("span",{className:"text-xs text-gray-500",children:f})]}),n.jsx("div",{className:"text-2xl font-semibold text-gray-700 tracking-wide",children:o})]})]})}const Wr=[{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}],Yr=[{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"}],Kr=[{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"}],Oe={severities:Wr,rules:Yr,userRoles:Kr},{Text:zr}=c.Typography;function Vr({sortBy:e,onChange:t,showActions:s,onSave:r,onClear:i,saving:a}){return n.jsxs(c.Row,{gutter:[16,16],align:"middle",children:[n.jsx(c.Col,{xs:24,md:8,lg:5,children:n.jsxs(c.Space,{className:"w-full items-center",direction:"horizontal",size:12,children:[n.jsx(zr,{className:"text-gray-600",children:"Sort by:"}),n.jsx(c.Select,{placeholder:"By Severity",value:e,onChange:o=>t({sortBy:o}),options:[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],className:"w-full",style:{minWidth:"200px"}})]})}),n.jsx(c.Col,{xs:24,md:8,style:{alignSelf:"end"},children:s?n.jsxs(c.Space,{className:"w-full",direction:"horizontal",size:8,children:[n.jsx(c.Button,{onClick:i,disabled:a,children:"Clear"}),n.jsx(c.Button,{type:"primary",onClick:r,loading:a,children:"Save"})]}):null})]})}const{Text:xe}=c.Typography;function Jr(e){const{selectedRule:t,setSelectedRule:s,ruleOptions:r,minsOptions:i,roleOptions:a,l1mins:o,setL1mins:l,l1role:f,setL1role:d,l2mins:u,setL2mins:N,l2role:m,setL2role:I,l3mins:w,setL3mins:y,l3role:S,setL3role:L,actions:U,setActions:$,thirdPartyIds:F,setThirdPartyIds:Y,humanLoop:V,setHumanLoop:W,onClear:H,onSave:T,saving:C,onActionTypesLoaded:R}=e,{rules:ee}=he(),[X,k]=h.useState([]),[v,p]=h.useState([]),[A,g]=h.useState(!1);h.useEffect(()=>{let O=!1;return(async()=>{try{g(!0);const D=await ee.getLookups();if(O||!D||!Array.isArray(D.actionTypes))return;const P=D.actionTypes.map(q=>({label:q.name,value:String(q.actionTypeId)}));k(P),R&&R(D.actionTypes);const B=Array.isArray(D.thirdParties)?D.thirdParties.map(q=>({label:q.thirdPartyName,value:q.thirdPartyId})):[];p(B)}catch(D){console.error("Error loading lookups",D)}finally{O||g(!1)}})(),()=>{O=!0}},[]);const x=typeof o=="number"||typeof f=="number"||typeof u=="number"||typeof m=="number"||typeof w=="number"||typeof S=="number"||Array.isArray(U)&&U.length>0||Array.isArray(F)&&F.length>0||!!V,b=!!t&&x&&!C;return n.jsxs(c.Spin,{spinning:!!C||A,children:[n.jsxs(c.Row,{gutter:[16,16],align:"bottom",children:[n.jsx(c.Col,{xs:24,sm:12,md:8,lg:4,children:n.jsxs("div",{children:[n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Rules"}),n.jsx(c.Select,{placeholder:"Rules",value:t,onChange:s,options:r,className:"w-full"})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,lg:4,children:n.jsxs("div",{children:[n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 1 (mins)"})}),n.jsx(c.Col,{span:14,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(c.Select,{className:"w-full",placeholder:"Mins",value:o,onChange:l,options:i})}),n.jsx(c.Col,{span:14,children:n.jsx(c.Select,{placeholder:"Escalate to",className:"w-full",value:f,onChange:d,options:a})})]})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,lg:4,children:n.jsxs("div",{children:[n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 2 (mins)"})}),n.jsx(c.Col,{span:14,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(c.Select,{className:"w-full",placeholder:"Mins",value:u,onChange:N,options:i})}),n.jsx(c.Col,{span:14,children:n.jsx(c.Select,{placeholder:"Escalate to",className:"w-full",value:m,onChange:I,options:a})})]})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,lg:4,children:n.jsxs("div",{children:[n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Level 3 (mins)"})}),n.jsx(c.Col,{span:14,children:n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Escalate to"})})]}),n.jsxs(c.Row,{gutter:8,children:[n.jsx(c.Col,{span:10,children:n.jsx(c.Select,{className:"w-full",placeholder:"Mins",value:w,onChange:y,options:i})}),n.jsx(c.Col,{span:14,children:n.jsx(c.Select,{placeholder:"Escalate to",className:"w-full",value:S,onChange:L,options:a})})]})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,lg:5,children:n.jsxs("div",{children:[n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Pick Actions"}),n.jsx(c.Select,{mode:"multiple",placeholder:"Select response actions",className:"w-full",value:U,onChange:$,options:X})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,lg:3,children:n.jsx("div",{className:"flex items-end h-full",children:n.jsx(c.Checkbox,{checked:V,onChange:O=>W(O.target.checked),children:"Human-In-The-Loop"})})})]}),n.jsxs(c.Row,{gutter:[16,16],align:"bottom",className:"mt-4",children:[n.jsx(c.Col,{xs:24,sm:12,md:8,lg:5,children:n.jsxs("div",{children:[n.jsx(xe,{className:"text-gray-700 font-medium block mb-1",children:"Third Party App"}),n.jsx(c.Select,{mode:"multiple",placeholder:"Third Party app",className:"w-full",value:F,onChange:Y,options:v})]})}),n.jsx(c.Col,{xs:24,sm:12,md:8,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(c.Button,{onClick:H,children:"Clear"}),n.jsx(c.Button,{type:"primary",onClick:T,loading:!!C,disabled:!b,children:"Save"})]})})]})]})}function Xr({entries:e,userRoles:t,onEdit:s,loading:r}){const i=new Map(t.map(o=>[o.userRoleId,o.userRoleName])),a=o=>o.map(l=>i.get(l)||String(l)).join(", ");return n.jsx(c.Table,{rowKey:"id",dataSource:e,pagination:!1,loading:r,columns:[{title:"Rule",dataIndex:"ruleOrSeverityLabel",key:"rule"},{title:"Level 1",key:"l1",render:(o,l)=>n.jsxs("span",{children:[l.l1.minutes?`Action taken in (${l.l1.minutes} Mins)`:"No Action taken in 0 Min",l.l1.roles?.length?`, Escalate to (${a(l.l1.roles)})`:""]})},{title:"Level 2",key:"l2",render:(o,l)=>n.jsxs("span",{children:[l.l2.minutes?`Action taken in (${l.l2.minutes} Mins)`:"No Action taken in 0 Min",l.l2.roles?.length?`, Escalate to (${a(l.l2.roles)})`:""]})},{title:"Level 3",key:"l3",render:(o,l)=>n.jsxs("span",{children:[l.l3.minutes?`Action taken in (${l.l3.minutes} Mins)`:"No Action taken in 0 Min",l.l3.roles?.length?`, Escalate to (${a(l.l3.roles)})`:""]})},{title:"Pick Actions",key:"actionsCol",render:(o,l)=>l.actions&&l.actions.length?l.actions.join(", "):"-"},{title:"Notify",key:"notify",render:(o,l)=>l.notify&&l.notify.length?l.notify.join(", "):"-"},{title:"Human-In-The-Loop",key:"humanLoop",render:(o,l)=>l.humanLoop?"Yes":"No"},{title:"Actions",key:"ops",render:(o,l)=>n.jsx(c.Button,{type:"text",onClick:()=>s(l.id),children:n.jsx(Ee.EditOutlined,{})})}]})}const{Title:Zr}=c.Typography;function ls({userRoles:e,rules:t,rawRules:s}){const{rules:r}=he(),[i,a]=h.useState(!1),[o,l]=h.useState(s),[f,d]=h.useState({}),u=h.useMemo(()=>e.map(y=>({label:y.userRoleName,value:y.userRoleId})),[e]),N=h.useMemo(()=>(t||[]).map((y,S)=>({key:y.RuleId||y.Name||String(S),ruleName:y.Name||"-",ruleDesc:y.Description||""})),[t]);h.useEffect(()=>{let y=!1;return(async()=>{try{a(!0);const S=await r.getRules();y||(l(Array.isArray(S)?S:[]),d({}))}catch{!y&&Array.isArray(s)&&l(s)}finally{y||a(!1)}})(),()=>{y=!0}},[]),h.useEffect(()=>{!o&&Array.isArray(s)&&l(s)},[s]);const m=h.useMemo(()=>{if(!Array.isArray(o)||!o.length)return{};const y={};for(const S of N){const L=o.find($=>$?.ruleId===S.key||$?.ruleName===S.key||$?.RuleId===S.key||$?.ruleName===S.ruleName||$?.Name===S.ruleName),U=Array.isArray(L?.userRoleIds)?L.userRoleIds:[];U.length&&(y[S.key]=U)}return y},[o,N]),I=()=>{d({})},w=async()=>{try{if(!o||!Array.isArray(o)||Object.keys(f).length===0){re.toast.info("No changes to save");return}a(!0);const y=Object.entries(f).map(async([S,L])=>{const U=o.find(W=>W?.ruleId===S||W?.ruleName===S||W?.RuleId===S),$=typeof U?.recordId=="number"?U.recordId:void 0;if(!U||typeof $!="number")throw new Error(`Unable to find recordId for rule ${S}`);const F=Array.isArray(L)?L:[],Y=F.map(W=>{const H=e.find(T=>T.userRoleId===W);return{id:W,name:H?.userRoleName??String(W)}}),V={...U,ruleId:S,userRoleIds:F,userRoles:Y,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 r.updateRule($,V)});await Promise.all(y),re.toast.success("Alert assignment saved");try{const S=await r.getRules();l(Array.isArray(S)?S:[]),d({})}catch(S){console.error("Failed to refresh rules after save",S)}}catch(y){console.error("Failed to save alert assignment",y)}finally{a(!1)}};return n.jsxs("div",{className:"w-full",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx(Zr,{level:4,className:"!mb-4",children:"Alert Assignment"})}),n.jsx(c.Table,{rowKey:"key",dataSource:N,loading:i,pagination:!1,columns:[{title:"Rule Name",dataIndex:"ruleName",key:"ruleName"},{title:"Description",dataIndex:"ruleDesc",key:"ruleDesc"},{title:"Alert Notification To",key:"assign",render:(y,S)=>n.jsx(c.Select,{mode:"multiple",placeholder:"Dropdown with Multi select",className:"w-full",value:f[S.key]??m[S.key]??[],onChange:L=>d(U=>({...U,[S.key]:L})),options:u})}]}),n.jsxs(c.Space,{className:"mt-4",children:[n.jsx(c.Button,{onClick:I,disabled:i,children:"Clear"}),n.jsx(c.Button,{type:"primary",onClick:w,loading:i,disabled:i||Object.keys(f).length===0,children:"Save"})]})]})}const{Title:Qt}=c.Typography;function cs({severities:e,rules:t,userRoles:s,rawRules:r,onSave:i}){const{rules:a,alerts:o}=he(),[l,f]=h.useState("By Severity"),[d,u]=h.useState("By severity"),[N,m]=h.useState("By Severity"),[I,w]=h.useState(!1),[y,S]=h.useState(!1),[L,U]=h.useState(!1),[$,F]=h.useState(null),[Y,V]=h.useState("rules"),[W,H]=h.useState(),[T,C]=h.useState(),[R,ee]=h.useState(),[X,k]=h.useState(),[v,p]=h.useState(),[A,g]=h.useState(),[x,b]=h.useState(),[O,D]=h.useState(),[P,B]=h.useState([]),[q,K]=h.useState([]),[ne,ue]=h.useState(!1),[oe,se]=h.useState({}),[j,_]=h.useState({}),[z,be]=h.useState(s||[]),[Se,ke]=h.useState([]),[Ge,Ae]=h.useState(!1),[We,yt]=h.useState(!1),[je,gt]=h.useState(r||[]);h.useEffect(()=>{r&&r.length&&gt(r)},[r]),h.useEffect(()=>{if(!je||!je.length)return;const E=Object.keys(oe).length>0||Object.keys(j).length>0;if(Se.length&&!E)return;const Z=je.map((Q,M)=>{const J=t.find(ye=>ye.RuleId===(Q.ruleId||Q.ruleName))?.Name||Q.ruleName||Q.Name||"-",G=Q.escalationSettings||{},te=typeof G.level1UserRoleId=="number"&&G.level1UserRoleId>0?[G.level1UserRoleId]:[],pe=typeof G.level2UserRoleId=="number"&&G.level2UserRoleId>0?[G.level2UserRoleId]:[],Ye=typeof G.level3UserRoleId=="number"&&G.level3UserRoleId>0?[G.level3UserRoleId]:[],xt=(Array.isArray(G.escalationSettingsActionTypeIds)?G.escalationSettingsActionTypeIds:[]).map(ye=>oe[ye]||String(ye)),St=(Array.isArray(G.thirdPartyId)?G.thirdPartyId:[]).map(ye=>j[ye]||String(ye)),Ke=typeof G.humanLoop=="boolean"?G.humanLoop:null;return{id:String(Q.ruleId||Q.ruleName||M),ruleOrSeverityLabel:J,l1:{minutes:G.level1PostAssistTime??void 0,roles:te},l2:{minutes:G.level2PostAssistTime??void 0,roles:pe},l3:{minutes:G.level3PostAssistTime??void 0,roles:Ye},actions:xt,notify:St,humanLoop:Ke}});ke(Z)},[je,t,oe,j]);const ms=h.useMemo(()=>e.map(E=>({label:E.DisplayName,value:E.SeverityId})),[e]),ps=h.useMemo(()=>t.map(E=>({label:E.Name,value:E.RuleId})),[t]),ys=h.useMemo(()=>z.map(E=>({label:E.userRoleName,value:E.userRoleId})),[z]),gs=h.useMemo(()=>[1,3,5,10,15,20,30,45,60].map(E=>({label:`${E}`,value:E})),[]);h.useEffect(()=>{let E=!1;async function Z(){try{U(!0),F(null);const Q=await o.getAdminSettings();if(!E&&Q){const M=Wt(Q.sortBy);f(M),m(M),w(!1)}}catch(Q){if(!E){const M=Q instanceof Error?Q.message:"Failed to load admin settings";F(M)}}finally{E||U(!1)}}return Z(),()=>{E=!0}},[]),h.useEffect(()=>{if(!T)return;const E=J=>{const G=Number(J);return!isNaN(G)&&G>0?G:void 0},Z=J=>{const G=Number(J);return!isNaN(G)&&G>0?G:void 0},M=(je||[]).find(J=>J?.ruleId===T||J?.ruleName===T||J?.RuleId===T)?.escalationSettings;if(M&&typeof M=="object"){ee(Z(M.level1PostAssistTime)),k(E(M.level1UserRoleId)),p(Z(M.level2PostAssistTime)),g(E(M.level2UserRoleId)),b(Z(M.level3PostAssistTime)),D(E(M.level3UserRoleId));const J=Array.isArray(M.escalationSettingsActionTypeIds)?M.escalationSettingsActionTypeIds:[];B(J.map(G=>String(G))),K(Array.isArray(M.thirdPartyId)?M.thirdPartyId:[]),ue(!!M.humanLoop)}},[Y,T,je]);const vs=async()=>{try{yt(!0);const E=await a.getRules(),Z=Array.isArray(E)?E:Array.isArray(E?.data)?E.data:[];gt(Z);const Q=Z.map((M,J)=>{const G=t.find(Ce=>Ce.RuleId===(M.ruleId||M.ruleName))?.Name||M.ruleName||M.Name||"-",te=M.escalationSettings||{},pe=typeof te.level1UserRoleId=="number"&&te.level1UserRoleId>0?[te.level1UserRoleId]:[],Ye=typeof te.level2UserRoleId=="number"&&te.level2UserRoleId>0?[te.level2UserRoleId]:[],vt=typeof te.level3UserRoleId=="number"&&te.level3UserRoleId>0?[te.level3UserRoleId]:[],bt=(Array.isArray(te.escalationSettingsActionTypeIds)?te.escalationSettingsActionTypeIds:[]).map(Ce=>oe[Ce]||String(Ce)),Ke=(Array.isArray(te.thirdPartyId)?te.thirdPartyId:[]).map(Ce=>j[Ce]||String(Ce)),ye=typeof te.humanLoop=="boolean"?te.humanLoop:null;return{id:String(M.ruleId||M.ruleName||J),ruleOrSeverityLabel:G,l1:{minutes:te.level1PostAssistTime??void 0,roles:pe},l2:{minutes:te.level2PostAssistTime??void 0,roles:Ye},l3:{minutes:te.level3PostAssistTime??void 0,roles:vt},actions:bt,notify:Ke,humanLoop:ye}});ke(Q)}catch(E){console.error("Failed to refetch entries",E)}finally{yt(!1)}};h.useEffect(()=>{let E=!1;return(async()=>{try{const Z=await a.getLookups();if(E||!Z)return;const Q={};if(Array.isArray(Z.thirdParties))for(const J of Z.thirdParties)typeof J.thirdPartyId=="number"&&(Q[J.thirdPartyId]=J.thirdPartyName);_(Q);const M=Array.isArray(Z.userRoles)?Z.userRoles.map(J=>({userRoleId:J.userRoleId??J.id,userRoleName:J.userRoleName??J.name})):[];E||be(M.length?M:s||[])}catch(Z){console.error("Error loading lookups",Z)}})(),()=>{E=!0}},[]);const xs=async()=>{S(!0);try{const E=await o.setAdminSettings({sortBy:l,groupBy:"string"});E?.responseStatus&&E?.data&&re.toast.success(E.data),m(l),w(!1)}catch(E){console.error("Error saving admin settings",E)}finally{S(!1)}},bs=()=>{f(N),w(!1)},Ss=async()=>{Ae(!0),i?.({ruleId:T,levels:[{minutes:R,role:X},{minutes:v,role:A},{minutes:x,role:O}],actions:P,thirdPartyIds:q,humanLoop:ne});try{if(T){const Q=Array.isArray(P)?P.map(pe=>Number(pe)):[],M=(je||[]).find(pe=>pe?.ruleId===T||pe?.ruleName===T||pe?.RuleId===T),J=typeof M?.recordId=="number"?M.recordId:void 0;if(!M||typeof J!="number"){re.toast.error("Unable to find rule recordId for update");return}const G={...M,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:X??0,level1PostAssistTime:R??0,level2UserRoleId:A??0,level2PostAssistTime:v??0,level3UserRoleId:O??0,level3PostAssistTime:x??0,escalationSettingsActionTypeIds:Q,thirdPartyId:Array.isArray(q)?q:[],humanLoop:ne}},te=await a.updateRule(J,G);if(te?.responseStatus||te?.ok||te){re.toast.success("Escalation settings saved"),await vs(),C(void 0),ee(void 0),k(void 0),p(void 0),g(void 0),b(void 0),D(void 0),B([]),K([]),ue(!1);return}}}catch(Q){console.error("Error saving escalation settings",Q)}finally{Ae(!1)}const Z=t.find(Q=>Q.RuleId===T)?.Name||"-";ke(Q=>[...Q,{id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ruleOrSeverityLabel:Z,l1:{minutes:R,roles:X?[X]:[]},l2:{minutes:v,roles:A?[A]:[]},l3:{minutes:x,roles:O?[O]:[]},actions:(Array.isArray(P)?P:[]).map(M=>{const J=Number(M);return oe[J]||String(M)}),notify:(Array.isArray(q)?q:[]).map(M=>j[M]||String(M)),humanLoop:!!ne}])},As=()=>{f("By Severity"),u("By severity"),V("rules"),H(void 0),C(void 0),ee(void 0),k(void 0),p(void 0),g(void 0),b(void 0),D(void 0),B([]),K([]),ue(!1)};return n.jsxs("div",{className:"w-full",children:[n.jsxs("div",{className:"mb-6",children:[n.jsx(Qt,{level:4,className:"!mb-2",children:"Admin Settings"}),n.jsxs(c.Spin,{spinning:L,children:[$?n.jsxs("div",{className:"text-sm text-red-600 mb-2",children:["Failed to load settings: ",$]}):null,n.jsx(Vr,{sortBy:l,groupBy:d,onChange:E=>{E.sortBy&&(f(E.sortBy),w(!0)),E.groupBy&&(u(E.groupBy),w(!0))},showActions:I,onSave:xs,onClear:bs,saving:y})]})]}),n.jsx(c.Divider,{className:"my-6"}),n.jsxs("div",{children:[n.jsx(Qt,{level:4,className:"!mb-4",children:"Escalation Settings"}),n.jsx(Jr,{escBasis:Y,setEscBasis:V,selectedSeverity:W,setSelectedSeverity:H,selectedRule:T,setSelectedRule:C,severityOptions:ms,ruleOptions:ps,minsOptions:gs,roleOptions:ys,l1mins:R,setL1mins:ee,l1role:X,setL1role:k,l2mins:v,setL2mins:p,l2role:A,setL2role:g,l3mins:x,setL3mins:b,l3role:O,setL3role:D,actions:P,setActions:B,thirdPartyIds:q,setThirdPartyIds:K,humanLoop:ne,setHumanLoop:ue,onClear:As,onSave:Ss,saving:Ge,onActionTypesLoaded:E=>{const Z={};for(const Q of E)typeof Q.actionTypeId=="number"&&(Z[Q.actionTypeId]=Q.name);se(Z)}})]}),n.jsx(c.Divider,{className:"my-6"}),n.jsx(Xr,{entries:Se,userRoles:z,loading:We,onEdit:E=>{V("rules");const Z=Se.find(M=>M.id===E),Q=t.find(M=>M.RuleId===E)||(Z?t.find(M=>M.Name===Z.ruleOrSeverityLabel):void 0);C(Q?Q.RuleId:E)}}),n.jsx(c.Divider,{className:"my-6"}),n.jsx(ls,{userRoles:z,rules:t,rawRules:r}),n.jsx(c.Divider,{})]})}const{Title:_t,Text:$e}=c.Typography;function us({severities:e,rules:t,onSave:s,onCancel:r}){const{rules:i,alerts:a}=he(),o=[{label:"By Severity",value:"By Severity"},{label:"By Created Date",value:"By Created Date"}],[l,f]=h.useState("By Severity"),[d,u]=h.useState(new Set),[N,m]=h.useState(null),[I,w]=h.useState(null),[y,S]=h.useState({inApp:!1,sms:!1,email:!1}),[L,U]=h.useState([]),[$,F]=h.useState(!0),[Y,V]=h.useState(!1);h.useEffect(()=>{let T=!1;return(async()=>{try{const C=await a.getPreferenceSettings();if(T||!C)return;S({inApp:!!C.inApp,sms:!!C.sms,email:!!C.email});const R=Wt(C.sortBy);f(R==="By Created Date"?"By Created Date":"By Severity"),m(Tt(C.doNotDisturbStart)),w(Tt(C.doNotDisturbEnd)),Array.isArray(C.anomalyIds)&&u(new Set(C.anomalyIds.map(ee=>String(ee))))}catch(C){console.error("Error in loading my preferences: ",C)}})(),()=>{T=!0}},[]),h.useEffect(()=>{let T=!1;return(async()=>{try{F(!0);const C=await i.getLookups();if(T||!C)return;const R=Array.isArray(C.anomalies)?C.anomalies:[];U(R)}catch(C){console.error("Failed to load anomalies lookups",C)}finally{T||F(!1)}})(),()=>{T=!0}},[]);const W=T=>{u(C=>{const R=new Set(C);return R.has(T)?R.delete(T):R.add(T),R})},H=async()=>{s?.({sortBy:l,subscribedRuleIds:Array.from(d),dnd:{from:N,to:I},channels:y});try{V(!0);const T=N?N.format?.("HH:mm:ss")??"00:00:00":"00:00:00",C=I?I.format?.("HH:mm:ss")??"00:00:00":"00:00:00",R=Array.from(d).map(X=>Number(X)).filter(X=>Number.isFinite(X)),ee=await a.setPreferenceSettings({anomalyIds:R,doNotDisturbStart:T,doNotDisturbEnd:C,inApp:!!y.inApp,sms:!!y.sms,email:!!y.email,sortBy:l});ee?.responseStatus&&re.toast.success(ee?.data||"Preferences updated successfully.")}catch(T){console.error("Error in saving my preferences: ",T)}finally{V(!1)}};return n.jsxs("div",{className:"w-full",children:[n.jsx(c.Row,{gutter:[16,16],align:"middle",className:"mb-4",children:n.jsx(c.Col,{xs:24,md:8,children:n.jsxs(c.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[n.jsx($e,{className:"text-gray-600",children:"Sort By:"}),n.jsx(c.Select,{className:"w-[240px]",value:l,options:o,onChange:f})]})})}),n.jsxs("div",{className:"mb-4",children:[n.jsx(_t,{level:5,className:"!mb-2",children:"Anomalies"}),$?n.jsx("div",{className:"py-4",children:n.jsx(c.Spin,{})}):n.jsx(c.Space,{direction:"vertical",size:10,className:"w-full",children:(Array.isArray(L)?L:[]).map(T=>{const C=String(T.recordId),R=T.anomalyName;return n.jsx(c.Checkbox,{checked:d.has(C),onChange:()=>W(C),children:R},C)})})]}),n.jsxs("div",{className:"mb-4",children:[n.jsx(_t,{level:5,className:"!mb-2",children:"Notification Timing & Channels"}),n.jsx(c.Row,{gutter:[16,16],align:"middle",className:"mb-3",children:n.jsx(c.Col,{xs:24,md:12,children:n.jsxs(c.Space,{direction:"horizontal",size:12,className:"w-full items-center",children:[n.jsx($e,{children:"Do Not Disturb mode:"}),n.jsxs(c.Space,{size:12,className:"w-full",children:[n.jsxs(c.Space,{direction:"horizontal",size:8,className:"items-center",children:[n.jsx($e,{children:"From"}),n.jsx(c.TimePicker,{value:N,onChange:T=>m(T),format:"HH:mm"})]}),n.jsxs(c.Space,{direction:"horizontal",size:8,className:"items-center",children:[n.jsx($e,{children:"To"}),n.jsx(c.TimePicker,{value:I,onChange:T=>w(T),format:"HH:mm"})]})]})]})})}),n.jsxs(c.Row,{gutter:[24,12],children:[n.jsx(c.Col,{children:n.jsx(c.Checkbox,{checked:y.inApp,onChange:T=>S({...y,inApp:T.target.checked}),children:"In-app"})}),n.jsx(c.Col,{children:n.jsx(c.Checkbox,{checked:y.sms,onChange:T=>S({...y,sms:T.target.checked}),children:"SMS"})}),n.jsx(c.Col,{children:n.jsx(c.Checkbox,{checked:y.email,onChange:T=>S({...y,email:T.target.checked}),children:"Email"})})]})]}),n.jsx(c.Divider,{}),n.jsxs(c.Space,{className:"gap-3",children:[n.jsx(c.Button,{onClick:r,disabled:Y,children:"Cancel"}),n.jsx(c.Button,{type:"primary",onClick:H,loading:Y,children:"Save"})]})]})}function ds({severities:e,rules:t,userRoles:s,rawRules:r}){const[i,a]=h.useState("global");return n.jsxs("div",{className:"w-full",children:[n.jsxs("div",{className:"inline-flex rounded-xl overflow-hidden border border-gray-200 mb-4",children:[n.jsx("button",{onClick:()=>a("global"),className:`px-5 py-2 text-base font-medium outline-none ${i==="global"?" bg-black text-white":" bg-white text-black"}`,style:{border:"0"},children:"Global Settings"}),n.jsx("button",{onClick:()=>a("prefs"),className:`px-5 py-2 text-base font-medium outline-none ${i==="prefs"?"bg-black text-white":"bg-white"}`,children:"My Preferences"})]}),i==="global"?n.jsx(cs,{severities:e,rules:t,userRoles:s,rawRules:r}):n.jsx(us,{severities:e,rules:t})]})}const en="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=",tn="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 sn(e){const t=(e.status||"").toLowerCase()==="completed"?n.jsx("img",{src:en,alt:"completed",style:{width:20,height:20}}):n.jsx("img",{src:tn,alt:"pending",style:{width:20,height:20}});return{title:n.jsxs("div",{className:"flex flex-col gap-0 min-w-0",children:[n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{className:"block text-sm break-words mb-1 overflow-visible whitespace-normal",children:n.jsx("b",{children:e.title})}),e.description?n.jsx("span",{className:"text-gray-500 text-xs",children:e.description}):null]}),e.timestamp?n.jsx("span",{className:"text-gray-500 text-xs",children:e.timestamp}):null]}),icon:t,description:null}}function rn({data:e}){return n.jsx("div",{className:"w-full",children:n.jsx(c.Tabs,{type:"card",items:[{key:"action",label:"Action Taken",children:n.jsxs("div",{className:"w-full",children:[n.jsx(c.Card,{className:"mb-4 rounded-md p-4",bordered:!0,children:n.jsxs("div",{className:"grid grid-cols-4 gap-6 text-xs",children:[n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-gray-500",children:"Alert ID"}),n.jsx("span",{className:"text-black",children:e.summary.alertNumber})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-gray-500",children:"Incident ID"}),n.jsx("span",{className:"text-black",children:e.summary.incidentId})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-gray-500",children:"Severity"}),n.jsx("span",{className:"text-black",children:e.summary.severity})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-gray-500",children:"Location"}),n.jsx("span",{className:"text-black",children:e.summary.location})]})]})}),n.jsxs(c.Card,{className:"rounded-md p-4",bordered:!0,children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("h4",{className:"text-sm text-black font-medium",children:"Response Timeline/ Audit trail/log"})}),n.jsx("div",{className:"mt-2",children:n.jsx(c.Steps,{direction:"vertical",size:"small",current:1,items:(e.timeline||[]).map(sn)})})]})]})},{key:"notification",label:"Notification Sent",children:n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(e.notifications||[]).map((t,s)=>n.jsxs(c.Card,{className:"rounded-md p-4",bordered:!0,children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex flex-col",children:[n.jsx("h4",{className:"text-sm text-black font-medium",children:t.channelLabel}),n.jsx("span",{className:"text-xs text-gray-500 mt-1",children:Gt(t.sentAt)?.format("MM/DD/YYYY HH:mm:ss")})]}),n.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-green-50 text-green-700 border border-green-200",children:[t.delivered,"/",t.total," Delivered"]})]}),n.jsxs("div",{className:"mt-4 text-xs",children:[n.jsxs("div",{className:"text-black",children:[" ",t.messageTitle]}),t.messageBody?n.jsx("div",{className:"text-gray-600",children:t.messageBody}):null]}),n.jsxs("div",{className:"mt-4",children:[n.jsxs("div",{className:"text-xs text-black font-medium",children:["Recipients (",t.total,")"]}),n.jsx("div",{className:"mt-2 flex flex-col gap-3 text-xs",children:(t.recipients||[]).map((r,i)=>{const a=String(r?.notificationReceipientType||"").toLowerCase()==="EscalationNotification".toLowerCase();return n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("span",{className:"text-black",children:[r.name," - ",n.jsx("span",{style:{color:a?"#FF3B30":"#FFB86A"},children:a?"Escalation Notification":"Alert Notification"})]}),n.jsxs("span",{className:"text-gray-500",children:[r.role," . ",r.phone]})]}),n.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)})})]})]},s)),e?.notifications?.length?null:n.jsx("span",{className:"text-gray-500 text-xs",children:"No notifications."})]})}]})})}const nn=({alertId:e,id:t,priority:s,spaceName:r,alertNumber:i,statusHistory:a,notifGroups:o})=>{const l={alertId:e??String(t??""),incidentId:"-",severity:s||"",location:r||"",alertNumber:i??""},f=a?.length?a.map(u=>{const N=(u?.status||u?.eventStatus||"").toLowerCase()==="completed"?"Completed":"Inprogress",m=u?.createdDate?nt(u.createdDate):u?.timestamp?nt(u.timestamp):"";return{status:N,title:u?.status||u?.eventStatus||"Status Update",description:u?.description||u?.actionNotes||"",timestamp:m}}):[],d={summary:l,timeline:f,notifications:o??[]};return n.jsx(rn,{data:d})};function an(e){if(!e||typeof e!="string")return!1;const t=e.split("?")[0].toLowerCase();return t.endsWith(".mp4")||t.endsWith(".webm")||t.endsWith(".ogg")||t.endsWith(".m3u8")}function on(e){const t=(e?.mediaType||e?.type||"").toString().toLowerCase();return t==="video"||t==="mp4"?!0:an(e?.mediaUrl||e)}function Ve(e){const t=e;return t?Array.isArray(t)?t:[t]:[]}const ln={Critical:"#FF3B30",High:"#FFB86A",Medium:"#FFCC00",Low:"#007AFF"},cn={Critical:"#FFE2E2",High:"#FF95004D",Medium:"#FEF9C2",Low:"#E0EDFF"},un=({isModalOpen:e,handleModalClose:t,selectedRow:s,fetchAlertLogs:r,alertStatusList:i=[],alertStatusLoading:a=!1,initialTab:o="details"})=>{const[l,f]=h.useState(),[d,u]=h.useState(""),[N,m]=h.useState(!1),I=h.useRef(null),[w,y]=h.useState("details"),[S,L]=h.useState(void 0),[U,$]=h.useState(!1),F=mt(),{alerts:Y,config:V}=he(),W=V?.tenant==="schools",H=s?.originalData||{},{eventName:T,alertId:C,timestamp:R,description:ee,spaceName:X,assignTeam:k,priority:v,statusType:p,id:A,alertDetails:g,statusHistory:x,mediaDetails:b,alertNumber:O}=H,D=!W&&typeof H?.anomalyName=="string"&&String(H?.anomalyName||"").toLowerCase().includes("elopement"),P=j=>{const _=String(j||"").toLowerCase();return _==="delivered"?"Delivered":_==="failed"?"Failed":"Queued"},B=j=>({name:j?.receipientName||j?.recipientName||"-",role:j?.receipientRoleName||"",phone:j?.receipentPhoneNumber||j?.recipientPhoneNumber||j?.receipientEmail||j?.recipientEmail||"",status:P(j?.messageStatus),notificationReceipientType:j?.notificationReceipientType||""}),q=(j,_)=>{const z=_.map(B),be=z.filter(Ae=>Ae.status==="Delivered").length,Se=_.map(Ae=>Ae?.sentAt).filter(Boolean).sort((Ae,We)=>new Date(We).getTime()-new Date(Ae).getTime())[0],ke=_[0]||{},Ge=[ke?.severityName,ke?.anomalyName].filter(Boolean).join(" - ")||`${j} Notification`;return{channelLabel:`${j} Notification`,sentAt:Se||"",messageTitle:Ge,messageBody:"",total:z.length,delivered:be,recipients:z}},K=j=>{const _=new Map;return(j||[]).forEach(z=>{const be=String(z?.notificationType||"Unknown"),Se=_.get(be)||[];Se.push(z),_.set(be,Se)}),Array.from(_.entries()).map(([z,be])=>q(z,be))},ne=async j=>{try{const _=await Y.getAlertNotifications(j),z=K(_);L(z)}catch{L(void 0)}};h.useEffect(()=>{if(w!=="track"||!A)return;let j=!1;return ne(A).then(()=>{j&&L(void 0)}),()=>{j=!0}},[w,A]),h.useEffect(()=>{e&&y(o)},[e,o]);const ue=(i||[]).map(j=>({value:j.value,label:j.statusName})),oe=async()=>{try{m(!0);const j={alertUniqueId:C,alertId:A,status:l?String(l):void 0,notes:d.trim(),modifiedBy:0},_=await F.mutateAsync(j);if(_?.responseStatus){const z=_?.data||"Alert updated successfully.";re.toast.success(z,{autoClose:1500,onClose:()=>{r(),t()}}),f(void 0),u("")}else{const z=_?.errorMessage||"Failed to update alert status";re.toast.error(z)}}catch(j){console.error("Error updating alert status:",j),re.toast.error("Failed to update alert status. Please try again.")}finally{m(!1)}},se=async()=>{try{if(!A){re.toast.error("Alert ID is missing.");return}$(!0);const j=A;if(!Y.notifyFamilyMembers){re.toast.error("Notify Family is not supported.");return}const _=await Y.notifyFamilyMembers(j);if(_?.responseStatus){const z=_?.data||"Alert Notifications sent to Family Members.";re.toast.success(z)}else{const z=_?.errorMessage||"Failed to send notifications.";re.toast.error(z)}}catch(j){console.error("Error notifying family members:",j),re.toast.error("Failed to send notifications. Please try again.")}finally{$(!1)}};return n.jsx(c.Modal,{open:e,onCancel:t,width:1e3,styles:{body:{maxHeight:"70vh",overflowY:"auto"}},footer:w==="details"?n.jsxs("div",{className:"flex flex-row gap-2 justify-start",children:[n.jsx(c.Button,{onClick:t,className:"bg-[#6C757D] text-white",children:"Cancel"}),n.jsx(c.Button,{type:"primary",onClick:oe,loading:N,children:N?"Saving...":"Save Changes"})]}):null,children:s&&n.jsx(c.Tabs,{activeKey:w,onChange:j=>y(j),items:[{key:"details",label:"Alert Detail",children:n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("div",{className:"text-sm font-bold",children:T||"Alert Event"}),g?.firstName?n.jsxs("div",{className:"text-sm text-gray-500",children:["Resident ID/Name: ",g?.firstName," ",g?.lastName||"","   ",g?.residentId||""]}):null,n.jsxs("div",{className:"text-sm text-gray-500",children:["Timestamp: ",nt(R)]}),n.jsxs("div",{className:"font-sm text-gray-500",children:[n.jsx("b",{className:"text-black text-sm/6",children:"Description:"})," ",ee||"No description available"]}),X&&n.jsxs("div",{className:"font-sm text-gray-500",children:["Space: ",X]}),k&&n.jsxs("div",{className:"font-sm text-gray-500",children:["Assigned to: ",k]}),n.jsxs("div",{className:"flex gap-2 justify-start mt-3",children:[n.jsxs(c.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:{border:`2px solid ${ln[String(v)]||"#DFE4EA"}`,backgroundColor:cn[String(v)]},children:["Severity: ",v||"N/A"]}),n.jsxs(c.Tag,{className:"font-sm text-gray-500 rounded-[8px] py-2 px-3",style:String(p||"").toLowerCase()==="completed"?{background:"#E7F6EC",border:"0.68px solid var(--Green, #34C759)"}:{background:"#E0EDFF",border:"1px solid var(--Grays-Gray-4, #D1D1D6)"},children:["Status: ",p||"N/A"]})]}),n.jsx("div",{className:"w-full flex flex-col justify-start items-start mt-2 font-bold",children:n.jsxs("div",{className:"w-full mt-4",children:[n.jsx("div",{className:"flex flex-col gap-2",children:n.jsx(c.Select,{placeholder:"Change Status",className:"w-full text-gray-500",onChange:j=>f(j),value:l,options:ue,loading:a})}),n.jsxs("div",{className:"flex flex-col gap-2 mt-3",children:[n.jsx("label",{htmlFor:"action-details-input",className:"text-xs text-gray-500 font-medium",children:"Action Taken (Comments)"}),n.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:j=>u(j.target.value)})]}),D&&n.jsxs("div",{className:"border border-[#DFE4EA] rounded-md px-4 py-2 flex flex-row justify-between items-center mt-4 mb-8",children:[n.jsx("label",{htmlFor:"notify-family-button",className:"text-xs font-medium",children:"Alert notification will be sent to all Family Members."}),n.jsx(c.Button,{loading:U,onClick:se,disabled:U,className:"bg-black text-white rounded-md px-4 py-2 text-xs disabled:opacity-60 disabled:cursor-not-allowed",children:"Notify Family"})]})]})})]}),n.jsx("div",{className:"flex flex-col gap-4",children:n.jsxs("div",{className:"w-full mt-1",children:[n.jsxs("div",{className:"w-full flex items-center justify-between",children:[n.jsx("h3",{className:"text-black font-bold text-sm",children:"Camera Footage"}),Ve(b).length?n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:()=>I.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:n.jsx(Ee.LeftOutlined,{style:{fontSize:12}})}),n.jsx("button",{type:"button",onClick:()=>I.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:n.jsx(Ee.RightOutlined,{style:{fontSize:12}})})]}):null]}),Ve(b).length?n.jsx("div",{className:"w-full",children:n.jsx(c.Carousel,{ref:I,dots:!0,className:"w-full",children:Ve(b).map((j,_)=>n.jsxs("div",{className:"flex justify-center items-center",children:[on(j)?n.jsxs("video",{width:"240",height:"200",controls:!0,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg",children:[n.jsx("source",{src:j.mediaUrl||j}),"Your browser does not support the video tag."]}):n.jsx("img",{src:j.mediaUrl||j,alt:j.caption||`media-${_}`,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-lg"}),j.caption&&n.jsx("p",{className:"text-xs text-gray-500 mt-1",children:j.caption})]},_))})}):null]})})]})},{key:"track",label:"Track Incident",children:n.jsx(nn,{alertId:C,id:A,priority:v,spaceName:X,alertNumber:O,statusHistory:x,notifGroups:S})}]})})};function hs(){const{alerts:e}=he(),t=ft({queryKey:["alerts","statusList"],queryFn:()=>e.getAlertStatusList(),staleTime:5*6e4});return{list:t.data??[],loading:t.isLoading,error:t.error,refetch:t.refetch}}function pt({alerts:e,loading:t=!1,columns:s,onRefetch:r}){const[i,a]=h.useState(!1),[o,l]=h.useState(null),[f,d]=h.useState("details"),{list:u,loading:N}=hs();function m(y,S){l(y),d(S?.tab??"details"),a(!0)}function I(){a(!1)}const w=o?{originalData:{...o,alertId:o.alertId??o.id,mediaDetails:o.mediaDetails}}:null;return n.jsxs("div",{className:"p-6 flex flex-col items-start justify-start min-h-screen w-full overflow-auto",children:[n.jsxs("div",{className:"w-1/2 flex items-center justify-between mb-4",children:[n.jsx("h1",{className:"text-xl font-bold text-black",children:"Alert Console"}),n.jsx(os,{label:"USA",timeZone:"America/New_York"})]}),n.jsx(c.Tabs,{defaultActiveKey:"active",className:"w-full",tabBarStyle:{fontSize:"medium"},onChange:y=>{y==="active"&&r?.()},items:[{key:"active",label:"Active",children:n.jsx(ot,{data:e,loading:t,pageSize:10,columns:s||[],onAlertIdClick:m,onRefetch:r})},{key:"archived",label:"Archived",children:n.jsx(as,{alerts:e,loading:t,columns:s||[],onAlertIdClick:m})},{key:"settings",label:"Settings",children:n.jsx(dn,{})}]}),n.jsx(un,{isModalOpen:i,handleModalClose:I,selectedRow:w,fetchAlertLogs:()=>{},alertStatusList:u,alertStatusLoading:N,initialTab:f})]})}function dn(){const[e,t]=h.useState([]),[s,r]=h.useState([]),[i,a]=h.useState([]),{rules:o}=he();return h.useEffect(()=>{let l=!0;return(async()=>{try{const f=await o.getRules();if(!l)return;a(Array.isArray(f)?f:[]);const d=(f||[]).map((u,N)=>({RuleId:u.ruleId||u.ruleName||String(N),Name:u.ruleName||u.Name||"-",Description:u.ruleDesc||u.Description||"",SeverityId:0}));t(d.length?d:Oe.rules);try{const u=await o.getLookups(),N=Array.isArray(u?.userRoles)?u.userRoles.map(m=>({userRoleId:m.userRoleId??m.id,userRoleName:m.userRoleName??m.name})):[];r(N.length?N:Oe.userRoles)}catch{r(Oe.userRoles)}}catch{t(Oe.rules),r(Oe.userRoles)}})(),()=>{l=!1}},[]),n.jsx(ds,{severities:Oe.severities,rules:e,userRoles:s,rawRules:i})}function fs(){const{alerts:e}=he(),t=ft({queryKey:["alerts","list"],queryFn:()=>e.listAlerts(),staleTime:3e4});return{alerts:t.data??[],loading:t.isLoading,error:t.error,refetch:t.refetch}}function hn(e){const{alerts:t,loading:s,refetch:r}=fs();return n.jsx(pt,{alerts:t,loading:s,columns:e.columns,onRefetch:r})}function fn({tenant:e,apiDomain:t,rulesDomain:s,headers:r,alerts:i,loading:a,columns:o}){const[l]=h.useState(()=>new Cr),f=h.useMemo(()=>({alertsBaseUrl:t,rulesBaseUrl:s||t,headers:r||void 0}),[t,s,r]);return n.jsx(Tr,{client:l,children:n.jsx(zt,{tenant:e,override:f,children:Array.isArray(i)?n.jsx(pt,{alerts:i,loading:!!a,columns:o}):n.jsx(hn,{columns:o})})})}function mn(e){const{alerts:t}=he(),s=ft({queryKey:["alerts","report",e],queryFn:()=>t.getAlertsReport(e),staleTime:6e4});return{data:s.data??[],loading:s.isLoading,error:s.error,refetch:s.refetch}}const pn=[{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=ls;exports.AlertConsole=pt;exports.AlertConsoleWidget=fn;exports.AlertsTable=ot;exports.ApiProvider=zt;exports.ArchivedTable=as;exports.Clock=os;exports.DataTable=Vt;exports.MyPreferencesPanel=us;exports.SettingsPanel=cs;exports.SettingsTabs=ds;exports.exampleAlertColumns=pn;exports.useAlertStatusList=hs;exports.useAlerts=fs;exports.useAlertsReport=mn;exports.useApi=he;exports.useUpdateAlertStatus=mt;
2
2
  //# sourceMappingURL=index.cjs.map