diff --git a/README_UNRAID_INSTALL.md b/README_UNRAID_INSTALL.md index ee18340..d81be9a 100755 --- a/README_UNRAID_INSTALL.md +++ b/README_UNRAID_INSTALL.md @@ -152,6 +152,31 @@ Click **Add another Path, Port, Variable, Label or Device** for each: | Key | `DB_PATH` | | Value | `/data/cpas.db` | +**Variable 3 — Admin Username** + +| Setting | Value | +|---|---| +| Config Type | `Variable` | +| Name | `Admin Username` | +| Key | `ADMIN_USERNAME` | +| Value | `admin` | + +**Variable 4 — Admin Password** + +| Setting | Value | +|---|---| +| Config Type | `Variable` | +| Name | `Admin Password` | +| Key | `ADMIN_PASSWORD` | +| Value | *(set a strong password — do not leave the default)* | + +> **Important:** The app requires login. The admin account is created from +> `ADMIN_USERNAME` / `ADMIN_PASSWORD` on every start. **Always set a strong +> `ADMIN_PASSWORD`** — the image ships with a placeholder (`changeme`) that must +> be overridden. To rotate the admin password later, change this value and +> **Restart** the container. Additional user accounts are created in-app by an +> admin (top-right **Users** button) and are not affected by restarts. + --- ### 5.6 Apply @@ -167,8 +192,10 @@ Click **Add another Path, Port, Variable, Label or Device** for each: 1. Docker tab → **cpas-tracker** should show a green icon 2. Click the container icon → **WebUI** Or open: `http://[YOUR-UNRAID-IP]:3001` -3. Confirm **● API connected** appears in the header -4. Health check: `http://[YOUR-UNRAID-IP]:3001/api/health` +3. A **login screen** appears. Sign in with the `ADMIN_USERNAME` / `ADMIN_PASSWORD` + you set in step 5.5. +4. Confirm **● API connected** appears in the header +5. Health check (no login required): `http://[YOUR-UNRAID-IP]:3001/api/health` → `{"status":"ok","timestamp":"..."}` --- @@ -197,6 +224,8 @@ docker save cpas-tracker | gzip > cpas-tracker.tar.gz | Problem | Fix | |---|---| | Container won't start | Docker tab → container icon → **Logs** | +| Can't log in / forgot admin password | Edit Container → set a new `ADMIN_PASSWORD` → **Restart**. The admin password re-syncs from this variable on every start. | +| "ADMIN_PASSWORD not set" in logs | Add the `ADMIN_PASSWORD` variable (step 5.5) and restart — without it the admin account is not created. | | Port 3001 conflict | Change Host Port to `3002` in Edit Container | | "API unreachable" in UI | Confirm green icon, check Logs, try Restart | | DB permission error | Terminal: `chmod 755 /mnt/user/appdata/cpas/db` | diff --git a/client/dist/assets/index-CkShUZiL.js b/client/dist/assets/index-C1XYfYmx.js similarity index 78% rename from client/dist/assets/index-CkShUZiL.js rename to client/dist/assets/index-C1XYfYmx.js index ac87f89..0fcc684 100644 --- a/client/dist/assets/index-CkShUZiL.js +++ b/client/dist/assets/index-C1XYfYmx.js @@ -1,4 +1,4 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function Af(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qu={exports:{}},si={},qu={exports:{}},q={};/** +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function Ap(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qu={exports:{}},si={},qu={exports:{}},q={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ur=Symbol.for("react.element"),Of=Symbol.for("react.portal"),Df=Symbol.for("react.fragment"),Lf=Symbol.for("react.strict_mode"),Ff=Symbol.for("react.profiler"),Bf=Symbol.for("react.provider"),If=Symbol.for("react.context"),Mf=Symbol.for("react.forward_ref"),Uf=Symbol.for("react.suspense"),$f=Symbol.for("react.memo"),Wf=Symbol.for("react.lazy"),ha=Symbol.iterator;function Hf(e){return e===null||typeof e!="object"?null:(e=ha&&e[ha]||e["@@iterator"],typeof e=="function"?e:null)}var Ku={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Yu=Object.assign,Xu={};function qn(e,t,n){this.props=e,this.context=t,this.refs=Xu,this.updater=n||Ku}qn.prototype.isReactComponent={};qn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};qn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Gu(){}Gu.prototype=qn.prototype;function fs(e,t,n){this.props=e,this.context=t,this.refs=Xu,this.updater=n||Ku}var ps=fs.prototype=new Gu;ps.constructor=fs;Yu(ps,qn.prototype);ps.isPureReactComponent=!0;var ma=Array.isArray,Ju=Object.prototype.hasOwnProperty,hs={current:null},Zu={key:!0,ref:!0,__self:!0,__source:!0};function ec(e,t,n){var r,o={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)Ju.call(t,r)&&!Zu.hasOwnProperty(r)&&(o[r]=t[r]);var a=arguments.length-2;if(a===1)o.children=n;else if(1>>1,le=z[K];if(0>>1;Ko(Fe,I))sto(Be,Fe)?(z[K]=Be,z[st]=I,K=st):(z[K]=Fe,z[Ce]=I,K=Ce);else if(sto(Be,I))z[K]=Be,z[st]=I,K=st;else break e}}return B}function o(z,B){var I=z.sortIndex-B.sortIndex;return I!==0?I:z.id-B.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,a=l.now();e.unstable_now=function(){return l.now()-a}}var u=[],c=[],p=1,m=null,y=3,S=!1,x=!1,v=!1,g=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(z){for(var B=n(c);B!==null;){if(B.callback===null)r(c);else if(B.startTime<=z)r(c),B.sortIndex=B.expirationTime,t(u,B);else break;B=n(c)}}function b(z){if(v=!1,h(z),!x)if(n(u)!==null)x=!0,P(C);else{var B=n(c);B!==null&&$(b,B.startTime-z)}}function C(z,B){x=!1,v&&(v=!1,f(_),_=-1),S=!0;var I=y;try{for(h(B),m=n(u);m!==null&&(!(m.expirationTime>B)||z&&!X());){var K=m.callback;if(typeof K=="function"){m.callback=null,y=m.priorityLevel;var le=K(m.expirationTime<=B);B=e.unstable_now(),typeof le=="function"?m.callback=le:m===n(u)&&r(u),h(B)}else r(u);m=n(u)}if(m!==null)var de=!0;else{var Ce=n(c);Ce!==null&&$(b,Ce.startTime-B),de=!1}return de}finally{m=null,y=I,S=!1}}var j=!1,T=null,_=-1,Q=5,U=-1;function X(){return!(e.unstable_now()-Uz||125K?(z.sortIndex=I,t(c,z),n(u)===null&&z===n(c)&&(v?(f(_),_=-1):v=!0,$(b,I-K))):(z.sortIndex=le,t(u,z),x||S||(x=!0,P(C))),z},e.unstable_shouldYield=X,e.unstable_wrapCallback=function(z){var B=y;return function(){var I=y;y=B;try{return z.apply(this,arguments)}finally{y=I}}}})(ic);oc.exports=ic;var np=oc.exports;/** + */(function(e){function t(N,I){var B=N.length;N.push(I);e:for(;0>>1,le=N[K];if(0>>1;Ko(Fe,B))sto(Ie,Fe)?(N[K]=Ie,N[st]=B,K=st):(N[K]=Fe,N[Ce]=B,K=Ce);else if(sto(Ie,B))N[K]=Ie,N[st]=B,K=st;else break e}}return I}function o(N,I){var B=N.sortIndex-I.sortIndex;return B!==0?B:N.id-I.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,a=l.now();e.unstable_now=function(){return l.now()-a}}var u=[],c=[],f=1,m=null,y=3,S=!1,x=!1,v=!1,g=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(N){for(var I=n(c);I!==null;){if(I.callback===null)r(c);else if(I.startTime<=N)r(c),I.sortIndex=I.expirationTime,t(u,I);else break;I=n(c)}}function b(N){if(v=!1,h(N),!x)if(n(u)!==null)x=!0,P(C);else{var I=n(c);I!==null&&$(b,I.startTime-N)}}function C(N,I){x=!1,v&&(v=!1,p(_),_=-1),S=!0;var B=y;try{for(h(I),m=n(u);m!==null&&(!(m.expirationTime>I)||N&&!X());){var K=m.callback;if(typeof K=="function"){m.callback=null,y=m.priorityLevel;var le=K(m.expirationTime<=I);I=e.unstable_now(),typeof le=="function"?m.callback=le:m===n(u)&&r(u),h(I)}else r(u);m=n(u)}if(m!==null)var de=!0;else{var Ce=n(c);Ce!==null&&$(b,Ce.startTime-I),de=!1}return de}finally{m=null,y=B,S=!1}}var j=!1,T=null,_=-1,Q=5,U=-1;function X(){return!(e.unstable_now()-UN||125K?(N.sortIndex=B,t(c,N),n(u)===null&&N===n(c)&&(v?(p(_),_=-1):v=!0,$(b,B-K))):(N.sortIndex=le,t(u,N),x||S||(x=!0,P(C))),N},e.unstable_shouldYield=X,e.unstable_wrapCallback=function(N){var I=y;return function(){var B=y;y=I;try{return N.apply(this,arguments)}finally{y=B}}}})(ic);oc.exports=ic;var tf=oc.exports;/** * @license React * react-dom.production.min.js * @@ -30,22 +30,22 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var rp=k,Xe=np;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),fl=Object.prototype.hasOwnProperty,op=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,ya={},xa={};function ip(e){return fl.call(xa,e)?!0:fl.call(ya,e)?!1:op.test(e)?xa[e]=!0:(ya[e]=!0,!1)}function lp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function sp(e,t,n,r){if(t===null||typeof t>"u"||lp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Le(e,t,n,r,o,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var je={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){je[e]=new Le(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];je[t]=new Le(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){je[e]=new Le(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){je[e]=new Le(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){je[e]=new Le(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){je[e]=new Le(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){je[e]=new Le(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){je[e]=new Le(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){je[e]=new Le(e,5,!1,e.toLowerCase(),null,!1,!1)});var gs=/[\-:]([a-z])/g;function ys(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(gs,ys);je[t]=new Le(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(gs,ys);je[t]=new Le(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(gs,ys);je[t]=new Le(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){je[e]=new Le(e,1,!1,e.toLowerCase(),null,!1,!1)});je.xlinkHref=new Le("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){je[e]=new Le(e,1,!1,e.toLowerCase(),null,!0,!0)});function xs(e,t,n,r){var o=je.hasOwnProperty(t)?je[t]:null;(o!==null?o.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),pl=Object.prototype.hasOwnProperty,rf=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,ya={},xa={};function of(e){return pl.call(xa,e)?!0:pl.call(ya,e)?!1:rf.test(e)?xa[e]=!0:(ya[e]=!0,!1)}function lf(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function sf(e,t,n,r){if(t===null||typeof t>"u"||lf(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Le(e,t,n,r,o,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var je={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){je[e]=new Le(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];je[t]=new Le(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){je[e]=new Le(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){je[e]=new Le(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){je[e]=new Le(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){je[e]=new Le(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){je[e]=new Le(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){je[e]=new Le(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){je[e]=new Le(e,5,!1,e.toLowerCase(),null,!1,!1)});var gs=/[\-:]([a-z])/g;function ys(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(gs,ys);je[t]=new Le(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(gs,ys);je[t]=new Le(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(gs,ys);je[t]=new Le(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){je[e]=new Le(e,1,!1,e.toLowerCase(),null,!1,!1)});je.xlinkHref=new Le("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){je[e]=new Le(e,1,!1,e.toLowerCase(),null,!0,!0)});function xs(e,t,n,r){var o=je.hasOwnProperty(t)?je[t]:null;(o!==null?o.type!==0:r||!(2a||o[l]!==i[a]){var u=` -`+o[l].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=l&&0<=a);break}}}finally{Ai=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?cr(e):""}function ap(e){switch(e.tag){case 5:return cr(e.type);case 16:return cr("Lazy");case 13:return cr("Suspense");case 19:return cr("SuspenseList");case 0:case 2:case 15:return e=Oi(e.type,!1),e;case 11:return e=Oi(e.type.render,!1),e;case 1:return e=Oi(e.type,!0),e;default:return""}}function gl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case bn:return"Fragment";case Sn:return"Portal";case pl:return"Profiler";case vs:return"StrictMode";case hl:return"Suspense";case ml:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ac:return(e.displayName||"Context")+".Consumer";case sc:return(e._context.displayName||"Context")+".Provider";case ws:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ss:return t=e.displayName||null,t!==null?t:gl(e.type)||"Memo";case Nt:t=e._payload,e=e._init;try{return gl(e(t))}catch{}}return null}function up(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return gl(t);case 8:return t===vs?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Qt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function cc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function cp(e){var t=cc(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function to(e){e._valueTracker||(e._valueTracker=cp(e))}function dc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=cc(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Lo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function yl(e,t){var n=t.checked;return ue({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function wa(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Qt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function fc(e,t){t=t.checked,t!=null&&xs(e,"checked",t,!1)}function xl(e,t){fc(e,t);var n=Qt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?vl(e,t.type,n):t.hasOwnProperty("defaultValue")&&vl(e,t.type,Qt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Sa(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function vl(e,t,n){(t!=="number"||Lo(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var dr=Array.isArray;function An(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=no.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Cr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var hr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},dp=["Webkit","ms","Moz","O"];Object.keys(hr).forEach(function(e){dp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),hr[t]=hr[e]})});function gc(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||hr.hasOwnProperty(e)&&hr[e]?(""+t).trim():t+"px"}function yc(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=gc(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var fp=ue({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function bl(e,t){if(t){if(fp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function kl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var jl=null;function bs(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Cl=null,On=null,Dn=null;function ja(e){if(e=Hr(e)){if(typeof Cl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=fi(t),Cl(e.stateNode,e.type,t))}}function xc(e){On?Dn?Dn.push(e):Dn=[e]:On=e}function vc(){if(On){var e=On,t=Dn;if(Dn=On=null,ja(e),t)for(e=0;e>>=0,e===0?32:31-(kp(e)/jp|0)|0}var ro=64,oo=4194304;function fr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Mo(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var a=l&~o;a!==0?r=fr(a):(i&=l,i!==0&&(r=fr(i)))}else l=n&~o,l!==0?r=fr(l):i!==0&&(r=fr(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,i=t&-t,o>=i||o===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function $r(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ft(t),e[t]=n}function Rp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=gr),Aa=" ",Oa=!1;function Ic(e,t){switch(e){case"keyup":return nh.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var kn=!1;function oh(e,t){switch(e){case"compositionend":return Mc(t);case"keypress":return t.which!==32?null:(Oa=!0,Aa);case"textInput":return e=t.data,e===Aa&&Oa?null:e;default:return null}}function ih(e,t){if(kn)return e==="compositionend"||!Ps&&Ic(e,t)?(e=Fc(),ko=_s=Lt=null,kn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ba(n)}}function Hc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Hc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Vc(){for(var e=window,t=Lo();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Lo(e.document)}return t}function zs(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function hh(e){var t=Vc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Hc(n.ownerDocument.documentElement,n)){if(r!==null&&zs(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,i=Math.min(r.start,o);r=r.end===void 0?i:Math.min(r.end,o),!e.extend&&i>r&&(o=r,r=i,i=o),o=Ia(n,i);var l=Ia(n,r);o&&l&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,jn=null,zl=null,xr=null,Nl=!1;function Ma(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Nl||jn==null||jn!==Lo(r)||(r=jn,"selectionStart"in r&&zs(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),xr&&zr(xr,r)||(xr=r,r=Wo(zl,"onSelect"),0_n||(e.current=Bl[_n],Bl[_n]=null,_n--)}function te(e,t){_n++,Bl[_n]=e.current,e.current=t}var qt={},ze=Xt(qt),We=Xt(!1),cn=qt;function Mn(e,t){var n=e.type.contextTypes;if(!n)return qt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},i;for(i in n)o[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function He(e){return e=e.childContextTypes,e!=null}function Vo(){oe(We),oe(ze)}function qa(e,t,n){if(ze.current!==qt)throw Error(E(168));te(ze,t),te(We,n)}function ed(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(E(108,up(e)||"Unknown",o));return ue({},n,r)}function Qo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||qt,cn=ze.current,te(ze,e),te(We,We.current),!0}function Ka(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=ed(e,t,cn),r.__reactInternalMemoizedMergedChildContext=e,oe(We),oe(ze),te(ze,e)):oe(We),te(We,n)}var bt=null,pi=!1,Ki=!1;function td(e){bt===null?bt=[e]:bt.push(e)}function Eh(e){pi=!0,td(e)}function Gt(){if(!Ki&&bt!==null){Ki=!0;var e=0,t=Z;try{var n=bt;for(Z=1;e>=l,o-=l,kt=1<<32-ft(t)+o|n<_?(Q=T,T=null):Q=T.sibling;var U=y(f,T,h[_],b);if(U===null){T===null&&(T=Q);break}e&&T&&U.alternate===null&&t(f,T),d=i(U,d,_),j===null?C=U:j.sibling=U,j=U,T=Q}if(_===h.length)return n(f,T),ie&&en(f,_),C;if(T===null){for(;__?(Q=T,T=null):Q=T.sibling;var X=y(f,T,U.value,b);if(X===null){T===null&&(T=Q);break}e&&T&&X.alternate===null&&t(f,T),d=i(X,d,_),j===null?C=X:j.sibling=X,j=X,T=Q}if(U.done)return n(f,T),ie&&en(f,_),C;if(T===null){for(;!U.done;_++,U=h.next())U=m(f,U.value,b),U!==null&&(d=i(U,d,_),j===null?C=U:j.sibling=U,j=U);return ie&&en(f,_),C}for(T=r(f,T);!U.done;_++,U=h.next())U=S(T,f,_,U.value,b),U!==null&&(e&&U.alternate!==null&&T.delete(U.key===null?_:U.key),d=i(U,d,_),j===null?C=U:j.sibling=U,j=U);return e&&T.forEach(function(H){return t(f,H)}),ie&&en(f,_),C}function g(f,d,h,b){if(typeof h=="object"&&h!==null&&h.type===bn&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case eo:e:{for(var C=h.key,j=d;j!==null;){if(j.key===C){if(C=h.type,C===bn){if(j.tag===7){n(f,j.sibling),d=o(j,h.props.children),d.return=f,f=d;break e}}else if(j.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Nt&&Ga(C)===j.type){n(f,j.sibling),d=o(j,h.props),d.ref=rr(f,j,h),d.return=f,f=d;break e}n(f,j);break}else t(f,j);j=j.sibling}h.type===bn?(d=an(h.props.children,f.mode,b,h.key),d.return=f,f=d):(b=zo(h.type,h.key,h.props,null,f.mode,b),b.ref=rr(f,d,h),b.return=f,f=b)}return l(f);case Sn:e:{for(j=h.key;d!==null;){if(d.key===j)if(d.tag===4&&d.stateNode.containerInfo===h.containerInfo&&d.stateNode.implementation===h.implementation){n(f,d.sibling),d=o(d,h.children||[]),d.return=f,f=d;break e}else{n(f,d);break}else t(f,d);d=d.sibling}d=nl(h,f.mode,b),d.return=f,f=d}return l(f);case Nt:return j=h._init,g(f,d,j(h._payload),b)}if(dr(h))return x(f,d,h,b);if(Jn(h))return v(f,d,h,b);fo(f,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,d!==null&&d.tag===6?(n(f,d.sibling),d=o(d,h),d.return=f,f=d):(n(f,d),d=tl(h,f.mode,b),d.return=f,f=d),l(f)):n(f,d)}return g}var $n=id(!0),ld=id(!1),Yo=Xt(null),Xo=null,Pn=null,Ds=null;function Ls(){Ds=Pn=Xo=null}function Fs(e){var t=Yo.current;oe(Yo),e._currentValue=t}function Ul(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Fn(e,t){Xo=e,Ds=Pn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&($e=!0),e.firstContext=null)}function it(e){var t=e._currentValue;if(Ds!==e)if(e={context:e,memoizedValue:t,next:null},Pn===null){if(Xo===null)throw Error(E(308));Pn=e,Xo.dependencies={lanes:0,firstContext:e}}else Pn=Pn.next=e;return t}var rn=null;function Bs(e){rn===null?rn=[e]:rn.push(e)}function sd(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,Bs(t)):(n.next=o.next,o.next=n),t.interleaved=n,Rt(e,r)}function Rt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var At=!1;function Is(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ad(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ct(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function $t(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Y&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,Rt(e,n)}return o=r.interleaved,o===null?(t.next=t,Bs(r)):(t.next=o.next,o.next=t),r.interleaved=t,Rt(e,n)}function Co(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,js(e,n)}}function Ja(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?o=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?o=i=t:i=i.next=t}else o=i=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Go(e,t,n,r){var o=e.updateQueue;At=!1;var i=o.firstBaseUpdate,l=o.lastBaseUpdate,a=o.shared.pending;if(a!==null){o.shared.pending=null;var u=a,c=u.next;u.next=null,l===null?i=c:l.next=c,l=u;var p=e.alternate;p!==null&&(p=p.updateQueue,a=p.lastBaseUpdate,a!==l&&(a===null?p.firstBaseUpdate=c:a.next=c,p.lastBaseUpdate=u))}if(i!==null){var m=o.baseState;l=0,p=c=u=null,a=i;do{var y=a.lane,S=a.eventTime;if((r&y)===y){p!==null&&(p=p.next={eventTime:S,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var x=e,v=a;switch(y=t,S=n,v.tag){case 1:if(x=v.payload,typeof x=="function"){m=x.call(S,m,y);break e}m=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=v.payload,y=typeof x=="function"?x.call(S,m,y):x,y==null)break e;m=ue({},m,y);break e;case 2:At=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,y=o.effects,y===null?o.effects=[a]:y.push(a))}else S={eventTime:S,lane:y,tag:a.tag,payload:a.payload,callback:a.callback,next:null},p===null?(c=p=S,u=m):p=p.next=S,l|=y;if(a=a.next,a===null){if(a=o.shared.pending,a===null)break;y=a,a=y.next,y.next=null,o.lastBaseUpdate=y,o.shared.pending=null}}while(!0);if(p===null&&(u=m),o.baseState=u,o.firstBaseUpdate=c,o.lastBaseUpdate=p,t=o.shared.interleaved,t!==null){o=t;do l|=o.lane,o=o.next;while(o!==t)}else i===null&&(o.shared.lanes=0);pn|=l,e.lanes=l,e.memoizedState=m}}function Za(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Xi.transition;Xi.transition={};try{e(!1),t()}finally{Z=n,Xi.transition=r}}function Cd(){return lt().memoizedState}function Ph(e,t,n){var r=Ht(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ed(e))_d(t,n);else if(n=sd(e,t,n,r),n!==null){var o=Ae();pt(n,e,r,o),Rd(n,t,r)}}function zh(e,t,n){var r=Ht(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ed(e))_d(t,o);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,a=i(l,n);if(o.hasEagerState=!0,o.eagerState=a,ht(a,l)){var u=t.interleaved;u===null?(o.next=o,Bs(t)):(o.next=u.next,u.next=o),t.interleaved=o;return}}catch{}finally{}n=sd(e,t,o,r),n!==null&&(o=Ae(),pt(n,e,r,o),Rd(n,t,r))}}function Ed(e){var t=e.alternate;return e===ae||t!==null&&t===ae}function _d(e,t){vr=Zo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Rd(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,js(e,n)}}var ei={readContext:it,useCallback:Ee,useContext:Ee,useEffect:Ee,useImperativeHandle:Ee,useInsertionEffect:Ee,useLayoutEffect:Ee,useMemo:Ee,useReducer:Ee,useRef:Ee,useState:Ee,useDebugValue:Ee,useDeferredValue:Ee,useTransition:Ee,useMutableSource:Ee,useSyncExternalStore:Ee,useId:Ee,unstable_isNewReconciler:!1},Nh={readContext:it,useCallback:function(e,t){return yt().memoizedState=[e,t===void 0?null:t],e},useContext:it,useEffect:tu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,_o(4194308,4,wd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return _o(4194308,4,e,t)},useInsertionEffect:function(e,t){return _o(4,2,e,t)},useMemo:function(e,t){var n=yt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=yt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Ph.bind(null,ae,e),[r.memoizedState,e]},useRef:function(e){var t=yt();return e={current:e},t.memoizedState=e},useState:eu,useDebugValue:qs,useDeferredValue:function(e){return yt().memoizedState=e},useTransition:function(){var e=eu(!1),t=e[0];return e=Th.bind(null,e[1]),yt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ae,o=yt();if(ie){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),we===null)throw Error(E(349));fn&30||fd(r,t,n)}o.memoizedState=n;var i={value:n,getSnapshot:t};return o.queue=i,tu(hd.bind(null,r,i,e),[e]),r.flags|=2048,Ir(9,pd.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=yt(),t=we.identifierPrefix;if(ie){var n=jt,r=kt;n=(r&~(1<<32-ft(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Fr++,0")&&(u=u.replace("",e.displayName)),u}while(1<=l&&0<=a);break}}}finally{zi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?cr(e):""}function af(e){switch(e.tag){case 5:return cr(e.type);case 16:return cr("Lazy");case 13:return cr("Suspense");case 19:return cr("SuspenseList");case 0:case 2:case 15:return e=Oi(e.type,!1),e;case 11:return e=Oi(e.type.render,!1),e;case 1:return e=Oi(e.type,!0),e;default:return""}}function gl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case bn:return"Fragment";case Sn:return"Portal";case fl:return"Profiler";case vs:return"StrictMode";case hl:return"Suspense";case ml:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ac:return(e.displayName||"Context")+".Consumer";case sc:return(e._context.displayName||"Context")+".Provider";case ws:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ss:return t=e.displayName||null,t!==null?t:gl(e.type)||"Memo";case At:t=e._payload,e=e._init;try{return gl(e(t))}catch{}}return null}function uf(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return gl(t);case 8:return t===vs?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Qt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function cc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function cf(e){var t=cc(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function to(e){e._valueTracker||(e._valueTracker=cf(e))}function dc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=cc(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Lo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function yl(e,t){var n=t.checked;return ue({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function wa(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Qt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function pc(e,t){t=t.checked,t!=null&&xs(e,"checked",t,!1)}function xl(e,t){pc(e,t);var n=Qt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?vl(e,t.type,n):t.hasOwnProperty("defaultValue")&&vl(e,t.type,Qt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Sa(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function vl(e,t,n){(t!=="number"||Lo(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var dr=Array.isArray;function zn(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=no.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Cr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var hr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},df=["Webkit","ms","Moz","O"];Object.keys(hr).forEach(function(e){df.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),hr[t]=hr[e]})});function gc(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||hr.hasOwnProperty(e)&&hr[e]?(""+t).trim():t+"px"}function yc(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=gc(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var pf=ue({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function bl(e,t){if(t){if(pf[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function kl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var jl=null;function bs(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Cl=null,On=null,Dn=null;function ja(e){if(e=Hr(e)){if(typeof Cl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=pi(t),Cl(e.stateNode,e.type,t))}}function xc(e){On?Dn?Dn.push(e):Dn=[e]:On=e}function vc(){if(On){var e=On,t=Dn;if(Dn=On=null,ja(e),t)for(e=0;e>>=0,e===0?32:31-(kf(e)/jf|0)|0}var ro=64,oo=4194304;function pr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Mo(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var a=l&~o;a!==0?r=pr(a):(i&=l,i!==0&&(r=pr(i)))}else l=n&~o,l!==0?r=pr(l):i!==0&&(r=pr(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,i=t&-t,o>=i||o===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function $r(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-pt(t),e[t]=n}function Rf(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=gr),za=" ",Oa=!1;function Bc(e,t){switch(e){case"keyup":return nh.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var kn=!1;function oh(e,t){switch(e){case"compositionend":return Mc(t);case"keypress":return t.which!==32?null:(Oa=!0,za);case"textInput":return e=t.data,e===za&&Oa?null:e;default:return null}}function ih(e,t){if(kn)return e==="compositionend"||!Ps&&Bc(e,t)?(e=Fc(),ko=_s=Lt=null,kn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ia(n)}}function Hc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Hc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Vc(){for(var e=window,t=Lo();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Lo(e.document)}return t}function Ns(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function hh(e){var t=Vc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Hc(n.ownerDocument.documentElement,n)){if(r!==null&&Ns(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,i=Math.min(r.start,o);r=r.end===void 0?i:Math.min(r.end,o),!e.extend&&i>r&&(o=r,r=i,i=o),o=Ba(n,i);var l=Ba(n,r);o&&l&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,jn=null,Nl=null,xr=null,Al=!1;function Ma(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Al||jn==null||jn!==Lo(r)||(r=jn,"selectionStart"in r&&Ns(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),xr&&Nr(xr,r)||(xr=r,r=Wo(Nl,"onSelect"),0_n||(e.current=Il[_n],Il[_n]=null,_n--)}function te(e,t){_n++,Il[_n]=e.current,e.current=t}var qt={},Ne=Xt(qt),We=Xt(!1),cn=qt;function Mn(e,t){var n=e.type.contextTypes;if(!n)return qt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},i;for(i in n)o[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function He(e){return e=e.childContextTypes,e!=null}function Vo(){oe(We),oe(Ne)}function qa(e,t,n){if(Ne.current!==qt)throw Error(E(168));te(Ne,t),te(We,n)}function ed(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(E(108,uf(e)||"Unknown",o));return ue({},n,r)}function Qo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||qt,cn=Ne.current,te(Ne,e),te(We,We.current),!0}function Ka(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=ed(e,t,cn),r.__reactInternalMemoizedMergedChildContext=e,oe(We),oe(Ne),te(Ne,e)):oe(We),te(We,n)}var bt=null,fi=!1,Ki=!1;function td(e){bt===null?bt=[e]:bt.push(e)}function Eh(e){fi=!0,td(e)}function Gt(){if(!Ki&&bt!==null){Ki=!0;var e=0,t=Z;try{var n=bt;for(Z=1;e>=l,o-=l,kt=1<<32-pt(t)+o|n<_?(Q=T,T=null):Q=T.sibling;var U=y(p,T,h[_],b);if(U===null){T===null&&(T=Q);break}e&&T&&U.alternate===null&&t(p,T),d=i(U,d,_),j===null?C=U:j.sibling=U,j=U,T=Q}if(_===h.length)return n(p,T),ie&&en(p,_),C;if(T===null){for(;__?(Q=T,T=null):Q=T.sibling;var X=y(p,T,U.value,b);if(X===null){T===null&&(T=Q);break}e&&T&&X.alternate===null&&t(p,T),d=i(X,d,_),j===null?C=X:j.sibling=X,j=X,T=Q}if(U.done)return n(p,T),ie&&en(p,_),C;if(T===null){for(;!U.done;_++,U=h.next())U=m(p,U.value,b),U!==null&&(d=i(U,d,_),j===null?C=U:j.sibling=U,j=U);return ie&&en(p,_),C}for(T=r(p,T);!U.done;_++,U=h.next())U=S(T,p,_,U.value,b),U!==null&&(e&&U.alternate!==null&&T.delete(U.key===null?_:U.key),d=i(U,d,_),j===null?C=U:j.sibling=U,j=U);return e&&T.forEach(function(H){return t(p,H)}),ie&&en(p,_),C}function g(p,d,h,b){if(typeof h=="object"&&h!==null&&h.type===bn&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case eo:e:{for(var C=h.key,j=d;j!==null;){if(j.key===C){if(C=h.type,C===bn){if(j.tag===7){n(p,j.sibling),d=o(j,h.props.children),d.return=p,p=d;break e}}else if(j.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===At&&Ga(C)===j.type){n(p,j.sibling),d=o(j,h.props),d.ref=rr(p,j,h),d.return=p,p=d;break e}n(p,j);break}else t(p,j);j=j.sibling}h.type===bn?(d=an(h.props.children,p.mode,b,h.key),d.return=p,p=d):(b=No(h.type,h.key,h.props,null,p.mode,b),b.ref=rr(p,d,h),b.return=p,p=b)}return l(p);case Sn:e:{for(j=h.key;d!==null;){if(d.key===j)if(d.tag===4&&d.stateNode.containerInfo===h.containerInfo&&d.stateNode.implementation===h.implementation){n(p,d.sibling),d=o(d,h.children||[]),d.return=p,p=d;break e}else{n(p,d);break}else t(p,d);d=d.sibling}d=nl(h,p.mode,b),d.return=p,p=d}return l(p);case At:return j=h._init,g(p,d,j(h._payload),b)}if(dr(h))return x(p,d,h,b);if(Jn(h))return v(p,d,h,b);po(p,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,d!==null&&d.tag===6?(n(p,d.sibling),d=o(d,h),d.return=p,p=d):(n(p,d),d=tl(h,p.mode,b),d.return=p,p=d),l(p)):n(p,d)}return g}var $n=id(!0),ld=id(!1),Yo=Xt(null),Xo=null,Pn=null,Ds=null;function Ls(){Ds=Pn=Xo=null}function Fs(e){var t=Yo.current;oe(Yo),e._currentValue=t}function Ul(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Fn(e,t){Xo=e,Ds=Pn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&($e=!0),e.firstContext=null)}function it(e){var t=e._currentValue;if(Ds!==e)if(e={context:e,memoizedValue:t,next:null},Pn===null){if(Xo===null)throw Error(E(308));Pn=e,Xo.dependencies={lanes:0,firstContext:e}}else Pn=Pn.next=e;return t}var rn=null;function Is(e){rn===null?rn=[e]:rn.push(e)}function sd(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,Is(t)):(n.next=o.next,o.next=n),t.interleaved=n,Rt(e,r)}function Rt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var zt=!1;function Bs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ad(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ct(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function $t(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Y&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,Rt(e,n)}return o=r.interleaved,o===null?(t.next=t,Is(r)):(t.next=o.next,o.next=t),r.interleaved=t,Rt(e,n)}function Co(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,js(e,n)}}function Ja(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?o=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?o=i=t:i=i.next=t}else o=i=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Go(e,t,n,r){var o=e.updateQueue;zt=!1;var i=o.firstBaseUpdate,l=o.lastBaseUpdate,a=o.shared.pending;if(a!==null){o.shared.pending=null;var u=a,c=u.next;u.next=null,l===null?i=c:l.next=c,l=u;var f=e.alternate;f!==null&&(f=f.updateQueue,a=f.lastBaseUpdate,a!==l&&(a===null?f.firstBaseUpdate=c:a.next=c,f.lastBaseUpdate=u))}if(i!==null){var m=o.baseState;l=0,f=c=u=null,a=i;do{var y=a.lane,S=a.eventTime;if((r&y)===y){f!==null&&(f=f.next={eventTime:S,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var x=e,v=a;switch(y=t,S=n,v.tag){case 1:if(x=v.payload,typeof x=="function"){m=x.call(S,m,y);break e}m=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=v.payload,y=typeof x=="function"?x.call(S,m,y):x,y==null)break e;m=ue({},m,y);break e;case 2:zt=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,y=o.effects,y===null?o.effects=[a]:y.push(a))}else S={eventTime:S,lane:y,tag:a.tag,payload:a.payload,callback:a.callback,next:null},f===null?(c=f=S,u=m):f=f.next=S,l|=y;if(a=a.next,a===null){if(a=o.shared.pending,a===null)break;y=a,a=y.next,y.next=null,o.lastBaseUpdate=y,o.shared.pending=null}}while(!0);if(f===null&&(u=m),o.baseState=u,o.firstBaseUpdate=c,o.lastBaseUpdate=f,t=o.shared.interleaved,t!==null){o=t;do l|=o.lane,o=o.next;while(o!==t)}else i===null&&(o.shared.lanes=0);fn|=l,e.lanes=l,e.memoizedState=m}}function Za(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Xi.transition;Xi.transition={};try{e(!1),t()}finally{Z=n,Xi.transition=r}}function Cd(){return lt().memoizedState}function Ph(e,t,n){var r=Ht(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ed(e))_d(t,n);else if(n=sd(e,t,n,r),n!==null){var o=ze();ft(n,e,r,o),Rd(n,t,r)}}function Nh(e,t,n){var r=Ht(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ed(e))_d(t,o);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,a=i(l,n);if(o.hasEagerState=!0,o.eagerState=a,ht(a,l)){var u=t.interleaved;u===null?(o.next=o,Is(t)):(o.next=u.next,u.next=o),t.interleaved=o;return}}catch{}finally{}n=sd(e,t,o,r),n!==null&&(o=ze(),ft(n,e,r,o),Rd(n,t,r))}}function Ed(e){var t=e.alternate;return e===ae||t!==null&&t===ae}function _d(e,t){vr=Zo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Rd(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,js(e,n)}}var ei={readContext:it,useCallback:Ee,useContext:Ee,useEffect:Ee,useImperativeHandle:Ee,useInsertionEffect:Ee,useLayoutEffect:Ee,useMemo:Ee,useReducer:Ee,useRef:Ee,useState:Ee,useDebugValue:Ee,useDeferredValue:Ee,useTransition:Ee,useMutableSource:Ee,useSyncExternalStore:Ee,useId:Ee,unstable_isNewReconciler:!1},Ah={readContext:it,useCallback:function(e,t){return yt().memoizedState=[e,t===void 0?null:t],e},useContext:it,useEffect:tu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,_o(4194308,4,wd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return _o(4194308,4,e,t)},useInsertionEffect:function(e,t){return _o(4,2,e,t)},useMemo:function(e,t){var n=yt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=yt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Ph.bind(null,ae,e),[r.memoizedState,e]},useRef:function(e){var t=yt();return e={current:e},t.memoizedState=e},useState:eu,useDebugValue:qs,useDeferredValue:function(e){return yt().memoizedState=e},useTransition:function(){var e=eu(!1),t=e[0];return e=Th.bind(null,e[1]),yt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ae,o=yt();if(ie){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),we===null)throw Error(E(349));pn&30||pd(r,t,n)}o.memoizedState=n;var i={value:n,getSnapshot:t};return o.queue=i,tu(hd.bind(null,r,i,e),[e]),r.flags|=2048,Br(9,fd.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=yt(),t=we.identifierPrefix;if(ie){var n=jt,r=kt;n=(r&~(1<<32-pt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Fr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[xt]=t,e[Or]=r,Bd(e,t,!1,!1),t.stateNode=e;e:{switch(l=kl(n,r),n){case"dialog":re("cancel",e),re("close",e),o=r;break;case"iframe":case"object":case"embed":re("load",e),o=r;break;case"video":case"audio":for(o=0;oVn&&(t.flags|=128,r=!0,or(i,!1),t.lanes=4194304)}else{if(!r)if(e=Jo(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),or(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!ie)return _e(t),null}else 2*he()-i.renderingStartTime>Vn&&n!==1073741824&&(t.flags|=128,r=!0,or(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=he(),t.sibling=null,n=se.current,te(se,r?n&1|2:n&1),t):(_e(t),null);case 22:case 23:return Zs(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?qe&1073741824&&(_e(t),t.subtreeFlags&6&&(t.flags|=8192)):_e(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function Mh(e,t){switch(As(t),t.tag){case 1:return He(t.type)&&Vo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wn(),oe(We),oe(ze),$s(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Us(t),null;case 13:if(oe(se),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Un()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return oe(se),null;case 4:return Wn(),null;case 10:return Fs(t.type._context),null;case 22:case 23:return Zs(),null;case 24:return null;default:return null}}var ho=!1,Te=!1,Uh=typeof WeakSet=="function"?WeakSet:Set,A=null;function zn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ce(e,t,r)}else n.current=null}function Xl(e,t,n){try{n()}catch(r){ce(e,t,r)}}var fu=!1;function $h(e,t){if(Al=Uo,e=Vc(),zs(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,a=-1,u=-1,c=0,p=0,m=e,y=null;t:for(;;){for(var S;m!==n||o!==0&&m.nodeType!==3||(a=l+o),m!==i||r!==0&&m.nodeType!==3||(u=l+r),m.nodeType===3&&(l+=m.nodeValue.length),(S=m.firstChild)!==null;)y=m,m=S;for(;;){if(m===e)break t;if(y===n&&++c===o&&(a=l),y===i&&++p===r&&(u=l),(S=m.nextSibling)!==null)break;m=y,y=m.parentNode}m=S}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ol={focusedElem:e,selectionRange:n},Uo=!1,A=t;A!==null;)if(t=A,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,A=e;else for(;A!==null;){t=A;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var v=x.memoizedProps,g=x.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?v:ut(t.type,v),g);f.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(b){ce(t,t.return,b)}if(e=t.sibling,e!==null){e.return=t.return,A=e;break}A=t.return}return x=fu,fu=!1,x}function wr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var i=o.destroy;o.destroy=void 0,i!==void 0&&Xl(t,n,i)}o=o.next}while(o!==r)}}function gi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Gl(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Ud(e){var t=e.alternate;t!==null&&(e.alternate=null,Ud(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[xt],delete t[Or],delete t[Fl],delete t[jh],delete t[Ch])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function $d(e){return e.tag===5||e.tag===3||e.tag===4}function pu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||$d(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Jl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ho));else if(r!==4&&(e=e.child,e!==null))for(Jl(e,t,n),e=e.sibling;e!==null;)Jl(e,t,n),e=e.sibling}function Zl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Zl(e,t,n),e=e.sibling;e!==null;)Zl(e,t,n),e=e.sibling}var be=null,ct=!1;function zt(e,t,n){for(n=n.child;n!==null;)Wd(e,t,n),n=n.sibling}function Wd(e,t,n){if(vt&&typeof vt.onCommitFiberUnmount=="function")try{vt.onCommitFiberUnmount(ai,n)}catch{}switch(n.tag){case 5:Te||zn(n,t);case 6:var r=be,o=ct;be=null,zt(e,t,n),be=r,ct=o,be!==null&&(ct?(e=be,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):be.removeChild(n.stateNode));break;case 18:be!==null&&(ct?(e=be,n=n.stateNode,e.nodeType===8?qi(e.parentNode,n):e.nodeType===1&&qi(e,n),Tr(e)):qi(be,n.stateNode));break;case 4:r=be,o=ct,be=n.stateNode.containerInfo,ct=!0,zt(e,t,n),be=r,ct=o;break;case 0:case 11:case 14:case 15:if(!Te&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var i=o,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&Xl(n,t,l),o=o.next}while(o!==r)}zt(e,t,n);break;case 1:if(!Te&&(zn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){ce(n,t,a)}zt(e,t,n);break;case 21:zt(e,t,n);break;case 22:n.mode&1?(Te=(r=Te)||n.memoizedState!==null,zt(e,t,n),Te=r):zt(e,t,n);break;default:zt(e,t,n)}}function hu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Uh),t.forEach(function(r){var o=Gh.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function at(e,t){var n=t.deletions;if(n!==null)for(var r=0;ro&&(o=l),r&=~i}if(r=o,r=he()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Hh(r/1960))-r,10e?16:e,Ft===null)var r=!1;else{if(e=Ft,Ft=null,ri=0,Y&6)throw Error(E(331));var o=Y;for(Y|=4,A=e.current;A!==null;){var i=A,l=i.child;if(A.flags&16){var a=i.deletions;if(a!==null){for(var u=0;uhe()-Gs?sn(e,0):Xs|=n),Ve(e,t)}function Gd(e,t){t===0&&(e.mode&1?(t=oo,oo<<=1,!(oo&130023424)&&(oo=4194304)):t=1);var n=Ae();e=Rt(e,t),e!==null&&($r(e,t,n),Ve(e,n))}function Xh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gd(e,n)}function Gh(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),Gd(e,n)}var Jd;Jd=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||We.current)$e=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return $e=!1,Bh(e,t,n);$e=!!(e.flags&131072)}else $e=!1,ie&&t.flags&1048576&&nd(t,Ko,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ro(e,t),e=t.pendingProps;var o=Mn(t,ze.current);Fn(t,n),o=Hs(null,t,r,e,o,n);var i=Vs();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,He(r)?(i=!0,Qo(t)):i=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,Is(t),o.updater=mi,t.stateNode=o,o._reactInternals=t,Wl(t,r,e,n),t=Ql(null,t,r,!0,i,n)):(t.tag=0,ie&&i&&Ns(t),Ne(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ro(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=Zh(r),e=ut(r,e),o){case 0:t=Vl(null,t,r,e,n);break e;case 1:t=uu(null,t,r,e,n);break e;case 11:t=su(null,t,r,e,n);break e;case 14:t=au(null,t,r,ut(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),Vl(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),uu(e,t,r,o,n);case 3:e:{if(Dd(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,o=i.element,ad(e,t),Go(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){o=Hn(Error(E(423)),t),t=cu(e,t,r,n,o);break e}else if(r!==o){o=Hn(Error(E(424)),t),t=cu(e,t,r,n,o);break e}else for(Ke=Ut(t.stateNode.containerInfo.firstChild),Ye=t,ie=!0,dt=null,n=ld(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Un(),r===o){t=Tt(e,t,n);break e}Ne(e,t,r,n)}t=t.child}return t;case 5:return ud(t),e===null&&Ml(t),r=t.type,o=t.pendingProps,i=e!==null?e.memoizedProps:null,l=o.children,Dl(r,o)?l=null:i!==null&&Dl(r,i)&&(t.flags|=32),Od(e,t),Ne(e,t,l,n),t.child;case 6:return e===null&&Ml(t),null;case 13:return Ld(e,t,n);case 4:return Ms(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=$n(t,null,r,n):Ne(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),su(e,t,r,o,n);case 7:return Ne(e,t,t.pendingProps,n),t.child;case 8:return Ne(e,t,t.pendingProps.children,n),t.child;case 12:return Ne(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,i=t.memoizedProps,l=o.value,te(Yo,r._currentValue),r._currentValue=l,i!==null)if(ht(i.value,l)){if(i.children===o.children&&!We.current){t=Tt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var a=i.dependencies;if(a!==null){l=i.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=Ct(-1,n&-n),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var p=c.pending;p===null?u.next=u:(u.next=p.next,p.next=u),c.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),Ul(i.return,n,t),a.lanes|=n;break}u=u.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,a=l.alternate,a!==null&&(a.lanes|=n),Ul(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}Ne(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,Fn(t,n),o=it(o),r=r(o),t.flags|=1,Ne(e,t,r,n),t.child;case 14:return r=t.type,o=ut(r,t.pendingProps),o=ut(r.type,o),au(e,t,r,o,n);case 15:return Nd(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),Ro(e,t),t.tag=1,He(r)?(e=!0,Qo(t)):e=!1,Fn(t,n),Td(t,r,o),Wl(t,r,o,n),Ql(null,t,r,!0,e,n);case 19:return Fd(e,t,n);case 22:return Ad(e,t,n)}throw Error(E(156,t.tag))};function Zd(e,t){return Ec(e,t)}function Jh(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function rt(e,t,n,r){return new Jh(e,t,n,r)}function ta(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Zh(e){if(typeof e=="function")return ta(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ws)return 11;if(e===Ss)return 14}return 2}function Vt(e,t){var n=e.alternate;return n===null?(n=rt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function zo(e,t,n,r,o,i){var l=2;if(r=e,typeof e=="function")ta(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case bn:return an(n.children,o,i,t);case vs:l=8,o|=8;break;case pl:return e=rt(12,n,t,o|2),e.elementType=pl,e.lanes=i,e;case hl:return e=rt(13,n,t,o),e.elementType=hl,e.lanes=i,e;case ml:return e=rt(19,n,t,o),e.elementType=ml,e.lanes=i,e;case uc:return xi(n,o,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case sc:l=10;break e;case ac:l=9;break e;case ws:l=11;break e;case Ss:l=14;break e;case Nt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=rt(l,n,t,o),t.elementType=e,t.type=r,t.lanes=i,t}function an(e,t,n,r){return e=rt(7,e,r,t),e.lanes=n,e}function xi(e,t,n,r){return e=rt(22,e,r,t),e.elementType=uc,e.lanes=n,e.stateNode={isHidden:!1},e}function tl(e,t,n){return e=rt(6,e,null,t),e.lanes=n,e}function nl(e,t,n){return t=rt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function em(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Li(0),this.expirationTimes=Li(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Li(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function na(e,t,n,r,o,i,l,a,u){return e=new em(e,t,n,a,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=rt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Is(i),e}function tm(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(rf)}catch(e){console.error(e)}}rf(),rc.exports=Ge;var lm=rc.exports,bu=lm;dl.createRoot=bu.createRoot,dl.hydrateRoot=bu.hydrateRoot;function of(e,t){return function(){return e.apply(t,arguments)}}const{toString:sm}=Object.prototype,{getPrototypeOf:ki}=Object,{iterator:ji,toStringTag:lf}=Symbol,Ci=(e=>t=>{const n=sm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),mt=e=>(e=e.toLowerCase(),t=>Ci(t)===e),Ei=e=>t=>typeof t===e,{isArray:Xn}=Array,Qn=Ei("undefined");function Qr(e){return e!==null&&!Qn(e)&&e.constructor!==null&&!Qn(e.constructor)&&Qe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const sf=mt("ArrayBuffer");function am(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&sf(e.buffer),t}const um=Ei("string"),Qe=Ei("function"),af=Ei("number"),qr=e=>e!==null&&typeof e=="object",cm=e=>e===!0||e===!1,No=e=>{if(Ci(e)!=="object")return!1;const t=ki(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lf in e)&&!(ji in e)},dm=e=>{if(!qr(e)||Qr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},fm=mt("Date"),pm=mt("File"),hm=e=>!!(e&&typeof e.uri<"u"),mm=e=>e&&typeof e.getParts<"u",gm=mt("Blob"),ym=mt("FileList"),xm=e=>qr(e)&&Qe(e.pipe);function vm(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const ku=vm(),ju=typeof ku.FormData<"u"?ku.FormData:void 0,wm=e=>{if(!e)return!1;if(ju&&e instanceof ju)return!0;const t=ki(e);if(!t||t===Object.prototype||!Qe(e.append))return!1;const n=Ci(e);return n==="formdata"||n==="object"&&Qe(e.toString)&&e.toString()==="[object FormData]"},Sm=mt("URLSearchParams"),[bm,km,jm,Cm]=["ReadableStream","Request","Response","Headers"].map(mt),Em=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Kr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Xn(e))for(r=0,o=e.length;r0;)if(o=n[r],t===o.toLowerCase())return o;return null}const ln=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,cf=e=>!Qn(e)&&e!==ln;function os(...e){const{caseless:t,skipUndefined:n}=cf(this)&&this||{},r={},o=(i,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const a=t&&uf(r,l)||l,u=is(r,a)?r[a]:void 0;No(u)&&No(i)?r[a]=os(u,i):No(i)?r[a]=os({},i):Xn(i)?r[a]=i.slice():(!n||!Qn(i))&&(r[a]=i)};for(let i=0,l=e.length;i(Kr(t,(o,i)=>{n&&Qe(o)?Object.defineProperty(e,i,{__proto__:null,value:of(o,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{__proto__:null,value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),Rm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Tm=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},Pm=(e,t,n,r)=>{let o,i,l;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)l=o[i],(!r||r(l,e,t))&&!a[l]&&(t[l]=e[l],a[l]=!0);e=n!==!1&&ki(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},zm=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Nm=e=>{if(!e)return null;if(Xn(e))return e;let t=e.length;if(!af(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Am=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ki(Uint8Array)),Om=(e,t)=>{const r=(e&&e[ji]).call(e);let o;for(;(o=r.next())&&!o.done;){const i=o.value;t.call(e,i[0],i[1])}},Dm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Lm=mt("HTMLFormElement"),Fm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),is=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Bm=mt("RegExp"),df=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Kr(n,(o,i)=>{let l;(l=t(o,i,e))!==!1&&(r[i]=l||o)}),Object.defineProperties(e,r)},Im=e=>{df(e,(t,n)=>{if(Qe(e)&&["arguments","caller","callee"].includes(n))return!1;const r=e[n];if(Qe(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Mm=(e,t)=>{const n={},r=o=>{o.forEach(i=>{n[i]=!0})};return Xn(e)?r(e):r(String(e).split(t)),n},Um=()=>{},$m=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Wm(e){return!!(e&&Qe(e.append)&&e[lf]==="FormData"&&e[ji])}const Hm=e=>{const t=new WeakSet,n=r=>{if(qr(r)){if(t.has(r))return;if(Qr(r))return r;if(!("toJSON"in r)){t.add(r);const o=Xn(r)?[]:{};return Kr(r,(i,l)=>{const a=n(i);!Qn(a)&&(o[l]=a)}),t.delete(r),o}}return r};return n(e)},Vm=mt("AsyncFunction"),Qm=e=>e&&(qr(e)||Qe(e))&&Qe(e.then)&&Qe(e.catch),ff=((e,t)=>e?setImmediate:t?((n,r)=>(ln.addEventListener("message",({source:o,data:i})=>{o===ln&&i===n&&r.length&&r.shift()()},!1),o=>{r.push(o),ln.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Qe(ln.postMessage)),qm=typeof queueMicrotask<"u"?queueMicrotask.bind(ln):typeof process<"u"&&process.nextTick||ff,Km=e=>e!=null&&Qe(e[ji]),w={isArray:Xn,isArrayBuffer:sf,isBuffer:Qr,isFormData:wm,isArrayBufferView:am,isString:um,isNumber:af,isBoolean:cm,isObject:qr,isPlainObject:No,isEmptyObject:dm,isReadableStream:bm,isRequest:km,isResponse:jm,isHeaders:Cm,isUndefined:Qn,isDate:fm,isFile:pm,isReactNativeBlob:hm,isReactNative:mm,isBlob:gm,isRegExp:Bm,isFunction:Qe,isStream:xm,isURLSearchParams:Sm,isTypedArray:Am,isFileList:ym,forEach:Kr,merge:os,extend:_m,trim:Em,stripBOM:Rm,inherits:Tm,toFlatObject:Pm,kindOf:Ci,kindOfTest:mt,endsWith:zm,toArray:Nm,forEachEntry:Om,matchAll:Dm,isHTMLForm:Lm,hasOwnProperty:is,hasOwnProp:is,reduceDescriptors:df,freezeMethods:Im,toObjectSet:Mm,toCamelCase:Fm,noop:Um,toFiniteNumber:$m,findKey:uf,global:ln,isContextDefined:cf,isSpecCompliantForm:Wm,toJSONObject:Hm,isAsyncFn:Vm,isThenable:Qm,setImmediate:ff,asap:qm,isIterable:Km},Ym=w.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Xm=e=>{const t={};let n,r,o;return e&&e.split(` -`).forEach(function(l){o=l.indexOf(":"),n=l.substring(0,o).trim().toLowerCase(),r=l.substring(o+1).trim(),!(!n||t[n]&&Ym[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t};function Gm(e){let t=0,n=e.length;for(;tt;){const r=e.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return t===0&&n===e.length?e:e.slice(t,n)}const Jm=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),Zm=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function la(e,t){return w.isArray(e)?e.map(n=>la(n,t)):Gm(String(e).replace(t,""))}const eg=e=>la(e,Jm),tg=e=>la(e,Zm);function pf(e){const t=Object.create(null);return w.forEach(e.toJSON(),(n,r)=>{t[r]=tg(n)}),t}const Cu=Symbol("internals");function lr(e){return e&&String(e).trim().toLowerCase()}function Ao(e){return e===!1||e==null?e:w.isArray(e)?e.map(Ao):eg(String(e))}function ng(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const rg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function rl(e,t,n,r,o){if(w.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!w.isString(t)){if(w.isString(r))return t.indexOf(r)!==-1;if(w.isRegExp(r))return r.test(t)}}function og(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function ig(e,t){const n=w.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(o,i,l){return this[r].call(this,t,o,i,l)},configurable:!0})})}let Oe=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function i(a,u,c){const p=lr(u);if(!p)throw new Error("header name must be a non-empty string");const m=w.findKey(o,p);(!m||o[m]===void 0||c===!0||c===void 0&&o[m]!==!1)&&(o[m||u]=Ao(a))}const l=(a,u)=>w.forEach(a,(c,p)=>i(c,p,u));if(w.isPlainObject(t)||t instanceof this.constructor)l(t,n);else if(w.isString(t)&&(t=t.trim())&&!rg(t))l(Xm(t),n);else if(w.isObject(t)&&w.isIterable(t)){let a={},u,c;for(const p of t){if(!w.isArray(p))throw TypeError("Object iterator must return a key-value pair");a[c=p[0]]=(u=a[c])?w.isArray(u)?[...u,p[1]]:[u,p[1]]:p[1]}l(a,n)}else t!=null&&i(n,t,r);return this}get(t,n){if(t=lr(t),t){const r=w.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return ng(o);if(w.isFunction(n))return n.call(this,o,r);if(w.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=lr(t),t){const r=w.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||rl(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function i(l){if(l=lr(l),l){const a=w.findKey(r,l);a&&(!n||rl(r,r[a],a,n))&&(delete r[a],o=!0)}}return w.isArray(t)?t.forEach(i):i(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const i=n[r];(!t||rl(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){const n=this,r={};return w.forEach(this,(o,i)=>{const l=w.findKey(r,i);if(l){n[l]=Ao(o),delete n[i];return}const a=t?og(i):String(i).trim();a!==i&&delete n[i],n[a]=Ao(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return w.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&w.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Cu]=this[Cu]={accessors:{}}).accessors,o=this.prototype;function i(l){const a=lr(l);r[a]||(ig(o,l),r[a]=!0)}return w.isArray(t)?t.forEach(i):i(t),this}};Oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);w.reduceDescriptors(Oe.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});w.freezeMethods(Oe);const lg="[REDACTED ****]";function sg(e){if(w.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(w.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}function ag(e,t){const n=new Set(t.map(i=>String(i).toLowerCase())),r=[],o=i=>{if(i===null||typeof i!="object"||w.isBuffer(i))return i;if(r.indexOf(i)!==-1)return;i instanceof Oe&&(i=i.toJSON()),r.push(i);let l;if(w.isArray(i))l=[],i.forEach((a,u)=>{const c=o(a);w.isUndefined(c)||(l[u]=c)});else{if(!w.isPlainObject(i)&&sg(i))return r.pop(),i;l=Object.create(null);for(const[a,u]of Object.entries(i)){const c=n.has(a.toLowerCase())?lg:o(u);w.isUndefined(c)||(l[a]=c)}}return r.pop(),l};return o(e)}let O=class hf extends Error{static from(t,n,r,o,i,l){const a=new hf(t.message,n||t.code,r,o,i);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),l&&Object.assign(a,l),a}constructor(t,n,r,o,i){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){const t=this.config,n=t&&w.hasOwnProp(t,"redact")?t.redact:void 0,r=w.isArray(n)&&n.length>0?ag(t,n):w.toJSONObject(t);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:r,code:this.code,status:this.status}}};O.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";O.ERR_BAD_OPTION="ERR_BAD_OPTION";O.ECONNABORTED="ECONNABORTED";O.ETIMEDOUT="ETIMEDOUT";O.ECONNREFUSED="ECONNREFUSED";O.ERR_NETWORK="ERR_NETWORK";O.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";O.ERR_DEPRECATED="ERR_DEPRECATED";O.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";O.ERR_BAD_REQUEST="ERR_BAD_REQUEST";O.ERR_CANCELED="ERR_CANCELED";O.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";O.ERR_INVALID_URL="ERR_INVALID_URL";O.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const ug=null;function ls(e){return w.isPlainObject(e)||w.isArray(e)}function mf(e){return w.endsWith(e,"[]")?e.slice(0,-2):e}function ol(e,t,n){return e?e.concat(t).map(function(o,i){return o=mf(o),!n&&i?"["+o+"]":o}).join(n?".":""):t}function cg(e){return w.isArray(e)&&!e.some(ls)}const dg=w.toFlatObject(w,{},null,function(t){return/^is[A-Z]/.test(t)});function _i(e,t,n){if(!w.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=w.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,f){return!w.isUndefined(f[g])});const r=n.metaTokens,o=n.visitor||m,i=n.dots,l=n.indexes,a=n.Blob||typeof Blob<"u"&&Blob,u=n.maxDepth===void 0?100:n.maxDepth,c=a&&w.isSpecCompliantForm(t);if(!w.isFunction(o))throw new TypeError("visitor must be a function");function p(v){if(v===null)return"";if(w.isDate(v))return v.toISOString();if(w.isBoolean(v))return v.toString();if(!c&&w.isBlob(v))throw new O("Blob is not supported. Use a Buffer instead.");return w.isArrayBuffer(v)||w.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function m(v,g,f){let d=v;if(w.isReactNative(t)&&w.isReactNativeBlob(v))return t.append(ol(f,g,i),p(v)),!1;if(v&&!f&&typeof v=="object"){if(w.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(w.isArray(v)&&cg(v)||(w.isFileList(v)||w.endsWith(g,"[]"))&&(d=w.toArray(v)))return g=mf(g),d.forEach(function(b,C){!(w.isUndefined(b)||b===null)&&t.append(l===!0?ol([g],C,i):l===null?g:g+"[]",p(b))}),!1}return ls(v)?!0:(t.append(ol(f,g,i),p(v)),!1)}const y=[],S=Object.assign(dg,{defaultVisitor:m,convertValue:p,isVisitable:ls});function x(v,g,f=0){if(!w.isUndefined(v)){if(f>u)throw new O("Object is too deeply nested ("+f+" levels). Max depth: "+u,O.ERR_FORM_DATA_DEPTH_EXCEEDED);if(y.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));y.push(v),w.forEach(v,function(h,b){(!(w.isUndefined(h)||h===null)&&o.call(t,h,w.isString(b)?b.trim():b,g,S))===!0&&x(h,g?g.concat(b):[b],f+1)}),y.pop()}}if(!w.isObject(e))throw new TypeError("data must be an object");return x(e),t}function Eu(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(r){return t[r]})}function sa(e,t){this._pairs=[],e&&_i(e,this,t)}const gf=sa.prototype;gf.append=function(t,n){this._pairs.push([t,n])};gf.toString=function(t){const n=t?function(r){return t.call(this,r,Eu)}:Eu;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function fg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function yf(e,t,n){if(!t)return e;const r=n&&n.encode||fg,o=w.isFunction(n)?{serialize:n}:n,i=o&&o.serialize;let l;if(i?l=i(t,o):l=w.isURLSearchParams(t)?t.toString():new sa(t,o).toString(r),l){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+l}return e}class _u{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){w.forEach(this.handlers,function(r){r!==null&&t(r)})}}const aa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},pg=typeof URLSearchParams<"u"?URLSearchParams:sa,hg=typeof FormData<"u"?FormData:null,mg=typeof Blob<"u"?Blob:null,gg={isBrowser:!0,classes:{URLSearchParams:pg,FormData:hg,Blob:mg},protocols:["http","https","file","blob","url","data"]},ua=typeof window<"u"&&typeof document<"u",ss=typeof navigator=="object"&&navigator||void 0,yg=ua&&(!ss||["ReactNative","NativeScript","NS"].indexOf(ss.product)<0),xg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",vg=ua&&window.location.href||"http://localhost",wg=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ua,hasStandardBrowserEnv:yg,hasStandardBrowserWebWorkerEnv:xg,navigator:ss,origin:vg},Symbol.toStringTag,{value:"Module"})),Pe={...wg,...gg};function Sg(e,t){return _i(e,new Pe.classes.URLSearchParams,{visitor:function(n,r,o,i){return Pe.isNode&&w.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function bg(e){return w.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function kg(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r=n.length;return l=!l&&w.isArray(o)?o.length:l,u?(w.hasOwnProp(o,l)?o[l]=w.isArray(o[l])?o[l].concat(r):[o[l],r]:o[l]=r,!a):((!w.hasOwnProp(o,l)||!w.isObject(o[l]))&&(o[l]=[]),t(n,r,o[l],i)&&w.isArray(o[l])&&(o[l]=kg(o[l])),!a)}if(w.isFormData(e)&&w.isFunction(e.entries)){const n={};return w.forEachEntry(e,(r,o)=>{t(bg(r),o,n,0)}),n}return null}const wn=(e,t)=>e!=null&&w.hasOwnProp(e,t)?e[t]:void 0;function jg(e,t,n){if(w.isString(e))try{return(t||JSON.parse)(e),w.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Yr={transitional:aa,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,i=w.isObject(t);if(i&&w.isHTMLForm(t)&&(t=new FormData(t)),w.isFormData(t))return o?JSON.stringify(xf(t)):t;if(w.isArrayBuffer(t)||w.isBuffer(t)||w.isStream(t)||w.isFile(t)||w.isBlob(t)||w.isReadableStream(t))return t;if(w.isArrayBufferView(t))return t.buffer;if(w.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){const u=wn(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Sg(t,u).toString();if((a=w.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=wn(this,"env"),p=c&&c.FormData;return _i(a?{"files[]":t}:t,p&&new p,u)}}return i||o?(n.setContentType("application/json",!1),jg(t)):t}],transformResponse:[function(t){const n=wn(this,"transitional")||Yr.transitional,r=n&&n.forcedJSONParsing,o=wn(this,"responseType"),i=o==="json";if(w.isResponse(t)||w.isReadableStream(t))return t;if(t&&w.isString(t)&&(r&&!o||i)){const a=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(t,wn(this,"parseReviver"))}catch(u){if(a)throw u.name==="SyntaxError"?O.from(u,O.ERR_BAD_RESPONSE,this,null,wn(this,"response")):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Pe.classes.FormData,Blob:Pe.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};w.forEach(["delete","get","head","post","put","patch","query"],e=>{Yr.headers[e]={}});function il(e,t){const n=this||Yr,r=t||n,o=Oe.from(r.headers);let i=r.data;return w.forEach(e,function(a){i=a.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function vf(e){return!!(e&&e.__CANCEL__)}let Xr=class extends O{constructor(t,n,r){super(t??"canceled",O.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function wf(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new O("Request failed with status code "+n.status,n.status>=400&&n.status<500?O.ERR_BAD_REQUEST:O.ERR_BAD_RESPONSE,n.config,n.request,n))}function Cg(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function Eg(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,i=0,l;return t=t!==void 0?t:1e3,function(u){const c=Date.now(),p=r[i];l||(l=c),n[o]=u,r[o]=c;let m=i,y=0;for(;m!==o;)y+=n[m++],m=m%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-l{n=p,o=null,i&&(clearTimeout(i),i=null),e(...c)};return[(...c)=>{const p=Date.now(),m=p-n;m>=r?l(c,p):(o=c,i||(i=setTimeout(()=>{i=null,l(o)},r-m)))},()=>o&&l(o)]}const li=(e,t,n=3)=>{let r=0;const o=Eg(50,250);return _g(i=>{if(!i||typeof i.loaded!="number")return;const l=i.loaded,a=i.lengthComputable?i.total:void 0,u=a!=null?Math.min(l,a):l,c=Math.max(0,u-r),p=o(c);r=Math.max(r,u);const m={loaded:u,total:a,progress:a?u/a:void 0,bytes:c,rate:p||void 0,estimated:p&&a?(a-u)/p:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(m)},n)},Ru=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Tu=e=>(...t)=>w.asap(()=>e(...t)),Rg=Pe.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Pe.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Pe.origin),Pe.navigator&&/(msie|trident)/i.test(Pe.navigator.userAgent)):()=>!0,Tg=Pe.hasStandardBrowserEnv?{write(e,t,n,r,o,i,l){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];w.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),w.isString(r)&&a.push(`path=${r}`),w.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),w.isString(l)&&a.push(`SameSite=${l}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.split(";");for(let n=0;ne instanceof Oe?{...e}:e;function mn(e,t){t=t||{};const n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(c,p,m,y){return w.isPlainObject(c)&&w.isPlainObject(p)?w.merge.call({caseless:y},c,p):w.isPlainObject(p)?w.merge({},p):w.isArray(p)?p.slice():p}function o(c,p,m,y){if(w.isUndefined(p)){if(!w.isUndefined(c))return r(void 0,c,m,y)}else return r(c,p,m,y)}function i(c,p){if(!w.isUndefined(p))return r(void 0,p)}function l(c,p){if(w.isUndefined(p)){if(!w.isUndefined(c))return r(void 0,c)}else return r(void 0,p)}function a(c,p,m){if(w.hasOwnProp(t,m))return r(c,p);if(w.hasOwnProp(e,m))return r(void 0,c)}const u={url:i,method:i,data:i,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,withXSRFToken:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,beforeRedirect:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,allowedSocketPaths:l,responseEncoding:l,validateStatus:a,headers:(c,p,m)=>o(Pu(c),Pu(p),m,!0)};return w.forEach(Object.keys({...e,...t}),function(p){if(p==="__proto__"||p==="constructor"||p==="prototype")return;const m=w.hasOwnProp(u,p)?u[p]:o,y=w.hasOwnProp(e,p)?e[p]:void 0,S=w.hasOwnProp(t,p)?t[p]:void 0,x=m(y,S,p);w.isUndefined(x)&&m!==a||(n[p]=x)}),n}const Ng=["content-type","content-length"];function Ag(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t).forEach(([r,o])=>{Ng.includes(r.toLowerCase())&&e.set(r,o)})}const Og=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),bf=e=>{const t=mn({},e),n=y=>w.hasOwnProp(t,y)?t[y]:void 0,r=n("data");let o=n("withXSRFToken");const i=n("xsrfHeaderName"),l=n("xsrfCookieName");let a=n("headers");const u=n("auth"),c=n("baseURL"),p=n("allowAbsoluteUrls"),m=n("url");if(t.headers=a=Oe.from(a),t.url=yf(Sf(c,m,p),e.params,e.paramsSerializer),u&&a.set("Authorization","Basic "+btoa((u.username||"")+":"+(u.password?Og(u.password):""))),w.isFormData(r)&&(Pe.hasStandardBrowserEnv||Pe.hasStandardBrowserWebWorkerEnv?a.setContentType(void 0):w.isFunction(r.getHeaders)&&Ag(a,r.getHeaders(),n("formDataHeaderPolicy"))),Pe.hasStandardBrowserEnv&&(w.isFunction(o)&&(o=o(t)),o===!0||o==null&&Rg(t.url))){const S=i&&l&&Tg.read(l);S&&a.set(i,S)}return t},Dg=typeof XMLHttpRequest<"u",Lg=Dg&&function(e){return new Promise(function(n,r){const o=bf(e);let i=o.data;const l=Oe.from(o.headers).normalize();let{responseType:a,onUploadProgress:u,onDownloadProgress:c}=o,p,m,y,S,x;function v(){S&&S(),x&&x(),o.cancelToken&&o.cancelToken.unsubscribe(p),o.signal&&o.signal.removeEventListener("abort",p)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function f(){if(!g)return;const h=Oe.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:h,config:e,request:g};wf(function(T){n(T),v()},function(T){r(T),v()},C),g=null}"onloadend"in g?g.onloadend=f:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.startsWith("file:"))||setTimeout(f)},g.onabort=function(){g&&(r(new O("Request aborted",O.ECONNABORTED,e,g)),v(),g=null)},g.onerror=function(b){const C=b&&b.message?b.message:"Network Error",j=new O(C,O.ERR_NETWORK,e,g);j.event=b||null,r(j),v(),g=null},g.ontimeout=function(){let b=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||aa;o.timeoutErrorMessage&&(b=o.timeoutErrorMessage),r(new O(b,C.clarifyTimeoutError?O.ETIMEDOUT:O.ECONNABORTED,e,g)),v(),g=null},i===void 0&&l.setContentType(null),"setRequestHeader"in g&&w.forEach(pf(l),function(b,C){g.setRequestHeader(C,b)}),w.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),c&&([y,x]=li(c,!0),g.addEventListener("progress",y)),u&&g.upload&&([m,S]=li(u),g.upload.addEventListener("progress",m),g.upload.addEventListener("loadend",S)),(o.cancelToken||o.signal)&&(p=h=>{g&&(r(!h||h.type?new Xr(null,e,g):h),g.abort(),v(),g=null)},o.cancelToken&&o.cancelToken.subscribe(p),o.signal&&(o.signal.aborted?p():o.signal.addEventListener("abort",p)));const d=Cg(o.url);if(d&&!Pe.protocols.includes(d)){r(new O("Unsupported protocol "+d+":",O.ERR_BAD_REQUEST,e));return}g.send(i||null)})},Fg=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;const n=new AbortController;let r=!1;const o=function(u){if(!r){r=!0,l();const c=u instanceof Error?u:this.reason;n.abort(c instanceof O?c:new Xr(c instanceof Error?c.message:c))}};let i=t&&setTimeout(()=>{i=null,o(new O(`timeout of ${t}ms exceeded`,O.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:a}=n;return a.unsubscribe=()=>w.asap(l),a},Bg=function*(e,t){let n=e.byteLength;if(n{const o=Ig(e,t);let i=0,l,a=u=>{l||(l=!0,r&&r(u))};return new ReadableStream({async pull(u){try{const{done:c,value:p}=await o.next();if(c){a(),u.close();return}let m=p.byteLength;if(n){let y=i+=m;n(y)}u.enqueue(new Uint8Array(p))}catch(c){throw a(c),c}},cancel(u){return a(u),o.return()}},{highWaterMark:2})};function Ug(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;const t=e.indexOf(",");if(t<0)return 0;const n=e.slice(5,t),r=e.slice(t+1);if(/;base64/i.test(n)){let l=r.length;const a=r.length;for(let S=0;S=48&&x<=57||x>=65&&x<=70||x>=97&&x<=102)&&(v>=48&&v<=57||v>=65&&v<=70||v>=97&&v<=102)&&(l-=2,S+=2)}let u=0,c=a-1;const p=S=>S>=2&&r.charCodeAt(S-2)===37&&r.charCodeAt(S-1)===51&&(r.charCodeAt(S)===68||r.charCodeAt(S)===100);c>=0&&(r.charCodeAt(c)===61?(u++,c--):p(c)&&(u++,c-=3)),u===1&&c>=0&&(r.charCodeAt(c)===61||p(c))&&u++;const y=Math.floor(l/4)*3-(u||0);return y>0?y:0}if(typeof Buffer<"u"&&typeof Buffer.byteLength=="function")return Buffer.byteLength(r,"utf8");let i=0;for(let l=0,a=r.length;l=55296&&u<=56319&&l+1=56320&&c<=57343?(i+=4,l++):i+=3}else i+=3}return i}const ca="1.16.1",Nu=64*1024,{isFunction:yo}=w,Au=(e,...t)=>{try{return!!e(...t)}catch{return!1}},$g=e=>{const t=w.global!==void 0&&w.global!==null?w.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=w.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:o,Request:i,Response:l}=e,a=o?yo(o):typeof fetch=="function",u=yo(i),c=yo(l);if(!a)return!1;const p=a&&yo(n),m=a&&(typeof r=="function"?(f=>d=>f.encode(d))(new r):async f=>new Uint8Array(await new i(f).arrayBuffer())),y=u&&p&&Au(()=>{let f=!1;const d=new i(Pe.origin,{body:new n,method:"POST",get duplex(){return f=!0,"half"}}),h=d.headers.has("Content-Type");return d.body!=null&&d.body.cancel(),f&&!h}),S=c&&p&&Au(()=>w.isReadableStream(new l("").body)),x={stream:S&&(f=>f.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!x[f]&&(x[f]=(d,h)=>{let b=d&&d[f];if(b)return b.call(d);throw new O(`Response type '${f}' is not supported`,O.ERR_NOT_SUPPORT,h)})});const v=async f=>{if(f==null)return 0;if(w.isBlob(f))return f.size;if(w.isSpecCompliantForm(f))return(await new i(Pe.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(w.isArrayBufferView(f)||w.isArrayBuffer(f))return f.byteLength;if(w.isURLSearchParams(f)&&(f=f+""),w.isString(f))return(await m(f)).byteLength},g=async(f,d)=>{const h=w.toFiniteNumber(f.getContentLength());return h??v(d)};return async f=>{let{url:d,method:h,data:b,signal:C,cancelToken:j,timeout:T,onDownloadProgress:_,onUploadProgress:Q,responseType:U,headers:X,withCredentials:H="same-origin",fetchOptions:N,maxContentLength:L,maxBodyLength:R}=bf(f);const P=w.isNumber(L)&&L>-1,$=w.isNumber(R)&&R>-1;let z=o||fetch;U=U?(U+"").toLowerCase():"text";let B=Fg([C,j&&j.toAbortSignal()],T),I=null;const K=B&&B.unsubscribe&&(()=>{B.unsubscribe()});let le;try{if(P&&typeof d=="string"&&d.startsWith("data:")&&Ug(d)>L)throw new O("maxContentLength size of "+L+" exceeded",O.ERR_BAD_RESPONSE,f,I);if($&&h!=="get"&&h!=="head"){const ee=await g(X,b);if(typeof ee=="number"&&isFinite(ee)&&ee>R)throw new O("Request body larger than maxBodyLength limit",O.ERR_BAD_REQUEST,f,I)}if(Q&&y&&h!=="get"&&h!=="head"&&(le=await g(X,b))!==0){let ee=new i(d,{method:"POST",body:b,duplex:"half"}),xn;if(w.isFormData(b)&&(xn=ee.headers.get("content-type"))&&X.setContentType(xn),ee.body){const[Gr,Jr]=Ru(le,li(Tu(Q)));b=zu(ee.body,Nu,Gr,Jr)}}w.isString(H)||(H=H?"include":"omit");const de=u&&"credentials"in i.prototype;if(w.isFormData(b)){const ee=X.getContentType();ee&&/^multipart\/form-data/i.test(ee)&&!/boundary=/i.test(ee)&&X.delete("content-type")}X.set("User-Agent","axios/"+ca,!1);const Ce={...N,signal:B,method:h.toUpperCase(),headers:pf(X.normalize()),body:b,duplex:"half",credentials:de?H:void 0};I=u&&new i(d,Ce);let Fe=await(u?z(I,N):z(d,Ce));if(P){const ee=w.toFiniteNumber(Fe.headers.get("content-length"));if(ee!=null&&ee>L)throw new O("maxContentLength size of "+L+" exceeded",O.ERR_BAD_RESPONSE,f,I)}const st=S&&(U==="stream"||U==="response");if(S&&Fe.body&&(_||P||st&&K)){const ee={};["status","statusText","headers"].forEach(Gn=>{ee[Gn]=Fe[Gn]});const xn=w.toFiniteNumber(Fe.headers.get("content-length")),[Gr,Jr]=_&&Ru(xn,li(Tu(_),!0))||[];let pa=0;const Nf=Gn=>{if(P&&(pa=Gn,pa>L))throw new O("maxContentLength size of "+L+" exceeded",O.ERR_BAD_RESPONSE,f,I);Gr&&Gr(Gn)};Fe=new l(zu(Fe.body,Nu,Nf,()=>{Jr&&Jr(),K&&K()}),ee)}U=U||"text";let Be=await x[w.findKey(x,U)||"text"](Fe,f);if(P&&!S&&!st){let ee;if(Be!=null&&(typeof Be.byteLength=="number"?ee=Be.byteLength:typeof Be.size=="number"?ee=Be.size:typeof Be=="string"&&(ee=typeof r=="function"?new r().encode(Be).byteLength:Be.length)),typeof ee=="number"&&ee>L)throw new O("maxContentLength size of "+L+" exceeded",O.ERR_BAD_RESPONSE,f,I)}return!st&&K&&K(),await new Promise((ee,xn)=>{wf(ee,xn,{data:Be,headers:Oe.from(Fe.headers),status:Fe.status,statusText:Fe.statusText,config:f,request:I})})}catch(de){if(K&&K(),B&&B.aborted&&B.reason instanceof O){const Ce=B.reason;throw Ce.config=f,I&&(Ce.request=I),de!==Ce&&(Ce.cause=de),Ce}throw de&&de.name==="TypeError"&&/Load failed|fetch/i.test(de.message)?Object.assign(new O("Network Error",O.ERR_NETWORK,f,I,de&&de.response),{cause:de.cause||de}):O.from(de,de&&de.code,f,I,de&&de.response)}}},Wg=new Map,kf=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:o}=t,i=[r,o,n];let l=i.length,a=l,u,c,p=Wg;for(;a--;)u=i[a],c=p.get(u),c===void 0&&p.set(u,c=a?new Map:$g(t)),p=c;return c};kf();const da={http:ug,xhr:Lg,fetch:{get:kf}};w.forEach(da,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const Ou=e=>`- ${e}`,Hg=e=>w.isFunction(e)||e===null||e===!1;function Vg(e,t){e=w.isArray(e)?e:[e];const{length:n}=e;let r,o;const i={};for(let l=0;l`adapter ${u} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?l.length>1?`since : +`+i.stack}return{value:e,source:t,stack:o,digest:null}}function Zi(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Hl(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Dh=typeof WeakMap=="function"?WeakMap:Map;function Pd(e,t,n){n=Ct(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){ni||(ni=!0,es=r),Hl(e,t)},n}function Nd(e,t,n){n=Ct(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var o=t.value;n.payload=function(){return r(o)},n.callback=function(){Hl(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Hl(e,t),typeof r!="function"&&(Wt===null?Wt=new Set([this]):Wt.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),n}function ou(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Dh;var o=new Set;r.set(t,o)}else o=r.get(t),o===void 0&&(o=new Set,r.set(t,o));o.has(n)||(o.add(n),e=Yh.bind(null,e,t,n),t.then(e,e))}function iu(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function lu(e,t,n,r,o){return e.mode&1?(e.flags|=65536,e.lanes=o,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Ct(-1,1),t.tag=2,$t(n,t,1))),n.lanes|=1),e)}var Lh=Pt.ReactCurrentOwner,$e=!1;function Ae(e,t,n,r){t.child=e===null?ld(t,null,n,r):$n(t,e.child,n,r)}function su(e,t,n,r,o){n=n.render;var i=t.ref;return Fn(t,o),r=Hs(e,t,n,r,i,o),n=Vs(),e!==null&&!$e?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,Tt(e,t,o)):(ie&&n&&As(t),t.flags|=1,Ae(e,t,r,o),t.child)}function au(e,t,n,r,o){if(e===null){var i=n.type;return typeof i=="function"&&!ta(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,Ad(e,t,i,r,o)):(e=No(n.type,null,r,t,t.mode,o),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&o)){var l=i.memoizedProps;if(n=n.compare,n=n!==null?n:Nr,n(l,r)&&e.ref===t.ref)return Tt(e,t,o)}return t.flags|=1,e=Vt(i,r),e.ref=t.ref,e.return=t,t.child=e}function Ad(e,t,n,r,o){if(e!==null){var i=e.memoizedProps;if(Nr(i,r)&&e.ref===t.ref)if($e=!1,t.pendingProps=r=i,(e.lanes&o)!==0)e.flags&131072&&($e=!0);else return t.lanes=e.lanes,Tt(e,t,o)}return Vl(e,t,n,r,o)}function zd(e,t,n){var r=t.pendingProps,o=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},te(An,qe),qe|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,te(An,qe),qe|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,te(An,qe),qe|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,te(An,qe),qe|=r;return Ae(e,t,o,n),t.child}function Od(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Vl(e,t,n,r,o){var i=He(n)?cn:Ne.current;return i=Mn(t,i),Fn(t,o),n=Hs(e,t,n,r,i,o),r=Vs(),e!==null&&!$e?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,Tt(e,t,o)):(ie&&r&&As(t),t.flags|=1,Ae(e,t,n,o),t.child)}function uu(e,t,n,r,o){if(He(n)){var i=!0;Qo(t)}else i=!1;if(Fn(t,o),t.stateNode===null)Ro(e,t),Td(t,n,r),Wl(t,n,r,o),r=!0;else if(e===null){var l=t.stateNode,a=t.memoizedProps;l.props=a;var u=l.context,c=n.contextType;typeof c=="object"&&c!==null?c=it(c):(c=He(n)?cn:Ne.current,c=Mn(t,c));var f=n.getDerivedStateFromProps,m=typeof f=="function"||typeof l.getSnapshotBeforeUpdate=="function";m||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(a!==r||u!==c)&&ru(t,l,r,c),zt=!1;var y=t.memoizedState;l.state=y,Go(t,r,l,o),u=t.memoizedState,a!==r||y!==u||We.current||zt?(typeof f=="function"&&($l(t,n,f,r),u=t.memoizedState),(a=zt||nu(t,n,a,r,y,u,c))?(m||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount()),typeof l.componentDidMount=="function"&&(t.flags|=4194308)):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=u),l.props=r,l.state=u,l.context=c,r=a):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{l=t.stateNode,ad(e,t),a=t.memoizedProps,c=t.type===t.elementType?a:ut(t.type,a),l.props=c,m=t.pendingProps,y=l.context,u=n.contextType,typeof u=="object"&&u!==null?u=it(u):(u=He(n)?cn:Ne.current,u=Mn(t,u));var S=n.getDerivedStateFromProps;(f=typeof S=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(a!==m||y!==u)&&ru(t,l,r,u),zt=!1,y=t.memoizedState,l.state=y,Go(t,r,l,o);var x=t.memoizedState;a!==m||y!==x||We.current||zt?(typeof S=="function"&&($l(t,n,S,r),x=t.memoizedState),(c=zt||nu(t,n,c,r,y,x,u)||!1)?(f||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(r,x,u),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(r,x,u)),typeof l.componentDidUpdate=="function"&&(t.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof l.componentDidUpdate!="function"||a===e.memoizedProps&&y===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&y===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=x),l.props=r,l.state=x,l.context=u,r=c):(typeof l.componentDidUpdate!="function"||a===e.memoizedProps&&y===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&y===e.memoizedState||(t.flags|=1024),r=!1)}return Ql(e,t,n,r,i,o)}function Ql(e,t,n,r,o,i){Od(e,t);var l=(t.flags&128)!==0;if(!r&&!l)return o&&Ka(t,n,!1),Tt(e,t,i);r=t.stateNode,Lh.current=t;var a=l&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&l?(t.child=$n(t,e.child,null,i),t.child=$n(t,null,a,i)):Ae(e,t,a,i),t.memoizedState=r.state,o&&Ka(t,n,!0),t.child}function Dd(e){var t=e.stateNode;t.pendingContext?qa(e,t.pendingContext,t.pendingContext!==t.context):t.context&&qa(e,t.context,!1),Ms(e,t.containerInfo)}function cu(e,t,n,r,o){return Un(),Os(o),t.flags|=256,Ae(e,t,n,r),t.child}var ql={dehydrated:null,treeContext:null,retryLane:0};function Kl(e){return{baseLanes:e,cachePool:null,transitions:null}}function Ld(e,t,n){var r=t.pendingProps,o=se.current,i=!1,l=(t.flags&128)!==0,a;if((a=l)||(a=e!==null&&e.memoizedState===null?!1:(o&2)!==0),a?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(o|=1),te(se,o&1),e===null)return Ml(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(l=r.children,e=r.fallback,i?(r=t.mode,i=t.child,l={mode:"hidden",children:l},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=l):i=xi(l,r,0,null),e=an(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Kl(n),t.memoizedState=ql,e):Ks(t,l));if(o=e.memoizedState,o!==null&&(a=o.dehydrated,a!==null))return Fh(e,t,l,r,a,o,n);if(i){i=r.fallback,l=t.mode,o=e.child,a=o.sibling;var u={mode:"hidden",children:r.children};return!(l&1)&&t.child!==o?(r=t.child,r.childLanes=0,r.pendingProps=u,t.deletions=null):(r=Vt(o,u),r.subtreeFlags=o.subtreeFlags&14680064),a!==null?i=Vt(a,i):(i=an(i,l,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,l=e.child.memoizedState,l=l===null?Kl(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},i.memoizedState=l,i.childLanes=e.childLanes&~n,t.memoizedState=ql,r}return i=e.child,e=i.sibling,r=Vt(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Ks(e,t){return t=xi({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function fo(e,t,n,r){return r!==null&&Os(r),$n(t,e.child,null,n),e=Ks(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Fh(e,t,n,r,o,i,l){if(n)return t.flags&256?(t.flags&=-257,r=Zi(Error(E(422))),fo(e,t,l,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,o=t.mode,r=xi({mode:"visible",children:r.children},o,0,null),i=an(i,o,l,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&$n(t,e.child,null,l),t.child.memoizedState=Kl(l),t.memoizedState=ql,i);if(!(t.mode&1))return fo(e,t,l,null);if(o.data==="$!"){if(r=o.nextSibling&&o.nextSibling.dataset,r)var a=r.dgst;return r=a,i=Error(E(419)),r=Zi(i,r,void 0),fo(e,t,l,r)}if(a=(l&e.childLanes)!==0,$e||a){if(r=we,r!==null){switch(l&-l){case 4:o=2;break;case 16:o=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}o=o&(r.suspendedLanes|l)?0:o,o!==0&&o!==i.retryLane&&(i.retryLane=o,Rt(e,o),ft(r,e,o,-1))}return ea(),r=Zi(Error(E(421))),fo(e,t,l,r)}return o.data==="$?"?(t.flags|=128,t.child=e.child,t=Xh.bind(null,e),o._reactRetry=t,null):(e=i.treeContext,Ke=Ut(o.nextSibling),Ye=t,ie=!0,dt=null,e!==null&&(tt[nt++]=kt,tt[nt++]=jt,tt[nt++]=dn,kt=e.id,jt=e.overflow,dn=t),t=Ks(t,r.children),t.flags|=4096,t)}function du(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ul(e.return,t,n)}function el(e,t,n,r,o){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:o}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=o)}function Fd(e,t,n){var r=t.pendingProps,o=r.revealOrder,i=r.tail;if(Ae(e,t,r.children,n),r=se.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&du(e,n,t);else if(e.tag===19)du(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(te(se,r),!(t.mode&1))t.memoizedState=null;else switch(o){case"forwards":for(n=t.child,o=null;n!==null;)e=n.alternate,e!==null&&Jo(e)===null&&(o=n),n=n.sibling;n=o,n===null?(o=t.child,t.child=null):(o=n.sibling,n.sibling=null),el(t,!1,o,n,i);break;case"backwards":for(n=null,o=t.child,t.child=null;o!==null;){if(e=o.alternate,e!==null&&Jo(e)===null){t.child=o;break}e=o.sibling,o.sibling=n,n=o,o=e}el(t,!0,n,null,i);break;case"together":el(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Ro(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Tt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),fn|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(E(153));if(t.child!==null){for(e=t.child,n=Vt(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Vt(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Ih(e,t,n){switch(t.tag){case 3:Dd(t),Un();break;case 5:ud(t);break;case 1:He(t.type)&&Qo(t);break;case 4:Ms(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,o=t.memoizedProps.value;te(Yo,r._currentValue),r._currentValue=o;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(te(se,se.current&1),t.flags|=128,null):n&t.child.childLanes?Ld(e,t,n):(te(se,se.current&1),e=Tt(e,t,n),e!==null?e.sibling:null);te(se,se.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Fd(e,t,n);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),te(se,se.current),r)break;return null;case 22:case 23:return t.lanes=0,zd(e,t,n)}return Tt(e,t,n)}var Id,Yl,Bd,Md;Id=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Yl=function(){};Bd=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,on(wt.current);var i=null;switch(n){case"input":o=yl(e,o),r=yl(e,r),i=[];break;case"select":o=ue({},o,{value:void 0}),r=ue({},r,{value:void 0}),i=[];break;case"textarea":o=wl(e,o),r=wl(e,r),i=[];break;default:typeof o.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Ho)}bl(n,r);var l;n=null;for(c in o)if(!r.hasOwnProperty(c)&&o.hasOwnProperty(c)&&o[c]!=null)if(c==="style"){var a=o[c];for(l in a)a.hasOwnProperty(l)&&(n||(n={}),n[l]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(jr.hasOwnProperty(c)?i||(i=[]):(i=i||[]).push(c,null));for(c in r){var u=r[c];if(a=o!=null?o[c]:void 0,r.hasOwnProperty(c)&&u!==a&&(u!=null||a!=null))if(c==="style")if(a){for(l in a)!a.hasOwnProperty(l)||u&&u.hasOwnProperty(l)||(n||(n={}),n[l]="");for(l in u)u.hasOwnProperty(l)&&a[l]!==u[l]&&(n||(n={}),n[l]=u[l])}else n||(i||(i=[]),i.push(c,n)),n=u;else c==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,a=a?a.__html:void 0,u!=null&&a!==u&&(i=i||[]).push(c,u)):c==="children"?typeof u!="string"&&typeof u!="number"||(i=i||[]).push(c,""+u):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(jr.hasOwnProperty(c)?(u!=null&&c==="onScroll"&&re("scroll",e),i||a===u||(i=[])):(i=i||[]).push(c,u))}n&&(i=i||[]).push("style",n);var c=i;(t.updateQueue=c)&&(t.flags|=4)}};Md=function(e,t,n,r){n!==r&&(t.flags|=4)};function or(e,t){if(!ie)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function _e(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags&14680064,r|=o.flags&14680064,o.return=e,o=o.sibling;else for(o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,o.return=e,o=o.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Bh(e,t,n){var r=t.pendingProps;switch(zs(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _e(t),null;case 1:return He(t.type)&&Vo(),_e(t),null;case 3:return r=t.stateNode,Wn(),oe(We),oe(Ne),$s(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(co(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,dt!==null&&(rs(dt),dt=null))),Yl(e,t),_e(t),null;case 5:Us(t);var o=on(Lr.current);if(n=t.type,e!==null&&t.stateNode!=null)Bd(e,t,n,r,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(E(166));return _e(t),null}if(e=on(wt.current),co(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[xt]=t,r[Or]=i,e=(t.mode&1)!==0,n){case"dialog":re("cancel",r),re("close",r);break;case"iframe":case"object":case"embed":re("load",r);break;case"video":case"audio":for(o=0;o<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[xt]=t,e[Or]=r,Id(e,t,!1,!1),t.stateNode=e;e:{switch(l=kl(n,r),n){case"dialog":re("cancel",e),re("close",e),o=r;break;case"iframe":case"object":case"embed":re("load",e),o=r;break;case"video":case"audio":for(o=0;oVn&&(t.flags|=128,r=!0,or(i,!1),t.lanes=4194304)}else{if(!r)if(e=Jo(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),or(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!ie)return _e(t),null}else 2*he()-i.renderingStartTime>Vn&&n!==1073741824&&(t.flags|=128,r=!0,or(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=he(),t.sibling=null,n=se.current,te(se,r?n&1|2:n&1),t):(_e(t),null);case 22:case 23:return Zs(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?qe&1073741824&&(_e(t),t.subtreeFlags&6&&(t.flags|=8192)):_e(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function Mh(e,t){switch(zs(t),t.tag){case 1:return He(t.type)&&Vo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wn(),oe(We),oe(Ne),$s(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Us(t),null;case 13:if(oe(se),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Un()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return oe(se),null;case 4:return Wn(),null;case 10:return Fs(t.type._context),null;case 22:case 23:return Zs(),null;case 24:return null;default:return null}}var ho=!1,Te=!1,Uh=typeof WeakSet=="function"?WeakSet:Set,z=null;function Nn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ce(e,t,r)}else n.current=null}function Xl(e,t,n){try{n()}catch(r){ce(e,t,r)}}var pu=!1;function $h(e,t){if(zl=Uo,e=Vc(),Ns(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,a=-1,u=-1,c=0,f=0,m=e,y=null;t:for(;;){for(var S;m!==n||o!==0&&m.nodeType!==3||(a=l+o),m!==i||r!==0&&m.nodeType!==3||(u=l+r),m.nodeType===3&&(l+=m.nodeValue.length),(S=m.firstChild)!==null;)y=m,m=S;for(;;){if(m===e)break t;if(y===n&&++c===o&&(a=l),y===i&&++f===r&&(u=l),(S=m.nextSibling)!==null)break;m=y,y=m.parentNode}m=S}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ol={focusedElem:e,selectionRange:n},Uo=!1,z=t;z!==null;)if(t=z,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,z=e;else for(;z!==null;){t=z;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var v=x.memoizedProps,g=x.memoizedState,p=t.stateNode,d=p.getSnapshotBeforeUpdate(t.elementType===t.type?v:ut(t.type,v),g);p.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(b){ce(t,t.return,b)}if(e=t.sibling,e!==null){e.return=t.return,z=e;break}z=t.return}return x=pu,pu=!1,x}function wr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var i=o.destroy;o.destroy=void 0,i!==void 0&&Xl(t,n,i)}o=o.next}while(o!==r)}}function gi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Gl(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Ud(e){var t=e.alternate;t!==null&&(e.alternate=null,Ud(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[xt],delete t[Or],delete t[Fl],delete t[jh],delete t[Ch])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function $d(e){return e.tag===5||e.tag===3||e.tag===4}function fu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||$d(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Jl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ho));else if(r!==4&&(e=e.child,e!==null))for(Jl(e,t,n),e=e.sibling;e!==null;)Jl(e,t,n),e=e.sibling}function Zl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Zl(e,t,n),e=e.sibling;e!==null;)Zl(e,t,n),e=e.sibling}var be=null,ct=!1;function Nt(e,t,n){for(n=n.child;n!==null;)Wd(e,t,n),n=n.sibling}function Wd(e,t,n){if(vt&&typeof vt.onCommitFiberUnmount=="function")try{vt.onCommitFiberUnmount(ai,n)}catch{}switch(n.tag){case 5:Te||Nn(n,t);case 6:var r=be,o=ct;be=null,Nt(e,t,n),be=r,ct=o,be!==null&&(ct?(e=be,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):be.removeChild(n.stateNode));break;case 18:be!==null&&(ct?(e=be,n=n.stateNode,e.nodeType===8?qi(e.parentNode,n):e.nodeType===1&&qi(e,n),Tr(e)):qi(be,n.stateNode));break;case 4:r=be,o=ct,be=n.stateNode.containerInfo,ct=!0,Nt(e,t,n),be=r,ct=o;break;case 0:case 11:case 14:case 15:if(!Te&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var i=o,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&Xl(n,t,l),o=o.next}while(o!==r)}Nt(e,t,n);break;case 1:if(!Te&&(Nn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){ce(n,t,a)}Nt(e,t,n);break;case 21:Nt(e,t,n);break;case 22:n.mode&1?(Te=(r=Te)||n.memoizedState!==null,Nt(e,t,n),Te=r):Nt(e,t,n);break;default:Nt(e,t,n)}}function hu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Uh),t.forEach(function(r){var o=Gh.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function at(e,t){var n=t.deletions;if(n!==null)for(var r=0;ro&&(o=l),r&=~i}if(r=o,r=he()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Hh(r/1960))-r,10e?16:e,Ft===null)var r=!1;else{if(e=Ft,Ft=null,ri=0,Y&6)throw Error(E(331));var o=Y;for(Y|=4,z=e.current;z!==null;){var i=z,l=i.child;if(z.flags&16){var a=i.deletions;if(a!==null){for(var u=0;uhe()-Gs?sn(e,0):Xs|=n),Ve(e,t)}function Gd(e,t){t===0&&(e.mode&1?(t=oo,oo<<=1,!(oo&130023424)&&(oo=4194304)):t=1);var n=ze();e=Rt(e,t),e!==null&&($r(e,t,n),Ve(e,n))}function Xh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gd(e,n)}function Gh(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),Gd(e,n)}var Jd;Jd=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||We.current)$e=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return $e=!1,Ih(e,t,n);$e=!!(e.flags&131072)}else $e=!1,ie&&t.flags&1048576&&nd(t,Ko,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ro(e,t),e=t.pendingProps;var o=Mn(t,Ne.current);Fn(t,n),o=Hs(null,t,r,e,o,n);var i=Vs();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,He(r)?(i=!0,Qo(t)):i=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,Bs(t),o.updater=mi,t.stateNode=o,o._reactInternals=t,Wl(t,r,e,n),t=Ql(null,t,r,!0,i,n)):(t.tag=0,ie&&i&&As(t),Ae(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ro(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=Zh(r),e=ut(r,e),o){case 0:t=Vl(null,t,r,e,n);break e;case 1:t=uu(null,t,r,e,n);break e;case 11:t=su(null,t,r,e,n);break e;case 14:t=au(null,t,r,ut(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),Vl(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),uu(e,t,r,o,n);case 3:e:{if(Dd(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,o=i.element,ad(e,t),Go(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){o=Hn(Error(E(423)),t),t=cu(e,t,r,n,o);break e}else if(r!==o){o=Hn(Error(E(424)),t),t=cu(e,t,r,n,o);break e}else for(Ke=Ut(t.stateNode.containerInfo.firstChild),Ye=t,ie=!0,dt=null,n=ld(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Un(),r===o){t=Tt(e,t,n);break e}Ae(e,t,r,n)}t=t.child}return t;case 5:return ud(t),e===null&&Ml(t),r=t.type,o=t.pendingProps,i=e!==null?e.memoizedProps:null,l=o.children,Dl(r,o)?l=null:i!==null&&Dl(r,i)&&(t.flags|=32),Od(e,t),Ae(e,t,l,n),t.child;case 6:return e===null&&Ml(t),null;case 13:return Ld(e,t,n);case 4:return Ms(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=$n(t,null,r,n):Ae(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),su(e,t,r,o,n);case 7:return Ae(e,t,t.pendingProps,n),t.child;case 8:return Ae(e,t,t.pendingProps.children,n),t.child;case 12:return Ae(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,i=t.memoizedProps,l=o.value,te(Yo,r._currentValue),r._currentValue=l,i!==null)if(ht(i.value,l)){if(i.children===o.children&&!We.current){t=Tt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var a=i.dependencies;if(a!==null){l=i.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=Ct(-1,n&-n),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var f=c.pending;f===null?u.next=u:(u.next=f.next,f.next=u),c.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),Ul(i.return,n,t),a.lanes|=n;break}u=u.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,a=l.alternate,a!==null&&(a.lanes|=n),Ul(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}Ae(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,Fn(t,n),o=it(o),r=r(o),t.flags|=1,Ae(e,t,r,n),t.child;case 14:return r=t.type,o=ut(r,t.pendingProps),o=ut(r.type,o),au(e,t,r,o,n);case 15:return Ad(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),Ro(e,t),t.tag=1,He(r)?(e=!0,Qo(t)):e=!1,Fn(t,n),Td(t,r,o),Wl(t,r,o,n),Ql(null,t,r,!0,e,n);case 19:return Fd(e,t,n);case 22:return zd(e,t,n)}throw Error(E(156,t.tag))};function Zd(e,t){return Ec(e,t)}function Jh(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function rt(e,t,n,r){return new Jh(e,t,n,r)}function ta(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Zh(e){if(typeof e=="function")return ta(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ws)return 11;if(e===Ss)return 14}return 2}function Vt(e,t){var n=e.alternate;return n===null?(n=rt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function No(e,t,n,r,o,i){var l=2;if(r=e,typeof e=="function")ta(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case bn:return an(n.children,o,i,t);case vs:l=8,o|=8;break;case fl:return e=rt(12,n,t,o|2),e.elementType=fl,e.lanes=i,e;case hl:return e=rt(13,n,t,o),e.elementType=hl,e.lanes=i,e;case ml:return e=rt(19,n,t,o),e.elementType=ml,e.lanes=i,e;case uc:return xi(n,o,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case sc:l=10;break e;case ac:l=9;break e;case ws:l=11;break e;case Ss:l=14;break e;case At:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=rt(l,n,t,o),t.elementType=e,t.type=r,t.lanes=i,t}function an(e,t,n,r){return e=rt(7,e,r,t),e.lanes=n,e}function xi(e,t,n,r){return e=rt(22,e,r,t),e.elementType=uc,e.lanes=n,e.stateNode={isHidden:!1},e}function tl(e,t,n){return e=rt(6,e,null,t),e.lanes=n,e}function nl(e,t,n){return t=rt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function em(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Li(0),this.expirationTimes=Li(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Li(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function na(e,t,n,r,o,i,l,a,u){return e=new em(e,t,n,a,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=rt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Bs(i),e}function tm(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(rp)}catch(e){console.error(e)}}rp(),rc.exports=Ge;var lm=rc.exports,bu=lm;dl.createRoot=bu.createRoot,dl.hydrateRoot=bu.hydrateRoot;function op(e,t){return function(){return e.apply(t,arguments)}}const{toString:sm}=Object.prototype,{getPrototypeOf:ki}=Object,{iterator:ji,toStringTag:ip}=Symbol,Ci=(e=>t=>{const n=sm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),mt=e=>(e=e.toLowerCase(),t=>Ci(t)===e),Ei=e=>t=>typeof t===e,{isArray:Xn}=Array,Qn=Ei("undefined");function Qr(e){return e!==null&&!Qn(e)&&e.constructor!==null&&!Qn(e.constructor)&&Qe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const lp=mt("ArrayBuffer");function am(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&lp(e.buffer),t}const um=Ei("string"),Qe=Ei("function"),sp=Ei("number"),qr=e=>e!==null&&typeof e=="object",cm=e=>e===!0||e===!1,Ao=e=>{if(Ci(e)!=="object")return!1;const t=ki(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ip in e)&&!(ji in e)},dm=e=>{if(!qr(e)||Qr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},pm=mt("Date"),fm=mt("File"),hm=e=>!!(e&&typeof e.uri<"u"),mm=e=>e&&typeof e.getParts<"u",gm=mt("Blob"),ym=mt("FileList"),xm=e=>qr(e)&&Qe(e.pipe);function vm(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const ku=vm(),ju=typeof ku.FormData<"u"?ku.FormData:void 0,wm=e=>{if(!e)return!1;if(ju&&e instanceof ju)return!0;const t=ki(e);if(!t||t===Object.prototype||!Qe(e.append))return!1;const n=Ci(e);return n==="formdata"||n==="object"&&Qe(e.toString)&&e.toString()==="[object FormData]"},Sm=mt("URLSearchParams"),[bm,km,jm,Cm]=["ReadableStream","Request","Response","Headers"].map(mt),Em=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Kr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Xn(e))for(r=0,o=e.length;r0;)if(o=n[r],t===o.toLowerCase())return o;return null}const ln=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,up=e=>!Qn(e)&&e!==ln;function os(...e){const{caseless:t,skipUndefined:n}=up(this)&&this||{},r={},o=(i,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const a=t&&ap(r,l)||l,u=is(r,a)?r[a]:void 0;Ao(u)&&Ao(i)?r[a]=os(u,i):Ao(i)?r[a]=os({},i):Xn(i)?r[a]=i.slice():(!n||!Qn(i))&&(r[a]=i)};for(let i=0,l=e.length;i(Kr(t,(o,i)=>{n&&Qe(o)?Object.defineProperty(e,i,{__proto__:null,value:op(o,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{__proto__:null,value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),Rm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Tm=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},Pm=(e,t,n,r)=>{let o,i,l;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)l=o[i],(!r||r(l,e,t))&&!a[l]&&(t[l]=e[l],a[l]=!0);e=n!==!1&&ki(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Nm=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Am=e=>{if(!e)return null;if(Xn(e))return e;let t=e.length;if(!sp(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},zm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ki(Uint8Array)),Om=(e,t)=>{const r=(e&&e[ji]).call(e);let o;for(;(o=r.next())&&!o.done;){const i=o.value;t.call(e,i[0],i[1])}},Dm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Lm=mt("HTMLFormElement"),Fm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),is=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Im=mt("RegExp"),cp=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Kr(n,(o,i)=>{let l;(l=t(o,i,e))!==!1&&(r[i]=l||o)}),Object.defineProperties(e,r)},Bm=e=>{cp(e,(t,n)=>{if(Qe(e)&&["arguments","caller","callee"].includes(n))return!1;const r=e[n];if(Qe(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Mm=(e,t)=>{const n={},r=o=>{o.forEach(i=>{n[i]=!0})};return Xn(e)?r(e):r(String(e).split(t)),n},Um=()=>{},$m=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Wm(e){return!!(e&&Qe(e.append)&&e[ip]==="FormData"&&e[ji])}const Hm=e=>{const t=new WeakSet,n=r=>{if(qr(r)){if(t.has(r))return;if(Qr(r))return r;if(!("toJSON"in r)){t.add(r);const o=Xn(r)?[]:{};return Kr(r,(i,l)=>{const a=n(i);!Qn(a)&&(o[l]=a)}),t.delete(r),o}}return r};return n(e)},Vm=mt("AsyncFunction"),Qm=e=>e&&(qr(e)||Qe(e))&&Qe(e.then)&&Qe(e.catch),dp=((e,t)=>e?setImmediate:t?((n,r)=>(ln.addEventListener("message",({source:o,data:i})=>{o===ln&&i===n&&r.length&&r.shift()()},!1),o=>{r.push(o),ln.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Qe(ln.postMessage)),qm=typeof queueMicrotask<"u"?queueMicrotask.bind(ln):typeof process<"u"&&process.nextTick||dp,Km=e=>e!=null&&Qe(e[ji]),w={isArray:Xn,isArrayBuffer:lp,isBuffer:Qr,isFormData:wm,isArrayBufferView:am,isString:um,isNumber:sp,isBoolean:cm,isObject:qr,isPlainObject:Ao,isEmptyObject:dm,isReadableStream:bm,isRequest:km,isResponse:jm,isHeaders:Cm,isUndefined:Qn,isDate:pm,isFile:fm,isReactNativeBlob:hm,isReactNative:mm,isBlob:gm,isRegExp:Im,isFunction:Qe,isStream:xm,isURLSearchParams:Sm,isTypedArray:zm,isFileList:ym,forEach:Kr,merge:os,extend:_m,trim:Em,stripBOM:Rm,inherits:Tm,toFlatObject:Pm,kindOf:Ci,kindOfTest:mt,endsWith:Nm,toArray:Am,forEachEntry:Om,matchAll:Dm,isHTMLForm:Lm,hasOwnProperty:is,hasOwnProp:is,reduceDescriptors:cp,freezeMethods:Bm,toObjectSet:Mm,toCamelCase:Fm,noop:Um,toFiniteNumber:$m,findKey:ap,global:ln,isContextDefined:up,isSpecCompliantForm:Wm,toJSONObject:Hm,isAsyncFn:Vm,isThenable:Qm,setImmediate:dp,asap:qm,isIterable:Km},Ym=w.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Xm=e=>{const t={};let n,r,o;return e&&e.split(` +`).forEach(function(l){o=l.indexOf(":"),n=l.substring(0,o).trim().toLowerCase(),r=l.substring(o+1).trim(),!(!n||t[n]&&Ym[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t};function Gm(e){let t=0,n=e.length;for(;tt;){const r=e.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return t===0&&n===e.length?e:e.slice(t,n)}const Jm=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),Zm=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function la(e,t){return w.isArray(e)?e.map(n=>la(n,t)):Gm(String(e).replace(t,""))}const eg=e=>la(e,Jm),tg=e=>la(e,Zm);function pp(e){const t=Object.create(null);return w.forEach(e.toJSON(),(n,r)=>{t[r]=tg(n)}),t}const Cu=Symbol("internals");function lr(e){return e&&String(e).trim().toLowerCase()}function zo(e){return e===!1||e==null?e:w.isArray(e)?e.map(zo):eg(String(e))}function ng(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const rg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function rl(e,t,n,r,o){if(w.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!w.isString(t)){if(w.isString(r))return t.indexOf(r)!==-1;if(w.isRegExp(r))return r.test(t)}}function og(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function ig(e,t){const n=w.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(o,i,l){return this[r].call(this,t,o,i,l)},configurable:!0})})}let Oe=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function i(a,u,c){const f=lr(u);if(!f)throw new Error("header name must be a non-empty string");const m=w.findKey(o,f);(!m||o[m]===void 0||c===!0||c===void 0&&o[m]!==!1)&&(o[m||u]=zo(a))}const l=(a,u)=>w.forEach(a,(c,f)=>i(c,f,u));if(w.isPlainObject(t)||t instanceof this.constructor)l(t,n);else if(w.isString(t)&&(t=t.trim())&&!rg(t))l(Xm(t),n);else if(w.isObject(t)&&w.isIterable(t)){let a={},u,c;for(const f of t){if(!w.isArray(f))throw TypeError("Object iterator must return a key-value pair");a[c=f[0]]=(u=a[c])?w.isArray(u)?[...u,f[1]]:[u,f[1]]:f[1]}l(a,n)}else t!=null&&i(n,t,r);return this}get(t,n){if(t=lr(t),t){const r=w.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return ng(o);if(w.isFunction(n))return n.call(this,o,r);if(w.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=lr(t),t){const r=w.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||rl(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function i(l){if(l=lr(l),l){const a=w.findKey(r,l);a&&(!n||rl(r,r[a],a,n))&&(delete r[a],o=!0)}}return w.isArray(t)?t.forEach(i):i(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const i=n[r];(!t||rl(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){const n=this,r={};return w.forEach(this,(o,i)=>{const l=w.findKey(r,i);if(l){n[l]=zo(o),delete n[i];return}const a=t?og(i):String(i).trim();a!==i&&delete n[i],n[a]=zo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return w.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&w.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` +`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Cu]=this[Cu]={accessors:{}}).accessors,o=this.prototype;function i(l){const a=lr(l);r[a]||(ig(o,l),r[a]=!0)}return w.isArray(t)?t.forEach(i):i(t),this}};Oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);w.reduceDescriptors(Oe.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});w.freezeMethods(Oe);const lg="[REDACTED ****]";function sg(e){if(w.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(w.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}function ag(e,t){const n=new Set(t.map(i=>String(i).toLowerCase())),r=[],o=i=>{if(i===null||typeof i!="object"||w.isBuffer(i))return i;if(r.indexOf(i)!==-1)return;i instanceof Oe&&(i=i.toJSON()),r.push(i);let l;if(w.isArray(i))l=[],i.forEach((a,u)=>{const c=o(a);w.isUndefined(c)||(l[u]=c)});else{if(!w.isPlainObject(i)&&sg(i))return r.pop(),i;l=Object.create(null);for(const[a,u]of Object.entries(i)){const c=n.has(a.toLowerCase())?lg:o(u);w.isUndefined(c)||(l[a]=c)}}return r.pop(),l};return o(e)}let O=class fp extends Error{static from(t,n,r,o,i,l){const a=new fp(t.message,n||t.code,r,o,i);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),l&&Object.assign(a,l),a}constructor(t,n,r,o,i){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){const t=this.config,n=t&&w.hasOwnProp(t,"redact")?t.redact:void 0,r=w.isArray(n)&&n.length>0?ag(t,n):w.toJSONObject(t);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:r,code:this.code,status:this.status}}};O.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";O.ERR_BAD_OPTION="ERR_BAD_OPTION";O.ECONNABORTED="ECONNABORTED";O.ETIMEDOUT="ETIMEDOUT";O.ECONNREFUSED="ECONNREFUSED";O.ERR_NETWORK="ERR_NETWORK";O.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";O.ERR_DEPRECATED="ERR_DEPRECATED";O.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";O.ERR_BAD_REQUEST="ERR_BAD_REQUEST";O.ERR_CANCELED="ERR_CANCELED";O.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";O.ERR_INVALID_URL="ERR_INVALID_URL";O.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const ug=null;function ls(e){return w.isPlainObject(e)||w.isArray(e)}function hp(e){return w.endsWith(e,"[]")?e.slice(0,-2):e}function ol(e,t,n){return e?e.concat(t).map(function(o,i){return o=hp(o),!n&&i?"["+o+"]":o}).join(n?".":""):t}function cg(e){return w.isArray(e)&&!e.some(ls)}const dg=w.toFlatObject(w,{},null,function(t){return/^is[A-Z]/.test(t)});function _i(e,t,n){if(!w.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=w.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,p){return!w.isUndefined(p[g])});const r=n.metaTokens,o=n.visitor||m,i=n.dots,l=n.indexes,a=n.Blob||typeof Blob<"u"&&Blob,u=n.maxDepth===void 0?100:n.maxDepth,c=a&&w.isSpecCompliantForm(t);if(!w.isFunction(o))throw new TypeError("visitor must be a function");function f(v){if(v===null)return"";if(w.isDate(v))return v.toISOString();if(w.isBoolean(v))return v.toString();if(!c&&w.isBlob(v))throw new O("Blob is not supported. Use a Buffer instead.");return w.isArrayBuffer(v)||w.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function m(v,g,p){let d=v;if(w.isReactNative(t)&&w.isReactNativeBlob(v))return t.append(ol(p,g,i),f(v)),!1;if(v&&!p&&typeof v=="object"){if(w.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(w.isArray(v)&&cg(v)||(w.isFileList(v)||w.endsWith(g,"[]"))&&(d=w.toArray(v)))return g=hp(g),d.forEach(function(b,C){!(w.isUndefined(b)||b===null)&&t.append(l===!0?ol([g],C,i):l===null?g:g+"[]",f(b))}),!1}return ls(v)?!0:(t.append(ol(p,g,i),f(v)),!1)}const y=[],S=Object.assign(dg,{defaultVisitor:m,convertValue:f,isVisitable:ls});function x(v,g,p=0){if(!w.isUndefined(v)){if(p>u)throw new O("Object is too deeply nested ("+p+" levels). Max depth: "+u,O.ERR_FORM_DATA_DEPTH_EXCEEDED);if(y.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));y.push(v),w.forEach(v,function(h,b){(!(w.isUndefined(h)||h===null)&&o.call(t,h,w.isString(b)?b.trim():b,g,S))===!0&&x(h,g?g.concat(b):[b],p+1)}),y.pop()}}if(!w.isObject(e))throw new TypeError("data must be an object");return x(e),t}function Eu(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(r){return t[r]})}function sa(e,t){this._pairs=[],e&&_i(e,this,t)}const mp=sa.prototype;mp.append=function(t,n){this._pairs.push([t,n])};mp.toString=function(t){const n=t?function(r){return t.call(this,r,Eu)}:Eu;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function pg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function gp(e,t,n){if(!t)return e;const r=n&&n.encode||pg,o=w.isFunction(n)?{serialize:n}:n,i=o&&o.serialize;let l;if(i?l=i(t,o):l=w.isURLSearchParams(t)?t.toString():new sa(t,o).toString(r),l){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+l}return e}class _u{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){w.forEach(this.handlers,function(r){r!==null&&t(r)})}}const aa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},fg=typeof URLSearchParams<"u"?URLSearchParams:sa,hg=typeof FormData<"u"?FormData:null,mg=typeof Blob<"u"?Blob:null,gg={isBrowser:!0,classes:{URLSearchParams:fg,FormData:hg,Blob:mg},protocols:["http","https","file","blob","url","data"]},ua=typeof window<"u"&&typeof document<"u",ss=typeof navigator=="object"&&navigator||void 0,yg=ua&&(!ss||["ReactNative","NativeScript","NS"].indexOf(ss.product)<0),xg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",vg=ua&&window.location.href||"http://localhost",wg=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ua,hasStandardBrowserEnv:yg,hasStandardBrowserWebWorkerEnv:xg,navigator:ss,origin:vg},Symbol.toStringTag,{value:"Module"})),Pe={...wg,...gg};function Sg(e,t){return _i(e,new Pe.classes.URLSearchParams,{visitor:function(n,r,o,i){return Pe.isNode&&w.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function bg(e){return w.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function kg(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r=n.length;return l=!l&&w.isArray(o)?o.length:l,u?(w.hasOwnProp(o,l)?o[l]=w.isArray(o[l])?o[l].concat(r):[o[l],r]:o[l]=r,!a):((!w.hasOwnProp(o,l)||!w.isObject(o[l]))&&(o[l]=[]),t(n,r,o[l],i)&&w.isArray(o[l])&&(o[l]=kg(o[l])),!a)}if(w.isFormData(e)&&w.isFunction(e.entries)){const n={};return w.forEachEntry(e,(r,o)=>{t(bg(r),o,n,0)}),n}return null}const wn=(e,t)=>e!=null&&w.hasOwnProp(e,t)?e[t]:void 0;function jg(e,t,n){if(w.isString(e))try{return(t||JSON.parse)(e),w.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Yr={transitional:aa,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,i=w.isObject(t);if(i&&w.isHTMLForm(t)&&(t=new FormData(t)),w.isFormData(t))return o?JSON.stringify(yp(t)):t;if(w.isArrayBuffer(t)||w.isBuffer(t)||w.isStream(t)||w.isFile(t)||w.isBlob(t)||w.isReadableStream(t))return t;if(w.isArrayBufferView(t))return t.buffer;if(w.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){const u=wn(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Sg(t,u).toString();if((a=w.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=wn(this,"env"),f=c&&c.FormData;return _i(a?{"files[]":t}:t,f&&new f,u)}}return i||o?(n.setContentType("application/json",!1),jg(t)):t}],transformResponse:[function(t){const n=wn(this,"transitional")||Yr.transitional,r=n&&n.forcedJSONParsing,o=wn(this,"responseType"),i=o==="json";if(w.isResponse(t)||w.isReadableStream(t))return t;if(t&&w.isString(t)&&(r&&!o||i)){const a=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(t,wn(this,"parseReviver"))}catch(u){if(a)throw u.name==="SyntaxError"?O.from(u,O.ERR_BAD_RESPONSE,this,null,wn(this,"response")):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Pe.classes.FormData,Blob:Pe.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};w.forEach(["delete","get","head","post","put","patch","query"],e=>{Yr.headers[e]={}});function il(e,t){const n=this||Yr,r=t||n,o=Oe.from(r.headers);let i=r.data;return w.forEach(e,function(a){i=a.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function xp(e){return!!(e&&e.__CANCEL__)}let Xr=class extends O{constructor(t,n,r){super(t??"canceled",O.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function vp(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new O("Request failed with status code "+n.status,n.status>=400&&n.status<500?O.ERR_BAD_REQUEST:O.ERR_BAD_RESPONSE,n.config,n.request,n))}function Cg(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function Eg(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,i=0,l;return t=t!==void 0?t:1e3,function(u){const c=Date.now(),f=r[i];l||(l=c),n[o]=u,r[o]=c;let m=i,y=0;for(;m!==o;)y+=n[m++],m=m%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-l{n=f,o=null,i&&(clearTimeout(i),i=null),e(...c)};return[(...c)=>{const f=Date.now(),m=f-n;m>=r?l(c,f):(o=c,i||(i=setTimeout(()=>{i=null,l(o)},r-m)))},()=>o&&l(o)]}const li=(e,t,n=3)=>{let r=0;const o=Eg(50,250);return _g(i=>{if(!i||typeof i.loaded!="number")return;const l=i.loaded,a=i.lengthComputable?i.total:void 0,u=a!=null?Math.min(l,a):l,c=Math.max(0,u-r),f=o(c);r=Math.max(r,u);const m={loaded:u,total:a,progress:a?u/a:void 0,bytes:c,rate:f||void 0,estimated:f&&a?(a-u)/f:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(m)},n)},Ru=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Tu=e=>(...t)=>w.asap(()=>e(...t)),Rg=Pe.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Pe.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Pe.origin),Pe.navigator&&/(msie|trident)/i.test(Pe.navigator.userAgent)):()=>!0,Tg=Pe.hasStandardBrowserEnv?{write(e,t,n,r,o,i,l){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];w.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),w.isString(r)&&a.push(`path=${r}`),w.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),w.isString(l)&&a.push(`SameSite=${l}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.split(";");for(let n=0;ne instanceof Oe?{...e}:e;function mn(e,t){t=t||{};const n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(c,f,m,y){return w.isPlainObject(c)&&w.isPlainObject(f)?w.merge.call({caseless:y},c,f):w.isPlainObject(f)?w.merge({},f):w.isArray(f)?f.slice():f}function o(c,f,m,y){if(w.isUndefined(f)){if(!w.isUndefined(c))return r(void 0,c,m,y)}else return r(c,f,m,y)}function i(c,f){if(!w.isUndefined(f))return r(void 0,f)}function l(c,f){if(w.isUndefined(f)){if(!w.isUndefined(c))return r(void 0,c)}else return r(void 0,f)}function a(c,f,m){if(w.hasOwnProp(t,m))return r(c,f);if(w.hasOwnProp(e,m))return r(void 0,c)}const u={url:i,method:i,data:i,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,withXSRFToken:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,beforeRedirect:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,allowedSocketPaths:l,responseEncoding:l,validateStatus:a,headers:(c,f,m)=>o(Pu(c),Pu(f),m,!0)};return w.forEach(Object.keys({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;const m=w.hasOwnProp(u,f)?u[f]:o,y=w.hasOwnProp(e,f)?e[f]:void 0,S=w.hasOwnProp(t,f)?t[f]:void 0,x=m(y,S,f);w.isUndefined(x)&&m!==a||(n[f]=x)}),n}const Ag=["content-type","content-length"];function zg(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t).forEach(([r,o])=>{Ag.includes(r.toLowerCase())&&e.set(r,o)})}const Og=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),Sp=e=>{const t=mn({},e),n=y=>w.hasOwnProp(t,y)?t[y]:void 0,r=n("data");let o=n("withXSRFToken");const i=n("xsrfHeaderName"),l=n("xsrfCookieName");let a=n("headers");const u=n("auth"),c=n("baseURL"),f=n("allowAbsoluteUrls"),m=n("url");if(t.headers=a=Oe.from(a),t.url=gp(wp(c,m,f),e.params,e.paramsSerializer),u&&a.set("Authorization","Basic "+btoa((u.username||"")+":"+(u.password?Og(u.password):""))),w.isFormData(r)&&(Pe.hasStandardBrowserEnv||Pe.hasStandardBrowserWebWorkerEnv?a.setContentType(void 0):w.isFunction(r.getHeaders)&&zg(a,r.getHeaders(),n("formDataHeaderPolicy"))),Pe.hasStandardBrowserEnv&&(w.isFunction(o)&&(o=o(t)),o===!0||o==null&&Rg(t.url))){const S=i&&l&&Tg.read(l);S&&a.set(i,S)}return t},Dg=typeof XMLHttpRequest<"u",Lg=Dg&&function(e){return new Promise(function(n,r){const o=Sp(e);let i=o.data;const l=Oe.from(o.headers).normalize();let{responseType:a,onUploadProgress:u,onDownloadProgress:c}=o,f,m,y,S,x;function v(){S&&S(),x&&x(),o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function p(){if(!g)return;const h=Oe.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:h,config:e,request:g};vp(function(T){n(T),v()},function(T){r(T),v()},C),g=null}"onloadend"in g?g.onloadend=p:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.startsWith("file:"))||setTimeout(p)},g.onabort=function(){g&&(r(new O("Request aborted",O.ECONNABORTED,e,g)),v(),g=null)},g.onerror=function(b){const C=b&&b.message?b.message:"Network Error",j=new O(C,O.ERR_NETWORK,e,g);j.event=b||null,r(j),v(),g=null},g.ontimeout=function(){let b=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||aa;o.timeoutErrorMessage&&(b=o.timeoutErrorMessage),r(new O(b,C.clarifyTimeoutError?O.ETIMEDOUT:O.ECONNABORTED,e,g)),v(),g=null},i===void 0&&l.setContentType(null),"setRequestHeader"in g&&w.forEach(pp(l),function(b,C){g.setRequestHeader(C,b)}),w.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),c&&([y,x]=li(c,!0),g.addEventListener("progress",y)),u&&g.upload&&([m,S]=li(u),g.upload.addEventListener("progress",m),g.upload.addEventListener("loadend",S)),(o.cancelToken||o.signal)&&(f=h=>{g&&(r(!h||h.type?new Xr(null,e,g):h),g.abort(),v(),g=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const d=Cg(o.url);if(d&&!Pe.protocols.includes(d)){r(new O("Unsupported protocol "+d+":",O.ERR_BAD_REQUEST,e));return}g.send(i||null)})},Fg=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;const n=new AbortController;let r=!1;const o=function(u){if(!r){r=!0,l();const c=u instanceof Error?u:this.reason;n.abort(c instanceof O?c:new Xr(c instanceof Error?c.message:c))}};let i=t&&setTimeout(()=>{i=null,o(new O(`timeout of ${t}ms exceeded`,O.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:a}=n;return a.unsubscribe=()=>w.asap(l),a},Ig=function*(e,t){let n=e.byteLength;if(n{const o=Bg(e,t);let i=0,l,a=u=>{l||(l=!0,r&&r(u))};return new ReadableStream({async pull(u){try{const{done:c,value:f}=await o.next();if(c){a(),u.close();return}let m=f.byteLength;if(n){let y=i+=m;n(y)}u.enqueue(new Uint8Array(f))}catch(c){throw a(c),c}},cancel(u){return a(u),o.return()}},{highWaterMark:2})};function Ug(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;const t=e.indexOf(",");if(t<0)return 0;const n=e.slice(5,t),r=e.slice(t+1);if(/;base64/i.test(n)){let l=r.length;const a=r.length;for(let S=0;S=48&&x<=57||x>=65&&x<=70||x>=97&&x<=102)&&(v>=48&&v<=57||v>=65&&v<=70||v>=97&&v<=102)&&(l-=2,S+=2)}let u=0,c=a-1;const f=S=>S>=2&&r.charCodeAt(S-2)===37&&r.charCodeAt(S-1)===51&&(r.charCodeAt(S)===68||r.charCodeAt(S)===100);c>=0&&(r.charCodeAt(c)===61?(u++,c--):f(c)&&(u++,c-=3)),u===1&&c>=0&&(r.charCodeAt(c)===61||f(c))&&u++;const y=Math.floor(l/4)*3-(u||0);return y>0?y:0}if(typeof Buffer<"u"&&typeof Buffer.byteLength=="function")return Buffer.byteLength(r,"utf8");let i=0;for(let l=0,a=r.length;l=55296&&u<=56319&&l+1=56320&&c<=57343?(i+=4,l++):i+=3}else i+=3}return i}const ca="1.16.1",Au=64*1024,{isFunction:yo}=w,zu=(e,...t)=>{try{return!!e(...t)}catch{return!1}},$g=e=>{const t=w.global!==void 0&&w.global!==null?w.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=w.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:o,Request:i,Response:l}=e,a=o?yo(o):typeof fetch=="function",u=yo(i),c=yo(l);if(!a)return!1;const f=a&&yo(n),m=a&&(typeof r=="function"?(p=>d=>p.encode(d))(new r):async p=>new Uint8Array(await new i(p).arrayBuffer())),y=u&&f&&zu(()=>{let p=!1;const d=new i(Pe.origin,{body:new n,method:"POST",get duplex(){return p=!0,"half"}}),h=d.headers.has("Content-Type");return d.body!=null&&d.body.cancel(),p&&!h}),S=c&&f&&zu(()=>w.isReadableStream(new l("").body)),x={stream:S&&(p=>p.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!x[p]&&(x[p]=(d,h)=>{let b=d&&d[p];if(b)return b.call(d);throw new O(`Response type '${p}' is not supported`,O.ERR_NOT_SUPPORT,h)})});const v=async p=>{if(p==null)return 0;if(w.isBlob(p))return p.size;if(w.isSpecCompliantForm(p))return(await new i(Pe.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(w.isArrayBufferView(p)||w.isArrayBuffer(p))return p.byteLength;if(w.isURLSearchParams(p)&&(p=p+""),w.isString(p))return(await m(p)).byteLength},g=async(p,d)=>{const h=w.toFiniteNumber(p.getContentLength());return h??v(d)};return async p=>{let{url:d,method:h,data:b,signal:C,cancelToken:j,timeout:T,onDownloadProgress:_,onUploadProgress:Q,responseType:U,headers:X,withCredentials:H="same-origin",fetchOptions:A,maxContentLength:L,maxBodyLength:R}=Sp(p);const P=w.isNumber(L)&&L>-1,$=w.isNumber(R)&&R>-1;let N=o||fetch;U=U?(U+"").toLowerCase():"text";let I=Fg([C,j&&j.toAbortSignal()],T),B=null;const K=I&&I.unsubscribe&&(()=>{I.unsubscribe()});let le;try{if(P&&typeof d=="string"&&d.startsWith("data:")&&Ug(d)>L)throw new O("maxContentLength size of "+L+" exceeded",O.ERR_BAD_RESPONSE,p,B);if($&&h!=="get"&&h!=="head"){const ee=await g(X,b);if(typeof ee=="number"&&isFinite(ee)&&ee>R)throw new O("Request body larger than maxBodyLength limit",O.ERR_BAD_REQUEST,p,B)}if(Q&&y&&h!=="get"&&h!=="head"&&(le=await g(X,b))!==0){let ee=new i(d,{method:"POST",body:b,duplex:"half"}),xn;if(w.isFormData(b)&&(xn=ee.headers.get("content-type"))&&X.setContentType(xn),ee.body){const[Gr,Jr]=Ru(le,li(Tu(Q)));b=Nu(ee.body,Au,Gr,Jr)}}w.isString(H)||(H=H?"include":"omit");const de=u&&"credentials"in i.prototype;if(w.isFormData(b)){const ee=X.getContentType();ee&&/^multipart\/form-data/i.test(ee)&&!/boundary=/i.test(ee)&&X.delete("content-type")}X.set("User-Agent","axios/"+ca,!1);const Ce={...A,signal:I,method:h.toUpperCase(),headers:pp(X.normalize()),body:b,duplex:"half",credentials:de?H:void 0};B=u&&new i(d,Ce);let Fe=await(u?N(B,A):N(d,Ce));if(P){const ee=w.toFiniteNumber(Fe.headers.get("content-length"));if(ee!=null&&ee>L)throw new O("maxContentLength size of "+L+" exceeded",O.ERR_BAD_RESPONSE,p,B)}const st=S&&(U==="stream"||U==="response");if(S&&Fe.body&&(_||P||st&&K)){const ee={};["status","statusText","headers"].forEach(Gn=>{ee[Gn]=Fe[Gn]});const xn=w.toFiniteNumber(Fe.headers.get("content-length")),[Gr,Jr]=_&&Ru(xn,li(Tu(_),!0))||[];let fa=0;const Np=Gn=>{if(P&&(fa=Gn,fa>L))throw new O("maxContentLength size of "+L+" exceeded",O.ERR_BAD_RESPONSE,p,B);Gr&&Gr(Gn)};Fe=new l(Nu(Fe.body,Au,Np,()=>{Jr&&Jr(),K&&K()}),ee)}U=U||"text";let Ie=await x[w.findKey(x,U)||"text"](Fe,p);if(P&&!S&&!st){let ee;if(Ie!=null&&(typeof Ie.byteLength=="number"?ee=Ie.byteLength:typeof Ie.size=="number"?ee=Ie.size:typeof Ie=="string"&&(ee=typeof r=="function"?new r().encode(Ie).byteLength:Ie.length)),typeof ee=="number"&&ee>L)throw new O("maxContentLength size of "+L+" exceeded",O.ERR_BAD_RESPONSE,p,B)}return!st&&K&&K(),await new Promise((ee,xn)=>{vp(ee,xn,{data:Ie,headers:Oe.from(Fe.headers),status:Fe.status,statusText:Fe.statusText,config:p,request:B})})}catch(de){if(K&&K(),I&&I.aborted&&I.reason instanceof O){const Ce=I.reason;throw Ce.config=p,B&&(Ce.request=B),de!==Ce&&(Ce.cause=de),Ce}throw de&&de.name==="TypeError"&&/Load failed|fetch/i.test(de.message)?Object.assign(new O("Network Error",O.ERR_NETWORK,p,B,de&&de.response),{cause:de.cause||de}):O.from(de,de&&de.code,p,B,de&&de.response)}}},Wg=new Map,bp=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:o}=t,i=[r,o,n];let l=i.length,a=l,u,c,f=Wg;for(;a--;)u=i[a],c=f.get(u),c===void 0&&f.set(u,c=a?new Map:$g(t)),f=c;return c};bp();const da={http:ug,xhr:Lg,fetch:{get:bp}};w.forEach(da,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const Ou=e=>`- ${e}`,Hg=e=>w.isFunction(e)||e===null||e===!1;function Vg(e,t){e=w.isArray(e)?e:[e];const{length:n}=e;let r,o;const i={};for(let l=0;l`adapter ${u} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?l.length>1?`since : `+l.map(Ou).join(` -`):" "+Ou(l[0]):"as no adapter specified";throw new O("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}const jf={getAdapter:Vg,adapters:da};function ll(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Xr(null,e)}function Du(e){return ll(e),e.headers=Oe.from(e.headers),e.data=il.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),jf.getAdapter(e.adapter||Yr.adapter,e)(e).then(function(r){ll(e),e.response=r;try{r.data=il.call(e,e.transformResponse,r)}finally{delete e.response}return r.headers=Oe.from(r.headers),r},function(r){if(!vf(r)&&(ll(e),r&&r.response)){e.response=r.response;try{r.response.data=il.call(e,e.transformResponse,r.response)}finally{delete e.response}r.response.headers=Oe.from(r.response.headers)}return Promise.reject(r)})}const Ri={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ri[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Lu={};Ri.transitional=function(t,n,r){function o(i,l){return"[Axios v"+ca+"] Transitional option '"+i+"'"+l+(r?". "+r:"")}return(i,l,a)=>{if(t===!1)throw new O(o(l," has been removed"+(n?" in "+n:"")),O.ERR_DEPRECATED);return n&&!Lu[l]&&(Lu[l]=!0,console.warn(o(l," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,l,a):!0}};Ri.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Qg(e,t,n){if(typeof e!="object")throw new O("options must be an object",O.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],l=Object.prototype.hasOwnProperty.call(t,i)?t[i]:void 0;if(l){const a=e[i],u=a===void 0||l(a,i,e);if(u!==!0)throw new O("option "+i+" must be "+u,O.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new O("Unknown option "+i,O.ERR_BAD_OPTION)}}const Oo={assertOptions:Qg,validators:Ri},Ze=Oo.validators;let un=class{constructor(t){this.defaults=t||{},this.interceptors={request:new _u,response:new _u}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const i=(()=>{if(!o.stack)return"";const l=o.stack.indexOf(` +`):" "+Ou(l[0]):"as no adapter specified";throw new O("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}const kp={getAdapter:Vg,adapters:da};function ll(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Xr(null,e)}function Du(e){return ll(e),e.headers=Oe.from(e.headers),e.data=il.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),kp.getAdapter(e.adapter||Yr.adapter,e)(e).then(function(r){ll(e),e.response=r;try{r.data=il.call(e,e.transformResponse,r)}finally{delete e.response}return r.headers=Oe.from(r.headers),r},function(r){if(!xp(r)&&(ll(e),r&&r.response)){e.response=r.response;try{r.response.data=il.call(e,e.transformResponse,r.response)}finally{delete e.response}r.response.headers=Oe.from(r.response.headers)}return Promise.reject(r)})}const Ri={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ri[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Lu={};Ri.transitional=function(t,n,r){function o(i,l){return"[Axios v"+ca+"] Transitional option '"+i+"'"+l+(r?". "+r:"")}return(i,l,a)=>{if(t===!1)throw new O(o(l," has been removed"+(n?" in "+n:"")),O.ERR_DEPRECATED);return n&&!Lu[l]&&(Lu[l]=!0,console.warn(o(l," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,l,a):!0}};Ri.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Qg(e,t,n){if(typeof e!="object")throw new O("options must be an object",O.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],l=Object.prototype.hasOwnProperty.call(t,i)?t[i]:void 0;if(l){const a=e[i],u=a===void 0||l(a,i,e);if(u!==!0)throw new O("option "+i+" must be "+u,O.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new O("Unknown option "+i,O.ERR_BAD_OPTION)}}const Oo={assertOptions:Qg,validators:Ri},Ze=Oo.validators;let un=class{constructor(t){this.defaults=t||{},this.interceptors={request:new _u,response:new _u}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const i=(()=>{if(!o.stack)return"";const l=o.stack.indexOf(` `);return l===-1?"":o.stack.slice(l+1)})();try{if(!r.stack)r.stack=i;else if(i){const l=i.indexOf(` `),a=l===-1?-1:i.indexOf(` `,l+1),u=a===-1?"":i.slice(a+1);String(r.stack).endsWith(u)||(r.stack+=` -`+i)}}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=mn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&Oo.assertOptions(r,{silentJSONParsing:Ze.transitional(Ze.boolean),forcedJSONParsing:Ze.transitional(Ze.boolean),clarifyTimeoutError:Ze.transitional(Ze.boolean),legacyInterceptorReqResOrdering:Ze.transitional(Ze.boolean)},!1),o!=null&&(w.isFunction(o)?n.paramsSerializer={serialize:o}:Oo.assertOptions(o,{encode:Ze.function,serialize:Ze.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Oo.assertOptions(n,{baseUrl:Ze.spelling("baseURL"),withXsrfToken:Ze.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let l=i&&w.merge(i.common,i[n.method]);i&&w.forEach(["delete","get","head","post","put","patch","query","common"],x=>{delete i[x]}),n.headers=Oe.concat(l,i);const a=[];let u=!0;this.interceptors.request.forEach(function(v){if(typeof v.runWhen=="function"&&v.runWhen(n)===!1)return;u=u&&v.synchronous;const g=n.transitional||aa;g&&g.legacyInterceptorReqResOrdering?a.unshift(v.fulfilled,v.rejected):a.push(v.fulfilled,v.rejected)});const c=[];this.interceptors.response.forEach(function(v){c.push(v.fulfilled,v.rejected)});let p,m=0,y;if(!u){const x=[Du.bind(this),void 0];for(x.unshift(...a),x.push(...c),y=x.length,p=Promise.resolve(n);m{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i;const l=new Promise(a=>{r.subscribe(a),i=a}).then(o);return l.cancel=function(){r.unsubscribe(i)},l},t(function(i,l,a){r.reason||(r.reason=new Xr(i,l,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Cf(function(o){t=o}),cancel:t}}};function Kg(e){return function(n){return e.apply(null,n)}}function Yg(e){return w.isObject(e)&&e.isAxiosError===!0}const as={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(as).forEach(([e,t])=>{as[t]=e});function Ef(e){const t=new un(e),n=of(un.prototype.request,t);return w.extend(n,un.prototype,t,{allOwnKeys:!0}),w.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Ef(mn(e,o))},n}const F=Ef(Yr);F.Axios=un;F.CanceledError=Xr;F.CancelToken=qg;F.isCancel=vf;F.VERSION=ca;F.toFormData=_i;F.AxiosError=O;F.Cancel=F.CanceledError;F.all=function(t){return Promise.all(t)};F.spread=Kg;F.isAxiosError=Yg;F.mergeConfig=mn;F.AxiosHeaders=Oe;F.formToJSON=e=>xf(w.isHTMLForm(e)?new FormData(e):e);F.getAdapter=jf.getAdapter;F.HttpStatusCode=as;F.default=F;const{Axios:Yy,AxiosError:Xy,CanceledError:Gy,isCancel:Jy,CancelToken:Zy,VERSION:ex,all:tx,Cancel:nx,isAxiosError:rx,spread:ox,toFormData:ix,AxiosHeaders:lx,HttpStatusCode:sx,formToJSON:ax,getAdapter:ux,mergeConfig:cx,create:dx}=F,Do={tardy:{name:"Tardy Core Hours",category:"Attendance & Punctuality",minPoints:1,maxPoints:1,chapter:"Chapter 4, Section 5",fields:["time","minutes","description"],description:"Arriving 7+ minutes after 9:00 AM or start of mandatory meeting without prior excuse"},unplanned_absence:{name:"Unplanned Absence",category:"Attendance & Punctuality",minPoints:3,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["description"],description:"Absence from Core Hours without 48-hour notification, excluding verified emergencies"},chronic_underscheduling:{name:"Chronic Under-Scheduling",category:"Attendance & Punctuality",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Consistently failing to meet 40-hour weekly baseline"},pto_exhausted:{name:"Absence - PTO Exhausted",category:"Attendance & Punctuality",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Any absence after PTO bank reaches zero"},shadow_absenteeism:{name:"Shadow Absenteeism",category:"Attendance & Punctuality",minPoints:5,maxPoints:20,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to record partial-day absences or habitual PTO system bypass (20 pts for recidivists)"},manual_punch_1st:{name:"Manual Punch Correction (1st)",category:"Administrative Integrity",minPoints:1,maxPoints:1,chapter:"Chapter 4, Section 5",fields:["description"],description:"First failure to punch in/out requiring manual audit"},manual_punch_2nd:{name:"Manual Punch Correction (2nd)",category:"Administrative Integrity",minPoints:2,maxPoints:2,chapter:"Chapter 4, Section 5",fields:["description"],description:"Second failure requiring written action plan"},manual_punch_3rd:{name:"Manual Punch Correction (3rd / Tier 1)",category:"Administrative Integrity",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Repeated timekeeping negligence triggering formal Tier 1 realignment"},geolocation_1st:{name:"Geolocation Integrity (1st)",category:"Administrative Integrity",minPoints:1,maxPoints:1,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Recording blind punch with location services disabled"},geolocation_2nd:{name:"Geolocation Integrity (2nd)",category:"Administrative Integrity",minPoints:10,maxPoints:10,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Subsequent attempt to bypass location safeguards"},point_of_work:{name:"Point-of-Work Integrity",category:"Administrative Integrity",minPoints:1,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Clocking in before arriving at assigned post or for personal errands"},financial_chargeback:{name:"Financial Stewardship / Chargeback",category:"Financial Stewardship",minPoints:1,maxPoints:1,chapter:"Chapter 4, Section 5",fields:["amount","description"],description:"Monthly assessment for unsubstantiated expenses requiring chargeback"},receipt_negligence:{name:"Receipt Negligence",category:"Financial Stewardship",minPoints:10,maxPoints:10,chapter:"Chapter 4, Section 5",fields:["amount","description"],description:"Frequent failure to provide company card expense documentation"},failure_to_respond:{name:"Failure to Respond",category:"Operational Response",minPoints:1,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to respond promptly to internal/external requests during Core Hours"},sunset_rule:{name:"Sunset Rule Violation",category:"Operational Response",minPoints:1,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to provide response or status update with commitment date by end of business day"},double_ask:{name:"Double Ask Friction",category:"Operational Response",minPoints:3,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["description"],description:"Forcing client to ask twice for same information due to employee neglect"},missed_deadline_internal:{name:"Missed Deadline - Internal",category:"Operational Response",minPoints:3,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to meet internal project milestones"},missed_deadline_client:{name:"Missed Deadline - Client",category:"Operational Response",minPoints:7,maxPoints:7,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to meet high-impact client-facing deadline"},commitment_breach:{name:"Commitment Breach",category:"Operational Response",minPoints:4,maxPoints:4,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failing to meet commitment date without proactive prior notification"},communication_gap:{name:"Communication Gap (15-min window)",category:"Operational Response",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to respond within 15-minute window due to mobile device distraction"},quality_recidivism:{name:"Quality Recidivism",category:"Operational Response",minPoints:4,maxPoints:4,chapter:"Chapter 4, Section 5",fields:["description"],description:"Repetition of technical/administrative error previously corrected"},technical_negligence:{name:"Technical Negligence",category:"Operational Response",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Performance error resulting in rework, data loss, or equipment damage"},appearance:{name:"Professional Appearance Violation",category:"Professional Conduct",minPoints:1,maxPoints:3,chapter:"Chapter 2, Section 9",fields:["time","location","description"],description:"Failure to maintain dress code standards (shirts, pants, shoes required)"},active_consumption:{name:"Active Consumption Media",category:"Professional Conduct",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["time","description"],description:"Interactive social media/gaming during Core Hours"},tobacco_debris:{name:"Tobacco Facility Debris",category:"Professional Conduct",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Failure to maintain clean smoking area or flicking debris on grounds"},passive_insubordination:{name:"Passive Insubordination",category:"Professional Conduct",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Ignoring reasonable requests, emails, or syncs without open dissent"},lockdown_violation:{name:"Lockdown Violation",category:"Professional Conduct",minPoints:10,maxPoints:10,chapter:"Chapter 4, Section 5",fields:["description"],description:"Using non-work media while under Tier 2 Administrative Friction"},vehicle_stewardship:{name:"Vehicle Stewardship",category:"Professional Conduct",minPoints:10,maxPoints:10,chapter:"Chapter 4, Section 5",fields:["description"],description:"Persistent tobacco-free transit violation (odor/debris in company vehicle)"},defiant_insubordination:{name:"Defiant Insubordination",category:"Professional Conduct",minPoints:15,maxPoints:15,chapter:"Chapter 4, Section 5",fields:["description"],description:"Openly refusing legal, ethical, or professional directive from management"},benefit_documentation:{name:"Benefit Documentation Failure",category:"Professional Conduct",minPoints:15,maxPoints:15,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to provide insurance records for Workers Comp"},professional_dishonesty:{name:"Professional Dishonesty",category:"Professional Conduct",minPoints:20,maxPoints:20,chapter:"Chapter 4, Section 5",fields:["description"],description:"Falsifying time records, expenses, or reasons for absence"},wfh_submittal:{name:"WFH Submittal Failure",category:"Work From Home",minPoints:1,maxPoints:5,chapter:"Chapter 4, Section 4.1",fields:["description"],description:"Failure to provide work-product summary or misrepresenting hours worked"},safety_minor:{name:"Safety Violation - Minor",category:"Safety & Security",minPoints:1,maxPoints:10,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Minor to moderate safety standard violations without immediate injury"},policy_isp:{name:"Policy Non-Alignment - ISP",category:"Safety & Security",minPoints:5,maxPoints:20,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to adhere to Information Security Policy protocols"},workspace_safety:{name:"Workspace Safety Neglect",category:"Safety & Security",minPoints:15,maxPoints:15,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Failure to maintain clean workspace or minor safety negligence"},distracted_driving:{name:"Distracted Driving",category:"Safety & Security",minPoints:15,maxPoints:15,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Use of handheld mobile devices while operating vehicle for company business"},operational_sabotage:{name:"Operational Sabotage",category:"Safety & Security",minPoints:20,maxPoints:20,chapter:"Chapter 4, Section 5",fields:["description"],description:"Willful disregard for security/safety protocols resulting in breach or injury"},impairment_redzone:{name:"Impairment in Red Zone",category:"Safety & Security",minPoints:30,maxPoints:30,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Operating machinery or working in Fabrication Area while under influence"},child_redzone:{name:"Child in Red Zone",category:"Safety & Security",minPoints:30,maxPoints:30,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Bringing minor into active Fabrication Area (Suite 24/25)"},i9_falsification:{name:"I-9 Eligibility Falsification",category:"Safety & Security",minPoints:30,maxPoints:30,chapter:"Chapter 4, Section 5",fields:["description"],description:"Falsifying work authorization or identity documentation"}},Xg=Object.entries(Do).reduce((e,[t,n])=>(e[n.category]||(e[n.category]=[]),e[n.category].push({key:t,...n}),e),{});function Gg(e){const[t,n]=k.useState(null),[r,o]=k.useState({}),[i,l]=k.useState({}),[a,u]=k.useState([]),[c,p]=k.useState(!1);return k.useEffect(()=>{if(!e){n(null),o({}),l({}),u([]);return}p(!0),Promise.all([F.get(`/api/employees/${e}/score`),F.get(`/api/employees/${e}/violation-counts`),F.get(`/api/employees/${e}/violation-counts/alltime`),F.get(`/api/violations/employee/${e}?limit=20`)]).then(([m,y,S,x])=>{n(m.data),o(y.data),l(S.data),u(x.data)}).catch(console.error).finally(()=>p(!1))},[e]),{score:t,counts90:r,countsAllTime:i,history:a,loading:c}}const kr=[{min:0,max:4,label:"Tier 0-1 — Elite Standing",color:"#28a745",bg:"#d4edda"},{min:5,max:9,label:"Tier 1 — Realignment",color:"#856404",bg:"#fff3cd"},{min:10,max:14,label:"Tier 2 — Administrative Lockdown",color:"#d9534f",bg:"#f8d7da"},{min:15,max:19,label:"Tier 3 — Verification",color:"#d9534f",bg:"#f8d7da"},{min:20,max:24,label:"Tier 4 — Risk Mitigation",color:"#721c24",bg:"#f5c6cb"},{min:25,max:29,label:"Tier 5 — Final Decision",color:"#721c24",bg:"#f5c6cb"},{min:30,max:999,label:"Tier 6 — Separation",color:"#fff",bg:"#721c24"}];function Kt(e){return kr.find(t=>e>=t.min&&e<=t.max)||kr[0]}function Jg(e){const t=kr.findIndex(n=>e>=n.min&&e<=n.max);return t>=0&&ts.jsxs("tr",{style:l%2===0?ge.trEven:ge.trOdd,children:[s.jsx("td",{style:ge.td,children:ey(i.incident_date)}),s.jsx("td",{style:ge.td,children:i.violation_name}),s.jsx("td",{style:{...ge.td,color:"#c0c2d6"},children:i.category}),s.jsx("td",{style:{...ge.td,...ge.pts},children:i.points}),s.jsx("td",{style:{...ge.td,color:"#c0c2d6"},children:i.details||"–"})]},i.id))})]}),e.length>5&&s.jsx("div",{style:{marginTop:"8px"},children:s.jsx("button",{style:ge.toggle,onClick:()=>r(i=>!i),children:n?"▲ Show less":`▼ Show all ${e.length} violations`})})]}):s.jsx("p",{style:ge.empty,children:"No violations on record for this employee."})}const _f=k.createContext(null);function Pi(){const e=k.useContext(_f);if(!e)throw new Error("useToast must be used within a ToastProvider");return e}const Fu={success:{bg:"#053321",border:"#0f5132",color:"#9ef7c1",icon:"✓"},error:{bg:"#3c1114",border:"#f5c6cb",color:"#ffb3b8",icon:"✗"},info:{bg:"#0c1f3f",border:"#2563eb",color:"#93c5fd",icon:"ℹ"},warning:{bg:"#3b2e00",border:"#d4af37",color:"#ffdf8a",icon:"⚠"}};let ny=0;function ry({toast:e,onDismiss:t}){const n=Fu[e.variant]||Fu.info,[r,o]=k.useState(!1),i=k.useRef(null);k.useEffect(()=>(i.current=setTimeout(()=>{o(!0),setTimeout(()=>t(e.id),280)},e.duration||4e3),()=>clearTimeout(i.current)),[e.id,e.duration,t]);const l=()=>{clearTimeout(i.current),o(!0),setTimeout(()=>t(e.id),280)};return s.jsxs("div",{style:{background:n.bg,border:`1px solid ${n.border}`,borderRadius:"8px",padding:"12px 16px",display:"flex",alignItems:"flex-start",gap:"10px",color:n.color,fontSize:"13px",fontWeight:500,minWidth:"320px",maxWidth:"480px",boxShadow:"0 4px 24px rgba(0,0,0,0.5)",animation:r?"toastOut 0.28s ease-in forwards":"toastIn 0.28s ease-out",position:"relative",overflow:"hidden"},children:[s.jsx("span",{style:{fontSize:"16px",lineHeight:1,flexShrink:0,marginTop:"1px"},children:n.icon}),s.jsx("span",{style:{flex:1,lineHeight:1.5},children:e.message}),s.jsx("button",{onClick:l,style:{background:"none",border:"none",color:n.color,cursor:"pointer",fontSize:"16px",padding:"0 0 0 8px",opacity:.7,lineHeight:1,flexShrink:0},"aria-label":"Dismiss",children:"×"}),s.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"3px",background:n.color,opacity:.4,borderRadius:"0 0 8px 8px",animation:`toastProgress ${e.duration||4e3}ms linear forwards`}})]})}function oy({children:e}){const[t,n]=k.useState([]),r=k.useCallback(l=>{n(a=>a.filter(u=>u.id!==l))},[]),o=k.useCallback((l,a="info",u=4e3)=>{const c=++ny;return n(p=>{const m=[...p,{id:c,message:l,variant:a,duration:u}];return m.length>5?m.slice(-5):m}),c},[]),i=k.useCallback({success:(l,a)=>o(l,"success",a),error:(l,a)=>o(l,"error",a||6e3),info:(l,a)=>o(l,"info",a),warning:(l,a)=>o(l,"warning",a||5e3)},[o]);return k.useEffect(()=>{if(document.getElementById("toast-keyframes"))return;const l=document.createElement("style");l.id="toast-keyframes",l.textContent=` +`+i)}}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=mn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&Oo.assertOptions(r,{silentJSONParsing:Ze.transitional(Ze.boolean),forcedJSONParsing:Ze.transitional(Ze.boolean),clarifyTimeoutError:Ze.transitional(Ze.boolean),legacyInterceptorReqResOrdering:Ze.transitional(Ze.boolean)},!1),o!=null&&(w.isFunction(o)?n.paramsSerializer={serialize:o}:Oo.assertOptions(o,{encode:Ze.function,serialize:Ze.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Oo.assertOptions(n,{baseUrl:Ze.spelling("baseURL"),withXsrfToken:Ze.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let l=i&&w.merge(i.common,i[n.method]);i&&w.forEach(["delete","get","head","post","put","patch","query","common"],x=>{delete i[x]}),n.headers=Oe.concat(l,i);const a=[];let u=!0;this.interceptors.request.forEach(function(v){if(typeof v.runWhen=="function"&&v.runWhen(n)===!1)return;u=u&&v.synchronous;const g=n.transitional||aa;g&&g.legacyInterceptorReqResOrdering?a.unshift(v.fulfilled,v.rejected):a.push(v.fulfilled,v.rejected)});const c=[];this.interceptors.response.forEach(function(v){c.push(v.fulfilled,v.rejected)});let f,m=0,y;if(!u){const x=[Du.bind(this),void 0];for(x.unshift(...a),x.push(...c),y=x.length,f=Promise.resolve(n);m{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i;const l=new Promise(a=>{r.subscribe(a),i=a}).then(o);return l.cancel=function(){r.unsubscribe(i)},l},t(function(i,l,a){r.reason||(r.reason=new Xr(i,l,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new jp(function(o){t=o}),cancel:t}}};function Kg(e){return function(n){return e.apply(null,n)}}function Yg(e){return w.isObject(e)&&e.isAxiosError===!0}const as={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(as).forEach(([e,t])=>{as[t]=e});function Cp(e){const t=new un(e),n=op(un.prototype.request,t);return w.extend(n,un.prototype,t,{allOwnKeys:!0}),w.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Cp(mn(e,o))},n}const F=Cp(Yr);F.Axios=un;F.CanceledError=Xr;F.CancelToken=qg;F.isCancel=xp;F.VERSION=ca;F.toFormData=_i;F.AxiosError=O;F.Cancel=F.CanceledError;F.all=function(t){return Promise.all(t)};F.spread=Kg;F.isAxiosError=Yg;F.mergeConfig=mn;F.AxiosHeaders=Oe;F.formToJSON=e=>yp(w.isHTMLForm(e)?new FormData(e):e);F.getAdapter=kp.getAdapter;F.HttpStatusCode=as;F.default=F;const{Axios:Yy,AxiosError:Xy,CanceledError:Gy,isCancel:Jy,CancelToken:Zy,VERSION:ex,all:tx,Cancel:nx,isAxiosError:rx,spread:ox,toFormData:ix,AxiosHeaders:lx,HttpStatusCode:sx,formToJSON:ax,getAdapter:ux,mergeConfig:cx,create:dx}=F,Do={tardy:{name:"Tardy Core Hours",category:"Attendance & Punctuality",minPoints:1,maxPoints:1,chapter:"Chapter 4, Section 5",fields:["time","minutes","description"],description:"Arriving 7+ minutes after 9:00 AM or start of mandatory meeting without prior excuse"},unplanned_absence:{name:"Unplanned Absence",category:"Attendance & Punctuality",minPoints:3,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["description"],description:"Absence from Core Hours without 48-hour notification, excluding verified emergencies"},chronic_underscheduling:{name:"Chronic Under-Scheduling",category:"Attendance & Punctuality",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Consistently failing to meet 40-hour weekly baseline"},pto_exhausted:{name:"Absence - PTO Exhausted",category:"Attendance & Punctuality",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Any absence after PTO bank reaches zero"},shadow_absenteeism:{name:"Shadow Absenteeism",category:"Attendance & Punctuality",minPoints:5,maxPoints:20,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to record partial-day absences or habitual PTO system bypass (20 pts for recidivists)"},manual_punch_1st:{name:"Manual Punch Correction (1st)",category:"Administrative Integrity",minPoints:1,maxPoints:1,chapter:"Chapter 4, Section 5",fields:["description"],description:"First failure to punch in/out requiring manual audit"},manual_punch_2nd:{name:"Manual Punch Correction (2nd)",category:"Administrative Integrity",minPoints:2,maxPoints:2,chapter:"Chapter 4, Section 5",fields:["description"],description:"Second failure requiring written action plan"},manual_punch_3rd:{name:"Manual Punch Correction (3rd / Tier 1)",category:"Administrative Integrity",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Repeated timekeeping negligence triggering formal Tier 1 realignment"},geolocation_1st:{name:"Geolocation Integrity (1st)",category:"Administrative Integrity",minPoints:1,maxPoints:1,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Recording blind punch with location services disabled"},geolocation_2nd:{name:"Geolocation Integrity (2nd)",category:"Administrative Integrity",minPoints:10,maxPoints:10,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Subsequent attempt to bypass location safeguards"},point_of_work:{name:"Point-of-Work Integrity",category:"Administrative Integrity",minPoints:1,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Clocking in before arriving at assigned post or for personal errands"},financial_chargeback:{name:"Financial Stewardship / Chargeback",category:"Financial Stewardship",minPoints:1,maxPoints:1,chapter:"Chapter 4, Section 5",fields:["amount","description"],description:"Monthly assessment for unsubstantiated expenses requiring chargeback"},receipt_negligence:{name:"Receipt Negligence",category:"Financial Stewardship",minPoints:10,maxPoints:10,chapter:"Chapter 4, Section 5",fields:["amount","description"],description:"Frequent failure to provide company card expense documentation"},failure_to_respond:{name:"Failure to Respond",category:"Operational Response",minPoints:1,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to respond promptly to internal/external requests during Core Hours"},sunset_rule:{name:"Sunset Rule Violation",category:"Operational Response",minPoints:1,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to provide response or status update with commitment date by end of business day"},double_ask:{name:"Double Ask Friction",category:"Operational Response",minPoints:3,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["description"],description:"Forcing client to ask twice for same information due to employee neglect"},missed_deadline_internal:{name:"Missed Deadline - Internal",category:"Operational Response",minPoints:3,maxPoints:3,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to meet internal project milestones"},missed_deadline_client:{name:"Missed Deadline - Client",category:"Operational Response",minPoints:7,maxPoints:7,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to meet high-impact client-facing deadline"},commitment_breach:{name:"Commitment Breach",category:"Operational Response",minPoints:4,maxPoints:4,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failing to meet commitment date without proactive prior notification"},communication_gap:{name:"Communication Gap (15-min window)",category:"Operational Response",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to respond within 15-minute window due to mobile device distraction"},quality_recidivism:{name:"Quality Recidivism",category:"Operational Response",minPoints:4,maxPoints:4,chapter:"Chapter 4, Section 5",fields:["description"],description:"Repetition of technical/administrative error previously corrected"},technical_negligence:{name:"Technical Negligence",category:"Operational Response",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Performance error resulting in rework, data loss, or equipment damage"},appearance:{name:"Professional Appearance Violation",category:"Professional Conduct",minPoints:1,maxPoints:3,chapter:"Chapter 2, Section 9",fields:["time","location","description"],description:"Failure to maintain dress code standards (shirts, pants, shoes required)"},active_consumption:{name:"Active Consumption Media",category:"Professional Conduct",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["time","description"],description:"Interactive social media/gaming during Core Hours"},tobacco_debris:{name:"Tobacco Facility Debris",category:"Professional Conduct",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Failure to maintain clean smoking area or flicking debris on grounds"},passive_insubordination:{name:"Passive Insubordination",category:"Professional Conduct",minPoints:5,maxPoints:5,chapter:"Chapter 4, Section 5",fields:["description"],description:"Ignoring reasonable requests, emails, or syncs without open dissent"},lockdown_violation:{name:"Lockdown Violation",category:"Professional Conduct",minPoints:10,maxPoints:10,chapter:"Chapter 4, Section 5",fields:["description"],description:"Using non-work media while under Tier 2 Administrative Friction"},vehicle_stewardship:{name:"Vehicle Stewardship",category:"Professional Conduct",minPoints:10,maxPoints:10,chapter:"Chapter 4, Section 5",fields:["description"],description:"Persistent tobacco-free transit violation (odor/debris in company vehicle)"},defiant_insubordination:{name:"Defiant Insubordination",category:"Professional Conduct",minPoints:15,maxPoints:15,chapter:"Chapter 4, Section 5",fields:["description"],description:"Openly refusing legal, ethical, or professional directive from management"},benefit_documentation:{name:"Benefit Documentation Failure",category:"Professional Conduct",minPoints:15,maxPoints:15,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to provide insurance records for Workers Comp"},professional_dishonesty:{name:"Professional Dishonesty",category:"Professional Conduct",minPoints:20,maxPoints:20,chapter:"Chapter 4, Section 5",fields:["description"],description:"Falsifying time records, expenses, or reasons for absence"},wfh_submittal:{name:"WFH Submittal Failure",category:"Work From Home",minPoints:1,maxPoints:5,chapter:"Chapter 4, Section 4.1",fields:["description"],description:"Failure to provide work-product summary or misrepresenting hours worked"},safety_minor:{name:"Safety Violation - Minor",category:"Safety & Security",minPoints:1,maxPoints:10,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Minor to moderate safety standard violations without immediate injury"},policy_isp:{name:"Policy Non-Alignment - ISP",category:"Safety & Security",minPoints:5,maxPoints:20,chapter:"Chapter 4, Section 5",fields:["description"],description:"Failure to adhere to Information Security Policy protocols"},workspace_safety:{name:"Workspace Safety Neglect",category:"Safety & Security",minPoints:15,maxPoints:15,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Failure to maintain clean workspace or minor safety negligence"},distracted_driving:{name:"Distracted Driving",category:"Safety & Security",minPoints:15,maxPoints:15,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Use of handheld mobile devices while operating vehicle for company business"},operational_sabotage:{name:"Operational Sabotage",category:"Safety & Security",minPoints:20,maxPoints:20,chapter:"Chapter 4, Section 5",fields:["description"],description:"Willful disregard for security/safety protocols resulting in breach or injury"},impairment_redzone:{name:"Impairment in Red Zone",category:"Safety & Security",minPoints:30,maxPoints:30,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Operating machinery or working in Fabrication Area while under influence"},child_redzone:{name:"Child in Red Zone",category:"Safety & Security",minPoints:30,maxPoints:30,chapter:"Chapter 4, Section 5",fields:["location","description"],description:"Bringing minor into active Fabrication Area (Suite 24/25)"},i9_falsification:{name:"I-9 Eligibility Falsification",category:"Safety & Security",minPoints:30,maxPoints:30,chapter:"Chapter 4, Section 5",fields:["description"],description:"Falsifying work authorization or identity documentation"}},Xg=Object.entries(Do).reduce((e,[t,n])=>(e[n.category]||(e[n.category]=[]),e[n.category].push({key:t,...n}),e),{});function Gg(e){const[t,n]=k.useState(null),[r,o]=k.useState({}),[i,l]=k.useState({}),[a,u]=k.useState([]),[c,f]=k.useState(!1);return k.useEffect(()=>{if(!e){n(null),o({}),l({}),u([]);return}f(!0),Promise.all([F.get(`/api/employees/${e}/score`),F.get(`/api/employees/${e}/violation-counts`),F.get(`/api/employees/${e}/violation-counts/alltime`),F.get(`/api/violations/employee/${e}?limit=20`)]).then(([m,y,S,x])=>{n(m.data),o(y.data),l(S.data),u(x.data)}).catch(console.error).finally(()=>f(!1))},[e]),{score:t,counts90:r,countsAllTime:i,history:a,loading:c}}const kr=[{min:0,max:4,label:"Tier 0-1 — Elite Standing",color:"#28a745",bg:"#d4edda"},{min:5,max:9,label:"Tier 1 — Realignment",color:"#856404",bg:"#fff3cd"},{min:10,max:14,label:"Tier 2 — Administrative Lockdown",color:"#d9534f",bg:"#f8d7da"},{min:15,max:19,label:"Tier 3 — Verification",color:"#d9534f",bg:"#f8d7da"},{min:20,max:24,label:"Tier 4 — Risk Mitigation",color:"#721c24",bg:"#f5c6cb"},{min:25,max:29,label:"Tier 5 — Final Decision",color:"#721c24",bg:"#f5c6cb"},{min:30,max:999,label:"Tier 6 — Separation",color:"#fff",bg:"#721c24"}];function Kt(e){return kr.find(t=>e>=t.min&&e<=t.max)||kr[0]}function Jg(e){const t=kr.findIndex(n=>e>=n.min&&e<=n.max);return t>=0&&ts.jsxs("tr",{style:l%2===0?ge.trEven:ge.trOdd,children:[s.jsx("td",{style:ge.td,children:ey(i.incident_date)}),s.jsx("td",{style:ge.td,children:i.violation_name}),s.jsx("td",{style:{...ge.td,color:"#c0c2d6"},children:i.category}),s.jsx("td",{style:{...ge.td,...ge.pts},children:i.points}),s.jsx("td",{style:{...ge.td,color:"#c0c2d6"},children:i.details||"–"})]},i.id))})]}),e.length>5&&s.jsx("div",{style:{marginTop:"8px"},children:s.jsx("button",{style:ge.toggle,onClick:()=>r(i=>!i),children:n?"▲ Show less":`▼ Show all ${e.length} violations`})})]}):s.jsx("p",{style:ge.empty,children:"No violations on record for this employee."})}const Ep=k.createContext(null);function Pi(){const e=k.useContext(Ep);if(!e)throw new Error("useToast must be used within a ToastProvider");return e}const Fu={success:{bg:"#053321",border:"#0f5132",color:"#9ef7c1",icon:"✓"},error:{bg:"#3c1114",border:"#f5c6cb",color:"#ffb3b8",icon:"✗"},info:{bg:"#0c1f3f",border:"#2563eb",color:"#93c5fd",icon:"ℹ"},warning:{bg:"#3b2e00",border:"#d4af37",color:"#ffdf8a",icon:"⚠"}};let ny=0;function ry({toast:e,onDismiss:t}){const n=Fu[e.variant]||Fu.info,[r,o]=k.useState(!1),i=k.useRef(null);k.useEffect(()=>(i.current=setTimeout(()=>{o(!0),setTimeout(()=>t(e.id),280)},e.duration||4e3),()=>clearTimeout(i.current)),[e.id,e.duration,t]);const l=()=>{clearTimeout(i.current),o(!0),setTimeout(()=>t(e.id),280)};return s.jsxs("div",{style:{background:n.bg,border:`1px solid ${n.border}`,borderRadius:"8px",padding:"12px 16px",display:"flex",alignItems:"flex-start",gap:"10px",color:n.color,fontSize:"13px",fontWeight:500,minWidth:"320px",maxWidth:"480px",boxShadow:"0 4px 24px rgba(0,0,0,0.5)",animation:r?"toastOut 0.28s ease-in forwards":"toastIn 0.28s ease-out",position:"relative",overflow:"hidden"},children:[s.jsx("span",{style:{fontSize:"16px",lineHeight:1,flexShrink:0,marginTop:"1px"},children:n.icon}),s.jsx("span",{style:{flex:1,lineHeight:1.5},children:e.message}),s.jsx("button",{onClick:l,style:{background:"none",border:"none",color:n.color,cursor:"pointer",fontSize:"16px",padding:"0 0 0 8px",opacity:.7,lineHeight:1,flexShrink:0},"aria-label":"Dismiss",children:"×"}),s.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"3px",background:n.color,opacity:.4,borderRadius:"0 0 8px 8px",animation:`toastProgress ${e.duration||4e3}ms linear forwards`}})]})}function oy({children:e}){const[t,n]=k.useState([]),r=k.useCallback(l=>{n(a=>a.filter(u=>u.id!==l))},[]),o=k.useCallback((l,a="info",u=4e3)=>{const c=++ny;return n(f=>{const m=[...f,{id:c,message:l,variant:a,duration:u}];return m.length>5?m.slice(-5):m}),c},[]),i=k.useCallback({success:(l,a)=>o(l,"success",a),error:(l,a)=>o(l,"error",a||6e3),info:(l,a)=>o(l,"info",a),warning:(l,a)=>o(l,"warning",a||5e3)},[o]);return k.useEffect(()=>{if(document.getElementById("toast-keyframes"))return;const l=document.createElement("style");l.id="toast-keyframes",l.textContent=` @keyframes toastIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } @@ -58,11 +58,11 @@ Error generating stack: `+i.message+` from { width: 100%; } to { width: 0%; } } - `,document.head.appendChild(l)},[]),s.jsxs(_f.Provider,{value:i,children:[e,s.jsx("div",{style:{position:"fixed",top:"16px",right:"16px",zIndex:99999,display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:t.map(l=>s.jsx("div",{style:{pointerEvents:"auto"},children:s.jsx(ry,{toast:l,onDismiss:r})},l.id))})]})}const iy=["Attendance & Punctuality","Administrative Integrity","Financial Stewardship","Operational Response","Professional Conduct","Work From Home","Safety & Security"],ly=[{key:"time",label:"Incident Time"},{key:"minutes",label:"Minutes Late"},{key:"amount",label:"Amount / Value"},{key:"location",label:"Location / Context"},{key:"description",label:"Additional Details"}],W={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},modal:{background:"#111217",border:"1px solid #2a2b3a",borderRadius:"10px",width:"100%",maxWidth:"620px",maxHeight:"90vh",overflowY:"auto",padding:"32px"},title:{color:"#f8f9fa",fontSize:"20px",fontWeight:700,marginBottom:"24px",borderBottom:"1px solid #2a2b3a",paddingBottom:"12px"},label:{fontWeight:600,color:"#e5e7f1",marginBottom:"5px",fontSize:"13px",display:"block"},input:{width:"100%",padding:"10px",border:"1px solid #333544",borderRadius:"4px",fontSize:"14px",fontFamily:"inherit",background:"#050608",color:"#f8f9fa",boxSizing:"border-box"},textarea:{width:"100%",padding:"10px",border:"1px solid #333544",borderRadius:"4px",fontSize:"13px",fontFamily:"inherit",background:"#050608",color:"#f8f9fa",resize:"vertical",minHeight:"80px",boxSizing:"border-box"},group:{marginBottom:"18px"},hint:{fontSize:"11px",color:"#9ca0b8",marginTop:"4px",fontStyle:"italic"},row:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"14px"},toggle:{display:"flex",gap:"8px",marginTop:"6px"},toggleBtn:e=>({padding:"7px 18px",borderRadius:"4px",fontSize:"13px",fontWeight:600,cursor:"pointer",border:"1px solid",background:e?"#d4af37":"#050608",color:e?"#000":"#9ca0b8",borderColor:e?"#d4af37":"#333544"}),fieldGrid:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginTop:"8px"},checkbox:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",color:"#d1d3e0",cursor:"pointer"},btnRow:{display:"flex",gap:"12px",justifyContent:"flex-end",marginTop:"28px",paddingTop:"16px",borderTop:"1px solid #2a2b3a"},btnSave:{padding:"10px 28px",fontSize:"14px",fontWeight:600,border:"none",borderRadius:"6px",cursor:"pointer",background:"linear-gradient(135deg, #d4af37 0%, #ffdf8a 100%)",color:"#000"},btnDanger:{padding:"10px 18px",fontSize:"14px",fontWeight:600,border:"1px solid #721c24",borderRadius:"6px",cursor:"pointer",background:"#3c1114",color:"#ffb3b8"},btnCancel:{padding:"10px 18px",fontSize:"14px",fontWeight:600,border:"1px solid #333544",borderRadius:"6px",cursor:"pointer",background:"#050608",color:"#f8f9fa"},section:{background:"#181924",border:"1px solid #2a2b3a",borderRadius:"6px",padding:"16px",marginBottom:"18px"},secTitle:{color:"#d4af37",fontSize:"13px",fontWeight:700,marginBottom:"12px",textTransform:"uppercase",letterSpacing:"0.05em"},customBadge:{display:"inline-block",marginLeft:"8px",padding:"1px 7px",borderRadius:"10px",fontSize:"10px",fontWeight:700,background:"#1a2e1a",color:"#4caf50",border:"1px solid #4caf50",verticalAlign:"middle"}},sy={name:"",category:"",chapter:"",description:"",pointType:"fixed",fixedPoints:1,minPoints:1,maxPoints:5,fields:["description"]};function ay({onClose:e,onSaved:t,editing:n=null}){const[r,o]=k.useState(sy),[i,l]=k.useState(!1),[a,u]=k.useState(!1),c=Pi();k.useEffect(()=>{if(n){const x=n.min_points!==n.max_points;o({name:n.name,category:n.category,chapter:n.chapter||"",description:n.description||"",pointType:x?"sliding":"fixed",fixedPoints:n.min_points,minPoints:n.min_points,maxPoints:n.max_points,fields:n.fields||["description"]})}},[n]);const p=(x,v)=>o(g=>({...g,[x]:v})),m=x=>{o(v=>({...v,fields:v.fields.includes(x)?v.fields.filter(g=>g!==x):[...v.fields,x]}))},y=async()=>{var f,d;if(!r.name.trim()){c.warning("Violation name is required.");return}if(!r.category.trim()){c.warning("Category is required.");return}const x=r.pointType==="fixed"?parseInt(r.fixedPoints)||1:parseInt(r.minPoints)||1,v=r.pointType==="fixed"?x:parseInt(r.maxPoints)||1;if(v= min points.");return}if(r.fields.length===0){c.warning("Select at least one context field.");return}const g={name:r.name.trim(),category:r.category.trim(),chapter:r.chapter.trim()||null,description:r.description.trim()||null,min_points:x,max_points:v,fields:r.fields};l(!0);try{let h;n?(h=(await F.put(`/api/violation-types/${n.id}`,g)).data,c.success(`"${h.name}" updated.`)):(h=(await F.post("/api/violation-types",g)).data,c.success(`"${h.name}" added to violation types.`)),t(h)}catch(h){c.error(((d=(f=h.response)==null?void 0:f.data)==null?void 0:d.error)||h.message)}finally{l(!1)}},S=async()=>{var x,v;if(n&&window.confirm(`Delete "${n.name}"? This cannot be undone and will fail if any violations reference this type.`)){u(!0);try{await F.delete(`/api/violation-types/${n.id}`),c.success(`"${n.name}" deleted.`),t(null)}catch(g){c.error(((v=(x=g.response)==null?void 0:x.data)==null?void 0:v.error)||g.message)}finally{u(!1)}}};return s.jsx("div",{style:W.overlay,onClick:x=>x.target===x.currentTarget&&e(),children:s.jsxs("div",{style:W.modal,children:[s.jsxs("div",{style:W.title,children:[n?"Edit Violation Type":"Add Violation Type",n&&s.jsx("span",{style:W.customBadge,children:"CUSTOM"})]}),s.jsxs("div",{style:W.section,children:[s.jsx("div",{style:W.secTitle,children:"Violation Definition"}),s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Violation Name *"}),s.jsx("input",{style:W.input,type:"text",value:r.name,onChange:x=>p("name",x.target.value),placeholder:"e.g. Unauthorized System Access"})]}),s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Category *"}),s.jsx("input",{style:W.input,type:"text",list:"vt-categories",value:r.category,onChange:x=>p("category",x.target.value),placeholder:"Select existing or type new category"}),s.jsx("datalist",{id:"vt-categories",children:iy.map(x=>s.jsx("option",{value:x},x))}),s.jsx("div",{style:W.hint,children:"Choose an existing category or type a new one to create a new group in the dropdown."})]}),s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Handbook Reference / Chapter"}),s.jsx("input",{style:W.input,type:"text",value:r.chapter,onChange:x=>p("chapter",x.target.value),placeholder:"e.g. Chapter 4, Section 6"})]}),s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Description / Reference Text"}),s.jsx("textarea",{style:W.textarea,value:r.description,onChange:x=>p("description",x.target.value),placeholder:"Paste the relevant handbook language or describe the infraction in plain terms..."}),s.jsx("div",{style:W.hint,children:"Shown in the context box on the violation form and printed on the PDF."})]})]}),s.jsxs("div",{style:W.section,children:[s.jsx("div",{style:W.secTitle,children:"Point Assignment"}),s.jsx("label",{style:W.label,children:"Point Type"}),s.jsxs("div",{style:W.toggle,children:[s.jsx("button",{type:"button",style:W.toggleBtn(r.pointType==="fixed"),onClick:()=>p("pointType","fixed"),children:"Fixed"}),s.jsx("button",{type:"button",style:W.toggleBtn(r.pointType==="sliding"),onClick:()=>p("pointType","sliding"),children:"Sliding Range"})]}),s.jsx("div",{style:{...W.hint,marginTop:"6px"},children:"Fixed = exact value every time. Sliding = supervisor adjusts within a min/max range."}),r.pointType==="fixed"?s.jsxs("div",{style:{...W.group,marginTop:"14px"},children:[s.jsx("label",{style:W.label,children:"Points (Fixed)"}),s.jsx("input",{style:{...W.input,width:"120px"},type:"number",min:"1",max:"30",value:r.fixedPoints,onChange:x=>p("fixedPoints",x.target.value)})]}):s.jsxs("div",{style:{...W.row,marginTop:"14px"},children:[s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Min Points"}),s.jsx("input",{style:W.input,type:"number",min:"1",max:"30",value:r.minPoints,onChange:x=>p("minPoints",x.target.value)})]}),s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Max Points"}),s.jsx("input",{style:W.input,type:"number",min:"1",max:"30",value:r.maxPoints,onChange:x=>p("maxPoints",x.target.value)})]})]})]}),s.jsxs("div",{style:W.section,children:[s.jsx("div",{style:W.secTitle,children:"Context Fields"}),s.jsx("div",{style:W.hint,children:"Select which additional fields appear on the violation form for this type."}),s.jsx("div",{style:W.fieldGrid,children:ly.map(({key:x,label:v})=>s.jsxs("label",{style:W.checkbox,children:[s.jsx("input",{type:"checkbox",checked:r.fields.includes(x),onChange:()=>m(x)}),v]},x))})]}),s.jsxs("div",{style:W.btnRow,children:[n&&s.jsx("button",{type:"button",style:W.btnDanger,onClick:S,disabled:a,children:a?"Deleting…":"Delete Type"}),s.jsx("button",{type:"button",style:W.btnCancel,onClick:e,children:"Cancel"}),s.jsx("button",{type:"button",style:W.btnSave,onClick:y,disabled:i,children:i?"Saving…":n?"Save Changes":"Add Violation Type"})]})]})})}const Rf=["Administrative","Business Development","Design and Content","Executive","Implementation and Support","Operations","Production"],D={content:{padding:"32px 40px",background:"#111217",borderRadius:"10px",color:"#f8f9fa"},section:{background:"#181924",borderLeft:"4px solid #d4af37",padding:"20px",marginBottom:"30px",borderRadius:"4px",border:"1px solid #2a2b3a"},sectionTitle:{color:"#f8f9fa",fontSize:"20px",marginBottom:"15px",fontWeight:700},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(250px, 1fr))",gap:"15px",marginTop:"15px"},item:{display:"flex",flexDirection:"column"},label:{fontWeight:600,color:"#e5e7f1",marginBottom:"5px",fontSize:"13px"},input:{padding:"10px",border:"1px solid #333544",borderRadius:"4px",fontSize:"14px",fontFamily:"inherit",background:"#050608",color:"#f8f9fa"},fullCol:{gridColumn:"1 / -1"},contextBox:{background:"#141623",border:"1px solid #333544",borderRadius:"4px",padding:"10px",fontSize:"12px",color:"#d1d3e0",marginTop:"4px"},repeatBadge:{display:"inline-block",marginLeft:"8px",padding:"1px 7px",borderRadius:"10px",fontSize:"11px",fontWeight:700,background:"#3b2e00",color:"#ffd666",border:"1px solid #d4af37"},repeatWarn:{background:"#3b2e00",border:"1px solid #d4af37",borderRadius:"4px",padding:"8px 12px",marginTop:"6px",fontSize:"12px",color:"#ffdf8a"},pointBox:{background:"#181200",border:"2px solid #d4af37",padding:"15px",borderRadius:"6px",marginTop:"15px",textAlign:"center"},pointValue:{fontSize:"24px",fontWeight:"bold",color:"#ffd666",margin:"10px 0"},scoreRow:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"14px",flexWrap:"wrap"},btnRow:{display:"flex",gap:"15px",justifyContent:"center",marginTop:"30px",flexWrap:"wrap"},btnPrimary:{padding:"15px 40px",fontSize:"16px",fontWeight:600,border:"none",borderRadius:"6px",cursor:"pointer",background:"linear-gradient(135deg, #d4af37 0%, #ffdf8a 100%)",color:"#000",textTransform:"uppercase"},btnPdf:{padding:"15px 40px",fontSize:"16px",fontWeight:600,border:"none",borderRadius:"6px",cursor:"pointer",background:"linear-gradient(135deg, #e74c3c 0%, #c0392b 100%)",color:"white",textTransform:"uppercase"},btnSecondary:{padding:"15px 40px",fontSize:"16px",fontWeight:600,border:"1px solid #333544",borderRadius:"6px",cursor:"pointer",background:"#050608",color:"#f8f9fa",textTransform:"uppercase"},ackSection:{background:"#181924",borderLeft:"4px solid #2196F3",padding:"20px",marginBottom:"30px",borderRadius:"4px",border:"1px solid #2a2b3a"},ackHint:{fontSize:"12px",color:"#9ca0b8",marginTop:"4px",fontStyle:"italic"}},sl={employeeId:"",employeeName:"",department:"",supervisor:"",witnessName:"",violationType:"",incidentDate:"",incidentTime:"",amount:"",minutesLate:"",location:"",additionalDetails:"",points:1,acknowledgedBy:"",acknowledgedDate:""};function uy(){var L;const[e,t]=k.useState([]),[n,r]=k.useState(sl),[o,i]=k.useState(null),[l,a]=k.useState(null),[u,c]=k.useState(null),[p,m]=k.useState(!1),[y,S]=k.useState([]),[x,v]=k.useState(null),g=Pi(),f=Gg(n.employeeId||null);k.useEffect(()=>{F.get("/api/employees").then(R=>t(R.data)).catch(()=>{}),d()},[]);const d=()=>{F.get("/api/violation-types").then(R=>S(R.data)).catch(()=>{})},h=k.useMemo(()=>Object.fromEntries(y.map(R=>[R.type_key,R])),[y]),b=k.useMemo(()=>{const R={};return Object.entries(Xg).forEach(([P,$])=>{R[P]=[...$]}),y.forEach(P=>{const $={key:P.type_key,name:P.name,category:P.category,minPoints:P.min_points,maxPoints:P.max_points,chapter:P.chapter||"",description:P.description||"",fields:P.fields,isCustom:!0,customId:P.id};R[P.category]||(R[P.category]=[]),R[P.category].push($)}),R},[y]),C=R=>{if(Do[R])return Do[R];const P=h[R];return P?{name:P.name,category:P.category,chapter:P.chapter||"",description:P.description||"",minPoints:P.min_points,maxPoints:P.max_points,fields:P.fields,isCustom:!0,customId:P.id}:null};k.useEffect(()=>{if(!o||!n.violationType)return;const R=f.countsAllTime[n.violationType];R&&R.count>=1&&o.minPoints!==o.maxPoints?r(P=>({...P,points:o.maxPoints})):r(P=>({...P,points:o.minPoints}))},[n.violationType,o,f.countsAllTime]);const j=R=>{const P=e.find($=>$.id===parseInt(R.target.value));P&&r($=>({...$,employeeId:P.id,employeeName:P.name,department:P.department||"",supervisor:P.supervisor||""}))},T=R=>{const P=R.target.value,$=C(P);i($),r(z=>({...z,violationType:P,points:$?$.minPoints:1}))},_=R=>r(P=>({...P,[R.target.name]:R.target.value})),Q=async R=>{var P,$;if(R.preventDefault(),!n.violationType){g.warning("Please select a violation type.");return}if(!n.employeeName){g.warning("Please enter an employee name.");return}try{const B=(await F.post("/api/employees",{name:n.employeeName,department:n.department,supervisor:n.supervisor})).data.id,K=(await F.post("/api/violations",{employee_id:B,violation_type:n.violationType,violation_name:(o==null?void 0:o.name)||n.violationType,category:(o==null?void 0:o.category)||"General",points:parseInt(n.points),incident_date:n.incidentDate,incident_time:n.incidentTime||null,location:n.location||null,details:n.additionalDetails||null,witness_name:n.witnessName||null,acknowledged_by:n.acknowledgedBy||null,acknowledged_date:n.acknowledgedDate||null,amount:n.amount||null})).data.id;c(K);const le=await F.get("/api/employees");t(le.data),g.success(`Violation #${K} recorded — click Download PDF to save the document.`),a({ok:!0,msg:`✓ Violation #${K} recorded — click Download PDF to save the document.`}),r(sl),i(null)}catch(z){const B=(($=(P=z.response)==null?void 0:P.data)==null?void 0:$.error)||z.message;g.error(`Failed to submit: ${B}`),a({ok:!1,msg:"✗ Error: "+B})}},U=async()=>{if(u){m(!0);try{const R=await F.get(`/api/violations/${u}/pdf`,{responseType:"blob"}),P=window.URL.createObjectURL(new Blob([R.data],{type:"application/pdf"})),$=document.createElement("a");$.href=P,$.download=`CPAS_Violation_${u}.pdf`,document.body.appendChild($),$.click(),$.remove(),window.URL.revokeObjectURL(P),g.success("PDF downloaded successfully.")}catch(R){g.error("PDF generation failed: "+R.message)}finally{m(!1)}}},X=R=>{var P;return(P=o==null?void 0:o.fields)==null?void 0:P.includes(R)},H=R=>f.counts90[R]||0,N=R=>{var P;return(((P=f.countsAllTime[R])==null?void 0:P.count)||0)>=1};return s.jsxs("div",{style:D.content,children:[s.jsxs("div",{style:D.section,children:[s.jsx("h2",{style:D.sectionTitle,children:"Employee Information"}),f.score&&n.employeeId&&s.jsxs("div",{style:D.scoreRow,children:[s.jsx("span",{style:{fontSize:"13px",color:"#d1d3e0",fontWeight:600},children:"Current Standing:"}),s.jsx(Ti,{points:f.score.active_points}),s.jsxs("span",{style:{fontSize:"12px",color:"#9ca0b8"},children:[f.score.violation_count," violation",f.score.violation_count!==1?"s":""," in last 90 days"]})]}),e.length>0&&s.jsxs("div",{style:{marginBottom:"12px"},children:[s.jsx("label",{style:D.label,children:"Quick-Select Existing Employee:"}),s.jsxs("select",{style:D.input,onChange:j,value:n.employeeId||"",children:[s.jsx("option",{value:"",children:"-- Select existing or enter new below --"}),e.map(R=>s.jsxs("option",{value:R.id,children:[R.name,R.department?` — ${R.department}`:""]},R.id))]})]}),s.jsxs("div",{style:D.grid,children:[[["employeeName","Employee Name","John Doe"],["supervisor","Supervisor Name","Jane Smith"],["witnessName","Witness Name (Officer)","Officer Name"]].map(([R,P,$])=>s.jsxs("div",{style:D.item,children:[s.jsxs("label",{style:D.label,children:[P,":"]}),s.jsx("input",{style:D.input,type:"text",name:R,value:n[R],onChange:_,placeholder:$})]},R)),s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Department:"}),s.jsxs("select",{style:D.input,name:"department",value:n.department,onChange:_,children:[s.jsx("option",{value:"",children:"-- Select Department --"}),Rf.map(R=>s.jsx("option",{value:R,children:R},R))]})]})]})]}),s.jsxs("form",{onSubmit:Q,children:[s.jsxs("div",{style:D.section,children:[s.jsx("h2",{style:D.sectionTitle,children:"Violation Details"}),s.jsxs("div",{style:D.grid,children:[s.jsxs("div",{style:{...D.item,...D.fullCol},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"5px"},children:[s.jsx("label",{style:{...D.label,marginBottom:0},children:"Violation Type:"}),s.jsxs("div",{style:{display:"flex",gap:"6px"},children:[(o==null?void 0:o.isCustom)&&s.jsx("button",{type:"button",onClick:()=>v(h[n.violationType]),style:{fontSize:"11px",padding:"3px 10px",borderRadius:"4px",border:"1px solid #4caf50",background:"#1a2e1a",color:"#4caf50",cursor:"pointer",fontWeight:600},children:"Edit Type"}),s.jsx("button",{type:"button",onClick:()=>v("create"),style:{fontSize:"11px",padding:"3px 10px",borderRadius:"4px",border:"1px solid #d4af37",background:"#181200",color:"#ffd666",cursor:"pointer",fontWeight:600},title:"Add a new custom violation type",children:"+ Add Type"})]})]}),s.jsxs("select",{style:D.input,value:n.violationType,onChange:T,required:!0,children:[s.jsx("option",{value:"",children:"-- Select Violation Type --"}),Object.entries(b).map(([R,P])=>s.jsx("optgroup",{label:R,children:P.map($=>{const z=H($.key);return s.jsxs("option",{value:$.key,children:[$.name,$.isCustom?" ✦":"",z>0?` ★ ${z}x in 90 days`:""]},$.key)})},R))]}),o&&s.jsxs("div",{style:D.contextBox,children:[s.jsx("strong",{children:o.name}),o.isCustom&&s.jsx("span",{style:{display:"inline-block",marginLeft:"8px",padding:"1px 7px",borderRadius:"10px",fontSize:"10px",fontWeight:700,background:"#1a2e1a",color:"#4caf50",border:"1px solid #4caf50"},children:"Custom"}),N(n.violationType)&&n.employeeId&&s.jsxs("span",{style:D.repeatBadge,children:["★ Repeat — ",(L=f.countsAllTime[n.violationType])==null?void 0:L.count,"x prior"]}),s.jsx("br",{}),o.description,s.jsx("br",{}),s.jsx("span",{style:{fontSize:"11px",color:"#a0a3ba"},children:o.chapter})]}),o&&N(n.violationType)&&n.employeeId&&o.minPoints!==o.maxPoints&&s.jsxs("div",{style:D.repeatWarn,children:[s.jsx("strong",{children:"Repeat offense detected."})," Point slider set to maximum (",o.maxPoints," pts) per recidivist policy. Adjust if needed."]})]}),s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Incident Date:"}),s.jsx("input",{style:D.input,type:"date",name:"incidentDate",value:n.incidentDate,onChange:_,required:!0})]}),X("time")&&s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Incident Time:"}),s.jsx("input",{style:D.input,type:"time",name:"incidentTime",value:n.incidentTime,onChange:_})]}),X("minutes")&&s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Minutes Late:"}),s.jsx("input",{style:D.input,type:"number",name:"minutesLate",value:n.minutesLate,onChange:_,placeholder:"15"})]}),X("amount")&&s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Amount / Value:"}),s.jsx("input",{style:D.input,type:"text",name:"amount",value:n.amount,onChange:_,placeholder:"$150.00"})]}),X("location")&&s.jsxs("div",{style:{...D.item,...D.fullCol},children:[s.jsx("label",{style:D.label,children:"Location / Context:"}),s.jsx("input",{style:D.input,type:"text",name:"location",value:n.location,onChange:_,placeholder:"Office, vehicle, facility area, etc."})]}),X("description")&&s.jsxs("div",{style:{...D.item,...D.fullCol},children:[s.jsx("label",{style:D.label,children:"Additional Details:"}),s.jsx("textarea",{style:{...D.input,resize:"vertical",minHeight:"80px"},name:"additionalDetails",value:n.additionalDetails,onChange:_,placeholder:"Provide specific context, observations, or details..."})]})]}),f.score&&o&&s.jsx(Zg,{currentPoints:f.score.active_points,addingPoints:parseInt(n.points)||0}),o&&s.jsxs("div",{style:D.pointBox,children:[s.jsx("h4",{style:{color:"#ffdf8a",marginBottom:"10px"},children:"CPAS Point Assessment"}),s.jsxs("p",{style:{margin:0},children:[o.name,": ",o.minPoints===o.maxPoints?`${o.minPoints} Points (Fixed)`:`${o.minPoints}–${o.maxPoints} Points`]}),s.jsx("input",{style:{width:"100%",marginTop:"10px"},type:"range",name:"points",min:o.minPoints,max:o.maxPoints,value:n.points,onChange:_}),s.jsxs("div",{style:D.pointValue,children:[n.points," Points"]}),s.jsx("p",{style:{fontSize:"12px",color:"#d1d3e0"},children:"Adjust to reflect severity and context"})]})]}),s.jsxs("div",{style:D.ackSection,children:[s.jsx("h2",{style:{...D.sectionTitle,fontSize:"17px"},children:"Employee Acknowledgment"}),s.jsx("p",{style:{fontSize:"12px",color:"#9ca0b8",marginBottom:"14px",lineHeight:1.6},children:"If the employee is present and acknowledges receipt of this violation, enter their name and the date below. This replaces the blank signature line on the PDF with a recorded acknowledgment."}),s.jsxs("div",{style:D.grid,children:[s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Acknowledged By (Employee Name):"}),s.jsx("input",{style:D.input,type:"text",name:"acknowledgedBy",value:n.acknowledgedBy,onChange:_,placeholder:"Employee's printed name"}),s.jsx("div",{style:D.ackHint,children:"Leave blank if employee is not present or declines to sign"})]}),s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Acknowledgment Date:"}),s.jsx("input",{style:D.input,type:"date",name:"acknowledgedDate",value:n.acknowledgedDate,onChange:_}),s.jsx("div",{style:D.ackHint,children:"Date the employee received and acknowledged this document"})]})]})]}),s.jsxs("div",{style:D.btnRow,children:[s.jsx("button",{type:"submit",style:D.btnPrimary,children:"Submit Violation"}),s.jsx("button",{type:"button",style:D.btnSecondary,onClick:()=>{r(sl),i(null),a(null),c(null)},children:"Clear Form"})]}),u&&(l==null?void 0:l.ok)&&s.jsxs("div",{style:{textAlign:"center",marginTop:"16px"},children:[s.jsx("button",{type:"button",style:{...D.btnPdf,opacity:p?.7:1},onClick:U,disabled:p,children:p?"⏳ Generating PDF...":"⬇ Download PDF"}),s.jsxs("p",{style:{fontSize:"11px",color:"#9ca0b8",marginTop:"6px"},children:["Violation #",u," — click to download the signed violation document"]})]}),l&&s.jsx("div",{style:l.ok?{marginTop:"15px",padding:"15px",borderRadius:"6px",textAlign:"center",fontWeight:600,background:"#053321",color:"#9ef7c1",border:"1px solid #0f5132"}:{marginTop:"15px",padding:"15px",borderRadius:"6px",textAlign:"center",fontWeight:600,background:"#3c1114",color:"#ffb3b8",border:"1px solid #f5c6cb"},children:l.msg})]}),n.employeeId&&s.jsxs("div",{style:D.section,children:[s.jsx("h2",{style:D.sectionTitle,children:"Violation History"}),s.jsx(ty,{history:f.history,loading:f.loading})]}),x&&s.jsx(ay,{editing:x==="create"?null:x,onClose:()=>v(null),onSaved:R=>{if(d(),v(null),R){const P={name:R.name,category:R.category,chapter:R.chapter||"",description:R.description||"",minPoints:R.min_points,maxPoints:R.max_points,fields:R.fields,isCustom:!0,customId:R.id};i(P),r($=>({...$,violationType:R.type_key,points:R.min_points}))}else r(P=>Do[P.violationType]||!1?P:{...P,violationType:"",points:1}),i(null)}})]})}const Re={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},modal:{width:"480px",maxWidth:"95vw",background:"#111217",borderRadius:"12px",boxShadow:"0 16px 40px rgba(0,0,0,0.8)",color:"#f8f9fa",overflow:"hidden",border:"1px solid #2a2b3a"},header:{padding:"18px 24px",borderBottom:"1px solid #222",background:"linear-gradient(135deg, #000000, #151622)"},title:{fontSize:"18px",fontWeight:700},subtitle:{fontSize:"12px",color:"#c0c2d6",marginTop:"4px"},body:{padding:"18px 24px 8px 24px"},pill:{background:"#3b2e00",borderRadius:"6px",padding:"8px 10px",fontSize:"12px",color:"#ffd666",border:"1px solid #d4af37",marginBottom:"14px"},label:{fontSize:"13px",fontWeight:600,marginBottom:"4px",color:"#e5e7f1"},input:{width:"100%",padding:"9px 10px",borderRadius:"6px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontSize:"13px",fontFamily:"inherit",marginBottom:"14px",boxSizing:"border-box"},textarea:{width:"100%",minHeight:"80px",resize:"vertical",padding:"9px 10px",borderRadius:"6px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontSize:"13px",fontFamily:"inherit",marginBottom:"14px",boxSizing:"border-box"},footer:{display:"flex",justifyContent:"flex-end",gap:"10px",padding:"16px 24px 20px 24px",background:"#0c0d14",borderTop:"1px solid #222"},btnCancel:{padding:"10px 20px",borderRadius:"6px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontWeight:600,fontSize:"13px",cursor:"pointer"},btnConfirm:{padding:"10px 22px",borderRadius:"6px",border:"none",background:"linear-gradient(135deg, #d4af37 0%, #ffdf8a 100%)",color:"#000",fontWeight:700,fontSize:"13px",cursor:"pointer",textTransform:"uppercase"}},cy=["Corrective Training Completed","Verbal Warning Issued","Written Warning Issued","Management Review","Policy Exception Approved","Data Entry Error","Other"];function dy({violation:e,onConfirm:t,onCancel:n}){const[r,o]=k.useState("Corrective Training Completed"),[i,l]=k.useState(""),[a,u]=k.useState("");if(!e)return null;const c=()=>{t&&t({resolution_type:r,details:i,resolved_by:a})},p=m=>{m.target===m.currentTarget&&n&&n()};return s.jsx("div",{style:Re.overlay,onClick:p,children:s.jsxs("div",{style:Re.modal,onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{style:Re.header,children:[s.jsx("div",{style:Re.title,children:"Negate Violation"}),s.jsxs("div",{style:Re.subtitle,children:["Record resolution for: ",s.jsx("strong",{children:e.violation_name})]})]}),s.jsxs("div",{style:Re.body,children:[s.jsxs("div",{style:Re.pill,children:["⚠ ",e.points," pt",e.points!==1?"s":""," · ",e.incident_date," · ",e.category]}),s.jsx("div",{style:Re.label,children:"Resolution Type"}),s.jsx("select",{style:Re.input,value:r,onChange:m=>o(m.target.value),children:cy.map(m=>s.jsx("option",{value:m,children:m},m))}),s.jsx("div",{style:Re.label,children:"Details / Notes"}),s.jsx("textarea",{style:Re.textarea,placeholder:"Describe the resolution or context…",value:i,onChange:m=>l(m.target.value)}),s.jsx("div",{style:Re.label,children:"Resolved By"}),s.jsx("input",{style:Re.input,placeholder:"Manager or HR name…",value:a,onChange:m=>u(m.target.value)})]}),s.jsxs("div",{style:Re.footer,children:[s.jsx("button",{style:Re.btnCancel,onClick:n,children:"Cancel"}),s.jsx("button",{style:Re.btnConfirm,onClick:c,children:"Confirm Negation"})]})]})})}const G={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center"},modal:{background:"#111217",color:"#f8f9fa",width:"480px",maxWidth:"95vw",borderRadius:"10px",boxShadow:"0 8px 40px rgba(0,0,0,0.8)",border:"1px solid #222",overflow:"hidden"},header:{background:"linear-gradient(135deg, #000000, #151622)",color:"white",padding:"18px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #222"},title:{fontSize:"15px",fontWeight:700},closeBtn:{background:"none",border:"none",color:"white",fontSize:"20px",cursor:"pointer",lineHeight:1},body:{padding:"22px"},tabs:{display:"flex",gap:"4px",marginBottom:"20px"},tab:e=>({flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",fontSize:"12px",fontWeight:700,textAlign:"center",border:"1px solid",background:e?"#1a1c2e":"none",borderColor:e?"#667eea":"#2a2b3a",color:e?"#667eea":"#777"}),label:{fontSize:"11px",color:"#9ca0b8",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"5px"},input:{width:"100%",background:"#0d0e14",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#f8f9fa",padding:"9px 12px",fontSize:"13px",marginBottom:"14px",outline:"none",boxSizing:"border-box"},select:{width:"100%",background:"#0d0e14",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#f8f9fa",padding:"9px 12px",fontSize:"13px",marginBottom:"14px",outline:"none",boxSizing:"border-box"},row:{display:"flex",gap:"10px",justifyContent:"flex-end",marginTop:"6px"},btn:(e,t)=>({padding:"8px 18px",borderRadius:"6px",fontWeight:700,fontSize:"13px",cursor:"pointer",border:`1px solid ${e}`,color:e,background:t||"none"}),error:{background:"#3c1114",border:"1px solid #f5c6cb",borderRadius:"6px",padding:"10px 12px",fontSize:"12px",color:"#ffb3b8",marginBottom:"14px"},success:{background:"#0a2e1f",border:"1px solid #0f5132",borderRadius:"6px",padding:"10px 12px",fontSize:"12px",color:"#9ef7c1",marginBottom:"14px"},mergeWarning:{background:"#2a1f00",border:"1px solid #7a5000",borderRadius:"6px",padding:"12px",fontSize:"12px",color:"#ffc107",marginBottom:"14px",lineHeight:1.5}};function fy({employee:e,onClose:t,onSaved:n}){const[r,o]=k.useState("edit"),[i,l]=k.useState(e.name),[a,u]=k.useState(e.department||""),[c,p]=k.useState(e.supervisor||""),[m,y]=k.useState(""),[S,x]=k.useState(!1),[v,g]=k.useState([]),[f,d]=k.useState(""),[h,b]=k.useState(""),[C,j]=k.useState(null),[T,_]=k.useState(!1);k.useEffect(()=>{r==="merge"&&F.get("/api/employees").then(H=>g(H.data))},[r]);const Q=async()=>{var H,N;y(""),x(!0);try{await F.patch(`/api/employees/${e.id}`,{name:i,department:a,supervisor:c}),n(),t()}catch(L){y(((N=(H=L.response)==null?void 0:H.data)==null?void 0:N.error)||"Failed to save changes")}finally{x(!1)}},U=async()=>{var H,N;if(!f)return b("Select an employee to merge in");b(""),_(!0);try{const L=await F.post(`/api/employees/${e.id}/merge`,{source_id:parseInt(f)});j(L.data),n()}catch(L){b(((N=(H=L.response)==null?void 0:H.data)==null?void 0:N.error)||"Merge failed")}finally{_(!1)}},X=v.filter(H=>H.id!==e.id);return s.jsx("div",{style:G.overlay,onClick:H=>H.target===H.currentTarget&&t(),children:s.jsxs("div",{style:G.modal,children:[s.jsxs("div",{style:G.header,children:[s.jsx("div",{style:G.title,children:"Edit Employee"}),s.jsx("button",{style:G.closeBtn,onClick:t,children:"✕"})]}),s.jsxs("div",{style:G.body,children:[s.jsxs("div",{style:G.tabs,children:[s.jsx("button",{style:G.tab(r==="edit"),onClick:()=>o("edit"),children:"Edit Details"}),s.jsx("button",{style:G.tab(r==="merge"),onClick:()=>o("merge"),children:"Merge Duplicate"})]}),r==="edit"&&s.jsxs(s.Fragment,{children:[m&&s.jsx("div",{style:G.error,children:m}),s.jsx("div",{style:G.label,children:"Full Name"}),s.jsx("input",{style:G.input,value:i,onChange:H=>l(H.target.value)}),s.jsx("div",{style:G.label,children:"Department"}),s.jsxs("select",{style:G.select,value:a,onChange:H=>u(H.target.value),children:[s.jsx("option",{value:"",children:"-- Select Department --"}),Rf.map(H=>s.jsx("option",{value:H,children:H},H))]}),s.jsx("div",{style:G.label,children:"Supervisor"}),s.jsx("input",{style:G.input,value:c,onChange:H=>p(H.target.value),placeholder:"Optional"}),s.jsxs("div",{style:G.row,children:[s.jsx("button",{style:G.btn("#888"),onClick:t,children:"Cancel"}),s.jsx("button",{style:G.btn("#fff","#667eea"),onClick:Q,disabled:S,children:S?"Saving…":"Save Changes"})]})]}),r==="merge"&&s.jsxs(s.Fragment,{children:[C?s.jsxs("div",{style:G.success,children:["✓ Merge complete — ",C.violations_reassigned," violation",C.violations_reassigned!==1?"s":""," reassigned to ",s.jsx("strong",{children:e.name}),". The duplicate record has been removed."]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:G.mergeWarning,children:["⚠ This will reassign ",s.jsx("strong",{children:"all violations"})," from the selected employee into"," ",s.jsx("strong",{children:e.name}),", then permanently delete the duplicate record. This cannot be undone."]}),h&&s.jsx("div",{style:G.error,children:h}),s.jsxs("div",{style:G.label,children:["Duplicate to merge into ",e.name]}),s.jsxs("select",{style:G.select,value:f,onChange:H=>d(H.target.value),children:[s.jsx("option",{value:"",children:"— select employee —"}),X.map(H=>s.jsxs("option",{value:H.id,children:[H.name,H.department?` (${H.department})`:""]},H.id))]}),s.jsxs("div",{style:G.row,children:[s.jsx("button",{style:G.btn("#888"),onClick:t,children:"Cancel"}),s.jsx("button",{style:G.btn("#fff","#c0392b"),onClick:U,disabled:T||!f,children:T?"Merging…":"Merge & Delete Duplicate"})]})]}),C&&s.jsx("div",{style:G.row,children:s.jsx("button",{style:G.btn("#fff","#667eea"),onClick:t,children:"Done"})})]})]})]})})}const Bu={incident_time:"Incident Time",location:"Location / Context",details:"Incident Notes",submitted_by:"Submitted By",witness_name:"Witness / Documenting Officer",amount:"Amount in Question"},ne={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center"},modal:{background:"#111217",color:"#f8f9fa",width:"520px",maxWidth:"95vw",maxHeight:"90vh",overflowY:"auto",borderRadius:"10px",boxShadow:"0 8px 40px rgba(0,0,0,0.8)",border:"1px solid #222"},header:{background:"linear-gradient(135deg, #000000, #151622)",color:"white",padding:"18px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #222",position:"sticky",top:0,zIndex:10},headerLeft:{},title:{fontSize:"15px",fontWeight:700},subtitle:{fontSize:"11px",color:"#9ca0b8",marginTop:"2px"},closeBtn:{background:"none",border:"none",color:"white",fontSize:"20px",cursor:"pointer",lineHeight:1},body:{padding:"22px"},notice:{background:"#0e1a30",border:"1px solid #1e3a5f",borderRadius:"6px",padding:"10px 14px",fontSize:"12px",color:"#7eb8f7",marginBottom:"18px"},label:{fontSize:"11px",color:"#9ca0b8",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"5px"},input:{width:"100%",background:"#0d0e14",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#f8f9fa",padding:"9px 12px",fontSize:"13px",marginBottom:"14px",outline:"none",boxSizing:"border-box"},textarea:{width:"100%",background:"#0d0e14",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#f8f9fa",padding:"9px 12px",fontSize:"13px",marginBottom:"14px",outline:"none",boxSizing:"border-box",minHeight:"80px",resize:"vertical"},divider:{borderTop:"1px solid #1c1d29",margin:"16px 0"},sectionTitle:{fontSize:"11px",fontWeight:700,color:"#9ca0b8",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"12px"},amendRow:{background:"#0d0e14",border:"1px solid #1c1d29",borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",fontSize:"12px"},amendField:{fontWeight:700,color:"#c0c2d6",marginBottom:"4px"},amendOld:{color:"#ff7070",textDecoration:"line-through",marginRight:"6px"},amendNew:{color:"#9ef7c1"},amendMeta:{fontSize:"10px",color:"#555a7a",marginTop:"4px"},row:{display:"flex",gap:"10px",justifyContent:"flex-end",marginTop:"6px"},btn:(e,t)=>({padding:"8px 18px",borderRadius:"6px",fontWeight:700,fontSize:"13px",cursor:"pointer",border:`1px solid ${e}`,color:e,background:t||"none"}),error:{background:"#3c1114",border:"1px solid #f5c6cb",borderRadius:"6px",padding:"10px 12px",fontSize:"12px",color:"#ffb3b8",marginBottom:"14px"}};function py(e){return e?new Date(e).toLocaleString("en-US",{timeZone:"America/Chicago",dateStyle:"medium",timeStyle:"short"}):"—"}function hy({violation:e,onClose:t,onSaved:n}){const[r,o]=k.useState({incident_time:e.incident_time||"",location:e.location||"",details:e.details||"",submitted_by:e.submitted_by||"",witness_name:e.witness_name||"",amount:e.amount||""}),[i,l]=k.useState(""),[a,u]=k.useState(!1),[c,p]=k.useState(""),[m,y]=k.useState([]);k.useEffect(()=>{F.get(`/api/violations/${e.id}/amendments`).then(g=>y(g.data)).catch(()=>{})},[e.id]);const S=Object.entries(r).some(([g,f])=>f!==(e[g]||"")),x=async()=>{var g,f;p(""),u(!0);try{const d=Object.fromEntries(Object.entries(r).filter(([h,b])=>b!==(e[h]||"")));await F.patch(`/api/violations/${e.id}/amend`,{...d,changed_by:i||null}),n(),t()}catch(d){p(((f=(g=d.response)==null?void 0:g.data)==null?void 0:f.error)||"Failed to save amendment")}finally{u(!1)}},v=(g,f)=>o(d=>({...d,[g]:f}));return s.jsx("div",{style:ne.overlay,onClick:g=>g.target===g.currentTarget&&t(),children:s.jsxs("div",{style:ne.modal,children:[s.jsxs("div",{style:ne.header,children:[s.jsxs("div",{style:ne.headerLeft,children:[s.jsx("div",{style:ne.title,children:"Amend Violation"}),s.jsxs("div",{style:ne.subtitle,children:["CPAS-",String(e.id).padStart(5,"0")," · ",e.violation_name," · ",e.incident_date]})]}),s.jsx("button",{style:ne.closeBtn,onClick:t,children:"✕"})]}),s.jsxs("div",{style:ne.body,children:[s.jsx("div",{style:ne.notice,children:"Only non-scoring fields can be amended. Point values, violation type, and incident date are immutable — delete and re-submit if those need to change."}),c&&s.jsx("div",{style:ne.error,children:c}),Object.entries(Bu).map(([g,f])=>s.jsxs("div",{children:[s.jsx("div",{style:ne.label,children:f}),g==="details"?s.jsx("textarea",{style:ne.textarea,value:r[g],onChange:d=>v(g,d.target.value)}):s.jsx("input",{style:ne.input,value:r[g],onChange:d=>v(g,d.target.value)})]},g)),s.jsx("div",{style:ne.label,children:"Your Name (recorded in amendment log)"}),s.jsx("input",{style:ne.input,value:i,onChange:g=>l(g.target.value),placeholder:"Optional but recommended"}),s.jsxs("div",{style:ne.row,children:[s.jsx("button",{style:ne.btn("#888"),onClick:t,children:"Cancel"}),s.jsx("button",{style:ne.btn("#fff",S?"#667eea":"#333"),onClick:x,disabled:!S||a,children:a?"Saving…":"Save Amendment"})]}),m.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:ne.divider}),s.jsxs("div",{style:ne.sectionTitle,children:["Amendment History (",m.length,")"]}),m.map(g=>s.jsxs("div",{style:ne.amendRow,children:[s.jsx("div",{style:ne.amendField,children:Bu[g.field_name]||g.field_name}),s.jsxs("div",{children:[s.jsx("span",{style:ne.amendOld,children:g.old_value||"(empty)"}),s.jsx("span",{style:{color:"#555",marginRight:"6px"},children:"→"}),s.jsx("span",{style:ne.amendNew,children:g.new_value||"(empty)"})]}),s.jsxs("div",{style:ne.amendMeta,children:[g.changed_by?`by ${g.changed_by} · `:"",py(g.created_at)]})]},g.id))]})]})]})})}const al=[{min:30,label:"Separation",color:"#ff1744"},{min:25,label:"Final Decision",color:"#ff6d00"},{min:20,label:"Risk Mitigation",color:"#ff9100"},{min:15,label:"Verification",color:"#ffc400"},{min:10,label:"Administrative Lockdown",color:"#ffea00"},{min:5,label:"Realignment",color:"#b2ff59"},{min:0,label:"Elite Standing",color:"#69f0ae"}];function Iu(e){return al.find(t=>e>=t.min)||al[al.length-1]}function my(e){return e<=7?"#ff4d4f":e<=14?"#ffa940":e<=30?"#fadb14":"#52c41a"}const Se={wrapper:{marginTop:"24px"},sectionHd:{fontSize:"13px",fontWeight:700,color:"#f8f9fa",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"10px"},empty:{color:"#777990",fontStyle:"italic",fontSize:"12px"},row:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",background:"#181924",borderRadius:"6px",border:"1px solid #2a2b3a",marginBottom:"6px"},bar:(e,t)=>({flex:1,height:"6px",background:"#2a2b3a",borderRadius:"3px",overflow:"hidden",position:"relative"}),barFill:(e,t)=>({position:"absolute",left:0,top:0,bottom:0,width:`${Math.min(100,Math.max(0,100-e))}%`,background:t,borderRadius:"3px",transition:"width 0.3s ease"}),pill:e=>({display:"inline-block",padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:700,background:`${e}22`,color:e,border:`1px solid ${e}55`,whiteSpace:"nowrap"}),pts:{fontSize:"13px",fontWeight:700,color:"#f8f9fa",minWidth:"28px",textAlign:"right"},name:{fontSize:"12px",color:"#f8f9fa",fontWeight:600,flex:"0 0 160px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},date:{fontSize:"11px",color:"#9ca0b8",minWidth:"88px"},projBox:{marginTop:"16px",padding:"12px 14px",background:"#0d1117",border:"1px solid #2a2b3a",borderRadius:"6px",fontSize:"12px",color:"#b5b5c0"},projRow:{display:"flex",justifyContent:"space-between",marginBottom:"4px"}};function gy({employeeId:e,currentPoints:t}){const[n,r]=k.useState([]),[o,i]=k.useState(!0);if(k.useEffect(()=>{i(!0),F.get(`/api/employees/${e}/expiration`).then(u=>r(u.data)).finally(()=>i(!1))},[e]),o)return s.jsxs("div",{style:Se.wrapper,children:[s.jsx("div",{style:Se.sectionHd,children:"Point Expiration Timeline"}),s.jsx("div",{style:{...Se.empty},children:"Loading…"})]});if(n.length===0)return s.jsxs("div",{style:Se.wrapper,children:[s.jsx("div",{style:Se.sectionHd,children:"Point Expiration Timeline"}),s.jsx("div",{style:Se.empty,children:"No active violations — nothing to expire."})]});let l=t||0;const a=n.map(u=>{const c=l;l=Math.max(0,l-u.points);const p=Iu(c),m=Iu(l),y=m.min{const c=my(u.days_remaining),p=u.days_remaining/90*100;return s.jsxs("div",{style:Se.row,children:[s.jsx("div",{style:Se.name,title:u.violation_name,children:u.violation_name}),s.jsxs("div",{style:Se.pts,children:["−",u.points]}),s.jsx("div",{style:Se.bar(p,c),children:s.jsx("div",{style:Se.barFill(p,c)})}),s.jsx("div",{style:Se.pill(c),children:u.days_remaining<=0?"Expiring today":`${u.days_remaining}d`}),s.jsx("div",{style:Se.date,children:u.expires_on}),u.tierDropped&&s.jsxs("div",{style:{fontSize:"10px",color:"#69f0ae",whiteSpace:"nowrap"},children:["↓ ",u.tierAfter.label]})]},u.id)}),s.jsxs("div",{style:Se.projBox,children:[s.jsx("div",{style:{fontWeight:700,color:"#f8f9fa",marginBottom:"8px",fontSize:"12px"},children:"Projected score after each expiration"}),a.map((u,c)=>s.jsxs("div",{style:Se.projRow,children:[s.jsxs("span",{style:{color:"#9ca0b8"},children:[u.expires_on," — ",u.violation_name]}),s.jsxs("span",{children:[s.jsxs("span",{style:{color:"#f8f9fa",fontWeight:700},children:[u.pointsAfter," pts"]}),u.tierDropped&&s.jsxs("span",{style:{marginLeft:"8px",color:u.tierAfter.color,fontWeight:700},children:["→ ",u.tierAfter.label]})]})]},u.id))]})]})}const Ie={wrapper:{marginTop:"20px"},sectionHd:{fontSize:"13px",fontWeight:700,color:"#f8f9fa",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},display:{background:"#181924",border:"1px solid #2a2b3a",borderRadius:"6px",padding:"10px 12px",fontSize:"13px",color:"#f8f9fa",minHeight:"36px",cursor:"pointer",position:"relative"},displayEmpty:{color:"#555770",fontStyle:"italic"},editHint:{position:"absolute",right:"8px",top:"8px",fontSize:"10px",color:"#555770"},textarea:{width:"100%",background:"#0d1117",border:"1px solid #4d6fa8",borderRadius:"6px",color:"#f8f9fa",fontSize:"13px",padding:"10px 12px",resize:"vertical",minHeight:"80px",boxSizing:"border-box",fontFamily:"inherit",outline:"none"},actions:{display:"flex",gap:"8px",marginTop:"8px"},saveBtn:{background:"#1a3a6b",border:"1px solid #4d6fa8",color:"#90caf9",borderRadius:"5px",padding:"5px 14px",fontSize:"12px",cursor:"pointer",fontWeight:600},cancelBtn:{background:"none",border:"1px solid #444",color:"#888",borderRadius:"5px",padding:"5px 14px",fontSize:"12px",cursor:"pointer"},saving:{fontSize:"12px",color:"#9ca0b8",alignSelf:"center"},tagRow:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"8px"},tag:{display:"inline-block",padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,background:"#1a2a3a",color:"#90caf9",border:"1px solid #2a3a5a",cursor:"default"}},yy=["On PIP","Union member","Probationary","Pending investigation","FMLA","ADA"];function xy({employeeId:e,initialNotes:t,onSaved:n}){const[r,o]=k.useState(!1),[i,l]=k.useState(t||""),[a,u]=k.useState(t||""),[c,p]=k.useState(!1),[m,y]=k.useState(""),S=Pi(),x=async()=>{var d,h;p(!0),y("");try{await F.patch(`/api/employees/${e}/notes`,{notes:i}),u(i),o(!1),n&&n(i)}catch(b){const C=((h=(d=b.response)==null?void 0:d.data)==null?void 0:h.error)||b.message||"Failed to save notes";y(C),S.error("Notes save failed: "+C)}finally{p(!1)}},v=()=>{l(a),o(!1)},g=d=>{const h=i.trim();h.includes(d)||l(h?`${h} -${d}`:d)},f=a?a.split(` -`).filter(Boolean):[];return s.jsxs("div",{style:Ie.wrapper,children:[s.jsx("div",{style:Ie.sectionHd,children:"Notes & Flags"}),r?s.jsxs("div",{children:[s.jsx("div",{style:{...Ie.tagRow,marginBottom:"6px"},children:yy.map(d=>s.jsxs("button",{style:{...Ie.tag,cursor:"pointer",background:i.includes(d)?"#0e2a3a":"#1a2a3a",opacity:i.includes(d)?.5:1},onClick:()=>g(d),title:"Add tag",children:["+ ",d]},d))}),s.jsx("textarea",{style:Ie.textarea,value:i,onChange:d=>l(d.target.value),placeholder:"Free-text notes — one per line or comma-separated. Does not affect CPAS scoring.",autoFocus:!0}),m&&s.jsxs("div",{style:{fontSize:"12px",color:"#ff7070",marginBottom:"6px"},children:["✗ ",m]}),s.jsxs("div",{style:Ie.actions,children:[s.jsx("button",{style:Ie.saveBtn,onClick:x,disabled:c,children:c?"Saving…":"Save Notes"}),s.jsx("button",{style:Ie.cancelBtn,onClick:v,disabled:c,children:"Cancel"}),c&&s.jsx("span",{style:Ie.saving,children:"Saving…"})]})]}):s.jsxs("div",{style:Ie.display,onClick:()=>{l(a),o(!0)},title:"Click to edit",children:[s.jsx("span",{style:Ie.editHint,children:"✎ edit"}),f.length===0?s.jsx("span",{style:Ie.displayEmpty,children:"No notes — click to add"}):s.jsx("div",{style:Ie.tagRow,children:f.map((d,h)=>s.jsx("span",{style:Ie.tag,children:d},h))})]})]})}const M={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",zIndex:1e3,display:"flex",alignItems:"flex-start",justifyContent:"flex-end"},panel:{background:"#111217",color:"#f8f9fa",width:"680px",maxWidth:"95vw",height:"100vh",overflowY:"auto",boxShadow:"-4px 0 24px rgba(0,0,0,0.7)",display:"flex",flexDirection:"column"},header:{background:"linear-gradient(135deg, #000000, #151622)",color:"white",padding:"24px 28px",position:"sticky",top:0,zIndex:10,borderBottom:"1px solid #222"},headerRow:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},closeBtn:{float:"right",background:"none",border:"none",color:"white",fontSize:"22px",cursor:"pointer",lineHeight:1,marginTop:"-2px"},editEmpBtn:{background:"none",border:"1px solid #555",color:"#ccc",borderRadius:"5px",padding:"4px 10px",fontSize:"11px",cursor:"pointer",marginTop:"8px",fontWeight:600},body:{padding:"24px 28px",flex:1},scoreRow:{display:"flex",gap:"12px",flexWrap:"wrap",marginBottom:"24px"},scoreCard:{flex:"1",minWidth:"100px",background:"#181924",borderRadius:"8px",padding:"14px",textAlign:"center",border:"1px solid #2a2b3a"},scoreNum:{fontSize:"26px",fontWeight:800},scoreLbl:{fontSize:"11px",color:"#b5b5c0",marginTop:"3px"},sectionHd:{fontSize:"13px",fontWeight:700,color:"#f8f9fa",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"10px",marginTop:"24px"},table:{width:"100%",borderCollapse:"collapse",fontSize:"12px",background:"#181924",borderRadius:"6px",overflow:"hidden",border:"1px solid #2a2b3a"},th:{background:"#050608",padding:"8px 10px",textAlign:"left",color:"#f8f9fa",fontWeight:600,fontSize:"11px",textTransform:"uppercase"},td:{padding:"9px 10px",borderBottom:"1px solid #202231",verticalAlign:"top",color:"#f8f9fa"},negatedRow:{background:"#151622",color:"#9ca0b8"},actionBtn:e=>({background:"none",border:`1px solid ${e}`,color:e,borderRadius:"4px",padding:"3px 8px",fontSize:"11px",cursor:"pointer",marginRight:"4px",fontWeight:600}),resTag:{display:"inline-block",padding:"2px 8px",borderRadius:"10px",fontSize:"10px",fontWeight:700,background:"#053321",color:"#9ef7c1",border:"1px solid #0f5132"},pdfBtn:{background:"none",border:"1px solid #d4af37",color:"#ffd666",borderRadius:"4px",padding:"3px 8px",fontSize:"11px",cursor:"pointer",fontWeight:600},amendBtn:{background:"none",border:"1px solid #4db6ac",color:"#4db6ac",borderRadius:"4px",padding:"3px 8px",fontSize:"11px",cursor:"pointer",marginRight:"4px",fontWeight:600},deleteConfirm:{background:"#3c1114",border:"1px solid #f5c6cb",borderRadius:"6px",padding:"12px",marginTop:"8px",fontSize:"12px",color:"#ffb3b8"},amendBadge:{display:"inline-block",marginLeft:"4px",padding:"1px 5px",borderRadius:"8px",fontSize:"9px",fontWeight:700,background:"#0e2a2a",color:"#4db6ac",border:"1px solid #1a4a4a",verticalAlign:"middle"},backfillBtn:{background:"none",border:"1px solid #d4af37",color:"#ffd666",borderRadius:"4px",padding:"4px 10px",fontSize:"11px",cursor:"pointer",fontWeight:600}};function vy({employeeId:e,onClose:t}){const[n,r]=k.useState(null),[o,i]=k.useState(null),[l,a]=k.useState([]),[u,c]=k.useState(!0),[p,m]=k.useState(null),[y,S]=k.useState(null),[x,v]=k.useState(!1),[g,f]=k.useState(null),d=Pi(),h=k.useCallback(()=>{c(!0),Promise.all([F.get(`/api/employees/${e}`),F.get(`/api/employees/${e}/score`),F.get(`/api/violations/employee/${e}?limit=100`)]).then(([N,L,R])=>{r(N.data||null),i(L.data),a(R.data)}).finally(()=>c(!1))},[e]);k.useEffect(()=>{h()},[h]);const b=async(N,L,R)=>{var P,$;try{const z=await F.get(`/api/violations/${N}/pdf`,{responseType:"blob"}),B=window.URL.createObjectURL(new Blob([z.data],{type:"application/pdf"})),I=document.createElement("a");I.href=B,I.download=`CPAS_${(L||"").replace(/[^a-z0-9]/gi,"_")}_${R}.pdf`,document.body.appendChild(I),I.click(),I.remove(),window.URL.revokeObjectURL(B),d.success("PDF downloaded.")}catch(z){d.error("PDF generation failed: "+((($=(P=z.response)==null?void 0:P.data)==null?void 0:$.error)||z.message))}},C=async N=>{var L,R;try{await F.delete(`/api/violations/${N}`),d.success("Violation permanently deleted."),S(null),h()}catch(P){d.error("Delete failed: "+(((R=(L=P.response)==null?void 0:L.data)==null?void 0:R.error)||P.message))}},j=async N=>{var L,R;try{await F.patch(`/api/violations/${N}/restore`),d.success("Violation restored to active."),S(null),h()}catch(P){d.error("Restore failed: "+(((R=(L=P.response)==null?void 0:L.data)==null?void 0:R.error)||P.message))}},T=async()=>{var N,L;if(window.confirm(`Rebuild the "Prior Active Points" snapshot on every violation for this employee? + `,document.head.appendChild(l)},[]),s.jsxs(Ep.Provider,{value:i,children:[e,s.jsx("div",{style:{position:"fixed",top:"16px",right:"16px",zIndex:99999,display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:t.map(l=>s.jsx("div",{style:{pointerEvents:"auto"},children:s.jsx(ry,{toast:l,onDismiss:r})},l.id))})]})}const iy=["Attendance & Punctuality","Administrative Integrity","Financial Stewardship","Operational Response","Professional Conduct","Work From Home","Safety & Security"],ly=[{key:"time",label:"Incident Time"},{key:"minutes",label:"Minutes Late"},{key:"amount",label:"Amount / Value"},{key:"location",label:"Location / Context"},{key:"description",label:"Additional Details"}],W={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},modal:{background:"#111217",border:"1px solid #2a2b3a",borderRadius:"10px",width:"100%",maxWidth:"620px",maxHeight:"90vh",overflowY:"auto",padding:"32px"},title:{color:"#f8f9fa",fontSize:"20px",fontWeight:700,marginBottom:"24px",borderBottom:"1px solid #2a2b3a",paddingBottom:"12px"},label:{fontWeight:600,color:"#e5e7f1",marginBottom:"5px",fontSize:"13px",display:"block"},input:{width:"100%",padding:"10px",border:"1px solid #333544",borderRadius:"4px",fontSize:"14px",fontFamily:"inherit",background:"#050608",color:"#f8f9fa",boxSizing:"border-box"},textarea:{width:"100%",padding:"10px",border:"1px solid #333544",borderRadius:"4px",fontSize:"13px",fontFamily:"inherit",background:"#050608",color:"#f8f9fa",resize:"vertical",minHeight:"80px",boxSizing:"border-box"},group:{marginBottom:"18px"},hint:{fontSize:"11px",color:"#9ca0b8",marginTop:"4px",fontStyle:"italic"},row:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"14px"},toggle:{display:"flex",gap:"8px",marginTop:"6px"},toggleBtn:e=>({padding:"7px 18px",borderRadius:"4px",fontSize:"13px",fontWeight:600,cursor:"pointer",border:"1px solid",background:e?"#d4af37":"#050608",color:e?"#000":"#9ca0b8",borderColor:e?"#d4af37":"#333544"}),fieldGrid:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginTop:"8px"},checkbox:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",color:"#d1d3e0",cursor:"pointer"},btnRow:{display:"flex",gap:"12px",justifyContent:"flex-end",marginTop:"28px",paddingTop:"16px",borderTop:"1px solid #2a2b3a"},btnSave:{padding:"10px 28px",fontSize:"14px",fontWeight:600,border:"none",borderRadius:"6px",cursor:"pointer",background:"linear-gradient(135deg, #d4af37 0%, #ffdf8a 100%)",color:"#000"},btnDanger:{padding:"10px 18px",fontSize:"14px",fontWeight:600,border:"1px solid #721c24",borderRadius:"6px",cursor:"pointer",background:"#3c1114",color:"#ffb3b8"},btnCancel:{padding:"10px 18px",fontSize:"14px",fontWeight:600,border:"1px solid #333544",borderRadius:"6px",cursor:"pointer",background:"#050608",color:"#f8f9fa"},section:{background:"#181924",border:"1px solid #2a2b3a",borderRadius:"6px",padding:"16px",marginBottom:"18px"},secTitle:{color:"#d4af37",fontSize:"13px",fontWeight:700,marginBottom:"12px",textTransform:"uppercase",letterSpacing:"0.05em"},customBadge:{display:"inline-block",marginLeft:"8px",padding:"1px 7px",borderRadius:"10px",fontSize:"10px",fontWeight:700,background:"#1a2e1a",color:"#4caf50",border:"1px solid #4caf50",verticalAlign:"middle"}},sy={name:"",category:"",chapter:"",description:"",pointType:"fixed",fixedPoints:1,minPoints:1,maxPoints:5,fields:["description"]};function ay({onClose:e,onSaved:t,editing:n=null}){const[r,o]=k.useState(sy),[i,l]=k.useState(!1),[a,u]=k.useState(!1),c=Pi();k.useEffect(()=>{if(n){const x=n.min_points!==n.max_points;o({name:n.name,category:n.category,chapter:n.chapter||"",description:n.description||"",pointType:x?"sliding":"fixed",fixedPoints:n.min_points,minPoints:n.min_points,maxPoints:n.max_points,fields:n.fields||["description"]})}},[n]);const f=(x,v)=>o(g=>({...g,[x]:v})),m=x=>{o(v=>({...v,fields:v.fields.includes(x)?v.fields.filter(g=>g!==x):[...v.fields,x]}))},y=async()=>{var p,d;if(!r.name.trim()){c.warning("Violation name is required.");return}if(!r.category.trim()){c.warning("Category is required.");return}const x=r.pointType==="fixed"?parseInt(r.fixedPoints)||1:parseInt(r.minPoints)||1,v=r.pointType==="fixed"?x:parseInt(r.maxPoints)||1;if(v= min points.");return}if(r.fields.length===0){c.warning("Select at least one context field.");return}const g={name:r.name.trim(),category:r.category.trim(),chapter:r.chapter.trim()||null,description:r.description.trim()||null,min_points:x,max_points:v,fields:r.fields};l(!0);try{let h;n?(h=(await F.put(`/api/violation-types/${n.id}`,g)).data,c.success(`"${h.name}" updated.`)):(h=(await F.post("/api/violation-types",g)).data,c.success(`"${h.name}" added to violation types.`)),t(h)}catch(h){c.error(((d=(p=h.response)==null?void 0:p.data)==null?void 0:d.error)||h.message)}finally{l(!1)}},S=async()=>{var x,v;if(n&&window.confirm(`Delete "${n.name}"? This cannot be undone and will fail if any violations reference this type.`)){u(!0);try{await F.delete(`/api/violation-types/${n.id}`),c.success(`"${n.name}" deleted.`),t(null)}catch(g){c.error(((v=(x=g.response)==null?void 0:x.data)==null?void 0:v.error)||g.message)}finally{u(!1)}}};return s.jsx("div",{style:W.overlay,onClick:x=>x.target===x.currentTarget&&e(),children:s.jsxs("div",{style:W.modal,children:[s.jsxs("div",{style:W.title,children:[n?"Edit Violation Type":"Add Violation Type",n&&s.jsx("span",{style:W.customBadge,children:"CUSTOM"})]}),s.jsxs("div",{style:W.section,children:[s.jsx("div",{style:W.secTitle,children:"Violation Definition"}),s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Violation Name *"}),s.jsx("input",{style:W.input,type:"text",value:r.name,onChange:x=>f("name",x.target.value),placeholder:"e.g. Unauthorized System Access"})]}),s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Category *"}),s.jsx("input",{style:W.input,type:"text",list:"vt-categories",value:r.category,onChange:x=>f("category",x.target.value),placeholder:"Select existing or type new category"}),s.jsx("datalist",{id:"vt-categories",children:iy.map(x=>s.jsx("option",{value:x},x))}),s.jsx("div",{style:W.hint,children:"Choose an existing category or type a new one to create a new group in the dropdown."})]}),s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Handbook Reference / Chapter"}),s.jsx("input",{style:W.input,type:"text",value:r.chapter,onChange:x=>f("chapter",x.target.value),placeholder:"e.g. Chapter 4, Section 6"})]}),s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Description / Reference Text"}),s.jsx("textarea",{style:W.textarea,value:r.description,onChange:x=>f("description",x.target.value),placeholder:"Paste the relevant handbook language or describe the infraction in plain terms..."}),s.jsx("div",{style:W.hint,children:"Shown in the context box on the violation form and printed on the PDF."})]})]}),s.jsxs("div",{style:W.section,children:[s.jsx("div",{style:W.secTitle,children:"Point Assignment"}),s.jsx("label",{style:W.label,children:"Point Type"}),s.jsxs("div",{style:W.toggle,children:[s.jsx("button",{type:"button",style:W.toggleBtn(r.pointType==="fixed"),onClick:()=>f("pointType","fixed"),children:"Fixed"}),s.jsx("button",{type:"button",style:W.toggleBtn(r.pointType==="sliding"),onClick:()=>f("pointType","sliding"),children:"Sliding Range"})]}),s.jsx("div",{style:{...W.hint,marginTop:"6px"},children:"Fixed = exact value every time. Sliding = supervisor adjusts within a min/max range."}),r.pointType==="fixed"?s.jsxs("div",{style:{...W.group,marginTop:"14px"},children:[s.jsx("label",{style:W.label,children:"Points (Fixed)"}),s.jsx("input",{style:{...W.input,width:"120px"},type:"number",min:"1",max:"30",value:r.fixedPoints,onChange:x=>f("fixedPoints",x.target.value)})]}):s.jsxs("div",{style:{...W.row,marginTop:"14px"},children:[s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Min Points"}),s.jsx("input",{style:W.input,type:"number",min:"1",max:"30",value:r.minPoints,onChange:x=>f("minPoints",x.target.value)})]}),s.jsxs("div",{style:W.group,children:[s.jsx("label",{style:W.label,children:"Max Points"}),s.jsx("input",{style:W.input,type:"number",min:"1",max:"30",value:r.maxPoints,onChange:x=>f("maxPoints",x.target.value)})]})]})]}),s.jsxs("div",{style:W.section,children:[s.jsx("div",{style:W.secTitle,children:"Context Fields"}),s.jsx("div",{style:W.hint,children:"Select which additional fields appear on the violation form for this type."}),s.jsx("div",{style:W.fieldGrid,children:ly.map(({key:x,label:v})=>s.jsxs("label",{style:W.checkbox,children:[s.jsx("input",{type:"checkbox",checked:r.fields.includes(x),onChange:()=>m(x)}),v]},x))})]}),s.jsxs("div",{style:W.btnRow,children:[n&&s.jsx("button",{type:"button",style:W.btnDanger,onClick:S,disabled:a,children:a?"Deleting…":"Delete Type"}),s.jsx("button",{type:"button",style:W.btnCancel,onClick:e,children:"Cancel"}),s.jsx("button",{type:"button",style:W.btnSave,onClick:y,disabled:i,children:i?"Saving…":n?"Save Changes":"Add Violation Type"})]})]})})}const _p=["Administrative","Business Development","Design and Content","Executive","Implementation and Support","Operations","Production"],D={content:{padding:"32px 40px",background:"#111217",borderRadius:"10px",color:"#f8f9fa"},section:{background:"#181924",borderLeft:"4px solid #d4af37",padding:"20px",marginBottom:"30px",borderRadius:"4px",border:"1px solid #2a2b3a"},sectionTitle:{color:"#f8f9fa",fontSize:"20px",marginBottom:"15px",fontWeight:700},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(250px, 1fr))",gap:"15px",marginTop:"15px"},item:{display:"flex",flexDirection:"column"},label:{fontWeight:600,color:"#e5e7f1",marginBottom:"5px",fontSize:"13px"},input:{padding:"10px",border:"1px solid #333544",borderRadius:"4px",fontSize:"14px",fontFamily:"inherit",background:"#050608",color:"#f8f9fa"},fullCol:{gridColumn:"1 / -1"},contextBox:{background:"#141623",border:"1px solid #333544",borderRadius:"4px",padding:"10px",fontSize:"12px",color:"#d1d3e0",marginTop:"4px"},repeatBadge:{display:"inline-block",marginLeft:"8px",padding:"1px 7px",borderRadius:"10px",fontSize:"11px",fontWeight:700,background:"#3b2e00",color:"#ffd666",border:"1px solid #d4af37"},repeatWarn:{background:"#3b2e00",border:"1px solid #d4af37",borderRadius:"4px",padding:"8px 12px",marginTop:"6px",fontSize:"12px",color:"#ffdf8a"},pointBox:{background:"#181200",border:"2px solid #d4af37",padding:"15px",borderRadius:"6px",marginTop:"15px",textAlign:"center"},pointValue:{fontSize:"24px",fontWeight:"bold",color:"#ffd666",margin:"10px 0"},scoreRow:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"14px",flexWrap:"wrap"},btnRow:{display:"flex",gap:"15px",justifyContent:"center",marginTop:"30px",flexWrap:"wrap"},btnPrimary:{padding:"15px 40px",fontSize:"16px",fontWeight:600,border:"none",borderRadius:"6px",cursor:"pointer",background:"linear-gradient(135deg, #d4af37 0%, #ffdf8a 100%)",color:"#000",textTransform:"uppercase"},btnPdf:{padding:"15px 40px",fontSize:"16px",fontWeight:600,border:"none",borderRadius:"6px",cursor:"pointer",background:"linear-gradient(135deg, #e74c3c 0%, #c0392b 100%)",color:"white",textTransform:"uppercase"},btnSecondary:{padding:"15px 40px",fontSize:"16px",fontWeight:600,border:"1px solid #333544",borderRadius:"6px",cursor:"pointer",background:"#050608",color:"#f8f9fa",textTransform:"uppercase"},ackSection:{background:"#181924",borderLeft:"4px solid #2196F3",padding:"20px",marginBottom:"30px",borderRadius:"4px",border:"1px solid #2a2b3a"},ackHint:{fontSize:"12px",color:"#9ca0b8",marginTop:"4px",fontStyle:"italic"}},sl={employeeId:"",employeeName:"",department:"",supervisor:"",witnessName:"",violationType:"",incidentDate:"",incidentTime:"",amount:"",minutesLate:"",location:"",additionalDetails:"",points:1,acknowledgedBy:"",acknowledgedDate:""};function uy(){var L;const[e,t]=k.useState([]),[n,r]=k.useState(sl),[o,i]=k.useState(null),[l,a]=k.useState(null),[u,c]=k.useState(null),[f,m]=k.useState(!1),[y,S]=k.useState([]),[x,v]=k.useState(null),g=Pi(),p=Gg(n.employeeId||null);k.useEffect(()=>{F.get("/api/employees").then(R=>t(R.data)).catch(()=>{}),d()},[]);const d=()=>{F.get("/api/violation-types").then(R=>S(R.data)).catch(()=>{})},h=k.useMemo(()=>Object.fromEntries(y.map(R=>[R.type_key,R])),[y]),b=k.useMemo(()=>{const R={};return Object.entries(Xg).forEach(([P,$])=>{R[P]=[...$]}),y.forEach(P=>{const $={key:P.type_key,name:P.name,category:P.category,minPoints:P.min_points,maxPoints:P.max_points,chapter:P.chapter||"",description:P.description||"",fields:P.fields,isCustom:!0,customId:P.id};R[P.category]||(R[P.category]=[]),R[P.category].push($)}),R},[y]),C=R=>{if(Do[R])return Do[R];const P=h[R];return P?{name:P.name,category:P.category,chapter:P.chapter||"",description:P.description||"",minPoints:P.min_points,maxPoints:P.max_points,fields:P.fields,isCustom:!0,customId:P.id}:null};k.useEffect(()=>{if(!o||!n.violationType)return;const R=p.countsAllTime[n.violationType];R&&R.count>=1&&o.minPoints!==o.maxPoints?r(P=>({...P,points:o.maxPoints})):r(P=>({...P,points:o.minPoints}))},[n.violationType,o,p.countsAllTime]);const j=R=>{const P=e.find($=>$.id===parseInt(R.target.value));P&&r($=>({...$,employeeId:P.id,employeeName:P.name,department:P.department||"",supervisor:P.supervisor||""}))},T=R=>{const P=R.target.value,$=C(P);i($),r(N=>({...N,violationType:P,points:$?$.minPoints:1}))},_=R=>r(P=>({...P,[R.target.name]:R.target.value})),Q=async R=>{var P,$;if(R.preventDefault(),!n.violationType){g.warning("Please select a violation type.");return}if(!n.employeeName){g.warning("Please enter an employee name.");return}try{const I=(await F.post("/api/employees",{name:n.employeeName,department:n.department,supervisor:n.supervisor})).data.id,K=(await F.post("/api/violations",{employee_id:I,violation_type:n.violationType,violation_name:(o==null?void 0:o.name)||n.violationType,category:(o==null?void 0:o.category)||"General",points:parseInt(n.points),incident_date:n.incidentDate,incident_time:n.incidentTime||null,location:n.location||null,details:n.additionalDetails||null,witness_name:n.witnessName||null,acknowledged_by:n.acknowledgedBy||null,acknowledged_date:n.acknowledgedDate||null,amount:n.amount||null})).data.id;c(K);const le=await F.get("/api/employees");t(le.data),g.success(`Violation #${K} recorded — click Download PDF to save the document.`),a({ok:!0,msg:`✓ Violation #${K} recorded — click Download PDF to save the document.`}),r(sl),i(null)}catch(N){const I=(($=(P=N.response)==null?void 0:P.data)==null?void 0:$.error)||N.message;g.error(`Failed to submit: ${I}`),a({ok:!1,msg:"✗ Error: "+I})}},U=async()=>{if(u){m(!0);try{const R=await F.get(`/api/violations/${u}/pdf`,{responseType:"blob"}),P=window.URL.createObjectURL(new Blob([R.data],{type:"application/pdf"})),$=document.createElement("a");$.href=P,$.download=`CPAS_Violation_${u}.pdf`,document.body.appendChild($),$.click(),$.remove(),window.URL.revokeObjectURL(P),g.success("PDF downloaded successfully.")}catch(R){g.error("PDF generation failed: "+R.message)}finally{m(!1)}}},X=R=>{var P;return(P=o==null?void 0:o.fields)==null?void 0:P.includes(R)},H=R=>p.counts90[R]||0,A=R=>{var P;return(((P=p.countsAllTime[R])==null?void 0:P.count)||0)>=1};return s.jsxs("div",{style:D.content,children:[s.jsxs("div",{style:D.section,children:[s.jsx("h2",{style:D.sectionTitle,children:"Employee Information"}),p.score&&n.employeeId&&s.jsxs("div",{style:D.scoreRow,children:[s.jsx("span",{style:{fontSize:"13px",color:"#d1d3e0",fontWeight:600},children:"Current Standing:"}),s.jsx(Ti,{points:p.score.active_points}),s.jsxs("span",{style:{fontSize:"12px",color:"#9ca0b8"},children:[p.score.violation_count," violation",p.score.violation_count!==1?"s":""," in last 90 days"]})]}),e.length>0&&s.jsxs("div",{style:{marginBottom:"12px"},children:[s.jsx("label",{style:D.label,children:"Quick-Select Existing Employee:"}),s.jsxs("select",{style:D.input,onChange:j,value:n.employeeId||"",children:[s.jsx("option",{value:"",children:"-- Select existing or enter new below --"}),e.map(R=>s.jsxs("option",{value:R.id,children:[R.name,R.department?` — ${R.department}`:""]},R.id))]})]}),s.jsxs("div",{style:D.grid,children:[[["employeeName","Employee Name","John Doe"],["supervisor","Supervisor Name","Jane Smith"],["witnessName","Witness Name (Officer)","Officer Name"]].map(([R,P,$])=>s.jsxs("div",{style:D.item,children:[s.jsxs("label",{style:D.label,children:[P,":"]}),s.jsx("input",{style:D.input,type:"text",name:R,value:n[R],onChange:_,placeholder:$})]},R)),s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Department:"}),s.jsxs("select",{style:D.input,name:"department",value:n.department,onChange:_,children:[s.jsx("option",{value:"",children:"-- Select Department --"}),_p.map(R=>s.jsx("option",{value:R,children:R},R))]})]})]})]}),s.jsxs("form",{onSubmit:Q,children:[s.jsxs("div",{style:D.section,children:[s.jsx("h2",{style:D.sectionTitle,children:"Violation Details"}),s.jsxs("div",{style:D.grid,children:[s.jsxs("div",{style:{...D.item,...D.fullCol},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"5px"},children:[s.jsx("label",{style:{...D.label,marginBottom:0},children:"Violation Type:"}),s.jsxs("div",{style:{display:"flex",gap:"6px"},children:[(o==null?void 0:o.isCustom)&&s.jsx("button",{type:"button",onClick:()=>v(h[n.violationType]),style:{fontSize:"11px",padding:"3px 10px",borderRadius:"4px",border:"1px solid #4caf50",background:"#1a2e1a",color:"#4caf50",cursor:"pointer",fontWeight:600},children:"Edit Type"}),s.jsx("button",{type:"button",onClick:()=>v("create"),style:{fontSize:"11px",padding:"3px 10px",borderRadius:"4px",border:"1px solid #d4af37",background:"#181200",color:"#ffd666",cursor:"pointer",fontWeight:600},title:"Add a new custom violation type",children:"+ Add Type"})]})]}),s.jsxs("select",{style:D.input,value:n.violationType,onChange:T,required:!0,children:[s.jsx("option",{value:"",children:"-- Select Violation Type --"}),Object.entries(b).map(([R,P])=>s.jsx("optgroup",{label:R,children:P.map($=>{const N=H($.key);return s.jsxs("option",{value:$.key,children:[$.name,$.isCustom?" ✦":"",N>0?` ★ ${N}x in 90 days`:""]},$.key)})},R))]}),o&&s.jsxs("div",{style:D.contextBox,children:[s.jsx("strong",{children:o.name}),o.isCustom&&s.jsx("span",{style:{display:"inline-block",marginLeft:"8px",padding:"1px 7px",borderRadius:"10px",fontSize:"10px",fontWeight:700,background:"#1a2e1a",color:"#4caf50",border:"1px solid #4caf50"},children:"Custom"}),A(n.violationType)&&n.employeeId&&s.jsxs("span",{style:D.repeatBadge,children:["★ Repeat — ",(L=p.countsAllTime[n.violationType])==null?void 0:L.count,"x prior"]}),s.jsx("br",{}),o.description,s.jsx("br",{}),s.jsx("span",{style:{fontSize:"11px",color:"#a0a3ba"},children:o.chapter})]}),o&&A(n.violationType)&&n.employeeId&&o.minPoints!==o.maxPoints&&s.jsxs("div",{style:D.repeatWarn,children:[s.jsx("strong",{children:"Repeat offense detected."})," Point slider set to maximum (",o.maxPoints," pts) per recidivist policy. Adjust if needed."]})]}),s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Incident Date:"}),s.jsx("input",{style:D.input,type:"date",name:"incidentDate",value:n.incidentDate,onChange:_,required:!0})]}),X("time")&&s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Incident Time:"}),s.jsx("input",{style:D.input,type:"time",name:"incidentTime",value:n.incidentTime,onChange:_})]}),X("minutes")&&s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Minutes Late:"}),s.jsx("input",{style:D.input,type:"number",name:"minutesLate",value:n.minutesLate,onChange:_,placeholder:"15"})]}),X("amount")&&s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Amount / Value:"}),s.jsx("input",{style:D.input,type:"text",name:"amount",value:n.amount,onChange:_,placeholder:"$150.00"})]}),X("location")&&s.jsxs("div",{style:{...D.item,...D.fullCol},children:[s.jsx("label",{style:D.label,children:"Location / Context:"}),s.jsx("input",{style:D.input,type:"text",name:"location",value:n.location,onChange:_,placeholder:"Office, vehicle, facility area, etc."})]}),X("description")&&s.jsxs("div",{style:{...D.item,...D.fullCol},children:[s.jsx("label",{style:D.label,children:"Additional Details:"}),s.jsx("textarea",{style:{...D.input,resize:"vertical",minHeight:"80px"},name:"additionalDetails",value:n.additionalDetails,onChange:_,placeholder:"Provide specific context, observations, or details..."})]})]}),p.score&&o&&s.jsx(Zg,{currentPoints:p.score.active_points,addingPoints:parseInt(n.points)||0}),o&&s.jsxs("div",{style:D.pointBox,children:[s.jsx("h4",{style:{color:"#ffdf8a",marginBottom:"10px"},children:"CPAS Point Assessment"}),s.jsxs("p",{style:{margin:0},children:[o.name,": ",o.minPoints===o.maxPoints?`${o.minPoints} Points (Fixed)`:`${o.minPoints}–${o.maxPoints} Points`]}),s.jsx("input",{style:{width:"100%",marginTop:"10px"},type:"range",name:"points",min:o.minPoints,max:o.maxPoints,value:n.points,onChange:_}),s.jsxs("div",{style:D.pointValue,children:[n.points," Points"]}),s.jsx("p",{style:{fontSize:"12px",color:"#d1d3e0"},children:"Adjust to reflect severity and context"})]})]}),s.jsxs("div",{style:D.ackSection,children:[s.jsx("h2",{style:{...D.sectionTitle,fontSize:"17px"},children:"Employee Acknowledgment"}),s.jsx("p",{style:{fontSize:"12px",color:"#9ca0b8",marginBottom:"14px",lineHeight:1.6},children:"If the employee is present and acknowledges receipt of this violation, enter their name and the date below. This replaces the blank signature line on the PDF with a recorded acknowledgment."}),s.jsxs("div",{style:D.grid,children:[s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Acknowledged By (Employee Name):"}),s.jsx("input",{style:D.input,type:"text",name:"acknowledgedBy",value:n.acknowledgedBy,onChange:_,placeholder:"Employee's printed name"}),s.jsx("div",{style:D.ackHint,children:"Leave blank if employee is not present or declines to sign"})]}),s.jsxs("div",{style:D.item,children:[s.jsx("label",{style:D.label,children:"Acknowledgment Date:"}),s.jsx("input",{style:D.input,type:"date",name:"acknowledgedDate",value:n.acknowledgedDate,onChange:_}),s.jsx("div",{style:D.ackHint,children:"Date the employee received and acknowledged this document"})]})]})]}),s.jsxs("div",{style:D.btnRow,children:[s.jsx("button",{type:"submit",style:D.btnPrimary,children:"Submit Violation"}),s.jsx("button",{type:"button",style:D.btnSecondary,onClick:()=>{r(sl),i(null),a(null),c(null)},children:"Clear Form"})]}),u&&(l==null?void 0:l.ok)&&s.jsxs("div",{style:{textAlign:"center",marginTop:"16px"},children:[s.jsx("button",{type:"button",style:{...D.btnPdf,opacity:f?.7:1},onClick:U,disabled:f,children:f?"⏳ Generating PDF...":"⬇ Download PDF"}),s.jsxs("p",{style:{fontSize:"11px",color:"#9ca0b8",marginTop:"6px"},children:["Violation #",u," — click to download the signed violation document"]})]}),l&&s.jsx("div",{style:l.ok?{marginTop:"15px",padding:"15px",borderRadius:"6px",textAlign:"center",fontWeight:600,background:"#053321",color:"#9ef7c1",border:"1px solid #0f5132"}:{marginTop:"15px",padding:"15px",borderRadius:"6px",textAlign:"center",fontWeight:600,background:"#3c1114",color:"#ffb3b8",border:"1px solid #f5c6cb"},children:l.msg})]}),n.employeeId&&s.jsxs("div",{style:D.section,children:[s.jsx("h2",{style:D.sectionTitle,children:"Violation History"}),s.jsx(ty,{history:p.history,loading:p.loading})]}),x&&s.jsx(ay,{editing:x==="create"?null:x,onClose:()=>v(null),onSaved:R=>{if(d(),v(null),R){const P={name:R.name,category:R.category,chapter:R.chapter||"",description:R.description||"",minPoints:R.min_points,maxPoints:R.max_points,fields:R.fields,isCustom:!0,customId:R.id};i(P),r($=>({...$,violationType:R.type_key,points:R.min_points}))}else r(P=>Do[P.violationType]||!1?P:{...P,violationType:"",points:1}),i(null)}})]})}const Re={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},modal:{width:"480px",maxWidth:"95vw",background:"#111217",borderRadius:"12px",boxShadow:"0 16px 40px rgba(0,0,0,0.8)",color:"#f8f9fa",overflow:"hidden",border:"1px solid #2a2b3a"},header:{padding:"18px 24px",borderBottom:"1px solid #222",background:"linear-gradient(135deg, #000000, #151622)"},title:{fontSize:"18px",fontWeight:700},subtitle:{fontSize:"12px",color:"#c0c2d6",marginTop:"4px"},body:{padding:"18px 24px 8px 24px"},pill:{background:"#3b2e00",borderRadius:"6px",padding:"8px 10px",fontSize:"12px",color:"#ffd666",border:"1px solid #d4af37",marginBottom:"14px"},label:{fontSize:"13px",fontWeight:600,marginBottom:"4px",color:"#e5e7f1"},input:{width:"100%",padding:"9px 10px",borderRadius:"6px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontSize:"13px",fontFamily:"inherit",marginBottom:"14px",boxSizing:"border-box"},textarea:{width:"100%",minHeight:"80px",resize:"vertical",padding:"9px 10px",borderRadius:"6px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontSize:"13px",fontFamily:"inherit",marginBottom:"14px",boxSizing:"border-box"},footer:{display:"flex",justifyContent:"flex-end",gap:"10px",padding:"16px 24px 20px 24px",background:"#0c0d14",borderTop:"1px solid #222"},btnCancel:{padding:"10px 20px",borderRadius:"6px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontWeight:600,fontSize:"13px",cursor:"pointer"},btnConfirm:{padding:"10px 22px",borderRadius:"6px",border:"none",background:"linear-gradient(135deg, #d4af37 0%, #ffdf8a 100%)",color:"#000",fontWeight:700,fontSize:"13px",cursor:"pointer",textTransform:"uppercase"}},cy=["Corrective Training Completed","Verbal Warning Issued","Written Warning Issued","Management Review","Policy Exception Approved","Data Entry Error","Other"];function dy({violation:e,onConfirm:t,onCancel:n}){const[r,o]=k.useState("Corrective Training Completed"),[i,l]=k.useState(""),[a,u]=k.useState("");if(!e)return null;const c=()=>{t&&t({resolution_type:r,details:i,resolved_by:a})},f=m=>{m.target===m.currentTarget&&n&&n()};return s.jsx("div",{style:Re.overlay,onClick:f,children:s.jsxs("div",{style:Re.modal,onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{style:Re.header,children:[s.jsx("div",{style:Re.title,children:"Negate Violation"}),s.jsxs("div",{style:Re.subtitle,children:["Record resolution for: ",s.jsx("strong",{children:e.violation_name})]})]}),s.jsxs("div",{style:Re.body,children:[s.jsxs("div",{style:Re.pill,children:["⚠ ",e.points," pt",e.points!==1?"s":""," · ",e.incident_date," · ",e.category]}),s.jsx("div",{style:Re.label,children:"Resolution Type"}),s.jsx("select",{style:Re.input,value:r,onChange:m=>o(m.target.value),children:cy.map(m=>s.jsx("option",{value:m,children:m},m))}),s.jsx("div",{style:Re.label,children:"Details / Notes"}),s.jsx("textarea",{style:Re.textarea,placeholder:"Describe the resolution or context…",value:i,onChange:m=>l(m.target.value)}),s.jsx("div",{style:Re.label,children:"Resolved By"}),s.jsx("input",{style:Re.input,placeholder:"Manager or HR name…",value:a,onChange:m=>u(m.target.value)})]}),s.jsxs("div",{style:Re.footer,children:[s.jsx("button",{style:Re.btnCancel,onClick:n,children:"Cancel"}),s.jsx("button",{style:Re.btnConfirm,onClick:c,children:"Confirm Negation"})]})]})})}const G={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center"},modal:{background:"#111217",color:"#f8f9fa",width:"480px",maxWidth:"95vw",borderRadius:"10px",boxShadow:"0 8px 40px rgba(0,0,0,0.8)",border:"1px solid #222",overflow:"hidden"},header:{background:"linear-gradient(135deg, #000000, #151622)",color:"white",padding:"18px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #222"},title:{fontSize:"15px",fontWeight:700},closeBtn:{background:"none",border:"none",color:"white",fontSize:"20px",cursor:"pointer",lineHeight:1},body:{padding:"22px"},tabs:{display:"flex",gap:"4px",marginBottom:"20px"},tab:e=>({flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",fontSize:"12px",fontWeight:700,textAlign:"center",border:"1px solid",background:e?"#1a1c2e":"none",borderColor:e?"#667eea":"#2a2b3a",color:e?"#667eea":"#777"}),label:{fontSize:"11px",color:"#9ca0b8",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"5px"},input:{width:"100%",background:"#0d0e14",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#f8f9fa",padding:"9px 12px",fontSize:"13px",marginBottom:"14px",outline:"none",boxSizing:"border-box"},select:{width:"100%",background:"#0d0e14",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#f8f9fa",padding:"9px 12px",fontSize:"13px",marginBottom:"14px",outline:"none",boxSizing:"border-box"},row:{display:"flex",gap:"10px",justifyContent:"flex-end",marginTop:"6px"},btn:(e,t)=>({padding:"8px 18px",borderRadius:"6px",fontWeight:700,fontSize:"13px",cursor:"pointer",border:`1px solid ${e}`,color:e,background:t||"none"}),error:{background:"#3c1114",border:"1px solid #f5c6cb",borderRadius:"6px",padding:"10px 12px",fontSize:"12px",color:"#ffb3b8",marginBottom:"14px"},success:{background:"#0a2e1f",border:"1px solid #0f5132",borderRadius:"6px",padding:"10px 12px",fontSize:"12px",color:"#9ef7c1",marginBottom:"14px"},mergeWarning:{background:"#2a1f00",border:"1px solid #7a5000",borderRadius:"6px",padding:"12px",fontSize:"12px",color:"#ffc107",marginBottom:"14px",lineHeight:1.5}};function py({employee:e,onClose:t,onSaved:n}){const[r,o]=k.useState("edit"),[i,l]=k.useState(e.name),[a,u]=k.useState(e.department||""),[c,f]=k.useState(e.supervisor||""),[m,y]=k.useState(""),[S,x]=k.useState(!1),[v,g]=k.useState([]),[p,d]=k.useState(""),[h,b]=k.useState(""),[C,j]=k.useState(null),[T,_]=k.useState(!1);k.useEffect(()=>{r==="merge"&&F.get("/api/employees").then(H=>g(H.data))},[r]);const Q=async()=>{var H,A;y(""),x(!0);try{await F.patch(`/api/employees/${e.id}`,{name:i,department:a,supervisor:c}),n(),t()}catch(L){y(((A=(H=L.response)==null?void 0:H.data)==null?void 0:A.error)||"Failed to save changes")}finally{x(!1)}},U=async()=>{var H,A;if(!p)return b("Select an employee to merge in");b(""),_(!0);try{const L=await F.post(`/api/employees/${e.id}/merge`,{source_id:parseInt(p)});j(L.data),n()}catch(L){b(((A=(H=L.response)==null?void 0:H.data)==null?void 0:A.error)||"Merge failed")}finally{_(!1)}},X=v.filter(H=>H.id!==e.id);return s.jsx("div",{style:G.overlay,onClick:H=>H.target===H.currentTarget&&t(),children:s.jsxs("div",{style:G.modal,children:[s.jsxs("div",{style:G.header,children:[s.jsx("div",{style:G.title,children:"Edit Employee"}),s.jsx("button",{style:G.closeBtn,onClick:t,children:"✕"})]}),s.jsxs("div",{style:G.body,children:[s.jsxs("div",{style:G.tabs,children:[s.jsx("button",{style:G.tab(r==="edit"),onClick:()=>o("edit"),children:"Edit Details"}),s.jsx("button",{style:G.tab(r==="merge"),onClick:()=>o("merge"),children:"Merge Duplicate"})]}),r==="edit"&&s.jsxs(s.Fragment,{children:[m&&s.jsx("div",{style:G.error,children:m}),s.jsx("div",{style:G.label,children:"Full Name"}),s.jsx("input",{style:G.input,value:i,onChange:H=>l(H.target.value)}),s.jsx("div",{style:G.label,children:"Department"}),s.jsxs("select",{style:G.select,value:a,onChange:H=>u(H.target.value),children:[s.jsx("option",{value:"",children:"-- Select Department --"}),_p.map(H=>s.jsx("option",{value:H,children:H},H))]}),s.jsx("div",{style:G.label,children:"Supervisor"}),s.jsx("input",{style:G.input,value:c,onChange:H=>f(H.target.value),placeholder:"Optional"}),s.jsxs("div",{style:G.row,children:[s.jsx("button",{style:G.btn("#888"),onClick:t,children:"Cancel"}),s.jsx("button",{style:G.btn("#fff","#667eea"),onClick:Q,disabled:S,children:S?"Saving…":"Save Changes"})]})]}),r==="merge"&&s.jsxs(s.Fragment,{children:[C?s.jsxs("div",{style:G.success,children:["✓ Merge complete — ",C.violations_reassigned," violation",C.violations_reassigned!==1?"s":""," reassigned to ",s.jsx("strong",{children:e.name}),". The duplicate record has been removed."]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:G.mergeWarning,children:["⚠ This will reassign ",s.jsx("strong",{children:"all violations"})," from the selected employee into"," ",s.jsx("strong",{children:e.name}),", then permanently delete the duplicate record. This cannot be undone."]}),h&&s.jsx("div",{style:G.error,children:h}),s.jsxs("div",{style:G.label,children:["Duplicate to merge into ",e.name]}),s.jsxs("select",{style:G.select,value:p,onChange:H=>d(H.target.value),children:[s.jsx("option",{value:"",children:"— select employee —"}),X.map(H=>s.jsxs("option",{value:H.id,children:[H.name,H.department?` (${H.department})`:""]},H.id))]}),s.jsxs("div",{style:G.row,children:[s.jsx("button",{style:G.btn("#888"),onClick:t,children:"Cancel"}),s.jsx("button",{style:G.btn("#fff","#c0392b"),onClick:U,disabled:T||!p,children:T?"Merging…":"Merge & Delete Duplicate"})]})]}),C&&s.jsx("div",{style:G.row,children:s.jsx("button",{style:G.btn("#fff","#667eea"),onClick:t,children:"Done"})})]})]})]})})}const Iu={incident_time:"Incident Time",location:"Location / Context",details:"Incident Notes",submitted_by:"Submitted By",witness_name:"Witness / Documenting Officer",amount:"Amount in Question"},ne={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center"},modal:{background:"#111217",color:"#f8f9fa",width:"520px",maxWidth:"95vw",maxHeight:"90vh",overflowY:"auto",borderRadius:"10px",boxShadow:"0 8px 40px rgba(0,0,0,0.8)",border:"1px solid #222"},header:{background:"linear-gradient(135deg, #000000, #151622)",color:"white",padding:"18px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #222",position:"sticky",top:0,zIndex:10},headerLeft:{},title:{fontSize:"15px",fontWeight:700},subtitle:{fontSize:"11px",color:"#9ca0b8",marginTop:"2px"},closeBtn:{background:"none",border:"none",color:"white",fontSize:"20px",cursor:"pointer",lineHeight:1},body:{padding:"22px"},notice:{background:"#0e1a30",border:"1px solid #1e3a5f",borderRadius:"6px",padding:"10px 14px",fontSize:"12px",color:"#7eb8f7",marginBottom:"18px"},label:{fontSize:"11px",color:"#9ca0b8",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"5px"},input:{width:"100%",background:"#0d0e14",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#f8f9fa",padding:"9px 12px",fontSize:"13px",marginBottom:"14px",outline:"none",boxSizing:"border-box"},textarea:{width:"100%",background:"#0d0e14",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#f8f9fa",padding:"9px 12px",fontSize:"13px",marginBottom:"14px",outline:"none",boxSizing:"border-box",minHeight:"80px",resize:"vertical"},divider:{borderTop:"1px solid #1c1d29",margin:"16px 0"},sectionTitle:{fontSize:"11px",fontWeight:700,color:"#9ca0b8",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"12px"},amendRow:{background:"#0d0e14",border:"1px solid #1c1d29",borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",fontSize:"12px"},amendField:{fontWeight:700,color:"#c0c2d6",marginBottom:"4px"},amendOld:{color:"#ff7070",textDecoration:"line-through",marginRight:"6px"},amendNew:{color:"#9ef7c1"},amendMeta:{fontSize:"10px",color:"#555a7a",marginTop:"4px"},row:{display:"flex",gap:"10px",justifyContent:"flex-end",marginTop:"6px"},btn:(e,t)=>({padding:"8px 18px",borderRadius:"6px",fontWeight:700,fontSize:"13px",cursor:"pointer",border:`1px solid ${e}`,color:e,background:t||"none"}),error:{background:"#3c1114",border:"1px solid #f5c6cb",borderRadius:"6px",padding:"10px 12px",fontSize:"12px",color:"#ffb3b8",marginBottom:"14px"}};function fy(e){return e?new Date(e).toLocaleString("en-US",{timeZone:"America/Chicago",dateStyle:"medium",timeStyle:"short"}):"—"}function hy({violation:e,onClose:t,onSaved:n}){const[r,o]=k.useState({incident_time:e.incident_time||"",location:e.location||"",details:e.details||"",submitted_by:e.submitted_by||"",witness_name:e.witness_name||"",amount:e.amount||""}),[i,l]=k.useState(""),[a,u]=k.useState(!1),[c,f]=k.useState(""),[m,y]=k.useState([]);k.useEffect(()=>{F.get(`/api/violations/${e.id}/amendments`).then(g=>y(g.data)).catch(()=>{})},[e.id]);const S=Object.entries(r).some(([g,p])=>p!==(e[g]||"")),x=async()=>{var g,p;f(""),u(!0);try{const d=Object.fromEntries(Object.entries(r).filter(([h,b])=>b!==(e[h]||"")));await F.patch(`/api/violations/${e.id}/amend`,{...d,changed_by:i||null}),n(),t()}catch(d){f(((p=(g=d.response)==null?void 0:g.data)==null?void 0:p.error)||"Failed to save amendment")}finally{u(!1)}},v=(g,p)=>o(d=>({...d,[g]:p}));return s.jsx("div",{style:ne.overlay,onClick:g=>g.target===g.currentTarget&&t(),children:s.jsxs("div",{style:ne.modal,children:[s.jsxs("div",{style:ne.header,children:[s.jsxs("div",{style:ne.headerLeft,children:[s.jsx("div",{style:ne.title,children:"Amend Violation"}),s.jsxs("div",{style:ne.subtitle,children:["CPAS-",String(e.id).padStart(5,"0")," · ",e.violation_name," · ",e.incident_date]})]}),s.jsx("button",{style:ne.closeBtn,onClick:t,children:"✕"})]}),s.jsxs("div",{style:ne.body,children:[s.jsx("div",{style:ne.notice,children:"Only non-scoring fields can be amended. Point values, violation type, and incident date are immutable — delete and re-submit if those need to change."}),c&&s.jsx("div",{style:ne.error,children:c}),Object.entries(Iu).map(([g,p])=>s.jsxs("div",{children:[s.jsx("div",{style:ne.label,children:p}),g==="details"?s.jsx("textarea",{style:ne.textarea,value:r[g],onChange:d=>v(g,d.target.value)}):s.jsx("input",{style:ne.input,value:r[g],onChange:d=>v(g,d.target.value)})]},g)),s.jsx("div",{style:ne.label,children:"Your Name (recorded in amendment log)"}),s.jsx("input",{style:ne.input,value:i,onChange:g=>l(g.target.value),placeholder:"Optional but recommended"}),s.jsxs("div",{style:ne.row,children:[s.jsx("button",{style:ne.btn("#888"),onClick:t,children:"Cancel"}),s.jsx("button",{style:ne.btn("#fff",S?"#667eea":"#333"),onClick:x,disabled:!S||a,children:a?"Saving…":"Save Amendment"})]}),m.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:ne.divider}),s.jsxs("div",{style:ne.sectionTitle,children:["Amendment History (",m.length,")"]}),m.map(g=>s.jsxs("div",{style:ne.amendRow,children:[s.jsx("div",{style:ne.amendField,children:Iu[g.field_name]||g.field_name}),s.jsxs("div",{children:[s.jsx("span",{style:ne.amendOld,children:g.old_value||"(empty)"}),s.jsx("span",{style:{color:"#555",marginRight:"6px"},children:"→"}),s.jsx("span",{style:ne.amendNew,children:g.new_value||"(empty)"})]}),s.jsxs("div",{style:ne.amendMeta,children:[g.changed_by?`by ${g.changed_by} · `:"",fy(g.created_at)]})]},g.id))]})]})]})})}const al=[{min:30,label:"Separation",color:"#ff1744"},{min:25,label:"Final Decision",color:"#ff6d00"},{min:20,label:"Risk Mitigation",color:"#ff9100"},{min:15,label:"Verification",color:"#ffc400"},{min:10,label:"Administrative Lockdown",color:"#ffea00"},{min:5,label:"Realignment",color:"#b2ff59"},{min:0,label:"Elite Standing",color:"#69f0ae"}];function Bu(e){return al.find(t=>e>=t.min)||al[al.length-1]}function my(e){return e<=7?"#ff4d4f":e<=14?"#ffa940":e<=30?"#fadb14":"#52c41a"}const Se={wrapper:{marginTop:"24px"},sectionHd:{fontSize:"13px",fontWeight:700,color:"#f8f9fa",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"10px"},empty:{color:"#777990",fontStyle:"italic",fontSize:"12px"},row:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",background:"#181924",borderRadius:"6px",border:"1px solid #2a2b3a",marginBottom:"6px"},bar:(e,t)=>({flex:1,height:"6px",background:"#2a2b3a",borderRadius:"3px",overflow:"hidden",position:"relative"}),barFill:(e,t)=>({position:"absolute",left:0,top:0,bottom:0,width:`${Math.min(100,Math.max(0,100-e))}%`,background:t,borderRadius:"3px",transition:"width 0.3s ease"}),pill:e=>({display:"inline-block",padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:700,background:`${e}22`,color:e,border:`1px solid ${e}55`,whiteSpace:"nowrap"}),pts:{fontSize:"13px",fontWeight:700,color:"#f8f9fa",minWidth:"28px",textAlign:"right"},name:{fontSize:"12px",color:"#f8f9fa",fontWeight:600,flex:"0 0 160px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},date:{fontSize:"11px",color:"#9ca0b8",minWidth:"88px"},projBox:{marginTop:"16px",padding:"12px 14px",background:"#0d1117",border:"1px solid #2a2b3a",borderRadius:"6px",fontSize:"12px",color:"#b5b5c0"},projRow:{display:"flex",justifyContent:"space-between",marginBottom:"4px"}};function gy({employeeId:e,currentPoints:t}){const[n,r]=k.useState([]),[o,i]=k.useState(!0);if(k.useEffect(()=>{i(!0),F.get(`/api/employees/${e}/expiration`).then(u=>r(u.data)).finally(()=>i(!1))},[e]),o)return s.jsxs("div",{style:Se.wrapper,children:[s.jsx("div",{style:Se.sectionHd,children:"Point Expiration Timeline"}),s.jsx("div",{style:{...Se.empty},children:"Loading…"})]});if(n.length===0)return s.jsxs("div",{style:Se.wrapper,children:[s.jsx("div",{style:Se.sectionHd,children:"Point Expiration Timeline"}),s.jsx("div",{style:Se.empty,children:"No active violations — nothing to expire."})]});let l=t||0;const a=n.map(u=>{const c=l;l=Math.max(0,l-u.points);const f=Bu(c),m=Bu(l),y=m.min{const c=my(u.days_remaining),f=u.days_remaining/90*100;return s.jsxs("div",{style:Se.row,children:[s.jsx("div",{style:Se.name,title:u.violation_name,children:u.violation_name}),s.jsxs("div",{style:Se.pts,children:["−",u.points]}),s.jsx("div",{style:Se.bar(f,c),children:s.jsx("div",{style:Se.barFill(f,c)})}),s.jsx("div",{style:Se.pill(c),children:u.days_remaining<=0?"Expiring today":`${u.days_remaining}d`}),s.jsx("div",{style:Se.date,children:u.expires_on}),u.tierDropped&&s.jsxs("div",{style:{fontSize:"10px",color:"#69f0ae",whiteSpace:"nowrap"},children:["↓ ",u.tierAfter.label]})]},u.id)}),s.jsxs("div",{style:Se.projBox,children:[s.jsx("div",{style:{fontWeight:700,color:"#f8f9fa",marginBottom:"8px",fontSize:"12px"},children:"Projected score after each expiration"}),a.map((u,c)=>s.jsxs("div",{style:Se.projRow,children:[s.jsxs("span",{style:{color:"#9ca0b8"},children:[u.expires_on," — ",u.violation_name]}),s.jsxs("span",{children:[s.jsxs("span",{style:{color:"#f8f9fa",fontWeight:700},children:[u.pointsAfter," pts"]}),u.tierDropped&&s.jsxs("span",{style:{marginLeft:"8px",color:u.tierAfter.color,fontWeight:700},children:["→ ",u.tierAfter.label]})]})]},u.id))]})]})}const Be={wrapper:{marginTop:"20px"},sectionHd:{fontSize:"13px",fontWeight:700,color:"#f8f9fa",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},display:{background:"#181924",border:"1px solid #2a2b3a",borderRadius:"6px",padding:"10px 12px",fontSize:"13px",color:"#f8f9fa",minHeight:"36px",cursor:"pointer",position:"relative"},displayEmpty:{color:"#555770",fontStyle:"italic"},editHint:{position:"absolute",right:"8px",top:"8px",fontSize:"10px",color:"#555770"},textarea:{width:"100%",background:"#0d1117",border:"1px solid #4d6fa8",borderRadius:"6px",color:"#f8f9fa",fontSize:"13px",padding:"10px 12px",resize:"vertical",minHeight:"80px",boxSizing:"border-box",fontFamily:"inherit",outline:"none"},actions:{display:"flex",gap:"8px",marginTop:"8px"},saveBtn:{background:"#1a3a6b",border:"1px solid #4d6fa8",color:"#90caf9",borderRadius:"5px",padding:"5px 14px",fontSize:"12px",cursor:"pointer",fontWeight:600},cancelBtn:{background:"none",border:"1px solid #444",color:"#888",borderRadius:"5px",padding:"5px 14px",fontSize:"12px",cursor:"pointer"},saving:{fontSize:"12px",color:"#9ca0b8",alignSelf:"center"},tagRow:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"8px"},tag:{display:"inline-block",padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,background:"#1a2a3a",color:"#90caf9",border:"1px solid #2a3a5a",cursor:"default"}},yy=["On PIP","Union member","Probationary","Pending investigation","FMLA","ADA"];function xy({employeeId:e,initialNotes:t,onSaved:n}){const[r,o]=k.useState(!1),[i,l]=k.useState(t||""),[a,u]=k.useState(t||""),[c,f]=k.useState(!1),[m,y]=k.useState(""),S=Pi(),x=async()=>{var d,h;f(!0),y("");try{await F.patch(`/api/employees/${e}/notes`,{notes:i}),u(i),o(!1),n&&n(i)}catch(b){const C=((h=(d=b.response)==null?void 0:d.data)==null?void 0:h.error)||b.message||"Failed to save notes";y(C),S.error("Notes save failed: "+C)}finally{f(!1)}},v=()=>{l(a),o(!1)},g=d=>{const h=i.trim();h.includes(d)||l(h?`${h} +${d}`:d)},p=a?a.split(` +`).filter(Boolean):[];return s.jsxs("div",{style:Be.wrapper,children:[s.jsx("div",{style:Be.sectionHd,children:"Notes & Flags"}),r?s.jsxs("div",{children:[s.jsx("div",{style:{...Be.tagRow,marginBottom:"6px"},children:yy.map(d=>s.jsxs("button",{style:{...Be.tag,cursor:"pointer",background:i.includes(d)?"#0e2a3a":"#1a2a3a",opacity:i.includes(d)?.5:1},onClick:()=>g(d),title:"Add tag",children:["+ ",d]},d))}),s.jsx("textarea",{style:Be.textarea,value:i,onChange:d=>l(d.target.value),placeholder:"Free-text notes — one per line or comma-separated. Does not affect CPAS scoring.",autoFocus:!0}),m&&s.jsxs("div",{style:{fontSize:"12px",color:"#ff7070",marginBottom:"6px"},children:["✗ ",m]}),s.jsxs("div",{style:Be.actions,children:[s.jsx("button",{style:Be.saveBtn,onClick:x,disabled:c,children:c?"Saving…":"Save Notes"}),s.jsx("button",{style:Be.cancelBtn,onClick:v,disabled:c,children:"Cancel"}),c&&s.jsx("span",{style:Be.saving,children:"Saving…"})]})]}):s.jsxs("div",{style:Be.display,onClick:()=>{l(a),o(!0)},title:"Click to edit",children:[s.jsx("span",{style:Be.editHint,children:"✎ edit"}),p.length===0?s.jsx("span",{style:Be.displayEmpty,children:"No notes — click to add"}):s.jsx("div",{style:Be.tagRow,children:p.map((d,h)=>s.jsx("span",{style:Be.tag,children:d},h))})]})]})}const M={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",zIndex:1e3,display:"flex",alignItems:"flex-start",justifyContent:"flex-end"},panel:{background:"#111217",color:"#f8f9fa",width:"680px",maxWidth:"95vw",height:"100vh",overflowY:"auto",boxShadow:"-4px 0 24px rgba(0,0,0,0.7)",display:"flex",flexDirection:"column"},header:{background:"linear-gradient(135deg, #000000, #151622)",color:"white",padding:"24px 28px",position:"sticky",top:0,zIndex:10,borderBottom:"1px solid #222"},headerRow:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},closeBtn:{float:"right",background:"none",border:"none",color:"white",fontSize:"22px",cursor:"pointer",lineHeight:1,marginTop:"-2px"},editEmpBtn:{background:"none",border:"1px solid #555",color:"#ccc",borderRadius:"5px",padding:"4px 10px",fontSize:"11px",cursor:"pointer",marginTop:"8px",fontWeight:600},body:{padding:"24px 28px",flex:1},scoreRow:{display:"flex",gap:"12px",flexWrap:"wrap",marginBottom:"24px"},scoreCard:{flex:"1",minWidth:"100px",background:"#181924",borderRadius:"8px",padding:"14px",textAlign:"center",border:"1px solid #2a2b3a"},scoreNum:{fontSize:"26px",fontWeight:800},scoreLbl:{fontSize:"11px",color:"#b5b5c0",marginTop:"3px"},sectionHd:{fontSize:"13px",fontWeight:700,color:"#f8f9fa",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"10px",marginTop:"24px"},table:{width:"100%",borderCollapse:"collapse",fontSize:"12px",background:"#181924",borderRadius:"6px",overflow:"hidden",border:"1px solid #2a2b3a"},th:{background:"#050608",padding:"8px 10px",textAlign:"left",color:"#f8f9fa",fontWeight:600,fontSize:"11px",textTransform:"uppercase"},td:{padding:"9px 10px",borderBottom:"1px solid #202231",verticalAlign:"top",color:"#f8f9fa"},negatedRow:{background:"#151622",color:"#9ca0b8"},actionBtn:e=>({background:"none",border:`1px solid ${e}`,color:e,borderRadius:"4px",padding:"3px 8px",fontSize:"11px",cursor:"pointer",marginRight:"4px",fontWeight:600}),resTag:{display:"inline-block",padding:"2px 8px",borderRadius:"10px",fontSize:"10px",fontWeight:700,background:"#053321",color:"#9ef7c1",border:"1px solid #0f5132"},pdfBtn:{background:"none",border:"1px solid #d4af37",color:"#ffd666",borderRadius:"4px",padding:"3px 8px",fontSize:"11px",cursor:"pointer",fontWeight:600},amendBtn:{background:"none",border:"1px solid #4db6ac",color:"#4db6ac",borderRadius:"4px",padding:"3px 8px",fontSize:"11px",cursor:"pointer",marginRight:"4px",fontWeight:600},deleteConfirm:{background:"#3c1114",border:"1px solid #f5c6cb",borderRadius:"6px",padding:"12px",marginTop:"8px",fontSize:"12px",color:"#ffb3b8"},amendBadge:{display:"inline-block",marginLeft:"4px",padding:"1px 5px",borderRadius:"8px",fontSize:"9px",fontWeight:700,background:"#0e2a2a",color:"#4db6ac",border:"1px solid #1a4a4a",verticalAlign:"middle"},backfillBtn:{background:"none",border:"1px solid #d4af37",color:"#ffd666",borderRadius:"4px",padding:"4px 10px",fontSize:"11px",cursor:"pointer",fontWeight:600}};function vy({employeeId:e,onClose:t}){const[n,r]=k.useState(null),[o,i]=k.useState(null),[l,a]=k.useState([]),[u,c]=k.useState(!0),[f,m]=k.useState(null),[y,S]=k.useState(null),[x,v]=k.useState(!1),[g,p]=k.useState(null),d=Pi(),h=k.useCallback(()=>{c(!0),Promise.all([F.get(`/api/employees/${e}`),F.get(`/api/employees/${e}/score`),F.get(`/api/violations/employee/${e}?limit=100`)]).then(([A,L,R])=>{r(A.data||null),i(L.data),a(R.data)}).finally(()=>c(!1))},[e]);k.useEffect(()=>{h()},[h]);const b=async(A,L,R)=>{var P,$;try{const N=await F.get(`/api/violations/${A}/pdf`,{responseType:"blob"}),I=window.URL.createObjectURL(new Blob([N.data],{type:"application/pdf"})),B=document.createElement("a");B.href=I,B.download=`CPAS_${(L||"").replace(/[^a-z0-9]/gi,"_")}_${R}.pdf`,document.body.appendChild(B),B.click(),B.remove(),window.URL.revokeObjectURL(I),d.success("PDF downloaded.")}catch(N){d.error("PDF generation failed: "+((($=(P=N.response)==null?void 0:P.data)==null?void 0:$.error)||N.message))}},C=async A=>{var L,R;try{await F.delete(`/api/violations/${A}`),d.success("Violation permanently deleted."),S(null),h()}catch(P){d.error("Delete failed: "+(((R=(L=P.response)==null?void 0:L.data)==null?void 0:R.error)||P.message))}},j=async A=>{var L,R;try{await F.patch(`/api/violations/${A}/restore`),d.success("Violation restored to active."),S(null),h()}catch(P){d.error("Restore failed: "+(((R=(L=P.response)==null?void 0:L.data)==null?void 0:R.error)||P.message))}},T=async()=>{var A,L;if(window.confirm(`Rebuild the "Prior Active Points" snapshot on every violation for this employee? -Use this after back-dating a violation if older PDFs no longer reflect the correct prior-points total. Existing PDFs will regenerate with up-to-date numbers.`))try{const R=await F.post(`/api/employees/${e}/recompute-snapshots`),{scanned:P,updated:$}=R.data;$===0?d.success(`Snapshots already up to date (${P} checked).`):d.success(`Updated ${$} of ${P} snapshot${$===1?"":"s"}.`),h()}catch(R){d.error("Backfill failed: "+(((L=(N=R.response)==null?void 0:N.data)==null?void 0:L.error)||R.message))}},_=async({resolution_type:N,details:L,resolved_by:R})=>{var P,$;try{await F.patch(`/api/violations/${p.id}/negate`,{resolution_type:N,details:L,resolved_by:R}),d.success("Violation negated."),m(null),S(null),h()}catch(z){d.error("Negate failed: "+((($=(P=z.response)==null?void 0:P.data)==null?void 0:$.error)||z.message))}},Q=o?Kt(o.active_points):null,U=l.filter(N=>!N.negated),X=l.filter(N=>N.negated),H=N=>{N.target===N.currentTarget&&t()};return s.jsxs("div",{style:M.overlay,onClick:H,children:[s.jsxs("div",{style:M.panel,onClick:N=>N.stopPropagation(),children:[s.jsx("div",{style:M.header,children:s.jsxs("div",{style:M.headerRow,children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:"18px",fontWeight:700},children:n?n.name:"Employee"}),n&&s.jsxs("div",{style:{fontSize:"12px",color:"#b5b5c0",marginTop:"4px"},children:[n.department," ",n.supervisor&&`· Supervisor: ${n.supervisor}`]}),n&&s.jsx("button",{style:M.editEmpBtn,onClick:()=>v(!0),children:"✎ Edit Employee"})]}),s.jsx("button",{style:M.closeBtn,onClick:t,children:"✕"})]})}),s.jsx("div",{style:M.body,children:u?s.jsx("div",{style:{padding:"40px",textAlign:"center",color:"#b5b5c0"},children:"Loading…"}):s.jsxs(s.Fragment,{children:[o&&s.jsxs("div",{style:M.scoreRow,children:[s.jsxs("div",{style:M.scoreCard,children:[s.jsx("div",{style:{...M.scoreNum,color:(Q==null?void 0:Q.color)||"#f8f9fa"},children:o.active_points}),s.jsx("div",{style:M.scoreLbl,children:"Active Points"})]}),s.jsxs("div",{style:M.scoreCard,children:[s.jsx("div",{style:M.scoreNum,children:o.total_violations}),s.jsx("div",{style:M.scoreLbl,children:"Total Violations"})]}),s.jsxs("div",{style:M.scoreCard,children:[s.jsx("div",{style:M.scoreNum,children:o.negated_count}),s.jsx("div",{style:M.scoreLbl,children:"Negated"})]}),s.jsxs("div",{style:{...M.scoreCard,minWidth:"140px"},children:[s.jsx("div",{style:{fontSize:"13px",fontWeight:700,color:(Q==null?void 0:Q.color)||"#f8f9fa"},children:Q?Q.label:"—"}),s.jsx("div",{style:M.scoreLbl,children:"Current Tier"})]})]}),o&&s.jsx(Ti,{points:o.active_points,style:{marginBottom:"20px"}}),n&&s.jsx(xy,{employeeId:e,initialNotes:n.notes,onSaved:N=>r(L=>({...L,notes:N}))}),o&&o.active_points>0&&s.jsx(gy,{employeeId:e,currentPoints:o.active_points}),s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"24px",marginBottom:"10px"},children:[s.jsx("div",{style:{...M.sectionHd,marginTop:0,marginBottom:0},children:"Active Violations"}),l.length>0&&s.jsx("button",{style:M.backfillBtn,onClick:T,title:"Rebuild prior-points snapshot on each violation. Use after a back-dated insert if older PDFs show the wrong Prior Active Points.",children:"↻ Backfill Snapshots"})]}),U.length===0?s.jsx("div",{style:{color:"#777990",fontStyle:"italic",fontSize:"12px"},children:"No active violations on record."}):s.jsxs("table",{style:M.table,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:M.th,children:"Date"}),s.jsx("th",{style:M.th,children:"Violation"}),s.jsx("th",{style:M.th,children:"Pts"}),s.jsx("th",{style:M.th,children:"Actions"})]})}),s.jsx("tbody",{children:U.map(N=>s.jsxs("tr",{children:[s.jsx("td",{style:M.td,children:N.incident_date}),s.jsxs("td",{style:M.td,children:[s.jsxs("div",{style:{fontWeight:600},children:[N.violation_name,N.amendment_count>0&&s.jsxs("span",{style:M.amendBadge,children:[N.amendment_count," edit",N.amendment_count!==1?"s":""]})]}),s.jsx("div",{style:{fontSize:"10px",color:"#9ca0b8"},children:N.category}),N.details&&s.jsx("div",{style:{fontSize:"10px",color:"#b5b5c0",marginTop:"2px"},children:N.details})]}),s.jsx("td",{style:{...M.td,fontWeight:700},children:N.points}),s.jsxs("td",{style:M.td,children:[s.jsx("button",{style:M.amendBtn,onClick:L=>{L.stopPropagation(),f(N)},children:"Amend"}),s.jsx("button",{style:M.actionBtn("#ffc107"),onClick:L=>{L.stopPropagation(),m(N),S(null)},children:"Negate"}),s.jsx("button",{style:M.actionBtn("#ff4d4f"),onClick:L=>{L.stopPropagation(),S(y===N.id?null:N.id)},children:y===N.id?"Cancel":"Delete"}),s.jsx("button",{style:M.pdfBtn,onClick:L=>{L.stopPropagation(),b(N.id,n==null?void 0:n.name,N.incident_date)},children:"PDF"}),y===N.id&&s.jsxs("div",{style:M.deleteConfirm,children:["Permanently delete? This cannot be undone.",s.jsxs("div",{style:{marginTop:"8px"},children:[s.jsx("button",{style:M.actionBtn("#ff4d4f"),onClick:L=>{L.stopPropagation(),C(N.id)},children:"Confirm Delete"}),s.jsx("button",{style:M.actionBtn("#888"),onClick:L=>{L.stopPropagation(),S(null)},children:"Cancel"})]})]})]})]},N.id))})]}),X.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:M.sectionHd,children:"Negated / Resolved"}),s.jsxs("table",{style:M.table,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:M.th,children:"Date"}),s.jsx("th",{style:M.th,children:"Violation"}),s.jsx("th",{style:M.th,children:"Pts"}),s.jsx("th",{style:M.th,children:"Resolution"}),s.jsx("th",{style:M.th,children:"Actions"})]})}),s.jsx("tbody",{children:X.map(N=>s.jsxs("tr",{style:M.negatedRow,children:[s.jsx("td",{style:M.td,children:N.incident_date}),s.jsxs("td",{style:M.td,children:[s.jsx("div",{style:{fontWeight:600},children:N.violation_name}),s.jsx("div",{style:{fontSize:"10px",color:"#9ca0b8"},children:N.category})]}),s.jsx("td",{style:M.td,children:N.points}),s.jsxs("td",{style:M.td,children:[s.jsx("span",{style:M.resTag,children:N.resolution_type}),N.resolution_details&&s.jsx("div",{style:{fontSize:"10px",color:"#b5b5c0",marginTop:"2px"},children:N.resolution_details}),N.resolved_by&&s.jsxs("div",{style:{fontSize:"10px",color:"#9ca0b8"},children:["by ",N.resolved_by]})]}),s.jsxs("td",{style:M.td,children:[s.jsx("button",{style:M.actionBtn("#4db6ac"),onClick:L=>{L.stopPropagation(),j(N.id)},children:"Restore"}),s.jsx("button",{style:M.actionBtn("#ff4d4f"),onClick:L=>{L.stopPropagation(),S(y===N.id?null:N.id)},children:y===N.id?"Cancel":"Delete"}),s.jsx("button",{style:M.pdfBtn,onClick:L=>{L.stopPropagation(),b(N.id,n==null?void 0:n.name,N.incident_date)},children:"PDF"}),y===N.id&&s.jsxs("div",{style:M.deleteConfirm,children:["Permanently delete? This cannot be undone.",s.jsxs("div",{style:{marginTop:"8px"},children:[s.jsx("button",{style:M.actionBtn("#ff4d4f"),onClick:L=>{L.stopPropagation(),C(N.id)},children:"Confirm Delete"}),s.jsx("button",{style:M.actionBtn("#888"),onClick:L=>{L.stopPropagation(),S(null)},children:"Cancel"})]})]})]})]},N.id))})]})]})]})})]}),p&&s.jsx(dy,{violation:p,onConfirm:_,onCancel:()=>m(null)}),x&&n&&s.jsx(fy,{employee:n,onClose:()=>v(!1),onSaved:()=>{d.success("Employee updated."),h()}}),g&&s.jsx(hy,{violation:g,onClose:()=>f(null),onSaved:()=>{d.success("Violation amended."),h()}})]})}const xo={employee_created:"#667eea",employee_edited:"#9b8af8",employee_merged:"#f0a500",violation_created:"#28a745",violation_amended:"#4db6ac",violation_negated:"#ffc107",violation_restored:"#17a2b8",violation_deleted:"#dc3545"},Mu={employee_created:"Employee Created",employee_edited:"Employee Edited",employee_merged:"Employee Merged",violation_created:"Violation Logged",violation_amended:"Violation Amended",violation_negated:"Violation Negated",violation_restored:"Violation Restored",violation_deleted:"Violation Deleted"},Uu={employee:"Employee",violation:"Violation"},fe={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",zIndex:1e3,display:"flex",alignItems:"flex-start",justifyContent:"flex-end"},panel:{background:"#111217",color:"#f8f9fa",width:"680px",maxWidth:"95vw",height:"100vh",overflowY:"auto",boxShadow:"-4px 0 24px rgba(0,0,0,0.7)",display:"flex",flexDirection:"column"},header:{background:"linear-gradient(135deg, #000000, #151622)",color:"white",padding:"22px 26px",position:"sticky",top:0,zIndex:10,borderBottom:"1px solid #222"},headerRow:{display:"flex",alignItems:"center",justifyContent:"space-between"},title:{fontSize:"17px",fontWeight:700},subtitle:{fontSize:"12px",color:"#9ca0b8",marginTop:"3px"},closeBtn:{background:"none",border:"none",color:"white",fontSize:"22px",cursor:"pointer",lineHeight:1},filters:{padding:"14px 26px",borderBottom:"1px solid #1c1d29",display:"flex",gap:"10px",flexWrap:"wrap"},select:{background:"#0d0e14",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#f8f9fa",padding:"7px 12px",fontSize:"12px",outline:"none"},body:{padding:"16px 26px",flex:1},entry:{borderBottom:"1px solid #1c1d29",padding:"12px 0",display:"flex",gap:"12px",alignItems:"flex-start"},dot:e=>({width:"8px",height:"8px",borderRadius:"50%",marginTop:"5px",flexShrink:0,background:xo[e]||"#555"}),entryMain:{flex:1,minWidth:0},actionBadge:e=>({display:"inline-block",padding:"2px 8px",borderRadius:"10px",fontSize:"10px",fontWeight:700,letterSpacing:"0.3px",marginRight:"6px",background:(xo[e]||"#555")+"22",color:xo[e]||"#aaa",border:`1px solid ${xo[e]||"#555"}44`}),entityRef:{fontSize:"11px",color:"#9ca0b8"},details:{fontSize:"11px",color:"#667",marginTop:"4px",fontFamily:"monospace",wordBreak:"break-all"},meta:{fontSize:"10px",color:"#555a7a",marginTop:"4px"},empty:{textAlign:"center",color:"#555a7a",padding:"60px 0",fontSize:"13px"},loadMore:{width:"100%",background:"none",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#9ca0b8",padding:"10px",cursor:"pointer",fontSize:"12px",marginTop:"16px"}};function wy(e){return e?new Date(e).toLocaleString("en-US",{timeZone:"America/Chicago",dateStyle:"medium",timeStyle:"short"}):"—"}function Sy(e){if(!e)return null;try{const t=JSON.parse(e);return JSON.stringify(t,null,0).replace(/^\{/,"").replace(/\}$/,"").replace(/","/g," ")}catch{return e}}function by({onClose:e}){const[t,n]=k.useState([]),[r,o]=k.useState(!0),[i,l]=k.useState(0),[a,u]=k.useState(!1),[c,p]=k.useState(""),[m,y]=k.useState(""),S=50,x=k.useCallback((g=!1)=>{o(!0);const f=g?0:i,d={limit:S,offset:f};c&&(d.entity_type=c),m&&(d.action=m),F.get("/api/audit",{params:d}).then(h=>{const b=h.data,C=m?b.filter(j=>j.action===m):b;n(j=>g?C:[...j,...C]),u(b.length===S),l(f+S)}).finally(()=>o(!1))},[i,c,m]);k.useEffect(()=>{x(!0)},[c,m]);const v=g=>{g.target===g.currentTarget&&e()};return s.jsx("div",{style:fe.overlay,onClick:v,children:s.jsxs("div",{style:fe.panel,onClick:g=>g.stopPropagation(),children:[s.jsx("div",{style:fe.header,children:s.jsxs("div",{style:fe.headerRow,children:[s.jsxs("div",{children:[s.jsx("div",{style:fe.title,children:"Audit Log"}),s.jsx("div",{style:fe.subtitle,children:"All system write actions — append-only"})]}),s.jsx("button",{style:fe.closeBtn,onClick:e,children:"✕"})]})}),s.jsxs("div",{style:fe.filters,children:[s.jsxs("select",{style:fe.select,value:c,onChange:g=>{p(g.target.value),l(0)},children:[s.jsx("option",{value:"",children:"All entity types"}),Object.entries(Uu).map(([g,f])=>s.jsx("option",{value:g,children:f},g))]}),s.jsxs("select",{style:fe.select,value:m,onChange:g=>{y(g.target.value),l(0)},children:[s.jsx("option",{value:"",children:"All actions"}),Object.entries(Mu).map(([g,f])=>s.jsx("option",{value:g,children:f},g))]})]}),s.jsxs("div",{style:fe.body,children:[r&&t.length===0?s.jsx("div",{style:fe.empty,children:"Loading…"}):t.length===0?s.jsx("div",{style:fe.empty,children:"No audit entries found."}):t.map(g=>s.jsxs("div",{style:fe.entry,children:[s.jsx("div",{style:fe.dot(g.action)}),s.jsxs("div",{style:fe.entryMain,children:[s.jsxs("div",{children:[s.jsx("span",{style:fe.actionBadge(g.action),children:Mu[g.action]||g.action}),s.jsxs("span",{style:fe.entityRef,children:[Uu[g.entity_type]||g.entity_type,g.entity_id?` #${g.entity_id}`:""]})]}),g.details&&s.jsx("div",{style:fe.details,children:Sy(g.details)}),s.jsxs("div",{style:fe.meta,children:[g.performed_by?`by ${g.performed_by} · `:"",wy(g.created_at)]})]})]},g.id)),a&&s.jsx("button",{style:fe.loadMore,onClick:()=>x(!1),children:"Load more"})]})]})})}const ky=2,jy=[{min:0,max:4},{min:5,max:9},{min:10,max:14},{min:15,max:19},{min:20,max:24},{min:25,max:29},{min:30,max:999}];function Tf(e){for(const t of jy)if(e>=t.min&&e<=t.max&&t.max<999)return t.max+1;return null}function Cy(e){const t=Tf(e);return t!==null&&t-e<=ky}const pe={card:{background:"#181924",border:"1px solid #2a2b3a",borderRadius:"10px",padding:"16px",marginBottom:"12px",boxShadow:"0 1px 4px rgba(0,0,0,0.4)"},cardAtRisk:{background:"#181200",border:"1px solid #d4af37"},row:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderBottom:"1px solid rgba(255,255,255,0.05)"},rowLast:{borderBottom:"none"},label:{fontSize:"11px",fontWeight:600,color:"#9ca0b8",textTransform:"uppercase",letterSpacing:"0.5px"},value:{fontSize:"14px",fontWeight:600,color:"#f8f9fa",textAlign:"right"},name:{fontSize:"16px",fontWeight:700,color:"#d4af37",marginBottom:"8px",cursor:"pointer",textDecoration:"underline dotted",background:"none",border:"none",padding:0,textAlign:"left",width:"100%"},atRiskBadge:{display:"inline-block",marginTop:"4px",padding:"3px 8px",borderRadius:"10px",fontSize:"10px",fontWeight:700,background:"#3b2e00",color:"#ffd666",border:"1px solid #d4af37"},points:{fontSize:"28px",fontWeight:800,textAlign:"center",margin:"8px 0"}};function Ey({employees:e,onEmployeeClick:t}){return!e||e.length===0?s.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#77798a",fontStyle:"italic"},children:"No employees found."}):s.jsx("div",{style:{padding:"12px"},children:e.map(n=>{const r=Cy(n.active_points),o=Kt(n.active_points),i=Tf(n.active_points),l=r?{...pe.card,...pe.cardAtRisk}:pe.card;return s.jsxs("div",{style:l,children:[s.jsx("button",{style:pe.name,onClick:()=>t(n.id),children:n.name}),r&&s.jsxs("div",{style:pe.atRiskBadge,children:["⚠ ",i-n.active_points," pt",i-n.active_points>1?"s":""," to ",Kt(i).label.split("—")[0].trim()]}),s.jsxs("div",{style:{...pe.row,marginTop:"12px"},children:[s.jsx("span",{style:pe.label,children:"Tier / Standing"}),s.jsx("span",{style:pe.value,children:s.jsx(Ti,{points:n.active_points})})]}),s.jsxs("div",{style:pe.row,children:[s.jsx("span",{style:pe.label,children:"Active Points"}),s.jsx("span",{style:{...pe.points,color:o.color},children:n.active_points})]}),s.jsxs("div",{style:pe.row,children:[s.jsx("span",{style:pe.label,children:"90-Day Violations"}),s.jsx("span",{style:pe.value,children:n.violation_count})]}),n.department&&s.jsxs("div",{style:pe.row,children:[s.jsx("span",{style:pe.label,children:"Department"}),s.jsx("span",{style:{...pe.value,color:"#c0c2d6"},children:n.department})]}),n.supervisor&&s.jsxs("div",{style:{...pe.row,...pe.rowLast},children:[s.jsx("span",{style:pe.label,children:"Supervisor"}),s.jsx("span",{style:{...pe.value,color:"#c0c2d6"},children:n.supervisor})]})]},n.id)})})}const us=2,_y=[{min:0,max:4},{min:5,max:9},{min:10,max:14},{min:15,max:19},{min:20,max:24},{min:25,max:29},{min:30,max:999}];function Pf(e){for(const t of _y)if(e>=t.min&&e<=t.max&&t.max<999)return t.max+1;return null}function ul(e){const t=Pf(e);return t!==null&&t-e<=us}function Ry(e){const[t,n]=k.useState(!1);return k.useEffect(()=>{const r=window.matchMedia(e);r.matches!==t&&n(r.matches);const o=()=>n(r.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[t,e]),t}const vo=null,cl="total",sr="elite",ar="active",ur="at_risk",V={wrap:{padding:"32px 40px",color:"#f8f9fa"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",flexWrap:"wrap",gap:"12px"},title:{fontSize:"24px",fontWeight:700,color:"#f8f9fa"},subtitle:{fontSize:"13px",color:"#b5b5c0",marginTop:"3px"},statsRow:{display:"flex",gap:"16px",flexWrap:"wrap",marginBottom:"28px"},statCard:{flex:"1",minWidth:"140px",background:"#181924",border:"1px solid #303136",borderRadius:"8px",padding:"16px",textAlign:"center",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s"},statCardActive:{boxShadow:"0 0 0 2px #d4af37",border:"1px solid #d4af37"},statNum:{fontSize:"28px",fontWeight:800,color:"#f8f9fa"},statLbl:{fontSize:"11px",color:"#b5b5c0",marginTop:"4px"},filterBadge:{fontSize:"10px",color:"#d4af37",marginTop:"4px",fontWeight:600},search:{padding:"10px 14px",border:"1px solid #333544",borderRadius:"6px",fontSize:"14px",width:"260px",background:"#050608",color:"#f8f9fa"},table:{width:"100%",borderCollapse:"collapse",background:"#111217",borderRadius:"8px",overflow:"hidden",boxShadow:"0 1px 8px rgba(0,0,0,0.6)",border:"1px solid #222"},th:{background:"#000000",color:"#f8f9fa",padding:"10px 14px",textAlign:"left",fontSize:"12px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},td:{padding:"11px 14px",borderBottom:"1px solid #1c1d29",fontSize:"13px",verticalAlign:"middle",color:"#f8f9fa"},nameBtn:{background:"none",border:"none",cursor:"pointer",fontWeight:600,color:"#d4af37",fontSize:"14px",padding:0,textDecoration:"underline dotted"},atRiskBadge:{display:"inline-block",marginLeft:"8px",padding:"2px 8px",borderRadius:"10px",fontSize:"10px",fontWeight:700,background:"#3b2e00",color:"#ffd666",border:"1px solid #d4af37",verticalAlign:"middle"},zeroRow:{color:"#77798a",fontStyle:"italic",fontSize:"12px"},toolbarRight:{display:"flex",gap:"10px",alignItems:"center"},refreshBtn:{padding:"9px 18px",background:"#d4af37",color:"#000",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:600,fontSize:"13px"},auditBtn:{padding:"9px 18px",background:"none",color:"#9ca0b8",border:"1px solid #2a2b3a",borderRadius:"6px",cursor:"pointer",fontWeight:600,fontSize:"13px"}},Ty=` +Use this after back-dating a violation if older PDFs no longer reflect the correct prior-points total. Existing PDFs will regenerate with up-to-date numbers.`))try{const R=await F.post(`/api/employees/${e}/recompute-snapshots`),{scanned:P,updated:$}=R.data;$===0?d.success(`Snapshots already up to date (${P} checked).`):d.success(`Updated ${$} of ${P} snapshot${$===1?"":"s"}.`),h()}catch(R){d.error("Backfill failed: "+(((L=(A=R.response)==null?void 0:A.data)==null?void 0:L.error)||R.message))}},_=async({resolution_type:A,details:L,resolved_by:R})=>{var P,$;try{await F.patch(`/api/violations/${f.id}/negate`,{resolution_type:A,details:L,resolved_by:R}),d.success("Violation negated."),m(null),S(null),h()}catch(N){d.error("Negate failed: "+((($=(P=N.response)==null?void 0:P.data)==null?void 0:$.error)||N.message))}},Q=o?Kt(o.active_points):null,U=l.filter(A=>!A.negated),X=l.filter(A=>A.negated),H=A=>{A.target===A.currentTarget&&t()};return s.jsxs("div",{style:M.overlay,onClick:H,children:[s.jsxs("div",{style:M.panel,onClick:A=>A.stopPropagation(),children:[s.jsx("div",{style:M.header,children:s.jsxs("div",{style:M.headerRow,children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:"18px",fontWeight:700},children:n?n.name:"Employee"}),n&&s.jsxs("div",{style:{fontSize:"12px",color:"#b5b5c0",marginTop:"4px"},children:[n.department," ",n.supervisor&&`· Supervisor: ${n.supervisor}`]}),n&&s.jsx("button",{style:M.editEmpBtn,onClick:()=>v(!0),children:"✎ Edit Employee"})]}),s.jsx("button",{style:M.closeBtn,onClick:t,children:"✕"})]})}),s.jsx("div",{style:M.body,children:u?s.jsx("div",{style:{padding:"40px",textAlign:"center",color:"#b5b5c0"},children:"Loading…"}):s.jsxs(s.Fragment,{children:[o&&s.jsxs("div",{style:M.scoreRow,children:[s.jsxs("div",{style:M.scoreCard,children:[s.jsx("div",{style:{...M.scoreNum,color:(Q==null?void 0:Q.color)||"#f8f9fa"},children:o.active_points}),s.jsx("div",{style:M.scoreLbl,children:"Active Points"})]}),s.jsxs("div",{style:M.scoreCard,children:[s.jsx("div",{style:M.scoreNum,children:o.total_violations}),s.jsx("div",{style:M.scoreLbl,children:"Total Violations"})]}),s.jsxs("div",{style:M.scoreCard,children:[s.jsx("div",{style:M.scoreNum,children:o.negated_count}),s.jsx("div",{style:M.scoreLbl,children:"Negated"})]}),s.jsxs("div",{style:{...M.scoreCard,minWidth:"140px"},children:[s.jsx("div",{style:{fontSize:"13px",fontWeight:700,color:(Q==null?void 0:Q.color)||"#f8f9fa"},children:Q?Q.label:"—"}),s.jsx("div",{style:M.scoreLbl,children:"Current Tier"})]})]}),o&&s.jsx(Ti,{points:o.active_points,style:{marginBottom:"20px"}}),n&&s.jsx(xy,{employeeId:e,initialNotes:n.notes,onSaved:A=>r(L=>({...L,notes:A}))}),o&&o.active_points>0&&s.jsx(gy,{employeeId:e,currentPoints:o.active_points}),s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"24px",marginBottom:"10px"},children:[s.jsx("div",{style:{...M.sectionHd,marginTop:0,marginBottom:0},children:"Active Violations"}),l.length>0&&s.jsx("button",{style:M.backfillBtn,onClick:T,title:"Rebuild prior-points snapshot on each violation. Use after a back-dated insert if older PDFs show the wrong Prior Active Points.",children:"↻ Backfill Snapshots"})]}),U.length===0?s.jsx("div",{style:{color:"#777990",fontStyle:"italic",fontSize:"12px"},children:"No active violations on record."}):s.jsxs("table",{style:M.table,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:M.th,children:"Date"}),s.jsx("th",{style:M.th,children:"Violation"}),s.jsx("th",{style:M.th,children:"Pts"}),s.jsx("th",{style:M.th,children:"Actions"})]})}),s.jsx("tbody",{children:U.map(A=>s.jsxs("tr",{children:[s.jsx("td",{style:M.td,children:A.incident_date}),s.jsxs("td",{style:M.td,children:[s.jsxs("div",{style:{fontWeight:600},children:[A.violation_name,A.amendment_count>0&&s.jsxs("span",{style:M.amendBadge,children:[A.amendment_count," edit",A.amendment_count!==1?"s":""]})]}),s.jsx("div",{style:{fontSize:"10px",color:"#9ca0b8"},children:A.category}),A.details&&s.jsx("div",{style:{fontSize:"10px",color:"#b5b5c0",marginTop:"2px"},children:A.details})]}),s.jsx("td",{style:{...M.td,fontWeight:700},children:A.points}),s.jsxs("td",{style:M.td,children:[s.jsx("button",{style:M.amendBtn,onClick:L=>{L.stopPropagation(),p(A)},children:"Amend"}),s.jsx("button",{style:M.actionBtn("#ffc107"),onClick:L=>{L.stopPropagation(),m(A),S(null)},children:"Negate"}),s.jsx("button",{style:M.actionBtn("#ff4d4f"),onClick:L=>{L.stopPropagation(),S(y===A.id?null:A.id)},children:y===A.id?"Cancel":"Delete"}),s.jsx("button",{style:M.pdfBtn,onClick:L=>{L.stopPropagation(),b(A.id,n==null?void 0:n.name,A.incident_date)},children:"PDF"}),y===A.id&&s.jsxs("div",{style:M.deleteConfirm,children:["Permanently delete? This cannot be undone.",s.jsxs("div",{style:{marginTop:"8px"},children:[s.jsx("button",{style:M.actionBtn("#ff4d4f"),onClick:L=>{L.stopPropagation(),C(A.id)},children:"Confirm Delete"}),s.jsx("button",{style:M.actionBtn("#888"),onClick:L=>{L.stopPropagation(),S(null)},children:"Cancel"})]})]})]})]},A.id))})]}),X.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:M.sectionHd,children:"Negated / Resolved"}),s.jsxs("table",{style:M.table,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:M.th,children:"Date"}),s.jsx("th",{style:M.th,children:"Violation"}),s.jsx("th",{style:M.th,children:"Pts"}),s.jsx("th",{style:M.th,children:"Resolution"}),s.jsx("th",{style:M.th,children:"Actions"})]})}),s.jsx("tbody",{children:X.map(A=>s.jsxs("tr",{style:M.negatedRow,children:[s.jsx("td",{style:M.td,children:A.incident_date}),s.jsxs("td",{style:M.td,children:[s.jsx("div",{style:{fontWeight:600},children:A.violation_name}),s.jsx("div",{style:{fontSize:"10px",color:"#9ca0b8"},children:A.category})]}),s.jsx("td",{style:M.td,children:A.points}),s.jsxs("td",{style:M.td,children:[s.jsx("span",{style:M.resTag,children:A.resolution_type}),A.resolution_details&&s.jsx("div",{style:{fontSize:"10px",color:"#b5b5c0",marginTop:"2px"},children:A.resolution_details}),A.resolved_by&&s.jsxs("div",{style:{fontSize:"10px",color:"#9ca0b8"},children:["by ",A.resolved_by]})]}),s.jsxs("td",{style:M.td,children:[s.jsx("button",{style:M.actionBtn("#4db6ac"),onClick:L=>{L.stopPropagation(),j(A.id)},children:"Restore"}),s.jsx("button",{style:M.actionBtn("#ff4d4f"),onClick:L=>{L.stopPropagation(),S(y===A.id?null:A.id)},children:y===A.id?"Cancel":"Delete"}),s.jsx("button",{style:M.pdfBtn,onClick:L=>{L.stopPropagation(),b(A.id,n==null?void 0:n.name,A.incident_date)},children:"PDF"}),y===A.id&&s.jsxs("div",{style:M.deleteConfirm,children:["Permanently delete? This cannot be undone.",s.jsxs("div",{style:{marginTop:"8px"},children:[s.jsx("button",{style:M.actionBtn("#ff4d4f"),onClick:L=>{L.stopPropagation(),C(A.id)},children:"Confirm Delete"}),s.jsx("button",{style:M.actionBtn("#888"),onClick:L=>{L.stopPropagation(),S(null)},children:"Cancel"})]})]})]})]},A.id))})]})]})]})})]}),f&&s.jsx(dy,{violation:f,onConfirm:_,onCancel:()=>m(null)}),x&&n&&s.jsx(py,{employee:n,onClose:()=>v(!1),onSaved:()=>{d.success("Employee updated."),h()}}),g&&s.jsx(hy,{violation:g,onClose:()=>p(null),onSaved:()=>{d.success("Violation amended."),h()}})]})}const xo={employee_created:"#667eea",employee_edited:"#9b8af8",employee_merged:"#f0a500",violation_created:"#28a745",violation_amended:"#4db6ac",violation_negated:"#ffc107",violation_restored:"#17a2b8",violation_deleted:"#dc3545"},Mu={employee_created:"Employee Created",employee_edited:"Employee Edited",employee_merged:"Employee Merged",violation_created:"Violation Logged",violation_amended:"Violation Amended",violation_negated:"Violation Negated",violation_restored:"Violation Restored",violation_deleted:"Violation Deleted"},Uu={employee:"Employee",violation:"Violation"},pe={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",zIndex:1e3,display:"flex",alignItems:"flex-start",justifyContent:"flex-end"},panel:{background:"#111217",color:"#f8f9fa",width:"680px",maxWidth:"95vw",height:"100vh",overflowY:"auto",boxShadow:"-4px 0 24px rgba(0,0,0,0.7)",display:"flex",flexDirection:"column"},header:{background:"linear-gradient(135deg, #000000, #151622)",color:"white",padding:"22px 26px",position:"sticky",top:0,zIndex:10,borderBottom:"1px solid #222"},headerRow:{display:"flex",alignItems:"center",justifyContent:"space-between"},title:{fontSize:"17px",fontWeight:700},subtitle:{fontSize:"12px",color:"#9ca0b8",marginTop:"3px"},closeBtn:{background:"none",border:"none",color:"white",fontSize:"22px",cursor:"pointer",lineHeight:1},filters:{padding:"14px 26px",borderBottom:"1px solid #1c1d29",display:"flex",gap:"10px",flexWrap:"wrap"},select:{background:"#0d0e14",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#f8f9fa",padding:"7px 12px",fontSize:"12px",outline:"none"},body:{padding:"16px 26px",flex:1},entry:{borderBottom:"1px solid #1c1d29",padding:"12px 0",display:"flex",gap:"12px",alignItems:"flex-start"},dot:e=>({width:"8px",height:"8px",borderRadius:"50%",marginTop:"5px",flexShrink:0,background:xo[e]||"#555"}),entryMain:{flex:1,minWidth:0},actionBadge:e=>({display:"inline-block",padding:"2px 8px",borderRadius:"10px",fontSize:"10px",fontWeight:700,letterSpacing:"0.3px",marginRight:"6px",background:(xo[e]||"#555")+"22",color:xo[e]||"#aaa",border:`1px solid ${xo[e]||"#555"}44`}),entityRef:{fontSize:"11px",color:"#9ca0b8"},details:{fontSize:"11px",color:"#667",marginTop:"4px",fontFamily:"monospace",wordBreak:"break-all"},meta:{fontSize:"10px",color:"#555a7a",marginTop:"4px"},empty:{textAlign:"center",color:"#555a7a",padding:"60px 0",fontSize:"13px"},loadMore:{width:"100%",background:"none",border:"1px solid #2a2b3a",borderRadius:"6px",color:"#9ca0b8",padding:"10px",cursor:"pointer",fontSize:"12px",marginTop:"16px"}};function wy(e){return e?new Date(e).toLocaleString("en-US",{timeZone:"America/Chicago",dateStyle:"medium",timeStyle:"short"}):"—"}function Sy(e){if(!e)return null;try{const t=JSON.parse(e);return JSON.stringify(t,null,0).replace(/^\{/,"").replace(/\}$/,"").replace(/","/g," ")}catch{return e}}function by({onClose:e}){const[t,n]=k.useState([]),[r,o]=k.useState(!0),[i,l]=k.useState(0),[a,u]=k.useState(!1),[c,f]=k.useState(""),[m,y]=k.useState(""),S=50,x=k.useCallback((g=!1)=>{o(!0);const p=g?0:i,d={limit:S,offset:p};c&&(d.entity_type=c),m&&(d.action=m),F.get("/api/audit",{params:d}).then(h=>{const b=h.data,C=m?b.filter(j=>j.action===m):b;n(j=>g?C:[...j,...C]),u(b.length===S),l(p+S)}).finally(()=>o(!1))},[i,c,m]);k.useEffect(()=>{x(!0)},[c,m]);const v=g=>{g.target===g.currentTarget&&e()};return s.jsx("div",{style:pe.overlay,onClick:v,children:s.jsxs("div",{style:pe.panel,onClick:g=>g.stopPropagation(),children:[s.jsx("div",{style:pe.header,children:s.jsxs("div",{style:pe.headerRow,children:[s.jsxs("div",{children:[s.jsx("div",{style:pe.title,children:"Audit Log"}),s.jsx("div",{style:pe.subtitle,children:"All system write actions — append-only"})]}),s.jsx("button",{style:pe.closeBtn,onClick:e,children:"✕"})]})}),s.jsxs("div",{style:pe.filters,children:[s.jsxs("select",{style:pe.select,value:c,onChange:g=>{f(g.target.value),l(0)},children:[s.jsx("option",{value:"",children:"All entity types"}),Object.entries(Uu).map(([g,p])=>s.jsx("option",{value:g,children:p},g))]}),s.jsxs("select",{style:pe.select,value:m,onChange:g=>{y(g.target.value),l(0)},children:[s.jsx("option",{value:"",children:"All actions"}),Object.entries(Mu).map(([g,p])=>s.jsx("option",{value:g,children:p},g))]})]}),s.jsxs("div",{style:pe.body,children:[r&&t.length===0?s.jsx("div",{style:pe.empty,children:"Loading…"}):t.length===0?s.jsx("div",{style:pe.empty,children:"No audit entries found."}):t.map(g=>s.jsxs("div",{style:pe.entry,children:[s.jsx("div",{style:pe.dot(g.action)}),s.jsxs("div",{style:pe.entryMain,children:[s.jsxs("div",{children:[s.jsx("span",{style:pe.actionBadge(g.action),children:Mu[g.action]||g.action}),s.jsxs("span",{style:pe.entityRef,children:[Uu[g.entity_type]||g.entity_type,g.entity_id?` #${g.entity_id}`:""]})]}),g.details&&s.jsx("div",{style:pe.details,children:Sy(g.details)}),s.jsxs("div",{style:pe.meta,children:[g.performed_by?`by ${g.performed_by} · `:"",wy(g.created_at)]})]})]},g.id)),a&&s.jsx("button",{style:pe.loadMore,onClick:()=>x(!1),children:"Load more"})]})]})})}const ky=2,jy=[{min:0,max:4},{min:5,max:9},{min:10,max:14},{min:15,max:19},{min:20,max:24},{min:25,max:29},{min:30,max:999}];function Rp(e){for(const t of jy)if(e>=t.min&&e<=t.max&&t.max<999)return t.max+1;return null}function Cy(e){const t=Rp(e);return t!==null&&t-e<=ky}const fe={card:{background:"#181924",border:"1px solid #2a2b3a",borderRadius:"10px",padding:"16px",marginBottom:"12px",boxShadow:"0 1px 4px rgba(0,0,0,0.4)"},cardAtRisk:{background:"#181200",border:"1px solid #d4af37"},row:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderBottom:"1px solid rgba(255,255,255,0.05)"},rowLast:{borderBottom:"none"},label:{fontSize:"11px",fontWeight:600,color:"#9ca0b8",textTransform:"uppercase",letterSpacing:"0.5px"},value:{fontSize:"14px",fontWeight:600,color:"#f8f9fa",textAlign:"right"},name:{fontSize:"16px",fontWeight:700,color:"#d4af37",marginBottom:"8px",cursor:"pointer",textDecoration:"underline dotted",background:"none",border:"none",padding:0,textAlign:"left",width:"100%"},atRiskBadge:{display:"inline-block",marginTop:"4px",padding:"3px 8px",borderRadius:"10px",fontSize:"10px",fontWeight:700,background:"#3b2e00",color:"#ffd666",border:"1px solid #d4af37"},points:{fontSize:"28px",fontWeight:800,textAlign:"center",margin:"8px 0"}};function Ey({employees:e,onEmployeeClick:t}){return!e||e.length===0?s.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#77798a",fontStyle:"italic"},children:"No employees found."}):s.jsx("div",{style:{padding:"12px"},children:e.map(n=>{const r=Cy(n.active_points),o=Kt(n.active_points),i=Rp(n.active_points),l=r?{...fe.card,...fe.cardAtRisk}:fe.card;return s.jsxs("div",{style:l,children:[s.jsx("button",{style:fe.name,onClick:()=>t(n.id),children:n.name}),r&&s.jsxs("div",{style:fe.atRiskBadge,children:["⚠ ",i-n.active_points," pt",i-n.active_points>1?"s":""," to ",Kt(i).label.split("—")[0].trim()]}),s.jsxs("div",{style:{...fe.row,marginTop:"12px"},children:[s.jsx("span",{style:fe.label,children:"Tier / Standing"}),s.jsx("span",{style:fe.value,children:s.jsx(Ti,{points:n.active_points})})]}),s.jsxs("div",{style:fe.row,children:[s.jsx("span",{style:fe.label,children:"Active Points"}),s.jsx("span",{style:{...fe.points,color:o.color},children:n.active_points})]}),s.jsxs("div",{style:fe.row,children:[s.jsx("span",{style:fe.label,children:"90-Day Violations"}),s.jsx("span",{style:fe.value,children:n.violation_count})]}),n.department&&s.jsxs("div",{style:fe.row,children:[s.jsx("span",{style:fe.label,children:"Department"}),s.jsx("span",{style:{...fe.value,color:"#c0c2d6"},children:n.department})]}),n.supervisor&&s.jsxs("div",{style:{...fe.row,...fe.rowLast},children:[s.jsx("span",{style:fe.label,children:"Supervisor"}),s.jsx("span",{style:{...fe.value,color:"#c0c2d6"},children:n.supervisor})]})]},n.id)})})}const us=2,_y=[{min:0,max:4},{min:5,max:9},{min:10,max:14},{min:15,max:19},{min:20,max:24},{min:25,max:29},{min:30,max:999}];function Tp(e){for(const t of _y)if(e>=t.min&&e<=t.max&&t.max<999)return t.max+1;return null}function ul(e){const t=Tp(e);return t!==null&&t-e<=us}function Ry(e){const[t,n]=k.useState(!1);return k.useEffect(()=>{const r=window.matchMedia(e);r.matches!==t&&n(r.matches);const o=()=>n(r.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[t,e]),t}const vo=null,cl="total",sr="elite",ar="active",ur="at_risk",V={wrap:{padding:"32px 40px",color:"#f8f9fa"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",flexWrap:"wrap",gap:"12px"},title:{fontSize:"24px",fontWeight:700,color:"#f8f9fa"},subtitle:{fontSize:"13px",color:"#b5b5c0",marginTop:"3px"},statsRow:{display:"flex",gap:"16px",flexWrap:"wrap",marginBottom:"28px"},statCard:{flex:"1",minWidth:"140px",background:"#181924",border:"1px solid #303136",borderRadius:"8px",padding:"16px",textAlign:"center",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s"},statCardActive:{boxShadow:"0 0 0 2px #d4af37",border:"1px solid #d4af37"},statNum:{fontSize:"28px",fontWeight:800,color:"#f8f9fa"},statLbl:{fontSize:"11px",color:"#b5b5c0",marginTop:"4px"},filterBadge:{fontSize:"10px",color:"#d4af37",marginTop:"4px",fontWeight:600},search:{padding:"10px 14px",border:"1px solid #333544",borderRadius:"6px",fontSize:"14px",width:"260px",background:"#050608",color:"#f8f9fa"},table:{width:"100%",borderCollapse:"collapse",background:"#111217",borderRadius:"8px",overflow:"hidden",boxShadow:"0 1px 8px rgba(0,0,0,0.6)",border:"1px solid #222"},th:{background:"#000000",color:"#f8f9fa",padding:"10px 14px",textAlign:"left",fontSize:"12px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},td:{padding:"11px 14px",borderBottom:"1px solid #1c1d29",fontSize:"13px",verticalAlign:"middle",color:"#f8f9fa"},nameBtn:{background:"none",border:"none",cursor:"pointer",fontWeight:600,color:"#d4af37",fontSize:"14px",padding:0,textDecoration:"underline dotted"},atRiskBadge:{display:"inline-block",marginLeft:"8px",padding:"2px 8px",borderRadius:"10px",fontSize:"10px",fontWeight:700,background:"#3b2e00",color:"#ffd666",border:"1px solid #d4af37",verticalAlign:"middle"},zeroRow:{color:"#77798a",fontStyle:"italic",fontSize:"12px"},toolbarRight:{display:"flex",gap:"10px",alignItems:"center"},refreshBtn:{padding:"9px 18px",background:"#d4af37",color:"#000",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:600,fontSize:"13px"},auditBtn:{padding:"9px 18px",background:"none",color:"#9ca0b8",border:"1px solid #2a2b3a",borderRadius:"6px",cursor:"pointer",fontWeight:600,fontSize:"13px"}},Ty=` @media (max-width: 768px) { .dashboard-wrap { padding: 16px !important; @@ -108,10 +108,10 @@ Use this after back-dating a violation if older PDFs no longer reflect the corre min-width: 100% !important; } } -`;function Py(){const[e,t]=k.useState([]),[n,r]=k.useState([]),[o,i]=k.useState(""),[l,a]=k.useState(null),[u,c]=k.useState(!1),[p,m]=k.useState(!0),[y,S]=k.useState(vo),x=Ry("(max-width: 768px)"),v=k.useCallback(()=>{m(!0),F.get("/api/dashboard").then(j=>{t(j.data),r(j.data)}).finally(()=>m(!1))},[]);k.useEffect(()=>{v()},[v]),k.useEffect(()=>{const j=o.toLowerCase();let T=e;y===sr?T=T.filter(_=>_.active_points>=0&&_.active_points<=4):y===ar?T=T.filter(_=>_.active_points>0):y===ur&&(T=T.filter(_=>ul(_.active_points))),j&&(T=T.filter(_=>_.name.toLowerCase().includes(j)||(_.department||"").toLowerCase().includes(j)||(_.supervisor||"").toLowerCase().includes(j))),r(T)},[o,e,y]);const g=e.filter(j=>ul(j.active_points)).length,f=e.filter(j=>j.active_points>0).length,d=e.filter(j=>j.active_points>=0&&j.active_points<=4).length,h=e.reduce((j,T)=>Math.max(j,T.active_points),0);function b(j){S(T=>T===j?vo:j)}function C(j,T={}){const _=y===j;return{...V.statCard,..._?V.statCardActive:{},...T}}return s.jsxs(s.Fragment,{children:[s.jsx("style",{children:Ty}),s.jsxs("div",{style:V.wrap,className:"dashboard-wrap",children:[s.jsxs("div",{style:V.header,className:"dashboard-header",children:[s.jsxs("div",{children:[s.jsx("div",{style:V.title,className:"dashboard-title",children:"Company Dashboard"}),s.jsxs("div",{style:V.subtitle,className:"dashboard-subtitle",children:["Click any employee name to view their full profile",y&&y!==vo&&s.jsxs("span",{style:{marginLeft:"10px",color:"#d4af37",fontWeight:600},children:["· Filtered: ",y===sr?"Elite Standing (0–4 pts)":y===ar?"With Active Points":y===ur?"At Risk":"All",s.jsx("button",{onClick:()=>S(vo),style:{marginLeft:"6px",background:"none",border:"none",color:"#9ca0b8",cursor:"pointer",fontSize:"12px"},title:"Clear filter",children:"✕"})]})]})]}),s.jsxs("div",{style:V.toolbarRight,className:"toolbar-right",children:[s.jsx("input",{style:V.search,className:"search-input",placeholder:"Search name, dept, supervisor…",value:o,onChange:j=>i(j.target.value)}),s.jsx("button",{style:V.auditBtn,className:"toolbar-btn",onClick:()=>c(!0),children:"📋 Audit Log"}),s.jsx("button",{style:V.refreshBtn,className:"toolbar-btn",onClick:v,children:"↻ Refresh"})]})]}),s.jsxs("div",{style:V.statsRow,className:"dashboard-stats",children:[s.jsxs("div",{style:C(cl),className:"dashboard-stat-card",onClick:()=>b(cl),title:"Click to show all employees",children:[s.jsx("div",{style:V.statNum,className:"stat-num",children:e.length}),s.jsx("div",{style:V.statLbl,className:"stat-lbl",children:"Total Employees"}),y===cl&&s.jsx("div",{style:V.filterBadge,children:"▼ Showing All"})]}),s.jsxs("div",{style:C(sr,{borderTop:"3px solid #28a745"}),className:"dashboard-stat-card",onClick:()=>b(sr),title:"Click to filter: Elite Standing (0–4 pts)",children:[s.jsx("div",{style:{...V.statNum,color:"#6ee7b7"},className:"stat-num",children:d}),s.jsx("div",{style:V.statLbl,className:"stat-lbl",children:"Elite Standing (0–4 pts)"}),y===sr&&s.jsx("div",{style:V.filterBadge,children:"▼ Filtered"})]}),s.jsxs("div",{style:C(ar,{borderTop:"3px solid #d4af37"}),className:"dashboard-stat-card",onClick:()=>b(ar),title:"Click to filter: employees with active points",children:[s.jsx("div",{style:{...V.statNum,color:"#ffd666"},className:"stat-num",children:f}),s.jsx("div",{style:V.statLbl,className:"stat-lbl",children:"With Active Points"}),y===ar&&s.jsx("div",{style:V.filterBadge,children:"▼ Filtered"})]}),s.jsxs("div",{style:C(ur,{borderTop:"3px solid #ffb020"}),className:"dashboard-stat-card",onClick:()=>b(ur),title:`Click to filter: at risk (≤${us} pts to next tier)`,children:[s.jsx("div",{style:{...V.statNum,color:"#ffdf8a"},className:"stat-num",children:g}),s.jsxs("div",{style:V.statLbl,className:"stat-lbl",children:["At Risk (≤",us," pts to next tier)"]}),y===ur&&s.jsx("div",{style:V.filterBadge,children:"▼ Filtered"})]}),s.jsxs("div",{style:{...V.statCard,borderTop:"3px solid #c0392b",cursor:"default"},className:"dashboard-stat-card",children:[s.jsx("div",{style:{...V.statNum,color:"#ff8a80"},className:"stat-num",children:h}),s.jsx("div",{style:V.statLbl,className:"stat-lbl",children:"Highest Active Score"})]})]}),p?s.jsx("p",{style:{color:"#77798a",textAlign:"center",padding:"40px"},children:"Loading…"}):x?s.jsx(Ey,{employees:n,onEmployeeClick:a}):s.jsxs("table",{style:V.table,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:V.th,children:"#"}),s.jsx("th",{style:V.th,children:"Employee"}),s.jsx("th",{style:V.th,children:"Department"}),s.jsx("th",{style:V.th,children:"Supervisor"}),s.jsx("th",{style:V.th,children:"Tier / Standing"}),s.jsx("th",{style:V.th,children:"Active Points"}),s.jsx("th",{style:V.th,children:"90-Day Violations"})]})}),s.jsxs("tbody",{children:[n.length===0&&s.jsx("tr",{children:s.jsx("td",{colSpan:7,style:{...V.td,textAlign:"center",...V.zeroRow},children:"No employees found."})}),n.map((j,T)=>{const _=ul(j.active_points),Q=Kt(j.active_points),U=Pf(j.active_points);return s.jsxs("tr",{style:{background:_?"#181200":T%2===0?"#111217":"#151622"},children:[s.jsx("td",{style:{...V.td,color:"#77798a",fontSize:"12px"},children:T+1}),s.jsxs("td",{style:V.td,children:[s.jsx("button",{style:V.nameBtn,onClick:()=>a(j.id),children:j.name}),_&&s.jsxs("span",{style:V.atRiskBadge,children:["⚠ ",U-j.active_points," pt",U-j.active_points>1?"s":""," to ",Kt(U).label.split("—")[0].trim()]})]}),s.jsx("td",{style:{...V.td,color:"#c0c2d6"},children:j.department||"—"}),s.jsx("td",{style:{...V.td,color:"#c0c2d6"},children:j.supervisor||"—"}),s.jsx("td",{style:V.td,children:s.jsx(Ti,{points:j.active_points})}),s.jsx("td",{style:{...V.td,fontWeight:700,color:Q.color,fontSize:"16px"},children:j.active_points}),s.jsx("td",{style:{...V.td,color:"#c0c2d6"},children:j.violation_count})]},j.id)})]})]})]}),l&&s.jsx(vy,{employeeId:l,onClose:()=>{a(null),v()}}),u&&s.jsx(by,{onClose:()=>c(!1)})]})}function zy(e){const t=e.split(` -`),n=[];let r=0,o=!1,i=!1,l=!1;const a=()=>{o&&(n.push(""),o=!1),i&&(n.push(""),i=!1),l&&(n.push(""),l=!1)},u=c=>c.replace(/&/g,"&").replace(//g,">").replace(/\*\*(.+?)\*\*/g,"$1").replace(/`([^`]+)`/g,"$1");for(;r"),r++;continue}const p=c.match(/^(#{1,4})\s+(.+)/);if(p){a();const S=p[1].length,x=p[2].toLowerCase().replace(/[^a-z0-9]+/g,"-");n.push(`${u(p[2])}`),r++;continue}if(c.trim().startsWith("|")){const S=c.trim().replace(/^\|||\|$/g,"").split("|").map(x=>x.trim());if(l){n.push(""),S.forEach(x=>n.push(`${u(x)}`)),n.push(""),r++;continue}else{a(),l=!0,n.push(""),S.forEach(x=>n.push(``)),n.push(""),r++,r"),i=!1),n.push("
    "),o=!0),n.push(`
  • ${u(m[1])}
  • `),r++;continue}const y=c.match(/^\d+\.\s+(.*)/);if(y){l&&a(),i||(o&&(n.push("
"),o=!1),n.push("
    "),i=!0),n.push(`
  1. ${u(y[1])}
  2. `),r++;continue}if(c.trim()===""){a(),r++;continue}a(),n.push(`

    ${u(c)}

    `),r++}return a(),n.join(` -`)}function Ny(e){return e.split(` -`).reduce((t,n)=>{const r=n.match(/^(#{1,2})\s+(.+)/);return r&&t.push({level:r[1].length,text:r[2],id:r[2].toLowerCase().replace(/[^a-z0-9]+/g,"-")}),t},[])}const Jt={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",zIndex:2e3,display:"flex",alignItems:"flex-start",justifyContent:"flex-end"},panel:{background:"#111217",color:"#f8f9fa",width:"760px",maxWidth:"95vw",height:"100vh",overflowY:"auto",boxShadow:"-4px 0 32px rgba(0,0,0,0.85)",display:"flex",flexDirection:"column"},header:{background:"linear-gradient(135deg,#000000,#151622)",color:"white",padding:"22px 28px",position:"sticky",top:0,zIndex:10,borderBottom:"1px solid #222",display:"flex",alignItems:"center",justifyContent:"space-between"},closeBtn:{background:"none",border:"none",color:"white",fontSize:"22px",cursor:"pointer",lineHeight:1},toc:{background:"#0d1117",borderBottom:"1px solid #1e1f2e",padding:"10px 32px",display:"flex",flexWrap:"wrap",gap:"4px 18px",fontSize:"11px"},body:{padding:"28px 32px",flex:1,fontSize:"13px",lineHeight:"1.75"},footer:{padding:"14px 32px",borderTop:"1px solid #1e1f2e",fontSize:"11px",color:"#555770",textAlign:"center"}},Ay=` +`;function Py(){const[e,t]=k.useState([]),[n,r]=k.useState([]),[o,i]=k.useState(""),[l,a]=k.useState(null),[u,c]=k.useState(!1),[f,m]=k.useState(!0),[y,S]=k.useState(vo),x=Ry("(max-width: 768px)"),v=k.useCallback(()=>{m(!0),F.get("/api/dashboard").then(j=>{t(j.data),r(j.data)}).finally(()=>m(!1))},[]);k.useEffect(()=>{v()},[v]),k.useEffect(()=>{const j=o.toLowerCase();let T=e;y===sr?T=T.filter(_=>_.active_points>=0&&_.active_points<=4):y===ar?T=T.filter(_=>_.active_points>0):y===ur&&(T=T.filter(_=>ul(_.active_points))),j&&(T=T.filter(_=>_.name.toLowerCase().includes(j)||(_.department||"").toLowerCase().includes(j)||(_.supervisor||"").toLowerCase().includes(j))),r(T)},[o,e,y]);const g=e.filter(j=>ul(j.active_points)).length,p=e.filter(j=>j.active_points>0).length,d=e.filter(j=>j.active_points>=0&&j.active_points<=4).length,h=e.reduce((j,T)=>Math.max(j,T.active_points),0);function b(j){S(T=>T===j?vo:j)}function C(j,T={}){const _=y===j;return{...V.statCard,..._?V.statCardActive:{},...T}}return s.jsxs(s.Fragment,{children:[s.jsx("style",{children:Ty}),s.jsxs("div",{style:V.wrap,className:"dashboard-wrap",children:[s.jsxs("div",{style:V.header,className:"dashboard-header",children:[s.jsxs("div",{children:[s.jsx("div",{style:V.title,className:"dashboard-title",children:"Company Dashboard"}),s.jsxs("div",{style:V.subtitle,className:"dashboard-subtitle",children:["Click any employee name to view their full profile",y&&y!==vo&&s.jsxs("span",{style:{marginLeft:"10px",color:"#d4af37",fontWeight:600},children:["· Filtered: ",y===sr?"Elite Standing (0–4 pts)":y===ar?"With Active Points":y===ur?"At Risk":"All",s.jsx("button",{onClick:()=>S(vo),style:{marginLeft:"6px",background:"none",border:"none",color:"#9ca0b8",cursor:"pointer",fontSize:"12px"},title:"Clear filter",children:"✕"})]})]})]}),s.jsxs("div",{style:V.toolbarRight,className:"toolbar-right",children:[s.jsx("input",{style:V.search,className:"search-input",placeholder:"Search name, dept, supervisor…",value:o,onChange:j=>i(j.target.value)}),s.jsx("button",{style:V.auditBtn,className:"toolbar-btn",onClick:()=>c(!0),children:"📋 Audit Log"}),s.jsx("button",{style:V.refreshBtn,className:"toolbar-btn",onClick:v,children:"↻ Refresh"})]})]}),s.jsxs("div",{style:V.statsRow,className:"dashboard-stats",children:[s.jsxs("div",{style:C(cl),className:"dashboard-stat-card",onClick:()=>b(cl),title:"Click to show all employees",children:[s.jsx("div",{style:V.statNum,className:"stat-num",children:e.length}),s.jsx("div",{style:V.statLbl,className:"stat-lbl",children:"Total Employees"}),y===cl&&s.jsx("div",{style:V.filterBadge,children:"▼ Showing All"})]}),s.jsxs("div",{style:C(sr,{borderTop:"3px solid #28a745"}),className:"dashboard-stat-card",onClick:()=>b(sr),title:"Click to filter: Elite Standing (0–4 pts)",children:[s.jsx("div",{style:{...V.statNum,color:"#6ee7b7"},className:"stat-num",children:d}),s.jsx("div",{style:V.statLbl,className:"stat-lbl",children:"Elite Standing (0–4 pts)"}),y===sr&&s.jsx("div",{style:V.filterBadge,children:"▼ Filtered"})]}),s.jsxs("div",{style:C(ar,{borderTop:"3px solid #d4af37"}),className:"dashboard-stat-card",onClick:()=>b(ar),title:"Click to filter: employees with active points",children:[s.jsx("div",{style:{...V.statNum,color:"#ffd666"},className:"stat-num",children:p}),s.jsx("div",{style:V.statLbl,className:"stat-lbl",children:"With Active Points"}),y===ar&&s.jsx("div",{style:V.filterBadge,children:"▼ Filtered"})]}),s.jsxs("div",{style:C(ur,{borderTop:"3px solid #ffb020"}),className:"dashboard-stat-card",onClick:()=>b(ur),title:`Click to filter: at risk (≤${us} pts to next tier)`,children:[s.jsx("div",{style:{...V.statNum,color:"#ffdf8a"},className:"stat-num",children:g}),s.jsxs("div",{style:V.statLbl,className:"stat-lbl",children:["At Risk (≤",us," pts to next tier)"]}),y===ur&&s.jsx("div",{style:V.filterBadge,children:"▼ Filtered"})]}),s.jsxs("div",{style:{...V.statCard,borderTop:"3px solid #c0392b",cursor:"default"},className:"dashboard-stat-card",children:[s.jsx("div",{style:{...V.statNum,color:"#ff8a80"},className:"stat-num",children:h}),s.jsx("div",{style:V.statLbl,className:"stat-lbl",children:"Highest Active Score"})]})]}),f?s.jsx("p",{style:{color:"#77798a",textAlign:"center",padding:"40px"},children:"Loading…"}):x?s.jsx(Ey,{employees:n,onEmployeeClick:a}):s.jsxs("table",{style:V.table,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:V.th,children:"#"}),s.jsx("th",{style:V.th,children:"Employee"}),s.jsx("th",{style:V.th,children:"Department"}),s.jsx("th",{style:V.th,children:"Supervisor"}),s.jsx("th",{style:V.th,children:"Tier / Standing"}),s.jsx("th",{style:V.th,children:"Active Points"}),s.jsx("th",{style:V.th,children:"90-Day Violations"})]})}),s.jsxs("tbody",{children:[n.length===0&&s.jsx("tr",{children:s.jsx("td",{colSpan:7,style:{...V.td,textAlign:"center",...V.zeroRow},children:"No employees found."})}),n.map((j,T)=>{const _=ul(j.active_points),Q=Kt(j.active_points),U=Tp(j.active_points);return s.jsxs("tr",{style:{background:_?"#181200":T%2===0?"#111217":"#151622"},children:[s.jsx("td",{style:{...V.td,color:"#77798a",fontSize:"12px"},children:T+1}),s.jsxs("td",{style:V.td,children:[s.jsx("button",{style:V.nameBtn,onClick:()=>a(j.id),children:j.name}),_&&s.jsxs("span",{style:V.atRiskBadge,children:["⚠ ",U-j.active_points," pt",U-j.active_points>1?"s":""," to ",Kt(U).label.split("—")[0].trim()]})]}),s.jsx("td",{style:{...V.td,color:"#c0c2d6"},children:j.department||"—"}),s.jsx("td",{style:{...V.td,color:"#c0c2d6"},children:j.supervisor||"—"}),s.jsx("td",{style:V.td,children:s.jsx(Ti,{points:j.active_points})}),s.jsx("td",{style:{...V.td,fontWeight:700,color:Q.color,fontSize:"16px"},children:j.active_points}),s.jsx("td",{style:{...V.td,color:"#c0c2d6"},children:j.violation_count})]},j.id)})]})]})]}),l&&s.jsx(vy,{employeeId:l,onClose:()=>{a(null),v()}}),u&&s.jsx(by,{onClose:()=>c(!1)})]})}function Ny(e){const t=e.split(` +`),n=[];let r=0,o=!1,i=!1,l=!1;const a=()=>{o&&(n.push(""),o=!1),i&&(n.push("
"),i=!1),l&&(n.push("
${u(x)}
"),l=!1)},u=c=>c.replace(/&/g,"&").replace(//g,">").replace(/\*\*(.+?)\*\*/g,"$1").replace(/`([^`]+)`/g,"$1");for(;r"),r++;continue}const f=c.match(/^(#{1,4})\s+(.+)/);if(f){a();const S=f[1].length,x=f[2].toLowerCase().replace(/[^a-z0-9]+/g,"-");n.push(`${u(f[2])}`),r++;continue}if(c.trim().startsWith("|")){const S=c.trim().replace(/^\|||\|$/g,"").split("|").map(x=>x.trim());if(l){n.push(""),S.forEach(x=>n.push(`${u(x)}`)),n.push(""),r++;continue}else{a(),l=!0,n.push(""),S.forEach(x=>n.push(``)),n.push(""),r++,r"),i=!1),n.push("
    "),o=!0),n.push(`
  • ${u(m[1])}
  • `),r++;continue}const y=c.match(/^\d+\.\s+(.*)/);if(y){l&&a(),i||(o&&(n.push("
"),o=!1),n.push("
    "),i=!0),n.push(`
  1. ${u(y[1])}
  2. `),r++;continue}if(c.trim()===""){a(),r++;continue}a(),n.push(`

    ${u(c)}

    `),r++}return a(),n.join(` +`)}function Ay(e){return e.split(` +`).reduce((t,n)=>{const r=n.match(/^(#{1,2})\s+(.+)/);return r&&t.push({level:r[1].length,text:r[2],id:r[2].toLowerCase().replace(/[^a-z0-9]+/g,"-")}),t},[])}const Jt={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",zIndex:2e3,display:"flex",alignItems:"flex-start",justifyContent:"flex-end"},panel:{background:"#111217",color:"#f8f9fa",width:"760px",maxWidth:"95vw",height:"100vh",overflowY:"auto",boxShadow:"-4px 0 32px rgba(0,0,0,0.85)",display:"flex",flexDirection:"column"},header:{background:"linear-gradient(135deg,#000000,#151622)",color:"white",padding:"22px 28px",position:"sticky",top:0,zIndex:10,borderBottom:"1px solid #222",display:"flex",alignItems:"center",justifyContent:"space-between"},closeBtn:{background:"none",border:"none",color:"white",fontSize:"22px",cursor:"pointer",lineHeight:1},toc:{background:"#0d1117",borderBottom:"1px solid #1e1f2e",padding:"10px 32px",display:"flex",flexWrap:"wrap",gap:"4px 18px",fontSize:"11px"},body:{padding:"28px 32px",flex:1,fontSize:"13px",lineHeight:"1.75"},footer:{padding:"14px 32px",borderTop:"1px solid #1e1f2e",fontSize:"11px",color:"#555770",textAlign:"center"}},zy=` .adm h1 { font-size:21px; font-weight:800; color:#f8f9fa; margin:28px 0 10px; border-bottom:1px solid #2a2b3a; padding-bottom:8px } .adm h2 { font-size:16px; font-weight:700; color:#d4af37; margin:28px 0 6px; letter-spacing:.2px } .adm h3 { font-size:12px; font-weight:700; color:#90caf9; margin:18px 0 4px; text-transform:uppercase; letter-spacing:.5px } @@ -134,6 +134,33 @@ Internal tool for CPAS violation documentation, workforce standing management, a --- +## Authentication & User Accounts + +The application is protected by a login screen. Every page and every API action requires a valid signed-in session — unauthenticated visitors cannot view or edit any CPAS data. + +### Signing in + +Open the app and enter your username and password in the login popup. A session lasts **7 days**, after which you'll be asked to sign in again. Use the **Logout** button in the top-right of the nav bar to end your session immediately. + +### The bootstrap admin + +A single admin account is created automatically from the container's environment variables (\`ADMIN_USERNAME\` / \`ADMIN_PASSWORD\`). Notes: + +- Its password is **owned by the Docker environment** — it re-syncs on every container start. To rotate it, change \`ADMIN_PASSWORD\` in the container settings and restart. It cannot be changed from the UI (a UI change would be overwritten on the next restart). +- Set a strong \`ADMIN_PASSWORD\` at deploy time. The image ships with a placeholder default that must be overridden. + +### Managing users (admin only) + +Admins see a **Users** button in the nav bar that opens the user-management panel. From there you can: + +- **Add a user** — username, password (min 6 characters), and a role of **User** or **Admin**. +- **Reset a password** for any account. +- **Delete a user** — they lose access immediately. You cannot delete your own account. + +Roles: **Admin** can manage users plus everything a User can do; **User** can view and edit CPAS data but cannot manage accounts. Login attempts and all account changes are written to the audit log. + +--- + ## How Scoring Works Every violation carries a **point value** set at the time of submission. Points count toward an employee's score only within a **rolling 90-day window** — once a violation is older than 90 days it automatically drops off and the score recalculates. @@ -315,6 +342,7 @@ Toasts auto-dismiss after a few seconds (errors persist longer). Each toast has - Acknowledgment signature field — employee name + date on form and PDF - Toast notification system — global feedback for all user actions - Backfill Snapshots — per-employee repair tool that rebuilds the prior-points snapshot on every violation when older PDFs drift from current data +- Authentication — login screen gating all routes, env-bootstrapped admin account, and admin-managed user accounts with admin/user roles --- @@ -323,7 +351,7 @@ Toasts auto-dismiss after a few seconds (errors persist longer). Each toast has These are well-scoped additions that fit the current architecture without major changes. - **CSV export** — one endpoint returning violations or dashboard data as a downloadable CSV for payroll or external reporting. -- **Supervisor-scoped view** — filter the dashboard to a single supervisor's team via URL param; useful in multi-supervisor environments without requiring full auth. +- **Supervisor-scoped view** — filter the dashboard to a single supervisor's team via URL param; useful in multi-supervisor environments. --- @@ -342,13 +370,13 @@ Larger features that require more design work or infrastructure. These require meaningful infrastructure additions and should be evaluated against actual operational need before committing. -- **Multi-user auth** — role-based login (admin, supervisor, read-only). Currently the app assumes a trusted internal network with no authentication layer. +- **Expanded roles** — finer-grained permissions beyond the current admin/user split (e.g. supervisor-scoped or read-only roles). - **Tier escalation alerts** — email or in-app notification when an employee crosses into Tier 2+, automatically routed to their supervisor. - **Scheduled digest** — weekly email summary to supervisors showing their employees' current standings and any approaching thresholds. - **Automated DB backup** — scheduled snapshot of the database to a mounted backup volume or remote destination. - **Bulk CSV import** — migrate historical violation records from paper logs or a prior system. - **Dark/light theme toggle** — UI is currently dark-only. -`;function Oy({onClose:e}){const t=k.useRef(null),n=zy($u),r=Ny($u);k.useEffect(()=>{const i=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e]);const o=i=>{var a;const l=(a=t.current)==null?void 0:a.querySelector(`#${i}`);l&&l.scrollIntoView({behavior:"smooth",block:"start"})};return s.jsxs("div",{style:Jt.overlay,onClick:i=>{i.target===i.currentTarget&&e()},children:[s.jsx("style",{children:Ay}),s.jsxs("div",{style:Jt.panel,onClick:i=>i.stopPropagation(),children:[s.jsxs("div",{style:Jt.header,children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:"17px",fontWeight:800,letterSpacing:".3px"},children:"📋 CPAS Tracker — Admin Guide"}),s.jsx("div",{style:{fontSize:"11px",color:"#9ca0b8",marginTop:"3px"},children:"Feature map · workflows · roadmap · Esc or click outside to close"})]}),s.jsx("button",{style:Jt.closeBtn,onClick:e,"aria-label":"Close",children:"✕"})]}),s.jsx("div",{style:Jt.toc,children:r.map(i=>s.jsxs("button",{onClick:()=>o(i.id),style:{background:"none",border:"none",cursor:"pointer",padding:"3px 0",color:i.level===1?"#f8f9fa":"#d4af37",fontWeight:i.level===1?700:500,fontSize:"11px"},children:[i.level===2?"↳ ":"",i.text]},i.id))}),s.jsx("div",{ref:t,style:Jt.body,className:"adm",dangerouslySetInnerHTML:{__html:n}}),s.jsx("div",{style:Jt.footer,children:"CPAS Violation Tracker · internal admin use only"})]})]})}const fa="cpas_token";function zf(){return localStorage.getItem(fa)}function Dy(e){localStorage.setItem(fa,e)}function cs(){localStorage.removeItem(fa)}F.interceptors.request.use(e=>{const t=zf();return t&&(e.headers.Authorization=`Bearer ${t}`),e});let ds=null;function Ly(e){ds=e}F.interceptors.response.use(e=>e,e=>(e.response&&e.response.status===401&&(cs(),ds&&ds()),Promise.reject(e)));const Me={overlay:{position:"fixed",inset:0,background:"#050608",display:"flex",alignItems:"center",justifyContent:"center",zIndex:3e3,fontFamily:"'Segoe UI', Arial, sans-serif"},modal:{width:"380px",maxWidth:"92vw",background:"#111217",borderRadius:"12px",boxShadow:"0 16px 40px rgba(0,0,0,0.8)",color:"#f8f9fa",overflow:"hidden",border:"1px solid #2a2b3a"},header:{padding:"24px",borderBottom:"1px solid #222",textAlign:"center",background:"linear-gradient(135deg, #000000, #151622)"},logo:{height:"34px",marginBottom:"12px"},title:{fontSize:"18px",fontWeight:800,letterSpacing:"0.5px"},subtitle:{fontSize:"12px",color:"#c0c2d6",marginTop:"4px"},body:{padding:"22px 24px 8px 24px"},label:{fontSize:"13px",fontWeight:600,marginBottom:"4px",color:"#e5e7f1"},input:{width:"100%",padding:"10px 12px",borderRadius:"6px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontSize:"14px",fontFamily:"inherit",marginBottom:"16px",boxSizing:"border-box"},error:{background:"#3a1414",borderRadius:"6px",padding:"9px 11px",fontSize:"12px",color:"#ff9b9b",border:"1px solid #c0392b",marginBottom:"14px"},footer:{padding:"0 24px 22px 24px"},btn:{width:"100%",padding:"11px",borderRadius:"6px",border:"none",background:"linear-gradient(135deg, #d4af37 0%, #ffdf8a 100%)",color:"#000",fontWeight:700,fontSize:"14px",cursor:"pointer",textTransform:"uppercase",letterSpacing:"0.5px"}};function Fy({onSuccess:e}){const[t,n]=k.useState(""),[r,o]=k.useState(""),[i,l]=k.useState(""),[a,u]=k.useState(!1),c=async p=>{var m,y;p.preventDefault(),l(""),u(!0);try{const{data:S}=await F.post("/api/auth/login",{username:t,password:r});Dy(S.token),e(S.user)}catch(S){l(((y=(m=S.response)==null?void 0:m.data)==null?void 0:y.error)||"Login failed. Please try again."),u(!1)}};return s.jsx("div",{style:Me.overlay,children:s.jsxs("form",{style:Me.modal,onSubmit:c,children:[s.jsxs("div",{style:Me.header,children:[s.jsx("img",{src:"/static/mpm-logo.png",alt:"MPM",style:Me.logo}),s.jsx("div",{style:Me.title,children:"CPAS Tracker"}),s.jsx("div",{style:Me.subtitle,children:"Sign in to continue"})]}),s.jsxs("div",{style:Me.body,children:[i&&s.jsx("div",{style:Me.error,children:i}),s.jsx("div",{style:Me.label,children:"Username"}),s.jsx("input",{style:Me.input,value:t,onChange:p=>n(p.target.value),autoFocus:!0,autoComplete:"username"}),s.jsx("div",{style:Me.label,children:"Password"}),s.jsx("input",{style:Me.input,type:"password",value:r,onChange:p=>o(p.target.value),autoComplete:"current-password"})]}),s.jsx("div",{style:Me.footer,children:s.jsx("button",{style:{...Me.btn,opacity:a?.7:1},type:"submit",disabled:a,children:a?"Signing in…":"Sign In"})})]})})}const J={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2500},modal:{width:"560px",maxWidth:"95vw",maxHeight:"90vh",background:"#111217",borderRadius:"12px",boxShadow:"0 16px 40px rgba(0,0,0,0.8)",color:"#f8f9fa",overflow:"hidden",border:"1px solid #2a2b3a",display:"flex",flexDirection:"column"},header:{padding:"18px 24px",borderBottom:"1px solid #222",background:"linear-gradient(135deg, #000000, #151622)",display:"flex",justifyContent:"space-between",alignItems:"center"},title:{fontSize:"18px",fontWeight:700},close:{background:"none",border:"none",color:"#9ca0b8",fontSize:"22px",cursor:"pointer",lineHeight:1},body:{padding:"18px 24px",overflowY:"auto"},error:{background:"#3a1414",borderRadius:"6px",padding:"9px 11px",fontSize:"12px",color:"#ff9b9b",border:"1px solid #c0392b",marginBottom:"14px"},table:{width:"100%",borderCollapse:"collapse",marginBottom:"20px",fontSize:"13px"},th:{textAlign:"left",padding:"8px 10px",color:"#9ca0b8",borderBottom:"1px solid #222",fontWeight:600},td:{padding:"8px 10px",borderBottom:"1px solid #1a1b22"},roleBadge:e=>({fontSize:"11px",fontWeight:700,padding:"2px 8px",borderRadius:"10px",background:e?"#3b2e00":"#1a2733",color:e?"#ffd666":"#7fc4ff",border:`1px solid ${e?"#d4af37":"#2a4a66"}`}),smallBtn:{padding:"4px 10px",borderRadius:"5px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontSize:"12px",cursor:"pointer",marginRight:"6px"},dangerBtn:{padding:"4px 10px",borderRadius:"5px",border:"1px solid #5a2020",background:"#2a1010",color:"#ff9b9b",fontSize:"12px",cursor:"pointer"},sectionTitle:{fontSize:"14px",fontWeight:700,margin:"6px 0 12px 0",color:"#e5e7f1"},row:{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-end"},field:{flex:"1 1 140px"},label:{fontSize:"12px",fontWeight:600,marginBottom:"4px",color:"#e5e7f1"},input:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontSize:"13px",fontFamily:"inherit",boxSizing:"border-box"},addBtn:{padding:"9px 18px",borderRadius:"6px",border:"none",background:"linear-gradient(135deg, #d4af37 0%, #ffdf8a 100%)",color:"#000",fontWeight:700,fontSize:"13px",cursor:"pointer"}};function By({currentUser:e,onClose:t}){const[n,r]=k.useState([]),[o,i]=k.useState(""),[l,a]=k.useState(""),[u,c]=k.useState(""),[p,m]=k.useState("user"),y=k.useCallback(async()=>{var g,f;try{const{data:d}=await F.get("/api/users");r(d)}catch(d){i(((f=(g=d.response)==null?void 0:g.data)==null?void 0:f.error)||"Failed to load users")}},[]);k.useEffect(()=>{y()},[y]);const S=async g=>{var f,d;g.preventDefault(),i("");try{await F.post("/api/users",{username:l,password:u,role:p}),a(""),c(""),m("user"),y()}catch(h){i(((d=(f=h.response)==null?void 0:f.data)==null?void 0:d.error)||"Failed to create user")}},x=async g=>{var f,d;if(window.confirm(`Delete user "${g.username}"? They will lose access immediately.`)){i("");try{await F.delete(`/api/users/${g.id}`),y()}catch(h){i(((d=(f=h.response)==null?void 0:f.data)==null?void 0:d.error)||"Failed to delete user")}}},v=async g=>{var d,h;const f=window.prompt(`Enter a new password for "${g.username}" (min 6 characters):`);if(f!=null){i("");try{await F.patch(`/api/users/${g.id}/password`,{password:f}),window.alert("Password updated.")}catch(b){i(((h=(d=b.response)==null?void 0:d.data)==null?void 0:h.error)||"Failed to update password")}}};return s.jsx("div",{style:J.overlay,onClick:g=>{g.target===g.currentTarget&&t()},children:s.jsxs("div",{style:J.modal,onClick:g=>g.stopPropagation(),children:[s.jsxs("div",{style:J.header,children:[s.jsx("div",{style:J.title,children:"User Management"}),s.jsx("button",{style:J.close,onClick:t,title:"Close",children:"×"})]}),s.jsxs("div",{style:J.body,children:[o&&s.jsx("div",{style:J.error,children:o}),s.jsxs("table",{style:J.table,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:J.th,children:"Username"}),s.jsx("th",{style:J.th,children:"Role"}),s.jsx("th",{style:J.th,children:"Actions"})]})}),s.jsx("tbody",{children:n.map(g=>s.jsxs("tr",{children:[s.jsxs("td",{style:J.td,children:[g.username,g.id===(e==null?void 0:e.id)&&s.jsx("span",{style:{color:"#9ca0b8"},children:" (you)"})]}),s.jsx("td",{style:J.td,children:s.jsx("span",{style:J.roleBadge(g.role==="admin"),children:g.role})}),s.jsxs("td",{style:J.td,children:[s.jsx("button",{style:J.smallBtn,onClick:()=>v(g),children:"Reset Password"}),g.id!==(e==null?void 0:e.id)&&s.jsx("button",{style:J.dangerBtn,onClick:()=>x(g),children:"Delete"})]})]},g.id))})]}),s.jsx("div",{style:J.sectionTitle,children:"Add New User"}),s.jsxs("form",{style:J.row,onSubmit:S,children:[s.jsxs("div",{style:J.field,children:[s.jsx("div",{style:J.label,children:"Username"}),s.jsx("input",{style:J.input,value:l,onChange:g=>a(g.target.value),required:!0})]}),s.jsxs("div",{style:J.field,children:[s.jsx("div",{style:J.label,children:"Password"}),s.jsx("input",{style:J.input,type:"password",value:u,onChange:g=>c(g.target.value),required:!0})]}),s.jsxs("div",{style:{...J.field,flex:"0 0 110px"},children:[s.jsx("div",{style:J.label,children:"Role"}),s.jsxs("select",{style:J.input,value:p,onChange:g=>m(g.target.value),children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]})]}),s.jsx("button",{style:J.addBtn,type:"submit",children:"Add User"})]})]})]})})}const Wu="https://git.alwisp.com/jason/cpas",Hu=new Date("2026-03-06T11:33:32-06:00");function Vu(e){const t=Math.floor((Date.now()-e.getTime())/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),i=t%60;return`${n}d ${String(r).padStart(2,"0")}h ${String(o).padStart(2,"0")}m ${String(i).padStart(2,"0")}s`}function Iy(){const[e,t]=k.useState(()=>Vu(Hu));return k.useEffect(()=>{const n=setInterval(()=>t(Vu(Hu)),1e3);return()=>clearInterval(n)},[]),s.jsxs("span",{title:"Time since first commit",style:{display:"inline-flex",alignItems:"center",gap:"5px"},children:[s.jsx("span",{style:{width:"7px",height:"7px",borderRadius:"50%",background:"#22c55e",display:"inline-block",animation:"cpas-pulse 1.4s ease-in-out infinite"}}),e]})}function My(){return s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle"},children:s.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})})}function Uy({version:e}){const t=new Date().getFullYear(),n=(e==null?void 0:e.shortSha)||null,r=e!=null&&e.buildTime?new Date(e.buildTime).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):null;return s.jsxs(s.Fragment,{children:[s.jsx("style",{children:` +`;function Oy({onClose:e}){const t=k.useRef(null),n=Ny($u),r=Ay($u);k.useEffect(()=>{const i=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e]);const o=i=>{var a;const l=(a=t.current)==null?void 0:a.querySelector(`#${i}`);l&&l.scrollIntoView({behavior:"smooth",block:"start"})};return s.jsxs("div",{style:Jt.overlay,onClick:i=>{i.target===i.currentTarget&&e()},children:[s.jsx("style",{children:zy}),s.jsxs("div",{style:Jt.panel,onClick:i=>i.stopPropagation(),children:[s.jsxs("div",{style:Jt.header,children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:"17px",fontWeight:800,letterSpacing:".3px"},children:"📋 CPAS Tracker — Admin Guide"}),s.jsx("div",{style:{fontSize:"11px",color:"#9ca0b8",marginTop:"3px"},children:"Feature map · workflows · roadmap · Esc or click outside to close"})]}),s.jsx("button",{style:Jt.closeBtn,onClick:e,"aria-label":"Close",children:"✕"})]}),s.jsx("div",{style:Jt.toc,children:r.map(i=>s.jsxs("button",{onClick:()=>o(i.id),style:{background:"none",border:"none",cursor:"pointer",padding:"3px 0",color:i.level===1?"#f8f9fa":"#d4af37",fontWeight:i.level===1?700:500,fontSize:"11px"},children:[i.level===2?"↳ ":"",i.text]},i.id))}),s.jsx("div",{ref:t,style:Jt.body,className:"adm",dangerouslySetInnerHTML:{__html:n}}),s.jsx("div",{style:Jt.footer,children:"CPAS Violation Tracker · internal admin use only"})]})]})}const pa="cpas_token";function Pp(){return localStorage.getItem(pa)}function Dy(e){localStorage.setItem(pa,e)}function cs(){localStorage.removeItem(pa)}F.interceptors.request.use(e=>{const t=Pp();return t&&(e.headers.Authorization=`Bearer ${t}`),e});let ds=null;function Ly(e){ds=e}F.interceptors.response.use(e=>e,e=>(e.response&&e.response.status===401&&(cs(),ds&&ds()),Promise.reject(e)));const Me={overlay:{position:"fixed",inset:0,background:"#050608",display:"flex",alignItems:"center",justifyContent:"center",zIndex:3e3,fontFamily:"'Segoe UI', Arial, sans-serif"},modal:{width:"380px",maxWidth:"92vw",background:"#111217",borderRadius:"12px",boxShadow:"0 16px 40px rgba(0,0,0,0.8)",color:"#f8f9fa",overflow:"hidden",border:"1px solid #2a2b3a"},header:{padding:"24px",borderBottom:"1px solid #222",textAlign:"center",background:"linear-gradient(135deg, #000000, #151622)"},logo:{height:"34px",marginBottom:"12px"},title:{fontSize:"18px",fontWeight:800,letterSpacing:"0.5px"},subtitle:{fontSize:"12px",color:"#c0c2d6",marginTop:"4px"},body:{padding:"22px 24px 8px 24px"},label:{fontSize:"13px",fontWeight:600,marginBottom:"4px",color:"#e5e7f1"},input:{width:"100%",padding:"10px 12px",borderRadius:"6px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontSize:"14px",fontFamily:"inherit",marginBottom:"16px",boxSizing:"border-box"},error:{background:"#3a1414",borderRadius:"6px",padding:"9px 11px",fontSize:"12px",color:"#ff9b9b",border:"1px solid #c0392b",marginBottom:"14px"},footer:{padding:"0 24px 22px 24px"},btn:{width:"100%",padding:"11px",borderRadius:"6px",border:"none",background:"linear-gradient(135deg, #d4af37 0%, #ffdf8a 100%)",color:"#000",fontWeight:700,fontSize:"14px",cursor:"pointer",textTransform:"uppercase",letterSpacing:"0.5px"}};function Fy({onSuccess:e}){const[t,n]=k.useState(""),[r,o]=k.useState(""),[i,l]=k.useState(""),[a,u]=k.useState(!1),c=async f=>{var m,y;f.preventDefault(),l(""),u(!0);try{const{data:S}=await F.post("/api/auth/login",{username:t,password:r});Dy(S.token),e(S.user)}catch(S){l(((y=(m=S.response)==null?void 0:m.data)==null?void 0:y.error)||"Login failed. Please try again."),u(!1)}};return s.jsx("div",{style:Me.overlay,children:s.jsxs("form",{style:Me.modal,onSubmit:c,children:[s.jsxs("div",{style:Me.header,children:[s.jsx("img",{src:"/static/mpm-logo.png",alt:"MPM",style:Me.logo}),s.jsx("div",{style:Me.title,children:"CPAS Tracker"}),s.jsx("div",{style:Me.subtitle,children:"Sign in to continue"})]}),s.jsxs("div",{style:Me.body,children:[i&&s.jsx("div",{style:Me.error,children:i}),s.jsx("div",{style:Me.label,children:"Username"}),s.jsx("input",{style:Me.input,value:t,onChange:f=>n(f.target.value),autoFocus:!0,autoComplete:"username"}),s.jsx("div",{style:Me.label,children:"Password"}),s.jsx("input",{style:Me.input,type:"password",value:r,onChange:f=>o(f.target.value),autoComplete:"current-password"})]}),s.jsx("div",{style:Me.footer,children:s.jsx("button",{style:{...Me.btn,opacity:a?.7:1},type:"submit",disabled:a,children:a?"Signing in…":"Sign In"})})]})})}const J={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2500},modal:{width:"560px",maxWidth:"95vw",maxHeight:"90vh",background:"#111217",borderRadius:"12px",boxShadow:"0 16px 40px rgba(0,0,0,0.8)",color:"#f8f9fa",overflow:"hidden",border:"1px solid #2a2b3a",display:"flex",flexDirection:"column"},header:{padding:"18px 24px",borderBottom:"1px solid #222",background:"linear-gradient(135deg, #000000, #151622)",display:"flex",justifyContent:"space-between",alignItems:"center"},title:{fontSize:"18px",fontWeight:700},close:{background:"none",border:"none",color:"#9ca0b8",fontSize:"22px",cursor:"pointer",lineHeight:1},body:{padding:"18px 24px",overflowY:"auto"},error:{background:"#3a1414",borderRadius:"6px",padding:"9px 11px",fontSize:"12px",color:"#ff9b9b",border:"1px solid #c0392b",marginBottom:"14px"},table:{width:"100%",borderCollapse:"collapse",marginBottom:"20px",fontSize:"13px"},th:{textAlign:"left",padding:"8px 10px",color:"#9ca0b8",borderBottom:"1px solid #222",fontWeight:600},td:{padding:"8px 10px",borderBottom:"1px solid #1a1b22"},roleBadge:e=>({fontSize:"11px",fontWeight:700,padding:"2px 8px",borderRadius:"10px",background:e?"#3b2e00":"#1a2733",color:e?"#ffd666":"#7fc4ff",border:`1px solid ${e?"#d4af37":"#2a4a66"}`}),smallBtn:{padding:"4px 10px",borderRadius:"5px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontSize:"12px",cursor:"pointer",marginRight:"6px"},dangerBtn:{padding:"4px 10px",borderRadius:"5px",border:"1px solid #5a2020",background:"#2a1010",color:"#ff9b9b",fontSize:"12px",cursor:"pointer"},sectionTitle:{fontSize:"14px",fontWeight:700,margin:"6px 0 12px 0",color:"#e5e7f1"},row:{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-end"},field:{flex:"1 1 140px"},label:{fontSize:"12px",fontWeight:600,marginBottom:"4px",color:"#e5e7f1"},input:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:"1px solid #333544",background:"#050608",color:"#f8f9fa",fontSize:"13px",fontFamily:"inherit",boxSizing:"border-box"},addBtn:{padding:"9px 18px",borderRadius:"6px",border:"none",background:"linear-gradient(135deg, #d4af37 0%, #ffdf8a 100%)",color:"#000",fontWeight:700,fontSize:"13px",cursor:"pointer"}};function Iy({currentUser:e,onClose:t}){const[n,r]=k.useState([]),[o,i]=k.useState(""),[l,a]=k.useState(""),[u,c]=k.useState(""),[f,m]=k.useState("user"),y=k.useCallback(async()=>{var g,p;try{const{data:d}=await F.get("/api/users");r(d)}catch(d){i(((p=(g=d.response)==null?void 0:g.data)==null?void 0:p.error)||"Failed to load users")}},[]);k.useEffect(()=>{y()},[y]);const S=async g=>{var p,d;g.preventDefault(),i("");try{await F.post("/api/users",{username:l,password:u,role:f}),a(""),c(""),m("user"),y()}catch(h){i(((d=(p=h.response)==null?void 0:p.data)==null?void 0:d.error)||"Failed to create user")}},x=async g=>{var p,d;if(window.confirm(`Delete user "${g.username}"? They will lose access immediately.`)){i("");try{await F.delete(`/api/users/${g.id}`),y()}catch(h){i(((d=(p=h.response)==null?void 0:p.data)==null?void 0:d.error)||"Failed to delete user")}}},v=async g=>{var d,h;const p=window.prompt(`Enter a new password for "${g.username}" (min 6 characters):`);if(p!=null){i("");try{await F.patch(`/api/users/${g.id}/password`,{password:p}),window.alert("Password updated.")}catch(b){i(((h=(d=b.response)==null?void 0:d.data)==null?void 0:h.error)||"Failed to update password")}}};return s.jsx("div",{style:J.overlay,onClick:g=>{g.target===g.currentTarget&&t()},children:s.jsxs("div",{style:J.modal,onClick:g=>g.stopPropagation(),children:[s.jsxs("div",{style:J.header,children:[s.jsx("div",{style:J.title,children:"User Management"}),s.jsx("button",{style:J.close,onClick:t,title:"Close",children:"×"})]}),s.jsxs("div",{style:J.body,children:[o&&s.jsx("div",{style:J.error,children:o}),s.jsxs("table",{style:J.table,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:J.th,children:"Username"}),s.jsx("th",{style:J.th,children:"Role"}),s.jsx("th",{style:J.th,children:"Actions"})]})}),s.jsx("tbody",{children:n.map(g=>s.jsxs("tr",{children:[s.jsxs("td",{style:J.td,children:[g.username,g.id===(e==null?void 0:e.id)&&s.jsx("span",{style:{color:"#9ca0b8"},children:" (you)"})]}),s.jsx("td",{style:J.td,children:s.jsx("span",{style:J.roleBadge(g.role==="admin"),children:g.role})}),s.jsxs("td",{style:J.td,children:[s.jsx("button",{style:J.smallBtn,onClick:()=>v(g),children:"Reset Password"}),g.id!==(e==null?void 0:e.id)&&s.jsx("button",{style:J.dangerBtn,onClick:()=>x(g),children:"Delete"})]})]},g.id))})]}),s.jsx("div",{style:J.sectionTitle,children:"Add New User"}),s.jsxs("form",{style:J.row,onSubmit:S,children:[s.jsxs("div",{style:J.field,children:[s.jsx("div",{style:J.label,children:"Username"}),s.jsx("input",{style:J.input,value:l,onChange:g=>a(g.target.value),required:!0})]}),s.jsxs("div",{style:J.field,children:[s.jsx("div",{style:J.label,children:"Password"}),s.jsx("input",{style:J.input,type:"password",value:u,onChange:g=>c(g.target.value),required:!0})]}),s.jsxs("div",{style:{...J.field,flex:"0 0 110px"},children:[s.jsx("div",{style:J.label,children:"Role"}),s.jsxs("select",{style:J.input,value:f,onChange:g=>m(g.target.value),children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]})]}),s.jsx("button",{style:J.addBtn,type:"submit",children:"Add User"})]})]})]})})}const Wu="https://git.alwisp.com/jason/cpas",Hu=new Date("2026-03-06T11:33:32-06:00");function Vu(e){const t=Math.floor((Date.now()-e.getTime())/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),i=t%60;return`${n}d ${String(r).padStart(2,"0")}h ${String(o).padStart(2,"0")}m ${String(i).padStart(2,"0")}s`}function By(){const[e,t]=k.useState(()=>Vu(Hu));return k.useEffect(()=>{const n=setInterval(()=>t(Vu(Hu)),1e3);return()=>clearInterval(n)},[]),s.jsxs("span",{title:"Time since first commit",style:{display:"inline-flex",alignItems:"center",gap:"5px"},children:[s.jsx("span",{style:{width:"7px",height:"7px",borderRadius:"50%",background:"#22c55e",display:"inline-block",animation:"cpas-pulse 1.4s ease-in-out infinite"}}),e]})}function My(){return s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle"},children:s.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})})}function Uy({version:e}){const t=new Date().getFullYear(),n=(e==null?void 0:e.shortSha)||null,r=e!=null&&e.buildTime?new Date(e.buildTime).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):null;return s.jsxs(s.Fragment,{children:[s.jsx("style",{children:` @keyframes cpas-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.75); } @@ -364,7 +392,7 @@ These require meaningful infrastructure additions and should be evaluated agains gap: 8px; } } - `}),s.jsxs("footer",{style:Zt.footer,className:"footer-content",children:[s.jsxs("span",{style:Zt.copy,children:["© ",t," Jason Stedwell"]}),s.jsx("span",{style:Zt.sep,children:"·"}),s.jsx(Iy,{}),s.jsx("span",{style:Zt.sep,children:"·"}),s.jsxs("a",{href:Wu,target:"_blank",rel:"noopener noreferrer",style:Zt.link,children:[s.jsx(My,{})," cpas"]}),n&&n!=="dev"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{style:Zt.sep,children:"·"}),s.jsx("a",{href:`${Wu}/commit/${e.sha}`,target:"_blank",rel:"noopener noreferrer",style:Zt.link,title:r?`Built ${r}`:"View commit",children:n})]})]})]})}const $y=[{id:"dashboard",label:"📊 Dashboard"},{id:"violation",label:"+ New Violation"}];function Wy(e){const[t,n]=k.useState(!1);return k.useEffect(()=>{const r=window.matchMedia(e);r.matches!==t&&n(r.matches);const o=()=>n(r.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[t,e]),t}const et={app:{minHeight:"100vh",background:"#050608",fontFamily:"'Segoe UI', Arial, sans-serif",color:"#f8f9fa",display:"flex",flexDirection:"column"},nav:{background:"#000000",padding:"0 40px",display:"flex",alignItems:"center",gap:0,borderBottom:"1px solid #333"},logoWrap:{display:"flex",alignItems:"center",marginRight:"32px",padding:"14px 0"},logoImg:{height:"28px",marginRight:"10px"},logoText:{color:"#f8f9fa",fontWeight:800,fontSize:"18px",letterSpacing:"0.5px"},tab:e=>({padding:"18px 22px",color:e?"#f8f9fa":"rgba(248,249,250,0.6)",borderBottom:e?"3px solid #d4af37":"3px solid transparent",cursor:"pointer",fontWeight:e?700:400,fontSize:"14px",background:"none",border:"none"}),docsBtn:{marginLeft:"auto",background:"none",border:"1px solid #2a2b3a",color:"#9ca0b8",borderRadius:"6px",padding:"6px 14px",fontSize:"12px",cursor:"pointer",fontWeight:600,letterSpacing:"0.3px",display:"flex",alignItems:"center",gap:"6px"},navBtn:{background:"none",border:"1px solid #2a2b3a",color:"#9ca0b8",borderRadius:"6px",padding:"6px 14px",fontSize:"12px",cursor:"pointer",fontWeight:600,letterSpacing:"0.3px",display:"flex",alignItems:"center",gap:"6px"},userBadge:{fontSize:"12px",color:"#c0c2d6",fontWeight:600,display:"flex",alignItems:"center",gap:"5px"},main:{flex:1},card:{maxWidth:"1100px",margin:"30px auto",background:"#111217",borderRadius:"10px",boxShadow:"0 2px 16px rgba(0,0,0,0.6)",border:"1px solid #222"}},Hy=` + `}),s.jsxs("footer",{style:Zt.footer,className:"footer-content",children:[s.jsxs("span",{style:Zt.copy,children:["© ",t," Jason Stedwell"]}),s.jsx("span",{style:Zt.sep,children:"·"}),s.jsx(By,{}),s.jsx("span",{style:Zt.sep,children:"·"}),s.jsxs("a",{href:Wu,target:"_blank",rel:"noopener noreferrer",style:Zt.link,children:[s.jsx(My,{})," cpas"]}),n&&n!=="dev"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{style:Zt.sep,children:"·"}),s.jsx("a",{href:`${Wu}/commit/${e.sha}`,target:"_blank",rel:"noopener noreferrer",style:Zt.link,title:r?`Built ${r}`:"View commit",children:n})]})]})]})}const $y=[{id:"dashboard",label:"📊 Dashboard"},{id:"violation",label:"+ New Violation"}];function Wy(e){const[t,n]=k.useState(!1);return k.useEffect(()=>{const r=window.matchMedia(e);r.matches!==t&&n(r.matches);const o=()=>n(r.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[t,e]),t}const et={app:{minHeight:"100vh",background:"#050608",fontFamily:"'Segoe UI', Arial, sans-serif",color:"#f8f9fa",display:"flex",flexDirection:"column"},nav:{background:"#000000",padding:"0 40px",display:"flex",alignItems:"center",gap:0,borderBottom:"1px solid #333"},logoWrap:{display:"flex",alignItems:"center",marginRight:"32px",padding:"14px 0"},logoImg:{height:"28px",marginRight:"10px"},logoText:{color:"#f8f9fa",fontWeight:800,fontSize:"18px",letterSpacing:"0.5px"},tab:e=>({padding:"18px 22px",color:e?"#f8f9fa":"rgba(248,249,250,0.6)",borderBottom:e?"3px solid #d4af37":"3px solid transparent",cursor:"pointer",fontWeight:e?700:400,fontSize:"14px",background:"none",border:"none"}),docsBtn:{marginLeft:"auto",background:"none",border:"1px solid #2a2b3a",color:"#9ca0b8",borderRadius:"6px",padding:"6px 14px",fontSize:"12px",cursor:"pointer",fontWeight:600,letterSpacing:"0.3px",display:"flex",alignItems:"center",gap:"6px"},navBtn:{background:"none",border:"1px solid #2a2b3a",color:"#9ca0b8",borderRadius:"6px",padding:"6px 14px",fontSize:"12px",cursor:"pointer",fontWeight:600,letterSpacing:"0.3px",display:"flex",alignItems:"center",gap:"6px"},userBadge:{fontSize:"12px",color:"#c0c2d6",fontWeight:600,display:"flex",alignItems:"center",gap:"5px"},main:{flex:1},card:{maxWidth:"1100px",margin:"30px auto",background:"#111217",borderRadius:"10px",boxShadow:"0 2px 16px rgba(0,0,0,0.6)",border:"1px solid #222"}},Hy=` @media (max-width: 768px) { .app-nav { padding: 0 16px !important; @@ -413,4 +441,4 @@ These require meaningful infrastructure additions and should be evaluated agains height: 24px !important; } } -`,Zt={footer:{borderTop:"1px solid #1a1b22",padding:"12px 40px",display:"flex",alignItems:"center",gap:"12px",fontSize:"11px",color:"rgba(248,249,250,0.35)",background:"#000",flexShrink:0},copy:{color:"rgba(248,249,250,0.35)"},sep:{color:"rgba(248,249,250,0.15)"},link:{color:"rgba(248,249,250,0.35)",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:"4px",transition:"color 0.15s"}};function Vy(){const[e,t]=k.useState("dashboard"),[n,r]=k.useState(!1),[o,i]=k.useState(!1),[l,a]=k.useState(null),[u,c]=k.useState(null),[p,m]=k.useState(!1),y=Wy("(max-width: 768px)");k.useEffect(()=>{fetch("/version.json").then(x=>x.ok?x.json():null).then(x=>{x&&a(x)}).catch(()=>{})},[]),k.useEffect(()=>{if(Ly(()=>c(null)),!zf()){m(!0);return}F.get("/api/auth/me").then(x=>c(x.data.user)).catch(()=>cs()).finally(()=>m(!0))},[]);const S=async()=>{try{await F.post("/api/auth/logout")}catch{}cs(),c(null)};return p?u?s.jsxs(oy,{children:[s.jsx("style",{children:Hy}),s.jsxs("div",{style:et.app,children:[s.jsxs("nav",{style:et.nav,className:"app-nav",children:[s.jsxs("div",{style:et.logoWrap,className:"logo-wrap",children:[s.jsx("img",{src:"/static/mpm-logo.png",alt:"MPM",style:et.logoImg,className:"logo-img"}),s.jsx("div",{style:et.logoText,className:"logo-text",children:"CPAS Tracker"})]}),s.jsx("div",{className:"nav-tabs",children:$y.map(x=>s.jsx("button",{style:et.tab(e===x.id),className:"nav-tab",onClick:()=>t(x.id),children:y?x.label.replace("📊 ","📊 ").replace("+ New ","+ "):x.label},x.id))}),s.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"10px"},children:[s.jsxs("span",{style:et.userBadge,title:`Signed in as ${u.username} (${u.role})`,children:["👤 ",u.username]}),u.role==="admin"&&s.jsx("button",{style:et.navBtn,onClick:()=>i(!0),title:"Manage user accounts",children:"Users"}),s.jsxs("button",{style:{...et.docsBtn,marginLeft:0},className:"docs-btn",onClick:()=>r(!0),title:"Open admin documentation",children:[s.jsx("span",{children:"?"})," Docs"]}),s.jsx("button",{style:et.navBtn,onClick:S,title:"Sign out",children:"Logout"})]})]}),s.jsx("div",{style:et.main,children:s.jsx("div",{style:et.card,className:"main-card",children:e==="dashboard"?s.jsx(Py,{}):s.jsx(uy,{})})}),s.jsx(Uy,{version:l}),n&&s.jsx(Oy,{onClose:()=>r(!1)}),o&&s.jsx(By,{currentUser:u,onClose:()=>i(!1)})]})]}):s.jsx(Fy,{onSuccess:c}):null}dl.createRoot(document.getElementById("root")).render(s.jsx(Yf.StrictMode,{children:s.jsx(Vy,{})})); +`,Zt={footer:{borderTop:"1px solid #1a1b22",padding:"12px 40px",display:"flex",alignItems:"center",gap:"12px",fontSize:"11px",color:"rgba(248,249,250,0.35)",background:"#000",flexShrink:0},copy:{color:"rgba(248,249,250,0.35)"},sep:{color:"rgba(248,249,250,0.15)"},link:{color:"rgba(248,249,250,0.35)",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:"4px",transition:"color 0.15s"}};function Vy(){const[e,t]=k.useState("dashboard"),[n,r]=k.useState(!1),[o,i]=k.useState(!1),[l,a]=k.useState(null),[u,c]=k.useState(null),[f,m]=k.useState(!1),y=Wy("(max-width: 768px)");k.useEffect(()=>{fetch("/version.json").then(x=>x.ok?x.json():null).then(x=>{x&&a(x)}).catch(()=>{})},[]),k.useEffect(()=>{if(Ly(()=>c(null)),!Pp()){m(!0);return}F.get("/api/auth/me").then(x=>c(x.data.user)).catch(()=>cs()).finally(()=>m(!0))},[]);const S=async()=>{try{await F.post("/api/auth/logout")}catch{}cs(),c(null)};return f?u?s.jsxs(oy,{children:[s.jsx("style",{children:Hy}),s.jsxs("div",{style:et.app,children:[s.jsxs("nav",{style:et.nav,className:"app-nav",children:[s.jsxs("div",{style:et.logoWrap,className:"logo-wrap",children:[s.jsx("img",{src:"/static/mpm-logo.png",alt:"MPM",style:et.logoImg,className:"logo-img"}),s.jsx("div",{style:et.logoText,className:"logo-text",children:"CPAS Tracker"})]}),s.jsx("div",{className:"nav-tabs",children:$y.map(x=>s.jsx("button",{style:et.tab(e===x.id),className:"nav-tab",onClick:()=>t(x.id),children:y?x.label.replace("📊 ","📊 ").replace("+ New ","+ "):x.label},x.id))}),s.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"10px"},children:[s.jsxs("span",{style:et.userBadge,title:`Signed in as ${u.username} (${u.role})`,children:["👤 ",u.username]}),u.role==="admin"&&s.jsx("button",{style:et.navBtn,onClick:()=>i(!0),title:"Manage user accounts",children:"Users"}),s.jsxs("button",{style:{...et.docsBtn,marginLeft:0},className:"docs-btn",onClick:()=>r(!0),title:"Open admin documentation",children:[s.jsx("span",{children:"?"})," Docs"]}),s.jsx("button",{style:et.navBtn,onClick:S,title:"Sign out",children:"Logout"})]})]}),s.jsx("div",{style:et.main,children:s.jsx("div",{style:et.card,className:"main-card",children:e==="dashboard"?s.jsx(Py,{}):s.jsx(uy,{})})}),s.jsx(Uy,{version:l}),n&&s.jsx(Oy,{onClose:()=>r(!1)}),o&&s.jsx(Iy,{currentUser:u,onClose:()=>i(!1)})]})]}):s.jsx(Fy,{onSuccess:c}):null}dl.createRoot(document.getElementById("root")).render(s.jsx(Kp.StrictMode,{children:s.jsx(Vy,{})})); diff --git a/client/dist/index.html b/client/dist/index.html index f881233..8eb5f4f 100644 --- a/client/dist/index.html +++ b/client/dist/index.html @@ -9,7 +9,7 @@ html, body { margin: 0; padding: 0; height: 100%; } #root { height: 100%; } - + diff --git a/client/src/components/ReadmeModal.jsx b/client/src/components/ReadmeModal.jsx index 2ee2bac..2d281dd 100644 --- a/client/src/components/ReadmeModal.jsx +++ b/client/src/components/ReadmeModal.jsx @@ -83,6 +83,33 @@ Internal tool for CPAS violation documentation, workforce standing management, a --- +## Authentication & User Accounts + +The application is protected by a login screen. Every page and every API action requires a valid signed-in session — unauthenticated visitors cannot view or edit any CPAS data. + +### Signing in + +Open the app and enter your username and password in the login popup. A session lasts **7 days**, after which you'll be asked to sign in again. Use the **Logout** button in the top-right of the nav bar to end your session immediately. + +### The bootstrap admin + +A single admin account is created automatically from the container's environment variables (\`ADMIN_USERNAME\` / \`ADMIN_PASSWORD\`). Notes: + +- Its password is **owned by the Docker environment** — it re-syncs on every container start. To rotate it, change \`ADMIN_PASSWORD\` in the container settings and restart. It cannot be changed from the UI (a UI change would be overwritten on the next restart). +- Set a strong \`ADMIN_PASSWORD\` at deploy time. The image ships with a placeholder default that must be overridden. + +### Managing users (admin only) + +Admins see a **Users** button in the nav bar that opens the user-management panel. From there you can: + +- **Add a user** — username, password (min 6 characters), and a role of **User** or **Admin**. +- **Reset a password** for any account. +- **Delete a user** — they lose access immediately. You cannot delete your own account. + +Roles: **Admin** can manage users plus everything a User can do; **User** can view and edit CPAS data but cannot manage accounts. Login attempts and all account changes are written to the audit log. + +--- + ## How Scoring Works Every violation carries a **point value** set at the time of submission. Points count toward an employee's score only within a **rolling 90-day window** — once a violation is older than 90 days it automatically drops off and the score recalculates. @@ -264,6 +291,7 @@ Toasts auto-dismiss after a few seconds (errors persist longer). Each toast has - Acknowledgment signature field — employee name + date on form and PDF - Toast notification system — global feedback for all user actions - Backfill Snapshots — per-employee repair tool that rebuilds the prior-points snapshot on every violation when older PDFs drift from current data +- Authentication — login screen gating all routes, env-bootstrapped admin account, and admin-managed user accounts with admin/user roles --- @@ -272,7 +300,7 @@ Toasts auto-dismiss after a few seconds (errors persist longer). Each toast has These are well-scoped additions that fit the current architecture without major changes. - **CSV export** — one endpoint returning violations or dashboard data as a downloadable CSV for payroll or external reporting. -- **Supervisor-scoped view** — filter the dashboard to a single supervisor's team via URL param; useful in multi-supervisor environments without requiring full auth. +- **Supervisor-scoped view** — filter the dashboard to a single supervisor's team via URL param; useful in multi-supervisor environments. --- @@ -291,7 +319,7 @@ Larger features that require more design work or infrastructure. These require meaningful infrastructure additions and should be evaluated against actual operational need before committing. -- **Multi-user auth** — role-based login (admin, supervisor, read-only). Currently the app assumes a trusted internal network with no authentication layer. +- **Expanded roles** — finer-grained permissions beyond the current admin/user split (e.g. supervisor-scoped or read-only roles). - **Tier escalation alerts** — email or in-app notification when an employee crosses into Tier 2+, automatically routed to their supervisor. - **Scheduled digest** — weekly email summary to supervisors showing their employees' current standings and any approaching thresholds. - **Automated DB backup** — scheduled snapshot of the database to a mounted backup volume or remote destination.
${u(x)}