import{t as e}from"./api-DqXJkjY6.js";import{a as t,c as n,l as r,o as i}from"./en-US-xOAJevKG.js";function a(e,n){let r=()=>i(n?.in,NaN),a=n?.additionalDigits??2,o=u(e),s;if(o.date){let e=d(o.date,a);s=f(e.restDateString,e.year)}if(!s||isNaN(+s))return r();let c=+s,l=0,p;if(o.time&&(l=m(o.time),isNaN(l)))return r();if(o.timezone){if(p=g(o.timezone),isNaN(p))return r()}else{let e=new Date(c+l),r=t(0,n?.in);return r.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),r.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),r}return t(c+l+p,n?.in)}var o={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},s=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,c=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,l=/^([+-])(\d{2})(?::?(\d{2}))?$/;function u(e){let t={},n=e.split(o.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],o.timeZoneDelimiter.test(t.date)&&(t.date=e.split(o.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=o.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function d(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function f(e,t){if(t===null)return new Date(NaN);let n=e.match(s);if(!n)return new Date(NaN);let r=!!n[4],i=p(n[1]),a=p(n[2])-1,o=p(n[3]),c=p(n[4]),l=p(n[5])-1;if(r)return S(t,c,l)?_(t,c,l):new Date(NaN);{let e=new Date(0);return!b(t,a,o)||!x(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function p(e){return e?parseInt(e):1}function m(e){let t=e.match(c);if(!t)return NaN;let i=h(t[1]),a=h(t[2]),o=h(t[3]);return C(i,a,o)?i*n+a*r+o*1e3:NaN}function h(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function g(e){if(e===`Z`)return 0;let t=e.match(l);if(!t)return 0;let i=t[1]===`+`?-1:1,a=parseInt(t[2]),o=t[3]&&parseInt(t[3])||0;return w(a,o)?i*(a*n+o*r):NaN}function _(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var v=[31,null,31,30,31,30,31,31,30,31,30,31];function y(e){return e%400==0||e%4==0&&e%100!=0}function b(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(v[t]||(y(e)?29:28))}function x(e,t){return t>=1&&t<=(y(e)?366:365)}function S(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function C(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function w(e,t){return t>=0&&t<=59}var{useListAuditEventsQuery:T,useGetAuditEventQuery:E,useGetAuditStatsQuery:D,usePurgeAuditEventsMutation:O}=e.injectEndpoints({endpoints:e=>({listAuditEvents:e.query({query:e=>({url:`/audit/events/`,params:e||void 0}),providesTags:[{type:`AuditLog`,id:`LIST`}]}),getAuditEvent:e.query({query:e=>`/audit/events/${e}/`,providesTags:(e,t,n)=>[{type:`AuditLog`,id:n}]}),getAuditStats:e.query({query:()=>`/audit/events/stats/`,providesTags:[{type:`AuditLog`,id:`STATS`}]}),purgeAuditEvents:e.mutation({query:e=>({url:`/audit/events/purge/`,method:`POST`,body:e}),invalidatesTags:[{type:`AuditLog`,id:`LIST`},{type:`AuditLog`,id:`STATS`}]})})}),k=`https://api.wheelsmart-lms.staging.absol.in/api/v1`;async function A(e){let t=localStorage.getItem(`access_token`),n={},r=new Set([`page`,`page_size`]);for(let[t,i]of Object.entries(e))r.has(t)||i!=null&&i!==``&&(n[t]=String(i));let i=new URLSearchParams(n).toString(),a=`${k}/audit/events/export/${i?`?${i}`:``}`,o=await fetch(a,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}});if(!o.ok)throw Error(`Export failed: ${o.status} ${o.statusText}`);let s=await o.blob(),c=URL.createObjectURL(s),l=(o.headers.get(`Content-Disposition`)||``).match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/),u=l?l[1].replace(/['"]/g,``):`audit_log_${new Date().toISOString().slice(0,10)}.csv`,d=document.createElement(`a`);d.href=c,d.download=u,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(c)}export{O as a,T as i,E as n,a as o,D as r,A as t};